varlock 0.3.0 → 0.4.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 (60) hide show
  1. package/README.md +23 -10
  2. package/dist/chunk-36LTSUR6.js +48 -0
  3. package/dist/chunk-36LTSUR6.js.map +1 -0
  4. package/dist/{chunk-KKPD7AYU.js → chunk-4DZ3IHF6.js} +4 -4
  5. package/dist/{chunk-KKPD7AYU.js.map → chunk-4DZ3IHF6.js.map} +1 -1
  6. package/dist/{chunk-MXZI2FC6.js → chunk-5HF5TS2C.js} +5 -5
  7. package/dist/{chunk-MXZI2FC6.js.map → chunk-5HF5TS2C.js.map} +1 -1
  8. package/dist/{chunk-JDMZWNQA.js → chunk-ALNELNTO.js} +6 -6
  9. package/dist/{chunk-JDMZWNQA.js.map → chunk-ALNELNTO.js.map} +1 -1
  10. package/dist/{chunk-IG5PPVD7.js → chunk-BS7P3FRR.js} +5 -5
  11. package/dist/{chunk-IG5PPVD7.js.map → chunk-BS7P3FRR.js.map} +1 -1
  12. package/dist/{chunk-WZW7QS6M.js → chunk-CBP4M7BN.js} +314 -27
  13. package/dist/chunk-CBP4M7BN.js.map +1 -0
  14. package/dist/{chunk-LZ52O5WU.js → chunk-EDSWMPIV.js} +7 -18
  15. package/dist/chunk-EDSWMPIV.js.map +1 -0
  16. package/dist/{chunk-26ICEAKS.js → chunk-F5WNDO7I.js} +5 -5
  17. package/dist/{chunk-26ICEAKS.js.map → chunk-F5WNDO7I.js.map} +1 -1
  18. package/dist/{chunk-GEJNYKR4.js → chunk-HRNVJUR5.js} +3 -3
  19. package/dist/{chunk-GEJNYKR4.js.map → chunk-HRNVJUR5.js.map} +1 -1
  20. package/dist/{chunk-WDC5CEKD.js → chunk-QNKJGOQ6.js} +5 -5
  21. package/dist/{chunk-WDC5CEKD.js.map → chunk-QNKJGOQ6.js.map} +1 -1
  22. package/dist/{chunk-VQ5I7WMP.js → chunk-VKRGHRPK.js} +3 -3
  23. package/dist/{chunk-VQ5I7WMP.js.map → chunk-VKRGHRPK.js.map} +1 -1
  24. package/dist/{chunk-MHIFZAPA.js → chunk-WIIXKZ3N.js} +7 -7
  25. package/dist/{chunk-MHIFZAPA.js.map → chunk-WIIXKZ3N.js.map} +1 -1
  26. package/dist/{chunk-TLXFVH7P.js → chunk-YFP6VA2U.js} +4 -4
  27. package/dist/{chunk-TLXFVH7P.js.map → chunk-YFP6VA2U.js.map} +1 -1
  28. package/dist/cli/cli-executable.js +24 -22
  29. package/dist/cli/cli-executable.js.map +1 -1
  30. package/dist/config-item-GN5AUR45.js +5 -0
  31. package/dist/{config-item-2AL7WF23.js.map → config-item-GN5AUR45.js.map} +1 -1
  32. package/dist/{env-graph-C8s2oqOJ.d.ts → env-graph-COORmJlH.d.ts} +59 -0
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.js +4 -4
  35. package/dist/init.command-FMHXUGDI.js +12 -0
  36. package/dist/{init.command-J4HZL3PB.js.map → init.command-FMHXUGDI.js.map} +1 -1
  37. package/dist/load.command-6I2D5BPL.js +11 -0
  38. package/dist/{load.command-6DAP7LEX.js.map → load.command-6I2D5BPL.js.map} +1 -1
  39. package/dist/plugin-lib.d.ts +2 -2
  40. package/dist/printenv.command-TROZTZ26.js +12 -0
  41. package/dist/{printenv.command-7B7SZ2EF.js.map → printenv.command-TROZTZ26.js.map} +1 -1
  42. package/dist/run.command-4OJ6MBP6.js +12 -0
  43. package/dist/{run.command-HVV6XXDR.js.map → run.command-4OJ6MBP6.js.map} +1 -1
  44. package/dist/runtime/env.d.ts +1 -1
  45. package/dist/scan.command-YRNAKUZT.js +13 -0
  46. package/dist/{scan.command-Q33VJOPD.js.map → scan.command-YRNAKUZT.js.map} +1 -1
  47. package/dist/telemetry.command-UZQSUYAY.js +11 -0
  48. package/dist/{telemetry.command-HOJDUCKG.js.map → telemetry.command-UZQSUYAY.js.map} +1 -1
  49. package/dist/typegen.command-V4MATON4.js +12 -0
  50. package/dist/typegen.command-V4MATON4.js.map +1 -0
  51. package/package.json +11 -11
  52. package/dist/chunk-LZ52O5WU.js.map +0 -1
  53. package/dist/chunk-WZW7QS6M.js.map +0 -1
  54. package/dist/config-item-2AL7WF23.js +0 -5
  55. package/dist/init.command-J4HZL3PB.js +0 -12
  56. package/dist/load.command-6DAP7LEX.js +0 -11
  57. package/dist/printenv.command-7B7SZ2EF.js +0 -12
  58. package/dist/run.command-HVV6XXDR.js +0 -12
  59. package/dist/scan.command-Q33VJOPD.js +0 -13
  60. package/dist/telemetry.command-HOJDUCKG.js +0 -11
@@ -6,8 +6,11 @@ import os from 'os';
6
6
  import fs3, { accessSync } from 'fs';
7
7
  import { exec } from 'child_process';
8
8
  import { promisify } from 'util';
9
+ import { createRequire } from 'module';
10
+ import { pathToFileURL } from 'url';
9
11
  import crypto from 'crypto';
10
12
  import https from 'https';
13
+ import vm from 'vm';
11
14
 
12
15
  // ../../node_modules/.bun/semver@7.7.4/node_modules/semver/internal/constants.js
13
16
  var require_constants = __commonJS({
@@ -8353,7 +8356,7 @@ var builtInRootDecorators = [
8353
8356
  dataSource._loadingError = err instanceof SchemaError ? err : new SchemaError(err);
8354
8357
  return;
8355
8358
  }
8356
- const { ConfigItem: ConfigItem3 } = await import('./config-item-2AL7WF23.js');
8359
+ const { ConfigItem: ConfigItem2 } = await import('./config-item-GN5AUR45.js');
8357
8360
  for (const [key, entry] of Object.entries(entries)) {
8358
8361
  const existsInSchema = key in graph.configSchema;
8359
8362
  if (!existsInSchema && !createMissing) {
@@ -8369,7 +8372,7 @@ var builtInRootDecorators = [
8369
8372
  };
8370
8373
  }
8371
8374
  if (!existsInSchema && createMissing) {
8372
- const newItem = new ConfigItem3(graph, key);
8375
+ const newItem = new ConfigItem2(graph, key);
8373
8376
  graph.configSchema[key] = newItem;
8374
8377
  await newItem.process();
8375
8378
  }
@@ -9568,6 +9571,53 @@ __name(convertParsedValueToResolvers, "convertParsedValueToResolvers");
9568
9571
 
9569
9572
  // src/env-graph/lib/plugins.ts
9570
9573
  var importedPluginModulePaths = /* @__PURE__ */ new Set();
9574
+ function isSEABuild() {
9575
+ try {
9576
+ return false;
9577
+ } catch {
9578
+ return false;
9579
+ }
9580
+ }
9581
+ __name(isSEABuild, "isSEABuild");
9582
+ async function loadPluginModuleInSEA(filePath) {
9583
+ const code = fs3.readFileSync(filePath, "utf-8");
9584
+ const fileUrl = pathToFileURL(filePath).href;
9585
+ const pluginDir = path.dirname(filePath);
9586
+ const pluginRequire = createRequire(filePath);
9587
+ let transformed = code.replace(
9588
+ /^import\s+(\w+)\s*,\s*(\{[^}]+\})\s+from\s+['"]([^'"]+)['"]\s*;?/gm,
9589
+ 'const $1 = __plugin_require__("$3"); const $2 = $1;'
9590
+ ).replace(
9591
+ /^import\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm,
9592
+ 'const $1 = __plugin_require__("$2");'
9593
+ ).replace(
9594
+ /^import\s+(\{[^}]+\})\s+from\s+['"]([^'"]+)['"]\s*;?/gm,
9595
+ 'const $1 = __plugin_require__("$2");'
9596
+ ).replace(
9597
+ /^import\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm,
9598
+ 'const $1 = __plugin_require__("$2");'
9599
+ ).replace(
9600
+ /^import\s+['"]([^'"]+)['"]\s*;?/gm,
9601
+ '__plugin_require__("$1");'
9602
+ );
9603
+ transformed = transformed.replace(/import\.meta/g, "__plugin_import_meta__");
9604
+ const wrapped = `(async () => {
9605
+ ${transformed}
9606
+ })()`;
9607
+ const context = vm.createContext(globalThis, {
9608
+ codeGeneration: { strings: true, wasm: true }
9609
+ });
9610
+ context.__plugin_require__ = pluginRequire;
9611
+ context.__plugin_import_meta__ = Object.freeze({
9612
+ url: fileUrl,
9613
+ dirname: pluginDir,
9614
+ filename: filePath
9615
+ });
9616
+ const script = new vm.Script(wrapped, { filename: filePath });
9617
+ const result = script.runInContext(context);
9618
+ await result;
9619
+ }
9620
+ __name(loadPluginModuleInSEA, "loadPluginModuleInSEA");
9571
9621
  var VarlockPlugin = class {
9572
9622
  static {
9573
9623
  __name(this, "VarlockPlugin");
@@ -9654,7 +9704,11 @@ var VarlockPlugin = class {
9654
9704
  try {
9655
9705
  if (!await pathExists(this.pluginFilePath)) throw new Error(`Plugin file not found: ${this.pluginFilePath}`);
9656
9706
  importedPluginModulePaths.add(this.pluginFilePath);
9657
- await import(this.pluginFilePath);
9707
+ if (isSEABuild()) {
9708
+ await loadPluginModuleInSEA(this.pluginFilePath);
9709
+ } else {
9710
+ await import(this.pluginFilePath);
9711
+ }
9658
9712
  } catch (err) {
9659
9713
  this.loadingError = err;
9660
9714
  }
@@ -9970,6 +10024,28 @@ var EnvGraphDataSource2 = class {
9970
10024
  if (importMeta) child.importMeta = importMeta;
9971
10025
  await child.finishInit();
9972
10026
  }
10027
+ /**
10028
+ * Whether this data source is environment-specific.
10029
+ * A source is env-specific if:
10030
+ * - it was auto-loaded for a specific env (e.g., `.env.production` loaded by a DirectoryDataSource)
10031
+ * - it has a conditional `@disable` decorator (e.g., `@disable=forEnv(test)`)
10032
+ * - it was conditionally imported (e.g., `@import(..., enabled=forEnv("dev"))`)
10033
+ * - any of its ancestors are env-specific
10034
+ * Used by type generation to filter out env-dependent definitions.
10035
+ *
10036
+ * Note: `applyForEnv` from filename parsing is only relevant for auto-loaded files.
10037
+ * Explicitly imported files (via `@import`) are controlled by the import mechanism,
10038
+ * not the auto-load-by-env logic, so their `applyForEnv` is ignored here.
10039
+ */
10040
+ get isEnvSpecific() {
10041
+ if (this.applyForEnv && !this.isImport) return true;
10042
+ if (this._hasConditionalDisable) return true;
10043
+ if (this.importMeta?.isConditionallyEnabled) return true;
10044
+ if (this.parent?.isEnvSpecific) return true;
10045
+ return false;
10046
+ }
10047
+ /** true when the source has a `@disable` decorator whose value is not static */
10048
+ _hasConditionalDisable;
9973
10049
  /** environment flag key (as set by @envFlag decorator) - only if set within this source */
9974
10050
  _envFlagKey;
9975
10051
  /** environment flag key getter that will follow up the parent chain */
@@ -10019,6 +10095,9 @@ var EnvGraphDataSource2 = class {
10019
10095
  return;
10020
10096
  }
10021
10097
  this._disabled = disabledVal;
10098
+ if (disabledDec.decValueResolver && !disabledDec.decValueResolver.isStatic) {
10099
+ this._hasConditionalDisable = true;
10100
+ }
10022
10101
  }
10023
10102
  if (this.disabled) return;
10024
10103
  for (const itemKey of this.importKeys || my_dash_default.keys(this.configItemDefs)) {
@@ -10083,8 +10162,8 @@ var EnvGraphDataSource2 = class {
10083
10162
  try {
10084
10163
  await importDec.process();
10085
10164
  if (importDec.decValueResolver?.objArgs?.enabled) {
10086
- const enabledResolver = importDec.decValueResolver.objArgs.enabled;
10087
- const enabledDeps = enabledResolver.deps;
10165
+ const enabledResolver2 = importDec.decValueResolver.objArgs.enabled;
10166
+ const enabledDeps = enabledResolver2.deps;
10088
10167
  for (const depKey of enabledDeps) {
10089
10168
  const depItem = this.graph.configSchema[depKey];
10090
10169
  if (!depItem) {
@@ -10115,6 +10194,8 @@ var EnvGraphDataSource2 = class {
10115
10194
  throw new Error("expected @import enabled parameter to be a boolean");
10116
10195
  }
10117
10196
  if (!enabledValue) continue;
10197
+ const enabledResolver = importDec.decValueResolver?.objArgs?.enabled;
10198
+ const isConditionallyEnabled = !!enabledResolver && !enabledResolver.isStatic;
10118
10199
  const allowMissing = importArgs.obj.allowMissing ?? false;
10119
10200
  if (!my_dash_default.isBoolean(allowMissing)) {
10120
10201
  throw new Error("expected @import allowMissing parameter to be a boolean");
@@ -10131,7 +10212,8 @@ var EnvGraphDataSource2 = class {
10131
10212
  }
10132
10213
  await this.addChild(new DirectoryDataSource(fullImportPath), {
10133
10214
  isImport: true,
10134
- importKeys
10215
+ importKeys,
10216
+ isConditionallyEnabled
10135
10217
  });
10136
10218
  } else {
10137
10219
  const fileExists = this.graph.virtualImports[fullImportPath];
@@ -10143,7 +10225,7 @@ var EnvGraphDataSource2 = class {
10143
10225
  const source = new DotEnvFileDataSource(fullImportPath, {
10144
10226
  overrideContents: this.graph.virtualImports[fullImportPath]
10145
10227
  });
10146
- await this.addChild(source, { isImport: true, importKeys });
10228
+ await this.addChild(source, { isImport: true, importKeys, isConditionallyEnabled });
10147
10229
  }
10148
10230
  } else {
10149
10231
  const fsStat = await tryCatch(async () => fs.stat(fullImportPath), (_err) => {
@@ -10157,7 +10239,8 @@ var EnvGraphDataSource2 = class {
10157
10239
  if (fsStat.isDirectory()) {
10158
10240
  await this.addChild(new DirectoryDataSource(fullImportPath), {
10159
10241
  isImport: true,
10160
- importKeys
10242
+ importKeys,
10243
+ isConditionallyEnabled
10161
10244
  });
10162
10245
  } else {
10163
10246
  this._loadingError = new Error(`Imported path ending with "/" is not a directory: ${fullImportPath}`);
@@ -10171,7 +10254,11 @@ var EnvGraphDataSource2 = class {
10171
10254
  this._loadingError = new Error("imported file must be a .env.* file");
10172
10255
  return;
10173
10256
  }
10174
- await this.addChild(new DotEnvFileDataSource(fullImportPath), { isImport: true, importKeys });
10257
+ await this.addChild(new DotEnvFileDataSource(fullImportPath), {
10258
+ isImport: true,
10259
+ importKeys,
10260
+ isConditionallyEnabled
10261
+ });
10175
10262
  }
10176
10263
  }
10177
10264
  } else if (importPath.startsWith("http://") || importPath.startsWith("https://")) {
@@ -10501,18 +10588,18 @@ async function fetchIconSvg(iconifyName, color = "808080", iconCacheFolder = "/t
10501
10588
  return colorizedSvg;
10502
10589
  }
10503
10590
  __name(fetchIconSvg, "fetchIconSvg");
10504
- async function getTsDefinitionForItem(item, indentLevel = 0) {
10591
+ async function getTsDefinitionForItem(info, indentLevel = 0) {
10505
10592
  const i = my_dash_default.times(indentLevel, () => " ").join("");
10506
10593
  const itemSrc = [];
10507
10594
  const jsDocLines = [];
10508
- jsDocLines.push(`**${item.key}**${item.isSensitive ? " \u{1F510} _sensitive_" : ""}`);
10509
- if (item.description) jsDocLines.push(...item.description.split("\n"));
10510
- const iconName = item.icon;
10595
+ jsDocLines.push(`**${info.key}**${info.isSensitive ? " \u{1F510} _sensitive_" : ""}`);
10596
+ if (info.description) jsDocLines.push(...info.description.split("\n"));
10597
+ const iconName = info.icon;
10511
10598
  if (iconName) {
10512
10599
  const iconSvg = await fetchIconSvg(iconName);
10513
10600
  if (iconSvg) jsDocLines.push(`![icon](data:image/svg+xml;utf-8,${encodeURIComponent(iconSvg)}) `);
10514
10601
  }
10515
- const docsLinks = item.docsLinks;
10602
+ const docsLinks = info.docsLinks;
10516
10603
  if (docsLinks.length) {
10517
10604
  jsDocLines.push("");
10518
10605
  docsLinks.forEach((docsEntry) => {
@@ -10530,7 +10617,7 @@ async function getTsDefinitionForItem(item, indentLevel = 0) {
10530
10617
  " */"
10531
10618
  ]);
10532
10619
  }
10533
- const dataType = item.dataType;
10620
+ const dataType = info.dataType;
10534
10621
  const dataTypeName = dataType?.name;
10535
10622
  let itemTsType = "string";
10536
10623
  if (dataType) {
@@ -10551,24 +10638,25 @@ async function getTsDefinitionForItem(item, indentLevel = 0) {
10551
10638
  }
10552
10639
  }
10553
10640
  }
10554
- const isRequired = item.isRequired && !item.isRequiredDynamic;
10555
- itemSrc.push(`${item.key}${isRequired ? "" : "?"}: ${itemTsType};`);
10641
+ const isRequired = info.isRequired && !info.isRequiredDynamic;
10642
+ itemSrc.push(`${info.key}${isRequired ? "" : "?"}: ${itemTsType};`);
10556
10643
  itemSrc.push("");
10557
10644
  return my_dash_default.map(itemSrc, (line) => `${i}${line}`);
10558
10645
  }
10559
10646
  __name(getTsDefinitionForItem, "getTsDefinitionForItem");
10560
- async function generateTsTypesSrc(graph) {
10647
+ async function generateTsTypesSrc(items) {
10561
10648
  const tsSrc = [
10562
10649
  AUTOGENERATED_FILE_BANNER,
10563
10650
  // might want to add some options to let users inject this, or somehow detect eslint, but fine for now
10564
10651
  "/* eslint-disable */",
10565
10652
  "export type CoercedEnvSchema = {"
10566
10653
  ];
10654
+ const exposedKeys = [];
10567
10655
  const exposedNonSensitiveKeys = [];
10568
- for (const itemKey of graph.sortedConfigKeys) {
10569
- const configItem = graph.configSchema[itemKey];
10570
- tsSrc.push(...await getTsDefinitionForItem(configItem, 1));
10571
- if (!configItem.isSensitive) exposedNonSensitiveKeys.push(itemKey);
10656
+ for (const info of items) {
10657
+ tsSrc.push(...await getTsDefinitionForItem(info, 1));
10658
+ exposedKeys.push(info.key);
10659
+ if (!info.isSensitive) exposedNonSensitiveKeys.push(info.key);
10572
10660
  }
10573
10661
  tsSrc.push("};\n");
10574
10662
  tsSrc.push(`
@@ -10606,7 +10694,13 @@ export type EnvSchemaAsStrings = {
10606
10694
  __name(generateTsTypesSrc, "generateTsTypesSrc");
10607
10695
  async function generateTypes(graph, lang, typesPath) {
10608
10696
  if (lang !== "ts") throw new Error(`Unsupported @generateTypes lang: ${lang}`);
10609
- const tsSrc = await generateTsTypesSrc(graph);
10697
+ const items = [];
10698
+ for (const itemKey of graph.sortedConfigKeys) {
10699
+ const configItem = graph.configSchema[itemKey];
10700
+ if (!configItem.defsForTypeGeneration.length) continue;
10701
+ items.push(await configItem.getTypeGenInfo());
10702
+ }
10703
+ const tsSrc = await generateTsTypesSrc(items);
10610
10704
  await fs3.promises.writeFile(typesPath, tsSrc, "utf-8");
10611
10705
  }
10612
10706
  __name(generateTypes, "generateTypes");
@@ -10614,7 +10708,7 @@ __name(generateTypes, "generateTypes");
10614
10708
  // src/env-graph/lib/env-graph.ts
10615
10709
  var processExists = !!globalThis.process;
10616
10710
  var originalProcessEnv = { ...processExists && process.env };
10617
- var EnvGraph3 = class {
10711
+ var EnvGraph2 = class {
10618
10712
  static {
10619
10713
  __name(this, "EnvGraph");
10620
10714
  }
@@ -10916,6 +11010,33 @@ var EnvGraph3 = class {
10916
11010
  async generateTypes(lang, outputPath) {
10917
11011
  await generateTypes(this, lang, outputPath);
10918
11012
  }
11013
+ /**
11014
+ * Resolve @generateTypes decorators and generate type files.
11015
+ * This should be called after finishLoad() but before resolveEnvValues().
11016
+ * The @generateTypes decorator args (lang, path) are static, so we can resolve them
11017
+ * without needing full env resolution. Type info is computed from non-env-specific
11018
+ * definitions only, so the output is deterministic regardless of environment.
11019
+ *
11020
+ * @param opts.ignoreAutoFalse - if true, generate types even if `auto=false` is set.
11021
+ * Used by the `varlock typegen` command to force generation.
11022
+ */
11023
+ async generateTypesIfNeeded(opts) {
11024
+ const generateTypesDecs = this.getRootDecFns("generateTypes");
11025
+ let generatedCount = 0;
11026
+ for (const generateTypesDec of generateTypesDecs) {
11027
+ const typeGenSettings = await generateTypesDec.resolve();
11028
+ if (generateTypesDec.dataSource.isImport && !typeGenSettings.obj.executeWhenImported) continue;
11029
+ if (typeGenSettings.obj.auto === false && !opts?.ignoreAutoFalse) continue;
11030
+ if (!typeGenSettings.obj.lang) throw new Error("@generateTypes - must set `lang` arg");
11031
+ if (typeGenSettings.obj.lang !== "ts") throw new Error(`@generateTypes - unsupported language: ${typeGenSettings.obj.lang}`);
11032
+ if (!typeGenSettings.obj.path) throw new Error("@generateTypes - must set `path` arg");
11033
+ if (!my_dash_default.isString(typeGenSettings.obj.path)) throw new Error("@generateTypes - `path` arg must be a string");
11034
+ const outputPath = generateTypesDec.dataSource instanceof FileBasedDataSource ? path.resolve(generateTypesDec.dataSource.fullPath, "..", typeGenSettings.obj.path) : typeGenSettings.obj.path;
11035
+ await this.generateTypes(typeGenSettings.obj.lang, outputPath);
11036
+ generatedCount++;
11037
+ }
11038
+ return generatedCount;
11039
+ }
10919
11040
  getRootDec(decoratorName) {
10920
11041
  const sources = Array.from(this.sortedDataSources).reverse();
10921
11042
  for (const s of sources) {
@@ -10968,6 +11089,14 @@ var ConfigItem = class {
10968
11089
  defs.push(...this._internalDefs);
10969
11090
  return defs;
10970
11091
  }
11092
+ /**
11093
+ * Like `defs` but filtered to exclude environment-specific data sources.
11094
+ * Used by type generation so that generated types are deterministic
11095
+ * regardless of which environment is being loaded.
11096
+ */
11097
+ get defsForTypeGeneration() {
11098
+ return this.defs.filter((def) => !def.source || !def.source.isEnvSpecific);
11099
+ }
10971
11100
  get description() {
10972
11101
  for (const def of this.defs) {
10973
11102
  if (def.itemDef.description) return def.itemDef.description;
@@ -11363,9 +11492,167 @@ var ConfigItem = class {
11363
11492
  get isValid() {
11364
11493
  return this.validationState === "valid";
11365
11494
  }
11495
+ /**
11496
+ * Compute schema-level info for type generation using only non-env-specific definitions.
11497
+ * This mirrors the logic of processRequired/processSensitive but:
11498
+ * - Uses defsForTypeGeneration (excludes env-specific sources)
11499
+ * - Returns a result object instead of mutating item state
11500
+ * - Resolves only static decorators from non-env-specific sources
11501
+ */
11502
+ async getTypeGenInfo() {
11503
+ const defs = this.defsForTypeGeneration;
11504
+ let description;
11505
+ for (const def of defs) {
11506
+ if (def.itemDef.description) {
11507
+ description = def.itemDef.description;
11508
+ break;
11509
+ }
11510
+ }
11511
+ let isRequired = true;
11512
+ let isRequiredDynamic = false;
11513
+ try {
11514
+ for (const def of defs) {
11515
+ const requiredDecs = def.itemDef.decorators?.filter((d) => d.name === "required" || d.name === "optional") || [];
11516
+ const requiredDec = requiredDecs[0];
11517
+ if (requiredDec) {
11518
+ const usingOptional = requiredDec.name === "optional";
11519
+ if (requiredDec.decValueResolver?.fnName !== "\0static") {
11520
+ isRequiredDynamic = true;
11521
+ }
11522
+ const requiredDecoratorVal = await requiredDec.resolve();
11523
+ if (requiredDec.schemaErrors.length) {
11524
+ isRequired = false;
11525
+ break;
11526
+ }
11527
+ if (![true, false, void 0].includes(requiredDecoratorVal)) break;
11528
+ if (requiredDecoratorVal !== void 0) {
11529
+ isRequired = usingOptional ? !requiredDecoratorVal : requiredDecoratorVal;
11530
+ break;
11531
+ }
11532
+ }
11533
+ const defaultRequiredDec = def.source?.getRootDec("defaultRequired");
11534
+ if (defaultRequiredDec) {
11535
+ const defaultRequiredVal = await defaultRequiredDec.resolve();
11536
+ if (my_dash_default.isBoolean(defaultRequiredVal)) {
11537
+ isRequired = defaultRequiredVal;
11538
+ break;
11539
+ } else if (defaultRequiredVal === "infer") {
11540
+ if (def.itemDef.resolver) {
11541
+ if (def.itemDef.resolver instanceof StaticValueResolver) {
11542
+ isRequired = def.itemDef.resolver.staticValue !== void 0 && def.itemDef.resolver.staticValue !== "";
11543
+ } else {
11544
+ isRequired = true;
11545
+ }
11546
+ } else {
11547
+ isRequired = false;
11548
+ }
11549
+ break;
11550
+ }
11551
+ }
11552
+ }
11553
+ } catch {
11554
+ }
11555
+ let isSensitive = true;
11556
+ const sensitiveFromDataType = this.dataType?.isSensitive;
11557
+ try {
11558
+ let foundSensitive = false;
11559
+ for (const def of defs) {
11560
+ const sensitiveDecs = def.itemDef.decorators?.filter((d) => d.name === "sensitive" || d.name === "public") || [];
11561
+ const sensitiveDec = sensitiveDecs[0];
11562
+ if (sensitiveDec) {
11563
+ const usingPublic = sensitiveDec.name === "public";
11564
+ const sensitiveDecValue = await sensitiveDec.resolve();
11565
+ if (sensitiveDec.schemaErrors.length) break;
11566
+ if (![true, false, void 0].includes(sensitiveDecValue)) break;
11567
+ if (sensitiveDecValue !== void 0) {
11568
+ isSensitive = usingPublic ? !sensitiveDecValue : sensitiveDecValue;
11569
+ foundSensitive = true;
11570
+ break;
11571
+ }
11572
+ }
11573
+ if (sensitiveFromDataType !== void 0) continue;
11574
+ const defaultSensitiveDec = def.source?.getRootDec("defaultSensitive");
11575
+ if (defaultSensitiveDec) {
11576
+ if (!defaultSensitiveDec.decValueResolver) break;
11577
+ if (defaultSensitiveDec.decValueResolver.fnName === "inferFromPrefix") {
11578
+ const prefix = defaultSensitiveDec.decValueResolver.arrArgs[0].staticValue;
11579
+ if (my_dash_default.isString(prefix)) {
11580
+ isSensitive = !this.key.startsWith(prefix);
11581
+ foundSensitive = true;
11582
+ break;
11583
+ }
11584
+ } else {
11585
+ const defaultSensitiveVal = await defaultSensitiveDec.resolve();
11586
+ if (my_dash_default.isBoolean(defaultSensitiveVal)) {
11587
+ isSensitive = defaultSensitiveVal;
11588
+ foundSensitive = true;
11589
+ break;
11590
+ }
11591
+ }
11592
+ }
11593
+ }
11594
+ if (!foundSensitive && sensitiveFromDataType !== void 0) {
11595
+ isSensitive = sensitiveFromDataType;
11596
+ }
11597
+ } catch {
11598
+ }
11599
+ let icon;
11600
+ for (const def of defs) {
11601
+ const iconDec = def.itemDef.decorators?.find((d) => d.name === "icon");
11602
+ if (iconDec) {
11603
+ try {
11604
+ icon = await iconDec.resolve();
11605
+ } catch {
11606
+ }
11607
+ break;
11608
+ }
11609
+ }
11610
+ icon ??= this.dataType?.icon;
11611
+ const docsLinks = [];
11612
+ if (this.dataType?.docsEntries) {
11613
+ for (const entry of this.dataType.docsEntries) {
11614
+ if (my_dash_default.isPlainObject(entry)) docsLinks.push(entry);
11615
+ else docsLinks.push({ url: entry });
11616
+ }
11617
+ }
11618
+ for (const def of defs) {
11619
+ const docsUrlDec = def.itemDef.decorators?.find((d) => d.name === "docsUrl");
11620
+ if (docsUrlDec) {
11621
+ try {
11622
+ const val = await docsUrlDec.resolve();
11623
+ if (val) docsLinks.push({ url: val });
11624
+ } catch {
11625
+ }
11626
+ }
11627
+ const docsFnDecs = def.itemDef.decorators?.filter((d) => d.name === "docs" && d.isFunctionCall) || [];
11628
+ for (const docsDec of docsFnDecs) {
11629
+ try {
11630
+ const decVal = await docsDec.resolve();
11631
+ if (decVal?.arr && my_dash_default.isArray(decVal.arr)) {
11632
+ if (decVal.arr.length === 1) {
11633
+ docsLinks.push({ url: decVal.arr[0] });
11634
+ } else if (decVal.arr.length === 2) {
11635
+ docsLinks.push({ url: decVal.arr[1], description: decVal.arr[0] });
11636
+ }
11637
+ }
11638
+ } catch {
11639
+ }
11640
+ }
11641
+ }
11642
+ return {
11643
+ key: this.key,
11644
+ description,
11645
+ dataType: this.dataType,
11646
+ isRequired,
11647
+ isRequiredDynamic,
11648
+ isSensitive,
11649
+ icon,
11650
+ docsLinks
11651
+ };
11652
+ }
11366
11653
  };
11367
11654
  //! these are probably not relevant anymore, or needs to move to a plugin layer?
11368
11655
 
11369
- export { CoercionError, ConfigItem, ConfigLoadError, DirectoryDataSource, DotEnvFileDataSource, EnvGraph3 as EnvGraph, FileBasedDataSource, ParsedEnvSpecStaticValue, ResolutionError, SchemaError, ValidationError, VarlockError, envSpecUpdater, my_dash_default, parseEnvSpecDotEnvFile, pathExists, pathExistsSync, tryCatch };
11370
- //# sourceMappingURL=chunk-WZW7QS6M.js.map
11371
- //# sourceMappingURL=chunk-WZW7QS6M.js.map
11656
+ export { CoercionError, ConfigItem, ConfigLoadError, DirectoryDataSource, DotEnvFileDataSource, EnvGraph2 as EnvGraph, ParsedEnvSpecStaticValue, ResolutionError, SchemaError, ValidationError, VarlockError, envSpecUpdater, my_dash_default, parseEnvSpecDotEnvFile, pathExists, pathExistsSync, tryCatch };
11657
+ //# sourceMappingURL=chunk-CBP4M7BN.js.map
11658
+ //# sourceMappingURL=chunk-CBP4M7BN.js.map