alepha 0.6.7 → 0.6.9
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/cache.d.ts +353 -1
- package/core.d.ts +998 -19
- package/datetime.d.ts +167 -1
- package/lock.d.ts +280 -1
- package/package.json +36 -22
- package/postgres.d.ts +1452 -1
- package/queue.d.ts +305 -1
- package/react/auth.d.ts +300 -1
- package/react.d.ts +617 -1
- package/redis.d.ts +135 -1
- package/scheduler.d.ts +185 -1
- package/security.d.ts +651 -1
- package/server/cookies.d.ts +56 -1
- package/server/metrics.d.ts +14 -1
- package/server/proxy.d.ts +34 -1
- package/server/static.d.ts +103 -1
- package/server/swagger.d.ts +102 -1
- package/server.d.ts +879 -1
- package/topic.d.ts +301 -1
- package/vite.d.ts +80 -1
package/core.d.ts
CHANGED
|
@@ -1,19 +1,998 @@
|
|
|
1
|
-
|
|
2
|
-
import '@
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import '@
|
|
6
|
-
import '
|
|
7
|
-
import '@
|
|
8
|
-
import '
|
|
9
|
-
import '@
|
|
10
|
-
|
|
11
|
-
import '
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import * as TypeBox from '@sinclair/typebox';
|
|
2
|
+
import { TSchema, Static, TObject, FormatRegistry, SchemaOptions, ObjectOptions, Union, TProperties, ArrayOptions, TArray, StringOptions, TString, TBoolean, NumberOptions, TNumber, IntegerOptions, TInteger, TOptionalWithFlag, TNull, TIntersect, TUnsafe, UnsafeOptions } from '@sinclair/typebox';
|
|
3
|
+
export { TypeBox };
|
|
4
|
+
export { Static, StaticDecode, StaticEncode, TObject, TSchema, TypeGuard } from '@sinclair/typebox';
|
|
5
|
+
import { TypeCheck } from '@sinclair/typebox/compiler';
|
|
6
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
7
|
+
import { ValueError } from '@sinclair/typebox/errors';
|
|
8
|
+
import { ReadableStream as ReadableStream$1 } from 'node:stream/web';
|
|
9
|
+
import * as TypeBoxValue from '@sinclair/typebox/value';
|
|
10
|
+
export { TypeBoxValue };
|
|
11
|
+
import { Readable } from 'node:stream';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Used for identifying descriptors.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
declare const KIND: unique symbol;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Represents a value that can be either a value or a promise.
|
|
22
|
+
*/
|
|
23
|
+
type Async<T> = T | Promise<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Represents a function that returns a promise.
|
|
26
|
+
*/
|
|
27
|
+
type PromiseFn = (...args: any[]) => Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Represents a function that returns an async value.
|
|
30
|
+
*/
|
|
31
|
+
type AsyncFn = (...args: any[]) => Async<any>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents a generic definition type in TypeScript.
|
|
35
|
+
*/
|
|
36
|
+
interface Class<T extends object = any> {
|
|
37
|
+
new (...args: any[]): T;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
interface ClassSwap<T extends object = any> {
|
|
43
|
+
/**
|
|
44
|
+
* Class to register.
|
|
45
|
+
*/
|
|
46
|
+
provide: Class<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Class to use AS the provided class.
|
|
49
|
+
*/
|
|
50
|
+
use: Class<T>;
|
|
51
|
+
/**
|
|
52
|
+
* If true, "use" only if class is not already registered.
|
|
53
|
+
*/
|
|
54
|
+
default?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* If true, class will be removed if nobody is using it.
|
|
57
|
+
*/
|
|
58
|
+
optional?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
type ClassEntry<T extends object = any> = Class<T> | ClassSwap<T>;
|
|
64
|
+
/**
|
|
65
|
+
* Represents a definition for a class.
|
|
66
|
+
*/
|
|
67
|
+
interface ClassProvider<T extends object = any> {
|
|
68
|
+
/**
|
|
69
|
+
* The class or type definition to provide.
|
|
70
|
+
*/
|
|
71
|
+
provide: Class<T>;
|
|
72
|
+
/**
|
|
73
|
+
* The class or type definition to use. This will override the 'provide' property.
|
|
74
|
+
*/
|
|
75
|
+
use?: Class<T>;
|
|
76
|
+
/**
|
|
77
|
+
* The instance of the class or type definition.
|
|
78
|
+
* Mostly used for caching / singleton but can be used for other purposes like forcing the instance.
|
|
79
|
+
*/
|
|
80
|
+
instance: T;
|
|
81
|
+
/**
|
|
82
|
+
* List of classes which use this class.
|
|
83
|
+
*/
|
|
84
|
+
parents: Array<Class | null>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Used for identifying descriptors.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
declare const OPTIONS: unique symbol;
|
|
93
|
+
|
|
94
|
+
declare const KEY = "HOOK";
|
|
95
|
+
interface Hooks {
|
|
96
|
+
/**
|
|
97
|
+
* Triggered during the configuration phase. Before the start phase.
|
|
98
|
+
*
|
|
99
|
+
* - Configuration should technically be called many times without any side effects.
|
|
100
|
+
* - Spamming Alepha#configure() should not cause any issues.
|
|
101
|
+
*/
|
|
102
|
+
configure: Alepha;
|
|
103
|
+
/**
|
|
104
|
+
* Triggered during the start phase. When `Alepha#start()` is called.
|
|
105
|
+
*
|
|
106
|
+
* - Start is called only once. It should not be called multiple times.
|
|
107
|
+
*/
|
|
108
|
+
start: Alepha;
|
|
109
|
+
/**
|
|
110
|
+
* Triggered during the ready phase. After the start phase.
|
|
111
|
+
*
|
|
112
|
+
* - Ready is called only once. It should not be called multiple times.
|
|
113
|
+
*/
|
|
114
|
+
ready: Alepha;
|
|
115
|
+
/**
|
|
116
|
+
* Triggered during the stop phase.
|
|
117
|
+
*
|
|
118
|
+
* - Stop is called only once. It should not be called multiple times.
|
|
119
|
+
* - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application.
|
|
120
|
+
*/
|
|
121
|
+
stop: Alepha;
|
|
122
|
+
}
|
|
123
|
+
interface HookOptions<T extends keyof Hooks> {
|
|
124
|
+
/**
|
|
125
|
+
* The name of the hook. "configure", "start", "ready", "stop", ...
|
|
126
|
+
*/
|
|
127
|
+
name: T;
|
|
128
|
+
/**
|
|
129
|
+
* The handler to run when the hook is triggered.
|
|
130
|
+
*/
|
|
131
|
+
handler: (app: Hooks[T]) => Async<any>;
|
|
132
|
+
before?: object | Array<object>;
|
|
133
|
+
after?: object | Array<object>;
|
|
134
|
+
priority?: "first" | "last";
|
|
135
|
+
}
|
|
136
|
+
interface Hook<T extends keyof Hooks = any> {
|
|
137
|
+
caller?: Class;
|
|
138
|
+
priority?: "first" | "last";
|
|
139
|
+
callback: (payload: Hooks[T]) => Async<void>;
|
|
140
|
+
}
|
|
141
|
+
interface HookDescriptor<T extends keyof Hooks> {
|
|
142
|
+
[KIND]: typeof KEY;
|
|
143
|
+
[OPTIONS]: HookOptions<T>;
|
|
144
|
+
(app: Hooks[T]): Async<any>;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Registers a new hook.
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* import { $hook } from "alepha";
|
|
151
|
+
*
|
|
152
|
+
* class MyProvider {
|
|
153
|
+
* onStart = $hook({
|
|
154
|
+
* name: "start", // or "configure", "ready", "stop", ...
|
|
155
|
+
* handler: async (app) => {
|
|
156
|
+
* // await db.connect(); ...
|
|
157
|
+
* }
|
|
158
|
+
* });
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* Hooks are used to run async functions from all registered providers/services.
|
|
163
|
+
*
|
|
164
|
+
* - You can't unregister a hook once it has been registered.
|
|
165
|
+
* - You can't register a hook after the App has started.
|
|
166
|
+
*
|
|
167
|
+
* It's used under the hood by the `configure`, `start`, and `stop` methods.
|
|
168
|
+
* Some modules also use hooks to run their own logic.
|
|
169
|
+
*/
|
|
170
|
+
declare const $hook: {
|
|
171
|
+
<T extends keyof Hooks>(options: HookOptions<T>): HookDescriptor<T>;
|
|
172
|
+
[KIND]: string;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Used to store the current context and definition during injections.
|
|
177
|
+
*
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
declare const __alephaRef: {
|
|
181
|
+
context?: Alepha;
|
|
182
|
+
definition?: Class;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Cursor descriptor.
|
|
186
|
+
*/
|
|
187
|
+
interface CursorDescriptor {
|
|
188
|
+
context: Alepha;
|
|
189
|
+
definition?: Class;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get Alepha instance and Class definition from the current context.
|
|
193
|
+
*
|
|
194
|
+
* This should be used inside a descriptor only.
|
|
195
|
+
*
|
|
196
|
+
* @internal
|
|
197
|
+
*/
|
|
198
|
+
declare const $cursor: () => CursorDescriptor;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Light-weight event emitter like.
|
|
202
|
+
*/
|
|
203
|
+
declare class EventEmitterLike<TEvents extends {
|
|
204
|
+
[key: string]: any;
|
|
205
|
+
}> {
|
|
206
|
+
private hooks;
|
|
207
|
+
on<T extends keyof TEvents>(event: T, callback: (data: TEvents[T]) => void): void;
|
|
208
|
+
emit<T extends keyof TEvents>(event: T, data: TEvents[T]): void;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Descriptor events.
|
|
212
|
+
*
|
|
213
|
+
* - `create` - Emitted when a descriptor is created.
|
|
214
|
+
*/
|
|
215
|
+
declare const descriptorEvents: EventEmitterLike<{
|
|
216
|
+
create: CursorDescriptor & {
|
|
217
|
+
[KIND]: string;
|
|
218
|
+
};
|
|
219
|
+
}>;
|
|
220
|
+
/**
|
|
221
|
+
* Register a descriptor.
|
|
222
|
+
*
|
|
223
|
+
* This is used to run the event "create" and allow auto-registration of descriptors.
|
|
224
|
+
*
|
|
225
|
+
* @internal
|
|
226
|
+
* @param kind
|
|
227
|
+
*/
|
|
228
|
+
declare const __descriptor: (kind: string) => void;
|
|
229
|
+
/**
|
|
230
|
+
* Auto-inject a class/module when a descriptor is created.
|
|
231
|
+
*
|
|
232
|
+
* Like, you auto-inject the ServerModule when a `$route` descriptor is used.
|
|
233
|
+
*
|
|
234
|
+
* @param descriptor
|
|
235
|
+
* @param to
|
|
236
|
+
*/
|
|
237
|
+
declare const __bind: (descriptor: {
|
|
238
|
+
[KIND]: string;
|
|
239
|
+
}, ...to: Class[]) => void;
|
|
240
|
+
/**
|
|
241
|
+
* Check if the value is a descriptor value.
|
|
242
|
+
*
|
|
243
|
+
* @param value - Value to check.
|
|
244
|
+
* @returns Is the value a descriptor value.
|
|
245
|
+
*/
|
|
246
|
+
declare const isDescriptorValue: (value: any) => value is DescriptorIdentifier;
|
|
247
|
+
/**
|
|
248
|
+
* The "$descriptor" function.
|
|
249
|
+
*/
|
|
250
|
+
interface Descriptor<T extends object = any> {
|
|
251
|
+
[KIND]: string;
|
|
252
|
+
(options: T): DescriptorIdentifier<T>;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Class member descriptor.
|
|
256
|
+
*/
|
|
257
|
+
interface DescriptorIdentifier<T = object> {
|
|
258
|
+
[KIND]: string;
|
|
259
|
+
[OPTIONS]: T;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Descriptor identifier + his instance + his key.
|
|
263
|
+
*/
|
|
264
|
+
interface DescriptorItem<T extends Descriptor> {
|
|
265
|
+
value: ReturnType<T>;
|
|
266
|
+
key: string;
|
|
267
|
+
instance: Record<string, any>;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
type AsyncLocalStorageData = any;
|
|
271
|
+
declare class AsyncLocalStorageProvider {
|
|
272
|
+
protected als?: AsyncLocalStorage<AsyncLocalStorageData>;
|
|
273
|
+
configure(): Promise<void>;
|
|
274
|
+
run<R>(data: AsyncLocalStorageData, callback: () => R): R;
|
|
275
|
+
get<T>(key: string): T | undefined;
|
|
276
|
+
set<T>(key: string, value: T): void;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
type LogLevel = "error" | "warn" | "info" | "debug" | "trace" | "silent";
|
|
280
|
+
interface LoggerEnv {
|
|
281
|
+
/**
|
|
282
|
+
* Default log level for the application.
|
|
283
|
+
* Default by environment:
|
|
284
|
+
* - dev = "debug"
|
|
285
|
+
* - test = "error"
|
|
286
|
+
* - prod = "info"
|
|
287
|
+
*/
|
|
288
|
+
LOG_LEVEL?: "trace" | "debug" | "info" | "warn" | "error" | "silent";
|
|
289
|
+
/**
|
|
290
|
+
* Disable colors in the console output.
|
|
291
|
+
*/
|
|
292
|
+
NO_COLOR?: string;
|
|
293
|
+
/**
|
|
294
|
+
* Force color output for the application.
|
|
295
|
+
*/
|
|
296
|
+
FORCE_COLOR?: string;
|
|
297
|
+
/**
|
|
298
|
+
* Log format.
|
|
299
|
+
*
|
|
300
|
+
* @default "text"
|
|
301
|
+
*/
|
|
302
|
+
LOG_FORMAT?: "json" | "text";
|
|
303
|
+
}
|
|
304
|
+
interface LoggerOptions {
|
|
305
|
+
/**
|
|
306
|
+
* The logging level. Can be one of "error", "warn", "info", "debug", or "trace".
|
|
307
|
+
*/
|
|
308
|
+
level?: LogLevel;
|
|
309
|
+
/**
|
|
310
|
+
* The name of the logger. Like a module name or a service name.
|
|
311
|
+
*/
|
|
312
|
+
name?: string;
|
|
313
|
+
/**
|
|
314
|
+
* An optional context to include in the log output. Like a request ID or a correlation ID.
|
|
315
|
+
*/
|
|
316
|
+
context?: string;
|
|
317
|
+
/**
|
|
318
|
+
* An optional tag to include in the log output. Like a class name or a module name.
|
|
319
|
+
*/
|
|
320
|
+
caller?: string;
|
|
321
|
+
/**
|
|
322
|
+
* Whether to use colors in the log output. Defaults to true.
|
|
323
|
+
*/
|
|
324
|
+
color?: boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Whether to log in JSON format. Defaults to false.
|
|
327
|
+
*/
|
|
328
|
+
json?: boolean;
|
|
329
|
+
/**
|
|
330
|
+
* An optional async local storage provider to use for storing context information.
|
|
331
|
+
*/
|
|
332
|
+
als?: AsyncLocalStorageProvider;
|
|
333
|
+
}
|
|
334
|
+
declare const COLORS: {
|
|
335
|
+
reset: string;
|
|
336
|
+
grey: string;
|
|
337
|
+
red: string;
|
|
338
|
+
orange: string;
|
|
339
|
+
green: string;
|
|
340
|
+
blue: string;
|
|
341
|
+
white: string;
|
|
342
|
+
cyan: string;
|
|
343
|
+
darkGrey: string;
|
|
344
|
+
};
|
|
345
|
+
declare const LEVEL_COLORS: Record<LogLevel, string>;
|
|
346
|
+
declare class Logger {
|
|
347
|
+
protected levelOrder: Record<LogLevel, number>;
|
|
348
|
+
readonly level: LogLevel;
|
|
349
|
+
readonly name: string;
|
|
350
|
+
protected caller: string;
|
|
351
|
+
protected context: string;
|
|
352
|
+
protected color: boolean;
|
|
353
|
+
protected json: boolean;
|
|
354
|
+
protected als?: AsyncLocalStorageProvider;
|
|
355
|
+
constructor(options?: LoggerOptions);
|
|
356
|
+
child(options: LoggerOptions): Logger;
|
|
357
|
+
error(message: unknown, data?: object | Error | string | unknown): void;
|
|
358
|
+
warn(message: unknown, data?: object | Error | string): void;
|
|
359
|
+
info(message: unknown, data?: object | Error | string): void;
|
|
360
|
+
debug(message: unknown, data?: object | Error | string): void;
|
|
361
|
+
trace(message: unknown, data?: object | Error | string): void;
|
|
362
|
+
/**
|
|
363
|
+
* Log a message to the console.
|
|
364
|
+
*
|
|
365
|
+
* @param level
|
|
366
|
+
* @param message
|
|
367
|
+
* @param data
|
|
368
|
+
* @protected
|
|
369
|
+
*/
|
|
370
|
+
protected log(level: LogLevel, message: unknown, data?: object | Error | string): void;
|
|
371
|
+
/**
|
|
372
|
+
* Print a log message to the console.
|
|
373
|
+
*
|
|
374
|
+
* @param formatted
|
|
375
|
+
* @protected
|
|
376
|
+
*/
|
|
377
|
+
protected print(formatted: string): void;
|
|
378
|
+
/**
|
|
379
|
+
* Format a log message to JSON.
|
|
380
|
+
*
|
|
381
|
+
* @param level
|
|
382
|
+
* @param message
|
|
383
|
+
* @param data
|
|
384
|
+
* @protected
|
|
385
|
+
*/
|
|
386
|
+
protected formatJson(level: LogLevel, message: unknown, data?: object | Error | string): string;
|
|
387
|
+
/**
|
|
388
|
+
* Format a log message to a string.
|
|
389
|
+
*
|
|
390
|
+
* @param level
|
|
391
|
+
* @param message
|
|
392
|
+
* @param data
|
|
393
|
+
* @protected
|
|
394
|
+
*/
|
|
395
|
+
protected formatLog(level: LogLevel, message: string, data?: object | Error): string;
|
|
396
|
+
/**
|
|
397
|
+
* Format an error to a string.
|
|
398
|
+
*
|
|
399
|
+
* @param error
|
|
400
|
+
* @protected
|
|
401
|
+
*/
|
|
402
|
+
protected formatError(error: Error): string;
|
|
403
|
+
}
|
|
404
|
+
declare class MockLogger extends Logger {
|
|
405
|
+
store: MockLoggerStore;
|
|
406
|
+
constructor(options?: LoggerOptions & {
|
|
407
|
+
store: MockLoggerStore;
|
|
408
|
+
});
|
|
409
|
+
print(msg: string): void;
|
|
410
|
+
child(options: LoggerOptions): MockLogger;
|
|
411
|
+
}
|
|
412
|
+
interface MockLoggerStore {
|
|
413
|
+
stack: Array<{
|
|
414
|
+
date: string;
|
|
415
|
+
level: string;
|
|
416
|
+
msg: string;
|
|
417
|
+
data?: object;
|
|
418
|
+
}>;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
interface Env extends LoggerEnv {
|
|
422
|
+
[key: string]: string | boolean | number | undefined;
|
|
423
|
+
/**
|
|
424
|
+
*
|
|
425
|
+
*/
|
|
426
|
+
NODE_ENV?: "dev" | "test" | "production";
|
|
427
|
+
/**
|
|
428
|
+
* Optional name of the application.
|
|
429
|
+
*/
|
|
430
|
+
APP_NAME?: string;
|
|
431
|
+
/**
|
|
432
|
+
* If true, the container will not automatically register the default providers.
|
|
433
|
+
* Default is false.
|
|
434
|
+
*/
|
|
435
|
+
EXPLICIT_PROVIDERS?: boolean;
|
|
436
|
+
}
|
|
437
|
+
interface State {
|
|
438
|
+
log: Logger;
|
|
439
|
+
env?: Readonly<Env>;
|
|
440
|
+
beforeAll?: (run: any) => any;
|
|
441
|
+
afterAll?: (run: any) => any;
|
|
442
|
+
afterEach?: (run: any) => any;
|
|
443
|
+
onTestFinished?: (run: any) => any;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
*
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* ```ts
|
|
450
|
+
* const app = Alepha.create();
|
|
451
|
+
* ```
|
|
452
|
+
*/
|
|
453
|
+
declare class Alepha {
|
|
454
|
+
/**
|
|
455
|
+
* Syntactic sugar for creating a new instance of the container.
|
|
456
|
+
* Equivalent to `Alepha.create()`.
|
|
457
|
+
*/
|
|
458
|
+
static create(state?: Partial<State>): Alepha;
|
|
459
|
+
/**
|
|
460
|
+
* List of all services + how they are provided.
|
|
461
|
+
*/
|
|
462
|
+
protected registry: Map<Class, ClassProvider>;
|
|
463
|
+
/**
|
|
464
|
+
* Flag indicating whether the App won't accept any further changes.
|
|
465
|
+
* Pass to true when #start() is called.
|
|
466
|
+
*/
|
|
467
|
+
protected locked: boolean;
|
|
468
|
+
/**
|
|
469
|
+
* True if the App has been configured.
|
|
470
|
+
*/
|
|
471
|
+
protected configured: boolean;
|
|
472
|
+
/**
|
|
473
|
+
* True if the App has started.
|
|
474
|
+
*/
|
|
475
|
+
protected started: boolean;
|
|
476
|
+
/**
|
|
477
|
+
* True if the App is ready.
|
|
478
|
+
*/
|
|
479
|
+
protected ready: boolean;
|
|
480
|
+
/**
|
|
481
|
+
* The state of the App.
|
|
482
|
+
*/
|
|
483
|
+
protected _starting?: PromiseWithResolvers<this>;
|
|
484
|
+
protected _state: State;
|
|
485
|
+
protected _dependencyStack: Class[];
|
|
486
|
+
protected _lazyRegistrations: Array<Promise<{
|
|
487
|
+
default: Class<object>;
|
|
488
|
+
}>>;
|
|
489
|
+
protected _cacheEnv: Map<TSchema, any>;
|
|
490
|
+
protected _cacheTypeCheck: Map<TSchema, TypeCheck<TSchema>>;
|
|
491
|
+
protected _events: Record<string, Array<Hook>>;
|
|
492
|
+
readonly als: AsyncLocalStorageProvider;
|
|
493
|
+
get log(): Logger;
|
|
494
|
+
handle?: (req: any, res: any) => Promise<any>;
|
|
495
|
+
/**
|
|
496
|
+
* The environment variables for the App.
|
|
497
|
+
*/
|
|
498
|
+
get env(): Readonly<Env>;
|
|
499
|
+
constructor(state?: Partial<State>);
|
|
500
|
+
/**
|
|
501
|
+
* State accessor.
|
|
502
|
+
*/
|
|
503
|
+
state<Key extends keyof State>(key: Key, value?: State[Key]): State[Key];
|
|
504
|
+
/**
|
|
505
|
+
*
|
|
506
|
+
*/
|
|
507
|
+
graph(): Record<string, {
|
|
508
|
+
from: string[];
|
|
509
|
+
as?: string;
|
|
510
|
+
}>;
|
|
511
|
+
/**
|
|
512
|
+
* True if the App is running in a browser environment.
|
|
513
|
+
*/
|
|
514
|
+
isBrowser(): boolean;
|
|
515
|
+
/**
|
|
516
|
+
* Returns whether the App has started.
|
|
517
|
+
*
|
|
518
|
+
* It means that #start() has been called but maybe not all services are ready.
|
|
519
|
+
*/
|
|
520
|
+
isStarted(): boolean;
|
|
521
|
+
/**
|
|
522
|
+
* True if the App is ready. It means that Alepha is started AND ready() hook has beed called.
|
|
523
|
+
*/
|
|
524
|
+
isReady(): boolean;
|
|
525
|
+
/**
|
|
526
|
+
* True when start() is called. No more services can be added.
|
|
527
|
+
*/
|
|
528
|
+
isLocked(): boolean;
|
|
529
|
+
isConfigured(): boolean;
|
|
530
|
+
/**
|
|
531
|
+
* Returns whether the App is running in a serverless environment.
|
|
532
|
+
*/
|
|
533
|
+
isServerless(): boolean | "vite" | "vercel";
|
|
534
|
+
/**
|
|
535
|
+
* Returns whether the App is in test mode. (Running in a test environment)
|
|
536
|
+
*/
|
|
537
|
+
isTest(): boolean;
|
|
538
|
+
/**
|
|
539
|
+
* Returns whether the App is in production mode. (Running in a production environment)
|
|
540
|
+
*/
|
|
541
|
+
isProduction(): boolean;
|
|
542
|
+
/**
|
|
543
|
+
* > configure() is automatically called by start().
|
|
544
|
+
* Use this method only if you need to configure the App without starting it.
|
|
545
|
+
*
|
|
546
|
+
* @internal
|
|
547
|
+
*/
|
|
548
|
+
configure(): Promise<this | undefined>;
|
|
549
|
+
/**
|
|
550
|
+
* Starts the App.
|
|
551
|
+
*
|
|
552
|
+
* - Lock any further changes to the container.
|
|
553
|
+
* - Run "configure" hook for all services.
|
|
554
|
+
* - Run "start" hook for all services.
|
|
555
|
+
*
|
|
556
|
+
* @return A promise that resolves when the App has started.
|
|
557
|
+
*/
|
|
558
|
+
start(): Promise<this>;
|
|
559
|
+
/**
|
|
560
|
+
* Stops the App.
|
|
561
|
+
*
|
|
562
|
+
* - Run "stop" hook for all services.
|
|
563
|
+
*
|
|
564
|
+
* @return A promise that resolves when the App has stopped.
|
|
565
|
+
*/
|
|
566
|
+
stop(): Promise<void>;
|
|
567
|
+
/**
|
|
568
|
+
* Returns whether the specified class or type is registered in the container.
|
|
569
|
+
*
|
|
570
|
+
* @param injectable - The class or type definition to check.
|
|
571
|
+
* @param opts - Additional options for the check.
|
|
572
|
+
* @return True if the class or type is registered in the container, false otherwise.
|
|
573
|
+
*/
|
|
574
|
+
has(injectable: ClassEntry, opts?: {
|
|
575
|
+
overridden?: boolean;
|
|
576
|
+
pending?: boolean;
|
|
577
|
+
}): boolean;
|
|
578
|
+
/**
|
|
579
|
+
* Registers the specified class or type in the container.
|
|
580
|
+
*
|
|
581
|
+
* - If the class or type is already registered, the method does nothing.
|
|
582
|
+
* - If the class or type is not registered, a new instance is created and registered.
|
|
583
|
+
*
|
|
584
|
+
* ClassEntry allows to provide a class swapping feature.
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```ts
|
|
588
|
+
* class A { value = "a"; }
|
|
589
|
+
* class B { value = "b"; }
|
|
590
|
+
* class M { a = $inject(A); }
|
|
591
|
+
*
|
|
592
|
+
* Alepha.create().register({ provide: A, use: B }).get(M).a.value; // "b"
|
|
593
|
+
* ```
|
|
594
|
+
*
|
|
595
|
+
* > Swapping is an advanced feature that allows you to replace a class with another class.
|
|
596
|
+
* > It's useful for testing or for providing different implementations of a class.
|
|
597
|
+
*
|
|
598
|
+
* @param it - The class or type definitions to register in the container.
|
|
599
|
+
* @return The current instance of the container.
|
|
600
|
+
*/
|
|
601
|
+
register<T extends object>(it: ClassEntry<T> | Promise<{
|
|
602
|
+
default: Class<object>;
|
|
603
|
+
}>): this;
|
|
604
|
+
/**
|
|
605
|
+
* Alias for the 'register' method.
|
|
606
|
+
*
|
|
607
|
+
* @alias {Alepha#register}
|
|
608
|
+
*/
|
|
609
|
+
with: <T extends object>(it: ClassEntry<T> | Promise<{
|
|
610
|
+
default: Class<object>;
|
|
611
|
+
}>) => this;
|
|
612
|
+
/**
|
|
613
|
+
* Works like 'Alepha#register' but it must return the instance.
|
|
614
|
+
*
|
|
615
|
+
* @param entry - The class or type definition to retrieve or create.
|
|
616
|
+
* @param opts
|
|
617
|
+
* @param opts.parent - The parent class that requested the instance.
|
|
618
|
+
* @return The instance of the specified class or type.
|
|
619
|
+
*/
|
|
620
|
+
get<T extends object>(entry: ClassEntry<T>, opts?: {
|
|
621
|
+
parent?: Class | null;
|
|
622
|
+
skipCache?: boolean;
|
|
623
|
+
skipRegistration?: boolean;
|
|
624
|
+
args?: any[];
|
|
625
|
+
}): T;
|
|
626
|
+
on<T extends keyof Hooks>(event: T, hook: Hook<T>): () => void;
|
|
627
|
+
emit<T extends keyof Hooks>(func: keyof Hooks, payload: Hooks[T], options?: {
|
|
628
|
+
reverse?: boolean;
|
|
629
|
+
log?: boolean;
|
|
630
|
+
}): Promise<void>;
|
|
631
|
+
/**
|
|
632
|
+
* Casts the given value to the specified schema.
|
|
633
|
+
*
|
|
634
|
+
* It uses the TypeBox library to validate the value against the schema.
|
|
635
|
+
*
|
|
636
|
+
* @param schema - The schema to cast the value to.
|
|
637
|
+
* @param value - The value to cast.
|
|
638
|
+
* @param opts - default: true, clean: true, convert: true, decode: true, encode: false
|
|
639
|
+
*/
|
|
640
|
+
parse<T extends TSchema>(schema: T, value?: any, opts?: {
|
|
641
|
+
/**
|
|
642
|
+
* Clone the value before parsing.
|
|
643
|
+
* @default true
|
|
644
|
+
*/
|
|
645
|
+
clone?: boolean;
|
|
646
|
+
/**
|
|
647
|
+
* Apply default values defined in the schema.
|
|
648
|
+
* @default true
|
|
649
|
+
*/
|
|
650
|
+
default?: boolean;
|
|
651
|
+
/**
|
|
652
|
+
* Remove all values not defined in the schema.
|
|
653
|
+
* @default true
|
|
654
|
+
*/
|
|
655
|
+
clean?: boolean;
|
|
656
|
+
/**
|
|
657
|
+
* Try to cast/convert some data based on the schema.
|
|
658
|
+
* @default true
|
|
659
|
+
*/
|
|
660
|
+
convert?: boolean;
|
|
661
|
+
/**
|
|
662
|
+
* Prepare value after being deserialized.
|
|
663
|
+
* @default true
|
|
664
|
+
*/
|
|
665
|
+
check?: boolean;
|
|
666
|
+
}): Static<T>;
|
|
667
|
+
/**
|
|
668
|
+
* Applies environment variables to the provided schema and state object.
|
|
669
|
+
*
|
|
670
|
+
* It replaces also all templated $ENV inside string values.
|
|
671
|
+
*
|
|
672
|
+
* @param schema - The schema object to apply environment variables to.
|
|
673
|
+
* @return The schema object with environment variables applied.
|
|
674
|
+
*/
|
|
675
|
+
parseEnv<T extends TObject>(schema: T): Static<T>;
|
|
676
|
+
/**
|
|
677
|
+
* Returns all registered services that match the specified descriptor.
|
|
678
|
+
*
|
|
679
|
+
* @param descriptor
|
|
680
|
+
*/
|
|
681
|
+
getDescriptorValues<T extends Descriptor>(descriptor: T): Array<DescriptorItem<T>>;
|
|
682
|
+
/**
|
|
683
|
+
* Create a new instance of a logger.
|
|
684
|
+
*
|
|
685
|
+
* @returns The newly created logger instance.
|
|
686
|
+
*/
|
|
687
|
+
protected createLogger(env: Env): Logger;
|
|
688
|
+
/**
|
|
689
|
+
* Creates a new instance of a given class with dependency injection.
|
|
690
|
+
*
|
|
691
|
+
* @param definition - The class for which to create a new instance.
|
|
692
|
+
* @param args - The arguments to pass to the class constructor
|
|
693
|
+
* @returns The newly created instance of the given class.
|
|
694
|
+
*/
|
|
695
|
+
protected new<T extends object>(definition: Class<T>, args?: any[]): T;
|
|
696
|
+
/**
|
|
697
|
+
* Removes all useless dependencies.
|
|
698
|
+
*
|
|
699
|
+
* @protected
|
|
700
|
+
*/
|
|
701
|
+
protected removeUselessDependencies(): void;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Symbol to mark a value create from a provider.
|
|
706
|
+
*
|
|
707
|
+
* @internal
|
|
708
|
+
*/
|
|
709
|
+
declare const PROVIDER: unique symbol;
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Get the instance of the specified type from the context.
|
|
713
|
+
*
|
|
714
|
+
* - If the type is a class, it will be resolved from the context.
|
|
715
|
+
* - If the type is a schema, it will be parsed from the environment.
|
|
716
|
+
*
|
|
717
|
+
* ```ts
|
|
718
|
+
* class A { }
|
|
719
|
+
* class B {
|
|
720
|
+
* a = $inject(A);
|
|
721
|
+
* }
|
|
722
|
+
* ```
|
|
723
|
+
*
|
|
724
|
+
* @param type - Type (or TypeBox schema) to resolve
|
|
725
|
+
* @returns Instance of the specified type
|
|
726
|
+
*/
|
|
727
|
+
declare function $inject<T extends TObject>(type: T): Static<T>;
|
|
728
|
+
declare function $inject<T extends object>(type: Class<T>): T;
|
|
729
|
+
|
|
730
|
+
declare const $logger: (name?: string) => Logger;
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Retry Descriptor options.
|
|
734
|
+
*/
|
|
735
|
+
interface RetryDescriptorOptions<T extends (...args: any[]) => any> {
|
|
736
|
+
/**
|
|
737
|
+
*
|
|
738
|
+
*/
|
|
739
|
+
max?: number;
|
|
740
|
+
/**
|
|
741
|
+
*
|
|
742
|
+
*/
|
|
743
|
+
delay?: number;
|
|
744
|
+
/**
|
|
745
|
+
*
|
|
746
|
+
*/
|
|
747
|
+
when?: (error: Error) => boolean;
|
|
748
|
+
/**
|
|
749
|
+
*
|
|
750
|
+
*/
|
|
751
|
+
handler: T;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Retry descriptor.
|
|
755
|
+
*
|
|
756
|
+
* @param opts - Retry descriptor options.
|
|
757
|
+
* @returns A function that will retry the handler.
|
|
758
|
+
*/
|
|
759
|
+
declare const $retry: <T extends (...args: any[]) => any>(opts: RetryDescriptorOptions<T>) => ((...parameters: Parameters<T>) => Promise<ReturnType<T>>);
|
|
760
|
+
|
|
761
|
+
declare class AppNotStartedError extends Error {
|
|
762
|
+
constructor();
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
declare class CircularDependencyError extends Error {
|
|
766
|
+
constructor(provider: string, parents?: string[]);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
declare class ContainerLockedError extends Error {
|
|
770
|
+
constructor(message?: string);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
declare class NotImplementedError extends Error {
|
|
774
|
+
constructor(provider: string);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
declare class TypeBoxError extends Error {
|
|
778
|
+
readonly value: ValueError;
|
|
779
|
+
constructor(value: ValueError);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
interface EventEmitterItem<T extends object> {
|
|
783
|
+
name: keyof T;
|
|
784
|
+
handler: (arg: any) => Async<void>;
|
|
785
|
+
}
|
|
786
|
+
declare class EventEmitter<T extends object> {
|
|
787
|
+
protected events: EventEmitterItem<T>[];
|
|
788
|
+
/**
|
|
789
|
+
*
|
|
790
|
+
* @param name
|
|
791
|
+
* @param handler
|
|
792
|
+
*/
|
|
793
|
+
on<Key extends keyof T>(name: Key, handler: (arg: T[Key]) => void): () => void;
|
|
794
|
+
/**
|
|
795
|
+
*
|
|
796
|
+
* @param name
|
|
797
|
+
* @param data
|
|
798
|
+
*/
|
|
799
|
+
emit<Key extends keyof T>(name: Key, data: T[Key]): Promise<void>;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
declare class TypeProvider {
|
|
803
|
+
static DEFAULT_STRING_MAX_LENGTH: number;
|
|
804
|
+
static DEFAULT_LONG_STRING_MAX_LENGTH: number;
|
|
805
|
+
static DEFAULT_RICH_STRING_MAX_LENGTH: number;
|
|
806
|
+
static DEFAULT_ARRAY_MAX_ITEMS: number;
|
|
807
|
+
static FormatRegistry: typeof FormatRegistry;
|
|
808
|
+
Type: TypeBox.JavaScriptTypeBuilder;
|
|
809
|
+
any: (options?: SchemaOptions) => TypeBox.TAny;
|
|
810
|
+
void: (options?: SchemaOptions) => TypeBox.TVoid;
|
|
811
|
+
undefined: (options?: SchemaOptions) => TypeBox.TUndefined;
|
|
812
|
+
record: <Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options?: ObjectOptions) => TypeBox.TRecordOrObject<Key, Value>;
|
|
813
|
+
omit: {
|
|
814
|
+
<Type extends TSchema, Key extends PropertyKey[]>(type: Type, key: readonly [...Key], options?: SchemaOptions): TypeBox.TOmit<Type, Key>;
|
|
815
|
+
<Type extends TSchema, Key extends TSchema>(type: Type, key: Key, options?: SchemaOptions): TypeBox.TOmit<Type, Key>;
|
|
816
|
+
};
|
|
817
|
+
union: <Types extends TSchema[]>(types: [...Types], options?: SchemaOptions) => Union<Types>;
|
|
818
|
+
partial: {
|
|
819
|
+
<MappedResult extends TypeBox.TMappedResult>(type: MappedResult, options?: SchemaOptions): TypeBox.TPartialFromMappedResult<MappedResult>;
|
|
820
|
+
<Type extends TSchema>(type: Type, options?: SchemaOptions): TypeBox.TPartial<Type>;
|
|
821
|
+
};
|
|
822
|
+
composite: <T extends TSchema[]>(schemas: [...T], options?: ObjectOptions) => TypeBox.TComposite<T>;
|
|
823
|
+
pick: {
|
|
824
|
+
<Type extends TSchema, Key extends PropertyKey[]>(type: Type, key: readonly [...Key], options?: SchemaOptions): TypeBox.TPick<Type, Key>;
|
|
825
|
+
<Type extends TSchema, Key extends TSchema>(type: Type, key: Key, options?: SchemaOptions): TypeBox.TPick<Type, Key>;
|
|
826
|
+
};
|
|
827
|
+
clean: typeof TypeBoxValue.Clean;
|
|
828
|
+
/**
|
|
829
|
+
* Create a schema for an object.
|
|
830
|
+
*
|
|
831
|
+
* @param properties The properties of the object.
|
|
832
|
+
* @param options The options for the object.
|
|
833
|
+
*/
|
|
834
|
+
object: <T extends TProperties>(properties: T, options?: ObjectOptions) => TObject<T>;
|
|
835
|
+
/**
|
|
836
|
+
* Create a schema for an array.
|
|
837
|
+
*
|
|
838
|
+
* @param schema
|
|
839
|
+
* @param options
|
|
840
|
+
*/
|
|
841
|
+
array: <T extends TSchema>(schema: T, options?: ArrayOptions) => TArray<T>;
|
|
842
|
+
/**
|
|
843
|
+
* Create a schema for a string.
|
|
844
|
+
*
|
|
845
|
+
* @param options
|
|
846
|
+
*/
|
|
847
|
+
string: (options?: AlephaStringOptions) => TString;
|
|
848
|
+
/**
|
|
849
|
+
* Create a schema for a JSON object.
|
|
850
|
+
*
|
|
851
|
+
* @param options
|
|
852
|
+
*/
|
|
853
|
+
json: (options?: SchemaOptions) => TypeBox.TRecord<TString, TypeBox.TAny>;
|
|
854
|
+
/**
|
|
855
|
+
* Create a schema for a boolean.
|
|
856
|
+
*
|
|
857
|
+
* @param options
|
|
858
|
+
*/
|
|
859
|
+
boolean: (options?: SchemaOptions) => TBoolean;
|
|
860
|
+
/**
|
|
861
|
+
* Create a schema for a number.
|
|
862
|
+
*
|
|
863
|
+
* @param options
|
|
864
|
+
*/
|
|
865
|
+
number: (options?: NumberOptions) => TNumber;
|
|
866
|
+
/**
|
|
867
|
+
* Create a schema for an unsigned 8-bit integer.
|
|
868
|
+
*
|
|
869
|
+
* @param options
|
|
870
|
+
*/
|
|
871
|
+
uchar: (options?: IntegerOptions) => TInteger;
|
|
872
|
+
/**
|
|
873
|
+
* Create a schema for an unsigned 32-bit integer.
|
|
874
|
+
*
|
|
875
|
+
* @param options
|
|
876
|
+
*/
|
|
877
|
+
uint: (options?: IntegerOptions) => TNumber;
|
|
878
|
+
/**
|
|
879
|
+
* Create a schema for a signed 32-bit integer.
|
|
880
|
+
*
|
|
881
|
+
* @param options
|
|
882
|
+
*/
|
|
883
|
+
int: (options?: IntegerOptions) => TInteger;
|
|
884
|
+
/**
|
|
885
|
+
* Make a schema optional.
|
|
886
|
+
*
|
|
887
|
+
* @param schema The schema to make optional.
|
|
888
|
+
*/
|
|
889
|
+
optional: <T extends TSchema>(schema: T) => TOptionalWithFlag<T, true>;
|
|
890
|
+
/**
|
|
891
|
+
* Nullify all properties of a schema.
|
|
892
|
+
*
|
|
893
|
+
* @param schema The schema to nullify.
|
|
894
|
+
* @param options The options for the schema.
|
|
895
|
+
*/
|
|
896
|
+
nullify: <T extends TSchema>(schema: T, options?: ObjectOptions) => TObject<TypeBox.Evaluate<TypeBox.TMappedFunctionReturnType<TypeBox.TIndexPropertyKeys<TypeBox.TKeyOf<T>>, TypeBox.TUnion<[TNull, TypeBox.TMappedResult<TypeBox.Evaluate<TypeBox.TIndexPropertyKeys<TypeBox.TKeyOf<T>> extends infer T_1 ? T_1 extends TypeBox.TIndexPropertyKeys<TypeBox.TKeyOf<T>> ? T_1 extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? /*elided*/ any : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema>; } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema>; } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema>; } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema>; } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema>; } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema>; } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema>; } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema>; } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema>; } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema>; } : {} : never : never>>]>, {}>>>;
|
|
897
|
+
/**
|
|
898
|
+
* Make a schema nullable.
|
|
899
|
+
*
|
|
900
|
+
* @param schema The schema to make nullable.
|
|
901
|
+
* @param options The options for the schema.
|
|
902
|
+
*/
|
|
903
|
+
nullable: <T extends TSchema>(schema: T, options?: ObjectOptions) => Union<[TNull, T]>;
|
|
904
|
+
/**
|
|
905
|
+
* Map a schema to another schema.
|
|
906
|
+
*
|
|
907
|
+
* @param schema The schema to map.
|
|
908
|
+
* @param operations The operations to perform on the schema.
|
|
909
|
+
* @param options The options for the schema.
|
|
910
|
+
* @returns The mapped schema.
|
|
911
|
+
*/
|
|
912
|
+
map: <T extends TObject | TIntersect, Omit extends (keyof T["properties"])[], Optional extends (keyof T["properties"])[]>(schema: T, operations: {
|
|
913
|
+
omit: readonly [...Omit];
|
|
914
|
+
optional: [...Optional];
|
|
915
|
+
}, options?: ObjectOptions) => TObject<TypeBox.Evaluate<TypeBox.TSetDistinct<[...TypeBox.TKeyOfPropertyKeys<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_1 ? T_1 extends [...Omit, ...Optional] ? T_1 extends TypeBox.TRef<string> ? true : false : never : never>>, ...TypeBox.TKeyOfPropertyKeys<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>>], []> extends infer T_2 ? T_2 extends TypeBox.TSetDistinct<[...TypeBox.TKeyOfPropertyKeys<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_53 ? T_53 extends [...Omit, ...Optional] ? T_53 extends TypeBox.TRef<string> ? true : false : never : never>>, ...TypeBox.TKeyOfPropertyKeys<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>>], []> ? T_2 extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? /*elided*/ any : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_3 ? T_3 extends [...Omit, ...Optional] ? T_3 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> extends infer T_4 ? T_4 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_7 ? T_7 extends [...Omit, ...Optional] ? T_7 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> ? T_4 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_5 ? T_5 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_5 extends TypeBox.TNever ? [] : [T_5] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_6 ? T_6 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_6 extends TypeBox.TNever ? [T_4] : [T_4, T_6] : never : never : never : never>; } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_8 ? T_8 extends [...Omit, ...Optional] ? T_8 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> extends infer T_9 ? T_9 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_12 ? T_12 extends [...Omit, ...Optional] ? T_12 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> ? T_9 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_10 ? T_10 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_10 extends TypeBox.TNever ? [] : [T_10] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_11 ? T_11 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_11 extends TypeBox.TNever ? [T_9] : [T_9, T_11] : never : never : never : never>; } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_13 ? T_13 extends [...Omit, ...Optional] ? T_13 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> extends infer T_14 ? T_14 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_17 ? T_17 extends [...Omit, ...Optional] ? T_17 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> ? T_14 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_15 ? T_15 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_15 extends TypeBox.TNever ? [] : [T_15] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_16 ? T_16 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_16 extends TypeBox.TNever ? [T_14] : [T_14, T_16] : never : never : never : never>; } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_18 ? T_18 extends [...Omit, ...Optional] ? T_18 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> extends infer T_19 ? T_19 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_22 ? T_22 extends [...Omit, ...Optional] ? T_22 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> ? T_19 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_20 ? T_20 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_20 extends TypeBox.TNever ? [] : [T_20] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_21 ? T_21 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_21 extends TypeBox.TNever ? [T_19] : [T_19, T_21] : never : never : never : never>; } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_23 ? T_23 extends [...Omit, ...Optional] ? T_23 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> extends infer T_24 ? T_24 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_27 ? T_27 extends [...Omit, ...Optional] ? T_27 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> ? T_24 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_25 ? T_25 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_25 extends TypeBox.TNever ? [] : [T_25] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_26 ? T_26 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_26 extends TypeBox.TNever ? [T_24] : [T_24, T_26] : never : never : never : never>; } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_28 ? T_28 extends [...Omit, ...Optional] ? T_28 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> extends infer T_29 ? T_29 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_32 ? T_32 extends [...Omit, ...Optional] ? T_32 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> ? T_29 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_30 ? T_30 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_30 extends TypeBox.TNever ? [] : [T_30] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_31 ? T_31 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_31 extends TypeBox.TNever ? [T_29] : [T_29, T_31] : never : never : never : never>; } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_33 ? T_33 extends [...Omit, ...Optional] ? T_33 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> extends infer T_34 ? T_34 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_37 ? T_37 extends [...Omit, ...Optional] ? T_37 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> ? T_34 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_35 ? T_35 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_35 extends TypeBox.TNever ? [] : [T_35] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_36 ? T_36 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_36 extends TypeBox.TNever ? [T_34] : [T_34, T_36] : never : never : never : never>; } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_38 ? T_38 extends [...Omit, ...Optional] ? T_38 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> extends infer T_39 ? T_39 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_42 ? T_42 extends [...Omit, ...Optional] ? T_42 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> ? T_39 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_40 ? T_40 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_40 extends TypeBox.TNever ? [] : [T_40] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_41 ? T_41 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_41 extends TypeBox.TNever ? [T_39] : [T_39, T_41] : never : never : never : never>; } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_43 ? T_43 extends [...Omit, ...Optional] ? T_43 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> extends infer T_44 ? T_44 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_47 ? T_47 extends [...Omit, ...Optional] ? T_47 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> ? T_44 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_45 ? T_45 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_45 extends TypeBox.TNever ? [] : [T_45] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_46 ? T_46 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_46 extends TypeBox.TNever ? [T_44] : [T_44, T_46] : never : never : never : never>; } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_48 ? T_48 extends [...Omit, ...Optional] ? T_48 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> extends infer T_49 ? T_49 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_52 ? T_52 extends [...Omit, ...Optional] ? T_52 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema> ? T_49 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_50 ? T_50 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_50 extends TypeBox.TNever ? [] : [T_50] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> extends infer T_51 ? T_51 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema> ? T_51 extends TypeBox.TNever ? [T_49] : [T_49, T_51] : never : never : never : never>; } : {} : never : never>>;
|
|
916
|
+
/**
|
|
917
|
+
* Create a schema for a string enum.
|
|
918
|
+
*
|
|
919
|
+
* @param values
|
|
920
|
+
* @param options
|
|
921
|
+
*/
|
|
922
|
+
enum: <T extends string[]>(values: [...T], options?: StringOptions) => TUnsafe<T[number]>;
|
|
923
|
+
/**
|
|
924
|
+
* Create a schema for a string enum e.g. LIKE_THIS.
|
|
925
|
+
*
|
|
926
|
+
* @param options
|
|
927
|
+
*/
|
|
928
|
+
snakeCase: (options?: StringOptions) => TString;
|
|
929
|
+
/**
|
|
930
|
+
* Create a schema for an object with a value and label.
|
|
931
|
+
*
|
|
932
|
+
* @param options
|
|
933
|
+
*/
|
|
934
|
+
valueLabel: (options?: ObjectOptions) => TObject<{
|
|
935
|
+
value: TString;
|
|
936
|
+
label: TString;
|
|
937
|
+
description: TypeBox.TOptional<TString>;
|
|
938
|
+
}>;
|
|
939
|
+
/**
|
|
940
|
+
* Create a schema for a datetime.
|
|
941
|
+
*
|
|
942
|
+
* @param options The options for the date.
|
|
943
|
+
*/
|
|
944
|
+
datetime: (options?: StringOptions) => TString;
|
|
945
|
+
/**
|
|
946
|
+
* Create a schema for a date.
|
|
947
|
+
*
|
|
948
|
+
* @param options
|
|
949
|
+
*/
|
|
950
|
+
date: (options?: StringOptions) => TString;
|
|
951
|
+
/**
|
|
952
|
+
* Create a schema for uuid.
|
|
953
|
+
*
|
|
954
|
+
* @param options The options for the duration.
|
|
955
|
+
*/
|
|
956
|
+
uuid: (options?: StringOptions) => TString;
|
|
957
|
+
/**
|
|
958
|
+
*
|
|
959
|
+
*
|
|
960
|
+
* @param kind
|
|
961
|
+
* @param options
|
|
962
|
+
*/
|
|
963
|
+
unsafe: <T>(kind: string, options?: UnsafeOptions) => TUnsafe<T>;
|
|
964
|
+
file: (options?: {
|
|
965
|
+
max?: number;
|
|
966
|
+
}) => TFile;
|
|
967
|
+
stream: () => TStream;
|
|
968
|
+
}
|
|
969
|
+
interface FileLike {
|
|
970
|
+
name: string;
|
|
971
|
+
type: string;
|
|
972
|
+
size: number;
|
|
973
|
+
lastModified: number;
|
|
974
|
+
stream(): StreamLike;
|
|
975
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
976
|
+
text(): Promise<string>;
|
|
977
|
+
filepath?: string;
|
|
978
|
+
}
|
|
979
|
+
type TFile = TUnsafe<FileLike>;
|
|
980
|
+
type StreamLike = ReadableStream | ReadableStream$1 | Readable;
|
|
981
|
+
type TStream = TUnsafe<StreamLike>;
|
|
982
|
+
declare const t: TypeProvider;
|
|
983
|
+
declare const isTypeFile: (value: TSchema) => value is TFile;
|
|
984
|
+
declare const isFileLike: (value: any) => value is FileLike;
|
|
985
|
+
declare const isTypeStream: (value: TSchema) => value is TStream;
|
|
986
|
+
type TextLength = "short" | "long" | "rich";
|
|
987
|
+
interface AlephaStringOptions extends StringOptions {
|
|
988
|
+
size?: TextLength;
|
|
989
|
+
}
|
|
990
|
+
declare const isUUID: (value: string) => boolean;
|
|
991
|
+
|
|
992
|
+
declare const run: (arg: Alepha | Class | ((env?: Env) => Alepha), opts?: {
|
|
993
|
+
env?: Env;
|
|
994
|
+
configure?: (alepha: Alepha) => Async<void>;
|
|
995
|
+
ready?: (alepha: Alepha) => Async<void>;
|
|
996
|
+
}) => Alepha;
|
|
997
|
+
|
|
998
|
+
export { $cursor, $hook, $inject, $logger, $retry, Alepha, type AlephaStringOptions, AppNotStartedError, type Async, type AsyncFn, type AsyncLocalStorageData, AsyncLocalStorageProvider, COLORS, CircularDependencyError, type Class, type ClassEntry, type ClassProvider, type ClassSwap, ContainerLockedError, type CursorDescriptor, type Descriptor, type DescriptorIdentifier, type DescriptorItem, type Env, EventEmitter, type EventEmitterItem, EventEmitterLike, type FileLike, type Hook, type HookDescriptor, type HookOptions, type Hooks, KIND, LEVEL_COLORS, type LogLevel, Logger, type LoggerEnv, type LoggerOptions, MockLogger, type MockLoggerStore, NotImplementedError, OPTIONS, PROVIDER, type PromiseFn, type RetryDescriptorOptions, type State, type StreamLike, type TFile, type TStream, type TextLength, TypeBoxError, TypeProvider, __alephaRef, __bind, __descriptor, descriptorEvents, isDescriptorValue, isFileLike, isTypeFile, isTypeStream, isUUID, run, t };
|