expo-backend-types 0.0.33 → 0.0.35

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "expo-backend-types",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "",
5
5
  "author": "Expo",
6
6
  "private": false,
7
7
  "license": "UNLICENSED",
8
8
  "files": [
9
- "types"
9
+ "types",
10
+ "src/**/*.dto.ts"
10
11
  ],
11
12
  "scripts": {
12
13
  "ci": "npm run build && npm run generate-ts-schema && npm run check-format && npm run lint && npm run check-exports",
@@ -26,11 +27,13 @@
26
27
  "test:cov": "jest --coverage",
27
28
  "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
28
29
  "test:e2e": "jest --config ./test/jest-e2e.json",
29
- "generate-ts-schema": "node ./dist/main.swagger.js && openapi-typescript ./swagger.yaml -o ./types/schema.d.ts",
30
+ "generate-ts-schema": "node ./dist/src/main.swagger.js && openapi-typescript ./swagger.yaml -o ./types/schema.d.ts",
30
31
  "prepare": "husky",
31
32
  "prepublishOnly": "npm run ci"
32
33
  },
33
34
  "dependencies": {
35
+ "@anatine/zod-nestjs": "^2.0.9",
36
+ "@anatine/zod-openapi": "^2.2.6",
34
37
  "@nestjs/common": "^10.0.0",
35
38
  "@nestjs/config": "^3.2.3",
36
39
  "@nestjs/core": "^10.0.0",
@@ -40,6 +43,7 @@
40
43
  "@prisma/client": "^5.14.0",
41
44
  "bcrypt": "^5.1.1",
42
45
  "json-to-pretty-yaml": "^1.2.2",
46
+ "openapi3-ts": "^4.4.0",
43
47
  "reflect-metadata": "^0.2.0",
44
48
  "rxjs": "^7.8.1",
45
49
  "zod": "^3.23.8"
@@ -107,4 +111,4 @@
107
111
  "git add"
108
112
  ]
109
113
  }
110
- }
114
+ }
@@ -0,0 +1,22 @@
1
+ import { createZodDto } from '@anatine/zod-nestjs';
2
+ import { cuentaSchema } from 'src/cuenta/dto/cuenta.dto';
3
+ import z from 'zod';
4
+
5
+ export const loginSchema = cuentaSchema.pick({
6
+ username: true,
7
+ password: true,
8
+ });
9
+
10
+ export class LoginDto extends createZodDto(loginSchema) {}
11
+
12
+ export const loginResponseSchema = z.object({
13
+ user: cuentaSchema.omit({
14
+ password: true,
15
+ }),
16
+ backendTokens: z.object({
17
+ accessToken: z.string(),
18
+ refreshToken: z.string(),
19
+ }),
20
+ });
21
+
22
+ export class LoginResponseDto extends createZodDto(loginResponseSchema) {}
@@ -0,0 +1,16 @@
1
+ import { createZodDto } from '@anatine/zod-nestjs';
2
+ import { cuentaSchema } from 'src/cuenta/dto/cuenta.dto';
3
+
4
+ export const registerSchema = cuentaSchema.pick({
5
+ username: true,
6
+ password: true,
7
+ isAdmin: true,
8
+ });
9
+
10
+ export class RegisterDto extends createZodDto(registerSchema) {}
11
+
12
+ export const registerResponseSchema = registerSchema.omit({
13
+ password: true,
14
+ });
15
+
16
+ export class RegisterResponseDto extends createZodDto(registerResponseSchema) {}
@@ -0,0 +1,28 @@
1
+ import { createZodDto } from '@anatine/zod-nestjs';
2
+ import { z } from 'zod';
3
+
4
+ export const cuentaSchema = z.object({
5
+ id: z
6
+ .string({
7
+ required_error: 'El id es requerido',
8
+ })
9
+ .uuid({
10
+ message: 'El id debe ser un UUID',
11
+ }),
12
+ username: z.string({
13
+ required_error: 'El nombre de usuario es requerido',
14
+ }),
15
+ password: z
16
+ .string({
17
+ required_error: 'La contraseña es requerida',
18
+ })
19
+ .min(6, 'La contraseña debe tener al menos 6 caracteres'),
20
+ isAdmin: z.boolean().default(false),
21
+ created_at: z.string().datetime(),
22
+ updated_at: z.string().datetime(),
23
+ // filtroBase: z.array(EtiquetaSchema),
24
+ filtroBaseActivo: z.boolean().default(false),
25
+ fcmToken: z.array(z.string()).default([]),
26
+ });
27
+
28
+ export class CuentaDto extends createZodDto(cuentaSchema) {}
package/types/dto.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '../src/exports';
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './schema';
2
- export * from './prisma-schema/index.d';
1
+ export * from './schema';
2
+ export * from './prisma-schema/index.d';
package/types/schema.d.ts CHANGED
@@ -55,7 +55,44 @@ export interface paths {
55
55
  }
56
56
  export type webhooks = Record<string, never>;
57
57
  export interface components {
58
- schemas: never;
58
+ schemas: {
59
+ RegisterDto: {
60
+ username: string;
61
+ password: string;
62
+ /** @default false */
63
+ isAdmin: boolean;
64
+ };
65
+ RegisterResponseDto: {
66
+ username: string;
67
+ /** @default false */
68
+ isAdmin: boolean;
69
+ };
70
+ LoginDto: {
71
+ username: string;
72
+ password: string;
73
+ };
74
+ LoginResponseDto: {
75
+ user: {
76
+ /** Format: uuid */
77
+ id?: string;
78
+ username?: string;
79
+ /** @default false */
80
+ isAdmin: boolean;
81
+ /** Format: date-time */
82
+ created_at?: string;
83
+ /** Format: date-time */
84
+ updated_at?: string;
85
+ /** @default false */
86
+ filtroBaseActivo: boolean;
87
+ /** @default [] */
88
+ fcmToken: string[];
89
+ };
90
+ backendTokens: {
91
+ accessToken?: string;
92
+ refreshToken?: string;
93
+ };
94
+ };
95
+ };
59
96
  responses: never;
60
97
  parameters: never;
61
98
  requestBodies: never;
@@ -71,13 +108,20 @@ export interface operations {
71
108
  path?: never;
72
109
  cookie?: never;
73
110
  };
74
- requestBody?: never;
111
+ requestBody: {
112
+ content: {
113
+ "application/json": components["schemas"]["RegisterDto"];
114
+ };
115
+ };
75
116
  responses: {
117
+ /** @description Cuenta creada */
76
118
  201: {
77
119
  headers: {
78
120
  [name: string]: unknown;
79
121
  };
80
- content?: never;
122
+ content: {
123
+ "application/json": components["schemas"]["RegisterResponseDto"];
124
+ };
81
125
  };
82
126
  };
83
127
  };
@@ -88,13 +132,20 @@ export interface operations {
88
132
  path?: never;
89
133
  cookie?: never;
90
134
  };
91
- requestBody?: never;
135
+ requestBody: {
136
+ content: {
137
+ "application/json": components["schemas"]["LoginDto"];
138
+ };
139
+ };
92
140
  responses: {
93
- 201: {
141
+ /** @description Cuenta creada */
142
+ 200: {
94
143
  headers: {
95
144
  [name: string]: unknown;
96
145
  };
97
- content?: never;
146
+ content: {
147
+ "application/json": components["schemas"]["LoginResponseDto"];
148
+ };
98
149
  };
99
150
  };
100
151
  };