@hed-hog/contact 0.0.146 → 0.0.151

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 (41) hide show
  1. package/dist/person/person.controller.js +1 -1
  2. package/dist/person/person.controller.js.map +1 -1
  3. package/dist/person/person.module.d.ts.map +1 -1
  4. package/dist/person/person.module.js +1 -29
  5. package/dist/person/person.module.js.map +1 -1
  6. package/dist/person/person.service.d.ts +3 -3
  7. package/dist/person/person.service.d.ts.map +1 -1
  8. package/dist/person/person.service.js +21 -6
  9. package/dist/person/person.service.js.map +1 -1
  10. package/package.json +4 -4
  11. package/src/person/person.controller.ts +1 -1
  12. package/src/person/person.module.ts +1 -29
  13. package/src/person/person.service.ts +30 -6
  14. package/src/person/address/address.controller.ts +0 -67
  15. package/src/person/address/address.service.ts +0 -91
  16. package/src/person/address/dto/create.dto.ts +0 -30
  17. package/src/person/address/dto/update.dto.ts +0 -4
  18. package/src/person/contact/contact.controller.ts +0 -67
  19. package/src/person/contact/contact.service.ts +0 -83
  20. package/src/person/contact/dto/create.dto.ts +0 -14
  21. package/src/person/contact/dto/update.dto.ts +0 -4
  22. package/src/person/document/document.controller.ts +0 -67
  23. package/src/person/document/document.service.ts +0 -83
  24. package/src/person/document/dto/create.dto.ts +0 -10
  25. package/src/person/document/dto/update.dto.ts +0 -4
  26. package/src/person/person-company/dto/create.dto.ts +0 -14
  27. package/src/person/person-company/dto/update.dto.ts +0 -4
  28. package/src/person/person-company/person-company.controller.ts +0 -45
  29. package/src/person/person-company/person-company.service.ts +0 -32
  30. package/src/person/person-individual/dto/create.dto.ts +0 -20
  31. package/src/person/person-individual/dto/update.dto.ts +0 -4
  32. package/src/person/person-individual/person-individual.controller.ts +0 -45
  33. package/src/person/person-individual/person-individual.service.ts +0 -36
  34. package/src/person/person-metadata/dto/create.dto.ts +0 -9
  35. package/src/person/person-metadata/dto/update.dto.ts +0 -4
  36. package/src/person/person-metadata/person-metadata.controller.ts +0 -67
  37. package/src/person/person-metadata/person-metadata.service.ts +0 -83
  38. package/src/person/person-relation/dto/create.dto.ts +0 -10
  39. package/src/person/person-relation/dto/update.dto.ts +0 -4
  40. package/src/person/person-relation/person-relation.controller.ts +0 -67
  41. package/src/person/person-relation/person-relation.service.ts +0 -91
@@ -1,83 +0,0 @@
1
- import { DeleteDTO } from '@hed-hog/api';
2
- import { getLocaleText } from '@hed-hog/api-locale';
3
- import { PaginationDTO, PaginationService } from '@hed-hog/api-pagination';
4
- import { PrismaService } from '@hed-hog/api-prisma';
5
- import {
6
- BadRequestException,
7
- Injectable
8
- } from '@nestjs/common';
9
- import { CreateDTO } from './dto/create.dto';
10
- import { UpdateDTO } from './dto/update.dto';
11
-
12
- @Injectable()
13
- export class PersonContactService {
14
- constructor(
15
- private readonly prismaService: PrismaService,
16
- private readonly paginationService: PaginationService
17
- ) {}
18
-
19
- async create(personId: number, data: CreateDTO) {
20
- return this.prismaService.contact.create({
21
- data: {
22
- person_id: personId,
23
- ...data
24
- }
25
- });
26
- }
27
-
28
- async get(personId: number, id: number) {
29
- return this.prismaService.contact.findFirst({
30
- where: {
31
- person_id: personId,
32
- id: id
33
- }
34
- });
35
- }
36
-
37
- async list(paginationParams: PaginationDTO, personId?: number) {
38
- const where: any = {};
39
- if (personId !== undefined) where.person_id = personId;
40
-
41
- return this.paginationService.paginate(
42
- this.prismaService.contact,
43
- {
44
- fields: 'is_primary,value',
45
- ...paginationParams
46
- },
47
- {
48
- where
49
- }
50
- );
51
- }
52
-
53
- async update(personId: number, id: number, data: UpdateDTO) {
54
- return this.prismaService.contact.updateMany({
55
- where: {
56
- person_id: personId,
57
- id: id
58
- },
59
- data
60
- });
61
- }
62
-
63
- async delete(personId: number, { ids }: DeleteDTO, locale: string = 'en') {
64
- if (ids == undefined || ids == null) {
65
- throw new BadRequestException(
66
- getLocaleText(
67
- 'deleteItemsRequired',
68
- locale,
69
- 'You must select at least one item to delete.',
70
- ),
71
- );
72
- }
73
-
74
- return this.prismaService.contact.deleteMany({
75
- where: {
76
- person_id: personId,
77
- id: {
78
- in: ids
79
- }
80
- }
81
- });
82
- }
83
- }
@@ -1,14 +0,0 @@
1
- import { getLocaleText } from '@hed-hog/api-locale';
2
- import { IsBoolean, IsNumber, IsOptional, IsString } from 'class-validator';
3
-
4
- export class CreateDTO {
5
- @IsNumber({}, { message: (args) => getLocaleText('validation.numberRequired', args.value) })
6
- contact_type_id: number;
7
-
8
- @IsOptional()
9
- @IsBoolean({ message: (args) => getLocaleText('validation.booleanRequired', args.value) })
10
- is_primary?: boolean;
11
-
12
- @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
13
- value: string;
14
- }
@@ -1,4 +0,0 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -1,67 +0,0 @@
1
- import { DeleteDTO, Role } from '@hed-hog/api';
2
- import { Pagination } from '@hed-hog/api-pagination';
3
- import {
4
- Body,
5
- Controller,
6
- Delete,
7
- Get,
8
- Inject,
9
- Param,
10
- ParseIntPipe,
11
- Patch,
12
- Post,
13
- forwardRef
14
- } from '@nestjs/common';
15
- import { PersonDocumentService } from './document.service';
16
- import { CreateDTO } from './dto/create.dto';
17
- import { UpdateDTO } from './dto/update.dto';
18
-
19
- @Role()
20
- @Controller('person/:personId/person-document')
21
- export class PersonDocumentController {
22
- constructor(
23
- @Inject(forwardRef(() => PersonDocumentService))
24
- private readonly personDocumentService: PersonDocumentService
25
- ) {}
26
-
27
- @Post()
28
- create(
29
- @Param('personId', ParseIntPipe) personId: number,
30
- @Body() data: CreateDTO
31
- ) {
32
- return this.personDocumentService.create(personId, data);
33
- }
34
-
35
- @Get()
36
- list(
37
- @Param('personId', ParseIntPipe) personId: number,
38
- @Pagination() paginationParams
39
- ) {
40
- return this.personDocumentService.list(paginationParams, personId);
41
- }
42
-
43
- @Get(':id')
44
- get(
45
- @Param('personId', ParseIntPipe) personId: number,
46
- @Param('id', ParseIntPipe) id: number
47
- ) {
48
- return this.personDocumentService.get(personId, id);
49
- }
50
-
51
- @Patch(':id')
52
- update(
53
- @Param('personId', ParseIntPipe) personId: number,
54
- @Param('id', ParseIntPipe) id: number,
55
- @Body() data: UpdateDTO
56
- ) {
57
- return this.personDocumentService.update(personId, id, data);
58
- }
59
-
60
- @Delete()
61
- delete(
62
- @Param('personId', ParseIntPipe) personId: number,
63
- @Body() { ids }: DeleteDTO
64
- ) {
65
- return this.personDocumentService.delete(personId, { ids });
66
- }
67
- }
@@ -1,83 +0,0 @@
1
- import { DeleteDTO } from '@hed-hog/api';
2
- import { getLocaleText } from '@hed-hog/api-locale';
3
- import { PaginationDTO, PaginationService } from '@hed-hog/api-pagination';
4
- import { PrismaService } from '@hed-hog/api-prisma';
5
- import {
6
- BadRequestException,
7
- Injectable
8
- } from '@nestjs/common';
9
- import { CreateDTO } from './dto/create.dto';
10
- import { UpdateDTO } from './dto/update.dto';
11
-
12
- @Injectable()
13
- export class PersonDocumentService {
14
- constructor(
15
- private readonly prismaService: PrismaService,
16
- private readonly paginationService: PaginationService
17
- ) {}
18
-
19
- async create(personId: number, data: CreateDTO) {
20
- return this.prismaService.document.create({
21
- data: {
22
- person_id: personId,
23
- ...data
24
- }
25
- });
26
- }
27
-
28
- async get(personId: number, id: number) {
29
- return this.prismaService.document.findFirst({
30
- where: {
31
- person_id: personId,
32
- id: id
33
- }
34
- });
35
- }
36
-
37
- async list(paginationParams: PaginationDTO, personId?: number) {
38
- const where: any = {};
39
- if (personId !== undefined) where.person_id = personId;
40
-
41
- return this.paginationService.paginate(
42
- this.prismaService.document,
43
- {
44
- fields: 'value',
45
- ...paginationParams
46
- },
47
- {
48
- where
49
- }
50
- );
51
- }
52
-
53
- async update(personId: number, id: number, data: UpdateDTO) {
54
- return this.prismaService.document.updateMany({
55
- where: {
56
- person_id: personId,
57
- id: id
58
- },
59
- data
60
- });
61
- }
62
-
63
- async delete(personId: number, { ids }: DeleteDTO, locale: string = 'en') {
64
- if (ids == undefined || ids == null) {
65
- throw new BadRequestException(
66
- getLocaleText(
67
- 'deleteItemsRequired',
68
- locale,
69
- 'You must select at least one item to delete.',
70
- ),
71
- );
72
- }
73
-
74
- return this.prismaService.document.deleteMany({
75
- where: {
76
- person_id: personId,
77
- id: {
78
- in: ids
79
- }
80
- }
81
- });
82
- }
83
- }
@@ -1,10 +0,0 @@
1
- import { getLocaleText } from '@hed-hog/api-locale';
2
- import { IsNumber, IsString } from 'class-validator';
3
-
4
- export class CreateDTO {
5
- @IsNumber({}, { message: (args) => getLocaleText('validation.numberRequired', args.value) })
6
- document_type_id: number;
7
-
8
- @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
9
- value: string;
10
- }
@@ -1,4 +0,0 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -1,14 +0,0 @@
1
- import { getLocaleText } from '@hed-hog/api-locale';
2
- import { Type } from 'class-transformer';
3
- import { IsDate, IsNotEmpty, IsString } from 'class-validator';
4
-
5
- export class CreateDTO {
6
- @IsNotEmpty({ message: (args) => getLocaleText('validation.fieldRequired', args.value) })
7
- @IsDate({ message: (args) => getLocaleText('validation.dateInvalid', args.value) })
8
- @Type(() => Date)
9
- foundation_date: Date;
10
-
11
- @IsNotEmpty({ message: (args) => getLocaleText('validation.fieldRequired', args.value) })
12
- @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
13
- legal_nature: string;
14
- }
@@ -1,4 +0,0 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -1,45 +0,0 @@
1
- import { Role } from '@hed-hog/api';
2
- import {
3
- Body,
4
- Controller,
5
- Get,
6
- Inject,
7
- Param,
8
- ParseIntPipe,
9
- Patch,
10
- Post,
11
- forwardRef
12
- } from '@nestjs/common';
13
- import { CreateDTO } from './dto/create.dto';
14
- import { UpdateDTO } from './dto/update.dto';
15
- import { PersonCompanyService } from './person-company.service';
16
-
17
- @Role()
18
- @Controller('person/:personId/person-company')
19
- export class PersonCompanyController {
20
- constructor(
21
- @Inject(forwardRef(() => PersonCompanyService))
22
- private readonly personCompanyService: PersonCompanyService
23
- ) {}
24
-
25
- @Post()
26
- create(
27
- @Param('personId', ParseIntPipe) personId: number,
28
- @Body() data: CreateDTO
29
- ) {
30
- return this.personCompanyService.create(data);
31
- }
32
-
33
- @Get()
34
- get(@Param('personId', ParseIntPipe) personId: number) {
35
- return this.personCompanyService.get(personId);
36
- }
37
-
38
- @Patch()
39
- update(
40
- @Param('personId', ParseIntPipe) personId: number,
41
- @Body() data: UpdateDTO
42
- ) {
43
- return this.personCompanyService.update(personId, data);
44
- }
45
- }
@@ -1,32 +0,0 @@
1
- import { PrismaService } from '@hed-hog/api-prisma';
2
- import { Injectable } from '@nestjs/common';
3
- import { CreateDTO } from './dto/create.dto';
4
- import { UpdateDTO } from './dto/update.dto';
5
-
6
- @Injectable()
7
- export class PersonCompanyService {
8
- constructor(private readonly prismaService: PrismaService) {}
9
-
10
- async create(data: CreateDTO) {
11
- return this.prismaService.person_company.create({
12
- data
13
- });
14
- }
15
-
16
- async get(personId: number) {
17
- return this.prismaService.person_company.findUnique({
18
- where: {
19
- id: personId
20
- }
21
- });
22
- }
23
-
24
- async update(personId: number, data: UpdateDTO) {
25
- return this.prismaService.person_company.update({
26
- where: {
27
- id: personId
28
- },
29
- data
30
- });
31
- }
32
- }
@@ -1,20 +0,0 @@
1
- import { getLocaleText } from '@hed-hog/api-locale';
2
- import { Type } from 'class-transformer';
3
- import { IsDate, IsEnum, IsOptional } from 'class-validator';
4
-
5
- export enum Gender {
6
- MALE = 'male',
7
- FEMALE = 'female',
8
- OTHER = 'other'
9
- }
10
-
11
- export class CreateDTO {
12
- @IsOptional()
13
- @IsDate({ message: (args) => getLocaleText('validation.dateInvalid', args.value) })
14
- @Type(() => Date)
15
- birth_date?: Date;
16
-
17
- @IsOptional()
18
- @IsEnum(Gender, { message: (args) => getLocaleText('validation.genderInvalid', args.value) })
19
- gender?: Gender;
20
- }
@@ -1,4 +0,0 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -1,45 +0,0 @@
1
- import { Role } from '@hed-hog/api';
2
- import {
3
- Body,
4
- Controller,
5
- Get,
6
- Inject,
7
- Param,
8
- ParseIntPipe,
9
- Patch,
10
- Post,
11
- forwardRef
12
- } from '@nestjs/common';
13
- import { CreateDTO } from './dto/create.dto';
14
- import { UpdateDTO } from './dto/update.dto';
15
- import { PersonIndividualService } from './person-individual.service';
16
-
17
- @Role()
18
- @Controller('person/:personId/person-individual')
19
- export class PersonIndividualController {
20
- constructor(
21
- @Inject(forwardRef(() => PersonIndividualService))
22
- private readonly personIndividualService: PersonIndividualService
23
- ) {}
24
-
25
- @Post()
26
- create(
27
- @Param('personId', ParseIntPipe) personId: number,
28
- @Body() data: CreateDTO
29
- ) {
30
- return this.personIndividualService.create(personId, data);
31
- }
32
-
33
- @Get()
34
- get(@Param('personId', ParseIntPipe) personId: number) {
35
- return this.personIndividualService.get(personId);
36
- }
37
-
38
- @Patch()
39
- update(
40
- @Param('personId', ParseIntPipe) personId: number,
41
- @Body() data: UpdateDTO
42
- ) {
43
- return this.personIndividualService.update(personId, data);
44
- }
45
- }
@@ -1,36 +0,0 @@
1
- import { PrismaService } from '@hed-hog/api-prisma';
2
- import { Injectable } from '@nestjs/common';
3
- import { CreateDTO } from './dto/create.dto';
4
- import { UpdateDTO } from './dto/update.dto';
5
-
6
- @Injectable()
7
- export class PersonIndividualService {
8
- constructor(private readonly prismaService: PrismaService) {}
9
-
10
- async create(personId: number, {birth_date, gender}: CreateDTO) {
11
- // TODO: Once person_individual.id has a FK constraint to person.id,
12
- // update this to use proper Prisma relations
13
- return this.prismaService.$queryRaw`
14
- INSERT INTO person_individual (id, birth_date, gender)
15
- VALUES (${personId}, ${birth_date}, ${gender}::person_individual_gender_enum)
16
- RETURNING *
17
- ` as Promise<any>;
18
- }
19
-
20
- async get(personId: number) {
21
- return this.prismaService.person_individual.findUnique({
22
- where: {
23
- id: personId
24
- }
25
- });
26
- }
27
-
28
- async update(personId: number, data: UpdateDTO) {
29
- return this.prismaService.person_individual.update({
30
- where: {
31
- id: personId
32
- },
33
- data
34
- });
35
- }
36
- }
@@ -1,9 +0,0 @@
1
- import { getLocaleText } from '@hed-hog/api-locale';
2
- import { IsString } from 'class-validator';
3
-
4
- export class CreateDTO {
5
- @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
6
- key: string;
7
-
8
- value: any;
9
- }
@@ -1,4 +0,0 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -1,67 +0,0 @@
1
- import { DeleteDTO, Role } from '@hed-hog/api';
2
- import { Pagination } from '@hed-hog/api-pagination';
3
- import {
4
- Body,
5
- Controller,
6
- Delete,
7
- Get,
8
- Inject,
9
- Param,
10
- ParseIntPipe,
11
- Patch,
12
- Post,
13
- forwardRef
14
- } from '@nestjs/common';
15
- import { CreateDTO } from './dto/create.dto';
16
- import { UpdateDTO } from './dto/update.dto';
17
- import { PersonMetadataService } from './person-metadata.service';
18
-
19
- @Role()
20
- @Controller('person/:personId/person-metadata')
21
- export class PersonMetadataController {
22
- constructor(
23
- @Inject(forwardRef(() => PersonMetadataService))
24
- private readonly personMetadataService: PersonMetadataService
25
- ) {}
26
-
27
- @Post()
28
- create(
29
- @Param('personId', ParseIntPipe) personId: number,
30
- @Body() data: CreateDTO
31
- ) {
32
- return this.personMetadataService.create(personId, data);
33
- }
34
-
35
- @Get()
36
- list(
37
- @Param('personId', ParseIntPipe) personId: number,
38
- @Pagination() paginationParams
39
- ) {
40
- return this.personMetadataService.list(paginationParams, personId);
41
- }
42
-
43
- @Get(':id')
44
- get(
45
- @Param('personId', ParseIntPipe) personId: number,
46
- @Param('id', ParseIntPipe) id: number
47
- ) {
48
- return this.personMetadataService.get(personId, id);
49
- }
50
-
51
- @Patch(':id')
52
- update(
53
- @Param('personId', ParseIntPipe) personId: number,
54
- @Param('id', ParseIntPipe) id: number,
55
- @Body() data: UpdateDTO
56
- ) {
57
- return this.personMetadataService.update(personId, id, data);
58
- }
59
-
60
- @Delete()
61
- delete(
62
- @Param('personId', ParseIntPipe) personId: number,
63
- @Body() { ids }: DeleteDTO
64
- ) {
65
- return this.personMetadataService.delete(personId, { ids });
66
- }
67
- }
@@ -1,83 +0,0 @@
1
- import { DeleteDTO } from '@hed-hog/api';
2
- import { getLocaleText } from '@hed-hog/api-locale';
3
- import { PaginationDTO, PaginationService } from '@hed-hog/api-pagination';
4
- import { PrismaService } from '@hed-hog/api-prisma';
5
- import {
6
- BadRequestException,
7
- Injectable
8
- } from '@nestjs/common';
9
- import { CreateDTO } from './dto/create.dto';
10
- import { UpdateDTO } from './dto/update.dto';
11
-
12
- @Injectable()
13
- export class PersonMetadataService {
14
- constructor(
15
- private readonly prismaService: PrismaService,
16
- private readonly paginationService: PaginationService
17
- ) {}
18
-
19
- async create(personId: number, data: CreateDTO) {
20
- return this.prismaService.person_metadata.create({
21
- data: {
22
- person_id: personId,
23
- ...data
24
- }
25
- });
26
- }
27
-
28
- async get(personId: number, id: number) {
29
- return this.prismaService.person_metadata.findFirst({
30
- where: {
31
- person_id: personId,
32
- id: id
33
- }
34
- });
35
- }
36
-
37
- async list(paginationParams: PaginationDTO, personId?: number) {
38
- const where: any = {};
39
- if (personId !== undefined) where.person_id = personId;
40
-
41
- return this.paginationService.paginate(
42
- this.prismaService.person_metadata,
43
- {
44
- fields: 'key,value',
45
- ...paginationParams
46
- },
47
- {
48
- where
49
- }
50
- );
51
- }
52
-
53
- async update(personId: number, id: number, data: UpdateDTO) {
54
- return this.prismaService.person_metadata.updateMany({
55
- where: {
56
- person_id: personId,
57
- id: id
58
- },
59
- data
60
- });
61
- }
62
-
63
- async delete(personId: number, { ids }: DeleteDTO, locale: string = 'en') {
64
- if (ids == undefined || ids == null) {
65
- throw new BadRequestException(
66
- getLocaleText(
67
- 'deleteItemsRequired',
68
- locale,
69
- 'You must select at least one item to delete.',
70
- ),
71
- );
72
- }
73
-
74
- return this.prismaService.person_metadata.deleteMany({
75
- where: {
76
- person_id: personId,
77
- id: {
78
- in: ids
79
- }
80
- }
81
- });
82
- }
83
- }
@@ -1,10 +0,0 @@
1
- import { getLocaleText } from '@hed-hog/api-locale';
2
- import { IsNumber } from 'class-validator';
3
-
4
- export class CreateDTO {
5
- @IsNumber({}, { message: (args) => getLocaleText('validation.numberRequired', args.value) })
6
- related_person_id: number;
7
-
8
- @IsNumber({}, { message: (args) => getLocaleText('validation.numberRequired', args.value) })
9
- relation_type_id: number;
10
- }
@@ -1,4 +0,0 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}