@webiny/notifications-integrations 0.0.0-unstable.a4f3e4ea8b

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 +21 -0
  2. package/NotificationsIntegrations.d.ts +2 -0
  3. package/NotificationsIntegrations.js +8 -0
  4. package/NotificationsIntegrations.js.map +1 -0
  5. package/README.md +11 -0
  6. package/api/Extension.d.ts +4 -0
  7. package/api/Extension.js +13 -0
  8. package/api/Extension.js.map +1 -0
  9. package/api/collaboration/ReplyAddedNotificationHandler.d.ts +11 -0
  10. package/api/collaboration/ReplyAddedNotificationHandler.js +53 -0
  11. package/api/collaboration/ReplyAddedNotificationHandler.js.map +1 -0
  12. package/api/collaboration/ThreadCreatedNotificationHandler.d.ts +11 -0
  13. package/api/collaboration/ThreadCreatedNotificationHandler.js +39 -0
  14. package/api/collaboration/ThreadCreatedNotificationHandler.js.map +1 -0
  15. package/api/collaboration/feature.d.ts +4 -0
  16. package/api/collaboration/feature.js +13 -0
  17. package/api/collaboration/feature.js.map +1 -0
  18. package/api/workflows/WorkflowApprovedNotificationHandler.d.ts +13 -0
  19. package/api/workflows/WorkflowApprovedNotificationHandler.js +41 -0
  20. package/api/workflows/WorkflowApprovedNotificationHandler.js.map +1 -0
  21. package/api/workflows/WorkflowRejectedNotificationHandler.d.ts +13 -0
  22. package/api/workflows/WorkflowRejectedNotificationHandler.js +41 -0
  23. package/api/workflows/WorkflowRejectedNotificationHandler.js.map +1 -0
  24. package/api/workflows/feature.d.ts +4 -0
  25. package/api/workflows/feature.js +13 -0
  26. package/api/workflows/feature.js.map +1 -0
  27. package/index.d.ts +1 -0
  28. package/index.js +1 -0
  29. package/package.json +37 -0
  30. package/shared/constants.d.ts +2 -0
  31. package/shared/constants.js +4 -0
  32. package/shared/constants.js.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const NotificationsIntegrations: () => React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import react from "react";
2
+ import { Api } from "@webiny/project-aws";
3
+ const NotificationsIntegrations = ()=>/*#__PURE__*/ react.createElement(Api.Extension, {
4
+ src: import.meta.dirname + "/api/Extension.js"
5
+ });
6
+ export { NotificationsIntegrations };
7
+
8
+ //# sourceMappingURL=NotificationsIntegrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationsIntegrations.js","sources":["../src/NotificationsIntegrations.tsx"],"sourcesContent":["import React from \"react\";\nimport { Api } from \"@webiny/project-aws\";\n\nexport const NotificationsIntegrations = () => {\n return <Api.Extension src={import.meta.dirname + \"/api/Extension.js\"} />;\n};\n"],"names":["NotificationsIntegrations","Api"],"mappings":";;AAGO,MAAMA,4BAA4B,IAC9B,WAAP,GAAO,oBAACC,IAAI,SAAS;QAAC,KAAK,YAAY,OAAO,GAAG"}
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @webiny/notifications-integrations
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
@@ -0,0 +1,4 @@
1
+ export declare const Extension: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { CollaborationNotificationsFeature } from "./collaboration/feature.js";
3
+ import { WorkflowNotificationsFeature } from "./workflows/feature.js";
4
+ const Extension = createFeature({
5
+ name: "NotificationsIntegrations",
6
+ register (container) {
7
+ CollaborationNotificationsFeature.register(container);
8
+ WorkflowNotificationsFeature.register(container);
9
+ }
10
+ });
11
+ export { Extension };
12
+
13
+ //# sourceMappingURL=Extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api/Extension.js","sources":["../../src/api/Extension.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CollaborationNotificationsFeature } from \"./collaboration/feature.js\";\nimport { WorkflowNotificationsFeature } from \"./workflows/feature.js\";\n\nexport const Extension = createFeature({\n name: \"NotificationsIntegrations\",\n register(container) {\n CollaborationNotificationsFeature.register(container);\n WorkflowNotificationsFeature.register(container);\n }\n});\n"],"names":["Extension","createFeature","container","CollaborationNotificationsFeature","WorkflowNotificationsFeature"],"mappings":";;;AAIO,MAAMA,YAAYC,cAAc;IACnC,MAAM;IACN,UAASC,SAAS;QACdC,kCAAkC,QAAQ,CAACD;QAC3CE,6BAA6B,QAAQ,CAACF;IAC1C;AACJ"}
@@ -0,0 +1,11 @@
1
+ import { CollabReplyAddedHandler } from "@webiny/collaboration/api/domain/thread/events.js";
2
+ import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
3
+ declare class ReplyAddedNotificationHandlerImpl implements CollabReplyAddedHandler.Interface {
4
+ private createNotification;
5
+ constructor(createNotification: CreateNotificationUseCase.Interface);
6
+ handle(event: CollabReplyAddedHandler.Event): Promise<void>;
7
+ }
8
+ export declare const ReplyAddedNotificationHandler: typeof ReplyAddedNotificationHandlerImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/collaboration/api/domain/thread/events.js").CollabReplyAddedEvent>>;
10
+ };
11
+ export {};
@@ -0,0 +1,53 @@
1
+ import { CollabReplyAddedHandler } from "@webiny/collaboration/api/domain/thread/events.js";
2
+ import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
3
+ import { NotificationType } from "@webiny/notifications/api/domain/notification/abstractions.js";
4
+ import { APP_HEADLESS_CMS } from "../../shared/constants.js";
5
+ class ReplyAddedNotificationHandlerImpl {
6
+ constructor(createNotification){
7
+ this.createNotification = createNotification;
8
+ }
9
+ async handle(event) {
10
+ const { thread, message, anchor } = event.payload;
11
+ const actor = message.createdBy;
12
+ const title = anchor.contentTitle || anchor.label || "a comment";
13
+ const link = {
14
+ app: APP_HEADLESS_CMS,
15
+ contentType: thread.contentType,
16
+ contentId: thread.contentId,
17
+ locator: thread.locator,
18
+ threadId: thread.id
19
+ };
20
+ const mentioned = new Set((message.mentions || []).filter((id)=>id && id !== actor.id));
21
+ const participants = new Set();
22
+ for (const existing of thread.messages){
23
+ if (existing.id === message.id || existing.deleted) continue;
24
+ const authorId = existing.createdBy?.id;
25
+ if (authorId && authorId !== actor.id && !mentioned.has(authorId)) participants.add(authorId);
26
+ }
27
+ for (const recipientId of mentioned)await this.createNotification.execute({
28
+ recipientId,
29
+ type: NotificationType.mention,
30
+ actor,
31
+ title,
32
+ snippet: message.body,
33
+ link
34
+ });
35
+ for (const recipientId of participants)await this.createNotification.execute({
36
+ recipientId,
37
+ type: NotificationType.reply,
38
+ actor,
39
+ title,
40
+ snippet: message.body,
41
+ link
42
+ });
43
+ }
44
+ }
45
+ const ReplyAddedNotificationHandler = CollabReplyAddedHandler.createImplementation({
46
+ implementation: ReplyAddedNotificationHandlerImpl,
47
+ dependencies: [
48
+ CreateNotificationUseCase
49
+ ]
50
+ });
51
+ export { ReplyAddedNotificationHandler };
52
+
53
+ //# sourceMappingURL=ReplyAddedNotificationHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api/collaboration/ReplyAddedNotificationHandler.js","sources":["../../../src/api/collaboration/ReplyAddedNotificationHandler.ts"],"sourcesContent":["import { CollabReplyAddedHandler } from \"@webiny/collaboration/api/domain/thread/events.js\";\nimport { CreateNotificationUseCase } from \"@webiny/notifications/api/features/CreateNotification/index.js\";\nimport { NotificationType } from \"@webiny/notifications/api/domain/notification/abstractions.js\";\nimport { APP_HEADLESS_CMS } from \"~/shared/constants.js\";\n\nclass ReplyAddedNotificationHandlerImpl implements CollabReplyAddedHandler.Interface {\n constructor(private createNotification: CreateNotificationUseCase.Interface) {}\n\n async handle(event: CollabReplyAddedHandler.Event) {\n const { thread, message, anchor } = event.payload;\n const actor = message.createdBy;\n const title = anchor.contentTitle || anchor.label || \"a comment\";\n const link = {\n app: APP_HEADLESS_CMS,\n contentType: thread.contentType,\n contentId: thread.contentId,\n locator: thread.locator,\n threadId: thread.id\n };\n\n const mentioned = new Set((message.mentions || []).filter(id => id && id !== actor.id));\n const participants = new Set<string>();\n\n for (const existing of thread.messages) {\n if (existing.id === message.id || existing.deleted) {\n continue;\n }\n const authorId = existing.createdBy?.id;\n if (authorId && authorId !== actor.id && !mentioned.has(authorId)) {\n participants.add(authorId);\n }\n }\n\n for (const recipientId of mentioned) {\n await this.createNotification.execute({\n recipientId,\n type: NotificationType.mention,\n actor,\n title,\n snippet: message.body,\n link\n });\n }\n\n for (const recipientId of participants) {\n await this.createNotification.execute({\n recipientId,\n type: NotificationType.reply,\n actor,\n title,\n snippet: message.body,\n link\n });\n }\n }\n}\n\nexport const ReplyAddedNotificationHandler = CollabReplyAddedHandler.createImplementation({\n implementation: ReplyAddedNotificationHandlerImpl,\n dependencies: [CreateNotificationUseCase]\n});\n"],"names":["ReplyAddedNotificationHandlerImpl","createNotification","event","thread","message","anchor","actor","title","link","APP_HEADLESS_CMS","mentioned","Set","id","participants","existing","authorId","recipientId","NotificationType","ReplyAddedNotificationHandler","CollabReplyAddedHandler","CreateNotificationUseCase"],"mappings":";;;;AAKA,MAAMA;IACF,YAAoBC,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAAoC,EAAE;QAC/C,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGH,MAAM,OAAO;QACjD,MAAMI,QAAQF,QAAQ,SAAS;QAC/B,MAAMG,QAAQF,OAAO,YAAY,IAAIA,OAAO,KAAK,IAAI;QACrD,MAAMG,OAAO;YACT,KAAKC;YACL,aAAaN,OAAO,WAAW;YAC/B,WAAWA,OAAO,SAAS;YAC3B,SAASA,OAAO,OAAO;YACvB,UAAUA,OAAO,EAAE;QACvB;QAEA,MAAMO,YAAY,IAAIC,IAAKP,AAAAA,CAAAA,QAAQ,QAAQ,IAAI,EAAC,EAAG,MAAM,CAACQ,CAAAA,KAAMA,MAAMA,OAAON,MAAM,EAAE;QACrF,MAAMO,eAAe,IAAIF;QAEzB,KAAK,MAAMG,YAAYX,OAAO,QAAQ,CAAE;YACpC,IAAIW,SAAS,EAAE,KAAKV,QAAQ,EAAE,IAAIU,SAAS,OAAO,EAC9C;YAEJ,MAAMC,WAAWD,SAAS,SAAS,EAAE;YACrC,IAAIC,YAAYA,aAAaT,MAAM,EAAE,IAAI,CAACI,UAAU,GAAG,CAACK,WACpDF,aAAa,GAAG,CAACE;QAEzB;QAEA,KAAK,MAAMC,eAAeN,UACtB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClCM;YACA,MAAMC,iBAAiB,OAAO;YAC9BX;YACAC;YACA,SAASH,QAAQ,IAAI;YACrBI;QACJ;QAGJ,KAAK,MAAMQ,eAAeH,aACtB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClCG;YACA,MAAMC,iBAAiB,KAAK;YAC5BX;YACAC;YACA,SAASH,QAAQ,IAAI;YACrBI;QACJ;IAER;AACJ;AAEO,MAAMU,gCAAgCC,wBAAwB,oBAAoB,CAAC;IACtF,gBAAgBnB;IAChB,cAAc;QAACoB;KAA0B;AAC7C"}
@@ -0,0 +1,11 @@
1
+ import { CollabThreadCreatedHandler } from "@webiny/collaboration/api/domain/thread/events.js";
2
+ import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
3
+ declare class ThreadCreatedNotificationHandlerImpl implements CollabThreadCreatedHandler.Interface {
4
+ private createNotification;
5
+ constructor(createNotification: CreateNotificationUseCase.Interface);
6
+ handle(event: CollabThreadCreatedHandler.Event): Promise<void>;
7
+ }
8
+ export declare const ThreadCreatedNotificationHandler: typeof ThreadCreatedNotificationHandlerImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/collaboration/api/domain/thread/events.js").CollabThreadCreatedEvent>>;
10
+ };
11
+ export {};
@@ -0,0 +1,39 @@
1
+ import { CollabThreadCreatedHandler } from "@webiny/collaboration/api/domain/thread/events.js";
2
+ import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
3
+ import { NotificationType } from "@webiny/notifications/api/domain/notification/abstractions.js";
4
+ import { APP_HEADLESS_CMS } from "../../shared/constants.js";
5
+ class ThreadCreatedNotificationHandlerImpl {
6
+ constructor(createNotification){
7
+ this.createNotification = createNotification;
8
+ }
9
+ async handle(event) {
10
+ const { thread, message, anchor } = event.payload;
11
+ const actor = message.createdBy;
12
+ const title = anchor.contentTitle || anchor.label || "a comment";
13
+ const link = {
14
+ app: APP_HEADLESS_CMS,
15
+ contentType: thread.contentType,
16
+ contentId: thread.contentId,
17
+ locator: thread.locator,
18
+ threadId: thread.id
19
+ };
20
+ const recipients = new Set((message.mentions || []).filter((id)=>id && id !== actor.id));
21
+ for (const recipientId of recipients)await this.createNotification.execute({
22
+ recipientId,
23
+ type: NotificationType.mention,
24
+ actor,
25
+ title,
26
+ snippet: message.body,
27
+ link
28
+ });
29
+ }
30
+ }
31
+ const ThreadCreatedNotificationHandler = CollabThreadCreatedHandler.createImplementation({
32
+ implementation: ThreadCreatedNotificationHandlerImpl,
33
+ dependencies: [
34
+ CreateNotificationUseCase
35
+ ]
36
+ });
37
+ export { ThreadCreatedNotificationHandler };
38
+
39
+ //# sourceMappingURL=ThreadCreatedNotificationHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api/collaboration/ThreadCreatedNotificationHandler.js","sources":["../../../src/api/collaboration/ThreadCreatedNotificationHandler.ts"],"sourcesContent":["import { CollabThreadCreatedHandler } from \"@webiny/collaboration/api/domain/thread/events.js\";\nimport { CreateNotificationUseCase } from \"@webiny/notifications/api/features/CreateNotification/index.js\";\nimport { NotificationType } from \"@webiny/notifications/api/domain/notification/abstractions.js\";\nimport { APP_HEADLESS_CMS } from \"~/shared/constants.js\";\n\nclass ThreadCreatedNotificationHandlerImpl implements CollabThreadCreatedHandler.Interface {\n constructor(private createNotification: CreateNotificationUseCase.Interface) {}\n\n async handle(event: CollabThreadCreatedHandler.Event) {\n const { thread, message, anchor } = event.payload;\n const actor = message.createdBy;\n const title = anchor.contentTitle || anchor.label || \"a comment\";\n const link = {\n app: APP_HEADLESS_CMS,\n contentType: thread.contentType,\n contentId: thread.contentId,\n locator: thread.locator,\n threadId: thread.id\n };\n\n const recipients = new Set((message.mentions || []).filter(id => id && id !== actor.id));\n\n for (const recipientId of recipients) {\n await this.createNotification.execute({\n recipientId,\n type: NotificationType.mention,\n actor,\n title,\n snippet: message.body,\n link\n });\n }\n }\n}\n\nexport const ThreadCreatedNotificationHandler = CollabThreadCreatedHandler.createImplementation({\n implementation: ThreadCreatedNotificationHandlerImpl,\n dependencies: [CreateNotificationUseCase]\n});\n"],"names":["ThreadCreatedNotificationHandlerImpl","createNotification","event","thread","message","anchor","actor","title","link","APP_HEADLESS_CMS","recipients","Set","id","recipientId","NotificationType","ThreadCreatedNotificationHandler","CollabThreadCreatedHandler","CreateNotificationUseCase"],"mappings":";;;;AAKA,MAAMA;IACF,YAAoBC,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAAuC,EAAE;QAClD,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGH,MAAM,OAAO;QACjD,MAAMI,QAAQF,QAAQ,SAAS;QAC/B,MAAMG,QAAQF,OAAO,YAAY,IAAIA,OAAO,KAAK,IAAI;QACrD,MAAMG,OAAO;YACT,KAAKC;YACL,aAAaN,OAAO,WAAW;YAC/B,WAAWA,OAAO,SAAS;YAC3B,SAASA,OAAO,OAAO;YACvB,UAAUA,OAAO,EAAE;QACvB;QAEA,MAAMO,aAAa,IAAIC,IAAKP,AAAAA,CAAAA,QAAQ,QAAQ,IAAI,EAAC,EAAG,MAAM,CAACQ,CAAAA,KAAMA,MAAMA,OAAON,MAAM,EAAE;QAEtF,KAAK,MAAMO,eAAeH,WACtB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClCG;YACA,MAAMC,iBAAiB,OAAO;YAC9BR;YACAC;YACA,SAASH,QAAQ,IAAI;YACrBI;QACJ;IAER;AACJ;AAEO,MAAMO,mCAAmCC,2BAA2B,oBAAoB,CAAC;IAC5F,gBAAgBhB;IAChB,cAAc;QAACiB;KAA0B;AAC7C"}
@@ -0,0 +1,4 @@
1
+ export declare const CollaborationNotificationsFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { ThreadCreatedNotificationHandler } from "./ThreadCreatedNotificationHandler.js";
3
+ import { ReplyAddedNotificationHandler } from "./ReplyAddedNotificationHandler.js";
4
+ const CollaborationNotificationsFeature = createFeature({
5
+ name: "NotificationsIntegrations/Collaboration",
6
+ register (container) {
7
+ container.register(ThreadCreatedNotificationHandler);
8
+ container.register(ReplyAddedNotificationHandler);
9
+ }
10
+ });
11
+ export { CollaborationNotificationsFeature };
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api/collaboration/feature.js","sources":["../../../src/api/collaboration/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ThreadCreatedNotificationHandler } from \"./ThreadCreatedNotificationHandler.js\";\nimport { ReplyAddedNotificationHandler } from \"./ReplyAddedNotificationHandler.js\";\n\nexport const CollaborationNotificationsFeature = createFeature({\n name: \"NotificationsIntegrations/Collaboration\",\n register(container) {\n container.register(ThreadCreatedNotificationHandler);\n container.register(ReplyAddedNotificationHandler);\n }\n});\n"],"names":["CollaborationNotificationsFeature","createFeature","container","ThreadCreatedNotificationHandler","ReplyAddedNotificationHandler"],"mappings":";;;AAIO,MAAMA,oCAAoCC,cAAc;IAC3D,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;IACvB;AACJ"}
@@ -0,0 +1,13 @@
1
+ import { WorkflowStateApproveStepHandler } from "@webiny/api-workflows/features/workflowState/ApproveWorkflowStateStep/events.js";
2
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
3
+ import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
4
+ declare class WorkflowApprovedNotificationHandlerImpl implements WorkflowStateApproveStepHandler.Interface {
5
+ private createNotification;
6
+ private identityContext;
7
+ constructor(createNotification: CreateNotificationUseCase.Interface, identityContext: IdentityContext.Interface);
8
+ handle(event: WorkflowStateApproveStepHandler.Event): Promise<void>;
9
+ }
10
+ export declare const WorkflowApprovedNotificationHandler: typeof WorkflowApprovedNotificationHandlerImpl & {
11
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-workflows/features/workflowState/ApproveWorkflowStateStep/events.js").WorkflowStateApproveStepEvent>>;
12
+ };
13
+ export {};
@@ -0,0 +1,41 @@
1
+ import { WorkflowStateApproveStepHandler } from "@webiny/api-workflows/features/workflowState/ApproveWorkflowStateStep/events.js";
2
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
3
+ import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
4
+ import { NotificationType } from "@webiny/notifications/api/domain/notification/abstractions.js";
5
+ class WorkflowApprovedNotificationHandlerImpl {
6
+ constructor(createNotification, identityContext){
7
+ this.createNotification = createNotification;
8
+ this.identityContext = identityContext;
9
+ }
10
+ async handle(event) {
11
+ const state = event.payload.state;
12
+ const recipientId = state.createdBy?.id;
13
+ const identity = this.identityContext.getIdentity();
14
+ if (!recipientId || recipientId === identity.id) return;
15
+ await this.createNotification.execute({
16
+ recipientId,
17
+ type: NotificationType.approved,
18
+ actor: {
19
+ id: identity.id,
20
+ displayName: identity.displayName,
21
+ type: identity.type
22
+ },
23
+ title: state.title,
24
+ snippet: null,
25
+ link: {
26
+ app: state.app,
27
+ contentId: state.targetId
28
+ }
29
+ });
30
+ }
31
+ }
32
+ const WorkflowApprovedNotificationHandler = WorkflowStateApproveStepHandler.createImplementation({
33
+ implementation: WorkflowApprovedNotificationHandlerImpl,
34
+ dependencies: [
35
+ CreateNotificationUseCase,
36
+ IdentityContext
37
+ ]
38
+ });
39
+ export { WorkflowApprovedNotificationHandler };
40
+
41
+ //# sourceMappingURL=WorkflowApprovedNotificationHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api/workflows/WorkflowApprovedNotificationHandler.js","sources":["../../../src/api/workflows/WorkflowApprovedNotificationHandler.ts"],"sourcesContent":["import { WorkflowStateApproveStepHandler } from \"@webiny/api-workflows/features/workflowState/ApproveWorkflowStateStep/events.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { CreateNotificationUseCase } from \"@webiny/notifications/api/features/CreateNotification/index.js\";\nimport { NotificationType } from \"@webiny/notifications/api/domain/notification/abstractions.js\";\n\nclass WorkflowApprovedNotificationHandlerImpl implements WorkflowStateApproveStepHandler.Interface {\n constructor(\n private createNotification: CreateNotificationUseCase.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async handle(event: WorkflowStateApproveStepHandler.Event) {\n const state = event.payload.state;\n const recipientId = state.createdBy?.id;\n const identity = this.identityContext.getIdentity();\n\n if (!recipientId || recipientId === identity.id) {\n return;\n }\n\n await this.createNotification.execute({\n recipientId,\n type: NotificationType.approved,\n actor: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n title: state.title,\n snippet: null,\n link: { app: state.app, contentId: state.targetId }\n });\n }\n}\n\nexport const WorkflowApprovedNotificationHandler =\n WorkflowStateApproveStepHandler.createImplementation({\n implementation: WorkflowApprovedNotificationHandlerImpl,\n dependencies: [CreateNotificationUseCase, IdentityContext]\n });\n"],"names":["WorkflowApprovedNotificationHandlerImpl","createNotification","identityContext","event","state","recipientId","identity","NotificationType","WorkflowApprovedNotificationHandler","WorkflowStateApproveStepHandler","CreateNotificationUseCase","IdentityContext"],"mappings":";;;;AAKA,MAAMA;IACF,YACYC,kBAAuD,EACvDC,eAA0C,CACpD;aAFUD,kBAAkB,GAAlBA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,OAAOC,KAA4C,EAAE;QACvD,MAAMC,QAAQD,MAAM,OAAO,CAAC,KAAK;QACjC,MAAME,cAAcD,MAAM,SAAS,EAAE;QACrC,MAAME,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QAEjD,IAAI,CAACD,eAAeA,gBAAgBC,SAAS,EAAE,EAC3C;QAGJ,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClCD;YACA,MAAME,iBAAiB,QAAQ;YAC/B,OAAO;gBACH,IAAID,SAAS,EAAE;gBACf,aAAaA,SAAS,WAAW;gBACjC,MAAMA,SAAS,IAAI;YACvB;YACA,OAAOF,MAAM,KAAK;YAClB,SAAS;YACT,MAAM;gBAAE,KAAKA,MAAM,GAAG;gBAAE,WAAWA,MAAM,QAAQ;YAAC;QACtD;IACJ;AACJ;AAEO,MAAMI,sCACTC,gCAAgC,oBAAoB,CAAC;IACjD,gBAAgBT;IAChB,cAAc;QAACU;QAA2BC;KAAgB;AAC9D"}
@@ -0,0 +1,13 @@
1
+ import { WorkflowStateRejectHandler } from "@webiny/api-workflows/features/workflowState/RejectWorkflowStateStep/events.js";
2
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
3
+ import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
4
+ declare class WorkflowRejectedNotificationHandlerImpl implements WorkflowStateRejectHandler.Interface {
5
+ private createNotification;
6
+ private identityContext;
7
+ constructor(createNotification: CreateNotificationUseCase.Interface, identityContext: IdentityContext.Interface);
8
+ handle(event: WorkflowStateRejectHandler.Event): Promise<void>;
9
+ }
10
+ export declare const WorkflowRejectedNotificationHandler: typeof WorkflowRejectedNotificationHandlerImpl & {
11
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-workflows/features/workflowState/RejectWorkflowStateStep/events.js").WorkflowStateRejectEvent>>;
12
+ };
13
+ export {};
@@ -0,0 +1,41 @@
1
+ import { WorkflowStateRejectHandler } from "@webiny/api-workflows/features/workflowState/RejectWorkflowStateStep/events.js";
2
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
3
+ import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
4
+ import { NotificationType } from "@webiny/notifications/api/domain/notification/abstractions.js";
5
+ class WorkflowRejectedNotificationHandlerImpl {
6
+ constructor(createNotification, identityContext){
7
+ this.createNotification = createNotification;
8
+ this.identityContext = identityContext;
9
+ }
10
+ async handle(event) {
11
+ const state = event.payload.state;
12
+ const recipientId = state.createdBy?.id;
13
+ const identity = this.identityContext.getIdentity();
14
+ if (!recipientId || recipientId === identity.id) return;
15
+ await this.createNotification.execute({
16
+ recipientId,
17
+ type: NotificationType.rejected,
18
+ actor: {
19
+ id: identity.id,
20
+ displayName: identity.displayName,
21
+ type: identity.type
22
+ },
23
+ title: state.title,
24
+ snippet: null,
25
+ link: {
26
+ app: state.app,
27
+ contentId: state.targetId
28
+ }
29
+ });
30
+ }
31
+ }
32
+ const WorkflowRejectedNotificationHandler = WorkflowStateRejectHandler.createImplementation({
33
+ implementation: WorkflowRejectedNotificationHandlerImpl,
34
+ dependencies: [
35
+ CreateNotificationUseCase,
36
+ IdentityContext
37
+ ]
38
+ });
39
+ export { WorkflowRejectedNotificationHandler };
40
+
41
+ //# sourceMappingURL=WorkflowRejectedNotificationHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api/workflows/WorkflowRejectedNotificationHandler.js","sources":["../../../src/api/workflows/WorkflowRejectedNotificationHandler.ts"],"sourcesContent":["import { WorkflowStateRejectHandler } from \"@webiny/api-workflows/features/workflowState/RejectWorkflowStateStep/events.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { CreateNotificationUseCase } from \"@webiny/notifications/api/features/CreateNotification/index.js\";\nimport { NotificationType } from \"@webiny/notifications/api/domain/notification/abstractions.js\";\n\nclass WorkflowRejectedNotificationHandlerImpl implements WorkflowStateRejectHandler.Interface {\n constructor(\n private createNotification: CreateNotificationUseCase.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async handle(event: WorkflowStateRejectHandler.Event) {\n const state = event.payload.state;\n const recipientId = state.createdBy?.id;\n const identity = this.identityContext.getIdentity();\n\n if (!recipientId || recipientId === identity.id) {\n return;\n }\n\n await this.createNotification.execute({\n recipientId,\n type: NotificationType.rejected,\n actor: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n title: state.title,\n snippet: null,\n link: { app: state.app, contentId: state.targetId }\n });\n }\n}\n\nexport const WorkflowRejectedNotificationHandler = WorkflowStateRejectHandler.createImplementation({\n implementation: WorkflowRejectedNotificationHandlerImpl,\n dependencies: [CreateNotificationUseCase, IdentityContext]\n});\n"],"names":["WorkflowRejectedNotificationHandlerImpl","createNotification","identityContext","event","state","recipientId","identity","NotificationType","WorkflowRejectedNotificationHandler","WorkflowStateRejectHandler","CreateNotificationUseCase","IdentityContext"],"mappings":";;;;AAKA,MAAMA;IACF,YACYC,kBAAuD,EACvDC,eAA0C,CACpD;aAFUD,kBAAkB,GAAlBA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,OAAOC,KAAuC,EAAE;QAClD,MAAMC,QAAQD,MAAM,OAAO,CAAC,KAAK;QACjC,MAAME,cAAcD,MAAM,SAAS,EAAE;QACrC,MAAME,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QAEjD,IAAI,CAACD,eAAeA,gBAAgBC,SAAS,EAAE,EAC3C;QAGJ,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClCD;YACA,MAAME,iBAAiB,QAAQ;YAC/B,OAAO;gBACH,IAAID,SAAS,EAAE;gBACf,aAAaA,SAAS,WAAW;gBACjC,MAAMA,SAAS,IAAI;YACvB;YACA,OAAOF,MAAM,KAAK;YAClB,SAAS;YACT,MAAM;gBAAE,KAAKA,MAAM,GAAG;gBAAE,WAAWA,MAAM,QAAQ;YAAC;QACtD;IACJ;AACJ;AAEO,MAAMI,sCAAsCC,2BAA2B,oBAAoB,CAAC;IAC/F,gBAAgBT;IAChB,cAAc;QAACU;QAA2BC;KAAgB;AAC9D"}
@@ -0,0 +1,4 @@
1
+ export declare const WorkflowNotificationsFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { WorkflowApprovedNotificationHandler } from "./WorkflowApprovedNotificationHandler.js";
3
+ import { WorkflowRejectedNotificationHandler } from "./WorkflowRejectedNotificationHandler.js";
4
+ const WorkflowNotificationsFeature = createFeature({
5
+ name: "NotificationsIntegrations/Workflows",
6
+ register (container) {
7
+ container.register(WorkflowApprovedNotificationHandler);
8
+ container.register(WorkflowRejectedNotificationHandler);
9
+ }
10
+ });
11
+ export { WorkflowNotificationsFeature };
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api/workflows/feature.js","sources":["../../../src/api/workflows/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { WorkflowApprovedNotificationHandler } from \"./WorkflowApprovedNotificationHandler.js\";\nimport { WorkflowRejectedNotificationHandler } from \"./WorkflowRejectedNotificationHandler.js\";\n\nexport const WorkflowNotificationsFeature = createFeature({\n name: \"NotificationsIntegrations/Workflows\",\n register(container) {\n container.register(WorkflowApprovedNotificationHandler);\n container.register(WorkflowRejectedNotificationHandler);\n }\n});\n"],"names":["WorkflowNotificationsFeature","createFeature","container","WorkflowApprovedNotificationHandler","WorkflowRejectedNotificationHandler"],"mappings":";;;AAIO,MAAMA,+BAA+BC,cAAc;IACtD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;IACvB;AACJ"}
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { NotificationsIntegrations } from "./NotificationsIntegrations.js";
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { NotificationsIntegrations } from "./NotificationsIntegrations.js";
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@webiny/notifications-integrations",
3
+ "version": "0.0.0-unstable.a4f3e4ea8b",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./*": "./*"
9
+ },
10
+ "description": "Notification integrations: feeds the notifications inbox from Workflows and Collaboration",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/webiny/webiny-js.git",
14
+ "directory": "packages/notifications-integrations"
15
+ },
16
+ "license": "MIT",
17
+ "dependencies": {
18
+ "@webiny/api-core": "0.0.0-unstable.a4f3e4ea8b",
19
+ "@webiny/api-workflows": "0.0.0-unstable.a4f3e4ea8b",
20
+ "@webiny/collaboration": "0.0.0-unstable.a4f3e4ea8b",
21
+ "@webiny/feature": "0.0.0-unstable.a4f3e4ea8b",
22
+ "@webiny/notifications": "0.0.0-unstable.a4f3e4ea8b",
23
+ "@webiny/project-aws": "0.0.0-unstable.a4f3e4ea8b",
24
+ "react": "18.3.1"
25
+ },
26
+ "devDependencies": {
27
+ "@types/react": "18.3.31",
28
+ "@webiny/build-tools": "0.0.0-unstable.a4f3e4ea8b",
29
+ "typescript": "7.0.2"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "webiny": {
35
+ "publishFrom": "dist"
36
+ }
37
+ }
@@ -0,0 +1,2 @@
1
+ /** Routing hints stored on a notification's link, used by the admin to navigate on click. */
2
+ export declare const APP_HEADLESS_CMS = "cms";
@@ -0,0 +1,4 @@
1
+ const APP_HEADLESS_CMS = "cms";
2
+ export { APP_HEADLESS_CMS };
3
+
4
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared/constants.js","sources":["../../src/shared/constants.ts"],"sourcesContent":["/** Routing hints stored on a notification's link, used by the admin to navigate on click. */\nexport const APP_HEADLESS_CMS = \"cms\";\n"],"names":["APP_HEADLESS_CMS"],"mappings":"AACO,MAAMA,mBAAmB"}