typed-openapi 1.4.5 → 1.5.1

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.
@@ -0,0 +1,21 @@
1
+ // src/format.ts
2
+ import prettier from "prettier";
3
+ import parserTypescript from "prettier/parser-typescript";
4
+ function maybePretty(input, options) {
5
+ try {
6
+ return prettier.format(input, {
7
+ parser: "typescript",
8
+ plugins: [parserTypescript],
9
+ ...options
10
+ });
11
+ } catch (err) {
12
+ console.warn("Failed to format code");
13
+ console.warn(err);
14
+ return input;
15
+ }
16
+ }
17
+ var prettify = (str, options) => maybePretty(str, { printWidth: 120, trailingComma: "all", ...options });
18
+
19
+ export {
20
+ prettify
21
+ };
@@ -2,9 +2,11 @@ import {
2
2
  allowedRuntimes,
3
3
  generateFile,
4
4
  generateTanstackQueryFile,
5
- mapOpenApiEndpoints,
5
+ mapOpenApiEndpoints
6
+ } from "./chunk-OVT6OLBK.js";
7
+ import {
6
8
  prettify
7
- } from "./chunk-52X6V4N5.js";
9
+ } from "./chunk-KAEXXJ7X.js";
8
10
 
9
11
  // src/generate-client-files.ts
10
12
  import SwaggerParser from "@apidevtools/swagger-parser";
@@ -28,13 +30,16 @@ var optionsSchema = type({
28
30
  });
29
31
  async function generateClientFiles(input, options) {
30
32
  const openApiDoc = await SwaggerParser.bundle(input);
31
- const ctx = mapOpenApiEndpoints(openApiDoc);
33
+ const ctx = mapOpenApiEndpoints(openApiDoc, options);
32
34
  console.log(`Found ${ctx.endpointList.length} endpoints`);
33
- const content = await prettify(generateFile({
34
- ...ctx,
35
- runtime: options.runtime,
36
- schemasOnly: options.schemasOnly
37
- }));
35
+ const content = await prettify(
36
+ generateFile({
37
+ ...ctx,
38
+ runtime: options.runtime,
39
+ schemasOnly: options.schemasOnly,
40
+ nameTransform: options.nameTransform
41
+ })
42
+ );
38
43
  const outputPath = join(
39
44
  cwd,
40
45
  options.output ?? input + `.${options.runtime === "none" ? "client" : options.runtime}.ts`
@@ -47,7 +52,10 @@ async function generateClientFiles(input, options) {
47
52
  ...ctx,
48
53
  relativeApiClientPath: "./" + basename(outputPath)
49
54
  });
50
- const tanstackOutputPath = join(dirname(outputPath), typeof options.tanstack === "string" ? options.tanstack : `tanstack.client.ts`);
55
+ const tanstackOutputPath = join(
56
+ dirname(outputPath),
57
+ typeof options.tanstack === "string" ? options.tanstack : `tanstack.client.ts`
58
+ );
51
59
  console.log("Generating tanstack client...", tanstackOutputPath);
52
60
  await ensureDir(dirname(tanstackOutputPath));
53
61
  await writeFile(tanstackOutputPath, tanstackContent);
@@ -1,3 +1,7 @@
1
+ import {
2
+ prettify
3
+ } from "./chunk-KAEXXJ7X.js";
4
+
1
5
  // src/asserts.ts
2
6
  var isPrimitiveType = (type2) => primitiveTypeList.includes(type2);
3
7
  var primitiveTypeList = ["string", "number", "integer", "boolean", "null"];
@@ -104,15 +108,17 @@ var openApiSchemaToTs = ({ schema, meta: _inheritedMeta, ctx }) => {
104
108
  if (schemaType === "null") return t.literal("null");
105
109
  }
106
110
  if (!schemaType && schema.enum) {
107
- return t.union(schema.enum.map((value) => {
108
- if (typeof value === "string") {
109
- return t.literal(`"${value}"`);
110
- }
111
- if (value === null) {
112
- return t.literal("null");
113
- }
114
- return t.literal(value);
115
- }));
111
+ return t.union(
112
+ schema.enum.map((value) => {
113
+ if (typeof value === "string") {
114
+ return t.literal(`"${value}"`);
115
+ }
116
+ if (value === null) {
117
+ return t.literal("null");
118
+ }
119
+ return t.literal(value);
120
+ })
121
+ );
116
122
  }
117
123
  if (schemaType === "array") {
118
124
  if (schema.items) {
@@ -360,6 +366,20 @@ var parameterObjectToString = (parameters) => {
360
366
  }
361
367
  return str + "}";
362
368
  };
369
+ var responseHeadersObjectToString = (responseHeaders, ctx) => {
370
+ let str = "{";
371
+ for (const [key, responseHeader] of Object.entries(responseHeaders)) {
372
+ const value = ctx.runtime === "none" ? responseHeader.recompute((box) => {
373
+ if (Box.isReference(box) && !box.params.generics && box.value !== "null") {
374
+ box.value = `Schemas.${box.value}`;
375
+ }
376
+ return box;
377
+ }).value : responseHeader.value;
378
+ str += `${wrapWithQuotesIfNeeded(key.toLowerCase())}: ${value},
379
+ `;
380
+ }
381
+ return str + "}";
382
+ };
363
383
  var generateEndpointSchemaList = (ctx) => {
364
384
  let file = `
365
385
  ${ctx.runtime === "none" ? "export namespace Endpoints {" : ""}
@@ -391,6 +411,7 @@ var generateEndpointSchemaList = (ctx) => {
391
411
  }
392
412
  return box;
393
413
  }).value : endpoint.response.value},
414
+ ${endpoint.responseHeaders ? `responseHeaders: ${responseHeadersObjectToString(endpoint.responseHeaders, ctx)},` : ""}
394
415
  }
395
416
  `;
396
417
  });
@@ -446,6 +467,7 @@ type RequestFormat = "json" | "form-data" | "form-url" | "binary" | "text";
446
467
  export type DefaultEndpoint = {
447
468
  parameters?: EndpointParameters | undefined;
448
469
  response: unknown;
470
+ responseHeaders?: Record<string, unknown>;
449
471
  };
450
472
 
451
473
  export type Endpoint<TConfig extends DefaultEndpoint = DefaultEndpoint> = {
@@ -460,6 +482,7 @@ export type Endpoint<TConfig extends DefaultEndpoint = DefaultEndpoint> = {
460
482
  areParametersRequired: boolean;
461
483
  };
462
484
  response: TConfig["response"];
485
+ responseHeaders?: TConfig["responseHeaders"]
463
486
  };
464
487
 
465
488
  export type Fetcher = (method: Method, url: string, parameters?: EndpointParameters | undefined) => Promise<Response>;
@@ -584,10 +607,90 @@ function topologicalSort(graph) {
584
607
  return sorted;
585
608
  }
586
609
 
610
+ // src/sanitize-name.ts
611
+ var reservedWords = /* @__PURE__ */ new Set([
612
+ // TS keywords and built-ins
613
+ "import",
614
+ "package",
615
+ "namespace",
616
+ "Record",
617
+ "Partial",
618
+ "Required",
619
+ "Readonly",
620
+ "Pick",
621
+ "Omit",
622
+ "String",
623
+ "Number",
624
+ "Boolean",
625
+ "Object",
626
+ "Array",
627
+ "Function",
628
+ "any",
629
+ "unknown",
630
+ "never",
631
+ "void",
632
+ "extends",
633
+ "super",
634
+ "class",
635
+ "interface",
636
+ "type",
637
+ "enum",
638
+ "const",
639
+ "let",
640
+ "var",
641
+ "if",
642
+ "else",
643
+ "for",
644
+ "while",
645
+ "do",
646
+ "switch",
647
+ "case",
648
+ "default",
649
+ "break",
650
+ "continue",
651
+ "return",
652
+ "try",
653
+ "catch",
654
+ "finally",
655
+ "throw",
656
+ "new",
657
+ "delete",
658
+ "in",
659
+ "instanceof",
660
+ "typeof",
661
+ "void",
662
+ "with",
663
+ "yield",
664
+ "await",
665
+ "static",
666
+ "public",
667
+ "private",
668
+ "protected",
669
+ "abstract",
670
+ "as",
671
+ "asserts",
672
+ "from",
673
+ "get",
674
+ "set",
675
+ "module",
676
+ "require",
677
+ "keyof",
678
+ "readonly",
679
+ "global",
680
+ "symbol",
681
+ "bigint"
682
+ ]);
683
+ function sanitizeName(name, type2) {
684
+ let n = name.replace(/[\W/]+/g, "_");
685
+ if (/^\d/.test(n)) n = "_" + n;
686
+ if (reservedWords.has(n)) n = (type2 === "schema" ? "Schema_" : "Endpoint_") + n;
687
+ return n;
688
+ }
689
+
587
690
  // src/ref-resolver.ts
588
691
  var autocorrectRef = (ref) => ref[1] === "/" ? ref : "#/" + ref.slice(1);
589
692
  var componentsWithSchemas = ["schemas", "responses", "parameters", "requestBodies", "headers"];
590
- var createRefResolver = (doc, factory2) => {
693
+ var createRefResolver = (doc, factory2, nameTransform) => {
591
694
  const nameByRef = /* @__PURE__ */ new Map();
592
695
  const refByName = /* @__PURE__ */ new Map();
593
696
  const byRef = /* @__PURE__ */ new Map();
@@ -600,7 +703,11 @@ var createRefResolver = (doc, factory2) => {
600
703
  const normalizedPath = path.replace("#/", "").replace("#", "").replaceAll("/", ".");
601
704
  const map = get(doc, normalizedPath) ?? {};
602
705
  const name = split[split.length - 1];
603
- const normalized = normalizeString(name);
706
+ let normalized = normalizeString(name);
707
+ if (nameTransform?.transformSchemaName) {
708
+ normalized = nameTransform.transformSchemaName(normalized);
709
+ }
710
+ normalized = sanitizeName(normalized, "schema");
604
711
  nameByRef.set(correctRef, normalized);
605
712
  refByName.set(normalized, correctRef);
606
713
  const infos = { ref: correctRef, name, normalized, kind: normalizedPath.split(".")[1] };
@@ -749,7 +856,7 @@ var tsFactory = createFactory({
749
856
  import { capitalize as capitalize3, pick } from "pastable/server";
750
857
  import { match as match2, P } from "ts-pattern";
751
858
  var factory = tsFactory;
752
- var mapOpenApiEndpoints = (doc) => {
859
+ var mapOpenApiEndpoints = (doc, options) => {
753
860
  const refs = createRefResolver(doc, factory);
754
861
  const ctx = { refs, factory };
755
862
  const endpointList = [];
@@ -757,6 +864,10 @@ var mapOpenApiEndpoints = (doc) => {
757
864
  const pathItem = pick(pathItemObj, ["get", "put", "post", "delete", "options", "head", "patch", "trace"]);
758
865
  Object.entries(pathItem).forEach(([method, operation]) => {
759
866
  if (operation.deprecated) return;
867
+ let alias = getAlias({ path, method, operation });
868
+ if (options?.nameTransform?.transformEndpointName) {
869
+ alias = options.nameTransform.transformEndpointName({ alias, path, method, operation });
870
+ }
760
871
  const endpoint = {
761
872
  operation,
762
873
  method,
@@ -764,7 +875,7 @@ var mapOpenApiEndpoints = (doc) => {
764
875
  requestFormat: "json",
765
876
  response: openApiSchemaToTs({ schema: {}, ctx }),
766
877
  meta: {
767
- alias: getAlias({ path, method, operation }),
878
+ alias,
768
879
  areParametersRequired: false,
769
880
  hasParameters: false
770
881
  }
@@ -808,7 +919,7 @@ var mapOpenApiEndpoints = (doc) => {
808
919
  const matchingMediaType = Object.keys(content2).find(isAllowedParamMediaTypes);
809
920
  if (matchingMediaType && content2[matchingMediaType]) {
810
921
  params.body = openApiSchemaToTs({
811
- schema: content2[matchingMediaType]?.schema ?? {} ?? {},
922
+ schema: content2[matchingMediaType]?.schema ?? {},
812
923
  ctx
813
924
  });
814
925
  }
@@ -847,11 +958,22 @@ var mapOpenApiEndpoints = (doc) => {
847
958
  const matchingMediaType = Object.keys(content).find(isResponseMediaType);
848
959
  if (matchingMediaType && content[matchingMediaType]) {
849
960
  endpoint.response = openApiSchemaToTs({
850
- schema: content[matchingMediaType]?.schema ?? {} ?? {},
961
+ schema: content[matchingMediaType]?.schema ?? {},
851
962
  ctx
852
963
  });
853
964
  }
854
965
  }
966
+ const headers = responseObject?.headers;
967
+ if (headers) {
968
+ endpoint.responseHeaders = Object.entries(headers).reduce(
969
+ (acc, [name, headerOrRef]) => {
970
+ const header = refs.unwrap(headerOrRef);
971
+ acc[name] = openApiSchemaToTs({ schema: header.schema ?? {}, ctx });
972
+ return acc;
973
+ },
974
+ {}
975
+ );
976
+ }
855
977
  endpointList.push(endpoint);
856
978
  });
857
979
  });
@@ -865,25 +987,10 @@ var allowedParamMediaTypes = [
865
987
  ];
866
988
  var isAllowedParamMediaTypes = (mediaType) => mediaType.includes("application/") && mediaType.includes("json") || allowedParamMediaTypes.includes(mediaType) || mediaType.includes("text/");
867
989
  var isResponseMediaType = (mediaType) => mediaType === "application/json";
868
- var getAlias = ({ path, method, operation }) => (method + "_" + capitalize3(operation.operationId ?? pathToVariableName(path))).replace(/-/g, "__");
869
-
870
- // src/format.ts
871
- import prettier from "prettier";
872
- import parserTypescript from "prettier/parser-typescript";
873
- function maybePretty(input, options) {
874
- try {
875
- return prettier.format(input, {
876
- parser: "typescript",
877
- plugins: [parserTypescript],
878
- ...options
879
- });
880
- } catch (err) {
881
- console.warn("Failed to format code");
882
- console.warn(err);
883
- return input;
884
- }
885
- }
886
- var prettify = (str, options) => maybePretty(str, { printWidth: 120, trailingComma: "all", ...options });
990
+ var getAlias = ({ path, method, operation }) => sanitizeName(
991
+ (method + "_" + capitalize3(operation.operationId ?? pathToVariableName(path))).replace(/-/g, "__"),
992
+ "endpoint"
993
+ );
887
994
 
888
995
  // src/tanstack-query.generator.ts
889
996
  import { capitalize as capitalize4 } from "pastable/server";
@@ -1034,6 +1141,5 @@ export {
1034
1141
  createRefResolver,
1035
1142
  tsFactory,
1036
1143
  mapOpenApiEndpoints,
1037
- prettify,
1038
1144
  generateTanstackQueryFile
1039
1145
  };
package/dist/cli.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  generateClientFiles
3
- } from "./chunk-F4UA5MLD.js";
3
+ } from "./chunk-O7DZWQK4.js";
4
4
  import {
5
5
  allowedRuntimes
6
- } from "./chunk-52X6V4N5.js";
6
+ } from "./chunk-OVT6OLBK.js";
7
+ import "./chunk-KAEXXJ7X.js";
7
8
 
8
9
  // src/cli.ts
9
10
  import { cac } from "cac";
@@ -14,11 +15,7 @@ cli.command("<input>", "Generate").option("-o, --output <path>", "Output path fo
14
15
  "-r, --runtime <name>",
15
16
  `Runtime to use for validation; defaults to \`none\`; available: ${allowedRuntimes.toString()}`,
16
17
  { default: "none" }
17
- ).option(
18
- "--schemas-only",
19
- "Only generate schemas, skipping client generation (defaults to false)",
20
- { default: false }
21
- ).option(
18
+ ).option("--schemas-only", "Only generate schemas, skipping client generation (defaults to false)", { default: false }).option(
22
19
  "--tanstack [name]",
23
20
  "Generate tanstack client, defaults to false, can optionally specify a name for the generated file"
24
21
  ).action(async (input, _options) => {
package/dist/index.d.ts CHANGED
@@ -1,176 +1,9 @@
1
- import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
2
- import { OpenAPIObject, ReferenceObject, SchemaObject, OperationObject } from 'openapi3-ts/oas31';
3
- import { SchemaObject as SchemaObject$1 } from 'openapi3-ts/oas30';
1
+ import { ReferenceObject } from 'openapi3-ts/oas31';
2
+ import { S as StringOrBox, O as OpenapiSchemaConvertContext, L as LibSchemaObject, B as BoxFactory, m as mapOpenApiEndpoints, N as NameTransformOptions, a as OpenapiSchemaConvertArgs, b as Box, A as AnyBoxDef } from './types-DLE5RaXi.js';
3
+ export { q as AnyBox, j as BoxArray, f as BoxDefinition, i as BoxIntersection, o as BoxKeyword, n as BoxLiteral, p as BoxObject, k as BoxOptional, g as BoxParams, l as BoxRef, h as BoxUnion, c as Endpoint, E as EndpointParameters, F as FactoryCreator, G as GenericFactory, M as Method, R as RefInfo, e as RefResolver, W as WithSchema, d as createRefResolver } from './types-DLE5RaXi.js';
4
4
  import * as arktype_internal_methods_string_ts from 'arktype/internal/methods/string.ts';
5
5
  import * as Codegen from '@sinclair/typebox-codegen';
6
-
7
- declare class Box<T extends AnyBoxDef = AnyBoxDef> {
8
- definition: T;
9
- type: T["type"];
10
- value: T["value"];
11
- params: T["params"];
12
- schema: T["schema"];
13
- ctx: T["ctx"];
14
- constructor(definition: T);
15
- toJSON(): {
16
- type: T["type"];
17
- value: T["value"];
18
- };
19
- toString(): string;
20
- recompute(callback: OpenapiSchemaConvertContext["onBox"]): Box<AnyBoxDef>;
21
- static fromJSON(json: string): Box<any>;
22
- static isBox(box: unknown): box is Box<AnyBoxDef>;
23
- static isUnion(box: Box<AnyBoxDef>): box is Box<BoxUnion>;
24
- static isIntersection(box: Box<AnyBoxDef>): box is Box<BoxIntersection>;
25
- static isArray(box: Box<AnyBoxDef>): box is Box<BoxArray>;
26
- static isOptional(box: Box<AnyBoxDef>): box is Box<BoxOptional>;
27
- static isReference(box: Box<AnyBoxDef>): box is Box<BoxRef>;
28
- static isKeyword(box: Box<AnyBoxDef>): box is Box<BoxKeyword>;
29
- static isObject(box: Box<AnyBoxDef>): box is Box<BoxObject>;
30
- static isLiteral(box: Box<AnyBoxDef>): box is Box<BoxLiteral>;
31
- }
32
-
33
- type RefInfo = {
34
- /**
35
- * The (potentially autocorrected) ref
36
- * @example "#/components/schemas/MySchema"
37
- */
38
- ref: string;
39
- /**
40
- * The name of the ref
41
- * @example "MySchema"
42
- * */
43
- name: string;
44
- normalized: string;
45
- kind: "schemas" | "responses" | "parameters" | "requestBodies" | "headers";
46
- };
47
- declare const createRefResolver: (doc: OpenAPIObject, factory: GenericFactory) => {
48
- get: <T = LibSchemaObject>(ref: string) => NonNullable<T>;
49
- unwrap: <T extends ReferenceObject | {}>(component: T) => Exclude<T, ReferenceObject>;
50
- getInfosByRef: (ref: string) => RefInfo;
51
- infos: Map<string, RefInfo>;
52
- /**
53
- * Get the schemas in the order they should be generated, depending on their dependencies
54
- * so that a schema is generated before the ones that depend on it
55
- */
56
- getOrderedSchemas: () => [schema: Box<AnyBoxDef>, infos: RefInfo][];
57
- directDependencies: Map<string, Set<string>>;
58
- transitiveDependencies: Map<string, Set<string>>;
59
- };
60
- interface RefResolver extends ReturnType<typeof createRefResolver> {
61
- }
62
-
63
- type LibSchemaObject = SchemaObject & SchemaObject$1;
64
- type BoxDefinition = {
65
- type: string;
66
- params: unknown;
67
- value: string;
68
- };
69
- type BoxParams = string | BoxDefinition;
70
- type WithSchema = {
71
- schema: LibSchemaObject | ReferenceObject | undefined;
72
- ctx: OpenapiSchemaConvertContext;
73
- };
74
- type BoxUnion = WithSchema & {
75
- type: "union";
76
- params: {
77
- types: Array<BoxParams>;
78
- };
79
- value: string;
80
- };
81
- type BoxIntersection = WithSchema & {
82
- type: "intersection";
83
- params: {
84
- types: Array<BoxParams>;
85
- };
86
- value: string;
87
- };
88
- type BoxArray = WithSchema & {
89
- type: "array";
90
- params: {
91
- type: BoxParams;
92
- };
93
- value: string;
94
- };
95
- type BoxOptional = WithSchema & {
96
- type: "optional";
97
- params: {
98
- type: BoxParams;
99
- };
100
- value: string;
101
- };
102
- type BoxRef = WithSchema & {
103
- type: "ref";
104
- params: {
105
- name: string;
106
- generics?: BoxParams[] | undefined;
107
- };
108
- value: string;
109
- };
110
- type BoxLiteral = WithSchema & {
111
- type: "literal";
112
- params: {};
113
- value: string;
114
- };
115
- type BoxKeyword = WithSchema & {
116
- type: "keyword";
117
- params: {
118
- name: string;
119
- };
120
- value: string;
121
- };
122
- type BoxObject = WithSchema & {
123
- type: "object";
124
- params: {
125
- props: Record<string, BoxParams>;
126
- };
127
- value: string;
128
- };
129
- type AnyBoxDef = BoxUnion | BoxIntersection | BoxArray | BoxOptional | BoxRef | BoxLiteral | BoxKeyword | BoxObject;
130
- type AnyBox = Box<AnyBoxDef>;
131
- type OpenapiSchemaConvertArgs = {
132
- schema: SchemaObject | ReferenceObject;
133
- ctx: OpenapiSchemaConvertContext;
134
- meta?: {} | undefined;
135
- };
136
- type FactoryCreator = (schema: SchemaObject | ReferenceObject, ctx: OpenapiSchemaConvertContext) => GenericFactory;
137
- type OpenapiSchemaConvertContext = {
138
- factory: FactoryCreator | GenericFactory;
139
- refs: RefResolver;
140
- onBox?: (box: Box<AnyBoxDef>) => Box<AnyBoxDef>;
141
- };
142
- type StringOrBox = string | Box<AnyBoxDef>;
143
- type BoxFactory = {
144
- union: (types: Array<StringOrBox>) => Box<BoxUnion>;
145
- intersection: (types: Array<StringOrBox>) => Box<BoxIntersection>;
146
- array: (type: StringOrBox) => Box<BoxArray>;
147
- object: (props: Record<string, StringOrBox>) => Box<BoxObject>;
148
- optional: (type: StringOrBox) => Box<BoxOptional>;
149
- reference: (name: string, generics?: Array<StringOrBox> | undefined) => Box<BoxRef>;
150
- literal: (value: StringOrBox) => Box<BoxLiteral>;
151
- string: () => Box<BoxKeyword>;
152
- number: () => Box<BoxKeyword>;
153
- boolean: () => Box<BoxKeyword>;
154
- unknown: () => Box<BoxKeyword>;
155
- any: () => Box<BoxKeyword>;
156
- never: () => Box<BoxKeyword>;
157
- };
158
- type GenericFactory = {
159
- callback?: OpenapiSchemaConvertContext["onBox"];
160
- union: (types: Array<StringOrBox>) => string;
161
- intersection: (types: Array<StringOrBox>) => string;
162
- array: (type: StringOrBox) => string;
163
- object: (props: Record<string, StringOrBox>) => string;
164
- optional: (type: StringOrBox) => string;
165
- reference: (name: string, generics?: Array<StringOrBox> | undefined) => string;
166
- literal: (value: StringOrBox) => string;
167
- string: () => string;
168
- number: () => string;
169
- boolean: () => string;
170
- unknown: () => string;
171
- any: () => string;
172
- never: () => string;
173
- };
6
+ import 'openapi3-ts/oas30';
174
7
 
175
8
  declare const unwrap: (param: StringOrBox) => string;
176
9
  declare const createFactory: <T extends OpenapiSchemaConvertContext["factory"]>(f: T) => T;
@@ -179,64 +12,10 @@ declare const createFactory: <T extends OpenapiSchemaConvertContext["factory"]>(
179
12
  */
180
13
  declare const createBoxFactory: (schema: LibSchemaObject | ReferenceObject, ctx: OpenapiSchemaConvertContext) => BoxFactory;
181
14
 
182
- declare const mapOpenApiEndpoints: (doc: OpenAPIObject) => {
183
- doc: OpenAPIObject;
184
- refs: {
185
- get: <T = LibSchemaObject>(ref: string) => NonNullable<T>;
186
- unwrap: <T extends openapi3_ts_oas31.ReferenceObject | {}>(component: T) => Exclude<T, openapi3_ts_oas31.ReferenceObject>;
187
- getInfosByRef: (ref: string) => RefInfo;
188
- infos: Map<string, RefInfo>;
189
- getOrderedSchemas: () => [schema: Box<AnyBoxDef>, infos: RefInfo][];
190
- directDependencies: Map<string, Set<string>>;
191
- transitiveDependencies: Map<string, Set<string>>;
192
- };
193
- endpointList: Endpoint<DefaultEndpoint>[];
194
- factory: {
195
- union: (types: StringOrBox[]) => string;
196
- intersection: (types: StringOrBox[]) => string;
197
- array: (type: StringOrBox) => string;
198
- optional: (type: StringOrBox) => string;
199
- reference: (name: string, typeArgs: StringOrBox[] | undefined) => string;
200
- literal: (value: StringOrBox) => string;
201
- string: () => "string";
202
- number: () => "number";
203
- boolean: () => "boolean";
204
- unknown: () => "unknown";
205
- any: () => "any";
206
- never: () => "never";
207
- object: (props: Record<string, StringOrBox>) => string;
208
- };
209
- };
210
- type MutationMethod = "post" | "put" | "patch" | "delete";
211
- type Method = "get" | "head" | "options" | MutationMethod;
212
- type EndpointParameters = {
213
- body?: Box<BoxRef>;
214
- query?: Box<BoxRef> | Record<string, AnyBox>;
215
- header?: Box<BoxRef> | Record<string, AnyBox>;
216
- path?: Box<BoxRef> | Record<string, AnyBox>;
217
- };
218
- type RequestFormat = "json" | "form-data" | "form-url" | "binary" | "text";
219
- type DefaultEndpoint = {
220
- parameters?: EndpointParameters | undefined;
221
- response: AnyBox;
222
- };
223
- type Endpoint<TConfig extends DefaultEndpoint = DefaultEndpoint> = {
224
- operation: OperationObject;
225
- method: Method;
226
- path: string;
227
- parameters?: TConfig["parameters"];
228
- requestFormat: RequestFormat;
229
- meta: {
230
- alias: string;
231
- hasParameters: boolean;
232
- areParametersRequired: boolean;
233
- };
234
- response: TConfig["response"];
235
- };
236
-
237
15
  type GeneratorOptions$1 = ReturnType<typeof mapOpenApiEndpoints> & {
238
16
  runtime?: "none" | keyof typeof runtimeValidationGenerator;
239
17
  schemasOnly?: boolean;
18
+ nameTransform?: NameTransformOptions | undefined;
240
19
  };
241
20
  declare const allowedRuntimes: arktype_internal_methods_string_ts.StringType<"none" | "arktype" | "io-ts" | "typebox" | "valibot" | "yup" | "zod", {}>;
242
21
  type OutputRuntime = typeof allowedRuntimes.infer;
@@ -274,4 +53,4 @@ declare const tsFactory: {
274
53
  object: (props: Record<string, StringOrBox>) => string;
275
54
  };
276
55
 
277
- export { type AnyBox, type AnyBoxDef, type BoxArray, type BoxDefinition, type BoxFactory, type BoxIntersection, type BoxKeyword, type BoxLiteral, type BoxObject, type BoxOptional, type BoxParams, type BoxRef, type BoxUnion, type Endpoint, type EndpointParameters, type FactoryCreator, type GenericFactory, type LibSchemaObject, type OpenapiSchemaConvertArgs, type OpenapiSchemaConvertContext, type OutputRuntime, type RefInfo, type RefResolver, type StringOrBox, type WithSchema, createBoxFactory, createFactory, createRefResolver, generateFile, generateTanstackQueryFile, mapOpenApiEndpoints, openApiSchemaToTs, tsFactory, unwrap };
56
+ export { AnyBoxDef, BoxFactory, LibSchemaObject, NameTransformOptions, OpenapiSchemaConvertArgs, OpenapiSchemaConvertContext, type OutputRuntime, StringOrBox, createBoxFactory, createFactory, generateFile, generateTanstackQueryFile, mapOpenApiEndpoints, openApiSchemaToTs, tsFactory, unwrap };
package/dist/index.js CHANGED
@@ -8,7 +8,8 @@ import {
8
8
  openApiSchemaToTs,
9
9
  tsFactory,
10
10
  unwrap
11
- } from "./chunk-52X6V4N5.js";
11
+ } from "./chunk-OVT6OLBK.js";
12
+ import "./chunk-KAEXXJ7X.js";
12
13
  export {
13
14
  createBoxFactory,
14
15
  createFactory,
@@ -1,7 +1,7 @@
1
- import { Options } from 'prettier';
2
1
  import * as arktype_internal_methods_object_ts from 'arktype/internal/methods/object.ts';
3
-
4
- declare const prettify: (str: string, options?: Options | null) => string | Promise<string>;
2
+ import { N as NameTransformOptions } from './types-DLE5RaXi.js';
3
+ import 'openapi3-ts/oas31';
4
+ import 'openapi3-ts/oas30';
5
5
 
6
6
  declare const optionsSchema: arktype_internal_methods_object_ts.ObjectType<{
7
7
  runtime: "none" | "arktype" | "io-ts" | "typebox" | "valibot" | "yup" | "zod";
@@ -9,6 +9,9 @@ declare const optionsSchema: arktype_internal_methods_object_ts.ObjectType<{
9
9
  schemasOnly: boolean;
10
10
  output?: string;
11
11
  }, {}>;
12
- declare function generateClientFiles(input: string, options: typeof optionsSchema.infer): Promise<void>;
12
+ type GenerateClientFilesOptions = typeof optionsSchema.infer & {
13
+ nameTransform?: NameTransformOptions;
14
+ };
15
+ declare function generateClientFiles(input: string, options: GenerateClientFilesOptions): Promise<void>;
13
16
 
14
- export { generateClientFiles, prettify };
17
+ export { generateClientFiles };
@@ -1,10 +1,8 @@
1
1
  import {
2
2
  generateClientFiles
3
- } from "./chunk-F4UA5MLD.js";
4
- import {
5
- prettify
6
- } from "./chunk-52X6V4N5.js";
3
+ } from "./chunk-O7DZWQK4.js";
4
+ import "./chunk-OVT6OLBK.js";
5
+ import "./chunk-KAEXXJ7X.js";
7
6
  export {
8
- generateClientFiles,
9
- prettify
7
+ generateClientFiles
10
8
  };
@@ -0,0 +1,5 @@
1
+ import { Options } from 'prettier';
2
+
3
+ declare const prettify: (str: string, options?: Options | null) => string | Promise<string>;
4
+
5
+ export { prettify };