varlock 0.0.15 → 0.1.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.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/dist/auto-load.js +6 -6
  3. package/dist/{chunk-2SPIWTVE.js → chunk-2JGPOSVQ.js} +2 -2
  4. package/dist/chunk-2JGPOSVQ.js.map +1 -0
  5. package/dist/{chunk-OLZUI45U.js → chunk-2VZORH2Y.js} +4 -4
  6. package/dist/{chunk-OLZUI45U.js.map → chunk-2VZORH2Y.js.map} +1 -1
  7. package/dist/chunk-5NNVZXCM.js +18 -0
  8. package/dist/{chunk-IH74UIYN.js.map → chunk-5NNVZXCM.js.map} +1 -1
  9. package/dist/{chunk-OM3JCP4E.js → chunk-7FI2PPMC.js} +3 -3
  10. package/dist/{chunk-OM3JCP4E.js.map → chunk-7FI2PPMC.js.map} +1 -1
  11. package/dist/{chunk-IWQ4BDSW.js → chunk-7UWLKQXP.js} +1507 -591
  12. package/dist/chunk-7UWLKQXP.js.map +1 -0
  13. package/dist/{chunk-WTAZCEL6.js → chunk-D7YI7IQX.js} +4 -4
  14. package/dist/{chunk-WTAZCEL6.js.map → chunk-D7YI7IQX.js.map} +1 -1
  15. package/dist/{chunk-UPLR6H2O.js → chunk-H3R4W3XK.js} +33 -14
  16. package/dist/chunk-H3R4W3XK.js.map +1 -0
  17. package/dist/{chunk-LYSRVOTA.js → chunk-IBAUYNXV.js} +3 -3
  18. package/dist/{chunk-LYSRVOTA.js.map → chunk-IBAUYNXV.js.map} +1 -1
  19. package/dist/{chunk-LBV2UW3I.js → chunk-QT5E2RY6.js} +3 -3
  20. package/dist/chunk-QT5E2RY6.js.map +1 -0
  21. package/dist/{chunk-XTPPJ3UK.js → chunk-R66KFGSX.js} +15 -22
  22. package/dist/chunk-R66KFGSX.js.map +1 -0
  23. package/dist/{chunk-C5BEZMSO.js → chunk-RWBSXJV6.js} +3 -3
  24. package/dist/{chunk-C5BEZMSO.js.map → chunk-RWBSXJV6.js.map} +1 -1
  25. package/dist/{chunk-WMCJKFEN.js → chunk-VYAOZFZB.js} +4 -4
  26. package/dist/{chunk-WMCJKFEN.js.map → chunk-VYAOZFZB.js.map} +1 -1
  27. package/dist/{chunk-7JMYT62X.js → chunk-WDC67GVB.js} +3 -3
  28. package/dist/{chunk-7JMYT62X.js.map → chunk-WDC67GVB.js.map} +1 -1
  29. package/dist/cli/cli-executable.js +189 -94
  30. package/dist/cli/cli-executable.js.map +1 -1
  31. package/dist/dotenv-compat.js +6 -6
  32. package/dist/{env-DLUhFCnC.d.ts → env-graph-eF0B8G0j.d.ts} +210 -55
  33. package/dist/index.d.ts +5 -2
  34. package/dist/index.js +7 -7
  35. package/dist/index.js.map +1 -1
  36. package/dist/init.command-A52ZWKL2.js +8 -0
  37. package/dist/{init.command-YZ23U7SF.js.map → init.command-A52ZWKL2.js.map} +1 -1
  38. package/dist/lib/exec-sync-varlock.js +1 -1
  39. package/dist/load.command-C75DTSKP.js +8 -0
  40. package/dist/{load.command-NVMWXLOK.js.map → load.command-C75DTSKP.js.map} +1 -1
  41. package/dist/plugin-lib.d.ts +9 -0
  42. package/dist/plugin-lib.js +3 -0
  43. package/dist/plugin-lib.js.map +1 -0
  44. package/dist/run.command-YSQDB4GE.js +8 -0
  45. package/dist/{run.command-CXMAPHO7.js.map → run.command-YSQDB4GE.js.map} +1 -1
  46. package/dist/runtime/env.d.ts +28 -1
  47. package/dist/runtime/env.js +1 -1
  48. package/dist/runtime/patch-console.js +2 -2
  49. package/dist/runtime/patch-response.js +2 -2
  50. package/dist/runtime/patch-server-response.js +2 -2
  51. package/dist/telemetry.command-JIHKG3ZH.js +8 -0
  52. package/dist/{telemetry.command-3DVW7H2K.js.map → telemetry.command-JIHKG3ZH.js.map} +1 -1
  53. package/package.json +18 -10
  54. package/dist/chunk-2SPIWTVE.js.map +0 -1
  55. package/dist/chunk-EPKIAPPA.js +0 -146
  56. package/dist/chunk-EPKIAPPA.js.map +0 -1
  57. package/dist/chunk-IH74UIYN.js +0 -18
  58. package/dist/chunk-IWQ4BDSW.js.map +0 -1
  59. package/dist/chunk-LBV2UW3I.js.map +0 -1
  60. package/dist/chunk-UPLR6H2O.js.map +0 -1
  61. package/dist/chunk-XTPPJ3UK.js.map +0 -1
  62. package/dist/init.command-YZ23U7SF.js +0 -8
  63. package/dist/load.command-NVMWXLOK.js +0 -8
  64. package/dist/login.command-W4DP7RUO.js +0 -8
  65. package/dist/login.command-W4DP7RUO.js.map +0 -1
  66. package/dist/run.command-CXMAPHO7.js +0 -8
  67. package/dist/telemetry.command-3DVW7H2K.js +0 -8
@@ -1,6 +1,17 @@
1
1
  import { ParsedEnvSpecDecorator, ParsedEnvSpecFile, ParsedEnvSpecStaticValue, ParsedEnvSpecFunctionCall } from '@env-spec/parser';
2
2
  import { FallbackIfUnknown } from '@env-spec/utils/type-utils';
3
+ import { Debugger } from 'debug';
3
4
 
5
+ type VarlockErrorLocationDetails = {
6
+ /** file path or url */
7
+ id: string;
8
+ /** 1-based line number */
9
+ lineNumber: number;
10
+ /** 1-based column number */
11
+ colNumber: number;
12
+ /** full line string */
13
+ lineStr: string;
14
+ };
4
15
  declare class VarlockError extends Error {
5
16
  readonly more?: {
6
17
  tip?: string | Array<string>;
@@ -8,6 +19,7 @@ declare class VarlockError extends Error {
8
19
  isWarning?: boolean;
9
20
  /** machine-friendly error code if needed for anything else */
10
21
  code?: string;
22
+ location?: VarlockErrorLocationDetails;
11
23
  /** free-form additional metadata */
12
24
  extraMetadata?: Record<string, any>;
13
25
  } | undefined;
@@ -23,10 +35,12 @@ declare class VarlockError extends Error {
23
35
  isWarning?: boolean;
24
36
  /** machine-friendly error code if needed for anything else */
25
37
  code?: string;
38
+ location?: VarlockErrorLocationDetails;
26
39
  /** free-form additional metadata */
27
40
  extraMetadata?: Record<string, any>;
28
41
  } | undefined);
29
42
  get tip(): string | undefined;
43
+ get location(): VarlockErrorLocationDetails | undefined;
30
44
  get code(): string | undefined;
31
45
  get extraMetadata(): Record<string, any> | undefined;
32
46
  set isWarning(w: boolean);
@@ -71,6 +85,7 @@ declare class ResolutionError extends VarlockError {
71
85
  get retryable(): boolean;
72
86
  }
73
87
 
88
+ type MaybePromise<T> = T | Promise<T>;
74
89
  type EnvGraphDataTypeDef<CoerceReturnType, ValidateInputType = FallbackIfUnknown<CoerceReturnType, string>> = {
75
90
  /** this will be the name of the type, used to reference it when using it in a schema */
76
91
  name: string;
@@ -87,7 +102,14 @@ type EnvGraphDataTypeDef<CoerceReturnType, ValidateInputType = FallbackIfUnknown
87
102
  * - if validation passes, should return true
88
103
  * - if validation fails, should return a ValidationError or array of errors - or throw an error
89
104
  * */
90
- validate: (value: ValidateInputType) => (true | undefined | void | Error | Array<Error>);
105
+ validate: (value: ValidateInputType) => MaybePromise<(true | undefined | void | Error | Array<Error>)>;
106
+ /** will make items of this type sensitive, unless overridden specifically on that item */
107
+ sensitive?: boolean;
108
+ /** adds docs info for these */
109
+ docs?: Array<string | {
110
+ url: string;
111
+ description: string;
112
+ }>;
91
113
  };
92
114
  /**
93
115
  * holds a specific instance of a data type, along with specific settings which affect validation/coercion etc
@@ -101,10 +123,15 @@ declare class EnvGraphDataType {
101
123
  factory: any);
102
124
  get name(): string;
103
125
  get icon(): string | undefined;
126
+ get isSensitive(): boolean | undefined;
127
+ get docsEntries(): (string | {
128
+ url: string;
129
+ description: string;
130
+ })[] | undefined;
104
131
  /** @internal */
105
132
  get _rawDef(): EnvGraphDataTypeDef<any, any>;
106
133
  coerce(val: any): any;
107
- validate(val: any): true | void | Error | Error[];
134
+ validate(val: any): MaybePromise<true | void | Error | Error[] | undefined>;
108
135
  }
109
136
  declare function createEnvGraphDataType<TsType, InstanceSettingsArgs extends Array<any>>(dataTypeDef: EnvGraphDataTypeDef<TsType> | ((...args: InstanceSettingsArgs) => EnvGraphDataTypeDef<TsType>)): {
110
137
  (...usageOpts: InstanceSettingsArgs): EnvGraphDataType;
@@ -113,29 +140,112 @@ declare function createEnvGraphDataType<TsType, InstanceSettingsArgs extends Arr
113
140
  };
114
141
  type EnvGraphDataTypeFactory = ReturnType<typeof createEnvGraphDataType>;
115
142
 
116
- type ResolvedValue = undefined | string | number | boolean | RegExp;
117
- type ResolverFunctionArgs = Array<Resolver | Record<string, Resolver>>;
118
- declare abstract class Resolver {
119
- readonly fnArgs: ResolverFunctionArgs;
120
- static fnName?: string;
121
- constructor(fnArgs: ResolverFunctionArgs);
122
- abstract label: string;
123
- abstract icon: string;
143
+ declare abstract class DecoratorInstance {
144
+ get name(): string;
145
+ get isFunctionCall(): boolean;
146
+ _decValueResolver?: Resolver;
147
+ get decValueResolver(): Resolver | undefined;
148
+ abstract readonly isRootDecorator: boolean;
149
+ abstract readonly dataSource: EnvGraphDataSource;
150
+ abstract readonly parsedDecorator: ParsedEnvSpecDecorator;
151
+ abstract graph: EnvGraph;
152
+ _schemaErrors: Array<SchemaError>;
153
+ get schemaErrors(): SchemaError[];
154
+ _executionError?: Error;
155
+ private decoratorDef?;
156
+ get incompatibleWith(): string[] | undefined;
157
+ private processed;
158
+ private processedData;
159
+ process(): Promise<void>;
160
+ execute(): Promise<void>;
161
+ resolvedValue?: any;
162
+ isResolved: boolean;
163
+ resolve(): Promise<any>;
164
+ }
165
+ declare class ItemDecoratorInstance extends DecoratorInstance {
166
+ readonly configItem: ConfigItem;
167
+ readonly dataSource: EnvGraphDataSource;
168
+ readonly parsedDecorator: ParsedEnvSpecDecorator;
169
+ isRootDecorator: boolean;
170
+ constructor(configItem: ConfigItem, dataSource: EnvGraphDataSource, parsedDecorator: ParsedEnvSpecDecorator);
171
+ get graph(): EnvGraph;
172
+ }
173
+ declare class RootDecoratorInstance extends DecoratorInstance {
174
+ readonly dataSource: EnvGraphDataSource;
175
+ readonly parsedDecorator: ParsedEnvSpecDecorator;
176
+ isRootDecorator: boolean;
177
+ constructor(dataSource: EnvGraphDataSource, parsedDecorator: ParsedEnvSpecDecorator);
178
+ get graph(): EnvGraph;
179
+ }
180
+ type RootDecoratorDef<Processed = any> = {
181
+ name: string;
182
+ description?: string;
183
+ isFunction?: boolean;
184
+ deprecated?: boolean | string;
185
+ incompatibleWith?: Array<string>;
186
+ process?: (decoratorValue: Resolver) => (Processed | Promise<Processed>);
187
+ execute?: (executeInput: Processed) => void | Promise<void>;
188
+ useFnArgsResolver?: boolean;
189
+ };
190
+ type ItemDecoratorDef<T = any> = {
191
+ name: string;
192
+ incompatibleWith?: Array<string>;
193
+ isFunction?: boolean;
194
+ deprecated?: boolean | string;
195
+ process?: (decoratorValue: Resolver) => T | Promise<T>;
196
+ execute?: (executeInput: T) => void | Promise<void>;
197
+ useFnArgsResolver?: boolean;
198
+ };
199
+
200
+ type ResolvedValue = undefined | string | number | boolean | RegExp | {
201
+ [key: string]: ResolvedValue;
202
+ } | Array<ResolvedValue>;
203
+ declare class Resolver {
204
+ readonly arrArgs?: Array<Resolver> | undefined;
205
+ readonly objArgs?: Record<string, Resolver> | undefined;
206
+ readonly dataSource?: EnvGraphDataSource | undefined;
207
+ static def: ResolverDef;
208
+ constructor(arrArgs?: Array<Resolver> | undefined, objArgs?: Record<string, Resolver> | undefined, dataSource?: EnvGraphDataSource | undefined);
209
+ static get fnName(): string;
210
+ get def(): ResolverDef<any>;
211
+ get fnName(): string;
212
+ get label(): string | undefined;
213
+ get icon(): string | undefined;
214
+ get isStatic(): boolean;
215
+ get staticValue(): ResolvedValue;
124
216
  inferredType?: string;
125
217
  _schemaErrors: Array<SchemaError>;
126
218
  private _depsObj;
127
219
  get childResolvers(): Array<Resolver>;
128
220
  get schemaErrors(): Array<SchemaError>;
221
+ set schemaErrors(v: Array<SchemaError>);
129
222
  get depsObj(): Record<string, boolean>;
130
223
  get deps(): string[];
131
- protected abstract _process(ctx?: any): Promise<void | (() => void)>;
132
- private configItem?;
133
- process(configItem: ConfigItem): Promise<void>;
224
+ private parent?;
225
+ private meta;
226
+ process(parent?: ConfigItem | DecoratorInstance): void;
134
227
  protected addDep(key: string): void;
135
- protected abstract _resolve(): Promise<ResolvedValue>;
228
+ protected getCurrentEnv(): Promise<string | undefined>;
136
229
  resolve(): Promise<ResolvedValue>;
230
+ get envGraph(): EnvGraph | undefined;
137
231
  protected getDepValue(key: string): ResolvedValue;
138
232
  }
233
+ type ResolverDef<T = any> = {
234
+ name: string;
235
+ description?: string;
236
+ label?: string;
237
+ icon?: string;
238
+ inferredType?: string;
239
+ argsSchema?: {
240
+ type: 'array' | 'object' | 'mixed';
241
+ arrayExactLength?: number;
242
+ arrayMinLength?: number;
243
+ arrayMaxLength?: number;
244
+ objKeyMinLength?: number;
245
+ };
246
+ process?: (this: Resolver) => T;
247
+ resolve: (this: Resolver, state: T) => ResolvedValue | Promise<ResolvedValue>;
248
+ };
139
249
  type ResolverChildClass<ChildClass extends Resolver = Resolver> = ({
140
250
  new (...args: Array<any>): ChildClass;
141
251
  } & typeof Resolver);
@@ -207,7 +317,9 @@ declare abstract class EnvGraphDataSource {
207
317
  /** environment flag value getter (follows up the parent chain), and checks the graph-level fallback */
208
318
  get envFlagValue(): ResolvedValue;
209
319
  /** helper to resolve the envFlag value */
210
- resolveCurrentEnv(): Promise<ResolvedValue>;
320
+ resolveCurrentEnv(): Promise<string | number | boolean | RegExp | {
321
+ [key: string]: ResolvedValue;
322
+ } | ResolvedValue[] | undefined>;
211
323
  /** finish init process for this data source */
212
324
  finishInit(): Promise<void>;
213
325
  /**
@@ -225,11 +337,17 @@ declare abstract class EnvGraphDataSource {
225
337
  /** an error encountered while loading/parsing the data source */
226
338
  _loadingError?: Error;
227
339
  get loadingError(): Error | undefined;
340
+ _schemaErrors: Array<SchemaError>;
341
+ get schemaErrors(): SchemaError[];
342
+ get resolutionErrors(): Error[];
228
343
  get isValid(): boolean;
229
344
  configItemDefs: Record<string, ConfigItemDef>;
230
345
  decorators: Array<ParsedEnvSpecDecorator>;
231
346
  getRootDecorators(decName: string): ParsedEnvSpecDecorator[];
232
347
  getRootDecoratorSimpleValue(decName: string): any;
348
+ rootDecorators: Array<RootDecoratorInstance>;
349
+ getRootDec(decName: string): RootDecoratorInstance | undefined;
350
+ getRootDecFns(decName: string): RootDecoratorInstance[];
233
351
  }
234
352
  declare abstract class FileBasedDataSource extends EnvGraphDataSource {
235
353
  isGitIgnored?: boolean;
@@ -237,6 +355,7 @@ declare abstract class FileBasedDataSource extends EnvGraphDataSource {
237
355
  fileName: string;
238
356
  rawContents?: string;
239
357
  get typeLabel(): string;
358
+ private relativePath;
240
359
  get label(): string;
241
360
  static format: string;
242
361
  static validFileExtensions: Array<string>;
@@ -252,42 +371,48 @@ declare class DotEnvFileDataSource extends FileBasedDataSource {
252
371
  static format: string;
253
372
  static validFileExtensions: never[];
254
373
  parsedFile?: ParsedEnvSpecFile;
255
- private convertParserValueToResolvers;
256
374
  _parseContents(): Promise<void>;
257
375
  }
258
376
 
259
377
  type ConfigItemDef = {
260
378
  description?: string;
379
+ parsedDecorators?: Array<ParsedEnvSpecDecorator>;
380
+ parsedValue: ParsedEnvSpecStaticValue | ParsedEnvSpecFunctionCall | undefined;
261
381
  resolver?: Resolver;
262
- decorators?: Record<string, ParsedEnvSpecDecorator>;
382
+ decorators?: Array<ItemDecoratorInstance>;
263
383
  };
264
384
  type ConfigItemDefAndSource = {
265
385
  itemDef: ConfigItemDef;
266
386
  source: EnvGraphDataSource;
267
387
  };
268
388
  declare class ConfigItem {
269
- #private;
270
- constructor(_envGraph: EnvGraph, _key: string);
271
- get envGraph(): EnvGraph;
272
- get key(): string;
389
+ readonly envGraph: EnvGraph;
390
+ readonly key: string;
391
+ constructor(envGraph: EnvGraph, key: string);
273
392
  /**
274
393
  * fetch ordered list of definitions for this item, by following up sorted data sources list
275
394
  */
276
395
  get defs(): ConfigItemDefAndSource[];
277
396
  get description(): string | undefined;
278
- get icon(): string | undefined;
397
+ get icon(): any;
279
398
  get docsLinks(): {
280
399
  url: string;
281
400
  description?: string;
282
401
  }[];
283
402
  get valueResolver(): Resolver | undefined;
284
- getDecorator(decoratorName: string): ParsedEnvSpecDecorator | undefined;
285
- getDecoratorValueRaw(decoratorName: string): ParsedEnvSpecStaticValue | ParsedEnvSpecFunctionCall | undefined;
286
- getDecoratorValueString(decoratorName: string): string | undefined;
403
+ allDecorators: Array<ItemDecoratorInstance>;
404
+ effectiveDecorators: Record<string, ItemDecoratorInstance>;
405
+ effectiveDecoratorFns: Record<string, Array<ItemDecoratorInstance>>;
406
+ getDec(decoratorName: string): ItemDecoratorInstance;
407
+ getDecFns(decoratorName: string): ItemDecoratorInstance[];
408
+ resolveDecorators(): Promise<void>;
287
409
  dataType?: EnvGraphDataType;
288
- schemaErrors: Array<SchemaError>;
410
+ _schemaErrors: Array<SchemaError>;
289
411
  get resolverSchemaErrors(): SchemaError[];
412
+ get decoratorSchemaErrors(): SchemaError[];
413
+ private isProcessed;
290
414
  process(): Promise<void>;
415
+ get dependencyKeys(): string[];
291
416
  /**
292
417
  * special early resolution helper
293
418
  * currently used to resolve the envFlag before everything else has been loaded
@@ -302,7 +427,9 @@ declare class ConfigItem {
302
427
  private processRequired;
303
428
  get isRequired(): boolean;
304
429
  get isRequiredDynamic(): boolean;
305
- get isSensitive(): any;
430
+ _isSensitive: boolean;
431
+ get isSensitive(): boolean;
432
+ private processSensitive;
306
433
  get errors(): (SchemaError | ValidationError | CoercionError | ResolutionError)[];
307
434
  get validationState(): 'warn' | 'error' | 'valid';
308
435
  /** resolved value _before coercion_ */
@@ -322,6 +449,52 @@ declare class ConfigItem {
322
449
  type GraphNodeId = string;
323
450
  type GraphAdjacencyList = Record<GraphNodeId, Array<GraphNodeId>>;
324
451
 
452
+ declare class VarlockPlugin {
453
+ readonly ERRORS: {
454
+ ValidationError: typeof ValidationError;
455
+ CoercionError: typeof CoercionError;
456
+ SchemaError: typeof SchemaError;
457
+ ResolutionError: typeof ResolutionError;
458
+ };
459
+ private _packageJson?;
460
+ private _name?;
461
+ get name(): string;
462
+ set name(val: string);
463
+ private _version?;
464
+ get version(): string;
465
+ set version(val: string);
466
+ private _icon?;
467
+ get icon(): string;
468
+ set icon(val: string);
469
+ loadingError?: Error;
470
+ readonly localPath?: string;
471
+ /** reference to the `@plugin()` decorator instance(s) that installed the plugin */
472
+ installDecoratorInstances: Array<DecoratorInstance>;
473
+ type: 'single-file' | 'package';
474
+ constructor(opts: {
475
+ type: 'single-file' | 'package';
476
+ localPath: string;
477
+ loadingError?: Error;
478
+ packageJson?: {
479
+ name: string;
480
+ version?: string;
481
+ description?: string;
482
+ };
483
+ });
484
+ private debugger;
485
+ get debug(): (...args: Parameters<Debugger>) => void;
486
+ readonly dataTypes?: Array<Parameters<typeof createEnvGraphDataType>[0]>;
487
+ registerDataType(dataTypeDef: Parameters<typeof createEnvGraphDataType>[0]): void;
488
+ readonly rootDecorators?: Array<RootDecoratorDef<any>>;
489
+ registerRootDecorator<T>(decoratorDef: RootDecoratorDef<T>): void;
490
+ readonly itemDecorators?: Array<ItemDecoratorDef<any>>;
491
+ registerItemDecorator<T>(decoratorDef: ItemDecoratorDef<T>): void;
492
+ readonly resolverFunctions?: Array<ResolverDef<any>>;
493
+ registerResolverFunction<T>(resolverDef: ResolverDef<T>): void;
494
+ get pluginFilePath(): string;
495
+ executePluginModule(): Promise<void>;
496
+ }
497
+
325
498
  type SerializedEnvGraph = {
326
499
  basePath?: string;
327
500
  sources: Array<{
@@ -358,41 +531,23 @@ declare class EnvGraph {
358
531
  registerResolver(resolverClass: ResolverChildClass): void;
359
532
  dataTypesRegistry: Record<string, EnvGraphDataTypeFactory>;
360
533
  registerDataType(factory: EnvGraphDataTypeFactory): void;
534
+ itemDecoratorsRegistry: Record<string, ItemDecoratorDef>;
535
+ registerItemDecorator(decoratorDef: ItemDecoratorDef): void;
536
+ rootDecoratorsRegistry: Record<string, RootDecoratorDef>;
537
+ registerRootDecorator(decoratorDef: RootDecoratorDef): void;
361
538
  constructor();
362
539
  setRootDataSource(source: EnvGraphDataSource): Promise<void>;
363
540
  finishLoad(): Promise<void>;
364
541
  get graphAdjacencyList(): GraphAdjacencyList;
365
- resolveEnvValues(): Promise<void>;
542
+ resolveEnvValues(keys?: Array<string>): Promise<void>;
366
543
  getResolvedEnvObject(): Record<string, any>;
367
544
  getSerializedGraph(): SerializedEnvGraph;
368
545
  get isInvalid(): boolean;
369
546
  generateTypes(lang: string, outputPath: string): Promise<void>;
370
- getRootDecoratorValue(decoratorName: string): any;
371
- getRootDecorators(decoratorName: string): [EnvGraphDataSource, ParsedEnvSpecDecorator[]][];
372
- }
373
-
374
- declare function resetRedactionMap(graph: SerializedEnvGraph): void;
375
- /**
376
- * Redacts senstive config values from any string/array/object/etc
377
- *
378
- * NOTE - must be used only after varlock has loaded config
379
- * */
380
- declare function redactSensitiveConfig(o: any): any;
381
- /**
382
- * utility to unmask a secret/sensitive value when logging to the console
383
- * currently this only works on a single secret, not objects or aggregated strings
384
- * */
385
- declare function revealSensitiveConfig(secretStr: string): string;
386
- declare function scanForLeaks(toScan: string | ReadableStream | null, meta?: {
387
- method?: string;
388
- file?: string;
389
- }): string | ReadableStream<any> | null;
390
- declare const varlockSettings: Record<string, any>;
391
- declare function initVarlockEnv(opts?: {
392
- allowFail?: boolean;
393
- }): void;
394
- interface TypedEnvSchema {
547
+ getRootDec(decoratorName: string): RootDecoratorInstance | undefined;
548
+ getRootDecFns(decoratorName: string): RootDecoratorInstance[];
549
+ /** plugins installed globally in the graph */
550
+ plugins: Array<VarlockPlugin>;
395
551
  }
396
- declare const ENV: TypedEnvSchema;
397
552
 
398
- export { ConfigLoadError as C, DotEnvFileDataSource as D, EnvGraph as E, ResolutionError as R, SchemaError as S, type TypedEnvSchema as T, ValidationError as V, CoercionError as a, type SerializedEnvGraph as b, ENV as c, redactSensitiveConfig as d, revealSensitiveConfig as e, initVarlockEnv as i, resetRedactionMap as r, scanForLeaks as s, varlockSettings as v };
553
+ export { ConfigLoadError as C, DotEnvFileDataSource as D, EnvGraph as E, Resolver as R, type SerializedEnvGraph as S, VarlockPlugin as V, SchemaError as a, ValidationError as b, CoercionError as c, ResolutionError as d };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,13 @@
1
- import { E as EnvGraph, D as DotEnvFileDataSource, C as ConfigLoadError, S as SchemaError, V as ValidationError, a as CoercionError, R as ResolutionError, i as initVarlockEnv } from './env-DLUhFCnC.js';
2
- export { c as ENV, b as SerializedEnvGraph } from './env-DLUhFCnC.js';
1
+ import { E as EnvGraph, D as DotEnvFileDataSource, C as ConfigLoadError, a as SchemaError, b as ValidationError, c as CoercionError, d as ResolutionError } from './env-graph-eF0B8G0j.js';
2
+ export { S as SerializedEnvGraph } from './env-graph-eF0B8G0j.js';
3
+ import { initVarlockEnv } from './runtime/env.js';
4
+ export { ENV } from './runtime/env.js';
3
5
  export { patchGlobalConsole } from './runtime/patch-console.js';
4
6
  export { patchGlobalServerResponse } from './runtime/patch-server-response.js';
5
7
  export { patchGlobalResponse } from './runtime/patch-response.js';
6
8
  import '@env-spec/parser';
7
9
  import '@env-spec/utils/type-utils';
10
+ import 'debug';
8
11
 
9
12
  declare function loadEnvGraph(opts?: {
10
13
  basePath?: string;
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- export { patchGlobalServerResponse } from './chunk-7JMYT62X.js';
2
- import { loadVarlockEnvGraph, checkForConfigErrors } from './chunk-UPLR6H2O.js';
3
- import { ResolutionError, CoercionError, ValidationError, SchemaError, ConfigLoadError, loadEnvGraph, DotEnvFileDataSource, EnvGraph } from './chunk-IWQ4BDSW.js';
4
- export { patchGlobalConsole } from './chunk-C5BEZMSO.js';
5
- export { patchGlobalResponse } from './chunk-OM3JCP4E.js';
6
- import { initVarlockEnv } from './chunk-2SPIWTVE.js';
7
- export { ENV } from './chunk-2SPIWTVE.js';
1
+ export { patchGlobalResponse } from './chunk-7FI2PPMC.js';
2
+ export { patchGlobalServerResponse } from './chunk-WDC67GVB.js';
3
+ import { loadVarlockEnvGraph, checkForConfigErrors } from './chunk-H3R4W3XK.js';
4
+ import { ResolutionError, CoercionError, ValidationError, SchemaError, ConfigLoadError, loadEnvGraph, DotEnvFileDataSource, EnvGraph } from './chunk-7UWLKQXP.js';
5
+ export { patchGlobalConsole } from './chunk-RWBSXJV6.js';
6
+ import { initVarlockEnv } from './chunk-2JGPOSVQ.js';
7
+ export { ENV } from './chunk-2JGPOSVQ.js';
8
8
  import './chunk-FGMXIEFA.js';
9
9
  import { __name } from './chunk-XN24GZXQ.js';
10
10
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAiBA,eAAsB,IAAA,GAAO;AAE3B,EAAA,MAAM,QAAA,GAAW,MAAM,mBAAA,EAAoB;AAC3C,EAAA,MAAM,SAAS,gBAAA,EAAiB;AAChC,EAAA,oBAAA,CAAqB,QAAQ,CAAA;AAG7B,EAAA,OAAA,CAAQ,IAAI,aAAA,GAAgB,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,oBAAoB,CAAA;AACxE,EAAA,cAAA,EAAe;AAEjB;AAVsB,MAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AAaf,SAAS,yBAAyB,IAAA,EAGtC;AACD,EAAA,IAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,aAAA,SAAsB,EAAC;AACxC,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,OAAA,CAAQ,IAAI,aAAa,CAAA;AACpD,EAAA,MAAM,eAAe,EAAC;AACtB,EAAA,KAAA,MAAW,GAAA,IAAO,QAAQ,MAAA,EAAQ;AAChC,IAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAA;AACnC,IAAA,MAAM,WAAA,GAAc,CAAC,QAAA,CAAS,WAAA,IAAe,IAAA,EAAM,gBAAA;AACnD,IAAA,IAAI,CAAC,WAAA,EAAa;AAClB,IAAA,YAAA,CAAa,CAAA,EAAG,IAAA,EAAM,SAAA,IAAa,KAAK,IAAI,GAAG,CAAA,CAAE,CAAA,GAAI,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,MAAA,CAAO,GAAG,EAAE,KAAK,CAAA;AAAA,EAC/F;AACA,EAAA,OAAO,YAAA;AACT;AAdgB,MAAA,CAAA,wBAAA,EAAA,0BAAA,CAAA;AAiBT,IAAM,QAAA,GAAW;AAAA;AAAA,EAEtB,QAAA;AAAA,EACA,oBAAA;AAAA;AAAA,EAGA,YAAA;AAAA;AAAA,EAGA,eAAA;AAAA,EACA,WAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA;AAAA,EAGA,mBAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["import { checkForConfigErrors } from './cli/helpers/error-checks';\nimport { loadVarlockEnvGraph } from './lib/load-graph';\nimport { initVarlockEnv } from './runtime/env';\n\n// Import env-graph components for internal API\nimport {\n EnvGraph,\n loadEnvGraph,\n DotEnvFileDataSource,\n ConfigLoadError,\n SchemaError,\n ValidationError,\n CoercionError,\n ResolutionError,\n type SerializedEnvGraph,\n} from '../env-graph';\n\nexport async function load() {\n // TODO: add some options\n const envGraph = await loadVarlockEnvGraph();\n await envGraph.resolveEnvValues();\n checkForConfigErrors(envGraph);\n\n // loadFromSerializedGraph(envGraph.getSerializedGraph());\n process.env.__VARLOCK_ENV = JSON.stringify(envGraph.getSerializedGraph());\n initVarlockEnv();\n // TODO: return resolved env and schema / meta info\n}\n\n\nexport function getBuildTimeReplacements(opts?: {\n objectKey?: string,\n includeSensitive?: boolean,\n}) {\n if (!process.env.__VARLOCK_ENV) return {};\n const envInfo = JSON.parse(process.env.__VARLOCK_ENV) as SerializedEnvGraph;\n const replacements = {} as Record<string, string>;\n for (const key in envInfo.config) {\n const itemInfo = envInfo.config[key];\n const replaceItem = !itemInfo.isSensitive || opts?.includeSensitive;\n if (!replaceItem) continue;\n replacements[`${opts?.objectKey || 'ENV'}.${key}`] = JSON.stringify(envInfo.config[key].value);\n }\n return replacements;\n}\n\n// Internal API for direct env graph manipulation\nexport const internal = {\n // Core classes\n EnvGraph,\n DotEnvFileDataSource,\n\n // Loader function\n loadEnvGraph,\n\n // Error classes\n ConfigLoadError,\n SchemaError,\n ValidationError,\n CoercionError,\n ResolutionError,\n\n // Varlock-specific utilities\n loadVarlockEnvGraph,\n checkForConfigErrors,\n initVarlockEnv,\n};\n\nexport { patchGlobalConsole } from './runtime/patch-console';\nexport { patchGlobalServerResponse } from './runtime/patch-server-response';\nexport { patchGlobalResponse } from './runtime/patch-response';\nexport { ENV } from './runtime/env';\nexport type { SerializedEnvGraph };\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAiBA,eAAsB,IAAA,GAAO;AAE3B,EAAA,MAAM,QAAA,GAAW,MAAM,mBAAA,EAAoB;AAC3C,EAAA,MAAM,SAAS,gBAAA,EAAiB;AAChC,EAAA,oBAAA,CAAqB,QAAQ,CAAA;AAG7B,EAAA,OAAA,CAAQ,IAAI,aAAA,GAAgB,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,oBAAoB,CAAA;AACxE,EAAA,cAAA,EAAe;AAEjB;AAVsB,MAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AAaf,SAAS,yBAAyB,IAAA,EAGtC;AACD,EAAA,IAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,aAAA,SAAsB,EAAC;AACxC,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,OAAA,CAAQ,IAAI,aAAa,CAAA;AACpD,EAAA,MAAM,eAAe,EAAC;AACtB,EAAA,KAAA,MAAW,GAAA,IAAO,QAAQ,MAAA,EAAQ;AAChC,IAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAA;AACnC,IAAA,MAAM,WAAA,GAAc,CAAC,QAAA,CAAS,WAAA,IAAe,IAAA,EAAM,gBAAA;AACnD,IAAA,IAAI,CAAC,WAAA,EAAa;AAClB,IAAA,YAAA,CAAa,CAAA,EAAG,IAAA,EAAM,SAAA,IAAa,KAAK,IAAI,GAAG,CAAA,CAAE,CAAA,GAAI,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,MAAA,CAAO,GAAG,EAAE,KAAK,CAAA;AAAA,EAC/F;AACA,EAAA,OAAO,YAAA;AACT;AAdgB,MAAA,CAAA,wBAAA,EAAA,0BAAA,CAAA;AAiBT,IAAM,QAAA,GAAW;AAAA;AAAA,EAEtB,QAAA;AAAA,EACA,oBAAA;AAAA;AAAA,EAGA,YAAA;AAAA;AAAA,EAGA,eAAA;AAAA,EACA,WAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA;AAAA,EAGA,mBAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["import { checkForConfigErrors } from './cli/helpers/error-checks';\nimport { loadVarlockEnvGraph } from './lib/load-graph';\nimport { initVarlockEnv } from './runtime/env';\n\n// Import env-graph components for internal API\nimport {\n EnvGraph,\n loadEnvGraph,\n DotEnvFileDataSource,\n ConfigLoadError,\n SchemaError,\n ValidationError,\n CoercionError,\n ResolutionError,\n type SerializedEnvGraph,\n} from './env-graph';\n\nexport async function load() {\n // TODO: add some options\n const envGraph = await loadVarlockEnvGraph();\n await envGraph.resolveEnvValues();\n checkForConfigErrors(envGraph);\n\n // loadFromSerializedGraph(envGraph.getSerializedGraph());\n process.env.__VARLOCK_ENV = JSON.stringify(envGraph.getSerializedGraph());\n initVarlockEnv();\n // TODO: return resolved env and schema / meta info\n}\n\n\nexport function getBuildTimeReplacements(opts?: {\n objectKey?: string,\n includeSensitive?: boolean,\n}) {\n if (!process.env.__VARLOCK_ENV) return {};\n const envInfo = JSON.parse(process.env.__VARLOCK_ENV) as SerializedEnvGraph;\n const replacements = {} as Record<string, string>;\n for (const key in envInfo.config) {\n const itemInfo = envInfo.config[key];\n const replaceItem = !itemInfo.isSensitive || opts?.includeSensitive;\n if (!replaceItem) continue;\n replacements[`${opts?.objectKey || 'ENV'}.${key}`] = JSON.stringify(envInfo.config[key].value);\n }\n return replacements;\n}\n\n// Internal API for direct env graph manipulation\nexport const internal = {\n // Core classes\n EnvGraph,\n DotEnvFileDataSource,\n\n // Loader function\n loadEnvGraph,\n\n // Error classes\n ConfigLoadError,\n SchemaError,\n ValidationError,\n CoercionError,\n ResolutionError,\n\n // Varlock-specific utilities\n loadVarlockEnvGraph,\n checkForConfigErrors,\n initVarlockEnv,\n};\n\nexport { patchGlobalConsole } from './runtime/patch-console';\nexport { patchGlobalServerResponse } from './runtime/patch-server-response';\nexport { patchGlobalResponse } from './runtime/patch-response';\nexport { ENV } from './runtime/env';\nexport type { SerializedEnvGraph };\n"]}
@@ -0,0 +1,8 @@
1
+ export { commandFn, commandSpec } from './chunk-D7YI7IQX.js';
2
+ import './chunk-IBAUYNXV.js';
3
+ import './chunk-33ROL4J5.js';
4
+ import './chunk-7UWLKQXP.js';
5
+ import './chunk-FGMXIEFA.js';
6
+ import './chunk-XN24GZXQ.js';
7
+ //# sourceMappingURL=init.command-A52ZWKL2.js.map
8
+ //# sourceMappingURL=init.command-A52ZWKL2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"init.command-YZ23U7SF.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"init.command-A52ZWKL2.js"}
@@ -1,4 +1,4 @@
1
- export { execSyncVarlock } from '../chunk-LBV2UW3I.js';
1
+ export { execSyncVarlock } from '../chunk-QT5E2RY6.js';
2
2
  import '../chunk-XN24GZXQ.js';
3
3
  //# sourceMappingURL=exec-sync-varlock.js.map
4
4
  //# sourceMappingURL=exec-sync-varlock.js.map
@@ -0,0 +1,8 @@
1
+ export { commandFn, commandSpec } from './chunk-R66KFGSX.js';
2
+ import './chunk-33ROL4J5.js';
3
+ import './chunk-H3R4W3XK.js';
4
+ import './chunk-7UWLKQXP.js';
5
+ import './chunk-FGMXIEFA.js';
6
+ import './chunk-XN24GZXQ.js';
7
+ //# sourceMappingURL=load.command-C75DTSKP.js.map
8
+ //# sourceMappingURL=load.command-C75DTSKP.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"load.command-NVMWXLOK.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"load.command-C75DTSKP.js"}
@@ -0,0 +1,9 @@
1
+ import { V as VarlockPlugin } from './env-graph-eF0B8G0j.js';
2
+ export { R as Resolver } from './env-graph-eF0B8G0j.js';
3
+ import '@env-spec/parser';
4
+ import '@env-spec/utils/type-utils';
5
+ import 'debug';
6
+
7
+ declare global {
8
+ const plugin: VarlockPlugin;
9
+ }
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=plugin-lib.js.map
3
+ //# sourceMappingURL=plugin-lib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"plugin-lib.js"}
@@ -0,0 +1,8 @@
1
+ export { commandFn, commandSpec } from './chunk-VYAOZFZB.js';
2
+ import './chunk-33ROL4J5.js';
3
+ import './chunk-H3R4W3XK.js';
4
+ import './chunk-7UWLKQXP.js';
5
+ import './chunk-FGMXIEFA.js';
6
+ import './chunk-XN24GZXQ.js';
7
+ //# sourceMappingURL=run.command-YSQDB4GE.js.map
8
+ //# sourceMappingURL=run.command-YSQDB4GE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"run.command-CXMAPHO7.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"run.command-YSQDB4GE.js"}
@@ -1,3 +1,30 @@
1
- export { c as ENV, T as TypedEnvSchema, i as initVarlockEnv, d as redactSensitiveConfig, r as resetRedactionMap, e as revealSensitiveConfig, s as scanForLeaks, v as varlockSettings } from '../env-DLUhFCnC.js';
1
+ import { S as SerializedEnvGraph } from '../env-graph-eF0B8G0j.js';
2
2
  import '@env-spec/parser';
3
3
  import '@env-spec/utils/type-utils';
4
+ import 'debug';
5
+
6
+ declare function resetRedactionMap(graph: SerializedEnvGraph): void;
7
+ /**
8
+ * Redacts senstive config values from any string/array/object/etc
9
+ *
10
+ * NOTE - must be used only after varlock has loaded config
11
+ * */
12
+ declare function redactSensitiveConfig(o: any): any;
13
+ /**
14
+ * utility to unmask a secret/sensitive value when logging to the console
15
+ * currently this only works on a single secret, not objects or aggregated strings
16
+ * */
17
+ declare function revealSensitiveConfig(secretStr: string): string;
18
+ declare function scanForLeaks(toScan: string | ReadableStream | null, meta?: {
19
+ method?: string;
20
+ file?: string;
21
+ }): string | ReadableStream<any> | null;
22
+ declare const varlockSettings: Record<string, any>;
23
+ declare function initVarlockEnv(opts?: {
24
+ allowFail?: boolean;
25
+ }): void;
26
+ interface TypedEnvSchema {
27
+ }
28
+ declare const ENV: TypedEnvSchema;
29
+
30
+ export { ENV, type TypedEnvSchema, initVarlockEnv, redactSensitiveConfig, resetRedactionMap, revealSensitiveConfig, scanForLeaks, varlockSettings };
@@ -1,4 +1,4 @@
1
- export { ENV, initVarlockEnv, redactSensitiveConfig, resetRedactionMap, revealSensitiveConfig, scanForLeaks, varlockSettings } from '../chunk-2SPIWTVE.js';
1
+ export { ENV, initVarlockEnv, redactSensitiveConfig, resetRedactionMap, revealSensitiveConfig, scanForLeaks, varlockSettings } from '../chunk-2JGPOSVQ.js';
2
2
  import '../chunk-FGMXIEFA.js';
3
3
  import '../chunk-XN24GZXQ.js';
4
4
  //# sourceMappingURL=env.js.map
@@ -1,5 +1,5 @@
1
- export { patchGlobalConsole, unpatchGlobalConsole } from '../chunk-C5BEZMSO.js';
2
- import '../chunk-2SPIWTVE.js';
1
+ export { patchGlobalConsole, unpatchGlobalConsole } from '../chunk-RWBSXJV6.js';
2
+ import '../chunk-2JGPOSVQ.js';
3
3
  import '../chunk-FGMXIEFA.js';
4
4
  import '../chunk-XN24GZXQ.js';
5
5
  //# sourceMappingURL=patch-console.js.map
@@ -1,5 +1,5 @@
1
- export { patchGlobalResponse } from '../chunk-OM3JCP4E.js';
2
- import '../chunk-2SPIWTVE.js';
1
+ export { patchGlobalResponse } from '../chunk-7FI2PPMC.js';
2
+ import '../chunk-2JGPOSVQ.js';
3
3
  import '../chunk-FGMXIEFA.js';
4
4
  import '../chunk-XN24GZXQ.js';
5
5
  //# sourceMappingURL=patch-response.js.map
@@ -1,5 +1,5 @@
1
- export { patchGlobalServerResponse } from '../chunk-7JMYT62X.js';
2
- import '../chunk-2SPIWTVE.js';
1
+ export { patchGlobalServerResponse } from '../chunk-WDC67GVB.js';
2
+ import '../chunk-2JGPOSVQ.js';
3
3
  import '../chunk-FGMXIEFA.js';
4
4
  import '../chunk-XN24GZXQ.js';
5
5
  //# sourceMappingURL=patch-server-response.js.map
@@ -0,0 +1,8 @@
1
+ export { commandFn, commandSpec } from './chunk-2VZORH2Y.js';
2
+ import './chunk-IBAUYNXV.js';
3
+ import './chunk-33ROL4J5.js';
4
+ import './chunk-7UWLKQXP.js';
5
+ import './chunk-FGMXIEFA.js';
6
+ import './chunk-XN24GZXQ.js';
7
+ //# sourceMappingURL=telemetry.command-JIHKG3ZH.js.map
8
+ //# sourceMappingURL=telemetry.command-JIHKG3ZH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"telemetry.command-3DVW7H2K.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"telemetry.command-JIHKG3ZH.js"}