@twin.org/messaging-connector-entity-storage 0.0.1-next.2 → 0.0.1-next.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.
@@ -3,6 +3,7 @@
3
3
  var core = require('@twin.org/core');
4
4
  var entityStorageModels = require('@twin.org/entity-storage-models');
5
5
  var loggingModels = require('@twin.org/logging-models');
6
+ var entity = require('@twin.org/entity');
6
7
 
7
8
  // Copyright 2024 IOTA Stiftung.
8
9
  // SPDX-License-Identifier: Apache-2.0.
@@ -23,19 +24,19 @@ class EntityStorageMessagingEmailConnector {
23
24
  * The entity storage for the emails entries.
24
25
  * @internal
25
26
  */
26
- _messagingEntryStorage;
27
+ _messagingEmailEntryStorage;
27
28
  /**
28
29
  * Create a new instance of EntityStorageMessagingEmailConnector.
29
30
  * @param options The options for the connector.
30
31
  * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
31
- * @param options.messagingEntryStorageConnectorType The type of entity storage connector to use for the email entries.
32
- * @param options.config The configuration for the email connector.
32
+ * @param options.messagingEmailEntryStorageConnectorType The type of entity storage connector to use for the email entries, defaults to "email-entry".
33
33
  */
34
34
  constructor(options) {
35
35
  if (core.Is.stringValue(options?.loggingConnectorType)) {
36
36
  this._logging = loggingModels.LoggingConnectorFactory.get(options.loggingConnectorType);
37
37
  }
38
- this._messagingEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingEntryStorageConnectorType ?? "email-entry");
38
+ this._messagingEmailEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingEmailEntryStorageConnectorType ??
39
+ core.StringHelper.kebabCase("EmailEntry"));
39
40
  }
40
41
  /**
41
42
  * Store a custom email using Entity Storage.
@@ -70,7 +71,7 @@ class EntityStorageMessagingEmailConnector {
70
71
  subject,
71
72
  status: "pending"
72
73
  };
73
- await this._messagingEntryStorage.set(entity);
74
+ await this._messagingEmailEntryStorage.set(entity);
74
75
  return true;
75
76
  }
76
77
  catch (err) {
@@ -108,15 +109,17 @@ class EntityStorageMessagingPushNotificationConnector {
108
109
  * Create a new instance of EntityStorageMessagingPushNotificationConnector.
109
110
  * @param options The options for the connector.
110
111
  * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
111
- * @param options.messagingEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries.
112
- * @param options.config The configuration for the push notifications connector.
112
+ * @param options.messagingDeviceEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-device-entry".
113
+ * @param options.messagingMessageEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-message-entry".
113
114
  */
114
115
  constructor(options) {
115
116
  if (core.Is.stringValue(options?.loggingConnectorType)) {
116
117
  this._logging = loggingModels.LoggingConnectorFactory.get(options.loggingConnectorType);
117
118
  }
118
- this._messagingDeviceEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingEntryStorageConnectorType ?? "push-notifications-device-entry");
119
- this._messagingMessageEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingEntryStorageConnectorType ?? "push-notifications-message-entry");
119
+ this._messagingDeviceEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingDeviceEntryStorageConnectorType ??
120
+ core.StringHelper.kebabCase("PushNotificationDeviceEntry"));
121
+ this._messagingMessageEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingMessageEntryStorageConnectorType ??
122
+ core.StringHelper.kebabCase("PushNotificationMessageEntry"));
120
123
  }
121
124
  /**
122
125
  * Registers a device to an specific app in order to send notifications to it.
@@ -204,19 +207,18 @@ class EntityStorageMessagingSmsConnector {
204
207
  * The entity storage for the sms entries.
205
208
  * @internal
206
209
  */
207
- _messagingEntryStorage;
210
+ _messagingSmsEntryStorage;
208
211
  /**
209
212
  * Create a new instance of EntityStorageMessagingSmsConnector.
210
213
  * @param options The options for the connector.
211
214
  * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
212
- * @param options.messagingEntryStorageConnectorType The type of entity storage connector to use for the sms entries.
213
- * @param options.config The configuration for the sms connector.
215
+ * @param options.messagingSmsEntryStorageConnectorType The type of entity storage connector to use for the sms entries, defaults to "sms-entry".
214
216
  */
215
217
  constructor(options) {
216
218
  if (core.Is.stringValue(options?.loggingConnectorType)) {
217
219
  this._logging = loggingModels.LoggingConnectorFactory.get(options.loggingConnectorType);
218
220
  }
219
- this._messagingEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingEntryStorageConnectorType ?? "sms-entry");
221
+ this._messagingSmsEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingSmsEntryStorageConnectorType ?? core.StringHelper.kebabCase("SmsEntry"));
220
222
  }
221
223
  /**
222
224
  * Send a SMS message to a phone number.
@@ -242,7 +244,7 @@ class EntityStorageMessagingSmsConnector {
242
244
  ts: Date.now(),
243
245
  status: "sent"
244
246
  };
245
- await this._messagingEntryStorage.set(entity);
247
+ await this._messagingSmsEntryStorage.set(entity);
246
248
  return true;
247
249
  }
248
250
  catch (err) {
@@ -251,6 +253,271 @@ class EntityStorageMessagingSmsConnector {
251
253
  }
252
254
  }
253
255
 
256
+ /**
257
+ * Call defining an email entry.
258
+ */
259
+ let EmailEntry = class EmailEntry {
260
+ /**
261
+ * The id.
262
+ */
263
+ id;
264
+ /**
265
+ * The sender email address.
266
+ */
267
+ sender;
268
+ /**
269
+ * The recipient email addresses.
270
+ */
271
+ recipients;
272
+ /**
273
+ * The timestamp of the email entry.
274
+ */
275
+ ts;
276
+ /**
277
+ * The message.
278
+ */
279
+ message;
280
+ /**
281
+ * The subject.
282
+ */
283
+ subject;
284
+ /**
285
+ * The status.
286
+ */
287
+ status;
288
+ /**
289
+ * The error.
290
+ */
291
+ error;
292
+ };
293
+ __decorate([
294
+ entity.property({ type: "string", isPrimary: true }),
295
+ __metadata("design:type", String)
296
+ ], EmailEntry.prototype, "id", void 0);
297
+ __decorate([
298
+ entity.property({ type: "string" }),
299
+ __metadata("design:type", String)
300
+ ], EmailEntry.prototype, "sender", void 0);
301
+ __decorate([
302
+ entity.property({ type: "array", itemType: "string" }),
303
+ __metadata("design:type", Array)
304
+ ], EmailEntry.prototype, "recipients", void 0);
305
+ __decorate([
306
+ entity.property({ type: "integer" }),
307
+ __metadata("design:type", Number)
308
+ ], EmailEntry.prototype, "ts", void 0);
309
+ __decorate([
310
+ entity.property({ type: "string" }),
311
+ __metadata("design:type", String)
312
+ ], EmailEntry.prototype, "message", void 0);
313
+ __decorate([
314
+ entity.property({ type: "string" }),
315
+ __metadata("design:type", String)
316
+ ], EmailEntry.prototype, "subject", void 0);
317
+ __decorate([
318
+ entity.property({ type: "string" }),
319
+ __metadata("design:type", String)
320
+ ], EmailEntry.prototype, "status", void 0);
321
+ __decorate([
322
+ entity.property({ type: "object" }),
323
+ __metadata("design:type", Object)
324
+ ], EmailEntry.prototype, "error", void 0);
325
+ EmailEntry = __decorate([
326
+ entity.entity()
327
+ ], EmailEntry);
328
+
329
+ /**
330
+ * Call defining an push notification device entry.
331
+ */
332
+ let PushNotificationDeviceEntry = class PushNotificationDeviceEntry {
333
+ /**
334
+ * The id.
335
+ */
336
+ id;
337
+ /**
338
+ * The applicationId.
339
+ */
340
+ applicationId;
341
+ /**
342
+ * The device token.
343
+ */
344
+ deviceToken;
345
+ /**
346
+ * The timestamp of the push notification device entry.
347
+ */
348
+ ts;
349
+ /**
350
+ * The status.
351
+ */
352
+ status;
353
+ /**
354
+ * The error.
355
+ */
356
+ error;
357
+ };
358
+ __decorate([
359
+ entity.property({ type: "string", isPrimary: true }),
360
+ __metadata("design:type", String)
361
+ ], PushNotificationDeviceEntry.prototype, "id", void 0);
362
+ __decorate([
363
+ entity.property({ type: "string" }),
364
+ __metadata("design:type", String)
365
+ ], PushNotificationDeviceEntry.prototype, "applicationId", void 0);
366
+ __decorate([
367
+ entity.property({ type: "string" }),
368
+ __metadata("design:type", String)
369
+ ], PushNotificationDeviceEntry.prototype, "deviceToken", void 0);
370
+ __decorate([
371
+ entity.property({ type: "integer" }),
372
+ __metadata("design:type", Number)
373
+ ], PushNotificationDeviceEntry.prototype, "ts", void 0);
374
+ __decorate([
375
+ entity.property({ type: "string" }),
376
+ __metadata("design:type", String)
377
+ ], PushNotificationDeviceEntry.prototype, "status", void 0);
378
+ __decorate([
379
+ entity.property({ type: "object" }),
380
+ __metadata("design:type", Object)
381
+ ], PushNotificationDeviceEntry.prototype, "error", void 0);
382
+ PushNotificationDeviceEntry = __decorate([
383
+ entity.entity()
384
+ ], PushNotificationDeviceEntry);
385
+
386
+ /**
387
+ * Call defining an push notification message entry.
388
+ */
389
+ let PushNotificationMessageEntry = class PushNotificationMessageEntry {
390
+ /**
391
+ * The id.
392
+ */
393
+ id;
394
+ /**
395
+ * The device address.
396
+ */
397
+ deviceAddress;
398
+ /**
399
+ * The title.
400
+ */
401
+ title;
402
+ /**
403
+ * The message.
404
+ */
405
+ message;
406
+ /**
407
+ * The timestamp of the push notification entry.
408
+ */
409
+ ts;
410
+ /**
411
+ * The status.
412
+ */
413
+ status;
414
+ /**
415
+ * The error.
416
+ */
417
+ error;
418
+ };
419
+ __decorate([
420
+ entity.property({ type: "string", isPrimary: true }),
421
+ __metadata("design:type", String)
422
+ ], PushNotificationMessageEntry.prototype, "id", void 0);
423
+ __decorate([
424
+ entity.property({ type: "string" }),
425
+ __metadata("design:type", String)
426
+ ], PushNotificationMessageEntry.prototype, "deviceAddress", void 0);
427
+ __decorate([
428
+ entity.property({ type: "string" }),
429
+ __metadata("design:type", String)
430
+ ], PushNotificationMessageEntry.prototype, "title", void 0);
431
+ __decorate([
432
+ entity.property({ type: "string" }),
433
+ __metadata("design:type", String)
434
+ ], PushNotificationMessageEntry.prototype, "message", void 0);
435
+ __decorate([
436
+ entity.property({ type: "integer" }),
437
+ __metadata("design:type", Number)
438
+ ], PushNotificationMessageEntry.prototype, "ts", void 0);
439
+ __decorate([
440
+ entity.property({ type: "string" }),
441
+ __metadata("design:type", String)
442
+ ], PushNotificationMessageEntry.prototype, "status", void 0);
443
+ __decorate([
444
+ entity.property({ type: "object" }),
445
+ __metadata("design:type", Object)
446
+ ], PushNotificationMessageEntry.prototype, "error", void 0);
447
+ PushNotificationMessageEntry = __decorate([
448
+ entity.entity()
449
+ ], PushNotificationMessageEntry);
450
+
451
+ /**
452
+ * Call defining an sms entry.
453
+ */
454
+ let SmsEntry = class SmsEntry {
455
+ /**
456
+ * The id.
457
+ */
458
+ id;
459
+ /**
460
+ * The phone number to deliver the message.
461
+ */
462
+ phoneNumber;
463
+ /**
464
+ * The timestamp of the sms entry.
465
+ */
466
+ ts;
467
+ /**
468
+ * The message.
469
+ */
470
+ message;
471
+ /**
472
+ * The status.
473
+ */
474
+ status;
475
+ /**
476
+ * The error.
477
+ */
478
+ error;
479
+ };
480
+ __decorate([
481
+ entity.property({ type: "string", isPrimary: true }),
482
+ __metadata("design:type", String)
483
+ ], SmsEntry.prototype, "id", void 0);
484
+ __decorate([
485
+ entity.property({ type: "string" }),
486
+ __metadata("design:type", String)
487
+ ], SmsEntry.prototype, "phoneNumber", void 0);
488
+ __decorate([
489
+ entity.property({ type: "integer" }),
490
+ __metadata("design:type", Number)
491
+ ], SmsEntry.prototype, "ts", void 0);
492
+ __decorate([
493
+ entity.property({ type: "string" }),
494
+ __metadata("design:type", String)
495
+ ], SmsEntry.prototype, "message", void 0);
496
+ __decorate([
497
+ entity.property({ type: "string" }),
498
+ __metadata("design:type", String)
499
+ ], SmsEntry.prototype, "status", void 0);
500
+ __decorate([
501
+ entity.property({ type: "object" }),
502
+ __metadata("design:type", Object)
503
+ ], SmsEntry.prototype, "error", void 0);
504
+ SmsEntry = __decorate([
505
+ entity.entity()
506
+ ], SmsEntry);
507
+
508
+ // Copyright 2024 IOTA Stiftung.
509
+ // SPDX-License-Identifier: Apache-2.0.
510
+ /**
511
+ * Initialize the schema for the messaging connector entity storage.
512
+ */
513
+ function initSchema() {
514
+ entity.EntitySchemaFactory.register("EmailEntry", () => entity.EntitySchemaHelper.getSchema(EmailEntry));
515
+ entity.EntitySchemaFactory.register("PushNotificationDeviceEntry", () => entity.EntitySchemaHelper.getSchema(PushNotificationDeviceEntry));
516
+ entity.EntitySchemaFactory.register("PushNotificationMessageEntry", () => entity.EntitySchemaHelper.getSchema(PushNotificationMessageEntry));
517
+ entity.EntitySchemaFactory.register("SmsEntry", () => entity.EntitySchemaHelper.getSchema(SmsEntry));
518
+ }
519
+
254
520
  exports.EntityStorageMessagingEmailConnector = EntityStorageMessagingEmailConnector;
255
521
  exports.EntityStorageMessagingPushNotificationConnector = EntityStorageMessagingPushNotificationConnector;
256
522
  exports.EntityStorageMessagingSmsConnector = EntityStorageMessagingSmsConnector;
523
+ exports.initSchema = initSchema;
@@ -1,6 +1,7 @@
1
- import { Is, Guards, Converter, RandomHelper, GeneralError } from '@twin.org/core';
1
+ import { Is, StringHelper, Guards, Converter, RandomHelper, GeneralError } from '@twin.org/core';
2
2
  import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
3
3
  import { LoggingConnectorFactory } from '@twin.org/logging-models';
4
+ import { property, entity, EntitySchemaFactory, EntitySchemaHelper } from '@twin.org/entity';
4
5
 
5
6
  // Copyright 2024 IOTA Stiftung.
6
7
  // SPDX-License-Identifier: Apache-2.0.
@@ -21,19 +22,19 @@ class EntityStorageMessagingEmailConnector {
21
22
  * The entity storage for the emails entries.
22
23
  * @internal
23
24
  */
24
- _messagingEntryStorage;
25
+ _messagingEmailEntryStorage;
25
26
  /**
26
27
  * Create a new instance of EntityStorageMessagingEmailConnector.
27
28
  * @param options The options for the connector.
28
29
  * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
29
- * @param options.messagingEntryStorageConnectorType The type of entity storage connector to use for the email entries.
30
- * @param options.config The configuration for the email connector.
30
+ * @param options.messagingEmailEntryStorageConnectorType The type of entity storage connector to use for the email entries, defaults to "email-entry".
31
31
  */
32
32
  constructor(options) {
33
33
  if (Is.stringValue(options?.loggingConnectorType)) {
34
34
  this._logging = LoggingConnectorFactory.get(options.loggingConnectorType);
35
35
  }
36
- this._messagingEntryStorage = EntityStorageConnectorFactory.get(options?.messagingEntryStorageConnectorType ?? "email-entry");
36
+ this._messagingEmailEntryStorage = EntityStorageConnectorFactory.get(options?.messagingEmailEntryStorageConnectorType ??
37
+ StringHelper.kebabCase("EmailEntry"));
37
38
  }
38
39
  /**
39
40
  * Store a custom email using Entity Storage.
@@ -68,7 +69,7 @@ class EntityStorageMessagingEmailConnector {
68
69
  subject,
69
70
  status: "pending"
70
71
  };
71
- await this._messagingEntryStorage.set(entity);
72
+ await this._messagingEmailEntryStorage.set(entity);
72
73
  return true;
73
74
  }
74
75
  catch (err) {
@@ -106,15 +107,17 @@ class EntityStorageMessagingPushNotificationConnector {
106
107
  * Create a new instance of EntityStorageMessagingPushNotificationConnector.
107
108
  * @param options The options for the connector.
108
109
  * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
109
- * @param options.messagingEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries.
110
- * @param options.config The configuration for the push notifications connector.
110
+ * @param options.messagingDeviceEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-device-entry".
111
+ * @param options.messagingMessageEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-message-entry".
111
112
  */
112
113
  constructor(options) {
113
114
  if (Is.stringValue(options?.loggingConnectorType)) {
114
115
  this._logging = LoggingConnectorFactory.get(options.loggingConnectorType);
115
116
  }
116
- this._messagingDeviceEntryStorage = EntityStorageConnectorFactory.get(options?.messagingEntryStorageConnectorType ?? "push-notifications-device-entry");
117
- this._messagingMessageEntryStorage = EntityStorageConnectorFactory.get(options?.messagingEntryStorageConnectorType ?? "push-notifications-message-entry");
117
+ this._messagingDeviceEntryStorage = EntityStorageConnectorFactory.get(options?.messagingDeviceEntryStorageConnectorType ??
118
+ StringHelper.kebabCase("PushNotificationDeviceEntry"));
119
+ this._messagingMessageEntryStorage = EntityStorageConnectorFactory.get(options?.messagingMessageEntryStorageConnectorType ??
120
+ StringHelper.kebabCase("PushNotificationMessageEntry"));
118
121
  }
119
122
  /**
120
123
  * Registers a device to an specific app in order to send notifications to it.
@@ -202,19 +205,18 @@ class EntityStorageMessagingSmsConnector {
202
205
  * The entity storage for the sms entries.
203
206
  * @internal
204
207
  */
205
- _messagingEntryStorage;
208
+ _messagingSmsEntryStorage;
206
209
  /**
207
210
  * Create a new instance of EntityStorageMessagingSmsConnector.
208
211
  * @param options The options for the connector.
209
212
  * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
210
- * @param options.messagingEntryStorageConnectorType The type of entity storage connector to use for the sms entries.
211
- * @param options.config The configuration for the sms connector.
213
+ * @param options.messagingSmsEntryStorageConnectorType The type of entity storage connector to use for the sms entries, defaults to "sms-entry".
212
214
  */
213
215
  constructor(options) {
214
216
  if (Is.stringValue(options?.loggingConnectorType)) {
215
217
  this._logging = LoggingConnectorFactory.get(options.loggingConnectorType);
216
218
  }
217
- this._messagingEntryStorage = EntityStorageConnectorFactory.get(options?.messagingEntryStorageConnectorType ?? "sms-entry");
219
+ this._messagingSmsEntryStorage = EntityStorageConnectorFactory.get(options?.messagingSmsEntryStorageConnectorType ?? StringHelper.kebabCase("SmsEntry"));
218
220
  }
219
221
  /**
220
222
  * Send a SMS message to a phone number.
@@ -240,7 +242,7 @@ class EntityStorageMessagingSmsConnector {
240
242
  ts: Date.now(),
241
243
  status: "sent"
242
244
  };
243
- await this._messagingEntryStorage.set(entity);
245
+ await this._messagingSmsEntryStorage.set(entity);
244
246
  return true;
245
247
  }
246
248
  catch (err) {
@@ -249,4 +251,268 @@ class EntityStorageMessagingSmsConnector {
249
251
  }
250
252
  }
251
253
 
252
- export { EntityStorageMessagingEmailConnector, EntityStorageMessagingPushNotificationConnector, EntityStorageMessagingSmsConnector };
254
+ /**
255
+ * Call defining an email entry.
256
+ */
257
+ let EmailEntry = class EmailEntry {
258
+ /**
259
+ * The id.
260
+ */
261
+ id;
262
+ /**
263
+ * The sender email address.
264
+ */
265
+ sender;
266
+ /**
267
+ * The recipient email addresses.
268
+ */
269
+ recipients;
270
+ /**
271
+ * The timestamp of the email entry.
272
+ */
273
+ ts;
274
+ /**
275
+ * The message.
276
+ */
277
+ message;
278
+ /**
279
+ * The subject.
280
+ */
281
+ subject;
282
+ /**
283
+ * The status.
284
+ */
285
+ status;
286
+ /**
287
+ * The error.
288
+ */
289
+ error;
290
+ };
291
+ __decorate([
292
+ property({ type: "string", isPrimary: true }),
293
+ __metadata("design:type", String)
294
+ ], EmailEntry.prototype, "id", void 0);
295
+ __decorate([
296
+ property({ type: "string" }),
297
+ __metadata("design:type", String)
298
+ ], EmailEntry.prototype, "sender", void 0);
299
+ __decorate([
300
+ property({ type: "array", itemType: "string" }),
301
+ __metadata("design:type", Array)
302
+ ], EmailEntry.prototype, "recipients", void 0);
303
+ __decorate([
304
+ property({ type: "integer" }),
305
+ __metadata("design:type", Number)
306
+ ], EmailEntry.prototype, "ts", void 0);
307
+ __decorate([
308
+ property({ type: "string" }),
309
+ __metadata("design:type", String)
310
+ ], EmailEntry.prototype, "message", void 0);
311
+ __decorate([
312
+ property({ type: "string" }),
313
+ __metadata("design:type", String)
314
+ ], EmailEntry.prototype, "subject", void 0);
315
+ __decorate([
316
+ property({ type: "string" }),
317
+ __metadata("design:type", String)
318
+ ], EmailEntry.prototype, "status", void 0);
319
+ __decorate([
320
+ property({ type: "object" }),
321
+ __metadata("design:type", Object)
322
+ ], EmailEntry.prototype, "error", void 0);
323
+ EmailEntry = __decorate([
324
+ entity()
325
+ ], EmailEntry);
326
+
327
+ /**
328
+ * Call defining an push notification device entry.
329
+ */
330
+ let PushNotificationDeviceEntry = class PushNotificationDeviceEntry {
331
+ /**
332
+ * The id.
333
+ */
334
+ id;
335
+ /**
336
+ * The applicationId.
337
+ */
338
+ applicationId;
339
+ /**
340
+ * The device token.
341
+ */
342
+ deviceToken;
343
+ /**
344
+ * The timestamp of the push notification device entry.
345
+ */
346
+ ts;
347
+ /**
348
+ * The status.
349
+ */
350
+ status;
351
+ /**
352
+ * The error.
353
+ */
354
+ error;
355
+ };
356
+ __decorate([
357
+ property({ type: "string", isPrimary: true }),
358
+ __metadata("design:type", String)
359
+ ], PushNotificationDeviceEntry.prototype, "id", void 0);
360
+ __decorate([
361
+ property({ type: "string" }),
362
+ __metadata("design:type", String)
363
+ ], PushNotificationDeviceEntry.prototype, "applicationId", void 0);
364
+ __decorate([
365
+ property({ type: "string" }),
366
+ __metadata("design:type", String)
367
+ ], PushNotificationDeviceEntry.prototype, "deviceToken", void 0);
368
+ __decorate([
369
+ property({ type: "integer" }),
370
+ __metadata("design:type", Number)
371
+ ], PushNotificationDeviceEntry.prototype, "ts", void 0);
372
+ __decorate([
373
+ property({ type: "string" }),
374
+ __metadata("design:type", String)
375
+ ], PushNotificationDeviceEntry.prototype, "status", void 0);
376
+ __decorate([
377
+ property({ type: "object" }),
378
+ __metadata("design:type", Object)
379
+ ], PushNotificationDeviceEntry.prototype, "error", void 0);
380
+ PushNotificationDeviceEntry = __decorate([
381
+ entity()
382
+ ], PushNotificationDeviceEntry);
383
+
384
+ /**
385
+ * Call defining an push notification message entry.
386
+ */
387
+ let PushNotificationMessageEntry = class PushNotificationMessageEntry {
388
+ /**
389
+ * The id.
390
+ */
391
+ id;
392
+ /**
393
+ * The device address.
394
+ */
395
+ deviceAddress;
396
+ /**
397
+ * The title.
398
+ */
399
+ title;
400
+ /**
401
+ * The message.
402
+ */
403
+ message;
404
+ /**
405
+ * The timestamp of the push notification entry.
406
+ */
407
+ ts;
408
+ /**
409
+ * The status.
410
+ */
411
+ status;
412
+ /**
413
+ * The error.
414
+ */
415
+ error;
416
+ };
417
+ __decorate([
418
+ property({ type: "string", isPrimary: true }),
419
+ __metadata("design:type", String)
420
+ ], PushNotificationMessageEntry.prototype, "id", void 0);
421
+ __decorate([
422
+ property({ type: "string" }),
423
+ __metadata("design:type", String)
424
+ ], PushNotificationMessageEntry.prototype, "deviceAddress", void 0);
425
+ __decorate([
426
+ property({ type: "string" }),
427
+ __metadata("design:type", String)
428
+ ], PushNotificationMessageEntry.prototype, "title", void 0);
429
+ __decorate([
430
+ property({ type: "string" }),
431
+ __metadata("design:type", String)
432
+ ], PushNotificationMessageEntry.prototype, "message", void 0);
433
+ __decorate([
434
+ property({ type: "integer" }),
435
+ __metadata("design:type", Number)
436
+ ], PushNotificationMessageEntry.prototype, "ts", void 0);
437
+ __decorate([
438
+ property({ type: "string" }),
439
+ __metadata("design:type", String)
440
+ ], PushNotificationMessageEntry.prototype, "status", void 0);
441
+ __decorate([
442
+ property({ type: "object" }),
443
+ __metadata("design:type", Object)
444
+ ], PushNotificationMessageEntry.prototype, "error", void 0);
445
+ PushNotificationMessageEntry = __decorate([
446
+ entity()
447
+ ], PushNotificationMessageEntry);
448
+
449
+ /**
450
+ * Call defining an sms entry.
451
+ */
452
+ let SmsEntry = class SmsEntry {
453
+ /**
454
+ * The id.
455
+ */
456
+ id;
457
+ /**
458
+ * The phone number to deliver the message.
459
+ */
460
+ phoneNumber;
461
+ /**
462
+ * The timestamp of the sms entry.
463
+ */
464
+ ts;
465
+ /**
466
+ * The message.
467
+ */
468
+ message;
469
+ /**
470
+ * The status.
471
+ */
472
+ status;
473
+ /**
474
+ * The error.
475
+ */
476
+ error;
477
+ };
478
+ __decorate([
479
+ property({ type: "string", isPrimary: true }),
480
+ __metadata("design:type", String)
481
+ ], SmsEntry.prototype, "id", void 0);
482
+ __decorate([
483
+ property({ type: "string" }),
484
+ __metadata("design:type", String)
485
+ ], SmsEntry.prototype, "phoneNumber", void 0);
486
+ __decorate([
487
+ property({ type: "integer" }),
488
+ __metadata("design:type", Number)
489
+ ], SmsEntry.prototype, "ts", void 0);
490
+ __decorate([
491
+ property({ type: "string" }),
492
+ __metadata("design:type", String)
493
+ ], SmsEntry.prototype, "message", void 0);
494
+ __decorate([
495
+ property({ type: "string" }),
496
+ __metadata("design:type", String)
497
+ ], SmsEntry.prototype, "status", void 0);
498
+ __decorate([
499
+ property({ type: "object" }),
500
+ __metadata("design:type", Object)
501
+ ], SmsEntry.prototype, "error", void 0);
502
+ SmsEntry = __decorate([
503
+ entity()
504
+ ], SmsEntry);
505
+
506
+ // Copyright 2024 IOTA Stiftung.
507
+ // SPDX-License-Identifier: Apache-2.0.
508
+ /**
509
+ * Initialize the schema for the messaging connector entity storage.
510
+ */
511
+ function initSchema() {
512
+ EntitySchemaFactory.register("EmailEntry", () => EntitySchemaHelper.getSchema(EmailEntry));
513
+ EntitySchemaFactory.register("PushNotificationDeviceEntry", () => EntitySchemaHelper.getSchema(PushNotificationDeviceEntry));
514
+ EntitySchemaFactory.register("PushNotificationMessageEntry", () => EntitySchemaHelper.getSchema(PushNotificationMessageEntry));
515
+ EntitySchemaFactory.register("SmsEntry", () => EntitySchemaHelper.getSchema(SmsEntry));
516
+ }
517
+
518
+ export { EntityStorageMessagingEmailConnector, EntityStorageMessagingPushNotificationConnector, EntityStorageMessagingSmsConnector, initSchema };
@@ -1,5 +1,4 @@
1
1
  import type { IMessagingEmailConnector } from "@twin.org/messaging-models";
2
- import type { IEntityStorageMessagingEmailConnectorConfig } from "./models/IEntityStorageMessagingEmailConnectorConfig";
3
2
  /**
4
3
  * Class for connecting to the email messaging operations of the Entity Storage.
5
4
  */
@@ -12,13 +11,11 @@ export declare class EntityStorageMessagingEmailConnector implements IMessagingE
12
11
  * Create a new instance of EntityStorageMessagingEmailConnector.
13
12
  * @param options The options for the connector.
14
13
  * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
15
- * @param options.messagingEntryStorageConnectorType The type of entity storage connector to use for the email entries.
16
- * @param options.config The configuration for the email connector.
14
+ * @param options.messagingEmailEntryStorageConnectorType The type of entity storage connector to use for the email entries, defaults to "email-entry".
17
15
  */
18
16
  constructor(options?: {
19
17
  loggingConnectorType?: string;
20
- messagingEntryStorageConnectorType: string;
21
- config?: IEntityStorageMessagingEmailConnectorConfig;
18
+ messagingEmailEntryStorageConnectorType?: string;
22
19
  });
23
20
  /**
24
21
  * Store a custom email using Entity Storage.
@@ -1,5 +1,4 @@
1
1
  import type { IMessagingPushNotificationsConnector } from "@twin.org/messaging-models";
2
- import type { IEntityStorageMessagingPushNotificationsConnectorConfig } from "./models/IEntityStorageMessagingPushNotificationsConnectorConfig";
3
2
  /**
4
3
  * Class for connecting to the push notifications messaging operations of the Entity Storage.
5
4
  */
@@ -12,13 +11,13 @@ export declare class EntityStorageMessagingPushNotificationConnector implements
12
11
  * Create a new instance of EntityStorageMessagingPushNotificationConnector.
13
12
  * @param options The options for the connector.
14
13
  * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
15
- * @param options.messagingEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries.
16
- * @param options.config The configuration for the push notifications connector.
14
+ * @param options.messagingDeviceEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-device-entry".
15
+ * @param options.messagingMessageEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-message-entry".
17
16
  */
18
17
  constructor(options?: {
19
18
  loggingConnectorType?: string;
20
- messagingEntryStorageConnectorType: string;
21
- config?: IEntityStorageMessagingPushNotificationsConnectorConfig;
19
+ messagingDeviceEntryStorageConnectorType?: string;
20
+ messagingMessageEntryStorageConnectorType?: string;
22
21
  });
23
22
  /**
24
23
  * Registers a device to an specific app in order to send notifications to it.
@@ -1,5 +1,4 @@
1
1
  import type { IMessagingSmsConnector } from "@twin.org/messaging-models";
2
- import type { IEntityStorageMessagingSmsConnectorConfig } from "./models/IEntityStorageMessagingSmsConnectorConfig";
3
2
  /**
4
3
  * Class for connecting to the SMS messaging operations of the Entity Storage.
5
4
  */
@@ -12,13 +11,11 @@ export declare class EntityStorageMessagingSmsConnector implements IMessagingSms
12
11
  * Create a new instance of EntityStorageMessagingSmsConnector.
13
12
  * @param options The options for the connector.
14
13
  * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
15
- * @param options.messagingEntryStorageConnectorType The type of entity storage connector to use for the sms entries.
16
- * @param options.config The configuration for the sms connector.
14
+ * @param options.messagingSmsEntryStorageConnectorType The type of entity storage connector to use for the sms entries, defaults to "sms-entry".
17
15
  */
18
16
  constructor(options?: {
19
17
  loggingConnectorType?: string;
20
- messagingEntryStorageConnectorType: string;
21
- config?: IEntityStorageMessagingSmsConnectorConfig;
18
+ messagingSmsEntryStorageConnectorType?: string;
22
19
  });
23
20
  /**
24
21
  * Send a SMS message to a phone number.
@@ -1,6 +1,4 @@
1
1
  export * from "./entityStorageMessagingEmailConnector";
2
2
  export * from "./entityStorageMessagingPushNotificationConnector";
3
3
  export * from "./entityStorageMessagingSmsConnector";
4
- export * from "./models/IEntityStorageMessagingEmailConnectorConfig";
5
- export * from "./models/IEntityStorageMessagingPushNotificationsConnectorConfig";
6
- export * from "./models/IEntityStorageMessagingSmsConnectorConfig";
4
+ export * from "./schema";
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/messaging-connector-entity-storage - Changelog
2
2
 
3
- ## v0.0.1-next.2
3
+ ## v0.0.1-next.3
4
4
 
5
5
  - Initial Release
@@ -24,13 +24,9 @@ The options for the connector.
24
24
 
25
25
  The type of logging connector to use, defaults to no logging.
26
26
 
27
- • **options.messagingEntryStorageConnectorType?**: `string`
27
+ • **options.messagingEmailEntryStorageConnectorType?**: `string`
28
28
 
29
- The type of entity storage connector to use for the email entries.
30
-
31
- • **options.config?**: `IMessagingEmailConnector`
32
-
33
- The configuration for the email connector.
29
+ The type of entity storage connector to use for the email entries, defaults to "email-entry".
34
30
 
35
31
  #### Returns
36
32
 
@@ -24,13 +24,13 @@ The options for the connector.
24
24
 
25
25
  The type of logging connector to use, defaults to no logging.
26
26
 
27
- • **options.messagingEntryStorageConnectorType?**: `string`
27
+ • **options.messagingDeviceEntryStorageConnectorType?**: `string`
28
28
 
29
- The type of entity storage connector to use for the push notifications entries.
29
+ The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-device-entry".
30
30
 
31
- • **options.config?**: `IMessagingPushNotificationsConnector`
31
+ • **options.messagingMessageEntryStorageConnectorType?**: `string`
32
32
 
33
- The configuration for the push notifications connector.
33
+ The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-message-entry".
34
34
 
35
35
  #### Returns
36
36
 
@@ -24,13 +24,9 @@ The options for the connector.
24
24
 
25
25
  The type of logging connector to use, defaults to no logging.
26
26
 
27
- • **options.messagingEntryStorageConnectorType?**: `string`
27
+ • **options.messagingSmsEntryStorageConnectorType?**: `string`
28
28
 
29
- The type of entity storage connector to use for the sms entries.
30
-
31
- • **options.config?**: `IMessagingSmsConnector`
32
-
33
- The configuration for the sms connector.
29
+ The type of entity storage connector to use for the sms entries, defaults to "sms-entry".
34
30
 
35
31
  #### Returns
36
32
 
@@ -0,0 +1,9 @@
1
+ # Function: initSchema()
2
+
3
+ > **initSchema**(): `void`
4
+
5
+ Initialize the schema for the messaging connector entity storage.
6
+
7
+ ## Returns
8
+
9
+ `void`
@@ -6,8 +6,6 @@
6
6
  - [EntityStorageMessagingPushNotificationConnector](classes/EntityStorageMessagingPushNotificationConnector.md)
7
7
  - [EntityStorageMessagingSmsConnector](classes/EntityStorageMessagingSmsConnector.md)
8
8
 
9
- ## Type Aliases
9
+ ## Functions
10
10
 
11
- - [IEntityStorageMessagingEmailConnectorConfig](type-aliases/IEntityStorageMessagingEmailConnectorConfig.md)
12
- - [IEntityStorageMessagingPushNotificationsConnectorConfig](type-aliases/IEntityStorageMessagingPushNotificationsConnectorConfig.md)
13
- - [IEntityStorageMessagingSmsConnectorConfig](type-aliases/IEntityStorageMessagingSmsConnectorConfig.md)
11
+ - [initSchema](functions/initSchema.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/messaging-connector-entity-storage",
3
- "version": "0.0.1-next.2",
3
+ "version": "0.0.1-next.3",
4
4
  "description": "Messaging connector implementation using the Entity Storage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "@twin.org/core": "next",
18
18
  "@twin.org/entity": "next",
19
19
  "@twin.org/logging-models": "next",
20
- "@twin.org/messaging-models": "0.0.1-next.2",
20
+ "@twin.org/messaging-models": "0.0.1-next.3",
21
21
  "@twin.org/nameof": "next"
22
22
  },
23
23
  "main": "./dist/cjs/index.cjs",
@@ -1,5 +0,0 @@
1
- import type { IMessagingEmailConnector } from "@twin.org/messaging-models";
2
- /**
3
- * Configuration for the Entity Storage Messaging Email Connector.
4
- */
5
- export type IEntityStorageMessagingEmailConnectorConfig = IMessagingEmailConnector;
@@ -1,5 +0,0 @@
1
- import type { IMessagingPushNotificationsConnector } from "@twin.org/messaging-models";
2
- /**
3
- * Configuration for the Entity Storage Messaging Push Notifications Connector.
4
- */
5
- export type IEntityStorageMessagingPushNotificationsConnectorConfig = IMessagingPushNotificationsConnector;
@@ -1,5 +0,0 @@
1
- import type { IMessagingSmsConnector } from "@twin.org/messaging-models";
2
- /**
3
- * Configuration for the Entity Storage Messaging Sms Connector.
4
- */
5
- export type IEntityStorageMessagingSmsConnectorConfig = IMessagingSmsConnector;
@@ -1,5 +0,0 @@
1
- # Type Alias: IEntityStorageMessagingEmailConnectorConfig
2
-
3
- > **IEntityStorageMessagingEmailConnectorConfig**: `IMessagingEmailConnector`
4
-
5
- Configuration for the Entity Storage Messaging Email Connector.
@@ -1,5 +0,0 @@
1
- # Type Alias: IEntityStorageMessagingPushNotificationsConnectorConfig
2
-
3
- > **IEntityStorageMessagingPushNotificationsConnectorConfig**: `IMessagingPushNotificationsConnector`
4
-
5
- Configuration for the Entity Storage Messaging Push Notifications Connector.
@@ -1,5 +0,0 @@
1
- # Type Alias: IEntityStorageMessagingSmsConnectorConfig
2
-
3
- > **IEntityStorageMessagingSmsConnectorConfig**: `IMessagingSmsConnector`
4
-
5
- Configuration for the Entity Storage Messaging Sms Connector.