@webiny/notifications-integrations 0.0.0-unstable.7c2def32a7 → 0.0.0-unstable.a85ef555b2

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,13 +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";
1
+ import { ReviewApprovedEventHandler } from "@webiny/api-workflows/features/review/ApproveReviewStep/index.js";
3
2
  import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
4
- declare class WorkflowApprovedNotificationHandlerImpl implements WorkflowStateApproveStepHandler.Interface {
3
+ import { WorkflowModelParserService } from "@webiny/api-workflows/features/model/WorkflowModelParserService/index.js";
4
+ declare class WorkflowApprovedNotificationHandlerImpl implements ReviewApprovedEventHandler.Interface {
5
5
  private createNotification;
6
- private identityContext;
7
- constructor(createNotification: CreateNotificationUseCase.Interface, identityContext: IdentityContext.Interface);
8
- handle(event: WorkflowStateApproveStepHandler.Event): Promise<void>;
6
+ private modelParser;
7
+ constructor(createNotification: CreateNotificationUseCase.Interface, modelParser: WorkflowModelParserService.Interface);
8
+ handle(event: ReviewApprovedEventHandler.Event): Promise<void>;
9
9
  }
10
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>>;
11
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-workflows/features/review/ApproveReviewStep/events.js").ReviewApprovedEvent>>;
12
12
  };
13
13
  export {};
@@ -1,39 +1,38 @@
1
- import { WorkflowStateApproveStepHandler } from "@webiny/api-workflows/features/workflowState/ApproveWorkflowStateStep/events.js";
2
- import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
1
+ import { ReviewApprovedEventHandler } from "@webiny/api-workflows/features/review/ApproveReviewStep/index.js";
3
2
  import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
4
3
  import { NotificationType } from "@webiny/notifications/api/domain/notification/abstractions.js";
4
+ import { WorkflowModelParserService } from "@webiny/api-workflows/features/model/WorkflowModelParserService/index.js";
5
+ import { buildApprovedMessage } from "@webiny/api-workflows/domain/notifications/messages/buildApprovedMessage.js";
6
+ import { getReviewNotificationLink } from "./getReviewNotificationLink.js";
7
+ import { toNotificationActor } from "./toNotificationActor.js";
5
8
  class WorkflowApprovedNotificationHandlerImpl {
6
- constructor(createNotification, identityContext){
9
+ constructor(createNotification, modelParser){
7
10
  this.createNotification = createNotification;
8
- this.identityContext = identityContext;
11
+ this.modelParser = modelParser;
9
12
  }
10
13
  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;
14
+ const review = event.payload.review;
15
+ const recipientId = review.createdBy?.id;
16
+ const actor = event.payload.fact.actor;
17
+ if (!recipientId || "user" === actor.type && actor.id === recipientId) return;
18
+ const step = review.steps[review.steps.length - 1];
15
19
  await this.createNotification.execute({
16
20
  recipientId,
17
21
  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
- }
22
+ actor: toNotificationActor(actor, step?.title ?? ""),
23
+ title: review.title,
24
+ snippet: buildApprovedMessage({
25
+ contentTitle: review.title
26
+ }).body,
27
+ link: getReviewNotificationLink(this.modelParser.parse(review.model), review.targetId)
29
28
  });
30
29
  }
31
30
  }
32
- const WorkflowApprovedNotificationHandler = WorkflowStateApproveStepHandler.createImplementation({
31
+ const WorkflowApprovedNotificationHandler = ReviewApprovedEventHandler.createImplementation({
33
32
  implementation: WorkflowApprovedNotificationHandlerImpl,
34
33
  dependencies: [
35
34
  CreateNotificationUseCase,
36
- IdentityContext
35
+ WorkflowModelParserService
37
36
  ]
38
37
  });
39
38
  export { WorkflowApprovedNotificationHandler };
@@ -1 +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"}
1
+ {"version":3,"file":"api/workflows/WorkflowApprovedNotificationHandler.js","sources":["../../../src/api/workflows/WorkflowApprovedNotificationHandler.ts"],"sourcesContent":["import { ReviewApprovedEventHandler } from \"@webiny/api-workflows/features/review/ApproveReviewStep/index.js\";\nimport { CreateNotificationUseCase } from \"@webiny/notifications/api/features/CreateNotification/index.js\";\nimport { NotificationType } from \"@webiny/notifications/api/domain/notification/abstractions.js\";\nimport { WorkflowModelParserService } from \"@webiny/api-workflows/features/model/WorkflowModelParserService/index.js\";\nimport { buildApprovedMessage } from \"@webiny/api-workflows/domain/notifications/messages/buildApprovedMessage.js\";\nimport { getReviewNotificationLink } from \"./getReviewNotificationLink.js\";\nimport { toNotificationActor } from \"./toNotificationActor.js\";\n\n// Tells the requester in the inbox that every step of their review approved it. Single steps are\n// not announced: the design has no per-step approval notice.\nclass WorkflowApprovedNotificationHandlerImpl implements ReviewApprovedEventHandler.Interface {\n constructor(\n private createNotification: CreateNotificationUseCase.Interface,\n private modelParser: WorkflowModelParserService.Interface\n ) {}\n\n async handle(event: ReviewApprovedEventHandler.Event) {\n const review = event.payload.review;\n const recipientId = review.createdBy?.id;\n // Who decided comes from the fact, not the current identity: an AI or automation step\n // decides while running as the requester (R149), and must still notify them. Only a\n // requester deciding the last step themselves is not told.\n const actor = event.payload.fact.actor;\n if (!recipientId || (actor.type === \"user\" && actor.id === recipientId)) {\n return;\n }\n // The last step is the one that approved the review.\n const step = review.steps[review.steps.length - 1];\n\n await this.createNotification.execute({\n recipientId,\n type: NotificationType.approved,\n actor: toNotificationActor(actor, step?.title ?? \"\"),\n title: review.title,\n snippet: buildApprovedMessage({ contentTitle: review.title }).body,\n link: getReviewNotificationLink(this.modelParser.parse(review.model), review.targetId)\n });\n }\n}\n\nexport const WorkflowApprovedNotificationHandler = ReviewApprovedEventHandler.createImplementation({\n implementation: WorkflowApprovedNotificationHandlerImpl,\n dependencies: [CreateNotificationUseCase, WorkflowModelParserService]\n});\n"],"names":["WorkflowApprovedNotificationHandlerImpl","createNotification","modelParser","event","review","recipientId","actor","step","NotificationType","toNotificationActor","buildApprovedMessage","getReviewNotificationLink","WorkflowApprovedNotificationHandler","ReviewApprovedEventHandler","CreateNotificationUseCase","WorkflowModelParserService"],"mappings":";;;;;;;AAUA,MAAMA;IACF,YACYC,kBAAuD,EACvDC,WAAiD,CAC3D;aAFUD,kBAAkB,GAAlBA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,OAAOC,KAAuC,EAAE;QAClD,MAAMC,SAASD,MAAM,OAAO,CAAC,MAAM;QACnC,MAAME,cAAcD,OAAO,SAAS,EAAE;QAItC,MAAME,QAAQH,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK;QACtC,IAAI,CAACE,eAAgBC,AAAe,WAAfA,MAAM,IAAI,IAAeA,MAAM,EAAE,KAAKD,aACvD;QAGJ,MAAME,OAAOH,OAAO,KAAK,CAACA,OAAO,KAAK,CAAC,MAAM,GAAG,EAAE;QAElD,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClCC;YACA,MAAMG,iBAAiB,QAAQ;YAC/B,OAAOC,oBAAoBH,OAAOC,MAAM,SAAS;YACjD,OAAOH,OAAO,KAAK;YACnB,SAASM,qBAAqB;gBAAE,cAAcN,OAAO,KAAK;YAAC,GAAG,IAAI;YAClE,MAAMO,0BAA0B,IAAI,CAAC,WAAW,CAAC,KAAK,CAACP,OAAO,KAAK,GAAGA,OAAO,QAAQ;QACzF;IACJ;AACJ;AAEO,MAAMQ,sCAAsCC,2BAA2B,oBAAoB,CAAC;IAC/F,gBAAgBb;IAChB,cAAc;QAACc;QAA2BC;KAA2B;AACzE"}
@@ -1,13 +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";
1
+ import { ReviewStepRejectedEventHandler } from "@webiny/api-workflows/features/review/RejectReviewStep/index.js";
3
2
  import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
4
- declare class WorkflowRejectedNotificationHandlerImpl implements WorkflowStateRejectHandler.Interface {
3
+ import { WorkflowModelParserService } from "@webiny/api-workflows/features/model/WorkflowModelParserService/index.js";
4
+ declare class WorkflowRejectedNotificationHandlerImpl implements ReviewStepRejectedEventHandler.Interface {
5
5
  private createNotification;
6
- private identityContext;
7
- constructor(createNotification: CreateNotificationUseCase.Interface, identityContext: IdentityContext.Interface);
8
- handle(event: WorkflowStateRejectHandler.Event): Promise<void>;
6
+ private modelParser;
7
+ constructor(createNotification: CreateNotificationUseCase.Interface, modelParser: WorkflowModelParserService.Interface);
8
+ handle(event: ReviewStepRejectedEventHandler.Event): Promise<void>;
9
9
  }
10
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>>;
11
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-workflows/features/review/RejectReviewStep/events.js").ReviewStepRejectedEvent>>;
12
12
  };
13
13
  export {};
@@ -1,39 +1,43 @@
1
- import { WorkflowStateRejectHandler } from "@webiny/api-workflows/features/workflowState/RejectWorkflowStateStep/events.js";
2
- import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
1
+ import { ReviewStepRejectedEventHandler } from "@webiny/api-workflows/features/review/RejectReviewStep/index.js";
3
2
  import { CreateNotificationUseCase } from "@webiny/notifications/api/features/CreateNotification/index.js";
4
3
  import { NotificationType } from "@webiny/notifications/api/domain/notification/abstractions.js";
4
+ import { WorkflowModelParserService } from "@webiny/api-workflows/features/model/WorkflowModelParserService/index.js";
5
+ import { buildRejectedMessage } from "@webiny/api-workflows/domain/notifications/messages/buildRejectedMessage.js";
6
+ import { getActorName } from "@webiny/api-workflows/domain/notifications/getActorName.js";
7
+ import { getReviewNotificationLink } from "./getReviewNotificationLink.js";
8
+ import { toNotificationActor } from "./toNotificationActor.js";
5
9
  class WorkflowRejectedNotificationHandlerImpl {
6
- constructor(createNotification, identityContext){
10
+ constructor(createNotification, modelParser){
7
11
  this.createNotification = createNotification;
8
- this.identityContext = identityContext;
12
+ this.modelParser = modelParser;
9
13
  }
10
14
  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
+ const review = event.payload.review;
16
+ const recipientId = review.createdBy?.id;
17
+ const actor = event.payload.fact.actor;
18
+ if (!recipientId || "user" === actor.type && actor.id === recipientId) return;
19
+ const step = review.steps.find((item)=>item.id === event.payload.fact.change.stepId);
20
+ const stepTitle = step?.title ?? "";
15
21
  await this.createNotification.execute({
16
22
  recipientId,
17
23
  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
- }
24
+ actor: toNotificationActor(actor, stepTitle),
25
+ title: review.title,
26
+ snippet: buildRejectedMessage({
27
+ contentTitle: review.title,
28
+ stepTitle,
29
+ decider: getActorName(actor, stepTitle),
30
+ comment: event.payload.fact.comment
31
+ }).body,
32
+ link: getReviewNotificationLink(this.modelParser.parse(review.model), review.targetId)
29
33
  });
30
34
  }
31
35
  }
32
- const WorkflowRejectedNotificationHandler = WorkflowStateRejectHandler.createImplementation({
36
+ const WorkflowRejectedNotificationHandler = ReviewStepRejectedEventHandler.createImplementation({
33
37
  implementation: WorkflowRejectedNotificationHandlerImpl,
34
38
  dependencies: [
35
39
  CreateNotificationUseCase,
36
- IdentityContext
40
+ WorkflowModelParserService
37
41
  ]
38
42
  });
39
43
  export { WorkflowRejectedNotificationHandler };
@@ -1 +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"}
1
+ {"version":3,"file":"api/workflows/WorkflowRejectedNotificationHandler.js","sources":["../../../src/api/workflows/WorkflowRejectedNotificationHandler.ts"],"sourcesContent":["import { ReviewStepRejectedEventHandler } from \"@webiny/api-workflows/features/review/RejectReviewStep/index.js\";\nimport { CreateNotificationUseCase } from \"@webiny/notifications/api/features/CreateNotification/index.js\";\nimport { NotificationType } from \"@webiny/notifications/api/domain/notification/abstractions.js\";\nimport { WorkflowModelParserService } from \"@webiny/api-workflows/features/model/WorkflowModelParserService/index.js\";\nimport { buildRejectedMessage } from \"@webiny/api-workflows/domain/notifications/messages/buildRejectedMessage.js\";\nimport { getActorName } from \"@webiny/api-workflows/domain/notifications/getActorName.js\";\nimport { getReviewNotificationLink } from \"./getReviewNotificationLink.js\";\nimport { toNotificationActor } from \"./toNotificationActor.js\";\n\n// Tells the requester in the inbox that a step of their review was rejected.\nclass WorkflowRejectedNotificationHandlerImpl implements ReviewStepRejectedEventHandler.Interface {\n constructor(\n private createNotification: CreateNotificationUseCase.Interface,\n private modelParser: WorkflowModelParserService.Interface\n ) {}\n\n async handle(event: ReviewStepRejectedEventHandler.Event) {\n const review = event.payload.review;\n const recipientId = review.createdBy?.id;\n // Who decided comes from the fact, not the current identity: an AI or automation step\n // decides while running as the requester (R149), and must still notify them. Only a\n // requester deciding their own step is not told.\n const actor = event.payload.fact.actor;\n if (!recipientId || (actor.type === \"user\" && actor.id === recipientId)) {\n return;\n }\n const step = review.steps.find(item => item.id === event.payload.fact.change.stepId);\n const stepTitle = step?.title ?? \"\";\n\n await this.createNotification.execute({\n recipientId,\n type: NotificationType.rejected,\n actor: toNotificationActor(actor, stepTitle),\n title: review.title,\n // The design's in-app body: who rejected it and why (D107, D126).\n snippet: buildRejectedMessage({\n contentTitle: review.title,\n stepTitle,\n decider: getActorName(actor, stepTitle),\n comment: event.payload.fact.comment\n }).body,\n link: getReviewNotificationLink(this.modelParser.parse(review.model), review.targetId)\n });\n }\n}\n\nexport const WorkflowRejectedNotificationHandler =\n ReviewStepRejectedEventHandler.createImplementation({\n implementation: WorkflowRejectedNotificationHandlerImpl,\n dependencies: [CreateNotificationUseCase, WorkflowModelParserService]\n });\n"],"names":["WorkflowRejectedNotificationHandlerImpl","createNotification","modelParser","event","review","recipientId","actor","step","item","stepTitle","NotificationType","toNotificationActor","buildRejectedMessage","getActorName","getReviewNotificationLink","WorkflowRejectedNotificationHandler","ReviewStepRejectedEventHandler","CreateNotificationUseCase","WorkflowModelParserService"],"mappings":";;;;;;;;AAUA,MAAMA;IACF,YACYC,kBAAuD,EACvDC,WAAiD,CAC3D;aAFUD,kBAAkB,GAAlBA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,OAAOC,KAA2C,EAAE;QACtD,MAAMC,SAASD,MAAM,OAAO,CAAC,MAAM;QACnC,MAAME,cAAcD,OAAO,SAAS,EAAE;QAItC,MAAME,QAAQH,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK;QACtC,IAAI,CAACE,eAAgBC,AAAe,WAAfA,MAAM,IAAI,IAAeA,MAAM,EAAE,KAAKD,aACvD;QAEJ,MAAME,OAAOH,OAAO,KAAK,CAAC,IAAI,CAACI,CAAAA,OAAQA,KAAK,EAAE,KAAKL,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;QACnF,MAAMM,YAAYF,MAAM,SAAS;QAEjC,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClCF;YACA,MAAMK,iBAAiB,QAAQ;YAC/B,OAAOC,oBAAoBL,OAAOG;YAClC,OAAOL,OAAO,KAAK;YAEnB,SAASQ,qBAAqB;gBAC1B,cAAcR,OAAO,KAAK;gBAC1BK;gBACA,SAASI,aAAaP,OAAOG;gBAC7B,SAASN,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO;YACvC,GAAG,IAAI;YACP,MAAMW,0BAA0B,IAAI,CAAC,WAAW,CAAC,KAAK,CAACV,OAAO,KAAK,GAAGA,OAAO,QAAQ;QACzF;IACJ;AACJ;AAEO,MAAMW,sCACTC,+BAA+B,oBAAoB,CAAC;IAChD,gBAAgBhB;IAChB,cAAc;QAACiB;QAA2BC;KAA2B;AACzE"}
@@ -0,0 +1,6 @@
1
+ import type { WorkflowModelParser } from "@webiny/api-workflows/features/model/WorkflowModelParser/index.js";
2
+ export interface ReviewNotificationLink {
3
+ app: string;
4
+ contentId: string;
5
+ }
6
+ export declare const getReviewNotificationLink: (parsed: WorkflowModelParser.Parsed | null, targetId: string) => ReviewNotificationLink | null;
@@ -0,0 +1,15 @@
1
+ import { APP_HEADLESS_CMS } from "../../shared/constants.js";
2
+ const getReviewNotificationLink = (parsed, targetId)=>{
3
+ if (!parsed) return null;
4
+ if (parsed.app === APP_HEADLESS_CMS) return {
5
+ app: parsed.app,
6
+ contentId: `${parsed.modelId}:${targetId}`
7
+ };
8
+ return {
9
+ app: parsed.app,
10
+ contentId: targetId
11
+ };
12
+ };
13
+ export { getReviewNotificationLink };
14
+
15
+ //# sourceMappingURL=getReviewNotificationLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api/workflows/getReviewNotificationLink.js","sources":["../../../src/api/workflows/getReviewNotificationLink.ts"],"sourcesContent":["import type { WorkflowModelParser } from \"@webiny/api-workflows/features/model/WorkflowModelParser/index.js\";\nimport { APP_HEADLESS_CMS } from \"~/shared/constants.js\";\n\nexport interface ReviewNotificationLink {\n app: string;\n contentId: string;\n}\n\n/*\n * A CMS entry link carries \"<modelId>:<entryId>\", which the inbox opens. Any other app gets its app\n * id and the bare target id; the inbox does not open those yet. A model no app knows gets no link.\n */\nexport const getReviewNotificationLink = (\n parsed: WorkflowModelParser.Parsed | null,\n targetId: string\n): ReviewNotificationLink | null => {\n if (!parsed) {\n return null;\n }\n if (parsed.app === APP_HEADLESS_CMS) {\n return { app: parsed.app, contentId: `${parsed.modelId}:${targetId}` };\n }\n return { app: parsed.app, contentId: targetId };\n};\n"],"names":["getReviewNotificationLink","parsed","targetId","APP_HEADLESS_CMS"],"mappings":";AAYO,MAAMA,4BAA4B,CACrCC,QACAC;IAEA,IAAI,CAACD,QACD,OAAO;IAEX,IAAIA,OAAO,GAAG,KAAKE,kBACf,OAAO;QAAE,KAAKF,OAAO,GAAG;QAAE,WAAW,GAAGA,OAAO,OAAO,CAAC,CAAC,EAAEC,UAAU;IAAC;IAEzE,OAAO;QAAE,KAAKD,OAAO,GAAG;QAAE,WAAWC;IAAS;AAClD"}
@@ -0,0 +1,8 @@
1
+ import type { Actor } from "@webiny/api-workflows/domain/review/types.js";
2
+ import type { NotificationIdentity } from "@webiny/notifications/api/domain/notification/abstractions.js";
3
+ /**
4
+ * Who the inbox names as having decided a step. An AI or automation actor carries the requester's
5
+ * id and name (D58), so it is named by the step title instead (D107): the requester did not
6
+ * decide.
7
+ */
8
+ export declare const toNotificationActor: (actor: Actor, stepTitle: string) => NotificationIdentity;
@@ -0,0 +1,15 @@
1
+ const toNotificationActor = (actor, stepTitle)=>{
2
+ if ("user" === actor.type) return {
3
+ id: actor.id,
4
+ displayName: actor.displayName,
5
+ type: actor.identityType ?? "admin"
6
+ };
7
+ return {
8
+ id: actor.id,
9
+ displayName: stepTitle,
10
+ type: actor.type
11
+ };
12
+ };
13
+ export { toNotificationActor };
14
+
15
+ //# sourceMappingURL=toNotificationActor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api/workflows/toNotificationActor.js","sources":["../../../src/api/workflows/toNotificationActor.ts"],"sourcesContent":["import type { Actor } from \"@webiny/api-workflows/domain/review/types.js\";\nimport type { NotificationIdentity } from \"@webiny/notifications/api/domain/notification/abstractions.js\";\n\n/**\n * Who the inbox names as having decided a step. An AI or automation actor carries the requester's\n * id and name (D58), so it is named by the step title instead (D107): the requester did not\n * decide.\n */\nexport const toNotificationActor = (actor: Actor, stepTitle: string): NotificationIdentity => {\n if (actor.type === \"user\") {\n return {\n id: actor.id,\n displayName: actor.displayName,\n type: actor.identityType ?? \"admin\"\n };\n }\n return { id: actor.id, displayName: stepTitle, type: actor.type };\n};\n"],"names":["toNotificationActor","actor","stepTitle"],"mappings":"AAQO,MAAMA,sBAAsB,CAACC,OAAcC;IAC9C,IAAID,AAAe,WAAfA,MAAM,IAAI,EACV,OAAO;QACH,IAAIA,MAAM,EAAE;QACZ,aAAaA,MAAM,WAAW;QAC9B,MAAMA,MAAM,YAAY,IAAI;IAChC;IAEJ,OAAO;QAAE,IAAIA,MAAM,EAAE;QAAE,aAAaC;QAAW,MAAMD,MAAM,IAAI;IAAC;AACpE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/notifications-integrations",
3
- "version": "0.0.0-unstable.7c2def32a7",
3
+ "version": "0.0.0-unstable.a85ef555b2",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -15,18 +15,18 @@
15
15
  },
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "@webiny/api-core": "0.0.0-unstable.7c2def32a7",
19
- "@webiny/api-workflows": "0.0.0-unstable.7c2def32a7",
20
- "@webiny/collaboration": "0.0.0-unstable.7c2def32a7",
21
- "@webiny/feature": "0.0.0-unstable.7c2def32a7",
22
- "@webiny/notifications": "0.0.0-unstable.7c2def32a7",
23
- "@webiny/project-aws": "0.0.0-unstable.7c2def32a7",
18
+ "@webiny/api-workflows": "0.0.0-unstable.a85ef555b2",
19
+ "@webiny/collaboration": "0.0.0-unstable.a85ef555b2",
20
+ "@webiny/feature": "0.0.0-unstable.a85ef555b2",
21
+ "@webiny/notifications": "0.0.0-unstable.a85ef555b2",
22
+ "@webiny/project-aws": "0.0.0-unstable.a85ef555b2",
24
23
  "react": "18.3.1"
25
24
  },
26
25
  "devDependencies": {
27
26
  "@types/react": "18.3.31",
28
- "@webiny/build-tools": "0.0.0-unstable.7c2def32a7",
29
- "typescript": "7.0.2"
27
+ "@webiny/build-tools": "0.0.0-unstable.a85ef555b2",
28
+ "typescript": "7.0.2",
29
+ "vitest": "4.1.11"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"