@supacloud/elysia 0.10.0 → 0.16.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 +275 -2
- package/compatibility.json +9 -0
- package/dist/command-errors.d.ts +3 -0
- package/dist/documentation.d.ts +29 -0
- package/dist/execution.d.ts +1 -0
- package/dist/fixtures/webhook/contracts.d.ts +42 -0
- package/dist/fixtures/webhook/environment.d.ts +11 -0
- package/dist/fixtures/webhook/update.command.d.ts +13 -0
- package/dist/fixtures/webhook/webhook.controller.d.ts +15 -0
- package/dist/fixtures/webhook/webhook.module.d.ts +2 -0
- package/dist/fixtures/webhook-generated/application.d.ts +100 -0
- package/dist/generate-webhook-example.d.ts +19 -0
- package/dist/index.d.ts +53 -1
- package/dist/index.js +1053 -112
- package/dist/persistent-command.d.ts +20 -0
- package/dist/schema_contract.d.ts +160 -0
- package/dist/webhook-migration-example.d.ts +41 -0
- package/dist/worker.d.ts +150 -0
- package/package.json +18 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { Elysia } from "elysia";
|
|
2
|
+
import { type CommandPreview } from "@supacloud/contracts";
|
|
3
|
+
import { type EnvironmentInjector } from "@supacloud/app";
|
|
2
4
|
import { type ExecutionObserver } from "./execution";
|
|
5
|
+
import { type ApplicationDocumentationOptions } from "./documentation";
|
|
3
6
|
export type { ExecutionEvent, ExecutionObserver } from "./execution";
|
|
7
|
+
export { createSchemaDecoder, assertResponseStatusDeclared, defineElysiaRoute, defineJsonContract, defineRouteContract, registerElysiaRoute, responseSchemaForStatus, responseStatusDeclared, responseStatusOf, SchemaContractError, toElysiaRouteSchema, } from "./schema_contract";
|
|
8
|
+
export type { ElysiaRouteContext, ElysiaRouteDefinition, ElysiaRouteHandler, ElysiaRouteSchema, ResponseMapSelector, RouteContractSchemas, SchemaDecoderOptions, SchemaNormalizeMode, } from "./schema_contract";
|
|
9
|
+
export { createPersistentCommandAdapter, type PersistentCommandHandler } from "./persistent-command";
|
|
10
|
+
export { createDocumentationPlugin } from "./documentation";
|
|
11
|
+
export type { ApplicationDocumentationOptions, DocumentationSource, GraphqlDocumentationOptions, OpenApiDocumentationOptions, } from "./documentation";
|
|
4
12
|
export interface CompiledRoute {
|
|
5
13
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
6
14
|
path: string;
|
|
@@ -10,13 +18,28 @@ export interface CompiledRoute {
|
|
|
10
18
|
body?: unknown;
|
|
11
19
|
params?: unknown;
|
|
12
20
|
query?: unknown;
|
|
21
|
+
headers?: unknown;
|
|
22
|
+
cookie?: unknown;
|
|
23
|
+
/** @deprecated Use `responses` with an explicit HTTP status map. */
|
|
13
24
|
response?: unknown;
|
|
25
|
+
responses?: Record<string | number, unknown>;
|
|
26
|
+
/** Compile-time ownership and transport classification for the route boundary. */
|
|
27
|
+
contract?: {
|
|
28
|
+
body?: "framework" | "domain";
|
|
29
|
+
response?: "framework" | "native-json" | "binary" | "stream";
|
|
30
|
+
evidence?: string;
|
|
31
|
+
};
|
|
32
|
+
/** Whether each declared schema is concrete or intentionally opaque. */
|
|
33
|
+
schemaKinds?: Partial<Record<"body" | "params" | "query" | "headers" | "cookie" | "response", "opaque" | "declared">>;
|
|
34
|
+
/** True when the handler returns a native Response rather than a framework value. */
|
|
35
|
+
nativeResponse?: boolean;
|
|
14
36
|
/** Compiler-emitted positional invoker; used when available. */
|
|
15
37
|
invoker?: (controller: unknown, request: {
|
|
16
38
|
params?: Record<string, unknown>;
|
|
17
39
|
query?: Record<string, unknown>;
|
|
18
40
|
body?: unknown;
|
|
19
41
|
headers?: Record<string, unknown>;
|
|
42
|
+
cookie?: Record<string, unknown>;
|
|
20
43
|
context?: unknown;
|
|
21
44
|
}) => Promise<unknown> | unknown;
|
|
22
45
|
/** Class name of the @Command explicitly bound to this route. */
|
|
@@ -40,6 +63,14 @@ export interface CompiledJob {
|
|
|
40
63
|
name: string;
|
|
41
64
|
serviceKey: string;
|
|
42
65
|
scope: "application" | "request" | "job";
|
|
66
|
+
/** TypeBox input schema emitted by the compiler. */
|
|
67
|
+
input?: unknown;
|
|
68
|
+
/** TypeBox output schema emitted by the compiler. */
|
|
69
|
+
output?: unknown;
|
|
70
|
+
mode?: "task" | "workflow";
|
|
71
|
+
timeoutSec?: number;
|
|
72
|
+
maxAttempts?: number;
|
|
73
|
+
idempotency?: "required" | "none";
|
|
43
74
|
aspects?: ApplicationAspect[];
|
|
44
75
|
}
|
|
45
76
|
export interface CompiledController {
|
|
@@ -127,6 +158,7 @@ export interface CommandGovernance {
|
|
|
127
158
|
audit?: boolean;
|
|
128
159
|
transaction?: boolean;
|
|
129
160
|
idempotency?: boolean;
|
|
161
|
+
boundary?: "database" | "external";
|
|
130
162
|
};
|
|
131
163
|
execute: CommandMiddleware;
|
|
132
164
|
}>;
|
|
@@ -173,10 +205,14 @@ export interface ErrorContext {
|
|
|
173
205
|
export type ErrorMapper = (error: unknown, context: ErrorContext) => Response | undefined | Promise<Response | undefined>;
|
|
174
206
|
export interface ApplicationOptions {
|
|
175
207
|
name?: string;
|
|
208
|
+
/** false rejects extra schema properties instead of silently removing them. */
|
|
209
|
+
normalize?: boolean;
|
|
176
210
|
/** Modules in topological import order. */
|
|
177
211
|
modules?: CompiledModule[];
|
|
178
212
|
/** Platform-level dependencies (db client etc.), passed to createServices. */
|
|
179
213
|
deps?: Record<string, unknown>;
|
|
214
|
+
/** Optional Angular-backed root injector used for async request contexts. */
|
|
215
|
+
injector?: EnvironmentInjector;
|
|
180
216
|
/** Builds the per-request context object. Defaults to { requestId, request }. */
|
|
181
217
|
requestContext?: RequestContextFactory;
|
|
182
218
|
/** Enforces permission/audit/idempotency policy for command-bound routes. */
|
|
@@ -187,6 +223,8 @@ export interface ApplicationOptions {
|
|
|
187
223
|
errorMapper?: ErrorMapper;
|
|
188
224
|
/** Best-effort execution metadata only; durable audit belongs to governance. */
|
|
189
225
|
onExecution?: ExecutionObserver;
|
|
226
|
+
/** Optional read-only OpenAPI and GraphQL documentation endpoints. */
|
|
227
|
+
documentation?: ApplicationDocumentationOptions;
|
|
190
228
|
}
|
|
191
229
|
export interface JobInvocation {
|
|
192
230
|
job: CompiledJob;
|
|
@@ -222,6 +260,18 @@ export declare function executeCompiledCommand<Input, Result>(options: {
|
|
|
222
260
|
handler: (input: Input) => Result | Promise<Result>;
|
|
223
261
|
decode: (value: unknown) => Result;
|
|
224
262
|
}): Promise<Result>;
|
|
263
|
+
/** Read-only actionability. Accepts the same governance object as execute, but only runs authorize. */
|
|
264
|
+
export declare function previewCompiledCommand<Input>(options: {
|
|
265
|
+
module: Pick<CompiledModule, "name" | "commands">;
|
|
266
|
+
command: string;
|
|
267
|
+
input: Input;
|
|
268
|
+
request: Request;
|
|
269
|
+
requestContext: unknown;
|
|
270
|
+
services?: Record<string, unknown>;
|
|
271
|
+
scope?: Record<string, unknown>;
|
|
272
|
+
governance: CommandGovernance;
|
|
273
|
+
preview: (input: Input) => unknown;
|
|
274
|
+
}): Promise<CommandPreview>;
|
|
225
275
|
export declare function requireTrustedIdentity(requestContext: unknown): Required<Pick<TrustedRequestIdentity, "subject" | "accessToken">> & TrustedRequestIdentity;
|
|
226
276
|
export declare function requireIdempotencyKey(invocation: CommandInvocation): string;
|
|
227
277
|
/**
|
|
@@ -232,7 +282,7 @@ export declare function requireIdempotencyKey(invocation: CommandInvocation): st
|
|
|
232
282
|
* exposed on the `scope` context key. Request-scoped controller instances are
|
|
233
283
|
* looked up on `scope`, everything else on `services`.
|
|
234
284
|
*/
|
|
235
|
-
export declare function createModulePlugin(compiled: CompiledModule, services: Record<string, unknown>, ctxFactory?: RequestContextFactory, options?: Pick<ApplicationOptions, "commandGovernance" | "commandExecutor" | "errorMapper" | "onExecution">, imported?: Record<string, Record<string, unknown>>): Elysia;
|
|
285
|
+
export declare function createModulePlugin(compiled: CompiledModule, services: Record<string, unknown>, ctxFactory?: RequestContextFactory, options?: Pick<ApplicationOptions, "commandGovernance" | "commandExecutor" | "errorMapper" | "onExecution" | "normalize" | "injector">, imported?: Record<string, Record<string, unknown>>): Elysia;
|
|
236
286
|
/**
|
|
237
287
|
* Execute one compiler-emitted Job descriptor.
|
|
238
288
|
*
|
|
@@ -256,3 +306,5 @@ export { createMemorySandbox, } from "./memory";
|
|
|
256
306
|
export type { HandleLike as MemoryHandleLike, MemoryDatabase, MemorySandbox, MemorySandboxOptions, MemoryStorage, MemoryStorageObject, } from "./memory";
|
|
257
307
|
export { createMemoryPolicy } from "./memory_policy";
|
|
258
308
|
export type { MemoryPolicy } from "./memory_policy";
|
|
309
|
+
export { createQueueWorkerTransport, createWorker, SupaCloudWorker, WorkerRegistrationError, WorkerReceiptUnconfirmedError, } from "./worker";
|
|
310
|
+
export type { WorkerAcknowledge, WorkerClaim, WorkerFail, WorkerOptions, QueueWorkerTransportOptions, WorkerQueueFailureOptions, WorkerQueueMessage, WorkerQueuePort, WorkerQueueReceiveOptions, WorkerReceiptContext, WorkerReceiptOperation, WorkerRunResult, WorkerState, WorkerTransport, } from "./worker";
|