@supacloud/elysia 0.30.0 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/compatibility.json +3 -3
- package/dist/framework.d.ts +2 -2
- package/dist/http-telemetry.d.ts +8 -2
- package/dist/index.d.ts +8 -11
- package/dist/index.js +9 -9
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -8,11 +8,11 @@ is a separately authorized business command, never an assumed rollback.
|
|
|
8
8
|
|
|
9
9
|
## Compatibility and Acceptance Boundary
|
|
10
10
|
|
|
11
|
-
The Elysia peer and development dependency are pinned to `2.0.0-beta.
|
|
12
|
-
The runtime adapter pins Effect `4.0.
|
|
11
|
+
The Elysia peer and development dependency are pinned to `2.0.0-beta.32`.
|
|
12
|
+
The runtime adapter pins Effect `4.0.5` and consumes its `Exit`-based
|
|
13
13
|
execution boundary.
|
|
14
14
|
`compatibility.json` records the acceptance target: Bun 1.4.3, Elysia
|
|
15
|
-
2.0.0-beta.
|
|
15
|
+
2.0.0-beta.32, Effect 4.0.5, `typebox` 1.3.37, `exact-mirror` 1.2.6,
|
|
16
16
|
TypeScript CLI 7.0.2 and the compiler's separate TypeScript 6 semantic API 6.0.2.
|
|
17
17
|
The matrix is a
|
|
18
18
|
required target, not proof of an execution. See the dated, commit-specific
|
|
@@ -319,7 +319,7 @@ Runtime adapter that turns `@supacloud/compiler` output into a production-ready
|
|
|
319
319
|
## Installation
|
|
320
320
|
|
|
321
321
|
```bash
|
|
322
|
-
bun add --exact @supacloud/elysia elysia@2.0.0-beta.
|
|
322
|
+
bun add --exact @supacloud/elysia elysia@2.0.0-beta.32
|
|
323
323
|
```
|
|
324
324
|
|
|
325
325
|
## Usage
|
package/compatibility.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bun": "1.4.3",
|
|
3
3
|
"packages": {
|
|
4
|
-
"elysia": "2.0.0-beta.
|
|
5
|
-
"effect": "4.0.
|
|
4
|
+
"elysia": "2.0.0-beta.32",
|
|
5
|
+
"effect": "4.0.5",
|
|
6
6
|
"typescript": "7.0.2",
|
|
7
|
-
"typebox": "1.3.
|
|
7
|
+
"typebox": "1.3.37",
|
|
8
8
|
"exact-mirror": "1.2.6",
|
|
9
9
|
"@typescript/typescript6": "6.0.2"
|
|
10
10
|
}
|
package/dist/framework.d.ts
CHANGED
|
@@ -29,8 +29,8 @@ export declare function createSupaCloudFramework<const Http extends AnyElysia =
|
|
|
29
29
|
macro: (import("elysia").DefaultMetadata & Http["~Metadata"])["macro"];
|
|
30
30
|
macroFn: (import("elysia").DefaultMetadata & Http["~Metadata"])["macroFn"];
|
|
31
31
|
parser: (import("elysia").DefaultMetadata & Http["~Metadata"])["parser"];
|
|
32
|
-
response: import("elysia/types").UnionResponseStatus<(import("elysia").DefaultMetadata & Http["~Metadata"])["response"], import("elysia/types").UnionResponseStatus<
|
|
33
|
-
},
|
|
32
|
+
response: import("elysia/types").UnionResponseStatus<(import("elysia").DefaultMetadata & Http["~Metadata"])["response"], import("elysia/types").UnionResponseStatus<Http["~Ephemeral"]["response"], {}>>;
|
|
33
|
+
}, {} & Http["~Routes"], import("elysia").DefaultEphemeral, {
|
|
34
34
|
derive: {};
|
|
35
35
|
schema: {};
|
|
36
36
|
schemas: {};
|
package/dist/http-telemetry.d.ts
CHANGED
|
@@ -16,12 +16,18 @@ export declare function createHttpTelemetry(observe: HttpTelemetryObserver): Ely
|
|
|
16
16
|
derive: {};
|
|
17
17
|
}, {
|
|
18
18
|
typebox: {};
|
|
19
|
-
error: [
|
|
19
|
+
error: [{
|
|
20
|
+
error: Error;
|
|
21
|
+
response: {};
|
|
22
|
+
passes: true;
|
|
23
|
+
'~return': undefined;
|
|
24
|
+
'~catchAll': true;
|
|
25
|
+
}];
|
|
20
26
|
}, {
|
|
21
27
|
schema: {};
|
|
22
28
|
schemas: {};
|
|
23
29
|
macro: {};
|
|
24
30
|
macroFn: {};
|
|
25
31
|
parser: {};
|
|
26
|
-
response:
|
|
32
|
+
response: import("elysia/types").ExtractErrorFromHandle<undefined>;
|
|
27
33
|
}, {}, import("elysia").DefaultEphemeral, import("elysia").DefaultEphemeral>;
|
package/dist/index.d.ts
CHANGED
|
@@ -255,7 +255,7 @@ export interface ErrorContext {
|
|
|
255
255
|
*
|
|
256
256
|
* Declaring the runtime classes here lets Elysia's type system (and therefore
|
|
257
257
|
* Eden Treaty / generated clients) know these errors are *handled*: the generic
|
|
258
|
-
* `.
|
|
258
|
+
* `.onError(handler)` catch-all no longer widens every route's response schema
|
|
259
259
|
* with an untyped fallback. Each entry also documents the public `code` served
|
|
260
260
|
* by {@link defaultErrorResponse} when a caller does not install an
|
|
261
261
|
* `errorMapper`.
|
|
@@ -399,16 +399,13 @@ export declare function createModulePlugin<const Services extends Record<string,
|
|
|
399
399
|
}, {
|
|
400
400
|
typebox: {} & Http["~Definitions"]["typebox"];
|
|
401
401
|
error: [...Http["~Definitions"]["error"]];
|
|
402
|
-
}, import("elysia").DefaultMetadata & Http["~Metadata"],
|
|
402
|
+
}, import("elysia").DefaultMetadata & Http["~Metadata"], {} & Http["~Routes"], import("elysia").DefaultEphemeral, {
|
|
403
403
|
derive: {} & Http["~Ephemeral"]["derive"];
|
|
404
404
|
schema: {} & import("elysia/types").MergeSchema<{} & Http["~Ephemeral"]["schema"], {}, "", false>;
|
|
405
405
|
schemas: {} & Http["~Ephemeral"]["schemas"];
|
|
406
|
-
response:
|
|
406
|
+
response: Http["~Ephemeral"]["response"];
|
|
407
407
|
error: [...Http["~Ephemeral"]["error"]];
|
|
408
|
-
},
|
|
409
|
-
readonly services: Services;
|
|
410
|
-
readonly requestContext: unknown;
|
|
411
|
-
}>, {
|
|
408
|
+
}, {}, {
|
|
412
409
|
readonly services: Services;
|
|
413
410
|
readonly requestContext: unknown;
|
|
414
411
|
}>;
|
|
@@ -441,8 +438,8 @@ export declare function createApplication<const Http extends AnyElysia = Elysia>
|
|
|
441
438
|
macro: (import("elysia").DefaultMetadata & Http["~Metadata"])["macro"];
|
|
442
439
|
macroFn: (import("elysia").DefaultMetadata & Http["~Metadata"])["macroFn"];
|
|
443
440
|
parser: (import("elysia").DefaultMetadata & Http["~Metadata"])["parser"];
|
|
444
|
-
response: import("elysia/types").UnionResponseStatus<(import("elysia").DefaultMetadata & Http["~Metadata"])["response"], import("elysia/types").UnionResponseStatus<
|
|
445
|
-
},
|
|
441
|
+
response: import("elysia/types").UnionResponseStatus<(import("elysia").DefaultMetadata & Http["~Metadata"])["response"], import("elysia/types").UnionResponseStatus<Http["~Ephemeral"]["response"], {}>>;
|
|
442
|
+
}, {} & Http["~Routes"], import("elysia").DefaultEphemeral, {
|
|
446
443
|
derive: {};
|
|
447
444
|
schema: {};
|
|
448
445
|
schemas: {};
|
|
@@ -463,8 +460,8 @@ export declare function createTestApp<const Http extends AnyElysia = Elysia>(opt
|
|
|
463
460
|
macro: (import("elysia").DefaultMetadata & Http["~Metadata"])["macro"];
|
|
464
461
|
macroFn: (import("elysia").DefaultMetadata & Http["~Metadata"])["macroFn"];
|
|
465
462
|
parser: (import("elysia").DefaultMetadata & Http["~Metadata"])["parser"];
|
|
466
|
-
response: import("elysia/types").UnionResponseStatus<(import("elysia").DefaultMetadata & Http["~Metadata"])["response"], import("elysia/types").UnionResponseStatus<
|
|
467
|
-
},
|
|
463
|
+
response: import("elysia/types").UnionResponseStatus<(import("elysia").DefaultMetadata & Http["~Metadata"])["response"], import("elysia/types").UnionResponseStatus<Http["~Ephemeral"]["response"], {}>>;
|
|
464
|
+
}, {} & Http["~Routes"], import("elysia").DefaultEphemeral, {
|
|
468
465
|
derive: {};
|
|
469
466
|
schema: {};
|
|
470
467
|
schemas: {};
|
package/dist/index.js
CHANGED
|
@@ -84,15 +84,15 @@ function httpRequestId(request) {
|
|
|
84
84
|
}
|
|
85
85
|
function createHttpTelemetry(observe) {
|
|
86
86
|
const starts = new WeakMap;
|
|
87
|
-
return new Elysia().
|
|
87
|
+
return new Elysia().onRequest(({ request, set }) => {
|
|
88
88
|
const supplied = request.headers.get("x-request-id");
|
|
89
89
|
const requestId = supplied && /^[A-Za-z0-9._:-]{1,128}$/.test(supplied) ? supplied : crypto.randomUUID();
|
|
90
90
|
starts.set(request, { time: performance.now(), requestId });
|
|
91
91
|
requestIds.set(request, requestId);
|
|
92
92
|
set.headers["x-request-id"] = requestId;
|
|
93
|
-
}).
|
|
93
|
+
}).onError(() => {
|
|
94
94
|
return;
|
|
95
|
-
}).
|
|
95
|
+
}).onAfterResponse(async ({ request, responseValue: response, set, route }) => {
|
|
96
96
|
const start = starts.get(request);
|
|
97
97
|
if (!start)
|
|
98
98
|
return;
|
|
@@ -861,7 +861,7 @@ function registerElysiaRoute(app, route) {
|
|
|
861
861
|
}
|
|
862
862
|
return value;
|
|
863
863
|
};
|
|
864
|
-
app.method(route.method, route.path, toElysiaRouteSchema(route.contract), handler);
|
|
864
|
+
app.method(route.method, route.path, { ...toElysiaRouteSchema(route.contract) }, handler);
|
|
865
865
|
return app;
|
|
866
866
|
}
|
|
867
867
|
|
|
@@ -2492,7 +2492,7 @@ function createModulePlugin(compiled, services, ctxFactory = defaultRequestConte
|
|
|
2492
2492
|
});
|
|
2493
2493
|
const createRequestScope = compiled.createRequestScope;
|
|
2494
2494
|
const requestScopes = new WeakMap;
|
|
2495
|
-
plugin.
|
|
2495
|
+
plugin.onAfterResponse(async ({ request }) => {
|
|
2496
2496
|
const scope = requestScopes.get(request);
|
|
2497
2497
|
requestScopes.delete(request);
|
|
2498
2498
|
try {
|
|
@@ -2514,9 +2514,9 @@ function createModulePlugin(compiled, services, ctxFactory = defaultRequestConte
|
|
|
2514
2514
|
const mapped = await options.errorMapper?.(error, context);
|
|
2515
2515
|
return mapped ?? defaultErrorResponse(error, frameworkCode);
|
|
2516
2516
|
};
|
|
2517
|
-
plugin.
|
|
2518
|
-
plugin.
|
|
2519
|
-
plugin.
|
|
2517
|
+
plugin.onError(ApplicationError, ({ error, request }) => mapError(error, frameworkErrorCode(error), request));
|
|
2518
|
+
plugin.onError(SchemaContractError, ({ error, request }) => mapError(error, frameworkErrorCode(error), request));
|
|
2519
|
+
plugin.onError(({ error, request }) => mapError(error, frameworkErrorCode(error), request));
|
|
2520
2520
|
const routeRegistrar = plugin;
|
|
2521
2521
|
for (const controller of compiled.controllers) {
|
|
2522
2522
|
for (const route of controller.routes) {
|
|
@@ -2565,7 +2565,7 @@ function createModulePlugin(compiled, services, ctxFactory = defaultRequestConte
|
|
|
2565
2565
|
requestContext: requestContexts.get(context.request),
|
|
2566
2566
|
response,
|
|
2567
2567
|
encodeResponse: async (value) => {
|
|
2568
|
-
const validator = responseValidators?.
|
|
2568
|
+
const validator = responseValidators?.get(responseStatusOf(value, context.set.status));
|
|
2569
2569
|
if (!validator)
|
|
2570
2570
|
return value;
|
|
2571
2571
|
if (!("EncodeFrom" in validator) || typeof validator.EncodeFrom !== "function") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/elysia",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"description": "Elysia runtime adapter for SupaCloud compiled modules: application/request scopes, route registration and validation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,29 +49,29 @@
|
|
|
49
49
|
"directory": "packages/elysia"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@supacloud/app": "0.27.
|
|
52
|
+
"@supacloud/app": "0.27.1",
|
|
53
53
|
"@supacloud/contracts": "0.9.0",
|
|
54
|
-
"effect": "4.0.
|
|
54
|
+
"effect": "4.0.5",
|
|
55
55
|
"exact-mirror": "1.2.6",
|
|
56
56
|
"jose": "^6.2.12",
|
|
57
|
-
"typebox": "1.3.
|
|
57
|
+
"typebox": "1.3.37"
|
|
58
58
|
},
|
|
59
59
|
"overrides": {
|
|
60
|
-
"@supacloud/delivery": "0.18.
|
|
60
|
+
"@supacloud/delivery": "0.18.1",
|
|
61
61
|
"@supacloud/contracts": "0.9.0",
|
|
62
|
-
"@supacloud/commands": "0.9.
|
|
63
|
-
"@graphql-tools/utils": "^12.0.
|
|
62
|
+
"@supacloud/commands": "0.9.3",
|
|
63
|
+
"@graphql-tools/utils": "^12.0.4"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"elysia": "2.0.0-beta.
|
|
66
|
+
"elysia": "2.0.0-beta.32"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@supacloud/compiler": "0.46.
|
|
70
|
-
"@supacloud/delivery": "0.18.
|
|
71
|
-
"@supacloud/commands": "0.9.
|
|
72
|
-
"@supacloud/db": "0.17.
|
|
69
|
+
"@supacloud/compiler": "0.46.2",
|
|
70
|
+
"@supacloud/delivery": "0.18.1",
|
|
71
|
+
"@supacloud/commands": "0.9.3",
|
|
72
|
+
"@supacloud/db": "0.17.1",
|
|
73
73
|
"@types/bun": "^1.4.3",
|
|
74
|
-
"elysia": "2.0.0-beta.
|
|
74
|
+
"elysia": "2.0.0-beta.32",
|
|
75
75
|
"typescript": "^7.0.2"
|
|
76
76
|
}
|
|
77
77
|
}
|