@webiny/api-apw 5.30.0 → 5.31.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/crud/createContentReviewMethods.js +2 -1
- package/crud/createContentReviewMethods.js.map +1 -1
- package/index.d.ts +3 -3
- package/package.json +31 -30
- package/plugins/context.d.ts +1 -1
- package/plugins/context.js +6 -6
- package/plugins/context.js.map +1 -1
- package/plugins/graphql.d.ts +1 -1
- package/plugins/graphql.js +2 -2
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/index.d.ts +1 -1
- package/plugins/hooks/index.js +2 -2
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/pageBuilder/apwContentPagePlugins.d.ts +1 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js +2 -2
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +5 -8
- package/scheduler/handlers/executeAction/index.js +21 -19
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/security.d.ts +1 -1
- package/scheduler/handlers/executeAction/security.js +2 -2
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +6 -6
- package/scheduler/handlers/scheduleAction/index.js +34 -31
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +1 -1
- package/scheduler/types.d.ts +1 -1
- package/scheduler/types.js.map +1 -1
- package/types.d.ts +1 -1
- package/types.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createContentReviewMethods","params","getIdentity","storageOperations","getReviewer","getContentGetter","getContentPublisher","getContentUnPublisher","scheduler","handlerClient","getTenant","getLocale","plugins","onBeforeContentReviewCreate","createTopic","onAfterContentReviewCreate","onBeforeContentReviewUpdate","onAfterContentReviewUpdate","onBeforeContentReviewDelete","onAfterContentReviewDelete","get","id","getContentReview","list","where","status","filterContentReviewsByRequiresMyAttention","listParams","listContentReviews","create","data","input","ApwContentReviewStatus","UNDER_REVIEW","publish","contentReview","createContentReview","update","original","updateContentReview","delete","deleteContentReview","provideSignOff","stepId","entry","steps","stepIndex","findIndex","step","currentStep","previousStep","identity","hasPermission","hasReviewer","NotAuthorizedError","ApwContentReviewStepStatus","DONE","type","ApwWorkflowStepTypes","MANDATORY_BLOCKING","StepMissingError","pendingChangeRequests","PendingChangeRequestsError","ACTIVE","StepInActiveError","previousStepStatus","updatedSteps","map","index","signOffProvidedOn","Date","toISOString","signOffProvidedBy","getNextStepStatus","newStatus","pendingRequiredSteps","getPendingRequiredSteps","length","READY_TO_BE_PUBLISHED","retractSignOff","NoSignOffProvidedError","isReviewRequired","contentGetter","content","settings","contentReviewId","contentApwSettingsPlugin","getContentApwSettingsPlugin","getContentReviewId","workflowId","getWorkflowId","publishContent","datetime","Error","message","code","checkValidDateTime","contentPublisher","action","ApwScheduleActionTypes","PUBLISH","entryId","modelId","scheduledActionId","scheduleAction","scheduledOn","scheduledBy","unpublishContent","PUBLISHED","contentUnPublisher","UNPUBLISH","scheduledAction","process","env","NODE_ENV","invoke","name","String","APW_SCHEDULER_SCHEDULE_ACTION_HANDLER","payload","tenant","locale","await","deleteScheduledAction","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META"],"sources":["createContentReviewMethods.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReview,\n ApwContentReviewCrud,\n ApwContentReviewStatus,\n ApwContentReviewStepStatus,\n ApwReviewerCrud,\n ApwScheduleActionData,\n ApwWorkflowStepTypes,\n CreateApwParams,\n OnAfterContentReviewCreateTopicParams,\n OnAfterContentReviewDeleteTopicParams,\n OnAfterContentReviewUpdateTopicParams,\n OnBeforeContentReviewCreateTopicParams,\n OnBeforeContentReviewDeleteTopicParams,\n OnBeforeContentReviewUpdateTopicParams\n} from \"~/types\";\nimport { getNextStepStatus, hasReviewer } from \"~/plugins/utils\";\nimport {\n NoSignOffProvidedError,\n NotAuthorizedError,\n PendingChangeRequestsError,\n StepInActiveError,\n StepMissingError\n} from \"~/utils/errors\";\nimport { ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport {\n checkValidDateTime,\n filterContentReviewsByRequiresMyAttention,\n getPendingRequiredSteps,\n INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n} from \"./utils\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface CreateContentReviewMethodsParams extends CreateApwParams {\n getReviewer: ApwReviewerCrud[\"get\"];\n getContentGetter: AdvancedPublishingWorkflow[\"getContentGetter\"];\n getContentPublisher: AdvancedPublishingWorkflow[\"getContentPublisher\"];\n getContentUnPublisher: AdvancedPublishingWorkflow[\"getContentUnPublisher\"];\n plugins: PluginsContainer;\n}\n\nexport function createContentReviewMethods(\n params: CreateContentReviewMethodsParams\n): ApwContentReviewCrud {\n const {\n getIdentity,\n storageOperations,\n getReviewer,\n getContentGetter,\n getContentPublisher,\n getContentUnPublisher,\n scheduler,\n handlerClient,\n getTenant,\n getLocale,\n plugins\n } = params;\n\n const onBeforeContentReviewCreate = createTopic<OnBeforeContentReviewCreateTopicParams>();\n const onAfterContentReviewCreate = createTopic<OnAfterContentReviewCreateTopicParams>();\n const onBeforeContentReviewUpdate = createTopic<OnBeforeContentReviewUpdateTopicParams>();\n const onAfterContentReviewUpdate = createTopic<OnAfterContentReviewUpdateTopicParams>();\n const onBeforeContentReviewDelete = createTopic<OnBeforeContentReviewDeleteTopicParams>();\n const onAfterContentReviewDelete = createTopic<OnAfterContentReviewDeleteTopicParams>();\n return {\n /**\n * Lifecycle events\n */\n onBeforeContentReviewCreate,\n onAfterContentReviewCreate,\n onBeforeContentReviewUpdate,\n onAfterContentReviewUpdate,\n onBeforeContentReviewDelete,\n onAfterContentReviewDelete,\n async get(id) {\n return storageOperations.getContentReview({ id });\n },\n async list(params) {\n if (params.where && params.where.status === \"requiresMyAttention\") {\n return filterContentReviewsByRequiresMyAttention({\n listParams: params,\n listContentReviews: storageOperations.listContentReviews,\n getReviewer,\n getIdentity\n });\n }\n\n return storageOperations.listContentReviews(params);\n },\n async create(data) {\n const input = {\n ...data,\n status: ApwContentReviewStatus.UNDER_REVIEW\n };\n await onBeforeContentReviewCreate.publish({ input });\n\n const contentReview = await storageOperations.createContentReview({\n data: input\n });\n\n await onAfterContentReviewCreate.publish({ contentReview });\n\n return contentReview;\n },\n async update(id, data) {\n const original = await storageOperations.getContentReview({ id });\n\n await onBeforeContentReviewUpdate.publish({ original, input: { id, data } });\n\n const contentReview = await storageOperations.updateContentReview({\n id,\n data\n });\n\n await onAfterContentReviewUpdate.publish({\n original,\n input: { id, data },\n contentReview\n });\n\n return contentReview;\n },\n async delete(id) {\n const contentReview = await storageOperations.getContentReview({ id });\n\n await onBeforeContentReviewDelete.publish({ contentReview });\n\n await storageOperations.deleteContentReview({ id });\n\n await onAfterContentReviewDelete.publish({ contentReview });\n\n return true;\n },\n async provideSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, status } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n const previousStep = steps[stepIndex - 1];\n\n const identity = getIdentity();\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if previous step is of \"mandatory_blocking\" type and undone.\n */\n if (\n previousStep &&\n previousStep.status !== ApwContentReviewStepStatus.DONE &&\n previousStep.type === ApwWorkflowStepTypes.MANDATORY_BLOCKING\n ) {\n throw new StepMissingError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if there are pending change requests.\n */\n if (currentStep.pendingChangeRequests > 0) {\n throw new PendingChangeRequestsError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if current step is not in \"active\" state.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.ACTIVE) {\n throw new StepInActiveError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n /*\n * Provide sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.DONE;\n return {\n ...step,\n status: ApwContentReviewStepStatus.DONE,\n signOffProvidedOn: new Date().toISOString(),\n signOffProvidedBy: identity\n };\n }\n /**\n * Update next steps status based on type.\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n /**\n * Check for pending steps\n */\n let newStatus = status;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => typeof step.signOffProvidedOn !== \"string\"\n );\n\n /**\n * If there are no required steps that are pending, set the status to \"READY_TO_BE_PUBLISHED\".\n */\n if (pendingRequiredSteps.length === 0) {\n newStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED;\n }\n\n /**\n * Save updated steps.\n */\n await this.update(id, {\n steps: updatedSteps,\n status: newStatus\n });\n return true;\n },\n async retractSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, status } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n\n const identity = getIdentity();\n\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the retract sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow, if step in not \"done\" i.e. no sign-off was provided for it.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.DONE) {\n throw new NoSignOffProvidedError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n\n /*\n * Retract sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.ACTIVE;\n return {\n ...step,\n status: previousStepStatus,\n signOffProvidedOn: null,\n signOffProvidedBy: null\n };\n }\n /**\n * Set next step status as \"inactive\".\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n\n /**\n * Check for pending steps\n */\n let newStatus = status;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => step.signOffProvidedOn === null\n );\n /**\n * If there are required steps that are pending, set the status to \"UNDER_REVIEW\".\n */\n if (pendingRequiredSteps.length !== 0) {\n newStatus = ApwContentReviewStatus.UNDER_REVIEW;\n }\n\n await this.update(id, {\n steps: updatedSteps,\n status: newStatus\n });\n return true;\n },\n async isReviewRequired(data) {\n const contentGetter = getContentGetter(data.type);\n const content = await contentGetter(data.id, data.settings);\n\n let isReviewRequired = false;\n let contentReviewId: string | null = null;\n\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type: data.type\n });\n\n if (contentApwSettingsPlugin) {\n contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n if (workflowId) {\n isReviewRequired = true;\n }\n }\n\n return {\n isReviewRequired,\n contentReviewId\n };\n },\n async publishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, status } = await this.get(id);\n const identity = getIdentity();\n\n if (status !== ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n throw new Error({\n message: `Cannot publish content because it is not yet ready to be published.`,\n code: \"NOT_READY_TO_BE_PUBLISHED\",\n data: {\n id,\n status,\n content\n }\n });\n }\n\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * And if not, we are publishing immediately.\n */\n if (!datetime) {\n const contentPublisher = getContentPublisher(content.type);\n\n await contentPublisher(content.id, content.settings);\n\n return true;\n }\n\n const data: ApwScheduleActionData = {\n action: ApwScheduleActionTypes.PUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n };\n const scheduledActionId = await this.scheduleAction(data);\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async unpublishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, status } = await this.get(id);\n const identity = getIdentity();\n\n if (status !== ApwContentReviewStatus.PUBLISHED) {\n throw new Error({\n message: `Cannot unpublish content because it is not yet published.`,\n code: \"NOT_YET_PUBLISHED\",\n data: {\n id,\n status,\n content\n }\n });\n }\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * If not, we are unpublishing immediately.\n */\n if (!datetime) {\n const contentUnPublisher = getContentUnPublisher(content.type);\n\n await contentUnPublisher(content.id, content.settings);\n\n return true;\n }\n\n const scheduledActionId = await this.scheduleAction({\n action: ApwScheduleActionTypes.UNPUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n });\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async scheduleAction(data) {\n // Save input in DB\n const scheduledAction = await scheduler.create(data);\n /**\n * This function contains logic of lambda invocation.\n * Current we're not mocking it, therefore, we're just returning true.\n */\n if (process.env.NODE_ENV === \"test\") {\n return scheduledAction.id;\n }\n // Invoke handler\n await handlerClient.invoke({\n name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),\n payload: { tenant: getTenant().id, locale: getLocale().code },\n await: false\n });\n return scheduledAction.id;\n },\n async deleteScheduledAction(id) {\n const contentReview = await this.get(id);\n const scheduledActionId = get(contentReview, \"content.scheduledActionId\");\n\n /**\n * Check if there is any action scheduled for this \"content review\".\n */\n if (!scheduledActionId) {\n throw new Error({\n message: `There is no action scheduled for content review.`,\n code: \"NO_ACTION_SCHEDULED\",\n data: {\n id\n }\n });\n }\n /**\n * Delete scheduled action.\n */\n await scheduler.delete(scheduledActionId);\n\n /**\n * Reset scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n }\n });\n\n return true;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAiBA;;AACA;;AAOA;;AACA;;AAMA;;;;;;AAWO,SAASA,0BAAT,CACHC,MADG,EAEiB;EACpB,MAAM;IACFC,WADE;IAEFC,iBAFE;IAGFC,WAHE;IAIFC,gBAJE;IAKFC,mBALE;IAMFC,qBANE;IAOFC,SAPE;IAQFC,aARE;IASFC,SATE;IAUFC,SAVE;IAWFC;EAXE,IAYFX,MAZJ;EAcA,MAAMY,2BAA2B,GAAG,IAAAC,mBAAA,GAApC;EACA,MAAMC,0BAA0B,GAAG,IAAAD,mBAAA,GAAnC;EACA,MAAME,2BAA2B,GAAG,IAAAF,mBAAA,GAApC;EACA,MAAMG,0BAA0B,GAAG,IAAAH,mBAAA,GAAnC;EACA,MAAMI,2BAA2B,GAAG,IAAAJ,mBAAA,GAApC;EACA,MAAMK,0BAA0B,GAAG,IAAAL,mBAAA,GAAnC;EACA,OAAO;IACH;AACR;AACA;IACQD,2BAJG;IAKHE,0BALG;IAMHC,2BANG;IAOHC,0BAPG;IAQHC,2BARG;IASHC,0BATG;;IAUH,MAAMC,GAAN,CAAUC,EAAV,EAAc;MACV,OAAOlB,iBAAiB,CAACmB,gBAAlB,CAAmC;QAAED;MAAF,CAAnC,C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vBC,OAAO,EAAE;UAAEC,MAAM,EAAE9G,SAAS,GAAGW,EAAtB;UAA0BoG,MAAM,EAAE9G,SAAS,GAAGoF;QAA9C,CAFc;QAGvB2B,KAAK,EAAE;MAHgB,CAArB,CAAN;MAKA,OAAOX,eAAe,CAAC1F,EAAvB;IACH,CApYE;;IAqYH,MAAMsG,qBAAN,CAA4BtG,EAA5B,EAAgC;MAC5B,MAAMc,aAAa,GAAG,MAAM,KAAKf,GAAL,CAASC,EAAT,CAA5B;MACA,MAAMkF,iBAAiB,GAAG,IAAAnF,YAAA,EAAIe,aAAJ,EAAmB,2BAAnB,CAA1B;MAEA;AACZ;AACA;;MACY,IAAI,CAACoE,iBAAL,EAAwB;QACpB,MAAM,IAAIV,cAAJ,CAAU;UACZC,OAAO,EAAG,kDADE;UAEZC,IAAI,EAAE,qBAFM;UAGZjE,IAAI,EAAE;YACFT;UADE;QAHM,CAAV,CAAN;MAOH;MACD;AACZ;AACA;;;MACY,MAAMb,SAAS,CAACgC,MAAV,CAAiB+D,iBAAjB,CAAN;MAEA;AACZ;AACA;;MACY,MAAM,KAAKlE,MAAL,CAAYhB,EAAZ,EAAgB;QAClB8D,OAAO,kCACAhD,aAAa,CAACgD,OADd,GAEAyC,oDAFA;MADW,CAAhB,CAAN;MAOA,OAAO,IAAP;IACH;;EAraE,CAAP;AAuaH"}
|
1
|
+
{"version":3,"names":["createContentReviewMethods","params","getIdentity","storageOperations","getReviewer","getContentGetter","getContentPublisher","getContentUnPublisher","scheduler","handlerClient","getTenant","getLocale","plugins","onBeforeContentReviewCreate","createTopic","onAfterContentReviewCreate","onBeforeContentReviewUpdate","onAfterContentReviewUpdate","onBeforeContentReviewDelete","onAfterContentReviewDelete","get","id","getContentReview","list","where","status","filterContentReviewsByRequiresMyAttention","listParams","listContentReviews","create","data","input","ApwContentReviewStatus","UNDER_REVIEW","publish","contentReview","createContentReview","update","original","updateContentReview","delete","deleteContentReview","provideSignOff","stepId","entry","steps","stepIndex","findIndex","step","currentStep","previousStep","identity","hasPermission","hasReviewer","NotAuthorizedError","ApwContentReviewStepStatus","DONE","type","ApwWorkflowStepTypes","MANDATORY_BLOCKING","StepMissingError","pendingChangeRequests","PendingChangeRequestsError","ACTIVE","StepInActiveError","previousStepStatus","updatedSteps","map","index","signOffProvidedOn","Date","toISOString","signOffProvidedBy","getNextStepStatus","newStatus","pendingRequiredSteps","getPendingRequiredSteps","length","READY_TO_BE_PUBLISHED","retractSignOff","NoSignOffProvidedError","isReviewRequired","contentGetter","content","settings","contentReviewId","contentApwSettingsPlugin","getContentApwSettingsPlugin","getContentReviewId","workflowId","getWorkflowId","publishContent","datetime","Error","message","code","checkValidDateTime","contentPublisher","action","ApwScheduleActionTypes","PUBLISH","entryId","modelId","scheduledActionId","scheduleAction","scheduledOn","scheduledBy","unpublishContent","PUBLISHED","contentUnPublisher","UNPUBLISH","scheduledAction","process","env","NODE_ENV","invoke","name","String","APW_SCHEDULER_SCHEDULE_ACTION_HANDLER","payload","tenant","locale","await","description","deleteScheduledAction","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META"],"sources":["createContentReviewMethods.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReview,\n ApwContentReviewCrud,\n ApwContentReviewStatus,\n ApwContentReviewStepStatus,\n ApwReviewerCrud,\n ApwScheduleActionData,\n ApwWorkflowStepTypes,\n CreateApwParams,\n OnAfterContentReviewCreateTopicParams,\n OnAfterContentReviewDeleteTopicParams,\n OnAfterContentReviewUpdateTopicParams,\n OnBeforeContentReviewCreateTopicParams,\n OnBeforeContentReviewDeleteTopicParams,\n OnBeforeContentReviewUpdateTopicParams\n} from \"~/types\";\nimport { getNextStepStatus, hasReviewer } from \"~/plugins/utils\";\nimport {\n NoSignOffProvidedError,\n NotAuthorizedError,\n PendingChangeRequestsError,\n StepInActiveError,\n StepMissingError\n} from \"~/utils/errors\";\nimport { ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport {\n checkValidDateTime,\n filterContentReviewsByRequiresMyAttention,\n getPendingRequiredSteps,\n INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n} from \"./utils\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface CreateContentReviewMethodsParams extends CreateApwParams {\n getReviewer: ApwReviewerCrud[\"get\"];\n getContentGetter: AdvancedPublishingWorkflow[\"getContentGetter\"];\n getContentPublisher: AdvancedPublishingWorkflow[\"getContentPublisher\"];\n getContentUnPublisher: AdvancedPublishingWorkflow[\"getContentUnPublisher\"];\n plugins: PluginsContainer;\n}\n\nexport function createContentReviewMethods(\n params: CreateContentReviewMethodsParams\n): ApwContentReviewCrud {\n const {\n getIdentity,\n storageOperations,\n getReviewer,\n getContentGetter,\n getContentPublisher,\n getContentUnPublisher,\n scheduler,\n handlerClient,\n getTenant,\n getLocale,\n plugins\n } = params;\n\n const onBeforeContentReviewCreate = createTopic<OnBeforeContentReviewCreateTopicParams>();\n const onAfterContentReviewCreate = createTopic<OnAfterContentReviewCreateTopicParams>();\n const onBeforeContentReviewUpdate = createTopic<OnBeforeContentReviewUpdateTopicParams>();\n const onAfterContentReviewUpdate = createTopic<OnAfterContentReviewUpdateTopicParams>();\n const onBeforeContentReviewDelete = createTopic<OnBeforeContentReviewDeleteTopicParams>();\n const onAfterContentReviewDelete = createTopic<OnAfterContentReviewDeleteTopicParams>();\n return {\n /**\n * Lifecycle events\n */\n onBeforeContentReviewCreate,\n onAfterContentReviewCreate,\n onBeforeContentReviewUpdate,\n onAfterContentReviewUpdate,\n onBeforeContentReviewDelete,\n onAfterContentReviewDelete,\n async get(id) {\n return storageOperations.getContentReview({ id });\n },\n async list(params) {\n if (params.where && params.where.status === \"requiresMyAttention\") {\n return filterContentReviewsByRequiresMyAttention({\n listParams: params,\n listContentReviews: storageOperations.listContentReviews,\n getReviewer,\n getIdentity\n });\n }\n\n return storageOperations.listContentReviews(params);\n },\n async create(data) {\n const input = {\n ...data,\n status: ApwContentReviewStatus.UNDER_REVIEW\n };\n await onBeforeContentReviewCreate.publish({ input });\n\n const contentReview = await storageOperations.createContentReview({\n data: input\n });\n\n await onAfterContentReviewCreate.publish({ contentReview });\n\n return contentReview;\n },\n async update(id, data) {\n const original = await storageOperations.getContentReview({ id });\n\n await onBeforeContentReviewUpdate.publish({ original, input: { id, data } });\n\n const contentReview = await storageOperations.updateContentReview({\n id,\n data\n });\n\n await onAfterContentReviewUpdate.publish({\n original,\n input: { id, data },\n contentReview\n });\n\n return contentReview;\n },\n async delete(id) {\n const contentReview = await storageOperations.getContentReview({ id });\n\n await onBeforeContentReviewDelete.publish({ contentReview });\n\n await storageOperations.deleteContentReview({ id });\n\n await onAfterContentReviewDelete.publish({ contentReview });\n\n return true;\n },\n async provideSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, status } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n const previousStep = steps[stepIndex - 1];\n\n const identity = getIdentity();\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if previous step is of \"mandatory_blocking\" type and undone.\n */\n if (\n previousStep &&\n previousStep.status !== ApwContentReviewStepStatus.DONE &&\n previousStep.type === ApwWorkflowStepTypes.MANDATORY_BLOCKING\n ) {\n throw new StepMissingError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if there are pending change requests.\n */\n if (currentStep.pendingChangeRequests > 0) {\n throw new PendingChangeRequestsError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if current step is not in \"active\" state.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.ACTIVE) {\n throw new StepInActiveError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n /*\n * Provide sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.DONE;\n return {\n ...step,\n status: ApwContentReviewStepStatus.DONE,\n signOffProvidedOn: new Date().toISOString(),\n signOffProvidedBy: identity\n };\n }\n /**\n * Update next steps status based on type.\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n /**\n * Check for pending steps\n */\n let newStatus = status;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => typeof step.signOffProvidedOn !== \"string\"\n );\n\n /**\n * If there are no required steps that are pending, set the status to \"READY_TO_BE_PUBLISHED\".\n */\n if (pendingRequiredSteps.length === 0) {\n newStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED;\n }\n\n /**\n * Save updated steps.\n */\n await this.update(id, {\n steps: updatedSteps,\n status: newStatus\n });\n return true;\n },\n async retractSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, status } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n\n const identity = getIdentity();\n\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the retract sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow, if step in not \"done\" i.e. no sign-off was provided for it.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.DONE) {\n throw new NoSignOffProvidedError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n\n /*\n * Retract sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.ACTIVE;\n return {\n ...step,\n status: previousStepStatus,\n signOffProvidedOn: null,\n signOffProvidedBy: null\n };\n }\n /**\n * Set next step status as \"inactive\".\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n\n /**\n * Check for pending steps\n */\n let newStatus = status;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => step.signOffProvidedOn === null\n );\n /**\n * If there are required steps that are pending, set the status to \"UNDER_REVIEW\".\n */\n if (pendingRequiredSteps.length !== 0) {\n newStatus = ApwContentReviewStatus.UNDER_REVIEW;\n }\n\n await this.update(id, {\n steps: updatedSteps,\n status: newStatus\n });\n return true;\n },\n async isReviewRequired(data) {\n const contentGetter = getContentGetter(data.type);\n const content = await contentGetter(data.id, data.settings);\n\n let isReviewRequired = false;\n let contentReviewId: string | null = null;\n\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type: data.type\n });\n\n if (contentApwSettingsPlugin) {\n contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n if (workflowId) {\n isReviewRequired = true;\n }\n }\n\n return {\n isReviewRequired,\n contentReviewId\n };\n },\n async publishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, status } = await this.get(id);\n const identity = getIdentity();\n\n if (status !== ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n throw new Error({\n message: `Cannot publish content because it is not yet ready to be published.`,\n code: \"NOT_READY_TO_BE_PUBLISHED\",\n data: {\n id,\n status,\n content\n }\n });\n }\n\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * And if not, we are publishing immediately.\n */\n if (!datetime) {\n const contentPublisher = getContentPublisher(content.type);\n\n await contentPublisher(content.id, content.settings);\n\n return true;\n }\n\n const data: ApwScheduleActionData = {\n action: ApwScheduleActionTypes.PUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n };\n const scheduledActionId = await this.scheduleAction(data);\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async unpublishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, status } = await this.get(id);\n const identity = getIdentity();\n\n if (status !== ApwContentReviewStatus.PUBLISHED) {\n throw new Error({\n message: `Cannot unpublish content because it is not yet published.`,\n code: \"NOT_YET_PUBLISHED\",\n data: {\n id,\n status,\n content\n }\n });\n }\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * If not, we are unpublishing immediately.\n */\n if (!datetime) {\n const contentUnPublisher = getContentUnPublisher(content.type);\n\n await contentUnPublisher(content.id, content.settings);\n\n return true;\n }\n\n const scheduledActionId = await this.scheduleAction({\n action: ApwScheduleActionTypes.UNPUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n });\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async scheduleAction(data) {\n // Save input in DB\n const scheduledAction = await scheduler.create(data);\n /**\n * This function contains logic of lambda invocation.\n * Current we're not mocking it, therefore, we're just returning true.\n */\n if (process.env.NODE_ENV === \"test\") {\n return scheduledAction.id;\n }\n // Invoke handler\n await handlerClient.invoke({\n name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),\n payload: {\n tenant: getTenant().id,\n locale: getLocale().code\n },\n await: false,\n description: \"APW scheduler handler\"\n });\n return scheduledAction.id;\n },\n async deleteScheduledAction(id) {\n const contentReview = await this.get(id);\n const scheduledActionId = get(contentReview, \"content.scheduledActionId\");\n\n /**\n * Check if there is any action scheduled for this \"content review\".\n */\n if (!scheduledActionId) {\n throw new Error({\n message: `There is no action scheduled for content review.`,\n code: \"NO_ACTION_SCHEDULED\",\n data: {\n id\n }\n });\n }\n /**\n * Delete scheduled action.\n */\n await scheduler.delete(scheduledActionId);\n\n /**\n * Reset scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n }\n });\n\n return true;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAiBA;;AACA;;AAOA;;AACA;;AAMA;;;;;;AAWO,SAASA,0BAAT,CACHC,MADG,EAEiB;EACpB,MAAM;IACFC,WADE;IAEFC,iBAFE;IAGFC,WAHE;IAIFC,gBAJE;IAKFC,mBALE;IAMFC,qBANE;IAOFC,SAPE;IAQFC,aARE;IASFC,SATE;IAUFC,SAVE;IAWFC;EAXE,IAYFX,MAZJ;EAcA,MAAMY,2BAA2B,GAAG,IAAAC,mBAAA,GAApC;EACA,MAAMC,0BAA0B,GAAG,IAAAD,mBAAA,GAAnC;EACA,MAAME,2BAA2B,GAAG,IAAAF,mBAAA,GAApC;EACA,MAAMG,0BAA0B,GAAG,IAAAH,mBAAA,GAAnC;EACA,MAAMI,2BAA2B,GAAG,IAAAJ,mBAAA,GAApC;EACA,MAAMK,0BAA0B,GAAG,IAAAL,mBAAA,GAAnC;EACA,OAAO;IACH;AACR;AACA;IACQD,2BAJG;IAKHE,0BALG;IAMHC,2BANG;IAOHC,0BAPG;IAQHC,2BARG;IASHC,0BATG;;IAUH,MAAMC,GAAN,CAAUC,EAAV,EAAc;MACV,OAAOlB,iBAAiB,CAACmB,gBAAlB,CAAmC;QAAED;MAAF,CAAnC,CAAP;IACH,CAZE;;IAaH,MAAME,IAAN,CAAWtB,MAAX,EAAmB;MACf,IAAIA,MAAM,CAACuB,KAAP,IAAgBvB,MAAM,CAACuB,KAAP,CAAaC,MAAb,KAA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OvBC,WAAW,EAAE;MAPU,CAArB,CAAN;MASA,OAAOZ,eAAe,CAAC1F,EAAvB;IACH,CAxYE;;IAyYH,MAAMuG,qBAAN,CAA4BvG,EAA5B,EAAgC;MAC5B,MAAMc,aAAa,GAAG,MAAM,KAAKf,GAAL,CAASC,EAAT,CAA5B;MACA,MAAMkF,iBAAiB,GAAG,IAAAnF,YAAA,EAAIe,aAAJ,EAAmB,2BAAnB,CAA1B;MAEA;AACZ;AACA;;MACY,IAAI,CAACoE,iBAAL,EAAwB;QACpB,MAAM,IAAIV,cAAJ,CAAU;UACZC,OAAO,EAAG,kDADE;UAEZC,IAAI,EAAE,qBAFM;UAGZjE,IAAI,EAAE;YACFT;UADE;QAHM,CAAV,CAAN;MAOH;MACD;AACZ;AACA;;;MACY,MAAMb,SAAS,CAACgC,MAAV,CAAiB+D,iBAAjB,CAAN;MAEA;AACZ;AACA;;MACY,MAAM,KAAKlE,MAAL,CAAYhB,EAAZ,EAAgB;QAClB8D,OAAO,kCACAhD,aAAa,CAACgD,OADd,GAEA0C,oDAFA;MADW,CAAhB,CAAN;MAOA,OAAO,IAAP;IACH;;EAzaE,CAAP;AA2aH"}
|
package/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import { CreateApwContextParams } from "./scheduler/types";
|
2
|
-
export declare const createApwHeadlessCmsContext: (params: CreateApwContextParams) => import("@webiny/
|
3
|
-
export declare const createApwPageBuilderContext: (params: CreateApwContextParams) => import("@webiny/
|
4
|
-
export declare const createApwGraphQL: () => import("@webiny/
|
2
|
+
export declare const createApwHeadlessCmsContext: (params: CreateApwContextParams) => import("@webiny/api").ContextPlugin<import("./types").ApwContext>;
|
3
|
+
export declare const createApwPageBuilderContext: (params: CreateApwContextParams) => import("@webiny/api").ContextPlugin<import("./types").ApwContext>;
|
4
|
+
export declare const createApwGraphQL: () => import("@webiny/api").ContextPlugin<import("./types").ApwContext>;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@webiny/api-apw",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.31.0-beta.0",
|
4
4
|
"keywords": [
|
5
5
|
"apw:base"
|
6
6
|
],
|
@@ -14,29 +14,28 @@
|
|
14
14
|
"author": "Webiny Ltd",
|
15
15
|
"license": "MIT",
|
16
16
|
"dependencies": {
|
17
|
-
"@aws-sdk/client-cloudwatch-events": "3.
|
18
|
-
"@babel/runtime": "7.18.
|
17
|
+
"@aws-sdk/client-cloudwatch-events": "3.142.0",
|
18
|
+
"@babel/runtime": "7.18.9",
|
19
19
|
"@commodo/fields": "1.1.2-beta.20",
|
20
|
-
"@webiny/api
|
21
|
-
"@webiny/api-
|
22
|
-
"@webiny/api-i18n
|
23
|
-
"@webiny/api-
|
24
|
-
"@webiny/api-
|
25
|
-
"@webiny/api-
|
26
|
-
"@webiny/api-
|
27
|
-
"@webiny/
|
28
|
-
"@webiny/
|
29
|
-
"@webiny/
|
30
|
-
"@webiny/handler
|
31
|
-
"@webiny/handler-
|
32
|
-
"@webiny/handler-
|
33
|
-
"@webiny/handler-
|
34
|
-
"@webiny/handler-
|
35
|
-
"@webiny/
|
36
|
-
"@webiny/
|
37
|
-
"@webiny/
|
38
|
-
"
|
39
|
-
"dayjs": "1.11.3",
|
20
|
+
"@webiny/api": "5.31.0-beta.0",
|
21
|
+
"@webiny/api-headless-cms": "5.31.0-beta.0",
|
22
|
+
"@webiny/api-i18n": "5.31.0-beta.0",
|
23
|
+
"@webiny/api-i18n-ddb": "5.31.0-beta.0",
|
24
|
+
"@webiny/api-page-builder": "5.31.0-beta.0",
|
25
|
+
"@webiny/api-security": "5.31.0-beta.0",
|
26
|
+
"@webiny/api-tenancy": "5.31.0-beta.0",
|
27
|
+
"@webiny/api-wcp": "5.31.0-beta.0",
|
28
|
+
"@webiny/db-dynamodb": "5.31.0-beta.0",
|
29
|
+
"@webiny/error": "5.31.0-beta.0",
|
30
|
+
"@webiny/handler": "5.31.0-beta.0",
|
31
|
+
"@webiny/handler-client": "5.31.0-beta.0",
|
32
|
+
"@webiny/handler-db": "5.31.0-beta.0",
|
33
|
+
"@webiny/handler-graphql": "5.31.0-beta.0",
|
34
|
+
"@webiny/handler-logs": "5.31.0-beta.0",
|
35
|
+
"@webiny/plugins": "5.31.0-beta.0",
|
36
|
+
"@webiny/pubsub": "5.31.0-beta.0",
|
37
|
+
"@webiny/validation": "5.31.0-beta.0",
|
38
|
+
"dayjs": "1.11.4",
|
40
39
|
"lodash": "4.17.21",
|
41
40
|
"mdbid": "1.0.0",
|
42
41
|
"nanoid": "3.3.4"
|
@@ -46,12 +45,14 @@
|
|
46
45
|
"@babel/core": "^7.5.5",
|
47
46
|
"@babel/preset-env": "^7.5.5",
|
48
47
|
"@babel/preset-flow": "^7.0.0",
|
49
|
-
"@webiny/api-headless-cms-ddb": "^5.
|
50
|
-
"@webiny/api-page-builder-so-ddb": "^5.
|
51
|
-
"@webiny/api-security-so-ddb": "^5.
|
52
|
-
"@webiny/api-tenancy-so-ddb": "^5.
|
53
|
-
"@webiny/cli": "^5.
|
54
|
-
"@webiny/
|
48
|
+
"@webiny/api-headless-cms-ddb": "^5.31.0-beta.0",
|
49
|
+
"@webiny/api-page-builder-so-ddb": "^5.31.0-beta.0",
|
50
|
+
"@webiny/api-security-so-ddb": "^5.31.0-beta.0",
|
51
|
+
"@webiny/api-tenancy-so-ddb": "^5.31.0-beta.0",
|
52
|
+
"@webiny/cli": "^5.31.0-beta.0",
|
53
|
+
"@webiny/handler-aws": "^5.31.0-beta.0",
|
54
|
+
"@webiny/project-utils": "^5.31.0-beta.0",
|
55
|
+
"@webiny/wcp": "^5.31.0-beta.0",
|
55
56
|
"get-yarn-workspaces": "^1.0.2",
|
56
57
|
"graphql": "^15.7.2",
|
57
58
|
"jest": "^28.1.0",
|
@@ -70,5 +71,5 @@
|
|
70
71
|
"build": "yarn webiny run build",
|
71
72
|
"watch": "yarn webiny run watch"
|
72
73
|
},
|
73
|
-
"gitHead": "
|
74
|
+
"gitHead": "dea7c56325ff140ef0e2d761f3e65708d46d401e"
|
74
75
|
}
|
package/plugins/context.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ContextPlugin } from "@webiny/
|
1
|
+
import { ContextPlugin } from "@webiny/api";
|
2
2
|
import { ApwContext } from "../types";
|
3
3
|
import { CreateApwContextParams } from "../scheduler/types";
|
4
4
|
export declare const createApwPageBuilderContext: (params: CreateApwContextParams) => ContextPlugin<ApwContext>;
|
package/plugins/context.js
CHANGED
@@ -11,7 +11,7 @@ var _hooks = require("./hooks");
|
|
11
11
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
13
13
|
|
14
|
-
var
|
14
|
+
var _api = require("@webiny/api");
|
15
15
|
|
16
16
|
var _crud = require("../crud");
|
17
17
|
|
@@ -31,7 +31,7 @@ var _apwContentPagePlugins = require("./pageBuilder/apwContentPagePlugins");
|
|
31
31
|
|
32
32
|
var _cms = require("./cms");
|
33
33
|
|
34
|
-
const setupApwContext = params => new
|
34
|
+
const setupApwContext = params => new _api.ContextPlugin(async context => {
|
35
35
|
const {
|
36
36
|
tenancy,
|
37
37
|
security,
|
@@ -96,19 +96,19 @@ const setupApwContext = params => new _ContextPlugin.ContextPlugin(async context
|
|
96
96
|
});
|
97
97
|
|
98
98
|
const setupApwPageBuilder = () => {
|
99
|
-
return new
|
99
|
+
return new _api.ContextPlugin(async context => {
|
100
100
|
(0, _pageBuilder.apwPageBuilderHooks)(context);
|
101
101
|
});
|
102
102
|
};
|
103
103
|
|
104
104
|
const setupApwHeadlessCms = () => {
|
105
|
-
return new
|
105
|
+
return new _api.ContextPlugin(async context => {
|
106
106
|
(0, _cms.apwCmsHooks)(context);
|
107
107
|
});
|
108
108
|
};
|
109
109
|
|
110
110
|
const createApwPageBuilderContext = params => {
|
111
|
-
return new
|
111
|
+
return new _api.ContextPlugin(async context => {
|
112
112
|
if (!context.wcp.canUseFeature("advancedPublishingWorkflow")) {
|
113
113
|
return;
|
114
114
|
} else if ((0, _utils.isInstallationPending)(context)) {
|
@@ -128,7 +128,7 @@ const createApwPageBuilderContext = params => {
|
|
128
128
|
exports.createApwPageBuilderContext = createApwPageBuilderContext;
|
129
129
|
|
130
130
|
const createApwHeadlessCmsContext = params => {
|
131
|
-
return new
|
131
|
+
return new _api.ContextPlugin(async context => {
|
132
132
|
if (!context.wcp.canUseFeature("advancedPublishingWorkflow")) {
|
133
133
|
return;
|
134
134
|
} else if ((0, _utils.isInstallationPending)(context)) {
|
package/plugins/context.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["setupApwContext","params","ContextPlugin","context","tenancy","security","i18n","handlerClient","isInstallationPending","getLocale","locale","getContentLocale","WebinyError","getTenant","getCurrentTenant","getPermission","name","getIdentity","scheduler","createScheduler","storageOperations","apw","createApw","createStorageOperations","cms","getCmsContext","plugins","setupApwPageBuilder","apwPageBuilderHooks","setupApwHeadlessCms","apwCmsHooks","createApwPageBuilderContext","wcp","canUseFeature","apply","apwContentPagePlugins","attachApwHooks","createCustomAuth","register","extendPbPageSettingsSchema","createApwHeadlessCmsContext"],"sources":["context.ts"],"sourcesContent":["import { attachApwHooks } from \"./hooks\";\nimport WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/
|
1
|
+
{"version":3,"names":["setupApwContext","params","ContextPlugin","context","tenancy","security","i18n","handlerClient","isInstallationPending","getLocale","locale","getContentLocale","WebinyError","getTenant","getCurrentTenant","getPermission","name","getIdentity","scheduler","createScheduler","storageOperations","apw","createApw","createStorageOperations","cms","getCmsContext","plugins","setupApwPageBuilder","apwPageBuilderHooks","setupApwHeadlessCms","apwCmsHooks","createApwPageBuilderContext","wcp","canUseFeature","apply","apwContentPagePlugins","attachApwHooks","createCustomAuth","register","extendPbPageSettingsSchema","createApwHeadlessCmsContext"],"sources":["context.ts"],"sourcesContent":["import { attachApwHooks } from \"./hooks\";\nimport WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\nimport { createApw } from \"~/crud\";\nimport { apwPageBuilderHooks } from \"./pageBuilder\";\nimport { createStorageOperations } from \"~/storageOperations\";\nimport { SecurityPermission } from \"@webiny/api-security/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { CreateApwContextParams } from \"~/scheduler/types\";\nimport { createScheduler } from \"~/scheduler\";\nimport { createCustomAuth } from \"~/scheduler/handlers/executeAction/security\";\nimport { isInstallationPending } from \"./utils\";\nimport { extendPbPageSettingsSchema } from \"~/plugins/pageBuilder/extendPbPageSettingsSchema\";\nimport { apwContentPagePlugins } from \"~/plugins/pageBuilder/apwContentPagePlugins\";\nimport { apwCmsHooks } from \"~/plugins/cms\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\n\nconst setupApwContext = (params: CreateApwContextParams) =>\n new ContextPlugin<ApwContext>(async context => {\n const { tenancy, security, i18n, handlerClient } = context;\n\n if (isInstallationPending({ tenancy, i18n })) {\n return;\n }\n\n const getLocale = (): I18NLocale => {\n const locale = i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-apw/plugins/context.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n return locale;\n };\n\n const getTenant = (): Tenant => {\n return tenancy.getCurrentTenant();\n };\n\n const getPermission = async (name: string): Promise<SecurityPermission | null> => {\n return security.getPermission(name);\n };\n const getIdentity = () => security.getIdentity();\n\n const scheduler = createScheduler({\n getLocale,\n getIdentity,\n getTenant,\n getPermission,\n storageOperations: params.storageOperations\n });\n\n context.apw = createApw({\n getLocale,\n getIdentity,\n getTenant,\n getPermission,\n storageOperations: createStorageOperations({\n /**\n * TODO: We need to figure out a way to pass \"cms\" from outside (e.g. apps/api/graphql)\n */\n cms: context.cms,\n /**\n * TODO: This is required for \"entryFieldFromStorageTransform\" which access plugins from context.\n */\n getCmsContext: () => context\n }),\n scheduler,\n handlerClient,\n plugins: context.plugins\n });\n });\n\nconst setupApwPageBuilder = () => {\n return new ContextPlugin<ApwContext>(async context => {\n apwPageBuilderHooks(context);\n });\n};\n\nconst setupApwHeadlessCms = () => {\n return new ContextPlugin<ApwContext>(async context => {\n apwCmsHooks(context);\n });\n};\n\nexport const createApwPageBuilderContext = (params: CreateApwContextParams) => {\n return new ContextPlugin<ApwContext>(async context => {\n if (!context.wcp.canUseFeature(\"advancedPublishingWorkflow\")) {\n return;\n } else if (isInstallationPending(context)) {\n return;\n }\n\n await setupApwContext(params).apply(context);\n await setupApwPageBuilder().apply(context);\n await setupApwHeadlessCms().apply(context);\n await apwContentPagePlugins().apply(context);\n await attachApwHooks().apply(context);\n await createCustomAuth(params).apply(context);\n\n context.plugins.register(extendPbPageSettingsSchema());\n });\n};\n\nexport const createApwHeadlessCmsContext = (params: CreateApwContextParams) => {\n return new ContextPlugin<ApwContext>(async context => {\n if (!context.wcp.canUseFeature(\"advancedPublishingWorkflow\")) {\n return;\n } else if (isInstallationPending(context)) {\n return;\n }\n\n await setupApwContext(params).apply(context);\n await setupApwHeadlessCms().apply(context);\n await attachApwHooks().apply(context);\n await createCustomAuth(params).apply(context);\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA,MAAMA,eAAe,GAAIC,MAAD,IACpB,IAAIC,kBAAJ,CAA8B,MAAMC,OAAN,IAAiB;EAC3C,MAAM;IAAEC,OAAF;IAAWC,QAAX;IAAqBC,IAArB;IAA2BC;EAA3B,IAA6CJ,OAAnD;;EAEA,IAAI,IAAAK,4BAAA,EAAsB;IAAEJ,OAAF;IAAWE;EAAX,CAAtB,CAAJ,EAA8C;IAC1C;EACH;;EAED,MAAMG,SAAS,GAAG,MAAkB;IAChC,MAAMC,MAAM,GAAGJ,IAAI,CAACK,gBAAL,EAAf;;IACA,IAAI,CAACD,MAAL,EAAa;MACT,MAAM,IAAIE,cAAJ,CACF,sDADE,EAEF,cAFE,CAAN;IAIH;;IAED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jB,EAAyBiC,KAAzB,CAA+B/B,OAA/B,CAAN;EACH,CAXM,CAAP;AAYH,CAbM"}
|
package/plugins/graphql.d.ts
CHANGED
package/plugins/graphql.js
CHANGED
@@ -19,7 +19,7 @@ var _comment = _interopRequireDefault(require("./graphql/comment.gql"));
|
|
19
19
|
|
20
20
|
var _changeRequest = _interopRequireDefault(require("./graphql/changeRequest.gql"));
|
21
21
|
|
22
|
-
var
|
22
|
+
var _api = require("@webiny/api");
|
23
23
|
|
24
24
|
const emptyResolver = () => ({});
|
25
25
|
|
@@ -83,7 +83,7 @@ const baseSchema = new _plugins.GraphQLSchemaPlugin({
|
|
83
83
|
});
|
84
84
|
|
85
85
|
var _default = () => {
|
86
|
-
return new
|
86
|
+
return new _api.ContextPlugin(context => {
|
87
87
|
if (!context.wcp.canUseFeature("advancedPublishingWorkflow")) {
|
88
88
|
return;
|
89
89
|
}
|
package/plugins/graphql.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","apw","Mutation","ContextPlugin","context","wcp","canUseFeature","plugins","register","workflowSchema","contentReviewSchema","reviewerSchema","commentSchema","changeRequestedSchema"],"sources":["graphql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport workflowSchema from \"./graphql/workflow.gql\";\nimport contentReviewSchema from \"./graphql/contentReview.gql\";\nimport reviewerSchema from \"./graphql/reviewer.gql\";\nimport commentSchema from \"./graphql/comment.gql\";\nimport changeRequestedSchema from \"./graphql/changeRequest.gql\";\nimport { ContextPlugin } from \"@webiny/
|
1
|
+
{"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","apw","Mutation","ContextPlugin","context","wcp","canUseFeature","plugins","register","workflowSchema","contentReviewSchema","reviewerSchema","commentSchema","changeRequestedSchema"],"sources":["graphql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport workflowSchema from \"./graphql/workflow.gql\";\nimport contentReviewSchema from \"./graphql/contentReview.gql\";\nimport reviewerSchema from \"./graphql/reviewer.gql\";\nimport commentSchema from \"./graphql/comment.gql\";\nimport changeRequestedSchema from \"./graphql/changeRequest.gql\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nconst baseSchema = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n input ApwRefFieldInput {\n id: ID!\n modelId: String\n }\n\n input ApwRefFieldWhereInput {\n id: String\n id_not: String\n id_in: [String!]\n id_not_in: [String]\n entryId: String\n entryId_not: String\n entryId_in: [String!]\n entryId_not_in: [String!]\n }\n\n type ApwRefField {\n modelId: String!\n entryId: ID!\n id: ID!\n }\n\n type ApwMeta {\n hasMoreItems: Boolean\n totalCount: Int\n cursor: String\n }\n type ApwCreatedBy {\n id: ID\n displayName: String\n type: String\n }\n type ApwError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n extend type Query {\n apw: ApwQuery\n }\n extend type Mutation {\n apw: ApwMutation\n }\n `,\n resolvers: {\n Query: {\n apw: emptyResolver\n },\n Mutation: {\n apw: emptyResolver\n }\n }\n});\n\nexport default () => {\n return new ContextPlugin<ApwContext>(context => {\n if (!context.wcp.canUseFeature(\"advancedPublishingWorkflow\")) {\n return;\n }\n\n context.plugins.register([\n baseSchema,\n workflowSchema,\n contentReviewSchema,\n reviewerSchema,\n commentSchema,\n changeRequestedSchema\n ]);\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA,MAAMA,aAAa,GAAG,OAAO,EAAP,CAAtB;;AAEA,MAAMC,UAAU,GAAG,IAAIC,4BAAJ,CAAwB;EACvCC,QAAQ;EAAE;EAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KA9C2C;EA+CvCC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,GAAG,EAAEN;IADF,CADA;IAIPO,QAAQ,EAAE;MACND,GAAG,EAAEN;IADC;EAJH;AA/C4B,CAAxB,CAAnB;;eAyDe,MAAM;EACjB,OAAO,IAAIQ,kBAAJ,CAA8BC,OAAO,IAAI;IAC5C,IAAI,CAACA,OAAO,CAACC,GAAR,CAAYC,aAAZ,CAA0B,4BAA1B,CAAL,EAA8D;MAC1D;IACH;;IAEDF,OAAO,CAACG,OAAR,CAAgBC,QAAhB,CAAyB,CACrBZ,UADqB,EAErBa,iBAFqB,EAGrBC,sBAHqB,EAIrBC,iBAJqB,EAKrBC,gBALqB,EAMrBC,sBANqB,CAAzB;EAQH,CAbM,CAAP;AAcH,C"}
|
package/plugins/hooks/index.d.ts
CHANGED
package/plugins/hooks/index.js
CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.attachApwHooks = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _api = require("@webiny/api");
|
9
9
|
|
10
10
|
var _deleteCommentsAfterChangeRequest = require("./deleteCommentsAfterChangeRequest");
|
11
11
|
|
@@ -29,7 +29,7 @@ const attachApwHooks = () =>
|
|
29
29
|
/**
|
30
30
|
* Hook into CMS events and execute business logic.
|
31
31
|
*/
|
32
|
-
new
|
32
|
+
new _api.ContextPlugin(async context => {
|
33
33
|
const {
|
34
34
|
security,
|
35
35
|
apw
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["attachApwHooks","ContextPlugin","context","security","apw","validateContentReview","validateChangeRequest","validateComment","createReviewerFromIdentity","initializeContentReviewSteps","updatePendingChangeRequestsCount","updateTotalCommentsCount","updateLatestCommentId","deleteCommentsAfterChangeRequest","deleteChangeRequestsWithContentReview"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/
|
1
|
+
{"version":3,"names":["attachApwHooks","ContextPlugin","context","security","apw","validateContentReview","validateChangeRequest","validateComment","createReviewerFromIdentity","initializeContentReviewSteps","updatePendingChangeRequestsCount","updateTotalCommentsCount","updateLatestCommentId","deleteCommentsAfterChangeRequest","deleteChangeRequestsWithContentReview"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\nimport { deleteCommentsAfterChangeRequest } from \"./deleteCommentsAfterChangeRequest\";\nimport { deleteChangeRequestsWithContentReview } from \"./deleteChangeRequestsAfterContentReview\";\nimport { createReviewerFromIdentity } from \"./createReviewerFromIdentity\";\nimport { initializeContentReviewSteps } from \"./initializeContentReviewSteps\";\nimport { updatePendingChangeRequestsCount } from \"./updatePendingChangeRequests\";\nimport { updateTotalCommentsCount, updateLatestCommentId } from \"./updateTotalComments\";\nimport { validateChangeRequest } from \"./validateChangeRequest\";\nimport { validateContentReview } from \"./validateContentReview\";\nimport { validateComment } from \"./validateComment\";\n\nexport const attachApwHooks = () =>\n /**\n * Hook into CMS events and execute business logic.\n */\n new ContextPlugin<ApwContext>(async context => {\n const { security, apw } = context;\n\n validateContentReview({ apw });\n\n validateChangeRequest({ apw });\n\n validateComment({ apw });\n\n createReviewerFromIdentity({ security, apw });\n\n initializeContentReviewSteps(context);\n\n updatePendingChangeRequestsCount({ apw });\n\n updateTotalCommentsCount({ apw });\n\n updateLatestCommentId({ apw });\n\n deleteCommentsAfterChangeRequest({ apw });\n\n deleteChangeRequestsWithContentReview({ apw });\n });\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,cAAc,GAAG;AAC1B;AACJ;AACA;AACI,IAAIC,kBAAJ,CAA8B,MAAMC,OAAN,IAAiB;EAC3C,MAAM;IAAEC,QAAF;IAAYC;EAAZ,IAAoBF,OAA1B;EAEA,IAAAG,4CAAA,EAAsB;IAAED;EAAF,CAAtB;EAEA,IAAAE,4CAAA,EAAsB;IAAEF;EAAF,CAAtB;EAEA,IAAAG,gCAAA,EAAgB;IAAEH;EAAF,CAAhB;EAEA,IAAAI,sDAAA,EAA2B;IAAEL,QAAF;IAAYC;EAAZ,CAA3B;EAEA,IAAAK,0DAAA,EAA6BP,OAA7B;EAEA,IAAAQ,6DAAA,EAAiC;IAAEN;EAAF,CAAjC;EAEA,IAAAO,6CAAA,EAAyB;IAAEP;EAAF,CAAzB;EAEA,IAAAQ,0CAAA,EAAsB;IAAER;EAAF,CAAtB;EAEA,IAAAS,kEAAA,EAAiC;IAAET;EAAF,CAAjC;EAEA,IAAAU,6EAAA,EAAsC;IAAEV;EAAF,CAAtC;AACH,CAtBD,CAJG"}
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.apwContentPagePlugins = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _api = require("@webiny/api");
|
9
9
|
|
10
10
|
var _types = require("../../types");
|
11
11
|
|
12
|
-
const apwContentPagePlugins = () => new
|
12
|
+
const apwContentPagePlugins = () => new _api.ContextPlugin(async context => {
|
13
13
|
const {
|
14
14
|
apw,
|
15
15
|
pageBuilder
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["apwContentPagePlugins","ContextPlugin","context","apw","pageBuilder","addContentGetter","ApwContentTypes","PAGE","id","getPage","addContentPublisher","publishPage","addContentUnPublisher","unpublishPage"],"sources":["apwContentPagePlugins.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/
|
1
|
+
{"version":3,"names":["apwContentPagePlugins","ContextPlugin","context","apw","pageBuilder","addContentGetter","ApwContentTypes","PAGE","id","getPage","addContentPublisher","publishPage","addContentUnPublisher","unpublishPage"],"sources":["apwContentPagePlugins.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { ApwContentTypes, ApwContext, PageWithWorkflow } from \"~/types\";\n\nexport const apwContentPagePlugins = () =>\n new ContextPlugin<ApwContext>(async context => {\n const { apw, pageBuilder } = context;\n\n apw.addContentGetter(ApwContentTypes.PAGE, async id => {\n return pageBuilder.getPage<PageWithWorkflow>(id);\n });\n\n apw.addContentPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.publishPage<PageWithWorkflow>(id);\n return true;\n });\n\n apw.addContentUnPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.unpublishPage<PageWithWorkflow>(id);\n return true;\n });\n });\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,qBAAqB,GAAG,MACjC,IAAIC,kBAAJ,CAA8B,MAAMC,OAAN,IAAiB;EAC3C,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAuBF,OAA7B;EAEAC,GAAG,CAACE,gBAAJ,CAAqBC,sBAAA,CAAgBC,IAArC,EAA2C,MAAMC,EAAN,IAAY;IACnD,OAAOJ,WAAW,CAACK,OAAZ,CAAsCD,EAAtC,CAAP;EACH,CAFD;EAIAL,GAAG,CAACO,mBAAJ,CAAwBJ,sBAAA,CAAgBC,IAAxC,EAA8C,MAAMC,EAAN,IAAY;IACtD,MAAMJ,WAAW,CAACO,WAAZ,CAA0CH,EAA1C,CAAN;IACA,OAAO,IAAP;EACH,CAHD;EAKAL,GAAG,CAACS,qBAAJ,CAA0BN,sBAAA,CAAgBC,IAA1C,EAAgD,MAAMC,EAAN,IAAY;IACxD,MAAMJ,WAAW,CAACS,aAAZ,CAA4CL,EAA5C,CAAN;IACA,OAAO,IAAP;EACH,CAHD;AAIH,CAhBD,CADG"}
|
@@ -1,16 +1,13 @@
|
|
1
|
-
import { HandlerPlugin } from "@webiny/handler/types";
|
2
|
-
import { ArgsContext } from "@webiny/handler-args/types";
|
3
1
|
import { ApwScheduleActionStorageOperations } from "../../types";
|
4
|
-
import {
|
5
|
-
|
6
|
-
export declare type HandlerArgs = {
|
2
|
+
import { ContextPlugin } from "@webiny/api";
|
3
|
+
export interface HandlerArgs {
|
7
4
|
datetime: string;
|
8
5
|
tenant: string;
|
9
6
|
locale: string;
|
10
|
-
futureDatetime
|
11
|
-
}
|
7
|
+
futureDatetime?: string;
|
8
|
+
}
|
12
9
|
interface Configuration {
|
13
10
|
storageOperations: ApwScheduleActionStorageOperations;
|
14
11
|
}
|
15
|
-
export declare const executeActionHandlerPlugins: (config: Configuration) => ((import("@webiny/
|
12
|
+
export declare const executeActionHandlerPlugins: (config: Configuration) => ((import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler").EventPlugin<HandlerArgs, import("@webiny/handler/types").Context, any> | ContextPlugin<import("@webiny/api/types").Context>)[];
|
16
13
|
export {};
|
@@ -7,7 +7,7 @@ exports.executeActionHandlerPlugins = void 0;
|
|
7
7
|
|
8
8
|
var _utils = require("../utils");
|
9
9
|
|
10
|
-
var
|
10
|
+
var _api = require("@webiny/api");
|
11
11
|
|
12
12
|
var _PageBuilderGraphQL = require("./plugins/PageBuilderGraphQL");
|
13
13
|
|
@@ -15,15 +15,19 @@ var _HeadlessCMSGraphQL = require("./plugins/HeadlessCMSGraphQL");
|
|
15
15
|
|
16
16
|
var _ApplicationGraphQL = require("./plugins/ApplicationGraphQL");
|
17
17
|
|
18
|
+
var _handler = require("@webiny/handler");
|
19
|
+
|
18
20
|
/**
|
19
21
|
* Handler that execute the provided action(s) for the schedule action workflow.
|
20
22
|
*/
|
21
|
-
const
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
const createExecuteActionLambda = params => {
|
24
|
+
const {
|
25
|
+
storageOperations
|
26
|
+
} = params;
|
27
|
+
return (0, _handler.createEvent)(async ({
|
28
|
+
payload,
|
29
|
+
context
|
30
|
+
}) => {
|
27
31
|
const log = console.log;
|
28
32
|
const applicationGraphQLPlugins = context.plugins.byType(_ApplicationGraphQL.ApplicationGraphQL.type);
|
29
33
|
|
@@ -56,13 +60,12 @@ const executeActionLambda = ({
|
|
56
60
|
};
|
57
61
|
|
58
62
|
try {
|
59
|
-
const {
|
60
|
-
invocationArgs: args
|
61
|
-
} = context;
|
62
63
|
const apwSettings = await (0, _utils.getApwSettings)();
|
63
64
|
const {
|
64
|
-
futureDatetime: datetime
|
65
|
-
|
65
|
+
futureDatetime: datetime,
|
66
|
+
locale,
|
67
|
+
tenant
|
68
|
+
} = payload;
|
66
69
|
/**
|
67
70
|
* If there is no datetime we bail out early.
|
68
71
|
*/
|
@@ -78,8 +81,8 @@ const executeActionLambda = ({
|
|
78
81
|
|
79
82
|
const [items] = await storageOperations.list({
|
80
83
|
where: {
|
81
|
-
tenant
|
82
|
-
locale
|
84
|
+
tenant,
|
85
|
+
locale,
|
83
86
|
datetime_startsWith: (0, _utils.getIsoStringTillMinutes)(datetime)
|
84
87
|
},
|
85
88
|
sort: ["datetime_ASC"],
|
@@ -137,12 +140,11 @@ const executeActionLambda = ({
|
|
137
140
|
} catch (e) {
|
138
141
|
log("[HANDLER_EXECUTE_ACTION] Error => ", e); // TODO: Maybe update the status like error in original item in DB.
|
139
142
|
}
|
140
|
-
}
|
141
|
-
|
142
|
-
});
|
143
|
+
});
|
144
|
+
};
|
143
145
|
|
144
|
-
const executeActionHandlerPlugins = config => [new
|
146
|
+
const executeActionHandlerPlugins = config => [new _api.ContextPlugin(async context => {
|
145
147
|
context.plugins.register([new _PageBuilderGraphQL.PageBuilderGraphQL(), new _HeadlessCMSGraphQL.HeadlessCMSGraphQL()]);
|
146
|
-
}), (0, _utils.basePlugins)(),
|
148
|
+
}), (0, _utils.basePlugins)(), createExecuteActionLambda(config)];
|
147
149
|
|
148
150
|
exports.executeActionHandlerPlugins = executeActionHandlerPlugins;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["createExecuteActionLambda","params","storageOperations","createEvent","payload","context","log","console","applicationGraphQLPlugins","plugins","byType","ApplicationGraphQL","type","length","error","applicationGraphQLPluginCache","getApplicationGraphQLPlugin","data","plugin","canUse","apwSettings","getApwSettings","futureDatetime","datetime","locale","tenant","items","list","where","datetime_startsWith","getIsoStringTillMinutes","sort","limit","item","action","JSON","stringify","name","getArn","body","getGraphQLBody","response","handlerClient","invoke","httpMethod","headers","Authorization","encodeToken","id","await","e","executeActionHandlerPlugins","config","ContextPlugin","register","PageBuilderGraphQL","HeadlessCMSGraphQL","basePlugins"],"sources":["index.ts"],"sourcesContent":["import { ApwScheduleActionData, ApwScheduleActionStorageOperations } from \"~/scheduler/types\";\nimport { getIsoStringTillMinutes, encodeToken, basePlugins } from \"~/scheduler/handlers/utils\";\nimport { getApwSettings } from \"~/scheduler/handlers/utils\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { PageBuilderGraphQL } from \"./plugins/PageBuilderGraphQL\";\nimport { HeadlessCMSGraphQL } from \"./plugins/HeadlessCMSGraphQL\";\nimport { ApplicationGraphQL } from \"./plugins/ApplicationGraphQL\";\nimport { createEvent } from \"@webiny/handler\";\n\nexport interface HandlerArgs {\n datetime: string;\n tenant: string;\n locale: string;\n futureDatetime?: string;\n}\n\ninterface Configuration {\n storageOperations: ApwScheduleActionStorageOperations;\n}\n\n/**\n * Handler that execute the provided action(s) for the schedule action workflow.\n */\nconst createExecuteActionLambda = (params: Configuration) => {\n const { storageOperations } = params;\n\n return createEvent<HandlerArgs>(async ({ payload, context }) => {\n const log = console.log;\n\n const applicationGraphQLPlugins = context.plugins.byType<ApplicationGraphQL>(\n ApplicationGraphQL.type\n );\n\n if (applicationGraphQLPlugins.length === 0) {\n console.error(`There are no plugins to determine GraphQL endpoints or mutations.`);\n return;\n }\n\n const applicationGraphQLPluginCache: Record<string, ApplicationGraphQL> = {};\n\n const getApplicationGraphQLPlugin = (\n data: ApwScheduleActionData\n ): ApplicationGraphQL | null => {\n const { type } = data;\n if (applicationGraphQLPluginCache[type]) {\n return applicationGraphQLPluginCache[type];\n }\n for (const plugin of applicationGraphQLPlugins) {\n if (!plugin.canUse(data)) {\n continue;\n }\n applicationGraphQLPluginCache[type] = plugin;\n return plugin;\n }\n return null;\n };\n\n try {\n const apwSettings = await getApwSettings();\n\n const { futureDatetime: datetime, locale, tenant } = payload;\n /**\n * If there is no datetime we bail out early.\n */\n if (!datetime || typeof datetime !== \"string\") {\n log(`Bailing out!!`);\n return;\n }\n\n /**\n * Get tasks from the DB by datetime.\n */\n const [items] = await storageOperations.list({\n where: {\n tenant,\n locale,\n datetime_startsWith: getIsoStringTillMinutes(datetime)\n },\n sort: [\"datetime_ASC\"],\n limit: 1000\n });\n\n /**\n * Execute all actions.\n */\n if (!items || items.length === 0) {\n return;\n }\n log(`Found ${items.length} actions.`);\n for (const item of items) {\n log(\n `Performing mutation \"${item.data.action}\" on \"${item.data.type}\" at \"${item.data.datetime}\"`\n );\n\n const plugin = getApplicationGraphQLPlugin(item.data);\n if (!plugin) {\n console.error(\n `There is no plugin to determine GraphQL endpoint and mutations for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n const name = plugin.getArn(apwSettings);\n\n const body = plugin.getGraphQLBody(item.data);\n\n if (!body) {\n console.error(\n `There is no GraphQL body defined, in the Plugin, for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n // Perform the actual action call.\n const response = await context.handlerClient.invoke({\n name,\n payload: {\n httpMethod: \"POST\",\n headers: {\n Authorization: encodeToken({\n id: item.id,\n locale: item.locale,\n tenant: item.tenant\n })\n },\n body: JSON.stringify(body)\n },\n await: true\n });\n console.log(JSON.stringify({ body: response.body }, null, 2));\n\n // TODO: Maybe update the status like error in original item in DB.\n }\n } catch (e) {\n log(\"[HANDLER_EXECUTE_ACTION] Error => \", e);\n // TODO: Maybe update the status like error in original item in DB.\n }\n });\n};\n\nexport const executeActionHandlerPlugins = (config: Configuration) => [\n new ContextPlugin(async context => {\n context.plugins.register([new PageBuilderGraphQL(), new HeadlessCMSGraphQL()]);\n }),\n basePlugins(),\n createExecuteActionLambda(config)\n];\n"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAaA;AACA;AACA;AACA,MAAMA,yBAAyB,GAAIC,MAAD,IAA2B;EACzD,MAAM;IAAEC;EAAF,IAAwBD,MAA9B;EAEA,OAAO,IAAAE,oBAAA,EAAyB,OAAO;IAAEC,OAAF;IAAWC;EAAX,CAAP,KAAgC;IAC5D,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAApB;IAEA,MAAME,yBAAyB,GAAGH,OAAO,CAACI,OAAR,CAAgBC,MAAhB,CAC9BC,sCAAA,CAAmBC,IADW,CAAlC;;IAIA,IAAIJ,yBAAyB,CAACK,MAA1B,KAAqC,CAAzC,EAA4C;MACxCN,OAAO,CAACO,KAAR,CAAe,mEAAf;MACA;IACH;;IAED,MAAMC,6BAAiE,GAAG,EAA1E;;IAEA,MAAMC,2BAA2B,GAC7BC,IADgC,IAEJ;MAC5B,MAAM;QAAEL;MAAF,IAAWK,IAAjB;;MACA,IAAIF,6BAA6B,CAACH,IAAD,CAAjC,EAAyC;QACrC,OAAOG,6BAA6B,CAACH,IAAD,CAApC;MACH;;MACD,KAAK,MAAMM,MAAX,IAAqBV,yBAArB,EAAgD;QAC5C,IAAI,CAACU,MAAM,CAACC,MAAP,CAAcF,IAAd,CAAL,EAA0B;UACtB;QACH;;QACDF,6BAA6B,CAACH,IAAD,CAA7B,GAAsCM,MAAtC;QACA,OAAOA,MAAP;MACH;;MACD,OAAO,IAAP;IACH,CAfD;;IAiBA,IAAI;MACA,MAAME,WAAW,GAAG,MAAM,IAAAC,qBAAA,GAA1B;MAEA,MAAM;QAAEC,cAAc,EAAEC,QAAlB;QAA4BC,MAA5B;QAAoCC;MAApC,IAA+CrB,OAArD;MACA;AACZ;AACA;;MACY,I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1
|
+
import { ContextPlugin } from "@webiny/api";
|
2
2
|
import { CreateApwContextParams } from "../../types";
|
3
3
|
import { ApwContext } from "../../../types";
|
4
4
|
export declare const createCustomAuth: ({ storageOperations }: CreateApwContextParams) => ContextPlugin<ApwContext>;
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.createCustomAuth = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _api = require("@webiny/api");
|
9
9
|
|
10
10
|
var _utils = require("../utils");
|
11
11
|
|
12
12
|
const createCustomAuth = ({
|
13
13
|
storageOperations
|
14
14
|
}) => {
|
15
|
-
return new
|
15
|
+
return new _api.ContextPlugin(({
|
16
16
|
security
|
17
17
|
}) => {
|
18
18
|
let hasApwToken = false;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createCustomAuth","storageOperations","ContextPlugin","security","hasApwToken","addAuthenticator","token","startsWith","TOKEN_PREFIX","id","tenant","locale","decodeToken","item","get","where","createdBy","addAuthorizer","name"],"sources":["security.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/
|
1
|
+
{"version":3,"names":["createCustomAuth","storageOperations","ContextPlugin","security","hasApwToken","addAuthenticator","token","startsWith","TOKEN_PREFIX","id","tenant","locale","decodeToken","item","get","where","createdBy","addAuthorizer","name"],"sources":["security.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { CreateApwContextParams } from \"~/scheduler/types\";\nimport { decodeToken, TOKEN_PREFIX } from \"~/scheduler/handlers/utils\";\nimport { ApwContext } from \"~/types\";\n\nexport const createCustomAuth = ({ storageOperations }: CreateApwContextParams) => {\n return new ContextPlugin<ApwContext>(({ security }) => {\n let hasApwToken = false;\n\n security.addAuthenticator(async token => {\n if (!token.startsWith(TOKEN_PREFIX)) {\n return null;\n }\n\n const { id, tenant, locale } = decodeToken(token);\n /**\n * No point in going further if any piece of information is missing.\n */\n if (!id || !tenant || !locale) {\n return null;\n }\n /**\n * We must verify that action we are trying to execute actually exists.\n */\n const item = await storageOperations.get({\n where: {\n id,\n tenant,\n locale\n }\n });\n\n if (!item) {\n return null;\n }\n\n hasApwToken = true;\n\n return item.createdBy;\n });\n\n security.addAuthorizer(async () => {\n if (!hasApwToken) {\n return null;\n }\n return [{ name: \"*\" }];\n });\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAGO,MAAMA,gBAAgB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAmD;EAC/E,OAAO,IAAIC,kBAAJ,CAA8B,CAAC;IAAEC;EAAF,CAAD,KAAkB;IACnD,IAAIC,WAAW,GAAG,KAAlB;IAEAD,QAAQ,CAACE,gBAAT,CAA0B,MAAMC,KAAN,IAAe;MACrC,IAAI,CAACA,KAAK,CAACC,UAAN,CAAiBC,mBAAjB,CAAL,EAAqC;QACjC,OAAO,IAAP;MACH;;MAED,MAAM;QAAEC,EAAF;QAAMC,MAAN;QAAcC;MAAd,IAAyB,IAAAC,kBAAA,EAAYN,KAAZ,CAA/B;MACA;AACZ;AACA;;MACY,IAAI,CAACG,EAAD,IAAO,CAACC,MAAR,IAAkB,CAACC,MAAvB,EAA+B;QAC3B,OAAO,IAAP;MACH;MACD;AACZ;AACA;;;MACY,MAAME,IAAI,GAAG,MAAMZ,iBAAiB,CAACa,GAAlB,CAAsB;QACrCC,KAAK,EAAE;UACHN,EADG;UAEHC,MAFG;UAGHC;QAHG;MAD8B,CAAtB,CAAnB;;MAQA,IAAI,CAACE,IAAL,EAAW;QACP,OAAO,IAAP;MACH;;MAEDT,WAAW,GAAG,IAAd;MAEA,OAAOS,IAAI,CAACG,SAAZ;IACH,CA9BD;IAgCAb,QAAQ,CAACc,aAAT,CAAuB,YAAY;MAC/B,IAAI,CAACb,WAAL,EAAkB;QACd,OAAO,IAAP;MACH;;MACD,OAAO,CAAC;QAAEc,IAAI,EAAE;MAAR,CAAD,CAAP;IACH,CALD;EAMH,CAzCM,CAAP;AA0CH,CA3CM"}
|
@@ -1,17 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
/**
|
2
|
+
* This logic/file should be moved somewhere else as it is relying on AWS specific stuff.
|
3
|
+
*/
|
4
4
|
import { ApwScheduleActionStorageOperations } from "../../types";
|
5
5
|
export declare enum InvocationTypes {
|
6
6
|
SCHEDULED = "scheduled"
|
7
7
|
}
|
8
|
-
export
|
8
|
+
export interface HandlerArgs {
|
9
9
|
datetime: string;
|
10
10
|
tenant: string;
|
11
11
|
locale: string;
|
12
12
|
invocationType?: InvocationTypes;
|
13
13
|
futureDatetime?: string;
|
14
|
-
}
|
14
|
+
}
|
15
15
|
export interface Configuration {
|
16
16
|
cwClient: any;
|
17
17
|
storageOperations: ApwScheduleActionStorageOperations;
|
@@ -19,4 +19,4 @@ export interface Configuration {
|
|
19
19
|
executeAction: string;
|
20
20
|
};
|
21
21
|
}
|
22
|
-
export declare const scheduleActionHandlerPlugins: (config: Configuration) => ((import("@webiny/
|
22
|
+
export declare const scheduleActionHandlerPlugins: (config: Configuration) => ((import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler-aws").RawEventHandler<HandlerArgs, import("@webiny/handler/types").Context, any>)[];
|
@@ -13,6 +13,8 @@ var _utils = require("../utils");
|
|
13
13
|
|
14
14
|
var _scheduleAction = require("./scheduleAction.utils");
|
15
15
|
|
16
|
+
var _handlerAws = require("@webiny/handler-aws");
|
17
|
+
|
16
18
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
17
19
|
|
18
20
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
@@ -29,30 +31,32 @@ const log = console.log;
|
|
29
31
|
* Handler that creates a cloudwatch event rule for the schedule action workflow.
|
30
32
|
*/
|
31
33
|
|
32
|
-
const
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
const createScheduleActionLambda = params => {
|
35
|
+
const {
|
36
|
+
cwClient: cloudWatchEventClient,
|
37
|
+
storageOperations,
|
38
|
+
handlers
|
39
|
+
} = params;
|
40
|
+
return (0, _handlerAws.createRawEventHandler)(async ({
|
41
|
+
payload,
|
42
|
+
context,
|
43
|
+
lambdaContext: eventContext
|
44
|
+
}) => {
|
40
45
|
try {
|
41
46
|
const {
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
} =
|
46
|
-
const [, eventContext] = originalArgs;
|
47
|
+
locale,
|
48
|
+
tenant,
|
49
|
+
invocationType
|
50
|
+
} = payload;
|
47
51
|
/**
|
48
52
|
* If invocationType is "scheduled", execute the action.
|
49
53
|
*/
|
50
54
|
|
51
|
-
if (
|
55
|
+
if (invocationType === InvocationTypes.SCHEDULED) {
|
52
56
|
await (0, _scheduleAction.executeTask)({
|
53
|
-
args,
|
57
|
+
args: payload,
|
54
58
|
lambdaName: handlers.executeAction,
|
55
|
-
handlerClient,
|
59
|
+
handlerClient: context.handlerClient,
|
56
60
|
storageOperations
|
57
61
|
});
|
58
62
|
}
|
@@ -63,8 +67,8 @@ const scheduleActionLambda = ({
|
|
63
67
|
|
64
68
|
const currentTask = await storageOperations.getCurrentTask({
|
65
69
|
where: {
|
66
|
-
tenant
|
67
|
-
locale
|
70
|
+
tenant,
|
71
|
+
locale
|
68
72
|
}
|
69
73
|
});
|
70
74
|
/**
|
@@ -73,8 +77,8 @@ const scheduleActionLambda = ({
|
|
73
77
|
|
74
78
|
const [[nextItem]] = await storageOperations.list({
|
75
79
|
where: {
|
76
|
-
tenant
|
77
|
-
locale
|
80
|
+
tenant,
|
81
|
+
locale
|
78
82
|
},
|
79
83
|
sort: ["datetime_ASC"],
|
80
84
|
limit: 1
|
@@ -119,12 +123,12 @@ const scheduleActionLambda = ({
|
|
119
123
|
*/
|
120
124
|
|
121
125
|
if (currentTaskDatetime && (0, _utils.shouldRestoreDatetime)({
|
122
|
-
invocationType
|
126
|
+
invocationType,
|
123
127
|
datetime: currentTaskDatetime
|
124
128
|
})) {
|
125
129
|
await (0, _scheduleAction.restoreDateTime)({
|
126
|
-
tenant
|
127
|
-
locale
|
130
|
+
tenant,
|
131
|
+
locale,
|
128
132
|
task: currentTask,
|
129
133
|
storageOperations
|
130
134
|
});
|
@@ -140,8 +144,8 @@ const scheduleActionLambda = ({
|
|
140
144
|
invokedFunctionArn: eventContext.invokedFunctionArn,
|
141
145
|
datetime: nextItem.data.datetime,
|
142
146
|
futureDatetime: futureDatetime,
|
143
|
-
tenant
|
144
|
-
locale
|
147
|
+
tenant,
|
148
|
+
locale
|
145
149
|
});
|
146
150
|
/**
|
147
151
|
* Update current task.
|
@@ -150,13 +154,12 @@ const scheduleActionLambda = ({
|
|
150
154
|
await storageOperations.updateCurrentTask({
|
151
155
|
item: nextItem
|
152
156
|
});
|
153
|
-
} catch (
|
154
|
-
log("[HANDLER_CREATE_RULE] Error => ",
|
157
|
+
} catch (ex) {
|
158
|
+
log("[HANDLER_CREATE_RULE] Error => ", ex); // TODO: Handler error. Maybe save it into DB.
|
155
159
|
}
|
156
|
-
}
|
157
|
-
|
158
|
-
});
|
160
|
+
});
|
161
|
+
};
|
159
162
|
|
160
|
-
const scheduleActionHandlerPlugins = config => [(0, _utils.basePlugins)(),
|
163
|
+
const scheduleActionHandlerPlugins = config => [(0, _utils.basePlugins)(), createScheduleActionLambda(config)];
|
161
164
|
|
162
165
|
exports.scheduleActionHandlerPlugins = scheduleActionHandlerPlugins;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["InvocationTypes","log","console","
|
1
|
+
{"version":3,"names":["InvocationTypes","log","console","createScheduleActionLambda","params","cwClient","cloudWatchEventClient","storageOperations","handlers","createRawEventHandler","payload","context","lambdaContext","eventContext","locale","tenant","invocationType","SCHEDULED","executeTask","args","lambdaName","executeAction","handlerClient","currentTask","getCurrentTask","where","nextItem","list","sort","limit","nextTaskDatetime","data","datetime","currentTaskDatetime","isDateTimeInNextCentury","shouldScheduleTask","futureDatetime","moveDateTimeToNextCentury","update","item","input","shouldRestoreDatetime","restoreDateTime","task","scheduleLambdaExecution","invokedFunctionArn","updateCurrentTask","ex","scheduleActionHandlerPlugins","config","basePlugins"],"sources":["index.ts"],"sourcesContent":["/**\n * This logic/file should be moved somewhere else as it is relying on AWS specific stuff.\n */\nimport { ApwScheduleActionStorageOperations } from \"~/scheduler/types\";\nimport {\n isDateTimeInNextCentury,\n moveDateTimeToNextCentury,\n shouldRestoreDatetime,\n basePlugins\n} from \"~/scheduler/handlers/utils\";\nimport {\n executeTask,\n shouldScheduleTask,\n restoreDateTime,\n scheduleLambdaExecution\n} from \"./scheduleAction.utils\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\n\nexport enum InvocationTypes {\n SCHEDULED = \"scheduled\"\n}\n\nexport interface HandlerArgs {\n datetime: string;\n tenant: string;\n locale: string;\n invocationType?: InvocationTypes;\n futureDatetime?: string;\n}\n\nexport interface Configuration {\n cwClient: any;\n storageOperations: ApwScheduleActionStorageOperations;\n handlers: {\n executeAction: string;\n };\n}\n\nconst log = console.log;\n\n/**\n * Handler that creates a cloudwatch event rule for the schedule action workflow.\n */\nconst createScheduleActionLambda = (params: Configuration) => {\n const { cwClient: cloudWatchEventClient, storageOperations, handlers } = params;\n\n return createRawEventHandler<HandlerArgs>(\n async ({ payload, context, lambdaContext: eventContext }) => {\n try {\n const { locale, tenant, invocationType } = payload;\n /**\n * If invocationType is \"scheduled\", execute the action.\n */\n if (invocationType === InvocationTypes.SCHEDULED) {\n await executeTask({\n args: payload,\n lambdaName: handlers.executeAction,\n handlerClient: context.handlerClient,\n storageOperations\n });\n }\n\n /**\n * Get current scheduled task from the DB.\n */\n const currentTask = await storageOperations.getCurrentTask({\n where: {\n tenant,\n locale\n }\n });\n\n /**\n * Get next task from the DB.\n */\n const [[nextItem]] = await storageOperations.list({\n where: {\n tenant,\n locale\n },\n sort: [\"datetime_ASC\"],\n limit: 1\n });\n\n if (!nextItem) {\n log(`No item found.`);\n return;\n }\n\n const nextTaskDatetime = nextItem.data.datetime;\n const currentTaskDatetime = currentTask && currentTask.data.datetime;\n\n if (isDateTimeInNextCentury(nextTaskDatetime)) {\n log(`Already processed the task.`);\n return;\n }\n\n if (!shouldScheduleTask(nextTaskDatetime, currentTaskDatetime)) {\n log(`Already scheduled the task.`);\n return;\n }\n\n const futureDatetime = moveDateTimeToNextCentury(nextItem.data.datetime);\n /**\n * Update \"datetime\" to a future date to mark it as scheduled.\n */\n log(`Update task's datetime to `, futureDatetime);\n await storageOperations.update({\n item: {\n ...nextItem,\n data: { ...nextItem.data, datetime: futureDatetime }\n },\n input: { ...nextItem.data, datetime: futureDatetime }\n });\n /**\n * Restore \"datetime\" of current task so that it can be schedule in next cycle.\n */\n if (\n currentTaskDatetime &&\n shouldRestoreDatetime({\n invocationType,\n datetime: currentTaskDatetime\n })\n ) {\n await restoreDateTime({\n tenant,\n locale,\n task: currentTask,\n storageOperations\n });\n }\n /**\n * Schedule Lambda\n */\n log(`Schedule Lambda Execution...`);\n await scheduleLambdaExecution({\n cloudWatchEventClient,\n invokedFunctionArn: eventContext.invokedFunctionArn,\n datetime: nextItem.data.datetime,\n futureDatetime: futureDatetime,\n tenant,\n locale\n });\n /**\n * Update current task.\n */\n await storageOperations.updateCurrentTask({ item: nextItem });\n } catch (ex) {\n log(\"[HANDLER_CREATE_RULE] Error => \", ex);\n // TODO: Handler error. Maybe save it into DB.\n }\n }\n );\n};\n\nexport const scheduleActionHandlerPlugins = (config: Configuration) => [\n basePlugins(),\n createScheduleActionLambda(config)\n];\n"],"mappings":";;;;;;;;;;;AAIA;;AAMA;;AAMA;;;;;;IAEYA,e;;;WAAAA,e;EAAAA,e;GAAAA,e,+BAAAA,e;;AAoBZ,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAApB;AAEA;AACA;AACA;;AACA,MAAME,0BAA0B,GAAIC,MAAD,IAA2B;EAC1D,MAAM;IAAEC,QAAQ,EAAEC,qBAAZ;IAAmCC,iBAAnC;IAAsDC;EAAtD,IAAmEJ,MAAzE;EAEA,OAAO,IAAAK,iCAAA,EACH,OAAO;IAAEC,OAAF;IAAWC,OAAX;IAAoBC,aAAa,EAAEC;EAAnC,CAAP,KAA6D;IACzD,IAAI;MACA,MAAM;QAAEC,MAAF;QAAUC,MAAV;QAAkBC;MAAlB,IAAqCN,OAA3C;MACA;AAChB;AACA;;MACgB,IAAIM,cAAc,KAAKhB,eAAe,CAACiB,SAAvC,EAAkD;QAC9C,MAAM,IAAAC,2BAAA,EAAY;UACdC,IAAI,EAAET,OADQ;UAEdU,UAAU,EAAEZ,QAAQ,CAACa,aAFP;UAGdC,aAAa,EAAEX,OAAO,CAACW,aAHT;UAIdf;QAJc,CAAZ,CAAN;MAMH;MAED;AAChB;AACA;;;MACgB,MAAMgB,WAAW,GAAG,MAAMhB,iBAAiB,CAACiB,cAAlB,CAAiC;QACvDC,KAAK,EAAE;UACHV,MADG;UAEHD;QAFG;MADgD,CAAjC,CAA1B;MAOA;AAChB;AACA;;MACgB,MAAM,CAAC,CAACY,QAAD,CAAD,IAAe,MAAMnB,iBAAiB,CAACoB,IAAlB,CAAuB;QAC9CF,KAAK,EAAE;UACHV,MADG;UAEHD;QAFG,CADuC;QAK9Cc,IAAI,EAAE,CAAC,cAAD,CALwC;Q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QAC1BtC,qBAD0B;QAE1BuC,kBAAkB,EAAEhC,YAAY,CAACgC,kBAFP;QAG1Bb,QAAQ,EAAEN,QAAQ,CAACK,IAAT,CAAcC,QAHE;QAI1BI,cAAc,EAAEA,cAJU;QAK1BrB,MAL0B;QAM1BD;MAN0B,CAAxB,CAAN;MAQA;AAChB;AACA;;MACgB,MAAMP,iBAAiB,CAACuC,iBAAlB,CAAoC;QAAEP,IAAI,EAAEb;MAAR,CAApC,CAAN;IACH,CAnGD,CAmGE,OAAOqB,EAAP,EAAW;MACT9C,GAAG,CAAC,iCAAD,EAAoC8C,EAApC,CAAH,CADS,CAET;IACH;EACJ,CAzGE,CAAP;AA2GH,CA9GD;;AAgHO,MAAMC,4BAA4B,GAAIC,MAAD,IAA2B,CACnE,IAAAC,kBAAA,GADmE,EAEnE/C,0BAA0B,CAAC8C,MAAD,CAFyC,CAAhE"}
|
@@ -19,7 +19,7 @@ export declare const encodeToken: ({ id, tenant, locale }: EncodeTokenParams) =>
|
|
19
19
|
export declare const TOKEN_PREFIX = "apw-";
|
20
20
|
export declare const decodeToken: (token: string) => Partial<EncodeTokenParams>;
|
21
21
|
export declare const documentClient: DocumentClient;
|
22
|
-
export declare const basePlugins: () => (import("@webiny/
|
22
|
+
export declare const basePlugins: () => (import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[];
|
23
23
|
/**
|
24
24
|
* Get APW settings record from DDB.
|
25
25
|
*/
|
package/scheduler/types.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Context } from "@webiny/
|
1
|
+
import { Context } from "@webiny/api/types";
|
2
2
|
import { SecurityIdentity, SecurityPermission } from "@webiny/api-security/types";
|
3
3
|
import { I18NLocale, I18NContext } from "@webiny/api-i18n/types";
|
4
4
|
import { Tenant } from "@webiny/api-tenancy/types";
|
package/scheduler/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ApwContentTypes","ApwScheduleActionTypes","InvocationTypes"],"sources":["types.ts"],"sourcesContent":["import { Context } from \"@webiny/
|
1
|
+
{"version":3,"names":["ApwContentTypes","ApwScheduleActionTypes","InvocationTypes"],"sources":["types.ts"],"sourcesContent":["import { Context } from \"@webiny/api/types\";\nimport { SecurityIdentity, SecurityPermission } from \"@webiny/api-security/types\";\nimport { I18NLocale, I18NContext } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\n\nexport interface ListWhere {\n /**\n * Fields.\n */\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n /**\n * Who created the entry?\n */\n createdBy?: string;\n createdBy_not?: string;\n createdBy_in?: string[];\n createdBy_not_in?: string[];\n /**\n * By datetime field.\n */\n datetime_startsWith?: string;\n}\n\nexport interface ListParams {\n where: ListWhere;\n sort?: (\"datetime_ASC\" | \"datetime_DESC\")[];\n limit?: number;\n after?: string;\n}\n\n/**\n * A interface describing the reference to a user that created some data in the database.\n *\n * @category General\n */\nexport interface CreatedBy {\n /**\n * ID if the user.\n */\n id: string;\n /**\n * Full name of the user.\n */\n displayName: string | null;\n /**\n * Type of the user (admin, user)\n */\n type: string;\n}\n\nexport interface ListMeta {\n /**\n * A cursor for pagination.\n */\n cursor: string | null;\n /**\n * Is there more items to load?\n */\n hasMoreItems: boolean;\n /**\n * Total count of the items in the storage.\n */\n totalCount: number;\n}\n\nexport enum ApwContentTypes {\n PAGE = \"page\",\n CMS_ENTRY = \"cms_entry\"\n}\n\nexport interface BaseFields {\n id: string;\n createdOn: string;\n savedOn?: string;\n createdBy: CreatedBy;\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":";;;;;;;AAkCA;AACA;AACA;AACA;AACA;IA+BYA,e;;;WAAAA,e;EAAAA,e;EAAAA,e;GAAAA,e,+BAAAA,e;;IAkBAC,sB;;;WAAAA,sB;EAAAA,sB;EAAAA,sB;GAAAA,sB,sCAAAA,sB;;IAiBAC,e;;;WAAAA,e;EAAAA,e;GAAAA,e,+BAAAA,e"}
|
package/types.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { CmsContext, CmsEntry as BaseCmsEntry, CmsModel, BeforeEntryPublishTopicParams, AfterEntryPublishTopicParams, AfterEntryUnpublishTopicParams } from "@webiny/api-headless-cms/types";
|
2
2
|
import { Page, OnBeforePageCreateTopicParams, OnBeforePageCreateFromTopicParams, OnBeforePageUpdateTopicParams, OnBeforePagePublishTopicParams, OnBeforePageRequestReviewTopicParams, PageSettings } from "@webiny/api-page-builder/types";
|
3
|
-
import { Context } from "@webiny/
|
3
|
+
import { Context } from "@webiny/api/types";
|
4
4
|
import { PageBuilderContextObject } from "@webiny/api-page-builder/graphql/types";
|
5
5
|
import { SecurityIdentity, SecurityPermission } from "@webiny/api-security/types";
|
6
6
|
import { I18NLocale } from "@webiny/api-i18n/types";
|
package/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ApwContentTypes","WorkflowScopeTypes","ApwContentReviewStepStatus","ApwWorkflowApplications","ApwWorkflowStepTypes","ApwContentReviewStatus","ApwScheduleActionTypes"],"sources":["types.ts"],"sourcesContent":["import {\n CmsContext,\n CmsEntry as BaseCmsEntry,\n CmsModel,\n BeforeEntryPublishTopicParams,\n AfterEntryPublishTopicParams,\n AfterEntryUnpublishTopicParams\n} from \"@webiny/api-headless-cms/types\";\nimport {\n Page,\n OnBeforePageCreateTopicParams,\n OnBeforePageCreateFromTopicParams,\n OnBeforePageUpdateTopicParams,\n OnBeforePagePublishTopicParams,\n OnBeforePageRequestReviewTopicParams,\n PageSettings\n} from \"@webiny/api-page-builder/types\";\nimport { Context } from \"@webiny/handler/types\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\nimport { SecurityIdentity, SecurityPermission } from \"@webiny/api-security/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { ApwScheduleActionCrud, ScheduleActionContext } from \"~/scheduler/types\";\nimport HandlerClient from \"@webiny/handler-client/HandlerClient\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { WcpContextObject } from \"@webiny/api-wcp/types\";\n\nexport interface ApwCmsEntry extends BaseCmsEntry {\n title: string;\n meta: {\n apw?: {\n contentReviewId?: string | null;\n workflowId?: string | null;\n };\n };\n}\n\nexport interface ApwFile {\n id: string;\n key: string;\n size: number;\n type: string;\n name: string;\n}\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\nexport interface ListParams {\n where?: ListWhere;\n sort?: string[];\n limit?: number;\n after?: string | null;\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 PageSettingsWithWorkflow extends PageSettings {\n apw: {\n workflowId: string;\n contentReviewId: string | null;\n };\n}\nexport interface PageWithWorkflow extends Page {\n settings: PageSettingsWithWorkflow;\n}\n\nexport type ApwOnBeforePageCreateTopicParams = OnBeforePageCreateTopicParams<PageWithWorkflow>;\n\nexport type ApwOnBeforePageCreateFromTopicParams =\n OnBeforePageCreateFromTopicParams<PageWithWorkflow>;\n\nexport type ApwOnBeforePageUpdateTopicParams = OnBeforePageUpdateTopicParams<PageWithWorkflow>;\n\nexport type ApwOnBeforePagePublishTopicParams = OnBeforePagePublishTopicParams<PageWithWorkflow>;\n\nexport type ApwOnBeforePageRequestReviewTopicParams =\n OnBeforePageRequestReviewTopicParams<PageWithWorkflow>;\n\nexport enum WorkflowScopeTypes {\n DEFAULT = \"default\",\n CUSTOM = \"custom\"\n}\n\nexport enum ApwContentReviewStepStatus {\n DONE = \"done\",\n ACTIVE = \"active\",\n INACTIVE = \"inactive\"\n}\n\nexport enum ApwWorkflowApplications {\n PB = \"pageBuilder\",\n CMS = \"cms\"\n}\n\n/**\n * A interface describing the reference to a user that created some data in the database.\n *\n * @category General\n */\nexport interface CreatedBy {\n /**\n * ID if the user.\n */\n id: string;\n /**\n * Full name of the user.\n */\n displayName: string | null;\n /**\n * Type of the user (admin, user)\n */\n type: string;\n}\n\nexport interface ApwBaseFields {\n id: string;\n createdOn: string;\n savedOn: string;\n createdBy: CreatedBy;\n}\n\nexport interface ApwReviewer extends ApwBaseFields {\n identityId: string;\n displayName: string | null;\n type: string;\n}\n\nexport interface ApwComment extends ApwBaseFields {\n body: Record<string, any>;\n changeRequest: string;\n step: string;\n media: ApwFile;\n}\n\nexport interface ApwChangeRequest extends ApwBaseFields {\n body: Record<string, any>;\n title: string;\n resolved: boolean;\n step: string;\n media: ApwFile;\n}\n\nexport interface ApwContentReviewStep {\n type: ApwWorkflowStepTypes;\n title: string;\n slug: string;\n reviewers: ApwReviewer[];\n status: ApwContentReviewStepStatus;\n pendingChangeRequests: number;\n totalComments: number;\n signOffProvidedOn: string | null;\n signOffProvidedBy: CreatedBy | null;\n}\n\nexport interface ApwContentReview extends ApwBaseFields {\n title: string;\n status: ApwContentReviewStatus;\n content: ApwContentReviewContent;\n steps: Array<ApwContentReviewStep>;\n latestCommentId: string | null;\n}\n\nexport interface ApwWorkflow extends ApwBaseFields {\n title: string;\n steps: ApwWorkflowStep[];\n scope: ApwWorkflowScope;\n app: ApwWorkflowApplications;\n}\n\ninterface ApwWorkflowScopeCmsEntry {\n id: string;\n modelId: string;\n}\nexport interface ApwWorkflowScope {\n type: WorkflowScopeTypes;\n data: {\n categories?: string[];\n pages?: string[];\n models?: string[];\n entries?: ApwWorkflowScopeCmsEntry[];\n };\n}\n\nexport enum ApwWorkflowStepTypes {\n MANDATORY_BLOCKING = \"mandatoryBlocking\",\n MANDATORY_NON_BLOCKING = \"mandatoryNonBlocking\",\n NON_MANDATORY = \"notMandatory\"\n}\n\nexport enum ApwContentReviewStatus {\n UNDER_REVIEW = \"underReview\",\n READY_TO_BE_PUBLISHED = \"readyToBePublished\",\n PUBLISHED = \"published\"\n}\n\nexport type ApwContentReviewListFilter = ApwContentReviewStatus | \"requiresMyAttention\";\n\nexport interface ApwWorkflowStep<TReviewer = ApwReviewer> {\n title: string;\n type: ApwWorkflowStepTypes;\n reviewers: TReviewer[];\n id: string;\n}\n\nexport interface ApwContentReviewStep extends ApwWorkflowStep {\n status: ApwContentReviewStepStatus;\n pendingChangeRequests: number;\n}\n\nexport interface CreateApwWorkflowParams<TReviewer = string> {\n app: ApwWorkflowApplications;\n title: string;\n scope: ApwWorkflowScope;\n steps: ApwWorkflowStep<TReviewer>[];\n}\n\nexport interface UpdateApwWorkflowParams<TReviewer = string> {\n title?: string;\n scope?: ApwWorkflowScope;\n steps?: ApwWorkflowStep<TReviewer>[];\n}\n\nexport interface ListWorkflowsParams extends ListParams {\n where: ListWhere & {\n app?: ApwWorkflowApplications;\n };\n}\n\ninterface CreateReviewerParams {\n identityId: string;\n displayName: string | null;\n type: string;\n}\n\ninterface CreateApwCommentParams {\n body: Record<string, any>;\n changeRequest: string;\n step: string;\n media: ApwFile;\n}\n\ninterface UpdateApwCommentParams {\n body: Record<string, any>;\n}\n\ninterface CreateApwChangeRequestParams {\n title: string;\n step: string;\n body: Record<string, any>;\n resolved: boolean;\n media: Record<string, any>;\n}\n\ninterface UpdateApwChangeRequestParams {\n title: string;\n body: Record<string, any>;\n resolved: boolean;\n media: Record<string, any>;\n}\n\nenum 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 interface ApwContentReviewContent {\n id: string;\n type: ApwContentTypes;\n settings: {\n modelId?: string;\n };\n scheduledOn?: string | null;\n scheduledBy?: string | null;\n scheduledActionId?: string | null;\n publishedBy?: string | null;\n}\n\nexport interface CreateApwContentReviewParams {\n content: ApwContentReviewContent;\n}\n\ninterface UpdateApwContentReviewParams {\n title?: string;\n steps?: ApwContentReviewStep[];\n status?: ApwContentReviewStatus;\n content?: ApwContentReviewContent;\n}\n\ninterface BaseApwCrud<TEntry, TCreateEntryParams, TUpdateEntryParams> {\n get(id: string): Promise<TEntry>;\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 ApwWorkflowCrud\n extends BaseApwCrud<ApwWorkflow, CreateApwWorkflowParams, UpdateApwWorkflowParams> {\n list(params: ListWorkflowsParams): Promise<[ApwWorkflow[], ListMeta]>;\n\n /**\n * Lifecycle events\n */\n onBeforeWorkflowCreate: Topic<OnBeforeWorkflowCreateTopicParams>;\n onAfterWorkflowCreate: Topic<OnAfterWorkflowCreateTopicParams>;\n onBeforeWorkflowUpdate: Topic<OnBeforeWorkflowUpdateTopicParams>;\n onAfterWorkflowUpdate: Topic<OnAfterWorkflowUpdateTopicParams>;\n onBeforeWorkflowDelete: Topic<OnBeforeWorkflowDeleteTopicParams>;\n onAfterWorkflowDelete: Topic<OnAfterWorkflowDeleteTopicParams>;\n}\n\nexport interface ApwReviewerListParams extends ListParams {\n where: ListParams[\"where\"] & {\n identityId?: string;\n };\n}\n\nexport interface ApwReviewerCrud\n extends BaseApwCrud<ApwReviewer, CreateReviewerParams, UpdateApwReviewerData> {\n list(params: ApwReviewerListParams): Promise<[ApwReviewer[], ListMeta]>;\n\n /**\n * Lifecycle events\n */\n onBeforeReviewerCreate: Topic<OnBeforeReviewerCreateTopicParams>;\n onAfterReviewerCreate: Topic<OnAfterReviewerCreateTopicParams>;\n onBeforeReviewerUpdate: Topic<OnBeforeReviewerUpdateTopicParams>;\n onAfterReviewerUpdate: Topic<OnAfterReviewerUpdateTopicParams>;\n onBeforeReviewerDelete: Topic<OnBeforeReviewerDeleteTopicParams>;\n onAfterReviewerDelete: Topic<OnAfterReviewerDeleteTopicParams>;\n}\n\nexport interface ApwCommentListParams extends ListParams {\n where: ListParams[\"where\"] & {\n changeRequest?: {\n id?: string;\n };\n };\n}\n\nexport interface ApwCommentCrud\n extends BaseApwCrud<ApwComment, CreateApwCommentParams, UpdateApwCommentParams> {\n list(params: ApwCommentListParams): Promise<[ApwComment[], ListMeta]>;\n\n /**\n * Lifecycle events\n */\n onBeforeCommentCreate: Topic<OnBeforeCommentCreateTopicParams>;\n onAfterCommentCreate: Topic<OnAfterCommentCreateTopicParams>;\n onBeforeCommentUpdate: Topic<OnBeforeCommentUpdateTopicParams>;\n onAfterCommentUpdate: Topic<OnAfterCommentUpdateTopicParams>;\n onBeforeCommentDelete: Topic<OnBeforeCommentDeleteTopicParams>;\n onAfterCommentDelete: Topic<OnAfterCommentDeleteTopicParams>;\n}\n\nexport interface ApwChangeRequestListParams extends ListParams {\n where: ListParams[\"where\"] & {\n step?: string;\n };\n}\n\nexport interface ApwChangeRequestCrud\n extends BaseApwCrud<\n ApwChangeRequest,\n CreateApwChangeRequestParams,\n UpdateApwChangeRequestParams\n > {\n list(params: ApwChangeRequestListParams): Promise<[ApwChangeRequest[], ListMeta]>;\n\n /**\n * Lifecycle events\n */\n onBeforeChangeRequestCreate: Topic<OnBeforeChangeRequestCreateTopicParams>;\n onAfterChangeRequestCreate: Topic<OnAfterChangeRequestCreateTopicParams>;\n onBeforeChangeRequestUpdate: Topic<OnBeforeChangeRequestUpdateTopicParams>;\n onAfterChangeRequestUpdate: Topic<OnAfterChangeRequestUpdateTopicParams>;\n onBeforeChangeRequestDelete: Topic<OnBeforeChangeRequestDeleteTopicParams>;\n onAfterChangeRequestDelete: Topic<OnAfterChangeRequestDeleteTopicParams>;\n}\n\nexport interface ApwContentReviewCrud\n extends BaseApwCrud<\n ApwContentReview,\n CreateApwContentReviewParams,\n UpdateApwContentReviewParams\n > {\n list(params: ApwContentReviewListParams): Promise<[ApwContentReview[], ListMeta]>;\n\n provideSignOff(id: string, step: string): Promise<Boolean>;\n\n retractSignOff(id: string, step: string): Promise<Boolean>;\n\n isReviewRequired(data: ApwContentReviewContent): Promise<{\n isReviewRequired: boolean;\n contentReviewId?: string | null;\n }>;\n\n publishContent(id: string, datetime?: string): Promise<Boolean>;\n\n unpublishContent(id: string, datetime?: string): Promise<Boolean>;\n\n scheduleAction(data: ApwScheduleActionData): Promise<string>;\n\n deleteScheduledAction(id: string): Promise<boolean>;\n\n /**\n * Lifecycle events\n */\n onBeforeContentReviewCreate: Topic<OnBeforeContentReviewCreateTopicParams>;\n onAfterContentReviewCreate: Topic<OnAfterContentReviewCreateTopicParams>;\n onBeforeContentReviewUpdate: Topic<OnBeforeContentReviewUpdateTopicParams>;\n onAfterContentReviewUpdate: Topic<OnAfterContentReviewUpdateTopicParams>;\n onBeforeContentReviewDelete: Topic<OnBeforeContentReviewDeleteTopicParams>;\n onAfterContentReviewDelete: Topic<OnAfterContentReviewDeleteTopicParams>;\n}\n\nexport type ContentGetter = (\n id: string,\n settings: { modelId?: string }\n) => Promise<PageWithWorkflow | ApwCmsEntry | null>;\n\nexport type ContentPublisher = (\n id: string,\n settings: { modelId?: string }\n) => Promise<Boolean | null>;\n\nexport type ContentUnPublisher = (\n id: string,\n settings: { modelId?: string }\n) => Promise<Boolean | null>;\n\nexport interface AdvancedPublishingWorkflow {\n addContentGetter: (type: ApwContentTypes, func: ContentGetter) => void;\n getContentGetter: (type: ApwContentTypes) => ContentGetter;\n addContentPublisher: (type: ApwContentTypes, func: ContentPublisher) => void;\n getContentPublisher: (type: ApwContentTypes) => ContentPublisher;\n addContentUnPublisher: (type: ApwContentTypes, func: ContentUnPublisher) => void;\n getContentUnPublisher: (type: ApwContentTypes) => ContentUnPublisher;\n workflow: ApwWorkflowCrud;\n reviewer: ApwReviewerCrud;\n comment: ApwCommentCrud;\n changeRequest: ApwChangeRequestCrud;\n contentReview: ApwContentReviewCrud;\n scheduleAction: ApwScheduleActionCrud;\n}\n\nexport interface ApwContext extends Context, CmsContext {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n wcp: WcpContextObject;\n scheduleAction: ScheduleActionContext[\"scheduleAction\"];\n}\n\nexport interface LifeCycleHookCallbackParams {\n apw: ApwContext[\"apw\"];\n security: ApwContext[\"security\"];\n cms?: ApwContext[\"cms\"];\n}\n\nexport interface CreateApwParams {\n getLocale: () => I18NLocale;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n getPermission: (name: string) => Promise<SecurityPermission | null>;\n storageOperations: ApwStorageOperations;\n scheduler: ApwScheduleActionCrud;\n handlerClient: HandlerClient;\n plugins: PluginsContainer;\n}\n\ninterface StorageOperationsGetReviewerParams {\n id: string;\n}\n\ntype StorageOperationsListReviewersParams = ApwReviewerListParams;\n\ninterface CreateApwReviewerData {\n identityId: string;\n displayName: string | null;\n type: string;\n}\n\ninterface UpdateApwReviewerData {\n identityId: string;\n displayName: string | null;\n type: string;\n}\n\ninterface StorageOperationsCreateReviewerParams {\n data: CreateApwReviewerData;\n}\n\ninterface StorageOperationsUpdateReviewerParams {\n id: string;\n data: UpdateApwReviewerData;\n}\n\ninterface StorageOperationsDeleteReviewerParams {\n id: string;\n}\n\ninterface StorageOperationsGetParams {\n id: string;\n}\n\ninterface StorageOperationsDeleteParams {\n id: string;\n}\n\ntype StorageOperationsGetWorkflowParams = StorageOperationsGetParams;\n\ntype StorageOperationsListWorkflowsParams = ListParams;\n\ninterface StorageOperationsCreateWorkflowParams {\n data: CreateApwWorkflowParams;\n}\n\ninterface StorageOperationsUpdateWorkflowParams {\n id: string;\n data: UpdateApwWorkflowParams;\n}\n\ntype StorageOperationsDeleteWorkflowParams = StorageOperationsDeleteParams;\ntype StorageOperationsGetContentReviewParams = StorageOperationsGetParams;\n\nexport interface ApwContentReviewListParams extends ListParams {\n where?: ListWhere & {\n status?: ApwContentReviewListFilter;\n title?: string;\n title_contains?: string;\n };\n}\n\ntype StorageOperationsListContentReviewsParams = ApwContentReviewListParams;\n\ninterface StorageOperationsCreateContentReviewParams {\n data: CreateApwContentReviewParams;\n}\n\ninterface StorageOperationsUpdateContentReviewParams {\n id: string;\n data: UpdateApwContentReviewParams;\n}\n\ntype StorageOperationsDeleteContentReviewParams = StorageOperationsDeleteParams;\n\ntype StorageOperationsGetChangeRequestParams = StorageOperationsGetParams;\ntype StorageOperationsListChangeRequestsParams = ApwChangeRequestListParams;\n\ninterface StorageOperationsCreateChangeRequestParams {\n data: CreateApwChangeRequestParams;\n}\n\ninterface StorageOperationsUpdateChangeRequestParams {\n id: string;\n data: UpdateApwChangeRequestParams;\n}\n\ntype StorageOperationsDeleteChangeRequestParams = StorageOperationsDeleteParams;\n\ntype StorageOperationsGetCommentParams = StorageOperationsGetParams;\n\ntype StorageOperationsDeleteCommentParams = StorageOperationsDeleteParams;\ntype StorageOperationsListCommentsParams = ApwCommentListParams;\n\ninterface StorageOperationsCreateCommentParams {\n data: CreateApwCommentParams;\n}\n\ninterface StorageOperationsUpdateCommentParams {\n id: string;\n data: UpdateApwCommentParams;\n}\n\nexport interface ApwReviewerStorageOperations {\n /*\n * Reviewer methods\n */\n getReviewer(params: StorageOperationsGetReviewerParams): Promise<ApwReviewer>;\n\n listReviewers(params: StorageOperationsListReviewersParams): Promise<[ApwReviewer[], ListMeta]>;\n\n createReviewer(params: StorageOperationsCreateReviewerParams): Promise<ApwReviewer>;\n\n updateReviewer(params: StorageOperationsUpdateReviewerParams): Promise<ApwReviewer>;\n\n deleteReviewer(params: StorageOperationsDeleteReviewerParams): Promise<Boolean>;\n}\n\nexport interface ApwWorkflowStorageOperations {\n /*\n * Workflow methods\n */\n getWorkflow(params: StorageOperationsGetWorkflowParams): Promise<ApwWorkflow>;\n\n listWorkflows(params: StorageOperationsListWorkflowsParams): Promise<[ApwWorkflow[], ListMeta]>;\n\n createWorkflow(params: StorageOperationsCreateWorkflowParams): Promise<ApwWorkflow>;\n\n updateWorkflow(params: StorageOperationsUpdateWorkflowParams): Promise<ApwWorkflow>;\n\n deleteWorkflow(params: StorageOperationsDeleteWorkflowParams): Promise<Boolean>;\n}\n\nexport interface ApwContentReviewStorageOperations {\n /*\n * ContentReview methods\n */\n getContentReview(params: StorageOperationsGetContentReviewParams): Promise<ApwContentReview>;\n\n listContentReviews(\n params: StorageOperationsListContentReviewsParams\n ): Promise<[ApwContentReview[], ListMeta]>;\n\n createContentReview(\n params: StorageOperationsCreateContentReviewParams\n ): Promise<ApwContentReview>;\n\n updateContentReview(\n params: StorageOperationsUpdateContentReviewParams\n ): Promise<ApwContentReview>;\n\n deleteContentReview(params: StorageOperationsDeleteContentReviewParams): Promise<Boolean>;\n}\n\nexport interface ApwChangeRequestStorageOperations {\n /*\n * ChangeRequest methods\n */\n getChangeRequest(params: StorageOperationsGetChangeRequestParams): Promise<ApwChangeRequest>;\n\n listChangeRequests(\n params: StorageOperationsListChangeRequestsParams\n ): Promise<[ApwChangeRequest[], ListMeta]>;\n\n createChangeRequest(\n params: StorageOperationsCreateChangeRequestParams\n ): Promise<ApwChangeRequest>;\n\n updateChangeRequest(\n params: StorageOperationsUpdateChangeRequestParams\n ): Promise<ApwChangeRequest>;\n\n deleteChangeRequest(params: StorageOperationsDeleteChangeRequestParams): Promise<Boolean>;\n}\n\nexport interface ApwCommentStorageOperations {\n /*\n * Comment methods\n */\n getComment(params: StorageOperationsGetCommentParams): Promise<ApwComment>;\n\n listComments(params: StorageOperationsListCommentsParams): Promise<[ApwComment[], ListMeta]>;\n\n createComment(params: StorageOperationsCreateCommentParams): Promise<ApwComment>;\n\n updateComment(params: StorageOperationsUpdateCommentParams): Promise<ApwComment>;\n\n deleteComment(params: StorageOperationsDeleteCommentParams): Promise<Boolean>;\n}\n\nexport interface ApwStorageOperations\n extends ApwReviewerStorageOperations,\n ApwWorkflowStorageOperations,\n ApwContentReviewStorageOperations,\n ApwChangeRequestStorageOperations,\n ApwCommentStorageOperations {}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeCommentCreateTopicParams {\n input: CreateApwCommentParams;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterCommentCreateTopicParams {\n comment: ApwComment;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeCommentUpdateTopicParams {\n original: ApwComment;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterCommentUpdateTopicParams {\n original: ApwComment;\n comment: ApwComment;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeCommentDeleteTopicParams {\n comment: ApwComment;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterCommentDeleteTopicParams {\n comment: ApwComment;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeChangeRequestCreateTopicParams {\n input: CreateApwChangeRequestParams;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterChangeRequestCreateTopicParams {\n changeRequest: ApwChangeRequest;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeChangeRequestUpdateTopicParams {\n original: ApwChangeRequest;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterChangeRequestUpdateTopicParams {\n original: ApwChangeRequest;\n changeRequest: ApwChangeRequest;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeChangeRequestDeleteTopicParams {\n changeRequest: ApwChangeRequest;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterChangeRequestDeleteTopicParams {\n changeRequest: ApwChangeRequest;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeContentReviewCreateTopicParams {\n input: CreateApwContentReviewParams;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterContentReviewCreateTopicParams {\n contentReview: ApwContentReview;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeContentReviewUpdateTopicParams {\n original: ApwContentReview;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterContentReviewUpdateTopicParams {\n original: ApwContentReview;\n contentReview: ApwContentReview;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeContentReviewDeleteTopicParams {\n contentReview: ApwContentReview;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterContentReviewDeleteTopicParams {\n contentReview: ApwContentReview;\n}\n\nexport interface CreateApwReviewerParams {\n type: string;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeReviewerCreateTopicParams {\n input: CreateApwReviewerParams;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterReviewerCreateTopicParams {\n reviewer: ApwReviewer;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeReviewerUpdateTopicParams {\n original: ApwReviewer;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterReviewerUpdateTopicParams {\n original: ApwReviewer;\n reviewer: ApwReviewer;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeReviewerDeleteTopicParams {\n reviewer: ApwReviewer;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterReviewerDeleteTopicParams {\n reviewer: ApwReviewer;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeWorkflowCreateTopicParams {\n input: CreateApwWorkflowParams;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterWorkflowCreateTopicParams {\n workflow: ApwWorkflow;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeWorkflowUpdateTopicParams {\n original: ApwWorkflow;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterWorkflowUpdateTopicParams {\n original: ApwWorkflow;\n workflow: ApwWorkflow;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeWorkflowDeleteTopicParams {\n workflow: ApwWorkflow;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterWorkflowDeleteTopicParams {\n workflow: ApwWorkflow;\n}\n\nexport type WorkflowModelDefinition = Pick<\n CmsModel,\n \"name\" | \"modelId\" | \"layout\" | \"titleFieldId\" | \"description\" | \"fields\" | \"isPrivate\"\n>;\n\n/**\n * Headless CMS\n */\nexport interface OnBeforeCmsEntryPublishTopicParams\n extends Omit<BeforeEntryPublishTopicParams, \"entry\"> {\n entry: ApwCmsEntry;\n}\nexport interface OnAfterCmsEntryPublishTopicParams\n extends Omit<AfterEntryPublishTopicParams, \"entry\"> {\n entry: ApwCmsEntry;\n}\nexport interface OnAfterCmsEntryUnpublishTopicParams\n extends Omit<AfterEntryUnpublishTopicParams, \"entry\"> {\n entry: ApwCmsEntry;\n}\n"],"mappings":";;;;;;IAqFYA,e;;;WAAAA,e;EAAAA,e;EAAAA,e;GAAAA,e,+BAAAA,e;;IA2BAC,kB;;;WAAAA,kB;EAAAA,kB;EAAAA,kB;GAAAA,kB,kCAAAA,kB;;IAKAC,0B;;;WAAAA,0B;EAAAA,0B;EAAAA,0B;EAAAA,0B;GAAAA,0B,0CAAAA,0B;;IAMAC,uB;AAKZ;AACA;AACA;AACA;AACA;;;;WATYA,uB;EAAAA,uB;EAAAA,uB;GAAAA,uB,uCAAAA,uB;;IA8FAC,oB;;;WAAAA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,oCAAAA,oB;;IAMAC,sB;;;WAAAA,sB;EAAAA,sB;EAAAA,sB;EAAAA,sB;GAAAA,sB,sCAAAA,sB;;IAuEPC,sB;;WAAAA,sB;EAAAA,sB;EAAAA,sB;GAAAA,sB,KAAAA,sB"}
|
1
|
+
{"version":3,"names":["ApwContentTypes","WorkflowScopeTypes","ApwContentReviewStepStatus","ApwWorkflowApplications","ApwWorkflowStepTypes","ApwContentReviewStatus","ApwScheduleActionTypes"],"sources":["types.ts"],"sourcesContent":["import {\n CmsContext,\n CmsEntry as BaseCmsEntry,\n CmsModel,\n BeforeEntryPublishTopicParams,\n AfterEntryPublishTopicParams,\n AfterEntryUnpublishTopicParams\n} from \"@webiny/api-headless-cms/types\";\nimport {\n Page,\n OnBeforePageCreateTopicParams,\n OnBeforePageCreateFromTopicParams,\n OnBeforePageUpdateTopicParams,\n OnBeforePagePublishTopicParams,\n OnBeforePageRequestReviewTopicParams,\n PageSettings\n} from \"@webiny/api-page-builder/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\nimport { SecurityIdentity, SecurityPermission } from \"@webiny/api-security/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { ApwScheduleActionCrud, ScheduleActionContext } from \"~/scheduler/types\";\nimport HandlerClient from \"@webiny/handler-client/HandlerClient\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { WcpContextObject } from \"@webiny/api-wcp/types\";\n\nexport interface ApwCmsEntry extends BaseCmsEntry {\n title: string;\n meta: {\n apw?: {\n contentReviewId?: string | null;\n workflowId?: string | null;\n };\n };\n}\n\nexport interface ApwFile {\n id: string;\n key: string;\n size: number;\n type: string;\n name: string;\n}\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\nexport interface ListParams {\n where?: ListWhere;\n sort?: string[];\n limit?: number;\n after?: string | null;\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 PageSettingsWithWorkflow extends PageSettings {\n apw: {\n workflowId: string;\n contentReviewId: string | null;\n };\n}\nexport interface PageWithWorkflow extends Page {\n settings: PageSettingsWithWorkflow;\n}\n\nexport type ApwOnBeforePageCreateTopicParams = OnBeforePageCreateTopicParams<PageWithWorkflow>;\n\nexport type ApwOnBeforePageCreateFromTopicParams =\n OnBeforePageCreateFromTopicParams<PageWithWorkflow>;\n\nexport type ApwOnBeforePageUpdateTopicParams = OnBeforePageUpdateTopicParams<PageWithWorkflow>;\n\nexport type ApwOnBeforePagePublishTopicParams = OnBeforePagePublishTopicParams<PageWithWorkflow>;\n\nexport type ApwOnBeforePageRequestReviewTopicParams =\n OnBeforePageRequestReviewTopicParams<PageWithWorkflow>;\n\nexport enum WorkflowScopeTypes {\n DEFAULT = \"default\",\n CUSTOM = \"custom\"\n}\n\nexport enum ApwContentReviewStepStatus {\n DONE = \"done\",\n ACTIVE = \"active\",\n INACTIVE = \"inactive\"\n}\n\nexport enum ApwWorkflowApplications {\n PB = \"pageBuilder\",\n CMS = \"cms\"\n}\n\n/**\n * A interface describing the reference to a user that created some data in the database.\n *\n * @category General\n */\nexport interface CreatedBy {\n /**\n * ID if the user.\n */\n id: string;\n /**\n * Full name of the user.\n */\n displayName: string | null;\n /**\n * Type of the user (admin, user)\n */\n type: string;\n}\n\nexport interface ApwBaseFields {\n id: string;\n createdOn: string;\n savedOn: string;\n createdBy: CreatedBy;\n}\n\nexport interface ApwReviewer extends ApwBaseFields {\n identityId: string;\n displayName: string | null;\n type: string;\n}\n\nexport interface ApwComment extends ApwBaseFields {\n body: Record<string, any>;\n changeRequest: string;\n step: string;\n media: ApwFile;\n}\n\nexport interface ApwChangeRequest extends ApwBaseFields {\n body: Record<string, any>;\n title: string;\n resolved: boolean;\n step: string;\n media: ApwFile;\n}\n\nexport interface ApwContentReviewStep {\n type: ApwWorkflowStepTypes;\n title: string;\n slug: string;\n reviewers: ApwReviewer[];\n status: ApwContentReviewStepStatus;\n pendingChangeRequests: number;\n totalComments: number;\n signOffProvidedOn: string | null;\n signOffProvidedBy: CreatedBy | null;\n}\n\nexport interface ApwContentReview extends ApwBaseFields {\n title: string;\n status: ApwContentReviewStatus;\n content: ApwContentReviewContent;\n steps: Array<ApwContentReviewStep>;\n latestCommentId: string | null;\n}\n\nexport interface ApwWorkflow extends ApwBaseFields {\n title: string;\n steps: ApwWorkflowStep[];\n scope: ApwWorkflowScope;\n app: ApwWorkflowApplications;\n}\n\ninterface ApwWorkflowScopeCmsEntry {\n id: string;\n modelId: string;\n}\nexport interface ApwWorkflowScope {\n type: WorkflowScopeTypes;\n data: {\n categories?: string[];\n pages?: string[];\n models?: string[];\n entries?: ApwWorkflowScopeCmsEntry[];\n };\n}\n\nexport enum ApwWorkflowStepTypes {\n MANDATORY_BLOCKING = \"mandatoryBlocking\",\n MANDATORY_NON_BLOCKING = \"mandatoryNonBlocking\",\n NON_MANDATORY = \"notMandatory\"\n}\n\nexport enum ApwContentReviewStatus {\n UNDER_REVIEW = \"underReview\",\n READY_TO_BE_PUBLISHED = \"readyToBePublished\",\n PUBLISHED = \"published\"\n}\n\nexport type ApwContentReviewListFilter = ApwContentReviewStatus | \"requiresMyAttention\";\n\nexport interface ApwWorkflowStep<TReviewer = ApwReviewer> {\n title: string;\n type: ApwWorkflowStepTypes;\n reviewers: TReviewer[];\n id: string;\n}\n\nexport interface ApwContentReviewStep extends ApwWorkflowStep {\n status: ApwContentReviewStepStatus;\n pendingChangeRequests: number;\n}\n\nexport interface CreateApwWorkflowParams<TReviewer = string> {\n app: ApwWorkflowApplications;\n title: string;\n scope: ApwWorkflowScope;\n steps: ApwWorkflowStep<TReviewer>[];\n}\n\nexport interface UpdateApwWorkflowParams<TReviewer = string> {\n title?: string;\n scope?: ApwWorkflowScope;\n steps?: ApwWorkflowStep<TReviewer>[];\n}\n\nexport interface ListWorkflowsParams extends ListParams {\n where: ListWhere & {\n app?: ApwWorkflowApplications;\n };\n}\n\ninterface CreateReviewerParams {\n identityId: string;\n displayName: string | null;\n type: string;\n}\n\ninterface CreateApwCommentParams {\n body: Record<string, any>;\n changeRequest: string;\n step: string;\n media: ApwFile;\n}\n\ninterface UpdateApwCommentParams {\n body: Record<string, any>;\n}\n\ninterface CreateApwChangeRequestParams {\n title: string;\n step: string;\n body: Record<string, any>;\n resolved: boolean;\n media: Record<string, any>;\n}\n\ninterface UpdateApwChangeRequestParams {\n title: string;\n body: Record<string, any>;\n resolved: boolean;\n media: Record<string, any>;\n}\n\nenum 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 interface ApwContentReviewContent {\n id: string;\n type: ApwContentTypes;\n settings: {\n modelId?: string;\n };\n scheduledOn?: string | null;\n scheduledBy?: string | null;\n scheduledActionId?: string | null;\n publishedBy?: string | null;\n}\n\nexport interface CreateApwContentReviewParams {\n content: ApwContentReviewContent;\n}\n\ninterface UpdateApwContentReviewParams {\n title?: string;\n steps?: ApwContentReviewStep[];\n status?: ApwContentReviewStatus;\n content?: ApwContentReviewContent;\n}\n\ninterface BaseApwCrud<TEntry, TCreateEntryParams, TUpdateEntryParams> {\n get(id: string): Promise<TEntry>;\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 ApwWorkflowCrud\n extends BaseApwCrud<ApwWorkflow, CreateApwWorkflowParams, UpdateApwWorkflowParams> {\n list(params: ListWorkflowsParams): Promise<[ApwWorkflow[], ListMeta]>;\n\n /**\n * Lifecycle events\n */\n onBeforeWorkflowCreate: Topic<OnBeforeWorkflowCreateTopicParams>;\n onAfterWorkflowCreate: Topic<OnAfterWorkflowCreateTopicParams>;\n onBeforeWorkflowUpdate: Topic<OnBeforeWorkflowUpdateTopicParams>;\n onAfterWorkflowUpdate: Topic<OnAfterWorkflowUpdateTopicParams>;\n onBeforeWorkflowDelete: Topic<OnBeforeWorkflowDeleteTopicParams>;\n onAfterWorkflowDelete: Topic<OnAfterWorkflowDeleteTopicParams>;\n}\n\nexport interface ApwReviewerListParams extends ListParams {\n where: ListParams[\"where\"] & {\n identityId?: string;\n };\n}\n\nexport interface ApwReviewerCrud\n extends BaseApwCrud<ApwReviewer, CreateReviewerParams, UpdateApwReviewerData> {\n list(params: ApwReviewerListParams): Promise<[ApwReviewer[], ListMeta]>;\n\n /**\n * Lifecycle events\n */\n onBeforeReviewerCreate: Topic<OnBeforeReviewerCreateTopicParams>;\n onAfterReviewerCreate: Topic<OnAfterReviewerCreateTopicParams>;\n onBeforeReviewerUpdate: Topic<OnBeforeReviewerUpdateTopicParams>;\n onAfterReviewerUpdate: Topic<OnAfterReviewerUpdateTopicParams>;\n onBeforeReviewerDelete: Topic<OnBeforeReviewerDeleteTopicParams>;\n onAfterReviewerDelete: Topic<OnAfterReviewerDeleteTopicParams>;\n}\n\nexport interface ApwCommentListParams extends ListParams {\n where: ListParams[\"where\"] & {\n changeRequest?: {\n id?: string;\n };\n };\n}\n\nexport interface ApwCommentCrud\n extends BaseApwCrud<ApwComment, CreateApwCommentParams, UpdateApwCommentParams> {\n list(params: ApwCommentListParams): Promise<[ApwComment[], ListMeta]>;\n\n /**\n * Lifecycle events\n */\n onBeforeCommentCreate: Topic<OnBeforeCommentCreateTopicParams>;\n onAfterCommentCreate: Topic<OnAfterCommentCreateTopicParams>;\n onBeforeCommentUpdate: Topic<OnBeforeCommentUpdateTopicParams>;\n onAfterCommentUpdate: Topic<OnAfterCommentUpdateTopicParams>;\n onBeforeCommentDelete: Topic<OnBeforeCommentDeleteTopicParams>;\n onAfterCommentDelete: Topic<OnAfterCommentDeleteTopicParams>;\n}\n\nexport interface ApwChangeRequestListParams extends ListParams {\n where: ListParams[\"where\"] & {\n step?: string;\n };\n}\n\nexport interface ApwChangeRequestCrud\n extends BaseApwCrud<\n ApwChangeRequest,\n CreateApwChangeRequestParams,\n UpdateApwChangeRequestParams\n > {\n list(params: ApwChangeRequestListParams): Promise<[ApwChangeRequest[], ListMeta]>;\n\n /**\n * Lifecycle events\n */\n onBeforeChangeRequestCreate: Topic<OnBeforeChangeRequestCreateTopicParams>;\n onAfterChangeRequestCreate: Topic<OnAfterChangeRequestCreateTopicParams>;\n onBeforeChangeRequestUpdate: Topic<OnBeforeChangeRequestUpdateTopicParams>;\n onAfterChangeRequestUpdate: Topic<OnAfterChangeRequestUpdateTopicParams>;\n onBeforeChangeRequestDelete: Topic<OnBeforeChangeRequestDeleteTopicParams>;\n onAfterChangeRequestDelete: Topic<OnAfterChangeRequestDeleteTopicParams>;\n}\n\nexport interface ApwContentReviewCrud\n extends BaseApwCrud<\n ApwContentReview,\n CreateApwContentReviewParams,\n UpdateApwContentReviewParams\n > {\n list(params: ApwContentReviewListParams): Promise<[ApwContentReview[], ListMeta]>;\n\n provideSignOff(id: string, step: string): Promise<Boolean>;\n\n retractSignOff(id: string, step: string): Promise<Boolean>;\n\n isReviewRequired(data: ApwContentReviewContent): Promise<{\n isReviewRequired: boolean;\n contentReviewId?: string | null;\n }>;\n\n publishContent(id: string, datetime?: string): Promise<Boolean>;\n\n unpublishContent(id: string, datetime?: string): Promise<Boolean>;\n\n scheduleAction(data: ApwScheduleActionData): Promise<string>;\n\n deleteScheduledAction(id: string): Promise<boolean>;\n\n /**\n * Lifecycle events\n */\n onBeforeContentReviewCreate: Topic<OnBeforeContentReviewCreateTopicParams>;\n onAfterContentReviewCreate: Topic<OnAfterContentReviewCreateTopicParams>;\n onBeforeContentReviewUpdate: Topic<OnBeforeContentReviewUpdateTopicParams>;\n onAfterContentReviewUpdate: Topic<OnAfterContentReviewUpdateTopicParams>;\n onBeforeContentReviewDelete: Topic<OnBeforeContentReviewDeleteTopicParams>;\n onAfterContentReviewDelete: Topic<OnAfterContentReviewDeleteTopicParams>;\n}\n\nexport type ContentGetter = (\n id: string,\n settings: { modelId?: string }\n) => Promise<PageWithWorkflow | ApwCmsEntry | null>;\n\nexport type ContentPublisher = (\n id: string,\n settings: { modelId?: string }\n) => Promise<Boolean | null>;\n\nexport type ContentUnPublisher = (\n id: string,\n settings: { modelId?: string }\n) => Promise<Boolean | null>;\n\nexport interface AdvancedPublishingWorkflow {\n addContentGetter: (type: ApwContentTypes, func: ContentGetter) => void;\n getContentGetter: (type: ApwContentTypes) => ContentGetter;\n addContentPublisher: (type: ApwContentTypes, func: ContentPublisher) => void;\n getContentPublisher: (type: ApwContentTypes) => ContentPublisher;\n addContentUnPublisher: (type: ApwContentTypes, func: ContentUnPublisher) => void;\n getContentUnPublisher: (type: ApwContentTypes) => ContentUnPublisher;\n workflow: ApwWorkflowCrud;\n reviewer: ApwReviewerCrud;\n comment: ApwCommentCrud;\n changeRequest: ApwChangeRequestCrud;\n contentReview: ApwContentReviewCrud;\n scheduleAction: ApwScheduleActionCrud;\n}\n\nexport interface ApwContext extends Context, CmsContext {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n wcp: WcpContextObject;\n scheduleAction: ScheduleActionContext[\"scheduleAction\"];\n}\n\nexport interface LifeCycleHookCallbackParams {\n apw: ApwContext[\"apw\"];\n security: ApwContext[\"security\"];\n cms?: ApwContext[\"cms\"];\n}\n\nexport interface CreateApwParams {\n getLocale: () => I18NLocale;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n getPermission: (name: string) => Promise<SecurityPermission | null>;\n storageOperations: ApwStorageOperations;\n scheduler: ApwScheduleActionCrud;\n handlerClient: HandlerClient;\n plugins: PluginsContainer;\n}\n\ninterface StorageOperationsGetReviewerParams {\n id: string;\n}\n\ntype StorageOperationsListReviewersParams = ApwReviewerListParams;\n\ninterface CreateApwReviewerData {\n identityId: string;\n displayName: string | null;\n type: string;\n}\n\ninterface UpdateApwReviewerData {\n identityId: string;\n displayName: string | null;\n type: string;\n}\n\ninterface StorageOperationsCreateReviewerParams {\n data: CreateApwReviewerData;\n}\n\ninterface StorageOperationsUpdateReviewerParams {\n id: string;\n data: UpdateApwReviewerData;\n}\n\ninterface StorageOperationsDeleteReviewerParams {\n id: string;\n}\n\ninterface StorageOperationsGetParams {\n id: string;\n}\n\ninterface StorageOperationsDeleteParams {\n id: string;\n}\n\ntype StorageOperationsGetWorkflowParams = StorageOperationsGetParams;\n\ntype StorageOperationsListWorkflowsParams = ListParams;\n\ninterface StorageOperationsCreateWorkflowParams {\n data: CreateApwWorkflowParams;\n}\n\ninterface StorageOperationsUpdateWorkflowParams {\n id: string;\n data: UpdateApwWorkflowParams;\n}\n\ntype StorageOperationsDeleteWorkflowParams = StorageOperationsDeleteParams;\ntype StorageOperationsGetContentReviewParams = StorageOperationsGetParams;\n\nexport interface ApwContentReviewListParams extends ListParams {\n where?: ListWhere & {\n status?: ApwContentReviewListFilter;\n title?: string;\n title_contains?: string;\n };\n}\n\ntype StorageOperationsListContentReviewsParams = ApwContentReviewListParams;\n\ninterface StorageOperationsCreateContentReviewParams {\n data: CreateApwContentReviewParams;\n}\n\ninterface StorageOperationsUpdateContentReviewParams {\n id: string;\n data: UpdateApwContentReviewParams;\n}\n\ntype StorageOperationsDeleteContentReviewParams = StorageOperationsDeleteParams;\n\ntype StorageOperationsGetChangeRequestParams = StorageOperationsGetParams;\ntype StorageOperationsListChangeRequestsParams = ApwChangeRequestListParams;\n\ninterface StorageOperationsCreateChangeRequestParams {\n data: CreateApwChangeRequestParams;\n}\n\ninterface StorageOperationsUpdateChangeRequestParams {\n id: string;\n data: UpdateApwChangeRequestParams;\n}\n\ntype StorageOperationsDeleteChangeRequestParams = StorageOperationsDeleteParams;\n\ntype StorageOperationsGetCommentParams = StorageOperationsGetParams;\n\ntype StorageOperationsDeleteCommentParams = StorageOperationsDeleteParams;\ntype StorageOperationsListCommentsParams = ApwCommentListParams;\n\ninterface StorageOperationsCreateCommentParams {\n data: CreateApwCommentParams;\n}\n\ninterface StorageOperationsUpdateCommentParams {\n id: string;\n data: UpdateApwCommentParams;\n}\n\nexport interface ApwReviewerStorageOperations {\n /*\n * Reviewer methods\n */\n getReviewer(params: StorageOperationsGetReviewerParams): Promise<ApwReviewer>;\n\n listReviewers(params: StorageOperationsListReviewersParams): Promise<[ApwReviewer[], ListMeta]>;\n\n createReviewer(params: StorageOperationsCreateReviewerParams): Promise<ApwReviewer>;\n\n updateReviewer(params: StorageOperationsUpdateReviewerParams): Promise<ApwReviewer>;\n\n deleteReviewer(params: StorageOperationsDeleteReviewerParams): Promise<Boolean>;\n}\n\nexport interface ApwWorkflowStorageOperations {\n /*\n * Workflow methods\n */\n getWorkflow(params: StorageOperationsGetWorkflowParams): Promise<ApwWorkflow>;\n\n listWorkflows(params: StorageOperationsListWorkflowsParams): Promise<[ApwWorkflow[], ListMeta]>;\n\n createWorkflow(params: StorageOperationsCreateWorkflowParams): Promise<ApwWorkflow>;\n\n updateWorkflow(params: StorageOperationsUpdateWorkflowParams): Promise<ApwWorkflow>;\n\n deleteWorkflow(params: StorageOperationsDeleteWorkflowParams): Promise<Boolean>;\n}\n\nexport interface ApwContentReviewStorageOperations {\n /*\n * ContentReview methods\n */\n getContentReview(params: StorageOperationsGetContentReviewParams): Promise<ApwContentReview>;\n\n listContentReviews(\n params: StorageOperationsListContentReviewsParams\n ): Promise<[ApwContentReview[], ListMeta]>;\n\n createContentReview(\n params: StorageOperationsCreateContentReviewParams\n ): Promise<ApwContentReview>;\n\n updateContentReview(\n params: StorageOperationsUpdateContentReviewParams\n ): Promise<ApwContentReview>;\n\n deleteContentReview(params: StorageOperationsDeleteContentReviewParams): Promise<Boolean>;\n}\n\nexport interface ApwChangeRequestStorageOperations {\n /*\n * ChangeRequest methods\n */\n getChangeRequest(params: StorageOperationsGetChangeRequestParams): Promise<ApwChangeRequest>;\n\n listChangeRequests(\n params: StorageOperationsListChangeRequestsParams\n ): Promise<[ApwChangeRequest[], ListMeta]>;\n\n createChangeRequest(\n params: StorageOperationsCreateChangeRequestParams\n ): Promise<ApwChangeRequest>;\n\n updateChangeRequest(\n params: StorageOperationsUpdateChangeRequestParams\n ): Promise<ApwChangeRequest>;\n\n deleteChangeRequest(params: StorageOperationsDeleteChangeRequestParams): Promise<Boolean>;\n}\n\nexport interface ApwCommentStorageOperations {\n /*\n * Comment methods\n */\n getComment(params: StorageOperationsGetCommentParams): Promise<ApwComment>;\n\n listComments(params: StorageOperationsListCommentsParams): Promise<[ApwComment[], ListMeta]>;\n\n createComment(params: StorageOperationsCreateCommentParams): Promise<ApwComment>;\n\n updateComment(params: StorageOperationsUpdateCommentParams): Promise<ApwComment>;\n\n deleteComment(params: StorageOperationsDeleteCommentParams): Promise<Boolean>;\n}\n\nexport interface ApwStorageOperations\n extends ApwReviewerStorageOperations,\n ApwWorkflowStorageOperations,\n ApwContentReviewStorageOperations,\n ApwChangeRequestStorageOperations,\n ApwCommentStorageOperations {}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeCommentCreateTopicParams {\n input: CreateApwCommentParams;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterCommentCreateTopicParams {\n comment: ApwComment;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeCommentUpdateTopicParams {\n original: ApwComment;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterCommentUpdateTopicParams {\n original: ApwComment;\n comment: ApwComment;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeCommentDeleteTopicParams {\n comment: ApwComment;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterCommentDeleteTopicParams {\n comment: ApwComment;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeChangeRequestCreateTopicParams {\n input: CreateApwChangeRequestParams;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterChangeRequestCreateTopicParams {\n changeRequest: ApwChangeRequest;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeChangeRequestUpdateTopicParams {\n original: ApwChangeRequest;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterChangeRequestUpdateTopicParams {\n original: ApwChangeRequest;\n changeRequest: ApwChangeRequest;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeChangeRequestDeleteTopicParams {\n changeRequest: ApwChangeRequest;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterChangeRequestDeleteTopicParams {\n changeRequest: ApwChangeRequest;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeContentReviewCreateTopicParams {\n input: CreateApwContentReviewParams;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterContentReviewCreateTopicParams {\n contentReview: ApwContentReview;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeContentReviewUpdateTopicParams {\n original: ApwContentReview;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterContentReviewUpdateTopicParams {\n original: ApwContentReview;\n contentReview: ApwContentReview;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeContentReviewDeleteTopicParams {\n contentReview: ApwContentReview;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterContentReviewDeleteTopicParams {\n contentReview: ApwContentReview;\n}\n\nexport interface CreateApwReviewerParams {\n type: string;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeReviewerCreateTopicParams {\n input: CreateApwReviewerParams;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterReviewerCreateTopicParams {\n reviewer: ApwReviewer;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeReviewerUpdateTopicParams {\n original: ApwReviewer;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterReviewerUpdateTopicParams {\n original: ApwReviewer;\n reviewer: ApwReviewer;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeReviewerDeleteTopicParams {\n reviewer: ApwReviewer;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterReviewerDeleteTopicParams {\n reviewer: ApwReviewer;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeWorkflowCreateTopicParams {\n input: CreateApwWorkflowParams;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterWorkflowCreateTopicParams {\n workflow: ApwWorkflow;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeWorkflowUpdateTopicParams {\n original: ApwWorkflow;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterWorkflowUpdateTopicParams {\n original: ApwWorkflow;\n workflow: ApwWorkflow;\n input: Record<string, any>;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnBeforeWorkflowDeleteTopicParams {\n workflow: ApwWorkflow;\n}\n\n/**\n * @category Lifecycle events\n */\nexport interface OnAfterWorkflowDeleteTopicParams {\n workflow: ApwWorkflow;\n}\n\nexport type WorkflowModelDefinition = Pick<\n CmsModel,\n \"name\" | \"modelId\" | \"layout\" | \"titleFieldId\" | \"description\" | \"fields\" | \"isPrivate\"\n>;\n\n/**\n * Headless CMS\n */\nexport interface OnBeforeCmsEntryPublishTopicParams\n extends Omit<BeforeEntryPublishTopicParams, \"entry\"> {\n entry: ApwCmsEntry;\n}\nexport interface OnAfterCmsEntryPublishTopicParams\n extends Omit<AfterEntryPublishTopicParams, \"entry\"> {\n entry: ApwCmsEntry;\n}\nexport interface OnAfterCmsEntryUnpublishTopicParams\n extends Omit<AfterEntryUnpublishTopicParams, \"entry\"> {\n entry: ApwCmsEntry;\n}\n"],"mappings":";;;;;;IAqFYA,e;;;WAAAA,e;EAAAA,e;EAAAA,e;GAAAA,e,+BAAAA,e;;IA2BAC,kB;;;WAAAA,kB;EAAAA,kB;EAAAA,kB;GAAAA,kB,kCAAAA,kB;;IAKAC,0B;;;WAAAA,0B;EAAAA,0B;EAAAA,0B;EAAAA,0B;GAAAA,0B,0CAAAA,0B;;IAMAC,uB;AAKZ;AACA;AACA;AACA;AACA;;;;WATYA,uB;EAAAA,uB;EAAAA,uB;GAAAA,uB,uCAAAA,uB;;IA8FAC,oB;;;WAAAA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,oCAAAA,oB;;IAMAC,sB;;;WAAAA,sB;EAAAA,sB;EAAAA,sB;EAAAA,sB;GAAAA,sB,sCAAAA,sB;;IAuEPC,sB;;WAAAA,sB;EAAAA,sB;EAAAA,sB;GAAAA,sB,KAAAA,sB"}
|
package/utils/resolve.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
import { Response, ErrorResponse } from "@webiny/handler-graphql";
|
2
|
-
declare const _default: (fn: () => Promise<any>) => Promise<
|
2
|
+
declare const _default: (fn: () => Promise<any>) => Promise<Response<any> | ErrorResponse>;
|
3
3
|
export default _default;
|