@epcc-sdk/sdks-files 0.0.3 → 0.2.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.
Files changed (121) hide show
  1. package/README.md +37 -6
  2. package/dist/client/client/client.gen.cjs +229 -0
  3. package/dist/client/client/client.gen.cjs.map +1 -0
  4. package/dist/client/client/client.gen.d.cts +10 -0
  5. package/dist/client/client/client.gen.d.ts +10 -0
  6. package/dist/client/client/client.gen.mjs +213 -0
  7. package/dist/client/client/client.gen.mjs.map +1 -0
  8. package/dist/client/client/index.cjs +47 -0
  9. package/dist/client/client/index.cjs.map +1 -0
  10. package/dist/client/client/index.d.cts +9 -0
  11. package/dist/client/client/index.d.ts +9 -0
  12. package/dist/client/client/index.mjs +20 -0
  13. package/dist/client/client/index.mjs.map +1 -0
  14. package/dist/client/client/types.gen.cjs +17 -0
  15. package/dist/client/client/types.gen.cjs.map +1 -0
  16. package/dist/client/client/types.gen.d.cts +6 -0
  17. package/dist/client/client/types.gen.d.ts +6 -0
  18. package/dist/client/client/types.gen.mjs +1 -0
  19. package/dist/client/client/types.gen.mjs.map +1 -0
  20. package/dist/client/client/utils.gen.cjs +263 -0
  21. package/dist/client/client/utils.gen.cjs.map +1 -0
  22. package/dist/client/client/utils.gen.d.cts +6 -0
  23. package/dist/client/client/utils.gen.d.ts +6 -0
  24. package/dist/client/client/utils.gen.mjs +237 -0
  25. package/dist/client/client/utils.gen.mjs.map +1 -0
  26. package/dist/client/client.gen.cjs +34 -0
  27. package/dist/client/client.gen.cjs.map +1 -0
  28. package/dist/client/client.gen.d.cts +20 -0
  29. package/dist/client/client.gen.d.ts +20 -0
  30. package/dist/client/client.gen.mjs +13 -0
  31. package/dist/client/client.gen.mjs.map +1 -0
  32. package/dist/client/core/auth.gen.cjs +41 -0
  33. package/dist/client/core/auth.gen.cjs.map +1 -0
  34. package/dist/client/core/auth.gen.d.cts +27 -0
  35. package/dist/client/core/auth.gen.d.ts +27 -0
  36. package/dist/client/core/auth.gen.mjs +17 -0
  37. package/dist/client/core/auth.gen.mjs.map +1 -0
  38. package/dist/client/core/bodySerializer.gen.cjs +86 -0
  39. package/dist/client/core/bodySerializer.gen.cjs.map +1 -0
  40. package/dist/client/core/bodySerializer.gen.d.cts +27 -0
  41. package/dist/client/core/bodySerializer.gen.d.ts +27 -0
  42. package/dist/client/core/bodySerializer.gen.mjs +60 -0
  43. package/dist/client/core/bodySerializer.gen.mjs.map +1 -0
  44. package/dist/client/core/params.gen.cjs +128 -0
  45. package/dist/client/core/params.gen.cjs.map +1 -0
  46. package/dist/client/core/params.gen.d.cts +44 -0
  47. package/dist/client/core/params.gen.d.ts +44 -0
  48. package/dist/client/core/params.gen.mjs +104 -0
  49. package/dist/client/core/params.gen.mjs.map +1 -0
  50. package/dist/client/core/pathSerializer.gen.cjs +164 -0
  51. package/dist/client/core/pathSerializer.gen.cjs.map +1 -0
  52. package/dist/client/core/pathSerializer.gen.d.cts +34 -0
  53. package/dist/client/core/pathSerializer.gen.d.ts +34 -0
  54. package/dist/client/core/pathSerializer.gen.mjs +135 -0
  55. package/dist/client/core/pathSerializer.gen.mjs.map +1 -0
  56. package/dist/client/core/queryKeySerializer.gen.cjs +109 -0
  57. package/dist/client/core/queryKeySerializer.gen.cjs.map +1 -0
  58. package/dist/client/core/queryKeySerializer.gen.d.cts +20 -0
  59. package/dist/client/core/queryKeySerializer.gen.d.ts +20 -0
  60. package/dist/client/core/queryKeySerializer.gen.mjs +83 -0
  61. package/dist/client/core/queryKeySerializer.gen.mjs.map +1 -0
  62. package/dist/client/core/serverSentEvents.gen.cjs +162 -0
  63. package/dist/client/core/serverSentEvents.gen.cjs.map +1 -0
  64. package/dist/client/core/serverSentEvents.gen.d.cts +77 -0
  65. package/dist/client/core/serverSentEvents.gen.d.ts +77 -0
  66. package/dist/client/core/serverSentEvents.gen.mjs +138 -0
  67. package/dist/client/core/serverSentEvents.gen.mjs.map +1 -0
  68. package/dist/client/core/types.gen.cjs +17 -0
  69. package/dist/client/core/types.gen.cjs.map +1 -0
  70. package/dist/client/core/types.gen.d.cts +86 -0
  71. package/dist/client/core/types.gen.d.ts +86 -0
  72. package/dist/client/core/types.gen.mjs +1 -0
  73. package/dist/client/core/types.gen.mjs.map +1 -0
  74. package/dist/client/core/utils.gen.cjs +136 -0
  75. package/dist/client/core/utils.gen.cjs.map +1 -0
  76. package/dist/client/core/utils.gen.d.cts +23 -0
  77. package/dist/client/core/utils.gen.d.ts +23 -0
  78. package/dist/client/core/utils.gen.mjs +113 -0
  79. package/dist/client/core/utils.gen.mjs.map +1 -0
  80. package/dist/client/index.cjs +15 -5
  81. package/dist/client/index.cjs.map +1 -1
  82. package/dist/client/index.d.cts +8 -3
  83. package/dist/client/index.d.ts +8 -3
  84. package/dist/client/index.mjs +12 -2
  85. package/dist/client/index.mjs.map +1 -1
  86. package/dist/client/sdk.gen.cjs +27 -57
  87. package/dist/client/sdk.gen.cjs.map +1 -1
  88. package/dist/client/sdk.gen.d.cts +29 -17
  89. package/dist/client/sdk.gen.d.ts +29 -17
  90. package/dist/client/sdk.gen.mjs +27 -58
  91. package/dist/client/sdk.gen.mjs.map +1 -1
  92. package/dist/client/types.gen.cjs.map +1 -1
  93. package/dist/client/types.gen.d.cts +6 -3
  94. package/dist/client/types.gen.d.ts +6 -3
  95. package/dist/client/zod.gen.cjs +165 -0
  96. package/dist/client/zod.gen.cjs.map +1 -0
  97. package/dist/client/zod.gen.d.cts +906 -0
  98. package/dist/client/zod.gen.d.ts +906 -0
  99. package/dist/client/zod.gen.mjs +122 -0
  100. package/dist/client/zod.gen.mjs.map +1 -0
  101. package/dist/index.cjs +32 -4
  102. package/dist/index.cjs.map +1 -1
  103. package/dist/index.d.cts +12 -3
  104. package/dist/index.d.ts +12 -3
  105. package/dist/index.mjs +30 -3
  106. package/dist/index.mjs.map +1 -1
  107. package/dist/runtime.cjs +33 -0
  108. package/dist/runtime.cjs.map +1 -0
  109. package/dist/runtime.d.cts +12 -0
  110. package/dist/runtime.d.ts +12 -0
  111. package/dist/runtime.mjs +9 -0
  112. package/dist/runtime.mjs.map +1 -0
  113. package/dist/types.gen-DXwTHYA3.d.ts +157 -0
  114. package/dist/types.gen-mB6gWg8u.d.cts +157 -0
  115. package/dist/zod.cjs +23 -0
  116. package/dist/zod.cjs.map +1 -0
  117. package/dist/zod.d.cts +2 -0
  118. package/dist/zod.d.ts +2 -0
  119. package/dist/zod.mjs +2 -0
  120. package/dist/zod.mjs.map +1 -0
  121. package/package.json +36 -7
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var client_gen_exports = {};
20
+ __export(client_gen_exports, {
21
+ client: () => client
22
+ });
23
+ module.exports = __toCommonJS(client_gen_exports);
24
+ var import_client = require('./client/index.cjs');
25
+ const client = (0, import_client.createClient)(
26
+ (0, import_client.createConfig)({
27
+ baseUrl: "https://euwest.api.elasticpath.com"
28
+ })
29
+ );
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ client
33
+ });
34
+ //# sourceMappingURL=client.gen.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/client.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport {\n type Client,\n type ClientOptions,\n type Config,\n createClient,\n createConfig,\n} from \"./client\"\nimport type { ClientOptions as ClientOptions2 } from \"./types.gen\"\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (\n override?: Config<ClientOptions & T>,\n) => Config<Required<ClientOptions> & T>\n\nexport const client: Client = createClient(\n createConfig<ClientOptions2>({\n baseUrl: \"https://euwest.api.elasticpath.com\",\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAMO;AAeA,MAAM,aAAiB;AAAA,MAC5B,4BAA6B;AAAA,IAC3B,SAAS;AAAA,EACX,CAAC;AACH;","names":[]}
@@ -0,0 +1,20 @@
1
+ import { d as ClientOptions, a as Config, C as Client } from '../types.gen-mB6gWg8u.cjs';
2
+ import { ClientOptions as ClientOptions$1 } from './types.gen.cjs';
3
+ import './core/auth.gen.cjs';
4
+ import './core/serverSentEvents.gen.cjs';
5
+ import './core/types.gen.cjs';
6
+ import './core/bodySerializer.gen.cjs';
7
+ import './core/pathSerializer.gen.cjs';
8
+
9
+ /**
10
+ * The `createClientConfig()` function will be called on client initialization
11
+ * and the returned object will become the client's initial configuration.
12
+ *
13
+ * You may want to initialize your client this way instead of calling
14
+ * `setConfig()`. This is useful for example if you're using Next.js
15
+ * to ensure your client always has the correct values.
16
+ */
17
+ type CreateClientConfig<T extends ClientOptions = ClientOptions$1> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
18
+ declare const client: Client;
19
+
20
+ export { type CreateClientConfig, client };
@@ -0,0 +1,20 @@
1
+ import { d as ClientOptions, a as Config, C as Client } from '../types.gen-DXwTHYA3.js';
2
+ import { ClientOptions as ClientOptions$1 } from './types.gen.js';
3
+ import './core/auth.gen.js';
4
+ import './core/serverSentEvents.gen.js';
5
+ import './core/types.gen.js';
6
+ import './core/bodySerializer.gen.js';
7
+ import './core/pathSerializer.gen.js';
8
+
9
+ /**
10
+ * The `createClientConfig()` function will be called on client initialization
11
+ * and the returned object will become the client's initial configuration.
12
+ *
13
+ * You may want to initialize your client this way instead of calling
14
+ * `setConfig()`. This is useful for example if you're using Next.js
15
+ * to ensure your client always has the correct values.
16
+ */
17
+ type CreateClientConfig<T extends ClientOptions = ClientOptions$1> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
18
+ declare const client: Client;
19
+
20
+ export { type CreateClientConfig, client };
@@ -0,0 +1,13 @@
1
+ import {
2
+ createClient,
3
+ createConfig
4
+ } from "./client/index.mjs";
5
+ const client = createClient(
6
+ createConfig({
7
+ baseUrl: "https://euwest.api.elasticpath.com"
8
+ })
9
+ );
10
+ export {
11
+ client
12
+ };
13
+ //# sourceMappingURL=client.gen.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/client.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport {\n type Client,\n type ClientOptions,\n type Config,\n createClient,\n createConfig,\n} from \"./client\"\nimport type { ClientOptions as ClientOptions2 } from \"./types.gen\"\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (\n override?: Config<ClientOptions & T>,\n) => Config<Required<ClientOptions> & T>\n\nexport const client: Client = createClient(\n createConfig<ClientOptions2>({\n baseUrl: \"https://euwest.api.elasticpath.com\",\n }),\n)\n"],"mappings":"AAEA;AAAA,EAIE;AAAA,EACA;AAAA,OACK;AAeA,MAAM,SAAiB;AAAA,EAC5B,aAA6B;AAAA,IAC3B,SAAS;AAAA,EACX,CAAC;AACH;","names":[]}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var auth_gen_exports = {};
20
+ __export(auth_gen_exports, {
21
+ getAuthToken: () => getAuthToken
22
+ });
23
+ module.exports = __toCommonJS(auth_gen_exports);
24
+ const getAuthToken = async (auth, callback) => {
25
+ const token = typeof callback === "function" ? await callback(auth) : callback;
26
+ if (!token) {
27
+ return;
28
+ }
29
+ if (auth.scheme === "bearer") {
30
+ return `Bearer ${token}`;
31
+ }
32
+ if (auth.scheme === "basic") {
33
+ return `Basic ${btoa(token)}`;
34
+ }
35
+ return token;
36
+ };
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ getAuthToken
40
+ });
41
+ //# sourceMappingURL=auth.gen.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/core/auth.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nexport type AuthToken = string | undefined\n\nexport interface Auth {\n /**\n * Which part of the request do we use to send the auth?\n *\n * @default 'header'\n */\n in?: \"header\" | \"query\" | \"cookie\"\n /**\n * A unique identifier for the security scheme.\n *\n * Defined only when there are multiple security schemes whose `Auth`\n * shape would otherwise be identical.\n */\n key?: string\n /**\n * Header or query parameter name.\n *\n * @default 'Authorization'\n */\n name?: string\n scheme?: \"basic\" | \"bearer\"\n type: \"apiKey\" | \"http\"\n}\n\nexport const getAuthToken = async (\n auth: Auth,\n callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,\n): Promise<string | undefined> => {\n const token = typeof callback === \"function\" ? await callback(auth) : callback\n\n if (!token) {\n return\n }\n\n if (auth.scheme === \"bearer\") {\n return `Bearer ${token}`\n }\n\n if (auth.scheme === \"basic\") {\n return `Basic ${btoa(token)}`\n }\n\n return token\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BO,MAAM,eAAe,OAC1B,MACA,aACgC;AAChC,QAAM,QAAQ,OAAO,aAAa,aAAa,MAAM,SAAS,IAAI,IAAI;AAEtE,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAEA,MAAI,KAAK,WAAW,UAAU;AAC5B,WAAO,UAAU,KAAK;AAAA,EACxB;AAEA,MAAI,KAAK,WAAW,SAAS;AAC3B,WAAO,SAAS,KAAK,KAAK,CAAC;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,27 @@
1
+ type AuthToken = string | undefined;
2
+ interface Auth {
3
+ /**
4
+ * Which part of the request do we use to send the auth?
5
+ *
6
+ * @default 'header'
7
+ */
8
+ in?: "header" | "query" | "cookie";
9
+ /**
10
+ * A unique identifier for the security scheme.
11
+ *
12
+ * Defined only when there are multiple security schemes whose `Auth`
13
+ * shape would otherwise be identical.
14
+ */
15
+ key?: string;
16
+ /**
17
+ * Header or query parameter name.
18
+ *
19
+ * @default 'Authorization'
20
+ */
21
+ name?: string;
22
+ scheme?: "basic" | "bearer";
23
+ type: "apiKey" | "http";
24
+ }
25
+ declare const getAuthToken: (auth: Auth, callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken) => Promise<string | undefined>;
26
+
27
+ export { type Auth, type AuthToken, getAuthToken };
@@ -0,0 +1,27 @@
1
+ type AuthToken = string | undefined;
2
+ interface Auth {
3
+ /**
4
+ * Which part of the request do we use to send the auth?
5
+ *
6
+ * @default 'header'
7
+ */
8
+ in?: "header" | "query" | "cookie";
9
+ /**
10
+ * A unique identifier for the security scheme.
11
+ *
12
+ * Defined only when there are multiple security schemes whose `Auth`
13
+ * shape would otherwise be identical.
14
+ */
15
+ key?: string;
16
+ /**
17
+ * Header or query parameter name.
18
+ *
19
+ * @default 'Authorization'
20
+ */
21
+ name?: string;
22
+ scheme?: "basic" | "bearer";
23
+ type: "apiKey" | "http";
24
+ }
25
+ declare const getAuthToken: (auth: Auth, callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken) => Promise<string | undefined>;
26
+
27
+ export { type Auth, type AuthToken, getAuthToken };
@@ -0,0 +1,17 @@
1
+ const getAuthToken = async (auth, callback) => {
2
+ const token = typeof callback === "function" ? await callback(auth) : callback;
3
+ if (!token) {
4
+ return;
5
+ }
6
+ if (auth.scheme === "bearer") {
7
+ return `Bearer ${token}`;
8
+ }
9
+ if (auth.scheme === "basic") {
10
+ return `Basic ${btoa(token)}`;
11
+ }
12
+ return token;
13
+ };
14
+ export {
15
+ getAuthToken
16
+ };
17
+ //# sourceMappingURL=auth.gen.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/core/auth.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nexport type AuthToken = string | undefined\n\nexport interface Auth {\n /**\n * Which part of the request do we use to send the auth?\n *\n * @default 'header'\n */\n in?: \"header\" | \"query\" | \"cookie\"\n /**\n * A unique identifier for the security scheme.\n *\n * Defined only when there are multiple security schemes whose `Auth`\n * shape would otherwise be identical.\n */\n key?: string\n /**\n * Header or query parameter name.\n *\n * @default 'Authorization'\n */\n name?: string\n scheme?: \"basic\" | \"bearer\"\n type: \"apiKey\" | \"http\"\n}\n\nexport const getAuthToken = async (\n auth: Auth,\n callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,\n): Promise<string | undefined> => {\n const token = typeof callback === \"function\" ? await callback(auth) : callback\n\n if (!token) {\n return\n }\n\n if (auth.scheme === \"bearer\") {\n return `Bearer ${token}`\n }\n\n if (auth.scheme === \"basic\") {\n return `Basic ${btoa(token)}`\n }\n\n return token\n}\n"],"mappings":"AA4BO,MAAM,eAAe,OAC1B,MACA,aACgC;AAChC,QAAM,QAAQ,OAAO,aAAa,aAAa,MAAM,SAAS,IAAI,IAAI;AAEtE,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAEA,MAAI,KAAK,WAAW,UAAU;AAC5B,WAAO,UAAU,KAAK;AAAA,EACxB;AAEA,MAAI,KAAK,WAAW,SAAS;AAC3B,WAAO,SAAS,KAAK,KAAK,CAAC;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var bodySerializer_gen_exports = {};
20
+ __export(bodySerializer_gen_exports, {
21
+ formDataBodySerializer: () => formDataBodySerializer,
22
+ jsonBodySerializer: () => jsonBodySerializer,
23
+ urlSearchParamsBodySerializer: () => urlSearchParamsBodySerializer
24
+ });
25
+ module.exports = __toCommonJS(bodySerializer_gen_exports);
26
+ const serializeFormDataPair = (data, key, value) => {
27
+ if (typeof value === "string" || value instanceof Blob) {
28
+ data.append(key, value);
29
+ } else if (value instanceof Date) {
30
+ data.append(key, value.toISOString());
31
+ } else {
32
+ data.append(key, JSON.stringify(value));
33
+ }
34
+ };
35
+ const serializeUrlSearchParamsPair = (data, key, value) => {
36
+ if (typeof value === "string") {
37
+ data.append(key, value);
38
+ } else {
39
+ data.append(key, JSON.stringify(value));
40
+ }
41
+ };
42
+ const formDataBodySerializer = {
43
+ bodySerializer: (body) => {
44
+ const data = new FormData();
45
+ Object.entries(body).forEach(([key, value]) => {
46
+ if (value === void 0 || value === null) {
47
+ return;
48
+ }
49
+ if (Array.isArray(value)) {
50
+ value.forEach((v) => serializeFormDataPair(data, key, v));
51
+ } else {
52
+ serializeFormDataPair(data, key, value);
53
+ }
54
+ });
55
+ return data;
56
+ }
57
+ };
58
+ const jsonBodySerializer = {
59
+ bodySerializer: (body) => JSON.stringify(
60
+ body,
61
+ (_key, value) => typeof value === "bigint" ? value.toString() : value
62
+ )
63
+ };
64
+ const urlSearchParamsBodySerializer = {
65
+ bodySerializer: (body) => {
66
+ const data = new URLSearchParams();
67
+ Object.entries(body).forEach(([key, value]) => {
68
+ if (value === void 0 || value === null) {
69
+ return;
70
+ }
71
+ if (Array.isArray(value)) {
72
+ value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
73
+ } else {
74
+ serializeUrlSearchParamsPair(data, key, value);
75
+ }
76
+ });
77
+ return data.toString();
78
+ }
79
+ };
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ formDataBodySerializer,
83
+ jsonBodySerializer,
84
+ urlSearchParamsBodySerializer
85
+ });
86
+ //# sourceMappingURL=bodySerializer.gen.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/core/bodySerializer.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n ArrayStyle,\n ObjectStyle,\n SerializerOptions,\n} from \"./pathSerializer.gen\"\n\nexport type QuerySerializer = (query: Record<string, unknown>) => string\n\nexport type BodySerializer = (body: unknown) => unknown\n\ntype QuerySerializerOptionsObject = {\n allowReserved?: boolean\n array?: Partial<SerializerOptions<ArrayStyle>>\n object?: Partial<SerializerOptions<ObjectStyle>>\n}\n\nexport type QuerySerializerOptions = QuerySerializerOptionsObject & {\n /**\n * Per-parameter serialization overrides. When provided, these settings\n * override the global array/object settings for specific parameter names.\n */\n parameters?: Record<string, QuerySerializerOptionsObject>\n}\n\nconst serializeFormDataPair = (\n data: FormData,\n key: string,\n value: unknown,\n): void => {\n if (typeof value === \"string\" || value instanceof Blob) {\n data.append(key, value)\n } else if (value instanceof Date) {\n data.append(key, value.toISOString())\n } else {\n data.append(key, JSON.stringify(value))\n }\n}\n\nconst serializeUrlSearchParamsPair = (\n data: URLSearchParams,\n key: string,\n value: unknown,\n): void => {\n if (typeof value === \"string\") {\n data.append(key, value)\n } else {\n data.append(key, JSON.stringify(value))\n }\n}\n\nexport const formDataBodySerializer = {\n bodySerializer: (body: unknown): FormData => {\n const data = new FormData()\n\n Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {\n if (value === undefined || value === null) {\n return\n }\n if (Array.isArray(value)) {\n value.forEach((v) => serializeFormDataPair(data, key, v))\n } else {\n serializeFormDataPair(data, key, value)\n }\n })\n\n return data\n },\n}\n\nexport const jsonBodySerializer = {\n bodySerializer: (body: unknown): string =>\n JSON.stringify(body, (_key, value) =>\n typeof value === \"bigint\" ? value.toString() : value,\n ),\n}\n\nexport const urlSearchParamsBodySerializer = {\n bodySerializer: (body: unknown): string => {\n const data = new URLSearchParams()\n\n Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {\n if (value === undefined || value === null) {\n return\n }\n if (Array.isArray(value)) {\n value.forEach((v) => serializeUrlSearchParamsPair(data, key, v))\n } else {\n serializeUrlSearchParamsPair(data, key, value)\n }\n })\n\n return data.toString()\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BA,MAAM,wBAAwB,CAC5B,MACA,KACA,UACS;AACT,MAAI,OAAO,UAAU,YAAY,iBAAiB,MAAM;AACtD,SAAK,OAAO,KAAK,KAAK;AAAA,EACxB,WAAW,iBAAiB,MAAM;AAChC,SAAK,OAAO,KAAK,MAAM,YAAY,CAAC;AAAA,EACtC,OAAO;AACL,SAAK,OAAO,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACxC;AACF;AAEA,MAAM,+BAA+B,CACnC,MACA,KACA,UACS;AACT,MAAI,OAAO,UAAU,UAAU;AAC7B,SAAK,OAAO,KAAK,KAAK;AAAA,EACxB,OAAO;AACL,SAAK,OAAO,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACxC;AACF;AAEO,MAAM,yBAAyB;AAAA,EACpC,gBAAgB,CAAC,SAA4B;AAC3C,UAAM,OAAO,IAAI,SAAS;AAE1B,WAAO,QAAQ,IAA+B,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACxE,UAAI,UAAU,UAAa,UAAU,MAAM;AACzC;AAAA,MACF;AACA,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,cAAM,QAAQ,CAAC,MAAM,sBAAsB,MAAM,KAAK,CAAC,CAAC;AAAA,MAC1D,OAAO;AACL,8BAAsB,MAAM,KAAK,KAAK;AAAA,MACxC;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;AAEO,MAAM,qBAAqB;AAAA,EAChC,gBAAgB,CAAC,SACf,KAAK;AAAA,IAAU;AAAA,IAAM,CAAC,MAAM,UAC1B,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI;AAAA,EACjD;AACJ;AAEO,MAAM,gCAAgC;AAAA,EAC3C,gBAAgB,CAAC,SAA0B;AACzC,UAAM,OAAO,IAAI,gBAAgB;AAEjC,WAAO,QAAQ,IAA+B,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACxE,UAAI,UAAU,UAAa,UAAU,MAAM;AACzC;AAAA,MACF;AACA,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,cAAM,QAAQ,CAAC,MAAM,6BAA6B,MAAM,KAAK,CAAC,CAAC;AAAA,MACjE,OAAO;AACL,qCAA6B,MAAM,KAAK,KAAK;AAAA,MAC/C;AAAA,IACF,CAAC;AAED,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;","names":[]}
@@ -0,0 +1,27 @@
1
+ import { SerializerOptions, ArrayStyle, ObjectStyle } from './pathSerializer.gen.cjs';
2
+
3
+ type QuerySerializer = (query: Record<string, unknown>) => string;
4
+ type BodySerializer = (body: unknown) => unknown;
5
+ type QuerySerializerOptionsObject = {
6
+ allowReserved?: boolean;
7
+ array?: Partial<SerializerOptions<ArrayStyle>>;
8
+ object?: Partial<SerializerOptions<ObjectStyle>>;
9
+ };
10
+ type QuerySerializerOptions = QuerySerializerOptionsObject & {
11
+ /**
12
+ * Per-parameter serialization overrides. When provided, these settings
13
+ * override the global array/object settings for specific parameter names.
14
+ */
15
+ parameters?: Record<string, QuerySerializerOptionsObject>;
16
+ };
17
+ declare const formDataBodySerializer: {
18
+ bodySerializer: (body: unknown) => FormData;
19
+ };
20
+ declare const jsonBodySerializer: {
21
+ bodySerializer: (body: unknown) => string;
22
+ };
23
+ declare const urlSearchParamsBodySerializer: {
24
+ bodySerializer: (body: unknown) => string;
25
+ };
26
+
27
+ export { type BodySerializer, type QuerySerializer, type QuerySerializerOptions, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
@@ -0,0 +1,27 @@
1
+ import { SerializerOptions, ArrayStyle, ObjectStyle } from './pathSerializer.gen.js';
2
+
3
+ type QuerySerializer = (query: Record<string, unknown>) => string;
4
+ type BodySerializer = (body: unknown) => unknown;
5
+ type QuerySerializerOptionsObject = {
6
+ allowReserved?: boolean;
7
+ array?: Partial<SerializerOptions<ArrayStyle>>;
8
+ object?: Partial<SerializerOptions<ObjectStyle>>;
9
+ };
10
+ type QuerySerializerOptions = QuerySerializerOptionsObject & {
11
+ /**
12
+ * Per-parameter serialization overrides. When provided, these settings
13
+ * override the global array/object settings for specific parameter names.
14
+ */
15
+ parameters?: Record<string, QuerySerializerOptionsObject>;
16
+ };
17
+ declare const formDataBodySerializer: {
18
+ bodySerializer: (body: unknown) => FormData;
19
+ };
20
+ declare const jsonBodySerializer: {
21
+ bodySerializer: (body: unknown) => string;
22
+ };
23
+ declare const urlSearchParamsBodySerializer: {
24
+ bodySerializer: (body: unknown) => string;
25
+ };
26
+
27
+ export { type BodySerializer, type QuerySerializer, type QuerySerializerOptions, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
@@ -0,0 +1,60 @@
1
+ const serializeFormDataPair = (data, key, value) => {
2
+ if (typeof value === "string" || value instanceof Blob) {
3
+ data.append(key, value);
4
+ } else if (value instanceof Date) {
5
+ data.append(key, value.toISOString());
6
+ } else {
7
+ data.append(key, JSON.stringify(value));
8
+ }
9
+ };
10
+ const serializeUrlSearchParamsPair = (data, key, value) => {
11
+ if (typeof value === "string") {
12
+ data.append(key, value);
13
+ } else {
14
+ data.append(key, JSON.stringify(value));
15
+ }
16
+ };
17
+ const formDataBodySerializer = {
18
+ bodySerializer: (body) => {
19
+ const data = new FormData();
20
+ Object.entries(body).forEach(([key, value]) => {
21
+ if (value === void 0 || value === null) {
22
+ return;
23
+ }
24
+ if (Array.isArray(value)) {
25
+ value.forEach((v) => serializeFormDataPair(data, key, v));
26
+ } else {
27
+ serializeFormDataPair(data, key, value);
28
+ }
29
+ });
30
+ return data;
31
+ }
32
+ };
33
+ const jsonBodySerializer = {
34
+ bodySerializer: (body) => JSON.stringify(
35
+ body,
36
+ (_key, value) => typeof value === "bigint" ? value.toString() : value
37
+ )
38
+ };
39
+ const urlSearchParamsBodySerializer = {
40
+ bodySerializer: (body) => {
41
+ const data = new URLSearchParams();
42
+ Object.entries(body).forEach(([key, value]) => {
43
+ if (value === void 0 || value === null) {
44
+ return;
45
+ }
46
+ if (Array.isArray(value)) {
47
+ value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
48
+ } else {
49
+ serializeUrlSearchParamsPair(data, key, value);
50
+ }
51
+ });
52
+ return data.toString();
53
+ }
54
+ };
55
+ export {
56
+ formDataBodySerializer,
57
+ jsonBodySerializer,
58
+ urlSearchParamsBodySerializer
59
+ };
60
+ //# sourceMappingURL=bodySerializer.gen.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/core/bodySerializer.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type {\n ArrayStyle,\n ObjectStyle,\n SerializerOptions,\n} from \"./pathSerializer.gen\"\n\nexport type QuerySerializer = (query: Record<string, unknown>) => string\n\nexport type BodySerializer = (body: unknown) => unknown\n\ntype QuerySerializerOptionsObject = {\n allowReserved?: boolean\n array?: Partial<SerializerOptions<ArrayStyle>>\n object?: Partial<SerializerOptions<ObjectStyle>>\n}\n\nexport type QuerySerializerOptions = QuerySerializerOptionsObject & {\n /**\n * Per-parameter serialization overrides. When provided, these settings\n * override the global array/object settings for specific parameter names.\n */\n parameters?: Record<string, QuerySerializerOptionsObject>\n}\n\nconst serializeFormDataPair = (\n data: FormData,\n key: string,\n value: unknown,\n): void => {\n if (typeof value === \"string\" || value instanceof Blob) {\n data.append(key, value)\n } else if (value instanceof Date) {\n data.append(key, value.toISOString())\n } else {\n data.append(key, JSON.stringify(value))\n }\n}\n\nconst serializeUrlSearchParamsPair = (\n data: URLSearchParams,\n key: string,\n value: unknown,\n): void => {\n if (typeof value === \"string\") {\n data.append(key, value)\n } else {\n data.append(key, JSON.stringify(value))\n }\n}\n\nexport const formDataBodySerializer = {\n bodySerializer: (body: unknown): FormData => {\n const data = new FormData()\n\n Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {\n if (value === undefined || value === null) {\n return\n }\n if (Array.isArray(value)) {\n value.forEach((v) => serializeFormDataPair(data, key, v))\n } else {\n serializeFormDataPair(data, key, value)\n }\n })\n\n return data\n },\n}\n\nexport const jsonBodySerializer = {\n bodySerializer: (body: unknown): string =>\n JSON.stringify(body, (_key, value) =>\n typeof value === \"bigint\" ? value.toString() : value,\n ),\n}\n\nexport const urlSearchParamsBodySerializer = {\n bodySerializer: (body: unknown): string => {\n const data = new URLSearchParams()\n\n Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {\n if (value === undefined || value === null) {\n return\n }\n if (Array.isArray(value)) {\n value.forEach((v) => serializeUrlSearchParamsPair(data, key, v))\n } else {\n serializeUrlSearchParamsPair(data, key, value)\n }\n })\n\n return data.toString()\n },\n}\n"],"mappings":"AA0BA,MAAM,wBAAwB,CAC5B,MACA,KACA,UACS;AACT,MAAI,OAAO,UAAU,YAAY,iBAAiB,MAAM;AACtD,SAAK,OAAO,KAAK,KAAK;AAAA,EACxB,WAAW,iBAAiB,MAAM;AAChC,SAAK,OAAO,KAAK,MAAM,YAAY,CAAC;AAAA,EACtC,OAAO;AACL,SAAK,OAAO,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACxC;AACF;AAEA,MAAM,+BAA+B,CACnC,MACA,KACA,UACS;AACT,MAAI,OAAO,UAAU,UAAU;AAC7B,SAAK,OAAO,KAAK,KAAK;AAAA,EACxB,OAAO;AACL,SAAK,OAAO,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACxC;AACF;AAEO,MAAM,yBAAyB;AAAA,EACpC,gBAAgB,CAAC,SAA4B;AAC3C,UAAM,OAAO,IAAI,SAAS;AAE1B,WAAO,QAAQ,IAA+B,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACxE,UAAI,UAAU,UAAa,UAAU,MAAM;AACzC;AAAA,MACF;AACA,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,cAAM,QAAQ,CAAC,MAAM,sBAAsB,MAAM,KAAK,CAAC,CAAC;AAAA,MAC1D,OAAO;AACL,8BAAsB,MAAM,KAAK,KAAK;AAAA,MACxC;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;AAEO,MAAM,qBAAqB;AAAA,EAChC,gBAAgB,CAAC,SACf,KAAK;AAAA,IAAU;AAAA,IAAM,CAAC,MAAM,UAC1B,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI;AAAA,EACjD;AACJ;AAEO,MAAM,gCAAgC;AAAA,EAC3C,gBAAgB,CAAC,SAA0B;AACzC,UAAM,OAAO,IAAI,gBAAgB;AAEjC,WAAO,QAAQ,IAA+B,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACxE,UAAI,UAAU,UAAa,UAAU,MAAM;AACzC;AAAA,MACF;AACA,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,cAAM,QAAQ,CAAC,MAAM,6BAA6B,MAAM,KAAK,CAAC,CAAC;AAAA,MACjE,OAAO;AACL,qCAA6B,MAAM,KAAK,KAAK;AAAA,MAC/C;AAAA,IACF,CAAC;AAED,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;","names":[]}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var params_gen_exports = {};
20
+ __export(params_gen_exports, {
21
+ buildClientParams: () => buildClientParams
22
+ });
23
+ module.exports = __toCommonJS(params_gen_exports);
24
+ const extraPrefixesMap = {
25
+ $body_: "body",
26
+ $headers_: "headers",
27
+ $path_: "path",
28
+ $query_: "query"
29
+ };
30
+ const extraPrefixes = Object.entries(extraPrefixesMap);
31
+ function buildKeyMap(fields, map) {
32
+ if (!map) {
33
+ map = /* @__PURE__ */ new Map();
34
+ }
35
+ for (const config of fields) {
36
+ if ("in" in config) {
37
+ if (config.key) {
38
+ map.set(config.key, {
39
+ in: config.in,
40
+ map: config.map
41
+ });
42
+ }
43
+ } else if ("key" in config) {
44
+ map.set(config.key, {
45
+ map: config.map
46
+ });
47
+ } else if (config.args) {
48
+ buildKeyMap(config.args, map);
49
+ }
50
+ }
51
+ return map;
52
+ }
53
+ function stripEmptySlots(params) {
54
+ for (const [slot, value] of Object.entries(params)) {
55
+ if (slot === "body") continue;
56
+ if (value && typeof value === "object" && !Array.isArray(value) && !Object.keys(value).length) {
57
+ delete params[slot];
58
+ }
59
+ }
60
+ }
61
+ function buildClientParams(args, fields) {
62
+ const params = {
63
+ headers: /* @__PURE__ */ Object.create(null),
64
+ path: /* @__PURE__ */ Object.create(null),
65
+ query: /* @__PURE__ */ Object.create(null)
66
+ };
67
+ const map = buildKeyMap(fields);
68
+ function writeSlot(slot, key, value) {
69
+ let record = params[slot];
70
+ if (record === void 0) {
71
+ record = /* @__PURE__ */ Object.create(null);
72
+ params[slot] = record;
73
+ }
74
+ record[key] = value;
75
+ }
76
+ let config;
77
+ for (const [index, arg] of args.entries()) {
78
+ if (fields[index]) {
79
+ config = fields[index];
80
+ }
81
+ if (!config) {
82
+ continue;
83
+ }
84
+ if ("in" in config) {
85
+ if (config.key) {
86
+ const field = map.get(config.key);
87
+ const name = field.map || config.key;
88
+ if (field.in) {
89
+ writeSlot(field.in, name, arg);
90
+ }
91
+ } else {
92
+ params.body = arg;
93
+ }
94
+ } else {
95
+ for (const [key, value] of Object.entries(arg ?? {})) {
96
+ const field = map.get(key);
97
+ if (field) {
98
+ if (field.in) {
99
+ const name = field.map || key;
100
+ writeSlot(field.in, name, value);
101
+ } else {
102
+ params[field.map] = value;
103
+ }
104
+ } else {
105
+ const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
106
+ if (extra) {
107
+ const [prefix, slot] = extra;
108
+ writeSlot(slot, key.slice(prefix.length), value);
109
+ } else if ("allowExtra" in config && config.allowExtra) {
110
+ for (const [slot, allowed] of Object.entries(config.allowExtra)) {
111
+ if (allowed) {
112
+ writeSlot(slot, key, value);
113
+ break;
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ stripEmptySlots(params);
122
+ return params;
123
+ }
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ buildClientParams
127
+ });
128
+ //# sourceMappingURL=params.gen.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/core/params.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\ntype Slot = \"body\" | \"headers\" | \"path\" | \"query\"\n\nexport type Field =\n | {\n in: Exclude<Slot, \"body\">\n /**\n * Field name. This is the name we want the user to see and use.\n */\n key: string\n /**\n * Field mapped name. This is the name we want to use in the request.\n * If omitted, we use the same value as `key`.\n */\n map?: string\n }\n | {\n in: Extract<Slot, \"body\">\n /**\n * Key isn't required for bodies.\n */\n key?: string\n map?: string\n }\n | {\n /**\n * Field name. This is the name we want the user to see and use.\n */\n key: string\n /**\n * Field mapped name. This is the name we want to use in the request.\n * If `in` is omitted, `map` aliases `key` to the transport layer.\n */\n map: Slot\n }\n\nexport interface Fields {\n allowExtra?: Partial<Record<Slot, boolean>>\n args?: ReadonlyArray<Field>\n}\n\nexport type FieldsConfig = ReadonlyArray<Field | Fields>\n\nconst extraPrefixesMap: Record<string, Slot> = {\n $body_: \"body\",\n $headers_: \"headers\",\n $path_: \"path\",\n $query_: \"query\",\n}\nconst extraPrefixes = Object.entries(extraPrefixesMap)\n\ntype KeyMap = Map<\n string,\n | {\n in: Slot\n map?: string\n }\n | {\n in?: never\n map: Slot\n }\n>\n\nfunction buildKeyMap(fields: FieldsConfig, map?: KeyMap): KeyMap {\n if (!map) {\n map = new Map()\n }\n\n for (const config of fields) {\n if (\"in\" in config) {\n if (config.key) {\n map.set(config.key, {\n in: config.in,\n map: config.map,\n })\n }\n } else if (\"key\" in config) {\n map.set(config.key, {\n map: config.map,\n })\n } else if (config.args) {\n buildKeyMap(config.args, map)\n }\n }\n\n return map\n}\n\ninterface Params {\n body?: unknown\n headers: Record<string, unknown>\n path: Record<string, unknown>\n query: Record<string, unknown>\n}\n\nfunction stripEmptySlots(params: Params): void {\n for (const [slot, value] of Object.entries(params)) {\n if (slot === \"body\") continue\n if (\n value &&\n typeof value === \"object\" &&\n !Array.isArray(value) &&\n !Object.keys(value).length\n ) {\n delete params[slot as Slot]\n }\n }\n}\n\nexport function buildClientParams(\n args: ReadonlyArray<unknown>,\n fields: FieldsConfig,\n): Params {\n const params: Params = {\n headers: Object.create(null),\n path: Object.create(null),\n query: Object.create(null),\n }\n\n const map = buildKeyMap(fields)\n\n function writeSlot(slot: Slot, key: string, value: unknown): void {\n let record = params[slot] as Record<string, unknown> | undefined\n if (record === undefined) {\n record = Object.create(null) as Record<string, unknown>\n params[slot] = record\n }\n record[key] = value\n }\n\n let config: FieldsConfig[number] | undefined\n\n for (const [index, arg] of args.entries()) {\n if (fields[index]) {\n config = fields[index]\n }\n\n if (!config) {\n continue\n }\n\n if (\"in\" in config) {\n if (config.key) {\n const field = map.get(config.key)!\n const name = field.map || config.key\n if (field.in) {\n writeSlot(field.in, name, arg)\n }\n } else {\n params.body = arg\n }\n } else {\n for (const [key, value] of Object.entries(arg ?? {})) {\n const field = map.get(key)\n\n if (field) {\n if (field.in) {\n const name = field.map || key\n writeSlot(field.in, name, value)\n } else {\n params[field.map] = value\n }\n } else {\n const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix))\n\n if (extra) {\n const [prefix, slot] = extra\n writeSlot(slot, key.slice(prefix.length), value)\n } else if (\"allowExtra\" in config && config.allowExtra) {\n for (const [slot, allowed] of Object.entries(config.allowExtra)) {\n if (allowed) {\n writeSlot(slot as Slot, key, value)\n break\n }\n }\n }\n }\n }\n }\n }\n\n stripEmptySlots(params)\n\n return params\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,44 @@
1
+ type Slot = "body" | "headers" | "path" | "query";
2
+ type Field = {
3
+ in: Exclude<Slot, "body">;
4
+ /**
5
+ * Field name. This is the name we want the user to see and use.
6
+ */
7
+ key: string;
8
+ /**
9
+ * Field mapped name. This is the name we want to use in the request.
10
+ * If omitted, we use the same value as `key`.
11
+ */
12
+ map?: string;
13
+ } | {
14
+ in: Extract<Slot, "body">;
15
+ /**
16
+ * Key isn't required for bodies.
17
+ */
18
+ key?: string;
19
+ map?: string;
20
+ } | {
21
+ /**
22
+ * Field name. This is the name we want the user to see and use.
23
+ */
24
+ key: string;
25
+ /**
26
+ * Field mapped name. This is the name we want to use in the request.
27
+ * If `in` is omitted, `map` aliases `key` to the transport layer.
28
+ */
29
+ map: Slot;
30
+ };
31
+ interface Fields {
32
+ allowExtra?: Partial<Record<Slot, boolean>>;
33
+ args?: ReadonlyArray<Field>;
34
+ }
35
+ type FieldsConfig = ReadonlyArray<Field | Fields>;
36
+ interface Params {
37
+ body?: unknown;
38
+ headers: Record<string, unknown>;
39
+ path: Record<string, unknown>;
40
+ query: Record<string, unknown>;
41
+ }
42
+ declare function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params;
43
+
44
+ export { type Field, type Fields, type FieldsConfig, buildClientParams };