@temporary-name/server 1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e → 1.9.3-alpha.52ad782be6ff2aac22845e524cd6454f857fb89b
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 +3 -3
- package/dist/adapters/aws-lambda/index.d.ts +3 -3
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +4 -4
- package/dist/adapters/standard/index.d.ts +4 -4
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/index.d.mts +46 -96
- package/dist/index.d.ts +46 -96
- package/dist/index.mjs +15 -215
- package/dist/openapi/index.mjs +30 -64
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.Bs6ka_UE.d.mts → server.B-pKBQ0r.d.mts} +2 -2
- package/dist/shared/{server.D2UFMrxf.d.ts → server.BQV-lt_s.d.ts} +2 -2
- package/dist/shared/{server.DcfsPloY.mjs → server.BdGbIyq8.mjs} +211 -17
- package/dist/shared/{server.Bk5r0-2R.d.ts → server.DAzElr6Q.d.ts} +1 -1
- package/dist/shared/{server.CZNLCQBm.d.mts → server.Do2Whl-h.d.mts} +114 -71
- package/dist/shared/{server.CZNLCQBm.d.ts → server.Do2Whl-h.d.ts} +114 -71
- package/dist/shared/{server.CbLTWfgn.d.mts → server.KIlJQ8K_.d.mts} +1 -1
- package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
- package/dist/shared/{server.BVxcyR6X.mjs → server.SmOM3Fae.mjs} +17 -42
- package/package.json +10 -10
package/dist/openapi/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isProcedure, resolveContractProcedures, ORPCError, createRouterClient } from '@temporary-name/server';
|
|
2
2
|
import { fallbackContractConfig, getEventIteratorSchemaDetails } from '@temporary-name/contract';
|
|
3
3
|
import { isObject, stringifyJSON, findDeepMatches, toArray, clone, value, toHttpPath, isORPCErrorStatus, fallbackORPCErrorStatus, fallbackORPCErrorMessage, resolveMaybeOptionalOptions, createORPCErrorFromJson } from '@temporary-name/shared';
|
|
4
|
-
import { a as standardizeHTTPPath, j as jsonSerialize, g as getDynamicParams, d as deserialize, s as serialize } from '../shared/server.
|
|
4
|
+
import { a as standardizeHTTPPath, j as jsonSerialize, g as getDynamicParams, d as deserialize, s as serialize } from '../shared/server.Kxw442A9.mjs';
|
|
5
5
|
import '@temporary-name/standard-server';
|
|
6
6
|
import { TypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
7
7
|
export { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
@@ -530,7 +530,7 @@ ${errors.join("\n\n")}`
|
|
|
530
530
|
}
|
|
531
531
|
async #request(doc, ref, def, baseSchemaConvertOptions) {
|
|
532
532
|
const method = fallbackContractConfig("defaultMethod", def.route.method);
|
|
533
|
-
const details = getEventIteratorSchemaDetails(def.inputSchema);
|
|
533
|
+
const details = getEventIteratorSchemaDetails(def.schemas.inputSchema);
|
|
534
534
|
if (details) {
|
|
535
535
|
ref.requestBody = {
|
|
536
536
|
required: true,
|
|
@@ -542,82 +542,48 @@ ${errors.join("\n\n")}`
|
|
|
542
542
|
return;
|
|
543
543
|
}
|
|
544
544
|
const dynamicParams = getDynamicParams(def.route.path)?.map((v) => v.name);
|
|
545
|
-
|
|
546
|
-
let [required, schema] = await this.converter.convert(def.inputSchema, {
|
|
545
|
+
let [required, schema] = await this.converter.convert(def.schemas.inputSchema, {
|
|
547
546
|
...baseSchemaConvertOptions,
|
|
548
547
|
strategy: "input",
|
|
549
|
-
minStructureDepthForRef: dynamicParams?.length
|
|
548
|
+
minStructureDepthForRef: dynamicParams?.length ? 1 : 0
|
|
550
549
|
});
|
|
551
550
|
if (isAnySchema(schema) && !dynamicParams?.length) {
|
|
552
551
|
return;
|
|
553
552
|
}
|
|
554
|
-
if (
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
throw error2;
|
|
561
|
-
}
|
|
562
|
-
const [paramsSchema, rest] = separateObjectSchema(schema, dynamicParams);
|
|
563
|
-
schema = rest;
|
|
564
|
-
required = rest.required ? rest.required.length !== 0 : false;
|
|
565
|
-
if (!checkParamsSchema(paramsSchema, dynamicParams)) {
|
|
566
|
-
throw error2;
|
|
567
|
-
}
|
|
568
|
-
ref.parameters ??= [];
|
|
569
|
-
ref.parameters.push(...toOpenAPIParameters(paramsSchema, "path"));
|
|
553
|
+
if (dynamicParams?.length) {
|
|
554
|
+
const error = new OpenAPIGeneratorError(
|
|
555
|
+
'When input structure is "compact", and path has dynamic params, input schema must be an object with all dynamic params as required.'
|
|
556
|
+
);
|
|
557
|
+
if (!isObjectSchema(schema)) {
|
|
558
|
+
throw error;
|
|
570
559
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
);
|
|
577
|
-
}
|
|
578
|
-
ref.parameters ??= [];
|
|
579
|
-
ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
|
|
580
|
-
} else {
|
|
581
|
-
ref.requestBody = {
|
|
582
|
-
required,
|
|
583
|
-
content: toOpenAPIContent(schema)
|
|
584
|
-
};
|
|
560
|
+
const [paramsSchema, rest] = separateObjectSchema(schema, dynamicParams);
|
|
561
|
+
schema = rest;
|
|
562
|
+
required = rest.required ? rest.required.length !== 0 : false;
|
|
563
|
+
if (!checkParamsSchema(paramsSchema, dynamicParams)) {
|
|
564
|
+
throw error;
|
|
585
565
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
if (dynamicParams?.length && (resolvedParamSchema === void 0 || !isObjectSchema(resolvedParamSchema) || !checkParamsSchema(resolvedParamSchema, dynamicParams))) {
|
|
596
|
-
throw new OpenAPIGeneratorError(
|
|
597
|
-
'When input structure is "detailed" and path has dynamic params, the "params" schema must be an object with all dynamic params as required.'
|
|
598
|
-
);
|
|
599
|
-
}
|
|
600
|
-
for (const from of ["params", "query", "headers"]) {
|
|
601
|
-
const fromSchema = schema.properties?.[from];
|
|
602
|
-
if (fromSchema !== void 0) {
|
|
603
|
-
const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, fromSchema);
|
|
604
|
-
if (!isObjectSchema(resolvedSchema)) {
|
|
605
|
-
throw error;
|
|
606
|
-
}
|
|
607
|
-
const parameterIn = from === "params" ? "path" : from === "headers" ? "header" : "query";
|
|
608
|
-
ref.parameters ??= [];
|
|
609
|
-
ref.parameters.push(...toOpenAPIParameters(resolvedSchema, parameterIn));
|
|
566
|
+
ref.parameters ??= [];
|
|
567
|
+
ref.parameters.push(...toOpenAPIParameters(paramsSchema, "path"));
|
|
568
|
+
}
|
|
569
|
+
if (method === "GET") {
|
|
570
|
+
const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, schema);
|
|
571
|
+
if (!isObjectSchema(resolvedSchema)) {
|
|
572
|
+
throw new OpenAPIGeneratorError(
|
|
573
|
+
'When method is "GET", input schema must satisfy: object | any | unknown'
|
|
574
|
+
);
|
|
610
575
|
}
|
|
611
|
-
|
|
612
|
-
|
|
576
|
+
ref.parameters ??= [];
|
|
577
|
+
ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
|
|
578
|
+
} else {
|
|
613
579
|
ref.requestBody = {
|
|
614
|
-
required
|
|
615
|
-
content: toOpenAPIContent(schema
|
|
580
|
+
required,
|
|
581
|
+
content: toOpenAPIContent(schema)
|
|
616
582
|
};
|
|
617
583
|
}
|
|
618
584
|
}
|
|
619
585
|
async #successResponse(doc, ref, def, baseSchemaConvertOptions) {
|
|
620
|
-
const outputSchema = def.outputSchema;
|
|
586
|
+
const outputSchema = def.schemas.outputSchema;
|
|
621
587
|
const status = fallbackContractConfig("defaultSuccessStatus", def.route.successStatus);
|
|
622
588
|
const description = fallbackContractConfig("defaultSuccessDescription", def.route?.successDescription);
|
|
623
589
|
const eventIteratorSchemaDetails = getEventIteratorSchemaDetails(outputSchema);
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Value, Promisable, ORPCError } from '@temporary-name/shared';
|
|
2
2
|
import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
|
|
3
3
|
import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
|
|
4
|
-
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.
|
|
5
|
-
import { C as Context,
|
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.KIlJQ8K_.mjs';
|
|
5
|
+
import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.Do2Whl-h.mjs';
|
|
6
6
|
import { Meta } from '@temporary-name/contract';
|
|
7
7
|
|
|
8
8
|
interface BatchHandlerOptions<T extends Context> {
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Value, Promisable, ORPCError } from '@temporary-name/shared';
|
|
2
2
|
import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
|
|
3
3
|
import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
|
|
4
|
-
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.
|
|
5
|
-
import { C as Context,
|
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.DAzElr6Q.js';
|
|
5
|
+
import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.Do2Whl-h.js';
|
|
6
6
|
import { Meta } from '@temporary-name/contract';
|
|
7
7
|
|
|
8
8
|
interface BatchHandlerOptions<T extends Context> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTTPPath } from '@temporary-name/shared';
|
|
2
|
-
import { C as Context } from './server.
|
|
3
|
-
import { c as StandardHandleOptions } from './server.
|
|
2
|
+
import { C as Context } from './server.Do2Whl-h.mjs';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.KIlJQ8K_.mjs';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTTPPath } from '@temporary-name/shared';
|
|
2
|
-
import { C as Context } from './server.
|
|
3
|
-
import { c as StandardHandleOptions } from './server.
|
|
2
|
+
import { C as Context } from './server.Do2Whl-h.js';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.DAzElr6Q.js';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|
|
@@ -1,25 +1,46 @@
|
|
|
1
|
-
import { validateORPCError, ValidationError } from '@temporary-name/contract';
|
|
1
|
+
import { isContractProcedure, mergePrefix, mergeErrorMap, enhanceRoute, validateORPCError, ValidationError } from '@temporary-name/contract';
|
|
2
2
|
import { resolveMaybeOptionalOptions, ORPCError, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@temporary-name/shared';
|
|
3
3
|
import { HibernationEventIterator, mapEventIterator } from '@temporary-name/standard-server';
|
|
4
4
|
import { safeParseAsync } from '@temporary-name/zod';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
function isStartWithMiddlewares(middlewares, compare) {
|
|
7
|
+
if (compare.length > middlewares.length) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
for (let i = 0; i < middlewares.length; i++) {
|
|
11
|
+
if (compare[i] === void 0) {
|
|
12
|
+
return true;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
if (middlewares[i] !== compare[i]) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
14
19
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
20
|
+
function mergeMiddlewares(first, second, options) {
|
|
21
|
+
if (options.dedupeLeading && isStartWithMiddlewares(second, first)) {
|
|
22
|
+
return second;
|
|
23
|
+
}
|
|
24
|
+
return [...first, ...second];
|
|
17
25
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
26
|
+
function addMiddleware(middlewares, addition) {
|
|
27
|
+
return [...middlewares, addition];
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
|
|
30
|
+
class Procedure {
|
|
31
|
+
/**
|
|
32
|
+
* This property holds the defined options.
|
|
33
|
+
*/
|
|
34
|
+
"~orpc";
|
|
35
|
+
constructor(def) {
|
|
36
|
+
this["~orpc"] = def;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isProcedure(item) {
|
|
40
|
+
if (item instanceof Procedure) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return isContractProcedure(item) && "middlewares" in item["~orpc"] && "handler" in item["~orpc"];
|
|
23
44
|
}
|
|
24
45
|
|
|
25
46
|
function mergeCurrentContext(context, other) {
|
|
@@ -49,6 +70,179 @@ function createORPCErrorConstructorMap(errors) {
|
|
|
49
70
|
return proxy;
|
|
50
71
|
}
|
|
51
72
|
|
|
73
|
+
const HIDDEN_ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_HIDDEN_ROUTER_CONTRACT");
|
|
74
|
+
function setHiddenRouterContract(router, contract) {
|
|
75
|
+
return new Proxy(router, {
|
|
76
|
+
get(target, key) {
|
|
77
|
+
if (key === HIDDEN_ROUTER_CONTRACT_SYMBOL) {
|
|
78
|
+
return contract;
|
|
79
|
+
}
|
|
80
|
+
return Reflect.get(target, key);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function getHiddenRouterContract(router) {
|
|
85
|
+
return router[HIDDEN_ROUTER_CONTRACT_SYMBOL];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function getRouter(router, path) {
|
|
89
|
+
let current = router;
|
|
90
|
+
for (let i = 0; i < path.length; i++) {
|
|
91
|
+
const segment = path[i];
|
|
92
|
+
if (!current) {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
if (isProcedure(current)) {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
if (!isLazy(current)) {
|
|
99
|
+
current = current[segment];
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const lazied = current;
|
|
103
|
+
const rest = path.slice(i);
|
|
104
|
+
return lazyInternal(async () => {
|
|
105
|
+
const unwrapped = await unlazy(lazied);
|
|
106
|
+
const next = getRouter(unwrapped.default, rest);
|
|
107
|
+
return unlazy(next);
|
|
108
|
+
}, getLazyMeta(lazied));
|
|
109
|
+
}
|
|
110
|
+
return current;
|
|
111
|
+
}
|
|
112
|
+
function createAccessibleLazyRouter(lazied) {
|
|
113
|
+
const recursive = new Proxy(lazied, {
|
|
114
|
+
get(target, key) {
|
|
115
|
+
if (typeof key !== "string") {
|
|
116
|
+
return Reflect.get(target, key);
|
|
117
|
+
}
|
|
118
|
+
const next = getRouter(lazied, [key]);
|
|
119
|
+
return createAccessibleLazyRouter(next);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return recursive;
|
|
123
|
+
}
|
|
124
|
+
function enhanceRouter(router, options) {
|
|
125
|
+
if (isLazy(router)) {
|
|
126
|
+
const laziedMeta = getLazyMeta(router);
|
|
127
|
+
const enhancedPrefix = laziedMeta?.prefix ? mergePrefix(options.prefix, laziedMeta?.prefix) : options.prefix;
|
|
128
|
+
const enhanced2 = lazyInternal(
|
|
129
|
+
async () => {
|
|
130
|
+
const { default: unlaziedRouter } = await unlazy(router);
|
|
131
|
+
const enhanced3 = enhanceRouter(unlaziedRouter, options);
|
|
132
|
+
return unlazy(enhanced3);
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
...laziedMeta,
|
|
136
|
+
prefix: enhancedPrefix
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
const accessible = createAccessibleLazyRouter(enhanced2);
|
|
140
|
+
return accessible;
|
|
141
|
+
}
|
|
142
|
+
if (isProcedure(router)) {
|
|
143
|
+
const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares, {
|
|
144
|
+
dedupeLeading: options.dedupeLeadingMiddlewares
|
|
145
|
+
});
|
|
146
|
+
const newMiddlewareAdded = newMiddlewares.length - router["~orpc"].middlewares.length;
|
|
147
|
+
const enhanced2 = new Procedure({
|
|
148
|
+
...router["~orpc"],
|
|
149
|
+
route: enhanceRoute(router["~orpc"].route, options),
|
|
150
|
+
errorMap: mergeErrorMap(options.errorMap, router["~orpc"].errorMap),
|
|
151
|
+
middlewares: newMiddlewares,
|
|
152
|
+
inputValidationIndex: router["~orpc"].inputValidationIndex + newMiddlewareAdded,
|
|
153
|
+
outputValidationIndex: router["~orpc"].outputValidationIndex + newMiddlewareAdded
|
|
154
|
+
});
|
|
155
|
+
return enhanced2;
|
|
156
|
+
}
|
|
157
|
+
const enhanced = {};
|
|
158
|
+
for (const key in router) {
|
|
159
|
+
enhanced[key] = enhanceRouter(router[key], options);
|
|
160
|
+
}
|
|
161
|
+
return enhanced;
|
|
162
|
+
}
|
|
163
|
+
function traverseContractProcedures(options, callback, lazyOptions = []) {
|
|
164
|
+
let currentRouter = options.router;
|
|
165
|
+
const hiddenContract = getHiddenRouterContract(options.router);
|
|
166
|
+
if (hiddenContract !== void 0) {
|
|
167
|
+
currentRouter = hiddenContract;
|
|
168
|
+
}
|
|
169
|
+
if (isLazy(currentRouter)) {
|
|
170
|
+
lazyOptions.push({
|
|
171
|
+
router: currentRouter,
|
|
172
|
+
path: options.path
|
|
173
|
+
});
|
|
174
|
+
} else if (isContractProcedure(currentRouter)) {
|
|
175
|
+
callback({
|
|
176
|
+
contract: currentRouter,
|
|
177
|
+
path: options.path
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
for (const key in currentRouter) {
|
|
181
|
+
traverseContractProcedures(
|
|
182
|
+
{
|
|
183
|
+
router: currentRouter[key],
|
|
184
|
+
path: [...options.path, key]
|
|
185
|
+
},
|
|
186
|
+
callback,
|
|
187
|
+
lazyOptions
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return lazyOptions;
|
|
192
|
+
}
|
|
193
|
+
async function resolveContractProcedures(options, callback) {
|
|
194
|
+
const pending = [options];
|
|
195
|
+
for (const options2 of pending) {
|
|
196
|
+
const lazyOptions = traverseContractProcedures(options2, callback);
|
|
197
|
+
for (const options3 of lazyOptions) {
|
|
198
|
+
const { default: router } = await unlazy(options3.router);
|
|
199
|
+
pending.push({
|
|
200
|
+
router,
|
|
201
|
+
path: options3.path
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function unlazyRouter(router) {
|
|
207
|
+
if (isProcedure(router)) {
|
|
208
|
+
return router;
|
|
209
|
+
}
|
|
210
|
+
const unlazied = {};
|
|
211
|
+
for (const key in router) {
|
|
212
|
+
const item = router[key];
|
|
213
|
+
const { default: unlaziedRouter } = await unlazy(item);
|
|
214
|
+
unlazied[key] = await unlazyRouter(unlaziedRouter);
|
|
215
|
+
}
|
|
216
|
+
return unlazied;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
|
220
|
+
function lazyInternal(loader, meta = {}) {
|
|
221
|
+
return {
|
|
222
|
+
[LAZY_SYMBOL]: {
|
|
223
|
+
loader,
|
|
224
|
+
meta
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function lazy(prefix, loader) {
|
|
229
|
+
return enhanceRouter(lazyInternal(loader), {
|
|
230
|
+
middlewares: [],
|
|
231
|
+
errorMap: {},
|
|
232
|
+
dedupeLeadingMiddlewares: true,
|
|
233
|
+
prefix
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function isLazy(item) {
|
|
237
|
+
return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_SYMBOL in item;
|
|
238
|
+
}
|
|
239
|
+
function getLazyMeta(lazied) {
|
|
240
|
+
return lazied[LAZY_SYMBOL].meta;
|
|
241
|
+
}
|
|
242
|
+
function unlazy(lazied) {
|
|
243
|
+
return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
|
|
244
|
+
}
|
|
245
|
+
|
|
52
246
|
function middlewareOutputFn(output) {
|
|
53
247
|
return { output, context: {} };
|
|
54
248
|
}
|
|
@@ -110,7 +304,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
110
304
|
};
|
|
111
305
|
}
|
|
112
306
|
async function validateInput(procedure, input) {
|
|
113
|
-
const schema = procedure["~orpc"].inputSchema;
|
|
307
|
+
const schema = procedure["~orpc"].schemas.inputSchema;
|
|
114
308
|
if (!schema) {
|
|
115
309
|
return input;
|
|
116
310
|
}
|
|
@@ -133,7 +327,7 @@ async function validateInput(procedure, input) {
|
|
|
133
327
|
});
|
|
134
328
|
}
|
|
135
329
|
async function validateOutput(procedure, output) {
|
|
136
|
-
const schema = procedure["~orpc"].outputSchema;
|
|
330
|
+
const schema = procedure["~orpc"].schemas.outputSchema;
|
|
137
331
|
if (!schema) {
|
|
138
332
|
return output;
|
|
139
333
|
}
|
|
@@ -199,4 +393,4 @@ async function executeProcedureInternal(procedure, options) {
|
|
|
199
393
|
return next(0, options.context, options.input);
|
|
200
394
|
}
|
|
201
395
|
|
|
202
|
-
export { LAZY_SYMBOL as L,
|
|
396
|
+
export { LAZY_SYMBOL as L, Procedure as P, addMiddleware as a, isLazy as b, createProcedureClient as c, getRouter as d, enhanceRouter as e, createORPCErrorConstructorMap as f, getLazyMeta as g, lazy as h, isProcedure as i, middlewareOutputFn as j, isStartWithMiddlewares as k, lazyInternal as l, mergeCurrentContext as m, mergeMiddlewares as n, getHiddenRouterContract as o, createAccessibleLazyRouter as p, unlazyRouter as q, resolveContractProcedures as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta } from '@temporary-name/contract';
|
|
2
2
|
import { HTTPPath, Interceptor } from '@temporary-name/shared';
|
|
3
3
|
import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
|
|
4
|
-
import { C as Context, R as Router,
|
|
4
|
+
import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.Do2Whl-h.js';
|
|
5
5
|
|
|
6
6
|
interface StandardHandlerPlugin<T extends Context> {
|
|
7
7
|
order?: number;
|