expo-backend-types 0.4.0-EXPO-248-EB-GrupoEtiqueta.10 → 0.4.0-EXPO-248-EB-GrupoEtiqueta.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ import { ReplaceDatesWithStrings } from '@/shared/dto-modification/zod-without-dates';
2
+ import { ZodDtoStatic } from '@anatine/zod-nestjs';
3
+ import { OpenApiZodAny } from '@anatine/zod-openapi';
4
+ export declare function createZodDtoWithoutDate<T extends OpenApiZodAny>(schema: T): ZodDtoStatic<ReplaceDatesWithStrings<T>>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createZodDtoWithoutDate = void 0;
4
+ const zod_without_dates_1 = require("./zod-without-dates");
5
+ const zod_nestjs_1 = require("@anatine/zod-nestjs");
6
+ function createZodDtoWithoutDate(schema) {
7
+ return (0, zod_nestjs_1.createZodDto)((0, zod_without_dates_1.replaceDatesWithStrings)(schema));
8
+ }
9
+ exports.createZodDtoWithoutDate = createZodDtoWithoutDate;
10
+ //# sourceMappingURL=create-zod-dto-without-date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-zod-dto-without-date.js","sourceRoot":"","sources":["../../../../src/shared/dto-modification/create-zod-dto-without-date.ts"],"names":[],"mappings":";;;AAAA,2DAGqD;AACrD,oDAAiE;AAGjE,SAAgB,uBAAuB,CACrC,MAAS;IAET,OAAO,IAAA,yBAAY,EAAC,IAAA,2CAAuB,EAAC,MAAM,CAAC,CAElD,CAAC;AACJ,CAAC;AAND,0DAMC"}
@@ -0,0 +1,4 @@
1
+ export type WithSerializedDates<T> = T extends Date ? string : T extends Array<infer R> ? Array<WithSerializedDates<R>> : T extends object ? {
2
+ [K in keyof T]: WithSerializedDates<T[K]>;
3
+ } : T;
4
+ export declare const withoutDates: <T>(model: T) => WithSerializedDates<T>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withoutDates = void 0;
4
+ const withoutDates = (model) => JSON.parse(JSON.stringify(model));
5
+ exports.withoutDates = withoutDates;
6
+ //# sourceMappingURL=without-dates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"without-dates.js","sourceRoot":"","sources":["../../../../src/shared/dto-modification/without-dates.ts"],"names":[],"mappings":";;;AAQO,MAAM,YAAY,GAAG,CAAI,KAAQ,EAA0B,EAAE,CAClE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAA2B,CAAC;AADjD,QAAA,YAAY,gBACqC"}
@@ -0,0 +1,8 @@
1
+ import { OpenApiZodAny } from '@anatine/zod-openapi';
2
+ import { z, ZodArray, ZodDate, ZodIntersection, ZodObject, ZodTypeAny, ZodUnion } from 'zod';
3
+ export type ReplaceDatesWithStrings<T extends ZodTypeAny> = T extends ZodDate ? ReturnType<typeof z.string> : T extends ZodObject<infer Shape> ? ZodObject<{
4
+ [k in keyof Shape]: ReplaceDatesWithStrings<Shape[k]>;
5
+ }> : T extends ZodArray<infer Item> ? ZodArray<ReplaceDatesWithStrings<Item>> : T extends ZodUnion<infer Options> ? ZodUnion<{
6
+ [k in keyof Options]: ReplaceDatesWithStrings<Options[k]>;
7
+ }> : T extends ZodIntersection<infer Left, infer Right> ? ZodIntersection<ReplaceDatesWithStrings<Left>, ReplaceDatesWithStrings<Right>> : T;
8
+ export declare const replaceDatesWithStrings: <T extends OpenApiZodAny>(schema: T) => ReplaceDatesWithStrings<T>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replaceDatesWithStrings = void 0;
4
+ const zod_1 = require("zod");
5
+ const replaceDatesWithStrings = (schema) => {
6
+ if (schema instanceof zod_1.ZodDate) {
7
+ return zod_1.z.string().datetime();
8
+ }
9
+ if (schema instanceof zod_1.ZodObject) {
10
+ const newShape = {};
11
+ for (const key in schema.shape) {
12
+ newShape[key] = (0, exports.replaceDatesWithStrings)(schema.shape[key]);
13
+ }
14
+ return zod_1.z.object(newShape);
15
+ }
16
+ if (schema instanceof zod_1.ZodArray) {
17
+ return zod_1.z.array((0, exports.replaceDatesWithStrings)(schema.element));
18
+ }
19
+ if (schema instanceof zod_1.ZodUnion) {
20
+ return zod_1.z.union(schema._def.options.map((option) => (0, exports.replaceDatesWithStrings)(option)));
21
+ }
22
+ if (schema instanceof zod_1.ZodIntersection) {
23
+ return zod_1.z.intersection((0, exports.replaceDatesWithStrings)(schema._def.left), (0, exports.replaceDatesWithStrings)(schema._def.right));
24
+ }
25
+ return schema;
26
+ };
27
+ exports.replaceDatesWithStrings = replaceDatesWithStrings;
28
+ //# sourceMappingURL=zod-without-dates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-without-dates.js","sourceRoot":"","sources":["../../../../src/shared/dto-modification/zod-without-dates.ts"],"names":[],"mappings":";;;AACA,6BASa;AAoBN,MAAM,uBAAuB,GAAG,CACrC,MAAS,EACmB,EAAE;IAC9B,IAAI,MAAM,YAAY,aAAO,EAAE,CAAC;QAC9B,OAAO,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAgC,CAAC;IAC7D,CAAC;IAED,IAAI,MAAM,YAAY,eAAS,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAgB,EAAE,CAAC;QACjC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YAC/B,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAA,+BAAuB,EAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,OAAC,CAAC,MAAM,CAAC,QAAQ,CAA+B,CAAC;IAC1D,CAAC;IAED,IAAI,MAAM,YAAY,cAAQ,EAAE,CAAC;QAC/B,OAAO,OAAC,CAAC,KAAK,CACZ,IAAA,+BAAuB,EAAC,MAAM,CAAC,OAAO,CAAC,CACV,CAAC;IAClC,CAAC;IAED,IAAI,MAAM,YAAY,cAAQ,EAAE,CAAC;QAC/B,OAAO,OAAC,CAAC,KAAK,CACZ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAS,EAAE,EAAE,CAAC,IAAA,+BAAuB,EAAC,MAAM,CAAC,CAAC,CAC1C,CAAC;IAClC,CAAC;IAED,IAAI,MAAM,YAAY,qBAAe,EAAE,CAAC;QACtC,OAAO,OAAC,CAAC,YAAY,CACnB,IAAA,+BAAuB,EAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EACzC,IAAA,+BAAuB,EAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CACb,CAAC;IAClC,CAAC;IAGD,OAAO,MAAoC,CAAC;AAC9C,CAAC,CAAC;AApCW,QAAA,uBAAuB,2BAoClC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-backend-types",
3
- "version": "0.4.0-EXPO-248-EB-GrupoEtiqueta.10",
3
+ "version": "0.4.0-EXPO-248-EB-GrupoEtiqueta.11",
4
4
  "description": "",
5
5
  "author": "Expo",
6
6
  "private": false,
@@ -9,7 +9,7 @@
9
9
  "dist/types",
10
10
  "dist/src/**/*.dto.{js,d.ts,ts}",
11
11
  "dist/src/**/exports.{js,d.ts,ts}",
12
- "dist/src/shared/dtoModification",
12
+ "dist/src/shared/dto-modification",
13
13
  "dist/src/i18n"
14
14
  ],
15
15
  "scripts": {