@webiny/api-apw 0.0.0-unstable.1e66d121db → 0.0.0-unstable.2696f9d9e8
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.d.ts +27 -0
- package/ApwChangeRequestNotification.js +28 -0
- package/ApwChangeRequestNotification.js.map +1 -0
- package/ApwCommentNotification.d.ts +27 -0
- package/ApwCommentNotification.js +28 -0
- package/ApwCommentNotification.js.map +1 -0
- package/ApwContentReviewNotification.d.ts +26 -0
- package/ApwContentReviewNotification.js +28 -0
- package/ApwContentReviewNotification.js.map +1 -0
- package/ApwContentUrlPlugin.d.ts +19 -0
- package/ApwContentUrlPlugin.js +28 -0
- package/ApwContentUrlPlugin.js.map +1 -0
- package/ContentApwSettingsPlugin.js +5 -9
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/README.md +3 -3
- package/crud/createChangeRequestMethods.js +7 -12
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +7 -13
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +83 -111
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +7 -13
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.js +7 -18
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +5 -29
- package/crud/index.js.map +1 -1
- package/crud/utils.js +6 -33
- package/crud/utils.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +6 -16
- package/index.js.map +1 -1
- package/package.json +40 -47
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +4 -19
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +8 -13
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +7 -10
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +4 -20
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +17 -45
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/cms/notifications/changeRequestNotification.js +33 -0
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/cms/notifications/commentNotification.d.ts +1 -0
- package/plugins/cms/notifications/commentNotification.js +33 -0
- package/plugins/cms/notifications/commentNotification.js.map +1 -0
- package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/cms/notifications/contentReviewNotification.js +33 -0
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/cms/notifications/contentUrl.d.ts +8 -0
- package/plugins/cms/notifications/contentUrl.js +55 -0
- package/plugins/cms/notifications/contentUrl.js.map +1 -0
- package/plugins/cms/triggerContentReview.js +5 -18
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +14 -30
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.d.ts +3 -2
- package/plugins/cms/utils.js +23 -60
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.d.ts +0 -1
- package/plugins/context.js +2 -45
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +16 -19
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +41 -42
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +25 -34
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +17 -19
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/utils.d.ts +2 -0
- package/plugins/graphql/utils.js +12 -0
- package/plugins/graphql/utils.js.map +1 -0
- package/plugins/graphql/workflow.gql.js +15 -19
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +5 -18
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +28 -15
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -9
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -8
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +4 -13
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +15 -20
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +2 -0
- package/plugins/hooks/initializeNotifications.js +17 -0
- package/plugins/hooks/initializeNotifications.js.map +1 -0
- package/plugins/hooks/listContentReviews.d.ts +1 -1
- package/plugins/hooks/listContentReviews.js +11 -33
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.d.ts +2 -0
- package/plugins/hooks/notifications/appUrl.js +20 -0
- package/plugins/hooks/notifications/appUrl.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +113 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
- package/plugins/hooks/notifications/changeRequestUrl.js +29 -0
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
- package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/commentAfterCreate.js +124 -0
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
- package/plugins/hooks/notifications/commentUrl.js +29 -0
- package/plugins/hooks/notifications/commentUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +96 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentReviewUrl.js +28 -0
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentUrl.js +26 -0
- package/plugins/hooks/notifications/contentUrl.js.map +1 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +23 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +23 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +23 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/reviewers.d.ts +15 -0
- package/plugins/hooks/notifications/reviewers.js +47 -0
- package/plugins/hooks/notifications/reviewers.js.map +1 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +43 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendCommentNotification.js +43 -0
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js +43 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
- package/plugins/hooks/updatePendingChangeRequests.js +7 -13
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +21 -23
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +27 -16
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +13 -12
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +2 -6
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +4 -19
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js +2 -4
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +3 -6
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
- package/plugins/pageBuilder/index.js +7 -8
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +15 -27
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +3 -31
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +33 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.js +33 -0
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +33 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.js +49 -0
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
- package/plugins/pageBuilder/triggerContentReview.js +2 -11
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +10 -17
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.d.ts +2 -2
- package/plugins/pageBuilder/utils.js +3 -35
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.d.ts +1 -2
- package/plugins/utils.js +6 -52
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +45 -50
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/index.js +47 -40
- 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 +19 -9
- 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 +11 -28
- 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 +10 -92
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.js +2 -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 +24 -37
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +20 -36
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +2 -4
- package/scheduler/handlers/utils.js +8 -47
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.js +2 -3
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.d.ts +12 -28
- package/scheduler/types.js +13 -22
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +59 -45
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +35 -50
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.d.ts +1 -1
- package/storageOperations/contentReviewStorageOperations.js +34 -43
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.d.ts +1 -7
- package/storageOperations/index.js +10 -29
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.d.ts +1 -2
- package/storageOperations/models/changeRequest.model.js +6 -15
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.d.ts +1 -2
- package/storageOperations/models/comment.model.js +6 -14
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentReview.model.d.ts +1 -2
- package/storageOperations/models/contentReview.model.js +13 -37
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +6 -50
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.d.ts +1 -2
- package/storageOperations/models/reviewer.model.js +22 -14
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +2 -4
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.d.ts +1 -2
- package/storageOperations/models/workflow.model.js +19 -42
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.d.ts +1 -1
- package/storageOperations/reviewerStorageOperations.js +34 -40
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/types.js +3 -1
- package/storageOperations/workflowStorageOperations.js +40 -47
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +39 -25
- package/types.js +126 -42
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.js +2 -6
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js +2 -17
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.js +8 -18
- package/utils/fieldResolver.js.map +1 -1
- package/utils/pickEntryFieldValues.d.ts +3 -0
- package/utils/pickEntryFieldValues.js +31 -0
- package/utils/pickEntryFieldValues.js.map +1 -0
- package/utils/resolve.d.ts +1 -1
- package/utils/resolve.js +2 -3
- package/utils/resolve.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.d.ts +0 -15
- package/storageOperations/models/contentModelPluginFactory.js +0 -28
- package/storageOperations/models/contentModelPluginFactory.js.map +0 -1
package/scheduler/types.js
CHANGED
@@ -4,31 +4,22 @@ 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
|
-
let ApwContentTypes;
|
14
|
-
exports.ApwContentTypes = ApwContentTypes;
|
15
|
-
|
16
|
-
(function (ApwContentTypes) {
|
7
|
+
let ApwContentTypes = /*#__PURE__*/function (ApwContentTypes) {
|
17
8
|
ApwContentTypes["PAGE"] = "page";
|
18
9
|
ApwContentTypes["CMS_ENTRY"] = "cms_entry";
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
(function (ApwScheduleActionTypes) {
|
10
|
+
return ApwContentTypes;
|
11
|
+
}({});
|
12
|
+
exports.ApwContentTypes = ApwContentTypes;
|
13
|
+
let ApwScheduleActionTypes = /*#__PURE__*/function (ApwScheduleActionTypes) {
|
25
14
|
ApwScheduleActionTypes["PUBLISH"] = "publish";
|
26
15
|
ApwScheduleActionTypes["UNPUBLISH"] = "unpublish";
|
27
|
-
|
28
|
-
|
29
|
-
|
16
|
+
return ApwScheduleActionTypes;
|
17
|
+
}({});
|
18
|
+
exports.ApwScheduleActionTypes = ApwScheduleActionTypes;
|
19
|
+
let InvocationTypes = /*#__PURE__*/function (InvocationTypes) {
|
20
|
+
InvocationTypes["SCHEDULED"] = "scheduled";
|
21
|
+
return InvocationTypes;
|
22
|
+
}({});
|
30
23
|
exports.InvocationTypes = InvocationTypes;
|
31
24
|
|
32
|
-
|
33
|
-
InvocationTypes["SCHEDULED"] = "scheduled";
|
34
|
-
})(InvocationTypes || (exports.InvocationTypes = InvocationTypes = {}));
|
25
|
+
//# sourceMappingURL=types.js.map
|
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 {
|
1
|
+
{"version":3,"names":["ApwContentTypes","exports","ApwScheduleActionTypes","InvocationTypes"],"sources":["types.ts"],"sourcesContent":["import { Context } from \"@webiny/api/types\";\nimport { SecurityIdentity, SecurityPermission } from \"@webiny/api-security/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { TenancyContext, Tenant } 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\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: ApwIdentity;\n modifiedBy: ApwIdentity | null;\n savedBy: ApwIdentity;\n\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":";;;;;;IAiDYA,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAAAC,OAAA,CAAAD,eAAA,GAAAA,eAAA;AAAA,IAuBfE,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAAD,OAAA,CAAAC,sBAAA,GAAAA,sBAAA;AAAA,IAiBtBC,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAAAF,OAAA,CAAAE,eAAA,GAAAA,eAAA"}
|
@@ -1,70 +1,59 @@
|
|
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
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
-
|
12
|
-
var _index = require("./index");
|
13
|
-
|
8
|
+
var _pickEntryFieldValues = require("../utils/pickEntryFieldValues");
|
14
9
|
var _fieldResolver = require("../utils/fieldResolver");
|
15
|
-
|
16
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
17
|
-
|
18
11
|
const createChangeRequestStorageOperations = params => {
|
19
12
|
const {
|
20
13
|
cms,
|
21
14
|
getCmsContext,
|
22
15
|
security
|
23
16
|
} = params;
|
24
|
-
|
25
17
|
const getChangeRequestModel = async () => {
|
26
|
-
security.
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
const model = await security.withoutAuthorization(async () => {
|
19
|
+
return cms.getModel("apwChangeRequestModelDefinition");
|
20
|
+
});
|
30
21
|
if (!model) {
|
31
22
|
throw new _error.default("Could not find `apwChangeRequestModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
|
32
23
|
}
|
33
|
-
|
34
24
|
return model;
|
35
25
|
};
|
36
|
-
|
37
26
|
const getChangeRequest = async ({
|
38
27
|
id
|
39
28
|
}) => {
|
40
29
|
const model = await getChangeRequestModel();
|
41
|
-
security.
|
42
|
-
|
43
|
-
|
30
|
+
const entry = await security.withoutAuthorization(async () => {
|
31
|
+
return cms.getEntryById(model, id);
|
32
|
+
});
|
44
33
|
return (0, _fieldResolver.getFieldValues)({
|
45
34
|
entry,
|
46
|
-
fields:
|
35
|
+
fields: _pickEntryFieldValues.baseFields,
|
47
36
|
context: getCmsContext(),
|
48
37
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
49
38
|
});
|
50
39
|
};
|
51
|
-
|
52
40
|
return {
|
53
41
|
getChangeRequestModel,
|
54
42
|
getChangeRequest,
|
55
|
-
|
56
43
|
async listChangeRequests(params) {
|
57
44
|
const model = await getChangeRequestModel();
|
58
|
-
security.
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
45
|
+
const [entries, meta] = await security.withoutAuthorization(async () => {
|
46
|
+
return cms.listLatestEntries(model, {
|
47
|
+
...params,
|
48
|
+
where: {
|
49
|
+
...params.where
|
50
|
+
}
|
51
|
+
});
|
52
|
+
});
|
64
53
|
try {
|
65
54
|
const all = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
66
55
|
entry,
|
67
|
-
fields:
|
56
|
+
fields: _pickEntryFieldValues.baseFields,
|
68
57
|
context: getCmsContext(),
|
69
58
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
70
59
|
})));
|
@@ -73,50 +62,75 @@ const createChangeRequestStorageOperations = params => {
|
|
73
62
|
throw new _error.default(ex.message, ex.code, ex.data);
|
74
63
|
}
|
75
64
|
},
|
76
|
-
|
77
65
|
async createChangeRequest(params) {
|
78
66
|
const model = await getChangeRequestModel();
|
79
|
-
security.
|
80
|
-
|
81
|
-
|
67
|
+
const entry = await security.withoutAuthorization(async () => {
|
68
|
+
return cms.createEntry(model, params.data);
|
69
|
+
});
|
82
70
|
return (0, _fieldResolver.getFieldValues)({
|
83
71
|
entry,
|
84
|
-
fields:
|
72
|
+
fields: _pickEntryFieldValues.baseFields,
|
85
73
|
context: getCmsContext(),
|
86
74
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
87
75
|
});
|
88
76
|
},
|
89
|
-
|
90
77
|
async updateChangeRequest(params) {
|
91
78
|
const model = await getChangeRequestModel();
|
79
|
+
|
92
80
|
/**
|
93
81
|
* We're fetching the existing entry here because we're not accepting "app" field as input,
|
94
82
|
* but, we still need to retain its value after the "update" operation.
|
95
83
|
*/
|
96
|
-
|
97
84
|
const existingEntry = await getChangeRequest({
|
98
85
|
id: params.id
|
99
86
|
});
|
100
|
-
|
101
|
-
|
102
|
-
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Only creator can update the change request
|
90
|
+
*/
|
91
|
+
if (existingEntry.createdBy.id !== security.getIdentity().id) {
|
92
|
+
throw new _error.default("A change request can only be updated by its creator.", "ONLY_CREATOR_CAN_UPDATE_CHANGE_REQUEST");
|
93
|
+
}
|
94
|
+
const entry = await security.withoutAuthorization(async () => {
|
95
|
+
return cms.updateEntry(model, params.id, {
|
96
|
+
...existingEntry,
|
97
|
+
...params.data,
|
98
|
+
savedOn: new Date()
|
99
|
+
});
|
100
|
+
});
|
103
101
|
return (0, _fieldResolver.getFieldValues)({
|
104
102
|
entry,
|
105
|
-
fields:
|
103
|
+
fields: _pickEntryFieldValues.baseFields,
|
106
104
|
context: getCmsContext(),
|
107
105
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
108
106
|
});
|
109
107
|
},
|
110
|
-
|
111
108
|
async deleteChangeRequest(params) {
|
112
109
|
const model = await getChangeRequestModel();
|
113
|
-
security.
|
114
|
-
|
115
|
-
|
110
|
+
if (!security.getIdentity()) {
|
111
|
+
return true;
|
112
|
+
}
|
113
|
+
|
114
|
+
/**
|
115
|
+
* We're fetching the existing entry
|
116
|
+
*/
|
117
|
+
const existingEntry = await getChangeRequest({
|
118
|
+
id: params.id
|
119
|
+
});
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Only creator can delete the change request
|
123
|
+
*/
|
124
|
+
if (existingEntry.createdBy.id !== security.getIdentity().id) {
|
125
|
+
throw new _error.default("A change request can only be deleted by its creator.", "ONLY_CREATOR_CAN_DELETE_CHANGE_REQUEST");
|
126
|
+
}
|
127
|
+
await security.withoutAuthorization(async () => {
|
128
|
+
return cms.deleteEntry(model, params.id);
|
129
|
+
});
|
116
130
|
return true;
|
117
131
|
}
|
118
|
-
|
119
132
|
};
|
120
133
|
};
|
134
|
+
exports.createChangeRequestStorageOperations = createChangeRequestStorageOperations;
|
121
135
|
|
122
|
-
|
136
|
+
//# sourceMappingURL=changeRequestStorageOperations.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createChangeRequestStorageOperations","params","cms","getCmsContext","security","getChangeRequestModel","
|
1
|
+
{"version":3,"names":["_pickEntryFieldValues","require","_fieldResolver","_error","_interopRequireDefault","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","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 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 /**\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 security.withoutAuthorization(async () => {\n return 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 security.withoutAuthorization(async () => {\n return cms.deleteEntry(model, params.id);\n });\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,MAAMF,QAAQ,CAACG,oBAAoB,CAAC,YAAY;MAC1D,OAAOL,GAAG,CAACM,QAAQ,CAAC,iCAAiC,CAAC;IAC1D,CAAC,CAAC;IACF,IAAI,CAACF,KAAK,EAAE;MACR,MAAM,IAAIG,cAAW,CACjB,yDAAyD,EACzD,uBACJ,CAAC;IACL;IACA,OAAOH,KAAK;EAChB,CAAC;EACD,MAAMI,gBAAuE,GAAG,MAAAA,CAAO;IACnFC;EACJ,CAAC,KAAK;IAC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AAO,IAAA1B,6BAAc,EAAC;QAClBF,KAAK;QACLG,MAAM,EAAEC,gCAAU;QAClBC,OAAO,EAAEd,aAAa,CAAC,CAAC;QACxBe,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACb,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;IACN,CAAC;IACD,MAAMmC,mBAAmBA,CAACxC,MAAM,EAAE;MAC9B,MAAMK,KAAK,GAAG,MAAMD,qBAAqB,CAAC,CAAC;MAE3C,IAAI,CAACD,QAAQ,CAACiC,WAAW,CAAC,CAAC,EAAE;QACzB,OAAO,IAAI;MACf;;MAEA;AACZ;AACA;MACY,MAAMF,aAAa,GAAG,MAAMzB,gBAAgB,CAAC;QAAEC,EAAE,EAAEV,MAAM,CAACU;MAAG,CAAC,CAAC;;MAE/D;AACZ;AACA;MACY,IAAIwB,aAAa,CAACC,SAAS,CAACzB,EAAE,KAAKP,QAAQ,CAACiC,WAAW,CAAC,CAAC,CAAC1B,EAAE,EAAE;QAC1D,MAAM,IAAIF,cAAW,CACjB,sDAAsD,EACtD,wCACJ,CAAC;MACL;MAEA,MAAML,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC5C,OAAOL,GAAG,CAACwC,WAAW,CAACpC,KAAK,EAAEL,MAAM,CAACU,EAAE,CAAC;MAC5C,CAAC,CAAC;MAEF,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAACgC,OAAA,CAAA3C,oCAAA,GAAAA,oCAAA"}
|
@@ -1,138 +1,123 @@
|
|
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
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
-
|
12
|
-
var _index = require("./index");
|
13
|
-
|
14
8
|
var _fieldResolver = require("../utils/fieldResolver");
|
15
|
-
|
9
|
+
var _pickEntryFieldValues = require("../utils/pickEntryFieldValues");
|
16
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
17
|
-
|
18
11
|
var _comment = require("./models/comment.model");
|
19
|
-
|
20
12
|
const pickIdFromChangeRequest = obj => {
|
21
13
|
const rawValue = obj["changeRequest"];
|
22
|
-
|
23
14
|
if (!rawValue) {
|
24
15
|
return obj;
|
25
16
|
}
|
26
|
-
|
27
17
|
obj["changeRequest"] = rawValue.id;
|
28
18
|
return obj;
|
29
19
|
};
|
30
|
-
|
31
20
|
const createCommentStorageOperations = ({
|
32
21
|
cms,
|
33
22
|
getCmsContext,
|
34
23
|
security
|
35
24
|
}) => {
|
36
25
|
const getCommentModel = async () => {
|
37
|
-
security.
|
38
|
-
|
39
|
-
|
40
|
-
|
26
|
+
const model = await security.withoutAuthorization(async () => {
|
27
|
+
return cms.getModel(_comment.COMMENT_MODEL_ID);
|
28
|
+
});
|
41
29
|
if (!model) {
|
42
30
|
throw new _error.default(`Could not find "${_comment.COMMENT_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
43
31
|
}
|
44
|
-
|
45
32
|
return model;
|
46
33
|
};
|
47
|
-
|
48
34
|
const getComment = async ({
|
49
35
|
id
|
50
36
|
}) => {
|
51
37
|
const model = await getCommentModel();
|
52
|
-
security.
|
53
|
-
|
54
|
-
|
38
|
+
const entry = await security.withoutAuthorization(async () => {
|
39
|
+
return cms.getEntryById(model, id);
|
40
|
+
});
|
55
41
|
return (0, _fieldResolver.getFieldValues)({
|
56
42
|
entry,
|
57
|
-
fields:
|
43
|
+
fields: _pickEntryFieldValues.baseFields,
|
58
44
|
context: getCmsContext(),
|
59
45
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
60
46
|
});
|
61
47
|
};
|
62
|
-
|
63
48
|
return {
|
64
49
|
getCommentModel,
|
65
50
|
getComment: async params => {
|
66
51
|
const values = await getComment(params);
|
67
52
|
return pickIdFromChangeRequest(values);
|
68
53
|
},
|
69
|
-
|
70
54
|
async listComments(params) {
|
71
55
|
const model = await getCommentModel();
|
72
|
-
security.
|
73
|
-
|
74
|
-
|
56
|
+
const [entries, meta] = await security.withoutAuthorization(async () => {
|
57
|
+
return cms.listLatestEntries(model, params);
|
58
|
+
});
|
75
59
|
const values = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
76
60
|
entry,
|
77
|
-
fields:
|
61
|
+
fields: _pickEntryFieldValues.baseFields,
|
78
62
|
context: getCmsContext(),
|
79
63
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
80
64
|
})));
|
81
65
|
const all = values.map(value => pickIdFromChangeRequest(value));
|
82
66
|
return [all, meta];
|
83
67
|
},
|
84
|
-
|
85
68
|
async createComment(params) {
|
86
69
|
const model = await getCommentModel();
|
87
70
|
const refModel = await this.getChangeRequestModel();
|
88
|
-
security.
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
71
|
+
const entry = await security.withoutAuthorization(async () => {
|
72
|
+
return cms.createEntry(model, {
|
73
|
+
...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
|
-
fields:
|
82
|
+
fields: _pickEntryFieldValues.baseFields,
|
99
83
|
context: getCmsContext(),
|
100
84
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
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, {
|
99
|
+
...existingEntry,
|
100
|
+
...params.data,
|
101
|
+
savedOn: new Date()
|
102
|
+
});
|
103
|
+
});
|
118
104
|
const values = await (0, _fieldResolver.getFieldValues)({
|
119
105
|
entry,
|
120
|
-
fields:
|
106
|
+
fields: _pickEntryFieldValues.baseFields,
|
121
107
|
context: getCmsContext(),
|
122
108
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
123
109
|
});
|
124
110
|
return pickIdFromChangeRequest(values);
|
125
111
|
},
|
126
|
-
|
127
112
|
async deleteComment(params) {
|
128
113
|
const model = await getCommentModel();
|
129
|
-
security.
|
130
|
-
|
131
|
-
|
114
|
+
await security.withoutAuthorization(async () => {
|
115
|
+
return cms.deleteEntry(model, params.id);
|
116
|
+
});
|
132
117
|
return true;
|
133
118
|
}
|
134
|
-
|
135
119
|
};
|
136
120
|
};
|
121
|
+
exports.createCommentStorageOperations = createCommentStorageOperations;
|
137
122
|
|
138
|
-
|
123
|
+
//# sourceMappingURL=commentStorageOperations.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["pickIdFromChangeRequest","obj","rawValue","id","createCommentStorageOperations","cms","getCmsContext","security","getCommentModel","
|
1
|
+
{"version":3,"names":["_fieldResolver","require","_pickEntryFieldValues","_error","_interopRequireDefault","_comment","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","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 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 savedOn: new Date()\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":";;;;;;;AAGA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAGA,IAAAI,QAAA,GAAAJ,OAAA;AAEA,MAAMK,uBAAuB,GAAIC,GAAwB,IAAiB;EACtE,MAAMC,QAAQ,GAAGD,GAAG,CAAC,eAAe,CAAC;EACrC,IAAI,CAACC,QAAQ,EAAE;IACX,OAAOD,GAAG;EACd;EACAA,GAAG,CAAC,eAAe,CAAC,GAAGC,QAAQ,CAACC,EAAE;EAClC,OAAOF,GAAG;AACd,CAAC;AAEM,MAAMG,8BAA8B,GAAGA,CAAC;EAC3CC,GAAG;EACHC,aAAa;EACbC;AA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AE;MACxB,MAAMd,KAAK,GAAG,MAAMD,eAAe,CAAC,CAAC;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,EAAE;UACrC,GAAGsC,aAAa;UAChB,GAAGlB,MAAM,CAACc,IAAI;UACdM,OAAO,EAAE,IAAIC,IAAI,CAAC;QACtB,CAAC,CAAC;MACN,CAAC,CAAC;MAEF,MAAMpB,MAAM,GAAG,MAAM,IAAAP,6BAAc,EAAC;QAChCF,KAAK;QACLG,MAAM,EAAEC,gCAAU;QAClBC,OAAO,EAAEd,aAAa,CAAC,CAAC;QACxBe,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACb,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;MACF,OAAOT,uBAAuB,CAACwB,MAAM,CAAC;IAC1C,CAAC;IACD,MAAMqB,aAAaA,CAACtB,MAAM,EAAE;MACxB,MAAMd,KAAK,GAAG,MAAMD,eAAe,CAAC,CAAC;MACrC,MAAMD,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC5C,OAAOL,GAAG,CAACyC,WAAW,CAACrC,KAAK,EAAEc,MAAM,CAACpB,EAAE,CAAC;MAC5C,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC4C,OAAA,CAAA3C,8BAAA,GAAAA,8BAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { ApwContentReviewStorageOperations } from "./types";
|
2
|
-
import { CreateApwStorageOperationsParams } from "
|
2
|
+
import { CreateApwStorageOperationsParams } from ".";
|
3
3
|
export declare const createContentReviewStorageOperations: ({ cms, security }: CreateApwStorageOperationsParams) => ApwContentReviewStorageOperations;
|