@trpc/openapi 11.18.1-canary.2 → 11.18.1-canary.30

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,40 +1,27 @@
1
- import { __commonJS, __toESM } from "../chunk-CJ2cON1m.mjs";
2
- import { require_objectSpread2 } from "../objectSpread2-Blgb1OZh.mjs";
3
-
4
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js
5
- var require_objectWithoutPropertiesLoose = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(exports, module) {
6
- function _objectWithoutPropertiesLoose(r, e) {
7
- if (null == r) return {};
8
- var t = {};
9
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
10
- if (e.includes(n)) continue;
11
- t[n] = r[n];
12
- }
13
- return t;
1
+ import { t as _objectSpread2 } from "../objectSpread2-Dh4InpQf.mjs";
2
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/objectWithoutPropertiesLoose.js
3
+ function _objectWithoutPropertiesLoose(r, e) {
4
+ if (null == r) return {};
5
+ var t = {};
6
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
7
+ if (e.includes(n)) continue;
8
+ t[n] = r[n];
14
9
  }
15
- module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
16
- } });
17
-
10
+ return t;
11
+ }
18
12
  //#endregion
19
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js
20
- var require_objectWithoutProperties = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(exports, module) {
21
- var objectWithoutPropertiesLoose = require_objectWithoutPropertiesLoose();
22
- function _objectWithoutProperties$1(e, t) {
23
- if (null == e) return {};
24
- var o, r, i = objectWithoutPropertiesLoose(e, t);
25
- if (Object.getOwnPropertySymbols) {
26
- var s = Object.getOwnPropertySymbols(e);
27
- for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
28
- }
29
- return i;
13
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/objectWithoutProperties.js
14
+ function _objectWithoutProperties(e, t) {
15
+ if (null == e) return {};
16
+ var o, r, i = _objectWithoutPropertiesLoose(e, t);
17
+ if (Object.getOwnPropertySymbols) {
18
+ var s = Object.getOwnPropertySymbols(e);
19
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
30
20
  }
31
- module.exports = _objectWithoutProperties$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
32
- } });
33
-
21
+ return i;
22
+ }
34
23
  //#endregion
35
24
  //#region src/heyapi/index.ts
36
- var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
37
- var import_objectWithoutProperties = __toESM(require_objectWithoutProperties(), 1);
38
25
  const _excluded = ["transformer"];
39
26
  function resolveTransformer(transformer) {
40
27
  if ("input" in transformer) return transformer;
@@ -65,11 +52,9 @@ function createTRPCHeyApiTypeResolvers() {
65
52
  return {
66
53
  string(ctx) {
67
54
  if (ctx.schema.format === "date-time" || ctx.schema.format === "date") return ctx.$.type("Date");
68
- return void 0;
69
55
  },
70
56
  number(ctx) {
71
57
  if (ctx.schema.format === "bigint") return ctx.$.type("bigint");
72
- return void 0;
73
58
  }
74
59
  };
75
60
  }
@@ -78,7 +63,7 @@ function createTRPCHeyApiTypeResolvers() {
78
63
  */
79
64
  function createTRPCHeyApiClientConfig(opts) {
80
65
  const transformer = (opts === null || opts === void 0 ? void 0 : opts.transformer) ? resolveTransformer(opts.transformer) : void 0;
81
- return (0, import_objectSpread2.default)({ querySerializer: (query) => {
66
+ return _objectSpread2({ querySerializer: (query) => {
82
67
  const params = new URLSearchParams();
83
68
  for (const [key, value] of Object.entries(query)) {
84
69
  if (value === void 0) continue;
@@ -129,12 +114,12 @@ function createTRPCErrorInterceptor(transformerOpts) {
129
114
  * ```
130
115
  */
131
116
  function configureTRPCHeyApiClient(client, opts) {
132
- const { transformer } = opts, heyConfig = (0, import_objectWithoutProperties.default)(opts, _excluded);
117
+ const { transformer } = opts, heyConfig = _objectWithoutProperties(opts, _excluded);
133
118
  const trpcConfig = createTRPCHeyApiClientConfig({ transformer });
134
- client.setConfig((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, heyConfig), trpcConfig));
119
+ client.setConfig(_objectSpread2(_objectSpread2({}, heyConfig), trpcConfig));
135
120
  if (transformer) client.interceptors.error.use(createTRPCErrorInterceptor(transformer));
136
121
  }
137
-
138
122
  //#endregion
139
123
  export { configureTRPCHeyApiClient, createTRPCErrorInterceptor, createTRPCHeyApiClientConfig, createTRPCHeyApiTypeResolvers };
124
+
140
125
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["_objectWithoutProperties","transformer: DataTransformerOptions","opts?: TRPCHeyApiClientOptions","query: Record<string, unknown>","body: unknown","data: unknown","transformerOpts: DataTransformerOptions","error: unknown","client: Plugins.HeyApiClientFetch.Client","opts: TRPCHeyApiClientOptions &\n Omit<HeyApiConfig, keyof TRPCHeyApiClientConfig>"],"sources":["../../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js","../../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js","../../src/heyapi/index.ts"],"sourcesContent":["function _objectWithoutPropertiesLoose(r, e) {\n if (null == r) return {};\n var t = {};\n for (var n in r) if ({}.hasOwnProperty.call(r, n)) {\n if (e.includes(n)) continue;\n t[n] = r[n];\n }\n return t;\n}\nmodule.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var objectWithoutPropertiesLoose = require(\"./objectWithoutPropertiesLoose.js\");\nfunction _objectWithoutProperties(e, t) {\n if (null == e) return {};\n var o,\n r,\n i = objectWithoutPropertiesLoose(e, t);\n if (Object.getOwnPropertySymbols) {\n var s = Object.getOwnPropertySymbols(e);\n for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);\n }\n return i;\n}\nmodule.exports = _objectWithoutProperties, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","import type { Plugins } from '@hey-api/openapi-ts';\nimport type {\n TRPCCombinedDataTransformer,\n TRPCDataTransformer,\n} from '@trpc/server';\n\nexport type DataTransformerOptions =\n | TRPCDataTransformer\n | TRPCCombinedDataTransformer;\nexport interface TRPCHeyApiClientOptions {\n transformer?: DataTransformerOptions;\n}\n\nexport type HeyAPIResolvers = Plugins.HeyApiTypeScript.Resolvers;\n\nexport type HeyApiConfig = ReturnType<\n Plugins.HeyApiClientFetch.Client['getConfig']\n>;\n\nexport type TRPCHeyApiClientConfig = Required<\n Pick<HeyApiConfig, 'querySerializer'>\n> &\n Pick<HeyApiConfig, 'bodySerializer' | 'responseTransformer'>;\n\nfunction resolveTransformer(\n transformer: DataTransformerOptions,\n): TRPCCombinedDataTransformer {\n if ('input' in transformer) {\n return transformer;\n }\n return { input: transformer, output: transformer };\n}\n\n/**\n * Returns the `~resolvers` object for the `@hey-api/typescript` plugin.\n *\n * Maps `date` and `date-time` string formats to `Date` so that the\n * generated SDK uses `Date` instead of `string` for those fields.\n *\n * @example\n * ```ts\n * import { createClient } from '@hey-api/openapi-ts';\n * import { createTRPCHeyApiTypeResolvers } from '@trpc/openapi/heyapi';\n *\n * await createClient({\n * plugins: [\n * { name: '@hey-api/typescript', '~resolvers': createTRPCHeyApiTypeResolvers() },\n * ],\n * });\n * ```\n */\nexport function createTRPCHeyApiTypeResolvers(): HeyAPIResolvers {\n return {\n string(ctx) {\n if (ctx.schema.format === 'date-time' || ctx.schema.format === 'date') {\n return ctx.$.type('Date');\n }\n return undefined;\n },\n number(ctx) {\n if (ctx.schema.format === 'bigint') {\n return ctx.$.type('bigint');\n }\n return undefined;\n },\n };\n}\n\n/**\n * @internal - Prefer `configureTRPCHeyApiClient`\n */\nexport function createTRPCHeyApiClientConfig(opts?: TRPCHeyApiClientOptions) {\n const transformer = opts?.transformer\n ? resolveTransformer(opts.transformer)\n : undefined;\n\n return {\n querySerializer: (query: Record<string, unknown>) => {\n const params = new URLSearchParams();\n\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) {\n continue;\n }\n\n if (key === 'input' && transformer) {\n params.append(\n key,\n JSON.stringify(transformer.input.serialize(value)),\n );\n } else {\n params.append(key, JSON.stringify(value));\n }\n }\n\n return params.toString();\n },\n\n ...(transformer && {\n bodySerializer: (body: unknown) => {\n return JSON.stringify(transformer.input.serialize(body));\n },\n\n responseTransformer: async (data: unknown) => {\n if (!!data && typeof data === 'object' && 'result' in data) {\n const result = (data as any).result;\n if (!result.type || result.type === 'data') {\n result.data = transformer.output.deserialize(result.data);\n }\n }\n\n return data;\n },\n }),\n } as const satisfies TRPCHeyApiClientConfig;\n}\n\n/**\n * @internal - Prefer `configureTRPCHeyApiClient`\n */\nexport function createTRPCErrorInterceptor(\n transformerOpts: DataTransformerOptions,\n) {\n const transformer = resolveTransformer(transformerOpts);\n return (error: unknown) => {\n if (!!error && typeof error === 'object' && 'error' in error) {\n (error as any).error = transformer.output.deserialize(\n (error as any).error,\n );\n }\n return error;\n };\n}\n\n/**\n * Configures a hey-api client for use with a tRPC OpenAPI backend.\n *\n * Sets up querySerializer, bodySerializer, responseTransformer, and\n * an error interceptor (for transformer-based error deserialization)\n * in a single call.\n *\n * @example\n * ```ts\n * import { configureTRPCHeyApiClient } from '@trpc/openapi/heyapi';\n * import superjson from 'superjson';\n * import { client } from './generated/client.gen';\n *\n * configureTRPCHeyApiClient(client, {\n * baseUrl: 'http://localhost:3000',\n * transformer: superjson,\n * });\n * ```\n */\nexport function configureTRPCHeyApiClient(\n client: Plugins.HeyApiClientFetch.Client,\n opts: TRPCHeyApiClientOptions &\n Omit<HeyApiConfig, keyof TRPCHeyApiClientConfig>,\n) {\n const { transformer, ...heyConfig } = opts;\n const trpcConfig = createTRPCHeyApiClientConfig({ transformer });\n\n client.setConfig({ ...heyConfig, ...trpcConfig });\n\n if (transformer) {\n client.interceptors.error.use(createTRPCErrorInterceptor(transformer));\n }\n}\n"],"x_google_ignoreList":[0,1],"mappings":";;;;;CAAA,SAAS,8BAA8B,GAAG,GAAG;AAC3C,MAAI,QAAQ,EAAG,QAAO,CAAE;EACxB,IAAI,IAAI,CAAE;AACV,OAAK,IAAI,KAAK,EAAG,KAAI,CAAE,EAAC,eAAe,KAAK,GAAG,EAAE,EAAE;AACjD,OAAI,EAAE,SAAS,EAAE,CAAE;AACnB,KAAE,KAAK,EAAE;EACV;AACD,SAAO;CACR;AACD,QAAO,UAAU,+BAA+B,OAAO,QAAQ,aAAa,MAAM,OAAO,QAAQ,aAAa,OAAO;;;;;;CCTrH,IAAI;CACJ,SAASA,2BAAyB,GAAG,GAAG;AACtC,MAAI,QAAQ,EAAG,QAAO,CAAE;EACxB,IAAI,GACF,GACA,IAAI,6BAA6B,GAAG,EAAE;AACxC,MAAI,OAAO,uBAAuB;GAChC,IAAI,IAAI,OAAO,sBAAsB,EAAE;AACvC,QAAK,IAAI,GAAG,IAAI,EAAE,QAAQ,IAAK,KAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAE,EAAC,qBAAqB,KAAK,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE;EAC3G;AACD,SAAO;CACR;AACD,QAAO,UAAUA,4BAA0B,OAAO,QAAQ,aAAa,MAAM,OAAO,QAAQ,aAAa,OAAO;;;;;;;mBCkJtG;AAtIV,SAAS,mBACPC,aAC6B;AAC7B,KAAI,WAAW,YACb,QAAO;AAET,QAAO;EAAE,OAAO;E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AACF;;;;;;;;;;;;;;;;;;;;AAqBD,SAAgB,0BACdC,QACAC,MAEA;CACA,MAAM,EAAE,aAA2B,SAAX,wDAAc;CACtC,MAAM,aAAa,6BAA6B,EAAE,YAAa,EAAC;AAEhE,QAAO,kFAAe,YAAc,YAAa;AAEjD,KAAI,YACF,QAAO,aAAa,MAAM,IAAI,2BAA2B,YAAY,CAAC;AAEzE"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/heyapi/index.ts"],"sourcesContent":["import type { Plugins } from '@hey-api/openapi-ts';\nimport type {\n TRPCCombinedDataTransformer,\n TRPCDataTransformer,\n} from '@trpc/server';\n\nexport type DataTransformerOptions =\n TRPCDataTransformer | TRPCCombinedDataTransformer;\nexport interface TRPCHeyApiClientOptions {\n transformer?: DataTransformerOptions;\n}\n\nexport type HeyAPIResolvers = Plugins.HeyApiTypeScript.Resolvers;\n\nexport type HeyApiConfig = ReturnType<\n Plugins.HeyApiClientFetch.Client['getConfig']\n>;\n\nexport type TRPCHeyApiClientConfig = Required<\n Pick<HeyApiConfig, 'querySerializer'>\n> &\n Pick<HeyApiConfig, 'bodySerializer' | 'responseTransformer'>;\n\nfunction resolveTransformer(\n transformer: DataTransformerOptions,\n): TRPCCombinedDataTransformer {\n if ('input' in transformer) {\n return transformer;\n }\n return { input: transformer, output: transformer };\n}\n\n/**\n * Returns the `~resolvers` object for the `@hey-api/typescript` plugin.\n *\n * Maps `date` and `date-time` string formats to `Date` so that the\n * generated SDK uses `Date` instead of `string` for those fields.\n *\n * @example\n * ```ts\n * import { createClient } from '@hey-api/openapi-ts';\n * import { createTRPCHeyApiTypeResolvers } from '@trpc/openapi/heyapi';\n *\n * await createClient({\n * plugins: [\n * { name: '@hey-api/typescript', '~resolvers': createTRPCHeyApiTypeResolvers() },\n * ],\n * });\n * ```\n */\nexport function createTRPCHeyApiTypeResolvers(): HeyAPIResolvers {\n return {\n string(ctx) {\n if (ctx.schema.format === 'date-time' || ctx.schema.format === 'date') {\n return ctx.$.type('Date');\n }\n return undefined;\n },\n number(ctx) {\n if (ctx.schema.format === 'bigint') {\n return ctx.$.type('bigint');\n }\n return undefined;\n },\n };\n}\n\n/**\n * @internal - Prefer `configureTRPCHeyApiClient`\n */\nexport function createTRPCHeyApiClientConfig(opts?: TRPCHeyApiClientOptions) {\n const transformer = opts?.transformer\n ? resolveTransformer(opts.transformer)\n : undefined;\n\n return {\n querySerializer: (query: Record<string, unknown>) => {\n const params = new URLSearchParams();\n\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) {\n continue;\n }\n\n if (key === 'input' && transformer) {\n params.append(\n key,\n JSON.stringify(transformer.input.serialize(value)),\n );\n } else {\n params.append(key, JSON.stringify(value));\n }\n }\n\n return params.toString();\n },\n\n ...(transformer && {\n bodySerializer: (body: unknown) => {\n return JSON.stringify(transformer.input.serialize(body));\n },\n\n responseTransformer: async (data: unknown) => {\n if (!!data && typeof data === 'object' && 'result' in data) {\n const result = (data as any).result;\n if (!result.type || result.type === 'data') {\n result.data = transformer.output.deserialize(result.data);\n }\n }\n\n return data;\n },\n }),\n } as const satisfies TRPCHeyApiClientConfig;\n}\n\n/**\n * @internal - Prefer `configureTRPCHeyApiClient`\n */\nexport function createTRPCErrorInterceptor(\n transformerOpts: DataTransformerOptions,\n) {\n const transformer = resolveTransformer(transformerOpts);\n return (error: unknown) => {\n if (!!error && typeof error === 'object' && 'error' in error) {\n (error as any).error = transformer.output.deserialize(\n (error as any).error,\n );\n }\n return error;\n };\n}\n\n/**\n * Configures a hey-api client for use with a tRPC OpenAPI backend.\n *\n * Sets up querySerializer, bodySerializer, responseTransformer, and\n * an error interceptor (for transformer-based error deserialization)\n * in a single call.\n *\n * @example\n * ```ts\n * import { configureTRPCHeyApiClient } from '@trpc/openapi/heyapi';\n * import superjson from 'superjson';\n * import { client } from './generated/client.gen';\n *\n * configureTRPCHeyApiClient(client, {\n * baseUrl: 'http://localhost:3000',\n * transformer: superjson,\n * });\n * ```\n */\nexport function configureTRPCHeyApiClient(\n client: Plugins.HeyApiClientFetch.Client,\n opts: TRPCHeyApiClientOptions &\n Omit<HeyApiConfig, keyof TRPCHeyApiClientConfig>,\n) {\n const { transformer, ...heyConfig } = opts;\n const trpcConfig = createTRPCHeyApiClientConfig({ transformer });\n\n client.setConfig({ ...heyConfig, ...trpcConfig });\n\n if (transformer) {\n client.interceptors.error.use(createTRPCErrorInterceptor(transformer));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6JU,MAAA,YAAA,CAAA,aAAA;AAtIV,SAAS,mBACP,aAC6B;CAC7B,IAAI,WAAW,aACb,OAAO;CAET,OAAO;EAAE,OAAO;EAAa,QAAQ;CAAY;AACnD;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,gCAAiD;CAC/D,OAAO;EACL,OAAO,KAAK;GACV,IAAI,IAAI,OAAO,WAAW,eAAe,IAAI,OAAO,WAAW,QAC7D,OAAO,IAAI,EAAE,KAAK,MAAM;EAG5B;EACA,OAAO,KAAK;GACV,IAAI,IAAI,OAAO,WAAW,UACxB,OAAO,IAAI,EAAE,KAAK,QAAQ;EAG9B;CACF;AACF;;;;AAKA,SAAgB,6BAA6B,MAAgC;CAC3E,MAAM,eAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAc,KAAM,eACtB,mBAAmB,KAAK,WAAW,IACnC,KAAA;CAEJ,OAAA,eAAA,EACE,kBAAkB,UAAmC;EACnD,MAAM,SAAS,IAAI,gBAAgB;EAEnC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAAG;GAChD,IAAI,UAAU,KAAA,GACZ;GAGF,IAAI,QAAQ,WAAW,aACrB,OAAO,OACL,KACA,KAAK,UAAU,YAAY,MAAM,UAAU,KAAK,CAAC,CACnD;QAEA,OAAO,OAAO,KAAK,KAAK,UAAU,KAAK,CAAC;EAE5C;EAEA,OAAO,OAAO,SAAS;CACzB,EAAA,GAEI,eAAe;EACjB,iBAAiB,SAAkB;GACjC,OAAO,KAAK,UAAU,YAAY,MAAM,UAAU,IAAI,CAAC;EACzD;EAEA,qBAAqB,OAAO,SAAkB;GAC5C,IAAI,CAAC,CAAC,QAAQ,OAAO,SAAS,YAAY,YAAY,MAAM;IAC1D,MAAM,SAAU,KAAa;IAC7B,IAAI,CAAC,OAAO,QAAQ,OAAO,SAAS,QAClC,OAAO,OAAO,YAAY,OAAO,YAAY,OAAO,IAAI;GAE5D;GAEA,OAAO;EACT;CACF,CACF;AACF;;;;AAKA,SAAgB,2BACd,iBACA;CACA,MAAM,cAAc,mBAAmB,eAAe;CACtD,QAAQ,UAAmB;EACzB,IAAI,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW,OACrD,MAAe,QAAQ,YAAY,OAAO,YACvC,MAAc,KACjB;EAEF,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,0BACd,QACA,MAEA;CACA,MAAM,EAAE,gBAAA,MAAgB,YAAA,yBAAc,MAAA,SAAA;CACtC,MAAM,aAAa,6BAA6B,EAAE,YAAY,CAAC;CAE/D,OAAO,UAAA,eAAA,eAAA,CAAA,GAAe,SAAA,GAAc,UAAW,CAAC;CAEhD,IAAI,aACF,OAAO,aAAa,MAAM,IAAI,2BAA2B,WAAW,CAAC;AAEzE"}
package/dist/index.cjs CHANGED
@@ -1,9 +1,43 @@
1
- const require_objectSpread2$1 = require('./objectSpread2-Cw30I7tb.cjs');
2
- const node_fs = require_objectSpread2$1.__toESM(require("node:fs"));
3
- const node_path = require_objectSpread2$1.__toESM(require("node:path"));
4
- const typescript = require_objectSpread2$1.__toESM(require("typescript"));
5
- const node_url = require_objectSpread2$1.__toESM(require("node:url"));
6
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __exportAll = (all, no_symbols) => {
10
+ let target = {};
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
+ return target;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
20
+ key = keys[i];
21
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
22
+ get: ((k) => from[k]).bind(null, key),
23
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
24
+ });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
29
+ value: mod,
30
+ enumerable: true
31
+ }) : target, mod));
32
+ //#endregion
33
+ const require_objectSpread2 = require("./objectSpread2-C2ceYbQe.cjs");
34
+ let node_fs = require("node:fs");
35
+ node_fs = __toESM(node_fs, 1);
36
+ let node_path = require("node:path");
37
+ node_path = __toESM(node_path, 1);
38
+ let typescript = require("typescript");
39
+ typescript = __toESM(typescript, 1);
40
+ let node_url = require("node:url");
7
41
  //#region src/schemaExtraction.ts
8
42
  /**
9
43
  * Zod v4 stores `.describe()` strings in `globalThis.__zod_globalRegistry`,
@@ -33,7 +67,7 @@ function zodArrayElement(schema) {
33
67
  return null;
34
68
  }
35
69
  /** Wrapper def types whose inner schema is accessible via `innerType` or `in`. */
36
- const wrapperDefTypes = new Set([
70
+ const wrapperDefTypes = /* @__PURE__ */ new Set([
37
71
  "optional",
38
72
  "nullable",
39
73
  "nonoptional",
@@ -157,8 +191,7 @@ function findRouterExport(mod, exportName) {
157
191
  */
158
192
  async function tryImportRouter(resolvedPath, exportName) {
159
193
  try {
160
- const mod = await import((0, node_url.pathToFileURL)(resolvedPath).href);
161
- return findRouterExport(mod, exportName);
194
+ return findRouterExport(await import((0, node_url.pathToFileURL)(resolvedPath).href), exportName);
162
195
  } catch (_unused) {
163
196
  return null;
164
197
  }
@@ -246,9 +279,8 @@ function setNestedDescription({ schema, pathParts, description, schemas }) {
246
279
  if (rest.length === 0) setLeafDescription(items, description);
247
280
  else {
248
281
  var _resolveSchemaRef;
249
- const target = (_resolveSchemaRef = resolveSchemaRef(items, schemas)) !== null && _resolveSchemaRef !== void 0 ? _resolveSchemaRef : items;
250
282
  setNestedDescription({
251
- schema: target,
283
+ schema: (_resolveSchemaRef = resolveSchemaRef(items, schemas)) !== null && _resolveSchemaRef !== void 0 ? _resolveSchemaRef : items,
252
284
  pathParts: rest,
253
285
  description,
254
286
  schemas
@@ -262,19 +294,16 @@ function setNestedDescription({ schema, pathParts, description, schemas }) {
262
294
  else {
263
295
  var _getArrayItemsSchema, _resolveSchemaRef2;
264
296
  const target = (_getArrayItemsSchema = getArrayItemsSchema(propSchema)) !== null && _getArrayItemsSchema !== void 0 ? _getArrayItemsSchema : propSchema;
265
- const resolvedTarget = (_resolveSchemaRef2 = resolveSchemaRef(target, schemas)) !== null && _resolveSchemaRef2 !== void 0 ? _resolveSchemaRef2 : target;
266
297
  setNestedDescription({
267
- schema: resolvedTarget,
298
+ schema: (_resolveSchemaRef2 = resolveSchemaRef(target, schemas)) !== null && _resolveSchemaRef2 !== void 0 ? _resolveSchemaRef2 : target,
268
299
  pathParts: rest,
269
300
  description,
270
301
  schemas
271
302
  });
272
303
  }
273
304
  }
274
-
275
305
  //#endregion
276
306
  //#region src/generate.ts
277
- var import_objectSpread2 = require_objectSpread2$1.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
278
307
  const PRIMITIVE_FLAGS = typescript.TypeFlags.String | typescript.TypeFlags.Number | typescript.TypeFlags.Boolean | typescript.TypeFlags.StringLiteral | typescript.TypeFlags.NumberLiteral | typescript.TypeFlags.BooleanLiteral;
279
308
  function hasFlag(type, flag) {
280
309
  return (type.getFlags() & flag) !== 0;
@@ -300,7 +329,7 @@ function unwrapBrand(type) {
300
329
  if (first && hasObject) return first;
301
330
  return type;
302
331
  }
303
- const ANONYMOUS_NAMES = new Set([
332
+ const ANONYMOUS_NAMES = /* @__PURE__ */ new Set([
304
333
  "__type",
305
334
  "__object",
306
335
  "Object",
@@ -362,8 +391,8 @@ function typeToJsonSchema(type, ctx, depth = 0) {
362
391
  const storedSchema = ctx.schemas[existingRef];
363
392
  if (storedSchema && (isNonEmptySchema(storedSchema) || ctx.visited.has(type))) return schemaRef(existingRef);
364
393
  ctx.schemas[existingRef] = storedSchema !== null && storedSchema !== void 0 ? storedSchema : {};
365
- const schema$1 = convertTypeToSchema(type, ctx, depth);
366
- if (!isSelfSchemaRef(schema$1, existingRef)) ctx.schemas[existingRef] = schema$1;
394
+ const schema = convertTypeToSchema(type, ctx, depth);
395
+ if (!isSelfSchemaRef(schema, existingRef)) ctx.schemas[existingRef] = schema;
367
396
  return schemaRef(existingRef);
368
397
  }
369
398
  const schema = convertTypeToSchema(type, ctx, depth);
@@ -387,8 +416,7 @@ function handleCyclicRef(type, ctx) {
387
416
  let refName = ctx.typeToRef.get(type);
388
417
  if (!refName) {
389
418
  var _getTypeName;
390
- const name = (_getTypeName = getTypeName(type)) !== null && _getTypeName !== void 0 ? _getTypeName : "RecursiveType";
391
- refName = ensureUniqueName(name, ctx.schemas);
419
+ refName = ensureUniqueName((_getTypeName = getTypeName(type)) !== null && _getTypeName !== void 0 ? _getTypeName : "RecursiveType", ctx.schemas);
392
420
  ctx.typeToRef.set(type, refName);
393
421
  ctx.schemas[refName] = {};
394
422
  }
@@ -415,18 +443,14 @@ function convertPrimitiveOrLiteral(type, flags, checker) {
415
443
  type: "number",
416
444
  const: type.value
417
445
  };
418
- if (flags & typescript.TypeFlags.BooleanLiteral) {
419
- const isTrue = checker.typeToString(type) === "true";
420
- return {
421
- type: "boolean",
422
- const: isTrue
423
- };
424
- }
446
+ if (flags & typescript.TypeFlags.BooleanLiteral) return {
447
+ type: "boolean",
448
+ const: checker.typeToString(type) === "true"
449
+ };
425
450
  return null;
426
451
  }
427
452
  function convertUnionType(type, ctx, depth) {
428
- const members = type.types;
429
- const defined = members.filter((m) => !hasFlag(m, typescript.TypeFlags.Undefined | typescript.TypeFlags.Void));
453
+ const defined = type.types.filter((m) => !hasFlag(m, typescript.TypeFlags.Undefined | typescript.TypeFlags.Void));
430
454
  if (defined.length === 0) return {};
431
455
  const hasNull = defined.some((m) => hasFlag(m, typescript.TypeFlags.Null));
432
456
  const nonNull = defined.filter((m) => !hasFlag(m, typescript.TypeFlags.Null));
@@ -460,14 +484,11 @@ function detectDiscriminatorProperty(schemas) {
460
484
  const first = schemas[0];
461
485
  if (!(first === null || first === void 0 ? void 0 : first.properties)) return null;
462
486
  const firstProps = Object.keys(first.properties);
463
- for (const prop of firstProps) {
464
- const allHaveConst = schemas.every((s) => {
465
- var _s$properties, _s$required;
466
- const propSchema = (_s$properties = s.properties) === null || _s$properties === void 0 ? void 0 : _s$properties[prop];
467
- return propSchema !== void 0 && propSchema.const !== void 0 && ((_s$required = s.required) === null || _s$required === void 0 ? void 0 : _s$required.includes(prop));
468
- });
469
- if (allHaveConst) return prop;
470
- }
487
+ for (const prop of firstProps) if (schemas.every((s) => {
488
+ var _s$properties, _s$required;
489
+ const propSchema = (_s$properties = s.properties) === null || _s$properties === void 0 ? void 0 : _s$properties[prop];
490
+ return (propSchema === null || propSchema === void 0 ? void 0 : propSchema.const) !== void 0 && ((_s$required = s.required) === null || _s$required === void 0 ? void 0 : _s$required.includes(prop));
491
+ })) return prop;
471
492
  return null;
472
493
  }
473
494
  /** A schema that is just `{ type: "somePrimitive" }` with no other keys. */
@@ -481,14 +502,12 @@ function isSimpleTypeSchema(s) {
481
502
  */
482
503
  function tryCollapseLiteralUnion(nonNull, hasNull) {
483
504
  if (nonNull.length <= 1) return null;
484
- const allLiterals = nonNull.every((m) => hasFlag(m, typescript.TypeFlags.StringLiteral | typescript.TypeFlags.NumberLiteral));
485
- if (!allLiterals) return null;
505
+ if (!nonNull.every((m) => hasFlag(m, typescript.TypeFlags.StringLiteral | typescript.TypeFlags.NumberLiteral))) return null;
486
506
  const [first] = nonNull;
487
507
  if (!first) return null;
488
508
  const isString = hasFlag(first, typescript.TypeFlags.StringLiteral);
489
509
  const targetFlag = isString ? typescript.TypeFlags.StringLiteral : typescript.TypeFlags.NumberLiteral;
490
- const allSameKind = nonNull.every((m) => hasFlag(m, targetFlag));
491
- if (!allSameKind) return null;
510
+ if (!nonNull.every((m) => hasFlag(m, targetFlag))) return null;
492
511
  const values = nonNull.map((m) => isString ? m.value : m.value);
493
512
  const baseType = isString ? "string" : "number";
494
513
  return {
@@ -497,9 +516,7 @@ function tryCollapseLiteralUnion(nonNull, hasNull) {
497
516
  };
498
517
  }
499
518
  function convertIntersectionType(type, ctx, depth) {
500
- const hasPrimitiveMember = type.types.some(isPrimitive);
501
- const nonBrand = hasPrimitiveMember ? type.types.filter((m) => !isObjectType(m)) : type.types;
502
- const schemas = nonBrand.map((m) => typeToJsonSchema(m, ctx, depth + 1)).filter(isNonEmptySchema);
519
+ const schemas = (type.types.some(isPrimitive) ? type.types.filter((m) => !isObjectType(m)) : type.types).map((m) => typeToJsonSchema(m, ctx, depth + 1)).filter(isNonEmptySchema);
503
520
  if (schemas.length === 0) return {};
504
521
  const [onlySchema] = schemas;
505
522
  if (schemas.length === 1 && onlySchema !== void 0) return onlySchema;
@@ -559,10 +576,9 @@ function convertArrayType(type, ctx, depth) {
559
576
  }
560
577
  function convertTupleType(type, ctx, depth) {
561
578
  const args = ctx.checker.getTypeArguments(type);
562
- const schemas = args.map((a) => typeToJsonSchema(a, ctx, depth + 1));
563
579
  return {
564
580
  type: "array",
565
- prefixItems: schemas,
581
+ prefixItems: args.map((a) => typeToJsonSchema(a, ctx, depth + 1)),
566
582
  items: false,
567
583
  minItems: args.length,
568
584
  maxItems: args.length
@@ -579,8 +595,7 @@ function convertPlainObject(type, ctx, depth) {
579
595
  };
580
596
  let autoRegName = null;
581
597
  const tsName = getTypeName(type);
582
- const isNamedUnregisteredType = tsName !== null && typeProps.length > 0 && !ctx.typeToRef.has(type);
583
- if (isNamedUnregisteredType) {
598
+ if (tsName !== null && typeProps.length > 0 && !ctx.typeToRef.has(type)) {
584
599
  autoRegName = ensureUniqueName(tsName, ctx.schemas);
585
600
  ctx.typeToRef.set(type, autoRegName);
586
601
  ctx.schemas[autoRegName] = {};
@@ -590,8 +605,7 @@ function convertPlainObject(type, ctx, depth) {
590
605
  const required = [];
591
606
  for (const prop of typeProps) {
592
607
  if (shouldSkipPropertySymbol(prop)) continue;
593
- const propType = checker.getTypeOfSymbol(prop);
594
- const propSchema = typeToJsonSchema(propType, ctx, depth + 1);
608
+ const propSchema = typeToJsonSchema(checker.getTypeOfSymbol(prop), ctx, depth + 1);
595
609
  const jsDoc = getJsDocComment(prop, checker);
596
610
  if (jsDoc && !propSchema.description && !propSchema.$ref) propSchema.description = jsDoc;
597
611
  properties[prop.name] = propSchema;
@@ -620,8 +634,7 @@ function convertObjectType(type, ctx, depth) {
620
634
  /** Core type-to-schema conversion (no ref handling). */
621
635
  function convertTypeToSchema(type, ctx, depth) {
622
636
  if (ctx.visited.has(type)) return handleCyclicRef(type, ctx);
623
- const flags = type.getFlags();
624
- const primitive = convertPrimitiveOrLiteral(type, flags, ctx.checker);
637
+ const primitive = convertPrimitiveOrLiteral(type, type.getFlags(), ctx.checker);
625
638
  if (primitive) return primitive;
626
639
  if (type.isUnion()) {
627
640
  ctx.visited.add(type);
@@ -652,10 +665,8 @@ function getProcedureTypeName(defType, checker) {
652
665
  }
653
666
  function isVoidLikeInput(inputType) {
654
667
  if (!inputType) return true;
655
- const isVoidOrUndefinedOrNever = hasFlag(inputType, typescript.TypeFlags.Void | typescript.TypeFlags.Undefined | typescript.TypeFlags.Never);
656
- if (isVoidOrUndefinedOrNever) return true;
657
- const isUnionOfVoids = inputType.isUnion() && inputType.types.every((t) => hasFlag(t, typescript.TypeFlags.Void | typescript.TypeFlags.Undefined));
658
- return isUnionOfVoids;
668
+ if (hasFlag(inputType, typescript.TypeFlags.Void | typescript.TypeFlags.Undefined | typescript.TypeFlags.Never)) return true;
669
+ return inputType.isUnion() && inputType.types.every((t) => hasFlag(t, typescript.TypeFlags.Void | typescript.TypeFlags.Undefined));
659
670
  }
660
671
  function shouldIncludeProcedureInOpenAPI(type) {
661
672
  return type !== "subscription";
@@ -671,8 +682,7 @@ function getProcedureInputTypeName(type, path) {
671
682
  if (declarationName && !ANONYMOUS_NAMES.has(declarationName) && !declarationName.startsWith("__")) return declarationName;
672
683
  }
673
684
  }
674
- const fallbackName = path.split(".").filter(Boolean).map((segment) => segment.split(/[^A-Za-z0-9]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")).join("");
675
- return `${fallbackName || "Procedure"}Input`;
685
+ return `${path.split(".").filter(Boolean).map((segment) => segment.split(/[^A-Za-z0-9]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")).join("") || "Procedure"}Input`;
676
686
  }
677
687
  function isUnknownLikeType(type) {
678
688
  return hasFlag(type, typescript.TypeFlags.Unknown | typescript.TypeFlags.Any);
@@ -703,14 +713,11 @@ function recoverProcedureInputType(def, checker) {
703
713
  if (callee.name.text !== "input") return;
704
714
  const [parserExpr] = expr.arguments;
705
715
  if (!parserExpr) return;
706
- const parserType = checker.getTypeAtLocation(parserExpr);
707
- const standardSym = parserType.getProperty("~standard");
716
+ const standardSym = checker.getTypeAtLocation(parserExpr).getProperty("~standard");
708
717
  if (!standardSym) return;
709
- const standardType = checker.getTypeOfSymbolAtLocation(standardSym, parserExpr);
710
- const typesSym = standardType.getProperty("types");
718
+ const typesSym = checker.getTypeOfSymbolAtLocation(standardSym, parserExpr).getProperty("types");
711
719
  if (!typesSym) return;
712
- const typesType = checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(typesSym, parserExpr));
713
- const outputSym = typesType.getProperty("output");
720
+ const outputSym = checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(typesSym, parserExpr)).getProperty("output");
714
721
  if (!outputSym) return;
715
722
  const outputType = checker.getTypeOfSymbolAtLocation(outputSym, parserExpr);
716
723
  if (!isUnknownLikeType(outputType)) recovered = outputType;
@@ -766,22 +773,18 @@ function getJsDocComment(sym, checker) {
766
773
  var _sym$declarations2;
767
774
  const normalize = (filePath) => filePath.replace(/\\/g, "/");
768
775
  const declarations = (_sym$declarations2 = sym.declarations) !== null && _sym$declarations2 !== void 0 ? _sym$declarations2 : [];
769
- const isExternalNodeModulesDeclaration = declarations.length > 0 && declarations.every((declaration) => {
776
+ if (declarations.length > 0 && declarations.every((declaration) => {
770
777
  const sourceFile = declaration.getSourceFile();
771
778
  if (!sourceFile.isDeclarationFile) return false;
772
- const declarationPath = normalize(sourceFile.fileName);
773
- if (!declarationPath.includes("/node_modules/")) return false;
779
+ if (!normalize(sourceFile.fileName).includes("/node_modules/")) return false;
774
780
  try {
775
- const realPath = normalize(node_fs.realpathSync.native(sourceFile.fileName));
776
- if (!realPath.includes("/node_modules/")) return false;
781
+ if (!normalize(node_fs.realpathSync.native(sourceFile.fileName)).includes("/node_modules/")) return false;
777
782
  } catch (_unused) {}
778
783
  return true;
779
- });
780
- if (isExternalNodeModulesDeclaration) return void 0;
784
+ })) return;
781
785
  const parts = sym.getDocumentationComment(checker);
782
- if (parts.length === 0) return void 0;
783
- const text = parts.map((p) => p.text).join("");
784
- return text || void 0;
786
+ if (parts.length === 0) return;
787
+ return parts.map((p) => p.text).join("") || void 0;
785
788
  }
786
789
  function walkType(opts) {
787
790
  const { type, ctx, currentPath, description, symbol } = opts;
@@ -812,28 +815,21 @@ function walkType(opts) {
812
815
  }
813
816
  const routerSym = defType.getProperty("router");
814
817
  if (!routerSym) return;
815
- const isRouter = checker.typeToString(checker.getTypeOfSymbol(routerSym)) === "true";
816
- if (!isRouter) return;
818
+ if (!(checker.typeToString(checker.getTypeOfSymbol(routerSym)) === "true")) return;
817
819
  const recordSym = defType.getProperty("record");
818
820
  if (!recordSym) return;
819
821
  ctx.seen.add(type);
820
- const recordType = checker.getTypeOfSymbol(recordSym);
821
- walkRecord(recordType, ctx, currentPath);
822
+ walkRecord(checker.getTypeOfSymbol(recordSym), ctx, currentPath);
822
823
  ctx.seen.delete(type);
823
824
  }
824
825
  function walkRecord(recordType, ctx, prefix) {
825
- for (const prop of recordType.getProperties()) {
826
- const propType = ctx.schemaCtx.checker.getTypeOfSymbol(prop);
827
- const fullPath = prefix ? `${prefix}.${prop.name}` : prop.name;
828
- const description = getJsDocComment(prop, ctx.schemaCtx.checker);
829
- walkType({
830
- type: propType,
831
- ctx,
832
- currentPath: fullPath,
833
- description,
834
- symbol: prop
835
- });
836
- }
826
+ for (const prop of recordType.getProperties()) walkType({
827
+ type: ctx.schemaCtx.checker.getTypeOfSymbol(prop),
828
+ ctx,
829
+ currentPath: prefix ? `${prefix}.${prop.name}` : prop.name,
830
+ description: getJsDocComment(prop, ctx.schemaCtx.checker),
831
+ symbol: prop
832
+ });
837
833
  }
838
834
  function loadCompilerOptions(startDir) {
839
835
  const configPath = typescript.findConfigFile(startDir, (f) => typescript.sys.fileExists(f), "tsconfig.json");
@@ -845,7 +841,7 @@ function loadCompilerOptions(startDir) {
845
841
  };
846
842
  const configFile = typescript.readConfigFile(configPath, (f) => typescript.sys.readFile(f));
847
843
  const parsed = typescript.parseJsonConfigFileContent(configFile.config, typescript.sys, node_path.dirname(configPath));
848
- const options = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, parsed.options), {}, { noEmit: true });
844
+ const options = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, parsed.options), {}, { noEmit: true });
849
845
  if (options.moduleResolution === void 0) {
850
846
  const mod = options.module;
851
847
  if (mod === typescript.ModuleKind.Node16 || mod === typescript.ModuleKind.NodeNext) options.moduleResolution = typescript.ModuleResolutionKind.NodeNext;
@@ -898,19 +894,18 @@ const DEFAULT_ERROR_SCHEMA = {
898
894
  */
899
895
  function wrapInSuccessEnvelope(outputSchema) {
900
896
  const hasOutput = outputSchema !== null && isNonEmptySchema(outputSchema);
901
- const resultSchema = (0, import_objectSpread2.default)({
902
- type: "object",
903
- properties: (0, import_objectSpread2.default)({}, hasOutput ? { data: outputSchema } : {})
904
- }, hasOutput ? { required: ["data"] } : {});
905
897
  return {
906
898
  type: "object",
907
- properties: { result: resultSchema },
899
+ properties: { result: require_objectSpread2._objectSpread2({
900
+ type: "object",
901
+ properties: require_objectSpread2._objectSpread2({}, hasOutput ? { data: outputSchema } : {})
902
+ }, hasOutput ? { required: ["data"] } : {}) },
908
903
  required: ["result"]
909
904
  };
910
905
  }
911
906
  function buildProcedureOperation(proc, method) {
912
907
  const [tag = proc.path] = proc.path.split(".");
913
- const operation = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({ operationId: proc.path }, proc.description ? { description: proc.description } : {}), {}, {
908
+ const operation = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({ operationId: proc.path }, proc.description ? { description: proc.description } : {}), {}, {
914
909
  tags: [tag],
915
910
  responses: {
916
911
  "200": {
@@ -947,7 +942,7 @@ function buildOpenAPIDocument(procedures, options, meta = { errorSchema: null })
947
942
  pathItem[method] = buildProcedureOperation(proc, method);
948
943
  }
949
944
  const hasNamedSchemas = meta.schemas !== void 0 && Object.keys(meta.schemas).length > 0;
950
- return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({
945
+ return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({
951
946
  openapi: "3.1.1",
952
947
  jsonSchemaDialect: "https://spec.openapis.org/oas/3.1/dialect/base",
953
948
  info: {
@@ -956,7 +951,7 @@ function buildOpenAPIDocument(procedures, options, meta = { errorSchema: null })
956
951
  }
957
952
  }, ((_options$servers = options.servers) === null || _options$servers === void 0 ? void 0 : _options$servers.length) ? { servers: options.servers } : {}), {}, {
958
953
  paths,
959
- components: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, hasNamedSchemas && meta.schemas ? { schemas: meta.schemas } : {}), {}, { responses: { Error: {
954
+ components: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, hasNamedSchemas && meta.schemas ? { schemas: meta.schemas } : {}), {}, { responses: { Error: {
960
955
  description: "Error response",
961
956
  content: { "application/json": { schema: {
962
957
  type: "object",
@@ -1020,16 +1015,14 @@ async function generateOpenAPIDocument(routerFilePath, options = {}) {
1020
1015
  schemas: schemaCtx.schemas
1021
1016
  });
1022
1017
  }
1023
-
1024
1018
  //#endregion
1025
1019
  //#region src/types.ts
1026
- var types_exports = {};
1027
-
1020
+ var types_exports = /* @__PURE__ */ __exportAll({});
1028
1021
  //#endregion
1029
- Object.defineProperty(exports, 'OpenAPIV3_1', {
1030
- enumerable: true,
1031
- get: function () {
1032
- return types_exports;
1033
- }
1022
+ Object.defineProperty(exports, "OpenAPIV3_1", {
1023
+ enumerable: true,
1024
+ get: function() {
1025
+ return types_exports;
1026
+ }
1034
1027
  });
1035
- exports.generateOpenAPIDocument = generateOpenAPIDocument;
1028
+ exports.generateOpenAPIDocument = generateOpenAPIDocument;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { OpenAPIV3_1 } from "openapi-types";
2
-
3
- //#region rolldown:runtime
4
2
  declare namespace types_d_exports {
5
3
  export { ArraySchemaObject, CallbackObject, ComponentsObject, DiscriminatorObject, Document, ExampleObject, ExternalDocumentationObject, HeaderObject, HttpMethods, LinkObject, MediaTypeObject, OperationObject, ParameterBaseObject, ParameterObject, PathItemObject, PathsObject, PrimitiveSchemaType, ReferenceObject, Replace, RequestBodyObject, ResponseObject, ResponsesObject, SchemaLike, SchemaObject, SchemaType, SecuritySchemeObject, ServerObject, XMLObject };
6
4
  }
@@ -75,7 +73,7 @@ type OperationObject<T extends {} = {}> = Replace<OpenAPIV3_1.OperationObject<T>
75
73
  }> & T;
76
74
  type PathItemObject<T extends {} = {}> = Replace<OpenAPIV3_1.PathItemObject<T>, {
77
75
  parameters?: (ReferenceObject | ParameterObject)[];
78
- }> & { [method in HttpMethods]?: OperationObject<T> };
76
+ }> & { [method in HttpMethods]?: OperationObject<T>; };
79
77
  type PathsObject<T extends {} = {}, TPath extends {} = {}> = Record<string, (PathItemObject<T> & TPath) | undefined>;
80
78
  type CallbackObject = Record<string, PathItemObject | ReferenceObject>;
81
79
  type ComponentsObject = Replace<OpenAPIV3_1.ComponentsObject, {
@@ -92,7 +90,6 @@ type Document<T extends {} = {}> = Replace<OpenAPIV3_1.Document<T>, {
92
90
  paths?: PathsObject<T>;
93
91
  components?: ComponentsObject;
94
92
  }>;
95
- //# sourceMappingURL=types.d.ts.map
96
93
  //#endregion
97
94
  //#region src/generate.d.ts
98
95
  interface GenerateOptions {
@@ -121,9 +118,7 @@ interface GenerateOptions {
121
118
  * the AppRouter.
122
119
  * @param options - Optional generation settings (export name, title, version).
123
120
  */
124
- declare function generateOpenAPIDocument(routerFilePath: string, options?: GenerateOptions): Promise<Document>;
125
- //# sourceMappingURL=generate.d.ts.map
126
-
121
+ export declare function generateOpenAPIDocument(routerFilePath: string, options?: GenerateOptions): Promise<Document>;
127
122
  //#endregion
128
- export { GenerateOptions, types_d_exports as OpenAPIV3_1, generateOpenAPIDocument };
123
+ export { type GenerateOptions, types_d_exports as OpenAPIV3_1 };
129
124
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/generate.ts"],"sourcesContent":[],"mappings":";;;;;;KAEY,iCAAiC,KAAK,eAAe,gBAC/D;KAEU,UAAA;KASA,mBAAA,GAAsB;KAEtB,WAAA,GAAc,WAAA,CAAgB;KAC9B,eAAA,GAAkB,WAAA,CAAgB;KAClC,aAAA,GAAgB,WAAA,CAAgB;KAChC,mBAAA,GAAsB,WAAA,CAAgB;KACtC,2BAAA,GACV,WA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