@webiny/api-apw 5.39.1 → 5.39.2-beta.0
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/package.json +27 -27
- package/storageOperations/changeRequestStorageOperations.js +13 -25
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.d.ts +1 -1
- package/storageOperations/commentStorageOperations.js +15 -28
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.d.ts +1 -1
- package/storageOperations/contentReviewStorageOperations.js +14 -27
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/models/changeRequest.model.d.ts +1 -1
- package/storageOperations/models/changeRequest.model.js +4 -4
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.d.ts +1 -1
- package/storageOperations/models/comment.model.js +4 -4
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentReview.model.d.ts +1 -1
- package/storageOperations/models/contentReview.model.js +4 -4
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +5 -5
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.d.ts +1 -1
- package/storageOperations/models/reviewer.model.js +4 -4
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/workflow.model.d.ts +1 -1
- package/storageOperations/models/workflow.model.js +4 -4
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.d.ts +1 -1
- package/storageOperations/reviewerStorageOperations.js +14 -27
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +11 -24
- package/storageOperations/workflowStorageOperations.js.map +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@webiny/api-apw",
|
3
|
-
"version": "5.39.
|
3
|
+
"version": "5.39.2-beta.0",
|
4
4
|
"keywords": [
|
5
5
|
"apw:base"
|
6
6
|
],
|
@@ -16,27 +16,27 @@
|
|
16
16
|
"dependencies": {
|
17
17
|
"@babel/runtime": "7.22.6",
|
18
18
|
"@commodo/fields": "1.1.2-beta.20",
|
19
|
-
"@webiny/api": "5.39.
|
20
|
-
"@webiny/api-admin-settings": "5.39.
|
21
|
-
"@webiny/api-headless-cms": "5.39.
|
22
|
-
"@webiny/api-i18n": "5.39.
|
23
|
-
"@webiny/api-mailer": "5.39.
|
24
|
-
"@webiny/api-page-builder": "5.39.
|
25
|
-
"@webiny/api-security": "5.39.
|
26
|
-
"@webiny/api-tenancy": "5.39.
|
27
|
-
"@webiny/api-wcp": "5.39.
|
28
|
-
"@webiny/aws-sdk": "5.39.
|
29
|
-
"@webiny/db-dynamodb": "5.39.
|
30
|
-
"@webiny/error": "5.39.
|
31
|
-
"@webiny/handler": "5.39.
|
32
|
-
"@webiny/handler-client": "5.39.
|
33
|
-
"@webiny/handler-db": "5.39.
|
34
|
-
"@webiny/handler-graphql": "5.39.
|
35
|
-
"@webiny/handler-logs": "5.39.
|
36
|
-
"@webiny/plugins": "5.39.
|
37
|
-
"@webiny/pubsub": "5.39.
|
38
|
-
"@webiny/utils": "5.39.
|
39
|
-
"@webiny/validation": "5.39.
|
19
|
+
"@webiny/api": "5.39.2-beta.0",
|
20
|
+
"@webiny/api-admin-settings": "5.39.2-beta.0",
|
21
|
+
"@webiny/api-headless-cms": "5.39.2-beta.0",
|
22
|
+
"@webiny/api-i18n": "5.39.2-beta.0",
|
23
|
+
"@webiny/api-mailer": "5.39.2-beta.0",
|
24
|
+
"@webiny/api-page-builder": "5.39.2-beta.0",
|
25
|
+
"@webiny/api-security": "5.39.2-beta.0",
|
26
|
+
"@webiny/api-tenancy": "5.39.2-beta.0",
|
27
|
+
"@webiny/api-wcp": "5.39.2-beta.0",
|
28
|
+
"@webiny/aws-sdk": "5.39.2-beta.0",
|
29
|
+
"@webiny/db-dynamodb": "5.39.2-beta.0",
|
30
|
+
"@webiny/error": "5.39.2-beta.0",
|
31
|
+
"@webiny/handler": "5.39.2-beta.0",
|
32
|
+
"@webiny/handler-client": "5.39.2-beta.0",
|
33
|
+
"@webiny/handler-db": "5.39.2-beta.0",
|
34
|
+
"@webiny/handler-graphql": "5.39.2-beta.0",
|
35
|
+
"@webiny/handler-logs": "5.39.2-beta.0",
|
36
|
+
"@webiny/plugins": "5.39.2-beta.0",
|
37
|
+
"@webiny/pubsub": "5.39.2-beta.0",
|
38
|
+
"@webiny/utils": "5.39.2-beta.0",
|
39
|
+
"@webiny/validation": "5.39.2-beta.0",
|
40
40
|
"dayjs": "1.11.7",
|
41
41
|
"lodash": "4.17.21"
|
42
42
|
},
|
@@ -44,10 +44,10 @@
|
|
44
44
|
"@babel/cli": "7.22.6",
|
45
45
|
"@babel/core": "7.22.8",
|
46
46
|
"@babel/preset-env": "7.22.7",
|
47
|
-
"@webiny/cli": "5.39.
|
48
|
-
"@webiny/handler-aws": "5.39.
|
49
|
-
"@webiny/project-utils": "5.39.
|
50
|
-
"@webiny/wcp": "5.39.
|
47
|
+
"@webiny/cli": "5.39.2-beta.0",
|
48
|
+
"@webiny/handler-aws": "5.39.2-beta.0",
|
49
|
+
"@webiny/project-utils": "5.39.2-beta.0",
|
50
|
+
"@webiny/wcp": "5.39.2-beta.0",
|
51
51
|
"get-yarn-workspaces": "1.0.2",
|
52
52
|
"graphql": "15.8.0",
|
53
53
|
"jest": "29.5.0",
|
@@ -65,5 +65,5 @@
|
|
65
65
|
"build": "yarn webiny run build",
|
66
66
|
"watch": "yarn webiny run watch"
|
67
67
|
},
|
68
|
-
"gitHead": "
|
68
|
+
"gitHead": "3ceff3406ff490e6d7503b35733a09c1cee8ff12"
|
69
69
|
}
|
@@ -15,9 +15,7 @@ const createChangeRequestStorageOperations = params => {
|
|
15
15
|
security
|
16
16
|
} = params;
|
17
17
|
const getChangeRequestModel = async () => {
|
18
|
-
const model = await
|
19
|
-
return cms.getModel("apwChangeRequestModelDefinition");
|
20
|
-
});
|
18
|
+
const model = await cms.getModel("apwChangeRequestModelDefinition");
|
21
19
|
if (!model) {
|
22
20
|
throw new _error.default("Could not find `apwChangeRequestModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
|
23
21
|
}
|
@@ -27,9 +25,7 @@ const createChangeRequestStorageOperations = params => {
|
|
27
25
|
id
|
28
26
|
}) => {
|
29
27
|
const model = await getChangeRequestModel();
|
30
|
-
const entry = await
|
31
|
-
return cms.getEntryById(model, id);
|
32
|
-
});
|
28
|
+
const entry = await cms.getEntryById(model, id);
|
33
29
|
return (0, _fieldResolver.getFieldValues)({
|
34
30
|
entry,
|
35
31
|
fields: _pickEntryFieldValues.baseFields,
|
@@ -42,13 +38,11 @@ const createChangeRequestStorageOperations = params => {
|
|
42
38
|
getChangeRequest,
|
43
39
|
async listChangeRequests(params) {
|
44
40
|
const model = await getChangeRequestModel();
|
45
|
-
const [entries, meta] = await
|
46
|
-
|
47
|
-
|
48
|
-
where
|
49
|
-
|
50
|
-
}
|
51
|
-
});
|
41
|
+
const [entries, meta] = await cms.listLatestEntries(model, {
|
42
|
+
...params,
|
43
|
+
where: {
|
44
|
+
...params.where
|
45
|
+
}
|
52
46
|
});
|
53
47
|
try {
|
54
48
|
const all = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
@@ -64,9 +58,7 @@ const createChangeRequestStorageOperations = params => {
|
|
64
58
|
},
|
65
59
|
async createChangeRequest(params) {
|
66
60
|
const model = await getChangeRequestModel();
|
67
|
-
const entry = await
|
68
|
-
return cms.createEntry(model, params.data);
|
69
|
-
});
|
61
|
+
const entry = await cms.createEntry(model, params.data);
|
70
62
|
return (0, _fieldResolver.getFieldValues)({
|
71
63
|
entry,
|
72
64
|
fields: _pickEntryFieldValues.baseFields,
|
@@ -91,12 +83,10 @@ const createChangeRequestStorageOperations = params => {
|
|
91
83
|
if (existingEntry.createdBy.id !== security.getIdentity().id) {
|
92
84
|
throw new _error.default("A change request can only be updated by its creator.", "ONLY_CREATOR_CAN_UPDATE_CHANGE_REQUEST");
|
93
85
|
}
|
94
|
-
const entry = await
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
savedOn: new Date()
|
99
|
-
});
|
86
|
+
const entry = await cms.updateEntry(model, params.id, {
|
87
|
+
...existingEntry,
|
88
|
+
...params.data,
|
89
|
+
savedOn: new Date()
|
100
90
|
});
|
101
91
|
return (0, _fieldResolver.getFieldValues)({
|
102
92
|
entry,
|
@@ -124,9 +114,7 @@ const createChangeRequestStorageOperations = params => {
|
|
124
114
|
if (existingEntry.createdBy.id !== security.getIdentity().id) {
|
125
115
|
throw new _error.default("A change request can only be deleted by its creator.", "ONLY_CREATOR_CAN_DELETE_CHANGE_REQUEST");
|
126
116
|
}
|
127
|
-
await
|
128
|
-
return cms.deleteEntry(model, params.id);
|
129
|
-
});
|
117
|
+
await cms.deleteEntry(model, params.id);
|
130
118
|
return true;
|
131
119
|
}
|
132
120
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_pickEntryFieldValues","require","_fieldResolver","_error","_interopRequireDefault","createChangeRequestStorageOperations","params","cms","getCmsContext","security","getChangeRequestModel","model","
|
1
|
+
{"version":3,"names":["_pickEntryFieldValues","require","_fieldResolver","_error","_interopRequireDefault","createChangeRequestStorageOperations","params","cms","getCmsContext","security","getChangeRequestModel","model","getModel","WebinyError","getChangeRequest","id","entry","getEntryById","getFieldValues","fields","baseFields","context","transformers","getTransformer","listChangeRequests","entries","meta","listLatestEntries","where","all","Promise","map","ex","message","code","data","createChangeRequest","createEntry","updateChangeRequest","existingEntry","createdBy","getIdentity","updateEntry","savedOn","Date","deleteChangeRequest","deleteEntry","exports"],"sources":["changeRequestStorageOperations.ts"],"sourcesContent":["import { ApwChangeRequestStorageOperations } from \"./types\";\nimport { CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { baseFields } from \"~/utils/pickEntryFieldValues\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\nimport WebinyError from \"@webiny/error\";\nimport { ApwChangeRequest } from \"~/types\";\n\nexport const createChangeRequestStorageOperations = (\n params: CreateApwStorageOperationsParams\n): ApwChangeRequestStorageOperations => {\n const { cms, getCmsContext, security } = params;\n const getChangeRequestModel = async () => {\n const model = await cms.getModel(\"apwChangeRequestModelDefinition\");\n if (!model) {\n throw new WebinyError(\n \"Could not find `apwChangeRequestModelDefinition` model.\",\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getChangeRequest: ApwChangeRequestStorageOperations[\"getChangeRequest\"] = async ({\n id\n }) => {\n const model = await getChangeRequestModel();\n\n const entry = await cms.getEntryById(model, id);\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n };\n return {\n getChangeRequestModel,\n getChangeRequest,\n async listChangeRequests(params) {\n const model = await getChangeRequestModel();\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n\n try {\n const all = await Promise.all(\n entries.map(entry =>\n getFieldValues<ApwChangeRequest>({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n })\n )\n );\n return [all, meta];\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code, ex.data);\n }\n },\n async createChangeRequest(params) {\n const model = await getChangeRequestModel();\n const entry = await cms.createEntry(model, params.data);\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async updateChangeRequest(params) {\n const model = await getChangeRequestModel();\n\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getChangeRequest({ id: params.id });\n\n /**\n * Only creator can update the change request\n */\n if (existingEntry.createdBy.id !== security.getIdentity().id) {\n throw new WebinyError(\n \"A change request can only be updated by its creator.\",\n \"ONLY_CREATOR_CAN_UPDATE_CHANGE_REQUEST\"\n );\n }\n\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data,\n savedOn: new Date()\n });\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async deleteChangeRequest(params) {\n const model = await getChangeRequestModel();\n\n if (!security.getIdentity()) {\n return true;\n }\n\n /**\n * We're fetching the existing entry\n */\n const existingEntry = await getChangeRequest({ id: params.id });\n\n /**\n * Only creator can delete the change request\n */\n if (existingEntry.createdBy.id !== security.getIdentity().id) {\n throw new WebinyError(\n \"A change request can only be deleted by its creator.\",\n \"ONLY_CREATOR_CAN_DELETE_CHANGE_REQUEST\"\n );\n }\n\n await cms.deleteEntry(model, params.id);\n\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAGO,MAAMI,oCAAoC,GAC7CC,MAAwC,IACJ;EACpC,MAAM;IAAEC,GAAG;IAAEC,aAAa;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAC/C,MAAMI,qBAAqB,GAAG,MAAAA,CAAA,KAAY;IACtC,MAAMC,KAAK,GAAG,MAAMJ,GAAG,CAACK,QAAQ,CAAC,iCAAiC,CAAC;IACnE,IAAI,CAACD,KAAK,EAAE;MACR,MAAM,IAAIE,cAAW,CACjB,yDAAyD,EACzD,uBACJ,CAAC;IACL;IACA,OAAOF,KAAK;EAChB,CAAC;EACD,MAAMG,gBAAuE,GAAG,MAAAA,CAAO;IACnFC;EACJ,CAAC,KAAK;IACF,MAAMJ,KAAK,GAAG,MAAMD,qBAAqB,CAAC,CAAC;IAE3C,MAAMM,KAAK,GAAG,MAAMT,GAAG,CAACU,YAAY,CAACN,KAAK,EAAEI,EAAE,CAAC;IAE/C,OAAO,IAAAG,6BAAc,EAAC;MAClBF,KAAK;MACLG,MAAM,EAA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QAAEC,EAAE,EAAET,MAAM,CAACS;MAAG,CAAC,CAAC;;MAE/D;AACZ;AACA;MACY,IAAIwB,aAAa,CAACC,SAAS,CAACzB,EAAE,KAAKN,QAAQ,CAACgC,WAAW,CAAC,CAAC,CAAC1B,EAAE,EAAE;QAC1D,MAAM,IAAIF,cAAW,CACjB,sDAAsD,EACtD,wCACJ,CAAC;MACL;MAEA,MAAMN,GAAG,CAACuC,WAAW,CAACnC,KAAK,EAAEL,MAAM,CAACS,EAAE,CAAC;MAEvC,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAACgC,OAAA,CAAA1C,oCAAA,GAAAA,oCAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { ApwCommentStorageOperations } from "./types";
|
2
2
|
import { CreateApwStorageOperationsParams } from "./index";
|
3
|
-
export declare const createCommentStorageOperations: ({ cms, getCmsContext
|
3
|
+
export declare const createCommentStorageOperations: ({ cms, getCmsContext }: CreateApwStorageOperationsParams) => ApwCommentStorageOperations;
|
@@ -19,13 +19,10 @@ const pickIdFromChangeRequest = obj => {
|
|
19
19
|
};
|
20
20
|
const createCommentStorageOperations = ({
|
21
21
|
cms,
|
22
|
-
getCmsContext
|
23
|
-
security
|
22
|
+
getCmsContext
|
24
23
|
}) => {
|
25
24
|
const getCommentModel = async () => {
|
26
|
-
const model = await
|
27
|
-
return cms.getModel(_comment.COMMENT_MODEL_ID);
|
28
|
-
});
|
25
|
+
const model = await cms.getModel(_comment.COMMENT_MODEL_ID);
|
29
26
|
if (!model) {
|
30
27
|
throw new _error.default(`Could not find "${_comment.COMMENT_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
31
28
|
}
|
@@ -35,9 +32,7 @@ const createCommentStorageOperations = ({
|
|
35
32
|
id
|
36
33
|
}) => {
|
37
34
|
const model = await getCommentModel();
|
38
|
-
const entry = await
|
39
|
-
return cms.getEntryById(model, id);
|
40
|
-
});
|
35
|
+
const entry = await cms.getEntryById(model, id);
|
41
36
|
return (0, _fieldResolver.getFieldValues)({
|
42
37
|
entry,
|
43
38
|
fields: _pickEntryFieldValues.baseFields,
|
@@ -53,9 +48,7 @@ const createCommentStorageOperations = ({
|
|
53
48
|
},
|
54
49
|
async listComments(params) {
|
55
50
|
const model = await getCommentModel();
|
56
|
-
const [entries, meta] = await
|
57
|
-
return cms.listLatestEntries(model, params);
|
58
|
-
});
|
51
|
+
const [entries, meta] = await cms.listLatestEntries(model, params);
|
59
52
|
const values = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
60
53
|
entry,
|
61
54
|
fields: _pickEntryFieldValues.baseFields,
|
@@ -68,14 +61,12 @@ const createCommentStorageOperations = ({
|
|
68
61
|
async createComment(params) {
|
69
62
|
const model = await getCommentModel();
|
70
63
|
const refModel = await this.getChangeRequestModel();
|
71
|
-
const entry = await
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
}
|
78
|
-
});
|
64
|
+
const entry = await cms.createEntry(model, {
|
65
|
+
...params.data,
|
66
|
+
changeRequest: {
|
67
|
+
id: params.data.changeRequest,
|
68
|
+
modelId: refModel.modelId
|
69
|
+
}
|
79
70
|
});
|
80
71
|
const values = await (0, _fieldResolver.getFieldValues)({
|
81
72
|
entry,
|
@@ -94,12 +85,10 @@ const createCommentStorageOperations = ({
|
|
94
85
|
const existingEntry = await getComment({
|
95
86
|
id: params.id
|
96
87
|
});
|
97
|
-
const entry = await
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
savedOn: new Date()
|
102
|
-
});
|
88
|
+
const entry = await cms.updateEntry(model, params.id, {
|
89
|
+
...existingEntry,
|
90
|
+
...params.data,
|
91
|
+
savedOn: new Date()
|
103
92
|
});
|
104
93
|
const values = await (0, _fieldResolver.getFieldValues)({
|
105
94
|
entry,
|
@@ -111,9 +100,7 @@ const createCommentStorageOperations = ({
|
|
111
100
|
},
|
112
101
|
async deleteComment(params) {
|
113
102
|
const model = await getCommentModel();
|
114
|
-
await
|
115
|
-
return cms.deleteEntry(model, params.id);
|
116
|
-
});
|
103
|
+
await cms.deleteEntry(model, params.id);
|
117
104
|
return true;
|
118
105
|
}
|
119
106
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_fieldResolver","require","_pickEntryFieldValues","_error","_interopRequireDefault","_comment","pickIdFromChangeRequest","obj","rawValue","id","createCommentStorageOperations","cms","getCmsContext","
|
1
|
+
{"version":3,"names":["_fieldResolver","require","_pickEntryFieldValues","_error","_interopRequireDefault","_comment","pickIdFromChangeRequest","obj","rawValue","id","createCommentStorageOperations","cms","getCmsContext","getCommentModel","model","getModel","COMMENT_MODEL_ID","WebinyError","getComment","entry","getEntryById","getFieldValues","fields","baseFields","context","transformers","getTransformer","params","values","listComments","entries","meta","listLatestEntries","Promise","all","map","value","createComment","refModel","getChangeRequestModel","createEntry","data","changeRequest","modelId","updateComment","existingEntry","updateEntry","savedOn","Date","deleteComment","deleteEntry","exports"],"sources":["commentStorageOperations.ts"],"sourcesContent":["import { ApwStorageOperations } from \"./types\";\nimport { ApwCommentStorageOperations } from \"./types\";\nimport { CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\nimport { baseFields } from \"~/utils/pickEntryFieldValues\";\n\nimport WebinyError from \"@webiny/error\";\nimport { ApwComment } from \"~/types\";\nimport { CmsEntryListParams } from \"@webiny/api-headless-cms/types\";\nimport { COMMENT_MODEL_ID } from \"~/storageOperations/models/comment.model\";\n\nconst pickIdFromChangeRequest = (obj: Record<string, any>): ApwComment => {\n const rawValue = obj[\"changeRequest\"];\n if (!rawValue) {\n return obj as unknown as ApwComment;\n }\n obj[\"changeRequest\"] = rawValue.id;\n return obj as unknown as ApwComment;\n};\n\nexport const createCommentStorageOperations = ({\n cms,\n getCmsContext\n}: CreateApwStorageOperationsParams): ApwCommentStorageOperations => {\n const getCommentModel = async () => {\n const model = await cms.getModel(COMMENT_MODEL_ID);\n\n if (!model) {\n throw new WebinyError(\n `Could not find \"${COMMENT_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getComment: ApwCommentStorageOperations[\"getComment\"] = async ({ id }) => {\n const model = await getCommentModel();\n const entry = await cms.getEntryById(model, id);\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n };\n return {\n getCommentModel,\n getComment: async params => {\n const values = await getComment(params);\n return pickIdFromChangeRequest(values);\n },\n async listComments(params) {\n const model = await getCommentModel();\n const [entries, meta] = await cms.listLatestEntries(\n model,\n params as CmsEntryListParams\n );\n const values = await Promise.all(\n entries.map(entry =>\n getFieldValues<ApwComment>({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n })\n )\n );\n const all = values.map(value => pickIdFromChangeRequest(value));\n return [all, meta];\n },\n async createComment(this: ApwStorageOperations, params) {\n const model = await getCommentModel();\n const refModel = await this.getChangeRequestModel();\n\n const entry = await cms.createEntry(model, {\n ...params.data,\n changeRequest: {\n id: params.data.changeRequest,\n modelId: refModel.modelId\n }\n });\n\n const values = await getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n return pickIdFromChangeRequest(values);\n },\n async updateComment(params) {\n const model = await getCommentModel();\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getComment({ id: params.id });\n\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data,\n savedOn: new Date()\n });\n\n const values = await getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n return pickIdFromChangeRequest(values);\n },\n async deleteComment(params) {\n const model = await getCommentModel();\n await cms.deleteEntry(model, params.id);\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,c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YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACZ,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;MACF,OAAOR,uBAAuB,CAACsB,MAAM,CAAC;IAC1C,CAAC;IACD,MAAMgB,aAAaA,CAACjB,MAAM,EAAE;MACxB,MAAMb,KAAK,GAAG,MAAMD,eAAe,CAAC,CAAC;MACrC;AACZ;AACA;AACA;MACY,MAAMgC,aAAa,GAAG,MAAM3B,UAAU,CAAC;QAAET,EAAE,EAAEkB,MAAM,CAAClB;MAAG,CAAC,CAAC;MAEzD,MAAMU,KAAK,GAAG,MAAMR,GAAG,CAACmC,WAAW,CAAChC,KAAK,EAAEa,MAAM,CAAClB,EAAE,EAAE;QAClD,GAAGoC,aAAa;QAChB,GAAGlB,MAAM,CAACc,IAAI;QACdM,OAAO,EAAE,IAAIC,IAAI,CAAC;MACtB,CAAC,CAAC;MAEF,MAAMpB,MAAM,GAAG,MAAM,IAAAP,6BAAc,EAAC;QAChCF,KAAK;QACLG,MAAM,EAAEC,gCAAU;QAClBC,OAAO,EAAEZ,aAAa,CAAC,CAAC;QACxBa,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACZ,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;MACF,OAAOR,uBAAuB,CAACsB,MAAM,CAAC;IAC1C,CAAC;IACD,MAAMqB,aAAaA,CAACtB,MAAM,EAAE;MACxB,MAAMb,KAAK,GAAG,MAAMD,eAAe,CAAC,CAAC;MACrC,MAAMF,GAAG,CAACuC,WAAW,CAACpC,KAAK,EAAEa,MAAM,CAAClB,EAAE,CAAC;MACvC,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC0C,OAAA,CAAAzC,8BAAA,GAAAA,8BAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { ApwContentReviewStorageOperations } from "./types";
|
2
2
|
import { CreateApwStorageOperationsParams } from "./";
|
3
|
-
export declare const createContentReviewStorageOperations: ({ cms
|
3
|
+
export declare const createContentReviewStorageOperations: ({ cms }: CreateApwStorageOperationsParams) => ApwContentReviewStorageOperations;
|
@@ -9,13 +9,10 @@ var _pickEntryFieldValues = require("../utils/pickEntryFieldValues");
|
|
9
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
10
10
|
var _contentReview = require("./models/contentReview.model");
|
11
11
|
const createContentReviewStorageOperations = ({
|
12
|
-
cms
|
13
|
-
security
|
12
|
+
cms
|
14
13
|
}) => {
|
15
14
|
const getContentReviewModel = async () => {
|
16
|
-
const model = await
|
17
|
-
return cms.getModel(_contentReview.CONTENT_REVIEW_MODEL_ID);
|
18
|
-
});
|
15
|
+
const model = await cms.getModel(_contentReview.CONTENT_REVIEW_MODEL_ID);
|
19
16
|
if (!model) {
|
20
17
|
throw new _error.default(`Could not find "${_contentReview.CONTENT_REVIEW_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
21
18
|
}
|
@@ -25,9 +22,7 @@ const createContentReviewStorageOperations = ({
|
|
25
22
|
id
|
26
23
|
}) => {
|
27
24
|
const model = await getContentReviewModel();
|
28
|
-
const entry = await
|
29
|
-
return cms.getEntryById(model, id);
|
30
|
-
});
|
25
|
+
const entry = await cms.getEntryById(model, id);
|
31
26
|
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
32
27
|
};
|
33
28
|
return {
|
@@ -35,21 +30,17 @@ const createContentReviewStorageOperations = ({
|
|
35
30
|
getContentReview,
|
36
31
|
async listContentReviews(params) {
|
37
32
|
const model = await getContentReviewModel();
|
38
|
-
const [entries, meta] = await
|
39
|
-
|
40
|
-
|
41
|
-
where
|
42
|
-
|
43
|
-
}
|
44
|
-
});
|
33
|
+
const [entries, meta] = await cms.listLatestEntries(model, {
|
34
|
+
...params,
|
35
|
+
where: {
|
36
|
+
...params.where
|
37
|
+
}
|
45
38
|
});
|
46
39
|
return [entries.map(_pickEntryFieldValues.pickEntryFieldValues), meta];
|
47
40
|
},
|
48
41
|
async createContentReview(params) {
|
49
42
|
const model = await getContentReviewModel();
|
50
|
-
const entry = await
|
51
|
-
return cms.createEntry(model, params.data);
|
52
|
-
});
|
43
|
+
const entry = await cms.createEntry(model, params.data);
|
53
44
|
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
54
45
|
},
|
55
46
|
async updateContentReview(params) {
|
@@ -61,20 +52,16 @@ const createContentReviewStorageOperations = ({
|
|
61
52
|
const existingEntry = await getContentReview({
|
62
53
|
id: params.id
|
63
54
|
});
|
64
|
-
const entry = await
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
savedOn: new Date()
|
69
|
-
});
|
55
|
+
const entry = await cms.updateEntry(model, params.id, {
|
56
|
+
...existingEntry,
|
57
|
+
...params.data,
|
58
|
+
savedOn: new Date()
|
70
59
|
});
|
71
60
|
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
72
61
|
},
|
73
62
|
async deleteContentReview(params) {
|
74
63
|
const model = await getContentReviewModel();
|
75
|
-
await
|
76
|
-
return cms.deleteEntry(model, params.id);
|
77
|
-
});
|
64
|
+
await cms.deleteEntry(model, params.id);
|
78
65
|
return true;
|
79
66
|
}
|
80
67
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_pickEntryFieldValues","require","_error","_interopRequireDefault","_contentReview","createContentReviewStorageOperations","cms","
|
1
|
+
{"version":3,"names":["_pickEntryFieldValues","require","_error","_interopRequireDefault","_contentReview","createContentReviewStorageOperations","cms","getContentReviewModel","model","getModel","CONTENT_REVIEW_MODEL_ID","WebinyError","getContentReview","id","entry","getEntryById","pickEntryFieldValues","listContentReviews","params","entries","meta","listLatestEntries","where","map","createContentReview","createEntry","data","updateContentReview","existingEntry","updateEntry","savedOn","Date","deleteContentReview","deleteEntry","exports"],"sources":["contentReviewStorageOperations.ts"],"sourcesContent":["import { ApwContentReviewStorageOperations } from \"./types\";\nimport { CreateApwStorageOperationsParams } from \"~/storageOperations\";\nimport { pickEntryFieldValues } from \"~/utils/pickEntryFieldValues\";\nimport WebinyError from \"@webiny/error\";\nimport { CONTENT_REVIEW_MODEL_ID } from \"~/storageOperations/models/contentReview.model\";\nimport { ApwContentReview } from \"~/types\";\n\nexport const createContentReviewStorageOperations = ({\n cms\n}: CreateApwStorageOperationsParams): ApwContentReviewStorageOperations => {\n const getContentReviewModel = async () => {\n const model = await cms.getModel(CONTENT_REVIEW_MODEL_ID);\n if (!model) {\n throw new WebinyError(\n `Could not find \"${CONTENT_REVIEW_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getContentReview: ApwContentReviewStorageOperations[\"getContentReview\"] = async ({\n id\n }) => {\n const model = await getContentReviewModel();\n const entry = await cms.getEntryById(model, id);\n return pickEntryFieldValues(entry);\n };\n return {\n getContentReviewModel,\n getContentReview,\n async listContentReviews(params) {\n const model = await getContentReviewModel();\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n\n return [entries.map(pickEntryFieldValues<ApwContentReview>), meta];\n },\n async createContentReview(params) {\n const model = await getContentReviewModel();\n\n const entry = await cms.createEntry(model, params.data);\n return pickEntryFieldValues(entry);\n },\n async updateContentReview(params) {\n const model = await getContentReviewModel();\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getContentReview({ id: params.id });\n\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data,\n savedOn: new Date()\n });\n return pickEntryFieldValues(entry);\n },\n async deleteContentReview(params) {\n const model = await getContentReviewModel();\n await cms.deleteEntry(model, params.id);\n\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAGO,MAAMI,oCAAoC,GAAGA,CAAC;EACjDC;AAC8B,CAAC,KAAwC;EACvE,MAAMC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qBAAqB,CAAC,CAAC;MAC3C;AACZ;AACA;AACA;MACY,MAAMqB,aAAa,GAAG,MAAMhB,gBAAgB,CAAC;QAAEC,EAAE,EAAEK,MAAM,CAACL;MAAG,CAAC,CAAC;MAE/D,MAAMC,KAAK,GAAG,MAAMR,GAAG,CAACuB,WAAW,CAACrB,KAAK,EAAEU,MAAM,CAACL,EAAE,EAAE;QAClD,GAAGe,aAAa;QAChB,GAAGV,MAAM,CAACQ,IAAI;QACdI,OAAO,EAAE,IAAIC,IAAI,CAAC;MACtB,CAAC,CAAC;MACF,OAAO,IAAAf,0CAAoB,EAACF,KAAK,CAAC;IACtC,CAAC;IACD,MAAMkB,mBAAmBA,CAACd,MAAM,EAAE;MAC9B,MAAMV,KAAK,GAAG,MAAMD,qBAAqB,CAAC,CAAC;MAC3C,MAAMD,GAAG,CAAC2B,WAAW,CAACzB,KAAK,EAAEU,MAAM,CAACL,EAAE,CAAC;MAEvC,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAACqB,OAAA,CAAA7B,oCAAA,GAAAA,oCAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export declare const CHANGE_REQUEST_MODEL_ID = "apwChangeRequestModelDefinition";
|
2
|
-
export declare const
|
2
|
+
export declare const createChangeRequestModel: () => import("@webiny/api-headless-cms").CmsPrivateModelFull;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.createChangeRequestModel = exports.CHANGE_REQUEST_MODEL_ID = void 0;
|
7
7
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
8
8
|
var _utils = require("./utils");
|
9
9
|
const bodyField = () => (0, _utils.createModelField)({
|
@@ -37,14 +37,14 @@ const stepField = () => (0, _utils.createModelField)({
|
|
37
37
|
});
|
38
38
|
const CHANGE_REQUEST_MODEL_ID = "apwChangeRequestModelDefinition";
|
39
39
|
exports.CHANGE_REQUEST_MODEL_ID = CHANGE_REQUEST_MODEL_ID;
|
40
|
-
const
|
41
|
-
return (0, _apiHeadlessCms.
|
40
|
+
const createChangeRequestModel = () => {
|
41
|
+
return (0, _apiHeadlessCms.createPrivateModel)({
|
42
42
|
name: "APW - Change Request",
|
43
43
|
modelId: CHANGE_REQUEST_MODEL_ID,
|
44
44
|
titleFieldId: "title",
|
45
45
|
fields: [bodyField(), titleField(), resolvedField(), mediaField(), stepField()]
|
46
46
|
});
|
47
47
|
};
|
48
|
-
exports.
|
48
|
+
exports.createChangeRequestModel = createChangeRequestModel;
|
49
49
|
|
50
50
|
//# sourceMappingURL=changeRequest.model.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_apiHeadlessCms","require","_utils","bodyField","createModelField","label","type","parent","titleField","resolvedField","mediaField","stepField","validation","message","name","CHANGE_REQUEST_MODEL_ID","exports","
|
1
|
+
{"version":3,"names":["_apiHeadlessCms","require","_utils","bodyField","createModelField","label","type","parent","titleField","resolvedField","mediaField","stepField","validation","message","name","CHANGE_REQUEST_MODEL_ID","exports","createChangeRequestModel","createPrivateModel","modelId","titleFieldId","fields"],"sources":["changeRequest.model.ts"],"sourcesContent":["import { createPrivateModel } from \"@webiny/api-headless-cms\";\nimport { createModelField } from \"./utils\";\n\nconst bodyField = () =>\n createModelField({\n label: \"Body\",\n type: \"rich-text\",\n parent: \"changeRequest\"\n });\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"changeRequest\"\n });\n\nconst resolvedField = () =>\n createModelField({\n label: \"Resolved\",\n type: \"boolean\",\n parent: \"changeRequest\"\n });\n\nconst mediaField = () =>\n createModelField({\n label: \"Media\",\n type: \"file\",\n parent: \"changeRequest\"\n });\n\nconst stepField = () =>\n createModelField({\n label: \"Step\",\n type: \"text\",\n parent: \"changeRequest\",\n validation: [\n {\n message: \"`step` field value is required in changeRequest.\",\n name: \"required\"\n }\n ]\n });\n\nexport const CHANGE_REQUEST_MODEL_ID = \"apwChangeRequestModelDefinition\";\n\nexport const createChangeRequestModel = () => {\n return createPrivateModel({\n name: \"APW - Change Request\",\n modelId: CHANGE_REQUEST_MODEL_ID,\n titleFieldId: \"title\",\n fields: [bodyField(), titleField(), resolvedField(), mediaField(), stepField()]\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,MAAME,SAAS,GAAGA,CAAA,KACd,IAAAC,uBAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,WAAW;EACjBC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEN,MAAMC,UAAU,GAAGA,CAAA,KACf,IAAAJ,uBAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEN,MAAME,aAAa,GAAGA,CAAA,KAClB,IAAAL,uBAAgB,EAAC;EACbC,KAAK,EAAE,UAAU;EACjBC,IAAI,EAAE,SAAS;EACfC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEN,MAAMG,UAAU,GAAGA,CAAA,KACf,IAAAN,uBAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEN,MAAMI,SAAS,GAAGA,CAAA,KACd,IAAAP,uBAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,eAAe;EACvBK,UAAU,EAAE,CACR;IACIC,OAAO,EAAE,kDAAkD;IAC3DC,IAAI,EAAE;EACV,CAAC;AAET,CAAC,CAAC;AAEC,MAAMC,uBAAuB,GAAG,iCAAiC;AAACC,OAAA,CAAAD,uBAAA,GAAAA,uBAAA;AAElE,MAAME,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,OAAO,IAAAC,kCAAkB,EAAC;IACtBJ,IAAI,EAAE,sBAAsB;IAC5BK,OAAO,EAAEJ,uBAAuB;IAChCK,YAAY,EAAE,OAAO;IACrBC,MAAM,EAAE,CAAClB,SAAS,CAAC,CAAC,EAAEK,UAAU,CAAC,CAAC,EAAEC,aAAa,CAAC,CAAC,EAAEC,UAAU,CAAC,CAAC,EAAEC,SAAS,CAAC,CAAC;EAClF,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAAC,wBAAA,GAAAA,wBAAA"}
|
@@ -2,5 +2,5 @@ interface CreateCommentModelDefinitionParams {
|
|
2
2
|
modelId: string;
|
3
3
|
}
|
4
4
|
export declare const COMMENT_MODEL_ID = "apwCommentModelDefinition";
|
5
|
-
export declare const
|
5
|
+
export declare const createCommentModel: ({ modelId }: CreateCommentModelDefinitionParams) => import("@webiny/api-headless-cms").CmsPrivateModelFull;
|
6
6
|
export {};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.createCommentModel = exports.COMMENT_MODEL_ID = void 0;
|
7
7
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
8
8
|
var _utils = require("./utils");
|
9
9
|
const commentBody = () => (0, _utils.createModelField)({
|
@@ -37,16 +37,16 @@ const mediaField = () => (0, _utils.createModelField)({
|
|
37
37
|
});
|
38
38
|
const COMMENT_MODEL_ID = "apwCommentModelDefinition";
|
39
39
|
exports.COMMENT_MODEL_ID = COMMENT_MODEL_ID;
|
40
|
-
const
|
40
|
+
const createCommentModel = ({
|
41
41
|
modelId
|
42
42
|
}) => {
|
43
|
-
return (0, _apiHeadlessCms.
|
43
|
+
return (0, _apiHeadlessCms.createPrivateModel)({
|
44
44
|
name: "APW - Comment",
|
45
45
|
modelId: COMMENT_MODEL_ID,
|
46
46
|
titleFieldId: "step",
|
47
47
|
fields: [commentBody(), changeRequestRef(modelId), stepField(), mediaField()]
|
48
48
|
});
|
49
49
|
};
|
50
|
-
exports.
|
50
|
+
exports.createCommentModel = createCommentModel;
|
51
51
|
|
52
52
|
//# sourceMappingURL=comment.model.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_apiHeadlessCms","require","_utils","commentBody","createModelField","label","type","parent","changeRequestRef","modelId","settings","models","stepField","validation","message","name","mediaField","COMMENT_MODEL_ID","exports","
|
1
|
+
{"version":3,"names":["_apiHeadlessCms","require","_utils","commentBody","createModelField","label","type","parent","changeRequestRef","modelId","settings","models","stepField","validation","message","name","mediaField","COMMENT_MODEL_ID","exports","createCommentModel","createPrivateModel","titleFieldId","fields"],"sources":["comment.model.ts"],"sourcesContent":["import { createPrivateModel } from \"@webiny/api-headless-cms\";\nimport { createModelField } from \"./utils\";\n\nconst commentBody = () =>\n createModelField({\n label: \"Body\",\n type: \"rich-text\",\n parent: \"comment\"\n });\n\nconst changeRequestRef = (modelId: string) =>\n createModelField({\n label: \"Change Request\",\n type: \"ref\",\n parent: \"comment\",\n settings: {\n models: [\n {\n modelId\n }\n ]\n }\n });\n\nconst stepField = () =>\n createModelField({\n label: \"Step\",\n type: \"text\",\n parent: \"comment\",\n validation: [\n {\n message: \"`step` field value is required in comment.\",\n name: \"required\"\n }\n ]\n });\n\nconst mediaField = () =>\n createModelField({\n label: \"Media\",\n type: \"file\",\n parent: \"comment\"\n });\n\ninterface CreateCommentModelDefinitionParams {\n modelId: string;\n}\n\nexport const COMMENT_MODEL_ID = \"apwCommentModelDefinition\";\n\nexport const createCommentModel = ({ modelId }: CreateCommentModelDefinitionParams) => {\n return createPrivateModel({\n name: \"APW - Comment\",\n modelId: COMMENT_MODEL_ID,\n titleFieldId: \"step\",\n fields: [commentBody(), changeRequestRef(modelId), stepField(), mediaField()]\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,MAAME,WAAW,GAAGA,CAAA,KAChB,IAAAC,uBAAgB,EAAC;EACbC,KAAK,EAA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MODEL_ID = "apwContentReviewModelDefinition";
|
5
|
-
export declare const
|
5
|
+
export declare const createContentReviewModel: ({ reviewerModelId }: CreateContentReviewModelDefinitionParams) => import("@webiny/api-headless-cms").CmsPrivateModelFull;
|
6
6
|
export {};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.createContentReviewModel = exports.CONTENT_REVIEW_MODEL_ID = void 0;
|
7
7
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
8
8
|
var _utils = require("./utils");
|
9
9
|
var _workflow = require("./workflow.model");
|
@@ -219,16 +219,16 @@ const stepsField = fields => ({
|
|
219
219
|
});
|
220
220
|
const CONTENT_REVIEW_MODEL_ID = "apwContentReviewModelDefinition";
|
221
221
|
exports.CONTENT_REVIEW_MODEL_ID = CONTENT_REVIEW_MODEL_ID;
|
222
|
-
const
|
222
|
+
const createContentReviewModel = ({
|
223
223
|
reviewerModelId
|
224
224
|
}) => {
|
225
|
-
return (0, _apiHeadlessCms.
|
225
|
+
return (0, _apiHeadlessCms.createPrivateModel)({
|
226
226
|
name: "APW - Content Review",
|
227
227
|
modelId: CONTENT_REVIEW_MODEL_ID,
|
228
228
|
titleFieldId: "content",
|
229
229
|
fields: [titleField(), contentField([contentIdField(), contentTypeField(), contentSettingsField([contentSettingsModelIdField()]), contentScheduledOnField(), contentScheduledByField(), scheduledActionIdField(), contentPublishedByField()]), contentStatus(), stepsField([(0, _workflow.stepTitleField)(), (0, _workflow.stepTypeField)(), (0, _workflow.stepIdField)(), (0, _workflow.stepReviewersField)(reviewerModelId), stepStatusField(), stepPendingChangeRequests(), stepTotalComments(), stepSignOffProvidedOn(), stepSignOffProvidedBy([stepSignOffProvidedById(), stepSignOffProvidedByDisplayName()])]), latestCommentId(), workflowIdField()]
|
230
230
|
});
|
231
231
|
};
|
232
|
-
exports.
|
232
|
+
exports.createContentReviewModel = createContentReviewModel;
|
233
233
|
|
234
234
|
//# sourceMappingURL=contentReview.model.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_apiHeadlessCms","require","_utils","_workflow","contentField","fields","createModelField","label","parent","type","multipleValues","settings","validation","message","name","contentStatus","fieldId","predefinedValues","enabled","values","value","titleField","contentIdField","workflowIdField","contentTypeField","contentSettingsField","contentSettingsModelIdField","scheduledActionIdField","contentScheduledOnField","contentScheduledByField","contentPublishedByField","stepStatusField","listValidation","renderer","id","storageId","stepPendingChangeRequests","stepTotalComments","latestCommentId","stepSignOffProvidedOn","stepSignOffProvidedBy","stepSignOffProvidedById","stepSignOffProvidedByDisplayName","stepsField","layout","map","field","CONTENT_REVIEW_MODEL_ID","exports","createContentReviewModelDefinition","reviewerModelId","createPrivateModelDefinition","modelId","titleFieldId","stepTitleField","stepTypeField","stepIdField","stepReviewersField"],"sources":["contentReview.model.ts"],"sourcesContent":["import { createPrivateModelDefinition } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { createModelField } from \"./utils\";\nimport { stepTitleField, stepTypeField, stepIdField, stepReviewersField } from \"./workflow.model\";\n\nconst contentField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Content\",\n parent: \"contentReview\",\n type: \"object\",\n multipleValues: false,\n settings: { fields },\n validation: [\n {\n message: \"`content` field value is required in contentReview.\",\n name: \"required\"\n }\n ]\n });\n\nconst contentStatus = () =>\n createModelField({\n label: \"Status\",\n fieldId: \"reviewStatus\",\n parent: \"contentReview\",\n type: \"text\",\n predefinedValues: {\n enabled: true,\n values: [\n {\n label: \"Under review\",\n value: \"underReview\"\n },\n {\n label: \"Ready to be published\",\n value: \"readyToBePublished\"\n },\n {\n label: \"Published\",\n value: \"published\"\n }\n ]\n },\n validation: [\n {\n message: \"`reviewStatus` field value is required in contentReview.\",\n name: \"required\"\n }\n ]\n });\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"contentReview\",\n validation: [\n {\n message: \"`title` field value is required in contentReview.\",\n name: \"required\"\n }\n ]\n });\n\nconst contentIdField = () =>\n createModelField({\n label: \"Id\",\n type: \"text\",\n parent: \"contentReview Content\",\n validation: [\n {\n message: \"`id` field value is required in contentReview Content.\",\n name: \"required\"\n }\n ]\n });\n\nconst workflowIdField = () =>\n createModelField({\n label: \"Workflow Id\",\n type: \"text\",\n parent: \"contentReview\",\n validation: [\n {\n message: \"`workflowId` field value is required in contentReview Content.\",\n name: \"required\"\n }\n ]\n });\n\nconst contentTypeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n parent: \"contentReview Type\",\n predefinedValues: {\n enabled: true,\n values: [\n {\n label: \"Page\",\n value: \"page\"\n },\n { value: \"cms_entry\", label: \"CMS Entry\" }\n ]\n },\n validation: [\n {\n message: \"`type` field value is required in contentReview Type.\",\n name: \"required\"\n }\n ]\n });\n\nconst contentSettingsField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Settings\",\n parent: \"contentReview Content\",\n type: \"object\",\n multipleValues: false,\n settings: { fields }\n });\n\nconst contentSettingsModelIdField = () =>\n createModelField({\n label: \"Model Id\",\n parent: \"contentReview Settings\",\n type: \"text\"\n });\n\nconst scheduledActionIdField = () =>\n createModelField({\n label: \"Scheduled action Id\",\n type: \"text\",\n parent: \"contentReview Content\"\n });\n\nconst contentScheduledOnField = () =>\n createModelField({\n label: \"Scheduled on\",\n type: \"datetime\",\n parent: \"contentReview Content\"\n });\n\nconst contentScheduledByField = () =>\n createModelField({\n label: \"Scheduled by\",\n type: \"text\",\n parent: \"contentReview Content\"\n });\n\nconst contentPublishedByField = () =>\n createModelField({\n label: \"Published by\",\n type: \"text\",\n parent: \"contentReview Content\"\n });\n\nconst stepStatusField = (): CmsModelField => ({\n multipleValues: false,\n listValidation: [],\n renderer: {\n name: \"radio-buttons\"\n },\n predefinedValues: {\n enabled: true,\n values: [\n {\n value: \"done\",\n label: \"Steps done\"\n },\n {\n value: \"active\",\n label: \"Step active\"\n },\n {\n value: \"inactive\",\n label: \"Step inactive\"\n }\n ]\n },\n label: \"Status\",\n id: \"contentReview_steps_status\",\n type: \"text\",\n validation: [\n {\n message: \"`status` field value is required in contentReview steps status.\",\n name: \"required\"\n }\n ],\n storageId: \"status\",\n fieldId: \"status\"\n});\n\nconst stepPendingChangeRequests = () =>\n createModelField({\n label: \"Pending change requests\",\n type: \"number\",\n parent: \"contentReview Step\",\n validation: [\n {\n message: \"`pendingChangeRequests` field value is required in contentReview step.\",\n name: \"required\"\n }\n ]\n });\n\nconst stepTotalComments = () =>\n createModelField({\n label: \"Total comments\",\n type: \"number\",\n parent: \"contentReview Step\",\n validation: [\n {\n message: \"`totalComments` field value is required in contentReview step.\",\n name: \"required\"\n }\n ]\n });\n\nconst latestCommentId = () =>\n createModelField({\n label: \"Latest comment Id\",\n type: \"text\",\n parent: \"contentReview\"\n });\n\nconst stepSignOffProvidedOn = () =>\n createModelField({\n label: \"Sign off provided on\",\n type: \"datetime\",\n parent: \"contentReview Step\"\n });\n\nconst stepSignOffProvidedBy = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Sign off provided By\",\n type: \"object\",\n parent: \"contentReview Step\",\n multipleValues: false,\n settings: { fields }\n });\n\nconst stepSignOffProvidedById = () =>\n createModelField({\n label: \"Id\",\n type: \"text\",\n parent: \"contentReview Step\"\n });\n\nconst stepSignOffProvidedByDisplayName = () =>\n createModelField({\n label: \"DisplayName\",\n type: \"text\",\n parent: \"contentReview Step\"\n });\n\nconst stepsField = (fields: CmsModelField[]): CmsModelField => ({\n id: \"contentReview_steps\",\n label: \"Steps\",\n type: \"object\",\n settings: {\n fields,\n layout: fields.map(field => [field.storageId])\n },\n listValidation: [],\n validation: [],\n fieldId: \"steps\",\n storageId: \"steps\",\n multipleValues: true,\n predefinedValues: {\n values: [],\n enabled: false\n }\n});\n\ninterface CreateContentReviewModelDefinitionParams {\n reviewerModelId: string;\n}\n\nexport const CONTENT_REVIEW_MODEL_ID = \"apwContentReviewModelDefinition\";\n\nexport const createContentReviewModelDefinition = ({\n reviewerModelId\n}: CreateContentReviewModelDefinitionParams) => {\n return createPrivateModelDefinition({\n name: \"APW - Content Review\",\n modelId: CONTENT_REVIEW_MODEL_ID,\n titleFieldId: \"content\",\n fields: [\n titleField(),\n contentField([\n contentIdField(),\n contentTypeField(),\n contentSettingsField([contentSettingsModelIdField()]),\n contentScheduledOnField(),\n contentScheduledByField(),\n scheduledActionIdField(),\n contentPublishedByField()\n ]),\n contentStatus(),\n stepsField([\n stepTitleField(),\n stepTypeField(),\n stepIdField(),\n stepReviewersField(reviewerModelId),\n stepStatusField(),\n stepPendingChangeRequests(),\n stepTotalComments(),\n stepSignOffProvidedOn(),\n stepSignOffProvidedBy([\n stepSignOffProvidedById(),\n stepSignOffProvidedByDisplayName()\n ])\n ]),\n latestCommentId(),\n workflowIdField()\n ]\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA,MAAMG,YAAY,GAAIC,MAAuB,IACzC,IAAAC,uBAAgB,EAAC;EACbC,KAAK,EAAE,SAAS;EAChBC,MAAM,EAAE,eAAe;EACvBC,IAAI,EAAE,QAAQ;EACdC,cAAc,EAAE,KAAK;EACrBC,QAAQ,EAAE;IAAEN;EAAO,CAAC;EACpBO,UAAU,EAAE,CACR;IACIC,OAAO,EAAE,qDAAqD;IAC9DC,IAAI,EAAE;EACV,CAAC;AAET,CAAC,CAAC;AAEN,MAAMC,aAAa,GAAGA,CAAA,KAClB,IAAAT,uBAAgB,EAAC;EACbC,KAAK,EAAE,QAAQ;EACfS,OAAO,EAAE,cAAc;EACvBR,MAAM,EAAE,eAAe;EACvBC,IAAI,EAAE,MAAM;EACZQ,gBAAgB,EAAE;IACdC,OAAO,EAAE,IAAI;IACbC,MAAM,EAAE,CACJ;MACIZ,KAAK,EAAE,cAAc;MACrBa,KAAK,EAAE;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AA4B,EAAC;IAChCrC,IAAI,EAAE,sBAAsB;IAC5BsC,OAAO,EAAEL,uBAAuB;IAChCM,YAAY,EAAE,SAAS;IACvBhD,MAAM,EAAE,CACJgB,UAAU,CAAC,CAAC,EACZjB,YAAY,CAAC,CACTkB,cAAc,CAAC,CAAC,EAChBE,gBAAgB,CAAC,CAAC,EAClBC,oBAAoB,CAAC,CAACC,2BAA2B,CAAC,CAAC,CAAC,CAAC,EACrDE,uBAAuB,CAAC,CAAC,EACzBC,uBAAuB,CAAC,CAAC,EACzBF,sBAAsB,CAAC,CAAC,EACxBG,uBAAuB,CAAC,CAAC,CAC5B,CAAC,EACFf,aAAa,CAAC,CAAC,EACf4B,UAAU,CAAC,CACP,IAAAW,wBAAc,EAAC,CAAC,EAChB,IAAAC,uBAAa,EAAC,CAAC,EACf,IAAAC,qBAAW,EAAC,CAAC,EACb,IAAAC,4BAAkB,EAACP,eAAe,CAAC,EACnCnB,eAAe,CAAC,CAAC,EACjBK,yBAAyB,CAAC,CAAC,EAC3BC,iBAAiB,CAAC,CAAC,EACnBE,qBAAqB,CAAC,CAAC,EACvBC,qBAAqB,CAAC,CAClBC,uBAAuB,CAAC,CAAC,EACzBC,gCAAgC,CAAC,CAAC,CACrC,CAAC,CACL,CAAC,EACFJ,eAAe,CAAC,CAAC,EACjBf,eAAe,CAAC,CAAC;EAEzB,CAAC,CAAC;AACN,CAAC;AAACyB,OAAA,CAAAC,kCAAA,GAAAA,kCAAA"}
|
1
|
+
{"version":3,"names":["_apiHeadlessCms","require","_utils","_workflow","contentField","fields","createModelField","label","parent","type","multipleValues","settings","validation","message","name","contentStatus","fieldId","predefinedValues","enabled","values","value","titleField","contentIdField","workflowIdField","contentTypeField","contentSettingsField","contentSettingsModelIdField","scheduledActionIdField","contentScheduledOnField","contentScheduledByField","contentPublishedByField","stepStatusField","listValidation","renderer","id","storageId","stepPendingChangeRequests","stepTotalComments","latestCommentId","stepSignOffProvidedOn","stepSignOffProvidedBy","stepSignOffProvidedById","stepSignOffProvidedByDisplayName","stepsField","layout","map","field","CONTENT_REVIEW_MODEL_ID","exports","createContentReviewModel","reviewerModelId","createPrivateModel","modelId","titleFieldId","stepTitleField","stepTypeField","stepIdField","stepReviewersField"],"sources":["contentReview.model.ts"],"sourcesContent":["import { createPrivateModel } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { createModelField } from \"./utils\";\nimport { stepTitleField, stepTypeField, stepIdField, stepReviewersField } from \"./workflow.model\";\n\nconst contentField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Content\",\n parent: \"contentReview\",\n type: \"object\",\n multipleValues: false,\n settings: { fields },\n validation: [\n {\n message: \"`content` field value is required in contentReview.\",\n name: \"required\"\n }\n ]\n });\n\nconst contentStatus = () =>\n createModelField({\n label: \"Status\",\n fieldId: \"reviewStatus\",\n parent: \"contentReview\",\n type: \"text\",\n predefinedValues: {\n enabled: true,\n values: [\n {\n label: \"Under review\",\n value: \"underReview\"\n },\n {\n label: \"Ready to be published\",\n value: \"readyToBePublished\"\n },\n {\n label: \"Published\",\n value: \"published\"\n }\n ]\n },\n validation: [\n {\n message: \"`reviewStatus` field value is required in contentReview.\",\n name: \"required\"\n }\n ]\n });\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"contentReview\",\n validation: [\n {\n message: \"`title` field value is required in contentReview.\",\n name: \"required\"\n }\n ]\n });\n\nconst contentIdField = () =>\n createModelField({\n label: \"Id\",\n type: \"text\",\n parent: \"contentReview Content\",\n validation: [\n {\n message: \"`id` field value is required in contentReview Content.\",\n name: \"required\"\n }\n ]\n });\n\nconst workflowIdField = () =>\n createModelField({\n label: \"Workflow Id\",\n type: \"text\",\n parent: \"contentReview\",\n validation: [\n {\n message: \"`workflowId` field value is required in contentReview Content.\",\n name: \"required\"\n }\n ]\n });\n\nconst contentTypeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n parent: \"contentReview Type\",\n predefinedValues: {\n enabled: true,\n values: [\n {\n label: \"Page\",\n value: \"page\"\n },\n { value: \"cms_entry\", label: \"CMS Entry\" }\n ]\n },\n validation: [\n {\n message: \"`type` field value is required in contentReview Type.\",\n name: \"required\"\n }\n ]\n });\n\nconst contentSettingsField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Settings\",\n parent: \"contentReview Content\",\n type: \"object\",\n multipleValues: false,\n settings: { fields }\n });\n\nconst contentSettingsModelIdField = () =>\n createModelField({\n label: \"Model Id\",\n parent: \"contentReview Settings\",\n type: \"text\"\n });\n\nconst scheduledActionIdField = () =>\n createModelField({\n label: \"Scheduled action Id\",\n type: \"text\",\n parent: \"contentReview Content\"\n });\n\nconst contentScheduledOnField = () =>\n createModelField({\n label: \"Scheduled on\",\n type: \"datetime\",\n parent: \"contentReview Content\"\n });\n\nconst contentScheduledByField = () =>\n createModelField({\n label: \"Scheduled by\",\n type: \"text\",\n parent: \"contentReview Content\"\n });\n\nconst contentPublishedByField = () =>\n createModelField({\n label: \"Published by\",\n type: \"text\",\n parent: \"contentReview Content\"\n });\n\nconst stepStatusField = (): CmsModelField => ({\n multipleValues: false,\n listValidation: [],\n renderer: {\n name: \"radio-buttons\"\n },\n predefinedValues: {\n enabled: true,\n values: [\n {\n value: \"done\",\n label: \"Steps done\"\n },\n {\n value: \"active\",\n label: \"Step active\"\n },\n {\n value: \"inactive\",\n label: \"Step inactive\"\n }\n ]\n },\n label: \"Status\",\n id: \"contentReview_steps_status\",\n type: \"text\",\n validation: [\n {\n message: \"`status` field value is required in contentReview steps status.\",\n name: \"required\"\n }\n ],\n storageId: \"status\",\n fieldId: \"status\"\n});\n\nconst stepPendingChangeRequests = () =>\n createModelField({\n label: \"Pending change requests\",\n type: \"number\",\n parent: \"contentReview Step\",\n validation: [\n {\n message: \"`pendingChangeRequests` field value is required in contentReview step.\",\n name: \"required\"\n }\n ]\n });\n\nconst stepTotalComments = () =>\n createModelField({\n label: \"Total comments\",\n type: \"number\",\n parent: \"contentReview Step\",\n validation: [\n {\n message: \"`totalComments` field value is required in contentReview step.\",\n name: \"required\"\n }\n ]\n });\n\nconst latestCommentId = () =>\n createModelField({\n label: \"Latest comment Id\",\n type: \"text\",\n parent: \"contentReview\"\n });\n\nconst stepSignOffProvidedOn = () =>\n createModelField({\n label: \"Sign off provided on\",\n type: \"datetime\",\n parent: \"contentReview Step\"\n });\n\nconst stepSignOffProvidedBy = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Sign off provided By\",\n type: \"object\",\n parent: \"contentReview Step\",\n multipleValues: false,\n settings: { fields }\n });\n\nconst stepSignOffProvidedById = () =>\n createModelField({\n label: \"Id\",\n type: \"text\",\n parent: \"contentReview Step\"\n });\n\nconst stepSignOffProvidedByDisplayName = () =>\n createModelField({\n label: \"DisplayName\",\n type: \"text\",\n parent: \"contentReview Step\"\n });\n\nconst stepsField = (fields: CmsModelField[]): CmsModelField => ({\n id: \"contentReview_steps\",\n label: \"Steps\",\n type: \"object\",\n settings: {\n fields,\n layout: fields.map(field => [field.storageId])\n },\n listValidation: [],\n validation: [],\n fieldId: \"steps\",\n storageId: \"steps\",\n multipleValues: true,\n predefinedValues: {\n values: [],\n enabled: false\n }\n});\n\ninterface CreateContentReviewModelDefinitionParams {\n reviewerModelId: string;\n}\n\nexport const CONTENT_REVIEW_MODEL_ID = \"apwContentReviewModelDefinition\";\n\nexport const createContentReviewModel = ({\n reviewerModelId\n}: CreateContentReviewModelDefinitionParams) => {\n return createPrivateModel({\n name: \"APW - Content Review\",\n modelId: CONTENT_REVIEW_MODEL_ID,\n titleFieldId: \"content\",\n fields: [\n titleField(),\n contentField([\n contentIdField(),\n contentTypeField(),\n contentSettingsField([contentSettingsModelIdField()]),\n contentScheduledOnField(),\n contentScheduledByField(),\n scheduledActionIdField(),\n contentPublishedByField()\n ]),\n contentStatus(),\n stepsField([\n stepTitleField(),\n stepTypeField(),\n stepIdField(),\n stepReviewersField(reviewerModelId),\n stepStatusField(),\n stepPendingChangeRequests(),\n stepTotalComments(),\n stepSignOffProvidedOn(),\n stepSignOffProvidedBy([\n stepSignOffProvidedById(),\n stepSignOffProvidedByDisplayName()\n ])\n ]),\n latestCommentId(),\n workflowIdField()\n ]\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA,MAAMG,YAAY,GAAIC,MAAuB,IACzC,IAAAC,uBAAgB,EAAC;EACbC,KAAK,EAAE,SAAS;EAChBC,MAAM,EAAE,eAAe;EACvBC,IAAI,EAAE,QAAQ;EACdC,cAAc,EAAE,KAAK;EACrBC,QAAQ,EAAE;IAAEN;EAAO,CAAC;EACpBO,UAAU,EAAE,CACR;IACIC,OAAO,EAAE,qDAAqD;IAC9DC,IAAI,EAAE;EACV,CAAC;AAET,CAAC,CAAC;AAEN,MAAMC,aAAa,GAAGA,CAAA,KAClB,IAAAT,uBAAgB,EAAC;EACbC,KAAK,EAAE,QAAQ;EACfS,OAAO,EAAE,cAAc;EACvBR,MAAM,EAAE,eAAe;EACvBC,IAAI,EAAE,MAAM;EACZQ,gBAAgB,EAAE;IACdC,OAAO,EAAE,IAAI;IACbC,MAAM,EAAE,CACJ;MACIZ,KAAK,EAAE,cAAc;MACrBa,KAAK,EAAE;IACX,CAAC,EACD;MACIb,KAAK,EAAE,uBAAuB;MAC9Ba,KAAK,EAAE;IACX,CAAC,EACD;MACIb,KAAK,EAAE,WAAW;MAClBa,KAAK,EAAE;IACX,CAAC;EAET,CAAC;EACDR,UAAU,EAAE,CACR;IACIC,OAAO,EAAE,0DAA0D;IACnEC,IAAI,EAAE;EACV,CAAC;AAET,CAAC,CAAC;AAEN,MAAMO,UAAU,GAAGA,CAAA,KACf,IAAAf,uBAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdE,IAAI,EAAE,MAAM;EACZD,MAAM,EAAE,eAAe;EACvBI,UAAU,EAAE,CACR;IACIC,OAAO,E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,CAAC,CAAC,EACf4B,UAAU,CAAC,CACP,IAAAW,wBAAc,EAAC,CAAC,EAChB,IAAAC,uBAAa,EAAC,CAAC,EACf,IAAAC,qBAAW,EAAC,CAAC,EACb,IAAAC,4BAAkB,EAACP,eAAe,CAAC,EACnCnB,eAAe,CAAC,CAAC,EACjBK,yBAAyB,CAAC,CAAC,EAC3BC,iBAAiB,CAAC,CAAC,EACnBE,qBAAqB,CAAC,CAAC,EACvBC,qBAAqB,CAAC,CAClBC,uBAAuB,CAAC,CAAC,EACzBC,gCAAgC,CAAC,CAAC,CACrC,CAAC,CACL,CAAC,EACFJ,eAAe,CAAC,CAAC,EACjBf,eAAe,CAAC,CAAC;EAEzB,CAAC,CAAC;AACN,CAAC;AAACyB,OAAA,CAAAC,wBAAA,GAAAA,wBAAA"}
|
@@ -36,15 +36,15 @@ const createApwModels = context => {
|
|
36
36
|
/**
|
37
37
|
* Create CmsModel plugins.
|
38
38
|
*/
|
39
|
-
const changeRequestModelDefinition = (0, _changeRequest.
|
40
|
-
const reviewerModelDefinition = (0, _reviewer.
|
41
|
-
const workflowModelDefinition = (0, _workflow.
|
39
|
+
const changeRequestModelDefinition = (0, _changeRequest.createChangeRequestModel)();
|
40
|
+
const reviewerModelDefinition = (0, _reviewer.createReviewerModel)();
|
41
|
+
const workflowModelDefinition = (0, _workflow.createWorkflowModel)({
|
42
42
|
reviewerModelId: reviewerModelDefinition.modelId
|
43
43
|
});
|
44
|
-
const commentModelDefinition = (0, _comment.
|
44
|
+
const commentModelDefinition = (0, _comment.createCommentModel)({
|
45
45
|
modelId: changeRequestModelDefinition.modelId
|
46
46
|
});
|
47
|
-
const contentReviewModelDefinition = (0, _contentReview.
|
47
|
+
const contentReviewModelDefinition = (0, _contentReview.createContentReviewModel)({
|
48
48
|
reviewerModelId: reviewerModelDefinition.modelId
|
49
49
|
});
|
50
50
|
const modelDefinitions = [workflowModelDefinition, contentReviewModelDefinition, reviewerModelDefinition, changeRequestModelDefinition, commentModelDefinition];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_apiHeadlessCms","_workflow","_contentReview","_reviewer","_comment","_changeRequest","_utils","createApwModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","locale","getContentLocale","WebinyError","changeRequestModelDefinition","
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_apiHeadlessCms","_workflow","_contentReview","_reviewer","_comment","_changeRequest","_utils","createApwModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","locale","getContentLocale","WebinyError","changeRequestModelDefinition","createChangeRequestModel","reviewerModelDefinition","createReviewerModel","workflowModelDefinition","createWorkflowModel","reviewerModelId","modelId","commentModelDefinition","createCommentModel","contentReviewModelDefinition","createContentReviewModel","modelDefinitions","cmsModelPlugins","modelDefinition","cmsModelPlugin","createCmsModel","contentModel","titleFieldId","push","plugins","register","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin, createCmsModel } from \"@webiny/api-headless-cms\";\nimport { createWorkflowModel } from \"./workflow.model\";\nimport { createContentReviewModel } from \"./contentReview.model\";\nimport { createReviewerModel } from \"./reviewer.model\";\nimport { createCommentModel } from \"./comment.model\";\nimport { createChangeRequestModel } from \"./changeRequest.model\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { isInstallationPending } from \"~/plugins/utils\";\n\nexport const createApwModels = (context: CmsContext) => {\n /**\n * This should never happen in the actual project.\n * It is to make sure that we load setup context before the CRUD init in our internal code.\n */\n if (!context.cms) {\n console.warn(\"Creating model before cms init.\");\n return;\n }\n\n if (isInstallationPending({ tenancy: context.tenancy, i18n: context.i18n })) {\n return;\n }\n\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-apw/storageOperations/index.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n /**\n * Create CmsModel plugins.\n */\n const changeRequestModelDefinition = createChangeRequestModel();\n const reviewerModelDefinition = createReviewerModel();\n const workflowModelDefinition = createWorkflowModel({\n reviewerModelId: reviewerModelDefinition.modelId\n });\n const commentModelDefinition = createCommentModel({\n modelId: changeRequestModelDefinition.modelId\n });\n const contentReviewModelDefinition = createContentReviewModel({\n reviewerModelId: reviewerModelDefinition.modelId\n });\n\n const modelDefinitions = [\n workflowModelDefinition,\n contentReviewModelDefinition,\n reviewerModelDefinition,\n changeRequestModelDefinition,\n commentModelDefinition\n ];\n\n const cmsModelPlugins: CmsModelPlugin[] = [];\n for (const modelDefinition of modelDefinitions) {\n const cmsModelPlugin = createCmsModel(modelDefinition);\n /**\n * We want \"title\" field as the title field for \"ContentReview\" model.\n * so that we can later search entries by title.\n */\n if (cmsModelPlugin.contentModel.modelId === \"apwContentReviewModelDefinition\") {\n cmsModelPlugin.contentModel.titleFieldId = \"title\";\n }\n cmsModelPlugins.push(cmsModelPlugin);\n }\n\n /**\n * Register them so that they are accessible in cms context\n */\n context.plugins.register(...cmsModelPlugins);\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AAEA,IAAAO,MAAA,GAAAP,OAAA;AAEO,MAAMQ,eAAe,GAAIC,OAAmB,IAAK;EACpD;AACJ;AACA;AACA;EACI,IAAI,CAACA,OAAO,CAACC,GAAG,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,iCAAiC,CAAC;IAC/C;EACJ;EAEA,IAAI,IAAAC,4BAAqB,EAAC;IAAEC,OAAO,EAAEL,OAAO,CAACK,OAAO;IAAEC,IAAI,EAAEN,OAAO,CAACM;EAAK,CAAC,CAAC,EAAE;IACzE;EACJ;EAEA,MAAMC,MAAM,GAAGP,OAAO,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|
2
|
-
export declare const
|
2
|
+
export declare const createReviewerModel: () => import("@webiny/api-headless-cms").CmsPrivateModelFull;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.createReviewerModel = exports.REVIEWER_MODEL_ID = void 0;
|
7
7
|
var _utils = require("./utils");
|
8
8
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
9
9
|
const idField = () => (0, _utils.createModelField)({
|
@@ -50,14 +50,14 @@ const emailField = () => (0, _utils.createModelField)({
|
|
50
50
|
});
|
51
51
|
const REVIEWER_MODEL_ID = "apwReviewerModelDefinition";
|
52
52
|
exports.REVIEWER_MODEL_ID = REVIEWER_MODEL_ID;
|
53
|
-
const
|
54
|
-
return (0, _apiHeadlessCms.
|
53
|
+
const createReviewerModel = () => {
|
54
|
+
return (0, _apiHeadlessCms.createPrivateModel)({
|
55
55
|
name: "APW - Reviewer",
|
56
56
|
titleFieldId: "displayName",
|
57
57
|
modelId: REVIEWER_MODEL_ID,
|
58
58
|
fields: [idField(), displayNameField(), typeField(), emailField()]
|
59
59
|
});
|
60
60
|
};
|
61
|
-
exports.
|
61
|
+
exports.createReviewerModel = createReviewerModel;
|
62
62
|
|
63
63
|
//# sourceMappingURL=reviewer.model.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_utils","require","_apiHeadlessCms","idField","createModelField","label","type","parent","validation","message","name","displayNameField","typeField","emailField","fieldId","settings","preset","regex","flags","REVIEWER_MODEL_ID","exports","
|
1
|
+
{"version":3,"names":["_utils","require","_apiHeadlessCms","idField","createModelField","label","type","parent","validation","message","name","displayNameField","typeField","emailField","fieldId","settings","preset","regex","flags","REVIEWER_MODEL_ID","exports","createReviewerModel","createPrivateModel","titleFieldId","modelId","fields"],"sources":["reviewer.model.ts"],"sourcesContent":["import { createModelField } from \"./utils\";\nimport { createPrivateModel } from \"@webiny/api-headless-cms\";\n\nconst idField = () =>\n createModelField({\n label: \"Identity Id\",\n type: \"text\",\n parent: \"reviewer\",\n validation: [\n {\n message: \"`identityId` field value is required in reviewer.\",\n name: \"required\"\n }\n ]\n });\n\nconst displayNameField = () =>\n createModelField({\n label: \"Display Name\",\n type: \"text\",\n parent: \"reviewer\",\n validation: [\n {\n message: \"`displayName` field value is required in reviewer.\",\n name: \"required\"\n }\n ]\n });\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n parent: \"reviewer\",\n validation: [\n {\n message: \"`type` field value is required in reviewer.\",\n name: \"required\"\n }\n ]\n });\n\nconst emailField = () =>\n createModelField({\n label: \"E-mail\",\n fieldId: \"email\",\n type: \"text\",\n parent: \"reviewer\",\n validation: [\n {\n message: \"`email` field value in reviewer accepts only e-mails.\",\n name: \"pattern\",\n settings: {\n preset: \"email\",\n regex: null,\n flags: null\n }\n }\n ]\n });\n\nexport const REVIEWER_MODEL_ID = \"apwReviewerModelDefinition\";\n\nexport const createReviewerModel = () => {\n return createPrivateModel({\n name: \"APW - Reviewer\",\n titleFieldId: \"displayName\",\n modelId: REVIEWER_MODEL_ID,\n fields: [idField(), displayNameField(), typeField(), emailField()]\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEA,MAAME,OAAO,GAAGA,CAAA,KACZ,IAAAC,uBAAgB,EAAC;EACbC,KAAK,EAAE,aAAa;EACpBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,UAAU;EAClBC,UAAU,EAAE,CACR;IACIC,OAAO,EAAE,mDAAmD;IAC5DC,IAAI,EAAE;EACV,CAAC;AAET,CAAC,CAAC;AAEN,MAAMC,gBAAgB,GAAGA,CAAA,KACrB,IAAAP,uBAAgB,EAAC;EACbC,KAAK,EAAE,cAAc;EACrBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,UAAU;EAClBC,UAAU,EAAE,CACR;IACIC,OAAO,EAAE,oDAAoD;IAC7DC,IAAI,EAAE;EACV,CAAC;AAET,CAAC,CAAC;AAEN,MAAME,SAAS,GAAGA,CAAA,KACd,IAAAR,uBAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,UAAU;EAClBC,UAAU,EAAE,CACR;IACIC,OAAO,EAAE,6CAA6C;IACtDC,IAAI,EAAE;EACV,CAAC;AAET,CAAC,CAAC;AAEN,MAAMG,UAAU,GAAGA,CAAA,KACf,IAAAT,uBAAgB,EAAC;EACbC,KAAK,EAAE,QAAQ;EACfS,OAAO,EAAE,OAAO;EAChBR,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,UAAU;EAClBC,UAAU,EAAE,CACR;IACIC,OAAO,EAAE,uDAAuD;IAChEC,IAAI,EAAE,SAAS;IACfK,QAAQ,EAAE;MACNC,MAAM,EAAE,OAAO;MACfC,KAAK,EAAE,IAAI;MACXC,KAAK,EAAE;IACX;EACJ,CAAC;AAET,CAAC,CAAC;AAEC,MAAMC,iBAAiB,GAAG,4BAA4B;AAACC,OAAA,CAAAD,iBAAA,GAAAA,iBAAA;AAEvD,MAAME,mBAAmB,GAAGA,CAAA,KAAM;EACrC,OAAO,IAAAC,kCAAkB,EAAC;IACtBZ,IAAI,EAAE,gBAAgB;IACtBa,YAAY,EAAE,aAAa;IAC3BC,OAAO,EAAEL,iBAAiB;IAC1BM,MAAM,EAAE,CAACtB,OAAO,CAAC,CAAC,EAAEQ,gBAAgB,CAAC,CAAC,EAAEC,SAAS,CAAC,CAAC,EAAEC,UAAU,CAAC,CAAC;EACrE,CAAC,CAAC;AACN,CAAC;AAACO,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
|
@@ -7,5 +7,5 @@ interface CreateWorkflowModelDefinitionParams {
|
|
7
7
|
reviewerModelId: string;
|
8
8
|
}
|
9
9
|
export declare const WORKFLOW_MODEL_ID = "apwWorkflowModelDefinition";
|
10
|
-
export declare const
|
10
|
+
export declare const createWorkflowModel: ({ reviewerModelId }: CreateWorkflowModelDefinitionParams) => import("@webiny/api-headless-cms").CmsPrivateModelFull;
|
11
11
|
export {};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.stepTypeField = exports.stepTitleField = exports.stepReviewersField = exports.stepIdField = exports.
|
6
|
+
exports.stepTypeField = exports.stepTitleField = exports.stepReviewersField = exports.stepIdField = exports.createWorkflowModel = exports.WORKFLOW_MODEL_ID = void 0;
|
7
7
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
8
8
|
var _utils = require("./utils");
|
9
9
|
var _types = require("../../types");
|
@@ -167,10 +167,10 @@ const applicationField = () => (0, _utils.createModelField)({
|
|
167
167
|
});
|
168
168
|
const WORKFLOW_MODEL_ID = "apwWorkflowModelDefinition";
|
169
169
|
exports.WORKFLOW_MODEL_ID = WORKFLOW_MODEL_ID;
|
170
|
-
const
|
170
|
+
const createWorkflowModel = ({
|
171
171
|
reviewerModelId
|
172
172
|
}) => {
|
173
|
-
return (0, _apiHeadlessCms.
|
173
|
+
return (0, _apiHeadlessCms.createPrivateModel)({
|
174
174
|
name: "APW - Workflow",
|
175
175
|
/**
|
176
176
|
* Id of the model cannot be appWorkflow because it clashes with the GraphQL types for APW.
|
@@ -180,6 +180,6 @@ const createWorkflowModelDefinition = ({
|
|
180
180
|
fields: [titleField(), stepsField([stepTitleField(), stepTypeField(), stepIdField(), stepReviewersField(reviewerModelId)]), scopeField([scopeTypeField(), scopeDataField([scopeDataPbCategories(), scopeDataPbPages(), scopeDataCmsModels(), scopeDataCmsEntries()])]), applicationField()]
|
181
181
|
});
|
182
182
|
};
|
183
|
-
exports.
|
183
|
+
exports.createWorkflowModel = createWorkflowModel;
|
184
184
|
|
185
185
|
//# sourceMappingURL=workflow.model.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_apiHeadlessCms","require","_utils","_types","titleField","createModelField","label","type","parent","validation","message","name","stepsField","fields","settings","multipleValues","stepTitleField","exports","stepTypeField","predefinedValues","enabled","values","value","stepIdField","stepReviewersField","reviewerModelId","models","modelId","listValidation","scopeField","scopeTypeField","WorkflowScopeTypes","DEFAULT","CUSTOM","scopeDataField","scopeDataPbCategories","scopeDataPbPages","scopeDataCmsModels","scopeDataCmsEntries","applicationField","WORKFLOW_MODEL_ID","createWorkflowModelDefinition","createPrivateModelDefinition","titleFieldId"],"sources":["workflow.model.ts"],"sourcesContent":["import { createPrivateModelDefinition } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { createModelField } from \"./utils\";\nimport { WorkflowScopeTypes } from \"~/types\";\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"workflow\",\n validation: [\n {\n message: \"`title` field value is required in workflow.\",\n name: \"required\"\n }\n ]\n });\n\nconst stepsField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Steps\",\n type: \"object\",\n parent: \"workflow\",\n settings: {\n fields\n },\n multipleValues: true\n });\n\nexport const stepTitleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"workflow steps\",\n validation: [\n {\n message: \"`title` field value is required in workflow steps.\",\n name: \"required\"\n }\n ]\n });\n\nexport const stepTypeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n parent: \"workflow steps\",\n predefinedValues: {\n enabled: true,\n values: [\n {\n value: \"mandatoryBlocking\",\n label: \"Mandatory, blocking - An approval from a reviewer is required before being able to move to the next step and publish the content. \"\n },\n {\n value: \"mandatoryNonBlocking\",\n label: \"Mandatory, non-blocking - An approval from a reviewer is to publish the content, but the next step in the review workflow is not blocked. \"\n },\n {\n value: \"notMandatory\",\n label: \"Not mandatory - This is an optional review step. The content can be published regardless if an approval is provided or not.\"\n }\n ]\n },\n validation: [\n {\n name: \"required\",\n message: \"`type` field value is required in workflow steps.\"\n }\n ]\n });\n\nexport const stepIdField = () =>\n createModelField({\n label: \"Id\",\n type: \"text\",\n parent: \"workflow steps\",\n validation: [\n {\n message: \"`id` field value is required in workflow steps.\",\n name: \"required\"\n }\n ]\n });\n\nexport const stepReviewersField = (reviewerModelId: string) =>\n createModelField({\n label: \"Reviewers\",\n type: \"ref\",\n parent: \"workflow steps\",\n multipleValues: true,\n settings: {\n models: [\n {\n modelId: reviewerModelId\n }\n ]\n },\n listValidation: [\n {\n name: \"minLength\",\n message: \"Value is too short.\",\n settings: {\n value: \"1\"\n }\n }\n ]\n });\n\nconst scopeField = (fields: CmsModelField[]) =>\n createModelField({\n type: \"object\",\n label: \"Scope\",\n parent: \"workflow\",\n settings: {\n fields\n }\n });\n\nconst scopeTypeField = () =>\n createModelField({\n label: \"Type\",\n parent: \"workflow scope\",\n type: \"text\",\n validation: [\n {\n message: \"`type` field value is required in workflow scope.\",\n name: \"required\"\n }\n ],\n predefinedValues: {\n enabled: true,\n values: [\n {\n value: WorkflowScopeTypes.DEFAULT,\n label: \"Default - Catch all scope that applies to all content that's being published.\"\n },\n {\n value: WorkflowScopeTypes.CUSTOM,\n label: \"Custom - The workflow will be applied to all selected content.\"\n }\n ]\n }\n });\n\nconst scopeDataField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Data\",\n parent: \"workflow scope\",\n type: \"object\",\n settings: {\n fields\n }\n });\n\nconst scopeDataPbCategories = () =>\n createModelField({\n label: \"Categories\",\n parent: \"workflow scope data\",\n type: \"text\",\n multipleValues: true\n });\nconst scopeDataPbPages = () =>\n createModelField({\n label: \"Pages\",\n parent: \"workflow scope data\",\n type: \"text\",\n multipleValues: true\n });\nconst scopeDataCmsModels = () =>\n createModelField({\n label: \"Models\",\n parent: \"workflow scope data\",\n type: \"text\",\n multipleValues: true\n });\nconst scopeDataCmsEntries = () =>\n createModelField({\n label: \"Entries\",\n parent: \"workflow scope data\",\n type: \"text\",\n multipleValues: true\n });\n\nconst applicationField = () =>\n createModelField({\n parent: \"workflow\",\n type: \"text\",\n label: \"App\",\n validation: [\n {\n message: \"`app` field value is required in workflow.\",\n name: \"required\"\n }\n ],\n predefinedValues: {\n enabled: true,\n values: [\n { label: \"Page Builder\", value: \"pageBuilder\" },\n { label: \"Headless CMS\", value: \"cms\" }\n ]\n }\n });\n\ninterface CreateWorkflowModelDefinitionParams {\n reviewerModelId: string;\n}\n\nexport const WORKFLOW_MODEL_ID = \"apwWorkflowModelDefinition\";\n\nexport const createWorkflowModelDefinition = ({\n reviewerModelId\n}: CreateWorkflowModelDefinitionParams) => {\n return createPrivateModelDefinition({\n name: \"APW - Workflow\",\n /**\n * Id of the model cannot be appWorkflow because it clashes with the GraphQL types for APW.\n */\n modelId: WORKFLOW_MODEL_ID,\n titleFieldId: \"title\",\n fields: [\n titleField(),\n stepsField([\n stepTitleField(),\n stepTypeField(),\n stepIdField(),\n stepReviewersField(reviewerModelId)\n ]),\n scopeField([\n scopeTypeField(),\n scopeDataField([\n scopeDataPbCategories(),\n scopeDataPbPages(),\n scopeDataCmsModels(),\n scopeDataCmsEntries()\n ])\n ]),\n applicationField()\n ]\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,MAAMG,UAAU,GAAGA,CAAA,KACf,IAAAC,uBAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,UAAU;EAClBC,UAAU,EAAE,CACR;IACIC,OAAO,EAAE,8CAA8C;IACvDC,IAAI,EAAE;EACV,CAAC;AAET,CAAC,CAAC;AAEN,MAAMC,UAAU,GAAIC,MAAuB,IACvC,IAAAR,uBAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,UAAU;EAClBM,QAAQ,EAAE;IACND;EACJ,CAAC;EACDE,cAAc,EAAE;AACpB,CAAC,CAAC;A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C;IAChC/B,IAAI,EAAE,gBAAgB;IACtB;AACR;AACA;IACQgB,OAAO,EAAEa,iBAAiB;IAC1BG,YAAY,EAAE,OAAO;IACrB9B,MAAM,EAAE,CACJT,UAAU,CAAC,CAAC,EACZQ,UAAU,CAAC,CACPI,cAAc,CAAC,CAAC,EAChBE,aAAa,CAAC,CAAC,EACfK,WAAW,CAAC,CAAC,EACbC,kBAAkB,CAACC,eAAe,CAAC,CACtC,CAAC,EACFI,UAAU,CAAC,CACPC,cAAc,CAAC,CAAC,EAChBI,cAAc,CAAC,CACXC,qBAAqB,CAAC,CAAC,EACvBC,gBAAgB,CAAC,CAAC,EAClBC,kBAAkB,CAAC,CAAC,EACpBC,mBAAmB,CAAC,CAAC,CACxB,CAAC,CACL,CAAC,EACFC,gBAAgB,CAAC,CAAC;EAE1B,CAAC,CAAC;AACN,CAAC;AAACtB,OAAA,CAAAwB,6BAAA,GAAAA,6BAAA"}
|
1
|
+
{"version":3,"names":["_apiHeadlessCms","require","_utils","_types","titleField","createModelField","label","type","parent","validation","message","name","stepsField","fields","settings","multipleValues","stepTitleField","exports","stepTypeField","predefinedValues","enabled","values","value","stepIdField","stepReviewersField","reviewerModelId","models","modelId","listValidation","scopeField","scopeTypeField","WorkflowScopeTypes","DEFAULT","CUSTOM","scopeDataField","scopeDataPbCategories","scopeDataPbPages","scopeDataCmsModels","scopeDataCmsEntries","applicationField","WORKFLOW_MODEL_ID","createWorkflowModel","createPrivateModel","titleFieldId"],"sources":["workflow.model.ts"],"sourcesContent":["import { createPrivateModel } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { createModelField } from \"./utils\";\nimport { WorkflowScopeTypes } from \"~/types\";\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"workflow\",\n validation: [\n {\n message: \"`title` field value is required in workflow.\",\n name: \"required\"\n }\n ]\n });\n\nconst stepsField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Steps\",\n type: \"object\",\n parent: \"workflow\",\n settings: {\n fields\n },\n multipleValues: true\n });\n\nexport const stepTitleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"workflow steps\",\n validation: [\n {\n message: \"`title` field value is required in workflow steps.\",\n name: \"required\"\n }\n ]\n });\n\nexport const stepTypeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n parent: \"workflow steps\",\n predefinedValues: {\n enabled: true,\n values: [\n {\n value: \"mandatoryBlocking\",\n label: \"Mandatory, blocking - An approval from a reviewer is required before being able to move to the next step and publish the content. \"\n },\n {\n value: \"mandatoryNonBlocking\",\n label: \"Mandatory, non-blocking - An approval from a reviewer is to publish the content, but the next step in the review workflow is not blocked. \"\n },\n {\n value: \"notMandatory\",\n label: \"Not mandatory - This is an optional review step. The content can be published regardless if an approval is provided or not.\"\n }\n ]\n },\n validation: [\n {\n name: \"required\",\n message: \"`type` field value is required in workflow steps.\"\n }\n ]\n });\n\nexport const stepIdField = () =>\n createModelField({\n label: \"Id\",\n type: \"text\",\n parent: \"workflow steps\",\n validation: [\n {\n message: \"`id` field value is required in workflow steps.\",\n name: \"required\"\n }\n ]\n });\n\nexport const stepReviewersField = (reviewerModelId: string) =>\n createModelField({\n label: \"Reviewers\",\n type: \"ref\",\n parent: \"workflow steps\",\n multipleValues: true,\n settings: {\n models: [\n {\n modelId: reviewerModelId\n }\n ]\n },\n listValidation: [\n {\n name: \"minLength\",\n message: \"Value is too short.\",\n settings: {\n value: \"1\"\n }\n }\n ]\n });\n\nconst scopeField = (fields: CmsModelField[]) =>\n createModelField({\n type: \"object\",\n label: \"Scope\",\n parent: \"workflow\",\n settings: {\n fields\n }\n });\n\nconst scopeTypeField = () =>\n createModelField({\n label: \"Type\",\n parent: \"workflow scope\",\n type: \"text\",\n validation: [\n {\n message: \"`type` field value is required in workflow scope.\",\n name: \"required\"\n }\n ],\n predefinedValues: {\n enabled: true,\n values: [\n {\n value: WorkflowScopeTypes.DEFAULT,\n label: \"Default - Catch all scope that applies to all content that's being published.\"\n },\n {\n value: WorkflowScopeTypes.CUSTOM,\n label: \"Custom - The workflow will be applied to all selected content.\"\n }\n ]\n }\n });\n\nconst scopeDataField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Data\",\n parent: \"workflow scope\",\n type: \"object\",\n settings: {\n fields\n }\n });\n\nconst scopeDataPbCategories = () =>\n createModelField({\n label: \"Categories\",\n parent: \"workflow scope data\",\n type: \"text\",\n multipleValues: true\n });\nconst scopeDataPbPages = () =>\n createModelField({\n label: \"Pages\",\n parent: \"workflow scope data\",\n type: \"text\",\n multipleValues: true\n });\nconst scopeDataCmsModels = () =>\n createModelField({\n label: \"Models\",\n parent: \"workflow scope data\",\n type: \"text\",\n multipleValues: true\n });\nconst scopeDataCmsEntries = () =>\n createModelField({\n label: \"Entries\",\n parent: \"workflow scope data\",\n type: \"text\",\n multipleValues: true\n });\n\nconst applicationField = () =>\n createModelField({\n parent: \"workflow\",\n type: \"text\",\n label: \"App\",\n validation: [\n {\n message: \"`app` field value is required in workflow.\",\n name: \"required\"\n }\n ],\n predefinedValues: {\n enabled: true,\n values: [\n { label: \"Page Builder\", value: \"pageBuilder\" },\n { label: \"Headless CMS\", value: \"cms\" }\n ]\n }\n });\n\ninterface CreateWorkflowModelDefinitionParams {\n reviewerModelId: string;\n}\n\nexport const WORKFLOW_MODEL_ID = \"apwWorkflowModelDefinition\";\n\nexport const createWorkflowModel = ({ reviewerModelId }: CreateWorkflowModelDefinitionParams) => {\n return createPrivateModel({\n name: \"APW - Workflow\",\n /**\n * Id of the model cannot be appWorkflow because it clashes with the GraphQL types for APW.\n */\n modelId: WORKFLOW_MODEL_ID,\n titleFieldId: \"title\",\n fields: [\n titleField(),\n stepsField([\n stepTitleField(),\n stepTypeField(),\n stepIdField(),\n stepReviewersField(reviewerModelId)\n ]),\n scopeField([\n scopeTypeField(),\n scopeDataField([\n scopeDataPbCategories(),\n scopeDataPbPages(),\n scopeDataCmsModels(),\n scope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types";
|
2
2
|
import { CreateApwStorageOperationsParams } from "./";
|
3
|
-
export declare const createReviewerStorageOperations: ({ cms
|
3
|
+
export declare const createReviewerStorageOperations: ({ cms }: CreateApwStorageOperationsParams) => ApwReviewerStorageOperations;
|
@@ -8,13 +8,10 @@ exports.createReviewerStorageOperations = void 0;
|
|
8
8
|
var _pickEntryFieldValues = require("../utils/pickEntryFieldValues");
|
9
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
10
10
|
const createReviewerStorageOperations = ({
|
11
|
-
cms
|
12
|
-
security
|
11
|
+
cms
|
13
12
|
}) => {
|
14
13
|
const getReviewerModel = async () => {
|
15
|
-
const model = await
|
16
|
-
return cms.getModel("apwReviewerModelDefinition");
|
17
|
-
});
|
14
|
+
const model = await cms.getModel("apwReviewerModelDefinition");
|
18
15
|
if (!model) {
|
19
16
|
throw new _error.default("Could not find `apwReviewerModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
|
20
17
|
}
|
@@ -24,9 +21,7 @@ const createReviewerStorageOperations = ({
|
|
24
21
|
id
|
25
22
|
}) => {
|
26
23
|
const model = await getReviewerModel();
|
27
|
-
const entry = await
|
28
|
-
return cms.getEntryById(model, id);
|
29
|
-
});
|
24
|
+
const entry = await cms.getEntryById(model, id);
|
30
25
|
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
31
26
|
};
|
32
27
|
return {
|
@@ -34,21 +29,17 @@ const createReviewerStorageOperations = ({
|
|
34
29
|
getReviewer,
|
35
30
|
async listReviewers(params) {
|
36
31
|
const model = await getReviewerModel();
|
37
|
-
const [entries, meta] = await
|
38
|
-
|
39
|
-
|
40
|
-
where
|
41
|
-
|
42
|
-
}
|
43
|
-
});
|
32
|
+
const [entries, meta] = await cms.listLatestEntries(model, {
|
33
|
+
...params,
|
34
|
+
where: {
|
35
|
+
...params.where
|
36
|
+
}
|
44
37
|
});
|
45
38
|
return [entries.map(_pickEntryFieldValues.pickEntryFieldValues), meta];
|
46
39
|
},
|
47
40
|
async createReviewer(params) {
|
48
41
|
const model = await getReviewerModel();
|
49
|
-
const entry = await
|
50
|
-
return cms.createEntry(model, params.data);
|
51
|
-
});
|
42
|
+
const entry = await cms.createEntry(model, params.data);
|
52
43
|
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
53
44
|
},
|
54
45
|
async updateReviewer(params) {
|
@@ -60,20 +51,16 @@ const createReviewerStorageOperations = ({
|
|
60
51
|
const existingEntry = await getReviewer({
|
61
52
|
id: params.id
|
62
53
|
});
|
63
|
-
const entry = await
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
savedOn: new Date()
|
68
|
-
});
|
54
|
+
const entry = await cms.updateEntry(model, params.id, {
|
55
|
+
...existingEntry,
|
56
|
+
...params.data,
|
57
|
+
savedOn: new Date()
|
69
58
|
});
|
70
59
|
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
71
60
|
},
|
72
61
|
async deleteReviewer(params) {
|
73
62
|
const model = await getReviewerModel();
|
74
|
-
await
|
75
|
-
return cms.deleteEntry(model, params.id);
|
76
|
-
});
|
63
|
+
await cms.deleteEntry(model, params.id);
|
77
64
|
return true;
|
78
65
|
}
|
79
66
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_pickEntryFieldValues","require","_error","_interopRequireDefault","createReviewerStorageOperations","cms","
|
1
|
+
{"version":3,"names":["_pickEntryFieldValues","require","_error","_interopRequireDefault","createReviewerStorageOperations","cms","getReviewerModel","model","getModel","WebinyError","getReviewer","id","entry","getEntryById","pickEntryFieldValues","listReviewers","params","entries","meta","listLatestEntries","where","map","createReviewer","createEntry","data","updateReviewer","existingEntry","updateEntry","savedOn","Date","deleteReviewer","deleteEntry","exports"],"sources":["reviewerStorageOperations.ts"],"sourcesContent":["import { ApwReviewerStorageOperations } from \"./types\";\nimport { CreateApwStorageOperationsParams } from \"~/storageOperations\";\nimport { pickEntryFieldValues } from \"~/utils/pickEntryFieldValues\";\nimport WebinyError from \"@webiny/error\";\nimport { ApwReviewer } from \"~/types\";\n\nexport const createReviewerStorageOperations = ({\n cms\n}: CreateApwStorageOperationsParams): ApwReviewerStorageOperations => {\n const getReviewerModel = async () => {\n const model = await cms.getModel(\"apwReviewerModelDefinition\");\n if (!model) {\n throw new WebinyError(\n \"Could not find `apwReviewerModelDefinition` model.\",\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getReviewer: ApwReviewerStorageOperations[\"getReviewer\"] = async ({ id }) => {\n const model = await getReviewerModel();\n\n const entry = await cms.getEntryById(model, id);\n return pickEntryFieldValues(entry);\n };\n return {\n getReviewerModel,\n getReviewer,\n async listReviewers(params) {\n const model = await getReviewerModel();\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n return [entries.map(pickEntryFieldValues<ApwReviewer>), meta];\n },\n async createReviewer(params) {\n const model = await getReviewerModel();\n const entry = await cms.createEntry(model, params.data);\n return pickEntryFieldValues(entry);\n },\n async updateReviewer(params) {\n const model = await getReviewerModel();\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getReviewer({ id: params.id });\n\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data,\n savedOn: new Date()\n });\n return pickEntryFieldValues(entry);\n },\n async deleteReviewer(params) {\n const model = await getReviewerModel();\n\n await cms.deleteEntry(model, params.id);\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAGO,MAAMG,+BAA+B,GAAGA,CAAC;EAC5CC;AAC8B,CAAC,KAAmC;EAClE,MAAMC,gBAAgB,GAAG,MAAAA,CAAA,KAAY;IACjC,MAAMC,KAAK,GAAG,MAAMF,GAAG,CAACG,QAAQ,CAAC,4BAA4B,CAAC;IAC9D,IAAI,CAACD,KAAK,EAAE;MACR,MAA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AAG,CAACsB,WAAW,CAACpB,KAAK,EAAES,MAAM,CAACL,EAAE,EAAE;QAClD,GAAGe,aAAa;QAChB,GAAGV,MAAM,CAACQ,IAAI;QACdI,OAAO,EAAE,IAAIC,IAAI,CAAC;MACtB,CAAC,CAAC;MACF,OAAO,IAAAf,0CAAoB,EAACF,KAAK,CAAC;IACtC,CAAC;IACD,MAAMkB,cAAcA,CAACd,MAAM,EAAE;MACzB,MAAMT,KAAK,GAAG,MAAMD,gBAAgB,CAAC,CAAC;MAEtC,MAAMD,GAAG,CAAC0B,WAAW,CAACxB,KAAK,EAAES,MAAM,CAACL,EAAE,CAAC;MACvC,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAACqB,OAAA,CAAA5B,+BAAA,GAAAA,+BAAA"}
|
@@ -22,13 +22,10 @@ const formatReviewersForRefInput = (data, modelId) => {
|
|
22
22
|
};
|
23
23
|
const createWorkflowStorageOperations = params => {
|
24
24
|
const {
|
25
|
-
cms
|
26
|
-
security
|
25
|
+
cms
|
27
26
|
} = params;
|
28
27
|
const getWorkflowModel = async () => {
|
29
|
-
const model = await
|
30
|
-
return cms.getModel(_workflow.WORKFLOW_MODEL_ID);
|
31
|
-
});
|
28
|
+
const model = await cms.getModel(_workflow.WORKFLOW_MODEL_ID);
|
32
29
|
if (!model) {
|
33
30
|
throw new _error.default(`Could not find "${_workflow.WORKFLOW_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
34
31
|
}
|
@@ -38,9 +35,7 @@ const createWorkflowStorageOperations = params => {
|
|
38
35
|
id
|
39
36
|
}) => {
|
40
37
|
const model = await getWorkflowModel();
|
41
|
-
const entry = await
|
42
|
-
return cms.getEntryById(model, id);
|
43
|
-
});
|
38
|
+
const entry = await cms.getEntryById(model, id);
|
44
39
|
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
45
40
|
};
|
46
41
|
return {
|
@@ -48,13 +43,11 @@ const createWorkflowStorageOperations = params => {
|
|
48
43
|
getWorkflow,
|
49
44
|
async listWorkflows(params) {
|
50
45
|
const model = await getWorkflowModel();
|
51
|
-
const [entries, meta] = await
|
52
|
-
|
53
|
-
|
54
|
-
where
|
55
|
-
|
56
|
-
}
|
57
|
-
});
|
46
|
+
const [entries, meta] = await cms.listLatestEntries(model, {
|
47
|
+
...params,
|
48
|
+
where: {
|
49
|
+
...params.where
|
50
|
+
}
|
58
51
|
});
|
59
52
|
return [entries.map(_pickEntryFieldValues.pickEntryFieldValues), meta];
|
60
53
|
},
|
@@ -62,9 +55,7 @@ const createWorkflowStorageOperations = params => {
|
|
62
55
|
const model = await getWorkflowModel();
|
63
56
|
const reviewerModel = await this.getReviewerModel();
|
64
57
|
const data = formatReviewersForRefInput(params.data, reviewerModel.modelId);
|
65
|
-
const entry = await
|
66
|
-
return cms.createEntry(model, data);
|
67
|
-
});
|
58
|
+
const entry = await cms.createEntry(model, data);
|
68
59
|
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
69
60
|
},
|
70
61
|
async updateWorkflow(params) {
|
@@ -83,16 +74,12 @@ const createWorkflowStorageOperations = params => {
|
|
83
74
|
savedOn: new Date()
|
84
75
|
};
|
85
76
|
const data = formatReviewersForRefInput(input, reviewerModel.modelId);
|
86
|
-
const entry = await
|
87
|
-
return cms.updateEntry(model, params.id, data);
|
88
|
-
});
|
77
|
+
const entry = await cms.updateEntry(model, params.id, data);
|
89
78
|
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
90
79
|
},
|
91
80
|
async deleteWorkflow(params) {
|
92
81
|
const model = await getWorkflowModel();
|
93
|
-
await
|
94
|
-
return cms.deleteEntry(model, params.id);
|
95
|
-
});
|
82
|
+
await cms.deleteEntry(model, params.id);
|
96
83
|
return true;
|
97
84
|
}
|
98
85
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_pickEntryFieldValues","require","_error","_interopRequireDefault","_workflow","formatReviewersForRefInput","data","modelId","steps","map","step","reviewers","id","createWorkflowStorageOperations","params","cms","
|
1
|
+
{"version":3,"names":["_pickEntryFieldValues","require","_error","_interopRequireDefault","_workflow","formatReviewersForRefInput","data","modelId","steps","map","step","reviewers","id","createWorkflowStorageOperations","params","cms","getWorkflowModel","model","getModel","WORKFLOW_MODEL_ID","WebinyError","getWorkflow","entry","getEntryById","pickEntryFieldValues","listWorkflows","entries","meta","listLatestEntries","where","createWorkflow","reviewerModel","getReviewerModel","createEntry","updateWorkflow","existingEntry","input","savedOn","Date","updateEntry","deleteWorkflow","deleteEntry","exports"],"sources":["workflowStorageOperations.ts"],"sourcesContent":["import { ApwWorkflow, CreateApwWorkflowParams } from \"~/types\";\nimport { ApwStorageOperations, ApwWorkflowStorageOperations } from \"./types\";\nimport { CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { pickEntryFieldValues } from \"~/utils/pickEntryFieldValues\";\nimport WebinyError from \"@webiny/error\";\nimport { WORKFLOW_MODEL_ID } from \"~/storageOperations/models/workflow.model\";\n\ntype ReviewersRefInput = CreateApwWorkflowParams<{ modelId: string; id: string }>;\n\nconst formatReviewersForRefInput = (\n data: CreateApwWorkflowParams,\n modelId: string\n): ReviewersRefInput => {\n return {\n ...data,\n steps: data.steps.map(step => ({\n ...step,\n reviewers: step.reviewers.map(id => ({\n id,\n modelId\n }))\n }))\n };\n};\n\nexport const createWorkflowStorageOperations = (\n params: CreateApwStorageOperationsParams\n): ApwWorkflowStorageOperations => {\n const { cms } = params;\n const getWorkflowModel = async () => {\n const model = await cms.getModel(WORKFLOW_MODEL_ID);\n if (!model) {\n throw new WebinyError(\n `Could not find \"${WORKFLOW_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getWorkflow: ApwWorkflowStorageOperations[\"getWorkflow\"] = async ({ id }) => {\n const model = await getWorkflowModel();\n const entry = await cms.getEntryById(model, id);\n return pickEntryFieldValues(entry);\n };\n return {\n getWorkflowModel,\n getWorkflow,\n async listWorkflows(params) {\n const model = await getWorkflowModel();\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n return [entries.map(pickEntryFieldValues<ApwWorkflow>), meta];\n },\n async createWorkflow(this: ApwStorageOperations, params) {\n const model = await getWorkflowModel();\n const reviewerModel = await this.getReviewerModel();\n\n const data = formatReviewersForRefInput(params.data, reviewerModel.modelId);\n\n const entry = await cms.createEntry(model, data);\n\n return pickEntryFieldValues(entry);\n },\n async updateWorkflow(this: ApwStorageOperations, params) {\n const model = await getWorkflowModel();\n const reviewerModel = await this.getReviewerModel();\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getWorkflow({ id: params.id });\n const input = {\n ...existingEntry,\n ...params.data,\n savedOn: new Date()\n };\n const data = formatReviewersForRefInput(\n input as CreateApwWorkflowParams,\n reviewerModel.modelId\n );\n\n const entry = await cms.updateEntry(model, params.id, data);\n\n return pickEntryFieldValues(entry);\n },\n async deleteWorkflow(params) {\n const model = await getWorkflowModel();\n\n await cms.deleteEntry(model, params.id);\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAIA,MAAMI,0BAA0B,GAAGA,CAC/BC,IAA6B,EAC7BC,OAAe,KACK;EACpB,OAAO;IACH,GAAGD,IAAI;IACPE,KAAK,EAAEF,IAAI,CAACE,KAAK,CAACC,GAAG,CAACC,IAAI,KAAK;MAC3B,GAAGA,IAAI;MACPC,SAAS,EAAED,IAAI,CAACC,SAAS,CAACF,GAAG,CAACG,EAAE,KAAK;QACjCA,EAAE;QACFL;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAEM,MAAMM,+BAA+B,GACxCC,MAAwC,IACT;EAC/B,MAAM;IAAEC;EAAI,CAAC,GAAGD,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