@twin.org/messaging-connector-entity-storage 0.0.2-next.6 → 0.0.3-next.2
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/es/entities/emailEntry.js +75 -0
- package/dist/es/entities/emailEntry.js.map +1 -0
- package/dist/es/entities/pushNotificationDeviceEntry.js +59 -0
- package/dist/es/entities/pushNotificationDeviceEntry.js.map +1 -0
- package/dist/es/entities/pushNotificationMessageEntry.js +67 -0
- package/dist/es/entities/pushNotificationMessageEntry.js.map +1 -0
- package/dist/es/entities/smsEntry.js +59 -0
- package/dist/es/entities/smsEntry.js.map +1 -0
- package/dist/es/entityStorageMessagingEmailConnector.js +83 -0
- package/dist/es/entityStorageMessagingEmailConnector.js.map +1 -0
- package/dist/es/entityStorageMessagingPushNotificationConnector.js +114 -0
- package/dist/es/entityStorageMessagingPushNotificationConnector.js.map +1 -0
- package/dist/es/entityStorageMessagingSmsConnector.js +74 -0
- package/dist/es/entityStorageMessagingSmsConnector.js.map +1 -0
- package/dist/es/index.js +14 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IEntityStorageMessagingEmailConnectorConstructorOptions.js +4 -0
- package/dist/es/models/IEntityStorageMessagingEmailConnectorConstructorOptions.js.map +1 -0
- package/dist/es/models/IEntityStorageMessagingPushNotificationConnectorConstructorOptions.js +4 -0
- package/dist/es/models/IEntityStorageMessagingPushNotificationConnectorConstructorOptions.js.map +1 -0
- package/dist/es/models/IEntityStorageMessagingSmsConnectorConstructorOptions.js +4 -0
- package/dist/es/models/IEntityStorageMessagingSmsConnectorConstructorOptions.js.map +1 -0
- package/dist/es/schema.js +27 -0
- package/dist/es/schema.js.map +1 -0
- package/dist/types/entityStorageMessagingEmailConnector.d.ts +6 -1
- package/dist/types/entityStorageMessagingPushNotificationConnector.d.ts +6 -1
- package/dist/types/entityStorageMessagingSmsConnector.d.ts +6 -1
- package/dist/types/index.d.ts +11 -11
- package/docs/changelog.md +41 -0
- package/docs/reference/classes/EntityStorageMessagingEmailConnector.md +18 -0
- package/docs/reference/classes/EntityStorageMessagingPushNotificationConnector.md +18 -0
- package/docs/reference/classes/EntityStorageMessagingSmsConnector.md +18 -0
- package/package.json +7 -10
- package/dist/cjs/index.cjs +0 -528
- package/dist/esm/index.mjs +0 -523
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { entity, property, SortDirection } from "@twin.org/entity";
|
|
2
|
+
/**
|
|
3
|
+
* Call defining an email entry.
|
|
4
|
+
*/
|
|
5
|
+
let EmailEntry = class EmailEntry {
|
|
6
|
+
/**
|
|
7
|
+
* The id.
|
|
8
|
+
*/
|
|
9
|
+
id;
|
|
10
|
+
/**
|
|
11
|
+
* The sender email address.
|
|
12
|
+
*/
|
|
13
|
+
sender;
|
|
14
|
+
/**
|
|
15
|
+
* The recipient email addresses.
|
|
16
|
+
*/
|
|
17
|
+
recipients;
|
|
18
|
+
/**
|
|
19
|
+
* The timestamp of the email entry.
|
|
20
|
+
*/
|
|
21
|
+
ts;
|
|
22
|
+
/**
|
|
23
|
+
* The message.
|
|
24
|
+
*/
|
|
25
|
+
message;
|
|
26
|
+
/**
|
|
27
|
+
* The subject.
|
|
28
|
+
*/
|
|
29
|
+
subject;
|
|
30
|
+
/**
|
|
31
|
+
* The status.
|
|
32
|
+
*/
|
|
33
|
+
status;
|
|
34
|
+
/**
|
|
35
|
+
* The error.
|
|
36
|
+
*/
|
|
37
|
+
error;
|
|
38
|
+
};
|
|
39
|
+
__decorate([
|
|
40
|
+
property({ type: "string", isPrimary: true }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], EmailEntry.prototype, "id", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
property({ type: "string" }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], EmailEntry.prototype, "sender", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
property({ type: "array", itemType: "string" }),
|
|
49
|
+
__metadata("design:type", Array)
|
|
50
|
+
], EmailEntry.prototype, "recipients", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
property({ type: "integer", format: "uint64", sortDirection: SortDirection.Descending }),
|
|
53
|
+
__metadata("design:type", Number)
|
|
54
|
+
], EmailEntry.prototype, "ts", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
property({ type: "string" }),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], EmailEntry.prototype, "message", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
property({ type: "string" }),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], EmailEntry.prototype, "subject", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
property({ type: "string" }),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], EmailEntry.prototype, "status", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
property({ type: "object", optional: true }),
|
|
69
|
+
__metadata("design:type", Object)
|
|
70
|
+
], EmailEntry.prototype, "error", void 0);
|
|
71
|
+
EmailEntry = __decorate([
|
|
72
|
+
entity()
|
|
73
|
+
], EmailEntry);
|
|
74
|
+
export { EmailEntry };
|
|
75
|
+
//# sourceMappingURL=emailEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emailEntry.js","sourceRoot":"","sources":["../../../src/entities/emailEntry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;GAEG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAU;IACtB;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,MAAM,CAAU;IAEvB;;OAEG;IAEI,UAAU,CAAY;IAE7B;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,OAAO,CAAU;IAExB;;OAEG;IAEI,OAAO,CAAU;IAExB;;OAEG;IAEI,MAAM,CAAU;IAEvB;;OAEG;IAEI,KAAK,CAAU;CACtB,CAAA;AA3CO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;sCAC3B;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;0CACN;AAMhB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;;8CACnB;AAMtB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC;;sCACtE;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;2CACL;AAMjB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;2CACL;AAMjB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;0CACN;AAMhB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACvB;AA/CV,UAAU;IADtB,MAAM,EAAE;GACI,UAAU,CAgDtB","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IError } from \"@twin.org/core\";\nimport { entity, property, SortDirection } from \"@twin.org/entity\";\n\n/**\n * Call defining an email entry.\n */\n@entity()\nexport class EmailEntry {\n\t/**\n\t * The id.\n\t */\n\t@property({ type: \"string\", isPrimary: true })\n\tpublic id!: string;\n\n\t/**\n\t * The sender email address.\n\t */\n\t@property({ type: \"string\" })\n\tpublic sender!: string;\n\n\t/**\n\t * The recipient email addresses.\n\t */\n\t@property({ type: \"array\", itemType: \"string\" })\n\tpublic recipients!: string[];\n\n\t/**\n\t * The timestamp of the email entry.\n\t */\n\t@property({ type: \"integer\", format: \"uint64\", sortDirection: SortDirection.Descending })\n\tpublic ts!: number;\n\n\t/**\n\t * The message.\n\t */\n\t@property({ type: \"string\" })\n\tpublic message!: string;\n\n\t/**\n\t * The subject.\n\t */\n\t@property({ type: \"string\" })\n\tpublic subject!: string;\n\n\t/**\n\t * The status.\n\t */\n\t@property({ type: \"string\" })\n\tpublic status!: string;\n\n\t/**\n\t * The error.\n\t */\n\t@property({ type: \"object\", optional: true })\n\tpublic error?: IError;\n}\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { entity, property, SortDirection } from "@twin.org/entity";
|
|
2
|
+
/**
|
|
3
|
+
* Call defining an push notification device entry.
|
|
4
|
+
*/
|
|
5
|
+
let PushNotificationDeviceEntry = class PushNotificationDeviceEntry {
|
|
6
|
+
/**
|
|
7
|
+
* The id.
|
|
8
|
+
*/
|
|
9
|
+
id;
|
|
10
|
+
/**
|
|
11
|
+
* The applicationId.
|
|
12
|
+
*/
|
|
13
|
+
applicationId;
|
|
14
|
+
/**
|
|
15
|
+
* The device token.
|
|
16
|
+
*/
|
|
17
|
+
deviceToken;
|
|
18
|
+
/**
|
|
19
|
+
* The timestamp of the push notification device entry.
|
|
20
|
+
*/
|
|
21
|
+
ts;
|
|
22
|
+
/**
|
|
23
|
+
* The status.
|
|
24
|
+
*/
|
|
25
|
+
status;
|
|
26
|
+
/**
|
|
27
|
+
* The error.
|
|
28
|
+
*/
|
|
29
|
+
error;
|
|
30
|
+
};
|
|
31
|
+
__decorate([
|
|
32
|
+
property({ type: "string", isPrimary: true }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], PushNotificationDeviceEntry.prototype, "id", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
property({ type: "string" }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], PushNotificationDeviceEntry.prototype, "applicationId", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
property({ type: "string" }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], PushNotificationDeviceEntry.prototype, "deviceToken", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
property({ type: "integer", format: "uint64", sortDirection: SortDirection.Descending }),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], PushNotificationDeviceEntry.prototype, "ts", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
property({ type: "string" }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], PushNotificationDeviceEntry.prototype, "status", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
property({ type: "object", optional: true }),
|
|
53
|
+
__metadata("design:type", Object)
|
|
54
|
+
], PushNotificationDeviceEntry.prototype, "error", void 0);
|
|
55
|
+
PushNotificationDeviceEntry = __decorate([
|
|
56
|
+
entity()
|
|
57
|
+
], PushNotificationDeviceEntry);
|
|
58
|
+
export { PushNotificationDeviceEntry };
|
|
59
|
+
//# sourceMappingURL=pushNotificationDeviceEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pushNotificationDeviceEntry.js","sourceRoot":"","sources":["../../../src/entities/pushNotificationDeviceEntry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;GAEG;AAEI,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IACvC;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,aAAa,CAAU;IAE9B;;OAEG;IAEI,WAAW,CAAU;IAE5B;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,MAAM,CAAU;IAEvB;;OAEG;IAEI,KAAK,CAAU;CACtB,CAAA;AA/BO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;uDAC3B;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;kEACC;AAMvB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;gEACD;AAMrB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC;;uDACtE;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;2DACN;AAMhB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DACvB;AAnCV,2BAA2B;IADvC,MAAM,EAAE;GACI,2BAA2B,CAoCvC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IError } from \"@twin.org/core\";\nimport { entity, property, SortDirection } from \"@twin.org/entity\";\n\n/**\n * Call defining an push notification device entry.\n */\n@entity()\nexport class PushNotificationDeviceEntry {\n\t/**\n\t * The id.\n\t */\n\t@property({ type: \"string\", isPrimary: true })\n\tpublic id!: string;\n\n\t/**\n\t * The applicationId.\n\t */\n\t@property({ type: \"string\" })\n\tpublic applicationId!: string;\n\n\t/**\n\t * The device token.\n\t */\n\t@property({ type: \"string\" })\n\tpublic deviceToken!: string;\n\n\t/**\n\t * The timestamp of the push notification device entry.\n\t */\n\t@property({ type: \"integer\", format: \"uint64\", sortDirection: SortDirection.Descending })\n\tpublic ts!: number;\n\n\t/**\n\t * The status.\n\t */\n\t@property({ type: \"string\" })\n\tpublic status!: string;\n\n\t/**\n\t * The error.\n\t */\n\t@property({ type: \"object\", optional: true })\n\tpublic error?: IError;\n}\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { entity, property, SortDirection } from "@twin.org/entity";
|
|
2
|
+
/**
|
|
3
|
+
* Call defining an push notification message entry.
|
|
4
|
+
*/
|
|
5
|
+
let PushNotificationMessageEntry = class PushNotificationMessageEntry {
|
|
6
|
+
/**
|
|
7
|
+
* The id.
|
|
8
|
+
*/
|
|
9
|
+
id;
|
|
10
|
+
/**
|
|
11
|
+
* The device address.
|
|
12
|
+
*/
|
|
13
|
+
deviceAddress;
|
|
14
|
+
/**
|
|
15
|
+
* The title.
|
|
16
|
+
*/
|
|
17
|
+
title;
|
|
18
|
+
/**
|
|
19
|
+
* The message.
|
|
20
|
+
*/
|
|
21
|
+
message;
|
|
22
|
+
/**
|
|
23
|
+
* The timestamp of the push notification entry.
|
|
24
|
+
*/
|
|
25
|
+
ts;
|
|
26
|
+
/**
|
|
27
|
+
* The status.
|
|
28
|
+
*/
|
|
29
|
+
status;
|
|
30
|
+
/**
|
|
31
|
+
* The error.
|
|
32
|
+
*/
|
|
33
|
+
error;
|
|
34
|
+
};
|
|
35
|
+
__decorate([
|
|
36
|
+
property({ type: "string", isPrimary: true }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], PushNotificationMessageEntry.prototype, "id", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
property({ type: "string" }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], PushNotificationMessageEntry.prototype, "deviceAddress", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
property({ type: "string" }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], PushNotificationMessageEntry.prototype, "title", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
property({ type: "string" }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], PushNotificationMessageEntry.prototype, "message", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
property({ type: "integer", format: "uint64", sortDirection: SortDirection.Descending }),
|
|
53
|
+
__metadata("design:type", Number)
|
|
54
|
+
], PushNotificationMessageEntry.prototype, "ts", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
property({ type: "string" }),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], PushNotificationMessageEntry.prototype, "status", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
property({ type: "object", optional: true }),
|
|
61
|
+
__metadata("design:type", Object)
|
|
62
|
+
], PushNotificationMessageEntry.prototype, "error", void 0);
|
|
63
|
+
PushNotificationMessageEntry = __decorate([
|
|
64
|
+
entity()
|
|
65
|
+
], PushNotificationMessageEntry);
|
|
66
|
+
export { PushNotificationMessageEntry };
|
|
67
|
+
//# sourceMappingURL=pushNotificationMessageEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pushNotificationMessageEntry.js","sourceRoot":"","sources":["../../../src/entities/pushNotificationMessageEntry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;GAEG;AAEI,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IACxC;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,aAAa,CAAU;IAE9B;;OAEG;IAEI,KAAK,CAAU;IAEtB;;OAEG;IAEI,OAAO,CAAU;IAExB;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,MAAM,CAAU;IAEvB;;OAEG;IAEI,KAAK,CAAU;CACtB,CAAA;AArCO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;wDAC3B;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;mEACC;AAMvB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;2DACP;AAMf;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;6DACL;AAMjB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC;;wDACtE;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;4DACN;AAMhB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2DACvB;AAzCV,4BAA4B;IADxC,MAAM,EAAE;GACI,4BAA4B,CA0CxC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IError } from \"@twin.org/core\";\nimport { entity, property, SortDirection } from \"@twin.org/entity\";\n\n/**\n * Call defining an push notification message entry.\n */\n@entity()\nexport class PushNotificationMessageEntry {\n\t/**\n\t * The id.\n\t */\n\t@property({ type: \"string\", isPrimary: true })\n\tpublic id!: string;\n\n\t/**\n\t * The device address.\n\t */\n\t@property({ type: \"string\" })\n\tpublic deviceAddress!: string;\n\n\t/**\n\t * The title.\n\t */\n\t@property({ type: \"string\" })\n\tpublic title!: string;\n\n\t/**\n\t * The message.\n\t */\n\t@property({ type: \"string\" })\n\tpublic message!: string;\n\n\t/**\n\t * The timestamp of the push notification entry.\n\t */\n\t@property({ type: \"integer\", format: \"uint64\", sortDirection: SortDirection.Descending })\n\tpublic ts!: number;\n\n\t/**\n\t * The status.\n\t */\n\t@property({ type: \"string\" })\n\tpublic status!: string;\n\n\t/**\n\t * The error.\n\t */\n\t@property({ type: \"object\", optional: true })\n\tpublic error?: IError;\n}\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { entity, property, SortDirection } from "@twin.org/entity";
|
|
2
|
+
/**
|
|
3
|
+
* Call defining an sms entry.
|
|
4
|
+
*/
|
|
5
|
+
let SmsEntry = class SmsEntry {
|
|
6
|
+
/**
|
|
7
|
+
* The id.
|
|
8
|
+
*/
|
|
9
|
+
id;
|
|
10
|
+
/**
|
|
11
|
+
* The phone number to deliver the message.
|
|
12
|
+
*/
|
|
13
|
+
phoneNumber;
|
|
14
|
+
/**
|
|
15
|
+
* The timestamp of the sms entry.
|
|
16
|
+
*/
|
|
17
|
+
ts;
|
|
18
|
+
/**
|
|
19
|
+
* The message.
|
|
20
|
+
*/
|
|
21
|
+
message;
|
|
22
|
+
/**
|
|
23
|
+
* The status.
|
|
24
|
+
*/
|
|
25
|
+
status;
|
|
26
|
+
/**
|
|
27
|
+
* The error.
|
|
28
|
+
*/
|
|
29
|
+
error;
|
|
30
|
+
};
|
|
31
|
+
__decorate([
|
|
32
|
+
property({ type: "string", isPrimary: true }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], SmsEntry.prototype, "id", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
property({ type: "string" }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], SmsEntry.prototype, "phoneNumber", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
property({ type: "integer", format: "uint64", sortDirection: SortDirection.Descending }),
|
|
41
|
+
__metadata("design:type", Number)
|
|
42
|
+
], SmsEntry.prototype, "ts", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
property({ type: "string" }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], SmsEntry.prototype, "message", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
property({ type: "string" }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], SmsEntry.prototype, "status", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
property({ type: "object", optional: true }),
|
|
53
|
+
__metadata("design:type", Object)
|
|
54
|
+
], SmsEntry.prototype, "error", void 0);
|
|
55
|
+
SmsEntry = __decorate([
|
|
56
|
+
entity()
|
|
57
|
+
], SmsEntry);
|
|
58
|
+
export { SmsEntry };
|
|
59
|
+
//# sourceMappingURL=smsEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smsEntry.js","sourceRoot":"","sources":["../../../src/entities/smsEntry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;GAEG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAQ;IACpB;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,WAAW,CAAU;IAE5B;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,OAAO,CAAU;IAExB;;OAEG;IAEI,MAAM,CAAU;IAEvB;;OAEG;IAEI,KAAK,CAAU;CACtB,CAAA;AA/BO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;oCAC3B;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;6CACD;AAMrB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC;;oCACtE;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;yCACL;AAMjB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;wCACN;AAMhB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACvB;AAnCV,QAAQ;IADpB,MAAM,EAAE;GACI,QAAQ,CAoCpB","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IError } from \"@twin.org/core\";\nimport { entity, property, SortDirection } from \"@twin.org/entity\";\n\n/**\n * Call defining an sms entry.\n */\n@entity()\nexport class SmsEntry {\n\t/**\n\t * The id.\n\t */\n\t@property({ type: \"string\", isPrimary: true })\n\tpublic id!: string;\n\n\t/**\n\t * The phone number to deliver the message.\n\t */\n\t@property({ type: \"string\" })\n\tpublic phoneNumber!: string;\n\n\t/**\n\t * The timestamp of the sms entry.\n\t */\n\t@property({ type: \"integer\", format: \"uint64\", sortDirection: SortDirection.Descending })\n\tpublic ts!: number;\n\n\t/**\n\t * The message.\n\t */\n\t@property({ type: \"string\" })\n\tpublic message!: string;\n\n\t/**\n\t * The status.\n\t */\n\t@property({ type: \"string\" })\n\tpublic status!: string;\n\n\t/**\n\t * The error.\n\t */\n\t@property({ type: \"object\", optional: true })\n\tpublic error?: IError;\n}\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ComponentFactory, Converter, GeneralError, Guards, RandomHelper } from "@twin.org/core";
|
|
4
|
+
import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
|
|
5
|
+
/**
|
|
6
|
+
* Class for connecting to the email messaging operations of the Entity Storage.
|
|
7
|
+
*/
|
|
8
|
+
export class EntityStorageMessagingEmailConnector {
|
|
9
|
+
/**
|
|
10
|
+
* The namespace for the connector.
|
|
11
|
+
*/
|
|
12
|
+
static NAMESPACE = "entity-storage";
|
|
13
|
+
/**
|
|
14
|
+
* Runtime name for the class.
|
|
15
|
+
*/
|
|
16
|
+
static CLASS_NAME = "EntityStorageMessagingEmailConnector";
|
|
17
|
+
/**
|
|
18
|
+
* The logging component.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
_logging;
|
|
22
|
+
/**
|
|
23
|
+
* The entity storage for the emails entries.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
_messagingEmailEntryStorage;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new instance of EntityStorageMessagingEmailConnector.
|
|
29
|
+
* @param options The options for the connector.
|
|
30
|
+
*/
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
|
|
33
|
+
this._messagingEmailEntryStorage = EntityStorageConnectorFactory.get(options?.messagingEmailEntryStorageConnectorType ?? "email-entry");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns the class name of the component.
|
|
37
|
+
* @returns The class name of the component.
|
|
38
|
+
*/
|
|
39
|
+
className() {
|
|
40
|
+
return EntityStorageMessagingEmailConnector.CLASS_NAME;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Store a custom email using Entity Storage.
|
|
44
|
+
* @param sender The sender email address.
|
|
45
|
+
* @param recipients An array of recipients email addresses.
|
|
46
|
+
* @param subject The subject of the email.
|
|
47
|
+
* @param content The html content of the email.
|
|
48
|
+
* @returns True if the email was send successfully, otherwise undefined.
|
|
49
|
+
*/
|
|
50
|
+
async sendCustomEmail(sender, recipients, subject, content) {
|
|
51
|
+
Guards.stringValue(EntityStorageMessagingEmailConnector.CLASS_NAME, "sender", sender);
|
|
52
|
+
Guards.arrayValue(EntityStorageMessagingEmailConnector.CLASS_NAME, "recipients", recipients);
|
|
53
|
+
Guards.stringValue(EntityStorageMessagingEmailConnector.CLASS_NAME, "subject", subject);
|
|
54
|
+
Guards.stringValue(EntityStorageMessagingEmailConnector.CLASS_NAME, "content", content);
|
|
55
|
+
try {
|
|
56
|
+
await this._logging?.log({
|
|
57
|
+
level: "info",
|
|
58
|
+
source: EntityStorageMessagingEmailConnector.CLASS_NAME,
|
|
59
|
+
ts: Date.now(),
|
|
60
|
+
message: "emailSending",
|
|
61
|
+
data: {
|
|
62
|
+
type: "Custom Email"
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const id = Converter.bytesToHex(RandomHelper.generate(32));
|
|
66
|
+
const entity = {
|
|
67
|
+
id,
|
|
68
|
+
sender,
|
|
69
|
+
recipients,
|
|
70
|
+
ts: Date.now(),
|
|
71
|
+
message: content,
|
|
72
|
+
subject,
|
|
73
|
+
status: "pending"
|
|
74
|
+
};
|
|
75
|
+
await this._messagingEmailEntryStorage.set(entity);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
throw new GeneralError(EntityStorageMessagingEmailConnector.CLASS_NAME, "sendCustomEmailFailed", undefined, err);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=entityStorageMessagingEmailConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityStorageMessagingEmailConnector.js","sourceRoot":"","sources":["../../src/entityStorageMessagingEmailConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACjG,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAOzC;;GAEG;AACH,MAAM,OAAO,oCAAoC;IAChD;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAU,UAAU,0CAA0D;IAE3F;;;OAGG;IACgB,QAAQ,CAAqB;IAEhD;;;OAGG;IACc,2BAA2B,CAAsC;IAElF;;;OAGG;IACH,YAAY,OAAiE;QAC5E,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAAC,CAAC;QACzF,IAAI,CAAC,2BAA2B,GAAG,6BAA6B,CAAC,GAAG,CACnE,OAAO,EAAE,uCAAuC,iBAAiC,CACjF,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,oCAAoC,CAAC,UAAU,CAAC;IACxD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,eAAe,CAC3B,MAAc,EACd,UAAoB,EACpB,OAAe,EACf,OAAe;QAEf,MAAM,CAAC,WAAW,CAAC,oCAAoC,CAAC,UAAU,YAAkB,MAAM,CAAC,CAAC;QAC5F,MAAM,CAAC,UAAU,CAChB,oCAAoC,CAAC,UAAU,gBAE/C,UAAU,CACV,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,oCAAoC,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAC9F,MAAM,CAAC,WAAW,CAAC,oCAAoC,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAC9F,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;gBACxB,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,oCAAoC,CAAC,UAAU;gBACvD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,cAAc;gBACvB,IAAI,EAAE;oBACL,IAAI,EAAE,cAAc;iBACpB;aACD,CAAC,CAAC;YAEH,MAAM,EAAE,GAAG,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YAE3D,MAAM,MAAM,GAAe;gBAC1B,EAAE;gBACF,MAAM;gBACN,UAAU;gBACV,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,OAAO;gBAChB,OAAO;gBACP,MAAM,EAAE,SAAS;aACjB,CAAC;YAEF,MAAM,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAEnD,OAAO,IAAI,CAAC;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CACrB,oCAAoC,CAAC,UAAU,EAC/C,uBAAuB,EACvB,SAAS,EACT,GAAG,CACH,CAAC;QACH,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Converter, GeneralError, Guards, RandomHelper } from \"@twin.org/core\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport type { IMessagingEmailConnector } from \"@twin.org/messaging-models\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport type { EmailEntry } from \"./entities/emailEntry.js\";\nimport type { IEntityStorageMessagingEmailConnectorConstructorOptions } from \"./models/IEntityStorageMessagingEmailConnectorConstructorOptions.js\";\n\n/**\n * Class for connecting to the email messaging operations of the Entity Storage.\n */\nexport class EntityStorageMessagingEmailConnector implements IMessagingEmailConnector {\n\t/**\n\t * The namespace for the connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageMessagingEmailConnector>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprotected readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * The entity storage for the emails entries.\n\t * @internal\n\t */\n\tprivate readonly _messagingEmailEntryStorage: IEntityStorageConnector<EmailEntry>;\n\n\t/**\n\t * Create a new instance of EntityStorageMessagingEmailConnector.\n\t * @param options The options for the connector.\n\t */\n\tconstructor(options?: IEntityStorageMessagingEmailConnectorConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? \"logging\");\n\t\tthis._messagingEmailEntryStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.messagingEmailEntryStorageConnectorType ?? nameofKebabCase<EmailEntry>()\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageMessagingEmailConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Store a custom email using Entity Storage.\n\t * @param sender The sender email address.\n\t * @param recipients An array of recipients email addresses.\n\t * @param subject The subject of the email.\n\t * @param content The html content of the email.\n\t * @returns True if the email was send successfully, otherwise undefined.\n\t */\n\tpublic async sendCustomEmail(\n\t\tsender: string,\n\t\trecipients: string[],\n\t\tsubject: string,\n\t\tcontent: string\n\t): Promise<boolean> {\n\t\tGuards.stringValue(EntityStorageMessagingEmailConnector.CLASS_NAME, nameof(sender), sender);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageMessagingEmailConnector.CLASS_NAME,\n\t\t\tnameof(recipients),\n\t\t\trecipients\n\t\t);\n\t\tGuards.stringValue(EntityStorageMessagingEmailConnector.CLASS_NAME, nameof(subject), subject);\n\t\tGuards.stringValue(EntityStorageMessagingEmailConnector.CLASS_NAME, nameof(content), content);\n\t\ttry {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: EntityStorageMessagingEmailConnector.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"emailSending\",\n\t\t\t\tdata: {\n\t\t\t\t\ttype: \"Custom Email\"\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst id = Converter.bytesToHex(RandomHelper.generate(32));\n\n\t\t\tconst entity: EmailEntry = {\n\t\t\t\tid,\n\t\t\t\tsender,\n\t\t\t\trecipients,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: content,\n\t\t\t\tsubject,\n\t\t\t\tstatus: \"pending\"\n\t\t\t};\n\n\t\t\tawait this._messagingEmailEntryStorage.set(entity);\n\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageMessagingEmailConnector.CLASS_NAME,\n\t\t\t\t\"sendCustomEmailFailed\",\n\t\t\t\tundefined,\n\t\t\t\terr\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ComponentFactory, Converter, GeneralError, Guards, RandomHelper } from "@twin.org/core";
|
|
4
|
+
import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
|
|
5
|
+
/**
|
|
6
|
+
* Class for connecting to the push notifications messaging operations of the Entity Storage.
|
|
7
|
+
*/
|
|
8
|
+
export class EntityStorageMessagingPushNotificationConnector {
|
|
9
|
+
/**
|
|
10
|
+
* The namespace for the connector.
|
|
11
|
+
*/
|
|
12
|
+
static NAMESPACE = "entity-storage";
|
|
13
|
+
/**
|
|
14
|
+
* Runtime name for the class.
|
|
15
|
+
*/
|
|
16
|
+
static CLASS_NAME = "EntityStorageMessagingPushNotificationConnector";
|
|
17
|
+
/**
|
|
18
|
+
* The logging component.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
_logging;
|
|
22
|
+
/**
|
|
23
|
+
* The entity storage for the push notifications device entries.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
_messagingDeviceEntryStorage;
|
|
27
|
+
/**
|
|
28
|
+
* The entity storage for the push notifications message entries.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
_messagingMessageEntryStorage;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new instance of EntityStorageMessagingPushNotificationConnector.
|
|
34
|
+
* @param options The options for the connector.
|
|
35
|
+
*/
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
|
|
38
|
+
this._messagingDeviceEntryStorage = EntityStorageConnectorFactory.get(options?.messagingDeviceEntryStorageConnectorType ?? "push-notification-device-entry");
|
|
39
|
+
this._messagingMessageEntryStorage = EntityStorageConnectorFactory.get(options?.messagingMessageEntryStorageConnectorType ?? "push-notification-message-entry");
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns the class name of the component.
|
|
43
|
+
* @returns The class name of the component.
|
|
44
|
+
*/
|
|
45
|
+
className() {
|
|
46
|
+
return EntityStorageMessagingPushNotificationConnector.CLASS_NAME;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Registers a device to an specific app in order to send notifications to it.
|
|
50
|
+
* @param applicationId The application address.
|
|
51
|
+
* @param deviceToken The device token.
|
|
52
|
+
* @returns If the device was registered successfully.
|
|
53
|
+
*/
|
|
54
|
+
async registerDevice(applicationId, deviceToken) {
|
|
55
|
+
Guards.stringValue(EntityStorageMessagingPushNotificationConnector.CLASS_NAME, "applicationId", applicationId);
|
|
56
|
+
Guards.stringValue(EntityStorageMessagingPushNotificationConnector.CLASS_NAME, "deviceToken", deviceToken);
|
|
57
|
+
try {
|
|
58
|
+
await this._logging?.log({
|
|
59
|
+
level: "info",
|
|
60
|
+
source: EntityStorageMessagingPushNotificationConnector.CLASS_NAME,
|
|
61
|
+
ts: Date.now(),
|
|
62
|
+
message: "deviceRegistering"
|
|
63
|
+
});
|
|
64
|
+
const id = Converter.bytesToHex(RandomHelper.generate(32));
|
|
65
|
+
const entity = {
|
|
66
|
+
id,
|
|
67
|
+
applicationId,
|
|
68
|
+
deviceToken,
|
|
69
|
+
ts: Date.now(),
|
|
70
|
+
status: "pending"
|
|
71
|
+
};
|
|
72
|
+
await this._messagingDeviceEntryStorage.set(entity);
|
|
73
|
+
return id;
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
throw new GeneralError(EntityStorageMessagingPushNotificationConnector.CLASS_NAME, "deviceTokenRegisterFailed", { property: "applicationId", value: applicationId }, err);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Send a push notification to a device.
|
|
81
|
+
* @param deviceAddress The address of the device.
|
|
82
|
+
* @param title The title of the notification.
|
|
83
|
+
* @param message The message to send.
|
|
84
|
+
* @returns If the notification was sent successfully.
|
|
85
|
+
*/
|
|
86
|
+
async sendSinglePushNotification(deviceAddress, title, message) {
|
|
87
|
+
Guards.stringValue(EntityStorageMessagingPushNotificationConnector.CLASS_NAME, "deviceAddress", deviceAddress);
|
|
88
|
+
Guards.stringValue(EntityStorageMessagingPushNotificationConnector.CLASS_NAME, "title", title);
|
|
89
|
+
Guards.stringValue(EntityStorageMessagingPushNotificationConnector.CLASS_NAME, "message", message);
|
|
90
|
+
try {
|
|
91
|
+
await this._logging?.log({
|
|
92
|
+
level: "info",
|
|
93
|
+
source: EntityStorageMessagingPushNotificationConnector.CLASS_NAME,
|
|
94
|
+
ts: Date.now(),
|
|
95
|
+
message: "pushNotificationSending"
|
|
96
|
+
});
|
|
97
|
+
const id = Converter.bytesToHex(RandomHelper.generate(32));
|
|
98
|
+
const entity = {
|
|
99
|
+
id,
|
|
100
|
+
deviceAddress,
|
|
101
|
+
title,
|
|
102
|
+
message,
|
|
103
|
+
ts: Date.now(),
|
|
104
|
+
status: "pending"
|
|
105
|
+
};
|
|
106
|
+
await this._messagingMessageEntryStorage.set(entity);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
throw new GeneralError(EntityStorageMessagingPushNotificationConnector.CLASS_NAME, "sendPushNotificationFailed", { value: deviceAddress }, err);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=entityStorageMessagingPushNotificationConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityStorageMessagingPushNotificationConnector.js","sourceRoot":"","sources":["../../src/entityStorageMessagingPushNotificationConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACjG,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAQzC;;GAEG;AACH,MAAM,OAAO,+CAA+C;IAG3D;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAU,UAAU,qDAC0B;IAE3D;;;OAGG;IACgB,QAAQ,CAAqB;IAEhD;;;OAGG;IACc,4BAA4B,CAAuD;IAEpG;;;OAGG;IACc,6BAA6B,CAAwD;IAEtG;;;OAGG;IACH,YAAY,OAA4E;QACvF,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAAC,CAAC;QACzF,IAAI,CAAC,4BAA4B,GAAG,6BAA6B,CAAC,GAAG,CACpE,OAAO,EAAE,wCAAwC,oCACF,CAC/C,CAAC;QACF,IAAI,CAAC,6BAA6B,GAAG,6BAA6B,CAAC,GAAG,CACrE,OAAO,EAAE,yCAAyC,qCACF,CAChD,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,+CAA+C,CAAC,UAAU,CAAC;IACnE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,cAAc,CAAC,aAAqB,EAAE,WAAmB;QACrE,MAAM,CAAC,WAAW,CACjB,+CAA+C,CAAC,UAAU,mBAE1D,aAAa,CACb,CAAC;QACF,MAAM,CAAC,WAAW,CACjB,+CAA+C,CAAC,UAAU,iBAE1D,WAAW,CACX,CAAC;QACF,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;gBACxB,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,+CAA+C,CAAC,UAAU;gBAClE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,mBAAmB;aAC5B,CAAC,CAAC;YAEH,MAAM,EAAE,GAAG,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YAE3D,MAAM,MAAM,GAAgC;gBAC3C,EAAE;gBACF,aAAa;gBACb,WAAW;gBACX,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBACd,MAAM,EAAE,SAAS;aACjB,CAAC;YAEF,MAAM,IAAI,CAAC,4BAA4B,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpD,OAAO,EAAE,CAAC;QACX,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CACrB,+CAA+C,CAAC,UAAU,EAC1D,2BAA2B,EAC3B,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,EACnD,GAAG,CACH,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,0BAA0B,CACtC,aAAqB,EACrB,KAAa,EACb,OAAe;QAEf,MAAM,CAAC,WAAW,CACjB,+CAA+C,CAAC,UAAU,mBAE1D,aAAa,CACb,CAAC;QACF,MAAM,CAAC,WAAW,CACjB,+CAA+C,CAAC,UAAU,WAE1D,KAAK,CACL,CAAC;QACF,MAAM,CAAC,WAAW,CACjB,+CAA+C,CAAC,UAAU,aAE1D,OAAO,CACP,CAAC;QACF,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;gBACxB,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,+CAA+C,CAAC,UAAU;gBAClE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,yBAAyB;aAClC,CAAC,CAAC;YAEH,MAAM,EAAE,GAAG,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YAE3D,MAAM,MAAM,GAAiC;gBAC5C,EAAE;gBACF,aAAa;gBACb,KAAK;gBACL,OAAO;gBACP,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBACd,MAAM,EAAE,SAAS;aACjB,CAAC;YAEF,MAAM,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACrD,OAAO,IAAI,CAAC;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CACrB,+CAA+C,CAAC,UAAU,EAC1D,4BAA4B,EAC5B,EAAE,KAAK,EAAE,aAAa,EAAE,EACxB,GAAG,CACH,CAAC;QACH,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Converter, GeneralError, Guards, RandomHelper } from \"@twin.org/core\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport type { IMessagingPushNotificationsConnector } from \"@twin.org/messaging-models\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport type { PushNotificationDeviceEntry } from \"./entities/pushNotificationDeviceEntry.js\";\nimport type { PushNotificationMessageEntry } from \"./entities/pushNotificationMessageEntry.js\";\nimport type { IEntityStorageMessagingPushNotificationConnectorConstructorOptions } from \"./models/IEntityStorageMessagingPushNotificationConnectorConstructorOptions.js\";\n\n/**\n * Class for connecting to the push notifications messaging operations of the Entity Storage.\n */\nexport class EntityStorageMessagingPushNotificationConnector\n\timplements IMessagingPushNotificationsConnector\n{\n\t/**\n\t * The namespace for the connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string =\n\t\tnameof<EntityStorageMessagingPushNotificationConnector>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprotected readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * The entity storage for the push notifications device entries.\n\t * @internal\n\t */\n\tprivate readonly _messagingDeviceEntryStorage: IEntityStorageConnector<PushNotificationDeviceEntry>;\n\n\t/**\n\t * The entity storage for the push notifications message entries.\n\t * @internal\n\t */\n\tprivate readonly _messagingMessageEntryStorage: IEntityStorageConnector<PushNotificationMessageEntry>;\n\n\t/**\n\t * Create a new instance of EntityStorageMessagingPushNotificationConnector.\n\t * @param options The options for the connector.\n\t */\n\tconstructor(options?: IEntityStorageMessagingPushNotificationConnectorConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? \"logging\");\n\t\tthis._messagingDeviceEntryStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.messagingDeviceEntryStorageConnectorType ??\n\t\t\t\tnameofKebabCase<PushNotificationDeviceEntry>()\n\t\t);\n\t\tthis._messagingMessageEntryStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.messagingMessageEntryStorageConnectorType ??\n\t\t\t\tnameofKebabCase<PushNotificationMessageEntry>()\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageMessagingPushNotificationConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Registers a device to an specific app in order to send notifications to it.\n\t * @param applicationId The application address.\n\t * @param deviceToken The device token.\n\t * @returns If the device was registered successfully.\n\t */\n\tpublic async registerDevice(applicationId: string, deviceToken: string): Promise<string> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageMessagingPushNotificationConnector.CLASS_NAME,\n\t\t\tnameof(applicationId),\n\t\t\tapplicationId\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageMessagingPushNotificationConnector.CLASS_NAME,\n\t\t\tnameof(deviceToken),\n\t\t\tdeviceToken\n\t\t);\n\t\ttry {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: EntityStorageMessagingPushNotificationConnector.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"deviceRegistering\"\n\t\t\t});\n\n\t\t\tconst id = Converter.bytesToHex(RandomHelper.generate(32));\n\n\t\t\tconst entity: PushNotificationDeviceEntry = {\n\t\t\t\tid,\n\t\t\t\tapplicationId,\n\t\t\t\tdeviceToken,\n\t\t\t\tts: Date.now(),\n\t\t\t\tstatus: \"pending\"\n\t\t\t};\n\n\t\t\tawait this._messagingDeviceEntryStorage.set(entity);\n\t\t\treturn id;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageMessagingPushNotificationConnector.CLASS_NAME,\n\t\t\t\t\"deviceTokenRegisterFailed\",\n\t\t\t\t{ property: \"applicationId\", value: applicationId },\n\t\t\t\terr\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Send a push notification to a device.\n\t * @param deviceAddress The address of the device.\n\t * @param title The title of the notification.\n\t * @param message The message to send.\n\t * @returns If the notification was sent successfully.\n\t */\n\tpublic async sendSinglePushNotification(\n\t\tdeviceAddress: string,\n\t\ttitle: string,\n\t\tmessage: string\n\t): Promise<boolean> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageMessagingPushNotificationConnector.CLASS_NAME,\n\t\t\tnameof(deviceAddress),\n\t\t\tdeviceAddress\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageMessagingPushNotificationConnector.CLASS_NAME,\n\t\t\tnameof(title),\n\t\t\ttitle\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageMessagingPushNotificationConnector.CLASS_NAME,\n\t\t\tnameof(message),\n\t\t\tmessage\n\t\t);\n\t\ttry {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: EntityStorageMessagingPushNotificationConnector.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"pushNotificationSending\"\n\t\t\t});\n\n\t\t\tconst id = Converter.bytesToHex(RandomHelper.generate(32));\n\n\t\t\tconst entity: PushNotificationMessageEntry = {\n\t\t\t\tid,\n\t\t\t\tdeviceAddress,\n\t\t\t\ttitle,\n\t\t\t\tmessage,\n\t\t\t\tts: Date.now(),\n\t\t\t\tstatus: \"pending\"\n\t\t\t};\n\n\t\t\tawait this._messagingMessageEntryStorage.set(entity);\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageMessagingPushNotificationConnector.CLASS_NAME,\n\t\t\t\t\"sendPushNotificationFailed\",\n\t\t\t\t{ value: deviceAddress },\n\t\t\t\terr\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ComponentFactory, Converter, GeneralError, Guards, RandomHelper } from "@twin.org/core";
|
|
4
|
+
import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
|
|
5
|
+
/**
|
|
6
|
+
* Class for connecting to the SMS messaging operations of the Entity Storage.
|
|
7
|
+
*/
|
|
8
|
+
export class EntityStorageMessagingSmsConnector {
|
|
9
|
+
/**
|
|
10
|
+
* The namespace for the connector.
|
|
11
|
+
*/
|
|
12
|
+
static NAMESPACE = "entity-storage";
|
|
13
|
+
/**
|
|
14
|
+
* Runtime name for the class.
|
|
15
|
+
*/
|
|
16
|
+
static CLASS_NAME = "EntityStorageMessagingSmsConnector";
|
|
17
|
+
/**
|
|
18
|
+
* The logging component.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
_logging;
|
|
22
|
+
/**
|
|
23
|
+
* The entity storage for the sms entries.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
_messagingSmsEntryStorage;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new instance of EntityStorageMessagingSmsConnector.
|
|
29
|
+
* @param options The options for the connector.
|
|
30
|
+
*/
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
|
|
33
|
+
this._messagingSmsEntryStorage = EntityStorageConnectorFactory.get(options?.messagingSmsEntryStorageConnectorType ?? "sms-entry");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns the class name of the component.
|
|
37
|
+
* @returns The class name of the component.
|
|
38
|
+
*/
|
|
39
|
+
className() {
|
|
40
|
+
return EntityStorageMessagingSmsConnector.CLASS_NAME;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Send a SMS message to a phone number.
|
|
44
|
+
* @param phoneNumber The recipient phone number.
|
|
45
|
+
* @param message The message to send.
|
|
46
|
+
* @returns If the SMS was sent successfully.
|
|
47
|
+
*/
|
|
48
|
+
async sendSMS(phoneNumber, message) {
|
|
49
|
+
Guards.stringValue(EntityStorageMessagingSmsConnector.CLASS_NAME, "phoneNumber", phoneNumber);
|
|
50
|
+
Guards.stringValue(EntityStorageMessagingSmsConnector.CLASS_NAME, "message", message);
|
|
51
|
+
try {
|
|
52
|
+
await this._logging?.log({
|
|
53
|
+
level: "info",
|
|
54
|
+
source: EntityStorageMessagingSmsConnector.CLASS_NAME,
|
|
55
|
+
ts: Date.now(),
|
|
56
|
+
message: "smsSending"
|
|
57
|
+
});
|
|
58
|
+
const id = Converter.bytesToHex(RandomHelper.generate(32));
|
|
59
|
+
const entity = {
|
|
60
|
+
id,
|
|
61
|
+
phoneNumber,
|
|
62
|
+
message,
|
|
63
|
+
ts: Date.now(),
|
|
64
|
+
status: "sent"
|
|
65
|
+
};
|
|
66
|
+
await this._messagingSmsEntryStorage.set(entity);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
throw new GeneralError(EntityStorageMessagingSmsConnector.CLASS_NAME, "sendSMSFailed", undefined, err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=entityStorageMessagingSmsConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityStorageMessagingSmsConnector.js","sourceRoot":"","sources":["../../src/entityStorageMessagingSmsConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACjG,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAOzC;;GAEG;AACH,MAAM,OAAO,kCAAkC;IAC9C;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAU,UAAU,wCAAwD;IAEzF;;;OAGG;IACgB,QAAQ,CAAqB;IAEhD;;;OAGG;IACc,yBAAyB,CAAoC;IAE9E;;;OAGG;IACH,YAAY,OAA+D;QAC1E,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAAC,CAAC;QACzF,IAAI,CAAC,yBAAyB,GAAG,6BAA6B,CAAC,GAAG,CACjE,OAAO,EAAE,qCAAqC,eAA+B,CAC7E,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,kCAAkC,CAAC,UAAU,CAAC;IACtD,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,OAAO,CAAC,WAAmB,EAAE,OAAe;QACxD,MAAM,CAAC,WAAW,CACjB,kCAAkC,CAAC,UAAU,iBAE7C,WAAW,CACX,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,kCAAkC,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAC5F,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;gBACxB,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,kCAAkC,CAAC,UAAU;gBACrD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,YAAY;aACrB,CAAC,CAAC;YAEH,MAAM,EAAE,GAAG,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YAE3D,MAAM,MAAM,GAAa;gBACxB,EAAE;gBACF,WAAW;gBACX,OAAO;gBACP,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBACd,MAAM,EAAE,MAAM;aACd,CAAC;YAEF,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAEjD,OAAO,IAAI,CAAC;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CACrB,kCAAkC,CAAC,UAAU,EAC7C,eAAe,EACf,SAAS,EACT,GAAG,CACH,CAAC;QACH,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Converter, GeneralError, Guards, RandomHelper } from \"@twin.org/core\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport type { IMessagingSmsConnector } from \"@twin.org/messaging-models\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport type { SmsEntry } from \"./entities/smsEntry.js\";\nimport type { IEntityStorageMessagingSmsConnectorConstructorOptions } from \"./models/IEntityStorageMessagingSmsConnectorConstructorOptions.js\";\n\n/**\n * Class for connecting to the SMS messaging operations of the Entity Storage.\n */\nexport class EntityStorageMessagingSmsConnector implements IMessagingSmsConnector {\n\t/**\n\t * The namespace for the connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageMessagingSmsConnector>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprotected readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * The entity storage for the sms entries.\n\t * @internal\n\t */\n\tprivate readonly _messagingSmsEntryStorage: IEntityStorageConnector<SmsEntry>;\n\n\t/**\n\t * Create a new instance of EntityStorageMessagingSmsConnector.\n\t * @param options The options for the connector.\n\t */\n\tconstructor(options?: IEntityStorageMessagingSmsConnectorConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? \"logging\");\n\t\tthis._messagingSmsEntryStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.messagingSmsEntryStorageConnectorType ?? nameofKebabCase<SmsEntry>()\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageMessagingSmsConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Send a SMS message to a phone number.\n\t * @param phoneNumber The recipient phone number.\n\t * @param message The message to send.\n\t * @returns If the SMS was sent successfully.\n\t */\n\tpublic async sendSMS(phoneNumber: string, message: string): Promise<boolean> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageMessagingSmsConnector.CLASS_NAME,\n\t\t\tnameof(phoneNumber),\n\t\t\tphoneNumber\n\t\t);\n\t\tGuards.stringValue(EntityStorageMessagingSmsConnector.CLASS_NAME, nameof(message), message);\n\t\ttry {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: EntityStorageMessagingSmsConnector.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"smsSending\"\n\t\t\t});\n\n\t\t\tconst id = Converter.bytesToHex(RandomHelper.generate(32));\n\n\t\t\tconst entity: SmsEntry = {\n\t\t\t\tid,\n\t\t\t\tphoneNumber,\n\t\t\t\tmessage,\n\t\t\t\tts: Date.now(),\n\t\t\t\tstatus: \"sent\"\n\t\t\t};\n\n\t\t\tawait this._messagingSmsEntryStorage.set(entity);\n\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageMessagingSmsConnector.CLASS_NAME,\n\t\t\t\t\"sendSMSFailed\",\n\t\t\t\tundefined,\n\t\t\t\terr\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
export * from "./entities/emailEntry.js";
|
|
4
|
+
export * from "./entities/pushNotificationDeviceEntry.js";
|
|
5
|
+
export * from "./entities/pushNotificationMessageEntry.js";
|
|
6
|
+
export * from "./entities/smsEntry.js";
|
|
7
|
+
export * from "./entityStorageMessagingEmailConnector.js";
|
|
8
|
+
export * from "./entityStorageMessagingPushNotificationConnector.js";
|
|
9
|
+
export * from "./entityStorageMessagingSmsConnector.js";
|
|
10
|
+
export * from "./models/IEntityStorageMessagingEmailConnectorConstructorOptions.js";
|
|
11
|
+
export * from "./models/IEntityStorageMessagingPushNotificationConnectorConstructorOptions.js";
|
|
12
|
+
export * from "./models/IEntityStorageMessagingSmsConnectorConstructorOptions.js";
|
|
13
|
+
export * from "./schema.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wBAAwB,CAAC;AACvC,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sDAAsD,CAAC;AACrE,cAAc,yCAAyC,CAAC;AACxD,cAAc,qEAAqE,CAAC;AACpF,cAAc,gFAAgF,CAAC;AAC/F,cAAc,mEAAmE,CAAC;AAClF,cAAc,aAAa,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./entities/emailEntry.js\";\nexport * from \"./entities/pushNotificationDeviceEntry.js\";\nexport * from \"./entities/pushNotificationMessageEntry.js\";\nexport * from \"./entities/smsEntry.js\";\nexport * from \"./entityStorageMessagingEmailConnector.js\";\nexport * from \"./entityStorageMessagingPushNotificationConnector.js\";\nexport * from \"./entityStorageMessagingSmsConnector.js\";\nexport * from \"./models/IEntityStorageMessagingEmailConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageMessagingPushNotificationConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageMessagingSmsConnectorConstructorOptions.js\";\nexport * from \"./schema.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageMessagingEmailConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageMessagingEmailConnectorConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Options for the entity storage messaging email connector.\n */\nexport interface IEntityStorageMessagingEmailConnectorConstructorOptions {\n\t/**\n\t * The type of logging component to use, defaults to no logging.\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * The type of entity storage connector to use for the email entries.\n\t * @default email-entry\n\t */\n\tmessagingEmailEntryStorageConnectorType?: string;\n}\n"]}
|