@orpc/openapi 2.0.0-beta.49 → 2.0.0-beta.50

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 (65) hide show
  1. package/dist/adapters/aws-lambda/index.d.ts +3 -15
  2. package/dist/adapters/aws-lambda/index.js +1 -1
  3. package/dist/adapters/aws-lambda/openapi-handler.d.ts +8 -9
  4. package/dist/adapters/aws-lambda/openapi-handler.js +19 -17
  5. package/dist/adapters/fastify/index.d.ts +2 -1
  6. package/dist/adapters/fastify/index.js +1 -1
  7. package/dist/adapters/fastify/openapi-handler.d.ts +8 -9
  8. package/dist/adapters/fastify/openapi-handler.js +16 -14
  9. package/dist/adapters/fetch/index.d.ts +3 -2
  10. package/dist/adapters/fetch/index.js +2 -2
  11. package/dist/adapters/fetch/openapi-handler.d.ts +8 -9
  12. package/dist/adapters/fetch/openapi-handler.js +16 -14
  13. package/dist/adapters/fetch/openapi-link.d.ts +9 -10
  14. package/dist/adapters/fetch/openapi-link.js +21 -19
  15. package/dist/adapters/node/index.d.ts +2 -1
  16. package/dist/adapters/node/index.js +1 -1
  17. package/dist/adapters/node/openapi-handler.d.ts +8 -9
  18. package/dist/adapters/node/openapi-handler.js +16 -14
  19. package/dist/adapters/standard/index.d.ts +4 -3
  20. package/dist/adapters/standard/index.js +3 -3
  21. package/dist/adapters/standard/openapi-handler-codec.d.ts +56 -57
  22. package/dist/adapters/standard/openapi-handler-codec.js +143 -205
  23. package/dist/adapters/standard/openapi-link-codec.d.ts +55 -59
  24. package/dist/adapters/standard/openapi-link-codec.js +262 -377
  25. package/dist/adapters/standard/openapi-matcher.d.ts +26 -26
  26. package/dist/adapters/standard/openapi-matcher.js +78 -108
  27. package/dist/adapters/standard/utils.js +28 -44
  28. package/dist/bracket-notation.d.ts +22 -22
  29. package/dist/bracket-notation.js +123 -173
  30. package/dist/client-factory.d.ts +12 -12
  31. package/dist/client-factory.js +13 -11
  32. package/dist/constants.d.ts +1 -4
  33. package/dist/constants.js +5 -4
  34. package/dist/extensions/route.d.ts +36 -36
  35. package/dist/extensions/route.js +7 -6
  36. package/dist/helpers/form-data.d.ts +1 -1
  37. package/dist/helpers/form-data.js +74 -86
  38. package/dist/helpers/index.d.ts +2 -1
  39. package/dist/helpers/index.js +1 -1
  40. package/dist/index.d.ts +15 -13
  41. package/dist/index.js +11 -11
  42. package/dist/meta.d.ts +298 -298
  43. package/dist/meta.js +54 -72
  44. package/dist/openapi-generator-components.d.ts +2 -31
  45. package/dist/openapi-generator-components.js +200 -248
  46. package/dist/openapi-generator-operation.d.ts +12 -33
  47. package/dist/openapi-generator-operation.js +369 -437
  48. package/dist/openapi-generator.d.ts +75 -80
  49. package/dist/openapi-generator.js +114 -142
  50. package/dist/openapi-json-serializer.d.ts +65 -65
  51. package/dist/openapi-json-serializer.js +218 -257
  52. package/dist/openapi-serializer.d.ts +31 -32
  53. package/dist/openapi-serializer.js +68 -92
  54. package/dist/plugins/index.d.ts +2 -1
  55. package/dist/plugins/index.js +1 -1
  56. package/dist/plugins/openapi-reference.d.ts +99 -102
  57. package/dist/plugins/openapi-reference.js +109 -132
  58. package/dist/router-utils.d.ts +7 -10
  59. package/dist/router-utils.js +30 -34
  60. package/dist/types.d.ts +8 -12
  61. package/dist/utils.d.ts +5 -10
  62. package/dist/utils.js +39 -42
  63. package/package.json +12 -12
  64. package/dist/adapters/standard/utils.d.ts +0 -4
  65. package/dist/types.js +0 -1
package/dist/meta.js CHANGED
@@ -1,84 +1,66 @@
1
- import { mergeHttpPath } from '@orpc/shared';
1
+ import { mergeHttpPath } from "@orpc/shared";
2
+ // src/meta.ts
2
3
  /**
3
- * Creates OpenAPI meta plugins that control how a procedure is exposed over HTTP,
4
- * such as its method, path, prefix, and OpenAPI operation spec.
5
- *
6
- * @see {@link https://orpc.dev/docs/openapi/routing | OpenAPI Routing}
7
- * @see {@link https://orpc.dev/docs/openapi/specification | OpenAPI Specification}
8
- */
9
- export const openapi = (incoming) => ({
10
- name: '~openapi',
11
- init(meta) {
12
- const existing = meta['~openapi'];
13
- const tags = existing?.tags && incoming.tags
14
- ? [...existing.tags, ...incoming.tags]
15
- : 'tags' in incoming
16
- ? incoming.tags
17
- : existing?.tags;
18
- const queryStyles = existing?.queryStyles && incoming.queryStyles
19
- ? { ...existing.queryStyles, ...incoming.queryStyles }
20
- : 'queryStyles' in incoming
21
- ? incoming.queryStyles
22
- : existing?.queryStyles;
23
- const paramsStyles = existing?.paramsStyles && incoming.paramsStyles
24
- ? { ...existing.paramsStyles, ...incoming.paramsStyles }
25
- : 'paramsStyles' in incoming
26
- ? incoming.paramsStyles
27
- : existing?.paramsStyles;
28
- const existingSpec = existing?.spec;
29
- const incomingSpec = incoming.spec;
30
- // AVOID a function spec, it requires the current spec as an argument, triggering an extra auto-generation step.
31
- const spec = typeof existingSpec === 'function' && typeof incomingSpec === 'function'
32
- ? (current) => incomingSpec(existingSpec(current))
33
- : typeof existingSpec === 'function' && typeof incomingSpec === 'object'
34
- ? existingSpec(incomingSpec)
35
- : typeof existingSpec === 'object' && typeof incomingSpec === 'function'
36
- ? incomingSpec(existingSpec)
37
- : 'spec' in incoming
38
- ? incomingSpec
39
- : existingSpec;
40
- const prefix = existing?.prefix && incoming.prefix
41
- ? mergeHttpPath(existing.prefix, incoming.prefix)
42
- : 'prefix' in incoming
43
- ? incoming.prefix
44
- : existing?.prefix;
45
- // TODO: throw if incoming.path missing dynamic from existing.path
46
- const merged = {
47
- ...existing,
48
- ...incoming,
49
- tags,
50
- queryStyles,
51
- paramsStyles,
52
- spec,
53
- prefix,
54
- };
55
- return {
56
- ...meta,
57
- '~openapi': merged,
58
- };
59
- },
4
+ * Creates OpenAPI meta plugins that control how a procedure is exposed over HTTP,
5
+ * such as its method, path, prefix, and OpenAPI operation spec.
6
+ *
7
+ * @see {@link https://orpc.dev/docs/openapi/routing | OpenAPI Routing}
8
+ * @see {@link https://orpc.dev/docs/openapi/specification | OpenAPI Specification}
9
+ */
10
+ const openapi = (incoming) => ({
11
+ name: "~openapi",
12
+ init(meta) {
13
+ const existing = meta["~openapi"];
14
+ const tags = existing?.tags && incoming.tags ? [...existing.tags, ...incoming.tags] : "tags" in incoming ? incoming.tags : existing?.tags;
15
+ const queryStyles = existing?.queryStyles && incoming.queryStyles ? {
16
+ ...existing.queryStyles,
17
+ ...incoming.queryStyles
18
+ } : "queryStyles" in incoming ? incoming.queryStyles : existing?.queryStyles;
19
+ const paramsStyles = existing?.paramsStyles && incoming.paramsStyles ? {
20
+ ...existing.paramsStyles,
21
+ ...incoming.paramsStyles
22
+ } : "paramsStyles" in incoming ? incoming.paramsStyles : existing?.paramsStyles;
23
+ const existingSpec = existing?.spec;
24
+ const incomingSpec = incoming.spec;
25
+ const spec = typeof existingSpec === "function" && typeof incomingSpec === "function" ? (current) => incomingSpec(existingSpec(current)) : typeof existingSpec === "function" && typeof incomingSpec === "object" ? existingSpec(incomingSpec) : typeof existingSpec === "object" && typeof incomingSpec === "function" ? incomingSpec(existingSpec) : "spec" in incoming ? incomingSpec : existingSpec;
26
+ const prefix = existing?.prefix && incoming.prefix ? mergeHttpPath(existing.prefix, incoming.prefix) : "prefix" in incoming ? incoming.prefix : existing?.prefix;
27
+ const merged = {
28
+ ...existing,
29
+ ...incoming,
30
+ tags,
31
+ queryStyles,
32
+ paramsStyles,
33
+ spec,
34
+ prefix
35
+ };
36
+ return {
37
+ ...meta,
38
+ "~openapi": merged
39
+ };
40
+ }
60
41
  });
61
42
  openapi.method = (method) => ({
62
- ...openapi({ method }),
63
- name: '~openapi/method',
43
+ ...openapi({ method }),
44
+ name: "~openapi/method"
64
45
  });
65
46
  openapi.path = (path) => ({
66
- ...openapi({ path }),
67
- name: '~openapi/path',
47
+ ...openapi({ path }),
48
+ name: "~openapi/path"
68
49
  });
69
50
  openapi.spec = (spec) => ({
70
- ...openapi({ spec }),
71
- name: '~openapi/spec',
51
+ ...openapi({ spec }),
52
+ name: "~openapi/spec"
72
53
  });
73
54
  openapi.prefix = (prefix) => ({
74
- ...openapi({ prefix }),
75
- name: '~openapi/prefix',
55
+ ...openapi({ prefix }),
56
+ name: "~openapi/prefix"
76
57
  });
77
58
  /**
78
- * Retrieves the OpenAPI metadata attached to a procedure or router, or `undefined` if not set.
79
- *
80
- * @see {@link https://orpc.dev/docs/rpc/handler#enabling-the-get-method | RPC Handler - Enabling the GET Method}
81
- */
82
- export function getOpenAPIMeta(procedureOrLazy) {
83
- return procedureOrLazy['~orpc'].meta['~openapi'];
59
+ * Retrieves the OpenAPI metadata attached to a procedure or router, or `undefined` if not set.
60
+ *
61
+ * @see {@link https://orpc.dev/docs/rpc/handler#enabling-the-get-method | RPC Handler - Enabling the GET Method}
62
+ */
63
+ function getOpenAPIMeta(procedureOrLazy) {
64
+ return procedureOrLazy["~orpc"].meta["~openapi"];
84
65
  }
66
+ export { getOpenAPIMeta, openapi };
@@ -1,31 +1,2 @@
1
- import type { JsonSchema, JsonSchemaConverterDirection } from '@orpc/json-schema';
2
- import type { OpenAPIV3_2 } from './types.ts';
3
- /**
4
- * Collects reusable schemas into `doc.components.schemas`.
5
- *
6
- * Equivalent schemas (including recursive ones) reuse a single component, and different
7
- * schemas competing for the same name get direction-suffixed or numbered postfixes.
8
- */
9
- export declare class OpenAPIComponentRegistry {
10
- private readonly doc;
11
- private readonly componentName;
12
- /**
13
- * The unsanitized name each minted component was requested under, so distinct names
14
- * that sanitize to the same key (`User Profile`, `User_Profile`) are never merged.
15
- * Components the registry did not mint are reusable only when the requested name needs
16
- * no sanitizing, which keeps `base.components` family reuse (`Planet`, `Planet2`) intact.
17
- */
18
- private readonly componentSources;
19
- constructor(doc: OpenAPIV3_2.OpenAPIObject, componentName: ((defName: string, defSchema: JsonSchema) => string) | undefined);
20
- /**
21
- * Registers `schema` as a component under `preferredName` (or an equivalent/postfixed name)
22
- * and returns a `$ref` to it.
23
- */
24
- register(preferredName: string, schema: Exclude<JsonSchema, boolean>): JsonSchema;
25
- /**
26
- * Moves a schema's root-level `$defs` into `doc.components.schemas` and rewrites
27
- * its refs accordingly.
28
- */
29
- hoistDefs(schema: JsonSchema, direction?: JsonSchemaConverterDirection): JsonSchema;
30
- toOpenAPISchema(schema: JsonSchema, direction?: JsonSchemaConverterDirection): OpenAPIV3_2.SchemaObject;
31
- }
1
+ import "./types.js";
2
+ import "@orpc/json-schema";