expo-backend-types 0.0.34 → 0.0.35
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +4 -3
- package/src/auth/dto/login.dto.ts +22 -0
- package/src/auth/dto/register.dto.ts +16 -0
- package/src/cuenta/dto/cuenta.dto.ts +28 -0
- package/types/dto.ts +1 -0
- package/types/index.d.ts +2 -2
package/package.json
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "expo-backend-types",
|
3
|
-
"version": "0.0.
|
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,7 +27,7 @@
|
|
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
|
},
|
@@ -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';
|