typed-openapi 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-R7C7MEWK.js → chunk-T4QUCLXL.js} +3 -3
- package/dist/cli.cjs +4 -4
- package/dist/cli.js +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/generator.ts +4 -2
- package/src/map-openapi-endpoints.ts +1 -1
|
@@ -291,7 +291,7 @@ var inferByRuntime = {
|
|
|
291
291
|
arktype: (input) => `${input}["infer"]`,
|
|
292
292
|
"io-ts": (input) => `t.TypeOf<${input}>`,
|
|
293
293
|
typebox: (input) => `Static<${input}>`,
|
|
294
|
-
valibot: (input) => `v.
|
|
294
|
+
valibot: (input) => `v.InferOutput<${input}>`,
|
|
295
295
|
yup: (input) => `y.InferType<${input}>`,
|
|
296
296
|
zod: (input) => `z.infer<${input}>`
|
|
297
297
|
};
|
|
@@ -487,7 +487,7 @@ export class ApiClient {
|
|
|
487
487
|
path: Path,
|
|
488
488
|
...params: MaybeOptionalArg<${match(ctx.runtime).with("zod", "yup", () => infer(`TEndpoint["parameters"]`)).with("arktype", "io-ts", "typebox", "valibot", () => infer(`TEndpoint`) + `["parameters"]`).otherwise(() => `TEndpoint["parameters"]`)}>
|
|
489
489
|
): Promise<${match(ctx.runtime).with("zod", "yup", () => infer(`TEndpoint["response"]`)).with("arktype", "io-ts", "typebox", "valibot", () => infer(`TEndpoint`) + `["response"]`).otherwise(() => `TEndpoint["response"]`)}> {
|
|
490
|
-
return this.fetcher("${method}", this.baseUrl + path, params[0])${match(ctx.runtime).with("zod", () => `as Promise<${infer(`TEndpoint["response"]`)}>`).otherwise(() =>
|
|
490
|
+
return this.fetcher("${method}", this.baseUrl + path, params[0])${match(ctx.runtime).with("zod", "yup", () => `as Promise<${infer(`TEndpoint["response"]`)}>`).with("arktype", "io-ts", "typebox", "valibot", () => `as Promise<${infer(`TEndpoint`) + `["response"]`}>`).otherwise(() => `as Promise<TEndpoint["response"]>`)};
|
|
491
491
|
}
|
|
492
492
|
// </ApiClient.${method}>
|
|
493
493
|
` : "";
|
|
@@ -823,7 +823,7 @@ var allowedParamMediaTypes = [
|
|
|
823
823
|
];
|
|
824
824
|
var isAllowedParamMediaTypes = (mediaType) => mediaType.includes("application/") && mediaType.includes("json") || allowedParamMediaTypes.includes(mediaType) || mediaType.includes("text/");
|
|
825
825
|
var isResponseMediaType = (mediaType) => mediaType === "application/json";
|
|
826
|
-
var getAlias = ({ path, method, operation }) => method + "_" + capitalize3(operation.operationId ?? pathToVariableName(path));
|
|
826
|
+
var getAlias = ({ path, method, operation }) => (method + "_" + capitalize3(operation.operationId ?? pathToVariableName(path))).replace(/-/g, "__");
|
|
827
827
|
|
|
828
828
|
export {
|
|
829
829
|
unwrap,
|
package/dist/cli.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var import_promises = require("fs/promises");
|
|
|
31
31
|
|
|
32
32
|
// package.json
|
|
33
33
|
var name = "typed-openapi";
|
|
34
|
-
var version = "0.
|
|
34
|
+
var version = "0.7.0";
|
|
35
35
|
|
|
36
36
|
// src/generator.ts
|
|
37
37
|
var import_server2 = require("pastable/server");
|
|
@@ -326,7 +326,7 @@ var inferByRuntime = {
|
|
|
326
326
|
arktype: (input) => `${input}["infer"]`,
|
|
327
327
|
"io-ts": (input) => `t.TypeOf<${input}>`,
|
|
328
328
|
typebox: (input) => `Static<${input}>`,
|
|
329
|
-
valibot: (input) => `v.
|
|
329
|
+
valibot: (input) => `v.InferOutput<${input}>`,
|
|
330
330
|
yup: (input) => `y.InferType<${input}>`,
|
|
331
331
|
zod: (input) => `z.infer<${input}>`
|
|
332
332
|
};
|
|
@@ -522,7 +522,7 @@ export class ApiClient {
|
|
|
522
522
|
path: Path,
|
|
523
523
|
...params: MaybeOptionalArg<${(0, import_ts_pattern.match)(ctx.runtime).with("zod", "yup", () => infer(`TEndpoint["parameters"]`)).with("arktype", "io-ts", "typebox", "valibot", () => infer(`TEndpoint`) + `["parameters"]`).otherwise(() => `TEndpoint["parameters"]`)}>
|
|
524
524
|
): Promise<${(0, import_ts_pattern.match)(ctx.runtime).with("zod", "yup", () => infer(`TEndpoint["response"]`)).with("arktype", "io-ts", "typebox", "valibot", () => infer(`TEndpoint`) + `["response"]`).otherwise(() => `TEndpoint["response"]`)}> {
|
|
525
|
-
return this.fetcher("${method}", this.baseUrl + path, params[0])${(0, import_ts_pattern.match)(ctx.runtime).with("zod", () => `as Promise<${infer(`TEndpoint["response"]`)}>`).otherwise(() =>
|
|
525
|
+
return this.fetcher("${method}", this.baseUrl + path, params[0])${(0, import_ts_pattern.match)(ctx.runtime).with("zod", "yup", () => `as Promise<${infer(`TEndpoint["response"]`)}>`).with("arktype", "io-ts", "typebox", "valibot", () => `as Promise<${infer(`TEndpoint`) + `["response"]`}>`).otherwise(() => `as Promise<TEndpoint["response"]>`)};
|
|
526
526
|
}
|
|
527
527
|
// </ApiClient.${method}>
|
|
528
528
|
` : "";
|
|
@@ -860,7 +860,7 @@ var allowedParamMediaTypes = [
|
|
|
860
860
|
];
|
|
861
861
|
var isAllowedParamMediaTypes = (mediaType) => mediaType.includes("application/") && mediaType.includes("json") || allowedParamMediaTypes.includes(mediaType) || mediaType.includes("text/");
|
|
862
862
|
var isResponseMediaType = (mediaType) => mediaType === "application/json";
|
|
863
|
-
var getAlias = ({ path, method, operation }) => method + "_" + (0, import_server4.capitalize)(operation.operationId ?? pathToVariableName(path));
|
|
863
|
+
var getAlias = ({ path, method, operation }) => (method + "_" + (0, import_server4.capitalize)(operation.operationId ?? pathToVariableName(path))).replace(/-/g, "__");
|
|
864
864
|
|
|
865
865
|
// src/cli.ts
|
|
866
866
|
var cwd = process.cwd();
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
allowedRuntimes,
|
|
3
3
|
generateFile,
|
|
4
4
|
mapOpenApiEndpoints
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-T4QUCLXL.js";
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
@@ -13,7 +13,7 @@ import { writeFile } from "fs/promises";
|
|
|
13
13
|
|
|
14
14
|
// package.json
|
|
15
15
|
var name = "typed-openapi";
|
|
16
|
-
var version = "0.
|
|
16
|
+
var version = "0.7.0";
|
|
17
17
|
|
|
18
18
|
// src/cli.ts
|
|
19
19
|
var cwd = process.cwd();
|
package/dist/index.cjs
CHANGED
|
@@ -334,7 +334,7 @@ var inferByRuntime = {
|
|
|
334
334
|
arktype: (input) => `${input}["infer"]`,
|
|
335
335
|
"io-ts": (input) => `t.TypeOf<${input}>`,
|
|
336
336
|
typebox: (input) => `Static<${input}>`,
|
|
337
|
-
valibot: (input) => `v.
|
|
337
|
+
valibot: (input) => `v.InferOutput<${input}>`,
|
|
338
338
|
yup: (input) => `y.InferType<${input}>`,
|
|
339
339
|
zod: (input) => `z.infer<${input}>`
|
|
340
340
|
};
|
|
@@ -530,7 +530,7 @@ export class ApiClient {
|
|
|
530
530
|
path: Path,
|
|
531
531
|
...params: MaybeOptionalArg<${(0, import_ts_pattern.match)(ctx.runtime).with("zod", "yup", () => infer(`TEndpoint["parameters"]`)).with("arktype", "io-ts", "typebox", "valibot", () => infer(`TEndpoint`) + `["parameters"]`).otherwise(() => `TEndpoint["parameters"]`)}>
|
|
532
532
|
): Promise<${(0, import_ts_pattern.match)(ctx.runtime).with("zod", "yup", () => infer(`TEndpoint["response"]`)).with("arktype", "io-ts", "typebox", "valibot", () => infer(`TEndpoint`) + `["response"]`).otherwise(() => `TEndpoint["response"]`)}> {
|
|
533
|
-
return this.fetcher("${method}", this.baseUrl + path, params[0])${(0, import_ts_pattern.match)(ctx.runtime).with("zod", () => `as Promise<${infer(`TEndpoint["response"]`)}>`).otherwise(() =>
|
|
533
|
+
return this.fetcher("${method}", this.baseUrl + path, params[0])${(0, import_ts_pattern.match)(ctx.runtime).with("zod", "yup", () => `as Promise<${infer(`TEndpoint["response"]`)}>`).with("arktype", "io-ts", "typebox", "valibot", () => `as Promise<${infer(`TEndpoint`) + `["response"]`}>`).otherwise(() => `as Promise<TEndpoint["response"]>`)};
|
|
534
534
|
}
|
|
535
535
|
// </ApiClient.${method}>
|
|
536
536
|
` : "";
|
|
@@ -868,7 +868,7 @@ var allowedParamMediaTypes = [
|
|
|
868
868
|
];
|
|
869
869
|
var isAllowedParamMediaTypes = (mediaType) => mediaType.includes("application/") && mediaType.includes("json") || allowedParamMediaTypes.includes(mediaType) || mediaType.includes("text/");
|
|
870
870
|
var isResponseMediaType = (mediaType) => mediaType === "application/json";
|
|
871
|
-
var getAlias = ({ path, method, operation }) => method + "_" + (0, import_server4.capitalize)(operation.operationId ?? pathToVariableName(path));
|
|
871
|
+
var getAlias = ({ path, method, operation }) => (method + "_" + (0, import_server4.capitalize)(operation.operationId ?? pathToVariableName(path))).replace(/-/g, "__");
|
|
872
872
|
// Annotate the CommonJS export names for ESM import in node:
|
|
873
873
|
0 && (module.exports = {
|
|
874
874
|
createBoxFactory,
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typed-openapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
17
17
|
"@changesets/cli": "^2.26.2",
|
|
18
|
-
"@sinclair/typebox-codegen": "^0.
|
|
18
|
+
"@sinclair/typebox-codegen": "^0.10.3",
|
|
19
19
|
"arktype": "1.0.18-alpha",
|
|
20
20
|
"cac": "^6.7.14",
|
|
21
21
|
"openapi3-ts": "^4.1.2",
|
package/src/generator.ts
CHANGED
|
@@ -33,7 +33,7 @@ const inferByRuntime = {
|
|
|
33
33
|
arktype: (input: string) => `${input}["infer"]`,
|
|
34
34
|
"io-ts": (input: string) => `t.TypeOf<${input}>`,
|
|
35
35
|
typebox: (input: string) => `Static<${input}>`,
|
|
36
|
-
valibot: (input: string) => `v.
|
|
36
|
+
valibot: (input: string) => `v.InferOutput<${input}>`,
|
|
37
37
|
yup: (input: string) => `y.InferType<${input}>`,
|
|
38
38
|
zod: (input: string) => `z.infer<${input}>`,
|
|
39
39
|
};
|
|
@@ -294,7 +294,9 @@ export class ApiClient {
|
|
|
294
294
|
.with("arktype", "io-ts", "typebox", "valibot", () => infer(`TEndpoint`) + `["response"]`)
|
|
295
295
|
.otherwise(() => `TEndpoint["response"]`)}> {
|
|
296
296
|
return this.fetcher("${method}", this.baseUrl + path, params[0])${match(ctx.runtime)
|
|
297
|
-
|
|
297
|
+
.with("zod", "yup", () => `as Promise<${infer(`TEndpoint["response"]`)}>`)
|
|
298
|
+
.with("arktype", "io-ts", "typebox", "valibot", () => `as Promise<${infer(`TEndpoint`) + `["response"]`}>`)
|
|
299
|
+
.otherwise(() => `as Promise<TEndpoint["response"]>`)};
|
|
298
300
|
}
|
|
299
301
|
// </ApiClient.${method}>
|
|
300
302
|
`
|
|
@@ -153,7 +153,7 @@ const isAllowedParamMediaTypes = (
|
|
|
153
153
|
|
|
154
154
|
const isResponseMediaType = (mediaType: string) => mediaType === "application/json";
|
|
155
155
|
const getAlias = ({ path, method, operation }: Endpoint) =>
|
|
156
|
-
method + "_" + capitalize(operation.operationId ?? pathToVariableName(path));
|
|
156
|
+
(method + "_" + capitalize(operation.operationId ?? pathToVariableName(path))).replace(/-/g, "__");
|
|
157
157
|
|
|
158
158
|
type MutationMethod = "post" | "put" | "patch" | "delete";
|
|
159
159
|
type Method = "get" | "head" | "options" | MutationMethod;
|