types

Modules

Interfaces

Config<T, TContext>

Defined in: types.ts:194

High-level configuration object for conflict resolution.

Type Parameters

T

T extends string = AllStrategies

Strategy string type (defaults to built-in strategies).

TContext

TContext = unknown

Context object type passed to strategies.

Properties

autoStage?

optional autoStage: boolean

Defined in: types.ts:251

Whether to automatically stage resolved files. Default: true.

backupDir?

optional backupDir: string

Defined in: types.ts:236

Directory for backing up original files before modification.

byStrategy?

optional byStrategy: Partial<Record<T, string[]>>

Defined in: types.ts:202

Reverse mapping: strategy → list of field globs.

customStrategies?

optional customStrategies: Record<Exclude<ForbidBangEnd<T>, InbuiltMergeStrategies>, StrategyFn<TContext>>

Defined in: types.ts:205

Custom strategies (names must not clash with built-ins).

debug?

optional debug: boolean

Defined in: types.ts:227

Enable debug mode for verbose logs and traceability (slower).

defaultStrategy?

optional defaultStrategy: T | T[]

Defined in: types.ts:196

Fallback strategy when no rule matches.

exclude?

optional exclude: string[]

Defined in: types.ts:214

File exclusion globs.

include?

optional include: string[]

Defined in: types.ts:211

File inclusion globs.

includeNonConflicted?

optional includeNonConflicted: boolean

Defined in: types.ts:224

Whether to include files that do not contain conflicts. Useful if strategies (e.g., “drop”) should apply even to clean files. Default: false.

loggerConfig?

optional loggerConfig: LoggerConfig

Defined in: types.ts:233

Logger configuration.

matcher?

optional matcher: Matcher | "micromatch" | "picomatch"

Defined in: types.ts:217

Glob matcher: "micromatch", "picomatch", or a custom implementation. Defaults to internal minimal matcher

parsers?

optional parsers: "auto" | SupportedParsers | SupportedParsers[]

Defined in: types.ts:245

Parsers to attempt, in order:

  • A single parser ("json", "yaml", custom function, etc.).
  • An array of parsers (e.g. ["yaml", "json5"]).

Defaults to "json".

pluginConfig?

optional pluginConfig: Partial<PluginConfigs>

Defined in: types.ts:257

Plugin-specific configuration passed to plugin.init().

plugins?

optional plugins: string[]

Defined in: types.ts:254

NPM package names of strategy plugins to load.

rules?

optional rules: RuleTree<T>

Defined in: types.ts:199

Rule tree mapping globs → strategies.

writeConflictSidecar?

optional writeConflictSidecar: boolean

Defined in: types.ts:230

Whether to write sidecar files with unresolved conflicts.


LoggerConfig

Defined in: types.ts:151

Logger configuration.

Properties

levels?

optional levels: { file?: LogLevel[]; stdout?: LogLevel[]; }

Defined in: types.ts:162

Level filters for stdout and file logging.

file?

optional file: LogLevel[]

Levels to write into files (default: ["info", "warn", "error"]).

stdout?

optional stdout: LogLevel[]

Levels to print on stdout (default: ["warn", "error"]).

logDir?

optional logDir: string

Defined in: types.ts:156

Directory for log files (default: "logs").

mode?

optional mode: LogMode

Defined in: types.ts:153

Logging mode (default: "memory").

singleFile?

optional singleFile: boolean

Defined in: types.ts:159

Whether to log into a single file instead of per-input-file logs.


PluginConfigs

Defined in: types.ts:128

Interface for plugin-specific configuration. Plugins augment this interface with their own config types.

Example plugin declaration:

declare module "git-json-resolver" {
  interface PluginConfigs {
    "git-json-resolver-semver": {
      strict?: boolean;
      fallback?: "ours" | "theirs" | "continue" | "error";
      preferValid?: boolean;
      preferRange?: boolean;
      workspacePattern?: string;
    };
  }
}

Indexable

[pluginName: string]: Record<string, unknown>


PluginStrategies

Defined in: types.ts:102

Interface for plugin-contributed strategies. Plugins should augment this interface to add their strategy names.

Example plugin declaration:

declare module "git-json-resolver" {
  interface PluginStrategies {
    "semantic-version": string;
    "timestamp-latest": string;
  }
}

StrategyPlugin<TContext>

Defined in: types.ts:180

Plugin interface that strategy plugins must implement.

Type Parameters

TContext

TContext = unknown

Properties

strategies

strategies: Record<string, StrategyFn<TContext>>

Defined in: types.ts:182

Strategy functions provided by this plugin.

Methods

init()?

optional init(config: Record<string, unknown>): void | Promise<void>

Defined in: types.ts:185

Optional plugin initialization with config.

Parameters
config

Record<string, unknown>

Returns

void | Promise<void>

Type Aliases

AllStrategies

AllStrategies = InbuiltMergeStrategies | keyof PluginStrategies

Defined in: types.ts:107

All available strategy names (built-in + plugins).


InbuiltMergeStrategies

InbuiltMergeStrategies = "merge" | "ours" | "theirs" | "base" | "skip" | "drop" | "non-empty" | "update" | "concat" | "unique"

Defined in: types.ts:27

Built-in merge strategies. ⚠️ Reserved names — plugin authors should avoid reusing these.

Strategy Description
merge Deep merge objects/arrays where possible; conflicts bubble up otherwise.
ours Always take the value from “ours”.
theirs Always take the value from “theirs”.
base Revert to the common ancestor (“base”).
skip Leave unresolved; conflict entry is created with undefined.
drop Remove the field entirely (always).
non-empty Prefer non-empty value: ours > theirs > base; fallback to undefined.
update Update with “theirs” if field exists in “ours”; drop if missing in “ours”.
concat Concatenate arrays from both sides (applies only if both are arrays).
unique Merge arrays and remove duplicates (applies only if both are arrays).

LogLevel

LogLevel = "info" | "warn" | "error" | "debug"

Defined in: types.ts:143

Logging levels available to the logger.


LogMode

LogMode = "memory" | "stream"

Defined in: types.ts:146

Logging modes: in-memory or streaming to files.


Parser

Parser = { name: string; parser: (input: string) => unknown; }

Defined in: types.ts:172

A parser function that takes a raw string and returns parsed content.

Properties

name

name: string

Defined in: types.ts:172

parser()

parser: (input: string) => unknown

Defined in: types.ts:172

Parameters
input

string

Returns

unknown


RuleTree<T>

RuleTree<T> = {[fieldGlob: string]: RuleTree<T> | T[]; }

Defined in: types.ts:138

Rule tree: maps field glob patterns → strategy names or nested rule trees.

  • Keys: field glob patterns (matcher configurable)
  • Values: one or more strategies, or further nested rules

Type Parameters

T

T extends string = AllStrategies

Index Signature

[fieldGlob: string]: RuleTree<T> | T[]


StrategyFn()<TContext>

StrategyFn<TContext> = (args: { base?: unknown; context?: TContext; filePath?: string; logger: Awaited<ReturnType<typeof createLogger>>; ours: unknown; path: string; theirs: unknown; }) => StrategyResult | Promise<StrategyResult>

Defined in: types.ts:59

Strategy function signature.

Type Parameters

TContext

TContext = unknown

Optional context type passed during resolution.

Parameters

args
base?

unknown

Value from common ancestor (if available).

context?

TContext

Custom context object, if provided by caller.

filePath?

string

Full file path of the file being merged.

logger

Awaited<ReturnType<typeof createLogger>>

logger

ours

unknown

Value from “ours”.

path

string

JSON path of the current field.

theirs

unknown

Value from “theirs”.

Returns

StrategyResult | Promise<StrategyResult>


StrategyResult

StrategyResult = { status: typeof StrategyStatus_OK; value: unknown; } | { reason?: string; status: typeof StrategyStatus_CONTINUE; } | { reason: string; status: typeof StrategyStatus_SKIP; } | { reason: string; status: typeof StrategyStatus_FAIL; }

Defined in: types.ts:48

Union type representing the outcome of a strategy function.


StrategyStatus

StrategyStatus = typeof StrategyStatus_OK | typeof StrategyStatus_CONTINUE | typeof StrategyStatus_FAIL | typeof StrategyStatus_SKIP

Defined in: types.ts:39


SupportedParsers

SupportedParsers = "json" | "json5" | "yaml" | "toml" | "xml" | Parser

Defined in: types.ts:175

Built-in parser identifiers or a custom parser function.

References

Matcher

Re-exports Matcher