@celerity-sdk/core 0.2.0
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/LICENSE +201 -0
- package/README.md +122 -0
- package/dist/index.cjs +2002 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +433 -0
- package/dist/index.d.ts +433 -0
- package/dist/index.js +1885 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import { Schema, Type, CelerityLayer, InjectionToken, ModuleMetadata, HandlerContext, HandlerResponse, HandlerMetadata, ServiceContainer, Provider, HttpRequest, HttpResponse, FunctionHandlerDefinition, HttpMethod, CelerityLogger } from '@celerity-sdk/types';
|
|
2
|
+
export { CelerityLayer, FunctionHandlerDefinition, HandlerContext, HandlerMetadata, HandlerResponse, HttpMethod, HttpRequest, HttpResponse, InjectionToken, ModuleMetadata, Provider, Schema, ServiceContainer, Type } from '@celerity-sdk/types';
|
|
3
|
+
import { Request, Response } from '@celerity-sdk/runtime';
|
|
4
|
+
|
|
5
|
+
type ControllerMetadata = {
|
|
6
|
+
prefix?: string;
|
|
7
|
+
};
|
|
8
|
+
declare function Controller(prefix?: string): ClassDecorator;
|
|
9
|
+
|
|
10
|
+
declare function Get(path?: string): MethodDecorator;
|
|
11
|
+
declare function Post(path?: string): MethodDecorator;
|
|
12
|
+
declare function Put(path?: string): MethodDecorator;
|
|
13
|
+
declare function Patch(path?: string): MethodDecorator;
|
|
14
|
+
declare function Delete(path?: string): MethodDecorator;
|
|
15
|
+
declare function Head(path?: string): MethodDecorator;
|
|
16
|
+
declare function Options(path?: string): MethodDecorator;
|
|
17
|
+
|
|
18
|
+
type ParamType = "body" | "query" | "param" | "headers" | "auth" | "request" | "cookies" | "requestId";
|
|
19
|
+
type ParamMetadata = {
|
|
20
|
+
index: number;
|
|
21
|
+
type: ParamType;
|
|
22
|
+
key?: string;
|
|
23
|
+
schema?: Schema;
|
|
24
|
+
};
|
|
25
|
+
declare function Body(schema?: Schema): ParameterDecorator;
|
|
26
|
+
declare function Query(): ParameterDecorator;
|
|
27
|
+
declare function Query(key: string): ParameterDecorator;
|
|
28
|
+
declare function Query(schema: Schema): ParameterDecorator;
|
|
29
|
+
declare function Query(key: string, schema: Schema): ParameterDecorator;
|
|
30
|
+
declare function Param(): ParameterDecorator;
|
|
31
|
+
declare function Param(key: string): ParameterDecorator;
|
|
32
|
+
declare function Param(schema: Schema): ParameterDecorator;
|
|
33
|
+
declare function Param(key: string, schema: Schema): ParameterDecorator;
|
|
34
|
+
declare function Headers(): ParameterDecorator;
|
|
35
|
+
declare function Headers(key: string): ParameterDecorator;
|
|
36
|
+
declare function Headers(schema: Schema): ParameterDecorator;
|
|
37
|
+
declare function Headers(key: string, schema: Schema): ParameterDecorator;
|
|
38
|
+
declare function Auth(): ParameterDecorator;
|
|
39
|
+
declare function Req(): ParameterDecorator;
|
|
40
|
+
declare function Cookies(key?: string): ParameterDecorator;
|
|
41
|
+
declare function RequestId(): ParameterDecorator;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Marks a handler class as a custom guard implementation.
|
|
45
|
+
* The handler IS the guard — in serverless it becomes a Lambda Authorizer,
|
|
46
|
+
* in containers the Rust runtime invokes it before protected handlers.
|
|
47
|
+
*
|
|
48
|
+
* Other handlers reference this guard via `@ProtectedBy("name")`.
|
|
49
|
+
*/
|
|
50
|
+
declare function Guard(name: string): ClassDecorator;
|
|
51
|
+
/**
|
|
52
|
+
* Declares that a handler or method is protected by one or more named guards.
|
|
53
|
+
* Multiple `@ProtectedBy` decorators accumulate in declaration order (top-to-bottom).
|
|
54
|
+
*
|
|
55
|
+
* Can be applied at class level (all methods) or method level.
|
|
56
|
+
*/
|
|
57
|
+
declare function ProtectedBy(name: string): (target: object, propertyKey?: string | symbol, _descriptor?: PropertyDescriptor) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Marks a method as public, opting out of the default guard.
|
|
60
|
+
*/
|
|
61
|
+
declare function Public(): MethodDecorator;
|
|
62
|
+
|
|
63
|
+
declare function UseLayer(...layers: (Type<CelerityLayer> | CelerityLayer)[]): (target: object, propertyKey?: string | symbol, _descriptor?: PropertyDescriptor) => void;
|
|
64
|
+
declare function UseLayers(layers: (Type<CelerityLayer> | CelerityLayer)[]): (target: object, propertyKey?: string | symbol, _descriptor?: PropertyDescriptor) => void;
|
|
65
|
+
|
|
66
|
+
declare function SetMetadata(key: string, value: unknown): (target: object, propertyKey?: string | symbol, _descriptor?: PropertyDescriptor) => void;
|
|
67
|
+
declare function Action(value: unknown): (target: object, propertyKey?: string | symbol, _descriptor?: PropertyDescriptor) => void;
|
|
68
|
+
|
|
69
|
+
declare function Injectable(): ClassDecorator;
|
|
70
|
+
declare function Inject(token: InjectionToken): ParameterDecorator;
|
|
71
|
+
|
|
72
|
+
declare function Module(metadata: ModuleMetadata): ClassDecorator;
|
|
73
|
+
|
|
74
|
+
type ValidationSchemas = {
|
|
75
|
+
body?: Schema;
|
|
76
|
+
params?: Schema;
|
|
77
|
+
query?: Schema;
|
|
78
|
+
headers?: Schema;
|
|
79
|
+
};
|
|
80
|
+
declare function validate(schemas: ValidationSchemas): CelerityLayer;
|
|
81
|
+
|
|
82
|
+
declare function runLayerPipeline(layers: (CelerityLayer | Type<CelerityLayer>)[], context: HandlerContext, handler: () => Promise<HandlerResponse>): Promise<HandlerResponse>;
|
|
83
|
+
|
|
84
|
+
declare function createDefaultSystemLayers(): Promise<CelerityLayer[]>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Disposes an array of layers in reverse order.
|
|
88
|
+
* Skips class references (Type<CelerityLayer>) — only instances with a
|
|
89
|
+
* `dispose` method are called. Errors are non-fatal; disposal continues
|
|
90
|
+
* for remaining layers.
|
|
91
|
+
*/
|
|
92
|
+
declare function disposeLayers(layers: (CelerityLayer | Type<CelerityLayer>)[]): Promise<void>;
|
|
93
|
+
|
|
94
|
+
declare class HandlerMetadataStore implements HandlerMetadata {
|
|
95
|
+
private readonly decoratorData;
|
|
96
|
+
private readonly requestData;
|
|
97
|
+
constructor(decoratorMetadata: Record<string, unknown>);
|
|
98
|
+
get<T = unknown>(key: string): T | undefined;
|
|
99
|
+
set(key: string, value: unknown): void;
|
|
100
|
+
has(key: string): boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare function tokenToString(token: InjectionToken): string;
|
|
104
|
+
type AnyProvider = Provider<any>;
|
|
105
|
+
declare class Container implements ServiceContainer {
|
|
106
|
+
private providers;
|
|
107
|
+
private instances;
|
|
108
|
+
private resolving;
|
|
109
|
+
private edges;
|
|
110
|
+
private closeStack;
|
|
111
|
+
private trackedTokens;
|
|
112
|
+
register<T>(token: InjectionToken, provider: Provider<T>): void;
|
|
113
|
+
registerClass<T>(target: Type<T>): void;
|
|
114
|
+
registerValue<T>(token: InjectionToken, value: T): void;
|
|
115
|
+
resolve<T>(token: InjectionToken): Promise<T>;
|
|
116
|
+
resolveClass<T>(target: Type<T>): Promise<T>;
|
|
117
|
+
has(token: InjectionToken): boolean;
|
|
118
|
+
getDependencies(token: InjectionToken): ReadonlySet<InjectionToken>;
|
|
119
|
+
closeAll(): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Validates that all registered providers have resolvable dependencies.
|
|
122
|
+
* Call after all module providers are registered but before resolution.
|
|
123
|
+
* Throws a descriptive error listing ALL missing dependencies at once.
|
|
124
|
+
*/
|
|
125
|
+
validateDependencies(): void;
|
|
126
|
+
getClassDependencyTokens(target: Type): InjectionToken[];
|
|
127
|
+
getProviderDependencyTokens(provider: AnyProvider): InjectionToken[];
|
|
128
|
+
/**
|
|
129
|
+
* Constructs a class by resolving constructor dependencies via design:paramtypes.
|
|
130
|
+
* Does NOT manage the resolving set — callers (resolve/resolveClass) own cycle detection.
|
|
131
|
+
*/
|
|
132
|
+
private constructClass;
|
|
133
|
+
private recordEdges;
|
|
134
|
+
private trackCloseable;
|
|
135
|
+
private createFromProvider;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Reads reflect-metadata to determine the constructor dependency tokens for a class.
|
|
140
|
+
* Applies @Inject() overrides where present.
|
|
141
|
+
*
|
|
142
|
+
* Pure function — reads metadata only, no container side effects.
|
|
143
|
+
*/
|
|
144
|
+
declare function getClassDependencyTokens(target: Type): InjectionToken[];
|
|
145
|
+
/**
|
|
146
|
+
* Determines the dependency tokens for a provider (class, factory, or value).
|
|
147
|
+
*
|
|
148
|
+
* Pure function — reads metadata only, no container side effects.
|
|
149
|
+
*/
|
|
150
|
+
declare function getProviderDependencyTokens(provider: Provider<any>): InjectionToken[];
|
|
151
|
+
|
|
152
|
+
declare const APP_CONFIG: unique symbol;
|
|
153
|
+
declare const RUNTIME_APP: unique symbol;
|
|
154
|
+
|
|
155
|
+
type ResolvedHandler = {
|
|
156
|
+
path?: string;
|
|
157
|
+
method?: string;
|
|
158
|
+
protectedBy: string[];
|
|
159
|
+
layers: (CelerityLayer | Type<CelerityLayer>)[];
|
|
160
|
+
isPublic: boolean;
|
|
161
|
+
paramMetadata: ParamMetadata[];
|
|
162
|
+
customMetadata: Record<string, unknown>;
|
|
163
|
+
handlerFn: (...args: unknown[]) => unknown;
|
|
164
|
+
handlerInstance?: object;
|
|
165
|
+
isFunctionHandler?: boolean;
|
|
166
|
+
injectTokens?: InjectionToken[];
|
|
167
|
+
};
|
|
168
|
+
type PipelineOptions = {
|
|
169
|
+
container: ServiceContainer;
|
|
170
|
+
systemLayers?: (CelerityLayer | Type<CelerityLayer>)[];
|
|
171
|
+
appLayers?: (CelerityLayer | Type<CelerityLayer>)[];
|
|
172
|
+
};
|
|
173
|
+
declare function executeHandlerPipeline(handler: ResolvedHandler, request: HttpRequest, options: PipelineOptions): Promise<HttpResponse>;
|
|
174
|
+
|
|
175
|
+
type ModuleNode = {
|
|
176
|
+
moduleClass: Type;
|
|
177
|
+
ownTokens: Set<InjectionToken>;
|
|
178
|
+
exports: Set<InjectionToken>;
|
|
179
|
+
imports: Type[];
|
|
180
|
+
controllers: Type[];
|
|
181
|
+
functionHandlers: FunctionHandlerDefinition[];
|
|
182
|
+
providers: (Type | (Provider & {
|
|
183
|
+
provide: InjectionToken;
|
|
184
|
+
}))[];
|
|
185
|
+
};
|
|
186
|
+
type ModuleGraph = Map<Type, ModuleNode>;
|
|
187
|
+
/**
|
|
188
|
+
* Builds a module graph by walking the module tree depth-first, collecting
|
|
189
|
+
* all metadata into a graph structure without any side effects.
|
|
190
|
+
*
|
|
191
|
+
* Detects circular module imports and deduplicates visited modules.
|
|
192
|
+
*/
|
|
193
|
+
declare function buildModuleGraph(rootModule: Type): ModuleGraph;
|
|
194
|
+
/**
|
|
195
|
+
* Registers all providers and controllers from the module graph into the
|
|
196
|
+
* DI container.
|
|
197
|
+
*/
|
|
198
|
+
declare function registerModuleGraph(graph: ModuleGraph, container: Container): void;
|
|
199
|
+
|
|
200
|
+
declare class HandlerRegistry {
|
|
201
|
+
private handlers;
|
|
202
|
+
getHandler(path: string, method: string): ResolvedHandler | undefined;
|
|
203
|
+
getAllHandlers(): ResolvedHandler[];
|
|
204
|
+
populateFromGraph(graph: ModuleGraph, container: Container): Promise<void>;
|
|
205
|
+
scanModule(moduleClass: Type, container: Container): Promise<void>;
|
|
206
|
+
private registerClassHandler;
|
|
207
|
+
private registerFunctionHandler;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
declare class CelerityApplication {
|
|
211
|
+
private registry;
|
|
212
|
+
private container;
|
|
213
|
+
private systemLayers;
|
|
214
|
+
private appLayers;
|
|
215
|
+
private runtimeApp?;
|
|
216
|
+
constructor(registry: HandlerRegistry, container: Container, systemLayers?: (CelerityLayer | Type<CelerityLayer>)[], appLayers?: (CelerityLayer | Type<CelerityLayer>)[], runtimeApp?: unknown | undefined);
|
|
217
|
+
start(): Promise<void>;
|
|
218
|
+
close(): Promise<void>;
|
|
219
|
+
getContainer(): Container;
|
|
220
|
+
getRegistry(): HandlerRegistry;
|
|
221
|
+
getSystemLayers(): (CelerityLayer | Type<CelerityLayer>)[];
|
|
222
|
+
getAppLayers(): (CelerityLayer | Type<CelerityLayer>)[];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
type ServerlessHandler = (event: unknown, context: unknown) => Promise<unknown>;
|
|
226
|
+
interface ServerlessAdapter {
|
|
227
|
+
createHandler(registry: HandlerRegistry, options: PipelineOptions): ServerlessHandler;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
declare class ServerlessApplication {
|
|
231
|
+
private registry;
|
|
232
|
+
private container;
|
|
233
|
+
private adapter;
|
|
234
|
+
private systemLayers;
|
|
235
|
+
private appLayers;
|
|
236
|
+
private handler;
|
|
237
|
+
constructor(registry: HandlerRegistry, container: Container, adapter: ServerlessAdapter, systemLayers?: (CelerityLayer | Type<CelerityLayer>)[], appLayers?: (CelerityLayer | Type<CelerityLayer>)[]);
|
|
238
|
+
start(): Promise<ServerlessHandler>;
|
|
239
|
+
close(): Promise<void>;
|
|
240
|
+
getHandler(): ServerlessHandler;
|
|
241
|
+
getContainer(): Container;
|
|
242
|
+
getRegistry(): HandlerRegistry;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
declare class TestingApplication {
|
|
246
|
+
private registry;
|
|
247
|
+
private container;
|
|
248
|
+
private systemLayers;
|
|
249
|
+
private appLayers;
|
|
250
|
+
constructor(registry: HandlerRegistry, container: Container, systemLayers?: (CelerityLayer | Type<CelerityLayer>)[], appLayers?: (CelerityLayer | Type<CelerityLayer>)[]);
|
|
251
|
+
inject(request: HttpRequest): Promise<HttpResponse>;
|
|
252
|
+
getContainer(): Container;
|
|
253
|
+
getRegistry(): HandlerRegistry;
|
|
254
|
+
}
|
|
255
|
+
type MockRequestOptions = {
|
|
256
|
+
pathParams?: Record<string, string>;
|
|
257
|
+
query?: Record<string, string | string[]>;
|
|
258
|
+
headers?: Record<string, string | string[]>;
|
|
259
|
+
cookies?: Record<string, string>;
|
|
260
|
+
body?: unknown;
|
|
261
|
+
auth?: Record<string, unknown>;
|
|
262
|
+
requestId?: string;
|
|
263
|
+
clientIp?: string;
|
|
264
|
+
};
|
|
265
|
+
declare function mockRequest(method: HttpMethod, path: string, options?: MockRequestOptions): HttpRequest;
|
|
266
|
+
|
|
267
|
+
type CreateOptions = {
|
|
268
|
+
adapter?: ServerlessAdapter;
|
|
269
|
+
/** App-wide layers that run after system layers but before handler layers. */
|
|
270
|
+
layers?: (CelerityLayer | Type<CelerityLayer>)[];
|
|
271
|
+
/**
|
|
272
|
+
* Override the default system layer stack.
|
|
273
|
+
* @internal Used by TestingApplication and runtime orchestrator.
|
|
274
|
+
*/
|
|
275
|
+
systemLayers?: (CelerityLayer | Type<CelerityLayer>)[];
|
|
276
|
+
};
|
|
277
|
+
declare class CelerityFactory {
|
|
278
|
+
static create(rootModule: Type, options?: CreateOptions): Promise<CelerityApplication | ServerlessApplication>;
|
|
279
|
+
static createTestingApp(rootModule: Type, options?: CreateOptions): Promise<TestingApplication>;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
type HttpHandlerRequest<TBody = unknown> = {
|
|
283
|
+
method: HttpMethod;
|
|
284
|
+
path: string;
|
|
285
|
+
params: Record<string, string>;
|
|
286
|
+
query: Record<string, string | string[]>;
|
|
287
|
+
body: TBody;
|
|
288
|
+
headers: Record<string, string | string[]>;
|
|
289
|
+
cookies: Record<string, string>;
|
|
290
|
+
auth: Record<string, unknown> | null;
|
|
291
|
+
clientIp: string | null;
|
|
292
|
+
userAgent: string | null;
|
|
293
|
+
contentType: string | null;
|
|
294
|
+
};
|
|
295
|
+
type HttpHandlerContext = {
|
|
296
|
+
requestId: string;
|
|
297
|
+
requestTime: string;
|
|
298
|
+
metadata: HandlerMetadata;
|
|
299
|
+
container: ServiceContainer;
|
|
300
|
+
/** Request-scoped logger set by TelemetryLayer. */
|
|
301
|
+
logger?: CelerityLogger;
|
|
302
|
+
raw: HttpRequest;
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
type HttpHandlerConfig<TBody = unknown> = {
|
|
306
|
+
path?: string;
|
|
307
|
+
method?: HttpMethod;
|
|
308
|
+
schema?: {
|
|
309
|
+
body?: Schema<TBody>;
|
|
310
|
+
query?: Schema;
|
|
311
|
+
params?: Schema;
|
|
312
|
+
headers?: Schema;
|
|
313
|
+
};
|
|
314
|
+
layers?: (CelerityLayer | Type<CelerityLayer>)[];
|
|
315
|
+
inject?: InjectionToken[];
|
|
316
|
+
metadata?: Record<string, unknown>;
|
|
317
|
+
};
|
|
318
|
+
type HttpHandlerOptions<TBody = unknown> = Omit<HttpHandlerConfig<TBody>, "path" | "method">;
|
|
319
|
+
type HttpHandlerFn<TBody = unknown> = (req: HttpHandlerRequest<TBody>, ctx: HttpHandlerContext, ...deps: unknown[]) => unknown;
|
|
320
|
+
declare function createHttpHandler<TBody = unknown>(config: HttpHandlerConfig<TBody>, handler: HttpHandlerFn<TBody>): FunctionHandlerDefinition;
|
|
321
|
+
declare function httpGet(path: string, handler: HttpHandlerFn): FunctionHandlerDefinition;
|
|
322
|
+
declare function httpGet(path: string, options: HttpHandlerOptions, handler: HttpHandlerFn): FunctionHandlerDefinition;
|
|
323
|
+
declare function httpPost(path: string, handler: HttpHandlerFn): FunctionHandlerDefinition;
|
|
324
|
+
declare function httpPost<TBody = unknown>(path: string, options: HttpHandlerOptions<TBody>, handler: HttpHandlerFn<TBody>): FunctionHandlerDefinition;
|
|
325
|
+
declare function httpPut(path: string, handler: HttpHandlerFn): FunctionHandlerDefinition;
|
|
326
|
+
declare function httpPut<TBody = unknown>(path: string, options: HttpHandlerOptions<TBody>, handler: HttpHandlerFn<TBody>): FunctionHandlerDefinition;
|
|
327
|
+
declare function httpPatch(path: string, handler: HttpHandlerFn): FunctionHandlerDefinition;
|
|
328
|
+
declare function httpPatch<TBody = unknown>(path: string, options: HttpHandlerOptions<TBody>, handler: HttpHandlerFn<TBody>): FunctionHandlerDefinition;
|
|
329
|
+
declare function httpDelete(path: string, handler: HttpHandlerFn): FunctionHandlerDefinition;
|
|
330
|
+
declare function httpDelete(path: string, options: HttpHandlerOptions, handler: HttpHandlerFn): FunctionHandlerDefinition;
|
|
331
|
+
|
|
332
|
+
declare class HttpException extends Error {
|
|
333
|
+
readonly statusCode: number;
|
|
334
|
+
readonly details?: unknown | undefined;
|
|
335
|
+
constructor(statusCode: number, message: string, details?: unknown | undefined);
|
|
336
|
+
}
|
|
337
|
+
declare class BadRequestException extends HttpException {
|
|
338
|
+
constructor(message?: string, details?: unknown);
|
|
339
|
+
}
|
|
340
|
+
declare class UnauthorizedException extends HttpException {
|
|
341
|
+
constructor(message?: string, details?: unknown);
|
|
342
|
+
}
|
|
343
|
+
declare class ForbiddenException extends HttpException {
|
|
344
|
+
constructor(message?: string, details?: unknown);
|
|
345
|
+
}
|
|
346
|
+
declare class NotFoundException extends HttpException {
|
|
347
|
+
constructor(message?: string, details?: unknown);
|
|
348
|
+
}
|
|
349
|
+
declare class MethodNotAllowedException extends HttpException {
|
|
350
|
+
constructor(message?: string, details?: unknown);
|
|
351
|
+
}
|
|
352
|
+
declare class NotAcceptableException extends HttpException {
|
|
353
|
+
constructor(message?: string, details?: unknown);
|
|
354
|
+
}
|
|
355
|
+
declare class ConflictException extends HttpException {
|
|
356
|
+
constructor(message?: string, details?: unknown);
|
|
357
|
+
}
|
|
358
|
+
declare class GoneException extends HttpException {
|
|
359
|
+
constructor(message?: string, details?: unknown);
|
|
360
|
+
}
|
|
361
|
+
declare class UnprocessableEntityException extends HttpException {
|
|
362
|
+
constructor(message?: string, details?: unknown);
|
|
363
|
+
}
|
|
364
|
+
declare class TooManyRequestsException extends HttpException {
|
|
365
|
+
constructor(message?: string, details?: unknown);
|
|
366
|
+
}
|
|
367
|
+
declare class InternalServerErrorException extends HttpException {
|
|
368
|
+
constructor(message?: string, details?: unknown);
|
|
369
|
+
}
|
|
370
|
+
declare class NotImplementedException extends HttpException {
|
|
371
|
+
constructor(message?: string, details?: unknown);
|
|
372
|
+
}
|
|
373
|
+
declare class BadGatewayException extends HttpException {
|
|
374
|
+
constructor(message?: string, details?: unknown);
|
|
375
|
+
}
|
|
376
|
+
declare class ServiceUnavailableException extends HttpException {
|
|
377
|
+
constructor(message?: string, details?: unknown);
|
|
378
|
+
}
|
|
379
|
+
declare class GatewayTimeoutException extends HttpException {
|
|
380
|
+
constructor(message?: string, details?: unknown);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
declare const CONTROLLER_METADATA: unique symbol;
|
|
384
|
+
declare const HTTP_METHOD_METADATA: unique symbol;
|
|
385
|
+
declare const ROUTE_PATH_METADATA: unique symbol;
|
|
386
|
+
declare const GUARD_PROTECTEDBY_METADATA: unique symbol;
|
|
387
|
+
declare const GUARD_CUSTOM_METADATA: unique symbol;
|
|
388
|
+
declare const LAYER_METADATA: unique symbol;
|
|
389
|
+
declare const MODULE_METADATA: unique symbol;
|
|
390
|
+
declare const INJECT_METADATA: unique symbol;
|
|
391
|
+
declare const PUBLIC_METADATA: unique symbol;
|
|
392
|
+
declare const CUSTOM_METADATA: unique symbol;
|
|
393
|
+
|
|
394
|
+
type BootstrapResult = {
|
|
395
|
+
container: Container;
|
|
396
|
+
registry: HandlerRegistry;
|
|
397
|
+
};
|
|
398
|
+
/** Bootstrap DI container + handler registry from a root module class. */
|
|
399
|
+
declare function bootstrap(rootModule: Type): Promise<BootstrapResult>;
|
|
400
|
+
|
|
401
|
+
/** Discover and dynamically import the user's root module. */
|
|
402
|
+
declare function discoverModule(modulePath?: string): Promise<Type>;
|
|
403
|
+
|
|
404
|
+
/** Flatten multi-value records: single-element arrays become plain strings. */
|
|
405
|
+
declare function flattenMultiValueRecord(record: Record<string, string[]>): Record<string, string | string[]>;
|
|
406
|
+
/** Convert NAPI runtime Request → SDK HttpRequest. */
|
|
407
|
+
declare function mapRuntimeRequest(request: Request): HttpRequest;
|
|
408
|
+
/** Convert SDK HttpResponse → NAPI runtime Response. */
|
|
409
|
+
declare function mapToRuntimeResponse(response: HttpResponse): Response;
|
|
410
|
+
|
|
411
|
+
type RuntimeBootstrapResult = {
|
|
412
|
+
registry: HandlerRegistry;
|
|
413
|
+
container: Container;
|
|
414
|
+
/** Create a runtime-compatible handler callback for a specific route. */
|
|
415
|
+
createRouteCallback(path: string, method: string): ((err: Error | null, request: Request) => Promise<Response>) | null;
|
|
416
|
+
};
|
|
417
|
+
/**
|
|
418
|
+
* Bootstrap the user's module and return an object with per-route callback creation.
|
|
419
|
+
* Used by the runtime host to get handler callbacks for each blueprint route.
|
|
420
|
+
*/
|
|
421
|
+
declare function bootstrapForRuntime(modulePath?: string, systemLayers?: (CelerityLayer | Type<CelerityLayer>)[]): Promise<RuntimeBootstrapResult>;
|
|
422
|
+
|
|
423
|
+
type StartRuntimeOptions = {
|
|
424
|
+
block?: boolean;
|
|
425
|
+
};
|
|
426
|
+
/**
|
|
427
|
+
* Full runtime lifecycle orchestrator.
|
|
428
|
+
* Dynamically imports @celerity-sdk/runtime, loads config from CELERITY_* environment
|
|
429
|
+
* variables, bootstraps the user's module, registers handler callbacks, and starts the server.
|
|
430
|
+
*/
|
|
431
|
+
declare function startRuntime(options?: StartRuntimeOptions): Promise<void>;
|
|
432
|
+
|
|
433
|
+
export { APP_CONFIG, Action, Auth, BadGatewayException, BadRequestException, Body, type BootstrapResult, CONTROLLER_METADATA, CUSTOM_METADATA, CelerityApplication, CelerityFactory, ConflictException, Container, Controller, type ControllerMetadata, Cookies, type CreateOptions, Delete, ForbiddenException, GUARD_CUSTOM_METADATA, GUARD_PROTECTEDBY_METADATA, GatewayTimeoutException, Get, GoneException, Guard, HTTP_METHOD_METADATA, HandlerMetadataStore, HandlerRegistry, Head, Headers, HttpException, type HttpHandlerConfig, type HttpHandlerContext, type HttpHandlerRequest, INJECT_METADATA, Inject, Injectable, InternalServerErrorException, LAYER_METADATA, MODULE_METADATA, MethodNotAllowedException, type MockRequestOptions, Module, type ModuleGraph, type ModuleNode, NotAcceptableException, NotFoundException, NotImplementedException, Options, PUBLIC_METADATA, Param, type ParamMetadata, type ParamType, Patch, type PipelineOptions, Post, ProtectedBy, Public, Put, Query, ROUTE_PATH_METADATA, RUNTIME_APP, Req, RequestId, type ResolvedHandler, type RuntimeBootstrapResult, type ServerlessAdapter, ServerlessApplication, type ServerlessHandler, ServiceUnavailableException, SetMetadata, type StartRuntimeOptions, TestingApplication, TooManyRequestsException, UnauthorizedException, UnprocessableEntityException, UseLayer, UseLayers, type ValidationSchemas, bootstrap, bootstrapForRuntime, buildModuleGraph, createDefaultSystemLayers, createHttpHandler, discoverModule, disposeLayers, executeHandlerPipeline, flattenMultiValueRecord, getClassDependencyTokens, getProviderDependencyTokens, httpDelete, httpGet, httpPatch, httpPost, httpPut, mapRuntimeRequest, mapToRuntimeResponse, mockRequest, registerModuleGraph, runLayerPipeline, startRuntime, tokenToString, validate };
|