@twin.org/messaging-service 0.0.2-next.4 → 0.0.2-next.6

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.
@@ -55,13 +55,13 @@ exports.TemplateEntry = __decorate([
55
55
  */
56
56
  class MessagingAdminService {
57
57
  /**
58
- * Default locale for the messaging service.
58
+ * Runtime name for the class.
59
59
  */
60
- static _DEFAULT_LOCALE = "en";
60
+ static CLASS_NAME = "MessagingAdminService";
61
61
  /**
62
- * Runtime name for the class.
62
+ * Default locale for the messaging service.
63
63
  */
64
- CLASS_NAME = "MessagingAdminService";
64
+ static _DEFAULT_LOCALE = "en";
65
65
  /**
66
66
  * Entity storage connector used by the service.
67
67
  * @internal
@@ -110,10 +110,10 @@ class MessagingAdminService {
110
110
  * @returns Nothing.
111
111
  */
112
112
  async setTemplate(templateId, locale, title, content) {
113
- core.Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
114
- core.Guards.stringValue(this.CLASS_NAME, "locale", locale);
115
- core.Guards.stringValue(this.CLASS_NAME, "title", title);
116
- core.Guards.stringValue(this.CLASS_NAME, "content", content);
113
+ core.Guards.stringValue(MessagingAdminService.CLASS_NAME, "templateId", templateId);
114
+ core.Guards.stringValue(MessagingAdminService.CLASS_NAME, "locale", locale);
115
+ core.Guards.stringValue(MessagingAdminService.CLASS_NAME, "title", title);
116
+ core.Guards.stringValue(MessagingAdminService.CLASS_NAME, "content", content);
117
117
  const templateEntry = new exports.TemplateEntry();
118
118
  templateEntry.id = `${templateId}:${locale}`;
119
119
  templateEntry.dateCreated = new Date(Date.now()).toISOString();
@@ -128,8 +128,8 @@ class MessagingAdminService {
128
128
  * @returns The email template.
129
129
  */
130
130
  async getTemplate(templateId, locale) {
131
- core.Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
132
- core.Guards.stringValue(this.CLASS_NAME, "locale", locale);
131
+ core.Guards.stringValue(MessagingAdminService.CLASS_NAME, "templateId", templateId);
132
+ core.Guards.stringValue(MessagingAdminService.CLASS_NAME, "locale", locale);
133
133
  let templateEntry;
134
134
  try {
135
135
  // First try to get the template for the requested locale
@@ -145,7 +145,10 @@ class MessagingAdminService {
145
145
  catch { }
146
146
  }
147
147
  if (core.Is.empty(templateEntry)) {
148
- throw new core.GeneralError(this.CLASS_NAME, "getTemplateFailed", { templateId, locale });
148
+ throw new core.GeneralError(MessagingAdminService.CLASS_NAME, "getTemplateFailed", {
149
+ templateId,
150
+ locale
151
+ });
149
152
  }
150
153
  return templateEntry;
151
154
  }
@@ -156,8 +159,8 @@ class MessagingAdminService {
156
159
  * @returns Nothing
157
160
  */
158
161
  async removeTemplate(templateId, locale) {
159
- core.Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
160
- core.Guards.stringValue(this.CLASS_NAME, "locale", locale);
162
+ core.Guards.stringValue(MessagingAdminService.CLASS_NAME, "templateId", templateId);
163
+ core.Guards.stringValue(MessagingAdminService.CLASS_NAME, "locale", locale);
161
164
  return this._entityStorageConnector.remove(`${templateId}:${locale}`);
162
165
  }
163
166
  }
@@ -171,7 +174,7 @@ class MessagingService {
171
174
  /**
172
175
  * Runtime name for the class.
173
176
  */
174
- CLASS_NAME = "MessagingService";
177
+ static CLASS_NAME = "MessagingService";
175
178
  /**
176
179
  * Emails messaging connector used by the service.
177
180
  * @internal
@@ -219,13 +222,13 @@ class MessagingService {
219
222
  */
220
223
  async sendCustomEmail(sender, recipients, templateId, data, locale) {
221
224
  if (core.Is.empty(this._emailMessagingConnector)) {
222
- throw new core.GeneralError(this.CLASS_NAME, "notConfiguredEmailMessagingConnector");
225
+ throw new core.GeneralError(MessagingService.CLASS_NAME, "notConfiguredEmailMessagingConnector");
223
226
  }
224
- core.Guards.stringValue(this.CLASS_NAME, "sender", sender);
225
- core.Guards.arrayValue(this.CLASS_NAME, "recipients", recipients);
226
- core.Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
227
- core.Guards.object(this.CLASS_NAME, "data", data);
228
- core.Guards.stringValue(this.CLASS_NAME, "locale", locale);
227
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "sender", sender);
228
+ core.Guards.arrayValue(MessagingService.CLASS_NAME, "recipients", recipients);
229
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "templateId", templateId);
230
+ core.Guards.object(MessagingService.CLASS_NAME, "data", data);
231
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "locale", locale);
229
232
  const template = await this._messagingAdminComponent.getTemplate(templateId, locale);
230
233
  const populatedTemplate = this.populateTemplate(template, data);
231
234
  return this._emailMessagingConnector.sendCustomEmail(sender, recipients, populatedTemplate.title, populatedTemplate.content);
@@ -238,10 +241,10 @@ class MessagingService {
238
241
  */
239
242
  async registerDevice(applicationId, deviceToken) {
240
243
  if (core.Is.empty(this._pushNotificationMessagingConnector)) {
241
- throw new core.GeneralError(this.CLASS_NAME, "notConfiguredPushNotificationMessagingConnector");
244
+ throw new core.GeneralError(MessagingService.CLASS_NAME, "notConfiguredPushNotificationMessagingConnector");
242
245
  }
243
- core.Guards.stringValue(this.CLASS_NAME, "applicationId", applicationId);
244
- core.Guards.stringValue(this.CLASS_NAME, "deviceToken", deviceToken);
246
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "applicationId", applicationId);
247
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "deviceToken", deviceToken);
245
248
  return this._pushNotificationMessagingConnector.registerDevice(applicationId, deviceToken);
246
249
  }
247
250
  /**
@@ -254,12 +257,12 @@ class MessagingService {
254
257
  */
255
258
  async sendSinglePushNotification(deviceAddress, templateId, data, locale) {
256
259
  if (core.Is.empty(this._pushNotificationMessagingConnector)) {
257
- throw new core.GeneralError(this.CLASS_NAME, "notConfiguredPushNotificationMessagingConnector");
260
+ throw new core.GeneralError(MessagingService.CLASS_NAME, "notConfiguredPushNotificationMessagingConnector");
258
261
  }
259
- core.Guards.stringValue(this.CLASS_NAME, "deviceAddress", deviceAddress);
260
- core.Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
261
- core.Guards.object(this.CLASS_NAME, "data", data);
262
- core.Guards.stringValue(this.CLASS_NAME, "locale", locale);
262
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "deviceAddress", deviceAddress);
263
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "templateId", templateId);
264
+ core.Guards.object(MessagingService.CLASS_NAME, "data", data);
265
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "locale", locale);
263
266
  const template = await this._messagingAdminComponent.getTemplate(templateId, locale);
264
267
  const populatedTemplate = this.populateTemplate(template, data);
265
268
  return this._pushNotificationMessagingConnector.sendSinglePushNotification(deviceAddress, populatedTemplate.title, populatedTemplate.content);
@@ -274,12 +277,12 @@ class MessagingService {
274
277
  */
275
278
  async sendSMS(phoneNumber, templateId, data, locale) {
276
279
  if (core.Is.empty(this._smsMessagingConnector)) {
277
- throw new core.GeneralError(this.CLASS_NAME, "notConfiguredSmsMessagingConnector");
280
+ throw new core.GeneralError(MessagingService.CLASS_NAME, "notConfiguredSmsMessagingConnector");
278
281
  }
279
- core.Guards.stringValue(this.CLASS_NAME, "phoneNumber", phoneNumber);
280
- core.Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
281
- core.Guards.object(this.CLASS_NAME, "data", data);
282
- core.Guards.stringValue(this.CLASS_NAME, "locale", locale);
282
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "phoneNumber", phoneNumber);
283
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "templateId", templateId);
284
+ core.Guards.object(MessagingService.CLASS_NAME, "data", data);
285
+ core.Guards.stringValue(MessagingService.CLASS_NAME, "locale", locale);
283
286
  const template = await this._messagingAdminComponent.getTemplate(templateId, locale);
284
287
  const populatedTemplate = this.populateTemplate(template, data);
285
288
  return this._smsMessagingConnector.sendSMS(phoneNumber, populatedTemplate.content);
@@ -53,13 +53,13 @@ TemplateEntry = __decorate([
53
53
  */
54
54
  class MessagingAdminService {
55
55
  /**
56
- * Default locale for the messaging service.
56
+ * Runtime name for the class.
57
57
  */
58
- static _DEFAULT_LOCALE = "en";
58
+ static CLASS_NAME = "MessagingAdminService";
59
59
  /**
60
- * Runtime name for the class.
60
+ * Default locale for the messaging service.
61
61
  */
62
- CLASS_NAME = "MessagingAdminService";
62
+ static _DEFAULT_LOCALE = "en";
63
63
  /**
64
64
  * Entity storage connector used by the service.
65
65
  * @internal
@@ -108,10 +108,10 @@ class MessagingAdminService {
108
108
  * @returns Nothing.
109
109
  */
110
110
  async setTemplate(templateId, locale, title, content) {
111
- Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
112
- Guards.stringValue(this.CLASS_NAME, "locale", locale);
113
- Guards.stringValue(this.CLASS_NAME, "title", title);
114
- Guards.stringValue(this.CLASS_NAME, "content", content);
111
+ Guards.stringValue(MessagingAdminService.CLASS_NAME, "templateId", templateId);
112
+ Guards.stringValue(MessagingAdminService.CLASS_NAME, "locale", locale);
113
+ Guards.stringValue(MessagingAdminService.CLASS_NAME, "title", title);
114
+ Guards.stringValue(MessagingAdminService.CLASS_NAME, "content", content);
115
115
  const templateEntry = new TemplateEntry();
116
116
  templateEntry.id = `${templateId}:${locale}`;
117
117
  templateEntry.dateCreated = new Date(Date.now()).toISOString();
@@ -126,8 +126,8 @@ class MessagingAdminService {
126
126
  * @returns The email template.
127
127
  */
128
128
  async getTemplate(templateId, locale) {
129
- Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
130
- Guards.stringValue(this.CLASS_NAME, "locale", locale);
129
+ Guards.stringValue(MessagingAdminService.CLASS_NAME, "templateId", templateId);
130
+ Guards.stringValue(MessagingAdminService.CLASS_NAME, "locale", locale);
131
131
  let templateEntry;
132
132
  try {
133
133
  // First try to get the template for the requested locale
@@ -143,7 +143,10 @@ class MessagingAdminService {
143
143
  catch { }
144
144
  }
145
145
  if (Is.empty(templateEntry)) {
146
- throw new GeneralError(this.CLASS_NAME, "getTemplateFailed", { templateId, locale });
146
+ throw new GeneralError(MessagingAdminService.CLASS_NAME, "getTemplateFailed", {
147
+ templateId,
148
+ locale
149
+ });
147
150
  }
148
151
  return templateEntry;
149
152
  }
@@ -154,8 +157,8 @@ class MessagingAdminService {
154
157
  * @returns Nothing
155
158
  */
156
159
  async removeTemplate(templateId, locale) {
157
- Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
158
- Guards.stringValue(this.CLASS_NAME, "locale", locale);
160
+ Guards.stringValue(MessagingAdminService.CLASS_NAME, "templateId", templateId);
161
+ Guards.stringValue(MessagingAdminService.CLASS_NAME, "locale", locale);
159
162
  return this._entityStorageConnector.remove(`${templateId}:${locale}`);
160
163
  }
161
164
  }
@@ -169,7 +172,7 @@ class MessagingService {
169
172
  /**
170
173
  * Runtime name for the class.
171
174
  */
172
- CLASS_NAME = "MessagingService";
175
+ static CLASS_NAME = "MessagingService";
173
176
  /**
174
177
  * Emails messaging connector used by the service.
175
178
  * @internal
@@ -217,13 +220,13 @@ class MessagingService {
217
220
  */
218
221
  async sendCustomEmail(sender, recipients, templateId, data, locale) {
219
222
  if (Is.empty(this._emailMessagingConnector)) {
220
- throw new GeneralError(this.CLASS_NAME, "notConfiguredEmailMessagingConnector");
223
+ throw new GeneralError(MessagingService.CLASS_NAME, "notConfiguredEmailMessagingConnector");
221
224
  }
222
- Guards.stringValue(this.CLASS_NAME, "sender", sender);
223
- Guards.arrayValue(this.CLASS_NAME, "recipients", recipients);
224
- Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
225
- Guards.object(this.CLASS_NAME, "data", data);
226
- Guards.stringValue(this.CLASS_NAME, "locale", locale);
225
+ Guards.stringValue(MessagingService.CLASS_NAME, "sender", sender);
226
+ Guards.arrayValue(MessagingService.CLASS_NAME, "recipients", recipients);
227
+ Guards.stringValue(MessagingService.CLASS_NAME, "templateId", templateId);
228
+ Guards.object(MessagingService.CLASS_NAME, "data", data);
229
+ Guards.stringValue(MessagingService.CLASS_NAME, "locale", locale);
227
230
  const template = await this._messagingAdminComponent.getTemplate(templateId, locale);
228
231
  const populatedTemplate = this.populateTemplate(template, data);
229
232
  return this._emailMessagingConnector.sendCustomEmail(sender, recipients, populatedTemplate.title, populatedTemplate.content);
@@ -236,10 +239,10 @@ class MessagingService {
236
239
  */
237
240
  async registerDevice(applicationId, deviceToken) {
238
241
  if (Is.empty(this._pushNotificationMessagingConnector)) {
239
- throw new GeneralError(this.CLASS_NAME, "notConfiguredPushNotificationMessagingConnector");
242
+ throw new GeneralError(MessagingService.CLASS_NAME, "notConfiguredPushNotificationMessagingConnector");
240
243
  }
241
- Guards.stringValue(this.CLASS_NAME, "applicationId", applicationId);
242
- Guards.stringValue(this.CLASS_NAME, "deviceToken", deviceToken);
244
+ Guards.stringValue(MessagingService.CLASS_NAME, "applicationId", applicationId);
245
+ Guards.stringValue(MessagingService.CLASS_NAME, "deviceToken", deviceToken);
243
246
  return this._pushNotificationMessagingConnector.registerDevice(applicationId, deviceToken);
244
247
  }
245
248
  /**
@@ -252,12 +255,12 @@ class MessagingService {
252
255
  */
253
256
  async sendSinglePushNotification(deviceAddress, templateId, data, locale) {
254
257
  if (Is.empty(this._pushNotificationMessagingConnector)) {
255
- throw new GeneralError(this.CLASS_NAME, "notConfiguredPushNotificationMessagingConnector");
258
+ throw new GeneralError(MessagingService.CLASS_NAME, "notConfiguredPushNotificationMessagingConnector");
256
259
  }
257
- Guards.stringValue(this.CLASS_NAME, "deviceAddress", deviceAddress);
258
- Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
259
- Guards.object(this.CLASS_NAME, "data", data);
260
- Guards.stringValue(this.CLASS_NAME, "locale", locale);
260
+ Guards.stringValue(MessagingService.CLASS_NAME, "deviceAddress", deviceAddress);
261
+ Guards.stringValue(MessagingService.CLASS_NAME, "templateId", templateId);
262
+ Guards.object(MessagingService.CLASS_NAME, "data", data);
263
+ Guards.stringValue(MessagingService.CLASS_NAME, "locale", locale);
261
264
  const template = await this._messagingAdminComponent.getTemplate(templateId, locale);
262
265
  const populatedTemplate = this.populateTemplate(template, data);
263
266
  return this._pushNotificationMessagingConnector.sendSinglePushNotification(deviceAddress, populatedTemplate.title, populatedTemplate.content);
@@ -272,12 +275,12 @@ class MessagingService {
272
275
  */
273
276
  async sendSMS(phoneNumber, templateId, data, locale) {
274
277
  if (Is.empty(this._smsMessagingConnector)) {
275
- throw new GeneralError(this.CLASS_NAME, "notConfiguredSmsMessagingConnector");
278
+ throw new GeneralError(MessagingService.CLASS_NAME, "notConfiguredSmsMessagingConnector");
276
279
  }
277
- Guards.stringValue(this.CLASS_NAME, "phoneNumber", phoneNumber);
278
- Guards.stringValue(this.CLASS_NAME, "templateId", templateId);
279
- Guards.object(this.CLASS_NAME, "data", data);
280
- Guards.stringValue(this.CLASS_NAME, "locale", locale);
280
+ Guards.stringValue(MessagingService.CLASS_NAME, "phoneNumber", phoneNumber);
281
+ Guards.stringValue(MessagingService.CLASS_NAME, "templateId", templateId);
282
+ Guards.object(MessagingService.CLASS_NAME, "data", data);
283
+ Guards.stringValue(MessagingService.CLASS_NAME, "locale", locale);
281
284
  const template = await this._messagingAdminComponent.getTemplate(templateId, locale);
282
285
  const populatedTemplate = this.populateTemplate(template, data);
283
286
  return this._smsMessagingConnector.sendSMS(phoneNumber, populatedTemplate.content);
@@ -5,13 +5,13 @@ import type { IMessagingAdminServiceConstructorOptions } from "./models/IMessagi
5
5
  */
6
6
  export declare class MessagingAdminService implements IMessagingAdminComponent {
7
7
  /**
8
- * Default locale for the messaging service.
8
+ * Runtime name for the class.
9
9
  */
10
- private static readonly _DEFAULT_LOCALE;
10
+ static readonly CLASS_NAME: string;
11
11
  /**
12
- * Runtime name for the class.
12
+ * Default locale for the messaging service.
13
13
  */
14
- readonly CLASS_NAME: string;
14
+ private static readonly _DEFAULT_LOCALE;
15
15
  /**
16
16
  * Create a new instance of MessagingAdminService.
17
17
  * @param options The options for the connector.
@@ -7,7 +7,7 @@ export declare class MessagingService implements IMessagingComponent {
7
7
  /**
8
8
  * Runtime name for the class.
9
9
  */
10
- readonly CLASS_NAME: string;
10
+ static readonly CLASS_NAME: string;
11
11
  /**
12
12
  * Create a new instance of MessagingService.
13
13
  * @param options The options for the connector.
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @twin.org/messaging-service - Changelog
2
2
 
3
+ ## [0.0.2-next.6](https://github.com/twinfoundation/messaging/compare/messaging-service-v0.0.2-next.5...messaging-service-v0.0.2-next.6) (2025-10-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * add validate-locales ([5eeff9b](https://github.com/twinfoundation/messaging/commit/5eeff9b9bf6cecf93b249b56c4bb74b4c5bf86c9))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/messaging-models bumped from 0.0.2-next.5 to 0.0.2-next.6
16
+
17
+ ## [0.0.2-next.5](https://github.com/twinfoundation/messaging/compare/messaging-service-v0.0.2-next.4...messaging-service-v0.0.2-next.5) (2025-10-02)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **messaging-service:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/messaging-models bumped from 0.0.2-next.4 to 0.0.2-next.5
30
+
3
31
  ## [0.0.2-next.4](https://github.com/twinfoundation/messaging/compare/messaging-service-v0.0.2-next.3...messaging-service-v0.0.2-next.4) (2025-09-29)
4
32
 
5
33
 
@@ -186,8 +186,8 @@
186
186
  }
187
187
  },
188
188
  {
189
- "name": "pageSize",
190
- "description": "The maximum number of entities in a page.",
189
+ "name": "limit",
190
+ "description": "Limit the number of entities to return.",
191
191
  "in": "query",
192
192
  "required": false,
193
193
  "schema": {
@@ -30,14 +30,10 @@ The options for the connector.
30
30
 
31
31
  ### CLASS\_NAME
32
32
 
33
- > `readonly` **CLASS\_NAME**: `string`
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
34
 
35
35
  Runtime name for the class.
36
36
 
37
- #### Implementation of
38
-
39
- `IMessagingAdminComponent.CLASS_NAME`
40
-
41
37
  ## Methods
42
38
 
43
39
  ### start()
@@ -30,14 +30,10 @@ The options for the connector.
30
30
 
31
31
  ### CLASS\_NAME
32
32
 
33
- > `readonly` **CLASS\_NAME**: `string`
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
34
 
35
35
  Runtime name for the class.
36
36
 
37
- #### Implementation of
38
-
39
- `IMessagingComponent.CLASS_NAME`
40
-
41
37
  ## Methods
42
38
 
43
39
  ### sendCustomEmail()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/messaging-service",
3
- "version": "0.0.2-next.4",
3
+ "version": "0.0.2-next.6",
4
4
  "description": "Messaging service implementation",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  "@twin.org/entity": "next",
19
19
  "@twin.org/entity-storage-models": "next",
20
20
  "@twin.org/logging-models": "next",
21
- "@twin.org/messaging-models": "0.0.2-next.4",
21
+ "@twin.org/messaging-models": "0.0.2-next.6",
22
22
  "@twin.org/nameof": "next"
23
23
  },
24
24
  "main": "./dist/cjs/index.cjs",
@@ -38,5 +38,20 @@
38
38
  "dist/types",
39
39
  "locales",
40
40
  "docs"
41
- ]
41
+ ],
42
+ "keywords": [
43
+ "twin",
44
+ "trade",
45
+ "iota",
46
+ "framework",
47
+ "blockchain",
48
+ "messaging",
49
+ "service",
50
+ "microservice",
51
+ "business-logic"
52
+ ],
53
+ "bugs": {
54
+ "url": "git+https://github.com/twinfoundation/messaging/issues"
55
+ },
56
+ "homepage": "https://twindev.org"
42
57
  }