@spfn/core 0.1.0-alpha.8 → 0.1.0-alpha.82
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 +169 -195
- package/dist/auto-loader-JFaZ9gON.d.ts +80 -0
- package/dist/cache/index.d.ts +211 -0
- package/dist/cache/index.js +1013 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/client/index.d.ts +131 -92
- package/dist/client/index.js +93 -85
- package/dist/client/index.js.map +1 -1
- package/dist/codegen/generators/index.d.ts +19 -0
- package/dist/codegen/generators/index.js +1521 -0
- package/dist/codegen/generators/index.js.map +1 -0
- package/dist/codegen/index.d.ts +76 -60
- package/dist/codegen/index.js +1506 -735
- package/dist/codegen/index.js.map +1 -1
- package/dist/database-errors-BNNmLTJE.d.ts +86 -0
- package/dist/db/index.d.ts +844 -44
- package/dist/db/index.js +1281 -1307
- package/dist/db/index.js.map +1 -1
- package/dist/env/index.d.ts +508 -0
- package/dist/env/index.js +1127 -0
- package/dist/env/index.js.map +1 -0
- package/dist/errors/index.d.ts +136 -0
- package/dist/errors/index.js +172 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index-DHiAqhKv.d.ts +101 -0
- package/dist/index.d.ts +3 -374
- package/dist/index.js +2424 -2178
- package/dist/index.js.map +1 -1
- package/dist/logger/index.d.ts +94 -0
- package/dist/logger/index.js +795 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/middleware/index.d.ts +60 -0
- package/dist/middleware/index.js +918 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/route/index.d.ts +21 -53
- package/dist/route/index.js +1259 -219
- package/dist/route/index.js.map +1 -1
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.js +2419 -2059
- package/dist/server/index.js.map +1 -1
- package/dist/types/index.d.ts +121 -0
- package/dist/types/index.js +38 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types-BXibIEyj.d.ts +60 -0
- package/package.json +67 -17
- package/dist/auto-loader-C44TcLmM.d.ts +0 -125
- package/dist/bind-pssq1NRT.d.ts +0 -34
- package/dist/postgres-errors-CY_Es8EJ.d.ts +0 -1703
- package/dist/scripts/index.d.ts +0 -24
- package/dist/scripts/index.js +0 -1201
- package/dist/scripts/index.js.map +0 -1
- package/dist/scripts/templates/api-index.template.txt +0 -10
- package/dist/scripts/templates/api-tag.template.txt +0 -11
- package/dist/scripts/templates/contract.template.txt +0 -87
- package/dist/scripts/templates/entity-type.template.txt +0 -31
- package/dist/scripts/templates/entity.template.txt +0 -19
- package/dist/scripts/templates/index.template.txt +0 -10
- package/dist/scripts/templates/repository.template.txt +0 -37
- package/dist/scripts/templates/routes-id.template.txt +0 -59
- package/dist/scripts/templates/routes-index.template.txt +0 -44
- package/dist/types-SlzTr8ZO.d.ts +0 -143
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Variable Management - Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for centralized environment variable loading
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for loading environment variables
|
|
8
|
+
*/
|
|
9
|
+
interface LoadEnvironmentOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Base directory for .env files
|
|
12
|
+
* @default process.cwd()
|
|
13
|
+
*/
|
|
14
|
+
basePath?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Additional custom paths to load
|
|
17
|
+
* Loaded after standard files
|
|
18
|
+
* @default []
|
|
19
|
+
*/
|
|
20
|
+
customPaths?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Enable debug logging
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
debug?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Override NODE_ENV for file selection
|
|
28
|
+
* @default process.env.NODE_ENV
|
|
29
|
+
*/
|
|
30
|
+
nodeEnv?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Required environment variables
|
|
33
|
+
* Throws error if any are missing after loading
|
|
34
|
+
* @default []
|
|
35
|
+
*/
|
|
36
|
+
required?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Skip loading if environment already loaded
|
|
39
|
+
* Set to false to force reload (useful for testing)
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
useCache?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Result of environment loading operation
|
|
46
|
+
*/
|
|
47
|
+
interface LoadResult {
|
|
48
|
+
/**
|
|
49
|
+
* Whether loading was successful overall
|
|
50
|
+
*/
|
|
51
|
+
success: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Files that were successfully loaded
|
|
54
|
+
*/
|
|
55
|
+
loaded: string[];
|
|
56
|
+
/**
|
|
57
|
+
* Files that failed to load (with reasons)
|
|
58
|
+
*/
|
|
59
|
+
failed: Array<{
|
|
60
|
+
path: string;
|
|
61
|
+
reason: string;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Environment variables that were parsed from files
|
|
65
|
+
*/
|
|
66
|
+
parsed: Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Error messages if any critical errors occurred
|
|
69
|
+
*/
|
|
70
|
+
errors?: string[];
|
|
71
|
+
/**
|
|
72
|
+
* Warning messages for non-critical issues
|
|
73
|
+
*/
|
|
74
|
+
warnings: string[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Options for getting environment variables
|
|
78
|
+
*/
|
|
79
|
+
interface GetEnvOptions {
|
|
80
|
+
/**
|
|
81
|
+
* Throw error if variable not found
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
required?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Default value if variable not found
|
|
87
|
+
* Only used if required is false
|
|
88
|
+
*/
|
|
89
|
+
default?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Custom validation function
|
|
92
|
+
* Return true if valid, false if invalid
|
|
93
|
+
*/
|
|
94
|
+
validator?: (value: string) => boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Custom error message for validation failure
|
|
97
|
+
*/
|
|
98
|
+
validationError?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Standard environment file names in priority order
|
|
102
|
+
*
|
|
103
|
+
* Next.js-style loading behavior:
|
|
104
|
+
* - development: .env → .env.development → .env.local → .env.development.local
|
|
105
|
+
* - production: .env → .env.production → .env.local → .env.production.local
|
|
106
|
+
* - test: .env → .env.test → (skip .env.local) → .env.test.local
|
|
107
|
+
*
|
|
108
|
+
* Note: .env.local is excluded in test environment for proper test isolation
|
|
109
|
+
*/
|
|
110
|
+
declare const ENV_FILE_PRIORITY: readonly [".env", ".env.{NODE_ENV}", ".env.local", ".env.{NODE_ENV}.local"];
|
|
111
|
+
/**
|
|
112
|
+
* Environment files that should only be loaded in test environment
|
|
113
|
+
*/
|
|
114
|
+
declare const TEST_ONLY_FILES: readonly [".env.test", ".env.test.local"];
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Environment Variable Management - Core Loader
|
|
118
|
+
*
|
|
119
|
+
* Centralized singleton environment variable loader with dotenv priority support
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Load environment variables from .env files with Next.js-style priority
|
|
124
|
+
*
|
|
125
|
+
* Loading behavior by environment:
|
|
126
|
+
* - (no NODE_ENV): .env → .env.local
|
|
127
|
+
* - development: .env → .env.development → .env.local → .env.development.local
|
|
128
|
+
* - production: .env → .env.production → .env.local → .env.production.local
|
|
129
|
+
* - test: .env → .env.test → (skip .env.local) → .env.test.local
|
|
130
|
+
* - local: .env → .env.local → .env.local.local (duplicate .env.local prevented)
|
|
131
|
+
* - staging/qa/etc: .env → .env.{NODE_ENV} → .env.local → .env.{NODE_ENV}.local
|
|
132
|
+
*
|
|
133
|
+
* Notes:
|
|
134
|
+
* - .env.local is excluded in test environment for proper test isolation
|
|
135
|
+
* - Any custom NODE_ENV value is supported (staging, qa, uat, preview, etc.)
|
|
136
|
+
* - If NODE_ENV is not set, .env and .env.local are loaded
|
|
137
|
+
*
|
|
138
|
+
* @param options - Loading options
|
|
139
|
+
* @returns Load result with success status and loaded variables
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* // Simple usage (no NODE_ENV set)
|
|
144
|
+
* const result = loadEnvironment();
|
|
145
|
+
*
|
|
146
|
+
* // With NODE_ENV=local
|
|
147
|
+
* process.env.NODE_ENV = 'local';
|
|
148
|
+
* const result = loadEnvironment({
|
|
149
|
+
* debug: true,
|
|
150
|
+
* required: ['DATABASE_URL'],
|
|
151
|
+
* });
|
|
152
|
+
*
|
|
153
|
+
* // With custom environment
|
|
154
|
+
* process.env.NODE_ENV = 'staging';
|
|
155
|
+
* const result = loadEnvironment();
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
declare function loadEnvironment(options?: LoadEnvironmentOptions): LoadResult;
|
|
159
|
+
/**
|
|
160
|
+
* Get an environment variable with optional validation
|
|
161
|
+
*
|
|
162
|
+
* @param key - Environment variable name
|
|
163
|
+
* @param options - Get options (default, required, validator)
|
|
164
|
+
* @returns Variable value or undefined
|
|
165
|
+
* @throws Error if required and not found, or validation fails
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* // Simple get
|
|
170
|
+
* const dbUrl = getEnvVar('DATABASE_URL');
|
|
171
|
+
*
|
|
172
|
+
* // With default
|
|
173
|
+
* const port = getEnvVar('PORT', { default: '3000' });
|
|
174
|
+
*
|
|
175
|
+
* // Required
|
|
176
|
+
* const apiKey = getEnvVar('API_KEY', { required: true });
|
|
177
|
+
*
|
|
178
|
+
* // With validation
|
|
179
|
+
* const url = getEnvVar('API_URL', {
|
|
180
|
+
* validator: (val) => val.startsWith('https://'),
|
|
181
|
+
* validationError: 'API_URL must use HTTPS',
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
declare function getEnvVar(key: string, options?: GetEnvOptions): string | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* Get a required environment variable
|
|
188
|
+
*
|
|
189
|
+
* @param key - Environment variable name
|
|
190
|
+
* @returns Variable value
|
|
191
|
+
* @throws Error if not found
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const dbUrl = requireEnvVar('DATABASE_URL');
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare function requireEnvVar(key: string): string;
|
|
199
|
+
/**
|
|
200
|
+
* Check if an environment variable exists
|
|
201
|
+
*
|
|
202
|
+
* @param key - Environment variable name
|
|
203
|
+
* @returns True if variable exists and is non-empty
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* if (hasEnvVar('REDIS_URL')) {
|
|
208
|
+
* // Use Redis
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
declare function hasEnvVar(key: string): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Get multiple environment variables at once
|
|
215
|
+
*
|
|
216
|
+
* @param keys - Array of environment variable names
|
|
217
|
+
* @returns Object mapping keys to values (undefined if not found)
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* const { DATABASE_URL, REDIS_URL } = getEnvVars([
|
|
222
|
+
* 'DATABASE_URL',
|
|
223
|
+
* 'REDIS_URL',
|
|
224
|
+
* ]);
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
declare function getEnvVars(keys: string[]): Record<string, string | undefined>;
|
|
228
|
+
/**
|
|
229
|
+
* Check if environment has been loaded
|
|
230
|
+
*
|
|
231
|
+
* @returns True if loadEnvironment has been called successfully
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* if (!isEnvironmentLoaded()) {
|
|
236
|
+
* loadEnvironment();
|
|
237
|
+
* }
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
declare function isEnvironmentLoaded(): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Reset environment loading state
|
|
243
|
+
* FOR TESTING ONLY - DO NOT USE IN PRODUCTION
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* // In test cleanup
|
|
248
|
+
* afterEach(() => {
|
|
249
|
+
* resetEnvironment();
|
|
250
|
+
* });
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
declare function resetEnvironment(): void;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Environment Variable Management - Validators
|
|
257
|
+
*
|
|
258
|
+
* Common validation functions for environment variables
|
|
259
|
+
*/
|
|
260
|
+
/**
|
|
261
|
+
* Validate that a value is a valid URL
|
|
262
|
+
*
|
|
263
|
+
* @param value - Value to validate
|
|
264
|
+
* @param options - Validation options
|
|
265
|
+
* @returns True if valid URL, false otherwise
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* const apiUrl = getEnvVar('API_URL', {
|
|
270
|
+
* validator: validateUrl,
|
|
271
|
+
* });
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
declare function validateUrl(value: string, options?: {
|
|
275
|
+
protocol?: 'http' | 'https' | 'any';
|
|
276
|
+
}): boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Create a URL validator with specific protocol requirement
|
|
279
|
+
*
|
|
280
|
+
* @param protocol - Required protocol ('http', 'https', or 'any')
|
|
281
|
+
* @returns Validator function
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* const apiUrl = getEnvVar('API_URL', {
|
|
286
|
+
* validator: createUrlValidator('https'),
|
|
287
|
+
* validationError: 'API_URL must use HTTPS',
|
|
288
|
+
* });
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
declare function createUrlValidator(protocol?: 'http' | 'https' | 'any'): (value: string) => boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Validate that a value is a valid number
|
|
294
|
+
*
|
|
295
|
+
* @param value - Value to validate
|
|
296
|
+
* @param options - Validation options
|
|
297
|
+
* @returns True if valid number, false otherwise
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```typescript
|
|
301
|
+
* const port = getEnvVar('PORT', {
|
|
302
|
+
* validator: (val) => validateNumber(val, { min: 1, max: 65535 }),
|
|
303
|
+
* });
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
declare function validateNumber(value: string, options?: {
|
|
307
|
+
min?: number;
|
|
308
|
+
max?: number;
|
|
309
|
+
integer?: boolean;
|
|
310
|
+
}): boolean;
|
|
311
|
+
/**
|
|
312
|
+
* Create a number validator with specific constraints
|
|
313
|
+
*
|
|
314
|
+
* @param options - Validation constraints
|
|
315
|
+
* @returns Validator function
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```typescript
|
|
319
|
+
* const port = getEnvVar('PORT', {
|
|
320
|
+
* validator: createNumberValidator({ min: 1, max: 65535, integer: true }),
|
|
321
|
+
* validationError: 'PORT must be an integer between 1 and 65535',
|
|
322
|
+
* });
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
declare function createNumberValidator(options?: {
|
|
326
|
+
min?: number;
|
|
327
|
+
max?: number;
|
|
328
|
+
integer?: boolean;
|
|
329
|
+
}): (value: string) => boolean;
|
|
330
|
+
/**
|
|
331
|
+
* Validate that a value is a valid boolean string
|
|
332
|
+
*
|
|
333
|
+
* @param value - Value to validate
|
|
334
|
+
* @returns True if valid boolean string, false otherwise
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```typescript
|
|
338
|
+
* const debugMode = getEnvVar('DEBUG', {
|
|
339
|
+
* validator: validateBoolean,
|
|
340
|
+
* });
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare function validateBoolean(value: string): boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Parse a boolean environment variable
|
|
346
|
+
*
|
|
347
|
+
* @param value - Value to parse
|
|
348
|
+
* @returns Boolean value
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```typescript
|
|
352
|
+
* const debug = parseBoolean(getEnvVar('DEBUG', { default: 'false' })!);
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
declare function parseBoolean(value: string): boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Validate that a value is one of allowed options
|
|
358
|
+
*
|
|
359
|
+
* @param value - Value to validate
|
|
360
|
+
* @param allowed - Array of allowed values
|
|
361
|
+
* @param caseInsensitive - Whether to perform case-insensitive comparison
|
|
362
|
+
* @returns True if value is in allowed list, false otherwise
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```typescript
|
|
366
|
+
* const env = getEnvVar('NODE_ENV', {
|
|
367
|
+
* validator: (val) => validateEnum(val, ['development', 'production', 'test']),
|
|
368
|
+
* });
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
declare function validateEnum(value: string, allowed: string[], caseInsensitive?: boolean): boolean;
|
|
372
|
+
/**
|
|
373
|
+
* Create an enum validator with specific allowed values
|
|
374
|
+
*
|
|
375
|
+
* @param allowed - Array of allowed values
|
|
376
|
+
* @param caseInsensitive - Whether to perform case-insensitive comparison
|
|
377
|
+
* @returns Validator function
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* ```typescript
|
|
381
|
+
* const logLevel = getEnvVar('LOG_LEVEL', {
|
|
382
|
+
* validator: createEnumValidator(['debug', 'info', 'warn', 'error']),
|
|
383
|
+
* validationError: 'LOG_LEVEL must be one of: debug, info, warn, error',
|
|
384
|
+
* });
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
declare function createEnumValidator(allowed: string[], caseInsensitive?: boolean): (value: string) => boolean;
|
|
388
|
+
/**
|
|
389
|
+
* Validate that a value matches a regular expression
|
|
390
|
+
*
|
|
391
|
+
* @param value - Value to validate
|
|
392
|
+
* @param pattern - Regular expression pattern
|
|
393
|
+
* @returns True if value matches pattern, false otherwise
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```typescript
|
|
397
|
+
* const apiKey = getEnvVar('API_KEY', {
|
|
398
|
+
* validator: (val) => validatePattern(val, /^[A-Za-z0-9_-]{32}$/),
|
|
399
|
+
* });
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
declare function validatePattern(value: string, pattern: RegExp): boolean;
|
|
403
|
+
/**
|
|
404
|
+
* Create a pattern validator with specific regex
|
|
405
|
+
*
|
|
406
|
+
* @param pattern - Regular expression pattern
|
|
407
|
+
* @returns Validator function
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```typescript
|
|
411
|
+
* const apiKey = getEnvVar('API_KEY', {
|
|
412
|
+
* validator: createPatternValidator(/^[A-Za-z0-9_-]{32}$/),
|
|
413
|
+
* validationError: 'API_KEY must be 32 alphanumeric characters',
|
|
414
|
+
* });
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
declare function createPatternValidator(pattern: RegExp): (value: string) => boolean;
|
|
418
|
+
/**
|
|
419
|
+
* Validate that a value is not empty
|
|
420
|
+
*
|
|
421
|
+
* @param value - Value to validate
|
|
422
|
+
* @returns True if not empty, false otherwise
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```typescript
|
|
426
|
+
* const name = getEnvVar('APP_NAME', {
|
|
427
|
+
* validator: validateNotEmpty,
|
|
428
|
+
* });
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
declare function validateNotEmpty(value: string): boolean;
|
|
432
|
+
/**
|
|
433
|
+
* Validate that a value has minimum length
|
|
434
|
+
*
|
|
435
|
+
* @param value - Value to validate
|
|
436
|
+
* @param minLength - Minimum required length
|
|
437
|
+
* @returns True if meets minimum length, false otherwise
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```typescript
|
|
441
|
+
* const password = getEnvVar('DB_PASSWORD', {
|
|
442
|
+
* validator: (val) => validateMinLength(val, 8),
|
|
443
|
+
* });
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
declare function validateMinLength(value: string, minLength: number): boolean;
|
|
447
|
+
/**
|
|
448
|
+
* Create a minimum length validator
|
|
449
|
+
*
|
|
450
|
+
* @param minLength - Minimum required length
|
|
451
|
+
* @returns Validator function
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```typescript
|
|
455
|
+
* const password = getEnvVar('DB_PASSWORD', {
|
|
456
|
+
* validator: createMinLengthValidator(8),
|
|
457
|
+
* validationError: 'DB_PASSWORD must be at least 8 characters',
|
|
458
|
+
* });
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
declare function createMinLengthValidator(minLength: number): (value: string) => boolean;
|
|
462
|
+
/**
|
|
463
|
+
* Combine multiple validators with AND logic
|
|
464
|
+
*
|
|
465
|
+
* @param validators - Array of validator functions
|
|
466
|
+
* @returns Combined validator function
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```typescript
|
|
470
|
+
* const port = getEnvVar('PORT', {
|
|
471
|
+
* validator: combineValidators([
|
|
472
|
+
* validateNotEmpty,
|
|
473
|
+
* createNumberValidator({ min: 1, max: 65535, integer: true }),
|
|
474
|
+
* ]),
|
|
475
|
+
* });
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
478
|
+
declare function combineValidators(validators: Array<(value: string) => boolean>): (value: string) => boolean;
|
|
479
|
+
/**
|
|
480
|
+
* Validate PostgreSQL connection string
|
|
481
|
+
*
|
|
482
|
+
* @param value - Value to validate
|
|
483
|
+
* @returns True if valid PostgreSQL URL, false otherwise
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```typescript
|
|
487
|
+
* const dbUrl = getEnvVar('DATABASE_URL', {
|
|
488
|
+
* validator: validatePostgresUrl,
|
|
489
|
+
* });
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
declare function validatePostgresUrl(value: string): boolean;
|
|
493
|
+
/**
|
|
494
|
+
* Validate Redis connection string
|
|
495
|
+
*
|
|
496
|
+
* @param value - Value to validate
|
|
497
|
+
* @returns True if valid Redis URL, false otherwise
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```typescript
|
|
501
|
+
* const redisUrl = getEnvVar('REDIS_URL', {
|
|
502
|
+
* validator: validateRedisUrl,
|
|
503
|
+
* });
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
declare function validateRedisUrl(value: string): boolean;
|
|
507
|
+
|
|
508
|
+
export { ENV_FILE_PRIORITY, type GetEnvOptions, type LoadEnvironmentOptions, type LoadResult, TEST_ONLY_FILES, combineValidators, createEnumValidator, createMinLengthValidator, createNumberValidator, createPatternValidator, createUrlValidator, getEnvVar, getEnvVars, hasEnvVar, isEnvironmentLoaded, loadEnvironment, parseBoolean, requireEnvVar, resetEnvironment, validateBoolean, validateEnum, validateMinLength, validateNotEmpty, validateNumber, validatePattern, validatePostgresUrl, validateRedisUrl, validateUrl };
|