@randstad-uca/aws-sns-publisher 1.2.1 → 1.2.3

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.
@@ -31,6 +31,7 @@ export declare const validEventTypes: {
31
31
  mail: string;
32
32
  push: string;
33
33
  addUserIdentity: string;
34
+ deleteOneSignalUser: string;
34
35
  };
35
36
  export declare const validDocumentStatus: {
36
37
  enviado: string;
@@ -34,6 +34,7 @@ exports.validEventTypes = {
34
34
  mail: 'mail',
35
35
  push: 'push',
36
36
  addUserIdentity: 'add-user-identity',
37
+ deleteOneSignalUser: 'delete-one-signal-user',
37
38
  };
38
39
  exports.validDocumentStatus = {
39
40
  enviado: 'enviado',
@@ -20,6 +20,7 @@ const email_schema_1 = require("./schemas/email.schema");
20
20
  const push_schema_1 = require("./schemas/push.schema");
21
21
  const cv_schema_1 = require("./schemas/cv.schema");
22
22
  const user_identity_schema_1 = require("./schemas/user-identity.schema");
23
+ const one_signal_schema_1 = require("./schemas/one-signal.schema");
23
24
  const schemas = {
24
25
  [constants_1.validEventTypes.sms]: { schema: sms_schema_1.SMSSchema, label: 'SMS' },
25
26
  [constants_1.validEventTypes.updatePersonalData]: {
@@ -114,6 +115,10 @@ const schemas = {
114
115
  schema: user_identity_schema_1.AddUserIdentitySchema,
115
116
  label: 'Add User Identity',
116
117
  },
118
+ [constants_1.validEventTypes.deleteOneSignalUser]: {
119
+ schema: one_signal_schema_1.DeleteOneSignalUserSchema,
120
+ label: 'Delete OneSignal User',
121
+ },
117
122
  };
118
123
  function getFieldsFromJoi(schema) {
119
124
  const description = schema.describe();
@@ -5,11 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.UpdateCertificationsSchema = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
- const userId = joi_1.default.string().uuid().required();
9
- const certificaciones = joi_1.default.string().valid('si', 'no').required();
10
8
  exports.UpdateCertificationsSchema = joi_1.default.object({
11
- userId,
12
- certificaciones,
9
+ userId: joi_1.default.string().uuid().required(),
10
+ certificaciones: joi_1.default.string().valid('si', 'no').required(),
11
+ fechaActualizacionPerfil: joi_1.default.date().timestamp('javascript').required(),
13
12
  })
14
13
  .unknown(false)
15
14
  .meta({ className: 'UpdateCertificationsType' });
@@ -8,6 +8,7 @@ const joi_1 = __importDefault(require("joi"));
8
8
  exports.SetCvSchema = joi_1.default.object({
9
9
  userId: joi_1.default.string().uuid().required(),
10
10
  cvAdjunto: joi_1.default.string().valid('si', 'no').required(),
11
+ fechaActualizacionPerfil: joi_1.default.date().timestamp('javascript').required(),
11
12
  })
12
13
  .unknown(false)
13
14
  .meta({ className: 'SetCvType' });
@@ -14,12 +14,14 @@ const estado = joi_1.default.string()
14
14
  .valid('completo', 'incompleto', 'en curso')
15
15
  .required();
16
16
  const nivelMaximo = joi_1.default.number().integer().min(1).required();
17
+ const fechaActualizacionPerfil = joi_1.default.date().timestamp('javascript').required();
17
18
  const baseFields = {
18
19
  userId,
19
20
  nivel,
20
21
  area,
21
22
  estado,
22
23
  nivelMaximo,
24
+ fechaActualizacionPerfil,
23
25
  };
24
26
  exports.AddEducationSchema = joi_1.default.object(baseFields)
25
27
  .unknown(false)
@@ -5,18 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DeleteLanguageSchema = exports.UpdateLanguageSchema = exports.AddLanguageSchema = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
- const idioma = joi_1.default.string().min(1).max(50).required();
9
8
  const baseFields = {
10
9
  userId: joi_1.default.string().uuid().required(),
11
10
  nivelMaximo: joi_1.default.number().integer().min(1).required(),
12
- idioma,
11
+ idioma: joi_1.default.string().min(1).max(50).required(),
12
+ fechaActualizacionPerfil: joi_1.default.date().timestamp('javascript').required(),
13
13
  };
14
14
  exports.AddLanguageSchema = joi_1.default.object(baseFields)
15
15
  .unknown(false)
16
16
  .meta({ className: 'AddLanguageType' });
17
17
  exports.UpdateLanguageSchema = joi_1.default.object({
18
18
  ...baseFields,
19
- prevIdioma: idioma,
19
+ prevIdioma: baseFields.idioma,
20
20
  })
21
21
  .unknown(false)
22
22
  .meta({ className: 'UpdateLanguageType' });
@@ -1,3 +1,4 @@
1
1
  import Joi from 'joi';
2
2
  export declare const SubscriptionSchema: Joi.ObjectSchema<any>;
3
3
  export declare const TagsTypeSchema: Joi.ObjectSchema<any>;
4
+ export declare const DeleteOneSignalUserSchema: Joi.ObjectSchema<any>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TagsTypeSchema = exports.SubscriptionSchema = void 0;
6
+ exports.DeleteOneSignalUserSchema = exports.TagsTypeSchema = exports.SubscriptionSchema = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
8
  exports.SubscriptionSchema = joi_1.default.object({
9
9
  id: joi_1.default.string().uuid().optional(),
@@ -30,3 +30,8 @@ exports.TagsTypeSchema = joi_1.default.object()
30
30
  .pattern(joi_1.default.string(), joi_1.default.any())
31
31
  .optional()
32
32
  .meta({ className: 'TagsType' });
33
+ exports.DeleteOneSignalUserSchema = joi_1.default.object({
34
+ userId: joi_1.default.string().uuid().required(),
35
+ })
36
+ .unknown(false)
37
+ .meta({ className: 'DeleteOneSignalUserType' });
@@ -22,6 +22,7 @@ const baseFields = {
22
22
  .message('phone number must be in E.164 format (e.g., +5491234567890)')
23
23
  .optional(),
24
24
  subscriptions: one_signal_schema_1.SubscriptionSchema.optional(),
25
+ fechaActualizacionPerfil: joi_1.default.date().timestamp('javascript').required(),
25
26
  };
26
27
  exports.UpdatePersonalDataSchema = joi_1.default.object(baseFields)
27
28
  .unknown(false)
@@ -10,12 +10,14 @@ const puesto = joi_1.default.string().min(1).max(45).required();
10
10
  const area = joi_1.default.string().min(1).max(45).required();
11
11
  const rubro = joi_1.default.string().min(1).max(45).required();
12
12
  const nivelMaximo = joi_1.default.number().integer().min(1).required();
13
+ const fechaActualizacionPerfil = joi_1.default.date().timestamp('javascript').required();
13
14
  const baseFields = {
14
15
  userId,
15
16
  puesto,
16
17
  area,
17
18
  rubro,
18
19
  nivelMaximo,
20
+ fechaActualizacionPerfil,
19
21
  };
20
22
  exports.AddWorkExperienceSchema = joi_1.default.object(baseFields)
21
23
  .unknown(false)
@@ -4,5 +4,6 @@
4
4
  */
5
5
  export interface UpdateCertificationsType {
6
6
  certificaciones: 'si' | 'no';
7
+ fechaActualizacionPerfil: Date;
7
8
  userId: string;
8
9
  }
@@ -4,5 +4,6 @@
4
4
  */
5
5
  export interface SetCvType {
6
6
  cvAdjunto: 'si' | 'no';
7
+ fechaActualizacionPerfil: Date;
7
8
  userId: string;
8
9
  }
@@ -5,6 +5,7 @@
5
5
  export interface AddEducationType {
6
6
  area?: string;
7
7
  estado: 'completo' | 'incompleto' | 'en curso';
8
+ fechaActualizacionPerfil: Date;
8
9
  nivel: 'primario' | 'secundario' | 'terciario' | 'universitario' | 'posgrado' | 'master' | 'doctorado';
9
10
  nivelMaximo: number;
10
11
  userId: string;
@@ -12,6 +13,7 @@ export interface AddEducationType {
12
13
  export interface DeleteEducationType {
13
14
  area?: string;
14
15
  estado: 'completo' | 'incompleto' | 'en curso';
16
+ fechaActualizacionPerfil: Date;
15
17
  nivel: 'primario' | 'secundario' | 'terciario' | 'universitario' | 'posgrado' | 'master' | 'doctorado';
16
18
  nivelMaximo: number;
17
19
  userId: string;
@@ -19,6 +21,7 @@ export interface DeleteEducationType {
19
21
  export interface UpdateEducationType {
20
22
  area?: string;
21
23
  estado: 'completo' | 'incompleto' | 'en curso';
24
+ fechaActualizacionPerfil: Date;
22
25
  nivel: 'primario' | 'secundario' | 'terciario' | 'universitario' | 'posgrado' | 'master' | 'doctorado';
23
26
  nivelMaximo: number;
24
27
  prevArea?: string;
@@ -3,16 +3,19 @@
3
3
  * Do not modify this file manually
4
4
  */
5
5
  export interface AddLanguageType {
6
+ fechaActualizacionPerfil: Date;
6
7
  idioma: string;
7
8
  nivelMaximo: number;
8
9
  userId: string;
9
10
  }
10
11
  export interface DeleteLanguageType {
12
+ fechaActualizacionPerfil: Date;
11
13
  idioma: string;
12
14
  nivelMaximo: number;
13
15
  userId: string;
14
16
  }
15
17
  export interface UpdateLanguageType {
18
+ fechaActualizacionPerfil: Date;
16
19
  idioma: string;
17
20
  nivelMaximo: number;
18
21
  prevIdioma: string;
@@ -2,6 +2,9 @@
2
2
  * This file was automatically generated by joi-to-typescript
3
3
  * Do not modify this file manually
4
4
  */
5
+ export interface DeleteOneSignalUserType {
6
+ userId: string;
7
+ }
5
8
  export interface SubscriptionType {
6
9
  app_id?: string;
7
10
  app_version: string;
@@ -8,6 +8,7 @@ export interface DeletePersonalDataType {
8
8
  }
9
9
  export interface UpdatePersonalDataType {
10
10
  email?: string;
11
+ fechaActualizacionPerfil: Date;
11
12
  fechaNacimiento?: Date;
12
13
  genero?: 'M' | 'F' | 'N';
13
14
  localidad?: string;
@@ -9,6 +9,7 @@ export interface AddUserIdentityType {
9
9
  cvAdjunto: 'si' | 'no';
10
10
  educations: AddEducationType[];
11
11
  email?: string;
12
+ fechaActualizacionPerfil: Date;
12
13
  fechaNacimiento?: Date;
13
14
  genero?: 'M' | 'F' | 'N';
14
15
  jobApplications: AddJobApplicationType[];
@@ -4,6 +4,7 @@
4
4
  */
5
5
  export interface AddWorkExperienceType {
6
6
  area: string;
7
+ fechaActualizacionPerfil: Date;
7
8
  nivelMaximo: number;
8
9
  puesto: string;
9
10
  rubro: string;
@@ -11,6 +12,7 @@ export interface AddWorkExperienceType {
11
12
  }
12
13
  export interface DeleteWorkExperienceType {
13
14
  area: string;
15
+ fechaActualizacionPerfil: Date;
14
16
  nivelMaximo: number;
15
17
  puesto: string;
16
18
  rubro: string;
@@ -18,6 +20,7 @@ export interface DeleteWorkExperienceType {
18
20
  }
19
21
  export interface UpdateWorkExperienceType {
20
22
  area: string;
23
+ fechaActualizacionPerfil: Date;
21
24
  nivelMaximo: number;
22
25
  prevArea: string;
23
26
  prevPuesto: string;
@@ -16,6 +16,7 @@ const push_schema_1 = require("./schemas/push.schema");
16
16
  const cv_schema_1 = require("./schemas/cv.schema");
17
17
  const update_documents_status_schema_1 = require("./schemas/update-documents-status.schema");
18
18
  const user_identity_schema_1 = require("./schemas/user-identity.schema");
19
+ const one_signal_schema_1 = require("./schemas/one-signal.schema");
19
20
  const validateSchema = (eventType, data) => {
20
21
  let schema;
21
22
  switch (eventType) {
@@ -90,6 +91,9 @@ const validateSchema = (eventType, data) => {
90
91
  case constants_1.validEventTypes.addUserIdentity:
91
92
  schema = user_identity_schema_1.AddUserIdentitySchema;
92
93
  break;
94
+ case constants_1.validEventTypes.deleteOneSignalUser:
95
+ schema = one_signal_schema_1.DeleteOneSignalUserSchema;
96
+ break;
93
97
  default:
94
98
  console.error(`Unknown event type: ${eventType}`);
95
99
  return false;
package/package.json CHANGED
@@ -1,50 +1,50 @@
1
- {
2
- "name": "@randstad-uca/aws-sns-publisher",
3
- "version": "1.2.1",
4
- "description": "AWS SNS Publisher",
5
- "main": "./build/index.js",
6
- "types": "./build/index.d.ts",
7
- "files": [
8
- "build/**/*",
9
- "schema-doc.md"
10
- ],
11
- "scripts": {
12
- "clean": "rimraf build",
13
- "build": "npm run clean && npx tsc",
14
- "test": "echo \"No tests implemented yet\" && exit 0",
15
- "prepublishOnly": "npm run test && npm run generate-types && npm run generate-doc && npm run build",
16
- "pub": "npm publish",
17
- "generate-doc": "ts-node ./src/generate-schema-doc.ts",
18
- "generate-types": "ts-node ./src/generate-types.ts"
19
- },
20
- "keywords": [
21
- "aws",
22
- "sns",
23
- "publisher"
24
- ],
25
- "author": "Facundo Brusa",
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/randstad-argentina/aws-sns-publisher.git"
29
- },
30
- "bugs": {
31
- "url": "https://github.com/randstad-argentina/aws-sns-publisher/issues"
32
- },
33
- "homepage": "https://github.com/randstad-argentina/aws-sns-publisher#readme",
34
- "license": "ISC",
35
- "publishConfig": {
36
- "access": "public"
37
- },
38
- "devDependencies": {
39
- "@types/node": "^22.15.17",
40
- "joi-to-typescript": "^4.15.0",
41
- "rimraf": "^6.0.1",
42
- "ts-node": "^10.9.2",
43
- "typescript": "^5.7.3"
44
- },
45
- "dependencies": {
46
- "@aws-sdk/client-sns": "^3.741.0",
47
- "joi": "^17.13.3",
48
- "uuid": "^11.0.5"
49
- }
50
- }
1
+ {
2
+ "name": "@randstad-uca/aws-sns-publisher",
3
+ "version": "1.2.3",
4
+ "description": "AWS SNS Publisher",
5
+ "main": "./build/index.js",
6
+ "types": "./build/index.d.ts",
7
+ "files": [
8
+ "build/**/*",
9
+ "schema-doc.md"
10
+ ],
11
+ "scripts": {
12
+ "clean": "rimraf build",
13
+ "build": "npm run clean && npx tsc",
14
+ "test": "echo \"No tests implemented yet\" && exit 0",
15
+ "prepublishOnly": "npm run test && npm run generate-types && npm run generate-doc && npm run build",
16
+ "pub": "npm publish",
17
+ "generate-doc": "ts-node ./src/generate-schema-doc.ts",
18
+ "generate-types": "ts-node ./src/generate-types.ts"
19
+ },
20
+ "keywords": [
21
+ "aws",
22
+ "sns",
23
+ "publisher"
24
+ ],
25
+ "author": "Facundo Brusa",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/randstad-argentina/aws-sns-publisher.git"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/randstad-argentina/aws-sns-publisher/issues"
32
+ },
33
+ "homepage": "https://github.com/randstad-argentina/aws-sns-publisher#readme",
34
+ "license": "ISC",
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^22.15.17",
40
+ "joi-to-typescript": "^4.15.0",
41
+ "rimraf": "^6.0.1",
42
+ "ts-node": "^10.9.2",
43
+ "typescript": "^5.7.3"
44
+ },
45
+ "dependencies": {
46
+ "@aws-sdk/client-sns": "^3.741.0",
47
+ "joi": "^17.13.3",
48
+ "uuid": "^11.0.5"
49
+ }
50
+ }
package/readme.md CHANGED
@@ -1,156 +1,156 @@
1
- # @randstad-uca/aws-sns-publisher
2
-
3
- ---
4
-
5
- Es una librería ligera desarrollada en Node.js para publicar mensajes a Amazon SNS de forma simple, validada y con logging configurable. Ideal para sistemas desacoplados y orientados a eventos en entornos AWS.
6
-
7
- ---
8
-
9
- ## 📦 Instalación
10
-
11
- ```bash
12
- npm install @randstad-uca/aws-sns-publisher
13
- ```
14
-
15
- ---
16
-
17
- ## 🚀 Uso Básico
18
-
19
- ```js
20
- import { SimpleSNSPublisher } from '@randstad-uca/aws-sns-publisher';
21
-
22
- const SNSClient = new SimpleSNSPublisher({
23
- awsConfig: { region: 'us-east-1' }, // required obj
24
- logEnabled: true, // optional (default value: true)
25
- logLevel: 'info', // optional (default value: info)
26
- throwError: true, // optional (default value: true)
27
- logHandler: {
28
- // You can implement your own logging handler here (optional)
29
- info: (args) =>
30
- // success case
31
- console.log('Custom success logging handler logic', args),
32
- error: (args) =>
33
- // error case
34
- console.error('Custom error logging handler logic', args),
35
- },
36
- });
37
-
38
- const payload = {
39
- eventType: 'sms',
40
- payload: {
41
- phone: '+543564123123',
42
- message: 'Hello there!',
43
- },
44
- };
45
-
46
- SNSClient.publish({
47
- message: JSON.stringify(payload),
48
- topicARN: 'your-sns-topic-ARN',
49
- apiName: 'api-name', // If the topic type is FIFO you must define a valid apiName
50
- })
51
- .then((result) => console.log('Success:', result))
52
- .catch((err) => console.error('Error:', err));
53
- ```
54
-
55
- ---
56
-
57
- ## 📘 API
58
-
59
- #### Clase: `SimpleSNSPublisher`
60
-
61
- ##### Constructor
62
- ```js
63
- new SimpleSNSPublisher(options: IPublisherOptions)
64
- ```
65
-
66
- `IPublisherOptions:`
67
-
68
- - `awsConfig: SNSClientConfig` – **Requerido**. Como minimo se debe especificar la región de AWS para instanciar el cliente SNS.
69
-
70
- - `logEnabled?: boolean` – Habilita logs. Default: `true`.
71
-
72
- - `logLevel?: 'info' | 'silent'` – Nivel de log. Default: `'info'`.
73
-
74
- - `throwError?: boolean` – Si lanzar errores o no. Default: `true`.
75
-
76
- - `logHandler?: { info: Function; error: Function }` – Handler personalizado para logs.
77
-
78
- ---
79
-
80
- ## ✨ Metodos
81
-
82
- #### Método: `publish(options: IPublishOptions): Promise<PublishResponse>`
83
-
84
- Publica un mensaje en un topic SNS. Antes de enviar el mensaje, se valida su estructura usando la libreria `Joi`.
85
-
86
- `IPublishOptions`:
87
-
88
- - `message: string` – Debe ser un string que contenga un objeto, y este **debe** tener las siguientes propiedades:
89
-
90
- - `eventType: string` – Tipo del evento (ej: `"sms"`, `"add-personal-data"` o cualquiera que se encuentre dentro del objeto ***validEventTypes*** ubicado en el archivo `constants.ts`).
91
-
92
- - `payload: object` – Objeto con los datos del evento.
93
-
94
- - `topicARN: string` – ARN del SNS Topic.
95
-
96
- - `apiName?: string` – Nombre de la API emisora, las unicas validas son las que se encuentran dentro del objeto ***validApiNames*** ubicado en el archivo `constants.ts`.
97
- <span style="color: red;">Esta se utiliza como bandera para la creación del MessageDeduplicationId y MessageGroupId necesarios en topics FIFO.</span>
98
-
99
-
100
- - `extraOptions?: object` – Parámetros adicionales para `PublishCommand`.
101
-
102
- **Validaciones automáticas:**
103
-
104
- - `eventType` es obligatorio y debe estar en la lista de eventos válidos.
105
-
106
- - Se valida el `payload` según el tipo de evento con esquemas Joi definidos internamente.
107
-
108
- - Si se configura `throwError: true`, lanza error. Si no, devuelve `Promise.reject()` con el error.
109
-
110
-
111
- #### Método: `validateSchema(eventType: string, payload: object): boolean`
112
-
113
- Valida el `payload` contra el esquema correspondiente según eventType.
114
-
115
- ---
116
-
117
- ### 📎 Ejemplo de payload válido
118
-
119
- ```json
120
- {
121
- "eventType": "email",
122
- "payload": {
123
- "to": "user@example.com",
124
- "subject": "Hello!",
125
- "body": "This is an example email."
126
- }
127
- }
128
- ```
129
-
130
- ---
131
-
132
- ## 📄 Schema Documentation
133
-
134
- See [schema-doc.md](./schema-doc.md) for a full list of event types and their schema fields
135
-
136
- ---
137
-
138
- 🧩 Características
139
-
140
- - ✅ Compatible con múltiples regiones AWS.
141
-
142
- - ✅ Validación automática con Joi.
143
-
144
- - ✅ Logging personalizable (info y error).
145
-
146
- - ✅ Ideal para arquitectura orientada a eventos.
147
-
148
- ---
149
-
150
- 📌 Consideraciones
151
-
152
- - Se espera que los topics estén previamente creados en SNS.
153
-
154
- - Esta librería no crea los topics automáticamente.
155
-
156
- - <span style="color:red">En caso de usar topics FIFO, es importante pasar un `apiName` **valido** para deduplicación.</span>
1
+ # @randstad-uca/aws-sns-publisher
2
+
3
+ ---
4
+
5
+ Es una librería ligera desarrollada en Node.js para publicar mensajes a Amazon SNS de forma simple, validada y con logging configurable. Ideal para sistemas desacoplados y orientados a eventos en entornos AWS.
6
+
7
+ ---
8
+
9
+ ## 📦 Instalación
10
+
11
+ ```bash
12
+ npm install @randstad-uca/aws-sns-publisher
13
+ ```
14
+
15
+ ---
16
+
17
+ ## 🚀 Uso Básico
18
+
19
+ ```js
20
+ import { SimpleSNSPublisher } from '@randstad-uca/aws-sns-publisher';
21
+
22
+ const SNSClient = new SimpleSNSPublisher({
23
+ awsConfig: { region: 'us-east-1' }, // required obj
24
+ logEnabled: true, // optional (default value: true)
25
+ logLevel: 'info', // optional (default value: info)
26
+ throwError: true, // optional (default value: true)
27
+ logHandler: {
28
+ // You can implement your own logging handler here (optional)
29
+ info: (args) =>
30
+ // success case
31
+ console.log('Custom success logging handler logic', args),
32
+ error: (args) =>
33
+ // error case
34
+ console.error('Custom error logging handler logic', args),
35
+ },
36
+ });
37
+
38
+ const payload = {
39
+ eventType: 'sms',
40
+ payload: {
41
+ phone: '+543564123123',
42
+ message: 'Hello there!',
43
+ },
44
+ };
45
+
46
+ SNSClient.publish({
47
+ message: JSON.stringify(payload),
48
+ topicARN: 'your-sns-topic-ARN',
49
+ apiName: 'api-name', // If the topic type is FIFO you must define a valid apiName
50
+ })
51
+ .then((result) => console.log('Success:', result))
52
+ .catch((err) => console.error('Error:', err));
53
+ ```
54
+
55
+ ---
56
+
57
+ ## 📘 API
58
+
59
+ #### Clase: `SimpleSNSPublisher`
60
+
61
+ ##### Constructor
62
+ ```js
63
+ new SimpleSNSPublisher(options: IPublisherOptions)
64
+ ```
65
+
66
+ `IPublisherOptions:`
67
+
68
+ - `awsConfig: SNSClientConfig` – **Requerido**. Como minimo se debe especificar la región de AWS para instanciar el cliente SNS.
69
+
70
+ - `logEnabled?: boolean` – Habilita logs. Default: `true`.
71
+
72
+ - `logLevel?: 'info' | 'silent'` – Nivel de log. Default: `'info'`.
73
+
74
+ - `throwError?: boolean` – Si lanzar errores o no. Default: `true`.
75
+
76
+ - `logHandler?: { info: Function; error: Function }` – Handler personalizado para logs.
77
+
78
+ ---
79
+
80
+ ## ✨ Metodos
81
+
82
+ #### Método: `publish(options: IPublishOptions): Promise<PublishResponse>`
83
+
84
+ Publica un mensaje en un topic SNS. Antes de enviar el mensaje, se valida su estructura usando la libreria `Joi`.
85
+
86
+ `IPublishOptions`:
87
+
88
+ - `message: string` – Debe ser un string que contenga un objeto, y este **debe** tener las siguientes propiedades:
89
+
90
+ - `eventType: string` – Tipo del evento (ej: `"sms"`, `"add-personal-data"` o cualquiera que se encuentre dentro del objeto ***validEventTypes*** ubicado en el archivo `constants.ts`).
91
+
92
+ - `payload: object` – Objeto con los datos del evento.
93
+
94
+ - `topicARN: string` – ARN del SNS Topic.
95
+
96
+ - `apiName?: string` – Nombre de la API emisora, las unicas validas son las que se encuentran dentro del objeto ***validApiNames*** ubicado en el archivo `constants.ts`.
97
+ <span style="color: red;">Esta se utiliza como bandera para la creación del MessageDeduplicationId y MessageGroupId necesarios en topics FIFO.</span>
98
+
99
+
100
+ - `extraOptions?: object` – Parámetros adicionales para `PublishCommand`.
101
+
102
+ **Validaciones automáticas:**
103
+
104
+ - `eventType` es obligatorio y debe estar en la lista de eventos válidos.
105
+
106
+ - Se valida el `payload` según el tipo de evento con esquemas Joi definidos internamente.
107
+
108
+ - Si se configura `throwError: true`, lanza error. Si no, devuelve `Promise.reject()` con el error.
109
+
110
+
111
+ #### Método: `validateSchema(eventType: string, payload: object): boolean`
112
+
113
+ Valida el `payload` contra el esquema correspondiente según eventType.
114
+
115
+ ---
116
+
117
+ ### 📎 Ejemplo de payload válido
118
+
119
+ ```json
120
+ {
121
+ "eventType": "email",
122
+ "payload": {
123
+ "to": "user@example.com",
124
+ "subject": "Hello!",
125
+ "body": "This is an example email."
126
+ }
127
+ }
128
+ ```
129
+
130
+ ---
131
+
132
+ ## 📄 Schema Documentation
133
+
134
+ See [schema-doc.md](./schema-doc.md) for a full list of event types and their schema fields
135
+
136
+ ---
137
+
138
+ 🧩 Características
139
+
140
+ - ✅ Compatible con múltiples regiones AWS.
141
+
142
+ - ✅ Validación automática con Joi.
143
+
144
+ - ✅ Logging personalizable (info y error).
145
+
146
+ - ✅ Ideal para arquitectura orientada a eventos.
147
+
148
+ ---
149
+
150
+ 📌 Consideraciones
151
+
152
+ - Se espera que los topics estén previamente creados en SNS.
153
+
154
+ - Esta librería no crea los topics automáticamente.
155
+
156
+ - <span style="color:red">En caso de usar topics FIFO, es importante pasar un `apiName` **valido** para deduplicación.</span>
package/schema-doc.md CHANGED
@@ -18,6 +18,7 @@ This file describes the required and optional fields for each `eventType`.
18
18
 
19
19
  **Required fields:**
20
20
  - `userId` (string)
21
+ - `fechaActualizacionPerfil` (date)
21
22
 
22
23
  **Optional fields:**
23
24
  - `email` (string)
@@ -48,6 +49,7 @@ This file describes the required and optional fields for each `eventType`.
48
49
  - `nivel` (string) (valid: 'primario', 'secundario', 'terciario', 'universitario', 'posgrado', 'master', 'doctorado')
49
50
  - `estado` (string) (valid: 'completo', 'incompleto', 'en curso')
50
51
  - `nivelMaximo` (number)
52
+ - `fechaActualizacionPerfil` (date)
51
53
 
52
54
  **Optional fields:**
53
55
  - `area` (string)
@@ -61,6 +63,7 @@ This file describes the required and optional fields for each `eventType`.
61
63
  - `nivel` (string) (valid: 'primario', 'secundario', 'terciario', 'universitario', 'posgrado', 'master', 'doctorado')
62
64
  - `estado` (string) (valid: 'completo', 'incompleto', 'en curso')
63
65
  - `nivelMaximo` (number)
66
+ - `fechaActualizacionPerfil` (date)
64
67
  - `prevNivel` (string) (valid: 'primario', 'secundario', 'terciario', 'universitario', 'posgrado', 'master', 'doctorado')
65
68
  - `prevEstado` (string) (valid: 'completo', 'incompleto', 'en curso')
66
69
 
@@ -77,23 +80,13 @@ This file describes the required and optional fields for each `eventType`.
77
80
  - `nivel` (string) (valid: 'primario', 'secundario', 'terciario', 'universitario', 'posgrado', 'master', 'doctorado')
78
81
  - `estado` (string) (valid: 'completo', 'incompleto', 'en curso')
79
82
  - `nivelMaximo` (number)
83
+ - `fechaActualizacionPerfil` (date)
80
84
 
81
85
  **Optional fields:**
82
86
  - `area` (string)
83
87
 
84
88
  ---
85
89
 
86
- ## Event: `update-certifications` (Update Certifications)
87
-
88
- **Required fields:**
89
- - `userId` (string)
90
- - `certificaciones` (string) (valid: 'si', 'no')
91
-
92
- **Optional fields:**
93
- - *(none)*
94
-
95
- ---
96
-
97
90
  ## Event: `add-work-experience` (Add Work Experience)
98
91
 
99
92
  **Required fields:**
@@ -102,6 +95,7 @@ This file describes the required and optional fields for each `eventType`.
102
95
  - `area` (string)
103
96
  - `rubro` (string)
104
97
  - `nivelMaximo` (number)
98
+ - `fechaActualizacionPerfil` (date)
105
99
 
106
100
  **Optional fields:**
107
101
  - *(none)*
@@ -116,6 +110,7 @@ This file describes the required and optional fields for each `eventType`.
116
110
  - `area` (string)
117
111
  - `rubro` (string)
118
112
  - `nivelMaximo` (number)
113
+ - `fechaActualizacionPerfil` (date)
119
114
  - `prevPuesto` (string)
120
115
  - `prevArea` (string)
121
116
  - `prevRubro` (string)
@@ -133,6 +128,7 @@ This file describes the required and optional fields for each `eventType`.
133
128
  - `area` (string)
134
129
  - `rubro` (string)
135
130
  - `nivelMaximo` (number)
131
+ - `fechaActualizacionPerfil` (date)
136
132
 
137
133
  **Optional fields:**
138
134
  - *(none)*
@@ -198,6 +194,7 @@ This file describes the required and optional fields for each `eventType`.
198
194
  - `userId` (string)
199
195
  - `nivelMaximo` (number)
200
196
  - `idioma` (string)
197
+ - `fechaActualizacionPerfil` (date)
201
198
 
202
199
  **Optional fields:**
203
200
  - *(none)*
@@ -210,6 +207,7 @@ This file describes the required and optional fields for each `eventType`.
210
207
  - `userId` (string)
211
208
  - `nivelMaximo` (number)
212
209
  - `idioma` (string)
210
+ - `fechaActualizacionPerfil` (date)
213
211
  - `prevIdioma` (string)
214
212
 
215
213
  **Optional fields:**
@@ -223,6 +221,7 @@ This file describes the required and optional fields for each `eventType`.
223
221
  - `userId` (string)
224
222
  - `nivelMaximo` (number)
225
223
  - `idioma` (string)
224
+ - `fechaActualizacionPerfil` (date)
226
225
 
227
226
  **Optional fields:**
228
227
  - *(none)*
@@ -234,6 +233,7 @@ This file describes the required and optional fields for each `eventType`.
234
233
  **Required fields:**
235
234
  - `userId` (string)
236
235
  - `cvAdjunto` (string) (valid: 'si', 'no')
236
+ - `fechaActualizacionPerfil` (date)
237
237
 
238
238
  **Optional fields:**
239
239
  - *(none)*
@@ -331,6 +331,7 @@ This file describes the required and optional fields for each `eventType`.
331
331
 
332
332
  **Required fields:**
333
333
  - `userId` (string)
334
+ - `fechaActualizacionPerfil` (date)
334
335
  - `alerta` (string) (valid: 'si', 'no', '')
335
336
  - `cvAdjunto` (string) (valid: 'si', 'no')
336
337
  - `certificaciones` (string) (valid: 'si', 'no')
@@ -350,3 +351,14 @@ This file describes the required and optional fields for each `eventType`.
350
351
  - `subscriptions` (object)
351
352
 
352
353
  ---
354
+
355
+ ## Event: `delete-one-signal-user` (Delete OneSignal User)
356
+
357
+ **Required fields:**
358
+ - `userId` (string)
359
+
360
+ **Optional fields:**
361
+ - *(none)*
362
+
363
+ ---
364
+