envapt 7.0.0-next.0 → 7.0.0-next.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 (113) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/browser/index.mjs.map +1 -1
  3. package/dist/{node → types}/engine/NodeEnvapter.d.mts +0 -2
  4. package/dist/{node → types}/index.d.mts +0 -2
  5. package/dist/{node/sources/NodeEnvSource.d.cts → types/sources/NodeEnvSource.d.mts} +2 -2
  6. package/package.json +23 -19
  7. package/dist/node/config.d.mts +0 -2
  8. package/dist/node/converters/Converters.d.cts +0 -93
  9. package/dist/node/converters/Converters.d.mts +0 -95
  10. package/dist/node/converters/ValueConverter.d.cts +0 -25
  11. package/dist/node/converters/ValueConverter.d.mts +0 -27
  12. package/dist/node/core/AdvancedMethods.d.cts +0 -76
  13. package/dist/node/core/AdvancedMethods.d.mts +0 -78
  14. package/dist/node/core/EnvapterBase.d.cts +0 -75
  15. package/dist/node/core/EnvapterBase.d.mts +0 -77
  16. package/dist/node/core/EnvironmentMethods.d.cts +0 -115
  17. package/dist/node/core/EnvironmentMethods.d.mts +0 -117
  18. package/dist/node/core/PrimitiveMethods.d.cts +0 -70
  19. package/dist/node/core/PrimitiveMethods.d.mts +0 -72
  20. package/dist/node/decorators/legacy/Envapt.d.cts +0 -218
  21. package/dist/node/decorators/legacy/Envapt.d.mts +0 -220
  22. package/dist/node/decorators/legacy/SugarDecorators.d.cts +0 -40
  23. package/dist/node/decorators/legacy/SugarDecorators.d.mts +0 -42
  24. package/dist/node/decorators/modern/Envapt.d.cts +0 -218
  25. package/dist/node/decorators/modern/Envapt.d.mts +0 -220
  26. package/dist/node/decorators/modern/SugarDecorators.d.cts +0 -40
  27. package/dist/node/decorators/modern/SugarDecorators.d.mts +0 -42
  28. package/dist/node/engine/Envapter.d.cts +0 -70
  29. package/dist/node/engine/Envapter.d.mts +0 -72
  30. package/dist/node/engine/NodeEnvapter.d.cts +0 -73
  31. package/dist/node/engine/TemplateResolver.d.cts +0 -17
  32. package/dist/node/engine/TemplateResolver.d.mts +0 -19
  33. package/dist/node/index.d.cts +0 -19
  34. package/dist/node/infra/Debug.d.cts +0 -13
  35. package/dist/node/infra/Debug.d.mts +0 -15
  36. package/dist/node/infra/Dotenv.d.cts +0 -17
  37. package/dist/node/infra/Dotenv.d.mts +0 -19
  38. package/dist/node/infra/Error.d.cts +0 -72
  39. package/dist/node/infra/Error.d.mts +0 -74
  40. package/dist/node/infra/StandardSchema.d.cts +0 -59
  41. package/dist/node/infra/StandardSchema.d.mts +0 -61
  42. package/dist/node/legacy.d.cts +0 -4
  43. package/dist/node/legacy.d.mts +0 -6
  44. package/dist/node/sources/ManualEnvSource.d.cts +0 -19
  45. package/dist/node/sources/ManualEnvSource.d.mts +0 -21
  46. package/dist/node/sources/NodeEnvSource.d.mts +0 -22
  47. package/dist/node/sources/WorkerEnvSource.d.cts +0 -19
  48. package/dist/node/sources/WorkerEnvSource.d.mts +0 -21
  49. package/dist/node/types/Conversion.d.cts +0 -123
  50. package/dist/node/types/Conversion.d.mts +0 -125
  51. package/dist/node/types/Decorator.d.cts +0 -26
  52. package/dist/node/types/Decorator.d.mts +0 -28
  53. package/dist/node/types/Env.d.cts +0 -17
  54. package/dist/node/types/Env.d.mts +0 -19
  55. package/dist/node/types/Options.d.cts +0 -39
  56. package/dist/node/types/Options.d.mts +0 -41
  57. package/dist/node/types/Schema.d.cts +0 -12
  58. package/dist/node/types/Schema.d.mts +0 -14
  59. package/dist/node/types/Source.d.cts +0 -44
  60. package/dist/node/types/Source.d.mts +0 -46
  61. package/dist/workerd/converters/Converters.d.mts +0 -93
  62. package/dist/workerd/converters/ValueConverter.d.mts +0 -25
  63. package/dist/workerd/core/AdvancedMethods.d.mts +0 -76
  64. package/dist/workerd/core/EnvapterBase.d.mts +0 -75
  65. package/dist/workerd/core/EnvironmentMethods.d.mts +0 -115
  66. package/dist/workerd/core/PrimitiveMethods.d.mts +0 -70
  67. package/dist/workerd/decorators/legacy/Envapt.d.mts +0 -218
  68. package/dist/workerd/decorators/legacy/SugarDecorators.d.mts +0 -40
  69. package/dist/workerd/decorators/modern/Envapt.d.mts +0 -218
  70. package/dist/workerd/decorators/modern/SugarDecorators.d.mts +0 -40
  71. package/dist/workerd/engine/Envapter.d.mts +0 -70
  72. package/dist/workerd/engine/TemplateResolver.d.mts +0 -17
  73. package/dist/workerd/index.d.mts +0 -18
  74. package/dist/workerd/infra/Debug.d.mts +0 -13
  75. package/dist/workerd/infra/Dotenv.d.mts +0 -17
  76. package/dist/workerd/infra/Error.d.mts +0 -72
  77. package/dist/workerd/infra/StandardSchema.d.mts +0 -59
  78. package/dist/workerd/legacy.d.mts +0 -4
  79. package/dist/workerd/sources/ManualEnvSource.d.mts +0 -19
  80. package/dist/workerd/sources/WorkerEnvSource.d.mts +0 -19
  81. package/dist/workerd/types/Conversion.d.mts +0 -123
  82. package/dist/workerd/types/Decorator.d.mts +0 -26
  83. package/dist/workerd/types/Env.d.mts +0 -17
  84. package/dist/workerd/types/Options.d.mts +0 -39
  85. package/dist/workerd/types/Schema.d.mts +0 -12
  86. package/dist/workerd/types/Source.d.mts +0 -44
  87. /package/dist/{node/config.d.cts → types/config.d.mts} +0 -0
  88. /package/dist/{browser → types}/converters/Converters.d.mts +0 -0
  89. /package/dist/{browser → types}/converters/ValueConverter.d.mts +0 -0
  90. /package/dist/{browser → types}/core/AdvancedMethods.d.mts +0 -0
  91. /package/dist/{browser → types}/core/EnvapterBase.d.mts +0 -0
  92. /package/dist/{browser → types}/core/EnvironmentMethods.d.mts +0 -0
  93. /package/dist/{browser → types}/core/PrimitiveMethods.d.mts +0 -0
  94. /package/dist/{browser → types}/decorators/legacy/Envapt.d.mts +0 -0
  95. /package/dist/{browser → types}/decorators/legacy/SugarDecorators.d.mts +0 -0
  96. /package/dist/{browser → types}/decorators/modern/Envapt.d.mts +0 -0
  97. /package/dist/{browser → types}/decorators/modern/SugarDecorators.d.mts +0 -0
  98. /package/dist/{browser → types}/engine/Envapter.d.mts +0 -0
  99. /package/dist/{browser → types}/engine/TemplateResolver.d.mts +0 -0
  100. /package/dist/{browser/index.d.mts → types/index.portable.d.mts} +0 -0
  101. /package/dist/{browser → types}/infra/Debug.d.mts +0 -0
  102. /package/dist/{browser → types}/infra/Dotenv.d.mts +0 -0
  103. /package/dist/{browser → types}/infra/Error.d.mts +0 -0
  104. /package/dist/{browser → types}/infra/StandardSchema.d.mts +0 -0
  105. /package/dist/{browser → types}/legacy.d.mts +0 -0
  106. /package/dist/{browser → types}/sources/ManualEnvSource.d.mts +0 -0
  107. /package/dist/{browser → types}/sources/WorkerEnvSource.d.mts +0 -0
  108. /package/dist/{browser → types}/types/Conversion.d.mts +0 -0
  109. /package/dist/{browser → types}/types/Decorator.d.mts +0 -0
  110. /package/dist/{browser → types}/types/Env.d.mts +0 -0
  111. /package/dist/{browser → types}/types/Options.d.mts +0 -0
  112. /package/dist/{browser → types}/types/Schema.d.mts +0 -0
  113. /package/dist/{browser → types}/types/Source.d.mts +0 -0
@@ -1,72 +0,0 @@
1
- import { StandardSchemaV1 } from "./StandardSchema.cjs";
2
-
3
- //#region src/infra/Error.d.ts
4
- declare enum EnvaptErrorCodes {
5
- /** Thrown when an invalid fallback value is provided */
6
- InvalidFallback = 101,
7
- /** Thrown when fallback value type doesn't match expected converter type */
8
- InvalidFallbackType = 102,
9
- /** Thrown when array fallback contains elements of wrong type */
10
- ArrayFallbackElementTypeMismatch = 103,
11
- /** Thrown when fallback type doesn't match the specified converter */
12
- FallbackConverterTypeMismatch = 104,
13
- /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */
14
- MalformedTimeFallback = 105,
15
- /** Thrown when invalid array converter configuration is provided */
16
- InvalidArrayConverterType = 201,
17
- /** Thrown when an invalid built-in converter is specified */
18
- InvalidBuiltInConverter = 202,
19
- /** Thrown when a custom converter is not a function */
20
- InvalidCustomConverter = 203,
21
- /** Thrown when converter type is not recognized */
22
- InvalidConverterType = 204,
23
- /** Thrown when primitive type coercion on fallback value fails */
24
- PrimitiveCoercionFailed = 205,
25
- /** Thrown when an array element fails to convert to the configured element type */
26
- ArrayElementConversionFailed = 206,
27
- /** Thrown under strict mode when an array element is empty or whitespace only */
28
- EmptyArrayElement = 207,
29
- /** Thrown when a Standard Schema returns issues for a non-empty env value */
30
- SchemaValidationFailed = 208,
31
- /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */
32
- SchemaThrew = 209,
33
- /** Thrown when delimiter is missing in array converter configuration */
34
- MissingDelimiter = 301,
35
- /** Thrown when invalid user-defined configuration is provided */
36
- InvalidUserDefinedConfig = 302,
37
- /** Thrown when specified environment files don't exist */
38
- EnvFilesNotFound = 303,
39
- /** Thrown when no valid environment key is provided */
40
- InvalidKeyInput = 304,
41
- /** Thrown when a required environment value is missing or empty (post-trim) */
42
- MissingEnvValue = 305,
43
- /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */
44
- FileApiUnsupported = 306,
45
- /** Thrown when an environment value is read before a source is bound via Envapter.useSource */
46
- NoSourceBound = 307
47
- }
48
- interface EnvaptErrorOptions {
49
- issues?: readonly StandardSchemaV1.Issue[];
50
- cause?: unknown;
51
- }
52
- /**
53
- * Custom error for better DX and debugging when using Envapt.
54
- *
55
- * @example
56
- * ```ts
57
- * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, "Invalid fallback value provided for environment variable.");
58
- * ```
59
- */
60
- declare class EnvaptError extends Error {
61
- readonly code: EnvaptErrorCodes;
62
- /**
63
- * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other
64
- * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`
65
- * without a type cast.
66
- */
67
- readonly issues: readonly StandardSchemaV1.Issue[] | undefined;
68
- constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions);
69
- }
70
- //#endregion
71
- export { EnvaptError, EnvaptErrorCodes };
72
- //# sourceMappingURL=Error.d.cts.map
@@ -1,74 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { StandardSchemaV1 } from "./StandardSchema.mjs";
4
-
5
- //#region src/infra/Error.d.ts
6
- declare enum EnvaptErrorCodes {
7
- /** Thrown when an invalid fallback value is provided */
8
- InvalidFallback = 101,
9
- /** Thrown when fallback value type doesn't match expected converter type */
10
- InvalidFallbackType = 102,
11
- /** Thrown when array fallback contains elements of wrong type */
12
- ArrayFallbackElementTypeMismatch = 103,
13
- /** Thrown when fallback type doesn't match the specified converter */
14
- FallbackConverterTypeMismatch = 104,
15
- /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */
16
- MalformedTimeFallback = 105,
17
- /** Thrown when invalid array converter configuration is provided */
18
- InvalidArrayConverterType = 201,
19
- /** Thrown when an invalid built-in converter is specified */
20
- InvalidBuiltInConverter = 202,
21
- /** Thrown when a custom converter is not a function */
22
- InvalidCustomConverter = 203,
23
- /** Thrown when converter type is not recognized */
24
- InvalidConverterType = 204,
25
- /** Thrown when primitive type coercion on fallback value fails */
26
- PrimitiveCoercionFailed = 205,
27
- /** Thrown when an array element fails to convert to the configured element type */
28
- ArrayElementConversionFailed = 206,
29
- /** Thrown under strict mode when an array element is empty or whitespace only */
30
- EmptyArrayElement = 207,
31
- /** Thrown when a Standard Schema returns issues for a non-empty env value */
32
- SchemaValidationFailed = 208,
33
- /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */
34
- SchemaThrew = 209,
35
- /** Thrown when delimiter is missing in array converter configuration */
36
- MissingDelimiter = 301,
37
- /** Thrown when invalid user-defined configuration is provided */
38
- InvalidUserDefinedConfig = 302,
39
- /** Thrown when specified environment files don't exist */
40
- EnvFilesNotFound = 303,
41
- /** Thrown when no valid environment key is provided */
42
- InvalidKeyInput = 304,
43
- /** Thrown when a required environment value is missing or empty (post-trim) */
44
- MissingEnvValue = 305,
45
- /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */
46
- FileApiUnsupported = 306,
47
- /** Thrown when an environment value is read before a source is bound via Envapter.useSource */
48
- NoSourceBound = 307
49
- }
50
- interface EnvaptErrorOptions {
51
- issues?: readonly StandardSchemaV1.Issue[];
52
- cause?: unknown;
53
- }
54
- /**
55
- * Custom error for better DX and debugging when using Envapt.
56
- *
57
- * @example
58
- * ```ts
59
- * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, "Invalid fallback value provided for environment variable.");
60
- * ```
61
- */
62
- declare class EnvaptError extends Error {
63
- readonly code: EnvaptErrorCodes;
64
- /**
65
- * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other
66
- * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`
67
- * without a type cast.
68
- */
69
- readonly issues: readonly StandardSchemaV1.Issue[] | undefined;
70
- constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions);
71
- }
72
- //#endregion
73
- export { EnvaptError, EnvaptErrorCodes };
74
- //# sourceMappingURL=Error.d.mts.map
@@ -1,59 +0,0 @@
1
- //#region src/infra/StandardSchema.d.ts
2
- /**
3
- * Standard Schema V1 interface. Inlined verbatim from the spec at https://standardschema.dev
4
- * so envapt has zero runtime peer dependencies on any specific schema library
5
- * (zod / valibot / arktype / etc).
6
- *
7
- * envapt narrows usage to SYNCHRONOUS schemas only: env loading is boot-time,
8
- * `validate` returning `Promise<Result>` is rejected at the type level (see
9
- * `SchemaMustBeSync` brand in `Types.ts`) and at runtime by the Parser dispatch.
10
- *
11
- * @public
12
- */
13
- interface StandardSchemaV1<Input = unknown, Output = Input> {
14
- readonly '~standard': StandardSchemaV1.Props<Input, Output>;
15
- }
16
- declare namespace StandardSchemaV1 {
17
- interface Props<Input = unknown, Output = Input> {
18
- readonly version: 1;
19
- readonly vendor: string;
20
- readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
21
- readonly types?: Types<Input, Output> | undefined;
22
- }
23
- type Result<Output> = SuccessResult<Output> | FailureResult;
24
- interface SuccessResult<Output> {
25
- readonly value: Output;
26
- readonly issues?: undefined;
27
- }
28
- interface FailureResult {
29
- readonly issues: readonly Issue[];
30
- }
31
- interface Issue {
32
- readonly message: string;
33
- readonly path?: readonly (PropertyKey | PathSegment)[] | undefined;
34
- }
35
- interface PathSegment {
36
- readonly key: PropertyKey;
37
- }
38
- interface Types<Input = unknown, Output = Input> {
39
- readonly input: Input;
40
- readonly output: Output;
41
- }
42
- type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
43
- type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
44
- }
45
- /**
46
- * Envapt-side alias for {@link StandardSchemaV1.InferOutput}. Re-exported under a friendlier
47
- * name so consumers writing `static readonly x: InferSchemaOutput<typeof mySchema>`
48
- * don't need the namespace path.
49
- * @public
50
- */
51
- type InferSchemaOutput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema>;
52
- /**
53
- * Envapt-side alias for {@link StandardSchemaV1.InferInput}.
54
- * @public
55
- */
56
- type InferSchemaInput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferInput<Schema>;
57
- //#endregion
58
- export { InferSchemaInput, InferSchemaOutput, StandardSchemaV1 };
59
- //# sourceMappingURL=StandardSchema.d.cts.map
@@ -1,61 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- //#region src/infra/StandardSchema.d.ts
4
- /**
5
- * Standard Schema V1 interface. Inlined verbatim from the spec at https://standardschema.dev
6
- * so envapt has zero runtime peer dependencies on any specific schema library
7
- * (zod / valibot / arktype / etc).
8
- *
9
- * envapt narrows usage to SYNCHRONOUS schemas only: env loading is boot-time,
10
- * `validate` returning `Promise<Result>` is rejected at the type level (see
11
- * `SchemaMustBeSync` brand in `Types.ts`) and at runtime by the Parser dispatch.
12
- *
13
- * @public
14
- */
15
- interface StandardSchemaV1<Input = unknown, Output = Input> {
16
- readonly '~standard': StandardSchemaV1.Props<Input, Output>;
17
- }
18
- declare namespace StandardSchemaV1 {
19
- interface Props<Input = unknown, Output = Input> {
20
- readonly version: 1;
21
- readonly vendor: string;
22
- readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
23
- readonly types?: Types<Input, Output> | undefined;
24
- }
25
- type Result<Output> = SuccessResult<Output> | FailureResult;
26
- interface SuccessResult<Output> {
27
- readonly value: Output;
28
- readonly issues?: undefined;
29
- }
30
- interface FailureResult {
31
- readonly issues: readonly Issue[];
32
- }
33
- interface Issue {
34
- readonly message: string;
35
- readonly path?: readonly (PropertyKey | PathSegment)[] | undefined;
36
- }
37
- interface PathSegment {
38
- readonly key: PropertyKey;
39
- }
40
- interface Types<Input = unknown, Output = Input> {
41
- readonly input: Input;
42
- readonly output: Output;
43
- }
44
- type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
45
- type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
46
- }
47
- /**
48
- * Envapt-side alias for {@link StandardSchemaV1.InferOutput}. Re-exported under a friendlier
49
- * name so consumers writing `static readonly x: InferSchemaOutput<typeof mySchema>`
50
- * don't need the namespace path.
51
- * @public
52
- */
53
- type InferSchemaOutput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema>;
54
- /**
55
- * Envapt-side alias for {@link StandardSchemaV1.InferInput}.
56
- * @public
57
- */
58
- type InferSchemaInput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferInput<Schema>;
59
- //#endregion
60
- export { InferSchemaInput, InferSchemaOutput, StandardSchemaV1 };
61
- //# sourceMappingURL=StandardSchema.d.mts.map
@@ -1,4 +0,0 @@
1
- import { EnvaptFieldDecorator } from "./types/Decorator.cjs";
2
- import { Envapt } from "./decorators/legacy/Envapt.cjs";
3
- import { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl } from "./decorators/legacy/SugarDecorators.cjs";
4
- export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl, Envapt, type EnvaptFieldDecorator };
@@ -1,6 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { EnvaptFieldDecorator } from "./types/Decorator.mjs";
4
- import { Envapt } from "./decorators/legacy/Envapt.mjs";
5
- import { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl } from "./decorators/legacy/SugarDecorators.mjs";
6
- export { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl, Envapt, type EnvaptFieldDecorator };
@@ -1,19 +0,0 @@
1
- import { BareEnvSource } from "../types/Source.cjs";
2
-
3
- //#region src/sources/ManualEnvSource.d.ts
4
- /**
5
- * Environment source seeded from an object you provide: the config your bundler injects into a browser
6
- * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain
7
- * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.
8
- * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.
9
- * @public
10
- */
11
- declare class ManualEnvSource implements BareEnvSource {
12
- readonly supportsFiles = false;
13
- private readonly vars;
14
- constructor(vars: Record<string, unknown>);
15
- readVars(): Record<string, string>;
16
- }
17
- //#endregion
18
- export { ManualEnvSource };
19
- //# sourceMappingURL=ManualEnvSource.d.cts.map
@@ -1,21 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { BareEnvSource } from "../types/Source.mjs";
4
-
5
- //#region src/sources/ManualEnvSource.d.ts
6
- /**
7
- * Environment source seeded from an object you provide: the config your bundler injects into a browser
8
- * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain
9
- * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.
10
- * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.
11
- * @public
12
- */
13
- declare class ManualEnvSource implements BareEnvSource {
14
- readonly supportsFiles = false;
15
- private readonly vars;
16
- constructor(vars: Record<string, unknown>);
17
- readVars(): Record<string, string>;
18
- }
19
- //#endregion
20
- export { ManualEnvSource };
21
- //# sourceMappingURL=ManualEnvSource.d.mts.map
@@ -1,22 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { FileEnvSource } from "../types/Source.mjs";
4
-
5
- //#region src/sources/NodeEnvSource.d.ts
6
- /**
7
- * Default environment source on Node, Bun, and Deno: a snapshot of `process.env`. Its
8
- * `supportsFiles` is `true`, so the engine also layers the `.env` cascade on top, resolves
9
- * `baseDir`, and can mirror loaded keys back to `process.env`.
10
- * @public
11
- */
12
- declare class NodeEnvSource implements FileEnvSource {
13
- readonly supportsFiles = true;
14
- readVars(): Record<string, string>;
15
- readFile(path: string, encoding: string): string | undefined;
16
- normalizeBaseDir(value: string | URL): string;
17
- resolvePath(baseDir: string, candidate: string): string;
18
- writeVars(vars: Record<string, string>): void;
19
- }
20
- //#endregion
21
- export { NodeEnvSource };
22
- //# sourceMappingURL=NodeEnvSource.d.mts.map
@@ -1,19 +0,0 @@
1
- import { BareEnvSource } from "../types/Source.cjs";
2
-
3
- //#region src/sources/WorkerEnvSource.d.ts
4
- /**
5
- * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass
6
- * through; non-string bindings are JSON-stringified so the converters still apply, and so must be
7
- * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and
8
- * file-based APIs do not apply.
9
- * @public
10
- */
11
- declare class WorkerEnvSource implements BareEnvSource {
12
- readonly supportsFiles = false;
13
- private readonly vars;
14
- constructor(env: Record<string, unknown>);
15
- readVars(): Record<string, string>;
16
- }
17
- //#endregion
18
- export { WorkerEnvSource };
19
- //# sourceMappingURL=WorkerEnvSource.d.cts.map
@@ -1,21 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { BareEnvSource } from "../types/Source.mjs";
4
-
5
- //#region src/sources/WorkerEnvSource.d.ts
6
- /**
7
- * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass
8
- * through; non-string bindings are JSON-stringified so the converters still apply, and so must be
9
- * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and
10
- * file-based APIs do not apply.
11
- * @public
12
- */
13
- declare class WorkerEnvSource implements BareEnvSource {
14
- readonly supportsFiles = false;
15
- private readonly vars;
16
- constructor(env: Record<string, unknown>);
17
- readVars(): Record<string, string>;
18
- }
19
- //#endregion
20
- export { WorkerEnvSource };
21
- //# sourceMappingURL=WorkerEnvSource.d.mts.map
@@ -1,123 +0,0 @@
1
- import { ArrayOf, ConverterToken, CustomElementConverter } from "../converters/Converters.cjs";
2
-
3
- //#region src/types/Conversion.d.ts
4
- /**
5
- * Scalar built-in converter tokens (e.g. `'number'`, `'time'`).
6
- * Excludes the array builder (see {@link ArrayOf}).
7
- * @public
8
- */
9
- type BuiltInConverter = ConverterToken;
10
- /**
11
- * Primitive types supported by Envapter
12
- * @public
13
- */
14
- type PrimitiveConstructor = typeof String | typeof Number | typeof Boolean | typeof BigInt | typeof Symbol;
15
- /**
16
- * String value from a .env file or environment variable
17
- * @public
18
- */
19
- type BaseInput = string | undefined;
20
- /**
21
- * Custom parser function type for environment variables
22
- * @param raw - Raw string value from environment
23
- * @param fallback - Fallback value if parsing fails
24
- * @returns Parsed value of type T
25
- * @public
26
- */
27
- type ConverterFunction<TFallback = unknown> = (raw: BaseInput, fallback?: TFallback) => TFallback;
28
- /**
29
- * Environment variable converter: a primitive constructor, a built-in scalar token, an `ArrayOf<...>`
30
- * produced by {@link Converters.array}, or a custom parser function.
31
- * @public
32
- */
33
- type EnvaptConverter<TFallback> = PrimitiveConstructor | BuiltInConverter | ArrayOf | ConverterFunction<TFallback>;
34
- type JsonPrimitive = string | number | boolean | null;
35
- type JsonArray = JsonValue[];
36
- interface JsonObject {
37
- [key: string]: JsonValue;
38
- }
39
- /**
40
- * JSON value types for custom converters
41
- * @public
42
- */
43
- type JsonValue = JsonPrimitive | JsonArray | JsonObject;
44
- interface ConverterMap {
45
- string: string;
46
- number: number;
47
- boolean: boolean;
48
- bigint: bigint;
49
- symbol: symbol;
50
- integer: number;
51
- float: number;
52
- json: JsonValue;
53
- url: URL;
54
- regexp: RegExp;
55
- date: Date;
56
- time: number;
57
- }
58
- /**
59
- * Type mapping for built-in scalar converters to their return types
60
- * @internal
61
- */
62
- type BuiltInConverterReturnType<ConverterKey extends BuiltInConverter> = ConverterMap[ConverterKey];
63
- /**
64
- * Return type for built-in converter functions
65
- * @internal
66
- */
67
- type ReturnValuesOfConverterFunctions = ConverterMap[BuiltInConverter];
68
- /**
69
- * Function type for built-in converter functions
70
- * @internal
71
- */
72
- type BuiltInConverterFunction = (...args: Parameters<(...args: any[]) => ReturnValuesOfConverterFunctions>) => ReturnValuesOfConverterFunctions | undefined;
73
- /**
74
- * Map of built-in converter functions
75
- * @internal
76
- */
77
- type MapOfConverterFunctions = Record<BuiltInConverter, BuiltInConverterFunction>;
78
- /**
79
- * Time unit types for duration conversions
80
- * @internal
81
- */
82
- type TimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w';
83
- /**
84
- * Fallback type for time duration conversions
85
- * @public
86
- */
87
- type TimeFallback = number | `${number}${TimeUnit}`;
88
- /**
89
- * Helper type for getter methods that conditionally return undefined based on whether a fallback is provided
90
- * If fallback is provided, return ReturnType. If no fallback (undefined), return ReturnType | undefined.
91
- * @internal
92
- */
93
- type ConditionalReturn<ReturnType, TFallback> = TFallback extends undefined ? ReturnType | undefined : ReturnType;
94
- /**
95
- * Inferred return type for a converter.
96
- *
97
- * - `ArrayOf<E>` resolves to the element type's return as an array. When `E` is a custom
98
- * function, the function's return type drives the array element. When `E` is a scalar
99
- * token, `ConverterMap` provides the element type.
100
- * - Bare scalar tokens resolve through `ConverterMap`.
101
- * @internal
102
- */
103
- type InferConverterReturnType<TConverter> = TConverter extends ArrayOf<infer Element> ? Element extends BuiltInConverter ? ConverterMap[Element][] : Element extends CustomElementConverter<infer Returned> ? Returned[] : never : TConverter extends BuiltInConverter ? BuiltInConverterReturnType<TConverter> : never;
104
- /**
105
- * Type inference for the *fallback* slot of a converter. `Converters.Time` (scalar or array
106
- * element) accepts {@link TimeFallback} / `TimeFallback[]`; everything else mirrors the
107
- * return type. Add future asymmetric fallback/return converters to this conditional.
108
- * @internal
109
- */
110
- type InferConverterFallbackType<TConverter> = TConverter extends 'time' ? TimeFallback : TConverter extends ArrayOf<infer Element> ? Element extends 'time' ? TimeFallback[] : InferConverterReturnType<TConverter> : InferConverterReturnType<TConverter>;
111
- /**
112
- * Complete type inference for advanced converter methods
113
- * @internal
114
- */
115
- type AdvancedConverterReturn<TConverter, TFallback = undefined> = ConditionalReturn<InferConverterReturnType<TConverter>, TFallback>;
116
- /**
117
- * Type inference for primitive constructor return types
118
- * @internal
119
- */
120
- type InferPrimitiveReturnType<TConstructor extends PrimitiveConstructor> = TConstructor extends typeof String ? string : TConstructor extends typeof Number ? number : TConstructor extends typeof Boolean ? boolean : TConstructor extends typeof BigInt ? bigint : TConstructor extends typeof Symbol ? symbol : never;
121
- //#endregion
122
- export type { AdvancedConverterReturn, BuiltInConverter, BuiltInConverterFunction, ConditionalReturn, ConverterFunction, EnvaptConverter, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, JsonValue, MapOfConverterFunctions, PrimitiveConstructor, TimeFallback, TimeUnit };
123
- //# sourceMappingURL=Conversion.d.cts.map
@@ -1,125 +0,0 @@
1
- import __tsdown_shims_path from 'node:path';
2
- import __tsdown_shims_url from 'node:url';
3
- import { ArrayOf, ConverterToken, CustomElementConverter } from "../converters/Converters.mjs";
4
-
5
- //#region src/types/Conversion.d.ts
6
- /**
7
- * Scalar built-in converter tokens (e.g. `'number'`, `'time'`).
8
- * Excludes the array builder (see {@link ArrayOf}).
9
- * @public
10
- */
11
- type BuiltInConverter = ConverterToken;
12
- /**
13
- * Primitive types supported by Envapter
14
- * @public
15
- */
16
- type PrimitiveConstructor = typeof String | typeof Number | typeof Boolean | typeof BigInt | typeof Symbol;
17
- /**
18
- * String value from a .env file or environment variable
19
- * @public
20
- */
21
- type BaseInput = string | undefined;
22
- /**
23
- * Custom parser function type for environment variables
24
- * @param raw - Raw string value from environment
25
- * @param fallback - Fallback value if parsing fails
26
- * @returns Parsed value of type T
27
- * @public
28
- */
29
- type ConverterFunction<TFallback = unknown> = (raw: BaseInput, fallback?: TFallback) => TFallback;
30
- /**
31
- * Environment variable converter: a primitive constructor, a built-in scalar token, an `ArrayOf<...>`
32
- * produced by {@link Converters.array}, or a custom parser function.
33
- * @public
34
- */
35
- type EnvaptConverter<TFallback> = PrimitiveConstructor | BuiltInConverter | ArrayOf | ConverterFunction<TFallback>;
36
- type JsonPrimitive = string | number | boolean | null;
37
- type JsonArray = JsonValue[];
38
- interface JsonObject {
39
- [key: string]: JsonValue;
40
- }
41
- /**
42
- * JSON value types for custom converters
43
- * @public
44
- */
45
- type JsonValue = JsonPrimitive | JsonArray | JsonObject;
46
- interface ConverterMap {
47
- string: string;
48
- number: number;
49
- boolean: boolean;
50
- bigint: bigint;
51
- symbol: symbol;
52
- integer: number;
53
- float: number;
54
- json: JsonValue;
55
- url: URL;
56
- regexp: RegExp;
57
- date: Date;
58
- time: number;
59
- }
60
- /**
61
- * Type mapping for built-in scalar converters to their return types
62
- * @internal
63
- */
64
- type BuiltInConverterReturnType<ConverterKey extends BuiltInConverter> = ConverterMap[ConverterKey];
65
- /**
66
- * Return type for built-in converter functions
67
- * @internal
68
- */
69
- type ReturnValuesOfConverterFunctions = ConverterMap[BuiltInConverter];
70
- /**
71
- * Function type for built-in converter functions
72
- * @internal
73
- */
74
- type BuiltInConverterFunction = (...args: Parameters<(...args: any[]) => ReturnValuesOfConverterFunctions>) => ReturnValuesOfConverterFunctions | undefined;
75
- /**
76
- * Map of built-in converter functions
77
- * @internal
78
- */
79
- type MapOfConverterFunctions = Record<BuiltInConverter, BuiltInConverterFunction>;
80
- /**
81
- * Time unit types for duration conversions
82
- * @internal
83
- */
84
- type TimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w';
85
- /**
86
- * Fallback type for time duration conversions
87
- * @public
88
- */
89
- type TimeFallback = number | `${number}${TimeUnit}`;
90
- /**
91
- * Helper type for getter methods that conditionally return undefined based on whether a fallback is provided
92
- * If fallback is provided, return ReturnType. If no fallback (undefined), return ReturnType | undefined.
93
- * @internal
94
- */
95
- type ConditionalReturn<ReturnType, TFallback> = TFallback extends undefined ? ReturnType | undefined : ReturnType;
96
- /**
97
- * Inferred return type for a converter.
98
- *
99
- * - `ArrayOf<E>` resolves to the element type's return as an array. When `E` is a custom
100
- * function, the function's return type drives the array element. When `E` is a scalar
101
- * token, `ConverterMap` provides the element type.
102
- * - Bare scalar tokens resolve through `ConverterMap`.
103
- * @internal
104
- */
105
- type InferConverterReturnType<TConverter> = TConverter extends ArrayOf<infer Element> ? Element extends BuiltInConverter ? ConverterMap[Element][] : Element extends CustomElementConverter<infer Returned> ? Returned[] : never : TConverter extends BuiltInConverter ? BuiltInConverterReturnType<TConverter> : never;
106
- /**
107
- * Type inference for the *fallback* slot of a converter. `Converters.Time` (scalar or array
108
- * element) accepts {@link TimeFallback} / `TimeFallback[]`; everything else mirrors the
109
- * return type. Add future asymmetric fallback/return converters to this conditional.
110
- * @internal
111
- */
112
- type InferConverterFallbackType<TConverter> = TConverter extends 'time' ? TimeFallback : TConverter extends ArrayOf<infer Element> ? Element extends 'time' ? TimeFallback[] : InferConverterReturnType<TConverter> : InferConverterReturnType<TConverter>;
113
- /**
114
- * Complete type inference for advanced converter methods
115
- * @internal
116
- */
117
- type AdvancedConverterReturn<TConverter, TFallback = undefined> = ConditionalReturn<InferConverterReturnType<TConverter>, TFallback>;
118
- /**
119
- * Type inference for primitive constructor return types
120
- * @internal
121
- */
122
- type InferPrimitiveReturnType<TConstructor extends PrimitiveConstructor> = TConstructor extends typeof String ? string : TConstructor extends typeof Number ? number : TConstructor extends typeof Boolean ? boolean : TConstructor extends typeof BigInt ? bigint : TConstructor extends typeof Symbol ? symbol : never;
123
- //#endregion
124
- export type { AdvancedConverterReturn, BuiltInConverter, BuiltInConverterFunction, ConditionalReturn, ConverterFunction, EnvaptConverter, InferConverterFallbackType, InferConverterReturnType, InferPrimitiveReturnType, JsonValue, MapOfConverterFunctions, PrimitiveConstructor, TimeFallback, TimeUnit };
125
- //# sourceMappingURL=Conversion.d.mts.map
@@ -1,26 +0,0 @@
1
- //#region src/types/Decorator.d.ts
2
- /**
3
- * A legacy (experimentalDecorators) property decorator that also constrains the decorated field's
4
- * declared type. `Output` is the value the decorator produces. The field must be wide enough to hold
5
- * it, so a field narrower than `Output` fails to compile while a wider or nullable field is accepted.
6
- * The tuple wrap stops `Output` from distributing when it is a union.
7
- * @public
8
- */
9
- type EnvaptFieldDecorator<Output> = <Target, Key extends keyof Target>(target: Target, key: [Output] extends [Target[Key]] ? Key : {
10
- '[envapt] field type must hold the converter output': Output;
11
- }) => void;
12
- /**
13
- * A modern (TC39 Stage 3) accessor decorator that also constrains the decorated `accessor`'s
14
- * declared type. `Output` is the value the decorator produces. The accessor must be wide enough to
15
- * hold it, so an accessor narrower than `Output` fails to compile while a wider or nullable one is
16
- * accepted. The tuple wrap stops `Output` from distributing when it is a union.
17
- * @public
18
- */
19
- type EnvaptAccessorDecorator<Output> = <This, Value>(target: ClassAccessorDecoratorTarget<This, [Output] extends [Value] ? Value : {
20
- '[envapt] field type must hold the converter output': Output;
21
- }>, context: ClassAccessorDecoratorContext<This, [Output] extends [Value] ? Value : {
22
- '[envapt] field type must hold the converter output': Output;
23
- }>) => ClassAccessorDecoratorResult<This, Value>;
24
- //#endregion
25
- export { EnvaptAccessorDecorator, EnvaptFieldDecorator };
26
- //# sourceMappingURL=Decorator.d.cts.map