express-zod-api 9.2.1 → 10.0.0-beta2
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/CHANGELOG.md +62 -0
- package/README.md +28 -20
- package/SECURITY.md +14 -13
- package/dist/esm/index.js +58 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/index.d.ts +776 -21
- package/dist/index.js +55 -69
- package/dist/index.js.map +1 -1
- package/package.json +31 -25
- package/dist/api-response.d.ts +0 -16
- package/dist/api-response.js +0 -3
- package/dist/api-response.js.map +0 -1
- package/dist/client-helpers.d.ts +0 -23
- package/dist/client-helpers.js +0 -71
- package/dist/client-helpers.js.map +0 -1
- package/dist/client.d.ts +0 -15
- package/dist/client.js +0 -120
- package/dist/client.js.map +0 -1
- package/dist/common-helpers.d.ts +0 -46
- package/dist/common-helpers.js +0 -207
- package/dist/common-helpers.js.map +0 -1
- package/dist/config-type.d.ts +0 -59
- package/dist/config-type.js +0 -11
- package/dist/config-type.js.map +0 -1
- package/dist/date-in-schema.d.ts +0 -11
- package/dist/date-in-schema.js +0 -46
- package/dist/date-in-schema.js.map +0 -1
- package/dist/date-out-schema.d.ts +0 -10
- package/dist/date-out-schema.js +0 -31
- package/dist/date-out-schema.js.map +0 -1
- package/dist/depends-on-method.d.ts +0 -10
- package/dist/depends-on-method.js +0 -32
- package/dist/depends-on-method.js.map +0 -1
- package/dist/endpoint.d.ts +0 -98
- package/dist/endpoint.js +0 -261
- package/dist/endpoint.js.map +0 -1
- package/dist/endpoints-factory.d.ts +0 -161
- package/dist/endpoints-factory.js +0 -68
- package/dist/endpoints-factory.js.map +0 -1
- package/dist/errors.d.ts +0 -35
- package/dist/errors.js +0 -64
- package/dist/errors.js.map +0 -1
- package/dist/extend-zod.d.ts +0 -22
- package/dist/extend-zod.js +0 -33
- package/dist/extend-zod.js.map +0 -1
- package/dist/file-schema.d.ts +0 -23
- package/dist/file-schema.js +0 -55
- package/dist/file-schema.js.map +0 -1
- package/dist/io-schema.d.ts +0 -16
- package/dist/io-schema.js +0 -21
- package/dist/io-schema.js.map +0 -1
- package/dist/logger.d.ts +0 -3
- package/dist/logger.js +0 -54
- package/dist/logger.js.map +0 -1
- package/dist/logical-container.d.ts +0 -16
- package/dist/logical-container.js +0 -85
- package/dist/logical-container.js.map +0 -1
- package/dist/metadata.d.ts +0 -27
- package/dist/metadata.js +0 -58
- package/dist/metadata.js.map +0 -1
- package/dist/method.d.ts +0 -8
- package/dist/method.js +0 -5
- package/dist/method.js.map +0 -1
- package/dist/middleware.d.ts +0 -32
- package/dist/middleware.js +0 -16
- package/dist/middleware.js.map +0 -1
- package/dist/mime.d.ts +0 -2
- package/dist/mime.js +0 -10
- package/dist/mime.js.map +0 -1
- package/dist/mock.d.ts +0 -38
- package/dist/mock.js +0 -66
- package/dist/mock.js.map +0 -1
- package/dist/open-api-helpers.d.ts +0 -83
- package/dist/open-api-helpers.js +0 -621
- package/dist/open-api-helpers.js.map +0 -1
- package/dist/open-api.d.ts +0 -25
- package/dist/open-api.js +0 -98
- package/dist/open-api.js.map +0 -1
- package/dist/result-handler.d.ts +0 -151
- package/dist/result-handler.js +0 -71
- package/dist/result-handler.js.map +0 -1
- package/dist/routing-walker.d.ts +0 -12
- package/dist/routing-walker.js +0 -55
- package/dist/routing-walker.js.map +0 -1
- package/dist/routing.d.ts +0 -15
- package/dist/routing.js +0 -25
- package/dist/routing.js.map +0 -1
- package/dist/schema-walker.d.ts +0 -23
- package/dist/schema-walker.js +0 -26
- package/dist/schema-walker.js.map +0 -1
- package/dist/security.d.ts +0 -72
- package/dist/security.js +0 -3
- package/dist/security.js.map +0 -1
- package/dist/serve-static.d.ts +0 -9
- package/dist/serve-static.js +0 -17
- package/dist/serve-static.js.map +0 -1
- package/dist/server.d.ts +0 -20
- package/dist/server.js +0 -131
- package/dist/server.js.map +0 -1
- package/dist/startup-logo.d.ts +0 -1
- package/dist/startup-logo.js +0 -27
- package/dist/startup-logo.js.map +0 -1
- package/dist/upload-schema.d.ts +0 -11
- package/dist/upload-schema.js +0 -42
- package/dist/upload-schema.js.map +0 -1
- package/dist/zts-helpers.d.ts +0 -37
- package/dist/zts-helpers.js +0 -60
- package/dist/zts-helpers.js.map +0 -1
- package/dist/zts.d.ts +0 -31
- package/dist/zts.js +0 -147
- package/dist/zts.js.map +0 -1
- package/dist-esm/api-response.js +0 -2
- package/dist-esm/api-response.js.map +0 -1
- package/dist-esm/client-helpers.js +0 -48
- package/dist-esm/client-helpers.js.map +0 -1
- package/dist-esm/client.js +0 -113
- package/dist-esm/client.js.map +0 -1
- package/dist-esm/common-helpers.js +0 -188
- package/dist-esm/common-helpers.js.map +0 -1
- package/dist-esm/config-type.js +0 -7
- package/dist-esm/config-type.js.map +0 -1
- package/dist-esm/date-in-schema.js +0 -42
- package/dist-esm/date-in-schema.js.map +0 -1
- package/dist-esm/date-out-schema.js +0 -27
- package/dist-esm/date-out-schema.js.map +0 -1
- package/dist-esm/depends-on-method.js +0 -28
- package/dist-esm/depends-on-method.js.map +0 -1
- package/dist-esm/endpoint.js +0 -256
- package/dist-esm/endpoint.js.map +0 -1
- package/dist-esm/endpoints-factory.js +0 -64
- package/dist-esm/endpoints-factory.js.map +0 -1
- package/dist-esm/errors.js +0 -54
- package/dist-esm/errors.js.map +0 -1
- package/dist-esm/extend-zod.js +0 -16
- package/dist-esm/extend-zod.js.map +0 -1
- package/dist-esm/file-schema.js +0 -51
- package/dist-esm/file-schema.js.map +0 -1
- package/dist-esm/index.js +0 -19
- package/dist-esm/index.js.map +0 -1
- package/dist-esm/io-schema.js +0 -17
- package/dist-esm/io-schema.js.map +0 -1
- package/dist-esm/logger.js +0 -47
- package/dist-esm/logger.js.map +0 -1
- package/dist-esm/logical-container.js +0 -78
- package/dist-esm/logical-container.js.map +0 -1
- package/dist-esm/metadata.js +0 -51
- package/dist-esm/metadata.js.map +0 -1
- package/dist-esm/method.js +0 -2
- package/dist-esm/method.js.map +0 -1
- package/dist-esm/middleware.js +0 -12
- package/dist-esm/middleware.js.map +0 -1
- package/dist-esm/mime.js +0 -4
- package/dist-esm/mime.js.map +0 -1
- package/dist-esm/mock.js +0 -57
- package/dist-esm/mock.js.map +0 -1
- package/dist-esm/open-api-helpers.js +0 -575
- package/dist-esm/open-api-helpers.js.map +0 -1
- package/dist-esm/open-api.js +0 -94
- package/dist-esm/open-api.js.map +0 -1
- package/dist-esm/package.json +0 -1
- package/dist-esm/result-handler.js +0 -66
- package/dist-esm/result-handler.js.map +0 -1
- package/dist-esm/routing-walker.js +0 -51
- package/dist-esm/routing-walker.js.map +0 -1
- package/dist-esm/routing.js +0 -21
- package/dist-esm/routing.js.map +0 -1
- package/dist-esm/schema-walker.js +0 -22
- package/dist-esm/schema-walker.js.map +0 -1
- package/dist-esm/security.js +0 -2
- package/dist-esm/security.js.map +0 -1
- package/dist-esm/serve-static.js +0 -10
- package/dist-esm/serve-static.js.map +0 -1
- package/dist-esm/server.js +0 -98
- package/dist-esm/server.js.map +0 -1
- package/dist-esm/startup-logo.js +0 -23
- package/dist-esm/startup-logo.js.map +0 -1
- package/dist-esm/upload-schema.js +0 -38
- package/dist-esm/upload-schema.js.map +0 -1
- package/dist-esm/zts-helpers.js +0 -50
- package/dist-esm/zts-helpers.js.map +0 -1
- package/dist-esm/zts.js +0 -140
- package/dist-esm/zts.js.map +0 -1
package/dist/server.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
import express, { ErrorRequestHandler, RequestHandler } from "express";
|
|
5
|
-
import https from "https";
|
|
6
|
-
import { Logger } from "winston";
|
|
7
|
-
import { AppConfig, CommonConfig, ServerConfig } from "./config-type";
|
|
8
|
-
import { Routing } from "./routing";
|
|
9
|
-
export declare const createParserFailureHandler: (errorHandler: import("./result-handler").ResultHandlerDefinition<any, any>, logger: Logger) => ErrorRequestHandler;
|
|
10
|
-
export declare const createNotFoundHandler: (errorHandler: import("./result-handler").ResultHandlerDefinition<any, any>, logger: Logger) => RequestHandler;
|
|
11
|
-
export declare function attachRouting(config: AppConfig & CommonConfig, routing: Routing): {
|
|
12
|
-
notFoundHandler: express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
13
|
-
logger: Logger;
|
|
14
|
-
};
|
|
15
|
-
export declare function createServer(config: ServerConfig & CommonConfig, routing: Routing): {
|
|
16
|
-
app: import("express-serve-static-core").Express;
|
|
17
|
-
httpServer: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
18
|
-
httpsServer: https.Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | undefined;
|
|
19
|
-
logger: Logger;
|
|
20
|
-
};
|
package/dist/server.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.createServer = exports.attachRouting = exports.createNotFoundHandler = exports.createParserFailureHandler = void 0;
|
|
30
|
-
const express_1 = __importStar(require("express"));
|
|
31
|
-
const compression_1 = __importDefault(require("compression"));
|
|
32
|
-
const express_fileupload_1 = __importDefault(require("express-fileupload"));
|
|
33
|
-
const https_1 = __importDefault(require("https"));
|
|
34
|
-
const errors_1 = require("./errors");
|
|
35
|
-
const common_helpers_1 = require("./common-helpers");
|
|
36
|
-
const logger_1 = require("./logger");
|
|
37
|
-
const result_handler_1 = require("./result-handler");
|
|
38
|
-
const routing_1 = require("./routing");
|
|
39
|
-
const http_errors_1 = __importDefault(require("http-errors"));
|
|
40
|
-
const createParserFailureHandler = (errorHandler, logger) => (error, request, response, next) => {
|
|
41
|
-
if (!error) {
|
|
42
|
-
return next();
|
|
43
|
-
}
|
|
44
|
-
errorHandler.handler({
|
|
45
|
-
error,
|
|
46
|
-
request,
|
|
47
|
-
response,
|
|
48
|
-
logger,
|
|
49
|
-
input: request.body,
|
|
50
|
-
output: null,
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
exports.createParserFailureHandler = createParserFailureHandler;
|
|
54
|
-
const createNotFoundHandler = (errorHandler, logger) => (request, response) => {
|
|
55
|
-
const error = (0, http_errors_1.default)(404, `Can not ${request.method} ${request.path}`);
|
|
56
|
-
try {
|
|
57
|
-
errorHandler.handler({
|
|
58
|
-
request,
|
|
59
|
-
response,
|
|
60
|
-
logger,
|
|
61
|
-
error,
|
|
62
|
-
input: null,
|
|
63
|
-
output: null,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
(0, result_handler_1.lastResortHandler)({
|
|
68
|
-
response,
|
|
69
|
-
logger,
|
|
70
|
-
error: new errors_1.ResultHandlerError((0, common_helpers_1.makeErrorFromAnything)(e).message, error),
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
exports.createNotFoundHandler = createNotFoundHandler;
|
|
75
|
-
function attachRouting(config, routing) {
|
|
76
|
-
const logger = (0, common_helpers_1.isLoggerConfig)(config.logger)
|
|
77
|
-
? (0, logger_1.createLogger)(config.logger)
|
|
78
|
-
: config.logger;
|
|
79
|
-
(0, routing_1.initRouting)({ app: config.app, routing, logger, config });
|
|
80
|
-
const errorHandler = config.errorHandler || result_handler_1.defaultResultHandler;
|
|
81
|
-
const notFoundHandler = (0, exports.createNotFoundHandler)(errorHandler, logger);
|
|
82
|
-
return { notFoundHandler, logger };
|
|
83
|
-
}
|
|
84
|
-
exports.attachRouting = attachRouting;
|
|
85
|
-
function createServer(config, routing) {
|
|
86
|
-
const logger = (0, common_helpers_1.isLoggerConfig)(config.logger)
|
|
87
|
-
? (0, logger_1.createLogger)(config.logger)
|
|
88
|
-
: config.logger;
|
|
89
|
-
const app = (0, express_1.default)();
|
|
90
|
-
app.disable("x-powered-by");
|
|
91
|
-
const errorHandler = config.errorHandler || result_handler_1.defaultResultHandler;
|
|
92
|
-
const compressor = config.server.compression
|
|
93
|
-
? (0, compression_1.default)({
|
|
94
|
-
...(typeof config.server.compression === "object"
|
|
95
|
-
? config.server.compression
|
|
96
|
-
: {}),
|
|
97
|
-
})
|
|
98
|
-
: undefined;
|
|
99
|
-
const jsonParser = config.server.jsonParser || (0, express_1.json)();
|
|
100
|
-
const multipartParser = config.server.upload
|
|
101
|
-
? (0, express_fileupload_1.default)({
|
|
102
|
-
...(typeof config.server.upload === "object"
|
|
103
|
-
? config.server.upload
|
|
104
|
-
: {}),
|
|
105
|
-
abortOnLimit: false,
|
|
106
|
-
parseNested: true,
|
|
107
|
-
})
|
|
108
|
-
: undefined;
|
|
109
|
-
const middlewares = []
|
|
110
|
-
.concat(compressor || [])
|
|
111
|
-
.concat(jsonParser)
|
|
112
|
-
.concat(multipartParser || []);
|
|
113
|
-
app.use(middlewares);
|
|
114
|
-
app.use((0, exports.createParserFailureHandler)(errorHandler, logger));
|
|
115
|
-
(0, routing_1.initRouting)({ app, routing, logger, config });
|
|
116
|
-
app.use((0, exports.createNotFoundHandler)(errorHandler, logger));
|
|
117
|
-
const httpServer = app.listen(config.server.listen, () => {
|
|
118
|
-
logger.info(`Listening ${config.server.listen}`);
|
|
119
|
-
});
|
|
120
|
-
let httpsServer;
|
|
121
|
-
if (config.https) {
|
|
122
|
-
httpsServer = https_1.default
|
|
123
|
-
.createServer(config.https.options, app)
|
|
124
|
-
.listen(config.https.listen, () => {
|
|
125
|
-
logger.info(`Listening ${config.https.listen}`);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
return { app, httpServer, httpsServer, logger };
|
|
129
|
-
}
|
|
130
|
-
exports.createServer = createServer;
|
|
131
|
-
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA6E;AAC7E,8DAAsC;AACtC,4EAA4C;AAC5C,kDAA0B;AAG1B,qCAA8C;AAC9C,qDAAyE;AACzE,qCAAwC;AACxC,qDAA2E;AAC3E,uCAAiD;AACjD,8DAA0C;AAInC,MAAM,0BAA0B,GACrC,CAAC,YAA8B,EAAE,MAAc,EAAuB,EAAE,CACxE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IACjC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,EAAE,CAAC;KACf;IACD,YAAY,C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
|
2
|
-
// ANSI font attribution
|
|
3
|
-
// Colossal.flf (Jonathon - jon@mq.edu.au), 8 June 1994
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.getStartupLogo = void 0;
|
|
6
|
-
const getStartupLogo = () => {
|
|
7
|
-
return `
|
|
8
|
-
[94m[39m
|
|
9
|
-
[94m[39m
|
|
10
|
-
[94m8888888888 8888888888P 888 d8888 8888888b. 8888888 [39m
|
|
11
|
-
[94m888 d88P 888 d88888 888 Y88b 888[39m[95m[39m
|
|
12
|
-
[95m888 d88P 888 d88P888 888 888 888[39m
|
|
13
|
-
[95m8888888 888 888 88888b. 888d888 .d88b. .d8888b .d8888b d88P .d88b. .d88888 d88P 888 888 d88P 888[39m[97m[39m
|
|
14
|
-
[97m888 \`Y8bd8P' 888 "88b 888P" d8P Y8b 88K 88K d88P d88""88b d88" 888 d88P 888 8888888P" 888 [39m
|
|
15
|
-
[97m888 X88K 888 888 888 88888888 "Y8888b. "Y8888b. d88P 888 888 888 888 d88P 888 888 888[39m[95m[39m
|
|
16
|
-
[95m888 .d8""8b. 888 d88P 888 Y8b. X88 X88 d88P Y88..88P Y88b 888 d8888888888 888 888 [39m
|
|
17
|
-
[95m8888888888 888 888 88888P" 888 "Y8888 88888P' 88888P' d8888888888 "Y88P" "Y88888 d88P 888 888 8888888[39m[94m[39m
|
|
18
|
-
[94m 888[39m
|
|
19
|
-
[94m 888[3m Proudly supports transgender community.[23m[39m
|
|
20
|
-
[94m[3mfor Brianna [23m 888[3m Start your API server with I/O schema validation and custom middlewares in minutes.[23m[39m[90m[39m
|
|
21
|
-
[90m[3m Thank you for choosing Express Zod API for your project.[23m[39m[0m[0m
|
|
22
|
-
[0m[0m
|
|
23
|
-
[0m[0m
|
|
24
|
-
`.trim();
|
|
25
|
-
};
|
|
26
|
-
exports.getStartupLogo = getStartupLogo;
|
|
27
|
-
//# sourceMappingURL=startup-logo.js.map
|
package/dist/startup-logo.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"startup-logo.js","sourceRoot":"","sources":["../src/startup-logo.ts"],"names":[],"mappings":";AAAA,wBAAwB;AACxB,uDAAuD;;;AAEhD,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,OAAO;;;;;;;;;;;;;;;;;CAiBR,CAAC,IAAI,EAAE,CAAC;AACT,CAAC,CAAC;AAnBW,QAAA,cAAc,kBAmBzB"}
|
package/dist/upload-schema.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { UploadedFile } from "express-fileupload";
|
|
2
|
-
import { ParseInput, ParseReturnType, ZodType, ZodTypeDef } from "zod";
|
|
3
|
-
declare const zodUploadKind = "ZodUpload";
|
|
4
|
-
export interface ZodUploadDef extends ZodTypeDef {
|
|
5
|
-
typeName: typeof zodUploadKind;
|
|
6
|
-
}
|
|
7
|
-
export declare class ZodUpload extends ZodType<UploadedFile, ZodUploadDef> {
|
|
8
|
-
_parse(input: ParseInput): ParseReturnType<UploadedFile>;
|
|
9
|
-
static create: () => ZodUpload;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
package/dist/upload-schema.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZodUpload = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const zodUploadKind = "ZodUpload";
|
|
6
|
-
const isUploadedFile = (data) => typeof data === "object" &&
|
|
7
|
-
data !== null &&
|
|
8
|
-
"name" in data &&
|
|
9
|
-
"encoding" in data &&
|
|
10
|
-
"mimetype" in data &&
|
|
11
|
-
"data" in data &&
|
|
12
|
-
"tempFilePath" in data &&
|
|
13
|
-
"truncated" in data &&
|
|
14
|
-
"size" in data &&
|
|
15
|
-
"md5" in data &&
|
|
16
|
-
"mv" in data &&
|
|
17
|
-
typeof data.name === "string" &&
|
|
18
|
-
typeof data.mimetype === "string" &&
|
|
19
|
-
typeof data.data === "object" &&
|
|
20
|
-
typeof data.tempFilePath === "string" &&
|
|
21
|
-
typeof data.truncated === "boolean" &&
|
|
22
|
-
typeof data.size === "number" &&
|
|
23
|
-
typeof data.md5 === "string" &&
|
|
24
|
-
typeof data.mv === "function";
|
|
25
|
-
class ZodUpload extends zod_1.ZodType {
|
|
26
|
-
_parse(input) {
|
|
27
|
-
const { ctx } = this._processInputParams(input);
|
|
28
|
-
if (ctx.parsedType !== zod_1.ZodParsedType.object || !isUploadedFile(ctx.data)) {
|
|
29
|
-
(0, zod_1.addIssueToContext)(ctx, {
|
|
30
|
-
code: zod_1.ZodIssueCode.custom,
|
|
31
|
-
message: `Expected file upload, received ${ctx.parsedType}`,
|
|
32
|
-
});
|
|
33
|
-
return zod_1.INVALID;
|
|
34
|
-
}
|
|
35
|
-
return (0, zod_1.OK)(ctx.data);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.ZodUpload = ZodUpload;
|
|
39
|
-
ZodUpload.create = () => new ZodUpload({
|
|
40
|
-
typeName: zodUploadKind,
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=upload-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload-schema.js","sourceRoot":"","sources":["../src/upload-schema.ts"],"names":[],"mappings":";;;AACA,6BAUa;AAEb,MAAM,aAAa,GAAG,WAAW,CAAC;AAMlC,MAAM,cAAc,GAAG,CAAC,IAAS,EAAwB,EAAE,CACzD,OAAO,IAAI,KAAK,QAAQ;IACxB,IAAI,KAAK,IAAI;IACb,MAAM,IAAI,IAAI;IACd,UAAU,IAAI,IAAI;IAClB,UAAU,IAAI,IAAI;IAClB,MAAM,IAAI,IAAI;IACd,cAAc,IAAI,IAAI;IACtB,WAAW,IAAI,IAAI;IACnB,MAAM,IAAI,IAAI;IACd,KAAK,IAAI,IAAI;IACb,IAAI,IAAI,IAAI;IACZ,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;IAC7B,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ;IACjC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;IAC7B,OAAO,IAAI,CAAC,YAAY,KAAK,QAAQ;IACrC,OAAO,IAAI,CAAC,SAAS,KAAK,SAAS;IACnC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;IAC7B,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ;IAC5B,OAAO,IAAI,CAAC,EAAE,KAAK,UAAU,CAAC;AAEhC,MAAa,SAAU,SAAQ,aAAmC;IAChE,MAAM,CAAC,KAAiB;QACtB,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAChD,IAAI,GAAG,CAAC,UAAU,KAAK,mBAAa,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACxE,IAAA,uBAAiB,EAAC,GAAG,EAAE;gBACrB,IAAI,EAAE,kBAAY,CAAC,MAAM;gBACzB,OAAO,EAAE,kCAAkC,GAAG,CAAC,UAAU,EAAE;aAC5D,CAAC,CAAC;YACH,OAAO,aAAO,CAAC;SAChB;QAED,OAAO,IAAA,QAAE,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;;AAZH,8BAkBC;AAJQ,gBAAM,GAAG,GAAG,EAAE,CACnB,IAAI,SAAS,CAAC;IACZ,QAAQ,EAAE,aAAa;CACxB,CAAC,CAAC"}
|
package/dist/zts-helpers.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is based on https://github.com/sachinraja/zod-to-ts
|
|
3
|
-
*
|
|
4
|
-
* MIT License
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021 Sachin Raja
|
|
7
|
-
*
|
|
8
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
-
* in the Software without restriction, including without limitation the rights
|
|
11
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
* furnished to do so, subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
-
* copies or substantial portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
-
* SOFTWARE.
|
|
25
|
-
*/
|
|
26
|
-
import ts from "typescript";
|
|
27
|
-
import { z } from "zod";
|
|
28
|
-
import { SchemaHandler } from "./schema-walker";
|
|
29
|
-
export type LiteralType = string | number | boolean;
|
|
30
|
-
export type ZTSContext = {
|
|
31
|
-
isResponse?: boolean;
|
|
32
|
-
};
|
|
33
|
-
export type Producer<T extends z.ZodTypeAny> = SchemaHandler<T, ts.TypeNode, ZTSContext>;
|
|
34
|
-
export declare const addJsDocComment: (node: ts.Node, text: string) => void;
|
|
35
|
-
export declare const createTypeAlias: (node: ts.TypeNode, identifier: string, comment?: string) => ts.TypeAliasDeclaration;
|
|
36
|
-
export declare const printNode: (node: ts.Node, printerOptions?: ts.PrinterOptions) => string;
|
|
37
|
-
export declare const makePropertyIdentifier: (name: string) => ts.Identifier | ts.StringLiteral;
|
package/dist/zts-helpers.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* This file is based on https://github.com/sachinraja/zod-to-ts
|
|
4
|
-
*
|
|
5
|
-
* MIT License
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) 2021 Sachin Raja
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
* in the Software without restriction, including without limitation the rights
|
|
12
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
* furnished to do so, subject to the following conditions:
|
|
15
|
-
*
|
|
16
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
-
* copies or substantial portions of the Software.
|
|
18
|
-
*
|
|
19
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
-
* SOFTWARE.
|
|
26
|
-
*/
|
|
27
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
-
};
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.makePropertyIdentifier = exports.printNode = exports.createTypeAlias = exports.addJsDocComment = void 0;
|
|
32
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
33
|
-
const { factory: f } = typescript_1.default;
|
|
34
|
-
const addJsDocComment = (node, text) => {
|
|
35
|
-
typescript_1.default.addSyntheticLeadingComment(node, typescript_1.default.SyntaxKind.MultiLineCommentTrivia, `* ${text} `, true);
|
|
36
|
-
};
|
|
37
|
-
exports.addJsDocComment = addJsDocComment;
|
|
38
|
-
const createTypeAlias = (node, identifier, comment) => {
|
|
39
|
-
const typeAlias = f.createTypeAliasDeclaration(undefined, f.createIdentifier(identifier), undefined, node);
|
|
40
|
-
if (comment) {
|
|
41
|
-
(0, exports.addJsDocComment)(typeAlias, comment);
|
|
42
|
-
}
|
|
43
|
-
return typeAlias;
|
|
44
|
-
};
|
|
45
|
-
exports.createTypeAlias = createTypeAlias;
|
|
46
|
-
const printNode = (node, printerOptions) => {
|
|
47
|
-
const sourceFile = typescript_1.default.createSourceFile("print.ts", "", typescript_1.default.ScriptTarget.Latest, false, typescript_1.default.ScriptKind.TS);
|
|
48
|
-
const printer = typescript_1.default.createPrinter(printerOptions);
|
|
49
|
-
return printer.printNode(typescript_1.default.EmitHint.Unspecified, node, sourceFile);
|
|
50
|
-
};
|
|
51
|
-
exports.printNode = printNode;
|
|
52
|
-
const safePropRegex = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
53
|
-
const makePropertyIdentifier = (name) => {
|
|
54
|
-
if (safePropRegex.test(name)) {
|
|
55
|
-
return f.createIdentifier(name);
|
|
56
|
-
}
|
|
57
|
-
return f.createStringLiteral(name);
|
|
58
|
-
};
|
|
59
|
-
exports.makePropertyIdentifier = makePropertyIdentifier;
|
|
60
|
-
//# sourceMappingURL=zts-helpers.js.map
|
package/dist/zts-helpers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zts-helpers.js","sourceRoot":"","sources":["../src/zts-helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;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IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC5B,OAAO,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;KACjC;IACD,OAAO,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC,CAAC;AALW,QAAA,sBAAsB,0BAKjC"}
|
package/dist/zts.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is based on https://github.com/sachinraja/zod-to-ts
|
|
3
|
-
*
|
|
4
|
-
* MIT License
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021 Sachin Raja
|
|
7
|
-
*
|
|
8
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
-
* in the Software without restriction, including without limitation the rights
|
|
11
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
* furnished to do so, subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
-
* copies or substantial portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
-
* SOFTWARE.
|
|
25
|
-
*/
|
|
26
|
-
import ts from "typescript";
|
|
27
|
-
import { z } from "zod";
|
|
28
|
-
import { ZTSContext } from "./zts-helpers";
|
|
29
|
-
export declare const zodToTs: ({ schema, ...context }: {
|
|
30
|
-
schema: z.ZodTypeAny;
|
|
31
|
-
} & ZTSContext) => ts.TypeNode;
|
package/dist/zts.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* This file is based on https://github.com/sachinraja/zod-to-ts
|
|
4
|
-
*
|
|
5
|
-
* MIT License
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) 2021 Sachin Raja
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
* in the Software without restriction, including without limitation the rights
|
|
12
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
* furnished to do so, subject to the following conditions:
|
|
15
|
-
*
|
|
16
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
-
* copies or substantial portions of the Software.
|
|
18
|
-
*
|
|
19
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
-
* SOFTWARE.
|
|
26
|
-
*/
|
|
27
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
-
};
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.zodToTs = void 0;
|
|
32
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
33
|
-
const zod_1 = require("zod");
|
|
34
|
-
const common_helpers_1 = require("./common-helpers");
|
|
35
|
-
const schema_walker_1 = require("./schema-walker");
|
|
36
|
-
const zts_helpers_1 = require("./zts-helpers");
|
|
37
|
-
const { factory: f } = typescript_1.default;
|
|
38
|
-
const samples = {
|
|
39
|
-
[typescript_1.default.SyntaxKind.AnyKeyword]: "",
|
|
40
|
-
[typescript_1.default.SyntaxKind.BigIntKeyword]: BigInt(0),
|
|
41
|
-
[typescript_1.default.SyntaxKind.BooleanKeyword]: false,
|
|
42
|
-
[typescript_1.default.SyntaxKind.NumberKeyword]: 0,
|
|
43
|
-
[typescript_1.default.SyntaxKind.ObjectKeyword]: {},
|
|
44
|
-
[typescript_1.default.SyntaxKind.StringKeyword]: "",
|
|
45
|
-
[typescript_1.default.SyntaxKind.UndefinedKeyword]: undefined,
|
|
46
|
-
};
|
|
47
|
-
const onLiteral = ({ schema: { value }, }) => f.createLiteralTypeNode(typeof value === "number"
|
|
48
|
-
? f.createNumericLiteral(value)
|
|
49
|
-
: typeof value === "boolean"
|
|
50
|
-
? value
|
|
51
|
-
? f.createTrue()
|
|
52
|
-
: f.createFalse()
|
|
53
|
-
: f.createStringLiteral(value));
|
|
54
|
-
const onObject = ({ schema: { shape }, isResponse, next, }) => {
|
|
55
|
-
const members = Object.entries(shape).map(([key, value]) => {
|
|
56
|
-
const isOptional = isResponse && (0, common_helpers_1.hasCoercion)(value)
|
|
57
|
-
? value instanceof zod_1.z.ZodOptional
|
|
58
|
-
: value.isOptional();
|
|
59
|
-
const propertySignature = f.createPropertySignature(undefined, (0, zts_helpers_1.makePropertyIdentifier)(key), isOptional ? f.createToken(typescript_1.default.SyntaxKind.QuestionToken) : undefined, next({ schema: value }));
|
|
60
|
-
if (value.description) {
|
|
61
|
-
(0, zts_helpers_1.addJsDocComment)(propertySignature, value.description);
|
|
62
|
-
}
|
|
63
|
-
return propertySignature;
|
|
64
|
-
});
|
|
65
|
-
return f.createTypeLiteralNode(members);
|
|
66
|
-
};
|
|
67
|
-
const onArray = ({ schema: { element }, next, }) => f.createArrayTypeNode(next({ schema: element }));
|
|
68
|
-
const onEnum = ({ schema: { options }, }) => f.createUnionTypeNode(options.map((option) => f.createLiteralTypeNode(f.createStringLiteral(option))));
|
|
69
|
-
const onSomeUnion = ({ schema: { options }, next }) => f.createUnionTypeNode(options.map((option) => next({ schema: option })));
|
|
70
|
-
const makeSample = (produced) => samples?.[produced.kind];
|
|
71
|
-
const onEffects = ({ schema, next, isResponse, }) => {
|
|
72
|
-
const input = next({ schema: schema.innerType() });
|
|
73
|
-
const effect = schema._def.effect;
|
|
74
|
-
if (isResponse && effect.type === "transform") {
|
|
75
|
-
const outputType = (0, common_helpers_1.tryToTransform)({ effect, sample: makeSample(input) });
|
|
76
|
-
const resolutions = {
|
|
77
|
-
number: typescript_1.default.SyntaxKind.NumberKeyword,
|
|
78
|
-
bigint: typescript_1.default.SyntaxKind.BigIntKeyword,
|
|
79
|
-
boolean: typescript_1.default.SyntaxKind.BooleanKeyword,
|
|
80
|
-
string: typescript_1.default.SyntaxKind.StringKeyword,
|
|
81
|
-
undefined: typescript_1.default.SyntaxKind.UndefinedKeyword,
|
|
82
|
-
object: typescript_1.default.SyntaxKind.ObjectKeyword,
|
|
83
|
-
};
|
|
84
|
-
return f.createKeywordTypeNode((outputType && resolutions[outputType]) || typescript_1.default.SyntaxKind.AnyKeyword);
|
|
85
|
-
}
|
|
86
|
-
return input;
|
|
87
|
-
};
|
|
88
|
-
const onNativeEnum = ({ schema }) => f.createUnionTypeNode(Object.values(schema.enum).map((value) => f.createLiteralTypeNode(typeof value === "number"
|
|
89
|
-
? f.createNumericLiteral(value)
|
|
90
|
-
: f.createStringLiteral(value))));
|
|
91
|
-
const onOptional = ({ next, schema }) => f.createUnionTypeNode([
|
|
92
|
-
next({ schema: schema.unwrap() }),
|
|
93
|
-
f.createKeywordTypeNode(typescript_1.default.SyntaxKind.UndefinedKeyword),
|
|
94
|
-
]);
|
|
95
|
-
const onNullable = ({ next, schema }) => f.createUnionTypeNode([
|
|
96
|
-
next({ schema: schema.unwrap() }),
|
|
97
|
-
f.createLiteralTypeNode(f.createNull()),
|
|
98
|
-
]);
|
|
99
|
-
const onTuple = ({ next, schema: { items } }) => f.createTupleTypeNode(items.map((option) => next({ schema: option })));
|
|
100
|
-
const onRecord = ({ next, schema: { keySchema, valueSchema }, }) => f.createExpressionWithTypeArguments(f.createIdentifier("Record"), [
|
|
101
|
-
next({ schema: keySchema }),
|
|
102
|
-
next({ schema: valueSchema }),
|
|
103
|
-
]);
|
|
104
|
-
const onIntersection = ({ next, schema }) => f.createIntersectionTypeNode([schema._def.left, schema._def.right].map((entry) => next({ schema: entry })));
|
|
105
|
-
const onDefault = ({ next, schema }) => next({ schema: schema._def.innerType });
|
|
106
|
-
const onPrimitive = (syntaxKind) => () => f.createKeywordTypeNode(syntaxKind);
|
|
107
|
-
const onBranded = ({ next, schema, }) => next({ schema: schema.unwrap() });
|
|
108
|
-
const onCatch = ({ next, schema }) => next({ schema: schema._def.innerType });
|
|
109
|
-
const onPipeline = ({ schema, next, isResponse, }) => next({ schema: schema._def[isResponse ? "out" : "in"] });
|
|
110
|
-
const onNull = () => f.createLiteralTypeNode(f.createNull());
|
|
111
|
-
const producers = {
|
|
112
|
-
ZodString: onPrimitive(typescript_1.default.SyntaxKind.StringKeyword),
|
|
113
|
-
ZodNumber: onPrimitive(typescript_1.default.SyntaxKind.NumberKeyword),
|
|
114
|
-
ZodBigInt: onPrimitive(typescript_1.default.SyntaxKind.BigIntKeyword),
|
|
115
|
-
ZodBoolean: onPrimitive(typescript_1.default.SyntaxKind.BooleanKeyword),
|
|
116
|
-
ZodDateIn: onPrimitive(typescript_1.default.SyntaxKind.StringKeyword),
|
|
117
|
-
ZodDateOut: onPrimitive(typescript_1.default.SyntaxKind.StringKeyword),
|
|
118
|
-
ZodNull: onNull,
|
|
119
|
-
ZodArray: onArray,
|
|
120
|
-
ZodTuple: onTuple,
|
|
121
|
-
ZodRecord: onRecord,
|
|
122
|
-
ZodObject: onObject,
|
|
123
|
-
ZodLiteral: onLiteral,
|
|
124
|
-
ZodIntersection: onIntersection,
|
|
125
|
-
ZodUnion: onSomeUnion,
|
|
126
|
-
ZodFile: onPrimitive(typescript_1.default.SyntaxKind.StringKeyword),
|
|
127
|
-
// ZodUpload:
|
|
128
|
-
ZodAny: onPrimitive(typescript_1.default.SyntaxKind.AnyKeyword),
|
|
129
|
-
ZodDefault: onDefault,
|
|
130
|
-
ZodEnum: onEnum,
|
|
131
|
-
ZodNativeEnum: onNativeEnum,
|
|
132
|
-
ZodEffects: onEffects,
|
|
133
|
-
ZodOptional: onOptional,
|
|
134
|
-
ZodNullable: onNullable,
|
|
135
|
-
ZodDiscriminatedUnion: onSomeUnion,
|
|
136
|
-
ZodBranded: onBranded,
|
|
137
|
-
ZodCatch: onCatch,
|
|
138
|
-
ZodPipeline: onPipeline,
|
|
139
|
-
};
|
|
140
|
-
const zodToTs = ({ schema, ...context }) => (0, schema_walker_1.walkSchema)({
|
|
141
|
-
schema,
|
|
142
|
-
rules: producers,
|
|
143
|
-
onMissing: () => f.createKeywordTypeNode(typescript_1.default.SyntaxKind.AnyKeyword),
|
|
144
|
-
...context,
|
|
145
|
-
});
|
|
146
|
-
exports.zodToTs = zodToTs;
|
|
147
|
-
//# sourceMappingURL=zts.js.map
|
package/dist/zts.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zts.js","sourceRoot":"","sources":["../src/zts.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;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O;IACjB,WAAW,EAAE,UAAU;CACxB,CAAC;AAEK,MAAM,OAAO,GAAG,CAAC,EACtB,MAAM,EACN,GAAG,OAAO,EAGE,EAAE,EAAE,CAChB,IAAA,0BAAU,EAA0B;IAClC,MAAM;IACN,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC,oBAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IAClE,GAAG,OAAO;CACX,CAAC,CAAC;AAXQ,QAAA,OAAO,WAWf"}
|
package/dist-esm/api-response.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-response.js","sourceRoot":"","sources":["../src/api-response.ts"],"names":[],"mappings":""}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
export const f = ts.factory;
|
|
3
|
-
export const exportModifier = [f.createModifier(ts.SyntaxKind.ExportKeyword)];
|
|
4
|
-
export const publicReadonlyModifier = [
|
|
5
|
-
f.createModifier(ts.SyntaxKind.PublicKeyword),
|
|
6
|
-
f.createModifier(ts.SyntaxKind.ReadonlyKeyword),
|
|
7
|
-
];
|
|
8
|
-
export const protectedReadonlyModifier = [
|
|
9
|
-
f.createModifier(ts.SyntaxKind.ProtectedKeyword),
|
|
10
|
-
f.createModifier(ts.SyntaxKind.ReadonlyKeyword),
|
|
11
|
-
];
|
|
12
|
-
const emptyPrefix = f.createTemplateHead("");
|
|
13
|
-
const emptyEnding = f.createTemplateTail("");
|
|
14
|
-
const spacingSuffix = f.createTemplateMiddle(" ");
|
|
15
|
-
export const makeTemplate = (names) => f.createTemplateLiteralType(emptyPrefix, names.map((name, index) => f.createTemplateLiteralTypeSpan(f.createTypeReferenceNode(name), index === names.length - 1 ? emptyEnding : spacingSuffix)));
|
|
16
|
-
export const parametricIndexNode = makeTemplate(["M", "P"]);
|
|
17
|
-
export const makeParam = (name, type, mod) => f.createParameterDeclaration(mod, undefined, name, undefined, type);
|
|
18
|
-
export const makeParams = (params, mod) => Object.keys(params).reduce((acc, name) => acc.concat(makeParam(name, params[name], mod)), []);
|
|
19
|
-
export const makeRecord = (key, value) => f.createExpressionWithTypeArguments(f.createIdentifier("Record"), [
|
|
20
|
-
typeof key === "number"
|
|
21
|
-
? f.createKeywordTypeNode(key)
|
|
22
|
-
: f.createTypeReferenceNode(key),
|
|
23
|
-
f.createKeywordTypeNode(value),
|
|
24
|
-
]);
|
|
25
|
-
export const makeEmptyInitializingConstructor = (params) => f.createConstructorDeclaration(undefined, params, f.createBlock([]));
|
|
26
|
-
export const makeQuotedProp = (name, ref) => f.createPropertySignature(undefined, `"${name}"`, undefined, f.createTypeReferenceNode(ref));
|
|
27
|
-
export const makeConst = (name, value) => f.createVariableDeclarationList([f.createVariableDeclaration(name, undefined, undefined, value)], ts.NodeFlags.Const);
|
|
28
|
-
export const makePublicLiteralType = (name, literals) => f.createTypeAliasDeclaration(exportModifier, name, undefined, f.createUnionTypeNode(literals.map((option) => f.createLiteralTypeNode(f.createStringLiteral(option)))));
|
|
29
|
-
export const makePublicType = (name, value) => f.createTypeAliasDeclaration(exportModifier, name, undefined, value);
|
|
30
|
-
export const makePublicReadonlyProp = (name, type, exp) => f.createPropertyDeclaration(publicReadonlyModifier, name, undefined, type, exp);
|
|
31
|
-
export const makePublicClass = (name, constructor, props = []) => f.createClassDeclaration(exportModifier, name, undefined, undefined, [
|
|
32
|
-
constructor,
|
|
33
|
-
...props,
|
|
34
|
-
]);
|
|
35
|
-
export const makeIndexedPromise = (type, index) => f.createTypeReferenceNode("Promise", [
|
|
36
|
-
f.createIndexedAccessTypeNode(f.createTypeReferenceNode(type), index),
|
|
37
|
-
]);
|
|
38
|
-
export const makeAnyPromise = () => f.createTypeReferenceNode("Promise", [
|
|
39
|
-
f.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
|
|
40
|
-
]);
|
|
41
|
-
export const makePublicExtendedInterface = (name, extender, props) => f.createInterfaceDeclaration(exportModifier, name, undefined, extender, props);
|
|
42
|
-
export const makeTypeParams = (params) => Object.keys(params).reduce((acc, name) => acc.concat(f.createTypeParameterDeclaration([], name, f.createTypeReferenceNode(params[name]))), []);
|
|
43
|
-
export const makeImplementationCallFn = (params, args) => f.createArrowFunction(undefined, undefined, params.map((key) => makeParam(key)), undefined, undefined, f.createCallExpression(f.createPropertyAccessExpression(f.createThis(), "implementation"), undefined, args));
|
|
44
|
-
export const makeObjectKeysReducer = (obj, exp, initial) => f.createCallExpression(f.createPropertyAccessExpression(f.createCallExpression(f.createPropertyAccessExpression(f.createIdentifier("Object"), "keys"), undefined, [f.createIdentifier(obj)]), "reduce"), undefined, [
|
|
45
|
-
f.createArrowFunction(undefined, undefined, makeParams({ acc: undefined, key: undefined }), undefined, undefined, exp),
|
|
46
|
-
initial,
|
|
47
|
-
]);
|
|
48
|
-
//# sourceMappingURL=client-helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-helpers.js","sourceRoot":"","sources":["../src/client-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;AAE5B,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;AAE9E,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC;IAC7C,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;CAChD,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC;IAChD,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;CA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