@webiny/api-workflows 0.0.0-unstable.0d717d18dd → 0.0.0-unstable.5387e5f7c8
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.
- package/WorkflowsFeature.js +55 -2
- package/WorkflowsFeature.js.map +1 -1
- package/WorkflowsSchemaFactory.d.ts +1 -0
- package/WorkflowsSchemaFactory.js +4 -0
- package/WorkflowsSchemaFactory.js.map +1 -1
- package/domain/workflow/abstractions.d.ts +13 -3
- package/domain/workflow/abstractions.js +2 -2
- package/domain/workflow/abstractions.js.map +1 -1
- package/domain/workflow/workflowModel.js +2 -1
- package/domain/workflow/workflowModel.js.map +1 -1
- package/domain/workflowState/abstractions.d.ts +13 -3
- package/domain/workflowState/abstractions.js +2 -2
- package/domain/workflowState/abstractions.js.map +1 -1
- package/domain/workflowState/stateModel.js +2 -1
- package/domain/workflowState/stateModel.js.map +1 -1
- package/features/WorkflowModelProviders.d.ts +34 -0
- package/features/WorkflowModelProviders.js +40 -0
- package/features/WorkflowModelProviders.js.map +1 -0
- package/features/workflow/CreateWorkflow/CreateWorkflowRepository.d.ts +3 -3
- package/features/workflow/CreateWorkflow/CreateWorkflowRepository.js +6 -5
- package/features/workflow/CreateWorkflow/CreateWorkflowRepository.js.map +1 -1
- package/features/workflow/DeleteWorkflow/DeleteWorkflowRepository.d.ts +3 -3
- package/features/workflow/DeleteWorkflow/DeleteWorkflowRepository.js +6 -5
- package/features/workflow/DeleteWorkflow/DeleteWorkflowRepository.js.map +1 -1
- package/features/workflow/GetWorkflow/GetWorkflowRepository.d.ts +3 -3
- package/features/workflow/GetWorkflow/GetWorkflowRepository.js +6 -5
- package/features/workflow/GetWorkflow/GetWorkflowRepository.js.map +1 -1
- package/features/workflow/ListWorkflows/ListWorkflowsRepository.d.ts +3 -3
- package/features/workflow/ListWorkflows/ListWorkflowsRepository.js +7 -6
- package/features/workflow/ListWorkflows/ListWorkflowsRepository.js.map +1 -1
- package/features/workflow/UpdateWorkflow/UpdateWorkflowRepository.d.ts +3 -3
- package/features/workflow/UpdateWorkflow/UpdateWorkflowRepository.js +6 -5
- package/features/workflow/UpdateWorkflow/UpdateWorkflowRepository.js.map +1 -1
- package/features/workflowState/CreateWorkflowState/CreateWorkflowStateRepository.d.ts +3 -3
- package/features/workflowState/CreateWorkflowState/CreateWorkflowStateRepository.js +6 -5
- package/features/workflowState/CreateWorkflowState/CreateWorkflowStateRepository.js.map +1 -1
- package/features/workflowState/DeleteWorkflowState/DeleteWorkflowStateRepository.d.ts +3 -3
- package/features/workflowState/DeleteWorkflowState/DeleteWorkflowStateRepository.js +6 -5
- package/features/workflowState/DeleteWorkflowState/DeleteWorkflowStateRepository.js.map +1 -1
- package/features/workflowState/GetTargetWorkflowState/GetTargetWorkflowStateRepository.d.ts +3 -3
- package/features/workflowState/GetTargetWorkflowState/GetTargetWorkflowStateRepository.js +6 -5
- package/features/workflowState/GetTargetWorkflowState/GetTargetWorkflowStateRepository.js.map +1 -1
- package/features/workflowState/GetWorkflowState/GetWorkflowStateRepository.d.ts +3 -3
- package/features/workflowState/GetWorkflowState/GetWorkflowStateRepository.js +6 -5
- package/features/workflowState/GetWorkflowState/GetWorkflowStateRepository.js.map +1 -1
- package/features/workflowState/ListWorkflowStates/ListWorkflowStatesRepository.d.ts +3 -3
- package/features/workflowState/ListWorkflowStates/ListWorkflowStatesRepository.js +7 -6
- package/features/workflowState/ListWorkflowStates/ListWorkflowStatesRepository.js.map +1 -1
- package/features/workflowState/UpdateWorkflowState/UpdateWorkflowStateRepository.d.ts +3 -3
- package/features/workflowState/UpdateWorkflowState/UpdateWorkflowStateRepository.js +7 -6
- package/features/workflowState/UpdateWorkflowState/UpdateWorkflowStateRepository.js.map +1 -1
- package/package.json +13 -16
- package/WorkflowsInitializer.d.ts +0 -19
- package/WorkflowsInitializer.js +0 -97
- package/WorkflowsInitializer.js.map +0 -1
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js";
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js";
|
|
4
|
-
import { WorkflowStateMapper,
|
|
4
|
+
import { WorkflowStateMapper, WorkflowStateModelProvider } from "../../../domain/workflowState/abstractions.js";
|
|
5
5
|
import { WorkflowStateNotFoundError, WorkflowStatePersistenceError } from "../../../domain/workflowState/errors.js";
|
|
6
6
|
import { UpdateWorkflowStateRepository } from "./abstractions.js";
|
|
7
7
|
class UpdateWorkflowStateRepositoryImpl {
|
|
8
|
-
constructor(getEntryById, updateEntry,
|
|
8
|
+
constructor(getEntryById, updateEntry, modelProvider, mapper){
|
|
9
9
|
this.getEntryById = getEntryById;
|
|
10
10
|
this.updateEntry = updateEntry;
|
|
11
|
-
this.
|
|
11
|
+
this.modelProvider = modelProvider;
|
|
12
12
|
this.mapper = mapper;
|
|
13
13
|
}
|
|
14
14
|
async execute(id, input) {
|
|
15
|
-
const
|
|
15
|
+
const model = await this.modelProvider.get();
|
|
16
|
+
const getResult = await this.getEntryById.execute(model, id);
|
|
16
17
|
if (getResult.isFail()) {
|
|
17
18
|
if ("Cms/Entry/NotFound" === getResult.error.code) return Result.fail(new WorkflowStateNotFoundError({
|
|
18
19
|
id
|
|
@@ -25,7 +26,7 @@ class UpdateWorkflowStateRepositoryImpl {
|
|
|
25
26
|
...input
|
|
26
27
|
});
|
|
27
28
|
try {
|
|
28
|
-
const updateResult = await this.updateEntry.execute(
|
|
29
|
+
const updateResult = await this.updateEntry.execute(model, id, {
|
|
29
30
|
values: updatedValues
|
|
30
31
|
});
|
|
31
32
|
if (updateResult.isFail()) return Result.fail(new WorkflowStatePersistenceError(updateResult.error));
|
|
@@ -41,7 +42,7 @@ const UpdateWorkflowStateRepository_UpdateWorkflowStateRepository = UpdateWorkfl
|
|
|
41
42
|
dependencies: [
|
|
42
43
|
GetEntryByIdUseCase,
|
|
43
44
|
UpdateEntryUseCase,
|
|
44
|
-
|
|
45
|
+
WorkflowStateModelProvider,
|
|
45
46
|
WorkflowStateMapper
|
|
46
47
|
]
|
|
47
48
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/workflowState/UpdateWorkflowState/UpdateWorkflowStateRepository.js","sources":["../../../../src/features/workflowState/UpdateWorkflowState/UpdateWorkflowStateRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/workflowState/UpdateWorkflowState/UpdateWorkflowStateRepository.js","sources":["../../../../src/features/workflowState/UpdateWorkflowState/UpdateWorkflowStateRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport {\n WorkflowStateModelProvider,\n WorkflowStateMapper\n} from \"~/domain/workflowState/abstractions.js\";\nimport type { IWorkflowStateRecord } from \"~/domain/workflowState/abstractions.js\";\nimport {\n WorkflowStateNotFoundError,\n WorkflowStatePersistenceError\n} from \"~/domain/workflowState/errors.js\";\nimport { UpdateWorkflowStateRepository as Repository } from \"./abstractions.js\";\nimport type { IUpdateWorkflowStateInput } from \"./abstractions.js\";\n\nclass UpdateWorkflowStateRepositoryImpl implements Repository.Interface {\n constructor(\n private getEntryById: GetEntryByIdUseCase.Interface,\n private updateEntry: UpdateEntryUseCase.Interface,\n private modelProvider: WorkflowStateModelProvider.Interface,\n private mapper: WorkflowStateMapper.Interface\n ) {}\n\n async execute(id: string, input: IUpdateWorkflowStateInput): Repository.Return {\n const model = await this.modelProvider.get();\n const getResult = await this.getEntryById.execute<Omit<IWorkflowStateRecord, \"id\">>(\n model,\n id\n );\n\n if (getResult.isFail()) {\n if (getResult.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(\n new WorkflowStateNotFoundError({\n id\n })\n );\n }\n return Result.fail(new WorkflowStatePersistenceError(getResult.error));\n }\n\n const originalRecord = this.mapper.fromCmsEntry(getResult.value);\n\n const updatedValues = this.mapper.toCmsEntry({\n ...originalRecord,\n ...input\n });\n\n try {\n const updateResult = await this.updateEntry.execute<Repository.Input>(model, id, {\n values: updatedValues\n });\n\n if (updateResult.isFail()) {\n return Result.fail(new WorkflowStatePersistenceError(updateResult.error));\n }\n\n const updatedRecord = this.mapper.fromCmsEntry(updateResult.value);\n return Result.ok(updatedRecord);\n } catch (error) {\n return Result.fail(new WorkflowStatePersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateWorkflowStateRepository = Repository.createImplementation({\n implementation: UpdateWorkflowStateRepositoryImpl,\n dependencies: [\n GetEntryByIdUseCase,\n UpdateEntryUseCase,\n WorkflowStateModelProvider,\n WorkflowStateMapper\n ]\n});\n"],"names":["UpdateWorkflowStateRepositoryImpl","getEntryById","updateEntry","modelProvider","mapper","id","input","model","getResult","Result","WorkflowStateNotFoundError","WorkflowStatePersistenceError","originalRecord","updatedValues","updateResult","updatedRecord","error","UpdateWorkflowStateRepository","Repository","GetEntryByIdUseCase","UpdateEntryUseCase","WorkflowStateModelProvider","WorkflowStateMapper"],"mappings":";;;;;;AAeA,MAAMA;IACF,YACYC,YAA2C,EAC3CC,WAAyC,EACzCC,aAAmD,EACnDC,MAAqC,CAC/C;aAJUH,YAAY,GAAZA;aACAC,WAAW,GAAXA;aACAC,aAAa,GAAbA;aACAC,MAAM,GAANA;IACT;IAEH,MAAM,QAAQC,EAAU,EAAEC,KAAgC,EAAqB;QAC3E,MAAMC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG;QAC1C,MAAMC,YAAY,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAC7CD,OACAF;QAGJ,IAAIG,UAAU,MAAM,IAAI;YACpB,IAAIA,AAAyB,yBAAzBA,UAAU,KAAK,CAAC,IAAI,EACpB,OAAOC,OAAO,IAAI,CACd,IAAIC,2BAA2B;gBAC3BL;YACJ;YAGR,OAAOI,OAAO,IAAI,CAAC,IAAIE,8BAA8BH,UAAU,KAAK;QACxE;QAEA,MAAMI,iBAAiB,IAAI,CAAC,MAAM,CAAC,YAAY,CAACJ,UAAU,KAAK;QAE/D,MAAMK,gBAAgB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;YACzC,GAAGD,cAAc;YACjB,GAAGN,KAAK;QACZ;QAEA,IAAI;YACA,MAAMQ,eAAe,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAmBP,OAAOF,IAAI;gBAC7E,QAAQQ;YACZ;YAEA,IAAIC,aAAa,MAAM,IACnB,OAAOL,OAAO,IAAI,CAAC,IAAIE,8BAA8BG,aAAa,KAAK;YAG3E,MAAMC,gBAAgB,IAAI,CAAC,MAAM,CAAC,YAAY,CAACD,aAAa,KAAK;YACjE,OAAOL,OAAO,EAAE,CAACM;QACrB,EAAE,OAAOC,OAAO;YACZ,OAAOP,OAAO,IAAI,CAAC,IAAIE,8BAA8BK;QACzD;IACJ;AACJ;AAEO,MAAMC,8DAAgCC,8BAAAA,oBAA+B,CAAC;IACzE,gBAAgBlB;IAChB,cAAc;QACVmB;QACAC;QACAC;QACAC;KACH;AACL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-workflows",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.5387e5f7c8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -17,27 +17,24 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@webiny/api": "0.0.0-unstable.
|
|
21
|
-
"@webiny/api-core": "0.0.0-unstable.
|
|
22
|
-
"@webiny/api-graphql": "0.0.0-unstable.
|
|
23
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
24
|
-
"@webiny/api-mailer": "0.0.0-unstable.
|
|
25
|
-
"@webiny/
|
|
26
|
-
"@webiny/
|
|
27
|
-
"@webiny/feature": "0.0.0-unstable.0d717d18dd",
|
|
28
|
-
"@webiny/utils": "0.0.0-unstable.0d717d18dd",
|
|
20
|
+
"@webiny/api": "0.0.0-unstable.5387e5f7c8",
|
|
21
|
+
"@webiny/api-core": "0.0.0-unstable.5387e5f7c8",
|
|
22
|
+
"@webiny/api-graphql": "0.0.0-unstable.5387e5f7c8",
|
|
23
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.5387e5f7c8",
|
|
24
|
+
"@webiny/api-mailer": "0.0.0-unstable.5387e5f7c8",
|
|
25
|
+
"@webiny/feature": "0.0.0-unstable.5387e5f7c8",
|
|
26
|
+
"@webiny/utils": "0.0.0-unstable.5387e5f7c8",
|
|
29
27
|
"graphql": "16.14.2",
|
|
30
28
|
"zod": "4.4.3"
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
33
|
-
"@webiny/api-core-testing": "0.0.0-unstable.
|
|
34
|
-
"@webiny/api-headless-cms-testing": "0.0.0-unstable.
|
|
35
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
36
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
37
|
-
"@webiny/project-utils": "0.0.0-unstable.0d717d18dd",
|
|
31
|
+
"@webiny/api-core-testing": "0.0.0-unstable.5387e5f7c8",
|
|
32
|
+
"@webiny/api-headless-cms-testing": "0.0.0-unstable.5387e5f7c8",
|
|
33
|
+
"@webiny/build-tools": "0.0.0-unstable.5387e5f7c8",
|
|
34
|
+
"@webiny/plugins": "0.0.0-unstable.5387e5f7c8",
|
|
38
35
|
"type-fest": "5.8.0",
|
|
39
36
|
"typescript": "7.0.2",
|
|
40
|
-
"vitest": "4.1.
|
|
37
|
+
"vitest": "4.1.11"
|
|
41
38
|
},
|
|
42
39
|
"publishConfig": {
|
|
43
40
|
"access": "public"
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Container } from "@webiny/di";
|
|
2
|
-
import type { IRequestContextInitializer } from "@webiny/event-handler-core";
|
|
3
|
-
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
4
|
-
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
5
|
-
import { WcpContext } from "@webiny/api-core/features/wcp/WcpContext/index.js";
|
|
6
|
-
declare class WorkflowsInitializerImpl implements IRequestContextInitializer {
|
|
7
|
-
private container;
|
|
8
|
-
private tenantCtx;
|
|
9
|
-
private identityCtx;
|
|
10
|
-
private wcp;
|
|
11
|
-
private initialized;
|
|
12
|
-
constructor(container: Container, tenantCtx: TenantContext.Interface, identityCtx: IdentityContext.Interface, wcp: WcpContext.Interface);
|
|
13
|
-
init(_ctx: Record<string, any>): Promise<void>;
|
|
14
|
-
private registerWorkflowFeatures;
|
|
15
|
-
}
|
|
16
|
-
export declare const WorkflowsInitializer: typeof WorkflowsInitializerImpl & {
|
|
17
|
-
__abstraction: import("@webiny/di").Abstraction<IRequestContextInitializer>;
|
|
18
|
-
};
|
|
19
|
-
export {};
|
package/WorkflowsInitializer.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { RequestContainer, RequestContextInitializer } from "@webiny/event-handler-core";
|
|
2
|
-
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
3
|
-
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
4
|
-
import { WcpContext } from "@webiny/api-core/features/wcp/WcpContext/index.js";
|
|
5
|
-
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
6
|
-
import { WORKFLOW_MODEL_ID } from "./domain/workflow/workflowModel.js";
|
|
7
|
-
import { WORKFLOW_STATE_MODEL_ID } from "./domain/workflowState/stateModel.js";
|
|
8
|
-
import { WorkflowModel } from "./domain/workflow/abstractions.js";
|
|
9
|
-
import { WorkflowStateModel } from "./domain/workflowState/abstractions.js";
|
|
10
|
-
import { WorkflowMapper } from "./domain/workflow/WorkflowMapper.js";
|
|
11
|
-
import { WorkflowStateMapper } from "./domain/workflowState/WorkflowStateMapper.js";
|
|
12
|
-
import { GetWorkflowFeature } from "./features/workflow/GetWorkflow/feature.js";
|
|
13
|
-
import { ListWorkflowsFeature } from "./features/workflow/ListWorkflows/feature.js";
|
|
14
|
-
import { CreateWorkflowFeature } from "./features/workflow/CreateWorkflow/feature.js";
|
|
15
|
-
import { DeleteWorkflowFeature } from "./features/workflow/DeleteWorkflow/feature.js";
|
|
16
|
-
import { UpdateWorkflowFeature } from "./features/workflow/UpdateWorkflow/feature.js";
|
|
17
|
-
import { StoreWorkflowFeature } from "./features/workflow/StoreWorkflow/feature.js";
|
|
18
|
-
import { GetWorkflowStateFeature } from "./features/workflowState/GetWorkflowState/feature.js";
|
|
19
|
-
import { GetTargetWorkflowStateFeature } from "./features/workflowState/GetTargetWorkflowState/feature.js";
|
|
20
|
-
import { ListOwnWorkflowStatesFeature } from "./features/workflowState/ListOwnWorkflowStates/feature.js";
|
|
21
|
-
import { ListWorkflowStatesFeature } from "./features/workflowState/ListWorkflowStates/feature.js";
|
|
22
|
-
import { ListRequestedWorkflowStatesFeature } from "./features/workflowState/ListRequestedWorkflowStates/feature.js";
|
|
23
|
-
import { CreateWorkflowStateFeature } from "./features/workflowState/CreateWorkflowState/feature.js";
|
|
24
|
-
import { UpdateWorkflowStateFeature } from "./features/workflowState/UpdateWorkflowState/feature.js";
|
|
25
|
-
import { CancelWorkflowStateFeature } from "./features/workflowState/CancelWorkflowState/feature.js";
|
|
26
|
-
import { DeleteWorkflowStateFeature } from "./features/workflowState/DeleteWorkflowState/feature.js";
|
|
27
|
-
import { DeleteTargetWorkflowStateFeature } from "./features/workflowState/DeleteTargetWorkflowState/feature.js";
|
|
28
|
-
import { StartWorkflowStateStepFeature } from "./features/workflowState/StartWorkflowStateStep/feature.js";
|
|
29
|
-
import { ApproveWorkflowStateStepFeature } from "./features/workflowState/ApproveWorkflowStateStep/feature.js";
|
|
30
|
-
import { RejectWorkflowStateStepFeature } from "./features/workflowState/RejectWorkflowStateStep/feature.js";
|
|
31
|
-
import { TakeOverWorkflowStateStepFeature } from "./features/workflowState/TakeOverWorkflowStateStep/feature.js";
|
|
32
|
-
import { GetUserTeamsFeature } from "./features/internal/GetUserTeams/feature.js";
|
|
33
|
-
import { ListNotificationTypesFeature } from "./features/notifications/ListNotificationTypes/index.js";
|
|
34
|
-
import { NotificationTransportFeature } from "./features/notifications/NotificationTransport/index.js";
|
|
35
|
-
class WorkflowsInitializerImpl {
|
|
36
|
-
constructor(container, tenantCtx, identityCtx, wcp){
|
|
37
|
-
this.container = container;
|
|
38
|
-
this.tenantCtx = tenantCtx;
|
|
39
|
-
this.identityCtx = identityCtx;
|
|
40
|
-
this.wcp = wcp;
|
|
41
|
-
this.initialized = false;
|
|
42
|
-
}
|
|
43
|
-
async init(_ctx) {
|
|
44
|
-
if (!this.initialized) {
|
|
45
|
-
this.initialized = true;
|
|
46
|
-
if (this.tenantCtx.getTenant() && this.wcp.canUseWorkflows()) await this.registerWorkflowFeatures();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async registerWorkflowFeatures() {
|
|
50
|
-
const getModel = this.container.resolve(GetModelUseCase);
|
|
51
|
-
await this.identityCtx.withoutAuthorization(async ()=>{
|
|
52
|
-
const [workflowModel, workflowStateModel] = await Promise.all([
|
|
53
|
-
getModel.execute(WORKFLOW_MODEL_ID),
|
|
54
|
-
getModel.execute(WORKFLOW_STATE_MODEL_ID)
|
|
55
|
-
]);
|
|
56
|
-
this.container.registerInstance(WorkflowModel, workflowModel.value);
|
|
57
|
-
this.container.registerInstance(WorkflowStateModel, workflowStateModel.value);
|
|
58
|
-
});
|
|
59
|
-
this.container.register(WorkflowMapper);
|
|
60
|
-
this.container.register(WorkflowStateMapper);
|
|
61
|
-
ListNotificationTypesFeature.register(this.container);
|
|
62
|
-
NotificationTransportFeature.register(this.container);
|
|
63
|
-
GetWorkflowFeature.register(this.container);
|
|
64
|
-
ListWorkflowsFeature.register(this.container);
|
|
65
|
-
CreateWorkflowFeature.register(this.container);
|
|
66
|
-
DeleteWorkflowFeature.register(this.container);
|
|
67
|
-
UpdateWorkflowFeature.register(this.container);
|
|
68
|
-
StoreWorkflowFeature.register(this.container);
|
|
69
|
-
GetUserTeamsFeature.register(this.container);
|
|
70
|
-
GetWorkflowStateFeature.register(this.container);
|
|
71
|
-
GetTargetWorkflowStateFeature.register(this.container);
|
|
72
|
-
ListOwnWorkflowStatesFeature.register(this.container);
|
|
73
|
-
ListWorkflowStatesFeature.register(this.container);
|
|
74
|
-
ListRequestedWorkflowStatesFeature.register(this.container);
|
|
75
|
-
CreateWorkflowStateFeature.register(this.container);
|
|
76
|
-
UpdateWorkflowStateFeature.register(this.container);
|
|
77
|
-
CancelWorkflowStateFeature.register(this.container);
|
|
78
|
-
DeleteWorkflowStateFeature.register(this.container);
|
|
79
|
-
DeleteTargetWorkflowStateFeature.register(this.container);
|
|
80
|
-
StartWorkflowStateStepFeature.register(this.container);
|
|
81
|
-
ApproveWorkflowStateStepFeature.register(this.container);
|
|
82
|
-
RejectWorkflowStateStepFeature.register(this.container);
|
|
83
|
-
TakeOverWorkflowStateStepFeature.register(this.container);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const WorkflowsInitializer = RequestContextInitializer.createImplementation({
|
|
87
|
-
implementation: WorkflowsInitializerImpl,
|
|
88
|
-
dependencies: [
|
|
89
|
-
RequestContainer,
|
|
90
|
-
TenantContext,
|
|
91
|
-
IdentityContext,
|
|
92
|
-
WcpContext
|
|
93
|
-
]
|
|
94
|
-
});
|
|
95
|
-
export { WorkflowsInitializer };
|
|
96
|
-
|
|
97
|
-
//# sourceMappingURL=WorkflowsInitializer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowsInitializer.js","sources":["../src/WorkflowsInitializer.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { RequestContextInitializer } from \"@webiny/event-handler-core\";\nimport type { IRequestContextInitializer } from \"@webiny/event-handler-core\";\nimport { RequestContainer } from \"@webiny/event-handler-core\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { WORKFLOW_MODEL_ID } from \"./domain/workflow/workflowModel.js\";\nimport { WORKFLOW_STATE_MODEL_ID } from \"./domain/workflowState/stateModel.js\";\nimport { WorkflowModel } from \"./domain/workflow/abstractions.js\";\nimport { WorkflowStateModel } from \"./domain/workflowState/abstractions.js\";\nimport { WorkflowMapper } from \"~/domain/workflow/WorkflowMapper.js\";\nimport { WorkflowStateMapper } from \"~/domain/workflowState/WorkflowStateMapper.js\";\nimport { GetWorkflowFeature } from \"~/features/workflow/GetWorkflow/feature.js\";\nimport { ListWorkflowsFeature } from \"~/features/workflow/ListWorkflows/feature.js\";\nimport { CreateWorkflowFeature } from \"~/features/workflow/CreateWorkflow/feature.js\";\nimport { DeleteWorkflowFeature } from \"~/features/workflow/DeleteWorkflow/feature.js\";\nimport { UpdateWorkflowFeature } from \"~/features/workflow/UpdateWorkflow/feature.js\";\nimport { StoreWorkflowFeature } from \"~/features/workflow/StoreWorkflow/feature.js\";\nimport { GetWorkflowStateFeature } from \"~/features/workflowState/GetWorkflowState/feature.js\";\nimport { GetTargetWorkflowStateFeature } from \"~/features/workflowState/GetTargetWorkflowState/feature.js\";\nimport { ListOwnWorkflowStatesFeature } from \"~/features/workflowState/ListOwnWorkflowStates/feature.js\";\nimport { ListWorkflowStatesFeature } from \"~/features/workflowState/ListWorkflowStates/feature.js\";\nimport { ListRequestedWorkflowStatesFeature } from \"~/features/workflowState/ListRequestedWorkflowStates/feature.js\";\nimport { CreateWorkflowStateFeature } from \"~/features/workflowState/CreateWorkflowState/feature.js\";\nimport { UpdateWorkflowStateFeature } from \"~/features/workflowState/UpdateWorkflowState/feature.js\";\nimport { CancelWorkflowStateFeature } from \"~/features/workflowState/CancelWorkflowState/feature.js\";\nimport { DeleteWorkflowStateFeature } from \"~/features/workflowState/DeleteWorkflowState/feature.js\";\nimport { DeleteTargetWorkflowStateFeature } from \"~/features/workflowState/DeleteTargetWorkflowState/feature.js\";\nimport { StartWorkflowStateStepFeature } from \"~/features/workflowState/StartWorkflowStateStep/feature.js\";\nimport { ApproveWorkflowStateStepFeature } from \"~/features/workflowState/ApproveWorkflowStateStep/feature.js\";\nimport { RejectWorkflowStateStepFeature } from \"~/features/workflowState/RejectWorkflowStateStep/feature.js\";\nimport { TakeOverWorkflowStateStepFeature } from \"~/features/workflowState/TakeOverWorkflowStateStep/feature.js\";\nimport { GetUserTeamsFeature } from \"~/features/internal/GetUserTeams/feature.js\";\nimport { ListNotificationTypesFeature } from \"~/features/notifications/ListNotificationTypes/index.js\";\nimport { NotificationTransportFeature } from \"./features/notifications/NotificationTransport/index.js\";\n\n// A request initializer — it contributes no schema content (the static schema is registered via\n// WorkflowsSchemaFactory). It runs after context enhancers and before resolvers, making it the\n// right hook for the async CMS model fetch and lazy feature registrations resolvers depend on.\nclass WorkflowsInitializerImpl implements IRequestContextInitializer {\n private initialized = false;\n\n constructor(\n private container: Container,\n private tenantCtx: TenantContext.Interface,\n private identityCtx: IdentityContext.Interface,\n private wcp: WcpContext.Interface\n ) {}\n\n async init(_ctx: Record<string, any>): Promise<void> {\n if (!this.initialized) {\n this.initialized = true;\n\n if (this.tenantCtx.getTenant() && this.wcp.canUseWorkflows()) {\n await this.registerWorkflowFeatures();\n }\n }\n }\n\n private async registerWorkflowFeatures(): Promise<void> {\n // Fetch and register CMS models — resolved lazily here because CmsContext is only\n // registered after HeadlessCmsInitializerImpl.enhance() runs (before this runs).\n const getModel = this.container.resolve(GetModelUseCase);\n await this.identityCtx.withoutAuthorization(async () => {\n const [workflowModel, workflowStateModel] = await Promise.all([\n getModel.execute(WORKFLOW_MODEL_ID),\n getModel.execute(WORKFLOW_STATE_MODEL_ID)\n ]);\n\n this.container.registerInstance(WorkflowModel, workflowModel.value);\n this.container.registerInstance(WorkflowStateModel, workflowStateModel.value);\n });\n\n // Register mappers\n this.container.register(WorkflowMapper);\n this.container.register(WorkflowStateMapper);\n\n // Register notification features\n ListNotificationTypesFeature.register(this.container);\n NotificationTransportFeature.register(this.container);\n\n // Register workflow features\n GetWorkflowFeature.register(this.container);\n ListWorkflowsFeature.register(this.container);\n CreateWorkflowFeature.register(this.container);\n DeleteWorkflowFeature.register(this.container);\n UpdateWorkflowFeature.register(this.container);\n StoreWorkflowFeature.register(this.container);\n\n // Register internal features\n GetUserTeamsFeature.register(this.container);\n\n // Register workflow state features\n GetWorkflowStateFeature.register(this.container);\n GetTargetWorkflowStateFeature.register(this.container);\n ListOwnWorkflowStatesFeature.register(this.container);\n ListWorkflowStatesFeature.register(this.container);\n ListRequestedWorkflowStatesFeature.register(this.container);\n CreateWorkflowStateFeature.register(this.container);\n UpdateWorkflowStateFeature.register(this.container);\n CancelWorkflowStateFeature.register(this.container);\n DeleteWorkflowStateFeature.register(this.container);\n DeleteTargetWorkflowStateFeature.register(this.container);\n StartWorkflowStateStepFeature.register(this.container);\n ApproveWorkflowStateStepFeature.register(this.container);\n RejectWorkflowStateStepFeature.register(this.container);\n TakeOverWorkflowStateStepFeature.register(this.container);\n }\n}\n\nexport const WorkflowsInitializer = RequestContextInitializer.createImplementation({\n implementation: WorkflowsInitializerImpl,\n dependencies: [RequestContainer, TenantContext, IdentityContext, WcpContext]\n});\n"],"names":["WorkflowsInitializerImpl","container","tenantCtx","identityCtx","wcp","_ctx","getModel","GetModelUseCase","workflowModel","workflowStateModel","Promise","WORKFLOW_MODEL_ID","WORKFLOW_STATE_MODEL_ID","WorkflowModel","WorkflowStateModel","WorkflowMapper","WorkflowStateMapper","ListNotificationTypesFeature","NotificationTransportFeature","GetWorkflowFeature","ListWorkflowsFeature","CreateWorkflowFeature","DeleteWorkflowFeature","UpdateWorkflowFeature","StoreWorkflowFeature","GetUserTeamsFeature","GetWorkflowStateFeature","GetTargetWorkflowStateFeature","ListOwnWorkflowStatesFeature","ListWorkflowStatesFeature","ListRequestedWorkflowStatesFeature","CreateWorkflowStateFeature","UpdateWorkflowStateFeature","CancelWorkflowStateFeature","DeleteWorkflowStateFeature","DeleteTargetWorkflowStateFeature","StartWorkflowStateStepFeature","ApproveWorkflowStateStepFeature","RejectWorkflowStateStepFeature","TakeOverWorkflowStateStepFeature","WorkflowsInitializer","RequestContextInitializer","RequestContainer","TenantContext","IdentityContext","WcpContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAMA;IAGF,YACYC,SAAoB,EACpBC,SAAkC,EAClCC,WAAsC,EACtCC,GAAyB,CACnC;aAJUH,SAAS,GAATA;aACAC,SAAS,GAATA;aACAC,WAAW,GAAXA;aACAC,GAAG,GAAHA;aANJ,WAAW,GAAG;IAOnB;IAEH,MAAM,KAAKC,IAAyB,EAAiB;QACjD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,IAAI,CAAC,WAAW,GAAG;YAEnB,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG,CAAC,eAAe,IACtD,MAAM,IAAI,CAAC,wBAAwB;QAE3C;IACJ;IAEA,MAAc,2BAA0C;QAGpD,MAAMC,WAAW,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QACxC,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC;YACxC,MAAM,CAACC,eAAeC,mBAAmB,GAAG,MAAMC,QAAQ,GAAG,CAAC;gBAC1DJ,SAAS,OAAO,CAACK;gBACjBL,SAAS,OAAO,CAACM;aACpB;YAED,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAACC,eAAeL,cAAc,KAAK;YAClE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAACM,oBAAoBL,mBAAmB,KAAK;QAChF;QAGA,IAAI,CAAC,SAAS,CAAC,QAAQ,CAACM;QACxB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAACC;QAGxBC,6BAA6B,QAAQ,CAAC,IAAI,CAAC,SAAS;QACpDC,6BAA6B,QAAQ,CAAC,IAAI,CAAC,SAAS;QAGpDC,mBAAmB,QAAQ,CAAC,IAAI,CAAC,SAAS;QAC1CC,qBAAqB,QAAQ,CAAC,IAAI,CAAC,SAAS;QAC5CC,sBAAsB,QAAQ,CAAC,IAAI,CAAC,SAAS;QAC7CC,sBAAsB,QAAQ,CAAC,IAAI,CAAC,SAAS;QAC7CC,sBAAsB,QAAQ,CAAC,IAAI,CAAC,SAAS;QAC7CC,qBAAqB,QAAQ,CAAC,IAAI,CAAC,SAAS;QAG5CC,oBAAoB,QAAQ,CAAC,IAAI,CAAC,SAAS;QAG3CC,wBAAwB,QAAQ,CAAC,IAAI,CAAC,SAAS;QAC/CC,8BAA8B,QAAQ,CAAC,IAAI,CAAC,SAAS;QACrDC,6BAA6B,QAAQ,CAAC,IAAI,CAAC,SAAS;QACpDC,0BAA0B,QAAQ,CAAC,IAAI,CAAC,SAAS;QACjDC,mCAAmC,QAAQ,CAAC,IAAI,CAAC,SAAS;QAC1DC,2BAA2B,QAAQ,CAAC,IAAI,CAAC,SAAS;QAClDC,2BAA2B,QAAQ,CAAC,IAAI,CAAC,SAAS;QAClDC,2BAA2B,QAAQ,CAAC,IAAI,CAAC,SAAS;QAClDC,2BAA2B,QAAQ,CAAC,IAAI,CAAC,SAAS;QAClDC,iCAAiC,QAAQ,CAAC,IAAI,CAAC,SAAS;QACxDC,8BAA8B,QAAQ,CAAC,IAAI,CAAC,SAAS;QACrDC,gCAAgC,QAAQ,CAAC,IAAI,CAAC,SAAS;QACvDC,+BAA+B,QAAQ,CAAC,IAAI,CAAC,SAAS;QACtDC,iCAAiC,QAAQ,CAAC,IAAI,CAAC,SAAS;IAC5D;AACJ;AAEO,MAAMC,uBAAuBC,0BAA0B,oBAAoB,CAAC;IAC/E,gBAAgBzC;IAChB,cAAc;QAAC0C;QAAkBC;QAAeC;QAAiBC;KAAW;AAChF"}
|