@twin.org/messaging-service 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.
@@ -0,0 +1,403 @@
1
+ {
2
+ "openapi": "3.1.0",
3
+ "info": {
4
+ "title": "TWIN - Test Endpoints",
5
+ "description": "REST API for TWIN - Test Endpoints.",
6
+ "version": "1.0.0",
7
+ "license": {
8
+ "name": "Apache 2.0 License",
9
+ "url": "https://opensource.org/licenses/Apache-2.0"
10
+ }
11
+ },
12
+ "servers": [
13
+ {
14
+ "url": "https://localhost"
15
+ }
16
+ ],
17
+ "tags": [
18
+ {
19
+ "name": "Logging",
20
+ "description": "Endpoints which are modelled to access a logging contract."
21
+ }
22
+ ],
23
+ "paths": {
24
+ "/logging": {
25
+ "post": {
26
+ "operationId": "loggingEntryCreate",
27
+ "summary": "Create a log entry",
28
+ "tags": [
29
+ "Logging"
30
+ ],
31
+ "security": [
32
+ {
33
+ "jwtBearerAuthScheme": []
34
+ }
35
+ ],
36
+ "requestBody": {
37
+ "description": "Create a new log entry.",
38
+ "required": true,
39
+ "content": {
40
+ "application/json": {
41
+ "schema": {
42
+ "$ref": "#/components/schemas/LogEntry"
43
+ },
44
+ "examples": {
45
+ "loggingEntryCreateInfoExample": {
46
+ "value": {
47
+ "level": "info",
48
+ "message": "This is an information message",
49
+ "source": "source",
50
+ "ts": 1715252922273
51
+ }
52
+ },
53
+ "loggingEntryCreateErrorExample": {
54
+ "value": {
55
+ "level": "info",
56
+ "message": "This is an error message",
57
+ "source": "source",
58
+ "ts": 1715252922273,
59
+ "error": {
60
+ "name": "GeneralError",
61
+ "message": "component.error",
62
+ "properties": {
63
+ "foo": "bar"
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ },
72
+ "responses": {
73
+ "204": {
74
+ "description": "The rest request ended in success with no data."
75
+ },
76
+ "400": {
77
+ "description": "The server cannot process the request, see the content for more details.",
78
+ "content": {
79
+ "application/json": {
80
+ "schema": {
81
+ "$ref": "#/components/schemas/Error"
82
+ },
83
+ "examples": {
84
+ "exampleResponse": {
85
+ "value": {
86
+ "name": "GeneralError",
87
+ "message": "component.error",
88
+ "properties": {
89
+ "foo": "bar"
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ },
97
+ "401": {
98
+ "description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
99
+ "content": {
100
+ "application/json": {
101
+ "schema": {
102
+ "$ref": "#/components/schemas/Error"
103
+ },
104
+ "examples": {
105
+ "exampleResponse": {
106
+ "value": {
107
+ "name": "UnauthorizedError",
108
+ "message": "component.error"
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ },
115
+ "500": {
116
+ "description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
117
+ "content": {
118
+ "application/json": {
119
+ "schema": {
120
+ "$ref": "#/components/schemas/Error"
121
+ },
122
+ "examples": {
123
+ "exampleResponse": {
124
+ "value": {
125
+ "name": "InternalServerError",
126
+ "message": "component.error"
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ },
135
+ "get": {
136
+ "operationId": "loggingListEntries",
137
+ "summary": "Get a list of the log entries",
138
+ "tags": [
139
+ "Logging"
140
+ ],
141
+ "parameters": [
142
+ {
143
+ "name": "level",
144
+ "description": "The level of the log entries to retrieve.",
145
+ "in": "query",
146
+ "required": false,
147
+ "schema": {
148
+ "$ref": "#/components/schemas/LogLevel"
149
+ },
150
+ "example": "info"
151
+ },
152
+ {
153
+ "name": "source",
154
+ "description": "The source of the log entries to retrieve.",
155
+ "in": "query",
156
+ "required": false,
157
+ "schema": {
158
+ "type": "string"
159
+ }
160
+ },
161
+ {
162
+ "name": "timeStart",
163
+ "description": "The start time of the metrics to retrieve as a timestamp in ms.",
164
+ "in": "query",
165
+ "required": false,
166
+ "schema": {
167
+ "type": "number"
168
+ }
169
+ },
170
+ {
171
+ "name": "timeEnd",
172
+ "description": "The end time of the metrics to retrieve as a timestamp in ms.",
173
+ "in": "query",
174
+ "required": false,
175
+ "schema": {
176
+ "type": "number"
177
+ }
178
+ },
179
+ {
180
+ "name": "cursor",
181
+ "description": "The optional cursor to get next chunk.",
182
+ "in": "query",
183
+ "required": false,
184
+ "schema": {
185
+ "type": "string"
186
+ }
187
+ },
188
+ {
189
+ "name": "pageSize",
190
+ "description": "The maximum number of entities in a page.",
191
+ "in": "query",
192
+ "required": false,
193
+ "schema": {
194
+ "type": "number"
195
+ }
196
+ }
197
+ ],
198
+ "security": [
199
+ {
200
+ "jwtBearerAuthScheme": []
201
+ }
202
+ ],
203
+ "responses": {
204
+ "200": {
205
+ "description": "Response for log entry list request.",
206
+ "content": {
207
+ "application/json": {
208
+ "schema": {
209
+ "$ref": "#/components/schemas/LoggingListResponse"
210
+ },
211
+ "examples": {
212
+ "listResponseExample": {
213
+ "value": {
214
+ "entities": [
215
+ {
216
+ "level": "info",
217
+ "message": "This is an information message",
218
+ "source": "source",
219
+ "ts": 1715252922273
220
+ }
221
+ ],
222
+ "cursor": "1"
223
+ }
224
+ }
225
+ }
226
+ }
227
+ }
228
+ },
229
+ "400": {
230
+ "description": "The server cannot process the request, see the content for more details.",
231
+ "content": {
232
+ "application/json": {
233
+ "schema": {
234
+ "$ref": "#/components/schemas/Error"
235
+ },
236
+ "examples": {
237
+ "exampleResponse": {
238
+ "value": {
239
+ "name": "GeneralError",
240
+ "message": "component.error",
241
+ "properties": {
242
+ "foo": "bar"
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ }
249
+ },
250
+ "401": {
251
+ "description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
252
+ "content": {
253
+ "application/json": {
254
+ "schema": {
255
+ "$ref": "#/components/schemas/Error"
256
+ },
257
+ "examples": {
258
+ "exampleResponse": {
259
+ "value": {
260
+ "name": "UnauthorizedError",
261
+ "message": "component.error"
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }
267
+ },
268
+ "500": {
269
+ "description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
270
+ "content": {
271
+ "application/json": {
272
+ "schema": {
273
+ "$ref": "#/components/schemas/Error"
274
+ },
275
+ "examples": {
276
+ "exampleResponse": {
277
+ "value": {
278
+ "name": "InternalServerError",
279
+ "message": "component.error"
280
+ }
281
+ }
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
287
+ }
288
+ }
289
+ },
290
+ "components": {
291
+ "schemas": {
292
+ "Error": {
293
+ "type": "object",
294
+ "properties": {
295
+ "name": {
296
+ "type": "string",
297
+ "description": "The name for the error."
298
+ },
299
+ "message": {
300
+ "type": "string",
301
+ "description": "The message for the error."
302
+ },
303
+ "source": {
304
+ "type": "string",
305
+ "description": "The source of the error."
306
+ },
307
+ "properties": {
308
+ "type": "object",
309
+ "additionalProperties": {},
310
+ "description": "Any additional information for the error."
311
+ },
312
+ "stack": {
313
+ "type": "string",
314
+ "description": "The stack trace for the error."
315
+ },
316
+ "inner": {
317
+ "$ref": "#/components/schemas/Error"
318
+ }
319
+ },
320
+ "required": [
321
+ "name",
322
+ "message"
323
+ ],
324
+ "additionalProperties": false,
325
+ "description": "Model to describe serialized error."
326
+ },
327
+ "LogEntry": {
328
+ "type": "object",
329
+ "properties": {
330
+ "level": {
331
+ "$ref": "#/components/schemas/LogLevel"
332
+ },
333
+ "source": {
334
+ "type": "string",
335
+ "description": "The source of the log entry."
336
+ },
337
+ "ts": {
338
+ "type": "number",
339
+ "description": "The timestamp of the log entry, if left blank will be populated by the connector."
340
+ },
341
+ "message": {
342
+ "type": "string",
343
+ "description": "The message."
344
+ },
345
+ "error": {
346
+ "$ref": "#/components/schemas/Error"
347
+ },
348
+ "data": {
349
+ "type": "object",
350
+ "additionalProperties": {},
351
+ "description": "Optional data for the message."
352
+ }
353
+ },
354
+ "required": [
355
+ "level",
356
+ "source",
357
+ "message"
358
+ ],
359
+ "additionalProperties": false,
360
+ "description": "Interface describing a log entry."
361
+ },
362
+ "LogLevel": {
363
+ "type": "string",
364
+ "enum": [
365
+ "info",
366
+ "error",
367
+ "warn",
368
+ "trace",
369
+ "debug"
370
+ ],
371
+ "description": "Log level."
372
+ },
373
+ "LoggingListResponse": {
374
+ "type": "object",
375
+ "properties": {
376
+ "entities": {
377
+ "type": "array",
378
+ "items": {
379
+ "$ref": "#/components/schemas/LogEntry"
380
+ },
381
+ "description": "The entities, which can be partial if a limited keys list was provided."
382
+ },
383
+ "cursor": {
384
+ "type": "string",
385
+ "description": "An optional cursor, when defined can be used to call find to get more entities."
386
+ }
387
+ },
388
+ "required": [
389
+ "entities"
390
+ ],
391
+ "additionalProperties": false,
392
+ "description": "The response payload."
393
+ }
394
+ },
395
+ "securitySchemes": {
396
+ "jwtBearerAuthScheme": {
397
+ "type": "http",
398
+ "scheme": "bearer",
399
+ "bearerFormat": "JWT"
400
+ }
401
+ }
402
+ }
403
+ }
@@ -0,0 +1,251 @@
1
+ # Class: MessagingService
2
+
3
+ Service for performing email messaging operations to a connector.
4
+
5
+ ## Implements
6
+
7
+ - `IMessagingComponent`
8
+
9
+ ## Constructors
10
+
11
+ ### new MessagingService()
12
+
13
+ > **new MessagingService**(`options`?): [`MessagingService`](MessagingService.md)
14
+
15
+ Create a new instance of MessagingService.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IMessagingServiceConstructorOptions`](../interfaces/IMessagingServiceConstructorOptions.md)
22
+
23
+ The options for the connector.
24
+
25
+ #### Returns
26
+
27
+ [`MessagingService`](MessagingService.md)
28
+
29
+ ## Properties
30
+
31
+ ### NAMESPACE
32
+
33
+ > `readonly` `static` **NAMESPACE**: `string` = `"messaging"`
34
+
35
+ The namespace for the service.
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
+ `IMessagingComponent.CLASS_NAME`
48
+
49
+ ## Methods
50
+
51
+ ### sendCustomEmail()
52
+
53
+ > **sendCustomEmail**(`sender`, `recipients`, `templateId`, `data`, `locale`): `Promise`\<`boolean`\>
54
+
55
+ Send a custom email.
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
+ ##### templateId
72
+
73
+ `string`
74
+
75
+ The id of the email template.
76
+
77
+ ##### data
78
+
79
+ The data to populate the email template.
80
+
81
+ ##### locale
82
+
83
+ `string`
84
+
85
+ The locale of the email template.
86
+
87
+ #### Returns
88
+
89
+ `Promise`\<`boolean`\>
90
+
91
+ If the email was sent successfully.
92
+
93
+ #### Implementation of
94
+
95
+ `IMessagingComponent.sendCustomEmail`
96
+
97
+ ***
98
+
99
+ ### registerDevice()
100
+
101
+ > **registerDevice**(`applicationId`, `deviceToken`): `Promise`\<`string`\>
102
+
103
+ Registers a device to an specific app in order to send notifications to it.
104
+
105
+ #### Parameters
106
+
107
+ ##### applicationId
108
+
109
+ `string`
110
+
111
+ The application address.
112
+
113
+ ##### deviceToken
114
+
115
+ `string`
116
+
117
+ The device token.
118
+
119
+ #### Returns
120
+
121
+ `Promise`\<`string`\>
122
+
123
+ If the device was registered successfully.
124
+
125
+ #### Implementation of
126
+
127
+ `IMessagingComponent.registerDevice`
128
+
129
+ ***
130
+
131
+ ### sendSinglePushNotification()
132
+
133
+ > **sendSinglePushNotification**(`deviceAddress`, `templateId`, `data`, `locale`): `Promise`\<`boolean`\>
134
+
135
+ Send a push notification to a device.
136
+
137
+ #### Parameters
138
+
139
+ ##### deviceAddress
140
+
141
+ `string`
142
+
143
+ The address of the device.
144
+
145
+ ##### templateId
146
+
147
+ `string`
148
+
149
+ The id of the push notification template.
150
+
151
+ ##### data
152
+
153
+ The data to populate the push notification template.
154
+
155
+ ##### locale
156
+
157
+ `string`
158
+
159
+ The locale of the push notification template.
160
+
161
+ #### Returns
162
+
163
+ `Promise`\<`boolean`\>
164
+
165
+ If the notification was sent successfully.
166
+
167
+ #### Implementation of
168
+
169
+ `IMessagingComponent.sendSinglePushNotification`
170
+
171
+ ***
172
+
173
+ ### sendSMS()
174
+
175
+ > **sendSMS**(`phoneNumber`, `templateId`, `data`, `locale`): `Promise`\<`boolean`\>
176
+
177
+ Send a SMS message to a phone number.
178
+
179
+ #### Parameters
180
+
181
+ ##### phoneNumber
182
+
183
+ `string`
184
+
185
+ The recipient phone number.
186
+
187
+ ##### templateId
188
+
189
+ `string`
190
+
191
+ The id of the SMS template.
192
+
193
+ ##### data
194
+
195
+ The data to populate the SMS template.
196
+
197
+ ##### locale
198
+
199
+ `string`
200
+
201
+ The locale of the SMS template.
202
+
203
+ #### Returns
204
+
205
+ `Promise`\<`boolean`\>
206
+
207
+ If the SMS was sent successfully.
208
+
209
+ #### Implementation of
210
+
211
+ `IMessagingComponent.sendSMS`
212
+
213
+ ***
214
+
215
+ ### createOrUpdateTemplate()
216
+
217
+ > **createOrUpdateTemplate**(`templateId`, `locale`, `title`, `content`): `Promise`\<`boolean`\>
218
+
219
+ Create or update a template.
220
+
221
+ #### Parameters
222
+
223
+ ##### templateId
224
+
225
+ `string`
226
+
227
+ The id of the template.
228
+
229
+ ##### locale
230
+
231
+ `string`
232
+
233
+ The locale of the template.
234
+
235
+ ##### title
236
+
237
+ `string`
238
+
239
+ The title of the template.
240
+
241
+ ##### content
242
+
243
+ `string`
244
+
245
+ The content of the template.
246
+
247
+ #### Returns
248
+
249
+ `Promise`\<`boolean`\>
250
+
251
+ If the template was created or updated successfully.
@@ -0,0 +1,45 @@
1
+ # Class: TemplateEntry
2
+
3
+ Call defining a template message entry.
4
+
5
+ ## Constructors
6
+
7
+ ### new TemplateEntry()
8
+
9
+ > **new TemplateEntry**(): [`TemplateEntry`](TemplateEntry.md)
10
+
11
+ #### Returns
12
+
13
+ [`TemplateEntry`](TemplateEntry.md)
14
+
15
+ ## Properties
16
+
17
+ ### id
18
+
19
+ > **id**: `string`
20
+
21
+ The id.
22
+
23
+ ***
24
+
25
+ ### title
26
+
27
+ > **title**: `string`
28
+
29
+ The title.
30
+
31
+ ***
32
+
33
+ ### content
34
+
35
+ > **content**: `string`
36
+
37
+ The content.
38
+
39
+ ***
40
+
41
+ ### ts
42
+
43
+ > **ts**: `number`
44
+
45
+ The timestamp of the template entry.
@@ -0,0 +1,9 @@
1
+ # Function: initSchema()
2
+
3
+ > **initSchema**(): `void`
4
+
5
+ Initialize the schema for the messaging service.
6
+
7
+ ## Returns
8
+
9
+ `void`