@supacloud/elysia 0.38.1 → 0.39.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/README.md +40 -0
- package/dist/bun-aot.d.ts +18 -0
- package/dist/bun-aot.js +3271 -0
- package/dist/fixtures/webhook-generated/application.d.ts +31 -1
- package/dist/index.d.ts +19 -4
- package/dist/index.js +278 -221
- package/dist/testing.d.ts +11 -0
- package/package.json +9 -4
|
@@ -12,6 +12,19 @@ export interface CompiledRoute {
|
|
|
12
12
|
cookie?: unknown;
|
|
13
13
|
response?: unknown;
|
|
14
14
|
responses?: Record<string | number, unknown>;
|
|
15
|
+
effect?: {
|
|
16
|
+
required: true;
|
|
17
|
+
errors?: Array<{
|
|
18
|
+
tag: string;
|
|
19
|
+
status: number;
|
|
20
|
+
code: string;
|
|
21
|
+
message?: string;
|
|
22
|
+
}>;
|
|
23
|
+
dependencies?: string[];
|
|
24
|
+
retry?: "none" | "explicit";
|
|
25
|
+
maxAttempts?: number;
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
};
|
|
15
28
|
/** Compile-time ownership and transport classification for the route boundary. */
|
|
16
29
|
contract?: {
|
|
17
30
|
body?: "framework" | "domain";
|
|
@@ -23,6 +36,8 @@ export interface CompiledRoute {
|
|
|
23
36
|
/** True when the handler returns a native Response rather than a framework value. */
|
|
24
37
|
nativeResponse?: boolean;
|
|
25
38
|
command?: string;
|
|
39
|
+
/** Transport-level idempotency contract, independent of route command binding. */
|
|
40
|
+
idempotency?: "required" | "none";
|
|
26
41
|
guards?: string[];
|
|
27
42
|
canMatch?: string[];
|
|
28
43
|
canDeactivate?: string[];
|
|
@@ -37,7 +52,7 @@ export interface CompiledRoute {
|
|
|
37
52
|
data?: Record<string, unknown>;
|
|
38
53
|
aspects?: CompiledAspect[];
|
|
39
54
|
aspectPipeline?: CompiledAspectPipeline;
|
|
40
|
-
invoker
|
|
55
|
+
invoker: (controller: unknown, request: {
|
|
41
56
|
params?: Record<string, unknown>;
|
|
42
57
|
query?: Record<string, unknown>;
|
|
43
58
|
body?: unknown;
|
|
@@ -45,19 +60,32 @@ export interface CompiledRoute {
|
|
|
45
60
|
cookie?: Record<string, unknown>;
|
|
46
61
|
context?: unknown;
|
|
47
62
|
}) => Promise<unknown> | unknown;
|
|
63
|
+
directInvoker?: (controller: unknown, context: unknown) => Promise<unknown> | unknown;
|
|
64
|
+
directInvokerFast?: (controller: Record<string, unknown>, handler: (...args: unknown[]) => unknown, context: unknown) => Promise<unknown> | unknown;
|
|
65
|
+
executionMode?: "direct" | "pipeline";
|
|
48
66
|
}
|
|
49
67
|
export interface CompiledCommand {
|
|
50
68
|
rpc?: string;
|
|
69
|
+
branches?: readonly CompiledCommandBranch[];
|
|
51
70
|
className: string;
|
|
52
71
|
name: string;
|
|
53
72
|
permission: string;
|
|
54
73
|
transaction: "required" | "none";
|
|
55
74
|
audit?: string;
|
|
56
75
|
idempotency: "required" | "none";
|
|
76
|
+
tenantScope?: "required" | "none";
|
|
57
77
|
standalone?: boolean;
|
|
58
78
|
aspects?: CompiledAspect[];
|
|
59
79
|
aspectPipeline?: CompiledAspectPipeline;
|
|
60
80
|
}
|
|
81
|
+
export interface CompiledCommandBranch {
|
|
82
|
+
when: string;
|
|
83
|
+
rpc: string;
|
|
84
|
+
transaction?: "required" | "none" | string;
|
|
85
|
+
audit?: string;
|
|
86
|
+
idempotency?: "required" | "none" | string;
|
|
87
|
+
boundary?: "database" | "external";
|
|
88
|
+
}
|
|
61
89
|
export interface CompiledJob {
|
|
62
90
|
className: string;
|
|
63
91
|
name: string;
|
|
@@ -69,6 +97,7 @@ export interface CompiledJob {
|
|
|
69
97
|
timeoutSec?: number;
|
|
70
98
|
maxAttempts?: number;
|
|
71
99
|
idempotency?: "required" | "none";
|
|
100
|
+
tenantScope?: "required" | "none";
|
|
72
101
|
aspects?: CompiledAspect[];
|
|
73
102
|
aspectPipeline?: CompiledAspectPipeline;
|
|
74
103
|
}
|
|
@@ -101,6 +130,7 @@ export interface CompiledModule {
|
|
|
101
130
|
createJobScope?(services: Record<string, unknown>, ctx: unknown, imported?: Record<string, Record<string, unknown>>): Promise<Record<string, unknown>>;
|
|
102
131
|
destroyJobScope?(scope: Record<string, unknown>): Promise<void>;
|
|
103
132
|
controllers: CompiledController[];
|
|
133
|
+
registerRoutes?(register: (controller: CompiledController, route: CompiledRoute, path: string) => void): void;
|
|
104
134
|
commands: CompiledCommand[];
|
|
105
135
|
jobs: CompiledJob[];
|
|
106
136
|
aspects?: CompiledAspect[];
|
package/dist/index.d.ts
CHANGED
|
@@ -62,8 +62,8 @@ export interface CompiledRoute {
|
|
|
62
62
|
schemaKinds?: Partial<Record<"body" | "params" | "query" | "headers" | "cookie" | "response", "opaque" | "declared">>;
|
|
63
63
|
/** True when the handler returns a native Response rather than a framework value. */
|
|
64
64
|
nativeResponse?: boolean;
|
|
65
|
-
/** Compiler-emitted positional invoker
|
|
66
|
-
invoker?: (controller:
|
|
65
|
+
/** Compiler-emitted positional invoker. */
|
|
66
|
+
invoker?: <Controller extends CompiledControllerInvokerTarget>(controller: Controller, request: {
|
|
67
67
|
params?: Record<string, unknown>;
|
|
68
68
|
query?: Record<string, unknown>;
|
|
69
69
|
body?: unknown;
|
|
@@ -71,6 +71,12 @@ export interface CompiledRoute {
|
|
|
71
71
|
cookie?: Record<string, unknown>;
|
|
72
72
|
context?: unknown;
|
|
73
73
|
}) => Promise<unknown> | unknown;
|
|
74
|
+
/** Compiler-emitted Elysia-context invoker for routes without SupaCloud stages. */
|
|
75
|
+
directInvoker?: <Controller extends CompiledControllerInvokerTarget>(controller: Controller, context: unknown) => Promise<unknown> | unknown;
|
|
76
|
+
/** Generated invoker accepting a controller and method validated at registration. */
|
|
77
|
+
directInvokerFast?: (controller: Record<string, unknown>, handler: (...args: unknown[]) => unknown, context: unknown) => unknown | Promise<unknown>;
|
|
78
|
+
/** Compiler-selected execution plan. Older artifacts default to the full pipeline. */
|
|
79
|
+
executionMode?: "direct" | "pipeline";
|
|
74
80
|
/** Class name of the @Command explicitly bound to this route. */
|
|
75
81
|
command?: string;
|
|
76
82
|
/** Transport-level idempotency contract, independent of route command binding. */
|
|
@@ -79,6 +85,13 @@ export interface CompiledRoute {
|
|
|
79
85
|
aspects?: ApplicationAspect[];
|
|
80
86
|
aspectPipeline?: ApplicationAspectPipeline;
|
|
81
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* The generated invoker validates the controller at runtime, while hand-written
|
|
90
|
+
* descriptors often call a known method directly. Keep the target callable so
|
|
91
|
+
* those descriptors retain useful contextual types without weakening the
|
|
92
|
+
* compiled module contract to `any`.
|
|
93
|
+
*/
|
|
94
|
+
export type CompiledControllerInvokerTarget = Record<string, (...args: unknown[]) => unknown> & object;
|
|
82
95
|
export interface CompiledCommand {
|
|
83
96
|
rpc?: string;
|
|
84
97
|
branches?: readonly CompiledCommandBranch[];
|
|
@@ -126,6 +139,7 @@ export interface CompiledController {
|
|
|
126
139
|
scope: "application" | "request" | "job";
|
|
127
140
|
routes: CompiledRoute[];
|
|
128
141
|
}
|
|
142
|
+
export type CompiledRouteRegistrar = (controller: CompiledController, route: CompiledRoute, path: string) => void;
|
|
129
143
|
export interface CompiledModule {
|
|
130
144
|
name: string;
|
|
131
145
|
createServices(deps: Record<string, unknown>, imported: Record<string, Record<string, unknown>>): Record<string, unknown>;
|
|
@@ -138,6 +152,8 @@ export interface CompiledModule {
|
|
|
138
152
|
createJobScope?(services: Record<string, unknown>, ctx: unknown, imported?: Record<string, Record<string, unknown>>): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
139
153
|
destroyJobScope?(scope: Record<string, unknown>): Promise<void>;
|
|
140
154
|
controllers: CompiledController[];
|
|
155
|
+
/** Required for HTTP modules. Recompile artifacts when upgrading the adapter. */
|
|
156
|
+
registerRoutes?(register: CompiledRouteRegistrar): void;
|
|
141
157
|
commands?: CompiledCommand[];
|
|
142
158
|
jobs?: CompiledJob[];
|
|
143
159
|
/** Statically generated module aspects. */
|
|
@@ -421,8 +437,7 @@ export declare function createModulePlugin<const Services extends Record<string,
|
|
|
421
437
|
response: Http["~Ephemeral"]["response"];
|
|
422
438
|
error: [...Http["~Ephemeral"]["error"]];
|
|
423
439
|
}, {}, {
|
|
424
|
-
|
|
425
|
-
readonly requestContext: unknown;
|
|
440
|
+
services: Services;
|
|
426
441
|
}>;
|
|
427
442
|
/**
|
|
428
443
|
* Execute one compiler-emitted Job descriptor.
|