@arkenv/core 1.0.0-alpha.5 → 1.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -487,6 +487,38 @@ function getSchemaKeys(schema) {
487
487
  } catch {}
488
488
  return Object.keys(schema);
489
489
  }
490
+ const SCHEMA_CAPTURE_KEY = "__ARKENV_SCHEMA_CAPTURE__";
491
+ /**
492
+ * Read the process-global schema-capture bag so separately loaded copies of
493
+ * `@arkenv/core` / `@arkenv/standard` (for example via Jiti) share one flag.
494
+ *
495
+ * @returns The shared capture state
496
+ */
497
+ function getSchemaCaptureState() {
498
+ const globals = globalThis;
499
+ if (!globals[SCHEMA_CAPTURE_KEY]) globals[SCHEMA_CAPTURE_KEY] = {
500
+ capturing: false,
501
+ definitions: []
502
+ };
503
+ return globals[SCHEMA_CAPTURE_KEY];
504
+ }
505
+ /**
506
+ * Report whether schema capture mode is active.
507
+ *
508
+ * @returns `true` when {@link beginSchemaCapture} is in effect
509
+ */
510
+ function isCapturingSchema() {
511
+ return getSchemaCaptureState().capturing;
512
+ }
513
+ /**
514
+ * Record an `arkenv()` schema definition while capture mode is active.
515
+ *
516
+ * @param def The schema definition passed to `arkenv()`
517
+ */
518
+ function recordSchemaCapture(def) {
519
+ const state = getSchemaCaptureState();
520
+ if (state.capturing) state.definitions.push(def);
521
+ }
490
522
 
491
523
  //#endregion
492
524
  //#region src/arktype/index.ts
@@ -611,6 +643,10 @@ function parse(def, config) {
611
643
  //#endregion
612
644
  //#region src/arkenv.ts
613
645
  function arkenv(def, config = {}) {
646
+ if (isCapturingSchema()) {
647
+ recordSchemaCapture(def);
648
+ return {};
649
+ }
614
650
  if (config.safe) return safeExecute(() => parse(def, config));
615
651
  return parse(def, config);
616
652
  }
package/dist/index.d.cts CHANGED
@@ -6102,15 +6102,12 @@ type SafeArkEnvResult<T> = {
6102
6102
  * @returns An array of extracted key names
6103
6103
  */
6104
6104
  declare function getSchemaKeys(schema: any): string[]; //#endregion
6105
- //#region src/utils/errors.d.ts
6105
+ //#region src/schema-capture.d.ts
6106
6106
  /**
6107
- * Map a Standard Schema validation issue to a normalized EnvIssueCode.
6107
+ * Start recording `arkenv()` schema arguments instead of validating the environment.
6108
6108
  *
6109
- * @param engineCode The raw issue code from the Standard Schema engine
6110
- * @param message The error message associated with the issue
6111
- * @param receivedVal The raw value received by the validator
6112
- * @returns The normalized EnvIssueCode classification
6113
- * @internal
6109
+ * CLI-supporting API: tools such as the ArkEnv CLI use this to inspect a user's
6110
+ * schema module without requiring `process.env` to be populated.
6114
6111
  */
6115
6112
  //#endregion
6116
6113
  //#region ../internal/scope/dist/index.d.ts
@@ -6457,7 +6454,7 @@ type ArkenvOutput<T extends SchemaShape, D> = distill.Out<type$1.infer<T, $$1>>
6457
6454
  *
6458
6455
  * @param def The schema definition
6459
6456
  * @param config The evaluation configuration
6460
- * @returns The parsed environment variables, or a SafeArkEnvResult if `{ safe: true }` is configured
6457
+ * @returns The parsed environment variables, a SafeArkEnvResult if `{ safe: true }` is configured, or a value-less stub when schema capture is active
6461
6458
  * @throws An {@link ArkEnvError | error} if the environment variables are invalid and `safe` is not enabled
6462
6459
  */
6463
6460
  declare function arkenv<const T extends SchemaShape>(def: EnvSchema<T>, config?: ArkEnvConfig & {