@logtape/config 1.4.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +47 -0
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/config.cjs +80 -0
- package/dist/config.d.cts +26 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.ts +26 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +80 -0
- package/dist/config.js.map +1 -0
- package/dist/env.cjs +35 -0
- package/dist/env.d.cts +17 -0
- package/dist/env.d.cts.map +1 -0
- package/dist/env.d.ts +17 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +35 -0
- package/dist/env.js.map +1 -0
- package/dist/loader.cjs +94 -0
- package/dist/loader.js +94 -0
- package/dist/loader.js.map +1 -0
- package/dist/mod.cjs +9 -0
- package/dist/mod.d.cts +5 -0
- package/dist/mod.d.ts +5 -0
- package/dist/mod.js +6 -0
- package/dist/parser.cjs +43 -0
- package/dist/parser.js +43 -0
- package/dist/parser.js.map +1 -0
- package/dist/shorthands.cjs +46 -0
- package/dist/shorthands.d.cts +19 -0
- package/dist/shorthands.d.cts.map +1 -0
- package/dist/shorthands.d.ts +19 -0
- package/dist/shorthands.d.ts.map +1 -0
- package/dist/shorthands.js +45 -0
- package/dist/shorthands.js.map +1 -0
- package/dist/types.cjs +15 -0
- package/dist/types.d.cts +146 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +146 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","names":["parsed: ParsedModuleReference","shorthands: ShorthandRegistry","type: \"sinks\" | \"filters\" | \"formatters\"","mod: Record<string, unknown>","config: SinkConfig","sink: Sink","options: Record<string, unknown>","fmtOptions: Record<string, unknown>","config: FilterConfig"],"sources":["../src/loader.ts"],"sourcesContent":["import { parseModuleReference } from \"./parser.ts\";\nimport { ConfigError } from \"./types.ts\";\nimport type {\n FilterConfig,\n FormatterConfig,\n ParsedModuleReference,\n ShorthandRegistry,\n SinkConfig,\n} from \"./types.ts\";\nimport type { Filter, Sink } from \"@logtape/logtape\";\n\n/**\n * Loads a module and extracts the specified export.\n *\n * @param parsed Parsed module reference\n * @param shorthands Shorthand registry for resolving shorthands\n * @param type Type of shorthand (sinks, filters, formatters)\n * @returns The loaded module export\n * @since 1.4.0\n */\nexport async function loadModuleExport(\n parsed: ParsedModuleReference,\n shorthands: ShorthandRegistry,\n type: \"sinks\" | \"filters\" | \"formatters\",\n): Promise<unknown> {\n if (parsed.isShorthand) {\n const registry = shorthands[type];\n const resolved = registry ? registry[parsed.shorthandName!] : undefined;\n\n if (!resolved) {\n throw new ConfigError(\n `Unknown ${type.slice(0, -1)} shorthand: #${parsed.shorthandName}`,\n );\n }\n\n const resolvedParsed = parseModuleReference(resolved);\n // Inherit isFactory from the original shorthand usage if meaningful?\n // Actually, the resolved string decides the module and export.\n // The usage (with or without parens) decides if we call it.\n // But here we are just loading the export.\n return loadModuleExport(resolvedParsed, shorthands, type);\n }\n\n if (!parsed.modulePath) {\n throw new ConfigError(\"Module path is missing\");\n }\n\n let mod: Record<string, unknown>;\n try {\n mod = await import(parsed.modulePath);\n } catch (e) {\n throw new ConfigError(\n `Failed to load module ${parsed.modulePath}: ${e}`,\n );\n }\n\n const exportName = parsed.exportName ?? \"default\";\n const exported = mod[exportName];\n\n if (exported === undefined) {\n throw new ConfigError(\n `Module ${parsed.modulePath} does not have export '${exportName}'`,\n );\n }\n\n return exported;\n}\n\n/**\n * Creates a sink from configuration.\n *\n * @param config Sink configuration\n * @param shorthands Shorthand registry\n * @returns The created sink\n * @since 1.4.0\n */\nexport async function createSink(\n config: SinkConfig,\n shorthands: ShorthandRegistry,\n): Promise<Sink> {\n const parsed = parseModuleReference(config.type);\n const factory = await loadModuleExport(parsed, shorthands, \"sinks\");\n\n let sink: Sink;\n if (parsed.isFactory) {\n if (typeof factory !== \"function\") {\n throw new ConfigError(\n `Export ${parsed.exportName} in ${parsed.modulePath} is not a function, but invoked as factory`,\n );\n }\n\n // Process formatter if present\n const options: Record<string, unknown> = { ...config };\n delete options.type;\n\n if (options.formatter) {\n if (typeof options.formatter === \"string\") {\n const fmtParsed = parseModuleReference(options.formatter);\n const fmtFactory = await loadModuleExport(\n fmtParsed,\n shorthands,\n \"formatters\",\n );\n if (fmtParsed.isFactory) {\n if (typeof fmtFactory !== \"function\") {\n throw new ConfigError(\n `Formatter ${options.formatter} is not a function`,\n );\n }\n options.formatter = (fmtFactory as (opts?: unknown) => unknown)({});\n } else {\n options.formatter = fmtFactory;\n }\n } else {\n // FormatterConfig\n const fmtConfig = options.formatter as FormatterConfig;\n const fmtParsed = parseModuleReference(fmtConfig.type);\n const fmtFactory = await loadModuleExport(\n fmtParsed,\n shorthands,\n \"formatters\",\n );\n\n if (fmtParsed.isFactory) {\n if (typeof fmtFactory !== \"function\") {\n throw new ConfigError(\n `Formatter ${fmtConfig.type} is not a function`,\n );\n }\n const fmtOptions: Record<string, unknown> = { ...fmtConfig };\n delete fmtOptions.type;\n options.formatter = (fmtFactory as (opts: unknown) => unknown)(\n fmtOptions,\n );\n } else {\n options.formatter = fmtFactory;\n }\n }\n }\n\n sink = (factory as (opts: unknown) => Sink)(options);\n } else {\n sink = factory as Sink;\n }\n\n return sink;\n}\n\n/**\n * Creates a filter from configuration.\n *\n * @param config Filter configuration\n * @param shorthands Shorthand registry\n * @returns The created filter\n * @since 1.4.0\n */\nexport async function createFilter(\n config: FilterConfig,\n shorthands: ShorthandRegistry,\n): Promise<Filter> {\n const parsed = parseModuleReference(config.type);\n const factory = await loadModuleExport(parsed, shorthands, \"filters\");\n\n if (parsed.isFactory) {\n if (typeof factory !== \"function\") {\n throw new ConfigError(\n `Export ${parsed.exportName} in ${parsed.modulePath} is not a function, but invoked as factory`,\n );\n }\n const options: Record<string, unknown> = { ...config };\n delete options.type;\n return (factory as (opts: unknown) => Filter)(options);\n }\n\n return factory as Filter;\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,eAAsB,iBACpBA,QACAC,YACAC,MACkB;AAClB,KAAI,OAAO,aAAa;EACtB,MAAM,WAAW,WAAW;EAC5B,MAAM,WAAW,WAAW,SAAS,OAAO;AAE5C,OAAK,SACH,OAAM,IAAI,aACP,UAAU,KAAK,MAAM,GAAG,GAAG,CAAC,eAAe,OAAO,cAAc;EAIrE,MAAM,iBAAiB,qBAAqB,SAAS;AAKrD,SAAO,iBAAiB,gBAAgB,YAAY,KAAK;CAC1D;AAED,MAAK,OAAO,WACV,OAAM,IAAI,YAAY;CAGxB,IAAIC;AACJ,KAAI;AACF,QAAM,MAAM,OAAO,OAAO;CAC3B,SAAQ,GAAG;AACV,QAAM,IAAI,aACP,wBAAwB,OAAO,WAAW,IAAI,EAAE;CAEpD;CAED,MAAM,aAAa,OAAO,cAAc;CACxC,MAAM,WAAW,IAAI;AAErB,KAAI,oBACF,OAAM,IAAI,aACP,SAAS,OAAO,WAAW,yBAAyB,WAAW;AAIpE,QAAO;AACR;;;;;;;;;AAUD,eAAsB,WACpBC,QACAH,YACe;CACf,MAAM,SAAS,qBAAqB,OAAO,KAAK;CAChD,MAAM,UAAU,MAAM,iBAAiB,QAAQ,YAAY,QAAQ;CAEnE,IAAII;AACJ,KAAI,OAAO,WAAW;AACpB,aAAW,YAAY,WACrB,OAAM,IAAI,aACP,SAAS,OAAO,WAAW,MAAM,OAAO,WAAW;EAKxD,MAAMC,UAAmC,EAAE,GAAG,OAAQ;AACtD,SAAO,QAAQ;AAEf,MAAI,QAAQ,UACV,YAAW,QAAQ,cAAc,UAAU;GACzC,MAAM,YAAY,qBAAqB,QAAQ,UAAU;GACzD,MAAM,aAAa,MAAM,iBACvB,WACA,YACA,aACD;AACD,OAAI,UAAU,WAAW;AACvB,eAAW,eAAe,WACxB,OAAM,IAAI,aACP,YAAY,QAAQ,UAAU;AAGnC,YAAQ,YAAY,AAAC,WAA2C,CAAE,EAAC;GACpE,MACC,SAAQ,YAAY;EAEvB,OAAM;GAEL,MAAM,YAAY,QAAQ;GAC1B,MAAM,YAAY,qBAAqB,UAAU,KAAK;GACtD,MAAM,aAAa,MAAM,iBACvB,WACA,YACA,aACD;AAED,OAAI,UAAU,WAAW;AACvB,eAAW,eAAe,WACxB,OAAM,IAAI,aACP,YAAY,UAAU,KAAK;IAGhC,MAAMC,aAAsC,EAAE,GAAG,UAAW;AAC5D,WAAO,WAAW;AAClB,YAAQ,YAAY,AAAC,WACnB,WACD;GACF,MACC,SAAQ,YAAY;EAEvB;AAGH,SAAO,AAAC,QAAoC,QAAQ;CACrD,MACC,QAAO;AAGT,QAAO;AACR;;;;;;;;;AAUD,eAAsB,aACpBC,QACAP,YACiB;CACjB,MAAM,SAAS,qBAAqB,OAAO,KAAK;CAChD,MAAM,UAAU,MAAM,iBAAiB,QAAQ,YAAY,UAAU;AAErE,KAAI,OAAO,WAAW;AACpB,aAAW,YAAY,WACrB,OAAM,IAAI,aACP,SAAS,OAAO,WAAW,MAAM,OAAO,WAAW;EAGxD,MAAMK,UAAmC,EAAE,GAAG,OAAQ;AACtD,SAAO,QAAQ;AACf,SAAO,AAAC,QAAsC,QAAQ;CACvD;AAED,QAAO;AACR"}
|
package/dist/mod.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_types = require('./types.cjs');
|
|
2
|
+
const require_shorthands = require('./shorthands.cjs');
|
|
3
|
+
const require_config = require('./config.cjs');
|
|
4
|
+
const require_env = require('./env.cjs');
|
|
5
|
+
|
|
6
|
+
exports.ConfigError = require_types.ConfigError;
|
|
7
|
+
exports.DEFAULT_SHORTHANDS = require_shorthands.DEFAULT_SHORTHANDS;
|
|
8
|
+
exports.configureFromObject = require_config.configureFromObject;
|
|
9
|
+
exports.expandEnvVars = require_env.expandEnvVars;
|
package/dist/mod.d.cts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConfigError, ConfigureOptions, EnvExpansionOptions, FilterConfig, FormatterConfig, LogTapeConfig, LoggerConfig, ShorthandRegistry, SinkConfig } from "./types.cjs";
|
|
2
|
+
import { configureFromObject } from "./config.cjs";
|
|
3
|
+
import { expandEnvVars } from "./env.cjs";
|
|
4
|
+
import { DEFAULT_SHORTHANDS } from "./shorthands.cjs";
|
|
5
|
+
export { ConfigError, ConfigureOptions, DEFAULT_SHORTHANDS, EnvExpansionOptions, FilterConfig, FormatterConfig, LogTapeConfig, LoggerConfig, ShorthandRegistry, SinkConfig, configureFromObject, expandEnvVars };
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConfigError, ConfigureOptions, EnvExpansionOptions, FilterConfig, FormatterConfig, LogTapeConfig, LoggerConfig, ShorthandRegistry, SinkConfig } from "./types.js";
|
|
2
|
+
import { configureFromObject } from "./config.js";
|
|
3
|
+
import { expandEnvVars } from "./env.js";
|
|
4
|
+
import { DEFAULT_SHORTHANDS } from "./shorthands.js";
|
|
5
|
+
export { ConfigError, ConfigureOptions, DEFAULT_SHORTHANDS, EnvExpansionOptions, FilterConfig, FormatterConfig, LogTapeConfig, LoggerConfig, ShorthandRegistry, SinkConfig, configureFromObject, expandEnvVars };
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConfigError } from "./types.js";
|
|
2
|
+
import { DEFAULT_SHORTHANDS } from "./shorthands.js";
|
|
3
|
+
import { configureFromObject } from "./config.js";
|
|
4
|
+
import { expandEnvVars } from "./env.js";
|
|
5
|
+
|
|
6
|
+
export { ConfigError, DEFAULT_SHORTHANDS, configureFromObject, expandEnvVars };
|
package/dist/parser.cjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/parser.ts
|
|
3
|
+
/**
|
|
4
|
+
* Parses a module reference string.
|
|
5
|
+
*
|
|
6
|
+
* Formats:
|
|
7
|
+
* - `#shorthand()` - Shorthand with factory
|
|
8
|
+
* - `#shorthand` - Shorthand without factory
|
|
9
|
+
* - `module#export()` - Module with named export factory
|
|
10
|
+
* - `module#export` - Module with named export
|
|
11
|
+
* - `module()` - Module with default export factory
|
|
12
|
+
* - `module` - Module with default export
|
|
13
|
+
*
|
|
14
|
+
* @param reference The module reference string
|
|
15
|
+
* @returns Parsed module reference
|
|
16
|
+
* @since 1.4.0
|
|
17
|
+
*/
|
|
18
|
+
function parseModuleReference(reference) {
|
|
19
|
+
const isShorthand = reference.startsWith("#");
|
|
20
|
+
const isFactory = reference.endsWith("()");
|
|
21
|
+
const cleanRef = isFactory ? reference.slice(0, -2) : reference;
|
|
22
|
+
if (isShorthand) return {
|
|
23
|
+
isShorthand: true,
|
|
24
|
+
shorthandName: cleanRef.slice(1),
|
|
25
|
+
isFactory
|
|
26
|
+
};
|
|
27
|
+
const hashIndex = cleanRef.indexOf("#");
|
|
28
|
+
if (hashIndex !== -1) return {
|
|
29
|
+
isShorthand: false,
|
|
30
|
+
modulePath: cleanRef.slice(0, hashIndex),
|
|
31
|
+
exportName: cleanRef.slice(hashIndex + 1),
|
|
32
|
+
isFactory
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
isShorthand: false,
|
|
36
|
+
modulePath: cleanRef,
|
|
37
|
+
exportName: "default",
|
|
38
|
+
isFactory
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.parseModuleReference = parseModuleReference;
|
package/dist/parser.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/parser.ts
|
|
2
|
+
/**
|
|
3
|
+
* Parses a module reference string.
|
|
4
|
+
*
|
|
5
|
+
* Formats:
|
|
6
|
+
* - `#shorthand()` - Shorthand with factory
|
|
7
|
+
* - `#shorthand` - Shorthand without factory
|
|
8
|
+
* - `module#export()` - Module with named export factory
|
|
9
|
+
* - `module#export` - Module with named export
|
|
10
|
+
* - `module()` - Module with default export factory
|
|
11
|
+
* - `module` - Module with default export
|
|
12
|
+
*
|
|
13
|
+
* @param reference The module reference string
|
|
14
|
+
* @returns Parsed module reference
|
|
15
|
+
* @since 1.4.0
|
|
16
|
+
*/
|
|
17
|
+
function parseModuleReference(reference) {
|
|
18
|
+
const isShorthand = reference.startsWith("#");
|
|
19
|
+
const isFactory = reference.endsWith("()");
|
|
20
|
+
const cleanRef = isFactory ? reference.slice(0, -2) : reference;
|
|
21
|
+
if (isShorthand) return {
|
|
22
|
+
isShorthand: true,
|
|
23
|
+
shorthandName: cleanRef.slice(1),
|
|
24
|
+
isFactory
|
|
25
|
+
};
|
|
26
|
+
const hashIndex = cleanRef.indexOf("#");
|
|
27
|
+
if (hashIndex !== -1) return {
|
|
28
|
+
isShorthand: false,
|
|
29
|
+
modulePath: cleanRef.slice(0, hashIndex),
|
|
30
|
+
exportName: cleanRef.slice(hashIndex + 1),
|
|
31
|
+
isFactory
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
isShorthand: false,
|
|
35
|
+
modulePath: cleanRef,
|
|
36
|
+
exportName: "default",
|
|
37
|
+
isFactory
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { parseModuleReference };
|
|
43
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","names":["reference: string"],"sources":["../src/parser.ts"],"sourcesContent":["import type { ParsedModuleReference } from \"./types.ts\";\n\n/**\n * Parses a module reference string.\n *\n * Formats:\n * - `#shorthand()` - Shorthand with factory\n * - `#shorthand` - Shorthand without factory\n * - `module#export()` - Module with named export factory\n * - `module#export` - Module with named export\n * - `module()` - Module with default export factory\n * - `module` - Module with default export\n *\n * @param reference The module reference string\n * @returns Parsed module reference\n * @since 1.4.0\n */\nexport function parseModuleReference(reference: string): ParsedModuleReference {\n const isShorthand = reference.startsWith(\"#\");\n const isFactory = reference.endsWith(\"()\");\n const cleanRef = isFactory ? reference.slice(0, -2) : reference;\n\n if (isShorthand) {\n return {\n isShorthand: true,\n shorthandName: cleanRef.slice(1),\n isFactory,\n };\n }\n\n const hashIndex = cleanRef.indexOf(\"#\");\n if (hashIndex !== -1) {\n return {\n isShorthand: false,\n modulePath: cleanRef.slice(0, hashIndex),\n exportName: cleanRef.slice(hashIndex + 1),\n isFactory,\n };\n }\n\n return {\n isShorthand: false,\n modulePath: cleanRef,\n exportName: \"default\",\n isFactory,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,qBAAqBA,WAA0C;CAC7E,MAAM,cAAc,UAAU,WAAW,IAAI;CAC7C,MAAM,YAAY,UAAU,SAAS,KAAK;CAC1C,MAAM,WAAW,YAAY,UAAU,MAAM,GAAG,GAAG,GAAG;AAEtD,KAAI,YACF,QAAO;EACL,aAAa;EACb,eAAe,SAAS,MAAM,EAAE;EAChC;CACD;CAGH,MAAM,YAAY,SAAS,QAAQ,IAAI;AACvC,KAAI,cAAc,GAChB,QAAO;EACL,aAAa;EACb,YAAY,SAAS,MAAM,GAAG,UAAU;EACxC,YAAY,SAAS,MAAM,YAAY,EAAE;EACzC;CACD;AAGH,QAAO;EACL,aAAa;EACb,YAAY;EACZ,YAAY;EACZ;CACD;AACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/shorthands.ts
|
|
3
|
+
/**
|
|
4
|
+
* Default shorthand mappings for built-in sinks and formatters.
|
|
5
|
+
* @since 1.4.0
|
|
6
|
+
*/
|
|
7
|
+
const DEFAULT_SHORTHANDS = {
|
|
8
|
+
sinks: {
|
|
9
|
+
console: "@logtape/logtape#getConsoleSink",
|
|
10
|
+
stream: "@logtape/logtape#getStreamSink"
|
|
11
|
+
},
|
|
12
|
+
filters: {},
|
|
13
|
+
formatters: {
|
|
14
|
+
text: "@logtape/logtape#getTextFormatter",
|
|
15
|
+
ansiColor: "@logtape/logtape#getAnsiColorFormatter",
|
|
16
|
+
jsonLines: "@logtape/logtape#getJsonLinesFormatter"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Merges user shorthands with default shorthands.
|
|
21
|
+
* @param defaults Default shorthands
|
|
22
|
+
* @param custom Custom shorthands
|
|
23
|
+
* @returns Merged shorthands
|
|
24
|
+
* @since 1.4.0
|
|
25
|
+
*/
|
|
26
|
+
function mergeShorthands(defaults, custom) {
|
|
27
|
+
if (!custom) return defaults;
|
|
28
|
+
return {
|
|
29
|
+
sinks: {
|
|
30
|
+
...defaults.sinks,
|
|
31
|
+
...custom.sinks
|
|
32
|
+
},
|
|
33
|
+
filters: {
|
|
34
|
+
...defaults.filters,
|
|
35
|
+
...custom.filters
|
|
36
|
+
},
|
|
37
|
+
formatters: {
|
|
38
|
+
...defaults.formatters,
|
|
39
|
+
...custom.formatters
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.DEFAULT_SHORTHANDS = DEFAULT_SHORTHANDS;
|
|
46
|
+
exports.mergeShorthands = mergeShorthands;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ShorthandRegistry } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/shorthands.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Default shorthand mappings for built-in sinks and formatters.
|
|
7
|
+
* @since 1.4.0
|
|
8
|
+
*/
|
|
9
|
+
declare const DEFAULT_SHORTHANDS: ShorthandRegistry;
|
|
10
|
+
/**
|
|
11
|
+
* Merges user shorthands with default shorthands.
|
|
12
|
+
* @param defaults Default shorthands
|
|
13
|
+
* @param custom Custom shorthands
|
|
14
|
+
* @returns Merged shorthands
|
|
15
|
+
* @since 1.4.0
|
|
16
|
+
*/
|
|
17
|
+
//#endregion
|
|
18
|
+
export { DEFAULT_SHORTHANDS };
|
|
19
|
+
//# sourceMappingURL=shorthands.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shorthands.d.cts","names":[],"sources":["../src/shorthands.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;cAAa,oBAAoB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ShorthandRegistry } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/shorthands.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Default shorthand mappings for built-in sinks and formatters.
|
|
7
|
+
* @since 1.4.0
|
|
8
|
+
*/
|
|
9
|
+
declare const DEFAULT_SHORTHANDS: ShorthandRegistry;
|
|
10
|
+
/**
|
|
11
|
+
* Merges user shorthands with default shorthands.
|
|
12
|
+
* @param defaults Default shorthands
|
|
13
|
+
* @param custom Custom shorthands
|
|
14
|
+
* @returns Merged shorthands
|
|
15
|
+
* @since 1.4.0
|
|
16
|
+
*/
|
|
17
|
+
//#endregion
|
|
18
|
+
export { DEFAULT_SHORTHANDS };
|
|
19
|
+
//# sourceMappingURL=shorthands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shorthands.d.ts","names":[],"sources":["../src/shorthands.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;cAAa,oBAAoB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/shorthands.ts
|
|
2
|
+
/**
|
|
3
|
+
* Default shorthand mappings for built-in sinks and formatters.
|
|
4
|
+
* @since 1.4.0
|
|
5
|
+
*/
|
|
6
|
+
const DEFAULT_SHORTHANDS = {
|
|
7
|
+
sinks: {
|
|
8
|
+
console: "@logtape/logtape#getConsoleSink",
|
|
9
|
+
stream: "@logtape/logtape#getStreamSink"
|
|
10
|
+
},
|
|
11
|
+
filters: {},
|
|
12
|
+
formatters: {
|
|
13
|
+
text: "@logtape/logtape#getTextFormatter",
|
|
14
|
+
ansiColor: "@logtape/logtape#getAnsiColorFormatter",
|
|
15
|
+
jsonLines: "@logtape/logtape#getJsonLinesFormatter"
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Merges user shorthands with default shorthands.
|
|
20
|
+
* @param defaults Default shorthands
|
|
21
|
+
* @param custom Custom shorthands
|
|
22
|
+
* @returns Merged shorthands
|
|
23
|
+
* @since 1.4.0
|
|
24
|
+
*/
|
|
25
|
+
function mergeShorthands(defaults, custom) {
|
|
26
|
+
if (!custom) return defaults;
|
|
27
|
+
return {
|
|
28
|
+
sinks: {
|
|
29
|
+
...defaults.sinks,
|
|
30
|
+
...custom.sinks
|
|
31
|
+
},
|
|
32
|
+
filters: {
|
|
33
|
+
...defaults.filters,
|
|
34
|
+
...custom.filters
|
|
35
|
+
},
|
|
36
|
+
formatters: {
|
|
37
|
+
...defaults.formatters,
|
|
38
|
+
...custom.formatters
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { DEFAULT_SHORTHANDS, mergeShorthands };
|
|
45
|
+
//# sourceMappingURL=shorthands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shorthands.js","names":["DEFAULT_SHORTHANDS: ShorthandRegistry","defaults: ShorthandRegistry","custom?: ShorthandRegistry"],"sources":["../src/shorthands.ts"],"sourcesContent":["import type { ShorthandRegistry } from \"./types.ts\";\n\n/**\n * Default shorthand mappings for built-in sinks and formatters.\n * @since 1.4.0\n */\nexport const DEFAULT_SHORTHANDS: ShorthandRegistry = {\n sinks: {\n console: \"@logtape/logtape#getConsoleSink\",\n stream: \"@logtape/logtape#getStreamSink\",\n },\n filters: {},\n formatters: {\n text: \"@logtape/logtape#getTextFormatter\",\n ansiColor: \"@logtape/logtape#getAnsiColorFormatter\",\n jsonLines: \"@logtape/logtape#getJsonLinesFormatter\",\n },\n};\n\n/**\n * Merges user shorthands with default shorthands.\n * @param defaults Default shorthands\n * @param custom Custom shorthands\n * @returns Merged shorthands\n * @since 1.4.0\n */\nexport function mergeShorthands(\n defaults: ShorthandRegistry,\n custom?: ShorthandRegistry,\n): ShorthandRegistry {\n if (!custom) return defaults;\n\n return {\n sinks: { ...defaults.sinks, ...custom.sinks },\n filters: { ...defaults.filters, ...custom.filters },\n formatters: { ...defaults.formatters, ...custom.formatters },\n };\n}\n"],"mappings":";;;;;AAMA,MAAaA,qBAAwC;CACnD,OAAO;EACL,SAAS;EACT,QAAQ;CACT;CACD,SAAS,CAAE;CACX,YAAY;EACV,MAAM;EACN,WAAW;EACX,WAAW;CACZ;AACF;;;;;;;;AASD,SAAgB,gBACdC,UACAC,QACmB;AACnB,MAAK,OAAQ,QAAO;AAEpB,QAAO;EACL,OAAO;GAAE,GAAG,SAAS;GAAO,GAAG,OAAO;EAAO;EAC7C,SAAS;GAAE,GAAG,SAAS;GAAS,GAAG,OAAO;EAAS;EACnD,YAAY;GAAE,GAAG,SAAS;GAAY,GAAG,OAAO;EAAY;CAC7D;AACF"}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/types.ts
|
|
3
|
+
/**
|
|
4
|
+
* Error thrown when configuration is invalid.
|
|
5
|
+
* @since 1.4.0
|
|
6
|
+
*/
|
|
7
|
+
var ConfigError = class extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "ConfigError";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.ConfigError = ConfigError;
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { LogLevel } from "@logtape/logtape";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration object schema for `configureFromObject()`.
|
|
7
|
+
* @since 1.4.0
|
|
8
|
+
*/
|
|
9
|
+
interface LogTapeConfig {
|
|
10
|
+
/**
|
|
11
|
+
* The sinks to configure.
|
|
12
|
+
*/
|
|
13
|
+
sinks?: Record<string, SinkConfig>;
|
|
14
|
+
/**
|
|
15
|
+
* The filters to configure.
|
|
16
|
+
*/
|
|
17
|
+
filters?: Record<string, FilterConfig>;
|
|
18
|
+
/**
|
|
19
|
+
* The loggers to configure.
|
|
20
|
+
*/
|
|
21
|
+
loggers?: LoggerConfig[];
|
|
22
|
+
/**
|
|
23
|
+
* Whether to reset the configuration before applying this one.
|
|
24
|
+
*/
|
|
25
|
+
reset?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Sink configuration with module reference.
|
|
29
|
+
* @since 1.4.0
|
|
30
|
+
*/
|
|
31
|
+
interface SinkConfig {
|
|
32
|
+
/** Module reference in `module#export()` format */
|
|
33
|
+
type: string;
|
|
34
|
+
/** Formatter configuration or shorthand */
|
|
35
|
+
formatter?: string | FormatterConfig;
|
|
36
|
+
/** Additional options passed to the factory function */
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Filter configuration with module reference.
|
|
41
|
+
* @since 1.4.0
|
|
42
|
+
*/
|
|
43
|
+
interface FilterConfig {
|
|
44
|
+
/** Module reference in `module#export()` format */
|
|
45
|
+
type: string;
|
|
46
|
+
/** Additional options passed to the factory function */
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Formatter configuration with module reference.
|
|
51
|
+
* @since 1.4.0
|
|
52
|
+
*/
|
|
53
|
+
interface FormatterConfig {
|
|
54
|
+
/** Module reference in `module#export()` format */
|
|
55
|
+
type: string;
|
|
56
|
+
/** Additional options passed to the factory function */
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Logger configuration.
|
|
61
|
+
* @since 1.4.0
|
|
62
|
+
*/
|
|
63
|
+
interface LoggerConfig {
|
|
64
|
+
/**
|
|
65
|
+
* The category of the logger.
|
|
66
|
+
*/
|
|
67
|
+
category: string | string[];
|
|
68
|
+
/**
|
|
69
|
+
* The sink identifiers to use.
|
|
70
|
+
*/
|
|
71
|
+
sinks?: string[];
|
|
72
|
+
/**
|
|
73
|
+
* The filter identifiers to use.
|
|
74
|
+
*/
|
|
75
|
+
filters?: string[];
|
|
76
|
+
/**
|
|
77
|
+
* The lowest log level to log.
|
|
78
|
+
*/
|
|
79
|
+
lowestLevel?: LogLevel;
|
|
80
|
+
/**
|
|
81
|
+
* Whether to inherit the parent's sinks.
|
|
82
|
+
*/
|
|
83
|
+
parentSinks?: "inherit" | "override";
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Registry of shorthand mappings.
|
|
87
|
+
* @since 1.4.0
|
|
88
|
+
*/
|
|
89
|
+
interface ShorthandRegistry {
|
|
90
|
+
/**
|
|
91
|
+
* The shorthand mappings for sinks.
|
|
92
|
+
*/
|
|
93
|
+
sinks?: Record<string, string>;
|
|
94
|
+
/**
|
|
95
|
+
* The shorthand mappings for filters.
|
|
96
|
+
*/
|
|
97
|
+
filters?: Record<string, string>;
|
|
98
|
+
/**
|
|
99
|
+
* The shorthand mappings for formatters.
|
|
100
|
+
*/
|
|
101
|
+
formatters?: Record<string, string>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Options for `configureFromObject()`.
|
|
105
|
+
* @since 1.4.0
|
|
106
|
+
*/
|
|
107
|
+
interface ConfigureOptions {
|
|
108
|
+
/**
|
|
109
|
+
* Custom shorthand mappings to extend or override defaults.
|
|
110
|
+
*/
|
|
111
|
+
shorthands?: ShorthandRegistry;
|
|
112
|
+
/**
|
|
113
|
+
* How to handle invalid configuration entries.
|
|
114
|
+
*
|
|
115
|
+
* - `"throw"` (default): Throw `ConfigError` on any invalid configuration.
|
|
116
|
+
* - `"warn"`: Apply only valid parts and log warnings to meta logger.
|
|
117
|
+
*/
|
|
118
|
+
onInvalidConfig?: "throw" | "warn";
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Options for environment variable expansion.
|
|
122
|
+
* @since 1.4.0
|
|
123
|
+
*/
|
|
124
|
+
interface EnvExpansionOptions {
|
|
125
|
+
/**
|
|
126
|
+
* Regular expression pattern for matching environment variables.
|
|
127
|
+
* Default: `/\$\{([^}:]+)(?::([^}]+))?\}/g` (matches `${VAR}` or `${VAR:default}`)
|
|
128
|
+
*/
|
|
129
|
+
pattern?: RegExp;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Parsed module reference.
|
|
133
|
+
* @since 1.4.0
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Error thrown when configuration is invalid.
|
|
138
|
+
* @since 1.4.0
|
|
139
|
+
*/
|
|
140
|
+
declare class ConfigError extends Error {
|
|
141
|
+
constructor(message: string);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=types.d.ts.map
|
|
144
|
+
//#endregion
|
|
145
|
+
export { ConfigError, ConfigureOptions, EnvExpansionOptions, FilterConfig, FormatterConfig, LogTapeConfig, LoggerConfig, ShorthandRegistry, SinkConfig };
|
|
146
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;AAIyB,UAJR,aAAA,CAIQ;EAAU;;;EAKjB,KAKN,CAAA,EAVF,MAUE,CAAA,MAAA,EAVa,UAUb,CAAA;EAAY;AAYxB;AAaA;EAWiB,OAAA,CAAA,EAzCL,MAyCK,CAAA,MAAe,EAzCL,YAyCK,CAAA;EAWf;AA+BjB;;EAAkC,OAIxB,CAAA,EAlFE,YAkFF,EAAA;EAAM;;AAUK;EAOJ,KAAA,CAAA,EAAA,OAAA;AAmBjB;AA6BA;;;;UAvIiB,UAAA;;;;uBAIM;;;;;;;;UASN,YAAA;;;;;;;;;;UAWA,eAAA;;;;;;;;;;UAWA,YAAA;;;;;;;;;;;;;;;;gBAmBD;;;;;;;;;;UAYC,iBAAA;;;;UAIP;;;;YAKE;;;;eAKG;;;;;;UAOE,gBAAA;;;;eAIF;;;;;;;;;;;;;UAeE,mBAAA;;;;;YAKL;;;;;;;;;;;cAwBC,WAAA,SAAoB,KAAK"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { LogLevel } from "@logtape/logtape";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration object schema for `configureFromObject()`.
|
|
7
|
+
* @since 1.4.0
|
|
8
|
+
*/
|
|
9
|
+
interface LogTapeConfig {
|
|
10
|
+
/**
|
|
11
|
+
* The sinks to configure.
|
|
12
|
+
*/
|
|
13
|
+
sinks?: Record<string, SinkConfig>;
|
|
14
|
+
/**
|
|
15
|
+
* The filters to configure.
|
|
16
|
+
*/
|
|
17
|
+
filters?: Record<string, FilterConfig>;
|
|
18
|
+
/**
|
|
19
|
+
* The loggers to configure.
|
|
20
|
+
*/
|
|
21
|
+
loggers?: LoggerConfig[];
|
|
22
|
+
/**
|
|
23
|
+
* Whether to reset the configuration before applying this one.
|
|
24
|
+
*/
|
|
25
|
+
reset?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Sink configuration with module reference.
|
|
29
|
+
* @since 1.4.0
|
|
30
|
+
*/
|
|
31
|
+
interface SinkConfig {
|
|
32
|
+
/** Module reference in `module#export()` format */
|
|
33
|
+
type: string;
|
|
34
|
+
/** Formatter configuration or shorthand */
|
|
35
|
+
formatter?: string | FormatterConfig;
|
|
36
|
+
/** Additional options passed to the factory function */
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Filter configuration with module reference.
|
|
41
|
+
* @since 1.4.0
|
|
42
|
+
*/
|
|
43
|
+
interface FilterConfig {
|
|
44
|
+
/** Module reference in `module#export()` format */
|
|
45
|
+
type: string;
|
|
46
|
+
/** Additional options passed to the factory function */
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Formatter configuration with module reference.
|
|
51
|
+
* @since 1.4.0
|
|
52
|
+
*/
|
|
53
|
+
interface FormatterConfig {
|
|
54
|
+
/** Module reference in `module#export()` format */
|
|
55
|
+
type: string;
|
|
56
|
+
/** Additional options passed to the factory function */
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Logger configuration.
|
|
61
|
+
* @since 1.4.0
|
|
62
|
+
*/
|
|
63
|
+
interface LoggerConfig {
|
|
64
|
+
/**
|
|
65
|
+
* The category of the logger.
|
|
66
|
+
*/
|
|
67
|
+
category: string | string[];
|
|
68
|
+
/**
|
|
69
|
+
* The sink identifiers to use.
|
|
70
|
+
*/
|
|
71
|
+
sinks?: string[];
|
|
72
|
+
/**
|
|
73
|
+
* The filter identifiers to use.
|
|
74
|
+
*/
|
|
75
|
+
filters?: string[];
|
|
76
|
+
/**
|
|
77
|
+
* The lowest log level to log.
|
|
78
|
+
*/
|
|
79
|
+
lowestLevel?: LogLevel;
|
|
80
|
+
/**
|
|
81
|
+
* Whether to inherit the parent's sinks.
|
|
82
|
+
*/
|
|
83
|
+
parentSinks?: "inherit" | "override";
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Registry of shorthand mappings.
|
|
87
|
+
* @since 1.4.0
|
|
88
|
+
*/
|
|
89
|
+
interface ShorthandRegistry {
|
|
90
|
+
/**
|
|
91
|
+
* The shorthand mappings for sinks.
|
|
92
|
+
*/
|
|
93
|
+
sinks?: Record<string, string>;
|
|
94
|
+
/**
|
|
95
|
+
* The shorthand mappings for filters.
|
|
96
|
+
*/
|
|
97
|
+
filters?: Record<string, string>;
|
|
98
|
+
/**
|
|
99
|
+
* The shorthand mappings for formatters.
|
|
100
|
+
*/
|
|
101
|
+
formatters?: Record<string, string>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Options for `configureFromObject()`.
|
|
105
|
+
* @since 1.4.0
|
|
106
|
+
*/
|
|
107
|
+
interface ConfigureOptions {
|
|
108
|
+
/**
|
|
109
|
+
* Custom shorthand mappings to extend or override defaults.
|
|
110
|
+
*/
|
|
111
|
+
shorthands?: ShorthandRegistry;
|
|
112
|
+
/**
|
|
113
|
+
* How to handle invalid configuration entries.
|
|
114
|
+
*
|
|
115
|
+
* - `"throw"` (default): Throw `ConfigError` on any invalid configuration.
|
|
116
|
+
* - `"warn"`: Apply only valid parts and log warnings to meta logger.
|
|
117
|
+
*/
|
|
118
|
+
onInvalidConfig?: "throw" | "warn";
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Options for environment variable expansion.
|
|
122
|
+
* @since 1.4.0
|
|
123
|
+
*/
|
|
124
|
+
interface EnvExpansionOptions {
|
|
125
|
+
/**
|
|
126
|
+
* Regular expression pattern for matching environment variables.
|
|
127
|
+
* Default: `/\$\{([^}:]+)(?::([^}]+))?\}/g` (matches `${VAR}` or `${VAR:default}`)
|
|
128
|
+
*/
|
|
129
|
+
pattern?: RegExp;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Parsed module reference.
|
|
133
|
+
* @since 1.4.0
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Error thrown when configuration is invalid.
|
|
138
|
+
* @since 1.4.0
|
|
139
|
+
*/
|
|
140
|
+
declare class ConfigError extends Error {
|
|
141
|
+
constructor(message: string);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=types.d.ts.map
|
|
144
|
+
//#endregion
|
|
145
|
+
export { ConfigError, ConfigureOptions, EnvExpansionOptions, FilterConfig, FormatterConfig, LogTapeConfig, LoggerConfig, ShorthandRegistry, SinkConfig };
|
|
146
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;AAIyB,UAJR,aAAA,CAIQ;EAAU;;;EAKjB,KAKN,CAAA,EAVF,MAUE,CAAA,MAAA,EAVa,UAUb,CAAA;EAAY;AAYxB;AAaA;EAWiB,OAAA,CAAA,EAzCL,MAyCK,CAAA,MAAe,EAzCL,YAyCK,CAAA;EAWf;AA+BjB;;EAAkC,OAIxB,CAAA,EAlFE,YAkFF,EAAA;EAAM;;AAUK;EAOJ,KAAA,CAAA,EAAA,OAAA;AAmBjB;AA6BA;;;;UAvIiB,UAAA;;;;uBAIM;;;;;;;;UASN,YAAA;;;;;;;;;;UAWA,eAAA;;;;;;;;;;UAWA,YAAA;;;;;;;;;;;;;;;;gBAmBD;;;;;;;;;;UAYC,iBAAA;;;;UAIP;;;;YAKE;;;;eAKG;;;;;;UAOE,gBAAA;;;;eAIF;;;;;;;;;;;;;UAeE,mBAAA;;;;;YAKL;;;;;;;;;;;cAwBC,WAAA,SAAoB,KAAK"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when configuration is invalid.
|
|
4
|
+
* @since 1.4.0
|
|
5
|
+
*/
|
|
6
|
+
var ConfigError = class extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "ConfigError";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ConfigError };
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":["message: string"],"sources":["../src/types.ts"],"sourcesContent":["import type { LogLevel } from \"@logtape/logtape\";\n\n/**\n * Configuration object schema for `configureFromObject()`.\n * @since 1.4.0\n */\nexport interface LogTapeConfig {\n /**\n * The sinks to configure.\n */\n sinks?: Record<string, SinkConfig>;\n\n /**\n * The filters to configure.\n */\n filters?: Record<string, FilterConfig>;\n\n /**\n * The loggers to configure.\n */\n loggers?: LoggerConfig[];\n\n /**\n * Whether to reset the configuration before applying this one.\n */\n reset?: boolean;\n}\n\n/**\n * Sink configuration with module reference.\n * @since 1.4.0\n */\nexport interface SinkConfig {\n /** Module reference in `module#export()` format */\n type: string;\n /** Formatter configuration or shorthand */\n formatter?: string | FormatterConfig;\n /** Additional options passed to the factory function */\n [key: string]: unknown;\n}\n\n/**\n * Filter configuration with module reference.\n * @since 1.4.0\n */\nexport interface FilterConfig {\n /** Module reference in `module#export()` format */\n type: string;\n /** Additional options passed to the factory function */\n [key: string]: unknown;\n}\n\n/**\n * Formatter configuration with module reference.\n * @since 1.4.0\n */\nexport interface FormatterConfig {\n /** Module reference in `module#export()` format */\n type: string;\n /** Additional options passed to the factory function */\n [key: string]: unknown;\n}\n\n/**\n * Logger configuration.\n * @since 1.4.0\n */\nexport interface LoggerConfig {\n /**\n * The category of the logger.\n */\n category: string | string[];\n\n /**\n * The sink identifiers to use.\n */\n sinks?: string[];\n\n /**\n * The filter identifiers to use.\n */\n filters?: string[];\n\n /**\n * The lowest log level to log.\n */\n lowestLevel?: LogLevel;\n\n /**\n * Whether to inherit the parent's sinks.\n */\n parentSinks?: \"inherit\" | \"override\";\n}\n\n/**\n * Registry of shorthand mappings.\n * @since 1.4.0\n */\nexport interface ShorthandRegistry {\n /**\n * The shorthand mappings for sinks.\n */\n sinks?: Record<string, string>;\n\n /**\n * The shorthand mappings for filters.\n */\n filters?: Record<string, string>;\n\n /**\n * The shorthand mappings for formatters.\n */\n formatters?: Record<string, string>;\n}\n\n/**\n * Options for `configureFromObject()`.\n * @since 1.4.0\n */\nexport interface ConfigureOptions {\n /**\n * Custom shorthand mappings to extend or override defaults.\n */\n shorthands?: ShorthandRegistry;\n\n /**\n * How to handle invalid configuration entries.\n *\n * - `\"throw\"` (default): Throw `ConfigError` on any invalid configuration.\n * - `\"warn\"`: Apply only valid parts and log warnings to meta logger.\n */\n onInvalidConfig?: \"throw\" | \"warn\";\n}\n\n/**\n * Options for environment variable expansion.\n * @since 1.4.0\n */\nexport interface EnvExpansionOptions {\n /**\n * Regular expression pattern for matching environment variables.\n * Default: `/\\$\\{([^}:]+)(?::([^}]+))?\\}/g` (matches `${VAR}` or `${VAR:default}`)\n */\n pattern?: RegExp;\n}\n\n/**\n * Parsed module reference.\n * @since 1.4.0\n */\nexport interface ParsedModuleReference {\n /** Whether this is a shorthand (starts with #) */\n isShorthand: boolean;\n /** The shorthand name (if isShorthand is true) */\n shorthandName?: string;\n /** The module path */\n modulePath?: string;\n /** The export name (after #) */\n exportName?: string;\n /** Whether this is a factory function (ends with ()) */\n isFactory: boolean;\n}\n\n/**\n * Error thrown when configuration is invalid.\n * @since 1.4.0\n */\nexport class ConfigError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigError\";\n }\n}\n"],"mappings":";;;;;AAuKA,IAAa,cAAb,cAAiC,MAAM;CACrC,YAAYA,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;CACb;AACF"}
|