@temporary-name/server 1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93 → 1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc
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 +4 -6
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +4 -6
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +4 -6
- package/dist/adapters/standard/index.d.mts +14 -30
- package/dist/adapters/standard/index.d.ts +14 -30
- package/dist/adapters/standard/index.mjs +4 -6
- package/dist/index.d.mts +41 -282
- package/dist/index.d.ts +41 -282
- package/dist/index.mjs +102 -155
- package/dist/openapi/index.mjs +27 -61
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.BeuTpcmO.d.mts → server.B93y_8tj.d.mts} +2 -2
- package/dist/shared/{server.BKh8I1Ny.mjs → server.BYYf0Wn6.mjs} +36 -73
- package/dist/shared/{server.BKSOrA6h.d.mts → server.C3RuMHWl.d.mts} +30 -30
- package/dist/shared/{server.BKSOrA6h.d.ts → server.C3RuMHWl.d.ts} +30 -30
- package/dist/shared/{server.CQyYNJ1H.d.ts → server.CT1xhSmE.d.mts} +1 -2
- package/dist/shared/{server.DLsti1Pv.mjs → server.CqTex_jI.mjs} +57 -85
- package/dist/shared/{server.SLLuK6_v.d.ts → server.D_fags8X.d.ts} +2 -2
- package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
- package/dist/shared/{server.C1fnTLq0.d.mts → server.cjcgLdr1.d.ts} +1 -2
- package/package.json +10 -9
package/dist/index.mjs
CHANGED
|
@@ -1,49 +1,11 @@
|
|
|
1
|
-
import { isContractProcedure, mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, enhanceRoute, mergeTags, getContractRouter } from '@temporary-name/contract';
|
|
2
|
-
export { ValidationError, eventIterator, type, validateORPCError } from '@temporary-name/contract';
|
|
3
1
|
import { onError, resolveMaybeOptionalOptions } from '@temporary-name/shared';
|
|
4
2
|
export { AsyncIteratorClass, EventPublisher, ORPCError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, safe, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
3
|
+
import { isContractProcedure, mergePrefix, mergeErrorMap, enhanceRoute, mergeTags, ContractProcedure, mergeMeta, mergeRoute, prefixRoute, getContractRouter } from '@temporary-name/contract';
|
|
4
|
+
export { ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
|
|
5
|
+
import { SchemaClass, gatingContext } from '@temporary-name/zod';
|
|
6
|
+
import { c as createProcedureClient, i as isLazy, g as getLazyMeta, l as lazy, u as unlazy } from './shared/server.BYYf0Wn6.mjs';
|
|
7
|
+
export { L as LAZY_SYMBOL, a as createORPCErrorConstructorMap, m as mergeCurrentContext, b as middlewareOutputFn } from './shared/server.BYYf0Wn6.mjs';
|
|
7
8
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
8
|
-
import 'node:async_hooks';
|
|
9
|
-
import 'zod';
|
|
10
|
-
import 'zod/v4/core';
|
|
11
|
-
|
|
12
|
-
function decorateMiddleware(middleware) {
|
|
13
|
-
const decorated = ((...args) => middleware(...args));
|
|
14
|
-
decorated.mapInput = (mapInput) => {
|
|
15
|
-
const mapped = decorateMiddleware(
|
|
16
|
-
(options, input, ...rest) => middleware(options, mapInput(input), ...rest)
|
|
17
|
-
);
|
|
18
|
-
return mapped;
|
|
19
|
-
};
|
|
20
|
-
decorated.concat = (concatMiddleware, mapInput) => {
|
|
21
|
-
const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;
|
|
22
|
-
const concatted = decorateMiddleware((options, input, output, ...rest) => {
|
|
23
|
-
const merged = middleware(
|
|
24
|
-
{
|
|
25
|
-
...options,
|
|
26
|
-
next: (...[nextOptions1]) => mapped(
|
|
27
|
-
{
|
|
28
|
-
...options,
|
|
29
|
-
context: { ...options.context, ...nextOptions1?.context },
|
|
30
|
-
next: (...[nextOptions2]) => options.next({ context: { ...nextOptions1?.context, ...nextOptions2?.context } })
|
|
31
|
-
},
|
|
32
|
-
input,
|
|
33
|
-
output,
|
|
34
|
-
...rest
|
|
35
|
-
)
|
|
36
|
-
},
|
|
37
|
-
input,
|
|
38
|
-
output,
|
|
39
|
-
...rest
|
|
40
|
-
);
|
|
41
|
-
return merged;
|
|
42
|
-
});
|
|
43
|
-
return concatted;
|
|
44
|
-
};
|
|
45
|
-
return decorated;
|
|
46
|
-
}
|
|
47
9
|
|
|
48
10
|
function isStartWithMiddlewares(middlewares, compare) {
|
|
49
11
|
if (compare.length > middlewares.length) {
|
|
@@ -82,55 +44,10 @@ function isProcedure(item) {
|
|
|
82
44
|
if (item instanceof Procedure) {
|
|
83
45
|
return true;
|
|
84
46
|
}
|
|
85
|
-
return isContractProcedure(item) && "middlewares" in item["~orpc"] && "
|
|
47
|
+
return isContractProcedure(item) && "middlewares" in item["~orpc"] && "handler" in item["~orpc"];
|
|
86
48
|
}
|
|
87
49
|
|
|
88
50
|
class DecoratedProcedure extends Procedure {
|
|
89
|
-
/**
|
|
90
|
-
* Adds type-safe custom errors.
|
|
91
|
-
* The provided errors are spared-merged with any existing errors.
|
|
92
|
-
*
|
|
93
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
94
|
-
*/
|
|
95
|
-
errors(errors) {
|
|
96
|
-
return new DecoratedProcedure({
|
|
97
|
-
...this["~orpc"],
|
|
98
|
-
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Sets or updates the metadata.
|
|
103
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
104
|
-
*
|
|
105
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
106
|
-
*/
|
|
107
|
-
meta(meta) {
|
|
108
|
-
return new DecoratedProcedure({
|
|
109
|
-
...this["~orpc"],
|
|
110
|
-
meta: mergeMeta(this["~orpc"].meta, meta)
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Sets or updates the route definition.
|
|
115
|
-
* The provided route is spared-merged with any existing route.
|
|
116
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
117
|
-
*
|
|
118
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
119
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
120
|
-
*/
|
|
121
|
-
route(route) {
|
|
122
|
-
return new DecoratedProcedure({
|
|
123
|
-
...this["~orpc"],
|
|
124
|
-
route: mergeRoute(this["~orpc"].route, route)
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
use(middleware, mapInput) {
|
|
128
|
-
const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
|
129
|
-
return new DecoratedProcedure({
|
|
130
|
-
...this["~orpc"],
|
|
131
|
-
middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
51
|
/**
|
|
135
52
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
136
53
|
*
|
|
@@ -295,87 +212,49 @@ async function unlazyRouter(router) {
|
|
|
295
212
|
return unlazied;
|
|
296
213
|
}
|
|
297
214
|
|
|
298
|
-
class
|
|
299
|
-
|
|
300
|
-
* This property holds the defined options.
|
|
301
|
-
*/
|
|
302
|
-
"~orpc";
|
|
215
|
+
class ProcedureBuilder extends ContractProcedure {
|
|
216
|
+
z;
|
|
303
217
|
constructor(def) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Set or override the initial context.
|
|
308
|
-
*
|
|
309
|
-
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
310
|
-
*/
|
|
311
|
-
$context() {
|
|
312
|
-
return this;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Creates a middleware.
|
|
316
|
-
*
|
|
317
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
318
|
-
*/
|
|
319
|
-
middleware(middleware) {
|
|
320
|
-
return decorateMiddleware(middleware);
|
|
218
|
+
super(def);
|
|
219
|
+
this.z = new SchemaClass();
|
|
321
220
|
}
|
|
322
221
|
/**
|
|
323
|
-
* Adds type-safe custom errors.
|
|
324
|
-
* The provided errors are spared-merged with any existing errors.
|
|
222
|
+
* Adds type-safe custom errors to the contract.
|
|
223
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
325
224
|
*
|
|
326
225
|
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
327
226
|
*/
|
|
328
227
|
errors(errors) {
|
|
329
|
-
return new
|
|
228
|
+
return new ProcedureBuilder({
|
|
330
229
|
...this["~orpc"],
|
|
331
230
|
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
|
332
231
|
});
|
|
333
232
|
}
|
|
334
233
|
/**
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
338
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
339
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
340
|
-
*/
|
|
341
|
-
use(middleware) {
|
|
342
|
-
return new Builder({
|
|
343
|
-
...this["~orpc"],
|
|
344
|
-
middlewares: addMiddleware(this["~orpc"].middlewares, middleware)
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
useGating(gates, isGateEnabled) {
|
|
348
|
-
return this.use(({ next, context }) => {
|
|
349
|
-
return gatingContext.run(
|
|
350
|
-
(gate) => isGateEnabled(gate, context),
|
|
351
|
-
() => next({ context: { isGateEnabled } })
|
|
352
|
-
);
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Sets or updates the metadata.
|
|
357
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
234
|
+
* Sets or updates the metadata for the contract.
|
|
235
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
358
236
|
*
|
|
359
237
|
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
360
238
|
*/
|
|
361
239
|
meta(meta) {
|
|
362
|
-
return new
|
|
240
|
+
return new ProcedureBuilder({
|
|
363
241
|
...this["~orpc"],
|
|
364
242
|
meta: mergeMeta(this["~orpc"].meta, meta)
|
|
365
243
|
});
|
|
366
244
|
}
|
|
367
245
|
/**
|
|
368
|
-
* Sets or updates the route definition.
|
|
369
|
-
* The provided route is spared-merged with any existing route.
|
|
246
|
+
* Sets or updates the route definition for the contract.
|
|
247
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
370
248
|
* This option is typically relevant when integrating with OpenAPI.
|
|
371
249
|
*
|
|
372
250
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
373
251
|
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
374
252
|
*/
|
|
375
253
|
route(route) {
|
|
376
|
-
|
|
254
|
+
const { prefix } = this["~orpc"];
|
|
255
|
+
return new ProcedureBuilder({
|
|
377
256
|
...this["~orpc"],
|
|
378
|
-
route: mergeRoute(this["~orpc"].route, route)
|
|
257
|
+
route: mergeRoute(this["~orpc"].route, prefix ? prefixRoute(route, prefix) : route)
|
|
379
258
|
});
|
|
380
259
|
}
|
|
381
260
|
/**
|
|
@@ -384,7 +263,7 @@ class Builder {
|
|
|
384
263
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
385
264
|
*/
|
|
386
265
|
input(schema) {
|
|
387
|
-
return new
|
|
266
|
+
return new ProcedureBuilder({
|
|
388
267
|
...this["~orpc"],
|
|
389
268
|
inputSchema: schema,
|
|
390
269
|
inputValidationIndex: this["~orpc"].middlewares.length
|
|
@@ -396,12 +275,33 @@ class Builder {
|
|
|
396
275
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
397
276
|
*/
|
|
398
277
|
output(schema) {
|
|
399
|
-
return new
|
|
278
|
+
return new ProcedureBuilder({
|
|
400
279
|
...this["~orpc"],
|
|
401
280
|
outputSchema: schema,
|
|
402
281
|
outputValidationIndex: this["~orpc"].middlewares.length
|
|
403
282
|
});
|
|
404
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Uses a middleware to modify the context or improve the pipeline.
|
|
286
|
+
*
|
|
287
|
+
* @info Supports both normal middleware and inline middleware implementations.
|
|
288
|
+
* @note The current context must be satisfy middleware dependent-context
|
|
289
|
+
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
290
|
+
*/
|
|
291
|
+
use(middleware) {
|
|
292
|
+
return new this.constructor({
|
|
293
|
+
...this["~orpc"],
|
|
294
|
+
middlewares: addMiddleware(this["~orpc"].middlewares, middleware)
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
useGating(gates, isGateEnabled) {
|
|
298
|
+
return this.use(({ next, context }) => {
|
|
299
|
+
return gatingContext.run(
|
|
300
|
+
(gate) => isGateEnabled(gate, context),
|
|
301
|
+
() => next({ context: { isGateEnabled } })
|
|
302
|
+
);
|
|
303
|
+
});
|
|
304
|
+
}
|
|
405
305
|
/**
|
|
406
306
|
* Defines the handler of the procedure.
|
|
407
307
|
*
|
|
@@ -413,6 +313,8 @@ class Builder {
|
|
|
413
313
|
handler
|
|
414
314
|
});
|
|
415
315
|
}
|
|
316
|
+
}
|
|
317
|
+
class BuilderWithMiddlewares extends ProcedureBuilder {
|
|
416
318
|
/**
|
|
417
319
|
* Prefixes all procedures in the router.
|
|
418
320
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -422,7 +324,7 @@ class Builder {
|
|
|
422
324
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
423
325
|
*/
|
|
424
326
|
prefix(prefix) {
|
|
425
|
-
return new
|
|
327
|
+
return new this.constructor({
|
|
426
328
|
...this["~orpc"],
|
|
427
329
|
prefix: mergePrefix(this["~orpc"].prefix, prefix)
|
|
428
330
|
});
|
|
@@ -434,7 +336,7 @@ class Builder {
|
|
|
434
336
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
435
337
|
*/
|
|
436
338
|
tag(...tags) {
|
|
437
|
-
return new
|
|
339
|
+
return new this.constructor({
|
|
438
340
|
...this["~orpc"],
|
|
439
341
|
tags: mergeTags(this["~orpc"].tags, tags)
|
|
440
342
|
});
|
|
@@ -447,25 +349,71 @@ class Builder {
|
|
|
447
349
|
router(router) {
|
|
448
350
|
return enhanceRouter(router, this["~orpc"]);
|
|
449
351
|
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function decorateMiddleware(middleware) {
|
|
355
|
+
const decorated = ((...args) => middleware(...args));
|
|
356
|
+
decorated.mapInput = (mapInput) => {
|
|
357
|
+
const mapped = decorateMiddleware(
|
|
358
|
+
(options, input, ...rest) => middleware(options, mapInput(input), ...rest)
|
|
359
|
+
);
|
|
360
|
+
return mapped;
|
|
361
|
+
};
|
|
362
|
+
decorated.concat = (concatMiddleware, mapInput) => {
|
|
363
|
+
const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;
|
|
364
|
+
const concatted = decorateMiddleware((options, input, output, ...rest) => {
|
|
365
|
+
const merged = middleware(
|
|
366
|
+
{
|
|
367
|
+
...options,
|
|
368
|
+
next: (...[nextOptions1]) => mapped(
|
|
369
|
+
{
|
|
370
|
+
...options,
|
|
371
|
+
context: { ...options.context, ...nextOptions1?.context },
|
|
372
|
+
next: (...[nextOptions2]) => options.next({ context: { ...nextOptions1?.context, ...nextOptions2?.context } })
|
|
373
|
+
},
|
|
374
|
+
input,
|
|
375
|
+
output,
|
|
376
|
+
...rest
|
|
377
|
+
)
|
|
378
|
+
},
|
|
379
|
+
input,
|
|
380
|
+
output,
|
|
381
|
+
...rest
|
|
382
|
+
);
|
|
383
|
+
return merged;
|
|
384
|
+
});
|
|
385
|
+
return concatted;
|
|
386
|
+
};
|
|
387
|
+
return decorated;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
class Builder extends BuilderWithMiddlewares {
|
|
391
|
+
/**
|
|
392
|
+
* Set or override the initial context.
|
|
393
|
+
*
|
|
394
|
+
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
395
|
+
*/
|
|
396
|
+
$context() {
|
|
397
|
+
return this;
|
|
398
|
+
}
|
|
450
399
|
/**
|
|
451
|
-
*
|
|
452
|
-
* And applies all of the previously defined options to the specified router.
|
|
400
|
+
* Creates a middleware.
|
|
453
401
|
*
|
|
454
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
402
|
+
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
455
403
|
*/
|
|
456
|
-
|
|
457
|
-
return
|
|
404
|
+
middleware(middleware) {
|
|
405
|
+
return decorateMiddleware(middleware);
|
|
458
406
|
}
|
|
459
407
|
}
|
|
460
408
|
function createApiBuilder(opts = {}) {
|
|
461
|
-
|
|
409
|
+
return new Builder({
|
|
462
410
|
route: {},
|
|
463
411
|
meta: opts.meta ?? {},
|
|
464
412
|
errorMap: {},
|
|
465
413
|
inputValidationIndex: 0,
|
|
466
414
|
outputValidationIndex: 0,
|
|
467
415
|
middlewares: [
|
|
468
|
-
onError((error,
|
|
416
|
+
onError((error, _options) => {
|
|
469
417
|
console.dir(error, { depth: null });
|
|
470
418
|
})
|
|
471
419
|
],
|
|
@@ -473,7 +421,6 @@ function createApiBuilder(opts = {}) {
|
|
|
473
421
|
// the best solution). For now I've removed the interface to configure it externally.
|
|
474
422
|
dedupeLeadingMiddlewares: true
|
|
475
423
|
});
|
|
476
|
-
return base;
|
|
477
424
|
}
|
|
478
425
|
const os = createApiBuilder();
|
|
479
426
|
|
|
@@ -614,4 +561,4 @@ function createRouterClient(router, ...rest) {
|
|
|
614
561
|
return recursive;
|
|
615
562
|
}
|
|
616
563
|
|
|
617
|
-
export { Builder, DecoratedProcedure, Procedure, addMiddleware, call, createAccessibleLazyRouter, createApiBuilder, createAssertedLazyProcedure, createContractedProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, getHiddenRouterContract, getLazyMeta, getRouter, implement, implementerInternal, isLazy, isProcedure, isStartWithMiddlewares, lazy, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazy, unlazyRouter };
|
|
564
|
+
export { Builder, BuilderWithMiddlewares, DecoratedProcedure, Procedure, ProcedureBuilder, addMiddleware, call, createAccessibleLazyRouter, createApiBuilder, createAssertedLazyProcedure, createContractedProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, getHiddenRouterContract, getLazyMeta, getRouter, implement, implementerInternal, isLazy, isProcedure, isStartWithMiddlewares, lazy, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazy, unlazyRouter };
|
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';
|
|
@@ -542,77 +542,43 @@ ${errors.join("\n\n")}`
|
|
|
542
542
|
return;
|
|
543
543
|
}
|
|
544
544
|
const dynamicParams = getDynamicParams(def.route.path)?.map((v) => v.name);
|
|
545
|
-
const inputStructure = fallbackContractConfig("defaultInputStructure", def.route.inputStructure);
|
|
546
545
|
let [required, schema] = await this.converter.convert(def.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
|
}
|
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, E as ProcedureClientInterceptorOptions } from '../shared/server.
|
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CT1xhSmE.mjs';
|
|
5
|
+
import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.C3RuMHWl.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, E as ProcedureClientInterceptorOptions } from '../shared/server.
|
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.cjcgLdr1.js';
|
|
5
|
+
import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.C3RuMHWl.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.C3RuMHWl.mjs';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.CT1xhSmE.mjs';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|