@webiny/api-headless-cms-workflows 0.0.0-unstable.ac6ebf63c6 → 0.0.0-unstable.b6d7105cee

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 (59) hide show
  1. package/features/EntryWorkflows/decorators/CmsWorkflowStateContextProvider.d.ts +15 -0
  2. package/features/EntryWorkflows/decorators/CmsWorkflowStateContextProvider.js +35 -0
  3. package/features/EntryWorkflows/decorators/CmsWorkflowStateContextProvider.js.map +1 -0
  4. package/features/EntryWorkflows/decorators/CmsWorkflowStateFilter.d.ts +13 -0
  5. package/features/EntryWorkflows/decorators/CmsWorkflowStateFilter.js +45 -0
  6. package/features/EntryWorkflows/decorators/CmsWorkflowStateFilter.js.map +1 -0
  7. package/features/EntryWorkflows/errors.d.ts +11 -0
  8. package/features/EntryWorkflows/errors.js +12 -0
  9. package/features/EntryWorkflows/errors.js.map +1 -0
  10. package/features/EntryWorkflows/feature.d.ts +4 -1
  11. package/features/EntryWorkflows/feature.js +19 -10
  12. package/features/EntryWorkflows/feature.js.map +1 -1
  13. package/features/EntryWorkflows/handlers/BlockMoveOnActiveWorkflowState.d.ts +11 -0
  14. package/features/EntryWorkflows/handlers/BlockMoveOnActiveWorkflowState.js +37 -0
  15. package/features/EntryWorkflows/handlers/BlockMoveOnActiveWorkflowState.js.map +1 -0
  16. package/features/EntryWorkflows/handlers/ClearEntryStateOnWorkflowStateAfterDelete.d.ts +1 -1
  17. package/features/EntryWorkflows/handlers/ClearEntryStateOnWorkflowStateAfterDelete.js +24 -22
  18. package/features/EntryWorkflows/handlers/ClearEntryStateOnWorkflowStateAfterDelete.js.map +1 -1
  19. package/features/EntryWorkflows/handlers/ClearEntryStateOnWorkflowStateCancel.d.ts +13 -0
  20. package/features/EntryWorkflows/handlers/ClearEntryStateOnWorkflowStateCancel.js +35 -0
  21. package/features/EntryWorkflows/handlers/ClearEntryStateOnWorkflowStateCancel.js.map +1 -0
  22. package/features/EntryWorkflows/handlers/DeleteWorkflowStateOnEntryAfterDelete.d.ts +1 -1
  23. package/features/EntryWorkflows/handlers/DeleteWorkflowStateOnEntryAfterDelete.js +16 -19
  24. package/features/EntryWorkflows/handlers/DeleteWorkflowStateOnEntryAfterDelete.js.map +1 -1
  25. package/features/EntryWorkflows/handlers/DeleteWorkflowsOnModelAfterDelete.d.ts +1 -1
  26. package/features/EntryWorkflows/handlers/DeleteWorkflowsOnModelAfterDelete.js +28 -32
  27. package/features/EntryWorkflows/handlers/DeleteWorkflowsOnModelAfterDelete.js.map +1 -1
  28. package/features/EntryWorkflows/handlers/UpdateEntryOnWorkflowStateAfterCreate.d.ts +1 -1
  29. package/features/EntryWorkflows/handlers/UpdateEntryOnWorkflowStateAfterCreate.js +25 -23
  30. package/features/EntryWorkflows/handlers/UpdateEntryOnWorkflowStateAfterCreate.js.map +1 -1
  31. package/features/EntryWorkflows/handlers/UpdateEntryOnWorkflowStateAfterUpdate.d.ts +1 -1
  32. package/features/EntryWorkflows/handlers/UpdateEntryOnWorkflowStateAfterUpdate.js +24 -23
  33. package/features/EntryWorkflows/handlers/UpdateEntryOnWorkflowStateAfterUpdate.js.map +1 -1
  34. package/features/EntryWorkflows/handlers/ValidateWorkflowStateOnEntryBeforePublish.d.ts +1 -1
  35. package/features/EntryWorkflows/handlers/ValidateWorkflowStateOnEntryBeforePublish.js +34 -36
  36. package/features/EntryWorkflows/handlers/ValidateWorkflowStateOnEntryBeforePublish.js.map +1 -1
  37. package/features/EntryWorkflows/index.js +0 -2
  38. package/features/Workflows/feature.d.ts +4 -1
  39. package/features/Workflows/feature.js +6 -5
  40. package/features/Workflows/feature.js.map +1 -1
  41. package/features/Workflows/handlers/DisallowUnpublishableModelsOnBeforeCreate.d.ts +1 -1
  42. package/features/Workflows/handlers/DisallowUnpublishableModelsOnBeforeCreate.js +17 -22
  43. package/features/Workflows/handlers/DisallowUnpublishableModelsOnBeforeCreate.js.map +1 -1
  44. package/features/Workflows/index.js +0 -2
  45. package/graphql/entrySystemSchema.d.ts +2 -0
  46. package/graphql/entrySystemSchema.js +18 -0
  47. package/graphql/entrySystemSchema.js.map +1 -0
  48. package/index.js +12 -13
  49. package/index.js.map +1 -1
  50. package/package.json +25 -18
  51. package/utils/appName.js +6 -11
  52. package/utils/appName.js.map +1 -1
  53. package/utils/modelAllowed.js +5 -9
  54. package/utils/modelAllowed.js.map +1 -1
  55. package/utils/state.d.ts +2 -2
  56. package/utils/state.js +9 -8
  57. package/utils/state.js.map +1 -1
  58. package/features/EntryWorkflows/index.js.map +0 -1
  59. package/features/Workflows/index.js.map +0 -1
@@ -8,6 +8,6 @@ declare class UpdateEntryOnWorkflowStateAfterCreateImpl implements WorkflowState
8
8
  handle(event: WorkflowStateAfterCreateHandler.Event): Promise<void>;
9
9
  }
10
10
  export declare const UpdateEntryOnWorkflowStateAfterCreate: typeof UpdateEntryOnWorkflowStateAfterCreateImpl & {
11
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/EventPublisher").IEventHandler<import("@webiny/api-workflows/features/workflowState/CreateWorkflowState/events.js").WorkflowStateAfterCreateEvent>>;
11
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-workflows/features/workflowState/CreateWorkflowState/events.js").WorkflowStateAfterCreateEvent>>;
12
12
  };
13
13
  export {};
@@ -4,32 +4,34 @@ import { WorkflowStateAfterCreateHandler } from "@webiny/api-workflows/features/
4
4
  import { getModelIdFromAppName } from "../../../utils/appName.js";
5
5
  import { getStateValues } from "../../../utils/state.js";
6
6
  class UpdateEntryOnWorkflowStateAfterCreateImpl {
7
- constructor(getModel, updateEntry) {
8
- this.getModel = getModel;
9
- this.updateEntry = updateEntry;
10
- }
11
- async handle(event) {
12
- const {
13
- state
14
- } = event.payload;
15
- const modelId = getModelIdFromAppName(state.app);
16
- if (!modelId) {
17
- return;
7
+ constructor(getModel, updateEntry){
8
+ this.getModel = getModel;
9
+ this.updateEntry = updateEntry;
18
10
  }
19
- const values = getStateValues(state);
20
- const modelResult = await this.getModel.execute(modelId);
21
- if (modelResult.isFail()) {
22
- return;
11
+ async handle(event) {
12
+ const { state } = event.payload;
13
+ const modelId = getModelIdFromAppName(state.app);
14
+ if (!modelId) return;
15
+ const values = getStateValues(state);
16
+ const modelResult = await this.getModel.execute(modelId);
17
+ if (modelResult.isFail()) return;
18
+ const model = modelResult.value;
19
+ await this.updateEntry.execute(model, state.targetRevisionId, {
20
+ system: {
21
+ workflow: values
22
+ }
23
+ }, {
24
+ skipValidation: true
25
+ });
23
26
  }
24
- const model = modelResult.value;
25
- await this.updateEntry.execute(model, state.targetRevisionId, {
26
- state: values
27
- });
28
- }
29
27
  }
30
- export const UpdateEntryOnWorkflowStateAfterCreate = WorkflowStateAfterCreateHandler.createImplementation({
31
- implementation: UpdateEntryOnWorkflowStateAfterCreateImpl,
32
- dependencies: [GetModelUseCase, UpdateEntryUseCase]
28
+ const UpdateEntryOnWorkflowStateAfterCreate = WorkflowStateAfterCreateHandler.createImplementation({
29
+ implementation: UpdateEntryOnWorkflowStateAfterCreateImpl,
30
+ dependencies: [
31
+ GetModelUseCase,
32
+ UpdateEntryUseCase
33
+ ]
33
34
  });
35
+ export { UpdateEntryOnWorkflowStateAfterCreate };
34
36
 
35
37
  //# sourceMappingURL=UpdateEntryOnWorkflowStateAfterCreate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["GetModelUseCase","UpdateEntryUseCase","WorkflowStateAfterCreateHandler","getModelIdFromAppName","getStateValues","UpdateEntryOnWorkflowStateAfterCreateImpl","constructor","getModel","updateEntry","handle","event","state","payload","modelId","app","values","modelResult","execute","isFail","model","value","targetRevisionId","UpdateEntryOnWorkflowStateAfterCreate","createImplementation","implementation","dependencies"],"sources":["UpdateEntryOnWorkflowStateAfterCreate.ts"],"sourcesContent":["import { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { WorkflowStateAfterCreateHandler } from \"@webiny/api-workflows/features/workflowState/CreateWorkflowState/events.js\";\nimport { getModelIdFromAppName } from \"~/utils/appName.js\";\nimport { getStateValues } from \"~/utils/state.js\";\n\nclass UpdateEntryOnWorkflowStateAfterCreateImpl\n implements WorkflowStateAfterCreateHandler.Interface\n{\n constructor(\n private getModel: GetModelUseCase.Interface,\n private updateEntry: UpdateEntryUseCase.Interface\n ) {}\n\n async handle(event: WorkflowStateAfterCreateHandler.Event): Promise<void> {\n const { state } = event.payload;\n\n const modelId = getModelIdFromAppName(state.app);\n if (!modelId) {\n return;\n }\n\n const values = getStateValues(state);\n\n const modelResult = await this.getModel.execute(modelId);\n if (modelResult.isFail()) {\n return;\n }\n\n const model = modelResult.value;\n await this.updateEntry.execute(model, state.targetRevisionId, {\n state: values\n });\n }\n}\n\nexport const UpdateEntryOnWorkflowStateAfterCreate =\n WorkflowStateAfterCreateHandler.createImplementation({\n implementation: UpdateEntryOnWorkflowStateAfterCreateImpl,\n dependencies: [GetModelUseCase, UpdateEntryUseCase]\n });\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,kEAAkE;AAClG,SAASC,kBAAkB,QAAQ,qEAAqE;AACxG,SAASC,+BAA+B,QAAQ,4EAA4E;AAC5H,SAASC,qBAAqB;AAC9B,SAASC,cAAc;AAEvB,MAAMC,yCAAyC,CAE/C;EACIC,WAAWA,CACCC,QAAmC,EACnCC,WAAyC,EACnD;IAAA,KAFUD,QAAmC,GAAnCA,QAAmC;IAAA,KACnCC,WAAyC,GAAzCA,WAAyC;EAClD;EAEH,MAAMC,MAAMA,CAACC,KAA4C,EAAiB;IACtE,MAAM;MAAEC;IAAM,CAAC,GAAGD,KAAK,CAACE,OAAO;IAE/B,MAAMC,OAAO,GAAGV,qBAAqB,CAACQ,KAAK,CAACG,GAAG,CAAC;IAChD,IAAI,CAACD,OAAO,EAAE;MACV;IACJ;IAEA,MAAME,MAAM,GAAGX,cAAc,CAACO,KAAK,CAAC;IAEpC,MAAMK,WAAW,GAAG,MAAM,IAAI,CAACT,QAAQ,CAACU,OAAO,CAACJ,OAAO,CAAC;IACxD,IAAIG,WAAW,CAACE,MAAM,CAAC,CAAC,EAAE;MACtB;IACJ;IAEA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK;IAC/B,MAAM,IAAI,CAACZ,WAAW,CAACS,OAAO,CAACE,KAAK,EAAER,KAAK,CAACU,gBAAgB,EAAE;MAC1DV,KAAK,EAAEI;IACX,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMO,qCAAqC,GAC9CpB,+BAA+B,CAACqB,oBAAoB,CAAC;EACjDC,cAAc,EAAEnB,yCAAyC;EACzDoB,YAAY,EAAE,CAACzB,eAAe,EAAEC,kBAAkB;AACtD,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/EntryWorkflows/handlers/UpdateEntryOnWorkflowStateAfterCreate.js","sources":["../../../../src/features/EntryWorkflows/handlers/UpdateEntryOnWorkflowStateAfterCreate.ts"],"sourcesContent":["import { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { WorkflowStateAfterCreateHandler } from \"@webiny/api-workflows/features/workflowState/CreateWorkflowState/events.js\";\nimport { getModelIdFromAppName } from \"~/utils/appName.js\";\nimport { getStateValues } from \"~/utils/state.js\";\n\nclass UpdateEntryOnWorkflowStateAfterCreateImpl\n implements WorkflowStateAfterCreateHandler.Interface\n{\n constructor(\n private getModel: GetModelUseCase.Interface,\n private updateEntry: UpdateEntryUseCase.Interface\n ) {}\n\n async handle(event: WorkflowStateAfterCreateHandler.Event): Promise<void> {\n const { state } = event.payload;\n\n const modelId = getModelIdFromAppName(state.app);\n if (!modelId) {\n return;\n }\n\n const values = getStateValues(state);\n\n const modelResult = await this.getModel.execute(modelId);\n if (modelResult.isFail()) {\n return;\n }\n\n const model = modelResult.value;\n await this.updateEntry.execute(\n model,\n state.targetRevisionId,\n { system: { workflow: values } },\n { skipValidation: true }\n );\n }\n}\n\nexport const UpdateEntryOnWorkflowStateAfterCreate =\n WorkflowStateAfterCreateHandler.createImplementation({\n implementation: UpdateEntryOnWorkflowStateAfterCreateImpl,\n dependencies: [GetModelUseCase, UpdateEntryUseCase]\n });\n"],"names":["UpdateEntryOnWorkflowStateAfterCreateImpl","getModel","updateEntry","event","state","modelId","getModelIdFromAppName","values","getStateValues","modelResult","model","UpdateEntryOnWorkflowStateAfterCreate","WorkflowStateAfterCreateHandler","GetModelUseCase","UpdateEntryUseCase"],"mappings":";;;;;AAMA,MAAMA;IAGF,YACYC,QAAmC,EACnCC,WAAyC,CACnD;aAFUD,QAAQ,GAARA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,OAAOC,KAA4C,EAAiB;QACtE,MAAM,EAAEC,KAAK,EAAE,GAAGD,MAAM,OAAO;QAE/B,MAAME,UAAUC,sBAAsBF,MAAM,GAAG;QAC/C,IAAI,CAACC,SACD;QAGJ,MAAME,SAASC,eAAeJ;QAE9B,MAAMK,cAAc,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACJ;QAChD,IAAII,YAAY,MAAM,IAClB;QAGJ,MAAMC,QAAQD,YAAY,KAAK;QAC/B,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAC1BC,OACAN,MAAM,gBAAgB,EACtB;YAAE,QAAQ;gBAAE,UAAUG;YAAO;QAAE,GAC/B;YAAE,gBAAgB;QAAK;IAE/B;AACJ;AAEO,MAAMI,wCACTC,gCAAgC,oBAAoB,CAAC;IACjD,gBAAgBZ;IAChB,cAAc;QAACa;QAAiBC;KAAmB;AACvD"}
@@ -8,6 +8,6 @@ declare class UpdateEntryOnWorkflowStateAfterUpdateImpl implements WorkflowState
8
8
  handle(event: WorkflowStateAfterUpdateHandler.Event): Promise<void>;
9
9
  }
10
10
  export declare const UpdateEntryOnWorkflowStateAfterUpdate: typeof UpdateEntryOnWorkflowStateAfterUpdateImpl & {
11
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/EventPublisher").IEventHandler<import("@webiny/api-workflows/features/workflowState/UpdateWorkflowState/events.js").WorkflowStateAfterUpdateEvent>>;
11
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-workflows/features/workflowState/UpdateWorkflowState/events.js").WorkflowStateAfterUpdateEvent>>;
12
12
  };
13
13
  export {};
@@ -4,32 +4,33 @@ import { WorkflowStateAfterUpdateHandler } from "@webiny/api-workflows/features/
4
4
  import { getModelIdFromAppName } from "../../../utils/appName.js";
5
5
  import { getStateValues } from "../../../utils/state.js";
6
6
  class UpdateEntryOnWorkflowStateAfterUpdateImpl {
7
- constructor(getModel, updateEntry) {
8
- this.getModel = getModel;
9
- this.updateEntry = updateEntry;
10
- }
11
- async handle(event) {
12
- const {
13
- state
14
- } = event.payload;
15
- const modelId = getModelIdFromAppName(state.app);
16
- if (!modelId) {
17
- return;
7
+ constructor(getModel, updateEntry){
8
+ this.getModel = getModel;
9
+ this.updateEntry = updateEntry;
18
10
  }
19
- const values = getStateValues(state);
20
- const modelResult = await this.getModel.execute(modelId);
21
- if (modelResult.isFail()) {
22
- return;
11
+ async handle(event) {
12
+ const { state } = event.payload;
13
+ const modelId = getModelIdFromAppName(state.app);
14
+ if (!modelId) return;
15
+ const modelResult = await this.getModel.execute(modelId);
16
+ if (modelResult.isFail()) return;
17
+ const model = modelResult.value;
18
+ await this.updateEntry.execute(model, state.targetRevisionId, {
19
+ system: {
20
+ workflow: state.isActive ? getStateValues(state) : null
21
+ }
22
+ }, {
23
+ skipValidation: true
24
+ });
23
25
  }
24
- const model = modelResult.value;
25
- await this.updateEntry.execute(model, state.targetRevisionId, {
26
- state: values
27
- });
28
- }
29
26
  }
30
- export const UpdateEntryOnWorkflowStateAfterUpdate = WorkflowStateAfterUpdateHandler.createImplementation({
31
- implementation: UpdateEntryOnWorkflowStateAfterUpdateImpl,
32
- dependencies: [GetModelUseCase, UpdateEntryUseCase]
27
+ const UpdateEntryOnWorkflowStateAfterUpdate = WorkflowStateAfterUpdateHandler.createImplementation({
28
+ implementation: UpdateEntryOnWorkflowStateAfterUpdateImpl,
29
+ dependencies: [
30
+ GetModelUseCase,
31
+ UpdateEntryUseCase
32
+ ]
33
33
  });
34
+ export { UpdateEntryOnWorkflowStateAfterUpdate };
34
35
 
35
36
  //# sourceMappingURL=UpdateEntryOnWorkflowStateAfterUpdate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["GetModelUseCase","UpdateEntryUseCase","WorkflowStateAfterUpdateHandler","getModelIdFromAppName","getStateValues","UpdateEntryOnWorkflowStateAfterUpdateImpl","constructor","getModel","updateEntry","handle","event","state","payload","modelId","app","values","modelResult","execute","isFail","model","value","targetRevisionId","UpdateEntryOnWorkflowStateAfterUpdate","createImplementation","implementation","dependencies"],"sources":["UpdateEntryOnWorkflowStateAfterUpdate.ts"],"sourcesContent":["import { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { WorkflowStateAfterUpdateHandler } from \"@webiny/api-workflows/features/workflowState/UpdateWorkflowState/events.js\";\nimport { getModelIdFromAppName } from \"~/utils/appName.js\";\nimport { getStateValues } from \"~/utils/state.js\";\n\nclass UpdateEntryOnWorkflowStateAfterUpdateImpl\n implements WorkflowStateAfterUpdateHandler.Interface\n{\n constructor(\n private getModel: GetModelUseCase.Interface,\n private updateEntry: UpdateEntryUseCase.Interface\n ) {}\n\n async handle(event: WorkflowStateAfterUpdateHandler.Event): Promise<void> {\n const { state } = event.payload;\n\n const modelId = getModelIdFromAppName(state.app);\n if (!modelId) {\n return;\n }\n\n const values = getStateValues(state);\n\n const modelResult = await this.getModel.execute(modelId);\n if (modelResult.isFail()) {\n return;\n }\n\n const model = modelResult.value;\n await this.updateEntry.execute(model, state.targetRevisionId, {\n state: values\n });\n }\n}\n\nexport const UpdateEntryOnWorkflowStateAfterUpdate =\n WorkflowStateAfterUpdateHandler.createImplementation({\n implementation: UpdateEntryOnWorkflowStateAfterUpdateImpl,\n dependencies: [GetModelUseCase, UpdateEntryUseCase]\n });\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,kEAAkE;AAClG,SAASC,kBAAkB,QAAQ,qEAAqE;AACxG,SAASC,+BAA+B,QAAQ,4EAA4E;AAC5H,SAASC,qBAAqB;AAC9B,SAASC,cAAc;AAEvB,MAAMC,yCAAyC,CAE/C;EACIC,WAAWA,CACCC,QAAmC,EACnCC,WAAyC,EACnD;IAAA,KAFUD,QAAmC,GAAnCA,QAAmC;IAAA,KACnCC,WAAyC,GAAzCA,WAAyC;EAClD;EAEH,MAAMC,MAAMA,CAACC,KAA4C,EAAiB;IACtE,MAAM;MAAEC;IAAM,CAAC,GAAGD,KAAK,CAACE,OAAO;IAE/B,MAAMC,OAAO,GAAGV,qBAAqB,CAACQ,KAAK,CAACG,GAAG,CAAC;IAChD,IAAI,CAACD,OAAO,EAAE;MACV;IACJ;IAEA,MAAME,MAAM,GAAGX,cAAc,CAACO,KAAK,CAAC;IAEpC,MAAMK,WAAW,GAAG,MAAM,IAAI,CAACT,QAAQ,CAACU,OAAO,CAACJ,OAAO,CAAC;IACxD,IAAIG,WAAW,CAACE,MAAM,CAAC,CAAC,EAAE;MACtB;IACJ;IAEA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK;IAC/B,MAAM,IAAI,CAACZ,WAAW,CAACS,OAAO,CAACE,KAAK,EAAER,KAAK,CAACU,gBAAgB,EAAE;MAC1DV,KAAK,EAAEI;IACX,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMO,qCAAqC,GAC9CpB,+BAA+B,CAACqB,oBAAoB,CAAC;EACjDC,cAAc,EAAEnB,yCAAyC;EACzDoB,YAAY,EAAE,CAACzB,eAAe,EAAEC,kBAAkB;AACtD,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/EntryWorkflows/handlers/UpdateEntryOnWorkflowStateAfterUpdate.js","sources":["../../../../src/features/EntryWorkflows/handlers/UpdateEntryOnWorkflowStateAfterUpdate.ts"],"sourcesContent":["import { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { WorkflowStateAfterUpdateHandler } from \"@webiny/api-workflows/features/workflowState/UpdateWorkflowState/events.js\";\nimport { getModelIdFromAppName } from \"~/utils/appName.js\";\nimport { getStateValues } from \"~/utils/state.js\";\n\nclass UpdateEntryOnWorkflowStateAfterUpdateImpl\n implements WorkflowStateAfterUpdateHandler.Interface\n{\n constructor(\n private getModel: GetModelUseCase.Interface,\n private updateEntry: UpdateEntryUseCase.Interface\n ) {}\n\n async handle(event: WorkflowStateAfterUpdateHandler.Event): Promise<void> {\n const { state } = event.payload;\n\n const modelId = getModelIdFromAppName(state.app);\n if (!modelId) {\n return;\n }\n\n const modelResult = await this.getModel.execute(modelId);\n if (modelResult.isFail()) {\n return;\n }\n\n const model = modelResult.value;\n await this.updateEntry.execute(\n model,\n state.targetRevisionId,\n { system: { workflow: state.isActive ? getStateValues(state) : null } },\n { skipValidation: true }\n );\n }\n}\n\nexport const UpdateEntryOnWorkflowStateAfterUpdate =\n WorkflowStateAfterUpdateHandler.createImplementation({\n implementation: UpdateEntryOnWorkflowStateAfterUpdateImpl,\n dependencies: [GetModelUseCase, UpdateEntryUseCase]\n });\n"],"names":["UpdateEntryOnWorkflowStateAfterUpdateImpl","getModel","updateEntry","event","state","modelId","getModelIdFromAppName","modelResult","model","getStateValues","UpdateEntryOnWorkflowStateAfterUpdate","WorkflowStateAfterUpdateHandler","GetModelUseCase","UpdateEntryUseCase"],"mappings":";;;;;AAMA,MAAMA;IAGF,YACYC,QAAmC,EACnCC,WAAyC,CACnD;aAFUD,QAAQ,GAARA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,OAAOC,KAA4C,EAAiB;QACtE,MAAM,EAAEC,KAAK,EAAE,GAAGD,MAAM,OAAO;QAE/B,MAAME,UAAUC,sBAAsBF,MAAM,GAAG;QAC/C,IAAI,CAACC,SACD;QAGJ,MAAME,cAAc,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACF;QAChD,IAAIE,YAAY,MAAM,IAClB;QAGJ,MAAMC,QAAQD,YAAY,KAAK;QAC/B,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAC1BC,OACAJ,MAAM,gBAAgB,EACtB;YAAE,QAAQ;gBAAE,UAAUA,MAAM,QAAQ,GAAGK,eAAeL,SAAS;YAAK;QAAE,GACtE;YAAE,gBAAgB;QAAK;IAE/B;AACJ;AAEO,MAAMM,wCACTC,gCAAgC,oBAAoB,CAAC;IACjD,gBAAgBX;IAChB,cAAc;QAACY;QAAiBC;KAAmB;AACvD"}
@@ -6,6 +6,6 @@ declare class ValidateWorkflowStateOnEntryBeforePublishImpl implements EntryBefo
6
6
  handle(event: EntryBeforePublishEventHandler.Event): Promise<void>;
7
7
  }
8
8
  export declare const ValidateWorkflowStateOnEntryBeforePublish: typeof ValidateWorkflowStateOnEntryBeforePublishImpl & {
9
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/EventPublisher").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/PublishEntry/events.js").EntryBeforePublishEvent>>;
9
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/PublishEntry/events.js").EntryBeforePublishEvent>>;
10
10
  };
11
11
  export {};
@@ -4,45 +4,43 @@ import { createWorkflowAppName } from "../../../utils/appName.js";
4
4
  import { isModelAllowed } from "../../../utils/modelAllowed.js";
5
5
  import { GetTargetWorkflowStateUseCase } from "@webiny/api-workflows/features/workflowState/GetTargetWorkflowState/index.js";
6
6
  class ValidateWorkflowStateOnEntryBeforePublishImpl {
7
- constructor(getTargetState) {
8
- this.getTargetState = getTargetState;
9
- }
10
- async handle(event) {
11
- const {
12
- model,
13
- entry
14
- } = event.payload;
15
- if (!isModelAllowed(model)) {
16
- return;
7
+ constructor(getTargetState){
8
+ this.getTargetState = getTargetState;
17
9
  }
18
- const app = createWorkflowAppName({
19
- model
20
- });
21
- const stateResult = await this.getTargetState.execute({
22
- app,
23
- targetRevisionId: entry.id
24
- });
25
- if (stateResult.isFail()) {
26
- // If there's no state to deal with, exit early.
27
- return;
10
+ async handle(event) {
11
+ const { model, entry } = event.payload;
12
+ if (!isModelAllowed(model)) return;
13
+ const app = createWorkflowAppName({
14
+ model
15
+ });
16
+ const stateResult = await this.getTargetState.execute({
17
+ app,
18
+ targetRevisionId: entry.id
19
+ });
20
+ if (stateResult.isFail()) return;
21
+ const state = stateResult.value;
22
+ if (state?.done) {
23
+ entry.system = {
24
+ ...entry.system,
25
+ workflow: null
26
+ };
27
+ return;
28
+ }
29
+ throw new WebinyError("Cannot publish entry because its workflow state is not completed.", "WORKFLOW_STATE_NOT_COMPLETED", {
30
+ app,
31
+ entryId: entry.id,
32
+ state: {
33
+ ...state
34
+ }
35
+ });
28
36
  }
29
- const state = stateResult.value;
30
- if (state?.done) {
31
- entry.state = undefined;
32
- return;
33
- }
34
- throw new WebinyError("Cannot publish entry because its workflow state is not completed.", "WORKFLOW_STATE_NOT_COMPLETED", {
35
- app,
36
- entryId: entry.id,
37
- state: {
38
- ...state
39
- }
40
- });
41
- }
42
37
  }
43
- export const ValidateWorkflowStateOnEntryBeforePublish = EntryBeforePublishEventHandler.createImplementation({
44
- implementation: ValidateWorkflowStateOnEntryBeforePublishImpl,
45
- dependencies: [GetTargetWorkflowStateUseCase]
38
+ const ValidateWorkflowStateOnEntryBeforePublish = EntryBeforePublishEventHandler.createImplementation({
39
+ implementation: ValidateWorkflowStateOnEntryBeforePublishImpl,
40
+ dependencies: [
41
+ GetTargetWorkflowStateUseCase
42
+ ]
46
43
  });
44
+ export { ValidateWorkflowStateOnEntryBeforePublish };
47
45
 
48
46
  //# sourceMappingURL=ValidateWorkflowStateOnEntryBeforePublish.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","EntryBeforePublishEventHandler","createWorkflowAppName","isModelAllowed","GetTargetWorkflowStateUseCase","ValidateWorkflowStateOnEntryBeforePublishImpl","constructor","getTargetState","handle","event","model","entry","payload","app","stateResult","execute","targetRevisionId","id","isFail","state","value","done","undefined","entryId","ValidateWorkflowStateOnEntryBeforePublish","createImplementation","implementation","dependencies"],"sources":["ValidateWorkflowStateOnEntryBeforePublish.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { EntryBeforePublishEventHandler } from \"@webiny/api-headless-cms/features/contentEntry/PublishEntry/events.js\";\nimport { createWorkflowAppName } from \"~/utils/appName.js\";\nimport { isModelAllowed } from \"~/utils/modelAllowed.js\";\nimport { GetTargetWorkflowStateUseCase } from \"@webiny/api-workflows/features/workflowState/GetTargetWorkflowState/index.js\";\n\nclass ValidateWorkflowStateOnEntryBeforePublishImpl\n implements EntryBeforePublishEventHandler.Interface\n{\n constructor(private getTargetState: GetTargetWorkflowStateUseCase.Interface) {}\n\n async handle(event: EntryBeforePublishEventHandler.Event): Promise<void> {\n const { model, entry } = event.payload;\n\n if (!isModelAllowed(model)) {\n return;\n }\n\n const app = createWorkflowAppName({ model });\n\n const stateResult = await this.getTargetState.execute({ app, targetRevisionId: entry.id });\n\n if (stateResult.isFail()) {\n // If there's no state to deal with, exit early.\n return;\n }\n\n const state = stateResult.value;\n\n if (state?.done) {\n entry.state = undefined;\n return;\n }\n\n throw new WebinyError(\n \"Cannot publish entry because its workflow state is not completed.\",\n \"WORKFLOW_STATE_NOT_COMPLETED\",\n {\n app,\n entryId: entry.id,\n state: {\n ...state\n }\n }\n );\n }\n}\n\nexport const ValidateWorkflowStateOnEntryBeforePublish =\n EntryBeforePublishEventHandler.createImplementation({\n implementation: ValidateWorkflowStateOnEntryBeforePublishImpl,\n dependencies: [GetTargetWorkflowStateUseCase]\n });\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAC3C,SAASC,8BAA8B,QAAQ,uEAAuE;AACtH,SAASC,qBAAqB;AAC9B,SAASC,cAAc;AACvB,SAASC,6BAA6B,QAAQ,8EAA8E;AAE5H,MAAMC,6CAA6C,CAEnD;EACIC,WAAWA,CAASC,cAAuD,EAAE;IAAA,KAAzDA,cAAuD,GAAvDA,cAAuD;EAAG;EAE9E,MAAMC,MAAMA,CAACC,KAA2C,EAAiB;IACrE,MAAM;MAAEC,KAAK;MAAEC;IAAM,CAAC,GAAGF,KAAK,CAACG,OAAO;IAEtC,IAAI,CAACT,cAAc,CAACO,KAAK,CAAC,EAAE;MACxB;IACJ;IAEA,MAAMG,GAAG,GAAGX,qBAAqB,CAAC;MAAEQ;IAAM,CAAC,CAAC;IAE5C,MAAMI,WAAW,GAAG,MAAM,IAAI,CAACP,cAAc,CAACQ,OAAO,CAAC;MAAEF,GAAG;MAAEG,gBAAgB,EAAEL,KAAK,CAACM;IAAG,CAAC,CAAC;IAE1F,IAAIH,WAAW,CAACI,MAAM,CAAC,CAAC,EAAE;MACtB;MACA;IACJ;IAEA,MAAMC,KAAK,GAAGL,WAAW,CAACM,KAAK;IAE/B,IAAID,KAAK,EAAEE,IAAI,EAAE;MACbV,KAAK,CAACQ,KAAK,GAAGG,SAAS;MACvB;IACJ;IAEA,MAAM,IAAItB,WAAW,CACjB,mEAAmE,EACnE,8BAA8B,EAC9B;MACIa,GAAG;MACHU,OAAO,EAAEZ,KAAK,CAACM,EAAE;MACjBE,KAAK,EAAE;QACH,GAAGA;MACP;IACJ,CACJ,CAAC;EACL;AACJ;AAEA,OAAO,MAAMK,yCAAyC,GAClDvB,8BAA8B,CAACwB,oBAAoB,CAAC;EAChDC,cAAc,EAAErB,6CAA6C;EAC7DsB,YAAY,EAAE,CAACvB,6BAA6B;AAChD,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/EntryWorkflows/handlers/ValidateWorkflowStateOnEntryBeforePublish.js","sources":["../../../../src/features/EntryWorkflows/handlers/ValidateWorkflowStateOnEntryBeforePublish.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { EntryBeforePublishEventHandler } from \"@webiny/api-headless-cms/features/contentEntry/PublishEntry/events.js\";\nimport { createWorkflowAppName } from \"~/utils/appName.js\";\nimport { isModelAllowed } from \"~/utils/modelAllowed.js\";\nimport { GetTargetWorkflowStateUseCase } from \"@webiny/api-workflows/features/workflowState/GetTargetWorkflowState/index.js\";\n\nclass ValidateWorkflowStateOnEntryBeforePublishImpl\n implements EntryBeforePublishEventHandler.Interface\n{\n constructor(private getTargetState: GetTargetWorkflowStateUseCase.Interface) {}\n\n async handle(event: EntryBeforePublishEventHandler.Event): Promise<void> {\n const { model, entry } = event.payload;\n\n if (!isModelAllowed(model)) {\n return;\n }\n\n const app = createWorkflowAppName({ model });\n\n const stateResult = await this.getTargetState.execute({ app, targetRevisionId: entry.id });\n\n if (stateResult.isFail()) {\n // If there's no state to deal with, exit early.\n return;\n }\n\n const state = stateResult.value;\n\n if (state?.done) {\n entry.system = {\n ...entry.system,\n workflow: null\n };\n return;\n }\n\n throw new WebinyError(\n \"Cannot publish entry because its workflow state is not completed.\",\n \"WORKFLOW_STATE_NOT_COMPLETED\",\n {\n app,\n entryId: entry.id,\n state: {\n ...state\n }\n }\n );\n }\n}\n\nexport const ValidateWorkflowStateOnEntryBeforePublish =\n EntryBeforePublishEventHandler.createImplementation({\n implementation: ValidateWorkflowStateOnEntryBeforePublishImpl,\n dependencies: [GetTargetWorkflowStateUseCase]\n });\n"],"names":["ValidateWorkflowStateOnEntryBeforePublishImpl","getTargetState","event","model","entry","isModelAllowed","app","createWorkflowAppName","stateResult","state","WebinyError","ValidateWorkflowStateOnEntryBeforePublish","EntryBeforePublishEventHandler","GetTargetWorkflowStateUseCase"],"mappings":";;;;;AAMA,MAAMA;IAGF,YAAoBC,cAAuD,CAAE;aAAzDA,cAAc,GAAdA;IAA0D;IAE9E,MAAM,OAAOC,KAA2C,EAAiB;QACrE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF,MAAM,OAAO;QAEtC,IAAI,CAACG,eAAeF,QAChB;QAGJ,MAAMG,MAAMC,sBAAsB;YAAEJ;QAAM;QAE1C,MAAMK,cAAc,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YAAEF;YAAK,kBAAkBF,MAAM,EAAE;QAAC;QAExF,IAAII,YAAY,MAAM,IAElB;QAGJ,MAAMC,QAAQD,YAAY,KAAK;QAE/B,IAAIC,OAAO,MAAM;YACbL,MAAM,MAAM,GAAG;gBACX,GAAGA,MAAM,MAAM;gBACf,UAAU;YACd;YACA;QACJ;QAEA,MAAM,IAAIM,YACN,qEACA,gCACA;YACIJ;YACA,SAASF,MAAM,EAAE;YACjB,OAAO;gBACH,GAAGK,KAAK;YACZ;QACJ;IAER;AACJ;AAEO,MAAME,4CACTC,+BAA+B,oBAAoB,CAAC;IAChD,gBAAgBZ;IAChB,cAAc;QAACa;KAA8B;AACjD"}
@@ -1,3 +1 @@
1
1
  export { EntryWorkflowsFeature } from "./feature.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1 +1,4 @@
1
- export declare const WorkflowsFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const WorkflowsFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1,10 +1,11 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { DisallowUnpublishableModelsOnBeforeCreate } from "./handlers/DisallowUnpublishableModelsOnBeforeCreate.js";
3
- export const WorkflowsFeature = createFeature({
4
- name: "CmsWorkflows",
5
- register(container) {
6
- container.register(DisallowUnpublishableModelsOnBeforeCreate);
7
- }
3
+ const WorkflowsFeature = createFeature({
4
+ name: "CmsWorkflows",
5
+ register (container) {
6
+ container.register(DisallowUnpublishableModelsOnBeforeCreate);
7
+ }
8
8
  });
9
+ export { WorkflowsFeature };
9
10
 
10
11
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","DisallowUnpublishableModelsOnBeforeCreate","WorkflowsFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { DisallowUnpublishableModelsOnBeforeCreate } from \"./handlers/DisallowUnpublishableModelsOnBeforeCreate.js\";\n\nexport const WorkflowsFeature = createFeature({\n name: \"CmsWorkflows\",\n register(container) {\n container.register(DisallowUnpublishableModelsOnBeforeCreate);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,yCAAyC;AAElD,OAAO,MAAMC,gBAAgB,GAAGF,aAAa,CAAC;EAC1CG,IAAI,EAAE,cAAc;EACpBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,yCAAyC,CAAC;EACjE;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/Workflows/feature.js","sources":["../../../src/features/Workflows/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { DisallowUnpublishableModelsOnBeforeCreate } from \"./handlers/DisallowUnpublishableModelsOnBeforeCreate.js\";\n\nexport const WorkflowsFeature = createFeature({\n name: \"CmsWorkflows\",\n register(container) {\n container.register(DisallowUnpublishableModelsOnBeforeCreate);\n }\n});\n"],"names":["WorkflowsFeature","createFeature","container","DisallowUnpublishableModelsOnBeforeCreate"],"mappings":";;AAGO,MAAMA,mBAAmBC,cAAc;IAC1C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -6,6 +6,6 @@ declare class DisallowUnpublishableModelsOnBeforeCreateImpl implements WorkflowB
6
6
  handle(event: WorkflowBeforeCreateHandler.Event): Promise<void>;
7
7
  }
8
8
  export declare const DisallowUnpublishableModelsOnBeforeCreate: typeof DisallowUnpublishableModelsOnBeforeCreateImpl & {
9
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/EventPublisher").IEventHandler<import("@webiny/api-workflows/features/workflow/CreateWorkflow/events.js").WorkflowBeforeCreateEvent>>;
9
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-workflows/features/workflow/CreateWorkflow/events.js").WorkflowBeforeCreateEvent>>;
10
10
  };
11
11
  export {};
@@ -2,31 +2,26 @@ import { WorkflowBeforeCreateHandler } from "@webiny/api-workflows/features/work
2
2
  import { getModelIdFromAppName } from "../../../utils/appName.js";
3
3
  import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
4
4
  class DisallowUnpublishableModelsOnBeforeCreateImpl {
5
- constructor(getModelUseCase) {
6
- this.getModelUseCase = getModelUseCase;
7
- }
8
- async handle(event) {
9
- const {
10
- workflow
11
- } = event.payload;
12
- const modelId = getModelIdFromAppName(workflow.app);
13
- if (!modelId) {
14
- return;
5
+ constructor(getModelUseCase){
6
+ this.getModelUseCase = getModelUseCase;
15
7
  }
16
- const model = await this.getModelUseCase.execute(modelId);
17
- if (model.isFail()) {
18
- return;
8
+ async handle(event) {
9
+ const { workflow } = event.payload;
10
+ const modelId = getModelIdFromAppName(workflow.app);
11
+ if (!modelId) return;
12
+ const model = await this.getModelUseCase.execute(modelId);
13
+ if (model.isFail()) return;
14
+ const tags = model.value.tags || [];
15
+ if (false === tags.includes("$publishing:false")) return;
16
+ throw new Error(`Cannot create a workflow for the model "${modelId}" because it is marked as unpublishable.`);
19
17
  }
20
- const tags = model.value.tags || [];
21
- if (tags.includes("$publishing:false") === false) {
22
- return;
23
- }
24
- throw new Error(`Cannot create a workflow for the model "${modelId}" because it is marked as unpublishable.`);
25
- }
26
18
  }
27
- export const DisallowUnpublishableModelsOnBeforeCreate = WorkflowBeforeCreateHandler.createImplementation({
28
- implementation: DisallowUnpublishableModelsOnBeforeCreateImpl,
29
- dependencies: [GetModelUseCase]
19
+ const DisallowUnpublishableModelsOnBeforeCreate = WorkflowBeforeCreateHandler.createImplementation({
20
+ implementation: DisallowUnpublishableModelsOnBeforeCreateImpl,
21
+ dependencies: [
22
+ GetModelUseCase
23
+ ]
30
24
  });
25
+ export { DisallowUnpublishableModelsOnBeforeCreate };
31
26
 
32
27
  //# sourceMappingURL=DisallowUnpublishableModelsOnBeforeCreate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WorkflowBeforeCreateHandler","getModelIdFromAppName","GetModelUseCase","DisallowUnpublishableModelsOnBeforeCreateImpl","constructor","getModelUseCase","handle","event","workflow","payload","modelId","app","model","execute","isFail","tags","value","includes","Error","DisallowUnpublishableModelsOnBeforeCreate","createImplementation","implementation","dependencies"],"sources":["DisallowUnpublishableModelsOnBeforeCreate.ts"],"sourcesContent":["import { WorkflowBeforeCreateHandler } from \"@webiny/api-workflows/features/workflow/CreateWorkflow/events.js\";\nimport { getModelIdFromAppName } from \"~/utils/appName.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\n\nclass DisallowUnpublishableModelsOnBeforeCreateImpl\n implements WorkflowBeforeCreateHandler.Interface\n{\n public constructor(private getModelUseCase: GetModelUseCase.Interface) {}\n\n public async handle(event: WorkflowBeforeCreateHandler.Event): Promise<void> {\n const { workflow } = event.payload;\n const modelId = getModelIdFromAppName(workflow.app);\n if (!modelId) {\n return;\n }\n const model = await this.getModelUseCase.execute(modelId);\n if (model.isFail()) {\n return;\n }\n const tags = model.value.tags || [];\n if (tags.includes(\"$publishing:false\") === false) {\n return;\n }\n throw new Error(\n `Cannot create a workflow for the model \"${modelId}\" because it is marked as unpublishable.`\n );\n }\n}\n\nexport const DisallowUnpublishableModelsOnBeforeCreate =\n WorkflowBeforeCreateHandler.createImplementation({\n implementation: DisallowUnpublishableModelsOnBeforeCreateImpl,\n dependencies: [GetModelUseCase]\n });\n"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,kEAAkE;AAC9G,SAASC,qBAAqB;AAC9B,SAASC,eAAe,QAAQ,kEAAkE;AAElG,MAAMC,6CAA6C,CAEnD;EACWC,WAAWA,CAASC,eAA0C,EAAE;IAAA,KAA5CA,eAA0C,GAA1CA,eAA0C;EAAG;EAExE,MAAaC,MAAMA,CAACC,KAAwC,EAAiB;IACzE,MAAM;MAAEC;IAAS,CAAC,GAAGD,KAAK,CAACE,OAAO;IAClC,MAAMC,OAAO,GAAGT,qBAAqB,CAACO,QAAQ,CAACG,GAAG,CAAC;IACnD,IAAI,CAACD,OAAO,EAAE;MACV;IACJ;IACA,MAAME,KAAK,GAAG,MAAM,IAAI,CAACP,eAAe,CAACQ,OAAO,CAACH,OAAO,CAAC;IACzD,IAAIE,KAAK,CAACE,MAAM,CAAC,CAAC,EAAE;MAChB;IACJ;IACA,MAAMC,IAAI,GAAGH,KAAK,CAACI,KAAK,CAACD,IAAI,IAAI,EAAE;IACnC,IAAIA,IAAI,CAACE,QAAQ,CAAC,mBAAmB,CAAC,KAAK,KAAK,EAAE;MAC9C;IACJ;IACA,MAAM,IAAIC,KAAK,CACX,2CAA2CR,OAAO,0CACtD,CAAC;EACL;AACJ;AAEA,OAAO,MAAMS,yCAAyC,GAClDnB,2BAA2B,CAACoB,oBAAoB,CAAC;EAC7CC,cAAc,EAAElB,6CAA6C;EAC7DmB,YAAY,EAAE,CAACpB,eAAe;AAClC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/Workflows/handlers/DisallowUnpublishableModelsOnBeforeCreate.js","sources":["../../../../src/features/Workflows/handlers/DisallowUnpublishableModelsOnBeforeCreate.ts"],"sourcesContent":["import { WorkflowBeforeCreateHandler } from \"@webiny/api-workflows/features/workflow/CreateWorkflow/events.js\";\nimport { getModelIdFromAppName } from \"~/utils/appName.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\n\nclass DisallowUnpublishableModelsOnBeforeCreateImpl\n implements WorkflowBeforeCreateHandler.Interface\n{\n public constructor(private getModelUseCase: GetModelUseCase.Interface) {}\n\n public async handle(event: WorkflowBeforeCreateHandler.Event): Promise<void> {\n const { workflow } = event.payload;\n const modelId = getModelIdFromAppName(workflow.app);\n if (!modelId) {\n return;\n }\n const model = await this.getModelUseCase.execute(modelId);\n if (model.isFail()) {\n return;\n }\n const tags = model.value.tags || [];\n if (tags.includes(\"$publishing:false\") === false) {\n return;\n }\n throw new Error(\n `Cannot create a workflow for the model \"${modelId}\" because it is marked as unpublishable.`\n );\n }\n}\n\nexport const DisallowUnpublishableModelsOnBeforeCreate =\n WorkflowBeforeCreateHandler.createImplementation({\n implementation: DisallowUnpublishableModelsOnBeforeCreateImpl,\n dependencies: [GetModelUseCase]\n });\n"],"names":["DisallowUnpublishableModelsOnBeforeCreateImpl","getModelUseCase","event","workflow","modelId","getModelIdFromAppName","model","tags","Error","DisallowUnpublishableModelsOnBeforeCreate","WorkflowBeforeCreateHandler","GetModelUseCase"],"mappings":";;;AAIA,MAAMA;IAGF,YAA2BC,eAA0C,CAAE;aAA5CA,eAAe,GAAfA;IAA6C;IAExE,MAAa,OAAOC,KAAwC,EAAiB;QACzE,MAAM,EAAEC,QAAQ,EAAE,GAAGD,MAAM,OAAO;QAClC,MAAME,UAAUC,sBAAsBF,SAAS,GAAG;QAClD,IAAI,CAACC,SACD;QAEJ,MAAME,QAAQ,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAACF;QACjD,IAAIE,MAAM,MAAM,IACZ;QAEJ,MAAMC,OAAOD,MAAM,KAAK,CAAC,IAAI,IAAI,EAAE;QACnC,IAAIC,AAAuC,UAAvCA,KAAK,QAAQ,CAAC,sBACd;QAEJ,MAAM,IAAIC,MACN,CAAC,wCAAwC,EAAEJ,QAAQ,wCAAwC,CAAC;IAEpG;AACJ;AAEO,MAAMK,4CACTC,4BAA4B,oBAAoB,CAAC;IAC7C,gBAAgBV;IAChB,cAAc;QAACW;KAAgB;AACnC"}
@@ -1,3 +1 @@
1
1
  export { WorkflowsFeature } from "./feature.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import { CmsGraphQLSchemaPlugin } from "@webiny/api-headless-cms/plugins/index.js";
2
+ export declare const createEntrySystemSchemaExtension: () => CmsGraphQLSchemaPlugin<import("@webiny/api-headless-cms/types").CmsContext>;
@@ -0,0 +1,18 @@
1
+ import { CmsGraphQLSchemaPlugin } from "@webiny/api-headless-cms/plugins/index.js";
2
+ const createEntrySystemSchemaExtension = ()=>new CmsGraphQLSchemaPlugin({
3
+ typeDefs: `
4
+ type CmsEntrySystemWorkflow {
5
+ workflowId: String
6
+ stepId: ID
7
+ stepName: String
8
+ state: String
9
+ }
10
+
11
+ extend type CmsEntrySystem {
12
+ workflow: CmsEntrySystemWorkflow
13
+ }
14
+ `
15
+ });
16
+ export { createEntrySystemSchemaExtension };
17
+
18
+ //# sourceMappingURL=entrySystemSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql/entrySystemSchema.js","sources":["../../src/graphql/entrySystemSchema.ts"],"sourcesContent":["import { CmsGraphQLSchemaPlugin } from \"@webiny/api-headless-cms/plugins/index.js\";\n\nexport const createEntrySystemSchemaExtension = () => {\n return new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsEntrySystemWorkflow {\n workflowId: String\n stepId: ID\n stepName: String\n state: String\n }\n\n extend type CmsEntrySystem {\n workflow: CmsEntrySystemWorkflow\n }\n `\n });\n};\n"],"names":["createEntrySystemSchemaExtension","CmsGraphQLSchemaPlugin"],"mappings":";AAEO,MAAMA,mCAAmC,IACrC,IAAIC,uBAAuB;QAC9B,UAAwB,CAAC;;;;;;;;;;;QAWzB,CAAC;IACL"}
package/index.js CHANGED
@@ -2,19 +2,18 @@ import { createContextPlugin } from "@webiny/api";
2
2
  import { EntryWorkflowsFeature } from "./features/EntryWorkflows/feature.js";
3
3
  import { WcpContext } from "@webiny/api-core/features/wcp/WcpContext/index.js";
4
4
  import { WorkflowsFeature } from "./features/Workflows/index.js";
5
- export const createHeadlessCmsWorkflows = () => {
6
- const plugin = createContextPlugin(async context => {
7
- const wcpContext = context.container.resolve(WcpContext);
8
- if (!wcpContext.canUseWorkflows()) {
9
- return;
10
- }
11
-
12
- // Register features
13
- EntryWorkflowsFeature.register(context.container, context);
14
- WorkflowsFeature.register(context.container);
15
- });
16
- plugin.name = "headless-cms-workflows.context";
17
- return plugin;
5
+ import { createEntrySystemSchemaExtension } from "./graphql/entrySystemSchema.js";
6
+ const createHeadlessCmsWorkflows = ()=>{
7
+ const plugin = createContextPlugin(async (context)=>{
8
+ const wcpContext = context.container.resolve(WcpContext);
9
+ if (!wcpContext.canUseWorkflows()) return;
10
+ EntryWorkflowsFeature.register(context.container);
11
+ WorkflowsFeature.register(context.container);
12
+ context.plugins.register(createEntrySystemSchemaExtension());
13
+ });
14
+ plugin.name = "headless-cms-workflows.context";
15
+ return plugin;
18
16
  };
17
+ export { createHeadlessCmsWorkflows };
19
18
 
20
19
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["createContextPlugin","EntryWorkflowsFeature","WcpContext","WorkflowsFeature","createHeadlessCmsWorkflows","plugin","context","wcpContext","container","resolve","canUseWorkflows","register","name"],"sources":["index.ts"],"sourcesContent":["import { createContextPlugin } from \"@webiny/api\";\nimport { EntryWorkflowsFeature } from \"./features/EntryWorkflows/feature.js\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport { WorkflowsFeature } from \"~/features/Workflows/index.js\";\n\nexport const createHeadlessCmsWorkflows = () => {\n const plugin = createContextPlugin(async context => {\n const wcpContext = context.container.resolve(WcpContext);\n\n if (!wcpContext.canUseWorkflows()) {\n return;\n }\n\n // Register features\n EntryWorkflowsFeature.register(context.container, context);\n WorkflowsFeature.register(context.container);\n });\n\n plugin.name = \"headless-cms-workflows.context\";\n\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,aAAa;AACjD,SAASC,qBAAqB;AAC9B,SAASC,UAAU,QAAQ,mDAAmD;AAC9E,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,0BAA0B,GAAGA,CAAA,KAAM;EAC5C,MAAMC,MAAM,GAAGL,mBAAmB,CAAC,MAAMM,OAAO,IAAI;IAChD,MAAMC,UAAU,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACP,UAAU,CAAC;IAExD,IAAI,CAACK,UAAU,CAACG,eAAe,CAAC,CAAC,EAAE;MAC/B;IACJ;;IAEA;IACAT,qBAAqB,CAACU,QAAQ,CAACL,OAAO,CAACE,SAAS,EAAEF,OAAO,CAAC;IAC1DH,gBAAgB,CAACQ,QAAQ,CAACL,OAAO,CAACE,SAAS,CAAC;EAChD,CAAC,CAAC;EAEFH,MAAM,CAACO,IAAI,GAAG,gCAAgC;EAE9C,OAAOP,MAAM;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createContextPlugin } from \"@webiny/api\";\nimport { EntryWorkflowsFeature } from \"./features/EntryWorkflows/feature.js\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport { WorkflowsFeature } from \"~/features/Workflows/index.js\";\nimport { createEntrySystemSchemaExtension } from \"~/graphql/entrySystemSchema.js\";\n\nexport const createHeadlessCmsWorkflows = () => {\n const plugin = createContextPlugin(async context => {\n const wcpContext = context.container.resolve(WcpContext);\n\n if (!wcpContext.canUseWorkflows()) {\n return;\n }\n\n // Register features\n EntryWorkflowsFeature.register(context.container);\n WorkflowsFeature.register(context.container);\n\n // Extend CMS schema with workflow system fields\n context.plugins.register(createEntrySystemSchemaExtension());\n });\n\n plugin.name = \"headless-cms-workflows.context\";\n\n return plugin;\n};\n"],"names":["createHeadlessCmsWorkflows","plugin","createContextPlugin","context","wcpContext","WcpContext","EntryWorkflowsFeature","WorkflowsFeature","createEntrySystemSchemaExtension"],"mappings":";;;;;AAMO,MAAMA,6BAA6B;IACtC,MAAMC,SAASC,oBAAoB,OAAMC;QACrC,MAAMC,aAAaD,QAAQ,SAAS,CAAC,OAAO,CAACE;QAE7C,IAAI,CAACD,WAAW,eAAe,IAC3B;QAIJE,sBAAsB,QAAQ,CAACH,QAAQ,SAAS;QAChDI,iBAAiB,QAAQ,CAACJ,QAAQ,SAAS;QAG3CA,QAAQ,OAAO,CAAC,QAAQ,CAACK;IAC7B;IAEAP,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-workflows",
3
- "version": "0.0.0-unstable.ac6ebf63c6",
3
+ "version": "0.0.0-unstable.b6d7105cee",
4
4
  "type": "module",
5
- "main": "index.js",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
6
9
  "description": "Headless CMS Workflows",
7
10
  "keywords": [
8
11
  "api-headless-cms-workflows:base"
@@ -14,25 +17,29 @@
14
17
  },
15
18
  "license": "MIT",
16
19
  "dependencies": {
17
- "@webiny/api": "0.0.0-unstable.ac6ebf63c6",
18
- "@webiny/api-core": "0.0.0-unstable.ac6ebf63c6",
19
- "@webiny/api-headless-cms": "0.0.0-unstable.ac6ebf63c6",
20
- "@webiny/api-workflows": "0.0.0-unstable.ac6ebf63c6",
21
- "@webiny/error": "0.0.0-unstable.ac6ebf63c6",
22
- "@webiny/feature": "0.0.0-unstable.ac6ebf63c6"
20
+ "@webiny/api": "0.0.0-unstable.b6d7105cee",
21
+ "@webiny/api-aco": "0.0.0-unstable.b6d7105cee",
22
+ "@webiny/api-core": "0.0.0-unstable.b6d7105cee",
23
+ "@webiny/api-headless-cms": "0.0.0-unstable.b6d7105cee",
24
+ "@webiny/api-workflows": "0.0.0-unstable.b6d7105cee",
25
+ "@webiny/error": "0.0.0-unstable.b6d7105cee",
26
+ "@webiny/feature": "0.0.0-unstable.b6d7105cee",
27
+ "@webiny/shared-aco": "0.0.0-unstable.b6d7105cee"
23
28
  },
24
29
  "devDependencies": {
25
- "@webiny/build-tools": "0.0.0-unstable.ac6ebf63c6",
26
- "@webiny/plugins": "0.0.0-unstable.ac6ebf63c6",
27
- "@webiny/project-utils": "0.0.0-unstable.ac6ebf63c6",
28
- "@webiny/testing": "0.0.0-unstable.ac6ebf63c6",
29
- "@webiny/wcp": "0.0.0-unstable.ac6ebf63c6",
30
- "typescript": "5.9.3",
31
- "vitest": "3.2.4"
30
+ "@webiny/build-tools": "0.0.0-unstable.b6d7105cee",
31
+ "@webiny/handler": "0.0.0-unstable.b6d7105cee",
32
+ "@webiny/plugins": "0.0.0-unstable.b6d7105cee",
33
+ "@webiny/project-utils": "0.0.0-unstable.b6d7105cee",
34
+ "@webiny/testing": "0.0.0-unstable.b6d7105cee",
35
+ "@webiny/wcp": "0.0.0-unstable.b6d7105cee",
36
+ "typescript": "7.0.2",
37
+ "vitest": "4.1.10"
32
38
  },
33
39
  "publishConfig": {
34
- "access": "public",
35
- "directory": "dist"
40
+ "access": "public"
36
41
  },
37
- "gitHead": "ac6ebf63c6de308703d41f2c1b375e03cd96b813"
42
+ "webiny": {
43
+ "publishFrom": "dist"
44
+ }
38
45
  }
package/utils/appName.js CHANGED
@@ -1,14 +1,9 @@
1
- export const createWorkflowAppName = ({
2
- model
3
- }) => {
4
- return `cms.${model.modelId}`;
5
- };
6
- export const getModelIdFromAppName = app => {
7
- const matched = app.match(/^cms\.([a-zA-Z0-9_-]+)$/);
8
- if (!matched) {
9
- return null;
10
- }
11
- return matched ? matched[1] : null;
1
+ const createWorkflowAppName = ({ model })=>`cms.${model.modelId}`;
2
+ const getModelIdFromAppName = (app)=>{
3
+ const matched = app.match(/^cms\.([a-zA-Z0-9_-]+)$/);
4
+ if (!matched) return null;
5
+ return matched ? matched[1] : null;
12
6
  };
7
+ export { createWorkflowAppName, getModelIdFromAppName };
13
8
 
14
9
  //# sourceMappingURL=appName.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createWorkflowAppName","model","modelId","getModelIdFromAppName","app","matched","match"],"sources":["appName.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface IParams {\n model: Pick<CmsModel, \"modelId\">;\n}\nexport const createWorkflowAppName = ({ model }: IParams): string => {\n return `cms.${model.modelId}`;\n};\n\nexport const getModelIdFromAppName = (app: string): string | null => {\n const matched = app.match(/^cms\\.([a-zA-Z0-9_-]+)$/);\n if (!matched) {\n return null;\n }\n return matched ? matched[1] : null;\n};\n"],"mappings":"AAKA,OAAO,MAAMA,qBAAqB,GAAGA,CAAC;EAAEC;AAAe,CAAC,KAAa;EACjE,OAAO,OAAOA,KAAK,CAACC,OAAO,EAAE;AACjC,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAIC,GAAW,IAAoB;EACjE,MAAMC,OAAO,GAAGD,GAAG,CAACE,KAAK,CAAC,yBAAyB,CAAC;EACpD,IAAI,CAACD,OAAO,EAAE;IACV,OAAO,IAAI;EACf;EACA,OAAOA,OAAO,GAAGA,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI;AACtC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/appName.js","sources":["../../src/utils/appName.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface IParams {\n model: Pick<CmsModel, \"modelId\">;\n}\nexport const createWorkflowAppName = ({ model }: IParams): string => {\n return `cms.${model.modelId}`;\n};\n\nexport const getModelIdFromAppName = (app: string): string | null => {\n const matched = app.match(/^cms\\.([a-zA-Z0-9_-]+)$/);\n if (!matched) {\n return null;\n }\n return matched ? matched[1] : null;\n};\n"],"names":["createWorkflowAppName","model","getModelIdFromAppName","app","matched"],"mappings":"AAKO,MAAMA,wBAAwB,CAAC,EAAEC,KAAK,EAAW,GAC7C,CAAC,IAAI,EAAEA,MAAM,OAAO,EAAE;AAG1B,MAAMC,wBAAwB,CAACC;IAClC,MAAMC,UAAUD,IAAI,KAAK,CAAC;IAC1B,IAAI,CAACC,SACD,OAAO;IAEX,OAAOA,UAAUA,OAAO,CAAC,EAAE,GAAG;AAClC"}
@@ -1,13 +1,9 @@
1
1
  import { CMS_MODEL_SINGLETON_TAG } from "@webiny/api-headless-cms/constants.js";
2
- export const isModelAllowed = model => {
3
- if (model.isPrivate) {
4
- return false;
5
- }
6
- // TODO remove when we allow singleton models to have workflows.
7
- else if (model.tags?.includes(CMS_MODEL_SINGLETON_TAG)) {
8
- return false;
9
- }
10
- return true;
2
+ const isModelAllowed = (model)=>{
3
+ if (model.isPrivate) return false;
4
+ if (model.tags?.includes(CMS_MODEL_SINGLETON_TAG)) return false;
5
+ return true;
11
6
  };
7
+ export { isModelAllowed };
12
8
 
13
9
  //# sourceMappingURL=modelAllowed.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CMS_MODEL_SINGLETON_TAG","isModelAllowed","model","isPrivate","tags","includes"],"sources":["modelAllowed.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\n\nexport const isModelAllowed = (model: Pick<CmsModel, \"isPrivate\" | \"tags\">): boolean => {\n if (model.isPrivate) {\n return false;\n }\n // TODO remove when we allow singleton models to have workflows.\n else if (model.tags?.includes(CMS_MODEL_SINGLETON_TAG)) {\n return false;\n }\n return true;\n};\n"],"mappings":"AACA,SAASA,uBAAuB,QAAQ,uCAAuC;AAE/E,OAAO,MAAMC,cAAc,GAAIC,KAA2C,IAAc;EACpF,IAAIA,KAAK,CAACC,SAAS,EAAE;IACjB,OAAO,KAAK;EAChB;EACA;EAAA,KACK,IAAID,KAAK,CAACE,IAAI,EAAEC,QAAQ,CAACL,uBAAuB,CAAC,EAAE;IACpD,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/modelAllowed.js","sources":["../../src/utils/modelAllowed.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/api-headless-cms/constants.js\";\n\nexport const isModelAllowed = (model: Pick<CmsModel, \"isPrivate\" | \"tags\">): boolean => {\n if (model.isPrivate) {\n return false;\n }\n // TODO remove when we allow singleton models to have workflows.\n else if (model.tags?.includes(CMS_MODEL_SINGLETON_TAG)) {\n return false;\n }\n return true;\n};\n"],"names":["isModelAllowed","model","CMS_MODEL_SINGLETON_TAG"],"mappings":";AAGO,MAAMA,iBAAiB,CAACC;IAC3B,IAAIA,MAAM,SAAS,EACf,OAAO;IAGN,IAAIA,MAAM,IAAI,EAAE,SAASC,0BAC1B,OAAO;IAEX,OAAO;AACX"}