@optique/config 1.0.0-dev.438 → 1.0.0-dev.453
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 +9 -20
- package/dist/index.d.cts +1 -11
- package/dist/index.d.ts +1 -11
- package/dist/index.js +10 -19
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -28,16 +28,6 @@ const __optique_core_message = __toESM(require("@optique/core/message"));
|
|
|
28
28
|
|
|
29
29
|
//#region src/index.ts
|
|
30
30
|
/**
|
|
31
|
-
* Unique symbol for config data in annotations.
|
|
32
|
-
* @since 0.10.0
|
|
33
|
-
*/
|
|
34
|
-
const configKey = Symbol.for("@optique/config");
|
|
35
|
-
/**
|
|
36
|
-
* Unique symbol for config metadata in annotations.
|
|
37
|
-
* @since 1.0.0
|
|
38
|
-
*/
|
|
39
|
-
const configMetaKey = Symbol.for("@optique/config/meta");
|
|
40
|
-
/**
|
|
41
31
|
* Internal registry for active config data during config context execution.
|
|
42
32
|
* This is a workaround for the limitation that object() doesn't propagate
|
|
43
33
|
* annotations to child field parsers.
|
|
@@ -179,12 +169,12 @@ function createConfigContext(options) {
|
|
|
179
169
|
setActiveConfig(contextId, configData);
|
|
180
170
|
if (configMeta !== void 0) {
|
|
181
171
|
setActiveConfigMeta(contextId, configMeta);
|
|
182
|
-
return {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
};
|
|
172
|
+
return { [contextId]: {
|
|
173
|
+
data: configData,
|
|
174
|
+
meta: configMeta
|
|
175
|
+
} };
|
|
186
176
|
}
|
|
187
|
-
return { [
|
|
177
|
+
return { [contextId]: { data: configData } };
|
|
188
178
|
}
|
|
189
179
|
return {};
|
|
190
180
|
},
|
|
@@ -332,10 +322,11 @@ function bindConfig(parser, options) {
|
|
|
332
322
|
*/
|
|
333
323
|
function getConfigOrDefault(state, options) {
|
|
334
324
|
const annotations = (0, __optique_core_annotations.getAnnotations)(state);
|
|
335
|
-
|
|
336
|
-
|
|
325
|
+
const contextId = options.context.id;
|
|
326
|
+
const annotationValue = annotations?.[contextId];
|
|
327
|
+
let configData = annotationValue?.data;
|
|
328
|
+
let configMeta = annotationValue?.meta;
|
|
337
329
|
if (configData === void 0 || configData === null) {
|
|
338
|
-
const contextId = options.context.id;
|
|
339
330
|
configData = getActiveConfig(contextId);
|
|
340
331
|
configMeta = getActiveConfigMeta(contextId);
|
|
341
332
|
}
|
|
@@ -364,8 +355,6 @@ function getConfigOrDefault(state, options) {
|
|
|
364
355
|
exports.bindConfig = bindConfig;
|
|
365
356
|
exports.clearActiveConfig = clearActiveConfig;
|
|
366
357
|
exports.clearActiveConfigMeta = clearActiveConfigMeta;
|
|
367
|
-
exports.configKey = configKey;
|
|
368
|
-
exports.configMetaKey = configMetaKey;
|
|
369
358
|
exports.createConfigContext = createConfigContext;
|
|
370
359
|
exports.getActiveConfig = getActiveConfig;
|
|
371
360
|
exports.getActiveConfigMeta = getActiveConfigMeta;
|
package/dist/index.d.cts
CHANGED
|
@@ -4,16 +4,6 @@ import { Parser } from "@optique/core/parser";
|
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Unique symbol for config data in annotations.
|
|
9
|
-
* @since 0.10.0
|
|
10
|
-
*/
|
|
11
|
-
declare const configKey: unique symbol;
|
|
12
|
-
/**
|
|
13
|
-
* Unique symbol for config metadata in annotations.
|
|
14
|
-
* @since 1.0.0
|
|
15
|
-
*/
|
|
16
|
-
declare const configMetaKey: unique symbol;
|
|
17
7
|
/**
|
|
18
8
|
* Metadata about the loaded config source.
|
|
19
9
|
*
|
|
@@ -241,4 +231,4 @@ interface BindConfigOptions<T, TValue, TConfigMeta = ConfigMeta> {
|
|
|
241
231
|
*/
|
|
242
232
|
declare function bindConfig<M extends "sync" | "async", TValue, TState, T, TConfigMeta = ConfigMeta>(parser: Parser<M, TValue, TState>, options: BindConfigOptions<T, TValue, TConfigMeta>): Parser<M, TValue, TState>;
|
|
243
233
|
//#endregion
|
|
244
|
-
export { BindConfigOptions, ConfigContext, ConfigContextOptions, ConfigContextRequiredOptions, ConfigLoadResult, ConfigMeta, bindConfig, clearActiveConfig, clearActiveConfigMeta,
|
|
234
|
+
export { BindConfigOptions, ConfigContext, ConfigContextOptions, ConfigContextRequiredOptions, ConfigLoadResult, ConfigMeta, bindConfig, clearActiveConfig, clearActiveConfigMeta, createConfigContext, getActiveConfig, getActiveConfigMeta, setActiveConfig, setActiveConfigMeta };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,16 +4,6 @@ import { Parser } from "@optique/core/parser";
|
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Unique symbol for config data in annotations.
|
|
9
|
-
* @since 0.10.0
|
|
10
|
-
*/
|
|
11
|
-
declare const configKey: unique symbol;
|
|
12
|
-
/**
|
|
13
|
-
* Unique symbol for config metadata in annotations.
|
|
14
|
-
* @since 1.0.0
|
|
15
|
-
*/
|
|
16
|
-
declare const configMetaKey: unique symbol;
|
|
17
7
|
/**
|
|
18
8
|
* Metadata about the loaded config source.
|
|
19
9
|
*
|
|
@@ -241,4 +231,4 @@ interface BindConfigOptions<T, TValue, TConfigMeta = ConfigMeta> {
|
|
|
241
231
|
*/
|
|
242
232
|
declare function bindConfig<M extends "sync" | "async", TValue, TState, T, TConfigMeta = ConfigMeta>(parser: Parser<M, TValue, TState>, options: BindConfigOptions<T, TValue, TConfigMeta>): Parser<M, TValue, TState>;
|
|
243
233
|
//#endregion
|
|
244
|
-
export { BindConfigOptions, ConfigContext, ConfigContextOptions, ConfigContextRequiredOptions, ConfigLoadResult, ConfigMeta, bindConfig, clearActiveConfig, clearActiveConfigMeta,
|
|
234
|
+
export { BindConfigOptions, ConfigContext, ConfigContextOptions, ConfigContextRequiredOptions, ConfigLoadResult, ConfigMeta, bindConfig, clearActiveConfig, clearActiveConfigMeta, createConfigContext, getActiveConfig, getActiveConfigMeta, setActiveConfig, setActiveConfigMeta };
|
package/dist/index.js
CHANGED
|
@@ -5,16 +5,6 @@ import { message } from "@optique/core/message";
|
|
|
5
5
|
|
|
6
6
|
//#region src/index.ts
|
|
7
7
|
/**
|
|
8
|
-
* Unique symbol for config data in annotations.
|
|
9
|
-
* @since 0.10.0
|
|
10
|
-
*/
|
|
11
|
-
const configKey = Symbol.for("@optique/config");
|
|
12
|
-
/**
|
|
13
|
-
* Unique symbol for config metadata in annotations.
|
|
14
|
-
* @since 1.0.0
|
|
15
|
-
*/
|
|
16
|
-
const configMetaKey = Symbol.for("@optique/config/meta");
|
|
17
|
-
/**
|
|
18
8
|
* Internal registry for active config data during config context execution.
|
|
19
9
|
* This is a workaround for the limitation that object() doesn't propagate
|
|
20
10
|
* annotations to child field parsers.
|
|
@@ -156,12 +146,12 @@ function createConfigContext(options) {
|
|
|
156
146
|
setActiveConfig(contextId, configData);
|
|
157
147
|
if (configMeta !== void 0) {
|
|
158
148
|
setActiveConfigMeta(contextId, configMeta);
|
|
159
|
-
return {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
149
|
+
return { [contextId]: {
|
|
150
|
+
data: configData,
|
|
151
|
+
meta: configMeta
|
|
152
|
+
} };
|
|
163
153
|
}
|
|
164
|
-
return { [
|
|
154
|
+
return { [contextId]: { data: configData } };
|
|
165
155
|
}
|
|
166
156
|
return {};
|
|
167
157
|
},
|
|
@@ -309,10 +299,11 @@ function bindConfig(parser, options) {
|
|
|
309
299
|
*/
|
|
310
300
|
function getConfigOrDefault(state, options) {
|
|
311
301
|
const annotations = getAnnotations(state);
|
|
312
|
-
|
|
313
|
-
|
|
302
|
+
const contextId = options.context.id;
|
|
303
|
+
const annotationValue = annotations?.[contextId];
|
|
304
|
+
let configData = annotationValue?.data;
|
|
305
|
+
let configMeta = annotationValue?.meta;
|
|
314
306
|
if (configData === void 0 || configData === null) {
|
|
315
|
-
const contextId = options.context.id;
|
|
316
307
|
configData = getActiveConfig(contextId);
|
|
317
308
|
configMeta = getActiveConfigMeta(contextId);
|
|
318
309
|
}
|
|
@@ -338,4 +329,4 @@ function getConfigOrDefault(state, options) {
|
|
|
338
329
|
}
|
|
339
330
|
|
|
340
331
|
//#endregion
|
|
341
|
-
export { bindConfig, clearActiveConfig, clearActiveConfigMeta,
|
|
332
|
+
export { bindConfig, clearActiveConfig, clearActiveConfigMeta, createConfigContext, getActiveConfig, getActiveConfigMeta, setActiveConfig, setActiveConfigMeta };
|
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.453+9dcddf47",
|
|
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.453+9dcddf47"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@standard-schema/spec": "^1.1.0",
|