@twin.org/messaging-service 0.0.2-next.3 → 0.0.2-next.5

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.
@@ -72,6 +72,11 @@ class MessagingAdminService {
72
72
  * @internal
73
73
  */
74
74
  _defaultLocale;
75
+ /**
76
+ * Initial set of templates to create on startup.
77
+ * @internal
78
+ */
79
+ _initialTemplates;
75
80
  /**
76
81
  * Create a new instance of MessagingAdminService.
77
82
  * @param options The options for the connector.
@@ -79,6 +84,22 @@ class MessagingAdminService {
79
84
  constructor(options) {
80
85
  this._entityStorageConnector = entityStorageModels.EntityStorageConnectorFactory.get(options?.templateEntryStorageConnectorType ?? "template-entry");
81
86
  this._defaultLocale = options?.config?.defaultLocale ?? MessagingAdminService._DEFAULT_LOCALE;
87
+ this._initialTemplates = options?.config?.templates;
88
+ }
89
+ /**
90
+ * The component needs to be started when the node is initialized.
91
+ * @param nodeIdentity The identity of the node starting the component.
92
+ * @param nodeLoggingComponentType The node logging component type.
93
+ * @returns Nothing.
94
+ */
95
+ async start(nodeIdentity, nodeLoggingComponentType) {
96
+ if (core.Is.arrayValue(this._initialTemplates)) {
97
+ for (const template of this._initialTemplates) {
98
+ for (const locale of Object.keys(template.content)) {
99
+ await this.setTemplate(template.templateId, locale, template.title, template.content[locale]);
100
+ }
101
+ }
102
+ }
82
103
  }
83
104
  /**
84
105
  * Create or update a template.
@@ -1,5 +1,5 @@
1
1
  import { property, SortDirection, entity, EntitySchemaFactory, EntitySchemaHelper } from '@twin.org/entity';
2
- import { Guards, Is, GeneralError, ComponentFactory } from '@twin.org/core';
2
+ import { Is, Guards, GeneralError, ComponentFactory } from '@twin.org/core';
3
3
  import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
4
4
  import { MessagingEmailConnectorFactory, MessagingPushNotificationsConnectorFactory, MessagingSmsConnectorFactory } from '@twin.org/messaging-models';
5
5
 
@@ -70,6 +70,11 @@ class MessagingAdminService {
70
70
  * @internal
71
71
  */
72
72
  _defaultLocale;
73
+ /**
74
+ * Initial set of templates to create on startup.
75
+ * @internal
76
+ */
77
+ _initialTemplates;
73
78
  /**
74
79
  * Create a new instance of MessagingAdminService.
75
80
  * @param options The options for the connector.
@@ -77,6 +82,22 @@ class MessagingAdminService {
77
82
  constructor(options) {
78
83
  this._entityStorageConnector = EntityStorageConnectorFactory.get(options?.templateEntryStorageConnectorType ?? "template-entry");
79
84
  this._defaultLocale = options?.config?.defaultLocale ?? MessagingAdminService._DEFAULT_LOCALE;
85
+ this._initialTemplates = options?.config?.templates;
86
+ }
87
+ /**
88
+ * The component needs to be started when the node is initialized.
89
+ * @param nodeIdentity The identity of the node starting the component.
90
+ * @param nodeLoggingComponentType The node logging component type.
91
+ * @returns Nothing.
92
+ */
93
+ async start(nodeIdentity, nodeLoggingComponentType) {
94
+ if (Is.arrayValue(this._initialTemplates)) {
95
+ for (const template of this._initialTemplates) {
96
+ for (const locale of Object.keys(template.content)) {
97
+ await this.setTemplate(template.templateId, locale, template.title, template.content[locale]);
98
+ }
99
+ }
100
+ }
80
101
  }
81
102
  /**
82
103
  * Create or update a template.
@@ -17,6 +17,13 @@ export declare class MessagingAdminService implements IMessagingAdminComponent {
17
17
  * @param options The options for the connector.
18
18
  */
19
19
  constructor(options?: IMessagingAdminServiceConstructorOptions);
20
+ /**
21
+ * The component needs to be started when the node is initialized.
22
+ * @param nodeIdentity The identity of the node starting the component.
23
+ * @param nodeLoggingComponentType The node logging component type.
24
+ * @returns Nothing.
25
+ */
26
+ start(nodeIdentity?: string, nodeLoggingComponentType?: string): Promise<void>;
20
27
  /**
21
28
  * Create or update a template.
22
29
  * @param templateId The id of the template.
@@ -7,4 +7,14 @@ export interface IMessagingAdminServiceConfig {
7
7
  * @default en
8
8
  */
9
9
  defaultLocale?: string;
10
+ /**
11
+ * Initial set of templates to create on startup.
12
+ */
13
+ templates?: {
14
+ templateId: string;
15
+ title: string;
16
+ content: {
17
+ [locale: string]: string;
18
+ };
19
+ }[];
10
20
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @twin.org/messaging-service - Changelog
2
2
 
3
+ ## [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)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **messaging-service:** Synchronize repo versions
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.4 to 0.0.2-next.5
16
+
17
+ ## [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)
18
+
19
+
20
+ ### Features
21
+
22
+ * add initial templates config ([66b40eb](https://github.com/twinfoundation/messaging/commit/66b40eb57a478d9f79de540eb847a4fb37894235))
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.3 to 0.0.2-next.4
30
+
3
31
  ## [0.0.2-next.3](https://github.com/twinfoundation/messaging/compare/messaging-service-v0.0.2-next.2...messaging-service-v0.0.2-next.3) (2025-09-29)
4
32
 
5
33
 
@@ -40,6 +40,38 @@ Runtime name for the class.
40
40
 
41
41
  ## Methods
42
42
 
43
+ ### start()
44
+
45
+ > **start**(`nodeIdentity?`, `nodeLoggingComponentType?`): `Promise`\<`void`\>
46
+
47
+ The component needs to be started when the node is initialized.
48
+
49
+ #### Parameters
50
+
51
+ ##### nodeIdentity?
52
+
53
+ `string`
54
+
55
+ The identity of the node starting the component.
56
+
57
+ ##### nodeLoggingComponentType?
58
+
59
+ `string`
60
+
61
+ The node logging component type.
62
+
63
+ #### Returns
64
+
65
+ `Promise`\<`void`\>
66
+
67
+ Nothing.
68
+
69
+ #### Implementation of
70
+
71
+ `IMessagingAdminComponent.start`
72
+
73
+ ***
74
+
43
75
  ### setTemplate()
44
76
 
45
77
  > **setTemplate**(`templateId`, `locale`, `title`, `content`): `Promise`\<`void`\>
@@ -15,3 +15,27 @@ The default locale to use for the messaging service.
15
15
  ```ts
16
16
  en
17
17
  ```
18
+
19
+ ***
20
+
21
+ ### templates?
22
+
23
+ > `optional` **templates**: `object`[]
24
+
25
+ Initial set of templates to create on startup.
26
+
27
+ #### templateId
28
+
29
+ > **templateId**: `string`
30
+
31
+ #### title
32
+
33
+ > **title**: `string`
34
+
35
+ #### content
36
+
37
+ > **content**: `object`
38
+
39
+ ##### Index Signature
40
+
41
+ \[`locale`: `string`\]: `string`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/messaging-service",
3
- "version": "0.0.2-next.3",
3
+ "version": "0.0.2-next.5",
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.3",
21
+ "@twin.org/messaging-models": "0.0.2-next.5",
22
22
  "@twin.org/nameof": "next"
23
23
  },
24
24
  "main": "./dist/cjs/index.cjs",
@@ -38,5 +38,16 @@
38
38
  "dist/types",
39
39
  "locales",
40
40
  "docs"
41
+ ],
42
+ "keywords": [
43
+ "twin",
44
+ "trade",
45
+ "iota",
46
+ "framework",
47
+ "blockchain",
48
+ "messaging",
49
+ "service",
50
+ "microservice",
51
+ "business-logic"
41
52
  ]
42
53
  }