@sdk-it/typescript 0.13.0 → 0.14.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.
package/README.md CHANGED
@@ -37,14 +37,14 @@ await generate(spec, {
37
37
  import { generate } from '@sdk-it/typescript';
38
38
 
39
39
  // Fetch remote OpenAPI specification
40
- const spec = await fetch('https://petstore.swagger.io/v2/swagger.json').then(
41
- (res) => res.json(),
40
+ const spec = await fetch('https://api.openstatus.dev/v1/openapi').then((res) =>
41
+ res.json(),
42
42
  );
43
43
 
44
44
  // Generate client SDK
45
45
  await generate(spec, {
46
46
  output: './client',
47
- name: 'PetStore',
47
+ name: 'OpenStatus',
48
48
  });
49
49
  ```
50
50
 
@@ -67,3 +67,37 @@ await generate(spec, {
67
67
  },
68
68
  });
69
69
  ```
70
+
71
+ ### Run the script
72
+
73
+ ```bash
74
+ # using recent versions of node
75
+ node --experimental-strip-types ./openapi.ts
76
+
77
+ # using node < 22
78
+ npx tsx ./openapi.ts
79
+
80
+ # using bun
81
+ bun ./openapi.ts
82
+ ```
83
+
84
+ - Use the generated SDK
85
+
86
+ ```typescript
87
+ import { OpenStatus } from './client';
88
+
89
+ const client = new Client({
90
+ baseUrl: 'https://api.openstatus.dev/v1/',
91
+ });
92
+
93
+ const [result, error] = await client.request('GET /status_report', {});
94
+ ```
95
+
96
+ ## Using with Your Favorite Frameworks
97
+
98
+ The SDK works great on its own, but you might want to native integration with your frameworks:
99
+
100
+ - [React Query](../../docs/react-query.md)
101
+ - [Angular](../../docs/angular.md)
102
+
103
+ Let us know what are you using, and we will help you integrate it.
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import { getFolderExports, methods, writeFiles } from "@sdk-it/core";
6
6
  // packages/typescript/src/lib/generator.ts
7
7
  import { get as get2, merge } from "lodash-es";
8
8
  import { camelcase as camelcase2, pascalcase, spinalcase as spinalcase2 } from "stringcase";
9
+ import { removeDuplicates as removeDuplicates3 } from "@sdk-it/core";
9
10
 
10
11
  // packages/typescript/src/lib/utils.ts
11
12
  import { get } from "lodash-es";
@@ -45,7 +46,7 @@ import type { Endpoints } from './${spec.makeImport("endpoints")}';
45
46
  import schemas from './${spec.makeImport("schemas")}';
46
47
  import {
47
48
  createBaseUrlInterceptor,
48
- createDefaultHeadersInterceptor,
49
+ createHeadersInterceptor,
49
50
  } from './http/${spec.makeImport("interceptors")}';
50
51
 
51
52
  ${spec.servers.length ? `export const servers = ${JSON.stringify(spec.servers, null, 2)} as const` : ""}
@@ -63,14 +64,16 @@ export class ${spec.name} {
63
64
  async request<E extends keyof Endpoints>(
64
65
  endpoint: E,
65
66
  input: Endpoints[E]['input'],
67
+ options?: { signal?: AbortSignal, headers?: HeadersInit },
66
68
  ): Promise<readonly [Endpoints[E]['output'], Endpoints[E]['error'] | null]> {
67
69
  const route = schemas[endpoint];
68
70
  return sendRequest(Object.assign(this.#defaultInputs, input), route, {
69
71
  fetch: this.options.fetch,
70
72
  interceptors: [
71
- createDefaultHeadersInterceptor(() => this.defaultHeaders),
73
+ createHeadersInterceptor(() => this.defaultHeaders, options?.headers ?? {}),
72
74
  createBaseUrlInterceptor(() => this.options.baseUrl),
73
75
  ],
76
+ signal: options?.signal,
74
77
  });
75
78
  }
76
79
 
@@ -274,7 +277,7 @@ function generateSDK(spec) {
274
277
 
275
278
  // packages/typescript/src/lib/utils.ts
276
279
  function isRef(obj) {
277
- return "$ref" in obj;
280
+ return obj && "$ref" in obj;
278
281
  }
279
282
  function cleanRef(ref) {
280
283
  return ref.replace(/^#\//, "");
@@ -292,12 +295,15 @@ function followRef(spec, ref) {
292
295
  }
293
296
  return entry;
294
297
  }
295
- function securityToOptions(security2, securitySchemas, staticIn) {
296
- securitySchemas ??= {};
298
+ function securityToOptions(security2, securitySchemes, staticIn) {
299
+ securitySchemes ??= {};
297
300
  const options = {};
298
301
  for (const it of security2) {
299
302
  const [name] = Object.keys(it);
300
- const schema = securitySchemas[name];
303
+ if (!name) {
304
+ continue;
305
+ }
306
+ const schema = securitySchemes[name];
301
307
  if (isRef(schema)) {
302
308
  throw new Error(`Ref security schemas are not supported`);
303
309
  }
@@ -680,7 +686,7 @@ var ZodDeserialzer = class {
680
686
  normal(type, schema, required = false, nullable = false) {
681
687
  switch (type) {
682
688
  case "string":
683
- return `${this.string(schema)}${this.#suffixes(schema.default, required, nullable)}`;
689
+ return `${this.string(schema)}${this.#suffixes(JSON.stringify(schema.default), required, nullable)}`;
684
690
  case "number":
685
691
  case "integer": {
686
692
  const { base, defaultValue } = this.number(schema);
@@ -689,7 +695,7 @@ var ZodDeserialzer = class {
689
695
  case "boolean":
690
696
  return `z.boolean()${this.#suffixes(schema.default, required, nullable)}`;
691
697
  case "object":
692
- return this.object(schema, required);
698
+ return this.object(schema, true);
693
699
  case "array":
694
700
  return this.array(schema, required);
695
701
  case "null":
@@ -740,13 +746,13 @@ var ZodDeserialzer = class {
740
746
  }
741
747
  oneOf(schemas, required) {
742
748
  const oneOfSchemas = schemas.map((sub) => {
743
- if ("$ref" in sub) {
749
+ if (isRef(sub)) {
744
750
  const { model } = parseRef(sub.$ref);
745
751
  if (this.circularRefTracker.has(model)) {
746
752
  return model;
747
753
  }
748
754
  }
749
- return this.handle(sub, false);
755
+ return this.handle(sub, true);
750
756
  });
751
757
  if (oneOfSchemas.length === 1) {
752
758
  return oneOfSchemas[0];
@@ -851,7 +857,7 @@ var ZodDeserialzer = class {
851
857
  if (schema.anyOf && Array.isArray(schema.anyOf)) {
852
858
  return this.anyOf(schema.anyOf ?? [], required);
853
859
  }
854
- if (schema.oneOf && Array.isArray(schema.oneOf)) {
860
+ if (schema.oneOf && Array.isArray(schema.oneOf) && schema.oneOf.length) {
855
861
  return this.oneOf(schema.oneOf ?? [], required);
856
862
  }
857
863
  if (schema.enum && Array.isArray(schema.enum)) {
@@ -867,7 +873,7 @@ var ZodDeserialzer = class {
867
873
  if (types.length > 1) {
868
874
  const realTypes = types.filter((t) => t !== "null");
869
875
  if (realTypes.length === 1 && types.includes("null")) {
870
- return this.normal(realTypes[0], schema, false, true);
876
+ return this.normal(realTypes[0], schema, required, true);
871
877
  }
872
878
  const subSchemas = types.map((t) => this.normal(t, schema, false));
873
879
  return `z.union([${subSchemas.join(", ")}])${appendOptional2(required)}`;
@@ -879,11 +885,11 @@ function appendOptional2(isRequired) {
879
885
  return isRequired ? "" : ".optional()";
880
886
  }
881
887
  function appendDefault(defaultValue) {
882
- return defaultValue !== void 0 ? `.default(${JSON.stringify(defaultValue)})` : "";
888
+ return defaultValue !== void 0 ? `.default(${defaultValue})` : "";
883
889
  }
884
890
 
885
891
  // packages/typescript/src/lib/generator.ts
886
- var responses = {
892
+ var statusCdeToMessageMap = {
887
893
  "400": "BadRequest",
888
894
  "401": "Unauthorized",
889
895
  "402": "PaymentRequired",
@@ -928,7 +934,8 @@ function generateCode(config) {
928
934
  });
929
935
  const groups = {};
930
936
  const outputs = {};
931
- for (const [path, methods2] of Object.entries(config.spec.paths ?? {})) {
937
+ for (const [path, pathItem] of Object.entries(config.spec.paths ?? {})) {
938
+ const { parameters = [], ...methods2 } = pathItem;
932
939
  for (const [method, operation] of Object.entries(methods2)) {
933
940
  const formatOperationId = config.operationId ?? defaults.operationId;
934
941
  const operationName = formatOperationId(operation, path, method);
@@ -937,7 +944,7 @@ function generateCode(config) {
937
944
  groups[groupName] ??= [];
938
945
  const inputs = {};
939
946
  const additionalProperties = [];
940
- for (const param of operation.parameters ?? []) {
947
+ for (const param of [...parameters, ...operation.parameters ?? []]) {
941
948
  if (isRef(param)) {
942
949
  throw new Error(`Found reference in parameter ${param.$ref}`);
943
950
  }
@@ -951,8 +958,8 @@ function generateCode(config) {
951
958
  additionalProperties.push(param);
952
959
  }
953
960
  const security2 = operation.security ?? [];
954
- const securitySchemas = config.spec.components?.securitySchemes ?? {};
955
- const securityOptions = securityToOptions(security2, securitySchemas);
961
+ const securitySchemes = config.spec.components?.securitySchemes ?? {};
962
+ const securityOptions = securityToOptions(security2, securitySchemes);
956
963
  Object.assign(inputs, securityOptions);
957
964
  additionalProperties.push(
958
965
  ...Object.entries(securityOptions).map(
@@ -1027,6 +1034,8 @@ function generateCode(config) {
1027
1034
  let foundResponse = false;
1028
1035
  const output = [`import z from 'zod';`];
1029
1036
  let parser = "buffered";
1037
+ const responses = [];
1038
+ const responsesImports = {};
1030
1039
  for (const status in operation.responses) {
1031
1040
  const response = isRef(
1032
1041
  operation.responses[status]
@@ -1036,7 +1045,7 @@ function generateCode(config) {
1036
1045
  ) : operation.responses[status];
1037
1046
  const statusCode = +status;
1038
1047
  if (statusCode >= 400) {
1039
- errors.push(responses[status] ?? "ProblematicResponse");
1048
+ errors.push(statusCdeToMessageMap[status] ?? "ProblematicResponse");
1040
1049
  }
1041
1050
  if (statusCode >= 200 && statusCode < 300) {
1042
1051
  foundResponse = true;
@@ -1045,30 +1054,41 @@ function generateCode(config) {
1045
1054
  if ((response.headers ?? {})["Transfer-Encoding"]) {
1046
1055
  parser = "chunked";
1047
1056
  }
1048
- const imports = [];
1049
1057
  const typeScriptDeserialzer = new TypeScriptDeserialzer(
1050
1058
  config.spec,
1051
1059
  (schemaName, zod) => {
1052
1060
  commonSchemas[schemaName] = zod;
1053
- imports.push({
1061
+ responsesImports[schemaName] = {
1054
1062
  defaultImport: void 0,
1055
1063
  isTypeOnly: true,
1056
1064
  moduleSpecifier: `../models/${config.makeImport(schemaName)}`,
1057
1065
  namedImports: [{ isTypeOnly: true, name: schemaName }],
1058
1066
  namespaceImport: void 0
1059
- });
1067
+ };
1060
1068
  }
1061
1069
  );
1062
1070
  const responseSchema = isJson ? typeScriptDeserialzer.handle(
1063
1071
  responseContent["application/json"].schema,
1064
1072
  true
1065
- ) : "ReadableStream";
1066
- output.push(...useImports(responseSchema, imports));
1067
- output.push(
1068
- `export type ${pascalcase(operationName + " output")} = ${responseSchema}`
1069
- );
1073
+ ) : statusCode === 204 ? "void" : "ReadableStream";
1074
+ responses.push(responseSchema);
1070
1075
  }
1071
1076
  }
1077
+ if (responses.length > 1) {
1078
+ output.push(
1079
+ `export type ${pascalcase(operationName + " output")} = ${removeDuplicates3(
1080
+ responses,
1081
+ (it) => it
1082
+ ).join(" | ")};`
1083
+ );
1084
+ } else {
1085
+ output.push(
1086
+ `export type ${pascalcase(operationName + " output")} = ${responses[0]};`
1087
+ );
1088
+ }
1089
+ output.push(
1090
+ ...useImports(output.join(""), Object.values(responsesImports))
1091
+ );
1072
1092
  if (!foundResponse) {
1073
1093
  output.push(
1074
1094
  `export type ${pascalcase(operationName + " output")} = void`
@@ -1105,12 +1125,27 @@ function toProps(spec, schemaOrRef, aggregator = []) {
1105
1125
  aggregator.push(name);
1106
1126
  }
1107
1127
  return void 0;
1128
+ } else if ((schemaOrRef.type === "array" || schemaOrRef.type?.includes("array")) && schemaOrRef.items) {
1129
+ toProps(spec, schemaOrRef.items, aggregator);
1130
+ return void 0;
1108
1131
  } else if (schemaOrRef.allOf) {
1109
1132
  for (const it of schemaOrRef.allOf) {
1110
1133
  toProps(spec, it, aggregator);
1111
1134
  }
1112
1135
  return void 0;
1136
+ } else if (schemaOrRef.oneOf) {
1137
+ for (const it of schemaOrRef.oneOf) {
1138
+ toProps(spec, it, aggregator);
1139
+ }
1140
+ return void 0;
1141
+ } else if (schemaOrRef.anyOf) {
1142
+ for (const it of schemaOrRef.anyOf) {
1143
+ toProps(spec, it, aggregator);
1144
+ }
1145
+ return void 0;
1113
1146
  }
1147
+ console.warn("Unknown schema in body", schemaOrRef);
1148
+ return void 0;
1114
1149
  }
1115
1150
  function bodyInputs(config, ctSchema) {
1116
1151
  const props = [];
@@ -1128,7 +1163,7 @@ function bodyInputs(config, ctSchema) {
1128
1163
  }
1129
1164
 
1130
1165
  // packages/typescript/src/lib/http/interceptors.txt
1131
- var interceptors_default = "export interface Interceptor {\n before?: (request: Request) => Promise<Request> | Request;\n after?: (response: Response) => Promise<Response> | Response;\n}\n\nexport const createDefaultHeadersInterceptor = (\n getHeaders: () => Record<string, string | undefined>,\n) => {\n return {\n before(request: Request) {\n const headers = getHeaders();\n\n for (const [key, value] of Object.entries(headers)) {\n // Only set the header if it doesn't already exist and has a value\n if (value !== undefined && !request.headers.has(key)) {\n request.headers.set(key, value);\n }\n }\n\n return request;\n },\n };\n};\n\nexport const createBaseUrlInterceptor = (getBaseUrl: () => string) => {\n return {\n before(request: Request) {\n const baseUrl = getBaseUrl();\n if (request.url.startsWith('local://')) {\n return new Request(request.url.replace('local://', baseUrl), request);\n }\n return request;\n },\n };\n};\n\nexport const logInterceptor = {\n before(request: Request) {\n console.log('Request', request);\n return request;\n },\n after(response: Response) {\n console.log('Response', response);\n return response;\n },\n};\n\n/**\n * Creates an interceptor that logs detailed information about requests and responses.\n * @param options Configuration options for the logger\n * @returns An interceptor object with before and after handlers\n */\nexport const createDetailedLogInterceptor = (options?: {\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n includeRequestBody?: boolean;\n includeResponseBody?: boolean;\n}) => {\n const logLevel = options?.logLevel || 'info';\n const includeRequestBody = options?.includeRequestBody || false;\n const includeResponseBody = options?.includeResponseBody || false;\n\n return {\n async before(request: Request) {\n const logData = {\n url: request.url,\n method: request.method,\n contentType: request.headers.get('Content-Type'),\n headers: Object.fromEntries([...request.headers.entries()]),\n };\n\n console[logLevel]('\u{1F680} Outgoing Request:', logData);\n\n if (includeRequestBody) {\n try {\n // Clone the request to avoid consuming the body stream\n const clonedRequest = request.clone();\n if (clonedRequest.headers.get('Content-Type')?.includes('application/json')) {\n const body = await clonedRequest.json().catch(() => null);\n console[logLevel]('Request Body:', body);\n } else {\n const body = await clonedRequest.text().catch(() => null);\n console[logLevel]('Request Body:', body);\n }\n } catch (error) {\n console.error('Could not log request body:', error);\n }\n }\n\n return request;\n },\n\n async after(response: Response) {\n const logData = {\n status: response.status,\n statusText: response.statusText,\n url: response.url,\n headers: Object.fromEntries([...response.headers.entries()]),\n };\n\n console[logLevel]('\u{1F4E5} Incoming Response:', logData);\n\n if (includeResponseBody && response.body) {\n try {\n // Clone the response to avoid consuming the body stream\n const clonedResponse = response.clone();\n if (clonedResponse.headers.get('Content-Type')?.includes('application/json')) {\n const body = await clonedResponse.json().catch(() => null);\n console[logLevel]('Response Body:', body);\n } else {\n const body = await clonedResponse.text().catch(() => null);\n if (body) {\n console[logLevel]('Response Body:', body.substring(0, 500) + (body.length > 500 ? '...' : ''));\n } else {\n console[logLevel]('No response body');\n }\n }\n } catch (error) {\n console.error('Could not log response body:', error);\n }\n }\n\n return response;\n },\n };\n};\n";
1166
+ var interceptors_default = "export interface Interceptor {\n before?: (request: Request) => Promise<Request> | Request;\n after?: (response: Response) => Promise<Response> | Response;\n}\n\nexport const createHeadersInterceptor = (\n defaultHeaders: () => Record<string, string | undefined>,\n requestHeaders: HeadersInit,\n) => {\n return {\n before(request: Request) {\n // Priority Levels\n // 1. Headers Input\n // 2. Request Headers\n // 3. Default Headers\n const headers = defaultHeaders();\n\n for (const [key, value] of new Headers(requestHeaders)) {\n // Only set the header if it doesn't already exist and has a value\n // even though these headers are passed at operation level\n // still they are lower priority compared to the headers input\n if (value !== undefined && !request.headers.has(key)) {\n request.headers.set(key, value);\n }\n }\n\n for (const [key, value] of Object.entries(headers)) {\n // Only set the header if it doesn't already exist and has a value\n if (value !== undefined && !request.headers.has(key)) {\n request.headers.set(key, value);\n }\n }\n\n return request;\n },\n };\n};\n\nexport const createBaseUrlInterceptor = (getBaseUrl: () => string) => {\n return {\n before(request: Request) {\n const baseUrl = getBaseUrl();\n if (request.url.startsWith('local://')) {\n return new Request(request.url.replace('local://', baseUrl), request);\n }\n return request;\n },\n };\n};\n\nexport const logInterceptor = {\n before(request: Request) {\n console.log('Request', request);\n return request;\n },\n after(response: Response) {\n console.log('Response', response);\n return response;\n },\n};\n\n/**\n * Creates an interceptor that logs detailed information about requests and responses.\n * @param options Configuration options for the logger\n * @returns An interceptor object with before and after handlers\n */\nexport const createDetailedLogInterceptor = (options?: {\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n includeRequestBody?: boolean;\n includeResponseBody?: boolean;\n}) => {\n const logLevel = options?.logLevel || 'info';\n const includeRequestBody = options?.includeRequestBody || false;\n const includeResponseBody = options?.includeResponseBody || false;\n\n return {\n async before(request: Request) {\n const logData = {\n url: request.url,\n method: request.method,\n contentType: request.headers.get('Content-Type'),\n headers: Object.fromEntries([...request.headers.entries()]),\n };\n\n console[logLevel]('\u{1F680} Outgoing Request:', logData);\n\n if (includeRequestBody) {\n try {\n // Clone the request to avoid consuming the body stream\n const clonedRequest = request.clone();\n if (clonedRequest.headers.get('Content-Type')?.includes('application/json')) {\n const body = await clonedRequest.json().catch(() => null);\n console[logLevel]('Request Body:', body);\n } else {\n const body = await clonedRequest.text().catch(() => null);\n console[logLevel]('Request Body:', body);\n }\n } catch (error) {\n console.error('Could not log request body:', error);\n }\n }\n\n return request;\n },\n\n async after(response: Response) {\n const logData = {\n status: response.status,\n statusText: response.statusText,\n url: response.url,\n headers: Object.fromEntries([...response.headers.entries()]),\n };\n\n console[logLevel]('\u{1F4E5} Incoming Response:', logData);\n\n if (includeResponseBody && response.body) {\n try {\n // Clone the response to avoid consuming the body stream\n const clonedResponse = response.clone();\n if (clonedResponse.headers.get('Content-Type')?.includes('application/json')) {\n const body = await clonedResponse.json().catch(() => null);\n console[logLevel]('Response Body:', body);\n } else {\n const body = await clonedResponse.text().catch(() => null);\n if (body) {\n console[logLevel]('Response Body:', body.substring(0, 500) + (body.length > 500 ? '...' : ''));\n } else {\n console[logLevel]('No response body');\n }\n }\n } catch (error) {\n console.error('Could not log response body:', error);\n }\n }\n\n return response;\n },\n };\n};\n";
1132
1167
 
1133
1168
  // packages/typescript/src/lib/http/parse-response.txt
1134
1169
  var parse_response_default = 'import { parse } from "fast-content-type-parse";\n\nexport async function handleError(response: Response) {\n try {\n if (response.status >= 400 && response.status < 500) {\n const body = (await response.json()) as Record<string, any>;\n return {\n status: response.status,\n body: body,\n };\n }\n return new Error(\n `An error occurred while fetching the data. Status: ${response.status}`,\n );\n } catch (error) {\n return error as any;\n }\n}\n\nasync function handleChunkedResponse(response: Response, contentType: string) {\n const { type } = parse(contentType);\n\n switch (type) {\n case "application/json": {\n let buffer = "";\n const reader = response.body!.getReader();\n const decoder = new TextDecoder();\n while (true) {\n const { value, done } = await reader.read();\n if (done) break;\n buffer += decoder.decode(value);\n }\n return JSON.parse(buffer);\n }\n case "text/html":\n case "text/plain": {\n let buffer = "";\n const reader = response.body!.getReader();\n const decoder = new TextDecoder();\n while (true) {\n const { value, done } = await reader.read();\n if (done) break;\n buffer += decoder.decode(value);\n }\n return buffer;\n }\n default:\n return response.body;\n }\n}\n\nexport function chunked(response: Response) {\n return response.body;\n}\n\nexport async function buffered(response: Response) {\n const contentType = response.headers.get("Content-Type");\n if (!contentType) {\n throw new Error("Content-Type header is missing");\n }\n\n if (response.status === 204) {\n return null;\n }\n\n const { type } = parse(contentType);\n switch (type) {\n case "application/json":\n return response.json();\n case "text/plain":\n return response.text();\n case "text/html":\n return response.text();\n case "text/xml":\n case "application/xml":\n return response.text();\n case "application/x-www-form-urlencoded": {\n const text = await response.text();\n return Object.fromEntries(new URLSearchParams(text));\n }\n case "multipart/form-data":\n return response.formData();\n default:\n throw new Error(`Unsupported content type: ${contentType}`);\n }\n}\n';
@@ -1137,21 +1172,21 @@ var parse_response_default = 'import { parse } from "fast-content-type-parse";\n
1137
1172
  var parser_default = "import { z } from 'zod';\n\nexport type ParseError<T extends z.ZodType<any, any, any>> = {\n kind: 'parse';\n} & z.inferFlattenedErrors<T>;\n\nexport function parse<T extends z.ZodType>(\n schema: T,\n input: unknown,\n) {\n const result = schema.safeParse(input);\n if (!result.success) {\n const errors = result.error.flatten((issue) => issue);\n return [null, errors];\n }\n return [result.data as z.infer<T>, null];\n}\n";
1138
1173
 
1139
1174
  // packages/typescript/src/lib/http/request.txt
1140
- var request_default = "export type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\nexport type ContentType = 'xml' | 'json' | 'urlencoded' | 'multipart';\nexport type Endpoint =\n | `${ContentType} ${Method} ${string}`\n | `${Method} ${string}`;\n\nexport type BodyInit =\n | ArrayBuffer\n | Blob\n | FormData\n | URLSearchParams\n | null\n | string;\n\nexport function createUrl(path: string, query: URLSearchParams) {\n const url = new URL(path, `local://`);\n url.search = query.toString();\n return url;\n}\n\nfunction template(\n templateString: string,\n templateVariables: Record<string, any>,\n): string {\n const nargs = /{([0-9a-zA-Z_]+)}/g;\n return templateString.replace(nargs, (match, key: string, index: number) => {\n // Handle escaped double braces\n if (\n templateString[index - 1] === '{' &&\n templateString[index + match.length] === '}'\n ) {\n return key;\n }\n\n const result = key in templateVariables ? templateVariables[key] : null;\n return result === null || result === undefined ? '' : String(result);\n });\n}\n\ntype Input = Record<string, any>;\ntype Props = {\n inputHeaders: string[];\n inputQuery: string[];\n inputBody: string[];\n inputParams: string[];\n};\n\nabstract class Serializer {\n protected input: Input;\n protected props: Props;\n\n constructor(\n input: Input,\n props: Props,\n ) {\n this.input = input;\n this.props = props;\n }\n\n abstract getBody(): BodyInit | null;\n abstract getHeaders(): Record<string, string>;\n serialize(): Serialized {\n const headers = new Headers({});\n for (const header of this.props.inputHeaders) {\n headers.set(header, this.input[header]);\n }\n\n const query = new URLSearchParams();\n for (const key of this.props.inputQuery) {\n const value = this.input[key];\n if (value !== undefined) {\n query.set(key, String(value));\n }\n }\n\n const params = this.props.inputParams.reduce<Record<string, any>>(\n (acc, key) => {\n acc[key] = this.input[key];\n return acc;\n },\n {},\n );\n\n return {\n body: this.getBody(),\n query,\n params,\n headers: this.getHeaders(),\n };\n }\n}\n\ninterface Serialized {\n body: BodyInit | null;\n query: URLSearchParams;\n params: Record<string, any>;\n headers: Record<string, string>;\n}\n\nclass JsonSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body: Record<string, any> = {};\n for (const prop of this.props.inputBody) {\n body[prop] = this.input[prop];\n }\n return JSON.stringify(body);\n }\n getHeaders(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n };\n }\n}\n\nclass UrlencodedSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body = new URLSearchParams();\n for (const prop of this.props.inputBody) {\n body.set(prop, this.input[prop]);\n }\n return body;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nclass NoBodySerializer extends Serializer {\n getBody(): BodyInit | null {\n return null;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nclass FormDataSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body = new FormData();\n for (const prop of this.props.inputBody) {\n body.append(prop, this.input[prop]);\n }\n return body;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nexport function json(input: Input, props: Props) {\n return new JsonSerializer(input, props).serialize();\n}\nexport function urlencoded(input: Input, props: Props) {\n return new UrlencodedSerializer(input, props).serialize();\n}\nexport function nobody(input: Input, props: Props) {\n return new NoBodySerializer(input, props).serialize();\n}\nexport function formdata(input: Input, props: Props) {\n return new FormDataSerializer(input, props).serialize();\n}\n\nexport function toRequest<T extends Endpoint>(\n endpoint: T,\n input: Serialized,\n): Request {\n const [method, path] = endpoint.split(' ');\n const pathVariable = template(path, input.params);\n\n const url = createUrl(pathVariable, input.query);\n return new Request(url, {\n method: method,\n headers: input.headers,\n body: method === 'GET' ? undefined : input.body,\n });\n}\n";
1175
+ var request_default = "export type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\nexport type ContentType = 'xml' | 'json' | 'urlencoded' | 'multipart' | 'formdata';\nexport type Endpoint =\n | `${ContentType} ${Method} ${string}`\n | `${Method} ${string}`;\n\nexport type BodyInit =\n | ArrayBuffer\n | Blob\n | FormData\n | URLSearchParams\n | null\n | string;\n\nexport function createUrl(path: string, query: URLSearchParams) {\n const url = new URL(path, `local://`);\n url.search = query.toString();\n return url;\n}\n\nfunction template(\n templateString: string,\n templateVariables: Record<string, any>,\n): string {\n const nargs = /{([0-9a-zA-Z_]+)}/g;\n return templateString.replace(nargs, (match, key: string, index: number) => {\n // Handle escaped double braces\n if (\n templateString[index - 1] === '{' &&\n templateString[index + match.length] === '}'\n ) {\n return key;\n }\n\n const result = key in templateVariables ? templateVariables[key] : null;\n return result === null || result === undefined ? '' : String(result);\n });\n}\n\ntype Input = Record<string, any>;\ntype Props = {\n inputHeaders: string[];\n inputQuery: string[];\n inputBody: string[];\n inputParams: string[];\n};\n\nabstract class Serializer {\n protected input: Input;\n protected props: Props;\n\n constructor(\n input: Input,\n props: Props,\n ) {\n this.input = input;\n this.props = props;\n }\n\n abstract getBody(): BodyInit | null;\n abstract getHeaders(): Record<string, string>;\n serialize(): Serialized {\n const headers = new Headers({});\n for (const header of this.props.inputHeaders) {\n headers.set(header, this.input[header]);\n }\n\n const query = new URLSearchParams();\n for (const key of this.props.inputQuery) {\n const value = this.input[key];\n if (value !== undefined) {\n query.set(key, String(value));\n }\n }\n\n const params = this.props.inputParams.reduce<Record<string, any>>(\n (acc, key) => {\n acc[key] = this.input[key];\n return acc;\n },\n {},\n );\n\n return {\n body: this.getBody(),\n query,\n params,\n headers: this.getHeaders(),\n };\n }\n}\n\ninterface Serialized {\n body: BodyInit | null;\n query: URLSearchParams;\n params: Record<string, any>;\n headers: Record<string, string>;\n}\n\nclass JsonSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body: Record<string, any> = {};\n for (const prop of this.props.inputBody) {\n body[prop] = this.input[prop];\n }\n return JSON.stringify(body);\n }\n getHeaders(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n };\n }\n}\n\nclass UrlencodedSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body = new URLSearchParams();\n for (const prop of this.props.inputBody) {\n body.set(prop, this.input[prop]);\n }\n return body;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nclass NoBodySerializer extends Serializer {\n getBody(): BodyInit | null {\n return null;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nclass FormDataSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body = new FormData();\n for (const prop of this.props.inputBody) {\n body.append(prop, this.input[prop]);\n }\n return body;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nexport function json(input: Input, props: Props) {\n return new JsonSerializer(input, props).serialize();\n}\nexport function urlencoded(input: Input, props: Props) {\n return new UrlencodedSerializer(input, props).serialize();\n}\nexport function nobody(input: Input, props: Props) {\n return new NoBodySerializer(input, props).serialize();\n}\nexport function formdata(input: Input, props: Props) {\n return new FormDataSerializer(input, props).serialize();\n}\n\nexport function toRequest<T extends Endpoint>(\n endpoint: T,\n input: Serialized,\n): Request {\n const [method, path] = endpoint.split(' ');\n const pathVariable = template(path, input.params);\n\n const url = createUrl(pathVariable, input.query);\n return new Request(url, {\n method: method,\n headers: input.headers,\n body: method === 'GET' ? undefined : input.body,\n });\n}\n";
1141
1176
 
1142
1177
  // packages/typescript/src/lib/http/response.txt
1143
1178
  var response_default = "export interface ApiResponse<Status extends number, Body extends unknown> {\n kind: 'response';\n status: Status;\n body: Body;\n}\n\n// 4xx Client Errors\nexport type BadRequest = ApiResponse<400, { message: string }>;\nexport type Unauthorized = ApiResponse<401, { message: string }>;\nexport type PaymentRequired = ApiResponse<402, { message: string }>;\nexport type Forbidden = ApiResponse<403, { message: string }>;\nexport type NotFound = ApiResponse<404, { message: string }>;\nexport type MethodNotAllowed = ApiResponse<405, { message: string }>;\nexport type NotAcceptable = ApiResponse<406, { message: string }>;\nexport type Conflict = ApiResponse<409, { message: string }>;\nexport type Gone = ApiResponse<410, { message: string }>;\nexport type UnprocessableEntity = ApiResponse<422, { message: string; errors?: Record<string, string[]> }>;\nexport type TooManyRequests = ApiResponse<429, { message: string; retryAfter?: string }>;\nexport type PayloadTooLarge = ApiResponse<413, { message: string; }>;\nexport type UnsupportedMediaType = ApiResponse<415, { message: string; }>;\n\n// 5xx Server Errors\nexport type InternalServerError = ApiResponse<500, { message: string }>;\nexport type NotImplemented = ApiResponse<501, { message: string }>;\nexport type BadGateway = ApiResponse<502, { message: string }>;\nexport type ServiceUnavailable = ApiResponse<503, { message: string; retryAfter?: string }>;\nexport type GatewayTimeout = ApiResponse<504, { message: string }>;\n\nexport type ClientError =\n | BadRequest\n | Unauthorized\n | PaymentRequired\n | Forbidden\n | NotFound\n | MethodNotAllowed\n | NotAcceptable\n | Conflict\n | Gone\n | UnprocessableEntity\n | TooManyRequests;\n\nexport type ServerError =\n | InternalServerError\n | NotImplemented\n | BadGateway\n | ServiceUnavailable\n | GatewayTimeout;\n\nexport type ProblematicResponse = ClientError | ServerError;\n";
1144
1179
 
1145
1180
  // packages/typescript/src/lib/http/send-request.txt
1146
- var send_request_default = "\nexport interface RequestSchema {\n schema: z.ZodType;\n toRequest: (input: any) => Request;\n deserializer: (response: Response) => Promise<unknown> | unknown;\n}\n\nexport const fetchType = z\n .function()\n .args(z.instanceof(Request))\n .returns(z.promise(z.instanceof(Response)))\n .optional();\n\nexport async function sendRequest(\n input: unknown,\n route: RequestSchema,\n options: {\n fetch?: z.infer<typeof fetchType>;\n interceptors?: Interceptor[];\n },\n) {\n const { interceptors = [] } = options;\n const [parsedInput, parseError] = parse(route.schema, input);\n if (parseError) {\n return [null as never, { ...parseError, kind: 'parse' } as never] as const;\n }\n\n let request = route.toRequest(parsedInput as never);\n for (const interceptor of interceptors) {\n if (interceptor.before) {\n request = await interceptor.before(request);\n }\n }\n\n let response = await (options.fetch ?? fetch)(request);\n\n for (let i = interceptors.length - 1; i >= 0; i--) {\n const interceptor = interceptors[i];\n if (interceptor.after) {\n response = await interceptor.after(response.clone());\n }\n }\n\n if (response.ok) {\n const data = await route.deserializer(response);\n return [data as never, null] as const;\n }\n const error = await handleError(response);\n return [null as never, { ...error, kind: 'response' }] as const;\n}\n";
1181
+ var send_request_default = "\nexport interface RequestSchema {\n schema: z.ZodType;\n toRequest: (input: any) => Request;\n deserializer: (response: Response) => Promise<unknown> | unknown;\n}\n\nexport const fetchType = z\n .function()\n .args(z.instanceof(Request))\n .returns(z.promise(z.instanceof(Response)))\n .optional();\n\nexport async function sendRequest(\n input: unknown,\n route: RequestSchema,\n options: {\n fetch?: z.infer<typeof fetchType>;\n interceptors?: Interceptor[];\n signal?: AbortSignal;\n },\n) {\n const { interceptors = [] } = options;\n const [parsedInput, parseError] = parse(route.schema, input);\n if (parseError) {\n return [null as never, { ...parseError, kind: 'parse' } as never] as const;\n }\n\n let request = route.toRequest(parsedInput as never);\n for (const interceptor of interceptors) {\n if (interceptor.before) {\n request = await interceptor.before(request);\n }\n }\n\n let response = await (options.fetch ?? fetch)(request, { signal: options.signal });\n\n for (let i = interceptors.length - 1; i >= 0; i--) {\n const interceptor = interceptors[i];\n if (interceptor.after) {\n response = await interceptor.after(response.clone());\n }\n }\n\n if (response.ok) {\n const data = await route.deserializer(response);\n return [data as never, null] as const;\n }\n const error = await handleError(response);\n return [null as never, { ...error, kind: 'response' }] as const;\n}\n";
1147
1182
 
1148
1183
  // packages/typescript/src/lib/generate.ts
1149
1184
  function security(spec) {
1150
1185
  const security2 = spec.security || [];
1151
1186
  const components = spec.components || {};
1152
- const securitySchemas = components.securitySchemes || {};
1187
+ const securitySchemes = components.securitySchemes || {};
1153
1188
  const paths = Object.values(spec.paths ?? {});
1154
- const options = securityToOptions(security2, securitySchemas);
1189
+ const options = securityToOptions(security2, securitySchemes);
1155
1190
  for (const it of paths) {
1156
1191
  for (const method of methods) {
1157
1192
  const operation = it[method];
@@ -1160,7 +1195,7 @@ function security(spec) {
1160
1195
  }
1161
1196
  Object.assign(
1162
1197
  options,
1163
- securityToOptions(operation.security || [], securitySchemas, "input")
1198
+ securityToOptions(operation.security || [], securitySchemes, "input")
1164
1199
  );
1165
1200
  }
1166
1201
  }
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/lib/generate.ts", "../src/lib/generator.ts", "../src/lib/utils.ts", "../src/lib/sdk.ts", "../src/lib/client.ts", "../src/lib/emitters/interface.ts", "../src/lib/emitters/zod.ts", "../src/lib/http/interceptors.txt", "../src/lib/http/parse-response.txt", "../src/lib/http/parser.txt", "../src/lib/http/request.txt", "../src/lib/http/response.txt", "../src/lib/http/send-request.txt", "../src/lib/watcher.ts"],
4
- "sourcesContent": ["import { join } from 'node:path';\nimport { npmRunPathEnv } from 'npm-run-path';\nimport type { OpenAPIObject } from 'openapi3-ts/oas31';\n\nimport { getFolderExports, methods, writeFiles } from '@sdk-it/core';\n\nimport { generateCode } from './generator.ts';\nimport interceptors from './http/interceptors.txt';\nimport parseResponse from './http/parse-response.txt';\nimport parserTxt from './http/parser.txt';\nimport requestTxt from './http/request.txt';\nimport responseTxt from './http/response.txt';\nimport sendRequest from './http/send-request.txt';\nimport { generateInputs, generateSDK } from './sdk.ts';\nimport { exclude, securityToOptions } from './utils.ts';\n\nfunction security(spec: OpenAPIObject) {\n const security = spec.security || [];\n const components = spec.components || {};\n const securitySchemas = components.securitySchemes || {};\n const paths = Object.values(spec.paths ?? {});\n\n const options = securityToOptions(security, securitySchemas);\n\n for (const it of paths) {\n for (const method of methods) {\n const operation = it[method];\n if (!operation) {\n continue;\n }\n Object.assign(\n options,\n securityToOptions(operation.security || [], securitySchemas, 'input'),\n );\n }\n }\n return options;\n}\n\nexport async function generate(\n spec: OpenAPIObject,\n settings: {\n output: string;\n useTsExtension?: boolean;\n name?: string;\n /**\n * full: generate a full project including package.json and tsconfig.json. useful for monorepo/workspaces\n * minimal: generate only the client sdk\n */\n mode?: 'full' | 'minimal';\n formatCode?: (options: {\n output: string;\n env: ReturnType<typeof npmRunPathEnv>;\n }) => void | Promise<void>;\n },\n) {\n settings.useTsExtension ??= true;\n const makeImport = (moduleSpecifier: string) => {\n return settings.useTsExtension ? `${moduleSpecifier}.ts` : moduleSpecifier;\n };\n const { commonSchemas, groups, outputs, commonZod } = generateCode({\n spec,\n style: 'github',\n target: 'javascript',\n makeImport,\n });\n const output =\n settings.mode === 'full' ? join(settings.output, 'src') : settings.output;\n\n const options = security(spec);\n\n const clientFiles = generateSDK({\n name: settings.name || 'Client',\n operations: groups,\n servers: spec.servers?.map((server) => server.url) || [],\n options: options,\n makeImport,\n });\n\n // const readme = generateReadme(spec, {\n // name: settings.name || 'Client',\n // });\n\n const inputFiles = generateInputs(groups, commonZod, makeImport);\n\n await writeFiles(output, {\n 'outputs/.gitkeep': '',\n 'inputs/.gitkeep': '',\n 'models/.getkeep': '',\n // 'README.md': readme,\n });\n\n await writeFiles(join(output, 'http'), {\n 'interceptors.ts': interceptors,\n 'parse-response.ts': parseResponse,\n 'send-request.ts': `import z from 'zod';\nimport type { Interceptor } from './${makeImport('interceptors')}';\nimport { handleError } from './${makeImport('parse-response')}';\nimport { parse } from './${makeImport('parser')}';\n${sendRequest}`,\n 'response.ts': responseTxt,\n 'parser.ts': parserTxt,\n 'request.ts': requestTxt,\n });\n\n await writeFiles(join(output, 'outputs'), outputs);\n const modelsImports = Object.entries(commonSchemas).map(([name]) => name);\n await writeFiles(output, {\n ...clientFiles,\n ...inputFiles,\n ...Object.fromEntries(\n Object.entries(commonSchemas).map(([name, schema]) => [\n `models/${name}.ts`,\n [\n `import { z } from 'zod';`,\n ...exclude(modelsImports, [name]).map(\n (it) => `import type { ${it} } from './${it}.ts';`,\n ),\n `export type ${name} = ${schema};`,\n ].join('\\n'),\n ]),\n ),\n });\n\n const folders = [\n getFolderExports(output, settings.useTsExtension),\n getFolderExports(join(output, 'outputs'), settings.useTsExtension),\n getFolderExports(\n join(output, 'inputs'),\n settings.useTsExtension,\n ['ts'],\n (dirent) => dirent.isDirectory() && dirent.name === 'schemas',\n ),\n getFolderExports(join(output, 'http'), settings.useTsExtension),\n ];\n if (modelsImports.length) {\n folders.push(\n getFolderExports(join(output, 'models'), settings.useTsExtension),\n );\n }\n const [index, outputIndex, inputsIndex, httpIndex, modelsIndex] =\n await Promise.all(folders);\n await writeFiles(output, {\n 'index.ts': index,\n 'outputs/index.ts': outputIndex,\n 'inputs/index.ts': inputsIndex || null,\n 'http/index.ts': httpIndex,\n ...(modelsImports.length ? { 'models/index.ts': modelsIndex } : {}),\n });\n if (settings.mode === 'full') {\n await writeFiles(settings.output, {\n 'package.json': {\n ignoreIfExists: true,\n content: JSON.stringify(\n {\n name: 'sdk',\n type: 'module',\n main: './src/index.ts',\n dependencies: {\n 'fast-content-type-parse': '^3.0.0',\n zod: '^3.24.2',\n },\n },\n null,\n 2,\n ),\n },\n 'tsconfig.json': {\n ignoreIfExists: true,\n content: JSON.stringify(\n {\n compilerOptions: {\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n target: 'ESNext',\n module: 'ESNext',\n noEmit: true,\n strict: true,\n allowImportingTsExtensions: true,\n verbatimModuleSyntax: true,\n baseUrl: '.',\n moduleResolution: 'bundler',\n },\n include: ['**/*.ts'],\n },\n null,\n 2,\n ),\n },\n });\n }\n\n await settings.formatCode?.({\n output: output,\n env: npmRunPathEnv(),\n });\n}\n", "import { get, merge } from 'lodash-es';\nimport type {\n ContentObject,\n OpenAPIObject,\n OperationObject,\n ParameterLocation,\n ParameterObject,\n ReferenceObject,\n ResponseObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\nimport { camelcase, pascalcase, spinalcase } from 'stringcase';\n\nimport { TypeScriptDeserialzer } from './emitters/interface.ts';\nimport { ZodDeserialzer } from './emitters/zod.ts';\nimport {\n type Operation,\n type OperationInput,\n type Parser,\n type Spec,\n} from './sdk.ts';\nimport { followRef, isRef, securityToOptions, useImports } from './utils.ts';\n\nexport interface NamedImport {\n name: string;\n alias?: string;\n isTypeOnly: boolean;\n}\nexport interface Import {\n isTypeOnly: boolean;\n moduleSpecifier: string;\n defaultImport: string | undefined;\n namedImports: NamedImport[];\n namespaceImport: string | undefined;\n}\n\nconst responses: Record<string, string> = {\n '400': 'BadRequest',\n '401': 'Unauthorized',\n '402': 'PaymentRequired',\n '403': 'Forbidden',\n '404': 'NotFound',\n '405': 'MethodNotAllowed',\n '406': 'NotAcceptable',\n '409': 'Conflict',\n '413': 'PayloadTooLarge',\n '410': 'Gone',\n '422': 'UnprocessableEntity',\n '429': 'TooManyRequests',\n '500': 'InternalServerError',\n '501': 'NotImplemented',\n '502': 'BadGateway',\n '503': 'ServiceUnavailable',\n '504': 'GatewayTimeout',\n};\n\nexport interface GenerateSdkConfig {\n spec: OpenAPIObject;\n target?: 'javascript';\n /**\n * No support for jsdoc in vscode\n * @issue https://github.com/microsoft/TypeScript/issues/38106\n */\n style?: 'github';\n operationId?: (\n operation: OperationObject,\n path: string,\n method: string,\n ) => string;\n makeImport: (module: string) => string;\n}\n\nexport const defaults: Partial<GenerateSdkConfig> &\n Required<Pick<GenerateSdkConfig, 'operationId'>> = {\n target: 'javascript',\n style: 'github',\n operationId: (operation, path, method) => {\n if (operation.operationId) {\n return spinalcase(operation.operationId);\n }\n return camelcase(`${method} ${path.replace(/[\\\\/\\\\{\\\\}]/g, ' ').trim()}`);\n },\n};\n\nexport function generateCode(config: GenerateSdkConfig) {\n const commonSchemas: Record<string, string> = {};\n const commonZod = new Map<string, string>();\n const commonZodImports: Import[] = [];\n const zodDeserialzer = new ZodDeserialzer(config.spec, (model, schema) => {\n commonZod.set(model, schema);\n commonZodImports.push({\n defaultImport: undefined,\n isTypeOnly: true,\n moduleSpecifier: `./${config.makeImport(model)}`,\n namedImports: [{ isTypeOnly: true, name: model }],\n namespaceImport: undefined,\n });\n });\n\n const groups: Spec['operations'] = {};\n const outputs: Record<string, string> = {};\n\n for (const [path, methods] of Object.entries(config.spec.paths ?? {})) {\n for (const [method, operation] of Object.entries(methods) as [\n string,\n OperationObject,\n ][]) {\n const formatOperationId = config.operationId ?? defaults.operationId;\n const operationName = formatOperationId(operation, path, method);\n\n console.log(`Processing ${method} ${path}`);\n const [groupName] = Array.isArray(operation.tags)\n ? operation.tags\n : ['unknown'];\n groups[groupName] ??= [];\n const inputs: Operation['inputs'] = {};\n\n const additionalProperties: ParameterObject[] = [];\n for (const param of operation.parameters ?? []) {\n if (isRef(param)) {\n throw new Error(`Found reference in parameter ${param.$ref}`);\n }\n if (!param.schema) {\n throw new Error(`Schema not found for parameter ${param.name}`);\n }\n inputs[param.name] = {\n in: param.in,\n schema: '',\n };\n additionalProperties.push(param);\n }\n\n const security = operation.security ?? [];\n const securitySchemas = config.spec.components?.securitySchemes ?? {};\n\n const securityOptions = securityToOptions(security, securitySchemas);\n\n Object.assign(inputs, securityOptions);\n\n additionalProperties.push(\n ...Object.entries(securityOptions).map(\n ([name, value]) =>\n ({\n name: name,\n required: false,\n schema: {\n type: 'string',\n },\n in: value.in as ParameterLocation,\n }) satisfies ParameterObject,\n ),\n );\n\n const types: Record<string, string> = {};\n const shortContenTypeMap: Record<string, string> = {\n 'application/json': 'json',\n 'application/x-www-form-urlencoded': 'urlencoded',\n 'multipart/form-data': 'formdata',\n 'application/xml': 'xml',\n 'text/plain': 'text',\n };\n let outgoingContentType: string | undefined;\n if (operation.requestBody && Object.keys(operation.requestBody).length) {\n const content: ContentObject = isRef(operation.requestBody)\n ? get(followRef(config.spec, operation.requestBody.$ref), ['content'])\n : operation.requestBody.content;\n\n for (const type in content) {\n const ctSchema = isRef(content[type].schema)\n ? followRef(config.spec, content[type].schema.$ref)\n : content[type].schema;\n if (!ctSchema) {\n console.warn(`Schema not found for ${type}`);\n continue;\n }\n\n const schema = merge({}, ctSchema, {\n required: additionalProperties\n .filter((p) => p.required)\n .map((p) => p.name),\n properties: additionalProperties.reduce<Record<string, unknown>>(\n (acc, p) => ({\n ...acc,\n [p.name]: p.schema,\n }),\n {},\n ),\n });\n\n Object.assign(inputs, bodyInputs(config, ctSchema));\n types[shortContenTypeMap[type]] = zodDeserialzer.handle(schema, true);\n }\n\n if (content['application/json']) {\n outgoingContentType = 'json';\n } else if (content['application/x-www-form-urlencoded']) {\n outgoingContentType = 'urlencoded';\n } else if (content['multipart/form-data']) {\n outgoingContentType = 'formdata';\n } else {\n outgoingContentType = 'json';\n }\n } else {\n const properties = additionalProperties.reduce<Record<string, any>>(\n (acc, p) => ({\n ...acc,\n [p.name]: p.schema,\n }),\n {},\n );\n types[shortContenTypeMap['application/json']] = zodDeserialzer.handle(\n {\n type: 'object',\n required: additionalProperties\n .filter((p) => p.required)\n .map((p) => p.name),\n properties,\n },\n true,\n );\n }\n\n const errors: string[] = [];\n operation.responses ??= {};\n\n let foundResponse = false;\n const output = [`import z from 'zod';`];\n let parser: Parser = 'buffered';\n for (const status in operation.responses) {\n const response = isRef(\n operation.responses[status] as ResponseObject | ReferenceObject,\n )\n ? (followRef(\n config.spec,\n operation.responses[status].$ref,\n ) as ResponseObject)\n : (operation.responses[status] as ResponseObject);\n const statusCode = +status;\n if (statusCode >= 400) {\n errors.push(responses[status] ?? 'ProblematicResponse');\n }\n if (statusCode >= 200 && statusCode < 300) {\n foundResponse = true;\n const responseContent = get(response, ['content']);\n const isJson = responseContent && responseContent['application/json'];\n if ((response.headers ?? {})['Transfer-Encoding']) {\n parser = 'chunked';\n }\n // TODO: how the user is going to handle multiple response types\n const imports: Import[] = [];\n const typeScriptDeserialzer = new TypeScriptDeserialzer(\n config.spec,\n (schemaName, zod) => {\n commonSchemas[schemaName] = zod;\n imports.push({\n defaultImport: undefined,\n isTypeOnly: true,\n moduleSpecifier: `../models/${config.makeImport(schemaName)}`,\n namedImports: [{ isTypeOnly: true, name: schemaName }],\n namespaceImport: undefined,\n });\n },\n );\n const responseSchema = isJson\n ? typeScriptDeserialzer.handle(\n responseContent['application/json'].schema!,\n true,\n )\n : 'ReadableStream'; // non-json response treated as stream\n output.push(...useImports(responseSchema, imports));\n output.push(\n `export type ${pascalcase(operationName + ' output')} = ${responseSchema}`,\n );\n }\n }\n\n if (!foundResponse) {\n output.push(\n `export type ${pascalcase(operationName + ' output')} = void`,\n );\n }\n outputs[`${spinalcase(operationName)}.ts`] = output.join('\\n');\n groups[groupName].push({\n name: operationName,\n type: 'http',\n inputs,\n errors: errors.length ? errors : ['ServerError'],\n outgoingContentType,\n schemas: types,\n parser,\n formatOutput: () => ({\n import: pascalcase(operationName + ' output'),\n use: pascalcase(operationName + ' output'),\n }),\n trigger: {\n path,\n method,\n },\n });\n }\n }\n\n return { groups, commonSchemas, commonZod, outputs };\n}\n\n// TODO - USE CASES\n// 1. Some parameters conflicts with request body\n// 2. Generate 400 and 500 response variations // done\n// 3. Generate 200 response variations\n// 3. Doc Security\n// 4. Operation Security\n// 5. JsDocs\n// 5. test all different types of parameters\n// 6. cookies\n// 6. x-www-form-urlencoded // done\n// 7. multipart/form-data // done\n// 7. application/octet-stream // done\n// 7. chunked response // done\n\nfunction toProps(\n spec: OpenAPIObject,\n schemaOrRef: SchemaObject | ReferenceObject,\n aggregator: string[] = [],\n) {\n if (isRef(schemaOrRef)) {\n const schema = followRef(spec, schemaOrRef.$ref);\n return toProps(spec, schema, aggregator);\n } else if (schemaOrRef.type === 'object') {\n for (const [name] of Object.entries(schemaOrRef.properties ?? {})) {\n aggregator.push(name);\n }\n return void 0;\n } else if (schemaOrRef.allOf) {\n for (const it of schemaOrRef.allOf) {\n toProps(spec, it, aggregator);\n }\n return void 0;\n }\n}\n\nfunction bodyInputs(\n config: GenerateSdkConfig,\n ctSchema: SchemaObject | ReferenceObject,\n) {\n const props: string[] = [];\n toProps(config.spec, ctSchema, props);\n return props.reduce<Record<string, OperationInput>>(\n (acc, prop) => ({\n ...acc,\n [prop]: {\n in: 'body',\n schema: '',\n },\n }),\n {},\n );\n}\n", "import { get } from 'lodash-es';\nimport type {\n ComponentsObject,\n OpenAPIObject,\n ReferenceObject,\n SchemaObject,\n SecurityRequirementObject,\n} from 'openapi3-ts/oas31';\n\nimport { removeDuplicates } from '@sdk-it/core';\n\nimport { type Options } from './sdk.ts';\n\nexport function isRef(obj: any): obj is ReferenceObject {\n return '$ref' in obj;\n}\n\nexport function cleanRef(ref: string) {\n return ref.replace(/^#\\//, '');\n}\n\nexport function parseRef(ref: string) {\n const parts = ref.split('/');\n const [model] = parts.splice(-1);\n return { model, path: parts.join('/') };\n}\nexport function followRef(spec: OpenAPIObject, ref: string): SchemaObject {\n const pathParts = cleanRef(ref).split('/');\n const entry = get(spec, pathParts) as SchemaObject | ReferenceObject;\n if (entry && '$ref' in entry) {\n return followRef(spec, entry.$ref);\n }\n return entry;\n}\nexport function securityToOptions(\n security: SecurityRequirementObject[],\n securitySchemas: ComponentsObject['securitySchemes'],\n staticIn?: string,\n) {\n securitySchemas ??= {};\n const options: Options = {};\n for (const it of security) {\n const [name] = Object.keys(it);\n const schema = securitySchemas[name];\n if (isRef(schema)) {\n throw new Error(`Ref security schemas are not supported`);\n }\n if (schema.type === 'http') {\n options['authorization'] = {\n in: staticIn ?? 'header',\n schema:\n 'z.string().optional().transform((val) => (val ? `Bearer ${val}` : undefined))',\n optionName: 'token',\n };\n continue;\n }\n if (schema.type === 'apiKey') {\n if (!schema.in) {\n throw new Error(`apiKey security schema must have an \"in\" field`);\n }\n if (!schema.name) {\n throw new Error(`apiKey security schema must have a \"name\" field`);\n }\n options[schema.name] = {\n in: staticIn ?? schema.in,\n schema: 'z.string().optional()',\n };\n continue;\n }\n }\n return options;\n}\n\nexport function mergeImports(imports: Import[]) {\n const merged: Record<string, Import> = {};\n\n for (const i of imports) {\n merged[i.moduleSpecifier] = merged[i.moduleSpecifier] ?? {\n moduleSpecifier: i.moduleSpecifier,\n defaultImport: i.defaultImport,\n namespaceImport: i.namespaceImport,\n namedImports: [],\n };\n if (i.namedImports) {\n merged[i.moduleSpecifier].namedImports.push(...i.namedImports);\n }\n }\n\n return Object.values(merged);\n}\nexport interface Import {\n isTypeOnly: boolean;\n moduleSpecifier: string;\n defaultImport: string | undefined;\n namedImports: NamedImport[];\n namespaceImport: string | undefined;\n}\nexport interface NamedImport {\n name: string;\n alias?: string;\n isTypeOnly: boolean;\n}\n\nexport function importsToString(...imports: Import[]) {\n return imports.map((it) => {\n if (it.defaultImport) {\n return `import ${it.defaultImport} from '${it.moduleSpecifier}'`;\n }\n if (it.namespaceImport) {\n return `import * as ${it.namespaceImport} from '${it.moduleSpecifier}'`;\n }\n if (it.namedImports) {\n return `import {${removeDuplicates(it.namedImports, (it) => it.name)\n .map((n) => `${n.isTypeOnly ? 'type' : ''} ${n.name}`)\n .join(', ')}} from '${it.moduleSpecifier}'`;\n }\n throw new Error(`Invalid import ${JSON.stringify(it)}`);\n });\n}\n\nexport function exclude<T>(list: T[], exclude: T[]): T[] {\n return list.filter((it) => !exclude.includes(it));\n}\n\nexport function useImports(content: string, imports: Import[]) {\n const output: string[] = [];\n for (const it of mergeImports(imports)) {\n const singleImport = it.defaultImport ?? it.namespaceImport;\n if (singleImport && content.includes(singleImport)) {\n output.push(importsToString(it).join('\\n'));\n } else if (it.namedImports.length) {\n for (const namedImport of it.namedImports) {\n if (content.includes(namedImport.name)) {\n output.push(importsToString(it).join('\\n'));\n }\n }\n }\n }\n return output;\n}\n\nexport type MakeImportFn = (moduleSpecifier: string) => string;\n", "import { camelcase, spinalcase } from 'stringcase';\n\nimport { removeDuplicates, toLitObject } from '@sdk-it/core';\n\nimport backend from './client.ts';\nimport type { MakeImportFn } from './utils.ts';\n\nexport type Parser = 'chunked' | 'buffered';\nclass SchemaEndpoint {\n #makeImport: MakeImportFn;\n #imports: string[] = [];\n constructor(makeImport: MakeImportFn) {\n this.#makeImport = makeImport;\n this.#imports = [\n `import z from 'zod';`,\n `import type { Endpoints } from '${this.#makeImport('./endpoints')}';`,\n `import { toRequest, json, urlencoded, nobody, formdata, createUrl } from '${this.#makeImport('./http/request')}';`,\n `import type { ParseError } from '${this.#makeImport('./http/parser')}';`,\n `import { chunked, buffered } from \"${this.#makeImport('./http/parse-response')}\";`,\n ];\n }\n\n #endpoints: string[] = [];\n\n addEndpoint(endpoint: string, operation: string) {\n this.#endpoints.push(` \"${endpoint}\": ${operation},`);\n }\n\n addImport(value: string) {\n this.#imports.push(value);\n }\n\n complete() {\n return `${this.#imports.join('\\n')}\\nexport default {\\n${this.#endpoints.join('\\n')}\\n}`;\n }\n}\nclass Emitter {\n #makeImport: MakeImportFn;\n protected imports: string[] = [];\n constructor(makeImport: MakeImportFn) {\n this.#makeImport = makeImport;\n this.imports = [\n `import type z from 'zod';`,\n `import type { ParseError } from '${this.#makeImport('./http/parser')}';`,\n ];\n }\n protected endpoints: string[] = [];\n addEndpoint(endpoint: string, operation: string) {\n this.endpoints.push(` \"${endpoint}\": ${operation};`);\n }\n addImport(value: string) {\n this.imports.push(value);\n }\n complete() {\n return `${this.imports.join('\\n')}\\nexport interface Endpoints {\\n${this.endpoints.join('\\n')}\\n}`;\n }\n}\n\nexport interface SdkConfig {\n /**\n * The name of the sdk client\n */\n name: string;\n packageName?: string;\n options?: Record<string, any>;\n emptyBodyAsNull?: boolean;\n stripBodyFromGetAndHead?: boolean;\n output: string;\n}\n\nexport type Options = Record<\n string,\n {\n in: string;\n schema: string;\n optionName?: string;\n }\n>;\nexport interface Spec {\n operations: Record<string, Operation[]>;\n name: string;\n options: Options;\n servers: string[];\n makeImport: MakeImportFn;\n}\n\nexport interface OperationInput {\n in: string;\n schema: string;\n}\nexport interface Operation {\n name: string;\n errors: string[];\n type: string;\n trigger: Record<string, any>;\n outgoingContentType?: string;\n parser: Parser;\n schemas: Record<string, string>;\n inputs: Record<string, OperationInput>;\n formatOutput: () => { import: string; use: string };\n}\n\nexport function generateInputs(\n operationsSet: Spec['operations'],\n commonZod: Map<string, string>,\n makeImport: MakeImportFn,\n) {\n const commonImports = commonZod.keys().toArray();\n const inputs: Record<string, string> = {};\n for (const [name, operations] of Object.entries(operationsSet)) {\n const output: string[] = [];\n const imports = new Set(['import { z } from \"zod\";']);\n\n for (const operation of operations) {\n const schemaName = camelcase(`${operation.name} schema`);\n\n const schema = `export const ${schemaName} = ${\n Object.keys(operation.schemas).length === 1\n ? Object.values(operation.schemas)[0]\n : toLitObject(operation.schemas)\n };`;\n\n const inputContent = schema;\n\n for (const schema of commonImports) {\n if (inputContent.includes(schema)) {\n imports.add(\n `import { ${schema} } from './schemas/${makeImport(spinalcase(schema))}';`,\n );\n }\n }\n output.push(inputContent);\n }\n inputs[`inputs/${spinalcase(name)}.ts`] =\n [...imports, ...output].join('\\n') + '\\n';\n }\n\n const schemas = commonZod\n .entries()\n .reduce<string[][]>((acc, [name, schema]) => {\n const output = [`import { z } from 'zod';`];\n const content = `export const ${name} = ${schema};`;\n for (const schema of commonImports) {\n const preciseMatch = new RegExp(`\\\\b${schema}\\\\b`);\n if (preciseMatch.test(content) && schema !== name) {\n output.push(\n `import { ${schema} } from './${makeImport(spinalcase(schema))}';`,\n );\n }\n }\n\n output.push(content);\n return [\n [`inputs/schemas/${spinalcase(name)}.ts`, output.join('\\n')],\n ...acc,\n ];\n }, []);\n\n return {\n ...Object.fromEntries(schemas),\n ...inputs,\n };\n}\n\nexport function generateSDK(spec: Spec) {\n const emitter = new Emitter(spec.makeImport);\n const schemaEndpoint = new SchemaEndpoint(spec.makeImport);\n const errors: string[] = [];\n for (const [name, operations] of Object.entries(spec.operations)) {\n emitter.addImport(\n `import type * as ${camelcase(name)} from './inputs/${spec.makeImport(spinalcase(name))}';`,\n );\n schemaEndpoint.addImport(\n `import * as ${camelcase(name)} from './inputs/${spec.makeImport(spinalcase(name))}';`,\n );\n for (const operation of operations) {\n const schemaName = camelcase(`${operation.name} schema`);\n const schemaRef = `${camelcase(name)}.${schemaName}`;\n const output = operation.formatOutput();\n const inputHeaders: string[] = [];\n const inputQuery: string[] = [];\n const inputBody: string[] = [];\n const inputParams: string[] = [];\n for (const [name, prop] of Object.entries(operation.inputs)) {\n if (prop.in === 'headers' || prop.in === 'header') {\n inputHeaders.push(`\"${name}\"`);\n } else if (prop.in === 'query') {\n inputQuery.push(`\"${name}\"`);\n } else if (prop.in === 'body') {\n inputBody.push(`\"${name}\"`);\n } else if (prop.in === 'path') {\n inputParams.push(`\"${name}\"`);\n } else if (prop.in === 'internal') {\n // ignore internal sources\n continue;\n } else {\n throw new Error(\n `Unknown source ${prop.in} in ${name} ${JSON.stringify(\n prop,\n )} in ${operation.name}`,\n );\n }\n }\n emitter.addImport(\n `import type {${output.import}} from './outputs/${spec.makeImport(spinalcase(operation.name))}';`,\n );\n errors.push(...(operation.errors ?? []));\n\n const addTypeParser = Object.keys(operation.schemas).length > 1;\n for (const type in operation.schemas ?? {}) {\n let typePrefix = '';\n if (addTypeParser && type !== 'json') {\n typePrefix = `${type} `;\n }\n const input = `typeof ${schemaRef}${addTypeParser ? `.${type}` : ''}`;\n\n const endpoint = `${typePrefix}${operation.trigger.method.toUpperCase()} ${operation.trigger.path}`;\n emitter.addEndpoint(\n endpoint,\n `{input: z.infer<${input}>; output: ${output.use}; error: ${(operation.errors ?? ['ServerError']).concat(`ParseError<${input}>`).join('|')}}`,\n );\n schemaEndpoint.addEndpoint(\n endpoint,\n `{\n schema: ${schemaRef}${addTypeParser ? `.${type}` : ''},\n deserializer: ${operation.parser === 'chunked' ? 'chunked' : 'buffered'},\n toRequest(input: Endpoints['${endpoint}']['input']) {\n const endpoint = '${endpoint}';\n return toRequest(endpoint, ${operation.outgoingContentType || 'nobody'}(input, {\n inputHeaders: [${inputHeaders}],\n inputQuery: [${inputQuery}],\n inputBody: [${inputBody}],\n inputParams: [${inputParams}],\n }));\n },\n }`,\n );\n }\n }\n }\n\n emitter.addImport(\n `import type { ${removeDuplicates(errors, (it) => it).join(', ')} } from '${spec.makeImport('./http/response')}';`,\n );\n return {\n 'client.ts': backend(spec),\n 'schemas.ts': schemaEndpoint.complete(),\n 'endpoints.ts': emitter.complete(),\n };\n}\n", "import { toLitObject } from '@sdk-it/core';\n\nimport type { Spec } from './sdk.ts';\n\nexport default (spec: Spec) => {\n const optionsEntries = Object.entries(spec.options).map(\n ([key, value]) => [`'${key}'`, value] as const,\n );\n const defaultHeaders = `{${optionsEntries\n .filter(([, value]) => value.in === 'header')\n .map(\n ([key, value]) =>\n `${key}: this.options[${value.optionName ? `'${value.optionName}'` : key}]`,\n )\n .join(',\\n')}}`;\n const defaultInputs = `{${optionsEntries\n .filter(([, value]) => value.in === 'input')\n .map(\n ([key, value]) =>\n `${key}: this.options[${value.optionName ? `'${value.optionName}'` : key}]`,\n )\n .join(',\\n')}}`;\n const specOptions: Record<string, { schema: string }> = {\n ...Object.fromEntries(\n optionsEntries.map(([key, value]) => [value.optionName ?? key, value]),\n ),\n fetch: {\n schema: 'fetchType',\n },\n baseUrl: {\n schema: spec.servers.length\n ? `z.enum(servers).default(servers[0])`\n : 'z.string()',\n },\n };\n\n return `\nimport { fetchType, sendRequest } from './http/${spec.makeImport('send-request')}';\nimport z from 'zod';\nimport type { Endpoints } from './${spec.makeImport('endpoints')}';\nimport schemas from './${spec.makeImport('schemas')}';\nimport {\n createBaseUrlInterceptor,\n createDefaultHeadersInterceptor,\n} from './http/${spec.makeImport('interceptors')}';\n\n${spec.servers.length ? `export const servers = ${JSON.stringify(spec.servers, null, 2)} as const` : ''}\nconst optionsSchema = z.object(${toLitObject(specOptions, (x) => x.schema)});\n${spec.servers.length ? `export type Servers = typeof servers[number];` : ''}\n\ntype ${spec.name}Options = z.infer<typeof optionsSchema>;\n\nexport class ${spec.name} {\n public options: ${spec.name}Options\n constructor(options: ${spec.name}Options) {\n this.options = optionsSchema.parse(options);\n }\n\n async request<E extends keyof Endpoints>(\n endpoint: E,\n input: Endpoints[E]['input'],\n ): Promise<readonly [Endpoints[E]['output'], Endpoints[E]['error'] | null]> {\n const route = schemas[endpoint];\n return sendRequest(Object.assign(this.#defaultInputs, input), route, {\n fetch: this.options.fetch,\n interceptors: [\n createDefaultHeadersInterceptor(() => this.defaultHeaders),\n createBaseUrlInterceptor(() => this.options.baseUrl),\n ],\n });\n }\n\n get defaultHeaders() {\n return ${defaultHeaders}\n }\n\n get #defaultInputs() {\n return ${defaultInputs}\n }\n\n setOptions(options: Partial<${spec.name}Options>) {\n const validated = optionsSchema.partial().parse(options);\n\n for (const key of Object.keys(validated) as (keyof ${spec.name}Options)[]) {\n if (validated[key] !== undefined) {\n (this.options[key] as typeof validated[typeof key]) = validated[key]!;\n }\n }\n }\n}`;\n};\n", "import type {\n OpenAPIObject,\n ReferenceObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { cleanRef, followRef, isRef, parseRef } from '../utils.ts';\n\ntype OnRefCallback = (ref: string, interfaceContent: string) => void;\n\n/**\n * Convert an OpenAPI (JSON Schema style) object into TypeScript interfaces,\n * following the same pattern as ZodDeserialzer for easy interchangeability.\n */\nexport class TypeScriptDeserialzer {\n circularRefTracker = new Set<string>();\n #spec: OpenAPIObject;\n #onRef: OnRefCallback;\n\n constructor(spec: OpenAPIObject, onRef: OnRefCallback) {\n this.#spec = spec;\n this.#onRef = onRef;\n }\n #stringifyKey = (key: string): string => {\n // List of JavaScript keywords and special object properties that should be quoted\n const reservedWords = [\n 'constructor',\n 'prototype',\n 'break',\n 'case',\n 'catch',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'export',\n 'extends',\n 'false',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'import',\n 'in',\n 'instanceof',\n 'new',\n 'null',\n 'return',\n 'super',\n 'switch',\n 'this',\n 'throw',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'yield',\n ];\n\n // Check if key is a reserved word\n if (reservedWords.includes(key)) {\n return `'${key}'`;\n }\n\n // Check if key is empty or only whitespace\n if (key.trim() === '') {\n return `'${key}'`;\n }\n\n // Check if first character is valid for identifiers\n const firstChar = key.charAt(0);\n const validFirstChar =\n (firstChar >= 'a' && firstChar <= 'z') ||\n (firstChar >= 'A' && firstChar <= 'Z') ||\n firstChar === '_' ||\n firstChar === '$';\n\n if (!validFirstChar) {\n return `'${key.replace(/'/g, \"\\\\'\")}'`;\n }\n\n // Check if the rest of the characters are valid for identifiers\n for (let i = 1; i < key.length; i++) {\n const char = key.charAt(i);\n const validChar =\n (char >= 'a' && char <= 'z') ||\n (char >= 'A' && char <= 'Z') ||\n (char >= '0' && char <= '9') ||\n char === '_' ||\n char === '$';\n\n if (!validChar) {\n return `'${key.replace(/'/g, \"\\\\'\")}'`;\n }\n }\n\n return key;\n };\n #stringifyKeyV2 = (value: string): string => {\n return `'${value}'`;\n };\n\n /**\n * Handle objects (properties)\n */\n object(schema: SchemaObject, required = false): string {\n const properties = schema.properties || {};\n\n // Convert each property\n const propEntries = Object.entries(properties).map(([key, propSchema]) => {\n const isRequired = (schema.required ?? []).includes(key);\n const tsType = this.handle(propSchema, isRequired);\n // Add question mark for optional properties\n return `${this.#stringifyKeyV2(key)}: ${tsType}`;\n });\n\n // Handle additionalProperties\n if (schema.additionalProperties) {\n if (typeof schema.additionalProperties === 'object') {\n const indexType = this.handle(schema.additionalProperties, true);\n propEntries.push(`[key: string]: ${indexType}`);\n } else if (schema.additionalProperties === true) {\n propEntries.push('[key: string]: any');\n }\n }\n\n return `{ ${propEntries.join('; ')} }`;\n }\n\n /**\n * Handle arrays (items could be a single schema or a tuple)\n */\n array(schema: SchemaObject, required = false): string {\n const { items } = schema;\n if (!items) {\n // No items => any[]\n return 'any[]';\n }\n\n // If items is an array => tuple\n if (Array.isArray(items)) {\n const tupleItems = items.map((sub) => this.handle(sub, true));\n return `[${tupleItems.join(', ')}]`;\n }\n\n // If items is a single schema => standard array\n const itemsType = this.handle(items, true);\n return `${itemsType}[]`;\n }\n\n /**\n * Convert a basic type (string | number | boolean | object | array, etc.) to TypeScript\n */\n normal(type: string, schema: SchemaObject, required = false): string {\n switch (type) {\n case 'string':\n return this.string(schema, required);\n case 'number':\n case 'integer':\n return this.number(schema, required);\n case 'boolean':\n return appendOptional('boolean', required);\n case 'object':\n return this.object(schema, required);\n case 'array':\n return this.array(schema, required);\n case 'null':\n return 'null';\n default:\n // Unknown type -> fallback\n return appendOptional('any', required);\n }\n }\n\n ref($ref: string, required: boolean): string {\n const schemaName = cleanRef($ref).split('/').pop()!;\n\n if (this.circularRefTracker.has(schemaName)) {\n return schemaName;\n }\n\n this.circularRefTracker.add(schemaName);\n this.#onRef(schemaName, this.handle(followRef(this.#spec, $ref), true));\n this.circularRefTracker.delete(schemaName);\n\n return appendOptional(schemaName, required);\n }\n\n allOf(schemas: (SchemaObject | ReferenceObject)[]): string {\n // For TypeScript we use intersection types for allOf\n const allOfTypes = schemas.map((sub) => this.handle(sub, true));\n return allOfTypes.length > 1 ? `${allOfTypes.join(' & ')}` : allOfTypes[0];\n }\n\n anyOf(\n schemas: (SchemaObject | ReferenceObject)[],\n required: boolean,\n ): string {\n // For TypeScript we use union types for anyOf/oneOf\n const anyOfTypes = schemas.map((sub) => this.handle(sub, true));\n return appendOptional(\n anyOfTypes.length > 1 ? `${anyOfTypes.join(' | ')}` : anyOfTypes[0],\n required,\n );\n }\n\n oneOf(\n schemas: (SchemaObject | ReferenceObject)[],\n required: boolean,\n ): string {\n const oneOfTypes = schemas.map((sub) => {\n if (isRef(sub)) {\n const { model } = parseRef(sub.$ref);\n if (this.circularRefTracker.has(model)) {\n return model;\n }\n }\n return this.handle(sub, false);\n });\n return appendOptional(\n oneOfTypes.length > 1 ? `${oneOfTypes.join(' | ')}` : oneOfTypes[0],\n required,\n );\n }\n\n enum(values: any[], required: boolean): string {\n // For TypeScript enums as union of literals\n const enumValues = values\n .map((val) => (typeof val === 'string' ? `'${val}'` : `${val}`))\n .join(' | ');\n return appendOptional(enumValues, required);\n }\n\n /**\n * Handle string type with formats\n */\n string(schema: SchemaObject, required?: boolean): string {\n let type: string;\n\n switch (schema.format) {\n case 'date-time':\n case 'datetime':\n case 'date':\n type = 'Date';\n break;\n case 'binary':\n case 'byte':\n type = 'Blob';\n break;\n case 'int64':\n type = 'bigint';\n break;\n default:\n type = 'string';\n }\n\n return appendOptional(type, required);\n }\n\n /**\n * Handle number/integer types with formats\n */\n number(schema: SchemaObject, required?: boolean): string {\n const type = schema.format === 'int64' ? 'bigint' : 'number';\n return appendOptional(type, required);\n }\n\n handle(schema: SchemaObject | ReferenceObject, required: boolean): string {\n if (isRef(schema)) {\n return this.ref(schema.$ref, required);\n }\n\n // Handle allOf (intersection in TypeScript)\n if (schema.allOf && Array.isArray(schema.allOf)) {\n return this.allOf(schema.allOf);\n }\n\n // anyOf (union in TypeScript)\n if (schema.anyOf && Array.isArray(schema.anyOf)) {\n return this.anyOf(schema.anyOf, required);\n }\n\n // oneOf (union in TypeScript)\n if (schema.oneOf && Array.isArray(schema.oneOf)) {\n return this.oneOf(schema.oneOf, required);\n }\n\n // enum\n if (schema.enum && Array.isArray(schema.enum)) {\n return this.enum(schema.enum, required);\n }\n\n // Handle types, in TypeScript we can have union types directly\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n\n // If no explicit \"type\", fallback to any\n if (!types.length) {\n // unless properties are defined then assume object\n if ('properties' in schema) {\n return this.object(schema, required);\n }\n return appendOptional('any', required);\n }\n\n // Handle union types (multiple types)\n if (types.length > 1) {\n const realTypes = types.filter((t) => t !== 'null');\n if (realTypes.length === 1 && types.includes('null')) {\n // Single real type + \"null\"\n const tsType = this.normal(realTypes[0], schema, false);\n return appendOptional(`${tsType} | null`, required);\n }\n\n // Multiple different types\n const typeResults = types.map((t) => this.normal(t, schema, false));\n return appendOptional(typeResults.join(' | '), required);\n }\n\n // Single type\n return this.normal(types[0], schema, required);\n }\n\n /**\n * Generate an interface declaration\n */\n generateInterface(\n name: string,\n schema: SchemaObject | ReferenceObject,\n ): string {\n const content = this.handle(schema, true);\n return `interface ${name} ${content}`;\n }\n}\n\n/**\n * Append \"| undefined\" if not required\n */\nfunction appendOptional(type: string, isRequired?: boolean): string {\n return isRequired ? type : `${type} | undefined`;\n}\n", "import type {\n OpenAPIObject,\n ReferenceObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { cleanRef, followRef, isRef, parseRef } from '../utils.ts';\n\ntype OnRefCallback = (ref: string, zod: string) => void;\n\n/**\n * Convert an OpenAPI (JSON Schema style) object into a Zod schema string,\n * adapted for OpenAPI 3.1 (fully aligned with JSON Schema 2020-12).\n */\nexport class ZodDeserialzer {\n circularRefTracker = new Set<string>();\n #spec: OpenAPIObject;\n #onRef?: OnRefCallback;\n\n constructor(spec: OpenAPIObject, onRef?: OnRefCallback) {\n this.#spec = spec;\n this.#onRef = onRef;\n }\n /**\n * Handle objects (properties, additionalProperties).\n */\n object(schema: SchemaObject, required = false): string {\n const properties = schema.properties || {};\n\n // Convert each property\n const propEntries = Object.entries(properties).map(([key, propSchema]) => {\n const isRequired = (schema.required ?? []).includes(key);\n const zodPart = this.handle(propSchema, isRequired);\n return `'${key}': ${zodPart}`;\n });\n\n // additionalProperties\n let additionalProps = '';\n if (schema.additionalProperties) {\n if (typeof schema.additionalProperties === 'object') {\n // e.g. z.record() if it\u2019s an object schema\n const addPropZod = this.handle(schema.additionalProperties, true);\n additionalProps = `.catchall(${addPropZod})`;\n } else if (schema.additionalProperties === true) {\n // free-form additional props\n additionalProps = `.catchall(z.unknown())`;\n }\n }\n\n const objectSchema = `z.object({${propEntries.join(', ')}})${additionalProps}`;\n return `${objectSchema}${appendOptional(required)}`;\n }\n\n /**\n * Handle arrays (items could be a single schema or a tuple (array of schemas)).\n * In JSON Schema 2020-12, `items` can be an array \u2192 tuple style.\n */\n array(schema: SchemaObject, required = false): string {\n const { items } = schema;\n if (!items) {\n // No items => z.array(z.unknown())\n return `z.array(z.unknown())${appendOptional(required)}`;\n }\n\n // If items is an array => tuple\n if (Array.isArray(items)) {\n // Build a Zod tuple\n const tupleItems = items.map((sub) => this.handle(sub, true));\n const base = `z.tuple([${tupleItems.join(', ')}])`;\n // // If we have additionalItems: false => that\u2019s a fixed length\n // // If additionalItems is a schema => rest(...)\n // if (schema.additionalItems) {\n // if (typeof schema.additionalItems === 'object') {\n // const restSchema = jsonSchemaToZod(spec, schema.additionalItems, true);\n // base += `.rest(${restSchema})`;\n // }\n // // If `additionalItems: false`, no rest is allowed => do nothing\n // }\n return `${base}${appendOptional(required)}`;\n }\n\n // If items is a single schema => standard z.array(...)\n const itemsSchema = this.handle(items, true);\n return `z.array(${itemsSchema})${appendOptional(required)}`;\n }\n // oneOf() {}\n // enum() {}\n\n #suffixes = (defaultValue: unknown, required: boolean, nullable: boolean) => {\n return `${nullable ? '.nullable()' : ''}${appendDefault(defaultValue)}${appendOptional(required)}`;\n };\n\n /**\n * Convert a basic type (string | number | boolean | object | array, etc.) to Zod.\n * We'll also handle .optional() if needed.\n */\n normal(\n type: string,\n schema: SchemaObject,\n required = false,\n nullable = false,\n ): string {\n switch (type) {\n case 'string':\n return `${this.string(schema)}${this.#suffixes(schema.default, required, nullable)}`;\n case 'number':\n case 'integer': {\n const { base, defaultValue } = this.number(schema);\n return `${base}${this.#suffixes(defaultValue, required, nullable)}`;\n }\n case 'boolean':\n return `z.boolean()${this.#suffixes(schema.default, required, nullable)}`;\n case 'object':\n return this.object(schema, required);\n case 'array':\n return this.array(schema, required);\n case 'null':\n // If \"type\": \"null\" alone, this is basically z.null()\n return `z.null()${appendOptional(required)}`;\n default:\n // Unknown type -> fallback\n return `z.unknown()${appendOptional(required)}`;\n }\n }\n\n ref($ref: string, required: boolean) {\n const schemaName = cleanRef($ref).split('/').pop()!;\n\n if (this.circularRefTracker.has(schemaName)) {\n return schemaName;\n }\n\n this.circularRefTracker.add(schemaName);\n this.#onRef?.(\n schemaName,\n this.handle(followRef(this.#spec, $ref), required),\n );\n this.circularRefTracker.delete(schemaName);\n\n return schemaName;\n }\n allOf(schemas: (SchemaObject | ReferenceObject)[]) {\n const allOfSchemas = schemas.map((sub) => this.handle(sub, true));\n if (allOfSchemas.length === 0) {\n return `z.unknown()`;\n }\n if (allOfSchemas.length === 1) {\n return allOfSchemas[0];\n }\n return this.#toIntersection(allOfSchemas);\n }\n\n #toIntersection(schemas: string[]): string {\n const [left, ...right] = schemas;\n if (!right.length) {\n return left;\n }\n return `z.intersection(${left}, ${this.#toIntersection(right)})`;\n }\n\n anyOf(schemas: (SchemaObject | ReferenceObject)[], required: boolean) {\n const anyOfSchemas = schemas.map((sub) => this.handle(sub, false));\n if (anyOfSchemas.length === 1) {\n return anyOfSchemas[0];\n }\n return anyOfSchemas.length > 1\n ? `z.union([${anyOfSchemas.join(', ')}])${appendOptional(required)}`\n : // Handle an invalid anyOf with one schema\n anyOfSchemas[0];\n }\n\n oneOf(schemas: (SchemaObject | ReferenceObject)[], required: boolean) {\n const oneOfSchemas = schemas.map((sub) => {\n if ('$ref' in sub) {\n const { model } = parseRef(sub.$ref);\n if (this.circularRefTracker.has(model)) {\n return model;\n }\n }\n return this.handle(sub, false);\n });\n if (oneOfSchemas.length === 1) {\n return oneOfSchemas[0];\n }\n return oneOfSchemas.length > 1\n ? `z.union([${oneOfSchemas.join(', ')}])${appendOptional(required)}`\n : // Handle an invalid oneOf with one schema\n oneOfSchemas[0];\n }\n\n enum(values: any[], required: boolean) {\n const enumVals = values.map((val) => JSON.stringify(val)).join(', ');\n return `z.enum([${enumVals}])${appendOptional(required)}`;\n }\n\n /**\n * Handle a `string` schema with possible format keywords (JSON Schema).\n */\n string(schema: SchemaObject): string {\n let base = 'z.string()';\n\n // 3.1 replaces `example` in the schema with `examples` (array).\n // We do not strictly need them for the Zod type, so they\u2019re optional\n // for validation. However, we could keep them as metadata if you want.\n\n switch (schema.format) {\n case 'date-time':\n case 'datetime':\n // parse to JS Date\n base = 'z.coerce.date()';\n break;\n case 'date':\n base =\n 'z.coerce.date() /* or z.string() if you want raw date strings */';\n break;\n case 'time':\n base =\n 'z.string() /* optionally add .regex(...) for HH:MM:SS format */';\n break;\n case 'email':\n base = 'z.string().email()';\n break;\n case 'uuid':\n base = 'z.string().uuid()';\n break;\n case 'url':\n case 'uri':\n base = 'z.string().url()';\n break;\n case 'ipv4':\n base = 'z.string().ip({version: \"v4\"})';\n break;\n case 'ipv6':\n base = 'z.string().ip({version: \"v6\"})';\n break;\n case 'phone':\n base = 'z.string() /* or add .regex(...) for phone formats */';\n break;\n case 'byte':\n case 'binary':\n base = 'z.instanceof(Blob) /* consider base64 check if needed */';\n break;\n case 'int64':\n // JS numbers can't reliably store int64, consider z.bigint() or keep as string\n base = 'z.string() /* or z.bigint() if your app can handle it */';\n break;\n default:\n // No special format\n break;\n }\n\n return base;\n }\n\n /**\n * Handle number/integer constraints from OpenAPI/JSON Schema.\n * In 3.1, exclusiveMinimum/Maximum hold the actual numeric threshold,\n * rather than a boolean toggling `minimum`/`maximum`.\n */\n number(schema: SchemaObject) {\n let defaultValue = schema.default;\n let base = 'z.number()';\n if (schema.format === 'int64') {\n base = 'z.bigint()';\n if (schema.default !== undefined) {\n defaultValue = `BigInt(${schema.default})`;\n }\n }\n\n if (schema.format === 'int32') {\n // 32-bit integer\n base += '.int()';\n }\n\n // If we see exclusiveMinimum as a number in 3.1:\n if (typeof schema.exclusiveMinimum === 'number') {\n // Zod doesn\u2019t have a direct \"exclusiveMinimum\" method, so we can do .gt()\n // If exclusiveMinimum=7 => .gt(7)\n base += `.gt(${schema.exclusiveMinimum})`;\n }\n // Similarly for exclusiveMaximum\n if (typeof schema.exclusiveMaximum === 'number') {\n // If exclusiveMaximum=10 => .lt(10)\n base += `.lt(${schema.exclusiveMaximum})`;\n }\n\n // If standard minimum/maximum\n if (typeof schema.minimum === 'number') {\n base +=\n schema.format === 'int64'\n ? `.min(BigInt(${schema.minimum}))`\n : `.min(${schema.minimum})`;\n }\n if (typeof schema.maximum === 'number') {\n base +=\n schema.format === 'int64'\n ? `.max(BigInt(${schema.maximum}))`\n : `.max(${schema.maximum})`;\n }\n\n // multipleOf\n if (typeof schema.multipleOf === 'number') {\n // There's no direct multipleOf in Zod. Some folks do a custom refine.\n // For example:\n base += `.refine((val) => Number.isInteger(val / ${schema.multipleOf}), \"Must be a multiple of ${schema.multipleOf}\")`;\n }\n\n return { base, defaultValue };\n }\n\n handle(schema: SchemaObject | ReferenceObject, required: boolean): string {\n if (isRef(schema)) {\n return this.ref(schema.$ref, required);\n }\n\n // Handle allOf \u2192 intersection\n if (schema.allOf && Array.isArray(schema.allOf)) {\n return this.allOf(schema.allOf ?? []);\n }\n\n // anyOf \u2192 union\n if (schema.anyOf && Array.isArray(schema.anyOf)) {\n return this.anyOf(schema.anyOf ?? [], required);\n }\n\n // oneOf \u2192 union\n if (schema.oneOf && Array.isArray(schema.oneOf)) {\n return this.oneOf(schema.oneOf ?? [], required);\n }\n\n // enum\n if (schema.enum && Array.isArray(schema.enum)) {\n return this.enum(schema.enum, required);\n }\n\n // 3.1 can have type: string or type: string[] (e.g. [\"string\",\"null\"])\n // Let's parse that carefully.\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n\n // If no explicit \"type\", fallback to unknown\n if (!types.length) {\n return `z.unknown()${appendOptional(required)}`;\n }\n\n // If it's a union type (like [\"string\", \"null\"]), we'll build a Zod union\n // or apply .nullable() if it's just \"type + null\".\n\n // backward compatibility with openapi 3.0\n if ('nullable' in schema && schema.nullable) {\n types.push('null');\n }\n\n if (types.length > 1) {\n // If it\u2019s exactly one real type plus \"null\", we can do e.g. `z.string().nullable()`\n const realTypes = types.filter((t) => t !== 'null');\n if (realTypes.length === 1 && types.includes('null')) {\n // Single real type + \"null\"\n return this.normal(realTypes[0], schema, false, true);\n }\n // If multiple different types, build a union\n const subSchemas = types.map((t) => this.normal(t, schema, false));\n return `z.union([${subSchemas.join(', ')}])${appendOptional(required)}`;\n }\n return this.normal(types[0], schema, required, false);\n }\n}\n\n/**\n * Append .optional() if not required\n */\nfunction appendOptional(isRequired?: boolean) {\n return isRequired ? '' : '.optional()';\n}\nfunction appendDefault(defaultValue?: any) {\n return defaultValue !== undefined\n ? `.default(${JSON.stringify(defaultValue)})`\n : '';\n}\n\n// Todo: convert openapi 3.0 to 3.1 before proccesing\n", "export interface Interceptor {\n before?: (request: Request) => Promise<Request> | Request;\n after?: (response: Response) => Promise<Response> | Response;\n}\n\nexport const createDefaultHeadersInterceptor = (\n getHeaders: () => Record<string, string | undefined>,\n) => {\n return {\n before(request: Request) {\n const headers = getHeaders();\n\n for (const [key, value] of Object.entries(headers)) {\n // Only set the header if it doesn't already exist and has a value\n if (value !== undefined && !request.headers.has(key)) {\n request.headers.set(key, value);\n }\n }\n\n return request;\n },\n };\n};\n\nexport const createBaseUrlInterceptor = (getBaseUrl: () => string) => {\n return {\n before(request: Request) {\n const baseUrl = getBaseUrl();\n if (request.url.startsWith('local://')) {\n return new Request(request.url.replace('local://', baseUrl), request);\n }\n return request;\n },\n };\n};\n\nexport const logInterceptor = {\n before(request: Request) {\n console.log('Request', request);\n return request;\n },\n after(response: Response) {\n console.log('Response', response);\n return response;\n },\n};\n\n/**\n * Creates an interceptor that logs detailed information about requests and responses.\n * @param options Configuration options for the logger\n * @returns An interceptor object with before and after handlers\n */\nexport const createDetailedLogInterceptor = (options?: {\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n includeRequestBody?: boolean;\n includeResponseBody?: boolean;\n}) => {\n const logLevel = options?.logLevel || 'info';\n const includeRequestBody = options?.includeRequestBody || false;\n const includeResponseBody = options?.includeResponseBody || false;\n\n return {\n async before(request: Request) {\n const logData = {\n url: request.url,\n method: request.method,\n contentType: request.headers.get('Content-Type'),\n headers: Object.fromEntries([...request.headers.entries()]),\n };\n\n console[logLevel]('\uD83D\uDE80 Outgoing Request:', logData);\n\n if (includeRequestBody) {\n try {\n // Clone the request to avoid consuming the body stream\n const clonedRequest = request.clone();\n if (clonedRequest.headers.get('Content-Type')?.includes('application/json')) {\n const body = await clonedRequest.json().catch(() => null);\n console[logLevel]('Request Body:', body);\n } else {\n const body = await clonedRequest.text().catch(() => null);\n console[logLevel]('Request Body:', body);\n }\n } catch (error) {\n console.error('Could not log request body:', error);\n }\n }\n\n return request;\n },\n\n async after(response: Response) {\n const logData = {\n status: response.status,\n statusText: response.statusText,\n url: response.url,\n headers: Object.fromEntries([...response.headers.entries()]),\n };\n\n console[logLevel]('\uD83D\uDCE5 Incoming Response:', logData);\n\n if (includeResponseBody && response.body) {\n try {\n // Clone the response to avoid consuming the body stream\n const clonedResponse = response.clone();\n if (clonedResponse.headers.get('Content-Type')?.includes('application/json')) {\n const body = await clonedResponse.json().catch(() => null);\n console[logLevel]('Response Body:', body);\n } else {\n const body = await clonedResponse.text().catch(() => null);\n if (body) {\n console[logLevel]('Response Body:', body.substring(0, 500) + (body.length > 500 ? '...' : ''));\n } else {\n console[logLevel]('No response body');\n }\n }\n } catch (error) {\n console.error('Could not log response body:', error);\n }\n }\n\n return response;\n },\n };\n};\n", "import { parse } from \"fast-content-type-parse\";\n\nexport async function handleError(response: Response) {\n\ttry {\n\t\tif (response.status >= 400 && response.status < 500) {\n\t\t\tconst body = (await response.json()) as Record<string, any>;\n\t\t\treturn {\n\t\t\t\tstatus: response.status,\n\t\t\t\tbody: body,\n\t\t\t};\n\t\t}\n\t\treturn new Error(\n\t\t\t`An error occurred while fetching the data. Status: ${response.status}`,\n\t\t);\n\t} catch (error) {\n\t\treturn error as any;\n\t}\n}\n\nasync function handleChunkedResponse(response: Response, contentType: string) {\n\tconst { type } = parse(contentType);\n\n\tswitch (type) {\n\t\tcase \"application/json\": {\n\t\t\tlet buffer = \"\";\n\t\t\tconst reader = response.body!.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\twhile (true) {\n\t\t\t\tconst { value, done } = await reader.read();\n\t\t\t\tif (done) break;\n\t\t\t\tbuffer += decoder.decode(value);\n\t\t\t}\n\t\t\treturn JSON.parse(buffer);\n\t\t}\n\t\tcase \"text/html\":\n\t\tcase \"text/plain\": {\n\t\t\tlet buffer = \"\";\n\t\t\tconst reader = response.body!.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\twhile (true) {\n\t\t\t\tconst { value, done } = await reader.read();\n\t\t\t\tif (done) break;\n\t\t\t\tbuffer += decoder.decode(value);\n\t\t\t}\n\t\t\treturn buffer;\n\t\t}\n\t\tdefault:\n\t\t\treturn response.body;\n\t}\n}\n\nexport function chunked(response: Response) {\n\treturn response.body;\n}\n\nexport async function buffered(response: Response) {\n\tconst contentType = response.headers.get(\"Content-Type\");\n\tif (!contentType) {\n\t\tthrow new Error(\"Content-Type header is missing\");\n\t}\n\n\tif (response.status === 204) {\n\t\treturn null;\n\t}\n\n\tconst { type } = parse(contentType);\n\tswitch (type) {\n\t\tcase \"application/json\":\n\t\t\treturn response.json();\n\t\tcase \"text/plain\":\n\t\t\treturn response.text();\n\t\tcase \"text/html\":\n\t\t\treturn response.text();\n\t\tcase \"text/xml\":\n\t\tcase \"application/xml\":\n\t\t\treturn response.text();\n\t\tcase \"application/x-www-form-urlencoded\": {\n\t\t\tconst text = await response.text();\n\t\t\treturn Object.fromEntries(new URLSearchParams(text));\n\t\t}\n\t\tcase \"multipart/form-data\":\n\t\t\treturn response.formData();\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported content type: ${contentType}`);\n\t}\n}\n", "import { z } from 'zod';\n\nexport type ParseError<T extends z.ZodType<any, any, any>> = {\n kind: 'parse';\n} & z.inferFlattenedErrors<T>;\n\nexport function parse<T extends z.ZodType>(\n schema: T,\n input: unknown,\n) {\n const result = schema.safeParse(input);\n if (!result.success) {\n const errors = result.error.flatten((issue) => issue);\n return [null, errors];\n }\n return [result.data as z.infer<T>, null];\n}\n", "export type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\nexport type ContentType = 'xml' | 'json' | 'urlencoded' | 'multipart';\nexport type Endpoint =\n | `${ContentType} ${Method} ${string}`\n | `${Method} ${string}`;\n\nexport type BodyInit =\n | ArrayBuffer\n | Blob\n | FormData\n | URLSearchParams\n | null\n | string;\n\nexport function createUrl(path: string, query: URLSearchParams) {\n const url = new URL(path, `local://`);\n url.search = query.toString();\n return url;\n}\n\nfunction template(\n templateString: string,\n templateVariables: Record<string, any>,\n): string {\n const nargs = /{([0-9a-zA-Z_]+)}/g;\n return templateString.replace(nargs, (match, key: string, index: number) => {\n // Handle escaped double braces\n if (\n templateString[index - 1] === '{' &&\n templateString[index + match.length] === '}'\n ) {\n return key;\n }\n\n const result = key in templateVariables ? templateVariables[key] : null;\n return result === null || result === undefined ? '' : String(result);\n });\n}\n\ntype Input = Record<string, any>;\ntype Props = {\n inputHeaders: string[];\n inputQuery: string[];\n inputBody: string[];\n inputParams: string[];\n};\n\nabstract class Serializer {\n protected input: Input;\n protected props: Props;\n\n constructor(\n input: Input,\n props: Props,\n ) {\n this.input = input;\n this.props = props;\n }\n\n abstract getBody(): BodyInit | null;\n abstract getHeaders(): Record<string, string>;\n serialize(): Serialized {\n const headers = new Headers({});\n for (const header of this.props.inputHeaders) {\n headers.set(header, this.input[header]);\n }\n\n const query = new URLSearchParams();\n for (const key of this.props.inputQuery) {\n const value = this.input[key];\n if (value !== undefined) {\n query.set(key, String(value));\n }\n }\n\n const params = this.props.inputParams.reduce<Record<string, any>>(\n (acc, key) => {\n acc[key] = this.input[key];\n return acc;\n },\n {},\n );\n\n return {\n body: this.getBody(),\n query,\n params,\n headers: this.getHeaders(),\n };\n }\n}\n\ninterface Serialized {\n body: BodyInit | null;\n query: URLSearchParams;\n params: Record<string, any>;\n headers: Record<string, string>;\n}\n\nclass JsonSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body: Record<string, any> = {};\n for (const prop of this.props.inputBody) {\n body[prop] = this.input[prop];\n }\n return JSON.stringify(body);\n }\n getHeaders(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n };\n }\n}\n\nclass UrlencodedSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body = new URLSearchParams();\n for (const prop of this.props.inputBody) {\n body.set(prop, this.input[prop]);\n }\n return body;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nclass NoBodySerializer extends Serializer {\n getBody(): BodyInit | null {\n return null;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nclass FormDataSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body = new FormData();\n for (const prop of this.props.inputBody) {\n body.append(prop, this.input[prop]);\n }\n return body;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nexport function json(input: Input, props: Props) {\n return new JsonSerializer(input, props).serialize();\n}\nexport function urlencoded(input: Input, props: Props) {\n return new UrlencodedSerializer(input, props).serialize();\n}\nexport function nobody(input: Input, props: Props) {\n return new NoBodySerializer(input, props).serialize();\n}\nexport function formdata(input: Input, props: Props) {\n return new FormDataSerializer(input, props).serialize();\n}\n\nexport function toRequest<T extends Endpoint>(\n endpoint: T,\n input: Serialized,\n): Request {\n const [method, path] = endpoint.split(' ');\n const pathVariable = template(path, input.params);\n\n const url = createUrl(pathVariable, input.query);\n return new Request(url, {\n method: method,\n headers: input.headers,\n body: method === 'GET' ? undefined : input.body,\n });\n}\n", "export interface ApiResponse<Status extends number, Body extends unknown> {\n kind: 'response';\n status: Status;\n body: Body;\n}\n\n// 4xx Client Errors\nexport type BadRequest = ApiResponse<400, { message: string }>;\nexport type Unauthorized = ApiResponse<401, { message: string }>;\nexport type PaymentRequired = ApiResponse<402, { message: string }>;\nexport type Forbidden = ApiResponse<403, { message: string }>;\nexport type NotFound = ApiResponse<404, { message: string }>;\nexport type MethodNotAllowed = ApiResponse<405, { message: string }>;\nexport type NotAcceptable = ApiResponse<406, { message: string }>;\nexport type Conflict = ApiResponse<409, { message: string }>;\nexport type Gone = ApiResponse<410, { message: string }>;\nexport type UnprocessableEntity = ApiResponse<422, { message: string; errors?: Record<string, string[]> }>;\nexport type TooManyRequests = ApiResponse<429, { message: string; retryAfter?: string }>;\nexport type PayloadTooLarge = ApiResponse<413, { message: string; }>;\nexport type UnsupportedMediaType = ApiResponse<415, { message: string; }>;\n\n// 5xx Server Errors\nexport type InternalServerError = ApiResponse<500, { message: string }>;\nexport type NotImplemented = ApiResponse<501, { message: string }>;\nexport type BadGateway = ApiResponse<502, { message: string }>;\nexport type ServiceUnavailable = ApiResponse<503, { message: string; retryAfter?: string }>;\nexport type GatewayTimeout = ApiResponse<504, { message: string }>;\n\nexport type ClientError =\n | BadRequest\n | Unauthorized\n | PaymentRequired\n | Forbidden\n | NotFound\n | MethodNotAllowed\n | NotAcceptable\n | Conflict\n | Gone\n | UnprocessableEntity\n | TooManyRequests;\n\nexport type ServerError =\n | InternalServerError\n | NotImplemented\n | BadGateway\n | ServiceUnavailable\n | GatewayTimeout;\n\nexport type ProblematicResponse = ClientError | ServerError;\n", "\nexport interface RequestSchema {\n schema: z.ZodType;\n toRequest: (input: any) => Request;\n deserializer: (response: Response) => Promise<unknown> | unknown;\n}\n\nexport const fetchType = z\n .function()\n .args(z.instanceof(Request))\n .returns(z.promise(z.instanceof(Response)))\n .optional();\n\nexport async function sendRequest(\n input: unknown,\n route: RequestSchema,\n options: {\n fetch?: z.infer<typeof fetchType>;\n interceptors?: Interceptor[];\n },\n) {\n const { interceptors = [] } = options;\n const [parsedInput, parseError] = parse(route.schema, input);\n if (parseError) {\n return [null as never, { ...parseError, kind: 'parse' } as never] as const;\n }\n\n let request = route.toRequest(parsedInput as never);\n for (const interceptor of interceptors) {\n if (interceptor.before) {\n request = await interceptor.before(request);\n }\n }\n\n let response = await (options.fetch ?? fetch)(request);\n\n for (let i = interceptors.length - 1; i >= 0; i--) {\n const interceptor = interceptors[i];\n if (interceptor.after) {\n response = await interceptor.after(response.clone());\n }\n }\n\n if (response.ok) {\n const data = await route.deserializer(response);\n return [data as never, null] as const;\n }\n const error = await handleError(response);\n return [null as never, { ...error, kind: 'response' }] as const;\n}\n", "import { watch as nodeWatch } from 'node:fs/promises';\nimport { debounceTime, from } from 'rxjs';\n\nexport function watch(path: string) {\n return from(\n nodeWatch(path, {\n persistent: true,\n recursive: true,\n }),\n ).pipe(debounceTime(400));\n}\n"],
5
- "mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAG9B,SAAS,kBAAkB,SAAS,kBAAkB;;;ACJtD,SAAS,OAAAA,MAAK,aAAa;AAW3B,SAAS,aAAAC,YAAW,YAAY,cAAAC,mBAAkB;;;ACXlD,SAAS,WAAW;AASpB,SAAS,oBAAAC,yBAAwB;;;ACTjC,SAAS,WAAW,kBAAkB;AAEtC,SAAS,kBAAkB,eAAAC,oBAAmB;;;ACF9C,SAAS,mBAAmB;AAI5B,IAAO,iBAAQ,CAAC,SAAe;AAC7B,QAAM,iBAAiB,OAAO,QAAQ,KAAK,OAAO,EAAE;AAAA,IAClD,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,IAAI,GAAG,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;AAAA,YACP;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,MACA,iBAAiB;AAAA,QACf,gBAAgB;AAAA,QAChB,SAAS,KAAK;AAAA,UACZ;AAAA,YACE,iBAAiB;AAAA,cACf,cAAc;AAAA,cACd,qBAAqB;AAAA,cACrB,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,4BAA4B;AAAA,cAC5B,sBAAsB;AAAA,cACtB,SAAS;AAAA,cACT,kBAAkB;AAAA,YACpB;AAAA,YACA,SAAS,CAAC,SAAS;AAAA,UACrB;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,SAAS,aAAa;AAAA,IAC1B;AAAA,IACA,KAAK,cAAc;AAAA,EACrB,CAAC;AACH;;;AapMA,SAAS,SAAS,iBAAiB;AACnC,SAAS,cAAc,YAAY;AAE5B,SAAS,MAAM,MAAc;AAClC,SAAO;AAAA,IACL,UAAU,MAAM;AAAA,MACd,YAAY;AAAA,MACZ,WAAW;AAAA,IACb,CAAC;AAAA,EACH,EAAE,KAAK,aAAa,GAAG,CAAC;AAC1B;",
6
- "names": ["get", "camelcase", "spinalcase", "removeDuplicates", "toLitObject", "toLitObject", "schema", "name", "security", "removeDuplicates", "it", "exclude", "appendOptional", "spinalcase", "camelcase", "methods", "security", "get", "security"]
4
+ "sourcesContent": ["import { join } from 'node:path';\nimport { npmRunPathEnv } from 'npm-run-path';\nimport type { OpenAPIObject } from 'openapi3-ts/oas31';\n\nimport { getFolderExports, methods, writeFiles } from '@sdk-it/core';\n\nimport { generateCode } from './generator.ts';\nimport interceptors from './http/interceptors.txt';\nimport parseResponse from './http/parse-response.txt';\nimport parserTxt from './http/parser.txt';\nimport requestTxt from './http/request.txt';\nimport responseTxt from './http/response.txt';\nimport sendRequest from './http/send-request.txt';\nimport { generateInputs, generateSDK } from './sdk.ts';\nimport { exclude, securityToOptions } from './utils.ts';\n\nfunction security(spec: OpenAPIObject) {\n const security = spec.security || [];\n const components = spec.components || {};\n const securitySchemes = components.securitySchemes || {};\n const paths = Object.values(spec.paths ?? {});\n\n const options = securityToOptions(security, securitySchemes);\n\n for (const it of paths) {\n for (const method of methods) {\n const operation = it[method];\n if (!operation) {\n continue;\n }\n Object.assign(\n options,\n securityToOptions(operation.security || [], securitySchemes, 'input'),\n );\n }\n }\n return options;\n}\n\nexport async function generate(\n spec: OpenAPIObject,\n settings: {\n output: string;\n useTsExtension?: boolean;\n name?: string;\n /**\n * full: generate a full project including package.json and tsconfig.json. useful for monorepo/workspaces\n * minimal: generate only the client sdk\n */\n mode?: 'full' | 'minimal';\n formatCode?: (options: {\n output: string;\n env: ReturnType<typeof npmRunPathEnv>;\n }) => void | Promise<void>;\n },\n) {\n settings.useTsExtension ??= true;\n const makeImport = (moduleSpecifier: string) => {\n return settings.useTsExtension ? `${moduleSpecifier}.ts` : moduleSpecifier;\n };\n const { commonSchemas, groups, outputs, commonZod } = generateCode({\n spec,\n style: 'github',\n target: 'javascript',\n makeImport,\n });\n const output =\n settings.mode === 'full' ? join(settings.output, 'src') : settings.output;\n\n const options = security(spec);\n\n const clientFiles = generateSDK({\n name: settings.name || 'Client',\n operations: groups,\n servers: spec.servers?.map((server) => server.url) || [],\n options: options,\n makeImport,\n });\n\n // const readme = generateReadme(spec, {\n // name: settings.name || 'Client',\n // });\n\n const inputFiles = generateInputs(groups, commonZod, makeImport);\n\n await writeFiles(output, {\n 'outputs/.gitkeep': '',\n 'inputs/.gitkeep': '',\n 'models/.getkeep': '',\n // 'README.md': readme,\n });\n\n await writeFiles(join(output, 'http'), {\n 'interceptors.ts': interceptors,\n 'parse-response.ts': parseResponse,\n 'send-request.ts': `import z from 'zod';\nimport type { Interceptor } from './${makeImport('interceptors')}';\nimport { handleError } from './${makeImport('parse-response')}';\nimport { parse } from './${makeImport('parser')}';\n${sendRequest}`,\n 'response.ts': responseTxt,\n 'parser.ts': parserTxt,\n 'request.ts': requestTxt,\n });\n\n await writeFiles(join(output, 'outputs'), outputs);\n const modelsImports = Object.entries(commonSchemas).map(([name]) => name);\n await writeFiles(output, {\n ...clientFiles,\n ...inputFiles,\n ...Object.fromEntries(\n Object.entries(commonSchemas).map(([name, schema]) => [\n `models/${name}.ts`,\n [\n `import { z } from 'zod';`,\n ...exclude(modelsImports, [name]).map(\n (it) => `import type { ${it} } from './${it}.ts';`,\n ),\n `export type ${name} = ${schema};`,\n ].join('\\n'),\n ]),\n ),\n });\n\n const folders = [\n getFolderExports(output, settings.useTsExtension),\n getFolderExports(join(output, 'outputs'), settings.useTsExtension),\n getFolderExports(\n join(output, 'inputs'),\n settings.useTsExtension,\n ['ts'],\n (dirent) => dirent.isDirectory() && dirent.name === 'schemas',\n ),\n getFolderExports(join(output, 'http'), settings.useTsExtension),\n ];\n if (modelsImports.length) {\n folders.push(\n getFolderExports(join(output, 'models'), settings.useTsExtension),\n );\n }\n const [index, outputIndex, inputsIndex, httpIndex, modelsIndex] =\n await Promise.all(folders);\n await writeFiles(output, {\n 'index.ts': index,\n 'outputs/index.ts': outputIndex,\n 'inputs/index.ts': inputsIndex || null,\n 'http/index.ts': httpIndex,\n ...(modelsImports.length ? { 'models/index.ts': modelsIndex } : {}),\n });\n if (settings.mode === 'full') {\n await writeFiles(settings.output, {\n 'package.json': {\n ignoreIfExists: true,\n content: JSON.stringify(\n {\n name: 'sdk',\n type: 'module',\n main: './src/index.ts',\n dependencies: {\n 'fast-content-type-parse': '^3.0.0',\n zod: '^3.24.2',\n },\n },\n null,\n 2,\n ),\n },\n 'tsconfig.json': {\n ignoreIfExists: true,\n content: JSON.stringify(\n {\n compilerOptions: {\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n target: 'ESNext',\n module: 'ESNext',\n noEmit: true,\n strict: true,\n allowImportingTsExtensions: true,\n verbatimModuleSyntax: true,\n baseUrl: '.',\n moduleResolution: 'bundler',\n },\n include: ['**/*.ts'],\n },\n null,\n 2,\n ),\n },\n });\n }\n\n await settings.formatCode?.({\n output: output,\n env: npmRunPathEnv(),\n });\n}\n", "import { get, merge } from 'lodash-es';\nimport type {\n ContentObject,\n OpenAPIObject,\n OperationObject,\n ParameterLocation,\n ParameterObject,\n ReferenceObject,\n ResponseObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\nimport { camelcase, pascalcase, spinalcase } from 'stringcase';\n\nimport { removeDuplicates } from '@sdk-it/core';\n\nimport { TypeScriptDeserialzer } from './emitters/interface.ts';\nimport { ZodDeserialzer } from './emitters/zod.ts';\nimport {\n type Operation,\n type OperationInput,\n type Parser,\n type Spec,\n} from './sdk.ts';\nimport { followRef, isRef, securityToOptions, useImports } from './utils.ts';\n\nexport interface NamedImport {\n name: string;\n alias?: string;\n isTypeOnly: boolean;\n}\nexport interface Import {\n isTypeOnly: boolean;\n moduleSpecifier: string;\n defaultImport: string | undefined;\n namedImports: NamedImport[];\n namespaceImport: string | undefined;\n}\n\nconst statusCdeToMessageMap: Record<string, string> = {\n '400': 'BadRequest',\n '401': 'Unauthorized',\n '402': 'PaymentRequired',\n '403': 'Forbidden',\n '404': 'NotFound',\n '405': 'MethodNotAllowed',\n '406': 'NotAcceptable',\n '409': 'Conflict',\n '413': 'PayloadTooLarge',\n '410': 'Gone',\n '422': 'UnprocessableEntity',\n '429': 'TooManyRequests',\n '500': 'InternalServerError',\n '501': 'NotImplemented',\n '502': 'BadGateway',\n '503': 'ServiceUnavailable',\n '504': 'GatewayTimeout',\n};\n\nexport interface GenerateSdkConfig {\n spec: OpenAPIObject;\n target?: 'javascript';\n /**\n * No support for jsdoc in vscode\n * @issue https://github.com/microsoft/TypeScript/issues/38106\n */\n style?: 'github';\n operationId?: (\n operation: OperationObject,\n path: string,\n method: string,\n ) => string;\n makeImport: (module: string) => string;\n}\n\nexport const defaults: Partial<GenerateSdkConfig> &\n Required<Pick<GenerateSdkConfig, 'operationId'>> = {\n target: 'javascript',\n style: 'github',\n operationId: (operation, path, method) => {\n if (operation.operationId) {\n return spinalcase(operation.operationId);\n }\n return camelcase(`${method} ${path.replace(/[\\\\/\\\\{\\\\}]/g, ' ').trim()}`);\n },\n};\n\nexport function generateCode(config: GenerateSdkConfig) {\n const commonSchemas: Record<string, string> = {};\n const commonZod = new Map<string, string>();\n const commonZodImports: Import[] = [];\n const zodDeserialzer = new ZodDeserialzer(config.spec, (model, schema) => {\n commonZod.set(model, schema);\n commonZodImports.push({\n defaultImport: undefined,\n isTypeOnly: true,\n moduleSpecifier: `./${config.makeImport(model)}`,\n namedImports: [{ isTypeOnly: true, name: model }],\n namespaceImport: undefined,\n });\n });\n\n const groups: Spec['operations'] = {};\n const outputs: Record<string, string> = {};\n\n for (const [path, pathItem] of Object.entries(config.spec.paths ?? {})) {\n const { parameters = [], ...methods } = pathItem;\n\n for (const [method, operation] of Object.entries(methods) as [\n string,\n OperationObject,\n ][]) {\n const formatOperationId = config.operationId ?? defaults.operationId;\n const operationName = formatOperationId(operation, path, method);\n\n console.log(`Processing ${method} ${path}`);\n const [groupName] = Array.isArray(operation.tags)\n ? operation.tags\n : ['unknown'];\n groups[groupName] ??= [];\n const inputs: Operation['inputs'] = {};\n\n const additionalProperties: ParameterObject[] = [];\n for (const param of [...parameters, ...(operation.parameters ?? [])]) {\n if (isRef(param)) {\n throw new Error(`Found reference in parameter ${param.$ref}`);\n }\n if (!param.schema) {\n throw new Error(`Schema not found for parameter ${param.name}`);\n }\n inputs[param.name] = {\n in: param.in,\n schema: '',\n };\n additionalProperties.push(param);\n }\n\n const security = operation.security ?? [];\n const securitySchemes = config.spec.components?.securitySchemes ?? {};\n\n const securityOptions = securityToOptions(security, securitySchemes);\n\n Object.assign(inputs, securityOptions);\n\n additionalProperties.push(\n ...Object.entries(securityOptions).map(\n ([name, value]) =>\n ({\n name: name,\n required: false,\n schema: {\n type: 'string',\n },\n in: value.in as ParameterLocation,\n }) satisfies ParameterObject,\n ),\n );\n\n const types: Record<string, string> = {};\n const shortContenTypeMap: Record<string, string> = {\n 'application/json': 'json',\n 'application/x-www-form-urlencoded': 'urlencoded',\n 'multipart/form-data': 'formdata',\n 'application/xml': 'xml',\n 'text/plain': 'text',\n };\n let outgoingContentType: string | undefined;\n if (operation.requestBody && Object.keys(operation.requestBody).length) {\n const content: ContentObject = isRef(operation.requestBody)\n ? get(followRef(config.spec, operation.requestBody.$ref), ['content'])\n : operation.requestBody.content;\n\n for (const type in content) {\n const ctSchema = isRef(content[type].schema)\n ? followRef(config.spec, content[type].schema.$ref)\n : content[type].schema;\n if (!ctSchema) {\n console.warn(`Schema not found for ${type}`);\n continue;\n }\n\n const schema = merge({}, ctSchema, {\n required: additionalProperties\n .filter((p) => p.required)\n .map((p) => p.name),\n properties: additionalProperties.reduce<Record<string, unknown>>(\n (acc, p) => ({\n ...acc,\n [p.name]: p.schema,\n }),\n {},\n ),\n });\n\n Object.assign(inputs, bodyInputs(config, ctSchema));\n types[shortContenTypeMap[type]] = zodDeserialzer.handle(schema, true);\n }\n\n if (content['application/json']) {\n outgoingContentType = 'json';\n } else if (content['application/x-www-form-urlencoded']) {\n outgoingContentType = 'urlencoded';\n } else if (content['multipart/form-data']) {\n outgoingContentType = 'formdata';\n } else {\n outgoingContentType = 'json';\n }\n } else {\n const properties = additionalProperties.reduce<Record<string, any>>(\n (acc, p) => ({\n ...acc,\n [p.name]: p.schema,\n }),\n {},\n );\n types[shortContenTypeMap['application/json']] = zodDeserialzer.handle(\n {\n type: 'object',\n required: additionalProperties\n .filter((p) => p.required)\n .map((p) => p.name),\n properties,\n },\n true,\n );\n }\n\n const errors: string[] = [];\n operation.responses ??= {};\n\n let foundResponse = false;\n const output = [`import z from 'zod';`];\n let parser: Parser = 'buffered';\n const responses: string[] = [];\n const responsesImports: Record<string, Import> = {};\n for (const status in operation.responses) {\n const response = isRef(\n operation.responses[status] as ResponseObject | ReferenceObject,\n )\n ? (followRef(\n config.spec,\n operation.responses[status].$ref,\n ) as ResponseObject)\n : (operation.responses[status] as ResponseObject);\n const statusCode = +status;\n if (statusCode >= 400) {\n errors.push(statusCdeToMessageMap[status] ?? 'ProblematicResponse');\n }\n if (statusCode >= 200 && statusCode < 300) {\n foundResponse = true;\n const responseContent = get(response, ['content']);\n const isJson = responseContent && responseContent['application/json'];\n if ((response.headers ?? {})['Transfer-Encoding']) {\n parser = 'chunked';\n }\n // TODO: how the user is going to handle multiple response types\n const typeScriptDeserialzer = new TypeScriptDeserialzer(\n config.spec,\n (schemaName, zod) => {\n commonSchemas[schemaName] = zod;\n responsesImports[schemaName] = {\n defaultImport: undefined,\n isTypeOnly: true,\n moduleSpecifier: `../models/${config.makeImport(schemaName)}`,\n namedImports: [{ isTypeOnly: true, name: schemaName }],\n namespaceImport: undefined,\n };\n },\n );\n const responseSchema = isJson\n ? typeScriptDeserialzer.handle(\n responseContent['application/json'].schema!,\n true,\n )\n : statusCode === 204\n ? 'void'\n : 'ReadableStream'; // non-json response treated as stream\n\n responses.push(responseSchema);\n }\n }\n\n if (responses.length > 1) {\n // remove duplicates in case an operation has multiple responses with the same schema\n output.push(\n `export type ${pascalcase(operationName + ' output')} = ${removeDuplicates(\n responses,\n (it) => it,\n ).join(' | ')};`,\n );\n } else {\n output.push(\n `export type ${pascalcase(operationName + ' output')} = ${responses[0]};`,\n );\n }\n output.push(\n ...useImports(output.join(''), Object.values(responsesImports)),\n );\n\n if (!foundResponse) {\n output.push(\n `export type ${pascalcase(operationName + ' output')} = void`,\n );\n }\n outputs[`${spinalcase(operationName)}.ts`] = output.join('\\n');\n groups[groupName].push({\n name: operationName,\n type: 'http',\n inputs,\n errors: errors.length ? errors : ['ServerError'],\n outgoingContentType,\n schemas: types,\n parser,\n formatOutput: () => ({\n import: pascalcase(operationName + ' output'),\n use: pascalcase(operationName + ' output'),\n }),\n trigger: {\n path,\n method,\n },\n });\n }\n }\n\n return { groups, commonSchemas, commonZod, outputs };\n}\n\n// TODO - USE CASES\n// 1. Some parameters conflicts with request body\n// 2. Generate 400 and 500 response variations // done\n// 3. Generate 200 response variations\n// 3. Doc Security\n// 4. Operation Security\n// 5. JsDocs\n// 5. test all different types of parameters\n// 6. cookies\n// 6. x-www-form-urlencoded // done\n// 7. multipart/form-data // done\n// 7. application/octet-stream // done\n// 7. chunked response // done\n\nfunction toProps(\n spec: OpenAPIObject,\n schemaOrRef: SchemaObject | ReferenceObject,\n aggregator: string[] = [],\n) {\n if (isRef(schemaOrRef)) {\n const schema = followRef(spec, schemaOrRef.$ref);\n return toProps(spec, schema, aggregator);\n } else if (schemaOrRef.type === 'object') {\n for (const [name] of Object.entries(schemaOrRef.properties ?? {})) {\n aggregator.push(name);\n }\n return void 0;\n } else if (\n (schemaOrRef.type === 'array' || schemaOrRef.type?.includes('array')) &&\n schemaOrRef.items\n ) {\n toProps(spec, schemaOrRef.items, aggregator);\n return void 0;\n } else if (schemaOrRef.allOf) {\n for (const it of schemaOrRef.allOf) {\n toProps(spec, it, aggregator);\n }\n return void 0;\n } else if (schemaOrRef.oneOf) {\n for (const it of schemaOrRef.oneOf) {\n toProps(spec, it, aggregator);\n }\n return void 0;\n } else if (schemaOrRef.anyOf) {\n for (const it of schemaOrRef.anyOf) {\n toProps(spec, it, aggregator);\n }\n return void 0;\n }\n console.warn('Unknown schema in body', schemaOrRef);\n return void 0;\n}\n\nfunction bodyInputs(\n config: GenerateSdkConfig,\n ctSchema: SchemaObject | ReferenceObject,\n) {\n const props: string[] = [];\n toProps(config.spec, ctSchema, props);\n return props.reduce<Record<string, OperationInput>>(\n (acc, prop) => ({\n ...acc,\n [prop]: {\n in: 'body',\n schema: '',\n },\n }),\n {},\n );\n}\n", "import { get } from 'lodash-es';\nimport type {\n ComponentsObject,\n OpenAPIObject,\n ReferenceObject,\n SchemaObject,\n SecurityRequirementObject,\n} from 'openapi3-ts/oas31';\n\nimport { removeDuplicates } from '@sdk-it/core';\n\nimport { type Options } from './sdk.ts';\n\nexport function isRef(obj: any): obj is ReferenceObject {\n return obj && '$ref' in obj;\n}\n\nexport function cleanRef(ref: string) {\n return ref.replace(/^#\\//, '');\n}\n\nexport function parseRef(ref: string) {\n const parts = ref.split('/');\n const [model] = parts.splice(-1);\n return { model, path: parts.join('/') };\n}\nexport function followRef(spec: OpenAPIObject, ref: string): SchemaObject {\n const pathParts = cleanRef(ref).split('/');\n const entry = get(spec, pathParts) as SchemaObject | ReferenceObject;\n if (entry && '$ref' in entry) {\n return followRef(spec, entry.$ref);\n }\n return entry;\n}\nexport function securityToOptions(\n security: SecurityRequirementObject[],\n securitySchemes: ComponentsObject['securitySchemes'],\n staticIn?: string,\n) {\n securitySchemes ??= {};\n const options: Options = {};\n for (const it of security) {\n const [name] = Object.keys(it);\n if (!name) {\n // this means the operation doesn't necessarily require security\n continue;\n }\n const schema = securitySchemes[name];\n if (isRef(schema)) {\n throw new Error(`Ref security schemas are not supported`);\n }\n if (schema.type === 'http') {\n options['authorization'] = {\n in: staticIn ?? 'header',\n schema:\n 'z.string().optional().transform((val) => (val ? `Bearer ${val}` : undefined))',\n optionName: 'token',\n };\n continue;\n }\n if (schema.type === 'apiKey') {\n if (!schema.in) {\n throw new Error(`apiKey security schema must have an \"in\" field`);\n }\n if (!schema.name) {\n throw new Error(`apiKey security schema must have a \"name\" field`);\n }\n options[schema.name] = {\n in: staticIn ?? schema.in,\n schema: 'z.string().optional()',\n };\n continue;\n }\n }\n return options;\n}\n\nexport function mergeImports(imports: Import[]) {\n const merged: Record<string, Import> = {};\n\n for (const i of imports) {\n merged[i.moduleSpecifier] = merged[i.moduleSpecifier] ?? {\n moduleSpecifier: i.moduleSpecifier,\n defaultImport: i.defaultImport,\n namespaceImport: i.namespaceImport,\n namedImports: [],\n };\n if (i.namedImports) {\n merged[i.moduleSpecifier].namedImports.push(...i.namedImports);\n }\n }\n\n return Object.values(merged);\n}\nexport interface Import {\n isTypeOnly: boolean;\n moduleSpecifier: string;\n defaultImport: string | undefined;\n namedImports: NamedImport[];\n namespaceImport: string | undefined;\n}\nexport interface NamedImport {\n name: string;\n alias?: string;\n isTypeOnly: boolean;\n}\n\nexport function importsToString(...imports: Import[]) {\n return imports.map((it) => {\n if (it.defaultImport) {\n return `import ${it.defaultImport} from '${it.moduleSpecifier}'`;\n }\n if (it.namespaceImport) {\n return `import * as ${it.namespaceImport} from '${it.moduleSpecifier}'`;\n }\n if (it.namedImports) {\n return `import {${removeDuplicates(it.namedImports, (it) => it.name)\n .map((n) => `${n.isTypeOnly ? 'type' : ''} ${n.name}`)\n .join(', ')}} from '${it.moduleSpecifier}'`;\n }\n throw new Error(`Invalid import ${JSON.stringify(it)}`);\n });\n}\n\nexport function exclude<T>(list: T[], exclude: T[]): T[] {\n return list.filter((it) => !exclude.includes(it));\n}\n\nexport function useImports(content: string, imports: Import[]) {\n const output: string[] = [];\n for (const it of mergeImports(imports)) {\n const singleImport = it.defaultImport ?? it.namespaceImport;\n if (singleImport && content.includes(singleImport)) {\n output.push(importsToString(it).join('\\n'));\n } else if (it.namedImports.length) {\n for (const namedImport of it.namedImports) {\n if (content.includes(namedImport.name)) {\n output.push(importsToString(it).join('\\n'));\n }\n }\n }\n }\n return output;\n}\n\nexport type MakeImportFn = (moduleSpecifier: string) => string;\n", "import { camelcase, spinalcase } from 'stringcase';\n\nimport { removeDuplicates, toLitObject } from '@sdk-it/core';\n\nimport backend from './client.ts';\nimport type { MakeImportFn } from './utils.ts';\n\nexport type Parser = 'chunked' | 'buffered';\nclass SchemaEndpoint {\n #makeImport: MakeImportFn;\n #imports: string[] = [];\n constructor(makeImport: MakeImportFn) {\n this.#makeImport = makeImport;\n this.#imports = [\n `import z from 'zod';`,\n `import type { Endpoints } from '${this.#makeImport('./endpoints')}';`,\n `import { toRequest, json, urlencoded, nobody, formdata, createUrl } from '${this.#makeImport('./http/request')}';`,\n `import type { ParseError } from '${this.#makeImport('./http/parser')}';`,\n `import { chunked, buffered } from \"${this.#makeImport('./http/parse-response')}\";`,\n ];\n }\n\n #endpoints: string[] = [];\n\n addEndpoint(endpoint: string, operation: string) {\n this.#endpoints.push(` \"${endpoint}\": ${operation},`);\n }\n\n addImport(value: string) {\n this.#imports.push(value);\n }\n\n complete() {\n return `${this.#imports.join('\\n')}\\nexport default {\\n${this.#endpoints.join('\\n')}\\n}`;\n }\n}\nclass Emitter {\n #makeImport: MakeImportFn;\n protected imports: string[] = [];\n constructor(makeImport: MakeImportFn) {\n this.#makeImport = makeImport;\n this.imports = [\n `import type z from 'zod';`,\n `import type { ParseError } from '${this.#makeImport('./http/parser')}';`,\n ];\n }\n protected endpoints: string[] = [];\n addEndpoint(endpoint: string, operation: string) {\n this.endpoints.push(` \"${endpoint}\": ${operation};`);\n }\n addImport(value: string) {\n this.imports.push(value);\n }\n complete() {\n return `${this.imports.join('\\n')}\\nexport interface Endpoints {\\n${this.endpoints.join('\\n')}\\n}`;\n }\n}\n\nexport interface SdkConfig {\n /**\n * The name of the sdk client\n */\n name: string;\n packageName?: string;\n options?: Record<string, any>;\n emptyBodyAsNull?: boolean;\n stripBodyFromGetAndHead?: boolean;\n output: string;\n}\n\nexport type Options = Record<\n string,\n {\n in: string;\n schema: string;\n optionName?: string;\n }\n>;\nexport interface Spec {\n operations: Record<string, Operation[]>;\n name: string;\n options: Options;\n servers: string[];\n makeImport: MakeImportFn;\n}\n\nexport interface OperationInput {\n in: string;\n schema: string;\n}\nexport interface Operation {\n name: string;\n errors: string[];\n type: string;\n trigger: Record<string, any>;\n outgoingContentType?: string;\n parser: Parser;\n schemas: Record<string, string>;\n inputs: Record<string, OperationInput>;\n formatOutput: () => { import: string; use: string };\n}\n\nexport function generateInputs(\n operationsSet: Spec['operations'],\n commonZod: Map<string, string>,\n makeImport: MakeImportFn,\n) {\n const commonImports = commonZod.keys().toArray();\n const inputs: Record<string, string> = {};\n for (const [name, operations] of Object.entries(operationsSet)) {\n const output: string[] = [];\n const imports = new Set(['import { z } from \"zod\";']);\n\n for (const operation of operations) {\n const schemaName = camelcase(`${operation.name} schema`);\n\n const schema = `export const ${schemaName} = ${\n Object.keys(operation.schemas).length === 1\n ? Object.values(operation.schemas)[0]\n : toLitObject(operation.schemas)\n };`;\n\n const inputContent = schema;\n\n for (const schema of commonImports) {\n if (inputContent.includes(schema)) {\n imports.add(\n `import { ${schema} } from './schemas/${makeImport(spinalcase(schema))}';`,\n );\n }\n }\n output.push(inputContent);\n }\n inputs[`inputs/${spinalcase(name)}.ts`] =\n [...imports, ...output].join('\\n') + '\\n';\n }\n\n const schemas = commonZod\n .entries()\n .reduce<string[][]>((acc, [name, schema]) => {\n const output = [`import { z } from 'zod';`];\n const content = `export const ${name} = ${schema};`;\n for (const schema of commonImports) {\n const preciseMatch = new RegExp(`\\\\b${schema}\\\\b`);\n if (preciseMatch.test(content) && schema !== name) {\n output.push(\n `import { ${schema} } from './${makeImport(spinalcase(schema))}';`,\n );\n }\n }\n\n output.push(content);\n return [\n [`inputs/schemas/${spinalcase(name)}.ts`, output.join('\\n')],\n ...acc,\n ];\n }, []);\n\n return {\n ...Object.fromEntries(schemas),\n ...inputs,\n };\n}\n\nexport function generateSDK(spec: Spec) {\n const emitter = new Emitter(spec.makeImport);\n const schemaEndpoint = new SchemaEndpoint(spec.makeImport);\n const errors: string[] = [];\n for (const [name, operations] of Object.entries(spec.operations)) {\n emitter.addImport(\n `import type * as ${camelcase(name)} from './inputs/${spec.makeImport(spinalcase(name))}';`,\n );\n schemaEndpoint.addImport(\n `import * as ${camelcase(name)} from './inputs/${spec.makeImport(spinalcase(name))}';`,\n );\n for (const operation of operations) {\n const schemaName = camelcase(`${operation.name} schema`);\n const schemaRef = `${camelcase(name)}.${schemaName}`;\n const output = operation.formatOutput();\n const inputHeaders: string[] = [];\n const inputQuery: string[] = [];\n const inputBody: string[] = [];\n const inputParams: string[] = [];\n for (const [name, prop] of Object.entries(operation.inputs)) {\n if (prop.in === 'headers' || prop.in === 'header') {\n inputHeaders.push(`\"${name}\"`);\n } else if (prop.in === 'query') {\n inputQuery.push(`\"${name}\"`);\n } else if (prop.in === 'body') {\n inputBody.push(`\"${name}\"`);\n } else if (prop.in === 'path') {\n inputParams.push(`\"${name}\"`);\n } else if (prop.in === 'internal') {\n // ignore internal sources\n continue;\n } else {\n throw new Error(\n `Unknown source ${prop.in} in ${name} ${JSON.stringify(\n prop,\n )} in ${operation.name}`,\n );\n }\n }\n emitter.addImport(\n `import type {${output.import}} from './outputs/${spec.makeImport(spinalcase(operation.name))}';`,\n );\n errors.push(...(operation.errors ?? []));\n\n const addTypeParser = Object.keys(operation.schemas).length > 1;\n for (const type in operation.schemas ?? {}) {\n let typePrefix = '';\n if (addTypeParser && type !== 'json') {\n typePrefix = `${type} `;\n }\n const input = `typeof ${schemaRef}${addTypeParser ? `.${type}` : ''}`;\n\n const endpoint = `${typePrefix}${operation.trigger.method.toUpperCase()} ${operation.trigger.path}`;\n emitter.addEndpoint(\n endpoint,\n `{input: z.infer<${input}>; output: ${output.use}; error: ${(operation.errors ?? ['ServerError']).concat(`ParseError<${input}>`).join('|')}}`,\n );\n schemaEndpoint.addEndpoint(\n endpoint,\n `{\n schema: ${schemaRef}${addTypeParser ? `.${type}` : ''},\n deserializer: ${operation.parser === 'chunked' ? 'chunked' : 'buffered'},\n toRequest(input: Endpoints['${endpoint}']['input']) {\n const endpoint = '${endpoint}';\n return toRequest(endpoint, ${operation.outgoingContentType || 'nobody'}(input, {\n inputHeaders: [${inputHeaders}],\n inputQuery: [${inputQuery}],\n inputBody: [${inputBody}],\n inputParams: [${inputParams}],\n }));\n },\n }`,\n );\n }\n }\n }\n\n emitter.addImport(\n `import type { ${removeDuplicates(errors, (it) => it).join(', ')} } from '${spec.makeImport('./http/response')}';`,\n );\n return {\n 'client.ts': backend(spec),\n 'schemas.ts': schemaEndpoint.complete(),\n 'endpoints.ts': emitter.complete(),\n };\n}\n", "import { toLitObject } from '@sdk-it/core';\n\nimport type { Spec } from './sdk.ts';\n\nexport default (spec: Spec) => {\n const optionsEntries = Object.entries(spec.options).map(\n ([key, value]) => [`'${key}'`, value] as const,\n );\n const defaultHeaders = `{${optionsEntries\n .filter(([, value]) => value.in === 'header')\n .map(\n ([key, value]) =>\n `${key}: this.options[${value.optionName ? `'${value.optionName}'` : key}]`,\n )\n .join(',\\n')}}`;\n const defaultInputs = `{${optionsEntries\n .filter(([, value]) => value.in === 'input')\n .map(\n ([key, value]) =>\n `${key}: this.options[${value.optionName ? `'${value.optionName}'` : key}]`,\n )\n .join(',\\n')}}`;\n const specOptions: Record<string, { schema: string }> = {\n ...Object.fromEntries(\n optionsEntries.map(([key, value]) => [value.optionName ?? key, value]),\n ),\n fetch: {\n schema: 'fetchType',\n },\n baseUrl: {\n schema: spec.servers.length\n ? `z.enum(servers).default(servers[0])`\n : 'z.string()',\n },\n };\n\n return `\nimport { fetchType, sendRequest } from './http/${spec.makeImport('send-request')}';\nimport z from 'zod';\nimport type { Endpoints } from './${spec.makeImport('endpoints')}';\nimport schemas from './${spec.makeImport('schemas')}';\nimport {\n createBaseUrlInterceptor,\n createHeadersInterceptor,\n} from './http/${spec.makeImport('interceptors')}';\n\n${spec.servers.length ? `export const servers = ${JSON.stringify(spec.servers, null, 2)} as const` : ''}\nconst optionsSchema = z.object(${toLitObject(specOptions, (x) => x.schema)});\n${spec.servers.length ? `export type Servers = typeof servers[number];` : ''}\n\ntype ${spec.name}Options = z.infer<typeof optionsSchema>;\n\nexport class ${spec.name} {\n public options: ${spec.name}Options\n constructor(options: ${spec.name}Options) {\n this.options = optionsSchema.parse(options);\n }\n\n async request<E extends keyof Endpoints>(\n endpoint: E,\n input: Endpoints[E]['input'],\n options?: { signal?: AbortSignal, headers?: HeadersInit },\n ): Promise<readonly [Endpoints[E]['output'], Endpoints[E]['error'] | null]> {\n const route = schemas[endpoint];\n return sendRequest(Object.assign(this.#defaultInputs, input), route, {\n fetch: this.options.fetch,\n interceptors: [\n createHeadersInterceptor(() => this.defaultHeaders, options?.headers ?? {}),\n createBaseUrlInterceptor(() => this.options.baseUrl),\n ],\n signal: options?.signal,\n });\n }\n\n get defaultHeaders() {\n return ${defaultHeaders}\n }\n\n get #defaultInputs() {\n return ${defaultInputs}\n }\n\n setOptions(options: Partial<${spec.name}Options>) {\n const validated = optionsSchema.partial().parse(options);\n\n for (const key of Object.keys(validated) as (keyof ${spec.name}Options)[]) {\n if (validated[key] !== undefined) {\n (this.options[key] as typeof validated[typeof key]) = validated[key]!;\n }\n }\n }\n}`;\n};\n", "import type {\n OpenAPIObject,\n ReferenceObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { cleanRef, followRef, isRef, parseRef } from '../utils.ts';\n\ntype OnRefCallback = (ref: string, interfaceContent: string) => void;\n\n/**\n * Convert an OpenAPI (JSON Schema style) object into TypeScript interfaces,\n */\nexport class TypeScriptDeserialzer {\n circularRefTracker = new Set<string>();\n #spec: OpenAPIObject;\n #onRef: OnRefCallback;\n\n constructor(spec: OpenAPIObject, onRef: OnRefCallback) {\n this.#spec = spec;\n this.#onRef = onRef;\n }\n #stringifyKey = (key: string): string => {\n // List of JavaScript keywords and special object properties that should be quoted\n const reservedWords = [\n 'constructor',\n 'prototype',\n 'break',\n 'case',\n 'catch',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'export',\n 'extends',\n 'false',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'import',\n 'in',\n 'instanceof',\n 'new',\n 'null',\n 'return',\n 'super',\n 'switch',\n 'this',\n 'throw',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'yield',\n ];\n\n // Check if key is a reserved word\n if (reservedWords.includes(key)) {\n return `'${key}'`;\n }\n\n // Check if key is empty or only whitespace\n if (key.trim() === '') {\n return `'${key}'`;\n }\n\n // Check if first character is valid for identifiers\n const firstChar = key.charAt(0);\n const validFirstChar =\n (firstChar >= 'a' && firstChar <= 'z') ||\n (firstChar >= 'A' && firstChar <= 'Z') ||\n firstChar === '_' ||\n firstChar === '$';\n\n if (!validFirstChar) {\n return `'${key.replace(/'/g, \"\\\\'\")}'`;\n }\n\n // Check if the rest of the characters are valid for identifiers\n for (let i = 1; i < key.length; i++) {\n const char = key.charAt(i);\n const validChar =\n (char >= 'a' && char <= 'z') ||\n (char >= 'A' && char <= 'Z') ||\n (char >= '0' && char <= '9') ||\n char === '_' ||\n char === '$';\n\n if (!validChar) {\n return `'${key.replace(/'/g, \"\\\\'\")}'`;\n }\n }\n\n return key;\n };\n #stringifyKeyV2 = (value: string): string => {\n return `'${value}'`;\n };\n\n /**\n * Handle objects (properties)\n */\n object(schema: SchemaObject, required = false): string {\n const properties = schema.properties || {};\n\n // Convert each property\n const propEntries = Object.entries(properties).map(([key, propSchema]) => {\n const isRequired = (schema.required ?? []).includes(key);\n const tsType = this.handle(propSchema, isRequired);\n // Add question mark for optional properties\n return `${this.#stringifyKeyV2(key)}: ${tsType}`;\n });\n\n // Handle additionalProperties\n if (schema.additionalProperties) {\n if (typeof schema.additionalProperties === 'object') {\n const indexType = this.handle(schema.additionalProperties, true);\n propEntries.push(`[key: string]: ${indexType}`);\n } else if (schema.additionalProperties === true) {\n propEntries.push('[key: string]: any');\n }\n }\n\n return `{ ${propEntries.join('; ')} }`;\n }\n\n /**\n * Handle arrays (items could be a single schema or a tuple)\n */\n array(schema: SchemaObject, required = false): string {\n const { items } = schema;\n if (!items) {\n // No items => any[]\n return 'any[]';\n }\n\n // If items is an array => tuple\n if (Array.isArray(items)) {\n const tupleItems = items.map((sub) => this.handle(sub, true));\n return `[${tupleItems.join(', ')}]`;\n }\n\n // If items is a single schema => standard array\n const itemsType = this.handle(items, true);\n return `${itemsType}[]`;\n }\n\n /**\n * Convert a basic type (string | number | boolean | object | array, etc.) to TypeScript\n */\n normal(type: string, schema: SchemaObject, required = false): string {\n switch (type) {\n case 'string':\n return this.string(schema, required);\n case 'number':\n case 'integer':\n return this.number(schema, required);\n case 'boolean':\n return appendOptional('boolean', required);\n case 'object':\n return this.object(schema, required);\n case 'array':\n return this.array(schema, required);\n case 'null':\n return 'null';\n default:\n // Unknown type -> fallback\n return appendOptional('any', required);\n }\n }\n\n ref($ref: string, required: boolean): string {\n const schemaName = cleanRef($ref).split('/').pop()!;\n\n if (this.circularRefTracker.has(schemaName)) {\n return schemaName;\n }\n\n this.circularRefTracker.add(schemaName);\n this.#onRef(schemaName, this.handle(followRef(this.#spec, $ref), true));\n this.circularRefTracker.delete(schemaName);\n\n return appendOptional(schemaName, required);\n }\n\n allOf(schemas: (SchemaObject | ReferenceObject)[]): string {\n // For TypeScript we use intersection types for allOf\n const allOfTypes = schemas.map((sub) => this.handle(sub, true));\n return allOfTypes.length > 1 ? `${allOfTypes.join(' & ')}` : allOfTypes[0];\n }\n\n anyOf(\n schemas: (SchemaObject | ReferenceObject)[],\n required: boolean,\n ): string {\n // For TypeScript we use union types for anyOf/oneOf\n const anyOfTypes = schemas.map((sub) => this.handle(sub, true));\n return appendOptional(\n anyOfTypes.length > 1 ? `${anyOfTypes.join(' | ')}` : anyOfTypes[0],\n required,\n );\n }\n\n oneOf(\n schemas: (SchemaObject | ReferenceObject)[],\n required: boolean,\n ): string {\n const oneOfTypes = schemas.map((sub) => {\n if (isRef(sub)) {\n const { model } = parseRef(sub.$ref);\n if (this.circularRefTracker.has(model)) {\n return model;\n }\n }\n return this.handle(sub, false);\n });\n return appendOptional(\n oneOfTypes.length > 1 ? `${oneOfTypes.join(' | ')}` : oneOfTypes[0],\n required,\n );\n }\n\n enum(values: any[], required: boolean): string {\n // For TypeScript enums as union of literals\n const enumValues = values\n .map((val) => (typeof val === 'string' ? `'${val}'` : `${val}`))\n .join(' | ');\n return appendOptional(enumValues, required);\n }\n\n /**\n * Handle string type with formats\n */\n string(schema: SchemaObject, required?: boolean): string {\n let type: string;\n\n switch (schema.format) {\n case 'date-time':\n case 'datetime':\n case 'date':\n type = 'Date';\n break;\n case 'binary':\n case 'byte':\n type = 'Blob';\n break;\n case 'int64':\n type = 'bigint';\n break;\n default:\n type = 'string';\n }\n\n return appendOptional(type, required);\n }\n\n /**\n * Handle number/integer types with formats\n */\n number(schema: SchemaObject, required?: boolean): string {\n const type = schema.format === 'int64' ? 'bigint' : 'number';\n return appendOptional(type, required);\n }\n\n handle(schema: SchemaObject | ReferenceObject, required: boolean): string {\n if (isRef(schema)) {\n return this.ref(schema.$ref, required);\n }\n\n // Handle allOf (intersection in TypeScript)\n if (schema.allOf && Array.isArray(schema.allOf)) {\n return this.allOf(schema.allOf);\n }\n\n // anyOf (union in TypeScript)\n if (schema.anyOf && Array.isArray(schema.anyOf)) {\n return this.anyOf(schema.anyOf, required);\n }\n\n // oneOf (union in TypeScript)\n if (schema.oneOf && Array.isArray(schema.oneOf)) {\n return this.oneOf(schema.oneOf, required);\n }\n\n // enum\n if (schema.enum && Array.isArray(schema.enum)) {\n return this.enum(schema.enum, required);\n }\n\n // Handle types, in TypeScript we can have union types directly\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n\n // If no explicit \"type\", fallback to any\n if (!types.length) {\n // unless properties are defined then assume object\n if ('properties' in schema) {\n return this.object(schema, required);\n }\n return appendOptional('any', required);\n }\n\n // Handle union types (multiple types)\n if (types.length > 1) {\n const realTypes = types.filter((t) => t !== 'null');\n if (realTypes.length === 1 && types.includes('null')) {\n // Single real type + \"null\"\n const tsType = this.normal(realTypes[0], schema, false);\n return appendOptional(`${tsType} | null`, required);\n }\n\n // Multiple different types\n const typeResults = types.map((t) => this.normal(t, schema, false));\n return appendOptional(typeResults.join(' | '), required);\n }\n\n // Single type\n return this.normal(types[0], schema, required);\n }\n\n /**\n * Generate an interface declaration\n */\n generateInterface(\n name: string,\n schema: SchemaObject | ReferenceObject,\n ): string {\n const content = this.handle(schema, true);\n return `interface ${name} ${content}`;\n }\n}\n\n/**\n * Append \"| undefined\" if not required\n */\nfunction appendOptional(type: string, isRequired?: boolean): string {\n return isRequired ? type : `${type} | undefined`;\n}\n", "import type {\n OpenAPIObject,\n ReferenceObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { cleanRef, followRef, isRef, parseRef } from '../utils.ts';\n\ntype OnRefCallback = (ref: string, zod: string) => void;\n\n/**\n * Convert an OpenAPI (JSON Schema style) object into a Zod schema string,\n * adapted for OpenAPI 3.1 (fully aligned with JSON Schema 2020-12).\n */\nexport class ZodDeserialzer {\n circularRefTracker = new Set<string>();\n #spec: OpenAPIObject;\n #onRef?: OnRefCallback;\n\n constructor(spec: OpenAPIObject, onRef?: OnRefCallback) {\n this.#spec = spec;\n this.#onRef = onRef;\n }\n /**\n * Handle objects (properties, additionalProperties).\n */\n object(schema: SchemaObject, required = false): string {\n const properties = schema.properties || {};\n\n // Convert each property\n const propEntries = Object.entries(properties).map(([key, propSchema]) => {\n const isRequired = (schema.required ?? []).includes(key);\n const zodPart = this.handle(propSchema, isRequired);\n return `'${key}': ${zodPart}`;\n });\n\n // additionalProperties\n let additionalProps = '';\n if (schema.additionalProperties) {\n if (typeof schema.additionalProperties === 'object') {\n // e.g. z.record() if it\u2019s an object schema\n const addPropZod = this.handle(schema.additionalProperties, true);\n additionalProps = `.catchall(${addPropZod})`;\n } else if (schema.additionalProperties === true) {\n // free-form additional props\n additionalProps = `.catchall(z.unknown())`;\n }\n }\n\n const objectSchema = `z.object({${propEntries.join(', ')}})${additionalProps}`;\n return `${objectSchema}${appendOptional(required)}`;\n }\n\n /**\n * Handle arrays (items could be a single schema or a tuple (array of schemas)).\n * In JSON Schema 2020-12, `items` can be an array \u2192 tuple style.\n */\n array(schema: SchemaObject, required = false): string {\n const { items } = schema;\n if (!items) {\n // No items => z.array(z.unknown())\n return `z.array(z.unknown())${appendOptional(required)}`;\n }\n\n // If items is an array => tuple\n if (Array.isArray(items)) {\n // Build a Zod tuple\n const tupleItems = items.map((sub) => this.handle(sub, true));\n const base = `z.tuple([${tupleItems.join(', ')}])`;\n // // If we have additionalItems: false => that\u2019s a fixed length\n // // If additionalItems is a schema => rest(...)\n // if (schema.additionalItems) {\n // if (typeof schema.additionalItems === 'object') {\n // const restSchema = jsonSchemaToZod(spec, schema.additionalItems, true);\n // base += `.rest(${restSchema})`;\n // }\n // // If `additionalItems: false`, no rest is allowed => do nothing\n // }\n return `${base}${appendOptional(required)}`;\n }\n\n // If items is a single schema => standard z.array(...)\n const itemsSchema = this.handle(items, true);\n return `z.array(${itemsSchema})${appendOptional(required)}`;\n }\n // oneOf() {}\n // enum() {}\n\n #suffixes = (defaultValue: unknown, required: boolean, nullable: boolean) => {\n return `${nullable ? '.nullable()' : ''}${appendDefault(defaultValue)}${appendOptional(required)}`;\n };\n\n /**\n * Convert a basic type (string | number | boolean | object | array, etc.) to Zod.\n * We'll also handle .optional() if needed.\n */\n normal(\n type: string,\n schema: SchemaObject,\n required = false,\n nullable = false,\n ): string {\n switch (type) {\n case 'string':\n return `${this.string(schema)}${this.#suffixes(JSON.stringify(schema.default), required, nullable)}`;\n case 'number':\n case 'integer': {\n const { base, defaultValue } = this.number(schema);\n return `${base}${this.#suffixes(defaultValue, required, nullable)}`;\n }\n case 'boolean':\n return `z.boolean()${this.#suffixes(schema.default, required, nullable)}`;\n case 'object':\n return this.object(schema, true); // required always\n case 'array':\n return this.array(schema, required);\n case 'null':\n // If \"type\": \"null\" alone, this is basically z.null()\n return `z.null()${appendOptional(required)}`;\n default:\n // Unknown type -> fallback\n return `z.unknown()${appendOptional(required)}`;\n }\n }\n\n ref($ref: string, required: boolean) {\n const schemaName = cleanRef($ref).split('/').pop()!;\n\n if (this.circularRefTracker.has(schemaName)) {\n return schemaName;\n }\n\n this.circularRefTracker.add(schemaName);\n this.#onRef?.(\n schemaName,\n this.handle(followRef(this.#spec, $ref), required),\n );\n this.circularRefTracker.delete(schemaName);\n\n return schemaName;\n }\n allOf(schemas: (SchemaObject | ReferenceObject)[]) {\n const allOfSchemas = schemas.map((sub) => this.handle(sub, true));\n if (allOfSchemas.length === 0) {\n return `z.unknown()`;\n }\n if (allOfSchemas.length === 1) {\n return allOfSchemas[0];\n }\n return this.#toIntersection(allOfSchemas);\n }\n\n #toIntersection(schemas: string[]): string {\n const [left, ...right] = schemas;\n if (!right.length) {\n return left;\n }\n return `z.intersection(${left}, ${this.#toIntersection(right)})`;\n }\n\n anyOf(schemas: (SchemaObject | ReferenceObject)[], required: boolean) {\n const anyOfSchemas = schemas.map((sub) => this.handle(sub, false));\n if (anyOfSchemas.length === 1) {\n return anyOfSchemas[0];\n }\n return anyOfSchemas.length > 1\n ? `z.union([${anyOfSchemas.join(', ')}])${appendOptional(required)}`\n : // Handle an invalid anyOf with one schema\n anyOfSchemas[0];\n }\n\n oneOf(schemas: (SchemaObject | ReferenceObject)[], required: boolean) {\n const oneOfSchemas = schemas.map((sub) => {\n if (isRef(sub)) {\n const { model } = parseRef(sub.$ref);\n if (this.circularRefTracker.has(model)) {\n return model;\n }\n }\n return this.handle(sub, true);\n });\n if (oneOfSchemas.length === 1) {\n return oneOfSchemas[0];\n }\n return oneOfSchemas.length > 1\n ? `z.union([${oneOfSchemas.join(', ')}])${appendOptional(required)}`\n : // Handle an invalid oneOf with one schema\n oneOfSchemas[0];\n }\n\n enum(values: any[], required: boolean) {\n const enumVals = values.map((val) => JSON.stringify(val)).join(', ');\n return `z.enum([${enumVals}])${appendOptional(required)}`;\n }\n\n /**\n * Handle a `string` schema with possible format keywords (JSON Schema).\n */\n string(schema: SchemaObject): string {\n let base = 'z.string()';\n\n // 3.1 replaces `example` in the schema with `examples` (array).\n // We do not strictly need them for the Zod type, so they\u2019re optional\n // for validation. However, we could keep them as metadata if you want.\n\n switch (schema.format) {\n case 'date-time':\n case 'datetime':\n // parse to JS Date\n base = 'z.coerce.date()';\n break;\n case 'date':\n base =\n 'z.coerce.date() /* or z.string() if you want raw date strings */';\n break;\n case 'time':\n base =\n 'z.string() /* optionally add .regex(...) for HH:MM:SS format */';\n break;\n case 'email':\n base = 'z.string().email()';\n break;\n case 'uuid':\n base = 'z.string().uuid()';\n break;\n case 'url':\n case 'uri':\n base = 'z.string().url()';\n break;\n case 'ipv4':\n base = 'z.string().ip({version: \"v4\"})';\n break;\n case 'ipv6':\n base = 'z.string().ip({version: \"v6\"})';\n break;\n case 'phone':\n base = 'z.string() /* or add .regex(...) for phone formats */';\n break;\n case 'byte':\n case 'binary':\n base = 'z.instanceof(Blob) /* consider base64 check if needed */';\n break;\n case 'int64':\n // JS numbers can't reliably store int64, consider z.bigint() or keep as string\n base = 'z.string() /* or z.bigint() if your app can handle it */';\n break;\n default:\n // No special format\n break;\n }\n\n return base;\n }\n\n /**\n * Handle number/integer constraints from OpenAPI/JSON Schema.\n * In 3.1, exclusiveMinimum/Maximum hold the actual numeric threshold,\n * rather than a boolean toggling `minimum`/`maximum`.\n */\n number(schema: SchemaObject) {\n let defaultValue = schema.default;\n let base = 'z.number()';\n if (schema.format === 'int64') {\n base = 'z.bigint()';\n if (schema.default !== undefined) {\n defaultValue = `BigInt(${schema.default})`;\n }\n }\n\n if (schema.format === 'int32') {\n // 32-bit integer\n base += '.int()';\n }\n\n // If we see exclusiveMinimum as a number in 3.1:\n if (typeof schema.exclusiveMinimum === 'number') {\n // Zod doesn\u2019t have a direct \"exclusiveMinimum\" method, so we can do .gt()\n // If exclusiveMinimum=7 => .gt(7)\n base += `.gt(${schema.exclusiveMinimum})`;\n }\n // Similarly for exclusiveMaximum\n if (typeof schema.exclusiveMaximum === 'number') {\n // If exclusiveMaximum=10 => .lt(10)\n base += `.lt(${schema.exclusiveMaximum})`;\n }\n\n // If standard minimum/maximum\n if (typeof schema.minimum === 'number') {\n base +=\n schema.format === 'int64'\n ? `.min(BigInt(${schema.minimum}))`\n : `.min(${schema.minimum})`;\n }\n if (typeof schema.maximum === 'number') {\n base +=\n schema.format === 'int64'\n ? `.max(BigInt(${schema.maximum}))`\n : `.max(${schema.maximum})`;\n }\n\n // multipleOf\n if (typeof schema.multipleOf === 'number') {\n // There's no direct multipleOf in Zod. Some folks do a custom refine.\n // For example:\n base += `.refine((val) => Number.isInteger(val / ${schema.multipleOf}), \"Must be a multiple of ${schema.multipleOf}\")`;\n }\n\n return { base, defaultValue };\n }\n\n handle(schema: SchemaObject | ReferenceObject, required: boolean): string {\n if (isRef(schema)) {\n return this.ref(schema.$ref, required);\n }\n\n // Handle allOf \u2192 intersection\n if (schema.allOf && Array.isArray(schema.allOf)) {\n return this.allOf(schema.allOf ?? []);\n }\n\n // anyOf \u2192 union\n if (schema.anyOf && Array.isArray(schema.anyOf)) {\n return this.anyOf(schema.anyOf ?? [], required);\n }\n\n // oneOf \u2192 union\n if (schema.oneOf && Array.isArray(schema.oneOf) && schema.oneOf.length) {\n return this.oneOf(schema.oneOf ?? [], required);\n }\n\n // enum\n if (schema.enum && Array.isArray(schema.enum)) {\n return this.enum(schema.enum, required);\n }\n\n // 3.1 can have type: string or type: string[] (e.g. [\"string\",\"null\"])\n // Let's parse that carefully.\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n\n // If no explicit \"type\", fallback to unknown\n if (!types.length) {\n return `z.unknown()${appendOptional(required)}`;\n }\n\n // If it's a union type (like [\"string\", \"null\"]), we'll build a Zod union\n // or apply .nullable() if it's just \"type + null\".\n\n // backward compatibility with openapi 3.0\n if ('nullable' in schema && schema.nullable) {\n types.push('null');\n }\n\n if (types.length > 1) {\n // If it\u2019s exactly one real type plus \"null\", we can do e.g. `z.string().nullable()`\n const realTypes = types.filter((t) => t !== 'null');\n if (realTypes.length === 1 && types.includes('null')) {\n // Single real type + \"null\"\n return this.normal(realTypes[0], schema, required, true);\n }\n // If multiple different types, build a union\n const subSchemas = types.map((t) => this.normal(t, schema, false));\n return `z.union([${subSchemas.join(', ')}])${appendOptional(required)}`;\n }\n return this.normal(types[0], schema, required, false);\n }\n}\n\n/**\n * Append .optional() if not required\n */\nfunction appendOptional(isRequired?: boolean) {\n return isRequired ? '' : '.optional()';\n}\nfunction appendDefault(defaultValue?: any) {\n return defaultValue !== undefined ? `.default(${defaultValue})` : '';\n}\n\n// Todo: convert openapi 3.0 to 3.1 before proccesing\n", "export interface Interceptor {\n before?: (request: Request) => Promise<Request> | Request;\n after?: (response: Response) => Promise<Response> | Response;\n}\n\nexport const createHeadersInterceptor = (\n defaultHeaders: () => Record<string, string | undefined>,\n requestHeaders: HeadersInit,\n) => {\n return {\n before(request: Request) {\n // Priority Levels\n // 1. Headers Input\n // 2. Request Headers\n // 3. Default Headers\n const headers = defaultHeaders();\n\n for (const [key, value] of new Headers(requestHeaders)) {\n // Only set the header if it doesn't already exist and has a value\n // even though these headers are passed at operation level\n // still they are lower priority compared to the headers input\n if (value !== undefined && !request.headers.has(key)) {\n request.headers.set(key, value);\n }\n }\n\n for (const [key, value] of Object.entries(headers)) {\n // Only set the header if it doesn't already exist and has a value\n if (value !== undefined && !request.headers.has(key)) {\n request.headers.set(key, value);\n }\n }\n\n return request;\n },\n };\n};\n\nexport const createBaseUrlInterceptor = (getBaseUrl: () => string) => {\n return {\n before(request: Request) {\n const baseUrl = getBaseUrl();\n if (request.url.startsWith('local://')) {\n return new Request(request.url.replace('local://', baseUrl), request);\n }\n return request;\n },\n };\n};\n\nexport const logInterceptor = {\n before(request: Request) {\n console.log('Request', request);\n return request;\n },\n after(response: Response) {\n console.log('Response', response);\n return response;\n },\n};\n\n/**\n * Creates an interceptor that logs detailed information about requests and responses.\n * @param options Configuration options for the logger\n * @returns An interceptor object with before and after handlers\n */\nexport const createDetailedLogInterceptor = (options?: {\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n includeRequestBody?: boolean;\n includeResponseBody?: boolean;\n}) => {\n const logLevel = options?.logLevel || 'info';\n const includeRequestBody = options?.includeRequestBody || false;\n const includeResponseBody = options?.includeResponseBody || false;\n\n return {\n async before(request: Request) {\n const logData = {\n url: request.url,\n method: request.method,\n contentType: request.headers.get('Content-Type'),\n headers: Object.fromEntries([...request.headers.entries()]),\n };\n\n console[logLevel]('\uD83D\uDE80 Outgoing Request:', logData);\n\n if (includeRequestBody) {\n try {\n // Clone the request to avoid consuming the body stream\n const clonedRequest = request.clone();\n if (clonedRequest.headers.get('Content-Type')?.includes('application/json')) {\n const body = await clonedRequest.json().catch(() => null);\n console[logLevel]('Request Body:', body);\n } else {\n const body = await clonedRequest.text().catch(() => null);\n console[logLevel]('Request Body:', body);\n }\n } catch (error) {\n console.error('Could not log request body:', error);\n }\n }\n\n return request;\n },\n\n async after(response: Response) {\n const logData = {\n status: response.status,\n statusText: response.statusText,\n url: response.url,\n headers: Object.fromEntries([...response.headers.entries()]),\n };\n\n console[logLevel]('\uD83D\uDCE5 Incoming Response:', logData);\n\n if (includeResponseBody && response.body) {\n try {\n // Clone the response to avoid consuming the body stream\n const clonedResponse = response.clone();\n if (clonedResponse.headers.get('Content-Type')?.includes('application/json')) {\n const body = await clonedResponse.json().catch(() => null);\n console[logLevel]('Response Body:', body);\n } else {\n const body = await clonedResponse.text().catch(() => null);\n if (body) {\n console[logLevel]('Response Body:', body.substring(0, 500) + (body.length > 500 ? '...' : ''));\n } else {\n console[logLevel]('No response body');\n }\n }\n } catch (error) {\n console.error('Could not log response body:', error);\n }\n }\n\n return response;\n },\n };\n};\n", "import { parse } from \"fast-content-type-parse\";\n\nexport async function handleError(response: Response) {\n\ttry {\n\t\tif (response.status >= 400 && response.status < 500) {\n\t\t\tconst body = (await response.json()) as Record<string, any>;\n\t\t\treturn {\n\t\t\t\tstatus: response.status,\n\t\t\t\tbody: body,\n\t\t\t};\n\t\t}\n\t\treturn new Error(\n\t\t\t`An error occurred while fetching the data. Status: ${response.status}`,\n\t\t);\n\t} catch (error) {\n\t\treturn error as any;\n\t}\n}\n\nasync function handleChunkedResponse(response: Response, contentType: string) {\n\tconst { type } = parse(contentType);\n\n\tswitch (type) {\n\t\tcase \"application/json\": {\n\t\t\tlet buffer = \"\";\n\t\t\tconst reader = response.body!.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\twhile (true) {\n\t\t\t\tconst { value, done } = await reader.read();\n\t\t\t\tif (done) break;\n\t\t\t\tbuffer += decoder.decode(value);\n\t\t\t}\n\t\t\treturn JSON.parse(buffer);\n\t\t}\n\t\tcase \"text/html\":\n\t\tcase \"text/plain\": {\n\t\t\tlet buffer = \"\";\n\t\t\tconst reader = response.body!.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\twhile (true) {\n\t\t\t\tconst { value, done } = await reader.read();\n\t\t\t\tif (done) break;\n\t\t\t\tbuffer += decoder.decode(value);\n\t\t\t}\n\t\t\treturn buffer;\n\t\t}\n\t\tdefault:\n\t\t\treturn response.body;\n\t}\n}\n\nexport function chunked(response: Response) {\n\treturn response.body;\n}\n\nexport async function buffered(response: Response) {\n\tconst contentType = response.headers.get(\"Content-Type\");\n\tif (!contentType) {\n\t\tthrow new Error(\"Content-Type header is missing\");\n\t}\n\n\tif (response.status === 204) {\n\t\treturn null;\n\t}\n\n\tconst { type } = parse(contentType);\n\tswitch (type) {\n\t\tcase \"application/json\":\n\t\t\treturn response.json();\n\t\tcase \"text/plain\":\n\t\t\treturn response.text();\n\t\tcase \"text/html\":\n\t\t\treturn response.text();\n\t\tcase \"text/xml\":\n\t\tcase \"application/xml\":\n\t\t\treturn response.text();\n\t\tcase \"application/x-www-form-urlencoded\": {\n\t\t\tconst text = await response.text();\n\t\t\treturn Object.fromEntries(new URLSearchParams(text));\n\t\t}\n\t\tcase \"multipart/form-data\":\n\t\t\treturn response.formData();\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported content type: ${contentType}`);\n\t}\n}\n", "import { z } from 'zod';\n\nexport type ParseError<T extends z.ZodType<any, any, any>> = {\n kind: 'parse';\n} & z.inferFlattenedErrors<T>;\n\nexport function parse<T extends z.ZodType>(\n schema: T,\n input: unknown,\n) {\n const result = schema.safeParse(input);\n if (!result.success) {\n const errors = result.error.flatten((issue) => issue);\n return [null, errors];\n }\n return [result.data as z.infer<T>, null];\n}\n", "export type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\nexport type ContentType = 'xml' | 'json' | 'urlencoded' | 'multipart' | 'formdata';\nexport type Endpoint =\n | `${ContentType} ${Method} ${string}`\n | `${Method} ${string}`;\n\nexport type BodyInit =\n | ArrayBuffer\n | Blob\n | FormData\n | URLSearchParams\n | null\n | string;\n\nexport function createUrl(path: string, query: URLSearchParams) {\n const url = new URL(path, `local://`);\n url.search = query.toString();\n return url;\n}\n\nfunction template(\n templateString: string,\n templateVariables: Record<string, any>,\n): string {\n const nargs = /{([0-9a-zA-Z_]+)}/g;\n return templateString.replace(nargs, (match, key: string, index: number) => {\n // Handle escaped double braces\n if (\n templateString[index - 1] === '{' &&\n templateString[index + match.length] === '}'\n ) {\n return key;\n }\n\n const result = key in templateVariables ? templateVariables[key] : null;\n return result === null || result === undefined ? '' : String(result);\n });\n}\n\ntype Input = Record<string, any>;\ntype Props = {\n inputHeaders: string[];\n inputQuery: string[];\n inputBody: string[];\n inputParams: string[];\n};\n\nabstract class Serializer {\n protected input: Input;\n protected props: Props;\n\n constructor(\n input: Input,\n props: Props,\n ) {\n this.input = input;\n this.props = props;\n }\n\n abstract getBody(): BodyInit | null;\n abstract getHeaders(): Record<string, string>;\n serialize(): Serialized {\n const headers = new Headers({});\n for (const header of this.props.inputHeaders) {\n headers.set(header, this.input[header]);\n }\n\n const query = new URLSearchParams();\n for (const key of this.props.inputQuery) {\n const value = this.input[key];\n if (value !== undefined) {\n query.set(key, String(value));\n }\n }\n\n const params = this.props.inputParams.reduce<Record<string, any>>(\n (acc, key) => {\n acc[key] = this.input[key];\n return acc;\n },\n {},\n );\n\n return {\n body: this.getBody(),\n query,\n params,\n headers: this.getHeaders(),\n };\n }\n}\n\ninterface Serialized {\n body: BodyInit | null;\n query: URLSearchParams;\n params: Record<string, any>;\n headers: Record<string, string>;\n}\n\nclass JsonSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body: Record<string, any> = {};\n for (const prop of this.props.inputBody) {\n body[prop] = this.input[prop];\n }\n return JSON.stringify(body);\n }\n getHeaders(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n };\n }\n}\n\nclass UrlencodedSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body = new URLSearchParams();\n for (const prop of this.props.inputBody) {\n body.set(prop, this.input[prop]);\n }\n return body;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nclass NoBodySerializer extends Serializer {\n getBody(): BodyInit | null {\n return null;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nclass FormDataSerializer extends Serializer {\n getBody(): BodyInit | null {\n const body = new FormData();\n for (const prop of this.props.inputBody) {\n body.append(prop, this.input[prop]);\n }\n return body;\n }\n getHeaders(): Record<string, string> {\n return {};\n }\n}\n\nexport function json(input: Input, props: Props) {\n return new JsonSerializer(input, props).serialize();\n}\nexport function urlencoded(input: Input, props: Props) {\n return new UrlencodedSerializer(input, props).serialize();\n}\nexport function nobody(input: Input, props: Props) {\n return new NoBodySerializer(input, props).serialize();\n}\nexport function formdata(input: Input, props: Props) {\n return new FormDataSerializer(input, props).serialize();\n}\n\nexport function toRequest<T extends Endpoint>(\n endpoint: T,\n input: Serialized,\n): Request {\n const [method, path] = endpoint.split(' ');\n const pathVariable = template(path, input.params);\n\n const url = createUrl(pathVariable, input.query);\n return new Request(url, {\n method: method,\n headers: input.headers,\n body: method === 'GET' ? undefined : input.body,\n });\n}\n", "export interface ApiResponse<Status extends number, Body extends unknown> {\n kind: 'response';\n status: Status;\n body: Body;\n}\n\n// 4xx Client Errors\nexport type BadRequest = ApiResponse<400, { message: string }>;\nexport type Unauthorized = ApiResponse<401, { message: string }>;\nexport type PaymentRequired = ApiResponse<402, { message: string }>;\nexport type Forbidden = ApiResponse<403, { message: string }>;\nexport type NotFound = ApiResponse<404, { message: string }>;\nexport type MethodNotAllowed = ApiResponse<405, { message: string }>;\nexport type NotAcceptable = ApiResponse<406, { message: string }>;\nexport type Conflict = ApiResponse<409, { message: string }>;\nexport type Gone = ApiResponse<410, { message: string }>;\nexport type UnprocessableEntity = ApiResponse<422, { message: string; errors?: Record<string, string[]> }>;\nexport type TooManyRequests = ApiResponse<429, { message: string; retryAfter?: string }>;\nexport type PayloadTooLarge = ApiResponse<413, { message: string; }>;\nexport type UnsupportedMediaType = ApiResponse<415, { message: string; }>;\n\n// 5xx Server Errors\nexport type InternalServerError = ApiResponse<500, { message: string }>;\nexport type NotImplemented = ApiResponse<501, { message: string }>;\nexport type BadGateway = ApiResponse<502, { message: string }>;\nexport type ServiceUnavailable = ApiResponse<503, { message: string; retryAfter?: string }>;\nexport type GatewayTimeout = ApiResponse<504, { message: string }>;\n\nexport type ClientError =\n | BadRequest\n | Unauthorized\n | PaymentRequired\n | Forbidden\n | NotFound\n | MethodNotAllowed\n | NotAcceptable\n | Conflict\n | Gone\n | UnprocessableEntity\n | TooManyRequests;\n\nexport type ServerError =\n | InternalServerError\n | NotImplemented\n | BadGateway\n | ServiceUnavailable\n | GatewayTimeout;\n\nexport type ProblematicResponse = ClientError | ServerError;\n", "\nexport interface RequestSchema {\n schema: z.ZodType;\n toRequest: (input: any) => Request;\n deserializer: (response: Response) => Promise<unknown> | unknown;\n}\n\nexport const fetchType = z\n .function()\n .args(z.instanceof(Request))\n .returns(z.promise(z.instanceof(Response)))\n .optional();\n\nexport async function sendRequest(\n input: unknown,\n route: RequestSchema,\n options: {\n fetch?: z.infer<typeof fetchType>;\n interceptors?: Interceptor[];\n signal?: AbortSignal;\n },\n) {\n const { interceptors = [] } = options;\n const [parsedInput, parseError] = parse(route.schema, input);\n if (parseError) {\n return [null as never, { ...parseError, kind: 'parse' } as never] as const;\n }\n\n let request = route.toRequest(parsedInput as never);\n for (const interceptor of interceptors) {\n if (interceptor.before) {\n request = await interceptor.before(request);\n }\n }\n\n let response = await (options.fetch ?? fetch)(request, { signal: options.signal });\n\n for (let i = interceptors.length - 1; i >= 0; i--) {\n const interceptor = interceptors[i];\n if (interceptor.after) {\n response = await interceptor.after(response.clone());\n }\n }\n\n if (response.ok) {\n const data = await route.deserializer(response);\n return [data as never, null] as const;\n }\n const error = await handleError(response);\n return [null as never, { ...error, kind: 'response' }] as const;\n}\n", "import { watch as nodeWatch } from 'node:fs/promises';\nimport { debounceTime, from } from 'rxjs';\n\nexport function watch(path: string) {\n return from(\n nodeWatch(path, {\n persistent: true,\n recursive: true,\n }),\n ).pipe(debounceTime(400));\n}\n"],
5
+ "mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAG9B,SAAS,kBAAkB,SAAS,kBAAkB;;;ACJtD,SAAS,OAAAA,MAAK,aAAa;AAW3B,SAAS,aAAAC,YAAW,YAAY,cAAAC,mBAAkB;AAElD,SAAS,oBAAAC,yBAAwB;;;ACbjC,SAAS,WAAW;AASpB,SAAS,oBAAAC,yBAAwB;;;ACTjC,SAAS,WAAW,kBAAkB;AAEtC,SAAS,kBAAkB,eAAAC,oBAAmB;;;ACF9C,SAAS,mBAAmB;AAI5B,IAAO,iBAAQ,CAAC,SAAe;AAC7B,QAAM,iBAAiB,OAAO,QAAQ,KAAK,OAAO,EAAE;AAAA,IAClD,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,IAAI,GAAG,KAAK,KAAK;AAAA,EACtC;AACA,QAAM,iBAAiB,IAAI,eACxB,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,MAAM,OAAO,QAAQ,EAC3C;AAAA,IACC,CAAC,CAAC,KAAK,KAAK,MACV,GAAG,GAAG,kBAAkB,MAAM,aAAa,IAAI,MAAM,UAAU,MAAM,GAAG;AAAA,EAC5E,EACC,KAAK,KAAK,CAAC;AACd,QAAM,gBAAgB,IAAI,eACvB,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,MAAM,OAAO,OAAO,EAC1C;AAAA,IACC,CAAC,CAAC,KAAK,KAAK,MACV,GAAG,GAAG,kBAAkB,MAAM,aAAa,IAAI,MAAM,UAAU,MAAM,GAAG;AAAA,EAC5E,EACC,KAAK,KAAK,CAAC;AACd,QAAM,cAAkD;AAAA,IACtD,GAAG,OAAO;AAAA,MACR,eAAe,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,MAAM,cAAc,KAAK,KAAK,CAAC;AAAA,IACvE;AAAA,IACA,OAAO;AAAA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ACD,MAAI,SAAS,SAAS,QAAQ;AAC5B,UAAM,WAAW,SAAS,QAAQ;AAAA,MAChC,gBAAgB;AAAA,QACd,gBAAgB;AAAA,QAChB,SAAS,KAAK;AAAA,UACZ;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,cACZ,2BAA2B;AAAA,cAC3B,KAAK;AAAA,YACP;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,MACA,iBAAiB;AAAA,QACf,gBAAgB;AAAA,QAChB,SAAS,KAAK;AAAA,UACZ;AAAA,YACE,iBAAiB;AAAA,cACf,cAAc;AAAA,cACd,qBAAqB;AAAA,cACrB,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,QAAQ;AAAA,cACR,4BAA4B;AAAA,cAC5B,sBAAsB;AAAA,cACtB,SAAS;AAAA,cACT,kBAAkB;AAAA,YACpB;AAAA,YACA,SAAS,CAAC,SAAS;AAAA,UACrB;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,SAAS,aAAa;AAAA,IAC1B;AAAA,IACA,KAAK,cAAc;AAAA,EACrB,CAAC;AACH;;;AapMA,SAAS,SAAS,iBAAiB;AACnC,SAAS,cAAc,YAAY;AAE5B,SAAS,MAAM,MAAc;AAClC,SAAO;AAAA,IACL,UAAU,MAAM;AAAA,MACd,YAAY;AAAA,MACZ,WAAW;AAAA,IACb,CAAC;AAAA,EACH,EAAE,KAAK,aAAa,GAAG,CAAC;AAC1B;",
6
+ "names": ["get", "camelcase", "spinalcase", "removeDuplicates", "removeDuplicates", "toLitObject", "toLitObject", "schema", "name", "security", "removeDuplicates", "it", "exclude", "appendOptional", "spinalcase", "camelcase", "methods", "security", "get", "removeDuplicates", "security"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;+BAEf,IAAI;AAA1B,wBAsFE"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;+BAEf,IAAI;AAA1B,wBAwFE"}
@@ -2,7 +2,6 @@ import type { OpenAPIObject, ReferenceObject, SchemaObject } from 'openapi3-ts/o
2
2
  type OnRefCallback = (ref: string, interfaceContent: string) => void;
3
3
  /**
4
4
  * Convert an OpenAPI (JSON Schema style) object into TypeScript interfaces,
5
- * following the same pattern as ZodDeserialzer for easy interchangeability.
6
5
  */
7
6
  export declare class TypeScriptDeserialzer {
8
7
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/lib/emitters/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACb,MAAM,mBAAmB,CAAC;AAI3B,KAAK,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,KAAK,IAAI,CAAC;AAErE;;;GAGG;AACH,qBAAa,qBAAqB;;IAChC,kBAAkB,cAAqB;gBAI3B,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa;IA0FrD;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,UAAQ,GAAG,MAAM;IAwBtD;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,UAAQ,GAAG,MAAM;IAkBrD;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,UAAQ,GAAG,MAAM;IAqBpE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM;IA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S,CAAC;IAClC,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAsBD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,WAAW,CAAC,EAAE,CACZ,SAAS,EAAE,eAAe,EAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,KACX,MAAM,CAAC;IACZ,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC;AAED,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAC/C,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAShD,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB;;;;;EA+OrD"}
@@ -7,7 +7,7 @@ export declare function parseRef(ref: string): {
7
7
  path: string;
8
8
  };
9
9
  export declare function followRef(spec: OpenAPIObject, ref: string): SchemaObject;
10
- export declare function securityToOptions(security: SecurityRequirementObject[], securitySchemas: ComponentsObject['securitySchemes'], staticIn?: string): Options;
10
+ export declare function securityToOptions(security: SecurityRequirementObject[], securitySchemes: ComponentsObject['securitySchemes'], staticIn?: string): Options;
11
11
  export declare function mergeImports(imports: Import[]): Import[];
12
12
  export interface Import {
13
13
  isTypeOnly: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,wBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG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@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdk-it/typescript",
3
- "version": "0.13.0",
3
+ "version": "0.14.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "!**/*.tsbuildinfo"
22
22
  ],
23
23
  "dependencies": {
24
- "@sdk-it/core": "0.13.0",
24
+ "@sdk-it/core": "0.14.2",
25
25
  "openapi3-ts": "^4.4.0",
26
26
  "stringcase": "^4.3.1",
27
27
  "lodash-es": "^4.17.21",