varlock 0.0.10 → 0.0.12

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 (59) hide show
  1. package/dist/auto-load.js +5 -5
  2. package/dist/{chunk-PB7RWVE6.js → chunk-23GW4X5J.js} +3 -3
  3. package/dist/{chunk-PB7RWVE6.js.map → chunk-23GW4X5J.js.map} +1 -1
  4. package/dist/{chunk-KCX4NC7Q.js → chunk-2GR4YQFJ.js} +5 -5
  5. package/dist/{chunk-KCX4NC7Q.js.map → chunk-2GR4YQFJ.js.map} +1 -1
  6. package/dist/{chunk-UV5G2V4P.js → chunk-2SPIWTVE.js} +19 -5
  7. package/dist/chunk-2SPIWTVE.js.map +1 -0
  8. package/dist/{chunk-FYLMYWUF.js → chunk-52FLZJCQ.js} +3 -3
  9. package/dist/{chunk-FYLMYWUF.js.map → chunk-52FLZJCQ.js.map} +1 -1
  10. package/dist/{chunk-LS6F7BSZ.js → chunk-AMAUWR7O.js} +4 -4
  11. package/dist/{chunk-LS6F7BSZ.js.map → chunk-AMAUWR7O.js.map} +1 -1
  12. package/dist/{chunk-4CE75BSX.js → chunk-IBMSAOL6.js} +5 -5
  13. package/dist/{chunk-4CE75BSX.js.map → chunk-IBMSAOL6.js.map} +1 -1
  14. package/dist/{chunk-GWQT5VGW.js → chunk-LBVGWRPL.js} +4 -4
  15. package/dist/{chunk-GWQT5VGW.js.map → chunk-LBVGWRPL.js.map} +1 -1
  16. package/dist/{chunk-4WMY2EW3.js → chunk-MHDV65DI.js} +5 -5
  17. package/dist/{chunk-4WMY2EW3.js.map → chunk-MHDV65DI.js.map} +1 -1
  18. package/dist/{chunk-ZW2T4C6A.js → chunk-NXAXPMO5.js} +67 -35
  19. package/dist/chunk-NXAXPMO5.js.map +1 -0
  20. package/dist/{chunk-WA72VLVR.js → chunk-OM3JCP4E.js} +3 -3
  21. package/dist/{chunk-WA72VLVR.js.map → chunk-OM3JCP4E.js.map} +1 -1
  22. package/dist/{chunk-OSLQUOB3.js → chunk-POJECYSY.js} +3 -3
  23. package/dist/{chunk-OSLQUOB3.js.map → chunk-POJECYSY.js.map} +1 -1
  24. package/dist/chunk-TWKAUCTT.js +14 -0
  25. package/dist/{chunk-LSXECA6N.js.map → chunk-TWKAUCTT.js.map} +1 -1
  26. package/dist/{chunk-PEU3DXFM.js → chunk-UPKIHHPE.js} +3 -3
  27. package/dist/{chunk-PEU3DXFM.js.map → chunk-UPKIHHPE.js.map} +1 -1
  28. package/dist/{chunk-ZUG7BEY5.js → chunk-Y2EGAWAH.js} +3 -3
  29. package/dist/{chunk-ZUG7BEY5.js.map → chunk-Y2EGAWAH.js.map} +1 -1
  30. package/dist/cli/cli-executable.js +15 -15
  31. package/dist/cli/cli-executable.js.map +1 -1
  32. package/dist/dotenv-compat.js +5 -5
  33. package/dist/{env-KH4bPru7.d.ts → env-DxiD5Ylz.d.ts} +9 -1
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.js +8 -8
  36. package/dist/init.command-ZSH7NCV7.js +9 -0
  37. package/dist/{init.command-ZRQOE2OK.js.map → init.command-ZSH7NCV7.js.map} +1 -1
  38. package/dist/load.command-U2GASZRB.js +9 -0
  39. package/dist/{load.command-YBN3BW6U.js.map → load.command-U2GASZRB.js.map} +1 -1
  40. package/dist/login.command-2WG4GZV4.js +8 -0
  41. package/dist/{login.command-F5AWKZKA.js.map → login.command-2WG4GZV4.js.map} +1 -1
  42. package/dist/run.command-IETNJ6UU.js +9 -0
  43. package/dist/{run.command-WWJ6ZE26.js.map → run.command-IETNJ6UU.js.map} +1 -1
  44. package/dist/runtime/env.d.ts +1 -1
  45. package/dist/runtime/env.js +1 -1
  46. package/dist/runtime/patch-console.js +2 -2
  47. package/dist/runtime/patch-response.js +2 -2
  48. package/dist/runtime/patch-server-response.js +2 -2
  49. package/dist/telemetry.command-US72HXMS.js +8 -0
  50. package/dist/{telemetry.command-IS2JLIZM.js.map → telemetry.command-US72HXMS.js.map} +1 -1
  51. package/package.json +2 -2
  52. package/dist/chunk-LSXECA6N.js +0 -14
  53. package/dist/chunk-UV5G2V4P.js.map +0 -1
  54. package/dist/chunk-ZW2T4C6A.js.map +0 -1
  55. package/dist/init.command-ZRQOE2OK.js +0 -9
  56. package/dist/load.command-YBN3BW6U.js +0 -9
  57. package/dist/login.command-F5AWKZKA.js +0 -8
  58. package/dist/run.command-WWJ6ZE26.js +0 -9
  59. package/dist/telemetry.command-IS2JLIZM.js +0 -8
@@ -1780,7 +1780,8 @@ async function getTsDefinitionForItem(item, indentLevel = 0) {
1780
1780
  }
1781
1781
  }
1782
1782
  }
1783
- itemSrc.push(`readonly ${item.key}${item.isRequired ? "" : "?"}: ${itemTsType};`);
1783
+ const isRequired = item.isRequired && !item.isRequiredDynamic;
1784
+ itemSrc.push(`readonly ${item.key}${isRequired ? "" : "?"}: ${itemTsType};`);
1784
1785
  itemSrc.push("");
1785
1786
  return my_dash_default.map(itemSrc, (line) => `${i}${line}`);
1786
1787
  }
@@ -1902,8 +1903,8 @@ var EnvGraph2 = class {
1902
1903
  continue;
1903
1904
  }
1904
1905
  if (source.decorators?.envFlag) {
1905
- if (source.applyForEnv) {
1906
- throw new Error(`@envFlag cannot be set from within an env-specific data source - ${source.label}`);
1906
+ if (source.type !== "schema") {
1907
+ throw new Error(`@envFlag must only be used in .env.schema, but was found in ${source.label}`);
1907
1908
  } else if (this.envFlagKey) {
1908
1909
  throw new Error("only a single @envFlag setting is allowed");
1909
1910
  } else {
@@ -2175,40 +2176,74 @@ var ConfigItem3 = class {
2175
2176
  const dataTypeFactory = this.envGraph.dataTypesRegistry[dataTypeName];
2176
2177
  this.dataType = dataTypeFactory(...my_dash_default.isPlainObject(dataTypeArgs) ? [dataTypeArgs] : dataTypeArgs);
2177
2178
  }
2179
+ this.processRequired();
2178
2180
  }
2179
- get isRequired() {
2180
- for (const def of this.defs) {
2181
- const defDecorators = def.itemDef.decorators || {};
2182
- if ("required" in defDecorators) {
2183
- const val = defDecorators.required.simplifiedValue;
2184
- if (typeof val === "boolean") return val;
2185
- if (typeof val === "string") return val === "true";
2186
- return Boolean(val);
2187
- }
2188
- if ("optional" in defDecorators) {
2189
- const val = defDecorators.optional.simplifiedValue;
2190
- if (typeof val === "boolean") return !val;
2191
- if (typeof val === "string") return val !== "true";
2192
- return !val;
2193
- }
2194
- if ("defaultRequired" in def.source.decorators) {
2195
- const val = def.source.decorators.defaultRequired.simplifiedValue;
2196
- if (val === "infer") {
2197
- if (def.source.type === "schema") {
2198
- const resolver = def.itemDef.resolver;
2199
- if (resolver instanceof StaticValueResolver) {
2200
- return resolver.staticValue !== void 0 && resolver.staticValue !== "";
2181
+ _isRequired = true;
2182
+ /**
2183
+ * need to track if required-ness is dynamic, e.g. based on current env
2184
+ * because that will affect type generation (only _always_ required items are never undefined)
2185
+ * */
2186
+ _isRequiredDynamic = false;
2187
+ processRequired() {
2188
+ try {
2189
+ for (const def of this.defs) {
2190
+ const defDecorators = def.itemDef.decorators || {};
2191
+ if ("required" in defDecorators || "optional" in defDecorators) {
2192
+ if ("required" in defDecorators && "optional" in defDecorators) {
2193
+ throw new SchemaError("@required and @optional cannot both be set");
2194
+ }
2195
+ const requiredDecoratorVal = defDecorators.required?.value || defDecorators.optional?.value;
2196
+ const usingOptional = "optional" in defDecorators;
2197
+ if (requiredDecoratorVal instanceof ParsedEnvSpecStaticValue) {
2198
+ const staticVal = requiredDecoratorVal.value;
2199
+ if (my_dash_default.isBoolean(staticVal)) {
2200
+ this._isRequired = usingOptional ? !staticVal : staticVal;
2201
2201
  } else {
2202
- return true;
2202
+ throw new SchemaError("@required/@optional can only be set to true/false if using a static value");
2203
+ }
2204
+ } else if (requiredDecoratorVal instanceof ParsedEnvSpecFunctionCall) {
2205
+ this._isRequiredDynamic = true;
2206
+ const requiredFnName = requiredDecoratorVal.name;
2207
+ const requiredFnArgs = requiredDecoratorVal.simplifiedArgs;
2208
+ if (requiredFnName === "forEnv") {
2209
+ const currentEnv = this.#envGraph.envFlagValue;
2210
+ if (!currentEnv) {
2211
+ throw new SchemaError("Cannot set @required using forEnv() because environment flag is not set");
2212
+ }
2213
+ const envMatches = requiredFnArgs.includes(currentEnv);
2214
+ this._isRequired = usingOptional ? !envMatches : envMatches;
2215
+ }
2216
+ }
2217
+ return;
2218
+ }
2219
+ if ("defaultRequired" in def.source.decorators) {
2220
+ const val = def.source.decorators.defaultRequired.simplifiedValue;
2221
+ if (val === "infer") {
2222
+ if (def.source.type === "schema") {
2223
+ const resolver = def.itemDef.resolver;
2224
+ if (resolver instanceof StaticValueResolver) {
2225
+ this._isRequired = resolver.staticValue !== void 0 && resolver.staticValue !== "";
2226
+ } else {
2227
+ this._isRequired = true;
2228
+ }
2229
+ return;
2230
+ } else {
2231
+ continue;
2203
2232
  }
2204
- } else {
2205
- continue;
2206
2233
  }
2234
+ this._isRequired = val;
2235
+ return;
2207
2236
  }
2208
- return val;
2209
2237
  }
2238
+ } catch (err) {
2239
+ this.schemaErrors.push(err instanceof SchemaError ? err : new SchemaError(err));
2210
2240
  }
2211
- return true;
2241
+ }
2242
+ get isRequired() {
2243
+ return this._isRequired;
2244
+ }
2245
+ get isRequiredDynamic() {
2246
+ return this._isRequiredDynamic;
2212
2247
  }
2213
2248
  get isSensitive() {
2214
2249
  for (const def of this.defs) {
@@ -2462,9 +2497,6 @@ var FileBasedDataSource = class extends EnvGraphDataSource {
2462
2497
  throw Error(`Unsure how to interpret filename - ${this.fileName}`);
2463
2498
  } else if (fileNameParts.length === 2) {
2464
2499
  this.applyForEnv = fileNameParts[1];
2465
- if (this.applyForEnv === "dev") this.applyForEnv = "development";
2466
- if (this.applyForEnv === "stage") this.applyForEnv = "staging";
2467
- if (this.applyForEnv === "prod") this.applyForEnv = "production";
2468
2500
  }
2469
2501
  }
2470
2502
  // no async constructors... :(
@@ -2776,5 +2808,5 @@ __name(gracefulExit, "gracefulExit");
2776
2808
  //! these are probably not relevant anymore, or needs to move to a plugin layer?
2777
2809
 
2778
2810
  export { CoercionError, ConfigLoadError, DotEnvFileDataSource, EnvGraph2 as EnvGraph, EnvSourceParseError, ProcessEnvDataSource, ResolutionError, SchemaError, StaticValueResolver, ValidationError, ansis_default, asyncExitHook, checkIsFileGitIgnored, getItemSummary, gracefulExit, joinAndCompact, loadEnvGraph, my_dash_default };
2779
- //# sourceMappingURL=chunk-ZW2T4C6A.js.map
2780
- //# sourceMappingURL=chunk-ZW2T4C6A.js.map
2811
+ //# sourceMappingURL=chunk-NXAXPMO5.js.map
2812
+ //# sourceMappingURL=chunk-NXAXPMO5.js.map