@unshared/client 0.2.0 → 0.2.2

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 (47) hide show
  1. package/dist/chunks/{wF9C7mO0.js → B5hc73Po.js} +16 -24
  2. package/dist/chunks/B5hc73Po.js.map +1 -0
  3. package/dist/chunks/{BIx2AaJH.d.ts → BsMghIPi.d.ts} +12 -14
  4. package/dist/chunks/CKfJvIQ8.js +50 -0
  5. package/dist/chunks/CKfJvIQ8.js.map +1 -0
  6. package/dist/chunks/Cx8m1YzL.cjs +49 -0
  7. package/dist/chunks/Cx8m1YzL.cjs.map +1 -0
  8. package/dist/chunks/D-WqCFul.js +30 -0
  9. package/dist/chunks/D-WqCFul.js.map +1 -0
  10. package/dist/chunks/{C3RyfPUw.cjs → D8Tsm7xC.cjs} +16 -24
  11. package/dist/chunks/D8Tsm7xC.cjs.map +1 -0
  12. package/dist/chunks/{B0duX_ls.d.ts → DZp6zyqV.d.ts} +13 -4
  13. package/dist/chunks/r8pYO6Hx.d.ts +38 -0
  14. package/dist/chunks/xRZPkxch.cjs +29 -0
  15. package/dist/chunks/xRZPkxch.cjs.map +1 -0
  16. package/dist/createClient.cjs +8 -11
  17. package/dist/createClient.cjs.map +1 -1
  18. package/dist/createClient.d.ts +8 -7
  19. package/dist/createClient.js +8 -10
  20. package/dist/createClient.js.map +1 -1
  21. package/dist/fetch.cjs +2 -2
  22. package/dist/fetch.cjs.map +1 -1
  23. package/dist/fetch.d.ts +5 -1
  24. package/dist/fetch.js +2 -2
  25. package/dist/fetch.js.map +1 -1
  26. package/dist/index.cjs +12 -9
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.ts +5 -3
  29. package/dist/index.js +15 -11
  30. package/dist/index.js.map +1 -1
  31. package/dist/openapi.cjs +45 -7
  32. package/dist/openapi.cjs.map +1 -1
  33. package/dist/openapi.d.ts +5 -5
  34. package/dist/openapi.js +43 -5
  35. package/dist/openapi.js.map +1 -1
  36. package/dist/utils.cjs +4 -1
  37. package/dist/utils.cjs.map +1 -1
  38. package/dist/utils.d.ts +17 -3
  39. package/dist/utils.js +6 -2
  40. package/dist/utils.js.map +1 -1
  41. package/package.json +4 -3
  42. package/dist/chunks/BzqHK4CV.cjs +0 -71
  43. package/dist/chunks/BzqHK4CV.cjs.map +0 -1
  44. package/dist/chunks/C3RyfPUw.cjs.map +0 -1
  45. package/dist/chunks/CRISqhP7.js +0 -72
  46. package/dist/chunks/CRISqhP7.js.map +0 -1
  47. package/dist/chunks/wF9C7mO0.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xRZPkxch.cjs","sources":["../../openapi/getBaseUrl.ts","../../openapi/getOperationById.ts"],"sourcesContent":["import type { OpenAPI } from 'openapi-types'\n\n/**\n * Given an OpenAPI specification, get the first base URL.\n *\n * @param specification The OpenAPI specification.\n * @returns The first base URL.\n * @example getBaseUrl(specification) // 'https://api.example.com/v1'\n */\nexport function getBaseUrl(specification: OpenAPI.Document): string {\n\n // --- Handle OpenAPI 3.0 specifications.\n if ('servers' in specification && Array.isArray(specification.servers) && specification.servers.length > 0)\n return specification.servers[0].url\n\n // --- Handle OpenAPI 2.0 specifications.\n if ('host' in specification && typeof specification.host === 'string') {\n const scheme = specification.schemes && specification.schemes.length > 0 ? specification.schemes[0] : 'https'\n const basePath = specification.basePath && typeof specification.basePath === 'string' ? specification.basePath : '/'\n return `${scheme}://${specification.host}${basePath}`\n }\n\n throw new Error('No base URL found in the OpenAPI specification.')\n}\n","import type { OpenAPI } from 'openapi-types'\nimport type { OpenAPIV2 } from './OpenApiV2'\n\n/** The HTTP methods supported by OpenAPI. */\nconst methods = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch'] as const\n\n/**\n * Given an OpenAPI specification, find an operation by its operationId.\n *\n * @param specification The OpenAPI specification.\n * @param operationId The operationId of the operation to resolve.\n * @returns The resolved operation.\n * @example openapiGetOperation(specification, 'getUser') // { method: 'get', path: '/users/{username}', ... }\n */\nexport function getOperationById<T, U extends OpenAPIV2.OperationId<T>>(\n specification: T,\n operationId: U,\n): OpenAPIV2.OperationById<T, U> {\n\n // --- Validate the specification.\n if (!specification\n || typeof specification !== 'object'\n || specification === null\n || 'paths' in specification === false\n || typeof specification.paths !== 'object'\n || specification.paths === null)\n throw new Error('Missing paths object in the OpenAPI specification.')\n\n // --- Search for the operation in the specification's paths.\n const paths = specification.paths as OpenAPI.Document['paths']\n for (const path in paths) {\n const route = paths[path]\n if (typeof route !== 'object' || route === null) continue\n\n // --- Search in each method for the operation.\n for (const method of methods) {\n const operation = route[method]\n if (method in route === false\n || typeof operation !== 'object'\n || operation === null\n || 'operationId' in operation === false\n || operation.operationId !== operationId) continue\n\n // --- Route was found, return the operation.\n return { ...route[method], method, path } as OpenAPIV2.OperationById<T, U>\n }\n }\n\n // --- Throw an error if the operation was not found.\n throw new Error(`Operation \"${operationId}\" not found in specification.`)\n}\n"],"names":[],"mappings":";AASO,SAAS,WAAW,eAAyC;AAG9D,MAAA,aAAa,iBAAiB,MAAM,QAAQ,cAAc,OAAO,KAAK,cAAc,QAAQ,SAAS;AAChG,WAAA,cAAc,QAAQ,CAAC,EAAE;AAGlC,MAAI,UAAU,iBAAiB,OAAO,cAAc,QAAS,UAAU;AAC/D,UAAA,SAAS,cAAc,WAAW,cAAc,QAAQ,SAAS,IAAI,cAAc,QAAQ,CAAC,IAAI,SAChG,WAAW,cAAc,YAAY,OAAO,cAAc,YAAa,WAAW,cAAc,WAAW;AACjH,WAAO,GAAG,MAAM,MAAM,cAAc,IAAI,GAAG,QAAQ;AAAA,EAAA;AAG/C,QAAA,IAAI,MAAM,iDAAiD;AACnE;ACnBA,MAAM,UAAU,CAAC,OAAO,OAAO,QAAQ,UAAU,WAAW,QAAQ,OAAO;AAU3D,SAAA,iBACd,eACA,aAC+B;AAG/B,MAAI,CAAC,iBACA,OAAO,iBAAkB,YACzB,kBAAkB,QAClB,EAAW,WAAA,kBACX,OAAO,cAAc,SAAU,YAC/B,cAAc,UAAU;AACrB,UAAA,IAAI,MAAM,oDAAoD;AAGtE,QAAM,QAAQ,cAAc;AAC5B,aAAW,QAAQ,OAAO;AAClB,UAAA,QAAQ,MAAM,IAAI;AACpB,QAAA,EAAA,OAAO,SAAU,YAAY,UAAU;AAG3C,iBAAW,UAAU,SAAS;AACtB,cAAA,YAAY,MAAM,MAAM;AAC1B,YAAA,EAAA,EAAA,UAAU,UACT,OAAO,aAAc,YACrB,cAAc,QACd,EAAA,iBAAiB,cACjB,UAAU,gBAAgB;AAG/B,iBAAO,EAAE,GAAG,MAAM,MAAM,GAAG,QAAQ,KAAK;AAAA,MAAA;AAAA,EAC1C;AAIF,QAAM,IAAI,MAAM,cAAc,WAAW,+BAA+B;AAC1E;;;"}
@@ -1,25 +1,22 @@
1
1
  "use strict";
2
- var fetch = require("./fetch.cjs"), index = require("./chunks/BzqHK4CV.cjs");
3
- require("./chunks/C3RyfPUw.cjs");
2
+ var fetch = require("./fetch.cjs"), getOperationById = require("./chunks/xRZPkxch.cjs"), handleResponse = require("./chunks/Cx8m1YzL.cjs");
3
+ require("./chunks/D8Tsm7xC.cjs");
4
+ require("@unshared/functions/awaitable");
4
5
  function createClient(documentOrUrl, initialOptions = {}) {
5
6
  const specifications = typeof documentOrUrl == "string" ? void 0 : documentOrUrl;
7
+ typeof documentOrUrl == "string" && (initialOptions.baseUrl = documentOrUrl);
6
8
  async function fetchByOperationId(operationId, options) {
7
9
  if (!specifications) throw new Error("No OpenAPI specification provided.");
8
- const operation = index.getOperationById(specifications, operationId);
10
+ const operation = getOperationById.getOperationById(specifications, operationId);
9
11
  if (!operation) throw new Error(`Operation ID "${operationId}" not found.`);
10
- const { method, path, responses = {} } = operation, response = await fetch.fetch(path, {
11
- method,
12
- baseUrl: index.getBaseUrl(specifications),
13
- ...initialOptions,
14
- ...options
15
- });
16
- if (response.ok) return response.json();
12
+ const { method, path, responses = {} } = operation, fetchOptions = { method, baseUrl: getOperationById.getBaseUrl(specifications), ...initialOptions, ...options }, response = await fetch.fetch(path, fetchOptions);
13
+ if (response.ok) return handleResponse.handleResponse(response, fetchOptions);
17
14
  const status = response.status.toString();
18
15
  throw status in responses && typeof responses[status] == "object" && responses[status] !== null && "description" in responses[status] && typeof responses[status].description == "string" ? new Error(responses[status].description) : new Error(response.statusText);
19
16
  }
20
17
  return new Proxy({}, {
21
18
  get(_, property) {
22
- return property === "fetch" ? fetch.fetch : (options) => fetchByOperationId(property, options);
19
+ return property === "fetch" ? (route, options) => fetch.fetch(route, { ...initialOptions, ...options }) : (options) => fetchByOperationId(property, options);
23
20
  }
24
21
  });
25
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createClient.cjs","sources":["../createClient.ts"],"sourcesContent":["import type { MaybeLiteral, Override, Pretty } from '@unshared/types'\nimport type { OpenAPI, OpenAPIV2 as V2, OpenAPIV3 as V3, OpenAPIV3_1 as V3_1 } from 'openapi-types'\nimport type { RequestOptions } from './utils/index'\nimport { fetch } from './fetch'\nimport { getOperationById } from './openapi/getOperationById'\nimport { getBaseUrl, type OpenAPIV2, type OpenAPIV3 } from './openapi/index'\n\ntype ClientBaseUrl<T> =\n MaybeLiteral<\n T extends V2.Document ? OpenAPIV2.ServerUrl<T>\n : T extends V3.Document ? OpenAPIV3.ServerUrl<T>\n : T extends V3_1.Document ? OpenAPIV3.ServerUrl<T>\n : string\n >\n\ntype ClientFetch<T> =\n T extends V2.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV2.RequestInit<OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV2.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : T extends V3.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : T extends V3_1.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : typeof globalThis.fetch\n\ntype ClientFetchOperation<T, U extends OpenAPIV2.OperationId<T>> =\n T extends V2.Document ? (options: OpenAPIV2.RequestInit<OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV2.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : T extends V3.Document ? (options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : T extends V3_1.Document ? (options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : (options: RequestOptions) => Promise<Response>\n\nexport type Client<T = OpenAPI.Document> =\n Pretty<\n & { [K in OpenAPIV2.OperationId<T>]: ClientFetchOperation<T, K> }\n & { fetch: ClientFetch<T> }\n >\n\nexport type ClientOptions<T = any> = Pretty<Override<RequestOptions, {\n baseUrl?: ClientBaseUrl<T>\n\n /**\n * The headers to include in every request made by the client.\n *\n * @example { 'Authorization': 'Bearer ...' }\n */\n headers?: T extends V3.Document\n ? OpenAPIV3.ServerHeaders<T>\n : Record<string, string>\n}>>\n\n/**\n * Create a new client instance for the given OpenAPI specification.\n *\n * @param document The OpenAPI specification document.\n * @param initialOptions The initial options to use for every request.\n * @returns The client instance.\n * @example\n * const client = createClient(document)\n * await client.fetch({ ... })\n */\n// @ts-expect-error: `ClientOptions` is not assignable to `ClientOptions<T>`.\nexport function createClient<T extends OpenAPI.Document>(document: Readonly<T>, initialOptions?: ClientOptions<T>): Client<T>\nexport function createClient<T extends OpenAPI.Document>(url: ClientBaseUrl<T>, initialOptions?: ClientOptions<T>): Client<T>\nexport function createClient(documentOrUrl: Readonly<OpenAPI.Document> | string, initialOptions: ClientOptions = {}): Client {\n const specifications = typeof documentOrUrl === 'string' ? undefined : documentOrUrl\n\n async function fetchByOperationId(operationId: string, options: ClientOptions<any>) {\n if (!specifications) throw new Error('No OpenAPI specification provided.')\n const operation = getOperationById(specifications, operationId) as { method: string; path: string } & OpenAPI.Operation\n if (!operation) throw new Error(`Operation ID \"${operationId}\" not found.`)\n const { method, path, responses = {} } = operation\n const response = await fetch(path, {\n method,\n baseUrl: getBaseUrl(specifications),\n ...initialOptions,\n ...options,\n })\n\n // --- Return the JSON response if successful.\n if (response.ok) return response.json() as Promise<unknown>\n\n // --- Throw an error if the response was not successful.\n const status = response.status.toString()\n if (status in responses\n && typeof responses[status] === 'object'\n && responses[status] !== null\n && 'description' in responses[status]\n && typeof responses[status].description === 'string')\n throw new Error(responses[status].description)\n\n // --- Throw a generic error if the response was not successful.\n throw new Error(response.statusText)\n }\n\n return new Proxy({}, {\n get(_, property: string) {\n if (property === 'fetch') return fetch\n return (options: Record<string, unknown>) => fetchByOperationId(property, options)\n },\n }) as unknown as Client\n}\n"],"names":["getOperationById","fetch","getBaseUrl"],"mappings":";;;AA2DO,SAAS,aAAa,eAAoD,iBAAgC,IAAY;AAC3H,QAAM,iBAAiB,OAAO,iBAAkB,WAAW,SAAY;AAExD,iBAAA,mBAAmB,aAAqB,SAA6B;AAClF,QAAI,CAAC,eAAsB,OAAA,IAAI,MAAM,oCAAoC;AACnE,UAAA,YAAYA,MAAAA,iBAAiB,gBAAgB,WAAW;AAC9D,QAAI,CAAC,UAAW,OAAM,IAAI,MAAM,iBAAiB,WAAW,cAAc;AACpE,UAAA,EAAE,QAAQ,MAAM,YAAY,CAAA,MAAO,WACnC,WAAW,MAAMC,MAAA,MAAM,MAAM;AAAA,MACjC;AAAA,MACA,SAASC,iBAAW,cAAc;AAAA,MAClC,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAGD,QAAI,SAAS,GAAW,QAAA,SAAS,KAAK;AAGhC,UAAA,SAAS,SAAS,OAAO,SAAS;AACxC,UAAI,UAAU,aACT,OAAO,UAAU,MAAM,KAAM,YAC7B,UAAU,MAAM,MAAM,QACtB,iBAAiB,UAAU,MAAM,KACjC,OAAO,UAAU,MAAM,EAAE,eAAgB,WACtC,IAAI,MAAM,UAAU,MAAM,EAAE,WAAW,IAGzC,IAAI,MAAM,SAAS,UAAU;AAAA,EAAA;AAG9B,SAAA,IAAI,MAAM,IAAI;AAAA,IACnB,IAAI,GAAG,UAAkB;AACvB,aAAI,aAAa,UAAgBD,MAAA,QAC1B,CAAC,YAAqC,mBAAmB,UAAU,OAAO;AAAA,IAAA;AAAA,EACnF,CACD;AACH;;"}
1
+ {"version":3,"file":"createClient.cjs","sources":["../createClient.ts"],"sourcesContent":["import type { MaybeLiteral, Override, Pretty } from '@unshared/types'\nimport type { OpenAPI, OpenAPIV2 as V2, OpenAPIV3 as V3, OpenAPIV3_1 as V3_1 } from 'openapi-types'\nimport type { OpenAPIV2, OpenAPIV3 } from './openapi/index'\nimport type { RequestHooks } from './utils/handleResponse'\nimport type { RequestHeaders, RequestMethod, RequestOptions } from './utils/parseRequest'\nimport { fetch } from './fetch'\nimport { getBaseUrl } from './openapi/getBaseUrl'\nimport { getOperationById } from './openapi/getOperationById'\nimport { handleResponse } from './utils/handleResponse'\n\ntype ClientBaseUrl<T> =\n MaybeLiteral<\n T extends V2.Document ? OpenAPIV2.ServerUrl<T>\n : T extends V3.Document ? OpenAPIV3.ServerUrl<T>\n : T extends V3_1.Document ? OpenAPIV3.ServerUrl<T>\n : string\n >\n\ntype ClientFetch<T> =\n T extends V2.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV2.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV2.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : T extends V3.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : T extends V3_1.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : typeof globalThis.fetch\n\ntype ClientFetchOperation<T, U extends OpenAPIV2.OperationId<T>> =\n T extends V2.Document ? (options: OpenAPIV2.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV2.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : T extends V3.Document ? (options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : T extends V3_1.Document ? (options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : (options: RequestOptions) => Promise<Response>\n\nexport type Client<T = OpenAPI.Document> =\n Pretty<\n & { [K in OpenAPIV2.OperationId<T>]: ClientFetchOperation<T, K> }\n & { fetch: ClientFetch<T> }\n >\n\nexport type ClientOptions<T = any> = Override<RequestHooks & RequestOptions, {\n baseUrl?: ClientBaseUrl<T>\n\n /**\n * The headers to include in every request made by the client.\n *\n * @example { 'Authorization': 'Bearer ...' }\n */\n headers?: T extends V3.Document\n ? OpenAPIV3.ServerHeaders<T>\n : RequestHeaders\n}>\n\n/**\n * Create a new client instance for the given OpenAPI specification.\n *\n * @param document The OpenAPI specification document.\n * @param initialOptions The initial options to use for every request.\n * @returns The client instance.\n * @example\n * const client = createClient(document)\n * await client.fetch({ ... })\n */\n// @ts-expect-error: `ClientOptions` is not assignable to `ClientOptions<T>`.\nexport function createClient<T extends OpenAPI.Document>(document: Readonly<T>, initialOptions?: ClientOptions<T>): Client<T>\nexport function createClient<T extends OpenAPI.Document>(url: ClientBaseUrl<T>, initialOptions?: ClientOptions<T>): Client<T>\nexport function createClient(documentOrUrl: Readonly<OpenAPI.Document> | string, initialOptions: ClientOptions = {}): Client {\n const specifications = typeof documentOrUrl === 'string' ? undefined : documentOrUrl\n if (typeof documentOrUrl === 'string') initialOptions.baseUrl = documentOrUrl\n\n async function fetchByOperationId(operationId: string, options: ClientOptions<any>) {\n if (!specifications) throw new Error('No OpenAPI specification provided.')\n const operation = getOperationById(specifications, operationId) as { method: RequestMethod; path: string } & OpenAPI.Operation\n if (!operation) throw new Error(`Operation ID \"${operationId}\" not found.`)\n const { method, path, responses = {} } = operation\n const fetchOptions = { method, baseUrl: getBaseUrl(specifications), ...initialOptions, ...options }\n const response = await fetch(path, fetchOptions)\n\n // --- Return the JSON response if successful.\n if (response.ok) return handleResponse(response, fetchOptions)\n\n // --- Throw an error if the response was not successful.\n const status = response.status.toString()\n if (status in responses\n && typeof responses[status] === 'object'\n && responses[status] !== null\n && 'description' in responses[status]\n && typeof responses[status].description === 'string')\n throw new Error(responses[status].description)\n\n // --- Throw a generic error if the response was not successful.\n throw new Error(response.statusText)\n }\n\n return new Proxy({}, {\n get(_, property: string) {\n if (property === 'fetch') return (route: string, options: RequestOptions) => fetch(route, ({ ...initialOptions, ...options }))\n return (options: Record<string, unknown>) => fetchByOperationId(property, options)\n },\n }) as unknown as Client\n}\n"],"names":["getOperationById","getBaseUrl","fetch","handleResponse"],"mappings":";;;;AA8DO,SAAS,aAAa,eAAoD,iBAAgC,IAAY;AAC3H,QAAM,iBAAiB,OAAO,iBAAkB,WAAW,SAAY;AACnE,SAAO,iBAAkB,aAAU,eAAe,UAAU;AAEjD,iBAAA,mBAAmB,aAAqB,SAA6B;AAClF,QAAI,CAAC,eAAsB,OAAA,IAAI,MAAM,oCAAoC;AACnE,UAAA,YAAYA,iBAAAA,iBAAiB,gBAAgB,WAAW;AAC9D,QAAI,CAAC,UAAW,OAAM,IAAI,MAAM,iBAAiB,WAAW,cAAc;AACpE,UAAA,EAAE,QAAQ,MAAM,YAAY,CAAA,EAAO,IAAA,WACnC,eAAe,EAAE,QAAQ,SAASC,4BAAW,cAAc,GAAG,GAAG,gBAAgB,GAAG,QAAA,GACpF,WAAW,MAAMC,MAAAA,MAAM,MAAM,YAAY;AAG/C,QAAI,SAAS,GAAW,QAAAC,eAAAA,eAAe,UAAU,YAAY;AAGvD,UAAA,SAAS,SAAS,OAAO,SAAS;AACxC,UAAI,UAAU,aACT,OAAO,UAAU,MAAM,KAAM,YAC7B,UAAU,MAAM,MAAM,QACtB,iBAAiB,UAAU,MAAM,KACjC,OAAO,UAAU,MAAM,EAAE,eAAgB,WACtC,IAAI,MAAM,UAAU,MAAM,EAAE,WAAW,IAGzC,IAAI,MAAM,SAAS,UAAU;AAAA,EAAA;AAG9B,SAAA,IAAI,MAAM,IAAI;AAAA,IACnB,IAAI,GAAG,UAAkB;AACvB,aAAI,aAAa,UAAgB,CAAC,OAAe,YAA4BD,MAAA,MAAM,OAAQ,EAAE,GAAG,gBAAgB,GAAG,SAAU,IACtH,CAAC,YAAqC,mBAAmB,UAAU,OAAO;AAAA,IAAA;AAAA,EACnF,CACD;AACH;;"}
@@ -1,26 +1,27 @@
1
1
  import { Pretty, Override, MaybeLiteral } from '@unshared/types';
2
2
  import { OpenAPI, OpenAPIV3, OpenAPIV2 as OpenAPIV2$1, OpenAPIV3_1 } from 'openapi-types';
3
- import { a as RequestOptions } from './chunks/B0duX_ls.js';
4
- import { O as OpenAPIV2, a as OpenAPIV3$1 } from './chunks/BIx2AaJH.js';
3
+ import { O as OpenAPIV2, a as OpenAPIV3$1 } from './chunks/BsMghIPi.js';
4
+ import { R as RequestHooks } from './chunks/r8pYO6Hx.js';
5
+ import { c as RequestOptions, a as RequestHeaders } from './chunks/DZp6zyqV.js';
5
6
  import './chunks/8BFCFxqa.js';
6
7
 
7
8
  type ClientBaseUrl<T> = MaybeLiteral<T extends OpenAPIV2$1.Document ? OpenAPIV2.ServerUrl<T> : T extends OpenAPIV3.Document ? OpenAPIV3$1.ServerUrl<T> : T extends OpenAPIV3_1.Document ? OpenAPIV3$1.ServerUrl<T> : string>;
8
- type ClientFetch<T> = T extends OpenAPIV2$1.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV2.RequestInit<OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV2.Response<OpenAPIV2.OperationByRoute<T, P>>> : T extends OpenAPIV3.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3$1.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3$1.Response<OpenAPIV2.OperationByRoute<T, P>>> : T extends OpenAPIV3_1.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3$1.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3$1.Response<OpenAPIV2.OperationByRoute<T, P>>> : typeof globalThis.fetch;
9
- type ClientFetchOperation<T, U extends OpenAPIV2.OperationId<T>> = T extends OpenAPIV2$1.Document ? (options: OpenAPIV2.RequestInit<OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV2.ResponseBody<OpenAPIV2.OperationById<T, U>>> : T extends OpenAPIV3.Document ? (options: OpenAPIV3$1.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3$1.ResponseBody<OpenAPIV2.OperationById<T, U>>> : T extends OpenAPIV3_1.Document ? (options: OpenAPIV3$1.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3$1.ResponseBody<OpenAPIV2.OperationById<T, U>>> : (options: RequestOptions) => Promise<Response>;
9
+ type ClientFetch<T> = T extends OpenAPIV2$1.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV2.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV2.Response<OpenAPIV2.OperationByRoute<T, P>>> : T extends OpenAPIV3.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3$1.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3$1.Response<OpenAPIV2.OperationByRoute<T, P>>> : T extends OpenAPIV3_1.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3$1.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3$1.Response<OpenAPIV2.OperationByRoute<T, P>>> : typeof globalThis.fetch;
10
+ type ClientFetchOperation<T, U extends OpenAPIV2.OperationId<T>> = T extends OpenAPIV2$1.Document ? (options: OpenAPIV2.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV2.ResponseBody<OpenAPIV2.OperationById<T, U>>> : T extends OpenAPIV3.Document ? (options: OpenAPIV3$1.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3$1.ResponseBody<OpenAPIV2.OperationById<T, U>>> : T extends OpenAPIV3_1.Document ? (options: OpenAPIV3$1.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3$1.ResponseBody<OpenAPIV2.OperationById<T, U>>> : (options: RequestOptions) => Promise<Response>;
10
11
  type Client<T = OpenAPI.Document> = Pretty<{
11
12
  [K in OpenAPIV2.OperationId<T>]: ClientFetchOperation<T, K>;
12
13
  } & {
13
14
  fetch: ClientFetch<T>;
14
15
  }>;
15
- type ClientOptions<T = any> = Pretty<Override<RequestOptions, {
16
+ type ClientOptions<T = any> = Override<RequestHooks & RequestOptions, {
16
17
  baseUrl?: ClientBaseUrl<T>;
17
18
  /**
18
19
  * The headers to include in every request made by the client.
19
20
  *
20
21
  * @example { 'Authorization': 'Bearer ...' }
21
22
  */
22
- headers?: T extends OpenAPIV3.Document ? OpenAPIV3$1.ServerHeaders<T> : Record<string, string>;
23
- }>>;
23
+ headers?: T extends OpenAPIV3.Document ? OpenAPIV3$1.ServerHeaders<T> : RequestHeaders;
24
+ }>;
24
25
  /**
25
26
  * Create a new client instance for the given OpenAPI specification.
26
27
  *
@@ -1,25 +1,23 @@
1
1
  import { fetch } from "./fetch.js";
2
- import { a as getOperationById, g as getBaseUrl } from "./chunks/CRISqhP7.js";
3
- import "./chunks/wF9C7mO0.js";
2
+ import { a as getOperationById, g as getBaseUrl } from "./chunks/D-WqCFul.js";
3
+ import { h as handleResponse } from "./chunks/CKfJvIQ8.js";
4
+ import "./chunks/B5hc73Po.js";
5
+ import "@unshared/functions/awaitable";
4
6
  function createClient(documentOrUrl, initialOptions = {}) {
5
7
  const specifications = typeof documentOrUrl == "string" ? void 0 : documentOrUrl;
8
+ typeof documentOrUrl == "string" && (initialOptions.baseUrl = documentOrUrl);
6
9
  async function fetchByOperationId(operationId, options) {
7
10
  if (!specifications) throw new Error("No OpenAPI specification provided.");
8
11
  const operation = getOperationById(specifications, operationId);
9
12
  if (!operation) throw new Error(`Operation ID "${operationId}" not found.`);
10
- const { method, path, responses = {} } = operation, response = await fetch(path, {
11
- method,
12
- baseUrl: getBaseUrl(specifications),
13
- ...initialOptions,
14
- ...options
15
- });
16
- if (response.ok) return response.json();
13
+ const { method, path, responses = {} } = operation, fetchOptions = { method, baseUrl: getBaseUrl(specifications), ...initialOptions, ...options }, response = await fetch(path, fetchOptions);
14
+ if (response.ok) return handleResponse(response, fetchOptions);
17
15
  const status = response.status.toString();
18
16
  throw status in responses && typeof responses[status] == "object" && responses[status] !== null && "description" in responses[status] && typeof responses[status].description == "string" ? new Error(responses[status].description) : new Error(response.statusText);
19
17
  }
20
18
  return new Proxy({}, {
21
19
  get(_, property) {
22
- return property === "fetch" ? fetch : (options) => fetchByOperationId(property, options);
20
+ return property === "fetch" ? (route, options) => fetch(route, { ...initialOptions, ...options }) : (options) => fetchByOperationId(property, options);
23
21
  }
24
22
  });
25
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createClient.js","sources":["../createClient.ts"],"sourcesContent":["import type { MaybeLiteral, Override, Pretty } from '@unshared/types'\nimport type { OpenAPI, OpenAPIV2 as V2, OpenAPIV3 as V3, OpenAPIV3_1 as V3_1 } from 'openapi-types'\nimport type { RequestOptions } from './utils/index'\nimport { fetch } from './fetch'\nimport { getOperationById } from './openapi/getOperationById'\nimport { getBaseUrl, type OpenAPIV2, type OpenAPIV3 } from './openapi/index'\n\ntype ClientBaseUrl<T> =\n MaybeLiteral<\n T extends V2.Document ? OpenAPIV2.ServerUrl<T>\n : T extends V3.Document ? OpenAPIV3.ServerUrl<T>\n : T extends V3_1.Document ? OpenAPIV3.ServerUrl<T>\n : string\n >\n\ntype ClientFetch<T> =\n T extends V2.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV2.RequestInit<OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV2.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : T extends V3.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : T extends V3_1.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : typeof globalThis.fetch\n\ntype ClientFetchOperation<T, U extends OpenAPIV2.OperationId<T>> =\n T extends V2.Document ? (options: OpenAPIV2.RequestInit<OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV2.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : T extends V3.Document ? (options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : T extends V3_1.Document ? (options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : (options: RequestOptions) => Promise<Response>\n\nexport type Client<T = OpenAPI.Document> =\n Pretty<\n & { [K in OpenAPIV2.OperationId<T>]: ClientFetchOperation<T, K> }\n & { fetch: ClientFetch<T> }\n >\n\nexport type ClientOptions<T = any> = Pretty<Override<RequestOptions, {\n baseUrl?: ClientBaseUrl<T>\n\n /**\n * The headers to include in every request made by the client.\n *\n * @example { 'Authorization': 'Bearer ...' }\n */\n headers?: T extends V3.Document\n ? OpenAPIV3.ServerHeaders<T>\n : Record<string, string>\n}>>\n\n/**\n * Create a new client instance for the given OpenAPI specification.\n *\n * @param document The OpenAPI specification document.\n * @param initialOptions The initial options to use for every request.\n * @returns The client instance.\n * @example\n * const client = createClient(document)\n * await client.fetch({ ... })\n */\n// @ts-expect-error: `ClientOptions` is not assignable to `ClientOptions<T>`.\nexport function createClient<T extends OpenAPI.Document>(document: Readonly<T>, initialOptions?: ClientOptions<T>): Client<T>\nexport function createClient<T extends OpenAPI.Document>(url: ClientBaseUrl<T>, initialOptions?: ClientOptions<T>): Client<T>\nexport function createClient(documentOrUrl: Readonly<OpenAPI.Document> | string, initialOptions: ClientOptions = {}): Client {\n const specifications = typeof documentOrUrl === 'string' ? undefined : documentOrUrl\n\n async function fetchByOperationId(operationId: string, options: ClientOptions<any>) {\n if (!specifications) throw new Error('No OpenAPI specification provided.')\n const operation = getOperationById(specifications, operationId) as { method: string; path: string } & OpenAPI.Operation\n if (!operation) throw new Error(`Operation ID \"${operationId}\" not found.`)\n const { method, path, responses = {} } = operation\n const response = await fetch(path, {\n method,\n baseUrl: getBaseUrl(specifications),\n ...initialOptions,\n ...options,\n })\n\n // --- Return the JSON response if successful.\n if (response.ok) return response.json() as Promise<unknown>\n\n // --- Throw an error if the response was not successful.\n const status = response.status.toString()\n if (status in responses\n && typeof responses[status] === 'object'\n && responses[status] !== null\n && 'description' in responses[status]\n && typeof responses[status].description === 'string')\n throw new Error(responses[status].description)\n\n // --- Throw a generic error if the response was not successful.\n throw new Error(response.statusText)\n }\n\n return new Proxy({}, {\n get(_, property: string) {\n if (property === 'fetch') return fetch\n return (options: Record<string, unknown>) => fetchByOperationId(property, options)\n },\n }) as unknown as Client\n}\n"],"names":[],"mappings":";;;AA2DO,SAAS,aAAa,eAAoD,iBAAgC,IAAY;AAC3H,QAAM,iBAAiB,OAAO,iBAAkB,WAAW,SAAY;AAExD,iBAAA,mBAAmB,aAAqB,SAA6B;AAClF,QAAI,CAAC,eAAsB,OAAA,IAAI,MAAM,oCAAoC;AACnE,UAAA,YAAY,iBAAiB,gBAAgB,WAAW;AAC9D,QAAI,CAAC,UAAW,OAAM,IAAI,MAAM,iBAAiB,WAAW,cAAc;AACpE,UAAA,EAAE,QAAQ,MAAM,YAAY,CAAA,MAAO,WACnC,WAAW,MAAM,MAAM,MAAM;AAAA,MACjC;AAAA,MACA,SAAS,WAAW,cAAc;AAAA,MAClC,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAGD,QAAI,SAAS,GAAW,QAAA,SAAS,KAAK;AAGhC,UAAA,SAAS,SAAS,OAAO,SAAS;AACxC,UAAI,UAAU,aACT,OAAO,UAAU,MAAM,KAAM,YAC7B,UAAU,MAAM,MAAM,QACtB,iBAAiB,UAAU,MAAM,KACjC,OAAO,UAAU,MAAM,EAAE,eAAgB,WACtC,IAAI,MAAM,UAAU,MAAM,EAAE,WAAW,IAGzC,IAAI,MAAM,SAAS,UAAU;AAAA,EAAA;AAG9B,SAAA,IAAI,MAAM,IAAI;AAAA,IACnB,IAAI,GAAG,UAAkB;AACvB,aAAI,aAAa,UAAgB,QAC1B,CAAC,YAAqC,mBAAmB,UAAU,OAAO;AAAA,IAAA;AAAA,EACnF,CACD;AACH;"}
1
+ {"version":3,"file":"createClient.js","sources":["../createClient.ts"],"sourcesContent":["import type { MaybeLiteral, Override, Pretty } from '@unshared/types'\nimport type { OpenAPI, OpenAPIV2 as V2, OpenAPIV3 as V3, OpenAPIV3_1 as V3_1 } from 'openapi-types'\nimport type { OpenAPIV2, OpenAPIV3 } from './openapi/index'\nimport type { RequestHooks } from './utils/handleResponse'\nimport type { RequestHeaders, RequestMethod, RequestOptions } from './utils/parseRequest'\nimport { fetch } from './fetch'\nimport { getBaseUrl } from './openapi/getBaseUrl'\nimport { getOperationById } from './openapi/getOperationById'\nimport { handleResponse } from './utils/handleResponse'\n\ntype ClientBaseUrl<T> =\n MaybeLiteral<\n T extends V2.Document ? OpenAPIV2.ServerUrl<T>\n : T extends V3.Document ? OpenAPIV3.ServerUrl<T>\n : T extends V3_1.Document ? OpenAPIV3.ServerUrl<T>\n : string\n >\n\ntype ClientFetch<T> =\n T extends V2.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV2.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV2.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : T extends V3.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : T extends V3_1.Document ? <P extends OpenAPIV2.Route<T>>(name: P, options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationByRoute<T, P>>) => Promise<OpenAPIV3.Response<OpenAPIV2.OperationByRoute<T, P>>>\n : typeof globalThis.fetch\n\ntype ClientFetchOperation<T, U extends OpenAPIV2.OperationId<T>> =\n T extends V2.Document ? (options: OpenAPIV2.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV2.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : T extends V3.Document ? (options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : T extends V3_1.Document ? (options: OpenAPIV3.RequestInit<T, OpenAPIV2.OperationById<T, U>>) => Promise<OpenAPIV3.ResponseBody<OpenAPIV2.OperationById<T, U>>>\n : (options: RequestOptions) => Promise<Response>\n\nexport type Client<T = OpenAPI.Document> =\n Pretty<\n & { [K in OpenAPIV2.OperationId<T>]: ClientFetchOperation<T, K> }\n & { fetch: ClientFetch<T> }\n >\n\nexport type ClientOptions<T = any> = Override<RequestHooks & RequestOptions, {\n baseUrl?: ClientBaseUrl<T>\n\n /**\n * The headers to include in every request made by the client.\n *\n * @example { 'Authorization': 'Bearer ...' }\n */\n headers?: T extends V3.Document\n ? OpenAPIV3.ServerHeaders<T>\n : RequestHeaders\n}>\n\n/**\n * Create a new client instance for the given OpenAPI specification.\n *\n * @param document The OpenAPI specification document.\n * @param initialOptions The initial options to use for every request.\n * @returns The client instance.\n * @example\n * const client = createClient(document)\n * await client.fetch({ ... })\n */\n// @ts-expect-error: `ClientOptions` is not assignable to `ClientOptions<T>`.\nexport function createClient<T extends OpenAPI.Document>(document: Readonly<T>, initialOptions?: ClientOptions<T>): Client<T>\nexport function createClient<T extends OpenAPI.Document>(url: ClientBaseUrl<T>, initialOptions?: ClientOptions<T>): Client<T>\nexport function createClient(documentOrUrl: Readonly<OpenAPI.Document> | string, initialOptions: ClientOptions = {}): Client {\n const specifications = typeof documentOrUrl === 'string' ? undefined : documentOrUrl\n if (typeof documentOrUrl === 'string') initialOptions.baseUrl = documentOrUrl\n\n async function fetchByOperationId(operationId: string, options: ClientOptions<any>) {\n if (!specifications) throw new Error('No OpenAPI specification provided.')\n const operation = getOperationById(specifications, operationId) as { method: RequestMethod; path: string } & OpenAPI.Operation\n if (!operation) throw new Error(`Operation ID \"${operationId}\" not found.`)\n const { method, path, responses = {} } = operation\n const fetchOptions = { method, baseUrl: getBaseUrl(specifications), ...initialOptions, ...options }\n const response = await fetch(path, fetchOptions)\n\n // --- Return the JSON response if successful.\n if (response.ok) return handleResponse(response, fetchOptions)\n\n // --- Throw an error if the response was not successful.\n const status = response.status.toString()\n if (status in responses\n && typeof responses[status] === 'object'\n && responses[status] !== null\n && 'description' in responses[status]\n && typeof responses[status].description === 'string')\n throw new Error(responses[status].description)\n\n // --- Throw a generic error if the response was not successful.\n throw new Error(response.statusText)\n }\n\n return new Proxy({}, {\n get(_, property: string) {\n if (property === 'fetch') return (route: string, options: RequestOptions) => fetch(route, ({ ...initialOptions, ...options }))\n return (options: Record<string, unknown>) => fetchByOperationId(property, options)\n },\n }) as unknown as Client\n}\n"],"names":[],"mappings":";;;;;AA8DO,SAAS,aAAa,eAAoD,iBAAgC,IAAY;AAC3H,QAAM,iBAAiB,OAAO,iBAAkB,WAAW,SAAY;AACnE,SAAO,iBAAkB,aAAU,eAAe,UAAU;AAEjD,iBAAA,mBAAmB,aAAqB,SAA6B;AAClF,QAAI,CAAC,eAAsB,OAAA,IAAI,MAAM,oCAAoC;AACnE,UAAA,YAAY,iBAAiB,gBAAgB,WAAW;AAC9D,QAAI,CAAC,UAAW,OAAM,IAAI,MAAM,iBAAiB,WAAW,cAAc;AACpE,UAAA,EAAE,QAAQ,MAAM,YAAY,CAAA,EAAO,IAAA,WACnC,eAAe,EAAE,QAAQ,SAAS,WAAW,cAAc,GAAG,GAAG,gBAAgB,GAAG,QAAA,GACpF,WAAW,MAAM,MAAM,MAAM,YAAY;AAG/C,QAAI,SAAS,GAAW,QAAA,eAAe,UAAU,YAAY;AAGvD,UAAA,SAAS,SAAS,OAAO,SAAS;AACxC,UAAI,UAAU,aACT,OAAO,UAAU,MAAM,KAAM,YAC7B,UAAU,MAAM,MAAM,QACtB,iBAAiB,UAAU,MAAM,KACjC,OAAO,UAAU,MAAM,EAAE,eAAgB,WACtC,IAAI,MAAM,UAAU,MAAM,EAAE,WAAW,IAGzC,IAAI,MAAM,SAAS,UAAU;AAAA,EAAA;AAG9B,SAAA,IAAI,MAAM,IAAI;AAAA,IACnB,IAAI,GAAG,UAAkB;AACvB,aAAI,aAAa,UAAgB,CAAC,OAAe,YAA4B,MAAM,OAAQ,EAAE,GAAG,gBAAgB,GAAG,SAAU,IACtH,CAAC,YAAqC,mBAAmB,UAAU,OAAO;AAAA,IAAA;AAAA,EACnF,CACD;AACH;"}
package/dist/fetch.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- var parseRequest = require("./chunks/C3RyfPUw.cjs");
3
- function fetch(route, options) {
2
+ var parseRequest = require("./chunks/D8Tsm7xC.cjs");
3
+ function fetch(route, options = {}) {
4
4
  const { url, init } = parseRequest.parseRequest(route, options);
5
5
  return globalThis.fetch(url, init);
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.cjs","sources":["../fetch.ts"],"sourcesContent":["import { parseRequest } from './utils/parseRequest'\n\n/**\n * Fetch a route with the provided options. This function will parse the route and\n * options to create a `Request` object and return the response from the server.\n *\n * @param route The name of the route to fetch.\n * @param options The options to pass to the request.\n * @returns The response from the server.\n * @example fetch('GET /users', { query: { limit: 10 } })\n */\nexport function fetch(route: string, options: Record<string, unknown>) {\n const { url, init } = parseRequest(route, options)\n return globalThis.fetch(url!, init)\n}\n"],"names":["parseRequest"],"mappings":";;AAWgB,SAAA,MAAM,OAAe,SAAkC;AACrE,QAAM,EAAE,KAAK,KAAA,IAASA,aAAAA,aAAa,OAAO,OAAO;AAC1C,SAAA,WAAW,MAAM,KAAM,IAAI;AACpC;;"}
1
+ {"version":3,"file":"fetch.cjs","sources":["../fetch.ts"],"sourcesContent":["import type { RequestOptions } from './utils/parseRequest'\nimport { parseRequest } from './utils/parseRequest'\n\n/**\n * Fetch a route with the provided options. This function will parse the route and\n * options to create a `Request` object and return the response from the server.\n *\n * @param route The name of the route to fetch.\n * @param options The options to pass to the request.\n * @returns The response from the server.\n * @example fetch('GET /users', { query: { limit: 10 } })\n */\nexport function fetch(route: string, options: RequestOptions = {}) {\n const { url, init } = parseRequest(route, options)\n return globalThis.fetch(url!, init)\n}\n"],"names":["parseRequest"],"mappings":";;AAYO,SAAS,MAAM,OAAe,UAA0B,IAAI;AACjE,QAAM,EAAE,KAAK,KAAA,IAASA,aAAAA,aAAa,OAAO,OAAO;AAC1C,SAAA,WAAW,MAAM,KAAM,IAAI;AACpC;;"}
package/dist/fetch.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import { c as RequestOptions } from './chunks/DZp6zyqV.js';
2
+ import '@unshared/types';
3
+ import './chunks/8BFCFxqa.js';
4
+
1
5
  /**
2
6
  * Fetch a route with the provided options. This function will parse the route and
3
7
  * options to create a `Request` object and return the response from the server.
@@ -7,6 +11,6 @@
7
11
  * @returns The response from the server.
8
12
  * @example fetch('GET /users', { query: { limit: 10 } })
9
13
  */
10
- declare function fetch(route: string, options: Record<string, unknown>): Promise<Response>;
14
+ declare function fetch(route: string, options?: RequestOptions): Promise<Response>;
11
15
 
12
16
  export { fetch };
package/dist/fetch.js CHANGED
@@ -1,5 +1,5 @@
1
- import { p as parseRequest } from "./chunks/wF9C7mO0.js";
2
- function fetch(route, options) {
1
+ import { p as parseRequest } from "./chunks/B5hc73Po.js";
2
+ function fetch(route, options = {}) {
3
3
  const { url, init } = parseRequest(route, options);
4
4
  return globalThis.fetch(url, init);
5
5
  }
package/dist/fetch.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sources":["../fetch.ts"],"sourcesContent":["import { parseRequest } from './utils/parseRequest'\n\n/**\n * Fetch a route with the provided options. This function will parse the route and\n * options to create a `Request` object and return the response from the server.\n *\n * @param route The name of the route to fetch.\n * @param options The options to pass to the request.\n * @returns The response from the server.\n * @example fetch('GET /users', { query: { limit: 10 } })\n */\nexport function fetch(route: string, options: Record<string, unknown>) {\n const { url, init } = parseRequest(route, options)\n return globalThis.fetch(url!, init)\n}\n"],"names":[],"mappings":";AAWgB,SAAA,MAAM,OAAe,SAAkC;AACrE,QAAM,EAAE,KAAK,KAAA,IAAS,aAAa,OAAO,OAAO;AAC1C,SAAA,WAAW,MAAM,KAAM,IAAI;AACpC;"}
1
+ {"version":3,"file":"fetch.js","sources":["../fetch.ts"],"sourcesContent":["import type { RequestOptions } from './utils/parseRequest'\nimport { parseRequest } from './utils/parseRequest'\n\n/**\n * Fetch a route with the provided options. This function will parse the route and\n * options to create a `Request` object and return the response from the server.\n *\n * @param route The name of the route to fetch.\n * @param options The options to pass to the request.\n * @returns The response from the server.\n * @example fetch('GET /users', { query: { limit: 10 } })\n */\nexport function fetch(route: string, options: RequestOptions = {}) {\n const { url, init } = parseRequest(route, options)\n return globalThis.fetch(url!, init)\n}\n"],"names":[],"mappings":";AAYO,SAAS,MAAM,OAAe,UAA0B,IAAI;AACjE,QAAM,EAAE,KAAK,KAAA,IAAS,aAAa,OAAO,OAAO;AAC1C,SAAA,WAAW,MAAM,KAAM,IAAI;AACpC;"}
package/dist/index.cjs CHANGED
@@ -1,16 +1,19 @@
1
1
  "use strict";
2
- var createClient = require("./createClient.cjs"), fetch = require("./fetch.cjs");
3
- require("./openapi.cjs");
2
+ var createClient = require("./createClient.cjs"), fetch = require("./fetch.cjs"), openapi = require("./openapi.cjs");
4
3
  require("./utils.cjs");
5
- var index = require("./chunks/BzqHK4CV.cjs"), parseRequest = require("./chunks/C3RyfPUw.cjs"), HttpHeader = /* @__PURE__ */ ((HttpHeader2) => (HttpHeader2["Accept-CH"] = "Accept-CH", HttpHeader2["Accept-Charset"] = "Accept-Charset", HttpHeader2["Accept-Encoding"] = "Accept-Encoding", HttpHeader2["Accept-Language"] = "Accept-Language", HttpHeader2["Accept-Patch"] = "Accept-Patch", HttpHeader2["Accept-Post"] = "Accept-Post", HttpHeader2["Accept-Ranges"] = "Accept-Ranges", HttpHeader2.Accept = "Accept", HttpHeader2["Access-Control-Allow-Credentials"] = "Access-Control-Allow-Credentials", HttpHeader2["Access-Control-Allow-Headers"] = "Access-Control-Allow-Headers", HttpHeader2["Access-Control-Allow-Methods"] = "Access-Control-Allow-Methods", HttpHeader2["Access-Control-Allow-Origin"] = "Access-Control-Allow-Origin", HttpHeader2["Access-Control-Expose-Headers"] = "Access-Control-Expose-Headers", HttpHeader2["Access-Control-Max-Age"] = "Access-Control-Max-Age", HttpHeader2["Access-Control-Request-Headers"] = "Access-Control-Request-Headers", HttpHeader2["Access-Control-Request-Method"] = "Access-Control-Request-Method", HttpHeader2.Age = "Age", HttpHeader2.Allow = "Allow", HttpHeader2["Alt-Svc"] = "Alt-Svc", HttpHeader2["Alt-Used"] = "Alt-Used", HttpHeader2["Attribution-Reporting-Eligible"] = "Attribution-Reporting-Eligible", HttpHeader2["Attribution-Reporting-Register-Source"] = "Attribution-Reporting-Register-Source", HttpHeader2["Attribution-Reporting-Register-Trigger"] = "Attribution-Reporting-Register-Trigger", HttpHeader2.Authorization = "Authorization", HttpHeader2["Cache-Control"] = "Cache-Control", HttpHeader2["Clear-Site-Data"] = "Clear-Site-Data", HttpHeader2.Connection = "Connection", HttpHeader2["Content-Digest"] = "Content-Digest", HttpHeader2["Content-Disposition"] = "Content-Disposition", HttpHeader2["Content-DPR"] = "Content-DPR", HttpHeader2["Content-Encoding"] = "Content-Encoding", HttpHeader2["Content-Language"] = "Content-Language", HttpHeader2["Content-Length"] = "Content-Length", HttpHeader2["Content-Location"] = "Content-Location", HttpHeader2["Content-Range"] = "Content-Range", HttpHeader2["Content-Security-Policy-Report-Only"] = "Content-Security-Policy-Report-Only", HttpHeader2["Content-Security-Policy"] = "Content-Security-Policy", HttpHeader2["Content-Type"] = "Content-Type", HttpHeader2.Cookie = "Cookie", HttpHeader2["Critical-CH"] = "Critical-CH", HttpHeader2["Cross-Origin-Embedder-Policy"] = "Cross-Origin-Embedder-Policy", HttpHeader2["Cross-Origin-Opener-Policy"] = "Cross-Origin-Opener-Policy", HttpHeader2["Cross-Origin-Resource-Policy"] = "Cross-Origin-Resource-Policy", HttpHeader2.Date = "Date", HttpHeader2["Device-Memory"] = "Device-Memory", HttpHeader2.Digest = "Digest", HttpHeader2.DNT = "DNT", HttpHeader2.Downlink = "Downlink", HttpHeader2.DPR = "DPR", HttpHeader2["Early-Data"] = "Early-Data", HttpHeader2.ECT = "ECT", HttpHeader2.ETag = "ETag", HttpHeader2["Expect-CT"] = "Expect-CT", HttpHeader2.Expect = "Expect", HttpHeader2.Expires = "Expires", HttpHeader2.Forwarded = "Forwarded", HttpHeader2.From = "From", HttpHeader2.Host = "Host", HttpHeader2["If-Match"] = "If-Match", HttpHeader2["If-Modified-Since"] = "If-Modified-Since", HttpHeader2["If-None-Match"] = "If-None-Match", HttpHeader2["If-Range"] = "If-Range", HttpHeader2["If-Unmodified-Since"] = "If-Unmodified-Since", HttpHeader2["Keep-Alive"] = "Keep-Alive", HttpHeader2["Last-Modified"] = "Last-Modified", HttpHeader2.Link = "Link", HttpHeader2.Location = "Location", HttpHeader2["Max-Forwards"] = "Max-Forwards", HttpHeader2.NEL = "NEL", HttpHeader2["No-Vary-Search"] = "No-Vary-Search", HttpHeader2["Observe-Browsing-Topics"] = "Observe-Browsing-Topics", HttpHeader2["Origin-Agent-Cluster"] = "Origin-Agent-Cluster", HttpHeader2.Origin = "Origin", HttpHeader2["Permissions-Policy"] = "Permissions-Policy", HttpHeader2.Pragma = "Pragma", HttpHeader2.Priority = "Priority", HttpHeader2["Proxy-Authenticate"] = "Proxy-Authenticate", HttpHeader2["Proxy-Authorization"] = "Proxy-Authorization", HttpHeader2.Range = "Range", HttpHeader2.Referer = "Referer", HttpHeader2["Referrer-Policy"] = "Referrer-Policy", HttpHeader2.Refresh = "Refresh", HttpHeader2["Report-To"] = "Report-To", HttpHeader2["Reporting-Endpoints"] = "Reporting-Endpoints", HttpHeader2["Repr-Digest"] = "Repr-Digest", HttpHeader2["Retry-After"] = "Retry-After", HttpHeader2.RTT = "RTT", HttpHeader2["Save-Data"] = "Save-Data", HttpHeader2["Sec-Browsing-Topics"] = "Sec-Browsing-Topics", HttpHeader2["Sec-CH-Prefers-Color-Scheme"] = "Sec-CH-Prefers-Color-Scheme", HttpHeader2["Sec-CH-Prefers-Reduced-Motion"] = "Sec-CH-Prefers-Reduced-Motion", HttpHeader2["Sec-CH-Prefers-Reduced-Transparency"] = "Sec-CH-Prefers-Reduced-Transparency", HttpHeader2["Sec-CH-UA-Arch"] = "Sec-CH-UA-Arch", HttpHeader2["Sec-CH-UA-Bitness"] = "Sec-CH-UA-Bitness", HttpHeader2["Sec-CH-UA-Full-Version-List"] = "Sec-CH-UA-Full-Version-List", HttpHeader2["Sec-CH-UA-Full-Version"] = "Sec-CH-UA-Full-Version", HttpHeader2["Sec-CH-UA-Mobile"] = "Sec-CH-UA-Mobile", HttpHeader2["Sec-CH-UA-Model"] = "Sec-CH-UA-Model", HttpHeader2["Sec-CH-UA-Platform-Version"] = "Sec-CH-UA-Platform-Version", HttpHeader2["Sec-CH-UA-Platform"] = "Sec-CH-UA-Platform", HttpHeader2["Sec-CH-UA"] = "Sec-CH-UA", HttpHeader2["Sec-Fetch-Dest"] = "Sec-Fetch-Dest", HttpHeader2["Sec-Fetch-Mode"] = "Sec-Fetch-Mode", HttpHeader2["Sec-Fetch-Site"] = "Sec-Fetch-Site", HttpHeader2["Sec-Fetch-User"] = "Sec-Fetch-User", HttpHeader2["Sec-GPC"] = "Sec-GPC", HttpHeader2["Sec-Purpose"] = "Sec-Purpose", HttpHeader2["Sec-WebSocket-Accept"] = "Sec-WebSocket-Accept", HttpHeader2["Sec-WebSocket-Extensions"] = "Sec-WebSocket-Extensions", HttpHeader2["Sec-WebSocket-Key"] = "Sec-WebSocket-Key", HttpHeader2["Sec-WebSocket-Protocol"] = "Sec-WebSocket-Protocol", HttpHeader2["Sec-WebSocket-Version"] = "Sec-WebSocket-Version", HttpHeader2["Server-Timing"] = "Server-Timing", HttpHeader2.Server = "Server", HttpHeader2["Service-Worker-Navigation-Preload"] = "Service-Worker-Navigation-Preload", HttpHeader2["Set-Cookie"] = "Set-Cookie", HttpHeader2["Set-Login"] = "Set-Login", HttpHeader2.SourceMap = "SourceMap", HttpHeader2["Speculation-Rules"] = "Speculation-Rules", HttpHeader2["Strict-Transport-Security"] = "Strict-Transport-Security", HttpHeader2["Supports-Loading-Mode"] = "Supports-Loading-Mode", HttpHeader2.TE = "TE", HttpHeader2["Timing-Allow-Origin"] = "Timing-Allow-Origin", HttpHeader2.Tk = "Tk", HttpHeader2.Trailer = "Trailer", HttpHeader2["Transfer-Encoding"] = "Transfer-Encoding", HttpHeader2["Upgrade-Insecure-Requests"] = "Upgrade-Insecure-Requests", HttpHeader2.Upgrade = "Upgrade", HttpHeader2["User-Agent"] = "User-Agent", HttpHeader2.Vary = "Vary", HttpHeader2.Via = "Via", HttpHeader2["Viewport-Width"] = "Viewport-Width", HttpHeader2["Want-Content-Digest"] = "Want-Content-Digest", HttpHeader2["Want-Digest"] = "Want-Digest", HttpHeader2["Want-Repr-Digest"] = "Want-Repr-Digest", HttpHeader2.Warning = "Warning", HttpHeader2.Width = "Width", HttpHeader2["WWW-Authenticate"] = "WWW-Authenticate", HttpHeader2["X-Content-Type-Options"] = "X-Content-Type-Options", HttpHeader2["X-DNS-Prefetch-Control"] = "X-DNS-Prefetch-Control", HttpHeader2["X-Forwarded-For"] = "X-Forwarded-For", HttpHeader2["X-Forwarded-Host"] = "X-Forwarded-Host", HttpHeader2["X-Forwarded-Proto"] = "X-Forwarded-Proto", HttpHeader2["X-Frame-Options"] = "X-Frame-Options", HttpHeader2["X-XSS-Protection"] = "X-XSS-Protection", HttpHeader2))(HttpHeader || {}), HttpMethod = /* @__PURE__ */ ((HttpMethod2) => (HttpMethod2.CONNECT = "CONNECT", HttpMethod2.DELETE = "DELETE", HttpMethod2.GET = "GET", HttpMethod2.HEAD = "HEAD", HttpMethod2.OPTIONS = "OPTIONS", HttpMethod2.PATCH = "PATCH", HttpMethod2.POST = "POST", HttpMethod2.PUT = "PUT", HttpMethod2.TRACE = "TRACE", HttpMethod2))(HttpMethod || {}), HttpStatusCode = /* @__PURE__ */ ((HttpStatusCode2) => (HttpStatusCode2[HttpStatusCode2.CONTINUE = 100] = "CONTINUE", HttpStatusCode2[HttpStatusCode2.SWITCHING_PROTOCOLS = 101] = "SWITCHING_PROTOCOLS", HttpStatusCode2[HttpStatusCode2.PROCESSING = 102] = "PROCESSING", HttpStatusCode2[HttpStatusCode2.EARLY_HINTS = 103] = "EARLY_HINTS", HttpStatusCode2[HttpStatusCode2.OK = 200] = "OK", HttpStatusCode2[HttpStatusCode2.CREATED = 201] = "CREATED", HttpStatusCode2[HttpStatusCode2.ACCEPTED = 202] = "ACCEPTED", HttpStatusCode2[HttpStatusCode2.NON_AUTHORITATIVE_INFORMATION = 203] = "NON_AUTHORITATIVE_INFORMATION", HttpStatusCode2[HttpStatusCode2.NO_CONTENT = 204] = "NO_CONTENT", HttpStatusCode2[HttpStatusCode2.RESET_CONTENT = 205] = "RESET_CONTENT", HttpStatusCode2[HttpStatusCode2.PARTIAL_CONTENT = 206] = "PARTIAL_CONTENT", HttpStatusCode2[HttpStatusCode2.MULTI_STATUS = 207] = "MULTI_STATUS", HttpStatusCode2[HttpStatusCode2.ALREADY_REPORTED = 208] = "ALREADY_REPORTED", HttpStatusCode2[HttpStatusCode2.IM_USED = 226] = "IM_USED", HttpStatusCode2[HttpStatusCode2.MULTIPLE_CHOICES = 300] = "MULTIPLE_CHOICES", HttpStatusCode2[HttpStatusCode2.MOVED_PERMANENTLY = 301] = "MOVED_PERMANENTLY", HttpStatusCode2[HttpStatusCode2.FOUND = 302] = "FOUND", HttpStatusCode2[HttpStatusCode2.SEE_OTHER = 303] = "SEE_OTHER", HttpStatusCode2[HttpStatusCode2.NOT_MODIFIED = 304] = "NOT_MODIFIED", HttpStatusCode2[HttpStatusCode2.TEMPORARY_REDIRECT = 307] = "TEMPORARY_REDIRECT", HttpStatusCode2[HttpStatusCode2.PERMANENT_REDIRECT = 308] = "PERMANENT_REDIRECT", HttpStatusCode2[HttpStatusCode2.BAD_REQUEST = 400] = "BAD_REQUEST", HttpStatusCode2[HttpStatusCode2.UNAUTHORIZED = 401] = "UNAUTHORIZED", HttpStatusCode2[HttpStatusCode2.PAYMENT_REQUIRED = 402] = "PAYMENT_REQUIRED", HttpStatusCode2[HttpStatusCode2.FORBIDDEN = 403] = "FORBIDDEN", HttpStatusCode2[HttpStatusCode2.NOT_FOUND = 404] = "NOT_FOUND", HttpStatusCode2[HttpStatusCode2.METHOD_NOT_ALLOWED = 405] = "METHOD_NOT_ALLOWED", HttpStatusCode2[HttpStatusCode2.NOT_ACCEPTABLE = 406] = "NOT_ACCEPTABLE", HttpStatusCode2[HttpStatusCode2.PROXY_AUTHENTICATION_REQUIRED = 407] = "PROXY_AUTHENTICATION_REQUIRED", HttpStatusCode2[HttpStatusCode2.REQUEST_TIMEOUT = 408] = "REQUEST_TIMEOUT", HttpStatusCode2[HttpStatusCode2.CONFLICT = 409] = "CONFLICT", HttpStatusCode2[HttpStatusCode2.GONE = 410] = "GONE", HttpStatusCode2[HttpStatusCode2.LENGTH_REQUIRED = 411] = "LENGTH_REQUIRED", HttpStatusCode2[HttpStatusCode2.PRECONDITION_FAILED = 412] = "PRECONDITION_FAILED", HttpStatusCode2[HttpStatusCode2.CONTENT_TOO_LARGE = 413] = "CONTENT_TOO_LARGE", HttpStatusCode2[HttpStatusCode2.URI_TOO_LONG = 414] = "URI_TOO_LONG", HttpStatusCode2[HttpStatusCode2.UNSUPPORTED_MEDIA_TYPE = 415] = "UNSUPPORTED_MEDIA_TYPE", HttpStatusCode2[HttpStatusCode2.RANGE_NOT_SATISFIABLE = 416] = "RANGE_NOT_SATISFIABLE", HttpStatusCode2[HttpStatusCode2.EXPECTATION_FAILED = 417] = "EXPECTATION_FAILED", HttpStatusCode2[HttpStatusCode2.I_M_A_TEAPOT = 418] = "I_M_A_TEAPOT", HttpStatusCode2[HttpStatusCode2.MISDIRECTED_REQUEST = 421] = "MISDIRECTED_REQUEST", HttpStatusCode2[HttpStatusCode2.UNPROCESSABLE_CONTENT = 422] = "UNPROCESSABLE_CONTENT", HttpStatusCode2[HttpStatusCode2.LOCKED = 423] = "LOCKED", HttpStatusCode2[HttpStatusCode2.FAILED_DEPENDENCY = 424] = "FAILED_DEPENDENCY", HttpStatusCode2[HttpStatusCode2.TOO_EARLY = 425] = "TOO_EARLY", HttpStatusCode2[HttpStatusCode2.UPGRADE_REQUIRED = 426] = "UPGRADE_REQUIRED", HttpStatusCode2[HttpStatusCode2.PRECONDITION_REQUIRED = 428] = "PRECONDITION_REQUIRED", HttpStatusCode2[HttpStatusCode2.TOO_MANY_REQUESTS = 429] = "TOO_MANY_REQUESTS", HttpStatusCode2[HttpStatusCode2.REQUEST_HEADER_FIELDS_TOO_LARGE = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE", HttpStatusCode2[HttpStatusCode2.UNAVAILABLE_FOR_LEGAL_REASONS = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS", HttpStatusCode2[HttpStatusCode2.INTERNAL_SERVER_ERROR = 500] = "INTERNAL_SERVER_ERROR", HttpStatusCode2[HttpStatusCode2.NOT_IMPLEMENTED = 501] = "NOT_IMPLEMENTED", HttpStatusCode2[HttpStatusCode2.BAD_GATEWAY = 502] = "BAD_GATEWAY", HttpStatusCode2[HttpStatusCode2.SERVICE_UNAVAILABLE = 503] = "SERVICE_UNAVAILABLE", HttpStatusCode2[HttpStatusCode2.GATEWAY_TIMEOUT = 504] = "GATEWAY_TIMEOUT", HttpStatusCode2[HttpStatusCode2.HTTP_VERSION_NOT_SUPPORTED = 505] = "HTTP_VERSION_NOT_SUPPORTED", HttpStatusCode2[HttpStatusCode2.VARIANT_ALSO_NEGOTIATES = 506] = "VARIANT_ALSO_NEGOTIATES", HttpStatusCode2[HttpStatusCode2.INSUFFICIENT_STORAGE = 507] = "INSUFFICIENT_STORAGE", HttpStatusCode2[HttpStatusCode2.LOOP_DETECTED = 508] = "LOOP_DETECTED", HttpStatusCode2[HttpStatusCode2.NOT_EXTENDED = 510] = "NOT_EXTENDED", HttpStatusCode2[HttpStatusCode2.NETWORK_AUTHENTICATION_REQUIRED = 511] = "NETWORK_AUTHENTICATION_REQUIRED", HttpStatusCode2))(HttpStatusCode || {});
4
+ var getOperationById = require("./chunks/xRZPkxch.cjs"), handleResponse = require("./chunks/Cx8m1YzL.cjs"), parseRequest = require("./chunks/D8Tsm7xC.cjs");
5
+ require("@unshared/functions/awaitable");
6
+ var HttpHeader = /* @__PURE__ */ ((HttpHeader2) => (HttpHeader2["Accept-CH"] = "Accept-CH", HttpHeader2["Accept-Charset"] = "Accept-Charset", HttpHeader2["Accept-Encoding"] = "Accept-Encoding", HttpHeader2["Accept-Language"] = "Accept-Language", HttpHeader2["Accept-Patch"] = "Accept-Patch", HttpHeader2["Accept-Post"] = "Accept-Post", HttpHeader2["Accept-Ranges"] = "Accept-Ranges", HttpHeader2.Accept = "Accept", HttpHeader2["Access-Control-Allow-Credentials"] = "Access-Control-Allow-Credentials", HttpHeader2["Access-Control-Allow-Headers"] = "Access-Control-Allow-Headers", HttpHeader2["Access-Control-Allow-Methods"] = "Access-Control-Allow-Methods", HttpHeader2["Access-Control-Allow-Origin"] = "Access-Control-Allow-Origin", HttpHeader2["Access-Control-Expose-Headers"] = "Access-Control-Expose-Headers", HttpHeader2["Access-Control-Max-Age"] = "Access-Control-Max-Age", HttpHeader2["Access-Control-Request-Headers"] = "Access-Control-Request-Headers", HttpHeader2["Access-Control-Request-Method"] = "Access-Control-Request-Method", HttpHeader2.Age = "Age", HttpHeader2.Allow = "Allow", HttpHeader2["Alt-Svc"] = "Alt-Svc", HttpHeader2["Alt-Used"] = "Alt-Used", HttpHeader2["Attribution-Reporting-Eligible"] = "Attribution-Reporting-Eligible", HttpHeader2["Attribution-Reporting-Register-Source"] = "Attribution-Reporting-Register-Source", HttpHeader2["Attribution-Reporting-Register-Trigger"] = "Attribution-Reporting-Register-Trigger", HttpHeader2.Authorization = "Authorization", HttpHeader2["Cache-Control"] = "Cache-Control", HttpHeader2["Clear-Site-Data"] = "Clear-Site-Data", HttpHeader2.Connection = "Connection", HttpHeader2["Content-Digest"] = "Content-Digest", HttpHeader2["Content-Disposition"] = "Content-Disposition", HttpHeader2["Content-DPR"] = "Content-DPR", HttpHeader2["Content-Encoding"] = "Content-Encoding", HttpHeader2["Content-Language"] = "Content-Language", HttpHeader2["Content-Length"] = "Content-Length", HttpHeader2["Content-Location"] = "Content-Location", HttpHeader2["Content-Range"] = "Content-Range", HttpHeader2["Content-Security-Policy-Report-Only"] = "Content-Security-Policy-Report-Only", HttpHeader2["Content-Security-Policy"] = "Content-Security-Policy", HttpHeader2["Content-Type"] = "Content-Type", HttpHeader2.Cookie = "Cookie", HttpHeader2["Critical-CH"] = "Critical-CH", HttpHeader2["Cross-Origin-Embedder-Policy"] = "Cross-Origin-Embedder-Policy", HttpHeader2["Cross-Origin-Opener-Policy"] = "Cross-Origin-Opener-Policy", HttpHeader2["Cross-Origin-Resource-Policy"] = "Cross-Origin-Resource-Policy", HttpHeader2.Date = "Date", HttpHeader2["Device-Memory"] = "Device-Memory", HttpHeader2.Digest = "Digest", HttpHeader2.DNT = "DNT", HttpHeader2.Downlink = "Downlink", HttpHeader2.DPR = "DPR", HttpHeader2["Early-Data"] = "Early-Data", HttpHeader2.ECT = "ECT", HttpHeader2.ETag = "ETag", HttpHeader2["Expect-CT"] = "Expect-CT", HttpHeader2.Expect = "Expect", HttpHeader2.Expires = "Expires", HttpHeader2.Forwarded = "Forwarded", HttpHeader2.From = "From", HttpHeader2.Host = "Host", HttpHeader2["If-Match"] = "If-Match", HttpHeader2["If-Modified-Since"] = "If-Modified-Since", HttpHeader2["If-None-Match"] = "If-None-Match", HttpHeader2["If-Range"] = "If-Range", HttpHeader2["If-Unmodified-Since"] = "If-Unmodified-Since", HttpHeader2["Keep-Alive"] = "Keep-Alive", HttpHeader2["Last-Modified"] = "Last-Modified", HttpHeader2.Link = "Link", HttpHeader2.Location = "Location", HttpHeader2["Max-Forwards"] = "Max-Forwards", HttpHeader2.NEL = "NEL", HttpHeader2["No-Vary-Search"] = "No-Vary-Search", HttpHeader2["Observe-Browsing-Topics"] = "Observe-Browsing-Topics", HttpHeader2["Origin-Agent-Cluster"] = "Origin-Agent-Cluster", HttpHeader2.Origin = "Origin", HttpHeader2["Permissions-Policy"] = "Permissions-Policy", HttpHeader2.Pragma = "Pragma", HttpHeader2.Priority = "Priority", HttpHeader2["Proxy-Authenticate"] = "Proxy-Authenticate", HttpHeader2["Proxy-Authorization"] = "Proxy-Authorization", HttpHeader2.Range = "Range", HttpHeader2.Referer = "Referer", HttpHeader2["Referrer-Policy"] = "Referrer-Policy", HttpHeader2.Refresh = "Refresh", HttpHeader2["Report-To"] = "Report-To", HttpHeader2["Reporting-Endpoints"] = "Reporting-Endpoints", HttpHeader2["Repr-Digest"] = "Repr-Digest", HttpHeader2["Retry-After"] = "Retry-After", HttpHeader2.RTT = "RTT", HttpHeader2["Save-Data"] = "Save-Data", HttpHeader2["Sec-Browsing-Topics"] = "Sec-Browsing-Topics", HttpHeader2["Sec-CH-Prefers-Color-Scheme"] = "Sec-CH-Prefers-Color-Scheme", HttpHeader2["Sec-CH-Prefers-Reduced-Motion"] = "Sec-CH-Prefers-Reduced-Motion", HttpHeader2["Sec-CH-Prefers-Reduced-Transparency"] = "Sec-CH-Prefers-Reduced-Transparency", HttpHeader2["Sec-CH-UA-Arch"] = "Sec-CH-UA-Arch", HttpHeader2["Sec-CH-UA-Bitness"] = "Sec-CH-UA-Bitness", HttpHeader2["Sec-CH-UA-Full-Version-List"] = "Sec-CH-UA-Full-Version-List", HttpHeader2["Sec-CH-UA-Full-Version"] = "Sec-CH-UA-Full-Version", HttpHeader2["Sec-CH-UA-Mobile"] = "Sec-CH-UA-Mobile", HttpHeader2["Sec-CH-UA-Model"] = "Sec-CH-UA-Model", HttpHeader2["Sec-CH-UA-Platform-Version"] = "Sec-CH-UA-Platform-Version", HttpHeader2["Sec-CH-UA-Platform"] = "Sec-CH-UA-Platform", HttpHeader2["Sec-CH-UA"] = "Sec-CH-UA", HttpHeader2["Sec-Fetch-Dest"] = "Sec-Fetch-Dest", HttpHeader2["Sec-Fetch-Mode"] = "Sec-Fetch-Mode", HttpHeader2["Sec-Fetch-Site"] = "Sec-Fetch-Site", HttpHeader2["Sec-Fetch-User"] = "Sec-Fetch-User", HttpHeader2["Sec-GPC"] = "Sec-GPC", HttpHeader2["Sec-Purpose"] = "Sec-Purpose", HttpHeader2["Sec-WebSocket-Accept"] = "Sec-WebSocket-Accept", HttpHeader2["Sec-WebSocket-Extensions"] = "Sec-WebSocket-Extensions", HttpHeader2["Sec-WebSocket-Key"] = "Sec-WebSocket-Key", HttpHeader2["Sec-WebSocket-Protocol"] = "Sec-WebSocket-Protocol", HttpHeader2["Sec-WebSocket-Version"] = "Sec-WebSocket-Version", HttpHeader2["Server-Timing"] = "Server-Timing", HttpHeader2.Server = "Server", HttpHeader2["Service-Worker-Navigation-Preload"] = "Service-Worker-Navigation-Preload", HttpHeader2["Set-Cookie"] = "Set-Cookie", HttpHeader2["Set-Login"] = "Set-Login", HttpHeader2.SourceMap = "SourceMap", HttpHeader2["Speculation-Rules"] = "Speculation-Rules", HttpHeader2["Strict-Transport-Security"] = "Strict-Transport-Security", HttpHeader2["Supports-Loading-Mode"] = "Supports-Loading-Mode", HttpHeader2.TE = "TE", HttpHeader2["Timing-Allow-Origin"] = "Timing-Allow-Origin", HttpHeader2.Tk = "Tk", HttpHeader2.Trailer = "Trailer", HttpHeader2["Transfer-Encoding"] = "Transfer-Encoding", HttpHeader2["Upgrade-Insecure-Requests"] = "Upgrade-Insecure-Requests", HttpHeader2.Upgrade = "Upgrade", HttpHeader2["User-Agent"] = "User-Agent", HttpHeader2.Vary = "Vary", HttpHeader2.Via = "Via", HttpHeader2["Viewport-Width"] = "Viewport-Width", HttpHeader2["Want-Content-Digest"] = "Want-Content-Digest", HttpHeader2["Want-Digest"] = "Want-Digest", HttpHeader2["Want-Repr-Digest"] = "Want-Repr-Digest", HttpHeader2.Warning = "Warning", HttpHeader2.Width = "Width", HttpHeader2["WWW-Authenticate"] = "WWW-Authenticate", HttpHeader2["X-Content-Type-Options"] = "X-Content-Type-Options", HttpHeader2["X-DNS-Prefetch-Control"] = "X-DNS-Prefetch-Control", HttpHeader2["X-Forwarded-For"] = "X-Forwarded-For", HttpHeader2["X-Forwarded-Host"] = "X-Forwarded-Host", HttpHeader2["X-Forwarded-Proto"] = "X-Forwarded-Proto", HttpHeader2["X-Frame-Options"] = "X-Frame-Options", HttpHeader2["X-XSS-Protection"] = "X-XSS-Protection", HttpHeader2))(HttpHeader || {}), HttpMethod = /* @__PURE__ */ ((HttpMethod2) => (HttpMethod2.CONNECT = "CONNECT", HttpMethod2.DELETE = "DELETE", HttpMethod2.GET = "GET", HttpMethod2.HEAD = "HEAD", HttpMethod2.OPTIONS = "OPTIONS", HttpMethod2.PATCH = "PATCH", HttpMethod2.POST = "POST", HttpMethod2.PUT = "PUT", HttpMethod2.TRACE = "TRACE", HttpMethod2))(HttpMethod || {}), HttpStatusCode = /* @__PURE__ */ ((HttpStatusCode2) => (HttpStatusCode2[HttpStatusCode2.CONTINUE = 100] = "CONTINUE", HttpStatusCode2[HttpStatusCode2.SWITCHING_PROTOCOLS = 101] = "SWITCHING_PROTOCOLS", HttpStatusCode2[HttpStatusCode2.PROCESSING = 102] = "PROCESSING", HttpStatusCode2[HttpStatusCode2.EARLY_HINTS = 103] = "EARLY_HINTS", HttpStatusCode2[HttpStatusCode2.OK = 200] = "OK", HttpStatusCode2[HttpStatusCode2.CREATED = 201] = "CREATED", HttpStatusCode2[HttpStatusCode2.ACCEPTED = 202] = "ACCEPTED", HttpStatusCode2[HttpStatusCode2.NON_AUTHORITATIVE_INFORMATION = 203] = "NON_AUTHORITATIVE_INFORMATION", HttpStatusCode2[HttpStatusCode2.NO_CONTENT = 204] = "NO_CONTENT", HttpStatusCode2[HttpStatusCode2.RESET_CONTENT = 205] = "RESET_CONTENT", HttpStatusCode2[HttpStatusCode2.PARTIAL_CONTENT = 206] = "PARTIAL_CONTENT", HttpStatusCode2[HttpStatusCode2.MULTI_STATUS = 207] = "MULTI_STATUS", HttpStatusCode2[HttpStatusCode2.ALREADY_REPORTED = 208] = "ALREADY_REPORTED", HttpStatusCode2[HttpStatusCode2.IM_USED = 226] = "IM_USED", HttpStatusCode2[HttpStatusCode2.MULTIPLE_CHOICES = 300] = "MULTIPLE_CHOICES", HttpStatusCode2[HttpStatusCode2.MOVED_PERMANENTLY = 301] = "MOVED_PERMANENTLY", HttpStatusCode2[HttpStatusCode2.FOUND = 302] = "FOUND", HttpStatusCode2[HttpStatusCode2.SEE_OTHER = 303] = "SEE_OTHER", HttpStatusCode2[HttpStatusCode2.NOT_MODIFIED = 304] = "NOT_MODIFIED", HttpStatusCode2[HttpStatusCode2.TEMPORARY_REDIRECT = 307] = "TEMPORARY_REDIRECT", HttpStatusCode2[HttpStatusCode2.PERMANENT_REDIRECT = 308] = "PERMANENT_REDIRECT", HttpStatusCode2[HttpStatusCode2.BAD_REQUEST = 400] = "BAD_REQUEST", HttpStatusCode2[HttpStatusCode2.UNAUTHORIZED = 401] = "UNAUTHORIZED", HttpStatusCode2[HttpStatusCode2.PAYMENT_REQUIRED = 402] = "PAYMENT_REQUIRED", HttpStatusCode2[HttpStatusCode2.FORBIDDEN = 403] = "FORBIDDEN", HttpStatusCode2[HttpStatusCode2.NOT_FOUND = 404] = "NOT_FOUND", HttpStatusCode2[HttpStatusCode2.METHOD_NOT_ALLOWED = 405] = "METHOD_NOT_ALLOWED", HttpStatusCode2[HttpStatusCode2.NOT_ACCEPTABLE = 406] = "NOT_ACCEPTABLE", HttpStatusCode2[HttpStatusCode2.PROXY_AUTHENTICATION_REQUIRED = 407] = "PROXY_AUTHENTICATION_REQUIRED", HttpStatusCode2[HttpStatusCode2.REQUEST_TIMEOUT = 408] = "REQUEST_TIMEOUT", HttpStatusCode2[HttpStatusCode2.CONFLICT = 409] = "CONFLICT", HttpStatusCode2[HttpStatusCode2.GONE = 410] = "GONE", HttpStatusCode2[HttpStatusCode2.LENGTH_REQUIRED = 411] = "LENGTH_REQUIRED", HttpStatusCode2[HttpStatusCode2.PRECONDITION_FAILED = 412] = "PRECONDITION_FAILED", HttpStatusCode2[HttpStatusCode2.CONTENT_TOO_LARGE = 413] = "CONTENT_TOO_LARGE", HttpStatusCode2[HttpStatusCode2.URI_TOO_LONG = 414] = "URI_TOO_LONG", HttpStatusCode2[HttpStatusCode2.UNSUPPORTED_MEDIA_TYPE = 415] = "UNSUPPORTED_MEDIA_TYPE", HttpStatusCode2[HttpStatusCode2.RANGE_NOT_SATISFIABLE = 416] = "RANGE_NOT_SATISFIABLE", HttpStatusCode2[HttpStatusCode2.EXPECTATION_FAILED = 417] = "EXPECTATION_FAILED", HttpStatusCode2[HttpStatusCode2.I_M_A_TEAPOT = 418] = "I_M_A_TEAPOT", HttpStatusCode2[HttpStatusCode2.MISDIRECTED_REQUEST = 421] = "MISDIRECTED_REQUEST", HttpStatusCode2[HttpStatusCode2.UNPROCESSABLE_CONTENT = 422] = "UNPROCESSABLE_CONTENT", HttpStatusCode2[HttpStatusCode2.LOCKED = 423] = "LOCKED", HttpStatusCode2[HttpStatusCode2.FAILED_DEPENDENCY = 424] = "FAILED_DEPENDENCY", HttpStatusCode2[HttpStatusCode2.TOO_EARLY = 425] = "TOO_EARLY", HttpStatusCode2[HttpStatusCode2.UPGRADE_REQUIRED = 426] = "UPGRADE_REQUIRED", HttpStatusCode2[HttpStatusCode2.PRECONDITION_REQUIRED = 428] = "PRECONDITION_REQUIRED", HttpStatusCode2[HttpStatusCode2.TOO_MANY_REQUESTS = 429] = "TOO_MANY_REQUESTS", HttpStatusCode2[HttpStatusCode2.REQUEST_HEADER_FIELDS_TOO_LARGE = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE", HttpStatusCode2[HttpStatusCode2.UNAVAILABLE_FOR_LEGAL_REASONS = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS", HttpStatusCode2[HttpStatusCode2.INTERNAL_SERVER_ERROR = 500] = "INTERNAL_SERVER_ERROR", HttpStatusCode2[HttpStatusCode2.NOT_IMPLEMENTED = 501] = "NOT_IMPLEMENTED", HttpStatusCode2[HttpStatusCode2.BAD_GATEWAY = 502] = "BAD_GATEWAY", HttpStatusCode2[HttpStatusCode2.SERVICE_UNAVAILABLE = 503] = "SERVICE_UNAVAILABLE", HttpStatusCode2[HttpStatusCode2.GATEWAY_TIMEOUT = 504] = "GATEWAY_TIMEOUT", HttpStatusCode2[HttpStatusCode2.HTTP_VERSION_NOT_SUPPORTED = 505] = "HTTP_VERSION_NOT_SUPPORTED", HttpStatusCode2[HttpStatusCode2.VARIANT_ALSO_NEGOTIATES = 506] = "VARIANT_ALSO_NEGOTIATES", HttpStatusCode2[HttpStatusCode2.INSUFFICIENT_STORAGE = 507] = "INSUFFICIENT_STORAGE", HttpStatusCode2[HttpStatusCode2.LOOP_DETECTED = 508] = "LOOP_DETECTED", HttpStatusCode2[HttpStatusCode2.NOT_EXTENDED = 510] = "NOT_EXTENDED", HttpStatusCode2[HttpStatusCode2.NETWORK_AUTHENTICATION_REQUIRED = 511] = "NETWORK_AUTHENTICATION_REQUIRED", HttpStatusCode2))(HttpStatusCode || {});
6
7
  exports.createClient = createClient.createClient;
7
8
  exports.fetch = fetch.fetch;
8
- exports.getBaseUrl = index.getBaseUrl;
9
- exports.getOperationById = index.getOperationById;
10
- exports.getOperationByRoute = index.getOperationByRoute;
11
- exports.isReferenceObject = index.isReferenceObject;
12
- exports.resolveDocument = index.resolveDocument;
13
- exports.resolveReference = index.resolveReference;
9
+ exports.getOperationByRoute = openapi.getOperationByRoute;
10
+ exports.isReferenceObject = openapi.isReferenceObject;
11
+ exports.resolveDocument = openapi.resolveDocument;
12
+ exports.resolveReference = openapi.resolveReference;
13
+ exports.getBaseUrl = getOperationById.getBaseUrl;
14
+ exports.getOperationById = getOperationById.getOperationById;
15
+ exports.handleResponse = handleResponse.handleResponse;
16
+ exports.handleResponseStreamJson = handleResponse.handleResponseStreamJson;
14
17
  exports.isFormDataLike = parseRequest.isFormDataLike;
15
18
  exports.isObjectLike = parseRequest.isObjectLike;
16
19
  exports.parseRequest = parseRequest.parseRequest;