@webiny/api-apw 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d
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 +1 -1
- package/ApwChangeRequestNotification.js +3 -15
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.d.ts +1 -1
- package/ApwCommentNotification.js +3 -15
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.d.ts +1 -1
- package/ApwContentReviewNotification.js +3 -15
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.d.ts +1 -1
- package/ApwContentUrlPlugin.js +3 -15
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.d.ts +1 -1
- package/ContentApwSettingsPlugin.js +5 -9
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/README.md +3 -3
- package/crud/createChangeRequestMethods.d.ts +1 -1
- package/crud/createChangeRequestMethods.js +7 -12
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.d.ts +1 -1
- package/crud/createCommentMethods.js +7 -13
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.d.ts +2 -2
- package/crud/createContentReviewMethods.js +76 -115
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.d.ts +1 -1
- package/crud/createReviewerMethods.js +7 -13
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.d.ts +1 -1
- package/crud/createWorkflowMethods.js +7 -18
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.d.ts +1 -1
- package/crud/index.js +5 -29
- package/crud/index.js.map +1 -1
- package/crud/utils.d.ts +2 -2
- package/crud/utils.js +7 -35
- package/crud/utils.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +6 -19
- package/index.js.map +1 -1
- package/package.json +32 -50
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +1 -1
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +4 -19
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.d.ts +2 -2
- package/plugins/cms/apwEntryPlugins.js +18 -14
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.d.ts +4 -4
- package/plugins/cms/index.js +2 -13
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.d.ts +2 -2
- package/plugins/cms/linkContentReviewToEntry.js +4 -20
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.d.ts +2 -2
- package/plugins/cms/linkWorkflowToEntry.js +18 -46
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.js +2 -4
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/cms/notifications/commentNotification.js +2 -4
- package/plugins/cms/notifications/commentNotification.js.map +1 -1
- package/plugins/cms/notifications/contentReviewNotification.js +2 -4
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/cms/notifications/contentUrl.js +3 -8
- package/plugins/cms/notifications/contentUrl.js.map +1 -1
- package/plugins/cms/triggerContentReview.d.ts +2 -2
- package/plugins/cms/triggerContentReview.js +5 -18
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.d.ts +3 -3
- package/plugins/cms/updateContentReviewStatus.js +14 -30
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.d.ts +5 -4
- package/plugins/cms/utils.js +20 -59
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.d.ts +3 -4
- package/plugins/context.js +4 -58
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.d.ts +1 -1
- package/plugins/graphql/changeRequest.gql.js +16 -20
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.d.ts +1 -1
- package/plugins/graphql/comment.gql.js +41 -43
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.d.ts +1 -1
- package/plugins/graphql/contentReview.gql.js +25 -35
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.d.ts +1 -1
- package/plugins/graphql/reviewer.gql.js +15 -20
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/utils.d.ts +2 -0
- package/plugins/graphql/utils.js +10 -0
- package/plugins/graphql/utils.js.map +1 -0
- package/plugins/graphql/workflow.gql.d.ts +1 -1
- package/plugins/graphql/workflow.gql.js +15 -20
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.d.ts +1 -1
- package/plugins/graphql.js +5 -18
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.d.ts +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +5 -12
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -9
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -8
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.d.ts +1 -1
- package/plugins/hooks/index.js +2 -14
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.d.ts +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +15 -20
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +1 -1
- package/plugins/hooks/initializeNotifications.js +2 -5
- package/plugins/hooks/initializeNotifications.js.map +1 -1
- package/plugins/hooks/listContentReviews.d.ts +3 -3
- package/plugins/hooks/listContentReviews.js +3 -13
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +7 -38
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestUrl.js +2 -4
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.d.ts +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +7 -40
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/commentUrl.js +2 -4
- package/plugins/hooks/notifications/commentUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +9 -35
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewUrl.js +2 -4
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentUrl.d.ts +2 -2
- package/plugins/hooks/notifications/contentUrl.js +2 -5
- package/plugins/hooks/notifications/contentUrl.js.map +1 -1
- package/plugins/hooks/notifications/getAppUrl.d.ts +2 -0
- package/plugins/hooks/notifications/getAppUrl.js +19 -0
- package/plugins/hooks/notifications/getAppUrl.js.map +1 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +2 -4
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +2 -4
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +2 -4
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.d.ts +1 -1
- package/plugins/hooks/notifications/reviewers.js +17 -21
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +2 -11
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.js +2 -11
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js +2 -11
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.d.ts +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js +7 -13
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.d.ts +1 -1
- package/plugins/hooks/updateTotalComments.js +21 -23
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.d.ts +1 -1
- package/plugins/hooks/validateChangeRequest.js +2 -16
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.d.ts +1 -1
- package/plugins/hooks/validateComment.js +3 -12
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.d.ts +1 -1
- package/plugins/hooks/validateContentReview.js +2 -6
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/utils.d.ts +7 -6
- package/plugins/utils.js +11 -50
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.d.ts +1 -1
- package/scheduler/createScheduleActionMethods.js +105 -85
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +2 -2
- package/scheduler/handlers/executeAction/index.js +47 -41
- 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 +3 -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 +4 -3
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +10 -92
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.d.ts +2 -2
- package/scheduler/handlers/executeAction/security.js +2 -11
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +2 -2
- package/scheduler/handlers/scheduleAction/index.js +23 -38
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +3 -3
- 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 +22 -53
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.d.ts +1 -1
- package/scheduler/index.js +2 -3
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.d.ts +20 -36
- package/scheduler/types.js +11 -23
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.d.ts +2 -2
- package/storageOperations/changeRequestStorageOperations.js +43 -41
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.d.ts +3 -3
- package/storageOperations/commentStorageOperations.js +16 -44
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.d.ts +3 -3
- package/storageOperations/contentReviewStorageOperations.js +19 -41
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.d.ts +3 -9
- 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 +9 -19
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.d.ts +1 -2
- package/storageOperations/models/comment.model.js +9 -18
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentReview.model.d.ts +1 -2
- package/storageOperations/models/contentReview.model.js +16 -41
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.d.ts +1 -1
- package/storageOperations/models/index.js +11 -55
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.d.ts +1 -2
- package/storageOperations/models/reviewer.model.js +10 -19
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.d.ts +2 -2
- package/storageOperations/models/utils.js +2 -4
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.d.ts +2 -3
- package/storageOperations/models/workflow.model.js +22 -46
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.d.ts +3 -3
- package/storageOperations/reviewerStorageOperations.js +23 -50
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/types.d.ts +2 -2
- package/storageOperations/types.js +3 -1
- package/storageOperations/types.js.map +1 -1
- package/storageOperations/workflowStorageOperations.d.ts +2 -2
- package/storageOperations/workflowStorageOperations.js +24 -44
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +49 -64
- package/types.js +121 -43
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.d.ts +2 -2
- 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.d.ts +2 -2
- package/utils/fieldResolver.js +8 -18
- package/utils/fieldResolver.js.map +1 -1
- package/utils/pickEntryFieldValues.d.ts +3 -0
- package/utils/pickEntryFieldValues.js +30 -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/plugins/hooks/notifications/appUrl.d.ts +0 -2
- package/plugins/hooks/notifications/appUrl.js +0 -22
- package/plugins/hooks/notifications/appUrl.js.map +0 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +0 -9
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -51
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +0 -1
- package/plugins/pageBuilder/apwContentPagePlugins.d.ts +0 -3
- package/plugins/pageBuilder/apwContentPagePlugins.js +0 -30
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +0 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +0 -3
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +0 -25
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +0 -1
- package/plugins/pageBuilder/index.d.ts +0 -11
- package/plugins/pageBuilder/index.js +0 -53
- package/plugins/pageBuilder/index.js.map +0 -1
- package/plugins/pageBuilder/linkContentReviewToPage.d.ts +0 -8
- package/plugins/pageBuilder/linkContentReviewToPage.js +0 -105
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +0 -1
- package/plugins/pageBuilder/linkWorkflowToPage.d.ts +0 -8
- package/plugins/pageBuilder/linkWorkflowToPage.js +0 -194
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +0 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +0 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +0 -35
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +0 -1
- package/plugins/pageBuilder/notifications/commentNotification.d.ts +0 -1
- package/plugins/pageBuilder/notifications/commentNotification.js +0 -35
- package/plugins/pageBuilder/notifications/commentNotification.js.map +0 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +0 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +0 -35
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +0 -1
- package/plugins/pageBuilder/notifications/contentUrl.d.ts +0 -1
- package/plugins/pageBuilder/notifications/contentUrl.js +0 -53
- package/plugins/pageBuilder/notifications/contentUrl.js.map +0 -1
- package/plugins/pageBuilder/triggerContentReview.d.ts +0 -8
- package/plugins/pageBuilder/triggerContentReview.js +0 -50
- package/plugins/pageBuilder/triggerContentReview.js.map +0 -1
- package/plugins/pageBuilder/updateContentReviewStatus.d.ts +0 -10
- package/plugins/pageBuilder/updateContentReviewStatus.js +0 -79
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +0 -1
- package/plugins/pageBuilder/utils.d.ts +0 -22
- package/plugins/pageBuilder/utils.js +0 -184
- package/plugins/pageBuilder/utils.js.map +0 -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,19 @@ 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 = exports.ApwContentTypes = /*#__PURE__*/function (ApwContentTypes) {
|
17
8
|
ApwContentTypes["PAGE"] = "page";
|
18
9
|
ApwContentTypes["CMS_ENTRY"] = "cms_entry";
|
19
|
-
|
20
|
-
|
21
|
-
let ApwScheduleActionTypes
|
22
|
-
exports.ApwScheduleActionTypes = ApwScheduleActionTypes;
|
23
|
-
|
24
|
-
(function (ApwScheduleActionTypes) {
|
10
|
+
return ApwContentTypes;
|
11
|
+
}({});
|
12
|
+
let ApwScheduleActionTypes = exports.ApwScheduleActionTypes = /*#__PURE__*/function (ApwScheduleActionTypes) {
|
25
13
|
ApwScheduleActionTypes["PUBLISH"] = "publish";
|
26
14
|
ApwScheduleActionTypes["UNPUBLISH"] = "unpublish";
|
27
|
-
|
28
|
-
|
29
|
-
let InvocationTypes
|
30
|
-
exports.InvocationTypes = InvocationTypes;
|
31
|
-
|
32
|
-
(function (InvocationTypes) {
|
15
|
+
return ApwScheduleActionTypes;
|
16
|
+
}({});
|
17
|
+
let InvocationTypes = exports.InvocationTypes = /*#__PURE__*/function (InvocationTypes) {
|
33
18
|
InvocationTypes["SCHEDULED"] = "scheduled";
|
34
|
-
|
19
|
+
return InvocationTypes;
|
20
|
+
}({});
|
21
|
+
|
22
|
+
//# 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 type { Context } from \"@webiny/api/types\";\nimport type { SecurityIdentity, SecurityPermission } from \"@webiny/api-security/types\";\nimport type { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport type { TenancyContext, Tenant } from \"@webiny/api-tenancy/types\";\nimport type { 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,GAAAC,OAAA,CAAAD,eAAA,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAAA,IAuBfE,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAA,IAiBtBC,eAAe,GAAAF,OAAA,CAAAE,eAAA,0BAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA","ignoreList":[]}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { ApwChangeRequestStorageOperations } from "./types";
|
2
|
-
import { CreateApwStorageOperationsParams } from "./index";
|
1
|
+
import type { ApwChangeRequestStorageOperations } from "./types";
|
2
|
+
import type { CreateApwStorageOperationsParams } from "./index";
|
3
3
|
export declare const createChangeRequestStorageOperations: (params: CreateApwStorageOperationsParams) => ApwChangeRequestStorageOperations;
|
@@ -1,70 +1,53 @@
|
|
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.disableAuthorization();
|
27
18
|
const model = await cms.getModel("apwChangeRequestModelDefinition");
|
28
|
-
security.enableAuthorization();
|
29
|
-
|
30
19
|
if (!model) {
|
31
20
|
throw new _error.default("Could not find `apwChangeRequestModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
|
32
21
|
}
|
33
|
-
|
34
22
|
return model;
|
35
23
|
};
|
36
|
-
|
37
24
|
const getChangeRequest = async ({
|
38
25
|
id
|
39
26
|
}) => {
|
40
27
|
const model = await getChangeRequestModel();
|
41
|
-
security.disableAuthorization();
|
42
28
|
const entry = await cms.getEntryById(model, id);
|
43
|
-
security.enableAuthorization();
|
44
29
|
return (0, _fieldResolver.getFieldValues)({
|
45
30
|
entry,
|
46
|
-
fields:
|
31
|
+
fields: _pickEntryFieldValues.baseFields,
|
47
32
|
context: getCmsContext(),
|
48
33
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
49
34
|
});
|
50
35
|
};
|
51
|
-
|
52
36
|
return {
|
53
37
|
getChangeRequestModel,
|
54
38
|
getChangeRequest,
|
55
|
-
|
56
39
|
async listChangeRequests(params) {
|
57
40
|
const model = await getChangeRequestModel();
|
58
|
-
|
59
|
-
|
60
|
-
where:
|
61
|
-
|
62
|
-
|
63
|
-
|
41
|
+
const [entries, meta] = await cms.listLatestEntries(model, {
|
42
|
+
...params,
|
43
|
+
where: {
|
44
|
+
...params.where
|
45
|
+
}
|
46
|
+
});
|
64
47
|
try {
|
65
48
|
const all = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
66
49
|
entry,
|
67
|
-
fields:
|
50
|
+
fields: _pickEntryFieldValues.baseFields,
|
68
51
|
context: getCmsContext(),
|
69
52
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
70
53
|
})));
|
@@ -73,50 +56,69 @@ const createChangeRequestStorageOperations = params => {
|
|
73
56
|
throw new _error.default(ex.message, ex.code, ex.data);
|
74
57
|
}
|
75
58
|
},
|
76
|
-
|
77
59
|
async createChangeRequest(params) {
|
78
60
|
const model = await getChangeRequestModel();
|
79
|
-
security.disableAuthorization();
|
80
61
|
const entry = await cms.createEntry(model, params.data);
|
81
|
-
security.enableAuthorization();
|
82
62
|
return (0, _fieldResolver.getFieldValues)({
|
83
63
|
entry,
|
84
|
-
fields:
|
64
|
+
fields: _pickEntryFieldValues.baseFields,
|
85
65
|
context: getCmsContext(),
|
86
66
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
87
67
|
});
|
88
68
|
},
|
89
|
-
|
90
69
|
async updateChangeRequest(params) {
|
91
70
|
const model = await getChangeRequestModel();
|
71
|
+
|
92
72
|
/**
|
93
73
|
* We're fetching the existing entry here because we're not accepting "app" field as input,
|
94
74
|
* but, we still need to retain its value after the "update" operation.
|
95
75
|
*/
|
96
|
-
|
97
76
|
const existingEntry = await getChangeRequest({
|
98
77
|
id: params.id
|
99
78
|
});
|
100
|
-
|
101
|
-
|
102
|
-
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Only creator can update the change request
|
82
|
+
*/
|
83
|
+
if (existingEntry.createdBy.id !== security.getIdentity().id) {
|
84
|
+
throw new _error.default("A change request can only be updated by its creator.", "ONLY_CREATOR_CAN_UPDATE_CHANGE_REQUEST");
|
85
|
+
}
|
86
|
+
const entry = await cms.updateEntry(model, params.id, {
|
87
|
+
...existingEntry,
|
88
|
+
...params.data,
|
89
|
+
savedOn: new Date()
|
90
|
+
});
|
103
91
|
return (0, _fieldResolver.getFieldValues)({
|
104
92
|
entry,
|
105
|
-
fields:
|
93
|
+
fields: _pickEntryFieldValues.baseFields,
|
106
94
|
context: getCmsContext(),
|
107
95
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
108
96
|
});
|
109
97
|
},
|
110
|
-
|
111
98
|
async deleteChangeRequest(params) {
|
112
99
|
const model = await getChangeRequestModel();
|
113
|
-
security.
|
100
|
+
if (!security.getIdentity()) {
|
101
|
+
return true;
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* We're fetching the existing entry
|
106
|
+
*/
|
107
|
+
const existingEntry = await getChangeRequest({
|
108
|
+
id: params.id
|
109
|
+
});
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Only creator can delete the change request
|
113
|
+
*/
|
114
|
+
if (existingEntry.createdBy.id !== security.getIdentity().id) {
|
115
|
+
throw new _error.default("A change request can only be deleted by its creator.", "ONLY_CREATOR_CAN_DELETE_CHANGE_REQUEST");
|
116
|
+
}
|
114
117
|
await cms.deleteEntry(model, params.id);
|
115
|
-
security.enableAuthorization();
|
116
118
|
return true;
|
117
119
|
}
|
118
|
-
|
119
120
|
};
|
120
121
|
};
|
122
|
+
exports.createChangeRequestStorageOperations = createChangeRequestStorageOperations;
|
121
123
|
|
122
|
-
|
124
|
+
//# 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","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 type { ApwChangeRequestStorageOperations } from \"./types\";\nimport type { CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { baseFields } from \"~/utils/pickEntryFieldValues\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\nimport WebinyError from \"@webiny/error\";\nimport type { ApwChangeRequest } from \"~/types\";\n\nexport const createChangeRequestStorageOperations = (\n params: CreateApwStorageOperationsParams\n): ApwChangeRequestStorageOperations => {\n const { cms, getCmsContext, security } = params;\n const getChangeRequestModel = async () => {\n const model = await cms.getModel(\"apwChangeRequestModelDefinition\");\n if (!model) {\n throw new WebinyError(\n \"Could not find `apwChangeRequestModelDefinition` model.\",\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getChangeRequest: ApwChangeRequestStorageOperations[\"getChangeRequest\"] = async ({\n id\n }) => {\n const model = await getChangeRequestModel();\n\n const entry = await cms.getEntryById(model, id);\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n };\n return {\n getChangeRequestModel,\n getChangeRequest,\n async listChangeRequests(params) {\n const model = await getChangeRequestModel();\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n\n try {\n const all = await Promise.all(\n entries.map(entry =>\n getFieldValues<ApwChangeRequest>({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n })\n )\n );\n return [all, meta];\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code, ex.data);\n }\n },\n async createChangeRequest(params) {\n const model = await getChangeRequestModel();\n const entry = await cms.createEntry(model, params.data);\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async updateChangeRequest(params) {\n const model = await getChangeRequestModel();\n\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getChangeRequest({ id: params.id });\n\n /**\n * Only creator can update the change request\n */\n if (existingEntry.createdBy.id !== security.getIdentity().id) {\n throw new WebinyError(\n \"A change request can only be updated by its creator.\",\n \"ONLY_CREATOR_CAN_UPDATE_CHANGE_REQUEST\"\n );\n }\n\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data,\n savedOn: new Date()\n });\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async deleteChangeRequest(params) {\n const model = await getChangeRequestModel();\n\n if (!security.getIdentity()) {\n return true;\n }\n\n /**\n * We're fetching the existing entry\n */\n const existingEntry = await getChangeRequest({ id: params.id });\n\n /**\n * Only creator can delete the change request\n */\n if (existingEntry.createdBy.id !== security.getIdentity().id) {\n throw new WebinyError(\n \"A change request can only be deleted by its creator.\",\n \"ONLY_CREATOR_CAN_DELETE_CHANGE_REQUEST\"\n );\n }\n\n await cms.deleteEntry(model, params.id);\n\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAGO,MAAMI,oCAAoC,GAC7CC,MAAwC,IACJ;EACpC,MAAM;IAAEC,GAAG;IAAEC,aAAa;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAC/C,MAAMI,qBAAqB,GAAG,MAAAA,CAAA,KAAY;IACtC,MAAMC,KAAK,GAAG,MAAMJ,GAAG,CAACK,QAAQ,CAAC,iCAAiC,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AEC,gCAAU;QAClBC,OAAO,EAAEb,aAAa,CAAC,CAAC;QACxBc,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACZ,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;IACN,CAAC;IACD,MAAMkC,mBAAmBA,CAACvC,MAAM,EAAE;MAC9B,MAAMK,KAAK,GAAG,MAAMD,qBAAqB,CAAC,CAAC;MAE3C,IAAI,CAACD,QAAQ,CAACgC,WAAW,CAAC,CAAC,EAAE;QACzB,OAAO,IAAI;MACf;;MAEA;AACZ;AACA;MACY,MAAMF,aAAa,GAAG,MAAMzB,gBAAgB,CAAC;QAAEC,EAAE,EAAET,MAAM,CAACS;MAAG,CAAC,CAAC;;MAE/D;AACZ;AACA;MACY,IAAIwB,aAAa,CAACC,SAAS,CAACzB,EAAE,KAAKN,QAAQ,CAACgC,WAAW,CAAC,CAAC,CAAC1B,EAAE,EAAE;QAC1D,MAAM,IAAIF,cAAW,CACjB,sDAAsD,EACtD,wCACJ,CAAC;MACL;MAEA,MAAMN,GAAG,CAACuC,WAAW,CAACnC,KAAK,EAAEL,MAAM,CAACS,EAAE,CAAC;MAEvC,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAACgC,OAAA,CAAA1C,oCAAA,GAAAA,oCAAA","ignoreList":[]}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { ApwCommentStorageOperations } from "./types";
|
2
|
-
import { CreateApwStorageOperationsParams } from "./index";
|
3
|
-
export declare const createCommentStorageOperations: ({ cms, getCmsContext
|
1
|
+
import type { ApwCommentStorageOperations } from "./types";
|
2
|
+
import type { CreateApwStorageOperationsParams } from "./index";
|
3
|
+
export declare const createCommentStorageOperations: ({ cms, getCmsContext }: CreateApwStorageOperationsParams) => ApwCommentStorageOperations;
|
@@ -1,138 +1,110 @@
|
|
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
|
-
getCmsContext
|
34
|
-
security
|
22
|
+
getCmsContext
|
35
23
|
}) => {
|
36
24
|
const getCommentModel = async () => {
|
37
|
-
security.disableAuthorization();
|
38
25
|
const model = await cms.getModel(_comment.COMMENT_MODEL_ID);
|
39
|
-
security.enableAuthorization();
|
40
|
-
|
41
26
|
if (!model) {
|
42
27
|
throw new _error.default(`Could not find "${_comment.COMMENT_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
43
28
|
}
|
44
|
-
|
45
29
|
return model;
|
46
30
|
};
|
47
|
-
|
48
31
|
const getComment = async ({
|
49
32
|
id
|
50
33
|
}) => {
|
51
34
|
const model = await getCommentModel();
|
52
|
-
security.disableAuthorization();
|
53
35
|
const entry = await cms.getEntryById(model, id);
|
54
|
-
security.enableAuthorization();
|
55
36
|
return (0, _fieldResolver.getFieldValues)({
|
56
37
|
entry,
|
57
|
-
fields:
|
38
|
+
fields: _pickEntryFieldValues.baseFields,
|
58
39
|
context: getCmsContext(),
|
59
40
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
60
41
|
});
|
61
42
|
};
|
62
|
-
|
63
43
|
return {
|
64
44
|
getCommentModel,
|
65
45
|
getComment: async params => {
|
66
46
|
const values = await getComment(params);
|
67
47
|
return pickIdFromChangeRequest(values);
|
68
48
|
},
|
69
|
-
|
70
49
|
async listComments(params) {
|
71
50
|
const model = await getCommentModel();
|
72
|
-
security.disableAuthorization();
|
73
51
|
const [entries, meta] = await cms.listLatestEntries(model, params);
|
74
|
-
security.enableAuthorization();
|
75
52
|
const values = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
76
53
|
entry,
|
77
|
-
fields:
|
54
|
+
fields: _pickEntryFieldValues.baseFields,
|
78
55
|
context: getCmsContext(),
|
79
56
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
80
57
|
})));
|
81
58
|
const all = values.map(value => pickIdFromChangeRequest(value));
|
82
59
|
return [all, meta];
|
83
60
|
},
|
84
|
-
|
85
61
|
async createComment(params) {
|
86
62
|
const model = await getCommentModel();
|
87
63
|
const refModel = await this.getChangeRequestModel();
|
88
|
-
|
89
|
-
|
64
|
+
const entry = await cms.createEntry(model, {
|
65
|
+
...params.data,
|
90
66
|
changeRequest: {
|
91
67
|
id: params.data.changeRequest,
|
92
68
|
modelId: refModel.modelId
|
93
69
|
}
|
94
|
-
})
|
95
|
-
security.enableAuthorization();
|
70
|
+
});
|
96
71
|
const values = await (0, _fieldResolver.getFieldValues)({
|
97
72
|
entry,
|
98
|
-
fields:
|
73
|
+
fields: _pickEntryFieldValues.baseFields,
|
99
74
|
context: getCmsContext(),
|
100
75
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
101
76
|
});
|
102
77
|
return pickIdFromChangeRequest(values);
|
103
78
|
},
|
104
|
-
|
105
79
|
async updateComment(params) {
|
106
80
|
const model = await getCommentModel();
|
107
81
|
/**
|
108
82
|
* We're fetching the existing entry here because we're not accepting "app" field as input,
|
109
83
|
* but, we still need to retain its value after the "update" operation.
|
110
84
|
*/
|
111
|
-
|
112
85
|
const existingEntry = await getComment({
|
113
86
|
id: params.id
|
114
87
|
});
|
115
|
-
|
116
|
-
|
117
|
-
|
88
|
+
const entry = await cms.updateEntry(model, params.id, {
|
89
|
+
...existingEntry,
|
90
|
+
...params.data,
|
91
|
+
savedOn: new Date()
|
92
|
+
});
|
118
93
|
const values = await (0, _fieldResolver.getFieldValues)({
|
119
94
|
entry,
|
120
|
-
fields:
|
95
|
+
fields: _pickEntryFieldValues.baseFields,
|
121
96
|
context: getCmsContext(),
|
122
97
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
123
98
|
});
|
124
99
|
return pickIdFromChangeRequest(values);
|
125
100
|
},
|
126
|
-
|
127
101
|
async deleteComment(params) {
|
128
102
|
const model = await getCommentModel();
|
129
|
-
security.disableAuthorization();
|
130
103
|
await cms.deleteEntry(model, params.id);
|
131
|
-
security.enableAuthorization();
|
132
104
|
return true;
|
133
105
|
}
|
134
|
-
|
135
106
|
};
|
136
107
|
};
|
108
|
+
exports.createCommentStorageOperations = createCommentStorageOperations;
|
137
109
|
|
138
|
-
|
110
|
+
//# sourceMappingURL=commentStorageOperations.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["pickIdFromChangeRequest","obj","rawValue","id","createCommentStorageOperations","cms","getCmsContext","
|
1
|
+
{"version":3,"names":["_fieldResolver","require","_pickEntryFieldValues","_error","_interopRequireDefault","_comment","pickIdFromChangeRequest","obj","rawValue","id","createCommentStorageOperations","cms","getCmsContext","getCommentModel","model","getModel","COMMENT_MODEL_ID","WebinyError","getComment","entry","getEntryById","getFieldValues","fields","baseFields","context","transformers","getTransformer","params","values","listComments","entries","meta","listLatestEntries","Promise","all","map","value","createComment","refModel","getChangeRequestModel","createEntry","data","changeRequest","modelId","updateComment","existingEntry","updateEntry","savedOn","Date","deleteComment","deleteEntry","exports"],"sources":["commentStorageOperations.ts"],"sourcesContent":["import type { ApwStorageOperations } from \"./types\";\nimport type { ApwCommentStorageOperations } from \"./types\";\nimport type { CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\nimport { baseFields } from \"~/utils/pickEntryFieldValues\";\n\nimport WebinyError from \"@webiny/error\";\nimport type { ApwComment } from \"~/types\";\nimport type { CmsEntryListParams } from \"@webiny/api-headless-cms/types\";\nimport { COMMENT_MODEL_ID } from \"~/storageOperations/models/comment.model\";\n\nconst pickIdFromChangeRequest = (obj: Record<string, any>): ApwComment => {\n const rawValue = obj[\"changeRequest\"];\n if (!rawValue) {\n return obj as unknown as ApwComment;\n }\n obj[\"changeRequest\"] = rawValue.id;\n return obj as unknown as ApwComment;\n};\n\nexport const createCommentStorageOperations = ({\n cms,\n getCmsContext\n}: CreateApwStorageOperationsParams): ApwCommentStorageOperations => {\n const getCommentModel = async () => {\n const model = await cms.getModel(COMMENT_MODEL_ID);\n\n if (!model) {\n throw new WebinyError(\n `Could not find \"${COMMENT_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getComment: ApwCommentStorageOperations[\"getComment\"] = async ({ id }) => {\n const model = await getCommentModel();\n const entry = await cms.getEntryById(model, id);\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n };\n return {\n getCommentModel,\n getComment: async params => {\n const values = await getComment(params);\n return pickIdFromChangeRequest(values);\n },\n async listComments(params) {\n const model = await getCommentModel();\n const [entries, meta] = await cms.listLatestEntries(\n model,\n params as CmsEntryListParams\n );\n const values = await Promise.all(\n entries.map(entry =>\n getFieldValues<ApwComment>({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n })\n )\n );\n const all = values.map(value => pickIdFromChangeRequest(value));\n return [all, meta];\n },\n async createComment(this: ApwStorageOperations, params) {\n const model = await getCommentModel();\n const refModel = await this.getChangeRequestModel();\n\n const entry = await cms.createEntry(model, {\n ...params.data,\n changeRequest: {\n id: params.data.changeRequest,\n modelId: refModel.modelId\n }\n });\n\n const values = await getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n return pickIdFromChangeRequest(values);\n },\n async updateComment(params) {\n const model = await getCommentModel();\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getComment({ id: params.id });\n\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data,\n savedOn: new Date()\n });\n\n const values = await getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n return pickIdFromChangeRequest(values);\n },\n async deleteComment(params) {\n const model = await getCommentModel();\n await cms.deleteEntry(model, params.id);\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,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;AAC8B,CAAC,KAAkC;EACjE,MAAMC,eAAe,GAAG,MAAAA,CAAA,KAAY;IAChC,MAAMC,KAAK,GAAG,MAAMH,GAAG,CAACI,QAAQ,CAACC,yBAAgB,CAAC;IAElD,IAAI,CAACF,KAAK,EAAE;MACR,MAAM,IAAIG,cAAW,CACjB,mBAAmBD,yB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AEC,gCAAU;QAClBC,OAAO,EAAEZ,aAAa,CAAC,CAAC;QACxBa,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACZ,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;MACF,OAAOR,uBAAuB,CAACsB,MAAM,CAAC;IAC1C,CAAC;IACD,MAAMqB,aAAaA,CAACtB,MAAM,EAAE;MACxB,MAAMb,KAAK,GAAG,MAAMD,eAAe,CAAC,CAAC;MACrC,MAAMF,GAAG,CAACuC,WAAW,CAACpC,KAAK,EAAEa,MAAM,CAAClB,EAAE,CAAC;MACvC,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC0C,OAAA,CAAAzC,8BAAA,GAAAA,8BAAA","ignoreList":[]}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { ApwContentReviewStorageOperations } from "./types";
|
2
|
-
import { CreateApwStorageOperationsParams } from "./
|
3
|
-
export declare const createContentReviewStorageOperations: ({ cms
|
1
|
+
import type { ApwContentReviewStorageOperations } from "./types";
|
2
|
+
import type { CreateApwStorageOperationsParams } from "./";
|
3
|
+
export declare const createContentReviewStorageOperations: ({ cms }: CreateApwStorageOperationsParams) => ApwContentReviewStorageOperations;
|