@temporary-name/server 1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d → 1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e
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 +14 -30
- package/dist/adapters/standard/index.d.ts +14 -30
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/index.d.mts +46 -139
- package/dist/index.d.ts +46 -139
- package/dist/index.mjs +51 -295
- 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.Bzrdopnd.d.ts → server.B5czSQQh.d.mts} +114 -71
- package/dist/shared/{server.Bzrdopnd.d.mts → server.B5czSQQh.d.ts} +114 -71
- package/dist/shared/{server.DcfsPloY.mjs → server.BdGbIyq8.mjs} +211 -17
- package/dist/shared/{server.Cp__uvkw.d.mts → server.Bk8Hmx7Z.d.mts} +2 -2
- package/dist/shared/{server.B9i6p26R.d.ts → server.C4l2ZA3m.d.ts} +1 -2
- package/dist/shared/{server.CYRDznXq.d.ts → server.D7UjcuIv.d.ts} +2 -2
- package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
- package/dist/shared/{server.B9VxPdeK.mjs → server.SmOM3Fae.mjs} +58 -89
- package/dist/shared/{server.C-j2WKJz.d.mts → server.TgmlNh8r.d.mts} +1 -2
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -1,134 +1,13 @@
|
|
|
1
|
+
import { mergePrefix, mergeTags, ContractProcedure, mergeErrorMap, mergeMeta, mergeRoute, prefixRoute, initialSchemas, isContractProcedure, getContractRouter } from '@temporary-name/contract';
|
|
2
|
+
export { ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
|
|
1
3
|
import { onError, resolveMaybeOptionalOptions } from '@temporary-name/shared';
|
|
2
4
|
export { AsyncIteratorClass, EventPublisher, ORPCError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, safe, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
|
|
3
|
-
import { isContractProcedure, mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, enhanceRoute, mergeTags, ContractProcedure, prefixRoute, getContractRouter } from '@temporary-name/contract';
|
|
4
|
-
export { ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
|
|
5
5
|
import { SchemaClass, gatingContext } from '@temporary-name/zod';
|
|
6
|
-
import { c as createProcedureClient,
|
|
7
|
-
export { L as LAZY_SYMBOL,
|
|
6
|
+
import { P as Procedure, c as createProcedureClient, e as enhanceRouter, a as addMiddleware, s as setHiddenRouterContract, l as lazyInternal, g as getLazyMeta, u as unlazy, i as isProcedure, b as isLazy, d as getRouter } from './shared/server.BdGbIyq8.mjs';
|
|
7
|
+
export { L as LAZY_SYMBOL, p as createAccessibleLazyRouter, f as createORPCErrorConstructorMap, o as getHiddenRouterContract, k as isStartWithMiddlewares, h as lazy, m as mergeCurrentContext, n as mergeMiddlewares, j as middlewareOutputFn, r as resolveContractProcedures, t as traverseContractProcedures, q as unlazyRouter } from './shared/server.BdGbIyq8.mjs';
|
|
8
8
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
9
9
|
|
|
10
|
-
function isStartWithMiddlewares(middlewares, compare) {
|
|
11
|
-
if (compare.length > middlewares.length) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
for (let i = 0; i < middlewares.length; i++) {
|
|
15
|
-
if (compare[i] === void 0) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
if (middlewares[i] !== compare[i]) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
function mergeMiddlewares(first, second, options) {
|
|
25
|
-
if (options.dedupeLeading && isStartWithMiddlewares(second, first)) {
|
|
26
|
-
return second;
|
|
27
|
-
}
|
|
28
|
-
return [...first, ...second];
|
|
29
|
-
}
|
|
30
|
-
function addMiddleware(middlewares, addition) {
|
|
31
|
-
return [...middlewares, addition];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function decorateMiddleware(middleware) {
|
|
35
|
-
const decorated = ((...args) => middleware(...args));
|
|
36
|
-
decorated.mapInput = (mapInput) => {
|
|
37
|
-
const mapped = decorateMiddleware(
|
|
38
|
-
(options, input, ...rest) => middleware(options, mapInput(input), ...rest)
|
|
39
|
-
);
|
|
40
|
-
return mapped;
|
|
41
|
-
};
|
|
42
|
-
decorated.concat = (concatMiddleware, mapInput) => {
|
|
43
|
-
const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;
|
|
44
|
-
const concatted = decorateMiddleware((options, input, output, ...rest) => {
|
|
45
|
-
const merged = middleware(
|
|
46
|
-
{
|
|
47
|
-
...options,
|
|
48
|
-
next: (...[nextOptions1]) => mapped(
|
|
49
|
-
{
|
|
50
|
-
...options,
|
|
51
|
-
context: { ...options.context, ...nextOptions1?.context },
|
|
52
|
-
next: (...[nextOptions2]) => options.next({ context: { ...nextOptions1?.context, ...nextOptions2?.context } })
|
|
53
|
-
},
|
|
54
|
-
input,
|
|
55
|
-
output,
|
|
56
|
-
...rest
|
|
57
|
-
)
|
|
58
|
-
},
|
|
59
|
-
input,
|
|
60
|
-
output,
|
|
61
|
-
...rest
|
|
62
|
-
);
|
|
63
|
-
return merged;
|
|
64
|
-
});
|
|
65
|
-
return concatted;
|
|
66
|
-
};
|
|
67
|
-
return decorated;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
class Procedure {
|
|
71
|
-
/**
|
|
72
|
-
* This property holds the defined options.
|
|
73
|
-
*/
|
|
74
|
-
"~orpc";
|
|
75
|
-
constructor(def) {
|
|
76
|
-
this["~orpc"] = def;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function isProcedure(item) {
|
|
80
|
-
if (item instanceof Procedure) {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
return isContractProcedure(item) && "middlewares" in item["~orpc"] && "inputValidationIndex" in item["~orpc"] && "outputValidationIndex" in item["~orpc"] && "handler" in item["~orpc"];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
10
|
class DecoratedProcedure extends Procedure {
|
|
87
|
-
/**
|
|
88
|
-
* Adds type-safe custom errors.
|
|
89
|
-
* The provided errors are spared-merged with any existing errors.
|
|
90
|
-
*
|
|
91
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
92
|
-
*/
|
|
93
|
-
errors(errors) {
|
|
94
|
-
return new DecoratedProcedure({
|
|
95
|
-
...this["~orpc"],
|
|
96
|
-
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Sets or updates the metadata.
|
|
101
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
102
|
-
*
|
|
103
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
104
|
-
*/
|
|
105
|
-
meta(meta) {
|
|
106
|
-
return new DecoratedProcedure({
|
|
107
|
-
...this["~orpc"],
|
|
108
|
-
meta: mergeMeta(this["~orpc"].meta, meta)
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Sets or updates the route definition.
|
|
113
|
-
* The provided route is spared-merged with any existing route.
|
|
114
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
115
|
-
*
|
|
116
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
117
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
118
|
-
*/
|
|
119
|
-
route(route) {
|
|
120
|
-
return new DecoratedProcedure({
|
|
121
|
-
...this["~orpc"],
|
|
122
|
-
route: mergeRoute(this["~orpc"].route, route)
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
use(middleware, mapInput) {
|
|
126
|
-
const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
|
127
|
-
return new DecoratedProcedure({
|
|
128
|
-
...this["~orpc"],
|
|
129
|
-
middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
11
|
/**
|
|
133
12
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
134
13
|
*
|
|
@@ -147,152 +26,6 @@ class DecoratedProcedure extends Procedure {
|
|
|
147
26
|
}
|
|
148
27
|
}
|
|
149
28
|
|
|
150
|
-
const HIDDEN_ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_HIDDEN_ROUTER_CONTRACT");
|
|
151
|
-
function setHiddenRouterContract(router, contract) {
|
|
152
|
-
return new Proxy(router, {
|
|
153
|
-
get(target, key) {
|
|
154
|
-
if (key === HIDDEN_ROUTER_CONTRACT_SYMBOL) {
|
|
155
|
-
return contract;
|
|
156
|
-
}
|
|
157
|
-
return Reflect.get(target, key);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
function getHiddenRouterContract(router) {
|
|
162
|
-
return router[HIDDEN_ROUTER_CONTRACT_SYMBOL];
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function getRouter(router, path) {
|
|
166
|
-
let current = router;
|
|
167
|
-
for (let i = 0; i < path.length; i++) {
|
|
168
|
-
const segment = path[i];
|
|
169
|
-
if (!current) {
|
|
170
|
-
return void 0;
|
|
171
|
-
}
|
|
172
|
-
if (isProcedure(current)) {
|
|
173
|
-
return void 0;
|
|
174
|
-
}
|
|
175
|
-
if (!isLazy(current)) {
|
|
176
|
-
current = current[segment];
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
const lazied = current;
|
|
180
|
-
const rest = path.slice(i);
|
|
181
|
-
return lazy(async () => {
|
|
182
|
-
const unwrapped = await unlazy(lazied);
|
|
183
|
-
const next = getRouter(unwrapped.default, rest);
|
|
184
|
-
return unlazy(next);
|
|
185
|
-
}, getLazyMeta(lazied));
|
|
186
|
-
}
|
|
187
|
-
return current;
|
|
188
|
-
}
|
|
189
|
-
function createAccessibleLazyRouter(lazied) {
|
|
190
|
-
const recursive = new Proxy(lazied, {
|
|
191
|
-
get(target, key) {
|
|
192
|
-
if (typeof key !== "string") {
|
|
193
|
-
return Reflect.get(target, key);
|
|
194
|
-
}
|
|
195
|
-
const next = getRouter(lazied, [key]);
|
|
196
|
-
return createAccessibleLazyRouter(next);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
return recursive;
|
|
200
|
-
}
|
|
201
|
-
function enhanceRouter(router, options) {
|
|
202
|
-
if (isLazy(router)) {
|
|
203
|
-
const laziedMeta = getLazyMeta(router);
|
|
204
|
-
const enhancedPrefix = laziedMeta?.prefix ? mergePrefix(options.prefix, laziedMeta?.prefix) : options.prefix;
|
|
205
|
-
const enhanced2 = lazy(
|
|
206
|
-
async () => {
|
|
207
|
-
const { default: unlaziedRouter } = await unlazy(router);
|
|
208
|
-
const enhanced3 = enhanceRouter(unlaziedRouter, options);
|
|
209
|
-
return unlazy(enhanced3);
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
...laziedMeta,
|
|
213
|
-
prefix: enhancedPrefix
|
|
214
|
-
}
|
|
215
|
-
);
|
|
216
|
-
const accessible = createAccessibleLazyRouter(enhanced2);
|
|
217
|
-
return accessible;
|
|
218
|
-
}
|
|
219
|
-
if (isProcedure(router)) {
|
|
220
|
-
const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares, {
|
|
221
|
-
dedupeLeading: options.dedupeLeadingMiddlewares
|
|
222
|
-
});
|
|
223
|
-
const newMiddlewareAdded = newMiddlewares.length - router["~orpc"].middlewares.length;
|
|
224
|
-
const enhanced2 = new Procedure({
|
|
225
|
-
...router["~orpc"],
|
|
226
|
-
route: enhanceRoute(router["~orpc"].route, options),
|
|
227
|
-
errorMap: mergeErrorMap(options.errorMap, router["~orpc"].errorMap),
|
|
228
|
-
middlewares: newMiddlewares,
|
|
229
|
-
inputValidationIndex: router["~orpc"].inputValidationIndex + newMiddlewareAdded,
|
|
230
|
-
outputValidationIndex: router["~orpc"].outputValidationIndex + newMiddlewareAdded
|
|
231
|
-
});
|
|
232
|
-
return enhanced2;
|
|
233
|
-
}
|
|
234
|
-
const enhanced = {};
|
|
235
|
-
for (const key in router) {
|
|
236
|
-
enhanced[key] = enhanceRouter(router[key], options);
|
|
237
|
-
}
|
|
238
|
-
return enhanced;
|
|
239
|
-
}
|
|
240
|
-
function traverseContractProcedures(options, callback, lazyOptions = []) {
|
|
241
|
-
let currentRouter = options.router;
|
|
242
|
-
const hiddenContract = getHiddenRouterContract(options.router);
|
|
243
|
-
if (hiddenContract !== void 0) {
|
|
244
|
-
currentRouter = hiddenContract;
|
|
245
|
-
}
|
|
246
|
-
if (isLazy(currentRouter)) {
|
|
247
|
-
lazyOptions.push({
|
|
248
|
-
router: currentRouter,
|
|
249
|
-
path: options.path
|
|
250
|
-
});
|
|
251
|
-
} else if (isContractProcedure(currentRouter)) {
|
|
252
|
-
callback({
|
|
253
|
-
contract: currentRouter,
|
|
254
|
-
path: options.path
|
|
255
|
-
});
|
|
256
|
-
} else {
|
|
257
|
-
for (const key in currentRouter) {
|
|
258
|
-
traverseContractProcedures(
|
|
259
|
-
{
|
|
260
|
-
router: currentRouter[key],
|
|
261
|
-
path: [...options.path, key]
|
|
262
|
-
},
|
|
263
|
-
callback,
|
|
264
|
-
lazyOptions
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return lazyOptions;
|
|
269
|
-
}
|
|
270
|
-
async function resolveContractProcedures(options, callback) {
|
|
271
|
-
const pending = [options];
|
|
272
|
-
for (const options2 of pending) {
|
|
273
|
-
const lazyOptions = traverseContractProcedures(options2, callback);
|
|
274
|
-
for (const options3 of lazyOptions) {
|
|
275
|
-
const { default: router } = await unlazy(options3.router);
|
|
276
|
-
pending.push({
|
|
277
|
-
router,
|
|
278
|
-
path: options3.path
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
async function unlazyRouter(router) {
|
|
284
|
-
if (isProcedure(router)) {
|
|
285
|
-
return router;
|
|
286
|
-
}
|
|
287
|
-
const unlazied = {};
|
|
288
|
-
for (const key in router) {
|
|
289
|
-
const item = router[key];
|
|
290
|
-
const { default: unlaziedRouter } = await unlazy(item);
|
|
291
|
-
unlazied[key] = await unlazyRouter(unlaziedRouter);
|
|
292
|
-
}
|
|
293
|
-
return unlazied;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
29
|
class ProcedureBuilder extends ContractProcedure {
|
|
297
30
|
z;
|
|
298
31
|
constructor(def) {
|
|
@@ -346,7 +79,10 @@ class ProcedureBuilder extends ContractProcedure {
|
|
|
346
79
|
input(schema) {
|
|
347
80
|
return new ProcedureBuilder({
|
|
348
81
|
...this["~orpc"],
|
|
349
|
-
|
|
82
|
+
schemas: {
|
|
83
|
+
...this["~orpc"].schemas,
|
|
84
|
+
inputSchema: schema
|
|
85
|
+
},
|
|
350
86
|
inputValidationIndex: this["~orpc"].middlewares.length
|
|
351
87
|
});
|
|
352
88
|
}
|
|
@@ -358,7 +94,10 @@ class ProcedureBuilder extends ContractProcedure {
|
|
|
358
94
|
output(schema) {
|
|
359
95
|
return new ProcedureBuilder({
|
|
360
96
|
...this["~orpc"],
|
|
361
|
-
|
|
97
|
+
schemas: {
|
|
98
|
+
...this["~orpc"].schemas,
|
|
99
|
+
outputSchema: schema
|
|
100
|
+
},
|
|
362
101
|
outputValidationIndex: this["~orpc"].middlewares.length
|
|
363
102
|
});
|
|
364
103
|
}
|
|
@@ -430,15 +169,42 @@ class BuilderWithMiddlewares extends ProcedureBuilder {
|
|
|
430
169
|
router(router) {
|
|
431
170
|
return enhanceRouter(router, this["~orpc"]);
|
|
432
171
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function decorateMiddleware(middleware) {
|
|
175
|
+
const decorated = ((...args) => middleware(...args));
|
|
176
|
+
decorated.mapInput = (mapInput) => {
|
|
177
|
+
const mapped = decorateMiddleware(
|
|
178
|
+
(options, input, ...rest) => middleware(options, mapInput(input), ...rest)
|
|
179
|
+
);
|
|
180
|
+
return mapped;
|
|
181
|
+
};
|
|
182
|
+
decorated.concat = (concatMiddleware, mapInput) => {
|
|
183
|
+
const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;
|
|
184
|
+
const concatted = decorateMiddleware((options, input, output, ...rest) => {
|
|
185
|
+
const merged = middleware(
|
|
186
|
+
{
|
|
187
|
+
...options,
|
|
188
|
+
next: (...[nextOptions1]) => mapped(
|
|
189
|
+
{
|
|
190
|
+
...options,
|
|
191
|
+
context: { ...options.context, ...nextOptions1?.context },
|
|
192
|
+
next: (...[nextOptions2]) => options.next({ context: { ...nextOptions1?.context, ...nextOptions2?.context } })
|
|
193
|
+
},
|
|
194
|
+
input,
|
|
195
|
+
output,
|
|
196
|
+
...rest
|
|
197
|
+
)
|
|
198
|
+
},
|
|
199
|
+
input,
|
|
200
|
+
output,
|
|
201
|
+
...rest
|
|
202
|
+
);
|
|
203
|
+
return merged;
|
|
204
|
+
});
|
|
205
|
+
return concatted;
|
|
206
|
+
};
|
|
207
|
+
return decorated;
|
|
442
208
|
}
|
|
443
209
|
|
|
444
210
|
class Builder extends BuilderWithMiddlewares {
|
|
@@ -471,6 +237,7 @@ function createApiBuilder(opts = {}) {
|
|
|
471
237
|
console.dir(error, { depth: null });
|
|
472
238
|
})
|
|
473
239
|
],
|
|
240
|
+
schemas: initialSchemas,
|
|
474
241
|
// NB: this is a relic from orpc -- I'm not convinced there's a need for this (or if there is, that it's
|
|
475
242
|
// the best solution). For now I've removed the interface to configure it externally.
|
|
476
243
|
dedupeLeadingMiddlewares: true
|
|
@@ -512,17 +279,6 @@ function implementerInternal(contract, middlewares) {
|
|
|
512
279
|
});
|
|
513
280
|
return setHiddenRouterContract(adapted, contract);
|
|
514
281
|
};
|
|
515
|
-
} else if (key === "lazyRoute") {
|
|
516
|
-
method = (loader) => {
|
|
517
|
-
const adapted = enhanceRouter(lazy(loader), {
|
|
518
|
-
middlewares,
|
|
519
|
-
errorMap: {},
|
|
520
|
-
prefix: void 0,
|
|
521
|
-
tags: void 0,
|
|
522
|
-
dedupeLeadingMiddlewares: true
|
|
523
|
-
});
|
|
524
|
-
return setHiddenRouterContract(adapted, contract);
|
|
525
|
-
};
|
|
526
282
|
}
|
|
527
283
|
const next = getContractRouter(target, [key]);
|
|
528
284
|
if (!next) {
|
|
@@ -564,7 +320,7 @@ function implement(contract) {
|
|
|
564
320
|
}
|
|
565
321
|
|
|
566
322
|
function createAssertedLazyProcedure(lazied) {
|
|
567
|
-
const lazyProcedure =
|
|
323
|
+
const lazyProcedure = lazyInternal(async () => {
|
|
568
324
|
const { default: maybeProcedure } = await unlazy(lazied);
|
|
569
325
|
if (!isProcedure(maybeProcedure)) {
|
|
570
326
|
throw new Error(`
|
|
@@ -615,4 +371,4 @@ function createRouterClient(router, ...rest) {
|
|
|
615
371
|
return recursive;
|
|
616
372
|
}
|
|
617
373
|
|
|
618
|
-
export { Builder, BuilderWithMiddlewares, DecoratedProcedure, Procedure, ProcedureBuilder, addMiddleware, call,
|
|
374
|
+
export { Builder, BuilderWithMiddlewares, DecoratedProcedure, Procedure, ProcedureBuilder, addMiddleware, call, createApiBuilder, createAssertedLazyProcedure, createContractedProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, getLazyMeta, getRouter, implement, implementerInternal, isLazy, isProcedure, lazyInternal, os, setHiddenRouterContract, unlazy };
|
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.TgmlNh8r.mjs';
|
|
5
|
+
import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.B5czSQQh.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.C4l2ZA3m.js';
|
|
5
|
+
import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.B5czSQQh.js';
|
|
6
6
|
import { Meta } from '@temporary-name/contract';
|
|
7
7
|
|
|
8
8
|
interface BatchHandlerOptions<T extends Context> {
|