expo-backend-types 0.0.34 → 0.0.36

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "expo-backend-types",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
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",
11
+ "src/**/exports.ts"
10
12
  ],
11
13
  "scripts": {
12
14
  "ci": "npm run build && npm run generate-ts-schema && npm run check-format && npm run lint && npm run check-exports",
@@ -26,7 +28,7 @@
26
28
  "test:cov": "jest --coverage",
27
29
  "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
28
30
  "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",
31
+ "generate-ts-schema": "node ./dist/src/main.swagger.js && openapi-typescript ./swagger.yaml -o ./types/schema.d.ts",
30
32
  "prepare": "husky",
31
33
  "prepublishOnly": "npm run ci"
32
34
  },
@@ -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,2 @@
1
+ export * from './dto/login.dto';
2
+ export * from './dto/register.dto';
@@ -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) {}
@@ -0,0 +1 @@
1
+ export * from './dto/cuenta.dto';
package/src/exports.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './auth/exports';
2
+ export * from './cuenta/exports';
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';