@webiny/api-apw 0.0.0-unstable.611c5af35e → 0.0.0-unstable.6509387258
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/index.d.ts +0 -1
- package/index.js +1 -5
- package/index.js.map +1 -1
- package/package.json +34 -34
- package/plugins/context.d.ts +0 -1
- package/plugins/context.js +2 -16
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +2 -2
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +2 -2
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +5 -5
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +2 -2
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +2 -2
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +2 -2
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +8 -2
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +3 -8
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +3 -8
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +3 -8
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.js +15 -14
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/index.js +37 -7
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +14 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +2 -3
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +7 -2
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +2 -2
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +3 -59
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
- package/scheduler/handlers/scheduleAction/index.js +5 -1
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -0
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +0 -1
- package/scheduler/handlers/utils.js +0 -1
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/types.d.ts +2 -20
- package/scheduler/types.js +0 -5
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +20 -20
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +23 -23
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +20 -20
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.d.ts +3 -10
- package/storageOperations/models/contentModelPluginFactory.js +3 -6
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/index.js +0 -4
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +23 -28
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +20 -18
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +6 -5
- package/types.js.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["pickIdFromChangeRequest","obj","rawValue","id","createCommentStorageOperations","cms","getCmsContext","security","getCommentModel","
|
1
|
+
{"version":3,"names":["pickIdFromChangeRequest","obj","rawValue","id","createCommentStorageOperations","cms","getCmsContext","security","getCommentModel","model","withoutAuthorization","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","deleteComment","deleteEntry"],"sources":["commentStorageOperations.ts"],"sourcesContent":["import { ApwStorageOperations } from \"./types\";\nimport { ApwCommentStorageOperations } from \"./types\";\nimport { baseFields, CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\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 security\n}: CreateApwStorageOperationsParams): ApwCommentStorageOperations => {\n const getCommentModel = async () => {\n const model = await security.withoutAuthorization(async () => {\n return cms.getModel(COMMENT_MODEL_ID);\n });\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 security.withoutAuthorization(async () => {\n return cms.getEntryById(model, id);\n });\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 security.withoutAuthorization(async () => {\n return cms.listLatestEntries(model, 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 security.withoutAuthorization(async () => {\n return cms.createEntry(model, {\n ...params.data,\n changeRequest: {\n id: params.data.changeRequest,\n modelId: refModel.modelId\n }\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 security.withoutAuthorization(async () => {\n return cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\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 deleteComment(params) {\n const model = await getCommentModel();\n await security.withoutAuthorization(async () => {\n return cms.deleteEntry(model, params.id);\n });\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AAEA;AACA;AACA;AAGA;AAEA,MAAMA,uBAAuB,GAAIC,GAAwB,IAAiB;EACtE,MAAMC,QAAQ,GAAGD,GAAG,CAAC,eAAe,CAAC;EACrC,IAAI,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M,CAAC;MAChD,CAAC,CAAC;MACF,OAAOT,uBAAuB,CAACwB,MAAM,CAAC;IAC1C,CAAC;IACD,MAAMgB,aAAa,CAACjB,MAAM,EAAE;MACxB,MAAMd,KAAK,GAAG,MAAMD,eAAe,EAAE;MACrC;AACZ;AACA;AACA;MACY,MAAMiC,aAAa,GAAG,MAAM3B,UAAU,CAAC;QAAEX,EAAE,EAAEoB,MAAM,CAACpB;MAAG,CAAC,CAAC;MAEzD,MAAMY,KAAK,GAAG,MAAMR,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC1D,OAAOL,GAAG,CAACqC,WAAW,CAACjC,KAAK,EAAEc,MAAM,CAACpB,EAAE,8DAChCsC,aAAa,GACblB,MAAM,CAACc,IAAI,EAChB;MACN,CAAC,CAAC;MAEF,MAAMb,MAAM,GAAG,MAAM,IAAAP,6BAAc,EAAC;QAChCF,KAAK;QACLG,MAAM,EAAEC,iBAAU;QAClBC,OAAO,EAAEd,aAAa,EAAE;QACxBe,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACb,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;MACF,OAAOT,uBAAuB,CAACwB,MAAM,CAAC;IAC1C,CAAC;IACD,MAAMmB,aAAa,CAACpB,MAAM,EAAE;MACxB,MAAMd,KAAK,GAAG,MAAMD,eAAe,EAAE;MACrC,MAAMD,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC5C,OAAOL,GAAG,CAACuC,WAAW,CAACnC,KAAK,EAAEc,MAAM,CAACpB,EAAE,CAAC;MAC5C,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
|
@@ -14,9 +14,9 @@ const createContentReviewStorageOperations = ({
|
|
14
14
|
security
|
15
15
|
}) => {
|
16
16
|
const getContentReviewModel = async () => {
|
17
|
-
security.
|
18
|
-
|
19
|
-
|
17
|
+
const model = await security.withoutAuthorization(async () => {
|
18
|
+
return cms.getModel(_contentReview.CONTENT_REVIEW_MODEL_ID);
|
19
|
+
});
|
20
20
|
if (!model) {
|
21
21
|
throw new _error.default(`Could not find "${_contentReview.CONTENT_REVIEW_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
22
22
|
}
|
@@ -26,9 +26,9 @@ const createContentReviewStorageOperations = ({
|
|
26
26
|
id
|
27
27
|
}) => {
|
28
28
|
const model = await getContentReviewModel();
|
29
|
-
security.
|
30
|
-
|
31
|
-
|
29
|
+
const entry = await security.withoutAuthorization(async () => {
|
30
|
+
return cms.getEntryById(model, id);
|
31
|
+
});
|
32
32
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
33
33
|
};
|
34
34
|
return {
|
@@ -36,18 +36,18 @@ const createContentReviewStorageOperations = ({
|
|
36
36
|
getContentReview,
|
37
37
|
async listContentReviews(params) {
|
38
38
|
const model = await getContentReviewModel();
|
39
|
-
security.
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
const [entries, meta] = await security.withoutAuthorization(async () => {
|
40
|
+
return cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
41
|
+
where: (0, _objectSpread2.default)({}, params.where)
|
42
|
+
}));
|
43
|
+
});
|
44
44
|
return [entries.map(entry => (0, _index.getFieldValues)(entry, _index.baseFields)), meta];
|
45
45
|
},
|
46
46
|
async createContentReview(params) {
|
47
47
|
const model = await getContentReviewModel();
|
48
|
-
security.
|
49
|
-
|
50
|
-
|
48
|
+
const entry = await security.withoutAuthorization(async () => {
|
49
|
+
return cms.createEntry(model, params.data);
|
50
|
+
});
|
51
51
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
52
52
|
},
|
53
53
|
async updateContentReview(params) {
|
@@ -59,16 +59,16 @@ const createContentReviewStorageOperations = ({
|
|
59
59
|
const existingEntry = await getContentReview({
|
60
60
|
id: params.id
|
61
61
|
});
|
62
|
-
security.
|
63
|
-
|
64
|
-
|
62
|
+
const entry = await security.withoutAuthorization(async () => {
|
63
|
+
return cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
|
64
|
+
});
|
65
65
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
66
66
|
},
|
67
67
|
async deleteContentReview(params) {
|
68
68
|
const model = await getContentReviewModel();
|
69
|
-
security.
|
70
|
-
|
71
|
-
|
69
|
+
await security.withoutAuthorization(async () => {
|
70
|
+
return cms.deleteEntry(model, params.id);
|
71
|
+
});
|
72
72
|
return true;
|
73
73
|
}
|
74
74
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createContentReviewStorageOperations","cms","security","getContentReviewModel","
|
1
|
+
{"version":3,"names":["createContentReviewStorageOperations","cms","security","getContentReviewModel","model","withoutAuthorization","getModel","CONTENT_REVIEW_MODEL_ID","WebinyError","getContentReview","id","entry","getEntryById","getFieldValues","baseFields","listContentReviews","params","entries","meta","listLatestEntries","where","map","createContentReview","createEntry","data","updateContentReview","existingEntry","updateEntry","deleteContentReview","deleteEntry"],"sources":["contentReviewStorageOperations.ts"],"sourcesContent":["import { ApwContentReviewStorageOperations } from \"./types\";\nimport {\n baseFields,\n CreateApwStorageOperationsParams,\n getFieldValues\n} from \"~/storageOperations/index\";\nimport WebinyError from \"@webiny/error\";\nimport { CONTENT_REVIEW_MODEL_ID } from \"~/storageOperations/models/contentReview.model\";\n\nexport const createContentReviewStorageOperations = ({\n cms,\n security\n}: CreateApwStorageOperationsParams): ApwContentReviewStorageOperations => {\n const getContentReviewModel = async () => {\n const model = await security.withoutAuthorization(async () => {\n return cms.getModel(CONTENT_REVIEW_MODEL_ID);\n });\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 security.withoutAuthorization(async () => {\n return cms.getEntryById(model, id);\n });\n return getFieldValues(entry, baseFields);\n };\n return {\n getContentReviewModel,\n getContentReview,\n async listContentReviews(params) {\n const model = await getContentReviewModel();\n\n const [entries, meta] = await security.withoutAuthorization(async () => {\n return cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n });\n\n return [entries.map(entry => getFieldValues(entry, baseFields)), meta];\n },\n async createContentReview(params) {\n const model = await getContentReviewModel();\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.createEntry(model, params.data);\n });\n return getFieldValues(entry, baseFields);\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 security.withoutAuthorization(async () => {\n return cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n });\n return getFieldValues(entry, baseFields);\n },\n async deleteContentReview(params) {\n const model = await getContentReviewModel();\n\n await security.withoutAuthorization(async () => {\n return cms.deleteEntry(model, params.id);\n });\n\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AAKA;AACA;AAEO,MAAMA,oCAAoC,GAAG,CAAC;EACjDC,GAAG;EACHC;AAC8B,CAAC,KAAwC;EACvE,MAAMC,qBAAqB,GAAG,YAAY;IACtC,MAAMC,KAAK,GAAG,MAAMF,QAAQ,CAACG,oBAAoB,CAAC,YAAY;MAC1D,OAAOJ,GAAG,CAACK,QAAQ,CAACC,sCAAuB,CAAC;IAChD,CAAC,CAAC;IACF,IAAI,CAACH,KAAK,EAAE;MACR,MAAM,IAAII,cAAW,CAChB,mBAAkBD,sCAAwB,UAAS,EACpD,uBAAuB,CAC1B;IACL;IACA,OAAOH,KAAK;EAChB,CAAC;EACD,MAAMK,gBAAuE,GAAG,OAAO;IACnFC;EACJ,CAAC,KAAK;IACF,MAAMN,KAAK,GAAG,MAAMD,qBAAqB,EAAE;IAC3C,MAAMQ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AAC;MAE/D,MAAMC,KAAK,GAAG,MAAMT,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC1D,OAAOJ,GAAG,CAAC0B,WAAW,CAACvB,KAAK,EAAEY,MAAM,CAACN,EAAE,8DAChCgB,aAAa,GACbV,MAAM,CAACQ,IAAI,EAChB;MACN,CAAC,CAAC;MACF,OAAO,IAAAX,qBAAc,EAACF,KAAK,EAAEG,iBAAU,CAAC;IAC5C,CAAC;IACD,MAAMc,mBAAmB,CAACZ,MAAM,EAAE;MAC9B,MAAMZ,KAAK,GAAG,MAAMD,qBAAqB,EAAE;MAE3C,MAAMD,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC5C,OAAOJ,GAAG,CAAC4B,WAAW,CAACzB,KAAK,EAAEY,MAAM,CAACN,EAAE,CAAC;MAC5C,CAAC,CAAC;MAEF,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
|
@@ -1,15 +1,8 @@
|
|
1
|
-
import { CmsModelPlugin } from "@webiny/api-headless-cms";
|
2
|
-
import {
|
1
|
+
import { CmsModelPlugin, CmsPrivateModelFull } from "@webiny/api-headless-cms";
|
2
|
+
import { CmsGroup } from "@webiny/api-headless-cms/types";
|
3
3
|
interface Params {
|
4
4
|
group: Pick<CmsGroup, "id" | "name">;
|
5
|
-
|
6
|
-
* Locale and tenant do not need to be defined.
|
7
|
-
* In that case model is not bound to any locale or tenant.
|
8
|
-
* You can bind it to locale, tenant, both or none.
|
9
|
-
*/
|
10
|
-
locale?: string;
|
11
|
-
tenant?: string;
|
12
|
-
modelDefinition: Omit<CmsModel, "locale" | "tenant" | "webinyVersion" | "group">;
|
5
|
+
modelDefinition: Omit<CmsPrivateModelFull, "group" | "noValidate">;
|
13
6
|
}
|
14
7
|
export declare const contentModelPluginFactory: (params: Params) => CmsModelPlugin;
|
15
8
|
export {};
|
@@ -10,14 +10,11 @@ var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
10
10
|
const contentModelPluginFactory = params => {
|
11
11
|
const {
|
12
12
|
group,
|
13
|
-
locale,
|
14
|
-
tenant,
|
15
13
|
modelDefinition
|
16
14
|
} = params;
|
17
|
-
return (0, _apiHeadlessCms.createCmsModel)((0, _objectSpread2.default)({
|
15
|
+
return (0, _apiHeadlessCms.createCmsModel)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, modelDefinition), {}, {
|
18
16
|
group,
|
19
|
-
|
20
|
-
|
21
|
-
}, modelDefinition));
|
17
|
+
noValidate: true
|
18
|
+
}));
|
22
19
|
};
|
23
20
|
exports.contentModelPluginFactory = contentModelPluginFactory;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["contentModelPluginFactory","params","group","
|
1
|
+
{"version":3,"names":["contentModelPluginFactory","params","group","modelDefinition","createCmsModel","noValidate"],"sources":["contentModelPluginFactory.ts"],"sourcesContent":["import { CmsModelPlugin, CmsPrivateModelFull, createCmsModel } from \"@webiny/api-headless-cms\";\nimport { CmsGroup } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n group: Pick<CmsGroup, \"id\" | \"name\">;\n modelDefinition: Omit<CmsPrivateModelFull, \"group\" | \"noValidate\">;\n}\n\nexport const contentModelPluginFactory = (params: Params): CmsModelPlugin => {\n const { group, modelDefinition } = params;\n\n return createCmsModel({\n ...modelDefinition,\n group,\n noValidate: true\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAQO,MAAMA,yBAAyB,GAAIC,MAAc,IAAqB;EACzE,MAAM;IAAEC,KAAK;IAAEC;EAAgB,CAAC,GAAGF,MAAM;EAEzC,OAAO,IAAAG,8BAAc,8DACdD,eAAe;IAClBD,KAAK;IACLG,UAAU,EAAE;EAAI,GAClB;AACN,CAAC;AAAC"}
|
@@ -29,7 +29,6 @@ const createApwModels = context => {
|
|
29
29
|
})) {
|
30
30
|
return;
|
31
31
|
}
|
32
|
-
context.security.disableAuthorization();
|
33
32
|
const locale = context.i18n.getContentLocale();
|
34
33
|
if (!locale) {
|
35
34
|
throw new _error.default("Missing content locale in api-apw/storageOperations/index.ts", "LOCALE_ERROR");
|
@@ -70,8 +69,6 @@ const createApwModels = context => {
|
|
70
69
|
for (const modelDefinition of modelDefinitions) {
|
71
70
|
const cmsModelPlugin = (0, _contentModelPluginFactory.contentModelPluginFactory)({
|
72
71
|
group: cmsGroupPlugin.contentModelGroup,
|
73
|
-
tenant: context.tenancy.getCurrentTenant().id,
|
74
|
-
locale: locale.code,
|
75
72
|
modelDefinition
|
76
73
|
});
|
77
74
|
/**
|
@@ -88,6 +85,5 @@ const createApwModels = context => {
|
|
88
85
|
* Register them so that they are accessible in cms context
|
89
86
|
*/
|
90
87
|
context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);
|
91
|
-
context.security.enableAuthorization();
|
92
88
|
};
|
93
89
|
exports.createApwModels = createApwModels;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createApwModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","
|
1
|
+
{"version":3,"names":["createApwModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","locale","getContentLocale","WebinyError","groupId","cmsGroupPlugin","CmsGroupPlugin","id","slug","name","description","icon","isPrivate","changeRequestModelDefinition","createChangeRequestModelDefinition","reviewerModelDefinition","createReviewerModelDefinition","workflowModelDefinition","createWorkflowModelDefinition","reviewerModelId","modelId","commentModelDefinition","createCommentModelDefinition","contentReviewModelDefinition","createContentReviewModelDefinition","modelDefinitions","cmsModelPlugins","modelDefinition","cmsModelPlugin","contentModelPluginFactory","group","contentModelGroup","contentModel","titleFieldId","push","plugins","register"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsGroupPlugin, CmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { contentModelPluginFactory } from \"./contentModelPluginFactory\";\nimport { createWorkflowModelDefinition } from \"./workflow.model\";\nimport { createContentReviewModelDefinition } from \"./contentReview.model\";\nimport { createReviewerModelDefinition } from \"./reviewer.model\";\nimport { createCommentModelDefinition } from \"./comment.model\";\nimport { createChangeRequestModelDefinition } 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 * TODO:@ashutosh\n * We need to move these plugin in an installation plugin\n */\n const groupId = \"contentModelGroup_apw\";\n /**\n * Create a CmsGroup.\n */\n const cmsGroupPlugin = new CmsGroupPlugin({\n id: groupId,\n slug: \"apw\",\n name: \"APW\",\n description: \"Group for Advanced Publishing Workflow\",\n icon: \"fas/star\",\n isPrivate: true\n });\n\n /**\n * Create CmsModel plugins.\n */\n const changeRequestModelDefinition = createChangeRequestModelDefinition();\n const reviewerModelDefinition = createReviewerModelDefinition();\n const workflowModelDefinition = createWorkflowModelDefinition({\n reviewerModelId: reviewerModelDefinition.modelId\n });\n const commentModelDefinition = createCommentModelDefinition({\n modelId: changeRequestModelDefinition.modelId\n });\n const contentReviewModelDefinition = createContentReviewModelDefinition({\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 = contentModelPluginFactory({\n group: cmsGroupPlugin.contentModelGroup,\n modelDefinition\n });\n /**\n * We want \"title\" field as the \"titleField\" 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([cmsGroupPlugin, cmsModelPlugins]);\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEO,MAAMA,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,CAACM,IAAI,CAACE,gBAAgB,EAAE;EAC9C,IAAI,CAACD,MAAM,EAAE;IACT,MAAM,IAAIE,cAAW,CACjB,8DAA8D,EAC9D,cAAc,CACjB;EACL;EACA;AACJ;AACA;AACA;EACI,MAAMC,OAAO,GAAG,uBAAuB;EACvC;AACJ;AACA;EACI,MAAMC,cAAc,GAAG,IAAIC,8BAAc,CAAC;IACtCC,EAAE,EAAEH,OAAO;IACXI,IAAI,EAAE,KAAK;IACXC,IAAI,EAAE,KAAK;IACXC,WAAW,EAAE,wCAAwC;IACrDC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE;EACf,CAAC,CAAC;;EAEF;AACJ;AACA;EACI,MAAMC,4BAA4B,GAAG,IAAAC,iDAAkC,GAAE;EACzE,MAAMC,uBAAuB,GAAG,IAAAC,uCAA6B,GAAE;EAC/D,MAAMC,uBAAuB,GAAG,IAAAC,uCAA6B,EAAC;IAC1DC,eAAe,EAAEJ,uBAAuB,CAACK;EAC7C,CAAC,CAAC;EACF,MAAMC,sBAAsB,GAAG,IAAAC,qCAA4B,EAAC;IACxDF,OAAO,EAAEP,4BAA4B,CAACO;EAC1C,CAAC,CAAC;EACF,MAAMG,4BAA4B,GAAG,IAAAC,iDAAkC,EAAC;IACpEL,eAAe,EAAEJ,uBAAuB,CAACK;EAC7C,CAAC,CAAC;EAEF,MAAMK,gBAAgB,GAAG,CACrBR,uBAAuB,EACvBM,4BAA4B,EAC5BR,uBAAuB,EACvBF,4BAA4B,EAC5BQ,sBAAsB,CACzB;EAED,MAAMK,eAAiC,GAAG,EAAE;EAC5C,KAAK,MAAMC,eAAe,IAAIF,gBAAgB,EAAE;IAC5C,MAAMG,cAAc,GAAG,IAAAC,oDAAyB,EAAC;MAC7CC,KAAK,EAAEzB,cAAc,CAAC0B,iBAAiB;MACvCJ;IACJ,CAAC,CAAC;IACF;AACR;AACA;AACA;IACQ,IAAIC,cAAc,CAACI,YAAY,CAACZ,OAAO,KAAK,iCAAiC,EAAE;MAC3EQ,cAAc,CAACI,YAAY,CAACC,YAAY,GAAG,OAAO;IACtD;IACAP,eAAe,CAACQ,IAAI,CAACN,cAAc,CAAC;EACxC;;EAEA;AACJ;AACA;EACIlC,OAAO,CAACyC,OAAO,CAACC,QAAQ,CAAC,CAAC/B,cAAc,EAAEqB,eAAe,CAAC,CAAC;AAC/D,CAAC;AAAC"}
|
@@ -13,26 +13,21 @@ const createReviewerStorageOperations = ({
|
|
13
13
|
security
|
14
14
|
}) => {
|
15
15
|
const getReviewerModel = async () => {
|
16
|
-
security.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
22
|
-
return model;
|
23
|
-
} catch (ex) {
|
24
|
-
throw ex;
|
25
|
-
} finally {
|
26
|
-
security.enableAuthorization();
|
16
|
+
const model = await security.withoutAuthorization(async () => {
|
17
|
+
return cms.getModel("apwReviewerModelDefinition");
|
18
|
+
});
|
19
|
+
if (!model) {
|
20
|
+
throw new _error.default("Could not find `apwReviewerModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
|
27
21
|
}
|
22
|
+
return model;
|
28
23
|
};
|
29
24
|
const getReviewer = async ({
|
30
25
|
id
|
31
26
|
}) => {
|
32
27
|
const model = await getReviewerModel();
|
33
|
-
security.
|
34
|
-
|
35
|
-
|
28
|
+
const entry = await security.withoutAuthorization(async () => {
|
29
|
+
return cms.getEntryById(model, id);
|
30
|
+
});
|
36
31
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
37
32
|
};
|
38
33
|
return {
|
@@ -40,18 +35,18 @@ const createReviewerStorageOperations = ({
|
|
40
35
|
getReviewer,
|
41
36
|
async listReviewers(params) {
|
42
37
|
const model = await getReviewerModel();
|
43
|
-
security.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
38
|
+
const [entries, meta] = await security.withoutAuthorization(async () => {
|
39
|
+
return cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
40
|
+
where: (0, _objectSpread2.default)({}, params.where)
|
41
|
+
}));
|
42
|
+
});
|
48
43
|
return [entries.map(entry => (0, _index.getFieldValues)(entry, _index.baseFields)), meta];
|
49
44
|
},
|
50
45
|
async createReviewer(params) {
|
51
46
|
const model = await getReviewerModel();
|
52
|
-
security.
|
53
|
-
|
54
|
-
|
47
|
+
const entry = await security.withoutAuthorization(async () => {
|
48
|
+
return cms.createEntry(model, params.data);
|
49
|
+
});
|
55
50
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
56
51
|
},
|
57
52
|
async updateReviewer(params) {
|
@@ -63,16 +58,16 @@ const createReviewerStorageOperations = ({
|
|
63
58
|
const existingEntry = await getReviewer({
|
64
59
|
id: params.id
|
65
60
|
});
|
66
|
-
security.
|
67
|
-
|
68
|
-
|
61
|
+
const entry = await security.withoutAuthorization(async () => {
|
62
|
+
return cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
|
63
|
+
});
|
69
64
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
70
65
|
},
|
71
66
|
async deleteReviewer(params) {
|
72
67
|
const model = await getReviewerModel();
|
73
|
-
security.
|
74
|
-
|
75
|
-
|
68
|
+
await security.withoutAuthorization(async () => {
|
69
|
+
return cms.deleteEntry(model, params.id);
|
70
|
+
});
|
76
71
|
return true;
|
77
72
|
}
|
78
73
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createReviewerStorageOperations","cms","security","getReviewerModel","
|
1
|
+
{"version":3,"names":["createReviewerStorageOperations","cms","security","getReviewerModel","model","withoutAuthorization","getModel","WebinyError","getReviewer","id","entry","getEntryById","getFieldValues","baseFields","listReviewers","params","entries","meta","listLatestEntries","where","map","createReviewer","createEntry","data","updateReviewer","existingEntry","updateEntry","deleteReviewer","deleteEntry"],"sources":["reviewerStorageOperations.ts"],"sourcesContent":["import { ApwReviewerStorageOperations } from \"./types\";\nimport {\n baseFields,\n CreateApwStorageOperationsParams,\n getFieldValues\n} from \"~/storageOperations/index\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createReviewerStorageOperations = ({\n cms,\n security\n}: CreateApwStorageOperationsParams): ApwReviewerStorageOperations => {\n const getReviewerModel = async () => {\n const model = await security.withoutAuthorization(async () => {\n return cms.getModel(\"apwReviewerModelDefinition\");\n });\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 security.withoutAuthorization(async () => {\n return cms.getEntryById(model, id);\n });\n return getFieldValues(entry, baseFields);\n };\n return {\n getReviewerModel,\n getReviewer,\n async listReviewers(params) {\n const model = await getReviewerModel();\n\n const [entries, meta] = await security.withoutAuthorization(async () => {\n return cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n });\n return [entries.map(entry => getFieldValues(entry, baseFields)), meta];\n },\n async createReviewer(params) {\n const model = await getReviewerModel();\n const entry = await security.withoutAuthorization(async () => {\n return cms.createEntry(model, params.data);\n });\n return getFieldValues(entry, baseFields);\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 security.withoutAuthorization(async () => {\n return cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n });\n return getFieldValues(entry, baseFields);\n },\n async deleteReviewer(params) {\n const model = await getReviewerModel();\n\n await security.withoutAuthorization(async () => {\n return cms.deleteEntry(model, params.id);\n });\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AAKA;AAEO,MAAMA,+BAA+B,GAAG,CAAC;EAC5CC,GAAG;EACHC;AAC8B,CAAC,KAAmC;EAClE,MAAMC,gBAAgB,GAAG,YAAY;IACjC,MAAMC,KAAK,GAAG,MAAMF,QAAQ,CAACG,oBAAoB,CAAC,YAAY;MAC1D,OAAOJ,GAAG,CAACK,QAAQ,CAAC,4BAA4B,CAAC;IACrD,CAAC,CAAC;IACF,IAAI,CAACF,KAAK,EAAE;MACR,MAAM,IAAIG,cAAW,CACjB,oDAAoD,EACpD,uBAAuB,CAC1B;IACL;IACA,OAAOH,KAAK;EAChB,CAAC;EACD,MAAMI,WAAwD,GAAG,OAAO;IAAEC;EAAG,CAAC,KAAK;IAC/E,MAAML,KAAK,GAAG,MAAMD,gBAAgB,EAAE;IAEtC,MAAMO,KAAK,GAAG,MAAMR,QAAQ,CAACG,oBAAoB,CAAC,YAAY;MAC1D,OAAOJ,GAAG,CAACU,YAAY,CAACP,KAAK,EAAEK,EAAE,CAAC;IACtC,CAAC,CAAC;IACF,OAAO,IAAAG,qBAAc,EAACF,KAAK,EAAEG,iBAAU,CAAC;EAC5C,CAAC;EACD,OAAO;IACHV,gBAAgB;IAChBK,WAAW;IACX,MAAMM,aAAa,CAACC,MAAM,EAAE;MACxB,MAAMX,KAAK,GA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KAAK,GAAG,MAAMD,gBAAgB,EAAE;MAEtC,MAAMD,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC5C,OAAOJ,GAAG,CAAC2B,WAAW,CAACxB,KAAK,EAAEW,MAAM,CAACN,EAAE,CAAC;MAC5C,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
|
@@ -25,9 +25,9 @@ const createWorkflowStorageOperations = params => {
|
|
25
25
|
security
|
26
26
|
} = params;
|
27
27
|
const getWorkflowModel = async () => {
|
28
|
-
security.
|
29
|
-
|
30
|
-
|
28
|
+
const model = await security.withoutAuthorization(async () => {
|
29
|
+
return cms.getModel(_workflow.WORKFLOW_MODEL_ID);
|
30
|
+
});
|
31
31
|
if (!model) {
|
32
32
|
throw new _error.default(`Could not find "${_workflow.WORKFLOW_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
33
33
|
}
|
@@ -37,9 +37,9 @@ const createWorkflowStorageOperations = params => {
|
|
37
37
|
id
|
38
38
|
}) => {
|
39
39
|
const model = await getWorkflowModel();
|
40
|
-
security.
|
41
|
-
|
42
|
-
|
40
|
+
const entry = await security.withoutAuthorization(async () => {
|
41
|
+
return cms.getEntryById(model, id);
|
42
|
+
});
|
43
43
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
44
44
|
};
|
45
45
|
return {
|
@@ -47,18 +47,20 @@ const createWorkflowStorageOperations = params => {
|
|
47
47
|
getWorkflow,
|
48
48
|
async listWorkflows(params) {
|
49
49
|
const model = await getWorkflowModel();
|
50
|
-
security.
|
51
|
-
|
52
|
-
|
50
|
+
const [entries, meta] = await security.withoutAuthorization(async () => {
|
51
|
+
return cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
52
|
+
where: (0, _objectSpread2.default)({}, params.where)
|
53
|
+
}));
|
54
|
+
});
|
53
55
|
return [entries.map(entry => (0, _index.getFieldValues)(entry, _index.baseFields)), meta];
|
54
56
|
},
|
55
57
|
async createWorkflow(params) {
|
56
58
|
const model = await getWorkflowModel();
|
57
59
|
const reviewerModel = await this.getReviewerModel();
|
58
60
|
const data = formatReviewersForRefInput(params.data, reviewerModel.modelId);
|
59
|
-
security.
|
60
|
-
|
61
|
-
|
61
|
+
const entry = await security.withoutAuthorization(async () => {
|
62
|
+
return cms.createEntry(model, data);
|
63
|
+
});
|
62
64
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
63
65
|
},
|
64
66
|
async updateWorkflow(params) {
|
@@ -73,16 +75,16 @@ const createWorkflowStorageOperations = params => {
|
|
73
75
|
});
|
74
76
|
const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data);
|
75
77
|
const data = formatReviewersForRefInput(input, reviewerModel.modelId);
|
76
|
-
security.
|
77
|
-
|
78
|
-
|
78
|
+
const entry = await security.withoutAuthorization(async () => {
|
79
|
+
return cms.updateEntry(model, params.id, data);
|
80
|
+
});
|
79
81
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
80
82
|
},
|
81
83
|
async deleteWorkflow(params) {
|
82
84
|
const model = await getWorkflowModel();
|
83
|
-
security.
|
84
|
-
|
85
|
-
|
85
|
+
await security.withoutAuthorization(async () => {
|
86
|
+
return cms.deleteEntry(model, params.id);
|
87
|
+
});
|
86
88
|
return true;
|
87
89
|
}
|
88
90
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["formatReviewersForRefInput","data","modelId","steps","map","step","reviewers","id","createWorkflowStorageOperations","params","cms","security","getWorkflowModel","
|
1
|
+
{"version":3,"names":["formatReviewersForRefInput","data","modelId","steps","map","step","reviewers","id","createWorkflowStorageOperations","params","cms","security","getWorkflowModel","model","withoutAuthorization","getModel","WORKFLOW_MODEL_ID","WebinyError","getWorkflow","entry","getEntryById","getFieldValues","baseFields","listWorkflows","entries","meta","listLatestEntries","where","createWorkflow","reviewerModel","getReviewerModel","createEntry","updateWorkflow","existingEntry","input","updateEntry","deleteWorkflow","deleteEntry"],"sources":["workflowStorageOperations.ts"],"sourcesContent":["import { CreateApwWorkflowParams } from \"~/types\";\nimport { ApwStorageOperations, ApwWorkflowStorageOperations } from \"./types\";\nimport {\n baseFields,\n CreateApwStorageOperationsParams,\n getFieldValues\n} from \"~/storageOperations/index\";\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, security } = params;\n const getWorkflowModel = async () => {\n const model = await security.withoutAuthorization(async () => {\n return cms.getModel(WORKFLOW_MODEL_ID);\n });\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 security.withoutAuthorization(async () => {\n return cms.getEntryById(model, id);\n });\n return getFieldValues(entry, baseFields);\n };\n return {\n getWorkflowModel,\n getWorkflow,\n async listWorkflows(params) {\n const model = await getWorkflowModel();\n\n const [entries, meta] = await security.withoutAuthorization(async () => {\n return cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n });\n return [entries.map(entry => getFieldValues(entry, baseFields)), 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 security.withoutAuthorization(async () => {\n return cms.createEntry(model, data);\n });\n\n return getFieldValues(entry, baseFields);\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 };\n const data = formatReviewersForRefInput(\n input as CreateApwWorkflowParams,\n reviewerModel.modelId\n );\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.updateEntry(model, params.id, data);\n });\n\n return getFieldValues(entry, baseFields);\n },\n async deleteWorkflow(params) {\n const model = await getWorkflowModel();\n\n await security.withoutAuthorization(async () => {\n return cms.deleteEntry(model, params.id);\n });\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AAEA;AAKA;AACA;AAIA,MAAMA,0BAA0B,GAAG,CAC/BC,IAA6B,EAC7BC,OAAe,KACK;EACpB,mEACOD,IAAI;IACPE,KAAK,EAAEF,IAAI,CAACE,KAAK,CAACC,GAAG,CAACC,IAAI,gEACnBA,IAAI;MACPC,SAAS,EAAED,IAAI,CAACC,SAAS,CAACF,GAAG,CAACG,EAAE,KAAK;QACjCA,EAAE;QACFL;MACJ,CAAC,CAAC;IAAC,EACL;EAAC;AAEX,CAAC;AAEM,MAAMM,+BAA+B,GACxCC,MAAwC,IACT;EAC/B,MAAM;IAAEC,GAAG;IAAEC;EAAS,CAAC,GAAGF,MAAM;EAChC,MAAMG,gBAAgB,GAAG,YAAY;IACjC,MAAMC,KAAK,GAAG,MAAMF,QAAQ,CAACG,oBAAoB,CAAC,YAAY;MAC1D,OAAOJ,GAAG,CAACK,QAAQ,CAACC,2BAAiB,CAAC;IAC1C,CAAC,CAAC;IACF,IAAI,CAACH,KAAK,EAAE;MACR,MAAM,IAAII,cAAW,CAChB,mBAAkBD,2BAAkB,UAAS,EAC9C,uBAAuB,CAC1B;IACL;IACA,OAAOH,KAAK;EAChB,CAA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AAc,EAACF,KAAK,EAAEG,iBAAU,CAAC;IAC5C,CAAC;IACD,MAAMU,cAAc,CAA6BvB,MAAM,EAAE;MACrD,MAAMI,KAAK,GAAG,MAAMD,gBAAgB,EAAE;MACtC,MAAMiB,aAAa,GAAG,MAAM,IAAI,CAACC,gBAAgB,EAAE;MACnD;AACZ;AACA;AACA;MACY,MAAMG,aAAa,GAAG,MAAMf,WAAW,CAAC;QAAEX,EAAE,EAAEE,MAAM,CAACF;MAAG,CAAC,CAAC;MAC1D,MAAM2B,KAAK,+DACJD,aAAa,GACbxB,MAAM,CAACR,IAAI,CACjB;MACD,MAAMA,IAAI,GAAGD,0BAA0B,CACnCkC,KAAK,EACLL,aAAa,CAAC3B,OAAO,CACxB;MAED,MAAMiB,KAAK,GAAG,MAAMR,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC1D,OAAOJ,GAAG,CAACyB,WAAW,CAACtB,KAAK,EAAEJ,MAAM,CAACF,EAAE,EAAEN,IAAI,CAAC;MAClD,CAAC,CAAC;MAEF,OAAO,IAAAoB,qBAAc,EAACF,KAAK,EAAEG,iBAAU,CAAC;IAC5C,CAAC;IACD,MAAMc,cAAc,CAAC3B,MAAM,EAAE;MACzB,MAAMI,KAAK,GAAG,MAAMD,gBAAgB,EAAE;MAEtC,MAAMD,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC5C,OAAOJ,GAAG,CAAC2B,WAAW,CAACxB,KAAK,EAAEJ,MAAM,CAACF,EAAE,CAAC;MAC5C,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/types.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CmsEntry as BaseCmsEntry,
|
1
|
+
import { CmsEntry as BaseCmsEntry, OnEntryBeforePublishTopicParams, OnEntryAfterPublishTopicParams, OnEntryAfterUnpublishTopicParams } from "@webiny/api-headless-cms/types";
|
2
2
|
import { Page, OnPageBeforeCreateTopicParams, OnPageBeforeCreateFromTopicParams, OnPageBeforeUpdateTopicParams, OnPageBeforePublishTopicParams, PageSettings } from "@webiny/api-page-builder/types";
|
3
3
|
import { Context } from "@webiny/api/types";
|
4
4
|
import { PageBuilderContextObject } from "@webiny/api-page-builder/graphql/types";
|
@@ -12,6 +12,7 @@ import { PluginsContainer } from "@webiny/plugins";
|
|
12
12
|
import { WcpContextObject } from "@webiny/api-wcp/types";
|
13
13
|
import { MailerContext } from "@webiny/api-mailer/types";
|
14
14
|
import { AdminSettingsContext } from "@webiny/api-admin-settings/types";
|
15
|
+
import { CmsPrivateModelFull } from "@webiny/api-headless-cms";
|
15
16
|
export interface ApwCmsEntry extends BaseCmsEntry {
|
16
17
|
title: string;
|
17
18
|
meta: {
|
@@ -99,7 +100,7 @@ export declare enum ApwWorkflowApplications {
|
|
99
100
|
*
|
100
101
|
* @category General
|
101
102
|
*/
|
102
|
-
export interface
|
103
|
+
export interface ApwIdentity {
|
103
104
|
/**
|
104
105
|
* ID if the user.
|
105
106
|
*/
|
@@ -118,7 +119,7 @@ export interface ApwBaseFields {
|
|
118
119
|
entryId: string;
|
119
120
|
createdOn: string;
|
120
121
|
savedOn: string;
|
121
|
-
createdBy:
|
122
|
+
createdBy: ApwIdentity;
|
122
123
|
}
|
123
124
|
export interface ApwReviewer extends ApwBaseFields {
|
124
125
|
identityId: string;
|
@@ -151,7 +152,7 @@ export interface ApwContentReviewStep {
|
|
151
152
|
pendingChangeRequests: number;
|
152
153
|
totalComments: number;
|
153
154
|
signOffProvidedOn: string | null;
|
154
|
-
signOffProvidedBy:
|
155
|
+
signOffProvidedBy: ApwIdentity | null;
|
155
156
|
}
|
156
157
|
export interface ApwContentReview extends ApwBaseFields {
|
157
158
|
title: string;
|
@@ -736,7 +737,7 @@ export interface OnWorkflowBeforeDeleteTopicParams {
|
|
736
737
|
export interface OnWorkflowAfterDeleteTopicParams {
|
737
738
|
workflow: ApwWorkflow;
|
738
739
|
}
|
739
|
-
export declare type WorkflowModelDefinition =
|
740
|
+
export declare type WorkflowModelDefinition = Omit<CmsPrivateModelFull, "noValidate" | "group">;
|
740
741
|
/**
|
741
742
|
* Headless CMS
|
742
743
|
*/
|