@e-n-v/env 0.0.2 → 0.0.5
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/README.md +43 -24
- package/dist/BooleanMap-B2eIP3tZ.d.cts +32 -0
- package/dist/BooleanMap-DmFnCA-O.d.ts +32 -0
- package/dist/EnvChannel-LMIRYvT1.d.cts +16 -0
- package/dist/EnvChannel-w27PEm7x.d.ts +16 -0
- package/dist/EnvChannelOptions-BPkWDrmr.d.cts +108 -0
- package/dist/EnvChannelOptions-CRwDLWjd.d.ts +108 -0
- package/dist/EnvModel-CrGclUpJ.d.cts +134 -0
- package/dist/EnvModel-D8rt0EJ6.d.ts +134 -0
- package/dist/EnvSource-BVnmdHku.cjs +420 -0
- package/dist/EnvSource-DA3ZGlES.js +400 -0
- package/dist/ProcessEnvChannel-D465c-dp.d.cts +97 -0
- package/dist/ProcessEnvChannel-Do4-yiLI.d.ts +97 -0
- package/dist/StringEnvVarSchema-B8MT7htU.d.ts +64 -0
- package/dist/StringEnvVarSchema-BF6C0nyT.d.cts +64 -0
- package/dist/channels.cjs +8 -0
- package/dist/channels.d.cts +20 -0
- package/dist/channels.d.ts +20 -0
- package/dist/channels.js +4 -0
- package/dist/chunk-pbleEpgJ.cjs +44 -0
- package/dist/cli.cjs +16 -10
- package/dist/cli.js +7 -2
- package/dist/coerce-DNIuYAx4.js +11028 -0
- package/dist/coerce-b7UVodS9.cjs +12365 -0
- package/dist/core.cjs +68 -0
- package/dist/core.d.cts +6 -0
- package/dist/core.d.ts +6 -0
- package/dist/core.js +40 -0
- package/dist/custom-Bt_wnxIu.js +114 -0
- package/dist/custom-D_Rqjm09.cjs +168 -0
- package/dist/files.cjs +18 -0
- package/dist/files.d.cts +38 -0
- package/dist/files.d.ts +38 -0
- package/dist/files.js +13 -0
- package/dist/index-D8pslhp4.d.cts +170 -0
- package/dist/index-Dq_0aeAL.d.ts +170 -0
- package/dist/model-Dic8IJsf.d.ts +29 -0
- package/dist/model-ft0WhSSS.d.cts +29 -0
- package/dist/model.cjs +14 -0
- package/dist/model.d.cts +35 -0
- package/dist/model.d.ts +35 -0
- package/dist/model.js +9 -0
- package/dist/parse-BT1QSa5e.d.cts +28 -0
- package/dist/parse-DwtLpVhC.d.ts +28 -0
- package/dist/parse.cjs +17 -0
- package/dist/parse.d.cts +52 -0
- package/dist/parse.d.ts +52 -0
- package/dist/parse.js +10 -0
- package/dist/prompt-C5WudV9x.d.cts +74 -0
- package/dist/prompt-yKdccbtZ.d.ts +74 -0
- package/dist/prompt.cjs +24 -0
- package/dist/prompt.d.cts +17 -0
- package/dist/prompt.d.ts +17 -0
- package/dist/prompt.js +12 -0
- package/dist/redis-CJOpRPjc.js +395 -0
- package/dist/redis-EcC7TX3K.cjs +611 -0
- package/dist/resolveChannel-CjAuxy3p.cjs +257 -0
- package/dist/resolveChannel-v9BDsw-M.js +224 -0
- package/dist/root.cjs +36 -0
- package/dist/root.d.cts +21 -0
- package/dist/root.d.ts +21 -0
- package/dist/root.js +21 -0
- package/dist/schema-DH4GiW9A.d.cts +18 -0
- package/dist/schema-jN4EtvEP.d.ts +18 -0
- package/dist/schemas/zod.cjs +629 -0
- package/dist/schemas/zod.d.cts +239 -0
- package/dist/schemas/zod.d.ts +239 -0
- package/dist/schemas/zod.js +550 -0
- package/dist/schemas.cjs +133 -0
- package/dist/schemas.d.cts +3 -0
- package/dist/schemas.d.ts +3 -0
- package/dist/schemas.js +6 -0
- package/dist/src-B7FG1rak.js +638 -0
- package/dist/src-BBwjK5SK.js +127 -0
- package/dist/src-CLTURaoo.js +311 -0
- package/dist/src-CVdUqK3q.js +850 -0
- package/dist/src-Cjo2XA4n.cjs +138 -0
- package/dist/{src-oetJm-nZ.cjs → src-DWYoqPX1.cjs} +31 -1964
- package/dist/src-DZmpNGrQ.cjs +1411 -0
- package/dist/{src-RlCvrI0s.js → src-Dtv7TlJx.js} +14 -1726
- package/dist/src-XjL5cyPG.cjs +873 -0
- package/dist/src-meUnCASg.cjs +413 -0
- package/dist/validate-BxA3a-ns.d.cts +203 -0
- package/dist/validate-CyxrRacF.d.ts +203 -0
- package/dist/vars-BNVI6k89.d.ts +21 -0
- package/dist/vars-CYOaskkK.cjs +27 -0
- package/dist/vars-CptZRPX5.d.cts +21 -0
- package/dist/vars-DOW0LiiN.js +22 -0
- package/dist/vars.cjs +138 -0
- package/dist/vars.d.cts +7 -0
- package/dist/vars.d.ts +7 -0
- package/dist/vars.js +9 -0
- package/package.json +58 -9
- package/assets/demo.gif +0 -0
- package/assets/env-logo.png +0 -0
- package/dist/bundle.cjs +0 -1290
- package/dist/bundle.d.cts +0 -1057
- package/dist/bundle.d.ts +0 -1055
- package/dist/bundle.js +0 -1244
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../core/src/schemas/EnvVarSchemaBase.ts
|
|
3
|
+
var EnvVarSchemaBase = class {
|
|
4
|
+
required;
|
|
5
|
+
default;
|
|
6
|
+
description;
|
|
7
|
+
process;
|
|
8
|
+
constructor(input) {
|
|
9
|
+
this.required = input?.required ?? true;
|
|
10
|
+
this.default = input?.default;
|
|
11
|
+
this.description = input?.description;
|
|
12
|
+
this.process = input.process;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region ../core/src/processing/helpers/toList.ts
|
|
18
|
+
/**
|
|
19
|
+
* Convert array of items to natural language list.
|
|
20
|
+
* Examples:
|
|
21
|
+
* - [] => ""
|
|
22
|
+
* - ["one"] => "one"
|
|
23
|
+
* - ["one", "two"] => "one and two"
|
|
24
|
+
* - ["one", "two", "three"] => "one, two, and three"
|
|
25
|
+
*/
|
|
26
|
+
function toList(items) {
|
|
27
|
+
if (items.length === 0) return "";
|
|
28
|
+
if (items.length === 1) return items[0];
|
|
29
|
+
if (items.length === 2) return `${items[0]} and ${items[1]}`;
|
|
30
|
+
return `${items.slice(0, -1).join(", ")}, and ${items[items.length - 1]}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region ../core/src/processing/helpers/validate.ts
|
|
35
|
+
/**
|
|
36
|
+
* Run checks and aggregate errors.
|
|
37
|
+
* Throws an error with all validation requirements if any check fails.
|
|
38
|
+
*/
|
|
39
|
+
function validate(value, checks) {
|
|
40
|
+
const allRequirements = checks.map((check) => check(value)).flat();
|
|
41
|
+
if (allRequirements.length > 0) {
|
|
42
|
+
const message = toList(allRequirements);
|
|
43
|
+
throw new Error(`Must be ${message}`);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region ../core/src/processing/processors/typed/string.ts
|
|
50
|
+
/**
|
|
51
|
+
* String processor with optional validation checks.
|
|
52
|
+
* This is the primary string processor - the base stringProcessor() calls this with no checks.
|
|
53
|
+
*/
|
|
54
|
+
function string$1(...checks) {
|
|
55
|
+
return (input) => {
|
|
56
|
+
if (typeof input !== "string") throw new Error("Value must be a string");
|
|
57
|
+
if (input === "") return;
|
|
58
|
+
if (checks.length > 0) return validate(input, checks);
|
|
59
|
+
return input;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region ../core/src/processing/processors/typed/number.ts
|
|
65
|
+
/**
|
|
66
|
+
* Number processor with optional validation checks.
|
|
67
|
+
* This is the primary number processor - the base numberProcessor() calls this with no checks.
|
|
68
|
+
*/
|
|
69
|
+
function number$1(...checks) {
|
|
70
|
+
return (input) => {
|
|
71
|
+
if (typeof input !== "string") throw new Error("Value must be a string");
|
|
72
|
+
const trimmed = input.trim();
|
|
73
|
+
if (trimmed === "") return;
|
|
74
|
+
const parsed = parseFloat(trimmed);
|
|
75
|
+
if (isNaN(parsed)) throw new Error(`"${input}" is not a valid number`);
|
|
76
|
+
if (checks.length > 0) return validate(parsed, checks);
|
|
77
|
+
return parsed;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region ../core/src/processing/constants/FALSE_STRINGS.ts
|
|
83
|
+
const FALSE_STRINGS = [
|
|
84
|
+
"false",
|
|
85
|
+
"0",
|
|
86
|
+
"no",
|
|
87
|
+
"off"
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region ../core/src/processing/constants/TRUE_STRINGS.ts
|
|
92
|
+
const TRUE_STRINGS = [
|
|
93
|
+
"true",
|
|
94
|
+
"1",
|
|
95
|
+
"yes",
|
|
96
|
+
"on"
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region ../core/src/processing/processors/typed/boolean.ts
|
|
101
|
+
/**
|
|
102
|
+
* Boolean processor.
|
|
103
|
+
* This is the primary boolean processor - the base booleanProcessor() calls this.
|
|
104
|
+
*/
|
|
105
|
+
function boolean$1() {
|
|
106
|
+
const trueValues = new Set(TRUE_STRINGS);
|
|
107
|
+
const falseValues = new Set(FALSE_STRINGS);
|
|
108
|
+
return (input) => {
|
|
109
|
+
if (typeof input !== "string") throw new Error("Value must be a string");
|
|
110
|
+
const trimmed = input.trim().toLowerCase();
|
|
111
|
+
if (trimmed === "") return;
|
|
112
|
+
if (trueValues.has(trimmed)) return true;
|
|
113
|
+
if (falseValues.has(trimmed)) return false;
|
|
114
|
+
const trueList = [...TRUE_STRINGS].join("/");
|
|
115
|
+
const falseList = [...FALSE_STRINGS].join("/");
|
|
116
|
+
throw new Error(`"${input}" is not a valid boolean. Use: ${trueList} or ${falseList}`);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region ../core/src/processing/processors/typed/enumeration.ts
|
|
122
|
+
/**
|
|
123
|
+
* Enum processor with optional validation checks.
|
|
124
|
+
* This is the primary enum processor - the base enumProcessor() calls this with no checks.
|
|
125
|
+
*/
|
|
126
|
+
function enumeration$1(allowedValues, ...checks) {
|
|
127
|
+
return (input) => {
|
|
128
|
+
if (typeof input !== "string") throw new Error("Value must be a string");
|
|
129
|
+
const trimmed = input.trim();
|
|
130
|
+
if (trimmed === "") return;
|
|
131
|
+
if (!allowedValues.includes(trimmed)) throw new Error(`"${input}" is not a valid option. Must be one of: ${allowedValues.join(", ")}`);
|
|
132
|
+
if (checks.length > 0) return validate(trimmed, checks);
|
|
133
|
+
return trimmed;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region ../core/src/processing/processors/processors.ts
|
|
139
|
+
/**
|
|
140
|
+
* Default processors for environment variable types.
|
|
141
|
+
* Each processor factory returns a function that takes a value and returns T | undefined.
|
|
142
|
+
* Returns undefined for empty/null values, throws descriptive errors for invalid values.
|
|
143
|
+
*/
|
|
144
|
+
const processors = {
|
|
145
|
+
boolean: boolean$1,
|
|
146
|
+
enum: enumeration$1,
|
|
147
|
+
number: number$1,
|
|
148
|
+
string: string$1
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region ../core/src/schemas/typed/BooleanEnvVarSchema.ts
|
|
153
|
+
var BooleanEnvVarSchema = class extends EnvVarSchemaBase {
|
|
154
|
+
type = "boolean";
|
|
155
|
+
constructor(input = {}) {
|
|
156
|
+
super({
|
|
157
|
+
...input,
|
|
158
|
+
process: input.process ?? processors.boolean()
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region ../core/src/schemas/typed/EnumEnvVarSchema.ts
|
|
165
|
+
var EnumEnvVarSchema = class extends EnvVarSchemaBase {
|
|
166
|
+
type = "enum";
|
|
167
|
+
values;
|
|
168
|
+
constructor(input) {
|
|
169
|
+
super({
|
|
170
|
+
...input,
|
|
171
|
+
process: input.process ?? processors.enum(input.values)
|
|
172
|
+
});
|
|
173
|
+
this.values = input.values;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region ../core/src/schemas/typed/NumberEnvVarSchema.ts
|
|
179
|
+
var NumberEnvVarSchema = class extends EnvVarSchemaBase {
|
|
180
|
+
type = "number";
|
|
181
|
+
constructor(input = {}) {
|
|
182
|
+
super({
|
|
183
|
+
...input,
|
|
184
|
+
process: input.process ?? processors.number()
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region ../core/src/schemas/typed/StringEnvVarSchema.ts
|
|
191
|
+
var StringEnvVarSchema = class extends EnvVarSchemaBase {
|
|
192
|
+
type = "string";
|
|
193
|
+
secret;
|
|
194
|
+
constructor(input = {}) {
|
|
195
|
+
super({
|
|
196
|
+
...input,
|
|
197
|
+
process: input.process ?? processors.string()
|
|
198
|
+
});
|
|
199
|
+
this.secret = input.secret;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region ../core/src/schemas/EnvVarSchema.ts
|
|
205
|
+
/**
|
|
206
|
+
* Type guard to check if a value is a EnvVarSchema instance
|
|
207
|
+
*/
|
|
208
|
+
function isEnvVarSchema(value) {
|
|
209
|
+
return value instanceof StringEnvVarSchema || value instanceof NumberEnvVarSchema || value instanceof BooleanEnvVarSchema || value instanceof EnumEnvVarSchema;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region ../core/src/processing/preprocessors/typed/number.ts
|
|
214
|
+
/**
|
|
215
|
+
* Create a number preprocessor that strips commas and whitespace
|
|
216
|
+
*/
|
|
217
|
+
const number = () => (value) => {
|
|
218
|
+
try {
|
|
219
|
+
const cleaned = value.replace(/,/g, "").trim();
|
|
220
|
+
if (/^-?\d*\.?\d+$/.test(cleaned)) return cleaned;
|
|
221
|
+
} catch {}
|
|
222
|
+
return value;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region ../core/src/processing/preprocessors/typed/boolean.ts
|
|
227
|
+
const boolean = (options = {
|
|
228
|
+
true: TRUE_STRINGS,
|
|
229
|
+
false: FALSE_STRINGS
|
|
230
|
+
}) => {
|
|
231
|
+
const normalize = (candidate) => candidate.toLowerCase().trim();
|
|
232
|
+
const trueValues = new Set(options.true.map(normalize));
|
|
233
|
+
const falseValues = new Set(options.false.map(normalize));
|
|
234
|
+
for (const candidate of trueValues) if (falseValues.has(candidate)) throw new Error(`Boolean preprocessor option value "${candidate}" cannot map to both true and false`);
|
|
235
|
+
return (value) => {
|
|
236
|
+
try {
|
|
237
|
+
const cleaned = normalize(value);
|
|
238
|
+
if (trueValues.has(cleaned)) return true;
|
|
239
|
+
if (falseValues.has(cleaned)) return false;
|
|
240
|
+
} catch {}
|
|
241
|
+
return value;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region ../core/src/processing/preprocessors/typed/enumeration.ts
|
|
247
|
+
/**
|
|
248
|
+
* Create an enum preprocessor - pass through unchanged
|
|
249
|
+
*/
|
|
250
|
+
const enumeration = () => (value) => value;
|
|
251
|
+
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region ../core/src/processing/preprocessors/typed/string.ts
|
|
254
|
+
/**
|
|
255
|
+
* Create a string preprocessor - pass through unchanged
|
|
256
|
+
*/
|
|
257
|
+
const string = () => (value) => value;
|
|
258
|
+
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region ../core/src/processing/preprocessors/preprocessors.ts
|
|
261
|
+
/**
|
|
262
|
+
* Default preprocessors map for each environment variable type
|
|
263
|
+
*/
|
|
264
|
+
const preprocessors = {
|
|
265
|
+
boolean,
|
|
266
|
+
enum: enumeration,
|
|
267
|
+
number,
|
|
268
|
+
string
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region ../core/src/processing/preprocessors/resolvePreprocessor.ts
|
|
273
|
+
const defaultFactories = {
|
|
274
|
+
number: preprocessors.number,
|
|
275
|
+
boolean: preprocessors.boolean,
|
|
276
|
+
string: void 0,
|
|
277
|
+
enum: void 0
|
|
278
|
+
};
|
|
279
|
+
const explicitFactories = {
|
|
280
|
+
number: preprocessors.number,
|
|
281
|
+
boolean: preprocessors.boolean,
|
|
282
|
+
string: preprocessors.string,
|
|
283
|
+
enum: preprocessors.enum
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Resolve the effective preprocessor for a given environment variable type.
|
|
287
|
+
* Respects custom overrides and falls back to built-in defaults (number, boolean).
|
|
288
|
+
*/
|
|
289
|
+
function resolvePreprocessor(envVarType, preprocessorOptions) {
|
|
290
|
+
const override = preprocessorOptions?.[envVarType];
|
|
291
|
+
if (override === void 0) {
|
|
292
|
+
const factory = defaultFactories[envVarType];
|
|
293
|
+
return factory ? factory() : void 0;
|
|
294
|
+
}
|
|
295
|
+
if (override === false) return;
|
|
296
|
+
if (override === true) return explicitFactories[envVarType]();
|
|
297
|
+
if (typeof override === "function") return override;
|
|
298
|
+
return preprocessors.boolean(override);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region ../core/src/schemas/schema.ts
|
|
303
|
+
const schema = {
|
|
304
|
+
string: (input = {}) => new StringEnvVarSchema(input),
|
|
305
|
+
number: (input = {}) => new NumberEnvVarSchema(input),
|
|
306
|
+
boolean: (input = {}) => new BooleanEnvVarSchema(input),
|
|
307
|
+
enum: (input) => new EnumEnvVarSchema(input)
|
|
308
|
+
};
|
|
309
|
+
const s = schema;
|
|
310
|
+
|
|
311
|
+
//#endregion
|
|
312
|
+
Object.defineProperty(exports, 'BooleanEnvVarSchema', {
|
|
313
|
+
enumerable: true,
|
|
314
|
+
get: function () {
|
|
315
|
+
return BooleanEnvVarSchema;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
Object.defineProperty(exports, 'EnumEnvVarSchema', {
|
|
319
|
+
enumerable: true,
|
|
320
|
+
get: function () {
|
|
321
|
+
return EnumEnvVarSchema;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
Object.defineProperty(exports, 'EnvVarSchemaBase', {
|
|
325
|
+
enumerable: true,
|
|
326
|
+
get: function () {
|
|
327
|
+
return EnvVarSchemaBase;
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
Object.defineProperty(exports, 'NumberEnvVarSchema', {
|
|
331
|
+
enumerable: true,
|
|
332
|
+
get: function () {
|
|
333
|
+
return NumberEnvVarSchema;
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
Object.defineProperty(exports, 'StringEnvVarSchema', {
|
|
337
|
+
enumerable: true,
|
|
338
|
+
get: function () {
|
|
339
|
+
return StringEnvVarSchema;
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
Object.defineProperty(exports, 'boolean', {
|
|
343
|
+
enumerable: true,
|
|
344
|
+
get: function () {
|
|
345
|
+
return boolean$1;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
Object.defineProperty(exports, 'enumeration', {
|
|
349
|
+
enumerable: true,
|
|
350
|
+
get: function () {
|
|
351
|
+
return enumeration$1;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
Object.defineProperty(exports, 'isEnvVarSchema', {
|
|
355
|
+
enumerable: true,
|
|
356
|
+
get: function () {
|
|
357
|
+
return isEnvVarSchema;
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
Object.defineProperty(exports, 'number', {
|
|
361
|
+
enumerable: true,
|
|
362
|
+
get: function () {
|
|
363
|
+
return number$1;
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
Object.defineProperty(exports, 'preprocessors', {
|
|
367
|
+
enumerable: true,
|
|
368
|
+
get: function () {
|
|
369
|
+
return preprocessors;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
Object.defineProperty(exports, 'processors', {
|
|
373
|
+
enumerable: true,
|
|
374
|
+
get: function () {
|
|
375
|
+
return processors;
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
Object.defineProperty(exports, 'resolvePreprocessor', {
|
|
379
|
+
enumerable: true,
|
|
380
|
+
get: function () {
|
|
381
|
+
return resolvePreprocessor;
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
Object.defineProperty(exports, 's', {
|
|
385
|
+
enumerable: true,
|
|
386
|
+
get: function () {
|
|
387
|
+
return s;
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
Object.defineProperty(exports, 'schema', {
|
|
391
|
+
enumerable: true,
|
|
392
|
+
get: function () {
|
|
393
|
+
return schema;
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
Object.defineProperty(exports, 'string', {
|
|
397
|
+
enumerable: true,
|
|
398
|
+
get: function () {
|
|
399
|
+
return string$1;
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
Object.defineProperty(exports, 'toList', {
|
|
403
|
+
enumerable: true,
|
|
404
|
+
get: function () {
|
|
405
|
+
return toList;
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
Object.defineProperty(exports, 'validate', {
|
|
409
|
+
enumerable: true,
|
|
410
|
+
get: function () {
|
|
411
|
+
return validate;
|
|
412
|
+
}
|
|
413
|
+
});
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { d as EnvVarType, f as Processor } from "./StringEnvVarSchema-BF6C0nyT.cjs";
|
|
2
|
+
import { n as Preprocessor, t as BooleanMap } from "./BooleanMap-B2eIP3tZ.cjs";
|
|
3
|
+
|
|
4
|
+
//#region ../core/src/schemas/EnvVarSchemaDetails.d.ts
|
|
5
|
+
interface EnvVarSchemaDetails<T> {
|
|
6
|
+
type: EnvVarType;
|
|
7
|
+
required: boolean;
|
|
8
|
+
default?: T;
|
|
9
|
+
description?: string;
|
|
10
|
+
process?: Processor<T>;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../core/src/processing/types/Check.d.ts
|
|
14
|
+
/**
|
|
15
|
+
* Check type definition.
|
|
16
|
+
* A check returns an array of requirement strings if the check fails, or an empty array if valid.
|
|
17
|
+
*/
|
|
18
|
+
type Check<T> = (value: T) => string[];
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region ../core/src/processing/processors/typed/string.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* String processor with optional validation checks.
|
|
23
|
+
* This is the primary string processor - the base stringProcessor() calls this with no checks.
|
|
24
|
+
*/
|
|
25
|
+
declare function string(...checks: Array<Check<string>>): Processor<string>;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region ../core/src/processing/processors/typed/number.d.ts
|
|
28
|
+
/**
|
|
29
|
+
* Number processor with optional validation checks.
|
|
30
|
+
* This is the primary number processor - the base numberProcessor() calls this with no checks.
|
|
31
|
+
*/
|
|
32
|
+
declare function number(...checks: Array<Check<number>>): Processor<number>;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region ../core/src/processing/processors/typed/boolean.d.ts
|
|
35
|
+
/**
|
|
36
|
+
* Boolean processor.
|
|
37
|
+
* This is the primary boolean processor - the base booleanProcessor() calls this.
|
|
38
|
+
*/
|
|
39
|
+
declare function boolean(): Processor<boolean>;
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region ../core/src/processing/processors/typed/enumeration.d.ts
|
|
42
|
+
/**
|
|
43
|
+
* Enum processor with optional validation checks.
|
|
44
|
+
* This is the primary enum processor - the base enumProcessor() calls this with no checks.
|
|
45
|
+
*/
|
|
46
|
+
declare function enumeration(allowedValues: readonly string[], ...checks: Array<Check<string>>): Processor<string>;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region ../core/src/processing/processors/processors.d.ts
|
|
49
|
+
/**
|
|
50
|
+
* Default processors for environment variable types.
|
|
51
|
+
* Each processor factory returns a function that takes a value and returns T | undefined.
|
|
52
|
+
* Returns undefined for empty/null values, throws descriptive errors for invalid values.
|
|
53
|
+
*/
|
|
54
|
+
declare const processors: {
|
|
55
|
+
readonly boolean: typeof boolean;
|
|
56
|
+
readonly enum: typeof enumeration;
|
|
57
|
+
readonly number: typeof number;
|
|
58
|
+
readonly string: typeof string;
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region ../core/src/processing/preprocessors/preprocessors.d.ts
|
|
62
|
+
/**
|
|
63
|
+
* Default preprocessors map for each environment variable type
|
|
64
|
+
*/
|
|
65
|
+
declare const preprocessors: {
|
|
66
|
+
readonly boolean: (options?: BooleanMap) => Preprocessor<boolean>;
|
|
67
|
+
readonly enum: () => Preprocessor<string>;
|
|
68
|
+
readonly number: () => Preprocessor<number>;
|
|
69
|
+
readonly string: () => Preprocessor<string>;
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region ../core/src/processing/options/PreprocessorOptions.d.ts
|
|
73
|
+
type PreprocessorOptions = Partial<{
|
|
74
|
+
/**
|
|
75
|
+
* Custom string preprocessing function
|
|
76
|
+
* Receives the string value and should return a string value
|
|
77
|
+
* @param value - The raw string value from the environment variable
|
|
78
|
+
* @returns Preprocessed string value
|
|
79
|
+
*/
|
|
80
|
+
string?: Preprocessor<string> | boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Custom number preprocessing function
|
|
83
|
+
* Receives the string value and should return a string or the target number type
|
|
84
|
+
* @param value - The raw string value from the environment variable
|
|
85
|
+
* @returns Preprocessed string or number value
|
|
86
|
+
*/
|
|
87
|
+
number?: Preprocessor<number> | boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Custom boolean preprocessing function
|
|
90
|
+
* Receives the string value and should return a string or the target boolean type
|
|
91
|
+
* @param value - The raw string value from the environment variable
|
|
92
|
+
* @returns Preprocessed string or boolean value
|
|
93
|
+
*/
|
|
94
|
+
boolean?: boolean | Preprocessor<boolean> | BooleanMap;
|
|
95
|
+
/**
|
|
96
|
+
* Custom enum preprocessing function
|
|
97
|
+
* Receives the string value and should return a string value
|
|
98
|
+
* @param value - The raw string value from the environment variable
|
|
99
|
+
* @returns Preprocessed string value
|
|
100
|
+
*/
|
|
101
|
+
enum?: Preprocessor<string> | boolean;
|
|
102
|
+
}>;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region ../core/src/processing/preprocessors/resolvePreprocessor.d.ts
|
|
105
|
+
type DefaultPreprocessor<T extends EnvVarType> = T extends "number" ? Preprocessor<number> : T extends "boolean" ? Preprocessor<boolean> : Preprocessor<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Resolve the effective preprocessor for a given environment variable type.
|
|
108
|
+
* Respects custom overrides and falls back to built-in defaults (number, boolean).
|
|
109
|
+
*/
|
|
110
|
+
declare function resolvePreprocessor<T extends EnvVarType>(envVarType: T, preprocessorOptions?: PreprocessorOptions): DefaultPreprocessor<T> | undefined;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region ../core/src/processing/checks/minLength.d.ts
|
|
113
|
+
/**
|
|
114
|
+
* String check: minimum length.
|
|
115
|
+
*/
|
|
116
|
+
declare function minLength(min: number, trait?: string): Check<string>;
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region ../core/src/processing/checks/maxLength.d.ts
|
|
119
|
+
/**
|
|
120
|
+
* String check: maximum length.
|
|
121
|
+
*/
|
|
122
|
+
declare function maxLength(max: number, trait?: string): Check<string>;
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region ../core/src/processing/checks/lengthBetween.d.ts
|
|
125
|
+
/**
|
|
126
|
+
* String check: length within a range.
|
|
127
|
+
*/
|
|
128
|
+
declare function lengthBetween(min: number, max: number, trait?: string): Check<string>;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region ../core/src/processing/checks/exactLength.d.ts
|
|
131
|
+
/**
|
|
132
|
+
* String check: exact length.
|
|
133
|
+
*/
|
|
134
|
+
declare function exactLength(length: number, trait?: string): Check<string>;
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region ../core/src/processing/checks/pattern.d.ts
|
|
137
|
+
/**
|
|
138
|
+
* String check: regex pattern match.
|
|
139
|
+
*/
|
|
140
|
+
declare function pattern(regex: RegExp, trait: string | readonly string[]): Check<string>;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region ../core/src/processing/checks/url.d.ts
|
|
143
|
+
/**
|
|
144
|
+
* String check: valid URL.
|
|
145
|
+
*/
|
|
146
|
+
declare function url(trait?: string): Check<string>;
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region ../core/src/processing/checks/oneOf.d.ts
|
|
149
|
+
/**
|
|
150
|
+
* String check: value must be one of the provided values.
|
|
151
|
+
*/
|
|
152
|
+
declare function oneOf<T extends string>(values: readonly T[], trait?: string): Check<string>;
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region ../core/src/processing/checks/integer.d.ts
|
|
155
|
+
/**
|
|
156
|
+
* Number check: must be an integer.
|
|
157
|
+
*/
|
|
158
|
+
declare function integer(trait?: string): Check<number>;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region ../core/src/processing/checks/min.d.ts
|
|
161
|
+
/**
|
|
162
|
+
* Number check: minimum value.
|
|
163
|
+
*/
|
|
164
|
+
declare function min(minimum: number, trait?: string): Check<number>;
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region ../core/src/processing/checks/max.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* Number check: maximum value.
|
|
169
|
+
*/
|
|
170
|
+
declare function max(maximum: number, trait?: string): Check<number>;
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region ../core/src/processing/checks/between.d.ts
|
|
173
|
+
/**
|
|
174
|
+
* Number check: value within a range.
|
|
175
|
+
*/
|
|
176
|
+
declare function between(minimum: number, maximum: number, trait?: string): Check<number>;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region ../core/src/processing/checks/custom.d.ts
|
|
179
|
+
/**
|
|
180
|
+
* Custom check with user-defined validation function.
|
|
181
|
+
* Can return multiple traits.
|
|
182
|
+
*/
|
|
183
|
+
declare function custom<T>(fn: (value: T) => boolean, ...traits: string[]): Check<T>;
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region ../core/src/processing/helpers/toList.d.ts
|
|
186
|
+
/**
|
|
187
|
+
* Convert array of items to natural language list.
|
|
188
|
+
* Examples:
|
|
189
|
+
* - [] => ""
|
|
190
|
+
* - ["one"] => "one"
|
|
191
|
+
* - ["one", "two"] => "one and two"
|
|
192
|
+
* - ["one", "two", "three"] => "one, two, and three"
|
|
193
|
+
*/
|
|
194
|
+
declare function toList(items: string[]): string;
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region ../core/src/processing/helpers/validate.d.ts
|
|
197
|
+
/**
|
|
198
|
+
* Run checks and aggregate errors.
|
|
199
|
+
* Throws an error with all validation requirements if any check fails.
|
|
200
|
+
*/
|
|
201
|
+
declare function validate<T>(value: T, checks: Array<Check<T>>): T;
|
|
202
|
+
//#endregion
|
|
203
|
+
export { Check as C, string as S, preprocessors as _, max as a, boolean as b, oneOf as c, exactLength as d, lengthBetween as f, PreprocessorOptions as g, resolvePreprocessor as h, between as i, url as l, minLength as m, toList as n, min as o, maxLength as p, custom as r, integer as s, validate as t, pattern as u, processors as v, EnvVarSchemaDetails as w, number as x, enumeration as y };
|