@natrave/shared-entities 1.1.1
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/.changeset/README.md +9 -0
- package/.changeset/config.json +11 -0
- package/.github/workflows/release.yml +80 -0
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +4 -0
- package/.lintstagedrc.json +5 -0
- package/.prettierignore +2 -0
- package/.prettierrc.json +12 -0
- package/CHANGELOG.md +13 -0
- package/eslint.config.js +84 -0
- package/package.json +52 -0
- package/src/app-auth/index.ts +5 -0
- package/src/app-auth/password-resets/index.ts +1 -0
- package/src/app-auth/password-resets/password-reset.entity.ts +52 -0
- package/src/app-auth/refresh-tokens/index.ts +1 -0
- package/src/app-auth/refresh-tokens/refresh-token.entity.ts +52 -0
- package/src/app-auth/user-auth-providers/enums/auth-provider.enum.ts +24 -0
- package/src/app-auth/user-auth-providers/index.ts +3 -0
- package/src/app-auth/user-auth-providers/user-auth-provider.entity.ts +58 -0
- package/src/app-auth/user-verifications/enums/verification-type.enum.ts +19 -0
- package/src/app-auth/user-verifications/index.ts +3 -0
- package/src/app-auth/user-verifications/user-verification.entity.ts +62 -0
- package/src/app-auth/users/index.ts +1 -0
- package/src/app-auth/users/user.entity.ts +149 -0
- package/src/app-auth/users/utils/format-data.utils.ts +38 -0
- package/src/common/utils/decimal-transformer.utils.ts +13 -0
- package/src/facilities/addresses/address.entity.ts +82 -0
- package/src/facilities/addresses/index.ts +1 -0
- package/src/facilities/facilities/enums/facility-status.enum.ts +25 -0
- package/src/facilities/facilities/facility.entity.ts +137 -0
- package/src/facilities/facilities/index.ts +3 -0
- package/src/facilities/facilities/utils/sanititze.utils.ts +19 -0
- package/src/facilities/facility-images/facility-image.entity.ts +64 -0
- package/src/facilities/facility-images/index.ts +1 -0
- package/src/facilities/facility-owners/facility-owner.entity.ts +74 -0
- package/src/facilities/facility-owners/index.ts +1 -0
- package/src/facilities/facility-owners/utils/sanitize.utils.ts +16 -0
- package/src/facilities/fields/enums/surface-type.enum.ts +35 -0
- package/src/facilities/fields/field.entity.ts +74 -0
- package/src/facilities/fields/index.ts +3 -0
- package/src/facilities/index.ts +5 -0
- package/src/index.ts +7 -0
- package/src/payments/index.ts +5 -0
- package/src/payments/payment-providers/enums/payment-provider-name.enum.ts +15 -0
- package/src/payments/payment-providers/index.ts +3 -0
- package/src/payments/payment-providers/payment-provider.entity.ts +61 -0
- package/src/payments/payments/enums/payment-method.enum.ts +20 -0
- package/src/payments/payments/enums/payment-status.enum.ts +45 -0
- package/src/payments/payments/index.ts +5 -0
- package/src/payments/payments/payment.entity.ts +84 -0
- package/src/payments/user-payment-providers/index.ts +1 -0
- package/src/payments/user-payment-providers/user-payment-provider.entity.ts +73 -0
- package/src/tournaments/index.ts +12 -0
- package/src/tournaments/tournament-facilities/index.ts +1 -0
- package/src/tournaments/tournament-facilities/tournament-facility.entity.ts +67 -0
- package/src/tournaments/tournament-format-configs/index.ts +1 -0
- package/src/tournaments/tournament-format-configs/tournament-format-config.entity.ts +69 -0
- package/src/tournaments/tournament-match-cards/index.ts +1 -0
- package/src/tournaments/tournament-match-cards/tournament-match-card.entity.ts +86 -0
- package/src/tournaments/tournament-match-goals/index.ts +1 -0
- package/src/tournaments/tournament-match-goals/tournament-match-goal.entity.ts +88 -0
- package/src/tournaments/tournament-match-schemas/index.ts +1 -0
- package/src/tournaments/tournament-match-schemas/tournament-match-schema.entity.ts +51 -0
- package/src/tournaments/tournament-matches/index.ts +1 -0
- package/src/tournaments/tournament-matches/tournament-match.entity.ts +101 -0
- package/src/tournaments/tournament-payments/index.ts +1 -0
- package/src/tournaments/tournament-payments/tournament-payment.entity.ts +67 -0
- package/src/tournaments/tournament-players/index.ts +1 -0
- package/src/tournaments/tournament-players/tournament-player.entity.ts +96 -0
- package/src/tournaments/tournament-prize-rules/index.ts +1 -0
- package/src/tournaments/tournament-prize-rules/tournament-prize-rule.entity.ts +65 -0
- package/src/tournaments/tournament-rules/index.ts +1 -0
- package/src/tournaments/tournament-rules/tournament-rule.entity.ts +81 -0
- package/src/tournaments/tournament-teams/index.ts +1 -0
- package/src/tournaments/tournament-teams/tournament-team.entity.ts +111 -0
- package/src/tournaments/tournament-teams/utils/invite-code-generator.ts +12 -0
- package/src/tournaments/tournaments/index.ts +1 -0
- package/src/tournaments/tournaments/tournament.entity.ts +153 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changesets
|
|
2
|
+
|
|
3
|
+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool
|
|
4
|
+
that works with multi-package repos, or single-package repos to help you version and publish your
|
|
5
|
+
code. You can find the full documentation for it
|
|
6
|
+
[in our repository](https://github.com/changesets/changesets)
|
|
7
|
+
|
|
8
|
+
We have a quick list of common questions to get you started engaging with this project in
|
|
9
|
+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
|
|
3
|
+
"changelog": "@changesets/cli/changelog",
|
|
4
|
+
"commit": false,
|
|
5
|
+
"fixed": [],
|
|
6
|
+
"linked": [],
|
|
7
|
+
"access": "restricted",
|
|
8
|
+
"baseBranch": "main",
|
|
9
|
+
"updateInternalDependencies": "patch",
|
|
10
|
+
"ignore": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
on:
|
|
2
|
+
push:
|
|
3
|
+
branches:
|
|
4
|
+
- main
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
release:
|
|
8
|
+
name: Criar Release & Publicar no npm
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- name: 🚀 Checkout do código
|
|
13
|
+
uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: 📦 Setup Node.js
|
|
16
|
+
uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: 'lts/*'
|
|
19
|
+
registry-url: 'https://registry.npmjs.org/'
|
|
20
|
+
|
|
21
|
+
- name: 🔑 Ativar e preparar Corepack (pnpm)
|
|
22
|
+
run: |
|
|
23
|
+
corepack enable
|
|
24
|
+
corepack prepare pnpm@latest --activate
|
|
25
|
+
|
|
26
|
+
- name: 📥 Instalar dependências
|
|
27
|
+
run: pnpm install --frozen-lockfile
|
|
28
|
+
|
|
29
|
+
- name: 🔎 Rodar lint e checagem de tipos
|
|
30
|
+
run: |
|
|
31
|
+
pnpm lint
|
|
32
|
+
pnpm check:types
|
|
33
|
+
|
|
34
|
+
- name: 🚀 Criar versão se necessário
|
|
35
|
+
id: version
|
|
36
|
+
run: pnpm changeset version
|
|
37
|
+
env:
|
|
38
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
39
|
+
|
|
40
|
+
- name: 🔄 Commitar alterações de versão
|
|
41
|
+
run: |
|
|
42
|
+
# Configurar usuário do Git para o commit
|
|
43
|
+
git config user.name "github-actions[bot]"
|
|
44
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
45
|
+
|
|
46
|
+
# Adicionar todas as alterações
|
|
47
|
+
git add .
|
|
48
|
+
|
|
49
|
+
# Verificar se há alterações para commit
|
|
50
|
+
if git diff-index --quiet HEAD; then
|
|
51
|
+
echo "✅ Nenhuma alteração para commitar."
|
|
52
|
+
else
|
|
53
|
+
# Commitar as alterações
|
|
54
|
+
git commit -m "chore(release): commit version bump e changesets"
|
|
55
|
+
# Fazer push para a branch atual
|
|
56
|
+
git push origin HEAD:${{ github.ref }}
|
|
57
|
+
fi
|
|
58
|
+
env:
|
|
59
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
60
|
+
|
|
61
|
+
- name: ⏭️ Pular publicação se não houver mudanças
|
|
62
|
+
if: steps.version.outputs.skipped == 'true'
|
|
63
|
+
run: echo "🟡 Nenhuma mudança detectada, pulando publicação."
|
|
64
|
+
|
|
65
|
+
- name: 🔍 Verificar se NPM_TOKEN está configurado
|
|
66
|
+
run: |
|
|
67
|
+
if [ -z "$NODE_AUTH_TOKEN" ]; then
|
|
68
|
+
echo "❌ NPM_TOKEN não está configurado corretamente!"
|
|
69
|
+
exit 1
|
|
70
|
+
else
|
|
71
|
+
echo "✅ NPM_TOKEN está configurado corretamente."
|
|
72
|
+
fi
|
|
73
|
+
env:
|
|
74
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
75
|
+
|
|
76
|
+
- name: 📦 Publicar no npm
|
|
77
|
+
if: steps.version.outputs.skipped != 'true'
|
|
78
|
+
run: pnpm publish --access public
|
|
79
|
+
env:
|
|
80
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.husky/pre-push
ADDED
package/.prettierignore
ADDED
package/.prettierrc.json
ADDED
package/CHANGELOG.md
ADDED
package/eslint.config.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
3
|
+
import tsparser from '@typescript-eslint/parser';
|
|
4
|
+
import prettier from 'eslint-plugin-prettier';
|
|
5
|
+
import importPlugin from 'eslint-plugin-import';
|
|
6
|
+
import unusedImports from 'eslint-plugin-unused-imports';
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
js.configs.recommended,
|
|
10
|
+
{
|
|
11
|
+
files: ['**/*.ts'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
parser: tsparser,
|
|
14
|
+
sourceType: 'module',
|
|
15
|
+
parserOptions: {
|
|
16
|
+
project: ['./tsconfig.json'],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
ignores: ['**/*.d.ts', 'dist/', 'node_modules/'],
|
|
20
|
+
plugins: {
|
|
21
|
+
'@typescript-eslint': tseslint,
|
|
22
|
+
prettier,
|
|
23
|
+
import: importPlugin,
|
|
24
|
+
'unused-imports': unusedImports,
|
|
25
|
+
},
|
|
26
|
+
settings: {
|
|
27
|
+
'import/resolver': {
|
|
28
|
+
typescript: {
|
|
29
|
+
project: './tsconfig.json',
|
|
30
|
+
},
|
|
31
|
+
node: {
|
|
32
|
+
extensions: ['.js', '.ts'],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
rules: {
|
|
37
|
+
'prettier/prettier': 'error',
|
|
38
|
+
'no-unused-vars': 'off',
|
|
39
|
+
'@typescript-eslint/no-unused-vars': [
|
|
40
|
+
'error',
|
|
41
|
+
{
|
|
42
|
+
argsIgnorePattern: '^_',
|
|
43
|
+
varsIgnorePattern: '^_',
|
|
44
|
+
caughtErrorsIgnorePattern: '^_',
|
|
45
|
+
ignoreRestSiblings: true,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
49
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
50
|
+
'@typescript-eslint/consistent-type-imports': 'error',
|
|
51
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
52
|
+
'import/extensions': [
|
|
53
|
+
'error',
|
|
54
|
+
'ignorePackages',
|
|
55
|
+
{
|
|
56
|
+
js: 'never',
|
|
57
|
+
ts: 'never',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
'import/order': [
|
|
61
|
+
'error',
|
|
62
|
+
{
|
|
63
|
+
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
|
|
64
|
+
'newlines-between': 'always',
|
|
65
|
+
alphabetize: { order: 'asc', caseInsensitive: true },
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
'import/no-unresolved': 'error',
|
|
69
|
+
'import/no-absolute-path': 'error',
|
|
70
|
+
'import/no-duplicates': 'error',
|
|
71
|
+
'import/no-extraneous-dependencies': [
|
|
72
|
+
'error',
|
|
73
|
+
{
|
|
74
|
+
devDependencies: ['**/*.test.ts', '**/*.spec.ts'],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
'unused-imports/no-unused-imports': 'error',
|
|
78
|
+
'unused-imports/no-unused-vars': [
|
|
79
|
+
'warn',
|
|
80
|
+
{ vars: 'all', args: 'after-used', argsIgnorePattern: '^_' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@natrave/shared-entities",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Entidades compartilhadass da NaTrave",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/na-trave/shared-entities.git"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"typescript",
|
|
19
|
+
"shared-entities",
|
|
20
|
+
"natrave"
|
|
21
|
+
],
|
|
22
|
+
"author": "NaTrave!",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"private": false,
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@changesets/cli": "^2.28.1",
|
|
27
|
+
"@eslint/js": "^9.23.0",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^8.27.0",
|
|
29
|
+
"@typescript-eslint/parser": "^8.27.0",
|
|
30
|
+
"eslint": "^9.23.0",
|
|
31
|
+
"eslint-config-prettier": "^10.1.1",
|
|
32
|
+
"eslint-import-resolver-typescript": "^4.2.2",
|
|
33
|
+
"eslint-plugin-import": "^2.31.0",
|
|
34
|
+
"eslint-plugin-prettier": "^5.2.4",
|
|
35
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
36
|
+
"husky": "^9.1.7",
|
|
37
|
+
"lint-staged": "^15.5.0",
|
|
38
|
+
"prettier": "^3.5.3",
|
|
39
|
+
"ts-node": "^10.9.2"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@natrave/tournaments-service-types": "^1.1.0",
|
|
43
|
+
"reflect-metadata": "^0.2.2",
|
|
44
|
+
"typeorm": "^0.3.21"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc",
|
|
48
|
+
"clean": "rm -rf dist",
|
|
49
|
+
"lint": "eslint src --ext .ts",
|
|
50
|
+
"check:types": "tsc --noEmit"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PasswordReset } from './password-reset.entity';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
Column,
|
|
4
|
+
PrimaryGeneratedColumn,
|
|
5
|
+
CreateDateColumn,
|
|
6
|
+
ManyToOne,
|
|
7
|
+
JoinColumn,
|
|
8
|
+
Unique,
|
|
9
|
+
} from 'typeorm';
|
|
10
|
+
|
|
11
|
+
import { User } from 'app-auth/users';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Entidade que representa um reset de senha.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Esta entidade armazena os dados relacionados ao processo de reset de senha de um usuário,
|
|
18
|
+
* incluindo a data de criação, expiração e o momento em que o reset foi utilizado (se aplicável).
|
|
19
|
+
* Também associa o reset ao respectivo usuário, garantindo a integridade da operação.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
@Entity('password_resets')
|
|
24
|
+
@Unique(['token', 'userId'])
|
|
25
|
+
export class PasswordReset {
|
|
26
|
+
@PrimaryGeneratedColumn()
|
|
27
|
+
id: number;
|
|
28
|
+
|
|
29
|
+
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
|
|
32
|
+
@Column({ name: 'expires_at', type: 'timestamptz' })
|
|
33
|
+
expiresAt: Date;
|
|
34
|
+
|
|
35
|
+
@Column({ name: 'used_at', type: 'timestamptz', nullable: true })
|
|
36
|
+
usedAt: Date | null;
|
|
37
|
+
|
|
38
|
+
@Column({ name: 'user_id', type: 'uuid' })
|
|
39
|
+
userId: string;
|
|
40
|
+
|
|
41
|
+
@Column({ type: 'varchar', length: 255 })
|
|
42
|
+
token: string;
|
|
43
|
+
|
|
44
|
+
/** RELAÇÕES */
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Relação com o usuário ao qual o reset de senha está associado.
|
|
48
|
+
*/
|
|
49
|
+
@ManyToOne(() => User, (user) => user.passwordResets, { onDelete: 'CASCADE' })
|
|
50
|
+
@JoinColumn({ name: 'user_id' })
|
|
51
|
+
user: User;
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RefreshToken } from './refresh-token.entity';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
Column,
|
|
4
|
+
PrimaryGeneratedColumn,
|
|
5
|
+
CreateDateColumn,
|
|
6
|
+
ManyToOne,
|
|
7
|
+
Unique,
|
|
8
|
+
JoinColumn,
|
|
9
|
+
} from 'typeorm';
|
|
10
|
+
|
|
11
|
+
import { User } from 'app-auth/users';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Entidade que representa um refresh token.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Esta entidade armazena os dados relativos a um token de atualização utilizado para manter
|
|
18
|
+
* a sessão de um usuário ativa. Ela inclui a data de criação, expiração, e a data de revogação
|
|
19
|
+
* (caso aplicável), além de armazenar o token propriamente dito e sua associação com um usuário.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
@Entity('refresh_tokens')
|
|
24
|
+
@Unique(['token'])
|
|
25
|
+
export class RefreshToken {
|
|
26
|
+
@PrimaryGeneratedColumn('uuid')
|
|
27
|
+
id: string;
|
|
28
|
+
|
|
29
|
+
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
|
|
32
|
+
@Column({ name: 'expires_at', type: 'timestamptz' })
|
|
33
|
+
expiresAt: Date;
|
|
34
|
+
|
|
35
|
+
@Column({ name: 'revoked_at', type: 'timestamptz', nullable: true })
|
|
36
|
+
revokedAt: Date | null;
|
|
37
|
+
|
|
38
|
+
@Column({ type: 'varchar', length: 255, unique: true })
|
|
39
|
+
token: string;
|
|
40
|
+
|
|
41
|
+
@Column({ name: 'user_id', type: 'uuid' })
|
|
42
|
+
userId: string;
|
|
43
|
+
|
|
44
|
+
/** RELAÇÕES */
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Relação com o usuário ao qual o refresh token pertence.
|
|
48
|
+
*/
|
|
49
|
+
@ManyToOne(() => User, (user) => user.refreshTokens, { onDelete: 'CASCADE' })
|
|
50
|
+
@JoinColumn({ name: 'user_id' })
|
|
51
|
+
user: User;
|
|
52
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum que representa os provedores de autenticação.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Este enum fornece valores para identificar o provedor de autenticação utilizado pelo usuário.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export enum AuthProvider {
|
|
10
|
+
/**
|
|
11
|
+
* Provedor de autenticação do Google.
|
|
12
|
+
*/
|
|
13
|
+
GOOGLE = 'google',
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Provedor de autenticação do Meta.
|
|
17
|
+
*/
|
|
18
|
+
META = 'meta',
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Provedor de autenticação da Apple.
|
|
22
|
+
*/
|
|
23
|
+
APPLE = 'apple',
|
|
24
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
Column,
|
|
4
|
+
PrimaryGeneratedColumn,
|
|
5
|
+
CreateDateColumn,
|
|
6
|
+
UpdateDateColumn,
|
|
7
|
+
ManyToOne,
|
|
8
|
+
JoinColumn,
|
|
9
|
+
Unique,
|
|
10
|
+
} from 'typeorm';
|
|
11
|
+
|
|
12
|
+
import { User } from 'app-auth/users';
|
|
13
|
+
|
|
14
|
+
import { AuthProvider } from './enums/auth-provider.enum';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Entidade que representa um provedor de autenticação associado a um usuário.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Esta entidade armazena os dados relacionados aos provedores de autenticação, incluindo o token do provedor,
|
|
21
|
+
* o identificador do usuário no provedor e a associação com o usuário local.
|
|
22
|
+
* Uma combinação única de provider e providerUserId é garantida para evitar duplicatas.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
@Entity('user_auth_providers')
|
|
27
|
+
@Unique(['provider', 'providerUserId'])
|
|
28
|
+
export class UserAuthProvider {
|
|
29
|
+
@PrimaryGeneratedColumn()
|
|
30
|
+
id: number;
|
|
31
|
+
|
|
32
|
+
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
33
|
+
createdAt: Date;
|
|
34
|
+
|
|
35
|
+
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
|
|
38
|
+
@Column({ name: 'user_id', type: 'uuid' })
|
|
39
|
+
userId: string;
|
|
40
|
+
|
|
41
|
+
@Column({ type: 'enum', enum: AuthProvider })
|
|
42
|
+
provider: AuthProvider;
|
|
43
|
+
|
|
44
|
+
@Column({ name: 'provider_user_id', type: 'text' })
|
|
45
|
+
providerUserId: string;
|
|
46
|
+
|
|
47
|
+
@Column({ name: 'provider_token', type: 'text', nullable: true })
|
|
48
|
+
providerToken: string | null;
|
|
49
|
+
|
|
50
|
+
/** RELAÇÕES */
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Relação com o usuário ao qual o provedor de autenticação está associado.
|
|
54
|
+
*/
|
|
55
|
+
@ManyToOne(() => User, (user) => user.userAuthProviders, { onDelete: 'CASCADE' })
|
|
56
|
+
@JoinColumn({ name: 'user_id' })
|
|
57
|
+
user: User;
|
|
58
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum que representa os tipos de verificação.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Este enum fornece valores para indicar o tipo de verificação de usuário, seja por email ou telefone.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export enum VerificationType {
|
|
10
|
+
/**
|
|
11
|
+
* Verificação via email.
|
|
12
|
+
*/
|
|
13
|
+
EMAIL = 'email',
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Verificação via telefone.
|
|
17
|
+
*/
|
|
18
|
+
PHONE = 'phone',
|
|
19
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
Column,
|
|
4
|
+
PrimaryGeneratedColumn,
|
|
5
|
+
CreateDateColumn,
|
|
6
|
+
UpdateDateColumn,
|
|
7
|
+
ManyToOne,
|
|
8
|
+
JoinColumn,
|
|
9
|
+
} from 'typeorm';
|
|
10
|
+
|
|
11
|
+
import { User } from 'app-auth/users';
|
|
12
|
+
|
|
13
|
+
import { VerificationType } from './enums/verification-type.enum';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Entidade que representa uma verificação de usuário.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Esta entidade armazena os dados relacionados a uma verificação de usuário, incluindo
|
|
20
|
+
* as datas de criação, expiração e verificação (se aplicável), o status do token e o tipo
|
|
21
|
+
* de verificação (por exemplo, email ou telefone). Também associa a verificação ao respectivo usuário.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
@Entity('user_verifications')
|
|
26
|
+
export class UserVerification {
|
|
27
|
+
@PrimaryGeneratedColumn()
|
|
28
|
+
id: number;
|
|
29
|
+
|
|
30
|
+
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
31
|
+
createdAt: Date;
|
|
32
|
+
|
|
33
|
+
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
|
|
34
|
+
updatedAt: Date;
|
|
35
|
+
|
|
36
|
+
@Column({ name: 'expires_at', type: 'timestamptz' })
|
|
37
|
+
expiresAt: Date;
|
|
38
|
+
|
|
39
|
+
@Column({ name: 'verified_at', type: 'timestamptz', nullable: true })
|
|
40
|
+
verifiedAt: Date | null;
|
|
41
|
+
|
|
42
|
+
@Column({ type: 'boolean', default: false })
|
|
43
|
+
isInvalid: boolean;
|
|
44
|
+
|
|
45
|
+
@Column({ type: 'varchar', length: 255, unique: true })
|
|
46
|
+
token: string;
|
|
47
|
+
|
|
48
|
+
@Column({ name: 'user_id', type: 'uuid' })
|
|
49
|
+
userId: string;
|
|
50
|
+
|
|
51
|
+
@Column({ type: 'enum', enum: VerificationType })
|
|
52
|
+
type: VerificationType;
|
|
53
|
+
|
|
54
|
+
/** RELAÇÕES */
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Relação com o usuário ao qual a verificação está associada.
|
|
58
|
+
*/
|
|
59
|
+
@ManyToOne(() => User, (user) => user.verifications, { onDelete: 'CASCADE' })
|
|
60
|
+
@JoinColumn({ name: 'user_id' })
|
|
61
|
+
user: User;
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { User } from './user.entity';
|