@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.
- package/README.md +470 -0
- package/dist/address-type.enum.d.ts +10 -0
- package/dist/address-type.enum.d.ts.map +1 -0
- package/dist/address-type.enum.js +14 -0
- package/dist/address-type.enum.js.map +1 -0
- package/dist/contact.module.d.ts.map +1 -1
- package/dist/contact.module.js +0 -2
- package/dist/contact.module.js.map +1 -1
- package/dist/contact.service.d.ts +19 -22
- package/dist/contact.service.d.ts.map +1 -1
- package/dist/contact.service.js +22 -2
- package/dist/contact.service.js.map +1 -1
- package/dist/index.d.ts +5 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/person/dto/create.dto.d.ts +14 -0
- package/dist/person/dto/create.dto.d.ts.map +1 -1
- package/dist/person/dto/create.dto.js +52 -1
- package/dist/person/dto/create.dto.js.map +1 -1
- package/dist/person/dto/interaction-create.dto.d.ts +16 -0
- package/dist/person/dto/interaction-create.dto.d.ts.map +1 -0
- package/dist/person/dto/interaction-create.dto.js +57 -0
- package/dist/person/dto/interaction-create.dto.js.map +1 -0
- package/dist/person/dto/update.dto.d.ts +17 -1
- package/dist/person/dto/update.dto.d.ts.map +1 -1
- package/dist/person/dto/update.dto.js +79 -3
- package/dist/person/dto/update.dto.js.map +1 -1
- package/dist/person/person.controller.d.ts +37 -8
- package/dist/person/person.controller.d.ts.map +1 -1
- package/dist/person/person.controller.js +29 -3
- package/dist/person/person.controller.js.map +1 -1
- package/dist/person/person.service.d.ts +71 -13
- package/dist/person/person.service.d.ts.map +1 -1
- package/dist/person/person.service.js +762 -108
- package/dist/person/person.service.js.map +1 -1
- package/dist/person-relation-type/person-relation-type.controller.d.ts +13 -9
- package/dist/person-relation-type/person-relation-type.controller.d.ts.map +1 -1
- package/dist/person-relation-type/person-relation-type.service.d.ts +16 -20
- package/dist/person-relation-type/person-relation-type.service.d.ts.map +1 -1
- package/dist/person-relation-type/person-relation-type.service.js +48 -41
- package/dist/person-relation-type/person-relation-type.service.js.map +1 -1
- package/hedhog/data/menu.yaml +2 -16
- package/hedhog/data/role.yaml +9 -1
- package/hedhog/data/route.yaml +10 -21
- package/hedhog/data/setting_group.yaml +21 -0
- package/hedhog/frontend/app/person/_components/delete-person-dialog.tsx.ejs +59 -0
- package/hedhog/frontend/app/person/_components/person-field-with-create.tsx.ejs +831 -0
- package/hedhog/frontend/app/person/_components/person-form-sheet.tsx.ejs +2277 -0
- package/hedhog/frontend/app/person/_components/person-types.ts.ejs +157 -0
- package/hedhog/frontend/app/person/page.tsx.ejs +1158 -1335
- package/hedhog/frontend/messages/en.json +114 -4
- package/hedhog/frontend/messages/pt.json +155 -4
- package/hedhog/table/person.yaml +7 -0
- package/hedhog/table/person_address.yaml +18 -0
- package/hedhog/table/person_company.yaml +26 -11
- package/hedhog/table/person_individual.yaml +4 -0
- package/hedhog/table/person_individual_relation.yaml +39 -0
- package/package.json +6 -5
- package/src/address-type.enum.ts +9 -0
- package/src/contact.module.ts +46 -48
- package/src/contact.service.ts +28 -13
- package/src/index.ts +6 -13
- package/src/language/en.json +8 -1
- package/src/language/pt.json +9 -1
- package/src/person/dto/create.dto.ts +49 -1
- package/src/person/dto/update.dto.ts +75 -3
- package/src/person/person.controller.ts +31 -14
- package/src/person/person.service.ts +1019 -121
- package/src/person-relation-type/person-relation-type.service.ts +84 -76
- package/hedhog/data/address_type.yaml +0 -28
- package/hedhog/frontend/app/address-type/page.tsx.ejs +0 -480
- package/hedhog/query/add-unique-address-type-locale.sql +0 -3
- package/hedhog/table/address.yaml +0 -28
- package/hedhog/table/address_type.yaml +0 -11
- package/hedhog/table/person_relation.yaml +0 -20
- package/hedhog/table/person_relation_type.yaml +0 -6
- package/src/address-type/address-type.controller.ts +0 -55
- package/src/address-type/address-type.enum.ts +0 -9
- package/src/address-type/address-type.module.ts +0 -18
- package/src/address-type/address-type.service.ts +0 -121
- package/src/address-type/dto/create.dto.ts +0 -19
- 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,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,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,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
|
-
}
|