@logtape/config 1.4.0-dev.466 → 2.0.0-dev.469
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/README.md +2 -2
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/env.cjs +1 -1
- package/dist/env.d.cts +1 -1
- package/dist/env.d.ts +1 -1
- package/dist/env.js +1 -1
- package/dist/env.js.map +1 -1
- package/dist/loader.cjs +3 -3
- package/dist/loader.js +3 -3
- package/dist/loader.js.map +1 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.js +1 -1
- package/dist/parser.js.map +1 -1
- package/dist/shorthands.cjs +2 -2
- package/dist/shorthands.d.cts +2 -2
- package/dist/shorthands.d.ts +2 -2
- package/dist/shorthands.js +2 -2
- package/dist/shorthands.js.map +1 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +10 -10
- package/dist/types.d.ts +10 -10
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
This package provides functionality to configure [LogTape] from plain objects,
|
|
8
8
|
such as those loaded from JSON or YAML files.
|
|
9
9
|
|
|
10
|
-
[JSR]: https://jsr.io/@logtape/config
|
|
11
10
|
[JSR badge]: https://jsr.io/badges/@logtape/config
|
|
12
|
-
[
|
|
11
|
+
[JSR]: https://jsr.io/@logtape/config
|
|
13
12
|
[npm badge]: https://img.shields.io/npm/v/@logtape/config?logo=npm
|
|
13
|
+
[npm]: https://www.npmjs.com/package/@logtape/config
|
|
14
14
|
[LogTape]: https://logtape.org/
|
|
15
15
|
|
|
16
16
|
|
package/dist/config.cjs
CHANGED
|
@@ -20,7 +20,7 @@ const __logtape_logtape = require_rolldown_runtime.__toESM(require("@logtape/log
|
|
|
20
20
|
* const config = JSON.parse(await readFile("./logtape.json", "utf-8"));
|
|
21
21
|
* await configureFromObject(config);
|
|
22
22
|
* ```
|
|
23
|
-
* @since
|
|
23
|
+
* @since 2.0.0
|
|
24
24
|
*/
|
|
25
25
|
async function configureFromObject(config, options) {
|
|
26
26
|
const shorthands = require_shorthands.mergeShorthands(require_shorthands.DEFAULT_SHORTHANDS, options?.shorthands);
|
package/dist/config.d.cts
CHANGED
|
@@ -17,7 +17,7 @@ import { ConfigureOptions, LogTapeConfig } from "./types.cjs";
|
|
|
17
17
|
* const config = JSON.parse(await readFile("./logtape.json", "utf-8"));
|
|
18
18
|
* await configureFromObject(config);
|
|
19
19
|
* ```
|
|
20
|
-
* @since
|
|
20
|
+
* @since 2.0.0
|
|
21
21
|
*/
|
|
22
22
|
declare function configureFromObject(config: LogTapeConfig, options?: ConfigureOptions): Promise<void>;
|
|
23
23
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { ConfigureOptions, LogTapeConfig } from "./types.js";
|
|
|
17
17
|
* const config = JSON.parse(await readFile("./logtape.json", "utf-8"));
|
|
18
18
|
* await configureFromObject(config);
|
|
19
19
|
* ```
|
|
20
|
-
* @since
|
|
20
|
+
* @since 2.0.0
|
|
21
21
|
*/
|
|
22
22
|
declare function configureFromObject(config: LogTapeConfig, options?: ConfigureOptions): Promise<void>;
|
|
23
23
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.js
CHANGED
|
@@ -19,7 +19,7 @@ import { configure, getLogger } from "@logtape/logtape";
|
|
|
19
19
|
* const config = JSON.parse(await readFile("./logtape.json", "utf-8"));
|
|
20
20
|
* await configureFromObject(config);
|
|
21
21
|
* ```
|
|
22
|
-
* @since
|
|
22
|
+
* @since 2.0.0
|
|
23
23
|
*/
|
|
24
24
|
async function configureFromObject(config, options) {
|
|
25
25
|
const shorthands = mergeShorthands(DEFAULT_SHORTHANDS, options?.shorthands);
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["config: LogTapeConfig","options?: ConfigureOptions","warnings: string[]","sinks: Record<string, Sink>","filters: Record<string, Filter>","logTapeConfig: Config<string, string>","validSinks: string[]","validFilters: string[]"],"sources":["../src/config.ts"],"sourcesContent":["import { configure, getLogger } from \"@logtape/logtape\";\nimport type { Config, Filter, Sink } from \"@logtape/logtape\";\nimport { createFilter, createSink } from \"./loader.ts\";\nimport { DEFAULT_SHORTHANDS, mergeShorthands } from \"./shorthands.ts\";\nimport { ConfigError } from \"./types.ts\";\nimport type { ConfigureOptions, LogTapeConfig } from \"./types.ts\";\n\n/**\n * Configures LogTape from a plain object.\n *\n * @param config Configuration object (typically loaded from JSON/YAML/TOML)\n * @param options Configuration options\n * @throws {ConfigError} If configuration is invalid and onInvalidConfig is \"throw\"\n *\n * @example\n * ```typescript\n * import { configureFromObject } from \"@logtape/config\";\n * import { readFile } from \"fs/promises\";\n *\n * const config = JSON.parse(await readFile(\"./logtape.json\", \"utf-8\"));\n * await configureFromObject(config);\n * ```\n * @since
|
|
1
|
+
{"version":3,"file":"config.js","names":["config: LogTapeConfig","options?: ConfigureOptions","warnings: string[]","sinks: Record<string, Sink>","filters: Record<string, Filter>","logTapeConfig: Config<string, string>","validSinks: string[]","validFilters: string[]"],"sources":["../src/config.ts"],"sourcesContent":["import { configure, getLogger } from \"@logtape/logtape\";\nimport type { Config, Filter, Sink } from \"@logtape/logtape\";\nimport { createFilter, createSink } from \"./loader.ts\";\nimport { DEFAULT_SHORTHANDS, mergeShorthands } from \"./shorthands.ts\";\nimport { ConfigError } from \"./types.ts\";\nimport type { ConfigureOptions, LogTapeConfig } from \"./types.ts\";\n\n/**\n * Configures LogTape from a plain object.\n *\n * @param config Configuration object (typically loaded from JSON/YAML/TOML)\n * @param options Configuration options\n * @throws {ConfigError} If configuration is invalid and onInvalidConfig is \"throw\"\n *\n * @example\n * ```typescript\n * import { configureFromObject } from \"@logtape/config\";\n * import { readFile } from \"fs/promises\";\n *\n * const config = JSON.parse(await readFile(\"./logtape.json\", \"utf-8\"));\n * await configureFromObject(config);\n * ```\n * @since 2.0.0\n */\nexport async function configureFromObject(\n config: LogTapeConfig,\n options?: ConfigureOptions,\n): Promise<void> {\n const shorthands = mergeShorthands(\n DEFAULT_SHORTHANDS,\n options?.shorthands,\n );\n const onInvalidConfig = options?.onInvalidConfig ?? \"throw\";\n const warnings: string[] = [];\n\n // 1. Create sinks\n const sinks: Record<string, Sink> = {};\n if (config.sinks) {\n for (const [name, sinkConfig] of Object.entries(config.sinks)) {\n try {\n sinks[name] = await createSink(sinkConfig, shorthands);\n } catch (e) {\n if (onInvalidConfig === \"throw\") {\n throw e;\n }\n warnings.push(`Failed to create sink '${name}': ${e}`);\n }\n }\n }\n\n // 2. Create filters\n const filters: Record<string, Filter> = {};\n if (config.filters) {\n for (const [name, filterConfig] of Object.entries(config.filters)) {\n try {\n filters[name] = await createFilter(filterConfig, shorthands);\n } catch (e) {\n if (onInvalidConfig === \"throw\") {\n throw e;\n }\n warnings.push(`Failed to create filter '${name}': ${e}`);\n }\n }\n }\n\n // 3. Configure logtape\n const logTapeConfig: Config<string, string> = {\n sinks,\n filters,\n loggers: [],\n };\n\n if (config.loggers) {\n for (const loggerConfig of config.loggers) {\n // Validate sink references\n const validSinks: string[] = [];\n if (loggerConfig.sinks) {\n for (const sinkName of loggerConfig.sinks) {\n if (sinkName in sinks) {\n validSinks.push(sinkName);\n } else {\n const msg = `Logger '${\n Array.isArray(loggerConfig.category)\n ? loggerConfig.category.join(\".\")\n : loggerConfig.category\n }' references unknown or failed sink '${sinkName}'`;\n if (onInvalidConfig === \"throw\") {\n throw new ConfigError(msg);\n }\n warnings.push(msg);\n }\n }\n }\n\n // Validate filter references\n const validFilters: string[] = [];\n if (loggerConfig.filters) {\n for (const filterName of loggerConfig.filters) {\n if (filterName in filters) {\n validFilters.push(filterName);\n } else {\n const msg = `Logger '${\n Array.isArray(loggerConfig.category)\n ? loggerConfig.category.join(\".\")\n : loggerConfig.category\n }' references unknown or failed filter '${filterName}'`;\n if (onInvalidConfig === \"throw\") {\n throw new ConfigError(msg);\n }\n warnings.push(msg);\n }\n }\n }\n\n logTapeConfig.loggers.push({\n category: loggerConfig.category,\n sinks: validSinks.length > 0 ? validSinks : undefined,\n filters: validFilters.length > 0 ? validFilters : undefined,\n lowestLevel: loggerConfig.lowestLevel,\n parentSinks: loggerConfig.parentSinks,\n });\n }\n }\n\n if (config.reset) {\n logTapeConfig.reset = true;\n }\n\n await configure(logTapeConfig);\n\n // 4. Log warnings to meta logger\n if (warnings.length > 0) {\n const metaLogger = getLogger([\"logtape\", \"meta\"]);\n for (const warning of warnings) {\n metaLogger.warn(warning);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,eAAsB,oBACpBA,QACAC,SACe;CACf,MAAM,aAAa,gBACjB,oBACA,SAAS,WACV;CACD,MAAM,kBAAkB,SAAS,mBAAmB;CACpD,MAAMC,WAAqB,CAAE;CAG7B,MAAMC,QAA8B,CAAE;AACtC,KAAI,OAAO,MACT,MAAK,MAAM,CAAC,MAAM,WAAW,IAAI,OAAO,QAAQ,OAAO,MAAM,CAC3D,KAAI;AACF,QAAM,QAAQ,MAAM,WAAW,YAAY,WAAW;CACvD,SAAQ,GAAG;AACV,MAAI,oBAAoB,QACtB,OAAM;AAER,WAAS,MAAM,yBAAyB,KAAK,KAAK,EAAE,EAAE;CACvD;CAKL,MAAMC,UAAkC,CAAE;AAC1C,KAAI,OAAO,QACT,MAAK,MAAM,CAAC,MAAM,aAAa,IAAI,OAAO,QAAQ,OAAO,QAAQ,CAC/D,KAAI;AACF,UAAQ,QAAQ,MAAM,aAAa,cAAc,WAAW;CAC7D,SAAQ,GAAG;AACV,MAAI,oBAAoB,QACtB,OAAM;AAER,WAAS,MAAM,2BAA2B,KAAK,KAAK,EAAE,EAAE;CACzD;CAKL,MAAMC,gBAAwC;EAC5C;EACA;EACA,SAAS,CAAE;CACZ;AAED,KAAI,OAAO,QACT,MAAK,MAAM,gBAAgB,OAAO,SAAS;EAEzC,MAAMC,aAAuB,CAAE;AAC/B,MAAI,aAAa,MACf,MAAK,MAAM,YAAY,aAAa,MAClC,KAAI,YAAY,MACd,YAAW,KAAK,SAAS;OACpB;GACL,MAAM,OAAO,UACX,MAAM,QAAQ,aAAa,SAAS,GAChC,aAAa,SAAS,KAAK,IAAI,GAC/B,aAAa,SAClB,uCAAuC,SAAS;AACjD,OAAI,oBAAoB,QACtB,OAAM,IAAI,YAAY;AAExB,YAAS,KAAK,IAAI;EACnB;EAKL,MAAMC,eAAyB,CAAE;AACjC,MAAI,aAAa,QACf,MAAK,MAAM,cAAc,aAAa,QACpC,KAAI,cAAc,QAChB,cAAa,KAAK,WAAW;OACxB;GACL,MAAM,OAAO,UACX,MAAM,QAAQ,aAAa,SAAS,GAChC,aAAa,SAAS,KAAK,IAAI,GAC/B,aAAa,SAClB,yCAAyC,WAAW;AACrD,OAAI,oBAAoB,QACtB,OAAM,IAAI,YAAY;AAExB,YAAS,KAAK,IAAI;EACnB;AAIL,gBAAc,QAAQ,KAAK;GACzB,UAAU,aAAa;GACvB,OAAO,WAAW,SAAS,IAAI;GAC/B,SAAS,aAAa,SAAS,IAAI;GACnC,aAAa,aAAa;GAC1B,aAAa,aAAa;EAC3B,EAAC;CACH;AAGH,KAAI,OAAO,MACT,eAAc,QAAQ;AAGxB,OAAM,UAAU,cAAc;AAG9B,KAAI,SAAS,SAAS,GAAG;EACvB,MAAM,aAAa,UAAU,CAAC,WAAW,MAAO,EAAC;AACjD,OAAK,MAAM,WAAW,SACpB,YAAW,KAAK,QAAQ;CAE3B;AACF"}
|
package/dist/env.cjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param config Configuration object
|
|
7
7
|
* @param options Expansion options
|
|
8
8
|
* @returns Configuration with expanded environment variables
|
|
9
|
-
* @since
|
|
9
|
+
* @since 2.0.0
|
|
10
10
|
*/
|
|
11
11
|
function expandEnvVars(config, options) {
|
|
12
12
|
const pattern = options?.pattern ?? /\$\{([^}:]+)(?::([^}]+))?\}/g;
|
package/dist/env.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ import { EnvExpansionOptions } from "./types.cjs";
|
|
|
8
8
|
* @param config Configuration object
|
|
9
9
|
* @param options Expansion options
|
|
10
10
|
* @returns Configuration with expanded environment variables
|
|
11
|
-
* @since
|
|
11
|
+
* @since 2.0.0
|
|
12
12
|
*/
|
|
13
13
|
declare function expandEnvVars<T extends object>(config: T, options?: EnvExpansionOptions): T;
|
|
14
14
|
//# sourceMappingURL=env.d.ts.map
|
package/dist/env.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { EnvExpansionOptions } from "./types.js";
|
|
|
8
8
|
* @param config Configuration object
|
|
9
9
|
* @param options Expansion options
|
|
10
10
|
* @returns Configuration with expanded environment variables
|
|
11
|
-
* @since
|
|
11
|
+
* @since 2.0.0
|
|
12
12
|
*/
|
|
13
13
|
declare function expandEnvVars<T extends object>(config: T, options?: EnvExpansionOptions): T;
|
|
14
14
|
//# sourceMappingURL=env.d.ts.map
|
package/dist/env.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param config Configuration object
|
|
6
6
|
* @param options Expansion options
|
|
7
7
|
* @returns Configuration with expanded environment variables
|
|
8
|
-
* @since
|
|
8
|
+
* @since 2.0.0
|
|
9
9
|
*/
|
|
10
10
|
function expandEnvVars(config, options) {
|
|
11
11
|
const pattern = options?.pattern ?? /\$\{([^}:]+)(?::([^}]+))?\}/g;
|
package/dist/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","names":["config: T","options?: EnvExpansionOptions","value: string","val: string | undefined","obj: unknown","result: Record<string, unknown>"],"sources":["../src/env.ts"],"sourcesContent":["import type { EnvExpansionOptions } from \"./types.ts\";\n\n/**\n * Expands environment variables in a configuration object.\n *\n * @param config Configuration object\n * @param options Expansion options\n * @returns Configuration with expanded environment variables\n * @since
|
|
1
|
+
{"version":3,"file":"env.js","names":["config: T","options?: EnvExpansionOptions","value: string","val: string | undefined","obj: unknown","result: Record<string, unknown>"],"sources":["../src/env.ts"],"sourcesContent":["import type { EnvExpansionOptions } from \"./types.ts\";\n\n/**\n * Expands environment variables in a configuration object.\n *\n * @param config Configuration object\n * @param options Expansion options\n * @returns Configuration with expanded environment variables\n * @since 2.0.0\n */\nexport function expandEnvVars<T extends object>(\n config: T,\n options?: EnvExpansionOptions,\n): T {\n const pattern = options?.pattern ?? /\\$\\{([^}:]+)(?::([^}]+))?\\}/g;\n\n function replace(value: string): string {\n return value.replace(pattern, (_, key, defaultValue) => {\n let val: string | undefined;\n // deno-lint-ignore no-explicit-any\n if (typeof (globalThis as any).process?.env === \"object\") {\n // Node.js / Bun\n // deno-lint-ignore no-explicit-any\n val = (globalThis as any).process.env[key];\n } else if (typeof Deno !== \"undefined\") {\n // Deno\n val = Deno.env.get(key);\n }\n\n return val ?? defaultValue ?? \"\";\n });\n }\n\n function walk(obj: unknown): unknown {\n if (typeof obj === \"string\") {\n return replace(obj);\n }\n if (Array.isArray(obj)) {\n return obj.map(walk);\n }\n if (obj !== null && typeof obj === \"object\") {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = walk(value);\n }\n return result;\n }\n return obj;\n }\n\n return walk(config) as T;\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,cACdA,QACAC,SACG;CACH,MAAM,UAAU,SAAS,WAAW;CAEpC,SAAS,QAAQC,OAAuB;AACtC,SAAO,MAAM,QAAQ,SAAS,CAAC,GAAG,KAAK,iBAAiB;GACtD,IAAIC;AAEJ,cAAY,WAAmB,SAAS,QAAQ,SAG9C,OAAO,WAAmB,QAAQ,IAAI;mBACtB,SAAS,YAEzB,OAAM,KAAK,IAAI,IAAI,IAAI;AAGzB,UAAO,OAAO,gBAAgB;EAC/B,EAAC;CACH;CAED,SAAS,KAAKC,KAAuB;AACnC,aAAW,QAAQ,SACjB,QAAO,QAAQ,IAAI;AAErB,MAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,IAAI,KAAK;AAEtB,MAAI,QAAQ,eAAe,QAAQ,UAAU;GAC3C,MAAMC,SAAkC,CAAE;AAC1C,QAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,IAAI,CAC5C,QAAO,OAAO,KAAK,MAAM;AAE3B,UAAO;EACR;AACD,SAAO;CACR;AAED,QAAO,KAAK,OAAO;AACpB"}
|
package/dist/loader.cjs
CHANGED
|
@@ -9,7 +9,7 @@ const require_types = require('./types.cjs');
|
|
|
9
9
|
* @param shorthands Shorthand registry for resolving shorthands
|
|
10
10
|
* @param type Type of shorthand (sinks, filters, formatters)
|
|
11
11
|
* @returns The loaded module export
|
|
12
|
-
* @since
|
|
12
|
+
* @since 2.0.0
|
|
13
13
|
*/
|
|
14
14
|
async function loadModuleExport(parsed, shorthands, type) {
|
|
15
15
|
if (parsed.isShorthand) {
|
|
@@ -37,7 +37,7 @@ async function loadModuleExport(parsed, shorthands, type) {
|
|
|
37
37
|
* @param config Sink configuration
|
|
38
38
|
* @param shorthands Shorthand registry
|
|
39
39
|
* @returns The created sink
|
|
40
|
-
* @since
|
|
40
|
+
* @since 2.0.0
|
|
41
41
|
*/
|
|
42
42
|
async function createSink(config, shorthands) {
|
|
43
43
|
const parsed = require_parser.parseModuleReference(config.type);
|
|
@@ -75,7 +75,7 @@ async function createSink(config, shorthands) {
|
|
|
75
75
|
* @param config Filter configuration
|
|
76
76
|
* @param shorthands Shorthand registry
|
|
77
77
|
* @returns The created filter
|
|
78
|
-
* @since
|
|
78
|
+
* @since 2.0.0
|
|
79
79
|
*/
|
|
80
80
|
async function createFilter(config, shorthands) {
|
|
81
81
|
const parsed = require_parser.parseModuleReference(config.type);
|
package/dist/loader.js
CHANGED
|
@@ -9,7 +9,7 @@ import { ConfigError } from "./types.js";
|
|
|
9
9
|
* @param shorthands Shorthand registry for resolving shorthands
|
|
10
10
|
* @param type Type of shorthand (sinks, filters, formatters)
|
|
11
11
|
* @returns The loaded module export
|
|
12
|
-
* @since
|
|
12
|
+
* @since 2.0.0
|
|
13
13
|
*/
|
|
14
14
|
async function loadModuleExport(parsed, shorthands, type) {
|
|
15
15
|
if (parsed.isShorthand) {
|
|
@@ -37,7 +37,7 @@ async function loadModuleExport(parsed, shorthands, type) {
|
|
|
37
37
|
* @param config Sink configuration
|
|
38
38
|
* @param shorthands Shorthand registry
|
|
39
39
|
* @returns The created sink
|
|
40
|
-
* @since
|
|
40
|
+
* @since 2.0.0
|
|
41
41
|
*/
|
|
42
42
|
async function createSink(config, shorthands) {
|
|
43
43
|
const parsed = parseModuleReference(config.type);
|
|
@@ -75,7 +75,7 @@ async function createSink(config, shorthands) {
|
|
|
75
75
|
* @param config Filter configuration
|
|
76
76
|
* @param shorthands Shorthand registry
|
|
77
77
|
* @returns The created filter
|
|
78
|
-
* @since
|
|
78
|
+
* @since 2.0.0
|
|
79
79
|
*/
|
|
80
80
|
async function createFilter(config, shorthands) {
|
|
81
81
|
const parsed = parseModuleReference(config.type);
|
package/dist/loader.js.map
CHANGED
|
@@ -1 +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
|
+
{"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 2.0.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 2.0.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 2.0.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/parser.cjs
CHANGED
package/dist/parser.js
CHANGED
package/dist/parser.js.map
CHANGED
|
@@ -1 +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
|
+
{"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 2.0.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"}
|
package/dist/shorthands.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//#region src/shorthands.ts
|
|
3
3
|
/**
|
|
4
4
|
* Default shorthand mappings for built-in sinks and formatters.
|
|
5
|
-
* @since
|
|
5
|
+
* @since 2.0.0
|
|
6
6
|
*/
|
|
7
7
|
const DEFAULT_SHORTHANDS = {
|
|
8
8
|
sinks: {
|
|
@@ -21,7 +21,7 @@ const DEFAULT_SHORTHANDS = {
|
|
|
21
21
|
* @param defaults Default shorthands
|
|
22
22
|
* @param custom Custom shorthands
|
|
23
23
|
* @returns Merged shorthands
|
|
24
|
-
* @since
|
|
24
|
+
* @since 2.0.0
|
|
25
25
|
*/
|
|
26
26
|
function mergeShorthands(defaults, custom) {
|
|
27
27
|
if (!custom) return defaults;
|
package/dist/shorthands.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ import { ShorthandRegistry } from "./types.cjs";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Default shorthand mappings for built-in sinks and formatters.
|
|
7
|
-
* @since
|
|
7
|
+
* @since 2.0.0
|
|
8
8
|
*/
|
|
9
9
|
declare const DEFAULT_SHORTHANDS: ShorthandRegistry;
|
|
10
10
|
/**
|
|
@@ -12,7 +12,7 @@ declare const DEFAULT_SHORTHANDS: ShorthandRegistry;
|
|
|
12
12
|
* @param defaults Default shorthands
|
|
13
13
|
* @param custom Custom shorthands
|
|
14
14
|
* @returns Merged shorthands
|
|
15
|
-
* @since
|
|
15
|
+
* @since 2.0.0
|
|
16
16
|
*/
|
|
17
17
|
//#endregion
|
|
18
18
|
export { DEFAULT_SHORTHANDS };
|
package/dist/shorthands.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ShorthandRegistry } from "./types.js";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Default shorthand mappings for built-in sinks and formatters.
|
|
7
|
-
* @since
|
|
7
|
+
* @since 2.0.0
|
|
8
8
|
*/
|
|
9
9
|
declare const DEFAULT_SHORTHANDS: ShorthandRegistry;
|
|
10
10
|
/**
|
|
@@ -12,7 +12,7 @@ declare const DEFAULT_SHORTHANDS: ShorthandRegistry;
|
|
|
12
12
|
* @param defaults Default shorthands
|
|
13
13
|
* @param custom Custom shorthands
|
|
14
14
|
* @returns Merged shorthands
|
|
15
|
-
* @since
|
|
15
|
+
* @since 2.0.0
|
|
16
16
|
*/
|
|
17
17
|
//#endregion
|
|
18
18
|
export { DEFAULT_SHORTHANDS };
|
package/dist/shorthands.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/shorthands.ts
|
|
2
2
|
/**
|
|
3
3
|
* Default shorthand mappings for built-in sinks and formatters.
|
|
4
|
-
* @since
|
|
4
|
+
* @since 2.0.0
|
|
5
5
|
*/
|
|
6
6
|
const DEFAULT_SHORTHANDS = {
|
|
7
7
|
sinks: {
|
|
@@ -20,7 +20,7 @@ const DEFAULT_SHORTHANDS = {
|
|
|
20
20
|
* @param defaults Default shorthands
|
|
21
21
|
* @param custom Custom shorthands
|
|
22
22
|
* @returns Merged shorthands
|
|
23
|
-
* @since
|
|
23
|
+
* @since 2.0.0
|
|
24
24
|
*/
|
|
25
25
|
function mergeShorthands(defaults, custom) {
|
|
26
26
|
if (!custom) return defaults;
|
package/dist/shorthands.js.map
CHANGED
|
@@ -1 +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
|
+
{"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 2.0.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 2.0.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
CHANGED
package/dist/types.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ import { LogLevel } from "@logtape/logtape";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Configuration object schema for `configureFromObject()`.
|
|
7
|
-
* @since
|
|
7
|
+
* @since 2.0.0
|
|
8
8
|
*/
|
|
9
9
|
interface LogTapeConfig {
|
|
10
10
|
/**
|
|
@@ -26,7 +26,7 @@ interface LogTapeConfig {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Sink configuration with module reference.
|
|
29
|
-
* @since
|
|
29
|
+
* @since 2.0.0
|
|
30
30
|
*/
|
|
31
31
|
interface SinkConfig {
|
|
32
32
|
/** Module reference in `module#export()` format */
|
|
@@ -38,7 +38,7 @@ interface SinkConfig {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Filter configuration with module reference.
|
|
41
|
-
* @since
|
|
41
|
+
* @since 2.0.0
|
|
42
42
|
*/
|
|
43
43
|
interface FilterConfig {
|
|
44
44
|
/** Module reference in `module#export()` format */
|
|
@@ -48,7 +48,7 @@ interface FilterConfig {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Formatter configuration with module reference.
|
|
51
|
-
* @since
|
|
51
|
+
* @since 2.0.0
|
|
52
52
|
*/
|
|
53
53
|
interface FormatterConfig {
|
|
54
54
|
/** Module reference in `module#export()` format */
|
|
@@ -58,7 +58,7 @@ interface FormatterConfig {
|
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Logger configuration.
|
|
61
|
-
* @since
|
|
61
|
+
* @since 2.0.0
|
|
62
62
|
*/
|
|
63
63
|
interface LoggerConfig {
|
|
64
64
|
/**
|
|
@@ -84,7 +84,7 @@ interface LoggerConfig {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Registry of shorthand mappings.
|
|
87
|
-
* @since
|
|
87
|
+
* @since 2.0.0
|
|
88
88
|
*/
|
|
89
89
|
interface ShorthandRegistry {
|
|
90
90
|
/**
|
|
@@ -102,7 +102,7 @@ interface ShorthandRegistry {
|
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Options for `configureFromObject()`.
|
|
105
|
-
* @since
|
|
105
|
+
* @since 2.0.0
|
|
106
106
|
*/
|
|
107
107
|
interface ConfigureOptions {
|
|
108
108
|
/**
|
|
@@ -119,7 +119,7 @@ interface ConfigureOptions {
|
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* Options for environment variable expansion.
|
|
122
|
-
* @since
|
|
122
|
+
* @since 2.0.0
|
|
123
123
|
*/
|
|
124
124
|
interface EnvExpansionOptions {
|
|
125
125
|
/**
|
|
@@ -130,12 +130,12 @@ interface EnvExpansionOptions {
|
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* Parsed module reference.
|
|
133
|
-
* @since
|
|
133
|
+
* @since 2.0.0
|
|
134
134
|
*/
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* Error thrown when configuration is invalid.
|
|
138
|
-
* @since
|
|
138
|
+
* @since 2.0.0
|
|
139
139
|
*/
|
|
140
140
|
declare class ConfigError extends Error {
|
|
141
141
|
constructor(message: string);
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { LogLevel } from "@logtape/logtape";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Configuration object schema for `configureFromObject()`.
|
|
7
|
-
* @since
|
|
7
|
+
* @since 2.0.0
|
|
8
8
|
*/
|
|
9
9
|
interface LogTapeConfig {
|
|
10
10
|
/**
|
|
@@ -26,7 +26,7 @@ interface LogTapeConfig {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Sink configuration with module reference.
|
|
29
|
-
* @since
|
|
29
|
+
* @since 2.0.0
|
|
30
30
|
*/
|
|
31
31
|
interface SinkConfig {
|
|
32
32
|
/** Module reference in `module#export()` format */
|
|
@@ -38,7 +38,7 @@ interface SinkConfig {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Filter configuration with module reference.
|
|
41
|
-
* @since
|
|
41
|
+
* @since 2.0.0
|
|
42
42
|
*/
|
|
43
43
|
interface FilterConfig {
|
|
44
44
|
/** Module reference in `module#export()` format */
|
|
@@ -48,7 +48,7 @@ interface FilterConfig {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Formatter configuration with module reference.
|
|
51
|
-
* @since
|
|
51
|
+
* @since 2.0.0
|
|
52
52
|
*/
|
|
53
53
|
interface FormatterConfig {
|
|
54
54
|
/** Module reference in `module#export()` format */
|
|
@@ -58,7 +58,7 @@ interface FormatterConfig {
|
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Logger configuration.
|
|
61
|
-
* @since
|
|
61
|
+
* @since 2.0.0
|
|
62
62
|
*/
|
|
63
63
|
interface LoggerConfig {
|
|
64
64
|
/**
|
|
@@ -84,7 +84,7 @@ interface LoggerConfig {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Registry of shorthand mappings.
|
|
87
|
-
* @since
|
|
87
|
+
* @since 2.0.0
|
|
88
88
|
*/
|
|
89
89
|
interface ShorthandRegistry {
|
|
90
90
|
/**
|
|
@@ -102,7 +102,7 @@ interface ShorthandRegistry {
|
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Options for `configureFromObject()`.
|
|
105
|
-
* @since
|
|
105
|
+
* @since 2.0.0
|
|
106
106
|
*/
|
|
107
107
|
interface ConfigureOptions {
|
|
108
108
|
/**
|
|
@@ -119,7 +119,7 @@ interface ConfigureOptions {
|
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* Options for environment variable expansion.
|
|
122
|
-
* @since
|
|
122
|
+
* @since 2.0.0
|
|
123
123
|
*/
|
|
124
124
|
interface EnvExpansionOptions {
|
|
125
125
|
/**
|
|
@@ -130,12 +130,12 @@ interface EnvExpansionOptions {
|
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* Parsed module reference.
|
|
133
|
-
* @since
|
|
133
|
+
* @since 2.0.0
|
|
134
134
|
*/
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* Error thrown when configuration is invalid.
|
|
138
|
-
* @since
|
|
138
|
+
* @since 2.0.0
|
|
139
139
|
*/
|
|
140
140
|
declare class ConfigError extends Error {
|
|
141
141
|
constructor(message: string);
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +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
|
+
{"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 2.0.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 2.0.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 2.0.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 2.0.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 2.0.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 2.0.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 2.0.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 2.0.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 2.0.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 2.0.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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logtape/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-dev.469+3c6fc1d7",
|
|
4
4
|
"description": "Configure LogTape from plain objects (JSON, YAML, TOML)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logging",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dist/"
|
|
50
50
|
],
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@logtape/logtape": "^
|
|
52
|
+
"@logtape/logtape": "^2.0.0-dev.469+3c6fc1d7"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@alinea/suite": "^0.6.3",
|