@temporary-name/server 1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36 → 1.9.3-alpha.102eab0800942eb736f7669a86c850ebfdfcd4a3

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.
Files changed (32) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +3 -3
  2. package/dist/adapters/aws-lambda/index.d.ts +3 -3
  3. package/dist/adapters/aws-lambda/index.mjs +4 -3
  4. package/dist/adapters/fetch/index.d.mts +3 -3
  5. package/dist/adapters/fetch/index.d.ts +3 -3
  6. package/dist/adapters/fetch/index.mjs +4 -3
  7. package/dist/adapters/node/index.d.mts +3 -3
  8. package/dist/adapters/node/index.d.ts +3 -3
  9. package/dist/adapters/node/index.mjs +4 -3
  10. package/dist/adapters/standard/index.d.mts +10 -5
  11. package/dist/adapters/standard/index.d.ts +10 -5
  12. package/dist/adapters/standard/index.mjs +4 -3
  13. package/dist/index.d.mts +55 -103
  14. package/dist/index.d.ts +55 -103
  15. package/dist/index.mjs +60 -223
  16. package/dist/openapi/index.d.mts +1 -1
  17. package/dist/openapi/index.d.ts +1 -1
  18. package/dist/openapi/index.mjs +60 -76
  19. package/dist/plugins/index.d.mts +2 -2
  20. package/dist/plugins/index.d.ts +2 -2
  21. package/dist/shared/{server.CbLTWfgn.d.mts → server.BCcLYvdF.d.mts} +1 -1
  22. package/dist/shared/server.CHV9AQHl.mjs +412 -0
  23. package/dist/shared/{server.Bk5r0-2R.d.ts → server.CdeqmULw.d.ts} +1 -1
  24. package/dist/shared/{server.Bs6ka_UE.d.mts → server.DHezmW6C.d.mts} +2 -2
  25. package/dist/shared/server.DN9mVGfv.mjs +11 -0
  26. package/dist/shared/{server.BVxcyR6X.mjs → server.DWwaAM-a.mjs} +12 -44
  27. package/dist/shared/{server.D2UFMrxf.d.ts → server.Da-qLzdU.d.ts} +2 -2
  28. package/dist/shared/{server.CZNLCQBm.d.mts → server.DecvGKtb.d.mts} +125 -75
  29. package/dist/shared/{server.CZNLCQBm.d.ts → server.DecvGKtb.d.ts} +125 -75
  30. package/dist/shared/{server.BEHw7Eyx.mjs → server.JtIZ8YG7.mjs} +1 -11
  31. package/package.json +10 -10
  32. package/dist/shared/server.DcfsPloY.mjs +0 -202
package/dist/index.mjs CHANGED
@@ -1,51 +1,12 @@
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, 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.DcfsPloY.mjs';
7
- export { L as LAZY_SYMBOL, a as createORPCErrorConstructorMap, m as mergeCurrentContext, b as middlewareOutputFn } from './shared/server.DcfsPloY.mjs';
5
+ import { SchemaClass, core, strictObject, gatingContext } from '@temporary-name/zod';
8
6
  export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
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
- class Procedure {
35
- /**
36
- * This property holds the defined options.
37
- */
38
- "~orpc";
39
- constructor(def) {
40
- this["~orpc"] = def;
41
- }
42
- }
43
- function isProcedure(item) {
44
- if (item instanceof Procedure) {
45
- return true;
46
- }
47
- return isContractProcedure(item) && "middlewares" in item["~orpc"] && "handler" in item["~orpc"];
48
- }
7
+ import { g as getDynamicParams } from './shared/server.DN9mVGfv.mjs';
8
+ 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.CHV9AQHl.mjs';
9
+ 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.CHV9AQHl.mjs';
49
10
 
50
11
  class DecoratedProcedure extends Procedure {
51
12
  /**
@@ -66,152 +27,6 @@ class DecoratedProcedure extends Procedure {
66
27
  }
67
28
  }
68
29
 
69
- const HIDDEN_ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_HIDDEN_ROUTER_CONTRACT");
70
- function setHiddenRouterContract(router, contract) {
71
- return new Proxy(router, {
72
- get(target, key) {
73
- if (key === HIDDEN_ROUTER_CONTRACT_SYMBOL) {
74
- return contract;
75
- }
76
- return Reflect.get(target, key);
77
- }
78
- });
79
- }
80
- function getHiddenRouterContract(router) {
81
- return router[HIDDEN_ROUTER_CONTRACT_SYMBOL];
82
- }
83
-
84
- function getRouter(router, path) {
85
- let current = router;
86
- for (let i = 0; i < path.length; i++) {
87
- const segment = path[i];
88
- if (!current) {
89
- return void 0;
90
- }
91
- if (isProcedure(current)) {
92
- return void 0;
93
- }
94
- if (!isLazy(current)) {
95
- current = current[segment];
96
- continue;
97
- }
98
- const lazied = current;
99
- const rest = path.slice(i);
100
- return lazy(async () => {
101
- const unwrapped = await unlazy(lazied);
102
- const next = getRouter(unwrapped.default, rest);
103
- return unlazy(next);
104
- }, getLazyMeta(lazied));
105
- }
106
- return current;
107
- }
108
- function createAccessibleLazyRouter(lazied) {
109
- const recursive = new Proxy(lazied, {
110
- get(target, key) {
111
- if (typeof key !== "string") {
112
- return Reflect.get(target, key);
113
- }
114
- const next = getRouter(lazied, [key]);
115
- return createAccessibleLazyRouter(next);
116
- }
117
- });
118
- return recursive;
119
- }
120
- function enhanceRouter(router, options) {
121
- if (isLazy(router)) {
122
- const laziedMeta = getLazyMeta(router);
123
- const enhancedPrefix = laziedMeta?.prefix ? mergePrefix(options.prefix, laziedMeta?.prefix) : options.prefix;
124
- const enhanced2 = lazy(
125
- async () => {
126
- const { default: unlaziedRouter } = await unlazy(router);
127
- const enhanced3 = enhanceRouter(unlaziedRouter, options);
128
- return unlazy(enhanced3);
129
- },
130
- {
131
- ...laziedMeta,
132
- prefix: enhancedPrefix
133
- }
134
- );
135
- const accessible = createAccessibleLazyRouter(enhanced2);
136
- return accessible;
137
- }
138
- if (isProcedure(router)) {
139
- const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares, {
140
- dedupeLeading: options.dedupeLeadingMiddlewares
141
- });
142
- const newMiddlewareAdded = newMiddlewares.length - router["~orpc"].middlewares.length;
143
- const enhanced2 = new Procedure({
144
- ...router["~orpc"],
145
- route: enhanceRoute(router["~orpc"].route, options),
146
- errorMap: mergeErrorMap(options.errorMap, router["~orpc"].errorMap),
147
- middlewares: newMiddlewares,
148
- inputValidationIndex: router["~orpc"].inputValidationIndex + newMiddlewareAdded,
149
- outputValidationIndex: router["~orpc"].outputValidationIndex + newMiddlewareAdded
150
- });
151
- return enhanced2;
152
- }
153
- const enhanced = {};
154
- for (const key in router) {
155
- enhanced[key] = enhanceRouter(router[key], options);
156
- }
157
- return enhanced;
158
- }
159
- function traverseContractProcedures(options, callback, lazyOptions = []) {
160
- let currentRouter = options.router;
161
- const hiddenContract = getHiddenRouterContract(options.router);
162
- if (hiddenContract !== void 0) {
163
- currentRouter = hiddenContract;
164
- }
165
- if (isLazy(currentRouter)) {
166
- lazyOptions.push({
167
- router: currentRouter,
168
- path: options.path
169
- });
170
- } else if (isContractProcedure(currentRouter)) {
171
- callback({
172
- contract: currentRouter,
173
- path: options.path
174
- });
175
- } else {
176
- for (const key in currentRouter) {
177
- traverseContractProcedures(
178
- {
179
- router: currentRouter[key],
180
- path: [...options.path, key]
181
- },
182
- callback,
183
- lazyOptions
184
- );
185
- }
186
- }
187
- return lazyOptions;
188
- }
189
- async function resolveContractProcedures(options, callback) {
190
- const pending = [options];
191
- for (const options2 of pending) {
192
- const lazyOptions = traverseContractProcedures(options2, callback);
193
- for (const options3 of lazyOptions) {
194
- const { default: router } = await unlazy(options3.router);
195
- pending.push({
196
- router,
197
- path: options3.path
198
- });
199
- }
200
- }
201
- }
202
- async function unlazyRouter(router) {
203
- if (isProcedure(router)) {
204
- return router;
205
- }
206
- const unlazied = {};
207
- for (const key in router) {
208
- const item = router[key];
209
- const { default: unlaziedRouter } = await unlazy(item);
210
- unlazied[key] = await unlazyRouter(unlaziedRouter);
211
- }
212
- return unlazied;
213
- }
214
-
215
30
  class ProcedureBuilder extends ContractProcedure {
216
31
  z;
217
32
  constructor(def) {
@@ -242,6 +57,27 @@ class ProcedureBuilder extends ContractProcedure {
242
57
  meta: mergeMeta(this["~orpc"].meta, meta)
243
58
  });
244
59
  }
60
+ endpoint(endpoint, schema) {
61
+ const [method, path] = endpoint.split(" ", 2);
62
+ const pathParamNames = getDynamicParams(path)?.map((p) => p.name) ?? [];
63
+ if (schema && !(schema instanceof core.$ZodObject)) {
64
+ throw new Error(`Path schema for endpoint "${endpoint}" must be a ZodObject schema.`);
65
+ }
66
+ const schemaKeys = schema ? Object.keys(schema._zod.def.shape) : [];
67
+ if (pathParamNames.length !== schemaKeys.length || !pathParamNames.every((name) => schemaKeys.includes(name))) {
68
+ throw new Error(`Path schema keys do not match dynamic parameters in endpoint "${endpoint}".`);
69
+ }
70
+ const { prefix } = this["~orpc"];
71
+ const route = { method, path };
72
+ return new ProcedureBuilder({
73
+ ...this["~orpc"],
74
+ route: mergeRoute(this["~orpc"].route, prefix ? prefixRoute(route, prefix) : route),
75
+ schemas: {
76
+ ...this["~orpc"].schemas,
77
+ pathSchema: schema ?? strictObject({})
78
+ }
79
+ });
80
+ }
245
81
  /**
246
82
  * Sets or updates the route definition for the contract.
247
83
  * The provided route is spared-merged with any existing route in the contract.
@@ -250,22 +86,40 @@ class ProcedureBuilder extends ContractProcedure {
250
86
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
251
87
  * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
252
88
  */
253
- route(route) {
89
+ endpointOpts(route) {
254
90
  const { prefix } = this["~orpc"];
255
91
  return new ProcedureBuilder({
256
92
  ...this["~orpc"],
257
93
  route: mergeRoute(this["~orpc"].route, prefix ? prefixRoute(route, prefix) : route)
258
94
  });
259
95
  }
260
- /**
261
- * Defines the input validation schema.
262
- *
263
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
264
- */
265
- input(schema) {
96
+ path(schema) {
97
+ return new ProcedureBuilder({
98
+ ...this["~orpc"],
99
+ schemas: {
100
+ ...this["~orpc"].schemas,
101
+ pathSchema: schema
102
+ },
103
+ inputValidationIndex: this["~orpc"].middlewares.length
104
+ });
105
+ }
106
+ query(schema) {
266
107
  return new ProcedureBuilder({
267
108
  ...this["~orpc"],
268
- inputSchema: schema,
109
+ schemas: {
110
+ ...this["~orpc"].schemas,
111
+ querySchema: schema
112
+ },
113
+ inputValidationIndex: this["~orpc"].middlewares.length
114
+ });
115
+ }
116
+ body(schema) {
117
+ return new ProcedureBuilder({
118
+ ...this["~orpc"],
119
+ schemas: {
120
+ ...this["~orpc"].schemas,
121
+ bodySchema: schema
122
+ },
269
123
  inputValidationIndex: this["~orpc"].middlewares.length
270
124
  });
271
125
  }
@@ -277,7 +131,10 @@ class ProcedureBuilder extends ContractProcedure {
277
131
  output(schema) {
278
132
  return new ProcedureBuilder({
279
133
  ...this["~orpc"],
280
- outputSchema: schema,
134
+ schemas: {
135
+ ...this["~orpc"].schemas,
136
+ outputSchema: schema
137
+ },
281
138
  outputValidationIndex: this["~orpc"].middlewares.length
282
139
  });
283
140
  }
@@ -349,16 +206,6 @@ class BuilderWithMiddlewares extends ProcedureBuilder {
349
206
  router(router) {
350
207
  return enhanceRouter(router, this["~orpc"]);
351
208
  }
352
- /**
353
- * Create a lazy router
354
- * And applies all of the previously defined options to the specified router.
355
- *
356
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
357
- */
358
- lazyRoute(loader) {
359
- const lazied = lazy(loader);
360
- return enhanceRouter(lazied, this["~orpc"]);
361
- }
362
209
  }
363
210
 
364
211
  function decorateMiddleware(middleware) {
@@ -427,6 +274,7 @@ function createApiBuilder(opts = {}) {
427
274
  console.dir(error, { depth: null });
428
275
  })
429
276
  ],
277
+ schemas: initialSchemas,
430
278
  // NB: this is a relic from orpc -- I'm not convinced there's a need for this (or if there is, that it's
431
279
  // the best solution). For now I've removed the interface to configure it externally.
432
280
  dedupeLeadingMiddlewares: true
@@ -468,17 +316,6 @@ function implementerInternal(contract, middlewares) {
468
316
  });
469
317
  return setHiddenRouterContract(adapted, contract);
470
318
  };
471
- } else if (key === "lazyRoute") {
472
- method = (loader) => {
473
- const adapted = enhanceRouter(lazy(loader), {
474
- middlewares,
475
- errorMap: {},
476
- prefix: void 0,
477
- tags: void 0,
478
- dedupeLeadingMiddlewares: true
479
- });
480
- return setHiddenRouterContract(adapted, contract);
481
- };
482
319
  }
483
320
  const next = getContractRouter(target, [key]);
484
321
  if (!next) {
@@ -520,7 +357,7 @@ function implement(contract) {
520
357
  }
521
358
 
522
359
  function createAssertedLazyProcedure(lazied) {
523
- const lazyProcedure = lazy(async () => {
360
+ const lazyProcedure = lazyInternal(async () => {
524
361
  const { default: maybeProcedure } = await unlazy(lazied);
525
362
  if (!isProcedure(maybeProcedure)) {
526
363
  throw new Error(`
@@ -571,4 +408,4 @@ function createRouterClient(router, ...rest) {
571
408
  return recursive;
572
409
  }
573
410
 
574
- 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 };
411
+ 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 };
@@ -55,7 +55,7 @@ interface SchemaConvertOptions {
55
55
  minStructureDepthForRef?: number;
56
56
  }
57
57
  interface SchemaConverter {
58
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
58
+ convert(schemas: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
59
59
  }
60
60
  interface ConditionalSchemaConverter extends SchemaConverter {
61
61
  condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
@@ -55,7 +55,7 @@ interface SchemaConvertOptions {
55
55
  minStructureDepthForRef?: number;
56
56
  }
57
57
  interface SchemaConverter {
58
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
58
+ convert(schemas: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
59
59
  }
60
60
  interface ConditionalSchemaConverter extends SchemaConverter {
61
61
  condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
@@ -1,8 +1,9 @@
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.BEHw7Eyx.mjs';
4
+ import { j as jsonSerialize, d as deserialize, s as serialize } from '../shared/server.JtIZ8YG7.mjs';
5
5
  import '@temporary-name/standard-server';
6
+ import { s as standardizeHTTPPath, g as getDynamicParams } from '../shared/server.DN9mVGfv.mjs';
6
7
  import { TypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
7
8
  export { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
8
9
 
@@ -530,94 +531,77 @@ ${errors.join("\n\n")}`
530
531
  }
531
532
  async #request(doc, ref, def, baseSchemaConvertOptions) {
532
533
  const method = fallbackContractConfig("defaultMethod", def.route.method);
533
- const details = getEventIteratorSchemaDetails(def.inputSchema);
534
- if (details) {
535
- ref.requestBody = {
536
- required: true,
537
- content: toOpenAPIEventIteratorContent(
538
- await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
539
- await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
540
- )
541
- };
542
- return;
543
- }
544
534
  const dynamicParams = getDynamicParams(def.route.path)?.map((v) => v.name);
545
- const inputStructure = fallbackContractConfig("defaultInputStructure", def.route.inputStructure);
546
- let [required, schema] = await this.converter.convert(def.inputSchema, {
535
+ const [_pathRequired, pathSchema] = await this.converter.convert(def.schemas.pathSchema, {
547
536
  ...baseSchemaConvertOptions,
548
537
  strategy: "input",
549
- minStructureDepthForRef: dynamicParams?.length || inputStructure === "detailed" ? 1 : 0
538
+ minStructureDepthForRef: 1
550
539
  });
551
- if (isAnySchema(schema) && !dynamicParams?.length) {
552
- return;
553
- }
554
- if (inputStructure === "compact") {
555
- if (dynamicParams?.length) {
556
- const error2 = new OpenAPIGeneratorError(
557
- 'When input structure is "compact", and path has dynamic params, input schema must be an object with all dynamic params as required.'
558
- );
559
- if (!isObjectSchema(schema)) {
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"));
540
+ if (dynamicParams?.length) {
541
+ const error = new OpenAPIGeneratorError(
542
+ // TODO: fix this error
543
+ 'When input structure is "compact", and path has dynamic params, input schema must be an object with all dynamic params as required.'
544
+ );
545
+ if (!isObjectSchema(pathSchema)) {
546
+ throw error;
570
547
  }
571
- if (method === "GET") {
572
- const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, schema);
573
- if (!isObjectSchema(resolvedSchema)) {
574
- throw new OpenAPIGeneratorError(
575
- 'When method is "GET", input schema must satisfy: object | any | unknown'
576
- );
577
- }
578
- ref.parameters ??= [];
579
- ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
580
- } else {
581
- ref.requestBody = {
582
- required,
583
- content: toOpenAPIContent(schema)
584
- };
548
+ if (!checkParamsSchema(pathSchema, dynamicParams)) {
549
+ throw error;
550
+ }
551
+ ref.parameters ??= [];
552
+ ref.parameters.push(...toOpenAPIParameters(pathSchema, "path"));
553
+ } else {
554
+ const error = new OpenAPIGeneratorError("Params set via path do not match those on the route");
555
+ if (!isObjectSchema(pathSchema)) {
556
+ console.log("FOO", pathSchema);
557
+ throw error;
558
+ }
559
+ if (!checkParamsSchema(pathSchema, [])) {
560
+ console.log("BAR", pathSchema);
561
+ throw error;
585
562
  }
586
- return;
587
- }
588
- const error = new OpenAPIGeneratorError(
589
- 'When input structure is "detailed", input schema must satisfy: { params?: Record<string, unknown>, query?: Record<string, unknown>, headers?: Record<string, unknown>, body?: unknown }'
590
- );
591
- if (!isObjectSchema(schema)) {
592
- throw error;
593
563
  }
594
- const resolvedParamSchema = schema.properties?.params !== void 0 ? resolveOpenAPIJsonSchemaRef(doc, schema.properties.params) : void 0;
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
- );
564
+ const [_queryRequired, querySchema] = await this.converter.convert(def.schemas.querySchema, {
565
+ ...baseSchemaConvertOptions,
566
+ strategy: "input",
567
+ minStructureDepthForRef: 0
568
+ });
569
+ if (!isAnySchema(querySchema)) {
570
+ const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, querySchema);
571
+ if (!isObjectSchema(resolvedSchema)) {
572
+ throw new OpenAPIGeneratorError("Query param schema must satisfy: object | any | unknown");
573
+ }
574
+ ref.parameters ??= [];
575
+ ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
599
576
  }
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;
577
+ if (method !== "GET") {
578
+ const details = getEventIteratorSchemaDetails(def.schemas.bodySchema);
579
+ if (details) {
580
+ ref.requestBody = {
581
+ required: true,
582
+ content: toOpenAPIEventIteratorContent(
583
+ await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
584
+ await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
585
+ )
586
+ };
587
+ } else {
588
+ const [bodyRequired, bodySchema] = await this.converter.convert(def.schemas.bodySchema, {
589
+ ...baseSchemaConvertOptions,
590
+ strategy: "input",
591
+ minStructureDepthForRef: 0
592
+ });
593
+ if (isAnySchema(bodySchema)) {
594
+ return;
606
595
  }
607
- const parameterIn = from === "params" ? "path" : from === "headers" ? "header" : "query";
608
- ref.parameters ??= [];
609
- ref.parameters.push(...toOpenAPIParameters(resolvedSchema, parameterIn));
596
+ ref.requestBody = {
597
+ required: bodyRequired,
598
+ content: toOpenAPIContent(bodySchema)
599
+ };
610
600
  }
611
601
  }
612
- if (schema.properties?.body !== void 0) {
613
- ref.requestBody = {
614
- required: schema.required?.includes("body"),
615
- content: toOpenAPIContent(schema.properties.body)
616
- };
617
- }
618
602
  }
619
603
  async #successResponse(doc, ref, def, baseSchemaConvertOptions) {
620
- const outputSchema = def.outputSchema;
604
+ const outputSchema = def.schemas.outputSchema;
621
605
  const status = fallbackContractConfig("defaultSuccessStatus", def.route.successStatus);
622
606
  const description = fallbackContractConfig("defaultSuccessDescription", def.route?.successDescription);
623
607
  const eventIteratorSchemaDetails = getEventIteratorSchemaDetails(outputSchema);
@@ -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.CbLTWfgn.mjs';
5
- import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.CZNLCQBm.mjs';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.BCcLYvdF.mjs';
5
+ import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.DecvGKtb.mjs';
6
6
  import { Meta } from '@temporary-name/contract';
7
7
 
8
8
  interface BatchHandlerOptions<T extends Context> {
@@ -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.Bk5r0-2R.js';
5
- import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.CZNLCQBm.js';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CdeqmULw.js';
5
+ import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.DecvGKtb.js';
6
6
  import { Meta } from '@temporary-name/contract';
7
7
 
8
8
  interface BatchHandlerOptions<T extends Context> {
@@ -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, E as ProcedureClientInterceptorOptions } from './server.CZNLCQBm.mjs';
4
+ import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.DecvGKtb.mjs';
5
5
 
6
6
  interface StandardHandlerPlugin<T extends Context> {
7
7
  order?: number;