@kitsy/cnos 1.9.2 → 1.11.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.
Files changed (61) hide show
  1. package/dist/build/index.cjs +523 -80
  2. package/dist/build/index.d.cts +1 -1
  3. package/dist/build/index.d.ts +1 -1
  4. package/dist/build/index.js +13 -15
  5. package/dist/{chunk-6QQPHDUI.js → chunk-2DMCB3PK.js} +1 -1
  6. package/dist/{chunk-LURQ4LAK.js → chunk-5JGNRADB.js} +1 -1
  7. package/dist/{chunk-2JBA2LXU.js → chunk-DPC2BV3S.js} +35 -6
  8. package/dist/{chunk-7JZO6XN3.js → chunk-KJ57PF47.js} +1 -1
  9. package/dist/{chunk-CPGRRZLP.js → chunk-NFGPS7VJ.js} +8 -8
  10. package/dist/{chunk-A2WG3ZKW.js → chunk-NU25VFA2.js} +1 -1
  11. package/dist/{chunk-L7JVECPE.js → chunk-RNTTPI5S.js} +1 -1
  12. package/dist/{chunk-NVFACB64.js → chunk-T3E57MSQ.js} +1 -1
  13. package/dist/{chunk-7KVM5PUW.js → chunk-WPB4HB2K.js} +478 -61
  14. package/dist/{chunk-QK7BMU47.js → chunk-XGK6DXQL.js} +157 -37
  15. package/dist/configure/index.cjs +521 -76
  16. package/dist/configure/index.d.cts +3 -3
  17. package/dist/configure/index.d.ts +3 -3
  18. package/dist/configure/index.js +8 -8
  19. package/dist/{core-zDTUSVx9.d.cts → core-BW8SLnRx.d.cts} +46 -7
  20. package/dist/{core-zDTUSVx9.d.ts → core-BW8SLnRx.d.ts} +46 -7
  21. package/dist/{envNaming-EFzezmB3.d.cts → envNaming-1rk7BR0e.d.cts} +1 -1
  22. package/dist/{envNaming-BkorOKW_.d.ts → envNaming-CjL28IeH.d.ts} +1 -1
  23. package/dist/index.cjs +672 -108
  24. package/dist/index.d.cts +2 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +10 -10
  27. package/dist/internal.cjs +378 -54
  28. package/dist/internal.d.cts +32 -4
  29. package/dist/internal.d.ts +32 -4
  30. package/dist/internal.js +141 -23
  31. package/dist/plugin/basic-schema.cjs +13 -3
  32. package/dist/plugin/basic-schema.d.cts +1 -1
  33. package/dist/plugin/basic-schema.d.ts +1 -1
  34. package/dist/plugin/basic-schema.js +2 -2
  35. package/dist/plugin/cli-args.cjs +4 -1
  36. package/dist/plugin/cli-args.d.cts +1 -1
  37. package/dist/plugin/cli-args.d.ts +1 -1
  38. package/dist/plugin/cli-args.js +2 -2
  39. package/dist/plugin/dotenv.cjs +40 -8
  40. package/dist/plugin/dotenv.d.cts +2 -2
  41. package/dist/plugin/dotenv.d.ts +2 -2
  42. package/dist/plugin/dotenv.js +2 -2
  43. package/dist/plugin/env-export.cjs +5 -2
  44. package/dist/plugin/env-export.d.cts +2 -2
  45. package/dist/plugin/env-export.d.ts +2 -2
  46. package/dist/plugin/env-export.js +2 -2
  47. package/dist/plugin/filesystem.cjs +13 -10
  48. package/dist/plugin/filesystem.d.cts +1 -1
  49. package/dist/plugin/filesystem.d.ts +1 -1
  50. package/dist/plugin/filesystem.js +2 -2
  51. package/dist/plugin/process-env.cjs +4 -1
  52. package/dist/plugin/process-env.d.cts +2 -2
  53. package/dist/plugin/process-env.d.ts +2 -2
  54. package/dist/plugin/process-env.js +2 -2
  55. package/dist/runtime/index.cjs +672 -108
  56. package/dist/runtime/index.d.cts +13 -6
  57. package/dist/runtime/index.d.ts +13 -6
  58. package/dist/runtime/index.js +10 -10
  59. package/dist/{toPublicEnv-Ds1DRwCX.d.cts → toPublicEnv-CZzpvhGg.d.cts} +1 -1
  60. package/dist/{toPublicEnv-CT265rzS.d.ts → toPublicEnv-CmydGcxg.d.ts} +1 -1
  61. package/package.json +1 -1
@@ -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-zDTUSVx9.cjs';
2
- export { l as RuntimeProvider, x as ValidationIssue, y as WorkspaceFile } from './core-zDTUSVx9.cjs';
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 SecretVaultProviderFactory, t as SecretVaultProvider, u as ResolvedRoot, m as NamespaceName, v as RootResolution, w as SecretReference, g as CnosRuntime, x as ValidationSummary, R as ResolvedGraph, S as ServerProjection } from './core-BW8SLnRx.cjs';
2
+ export { l as RuntimeProvider, y as ValidationIssue, z as WorkspaceFile } from './core-BW8SLnRx.cjs';
3
3
 
4
4
  declare class CnosError extends Error {
5
5
  constructor(message: string);
@@ -36,7 +36,7 @@ declare function writeVaultSessionKey(vault: string, derivedKey: Buffer, process
36
36
  declare function clearVaultSessionKey(vault: string, processEnv?: Record<string, string | undefined>): Promise<void>;
37
37
  declare function clearAllVaultSessionKeys(processEnv?: Record<string, string | undefined>): Promise<void>;
38
38
 
39
- declare function createSecretVaultProvider(vaultId: string, definition: VaultDefinition, processEnv?: Record<string, string | undefined>): SecretVaultProvider;
39
+ declare function createSecretVaultProvider(vaultId: string, definition: VaultDefinition, processEnv?: Record<string, string | undefined>, factories?: SecretVaultProviderFactory[]): SecretVaultProvider;
40
40
 
41
41
  interface ParsedGitUri {
42
42
  uri: 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 };
@@ -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-zDTUSVx9.js';
2
- export { l as RuntimeProvider, x as ValidationIssue, y as WorkspaceFile } from './core-zDTUSVx9.js';
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 SecretVaultProviderFactory, t as SecretVaultProvider, u as ResolvedRoot, m as NamespaceName, v as RootResolution, w as SecretReference, g as CnosRuntime, x as ValidationSummary, R as ResolvedGraph, S as ServerProjection } from './core-BW8SLnRx.js';
2
+ export { l as RuntimeProvider, y as ValidationIssue, z as WorkspaceFile } from './core-BW8SLnRx.js';
3
3
 
4
4
  declare class CnosError extends Error {
5
5
  constructor(message: string);
@@ -36,7 +36,7 @@ declare function writeVaultSessionKey(vault: string, derivedKey: Buffer, process
36
36
  declare function clearVaultSessionKey(vault: string, processEnv?: Record<string, string | undefined>): Promise<void>;
37
37
  declare function clearAllVaultSessionKeys(processEnv?: Record<string, string | undefined>): Promise<void>;
38
38
 
39
- declare function createSecretVaultProvider(vaultId: string, definition: VaultDefinition, processEnv?: Record<string, string | undefined>): SecretVaultProvider;
39
+ declare function createSecretVaultProvider(vaultId: string, definition: VaultDefinition, processEnv?: Record<string, string | undefined>, factories?: SecretVaultProviderFactory[]): SecretVaultProvider;
40
40
 
41
41
  interface ParsedGitUri {
42
42
  uri: 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.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  serializeRuntimeGraph,
12
12
  serializeSecretPayload,
13
13
  serializeServerProjection
14
- } from "./chunk-NVFACB64.js";
14
+ } from "./chunk-T3E57MSQ.js";
15
15
  import {
16
16
  CnosAuthenticationError,
17
17
  CnosSecurityError,
@@ -64,7 +64,7 @@ import {
64
64
  writeLocalSecret,
65
65
  writeRemoteRootCacheMetadata,
66
66
  writeVaultSessionKey
67
- } from "./chunk-7KVM5PUW.js";
67
+ } from "./chunk-WPB4HB2K.js";
68
68
 
69
69
  // src/codegen/generateTypes.ts
70
70
  function toPascalCase(value) {
@@ -269,7 +269,7 @@ async function watchSchema(options = {}) {
269
269
  return watcher;
270
270
  }
271
271
 
272
- // src/drift/compareSchemaToGraph.ts
272
+ // src/spec/compareSpecToGraph.ts
273
273
  function describeValueType(value) {
274
274
  if (Array.isArray(value)) {
275
275
  return "array";
@@ -292,6 +292,17 @@ function matchesType(value, type) {
292
292
  return typeof value === type;
293
293
  }
294
294
  }
295
+ function enumMatches(value, allowed) {
296
+ const serialized = JSON.stringify(value);
297
+ return allowed.some((candidate) => JSON.stringify(candidate) === serialized);
298
+ }
299
+ function matchesPattern(pattern, value) {
300
+ try {
301
+ return new RegExp(pattern).test(value);
302
+ } catch {
303
+ return false;
304
+ }
305
+ }
295
306
  function isSchemaDefault(entry) {
296
307
  return entry.winner.metadata?.schemaDefault === true;
297
308
  }
@@ -301,34 +312,53 @@ function shouldTrackKey(key) {
301
312
  function isTransientRuntimeSource(entry) {
302
313
  return entry.winner.sourceId === "process-env" || entry.winner.sourceId === "cli-args";
303
314
  }
304
- function compareSchemaToGraph(runtime) {
315
+ function buildSummary(issues) {
316
+ return {
317
+ missingRequired: issues.filter((issue) => issue.status === "missing_required").length,
318
+ undeclared: issues.filter((issue) => issue.status === "undeclared").length,
319
+ typeMismatch: issues.filter((issue) => issue.status === "type_mismatch").length,
320
+ enumMismatch: issues.filter((issue) => issue.status === "enum_mismatch").length,
321
+ patternMismatch: issues.filter((issue) => issue.status === "pattern_mismatch").length,
322
+ defaultApplied: issues.filter((issue) => issue.status === "default_applied").length,
323
+ deprecatedInUse: issues.filter((issue) => issue.status === "deprecated_in_use").length
324
+ };
325
+ }
326
+ function compareSpecToGraph(runtime) {
305
327
  const schema = runtime.manifest.schema;
306
- const missing = [];
307
- const mismatches = [];
308
- const defaultsApplied = [];
328
+ const issues = [];
309
329
  for (const [key, rule] of Object.entries(schema).sort(([left], [right]) => left.localeCompare(right))) {
310
330
  const entry = runtime.graph.entries.get(key);
331
+ const summary = rule.summary;
311
332
  if (!entry) {
312
333
  if (rule.required && rule.default === void 0) {
313
- missing.push({
334
+ issues.push({
314
335
  key,
336
+ status: "missing_required",
315
337
  ...rule.type ? {
316
338
  expectedType: rule.type
339
+ } : {},
340
+ ...summary ? {
341
+ summary
317
342
  } : {}
318
343
  });
319
344
  }
320
345
  continue;
321
346
  }
322
347
  if (isSchemaDefault(entry)) {
323
- defaultsApplied.push({
348
+ issues.push({
324
349
  key,
325
- value: entry.value
350
+ status: "default_applied",
351
+ value: entry.value,
352
+ ...summary ? {
353
+ summary
354
+ } : {}
326
355
  });
327
356
  }
328
357
  const actualValue = entry.winner.value;
329
358
  if (!matchesType(actualValue, rule.type)) {
330
- mismatches.push({
359
+ issues.push({
331
360
  key,
361
+ status: "type_mismatch",
332
362
  ...rule.type ? {
333
363
  expectedType: rule.type
334
364
  } : {},
@@ -336,26 +366,113 @@ function compareSchemaToGraph(runtime) {
336
366
  value: actualValue,
337
367
  ...entry.winner.origin?.file ? {
338
368
  sourceFile: entry.winner.origin.file
369
+ } : {},
370
+ ...summary ? {
371
+ summary
372
+ } : {}
373
+ });
374
+ }
375
+ if (rule.enum && !enumMatches(actualValue, rule.enum)) {
376
+ issues.push({
377
+ key,
378
+ status: "enum_mismatch",
379
+ value: actualValue,
380
+ ...summary ? {
381
+ summary
382
+ } : {}
383
+ });
384
+ }
385
+ if (rule.pattern) {
386
+ if (typeof actualValue !== "string" || !matchesPattern(rule.pattern, actualValue)) {
387
+ issues.push({
388
+ key,
389
+ status: "pattern_mismatch",
390
+ value: actualValue,
391
+ pattern: rule.pattern,
392
+ ...summary ? {
393
+ summary
394
+ } : {}
395
+ });
396
+ }
397
+ }
398
+ if (rule.deprecated) {
399
+ issues.push({
400
+ key,
401
+ status: "deprecated_in_use",
402
+ value: actualValue,
403
+ ...summary ? {
404
+ summary
339
405
  } : {}
340
406
  });
341
407
  }
342
408
  }
343
- const undeclared = Array.from(runtime.graph.entries.values()).filter(
409
+ const undeclaredIssues = Array.from(runtime.graph.entries.values()).filter(
344
410
  (entry) => shouldTrackKey(entry.key) && !schema[entry.key] && !isSchemaDefault(entry) && !isTransientRuntimeSource(entry)
345
- ).map((entry) => {
346
- const issue = {
347
- key: entry.key,
348
- value: entry.winner.value,
349
- actualType: describeValueType(entry.winner.value)
350
- };
351
- if (entry.winner.origin?.file) {
352
- issue.sourceFile = entry.winner.origin.file;
353
- }
354
- return issue;
355
- }).sort((left, right) => left.key.localeCompare(right.key));
411
+ ).map((entry) => ({
412
+ key: entry.key,
413
+ status: "undeclared",
414
+ value: entry.winner.value,
415
+ actualType: describeValueType(entry.winner.value),
416
+ ...entry.winner.origin?.file ? {
417
+ sourceFile: entry.winner.origin.file
418
+ } : {}
419
+ })).sort((left, right) => left.key.localeCompare(right.key));
420
+ const allIssues = [...issues, ...undeclaredIssues].sort((left, right) => left.key.localeCompare(right.key));
356
421
  return {
357
422
  profile: runtime.graph.profile,
358
423
  workspace: runtime.graph.workspace.workspaceId,
424
+ summary: buildSummary(allIssues),
425
+ issues: allIssues
426
+ };
427
+ }
428
+
429
+ // src/drift/compareSchemaToGraph.ts
430
+ function compareSchemaToGraph(runtime) {
431
+ const report = compareSpecToGraph(runtime);
432
+ const missing = report.issues.filter((issue) => issue.status === "missing_required").map(
433
+ (issue) => ({
434
+ key: issue.key,
435
+ ...issue.expectedType ? {
436
+ expectedType: issue.expectedType
437
+ } : {}
438
+ })
439
+ );
440
+ const undeclared = report.issues.filter((issue) => issue.status === "undeclared").map(
441
+ (issue) => ({
442
+ key: issue.key,
443
+ value: issue.value,
444
+ ...issue.actualType ? {
445
+ actualType: issue.actualType
446
+ } : {},
447
+ ...issue.sourceFile ? {
448
+ sourceFile: issue.sourceFile
449
+ } : {}
450
+ })
451
+ );
452
+ const mismatches = report.issues.filter((issue) => issue.status === "type_mismatch").map(
453
+ (issue) => ({
454
+ key: issue.key,
455
+ ...issue.expectedType ? {
456
+ expectedType: issue.expectedType
457
+ } : {},
458
+ ...issue.actualType ? {
459
+ actualType: issue.actualType
460
+ } : {},
461
+ value: issue.value,
462
+ ...issue.sourceFile ? {
463
+ sourceFile: issue.sourceFile
464
+ } : {}
465
+ })
466
+ );
467
+ const defaultsApplied = report.issues.filter((issue) => issue.status === "default_applied").map(
468
+ (issue) => ({
469
+ key: issue.key,
470
+ value: issue.value
471
+ })
472
+ );
473
+ return {
474
+ profile: report.profile,
475
+ workspace: report.workspace,
359
476
  missing,
360
477
  undeclared,
361
478
  mismatches,
@@ -666,6 +783,7 @@ export {
666
783
  clearAllVaultSessionKeys,
667
784
  clearVaultSessionKey,
668
785
  compareSchemaToGraph,
786
+ compareSpecToGraph,
669
787
  createRemoteRootCacheKey,
670
788
  createSecretVault,
671
789
  createSecretVaultProvider,
@@ -165,6 +165,13 @@ function enumMatches(value, allowed) {
165
165
  const serialized = JSON.stringify(value);
166
166
  return allowed.some((candidate) => JSON.stringify(candidate) === serialized);
167
167
  }
168
+ function testPattern(pattern, value) {
169
+ try {
170
+ return new RegExp(pattern).test(value);
171
+ } catch {
172
+ return false;
173
+ }
174
+ }
168
175
  function applySchemaRules(graph, schema) {
169
176
  const nextEntries = new Map(graph.entries);
170
177
  const issues = [];
@@ -231,11 +238,11 @@ function applySchemaRules(graph, schema) {
231
238
  key,
232
239
  message: `Config key ${key} must be a string to match pattern ${rule.pattern}`
233
240
  });
234
- } else if (!new RegExp(rule.pattern).test(coercedValue)) {
241
+ } else if (!testPattern(rule.pattern, coercedValue)) {
235
242
  issues.push({
236
243
  code: "schema.pattern",
237
244
  key,
238
- message: `Config key ${key} does not match pattern ${rule.pattern}`
245
+ message: `Config key ${key} does not match pattern ${rule.pattern} (or the pattern is invalid).`
239
246
  });
240
247
  }
241
248
  }
@@ -263,6 +270,9 @@ var import_node_path11 = __toESM(require("path"), 1);
263
270
  var import_promises9 = require("fs/promises");
264
271
  var import_node_path10 = __toESM(require("path"), 1);
265
272
 
273
+ // ../core/src/secrets/resolveAuth.ts
274
+ var import_promises12 = require("fs/promises");
275
+
266
276
  // ../core/src/secrets/prompt.ts
267
277
  var import_node_readline = __toESM(require("readline"), 1);
268
278
  var import_node_stream = require("stream");
@@ -271,7 +281,7 @@ var import_node_stream = require("stream");
271
281
  var import_node_crypto3 = require("crypto");
272
282
 
273
283
  // ../core/src/runtime/dump.ts
274
- var import_promises12 = require("fs/promises");
284
+ var import_promises13 = require("fs/promises");
275
285
  var import_node_path13 = __toESM(require("path"), 1);
276
286
 
277
287
  // ../../plugins/basic-schema/src/index.ts
@@ -1,4 +1,4 @@
1
- import { V as ValidatorPlugin } from '../core-zDTUSVx9.cjs';
1
+ import { V as ValidatorPlugin } from '../core-BW8SLnRx.cjs';
2
2
 
3
3
  declare function createBasicSchemaPlugin(): ValidatorPlugin;
4
4
 
@@ -1,4 +1,4 @@
1
- import { V as ValidatorPlugin } from '../core-zDTUSVx9.js';
1
+ import { V as ValidatorPlugin } from '../core-BW8SLnRx.js';
2
2
 
3
3
  declare function createBasicSchemaPlugin(): ValidatorPlugin;
4
4
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createBasicSchemaPlugin
3
- } from "../chunk-6QQPHDUI.js";
4
- import "../chunk-7KVM5PUW.js";
3
+ } from "../chunk-2DMCB3PK.js";
4
+ import "../chunk-WPB4HB2K.js";
5
5
  export {
6
6
  createBasicSchemaPlugin
7
7
  };
@@ -112,6 +112,9 @@ var import_node_path11 = __toESM(require("path"), 1);
112
112
  var import_promises9 = require("fs/promises");
113
113
  var import_node_path10 = __toESM(require("path"), 1);
114
114
 
115
+ // ../core/src/secrets/resolveAuth.ts
116
+ var import_promises12 = require("fs/promises");
117
+
115
118
  // ../core/src/secrets/prompt.ts
116
119
  var import_node_readline = __toESM(require("readline"), 1);
117
120
  var import_node_stream = require("stream");
@@ -120,7 +123,7 @@ var import_node_stream = require("stream");
120
123
  var import_node_crypto3 = require("crypto");
121
124
 
122
125
  // ../core/src/runtime/dump.ts
123
- var import_promises12 = require("fs/promises");
126
+ var import_promises13 = require("fs/promises");
124
127
  var import_node_path13 = __toESM(require("path"), 1);
125
128
 
126
129
  // ../../plugins/cli-args/src/index.ts
@@ -1,4 +1,4 @@
1
- import { a as ConfigEntry, L as LoaderPlugin } from '../core-zDTUSVx9.cjs';
1
+ import { a as ConfigEntry, L as LoaderPlugin } from '../core-BW8SLnRx.cjs';
2
2
 
3
3
  interface ParsedCliArg {
4
4
  key: string;
@@ -1,4 +1,4 @@
1
- import { a as ConfigEntry, L as LoaderPlugin } from '../core-zDTUSVx9.js';
1
+ import { a as ConfigEntry, L as LoaderPlugin } from '../core-BW8SLnRx.js';
2
2
 
3
3
  interface ParsedCliArg {
4
4
  key: string;
@@ -2,8 +2,8 @@ import {
2
2
  cliArgEntriesFromArgs,
3
3
  createCliArgsPlugin,
4
4
  parseCliArgs
5
- } from "../chunk-7JZO6XN3.js";
6
- import "../chunk-7KVM5PUW.js";
5
+ } from "../chunk-KJ57PF47.js";
6
+ import "../chunk-WPB4HB2K.js";
7
7
  export {
8
8
  cliArgEntriesFromArgs,
9
9
  createCliArgsPlugin,
@@ -37,7 +37,7 @@ __export(dotenv_exports, {
37
37
  module.exports = __toCommonJS(dotenv_exports);
38
38
 
39
39
  // ../../plugins/dotenv/src/index.ts
40
- var import_promises13 = require("fs/promises");
40
+ var import_promises14 = require("fs/promises");
41
41
  var import_node_path14 = __toESM(require("path"), 1);
42
42
 
43
43
  // ../core/src/keychain/linux.ts
@@ -138,6 +138,9 @@ var import_node_path11 = __toESM(require("path"), 1);
138
138
  var import_promises9 = require("fs/promises");
139
139
  var import_node_path10 = __toESM(require("path"), 1);
140
140
 
141
+ // ../core/src/secrets/resolveAuth.ts
142
+ var import_promises12 = require("fs/promises");
143
+
141
144
  // ../core/src/secrets/prompt.ts
142
145
  var import_node_readline = __toESM(require("readline"), 1);
143
146
  var import_node_stream = require("stream");
@@ -146,7 +149,7 @@ var import_node_stream = require("stream");
146
149
  var import_node_crypto3 = require("crypto");
147
150
 
148
151
  // ../core/src/runtime/dump.ts
149
- var import_promises12 = require("fs/promises");
152
+ var import_promises13 = require("fs/promises");
150
153
  var import_node_path13 = __toESM(require("path"), 1);
151
154
 
152
155
  // ../core/src/utils/envNaming.ts
@@ -186,9 +189,30 @@ var DOTENV_PLUGIN_ID = "@kitsy/cnos/plugins/dotenv";
186
189
  function parseDoubleQuoted(value) {
187
190
  return value.replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
188
191
  }
192
+ function isEscapedCharacter(value, index) {
193
+ let slashCount = 0;
194
+ for (let cursor = index - 1; cursor >= 0 && value[cursor] === "\\"; cursor -= 1) {
195
+ slashCount += 1;
196
+ }
197
+ return slashCount % 2 === 1;
198
+ }
199
+ function findClosingQuote(value, quote) {
200
+ for (let index = 0; index < value.length; index += 1) {
201
+ if (value[index] !== quote) {
202
+ continue;
203
+ }
204
+ if (quote === '"' && isEscapedCharacter(value, index)) {
205
+ continue;
206
+ }
207
+ return index;
208
+ }
209
+ return -1;
210
+ }
189
211
  function parseDotenv(document) {
190
212
  const parsed = {};
191
- for (const rawLine of document.split(/\r?\n/)) {
213
+ const lines = document.split(/\r?\n/);
214
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
215
+ const rawLine = lines[lineIndex] ?? "";
192
216
  const line = rawLine.trim();
193
217
  if (!line || line.startsWith("#")) {
194
218
  continue;
@@ -203,10 +227,18 @@ function parseDotenv(document) {
203
227
  if (!envVar) {
204
228
  continue;
205
229
  }
206
- if (value.startsWith('"') && value.endsWith('"')) {
207
- value = parseDoubleQuoted(value.slice(1, -1));
208
- } else if (value.startsWith("'") && value.endsWith("'")) {
209
- value = value.slice(1, -1);
230
+ if (value.startsWith('"') || value.startsWith("'")) {
231
+ const quote = value.startsWith('"') ? '"' : "'";
232
+ let quotedContent = value.slice(1);
233
+ let closingIndex = findClosingQuote(quotedContent, quote);
234
+ while (closingIndex === -1 && lineIndex < lines.length - 1) {
235
+ lineIndex += 1;
236
+ quotedContent = `${quotedContent}
237
+ ${lines[lineIndex] ?? ""}`;
238
+ closingIndex = findClosingQuote(quotedContent, quote);
239
+ }
240
+ const rawQuotedValue = closingIndex === -1 ? quotedContent : quotedContent.slice(0, closingIndex);
241
+ value = quote === '"' ? parseDoubleQuoted(rawQuotedValue) : rawQuotedValue;
210
242
  } else {
211
243
  value = value.replace(/\s+#.*$/, "").trim();
212
244
  }
@@ -238,7 +270,7 @@ function dotenvEntriesFromObject(values, mapping = {}, originFile, workspaceId =
238
270
  }
239
271
  async function readIfPresent(filePath) {
240
272
  try {
241
- return await (0, import_promises13.readFile)(filePath, "utf8");
273
+ return await (0, import_promises14.readFile)(filePath, "utf8");
242
274
  } catch {
243
275
  return void 0;
244
276
  }
@@ -1,5 +1,5 @@
1
- import { L as LoaderPlugin, a as ConfigEntry } from '../core-zDTUSVx9.cjs';
2
- import { E as EnvMappingConfig } from '../envNaming-EFzezmB3.cjs';
1
+ import { L as LoaderPlugin, a as ConfigEntry } from '../core-BW8SLnRx.cjs';
2
+ import { E as EnvMappingConfig } from '../envNaming-1rk7BR0e.cjs';
3
3
 
4
4
  declare function parseDotenv(document: string): Record<string, string>;
5
5
  declare function dotenvEntriesFromObject(values: Record<string, string>, mapping?: EnvMappingConfig, originFile?: string, workspaceId?: string): ConfigEntry[];
@@ -1,5 +1,5 @@
1
- import { L as LoaderPlugin, a as ConfigEntry } from '../core-zDTUSVx9.js';
2
- import { E as EnvMappingConfig } from '../envNaming-BkorOKW_.js';
1
+ import { L as LoaderPlugin, a as ConfigEntry } from '../core-BW8SLnRx.js';
2
+ import { E as EnvMappingConfig } from '../envNaming-CjL28IeH.js';
3
3
 
4
4
  declare function parseDotenv(document: string): Record<string, string>;
5
5
  declare function dotenvEntriesFromObject(values: Record<string, string>, mapping?: EnvMappingConfig, originFile?: string, workspaceId?: string): ConfigEntry[];
@@ -2,8 +2,8 @@ import {
2
2
  createDotenvPlugin,
3
3
  dotenvEntriesFromObject,
4
4
  parseDotenv
5
- } from "../chunk-2JBA2LXU.js";
6
- import "../chunk-7KVM5PUW.js";
5
+ } from "../chunk-DPC2BV3S.js";
6
+ import "../chunk-WPB4HB2K.js";
7
7
  export {
8
8
  createDotenvPlugin,
9
9
  dotenvEntriesFromObject,
@@ -150,9 +150,12 @@ function isObject(value) {
150
150
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
151
151
  }
152
152
  function isSecretReference(value) {
153
- return isObject(value) && typeof value.provider === "string" && value.provider.trim().length > 0 && typeof value.ref === "string" && value.ref.trim().length > 0 && (value.vault === void 0 && true || typeof value.vault === "string" && value.vault.trim().length > 0) && Object.keys(value).every((key) => ["provider", "ref", "vault"].includes(key));
153
+ return isObject(value) && (value.provider === void 0 || typeof value.provider === "string" && value.provider.trim().length > 0) && typeof value.ref === "string" && value.ref.trim().length > 0 && (value.vault === void 0 && true || typeof value.vault === "string" && value.vault.trim().length > 0) && Object.keys(value).every((key) => ["provider", "ref", "vault"].includes(key));
154
154
  }
155
155
 
156
+ // ../core/src/secrets/resolveAuth.ts
157
+ var import_promises12 = require("fs/promises");
158
+
156
159
  // ../core/src/secrets/prompt.ts
157
160
  var import_node_readline = __toESM(require("readline"), 1);
158
161
  var import_node_stream = require("stream");
@@ -263,7 +266,7 @@ function toPublicEnv(graph, manifest, options = {}, helpers = {}) {
263
266
  }
264
267
 
265
268
  // ../core/src/runtime/dump.ts
266
- var import_promises12 = require("fs/promises");
269
+ var import_promises13 = require("fs/promises");
267
270
  var import_node_path13 = __toESM(require("path"), 1);
268
271
 
269
272
  // ../../plugins/env-export/src/index.ts
@@ -1,5 +1,5 @@
1
- import { E as ExporterPlugin } from '../core-zDTUSVx9.cjs';
2
- export { t as toEnv, a as toPublicEnv } from '../toPublicEnv-Ds1DRwCX.cjs';
1
+ import { E as ExporterPlugin } from '../core-BW8SLnRx.cjs';
2
+ export { t as toEnv, a as toPublicEnv } from '../toPublicEnv-CZzpvhGg.cjs';
3
3
 
4
4
  declare function createEnvExportPlugin(): ExporterPlugin;
5
5
  declare function createPublicEnvExportPlugin(): ExporterPlugin;
@@ -1,5 +1,5 @@
1
- import { E as ExporterPlugin } from '../core-zDTUSVx9.js';
2
- export { t as toEnv, a as toPublicEnv } from '../toPublicEnv-CT265rzS.js';
1
+ import { E as ExporterPlugin } from '../core-BW8SLnRx.js';
2
+ export { t as toEnv, a as toPublicEnv } from '../toPublicEnv-CmydGcxg.js';
3
3
 
4
4
  declare function createEnvExportPlugin(): ExporterPlugin;
5
5
  declare function createPublicEnvExportPlugin(): ExporterPlugin;