@twin.org/messaging-connector-entity-storage 0.0.1-next.10

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.
Files changed (32) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +31 -0
  3. package/dist/cjs/index.cjs +538 -0
  4. package/dist/esm/index.mjs +533 -0
  5. package/dist/types/entities/emailEntry.d.ts +38 -0
  6. package/dist/types/entities/pushNotificationDeviceEntry.d.ts +30 -0
  7. package/dist/types/entities/pushNotificationMessageEntry.d.ts +34 -0
  8. package/dist/types/entities/smsEntry.d.ts +30 -0
  9. package/dist/types/entityStorageMessagingEmailConnector.d.ts +29 -0
  10. package/dist/types/entityStorageMessagingPushNotificationConnector.d.ts +35 -0
  11. package/dist/types/entityStorageMessagingSmsConnector.d.ts +27 -0
  12. package/dist/types/index.d.ts +11 -0
  13. package/dist/types/models/IEntityStorageMessagingEmailConnectorConstructorOptions.d.ts +14 -0
  14. package/dist/types/models/IEntityStorageMessagingPushNotificationConnectorConstructorOptions.d.ts +19 -0
  15. package/dist/types/models/IEntityStorageMessagingSmsConnectorConstructorOptions.d.ts +14 -0
  16. package/dist/types/schema.d.ts +12 -0
  17. package/docs/changelog.md +5 -0
  18. package/docs/examples.md +1 -0
  19. package/docs/reference/classes/EmailEntry.md +77 -0
  20. package/docs/reference/classes/EntityStorageMessagingEmailConnector.md +91 -0
  21. package/docs/reference/classes/EntityStorageMessagingPushNotificationConnector.md +117 -0
  22. package/docs/reference/classes/EntityStorageMessagingSmsConnector.md +79 -0
  23. package/docs/reference/classes/PushNotificationDeviceEntry.md +61 -0
  24. package/docs/reference/classes/PushNotificationMessageEntry.md +69 -0
  25. package/docs/reference/classes/SmsEntry.md +61 -0
  26. package/docs/reference/functions/initSchema.md +33 -0
  27. package/docs/reference/index.md +21 -0
  28. package/docs/reference/interfaces/IEntityStorageMessagingEmailConnectorConstructorOptions.md +25 -0
  29. package/docs/reference/interfaces/IEntityStorageMessagingPushNotificationConnectorConstructorOptions.md +39 -0
  30. package/docs/reference/interfaces/IEntityStorageMessagingSmsConnectorConstructorOptions.md +25 -0
  31. package/locales/en.json +19 -0
  32. package/package.json +41 -0
@@ -0,0 +1,35 @@
1
+ import type { IMessagingPushNotificationsConnector } from "@twin.org/messaging-models";
2
+ import type { IEntityStorageMessagingPushNotificationConnectorConstructorOptions } from "./models/IEntityStorageMessagingPushNotificationConnectorConstructorOptions";
3
+ /**
4
+ * Class for connecting to the push notifications messaging operations of the Entity Storage.
5
+ */
6
+ export declare class EntityStorageMessagingPushNotificationConnector implements IMessagingPushNotificationsConnector {
7
+ /**
8
+ * The namespace for the connector.
9
+ */
10
+ static readonly NAMESPACE: string;
11
+ /**
12
+ * Runtime name for the class.
13
+ */
14
+ readonly CLASS_NAME: string;
15
+ /**
16
+ * Create a new instance of EntityStorageMessagingPushNotificationConnector.
17
+ * @param options The options for the connector.
18
+ */
19
+ constructor(options?: IEntityStorageMessagingPushNotificationConnectorConstructorOptions);
20
+ /**
21
+ * Registers a device to an specific app in order to send notifications to it.
22
+ * @param applicationId The application address.
23
+ * @param deviceToken The device token.
24
+ * @returns If the device was registered successfully.
25
+ */
26
+ registerDevice(applicationId: string, deviceToken: string): Promise<string>;
27
+ /**
28
+ * Send a push notification to a device.
29
+ * @param deviceAddress The address of the device.
30
+ * @param title The title of the notification.
31
+ * @param message The message to send.
32
+ * @returns If the notification was sent successfully.
33
+ */
34
+ sendSinglePushNotification(deviceAddress: string, title: string, message: string): Promise<boolean>;
35
+ }
@@ -0,0 +1,27 @@
1
+ import type { IMessagingSmsConnector } from "@twin.org/messaging-models";
2
+ import type { IEntityStorageMessagingSmsConnectorConstructorOptions } from "./models/IEntityStorageMessagingSmsConnectorConstructorOptions";
3
+ /**
4
+ * Class for connecting to the SMS messaging operations of the Entity Storage.
5
+ */
6
+ export declare class EntityStorageMessagingSmsConnector implements IMessagingSmsConnector {
7
+ /**
8
+ * The namespace for the connector.
9
+ */
10
+ static readonly NAMESPACE: string;
11
+ /**
12
+ * Runtime name for the class.
13
+ */
14
+ readonly CLASS_NAME: string;
15
+ /**
16
+ * Create a new instance of EntityStorageMessagingSmsConnector.
17
+ * @param options The options for the connector.
18
+ */
19
+ constructor(options?: IEntityStorageMessagingSmsConnectorConstructorOptions);
20
+ /**
21
+ * Send a SMS message to a phone number.
22
+ * @param phoneNumber The recipient phone number.
23
+ * @param message The message to send.
24
+ * @returns If the SMS was sent successfully.
25
+ */
26
+ sendSMS(phoneNumber: string, message: string): Promise<boolean>;
27
+ }
@@ -0,0 +1,11 @@
1
+ export * from "./entities/emailEntry";
2
+ export * from "./entities/pushNotificationDeviceEntry";
3
+ export * from "./entities/pushNotificationMessageEntry";
4
+ export * from "./entities/smsEntry";
5
+ export * from "./entityStorageMessagingEmailConnector";
6
+ export * from "./entityStorageMessagingPushNotificationConnector";
7
+ export * from "./entityStorageMessagingSmsConnector";
8
+ export * from "./models/IEntityStorageMessagingEmailConnectorConstructorOptions";
9
+ export * from "./models/IEntityStorageMessagingPushNotificationConnectorConstructorOptions";
10
+ export * from "./models/IEntityStorageMessagingSmsConnectorConstructorOptions";
11
+ export * from "./schema";
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Options for the entity storage messaging email connector.
3
+ */
4
+ export interface IEntityStorageMessagingEmailConnectorConstructorOptions {
5
+ /**
6
+ * The type of logging connector to use, defaults to no logging.
7
+ */
8
+ loggingConnectorType?: string;
9
+ /**
10
+ * The type of entity storage connector to use for the email entries.
11
+ * @default email-entry
12
+ */
13
+ messagingEmailEntryStorageConnectorType?: string;
14
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Options for the entity storage messaging push notification connector.
3
+ */
4
+ export interface IEntityStorageMessagingPushNotificationConnectorConstructorOptions {
5
+ /**
6
+ * The type of logging connector to use, defaults to no logging.
7
+ */
8
+ loggingConnectorType?: string;
9
+ /**
10
+ * The type of entity storage connector to use for the push notifications entries.
11
+ * @default push-notification-device-entry
12
+ */
13
+ messagingDeviceEntryStorageConnectorType?: string;
14
+ /**
15
+ * The type of entity storage connector to use for the push notifications entries.
16
+ * @default push-notification-message-entry
17
+ */
18
+ messagingMessageEntryStorageConnectorType?: string;
19
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Options for the entity storage messaging SMS connector.
3
+ */
4
+ export interface IEntityStorageMessagingSmsConnectorConstructorOptions {
5
+ /**
6
+ * The type of logging connector to use, defaults to no logging.
7
+ */
8
+ loggingConnectorType?: string;
9
+ /**
10
+ * The type of entity storage connector to use for the sms entries.
11
+ * @default sms-entry
12
+ */
13
+ messagingSmsEntryStorageConnectorType?: string;
14
+ }
@@ -0,0 +1,12 @@
1
+ /**
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.
7
+ */
8
+ export declare function initSchema(options?: {
9
+ email?: boolean;
10
+ sms?: boolean;
11
+ pushNotification?: boolean;
12
+ }): void;
@@ -0,0 +1,5 @@
1
+ # @twin.org/messaging-connector-entity-storage - Changelog
2
+
3
+ ## v0.0.1-next.10
4
+
5
+ - Initial Release
@@ -0,0 +1 @@
1
+ # @twin.org/messaging-connector-entity-storage - Examples
@@ -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.
@@ -0,0 +1,91 @@
1
+ # Class: EntityStorageMessagingEmailConnector
2
+
3
+ Class for connecting to the email messaging operations of the Entity Storage.
4
+
5
+ ## Implements
6
+
7
+ - `IMessagingEmailConnector`
8
+
9
+ ## Constructors
10
+
11
+ ### new EntityStorageMessagingEmailConnector()
12
+
13
+ > **new EntityStorageMessagingEmailConnector**(`options`?): [`EntityStorageMessagingEmailConnector`](EntityStorageMessagingEmailConnector.md)
14
+
15
+ Create a new instance of EntityStorageMessagingEmailConnector.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IEntityStorageMessagingEmailConnectorConstructorOptions`](../interfaces/IEntityStorageMessagingEmailConnectorConstructorOptions.md)
22
+
23
+ The options for the connector.
24
+
25
+ #### Returns
26
+
27
+ [`EntityStorageMessagingEmailConnector`](EntityStorageMessagingEmailConnector.md)
28
+
29
+ ## Properties
30
+
31
+ ### NAMESPACE
32
+
33
+ > `readonly` `static` **NAMESPACE**: `string` = `"entity-storage"`
34
+
35
+ The namespace for the connector.
36
+
37
+ ***
38
+
39
+ ### CLASS\_NAME
40
+
41
+ > `readonly` **CLASS\_NAME**: `string`
42
+
43
+ Runtime name for the class.
44
+
45
+ #### Implementation of
46
+
47
+ `IMessagingEmailConnector.CLASS_NAME`
48
+
49
+ ## Methods
50
+
51
+ ### sendCustomEmail()
52
+
53
+ > **sendCustomEmail**(`sender`, `recipients`, `subject`, `content`): `Promise`\<`boolean`\>
54
+
55
+ Store a custom email using Entity Storage.
56
+
57
+ #### Parameters
58
+
59
+ ##### sender
60
+
61
+ `string`
62
+
63
+ The sender email address.
64
+
65
+ ##### recipients
66
+
67
+ `string`[]
68
+
69
+ An array of recipients email addresses.
70
+
71
+ ##### subject
72
+
73
+ `string`
74
+
75
+ The subject of the email.
76
+
77
+ ##### content
78
+
79
+ `string`
80
+
81
+ The html content of the email.
82
+
83
+ #### Returns
84
+
85
+ `Promise`\<`boolean`\>
86
+
87
+ True if the email was send successfully, otherwise undefined.
88
+
89
+ #### Implementation of
90
+
91
+ `IMessagingEmailConnector.sendCustomEmail`
@@ -0,0 +1,117 @@
1
+ # Class: EntityStorageMessagingPushNotificationConnector
2
+
3
+ Class for connecting to the push notifications messaging operations of the Entity Storage.
4
+
5
+ ## Implements
6
+
7
+ - `IMessagingPushNotificationsConnector`
8
+
9
+ ## Constructors
10
+
11
+ ### new EntityStorageMessagingPushNotificationConnector()
12
+
13
+ > **new EntityStorageMessagingPushNotificationConnector**(`options`?): [`EntityStorageMessagingPushNotificationConnector`](EntityStorageMessagingPushNotificationConnector.md)
14
+
15
+ Create a new instance of EntityStorageMessagingPushNotificationConnector.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IEntityStorageMessagingPushNotificationConnectorConstructorOptions`](../interfaces/IEntityStorageMessagingPushNotificationConnectorConstructorOptions.md)
22
+
23
+ The options for the connector.
24
+
25
+ #### Returns
26
+
27
+ [`EntityStorageMessagingPushNotificationConnector`](EntityStorageMessagingPushNotificationConnector.md)
28
+
29
+ ## Properties
30
+
31
+ ### NAMESPACE
32
+
33
+ > `readonly` `static` **NAMESPACE**: `string` = `"entity-storage"`
34
+
35
+ The namespace for the connector.
36
+
37
+ ***
38
+
39
+ ### CLASS\_NAME
40
+
41
+ > `readonly` **CLASS\_NAME**: `string`
42
+
43
+ Runtime name for the class.
44
+
45
+ #### Implementation of
46
+
47
+ `IMessagingPushNotificationsConnector.CLASS_NAME`
48
+
49
+ ## Methods
50
+
51
+ ### registerDevice()
52
+
53
+ > **registerDevice**(`applicationId`, `deviceToken`): `Promise`\<`string`\>
54
+
55
+ Registers a device to an specific app in order to send notifications to it.
56
+
57
+ #### Parameters
58
+
59
+ ##### applicationId
60
+
61
+ `string`
62
+
63
+ The application address.
64
+
65
+ ##### deviceToken
66
+
67
+ `string`
68
+
69
+ The device token.
70
+
71
+ #### Returns
72
+
73
+ `Promise`\<`string`\>
74
+
75
+ If the device was registered successfully.
76
+
77
+ #### Implementation of
78
+
79
+ `IMessagingPushNotificationsConnector.registerDevice`
80
+
81
+ ***
82
+
83
+ ### sendSinglePushNotification()
84
+
85
+ > **sendSinglePushNotification**(`deviceAddress`, `title`, `message`): `Promise`\<`boolean`\>
86
+
87
+ Send a push notification to a device.
88
+
89
+ #### Parameters
90
+
91
+ ##### deviceAddress
92
+
93
+ `string`
94
+
95
+ The address of the device.
96
+
97
+ ##### title
98
+
99
+ `string`
100
+
101
+ The title of the notification.
102
+
103
+ ##### message
104
+
105
+ `string`
106
+
107
+ The message to send.
108
+
109
+ #### Returns
110
+
111
+ `Promise`\<`boolean`\>
112
+
113
+ If the notification was sent successfully.
114
+
115
+ #### Implementation of
116
+
117
+ `IMessagingPushNotificationsConnector.sendSinglePushNotification`
@@ -0,0 +1,79 @@
1
+ # Class: EntityStorageMessagingSmsConnector
2
+
3
+ Class for connecting to the SMS messaging operations of the Entity Storage.
4
+
5
+ ## Implements
6
+
7
+ - `IMessagingSmsConnector`
8
+
9
+ ## Constructors
10
+
11
+ ### new EntityStorageMessagingSmsConnector()
12
+
13
+ > **new EntityStorageMessagingSmsConnector**(`options`?): [`EntityStorageMessagingSmsConnector`](EntityStorageMessagingSmsConnector.md)
14
+
15
+ Create a new instance of EntityStorageMessagingSmsConnector.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IEntityStorageMessagingSmsConnectorConstructorOptions`](../interfaces/IEntityStorageMessagingSmsConnectorConstructorOptions.md)
22
+
23
+ The options for the connector.
24
+
25
+ #### Returns
26
+
27
+ [`EntityStorageMessagingSmsConnector`](EntityStorageMessagingSmsConnector.md)
28
+
29
+ ## Properties
30
+
31
+ ### NAMESPACE
32
+
33
+ > `readonly` `static` **NAMESPACE**: `string` = `"entity-storage"`
34
+
35
+ The namespace for the connector.
36
+
37
+ ***
38
+
39
+ ### CLASS\_NAME
40
+
41
+ > `readonly` **CLASS\_NAME**: `string`
42
+
43
+ Runtime name for the class.
44
+
45
+ #### Implementation of
46
+
47
+ `IMessagingSmsConnector.CLASS_NAME`
48
+
49
+ ## Methods
50
+
51
+ ### sendSMS()
52
+
53
+ > **sendSMS**(`phoneNumber`, `message`): `Promise`\<`boolean`\>
54
+
55
+ Send a SMS message to a phone number.
56
+
57
+ #### Parameters
58
+
59
+ ##### phoneNumber
60
+
61
+ `string`
62
+
63
+ The recipient phone number.
64
+
65
+ ##### message
66
+
67
+ `string`
68
+
69
+ The message to send.
70
+
71
+ #### Returns
72
+
73
+ `Promise`\<`boolean`\>
74
+
75
+ If the SMS was sent successfully.
76
+
77
+ #### Implementation of
78
+
79
+ `IMessagingSmsConnector.sendSMS`
@@ -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.