@webiny/api-apw 0.0.0-unstable.d7f521b032 → 0.0.0-unstable.de38392959
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApwChangeRequestNotification.js +4 -6
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.js +4 -6
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.js +4 -6
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.js +4 -6
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.js +5 -4
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/README.md +3 -3
- package/crud/createChangeRequestMethods.js +3 -1
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +3 -1
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +56 -30
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +3 -1
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.js +3 -1
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +6 -5
- package/crud/index.js.map +1 -1
- package/crud/utils.js +7 -6
- package/crud/utils.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/package.json +39 -46
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +5 -5
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +9 -6
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +3 -1
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +5 -4
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +16 -15
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.js +3 -1
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/cms/notifications/commentNotification.js +3 -1
- package/plugins/cms/notifications/commentNotification.js.map +1 -1
- package/plugins/cms/notifications/contentReviewNotification.js +3 -1
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/cms/notifications/contentUrl.js +3 -1
- package/plugins/cms/notifications/contentUrl.js.map +1 -1
- package/plugins/cms/triggerContentReview.js +6 -5
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +15 -13
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.d.ts +3 -2
- package/plugins/cms/utils.js +22 -14
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.js +3 -1
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +16 -12
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +41 -35
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +26 -16
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +15 -12
- 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 -12
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +4 -2
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +4 -2
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +3 -1
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +6 -4
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.js +3 -1
- package/plugins/hooks/initializeNotifications.js.map +1 -1
- package/plugins/hooks/listContentReviews.js +4 -2
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.js +3 -1
- package/plugins/hooks/notifications/appUrl.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +6 -9
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestUrl.js +3 -1
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +6 -9
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/commentUrl.js +3 -1
- package/plugins/hooks/notifications/commentUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +7 -10
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewUrl.js +3 -1
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentUrl.js +3 -1
- package/plugins/hooks/notifications/contentUrl.js.map +1 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +3 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +3 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +3 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.js +18 -15
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +3 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.js +3 -1
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js +3 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js +8 -6
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +22 -15
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +3 -1
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +3 -1
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +3 -1
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +5 -5
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js +3 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +3 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
- package/plugins/pageBuilder/index.js +3 -1
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +16 -12
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +3 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +3 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/commentNotification.js +3 -1
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +3 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentUrl.js +3 -1
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -1
- package/plugins/pageBuilder/triggerContentReview.js +3 -1
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +11 -6
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.d.ts +2 -2
- package/plugins/pageBuilder/utils.js +3 -1
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.d.ts +1 -1
- package/plugins/utils.js +6 -3
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +44 -30
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/index.js +30 -8
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +5 -4
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +6 -7
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -7
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.js +3 -1
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
- package/scheduler/handlers/scheduleAction/index.js +21 -14
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +19 -14
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +2 -3
- package/scheduler/handlers/utils.js +6 -7
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.js +3 -1
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.d.ts +12 -28
- package/scheduler/types.js +14 -17
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +60 -27
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +36 -30
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.d.ts +1 -1
- package/storageOperations/contentReviewStorageOperations.js +35 -27
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.d.ts +1 -7
- package/storageOperations/index.js +11 -16
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.d.ts +1 -2
- package/storageOperations/models/changeRequest.model.js +7 -7
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.d.ts +1 -2
- package/storageOperations/models/comment.model.js +7 -7
- 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 -11
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +6 -26
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.d.ts +1 -2
- package/storageOperations/models/reviewer.model.js +8 -8
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +3 -1
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.d.ts +1 -2
- package/storageOperations/models/workflow.model.js +19 -19
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.d.ts +1 -1
- package/storageOperations/reviewerStorageOperations.js +38 -35
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/types.js +3 -1
- package/storageOperations/workflowStorageOperations.js +41 -31
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +19 -17
- package/types.js +126 -28
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.js +3 -1
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js +3 -1
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.js +7 -7
- 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 +3 -1
- package/utils/resolve.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.d.ts +0 -8
- package/storageOperations/models/contentModelPluginFactory.js +0 -19
- package/storageOperations/models/contentModelPluginFactory.js.map +0 -1
package/scheduler/types.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Context } from "@webiny/api/types";
|
2
2
|
import { SecurityIdentity, SecurityPermission } from "@webiny/api-security/types";
|
3
|
-
import {
|
4
|
-
import { Tenant } from "@webiny/api-tenancy/types";
|
5
|
-
import {
|
3
|
+
import { I18NContext, I18NLocale } from "@webiny/api-i18n/types";
|
4
|
+
import { TenancyContext, Tenant } from "@webiny/api-tenancy/types";
|
5
|
+
import { ApwIdentity } from "../types";
|
6
6
|
export interface ListWhere {
|
7
7
|
/**
|
8
8
|
* Fields.
|
@@ -29,25 +29,6 @@ export interface ListParams {
|
|
29
29
|
limit?: number;
|
30
30
|
after?: string;
|
31
31
|
}
|
32
|
-
/**
|
33
|
-
* A interface describing the reference to a user that created some data in the database.
|
34
|
-
*
|
35
|
-
* @category General
|
36
|
-
*/
|
37
|
-
export interface CreatedBy {
|
38
|
-
/**
|
39
|
-
* ID if the user.
|
40
|
-
*/
|
41
|
-
id: string;
|
42
|
-
/**
|
43
|
-
* Full name of the user.
|
44
|
-
*/
|
45
|
-
displayName: string | null;
|
46
|
-
/**
|
47
|
-
* Type of the user (admin, user)
|
48
|
-
*/
|
49
|
-
type: string;
|
50
|
-
}
|
51
32
|
export interface ListMeta {
|
52
33
|
/**
|
53
34
|
* A cursor for pagination.
|
@@ -69,8 +50,11 @@ export declare enum ApwContentTypes {
|
|
69
50
|
export interface BaseFields {
|
70
51
|
id: string;
|
71
52
|
createdOn: string;
|
72
|
-
|
73
|
-
|
53
|
+
modifiedOn: string | null;
|
54
|
+
savedOn: string;
|
55
|
+
createdBy: ApwIdentity;
|
56
|
+
modifiedBy: ApwIdentity | null;
|
57
|
+
savedBy: ApwIdentity;
|
74
58
|
tenant: string;
|
75
59
|
locale: string;
|
76
60
|
}
|
@@ -99,13 +83,13 @@ interface BaseApwCrud<TEntry, TCreateEntryParams, TUpdateEntryParams> {
|
|
99
83
|
get(id: string): Promise<TEntry | null>;
|
100
84
|
create(data: TCreateEntryParams): Promise<TEntry>;
|
101
85
|
update(id: string, data: TUpdateEntryParams): Promise<TEntry>;
|
102
|
-
delete(id: string): Promise<
|
86
|
+
delete(id: string): Promise<boolean>;
|
103
87
|
}
|
104
88
|
export interface ApwScheduleActionCrud extends BaseApwCrud<ApwScheduleAction, ApwScheduleActionData, ApwScheduleActionData> {
|
105
89
|
list(params: ListParams): Promise<[ApwScheduleAction[], ListMeta]>;
|
106
90
|
getCurrentTask(): Promise<ApwScheduleAction | null>;
|
107
91
|
updateCurrentTask(item: ApwScheduleAction): Promise<ApwScheduleAction>;
|
108
|
-
deleteCurrentTask(): Promise<
|
92
|
+
deleteCurrentTask(): Promise<boolean>;
|
109
93
|
}
|
110
94
|
export interface ScheduleActionContext extends Context, I18NContext, TenancyContext {
|
111
95
|
scheduleAction: ApwScheduleActionCrud;
|
@@ -160,10 +144,10 @@ export interface ApwScheduleActionStorageOperations {
|
|
160
144
|
list(params: StorageOperationsListScheduleActionsParams): Promise<StorageOperationsListScheduleActionsResponse>;
|
161
145
|
create(params: StorageOperationsCreateScheduleActionParams): Promise<ApwScheduleAction>;
|
162
146
|
update(params: StorageOperationsUpdateScheduleActionParams): Promise<ApwScheduleAction>;
|
163
|
-
delete(params: StorageOperationsDeleteScheduleActionParams): Promise<
|
147
|
+
delete(params: StorageOperationsDeleteScheduleActionParams): Promise<boolean>;
|
164
148
|
getCurrentTask(params: StorageOperationsGetCurrentTaskParams): Promise<ApwScheduleAction | null>;
|
165
149
|
updateCurrentTask(params: StorageOperationsUpdateCurrentTaskParams): Promise<ApwScheduleAction>;
|
166
|
-
deleteCurrentTask(params: StorageOperationsDeleteCurrentTaskParams): Promise<
|
150
|
+
deleteCurrentTask(params: StorageOperationsDeleteCurrentTaskParams): Promise<boolean>;
|
167
151
|
}
|
168
152
|
export interface CreateApwContextParams {
|
169
153
|
storageOperations: ApwScheduleActionStorageOperations;
|
package/scheduler/types.js
CHANGED
@@ -4,25 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.InvocationTypes = exports.ApwScheduleActionTypes = exports.ApwContentTypes = void 0;
|
7
|
-
|
8
|
-
* A interface describing the reference to a user that created some data in the database.
|
9
|
-
*
|
10
|
-
* @category General
|
11
|
-
*/
|
12
|
-
let ApwContentTypes;
|
13
|
-
exports.ApwContentTypes = ApwContentTypes;
|
14
|
-
(function (ApwContentTypes) {
|
7
|
+
let ApwContentTypes = /*#__PURE__*/function (ApwContentTypes) {
|
15
8
|
ApwContentTypes["PAGE"] = "page";
|
16
9
|
ApwContentTypes["CMS_ENTRY"] = "cms_entry";
|
17
|
-
|
18
|
-
|
19
|
-
exports.
|
20
|
-
|
10
|
+
return ApwContentTypes;
|
11
|
+
}({});
|
12
|
+
exports.ApwContentTypes = ApwContentTypes;
|
13
|
+
let ApwScheduleActionTypes = /*#__PURE__*/function (ApwScheduleActionTypes) {
|
21
14
|
ApwScheduleActionTypes["PUBLISH"] = "publish";
|
22
15
|
ApwScheduleActionTypes["UNPUBLISH"] = "unpublish";
|
23
|
-
|
24
|
-
|
25
|
-
exports.
|
26
|
-
|
16
|
+
return ApwScheduleActionTypes;
|
17
|
+
}({});
|
18
|
+
exports.ApwScheduleActionTypes = ApwScheduleActionTypes;
|
19
|
+
let InvocationTypes = /*#__PURE__*/function (InvocationTypes) {
|
27
20
|
InvocationTypes["SCHEDULED"] = "scheduled";
|
28
|
-
|
21
|
+
return InvocationTypes;
|
22
|
+
}({});
|
23
|
+
exports.InvocationTypes = InvocationTypes;
|
24
|
+
|
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"}
|
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
6
6
|
});
|
7
7
|
exports.createChangeRequestStorageOperations = void 0;
|
8
|
-
var
|
9
|
-
var _index = require("./index");
|
8
|
+
var _pickEntryFieldValues = require("../utils/pickEntryFieldValues");
|
10
9
|
var _fieldResolver = require("../utils/fieldResolver");
|
11
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
12
11
|
const createChangeRequestStorageOperations = params => {
|
@@ -16,9 +15,9 @@ const createChangeRequestStorageOperations = params => {
|
|
16
15
|
security
|
17
16
|
} = params;
|
18
17
|
const getChangeRequestModel = async () => {
|
19
|
-
security.
|
20
|
-
|
21
|
-
|
18
|
+
const model = await security.withoutAuthorization(async () => {
|
19
|
+
return cms.getModel("apwChangeRequestModelDefinition");
|
20
|
+
});
|
22
21
|
if (!model) {
|
23
22
|
throw new _error.default("Could not find `apwChangeRequestModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
|
24
23
|
}
|
@@ -28,12 +27,12 @@ const createChangeRequestStorageOperations = params => {
|
|
28
27
|
id
|
29
28
|
}) => {
|
30
29
|
const model = await getChangeRequestModel();
|
31
|
-
security.
|
32
|
-
|
33
|
-
|
30
|
+
const entry = await security.withoutAuthorization(async () => {
|
31
|
+
return cms.getEntryById(model, id);
|
32
|
+
});
|
34
33
|
return (0, _fieldResolver.getFieldValues)({
|
35
34
|
entry,
|
36
|
-
fields:
|
35
|
+
fields: _pickEntryFieldValues.baseFields,
|
37
36
|
context: getCmsContext(),
|
38
37
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
39
38
|
});
|
@@ -43,15 +42,18 @@ const createChangeRequestStorageOperations = params => {
|
|
43
42
|
getChangeRequest,
|
44
43
|
async listChangeRequests(params) {
|
45
44
|
const model = await getChangeRequestModel();
|
46
|
-
security.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
const [entries, meta] = await security.withoutAuthorization(async () => {
|
46
|
+
return cms.listLatestEntries(model, {
|
47
|
+
...params,
|
48
|
+
where: {
|
49
|
+
...params.where
|
50
|
+
}
|
51
|
+
});
|
52
|
+
});
|
51
53
|
try {
|
52
54
|
const all = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
53
55
|
entry,
|
54
|
-
fields:
|
56
|
+
fields: _pickEntryFieldValues.baseFields,
|
55
57
|
context: getCmsContext(),
|
56
58
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
57
59
|
})));
|
@@ -62,18 +64,19 @@ const createChangeRequestStorageOperations = params => {
|
|
62
64
|
},
|
63
65
|
async createChangeRequest(params) {
|
64
66
|
const model = await getChangeRequestModel();
|
65
|
-
security.
|
66
|
-
|
67
|
-
|
67
|
+
const entry = await security.withoutAuthorization(async () => {
|
68
|
+
return cms.createEntry(model, params.data);
|
69
|
+
});
|
68
70
|
return (0, _fieldResolver.getFieldValues)({
|
69
71
|
entry,
|
70
|
-
fields:
|
72
|
+
fields: _pickEntryFieldValues.baseFields,
|
71
73
|
context: getCmsContext(),
|
72
74
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
73
75
|
});
|
74
76
|
},
|
75
77
|
async updateChangeRequest(params) {
|
76
78
|
const model = await getChangeRequestModel();
|
79
|
+
|
77
80
|
/**
|
78
81
|
* We're fetching the existing entry here because we're not accepting "app" field as input,
|
79
82
|
* but, we still need to retain its value after the "update" operation.
|
@@ -81,23 +84,53 @@ const createChangeRequestStorageOperations = params => {
|
|
81
84
|
const existingEntry = await getChangeRequest({
|
82
85
|
id: params.id
|
83
86
|
});
|
84
|
-
|
85
|
-
|
86
|
-
|
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
|
+
});
|
87
101
|
return (0, _fieldResolver.getFieldValues)({
|
88
102
|
entry,
|
89
|
-
fields:
|
103
|
+
fields: _pickEntryFieldValues.baseFields,
|
90
104
|
context: getCmsContext(),
|
91
105
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
92
106
|
});
|
93
107
|
},
|
94
108
|
async deleteChangeRequest(params) {
|
95
109
|
const model = await getChangeRequestModel();
|
96
|
-
security.
|
97
|
-
|
98
|
-
|
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
|
+
});
|
99
130
|
return true;
|
100
131
|
}
|
101
132
|
};
|
102
133
|
};
|
103
|
-
exports.createChangeRequestStorageOperations = createChangeRequestStorageOperations;
|
134
|
+
exports.createChangeRequestStorageOperations = createChangeRequestStorageOperations;
|
135
|
+
|
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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,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"}
|
@@ -5,9 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
6
6
|
});
|
7
7
|
exports.createCommentStorageOperations = void 0;
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
9
|
-
var _index = require("./index");
|
10
8
|
var _fieldResolver = require("../utils/fieldResolver");
|
9
|
+
var _pickEntryFieldValues = require("../utils/pickEntryFieldValues");
|
11
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
12
11
|
var _comment = require("./models/comment.model");
|
13
12
|
const pickIdFromChangeRequest = obj => {
|
@@ -24,9 +23,9 @@ const createCommentStorageOperations = ({
|
|
24
23
|
security
|
25
24
|
}) => {
|
26
25
|
const getCommentModel = async () => {
|
27
|
-
security.
|
28
|
-
|
29
|
-
|
26
|
+
const model = await security.withoutAuthorization(async () => {
|
27
|
+
return cms.getModel(_comment.COMMENT_MODEL_ID);
|
28
|
+
});
|
30
29
|
if (!model) {
|
31
30
|
throw new _error.default(`Could not find "${_comment.COMMENT_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
32
31
|
}
|
@@ -36,12 +35,12 @@ const createCommentStorageOperations = ({
|
|
36
35
|
id
|
37
36
|
}) => {
|
38
37
|
const model = await getCommentModel();
|
39
|
-
security.
|
40
|
-
|
41
|
-
|
38
|
+
const entry = await security.withoutAuthorization(async () => {
|
39
|
+
return cms.getEntryById(model, id);
|
40
|
+
});
|
42
41
|
return (0, _fieldResolver.getFieldValues)({
|
43
42
|
entry,
|
44
|
-
fields:
|
43
|
+
fields: _pickEntryFieldValues.baseFields,
|
45
44
|
context: getCmsContext(),
|
46
45
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
47
46
|
});
|
@@ -54,12 +53,12 @@ const createCommentStorageOperations = ({
|
|
54
53
|
},
|
55
54
|
async listComments(params) {
|
56
55
|
const model = await getCommentModel();
|
57
|
-
security.
|
58
|
-
|
59
|
-
|
56
|
+
const [entries, meta] = await security.withoutAuthorization(async () => {
|
57
|
+
return cms.listLatestEntries(model, params);
|
58
|
+
});
|
60
59
|
const values = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
61
60
|
entry,
|
62
|
-
fields:
|
61
|
+
fields: _pickEntryFieldValues.baseFields,
|
63
62
|
context: getCmsContext(),
|
64
63
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
65
64
|
})));
|
@@ -69,17 +68,18 @@ const createCommentStorageOperations = ({
|
|
69
68
|
async createComment(params) {
|
70
69
|
const model = await getCommentModel();
|
71
70
|
const refModel = await this.getChangeRequestModel();
|
72
|
-
security.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
+
});
|
80
80
|
const values = await (0, _fieldResolver.getFieldValues)({
|
81
81
|
entry,
|
82
|
-
fields:
|
82
|
+
fields: _pickEntryFieldValues.baseFields,
|
83
83
|
context: getCmsContext(),
|
84
84
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
85
85
|
});
|
@@ -94,12 +94,16 @@ const createCommentStorageOperations = ({
|
|
94
94
|
const existingEntry = await getComment({
|
95
95
|
id: params.id
|
96
96
|
});
|
97
|
-
security.
|
98
|
-
|
99
|
-
|
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
|
+
});
|
100
104
|
const values = await (0, _fieldResolver.getFieldValues)({
|
101
105
|
entry,
|
102
|
-
fields:
|
106
|
+
fields: _pickEntryFieldValues.baseFields,
|
103
107
|
context: getCmsContext(),
|
104
108
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
105
109
|
});
|
@@ -107,11 +111,13 @@ const createCommentStorageOperations = ({
|
|
107
111
|
},
|
108
112
|
async deleteComment(params) {
|
109
113
|
const model = await getCommentModel();
|
110
|
-
security.
|
111
|
-
|
112
|
-
|
114
|
+
await security.withoutAuthorization(async () => {
|
115
|
+
return cms.deleteEntry(model, params.id);
|
116
|
+
});
|
113
117
|
return true;
|
114
118
|
}
|
115
119
|
};
|
116
120
|
};
|
117
|
-
exports.createCommentStorageOperations = createCommentStorageOperations;
|
121
|
+
exports.createCommentStorageOperations = createCommentStorageOperations;
|
122
|
+
|
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;AAC8B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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;
|