@e-n-v/env 0.0.2 → 0.0.4
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 +57 -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
package/dist/core.cjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const require_src = require('./src-meUnCASg.cjs');
|
|
2
|
+
const require_custom = require('./custom-D_Rqjm09.cjs');
|
|
3
|
+
|
|
4
|
+
//#region ../core/src/processing/checks/maxLength.ts
|
|
5
|
+
/**
|
|
6
|
+
* String check: maximum length.
|
|
7
|
+
*/
|
|
8
|
+
function maxLength(max$1, trait) {
|
|
9
|
+
return (value) => {
|
|
10
|
+
if (value.length > max$1) return trait ? [trait] : [`at most ${max$1} characters`];
|
|
11
|
+
return [];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../core/src/processing/checks/min.ts
|
|
17
|
+
/**
|
|
18
|
+
* Number check: minimum value.
|
|
19
|
+
*/
|
|
20
|
+
function min(minimum, trait) {
|
|
21
|
+
return (value) => {
|
|
22
|
+
if (value < minimum) return trait ? [trait] : [`at least ${minimum}`];
|
|
23
|
+
return [];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region ../core/src/processing/checks/max.ts
|
|
29
|
+
/**
|
|
30
|
+
* Number check: maximum value.
|
|
31
|
+
*/
|
|
32
|
+
function max(maximum, trait) {
|
|
33
|
+
return (value) => {
|
|
34
|
+
if (value > maximum) return trait ? [trait] : [`at most ${maximum}`];
|
|
35
|
+
return [];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.BooleanEnvVarSchema = require_src.BooleanEnvVarSchema;
|
|
41
|
+
exports.EnumEnvVarSchema = require_src.EnumEnvVarSchema;
|
|
42
|
+
exports.EnvVarSchemaBase = require_src.EnvVarSchemaBase;
|
|
43
|
+
exports.NumberEnvVarSchema = require_src.NumberEnvVarSchema;
|
|
44
|
+
exports.StringEnvVarSchema = require_src.StringEnvVarSchema;
|
|
45
|
+
exports.between = require_custom.between;
|
|
46
|
+
exports.boolean = require_src.boolean;
|
|
47
|
+
exports.custom = require_custom.custom;
|
|
48
|
+
exports.enumeration = require_src.enumeration;
|
|
49
|
+
exports.exactLength = require_custom.exactLength;
|
|
50
|
+
exports.integer = require_custom.integer;
|
|
51
|
+
exports.isEnvVarSchema = require_src.isEnvVarSchema;
|
|
52
|
+
exports.lengthBetween = require_custom.lengthBetween;
|
|
53
|
+
exports.max = max;
|
|
54
|
+
exports.maxLength = maxLength;
|
|
55
|
+
exports.min = min;
|
|
56
|
+
exports.minLength = require_custom.minLength;
|
|
57
|
+
exports.number = require_src.number;
|
|
58
|
+
exports.oneOf = require_custom.oneOf;
|
|
59
|
+
exports.pattern = require_custom.pattern;
|
|
60
|
+
exports.preprocessors = require_src.preprocessors;
|
|
61
|
+
exports.processors = require_src.processors;
|
|
62
|
+
exports.resolvePreprocessor = require_src.resolvePreprocessor;
|
|
63
|
+
exports.s = require_src.s;
|
|
64
|
+
exports.schema = require_src.schema;
|
|
65
|
+
exports.string = require_src.string;
|
|
66
|
+
exports.toList = require_src.toList;
|
|
67
|
+
exports.url = require_custom.url;
|
|
68
|
+
exports.validate = require_src.validate;
|
package/dist/core.d.cts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { a as EnumEnvVarSchema, c as BooleanEnvVarSchemaInput, d as EnvVarType, f as Processor, i as NumberEnvVarSchemaInput, l as EnvVarSchemaBase, n as StringEnvVarSchemaInput, o as EnumEnvVarSchemaInput, r as NumberEnvVarSchema, s as BooleanEnvVarSchema, t as StringEnvVarSchema, u as EnvVarSchemaInput } from "./StringEnvVarSchema-BF6C0nyT.cjs";
|
|
2
|
+
import { C as Check, S as string, _ as preprocessors, a as max, b as boolean, c as oneOf, d as exactLength, f as lengthBetween, g as PreprocessorOptions, h as resolvePreprocessor, i as between, l as url, m as minLength, n as toList, o as min, p as maxLength, r as custom, s as integer, t as validate, u as pattern, v as processors, w as EnvVarSchemaDetails, x as number, y as enumeration } from "./validate-BxA3a-ns.cjs";
|
|
3
|
+
import { a as isEnvVarSchema, i as EnvVarSchema, n as Preprocessor, r as PreprocessorToggle, t as BooleanMap } from "./BooleanMap-B2eIP3tZ.cjs";
|
|
4
|
+
import { t as EnvChannel } from "./EnvChannel-LMIRYvT1.cjs";
|
|
5
|
+
import { n as schema, t as s } from "./schema-DH4GiW9A.cjs";
|
|
6
|
+
export { BooleanEnvVarSchema, BooleanEnvVarSchemaInput, BooleanMap, BooleanMap as BooleanPreprocessorOptions, Check, EnumEnvVarSchema, EnumEnvVarSchemaInput, EnvChannel, EnvVarSchema, EnvVarSchemaBase, EnvVarSchemaDetails, EnvVarSchemaInput, EnvVarType, NumberEnvVarSchema, NumberEnvVarSchemaInput, Preprocessor, PreprocessorToggle, PreprocessorOptions as Preprocessors, Processor, StringEnvVarSchema, StringEnvVarSchemaInput, between, boolean, custom, enumeration, exactLength, integer, isEnvVarSchema, lengthBetween, max, maxLength, min, minLength, number, oneOf, pattern, preprocessors, processors, resolvePreprocessor, s, schema, string, toList, url, validate };
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { a as EnumEnvVarSchema, c as BooleanEnvVarSchemaInput, d as EnvVarType, f as Processor, i as NumberEnvVarSchemaInput, l as EnvVarSchemaBase, n as StringEnvVarSchemaInput, o as EnumEnvVarSchemaInput, r as NumberEnvVarSchema, s as BooleanEnvVarSchema, t as StringEnvVarSchema, u as EnvVarSchemaInput } from "./StringEnvVarSchema-B8MT7htU.js";
|
|
2
|
+
import { C as Check, S as string, _ as preprocessors, a as max, b as boolean, c as oneOf, d as exactLength, f as lengthBetween, g as PreprocessorOptions, h as resolvePreprocessor, i as between, l as url, m as minLength, n as toList, o as min, p as maxLength, r as custom, s as integer, t as validate, u as pattern, v as processors, w as EnvVarSchemaDetails, x as number, y as enumeration } from "./validate-CyxrRacF.js";
|
|
3
|
+
import { a as isEnvVarSchema, i as EnvVarSchema, n as Preprocessor, r as PreprocessorToggle, t as BooleanMap } from "./BooleanMap-DmFnCA-O.js";
|
|
4
|
+
import { t as EnvChannel } from "./EnvChannel-w27PEm7x.js";
|
|
5
|
+
import { n as schema, t as s } from "./schema-jN4EtvEP.js";
|
|
6
|
+
export { BooleanEnvVarSchema, BooleanEnvVarSchemaInput, BooleanMap, BooleanMap as BooleanPreprocessorOptions, Check, EnumEnvVarSchema, EnumEnvVarSchemaInput, EnvChannel, EnvVarSchema, EnvVarSchemaBase, EnvVarSchemaDetails, EnvVarSchemaInput, EnvVarType, NumberEnvVarSchema, NumberEnvVarSchemaInput, Preprocessor, PreprocessorToggle, PreprocessorOptions as Preprocessors, Processor, StringEnvVarSchema, StringEnvVarSchemaInput, between, boolean, custom, enumeration, exactLength, integer, isEnvVarSchema, lengthBetween, max, maxLength, min, minLength, number, oneOf, pattern, preprocessors, processors, resolvePreprocessor, s, schema, string, toList, url, validate };
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { _ as EnvVarSchemaBase, a as isEnvVarSchema, c as EnumEnvVarSchema, d as enumeration, f as boolean, g as toList, h as validate, i as preprocessors, l as BooleanEnvVarSchema, m as string, n as schema, o as StringEnvVarSchema, p as number, r as resolvePreprocessor, s as NumberEnvVarSchema, t as s, u as processors } from "./src-CLTURaoo.js";
|
|
2
|
+
import { a as url, c as lengthBetween, i as oneOf, l as minLength, n as between, o as pattern, r as integer, s as exactLength, t as custom } from "./custom-Bt_wnxIu.js";
|
|
3
|
+
|
|
4
|
+
//#region ../core/src/processing/checks/maxLength.ts
|
|
5
|
+
/**
|
|
6
|
+
* String check: maximum length.
|
|
7
|
+
*/
|
|
8
|
+
function maxLength(max$1, trait) {
|
|
9
|
+
return (value) => {
|
|
10
|
+
if (value.length > max$1) return trait ? [trait] : [`at most ${max$1} characters`];
|
|
11
|
+
return [];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../core/src/processing/checks/min.ts
|
|
17
|
+
/**
|
|
18
|
+
* Number check: minimum value.
|
|
19
|
+
*/
|
|
20
|
+
function min(minimum, trait) {
|
|
21
|
+
return (value) => {
|
|
22
|
+
if (value < minimum) return trait ? [trait] : [`at least ${minimum}`];
|
|
23
|
+
return [];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region ../core/src/processing/checks/max.ts
|
|
29
|
+
/**
|
|
30
|
+
* Number check: maximum value.
|
|
31
|
+
*/
|
|
32
|
+
function max(maximum, trait) {
|
|
33
|
+
return (value) => {
|
|
34
|
+
if (value > maximum) return trait ? [trait] : [`at most ${maximum}`];
|
|
35
|
+
return [];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { BooleanEnvVarSchema, EnumEnvVarSchema, EnvVarSchemaBase, NumberEnvVarSchema, StringEnvVarSchema, between, boolean, custom, enumeration, exactLength, integer, isEnvVarSchema, lengthBetween, max, maxLength, min, minLength, number, oneOf, pattern, preprocessors, processors, resolvePreprocessor, s, schema, string, toList, url, validate };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
//#region ../core/src/processing/checks/minLength.ts
|
|
2
|
+
/**
|
|
3
|
+
* String check: minimum length.
|
|
4
|
+
*/
|
|
5
|
+
function minLength(min, trait) {
|
|
6
|
+
return (value) => {
|
|
7
|
+
if (value.length < min) return trait ? [trait] : [`at least ${min} characters`];
|
|
8
|
+
return [];
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../core/src/processing/checks/lengthBetween.ts
|
|
14
|
+
/**
|
|
15
|
+
* String check: length within a range.
|
|
16
|
+
*/
|
|
17
|
+
function lengthBetween(min, max, trait) {
|
|
18
|
+
return (value) => {
|
|
19
|
+
if (value.length < min || value.length > max) return trait ? [trait] : [`between ${min} and ${max} characters`];
|
|
20
|
+
return [];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region ../core/src/processing/checks/exactLength.ts
|
|
26
|
+
/**
|
|
27
|
+
* String check: exact length.
|
|
28
|
+
*/
|
|
29
|
+
function exactLength(length, trait) {
|
|
30
|
+
return (value) => {
|
|
31
|
+
if (value.length !== length) return trait ? [trait] : [`exactly ${length} characters`];
|
|
32
|
+
return [];
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region ../core/src/processing/checks/pattern.ts
|
|
38
|
+
/**
|
|
39
|
+
* String check: regex pattern match.
|
|
40
|
+
*/
|
|
41
|
+
function pattern(regex, trait) {
|
|
42
|
+
return (value) => {
|
|
43
|
+
if (!regex.test(value)) return Array.isArray(trait) ? [...trait] : [trait];
|
|
44
|
+
return [];
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region ../core/src/processing/checks/url.ts
|
|
50
|
+
/**
|
|
51
|
+
* String check: valid URL.
|
|
52
|
+
*/
|
|
53
|
+
function url(trait) {
|
|
54
|
+
return (value) => {
|
|
55
|
+
try {
|
|
56
|
+
new URL(value);
|
|
57
|
+
return [];
|
|
58
|
+
} catch {
|
|
59
|
+
return trait ? [trait] : ["a valid URL"];
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region ../core/src/processing/checks/oneOf.ts
|
|
66
|
+
/**
|
|
67
|
+
* String check: value must be one of the provided values.
|
|
68
|
+
*/
|
|
69
|
+
function oneOf(values, trait) {
|
|
70
|
+
return (value) => {
|
|
71
|
+
if (!values.includes(value)) return trait ? [trait] : [`one of: ${values.join(", ")}`];
|
|
72
|
+
return [];
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region ../core/src/processing/checks/integer.ts
|
|
78
|
+
/**
|
|
79
|
+
* Number check: must be an integer.
|
|
80
|
+
*/
|
|
81
|
+
function integer(trait) {
|
|
82
|
+
return (value) => {
|
|
83
|
+
if (!Number.isInteger(value)) return trait ? [trait] : ["an integer"];
|
|
84
|
+
return [];
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region ../core/src/processing/checks/between.ts
|
|
90
|
+
/**
|
|
91
|
+
* Number check: value within a range.
|
|
92
|
+
*/
|
|
93
|
+
function between(minimum, maximum, trait) {
|
|
94
|
+
return (value) => {
|
|
95
|
+
if (value < minimum || value > maximum) return trait ? [trait] : [`between ${minimum} and ${maximum}`];
|
|
96
|
+
return [];
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region ../core/src/processing/checks/custom.ts
|
|
102
|
+
/**
|
|
103
|
+
* Custom check with user-defined validation function.
|
|
104
|
+
* Can return multiple traits.
|
|
105
|
+
*/
|
|
106
|
+
function custom(fn, ...traits) {
|
|
107
|
+
return (value) => {
|
|
108
|
+
if (!fn(value)) return traits;
|
|
109
|
+
return [];
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { url as a, lengthBetween as c, oneOf as i, minLength as l, between as n, pattern as o, integer as r, exactLength as s, custom as t };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../core/src/processing/checks/minLength.ts
|
|
3
|
+
/**
|
|
4
|
+
* String check: minimum length.
|
|
5
|
+
*/
|
|
6
|
+
function minLength(min, trait) {
|
|
7
|
+
return (value) => {
|
|
8
|
+
if (value.length < min) return trait ? [trait] : [`at least ${min} characters`];
|
|
9
|
+
return [];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region ../core/src/processing/checks/lengthBetween.ts
|
|
15
|
+
/**
|
|
16
|
+
* String check: length within a range.
|
|
17
|
+
*/
|
|
18
|
+
function lengthBetween(min, max, trait) {
|
|
19
|
+
return (value) => {
|
|
20
|
+
if (value.length < min || value.length > max) return trait ? [trait] : [`between ${min} and ${max} characters`];
|
|
21
|
+
return [];
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region ../core/src/processing/checks/exactLength.ts
|
|
27
|
+
/**
|
|
28
|
+
* String check: exact length.
|
|
29
|
+
*/
|
|
30
|
+
function exactLength(length, trait) {
|
|
31
|
+
return (value) => {
|
|
32
|
+
if (value.length !== length) return trait ? [trait] : [`exactly ${length} characters`];
|
|
33
|
+
return [];
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region ../core/src/processing/checks/pattern.ts
|
|
39
|
+
/**
|
|
40
|
+
* String check: regex pattern match.
|
|
41
|
+
*/
|
|
42
|
+
function pattern(regex, trait) {
|
|
43
|
+
return (value) => {
|
|
44
|
+
if (!regex.test(value)) return Array.isArray(trait) ? [...trait] : [trait];
|
|
45
|
+
return [];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region ../core/src/processing/checks/url.ts
|
|
51
|
+
/**
|
|
52
|
+
* String check: valid URL.
|
|
53
|
+
*/
|
|
54
|
+
function url(trait) {
|
|
55
|
+
return (value) => {
|
|
56
|
+
try {
|
|
57
|
+
new URL(value);
|
|
58
|
+
return [];
|
|
59
|
+
} catch {
|
|
60
|
+
return trait ? [trait] : ["a valid URL"];
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region ../core/src/processing/checks/oneOf.ts
|
|
67
|
+
/**
|
|
68
|
+
* String check: value must be one of the provided values.
|
|
69
|
+
*/
|
|
70
|
+
function oneOf(values, trait) {
|
|
71
|
+
return (value) => {
|
|
72
|
+
if (!values.includes(value)) return trait ? [trait] : [`one of: ${values.join(", ")}`];
|
|
73
|
+
return [];
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region ../core/src/processing/checks/integer.ts
|
|
79
|
+
/**
|
|
80
|
+
* Number check: must be an integer.
|
|
81
|
+
*/
|
|
82
|
+
function integer(trait) {
|
|
83
|
+
return (value) => {
|
|
84
|
+
if (!Number.isInteger(value)) return trait ? [trait] : ["an integer"];
|
|
85
|
+
return [];
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region ../core/src/processing/checks/between.ts
|
|
91
|
+
/**
|
|
92
|
+
* Number check: value within a range.
|
|
93
|
+
*/
|
|
94
|
+
function between(minimum, maximum, trait) {
|
|
95
|
+
return (value) => {
|
|
96
|
+
if (value < minimum || value > maximum) return trait ? [trait] : [`between ${minimum} and ${maximum}`];
|
|
97
|
+
return [];
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region ../core/src/processing/checks/custom.ts
|
|
103
|
+
/**
|
|
104
|
+
* Custom check with user-defined validation function.
|
|
105
|
+
* Can return multiple traits.
|
|
106
|
+
*/
|
|
107
|
+
function custom(fn, ...traits) {
|
|
108
|
+
return (value) => {
|
|
109
|
+
if (!fn(value)) return traits;
|
|
110
|
+
return [];
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
Object.defineProperty(exports, 'between', {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return between;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(exports, 'custom', {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function () {
|
|
124
|
+
return custom;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
Object.defineProperty(exports, 'exactLength', {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
get: function () {
|
|
130
|
+
return exactLength;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(exports, 'integer', {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function () {
|
|
136
|
+
return integer;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(exports, 'lengthBetween', {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function () {
|
|
142
|
+
return lengthBetween;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(exports, 'minLength', {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function () {
|
|
148
|
+
return minLength;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(exports, 'oneOf', {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
get: function () {
|
|
154
|
+
return oneOf;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
Object.defineProperty(exports, 'pattern', {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
get: function () {
|
|
160
|
+
return pattern;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
Object.defineProperty(exports, 'url', {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function () {
|
|
166
|
+
return url;
|
|
167
|
+
}
|
|
168
|
+
});
|
package/dist/files.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_EnvSource = require('./EnvSource-BVnmdHku.cjs');
|
|
3
|
+
|
|
4
|
+
//#region ../files/src/source.ts
|
|
5
|
+
function source(filePath) {
|
|
6
|
+
return new require_EnvSource.EnvSource(filePath);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/files.ts
|
|
11
|
+
var files_default = source;
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.EnvSource = require_EnvSource.EnvSource;
|
|
15
|
+
exports.default = files_default;
|
|
16
|
+
exports.get = require_EnvSource.get;
|
|
17
|
+
exports.set = require_EnvSource.set;
|
|
18
|
+
exports.source = source;
|
package/dist/files.d.cts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region ../files/src/types.d.ts
|
|
2
|
+
type EnvRecord = Record<string, string>;
|
|
3
|
+
type EnvSelectionRecord<T extends readonly string[]> = { [K in T[number]]: string | undefined };
|
|
4
|
+
type EnvPrimitiveValue = string | number | boolean | bigint;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region ../files/src/EnvSource.d.ts
|
|
7
|
+
declare class EnvSource {
|
|
8
|
+
private readonly filePath;
|
|
9
|
+
constructor(filePath: string);
|
|
10
|
+
readSync(): EnvRecord;
|
|
11
|
+
readSync(name: string): string | undefined;
|
|
12
|
+
readSync<const Names extends readonly string[]>(names: Names): EnvSelectionRecord<Names>;
|
|
13
|
+
read(): Promise<EnvRecord>;
|
|
14
|
+
read(name: string): Promise<string | undefined>;
|
|
15
|
+
read<const Names extends readonly string[]>(names: Names): Promise<EnvSelectionRecord<Names>>;
|
|
16
|
+
writeSync(name: string, value: EnvPrimitiveValue): void;
|
|
17
|
+
writeSync(values: Record<string, EnvPrimitiveValue>): void;
|
|
18
|
+
write(name: string, value: EnvPrimitiveValue): Promise<void>;
|
|
19
|
+
write(values: Record<string, EnvPrimitiveValue>): Promise<void>;
|
|
20
|
+
private readContentSync;
|
|
21
|
+
private readContent;
|
|
22
|
+
private ensureDirectorySync;
|
|
23
|
+
private ensureDirectory;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region ../files/src/get.d.ts
|
|
27
|
+
declare function get(content: string): EnvRecord;
|
|
28
|
+
declare function get(content: string, name: string): string | undefined;
|
|
29
|
+
declare function get<const Names extends readonly string[]>(content: string, names: Names): EnvSelectionRecord<Names>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region ../files/src/set.d.ts
|
|
32
|
+
declare function set(content: string, name: string, value: EnvPrimitiveValue): string;
|
|
33
|
+
declare function set(content: string, values: Record<string, EnvPrimitiveValue>): string;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region ../files/src/source.d.ts
|
|
36
|
+
declare function source(filePath: string): EnvSource;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { EnvPrimitiveValue, EnvRecord, EnvSelectionRecord, EnvSource, source as default, source, get, set };
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region ../files/src/types.d.ts
|
|
2
|
+
type EnvRecord = Record<string, string>;
|
|
3
|
+
type EnvSelectionRecord<T extends readonly string[]> = { [K in T[number]]: string | undefined };
|
|
4
|
+
type EnvPrimitiveValue = string | number | boolean | bigint;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region ../files/src/EnvSource.d.ts
|
|
7
|
+
declare class EnvSource {
|
|
8
|
+
private readonly filePath;
|
|
9
|
+
constructor(filePath: string);
|
|
10
|
+
readSync(): EnvRecord;
|
|
11
|
+
readSync(name: string): string | undefined;
|
|
12
|
+
readSync<const Names extends readonly string[]>(names: Names): EnvSelectionRecord<Names>;
|
|
13
|
+
read(): Promise<EnvRecord>;
|
|
14
|
+
read(name: string): Promise<string | undefined>;
|
|
15
|
+
read<const Names extends readonly string[]>(names: Names): Promise<EnvSelectionRecord<Names>>;
|
|
16
|
+
writeSync(name: string, value: EnvPrimitiveValue): void;
|
|
17
|
+
writeSync(values: Record<string, EnvPrimitiveValue>): void;
|
|
18
|
+
write(name: string, value: EnvPrimitiveValue): Promise<void>;
|
|
19
|
+
write(values: Record<string, EnvPrimitiveValue>): Promise<void>;
|
|
20
|
+
private readContentSync;
|
|
21
|
+
private readContent;
|
|
22
|
+
private ensureDirectorySync;
|
|
23
|
+
private ensureDirectory;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region ../files/src/get.d.ts
|
|
27
|
+
declare function get(content: string): EnvRecord;
|
|
28
|
+
declare function get(content: string, name: string): string | undefined;
|
|
29
|
+
declare function get<const Names extends readonly string[]>(content: string, names: Names): EnvSelectionRecord<Names>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region ../files/src/set.d.ts
|
|
32
|
+
declare function set(content: string, name: string, value: EnvPrimitiveValue): string;
|
|
33
|
+
declare function set(content: string, values: Record<string, EnvPrimitiveValue>): string;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region ../files/src/source.d.ts
|
|
36
|
+
declare function source(filePath: string): EnvSource;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { EnvPrimitiveValue, EnvRecord, EnvSelectionRecord, EnvSource, source as default, source, get, set };
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { n as set, r as get, t as EnvSource } from "./EnvSource-DA3ZGlES.js";
|
|
2
|
+
|
|
3
|
+
//#region ../files/src/source.ts
|
|
4
|
+
function source(filePath) {
|
|
5
|
+
return new EnvSource(filePath);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/files.ts
|
|
10
|
+
var files_default = source;
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { EnvSource, files_default as default, get, set, source };
|