@webiny/api-apw 0.0.0-unstable.ecd8734205 → 0.0.0-unstable.f9f12f52a0
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 +4 -6
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.d.ts +1 -1
- package/ApwCommentNotification.js +4 -6
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.d.ts +1 -1
- package/ApwContentReviewNotification.js +4 -6
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.d.ts +1 -1
- package/ApwContentUrlPlugin.js +4 -6
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.d.ts +1 -1
- package/ContentApwSettingsPlugin.js +5 -4
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/README.md +3 -3
- package/crud/createChangeRequestMethods.d.ts +1 -1
- package/crud/createChangeRequestMethods.js +3 -1
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.d.ts +1 -1
- package/crud/createCommentMethods.js +3 -1
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.d.ts +2 -2
- package/crud/createContentReviewMethods.js +57 -32
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.d.ts +1 -1
- package/crud/createReviewerMethods.js +3 -1
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.d.ts +1 -1
- package/crud/createWorkflowMethods.js +3 -1
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.d.ts +1 -1
- package/crud/index.js +6 -5
- package/crud/index.js.map +1 -1
- package/crud/utils.d.ts +2 -2
- package/crud/utils.js +8 -8
- package/crud/utils.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +7 -6
- package/index.js.map +1 -1
- package/package.json +32 -50
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +1 -1
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +5 -5
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.d.ts +2 -2
- package/plugins/cms/apwEntryPlugins.js +19 -7
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.d.ts +4 -4
- package/plugins/cms/index.js +3 -1
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.d.ts +2 -2
- package/plugins/cms/linkContentReviewToEntry.js +5 -4
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.d.ts +2 -2
- package/plugins/cms/linkWorkflowToEntry.js +17 -16
- 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.d.ts +2 -2
- package/plugins/cms/triggerContentReview.js +6 -5
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.d.ts +3 -3
- package/plugins/cms/updateContentReviewStatus.js +15 -13
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.d.ts +5 -4
- package/plugins/cms/utils.js +19 -13
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.d.ts +3 -3
- package/plugins/context.js +5 -14
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.d.ts +1 -1
- package/plugins/graphql/changeRequest.gql.js +16 -13
- 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 -36
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.d.ts +1 -1
- package/plugins/graphql/contentReview.gql.js +26 -17
- 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 -13
- 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 -13
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.d.ts +1 -1
- package/plugins/graphql.js +4 -2
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.d.ts +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +4 -2
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.d.ts +1 -1
- package/plugins/hooks/index.js +3 -1
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.d.ts +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +6 -4
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +1 -1
- package/plugins/hooks/initializeNotifications.js +3 -1
- package/plugins/hooks/initializeNotifications.js.map +1 -1
- package/plugins/hooks/listContentReviews.d.ts +3 -3
- package/plugins/hooks/listContentReviews.js +4 -2
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +8 -11
- 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.d.ts +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +8 -11
- 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.d.ts +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +9 -12
- 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.d.ts +2 -2
- package/plugins/hooks/notifications/contentUrl.js +3 -1
- 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 +3 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +3 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +3 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.d.ts +1 -1
- package/plugins/hooks/notifications/reviewers.js +18 -15
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +3 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.js +3 -1
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js +3 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.d.ts +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js +8 -6
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.d.ts +1 -1
- package/plugins/hooks/updateTotalComments.js +22 -15
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.d.ts +1 -1
- package/plugins/hooks/validateChangeRequest.js +3 -1
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.d.ts +1 -1
- package/plugins/hooks/validateComment.js +3 -1
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.d.ts +1 -1
- package/plugins/hooks/validateContentReview.js +3 -1
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/utils.d.ts +7 -6
- package/plugins/utils.js +12 -8
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.d.ts +1 -1
- package/scheduler/createScheduleActionMethods.js +105 -66
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +2 -2
- package/scheduler/handlers/executeAction/index.js +11 -7
- 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.d.ts +2 -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.d.ts +3 -2
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -7
- 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 +3 -1
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +2 -2
- package/scheduler/handlers/scheduleAction/index.js +20 -15
- 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 +17 -14
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +2 -3
- package/scheduler/handlers/utils.js +20 -13
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.d.ts +1 -1
- package/scheduler/index.js +3 -1
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.d.ts +20 -36
- package/scheduler/types.js +11 -17
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.d.ts +2 -2
- package/storageOperations/changeRequestStorageOperations.js +44 -23
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.d.ts +3 -3
- package/storageOperations/commentStorageOperations.js +17 -24
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.d.ts +3 -3
- package/storageOperations/contentReviewStorageOperations.js +20 -25
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.d.ts +3 -9
- 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 +10 -11
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.d.ts +1 -2
- package/storageOperations/models/comment.model.js +10 -11
- 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 -15
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.d.ts +1 -1
- package/storageOperations/models/index.js +11 -31
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.d.ts +1 -2
- package/storageOperations/models/reviewer.model.js +11 -12
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.d.ts +2 -2
- package/storageOperations/models/utils.js +3 -1
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.d.ts +2 -3
- package/storageOperations/models/workflow.model.js +22 -23
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.d.ts +3 -3
- package/storageOperations/reviewerStorageOperations.js +24 -34
- 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 +25 -28
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +49 -64
- package/types.js +121 -29
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.d.ts +2 -2
- 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.d.ts +2 -2
- package/utils/fieldResolver.js +7 -7
- 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 +3 -1
- package/utils/resolve.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.d.ts +0 -2
- package/plugins/hooks/notifications/appUrl.js +0 -18
- package/plugins/hooks/notifications/appUrl.js.map +0 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +0 -9
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -36
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +0 -1
- package/plugins/pageBuilder/apwContentPagePlugins.d.ts +0 -3
- package/plugins/pageBuilder/apwContentPagePlugins.js +0 -26
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +0 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +0 -3
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +0 -20
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +0 -1
- package/plugins/pageBuilder/index.d.ts +0 -11
- package/plugins/pageBuilder/index.js +0 -42
- package/plugins/pageBuilder/index.js.map +0 -1
- package/plugins/pageBuilder/linkContentReviewToPage.d.ts +0 -8
- package/plugins/pageBuilder/linkContentReviewToPage.js +0 -89
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +0 -1
- package/plugins/pageBuilder/linkWorkflowToPage.d.ts +0 -8
- package/plugins/pageBuilder/linkWorkflowToPage.js +0 -164
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +0 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +0 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +0 -31
- 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 -31
- 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 -31
- 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 -47
- package/plugins/pageBuilder/notifications/contentUrl.js.map +0 -1
- package/plugins/pageBuilder/triggerContentReview.d.ts +0 -8
- package/plugins/pageBuilder/triggerContentReview.js +0 -39
- package/plugins/pageBuilder/triggerContentReview.js.map +0 -1
- package/plugins/pageBuilder/updateContentReviewStatus.d.ts +0 -10
- package/plugins/pageBuilder/updateContentReviewStatus.js +0 -67
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +0 -1
- package/plugins/pageBuilder/utils.d.ts +0 -22
- package/plugins/pageBuilder/utils.js +0 -150
- package/plugins/pageBuilder/utils.js.map +0 -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
|
-
import { Context } from "@webiny/api/types";
|
2
|
-
import { SecurityIdentity, SecurityPermission } from "@webiny/api-security/types";
|
3
|
-
import {
|
4
|
-
import { Tenant } from "@webiny/api-tenancy/types";
|
5
|
-
import {
|
1
|
+
import type { Context } from "@webiny/api/types";
|
2
|
+
import type { SecurityIdentity, SecurityPermission } from "@webiny/api-security/types";
|
3
|
+
import type { I18NContext, I18NLocale } from "@webiny/api-i18n/types";
|
4
|
+
import type { TenancyContext, Tenant } from "@webiny/api-tenancy/types";
|
5
|
+
import type { 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;
|
@@ -139,31 +123,31 @@ export interface ApwScheduleActionListParams extends ListParams {
|
|
139
123
|
locale: string;
|
140
124
|
};
|
141
125
|
}
|
142
|
-
export
|
143
|
-
export
|
144
|
-
export
|
145
|
-
export
|
126
|
+
export type StorageOperationsGetScheduleActionParams = StorageOperationsGetParams;
|
127
|
+
export type StorageOperationsDeleteScheduleActionParams = StorageOperationsDeleteParams;
|
128
|
+
export type StorageOperationsListScheduleActionsParams = ApwScheduleActionListParams;
|
129
|
+
export type StorageOperationsCreateScheduleActionParams = CreateApwScheduleActionParams;
|
146
130
|
export interface StorageOperationsUpdateScheduleActionParams {
|
147
131
|
item: ApwScheduleAction;
|
148
132
|
input: ApwScheduleActionData;
|
149
133
|
}
|
150
|
-
export
|
134
|
+
export type StorageOperationsListScheduleActionsResponse = [ApwScheduleAction[], ListMeta];
|
151
135
|
export interface StorageOperationsUpdateCurrentTaskParams {
|
152
136
|
item: ApwScheduleAction;
|
153
137
|
}
|
154
138
|
export interface StorageOperationsGetCurrentTaskParams {
|
155
139
|
where: Pick<StorageOperationsGetParams["where"], "tenant" | "locale">;
|
156
140
|
}
|
157
|
-
export
|
141
|
+
export type StorageOperationsDeleteCurrentTaskParams = Pick<StorageOperationsDeleteParams, "tenant" | "locale">;
|
158
142
|
export interface ApwScheduleActionStorageOperations {
|
159
143
|
get(params: StorageOperationsGetScheduleActionParams): Promise<ApwScheduleAction | null>;
|
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,19 @@ 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 = exports.ApwContentTypes = /*#__PURE__*/function (ApwContentTypes) {
|
15
8
|
ApwContentTypes["PAGE"] = "page";
|
16
9
|
ApwContentTypes["CMS_ENTRY"] = "cms_entry";
|
17
|
-
|
18
|
-
|
19
|
-
exports.ApwScheduleActionTypes = ApwScheduleActionTypes
|
20
|
-
(function (ApwScheduleActionTypes) {
|
10
|
+
return ApwContentTypes;
|
11
|
+
}({});
|
12
|
+
let ApwScheduleActionTypes = exports.ApwScheduleActionTypes = /*#__PURE__*/function (ApwScheduleActionTypes) {
|
21
13
|
ApwScheduleActionTypes["PUBLISH"] = "publish";
|
22
14
|
ApwScheduleActionTypes["UNPUBLISH"] = "unpublish";
|
23
|
-
|
24
|
-
|
25
|
-
exports.InvocationTypes = InvocationTypes
|
26
|
-
(function (InvocationTypes) {
|
15
|
+
return ApwScheduleActionTypes;
|
16
|
+
}({});
|
17
|
+
let InvocationTypes = exports.InvocationTypes = /*#__PURE__*/function (InvocationTypes) {
|
27
18
|
InvocationTypes["SCHEDULED"] = "scheduled";
|
28
|
-
|
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;
|
@@ -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,7 @@ const createChangeRequestStorageOperations = params => {
|
|
16
15
|
security
|
17
16
|
} = params;
|
18
17
|
const getChangeRequestModel = async () => {
|
19
|
-
security.disableAuthorization();
|
20
18
|
const model = await cms.getModel("apwChangeRequestModelDefinition");
|
21
|
-
security.enableAuthorization();
|
22
19
|
if (!model) {
|
23
20
|
throw new _error.default("Could not find `apwChangeRequestModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
|
24
21
|
}
|
@@ -28,12 +25,10 @@ const createChangeRequestStorageOperations = params => {
|
|
28
25
|
id
|
29
26
|
}) => {
|
30
27
|
const model = await getChangeRequestModel();
|
31
|
-
security.disableAuthorization();
|
32
28
|
const entry = await cms.getEntryById(model, id);
|
33
|
-
security.enableAuthorization();
|
34
29
|
return (0, _fieldResolver.getFieldValues)({
|
35
30
|
entry,
|
36
|
-
fields:
|
31
|
+
fields: _pickEntryFieldValues.baseFields,
|
37
32
|
context: getCmsContext(),
|
38
33
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
39
34
|
});
|
@@ -43,15 +38,16 @@ const createChangeRequestStorageOperations = params => {
|
|
43
38
|
getChangeRequest,
|
44
39
|
async listChangeRequests(params) {
|
45
40
|
const model = await getChangeRequestModel();
|
46
|
-
|
47
|
-
|
48
|
-
where:
|
49
|
-
|
50
|
-
|
41
|
+
const [entries, meta] = await cms.listLatestEntries(model, {
|
42
|
+
...params,
|
43
|
+
where: {
|
44
|
+
...params.where
|
45
|
+
}
|
46
|
+
});
|
51
47
|
try {
|
52
48
|
const all = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
53
49
|
entry,
|
54
|
-
fields:
|
50
|
+
fields: _pickEntryFieldValues.baseFields,
|
55
51
|
context: getCmsContext(),
|
56
52
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
57
53
|
})));
|
@@ -62,18 +58,17 @@ const createChangeRequestStorageOperations = params => {
|
|
62
58
|
},
|
63
59
|
async createChangeRequest(params) {
|
64
60
|
const model = await getChangeRequestModel();
|
65
|
-
security.disableAuthorization();
|
66
61
|
const entry = await cms.createEntry(model, params.data);
|
67
|
-
security.enableAuthorization();
|
68
62
|
return (0, _fieldResolver.getFieldValues)({
|
69
63
|
entry,
|
70
|
-
fields:
|
64
|
+
fields: _pickEntryFieldValues.baseFields,
|
71
65
|
context: getCmsContext(),
|
72
66
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
73
67
|
});
|
74
68
|
},
|
75
69
|
async updateChangeRequest(params) {
|
76
70
|
const model = await getChangeRequestModel();
|
71
|
+
|
77
72
|
/**
|
78
73
|
* We're fetching the existing entry here because we're not accepting "app" field as input,
|
79
74
|
* but, we still need to retain its value after the "update" operation.
|
@@ -81,23 +76,49 @@ const createChangeRequestStorageOperations = params => {
|
|
81
76
|
const existingEntry = await getChangeRequest({
|
82
77
|
id: params.id
|
83
78
|
});
|
84
|
-
|
85
|
-
|
86
|
-
|
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
|
+
});
|
87
91
|
return (0, _fieldResolver.getFieldValues)({
|
88
92
|
entry,
|
89
|
-
fields:
|
93
|
+
fields: _pickEntryFieldValues.baseFields,
|
90
94
|
context: getCmsContext(),
|
91
95
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
92
96
|
});
|
93
97
|
},
|
94
98
|
async deleteChangeRequest(params) {
|
95
99
|
const model = await getChangeRequestModel();
|
96
|
-
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
|
+
}
|
97
117
|
await cms.deleteEntry(model, params.id);
|
98
|
-
security.enableAuthorization();
|
99
118
|
return true;
|
100
119
|
}
|
101
120
|
};
|
102
121
|
};
|
103
|
-
exports.createChangeRequestStorageOperations = createChangeRequestStorageOperations;
|
122
|
+
exports.createChangeRequestStorageOperations = createChangeRequestStorageOperations;
|
123
|
+
|
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_REQU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-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;
|
@@ -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 => {
|
@@ -20,13 +19,10 @@ const pickIdFromChangeRequest = obj => {
|
|
20
19
|
};
|
21
20
|
const createCommentStorageOperations = ({
|
22
21
|
cms,
|
23
|
-
getCmsContext
|
24
|
-
security
|
22
|
+
getCmsContext
|
25
23
|
}) => {
|
26
24
|
const getCommentModel = async () => {
|
27
|
-
security.disableAuthorization();
|
28
25
|
const model = await cms.getModel(_comment.COMMENT_MODEL_ID);
|
29
|
-
security.enableAuthorization();
|
30
26
|
if (!model) {
|
31
27
|
throw new _error.default(`Could not find "${_comment.COMMENT_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
32
28
|
}
|
@@ -36,12 +32,10 @@ const createCommentStorageOperations = ({
|
|
36
32
|
id
|
37
33
|
}) => {
|
38
34
|
const model = await getCommentModel();
|
39
|
-
security.disableAuthorization();
|
40
35
|
const entry = await cms.getEntryById(model, id);
|
41
|
-
security.enableAuthorization();
|
42
36
|
return (0, _fieldResolver.getFieldValues)({
|
43
37
|
entry,
|
44
|
-
fields:
|
38
|
+
fields: _pickEntryFieldValues.baseFields,
|
45
39
|
context: getCmsContext(),
|
46
40
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
47
41
|
});
|
@@ -54,12 +48,10 @@ const createCommentStorageOperations = ({
|
|
54
48
|
},
|
55
49
|
async listComments(params) {
|
56
50
|
const model = await getCommentModel();
|
57
|
-
security.disableAuthorization();
|
58
51
|
const [entries, meta] = await cms.listLatestEntries(model, params);
|
59
|
-
security.enableAuthorization();
|
60
52
|
const values = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
|
61
53
|
entry,
|
62
|
-
fields:
|
54
|
+
fields: _pickEntryFieldValues.baseFields,
|
63
55
|
context: getCmsContext(),
|
64
56
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
65
57
|
})));
|
@@ -69,17 +61,16 @@ const createCommentStorageOperations = ({
|
|
69
61
|
async createComment(params) {
|
70
62
|
const model = await getCommentModel();
|
71
63
|
const refModel = await this.getChangeRequestModel();
|
72
|
-
|
73
|
-
|
64
|
+
const entry = await cms.createEntry(model, {
|
65
|
+
...params.data,
|
74
66
|
changeRequest: {
|
75
67
|
id: params.data.changeRequest,
|
76
68
|
modelId: refModel.modelId
|
77
69
|
}
|
78
|
-
})
|
79
|
-
security.enableAuthorization();
|
70
|
+
});
|
80
71
|
const values = await (0, _fieldResolver.getFieldValues)({
|
81
72
|
entry,
|
82
|
-
fields:
|
73
|
+
fields: _pickEntryFieldValues.baseFields,
|
83
74
|
context: getCmsContext(),
|
84
75
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
85
76
|
});
|
@@ -94,12 +85,14 @@ const createCommentStorageOperations = ({
|
|
94
85
|
const existingEntry = await getComment({
|
95
86
|
id: params.id
|
96
87
|
});
|
97
|
-
|
98
|
-
|
99
|
-
|
88
|
+
const entry = await cms.updateEntry(model, params.id, {
|
89
|
+
...existingEntry,
|
90
|
+
...params.data,
|
91
|
+
savedOn: new Date()
|
92
|
+
});
|
100
93
|
const values = await (0, _fieldResolver.getFieldValues)({
|
101
94
|
entry,
|
102
|
-
fields:
|
95
|
+
fields: _pickEntryFieldValues.baseFields,
|
103
96
|
context: getCmsContext(),
|
104
97
|
transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
|
105
98
|
});
|
@@ -107,11 +100,11 @@ const createCommentStorageOperations = ({
|
|
107
100
|
},
|
108
101
|
async deleteComment(params) {
|
109
102
|
const model = await getCommentModel();
|
110
|
-
security.disableAuthorization();
|
111
103
|
await cms.deleteEntry(model, params.id);
|
112
|
-
security.enableAuthorization();
|
113
104
|
return true;
|
114
105
|
}
|
115
106
|
};
|
116
107
|
};
|
117
|
-
exports.createCommentStorageOperations = createCommentStorageOperations;
|
108
|
+
exports.createCommentStorageOperations = createCommentStorageOperations;
|
109
|
+
|
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,yBAAgB,UAAU,EAC7C,uBACJ,CAAC;IACL;IACA,OAAOF,KAAK;EAChB,CAAC;EACD,MAAMI,UAAqD,GAAG,MAAAA,CAAO;IAAET;EAAG,CAAC,KAAK;IAC5E,MAAMK,KAAK,GAAG,MAAM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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;
|
@@ -5,18 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
6
6
|
});
|
7
7
|
exports.createContentReviewStorageOperations = void 0;
|
8
|
-
var
|
9
|
-
var _index = require("./index");
|
8
|
+
var _pickEntryFieldValues = require("../utils/pickEntryFieldValues");
|
10
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
11
10
|
var _contentReview = require("./models/contentReview.model");
|
12
11
|
const createContentReviewStorageOperations = ({
|
13
|
-
cms
|
14
|
-
security
|
12
|
+
cms
|
15
13
|
}) => {
|
16
14
|
const getContentReviewModel = async () => {
|
17
|
-
security.disableAuthorization();
|
18
15
|
const model = await cms.getModel(_contentReview.CONTENT_REVIEW_MODEL_ID);
|
19
|
-
security.enableAuthorization();
|
20
16
|
if (!model) {
|
21
17
|
throw new _error.default(`Could not find "${_contentReview.CONTENT_REVIEW_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
22
18
|
}
|
@@ -26,29 +22,26 @@ const createContentReviewStorageOperations = ({
|
|
26
22
|
id
|
27
23
|
}) => {
|
28
24
|
const model = await getContentReviewModel();
|
29
|
-
security.disableAuthorization();
|
30
25
|
const entry = await cms.getEntryById(model, id);
|
31
|
-
|
32
|
-
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
26
|
+
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
33
27
|
};
|
34
28
|
return {
|
35
29
|
getContentReviewModel,
|
36
30
|
getContentReview,
|
37
31
|
async listContentReviews(params) {
|
38
32
|
const model = await getContentReviewModel();
|
39
|
-
|
40
|
-
|
41
|
-
where:
|
42
|
-
|
43
|
-
|
44
|
-
|
33
|
+
const [entries, meta] = await cms.listLatestEntries(model, {
|
34
|
+
...params,
|
35
|
+
where: {
|
36
|
+
...params.where
|
37
|
+
}
|
38
|
+
});
|
39
|
+
return [entries.map(_pickEntryFieldValues.pickEntryFieldValues), meta];
|
45
40
|
},
|
46
41
|
async createContentReview(params) {
|
47
42
|
const model = await getContentReviewModel();
|
48
|
-
security.disableAuthorization();
|
49
43
|
const entry = await cms.createEntry(model, params.data);
|
50
|
-
|
51
|
-
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
44
|
+
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
52
45
|
},
|
53
46
|
async updateContentReview(params) {
|
54
47
|
const model = await getContentReviewModel();
|
@@ -59,18 +52,20 @@ const createContentReviewStorageOperations = ({
|
|
59
52
|
const existingEntry = await getContentReview({
|
60
53
|
id: params.id
|
61
54
|
});
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
55
|
+
const entry = await cms.updateEntry(model, params.id, {
|
56
|
+
...existingEntry,
|
57
|
+
...params.data,
|
58
|
+
savedOn: new Date()
|
59
|
+
});
|
60
|
+
return (0, _pickEntryFieldValues.pickEntryFieldValues)(entry);
|
66
61
|
},
|
67
62
|
async deleteContentReview(params) {
|
68
63
|
const model = await getContentReviewModel();
|
69
|
-
security.disableAuthorization();
|
70
64
|
await cms.deleteEntry(model, params.id);
|
71
|
-
security.enableAuthorization();
|
72
65
|
return true;
|
73
66
|
}
|
74
67
|
};
|
75
68
|
};
|
76
|
-
exports.createContentReviewStorageOperations = createContentReviewStorageOperations;
|
69
|
+
exports.createContentReviewStorageOperations = createContentReviewStorageOperations;
|
70
|
+
|
71
|
+
//# sourceMappingURL=contentReviewStorageOperations.js.map
|