@temporary-name/server 1.9.3-alpha.ec3bfb9dce56198911349c322c970208b21b50db → 1.9.3-alpha.edd373b82156a10608d43b19a44b75ae72e72de7
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 +2 -2
- package/dist/adapters/aws-lambda/index.d.ts +2 -2
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/fetch/index.d.mts +2 -2
- package/dist/adapters/fetch/index.d.ts +2 -2
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +2 -2
- package/dist/adapters/node/index.d.ts +2 -2
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +2 -2
- package/dist/adapters/standard/index.d.ts +2 -2
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/index.d.mts +268 -16
- package/dist/index.d.ts +268 -16
- package/dist/index.mjs +379 -71
- package/dist/openapi/index.d.mts +11 -30
- package/dist/openapi/index.d.ts +11 -30
- package/dist/openapi/index.mjs +338 -295
- 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.CYa9puL2.mjs → server.Cq7SBLD5.mjs} +2 -2
- package/dist/shared/{server.CVhIyQ4x.d.mts → server.DGH2Bq4t.d.mts} +1 -1
- package/dist/shared/{server.D8RAzJ_p.d.ts → server.nQoUObAJ.d.ts} +1 -1
- package/dist/shared/{server.Cj3_Lp61.d.ts → server.zsKBRxsz.d.mts} +26 -11
- package/dist/shared/{server.Cj3_Lp61.d.mts → server.zsKBRxsz.d.ts} +26 -11
- package/package.json +8 -8
- package/dist/shared/server.YUvuxHty.mjs +0 -48
|
@@ -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.edd373b82156a10608d43b19a44b75ae72e72de7",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -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/interop": "1.9.3-alpha.
|
|
60
|
-
"@temporary-name/shared": "1.9.3-alpha.
|
|
61
|
-
"@temporary-name/standard-server": "1.9.3-alpha.
|
|
62
|
-
"@temporary-name/
|
|
63
|
-
"@temporary-name/standard-server-
|
|
64
|
-
"@temporary-name/standard-server
|
|
65
|
-
"@temporary-name/
|
|
59
|
+
"@temporary-name/interop": "1.9.3-alpha.edd373b82156a10608d43b19a44b75ae72e72de7",
|
|
60
|
+
"@temporary-name/shared": "1.9.3-alpha.edd373b82156a10608d43b19a44b75ae72e72de7",
|
|
61
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.edd373b82156a10608d43b19a44b75ae72e72de7",
|
|
62
|
+
"@temporary-name/zod": "1.9.3-alpha.edd373b82156a10608d43b19a44b75ae72e72de7",
|
|
63
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.edd373b82156a10608d43b19a44b75ae72e72de7",
|
|
64
|
+
"@temporary-name/standard-server": "1.9.3-alpha.edd373b82156a10608d43b19a44b75ae72e72de7",
|
|
65
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.edd373b82156a10608d43b19a44b75ae72e72de7"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/supertest": "^6.0.3",
|
|
@@ -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 };
|