stitchkit 0.49.2 → 0.51.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/dist/cli.js +3 -3
- package/dist/contract/errors-factory.d.ts +27 -6
- package/dist/contract/errors-factory.d.ts.map +1 -1
- package/dist/contract/factory.d.ts +15 -2
- package/dist/contract/factory.d.ts.map +1 -1
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +1 -1
- package/dist/{index-z992nfbx.js → index-8mt47qk7.js} +127 -123
- package/dist/{index-jewp9r0a.js → index-8qghvg18.js} +1 -1
- package/dist/{index-h05ygjqx.js → index-bmnhqtya.js} +4 -1
- package/dist/{index-p9d4cxt5.js → index-gff2mxzk.js} +1 -1
- package/dist/{index-0hj37z43.js → index-h55e1wyq.js} +2 -2
- package/dist/{index-v58mwa19.js → index-psrxjvbw.js} +2 -2
- package/dist/{index-45dz4m51.js → index-trz4ate5.js} +6 -2
- package/dist/{index-03j2t778.js → index-tw7mhqgy.js} +15 -4
- package/dist/index-ynts85ew.js +246 -0
- package/dist/index.js +1 -1
- package/dist/node.d.ts +3 -2
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +15 -6
- package/dist/observability/index.js +3 -3
- package/dist/server/implement.d.ts +101 -8
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/index.d.ts +4 -3
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +19 -11
- package/dist/server/middleware/auth.d.ts +63 -3
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/process-signals.d.ts +117 -0
- package/dist/server/process-signals.d.ts.map +1 -0
- package/dist/server/types.d.ts +38 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/testing.js +2 -2
- package/dist/tools/list-names.d.ts +13 -1
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +13 -8
- package/llms-full.txt +404 -39
- package/package.json +1 -1
- package/dist/index-r1qp4rve.js +0 -57
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mergeMeta
|
|
3
|
+
} from "./index-8qghvg18.js";
|
|
4
|
+
import {
|
|
5
|
+
callRuntimeHandler,
|
|
6
|
+
isRecord,
|
|
7
|
+
transportResult,
|
|
8
|
+
typedEntries
|
|
9
|
+
} from "./index-bmnhqtya.js";
|
|
10
|
+
|
|
11
|
+
// src/server/middleware/cors.ts
|
|
12
|
+
var DEFAULT_CORS_ALLOW_HEADERS = "Content-Type, Authorization, X-Trace-Id, traceparent, tracestate";
|
|
13
|
+
var DEFAULT_CORS_EXPOSE_HEADERS = "Content-Disposition, Content-Length, Content-Range, Accept-Ranges, ETag, Last-Modified, X-Request-Id";
|
|
14
|
+
function assertCorsConfig(config) {
|
|
15
|
+
if (config.credentials && (config.origin === undefined || config.origin === "*")) {
|
|
16
|
+
throw new Error("[stitchkit] cors: `credentials: true` cannot be combined with a wildcard origin. " + "Set `origin` to an explicit string or list.");
|
|
17
|
+
}
|
|
18
|
+
if (config.origin === undefined) {
|
|
19
|
+
throw new Error("[stitchkit] cors: `origin` is required. Pass an explicit origin (or list), or '*' to deliberately allow every origin — omit `cors` entirely to emit no CORS headers.");
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(config.origin) && config.origin.length === 0) {
|
|
22
|
+
throw new Error("[stitchkit] cors: `origin` cannot be an empty list. Pass explicit origins, or '*' to deliberately allow every origin.");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function resolveOrigin(config, requestOrigin) {
|
|
26
|
+
if (config.origin === undefined)
|
|
27
|
+
return;
|
|
28
|
+
if (config.origin === "*") {
|
|
29
|
+
return "*";
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(config.origin)) {
|
|
32
|
+
if (!requestOrigin)
|
|
33
|
+
return;
|
|
34
|
+
const lower = requestOrigin.toLowerCase();
|
|
35
|
+
return config.origin.some((o) => o.toLowerCase() === lower) ? requestOrigin : undefined;
|
|
36
|
+
}
|
|
37
|
+
return config.origin;
|
|
38
|
+
}
|
|
39
|
+
function corsHeaders(config, requestOrigin) {
|
|
40
|
+
const allowOrigin = resolveOrigin(config, requestOrigin);
|
|
41
|
+
const headers = {
|
|
42
|
+
"Access-Control-Allow-Methods": config.methods ?? "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS",
|
|
43
|
+
"Access-Control-Allow-Headers": config.headers ?? DEFAULT_CORS_ALLOW_HEADERS
|
|
44
|
+
};
|
|
45
|
+
const expose = Array.isArray(config.exposeHeaders) ? config.exposeHeaders.join(", ") : config.exposeHeaders ?? DEFAULT_CORS_EXPOSE_HEADERS;
|
|
46
|
+
if (expose !== "") {
|
|
47
|
+
headers["Access-Control-Expose-Headers"] = expose;
|
|
48
|
+
}
|
|
49
|
+
if (allowOrigin !== undefined) {
|
|
50
|
+
headers["Access-Control-Allow-Origin"] = allowOrigin;
|
|
51
|
+
if (config.credentials) {
|
|
52
|
+
headers["Access-Control-Allow-Credentials"] = "true";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(config.origin)) {
|
|
56
|
+
headers.Vary = "Origin";
|
|
57
|
+
}
|
|
58
|
+
return headers;
|
|
59
|
+
}
|
|
60
|
+
function corsPreflightResponse(config, req) {
|
|
61
|
+
return new Response(null, {
|
|
62
|
+
status: 204,
|
|
63
|
+
headers: corsHeaders(config, req.headers.get("origin"))
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/server/implement.ts
|
|
68
|
+
function isStreamingImplementation(value) {
|
|
69
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "stitchkit.multipart.stream";
|
|
70
|
+
}
|
|
71
|
+
function defineMultipartStream(endpoint, config) {
|
|
72
|
+
return buildMultipartStream(endpoint, config.files, config.handler);
|
|
73
|
+
}
|
|
74
|
+
function buildMultipartStream(endpoint, files, handler) {
|
|
75
|
+
const receivers = {};
|
|
76
|
+
for (const [key, receiver] of typedEntries(files)) {
|
|
77
|
+
receivers[String(key)] = receiver;
|
|
78
|
+
}
|
|
79
|
+
const declared = Object.keys(endpoint.multipart.files);
|
|
80
|
+
const configured = Object.keys(receivers);
|
|
81
|
+
if (declared.length !== configured.length || declared.some((field) => !Object.hasOwn(receivers, field))) {
|
|
82
|
+
throw new Error("Streaming multipart receivers must exactly match declared file fields");
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
kind: "stitchkit.multipart.stream",
|
|
86
|
+
receivers,
|
|
87
|
+
execute(ctx, streamedFiles) {
|
|
88
|
+
return callRuntimeHandler(handler, { ...ctx, files: streamedFiles });
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function createMultipartStream() {
|
|
93
|
+
return (endpoint, config) => buildMultipartStream(endpoint, config.files, config.handler);
|
|
94
|
+
}
|
|
95
|
+
function isStreamingEndpoint(endpoint) {
|
|
96
|
+
return endpoint.multipart?.delivery === "stream";
|
|
97
|
+
}
|
|
98
|
+
function contractOnlyService(contract) {
|
|
99
|
+
const handlers = {};
|
|
100
|
+
for (const [key, endpoint] of Object.entries(contract.endpoints)) {
|
|
101
|
+
if (isStreamingEndpoint(endpoint)) {
|
|
102
|
+
const receivers = {};
|
|
103
|
+
for (const field of Object.keys(endpoint.multipart.files)) {
|
|
104
|
+
receivers[field] = () => {
|
|
105
|
+
throw new Error("[stitchkit] contract-only service: handlers are not callable");
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const streaming = {
|
|
109
|
+
kind: "stitchkit.multipart.stream",
|
|
110
|
+
receivers,
|
|
111
|
+
execute: () => {
|
|
112
|
+
throw new Error("[stitchkit] contract-only service: handlers are not callable");
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
handlers[key] = streaming;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
handlers[key] = () => {
|
|
119
|
+
throw new Error("[stitchkit] contract-only service: handlers are not callable");
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return bindContract(contract, handlers);
|
|
123
|
+
}
|
|
124
|
+
var HTTP_ONLY = Object.freeze(["HTTP"]);
|
|
125
|
+
function bindContract(contract, handlers) {
|
|
126
|
+
const methods = {};
|
|
127
|
+
const groupScope = contract.meta.scope ?? "public";
|
|
128
|
+
for (const [key, endpoint] of typedEntries(contract.endpoints)) {
|
|
129
|
+
const typedHandler = handlers[String(key)];
|
|
130
|
+
const isStreaming = endpoint.multipart?.delivery === "stream";
|
|
131
|
+
if (!isStreaming && typeof typedHandler !== "function") {
|
|
132
|
+
throw new Error(`[stitchkit] implement: missing handler for "${contract.meta.prefix}.${String(key)}"`);
|
|
133
|
+
}
|
|
134
|
+
if (isStreaming && !isStreamingImplementation(typedHandler)) {
|
|
135
|
+
throw new Error(`[stitchkit] implement: streaming multipart endpoint "${contract.meta.prefix}.${String(key)}" must use defineMultipartStream()`);
|
|
136
|
+
}
|
|
137
|
+
const streamingHandler = isStreamingImplementation(typedHandler) ? typedHandler : undefined;
|
|
138
|
+
const regularHandler = typeof typedHandler === "function" ? typedHandler : undefined;
|
|
139
|
+
methods[String(key)] = {
|
|
140
|
+
method: endpoint.method,
|
|
141
|
+
path: endpoint.path,
|
|
142
|
+
desc: endpoint.desc,
|
|
143
|
+
serviceName: contract.meta.prefix,
|
|
144
|
+
key: String(key),
|
|
145
|
+
toolName: "toolName" in endpoint ? endpoint.toolName : undefined,
|
|
146
|
+
expose: endpoint.rawResponse || endpoint.rawBody || endpoint.responseMeta ? HTTP_ONLY : endpoint.expose,
|
|
147
|
+
scope: endpoint.scope ?? groupScope,
|
|
148
|
+
paramsSchema: endpoint.params,
|
|
149
|
+
inputSchema: endpoint.input,
|
|
150
|
+
outputSchema: endpoint.output,
|
|
151
|
+
multipart: endpoint.multipart,
|
|
152
|
+
multipartReceivers: streamingHandler?.receivers,
|
|
153
|
+
maxJsonBodyBytes: endpoint.maxJsonBodyBytes,
|
|
154
|
+
idempotent: endpoint.idempotent,
|
|
155
|
+
ui: "ui" in endpoint ? endpoint.ui : undefined,
|
|
156
|
+
annotations: "annotations" in endpoint ? endpoint.annotations : undefined,
|
|
157
|
+
mcp: "mcp" in endpoint ? endpoint.mcp : undefined,
|
|
158
|
+
meta: mergeMeta(contract.meta.meta, endpoint.meta),
|
|
159
|
+
rawResponse: endpoint.rawResponse,
|
|
160
|
+
rawBody: endpoint.rawBody,
|
|
161
|
+
responseMeta: endpoint.responseMeta,
|
|
162
|
+
contentType: "contentType" in endpoint ? endpoint.contentType : undefined,
|
|
163
|
+
handler: streamingHandler ? (ctx) => streamingHandler.execute(ctx, ctx.files ?? {}) : (ctx) => {
|
|
164
|
+
if (!regularHandler) {
|
|
165
|
+
throw new Error(`[stitchkit] implement: missing handler for "${contract.meta.prefix}.${String(key)}"`);
|
|
166
|
+
}
|
|
167
|
+
return callRuntimeHandler(regularHandler, ctx);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
name: contract.meta.prefix,
|
|
173
|
+
prefix: contract.meta.prefix,
|
|
174
|
+
scope: groupScope,
|
|
175
|
+
methods
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function implement(contract, handlers) {
|
|
179
|
+
return bindContract(contract, handlers);
|
|
180
|
+
}
|
|
181
|
+
function createImplement() {
|
|
182
|
+
return (contract, handlers) => implement(contract, handlers);
|
|
183
|
+
}
|
|
184
|
+
function createScopedImplement() {
|
|
185
|
+
const implementScoped = (contract, handlers) => bindContract(contract, handlers);
|
|
186
|
+
const stream = (scope, endpoint, config) => {
|
|
187
|
+
if (endpoint.scope !== undefined && endpoint.scope !== scope) {
|
|
188
|
+
throw new Error(`[stitchkit] createScopedImplement.stream: endpoint declares scope "${endpoint.scope}" but "${String(scope)}" was given`);
|
|
189
|
+
}
|
|
190
|
+
return buildMultipartStream(endpoint, config.files, config.handler);
|
|
191
|
+
};
|
|
192
|
+
return Object.assign(implementScoped, { stream });
|
|
193
|
+
}
|
|
194
|
+
function createScopedImplementRegistry() {
|
|
195
|
+
return (contracts, handlers) => transportResult(bindRegistry(contracts, handlers));
|
|
196
|
+
}
|
|
197
|
+
function isImplementationContract(value) {
|
|
198
|
+
return isRecord(value) && isRecord(value.meta) && typeof value.meta.prefix === "string" && isRecord(value.endpoints);
|
|
199
|
+
}
|
|
200
|
+
function bindRegistry(contracts, handlers) {
|
|
201
|
+
const contractKeys = Object.keys(contracts);
|
|
202
|
+
const handlerKeys = Object.keys(handlers);
|
|
203
|
+
const missing = contractKeys.filter((key) => !Object.hasOwn(handlers, key));
|
|
204
|
+
const extra = handlerKeys.filter((key) => !Object.hasOwn(contracts, key));
|
|
205
|
+
if (missing.length > 0 || extra.length > 0) {
|
|
206
|
+
throw new Error(`[stitchkit] implementRegistry: registry mismatch (missing: ${missing.join(", ") || "none"}; extra: ${extra.join(", ") || "none"})`);
|
|
207
|
+
}
|
|
208
|
+
const prefixes = new Map;
|
|
209
|
+
const services = [];
|
|
210
|
+
const byKey = {};
|
|
211
|
+
for (const [key, candidate] of Object.entries(contracts)) {
|
|
212
|
+
if (!isImplementationContract(candidate)) {
|
|
213
|
+
throw new TypeError(`[stitchkit] implementRegistry: registry entry "${key}" must be one contract; composed arrays and namespaces are not supported`);
|
|
214
|
+
}
|
|
215
|
+
const contract = candidate;
|
|
216
|
+
const previousKey = prefixes.get(contract.meta.prefix);
|
|
217
|
+
if (previousKey !== undefined) {
|
|
218
|
+
throw new Error(`[stitchkit] implementRegistry: duplicate contract prefix "${contract.meta.prefix}" at "${previousKey}" and "${key}"`);
|
|
219
|
+
}
|
|
220
|
+
prefixes.set(contract.meta.prefix, key);
|
|
221
|
+
const entryHandlers = handlers[key];
|
|
222
|
+
if (!isRecord(entryHandlers)) {
|
|
223
|
+
throw new TypeError(`[stitchkit] implementRegistry: handlers for "${key}" must be an object`);
|
|
224
|
+
}
|
|
225
|
+
const endpointKeys = Object.keys(contract.endpoints);
|
|
226
|
+
const handlerEntryKeys = Object.keys(entryHandlers);
|
|
227
|
+
const missingEndpoints = endpointKeys.filter((endpointKey) => !Object.hasOwn(entryHandlers, endpointKey));
|
|
228
|
+
const extraEndpoints = handlerEntryKeys.filter((endpointKey) => !Object.hasOwn(contract.endpoints, endpointKey));
|
|
229
|
+
if (missingEndpoints.length > 0 || extraEndpoints.length > 0) {
|
|
230
|
+
throw new Error(`[stitchkit] implementRegistry: handlers for "${key}" mismatch (missing: ${missingEndpoints.join(", ") || "none"}; extra: ${extraEndpoints.join(", ") || "none"})`);
|
|
231
|
+
}
|
|
232
|
+
const service = bindContract(contract, entryHandlers);
|
|
233
|
+
services.push(service);
|
|
234
|
+
byKey[key] = service;
|
|
235
|
+
}
|
|
236
|
+
Object.defineProperty(services, "byKey", { value: byKey, enumerable: false });
|
|
237
|
+
return transportResult(services);
|
|
238
|
+
}
|
|
239
|
+
function implementRegistry(contracts, handlers) {
|
|
240
|
+
return transportResult(bindRegistry(contracts, handlers));
|
|
241
|
+
}
|
|
242
|
+
function createImplementRegistry() {
|
|
243
|
+
return (contracts, handlers) => transportResult(bindRegistry(contracts, handlers));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export { DEFAULT_CORS_ALLOW_HEADERS, DEFAULT_CORS_EXPOSE_HEADERS, assertCorsConfig, corsHeaders, corsPreflightResponse, defineMultipartStream, createMultipartStream, contractOnlyService, implement, createImplement, createScopedImplement, createScopedImplementRegistry, implementRegistry, createImplementRegistry };
|
package/dist/index.js
CHANGED
package/dist/node.d.ts
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { AppError, appError, badRequest, conflict, forbidden, notFound, rateLimited, unauthorized, } from './contract';
|
|
8
8
|
export { createHandler } from './server/create';
|
|
9
|
-
export { createImplement, createImplementRegistry, type ExactRegistryHandlers, type ImplementationRegistry, implement, implementRegistry, type RegistryHandlers, } from './server/implement';
|
|
9
|
+
export { createImplement, createImplementRegistry, createMultipartStream, createScopedImplement, createScopedImplementRegistry, type ExactRegistryHandlers, type ExactScopedRegistryHandlers, type ImplementationRegistry, implement, implementRegistry, type KeyedServices, type MultipartStreamConfig, type RegistryHandlers, type ScopedImplementationRegistry, type ScopedRegistryHandlers, type StreamScope, } from './server/implement';
|
|
10
10
|
export type { LogFormat } from './server/logger';
|
|
11
11
|
export { type NodeRuntimeServer, type NodeServerConfig, type NodeServerHandle, type NodeSocketLifecycle, serveNode, } from './server/node';
|
|
12
|
+
export { bindProcessSignals, type ProcessSignalName, type ProcessSignalsBinding, type ProcessSignalsErrorPhase, type ProcessSignalsOptions, type ShutdownTarget, type SignalSource, } from './server/process-signals';
|
|
12
13
|
export { bindRealtimeServer, type RealtimeServer, type RealtimeServerConnection, type RealtimeServerHandle, } from './server/realtime';
|
|
13
14
|
export { type ManagedServerHandle, type ShutdownOptions, ShutdownOptionsSchema, type ShutdownResult, ShutdownResultSchema, type ShutdownState, ShutdownStateSchema, type ShutdownStatus, ShutdownStatusSchema, } from './server/shutdown';
|
|
14
15
|
export { createNodeSocketIOServer as createSocketIOServer, type NodeSocketIOServerHandle as SocketIOServerHandle, type SocketIORequestPolicy, type SocketIOServerConfig, } from './server/socket-io-node';
|
|
15
|
-
export type { FetchComposition, FetchHandler, HandlerConfig, LoggingConfig, LogOutcome, RawRoute, RawRouteContext, ServiceDef, } from './server/types';
|
|
16
|
+
export type { EffectiveScope, FetchComposition, FetchHandler, HandlerConfig, LoggingConfig, LogOutcome, RawRoute, RawRouteContext, ScopeContexts, ScopedHandlers, ServiceDef, } from './server/types';
|
|
16
17
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,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,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,aAAa,EAClB,mBAAmB,EACnB,KAAK,cAAc,EACnB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,IAAI,oBAAoB,EAChD,KAAK,wBAAwB,IAAI,oBAAoB,EACrD,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,QAAQ,EACR,eAAe,EACf,aAAa,EACb,cAAc,EACd,UAAU,GACX,MAAM,gBAAgB,CAAC"}
|
package/dist/node.js
CHANGED
|
@@ -3,16 +3,21 @@ import {
|
|
|
3
3
|
ShutdownResultSchema,
|
|
4
4
|
ShutdownStateSchema,
|
|
5
5
|
ShutdownStatusSchema,
|
|
6
|
+
bindProcessSignals,
|
|
6
7
|
bindRealtimeServer,
|
|
7
8
|
createHandler,
|
|
9
|
+
createServerLifecycle,
|
|
10
|
+
createSocketIOServer
|
|
11
|
+
} from "./index-8mt47qk7.js";
|
|
12
|
+
import {
|
|
8
13
|
createImplement,
|
|
9
14
|
createImplementRegistry,
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
createMultipartStream,
|
|
16
|
+
createScopedImplement,
|
|
17
|
+
createScopedImplementRegistry,
|
|
12
18
|
implement,
|
|
13
19
|
implementRegistry
|
|
14
|
-
} from "./index-
|
|
15
|
-
import"./index-r1qp4rve.js";
|
|
20
|
+
} from "./index-ynts85ew.js";
|
|
16
21
|
import {
|
|
17
22
|
AppError,
|
|
18
23
|
appError,
|
|
@@ -22,8 +27,8 @@ import {
|
|
|
22
27
|
notFound,
|
|
23
28
|
rateLimited,
|
|
24
29
|
unauthorized
|
|
25
|
-
} from "./index-
|
|
26
|
-
import"./index-
|
|
30
|
+
} from "./index-8qghvg18.js";
|
|
31
|
+
import"./index-bmnhqtya.js";
|
|
27
32
|
// src/server/node.ts
|
|
28
33
|
import { serve } from "srvx/node";
|
|
29
34
|
async function serveNode(config) {
|
|
@@ -142,11 +147,15 @@ export {
|
|
|
142
147
|
implement,
|
|
143
148
|
forbidden,
|
|
144
149
|
createNodeSocketIOServer as createSocketIOServer,
|
|
150
|
+
createScopedImplementRegistry,
|
|
151
|
+
createScopedImplement,
|
|
152
|
+
createMultipartStream,
|
|
145
153
|
createImplementRegistry,
|
|
146
154
|
createImplement,
|
|
147
155
|
createHandler,
|
|
148
156
|
conflict,
|
|
149
157
|
bindRealtimeServer,
|
|
158
|
+
bindProcessSignals,
|
|
150
159
|
badRequest,
|
|
151
160
|
appError,
|
|
152
161
|
ShutdownStatusSchema,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
redact,
|
|
4
4
|
sanitizePayload,
|
|
5
5
|
truncatePreview
|
|
6
|
-
} from "../index-
|
|
6
|
+
} from "../index-psrxjvbw.js";
|
|
7
7
|
import {
|
|
8
8
|
getRequestContext,
|
|
9
9
|
getTraceId,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
setRequestError,
|
|
16
16
|
setRequestUser,
|
|
17
17
|
wrapInRequestContext
|
|
18
|
-
} from "../index-
|
|
18
|
+
} from "../index-8qghvg18.js";
|
|
19
19
|
import {
|
|
20
20
|
childSpan,
|
|
21
21
|
createTraceContext,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
parseTraceparent,
|
|
25
25
|
resolvePropagationContext,
|
|
26
26
|
resolveTraceContext
|
|
27
|
-
} from "../index-
|
|
27
|
+
} from "../index-bmnhqtya.js";
|
|
28
28
|
|
|
29
29
|
// src/observability/status.ts
|
|
30
30
|
import { z } from "zod";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ZodType } from 'zod';
|
|
2
2
|
import type { ContractDef, EndpointDef, MultipartDescriptor, RuntimeContext } from '../contract';
|
|
3
|
-
import type { EndpointHandlerContext, Handlers, MultipartReceiver, ServiceDef, StreamingMultipartImplementation } from './types';
|
|
3
|
+
import type { EndpointHandlerContext, Handlers, MultipartReceiver, ScopeContexts, ScopedHandlers, ServiceDef, StreamingMultipartImplementation } from './types';
|
|
4
4
|
type StreamingEndpoint = EndpointDef & {
|
|
5
5
|
multipart: MultipartDescriptor & {
|
|
6
6
|
delivery: 'stream';
|
|
@@ -21,15 +21,43 @@ type StreamingReturn<E extends EndpointDef> = E extends {
|
|
|
21
21
|
output: ZodType<infer O>;
|
|
22
22
|
} ? O | Promise<O> : void | Promise<void>;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* Receivers plus the final handler for one streaming multipart endpoint. `TCtx`
|
|
25
|
+
* is the handler context: `RuntimeContext` by default, an application context
|
|
26
|
+
* through `createMultipartStream`, a scope's context through
|
|
27
|
+
* `createScopedImplement(...).stream`.
|
|
26
28
|
*/
|
|
27
|
-
export
|
|
29
|
+
export interface MultipartStreamConfig<E extends StreamingEndpoint, R extends ReceiverMap<E>, TCtx extends RuntimeContext> {
|
|
28
30
|
files: R & Record<Exclude<keyof R, keyof E['multipart']['files']>, never>;
|
|
29
|
-
handler: (ctx: EndpointHandlerContext<E,
|
|
31
|
+
handler: (ctx: EndpointHandlerContext<E, TCtx> & {
|
|
30
32
|
files: StreamedFiles<E, R>;
|
|
31
33
|
}) => StreamingReturn<E>;
|
|
32
|
-
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Bind streaming multipart receivers to one endpoint while inferring the
|
|
37
|
+
* receiver values handed to its final handler.
|
|
38
|
+
*
|
|
39
|
+
* The handler context is the loose `RuntimeContext`. To read fields the
|
|
40
|
+
* application injects, build the implementation through
|
|
41
|
+
* `createMultipartStream<Ctx>()` or, in a scoped app,
|
|
42
|
+
* `createScopedImplement<Scopes>().stream(scope, …)`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function defineMultipartStream<const E extends StreamingEndpoint, const R extends ReceiverMap<E>>(endpoint: E, config: MultipartStreamConfig<E, R, RuntimeContext>): StreamingMultipartImplementation;
|
|
45
|
+
/**
|
|
46
|
+
* Fix one handler context type for streaming multipart endpoints, the way
|
|
47
|
+
* `createImplement` fixes it for ordinary handlers. Without this, a streaming
|
|
48
|
+
* handler only ever sees the loose `RuntimeContext`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createMultipartStream<TCtx extends RuntimeContext>(): <const E extends StreamingEndpoint, const R extends ReceiverMap<E>>(endpoint: E, config: MultipartStreamConfig<E, R, TCtx>) => StreamingMultipartImplementation;
|
|
51
|
+
/**
|
|
52
|
+
* A `ServiceDef` whose handlers only throw — enough for everything that reads
|
|
53
|
+
* the mounted surface (names, exposure, kinds) without implementing anything.
|
|
54
|
+
*
|
|
55
|
+
* Internal on purpose (not re-exported from an entrypoint): a listing helper.
|
|
56
|
+
* Going through the real `bindContract` is the point — the produced methods are
|
|
57
|
+
* the same objects the real mounts see, so a name listing derived from here can
|
|
58
|
+
* never drift from the mounted surface.
|
|
59
|
+
*/
|
|
60
|
+
export declare function contractOnlyService(contract: ContractDef): ServiceDef;
|
|
33
61
|
export declare function implement<T extends Record<string, EndpointDef>, TCtx extends RuntimeContext = RuntimeContext>(contract: ContractDef<T, string>, handlers: Handlers<T, TCtx>): ServiceDef;
|
|
34
62
|
/**
|
|
35
63
|
* Fix the handler context type once — `const implement =
|
|
@@ -37,6 +65,54 @@ export declare function implement<T extends Record<string, EndpointDef>, TCtx ex
|
|
|
37
65
|
* the generic. The application declares its context shape in a single place.
|
|
38
66
|
*/
|
|
39
67
|
export declare function createImplement<TCtx extends RuntimeContext>(): <T extends Record<string, EndpointDef>>(contract: ContractDef<T, string>, handlers: Handlers<T, TCtx>) => ServiceDef;
|
|
68
|
+
/**
|
|
69
|
+
* Fix one scope→context map for the application, then implement every contract
|
|
70
|
+
* with it — each handler typed by its endpoint's **effective** scope rather than
|
|
71
|
+
* by a superset that promises fields the runtime never injects into a
|
|
72
|
+
* `public` call.
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* const implementFor = createScopedImplement<{
|
|
76
|
+
* public: object
|
|
77
|
+
* user: { userId: string }
|
|
78
|
+
* admin: { userId: string; isAdmin: true }
|
|
79
|
+
* }>()
|
|
80
|
+
*
|
|
81
|
+
* implementFor(usersContract, { … }) // ctx typed per endpoint scope
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* The map is type-only — scope fields are types, and a runtime map would force
|
|
85
|
+
* `{} as UserFields` at the call site. A contract with no `scope` is `'public'`
|
|
86
|
+
* (→ `defineContract`), so `'public'` must be a key of the map.
|
|
87
|
+
*
|
|
88
|
+
* The map states what the application's `beforeHandle` / `createAuthHook.inject`
|
|
89
|
+
* puts in the context. The framework does not verify it — a scope whose fields
|
|
90
|
+
* are never injected still type-checks. → ADR 0075.
|
|
91
|
+
*/
|
|
92
|
+
export declare function createScopedImplement<TScopes extends ScopeContexts>(): (<const T extends Record<string, EndpointDef>, TContractScope extends Extract<keyof TScopes, string>>(contract: ContractDef<T, TContractScope>, handlers: ScopedHandlers<T, TContractScope, TScopes>) => ServiceDef) & {
|
|
93
|
+
stream: <const E extends StreamingEndpoint, const R extends ReceiverMap<E>>(scope: StreamScope<E, TScopes>, endpoint: E, config: MultipartStreamConfig<E, R, RuntimeContext & TScopes[StreamScope<E, TScopes> & keyof TScopes]>) => StreamingMultipartImplementation;
|
|
94
|
+
};
|
|
95
|
+
/** A contract registry whose every group scope is a key of the scope map. */
|
|
96
|
+
export type ScopedImplementationRegistry<TScopes extends ScopeContexts> = Record<string, ContractDef<Record<string, EndpointDef>, Extract<keyof TScopes, string>>>;
|
|
97
|
+
/**
|
|
98
|
+
* The scope `createScopedImplement(...).stream` accepts for one endpoint: the
|
|
99
|
+
* literal the endpoint declares, or a message explaining why it cannot be typed.
|
|
100
|
+
*/
|
|
101
|
+
export type StreamScope<E extends EndpointDef, TScopes extends ScopeContexts> = 'scope' extends keyof E ? undefined extends E['scope'] ? 'stitchkit: .stream() needs the endpoint to declare its own scope' : Extract<E['scope'], string> extends infer S extends string ? [S] extends [Extract<keyof TScopes, string>] ? S : `stitchkit: scope "${S}" is not declared in createScopedImplement` : 'stitchkit: .stream() needs the endpoint to declare its own scope' : 'stitchkit: .stream() needs the endpoint to declare its own scope';
|
|
102
|
+
/** Exact scoped handlers map derived from a literal contract registry. */
|
|
103
|
+
export type ScopedRegistryHandlers<TContracts extends ImplementationRegistry, TScopes extends ScopeContexts> = {
|
|
104
|
+
[K in keyof TContracts]: TContracts[K] extends ContractDef<infer TEndpoints, infer TContractScope extends string> ? ScopedHandlers<TEndpoints, TContractScope, TScopes> : never;
|
|
105
|
+
};
|
|
106
|
+
export type ExactScopedRegistryHandlers<TContracts extends ImplementationRegistry, THandlers extends ScopedRegistryHandlers<TContracts, TScopes>, TScopes extends ScopeContexts> = THandlers & ScopedRegistryHandlers<TContracts, TScopes> & Record<Exclude<keyof THandlers, keyof TContracts>, never> & {
|
|
107
|
+
[K in keyof THandlers & keyof TContracts]: THandlers[K] & Record<Exclude<keyof THandlers[K], keyof ScopedRegistryHandlers<TContracts, TScopes>[K]>, never>;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* The registry form of {@link createScopedImplement} — one literal contract
|
|
111
|
+
* registry bound to one handler registry, with every handler still typed by its
|
|
112
|
+
* endpoint's effective scope. Missing, extra and endpoint-incompatible entries
|
|
113
|
+
* fail exactly as they do in `implementRegistry`.
|
|
114
|
+
*/
|
|
115
|
+
export declare function createScopedImplementRegistry<TScopes extends ScopeContexts>(): <const TContracts extends ScopedImplementationRegistry<TScopes>, const THandlers extends ScopedRegistryHandlers<TContracts, TScopes>>(contracts: TContracts, handlers: ExactScopedRegistryHandlers<TContracts, THandlers, TScopes>) => KeyedServices<TContracts>;
|
|
40
116
|
export type ImplementationRegistry = Record<string, ContractDef<Record<string, EndpointDef>, string>>;
|
|
41
117
|
/** Exact handlers map derived from a literal contract registry. */
|
|
42
118
|
export type RegistryHandlers<TContracts extends ImplementationRegistry, TCtx extends RuntimeContext = RuntimeContext> = {
|
|
@@ -45,13 +121,30 @@ export type RegistryHandlers<TContracts extends ImplementationRegistry, TCtx ext
|
|
|
45
121
|
export type ExactRegistryHandlers<TContracts extends ImplementationRegistry, THandlers extends RegistryHandlers<TContracts, TCtx>, TCtx extends RuntimeContext> = THandlers & RegistryHandlers<TContracts, TCtx> & Record<Exclude<keyof THandlers, keyof TContracts>, never> & {
|
|
46
122
|
[K in keyof THandlers & keyof TContracts]: THandlers[K] & Record<Exclude<keyof THandlers[K], keyof RegistryHandlers<TContracts, TCtx>[K]>, never>;
|
|
47
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Registry results keep both shapes: the mount-ordered array a server consumes,
|
|
126
|
+
* and the same services by their registry key. Keys are load-bearing for
|
|
127
|
+
* consumers that filter a tool surface per caller ("these bots see only
|
|
128
|
+
* services X and Y") — dropping them forced a hand-rebuilt prefix lookup, and a
|
|
129
|
+
* silent one at that.
|
|
130
|
+
*/
|
|
131
|
+
export type KeyedServices<TContracts extends ImplementationRegistry> = ServiceDef[] & {
|
|
132
|
+
/**
|
|
133
|
+
* The same services, by registry key. Same objects as the array entries.
|
|
134
|
+
* Non-enumerable: `Object.keys` / `Object.values` / object spread of the
|
|
135
|
+
* array see only the services, exactly as before.
|
|
136
|
+
*/
|
|
137
|
+
readonly byKey: {
|
|
138
|
+
readonly [K in keyof TContracts]: ServiceDef;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
48
141
|
/**
|
|
49
142
|
* Bind an exact `name → contract` registry to its exact handlers map. Missing,
|
|
50
143
|
* extra and endpoint-incompatible implementations fail at compile time; loose
|
|
51
144
|
* JavaScript callers receive the same checks at runtime.
|
|
52
145
|
*/
|
|
53
|
-
export declare function implementRegistry<const TContracts extends ImplementationRegistry, const THandlers extends RegistryHandlers<TContracts>>(contracts: TContracts, handlers: ExactRegistryHandlers<TContracts, THandlers, RuntimeContext>):
|
|
146
|
+
export declare function implementRegistry<const TContracts extends ImplementationRegistry, const THandlers extends RegistryHandlers<TContracts>>(contracts: TContracts, handlers: ExactRegistryHandlers<TContracts, THandlers, RuntimeContext>): KeyedServices<TContracts>;
|
|
54
147
|
/** Fix one handler context type for every entry in an implementation registry. */
|
|
55
|
-
export declare function createImplementRegistry<TCtx extends RuntimeContext>(): <const TContracts extends ImplementationRegistry, const THandlers extends RegistryHandlers<TContracts, TCtx>>(contracts: TContracts, handlers: ExactRegistryHandlers<TContracts, THandlers, TCtx>) =>
|
|
148
|
+
export declare function createImplementRegistry<TCtx extends RuntimeContext>(): <const TContracts extends ImplementationRegistry, const THandlers extends RegistryHandlers<TContracts, TCtx>>(contracts: TContracts, handlers: ExactRegistryHandlers<TContracts, THandlers, TCtx>) => KeyedServices<TContracts>;
|
|
56
149
|
export {};
|
|
57
150
|
//# sourceMappingURL=implement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implement.d.ts","sourceRoot":"","sources":["../../src/server/implement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,cAAc,EACf,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"implement.d.ts","sourceRoot":"","sources":["../../src/server/implement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,cAAc,EACf,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,EACV,sBAAsB,EACtB,QAAQ,EAER,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,UAAU,EACV,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAEjB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C;AAgEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,CAAC,UAAU,SAAS,sBAAsB,EAC/C,KAAK,CAAC,SAAS,SAAS,gBAAgB,CAAC,UAAU,CAAC,EAEpD,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,qBAAqB,CAAC,UAAU,EAAE,SAAS,EAAE,cAAc,CAAC,GACrE,aAAa,CAAC,UAAU,CAAC,CAK3B;AAED,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,IAAI,SAAS,cAAc,MAE/D,KAAK,CAAC,UAAU,SAAS,sBAAsB,EAC/C,KAAK,CAAC,SAAS,SAAS,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,aAE/C,UAAU,YACX,qBAAqB,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,KAC3D,aAAa,CAAC,UAAU,CAAC,CAG7B"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -7,14 +7,15 @@ export { createHandler } from './create';
|
|
|
7
7
|
export { createErrorHook, type ErrorHookConfig, type ResolvedError, } from './error-hook';
|
|
8
8
|
export { createEventBus, type DefaultEventMap, type EventBus, type EventBusOptions, type EventHandler, } from './event-bus';
|
|
9
9
|
export { type ByteRange, parseByteRange, type ServeFileOptions, serveFile, staticRoute, weakETag, } from './file';
|
|
10
|
-
export { createImplement, createImplementRegistry, defineMultipartStream, type ExactRegistryHandlers, type ImplementationRegistry, implement, implementRegistry, type RegistryHandlers, } from './implement';
|
|
10
|
+
export { createImplement, createImplementRegistry, createMultipartStream, createScopedImplement, createScopedImplementRegistry, defineMultipartStream, type ExactRegistryHandlers, type ExactScopedRegistryHandlers, type ImplementationRegistry, implement, implementRegistry, type KeyedServices, type MultipartStreamConfig, type RegistryHandlers, type ScopedImplementationRegistry, type ScopedRegistryHandlers, type StreamScope, } from './implement';
|
|
11
11
|
export type { LogFormat } from './logger';
|
|
12
|
-
export { type AuthHook, type AuthHookConfig, type AuthRule, type BearerResolverConfig, createAuthHook, createBearerResolver, extractToken, type JwtPayload, type SignJwtOptions, signJwt, type VerifyJwtOptions, verifyJwt, } from './middleware/auth';
|
|
12
|
+
export { type AuthHook, type AuthHookConfig, type AuthRule, type AuthRules, type AuthScopes, type BearerResolverConfig, createAuthHook, createBearerResolver, extractToken, type JwtPayload, type RuleScopes, type ScopedAuthHook, type ScopedAuthRule, type SignJwtOptions, signJwt, type VerifyJwtOptions, verifyJwt, } from './middleware/auth';
|
|
13
13
|
export { type CookieDef, type CookieOptions, defineCookie, parseCookies, serializeCookie, } from './middleware/cookies';
|
|
14
14
|
export { type CorsConfig, corsHeaders, corsPreflightResponse, DEFAULT_CORS_ALLOW_HEADERS, DEFAULT_CORS_EXPOSE_HEADERS, } from './middleware/cors';
|
|
15
15
|
export { deriveCodeChallenge, type PkceMethod, verifyPkce } from './middleware/pkce';
|
|
16
16
|
export { type MultipartLifecycle, type MultipartResult, parseMultipart } from './multipart';
|
|
17
17
|
export { generateOpenApiDocument, type OpenApiConfig, type OpenApiDocument, type OpenApiInfo, type OpenApiServer, openApiRoute, } from './openapi';
|
|
18
|
+
export { bindProcessSignals, type ProcessSignalName, type ProcessSignalsBinding, type ProcessSignalsErrorPhase, type ProcessSignalsOptions, type ShutdownTarget, type SignalSource, } from './process-signals';
|
|
18
19
|
export { createRateLimiter, type RateLimitConfig } from './rate-limit';
|
|
19
20
|
export { errorResponse, parseBody, respondJson } from './raw';
|
|
20
21
|
export { bindRealtimeServer, type RealtimeServer, type RealtimeServerConnection, type RealtimeServerHandle, } from './realtime';
|
|
@@ -23,6 +24,6 @@ export { type ManagedServerHandle, type ShutdownOptions, ShutdownOptionsSchema,
|
|
|
23
24
|
export type { SocketIORequestPolicy, SocketIOServerConfig, SocketIOServerHandle, SocketIOServerLifecycle, } from './socket-io';
|
|
24
25
|
export { createSocketIOServer, socketIoLane } from './socket-io';
|
|
25
26
|
export { type ParseSSEOptions, parseSSE, streamSSE } from './stream';
|
|
26
|
-
export type { AuthorizationContext, EndpointHandlerContext, Handlers, LifecycleHooks, LoggingConfig, LogOutcome, MethodDef, MultipartFileMetadata, MultipartReceiver, MultipartReceiverResult, OperationIdentity, RouteGroup, ServiceDef, StitchLogger, StreamingMultipartImplementation, } from './types';
|
|
27
|
+
export type { AuthorizationContext, EffectiveScope, EndpointHandlerContext, Handlers, LifecycleHooks, LoggingConfig, LogOutcome, MethodDef, MultipartFileMetadata, MultipartReceiver, MultipartReceiverResult, OperationIdentity, RouteGroup, ScopeContexts, ScopedHandlers, ServiceDef, StitchLogger, StreamingMultipartImplementation, } from './types';
|
|
27
28
|
export { type ComposedLane, composeWebSocketHandlers, type WebSocketComposeConfig, type WebSocketLane, webSocketLane, } from './websocket';
|
|
28
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe,EAC1C,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,SAAS,EACd,cAAc,EACd,KAAK,gBAAgB,EACrB,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,SAAS,EACT,iBAAiB,EACjB,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe,EAC1C,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,K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