@twin.org/messaging-connector-entity-storage 0.0.1-next.3 → 0.0.1-next.4

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.
@@ -1,9 +1,261 @@
1
1
  'use strict';
2
2
 
3
+ var entity = require('@twin.org/entity');
3
4
  var core = require('@twin.org/core');
4
5
  var entityStorageModels = require('@twin.org/entity-storage-models');
5
6
  var loggingModels = require('@twin.org/logging-models');
6
- var entity = require('@twin.org/entity');
7
+
8
+ /**
9
+ * Call defining an email entry.
10
+ */
11
+ exports.EmailEntry = class EmailEntry {
12
+ /**
13
+ * The id.
14
+ */
15
+ id;
16
+ /**
17
+ * The sender email address.
18
+ */
19
+ sender;
20
+ /**
21
+ * The recipient email addresses.
22
+ */
23
+ recipients;
24
+ /**
25
+ * The timestamp of the email entry.
26
+ */
27
+ ts;
28
+ /**
29
+ * The message.
30
+ */
31
+ message;
32
+ /**
33
+ * The subject.
34
+ */
35
+ subject;
36
+ /**
37
+ * The status.
38
+ */
39
+ status;
40
+ /**
41
+ * The error.
42
+ */
43
+ error;
44
+ };
45
+ __decorate([
46
+ entity.property({ type: "string", isPrimary: true }),
47
+ __metadata("design:type", String)
48
+ ], exports.EmailEntry.prototype, "id", void 0);
49
+ __decorate([
50
+ entity.property({ type: "string" }),
51
+ __metadata("design:type", String)
52
+ ], exports.EmailEntry.prototype, "sender", void 0);
53
+ __decorate([
54
+ entity.property({ type: "array", itemType: "string" }),
55
+ __metadata("design:type", Array)
56
+ ], exports.EmailEntry.prototype, "recipients", void 0);
57
+ __decorate([
58
+ entity.property({ type: "integer" }),
59
+ __metadata("design:type", Number)
60
+ ], exports.EmailEntry.prototype, "ts", void 0);
61
+ __decorate([
62
+ entity.property({ type: "string" }),
63
+ __metadata("design:type", String)
64
+ ], exports.EmailEntry.prototype, "message", void 0);
65
+ __decorate([
66
+ entity.property({ type: "string" }),
67
+ __metadata("design:type", String)
68
+ ], exports.EmailEntry.prototype, "subject", void 0);
69
+ __decorate([
70
+ entity.property({ type: "string" }),
71
+ __metadata("design:type", String)
72
+ ], exports.EmailEntry.prototype, "status", void 0);
73
+ __decorate([
74
+ entity.property({ type: "object" }),
75
+ __metadata("design:type", Object)
76
+ ], exports.EmailEntry.prototype, "error", void 0);
77
+ exports.EmailEntry = __decorate([
78
+ entity.entity()
79
+ ], exports.EmailEntry);
80
+
81
+ /**
82
+ * Call defining an push notification device entry.
83
+ */
84
+ exports.PushNotificationDeviceEntry = class PushNotificationDeviceEntry {
85
+ /**
86
+ * The id.
87
+ */
88
+ id;
89
+ /**
90
+ * The applicationId.
91
+ */
92
+ applicationId;
93
+ /**
94
+ * The device token.
95
+ */
96
+ deviceToken;
97
+ /**
98
+ * The timestamp of the push notification device entry.
99
+ */
100
+ ts;
101
+ /**
102
+ * The status.
103
+ */
104
+ status;
105
+ /**
106
+ * The error.
107
+ */
108
+ error;
109
+ };
110
+ __decorate([
111
+ entity.property({ type: "string", isPrimary: true }),
112
+ __metadata("design:type", String)
113
+ ], exports.PushNotificationDeviceEntry.prototype, "id", void 0);
114
+ __decorate([
115
+ entity.property({ type: "string" }),
116
+ __metadata("design:type", String)
117
+ ], exports.PushNotificationDeviceEntry.prototype, "applicationId", void 0);
118
+ __decorate([
119
+ entity.property({ type: "string" }),
120
+ __metadata("design:type", String)
121
+ ], exports.PushNotificationDeviceEntry.prototype, "deviceToken", void 0);
122
+ __decorate([
123
+ entity.property({ type: "integer" }),
124
+ __metadata("design:type", Number)
125
+ ], exports.PushNotificationDeviceEntry.prototype, "ts", void 0);
126
+ __decorate([
127
+ entity.property({ type: "string" }),
128
+ __metadata("design:type", String)
129
+ ], exports.PushNotificationDeviceEntry.prototype, "status", void 0);
130
+ __decorate([
131
+ entity.property({ type: "object" }),
132
+ __metadata("design:type", Object)
133
+ ], exports.PushNotificationDeviceEntry.prototype, "error", void 0);
134
+ exports.PushNotificationDeviceEntry = __decorate([
135
+ entity.entity()
136
+ ], exports.PushNotificationDeviceEntry);
137
+
138
+ /**
139
+ * Call defining an push notification message entry.
140
+ */
141
+ exports.PushNotificationMessageEntry = class PushNotificationMessageEntry {
142
+ /**
143
+ * The id.
144
+ */
145
+ id;
146
+ /**
147
+ * The device address.
148
+ */
149
+ deviceAddress;
150
+ /**
151
+ * The title.
152
+ */
153
+ title;
154
+ /**
155
+ * The message.
156
+ */
157
+ message;
158
+ /**
159
+ * The timestamp of the push notification entry.
160
+ */
161
+ ts;
162
+ /**
163
+ * The status.
164
+ */
165
+ status;
166
+ /**
167
+ * The error.
168
+ */
169
+ error;
170
+ };
171
+ __decorate([
172
+ entity.property({ type: "string", isPrimary: true }),
173
+ __metadata("design:type", String)
174
+ ], exports.PushNotificationMessageEntry.prototype, "id", void 0);
175
+ __decorate([
176
+ entity.property({ type: "string" }),
177
+ __metadata("design:type", String)
178
+ ], exports.PushNotificationMessageEntry.prototype, "deviceAddress", void 0);
179
+ __decorate([
180
+ entity.property({ type: "string" }),
181
+ __metadata("design:type", String)
182
+ ], exports.PushNotificationMessageEntry.prototype, "title", void 0);
183
+ __decorate([
184
+ entity.property({ type: "string" }),
185
+ __metadata("design:type", String)
186
+ ], exports.PushNotificationMessageEntry.prototype, "message", void 0);
187
+ __decorate([
188
+ entity.property({ type: "integer" }),
189
+ __metadata("design:type", Number)
190
+ ], exports.PushNotificationMessageEntry.prototype, "ts", void 0);
191
+ __decorate([
192
+ entity.property({ type: "string" }),
193
+ __metadata("design:type", String)
194
+ ], exports.PushNotificationMessageEntry.prototype, "status", void 0);
195
+ __decorate([
196
+ entity.property({ type: "object" }),
197
+ __metadata("design:type", Object)
198
+ ], exports.PushNotificationMessageEntry.prototype, "error", void 0);
199
+ exports.PushNotificationMessageEntry = __decorate([
200
+ entity.entity()
201
+ ], exports.PushNotificationMessageEntry);
202
+
203
+ /**
204
+ * Call defining an sms entry.
205
+ */
206
+ exports.SmsEntry = class SmsEntry {
207
+ /**
208
+ * The id.
209
+ */
210
+ id;
211
+ /**
212
+ * The phone number to deliver the message.
213
+ */
214
+ phoneNumber;
215
+ /**
216
+ * The timestamp of the sms entry.
217
+ */
218
+ ts;
219
+ /**
220
+ * The message.
221
+ */
222
+ message;
223
+ /**
224
+ * The status.
225
+ */
226
+ status;
227
+ /**
228
+ * The error.
229
+ */
230
+ error;
231
+ };
232
+ __decorate([
233
+ entity.property({ type: "string", isPrimary: true }),
234
+ __metadata("design:type", String)
235
+ ], exports.SmsEntry.prototype, "id", void 0);
236
+ __decorate([
237
+ entity.property({ type: "string" }),
238
+ __metadata("design:type", String)
239
+ ], exports.SmsEntry.prototype, "phoneNumber", void 0);
240
+ __decorate([
241
+ entity.property({ type: "integer" }),
242
+ __metadata("design:type", Number)
243
+ ], exports.SmsEntry.prototype, "ts", void 0);
244
+ __decorate([
245
+ entity.property({ type: "string" }),
246
+ __metadata("design:type", String)
247
+ ], exports.SmsEntry.prototype, "message", void 0);
248
+ __decorate([
249
+ entity.property({ type: "string" }),
250
+ __metadata("design:type", String)
251
+ ], exports.SmsEntry.prototype, "status", void 0);
252
+ __decorate([
253
+ entity.property({ type: "object" }),
254
+ __metadata("design:type", Object)
255
+ ], exports.SmsEntry.prototype, "error", void 0);
256
+ exports.SmsEntry = __decorate([
257
+ entity.entity()
258
+ ], exports.SmsEntry);
7
259
 
8
260
  // Copyright 2024 IOTA Stiftung.
9
261
  // SPDX-License-Identifier: Apache-2.0.
@@ -253,268 +505,26 @@ class EntityStorageMessagingSmsConnector {
253
505
  }
254
506
  }
255
507
 
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
508
  // Copyright 2024 IOTA Stiftung.
509
509
  // SPDX-License-Identifier: Apache-2.0.
510
510
  /**
511
511
  * Initialize the schema for the messaging connector entity storage.
512
+ * @param options The options for the initialisation.
513
+ * @param options.email Should we register email schemas.
514
+ * @param options.sms Should we register sms schemas.
515
+ * @param options.pushNotification Should we register push notification schemas.
512
516
  */
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));
517
+ function initSchema(options) {
518
+ if (options?.email ?? true) {
519
+ entity.EntitySchemaFactory.register("EmailEntry", () => entity.EntitySchemaHelper.getSchema(exports.EmailEntry));
520
+ }
521
+ if (options?.pushNotification ?? true) {
522
+ entity.EntitySchemaFactory.register("PushNotificationDeviceEntry", () => entity.EntitySchemaHelper.getSchema(exports.PushNotificationDeviceEntry));
523
+ entity.EntitySchemaFactory.register("PushNotificationMessageEntry", () => entity.EntitySchemaHelper.getSchema(exports.PushNotificationMessageEntry));
524
+ }
525
+ if (options?.sms ?? true) {
526
+ entity.EntitySchemaFactory.register("SmsEntry", () => entity.EntitySchemaHelper.getSchema(exports.SmsEntry));
527
+ }
518
528
  }
519
529
 
520
530
  exports.EntityStorageMessagingEmailConnector = EntityStorageMessagingEmailConnector;