@webiny/api-apw 0.0.0-unstable.7f63ea0744 → 0.0.0-unstable.8acc9e8892

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 (65) hide show
  1. package/index.d.ts +1 -1
  2. package/package.json +32 -32
  3. package/plugins/graphql/changeRequest.gql.js +2 -2
  4. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  5. package/plugins/graphql/comment.gql.js +2 -2
  6. package/plugins/graphql/comment.gql.js.map +1 -1
  7. package/plugins/graphql/contentReview.gql.js +5 -5
  8. package/plugins/graphql/contentReview.gql.js.map +1 -1
  9. package/plugins/graphql/reviewer.gql.js +2 -2
  10. package/plugins/graphql/reviewer.gql.js.map +1 -1
  11. package/plugins/graphql/workflow.gql.js +2 -2
  12. package/plugins/graphql/workflow.gql.js.map +1 -1
  13. package/plugins/graphql.js +1 -1
  14. package/plugins/graphql.js.map +1 -1
  15. package/plugins/hooks/initializeContentReviewSteps.js +8 -2
  16. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  17. package/plugins/hooks/notifications/changeRequestAfterCreate.js +3 -8
  18. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
  19. package/plugins/hooks/notifications/commentAfterCreate.js +3 -8
  20. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
  21. package/plugins/hooks/notifications/contentReviewAfterCreate.js +3 -8
  22. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
  23. package/plugins/hooks/notifications/reviewers.js +15 -14
  24. package/plugins/hooks/notifications/reviewers.js.map +1 -1
  25. package/scheduler/handlers/executeAction/index.d.ts +1 -1
  26. package/scheduler/handlers/executeAction/index.js +37 -7
  27. package/scheduler/handlers/executeAction/index.js.map +1 -1
  28. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
  29. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +14 -0
  30. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  31. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +2 -3
  32. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +7 -2
  33. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  34. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +2 -2
  35. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +3 -59
  36. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  37. package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
  38. package/scheduler/handlers/scheduleAction/index.js +5 -1
  39. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  40. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -0
  41. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  42. package/scheduler/handlers/utils.d.ts +1 -2
  43. package/scheduler/handlers/utils.js +0 -1
  44. package/scheduler/handlers/utils.js.map +1 -1
  45. package/scheduler/types.d.ts +2 -20
  46. package/scheduler/types.js +0 -5
  47. package/scheduler/types.js.map +1 -1
  48. package/storageOperations/changeRequestStorageOperations.js +20 -20
  49. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  50. package/storageOperations/commentStorageOperations.js +23 -23
  51. package/storageOperations/commentStorageOperations.js.map +1 -1
  52. package/storageOperations/contentReviewStorageOperations.js +20 -20
  53. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  54. package/storageOperations/models/contentModelPluginFactory.d.ts +3 -10
  55. package/storageOperations/models/contentModelPluginFactory.js +3 -6
  56. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  57. package/storageOperations/models/index.js +0 -4
  58. package/storageOperations/models/index.js.map +1 -1
  59. package/storageOperations/reviewerStorageOperations.js +23 -28
  60. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  61. package/storageOperations/workflowStorageOperations.js +20 -20
  62. package/storageOperations/workflowStorageOperations.js.map +1 -1
  63. package/types.d.ts +6 -5
  64. package/types.js.map +1 -1
  65. package/utils/resolve.d.ts +1 -1
@@ -114,14 +114,9 @@ const attachCommentAfterCreate = context => {
114
114
  });
115
115
  }
116
116
  };
117
- try {
118
- context.security.disableAuthorization();
119
- await execute();
120
- } catch (ex) {
121
- throw ex;
122
- } finally {
123
- context.security.enableAuthorization();
124
- }
117
+ await context.security.withoutAuthorization(async () => {
118
+ return execute();
119
+ });
125
120
  });
126
121
  };
127
122
  exports.attachCommentAfterCreate = attachCommentAfterCreate;
@@ -1 +1 @@
1
- {"version":3,"names":["attachCommentAfterCreate","context","apw","comment","onCommentAfterCreate","subscribe","execute","changeRequest","get","WebinyError","id","contentReviewId","stepId","extractContentReviewIdAndStep","step","settings","getAppUrl","commentUrl","createCommentUrl","baseUrl","appUrl","changeRequestId","console","log","contentReview","workflow","workflowId","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","length","sendCommentNotification","ex","commentId","error","message","code","data","stack","security","disableAuthorization","enableAuthorization"],"sources":["commentAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ApwContext } from \"~/types\";\nimport { extractContentReviewIdAndStep } from \"~/plugins/utils\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { createCommentUrl } from \"./commentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendCommentNotification } from \"./sendCommentNotification\";\nimport { getAppUrl } from \"~/plugins/hooks/notifications/appUrl\";\n\nexport const attachCommentAfterCreate = (context: ApwContext): void => {\n context.apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n const execute = async () => {\n const changeRequest = await context.apw.changeRequest.get(comment.changeRequest);\n if (!changeRequest) {\n throw new WebinyError(\"Missing change request.\", \"CHANGE_REQUEST_NOT_FOUND\", {\n changeRequest: comment.changeRequest,\n comment: comment.id\n });\n }\n\n const { id: contentReviewId, stepId } = extractContentReviewIdAndStep(\n changeRequest.step\n );\n if (!stepId) {\n throw new WebinyError(\"Malformed changeRequest.step value.\", \"MALFORMED_VALUE\", {\n step: changeRequest.step\n });\n }\n\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n /**\n * We will check if we can create a comment url before we go digging further into the database.\n */\n const commentUrl = createCommentUrl({\n baseUrl: settings.appUrl,\n changeRequestId: changeRequest.id,\n contentReviewId,\n stepId\n });\n if (!commentUrl) {\n console.log(\"No comment url.\");\n return;\n }\n /**\n * Let's see if content review exists.\n */\n const contentReview = await context.apw.contentReview.get(contentReviewId);\n if (!contentReview) {\n throw new WebinyError(\n `There is no contentReview with id \"${contentReviewId}\".`,\n \"CONTENT_REVIEW_NOT_FOUND\",\n {\n contentReviewId\n }\n );\n }\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with workflowId \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n console.log(\"No content url.\");\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [comment.createdBy.id]\n });\n\n if (reviewers.length === 0) {\n console.log(\"No reviewers to send the e-mail notification to.\");\n return;\n }\n\n try {\n await sendCommentNotification({\n context,\n reviewers,\n changeRequest,\n contentReview,\n workflow,\n commentUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send comment notifications.`,\n \"COMMENT_NOTIFICATIONS_NOT_SENT\",\n {\n commentId: comment.id,\n workflowId: workflow.id,\n changeRequestId: changeRequest.id,\n contentReviewId,\n commentUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n try {\n context.security.disableAuthorization();\n await execute();\n } catch (ex) {\n throw ex;\n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,uCAAsC,EACvC,gCAAgC,EAChC;UACI4B,SAAS,EAAElC,OAAO,CAACO,EAAE;UACrBgB,UAAU,EAAED,QAAQ,CAACf,EAAE;UACvBW,eAAe,EAAEd,aAAa,CAACG,EAAE;UACjCC,eAAe;UACfM,UAAU;UACVU,UAAU;UACVW,KAAK,EAAE;YACHC,OAAO,EAAEH,EAAE,CAACG,OAAO;YACnBC,IAAI,EAAEJ,EAAE,CAACI,IAAI;YACbC,IAAI,EAAEL,EAAE,CAACK,IAAI;YACbC,KAAK,EAAEN,EAAE,CAACM;UACd;QACJ,CAAC,CACJ;MACL;IACJ,CAAC;IAED,IAAI;MACAzC,OAAO,CAAC0C,QAAQ,CAACC,oBAAoB,EAAE;MACvC,MAAMtC,OAAO,EAAE;IACnB,CAAC,CAAC,OAAO8B,EAAE,EAAE;MACT,MAAMA,EAAE;IACZ,CAAC,SAAS;MACNnC,OAAO,CAAC0C,QAAQ,CAACE,mBAAmB,EAAE;IAC1C;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["attachCommentAfterCreate","context","apw","comment","onCommentAfterCreate","subscribe","execute","changeRequest","get","WebinyError","id","contentReviewId","stepId","extractContentReviewIdAndStep","step","settings","getAppUrl","commentUrl","createCommentUrl","baseUrl","appUrl","changeRequestId","console","log","contentReview","workflow","workflowId","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","length","sendCommentNotification","ex","commentId","error","message","code","data","stack","security","withoutAuthorization"],"sources":["commentAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ApwContext } from \"~/types\";\nimport { extractContentReviewIdAndStep } from \"~/plugins/utils\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { createCommentUrl } from \"./commentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendCommentNotification } from \"./sendCommentNotification\";\nimport { getAppUrl } from \"~/plugins/hooks/notifications/appUrl\";\n\nexport const attachCommentAfterCreate = (context: ApwContext): void => {\n context.apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n const execute = async () => {\n const changeRequest = await context.apw.changeRequest.get(comment.changeRequest);\n if (!changeRequest) {\n throw new WebinyError(\"Missing change request.\", \"CHANGE_REQUEST_NOT_FOUND\", {\n changeRequest: comment.changeRequest,\n comment: comment.id\n });\n }\n\n const { id: contentReviewId, stepId } = extractContentReviewIdAndStep(\n changeRequest.step\n );\n if (!stepId) {\n throw new WebinyError(\"Malformed changeRequest.step value.\", \"MALFORMED_VALUE\", {\n step: changeRequest.step\n });\n }\n\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n /**\n * We will check if we can create a comment url before we go digging further into the database.\n */\n const commentUrl = createCommentUrl({\n baseUrl: settings.appUrl,\n changeRequestId: changeRequest.id,\n contentReviewId,\n stepId\n });\n if (!commentUrl) {\n console.log(\"No comment url.\");\n return;\n }\n /**\n * Let's see if content review exists.\n */\n const contentReview = await context.apw.contentReview.get(contentReviewId);\n if (!contentReview) {\n throw new WebinyError(\n `There is no contentReview with id \"${contentReviewId}\".`,\n \"CONTENT_REVIEW_NOT_FOUND\",\n {\n contentReviewId\n }\n );\n }\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with workflowId \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n console.log(\"No content url.\");\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [comment.createdBy.id]\n });\n\n if (reviewers.length === 0) {\n console.log(\"No reviewers to send the e-mail notification to.\");\n return;\n }\n\n try {\n await sendCommentNotification({\n context,\n reviewers,\n changeRequest,\n contentReview,\n workflow,\n commentUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send comment notifications.`,\n \"COMMENT_NOTIFICATIONS_NOT_SENT\",\n {\n commentId: comment.id,\n workflowId: workflow.id,\n changeRequestId: changeRequest.id,\n contentReviewId,\n commentUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n await context.security.withoutAuthorization(async () => {\n return execute();\n });\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMA,wBAAwB,GAAIC,OAAmB,IAAW;EACnEA,OAAO,CAACC,GAAG,CAACC,OAAO,CAACC,oBAAoB,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAQ,CAAC,KAAK;IACtE,MAAMG,OAAO,GAAG,YAAY;MACxB,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAACC,GAAG,CAACK,aAAa,CAACC,GAAG,CAACL,OAAO,CAACI,aAAa,CAAC;MAChF,IAAI,CAACA,aAAa,EAAE;QAChB,MAAM,IAAIE,cAAW,CAAC,yBAAyB,EAAE,0BAA0B,EAAE;UACzEF,aAAa,EAAEJ,OAAO,CAACI,aAAa;UACpCJ,OAAO,EAAEA,OAAO,CAACO;QACrB,CAAC,CAAC;MACN;MAEA,MAAM;QAAEA,EAAE,EAAEC,eAAe;QAAEC;MAAO,CAAC,GAAG,IAAAC,oCAA6B,EACjEN,aAAa,CAACO,IAAI,CACrB;MACD,IAAI,CAACF,MAAM,EAAE;QACT,MAAM,IAAIH,cAAW,CAAC,qCAAqC,EAAE,iBAAiB,EAAE;UAC5EK,IAAI,EAAEP,aAAa,CAACO;QACxB,CAAC,CAAC;MACN;MAEA,MAAMC,QAAQ,GAAG,MAAM,IAAAC,iBAAS,EAACf,OAAO,CAAC;MACzC,IAAI,CAACc,QAAQ,EAAE;QACX;MACJ;MACA;AACZ;AACA;MACY,MAAME,UAAU,GAAG,IAAAC,4BAAgB,EAAC;QAChCC,OAAO,EAAEJ,QAAQ,C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/D;MACJ;MAEA,IAAI;QACA,MAAM,IAAAY,gDAAuB,EAAC;UAC1BlC,OAAO;UACP6B,SAAS;UACTvB,aAAa;UACbiB,aAAa;UACbC,QAAQ;UACRR,UAAU;UACVU;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOS,EAAE,EAAE;QACT,MAAM,IAAI3B,cAAW,CAChB,uCAAsC,EACvC,gCAAgC,EAChC;UACI4B,SAAS,EAAElC,OAAO,CAACO,EAAE;UACrBgB,UAAU,EAAED,QAAQ,CAACf,EAAE;UACvBW,eAAe,EAAEd,aAAa,CAACG,EAAE;UACjCC,eAAe;UACfM,UAAU;UACVU,UAAU;UACVW,KAAK,EAAE;YACHC,OAAO,EAAEH,EAAE,CAACG,OAAO;YACnBC,IAAI,EAAEJ,EAAE,CAACI,IAAI;YACbC,IAAI,EAAEL,EAAE,CAACK,IAAI;YACbC,KAAK,EAAEN,EAAE,CAACM;UACd;QACJ,CAAC,CACJ;MACL;IACJ,CAAC;IAED,MAAMzC,OAAO,CAAC0C,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,OAAOtC,OAAO,EAAE;IACpB,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -86,14 +86,9 @@ const attachContentReviewAfterCreate = context => {
86
86
  });
87
87
  }
88
88
  };
89
- try {
90
- context.security.disableAuthorization();
91
- await execute();
92
- } catch (ex) {
93
- throw ex;
94
- } finally {
95
- context.security.enableAuthorization();
96
- }
89
+ await context.security.withoutAuthorization(async () => {
90
+ return execute();
91
+ });
97
92
  });
98
93
  };
99
94
  exports.attachContentReviewAfterCreate = attachContentReviewAfterCreate;
@@ -1 +1 @@
1
- {"version":3,"names":["attachContentReviewAfterCreate","context","apw","contentReview","onContentReviewAfterCreate","subscribe","execute","steps","length","step","id","settings","getAppUrl","contentReviewUrl","createContentReviewUrl","baseUrl","appUrl","contentReviewId","stepId","workflow","get","workflowId","WebinyError","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","sendContentReviewNotification","ex","error","message","code","data","stack","security","disableAuthorization","enableAuthorization"],"sources":["contentReviewAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ApwContext } from \"~/types\";\nimport { getAppUrl } from \"./appUrl\";\nimport { createContentReviewUrl } from \"./contentReviewUrl\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendContentReviewNotification } from \"./sendContentReviewNotification\";\n\nexport const attachContentReviewAfterCreate = (context: ApwContext): void => {\n context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({ contentReview }) => {\n const execute = async () => {\n if (contentReview.steps.length === 0) {\n return;\n }\n const [step] = contentReview.steps;\n if (!step?.id) {\n return;\n }\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n\n const contentReviewUrl = createContentReviewUrl({\n baseUrl: settings.appUrl,\n contentReviewId: contentReview.id,\n stepId: step.id\n });\n if (!contentReviewUrl) {\n return;\n }\n\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with Id \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [contentReview.createdBy.id]\n });\n if (reviewers.length === 0) {\n return;\n }\n\n try {\n await sendContentReviewNotification({\n context,\n reviewers,\n contentReview,\n workflow,\n contentReviewUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send content review notifications.`,\n \"CONTENT_REVIEW_NOTIFICATIONS_NOT_SENT\",\n {\n workflowId: workflow.id,\n contentReviewId: contentReview.id,\n contentReviewUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n try {\n context.security.disableAuthorization();\n await execute();\n } catch (ex) {\n throw ex;\n } finally {\n context.security.enableAuthorization();\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AAEO,MAAMA,8BAA8B,GAAIC,OAAmB,IAAW;EACzEA,OAAO,CAACC,GAAG,CAACC,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IACxF,MAAMG,OAAO,GAAG,YAAY;MACxB,IAAIH,aAAa,CAACI,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;QAClC;MACJ;MACA,MAAM,CAACC,IAAI,CAAC,GAAGN,aAAa,CAACI,KAAK;MAClC,IAAI,EAACE,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEC,EAAE,GAAE;QACX;MACJ;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAAC,iBAAS,EAACX,OAAO,CAAC;MACzC,IAAI,CAACU,QAAQ,EAAE;QACX;MACJ;MAEA,MAAME,gBAAgB,GAAG,IAAAC,wCAAsB,EAAC;QAC5CC,OAAO,EAAEJ,QAAQ,CAACK,MAAM;QACxBC,eAAe,EAAEd,aAAa,CAACO,EAAE;QACjCQ,MAAM,EAAET,IAAI,CAACC;MACjB,CAAC,CAAC;MACF,IAAI,CAACG,gBAAgB,EAAE;QACnB;MACJ;;MAEA;AACZ;AACA;MACY,MAAMM,QAAQ,GAAG,MAAMlB,OAAO,CAACC,GAAG,CAACiB,QAAQ,CAACC,GAAG,CAACjB,aAAa,CAACkB,UAAU,CAAC;MACzE,IAAI,CAACF,QAAQ,EAAE;QACX,MAAM,IAAIG,cAAW,CAChB,iCAAgCnB,aAAa,CAACkB,UAAW,IAAG,EAC7D,oBAAoB,EACpB;UACIA,UAAU,EAAElB,aAAa,CAACkB;QAC9B,CAAC,CACJ;MACL;MAEA,MAAME,UAAU,GAAG,IAAA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w","contentReview","onContentReviewAfterCreate","subscribe","execute","steps","length","step","id","settings","getAppUrl","contentReviewUrl","createContentReviewUrl","baseUrl","appUrl","contentReviewId","stepId","workflow","get","workflowId","WebinyError","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","sendContentReviewNotification","ex","error","message","code","data","stack","security","withoutAuthorization"],"sources":["contentReviewAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ApwContext } from \"~/types\";\nimport { getAppUrl } from \"./appUrl\";\nimport { createContentReviewUrl } from \"./contentReviewUrl\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendContentReviewNotification } from \"./sendContentReviewNotification\";\n\nexport const attachContentReviewAfterCreate = (context: ApwContext): void => {\n context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({ contentReview }) => {\n const execute = async () => {\n if (contentReview.steps.length === 0) {\n return;\n }\n const [step] = contentReview.steps;\n if (!step?.id) {\n return;\n }\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n\n const contentReviewUrl = createContentReviewUrl({\n baseUrl: settings.appUrl,\n contentReviewId: contentReview.id,\n stepId: step.id\n });\n if (!contentReviewUrl) {\n return;\n }\n\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with Id \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [contentReview.createdBy.id]\n });\n if (reviewers.length === 0) {\n return;\n }\n\n try {\n await sendContentReviewNotification({\n context,\n reviewers,\n contentReview,\n workflow,\n contentReviewUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send content review notifications.`,\n \"CONTENT_REVIEW_NOTIFICATIONS_NOT_SENT\",\n {\n workflowId: workflow.id,\n contentReviewId: contentReview.id,\n contentReviewUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n await context.security.withoutAuthorization(async () => {\n return execute();\n });\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AAEO,MAAMA,8BAA8B,GAAIC,OAAmB,IAAW;EACzEA,OAAO,CAACC,GAAG,CAACC,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IACxF,MAAMG,OAAO,GAAG,YAAY;MACxB,IAAIH,aAAa,CAACI,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;QAClC;MACJ;MACA,MAAM,CAACC,IAAI,CAAC,GAAGN,aAAa,CAACI,KAAK;MAClC,IAAI,EAACE,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEC,EAAE,GAAE;QACX;MACJ;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAAC,iBAAS,EAACX,OAAO,CAAC;MACzC,IAAI,CAACU,QAAQ,EAAE;QACX;MACJ;MAEA,MAAME,gBAAgB,GAAG,IAAAC,wCAAsB,EAAC;QAC5CC,OAAO,EAAEJ,QAAQ,CAACK,MAAM;QACxBC,eAAe,EAAEd,aAAa,CAACO,EAAE;QACjCQ,MAAM,EAAET,IAAI,CAACC;MACjB,CAAC,CAAC;MACF,IAAI,CAACG,gBAAgB,EAAE;QACnB;MACJ;;MAEA;AACZ;AACA;MACY,MAAMM,QAAQ,GAAG,MAAMlB,OAAO,CAACC,GAAG,CAACiB,QAAQ,CAACC,GAAG,CAACjB,aAAa,CAACkB,UAAU,CAAC;MACzE,IAAI,CAACF,QAAQ,EAAE;QACX,MAAM,IAAIG,cAAW,CAChB,iCAAgCnB,aAAa,CAACkB,UAAW,IAAG,E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clude
26
26
  } = params;
27
27
  const idList = getReviewerIdList(workflow);
28
- context.security.disableAuthorization();
29
- const [reviewers] = await context.apw.reviewer.list({
30
- where: {
31
- id_in: idList
32
- },
33
- limit: 10000
34
- });
35
- return reviewers.filter(item => {
36
- if (!item.email) {
37
- return false;
38
- } else if (exclude.includes(item.identityId)) {
39
- return false;
40
- }
41
- return true;
28
+ return context.security.withoutAuthorization(async () => {
29
+ const [reviewers] = await context.apw.reviewer.list({
30
+ where: {
31
+ id_in: idList
32
+ },
33
+ limit: 10000
34
+ });
35
+ return reviewers.filter(item => {
36
+ if (!item.email) {
37
+ return false;
38
+ } else if (exclude.includes(item.identityId)) {
39
+ return false;
40
+ }
41
+ return true;
42
+ });
42
43
  });
43
44
  };
44
45
  exports.fetchReviewers = fetchReviewers;
@@ -1 +1 @@
1
- {"version":3,"names":["getReviewerIdList","steps","reduce","collection","step","reviewer","reviewers","includes","id","push","fetchReviewers","params","context","workflow","exclude","idList","security","disableAuthorization","apw","list","where","id_in","limit","filter","item","email","identityId"],"sources":["reviewers.ts"],"sourcesContent":["import { ApwContext, ApwReviewerWithEmail, ApwWorkflow, ApwWorkflowStep } from \"~/types\";\n\ninterface GetReviewerIdListParams {\n steps: ApwWorkflowStep[];\n}\ninterface GetReviewerIdList {\n (params: GetReviewerIdListParams): string[];\n}\nexport const getReviewerIdList: GetReviewerIdList = ({ steps }) => {\n return steps.reduce<string[]>((collection, step) => {\n for (const reviewer of step.reviewers) {\n if (collection.includes(reviewer.id)) {\n return collection;\n }\n collection.push(reviewer.id);\n }\n\n return collection;\n }, []);\n};\n\ninterface FetchReviewersParams {\n context: ApwContext;\n workflow: ApwWorkflow;\n exclude: string[];\n}\nexport const fetchReviewers = async (\n params: FetchReviewersParams\n): Promise<ApwReviewerWithEmail[]> => {\n const { context, workflow, exclude } = params;\n\n const idList = getReviewerIdList(workflow);\n\n context.security.disableAuthorization();\n\n const [reviewers] = await context.apw.reviewer.list({\n where: {\n id_in: idList\n },\n limit: 10000\n });\n return reviewers.filter(item => {\n if (!item.email) {\n return false;\n } else if (exclude.includes(item.identityId)) {\n return false;\n }\n\n return true;\n }) as ApwReviewerWithEmail[];\n};\n"],"mappings":";;;;;;AAQO,MAAMA,iBAAoC,GAAG,CAAC;EAAEC;AAAM,CAAC,KAAK;EAC/D,OAAOA,KAAK,CAACC,MAAM,CAAW,CAACC,UAAU,EAAEC,IAAI,KAAK;IAChD,KAAK,MAAMC,QAAQ,IAAID,IAAI,CAACE,SAAS,EAAE;MACnC,IAAIH,UAAU,CAACI,QAAQ,CAACF,QAAQ,CAACG,EAAE,CAAC,EAAE;QAClC,OAAOL,UAAU;MACrB;MACAA,UAAU,CAACM,IAAI,CAACJ,QAAQ,CAACG,EAAE,CAAC;IAChC;IAEA,OAAOL,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;AACV,CAAC;AAAC;AAOK,MAAMO,cAAc,GAAG,MAC1BC,MAA4B,IACM;EAClC,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE7C,MAAMI,MAAM,GAAGf,iBAAiB,CAACa,QAAQ,CAAC;EAE1CD,OAAO,CAACI,QAAQ,CAACC,oBAAoB,EAAE;EAEvC,MAAM,CAACX,SAAS,CAAC,GAAG,MAAMM,OAAO,CAACM,GAAG,CAACb,QAAQ,CAACc,IAAI,CAAC;IAChDC,KAAK,EAAE;MACHC,KAAK,EAAEN;IACX,CAAC;IACDO,KAAK,EAAE;EACX,CAAC,CAAC;EACF,OAAOhB,SAAS,CAACiB,MAAM,CAACC,IAAI,IAAI;IAC5B,IAAI,CAACA,IAAI,CAACC,KAAK,EAAE;MACb,OAAO,KAAK;IAChB,CAAC,MAAM,IAAIX,OAAO,CAACP,QAAQ,CAACiB,IAAI,CAACE,UAAU,CAAC,EAAE;MAC1C,OAAO,KAAK;IAChB;IAEA,OAAO,IAAI;EACf,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["getReviewerIdList","steps","reduce","collection","step","reviewer","reviewers","includes","id","push","fetchReviewers","params","context","workflow","exclude","idList","security","withoutAuthorization","apw","list","where","id_in","limit","filter","item","email","identityId"],"sources":["reviewers.ts"],"sourcesContent":["import { ApwContext, ApwReviewerWithEmail, ApwWorkflow, ApwWorkflowStep } from \"~/types\";\n\ninterface GetReviewerIdListParams {\n steps: ApwWorkflowStep[];\n}\n\ninterface GetReviewerIdList {\n (params: GetReviewerIdListParams): string[];\n}\n\nexport const getReviewerIdList: GetReviewerIdList = ({ steps }) => {\n return steps.reduce<string[]>((collection, step) => {\n for (const reviewer of step.reviewers) {\n if (collection.includes(reviewer.id)) {\n return collection;\n }\n collection.push(reviewer.id);\n }\n\n return collection;\n }, []);\n};\n\ninterface FetchReviewersParams {\n context: ApwContext;\n workflow: ApwWorkflow;\n exclude: string[];\n}\n\nexport const fetchReviewers = async (\n params: FetchReviewersParams\n): Promise<ApwReviewerWithEmail[]> => {\n const { context, workflow, exclude } = params;\n\n const idList = getReviewerIdList(workflow);\n\n return context.security.withoutAuthorization(async () => {\n const [reviewers] = await context.apw.reviewer.list({\n where: {\n id_in: idList\n },\n limit: 10000\n });\n return reviewers.filter((item): item is ApwReviewerWithEmail => {\n if (!item.email) {\n return false;\n } else if (exclude.includes(item.identityId)) {\n return false;\n }\n\n return true;\n });\n });\n};\n"],"mappings":";;;;;;AAUO,MAAMA,iBAAoC,GAAG,CAAC;EAAEC;AAAM,CAAC,KAAK;EAC/D,OAAOA,KAAK,CAACC,MAAM,CAAW,CAACC,UAAU,EAAEC,IAAI,KAAK;IAChD,KAAK,MAAMC,QAAQ,IAAID,IAAI,CAACE,SAAS,EAAE;MACnC,IAAIH,UAAU,CAACI,QAAQ,CAACF,QAAQ,CAACG,EAAE,CAAC,EAAE;QAClC,OAAOL,UAAU;MACrB;MACAA,UAAU,CAACM,IAAI,CAACJ,QAAQ,CAACG,EAAE,CAAC;IAChC;IAEA,OAAOL,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;AACV,CAAC;AAAC;AAQK,MAAMO,cAAc,GAAG,MAC1BC,MAA4B,IACM;EAClC,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE7C,MAAMI,MAAM,GAAGf,iBAAiB,CAACa,QAAQ,CAAC;EAE1C,OAAOD,OAAO,CAACI,QAAQ,CAACC,oBAAoB,CAAC,YAAY;IACrD,MAAM,CAACX,SAAS,CAAC,GAAG,MAAMM,OAAO,CAACM,GAAG,CAACb,QAAQ,CAACc,IAAI,CAAC;MAChDC,KAAK,EAAE;QACHC,KAAK,EAAEN;MACX,CAAC;MACDO,KAAK,EAAE;IACX,CAAC,CAAC;IACF,OAAOhB,SAAS,CAACiB,MAAM,CAAEC,IAAI,IAAmC;MAC5D,IAAI,CAACA,IAAI,CAACC,KAAK,EAAE;QACb,OAAO,KAAK;MAChB,CAAC,MAAM,IAAIX,OAAO,CAACP,QAAQ,CAACiB,IAAI,CAACE,UAAU,CAAC,EAAE;QAC1C,OAAO,KAAK;MAChB;MAEA,OAAO,IAAI;IACf,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -9,5 +9,5 @@ export interface HandlerArgs {
9
9
  interface Configuration {
10
10
  storageOperations: ApwScheduleActionStorageOperations;
11
11
  }
12
- export declare const executeActionHandlerPlugins: (config: Configuration) => ((import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler").EventPlugin<HandlerArgs, import("@webiny/handler/types").Context, any> | ContextPlugin<import("@webiny/api/types").Context>)[];
12
+ export declare const executeActionHandlerPlugins: (config: Configuration) => ((import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler-aws").RawEventHandler<HandlerArgs, import("@webiny/handler/types").Context, any> | ContextPlugin<import("@webiny/api/types").Context>)[];
13
13
  export {};
@@ -9,7 +9,7 @@ var _api = require("@webiny/api");
9
9
  var _PageBuilderGraphQL = require("./plugins/PageBuilderGraphQL");
10
10
  var _HeadlessCMSGraphQL = require("./plugins/HeadlessCMSGraphQL");
11
11
  var _ApplicationGraphQL = require("./plugins/ApplicationGraphQL");
12
- var _handler = require("@webiny/handler");
12
+ var _handlerAws = require("@webiny/handler-aws");
13
13
  /**
14
14
  * Handler that execute the provided action(s) for the schedule action workflow.
15
15
  */
@@ -17,7 +17,7 @@ const createExecuteActionLambda = params => {
17
17
  const {
18
18
  storageOperations
19
19
  } = params;
20
- return (0, _handler.createEvent)(async ({
20
+ return (0, _handlerAws.createRawEventHandler)(async ({
21
21
  payload,
22
22
  context
23
23
  }) => {
@@ -96,19 +96,28 @@ const createExecuteActionLambda = params => {
96
96
  }));
97
97
  continue;
98
98
  }
99
+ const url = plugin.getUrl({
100
+ locale,
101
+ tenant
102
+ });
103
+ if (!url) {
104
+ console.error(`There is no url defined, in the Plugin, for type "${item.data.type}".`);
105
+ console.log(JSON.stringify(item));
106
+ continue;
107
+ }
99
108
  const body = plugin.getGraphQLBody(item.data);
100
109
  if (!body) {
101
110
  console.error(`There is no GraphQL body defined, in the Plugin, for type "${item.data.type}".`);
102
111
  console.log(JSON.stringify(item));
103
112
  continue;
104
113
  }
105
-
114
+ console.log(`Invoking Lambda "${name}" with url "${url}".`);
106
115
  // Perform the actual action call.
107
116
  const response = await context.handlerClient.invoke({
108
117
  name,
109
118
  payload: {
110
119
  httpMethod: "POST",
111
- path: `/cms/manage/${locale}`,
120
+ path: url,
112
121
  headers: {
113
122
  ["content-type"]: "application/json",
114
123
  Authorization: (0, _utils.encodeToken)({
@@ -123,9 +132,26 @@ const createExecuteActionLambda = params => {
123
132
  },
124
133
  await: true
125
134
  });
135
+ /**
136
+ *
137
+ */
138
+ await storageOperations.delete({
139
+ locale,
140
+ tenant,
141
+ id: item.id
142
+ });
143
+ /**
144
+ * Check for the response and log the error if any.
145
+ */
126
146
  if (response !== null && response !== void 0 && response.body) {
147
+ var _response$body$data, _response$body$data$c;
148
+ const error = (_response$body$data = response.body.data) === null || _response$body$data === void 0 ? void 0 : (_response$body$data$c = _response$body$data.content) === null || _response$body$data$c === void 0 ? void 0 : _response$body$data$c.error;
149
+ if (!error) {
150
+ console.log("Invoke successful.");
151
+ continue;
152
+ }
127
153
  console.log(JSON.stringify({
128
- body: response.body
154
+ error
129
155
  }, null, 2));
130
156
  continue;
131
157
  }
@@ -135,8 +161,12 @@ const createExecuteActionLambda = params => {
135
161
 
136
162
  // TODO: Maybe update the status like error in original item in DB.
137
163
  }
138
- } catch (e) {
139
- log("[HANDLER_EXECUTE_ACTION] Error => ", e);
164
+ } catch (ex) {
165
+ console.error("[HANDLER_EXECUTE_ACTION] => ", JSON.stringify({
166
+ message: ex.message,
167
+ code: ex.code,
168
+ data: ex.data
169
+ }));
140
170
  // TODO: Maybe update the status like error in original item in DB.
141
171
  }
142
172
  });
@@ -1 +1 @@
1
- {"version":3,"names":["createExecuteActionLambda","params","storageOperations","createEvent","payload","context","log","console","applicationGraphQLPlugins","plugins","byType","ApplicationGraphQL","type","length","error","applicationGraphQLPluginCache","getApplicationGraphQLPlugin","data","plugin","canUse","apwSettings","getApwSettings","futureDatetime","datetime","locale","tenant","items","list","where","datetime_startsWith","getIsoStringTillMinutes","sort","limit","item","action","JSON","stringify","name","getArn","settings","body","getGraphQLBody","response","handlerClient","invoke","httpMethod","path","headers","Authorization","encodeToken","id","await","e","executeActionHandlerPlugins","config","ContextPlugin","register","PageBuilderGraphQL","HeadlessCMSGraphQL","basePlugins"],"sources":["index.ts"],"sourcesContent":["import { ApwScheduleActionData, ApwScheduleActionStorageOperations } from \"~/scheduler/types\";\nimport { getIsoStringTillMinutes, encodeToken, basePlugins } from \"~/scheduler/handlers/utils\";\nimport { getApwSettings } from \"~/scheduler/handlers/utils\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { PageBuilderGraphQL } from \"./plugins/PageBuilderGraphQL\";\nimport { HeadlessCMSGraphQL } from \"./plugins/HeadlessCMSGraphQL\";\nimport { ApplicationGraphQL } from \"./plugins/ApplicationGraphQL\";\nimport { createEvent } from \"@webiny/handler\";\n\nexport interface HandlerArgs {\n datetime: string;\n tenant: string;\n locale: string;\n futureDatetime?: string;\n}\n\ninterface Configuration {\n storageOperations: ApwScheduleActionStorageOperations;\n}\n\n/**\n * Handler that execute the provided action(s) for the schedule action workflow.\n */\nconst createExecuteActionLambda = (params: Configuration) => {\n const { storageOperations } = params;\n\n return createEvent<HandlerArgs>(async ({ payload, context }) => {\n const log = console.log;\n\n const applicationGraphQLPlugins = context.plugins.byType<ApplicationGraphQL>(\n ApplicationGraphQL.type\n );\n\n if (applicationGraphQLPlugins.length === 0) {\n console.error(`There are no plugins to determine GraphQL endpoints or mutations.`);\n return;\n }\n\n const applicationGraphQLPluginCache: Record<string, ApplicationGraphQL> = {};\n\n const getApplicationGraphQLPlugin = (\n data: ApwScheduleActionData\n ): ApplicationGraphQL | null => {\n const { type } = data;\n if (applicationGraphQLPluginCache[type]) {\n return applicationGraphQLPluginCache[type];\n }\n for (const plugin of applicationGraphQLPlugins) {\n if (!plugin.canUse(data)) {\n continue;\n }\n applicationGraphQLPluginCache[type] = plugin;\n return plugin;\n }\n return null;\n };\n\n try {\n const apwSettings = await getApwSettings();\n\n const { futureDatetime: datetime, locale, tenant } = payload;\n /**\n * If there is no datetime we bail out early.\n */\n if (!datetime || typeof datetime !== \"string\") {\n log(`Bailing out!!`);\n return;\n }\n\n /**\n * Get tasks from the DB by datetime.\n */\n const [items] = await storageOperations.list({\n where: {\n tenant,\n locale,\n datetime_startsWith: getIsoStringTillMinutes(datetime)\n },\n sort: [\"datetime_ASC\"],\n limit: 1000\n });\n\n /**\n * Execute all actions.\n */\n if (!items || items.length === 0) {\n return;\n }\n log(`Found ${items.length} actions.`);\n for (const item of items) {\n log(\n `Performing mutation \"${item.data.action}\" on \"${item.data.type}\" at \"${item.data.datetime}\"`\n );\n\n const plugin = getApplicationGraphQLPlugin(item.data);\n if (!plugin) {\n console.error(\n `There is no plugin to determine GraphQL endpoint and mutations for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n const name = plugin.getArn(apwSettings);\n if (!name) {\n console.error(`There is no FunctionName found for type \"${item.data.type}\".`);\n console.log(\n JSON.stringify({\n item,\n settings: apwSettings\n })\n );\n continue;\n }\n\n const body = plugin.getGraphQLBody(item.data);\n\n if (!body) {\n console.error(\n `There is no GraphQL body defined, in the Plugin, for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n // Perform the actual action call.\n const response = await context.handlerClient.invoke({\n name,\n payload: {\n httpMethod: \"POST\",\n path: `/cms/manage/${locale}`,\n headers: {\n [\"content-type\"]: \"application/json\",\n Authorization: encodeToken({\n id: item.id,\n locale: item.locale,\n tenant: item.tenant\n }),\n [\"x-tenant\"]: tenant,\n [\"x-i18n-locale\"]: `default:${locale};content:${locale};`\n },\n body: JSON.stringify(body)\n },\n await: true\n });\n if (response?.body) {\n console.log(JSON.stringify({ body: response.body }, null, 2));\n continue;\n }\n console.log(JSON.stringify({ response }, null, 2));\n\n // TODO: Maybe update the status like error in original item in DB.\n }\n } catch (e) {\n log(\"[HANDLER_EXECUTE_ACTION] Error => \", e);\n // TODO: Maybe update the status like error in original item in DB.\n }\n });\n};\n\nexport const executeActionHandlerPlugins = (config: Configuration) => [\n new ContextPlugin(async context => {\n context.plugins.register([new PageBuilderGraphQL(), new HeadlessCMSGraphQL()]);\n }),\n basePlugins(),\n createExecuteActionLambda(config)\n];\n"],"mappings":";;;;;;AACA;AAEA;AACA;AACA;AACA;AACA;AAaA;AACA;AACA;AACA,MAAMA,yBAAyB,GAAIC,MAAqB,IAAK;EACzD,MAAM;IAAEC;EAAk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EAC/BA,OAAO,CAACI,OAAO,CAAC+C,QAAQ,CAAC,CAAC,IAAIC,sCAAkB,EAAE,EAAE,IAAIC,sCAAkB,EAAE,CAAC,CAAC;AAClF,CAAC,CAAC,EACF,IAAAC,kBAAW,GAAE,EACb3D,yBAAyB,CAACsD,MAAM,CAAC,CACpC;AAAC"}
1
+ {"version":3,"names":["createExecuteActionLambda","params","storageOperations","createRawEventHandler","payload","context","log","console","applicationGraphQLPlugins","plugins","byType","ApplicationGraphQL","type","length","error","applicationGraphQLPluginCache","getApplicationGraphQLPlugin","data","plugin","canUse","apwSettings","getApwSettings","futureDatetime","datetime","locale","tenant","items","list","where","datetime_startsWith","getIsoStringTillMinutes","sort","limit","item","action","JSON","stringify","name","getArn","settings","url","getUrl","body","getGraphQLBody","response","handlerClient","invoke","httpMethod","path","headers","Authorization","encodeToken","id","await","delete","content","ex","message","code","executeActionHandlerPlugins","config","ContextPlugin","register","PageBuilderGraphQL","HeadlessCMSGraphQL","basePlugins"],"sources":["index.ts"],"sourcesContent":["import { ApwScheduleActionData, ApwScheduleActionStorageOperations } from \"~/scheduler/types\";\nimport { getIsoStringTillMinutes, encodeToken, basePlugins } from \"~/scheduler/handlers/utils\";\nimport { getApwSettings } from \"~/scheduler/handlers/utils\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { PageBuilderGraphQL } from \"./plugins/PageBuilderGraphQL\";\nimport { HeadlessCMSGraphQL } from \"./plugins/HeadlessCMSGraphQL\";\nimport { ApplicationGraphQL } from \"./plugins/ApplicationGraphQL\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\n\nexport interface HandlerArgs {\n datetime: string;\n tenant: string;\n locale: string;\n futureDatetime?: string;\n}\n\ninterface Configuration {\n storageOperations: ApwScheduleActionStorageOperations;\n}\n\n/**\n * Handler that execute the provided action(s) for the schedule action workflow.\n */\nconst createExecuteActionLambda = (params: Configuration) => {\n const { storageOperations } = params;\n\n return createRawEventHandler<HandlerArgs>(async ({ payload, context }) => {\n const log = console.log;\n\n const applicationGraphQLPlugins = context.plugins.byType<ApplicationGraphQL>(\n ApplicationGraphQL.type\n );\n\n if (applicationGraphQLPlugins.length === 0) {\n console.error(`There are no plugins to determine GraphQL endpoints or mutations.`);\n return;\n }\n\n const applicationGraphQLPluginCache: Record<string, ApplicationGraphQL> = {};\n\n const getApplicationGraphQLPlugin = (\n data: ApwScheduleActionData\n ): ApplicationGraphQL | null => {\n const { type } = data;\n if (applicationGraphQLPluginCache[type]) {\n return applicationGraphQLPluginCache[type];\n }\n for (const plugin of applicationGraphQLPlugins) {\n if (!plugin.canUse(data)) {\n continue;\n }\n applicationGraphQLPluginCache[type] = plugin;\n return plugin;\n }\n return null;\n };\n\n try {\n const apwSettings = await getApwSettings();\n\n const { futureDatetime: datetime, locale, tenant } = payload;\n /**\n * If there is no datetime we bail out early.\n */\n if (!datetime || typeof datetime !== \"string\") {\n log(`Bailing out!!`);\n return;\n }\n\n /**\n * Get tasks from the DB by datetime.\n */\n const [items] = await storageOperations.list({\n where: {\n tenant,\n locale,\n datetime_startsWith: getIsoStringTillMinutes(datetime)\n },\n sort: [\"datetime_ASC\"],\n limit: 1000\n });\n\n /**\n * Execute all actions.\n */\n if (!items || items.length === 0) {\n return;\n }\n log(`Found ${items.length} actions.`);\n for (const item of items) {\n log(\n `Performing mutation \"${item.data.action}\" on \"${item.data.type}\" at \"${item.data.datetime}\"`\n );\n\n const plugin = getApplicationGraphQLPlugin(item.data);\n if (!plugin) {\n console.error(\n `There is no plugin to determine GraphQL endpoint and mutations for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n const name = plugin.getArn(apwSettings);\n if (!name) {\n console.error(`There is no FunctionName found for type \"${item.data.type}\".`);\n console.log(\n JSON.stringify({\n item,\n settings: apwSettings\n })\n );\n continue;\n }\n\n const url = plugin.getUrl({\n locale,\n tenant\n });\n if (!url) {\n console.error(\n `There is no url defined, in the Plugin, for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n const body = plugin.getGraphQLBody(item.data);\n\n if (!body) {\n console.error(\n `There is no GraphQL body defined, in the Plugin, for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n console.log(`Invoking Lambda \"${name}\" with url \"${url}\".`);\n // Perform the actual action call.\n const response = await context.handlerClient.invoke({\n name,\n payload: {\n httpMethod: \"POST\",\n path: url,\n headers: {\n [\"content-type\"]: \"application/json\",\n Authorization: encodeToken({\n id: item.id,\n locale: item.locale,\n tenant: item.tenant\n }),\n [\"x-tenant\"]: tenant,\n [\"x-i18n-locale\"]: `default:${locale};content:${locale};`\n },\n body: JSON.stringify(body)\n },\n await: true\n });\n /**\n *\n */\n await storageOperations.delete({\n locale,\n tenant,\n id: item.id\n });\n /**\n * Check for the response and log the error if any.\n */\n if (response?.body) {\n const error = response.body.data?.content?.error;\n if (!error) {\n console.log(\"Invoke successful.\");\n continue;\n }\n console.log(JSON.stringify({ error }, null, 2));\n continue;\n }\n console.log(JSON.stringify({ response }, null, 2));\n\n // TODO: Maybe update the status like error in original item in DB.\n }\n } catch (ex) {\n console.error(\n \"[HANDLER_EXECUTE_ACTION] => \",\n JSON.stringify({\n message: ex.message,\n code: ex.code,\n data: ex.data\n })\n );\n // TODO: Maybe update the status like error in original item in DB.\n }\n });\n};\n\nexport const executeActionHandlerPlugins = (config: Configuration) => [\n new ContextPlugin(async context => {\n context.plugins.register([new PageBuilderGraphQL(), new HeadlessCMSGraphQL()]);\n }),\n basePlugins(),\n createExecuteActionLambda(config)\n];\n"],"mappings":";;;;;;AACA;AAEA;AACA;AACA;AACA;AACA;AAaA;AACA;AACA;AACA,MAAMA,yBAAyB,GAAIC,MAAqB,IAAK;EACzD,MAAM;IAAEC;EAAkB,CAAC,GAAGD,MAAM;EAEpC,OAAO,IAAAE,iCAAqB,EAAc,OAAO;IAAEC,OAAO;IAAEC;EAAQ,CAAC,KAAK;IACtE,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAAG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AAK,EAAE;YACRP,OAAO,CAACD,GAAG,CAAC,oBAAoB,CAAC;YACjC;UACJ;UACAC,OAAO,CAACD,GAAG,CAAC6B,IAAI,CAACC,SAAS,CAAC;YAAEtB;UAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;UAC/C;QACJ;QACAP,OAAO,CAACD,GAAG,CAAC6B,IAAI,CAACC,SAAS,CAAC;UAAEQ;QAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;;QAElD;MACJ;IACJ,CAAC,CAAC,OAAOY,EAAE,EAAE;MACTjD,OAAO,CAACO,KAAK,CACT,8BAA8B,EAC9BqB,IAAI,CAACC,SAAS,CAAC;QACXqB,OAAO,EAAED,EAAE,CAACC,OAAO;QACnBC,IAAI,EAAEF,EAAE,CAACE,IAAI;QACbzC,IAAI,EAAEuC,EAAE,CAACvC;MACb,CAAC,CAAC,CACL;MACD;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;;AAEM,MAAM0C,2BAA2B,GAAIC,MAAqB,IAAK,CAClE,IAAIC,kBAAa,CAAC,MAAMxD,OAAO,IAAI;EAC/BA,OAAO,CAACI,OAAO,CAACqD,QAAQ,CAAC,CAAC,IAAIC,sCAAkB,EAAE,EAAE,IAAIC,sCAAkB,EAAE,CAAC,CAAC;AAClF,CAAC,CAAC,EACF,IAAAC,kBAAW,GAAE,EACbjE,yBAAyB,CAAC4D,MAAM,CAAC,CACpC;AAAC"}
@@ -1,12 +1,18 @@
1
1
  import { Plugin } from "@webiny/plugins/Plugin";
2
2
  import { ApwScheduleActionData } from "../../../types";
3
3
  import { ApwSettings } from "../../utils";
4
+ export { ApwScheduleActionData, ApwSettings };
5
+ export interface ApplicationGraphQLGetUrlParams {
6
+ tenant: string;
7
+ locale: string;
8
+ }
4
9
  export interface ApplicationGraphQLBody<T = Record<string, any>> {
5
10
  query: string;
6
11
  variables: T;
7
12
  }
8
13
  export declare abstract class ApplicationGraphQL extends Plugin {
9
14
  static readonly type: string;
15
+ abstract getUrl(params: ApplicationGraphQLGetUrlParams): string;
10
16
  abstract canUse(data: ApwScheduleActionData): boolean;
11
17
  abstract getArn(settings: ApwSettings): string;
12
18
  abstract getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null;
@@ -5,8 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.ApplicationGraphQL = void 0;
8
+ Object.defineProperty(exports, "ApwScheduleActionData", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return _types.ApwScheduleActionData;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "ApwSettings", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _utils.ApwSettings;
18
+ }
19
+ });
8
20
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
21
  var _Plugin = require("@webiny/plugins/Plugin");
22
+ var _types = require("../../../types");
23
+ var _utils = require("../../utils");
10
24
  class ApplicationGraphQL extends _Plugin.Plugin {}
11
25
  exports.ApplicationGraphQL = ApplicationGraphQL;
12
26
  (0, _defineProperty2.default)(ApplicationGraphQL, "type", "apw.scheduler.applicationGraphQL");
@@ -1 +1 @@
1
- {"version":3,"names":["ApplicationGraphQL","Plugin"],"sources":["ApplicationGraphQL.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { ApwScheduleActionData } from \"~/scheduler/types\";\nimport { ApwSettings } from \"~/scheduler/handlers/utils\";\n\nexport interface ApplicationGraphQLBody<T = Record<string, any>> {\n query: string;\n variables: T;\n}\n\nexport abstract class ApplicationGraphQL extends Plugin {\n public static override readonly type: string = \"apw.scheduler.applicationGraphQL\";\n\n public abstract canUse(data: ApwScheduleActionData): boolean;\n\n public abstract getArn(settings: ApwSettings): string;\n\n public abstract getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null;\n}\n"],"mappings":";;;;;;;;AAAA;AASO,MAAeA,kBAAkB,SAASC,cAAM,CAAC;AAQvD;AAAA,8BARqBD,kBAAkB,UACW,kCAAkC"}
1
+ {"version":3,"names":["ApplicationGraphQL","Plugin"],"sources":["ApplicationGraphQL.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { ApwScheduleActionData } from \"~/scheduler/types\";\nimport { ApwSettings } from \"~/scheduler/handlers/utils\";\n\nexport { ApwScheduleActionData, ApwSettings };\n\nexport interface ApplicationGraphQLGetUrlParams {\n tenant: string;\n locale: string;\n}\nexport interface ApplicationGraphQLBody<T = Record<string, any>> {\n query: string;\n variables: T;\n}\n\nexport abstract class ApplicationGraphQL extends Plugin {\n public static override readonly type: string = \"apw.scheduler.applicationGraphQL\";\n\n public abstract getUrl(params: ApplicationGraphQLGetUrlParams): string;\n\n public abstract canUse(data: ApwScheduleActionData): boolean;\n\n public abstract getArn(settings: ApwSettings): string;\n\n public abstract getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAaO,MAAeA,kBAAkB,SAASC,cAAM,CAAC;AAUvD;AAAA,8BAVqBD,kBAAkB,UACW,kCAAkC"}
@@ -1,9 +1,8 @@
1
- import { ApplicationGraphQL, ApplicationGraphQLBody } from "./ApplicationGraphQL";
2
- import { ApwScheduleActionData } from "../../../types";
3
- import { ApwSettings } from "../../utils";
1
+ import { ApplicationGraphQL, ApplicationGraphQLBody, ApwSettings, ApplicationGraphQLGetUrlParams, ApwScheduleActionData } from "./ApplicationGraphQL";
4
2
  export declare class HeadlessCMSGraphQL extends ApplicationGraphQL {
5
3
  name: string;
6
4
  canUse(data: ApwScheduleActionData): boolean;
5
+ getUrl({ locale }: ApplicationGraphQLGetUrlParams): string;
7
6
  getArn(settings: ApwSettings): string;
8
7
  getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null;
9
8
  private getPublishBody;
@@ -57,13 +57,18 @@ const createUnpublishMutation = modelId => {
57
57
  class HeadlessCMSGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
58
58
  constructor(...args) {
59
59
  super(...args);
60
- (0, _defineProperty2.default)(this, "name", "apw.scheduler.applicationGraphQL.pageBuilder");
60
+ (0, _defineProperty2.default)(this, "name", "apw.scheduler.applicationGraphQL.headlessCms");
61
61
  }
62
62
  canUse(data) {
63
63
  return data.type === _types.ApwContentTypes.CMS_ENTRY;
64
64
  }
65
+ getUrl({
66
+ locale
67
+ }) {
68
+ return `/cms/manage/${locale}`;
69
+ }
65
70
  getArn(settings) {
66
- return settings.cmsGraphqlFunctionArn;
71
+ return settings.mainGraphqlFunctionArn;
67
72
  }
68
73
  getGraphQLBody(data) {
69
74
  switch (data.action) {
@@ -1 +1 @@
1
- {"version":3,"names":["META_FIELDS","ERROR_FIELD","createPublishMutation","modelId","ucFirstModelId","upperFirst","createUnpublishMutation","HeadlessCMSGraphQL","ApplicationGraphQL","canUse","data","type","ApwContentTypes","CMS_ENTRY","getArn","settings","cmsGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","WebinyError","query","variables","revision","entryId"],"sources":["HeadlessCMSGraphQL.ts"],"sourcesContent":["import { ApplicationGraphQL, ApplicationGraphQLBody } from \"./ApplicationGraphQL\";\nimport { ApwContentTypes, ApwScheduleActionData, ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport { ApwSettings } from \"~/scheduler/handlers/utils\";\nimport WebinyError from \"@webiny/error\";\nimport upperFirst from \"lodash/upperFirst\";\n\nconst META_FIELDS = `\n title\n publishedOn\n version\n locked\n status\n`;\n\nconst ERROR_FIELD = `\n {\n code\n data\n message\n }\n`;\n\nconst createPublishMutation = (modelId: string): string => {\n const ucFirstModelId = upperFirst(modelId);\n\n return `\n mutation CmsPublish${ucFirstModelId}($revision: ID!) {\n content: publish${ucFirstModelId}(revision: $revision) {\n data {\n id\n meta {\n ${META_FIELDS}\n }\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\nconst createUnpublishMutation = (modelId: string) => {\n const ucFirstModelId = upperFirst(modelId);\n\n return `\n mutation CmsUnpublish${ucFirstModelId}($revision: ID!) {\n content: unpublish${ucFirstModelId}(revision: $revision) {\n data {\n id\n meta {\n ${META_FIELDS}\n }\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\ninterface ApplicationGraphQLBodyVariables {\n revision: string;\n}\n\nexport class HeadlessCMSGraphQL extends ApplicationGraphQL {\n public override name = \"apw.scheduler.applicationGraphQL.pageBuilder\";\n\n public override canUse(data: ApwScheduleActionData): boolean {\n return data.type === ApwContentTypes.CMS_ENTRY;\n }\n\n public override getArn(settings: ApwSettings): string {\n return settings.cmsGraphqlFunctionArn;\n }\n\n public override getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null {\n switch (data.action) {\n case ApwScheduleActionTypes.PUBLISH:\n return this.getPublishBody(data);\n case ApwScheduleActionTypes.UNPUBLISH:\n return this.getUnpublishBody(data);\n default:\n return null;\n }\n }\n\n private getPublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n if (!data.modelId) {\n throw new WebinyError(\n \"Missing model ID in the schedule action data.\",\n \"SCHEDULE_ACTION_ERROR\",\n {\n data\n }\n );\n }\n return {\n query: createPublishMutation(data.modelId),\n variables: {\n revision: data.entryId\n }\n };\n }\n\n private getUnpublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n if (!data.modelId) {\n throw new WebinyError(\n \"Missing model ID in the schedule action data.\",\n \"SCHEDULE_ACTION_ERROR\",\n {\n data\n }\n );\n }\n return {\n query: createUnpublishMutation(data.modelId),\n variables: {\n revision: data.entryId\n }\n };\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAEA;AACA;AAEA,MAAMA,WAAW,GAAI;AACrB;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,WAAW,GAAI;AACrB;AACA;AACA;AACA;AACA;AAC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B,qBAAqB,CAACQ,IAAI,CAACP,OAAO,CAAC;MAC1CuB,SAAS,EAAE;QACPC,QAAQ,EAAEjB,IAAI,CAACkB;MACnB;IACJ,CAAC;EACL;EAEQL,gBAAgB,CACpBb,IAA2B,EAC4B;IACvD,IAAI,CAACA,IAAI,CAACP,OAAO,EAAE;MACf,MAAM,IAAIqB,cAAW,CACjB,+CAA+C,EAC/C,uBAAuB,EACvB;QACId;MACJ,CAAC,CACJ;IACL;IACA,OAAO;MACHe,KAAK,EAAEnB,uBAAuB,CAACI,IAAI,CAACP,OAAO,CAAC;MAC5CuB,SAAS,EAAE;QACPC,QAAQ,EAAEjB,IAAI,CAACkB;MACnB;IACJ,CAAC;EACL;AACJ;AAAC"}
1
+ {"version":3,"names":["META_FIELDS","ERROR_FIELD","createPublishMutation","modelId","ucFirstModelId","upperFirst","createUnpublishMutation","HeadlessCMSGraphQL","ApplicationGraphQL","canUse","data","type","ApwContentTypes","CMS_ENTRY","getUrl","locale","getArn","settings","mainGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","WebinyError","query","variables","revision","entryId"],"sources":["HeadlessCMSGraphQL.ts"],"sourcesContent":["import {\n ApplicationGraphQL,\n ApplicationGraphQLBody,\n ApwSettings,\n ApplicationGraphQLGetUrlParams,\n ApwScheduleActionData\n} from \"./ApplicationGraphQL\";\nimport { ApwContentTypes, ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport WebinyError from \"@webiny/error\";\nimport upperFirst from \"lodash/upperFirst\";\n\nconst META_FIELDS = `\n title\n publishedOn\n version\n locked\n status\n`;\n\nconst ERROR_FIELD = `\n {\n code\n data\n message\n }\n`;\n\nconst createPublishMutation = (modelId: string): string => {\n const ucFirstModelId = upperFirst(modelId);\n\n return `\n mutation CmsPublish${ucFirstModelId}($revision: ID!) {\n content: publish${ucFirstModelId}(revision: $revision) {\n data {\n id\n meta {\n ${META_FIELDS}\n }\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\nconst createUnpublishMutation = (modelId: string) => {\n const ucFirstModelId = upperFirst(modelId);\n\n return `\n mutation CmsUnpublish${ucFirstModelId}($revision: ID!) {\n content: unpublish${ucFirstModelId}(revision: $revision) {\n data {\n id\n meta {\n ${META_FIELDS}\n }\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\ninterface ApplicationGraphQLBodyVariables {\n revision: string;\n}\n\nexport class HeadlessCMSGraphQL extends ApplicationGraphQL {\n public override name = \"apw.scheduler.applicationGraphQL.headlessCms\";\n\n public override canUse(data: ApwScheduleActionData): boolean {\n return data.type === ApwContentTypes.CMS_ENTRY;\n }\n\n public override getUrl({ locale }: ApplicationGraphQLGetUrlParams): string {\n return `/cms/manage/${locale}`;\n }\n\n public override getArn(settings: ApwSettings): string {\n return settings.mainGraphqlFunctionArn;\n }\n\n public override getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null {\n switch (data.action) {\n case ApwScheduleActionTypes.PUBLISH:\n return this.getPublishBody(data);\n case ApwScheduleActionTypes.UNPUBLISH:\n return this.getUnpublishBody(data);\n default:\n return null;\n }\n }\n\n private getPublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n if (!data.modelId) {\n throw new WebinyError(\n \"Missing model ID in the schedule action data.\",\n \"SCHEDULE_ACTION_ERROR\",\n {\n data\n }\n );\n }\n return {\n query: createPublishMutation(data.modelId),\n variables: {\n revision: data.entryId\n }\n };\n }\n\n private getUnpublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n if (!data.modelId) {\n throw new WebinyError(\n \"Missing model ID in the schedule action data.\",\n \"SCHEDULE_ACTION_ERROR\",\n {\n data\n }\n );\n }\n return {\n query: createUnpublishMutation(data.modelId),\n variables: {\n revision: data.entryId\n }\n };\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAOA;AACA;AACA;AAEA,MAAMA,WA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,CAClBb,IAA2B,EAC4B;IACvD,IAAI,CAACA,IAAI,CAACP,OAAO,EAAE;MACf,MAAM,IAAIuB,cAAW,CACjB,+CAA+C,EAC/C,uBAAuB,EACvB;QACIhB;MACJ,CAAC,CACJ;IACL;IACA,OAAO;MACHiB,KAAK,EAAEzB,qBAAqB,CAACQ,IAAI,CAACP,OAAO,CAAC;MAC1CyB,SAAS,EAAE;QACPC,QAAQ,EAAEnB,IAAI,CAACoB;MACnB;IACJ,CAAC;EACL;EAEQL,gBAAgB,CACpBf,IAA2B,EAC4B;IACvD,IAAI,CAACA,IAAI,CAACP,OAAO,EAAE;MACf,MAAM,IAAIuB,cAAW,CACjB,+CAA+C,EAC/C,uBAAuB,EACvB;QACIhB;MACJ,CAAC,CACJ;IACL;IACA,OAAO;MACHiB,KAAK,EAAErB,uBAAuB,CAACI,IAAI,CAACP,OAAO,CAAC;MAC5CyB,SAAS,EAAE;QACPC,QAAQ,EAAEnB,IAAI,CAACoB;MACnB;IACJ,CAAC;EACL;AACJ;AAAC"}
@@ -1,9 +1,9 @@
1
- import { ApplicationGraphQL, ApplicationGraphQLBody } from "./ApplicationGraphQL";
2
- import { ApwScheduleActionData } from "../../../types";
1
+ import { ApplicationGraphQL, ApplicationGraphQLBody, ApwScheduleActionData } from "./ApplicationGraphQL";
3
2
  import { ApwSettings } from "../../utils";
4
3
  export declare class PageBuilderGraphQL extends ApplicationGraphQL {
5
4
  name: string;
6
5
  canUse(data: ApwScheduleActionData): boolean;
6
+ getUrl(): string;
7
7
  getArn(settings: ApwSettings): string;
8
8
  getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null;
9
9
  private getPublishBody;
@@ -11,65 +11,6 @@ var _types = require("../../../types");
11
11
  const PB_PAGE_DATA_FIELD = /* GraphQL */`
12
12
  {
13
13
  id
14
- pid
15
- editor
16
- category {
17
- slug
18
- }
19
- version
20
- title
21
- path
22
- url
23
- content
24
- savedOn
25
- status
26
- locked
27
- publishedOn
28
- locked
29
- revisions {
30
- id
31
- status
32
- locked
33
- version
34
- }
35
- settings {
36
- general {
37
- snippet
38
- tags
39
- layout
40
- image {
41
- id
42
- src
43
- }
44
- }
45
- social {
46
- meta {
47
- property
48
- content
49
- }
50
- title
51
- description
52
- image {
53
- id
54
- src
55
- }
56
- }
57
- seo {
58
- title
59
- description
60
- meta {
61
- name
62
- content
63
- }
64
- }
65
- }
66
- createdFrom
67
- createdOn
68
- createdBy {
69
- id
70
- displayName
71
- type
72
- }
73
14
  }
74
15
  `;
75
16
  const ERROR_FIELD = /* GraphQL */`
@@ -107,6 +48,9 @@ class PageBuilderGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
107
48
  canUse(data) {
108
49
  return data.type === _types.ApwContentTypes.PAGE;
109
50
  }
51
+ getUrl() {
52
+ return `/graphql`;
53
+ }
110
54
  getArn(settings) {
111
55
  return settings.mainGraphqlFunctionArn;
112
56
  }
@@ -1 +1 @@
1
- {"version":3,"names":["PB_PAGE_DATA_FIELD","ERROR_FIELD","PUBLISH_MUTATION","UNPUBLISH_MUTATION","PageBuilderGraphQL","ApplicationGraphQL","canUse","data","type","ApwContentTypes","PAGE","getArn","settings","mainGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","query","variables","id","entryId"],"sources":["PageBuilderGraphQL.ts"],"sourcesContent":["import { ApplicationGraphQL, ApplicationGraphQLBody } from \"./ApplicationGraphQL\";\nimport { ApwContentTypes, ApwScheduleActionData, ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport { ApwSettings } from \"~/scheduler/handlers/utils\";\n\nconst PB_PAGE_DATA_FIELD = /* GraphQL */ `\n {\n id\n pid\n editor\n category {\n slug\n }\n version\n title\n path\n url\n content\n savedOn\n status\n locked\n publishedOn\n locked\n revisions {\n id\n status\n locked\n version\n }\n settings {\n general {\n snippet\n tags\n layout\n image {\n id\n src\n }\n }\n social {\n meta {\n property\n content\n }\n title\n description\n image {\n id\n src\n }\n }\n seo {\n title\n description\n meta {\n name\n content\n }\n }\n }\n createdFrom\n createdOn\n createdBy {\n id\n displayName\n type\n }\n }\n`;\n\nconst ERROR_FIELD = /* GraphQL */ `\n {\n code\n data\n message\n }\n`;\n\nconst PUBLISH_MUTATION = /* GraphQL */ `\n mutation PublishPage($id: ID!) {\n pageBuilder {\n publishPage(id: $id) {\n data ${PB_PAGE_DATA_FIELD}\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n\nconst UNPUBLISH_MUTATION = /* GraphQL */ `\n mutation UnpublishPage($id: ID!) {\n pageBuilder {\n unpublishPage(id: $id) {\n data ${PB_PAGE_DATA_FIELD}\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n\ninterface ApplicationGraphQLBodyVariables {\n id: string;\n}\n\nexport class PageBuilderGraphQL extends ApplicationGraphQL {\n public override name = \"apw.scheduler.applicationGraphQL.pageBuilder\";\n\n public override canUse(data: ApwScheduleActionData): boolean {\n return data.type === ApwContentTypes.PAGE;\n }\n\n public override getArn(settings: ApwSettings): string {\n return settings.mainGraphqlFunctionArn;\n }\n\n public override getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null {\n switch (data.action) {\n case ApwScheduleActionTypes.PUBLISH:\n return this.getPublishBody(data);\n case ApwScheduleActionTypes.UNPUBLISH:\n return this.getUnpublishBody(data);\n default:\n return null;\n }\n }\n\n private getPublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n return {\n query: PUBLISH_MUTATION,\n variables: {\n id: data.entryId\n }\n };\n }\n\n private getUnpublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n return {\n query: UNPUBLISH_MUTATION,\n variables: {\n id: data.entryId\n }\n };\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAGA,MAAMA,kBAAkB,GAAG,aAAe;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,WAAW,GAAG,aAAe;AACnC;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,gBAAgB,GAAG,aAAe;AACxC;AACA;AACA;AACA,uBAAuBF,kBAAmB;AAC1C,wBAAwBC,WAAY;AACpC;AACA;AACA;AACA,CAAC;AAED,MAAME,kBAAkB,GAAG,aAAe;AAC1C;AACA;AACA;AACA,uBAAuBH,kBAAmB;AAC1C,wBAAwBC,WAAY;AACpC;AACA;AACA;AACA,CAAC;AAMM,MAAMG,kBAAkB,SAASC,sCAAkB,CAAC;EAAA;IAAA;IAAA,4CAChC,8CAA8C;EAAA;EAErDC,MAAM,CAACC,IAA2B,EAAW;IACzD,OAAOA,IAAI,CAACC,IAAI,KAAKC,sBAAe,CAACC,IAAI;EAC7C;EAEgBC,MAAM,CAACC,QAAqB,EAAU;IAClD,OAAOA,QAAQ,CAACC,sBAAsB;EAC1C;EAEgBC,cAAc,CAACP,IAA2B,EAAiC;IACvF,QAAQA,IAAI,CAACQ,MAAM;MACf,KAAKC,6BAAsB,CAACC,OAAO;QAC/B,OAAO,IAAI,CAACC,cAAc,CAACX,IAAI,CAAC;MACpC,KAAKS,6BAAsB,CAACG,SAAS;QACjC,OAAO,IAAI,CAACC,gBAAgB,CAACb,IAAI,CAAC;MACtC;QACI,OAAO,IAAI;IAAC;EAExB;EAEQW,cAAc,CAClBX,IAA2B,EAC4B;IACvD,OAAO;MACHc,KAAK,EAAEnB,gBAAgB;MACvBoB,SAAS,EAAE;QACPC,EAAE,EAAEhB,IAAI,CAACiB;MACb;IACJ,CAAC;EACL;EAEQJ,gBAAgB,CACpBb,IAA2B,EAC4B;IACvD,OAAO;MACHc,KAAK,EAAElB,kBAAkB;MACzBmB,SAAS,EAAE;QACPC,EAAE,EAAEhB,IAAI,CAACiB;MACb;IACJ,CAAC;EACL;AACJ;AAAC"}
1
+ {"version":3,"names":["PB_PAGE_DATA_FIELD","ERROR_FIELD","PUBLISH_MUTATION","UNPUBLISH_MUTATION","PageBuilderGraphQL","ApplicationGraphQL","canUse","data","type","ApwContentTypes","PAGE","getUrl","getArn","settings","mainGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","query","variables","id","entryId"],"sources":["PageBuilderGraphQL.ts"],"sourcesContent":["import {\n ApplicationGraphQL,\n ApplicationGraphQLBody,\n ApwScheduleActionData\n} from \"./ApplicationGraphQL\";\nimport { ApwContentTypes, ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport { ApwSettings } from \"~/scheduler/handlers/utils\";\n\nconst PB_PAGE_DATA_FIELD = /* GraphQL */ `\n {\n id\n }\n`;\n\nconst ERROR_FIELD = /* GraphQL */ `\n {\n code\n data\n message\n }\n`;\n\nconst PUBLISH_MUTATION = /* GraphQL */ `\n mutation PublishPage($id: ID!) {\n pageBuilder {\n publishPage(id: $id) {\n data ${PB_PAGE_DATA_FIELD}\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n\nconst UNPUBLISH_MUTATION = /* GraphQL */ `\n mutation UnpublishPage($id: ID!) {\n pageBuilder {\n unpublishPage(id: $id) {\n data ${PB_PAGE_DATA_FIELD}\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n\ninterface ApplicationGraphQLBodyVariables {\n id: string;\n}\n\nexport class PageBuilderGraphQL extends ApplicationGraphQL {\n public override name = \"apw.scheduler.applicationGraphQL.pageBuilder\";\n\n public override canUse(data: ApwScheduleActionData): boolean {\n return data.type === ApwContentTypes.PAGE;\n }\n\n public override getUrl(): string {\n return `/graphql`;\n }\n\n public override getArn(settings: ApwSettings): string {\n return settings.mainGraphqlFunctionArn;\n }\n\n public override getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null {\n switch (data.action) {\n case ApwScheduleActionTypes.PUBLISH:\n return this.getPublishBody(data);\n case ApwScheduleActionTypes.UNPUBLISH:\n return this.getUnpublishBody(data);\n default:\n return null;\n }\n }\n\n private getPublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n return {\n query: PUBLISH_MUTATION,\n variables: {\n id: data.entryId\n }\n };\n }\n\n private getUnpublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n return {\n query: UNPUBLISH_MUTATION,\n variables: {\n id: data.entryId\n }\n };\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAKA;AAGA,MAAMA,kBAAkB,GAAG,aAAe;AAC1C;AACA;AACA;AACA,CAAC;AAED,MAAMC,WAAW,GAAG,aAAe;AACnC;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,gBAAgB,GAAG,aAAe;AACxC;AACA;AACA;AACA,uBAAuBF,kBAAmB;AAC1C,wBAAwBC,WAAY;AACpC;AACA;AACA;AACA,CAAC;AAED,MAAME,kBAAkB,GAAG,aAAe;AAC1C;AACA;AACA;AACA,uBAAuBH,kBAAmB;AAC1C,wBAAwBC,WAAY;AACpC;AACA;AACA;AACA,CAAC;AAMM,MAAMG,kBAAkB,SAASC,sCAAkB,CAAC;EAAA;IAAA;IAAA,4CAChC,8CAA8C;EAAA;EAErDC,MAAM,CAACC,IAA2B,EAAW;IACzD,OAAOA,IAAI,CAACC,IAAI,KAAKC,sBAAe,CAACC,IAAI;EAC7C;EAEgBC,MAAM,GAAW;IAC7B,OAAQ,UAAS;EACrB;EAEgBC,MAAM,CAACC,QAAqB,EAAU;IAClD,OAAOA,QAAQ,CAACC,sBAAsB;EAC1C;EAEgBC,cAAc,CAACR,IAA2B,EAAiC;IACvF,QAAQA,IAAI,CAACS,MAAM;MACf,KAAKC,6BAAsB,CAACC,OAAO;QAC/B,OAAO,IAAI,CAACC,cAAc,CAACZ,IAAI,CAAC;MACpC,KAAKU,6BAAsB,CAACG,SAAS;QACjC,OAAO,IAAI,CAACC,gBAAgB,CAACd,IAAI,CAAC;MACtC;QACI,OAAO,IAAI;IAAC;EAExB;EAEQY,cAAc,CAClBZ,IAA2B,EAC4B;IACvD,OAAO;MACHe,KAAK,EAAEpB,gBAAgB;MACvBqB,SAAS,EAAE;QACPC,EAAE,EAAEjB,IAAI,CAACkB;MACb;IACJ,CAAC;EACL;EAEQJ,gBAAgB,CACpBd,IAA2B,EAC4B;IACvD,OAAO;MACHe,KAAK,EAAEnB,kBAAkB;MACzBoB,SAAS,EAAE;QACPC,EAAE,EAAEjB,IAAI,CAACkB;MACb;IACJ,CAAC;EACL;AACJ;AAAC"}
@@ -19,4 +19,4 @@ export interface Configuration {
19
19
  executeAction: string;
20
20
  };
21
21
  }
22
- export declare const scheduleActionHandlerPlugins: (config: Configuration) => ((import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler-aws").RawEventHandler<HandlerArgs, import("@webiny/handler/types").Context, any>)[];
22
+ export declare const scheduleActionHandlerPlugins: (config: Configuration) => ((import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler-aws").RawEventHandler<HandlerArgs, import("@webiny/handler/types").Context, any>)[];
@@ -134,7 +134,11 @@ const createScheduleActionLambda = params => {
134
134
  item: nextItem
135
135
  });
136
136
  } catch (ex) {
137
- log("[HANDLER_CREATE_RULE] Error => ", ex);
137
+ console.error("[HANDLER_CREATE_RULE] => ", JSON.stringify({
138
+ message: ex.message,
139
+ code: ex.code,
140
+ data: ex.data
141
+ }));
138
142
  // TODO: Handler error. Maybe save it into DB.
139
143
  }
140
144
  });