@randstad-uca/aws-sns-publisher 1.0.24 → 1.0.26

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.
@@ -29,13 +29,7 @@ export declare const validEventTypes: {
29
29
  setCvBuilderUpdatedDate: string;
30
30
  setCvBuilderDownloadUpdatedDate: string;
31
31
  setAlert: string;
32
- setAltaAfipEstado: string;
33
- setContratoEstado: string;
34
- setLegajoEstado: string;
35
- setSvoEstado: string;
36
- setAdendasEstado: string;
37
- setSeguridadyhigieneEstado: string;
38
- setReciboEstado: string;
32
+ updateDocumentsStatus: string;
39
33
  mail: string;
40
34
  push: string;
41
35
  };
@@ -32,13 +32,7 @@ exports.validEventTypes = {
32
32
  setCvBuilderUpdatedDate: 'set-cv-builder-updated-date',
33
33
  setCvBuilderDownloadUpdatedDate: 'set-cv-builder-download-updated-date',
34
34
  setAlert: 'set-alert',
35
- setAltaAfipEstado: 'set-alta-afip-estado',
36
- setContratoEstado: 'set-contrato-estado',
37
- setLegajoEstado: 'set-legajo-estado',
38
- setSvoEstado: 'set-svo-estado',
39
- setAdendasEstado: 'set-adendas-estado',
40
- setSeguridadyhigieneEstado: 'set-seguridadyhigiene-estado',
41
- setReciboEstado: 'set-recibo-estado',
35
+ updateDocumentsStatus: 'update-documents-status',
42
36
  mail: 'mail',
43
37
  push: 'push',
44
38
  };
@@ -16,7 +16,7 @@ const language_schema_1 = require("./schemas/language.schema");
16
16
  const certification_schema_1 = require("./schemas/certification.schema");
17
17
  const update_event_date_schema_1 = require("./schemas/update-event-date.schema");
18
18
  const alert_schema_1 = require("./schemas/alert.schema");
19
- const document_status_schema_1 = require("./schemas/document-status.schema");
19
+ const update_documents_status_schema_1 = require("./schemas/update-documents-status.schema");
20
20
  const email_schema_1 = require("./schemas/email.schema");
21
21
  const push_schema_1 = require("./schemas/push.schema");
22
22
  const cv_schema_1 = require("./schemas/cv.schema");
@@ -110,33 +110,9 @@ const schemas = {
110
110
  schema: alert_schema_1.SetAlertSchema,
111
111
  label: 'Set Alert',
112
112
  },
113
- [constants_1.validEventTypes.setAdendasEstado]: {
114
- schema: document_status_schema_1.SetDocumentStatusSchema,
115
- label: 'Set Adendas Estado',
116
- },
117
- [constants_1.validEventTypes.setAltaAfipEstado]: {
118
- schema: document_status_schema_1.SetDocumentStatusSchema,
119
- label: 'Set Alta Afip Estado',
120
- },
121
- [constants_1.validEventTypes.setContratoEstado]: {
122
- schema: document_status_schema_1.SetDocumentStatusSchema,
123
- label: 'Set Contrato Estado',
124
- },
125
- [constants_1.validEventTypes.setLegajoEstado]: {
126
- schema: document_status_schema_1.SetDocumentStatusSchema,
127
- label: 'Set Legajo Estado',
128
- },
129
- [constants_1.validEventTypes.setReciboEstado]: {
130
- schema: document_status_schema_1.SetDocumentStatusSchema,
131
- label: 'Set Recibo Estado',
132
- },
133
- [constants_1.validEventTypes.setSeguridadyhigieneEstado]: {
134
- schema: document_status_schema_1.SetDocumentStatusSchema,
135
- label: 'Set Seguridad y Higiene Estado',
136
- },
137
- [constants_1.validEventTypes.setSvoEstado]: {
138
- schema: document_status_schema_1.SetDocumentStatusSchema,
139
- label: 'Set SVO Estado',
113
+ [constants_1.validEventTypes.updateDocumentsStatus]: {
114
+ schema: update_documents_status_schema_1.UpdateDocumentsStatusSchema,
115
+ label: 'Update Documents Status',
140
116
  },
141
117
  [constants_1.validEventTypes.mail]: {
142
118
  schema: email_schema_1.SendEmailSchema,
@@ -28,19 +28,20 @@ class SimpleSNSPublisher {
28
28
  async publish(options) {
29
29
  const { logEnabled, logHandler, logLevel, throwError } = this.options;
30
30
  try {
31
- // Validate message structure
32
31
  const message = JSON.parse(options.message);
33
- if (!message.eventType) {
32
+ const { eventType, payload } = message;
33
+ // Validate message structure
34
+ if (!eventType) {
34
35
  throw new Error('Missing eventType in message');
35
36
  }
36
- else if (!Object.values(constants_1.validEventTypes).includes(message.eventType)) {
37
+ else if (!Object.values(constants_1.validEventTypes).includes(eventType)) {
37
38
  throw new Error('Invalid eventType in message');
38
39
  }
39
- if (!message.payload) {
40
+ if (!payload) {
40
41
  throw new Error('Missing payload in message');
41
42
  }
42
- else if (!(0, validator_1.validateSchema)(message.eventType, message.payload)) {
43
- throw new Error(`Invalid payload for ${message.eventType} event type`);
43
+ else if (!(0, validator_1.validateSchema)(eventType, payload)) {
44
+ throw new Error(`Invalid payload for ${eventType} event type`);
44
45
  }
45
46
  const publishCommandInput = {
46
47
  Message: options.message,
@@ -52,12 +53,21 @@ class SimpleSNSPublisher {
52
53
  if (!constants_1.validApiNames.includes(options.apiName)) {
53
54
  throw new Error('Invalid apiName');
54
55
  }
55
- // Create a unique id for the message
56
- publishCommandInput.MessageDeduplicationId = `${options.apiName}-${(0, uuid_1.v4)()}`;
57
- // Create a group id for the message
58
- publishCommandInput.MessageGroupId = options.apiName
59
- ? `api-${options.apiName}`
60
- : 'default-group';
56
+ const { CanCod: candidateCode } = payload;
57
+ if (candidateCode) {
58
+ // This prevents re-processing the exact same event for the same candidate.
59
+ publishCommandInput.MessageDeduplicationId = `${candidateCode}-${eventType}-${(0, uuid_1.v4)()}`;
60
+ // All updates for a specific candidate (CanCod) will be processed sequentially.
61
+ publishCommandInput.MessageGroupId = candidateCode.toString();
62
+ }
63
+ else {
64
+ // Create a unique id for the message
65
+ publishCommandInput.MessageDeduplicationId = `${options.apiName}-${(0, uuid_1.v4)()}`;
66
+ // Create a group id for the message
67
+ publishCommandInput.MessageGroupId = options.apiName
68
+ ? `api-${options.apiName}`
69
+ : 'default-group';
70
+ }
61
71
  }
62
72
  const params = new client_sns_1.PublishCommand(publishCommandInput);
63
73
  const result = await this.SNSClient.send(params);
@@ -1,6 +1,6 @@
1
1
  export * from './alert.schema';
2
2
  export * from './certification.schema';
3
- export * from './document-status.schema';
3
+ export * from './update-documents-status.schema';
4
4
  export * from './education.schema';
5
5
  export * from './email.schema';
6
6
  export * from './job-application.schema';
@@ -9,6 +9,6 @@ export * from './one-signal.schema';
9
9
  export * from './personal-data.schema';
10
10
  export * from './push.schema';
11
11
  export * from './sms.schema';
12
- export * from './update-documents-state.schema';
12
+ export * from './update-documents-status.schema';
13
13
  export * from './update-event-date.schema';
14
14
  export * from './work-experience.schema';
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./alert.schema"), exports);
18
18
  __exportStar(require("./certification.schema"), exports);
19
- __exportStar(require("./document-status.schema"), exports);
19
+ __exportStar(require("./update-documents-status.schema"), exports);
20
20
  __exportStar(require("./education.schema"), exports);
21
21
  __exportStar(require("./email.schema"), exports);
22
22
  __exportStar(require("./job-application.schema"), exports);
@@ -25,6 +25,6 @@ __exportStar(require("./one-signal.schema"), exports);
25
25
  __exportStar(require("./personal-data.schema"), exports);
26
26
  __exportStar(require("./push.schema"), exports);
27
27
  __exportStar(require("./sms.schema"), exports);
28
- __exportStar(require("./update-documents-state.schema"), exports);
28
+ __exportStar(require("./update-documents-status.schema"), exports);
29
29
  __exportStar(require("./update-event-date.schema"), exports);
30
30
  __exportStar(require("./work-experience.schema"), exports);
@@ -0,0 +1,2 @@
1
+ import Joi from 'joi';
2
+ export declare const UpdateDocumentsStatusSchema: Joi.ObjectSchema<any>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UpdateDocumentsStatusSchema = void 0;
7
+ const joi_1 = __importDefault(require("joi"));
8
+ const constants_1 = require("../constants");
9
+ const statusValues = Object.values(constants_1.validDocumentStatus);
10
+ exports.UpdateDocumentsStatusSchema = joi_1.default.object({
11
+ CanCod: joi_1.default.number().integer().required(),
12
+ altaAfipEstado: joi_1.default.string()
13
+ .valid(...statusValues)
14
+ .optional(),
15
+ contratoEstado: joi_1.default.string()
16
+ .valid(...statusValues)
17
+ .optional(),
18
+ legajoEstado: joi_1.default.string()
19
+ .valid(...statusValues)
20
+ .optional(),
21
+ svoEstado: joi_1.default.string()
22
+ .valid(...statusValues)
23
+ .optional(),
24
+ adendasEstado: joi_1.default.string()
25
+ .valid(...statusValues)
26
+ .optional(),
27
+ seguridadyhigieneEstado: joi_1.default.string()
28
+ .valid(...statusValues)
29
+ .optional(),
30
+ reciboEstado: joi_1.default.string()
31
+ .valid(...statusValues)
32
+ .optional(),
33
+ })
34
+ .unknown(false)
35
+ .meta({ className: 'UpdateDocumentsStatusType' });
@@ -5,7 +5,6 @@
5
5
  export * from './alert.type';
6
6
  export * from './certification.type';
7
7
  export * from './cv.type';
8
- export * from './document-status.type';
9
8
  export * from './education.type';
10
9
  export * from './email.type';
11
10
  export * from './index';
@@ -15,6 +14,6 @@ export * from './one-signal.type';
15
14
  export * from './personal-data.type';
16
15
  export * from './push.type';
17
16
  export * from './sms.type';
18
- export * from './update-documents-state.type';
17
+ export * from './update-documents-status.type';
19
18
  export * from './update-event-date.type';
20
19
  export * from './work-experience.type';
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  __exportStar(require("./alert.type"), exports);
22
22
  __exportStar(require("./certification.type"), exports);
23
23
  __exportStar(require("./cv.type"), exports);
24
- __exportStar(require("./document-status.type"), exports);
25
24
  __exportStar(require("./education.type"), exports);
26
25
  __exportStar(require("./email.type"), exports);
27
26
  __exportStar(require("./index"), exports);
@@ -31,6 +30,6 @@ __exportStar(require("./one-signal.type"), exports);
31
30
  __exportStar(require("./personal-data.type"), exports);
32
31
  __exportStar(require("./push.type"), exports);
33
32
  __exportStar(require("./sms.type"), exports);
34
- __exportStar(require("./update-documents-state.type"), exports);
33
+ __exportStar(require("./update-documents-status.type"), exports);
35
34
  __exportStar(require("./update-event-date.type"), exports);
36
35
  __exportStar(require("./work-experience.type"), exports);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This file was automatically generated by joi-to-typescript
3
+ * Do not modify this file manually
4
+ */
5
+ export interface UpdateDocumentsStatusType {
6
+ CanCod: number;
7
+ adendasEstado?: 'enviado' | 'rechazado' | 'firmado' | 'anulado' | 'pendiente envio' | 'incompleto' | 'pendiente firma';
8
+ altaAfipEstado?: 'enviado' | 'rechazado' | 'firmado' | 'anulado' | 'pendiente envio' | 'incompleto' | 'pendiente firma';
9
+ contratoEstado?: 'enviado' | 'rechazado' | 'firmado' | 'anulado' | 'pendiente envio' | 'incompleto' | 'pendiente firma';
10
+ legajoEstado?: 'enviado' | 'rechazado' | 'firmado' | 'anulado' | 'pendiente envio' | 'incompleto' | 'pendiente firma';
11
+ reciboEstado?: 'enviado' | 'rechazado' | 'firmado' | 'anulado' | 'pendiente envio' | 'incompleto' | 'pendiente firma';
12
+ seguridadyhigieneEstado?: 'enviado' | 'rechazado' | 'firmado' | 'anulado' | 'pendiente envio' | 'incompleto' | 'pendiente firma';
13
+ svoEstado?: 'enviado' | 'rechazado' | 'firmado' | 'anulado' | 'pendiente envio' | 'incompleto' | 'pendiente firma';
14
+ }
@@ -11,10 +11,10 @@ const language_schema_1 = require("./schemas/language.schema");
11
11
  const certification_schema_1 = require("./schemas/certification.schema");
12
12
  const update_event_date_schema_1 = require("./schemas/update-event-date.schema");
13
13
  const alert_schema_1 = require("./schemas/alert.schema");
14
- const document_status_schema_1 = require("./schemas/document-status.schema");
15
14
  const email_schema_1 = require("./schemas/email.schema");
16
15
  const push_schema_1 = require("./schemas/push.schema");
17
16
  const cv_schema_1 = require("./schemas/cv.schema");
17
+ const update_documents_status_schema_1 = require("./schemas/update-documents-status.schema");
18
18
  const validateSchema = (eventType, data) => {
19
19
  let schema;
20
20
  switch (eventType) {
@@ -81,14 +81,8 @@ const validateSchema = (eventType, data) => {
81
81
  case constants_1.validEventTypes.setAlert:
82
82
  schema = alert_schema_1.SetAlertSchema;
83
83
  break;
84
- case constants_1.validEventTypes.setAltaAfipEstado:
85
- case constants_1.validEventTypes.setContratoEstado:
86
- case constants_1.validEventTypes.setLegajoEstado:
87
- case constants_1.validEventTypes.setSvoEstado:
88
- case constants_1.validEventTypes.setAdendasEstado:
89
- case constants_1.validEventTypes.setSeguridadyhigieneEstado:
90
- case constants_1.validEventTypes.setReciboEstado:
91
- schema = document_status_schema_1.SetDocumentStatusSchema;
84
+ case constants_1.validEventTypes.updateDocumentsStatus:
85
+ schema = update_documents_status_schema_1.UpdateDocumentsStatusSchema;
92
86
  break;
93
87
  case constants_1.validEventTypes.mail:
94
88
  schema = email_schema_1.SendEmailSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@randstad-uca/aws-sns-publisher",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "AWS SNS Publisher",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
package/schema-doc.md CHANGED
@@ -312,80 +312,19 @@ This file describes the required and optional fields for each `eventType`.
312
312
 
313
313
  ---
314
314
 
315
- ## Event: `set-adendas-estado` (Set Adendas Estado)
315
+ ## Event: `update-documents-status` (Update Documents Status)
316
316
 
317
317
  **Required fields:**
318
318
  - `CanCod` (number)
319
- - `estado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
320
319
 
321
320
  **Optional fields:**
322
- - *(none)*
323
-
324
- ---
325
-
326
- ## Event: `set-alta-afip-estado` (Set Alta Afip Estado)
327
-
328
- **Required fields:**
329
- - `CanCod` (number)
330
- - `estado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
331
-
332
- **Optional fields:**
333
- - *(none)*
334
-
335
- ---
336
-
337
- ## Event: `set-contrato-estado` (Set Contrato Estado)
338
-
339
- **Required fields:**
340
- - `CanCod` (number)
341
- - `estado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
342
-
343
- **Optional fields:**
344
- - *(none)*
345
-
346
- ---
347
-
348
- ## Event: `set-legajo-estado` (Set Legajo Estado)
349
-
350
- **Required fields:**
351
- - `CanCod` (number)
352
- - `estado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
353
-
354
- **Optional fields:**
355
- - *(none)*
356
-
357
- ---
358
-
359
- ## Event: `set-recibo-estado` (Set Recibo Estado)
360
-
361
- **Required fields:**
362
- - `CanCod` (number)
363
- - `estado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
364
-
365
- **Optional fields:**
366
- - *(none)*
367
-
368
- ---
369
-
370
- ## Event: `set-seguridadyhigiene-estado` (Set Seguridad y Higiene Estado)
371
-
372
- **Required fields:**
373
- - `CanCod` (number)
374
- - `estado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
375
-
376
- **Optional fields:**
377
- - *(none)*
378
-
379
- ---
380
-
381
- ## Event: `set-svo-estado` (Set SVO Estado)
382
-
383
- **Required fields:**
384
- - `CanCod` (number)
385
- - `estado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
386
-
387
- **Optional fields:**
388
- - *(none)*
321
+ - `altaAfipEstado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
322
+ - `contratoEstado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
323
+ - `legajoEstado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
324
+ - `svoEstado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
325
+ - `adendasEstado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
326
+ - `seguridadyhigieneEstado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
327
+ - `reciboEstado` (string) (valid: 'enviado', 'rechazado', 'firmado', 'anulado', 'pendiente envio', 'incompleto', 'pendiente firma')
389
328
 
390
329
  ---
391
330
 
@@ -1,2 +0,0 @@
1
- import Joi from 'joi';
2
- export declare const SetDocumentStatusSchema: Joi.ObjectSchema<any>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SetDocumentStatusSchema = void 0;
7
- const joi_1 = __importDefault(require("joi"));
8
- const constants_1 = require("../constants");
9
- const statusValues = Object.values(constants_1.validDocumentStatus);
10
- exports.SetDocumentStatusSchema = joi_1.default.object({
11
- CanCod: joi_1.default.number().integer().required(),
12
- estado: joi_1.default.string()
13
- .valid(...statusValues)
14
- .required(),
15
- })
16
- .unknown(false)
17
- .meta({ className: 'SetDocumentStatusType' });
@@ -1,2 +0,0 @@
1
- import Joi from 'joi';
2
- export declare const UpdateDocumentsStateSchema: Joi.ObjectSchema<any>;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UpdateDocumentsStateSchema = void 0;
7
- const joi_1 = __importDefault(require("joi"));
8
- exports.UpdateDocumentsStateSchema = joi_1.default.object({
9
- altaAfip: joi_1.default.string().optional(),
10
- contrato: joi_1.default.string().optional(),
11
- legajo: joi_1.default.string().optional(),
12
- svo: joi_1.default.string().optional(),
13
- adendas: joi_1.default.string().optional(),
14
- seguridadyhigiene: joi_1.default.string().optional(),
15
- recibo: joi_1.default.string().optional(),
16
- })
17
- .unknown(false)
18
- .meta({ className: 'UpdateDocumentsStateType' });
@@ -1,8 +0,0 @@
1
- /**
2
- * This file was automatically generated by joi-to-typescript
3
- * Do not modify this file manually
4
- */
5
- export interface SetDocumentStatusType {
6
- CanCod: number;
7
- estado: 'enviado' | 'rechazado' | 'firmado' | 'anulado' | 'pendiente envio' | 'incompleto' | 'pendiente firma';
8
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * This file was automatically generated by joi-to-typescript
3
- * Do not modify this file manually
4
- */
5
- export interface UpdateDocumentsStateType {
6
- adendas?: string;
7
- altaAfip?: string;
8
- contrato?: string;
9
- legajo?: string;
10
- recibo?: string;
11
- seguridadyhigiene?: string;
12
- svo?: string;
13
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- /**
3
- * This file was automatically generated by joi-to-typescript
4
- * Do not modify this file manually
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });