@optique/config 1.0.0-dev.1828 → 1.0.0-dev.1840
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 +14 -18
- package/dist/index.d.cts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +14 -18
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -29,11 +29,7 @@ const __optique_core_message = __toESM(require("@optique/core/message"));
|
|
|
29
29
|
const __optique_core_mode_dispatch = __toESM(require("@optique/core/mode-dispatch"));
|
|
30
30
|
|
|
31
31
|
//#region src/index.ts
|
|
32
|
-
const phase2UndefinedParsedValueKey = Symbol("@optique/config/phase2UndefinedParsedValue");
|
|
33
32
|
const phase1ConfigAnnotationMarker = Symbol("@optique/config/phase1Annotation");
|
|
34
|
-
function isPhase2UndefinedParsedValue(value) {
|
|
35
|
-
return value != null && typeof value === "object" && phase2UndefinedParsedValueKey in value;
|
|
36
|
-
}
|
|
37
33
|
function getTypeName(value) {
|
|
38
34
|
if (value === null) return "null";
|
|
39
35
|
if (Array.isArray(value)) return "array";
|
|
@@ -97,11 +93,13 @@ function validateWithSchema(schema, rawData) {
|
|
|
97
93
|
* *@optique/run* to provide configuration file support. Each runner call
|
|
98
94
|
* receives its own annotation snapshot, so the same `ConfigContext`
|
|
99
95
|
* instance can be reused safely across independent or concurrent runs.
|
|
100
|
-
* When calling `context.getAnnotations()` manually,
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* `
|
|
104
|
-
*
|
|
96
|
+
* When calling `context.getAnnotations()` manually, omit the request for a
|
|
97
|
+
* phase-1 snapshot or pass `{ phase: "phase2", parsed }` for a phase-two
|
|
98
|
+
* snapshot, then thread the returned annotations into low-level APIs such
|
|
99
|
+
* as `parse()`, `parseAsync()`, `parser.complete()`, `suggest()`, or
|
|
100
|
+
* `getDocPage()`. Calling `getAnnotations()` by itself does not affect
|
|
101
|
+
* later parses unless those returned annotations are explicitly threaded
|
|
102
|
+
* into a low-level API call.
|
|
105
103
|
*
|
|
106
104
|
* @template T The output type of the config schema.
|
|
107
105
|
* @template TConfigMeta The metadata type for config sources.
|
|
@@ -135,21 +133,19 @@ function createConfigContext(options) {
|
|
|
135
133
|
id: contextId,
|
|
136
134
|
schema: rawSchema,
|
|
137
135
|
phase: "two-pass",
|
|
138
|
-
getInternalAnnotations(
|
|
139
|
-
if (
|
|
136
|
+
getInternalAnnotations(request, annotations) {
|
|
137
|
+
if (request.phase === "phase1") return { [contextId]: phase1ConfigAnnotationMarker };
|
|
140
138
|
return Object.getOwnPropertySymbols(annotations).includes(contextId) ? void 0 : { [contextId]: void 0 };
|
|
141
139
|
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (parsed === void 0) return {};
|
|
140
|
+
getAnnotations(request, runtimeOptions) {
|
|
141
|
+
if (request === void 0) return {};
|
|
142
|
+
if (request === null || typeof request !== "object" || !("phase" in request) || request.phase !== "phase1" && request.phase !== "phase2" || request.phase === "phase2" && !("parsed" in request)) throw new TypeError(`Expected getAnnotations() to receive no request or a SourceContextRequest ({ phase: "phase1" } or { phase: "phase2", parsed }), but got: ${getTypeName(request)}.`);
|
|
143
|
+
if (request.phase === "phase1") return {};
|
|
147
144
|
const opts = runtimeOptions;
|
|
148
145
|
if (!opts || !opts.getConfigPath && !opts.load) throw new TypeError("Either getConfigPath or load must be provided in the runner options when using ConfigContext.");
|
|
149
146
|
if (opts.load !== void 0 && typeof opts.load !== "function") throw new TypeError(`Expected load to be a function, but got: ${getTypeName(opts.load)}.`);
|
|
150
147
|
if (!opts.load && opts.getConfigPath !== void 0 && typeof opts.getConfigPath !== "function") throw new TypeError(`Expected getConfigPath to be a function, but got: ${getTypeName(opts.getConfigPath)}.`);
|
|
151
|
-
const
|
|
152
|
-
const parsedPlaceholder = parsedValue;
|
|
148
|
+
const parsedPlaceholder = request.parsed;
|
|
153
149
|
const emptyAnnotations = () => ({});
|
|
154
150
|
const buildAnnotations = (configData, configMeta) => {
|
|
155
151
|
if (configData === void 0 || configData === null) return emptyAnnotations();
|
package/dist/index.d.cts
CHANGED
|
@@ -129,11 +129,13 @@ interface ConfigContext<T, TConfigMeta = ConfigMeta> extends SourceContext<Confi
|
|
|
129
129
|
* *@optique/run* to provide configuration file support. Each runner call
|
|
130
130
|
* receives its own annotation snapshot, so the same `ConfigContext`
|
|
131
131
|
* instance can be reused safely across independent or concurrent runs.
|
|
132
|
-
* When calling `context.getAnnotations()` manually,
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* `
|
|
136
|
-
*
|
|
132
|
+
* When calling `context.getAnnotations()` manually, omit the request for a
|
|
133
|
+
* phase-1 snapshot or pass `{ phase: "phase2", parsed }` for a phase-two
|
|
134
|
+
* snapshot, then thread the returned annotations into low-level APIs such
|
|
135
|
+
* as `parse()`, `parseAsync()`, `parser.complete()`, `suggest()`, or
|
|
136
|
+
* `getDocPage()`. Calling `getAnnotations()` by itself does not affect
|
|
137
|
+
* later parses unless those returned annotations are explicitly threaded
|
|
138
|
+
* into a low-level API call.
|
|
137
139
|
*
|
|
138
140
|
* @template T The output type of the config schema.
|
|
139
141
|
* @template TConfigMeta The metadata type for config sources.
|
package/dist/index.d.ts
CHANGED
|
@@ -129,11 +129,13 @@ interface ConfigContext<T, TConfigMeta = ConfigMeta> extends SourceContext<Confi
|
|
|
129
129
|
* *@optique/run* to provide configuration file support. Each runner call
|
|
130
130
|
* receives its own annotation snapshot, so the same `ConfigContext`
|
|
131
131
|
* instance can be reused safely across independent or concurrent runs.
|
|
132
|
-
* When calling `context.getAnnotations()` manually,
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* `
|
|
136
|
-
*
|
|
132
|
+
* When calling `context.getAnnotations()` manually, omit the request for a
|
|
133
|
+
* phase-1 snapshot or pass `{ phase: "phase2", parsed }` for a phase-two
|
|
134
|
+
* snapshot, then thread the returned annotations into low-level APIs such
|
|
135
|
+
* as `parse()`, `parseAsync()`, `parser.complete()`, `suggest()`, or
|
|
136
|
+
* `getDocPage()`. Calling `getAnnotations()` by itself does not affect
|
|
137
|
+
* later parses unless those returned annotations are explicitly threaded
|
|
138
|
+
* into a low-level API call.
|
|
137
139
|
*
|
|
138
140
|
* @template T The output type of the config schema.
|
|
139
141
|
* @template TConfigMeta The metadata type for config sources.
|
package/dist/index.js
CHANGED
|
@@ -6,11 +6,7 @@ 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
|
-
const phase2UndefinedParsedValueKey = Symbol("@optique/config/phase2UndefinedParsedValue");
|
|
10
9
|
const phase1ConfigAnnotationMarker = Symbol("@optique/config/phase1Annotation");
|
|
11
|
-
function isPhase2UndefinedParsedValue(value) {
|
|
12
|
-
return value != null && typeof value === "object" && phase2UndefinedParsedValueKey in value;
|
|
13
|
-
}
|
|
14
10
|
function getTypeName(value) {
|
|
15
11
|
if (value === null) return "null";
|
|
16
12
|
if (Array.isArray(value)) return "array";
|
|
@@ -74,11 +70,13 @@ function validateWithSchema(schema, rawData) {
|
|
|
74
70
|
* *@optique/run* to provide configuration file support. Each runner call
|
|
75
71
|
* receives its own annotation snapshot, so the same `ConfigContext`
|
|
76
72
|
* instance can be reused safely across independent or concurrent runs.
|
|
77
|
-
* When calling `context.getAnnotations()` manually,
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* `
|
|
81
|
-
*
|
|
73
|
+
* When calling `context.getAnnotations()` manually, omit the request for a
|
|
74
|
+
* phase-1 snapshot or pass `{ phase: "phase2", parsed }` for a phase-two
|
|
75
|
+
* snapshot, then thread the returned annotations into low-level APIs such
|
|
76
|
+
* as `parse()`, `parseAsync()`, `parser.complete()`, `suggest()`, or
|
|
77
|
+
* `getDocPage()`. Calling `getAnnotations()` by itself does not affect
|
|
78
|
+
* later parses unless those returned annotations are explicitly threaded
|
|
79
|
+
* into a low-level API call.
|
|
82
80
|
*
|
|
83
81
|
* @template T The output type of the config schema.
|
|
84
82
|
* @template TConfigMeta The metadata type for config sources.
|
|
@@ -112,21 +110,19 @@ function createConfigContext(options) {
|
|
|
112
110
|
id: contextId,
|
|
113
111
|
schema: rawSchema,
|
|
114
112
|
phase: "two-pass",
|
|
115
|
-
getInternalAnnotations(
|
|
116
|
-
if (
|
|
113
|
+
getInternalAnnotations(request, annotations) {
|
|
114
|
+
if (request.phase === "phase1") return { [contextId]: phase1ConfigAnnotationMarker };
|
|
117
115
|
return Object.getOwnPropertySymbols(annotations).includes(contextId) ? void 0 : { [contextId]: void 0 };
|
|
118
116
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (parsed === void 0) return {};
|
|
117
|
+
getAnnotations(request, runtimeOptions) {
|
|
118
|
+
if (request === void 0) return {};
|
|
119
|
+
if (request === null || typeof request !== "object" || !("phase" in request) || request.phase !== "phase1" && request.phase !== "phase2" || request.phase === "phase2" && !("parsed" in request)) throw new TypeError(`Expected getAnnotations() to receive no request or a SourceContextRequest ({ phase: "phase1" } or { phase: "phase2", parsed }), but got: ${getTypeName(request)}.`);
|
|
120
|
+
if (request.phase === "phase1") return {};
|
|
124
121
|
const opts = runtimeOptions;
|
|
125
122
|
if (!opts || !opts.getConfigPath && !opts.load) throw new TypeError("Either getConfigPath or load must be provided in the runner options when using ConfigContext.");
|
|
126
123
|
if (opts.load !== void 0 && typeof opts.load !== "function") throw new TypeError(`Expected load to be a function, but got: ${getTypeName(opts.load)}.`);
|
|
127
124
|
if (!opts.load && opts.getConfigPath !== void 0 && typeof opts.getConfigPath !== "function") throw new TypeError(`Expected getConfigPath to be a function, but got: ${getTypeName(opts.getConfigPath)}.`);
|
|
128
|
-
const
|
|
129
|
-
const parsedPlaceholder = parsedValue;
|
|
125
|
+
const parsedPlaceholder = request.parsed;
|
|
130
126
|
const emptyAnnotations = () => ({});
|
|
131
127
|
const buildAnnotations = (configData, configMeta) => {
|
|
132
128
|
if (configData === void 0 || configData === null) return emptyAnnotations();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/config",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.1840+c09a37a0",
|
|
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.
|
|
62
|
+
"@optique/core": "1.0.0-dev.1840+c09a37a0"
|
|
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.
|
|
70
|
+
"@optique/env": "1.0.0-dev.1840+c09a37a0"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"build": "tsdown",
|