@twin.org/messaging-connector-entity-storage 0.0.1-next.2 → 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.
- package/dist/cjs/index.cjs +291 -14
- package/dist/esm/index.mjs +292 -16
- package/dist/types/entityStorageMessagingEmailConnector.d.ts +2 -5
- package/dist/types/entityStorageMessagingPushNotificationConnector.d.ts +4 -5
- package/dist/types/entityStorageMessagingSmsConnector.d.ts +2 -5
- package/dist/types/index.d.ts +5 -3
- package/dist/types/schema.d.ts +9 -1
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/EmailEntry.md +77 -0
- package/docs/reference/classes/EntityStorageMessagingEmailConnector.md +2 -6
- package/docs/reference/classes/EntityStorageMessagingPushNotificationConnector.md +4 -4
- package/docs/reference/classes/EntityStorageMessagingSmsConnector.md +2 -6
- package/docs/reference/classes/PushNotificationDeviceEntry.md +61 -0
- package/docs/reference/classes/PushNotificationMessageEntry.md +69 -0
- package/docs/reference/classes/SmsEntry.md +61 -0
- package/docs/reference/functions/initSchema.md +27 -0
- package/docs/reference/index.md +6 -4
- package/package.json +2 -2
- package/dist/types/models/IEntityStorageMessagingEmailConnectorConfig.d.ts +0 -5
- package/dist/types/models/IEntityStorageMessagingPushNotificationsConnectorConfig.d.ts +0 -5
- package/dist/types/models/IEntityStorageMessagingSmsConnectorConfig.d.ts +0 -5
- package/docs/reference/type-aliases/IEntityStorageMessagingEmailConnectorConfig.md +0 -5
- package/docs/reference/type-aliases/IEntityStorageMessagingPushNotificationsConnectorConfig.md +0 -5
- package/docs/reference/type-aliases/IEntityStorageMessagingSmsConnectorConfig.md +0 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,9 +1,262 @@
|
|
|
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
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);
|
|
259
|
+
|
|
7
260
|
// Copyright 2024 IOTA Stiftung.
|
|
8
261
|
// SPDX-License-Identifier: Apache-2.0.
|
|
9
262
|
/**
|
|
@@ -23,19 +276,19 @@ class EntityStorageMessagingEmailConnector {
|
|
|
23
276
|
* The entity storage for the emails entries.
|
|
24
277
|
* @internal
|
|
25
278
|
*/
|
|
26
|
-
|
|
279
|
+
_messagingEmailEntryStorage;
|
|
27
280
|
/**
|
|
28
281
|
* Create a new instance of EntityStorageMessagingEmailConnector.
|
|
29
282
|
* @param options The options for the connector.
|
|
30
283
|
* @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
|
|
31
|
-
* @param options.
|
|
32
|
-
* @param options.config The configuration for the email connector.
|
|
284
|
+
* @param options.messagingEmailEntryStorageConnectorType The type of entity storage connector to use for the email entries, defaults to "email-entry".
|
|
33
285
|
*/
|
|
34
286
|
constructor(options) {
|
|
35
287
|
if (core.Is.stringValue(options?.loggingConnectorType)) {
|
|
36
288
|
this._logging = loggingModels.LoggingConnectorFactory.get(options.loggingConnectorType);
|
|
37
289
|
}
|
|
38
|
-
this.
|
|
290
|
+
this._messagingEmailEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingEmailEntryStorageConnectorType ??
|
|
291
|
+
core.StringHelper.kebabCase("EmailEntry"));
|
|
39
292
|
}
|
|
40
293
|
/**
|
|
41
294
|
* Store a custom email using Entity Storage.
|
|
@@ -70,7 +323,7 @@ class EntityStorageMessagingEmailConnector {
|
|
|
70
323
|
subject,
|
|
71
324
|
status: "pending"
|
|
72
325
|
};
|
|
73
|
-
await this.
|
|
326
|
+
await this._messagingEmailEntryStorage.set(entity);
|
|
74
327
|
return true;
|
|
75
328
|
}
|
|
76
329
|
catch (err) {
|
|
@@ -108,15 +361,17 @@ class EntityStorageMessagingPushNotificationConnector {
|
|
|
108
361
|
* Create a new instance of EntityStorageMessagingPushNotificationConnector.
|
|
109
362
|
* @param options The options for the connector.
|
|
110
363
|
* @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
|
|
111
|
-
* @param options.
|
|
112
|
-
* @param options.
|
|
364
|
+
* @param options.messagingDeviceEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-device-entry".
|
|
365
|
+
* @param options.messagingMessageEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-message-entry".
|
|
113
366
|
*/
|
|
114
367
|
constructor(options) {
|
|
115
368
|
if (core.Is.stringValue(options?.loggingConnectorType)) {
|
|
116
369
|
this._logging = loggingModels.LoggingConnectorFactory.get(options.loggingConnectorType);
|
|
117
370
|
}
|
|
118
|
-
this._messagingDeviceEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.
|
|
119
|
-
|
|
371
|
+
this._messagingDeviceEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingDeviceEntryStorageConnectorType ??
|
|
372
|
+
core.StringHelper.kebabCase("PushNotificationDeviceEntry"));
|
|
373
|
+
this._messagingMessageEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingMessageEntryStorageConnectorType ??
|
|
374
|
+
core.StringHelper.kebabCase("PushNotificationMessageEntry"));
|
|
120
375
|
}
|
|
121
376
|
/**
|
|
122
377
|
* Registers a device to an specific app in order to send notifications to it.
|
|
@@ -204,19 +459,18 @@ class EntityStorageMessagingSmsConnector {
|
|
|
204
459
|
* The entity storage for the sms entries.
|
|
205
460
|
* @internal
|
|
206
461
|
*/
|
|
207
|
-
|
|
462
|
+
_messagingSmsEntryStorage;
|
|
208
463
|
/**
|
|
209
464
|
* Create a new instance of EntityStorageMessagingSmsConnector.
|
|
210
465
|
* @param options The options for the connector.
|
|
211
466
|
* @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
|
|
212
|
-
* @param options.
|
|
213
|
-
* @param options.config The configuration for the sms connector.
|
|
467
|
+
* @param options.messagingSmsEntryStorageConnectorType The type of entity storage connector to use for the sms entries, defaults to "sms-entry".
|
|
214
468
|
*/
|
|
215
469
|
constructor(options) {
|
|
216
470
|
if (core.Is.stringValue(options?.loggingConnectorType)) {
|
|
217
471
|
this._logging = loggingModels.LoggingConnectorFactory.get(options.loggingConnectorType);
|
|
218
472
|
}
|
|
219
|
-
this.
|
|
473
|
+
this._messagingSmsEntryStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.messagingSmsEntryStorageConnectorType ?? core.StringHelper.kebabCase("SmsEntry"));
|
|
220
474
|
}
|
|
221
475
|
/**
|
|
222
476
|
* Send a SMS message to a phone number.
|
|
@@ -242,7 +496,7 @@ class EntityStorageMessagingSmsConnector {
|
|
|
242
496
|
ts: Date.now(),
|
|
243
497
|
status: "sent"
|
|
244
498
|
};
|
|
245
|
-
await this.
|
|
499
|
+
await this._messagingSmsEntryStorage.set(entity);
|
|
246
500
|
return true;
|
|
247
501
|
}
|
|
248
502
|
catch (err) {
|
|
@@ -251,6 +505,29 @@ class EntityStorageMessagingSmsConnector {
|
|
|
251
505
|
}
|
|
252
506
|
}
|
|
253
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
|
+
* @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.
|
|
516
|
+
*/
|
|
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
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
254
530
|
exports.EntityStorageMessagingEmailConnector = EntityStorageMessagingEmailConnector;
|
|
255
531
|
exports.EntityStorageMessagingPushNotificationConnector = EntityStorageMessagingPushNotificationConnector;
|
|
256
532
|
exports.EntityStorageMessagingSmsConnector = EntityStorageMessagingSmsConnector;
|
|
533
|
+
exports.initSchema = initSchema;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,7 +1,260 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { property, entity, EntitySchemaFactory, EntitySchemaHelper } from '@twin.org/entity';
|
|
2
|
+
import { Is, StringHelper, Guards, Converter, RandomHelper, GeneralError } from '@twin.org/core';
|
|
2
3
|
import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
|
|
3
4
|
import { LoggingConnectorFactory } from '@twin.org/logging-models';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Call defining an email entry.
|
|
8
|
+
*/
|
|
9
|
+
let EmailEntry = class EmailEntry {
|
|
10
|
+
/**
|
|
11
|
+
* The id.
|
|
12
|
+
*/
|
|
13
|
+
id;
|
|
14
|
+
/**
|
|
15
|
+
* The sender email address.
|
|
16
|
+
*/
|
|
17
|
+
sender;
|
|
18
|
+
/**
|
|
19
|
+
* The recipient email addresses.
|
|
20
|
+
*/
|
|
21
|
+
recipients;
|
|
22
|
+
/**
|
|
23
|
+
* The timestamp of the email entry.
|
|
24
|
+
*/
|
|
25
|
+
ts;
|
|
26
|
+
/**
|
|
27
|
+
* The message.
|
|
28
|
+
*/
|
|
29
|
+
message;
|
|
30
|
+
/**
|
|
31
|
+
* The subject.
|
|
32
|
+
*/
|
|
33
|
+
subject;
|
|
34
|
+
/**
|
|
35
|
+
* The status.
|
|
36
|
+
*/
|
|
37
|
+
status;
|
|
38
|
+
/**
|
|
39
|
+
* The error.
|
|
40
|
+
*/
|
|
41
|
+
error;
|
|
42
|
+
};
|
|
43
|
+
__decorate([
|
|
44
|
+
property({ type: "string", isPrimary: true }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], EmailEntry.prototype, "id", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
property({ type: "string" }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], EmailEntry.prototype, "sender", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
property({ type: "array", itemType: "string" }),
|
|
53
|
+
__metadata("design:type", Array)
|
|
54
|
+
], EmailEntry.prototype, "recipients", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
property({ type: "integer" }),
|
|
57
|
+
__metadata("design:type", Number)
|
|
58
|
+
], EmailEntry.prototype, "ts", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
property({ type: "string" }),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], EmailEntry.prototype, "message", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
property({ type: "string" }),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], EmailEntry.prototype, "subject", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
property({ type: "string" }),
|
|
69
|
+
__metadata("design:type", String)
|
|
70
|
+
], EmailEntry.prototype, "status", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
property({ type: "object" }),
|
|
73
|
+
__metadata("design:type", Object)
|
|
74
|
+
], EmailEntry.prototype, "error", void 0);
|
|
75
|
+
EmailEntry = __decorate([
|
|
76
|
+
entity()
|
|
77
|
+
], EmailEntry);
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Call defining an push notification device entry.
|
|
81
|
+
*/
|
|
82
|
+
let PushNotificationDeviceEntry = class PushNotificationDeviceEntry {
|
|
83
|
+
/**
|
|
84
|
+
* The id.
|
|
85
|
+
*/
|
|
86
|
+
id;
|
|
87
|
+
/**
|
|
88
|
+
* The applicationId.
|
|
89
|
+
*/
|
|
90
|
+
applicationId;
|
|
91
|
+
/**
|
|
92
|
+
* The device token.
|
|
93
|
+
*/
|
|
94
|
+
deviceToken;
|
|
95
|
+
/**
|
|
96
|
+
* The timestamp of the push notification device entry.
|
|
97
|
+
*/
|
|
98
|
+
ts;
|
|
99
|
+
/**
|
|
100
|
+
* The status.
|
|
101
|
+
*/
|
|
102
|
+
status;
|
|
103
|
+
/**
|
|
104
|
+
* The error.
|
|
105
|
+
*/
|
|
106
|
+
error;
|
|
107
|
+
};
|
|
108
|
+
__decorate([
|
|
109
|
+
property({ type: "string", isPrimary: true }),
|
|
110
|
+
__metadata("design:type", String)
|
|
111
|
+
], PushNotificationDeviceEntry.prototype, "id", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
property({ type: "string" }),
|
|
114
|
+
__metadata("design:type", String)
|
|
115
|
+
], PushNotificationDeviceEntry.prototype, "applicationId", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
property({ type: "string" }),
|
|
118
|
+
__metadata("design:type", String)
|
|
119
|
+
], PushNotificationDeviceEntry.prototype, "deviceToken", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
property({ type: "integer" }),
|
|
122
|
+
__metadata("design:type", Number)
|
|
123
|
+
], PushNotificationDeviceEntry.prototype, "ts", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ type: "string" }),
|
|
126
|
+
__metadata("design:type", String)
|
|
127
|
+
], PushNotificationDeviceEntry.prototype, "status", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
property({ type: "object" }),
|
|
130
|
+
__metadata("design:type", Object)
|
|
131
|
+
], PushNotificationDeviceEntry.prototype, "error", void 0);
|
|
132
|
+
PushNotificationDeviceEntry = __decorate([
|
|
133
|
+
entity()
|
|
134
|
+
], PushNotificationDeviceEntry);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Call defining an push notification message entry.
|
|
138
|
+
*/
|
|
139
|
+
let PushNotificationMessageEntry = class PushNotificationMessageEntry {
|
|
140
|
+
/**
|
|
141
|
+
* The id.
|
|
142
|
+
*/
|
|
143
|
+
id;
|
|
144
|
+
/**
|
|
145
|
+
* The device address.
|
|
146
|
+
*/
|
|
147
|
+
deviceAddress;
|
|
148
|
+
/**
|
|
149
|
+
* The title.
|
|
150
|
+
*/
|
|
151
|
+
title;
|
|
152
|
+
/**
|
|
153
|
+
* The message.
|
|
154
|
+
*/
|
|
155
|
+
message;
|
|
156
|
+
/**
|
|
157
|
+
* The timestamp of the push notification entry.
|
|
158
|
+
*/
|
|
159
|
+
ts;
|
|
160
|
+
/**
|
|
161
|
+
* The status.
|
|
162
|
+
*/
|
|
163
|
+
status;
|
|
164
|
+
/**
|
|
165
|
+
* The error.
|
|
166
|
+
*/
|
|
167
|
+
error;
|
|
168
|
+
};
|
|
169
|
+
__decorate([
|
|
170
|
+
property({ type: "string", isPrimary: true }),
|
|
171
|
+
__metadata("design:type", String)
|
|
172
|
+
], PushNotificationMessageEntry.prototype, "id", void 0);
|
|
173
|
+
__decorate([
|
|
174
|
+
property({ type: "string" }),
|
|
175
|
+
__metadata("design:type", String)
|
|
176
|
+
], PushNotificationMessageEntry.prototype, "deviceAddress", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
property({ type: "string" }),
|
|
179
|
+
__metadata("design:type", String)
|
|
180
|
+
], PushNotificationMessageEntry.prototype, "title", void 0);
|
|
181
|
+
__decorate([
|
|
182
|
+
property({ type: "string" }),
|
|
183
|
+
__metadata("design:type", String)
|
|
184
|
+
], PushNotificationMessageEntry.prototype, "message", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
property({ type: "integer" }),
|
|
187
|
+
__metadata("design:type", Number)
|
|
188
|
+
], PushNotificationMessageEntry.prototype, "ts", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
property({ type: "string" }),
|
|
191
|
+
__metadata("design:type", String)
|
|
192
|
+
], PushNotificationMessageEntry.prototype, "status", void 0);
|
|
193
|
+
__decorate([
|
|
194
|
+
property({ type: "object" }),
|
|
195
|
+
__metadata("design:type", Object)
|
|
196
|
+
], PushNotificationMessageEntry.prototype, "error", void 0);
|
|
197
|
+
PushNotificationMessageEntry = __decorate([
|
|
198
|
+
entity()
|
|
199
|
+
], PushNotificationMessageEntry);
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Call defining an sms entry.
|
|
203
|
+
*/
|
|
204
|
+
let SmsEntry = class SmsEntry {
|
|
205
|
+
/**
|
|
206
|
+
* The id.
|
|
207
|
+
*/
|
|
208
|
+
id;
|
|
209
|
+
/**
|
|
210
|
+
* The phone number to deliver the message.
|
|
211
|
+
*/
|
|
212
|
+
phoneNumber;
|
|
213
|
+
/**
|
|
214
|
+
* The timestamp of the sms entry.
|
|
215
|
+
*/
|
|
216
|
+
ts;
|
|
217
|
+
/**
|
|
218
|
+
* The message.
|
|
219
|
+
*/
|
|
220
|
+
message;
|
|
221
|
+
/**
|
|
222
|
+
* The status.
|
|
223
|
+
*/
|
|
224
|
+
status;
|
|
225
|
+
/**
|
|
226
|
+
* The error.
|
|
227
|
+
*/
|
|
228
|
+
error;
|
|
229
|
+
};
|
|
230
|
+
__decorate([
|
|
231
|
+
property({ type: "string", isPrimary: true }),
|
|
232
|
+
__metadata("design:type", String)
|
|
233
|
+
], SmsEntry.prototype, "id", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
property({ type: "string" }),
|
|
236
|
+
__metadata("design:type", String)
|
|
237
|
+
], SmsEntry.prototype, "phoneNumber", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
property({ type: "integer" }),
|
|
240
|
+
__metadata("design:type", Number)
|
|
241
|
+
], SmsEntry.prototype, "ts", void 0);
|
|
242
|
+
__decorate([
|
|
243
|
+
property({ type: "string" }),
|
|
244
|
+
__metadata("design:type", String)
|
|
245
|
+
], SmsEntry.prototype, "message", void 0);
|
|
246
|
+
__decorate([
|
|
247
|
+
property({ type: "string" }),
|
|
248
|
+
__metadata("design:type", String)
|
|
249
|
+
], SmsEntry.prototype, "status", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
property({ type: "object" }),
|
|
252
|
+
__metadata("design:type", Object)
|
|
253
|
+
], SmsEntry.prototype, "error", void 0);
|
|
254
|
+
SmsEntry = __decorate([
|
|
255
|
+
entity()
|
|
256
|
+
], SmsEntry);
|
|
257
|
+
|
|
5
258
|
// Copyright 2024 IOTA Stiftung.
|
|
6
259
|
// SPDX-License-Identifier: Apache-2.0.
|
|
7
260
|
/**
|
|
@@ -21,19 +274,19 @@ class EntityStorageMessagingEmailConnector {
|
|
|
21
274
|
* The entity storage for the emails entries.
|
|
22
275
|
* @internal
|
|
23
276
|
*/
|
|
24
|
-
|
|
277
|
+
_messagingEmailEntryStorage;
|
|
25
278
|
/**
|
|
26
279
|
* Create a new instance of EntityStorageMessagingEmailConnector.
|
|
27
280
|
* @param options The options for the connector.
|
|
28
281
|
* @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
|
|
29
|
-
* @param options.
|
|
30
|
-
* @param options.config The configuration for the email connector.
|
|
282
|
+
* @param options.messagingEmailEntryStorageConnectorType The type of entity storage connector to use for the email entries, defaults to "email-entry".
|
|
31
283
|
*/
|
|
32
284
|
constructor(options) {
|
|
33
285
|
if (Is.stringValue(options?.loggingConnectorType)) {
|
|
34
286
|
this._logging = LoggingConnectorFactory.get(options.loggingConnectorType);
|
|
35
287
|
}
|
|
36
|
-
this.
|
|
288
|
+
this._messagingEmailEntryStorage = EntityStorageConnectorFactory.get(options?.messagingEmailEntryStorageConnectorType ??
|
|
289
|
+
StringHelper.kebabCase("EmailEntry"));
|
|
37
290
|
}
|
|
38
291
|
/**
|
|
39
292
|
* Store a custom email using Entity Storage.
|
|
@@ -68,7 +321,7 @@ class EntityStorageMessagingEmailConnector {
|
|
|
68
321
|
subject,
|
|
69
322
|
status: "pending"
|
|
70
323
|
};
|
|
71
|
-
await this.
|
|
324
|
+
await this._messagingEmailEntryStorage.set(entity);
|
|
72
325
|
return true;
|
|
73
326
|
}
|
|
74
327
|
catch (err) {
|
|
@@ -106,15 +359,17 @@ class EntityStorageMessagingPushNotificationConnector {
|
|
|
106
359
|
* Create a new instance of EntityStorageMessagingPushNotificationConnector.
|
|
107
360
|
* @param options The options for the connector.
|
|
108
361
|
* @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
|
|
109
|
-
* @param options.
|
|
110
|
-
* @param options.
|
|
362
|
+
* @param options.messagingDeviceEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-device-entry".
|
|
363
|
+
* @param options.messagingMessageEntryStorageConnectorType The type of entity storage connector to use for the push notifications entries, defaults to "push-notification-message-entry".
|
|
111
364
|
*/
|
|
112
365
|
constructor(options) {
|
|
113
366
|
if (Is.stringValue(options?.loggingConnectorType)) {
|
|
114
367
|
this._logging = LoggingConnectorFactory.get(options.loggingConnectorType);
|
|
115
368
|
}
|
|
116
|
-
this._messagingDeviceEntryStorage = EntityStorageConnectorFactory.get(options?.
|
|
117
|
-
|
|
369
|
+
this._messagingDeviceEntryStorage = EntityStorageConnectorFactory.get(options?.messagingDeviceEntryStorageConnectorType ??
|
|
370
|
+
StringHelper.kebabCase("PushNotificationDeviceEntry"));
|
|
371
|
+
this._messagingMessageEntryStorage = EntityStorageConnectorFactory.get(options?.messagingMessageEntryStorageConnectorType ??
|
|
372
|
+
StringHelper.kebabCase("PushNotificationMessageEntry"));
|
|
118
373
|
}
|
|
119
374
|
/**
|
|
120
375
|
* Registers a device to an specific app in order to send notifications to it.
|
|
@@ -202,19 +457,18 @@ class EntityStorageMessagingSmsConnector {
|
|
|
202
457
|
* The entity storage for the sms entries.
|
|
203
458
|
* @internal
|
|
204
459
|
*/
|
|
205
|
-
|
|
460
|
+
_messagingSmsEntryStorage;
|
|
206
461
|
/**
|
|
207
462
|
* Create a new instance of EntityStorageMessagingSmsConnector.
|
|
208
463
|
* @param options The options for the connector.
|
|
209
464
|
* @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
|
|
210
|
-
* @param options.
|
|
211
|
-
* @param options.config The configuration for the sms connector.
|
|
465
|
+
* @param options.messagingSmsEntryStorageConnectorType The type of entity storage connector to use for the sms entries, defaults to "sms-entry".
|
|
212
466
|
*/
|
|
213
467
|
constructor(options) {
|
|
214
468
|
if (Is.stringValue(options?.loggingConnectorType)) {
|
|
215
469
|
this._logging = LoggingConnectorFactory.get(options.loggingConnectorType);
|
|
216
470
|
}
|
|
217
|
-
this.
|
|
471
|
+
this._messagingSmsEntryStorage = EntityStorageConnectorFactory.get(options?.messagingSmsEntryStorageConnectorType ?? StringHelper.kebabCase("SmsEntry"));
|
|
218
472
|
}
|
|
219
473
|
/**
|
|
220
474
|
* Send a SMS message to a phone number.
|
|
@@ -240,7 +494,7 @@ class EntityStorageMessagingSmsConnector {
|
|
|
240
494
|
ts: Date.now(),
|
|
241
495
|
status: "sent"
|
|
242
496
|
};
|
|
243
|
-
await this.
|
|
497
|
+
await this._messagingSmsEntryStorage.set(entity);
|
|
244
498
|
return true;
|
|
245
499
|
}
|
|
246
500
|
catch (err) {
|
|
@@ -249,4 +503,26 @@ class EntityStorageMessagingSmsConnector {
|
|
|
249
503
|
}
|
|
250
504
|
}
|
|
251
505
|
|
|
252
|
-
|
|
506
|
+
// Copyright 2024 IOTA Stiftung.
|
|
507
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
508
|
+
/**
|
|
509
|
+
* Initialize the schema for the messaging connector entity storage.
|
|
510
|
+
* @param options The options for the initialisation.
|
|
511
|
+
* @param options.email Should we register email schemas.
|
|
512
|
+
* @param options.sms Should we register sms schemas.
|
|
513
|
+
* @param options.pushNotification Should we register push notification schemas.
|
|
514
|
+
*/
|
|
515
|
+
function initSchema(options) {
|
|
516
|
+
if (options?.email ?? true) {
|
|
517
|
+
EntitySchemaFactory.register("EmailEntry", () => EntitySchemaHelper.getSchema(EmailEntry));
|
|
518
|
+
}
|
|
519
|
+
if (options?.pushNotification ?? true) {
|
|
520
|
+
EntitySchemaFactory.register("PushNotificationDeviceEntry", () => EntitySchemaHelper.getSchema(PushNotificationDeviceEntry));
|
|
521
|
+
EntitySchemaFactory.register("PushNotificationMessageEntry", () => EntitySchemaHelper.getSchema(PushNotificationMessageEntry));
|
|
522
|
+
}
|
|
523
|
+
if (options?.sms ?? true) {
|
|
524
|
+
EntitySchemaFactory.register("SmsEntry", () => EntitySchemaHelper.getSchema(SmsEntry));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
export { EmailEntry, EntityStorageMessagingEmailConnector, EntityStorageMessagingPushNotificationConnector, EntityStorageMessagingSmsConnector, PushNotificationDeviceEntry, PushNotificationMessageEntry, SmsEntry, 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.
|
|
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
|
-
|
|
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.
|
|
16
|
-
* @param options.
|
|
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
|
-
|
|
21
|
-
|
|
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.
|
|
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
|
-
|
|
21
|
-
config?: IEntityStorageMessagingSmsConnectorConfig;
|
|
18
|
+
messagingSmsEntryStorageConnectorType?: string;
|
|
22
19
|
});
|
|
23
20
|
/**
|
|
24
21
|
* Send a SMS message to a phone number.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from "./entities/emailEntry";
|
|
2
|
+
export * from "./entities/pushNotificationDeviceEntry";
|
|
3
|
+
export * from "./entities/pushNotificationMessageEntry";
|
|
4
|
+
export * from "./entities/smsEntry";
|
|
1
5
|
export * from "./entityStorageMessagingEmailConnector";
|
|
2
6
|
export * from "./entityStorageMessagingPushNotificationConnector";
|
|
3
7
|
export * from "./entityStorageMessagingSmsConnector";
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./models/IEntityStorageMessagingPushNotificationsConnectorConfig";
|
|
6
|
-
export * from "./models/IEntityStorageMessagingSmsConnectorConfig";
|
|
8
|
+
export * from "./schema";
|
package/dist/types/schema.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Initialize the schema for the messaging connector entity storage.
|
|
3
|
+
* @param options The options for the initialisation.
|
|
4
|
+
* @param options.email Should we register email schemas.
|
|
5
|
+
* @param options.sms Should we register sms schemas.
|
|
6
|
+
* @param options.pushNotification Should we register push notification schemas.
|
|
3
7
|
*/
|
|
4
|
-
export declare function initSchema(
|
|
8
|
+
export declare function initSchema(options?: {
|
|
9
|
+
email?: boolean;
|
|
10
|
+
sms?: boolean;
|
|
11
|
+
pushNotification?: boolean;
|
|
12
|
+
}): void;
|
package/docs/changelog.md
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Class: EmailEntry
|
|
2
|
+
|
|
3
|
+
Call defining an email entry.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new EmailEntry()
|
|
8
|
+
|
|
9
|
+
> **new EmailEntry**(): [`EmailEntry`](EmailEntry.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`EmailEntry`](EmailEntry.md)
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### id
|
|
18
|
+
|
|
19
|
+
> **id**: `string`
|
|
20
|
+
|
|
21
|
+
The id.
|
|
22
|
+
|
|
23
|
+
***
|
|
24
|
+
|
|
25
|
+
### sender
|
|
26
|
+
|
|
27
|
+
> **sender**: `string`
|
|
28
|
+
|
|
29
|
+
The sender email address.
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### recipients
|
|
34
|
+
|
|
35
|
+
> **recipients**: `string`[]
|
|
36
|
+
|
|
37
|
+
The recipient email addresses.
|
|
38
|
+
|
|
39
|
+
***
|
|
40
|
+
|
|
41
|
+
### ts
|
|
42
|
+
|
|
43
|
+
> **ts**: `number`
|
|
44
|
+
|
|
45
|
+
The timestamp of the email entry.
|
|
46
|
+
|
|
47
|
+
***
|
|
48
|
+
|
|
49
|
+
### message
|
|
50
|
+
|
|
51
|
+
> **message**: `string`
|
|
52
|
+
|
|
53
|
+
The message.
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### subject
|
|
58
|
+
|
|
59
|
+
> **subject**: `string`
|
|
60
|
+
|
|
61
|
+
The subject.
|
|
62
|
+
|
|
63
|
+
***
|
|
64
|
+
|
|
65
|
+
### status
|
|
66
|
+
|
|
67
|
+
> **status**: `string`
|
|
68
|
+
|
|
69
|
+
The status.
|
|
70
|
+
|
|
71
|
+
***
|
|
72
|
+
|
|
73
|
+
### error?
|
|
74
|
+
|
|
75
|
+
> `optional` **error**: `IError`
|
|
76
|
+
|
|
77
|
+
The error.
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
31
|
+
• **options.messagingMessageEntryStorageConnectorType?**: `string`
|
|
32
32
|
|
|
33
|
-
The
|
|
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.
|
|
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,61 @@
|
|
|
1
|
+
# Class: PushNotificationDeviceEntry
|
|
2
|
+
|
|
3
|
+
Call defining an push notification device entry.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new PushNotificationDeviceEntry()
|
|
8
|
+
|
|
9
|
+
> **new PushNotificationDeviceEntry**(): [`PushNotificationDeviceEntry`](PushNotificationDeviceEntry.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`PushNotificationDeviceEntry`](PushNotificationDeviceEntry.md)
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### id
|
|
18
|
+
|
|
19
|
+
> **id**: `string`
|
|
20
|
+
|
|
21
|
+
The id.
|
|
22
|
+
|
|
23
|
+
***
|
|
24
|
+
|
|
25
|
+
### applicationId
|
|
26
|
+
|
|
27
|
+
> **applicationId**: `string`
|
|
28
|
+
|
|
29
|
+
The applicationId.
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### deviceToken
|
|
34
|
+
|
|
35
|
+
> **deviceToken**: `string`
|
|
36
|
+
|
|
37
|
+
The device token.
|
|
38
|
+
|
|
39
|
+
***
|
|
40
|
+
|
|
41
|
+
### ts
|
|
42
|
+
|
|
43
|
+
> **ts**: `number`
|
|
44
|
+
|
|
45
|
+
The timestamp of the push notification device entry.
|
|
46
|
+
|
|
47
|
+
***
|
|
48
|
+
|
|
49
|
+
### status
|
|
50
|
+
|
|
51
|
+
> **status**: `string`
|
|
52
|
+
|
|
53
|
+
The status.
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### error?
|
|
58
|
+
|
|
59
|
+
> `optional` **error**: `IError`
|
|
60
|
+
|
|
61
|
+
The error.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Class: PushNotificationMessageEntry
|
|
2
|
+
|
|
3
|
+
Call defining an push notification message entry.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new PushNotificationMessageEntry()
|
|
8
|
+
|
|
9
|
+
> **new PushNotificationMessageEntry**(): [`PushNotificationMessageEntry`](PushNotificationMessageEntry.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`PushNotificationMessageEntry`](PushNotificationMessageEntry.md)
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### id
|
|
18
|
+
|
|
19
|
+
> **id**: `string`
|
|
20
|
+
|
|
21
|
+
The id.
|
|
22
|
+
|
|
23
|
+
***
|
|
24
|
+
|
|
25
|
+
### deviceAddress
|
|
26
|
+
|
|
27
|
+
> **deviceAddress**: `string`
|
|
28
|
+
|
|
29
|
+
The device address.
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### title
|
|
34
|
+
|
|
35
|
+
> **title**: `string`
|
|
36
|
+
|
|
37
|
+
The title.
|
|
38
|
+
|
|
39
|
+
***
|
|
40
|
+
|
|
41
|
+
### message
|
|
42
|
+
|
|
43
|
+
> **message**: `string`
|
|
44
|
+
|
|
45
|
+
The message.
|
|
46
|
+
|
|
47
|
+
***
|
|
48
|
+
|
|
49
|
+
### ts
|
|
50
|
+
|
|
51
|
+
> **ts**: `number`
|
|
52
|
+
|
|
53
|
+
The timestamp of the push notification entry.
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### status
|
|
58
|
+
|
|
59
|
+
> **status**: `string`
|
|
60
|
+
|
|
61
|
+
The status.
|
|
62
|
+
|
|
63
|
+
***
|
|
64
|
+
|
|
65
|
+
### error?
|
|
66
|
+
|
|
67
|
+
> `optional` **error**: `IError`
|
|
68
|
+
|
|
69
|
+
The error.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Class: SmsEntry
|
|
2
|
+
|
|
3
|
+
Call defining an sms entry.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new SmsEntry()
|
|
8
|
+
|
|
9
|
+
> **new SmsEntry**(): [`SmsEntry`](SmsEntry.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`SmsEntry`](SmsEntry.md)
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### id
|
|
18
|
+
|
|
19
|
+
> **id**: `string`
|
|
20
|
+
|
|
21
|
+
The id.
|
|
22
|
+
|
|
23
|
+
***
|
|
24
|
+
|
|
25
|
+
### phoneNumber
|
|
26
|
+
|
|
27
|
+
> **phoneNumber**: `string`
|
|
28
|
+
|
|
29
|
+
The phone number to deliver the message.
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### ts
|
|
34
|
+
|
|
35
|
+
> **ts**: `number`
|
|
36
|
+
|
|
37
|
+
The timestamp of the sms entry.
|
|
38
|
+
|
|
39
|
+
***
|
|
40
|
+
|
|
41
|
+
### message
|
|
42
|
+
|
|
43
|
+
> **message**: `string`
|
|
44
|
+
|
|
45
|
+
The message.
|
|
46
|
+
|
|
47
|
+
***
|
|
48
|
+
|
|
49
|
+
### status
|
|
50
|
+
|
|
51
|
+
> **status**: `string`
|
|
52
|
+
|
|
53
|
+
The status.
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### error?
|
|
58
|
+
|
|
59
|
+
> `optional` **error**: `IError`
|
|
60
|
+
|
|
61
|
+
The error.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Function: initSchema()
|
|
2
|
+
|
|
3
|
+
> **initSchema**(`options`?): `void`
|
|
4
|
+
|
|
5
|
+
Initialize the schema for the messaging connector entity storage.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
• **options?**
|
|
10
|
+
|
|
11
|
+
The options for the initialisation.
|
|
12
|
+
|
|
13
|
+
• **options.email?**: `boolean`
|
|
14
|
+
|
|
15
|
+
Should we register email schemas.
|
|
16
|
+
|
|
17
|
+
• **options.sms?**: `boolean`
|
|
18
|
+
|
|
19
|
+
Should we register sms schemas.
|
|
20
|
+
|
|
21
|
+
• **options.pushNotification?**: `boolean`
|
|
22
|
+
|
|
23
|
+
Should we register push notification schemas.
|
|
24
|
+
|
|
25
|
+
## Returns
|
|
26
|
+
|
|
27
|
+
`void`
|
package/docs/reference/index.md
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Classes
|
|
4
4
|
|
|
5
|
+
- [EmailEntry](classes/EmailEntry.md)
|
|
6
|
+
- [PushNotificationDeviceEntry](classes/PushNotificationDeviceEntry.md)
|
|
7
|
+
- [PushNotificationMessageEntry](classes/PushNotificationMessageEntry.md)
|
|
8
|
+
- [SmsEntry](classes/SmsEntry.md)
|
|
5
9
|
- [EntityStorageMessagingEmailConnector](classes/EntityStorageMessagingEmailConnector.md)
|
|
6
10
|
- [EntityStorageMessagingPushNotificationConnector](classes/EntityStorageMessagingPushNotificationConnector.md)
|
|
7
11
|
- [EntityStorageMessagingSmsConnector](classes/EntityStorageMessagingSmsConnector.md)
|
|
8
12
|
|
|
9
|
-
##
|
|
13
|
+
## Functions
|
|
10
14
|
|
|
11
|
-
- [
|
|
12
|
-
- [IEntityStorageMessagingPushNotificationsConnectorConfig](type-aliases/IEntityStorageMessagingPushNotificationsConnectorConfig.md)
|
|
13
|
-
- [IEntityStorageMessagingSmsConnectorConfig](type-aliases/IEntityStorageMessagingSmsConnectorConfig.md)
|
|
15
|
+
- [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.
|
|
3
|
+
"version": "0.0.1-next.4",
|
|
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.
|
|
20
|
+
"@twin.org/messaging-models": "0.0.1-next.4",
|
|
21
21
|
"@twin.org/nameof": "next"
|
|
22
22
|
},
|
|
23
23
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -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;
|