@hed-hog/contact 0.0.303 → 0.0.305
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 +225 -17
- package/dist/person/dto/account.dto.d.ts +5 -0
- package/dist/person/dto/account.dto.d.ts.map +1 -1
- package/dist/person/dto/account.dto.js +29 -0
- package/dist/person/dto/account.dto.js.map +1 -1
- package/dist/person/dto/import-preview.dto.d.ts +7 -0
- package/dist/person/dto/import-preview.dto.d.ts.map +1 -0
- package/dist/person/dto/import-preview.dto.js +7 -0
- package/dist/person/dto/import-preview.dto.js.map +1 -0
- package/dist/person/dto/import.dto.d.ts +15 -0
- package/dist/person/dto/import.dto.d.ts.map +1 -0
- package/dist/person/dto/import.dto.js +51 -0
- package/dist/person/dto/import.dto.js.map +1 -0
- package/dist/person/person.controller.d.ts +14 -0
- package/dist/person/person.controller.d.ts.map +1 -1
- package/dist/person/person.controller.js +53 -0
- package/dist/person/person.controller.js.map +1 -1
- package/dist/person/person.service.d.ts +19 -0
- package/dist/person/person.service.d.ts.map +1 -1
- package/dist/person/person.service.js +481 -67
- package/dist/person/person.service.js.map +1 -1
- package/dist/person-relation-type/person-relation-type.controller.d.ts +2 -2
- package/dist/person-relation-type/person-relation-type.service.d.ts +2 -2
- package/hedhog/data/route.yaml +6 -0
- package/hedhog/frontend/app/accounts/_components/account-form-sheet.tsx.ejs +2242 -484
- package/hedhog/frontend/app/accounts/_components/account-types.ts.ejs +51 -0
- package/hedhog/frontend/app/accounts/page.tsx.ejs +181 -16
- package/hedhog/frontend/app/contact-type/page.tsx.ejs +223 -29
- package/hedhog/frontend/app/document-type/page.tsx.ejs +248 -37
- package/hedhog/frontend/app/follow-ups/page.tsx.ejs +129 -19
- package/hedhog/frontend/app/person/_components/person-field-with-create.tsx.ejs +78 -212
- package/hedhog/frontend/app/person/_components/person-form-sheet.tsx.ejs +760 -178
- package/hedhog/frontend/app/person/_components/person-import-sheet.tsx.ejs +1120 -0
- package/hedhog/frontend/app/person/_components/person-interaction-dialog.tsx.ejs +171 -4
- package/hedhog/frontend/app/person/page.tsx.ejs +17 -0
- package/hedhog/frontend/app/pipeline/_components/lead-proposals-tab.tsx.ejs +696 -82
- package/hedhog/frontend/messages/en.json +140 -2
- package/hedhog/frontend/messages/pt.json +147 -9
- package/package.json +5 -5
- package/src/person/dto/account.dto.ts +31 -0
- package/src/person/dto/import-preview.dto.ts +6 -0
- package/src/person/dto/import.dto.ts +61 -0
- package/src/person/person.controller.ts +74 -12
- package/src/person/person.service.ts +615 -68
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
```markdown
|
|
2
1
|
# @hed-hog/contact
|
|
3
2
|
|
|
4
3
|
## 1. Visão geral do módulo
|
|
@@ -80,33 +79,76 @@ O módulo `@hed-hog/contact` gerencia informações relacionadas a contatos, doc
|
|
|
80
79
|
|--------|------------------------|-------------------------------------|----------------------------------|
|
|
81
80
|
| GET | `/person` | Autenticado (roles: admin, admin-contact) | Lista pessoas com filtros e paginação. |
|
|
82
81
|
| GET | `/person/stats` | Autenticado (roles: admin, admin-contact) | Estatísticas de pessoas. |
|
|
82
|
+
| GET | `/person/dashboard` | Autenticado (roles: admin, admin-contact) | Dashboard de pessoas com filtros. |
|
|
83
|
+
| GET | `/person/reports` | Autenticado (roles: admin, admin-contact) | Relatórios de pessoas por período. |
|
|
83
84
|
| GET | `/person/owner-options`| Autenticado (roles: admin, admin-contact) | Lista usuários possíveis para atribuição como responsáveis. |
|
|
84
|
-
| GET | `/person
|
|
85
|
+
| GET | `/person/duplicates` | Autenticado (roles: admin, admin-contact) | Verifica duplicatas de pessoa por email, telefone ou documento. |
|
|
86
|
+
| GET | `/person/accounts` | Autenticado (roles: admin, admin-contact) | Lista contas (empresas) com filtros e paginação. |
|
|
87
|
+
| GET | `/person/accounts/stats` | Autenticado (roles: admin, admin-contact) | Estatísticas de contas. |
|
|
88
|
+
| POST | `/person/accounts` | Autenticado (roles: admin, admin-contact) | Cria uma nova conta (empresa). |
|
|
89
|
+
| PATCH | `/person/accounts/:id` | Autenticado (roles: admin, admin-contact) | Atualiza uma conta existente. |
|
|
90
|
+
| DELETE | `/person/accounts` | Autenticado (roles: admin, admin-contact) | Exclui contas por IDs. |
|
|
91
|
+
| GET | `/person/followups` | Autenticado (roles: admin, admin-contact) | Lista followups com filtros e paginação. |
|
|
92
|
+
| GET | `/person/followups/stats` | Autenticado (roles: admin, admin-contact) | Estatísticas de followups. |
|
|
93
|
+
| GET | `/person/activities` | Autenticado (roles: admin, admin-contact) | Lista atividades com filtros e paginação. |
|
|
94
|
+
| GET | `/person/activities/stats` | Autenticado (roles: admin, admin-contact) | Estatísticas de atividades. |
|
|
95
|
+
| GET | `/person/activities/:id` | Autenticado (roles: admin, admin-contact) | Obtém atividade por ID. |
|
|
96
|
+
| POST | `/person/activities/:id/complete` | Autenticado (roles: admin, admin-contact) | Marca atividade como concluída. |
|
|
85
97
|
| GET | `/person/avatar/:id` | Pública | Abre avatar público pelo ID do arquivo. |
|
|
98
|
+
| GET | `/person/:id` | Autenticado (roles: admin, admin-contact) | Obtém pessoa por ID com detalhes. |
|
|
86
99
|
| POST | `/person` | Autenticado (roles: admin, admin-contact) | Cria uma nova pessoa. |
|
|
87
100
|
| PATCH | `/person/:id` | Autenticado (roles: admin, admin-contact) | Atualiza pessoa existente. |
|
|
88
101
|
| DELETE | `/person` | Autenticado (roles: admin, admin-contact) | Exclui pessoas por IDs. |
|
|
102
|
+
| POST | `/person/merge` | Autenticado (roles: admin, admin-contact) | Mescla duas pessoas (estratégia 'contact_only'). |
|
|
103
|
+
| GET | `/person/:id/interaction` | Autenticado (roles: admin, admin-contact) | Lista interações da pessoa. |
|
|
104
|
+
| POST | `/person/:id/interaction` | Autenticado (roles: admin, admin-contact) | Cria interação para pessoa. |
|
|
105
|
+
| POST | `/person/:id/followup` | Autenticado (roles: admin, admin-contact) | Agenda followup para pessoa. |
|
|
106
|
+
| POST | `/person/:id/lifecycle-stage` | Autenticado (roles: admin, admin-contact) | Atualiza estágio do ciclo de vida da pessoa. |
|
|
107
|
+
| POST | `/person/import/preview` | Autenticado (roles: admin, admin-contact) | Pré-visualiza importação CSV de pessoas. |
|
|
108
|
+
| POST | `/person/import` | Autenticado (roles: admin, admin-contact) | Importa pessoas via CSV com mapeamento. |
|
|
89
109
|
|
|
90
110
|
**Parâmetros e corpo:**
|
|
91
111
|
|
|
92
|
-
- `CreateDTO` para criação:
|
|
112
|
+
- `CreateDTO` para criação de pessoa:
|
|
93
113
|
- `name` (string): nome da pessoa.
|
|
94
114
|
- `type` (enum: individual, company): tipo da pessoa.
|
|
95
115
|
- `status` (enum: active, inactive): status da pessoa.
|
|
96
|
-
- Campos opcionais: `avatar_id`, `birth_date`, `gender`, `job_title`, `trade_name`, `foundation_date`, `legal_nature`, `notes`, `employer_company_id`.
|
|
116
|
+
- Campos opcionais: `avatar_id`, `birth_date`, `gender`, `job_title`, `trade_name`, `foundation_date`, `legal_nature`, `notes`, `employer_company_id`, `owner_user_id`, `source`, `lifecycle_stage`, `next_action_at`, `score`, `deal_value`, `tags`.
|
|
97
117
|
|
|
98
118
|
- `UpdateAllPersonDTO` para atualização:
|
|
99
119
|
- Inclui todos os campos do `CreateDTO`.
|
|
100
120
|
- Arrays para `contacts`, `addresses`, `documents` com seus respectivos campos e validações.
|
|
121
|
+
- Campos opcionais `branch_ids` (array de números) e `headquarter_id` (número opcional para empresa).
|
|
101
122
|
- Validação para garantir apenas um contato, endereço ou documento primário por tipo.
|
|
102
|
-
|
|
123
|
+
|
|
124
|
+
- `MergePersonDTO` para mesclagem:
|
|
125
|
+
- `source_person_id` (number): ID da pessoa origem.
|
|
126
|
+
- `target_person_id` (number): ID da pessoa destino.
|
|
127
|
+
- `strategy`: atualmente suportado apenas `'contact_only'`.
|
|
128
|
+
|
|
129
|
+
- `CreateInteractionDTO` para criação de interação:
|
|
130
|
+
- `type` (enum: call, email, whatsapp, meeting, note).
|
|
131
|
+
- `notes` (string, opcional).
|
|
132
|
+
|
|
133
|
+
- `CreateFollowupDTO` para criação de followup:
|
|
134
|
+
- `next_action_at` (string, data ISO).
|
|
135
|
+
- `notes` (string, opcional).
|
|
136
|
+
|
|
137
|
+
- `UpdateLifecycleStageDTO` para atualização do estágio do ciclo de vida:
|
|
138
|
+
- `lifecycle_stage` (enum: new, contacted, qualified, proposal, negotiation, customer, lost).
|
|
139
|
+
|
|
140
|
+
- Importação CSV:
|
|
141
|
+
- Arquivo CSV enviado via multipart/form-data.
|
|
142
|
+
- `mapping` (string JSON): mapeamento de colunas para campos.
|
|
143
|
+
- `company_id` (string numérico opcional): ID da empresa para associação.
|
|
103
144
|
|
|
104
145
|
**Resposta:**
|
|
105
146
|
|
|
106
|
-
- Listagem paginada, objeto da pessoa criada/atualizada, ou
|
|
147
|
+
- Listagem paginada, objeto da pessoa criada/atualizada, estatísticas, dashboards ou relatórios conforme endpoint.
|
|
148
|
+
- Pré-visualização e resultado da importação CSV.
|
|
107
149
|
- Erros:
|
|
108
|
-
- 400 Bad Request: dados inválidos, mais de um primário por tipo, referência inválida, registro de empresa desabilitado, IDs para exclusão não informados.
|
|
109
|
-
- 404 Not Found: pessoa
|
|
150
|
+
- 400 Bad Request: dados inválidos, mais de um primário por tipo, referência inválida, registro de empresa desabilitado, IDs para exclusão não informados, tentativa de criar/atualizar tipos de relação.
|
|
151
|
+
- 404 Not Found: pessoa, avatar, atividade ou entidade relacionada não encontrada.
|
|
110
152
|
|
|
111
153
|
---
|
|
112
154
|
|
|
@@ -186,7 +228,14 @@ Campos parciais de CreateDTO, `locale` opcional.
|
|
|
186
228
|
"foundation_date": "string (date) | null",
|
|
187
229
|
"legal_nature": "string | null",
|
|
188
230
|
"notes": "string | null",
|
|
189
|
-
"employer_company_id": "number | null"
|
|
231
|
+
"employer_company_id": "number | null",
|
|
232
|
+
"owner_user_id": "number | null",
|
|
233
|
+
"source": "referral | website | social | inbound | outbound | other | null",
|
|
234
|
+
"lifecycle_stage": "new | contacted | qualified | proposal | negotiation | customer | lost | null",
|
|
235
|
+
"next_action_at": "string (date) | null",
|
|
236
|
+
"score": "number | null",
|
|
237
|
+
"deal_value": "number | null",
|
|
238
|
+
"tags": ["string", "..."] | null
|
|
190
239
|
}
|
|
191
240
|
```
|
|
192
241
|
|
|
@@ -194,11 +243,80 @@ Campos parciais de CreateDTO, `locale` opcional.
|
|
|
194
243
|
|
|
195
244
|
Inclui todos os campos do CreateDTO e:
|
|
196
245
|
|
|
197
|
-
- `contacts`: array de objetos com
|
|
198
|
-
- `
|
|
199
|
-
- `
|
|
200
|
-
- `
|
|
201
|
-
- `
|
|
246
|
+
- `contacts`: array de objetos com:
|
|
247
|
+
- `id?` (number)
|
|
248
|
+
- `value` (string)
|
|
249
|
+
- `is_primary` (boolean)
|
|
250
|
+
- `contact_type_id` (number)
|
|
251
|
+
- `addresses`: array de objetos com:
|
|
252
|
+
- `id?` (number)
|
|
253
|
+
- `line1` (string)
|
|
254
|
+
- `line2?` (string)
|
|
255
|
+
- `city` (string)
|
|
256
|
+
- `state` (string)
|
|
257
|
+
- `country_code?` (string)
|
|
258
|
+
- `postal_code?` (string)
|
|
259
|
+
- `is_primary` (boolean)
|
|
260
|
+
- `address_type` (enum: residencial, comercial, etc. conforme AddressTypeEnum)
|
|
261
|
+
- `documents`: array de objetos com:
|
|
262
|
+
- `id?` (number)
|
|
263
|
+
- `value` (string)
|
|
264
|
+
- `document_type_id` (number)
|
|
265
|
+
- `branch_ids?`: array de números (IDs de filiais)
|
|
266
|
+
- `headquarter_id?`: número opcional (ID da matriz)
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
### MergePersonDTO
|
|
271
|
+
|
|
272
|
+
```json
|
|
273
|
+
{
|
|
274
|
+
"source_person_id": 1,
|
|
275
|
+
"target_person_id": 2,
|
|
276
|
+
"strategy": "contact_only"
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
### CreateInteractionDTO
|
|
283
|
+
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"type": "call | email | whatsapp | meeting | note",
|
|
287
|
+
"notes": "string | null"
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
### CreateFollowupDTO
|
|
294
|
+
|
|
295
|
+
```json
|
|
296
|
+
{
|
|
297
|
+
"next_action_at": "string (date ISO)",
|
|
298
|
+
"notes": "string | null"
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
### UpdateLifecycleStageDTO
|
|
305
|
+
|
|
306
|
+
```json
|
|
307
|
+
{
|
|
308
|
+
"lifecycle_stage": "new | contacted | qualified | proposal | negotiation | customer | lost"
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
### Import CSV (Person)
|
|
315
|
+
|
|
316
|
+
- Arquivo CSV enviado via multipart/form-data.
|
|
317
|
+
- Campos no corpo:
|
|
318
|
+
- `mapping` (string JSON): mapeamento de colunas para campos.
|
|
319
|
+
- `company_id` (string numérico opcional): ID da empresa para associação.
|
|
202
320
|
|
|
203
321
|
---
|
|
204
322
|
|
|
@@ -211,11 +329,11 @@ Inclui todos os campos do CreateDTO e:
|
|
|
211
329
|
- Tentativa de registrar empresa quando registro está desabilitado.
|
|
212
330
|
- Referência inválida para empresa ou endereço.
|
|
213
331
|
- IDs para exclusão não informados.
|
|
332
|
+
- Arquivo CSV ausente ou mapeamento JSON inválido na importação.
|
|
214
333
|
|
|
215
334
|
- **404 Not Found**
|
|
216
|
-
- Entidade não encontrada por ID (pessoa, tipo de contato, tipo de documento).
|
|
335
|
+
- Entidade não encontrada por ID (pessoa, tipo de contato, tipo de documento, avatar, atividade).
|
|
217
336
|
- Pessoa do tipo empresa não encontrada quando registro está desabilitado.
|
|
218
|
-
- Avatar não encontrado.
|
|
219
337
|
|
|
220
338
|
## 7. Banco de dados (tabelas YAML)
|
|
221
339
|
|
|
@@ -365,6 +483,10 @@ Inclui todos os campos do CreateDTO e:
|
|
|
365
483
|
- Validações específicas impedem inconsistências nas relações de empresas e indivíduos.
|
|
366
484
|
- Atualização de pessoa sincroniza contatos, endereços e documentos, criando, atualizando ou removendo conforme necessário.
|
|
367
485
|
- Pesquisa de pessoas suporta filtros por nome, tipo, status, e busca por dados normalizados em contatos, documentos e endereços.
|
|
486
|
+
- Mesclagem de pessoas suporta estratégia `contact_only` para unir contatos sem duplicar pessoas.
|
|
487
|
+
- Atividades e followups são gerenciados com tipos, status e prioridades específicas.
|
|
488
|
+
- Estágios do ciclo de vida da pessoa são atualizáveis via API.
|
|
489
|
+
- Importação CSV permite mapear colunas para campos do modelo, associando opcionalmente a uma empresa.
|
|
368
490
|
|
|
369
491
|
## 9. Guia rápido de uso (exemplos)
|
|
370
492
|
|
|
@@ -480,7 +602,93 @@ Content-Type: application/json
|
|
|
480
602
|
}
|
|
481
603
|
```
|
|
482
604
|
|
|
605
|
+
### Mesclar pessoas (estratégia contact_only)
|
|
606
|
+
|
|
607
|
+
```http
|
|
608
|
+
POST /person/merge
|
|
609
|
+
Authorization: Bearer <token>
|
|
610
|
+
Content-Type: application/json
|
|
611
|
+
|
|
612
|
+
{
|
|
613
|
+
"source_person_id": 15,
|
|
614
|
+
"target_person_id": 10,
|
|
615
|
+
"strategy": "contact_only"
|
|
616
|
+
}
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
### Criar interação para pessoa
|
|
620
|
+
|
|
621
|
+
```http
|
|
622
|
+
POST /person/10/interaction
|
|
623
|
+
Authorization: Bearer <token>
|
|
624
|
+
Content-Type: application/json
|
|
625
|
+
|
|
626
|
+
{
|
|
627
|
+
"type": "call",
|
|
628
|
+
"notes": "Ligação para confirmar reunião"
|
|
629
|
+
}
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
### Agendar followup para pessoa
|
|
633
|
+
|
|
634
|
+
```http
|
|
635
|
+
POST /person/10/followup
|
|
636
|
+
Authorization: Bearer <token>
|
|
637
|
+
Content-Type: application/json
|
|
638
|
+
|
|
639
|
+
{
|
|
640
|
+
"next_action_at": "2024-07-01T10:00:00Z",
|
|
641
|
+
"notes": "Enviar proposta"
|
|
642
|
+
}
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
### Atualizar estágio do ciclo de vida da pessoa
|
|
646
|
+
|
|
647
|
+
```http
|
|
648
|
+
POST /person/10/lifecycle-stage
|
|
649
|
+
Authorization: Bearer <token>
|
|
650
|
+
Content-Type: application/json
|
|
651
|
+
|
|
652
|
+
{
|
|
653
|
+
"lifecycle_stage": "customer"
|
|
654
|
+
}
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
### Pré-visualizar importação CSV de pessoas
|
|
658
|
+
|
|
659
|
+
```http
|
|
660
|
+
POST /person/import/preview
|
|
661
|
+
Authorization: Bearer <token>
|
|
662
|
+
Content-Type: multipart/form-data
|
|
663
|
+
Content-Disposition: form-data; name="file"; filename="pessoas.csv"
|
|
664
|
+
Content-Type: text/csv
|
|
665
|
+
|
|
666
|
+
<arquivo CSV>
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
### Importar pessoas via CSV
|
|
670
|
+
|
|
671
|
+
```http
|
|
672
|
+
POST /person/import
|
|
673
|
+
Authorization: Bearer <token>
|
|
674
|
+
Content-Type: multipart/form-data
|
|
675
|
+
|
|
676
|
+
--boundary
|
|
677
|
+
Content-Disposition: form-data; name="file"; filename="pessoas.csv"
|
|
678
|
+
Content-Type: text/csv
|
|
679
|
+
|
|
680
|
+
<arquivo CSV>
|
|
681
|
+
--boundary
|
|
682
|
+
Content-Disposition: form-data; name="mapping"
|
|
683
|
+
|
|
684
|
+
{"Nome":"name","Email":"email","Telefone":"phone", ...}
|
|
685
|
+
--boundary
|
|
686
|
+
Content-Disposition: form-data; name="company_id"
|
|
687
|
+
|
|
688
|
+
123
|
|
689
|
+
--boundary--
|
|
690
|
+
```
|
|
691
|
+
|
|
483
692
|
---
|
|
484
693
|
|
|
485
694
|
Este README documenta as funcionalidades principais do módulo `@hed-hog/contact` com base no código e definições atuais. Para detalhes adicionais, consulte o código fonte e as definições de DTOs.
|
|
486
|
-
```
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PersonStatus } from './create.dto';
|
|
2
|
+
import { UpdateAllAddressDTO, UpdateAllContactDTO, UpdateAllDocumentDTO } from './update.dto';
|
|
2
3
|
export declare const ACCOUNT_LIFECYCLE_STAGES: readonly ["prospect", "customer", "churned", "inactive"];
|
|
3
4
|
export type AccountLifecycleStage = (typeof ACCOUNT_LIFECYCLE_STAGES)[number];
|
|
4
5
|
export declare class AccountListQueryDTO {
|
|
@@ -22,6 +23,10 @@ export declare class CreateAccountDTO {
|
|
|
22
23
|
lifecycle_stage?: AccountLifecycleStage | null;
|
|
23
24
|
city?: string | null;
|
|
24
25
|
state?: string | null;
|
|
26
|
+
collaborator_person_ids?: number[];
|
|
27
|
+
contacts?: UpdateAllContactDTO[];
|
|
28
|
+
addresses?: UpdateAllAddressDTO[];
|
|
29
|
+
documents?: UpdateAllDocumentDTO[];
|
|
25
30
|
}
|
|
26
31
|
export declare class UpdateAccountDTO extends CreateAccountDTO {
|
|
27
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.dto.d.ts","sourceRoot":"","sources":["../../../src/person/dto/account.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account.dto.d.ts","sourceRoot":"","sources":["../../../src/person/dto/account.dto.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,wBAAwB,0DAK3B,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC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|
const class_transformer_1 = require("class-transformer");
|
|
14
14
|
const class_validator_1 = require("class-validator");
|
|
15
15
|
const create_dto_1 = require("./create.dto");
|
|
16
|
+
const update_dto_1 = require("./update.dto");
|
|
16
17
|
exports.ACCOUNT_LIFECYCLE_STAGES = [
|
|
17
18
|
'prospect',
|
|
18
19
|
'customer',
|
|
@@ -117,6 +118,34 @@ __decorate([
|
|
|
117
118
|
(0, class_validator_1.MaxLength)(2),
|
|
118
119
|
__metadata("design:type", String)
|
|
119
120
|
], CreateAccountDTO.prototype, "state", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
(0, class_validator_1.IsOptional)(),
|
|
123
|
+
(0, class_validator_1.IsArray)(),
|
|
124
|
+
(0, class_transformer_1.Type)(() => Number),
|
|
125
|
+
(0, class_validator_1.IsInt)({ each: true }),
|
|
126
|
+
__metadata("design:type", Array)
|
|
127
|
+
], CreateAccountDTO.prototype, "collaborator_person_ids", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, class_validator_1.IsOptional)(),
|
|
130
|
+
(0, class_validator_1.IsArray)(),
|
|
131
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
132
|
+
(0, class_transformer_1.Type)(() => update_dto_1.UpdateAllContactDTO),
|
|
133
|
+
__metadata("design:type", Array)
|
|
134
|
+
], CreateAccountDTO.prototype, "contacts", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
(0, class_validator_1.IsOptional)(),
|
|
137
|
+
(0, class_validator_1.IsArray)(),
|
|
138
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
139
|
+
(0, class_transformer_1.Type)(() => update_dto_1.UpdateAllAddressDTO),
|
|
140
|
+
__metadata("design:type", Array)
|
|
141
|
+
], CreateAccountDTO.prototype, "addresses", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
(0, class_validator_1.IsOptional)(),
|
|
144
|
+
(0, class_validator_1.IsArray)(),
|
|
145
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
146
|
+
(0, class_transformer_1.Type)(() => update_dto_1.UpdateAllDocumentDTO),
|
|
147
|
+
__metadata("design:type", Array)
|
|
148
|
+
], CreateAccountDTO.prototype, "documents", void 0);
|
|
120
149
|
class UpdateAccountDTO extends CreateAccountDTO {
|
|
121
150
|
}
|
|
122
151
|
exports.UpdateAccountDTO = UpdateAccountDTO;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.dto.js","sourceRoot":"","sources":["../../../src/person/dto/account.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"account.dto.js","sourceRoot":"","sources":["../../../src/person/dto/account.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAUyB;AACzB,6CAA4C;AAC5C,6CAIsB;AAET,QAAA,wBAAwB,GAAG;IACtC,UAAU;IACV,UAAU;IACV,SAAS;IACT,UAAU;CACF,CAAC;AAIX,MAAa,mBAAmB;CAoB/B;AApBD,kDAoBC;AAjBC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACK;AAIhB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,sBAAI,EAAC,CAAC,KAAK,EAAE,yBAAY,CAAC,MAAM,EAAE,yBAAY,CAAC,QAAQ,CAAC,CAAC;;mDAC5B;AAI9B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,sBAAI,EAAC,CAAC,KAAK,EAAE,GAAG,gCAAwB,CAAC,CAAC;;4DACK;AAIhD;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,sBAAI,EAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;;sDACK;AAIlC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,sBAAI,EAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;;sDACK;AAG7B,MAAa,gBAAgB;CA8E5B;AA9ED,4CA8EC;AA5EC;IADC,IAAA,0BA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,CAAC;;iEACa;AAMnC;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;IACT,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,gCAAmB,CAAC;;kDACC;AAMjC;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;IACT,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,gCAAmB,CAAC;;mDACE;AAMlC;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;IACT,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,iCAAoB,CAAC;;mDACE;AAGrC,MAAa,gBAAiB,SAAQ,gBAAgB;CAAG;AAAzD,4CAAyD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-preview.dto.d.ts","sourceRoot":"","sources":["../../../src/person/dto/import-preview.dto.ts"],"names":[],"mappings":"AAAA,qBAAa,wBAAwB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CACnC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportPreviewResponseDTO = void 0;
|
|
4
|
+
class ImportPreviewResponseDTO {
|
|
5
|
+
}
|
|
6
|
+
exports.ImportPreviewResponseDTO = ImportPreviewResponseDTO;
|
|
7
|
+
//# sourceMappingURL=import-preview.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-preview.dto.js","sourceRoot":"","sources":["../../../src/person/dto/import-preview.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,wBAAwB;CAKpC;AALD,4DAKC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class ImportPersonDTO {
|
|
2
|
+
mapping: Record<string, string>;
|
|
3
|
+
company_id?: number;
|
|
4
|
+
}
|
|
5
|
+
export type CrmImportField = 'name' | 'type' | 'status' | 'email' | 'phone' | 'mobile' | 'cpf' | 'cnpj' | 'job_title' | 'company_name' | 'trade_name' | 'website' | 'notes' | 'source' | 'address_street' | 'address_city' | 'address_state' | 'address_zip' | 'address_country' | '_ignore';
|
|
6
|
+
export declare const CRM_IMPORT_FIELDS: CrmImportField[];
|
|
7
|
+
export declare class ImportPersonResponseDTO {
|
|
8
|
+
imported: number;
|
|
9
|
+
skipped: number;
|
|
10
|
+
errors: Array<{
|
|
11
|
+
row: number;
|
|
12
|
+
message: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=import.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.dto.d.ts","sourceRoot":"","sources":["../../../src/person/dto/import.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,eAAe;IAE1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIhC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,MAAM,GACN,QAAQ,GACR,OAAO,GACP,OAAO,GACP,QAAQ,GACR,KAAK,GACL,MAAM,GACN,WAAW,GACX,cAAc,GACd,YAAY,GACZ,SAAS,GACT,OAAO,GACP,QAAQ,GACR,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,aAAa,GACb,iBAAiB,GACjB,SAAS,CAAC;AAEd,eAAO,MAAM,iBAAiB,EAAE,cAAc,EAqB7C,CAAC;AAEF,qBAAa,uBAAuB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ImportPersonResponseDTO = exports.CRM_IMPORT_FIELDS = exports.ImportPersonDTO = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class ImportPersonDTO {
|
|
15
|
+
}
|
|
16
|
+
exports.ImportPersonDTO = ImportPersonDTO;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsObject)(),
|
|
19
|
+
__metadata("design:type", Object)
|
|
20
|
+
], ImportPersonDTO.prototype, "mapping", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_validator_1.IsOptional)(),
|
|
23
|
+
(0, class_validator_1.IsNumber)(),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], ImportPersonDTO.prototype, "company_id", void 0);
|
|
26
|
+
exports.CRM_IMPORT_FIELDS = [
|
|
27
|
+
'name',
|
|
28
|
+
'type',
|
|
29
|
+
'status',
|
|
30
|
+
'email',
|
|
31
|
+
'phone',
|
|
32
|
+
'mobile',
|
|
33
|
+
'cpf',
|
|
34
|
+
'cnpj',
|
|
35
|
+
'job_title',
|
|
36
|
+
'company_name',
|
|
37
|
+
'trade_name',
|
|
38
|
+
'website',
|
|
39
|
+
'notes',
|
|
40
|
+
'source',
|
|
41
|
+
'address_street',
|
|
42
|
+
'address_city',
|
|
43
|
+
'address_state',
|
|
44
|
+
'address_zip',
|
|
45
|
+
'address_country',
|
|
46
|
+
'_ignore',
|
|
47
|
+
];
|
|
48
|
+
class ImportPersonResponseDTO {
|
|
49
|
+
}
|
|
50
|
+
exports.ImportPersonResponseDTO = ImportPersonResponseDTO;
|
|
51
|
+
//# sourceMappingURL=import.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.dto.js","sourceRoot":"","sources":["../../../src/person/dto/import.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAiE;AAEjE,MAAa,eAAe;CAO3B;AAPD,0CAOC;AALC;IADC,IAAA,0BAAQ,GAAE;;gDACqB;AAIhC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACS;AAyBT,QAAA,iBAAiB,GAAqB;IACjD,MAAM;IACN,MAAM;IACN,QAAQ;IACR,OAAO;IACP,OAAO;IACP,QAAQ;IACR,KAAK;IACL,MAAM;IACN,WAAW;IACX,cAAc;IACd,YAAY;IACZ,SAAS;IACT,OAAO;IACP,QAAQ;IACR,gBAAgB;IAChB,cAAc;IACd,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,SAAS;CACV,CAAC;AAEF,MAAa,uBAAuB;CAInC;AAJD,0DAIC"}
|
|
@@ -344,6 +344,20 @@ export declare class PersonController {
|
|
|
344
344
|
document: any;
|
|
345
345
|
address: any;
|
|
346
346
|
}>;
|
|
347
|
+
previewCsvImport(file: MulterFile): Promise<{
|
|
348
|
+
fileName: string;
|
|
349
|
+
totalEstimated: number;
|
|
350
|
+
columns: string[];
|
|
351
|
+
preview: Record<string, string>[];
|
|
352
|
+
}>;
|
|
353
|
+
importFromCsv(file: MulterFile, mappingJson: string, companyIdRaw: string, locale: string, user: any): Promise<{
|
|
354
|
+
imported: number;
|
|
355
|
+
skipped: number;
|
|
356
|
+
errors: {
|
|
357
|
+
row: number;
|
|
358
|
+
message: string;
|
|
359
|
+
}[];
|
|
360
|
+
}>;
|
|
347
361
|
create(data: CreateDTO, locale: string): Promise<{
|
|
348
362
|
name: string;
|
|
349
363
|
type: import("@prisma/client").$Enums.person_type_6dfa750c4d_enum;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"person.controller.d.ts","sourceRoot":"","sources":["../../src/person/person.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"person.controller.d.ts","sourceRoot":"","sources":["../../src/person/person.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,cAAc,CAAC;AAqB7D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EACL,oBAA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E,MAAM,EAC7B,IAAI,EAAE,uBAAuB,EAC3B,MAAM,EAAE,MAAM,EAChB,IAAI,KAAA;;;;IASR,MAAM,CACiB,EAAE,EAAE,MAAM,EAC7B,IAAI,EAAE,kBAAkB,EACtB,MAAM,EAAE,MAAM,EAChB,IAAI,KAAA;;;IASR,MAAM,CAAS,IAAI,EAAE,SAAS,EAAY,MAAM,EAAE,MAAM;CAG/D"}
|
|
@@ -18,6 +18,7 @@ const api_1 = require("@hed-hog/api");
|
|
|
18
18
|
const api_locale_1 = require("@hed-hog/api-locale");
|
|
19
19
|
const api_pagination_1 = require("@hed-hog/api-pagination");
|
|
20
20
|
const common_1 = require("@nestjs/common");
|
|
21
|
+
const platform_express_1 = require("@nestjs/platform-express");
|
|
21
22
|
const express_1 = require("express");
|
|
22
23
|
const account_dto_1 = require("./dto/account.dto");
|
|
23
24
|
const activity_dto_1 = require("./dto/activity.dto");
|
|
@@ -32,6 +33,18 @@ const reports_query_dto_1 = require("./dto/reports-query.dto");
|
|
|
32
33
|
const update_lifecycle_stage_dto_1 = require("./dto/update-lifecycle-stage.dto");
|
|
33
34
|
const update_dto_1 = require("./dto/update.dto");
|
|
34
35
|
const person_service_1 = require("./person.service");
|
|
36
|
+
const CSV_FILE_FILTER = (_req, file, cb) => {
|
|
37
|
+
const isAllowedMime = /text\/(csv|plain)/.test(file.mimetype) || file.mimetype === 'application/vnd.ms-excel';
|
|
38
|
+
const isAllowedExt = file.originalname.toLowerCase().endsWith('.csv');
|
|
39
|
+
if (!isAllowedMime && !isAllowedExt) {
|
|
40
|
+
return cb(new common_1.BadRequestException('Only CSV files are allowed'), false);
|
|
41
|
+
}
|
|
42
|
+
cb(null, true);
|
|
43
|
+
};
|
|
44
|
+
const CSV_UPLOAD_OPTIONS = {
|
|
45
|
+
limits: { fileSize: 10 * 1024 * 1024 }, // 10 MB
|
|
46
|
+
fileFilter: CSV_FILE_FILTER,
|
|
47
|
+
};
|
|
35
48
|
let PersonController = class PersonController {
|
|
36
49
|
constructor(personService) {
|
|
37
50
|
this.personService = personService;
|
|
@@ -96,6 +109,26 @@ let PersonController = class PersonController {
|
|
|
96
109
|
async get(id, locale) {
|
|
97
110
|
return this.personService.get(locale, id);
|
|
98
111
|
}
|
|
112
|
+
async previewCsvImport(file) {
|
|
113
|
+
if (!file) {
|
|
114
|
+
throw new common_1.BadRequestException('No file uploaded');
|
|
115
|
+
}
|
|
116
|
+
return this.personService.previewCsvImport(file);
|
|
117
|
+
}
|
|
118
|
+
async importFromCsv(file, mappingJson, companyIdRaw, locale, user) {
|
|
119
|
+
if (!file) {
|
|
120
|
+
throw new common_1.BadRequestException('No file uploaded');
|
|
121
|
+
}
|
|
122
|
+
let mapping;
|
|
123
|
+
try {
|
|
124
|
+
mapping = JSON.parse(mappingJson);
|
|
125
|
+
}
|
|
126
|
+
catch (_a) {
|
|
127
|
+
throw new common_1.BadRequestException('Invalid mapping JSON');
|
|
128
|
+
}
|
|
129
|
+
const companyId = companyIdRaw ? Number(companyIdRaw) : undefined;
|
|
130
|
+
return this.personService.importFromCsv(file, mapping, Number.isNaN(companyId) ? undefined : companyId, locale, Number((user === null || user === void 0 ? void 0 : user.id) || 0));
|
|
131
|
+
}
|
|
99
132
|
async create(data, locale) {
|
|
100
133
|
return this.personService.create(data, locale);
|
|
101
134
|
}
|
|
@@ -284,6 +317,26 @@ __decorate([
|
|
|
284
317
|
__metadata("design:paramtypes", [Number, String]),
|
|
285
318
|
__metadata("design:returntype", Promise)
|
|
286
319
|
], PersonController.prototype, "get", null);
|
|
320
|
+
__decorate([
|
|
321
|
+
(0, common_1.Post)('import/preview'),
|
|
322
|
+
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file', CSV_UPLOAD_OPTIONS)),
|
|
323
|
+
__param(0, (0, common_1.UploadedFile)()),
|
|
324
|
+
__metadata("design:type", Function),
|
|
325
|
+
__metadata("design:paramtypes", [Object]),
|
|
326
|
+
__metadata("design:returntype", Promise)
|
|
327
|
+
], PersonController.prototype, "previewCsvImport", null);
|
|
328
|
+
__decorate([
|
|
329
|
+
(0, common_1.Post)('import'),
|
|
330
|
+
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file', CSV_UPLOAD_OPTIONS)),
|
|
331
|
+
__param(0, (0, common_1.UploadedFile)()),
|
|
332
|
+
__param(1, (0, common_1.Body)('mapping')),
|
|
333
|
+
__param(2, (0, common_1.Body)('company_id')),
|
|
334
|
+
__param(3, (0, api_locale_1.Locale)()),
|
|
335
|
+
__param(4, (0, api_1.User)()),
|
|
336
|
+
__metadata("design:type", Function),
|
|
337
|
+
__metadata("design:paramtypes", [Object, String, String, String, Object]),
|
|
338
|
+
__metadata("design:returntype", Promise)
|
|
339
|
+
], PersonController.prototype, "importFromCsv", null);
|
|
287
340
|
__decorate([
|
|
288
341
|
(0, common_1.Post)(),
|
|
289
342
|
__param(0, (0, common_1.Body)()),
|