@twin.org/messaging-service 0.0.3-next.5 → 0.0.3-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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messagingAdminService.js","sourceRoot":"","sources":["../../src/messagingAdminService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACjC;;OAEG;IACI,MAAM,CAAU,UAAU,2BAA2C;IAE5E
|
|
1
|
+
{"version":3,"file":"messagingAdminService.js","sourceRoot":"","sources":["../../src/messagingAdminService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACjC;;OAEG;IACI,MAAM,CAAU,UAAU,2BAA2C;IAE5E;;;OAGG;IACK,MAAM,CAAU,eAAe,GAAW,IAAI,CAAC;IAEvD;;;OAGG;IACc,uBAAuB,CAAyC;IAEjF;;;OAGG;IACc,cAAc,CAAS;IAExC;;;OAGG;IACH,YAAY,OAAkD;QAC7D,IAAI,CAAC,uBAAuB,GAAG,6BAA6B,CAAC,GAAG,CAC/D,OAAO,EAAE,iCAAiC,IAAI,gBAAgB,CAC9D,CAAC;QAEF,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,MAAM,EAAE,aAAa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G,CAAC,GAAG,UAAU,IAAI,MAAM,EAAE,CAAC,CAAC;QACnF,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,8FAA8F;QAC9F,oEAAoE;QACpE,IAAI,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;YAC/D,IAAI,CAAC;gBACJ,aAAa,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,GAAG,CACrD,GAAG,UAAU,IAAI,IAAI,CAAC,cAAc,EAAE,CACtC,CAAC;YACH,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACX,CAAC;QAED,IAAI,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,YAAY,CAAC,qBAAqB,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBAC7E,UAAU;gBACV,MAAM;aACN,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,cAAc,CAAC,UAAkB,EAAE,MAAc;QAC7D,MAAM,CAAC,WAAW,CAAC,qBAAqB,CAAC,UAAU,gBAAsB,UAAU,CAAC,CAAC;QACrF,MAAM,CAAC,WAAW,CAAC,qBAAqB,CAAC,UAAU,YAAkB,MAAM,CAAC,CAAC;QAE7E,OAAO,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,GAAG,UAAU,IAAI,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Is } from \"@twin.org/core\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IMessagingAdminComponent } from \"@twin.org/messaging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { TemplateEntry } from \"./entities/templateEntry.js\";\nimport type { IMessagingAdminServiceConstructorOptions } from \"./models/IMessagingAdminServiceConstructorOptions.js\";\n\n/**\n * Service for performing email messaging operations to a connector.\n */\nexport class MessagingAdminService implements IMessagingAdminComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<MessagingAdminService>();\n\n\t/**\n\t * Default locale for the messaging service.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_LOCALE: string = \"en\";\n\n\t/**\n\t * Entity storage connector used by the service.\n\t * @internal\n\t */\n\tprivate readonly _entityStorageConnector: IEntityStorageConnector<TemplateEntry>;\n\n\t/**\n\t * The default locale to use for the messaging service.\n\t * @internal\n\t */\n\tprivate readonly _defaultLocale: string;\n\n\t/**\n\t * Create a new instance of MessagingAdminService.\n\t * @param options The options for the connector.\n\t */\n\tconstructor(options?: IMessagingAdminServiceConstructorOptions) {\n\t\tthis._entityStorageConnector = EntityStorageConnectorFactory.get(\n\t\t\toptions?.templateEntryStorageConnectorType ?? \"template-entry\"\n\t\t);\n\n\t\tthis._defaultLocale = options?.config?.defaultLocale ?? MessagingAdminService._DEFAULT_LOCALE;\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 MessagingAdminService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create or update a template.\n\t * @param templateId The id of the template.\n\t * @param locale The locale of the template.\n\t * @param title The title of the template.\n\t * @param content The content of the template.\n\t * @returns Nothing.\n\t */\n\tpublic async setTemplate(\n\t\ttemplateId: string,\n\t\tlocale: string,\n\t\ttitle: string,\n\t\tcontent: string\n\t): Promise<void> {\n\t\tGuards.stringValue(MessagingAdminService.CLASS_NAME, nameof(templateId), templateId);\n\t\tGuards.stringValue(MessagingAdminService.CLASS_NAME, nameof(locale), locale);\n\t\tGuards.stringValue(MessagingAdminService.CLASS_NAME, nameof(title), title);\n\t\tGuards.stringValue(MessagingAdminService.CLASS_NAME, nameof(content), content);\n\n\t\tconst templateEntry = new TemplateEntry();\n\t\ttemplateEntry.id = `${templateId}:${locale}`;\n\t\ttemplateEntry.dateCreated = new Date(Date.now()).toISOString();\n\t\ttemplateEntry.title = title;\n\t\ttemplateEntry.content = content;\n\n\t\tawait this._entityStorageConnector.set(templateEntry);\n\t}\n\n\t/**\n\t * Get the email template by id and locale.\n\t * @param templateId The id of the email template.\n\t * @param locale The locale of the email template.\n\t * @returns The email template.\n\t */\n\tpublic async getTemplate(\n\t\ttemplateId: string,\n\t\tlocale: string\n\t): Promise<{ title: string; content: string }> {\n\t\tGuards.stringValue(MessagingAdminService.CLASS_NAME, nameof(templateId), templateId);\n\t\tGuards.stringValue(MessagingAdminService.CLASS_NAME, nameof(locale), locale);\n\n\t\tlet templateEntry;\n\n\t\ttry {\n\t\t\t// First try to get the template for the requested locale\n\t\t\ttemplateEntry = await this._entityStorageConnector.get(`${templateId}:${locale}`);\n\t\t} catch {}\n\n\t\t// If the template is not found for the requested locale, try to get it for the default locale\n\t\t// only if the requested locale is different from the default locale\n\t\tif (Is.empty(templateEntry) && this._defaultLocale !== locale) {\n\t\t\ttry {\n\t\t\t\ttemplateEntry = await this._entityStorageConnector.get(\n\t\t\t\t\t`${templateId}:${this._defaultLocale}`\n\t\t\t\t);\n\t\t\t} catch {}\n\t\t}\n\n\t\tif (Is.empty(templateEntry)) {\n\t\t\tthrow new GeneralError(MessagingAdminService.CLASS_NAME, \"getTemplateFailed\", {\n\t\t\t\ttemplateId,\n\t\t\t\tlocale\n\t\t\t});\n\t\t}\n\n\t\treturn templateEntry;\n\t}\n\n\t/**\n\t * Remove a template.\n\t * @param templateId The id of the template.\n\t * @param locale The locale of the template.\n\t * @returns Nothing\n\t */\n\tpublic async removeTemplate(templateId: string, locale: string): Promise<void> {\n\t\tGuards.stringValue(MessagingAdminService.CLASS_NAME, nameof(templateId), templateId);\n\t\tGuards.stringValue(MessagingAdminService.CLASS_NAME, nameof(locale), locale);\n\n\t\treturn this._entityStorageConnector.remove(`${templateId}:${locale}`);\n\t}\n}\n"]}
|
|
@@ -8,10 +8,6 @@ export declare class MessagingAdminService implements IMessagingAdminComponent {
|
|
|
8
8
|
* Runtime name for the class.
|
|
9
9
|
*/
|
|
10
10
|
static readonly CLASS_NAME: string;
|
|
11
|
-
/**
|
|
12
|
-
* Default locale for the messaging service.
|
|
13
|
-
*/
|
|
14
|
-
private static readonly _DEFAULT_LOCALE;
|
|
15
11
|
/**
|
|
16
12
|
* Create a new instance of MessagingAdminService.
|
|
17
13
|
* @param options The options for the connector.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.6](https://github.com/iotaledger/twin-messaging/compare/messaging-service-v0.0.3-next.5...messaging-service-v0.0.3-next.6) (2026-06-11)
|
|
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.3-next.5 to 0.0.3-next.6
|
|
16
|
+
|
|
3
17
|
## [0.0.3-next.5](https://github.com/iotaledger/twin-messaging/compare/messaging-service-v0.0.3-next.4...messaging-service-v0.0.3-next.5) (2026-05-20)
|
|
4
18
|
|
|
5
19
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/messaging-service",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.6",
|
|
4
4
|
"description": "Implements the messaging service layer that orchestrates delivery workflows across connectors.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/iotaledger/messaging.git",
|
|
7
|
+
"url": "git+https://github.com/iotaledger/twin-messaging.git",
|
|
8
8
|
"directory": "packages/messaging-service"
|
|
9
9
|
},
|
|
10
10
|
"author": "adrian.sanchez.sequeira@iota.org",
|
|
@@ -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.3-next.
|
|
21
|
+
"@twin.org/messaging-models": "0.0.3-next.6",
|
|
22
22
|
"@twin.org/nameof": "next"
|
|
23
23
|
},
|
|
24
24
|
"main": "./dist/es/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"business-logic"
|
|
49
49
|
],
|
|
50
50
|
"bugs": {
|
|
51
|
-
"url": "git+https://github.com/iotaledger/messaging/issues"
|
|
51
|
+
"url": "git+https://github.com/iotaledger/twin-messaging/issues"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://twindev.org"
|
|
54
54
|
}
|