@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
@@ -1,90 +1,78 @@
1
- import { isSchemaIssue } from '@orpc/contract';
2
- import { isNonPrimitive } from '@orpc/shared';
3
- import { BracketNotationSerializer } from '../bracket-notation.js';
1
+ import { BracketNotationSerializer } from "../bracket-notation.js";
2
+ import { NON_NEGATIVE_INTEGER_REGEX, isNonPrimitive } from "@orpc/shared";
3
+ import { isSchemaIssue } from "@orpc/contract";
4
+ // src/helpers/form-data.ts
4
5
  /**
5
- * Parse a form data with [bracket notation](https://orpc.dev/docs/openapi/bracket-notation) syntax
6
- *
7
- * @example
8
- * ```ts
9
- * const form = new FormData()
10
- * form.append('a', '1')
11
- * form.append('user[name]', 'John')
12
- * form.append('user[age]', '20')
13
- * form.append('user[friends][]', 'Bob')
14
- * form.append('user[friends][]', 'Alice')
15
- * form.append('user[friends][]', 'Charlie')
16
- * form.append('thumb', new Blob(['hello']), 'thumb.png')
17
- *
18
- * parseFormData(form)
19
- * // {
20
- * // a: '1',
21
- * // user: {
22
- * // name: 'John',
23
- * // age: '20',
24
- * // friends: ['Bob', 'Alice', 'Charlie'],
25
- * // },
26
- * // thumb: form.get('thumb'),
27
- * // }
28
- * ```
29
- *
30
- * @see {@link https://orpc.dev/docs/helpers/form-data#parseformdata | Form Data Helpers - parseFormData}
31
- */
32
- export function parseFormData(form) {
33
- const serializer = new BracketNotationSerializer();
34
- return serializer.deserialize(Array.from(form.entries()));
6
+ * Parse a form data with [bracket notation](https://orpc.dev/docs/openapi/bracket-notation) syntax
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const form = new FormData()
11
+ * form.append('a', '1')
12
+ * form.append('user[name]', 'John')
13
+ * form.append('user[age]', '20')
14
+ * form.append('user[friends][]', 'Bob')
15
+ * form.append('user[friends][]', 'Alice')
16
+ * form.append('user[friends][]', 'Charlie')
17
+ * form.append('thumb', new Blob(['hello']), 'thumb.png')
18
+ *
19
+ * parseFormData(form)
20
+ * // {
21
+ * // a: '1',
22
+ * // user: {
23
+ * // name: 'John',
24
+ * // age: '20',
25
+ * // friends: ['Bob', 'Alice', 'Charlie'],
26
+ * // },
27
+ * // thumb: form.get('thumb'),
28
+ * // }
29
+ * ```
30
+ *
31
+ * @see {@link https://orpc.dev/docs/helpers/form-data#parseformdata | Form Data Helpers - parseFormData}
32
+ */
33
+ function parseFormData(form) {
34
+ return new BracketNotationSerializer().deserialize(Array.from(form.entries()));
35
35
  }
36
36
  /**
37
- * Gets the issue message from the error for a given field path.
38
- *
39
- * @remarks
40
- * **Note**: Requires validation errors to follow the standard schema issue format, stored under `data.issues` — customized validation errors may not be found.
41
- *
42
- * @example
43
- * ```tsx
44
- * const { error, data, execute } = useServerAction(someAction)
45
- *
46
- * return <form action={(form) => execute(parseFormData(form))}>
47
- * <input name="user[name]" type="text" />
48
- * <p>{getIssueMessage(error, 'user[name]')}</p>
49
- *
50
- * <input name="user[age]" type="number" />
51
- * <p>{getIssueMessage(error, 'user[age]')}</p>
52
- *
53
- * <input name="images[]" type="file" />
54
- * <p>{getIssueMessage(error, 'images[]')}</p>
55
- * </form>
56
- * ```
57
- *
58
- * @param error - The error (can be anything) can contain `data.issues` (standard schema issues)
59
- * @param path - The path of the field that has the issue follow [bracket notation](https://orpc.dev/docs/openapi/bracket-notation)
60
- *
61
- * @see {@link https://orpc.dev/docs/helpers/form-data#getissuemessage | Form Data Helpers - getIssueMessage}
62
- */
63
- export function getIssueMessage(error, path) {
64
- if (!isNonPrimitive(error) || !isNonPrimitive(error.data) || !Array.isArray(error.data.issues)) {
65
- return undefined;
66
- }
67
- const serializer = new BracketNotationSerializer();
68
- for (const issue of error.data.issues) {
69
- if (!isSchemaIssue(issue)) {
70
- continue;
71
- }
72
- if (issue.path === undefined) {
73
- if (path === '') {
74
- return issue.message;
75
- }
76
- continue;
77
- }
78
- const issuePath = serializer.stringifyPath(issue.path.map((segment) => typeof segment === 'object' ? segment.key.toString() : segment.toString()));
79
- if (issuePath === path) {
80
- return issue.message;
81
- }
82
- if (path.endsWith('[]') && issuePath.replace(/\[(?:0|[1-9]\d*)\]$/, '[]') === path) {
83
- return issue.message;
84
- }
85
- if (path === '' && /^(?:0|[1-9]\d*)$/.test(issuePath)) {
86
- return issue.message;
87
- }
88
- }
89
- return undefined;
37
+ * Gets the issue message from the error for a given field path.
38
+ *
39
+ * @remarks
40
+ * **Note**: Requires validation errors to follow the standard schema issue format, stored under `data.issues` — customized validation errors may not be found.
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * const { error, data, execute } = useServerAction(someAction)
45
+ *
46
+ * return <form action={(form) => execute(parseFormData(form))}>
47
+ * <input name="user[name]" type="text" />
48
+ * <p>{getIssueMessage(error, 'user[name]')}</p>
49
+ *
50
+ * <input name="user[age]" type="number" />
51
+ * <p>{getIssueMessage(error, 'user[age]')}</p>
52
+ *
53
+ * <input name="images[]" type="file" />
54
+ * <p>{getIssueMessage(error, 'images[]')}</p>
55
+ * </form>
56
+ * ```
57
+ *
58
+ * @param error - The error (can be anything) can contain `data.issues` (standard schema issues)
59
+ * @param path - The path of the field that has the issue follow [bracket notation](https://orpc.dev/docs/openapi/bracket-notation)
60
+ *
61
+ * @see {@link https://orpc.dev/docs/helpers/form-data#getissuemessage | Form Data Helpers - getIssueMessage}
62
+ */
63
+ function getIssueMessage(error, path) {
64
+ if (!isNonPrimitive(error) || !isNonPrimitive(error.data) || !Array.isArray(error.data.issues)) return;
65
+ const serializer = new BracketNotationSerializer();
66
+ for (const issue of error.data.issues) {
67
+ if (!isSchemaIssue(issue)) continue;
68
+ if (issue.path === void 0) {
69
+ if (path === "") return issue.message;
70
+ continue;
71
+ }
72
+ const issuePath = serializer.stringifyPath(issue.path.map((segment) => typeof segment === "object" ? segment.key.toString() : segment.toString()));
73
+ if (issuePath === path) return issue.message;
74
+ if (path.endsWith("[]") && issuePath.replace(/\[(?:0|[1-9]\d*)\]$/, "[]") === path) return issue.message;
75
+ if (path === "" && NON_NEGATIVE_INTEGER_REGEX.test(issuePath)) return issue.message;
76
+ }
90
77
  }
78
+ export { getIssueMessage, parseFormData };
@@ -1 +1,2 @@
1
- export * from './form-data.ts';
1
+ import { getIssueMessage, parseFormData } from "./form-data.js";
2
+ export { getIssueMessage, parseFormData };
@@ -1 +1 @@
1
- export * from './form-data.js';
1
+ export { getIssueMessage, parseFormData } from "./form-data.js";
package/dist/index.d.ts CHANGED
@@ -1,13 +1,15 @@
1
- export * from './bracket-notation.ts';
2
- export * from './client-factory.ts';
3
- export { DEFAULT_OPENAPI_METHOD } from './constants.ts';
4
- export * from './meta.ts';
5
- export * from './openapi-generator.ts';
6
- export * from './openapi-json-serializer.ts';
7
- export * from './openapi-serializer.ts';
8
- export * from './router-utils.ts';
9
- export * from './types.ts';
10
- export { getDynamicPathParams } from './utils.ts';
11
- export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
12
- export type { JsonSchema } from '@orpc/json-schema';
13
- export type { StandardBodyHint } from '@standard-server/core';
1
+ import { BracketNotationSerializeResult, BracketNotationSerializer, BracketNotationSerializerOptions } from "./bracket-notation.js";
2
+ import { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, createContractJsonifiedClientFactory } from "./client-factory.js";
3
+ import { DEFAULT_OPENAPI_METHOD } from "./constants.js";
4
+ import { OpenAPIFunction, OpenAPIMeta, OpenAPIMetaPlugin, OpenAPIMethodMetaPlugin, OpenAPIPathMetaPlugin, OpenAPIPrefixMetaPlugin, OpenAPISpecMetaPlugin, getOpenAPIMeta, openapi } from "./meta.js";
5
+ import { OpenAPIGenerator, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions } from "./openapi-generator.js";
6
+ import { OpenAPIJsonSerialization, OpenAPIJsonSerializer, OpenAPIJsonSerializerHandler, OpenAPIJsonSerializerOptions } from "./openapi-json-serializer.js";
7
+ import { OpenAPISerializer, OpenAPISerializerOptions, OpenAPISerializerSerializeOptions } from "./openapi-serializer.js";
8
+ import { PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths, populateRouterContractOpenAPIPaths } from "./router-utils.js";
9
+ import { OpenAPIErrorBodyDefinition, OpenAPIGeneratorError } from "./openapi-generator-operation.js";
10
+ import { JsonifiedArray, JsonifiedClient, JsonifiedClientError, JsonifiedValue, OpenAPIDocument, OpenAPIV3_0, OpenAPIV3_1, OpenAPIV3_2, OpenAPIVersion } from "./types.js";
11
+ import { getDynamicPathParams } from "./utils.js";
12
+ import { COMMON_ERROR_STATUS_MAP } from "@orpc/client";
13
+ import { JsonSchema } from "@orpc/json-schema";
14
+ import { StandardBodyHint } from "@standard-server/core";
15
+ export { BracketNotationSerializeResult, BracketNotationSerializer, BracketNotationSerializerOptions, COMMON_ERROR_STATUS_MAP, ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, DEFAULT_OPENAPI_METHOD, type JsonSchema, JsonifiedArray, JsonifiedClient, JsonifiedClientError, JsonifiedValue, OpenAPIDocument, type OpenAPIErrorBodyDefinition, OpenAPIFunction, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, OpenAPIJsonSerialization, OpenAPIJsonSerializer, OpenAPIJsonSerializerHandler, OpenAPIJsonSerializerOptions, OpenAPIMeta, OpenAPIMetaPlugin, OpenAPIMethodMetaPlugin, OpenAPIPathMetaPlugin, OpenAPIPrefixMetaPlugin, OpenAPISerializer, OpenAPISerializerOptions, OpenAPISerializerSerializeOptions, OpenAPISpecMetaPlugin, type OpenAPIV3_0, type OpenAPIV3_1, type OpenAPIV3_2, OpenAPIVersion, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths, type StandardBodyHint, createContractJsonifiedClientFactory, getDynamicPathParams, getOpenAPIMeta, openapi, populateRouterContractOpenAPIPaths };
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- export * from './bracket-notation.js';
2
- export * from './client-factory.js';
3
- export { DEFAULT_OPENAPI_METHOD } from './constants.js';
4
- export * from './meta.js';
5
- export * from './openapi-generator.js';
6
- export * from './openapi-json-serializer.js';
7
- export * from './openapi-serializer.js';
8
- export * from './router-utils.js';
9
- export * from './types.js';
10
- export { getDynamicPathParams } from './utils.js';
11
- export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
1
+ export { BracketNotationSerializer } from "./bracket-notation.js";
2
+ export { createContractJsonifiedClientFactory } from "./client-factory.js";
3
+ export { DEFAULT_OPENAPI_METHOD } from "./constants.js";
4
+ export { getOpenAPIMeta, openapi } from "./meta.js";
5
+ export { OpenAPIGenerator } from "./openapi-generator.js";
6
+ export { OpenAPIGeneratorError } from "./openapi-generator-operation.js";
7
+ export { OpenAPIJsonSerializer } from "./openapi-json-serializer.js";
8
+ export { OpenAPISerializer } from "./openapi-serializer.js";
9
+ export { populateRouterContractOpenAPIPaths } from "./router-utils.js";
10
+ export { getDynamicPathParams } from "./utils.js";
11
+ export { COMMON_ERROR_STATUS_MAP } from "@orpc/client";