@hed-hog/contact 0.0.33 → 0.0.39

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 (49) hide show
  1. package/dist/address-type/address-type.service.d.ts.map +1 -1
  2. package/dist/address-type/address-type.service.js +1 -1
  3. package/dist/address-type/address-type.service.js.map +1 -1
  4. package/dist/contact-type/contact-type.service.d.ts.map +1 -1
  5. package/dist/contact-type/contact-type.service.js +1 -1
  6. package/dist/contact-type/contact-type.service.js.map +1 -1
  7. package/dist/document-type/document-type.service.d.ts.map +1 -1
  8. package/dist/document-type/document-type.service.js +1 -1
  9. package/dist/document-type/document-type.service.js.map +1 -1
  10. package/dist/person/dto/create.dto.d.ts +2 -1
  11. package/dist/person/dto/create.dto.d.ts.map +1 -1
  12. package/dist/person/dto/create.dto.js +4 -1
  13. package/dist/person/dto/create.dto.js.map +1 -1
  14. package/dist/person/dto/update.dto.d.ts +26 -4
  15. package/dist/person/dto/update.dto.d.ts.map +1 -1
  16. package/dist/person/dto/update.dto.js +108 -5
  17. package/dist/person/dto/update.dto.js.map +1 -1
  18. package/dist/person/person-company/dto/create.dto.d.ts +2 -2
  19. package/dist/person/person-company/dto/create.dto.d.ts.map +1 -1
  20. package/dist/person/person-company/dto/create.dto.js +2 -2
  21. package/dist/person/person-company/dto/create.dto.js.map +1 -1
  22. package/dist/person/person-company/person-company.controller.js +1 -1
  23. package/dist/person/person-company/person-company.controller.js.map +1 -1
  24. package/dist/person/person-company/person-company.service.d.ts +1 -1
  25. package/dist/person/person-company/person-company.service.d.ts.map +1 -1
  26. package/dist/person/person-company/person-company.service.js +2 -2
  27. package/dist/person/person-company/person-company.service.js.map +1 -1
  28. package/dist/person/person.controller.d.ts +5 -10
  29. package/dist/person/person.controller.d.ts.map +1 -1
  30. package/dist/person/person.controller.js +6 -8
  31. package/dist/person/person.controller.js.map +1 -1
  32. package/dist/person/person.service.d.ts +7 -13
  33. package/dist/person/person.service.d.ts.map +1 -1
  34. package/dist/person/person.service.js +121 -13
  35. package/dist/person/person.service.js.map +1 -1
  36. package/hedhog/query/add-unique-address-type-locale.sql +3 -0
  37. package/hedhog/query/add-unique-contact-type-locale.sql +3 -0
  38. package/hedhog/query/add-unique-document-type-locale.sql +3 -0
  39. package/package.json +4 -4
  40. package/src/address-type/address-type.service.ts +1 -1
  41. package/src/contact-type/contact-type.service.ts +1 -1
  42. package/src/document-type/document-type.service.ts +1 -1
  43. package/src/person/dto/create.dto.ts +5 -3
  44. package/src/person/dto/update.dto.ts +75 -3
  45. package/src/person/person-company/dto/create.dto.ts +5 -5
  46. package/src/person/person-company/person-company.controller.ts +1 -1
  47. package/src/person/person-company/person-company.service.ts +2 -5
  48. package/src/person/person.controller.ts +19 -18
  49. package/src/person/person.service.ts +132 -19
@@ -1 +1 @@
1
- {"version":3,"file":"address-type.service.d.ts","sourceRoot":"","sources":["../../src/address-type/address-type.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBACa,wBAAwB;IAMjC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAPhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;gBAIrB,aAAa,EAAE,aAAa,EAE5B,aAAa,EAAE,aAAa;IAGzC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa;;;;;;;;;IAQpD,GAAG,CAAC,EAAE,EAAE,MAAM;IAId,MAAM,CAAC,IAAI,EAAE,SAAS;IAQtB,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE;IASpD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;CAehC"}
1
+ {"version":3,"file":"address-type.service.d.ts","sourceRoot":"","sources":["../../src/address-type/address-type.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBACa,wBAAwB;IAMjC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAPhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;gBAI7B,aAAa,EAAE,aAAa,EAE5B,aAAa,EAAE,aAAa;IAGzC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa;;;;;;;;;IAQpD,GAAG,CAAC,EAAE,EAAE,MAAM;IAId,MAAM,CAAC,IAAI,EAAE,SAAS;IAQtB,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE;IASpD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;CAehC"}
@@ -21,7 +21,7 @@ let PersonAddressTypeService = class PersonAddressTypeService {
21
21
  this.prismaService = prismaService;
22
22
  this.localeService = localeService;
23
23
  this.modelName = 'address_type';
24
- this.foreignKey = 'type_id';
24
+ this.foreignKey = 'address_type_id';
25
25
  }
26
26
  async list(locale, paginationParams) {
27
27
  return this.localeService.listModelWithLocale(locale, this.modelName, paginationParams);
@@ -1 +1 @@
1
- {"version":3,"file":"address-type.service.js","sourceRoot":"","sources":["../../src/address-type/address-type.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,oDAAoD;AAEpD,oDAAoD;AACpD,2CAKwB;AAKjB,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAInC,YAEE,aAA6C,EAE7C,aAA6C;QAF5B,kBAAa,GAAb,aAAa,CAAe;QAE5B,kBAAa,GAAb,aAAa,CAAe;QAP9B,cAAS,GAAG,cAAc,CAAC;QAC3B,eAAU,GAAG,SAAS,CAAC;IAOrC,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,gBAA+B;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAC3C,MAAM,EACN,IAAI,CAAC,SAAS,EACd,gBAAgB,CACjB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAe;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAC7C,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAmC;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAC7C,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,EAAE,EACF,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAa;QAC7B,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,4BAAmB,CAC3B,8CAA8C,CAC/C,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC;YAChD,KAAK,EAAE;gBACL,EAAE,EAAE;oBACF,EAAE,EAAE,GAAG;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAvDY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;qCADR,0BAAa;QAEb,0BAAa;GARpC,wBAAwB,CAuDpC"}
1
+ {"version":3,"file":"address-type.service.js","sourceRoot":"","sources":["../../src/address-type/address-type.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,oDAAoD;AAEpD,oDAAoD;AACpD,2CAKwB;AAKjB,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAInC,YAEE,aAA6C,EAE7C,aAA6C;QAF5B,kBAAa,GAAb,aAAa,CAAe;QAE5B,kBAAa,GAAb,aAAa,CAAe;QAP9B,cAAS,GAAG,cAAc,CAAC;QAC3B,eAAU,GAAG,iBAAiB,CAAC;IAO7C,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,gBAA+B;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAC3C,MAAM,EACN,IAAI,CAAC,SAAS,EACd,gBAAgB,CACjB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAe;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAC7C,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAmC;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAC7C,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,EAAE,EACF,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAa;QAC7B,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,4BAAmB,CAC3B,8CAA8C,CAC/C,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC;YAChD,KAAK,EAAE;gBACL,EAAE,EAAE;oBACF,EAAE,EAAE,GAAG;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAvDY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;qCADR,0BAAa;QAEb,0BAAa;GARpC,wBAAwB,CAuDpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"contact-type.service.d.ts","sourceRoot":"","sources":["../../src/contact-type/contact-type.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,a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Q,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAPhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;gBAI7B,aAAa,EAAE,aAAa,EAE5B,aAAa,EAAE,aAAa;IAGzC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa;;;;;;;;;IAQpD,GAAG,CAAC,EAAE,EAAE,MAAM;IAId,MAAM,CAAC,IAAI,EAAE,SAAS;IAQtB,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE;IASpD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;CAehC"}
@@ -21,7 +21,7 @@ let PersonContactTypeService = class PersonContactTypeService {
21
21
  this.prismaService = prismaService;
22
22
  this.localeService = localeService;
23
23
  this.modelName = 'contact_type';
24
- this.foreignKey = 'type_id';
24
+ this.foreignKey = 'contact_type_id';
25
25
  }
26
26
  async list(locale, paginationParams) {
27
27
  return this.localeService.listModelWithLocale(locale, this.modelName, paginationParams);
@@ -1 +1 @@
1
- {"version":3,"file":"contact-type.service.js","sourceRoot":"","sources":["../../src/contact-type/contact-type.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,oDAAoD;AAEpD,oDAAoD;AACpD,2CAKwB;AAKjB,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAInC,YAEE,aAA6C,EAE7C,aAA6C;QAF5B,kBAAa,GAAb,aAAa,CAAe;QAE5B,kBAAa,GAAb,aAAa,CAAe;QAP9B,cAAS,GAAG,cAAc,CAAC;QAC3B,eAAU,GAAG,SAAS,CAAC;IAOrC,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,gBAA+B;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAC3C,M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AAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE;IASpD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;CAehC"}
1
+ {"version":3,"file":"document-type.service.d.ts","sourceRoot":"","sources":["../../src/document-type/document-type.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBACa,yBAAyB;IAMlC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAPhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmB;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;gBAI9B,aAAa,EAAE,aAAa,EAE5B,aAAa,EAAE,aAAa;IAGzC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa;;;;;;;;;IAQpD,GAAG,CAAC,EAAE,EAAE,MAAM;IAId,MAAM,CAAC,IAAI,EAAE,SAAS;IAQtB,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE;IASpD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;CAehC"}
@@ -21,7 +21,7 @@ let PersonDocumentTypeService = class PersonDocumentTypeService {
21
21
  this.prismaService = prismaService;
22
22
  this.localeService = localeService;
23
23
  this.modelName = 'document_type';
24
- this.foreignKey = 'type_id';
24
+ this.foreignKey = 'document_type_id';
25
25
  }
26
26
  async list(locale, paginationParams) {
27
27
  return this.localeService.listModelWithLocale(locale, this.modelName, paginationParams);
@@ -1 +1 @@
1
- {"version":3,"file":"document-type.service.js","sourceRoot":"","sources":["../../src/document-type/document-type.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,oDAAoD;AAEpD,oDAAoD;AACpD,2CAKwB;AAKjB,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAIpC,YAEE,aAA6C,EAE7C,aAA6C;QAF5B,kBAAa,GAAb,aAAa,CAAe;QAE5B,kBAAa,GAAb,aAAa,CAAe;QAP9B,cAAS,GAAG,eAAe,CAAC;QAC5B,eAAU,GAAG,SAAS,CAAC;IAOrC,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,gBAA+B;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAC3C,MAAM,EACN,IAAI,CAAC,SAAS,EACd,gBAAgB,CACjB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAe;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAC7C,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAmC;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAC7C,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,EAAE,EACF,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAa;QAC7B,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,4BAAmB,CAC3B,8CAA8C,CAC/C,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC;YACjD,KAAK,EAAE;gBACL,EAAE,EAAE;oBACF,EAAE,EAAE,GAAG;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAvDY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;qCADR,0BAAa;QAEb,0BAAa;GARpC,yBAAyB,CAuDrC"}
1
+ {"version":3,"file":"document-type.service.js","sourceRoot":"","sources":["../../src/document-type/document-type.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,oDAAoD;AAEpD,oDAAoD;AACpD,2CAKwB;AAKjB,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAIpC,YAEE,aAA6C,EAE7C,aAA6C;QAF5B,kBAAa,GAAb,aAAa,CAAe;QAE5B,kBAAa,GAAb,aAAa,CAAe;QAP9B,cAAS,GAAG,eAAe,CAAC;QAC5B,eAAU,GAAG,kBAAkB,CAAC;IAO9C,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,gBAA+B;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAC3C,MAAM,EACN,IAAI,CAAC,SAAS,EACd,gBAAgB,CACjB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAe;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAC7C,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAmC;QACxD,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAC7C,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,EAAE,EACF,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAa;QAC7B,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,4BAAmB,CAC3B,8CAA8C,CAC/C,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC;YACjD,KAAK,EAAE;gBACL,EAAE,EAAE;oBACF,EAAE,EAAE,GAAG;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAvDY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;qCADR,0BAAa;QAEb,0BAAa;GARpC,yBAAyB,CAuDrC"}
@@ -7,7 +7,8 @@ export declare enum PersonStatus {
7
7
  INACTIVE = "inactive"
8
8
  }
9
9
  export declare class CreateDTO {
10
+ name: string;
10
11
  type: PersonType;
11
- status?: PersonStatus;
12
+ status: PersonStatus;
12
13
  }
13
14
  //# sourceMappingURL=create.dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.dto.d.ts","sourceRoot":"","sources":["../../../src/person/dto/create.dto.ts"],"names":[],"mappings":"AAEA,oBAAY,UAAU;IACpB,UAAU,eAAe;IACzB,OAAO,YAAY;CACpB;AAED,oBAAY,YAAY;IACtB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB;AAED,qBAAa,SAAS;IAEpB,IAAI,EAAE,UAAU,CAAC;IAIjB,MAAM,CAAC,EAAE,YAAY,CAAuB;CAC7C"}
1
+ {"version":3,"file":"create.dto.d.ts","sourceRoot":"","sources":["../../../src/person/dto/create.dto.ts"],"names":[],"mappings":"AAEA,oBAAY,UAAU;IACpB,UAAU,eAAe;IACzB,OAAO,YAAY;CACpB;AAED,oBAAY,YAAY;IACtB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB;AAED,qBAAa,SAAS;IAEpB,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,UAAU,CAAC;IAGjB,MAAM,EAAE,YAAY,CAAuB;CAC5C"}
@@ -27,12 +27,15 @@ class CreateDTO {
27
27
  }
28
28
  }
29
29
  exports.CreateDTO = CreateDTO;
30
+ __decorate([
31
+ (0, class_validator_1.IsString)(),
32
+ __metadata("design:type", String)
33
+ ], CreateDTO.prototype, "name", void 0);
30
34
  __decorate([
31
35
  (0, class_validator_1.IsEnum)(PersonType),
32
36
  __metadata("design:type", String)
33
37
  ], CreateDTO.prototype, "type", void 0);
34
38
  __decorate([
35
- (0, class_validator_1.IsOptional)(),
36
39
  (0, class_validator_1.IsEnum)(PersonStatus),
37
40
  __metadata("design:type", String)
38
41
  ], CreateDTO.prototype, "status", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"create.dto.js","sourceRoot":"","sources":["../../../src/person/dto/create.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAqD;AAErD,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,uCAAyB,CAAA;IACzB,iCAAmB,CAAA;AACrB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,qCAAqB,CAAA;AACvB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAED,MAAa,SAAS;IAAtB;QAME,WAAM,GAAkB,YAAY,CAAC,MAAM,CAAC;IAC9C,CAAC;CAAA;AAPD,8BAOC;AALC;IADC,IAAA,wBAAM,EAAC,UAAU,CAAC;;uCACF;AAIjB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,YAAY,CAAC;;yCACuB"}
1
+ {"version":3,"file":"create.dto.js","sourceRoot":"","sources":["../../../src/person/dto/create.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmD;AAEnD,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,uCAAyB,CAAA;IACzB,iCAAmB,CAAA;AACrB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,qCAAqB,CAAA;AACvB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAED,MAAa,SAAS;IAAtB;QAQE,WAAM,GAAiB,YAAY,CAAC,MAAM,CAAC;IAC7C,CAAC;CAAA;AATD,8BASC;AAPC;IADC,IAAA,0BAAQ,GAAE;;uCACE;AAGb;IADC,IAAA,wBAAM,EAAC,UAAU,CAAC;;uCACF;AAGjB;IADC,IAAA,wBAAM,EAAC,YAAY,CAAC;;yCACsB"}
@@ -1,6 +1,28 @@
1
- import { CreateDTO } from './create.dto';
2
- declare const UpdateDTO_base: import("@nestjs/mapped-types").MappedType<Partial<CreateDTO>>;
3
- export declare class UpdateDTO extends UpdateDTO_base {
1
+ export declare class UpdateAllContactDTO {
2
+ id?: number;
3
+ value: string;
4
+ is_primary: boolean;
5
+ contact_type_id: number;
6
+ }
7
+ export declare class UpdateAllAddressDTO {
8
+ id?: number;
9
+ line1: string;
10
+ city: string;
11
+ state: string;
12
+ is_primary: boolean;
13
+ address_type_id: number;
14
+ }
15
+ export declare class UpdateAllDocumentDTO {
16
+ id?: number;
17
+ value: string;
18
+ document_type_id: number;
19
+ }
20
+ export declare class UpdateAllPersonDTO {
21
+ name: string;
22
+ type: string;
23
+ status: string;
24
+ contacts: UpdateAllContactDTO[];
25
+ addresses: UpdateAllAddressDTO[];
26
+ documents: UpdateAllDocumentDTO[];
4
27
  }
5
- export {};
6
28
  //# sourceMappingURL=update.dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update.dto.d.ts","sourceRoot":"","sources":["../../../src/person/dto/update.dto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;;AAEzC,qBAAa,SAAU,SAAQ,cAAsB;CAAG"}
1
+ {"version":3,"file":"update.dto.d.ts","sourceRoot":"","sources":["../../../src/person/dto/update.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,mBAAmB;IAG9B,EAAE,CAAC,EAAE,MAAM,CAAC;IAGZ,KAAK,EAAE,MAAM,CAAC;IAGd,UAAU,EAAE,OAAO,CAAC;IAGpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,mBAAmB;IAG9B,EAAE,CAAC,EAAE,MAAM,CAAC;IAGZ,KAAK,EAAE,MAAM,CAAC;IAGd,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,MAAM,CAAC;IAGd,UAAU,EAAE,OAAO,CAAC;IAGpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,oBAAoB;IAG/B,EAAE,CAAC,EAAE,MAAM,CAAC;IAGZ,KAAK,EAAE,MAAM,CAAC;IAGd,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,kBAAkB;IAE7B,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,MAAM,CAAC;IAGb,MAAM,EAAE,MAAM,CAAC;IAKf,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAKhC,SAAS,EAAE,mBAAmB,EAAE,CAAC;IAKjC,SAAS,EAAE,oBAAoB,EAAE,CAAC;CACnC"}
@@ -1,9 +1,112 @@
1
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
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UpdateDTO = void 0;
4
- const mapped_types_1 = require("@nestjs/mapped-types");
5
- const create_dto_1 = require("./create.dto");
6
- class UpdateDTO extends (0, mapped_types_1.PartialType)(create_dto_1.CreateDTO) {
12
+ exports.UpdateAllPersonDTO = exports.UpdateAllDocumentDTO = exports.UpdateAllAddressDTO = exports.UpdateAllContactDTO = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ class UpdateAllContactDTO {
7
16
  }
8
- exports.UpdateDTO = UpdateDTO;
17
+ exports.UpdateAllContactDTO = UpdateAllContactDTO;
18
+ __decorate([
19
+ (0, class_validator_1.IsOptional)(),
20
+ (0, class_validator_1.IsInt)(),
21
+ __metadata("design:type", Number)
22
+ ], UpdateAllContactDTO.prototype, "id", void 0);
23
+ __decorate([
24
+ (0, class_validator_1.IsString)(),
25
+ __metadata("design:type", String)
26
+ ], UpdateAllContactDTO.prototype, "value", void 0);
27
+ __decorate([
28
+ (0, class_validator_1.IsBoolean)(),
29
+ __metadata("design:type", Boolean)
30
+ ], UpdateAllContactDTO.prototype, "is_primary", void 0);
31
+ __decorate([
32
+ (0, class_validator_1.IsInt)(),
33
+ __metadata("design:type", Number)
34
+ ], UpdateAllContactDTO.prototype, "contact_type_id", void 0);
35
+ class UpdateAllAddressDTO {
36
+ }
37
+ exports.UpdateAllAddressDTO = UpdateAllAddressDTO;
38
+ __decorate([
39
+ (0, class_validator_1.IsOptional)(),
40
+ (0, class_validator_1.IsInt)(),
41
+ __metadata("design:type", Number)
42
+ ], UpdateAllAddressDTO.prototype, "id", void 0);
43
+ __decorate([
44
+ (0, class_validator_1.IsString)(),
45
+ __metadata("design:type", String)
46
+ ], UpdateAllAddressDTO.prototype, "line1", void 0);
47
+ __decorate([
48
+ (0, class_validator_1.IsString)(),
49
+ __metadata("design:type", String)
50
+ ], UpdateAllAddressDTO.prototype, "city", void 0);
51
+ __decorate([
52
+ (0, class_validator_1.IsString)(),
53
+ __metadata("design:type", String)
54
+ ], UpdateAllAddressDTO.prototype, "state", void 0);
55
+ __decorate([
56
+ (0, class_validator_1.IsBoolean)(),
57
+ __metadata("design:type", Boolean)
58
+ ], UpdateAllAddressDTO.prototype, "is_primary", void 0);
59
+ __decorate([
60
+ (0, class_validator_1.IsInt)(),
61
+ __metadata("design:type", Number)
62
+ ], UpdateAllAddressDTO.prototype, "address_type_id", void 0);
63
+ class UpdateAllDocumentDTO {
64
+ }
65
+ exports.UpdateAllDocumentDTO = UpdateAllDocumentDTO;
66
+ __decorate([
67
+ (0, class_validator_1.IsOptional)(),
68
+ (0, class_validator_1.IsInt)(),
69
+ __metadata("design:type", Number)
70
+ ], UpdateAllDocumentDTO.prototype, "id", void 0);
71
+ __decorate([
72
+ (0, class_validator_1.IsString)(),
73
+ __metadata("design:type", String)
74
+ ], UpdateAllDocumentDTO.prototype, "value", void 0);
75
+ __decorate([
76
+ (0, class_validator_1.IsInt)(),
77
+ __metadata("design:type", Number)
78
+ ], UpdateAllDocumentDTO.prototype, "document_type_id", void 0);
79
+ class UpdateAllPersonDTO {
80
+ }
81
+ exports.UpdateAllPersonDTO = UpdateAllPersonDTO;
82
+ __decorate([
83
+ (0, class_validator_1.IsString)(),
84
+ __metadata("design:type", String)
85
+ ], UpdateAllPersonDTO.prototype, "name", void 0);
86
+ __decorate([
87
+ (0, class_validator_1.IsString)(),
88
+ __metadata("design:type", String)
89
+ ], UpdateAllPersonDTO.prototype, "type", void 0);
90
+ __decorate([
91
+ (0, class_validator_1.IsString)(),
92
+ __metadata("design:type", String)
93
+ ], UpdateAllPersonDTO.prototype, "status", void 0);
94
+ __decorate([
95
+ (0, class_validator_1.IsArray)(),
96
+ (0, class_validator_1.ValidateNested)({ each: true }),
97
+ (0, class_transformer_1.Type)(() => UpdateAllContactDTO),
98
+ __metadata("design:type", Array)
99
+ ], UpdateAllPersonDTO.prototype, "contacts", void 0);
100
+ __decorate([
101
+ (0, class_validator_1.IsArray)(),
102
+ (0, class_validator_1.ValidateNested)({ each: true }),
103
+ (0, class_transformer_1.Type)(() => UpdateAllAddressDTO),
104
+ __metadata("design:type", Array)
105
+ ], UpdateAllPersonDTO.prototype, "addresses", void 0);
106
+ __decorate([
107
+ (0, class_validator_1.IsArray)(),
108
+ (0, class_validator_1.ValidateNested)({ each: true }),
109
+ (0, class_transformer_1.Type)(() => UpdateAllDocumentDTO),
110
+ __metadata("design:type", Array)
111
+ ], UpdateAllPersonDTO.prototype, "documents", void 0);
9
112
  //# sourceMappingURL=update.dto.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update.dto.js","sourceRoot":"","sources":["../../../src/person/dto/update.dto.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,6CAAyC;AAEzC,MAAa,SAAU,SAAQ,IAAA,0BAAW,EAAC,sBAAS,CAAC;CAAG;AAAxD,8BAAwD"}
1
+ {"version":3,"file":"update.dto.js","sourceRoot":"","sources":["../../../src/person/dto/update.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAAkG;AAElG,MAAa,mBAAmB;CAa/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I,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;;qDACC"}
@@ -1,5 +1,5 @@
1
1
  export declare class CreateDTO {
2
- foundation_date?: Date;
3
- legal_nature?: string;
2
+ foundation_date: Date;
3
+ legal_nature: string;
4
4
  }
5
5
  //# sourceMappingURL=create.dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.dto.d.ts","sourceRoot":"","sources":["../../../../src/person/person-company/dto/create.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;IAIpB,eAAe,CAAC,EAAE,IAAI,CAAC;IAIvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
1
+ {"version":3,"file":"create.dto.d.ts","sourceRoot":"","sources":["../../../../src/person/person-company/dto/create.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;IAIpB,eAAe,EAAE,IAAI,CAAC;IAItB,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -16,13 +16,13 @@ class CreateDTO {
16
16
  }
17
17
  exports.CreateDTO = CreateDTO;
18
18
  __decorate([
19
- (0, class_validator_1.IsOptional)(),
19
+ (0, class_validator_1.IsNotEmpty)(),
20
20
  (0, class_validator_1.IsDate)(),
21
21
  (0, class_transformer_1.Type)(() => Date),
22
22
  __metadata("design:type", Date)
23
23
  ], CreateDTO.prototype, "foundation_date", void 0);
24
24
  __decorate([
25
- (0, class_validator_1.IsOptional)(),
25
+ (0, class_validator_1.IsNotEmpty)(),
26
26
  (0, class_validator_1.IsString)(),
27
27
  __metadata("design:type", String)
28
28
  ], CreateDTO.prototype, "legal_nature", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"create.dto.js","sourceRoot":"","sources":["../../../../src/person/person-company/dto/create.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAA+D;AAE/D,MAAa,SAAS;CASrB;AATD,8BASC;AALC;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,GAAE;IACR,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;8BACC,IAAI;kDAAC;AAIvB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;+CACW"}
1
+ {"version":3,"file":"create.dto.js","sourceRoot":"","sources":["../../../../src/person/person-company/dto/create.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAA+D;AAE/D,MAAa,SAAS;CASrB;AATD,8BASC;AALC;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,GAAE;IACR,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;8BACA,IAAI;kDAAC;AAItB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;+CACU"}
@@ -23,7 +23,7 @@ let PersonCompanyController = class PersonCompanyController {
23
23
  this.personCompanyService = personCompanyService;
24
24
  }
25
25
  create(personId, data) {
26
- return this.personCompanyService.create(personId, data);
26
+ return this.personCompanyService.create(data);
27
27
  }
28
28
  get(personId) {
29
29
  return this.personCompanyService.get(personId);
@@ -1 +1 @@
1
- {"version":3,"file":"person-company.controller.js","sourceRoot":"","sources":["../../../src/person/person-company/person-company.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAAoC;AACpC,2CAUwB;AACxB,iDAA6C;AAC7C,iDAA6C;AAC7C,qEAAgE;AAIzD,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAClC,YAEmB,oBAA0C;QAA1C,yBAAoB,GAApB,oBAAoB,CAAsB;IAC1D,CAAC;IAGJ,MAAM,CAC6B,QAAgB,EACzC,IAAe;QAEvB,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAGD,GAAG,CAAkC,QAAgB;QACnD,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;IAGD,MAAM,CAC6B,QAAgB,EACzC,IAAe;QAEvB,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AA1BY,0DAAuB;AAOlC;IADC,IAAA,aAAI,GAAE;IAEJ,WAAA,IAAA,cAAK,EAAC,UAAU,EAAE,qBAAY,CAAC,CAAA;IAC/B,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,sBAAS;;qDAGxB;AAGD;IADC,IAAA,YAAG,GAAE;IACD,WAAA,IAAA,cAAK,EAAC,UAAU,EAAE,qBAAY,CAAC,CAAA;;;;kDAEnC;AAGD;IADC,IAAA,cAAK,GAAE;IAEL,WAAA,IAAA,cAAK,EAAC,UAAU,EAAE,qBAAY,CAAC,CAAA;IAC/B,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,sBAAS;;qDAGxB;kCAzBU,uBAAuB;IAFnC,IAAA,UAAI,GAAE;IACN,IAAA,mBAAU,EAAC,iCAAiC,CAAC;IAGzC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6CAAoB,CAAC,CAAC,CAAA;qCACR,6CAAoB;GAHlD,uBAAuB,CA0BnC"}
1
+ {"version":3,"file":"person-company.controller.js","sourceRoot":"","sources":["../../../src/person/person-company/person-company.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAAoC;AACpC,2CAUwB;AACxB,iDAA6C;AAC7C,iDAA6C;AAC7C,qEAAgE;AAIzD,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAClC,YAEmB,oBAA0C;QAA1C,yBAAoB,GAApB,oBAAoB,CAAsB;IAC1D,CAAC;IAGJ,MAAM,CAC6B,QAAgB,EACzC,IAAe;QAEvB,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAGD,GAAG,CAAkC,QAAgB;QACnD,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;IAGD,MAAM,CAC6B,QAAgB,EACzC,IAAe;QAEvB,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AA1BY,0DAAuB;AAOlC;IADC,IAAA,aAAI,GAAE;IAEJ,WAAA,IAAA,cAAK,EAAC,UAAU,EAAE,qBAAY,CAAC,CAAA;IAC/B,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,sBAAS;;qDAGxB;AAGD;IADC,IAAA,YAAG,GAAE;IACD,WAAA,IAAA,cAAK,EAAC,UAAU,EAAE,qBAAY,CAAC,CAAA;;;;kDAEnC;AAGD;IADC,IAAA,cAAK,GAAE;IAEL,WAAA,IAAA,cAAK,EAAC,UAAU,EAAE,qBAAY,CAAC,CAAA;IAC/B,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,sBAAS;;qDAGxB;kCAzBU,uBAAuB;IAFnC,IAAA,UAAI,GAAE;IACN,IAAA,mBAAU,EAAC,iCAAiC,CAAC;IAGzC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6CAAoB,CAAC,CAAC,CAAA;qCACR,6CAAoB;GAHlD,uBAAuB,CA0BnC"}
@@ -4,7 +4,7 @@ import { UpdateDTO } from './dto/update.dto';
4
4
  export declare class PersonCompanyService {
5
5
  private readonly prismaService;
6
6
  constructor(prismaService: PrismaService);
7
- create(personId: number, data: CreateDTO): Promise<{
7
+ create(data: CreateDTO): Promise<{
8
8
  id: number;
9
9
  foundation_date: Date;
10
10
  legal_nature: string;
@@ -1 +1 @@
1
- {"version":3,"file":"person-company.service.d.ts","sourceRoot":"","sources":["../../../src/person/person-company/person-company.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBACa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAEnD,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS;;;;;IASxC,GAAG,CAAC,QAAQ,EAAE,MAAM;;;;;IAQpB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS;;;;;CAQ/C"}
1
+ {"version":3,"file":"person-company.service.d.ts","sourceRoot":"","sources":["../../../src/person/person-company/person-company.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBACa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAEnD,MAAM,CAAC,IAAI,EAAE,SAAS;;;;;IAMtB,GAAG,CAAC,QAAQ,EAAE,MAAM;;;;;IAQpB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS;;;;;CAQ/C"}
@@ -16,9 +16,9 @@ let PersonCompanyService = class PersonCompanyService {
16
16
  constructor(prismaService) {
17
17
  this.prismaService = prismaService;
18
18
  }
19
- async create(personId, data) {
19
+ async create(data) {
20
20
  return this.prismaService.person_company.create({
21
- data: Object.assign({ id: personId }, data)
21
+ data
22
22
  });
23
23
  }
24
24
  async get(personId) {
@@ -1 +1 @@
1
- {"version":3,"file":"person-company.service.js","sourceRoot":"","sources":["../../../src/person/person-company/person-company.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAoD;AACpD,2CAA4C;AAKrC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,IAAe;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC;YAC9C,IAAI,kBACF,EAAE,EAAE,QAAQ,IACT,IAAI,CACR;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,UAAU,CAAC;YAClD,KAAK,EAAE;gBACL,EAAE,EAAE,QAAQ;aACb;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,IAAe;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC;YAC9C,KAAK,EAAE;gBACL,EAAE,EAAE,QAAQ;aACb;YACD,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA5BY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAEiC,0BAAa;GAD9C,oBAAoB,CA4BhC"}
1
+ {"version":3,"file":"person-company.service.js","sourceRoot":"","sources":["../../../src/person/person-company/person-company.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAoD;AACpD,2CAA4C;AAKrC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,IAAe;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC;YAC9C,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,UAAU,CAAC;YAClD,KAAK,EAAE;gBACL,EAAE,EAAE,QAAQ;aACb;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,IAAe;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC;YAC9C,KAAK,EAAE;gBACL,EAAE,EAAE,QAAQ;aACb;YACD,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAzBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAEiC,0BAAa;GAD9C,oBAAoB,CAyBhC"}
@@ -1,6 +1,6 @@
1
1
  import { DeleteDTO } from '@hed-hog/api';
2
2
  import { CreateDTO } from './dto/create.dto';
3
- import { UpdateDTO } from './dto/update.dto';
3
+ import { UpdateAllPersonDTO } from './dto/update.dto';
4
4
  import { PersonService } from './person.service';
5
5
  export declare class PersonController {
6
6
  private readonly personService;
@@ -12,7 +12,7 @@ export declare class PersonController {
12
12
  active: number;
13
13
  inactive: number;
14
14
  }>;
15
- list(paginationParams: any): Promise<{
15
+ list(paginationParams: any, filters: any): Promise<{
16
16
  total: any;
17
17
  lastPage: number;
18
18
  page: number;
@@ -37,14 +37,9 @@ export declare class PersonController {
37
37
  updated_at: Date;
38
38
  status: import("@prisma/client").$Enums.person_status_enum;
39
39
  }>;
40
- update(id: number, data: UpdateDTO): Promise<{
41
- name: string;
42
- type: import("@prisma/client").$Enums.person_type_enum;
43
- id: number;
44
- created_at: Date;
45
- updated_at: Date;
46
- status: import("@prisma/client").$Enums.person_status_enum;
40
+ update(id: number, data: UpdateAllPersonDTO): Promise<{
41
+ success: boolean;
47
42
  }>;
48
- delete(data: DeleteDTO): Promise<import("@prisma/client").Prisma.BatchPayload>;
43
+ delete(data: DeleteDTO): Promise<[import("@prisma/client").Prisma.BatchPayload, import("@prisma/client").Prisma.BatchPayload, import("@prisma/client").Prisma.BatchPayload, import("@prisma/client").Prisma.BatchPayload]>;
49
44
  }
50
45
  //# sourceMappingURL=person.controller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"person.controller.d.ts","sourceRoot":"","sources":["../../src/person/person.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,MAAM,cAAc,CAAC;AAc/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAEa,gBAAgB;IAGzB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAIzC,QAAQ;;;;;;;IAKR,IAAI,CAAe,gBAAgB,KAAA;;;;;;;;;IAKnC,GAAG,CAA4B,EAAE,EAAE,MAAM;;;;;;;;IAKzC,MAAM,CAAS,IAAI,EAAE,SAAS;;;;;;;;IAK9B,MAAM,CAA4B,EAAE,EAAE,MAAM,EAAU,IAAI,EAAE,SAAS;;;;;;;;IAQrE,MAAM,CAAS,IAAI,EAAE,SAAS;CAGrC"}
1
+ {"version":3,"file":"person.controller.d.ts","sourceRoot":"","sources":["../../src/person/person.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,MAAM,cAAc,CAAC;AAe/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAEa,gBAAgB;IAGzB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAIzC,QAAQ;;;;;;;IAKR,IAAI,CAAe,gBAAgB,KAAA,EAAW,OAAO,KAAA;;;;;;;;;IAKrD,GAAG,CAA4B,EAAE,EAAE,MAAM;;;;;;;;IAKzC,MAAM,CAAS,IAAI,EAAE,SAAS;;;;;;;;IAK9B,MAAM,CACiB,EAAE,EAAE,MAAM,EAC7B,IAAI,EAAE,kBAAkB;;;IAM5B,MAAM,CAAS,IAAI,EAAE,SAAS;CAGrC"}
@@ -26,8 +26,8 @@ let PersonController = class PersonController {
26
26
  async getStats() {
27
27
  return this.personService.getStats();
28
28
  }
29
- async list(paginationParams) {
30
- return this.personService.list(paginationParams);
29
+ async list(paginationParams, filters) {
30
+ return this.personService.list(Object.assign(Object.assign({}, paginationParams), filters));
31
31
  }
32
32
  async get(id) {
33
33
  return this.personService.get(id);
@@ -36,10 +36,7 @@ let PersonController = class PersonController {
36
36
  return this.personService.create(data);
37
37
  }
38
38
  async update(id, data) {
39
- return this.personService.update({
40
- id,
41
- data
42
- });
39
+ return this.personService.update(id, data);
43
40
  }
44
41
  async delete(data) {
45
42
  return this.personService.delete(data);
@@ -55,8 +52,9 @@ __decorate([
55
52
  __decorate([
56
53
  (0, common_1.Get)(),
57
54
  __param(0, (0, api_pagination_1.Pagination)()),
55
+ __param(1, (0, common_1.Query)()),
58
56
  __metadata("design:type", Function),
59
- __metadata("design:paramtypes", [Object]),
57
+ __metadata("design:paramtypes", [Object, Object]),
60
58
  __metadata("design:returntype", Promise)
61
59
  ], PersonController.prototype, "list", null);
62
60
  __decorate([
@@ -78,7 +76,7 @@ __decorate([
78
76
  __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
79
77
  __param(1, (0, common_1.Body)()),
80
78
  __metadata("design:type", Function),
81
- __metadata("design:paramtypes", [Number, update_dto_1.UpdateDTO]),
79
+ __metadata("design:paramtypes", [Number, update_dto_1.UpdateAllPersonDTO]),
82
80
  __metadata("design:returntype", Promise)
83
81
  ], PersonController.prototype, "update", null);
84
82
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"person.controller.js","sourceRoot":"","sources":["../../src/person/person.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAA+C;AAC/C,4DAAqD;AACrD,2CAWwB;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aginationService } from '@hed-hog/api-pagination';
3
3
  import { PrismaService } from '@hed-hog/api-prisma';
4
4
  import { CreateDTO } from './dto/create.dto';
5
- import { UpdateDTO } from './dto/update.dto';
6
5
  export declare class PersonService {
7
6
  private readonly prismaService;
8
7
  private readonly paginationService;
@@ -14,7 +13,10 @@ export declare class PersonService {
14
13
  active: number;
15
14
  inactive: number;
16
15
  }>;
17
- list(paginationParams: PaginationDTO): Promise<{
16
+ list(paginationParams: PaginationDTO & {
17
+ type: string;
18
+ status: string;
19
+ }): Promise<{
18
20
  total: any;
19
21
  lastPage: number;
20
22
  page: number;
@@ -39,17 +41,9 @@ export declare class PersonService {
39
41
  updated_at: Date;
40
42
  status: import("@prisma/client").$Enums.person_status_enum;
41
43
  }>;
42
- update({ id, data }: {
43
- id: number;
44
- data: UpdateDTO;
45
- }): Promise<{
46
- name: string;
47
- type: import("@prisma/client").$Enums.person_type_enum;
48
- id: number;
49
- created_at: Date;
50
- updated_at: Date;
51
- status: import("@prisma/client").$Enums.person_status_enum;
44
+ update(id: number, data: any): Promise<{
45
+ success: boolean;
52
46
  }>;
53
- delete({ ids }: DeleteDTO): Promise<import("@prisma/client").Prisma.BatchPayload>;
47
+ delete({ ids }: DeleteDTO): Promise<[import("@prisma/client").Prisma.BatchPayload, import("@prisma/client").Prisma.BatchPayload, import("@prisma/client").Prisma.BatchPayload, import("@prisma/client").Prisma.BatchPayload]>;
54
48
  }
55
49
  //# sourceMappingURL=person.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"person.service.d.ts","sourceRoot":"","sources":["../../src/person/person.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,E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AM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;;;IAoG5B,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;CAoBhC"}
@@ -38,12 +38,27 @@ let PersonService = class PersonService {
38
38
  };
39
39
  }
40
40
  async list(paginationParams) {
41
+ var _a;
41
42
  const OR = [];
42
- if (paginationParams.search && !isNaN(+paginationParams.search)) {
43
- OR.push({ id: { equals: +paginationParams.search } });
43
+ const search = (_a = paginationParams.search) === null || _a === void 0 ? void 0 : _a.trim();
44
+ if (search) {
45
+ if (!isNaN(+search)) {
46
+ OR.push({ id: { equals: +search } });
47
+ }
48
+ OR.push({ name: { contains: search, mode: 'insensitive' } });
49
+ }
50
+ const where = {};
51
+ if (OR.length > 0) {
52
+ where.OR = OR;
53
+ }
54
+ if (paginationParams.type && paginationParams.type !== 'all') {
55
+ where.type = paginationParams.type;
56
+ }
57
+ if (paginationParams.status && paginationParams.status !== 'all') {
58
+ where.status = paginationParams.status;
44
59
  }
45
60
  return this.paginationService.paginate(this.prismaService.person, paginationParams, {
46
- where: OR.length > 0 ? { OR } : {},
61
+ where,
47
62
  include: {
48
63
  address: true,
49
64
  contact: true,
@@ -61,23 +76,116 @@ let PersonService = class PersonService {
61
76
  data,
62
77
  });
63
78
  }
64
- async update({ id, data }) {
65
- return this.prismaService.person.update({
66
- where: { id: id },
67
- data,
79
+ async update(id, data) {
80
+ const incomingContacts = data.contacts || [];
81
+ const incomingAddresses = data.addresses || [];
82
+ const incomingDocuments = data.documents || [];
83
+ const contactPrimaryMap = new Map();
84
+ for (const c of incomingContacts) {
85
+ if (c.is_primary) {
86
+ const key = String(c.contact_type_id);
87
+ contactPrimaryMap.set(key, (contactPrimaryMap.get(key) || 0) + 1);
88
+ }
89
+ }
90
+ for (const [_, count] of contactPrimaryMap.entries()) {
91
+ if (count > 1) {
92
+ throw new common_1.BadRequestException(`Não é permitido mais de um contato do tipo marcado como principal.`);
93
+ }
94
+ }
95
+ const addressPrimaryMap = new Map();
96
+ for (const a of incomingAddresses) {
97
+ if (a.is_primary) {
98
+ const key = String(a.address_type_id);
99
+ addressPrimaryMap.set(key, (addressPrimaryMap.get(key) || 0) + 1);
100
+ }
101
+ }
102
+ for (const [_, count] of addressPrimaryMap.entries()) {
103
+ if (count > 1) {
104
+ throw new common_1.BadRequestException(`Não é permitido mais de um endereço do mesmo tipo marcado como principal.`);
105
+ }
106
+ }
107
+ const documentPrimaryMap = new Map();
108
+ for (const d of incomingDocuments) {
109
+ if (d.is_primary) {
110
+ const key = String(d.document_type_id);
111
+ documentPrimaryMap.set(key, (documentPrimaryMap.get(key) || 0) + 1);
112
+ }
113
+ }
114
+ for (const [_, count] of documentPrimaryMap.entries()) {
115
+ if (count > 1) {
116
+ throw new common_1.BadRequestException(`Não é permitido mais de um documento do mesmo tipo marcado como principal.`);
117
+ }
118
+ }
119
+ return this.prismaService.$transaction(async (tx) => {
120
+ await tx.person.update({
121
+ where: { id },
122
+ data: {
123
+ name: data.name,
124
+ type: data.type,
125
+ status: data.status,
126
+ },
127
+ });
128
+ const existingContacts = await tx.contact.findMany({ where: { person_id: id } });
129
+ for (const c of incomingContacts) {
130
+ if (c.id) {
131
+ await tx.contact.update({ where: { id: c.id }, data: c });
132
+ }
133
+ else {
134
+ await tx.contact.create({ data: Object.assign(Object.assign({}, c), { person_id: id }) });
135
+ }
136
+ }
137
+ for (const old of existingContacts) {
138
+ if (!incomingContacts.find((c) => c.id === old.id)) {
139
+ await tx.contact.delete({ where: { id: old.id } });
140
+ }
141
+ }
142
+ const existingAddresses = await tx.address.findMany({ where: { person_id: id } });
143
+ for (const a of incomingAddresses) {
144
+ if (a.id) {
145
+ await tx.address.update({ where: { id: a.id }, data: a });
146
+ }
147
+ else {
148
+ await tx.address.create({ data: Object.assign(Object.assign({}, a), { person_id: id }) });
149
+ }
150
+ }
151
+ for (const old of existingAddresses) {
152
+ if (!incomingAddresses.find((a) => a.id === old.id)) {
153
+ await tx.address.delete({ where: { id: old.id } });
154
+ }
155
+ }
156
+ const existingDocuments = await tx.document.findMany({ where: { person_id: id } });
157
+ for (const d of incomingDocuments) {
158
+ if (d.id) {
159
+ await tx.document.update({ where: { id: d.id }, data: d });
160
+ }
161
+ else {
162
+ await tx.document.create({ data: Object.assign(Object.assign({}, d), { person_id: id }) });
163
+ }
164
+ }
165
+ for (const old of existingDocuments) {
166
+ if (!incomingDocuments.find((d) => d.id === old.id)) {
167
+ await tx.document.delete({ where: { id: old.id } });
168
+ }
169
+ }
170
+ return { success: true };
68
171
  });
69
172
  }
70
173
  async delete({ ids }) {
71
174
  if (ids == undefined || ids == null) {
72
175
  throw new common_1.BadRequestException('You must select at least one item to delete.');
73
176
  }
74
- return this.prismaService.person.deleteMany({
75
- where: {
76
- id: {
77
- in: ids,
177
+ return this.prismaService.$transaction([
178
+ this.prismaService.contact.deleteMany({ where: { person_id: { in: ids } } }),
179
+ this.prismaService.address.deleteMany({ where: { person_id: { in: ids } } }),
180
+ this.prismaService.document.deleteMany({ where: { person_id: { in: ids } } }),
181
+ this.prismaService.person.deleteMany({
182
+ where: {
183
+ id: {
184
+ in: ids,
185
+ },
78
186
  },
79
- },
80
- });
187
+ }),
188
+ ]);
81
189
  }
82
190
  };
83
191
  exports.PersonService = PersonService;
@@ -1 +1 @@
1
- {"version":3,"file":"person.service.js","sourceRoot":"","sources":["../../src/person/person.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,4DAA2E;AAC3E,oDAAoD;AACpD,2CAKwB;AAKjB,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,QAAQ;QACZ,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACvE,I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Aa,CAmMzB"}
@@ -0,0 +1,3 @@
1
+ -- Adiciona constraint UNIQUE composta para address_type_id e locale_id
2
+ ALTER TABLE address_type_locale
3
+ ADD CONSTRAINT address_type_locale_unique UNIQUE (address_type_id, locale_id);
@@ -0,0 +1,3 @@
1
+ -- Adiciona constraint UNIQUE composta para contact_type_id e locale_id
2
+ ALTER TABLE contact_type_locale
3
+ ADD CONSTRAINT contact_type_locale_unique UNIQUE (contact_type_id, locale_id);
@@ -0,0 +1,3 @@
1
+ -- Adiciona constraint UNIQUE composta para document_type_id e locale_id
2
+ ALTER TABLE document_type_locale
3
+ ADD CONSTRAINT document_type_locale_unique UNIQUE (document_type_id, locale_id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hed-hog/contact",
3
- "version": "0.0.33",
3
+ "version": "0.0.39",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -11,11 +11,11 @@
11
11
  "@nestjs/mapped-types": "*",
12
12
  "@hed-hog/api": "0.0.3",
13
13
  "@hed-hog/api-pagination": "0.0.3",
14
- "@hed-hog/api-locale": "0.0.10",
15
- "@hed-hog/country": "0.0.9",
16
14
  "@hed-hog/api-mail": "0.0.7",
17
15
  "@hed-hog/api-prisma": "0.0.4",
18
- "@hed-hog/admin": "0.0.129"
16
+ "@hed-hog/api-locale": "0.0.10",
17
+ "@hed-hog/admin": "0.0.129",
18
+ "@hed-hog/country": "0.0.9"
19
19
  },
20
20
  "exports": {
21
21
  ".": {
@@ -14,7 +14,7 @@ import { UpdateDTO } from './dto/update.dto';
14
14
  @Injectable()
15
15
  export class PersonAddressTypeService {
16
16
  private readonly modelName = 'address_type';
17
- private readonly foreignKey = 'type_id';
17
+ private readonly foreignKey = 'address_type_id';
18
18
 
19
19
  constructor(
20
20
  @Inject(forwardRef(() => PrismaService))
@@ -14,7 +14,7 @@ import { UpdateDTO } from './dto/update.dto';
14
14
  @Injectable()
15
15
  export class PersonContactTypeService {
16
16
  private readonly modelName = 'contact_type';
17
- private readonly foreignKey = 'type_id';
17
+ private readonly foreignKey = 'contact_type_id';
18
18
 
19
19
  constructor(
20
20
  @Inject(forwardRef(() => PrismaService))
@@ -14,7 +14,7 @@ import { UpdateDTO } from './dto/update.dto';
14
14
  @Injectable()
15
15
  export class PersonDocumentTypeService {
16
16
  private readonly modelName = 'document_type';
17
- private readonly foreignKey = 'type_id';
17
+ private readonly foreignKey = 'document_type_id';
18
18
 
19
19
  constructor(
20
20
  @Inject(forwardRef(() => PrismaService))
@@ -1,4 +1,4 @@
1
- import { IsEnum, IsOptional } from 'class-validator';
1
+ import { IsEnum, IsString } from 'class-validator';
2
2
 
3
3
  export enum PersonType {
4
4
  INDIVIDUAL = 'individual',
@@ -11,10 +11,12 @@ export enum PersonStatus {
11
11
  }
12
12
 
13
13
  export class CreateDTO {
14
+ @IsString()
15
+ name: string;
16
+
14
17
  @IsEnum(PersonType)
15
18
  type: PersonType;
16
19
 
17
- @IsOptional()
18
20
  @IsEnum(PersonStatus)
19
- status?: PersonStatus = PersonStatus.ACTIVE;
21
+ status: PersonStatus = PersonStatus.ACTIVE;
20
22
  }
@@ -1,4 +1,76 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
1
+ import { Type } from 'class-transformer';
2
+ import { IsArray, IsBoolean, IsInt, IsOptional, IsString, ValidateNested } from 'class-validator';
3
3
 
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
4
+ export class UpdateAllContactDTO {
5
+ @IsOptional()
6
+ @IsInt()
7
+ id?: number;
8
+
9
+ @IsString()
10
+ value: string;
11
+
12
+ @IsBoolean()
13
+ is_primary: boolean;
14
+
15
+ @IsInt()
16
+ contact_type_id: number;
17
+ }
18
+
19
+ export class UpdateAllAddressDTO {
20
+ @IsOptional()
21
+ @IsInt()
22
+ id?: number;
23
+
24
+ @IsString()
25
+ line1: string;
26
+
27
+ @IsString()
28
+ city: string;
29
+
30
+ @IsString()
31
+ state: string;
32
+
33
+ @IsBoolean()
34
+ is_primary: boolean;
35
+
36
+ @IsInt()
37
+ address_type_id: number;
38
+ }
39
+
40
+ export class UpdateAllDocumentDTO {
41
+ @IsOptional()
42
+ @IsInt()
43
+ id?: number;
44
+
45
+ @IsString()
46
+ value: string;
47
+
48
+ @IsInt()
49
+ document_type_id: number;
50
+ }
51
+
52
+ export class UpdateAllPersonDTO {
53
+ @IsString()
54
+ name: string;
55
+
56
+ @IsString()
57
+ type: string;
58
+
59
+ @IsString()
60
+ status: string;
61
+
62
+ @IsArray()
63
+ @ValidateNested({ each: true })
64
+ @Type(() => UpdateAllContactDTO)
65
+ contacts: UpdateAllContactDTO[];
66
+
67
+ @IsArray()
68
+ @ValidateNested({ each: true })
69
+ @Type(() => UpdateAllAddressDTO)
70
+ addresses: UpdateAllAddressDTO[];
71
+
72
+ @IsArray()
73
+ @ValidateNested({ each: true })
74
+ @Type(() => UpdateAllDocumentDTO)
75
+ documents: UpdateAllDocumentDTO[];
76
+ }
@@ -1,13 +1,13 @@
1
1
  import { Type } from 'class-transformer';
2
- import { IsDate, IsOptional, IsString } from 'class-validator';
2
+ import { IsDate, IsNotEmpty, IsString } from 'class-validator';
3
3
 
4
4
  export class CreateDTO {
5
- @IsOptional()
5
+ @IsNotEmpty()
6
6
  @IsDate()
7
7
  @Type(() => Date)
8
- foundation_date?: Date;
8
+ foundation_date: Date;
9
9
 
10
- @IsOptional()
10
+ @IsNotEmpty()
11
11
  @IsString()
12
- legal_nature?: string;
12
+ legal_nature: string;
13
13
  }
@@ -27,7 +27,7 @@ export class PersonCompanyController {
27
27
  @Param('personId', ParseIntPipe) personId: number,
28
28
  @Body() data: CreateDTO
29
29
  ) {
30
- return this.personCompanyService.create(personId, data);
30
+ return this.personCompanyService.create(data);
31
31
  }
32
32
 
33
33
  @Get()
@@ -7,12 +7,9 @@ import { UpdateDTO } from './dto/update.dto';
7
7
  export class PersonCompanyService {
8
8
  constructor(private readonly prismaService: PrismaService) {}
9
9
 
10
- async create(personId: number, data: CreateDTO) {
10
+ async create(data: CreateDTO) {
11
11
  return this.prismaService.person_company.create({
12
- data: {
13
- id: personId,
14
- ...data
15
- }
12
+ data
16
13
  });
17
14
  }
18
15
 
@@ -1,19 +1,20 @@
1
1
  import { DeleteDTO, Role } from '@hed-hog/api';
2
2
  import { Pagination } from '@hed-hog/api-pagination';
3
3
  import {
4
- Body,
5
- Controller,
6
- Delete,
7
- Get,
8
- Inject,
9
- Param,
10
- ParseIntPipe,
11
- Patch,
12
- Post,
13
- forwardRef
4
+ Body,
5
+ Controller,
6
+ Delete,
7
+ Get,
8
+ Inject,
9
+ Param,
10
+ ParseIntPipe,
11
+ Patch,
12
+ Post,
13
+ Query,
14
+ forwardRef
14
15
  } from '@nestjs/common';
15
16
  import { CreateDTO } from './dto/create.dto';
16
- import { UpdateDTO } from './dto/update.dto';
17
+ import { UpdateAllPersonDTO } from './dto/update.dto';
17
18
  import { PersonService } from './person.service';
18
19
 
19
20
  @Role()
@@ -30,8 +31,8 @@ export class PersonController {
30
31
  }
31
32
 
32
33
  @Get()
33
- async list(@Pagination() paginationParams) {
34
- return this.personService.list(paginationParams);
34
+ async list(@Pagination() paginationParams, @Query() filters) {
35
+ return this.personService.list({ ...paginationParams, ...filters });
35
36
  }
36
37
 
37
38
  @Get(':id')
@@ -45,11 +46,11 @@ export class PersonController {
45
46
  }
46
47
 
47
48
  @Patch(':id')
48
- async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
49
- return this.personService.update({
50
- id,
51
- data
52
- });
49
+ async update(
50
+ @Param('id', ParseIntPipe) id: number,
51
+ @Body() data: UpdateAllPersonDTO
52
+ ) {
53
+ return this.personService.update(id, data);
53
54
  }
54
55
 
55
56
  @Delete()
@@ -2,13 +2,12 @@ import { DeleteDTO } from '@hed-hog/api';
2
2
  import { PaginationDTO, PaginationService } from '@hed-hog/api-pagination';
3
3
  import { PrismaService } from '@hed-hog/api-prisma';
4
4
  import {
5
- BadRequestException,
6
- Inject,
7
- Injectable,
8
- forwardRef,
5
+ BadRequestException,
6
+ Inject,
7
+ Injectable,
8
+ forwardRef,
9
9
  } from '@nestjs/common';
10
10
  import { CreateDTO } from './dto/create.dto';
11
- import { UpdateDTO } from './dto/update.dto';
12
11
 
13
12
  @Injectable()
14
13
  export class PersonService {
@@ -37,18 +36,34 @@ export class PersonService {
37
36
  };
38
37
  }
39
38
 
40
- async list(paginationParams: PaginationDTO) {
39
+ async list(paginationParams: PaginationDTO & { type: string; status: string }) {
41
40
  const OR: any[] = [];
41
+ const search = paginationParams.search?.trim();
42
42
 
43
- if (paginationParams.search && !isNaN(+paginationParams.search)) {
44
- OR.push({ id: { equals: +paginationParams.search } });
43
+ if (search) {
44
+ if (!isNaN(+search)) {
45
+ OR.push({ id: { equals: +search } });
46
+ }
47
+ OR.push({ name: { contains: search, mode: 'insensitive' } });
48
+ }
49
+
50
+ const where: any = {};
51
+ if (OR.length > 0) {
52
+ where.OR = OR;
53
+ }
54
+
55
+ if (paginationParams.type && paginationParams.type !== 'all') {
56
+ where.type = paginationParams.type;
57
+ }
58
+ if (paginationParams.status && paginationParams.status !== 'all') {
59
+ where.status = paginationParams.status;
45
60
  }
46
61
 
47
62
  return this.paginationService.paginate(
48
63
  this.prismaService.person,
49
64
  paginationParams,
50
65
  {
51
- where: OR.length > 0 ? { OR } : {},
66
+ where,
52
67
  include: {
53
68
  address: true,
54
69
  contact: true,
@@ -70,10 +85,103 @@ export class PersonService {
70
85
  });
71
86
  }
72
87
 
73
- async update({ id, data }: { id: number; data: UpdateDTO }) {
74
- return this.prismaService.person.update({
75
- where: { id: id },
76
- data,
88
+ async update(id: number, data: any) {
89
+ const incomingContacts = data.contacts || [];
90
+ const incomingAddresses = data.addresses || [];
91
+ const incomingDocuments = data.documents || [];
92
+ const contactPrimaryMap = new Map();
93
+ for (const c of incomingContacts) {
94
+ if (c.is_primary) {
95
+ const key = String(c.contact_type_id);
96
+ contactPrimaryMap.set(key, (contactPrimaryMap.get(key) || 0) + 1);
97
+ }
98
+ }
99
+ for (const [_, count] of contactPrimaryMap.entries()) {
100
+ if (count > 1) {
101
+ throw new BadRequestException(`Não é permitido mais de um contato do tipo marcado como principal.`);
102
+ }
103
+ }
104
+
105
+ const addressPrimaryMap = new Map();
106
+ for (const a of incomingAddresses) {
107
+ if (a.is_primary) {
108
+ const key = String(a.address_type_id);
109
+ addressPrimaryMap.set(key, (addressPrimaryMap.get(key) || 0) + 1);
110
+ }
111
+ }
112
+ for (const [_, count] of addressPrimaryMap.entries()) {
113
+ if (count > 1) {
114
+ throw new BadRequestException(`Não é permitido mais de um endereço do mesmo tipo marcado como principal.`);
115
+ }
116
+ }
117
+
118
+ const documentPrimaryMap = new Map();
119
+ for (const d of incomingDocuments) {
120
+ if (d.is_primary) {
121
+ const key = String(d.document_type_id);
122
+ documentPrimaryMap.set(key, (documentPrimaryMap.get(key) || 0) + 1);
123
+ }
124
+ }
125
+ for (const [_, count] of documentPrimaryMap.entries()) {
126
+ if (count > 1) {
127
+ throw new BadRequestException(`Não é permitido mais de um documento do mesmo tipo marcado como principal.`);
128
+ }
129
+ }
130
+
131
+ return this.prismaService.$transaction(async (tx) => {
132
+ await tx.person.update({
133
+ where: { id },
134
+ data: {
135
+ name: data.name,
136
+ type: data.type,
137
+ status: data.status,
138
+ },
139
+ });
140
+
141
+ const existingContacts = await tx.contact.findMany({ where: { person_id: id } });
142
+ for (const c of incomingContacts) {
143
+ if (c.id) {
144
+ await tx.contact.update({ where: { id: c.id }, data: c });
145
+ } else {
146
+ await tx.contact.create({ data: { ...c, person_id: id } });
147
+ }
148
+ }
149
+
150
+ for (const old of existingContacts) {
151
+ if (!incomingContacts.find((c: any) => c.id === old.id)) {
152
+ await tx.contact.delete({ where: { id: old.id } });
153
+ }
154
+ }
155
+
156
+ const existingAddresses = await tx.address.findMany({ where: { person_id: id } });
157
+ for (const a of incomingAddresses) {
158
+ if (a.id) {
159
+ await tx.address.update({ where: { id: a.id }, data: a });
160
+ } else {
161
+ await tx.address.create({ data: { ...a, person_id: id } });
162
+ }
163
+ }
164
+ for (const old of existingAddresses) {
165
+ if (!incomingAddresses.find((a: any) => a.id === old.id)) {
166
+ await tx.address.delete({ where: { id: old.id } });
167
+ }
168
+ }
169
+
170
+ const existingDocuments = await tx.document.findMany({ where: { person_id: id } });
171
+ for (const d of incomingDocuments) {
172
+ if (d.id) {
173
+ await tx.document.update({ where: { id: d.id }, data: d });
174
+ } else {
175
+ await tx.document.create({ data: { ...d, person_id: id } });
176
+ }
177
+ }
178
+ for (const old of existingDocuments) {
179
+ if (!incomingDocuments.find((d: any) => d.id === old.id)) {
180
+ await tx.document.delete({ where: { id: old.id } });
181
+ }
182
+ }
183
+
184
+ return { success: true };
77
185
  });
78
186
  }
79
187
 
@@ -84,12 +192,17 @@ export class PersonService {
84
192
  );
85
193
  }
86
194
 
87
- return this.prismaService.person.deleteMany({
88
- where: {
89
- id: {
90
- in: ids,
195
+ return this.prismaService.$transaction([
196
+ this.prismaService.contact.deleteMany({ where: { person_id: { in: ids } } }),
197
+ this.prismaService.address.deleteMany({ where: { person_id: { in: ids } } }),
198
+ this.prismaService.document.deleteMany({ where: { person_id: { in: ids } } }),
199
+ this.prismaService.person.deleteMany({
200
+ where: {
201
+ id: {
202
+ in: ids,
203
+ },
91
204
  },
92
- },
93
- });
205
+ }),
206
+ ]);
94
207
  }
95
208
  }