node-env-resolver 6.4.0 → 6.5.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.
- package/README.md +73 -0
- package/binding.gyp +9 -0
- package/dist/builder.cjs +1 -1
- package/dist/builder.js +1 -1
- package/dist/chunk-2IQQVAXA.cjs +9 -0
- package/dist/chunk-46CBATKM.js +1 -0
- package/dist/{chunk-4TODB2KY.js → chunk-C34FGZOG.js} +1 -1
- package/dist/chunk-FNF55TN4.cjs +1 -0
- package/dist/chunk-G36OESVW.cjs +1 -0
- package/dist/chunk-I5UKYTX6.js +1 -0
- package/dist/chunk-MFFH2ZXS.js +17 -0
- package/dist/chunk-QCKMQEJP.cjs +17 -0
- package/dist/{chunk-OX54K5J5.cjs → chunk-S7AB6UX7.cjs} +3 -3
- package/dist/chunk-TGIYWWDY.js +9 -0
- package/dist/chunk-VUUPIWFJ.js +9 -0
- package/dist/chunk-ZDRU3RSU.cjs +9 -0
- package/dist/cli-main.cjs +4 -0
- package/dist/cli-main.d.cts +1 -0
- package/dist/cli-main.d.ts +1 -0
- package/dist/cli-main.js +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/redaction.cjs +1 -0
- package/dist/redaction.d.cts +54 -0
- package/dist/redaction.d.ts +54 -0
- package/dist/redaction.js +1 -0
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.js +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.cts +26 -1
- package/dist/resolvers.d.ts +26 -1
- package/dist/resolvers.js +1 -1
- package/dist/typegen.cjs +1 -0
- package/dist/typegen.d.cts +52 -0
- package/dist/typegen.d.ts +52 -0
- package/dist/typegen.js +1 -0
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +16 -2
- package/dist/types.d.ts +16 -2
- package/dist/types.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.cts +12 -2
- package/dist/utils.d.ts +12 -2
- package/dist/utils.js +1 -1
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.js +1 -1
- package/dist/validators.cjs +2 -2
- package/dist/validators.d.cts +47 -24
- package/dist/validators.d.ts +47 -24
- package/dist/validators.js +2 -2
- package/dist/web.cjs +3 -3
- package/dist/web.js +1 -1
- package/dist/zod.cjs +1 -1
- package/dist/zod.js +1 -1
- package/index.js +1 -0
- package/package.json +31 -7
- package/dist/chunk-4KFQR5TJ.js +0 -9
- package/dist/chunk-6D5APQIG.cjs +0 -1
- package/dist/chunk-DCAD54W2.js +0 -15
- package/dist/chunk-GMN7ADP3.cjs +0 -9
- package/dist/chunk-HHOS5S5T.js +0 -1
- package/dist/chunk-UQW24J5O.cjs +0 -15
package/dist/validators.d.cts
CHANGED
|
@@ -8,6 +8,11 @@ import { Validator } from './types.cjs';
|
|
|
8
8
|
* 'postgres', 'mysql', 'mongodb', 'redis', 'http', 'https', 'url', 'email', 'port', 'json', 'date', 'timestamp'
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
/** Common options shared by all validator factories */
|
|
12
|
+
interface BaseValidatorOpts {
|
|
13
|
+
sensitive?: boolean;
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
11
16
|
/**
|
|
12
17
|
* Result of a validation operation
|
|
13
18
|
*/
|
|
@@ -136,7 +141,7 @@ declare function validateFile(value: string, key?: string): ValidationResult;
|
|
|
136
141
|
declare function http<Opts extends {
|
|
137
142
|
default?: string;
|
|
138
143
|
optional?: boolean;
|
|
139
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
144
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
140
145
|
optional: true;
|
|
141
146
|
} ? Validator<string> & {
|
|
142
147
|
optional: true;
|
|
@@ -155,7 +160,7 @@ declare function http<Opts extends {
|
|
|
155
160
|
declare function json<Opts extends {
|
|
156
161
|
default?: unknown;
|
|
157
162
|
optional?: boolean;
|
|
158
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
163
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
159
164
|
optional: true;
|
|
160
165
|
} ? Validator<unknown> & {
|
|
161
166
|
optional: true;
|
|
@@ -194,7 +199,7 @@ declare function string<Opts extends {
|
|
|
194
199
|
allowEmpty?: boolean;
|
|
195
200
|
/** Regex pattern to validate against */
|
|
196
201
|
pattern?: string;
|
|
197
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
202
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
198
203
|
optional: true;
|
|
199
204
|
} ? Validator<string> & {
|
|
200
205
|
optional: true;
|
|
@@ -229,7 +234,7 @@ declare function number<Opts extends {
|
|
|
229
234
|
min?: number;
|
|
230
235
|
/** Maximum number value */
|
|
231
236
|
max?: number;
|
|
232
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
237
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
233
238
|
optional: true;
|
|
234
239
|
} ? Validator<number> & {
|
|
235
240
|
optional: true;
|
|
@@ -261,7 +266,7 @@ declare function boolean<Opts extends {
|
|
|
261
266
|
default?: boolean;
|
|
262
267
|
/** Make the field optional */
|
|
263
268
|
optional?: boolean;
|
|
264
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
269
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
265
270
|
optional: true;
|
|
266
271
|
} ? Validator<boolean> & {
|
|
267
272
|
optional: true;
|
|
@@ -292,7 +297,7 @@ declare function url<Opts extends {
|
|
|
292
297
|
default?: string;
|
|
293
298
|
/** Make the field optional */
|
|
294
299
|
optional?: boolean;
|
|
295
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
300
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
296
301
|
optional: true;
|
|
297
302
|
} ? Validator<string> & {
|
|
298
303
|
optional: true;
|
|
@@ -323,7 +328,7 @@ declare function email<Opts extends {
|
|
|
323
328
|
default?: string;
|
|
324
329
|
/** Make the field optional */
|
|
325
330
|
optional?: boolean;
|
|
326
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
331
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
327
332
|
optional: true;
|
|
328
333
|
} ? Validator<string> & {
|
|
329
334
|
optional: true;
|
|
@@ -354,7 +359,7 @@ declare function port<Opts extends {
|
|
|
354
359
|
default?: number;
|
|
355
360
|
/** Make the field optional */
|
|
356
361
|
optional?: boolean;
|
|
357
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
362
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
358
363
|
optional: true;
|
|
359
364
|
} ? Validator<number> & {
|
|
360
365
|
optional: true;
|
|
@@ -386,7 +391,7 @@ declare function postgres<Opts extends {
|
|
|
386
391
|
default?: string;
|
|
387
392
|
/** Make the field optional */
|
|
388
393
|
optional?: boolean;
|
|
389
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
394
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
390
395
|
optional: true;
|
|
391
396
|
} ? Validator<string> & {
|
|
392
397
|
optional: true;
|
|
@@ -418,7 +423,7 @@ declare function mysql<Opts extends {
|
|
|
418
423
|
default?: string;
|
|
419
424
|
/** Make the field optional */
|
|
420
425
|
optional?: boolean;
|
|
421
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
426
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
422
427
|
optional: true;
|
|
423
428
|
} ? Validator<string> & {
|
|
424
429
|
optional: true;
|
|
@@ -450,7 +455,7 @@ declare function mongodb<Opts extends {
|
|
|
450
455
|
default?: string;
|
|
451
456
|
/** Make the field optional */
|
|
452
457
|
optional?: boolean;
|
|
453
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
458
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
454
459
|
optional: true;
|
|
455
460
|
} ? Validator<string> & {
|
|
456
461
|
optional: true;
|
|
@@ -482,7 +487,7 @@ declare function redis<Opts extends {
|
|
|
482
487
|
default?: string;
|
|
483
488
|
/** Make the field optional */
|
|
484
489
|
optional?: boolean;
|
|
485
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
490
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
486
491
|
optional: true;
|
|
487
492
|
} ? Validator<string> & {
|
|
488
493
|
optional: true;
|
|
@@ -514,7 +519,7 @@ declare function https<Opts extends {
|
|
|
514
519
|
default?: string;
|
|
515
520
|
/** Make the field optional */
|
|
516
521
|
optional?: boolean;
|
|
517
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
522
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
518
523
|
optional: true;
|
|
519
524
|
} ? Validator<string> & {
|
|
520
525
|
optional: true;
|
|
@@ -548,7 +553,7 @@ declare function stringArray<Opts extends {
|
|
|
548
553
|
optional?: boolean;
|
|
549
554
|
/** Separator character (default: ',') */
|
|
550
555
|
separator?: string;
|
|
551
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
556
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
552
557
|
optional: true;
|
|
553
558
|
} ? Validator<string[]> & {
|
|
554
559
|
optional: true;
|
|
@@ -582,7 +587,7 @@ declare function numberArray<Opts extends {
|
|
|
582
587
|
optional?: boolean;
|
|
583
588
|
/** Separator character (default: ',') */
|
|
584
589
|
separator?: string;
|
|
585
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
590
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
586
591
|
optional: true;
|
|
587
592
|
} ? Validator<number[]> & {
|
|
588
593
|
optional: true;
|
|
@@ -616,7 +621,7 @@ declare function urlArray<Opts extends {
|
|
|
616
621
|
optional?: boolean;
|
|
617
622
|
/** Separator character (default: ',') */
|
|
618
623
|
separator?: string;
|
|
619
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
624
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
620
625
|
optional: true;
|
|
621
626
|
} ? Validator<string[]> & {
|
|
622
627
|
optional: true;
|
|
@@ -649,7 +654,7 @@ declare function oneOf<T extends readonly (string | number)[], Opts extends {
|
|
|
649
654
|
default?: T[number];
|
|
650
655
|
/** Make the field optional */
|
|
651
656
|
optional?: boolean;
|
|
652
|
-
} = Record<string, never>>(values: T, opts?: Opts): Opts extends {
|
|
657
|
+
} & BaseValidatorOpts = Record<string, never>>(values: T, opts?: Opts): Opts extends {
|
|
653
658
|
optional: true;
|
|
654
659
|
} ? Validator<T[number]> & {
|
|
655
660
|
optional: true;
|
|
@@ -745,7 +750,7 @@ declare function duration<Opts extends {
|
|
|
745
750
|
default?: number;
|
|
746
751
|
/** Make the field optional */
|
|
747
752
|
optional?: boolean;
|
|
748
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
753
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
749
754
|
optional: true;
|
|
750
755
|
} ? Validator<number> & {
|
|
751
756
|
optional: true;
|
|
@@ -779,7 +784,7 @@ declare function file<Opts extends {
|
|
|
779
784
|
optional?: boolean;
|
|
780
785
|
/** Base directory for secrets (Docker/K8s) */
|
|
781
786
|
secretsDir?: string;
|
|
782
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
787
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
783
788
|
optional: true;
|
|
784
789
|
} ? Validator<string> & {
|
|
785
790
|
optional: true;
|
|
@@ -813,7 +818,7 @@ declare function secret<Opts extends {
|
|
|
813
818
|
default?: string;
|
|
814
819
|
/** Make the field optional */
|
|
815
820
|
optional?: boolean;
|
|
816
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
821
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
817
822
|
optional: true;
|
|
818
823
|
} ? Validator<string> & {
|
|
819
824
|
optional: true;
|
|
@@ -856,7 +861,7 @@ declare function custom<T = unknown, Opts extends {
|
|
|
856
861
|
default?: T;
|
|
857
862
|
/** Make the field optional */
|
|
858
863
|
optional?: boolean;
|
|
859
|
-
} = Record<string, never>>(validator: (value: string) => T, opts?: Opts): Opts extends {
|
|
864
|
+
} & BaseValidatorOpts = Record<string, never>>(validator: (value: string) => T, opts?: Opts): Opts extends {
|
|
860
865
|
optional: true;
|
|
861
866
|
} ? Validator<T> & {
|
|
862
867
|
optional: true;
|
|
@@ -888,7 +893,7 @@ declare function date<Opts extends {
|
|
|
888
893
|
default?: string;
|
|
889
894
|
/** Make the field optional */
|
|
890
895
|
optional?: boolean;
|
|
891
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
896
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
892
897
|
optional: true;
|
|
893
898
|
} ? Validator<string> & {
|
|
894
899
|
optional: true;
|
|
@@ -920,7 +925,7 @@ declare function timestamp<Opts extends {
|
|
|
920
925
|
default?: number;
|
|
921
926
|
/** Make the field optional */
|
|
922
927
|
optional?: boolean;
|
|
923
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
928
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
924
929
|
optional: true;
|
|
925
930
|
} ? Validator<number> & {
|
|
926
931
|
optional: true;
|
|
@@ -929,5 +934,23 @@ declare function timestamp<Opts extends {
|
|
|
929
934
|
optional?: Opts['optional'];
|
|
930
935
|
default?: Opts['default'];
|
|
931
936
|
};
|
|
937
|
+
/**
|
|
938
|
+
* Non-mutating wrapper that marks a validator as sensitive.
|
|
939
|
+
* Creates a new validator that forwards to the original, preserving all metadata.
|
|
940
|
+
*
|
|
941
|
+
* @param validator - The validator to wrap
|
|
942
|
+
* @returns A new validator with sensitive: true in __meta
|
|
943
|
+
*
|
|
944
|
+
* @example
|
|
945
|
+
* ```ts
|
|
946
|
+
* import { string, sensitive } from 'node-env-resolver/validators';
|
|
947
|
+
*
|
|
948
|
+
* const config = resolve({
|
|
949
|
+
* API_KEY: sensitive(string()),
|
|
950
|
+
* DATABASE_URL: sensitive(postgres()),
|
|
951
|
+
* });
|
|
952
|
+
* ```
|
|
953
|
+
*/
|
|
954
|
+
declare function sensitive<T>(validator: Validator<T>): Validator<T>;
|
|
932
955
|
|
|
933
|
-
export { type ValidationResult, boolean, custom, date, duration, email, enumOf, file, http, https, json, mongodb, mysql, number, numberArray, oneOf, optional, port, postgres, redis, secret, string, stringArray, timestamp, url, urlArray, validateBoolean, validateDate, validateDuration, validateEmail, validateFile, validateMongodb, validateMysql, validateNumber, validatePort, validatePostgres, validateRedis, validateTimestamp, validateUrl };
|
|
956
|
+
export { type BaseValidatorOpts, type ValidationResult, boolean, custom, date, duration, email, enumOf, file, http, https, json, mongodb, mysql, number, numberArray, oneOf, optional, port, postgres, redis, secret, sensitive, string, stringArray, timestamp, url, urlArray, validateBoolean, validateDate, validateDuration, validateEmail, validateFile, validateMongodb, validateMysql, validateNumber, validatePort, validatePostgres, validateRedis, validateTimestamp, validateUrl };
|
package/dist/validators.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ import { Validator } from './types.js';
|
|
|
8
8
|
* 'postgres', 'mysql', 'mongodb', 'redis', 'http', 'https', 'url', 'email', 'port', 'json', 'date', 'timestamp'
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
/** Common options shared by all validator factories */
|
|
12
|
+
interface BaseValidatorOpts {
|
|
13
|
+
sensitive?: boolean;
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
11
16
|
/**
|
|
12
17
|
* Result of a validation operation
|
|
13
18
|
*/
|
|
@@ -136,7 +141,7 @@ declare function validateFile(value: string, key?: string): ValidationResult;
|
|
|
136
141
|
declare function http<Opts extends {
|
|
137
142
|
default?: string;
|
|
138
143
|
optional?: boolean;
|
|
139
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
144
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
140
145
|
optional: true;
|
|
141
146
|
} ? Validator<string> & {
|
|
142
147
|
optional: true;
|
|
@@ -155,7 +160,7 @@ declare function http<Opts extends {
|
|
|
155
160
|
declare function json<Opts extends {
|
|
156
161
|
default?: unknown;
|
|
157
162
|
optional?: boolean;
|
|
158
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
163
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
159
164
|
optional: true;
|
|
160
165
|
} ? Validator<unknown> & {
|
|
161
166
|
optional: true;
|
|
@@ -194,7 +199,7 @@ declare function string<Opts extends {
|
|
|
194
199
|
allowEmpty?: boolean;
|
|
195
200
|
/** Regex pattern to validate against */
|
|
196
201
|
pattern?: string;
|
|
197
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
202
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
198
203
|
optional: true;
|
|
199
204
|
} ? Validator<string> & {
|
|
200
205
|
optional: true;
|
|
@@ -229,7 +234,7 @@ declare function number<Opts extends {
|
|
|
229
234
|
min?: number;
|
|
230
235
|
/** Maximum number value */
|
|
231
236
|
max?: number;
|
|
232
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
237
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
233
238
|
optional: true;
|
|
234
239
|
} ? Validator<number> & {
|
|
235
240
|
optional: true;
|
|
@@ -261,7 +266,7 @@ declare function boolean<Opts extends {
|
|
|
261
266
|
default?: boolean;
|
|
262
267
|
/** Make the field optional */
|
|
263
268
|
optional?: boolean;
|
|
264
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
269
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
265
270
|
optional: true;
|
|
266
271
|
} ? Validator<boolean> & {
|
|
267
272
|
optional: true;
|
|
@@ -292,7 +297,7 @@ declare function url<Opts extends {
|
|
|
292
297
|
default?: string;
|
|
293
298
|
/** Make the field optional */
|
|
294
299
|
optional?: boolean;
|
|
295
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
300
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
296
301
|
optional: true;
|
|
297
302
|
} ? Validator<string> & {
|
|
298
303
|
optional: true;
|
|
@@ -323,7 +328,7 @@ declare function email<Opts extends {
|
|
|
323
328
|
default?: string;
|
|
324
329
|
/** Make the field optional */
|
|
325
330
|
optional?: boolean;
|
|
326
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
331
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
327
332
|
optional: true;
|
|
328
333
|
} ? Validator<string> & {
|
|
329
334
|
optional: true;
|
|
@@ -354,7 +359,7 @@ declare function port<Opts extends {
|
|
|
354
359
|
default?: number;
|
|
355
360
|
/** Make the field optional */
|
|
356
361
|
optional?: boolean;
|
|
357
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
362
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
358
363
|
optional: true;
|
|
359
364
|
} ? Validator<number> & {
|
|
360
365
|
optional: true;
|
|
@@ -386,7 +391,7 @@ declare function postgres<Opts extends {
|
|
|
386
391
|
default?: string;
|
|
387
392
|
/** Make the field optional */
|
|
388
393
|
optional?: boolean;
|
|
389
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
394
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
390
395
|
optional: true;
|
|
391
396
|
} ? Validator<string> & {
|
|
392
397
|
optional: true;
|
|
@@ -418,7 +423,7 @@ declare function mysql<Opts extends {
|
|
|
418
423
|
default?: string;
|
|
419
424
|
/** Make the field optional */
|
|
420
425
|
optional?: boolean;
|
|
421
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
426
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
422
427
|
optional: true;
|
|
423
428
|
} ? Validator<string> & {
|
|
424
429
|
optional: true;
|
|
@@ -450,7 +455,7 @@ declare function mongodb<Opts extends {
|
|
|
450
455
|
default?: string;
|
|
451
456
|
/** Make the field optional */
|
|
452
457
|
optional?: boolean;
|
|
453
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
458
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
454
459
|
optional: true;
|
|
455
460
|
} ? Validator<string> & {
|
|
456
461
|
optional: true;
|
|
@@ -482,7 +487,7 @@ declare function redis<Opts extends {
|
|
|
482
487
|
default?: string;
|
|
483
488
|
/** Make the field optional */
|
|
484
489
|
optional?: boolean;
|
|
485
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
490
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
486
491
|
optional: true;
|
|
487
492
|
} ? Validator<string> & {
|
|
488
493
|
optional: true;
|
|
@@ -514,7 +519,7 @@ declare function https<Opts extends {
|
|
|
514
519
|
default?: string;
|
|
515
520
|
/** Make the field optional */
|
|
516
521
|
optional?: boolean;
|
|
517
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
522
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
518
523
|
optional: true;
|
|
519
524
|
} ? Validator<string> & {
|
|
520
525
|
optional: true;
|
|
@@ -548,7 +553,7 @@ declare function stringArray<Opts extends {
|
|
|
548
553
|
optional?: boolean;
|
|
549
554
|
/** Separator character (default: ',') */
|
|
550
555
|
separator?: string;
|
|
551
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
556
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
552
557
|
optional: true;
|
|
553
558
|
} ? Validator<string[]> & {
|
|
554
559
|
optional: true;
|
|
@@ -582,7 +587,7 @@ declare function numberArray<Opts extends {
|
|
|
582
587
|
optional?: boolean;
|
|
583
588
|
/** Separator character (default: ',') */
|
|
584
589
|
separator?: string;
|
|
585
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
590
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
586
591
|
optional: true;
|
|
587
592
|
} ? Validator<number[]> & {
|
|
588
593
|
optional: true;
|
|
@@ -616,7 +621,7 @@ declare function urlArray<Opts extends {
|
|
|
616
621
|
optional?: boolean;
|
|
617
622
|
/** Separator character (default: ',') */
|
|
618
623
|
separator?: string;
|
|
619
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
624
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
620
625
|
optional: true;
|
|
621
626
|
} ? Validator<string[]> & {
|
|
622
627
|
optional: true;
|
|
@@ -649,7 +654,7 @@ declare function oneOf<T extends readonly (string | number)[], Opts extends {
|
|
|
649
654
|
default?: T[number];
|
|
650
655
|
/** Make the field optional */
|
|
651
656
|
optional?: boolean;
|
|
652
|
-
} = Record<string, never>>(values: T, opts?: Opts): Opts extends {
|
|
657
|
+
} & BaseValidatorOpts = Record<string, never>>(values: T, opts?: Opts): Opts extends {
|
|
653
658
|
optional: true;
|
|
654
659
|
} ? Validator<T[number]> & {
|
|
655
660
|
optional: true;
|
|
@@ -745,7 +750,7 @@ declare function duration<Opts extends {
|
|
|
745
750
|
default?: number;
|
|
746
751
|
/** Make the field optional */
|
|
747
752
|
optional?: boolean;
|
|
748
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
753
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
749
754
|
optional: true;
|
|
750
755
|
} ? Validator<number> & {
|
|
751
756
|
optional: true;
|
|
@@ -779,7 +784,7 @@ declare function file<Opts extends {
|
|
|
779
784
|
optional?: boolean;
|
|
780
785
|
/** Base directory for secrets (Docker/K8s) */
|
|
781
786
|
secretsDir?: string;
|
|
782
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
787
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
783
788
|
optional: true;
|
|
784
789
|
} ? Validator<string> & {
|
|
785
790
|
optional: true;
|
|
@@ -813,7 +818,7 @@ declare function secret<Opts extends {
|
|
|
813
818
|
default?: string;
|
|
814
819
|
/** Make the field optional */
|
|
815
820
|
optional?: boolean;
|
|
816
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
821
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
817
822
|
optional: true;
|
|
818
823
|
} ? Validator<string> & {
|
|
819
824
|
optional: true;
|
|
@@ -856,7 +861,7 @@ declare function custom<T = unknown, Opts extends {
|
|
|
856
861
|
default?: T;
|
|
857
862
|
/** Make the field optional */
|
|
858
863
|
optional?: boolean;
|
|
859
|
-
} = Record<string, never>>(validator: (value: string) => T, opts?: Opts): Opts extends {
|
|
864
|
+
} & BaseValidatorOpts = Record<string, never>>(validator: (value: string) => T, opts?: Opts): Opts extends {
|
|
860
865
|
optional: true;
|
|
861
866
|
} ? Validator<T> & {
|
|
862
867
|
optional: true;
|
|
@@ -888,7 +893,7 @@ declare function date<Opts extends {
|
|
|
888
893
|
default?: string;
|
|
889
894
|
/** Make the field optional */
|
|
890
895
|
optional?: boolean;
|
|
891
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
896
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
892
897
|
optional: true;
|
|
893
898
|
} ? Validator<string> & {
|
|
894
899
|
optional: true;
|
|
@@ -920,7 +925,7 @@ declare function timestamp<Opts extends {
|
|
|
920
925
|
default?: number;
|
|
921
926
|
/** Make the field optional */
|
|
922
927
|
optional?: boolean;
|
|
923
|
-
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
928
|
+
} & BaseValidatorOpts = Record<string, never>>(opts?: Opts): Opts extends {
|
|
924
929
|
optional: true;
|
|
925
930
|
} ? Validator<number> & {
|
|
926
931
|
optional: true;
|
|
@@ -929,5 +934,23 @@ declare function timestamp<Opts extends {
|
|
|
929
934
|
optional?: Opts['optional'];
|
|
930
935
|
default?: Opts['default'];
|
|
931
936
|
};
|
|
937
|
+
/**
|
|
938
|
+
* Non-mutating wrapper that marks a validator as sensitive.
|
|
939
|
+
* Creates a new validator that forwards to the original, preserving all metadata.
|
|
940
|
+
*
|
|
941
|
+
* @param validator - The validator to wrap
|
|
942
|
+
* @returns A new validator with sensitive: true in __meta
|
|
943
|
+
*
|
|
944
|
+
* @example
|
|
945
|
+
* ```ts
|
|
946
|
+
* import { string, sensitive } from 'node-env-resolver/validators';
|
|
947
|
+
*
|
|
948
|
+
* const config = resolve({
|
|
949
|
+
* API_KEY: sensitive(string()),
|
|
950
|
+
* DATABASE_URL: sensitive(postgres()),
|
|
951
|
+
* });
|
|
952
|
+
* ```
|
|
953
|
+
*/
|
|
954
|
+
declare function sensitive<T>(validator: Validator<T>): Validator<T>;
|
|
932
955
|
|
|
933
|
-
export { type ValidationResult, boolean, custom, date, duration, email, enumOf, file, http, https, json, mongodb, mysql, number, numberArray, oneOf, optional, port, postgres, redis, secret, string, stringArray, timestamp, url, urlArray, validateBoolean, validateDate, validateDuration, validateEmail, validateFile, validateMongodb, validateMysql, validateNumber, validatePort, validatePostgres, validateRedis, validateTimestamp, validateUrl };
|
|
956
|
+
export { type BaseValidatorOpts, type ValidationResult, boolean, custom, date, duration, email, enumOf, file, http, https, json, mongodb, mysql, number, numberArray, oneOf, optional, port, postgres, redis, secret, sensitive, string, stringArray, timestamp, url, urlArray, validateBoolean, validateDate, validateDuration, validateEmail, validateFile, validateMongodb, validateMysql, validateNumber, validatePort, validatePostgres, validateRedis, validateTimestamp, validateUrl };
|
package/dist/validators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a}from'./chunk-I7AUKTXE.js';function
|
|
2
|
-
export{
|
|
1
|
+
import {a}from'./chunk-I7AUKTXE.js';function i(t,n,r,e){let a={type:n};r?.sensitive!==void 0&&(a.sensitive=r.sensitive),r?.description!==void 0&&(a.description=r.description),e&&Object.assign(a,e),t.__meta=a;}function p(t){if(!/^postgres(ql)?:\/\/.+/.test(t))return {valid:false,error:"Invalid PostgreSQL URL"};try{return new URL(t),{valid:!0}}catch{return {valid:false,error:"Invalid PostgreSQL URL"}}}function f(t){if(!/^mysql:\/\/.+/.test(t))return {valid:false,error:"Invalid MySQL URL"};try{return new URL(t),{valid:!0}}catch{return {valid:false,error:"Invalid MySQL URL"}}}function c(t){return /^mongodb(\+srv)?:\/\/.+/.test(t)?/^mongodb(\+srv)?:\/\/([^@]+@)?[^/]+(\/[^?]*)?(\\?.*)?$/.test(t)?{valid:true}:{valid:false,error:"Invalid MongoDB URL"}:{valid:false,error:"Invalid MongoDB URL"}}function g(t){if(!/^rediss?:\/\/.+/.test(t))return {valid:false,error:"Invalid Redis URL"};try{return new URL(t),{valid:!0}}catch{return {valid:false,error:"Invalid Redis URL"}}}function m(t){try{let n=new URL(t);return ["http:","https:","ws:","wss:","ftp:","ftps:","file:","postgres:","postgresql:","mysql:","mongodb:","redis:","rediss:"].includes(n.protocol)?{valid:!0}:{valid:!1,error:`URL protocol '${n.protocol}' is not allowed`}}catch{return {valid:false,error:"Invalid URL"}}}function O(t){return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(t)?t.length>254?{valid:false,error:"Invalid email"}:{valid:true}:{valid:false,error:"Invalid email"}}function w(t){let n=Number(t);return n!==n||n<1||n>65535?{valid:false,error:"Invalid port"}:{valid:true}}function R(t){let n=Number(t);return n!==n?{valid:false,error:"Invalid number"}:{valid:true}}function v(t){let n=t.toLowerCase();return ["true","1","yes","on","false","0","no","off",""].includes(n)?{valid:true}:{valid:false,error:"Invalid boolean"}}function x(t){let n=new Date(t);if(isNaN(n.getTime()))return {valid:false,error:"Invalid date - cannot parse date value"};if(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?)?$/.test(t)){if(/^\d{4}-\d{2}-\d{2}$/.test(t)){let[e,a,o]=t.split("-").map(Number);if(n.getUTCFullYear()!==e||n.getUTCMonth()+1!==a||n.getUTCDate()!==o)return {valid:false,error:"Invalid date value"}}return {valid:true}}return {valid:false,error:"Date must be in ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)"}}function b(t){if(!/^\d+$/.test(t))return {valid:false,error:"Invalid timestamp"};let n=Number(t);return isNaN(n)||n<0?{valid:false,error:"Invalid timestamp"}:n>253402300799?{valid:false,error:"Timestamp too large"}:{valid:true}}function V(t){let n=/^(\d+(?:\.\d+)?)(ms|s|m|h|d)$/,r=/^(?:(\d+(?:\.\d+)?)h)?(?:(\d+(?:\.\d+)?)m)?(?:(\d+(?:\.\d+)?)s)?(?:(\d+(?:\.\d+)?)ms)?$/,e=t.match(n);if(e){let o=parseFloat(e[1]),s=e[2],d={ms:1,s:1e3,m:60*1e3,h:3600*1e3,d:1440*60*1e3};return {valid:true,value:Math.floor(o*d[s])}}let a=t.match(r);if(a&&a[0]){let o=0;if(a[1]&&(o+=parseFloat(a[1])*60*60*1e3),a[2]&&(o+=parseFloat(a[2])*60*1e3),a[3]&&(o+=parseFloat(a[3])*1e3),a[4]&&(o+=parseFloat(a[4])),o>0)return {valid:true,value:Math.floor(o)}}return {valid:false,error:"Duration must be in format: 5s, 2h, 30m, 1h30m, etc."}}function k(t,n){try{let r=a("fs"),{resolve:e}=a("path"),a$1=e(process.cwd(),t);return {valid:!0,value:r.readFileSync(a$1,"utf8").trim()}}catch(r){return {valid:false,error:`Failed to read file${n?` for ${n}`:""}: ${r instanceof Error?r.message:String(r)}`}}}function h(t){let n=(r=>{if(!r.startsWith("http://")&&!r.startsWith("https://"))throw new Error(`Invalid HTTP URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function y(t){let n=(r=>{try{return JSON.parse(r)}catch{throw new Error(`Invalid JSON: "${r}"`)}});return t&&(n.default=t.default,n.optional=t.optional),i(n,"json",t),n}function $(t){let n=((r,e)=>{if(r===""&&!t?.allowEmpty)throw new Error("String cannot be empty");if(t?.min!==void 0&&r.length<t.min)throw new Error(`String too short (min: ${t.min})`);if(t?.max!==void 0&&r.length>t.max)throw new Error(`String too long (max: ${t.max})`);if(t?.pattern&&!new RegExp(t.pattern).test(r)){let a=e?`${e} does not match required pattern`:"String does not match pattern";throw new Error(a)}return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function I(t){let n=(r=>{let e=Number(r);if(isNaN(e))throw new Error(`Invalid number: "${r}"`);if(t?.min!==void 0&&e<t.min)throw new Error(`Number too small (min: ${t.min})`);if(t?.max!==void 0&&e>t.max)throw new Error(`Number too large (max: ${t.max})`);return e});return t&&(n.default=t.default,n.optional=t.optional),i(n,"number",t),n}function T(t){let n=(r=>{let e=r.toLowerCase();if(["true","1","yes","on"].includes(e))return true;if(["false","0","no","off",""].includes(e))return false;throw new Error(`Invalid boolean: "${r}"`)});return t&&(n.default=t.default,n.optional=t.optional),i(n,"boolean",t),n}function E(t){let n=(r=>{try{return new URL(r),r}catch{throw new Error(`Invalid URL: "${r}"`)}});return t&&(n.default=t.default,n.optional=t.optional),i(n,"url",t),n}function L(t){let n=(r=>{if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))throw new Error(`Invalid email: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"email",t),n}function B(t){let n=(r=>{let e=Number(r);if(isNaN(e)||e<1||e>65535)throw new Error(`Invalid port: "${r}"`);return e});return t&&(n.default=t.default,n.optional=t.optional),i(n,"port",t),n}function N(t){let n=(r=>{if(!r.startsWith("postgres://")&&!r.startsWith("postgresql://"))throw new Error(`Invalid PostgreSQL URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function U(t){let n=(r=>{if(!r.startsWith("mysql://"))throw new Error(`Invalid MySQL URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function M(t){let n=(r=>{if(!r.startsWith("mongodb://")&&!r.startsWith("mongodb+srv://"))throw new Error(`Invalid MongoDB URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function D(t){let n=(r=>{if(!r.startsWith("redis://")&&!r.startsWith("rediss://"))throw new Error(`Invalid Redis URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function P(t){let n=(r=>{if(!r.startsWith("https://"))throw new Error(`Invalid HTTPS URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function S(t){let n=(r=>{let e=t?.separator||",";return r.split(e).map(a=>a.trim()).filter(a=>a.length>0)});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string[]",t),n}function _(t){let n=(r=>{let e=t?.separator||",";return r.split(e).map(a=>{let o=Number(a.trim());if(isNaN(o))throw new Error(`Invalid number in array: "${a}"`);return o})});return t&&(n.default=t.default,n.optional=t.optional),i(n,"number[]",t),n}function q(t){let n=(r=>{let e=t?.separator||",",a=r.split(e).map(o=>o.trim()).filter(o=>o.length>0);for(let o of a)try{new URL(o);}catch{throw new Error(`Invalid URL in array: "${o}"`)}return a});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string[]",t),n}function u(t,n){let r=(e=>{if(!t.includes(e))throw new Error(`Invalid value: "${e}". Allowed values: ${t.join(", ")}`);return e});return n&&(r.default=n.default,r.optional=n.optional),i(r,"oneOf",n,{enumValues:t}),r}function F(t,n){return u(t,n)}function A(t){let n=[...t];return n.__optional=true,n}function W(t){let n=(r=>{let e=r.match(/^(\d+)([smhd])$/);if(!e)throw new Error(`Invalid duration: "${r}". Use format like "5s", "2m", "1h", "1d"`);let[,a,o]=e,d={s:1e3,m:6e4,h:36e5,d:864e5}[o];return Number(a)*d});return t&&(n.default=t.default,n.optional=t.optional),i(n,"number",t),n}function Z(t){let n=(r=>{try{let e=a("fs"),{resolve:a$1}=a("path"),o=a$1(process.cwd(),r);return e.readFileSync(o,"utf8").trim()}catch(e){throw new Error(`Failed to read file: ${e instanceof Error?e.message:String(e)}`,{cause:e})}});return t&&(n.default=t.default,n.optional=t.optional,n.secretsDir=t.secretsDir),n.__isFileValidator=true,i(n,"string",t),n}function Y(t){let n=(r=>r);return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",{...t,sensitive:true}),n}function z(t,n){let r=t;return n&&(r.default=n.default,r.optional=n.optional),i(r,"custom",n),r}function C(t){let n=(r=>{if(!/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/.test(r))throw new Error(`Date must be in ISO 8601 format: "${r}"`);let a=new Date(r);if(isNaN(a.getTime()))throw new Error(`Cannot parse date value: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),i(n,"string",t),n}function Q(t){let n=(r=>{let e=Number(r);if(isNaN(e)||!Number.isInteger(e))throw new Error(`Invalid timestamp: "${r}"`);if(e<0)throw new Error(`Invalid timestamp: "${r}"`);if(e>253402300799)throw new Error(`Timestamp too large: "${r}"`);return e});return t&&(n.default=t.default,n.optional=t.optional),i(n,"number",t),n}function j(t){let n=(o=>t(o)),r=t,e=n;for(let[o,s]of Object.entries(r))o!=="__meta"&&(e[o]=s);let a=r.__meta??{};return e.__meta={...a||{},sensitive:true},n}
|
|
2
|
+
export{T as boolean,z as custom,C as date,W as duration,L as email,F as enumOf,Z as file,h as http,P as https,y as json,M as mongodb,U as mysql,I as number,_ as numberArray,u as oneOf,A as optional,B as port,N as postgres,D as redis,Y as secret,j as sensitive,$ as string,S as stringArray,Q as timestamp,E as url,q as urlArray,v as validateBoolean,x as validateDate,V as validateDuration,O as validateEmail,k as validateFile,c as validateMongodb,f as validateMysql,R as validateNumber,w as validatePort,p as validatePostgres,g as validateRedis,b as validateTimestamp,m as validateUrl};
|
package/dist/web.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
\u{1F4A1} Only variables prefixed with '${e}' are allowed in client bundles.`);if(process.env.NODE_ENV==="development")throw n;return console.error(n.message),{}}let i={};for(let[n,c]of Object.entries(r))n.startsWith(e)&&(i[n]=c);let f=o.map(n=>[n,i]);return await
|
|
1
|
+
'use strict';var chunkS7AB6UX7_cjs=require('./chunk-S7AB6UX7.cjs');require('./chunk-2IQQVAXA.cjs'),require('./chunk-O7NR4K6A.cjs'),require('./chunk-G36OESVW.cjs');var chunkQCKMQEJP_cjs=require('./chunk-QCKMQEJP.cjs'),chunk4QOKRJ3F_cjs=require('./chunk-4QOKRJ3F.cjs');require('./chunk-D6WM53FN.cjs');var h=()=>typeof globalThis.window<"u";async function u(r,v={}){let{resolvers:o=[chunk4QOKRJ3F_cjs.a()],clientPrefix:e="PUBLIC_",strict:m=true}=v,l=Object.keys(r).filter(n=>!n.startsWith(e));if(h()&&l.length>0){let n=new Error(`\u274C Server-only environment variables accessed in browser context: ${l.join(", ")}
|
|
2
|
+
\u{1F4A1} Only variables prefixed with '${e}' are allowed in client bundles.`);if(process.env.NODE_ENV==="development")throw n;return console.error(n.message),{}}let i={};for(let[n,c]of Object.entries(r))n.startsWith(e)&&(i[n]=c);let f=o.map(n=>[n,i]);return await chunkS7AB6UX7_cjs.b({resolvers:f,options:{strict:m}})}async function E(r,v={}){let{resolvers:o=[chunkQCKMQEJP_cjs.a({expand:true}),chunk4QOKRJ3F_cjs.a()],clientPrefix:e="PUBLIC_",policies:m,interpolate:l,strict:i}=v,s=Object.keys(r.client).filter(t=>!t.startsWith(e));if(s.length>0)throw new Error(`\u274C Client environment variables must be prefixed with '${e}': ${s.join(", ")}
|
|
3
3
|
\u{1F4A1} Rename these variables to start with '${e}' (e.g., ${s[0]} \u2192 ${e}${s[0]})`);let c=Object.keys(r.server).filter(t=>t.startsWith(e));if(c.length>0)throw new Error(`\u274C Server environment variables should not be prefixed with '${e}': ${c.join(", ")}
|
|
4
|
-
\u{1F4A1} These variables will be exposed to the client. Move to client schema or remove prefix.`);let x=o.map(t=>[t,r.server]),T=await
|
|
4
|
+
\u{1F4A1} These variables will be exposed to the client. Move to client schema or remove prefix.`);let x=o.map(t=>[t,r.server]),T=await chunkS7AB6UX7_cjs.b({resolvers:x,options:{policies:m,interpolate:l,strict:i}}),d=o.map(t=>[t,r.client]),y=await chunkS7AB6UX7_cjs.b({resolvers:d,options:{strict:i}});return {server:T,client:y}}h()&&process.env.NODE_ENV==="development"&&console.warn(`\u{1F310} node-env-resolver/web: Running in browser context
|
|
5
5
|
Only variables with your configured prefix will be accessible
|
|
6
6
|
Server-only variables are blocked for security`);exports.resolveClientEnv=u;exports.resolveEnvSplit=E;
|
package/dist/web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {b}from'./chunk-C34FGZOG.js';import'./chunk-VUUPIWFJ.js';import'./chunk-6EWR3WHU.js';import'./chunk-46CBATKM.js';import {a as a$1}from'./chunk-MFFH2ZXS.js';import {a}from'./chunk-WKIPEKF6.js';import'./chunk-I7AUKTXE.js';var h=()=>typeof globalThis.window<"u";async function u(r,v={}){let{resolvers:o=[a()],clientPrefix:e="PUBLIC_",strict:m=true}=v,l=Object.keys(r).filter(n=>!n.startsWith(e));if(h()&&l.length>0){let n=new Error(`\u274C Server-only environment variables accessed in browser context: ${l.join(", ")}
|
|
2
2
|
\u{1F4A1} Only variables prefixed with '${e}' are allowed in client bundles.`);if(process.env.NODE_ENV==="development")throw n;return console.error(n.message),{}}let i={};for(let[n,c]of Object.entries(r))n.startsWith(e)&&(i[n]=c);let f=o.map(n=>[n,i]);return await b({resolvers:f,options:{strict:m}})}async function E(r,v={}){let{resolvers:o=[a$1({expand:true}),a()],clientPrefix:e="PUBLIC_",policies:m,interpolate:l,strict:i}=v,s=Object.keys(r.client).filter(t=>!t.startsWith(e));if(s.length>0)throw new Error(`\u274C Client environment variables must be prefixed with '${e}': ${s.join(", ")}
|
|
3
3
|
\u{1F4A1} Rename these variables to start with '${e}' (e.g., ${s[0]} \u2192 ${e}${s[0]})`);let c=Object.keys(r.server).filter(t=>t.startsWith(e));if(c.length>0)throw new Error(`\u274C Server environment variables should not be prefixed with '${e}': ${c.join(", ")}
|
|
4
4
|
\u{1F4A1} These variables will be exposed to the client. Move to client schema or remove prefix.`);let x=o.map(t=>[t,r.server]),T=await b({resolvers:x,options:{policies:m,interpolate:l,strict:i}}),d=o.map(t=>[t,r.client]),y=await b({resolvers:d,options:{strict:i}});return {server:T,client:y}}h()&&process.env.NODE_ENV==="development"&&console.warn(`\u{1F310} node-env-resolver/web: Running in browser context
|
package/dist/zod.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';require('./chunk-
|
|
1
|
+
'use strict';require('./chunk-QCKMQEJP.cjs');var chunk4QOKRJ3F_cjs=require('./chunk-4QOKRJ3F.cjs');require('./chunk-D6WM53FN.cjs');async function u(n,t,e){let s={};for(let o of n)try{let r=o.load?await o.load():{};s={...s,...r};}catch(r){if(e)throw new Error(`Resolver ${o.name} failed: ${r instanceof Error?r.message:r}`,{cause:r})}if(t)for(let[o,r]of Object.entries(s))s[o]=r.replace(/\$\{([^}]+)\}/g,(a,c)=>s[c]||"");return s}function f(n){if(!n||typeof n!="object")return [{path:[],message:"Validation failed",code:"unknown_error"}];let t=n;return !t.issues||!Array.isArray(t.issues)?[{path:[],message:"Validation failed",code:"unknown_error"}]:t.issues.map(e=>({path:e.path||[],message:e.message,code:e.code}))}async function v(n,t={}){let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:s=false,strict:o=true}=t,r=await u(e,s,o);return n.parse(r)}async function g(n,t={}){try{let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:s=!1,strict:o=!0}=t,r=await u(e,s,o),a=n.safeParse(r);if(a.success)return {success:!0,data:a.data};let c=f(a.error);return {success:!1,error:c.map(l=>l.message).join(", "),issues:c}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}function p(n,t,e){let s={};for(let o of n)try{if(!o.loadSync){if(e)throw new Error(`Resolver ${o.name} does not support sync loading`);continue}let r=o.loadSync();s={...s,...r};}catch(r){if(e)throw new Error(`Resolver ${o.name} failed: ${r instanceof Error?r.message:r}`,{cause:r})}if(t)for(let[o,r]of Object.entries(s))s[o]=r.replace(/\$\{([^}]+)\}/g,(a,c)=>s[c]||"");return s}function h(n,t={}){let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:s=false,strict:o=true}=t,r=p(e,s,o);return n.parse(r)}function y(n,t={}){try{let{resolvers:e=[chunk4QOKRJ3F_cjs.a()],interpolate:s=!1,strict:o=!0}=t,r=p(e,s,o),a=n.safeParse(r);if(a.success)return {success:!0,data:a.data};let c=f(a.error);return {success:!1,error:c.map(l=>l.message).join(", "),issues:c}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}exports.resolveSyncZod=h;exports.resolveZod=v;exports.safeResolveSyncZod=y;exports.safeResolveZod=g;
|
package/dist/zod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-
|
|
1
|
+
import'./chunk-MFFH2ZXS.js';import {a}from'./chunk-WKIPEKF6.js';import'./chunk-I7AUKTXE.js';async function u(n,t,e){let s={};for(let o of n)try{let r=o.load?await o.load():{};s={...s,...r};}catch(r){if(e)throw new Error(`Resolver ${o.name} failed: ${r instanceof Error?r.message:r}`,{cause:r})}if(t)for(let[o,r]of Object.entries(s))s[o]=r.replace(/\$\{([^}]+)\}/g,(a,c)=>s[c]||"");return s}function f(n){if(!n||typeof n!="object")return [{path:[],message:"Validation failed",code:"unknown_error"}];let t=n;return !t.issues||!Array.isArray(t.issues)?[{path:[],message:"Validation failed",code:"unknown_error"}]:t.issues.map(e=>({path:e.path||[],message:e.message,code:e.code}))}async function v(n,t={}){let{resolvers:e=[a()],interpolate:s=false,strict:o=true}=t,r=await u(e,s,o);return n.parse(r)}async function g(n,t={}){try{let{resolvers:e=[a()],interpolate:s=!1,strict:o=!0}=t,r=await u(e,s,o),a$1=n.safeParse(r);if(a$1.success)return {success:!0,data:a$1.data};let c=f(a$1.error);return {success:!1,error:c.map(l=>l.message).join(", "),issues:c}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}function p(n,t,e){let s={};for(let o of n)try{if(!o.loadSync){if(e)throw new Error(`Resolver ${o.name} does not support sync loading`);continue}let r=o.loadSync();s={...s,...r};}catch(r){if(e)throw new Error(`Resolver ${o.name} failed: ${r instanceof Error?r.message:r}`,{cause:r})}if(t)for(let[o,r]of Object.entries(s))s[o]=r.replace(/\$\{([^}]+)\}/g,(a,c)=>s[c]||"");return s}function h(n,t={}){let{resolvers:e=[a()],interpolate:s=false,strict:o=true}=t,r=p(e,s,o);return n.parse(r)}function y(n,t={}){try{let{resolvers:e=[a()],interpolate:s=!1,strict:o=!0}=t,r=p(e,s,o),a$1=n.safeParse(r);if(a$1.success)return {success:!0,data:a$1.data};let c=f(a$1.error);return {success:!1,error:c.map(l=>l.message).join(", "),issues:c}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}export{h as resolveSyncZod,v as resolveZod,y as safeResolveSyncZod,g as safeResolveZod};
|