@origins-digital/zod-openapi-utils 0.0.2 → 0.0.4
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/openapi/dto.d.ts +10 -0
- package/dist/openapi/dto.d.ts.map +1 -0
- package/dist/openapi/dto.js +19 -0
- package/dist/openapi/dto.js.map +1 -0
- package/dist/openapi/zod.exception.d.ts +8 -0
- package/dist/openapi/zod.exception.d.ts.map +1 -0
- package/dist/openapi/zod.exception.js +19 -0
- package/dist/openapi/zod.exception.js.map +1 -0
- package/package.json +16 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./openapi/zod.extension"), exports);
|
|
18
18
|
__exportStar(require("./openapi/zod-to-openapi"), exports);
|
|
19
19
|
__exportStar(require("./openapi/make-open-api"), exports);
|
|
20
|
+
__exportStar(require("./openapi/dto"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,2DAAyC;AACzC,0DAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,2DAAyC;AACzC,0DAAwC;AACxC,gDAA8B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ZodSchema, ZodTypeDef } from 'zod';
|
|
2
|
+
export interface ZodDto<TOutput = any, TDef extends ZodTypeDef = ZodTypeDef, TInput = TOutput> {
|
|
3
|
+
new (): TOutput;
|
|
4
|
+
isZodDto: true;
|
|
5
|
+
schema: ZodSchema<TOutput, TDef, TInput>;
|
|
6
|
+
create(input: unknown): TOutput;
|
|
7
|
+
}
|
|
8
|
+
export declare function createZodDto<TOutput = any, TDef extends ZodTypeDef = ZodTypeDef, TInput = TOutput>(schema: ZodSchema<TOutput, TDef, TInput>): ZodDto<TOutput, TDef, TInput>;
|
|
9
|
+
export declare function isZodDto(metatype: any): metatype is ZodDto<unknown>;
|
|
10
|
+
//# sourceMappingURL=dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../../src/openapi/dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAG5C,MAAM,WAAW,MAAM,CACrB,OAAO,GAAG,GAAG,EACb,IAAI,SAAS,UAAU,GAAG,UAAU,EACpC,MAAM,GAAG,OAAO;IAEhB,QAAQ,OAAO,CAAC;IAChB,QAAQ,EAAE,IAAI,CAAC;IACf,MAAM,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;CACjC;AAED,wBAAgB,YAAY,CAC1B,OAAO,GAAG,GAAG,EACb,IAAI,SAAS,UAAU,GAAG,UAAU,EACpC,MAAM,GAAG,OAAO,EAChB,MAAM,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,GAUH,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CACnE;AAGD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,CAEnE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createZodDto = createZodDto;
|
|
4
|
+
exports.isZodDto = isZodDto;
|
|
5
|
+
function createZodDto(schema) {
|
|
6
|
+
class AugmentedZodDto {
|
|
7
|
+
static create(input) {
|
|
8
|
+
return this.schema.parse(input);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
AugmentedZodDto.isZodDto = true;
|
|
12
|
+
AugmentedZodDto.schema = schema;
|
|
13
|
+
return AugmentedZodDto;
|
|
14
|
+
}
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
function isZodDto(metatype) {
|
|
17
|
+
return metatype === null || metatype === void 0 ? void 0 : metatype.isZodDto;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.js","sourceRoot":"","sources":["../../src/openapi/dto.ts"],"names":[],"mappings":";;AAcA,oCAeC;AAGD,4BAEC;AApBD,SAAgB,YAAY,CAI1B,MAAwC;IACxC,MAAM,eAAe;QAIZ,MAAM,CAAC,MAAM,CAAC,KAAc;YACjC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;;IALa,wBAAQ,GAAG,IAAI,CAAC;IAChB,sBAAM,GAAG,MAAM,CAAC;IAOhC,OAAO,eAA2D,CAAC;AACrE,CAAC;AAED,8DAA8D;AAC9D,SAAgB,QAAQ,CAAC,QAAa;IACpC,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BadRequestException } from '@nestjs/common';
|
|
2
|
+
import { ZodError } from 'zod';
|
|
3
|
+
export declare class ZodValidationException extends BadRequestException {
|
|
4
|
+
private error;
|
|
5
|
+
constructor(error: ZodError);
|
|
6
|
+
getZodError(): ZodError<any>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=zod.exception.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod.exception.d.ts","sourceRoot":"","sources":["../../src/openapi/zod.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAc,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE/B,qBAAa,sBAAuB,SAAQ,mBAAmB;IACjD,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,QAAQ;IAQ5B,WAAW;CAGnB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodValidationException = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
class ZodValidationException extends common_1.BadRequestException {
|
|
6
|
+
constructor(error) {
|
|
7
|
+
super({
|
|
8
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
9
|
+
message: 'Validation failed',
|
|
10
|
+
errors: error.errors,
|
|
11
|
+
});
|
|
12
|
+
this.error = error;
|
|
13
|
+
}
|
|
14
|
+
getZodError() {
|
|
15
|
+
return this.error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ZodValidationException = ZodValidationException;
|
|
19
|
+
//# sourceMappingURL=zod.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod.exception.js","sourceRoot":"","sources":["../../src/openapi/zod.exception.ts"],"names":[],"mappings":";;;AAAA,2CAAiE;AAGjE,MAAa,sBAAuB,SAAQ,4BAAmB;IAC7D,YAAoB,KAAe;QACjC,KAAK,CAAC;YACJ,UAAU,EAAE,mBAAU,CAAC,WAAW;YAClC,OAAO,EAAE,mBAAmB;YAC5B,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC,CAAC;QALe,UAAK,GAAL,KAAK,CAAU;IAMnC,CAAC;IAEM,WAAW;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AAZD,wDAYC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@origins-digital/zod-openapi-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Origins Zod OpenAPI Utils",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.d.ts",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"sideEffects": [
|
|
9
|
+
"./dist/openapi/zod.extension.js"
|
|
10
|
+
],
|
|
8
11
|
"author": "Origins Digital (https://www.origins-digital.com/)",
|
|
9
12
|
"license": "MIT",
|
|
10
13
|
"exports": {
|
|
@@ -86,6 +89,18 @@
|
|
|
86
89
|
"commit": true,
|
|
87
90
|
"addUntrackedFiles": false
|
|
88
91
|
},
|
|
92
|
+
"plugins": {
|
|
93
|
+
"@release-it/bumper": {
|
|
94
|
+
"out": [
|
|
95
|
+
{
|
|
96
|
+
"file": "../swagger/package.json",
|
|
97
|
+
"path": [
|
|
98
|
+
"dependencies.@origins-digital/zod-openapi-utils"
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
},
|
|
89
104
|
"npm": {
|
|
90
105
|
"publish": true
|
|
91
106
|
},
|