@lorion-org/runtime-config-node 1.0.0-beta.0 → 1.0.0-beta.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 +21 -21
- package/README.md +26 -26
- package/dist/index.cjs +106 -14
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +107 -15
- package/examples/env-assignments.ts +5 -5
- package/examples/load-runtime-config-tree.ts +3 -3
- package/examples/query-runtime-config-tree.ts +17 -17
- package/examples/source-and-scope-files.ts +6 -6
- package/package.json +9 -3
- package/src/index.ts +1063 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -34,9 +34,9 @@ pnpm add @lorion-org/runtime-config-node @lorion-org/runtime-config
|
|
|
34
34
|
```text
|
|
35
35
|
var/
|
|
36
36
|
runtime-config/
|
|
37
|
-
|
|
37
|
+
checkout/
|
|
38
38
|
runtime.config.json
|
|
39
|
-
|
|
39
|
+
payments/
|
|
40
40
|
runtime.config.json
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -49,7 +49,7 @@ import { projectSectionedRuntimeConfig } from '@lorion-org/runtime-config';
|
|
|
49
49
|
const fragments = loadRuntimeConfigTree('./var');
|
|
50
50
|
const runtimeConfig = projectSectionedRuntimeConfig(fragments);
|
|
51
51
|
|
|
52
|
-
runtimeConfig.public.
|
|
52
|
+
runtimeConfig.public.checkoutSuccessPath;
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
## Single fragment example
|
|
@@ -57,9 +57,9 @@ runtimeConfig.public.billingApiBase;
|
|
|
57
57
|
```ts
|
|
58
58
|
import { loadRuntimeConfigFragment } from '@lorion-org/runtime-config-node';
|
|
59
59
|
|
|
60
|
-
const
|
|
60
|
+
const checkout = loadRuntimeConfigFragment('./var', 'checkout');
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
checkout?.public?.successPath;
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
## Source and scope file example
|
|
@@ -81,11 +81,11 @@ const source = resolveRuntimeConfigSource({
|
|
|
81
81
|
envKey: 'APP_VAR_DIR',
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
readRuntimeConfigScopeJson(source, '
|
|
85
|
-
// => {
|
|
84
|
+
readRuntimeConfigScopeJson(source, 'checkout', 'settings.json');
|
|
85
|
+
// => { successPath: '/orders/confirmed' }
|
|
86
86
|
|
|
87
|
-
resolveRuntimeConfigPublicFilePath(source, '
|
|
88
|
-
// => '/absolute/project/path/var/runtime-config/public/
|
|
87
|
+
resolveRuntimeConfigPublicFilePath(source, 'checkout/logo.svg');
|
|
88
|
+
// => '/absolute/project/path/var/runtime-config/public/checkout/logo.svg'
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
## Pattern source example
|
|
@@ -106,12 +106,12 @@ const source = {
|
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
resolveRuntimeConfigSourceFiles(source);
|
|
109
|
-
// => [{ scopeId: '
|
|
109
|
+
// => [{ scopeId: 'checkout', configPath: '/project/.runtimeconfig/runtime-config/checkout/runtime.config.json', ... }]
|
|
110
110
|
|
|
111
|
-
loadRuntimeConfigSourceTree(source).get('
|
|
112
|
-
// => '/
|
|
111
|
+
loadRuntimeConfigSourceTree(source).get('checkout')?.public?.successPath;
|
|
112
|
+
// => '/orders/confirmed'
|
|
113
113
|
|
|
114
|
-
validateRuntimeConfigSourceScopes(source, [{ scopeId: '
|
|
114
|
+
validateRuntimeConfigSourceScopes(source, [{ scopeId: 'checkout', cwd: './extensions/checkout' }]);
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
## Write fragment example
|
|
@@ -119,9 +119,9 @@ validateRuntimeConfigSourceScopes(source, [{ scopeId: 'billing', cwd: './extensi
|
|
|
119
119
|
```ts
|
|
120
120
|
import { writeRuntimeConfigFragment } from '@lorion-org/runtime-config-node';
|
|
121
121
|
|
|
122
|
-
writeRuntimeConfigFragment('./var', '
|
|
122
|
+
writeRuntimeConfigFragment('./var', 'checkout', {
|
|
123
123
|
public: {
|
|
124
|
-
|
|
124
|
+
successPath: '/orders/confirmed',
|
|
125
125
|
},
|
|
126
126
|
});
|
|
127
127
|
```
|
|
@@ -137,7 +137,7 @@ import { loadRuntimeConfigShellAssignments } from '@lorion-org/runtime-config-no
|
|
|
137
137
|
loadRuntimeConfigShellAssignments('./var', {
|
|
138
138
|
prefix: 'APP',
|
|
139
139
|
});
|
|
140
|
-
// =>
|
|
140
|
+
// => APP_PUBLIC_CHECKOUT_SUCCESS_PATH='"/orders/confirmed"'
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
## Tree query example
|
|
@@ -154,16 +154,16 @@ import {
|
|
|
154
154
|
} from '@lorion-org/runtime-config-node';
|
|
155
155
|
|
|
156
156
|
listRuntimeConfigFragments('./var');
|
|
157
|
-
// => { scopes: [{ scopeId: '
|
|
157
|
+
// => { scopes: [{ scopeId: 'checkout', ... }] }
|
|
158
158
|
|
|
159
|
-
projectRuntimeConfigTree('./var').runtimeConfig.public.
|
|
160
|
-
// => '/
|
|
159
|
+
projectRuntimeConfigTree('./var').runtimeConfig.public.checkoutSuccessPath;
|
|
160
|
+
// => '/orders/confirmed'
|
|
161
161
|
|
|
162
|
-
getRuntimeConfigValue('./var', '
|
|
163
|
-
// => '/
|
|
162
|
+
getRuntimeConfigValue('./var', 'checkout', 'successPath').value;
|
|
163
|
+
// => '/orders/confirmed'
|
|
164
164
|
|
|
165
|
-
getRuntimeConfigScopeView('./var', '
|
|
166
|
-
// => {
|
|
165
|
+
getRuntimeConfigScopeView('./var', 'checkout').config;
|
|
166
|
+
// => { successPath: '/orders/confirmed' }
|
|
167
167
|
```
|
|
168
168
|
|
|
169
169
|
## Schema validation example
|
|
@@ -176,9 +176,9 @@ import { validateRuntimeConfigSchemaTargets } from '@lorion-org/runtime-config-n
|
|
|
176
176
|
|
|
177
177
|
validateRuntimeConfigSchemaTargets([
|
|
178
178
|
{
|
|
179
|
-
scopeId: '
|
|
180
|
-
schemaPath: './schemas/
|
|
181
|
-
configPath: './var/runtime-config/
|
|
179
|
+
scopeId: 'checkout',
|
|
180
|
+
schemaPath: './schemas/checkout.schema.json',
|
|
181
|
+
configPath: './var/runtime-config/checkout/runtime.config.json',
|
|
182
182
|
},
|
|
183
183
|
]);
|
|
184
184
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
assertRequiredRuntimeConfigValidationTargets: () => assertRequiredRuntimeConfigValidationTargets,
|
|
33
34
|
collectRuntimeConfigFragmentFiles: () => collectRuntimeConfigFragmentFiles,
|
|
35
|
+
collectRuntimeConfigSchemaTargetValidationErrors: () => collectRuntimeConfigSchemaTargetValidationErrors,
|
|
34
36
|
ensureParentDir: () => ensureParentDir,
|
|
35
37
|
getRuntimeConfigScopeView: () => getRuntimeConfigScopeView,
|
|
36
38
|
getRuntimeConfigValue: () => getRuntimeConfigValue,
|
|
@@ -45,6 +47,7 @@ __export(index_exports, {
|
|
|
45
47
|
projectRuntimeConfigTree: () => projectRuntimeConfigTree,
|
|
46
48
|
readJsonFile: () => readJsonFile,
|
|
47
49
|
readRequiredJsonFile: () => readRequiredJsonFile,
|
|
50
|
+
readRuntimeConfigSchemaRegistry: () => readRuntimeConfigSchemaRegistry,
|
|
48
51
|
readRuntimeConfigScopeJson: () => readRuntimeConfigScopeJson,
|
|
49
52
|
readTextFile: () => readTextFile,
|
|
50
53
|
resolveRuntimeConfigFilePath: () => resolveRuntimeConfigFilePath,
|
|
@@ -162,6 +165,35 @@ function getRuntimeConfigPathOptions(source) {
|
|
|
162
165
|
function getSchemaFileName(options) {
|
|
163
166
|
return options.schemaFileName ?? defaultRuntimeConfigSchemaFileName;
|
|
164
167
|
}
|
|
168
|
+
function formatMissingRuntimeConfigValidationError(skipped) {
|
|
169
|
+
if (skipped.reason === "missing-schema") {
|
|
170
|
+
return new Error(
|
|
171
|
+
[
|
|
172
|
+
`RuntimeConfig schema file missing for scope "${skipped.scopeId}".`,
|
|
173
|
+
...skipped.schemaPath ? [`missing schema file: ${skipped.schemaPath}`] : [],
|
|
174
|
+
...skipped.configPath ? [`runtime config file: ${skipped.configPath}`] : []
|
|
175
|
+
].join(" ")
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
if (skipped.reason === "missing-config") {
|
|
179
|
+
return new Error(
|
|
180
|
+
[
|
|
181
|
+
`RuntimeConfig file missing for scope "${skipped.scopeId}".`,
|
|
182
|
+
...skipped.configPath ? [`expected runtime config file: ${skipped.configPath}`] : [],
|
|
183
|
+
...skipped.schemaPath ? [`schema file: ${skipped.schemaPath}`] : []
|
|
184
|
+
].join(" ")
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
const details = [
|
|
188
|
+
`RuntimeConfig validation target has no schema directory for scope "${skipped.scopeId}".`
|
|
189
|
+
];
|
|
190
|
+
if (skipped.configPath) details.push(`runtime config file: ${skipped.configPath}`);
|
|
191
|
+
if (skipped.schemaPath) details.push(`schema file: ${skipped.schemaPath}`);
|
|
192
|
+
return new Error(details.join(" "));
|
|
193
|
+
}
|
|
194
|
+
function shouldReportMissingRuntimeConfig(mode) {
|
|
195
|
+
return mode !== "optional";
|
|
196
|
+
}
|
|
165
197
|
function stripJsonBom(text) {
|
|
166
198
|
return text.charCodeAt(0) === 65279 ? text.slice(1) : text;
|
|
167
199
|
}
|
|
@@ -338,12 +370,19 @@ function formatRuntimeConfigSchemaValidationError(target, validationError) {
|
|
|
338
370
|
);
|
|
339
371
|
}
|
|
340
372
|
function validateRuntimeConfigSchemaTargets(targets, options = {}) {
|
|
373
|
+
const invalid = collectRuntimeConfigSchemaTargetValidationErrors(targets, options);
|
|
374
|
+
if (invalid[0]) {
|
|
375
|
+
throw invalid[0].error;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
function collectRuntimeConfigSchemaTargetValidationErrors(targets, options = {}) {
|
|
341
379
|
const ajv = new import_ajv.default({
|
|
342
380
|
strict: false,
|
|
343
381
|
allErrors: false,
|
|
344
382
|
...options.ajvOptions
|
|
345
383
|
});
|
|
346
384
|
const formatError = options.formatError ?? formatRuntimeConfigSchemaValidationError;
|
|
385
|
+
const invalid = [];
|
|
347
386
|
for (const target of targets) {
|
|
348
387
|
if (!(0, import_node_fs.existsSync)(target.schemaPath) || !(0, import_node_fs.existsSync)(target.configPath)) {
|
|
349
388
|
continue;
|
|
@@ -355,13 +394,21 @@ function validateRuntimeConfigSchemaTargets(targets, options = {}) {
|
|
|
355
394
|
if (!isValid) {
|
|
356
395
|
const validationError = validate.errors?.[0];
|
|
357
396
|
if (validationError) {
|
|
358
|
-
|
|
397
|
+
invalid.push({
|
|
398
|
+
...target,
|
|
399
|
+
error: formatError(target, validationError)
|
|
400
|
+
});
|
|
401
|
+
continue;
|
|
359
402
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
403
|
+
invalid.push({
|
|
404
|
+
...target,
|
|
405
|
+
error: new Error(
|
|
406
|
+
`RuntimeConfig schema validation failed for "${target.scopeId}" (${target.configPath})`
|
|
407
|
+
)
|
|
408
|
+
});
|
|
363
409
|
}
|
|
364
410
|
}
|
|
411
|
+
return invalid;
|
|
365
412
|
}
|
|
366
413
|
function loadRuntimeConfigTree(varDir, options = {}) {
|
|
367
414
|
const runtimeConfigDir = import_node_path.default.join(varDir, getRuntimeConfigDirName(options));
|
|
@@ -480,21 +527,28 @@ function validateRuntimeConfigScopes(varDir, targets, options = {}) {
|
|
|
480
527
|
const schemaFileName = getSchemaFileName(options);
|
|
481
528
|
const result = {
|
|
482
529
|
fileName: getFileName(options),
|
|
530
|
+
invalid: [],
|
|
483
531
|
skipped: [],
|
|
484
532
|
validated: [],
|
|
485
533
|
varDir
|
|
486
534
|
};
|
|
487
535
|
for (const target of targets) {
|
|
536
|
+
if (!(0, import_runtime_config.shouldRegisterRuntimeConfigValidationSchema)(target.policy)) continue;
|
|
488
537
|
const scopeId = target.scopeId.trim();
|
|
489
538
|
if (!scopeId) continue;
|
|
539
|
+
const mode = (0, import_runtime_config.resolveRuntimeConfigValidationMode)(target.policy);
|
|
490
540
|
const configPath = resolveRuntimeConfigPaths(varDir, scopeId, options).filePath;
|
|
491
541
|
const schemaPath = target.cwd ? import_node_path.default.resolve(target.cwd, schemaFileName) : void 0;
|
|
492
542
|
if (!target.cwd || !schemaPath) {
|
|
493
|
-
|
|
543
|
+
if (shouldReportMissingRuntimeConfig(mode)) {
|
|
544
|
+
result.skipped.push({ configPath, reason: "missing-scope-dir", scopeId });
|
|
545
|
+
}
|
|
494
546
|
continue;
|
|
495
547
|
}
|
|
496
548
|
if (!(0, import_node_fs.existsSync)(configPath)) {
|
|
497
|
-
|
|
549
|
+
if (shouldReportMissingRuntimeConfig(mode)) {
|
|
550
|
+
result.skipped.push({ configPath, reason: "missing-config", schemaPath, scopeId });
|
|
551
|
+
}
|
|
498
552
|
continue;
|
|
499
553
|
}
|
|
500
554
|
if (!(0, import_node_fs.existsSync)(schemaPath)) {
|
|
@@ -503,16 +557,45 @@ function validateRuntimeConfigScopes(varDir, targets, options = {}) {
|
|
|
503
557
|
}
|
|
504
558
|
result.validated.push({ configPath, schemaPath, scopeId });
|
|
505
559
|
}
|
|
506
|
-
|
|
560
|
+
result.invalid = collectRuntimeConfigSchemaTargetValidationErrors(result.validated, {
|
|
507
561
|
...options.formatError ? { formatError: options.formatError } : {}
|
|
508
562
|
});
|
|
509
563
|
return result;
|
|
510
564
|
}
|
|
565
|
+
function readRuntimeConfigSchemaRegistry(targets, options = {}) {
|
|
566
|
+
const schemaFileName = options.schemaFileName ?? defaultRuntimeConfigSchemaFileName;
|
|
567
|
+
const entries = targets.filter((target) => (0, import_runtime_config.shouldRegisterRuntimeConfigValidationSchema)(target.policy)).flatMap((target) => {
|
|
568
|
+
const scopeId = target.scopeId.trim();
|
|
569
|
+
if (!scopeId || !target.cwd) return [];
|
|
570
|
+
const schemaPath = import_node_path.default.resolve(target.cwd, schemaFileName);
|
|
571
|
+
if (!(0, import_node_fs.existsSync)(schemaPath)) return [];
|
|
572
|
+
return [[scopeId, readRequiredJsonFile(schemaPath)]];
|
|
573
|
+
});
|
|
574
|
+
return Object.fromEntries(entries);
|
|
575
|
+
}
|
|
576
|
+
function assertRequiredRuntimeConfigValidationTargets(result, targets) {
|
|
577
|
+
const requiredScopeIds = new Set(
|
|
578
|
+
targets.filter((target) => (0, import_runtime_config.shouldRequireRuntimeConfigAtStartup)(target.policy)).map((target) => target.scopeId.trim()).filter(Boolean)
|
|
579
|
+
);
|
|
580
|
+
const requiredFailures = [
|
|
581
|
+
...result.skipped.filter((entry) => requiredScopeIds.has(entry.scopeId)).map(formatMissingRuntimeConfigValidationError),
|
|
582
|
+
...result.invalid.filter((entry) => requiredScopeIds.has(entry.scopeId)).map((entry) => entry.error)
|
|
583
|
+
];
|
|
584
|
+
if (requiredFailures.length) {
|
|
585
|
+
throw new Error(
|
|
586
|
+
[
|
|
587
|
+
"RuntimeConfig startup validation failed.",
|
|
588
|
+
...requiredFailures.map((error) => error.message)
|
|
589
|
+
].join("\n\n")
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
511
593
|
function validateRuntimeConfigSourceScopes(source, targets, options = {}) {
|
|
512
594
|
const schemaFileName = getSchemaFileName(options);
|
|
513
595
|
const filesByScope = /* @__PURE__ */ new Map();
|
|
514
596
|
const result = {
|
|
515
597
|
fileName: source.paths[0] ?? "",
|
|
598
|
+
invalid: [],
|
|
516
599
|
skipped: [],
|
|
517
600
|
validated: [],
|
|
518
601
|
varDir: ""
|
|
@@ -521,20 +604,26 @@ function validateRuntimeConfigSourceScopes(source, targets, options = {}) {
|
|
|
521
604
|
filesByScope.set(file.scopeId, file.configPath);
|
|
522
605
|
}
|
|
523
606
|
for (const target of targets) {
|
|
607
|
+
if (!(0, import_runtime_config.shouldRegisterRuntimeConfigValidationSchema)(target.policy)) continue;
|
|
524
608
|
const scopeId = target.scopeId.trim();
|
|
525
609
|
if (!scopeId) continue;
|
|
610
|
+
const mode = (0, import_runtime_config.resolveRuntimeConfigValidationMode)(target.policy);
|
|
526
611
|
const configPath = filesByScope.get(scopeId);
|
|
527
612
|
const schemaPath = target.cwd ? import_node_path.default.resolve(target.cwd, schemaFileName) : void 0;
|
|
528
613
|
if (!target.cwd || !schemaPath) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
614
|
+
if (shouldReportMissingRuntimeConfig(mode)) {
|
|
615
|
+
result.skipped.push({
|
|
616
|
+
...configPath ? { configPath } : {},
|
|
617
|
+
reason: "missing-scope-dir",
|
|
618
|
+
scopeId
|
|
619
|
+
});
|
|
620
|
+
}
|
|
534
621
|
continue;
|
|
535
622
|
}
|
|
536
623
|
if (!configPath) {
|
|
537
|
-
|
|
624
|
+
if (shouldReportMissingRuntimeConfig(mode)) {
|
|
625
|
+
result.skipped.push({ reason: "missing-config", schemaPath, scopeId });
|
|
626
|
+
}
|
|
538
627
|
continue;
|
|
539
628
|
}
|
|
540
629
|
if (!(0, import_node_fs.existsSync)(schemaPath)) {
|
|
@@ -543,14 +632,16 @@ function validateRuntimeConfigSourceScopes(source, targets, options = {}) {
|
|
|
543
632
|
}
|
|
544
633
|
result.validated.push({ configPath, schemaPath, scopeId });
|
|
545
634
|
}
|
|
546
|
-
|
|
635
|
+
result.invalid = collectRuntimeConfigSchemaTargetValidationErrors(result.validated, {
|
|
547
636
|
...options.formatError ? { formatError: options.formatError } : {}
|
|
548
637
|
});
|
|
549
638
|
return result;
|
|
550
639
|
}
|
|
551
640
|
// Annotate the CommonJS export names for ESM import in node:
|
|
552
641
|
0 && (module.exports = {
|
|
642
|
+
assertRequiredRuntimeConfigValidationTargets,
|
|
553
643
|
collectRuntimeConfigFragmentFiles,
|
|
644
|
+
collectRuntimeConfigSchemaTargetValidationErrors,
|
|
554
645
|
ensureParentDir,
|
|
555
646
|
getRuntimeConfigScopeView,
|
|
556
647
|
getRuntimeConfigValue,
|
|
@@ -565,6 +656,7 @@ function validateRuntimeConfigSourceScopes(source, targets, options = {}) {
|
|
|
565
656
|
projectRuntimeConfigTree,
|
|
566
657
|
readJsonFile,
|
|
567
658
|
readRequiredJsonFile,
|
|
659
|
+
readRuntimeConfigSchemaRegistry,
|
|
568
660
|
readRuntimeConfigScopeJson,
|
|
569
661
|
readTextFile,
|
|
570
662
|
resolveRuntimeConfigFilePath,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorObject, Options } from 'ajv';
|
|
2
|
-
import { ProjectRuntimeConfigEnvVarsOptions, SectionedRuntimeConfig, ConfigVisibility, RuntimeConfigSection, RuntimeConfigFragment, RuntimeEnvVars, RuntimeConfigFragmentMap } from '@lorion-org/runtime-config';
|
|
2
|
+
import { ProjectRuntimeConfigEnvVarsOptions, SectionedRuntimeConfig, RuntimeConfigValidationPolicyInput, ConfigVisibility, RuntimeConfigSection, RuntimeConfigFragment, RuntimeEnvVars, RuntimeConfigFragmentMap, RuntimeConfigValidationSchemaRegistry } from '@lorion-org/runtime-config';
|
|
3
3
|
|
|
4
4
|
type RuntimeConfigPaths = {
|
|
5
5
|
varDir: string;
|
|
@@ -111,6 +111,7 @@ type RuntimeConfigScopeViewResult = {
|
|
|
111
111
|
};
|
|
112
112
|
type RuntimeConfigSchemaTargetInput = {
|
|
113
113
|
cwd?: string;
|
|
114
|
+
policy?: RuntimeConfigValidationPolicyInput;
|
|
114
115
|
scopeId: string;
|
|
115
116
|
};
|
|
116
117
|
type RuntimeConfigValidationEntry = {
|
|
@@ -124,6 +125,9 @@ type RuntimeConfigValidationSkippedEntry = {
|
|
|
124
125
|
schemaPath?: string;
|
|
125
126
|
scopeId: string;
|
|
126
127
|
};
|
|
128
|
+
type RuntimeConfigValidationInvalidEntry = RuntimeConfigSchemaValidationTarget & {
|
|
129
|
+
error: Error;
|
|
130
|
+
};
|
|
127
131
|
type ValidateRuntimeConfigScopesOptions = RuntimeConfigPathOptions & {
|
|
128
132
|
formatError?: RuntimeConfigSchemaValidationErrorFormatter;
|
|
129
133
|
schemaFileName?: string;
|
|
@@ -131,10 +135,14 @@ type ValidateRuntimeConfigScopesOptions = RuntimeConfigPathOptions & {
|
|
|
131
135
|
type ValidateRuntimeConfigPatternSourceScopesOptions = Pick<ValidateRuntimeConfigScopesOptions, 'formatError' | 'schemaFileName'>;
|
|
132
136
|
type RuntimeConfigValidateResult = {
|
|
133
137
|
fileName: string;
|
|
138
|
+
invalid: RuntimeConfigValidationInvalidEntry[];
|
|
134
139
|
skipped: RuntimeConfigValidationSkippedEntry[];
|
|
135
140
|
validated: RuntimeConfigValidationEntry[];
|
|
136
141
|
varDir: string;
|
|
137
142
|
};
|
|
143
|
+
type ReadRuntimeConfigSchemaRegistryOptions = {
|
|
144
|
+
schemaFileName?: string;
|
|
145
|
+
};
|
|
138
146
|
declare function ensureParentDir(filePath: string): void;
|
|
139
147
|
declare function readTextFile(filePath: string): string | undefined;
|
|
140
148
|
declare function writeTextFile(filePath: string, data: string, options?: WriteFileOptions): void;
|
|
@@ -160,6 +168,7 @@ declare function parseRuntimeConfigFragmentFiles(filePaths: string[], runtimeCon
|
|
|
160
168
|
declare function loadRuntimeConfigFragment(varDir: string, scopeId: string, options?: RuntimeConfigPathOptions): RuntimeConfigFragment | undefined;
|
|
161
169
|
declare function writeRuntimeConfigFragment(varDir: string, scopeId: string, config: RuntimeConfigFragment, options?: RuntimeConfigPathOptions & WriteJsonFileOptions): void;
|
|
162
170
|
declare function validateRuntimeConfigSchemaTargets(targets: RuntimeConfigSchemaValidationTarget[], options?: ValidateRuntimeConfigSchemaTargetsOptions): void;
|
|
171
|
+
declare function collectRuntimeConfigSchemaTargetValidationErrors(targets: RuntimeConfigSchemaValidationTarget[], options?: ValidateRuntimeConfigSchemaTargetsOptions): RuntimeConfigValidationInvalidEntry[];
|
|
163
172
|
declare function loadRuntimeConfigTree(varDir: string, options?: RuntimeConfigPathOptions): RuntimeConfigFragmentMap;
|
|
164
173
|
declare function loadRuntimeConfigEnvVars(varDir: string, options?: RuntimeConfigEnvFileOptions): RuntimeEnvVars;
|
|
165
174
|
declare function loadRuntimeConfigShellAssignments(varDir: string, options?: RuntimeConfigEnvFileOptions): string;
|
|
@@ -169,6 +178,8 @@ declare function projectRuntimeConfigTree(varDir: string, options?: RuntimeConfi
|
|
|
169
178
|
declare function getRuntimeConfigValue(varDir: string, scopeId: string, key: string, options?: RuntimeConfigValueQueryOptions): RuntimeConfigValueResult;
|
|
170
179
|
declare function getRuntimeConfigScopeView(varDir: string, scopeId: string, options?: RuntimeConfigScopeViewOptions): RuntimeConfigScopeViewResult;
|
|
171
180
|
declare function validateRuntimeConfigScopes(varDir: string, targets: RuntimeConfigSchemaTargetInput[], options?: ValidateRuntimeConfigScopesOptions): RuntimeConfigValidateResult;
|
|
181
|
+
declare function readRuntimeConfigSchemaRegistry(targets: RuntimeConfigSchemaTargetInput[], options?: ReadRuntimeConfigSchemaRegistryOptions): RuntimeConfigValidationSchemaRegistry;
|
|
182
|
+
declare function assertRequiredRuntimeConfigValidationTargets(result: RuntimeConfigValidateResult, targets: RuntimeConfigSchemaTargetInput[]): void;
|
|
172
183
|
declare function validateRuntimeConfigSourceScopes(source: RuntimeConfigPathPatternSource, targets: RuntimeConfigSchemaTargetInput[], options?: ValidateRuntimeConfigPatternSourceScopesOptions): RuntimeConfigValidateResult;
|
|
173
184
|
|
|
174
|
-
export { type ReadJsonFileOptions, type ResolveRuntimeConfigSourceOptions, type RuntimeConfigEnvFileOptions, type RuntimeConfigListEntry, type RuntimeConfigListOptions, type RuntimeConfigListResult, type RuntimeConfigPathOptions, type RuntimeConfigPathPatternSource, type RuntimeConfigPaths, type RuntimeConfigProjectOptions, type RuntimeConfigProjectResult, type RuntimeConfigSchemaTargetInput, type RuntimeConfigSchemaValidationErrorFormatter, type RuntimeConfigSchemaValidationTarget, type RuntimeConfigScopeViewOptions, type RuntimeConfigScopeViewResult, type RuntimeConfigShowResult, type RuntimeConfigSource, type RuntimeConfigSourceFile, type RuntimeConfigValidateResult, type RuntimeConfigValidationEntry, type RuntimeConfigValidationSkippedEntry, type RuntimeConfigValueQueryOptions, type RuntimeConfigValueResult, type ValidateRuntimeConfigPatternSourceScopesOptions, type ValidateRuntimeConfigSchemaTargetsOptions, type ValidateRuntimeConfigScopesOptions, type WriteFileOptions, type WriteJsonFileOptions, collectRuntimeConfigFragmentFiles, ensureParentDir, getRuntimeConfigScopeView, getRuntimeConfigValue, listRuntimeConfigFragments, listRuntimeConfigScopeFiles, loadRuntimeConfigEnvVars, loadRuntimeConfigFragment, loadRuntimeConfigShellAssignments, loadRuntimeConfigSourceTree, loadRuntimeConfigTree, parseRuntimeConfigFragmentFiles, projectRuntimeConfigTree, readJsonFile, readRequiredJsonFile, readRuntimeConfigScopeJson, readTextFile, resolveRuntimeConfigFilePath, resolveRuntimeConfigPaths, resolveRuntimeConfigPublicFilePath, resolveRuntimeConfigPublicRootPath, resolveRuntimeConfigScopeFilePath, resolveRuntimeConfigSource, resolveRuntimeConfigSourceFiles, resolveRuntimeConfigSourcePublicRootPath, showRuntimeConfigFragment, validateRuntimeConfigSchemaTargets, validateRuntimeConfigScopes, validateRuntimeConfigSourceScopes, writeJsonFile, writeRuntimeConfigFragment, writeRuntimeConfigScopeJson, writeTextFile };
|
|
185
|
+
export { type ReadJsonFileOptions, type ReadRuntimeConfigSchemaRegistryOptions, type ResolveRuntimeConfigSourceOptions, type RuntimeConfigEnvFileOptions, type RuntimeConfigListEntry, type RuntimeConfigListOptions, type RuntimeConfigListResult, type RuntimeConfigPathOptions, type RuntimeConfigPathPatternSource, type RuntimeConfigPaths, type RuntimeConfigProjectOptions, type RuntimeConfigProjectResult, type RuntimeConfigSchemaTargetInput, type RuntimeConfigSchemaValidationErrorFormatter, type RuntimeConfigSchemaValidationTarget, type RuntimeConfigScopeViewOptions, type RuntimeConfigScopeViewResult, type RuntimeConfigShowResult, type RuntimeConfigSource, type RuntimeConfigSourceFile, type RuntimeConfigValidateResult, type RuntimeConfigValidationEntry, type RuntimeConfigValidationInvalidEntry, type RuntimeConfigValidationSkippedEntry, type RuntimeConfigValueQueryOptions, type RuntimeConfigValueResult, type ValidateRuntimeConfigPatternSourceScopesOptions, type ValidateRuntimeConfigSchemaTargetsOptions, type ValidateRuntimeConfigScopesOptions, type WriteFileOptions, type WriteJsonFileOptions, assertRequiredRuntimeConfigValidationTargets, collectRuntimeConfigFragmentFiles, collectRuntimeConfigSchemaTargetValidationErrors, ensureParentDir, getRuntimeConfigScopeView, getRuntimeConfigValue, listRuntimeConfigFragments, listRuntimeConfigScopeFiles, loadRuntimeConfigEnvVars, loadRuntimeConfigFragment, loadRuntimeConfigShellAssignments, loadRuntimeConfigSourceTree, loadRuntimeConfigTree, parseRuntimeConfigFragmentFiles, projectRuntimeConfigTree, readJsonFile, readRequiredJsonFile, readRuntimeConfigSchemaRegistry, readRuntimeConfigScopeJson, readTextFile, resolveRuntimeConfigFilePath, resolveRuntimeConfigPaths, resolveRuntimeConfigPublicFilePath, resolveRuntimeConfigPublicRootPath, resolveRuntimeConfigScopeFilePath, resolveRuntimeConfigSource, resolveRuntimeConfigSourceFiles, resolveRuntimeConfigSourcePublicRootPath, showRuntimeConfigFragment, validateRuntimeConfigSchemaTargets, validateRuntimeConfigScopes, validateRuntimeConfigSourceScopes, writeJsonFile, writeRuntimeConfigFragment, writeRuntimeConfigScopeJson, writeTextFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorObject, Options } from 'ajv';
|
|
2
|
-
import { ProjectRuntimeConfigEnvVarsOptions, SectionedRuntimeConfig, ConfigVisibility, RuntimeConfigSection, RuntimeConfigFragment, RuntimeEnvVars, RuntimeConfigFragmentMap } from '@lorion-org/runtime-config';
|
|
2
|
+
import { ProjectRuntimeConfigEnvVarsOptions, SectionedRuntimeConfig, RuntimeConfigValidationPolicyInput, ConfigVisibility, RuntimeConfigSection, RuntimeConfigFragment, RuntimeEnvVars, RuntimeConfigFragmentMap, RuntimeConfigValidationSchemaRegistry } from '@lorion-org/runtime-config';
|
|
3
3
|
|
|
4
4
|
type RuntimeConfigPaths = {
|
|
5
5
|
varDir: string;
|
|
@@ -111,6 +111,7 @@ type RuntimeConfigScopeViewResult = {
|
|
|
111
111
|
};
|
|
112
112
|
type RuntimeConfigSchemaTargetInput = {
|
|
113
113
|
cwd?: string;
|
|
114
|
+
policy?: RuntimeConfigValidationPolicyInput;
|
|
114
115
|
scopeId: string;
|
|
115
116
|
};
|
|
116
117
|
type RuntimeConfigValidationEntry = {
|
|
@@ -124,6 +125,9 @@ type RuntimeConfigValidationSkippedEntry = {
|
|
|
124
125
|
schemaPath?: string;
|
|
125
126
|
scopeId: string;
|
|
126
127
|
};
|
|
128
|
+
type RuntimeConfigValidationInvalidEntry = RuntimeConfigSchemaValidationTarget & {
|
|
129
|
+
error: Error;
|
|
130
|
+
};
|
|
127
131
|
type ValidateRuntimeConfigScopesOptions = RuntimeConfigPathOptions & {
|
|
128
132
|
formatError?: RuntimeConfigSchemaValidationErrorFormatter;
|
|
129
133
|
schemaFileName?: string;
|
|
@@ -131,10 +135,14 @@ type ValidateRuntimeConfigScopesOptions = RuntimeConfigPathOptions & {
|
|
|
131
135
|
type ValidateRuntimeConfigPatternSourceScopesOptions = Pick<ValidateRuntimeConfigScopesOptions, 'formatError' | 'schemaFileName'>;
|
|
132
136
|
type RuntimeConfigValidateResult = {
|
|
133
137
|
fileName: string;
|
|
138
|
+
invalid: RuntimeConfigValidationInvalidEntry[];
|
|
134
139
|
skipped: RuntimeConfigValidationSkippedEntry[];
|
|
135
140
|
validated: RuntimeConfigValidationEntry[];
|
|
136
141
|
varDir: string;
|
|
137
142
|
};
|
|
143
|
+
type ReadRuntimeConfigSchemaRegistryOptions = {
|
|
144
|
+
schemaFileName?: string;
|
|
145
|
+
};
|
|
138
146
|
declare function ensureParentDir(filePath: string): void;
|
|
139
147
|
declare function readTextFile(filePath: string): string | undefined;
|
|
140
148
|
declare function writeTextFile(filePath: string, data: string, options?: WriteFileOptions): void;
|
|
@@ -160,6 +168,7 @@ declare function parseRuntimeConfigFragmentFiles(filePaths: string[], runtimeCon
|
|
|
160
168
|
declare function loadRuntimeConfigFragment(varDir: string, scopeId: string, options?: RuntimeConfigPathOptions): RuntimeConfigFragment | undefined;
|
|
161
169
|
declare function writeRuntimeConfigFragment(varDir: string, scopeId: string, config: RuntimeConfigFragment, options?: RuntimeConfigPathOptions & WriteJsonFileOptions): void;
|
|
162
170
|
declare function validateRuntimeConfigSchemaTargets(targets: RuntimeConfigSchemaValidationTarget[], options?: ValidateRuntimeConfigSchemaTargetsOptions): void;
|
|
171
|
+
declare function collectRuntimeConfigSchemaTargetValidationErrors(targets: RuntimeConfigSchemaValidationTarget[], options?: ValidateRuntimeConfigSchemaTargetsOptions): RuntimeConfigValidationInvalidEntry[];
|
|
163
172
|
declare function loadRuntimeConfigTree(varDir: string, options?: RuntimeConfigPathOptions): RuntimeConfigFragmentMap;
|
|
164
173
|
declare function loadRuntimeConfigEnvVars(varDir: string, options?: RuntimeConfigEnvFileOptions): RuntimeEnvVars;
|
|
165
174
|
declare function loadRuntimeConfigShellAssignments(varDir: string, options?: RuntimeConfigEnvFileOptions): string;
|
|
@@ -169,6 +178,8 @@ declare function projectRuntimeConfigTree(varDir: string, options?: RuntimeConfi
|
|
|
169
178
|
declare function getRuntimeConfigValue(varDir: string, scopeId: string, key: string, options?: RuntimeConfigValueQueryOptions): RuntimeConfigValueResult;
|
|
170
179
|
declare function getRuntimeConfigScopeView(varDir: string, scopeId: string, options?: RuntimeConfigScopeViewOptions): RuntimeConfigScopeViewResult;
|
|
171
180
|
declare function validateRuntimeConfigScopes(varDir: string, targets: RuntimeConfigSchemaTargetInput[], options?: ValidateRuntimeConfigScopesOptions): RuntimeConfigValidateResult;
|
|
181
|
+
declare function readRuntimeConfigSchemaRegistry(targets: RuntimeConfigSchemaTargetInput[], options?: ReadRuntimeConfigSchemaRegistryOptions): RuntimeConfigValidationSchemaRegistry;
|
|
182
|
+
declare function assertRequiredRuntimeConfigValidationTargets(result: RuntimeConfigValidateResult, targets: RuntimeConfigSchemaTargetInput[]): void;
|
|
172
183
|
declare function validateRuntimeConfigSourceScopes(source: RuntimeConfigPathPatternSource, targets: RuntimeConfigSchemaTargetInput[], options?: ValidateRuntimeConfigPatternSourceScopesOptions): RuntimeConfigValidateResult;
|
|
173
184
|
|
|
174
|
-
export { type ReadJsonFileOptions, type ResolveRuntimeConfigSourceOptions, type RuntimeConfigEnvFileOptions, type RuntimeConfigListEntry, type RuntimeConfigListOptions, type RuntimeConfigListResult, type RuntimeConfigPathOptions, type RuntimeConfigPathPatternSource, type RuntimeConfigPaths, type RuntimeConfigProjectOptions, type RuntimeConfigProjectResult, type RuntimeConfigSchemaTargetInput, type RuntimeConfigSchemaValidationErrorFormatter, type RuntimeConfigSchemaValidationTarget, type RuntimeConfigScopeViewOptions, type RuntimeConfigScopeViewResult, type RuntimeConfigShowResult, type RuntimeConfigSource, type RuntimeConfigSourceFile, type RuntimeConfigValidateResult, type RuntimeConfigValidationEntry, type RuntimeConfigValidationSkippedEntry, type RuntimeConfigValueQueryOptions, type RuntimeConfigValueResult, type ValidateRuntimeConfigPatternSourceScopesOptions, type ValidateRuntimeConfigSchemaTargetsOptions, type ValidateRuntimeConfigScopesOptions, type WriteFileOptions, type WriteJsonFileOptions, collectRuntimeConfigFragmentFiles, ensureParentDir, getRuntimeConfigScopeView, getRuntimeConfigValue, listRuntimeConfigFragments, listRuntimeConfigScopeFiles, loadRuntimeConfigEnvVars, loadRuntimeConfigFragment, loadRuntimeConfigShellAssignments, loadRuntimeConfigSourceTree, loadRuntimeConfigTree, parseRuntimeConfigFragmentFiles, projectRuntimeConfigTree, readJsonFile, readRequiredJsonFile, readRuntimeConfigScopeJson, readTextFile, resolveRuntimeConfigFilePath, resolveRuntimeConfigPaths, resolveRuntimeConfigPublicFilePath, resolveRuntimeConfigPublicRootPath, resolveRuntimeConfigScopeFilePath, resolveRuntimeConfigSource, resolveRuntimeConfigSourceFiles, resolveRuntimeConfigSourcePublicRootPath, showRuntimeConfigFragment, validateRuntimeConfigSchemaTargets, validateRuntimeConfigScopes, validateRuntimeConfigSourceScopes, writeJsonFile, writeRuntimeConfigFragment, writeRuntimeConfigScopeJson, writeTextFile };
|
|
185
|
+
export { type ReadJsonFileOptions, type ReadRuntimeConfigSchemaRegistryOptions, type ResolveRuntimeConfigSourceOptions, type RuntimeConfigEnvFileOptions, type RuntimeConfigListEntry, type RuntimeConfigListOptions, type RuntimeConfigListResult, type RuntimeConfigPathOptions, type RuntimeConfigPathPatternSource, type RuntimeConfigPaths, type RuntimeConfigProjectOptions, type RuntimeConfigProjectResult, type RuntimeConfigSchemaTargetInput, type RuntimeConfigSchemaValidationErrorFormatter, type RuntimeConfigSchemaValidationTarget, type RuntimeConfigScopeViewOptions, type RuntimeConfigScopeViewResult, type RuntimeConfigShowResult, type RuntimeConfigSource, type RuntimeConfigSourceFile, type RuntimeConfigValidateResult, type RuntimeConfigValidationEntry, type RuntimeConfigValidationInvalidEntry, type RuntimeConfigValidationSkippedEntry, type RuntimeConfigValueQueryOptions, type RuntimeConfigValueResult, type ValidateRuntimeConfigPatternSourceScopesOptions, type ValidateRuntimeConfigSchemaTargetsOptions, type ValidateRuntimeConfigScopesOptions, type WriteFileOptions, type WriteJsonFileOptions, assertRequiredRuntimeConfigValidationTargets, collectRuntimeConfigFragmentFiles, collectRuntimeConfigSchemaTargetValidationErrors, ensureParentDir, getRuntimeConfigScopeView, getRuntimeConfigValue, listRuntimeConfigFragments, listRuntimeConfigScopeFiles, loadRuntimeConfigEnvVars, loadRuntimeConfigFragment, loadRuntimeConfigShellAssignments, loadRuntimeConfigSourceTree, loadRuntimeConfigTree, parseRuntimeConfigFragmentFiles, projectRuntimeConfigTree, readJsonFile, readRequiredJsonFile, readRuntimeConfigSchemaRegistry, readRuntimeConfigScopeJson, readTextFile, resolveRuntimeConfigFilePath, resolveRuntimeConfigPaths, resolveRuntimeConfigPublicFilePath, resolveRuntimeConfigPublicRootPath, resolveRuntimeConfigScopeFilePath, resolveRuntimeConfigSource, resolveRuntimeConfigSourceFiles, resolveRuntimeConfigSourcePublicRootPath, showRuntimeConfigFragment, validateRuntimeConfigSchemaTargets, validateRuntimeConfigScopes, validateRuntimeConfigSourceScopes, writeJsonFile, writeRuntimeConfigFragment, writeRuntimeConfigScopeJson, writeTextFile };
|