@orpc/openapi 0.15.0 → 0.17.0

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.
@@ -1,12 +1,13 @@
1
1
  // src/utils.ts
2
2
  import { isContractProcedure } from "@orpc/contract";
3
- import { isLazy, isProcedure, ROUTER_CONTRACT_SYMBOL } from "@orpc/server";
3
+ import { flatLazy, getRouterContract, isLazy, isProcedure } from "@orpc/server";
4
4
  function eachContractProcedureLeaf(options, callback, result = [], isCurrentRouterContract = false) {
5
- if (!isCurrentRouterContract && ROUTER_CONTRACT_SYMBOL in options.router && options.router[ROUTER_CONTRACT_SYMBOL]) {
5
+ const hiddenContract = getRouterContract(options.router);
6
+ if (!isCurrentRouterContract && hiddenContract) {
6
7
  return eachContractProcedureLeaf(
7
8
  {
8
9
  path: options.path,
9
- router: options.router[ROUTER_CONTRACT_SYMBOL]
10
+ router: hiddenContract
10
11
  },
11
12
  callback,
12
13
  result,
@@ -15,12 +16,12 @@ function eachContractProcedureLeaf(options, callback, result = [], isCurrentRout
15
16
  }
16
17
  if (isLazy(options.router)) {
17
18
  result.push({
18
- lazy: options.router,
19
+ lazy: flatLazy(options.router),
19
20
  path: options.path
20
21
  });
21
22
  } else if (isProcedure(options.router)) {
22
23
  callback({
23
- contract: options.router.zz$p.contract,
24
+ contract: options.router["~orpc"].contract,
24
25
  path: options.path
25
26
  });
26
27
  } else if (isContractProcedure(options.router)) {
@@ -42,8 +43,12 @@ function eachContractProcedureLeaf(options, callback, result = [], isCurrentRout
42
43
  }
43
44
  return result;
44
45
  }
46
+ function standardizeHTTPPath(path) {
47
+ return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
48
+ }
45
49
 
46
50
  export {
47
- eachContractProcedureLeaf
51
+ eachContractProcedureLeaf,
52
+ standardizeHTTPPath
48
53
  };
49
- //# sourceMappingURL=chunk-KZIT2WCV.js.map
54
+ //# sourceMappingURL=chunk-CMRY2Z4J.js.map
package/dist/fetch.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import {
2
- eachContractProcedureLeaf
3
- } from "./chunk-KZIT2WCV.js";
2
+ eachContractProcedureLeaf,
3
+ standardizeHTTPPath
4
+ } from "./chunk-CMRY2Z4J.js";
4
5
 
5
6
  // src/fetch/base-handler.ts
6
- import { ORPC_HEADER, standardizeHTTPPath } from "@orpc/contract";
7
- import { createProcedureCaller, isLazy, isProcedure, LAZY_LOADER_SYMBOL, LAZY_ROUTER_PREFIX_SYMBOL, ORPCError } from "@orpc/server";
8
- import { executeWithHooks, isPlainObject, mapValues, trim, value } from "@orpc/shared";
7
+ import { createProcedureClient, getLazyRouterPrefix, getRouterChild, isProcedure, LAZY_LOADER_SYMBOL, ORPCError, unlazy } from "@orpc/server";
8
+ import { executeWithHooks, isPlainObject, mapValues, ORPC_PROTOCOL_HEADER, ORPC_PROTOCOL_VALUE, trim, value } from "@orpc/shared";
9
9
  import { OpenAPIDeserializer, OpenAPISerializer, zodCoerce } from "@orpc/transformer";
10
10
  function createOpenAPIHandler(createHonoRouter) {
11
11
  const resolveRouter = createResolveRouter(createHonoRouter);
12
12
  return async (options) => {
13
- if (options.request.headers.get(ORPC_HEADER) !== null) {
13
+ if (options.request.headers.get(ORPC_PROTOCOL_HEADER)?.includes(ORPC_PROTOCOL_VALUE)) {
14
14
  return void 0;
15
15
  }
16
16
  const context = await value(options.context);
@@ -25,22 +25,15 @@ function createOpenAPIHandler(createHonoRouter) {
25
25
  if (!match) {
26
26
  throw new ORPCError({ code: "NOT_FOUND", message: "Not found" });
27
27
  }
28
- const procedure = isLazy(match.procedure) ? (await match.procedure[LAZY_LOADER_SYMBOL]()).default : match.procedure;
29
- const path = match.path;
30
- if (!isProcedure(procedure)) {
31
- throw new ORPCError({
32
- code: "NOT_FOUND",
33
- message: "Not found"
34
- });
35
- }
36
- const params = procedure.zz$p.contract.zz$cp.InputSchema ? zodCoerce(
37
- procedure.zz$p.contract.zz$cp.InputSchema,
28
+ const { path, procedure } = match;
29
+ const params = procedure["~orpc"].contract["~orpc"].InputSchema ? zodCoerce(
30
+ procedure["~orpc"].contract["~orpc"].InputSchema,
38
31
  match.params,
39
32
  { bracketNotation: true }
40
33
  ) : match.params;
41
34
  const input = await deserializeInput(options.request, procedure);
42
35
  const mergedInput = mergeParamsAndInput(params, input);
43
- const caller = createProcedureCaller({
36
+ const caller = createProcedureClient({
44
37
  context,
45
38
  procedure,
46
39
  path
@@ -88,8 +81,8 @@ var pendingCache = /* @__PURE__ */ new Map();
88
81
  function createResolveRouter(createHonoRouter) {
89
82
  const addRoutes = (routing, pending, options) => {
90
83
  const lazies = eachContractProcedureLeaf(options, ({ path, contract }) => {
91
- const method = contract.zz$cp.method ?? "POST";
92
- const httpPath = contract.zz$cp.path ? openAPIPathToRouterPath(contract.zz$cp.path) : `/${path.map(encodeURIComponent).join("/")}`;
84
+ const method = contract["~orpc"].route?.method ?? "POST";
85
+ const httpPath = contract["~orpc"].route?.path ? openAPIPathToRouterPath(contract["~orpc"].route?.path) : `/${path.map(encodeURIComponent).join("/")}`;
93
86
  routing.add(method, httpPath, path);
94
87
  });
95
88
  pending.ref.push(...lazies);
@@ -114,7 +107,8 @@ function createResolveRouter(createHonoRouter) {
114
107
  })();
115
108
  const newPending = [];
116
109
  for (const item of pending.ref) {
117
- if (LAZY_ROUTER_PREFIX_SYMBOL in item.lazy && item.lazy[LAZY_ROUTER_PREFIX_SYMBOL] && !pathname.startsWith(item.lazy[LAZY_ROUTER_PREFIX_SYMBOL]) && !pathname.startsWith(`/${item.path.map(encodeURIComponent).join("/")}`)) {
110
+ const lazyPrefix = getLazyRouterPrefix(item.lazy);
111
+ if (lazyPrefix && !pathname.startsWith(lazyPrefix) && !pathname.startsWith(`/${item.path.map(encodeURIComponent).join("/")}`)) {
118
112
  newPending.push(item);
119
113
  continue;
120
114
  }
@@ -134,20 +128,16 @@ function createResolveRouter(createHonoRouter) {
134
128
  match[1],
135
129
  (v) => params_[v]
136
130
  ) : match[1];
137
- let current = router;
138
- for (const segment of path) {
139
- if (typeof current !== "object" && typeof current !== "function" || !current) {
140
- current = void 0;
141
- break;
142
- }
143
- current = current[segment];
131
+ const { default: maybeProcedure } = await unlazy(getRouterChild(router, ...path));
132
+ if (!isProcedure(maybeProcedure)) {
133
+ return void 0;
144
134
  }
145
- return isProcedure(current) || isLazy(current) ? {
135
+ return {
146
136
  path,
147
- procedure: current,
137
+ procedure: maybeProcedure,
148
138
  params: { ...params }
149
139
  // params from hono not a normal object, so we need spread here
150
- } : void 0;
140
+ };
151
141
  };
152
142
  }
153
143
  function mergeParamsAndInput(coercedParams, input) {
@@ -164,7 +154,7 @@ function mergeParamsAndInput(coercedParams, input) {
164
154
  }
165
155
  async function deserializeInput(request, procedure) {
166
156
  const deserializer = new OpenAPIDeserializer({
167
- schema: procedure.zz$p.contract.zz$cp.InputSchema
157
+ schema: procedure["~orpc"].contract["~orpc"].InputSchema
168
158
  });
169
159
  try {
170
160
  return await deserializer.deserialize(request);
@@ -702,7 +692,6 @@ export {
702
692
  createOpenAPIHandler,
703
693
  createOpenAPIServerHandler,
704
694
  createOpenAPIServerlessHandler,
705
- createResolveRouter,
706
- openAPIPathToRouterPath
695
+ createResolveRouter
707
696
  };
708
697
  //# sourceMappingURL=fetch.js.map
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import {
2
- eachContractProcedureLeaf
3
- } from "./chunk-KZIT2WCV.js";
2
+ eachContractProcedureLeaf,
3
+ standardizeHTTPPath
4
+ } from "./chunk-CMRY2Z4J.js";
4
5
 
5
6
  // src/generator.ts
6
7
  import { isContractProcedure } from "@orpc/contract";
7
- import { LAZY_LOADER_SYMBOL } from "@orpc/server";
8
+ import { unlazy } from "@orpc/server";
8
9
  import { findDeepMatches, isPlainObject, omit } from "@orpc/shared";
9
10
  import { preSerialize } from "@orpc/transformer";
10
11
  import {
@@ -3943,10 +3944,15 @@ var NON_LOGIC_KEYWORDS = [
3943
3944
  var UNSUPPORTED_JSON_SCHEMA = { not: {} };
3944
3945
  var UNDEFINED_JSON_SCHEMA = { const: "undefined" };
3945
3946
  function zodToJsonSchema(schema, options) {
3947
+ if (schema["~standard"].vendor !== "zod") {
3948
+ console.warn(`Generate JSON schema not support ${schema["~standard"].vendor} yet`);
3949
+ return {};
3950
+ }
3951
+ const schema__ = schema;
3946
3952
  if (!options?.isHandledCustomJSONSchema) {
3947
- const customJSONSchema = getCustomJSONSchema(schema._def, options);
3953
+ const customJSONSchema = getCustomJSONSchema(schema__._def, options);
3948
3954
  if (customJSONSchema) {
3949
- const json = zodToJsonSchema(schema, {
3955
+ const json = zodToJsonSchema(schema__, {
3950
3956
  ...options,
3951
3957
  isHandledCustomJSONSchema: true
3952
3958
  });
@@ -3957,13 +3963,13 @@ function zodToJsonSchema(schema, options) {
3957
3963
  }
3958
3964
  }
3959
3965
  const childOptions = { ...options, isHandledCustomJSONSchema: false };
3960
- const customType = getCustomZodType(schema._def);
3966
+ const customType = getCustomZodType(schema__._def);
3961
3967
  switch (customType) {
3962
3968
  case "Blob": {
3963
3969
  return { type: "string", contentMediaType: "*/*" };
3964
3970
  }
3965
3971
  case "File": {
3966
- const mimeType = getCustomZodFileMimeType(schema._def) ?? "*/*";
3972
+ const mimeType = getCustomZodFileMimeType(schema__._def) ?? "*/*";
3967
3973
  return { type: "string", contentMediaType: mimeType };
3968
3974
  }
3969
3975
  case "Invalid Date": {
@@ -3980,10 +3986,10 @@ function zodToJsonSchema(schema, options) {
3980
3986
  }
3981
3987
  }
3982
3988
  const _expectedCustomType = customType;
3983
- const typeName = schema._def.typeName;
3989
+ const typeName = schema__._def.typeName;
3984
3990
  switch (typeName) {
3985
3991
  case ZodFirstPartyTypeKind.ZodString: {
3986
- const schema_ = schema;
3992
+ const schema_ = schema__;
3987
3993
  const json = { type: "string" };
3988
3994
  for (const check of schema_._def.checks) {
3989
3995
  switch (check.kind) {
@@ -4065,7 +4071,7 @@ function zodToJsonSchema(schema, options) {
4065
4071
  return json;
4066
4072
  }
4067
4073
  case ZodFirstPartyTypeKind.ZodNumber: {
4068
- const schema_ = schema;
4074
+ const schema_ = schema__;
4069
4075
  const json = { type: "number" };
4070
4076
  for (const check of schema_._def.checks) {
4071
4077
  switch (check.kind) {
@@ -4110,23 +4116,23 @@ function zodToJsonSchema(schema, options) {
4110
4116
  return UNDEFINED_JSON_SCHEMA;
4111
4117
  }
4112
4118
  case ZodFirstPartyTypeKind.ZodLiteral: {
4113
- const schema_ = schema;
4119
+ const schema_ = schema__;
4114
4120
  return { const: schema_._def.value };
4115
4121
  }
4116
4122
  case ZodFirstPartyTypeKind.ZodEnum: {
4117
- const schema_ = schema;
4123
+ const schema_ = schema__;
4118
4124
  return {
4119
4125
  enum: schema_._def.values
4120
4126
  };
4121
4127
  }
4122
4128
  case ZodFirstPartyTypeKind.ZodNativeEnum: {
4123
- const schema_ = schema;
4129
+ const schema_ = schema__;
4124
4130
  return {
4125
4131
  enum: Object.values(schema_._def.values)
4126
4132
  };
4127
4133
  }
4128
4134
  case ZodFirstPartyTypeKind.ZodArray: {
4129
- const schema_ = schema;
4135
+ const schema_ = schema__;
4130
4136
  const def = schema_._def;
4131
4137
  const json = { type: "array" };
4132
4138
  if (def.exactLength) {
@@ -4142,7 +4148,7 @@ function zodToJsonSchema(schema, options) {
4142
4148
  return json;
4143
4149
  }
4144
4150
  case ZodFirstPartyTypeKind.ZodTuple: {
4145
- const schema_ = schema;
4151
+ const schema_ = schema__;
4146
4152
  const prefixItems = [];
4147
4153
  const json = { type: "array" };
4148
4154
  for (const item of schema_._def.items) {
@@ -4160,7 +4166,7 @@ function zodToJsonSchema(schema, options) {
4160
4166
  return json;
4161
4167
  }
4162
4168
  case ZodFirstPartyTypeKind.ZodObject: {
4163
- const schema_ = schema;
4169
+ const schema_ = schema__;
4164
4170
  const json = { type: "object" };
4165
4171
  const properties = {};
4166
4172
  const required = [];
@@ -4196,7 +4202,7 @@ function zodToJsonSchema(schema, options) {
4196
4202
  return json;
4197
4203
  }
4198
4204
  case ZodFirstPartyTypeKind.ZodRecord: {
4199
- const schema_ = schema;
4205
+ const schema_ = schema__;
4200
4206
  const json = { type: "object" };
4201
4207
  json.additionalProperties = zodToJsonSchema(
4202
4208
  schema_._def.valueType,
@@ -4205,14 +4211,14 @@ function zodToJsonSchema(schema, options) {
4205
4211
  return json;
4206
4212
  }
4207
4213
  case ZodFirstPartyTypeKind.ZodSet: {
4208
- const schema_ = schema;
4214
+ const schema_ = schema__;
4209
4215
  return {
4210
4216
  type: "array",
4211
4217
  items: zodToJsonSchema(schema_._def.valueType, childOptions)
4212
4218
  };
4213
4219
  }
4214
4220
  case ZodFirstPartyTypeKind.ZodMap: {
4215
- const schema_ = schema;
4221
+ const schema_ = schema__;
4216
4222
  return {
4217
4223
  type: "array",
4218
4224
  items: {
@@ -4228,7 +4234,7 @@ function zodToJsonSchema(schema, options) {
4228
4234
  }
4229
4235
  case ZodFirstPartyTypeKind.ZodUnion:
4230
4236
  case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
4231
- const schema_ = schema;
4237
+ const schema_ = schema__;
4232
4238
  const anyOf = [];
4233
4239
  for (const s of schema_._def.options) {
4234
4240
  anyOf.push(zodToJsonSchema(s, childOptions));
@@ -4236,7 +4242,7 @@ function zodToJsonSchema(schema, options) {
4236
4242
  return { anyOf };
4237
4243
  }
4238
4244
  case ZodFirstPartyTypeKind.ZodIntersection: {
4239
- const schema_ = schema;
4245
+ const schema_ = schema__;
4240
4246
  const allOf = [];
4241
4247
  for (const s of [schema_._def.left, schema_._def.right]) {
4242
4248
  allOf.push(zodToJsonSchema(s, childOptions));
@@ -4244,7 +4250,7 @@ function zodToJsonSchema(schema, options) {
4244
4250
  return { allOf };
4245
4251
  }
4246
4252
  case ZodFirstPartyTypeKind.ZodLazy: {
4247
- const schema_ = schema;
4253
+ const schema_ = schema__;
4248
4254
  const maxLazyDepth = childOptions?.maxLazyDepth ?? 5;
4249
4255
  const lazyDepth = childOptions?.lazyDepth ?? 0;
4250
4256
  if (lazyDepth > maxLazyDepth) {
@@ -4261,44 +4267,44 @@ function zodToJsonSchema(schema, options) {
4261
4267
  return {};
4262
4268
  }
4263
4269
  case ZodFirstPartyTypeKind.ZodOptional: {
4264
- const schema_ = schema;
4270
+ const schema_ = schema__;
4265
4271
  const inner = zodToJsonSchema(schema_._def.innerType, childOptions);
4266
4272
  return {
4267
4273
  anyOf: [UNDEFINED_JSON_SCHEMA, inner]
4268
4274
  };
4269
4275
  }
4270
4276
  case ZodFirstPartyTypeKind.ZodReadonly: {
4271
- const schema_ = schema;
4277
+ const schema_ = schema__;
4272
4278
  return zodToJsonSchema(schema_._def.innerType, childOptions);
4273
4279
  }
4274
4280
  case ZodFirstPartyTypeKind.ZodDefault: {
4275
- const schema_ = schema;
4281
+ const schema_ = schema__;
4276
4282
  return zodToJsonSchema(schema_._def.innerType, childOptions);
4277
4283
  }
4278
4284
  case ZodFirstPartyTypeKind.ZodEffects: {
4279
- const schema_ = schema;
4285
+ const schema_ = schema__;
4280
4286
  if (schema_._def.effect.type === "transform" && childOptions?.mode === "output") {
4281
4287
  return {};
4282
4288
  }
4283
4289
  return zodToJsonSchema(schema_._def.schema, childOptions);
4284
4290
  }
4285
4291
  case ZodFirstPartyTypeKind.ZodCatch: {
4286
- const schema_ = schema;
4292
+ const schema_ = schema__;
4287
4293
  return zodToJsonSchema(schema_._def.innerType, childOptions);
4288
4294
  }
4289
4295
  case ZodFirstPartyTypeKind.ZodBranded: {
4290
- const schema_ = schema;
4296
+ const schema_ = schema__;
4291
4297
  return zodToJsonSchema(schema_._def.type, childOptions);
4292
4298
  }
4293
4299
  case ZodFirstPartyTypeKind.ZodPipeline: {
4294
- const schema_ = schema;
4300
+ const schema_ = schema__;
4295
4301
  return zodToJsonSchema(
4296
4302
  childOptions?.mode === "output" ? schema_._def.out : schema_._def.in,
4297
4303
  childOptions
4298
4304
  );
4299
4305
  }
4300
4306
  case ZodFirstPartyTypeKind.ZodNullable: {
4301
- const schema_ = schema;
4307
+ const schema_ = schema__;
4302
4308
  const inner = zodToJsonSchema(schema_._def.innerType, childOptions);
4303
4309
  return {
4304
4310
  anyOf: [{ type: "null" }, inner]
@@ -4367,12 +4373,12 @@ async function generateOpenAPI(opts, options) {
4367
4373
  if (!isContractProcedure(contract)) {
4368
4374
  return;
4369
4375
  }
4370
- const internal = contract.zz$cp;
4371
- if (ignoreUndefinedPathProcedures && internal.path === void 0) {
4376
+ const internal = contract["~orpc"];
4377
+ if (ignoreUndefinedPathProcedures && internal.route?.path === void 0) {
4372
4378
  return;
4373
4379
  }
4374
- const httpPath = internal.path ?? `/${path.map(encodeURIComponent).join("/")}`;
4375
- const method = internal.method ?? "POST";
4380
+ const httpPath = internal.route?.path ? standardizeHTTPPath(internal.route?.path) : `/${path.map(encodeURIComponent).join("/")}`;
4381
+ const method = internal.route?.method ?? "POST";
4376
4382
  let inputSchema = internal.InputSchema ? zodToJsonSchema(internal.InputSchema, { mode: "input" }) : {};
4377
4383
  const outputSchema = internal.OutputSchema ? zodToJsonSchema(internal.OutputSchema, { mode: "output" }) : {};
4378
4384
  const params = (() => {
@@ -4507,7 +4513,9 @@ async function generateOpenAPI(opts, options) {
4507
4513
  };
4508
4514
  }
4509
4515
  return {
4510
- required: Boolean(internal.InputSchema?.isOptional()),
4516
+ required: Boolean(
4517
+ internal.InputSchema && "isOptional" in internal.InputSchema && typeof internal.InputSchema.isOptional === "function" ? internal.InputSchema.isOptional() : false
4518
+ ),
4511
4519
  content
4512
4520
  };
4513
4521
  })();
@@ -4532,8 +4540,8 @@ async function generateOpenAPI(opts, options) {
4532
4540
  content
4533
4541
  };
4534
4542
  })();
4535
- if (throwOnMissingTagDefinition && internal.tags) {
4536
- const missingTag = internal.tags.find((tag) => !rootTags.includes(tag));
4543
+ if (throwOnMissingTagDefinition && internal.route?.tags) {
4544
+ const missingTag = internal.route?.tags.find((tag) => !rootTags.includes(tag));
4537
4545
  if (missingTag !== void 0) {
4538
4546
  throw new Error(
4539
4547
  `Tag "${missingTag}" is missing definition. Please define it in OpenAPI root tags object. [${path.join(".")}]`
@@ -4541,10 +4549,10 @@ async function generateOpenAPI(opts, options) {
4541
4549
  }
4542
4550
  }
4543
4551
  const operation = {
4544
- summary: internal.summary,
4545
- description: internal.description,
4546
- deprecated: internal.deprecated,
4547
- tags: internal.tags,
4552
+ summary: internal.route?.summary,
4553
+ description: internal.route?.description,
4554
+ deprecated: internal.route?.deprecated,
4555
+ tags: internal.route?.tags ? [...internal.route.tags] : void 0,
4548
4556
  operationId: path.join("."),
4549
4557
  parameters: parameters.length ? parameters : void 0,
4550
4558
  requestBody,
@@ -4557,7 +4565,7 @@ async function generateOpenAPI(opts, options) {
4557
4565
  });
4558
4566
  });
4559
4567
  for (const lazy of lazies) {
4560
- const router = (await lazy.lazy[LAZY_LOADER_SYMBOL]()).default;
4568
+ const { default: router } = await unlazy(lazy.lazy);
4561
4569
  pending.push({
4562
4570
  path: lazy.path,
4563
4571
  router
@@ -1,15 +1,13 @@
1
- import type { HTTPPath } from '@orpc/contract';
2
- import type { ANY_LAZY_PROCEDURE, ANY_PROCEDURE, Router } from '@orpc/server';
1
+ import type { ANY_PROCEDURE, ANY_ROUTER } from '@orpc/server';
3
2
  import type { FetchHandler } from '@orpc/server/fetch';
4
3
  import type { Router as HonoRouter } from 'hono/router';
5
- export type ResolveRouter = (router: Router<any>, method: string, pathname: string) => Promise<{
4
+ export type ResolveRouter = (router: ANY_ROUTER, method: string, pathname: string) => Promise<{
6
5
  path: string[];
7
- procedure: ANY_PROCEDURE | ANY_LAZY_PROCEDURE;
6
+ procedure: ANY_PROCEDURE;
8
7
  params: Record<string, string>;
9
8
  } | undefined>;
10
9
  type Routing = HonoRouter<string[]>;
11
10
  export declare function createOpenAPIHandler(createHonoRouter: () => Routing): FetchHandler;
12
11
  export declare function createResolveRouter(createHonoRouter: () => Routing): ResolveRouter;
13
- export declare function openAPIPathToRouterPath(path: HTTPPath): string;
14
12
  export {};
15
13
  //# sourceMappingURL=base-handler.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { type ContractRouter } from '@orpc/contract';
2
- import { type Router } from '@orpc/server';
2
+ import { type ANY_ROUTER } from '@orpc/server';
3
3
  import { type OpenAPIObject } from 'openapi3-ts/oas31';
4
4
  export interface GenerateOpenAPIOptions {
5
5
  /**
@@ -19,6 +19,6 @@ export interface GenerateOpenAPIOptions {
19
19
  ignoreUndefinedPathProcedures?: boolean;
20
20
  }
21
21
  export declare function generateOpenAPI(opts: {
22
- router: ContractRouter | Router<any>;
22
+ router: ContractRouter | ANY_ROUTER;
23
23
  } & Omit<OpenAPIObject, 'openapi'>, options?: GenerateOpenAPIOptions): Promise<OpenAPIObject>;
24
24
  //# sourceMappingURL=generator.d.ts.map
@@ -1,7 +1,7 @@
1
- import type { ContractProcedure, ContractRouter, WELL_CONTRACT_PROCEDURE } from '@orpc/contract';
2
- import type { ANY_LAZY_PROCEDURE, ANY_PROCEDURE, Lazy, Router } from '@orpc/server';
1
+ import type { ContractRouter, HTTPPath, WELL_CONTRACT_PROCEDURE } from '@orpc/contract';
2
+ import type { ANY_PROCEDURE, ANY_ROUTER, Lazy } from '@orpc/server';
3
3
  export interface EachLeafOptions {
4
- router: ANY_PROCEDURE | Router<any> | ContractRouter | ContractProcedure<any, any>;
4
+ router: ContractRouter | ANY_ROUTER;
5
5
  path: string[];
6
6
  }
7
7
  export interface EachLeafCallbackOptions {
@@ -9,8 +9,9 @@ export interface EachLeafCallbackOptions {
9
9
  path: string[];
10
10
  }
11
11
  export interface EachContractLeafResultItem {
12
- lazy: ANY_LAZY_PROCEDURE | Lazy<Router<any>>;
12
+ lazy: Lazy<ANY_PROCEDURE> | Lazy<Record<string, ANY_ROUTER>>;
13
13
  path: string[];
14
14
  }
15
15
  export declare function eachContractProcedureLeaf(options: EachLeafOptions, callback: (options: EachLeafCallbackOptions) => void, result?: EachContractLeafResultItem[], isCurrentRouterContract?: boolean): EachContractLeafResultItem[];
16
+ export declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
16
17
  //# sourceMappingURL=utils.d.ts.map
@@ -1,5 +1,5 @@
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
1
2
  import { type JSONSchema } from 'json-schema-typed/draft-2020-12';
2
- import { type ZodTypeAny } from 'zod';
3
3
  export declare const NON_LOGIC_KEYWORDS: ("$anchor" | "$comment" | "$defs" | "$dynamicAnchor" | "$dynamicRef" | "$id" | "$schema" | "$vocabulary" | "contentEncoding" | "contentMediaType" | "default" | "definitions" | "deprecated" | "description" | "examples" | "format" | "readOnly" | "title" | "writeOnly")[];
4
4
  export declare const UNSUPPORTED_JSON_SCHEMA: {
5
5
  not: {};
@@ -35,7 +35,7 @@ export interface ZodToJsonSchemaOptions {
35
35
  */
36
36
  isHandledCustomJSONSchema?: boolean;
37
37
  }
38
- export declare function zodToJsonSchema(schema: ZodTypeAny, options?: ZodToJsonSchemaOptions): Exclude<JSONSchema, boolean>;
38
+ export declare function zodToJsonSchema(schema: StandardSchemaV1, options?: ZodToJsonSchemaOptions): Exclude<JSONSchema, boolean>;
39
39
  export declare function extractJSONSchema(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): {
40
40
  schema: JSONSchema | undefined;
41
41
  matches: JSONSchema[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/openapi",
3
3
  "type": "module",
4
- "version": "0.15.0",
4
+ "version": "0.17.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -34,14 +34,15 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
+ "@standard-schema/spec": "1.0.0-beta.4",
37
38
  "escape-string-regexp": "^5.0.0",
38
39
  "json-schema-typed": "^8.0.1",
39
40
  "openapi3-ts": "^4.4.0",
40
- "@orpc/server": "0.15.0",
41
- "@orpc/contract": "0.15.0",
42
- "@orpc/shared": "0.15.0",
43
- "@orpc/transformer": "0.15.0",
44
- "@orpc/zod": "0.15.0"
41
+ "@orpc/shared": "0.17.0",
42
+ "@orpc/server": "0.17.0",
43
+ "@orpc/transformer": "0.17.0",
44
+ "@orpc/zod": "0.17.0",
45
+ "@orpc/contract": "0.17.0"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@readme/openapi-parser": "^2.6.0",