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?
optionalautoStage:boolean
Defined in: types.ts:251
Whether to automatically stage resolved files. Default: true.
backupDir?
optionalbackupDir:string
Defined in: types.ts:236
Directory for backing up original files before modification.
byStrategy?
Defined in: types.ts:202
Reverse mapping: strategy → list of field globs.
customStrategies?
optionalcustomStrategies:Record<Exclude<ForbidBangEnd<T>,InbuiltMergeStrategies>,StrategyFn<TContext>>
Defined in: types.ts:205
Custom strategies (names must not clash with built-ins).
debug?
optionaldebug:boolean
Defined in: types.ts:227
Enable debug mode for verbose logs and traceability (slower).
defaultStrategy?
optionaldefaultStrategy:T|T[]
Defined in: types.ts:196
Fallback strategy when no rule matches.
exclude?
optionalexclude:string[]
Defined in: types.ts:214
File exclusion globs.
include?
optionalinclude:string[]
Defined in: types.ts:211
File inclusion globs.
includeNonConflicted?
optionalincludeNonConflicted: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?
optionalloggerConfig:LoggerConfig
Defined in: types.ts:233
Logger configuration.
matcher?
optionalmatcher:Matcher|"micromatch"|"picomatch"
Defined in: types.ts:217
Glob matcher: "micromatch", "picomatch", or a custom implementation. Defaults to internal minimal matcher
parsers?
optionalparsers:"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?
optionalpluginConfig:Partial<PluginConfigs>
Defined in: types.ts:257
Plugin-specific configuration passed to plugin.init().
plugins?
optionalplugins:string[]
Defined in: types.ts:254
NPM package names of strategy plugins to load.
rules?
optionalrules:RuleTree<T>
Defined in: types.ts:199
Rule tree mapping globs → strategies.
writeConflictSidecar?
optionalwriteConflictSidecar:boolean
Defined in: types.ts:230
Whether to write sidecar files with unresolved conflicts.
LoggerConfig
Defined in: types.ts:151
Logger configuration.
Properties
levels?
optionallevels: {file?:LogLevel[];stdout?:LogLevel[]; }
Defined in: types.ts:162
Level filters for stdout and file logging.
file?
optionalfile:LogLevel[]
Levels to write into files (default: ["info", "warn", "error"]).
stdout?
optionalstdout:LogLevel[]
Levels to print on stdout (default: ["warn", "error"]).
logDir?
optionallogDir:string
Defined in: types.ts:156
Directory for log files (default: "logs").
mode?
optionalmode:LogMode
Defined in: types.ts:153
Logging mode (default: "memory").
singleFile?
optionalsingleFile: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()?
optionalinit(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| keyofPluginStrategies
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<typeofcreateLogger>>;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: typeofStrategyStatus_OK;value:unknown; } | {reason?:string;status: typeofStrategyStatus_CONTINUE; } | {reason:string;status: typeofStrategyStatus_SKIP; } | {reason:string;status: typeofStrategyStatus_FAIL; }
Defined in: types.ts:48
Union type representing the outcome of a strategy function.
StrategyStatus
StrategyStatus = typeof
StrategyStatus_OK| typeofStrategyStatus_CONTINUE| typeofStrategyStatus_FAIL| typeofStrategyStatus_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