@temporary-name/server 1.9.3-alpha.beffd198e2d5853e3d12fa1517c8c9c06bbe6cee → 1.9.3-alpha.cd9bac3545348e08cfaddb66f59c70d314145115
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/adapters/aws-lambda/index.d.mts +4 -4
- package/dist/adapters/aws-lambda/index.d.ts +4 -4
- package/dist/adapters/aws-lambda/index.mjs +4 -5
- package/dist/adapters/fetch/index.d.mts +4 -4
- package/dist/adapters/fetch/index.d.ts +4 -4
- package/dist/adapters/fetch/index.mjs +4 -5
- package/dist/adapters/node/index.d.mts +5 -5
- package/dist/adapters/node/index.d.ts +5 -5
- package/dist/adapters/node/index.mjs +4 -5
- package/dist/{adapters/standard → handler}/index.d.mts +2 -2
- package/dist/{adapters/standard → handler}/index.d.ts +2 -2
- package/dist/{adapters/standard → handler}/index.mjs +3 -4
- package/dist/index.d.mts +277 -23
- package/dist/index.d.ts +277 -23
- package/dist/index.mjs +395 -90
- package/dist/openapi/index.d.mts +11 -30
- package/dist/openapi/index.d.ts +11 -30
- package/dist/openapi/index.mjs +339 -297
- package/dist/shared/{server.Cza0RB3u.mjs → server.BCY45g2x.mjs} +1 -1
- package/dist/shared/{server.ChOv1yG3.mjs → server.BETu17rq.mjs} +1 -1
- package/dist/shared/server.B_oW_rPl.mjs +525 -0
- package/dist/shared/server.CjPiuQYH.d.mts +51 -0
- package/dist/shared/server.CjPiuQYH.d.ts +51 -0
- package/dist/shared/{server.CfPVwdtY.d.mts → server.CunymBH3.d.mts} +4 -6
- package/dist/shared/{server.B_TpRN8E.d.ts → server.DGMnYd7G.d.ts} +4 -6
- package/dist/shared/{server.CYa9puL2.mjs → server.xNz5cP2B.mjs} +19 -101
- package/dist/shared/{server.BfraJHay.d.mts → server.zsKBRxsz.d.mts} +26 -11
- package/dist/shared/{server.BfraJHay.d.ts → server.zsKBRxsz.d.ts} +26 -11
- package/package.json +11 -11
- package/dist/shared/server.CQIFwyhc.mjs +0 -40
- package/dist/shared/server.YUvuxHty.mjs +0 -48
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTTPPath, StandardResponse, StandardLazyRequest } from '@temporary-name/shared';
|
|
2
|
-
import { C as Context,
|
|
2
|
+
import { C as Context, l as Router } from './server.zsKBRxsz.js';
|
|
3
3
|
|
|
4
4
|
interface StandardHandleOptions<T extends Context> {
|
|
5
5
|
prefix?: HTTPPath;
|
|
@@ -12,11 +12,9 @@ type StandardHandleResult = {
|
|
|
12
12
|
matched: false;
|
|
13
13
|
response: undefined;
|
|
14
14
|
};
|
|
15
|
-
interface StandardHandlerOptions<_TContext extends Context> {
|
|
16
|
-
}
|
|
17
15
|
declare class StandardHandler<T extends Context> {
|
|
18
16
|
private readonly matcher;
|
|
19
|
-
constructor(router: Router<T
|
|
17
|
+
constructor(router: Router<T>);
|
|
20
18
|
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
|
21
19
|
}
|
|
22
20
|
|
|
@@ -37,5 +35,5 @@ declare function toRou3Pattern(path: HTTPPath): string;
|
|
|
37
35
|
*/
|
|
38
36
|
declare function decodeParams(params: Record<string, string>): Record<string, string>;
|
|
39
37
|
|
|
40
|
-
export { StandardHandler as
|
|
41
|
-
export type { FriendlyStandardHandleOptions as F, StandardHandleOptions as S, StandardHandleResult as a
|
|
38
|
+
export { StandardHandler as b, decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
|
|
39
|
+
export type { FriendlyStandardHandleOptions as F, StandardHandleOptions as S, StandardHandleResult as a };
|
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import { isObject, NullProtoObj,
|
|
2
|
-
import { c as createProcedureClient } from './server.
|
|
1
|
+
import { isObject, NullProtoObj, fallbackContractConfig, stringifyJSON, isAsyncIteratorObject, toORPCError, isORPCErrorStatus, tryDecodeURIComponent, toHttpPath, runWithSpan, ORPC_NAME, asyncIteratorWithSpan, setSpanError, ORPCError } from '@temporary-name/shared';
|
|
2
|
+
import { c as createProcedureClient } from './server.BCY45g2x.mjs';
|
|
3
3
|
import { mapEventIterator, ErrorEvent } from '@temporary-name/standard-server';
|
|
4
|
-
import { j as jsonSerialize } from './server.CQIFwyhc.mjs';
|
|
5
4
|
import { traverseContractProcedures, getLazyMeta, unlazy } from '@temporary-name/server';
|
|
6
5
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
7
|
-
import { s as standardizeHTTPPath } from './server.
|
|
6
|
+
import { s as standardizeHTTPPath } from './server.BETu17rq.mjs';
|
|
8
7
|
|
|
9
|
-
function bracketNotationSerialize(data, segments = [], result = []) {
|
|
10
|
-
if (Array.isArray(data)) {
|
|
11
|
-
data.forEach((item, i) => {
|
|
12
|
-
bracketNotationSerialize(item, [...segments, i], result);
|
|
13
|
-
});
|
|
14
|
-
} else if (isObject(data)) {
|
|
15
|
-
for (const key in data) {
|
|
16
|
-
bracketNotationSerialize(data[key], [...segments, key], result);
|
|
17
|
-
}
|
|
18
|
-
} else {
|
|
19
|
-
result.push([stringifyPath(segments), data]);
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
}
|
|
23
8
|
function bracketNotationDeserialize(serialized, { maxArrayIndex = 9999 } = {}) {
|
|
24
9
|
if (serialized.length === 0) {
|
|
25
10
|
return {};
|
|
@@ -77,28 +62,6 @@ function bracketNotationDeserialize(serialized, { maxArrayIndex = 9999 } = {}) {
|
|
|
77
62
|
}
|
|
78
63
|
return ref.value;
|
|
79
64
|
}
|
|
80
|
-
function stringifyPath(segments) {
|
|
81
|
-
return segments.map((segment) => {
|
|
82
|
-
return segment.toString().replace(/[\\[\]]/g, (match) => {
|
|
83
|
-
switch (match) {
|
|
84
|
-
case "\\":
|
|
85
|
-
return "\\\\";
|
|
86
|
-
case "[":
|
|
87
|
-
return "\\[";
|
|
88
|
-
case "]":
|
|
89
|
-
return "\\]";
|
|
90
|
-
/* v8 ignore next 2 */
|
|
91
|
-
default:
|
|
92
|
-
return match;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}).reduce((result, segment, i) => {
|
|
96
|
-
if (i === 0) {
|
|
97
|
-
return segment;
|
|
98
|
-
}
|
|
99
|
-
return `${result}[${segment}]`;
|
|
100
|
-
}, "");
|
|
101
|
-
}
|
|
102
65
|
function parsePath(path) {
|
|
103
66
|
const segments = [];
|
|
104
67
|
let inBrackets = false;
|
|
@@ -143,73 +106,28 @@ function pushStyleArrayToObject(array) {
|
|
|
143
106
|
return obj;
|
|
144
107
|
}
|
|
145
108
|
|
|
146
|
-
function
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
cause: e
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
return _serialize(data, options);
|
|
159
|
-
}
|
|
160
|
-
function _serialize(data, options) {
|
|
161
|
-
const [json, hasBlob] = jsonSerialize(data);
|
|
162
|
-
if (options.outputFormat === "plain") {
|
|
163
|
-
return json;
|
|
164
|
-
}
|
|
165
|
-
if (options.outputFormat === "URLSearchParams") {
|
|
166
|
-
const params = new URLSearchParams();
|
|
167
|
-
for (const [path, value] of bracketNotationSerialize(json)) {
|
|
168
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
169
|
-
params.append(path, value.toString());
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return params;
|
|
173
|
-
}
|
|
174
|
-
if (json instanceof Blob || json === void 0 || !hasBlob) {
|
|
175
|
-
return json;
|
|
176
|
-
}
|
|
177
|
-
const form = new FormData();
|
|
178
|
-
for (const [path, value] of bracketNotationSerialize(json)) {
|
|
179
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
180
|
-
form.append(path, value.toString());
|
|
181
|
-
} else if (value instanceof Blob) {
|
|
182
|
-
form.append(path, value);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return form;
|
|
109
|
+
async function decode(request, pathParams) {
|
|
110
|
+
return {
|
|
111
|
+
path: pathParams ?? {},
|
|
112
|
+
query: bracketNotationDeserialize(Array.from(request.url.searchParams.entries())),
|
|
113
|
+
headers: request.headers,
|
|
114
|
+
body: await request.body() ?? {}
|
|
115
|
+
};
|
|
186
116
|
}
|
|
187
|
-
function
|
|
188
|
-
if (data instanceof URLSearchParams || data instanceof FormData) {
|
|
189
|
-
return bracketNotationDeserialize(Array.from(data.entries()));
|
|
190
|
-
}
|
|
117
|
+
function asyncSafeSerialize(data) {
|
|
191
118
|
if (isAsyncIteratorObject(data)) {
|
|
192
119
|
return mapEventIterator(data, {
|
|
193
120
|
value: async (value) => value,
|
|
194
121
|
error: async (e) => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
122
|
+
return new ErrorEvent({
|
|
123
|
+
data: toORPCError(e).toJSON(),
|
|
124
|
+
cause: e
|
|
125
|
+
});
|
|
199
126
|
}
|
|
200
127
|
});
|
|
201
128
|
}
|
|
202
129
|
return data;
|
|
203
130
|
}
|
|
204
|
-
|
|
205
|
-
async function decode(request, pathParams) {
|
|
206
|
-
return {
|
|
207
|
-
path: pathParams ?? {},
|
|
208
|
-
query: bracketNotationDeserialize(Array.from(request.url.searchParams.entries())),
|
|
209
|
-
headers: request.headers,
|
|
210
|
-
body: deserialize(await request.body()) ?? {}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
131
|
function encode(output, procedure) {
|
|
214
132
|
const successStatus = fallbackContractConfig(
|
|
215
133
|
"defaultSuccessStatus",
|
|
@@ -223,7 +141,7 @@ function encode(output, procedure) {
|
|
|
223
141
|
return {
|
|
224
142
|
status: successStatus,
|
|
225
143
|
headers: new Headers(),
|
|
226
|
-
body:
|
|
144
|
+
body: asyncSafeSerialize(output)
|
|
227
145
|
};
|
|
228
146
|
}
|
|
229
147
|
if (!isDetailedOutput(output)) {
|
|
@@ -242,14 +160,14 @@ function encode(output, procedure) {
|
|
|
242
160
|
return {
|
|
243
161
|
status: output.status ?? successStatus,
|
|
244
162
|
headers: output.headers ?? new Headers(),
|
|
245
|
-
body:
|
|
163
|
+
body: asyncSafeSerialize(output.body)
|
|
246
164
|
};
|
|
247
165
|
}
|
|
248
166
|
function encodeError(error) {
|
|
249
167
|
return {
|
|
250
168
|
status: error.status,
|
|
251
169
|
headers: new Headers(),
|
|
252
|
-
body:
|
|
170
|
+
body: error.toJSON()
|
|
253
171
|
};
|
|
254
172
|
}
|
|
255
173
|
function isDetailedOutput(output) {
|
|
@@ -331,7 +249,7 @@ class StandardOpenAPIMatcher {
|
|
|
331
249
|
|
|
332
250
|
class StandardHandler {
|
|
333
251
|
matcher;
|
|
334
|
-
constructor(router
|
|
252
|
+
constructor(router) {
|
|
335
253
|
this.matcher = new StandardOpenAPIMatcher();
|
|
336
254
|
this.matcher.init(router);
|
|
337
255
|
}
|
|
@@ -184,7 +184,6 @@ type MergedSchemas<T1 extends Schemas, T2 extends Partial<Schemas>> = {
|
|
|
184
184
|
outputSchema: T2['outputSchema'] extends AnySchema ? T2['outputSchema'] : T1['outputSchema'];
|
|
185
185
|
};
|
|
186
186
|
|
|
187
|
-
type DefaultProcedureHandlerOptions = ProcedureHandlerOptions<Context, Meta>;
|
|
188
187
|
interface ProcedureHandlerOptions<TCurrentContext extends Context, TMeta extends Meta> {
|
|
189
188
|
context: TCurrentContext;
|
|
190
189
|
path: readonly string[];
|
|
@@ -205,7 +204,7 @@ interface ContractDef<TSchemas extends Schemas, TMeta extends Meta> {
|
|
|
205
204
|
route: Route;
|
|
206
205
|
schemas: TSchemas;
|
|
207
206
|
middlewares: readonly AnyMiddleware[];
|
|
208
|
-
authConfigs:
|
|
207
|
+
authConfigs: AnyAuthConfig[];
|
|
209
208
|
inputValidationIndex: number;
|
|
210
209
|
outputValidationIndex: number;
|
|
211
210
|
}
|
|
@@ -232,22 +231,38 @@ type AnyProcedure = Procedure<any, any, Schemas, any>;
|
|
|
232
231
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
233
232
|
|
|
234
233
|
type ValidatedAuthContext = {};
|
|
235
|
-
interface
|
|
234
|
+
interface BaseAuthConfig {
|
|
235
|
+
oasDescription?: string;
|
|
236
|
+
oasName?: string;
|
|
237
|
+
}
|
|
238
|
+
interface BasicAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends BaseAuthConfig {
|
|
236
239
|
tokenPrefix?: string;
|
|
237
240
|
validate: (username: string, password: string, options: ProcedureHandlerOptions<TCurrentContext, TMeta>) => Promisable<TAuthContext>;
|
|
238
241
|
}
|
|
239
|
-
interface
|
|
242
|
+
interface BearerAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends TokenAuthConfig<TAuthContext, TCurrentContext, TMeta> {
|
|
243
|
+
oasBearerFormat?: string;
|
|
244
|
+
}
|
|
245
|
+
interface TokenAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends BaseAuthConfig {
|
|
240
246
|
tokenPrefix?: string;
|
|
241
247
|
validate: (token: string, options: ProcedureHandlerOptions<TCurrentContext, TMeta>) => Promisable<TAuthContext>;
|
|
242
248
|
}
|
|
243
249
|
interface NamedTokenAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends TokenAuthConfig<TAuthContext, TCurrentContext, TMeta> {
|
|
244
250
|
name: string;
|
|
245
251
|
}
|
|
246
|
-
type
|
|
247
|
-
type AuthConfig<
|
|
248
|
-
type
|
|
249
|
-
|
|
250
|
-
|
|
252
|
+
type AnyAuthConfig = AuthConfig<any, any, any>;
|
|
253
|
+
type AuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> = ({
|
|
254
|
+
type: 'basic';
|
|
255
|
+
} & BasicAuthConfig<TAuthContext, TCurrentContext, TMeta>) | ({
|
|
256
|
+
type: 'bearer';
|
|
257
|
+
} & BearerAuthConfig<TAuthContext, TCurrentContext, TMeta>) | ({
|
|
258
|
+
type: 'header';
|
|
259
|
+
} & NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta>) | ({
|
|
260
|
+
type: 'query';
|
|
261
|
+
} & NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta>) | ({
|
|
262
|
+
type: 'cookie';
|
|
263
|
+
} & NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta>) | {
|
|
264
|
+
type: 'none';
|
|
265
|
+
};
|
|
251
266
|
|
|
252
267
|
type ContractRouter = Contract | {
|
|
253
268
|
[k: string]: ContractRouter;
|
|
@@ -369,5 +384,5 @@ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
|
369
384
|
default: T extends Lazy<infer U> ? U : T;
|
|
370
385
|
}>;
|
|
371
386
|
|
|
372
|
-
export {
|
|
373
|
-
export type {
|
|
387
|
+
export { getLazyMeta as D, unlazy as F, mergeMeta as G, middlewareOutputFn as O, Procedure as P, isProcedure as Y, getRouter as a4, createAccessibleLazyRouter as a6, enhanceRouter as a7, traverseContractProcedures as ac, resolveContractProcedures as ad, unlazyRouter as af, initialSchemas as ah, Contract as b, mergeCurrentContext as u, LAZY_SYMBOL as v, lazyInternal as x, lazy as y, isLazy as z };
|
|
388
|
+
export type { InferRouterInitialContext as $, AnyShape as A, BuildContextWithAuth as B, Context as C, EnhanceRouterOptions as E, MiddlewareResult as H, InferProcedureClientInputs as I, MiddlewareNextFn as J, MiddlewareOutputFn as K, Lazyable as L, Meta as M, MiddlewareOptions as N, ProcedureHandlerOptions as Q, Route as R, Schemas as S, AnyContractDef as T, UnionToIntersection as U, ValidatedAuthContext as V, WrapShape as W, ProcedureDef as X, ContractRouter as Z, AnyRouter as _, InferSchemaOutput as a, InferRouterInitialContexts as a0, InferRouterCurrentContexts as a1, InferRouterInputs as a2, InferRouterOutputs as a3, AccessibleLazyRouter as a5, TraverseContractProceduresOptions as a8, TraverseContractProcedureCallbackOptions as a9, ContractProcedureCallbackOptions as aa, LazyTraverseContractProceduresOptions as ab, UnlaziedRouter as ae, TypeRest as ag, InitialSchemas as ai, MergedSchemas as c, AnySchema as d, Middleware as e, MergedCurrentContext as f, MergedInitialContext as g, AuthConfig as h, ProcedureHandler as i, InferHandlerInputs as j, InferSchemaInput as k, Router as l, EnhancedRouter as m, MapInputMiddleware as n, ContractDef as o, SchemaIssue as p, Schema as q, AnyMiddleware as r, Lazy as s, AnyProcedure as t, LazyMeta as w };
|
|
@@ -184,7 +184,6 @@ type MergedSchemas<T1 extends Schemas, T2 extends Partial<Schemas>> = {
|
|
|
184
184
|
outputSchema: T2['outputSchema'] extends AnySchema ? T2['outputSchema'] : T1['outputSchema'];
|
|
185
185
|
};
|
|
186
186
|
|
|
187
|
-
type DefaultProcedureHandlerOptions = ProcedureHandlerOptions<Context, Meta>;
|
|
188
187
|
interface ProcedureHandlerOptions<TCurrentContext extends Context, TMeta extends Meta> {
|
|
189
188
|
context: TCurrentContext;
|
|
190
189
|
path: readonly string[];
|
|
@@ -205,7 +204,7 @@ interface ContractDef<TSchemas extends Schemas, TMeta extends Meta> {
|
|
|
205
204
|
route: Route;
|
|
206
205
|
schemas: TSchemas;
|
|
207
206
|
middlewares: readonly AnyMiddleware[];
|
|
208
|
-
authConfigs:
|
|
207
|
+
authConfigs: AnyAuthConfig[];
|
|
209
208
|
inputValidationIndex: number;
|
|
210
209
|
outputValidationIndex: number;
|
|
211
210
|
}
|
|
@@ -232,22 +231,38 @@ type AnyProcedure = Procedure<any, any, Schemas, any>;
|
|
|
232
231
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
233
232
|
|
|
234
233
|
type ValidatedAuthContext = {};
|
|
235
|
-
interface
|
|
234
|
+
interface BaseAuthConfig {
|
|
235
|
+
oasDescription?: string;
|
|
236
|
+
oasName?: string;
|
|
237
|
+
}
|
|
238
|
+
interface BasicAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends BaseAuthConfig {
|
|
236
239
|
tokenPrefix?: string;
|
|
237
240
|
validate: (username: string, password: string, options: ProcedureHandlerOptions<TCurrentContext, TMeta>) => Promisable<TAuthContext>;
|
|
238
241
|
}
|
|
239
|
-
interface
|
|
242
|
+
interface BearerAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends TokenAuthConfig<TAuthContext, TCurrentContext, TMeta> {
|
|
243
|
+
oasBearerFormat?: string;
|
|
244
|
+
}
|
|
245
|
+
interface TokenAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends BaseAuthConfig {
|
|
240
246
|
tokenPrefix?: string;
|
|
241
247
|
validate: (token: string, options: ProcedureHandlerOptions<TCurrentContext, TMeta>) => Promisable<TAuthContext>;
|
|
242
248
|
}
|
|
243
249
|
interface NamedTokenAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends TokenAuthConfig<TAuthContext, TCurrentContext, TMeta> {
|
|
244
250
|
name: string;
|
|
245
251
|
}
|
|
246
|
-
type
|
|
247
|
-
type AuthConfig<
|
|
248
|
-
type
|
|
249
|
-
|
|
250
|
-
|
|
252
|
+
type AnyAuthConfig = AuthConfig<any, any, any>;
|
|
253
|
+
type AuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> = ({
|
|
254
|
+
type: 'basic';
|
|
255
|
+
} & BasicAuthConfig<TAuthContext, TCurrentContext, TMeta>) | ({
|
|
256
|
+
type: 'bearer';
|
|
257
|
+
} & BearerAuthConfig<TAuthContext, TCurrentContext, TMeta>) | ({
|
|
258
|
+
type: 'header';
|
|
259
|
+
} & NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta>) | ({
|
|
260
|
+
type: 'query';
|
|
261
|
+
} & NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta>) | ({
|
|
262
|
+
type: 'cookie';
|
|
263
|
+
} & NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta>) | {
|
|
264
|
+
type: 'none';
|
|
265
|
+
};
|
|
251
266
|
|
|
252
267
|
type ContractRouter = Contract | {
|
|
253
268
|
[k: string]: ContractRouter;
|
|
@@ -369,5 +384,5 @@ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
|
369
384
|
default: T extends Lazy<infer U> ? U : T;
|
|
370
385
|
}>;
|
|
371
386
|
|
|
372
|
-
export {
|
|
373
|
-
export type {
|
|
387
|
+
export { getLazyMeta as D, unlazy as F, mergeMeta as G, middlewareOutputFn as O, Procedure as P, isProcedure as Y, getRouter as a4, createAccessibleLazyRouter as a6, enhanceRouter as a7, traverseContractProcedures as ac, resolveContractProcedures as ad, unlazyRouter as af, initialSchemas as ah, Contract as b, mergeCurrentContext as u, LAZY_SYMBOL as v, lazyInternal as x, lazy as y, isLazy as z };
|
|
388
|
+
export type { InferRouterInitialContext as $, AnyShape as A, BuildContextWithAuth as B, Context as C, EnhanceRouterOptions as E, MiddlewareResult as H, InferProcedureClientInputs as I, MiddlewareNextFn as J, MiddlewareOutputFn as K, Lazyable as L, Meta as M, MiddlewareOptions as N, ProcedureHandlerOptions as Q, Route as R, Schemas as S, AnyContractDef as T, UnionToIntersection as U, ValidatedAuthContext as V, WrapShape as W, ProcedureDef as X, ContractRouter as Z, AnyRouter as _, InferSchemaOutput as a, InferRouterInitialContexts as a0, InferRouterCurrentContexts as a1, InferRouterInputs as a2, InferRouterOutputs as a3, AccessibleLazyRouter as a5, TraverseContractProceduresOptions as a8, TraverseContractProcedureCallbackOptions as a9, ContractProcedureCallbackOptions as aa, LazyTraverseContractProceduresOptions as ab, UnlaziedRouter as ae, TypeRest as ag, InitialSchemas as ai, MergedSchemas as c, AnySchema as d, Middleware as e, MergedCurrentContext as f, MergedInitialContext as g, AuthConfig as h, ProcedureHandler as i, InferHandlerInputs as j, InferSchemaInput as k, Router as l, EnhancedRouter as m, MapInputMiddleware as n, ContractDef as o, SchemaIssue as p, Schema as q, AnyMiddleware as r, Lazy as s, AnyProcedure as t, LazyMeta as w };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.cd9bac3545348e08cfaddb66f59c70d314145115",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"default": "./dist/helpers/index.mjs"
|
|
25
25
|
},
|
|
26
26
|
"./standard": {
|
|
27
|
-
"types": "./dist/
|
|
28
|
-
"import": "./dist/
|
|
29
|
-
"default": "./dist/
|
|
27
|
+
"types": "./dist/handler/index.d.mts",
|
|
28
|
+
"import": "./dist/handler/index.mjs",
|
|
29
|
+
"default": "./dist/handler/index.mjs"
|
|
30
30
|
},
|
|
31
31
|
"./fetch": {
|
|
32
32
|
"types": "./dist/adapters/fetch/index.d.mts",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"cookie": "^1.0.2",
|
|
57
57
|
"rou3": "^0.7.7",
|
|
58
58
|
"zod": "^4.1.12",
|
|
59
|
-
"@temporary-name/
|
|
60
|
-
"@temporary-name/
|
|
61
|
-
"@temporary-name/standard-server
|
|
62
|
-
"@temporary-name/standard-server-
|
|
63
|
-
"@temporary-name/standard-server-node": "1.9.3-alpha.
|
|
64
|
-
"@temporary-name/standard-server": "1.9.3-alpha.
|
|
65
|
-
"@temporary-name/zod": "1.9.3-alpha.
|
|
59
|
+
"@temporary-name/interop": "1.9.3-alpha.cd9bac3545348e08cfaddb66f59c70d314145115",
|
|
60
|
+
"@temporary-name/shared": "1.9.3-alpha.cd9bac3545348e08cfaddb66f59c70d314145115",
|
|
61
|
+
"@temporary-name/standard-server": "1.9.3-alpha.cd9bac3545348e08cfaddb66f59c70d314145115",
|
|
62
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.cd9bac3545348e08cfaddb66f59c70d314145115",
|
|
63
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.cd9bac3545348e08cfaddb66f59c70d314145115",
|
|
64
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.cd9bac3545348e08cfaddb66f59c70d314145115",
|
|
65
|
+
"@temporary-name/zod": "1.9.3-alpha.cd9bac3545348e08cfaddb66f59c70d314145115"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/supertest": "^6.0.3",
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { isObject } from '@temporary-name/shared';
|
|
2
|
-
|
|
3
|
-
function jsonSerialize(data, hasBlobRef = { value: false }) {
|
|
4
|
-
if (data instanceof Blob) {
|
|
5
|
-
hasBlobRef.value = true;
|
|
6
|
-
return [data, hasBlobRef.value];
|
|
7
|
-
}
|
|
8
|
-
if (data instanceof Set) {
|
|
9
|
-
return jsonSerialize(Array.from(data), hasBlobRef);
|
|
10
|
-
}
|
|
11
|
-
if (data instanceof Map) {
|
|
12
|
-
return jsonSerialize(Array.from(data.entries()), hasBlobRef);
|
|
13
|
-
}
|
|
14
|
-
if (Array.isArray(data)) {
|
|
15
|
-
const json = data.map((v) => v === void 0 ? null : jsonSerialize(v, hasBlobRef)[0]);
|
|
16
|
-
return [json, hasBlobRef.value];
|
|
17
|
-
}
|
|
18
|
-
if (isObject(data)) {
|
|
19
|
-
const json = {};
|
|
20
|
-
for (const k in data) {
|
|
21
|
-
if (k === "toJSON" && typeof data[k] === "function") {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
json[k] = jsonSerialize(data[k], hasBlobRef)[0];
|
|
25
|
-
}
|
|
26
|
-
return [json, hasBlobRef.value];
|
|
27
|
-
}
|
|
28
|
-
if (typeof data === "bigint" || data instanceof RegExp || data instanceof URL) {
|
|
29
|
-
return [data.toString(), hasBlobRef.value];
|
|
30
|
-
}
|
|
31
|
-
if (data instanceof Date) {
|
|
32
|
-
return [Number.isNaN(data.getTime()) ? null : data.toISOString(), hasBlobRef.value];
|
|
33
|
-
}
|
|
34
|
-
if (Number.isNaN(data)) {
|
|
35
|
-
return [null, hasBlobRef.value];
|
|
36
|
-
}
|
|
37
|
-
return [data, hasBlobRef.value];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export { jsonSerialize as j };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { isAsyncIteratorObject, ORPCError } from '@temporary-name/shared';
|
|
2
|
-
import { mapEventIterator } from '@temporary-name/standard-server';
|
|
3
|
-
import { custom, safeParseAsync } from '@temporary-name/zod';
|
|
4
|
-
import { V as ValidationError } from './server.ChOv1yG3.mjs';
|
|
5
|
-
|
|
6
|
-
const EVENT_ITERATOR_DETAILS_SYMBOL = Symbol("ORPC_EVENT_ITERATOR_DETAILS");
|
|
7
|
-
function eventIterator(yields, returns) {
|
|
8
|
-
const schema = custom(
|
|
9
|
-
(iterator) => isAsyncIteratorObject(iterator)
|
|
10
|
-
).transform((iterator) => {
|
|
11
|
-
const mapped = mapEventIterator(iterator, {
|
|
12
|
-
async value(value, done) {
|
|
13
|
-
const schema2 = done ? returns : yields;
|
|
14
|
-
if (!schema2) {
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
const result = await safeParseAsync(schema2, value);
|
|
18
|
-
if (result.success) {
|
|
19
|
-
return result.data;
|
|
20
|
-
} else {
|
|
21
|
-
throw new ORPCError("EVENT_ITERATOR_VALIDATION_FAILED", {
|
|
22
|
-
message: "Event iterator validation failed",
|
|
23
|
-
cause: new ValidationError({
|
|
24
|
-
issues: result.error.issues,
|
|
25
|
-
message: "Event iterator validation failed",
|
|
26
|
-
data: value
|
|
27
|
-
})
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
error: async (error) => error
|
|
32
|
-
});
|
|
33
|
-
return mapped;
|
|
34
|
-
});
|
|
35
|
-
schema[EVENT_ITERATOR_DETAILS_SYMBOL] = {
|
|
36
|
-
yields,
|
|
37
|
-
returns
|
|
38
|
-
};
|
|
39
|
-
return schema;
|
|
40
|
-
}
|
|
41
|
-
function getEventIteratorSchemaDetails(schema) {
|
|
42
|
-
if (schema === void 0) {
|
|
43
|
-
return void 0;
|
|
44
|
-
}
|
|
45
|
-
return schema[EVENT_ITERATOR_DETAILS_SYMBOL];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export { eventIterator as e, getEventIteratorSchemaDetails as g };
|