@kitsy/cnos 1.9.2 → 1.10.0
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/build/index.cjs +193 -18
- package/dist/build/index.d.cts +1 -1
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +8 -8
- package/dist/{chunk-2JBA2LXU.js → chunk-3EZGPQCE.js} +35 -6
- package/dist/{chunk-6QQPHDUI.js → chunk-A5U7EZCJ.js} +1 -1
- package/dist/{chunk-CPGRRZLP.js → chunk-CSA4L64V.js} +10 -10
- package/dist/{chunk-QK7BMU47.js → chunk-EIK7OUFP.js} +3 -3
- package/dist/{chunk-A2WG3ZKW.js → chunk-ESBHCFC6.js} +1 -1
- package/dist/{chunk-7JZO6XN3.js → chunk-FHXLOWAB.js} +1 -1
- package/dist/{chunk-7KVM5PUW.js → chunk-MQ4WG3K6.js} +158 -12
- package/dist/{chunk-LURQ4LAK.js → chunk-RTHKUGJV.js} +1 -1
- package/dist/{chunk-L7JVECPE.js → chunk-UGLATJJD.js} +1 -1
- package/dist/{chunk-NVFACB64.js → chunk-UKNL2Y4N.js} +1 -1
- package/dist/configure/index.cjs +193 -18
- package/dist/configure/index.d.cts +3 -3
- package/dist/configure/index.d.ts +3 -3
- package/dist/configure/index.js +8 -8
- package/dist/{core-zDTUSVx9.d.cts → core-Ud1o2MBn.d.cts} +12 -5
- package/dist/{core-zDTUSVx9.d.ts → core-Ud1o2MBn.d.ts} +12 -5
- package/dist/{envNaming-BkorOKW_.d.ts → envNaming-CPwXl4I6.d.ts} +1 -1
- package/dist/{envNaming-EFzezmB3.d.cts → envNaming-DxxqiGKN.d.cts} +1 -1
- package/dist/index.cjs +193 -18
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -10
- package/dist/internal.cjs +289 -31
- package/dist/internal.d.cts +31 -3
- package/dist/internal.d.ts +31 -3
- package/dist/internal.js +141 -23
- package/dist/plugin/basic-schema.cjs +9 -2
- package/dist/plugin/basic-schema.d.cts +1 -1
- package/dist/plugin/basic-schema.d.ts +1 -1
- package/dist/plugin/basic-schema.js +2 -2
- package/dist/plugin/cli-args.d.cts +1 -1
- package/dist/plugin/cli-args.d.ts +1 -1
- package/dist/plugin/cli-args.js +2 -2
- package/dist/plugin/dotenv.cjs +34 -5
- package/dist/plugin/dotenv.d.cts +2 -2
- package/dist/plugin/dotenv.d.ts +2 -2
- package/dist/plugin/dotenv.js +2 -2
- package/dist/plugin/env-export.d.cts +2 -2
- package/dist/plugin/env-export.d.ts +2 -2
- package/dist/plugin/env-export.js +2 -2
- package/dist/plugin/filesystem.d.cts +1 -1
- package/dist/plugin/filesystem.d.ts +1 -1
- package/dist/plugin/filesystem.js +2 -2
- package/dist/plugin/process-env.d.cts +2 -2
- package/dist/plugin/process-env.d.ts +2 -2
- package/dist/plugin/process-env.js +2 -2
- package/dist/runtime/index.cjs +193 -18
- package/dist/runtime/index.d.cts +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +10 -10
- package/dist/{toPublicEnv-CT265rzS.d.ts → toPublicEnv-C9wPSpRo.d.ts} +1 -1
- package/dist/{toPublicEnv-Ds1DRwCX.d.cts → toPublicEnv-fUZMRUOz.d.cts} +1 -1
- package/package.json +1 -1
package/dist/internal.cjs
CHANGED
|
@@ -40,6 +40,7 @@ __export(internal_exports, {
|
|
|
40
40
|
clearAllVaultSessionKeys: () => clearAllVaultSessionKeys,
|
|
41
41
|
clearVaultSessionKey: () => clearVaultSessionKey,
|
|
42
42
|
compareSchemaToGraph: () => compareSchemaToGraph,
|
|
43
|
+
compareSpecToGraph: () => compareSpecToGraph,
|
|
43
44
|
createRemoteRootCacheKey: () => createRemoteRootCacheKey,
|
|
44
45
|
createSecretVault: () => createSecretVault,
|
|
45
46
|
createSecretVaultProvider: () => createSecretVaultProvider,
|
|
@@ -1033,6 +1034,134 @@ function resolveConfigDocumentPath(workspaceRoot, namespace, configPath, profile
|
|
|
1033
1034
|
return import_node_path5.default.resolve(namespaceRoot, fileName);
|
|
1034
1035
|
}
|
|
1035
1036
|
|
|
1037
|
+
// ../core/src/spec/normalizeSpecRule.ts
|
|
1038
|
+
var ALLOWED_TYPES = /* @__PURE__ */ new Set(["string", "number", "boolean", "object", "array"]);
|
|
1039
|
+
var SECRET_FORBIDDEN_FIELDS = ["default", "examples", "enum"];
|
|
1040
|
+
function hasOwn(target, key) {
|
|
1041
|
+
return Object.prototype.hasOwnProperty.call(target, key);
|
|
1042
|
+
}
|
|
1043
|
+
function normalizeOptionalString(value, fieldName, logicalKey) {
|
|
1044
|
+
if (value === void 0) {
|
|
1045
|
+
return void 0;
|
|
1046
|
+
}
|
|
1047
|
+
if (typeof value !== "string") {
|
|
1048
|
+
throw new CnosManifestError(`Invalid schema rule for ${logicalKey}: "${fieldName}" must be a string.`);
|
|
1049
|
+
}
|
|
1050
|
+
const nextValue = value.trim();
|
|
1051
|
+
return nextValue.length > 0 ? nextValue : void 0;
|
|
1052
|
+
}
|
|
1053
|
+
function normalizeStringArray(value, fieldName, logicalKey) {
|
|
1054
|
+
if (value === void 0) {
|
|
1055
|
+
return void 0;
|
|
1056
|
+
}
|
|
1057
|
+
if (!Array.isArray(value)) {
|
|
1058
|
+
throw new CnosManifestError(`Invalid schema rule for ${logicalKey}: "${fieldName}" must be an array.`);
|
|
1059
|
+
}
|
|
1060
|
+
const nextValue = value.map((entry) => {
|
|
1061
|
+
if (typeof entry !== "string") {
|
|
1062
|
+
throw new CnosManifestError(
|
|
1063
|
+
`Invalid schema rule for ${logicalKey}: "${fieldName}" entries must be strings.`
|
|
1064
|
+
);
|
|
1065
|
+
}
|
|
1066
|
+
return entry.trim();
|
|
1067
|
+
}).filter(Boolean);
|
|
1068
|
+
return nextValue.length > 0 ? nextValue : void 0;
|
|
1069
|
+
}
|
|
1070
|
+
function normalizeUnknownArray(value, fieldName, logicalKey) {
|
|
1071
|
+
if (value === void 0) {
|
|
1072
|
+
return void 0;
|
|
1073
|
+
}
|
|
1074
|
+
if (!Array.isArray(value)) {
|
|
1075
|
+
throw new CnosManifestError(`Invalid schema rule for ${logicalKey}: "${fieldName}" must be an array.`);
|
|
1076
|
+
}
|
|
1077
|
+
return value.length > 0 ? value : void 0;
|
|
1078
|
+
}
|
|
1079
|
+
function assertValidPatternRegex(pattern, logicalKey) {
|
|
1080
|
+
try {
|
|
1081
|
+
void new RegExp(pattern);
|
|
1082
|
+
} catch (error) {
|
|
1083
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1084
|
+
throw new CnosManifestError(
|
|
1085
|
+
`Invalid schema rule for ${logicalKey}: "pattern" must be a valid regex (${reason}).`
|
|
1086
|
+
);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
function assertSecretRuleSafety(logicalKey, rule) {
|
|
1090
|
+
if (!logicalKey.startsWith("secret.")) {
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
const offendingFields = SECRET_FORBIDDEN_FIELDS.filter((field) => hasOwn(rule, field));
|
|
1094
|
+
if (offendingFields.length === 0) {
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
throw new CnosManifestError(
|
|
1098
|
+
`Invalid schema rule for ${logicalKey}: secret specs cannot include ${offendingFields.join(", ")}. Store secret values in the vault, not schema metadata. Remove ${offendingFields.map((field) => `schema.${logicalKey}.${field}`).join(", ")} to continue.`
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
function normalizeSpecRule(logicalKey, rule) {
|
|
1102
|
+
if (!rule || typeof rule !== "object" || Array.isArray(rule)) {
|
|
1103
|
+
throw new CnosManifestError(`Invalid schema rule for ${logicalKey}: expected an object.`);
|
|
1104
|
+
}
|
|
1105
|
+
const candidate = rule;
|
|
1106
|
+
assertSecretRuleSafety(logicalKey, candidate);
|
|
1107
|
+
const normalized = {};
|
|
1108
|
+
if (candidate.type !== void 0) {
|
|
1109
|
+
if (typeof candidate.type !== "string" || !ALLOWED_TYPES.has(candidate.type)) {
|
|
1110
|
+
throw new CnosManifestError(`Invalid schema rule for ${logicalKey}: unsupported type "${String(candidate.type)}".`);
|
|
1111
|
+
}
|
|
1112
|
+
normalized.type = candidate.type;
|
|
1113
|
+
}
|
|
1114
|
+
if (candidate.required !== void 0) {
|
|
1115
|
+
if (typeof candidate.required !== "boolean") {
|
|
1116
|
+
throw new CnosManifestError(`Invalid schema rule for ${logicalKey}: "required" must be a boolean.`);
|
|
1117
|
+
}
|
|
1118
|
+
normalized.required = candidate.required;
|
|
1119
|
+
}
|
|
1120
|
+
if (hasOwn(candidate, "default")) {
|
|
1121
|
+
normalized.default = candidate.default;
|
|
1122
|
+
}
|
|
1123
|
+
const normalizedEnum = normalizeUnknownArray(candidate.enum, "enum", logicalKey);
|
|
1124
|
+
if (normalizedEnum !== void 0) {
|
|
1125
|
+
normalized.enum = normalizedEnum;
|
|
1126
|
+
}
|
|
1127
|
+
const normalizedPattern = normalizeOptionalString(candidate.pattern, "pattern", logicalKey);
|
|
1128
|
+
if (normalizedPattern !== void 0) {
|
|
1129
|
+
assertValidPatternRegex(normalizedPattern, logicalKey);
|
|
1130
|
+
normalized.pattern = normalizedPattern;
|
|
1131
|
+
}
|
|
1132
|
+
const normalizedSummary = normalizeOptionalString(candidate.summary, "summary", logicalKey);
|
|
1133
|
+
if (normalizedSummary !== void 0) {
|
|
1134
|
+
normalized.summary = normalizedSummary;
|
|
1135
|
+
}
|
|
1136
|
+
const normalizedDescription = normalizeOptionalString(candidate.description, "description", logicalKey);
|
|
1137
|
+
if (normalizedDescription !== void 0) {
|
|
1138
|
+
normalized.description = normalizedDescription;
|
|
1139
|
+
}
|
|
1140
|
+
const normalizedExamples = normalizeUnknownArray(candidate.examples, "examples", logicalKey);
|
|
1141
|
+
if (normalizedExamples !== void 0) {
|
|
1142
|
+
normalized.examples = normalizedExamples;
|
|
1143
|
+
}
|
|
1144
|
+
const normalizedUsedBy = normalizeStringArray(candidate.usedBy, "usedBy", logicalKey);
|
|
1145
|
+
if (normalizedUsedBy !== void 0) {
|
|
1146
|
+
normalized.usedBy = normalizedUsedBy;
|
|
1147
|
+
}
|
|
1148
|
+
if (candidate.deprecated !== void 0) {
|
|
1149
|
+
if (typeof candidate.deprecated !== "boolean") {
|
|
1150
|
+
throw new CnosManifestError(`Invalid schema rule for ${logicalKey}: "deprecated" must be a boolean.`);
|
|
1151
|
+
}
|
|
1152
|
+
normalized.deprecated = candidate.deprecated;
|
|
1153
|
+
}
|
|
1154
|
+
const normalizedDeprecationMessage = normalizeOptionalString(
|
|
1155
|
+
candidate.deprecationMessage,
|
|
1156
|
+
"deprecationMessage",
|
|
1157
|
+
logicalKey
|
|
1158
|
+
);
|
|
1159
|
+
if (normalizedDeprecationMessage !== void 0) {
|
|
1160
|
+
normalized.deprecationMessage = normalizedDeprecationMessage;
|
|
1161
|
+
}
|
|
1162
|
+
return normalized;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1036
1165
|
// ../core/src/manifest/normalizeManifest.ts
|
|
1037
1166
|
var DEFAULT_RESOLVE_FROM = ["cli.profile", "env.CNOS_PROFILE", "default"];
|
|
1038
1167
|
var DEFAULT_LOADERS = [
|
|
@@ -1231,6 +1360,14 @@ function normalizeVaultAuth(vaultName, provider, auth) {
|
|
|
1231
1360
|
...auth?.config ? { config: auth.config } : {}
|
|
1232
1361
|
};
|
|
1233
1362
|
}
|
|
1363
|
+
function normalizeSchema(schema) {
|
|
1364
|
+
return Object.fromEntries(
|
|
1365
|
+
Object.entries(schema ?? {}).map(([logicalKey, rule]) => [
|
|
1366
|
+
logicalKey,
|
|
1367
|
+
normalizeSpecRule(logicalKey, rule)
|
|
1368
|
+
])
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1234
1371
|
function normalizeManifest(manifest) {
|
|
1235
1372
|
const version = manifest.version ?? 1;
|
|
1236
1373
|
if (version !== 1) {
|
|
@@ -1328,7 +1465,7 @@ function normalizeManifest(manifest) {
|
|
|
1328
1465
|
}
|
|
1329
1466
|
}
|
|
1330
1467
|
},
|
|
1331
|
-
schema: manifest.schema
|
|
1468
|
+
schema: normalizeSchema(manifest.schema)
|
|
1332
1469
|
};
|
|
1333
1470
|
}
|
|
1334
1471
|
|
|
@@ -1836,16 +1973,19 @@ async function removeLocalVaultFiles(storeRoot, vault = "default") {
|
|
|
1836
1973
|
// ../core/src/secrets/auditLog.ts
|
|
1837
1974
|
async function appendAuditEvent(event, processEnv = process.env) {
|
|
1838
1975
|
const auditFile = processEnv.CNOS_AUDIT_FILE ?? import_node_path12.default.join(resolveSecretStoreRoot(processEnv), "audit", "access.log");
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1976
|
+
try {
|
|
1977
|
+
await (0, import_promises11.mkdir)(import_node_path12.default.dirname(auditFile), { recursive: true });
|
|
1978
|
+
await (0, import_promises11.appendFile)(
|
|
1979
|
+
auditFile,
|
|
1980
|
+
`${JSON.stringify({
|
|
1981
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1982
|
+
...event
|
|
1983
|
+
})}
|
|
1846
1984
|
`,
|
|
1847
|
-
|
|
1848
|
-
|
|
1985
|
+
"utf8"
|
|
1986
|
+
);
|
|
1987
|
+
} catch {
|
|
1988
|
+
}
|
|
1849
1989
|
}
|
|
1850
1990
|
|
|
1851
1991
|
// ../core/src/secrets/providers/environment.ts
|
|
@@ -2580,7 +2720,7 @@ async function watchSchema(options = {}) {
|
|
|
2580
2720
|
return watcher;
|
|
2581
2721
|
}
|
|
2582
2722
|
|
|
2583
|
-
// src/
|
|
2723
|
+
// src/spec/compareSpecToGraph.ts
|
|
2584
2724
|
function describeValueType(value) {
|
|
2585
2725
|
if (Array.isArray(value)) {
|
|
2586
2726
|
return "array";
|
|
@@ -2603,6 +2743,17 @@ function matchesType(value, type) {
|
|
|
2603
2743
|
return typeof value === type;
|
|
2604
2744
|
}
|
|
2605
2745
|
}
|
|
2746
|
+
function enumMatches(value, allowed) {
|
|
2747
|
+
const serialized = JSON.stringify(value);
|
|
2748
|
+
return allowed.some((candidate) => JSON.stringify(candidate) === serialized);
|
|
2749
|
+
}
|
|
2750
|
+
function matchesPattern(pattern, value) {
|
|
2751
|
+
try {
|
|
2752
|
+
return new RegExp(pattern).test(value);
|
|
2753
|
+
} catch {
|
|
2754
|
+
return false;
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2606
2757
|
function isSchemaDefault(entry) {
|
|
2607
2758
|
return entry.winner.metadata?.schemaDefault === true;
|
|
2608
2759
|
}
|
|
@@ -2612,34 +2763,53 @@ function shouldTrackKey(key) {
|
|
|
2612
2763
|
function isTransientRuntimeSource(entry) {
|
|
2613
2764
|
return entry.winner.sourceId === "process-env" || entry.winner.sourceId === "cli-args";
|
|
2614
2765
|
}
|
|
2615
|
-
function
|
|
2766
|
+
function buildSummary(issues) {
|
|
2767
|
+
return {
|
|
2768
|
+
missingRequired: issues.filter((issue) => issue.status === "missing_required").length,
|
|
2769
|
+
undeclared: issues.filter((issue) => issue.status === "undeclared").length,
|
|
2770
|
+
typeMismatch: issues.filter((issue) => issue.status === "type_mismatch").length,
|
|
2771
|
+
enumMismatch: issues.filter((issue) => issue.status === "enum_mismatch").length,
|
|
2772
|
+
patternMismatch: issues.filter((issue) => issue.status === "pattern_mismatch").length,
|
|
2773
|
+
defaultApplied: issues.filter((issue) => issue.status === "default_applied").length,
|
|
2774
|
+
deprecatedInUse: issues.filter((issue) => issue.status === "deprecated_in_use").length
|
|
2775
|
+
};
|
|
2776
|
+
}
|
|
2777
|
+
function compareSpecToGraph(runtime) {
|
|
2616
2778
|
const schema = runtime.manifest.schema;
|
|
2617
|
-
const
|
|
2618
|
-
const mismatches = [];
|
|
2619
|
-
const defaultsApplied = [];
|
|
2779
|
+
const issues = [];
|
|
2620
2780
|
for (const [key, rule] of Object.entries(schema).sort(([left], [right]) => left.localeCompare(right))) {
|
|
2621
2781
|
const entry = runtime.graph.entries.get(key);
|
|
2782
|
+
const summary = rule.summary;
|
|
2622
2783
|
if (!entry) {
|
|
2623
2784
|
if (rule.required && rule.default === void 0) {
|
|
2624
|
-
|
|
2785
|
+
issues.push({
|
|
2625
2786
|
key,
|
|
2787
|
+
status: "missing_required",
|
|
2626
2788
|
...rule.type ? {
|
|
2627
2789
|
expectedType: rule.type
|
|
2790
|
+
} : {},
|
|
2791
|
+
...summary ? {
|
|
2792
|
+
summary
|
|
2628
2793
|
} : {}
|
|
2629
2794
|
});
|
|
2630
2795
|
}
|
|
2631
2796
|
continue;
|
|
2632
2797
|
}
|
|
2633
2798
|
if (isSchemaDefault(entry)) {
|
|
2634
|
-
|
|
2799
|
+
issues.push({
|
|
2635
2800
|
key,
|
|
2636
|
-
|
|
2801
|
+
status: "default_applied",
|
|
2802
|
+
value: entry.value,
|
|
2803
|
+
...summary ? {
|
|
2804
|
+
summary
|
|
2805
|
+
} : {}
|
|
2637
2806
|
});
|
|
2638
2807
|
}
|
|
2639
2808
|
const actualValue = entry.winner.value;
|
|
2640
2809
|
if (!matchesType(actualValue, rule.type)) {
|
|
2641
|
-
|
|
2810
|
+
issues.push({
|
|
2642
2811
|
key,
|
|
2812
|
+
status: "type_mismatch",
|
|
2643
2813
|
...rule.type ? {
|
|
2644
2814
|
expectedType: rule.type
|
|
2645
2815
|
} : {},
|
|
@@ -2647,26 +2817,113 @@ function compareSchemaToGraph(runtime) {
|
|
|
2647
2817
|
value: actualValue,
|
|
2648
2818
|
...entry.winner.origin?.file ? {
|
|
2649
2819
|
sourceFile: entry.winner.origin.file
|
|
2820
|
+
} : {},
|
|
2821
|
+
...summary ? {
|
|
2822
|
+
summary
|
|
2823
|
+
} : {}
|
|
2824
|
+
});
|
|
2825
|
+
}
|
|
2826
|
+
if (rule.enum && !enumMatches(actualValue, rule.enum)) {
|
|
2827
|
+
issues.push({
|
|
2828
|
+
key,
|
|
2829
|
+
status: "enum_mismatch",
|
|
2830
|
+
value: actualValue,
|
|
2831
|
+
...summary ? {
|
|
2832
|
+
summary
|
|
2833
|
+
} : {}
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
if (rule.pattern) {
|
|
2837
|
+
if (typeof actualValue !== "string" || !matchesPattern(rule.pattern, actualValue)) {
|
|
2838
|
+
issues.push({
|
|
2839
|
+
key,
|
|
2840
|
+
status: "pattern_mismatch",
|
|
2841
|
+
value: actualValue,
|
|
2842
|
+
pattern: rule.pattern,
|
|
2843
|
+
...summary ? {
|
|
2844
|
+
summary
|
|
2845
|
+
} : {}
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
if (rule.deprecated) {
|
|
2850
|
+
issues.push({
|
|
2851
|
+
key,
|
|
2852
|
+
status: "deprecated_in_use",
|
|
2853
|
+
value: actualValue,
|
|
2854
|
+
...summary ? {
|
|
2855
|
+
summary
|
|
2650
2856
|
} : {}
|
|
2651
2857
|
});
|
|
2652
2858
|
}
|
|
2653
2859
|
}
|
|
2654
|
-
const
|
|
2860
|
+
const undeclaredIssues = Array.from(runtime.graph.entries.values()).filter(
|
|
2655
2861
|
(entry) => shouldTrackKey(entry.key) && !schema[entry.key] && !isSchemaDefault(entry) && !isTransientRuntimeSource(entry)
|
|
2656
|
-
).map((entry) => {
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
}).sort((left, right) => left.key.localeCompare(right.key));
|
|
2862
|
+
).map((entry) => ({
|
|
2863
|
+
key: entry.key,
|
|
2864
|
+
status: "undeclared",
|
|
2865
|
+
value: entry.winner.value,
|
|
2866
|
+
actualType: describeValueType(entry.winner.value),
|
|
2867
|
+
...entry.winner.origin?.file ? {
|
|
2868
|
+
sourceFile: entry.winner.origin.file
|
|
2869
|
+
} : {}
|
|
2870
|
+
})).sort((left, right) => left.key.localeCompare(right.key));
|
|
2871
|
+
const allIssues = [...issues, ...undeclaredIssues].sort((left, right) => left.key.localeCompare(right.key));
|
|
2667
2872
|
return {
|
|
2668
2873
|
profile: runtime.graph.profile,
|
|
2669
2874
|
workspace: runtime.graph.workspace.workspaceId,
|
|
2875
|
+
summary: buildSummary(allIssues),
|
|
2876
|
+
issues: allIssues
|
|
2877
|
+
};
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
// src/drift/compareSchemaToGraph.ts
|
|
2881
|
+
function compareSchemaToGraph(runtime) {
|
|
2882
|
+
const report = compareSpecToGraph(runtime);
|
|
2883
|
+
const missing = report.issues.filter((issue) => issue.status === "missing_required").map(
|
|
2884
|
+
(issue) => ({
|
|
2885
|
+
key: issue.key,
|
|
2886
|
+
...issue.expectedType ? {
|
|
2887
|
+
expectedType: issue.expectedType
|
|
2888
|
+
} : {}
|
|
2889
|
+
})
|
|
2890
|
+
);
|
|
2891
|
+
const undeclared = report.issues.filter((issue) => issue.status === "undeclared").map(
|
|
2892
|
+
(issue) => ({
|
|
2893
|
+
key: issue.key,
|
|
2894
|
+
value: issue.value,
|
|
2895
|
+
...issue.actualType ? {
|
|
2896
|
+
actualType: issue.actualType
|
|
2897
|
+
} : {},
|
|
2898
|
+
...issue.sourceFile ? {
|
|
2899
|
+
sourceFile: issue.sourceFile
|
|
2900
|
+
} : {}
|
|
2901
|
+
})
|
|
2902
|
+
);
|
|
2903
|
+
const mismatches = report.issues.filter((issue) => issue.status === "type_mismatch").map(
|
|
2904
|
+
(issue) => ({
|
|
2905
|
+
key: issue.key,
|
|
2906
|
+
...issue.expectedType ? {
|
|
2907
|
+
expectedType: issue.expectedType
|
|
2908
|
+
} : {},
|
|
2909
|
+
...issue.actualType ? {
|
|
2910
|
+
actualType: issue.actualType
|
|
2911
|
+
} : {},
|
|
2912
|
+
value: issue.value,
|
|
2913
|
+
...issue.sourceFile ? {
|
|
2914
|
+
sourceFile: issue.sourceFile
|
|
2915
|
+
} : {}
|
|
2916
|
+
})
|
|
2917
|
+
);
|
|
2918
|
+
const defaultsApplied = report.issues.filter((issue) => issue.status === "default_applied").map(
|
|
2919
|
+
(issue) => ({
|
|
2920
|
+
key: issue.key,
|
|
2921
|
+
value: issue.value
|
|
2922
|
+
})
|
|
2923
|
+
);
|
|
2924
|
+
return {
|
|
2925
|
+
profile: report.profile,
|
|
2926
|
+
workspace: report.workspace,
|
|
2670
2927
|
missing,
|
|
2671
2928
|
undeclared,
|
|
2672
2929
|
mismatches,
|
|
@@ -2978,6 +3235,7 @@ async function watchFiles(runtime, root) {
|
|
|
2978
3235
|
clearAllVaultSessionKeys,
|
|
2979
3236
|
clearVaultSessionKey,
|
|
2980
3237
|
compareSchemaToGraph,
|
|
3238
|
+
compareSpecToGraph,
|
|
2981
3239
|
createRemoteRootCacheKey,
|
|
2982
3240
|
createSecretVault,
|
|
2983
3241
|
createSecretVaultProvider,
|
package/dist/internal.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as DerivedValue, P as ParsedDerivation, N as NormalizedManifest, n as LoadManifestOptions, o as LoadedManifest, b as LogicalKey, p as NamespaceDefinition, q as VaultDefinition, r as VaultAuthConfig, s as SecretVaultProvider, t as ResolvedRoot, m as NamespaceName, u as RootResolution, v as SecretReference, g as CnosRuntime, w as ValidationSummary, R as ResolvedGraph, S as ServerProjection } from './core-
|
|
2
|
-
export { l as RuntimeProvider, x as ValidationIssue, y as WorkspaceFile } from './core-
|
|
1
|
+
import { j as DerivedValue, P as ParsedDerivation, N as NormalizedManifest, n as LoadManifestOptions, o as LoadedManifest, b as LogicalKey, p as NamespaceDefinition, q as VaultDefinition, r as VaultAuthConfig, s as SecretVaultProvider, t as ResolvedRoot, m as NamespaceName, u as RootResolution, v as SecretReference, g as CnosRuntime, w as ValidationSummary, R as ResolvedGraph, S as ServerProjection } from './core-Ud1o2MBn.cjs';
|
|
2
|
+
export { l as RuntimeProvider, x as ValidationIssue, y as WorkspaceFile } from './core-Ud1o2MBn.cjs';
|
|
3
3
|
|
|
4
4
|
declare class CnosError extends Error {
|
|
5
5
|
constructor(message: string);
|
|
@@ -189,6 +189,34 @@ interface CnosWatchHandle {
|
|
|
189
189
|
}
|
|
190
190
|
declare function watchSchema(options?: WatchSchemaOptions): Promise<CnosWatchHandle>;
|
|
191
191
|
|
|
192
|
+
type SpecComparisonStatus = 'missing_required' | 'undeclared' | 'type_mismatch' | 'enum_mismatch' | 'pattern_mismatch' | 'default_applied' | 'deprecated_in_use';
|
|
193
|
+
interface SpecComparisonIssue {
|
|
194
|
+
key: string;
|
|
195
|
+
status: SpecComparisonStatus;
|
|
196
|
+
expectedType?: string;
|
|
197
|
+
actualType?: string;
|
|
198
|
+
value?: unknown;
|
|
199
|
+
sourceFile?: string;
|
|
200
|
+
summary?: string;
|
|
201
|
+
pattern?: string;
|
|
202
|
+
}
|
|
203
|
+
interface SpecComparisonSummary {
|
|
204
|
+
missingRequired: number;
|
|
205
|
+
undeclared: number;
|
|
206
|
+
typeMismatch: number;
|
|
207
|
+
enumMismatch: number;
|
|
208
|
+
patternMismatch: number;
|
|
209
|
+
defaultApplied: number;
|
|
210
|
+
deprecatedInUse: number;
|
|
211
|
+
}
|
|
212
|
+
interface SpecComparisonReport {
|
|
213
|
+
profile: string;
|
|
214
|
+
workspace: string;
|
|
215
|
+
summary: SpecComparisonSummary;
|
|
216
|
+
issues: SpecComparisonIssue[];
|
|
217
|
+
}
|
|
218
|
+
declare function compareSpecToGraph(runtime: CnosRuntime): SpecComparisonReport;
|
|
219
|
+
|
|
192
220
|
interface DriftIssue {
|
|
193
221
|
key: string;
|
|
194
222
|
expectedType?: string;
|
|
@@ -249,4 +277,4 @@ interface WatchTargetSet {
|
|
|
249
277
|
}
|
|
250
278
|
declare function watchFiles(runtime: CnosRuntime, root?: string): Promise<WatchTargetSet>;
|
|
251
279
|
|
|
252
|
-
export { CNOS_GRAPH_ENV_VAR, CNOS_PROJECTION_ENV_VAR, CNOS_SECRET_PAYLOAD_ENV_VAR, CNOS_SESSION_KEY_ENV_VAR, CnosAuthenticationError, CnosSecurityError, DerivedValue, ParsedDerivation, type RemoteRootCacheMetadata, type ResolvedVaultDefinition, RootResolution, SecretReference, ValidationSummary, VaultDefinition, applyManifestMappings, clearAllVaultSessionKeys, clearVaultSessionKey, compareSchemaToGraph, createRemoteRootCacheKey, createSecretVault, createSecretVaultProvider, deleteLocalSecret, deriveVaultKey, deserializeRuntimeGraph, deserializeServerProjection, detectLegacyVaultFormat, diffGraphs, ensureProjectionAllowed, flattenObject, formatDriftReport, generateCodegenContent, getNamespaceDefinition, getVaultPassphraseEnvVar, getVaultSessionKeyEnvVar, graphRequiresSecretHydration, isDerivedValue, isImmutableGitRef, isPassphraseEnvRef, isSecretReference, listLocalSecrets, listSecretVaults, loadManifest, normalizeDerivedValue, parseDerivation, parseGitUri, parseYaml, proposeMapping, readKeychain, readLocalSecret, readRemoteRootCacheMetadata, readRuntimeGraphFromEnv, readServerProjectionFromEnv, readVaultMetadata, removeLocalVaultFiles, resolveCnosCacheRoot, resolveCodegenPaths, resolveConfigDocumentPath, resolveConfiguredVaultPassphrase, resolveManifestRoot, resolveRemoteRootCachePaths, resolveRootUri, resolveSecretPassphrase, resolveSecretStoreRoot, resolveSecretVaultFile, resolveVaultAccessKey, resolveVaultAuth, resolveVaultDefinition, rewriteSourceFiles, scanEnvUsage, serializeRuntimeGraph, serializeSecretPayload, serializeServerProjection, stringifyYaml, validateDerivedTargetNamespace, validateParsedDerivation, validateRuntime, watchFiles, watchSchema, writeCodegenOutput, writeKeychain, writeLocalSecret, writeRemoteRootCacheMetadata, writeVaultSessionKey };
|
|
280
|
+
export { CNOS_GRAPH_ENV_VAR, CNOS_PROJECTION_ENV_VAR, CNOS_SECRET_PAYLOAD_ENV_VAR, CNOS_SESSION_KEY_ENV_VAR, CnosAuthenticationError, CnosSecurityError, DerivedValue, ParsedDerivation, type RemoteRootCacheMetadata, type ResolvedVaultDefinition, RootResolution, SecretReference, ValidationSummary, VaultDefinition, applyManifestMappings, clearAllVaultSessionKeys, clearVaultSessionKey, compareSchemaToGraph, compareSpecToGraph, createRemoteRootCacheKey, createSecretVault, createSecretVaultProvider, deleteLocalSecret, deriveVaultKey, deserializeRuntimeGraph, deserializeServerProjection, detectLegacyVaultFormat, diffGraphs, ensureProjectionAllowed, flattenObject, formatDriftReport, generateCodegenContent, getNamespaceDefinition, getVaultPassphraseEnvVar, getVaultSessionKeyEnvVar, graphRequiresSecretHydration, isDerivedValue, isImmutableGitRef, isPassphraseEnvRef, isSecretReference, listLocalSecrets, listSecretVaults, loadManifest, normalizeDerivedValue, parseDerivation, parseGitUri, parseYaml, proposeMapping, readKeychain, readLocalSecret, readRemoteRootCacheMetadata, readRuntimeGraphFromEnv, readServerProjectionFromEnv, readVaultMetadata, removeLocalVaultFiles, resolveCnosCacheRoot, resolveCodegenPaths, resolveConfigDocumentPath, resolveConfiguredVaultPassphrase, resolveManifestRoot, resolveRemoteRootCachePaths, resolveRootUri, resolveSecretPassphrase, resolveSecretStoreRoot, resolveSecretVaultFile, resolveVaultAccessKey, resolveVaultAuth, resolveVaultDefinition, rewriteSourceFiles, scanEnvUsage, serializeRuntimeGraph, serializeSecretPayload, serializeServerProjection, stringifyYaml, validateDerivedTargetNamespace, validateParsedDerivation, validateRuntime, watchFiles, watchSchema, writeCodegenOutput, writeKeychain, writeLocalSecret, writeRemoteRootCacheMetadata, writeVaultSessionKey };
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as DerivedValue, P as ParsedDerivation, N as NormalizedManifest, n as LoadManifestOptions, o as LoadedManifest, b as LogicalKey, p as NamespaceDefinition, q as VaultDefinition, r as VaultAuthConfig, s as SecretVaultProvider, t as ResolvedRoot, m as NamespaceName, u as RootResolution, v as SecretReference, g as CnosRuntime, w as ValidationSummary, R as ResolvedGraph, S as ServerProjection } from './core-
|
|
2
|
-
export { l as RuntimeProvider, x as ValidationIssue, y as WorkspaceFile } from './core-
|
|
1
|
+
import { j as DerivedValue, P as ParsedDerivation, N as NormalizedManifest, n as LoadManifestOptions, o as LoadedManifest, b as LogicalKey, p as NamespaceDefinition, q as VaultDefinition, r as VaultAuthConfig, s as SecretVaultProvider, t as ResolvedRoot, m as NamespaceName, u as RootResolution, v as SecretReference, g as CnosRuntime, w as ValidationSummary, R as ResolvedGraph, S as ServerProjection } from './core-Ud1o2MBn.js';
|
|
2
|
+
export { l as RuntimeProvider, x as ValidationIssue, y as WorkspaceFile } from './core-Ud1o2MBn.js';
|
|
3
3
|
|
|
4
4
|
declare class CnosError extends Error {
|
|
5
5
|
constructor(message: string);
|
|
@@ -189,6 +189,34 @@ interface CnosWatchHandle {
|
|
|
189
189
|
}
|
|
190
190
|
declare function watchSchema(options?: WatchSchemaOptions): Promise<CnosWatchHandle>;
|
|
191
191
|
|
|
192
|
+
type SpecComparisonStatus = 'missing_required' | 'undeclared' | 'type_mismatch' | 'enum_mismatch' | 'pattern_mismatch' | 'default_applied' | 'deprecated_in_use';
|
|
193
|
+
interface SpecComparisonIssue {
|
|
194
|
+
key: string;
|
|
195
|
+
status: SpecComparisonStatus;
|
|
196
|
+
expectedType?: string;
|
|
197
|
+
actualType?: string;
|
|
198
|
+
value?: unknown;
|
|
199
|
+
sourceFile?: string;
|
|
200
|
+
summary?: string;
|
|
201
|
+
pattern?: string;
|
|
202
|
+
}
|
|
203
|
+
interface SpecComparisonSummary {
|
|
204
|
+
missingRequired: number;
|
|
205
|
+
undeclared: number;
|
|
206
|
+
typeMismatch: number;
|
|
207
|
+
enumMismatch: number;
|
|
208
|
+
patternMismatch: number;
|
|
209
|
+
defaultApplied: number;
|
|
210
|
+
deprecatedInUse: number;
|
|
211
|
+
}
|
|
212
|
+
interface SpecComparisonReport {
|
|
213
|
+
profile: string;
|
|
214
|
+
workspace: string;
|
|
215
|
+
summary: SpecComparisonSummary;
|
|
216
|
+
issues: SpecComparisonIssue[];
|
|
217
|
+
}
|
|
218
|
+
declare function compareSpecToGraph(runtime: CnosRuntime): SpecComparisonReport;
|
|
219
|
+
|
|
192
220
|
interface DriftIssue {
|
|
193
221
|
key: string;
|
|
194
222
|
expectedType?: string;
|
|
@@ -249,4 +277,4 @@ interface WatchTargetSet {
|
|
|
249
277
|
}
|
|
250
278
|
declare function watchFiles(runtime: CnosRuntime, root?: string): Promise<WatchTargetSet>;
|
|
251
279
|
|
|
252
|
-
export { CNOS_GRAPH_ENV_VAR, CNOS_PROJECTION_ENV_VAR, CNOS_SECRET_PAYLOAD_ENV_VAR, CNOS_SESSION_KEY_ENV_VAR, CnosAuthenticationError, CnosSecurityError, DerivedValue, ParsedDerivation, type RemoteRootCacheMetadata, type ResolvedVaultDefinition, RootResolution, SecretReference, ValidationSummary, VaultDefinition, applyManifestMappings, clearAllVaultSessionKeys, clearVaultSessionKey, compareSchemaToGraph, createRemoteRootCacheKey, createSecretVault, createSecretVaultProvider, deleteLocalSecret, deriveVaultKey, deserializeRuntimeGraph, deserializeServerProjection, detectLegacyVaultFormat, diffGraphs, ensureProjectionAllowed, flattenObject, formatDriftReport, generateCodegenContent, getNamespaceDefinition, getVaultPassphraseEnvVar, getVaultSessionKeyEnvVar, graphRequiresSecretHydration, isDerivedValue, isImmutableGitRef, isPassphraseEnvRef, isSecretReference, listLocalSecrets, listSecretVaults, loadManifest, normalizeDerivedValue, parseDerivation, parseGitUri, parseYaml, proposeMapping, readKeychain, readLocalSecret, readRemoteRootCacheMetadata, readRuntimeGraphFromEnv, readServerProjectionFromEnv, readVaultMetadata, removeLocalVaultFiles, resolveCnosCacheRoot, resolveCodegenPaths, resolveConfigDocumentPath, resolveConfiguredVaultPassphrase, resolveManifestRoot, resolveRemoteRootCachePaths, resolveRootUri, resolveSecretPassphrase, resolveSecretStoreRoot, resolveSecretVaultFile, resolveVaultAccessKey, resolveVaultAuth, resolveVaultDefinition, rewriteSourceFiles, scanEnvUsage, serializeRuntimeGraph, serializeSecretPayload, serializeServerProjection, stringifyYaml, validateDerivedTargetNamespace, validateParsedDerivation, validateRuntime, watchFiles, watchSchema, writeCodegenOutput, writeKeychain, writeLocalSecret, writeRemoteRootCacheMetadata, writeVaultSessionKey };
|
|
280
|
+
export { CNOS_GRAPH_ENV_VAR, CNOS_PROJECTION_ENV_VAR, CNOS_SECRET_PAYLOAD_ENV_VAR, CNOS_SESSION_KEY_ENV_VAR, CnosAuthenticationError, CnosSecurityError, DerivedValue, ParsedDerivation, type RemoteRootCacheMetadata, type ResolvedVaultDefinition, RootResolution, SecretReference, ValidationSummary, VaultDefinition, applyManifestMappings, clearAllVaultSessionKeys, clearVaultSessionKey, compareSchemaToGraph, compareSpecToGraph, createRemoteRootCacheKey, createSecretVault, createSecretVaultProvider, deleteLocalSecret, deriveVaultKey, deserializeRuntimeGraph, deserializeServerProjection, detectLegacyVaultFormat, diffGraphs, ensureProjectionAllowed, flattenObject, formatDriftReport, generateCodegenContent, getNamespaceDefinition, getVaultPassphraseEnvVar, getVaultSessionKeyEnvVar, graphRequiresSecretHydration, isDerivedValue, isImmutableGitRef, isPassphraseEnvRef, isSecretReference, listLocalSecrets, listSecretVaults, loadManifest, normalizeDerivedValue, parseDerivation, parseGitUri, parseYaml, proposeMapping, readKeychain, readLocalSecret, readRemoteRootCacheMetadata, readRuntimeGraphFromEnv, readServerProjectionFromEnv, readVaultMetadata, removeLocalVaultFiles, resolveCnosCacheRoot, resolveCodegenPaths, resolveConfigDocumentPath, resolveConfiguredVaultPassphrase, resolveManifestRoot, resolveRemoteRootCachePaths, resolveRootUri, resolveSecretPassphrase, resolveSecretStoreRoot, resolveSecretVaultFile, resolveVaultAccessKey, resolveVaultAuth, resolveVaultDefinition, rewriteSourceFiles, scanEnvUsage, serializeRuntimeGraph, serializeSecretPayload, serializeServerProjection, stringifyYaml, validateDerivedTargetNamespace, validateParsedDerivation, validateRuntime, watchFiles, watchSchema, writeCodegenOutput, writeKeychain, writeLocalSecret, writeRemoteRootCacheMetadata, writeVaultSessionKey };
|