@hed-hog/contact 0.0.266 → 0.0.274

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.
Files changed (83) hide show
  1. package/README.md +470 -0
  2. package/dist/address-type.enum.d.ts +10 -0
  3. package/dist/address-type.enum.d.ts.map +1 -0
  4. package/dist/address-type.enum.js +14 -0
  5. package/dist/address-type.enum.js.map +1 -0
  6. package/dist/contact.module.d.ts.map +1 -1
  7. package/dist/contact.module.js +0 -2
  8. package/dist/contact.module.js.map +1 -1
  9. package/dist/contact.service.d.ts +19 -22
  10. package/dist/contact.service.d.ts.map +1 -1
  11. package/dist/contact.service.js +22 -2
  12. package/dist/contact.service.js.map +1 -1
  13. package/dist/index.d.ts +5 -8
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -4
  16. package/dist/index.js.map +1 -1
  17. package/dist/person/dto/create.dto.d.ts +14 -0
  18. package/dist/person/dto/create.dto.d.ts.map +1 -1
  19. package/dist/person/dto/create.dto.js +52 -1
  20. package/dist/person/dto/create.dto.js.map +1 -1
  21. package/dist/person/dto/interaction-create.dto.d.ts +16 -0
  22. package/dist/person/dto/interaction-create.dto.d.ts.map +1 -0
  23. package/dist/person/dto/interaction-create.dto.js +57 -0
  24. package/dist/person/dto/interaction-create.dto.js.map +1 -0
  25. package/dist/person/dto/update.dto.d.ts +17 -1
  26. package/dist/person/dto/update.dto.d.ts.map +1 -1
  27. package/dist/person/dto/update.dto.js +79 -3
  28. package/dist/person/dto/update.dto.js.map +1 -1
  29. package/dist/person/person.controller.d.ts +37 -8
  30. package/dist/person/person.controller.d.ts.map +1 -1
  31. package/dist/person/person.controller.js +29 -3
  32. package/dist/person/person.controller.js.map +1 -1
  33. package/dist/person/person.service.d.ts +71 -13
  34. package/dist/person/person.service.d.ts.map +1 -1
  35. package/dist/person/person.service.js +762 -108
  36. package/dist/person/person.service.js.map +1 -1
  37. package/dist/person-relation-type/person-relation-type.controller.d.ts +13 -9
  38. package/dist/person-relation-type/person-relation-type.controller.d.ts.map +1 -1
  39. package/dist/person-relation-type/person-relation-type.service.d.ts +16 -20
  40. package/dist/person-relation-type/person-relation-type.service.d.ts.map +1 -1
  41. package/dist/person-relation-type/person-relation-type.service.js +48 -41
  42. package/dist/person-relation-type/person-relation-type.service.js.map +1 -1
  43. package/hedhog/data/menu.yaml +2 -16
  44. package/hedhog/data/role.yaml +9 -1
  45. package/hedhog/data/route.yaml +10 -21
  46. package/hedhog/data/setting_group.yaml +21 -0
  47. package/hedhog/frontend/app/person/_components/delete-person-dialog.tsx.ejs +59 -0
  48. package/hedhog/frontend/app/person/_components/person-field-with-create.tsx.ejs +831 -0
  49. package/hedhog/frontend/app/person/_components/person-form-sheet.tsx.ejs +2277 -0
  50. package/hedhog/frontend/app/person/_components/person-types.ts.ejs +157 -0
  51. package/hedhog/frontend/app/person/page.tsx.ejs +1158 -1335
  52. package/hedhog/frontend/messages/en.json +114 -4
  53. package/hedhog/frontend/messages/pt.json +155 -4
  54. package/hedhog/table/person.yaml +7 -0
  55. package/hedhog/table/person_address.yaml +18 -0
  56. package/hedhog/table/person_company.yaml +26 -11
  57. package/hedhog/table/person_individual.yaml +4 -0
  58. package/hedhog/table/person_individual_relation.yaml +39 -0
  59. package/package.json +6 -5
  60. package/src/address-type.enum.ts +9 -0
  61. package/src/contact.module.ts +46 -48
  62. package/src/contact.service.ts +28 -13
  63. package/src/index.ts +6 -13
  64. package/src/language/en.json +8 -1
  65. package/src/language/pt.json +9 -1
  66. package/src/person/dto/create.dto.ts +49 -1
  67. package/src/person/dto/update.dto.ts +75 -3
  68. package/src/person/person.controller.ts +31 -14
  69. package/src/person/person.service.ts +1019 -121
  70. package/src/person-relation-type/person-relation-type.service.ts +84 -76
  71. package/hedhog/data/address_type.yaml +0 -28
  72. package/hedhog/frontend/app/address-type/page.tsx.ejs +0 -480
  73. package/hedhog/query/add-unique-address-type-locale.sql +0 -3
  74. package/hedhog/table/address.yaml +0 -28
  75. package/hedhog/table/address_type.yaml +0 -11
  76. package/hedhog/table/person_relation.yaml +0 -20
  77. package/hedhog/table/person_relation_type.yaml +0 -6
  78. package/src/address-type/address-type.controller.ts +0 -55
  79. package/src/address-type/address-type.enum.ts +0 -9
  80. package/src/address-type/address-type.module.ts +0 -18
  81. package/src/address-type/address-type.service.ts +0 -121
  82. package/src/address-type/dto/create.dto.ts +0 -19
  83. package/src/address-type/dto/update.dto.ts +0 -9
@@ -1,28 +0,0 @@
1
- table: address
2
- columns:
3
- - type: pk
4
- - name: person_id
5
- type: fk
6
- references:
7
- table: person
8
- column: id
9
- - name: address_type_id
10
- type: fk
11
- references:
12
- table: address_type
13
- column: id
14
- - name: country_code
15
- - name: state
16
- - name: city
17
- - name: postal_code
18
- - name: line1
19
- - name: line2
20
- - name: is_primary
21
- type: boolean
22
- default: false
23
- - type: created_at
24
- - type: updated_at
25
- indexes:
26
- - columns: [person_id, address_type_id, is_primary]
27
- unique: true
28
- where: is_primary = true
@@ -1,11 +0,0 @@
1
- table: address_type
2
- columns:
3
- - type: pk
4
- - name: name
5
- type: locale_varchar
6
- locale:
7
- pt: Nome
8
- en: Name
9
- - name: code
10
- - type: created_at
11
- - type: updated_at
@@ -1,20 +0,0 @@
1
- table: person_relation
2
- columns:
3
- - type: pk
4
- - name: person_id
5
- type: fk
6
- references:
7
- table: person
8
- column: id
9
- - name: related_person_id
10
- type: fk
11
- references:
12
- table: person
13
- column: id
14
- - name: relation_type_id
15
- type: fk
16
- references:
17
- table: person_relation_type
18
- column: id
19
- - type: created_at
20
- - type: updated_at
@@ -1,6 +0,0 @@
1
- table: person_relation_type
2
- columns:
3
- - type: pk
4
- - name: code
5
- - type: created_at
6
- - type: updated_at
@@ -1,55 +0,0 @@
1
- import { DeleteDTO, Role } from '@hed-hog/api';
2
- import { Locale } from '@hed-hog/api-locale';
3
- import { Pagination } from '@hed-hog/api-pagination';
4
- import {
5
- Body,
6
- Controller,
7
- Delete,
8
- Get,
9
- Inject,
10
- Param,
11
- ParseIntPipe,
12
- Patch,
13
- Post,
14
- forwardRef
15
- } from '@nestjs/common';
16
- import { PersonAddressTypeService } from './address-type.service';
17
- import { CreateDTO } from './dto/create.dto';
18
- import { UpdateDTO } from './dto/update.dto';
19
-
20
- @Role()
21
- @Controller('person-address-type')
22
- export class PersonAddressTypeController {
23
- constructor(
24
- @Inject(forwardRef(() => PersonAddressTypeService))
25
- private readonly personAddressTypeService: PersonAddressTypeService
26
- ) {}
27
-
28
- @Get()
29
- async list(@Locale() locale, @Pagination() paginationParams) {
30
- return this.personAddressTypeService.list(locale, paginationParams);
31
- }
32
-
33
- @Get(':id')
34
- async get(@Param('id', ParseIntPipe) id: number, @Locale() locale: string) {
35
- return this.personAddressTypeService.get(id, locale);
36
- }
37
-
38
- @Post()
39
- async create(@Locale() locale: string, @Body() data: CreateDTO) {
40
- return this.personAddressTypeService.create(data, locale);
41
- }
42
-
43
- @Patch(':id')
44
- async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO, @Locale() locale: string) {
45
- return this.personAddressTypeService.update({
46
- id,
47
- data
48
- }, locale);
49
- }
50
-
51
- @Delete()
52
- async delete(@Body() data: DeleteDTO, @Locale() locale: string) {
53
- return this.personAddressTypeService.delete(data, locale);
54
- }
55
- }
@@ -1,9 +0,0 @@
1
- export enum PersonAddressTypeEnum {
2
- RESIDENTIAL = 1,
3
- COMMERCIAL = 2,
4
- CORRESPONDENCE = 3,
5
- ALTERNATIVE = 4,
6
- WORK = 5,
7
- BILLING = 6,
8
- SHIPPING = 7,
9
- }
@@ -1,18 +0,0 @@
1
- import { PaginationModule } from '@hed-hog/api-pagination';
2
- import { PrismaModule } from '@hed-hog/api-prisma';
3
- import { CoreModule } from '@hed-hog/core';
4
- import { forwardRef, Module } from '@nestjs/common';
5
- import { PersonAddressTypeController } from './address-type.controller';
6
- import { PersonAddressTypeService } from './address-type.service';
7
-
8
- @Module({
9
- imports: [
10
- forwardRef(() => CoreModule),
11
- forwardRef(() => PrismaModule),
12
- forwardRef(() => PaginationModule)
13
- ],
14
- controllers: [PersonAddressTypeController],
15
- providers: [PersonAddressTypeService],
16
- exports: [PersonAddressTypeService]
17
- })
18
- export class PersonAddressTypeModule {}
@@ -1,121 +0,0 @@
1
- import { DeleteDTO } from '@hed-hog/api';
2
- import { LocaleService, getLocaleText } from '@hed-hog/api-locale';
3
- import { PaginationDTO } from '@hed-hog/api-pagination';
4
- import { PrismaService } from '@hed-hog/api-prisma';
5
- import {
6
- BadRequestException,
7
- Inject,
8
- Injectable,
9
- NotFoundException,
10
- forwardRef
11
- } from '@nestjs/common';
12
- import { CreateDTO } from './dto/create.dto';
13
- import { UpdateDTO } from './dto/update.dto';
14
-
15
- @Injectable()
16
- export class PersonAddressTypeService {
17
- private readonly modelName = 'address_type';
18
- private readonly foreignKey = 'address_type_id';
19
-
20
- constructor(
21
- @Inject(forwardRef(() => PrismaService))
22
- private readonly prismaService: PrismaService,
23
- @Inject(forwardRef(() => LocaleService))
24
- private readonly localeService: LocaleService
25
- ) {}
26
-
27
- async list(locale: string, paginationParams: PaginationDTO) {
28
- return this.localeService.listModelWithLocale(
29
- locale,
30
- this.modelName,
31
- paginationParams
32
- );
33
- }
34
-
35
- async get(id: number, locale: string) {
36
- const addressType = await this.prismaService.address_type.findUnique({ where: { id }});
37
-
38
- if (!addressType) {
39
- throw new NotFoundException(
40
- getLocaleText('addressTypeNotFound', locale, `Address Type with ID ${id} not found`).replace('{{item}}', 'Address Type')
41
- );
42
- }
43
-
44
- return this.localeService.getModelWithLocale(this.modelName, id);
45
- }
46
-
47
- async create(data: CreateDTO, locale: string) {
48
- if (!data.locale || Object.keys(data.locale).length === 0) {
49
- throw new BadRequestException(
50
- getLocaleText('localeRequired', locale, 'At least one locale is required')
51
- );
52
- }
53
-
54
- return this.localeService.createModelWithLocale(
55
- this.modelName,
56
- this.foreignKey,
57
- data
58
- );
59
- }
60
-
61
- async update({ id, data }: { id: number; data: UpdateDTO }, locale: string) {
62
- const addressTypeExists = await this.prismaService.address_type.findUnique({
63
- where: { id }
64
- });
65
-
66
- if (!addressTypeExists) {
67
- throw new NotFoundException(
68
- getLocaleText('addressTypeNotFound', locale, `Address Type with ID ${id} not found`).replace('{{item}}', 'Address Type')
69
- );
70
- }
71
-
72
- if (data.locale && Object.keys(data.locale).length === 0) {
73
- throw new BadRequestException(
74
- getLocaleText('localeRequired', locale, 'At least one locale is required')
75
- );
76
- }
77
-
78
- return this.localeService.updateModelWithLocale(
79
- this.modelName,
80
- this.foreignKey,
81
- id,
82
- data
83
- );
84
- }
85
-
86
- async delete({ ids }: DeleteDTO, locale: string) {
87
- if (ids == undefined || ids == null) {
88
- throw new BadRequestException(
89
- getLocaleText(
90
- 'deleteItemsRequired',
91
- locale,
92
- 'You must select at least one item to delete.',
93
- ),
94
- );
95
- }
96
-
97
- const existingAddressTypes = await this.prismaService.address_type.findMany({
98
- where: {
99
- id: {
100
- in: ids,
101
- },
102
- },
103
- });
104
-
105
- if (existingAddressTypes.length !== ids.length) {
106
- const existingIds = existingAddressTypes.map((item) => item.id);
107
- const missingIds = ids.filter((id) => !existingIds.includes(id));
108
- throw new NotFoundException(
109
- getLocaleText('addressTypesNotFound', locale, `Address Types with IDs ${missingIds.join(', ')} not found`).replace('{{items}}', 'Address Types')
110
- );
111
- }
112
-
113
- return this.prismaService.address_type.deleteMany({
114
- where: {
115
- id: {
116
- in: ids
117
- }
118
- }
119
- });
120
- }
121
- }
@@ -1,19 +0,0 @@
1
- import { getLocaleText } from '@hed-hog/api-locale';
2
- import { IsNotEmpty, IsObject, IsString } from 'class-validator';
3
-
4
- export class CreateDTO {
5
- @IsString({
6
- message: (args) =>
7
- getLocaleText('validation.codeMustBeString', args.value),
8
- })
9
- code: string;
10
-
11
- @IsObject({
12
- message: (args) =>
13
- getLocaleText('validation.localeMustBeObject', args.value),
14
- })
15
- @IsNotEmpty({
16
- message: (args) => getLocaleText('validation.localeRequired', args.value),
17
- })
18
- locale: Record<string, { name: string }>;
19
- }
@@ -1,9 +0,0 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { IsObject, IsOptional } from 'class-validator';
3
- import { CreateDTO } from './create.dto';
4
-
5
- export class UpdateDTO extends PartialType(CreateDTO) {
6
- @IsOptional()
7
- @IsObject()
8
- locale?: Record<string, { name: string }>;
9
- }