@webiny/api-apw 5.34.8 → 5.35.0-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/ApwChangeRequestNotification.js +0 -10
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.js +0 -10
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.js +0 -10
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.js +0 -10
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.js +0 -5
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/crud/createChangeRequestMethods.js +4 -11
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +4 -12
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +20 -84
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +4 -12
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.js +4 -17
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +0 -25
- package/crud/index.js.map +1 -1
- package/crud/utils.js +0 -28
- package/crud/utils.js.map +1 -1
- package/index.d.ts +1 -2
- package/index.js +1 -15
- package/index.js.map +1 -1
- package/package.json +34 -34
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +0 -15
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +0 -8
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +0 -13
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +0 -17
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +2 -31
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.js +0 -4
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/cms/notifications/commentNotification.js +0 -4
- package/plugins/cms/notifications/commentNotification.js.map +1 -1
- package/plugins/cms/notifications/contentReviewNotification.js +0 -4
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/cms/notifications/contentUrl.js +1 -8
- package/plugins/cms/notifications/contentUrl.js.map +1 -1
- package/plugins/cms/triggerContentReview.js +0 -14
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +0 -18
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +2 -47
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.d.ts +0 -1
- package/plugins/context.js +2 -47
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +3 -10
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +3 -10
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +6 -25
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +3 -10
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +3 -10
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +3 -18
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +2 -11
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -9
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -8
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +0 -14
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +2 -18
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.js +0 -5
- package/plugins/hooks/initializeNotifications.js.map +1 -1
- package/plugins/hooks/listContentReviews.js +0 -12
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.js +0 -4
- package/plugins/hooks/notifications/appUrl.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +3 -36
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestUrl.js +0 -4
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +3 -38
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/commentUrl.js +0 -4
- package/plugins/hooks/notifications/commentUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +4 -32
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewUrl.js +0 -4
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentUrl.js +0 -5
- package/plugins/hooks/notifications/contentUrl.js.map +1 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.js +15 -21
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +0 -11
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.js +0 -11
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js +0 -11
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js +0 -8
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +0 -9
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +0 -16
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +1 -12
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +0 -6
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -15
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
- package/plugins/pageBuilder/index.js +0 -11
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +0 -16
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +1 -31
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +0 -4
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/commentNotification.js +0 -4
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +0 -4
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentUrl.js +1 -7
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -1
- package/plugins/pageBuilder/triggerContentReview.js +0 -11
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +0 -12
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +1 -35
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.js +0 -43
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +1 -20
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/index.js +9 -40
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +0 -7
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -23
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -28
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.js +0 -11
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
- package/scheduler/handlers/scheduleAction/index.js +5 -25
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -23
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +1 -2
- package/scheduler/handlers/utils.js +3 -41
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.js +0 -3
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.d.ts +2 -20
- package/scheduler/types.js +0 -11
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +20 -39
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +23 -44
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +20 -37
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +0 -14
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.js +0 -9
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.js +0 -8
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.d.ts +3 -10
- package/storageOperations/models/contentModelPluginFactory.js +3 -11
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +0 -26
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +2 -28
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.js +0 -8
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +0 -4
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.js +0 -23
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +23 -45
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +20 -39
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +6 -5
- package/types.js +0 -14
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.js +0 -6
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js +0 -17
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.js +2 -12
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
- package/utils/resolve.js +0 -3
- package/utils/resolve.js.map +1 -1
package/scheduler/types.d.ts
CHANGED
@@ -3,6 +3,7 @@ import { SecurityIdentity, SecurityPermission } from "@webiny/api-security/types
|
|
3
3
|
import { I18NLocale, I18NContext } from "@webiny/api-i18n/types";
|
4
4
|
import { Tenant } from "@webiny/api-tenancy/types";
|
5
5
|
import { TenancyContext } from "@webiny/api-tenancy/types";
|
6
|
+
import { ApwIdentity } from "../types";
|
6
7
|
export interface ListWhere {
|
7
8
|
/**
|
8
9
|
* Fields.
|
@@ -29,25 +30,6 @@ export interface ListParams {
|
|
29
30
|
limit?: number;
|
30
31
|
after?: string;
|
31
32
|
}
|
32
|
-
/**
|
33
|
-
* A interface describing the reference to a user that created some data in the database.
|
34
|
-
*
|
35
|
-
* @category General
|
36
|
-
*/
|
37
|
-
export interface CreatedBy {
|
38
|
-
/**
|
39
|
-
* ID if the user.
|
40
|
-
*/
|
41
|
-
id: string;
|
42
|
-
/**
|
43
|
-
* Full name of the user.
|
44
|
-
*/
|
45
|
-
displayName: string | null;
|
46
|
-
/**
|
47
|
-
* Type of the user (admin, user)
|
48
|
-
*/
|
49
|
-
type: string;
|
50
|
-
}
|
51
33
|
export interface ListMeta {
|
52
34
|
/**
|
53
35
|
* A cursor for pagination.
|
@@ -70,7 +52,7 @@ export interface BaseFields {
|
|
70
52
|
id: string;
|
71
53
|
createdOn: string;
|
72
54
|
savedOn?: string;
|
73
|
-
createdBy:
|
55
|
+
createdBy: ApwIdentity;
|
74
56
|
tenant: string;
|
75
57
|
locale: string;
|
76
58
|
}
|
package/scheduler/types.js
CHANGED
@@ -4,31 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.InvocationTypes = exports.ApwScheduleActionTypes = exports.ApwContentTypes = void 0;
|
7
|
-
|
8
|
-
/**
|
9
|
-
* A interface describing the reference to a user that created some data in the database.
|
10
|
-
*
|
11
|
-
* @category General
|
12
|
-
*/
|
13
7
|
let ApwContentTypes;
|
14
8
|
exports.ApwContentTypes = ApwContentTypes;
|
15
|
-
|
16
9
|
(function (ApwContentTypes) {
|
17
10
|
ApwContentTypes["PAGE"] = "page";
|
18
11
|
ApwContentTypes["CMS_ENTRY"] = "cms_entry";
|
19
12
|
})(ApwContentTypes || (exports.ApwContentTypes = ApwContentTypes = {}));
|
20
|
-
|
21
13
|
let ApwScheduleActionTypes;
|
22
14
|
exports.ApwScheduleActionTypes = ApwScheduleActionTypes;
|
23
|
-
|
24
15
|
(function (ApwScheduleActionTypes) {
|
25
16
|
ApwScheduleActionTypes["PUBLISH"] = "publish";
|
26
17
|
ApwScheduleActionTypes["UNPUBLISH"] = "unpublish";
|
27
18
|
})(ApwScheduleActionTypes || (exports.ApwScheduleActionTypes = ApwScheduleActionTypes = {}));
|
28
|
-
|
29
19
|
let InvocationTypes;
|
30
20
|
exports.InvocationTypes = InvocationTypes;
|
31
|
-
|
32
21
|
(function (InvocationTypes) {
|
33
22
|
InvocationTypes["SCHEDULED"] = "scheduled";
|
34
23
|
})(InvocationTypes || (exports.InvocationTypes = InvocationTypes = {}));
|
package/scheduler/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ApwContentTypes","ApwScheduleActionTypes","InvocationTypes"],"sources":["types.ts"],"sourcesContent":["import { Context } from \"@webiny/api/types\";\nimport { SecurityIdentity, SecurityPermission } from \"@webiny/api-security/types\";\nimport { I18NLocale, I18NContext } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\n\nexport interface ListWhere {\n /**\n * Fields.\n */\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n /**\n * Who created the entry?\n */\n createdBy?: string;\n createdBy_not?: string;\n createdBy_in?: string[];\n createdBy_not_in?: string[];\n /**\n * By datetime field.\n */\n datetime_startsWith?: string;\n}\n\nexport interface ListParams {\n where: ListWhere;\n sort?: (\"datetime_ASC\" | \"datetime_DESC\")[];\n limit?: number;\n after?: string;\n}\n\
|
1
|
+
{"version":3,"names":["ApwContentTypes","ApwScheduleActionTypes","InvocationTypes"],"sources":["types.ts"],"sourcesContent":["import { Context } from \"@webiny/api/types\";\nimport { SecurityIdentity, SecurityPermission } from \"@webiny/api-security/types\";\nimport { I18NLocale, I18NContext } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { ApwIdentity } from \"~/types\";\n\nexport interface ListWhere {\n /**\n * Fields.\n */\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n /**\n * Who created the entry?\n */\n createdBy?: string;\n createdBy_not?: string;\n createdBy_in?: string[];\n createdBy_not_in?: string[];\n /**\n * By datetime field.\n */\n datetime_startsWith?: string;\n}\n\nexport interface ListParams {\n where: ListWhere;\n sort?: (\"datetime_ASC\" | \"datetime_DESC\")[];\n limit?: number;\n after?: string;\n}\n\nexport interface ListMeta {\n /**\n * A cursor for pagination.\n */\n cursor: string | null;\n /**\n * Is there more items to load?\n */\n hasMoreItems: boolean;\n /**\n * Total count of the items in the storage.\n */\n totalCount: number;\n}\n\nexport enum ApwContentTypes {\n PAGE = \"page\",\n CMS_ENTRY = \"cms_entry\"\n}\n\nexport interface BaseFields {\n id: string;\n createdOn: string;\n savedOn?: string;\n createdBy: ApwIdentity;\n tenant: string;\n locale: string;\n}\n\nexport interface ApwScheduleAction extends BaseFields {\n data: ApwScheduleActionData;\n}\n\nexport enum ApwScheduleActionTypes {\n PUBLISH = \"publish\",\n UNPUBLISH = \"unpublish\"\n}\n\nexport interface ApwScheduleActionData {\n action: ApwScheduleActionTypes;\n type: ApwContentTypes;\n datetime: string;\n entryId: string;\n /**\n * We will add modelId to the data for now.\n * TODO extract in separate package?\n */\n modelId?: string;\n}\n\nexport enum InvocationTypes {\n SCHEDULED = \"scheduled\"\n}\n\ninterface BaseApwCrud<TEntry, TCreateEntryParams, TUpdateEntryParams> {\n get(id: string): Promise<TEntry | null>;\n\n create(data: TCreateEntryParams): Promise<TEntry>;\n\n update(id: string, data: TUpdateEntryParams): Promise<TEntry>;\n\n delete(id: string): Promise<Boolean>;\n}\n\nexport interface ApwScheduleActionCrud\n extends BaseApwCrud<ApwScheduleAction, ApwScheduleActionData, ApwScheduleActionData> {\n list(params: ListParams): Promise<[ApwScheduleAction[], ListMeta]>;\n\n getCurrentTask(): Promise<ApwScheduleAction | null>;\n\n updateCurrentTask(item: ApwScheduleAction): Promise<ApwScheduleAction>;\n\n deleteCurrentTask(): Promise<Boolean>;\n}\n\nexport interface ScheduleActionContext extends Context, I18NContext, TenancyContext {\n scheduleAction: ApwScheduleActionCrud;\n}\n\nexport interface CreateScheduleActionParams {\n getLocale: () => I18NLocale;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n getPermission: (name: string) => Promise<SecurityPermission | null>;\n storageOperations: ApwScheduleActionStorageOperations;\n}\n\ninterface CreateApwScheduleActionParams {\n item: ApwScheduleAction;\n input: ApwScheduleActionData;\n}\n\ninterface StorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n\ninterface StorageOperationsDeleteParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport interface ApwScheduleActionListParams extends ListParams {\n where: ListWhere & {\n tenant: string;\n locale: string;\n };\n}\n\nexport type StorageOperationsGetScheduleActionParams = StorageOperationsGetParams;\n\nexport type StorageOperationsDeleteScheduleActionParams = StorageOperationsDeleteParams;\nexport type StorageOperationsListScheduleActionsParams = ApwScheduleActionListParams;\n\nexport type StorageOperationsCreateScheduleActionParams = CreateApwScheduleActionParams;\n\nexport interface StorageOperationsUpdateScheduleActionParams {\n item: ApwScheduleAction;\n input: ApwScheduleActionData;\n}\n\nexport type StorageOperationsListScheduleActionsResponse = [ApwScheduleAction[], ListMeta];\n\nexport interface StorageOperationsUpdateCurrentTaskParams {\n item: ApwScheduleAction;\n}\n\nexport interface StorageOperationsGetCurrentTaskParams {\n where: Pick<StorageOperationsGetParams[\"where\"], \"tenant\" | \"locale\">;\n}\n\nexport type StorageOperationsDeleteCurrentTaskParams = Pick<\n StorageOperationsDeleteParams,\n \"tenant\" | \"locale\"\n>;\n\nexport interface ApwScheduleActionStorageOperations {\n get(params: StorageOperationsGetScheduleActionParams): Promise<ApwScheduleAction | null>;\n\n list(\n params: StorageOperationsListScheduleActionsParams\n ): Promise<StorageOperationsListScheduleActionsResponse>;\n\n create(params: StorageOperationsCreateScheduleActionParams): Promise<ApwScheduleAction>;\n\n update(params: StorageOperationsUpdateScheduleActionParams): Promise<ApwScheduleAction>;\n\n delete(params: StorageOperationsDeleteScheduleActionParams): Promise<Boolean>;\n\n getCurrentTask(\n params: StorageOperationsGetCurrentTaskParams\n ): Promise<ApwScheduleAction | null>;\n\n updateCurrentTask(params: StorageOperationsUpdateCurrentTaskParams): Promise<ApwScheduleAction>;\n\n deleteCurrentTask(params: StorageOperationsDeleteCurrentTaskParams): Promise<Boolean>;\n}\n\nexport interface CreateApwContextParams {\n storageOperations: ApwScheduleActionStorageOperations;\n}\n"],"mappings":";;;;;;IAkDYA,eAAe;AAAA;AAAA,WAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;AAAA,GAAfA,eAAe,+BAAfA,eAAe;AAAA,IAkBfC,sBAAsB;AAAA;AAAA,WAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;AAAA,GAAtBA,sBAAsB,sCAAtBA,sBAAsB;AAAA,IAiBtBC,eAAe;AAAA;AAAA,WAAfA,eAAe;EAAfA,eAAe;AAAA,GAAfA,eAAe,+BAAfA,eAAe"}
|
@@ -1,46 +1,36 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.createChangeRequestStorageOperations = void 0;
|
9
|
-
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
-
|
12
9
|
var _index = require("./index");
|
13
|
-
|
14
10
|
var _fieldResolver = require("../utils/fieldResolver");
|
15
|
-
|
16
11
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
17
|
-
|
18
12
|
const createChangeRequestStorageOperations = params => {
|
19
13
|
const {
|
20
14
|
cms,
|
21
15
|
getCmsContext,
|
22
16
|
security
|
23
17
|
} = params;
|
24
|
-
|
25
18
|
const getChangeRequestModel = async () => {
|
26
|
-
security.
|
27
|
-
|
28
|
-
|
29
|
-
|
19
|
+
const model = await security.withoutAuthorization(async () => {
|
20
|
+
return cms.getModel("apwChangeRequestModelDefinition");
|
21
|
+
});
|
30
22
|
if (!model) {
|
31
23
|
throw new _error.default("Could not find `apwChangeRequestModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
|
32
24
|
}
|
33
|
-
|
34
25
|
return model;
|
35
26
|
};
|
36
|
-
|
37
27
|
const getChangeRequest = async ({
|
38
28
|
id
|
39
29
|
}) => {
|
40
30
|
const model = await getChangeRequestModel();
|
41
|
-
security.
|
42
|
-
|
43
|
-
|
31
|
+
const entry = await security.withoutAuthorization(async () => {
|
32
|
+
return cms.getEntryById(model, id);
|
33
|
+
});
|
44
34
|
return (0, _fieldResolver.getFieldValues)({
|
45
35
|
entry,
|
46
36
|
fields: _index.baseFields,
|
@@ -48,19 +38,16 @@ const createChangeRequestStorageOperations = params => {
|
|
48
38
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
49
39
|
});
|
50
40
|
};
|
51
|
-
|
52
41
|
return {
|
53
42
|
getChangeRequestModel,
|
54
43
|
getChangeRequest,
|
55
|
-
|
56
44
|
async listChangeRequests(params) {
|
57
45
|
const model = await getChangeRequestModel();
|
58
|
-
security.
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
46
|
+
const [entries, meta] = await security.withoutAuthorization(async () => {
|
47
|
+
return cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
48
|
+
where: (0, _objectSpread2.default)({}, params.where)
|
49
|
+
}));
|
50
|
+
});
|
64
51
|
try {
|
65
52
|
const all = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
66
53
|
entry,
|
@@ -73,12 +60,11 @@ const createChangeRequestStorageOperations = params => {
|
|
73
60
|
throw new _error.default(ex.message, ex.code, ex.data);
|
74
61
|
}
|
75
62
|
},
|
76
|
-
|
77
63
|
async createChangeRequest(params) {
|
78
64
|
const model = await getChangeRequestModel();
|
79
|
-
security.
|
80
|
-
|
81
|
-
|
65
|
+
const entry = await security.withoutAuthorization(async () => {
|
66
|
+
return cms.createEntry(model, params.data);
|
67
|
+
});
|
82
68
|
return (0, _fieldResolver.getFieldValues)({
|
83
69
|
entry,
|
84
70
|
fields: _index.baseFields,
|
@@ -86,20 +72,18 @@ const createChangeRequestStorageOperations = params => {
|
|
86
72
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
87
73
|
});
|
88
74
|
},
|
89
|
-
|
90
75
|
async updateChangeRequest(params) {
|
91
76
|
const model = await getChangeRequestModel();
|
92
77
|
/**
|
93
78
|
* We're fetching the existing entry here because we're not accepting "app" field as input,
|
94
79
|
* but, we still need to retain its value after the "update" operation.
|
95
80
|
*/
|
96
|
-
|
97
81
|
const existingEntry = await getChangeRequest({
|
98
82
|
id: params.id
|
99
83
|
});
|
100
|
-
security.
|
101
|
-
|
102
|
-
|
84
|
+
const entry = await security.withoutAuthorization(async () => {
|
85
|
+
return cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
|
86
|
+
});
|
103
87
|
return (0, _fieldResolver.getFieldValues)({
|
104
88
|
entry,
|
105
89
|
fields: _index.baseFields,
|
@@ -107,16 +91,13 @@ const createChangeRequestStorageOperations = params => {
|
|
107
91
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
108
92
|
});
|
109
93
|
},
|
110
|
-
|
111
94
|
async deleteChangeRequest(params) {
|
112
95
|
const model = await getChangeRequestModel();
|
113
|
-
security.
|
114
|
-
|
115
|
-
|
96
|
+
await security.withoutAuthorization(async () => {
|
97
|
+
return cms.deleteEntry(model, params.id);
|
98
|
+
});
|
116
99
|
return true;
|
117
100
|
}
|
118
|
-
|
119
101
|
};
|
120
102
|
};
|
121
|
-
|
122
103
|
exports.createChangeRequestStorageOperations = createChangeRequestStorageOperations;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createChangeRequestStorageOperations","params","cms","getCmsContext","security","getChangeRequestModel","
|
1
|
+
{"version":3,"names":["createChangeRequestStorageOperations","params","cms","getCmsContext","security","getChangeRequestModel","model","withoutAuthorization","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","updateEntry","deleteChangeRequest","deleteEntry"],"sources":["changeRequestStorageOperations.ts"],"sourcesContent":["import { ApwChangeRequestStorageOperations } from \"./types\";\nimport { baseFields, CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\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 security.withoutAuthorization(async () => {\n return cms.getModel(\"apwChangeRequestModelDefinition\");\n });\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 security.withoutAuthorization(async () => {\n return 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 security.withoutAuthorization(async () => {\n return 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\n const entry = await security.withoutAuthorization(async () => {\n return 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 * 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 const entry = await security.withoutAuthorization(async () => {\n return cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\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 await security.withoutAuthorization(async () => {\n return cms.deleteEntry(model, params.id);\n });\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AAGO,MAAMA,oCAAoC,GAC7CC,MAAwC,IACJ;EACpC,MAAM;IAAEC,GAAG;IAAEC,aAAa;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAC/C,MAAMI,qBAAqB,GAAG,YAAY;IACtC,MAAMC,KAAK,GAAG,MAAMF,QAAQ,CAACG,oBAAoB,CAAC,YAAY;MAC1D,OAAOL,GAAG,CAACM,QAAQ,CAAC,iCAAiC,CAAC;IAC1D,CAAC,CAAC;IACF,IAAI,CAACF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,CAAC;MAChD,CAAC,CAAC;IACN,CAAC;IACD,MAAM+B,mBAAmB,CAACpC,MAAM,EAAE;MAC9B,MAAMK,KAAK,GAAG,MAAMD,qBAAqB,EAAE;MAE3C,MAAMD,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC5C,OAAOL,GAAG,CAACoC,WAAW,CAAChC,KAAK,EAAEL,MAAM,CAACU,EAAE,CAAC;MAC5C,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
|
@@ -1,57 +1,44 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.createCommentStorageOperations = void 0;
|
9
|
-
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
-
|
12
9
|
var _index = require("./index");
|
13
|
-
|
14
10
|
var _fieldResolver = require("../utils/fieldResolver");
|
15
|
-
|
16
11
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
17
|
-
|
18
12
|
var _comment = require("./models/comment.model");
|
19
|
-
|
20
13
|
const pickIdFromChangeRequest = obj => {
|
21
14
|
const rawValue = obj["changeRequest"];
|
22
|
-
|
23
15
|
if (!rawValue) {
|
24
16
|
return obj;
|
25
17
|
}
|
26
|
-
|
27
18
|
obj["changeRequest"] = rawValue.id;
|
28
19
|
return obj;
|
29
20
|
};
|
30
|
-
|
31
21
|
const createCommentStorageOperations = ({
|
32
22
|
cms,
|
33
23
|
getCmsContext,
|
34
24
|
security
|
35
25
|
}) => {
|
36
26
|
const getCommentModel = async () => {
|
37
|
-
security.
|
38
|
-
|
39
|
-
|
40
|
-
|
27
|
+
const model = await security.withoutAuthorization(async () => {
|
28
|
+
return cms.getModel(_comment.COMMENT_MODEL_ID);
|
29
|
+
});
|
41
30
|
if (!model) {
|
42
31
|
throw new _error.default(`Could not find "${_comment.COMMENT_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
43
32
|
}
|
44
|
-
|
45
33
|
return model;
|
46
34
|
};
|
47
|
-
|
48
35
|
const getComment = async ({
|
49
36
|
id
|
50
37
|
}) => {
|
51
38
|
const model = await getCommentModel();
|
52
|
-
security.
|
53
|
-
|
54
|
-
|
39
|
+
const entry = await security.withoutAuthorization(async () => {
|
40
|
+
return cms.getEntryById(model, id);
|
41
|
+
});
|
55
42
|
return (0, _fieldResolver.getFieldValues)({
|
56
43
|
entry,
|
57
44
|
fields: _index.baseFields,
|
@@ -59,19 +46,17 @@ const createCommentStorageOperations = ({
|
|
59
46
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
60
47
|
});
|
61
48
|
};
|
62
|
-
|
63
49
|
return {
|
64
50
|
getCommentModel,
|
65
51
|
getComment: async params => {
|
66
52
|
const values = await getComment(params);
|
67
53
|
return pickIdFromChangeRequest(values);
|
68
54
|
},
|
69
|
-
|
70
55
|
async listComments(params) {
|
71
56
|
const model = await getCommentModel();
|
72
|
-
security.
|
73
|
-
|
74
|
-
|
57
|
+
const [entries, meta] = await security.withoutAuthorization(async () => {
|
58
|
+
return cms.listLatestEntries(model, params);
|
59
|
+
});
|
75
60
|
const values = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
76
61
|
entry,
|
77
62
|
fields: _index.baseFields,
|
@@ -81,18 +66,17 @@ const createCommentStorageOperations = ({
|
|
81
66
|
const all = values.map(value => pickIdFromChangeRequest(value));
|
82
67
|
return [all, meta];
|
83
68
|
},
|
84
|
-
|
85
69
|
async createComment(params) {
|
86
70
|
const model = await getCommentModel();
|
87
71
|
const refModel = await this.getChangeRequestModel();
|
88
|
-
security.
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
72
|
+
const entry = await security.withoutAuthorization(async () => {
|
73
|
+
return cms.createEntry(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params.data), {}, {
|
74
|
+
changeRequest: {
|
75
|
+
id: params.data.changeRequest,
|
76
|
+
modelId: refModel.modelId
|
77
|
+
}
|
78
|
+
}));
|
79
|
+
});
|
96
80
|
const values = await (0, _fieldResolver.getFieldValues)({
|
97
81
|
entry,
|
98
82
|
fields: _index.baseFields,
|
@@ -101,20 +85,18 @@ const createCommentStorageOperations = ({
|
|
101
85
|
});
|
102
86
|
return pickIdFromChangeRequest(values);
|
103
87
|
},
|
104
|
-
|
105
88
|
async updateComment(params) {
|
106
89
|
const model = await getCommentModel();
|
107
90
|
/**
|
108
91
|
* We're fetching the existing entry here because we're not accepting "app" field as input,
|
109
92
|
* but, we still need to retain its value after the "update" operation.
|
110
93
|
*/
|
111
|
-
|
112
94
|
const existingEntry = await getComment({
|
113
95
|
id: params.id
|
114
96
|
});
|
115
|
-
security.
|
116
|
-
|
117
|
-
|
97
|
+
const entry = await security.withoutAuthorization(async () => {
|
98
|
+
return cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
|
99
|
+
});
|
118
100
|
const values = await (0, _fieldResolver.getFieldValues)({
|
119
101
|
entry,
|
120
102
|
fields: _index.baseFields,
|
@@ -123,16 +105,13 @@ const createCommentStorageOperations = ({
|
|
123
105
|
});
|
124
106
|
return pickIdFromChangeRequest(values);
|
125
107
|
},
|
126
|
-
|
127
108
|
async deleteComment(params) {
|
128
109
|
const model = await getCommentModel();
|
129
|
-
security.
|
130
|
-
|
131
|
-
|
110
|
+
await security.withoutAuthorization(async () => {
|
111
|
+
return cms.deleteEntry(model, params.id);
|
112
|
+
});
|
132
113
|
return true;
|
133
114
|
}
|
134
|
-
|
135
115
|
};
|
136
116
|
};
|
137
|
-
|
138
117
|
exports.createCommentStorageOperations = createCommentStorageOperations;
|
@@ -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,CAACC,QAAQ,EAAE;IACX,OAAOD,GAAG;EACd;EACAA,GAAG,CAA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M,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"}
|
@@ -1,93 +1,76 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.createContentReviewStorageOperations = void 0;
|
9
|
-
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
-
|
12
9
|
var _index = require("./index");
|
13
|
-
|
14
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
15
|
-
|
16
11
|
var _contentReview = require("./models/contentReview.model");
|
17
|
-
|
18
12
|
const createContentReviewStorageOperations = ({
|
19
13
|
cms,
|
20
14
|
security
|
21
15
|
}) => {
|
22
16
|
const getContentReviewModel = async () => {
|
23
|
-
security.
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
const model = await security.withoutAuthorization(async () => {
|
18
|
+
return cms.getModel(_contentReview.CONTENT_REVIEW_MODEL_ID);
|
19
|
+
});
|
27
20
|
if (!model) {
|
28
21
|
throw new _error.default(`Could not find "${_contentReview.CONTENT_REVIEW_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
29
22
|
}
|
30
|
-
|
31
23
|
return model;
|
32
24
|
};
|
33
|
-
|
34
25
|
const getContentReview = async ({
|
35
26
|
id
|
36
27
|
}) => {
|
37
28
|
const model = await getContentReviewModel();
|
38
|
-
security.
|
39
|
-
|
40
|
-
|
29
|
+
const entry = await security.withoutAuthorization(async () => {
|
30
|
+
return cms.getEntryById(model, id);
|
31
|
+
});
|
41
32
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
42
33
|
};
|
43
|
-
|
44
34
|
return {
|
45
35
|
getContentReviewModel,
|
46
36
|
getContentReview,
|
47
|
-
|
48
37
|
async listContentReviews(params) {
|
49
38
|
const model = await getContentReviewModel();
|
50
|
-
security.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
+
});
|
55
44
|
return [entries.map(entry => (0, _index.getFieldValues)(entry, _index.baseFields)), meta];
|
56
45
|
},
|
57
|
-
|
58
46
|
async createContentReview(params) {
|
59
47
|
const model = await getContentReviewModel();
|
60
|
-
security.
|
61
|
-
|
62
|
-
|
48
|
+
const entry = await security.withoutAuthorization(async () => {
|
49
|
+
return cms.createEntry(model, params.data);
|
50
|
+
});
|
63
51
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
64
52
|
},
|
65
|
-
|
66
53
|
async updateContentReview(params) {
|
67
54
|
const model = await getContentReviewModel();
|
68
55
|
/**
|
69
56
|
* We're fetching the existing entry here because we're not accepting "app" field as input,
|
70
57
|
* but, we still need to retain its value after the "update" operation.
|
71
58
|
*/
|
72
|
-
|
73
59
|
const existingEntry = await getContentReview({
|
74
60
|
id: params.id
|
75
61
|
});
|
76
|
-
security.
|
77
|
-
|
78
|
-
|
62
|
+
const entry = await security.withoutAuthorization(async () => {
|
63
|
+
return cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
|
64
|
+
});
|
79
65
|
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
80
66
|
},
|
81
|
-
|
82
67
|
async deleteContentReview(params) {
|
83
68
|
const model = await getContentReviewModel();
|
84
|
-
security.
|
85
|
-
|
86
|
-
|
69
|
+
await security.withoutAuthorization(async () => {
|
70
|
+
return cms.deleteEntry(model, params.id);
|
71
|
+
});
|
87
72
|
return true;
|
88
73
|
}
|
89
|
-
|
90
74
|
};
|
91
75
|
};
|
92
|
-
|
93
76
|
exports.createContentReviewStorageOperations = createContentReviewStorageOperations;
|