@optique/config 1.0.0-dev.1658 → 1.0.0-dev.1661

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/dist/index.cjs CHANGED
@@ -30,7 +30,6 @@ const __optique_core_mode_dispatch = __toESM(require("@optique/core/mode-dispatc
30
30
 
31
31
  //#region src/index.ts
32
32
  const phase2UndefinedParsedValueKey = Symbol("@optique/config/phase2UndefinedParsedValue");
33
- const inheritParentAnnotationsKey = Symbol.for("@optique/core/inheritParentAnnotations");
34
33
  /**
35
34
  * Internal registry for active config data during config context execution.
36
35
  * This is a workaround for the limitation that object() doesn't propagate
@@ -316,12 +315,7 @@ function bindConfig(parser, options) {
316
315
  initialState: parser.initialState,
317
316
  getSuggestRuntimeNodes(state, path) {
318
317
  const innerState = getSuggestInnerState(state);
319
- const innerNodes = parser.getSuggestRuntimeNodes?.(innerState, path) ?? [];
320
- return boundParser.dependencyMetadata?.source != null ? [...innerNodes, {
321
- path,
322
- parser: boundParser,
323
- state
324
- }] : innerNodes;
318
+ return (0, __optique_core_parser.getDelegatingSuggestRuntimeNodes)(parser, boundParser, state, path, innerState);
325
319
  },
326
320
  parse: (context) => {
327
321
  const annotations = (0, __optique_core_annotations.getAnnotations)(context.state);
@@ -395,39 +389,29 @@ function bindConfig(parser, options) {
395
389
  configurable: true,
396
390
  enumerable: false
397
391
  });
398
- Object.defineProperty(boundParser, inheritParentAnnotationsKey, {
399
- value: true,
392
+ (0, __optique_core_parser.defineInheritedAnnotationParser)(boundParser);
393
+ const dependencyMetadata = (0, __optique_core_parser.composeWrappedSourceMetadata)(parser.dependencyMetadata, (sourceMetadata) => ({
394
+ ...sourceMetadata,
395
+ getMissingSourceValue: sourceMetadata.preservesSourceValue !== false && options.default !== void 0 ? () => ({
396
+ success: true,
397
+ value: options.default
398
+ }) : void 0,
399
+ extractSourceValue: (state) => {
400
+ if (!isConfigBindState(state)) {
401
+ if (sourceMetadata.preservesSourceValue) return getConfigSourceValue(state, options, state, sourceMetadata.extractSourceValue);
402
+ return sourceMetadata.extractSourceValue(state);
403
+ }
404
+ if (state.hasCliValue) return sourceMetadata.extractSourceValue(state.cliState);
405
+ const fallbackState = state.cliState ?? state;
406
+ if (!sourceMetadata.preservesSourceValue) return sourceMetadata.extractSourceValue(fallbackState);
407
+ return getConfigSourceValue(state, options, fallbackState, sourceMetadata.extractSourceValue);
408
+ }
409
+ }));
410
+ if (dependencyMetadata != null) Object.defineProperty(boundParser, "dependencyMetadata", {
411
+ value: dependencyMetadata,
400
412
  configurable: true,
401
413
  enumerable: false
402
414
  });
403
- const dependencyMetadata = parser.dependencyMetadata;
404
- if (dependencyMetadata != null) {
405
- const sourceMetadata = dependencyMetadata.source;
406
- Object.defineProperty(boundParser, "dependencyMetadata", {
407
- value: sourceMetadata == null ? dependencyMetadata : {
408
- ...dependencyMetadata,
409
- source: {
410
- ...sourceMetadata,
411
- getMissingSourceValue: sourceMetadata.preservesSourceValue !== false && options.default !== void 0 ? () => ({
412
- success: true,
413
- value: options.default
414
- }) : void 0,
415
- extractSourceValue: (state) => {
416
- if (!isConfigBindState(state)) {
417
- if (sourceMetadata.preservesSourceValue) return getConfigSourceValue(state, options, state, sourceMetadata.extractSourceValue);
418
- return sourceMetadata.extractSourceValue(state);
419
- }
420
- if (state.hasCliValue) return sourceMetadata.extractSourceValue(state.cliState);
421
- const fallbackState = state.cliState ?? state;
422
- if (!sourceMetadata.preservesSourceValue) return sourceMetadata.extractSourceValue(fallbackState);
423
- return getConfigSourceValue(state, options, fallbackState, sourceMetadata.extractSourceValue);
424
- }
425
- }
426
- },
427
- configurable: true,
428
- enumerable: false
429
- });
430
- }
431
415
  return boundParser;
432
416
  }
433
417
  /**
package/dist/index.js CHANGED
@@ -1,13 +1,12 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { dirname, resolve } from "node:path";
3
- import { unmatchedNonCliDependencySourceStateMarker } from "@optique/core/parser";
3
+ import { composeWrappedSourceMetadata, defineInheritedAnnotationParser, getDelegatingSuggestRuntimeNodes, unmatchedNonCliDependencySourceStateMarker } from "@optique/core/parser";
4
4
  import { annotationKey, getAnnotations, inheritAnnotations } from "@optique/core/annotations";
5
5
  import { message } from "@optique/core/message";
6
6
  import { mapModeValue, wrapForMode } from "@optique/core/mode-dispatch";
7
7
 
8
8
  //#region src/index.ts
9
9
  const phase2UndefinedParsedValueKey = Symbol("@optique/config/phase2UndefinedParsedValue");
10
- const inheritParentAnnotationsKey = Symbol.for("@optique/core/inheritParentAnnotations");
11
10
  /**
12
11
  * Internal registry for active config data during config context execution.
13
12
  * This is a workaround for the limitation that object() doesn't propagate
@@ -293,12 +292,7 @@ function bindConfig(parser, options) {
293
292
  initialState: parser.initialState,
294
293
  getSuggestRuntimeNodes(state, path) {
295
294
  const innerState = getSuggestInnerState(state);
296
- const innerNodes = parser.getSuggestRuntimeNodes?.(innerState, path) ?? [];
297
- return boundParser.dependencyMetadata?.source != null ? [...innerNodes, {
298
- path,
299
- parser: boundParser,
300
- state
301
- }] : innerNodes;
295
+ return getDelegatingSuggestRuntimeNodes(parser, boundParser, state, path, innerState);
302
296
  },
303
297
  parse: (context) => {
304
298
  const annotations = getAnnotations(context.state);
@@ -372,39 +366,29 @@ function bindConfig(parser, options) {
372
366
  configurable: true,
373
367
  enumerable: false
374
368
  });
375
- Object.defineProperty(boundParser, inheritParentAnnotationsKey, {
376
- value: true,
369
+ defineInheritedAnnotationParser(boundParser);
370
+ const dependencyMetadata = composeWrappedSourceMetadata(parser.dependencyMetadata, (sourceMetadata) => ({
371
+ ...sourceMetadata,
372
+ getMissingSourceValue: sourceMetadata.preservesSourceValue !== false && options.default !== void 0 ? () => ({
373
+ success: true,
374
+ value: options.default
375
+ }) : void 0,
376
+ extractSourceValue: (state) => {
377
+ if (!isConfigBindState(state)) {
378
+ if (sourceMetadata.preservesSourceValue) return getConfigSourceValue(state, options, state, sourceMetadata.extractSourceValue);
379
+ return sourceMetadata.extractSourceValue(state);
380
+ }
381
+ if (state.hasCliValue) return sourceMetadata.extractSourceValue(state.cliState);
382
+ const fallbackState = state.cliState ?? state;
383
+ if (!sourceMetadata.preservesSourceValue) return sourceMetadata.extractSourceValue(fallbackState);
384
+ return getConfigSourceValue(state, options, fallbackState, sourceMetadata.extractSourceValue);
385
+ }
386
+ }));
387
+ if (dependencyMetadata != null) Object.defineProperty(boundParser, "dependencyMetadata", {
388
+ value: dependencyMetadata,
377
389
  configurable: true,
378
390
  enumerable: false
379
391
  });
380
- const dependencyMetadata = parser.dependencyMetadata;
381
- if (dependencyMetadata != null) {
382
- const sourceMetadata = dependencyMetadata.source;
383
- Object.defineProperty(boundParser, "dependencyMetadata", {
384
- value: sourceMetadata == null ? dependencyMetadata : {
385
- ...dependencyMetadata,
386
- source: {
387
- ...sourceMetadata,
388
- getMissingSourceValue: sourceMetadata.preservesSourceValue !== false && options.default !== void 0 ? () => ({
389
- success: true,
390
- value: options.default
391
- }) : void 0,
392
- extractSourceValue: (state) => {
393
- if (!isConfigBindState(state)) {
394
- if (sourceMetadata.preservesSourceValue) return getConfigSourceValue(state, options, state, sourceMetadata.extractSourceValue);
395
- return sourceMetadata.extractSourceValue(state);
396
- }
397
- if (state.hasCliValue) return sourceMetadata.extractSourceValue(state.cliState);
398
- const fallbackState = state.cliState ?? state;
399
- if (!sourceMetadata.preservesSourceValue) return sourceMetadata.extractSourceValue(fallbackState);
400
- return getConfigSourceValue(state, options, fallbackState, sourceMetadata.extractSourceValue);
401
- }
402
- }
403
- },
404
- configurable: true,
405
- enumerable: false
406
- });
407
- }
408
392
  return boundParser;
409
393
  }
410
394
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/config",
3
- "version": "1.0.0-dev.1658+b57e115b",
3
+ "version": "1.0.0-dev.1661+6fc17d4f",
4
4
  "description": "Configuration file support for Optique with Standard Schema validation",
5
5
  "keywords": [
6
6
  "CLI",
@@ -59,7 +59,7 @@
59
59
  "@standard-schema/spec": "^1.1.0"
60
60
  },
61
61
  "dependencies": {
62
- "@optique/core": "1.0.0-dev.1658+b57e115b"
62
+ "@optique/core": "1.0.0-dev.1661+6fc17d4f"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@standard-schema/spec": "^1.1.0",
@@ -67,7 +67,7 @@
67
67
  "tsdown": "^0.13.0",
68
68
  "typescript": "^5.8.3",
69
69
  "zod": "^3.25.0 || ^4.0.0",
70
- "@optique/env": "1.0.0-dev.1658+b57e115b"
70
+ "@optique/env": "1.0.0-dev.1661+6fc17d4f"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "tsdown",