@strapi/review-workflows 5.56.0 → 5.58.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/dist/server/audit-logs.js +123 -0
- package/dist/server/audit-logs.js.map +1 -0
- package/dist/server/audit-logs.mjs +116 -0
- package/dist/server/audit-logs.mjs.map +1 -0
- package/dist/server/bootstrap.js +7 -0
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs +7 -0
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/controllers/workflows.js +8 -6
- package/dist/server/controllers/workflows.js.map +1 -1
- package/dist/server/controllers/workflows.mjs +8 -6
- package/dist/server/controllers/workflows.mjs.map +1 -1
- package/dist/server/entitlements.js +29 -0
- package/dist/server/entitlements.js.map +1 -0
- package/dist/server/entitlements.mjs +27 -0
- package/dist/server/entitlements.mjs.map +1 -0
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +5 -0
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/middlewares/review-workflows.js +7 -3
- package/dist/server/middlewares/review-workflows.js.map +1 -1
- package/dist/server/middlewares/review-workflows.mjs +7 -3
- package/dist/server/middlewares/review-workflows.mjs.map +1 -1
- package/dist/server/migrations/handle-deleted-ct-in-workflows.js +2 -2
- package/dist/server/migrations/handle-deleted-ct-in-workflows.js.map +1 -1
- package/dist/server/migrations/handle-deleted-ct-in-workflows.mjs +2 -2
- package/dist/server/migrations/handle-deleted-ct-in-workflows.mjs.map +1 -1
- package/dist/server/migrations/multiple-workflows.js +2 -5
- package/dist/server/migrations/multiple-workflows.js.map +1 -1
- package/dist/server/migrations/multiple-workflows.mjs +2 -5
- package/dist/server/migrations/multiple-workflows.mjs.map +1 -1
- package/dist/server/register.js +6 -7
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +6 -7
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/services/assignees.js +18 -2
- package/dist/server/services/assignees.js.map +1 -1
- package/dist/server/services/assignees.mjs +19 -3
- package/dist/server/services/assignees.mjs.map +1 -1
- package/dist/server/services/document-service-middleware.js +2 -3
- package/dist/server/services/document-service-middleware.js.map +1 -1
- package/dist/server/services/document-service-middleware.mjs +2 -3
- package/dist/server/services/document-service-middleware.mjs.map +1 -1
- package/dist/server/services/metrics/weekly-metrics.js +8 -8
- package/dist/server/services/metrics/weekly-metrics.js.map +1 -1
- package/dist/server/services/metrics/weekly-metrics.mjs +4 -4
- package/dist/server/services/metrics/weekly-metrics.mjs.map +1 -1
- package/dist/server/services/stage-permissions.js +1 -2
- package/dist/server/services/stage-permissions.js.map +1 -1
- package/dist/server/services/stage-permissions.mjs +1 -2
- package/dist/server/services/stage-permissions.mjs.map +1 -1
- package/dist/server/services/stages.js +8 -8
- package/dist/server/services/stages.js.map +1 -1
- package/dist/server/services/stages.mjs +7 -7
- package/dist/server/services/stages.mjs.map +1 -1
- package/dist/server/services/validation.js +1 -2
- package/dist/server/services/validation.js.map +1 -1
- package/dist/server/services/validation.mjs +1 -2
- package/dist/server/services/validation.mjs.map +1 -1
- package/dist/server/services/workflow-content-types.js +23 -6
- package/dist/server/services/workflow-content-types.js.map +1 -1
- package/dist/server/services/workflow-content-types.mjs +21 -4
- package/dist/server/services/workflow-content-types.mjs.map +1 -1
- package/dist/server/services/workflows.js +91 -13
- package/dist/server/services/workflows.js.map +1 -1
- package/dist/server/services/workflows.mjs +91 -13
- package/dist/server/services/workflows.mjs.map +1 -1
- package/dist/server/src/audit-logs.d.ts +112 -0
- package/dist/server/src/audit-logs.d.ts.map +1 -0
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/workflows.d.ts.map +1 -1
- package/dist/server/src/entitlements.d.ts +7 -0
- package/dist/server/src/entitlements.d.ts.map +1 -0
- package/dist/server/src/index.d.ts +17 -14
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/middlewares/review-workflows.d.ts.map +1 -1
- package/dist/server/src/migrations/handle-deleted-ct-in-workflows.d.ts.map +1 -1
- package/dist/server/src/migrations/multiple-workflows.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/assignees.d.ts.map +1 -1
- package/dist/server/src/services/document-service-middleware.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +1 -1
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/metrics/weekly-metrics.d.ts +1 -1
- package/dist/server/src/services/metrics/weekly-metrics.d.ts.map +1 -1
- package/dist/server/src/services/stage-permissions.d.ts.map +1 -1
- package/dist/server/src/services/validation.d.ts.map +1 -1
- package/dist/server/src/services/workflow-content-types.d.ts +10 -3
- package/dist/server/src/services/workflow-content-types.d.ts.map +1 -1
- package/dist/server/src/services/workflows.d.ts.map +1 -1
- package/dist/server/src/utils/review-workflows.d.ts +12 -8
- package/dist/server/src/utils/review-workflows.d.ts.map +1 -1
- package/dist/server/utils/review-workflows.js +8 -13
- package/dist/server/utils/review-workflows.js.map +1 -1
- package/dist/server/utils/review-workflows.mjs +8 -13
- package/dist/server/utils/review-workflows.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.mjs","sources":["../../../server/src/services/workflows.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport { set, isString, map, get } from 'lodash/fp';\nimport { errors } from '@strapi/utils';\nimport { WORKFLOW_MODEL_UID, WORKFLOW_POPULATE } from '../constants/workflows';\nimport { getService } from '../utils';\nimport { getWorkflowContentTypeFilter } from '../utils/review-workflows';\nimport workflowsContentTypesFactory from './workflow-content-types';\n\nconst processFilters = ({ strapi }: { strapi: Core.Strapi }, filters: any = {}) => {\n const processedFilters = { ...filters };\n\n if (isString(filters.contentTypes)) {\n processedFilters.contentTypes = getWorkflowContentTypeFilter({ strapi }, filters.contentTypes);\n }\n\n return processedFilters;\n};\n\n// TODO: How can we improve this? Maybe using traversePopulate?\nconst processPopulate = (populate: any) => {\n // If it does not exist or it's not an object (like an array) return the default populate\n if (!populate) {\n return WORKFLOW_POPULATE;\n }\n\n return populate;\n};\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => {\n const workflowsContentTypes = workflowsContentTypesFactory({ strapi });\n const workflowValidator = getService('validation', { strapi });\n const metrics = getService('workflow-metrics', { strapi });\n\n return {\n /**\n * Returns all the workflows matching the user-defined filters.\n * @param {object} opts - Options for the query.\n * @param {object} opts.filters - Filters object.\n * @returns {Promise<object[]>} - List of workflows that match the user's filters.\n */\n async find(opts: any = {}) {\n const filters = processFilters({ strapi }, opts.filters);\n const populate = processPopulate(opts.populate);\n\n const query = strapi.get('query-params').transform(WORKFLOW_MODEL_UID, {\n ...opts,\n filters,\n populate,\n });\n\n return strapi.db.query(WORKFLOW_MODEL_UID).findMany(query);\n },\n\n /**\n * Returns the workflow with the specified ID.\n * @param {string} id - ID of the requested workflow.\n * @param {object} opts - Options for the query.\n * @returns {Promise<object>} - Workflow object matching the requested ID.\n */\n findById(id: any, opts: { populate?: any } = {}) {\n const populate = processPopulate(opts.populate);\n\n const query = strapi.get('query-params').transform(WORKFLOW_MODEL_UID, { populate });\n\n return strapi.db.query(WORKFLOW_MODEL_UID).findOne({\n ...query,\n where: { id },\n });\n },\n\n /**\n * Creates a new workflow.\n * @param {object} opts - Options for creating the new workflow.\n * @returns {Promise<object>} - Workflow object that was just created.\n * @throws {ValidationError} - If the workflow has no stages.\n */\n async create(opts: { data: any }) {\n let createOpts = { ...opts, populate: WORKFLOW_POPULATE };\n\n workflowValidator.validateWorkflowStages(opts.data.stages);\n await workflowValidator.validateWorkflowCount(1);\n\n return strapi.db.transaction(async () => {\n // Create stages\n const stages = await getService('stages', { strapi }).createMany(opts.data.stages);\n const mapIds = map(get('id'));\n\n createOpts = set('data.stages', mapIds(stages), createOpts);\n\n if (opts.data.stageRequiredToPublishName) {\n const stageRequiredToPublish = stages.find(\n (stage: any) => stage.name === opts.data.stageRequiredToPublishName\n );\n if (!stageRequiredToPublish) {\n throw new errors.ApplicationError('Stage required to publish does not exist');\n }\n\n createOpts = set('data.stageRequiredToPublish', stageRequiredToPublish.id, createOpts);\n }\n\n // Update (un)assigned Content Types\n if (opts.data.contentTypes) {\n await workflowsContentTypes.migrate({\n destContentTypes: opts.data.contentTypes,\n stageId: stages[0].id,\n });\n }\n\n // Create Workflow\n const createdWorkflow = await strapi.db\n .query(WORKFLOW_MODEL_UID)\n .create(strapi.get('query-params').transform(WORKFLOW_MODEL_UID, createOpts));\n\n metrics.sendDidCreateWorkflow(createdWorkflow.id, !!opts.data.stageRequiredToPublishName);\n\n if (opts.data.stageRequiredToPublishName) {\n await strapi\n .plugin('content-releases')\n .service('release-action')\n ?.validateActionsByContentTypes(opts.data.contentTypes);\n }\n\n return createdWorkflow;\n });\n },\n\n /**\n * Updates an existing workflow.\n * @param {object} workflow - The existing workflow to update.\n * @param {object} opts - Options for updating the workflow.\n * @returns {Promise<object>} - Workflow object that was just updated.\n * @throws {ApplicationError} - If the supplied stage ID does not belong to the workflow.\n */\n async update(workflow: any, opts: any) {\n const stageService = getService('stages', { strapi });\n let updateOpts = { ...opts, populate: { ...WORKFLOW_POPULATE } };\n let updatedStages: any = [];\n let updatedStageIds: any;\n\n await workflowValidator.validateWorkflowCount();\n\n return strapi.db.transaction(async () => {\n // Update stages\n if (opts.data.stages) {\n workflowValidator.validateWorkflowStages(opts.data.stages);\n opts.data.stages.forEach((stage: any) =>\n this.assertStageBelongsToWorkflow(stage.id, workflow)\n );\n\n updatedStages = await stageService.replaceStages(\n workflow.stages,\n opts.data.stages,\n workflow.contentTypes\n );\n updatedStageIds = updatedStages.map((stage: any) => stage.id);\n\n updateOpts = set('data.stages', updatedStageIds, updateOpts);\n }\n\n if (opts.data.stageRequiredToPublishName !== undefined) {\n const stages = updatedStages ?? workflow.stages;\n\n if (opts.data.stageRequiredToPublishName === null) {\n updateOpts = set('data.stageRequiredToPublish', null, updateOpts);\n } else {\n const stageRequiredToPublish = stages.find(\n (stage: any) => stage.name === opts.data.stageRequiredToPublishName\n );\n\n if (!stageRequiredToPublish) {\n throw new errors.ApplicationError('Stage required to publish does not exist');\n }\n\n updateOpts = set('data.stageRequiredToPublish', stageRequiredToPublish.id, updateOpts);\n }\n }\n\n // Update (un)assigned Content Types\n if (opts.data.contentTypes) {\n await workflowsContentTypes.migrate({\n srcContentTypes: workflow.contentTypes,\n destContentTypes: opts.data.contentTypes,\n stageId: updatedStageIds ? updatedStageIds[0] : workflow.stages[0].id,\n });\n }\n\n metrics.sendDidEditWorkflow(workflow.id, !!opts.data.stageRequiredToPublishName);\n\n const query = strapi.get('query-params').transform(WORKFLOW_MODEL_UID, updateOpts);\n\n // Update Workflow\n const updatedWorkflow = await strapi.db.query(WORKFLOW_MODEL_UID).update({\n ...query,\n where: { id: workflow.id },\n });\n\n await strapi\n .plugin('content-releases')\n .service('release-action')\n ?.validateActionsByContentTypes([\n ...workflow.contentTypes,\n ...(opts.data.contentTypes || []),\n ]);\n\n return updatedWorkflow;\n });\n },\n\n /**\n * Deletes an existing workflow.\n * Also deletes all the workflow stages and migrate all assigned the content types.\n * @param {*} workflow\n * @param {*} opts\n * @returns\n */\n async delete(workflow: any, opts: any) {\n const stageService = getService('stages', { strapi });\n\n const workflowCount = await this.count();\n\n if (workflowCount <= 1) {\n throw new errors.ApplicationError('Can not delete the last workflow');\n }\n\n return strapi.db.transaction(async () => {\n // Delete stages\n await stageService.deleteMany(workflow.stages);\n\n // Unassign all content types, this will migrate the content types to null\n await workflowsContentTypes.migrate({\n srcContentTypes: workflow.contentTypes,\n destContentTypes: [],\n });\n\n const query = strapi.get('query-params').transform(WORKFLOW_MODEL_UID, opts);\n\n // Delete Workflow\n const deletedWorkflow = await strapi.db.query(WORKFLOW_MODEL_UID).delete({\n ...query,\n where: { id: workflow.id },\n });\n\n await strapi\n .plugin('content-releases')\n .service('release-action')\n ?.validateActionsByContentTypes(workflow.contentTypes);\n\n return deletedWorkflow;\n });\n },\n /**\n * Returns the total count of workflows.\n * @returns {Promise<number>} - Total count of workflows.\n */\n count() {\n return strapi.db.query(WORKFLOW_MODEL_UID).count();\n },\n\n /**\n * Finds the assigned workflow for a given content type ID.\n * @param {string} uid - Content type ID to find the assigned workflow for.\n * @param {object} opts - Options for the query.\n * @returns {Promise<object|null>} - Assigned workflow object if found, or null.\n */\n async getAssignedWorkflow(uid: any, opts: any = {}) {\n const workflows = await this._getAssignedWorkflows(uid, opts);\n\n return workflows.length > 0 ? workflows[0] : null;\n },\n\n /**\n * Finds all the assigned workflows for a given content type ID.\n * Normally, there should only be one workflow assigned to a content type.\n * However, edge cases can occur where a content type is assigned to multiple workflows.\n * @param {string} uid - Content type ID to find the assigned workflows for.\n * @param {object} opts - Options for the query.\n * @returns {Promise<object[]>} - List of assigned workflow objects.\n */\n async _getAssignedWorkflows(uid: any, opts = {}) {\n return this.find({\n ...opts,\n filters: { contentTypes: getWorkflowContentTypeFilter({ strapi }, uid) },\n });\n },\n\n /**\n * Asserts that a content type has an assigned workflow.\n * @param {string} uid - Content type ID to verify the assignment of.\n * @returns {Promise<object>} - Workflow object associated with the content type ID.\n * @throws {ApplicationError} - If no assigned workflow is found for the content type ID.\n */\n async assertContentTypeBelongsToWorkflow(uid: any) {\n const workflow = await this.getAssignedWorkflow(uid, {\n populate: 'stages',\n });\n\n if (!workflow) {\n throw new errors.ApplicationError(\n `Review workflows is not activated on Content Type ${uid}.`\n );\n }\n\n return workflow;\n },\n\n /**\n * Asserts that a stage belongs to a given workflow.\n * @param {string} stageId - ID of stage to check.\n * @param {object} workflow - Workflow object to check against.\n * @returns\n * @throws {ApplicationError} - If the stage does not belong to the specified workflow.\n */\n assertStageBelongsToWorkflow(stageId: any, workflow: any) {\n if (!stageId) {\n return;\n }\n\n const belongs = workflow.stages.some((stage: any) => stage.id === stageId);\n if (!belongs) {\n throw new errors.ApplicationError(`Stage does not belong to workflow \"${workflow.name}\"`);\n }\n },\n };\n};\n"],"names":["processFilters","strapi","filters","processedFilters","isString","contentTypes","getWorkflowContentTypeFilter","processPopulate","populate","WORKFLOW_POPULATE","workflowsContentTypes","workflowsContentTypesFactory","workflowValidator","getService","metrics","find","opts","query","get","transform","WORKFLOW_MODEL_UID","db","findMany","findById","id","findOne","where","create","createOpts","validateWorkflowStages","data","stages","validateWorkflowCount","transaction","createMany","mapIds","map","set","stageRequiredToPublishName","stageRequiredToPublish","stage","name","errors","ApplicationError","migrate","destContentTypes","stageId","createdWorkflow","sendDidCreateWorkflow","plugin","service","validateActionsByContentTypes","update","workflow","stageService","updateOpts","updatedStages","updatedStageIds","forEach","assertStageBelongsToWorkflow","replaceStages","undefined","srcContentTypes","sendDidEditWorkflow","updatedWorkflow","delete","workflowCount","count","deleteMany","deletedWorkflow","getAssignedWorkflow","uid","workflows","_getAssignedWorkflows","length","assertContentTypeBelongsToWorkflow","belongs","some"],"mappings":";;;;;;;AAQA,MAAMA,cAAAA,GAAiB,CAAC,EAAEC,MAAM,EAA2B,EAAEC,OAAAA,GAAe,EAAE,GAAA;AAC5E,IAAA,MAAMC,gBAAAA,GAAmB;AAAE,QAAA,GAAGD;AAAQ,KAAA;IAEtC,IAAIE,QAAAA,CAASF,OAAAA,CAAQG,YAAY,CAAA,EAAG;QAClCF,gBAAAA,CAAiBE,YAAY,GAAGC,4BAAAA,CAA6B;AAAEL,YAAAA;AAAO,SAAA,EAAGC,QAAQG,YAAY,CAAA;AAC/F,IAAA;IAEA,OAAOF,gBAAAA;AACT,CAAA;AAEA;AACA,MAAMI,kBAAkB,CAACC,QAAAA,GAAAA;;AAEvB,IAAA,IAAI,CAACA,QAAAA,EAAU;QACb,OAAOC,iBAAAA;AACT,IAAA;IAEA,OAAOD,QAAAA;AACT,CAAA;AAEA,gBAAe,CAAA,CAAC,EAAEP,MAAM,EAA2B,GAAA;AACjD,IAAA,MAAMS,wBAAwBC,4BAAAA,CAA6B;AAAEV,QAAAA;AAAO,KAAA,CAAA;IACpE,MAAMW,iBAAAA,GAAoBC,WAAW,YAAA,EAAc;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,OAAAA,CAAAA;AAClE,YAAA,IAAI,CAAC8B,OAAAA,EAAS;gBACZ,MAAM,IAAIlC,MAAAA,CAAOC,gBAAgB,CAAC,CAAC,mCAAmC,EAAEU,QAAAA,CAASZ,IAAI,CAAC,CAAC,CAAC,CAAA;AAC1F,YAAA;AACF,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"workflows.mjs","sources":["../../../server/src/services/workflows.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport { isString, map } from 'lodash';\nimport { errors, emitAudit } from '@strapi/utils';\nimport { WORKFLOW_MODEL_UID, WORKFLOW_POPULATE } from '../constants/workflows';\nimport {\n AUDITED_EVENTS,\n getWorkflowChanges,\n toWorkflowEvent,\n toWorkflowSnapshot,\n} from '../audit-logs';\nimport { getService } from '../utils';\nimport { getWorkflowContentTypeFilter } from '../utils/review-workflows';\nimport workflowsContentTypesFactory, { type ContentTypeTransfer } from './workflow-content-types';\n\nconst processFilters = ({ strapi }: { strapi: Core.Strapi }, filters: any = {}) => {\n const processedFilters = { ...filters };\n\n if (isString(filters.contentTypes)) {\n processedFilters.contentTypes = getWorkflowContentTypeFilter({ strapi }, filters.contentTypes);\n }\n\n return processedFilters;\n};\n\n// TODO: How can we improve this? Maybe using traversePopulate?\nconst processPopulate = (populate: any) => {\n // If it does not exist or it's not an object (like an array) return the default populate\n if (!populate) {\n return WORKFLOW_POPULATE;\n }\n\n return populate;\n};\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => {\n const workflowsContentTypes = workflowsContentTypesFactory({ strapi });\n const workflowValidator = getService('validation', { strapi });\n const metrics = getService('workflow-metrics', { strapi });\n\n const emitContentTypeTransfers = async (transfers: ContentTypeTransfer[]) => {\n for (const { workflowId, name, before, after } of transfers) {\n const changes = getWorkflowChanges(\n toWorkflowSnapshot({ id: workflowId, name, contentTypes: before }),\n toWorkflowSnapshot({ id: workflowId, name, contentTypes: after })\n );\n\n if (Object.keys(changes).length > 0) {\n await emitAudit({ strapi }, AUDITED_EVENTS.WORKFLOW_UPDATE, { workflowId, name, changes });\n }\n }\n };\n\n return {\n /**\n * Returns all the workflows matching the user-defined filters.\n * @param {object} opts - Options for the query.\n * @param {object} opts.filters - Filters object.\n * @returns {Promise<object[]>} - List of workflows that match the user's filters.\n */\n async find(opts: any = {}) {\n const filters = processFilters({ strapi }, opts.filters);\n const populate = processPopulate(opts.populate);\n\n const query = strapi.get('query-params').transform(WORKFLOW_MODEL_UID, {\n ...opts,\n filters,\n populate,\n });\n\n return strapi.db.query(WORKFLOW_MODEL_UID).findMany(query);\n },\n\n /**\n * Returns the workflow with the specified ID.\n * @param {string} id - ID of the requested workflow.\n * @param {object} opts - Options for the query.\n * @returns {Promise<object>} - Workflow object matching the requested ID.\n */\n findById(id: any, opts: { populate?: any } = {}) {\n const populate = processPopulate(opts.populate);\n\n const query = strapi.get('query-params').transform(WORKFLOW_MODEL_UID, { populate });\n\n return strapi.db.query(WORKFLOW_MODEL_UID).findOne({\n ...query,\n where: { id },\n });\n },\n\n /**\n * Creates a new workflow.\n * @param {object} opts - Options for creating the new workflow.\n * @returns {Promise<object>} - Workflow object that was just created.\n * @throws {ValidationError} - If the workflow has no stages.\n */\n async create(opts: { data: any }) {\n let createOpts = { ...opts, populate: WORKFLOW_POPULATE };\n\n workflowValidator.validateWorkflowStages(opts.data.stages);\n await workflowValidator.validateWorkflowCount(1);\n\n let transfers: ContentTypeTransfer[] = [];\n\n const createdWorkflow = await strapi.db.transaction(async () => {\n // Create stages\n const stages = await getService('stages', { strapi }).createMany(opts.data.stages);\n createOpts = { ...createOpts, data: { ...createOpts.data, stages: map(stages, 'id') } };\n\n if (opts.data.stageRequiredToPublishName) {\n const stageRequiredToPublish = stages.find(\n (stage: any) => stage.name === opts.data.stageRequiredToPublishName\n );\n if (!stageRequiredToPublish) {\n throw new errors.ApplicationError('Stage required to publish does not exist');\n }\n\n createOpts = {\n ...createOpts,\n data: { ...createOpts.data, stageRequiredToPublish: stageRequiredToPublish.id },\n };\n }\n\n // Update (un)assigned Content Types\n if (opts.data.contentTypes) {\n transfers = await workflowsContentTypes.migrate({\n destContentTypes: opts.data.contentTypes,\n stageId: stages[0].id,\n });\n }\n\n // Create Workflow\n const createdWorkflow = await strapi.db\n .query(WORKFLOW_MODEL_UID)\n .create(strapi.get('query-params').transform(WORKFLOW_MODEL_UID, createOpts));\n\n metrics.sendDidCreateWorkflow(createdWorkflow.id, !!opts.data.stageRequiredToPublishName);\n\n if (opts.data.stageRequiredToPublishName) {\n await strapi\n .plugin('content-releases')\n .service('release-action')\n ?.validateActionsByContentTypes(opts.data.contentTypes);\n }\n\n return createdWorkflow;\n });\n\n const { contentTypes, stages, stageRequiredToPublish } = toWorkflowSnapshot(createdWorkflow);\n await emitAudit({ strapi }, AUDITED_EVENTS.WORKFLOW_CREATE, {\n ...toWorkflowEvent(createdWorkflow),\n contentTypes,\n stages,\n stageRequiredToPublish,\n });\n await emitContentTypeTransfers(transfers);\n\n return createdWorkflow;\n },\n\n /**\n * Updates an existing workflow.\n * @param {object} workflow - The existing workflow to update.\n * @param {object} opts - Options for updating the workflow.\n * @returns {Promise<object>} - Workflow object that was just updated.\n * @throws {ApplicationError} - If the supplied stage ID does not belong to the workflow.\n */\n async update(workflow: any, opts: any) {\n const stageService = getService('stages', { strapi });\n let updateOpts = { ...opts, populate: { ...WORKFLOW_POPULATE } };\n let updatedStages: any = [];\n let updatedStageIds: any;\n\n await workflowValidator.validateWorkflowCount();\n\n let transfers: ContentTypeTransfer[] = [];\n\n const updatedWorkflow = await strapi.db.transaction(async () => {\n // Update stages\n if (opts.data.stages) {\n workflowValidator.validateWorkflowStages(opts.data.stages);\n opts.data.stages.forEach((stage: any) =>\n this.assertStageBelongsToWorkflow(stage.id, workflow)\n );\n\n updatedStages = await stageService.replaceStages(\n workflow.stages,\n opts.data.stages,\n workflow.contentTypes\n );\n updatedStageIds = updatedStages.map((stage: any) => stage.id);\n\n updateOpts = { ...updateOpts, data: { ...updateOpts.data, stages: updatedStageIds } };\n }\n\n if (opts.data.stageRequiredToPublishName !== undefined) {\n const stages = updatedStages ?? workflow.stages;\n\n if (opts.data.stageRequiredToPublishName === null) {\n updateOpts = {\n ...updateOpts,\n data: { ...updateOpts.data, stageRequiredToPublish: null },\n };\n } else {\n const stageRequiredToPublish = stages.find(\n (stage: any) => stage.name === opts.data.stageRequiredToPublishName\n );\n\n if (!stageRequiredToPublish) {\n throw new errors.ApplicationError('Stage required to publish does not exist');\n }\n\n updateOpts = {\n ...updateOpts,\n data: { ...updateOpts.data, stageRequiredToPublish: stageRequiredToPublish.id },\n };\n }\n }\n\n // Update (un)assigned Content Types\n if (opts.data.contentTypes) {\n transfers = await workflowsContentTypes.migrate({\n srcContentTypes: workflow.contentTypes,\n destContentTypes: opts.data.contentTypes,\n stageId: updatedStageIds ? updatedStageIds[0] : workflow.stages[0].id,\n });\n }\n\n metrics.sendDidEditWorkflow(workflow.id, !!opts.data.stageRequiredToPublishName);\n\n const query = strapi.get('query-params').transform(WORKFLOW_MODEL_UID, updateOpts);\n\n // Update Workflow\n const updatedWorkflow = await strapi.db.query(WORKFLOW_MODEL_UID).update({\n ...query,\n where: { id: workflow.id },\n });\n\n await strapi\n .plugin('content-releases')\n .service('release-action')\n ?.validateActionsByContentTypes([\n ...workflow.contentTypes,\n ...(opts.data.contentTypes || []),\n ]);\n\n return updatedWorkflow;\n });\n\n const changes = getWorkflowChanges(\n toWorkflowSnapshot(workflow),\n toWorkflowSnapshot(updatedWorkflow)\n );\n\n if (Object.keys(changes).length > 0) {\n await emitAudit({ strapi }, AUDITED_EVENTS.WORKFLOW_UPDATE, {\n ...toWorkflowEvent(updatedWorkflow),\n changes,\n });\n }\n await emitContentTypeTransfers(transfers);\n\n return updatedWorkflow;\n },\n\n /**\n * Deletes an existing workflow.\n * Also deletes all the workflow stages and migrate all assigned the content types.\n * @param {*} workflow\n * @param {*} opts\n * @returns\n */\n async delete(workflow: any, opts: any) {\n const stageService = getService('stages', { strapi });\n\n const workflowCount = await this.count();\n\n if (workflowCount <= 1) {\n throw new errors.ApplicationError('Can not delete the last workflow');\n }\n\n const deletedWorkflow = await strapi.db.transaction(async () => {\n // Delete stages\n await stageService.deleteMany(workflow.stages);\n\n // Unassign all content types, this will migrate the content types to null\n await workflowsContentTypes.migrate({\n srcContentTypes: workflow.contentTypes,\n destContentTypes: [],\n });\n\n const query = strapi.get('query-params').transform(WORKFLOW_MODEL_UID, opts);\n\n // Delete Workflow\n const deletedWorkflow = await strapi.db.query(WORKFLOW_MODEL_UID).delete({\n ...query,\n where: { id: workflow.id },\n });\n\n await strapi\n .plugin('content-releases')\n .service('release-action')\n ?.validateActionsByContentTypes(workflow.contentTypes);\n\n return deletedWorkflow;\n });\n\n await emitAudit({ strapi }, AUDITED_EVENTS.WORKFLOW_DELETE, toWorkflowEvent(workflow));\n\n return deletedWorkflow;\n },\n\n /**\n * Returns the total count of workflows.\n * @returns {Promise<number>} - Total count of workflows.\n */\n count() {\n return strapi.db.query(WORKFLOW_MODEL_UID).count();\n },\n\n /**\n * Finds the assigned workflow for a given content type ID.\n * @param {string} uid - Content type ID to find the assigned workflow for.\n * @param {object} opts - Options for the query.\n * @returns {Promise<object|null>} - Assigned workflow object if found, or null.\n */\n async getAssignedWorkflow(uid: any, opts: any = {}) {\n const workflows = await this._getAssignedWorkflows(uid, opts);\n\n return workflows.length > 0 ? workflows[0] : null;\n },\n\n /**\n * Finds all the assigned workflows for a given content type ID.\n * Normally, there should only be one workflow assigned to a content type.\n * However, edge cases can occur where a content type is assigned to multiple workflows.\n * @param {string} uid - Content type ID to find the assigned workflows for.\n * @param {object} opts - Options for the query.\n * @returns {Promise<object[]>} - List of assigned workflow objects.\n */\n async _getAssignedWorkflows(uid: any, opts = {}) {\n return this.find({\n ...opts,\n filters: { contentTypes: getWorkflowContentTypeFilter({ strapi }, uid) },\n });\n },\n\n /**\n * Asserts that a content type has an assigned workflow.\n * @param {string} uid - Content type ID to verify the assignment of.\n * @returns {Promise<object>} - Workflow object associated with the content type ID.\n * @throws {ApplicationError} - If no assigned workflow is found for the content type ID.\n */\n async assertContentTypeBelongsToWorkflow(uid: any) {\n const workflow = await this.getAssignedWorkflow(uid, {\n populate: 'stages',\n });\n\n if (!workflow) {\n throw new errors.ApplicationError(\n `Review workflows is not activated on Content Type ${uid}.`\n );\n }\n\n return workflow;\n },\n\n /**\n * Asserts that a stage belongs to a given workflow.\n * @param {string} stageId - ID of stage to check.\n * @param {object} workflow - Workflow object to check against.\n * @returns\n * @throws {ApplicationError} - If the stage does not belong to the specified workflow.\n */\n assertStageBelongsToWorkflow(stageId: any, workflow: any) {\n if (!stageId) {\n return;\n }\n\n const belongs = workflow.stages.some((stage: any) => stage.id === stageId);\n if (!belongs) {\n throw new errors.ApplicationError(`Stage does not belong to workflow \"${workflow.name}\"`);\n }\n },\n };\n};\n"],"names":["processFilters","strapi","filters","processedFilters","isString","contentTypes","getWorkflowContentTypeFilter","processPopulate","populate","WORKFLOW_POPULATE","workflowsContentTypes","workflowsContentTypesFactory","workflowValidator","getService","metrics","emitContentTypeTransfers","transfers","workflowId","name","before","after","changes","getWorkflowChanges","toWorkflowSnapshot","Object","keys","length","emitAudit","AUDITED_EVENTS","WORKFLOW_UPDATE","find","opts","query","get","transform","WORKFLOW_MODEL_UID","db","findMany","findById","id","findOne","where","create","createOpts","validateWorkflowStages","data","stages","validateWorkflowCount","createdWorkflow","transaction","createMany","map","stageRequiredToPublishName","stageRequiredToPublish","stage","errors","ApplicationError","migrate","destContentTypes","stageId","sendDidCreateWorkflow","plugin","service","validateActionsByContentTypes","WORKFLOW_CREATE","toWorkflowEvent","update","workflow","stageService","updateOpts","updatedStages","updatedStageIds","updatedWorkflow","forEach","assertStageBelongsToWorkflow","replaceStages","undefined","srcContentTypes","sendDidEditWorkflow","delete","workflowCount","count","deletedWorkflow","deleteMany","WORKFLOW_DELETE","getAssignedWorkflow","uid","workflows","_getAssignedWorkflows","assertContentTypeBelongsToWorkflow","belongs","some"],"m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/B,CAAC,kDAAkD,EAAE8B,GAAAA,CAAI,CAAC,CAAC,CAAA;AAE/D,YAAA;YAEA,OAAOnB,QAAAA;AACT,QAAA,CAAA;AAEA;;;;;;QAOAO,4BAAAA,CAAAA,CAA6Bf,OAAY,EAAEQ,QAAa,EAAA;AACtD,YAAA,IAAI,CAACR,OAAAA,EAAS;AACZ,gBAAA;AACF,YAAA;YAEA,MAAM+B,OAAAA,GAAUvB,QAAAA,CAASrB,MAAM,CAAC6C,IAAI,CAAC,CAACrC,KAAAA,GAAeA,KAAAA,CAAMf,EAAE,KAAKoB,OAAAA,CAAAA;AAClE,YAAA,IAAI,CAAC+B,OAAAA,EAAS;gBACZ,MAAM,IAAInC,MAAAA,CAAOC,gBAAgB,CAAC,CAAC,mCAAmC,EAAEW,QAAAA,CAASjD,IAAI,CAAC,CAAC,CAAC,CAAA;AAC1F,YAAA;AACF,QAAA;AACF,KAAA;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Core, Data, Modules, UID } from '@strapi/types';
|
|
2
|
+
export declare const AUDITED_EVENTS: {
|
|
3
|
+
readonly WORKFLOW_CREATE: "workflow.create";
|
|
4
|
+
readonly WORKFLOW_UPDATE: "workflow.update";
|
|
5
|
+
readonly WORKFLOW_DELETE: "workflow.delete";
|
|
6
|
+
readonly ENTRY_ASSIGNEE_UPDATE: "entry.assignee.update";
|
|
7
|
+
};
|
|
8
|
+
/** A stage as stored in the log: roles by name, sorted, so order alone is not a change. */
|
|
9
|
+
export interface StageSnapshot {
|
|
10
|
+
name: string;
|
|
11
|
+
color: string | null;
|
|
12
|
+
fromPermissions: string[];
|
|
13
|
+
toPermissions: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface WorkflowSnapshot {
|
|
16
|
+
name: string;
|
|
17
|
+
contentTypes: string[];
|
|
18
|
+
stages: StageSnapshot[];
|
|
19
|
+
stageRequiredToPublish: string | null;
|
|
20
|
+
}
|
|
21
|
+
export declare const WORKFLOW_TRACKED_FIELDS: readonly ["name", "contentTypes", "stages", "stageRequiredToPublish"];
|
|
22
|
+
export type WorkflowChanges = {
|
|
23
|
+
[K in keyof WorkflowSnapshot]?: Modules.AuditLogs.FieldChange<WorkflowSnapshot[K]>;
|
|
24
|
+
};
|
|
25
|
+
/** A workflow row read with WORKFLOW_POPULATE. Without the populated roles, the permission lists come out empty. */
|
|
26
|
+
export interface WorkflowRow {
|
|
27
|
+
id: Data.ID;
|
|
28
|
+
name: string;
|
|
29
|
+
contentTypes?: string[] | null;
|
|
30
|
+
stages?: Array<{
|
|
31
|
+
name: string;
|
|
32
|
+
color?: string | null;
|
|
33
|
+
permissions?: Array<{
|
|
34
|
+
actionParameters?: {
|
|
35
|
+
from?: unknown;
|
|
36
|
+
to?: unknown;
|
|
37
|
+
} | null;
|
|
38
|
+
role?: {
|
|
39
|
+
name: string;
|
|
40
|
+
} | null;
|
|
41
|
+
}> | null;
|
|
42
|
+
}> | null;
|
|
43
|
+
stageRequiredToPublish?: {
|
|
44
|
+
name: string;
|
|
45
|
+
} | null;
|
|
46
|
+
}
|
|
47
|
+
export interface WorkflowEvent {
|
|
48
|
+
workflowId: Data.ID;
|
|
49
|
+
name: string;
|
|
50
|
+
}
|
|
51
|
+
export type WorkflowCreateDetails = Omit<WorkflowSnapshot, 'name'>;
|
|
52
|
+
export type WorkflowCreateEvent = WorkflowEvent & WorkflowCreateDetails;
|
|
53
|
+
export interface WorkflowUpdateDetails {
|
|
54
|
+
changes: WorkflowChanges;
|
|
55
|
+
}
|
|
56
|
+
export type WorkflowUpdateEvent = WorkflowEvent & WorkflowUpdateDetails;
|
|
57
|
+
export interface EntryEvent {
|
|
58
|
+
uid: UID.ContentType;
|
|
59
|
+
documentId: string;
|
|
60
|
+
locale: string | null;
|
|
61
|
+
}
|
|
62
|
+
export interface AssigneeUpdateDetails {
|
|
63
|
+
locale: string | null;
|
|
64
|
+
changes: {
|
|
65
|
+
assignee: Modules.AuditLogs.FieldChange<Data.ID | null>;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export type AssigneeUpdateEvent = EntryEvent & Pick<AssigneeUpdateDetails, 'changes'>;
|
|
69
|
+
interface StageRef {
|
|
70
|
+
id: Data.ID;
|
|
71
|
+
name: string;
|
|
72
|
+
}
|
|
73
|
+
export interface StageUpdateDetails {
|
|
74
|
+
locale: string | null;
|
|
75
|
+
workflow: {
|
|
76
|
+
id: Data.ID;
|
|
77
|
+
name: string | null;
|
|
78
|
+
};
|
|
79
|
+
changes: {
|
|
80
|
+
stage: Modules.AuditLogs.FieldChange<StageRef>;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** The payload of the existing review-workflows.updateEntryStage webhook event. */
|
|
84
|
+
export interface StageUpdateEvent {
|
|
85
|
+
uid: UID.ContentType;
|
|
86
|
+
entity: {
|
|
87
|
+
documentId: string;
|
|
88
|
+
locale?: string | null;
|
|
89
|
+
};
|
|
90
|
+
workflow: {
|
|
91
|
+
id: Data.ID;
|
|
92
|
+
stages: {
|
|
93
|
+
from: StageRef;
|
|
94
|
+
to: StageRef;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export declare const toWorkflowSnapshot: (row: WorkflowRow) => WorkflowSnapshot;
|
|
99
|
+
export declare const getWorkflowChanges: (previous: WorkflowSnapshot, next: WorkflowSnapshot) => WorkflowChanges;
|
|
100
|
+
export declare const toWorkflowEvent: (row: WorkflowRow) => WorkflowEvent;
|
|
101
|
+
/**
|
|
102
|
+
* The part of the audit-logs lifecycle service used by this plugin.
|
|
103
|
+
* The full service type lives in the Admin EE package and cannot be imported here.
|
|
104
|
+
*/
|
|
105
|
+
interface AuditLogsLifecycle {
|
|
106
|
+
registerEvent<TDetails, TResource extends Modules.AuditLogs.Resource>(name: string, transform: Modules.AuditLogs.EventTransformer<TDetails, TResource>): void;
|
|
107
|
+
}
|
|
108
|
+
export declare const registerAuditEvents: ({ strapi }: {
|
|
109
|
+
strapi: Core.Strapi;
|
|
110
|
+
}, auditLogsLifecycle: AuditLogsLifecycle) => void;
|
|
111
|
+
export {};
|
|
112
|
+
//# sourceMappingURL=audit-logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-logs.d.ts","sourceRoot":"","sources":["../../../server/src/audit-logs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAK9D,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAcX,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAED,eAAO,MAAM,uBAAuB,uEAK1B,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG;KAC3B,CAAC,IAAI,MAAM,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;CACnF,CAAC;AAEF,oHAAoH;AACpH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,WAAW,CAAC,EAAE,KAAK,CA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mEvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../server/src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../server/src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;yBA0Cf,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;AAAzD,wBAsBE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;;
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;;IAsFjC;;OAEG;gBACe,OAAO;IAuBzB;;OAEG;gBACe,OAAO;IAmCzB;;OAEG;gBACe,OAAO;IAwBzB;;OAEG;cACa,OAAO;;AA/FzB,wBAwHE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Core } from '@strapi/types';
|
|
2
|
+
/**
|
|
3
|
+
* Exposes the clamped workflow limits to the Plan card and the debug dump. Registered whatever
|
|
4
|
+
* the boot-time license says, so a lapsed or later-renewed license still resolves.
|
|
5
|
+
*/
|
|
6
|
+
export declare const registerReviewWorkflowsEntitlements: (strapi: Core.Strapi) => void;
|
|
7
|
+
//# sourceMappingURL=entitlements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.d.ts","sourceRoot":"","sources":["../../../server/src/entitlements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAW1C;;;GAGG;AACH,eAAO,MAAM,mCAAmC,GAAI,QAAQ,IAAI,CAAC,MAAM,SAoBtE,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { Core } from '@strapi/types';
|
|
1
2
|
declare const _default: {
|
|
2
3
|
register: ({ strapi }: {
|
|
3
|
-
strapi:
|
|
4
|
+
strapi: Core.Strapi;
|
|
4
5
|
}) => Promise<void>;
|
|
5
6
|
bootstrap: ({ strapi }: {
|
|
6
|
-
strapi:
|
|
7
|
+
strapi: Core.Strapi;
|
|
7
8
|
}) => Promise<void>;
|
|
8
9
|
destroy: () => Promise<void>;
|
|
9
10
|
contentTypes: {
|
|
@@ -102,12 +103,12 @@ declare const _default: {
|
|
|
102
103
|
};
|
|
103
104
|
services: {
|
|
104
105
|
homepage: ({ strapi }: {
|
|
105
|
-
strapi:
|
|
106
|
+
strapi: Core.Strapi;
|
|
106
107
|
}) => {
|
|
107
108
|
getRecentlyAssignedDocuments(): Promise<import("../../shared/contracts/homepage").GetRecentlyAssignedDocuments.Response["data"]>;
|
|
108
109
|
};
|
|
109
110
|
workflows: ({ strapi }: {
|
|
110
|
-
strapi:
|
|
111
|
+
strapi: Core.Strapi;
|
|
111
112
|
}) => {
|
|
112
113
|
find(opts?: any): Promise<any[]>;
|
|
113
114
|
findById(id: any, opts?: {
|
|
@@ -125,7 +126,7 @@ declare const _default: {
|
|
|
125
126
|
assertStageBelongsToWorkflow(stageId: any, workflow: any): void;
|
|
126
127
|
};
|
|
127
128
|
stages: ({ strapi }: {
|
|
128
|
-
strapi:
|
|
129
|
+
strapi: Core.Strapi;
|
|
129
130
|
}) => {
|
|
130
131
|
find({ workflowId, populate }: any): Promise<any[]>;
|
|
131
132
|
findById(id: string | number, { populate }?: any): Promise<any>;
|
|
@@ -146,7 +147,7 @@ declare const _default: {
|
|
|
146
147
|
deleteAllEntitiesStage(contentTypeUID: any): Promise<number>;
|
|
147
148
|
};
|
|
148
149
|
'stage-permissions': ({ strapi }: {
|
|
149
|
-
strapi:
|
|
150
|
+
strapi: Core.Strapi;
|
|
150
151
|
}) => {
|
|
151
152
|
register({ roleId, action, fromStage, }: {
|
|
152
153
|
roleId: number;
|
|
@@ -185,7 +186,7 @@ declare const _default: {
|
|
|
185
186
|
}): boolean;
|
|
186
187
|
};
|
|
187
188
|
assignees: ({ strapi }: {
|
|
188
|
-
strapi:
|
|
189
|
+
strapi: Core.Strapi;
|
|
189
190
|
}) => {
|
|
190
191
|
findEntityAssigneeId(id: string | number, model: import("@strapi/types/dist/uid/index.js").ContentType): Promise<any>;
|
|
191
192
|
updateEntityAssignee(entityToUpdate: {
|
|
@@ -196,7 +197,7 @@ declare const _default: {
|
|
|
196
197
|
}, model: import("@strapi/types/dist/uid/index.js").ContentType, assigneeId: string | null): Promise<import("@strapi/types/dist/modules/documents/index.js").AnyDocument | null>;
|
|
197
198
|
};
|
|
198
199
|
validation: ({ strapi }: {
|
|
199
|
-
strapi:
|
|
200
|
+
strapi: Core.Strapi;
|
|
200
201
|
}) => {
|
|
201
202
|
limits: {
|
|
202
203
|
numberOfWorkflows: number;
|
|
@@ -223,12 +224,12 @@ declare const _default: {
|
|
|
223
224
|
sendDidEditAssignee: (fromId: any, toId: any) => Promise<void>;
|
|
224
225
|
};
|
|
225
226
|
'workflow-weekly-metrics': ({ strapi }: {
|
|
226
|
-
strapi:
|
|
227
|
+
strapi: Core.Strapi;
|
|
227
228
|
}) => {
|
|
228
229
|
computeMetrics(): Promise<{
|
|
229
230
|
numberOfActiveWorkflows: number;
|
|
230
231
|
avgStagesCount: number;
|
|
231
|
-
maxStagesCount:
|
|
232
|
+
maxStagesCount: number | undefined;
|
|
232
233
|
activatedContentTypes: number;
|
|
233
234
|
}>;
|
|
234
235
|
sendMetrics(): Promise<void>;
|
|
@@ -254,9 +255,9 @@ declare const _default: {
|
|
|
254
255
|
};
|
|
255
256
|
};
|
|
256
257
|
routes: {
|
|
257
|
-
homepage:
|
|
258
|
-
strapi:
|
|
259
|
-
}) =>
|
|
258
|
+
homepage: Core.Router | ((params: {
|
|
259
|
+
strapi: Core.Strapi;
|
|
260
|
+
}) => Core.Router);
|
|
260
261
|
'review-workflows': {
|
|
261
262
|
type: string;
|
|
262
263
|
routes: {
|
|
@@ -276,6 +277,9 @@ declare const _default: {
|
|
|
276
277
|
};
|
|
277
278
|
};
|
|
278
279
|
} | {
|
|
280
|
+
register({ strapi }: {
|
|
281
|
+
strapi: Core.Strapi;
|
|
282
|
+
}): void;
|
|
279
283
|
contentTypes: {
|
|
280
284
|
workflow: {
|
|
281
285
|
schema: {
|
|
@@ -370,7 +374,6 @@ declare const _default: {
|
|
|
370
374
|
};
|
|
371
375
|
};
|
|
372
376
|
};
|
|
373
|
-
register?: undefined;
|
|
374
377
|
bootstrap?: undefined;
|
|
375
378
|
destroy?: undefined;
|
|
376
379
|
services?: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAoCuzD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAA+pB,CAAC;oCAAoB,CAAC;0BAAM,CAAC;;wBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAVthF;QAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAShD,wBAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/middlewares/review-workflows.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"review-workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/middlewares/review-workflows.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,QAwBxD;;;;AAED,wBAEE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-deleted-ct-in-workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/migrations/handle-deleted-ct-in-workflows.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,iBAAe,2BAA2B,CAAC,EAAE,eAAe,EAAE,YAAY,EAAE,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"handle-deleted-ct-in-workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/migrations/handle-deleted-ct-in-workflows.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,iBAAe,2BAA2B,CAAC,EAAE,eAAe,EAAE,YAAY,EAAE,EAAE,GAAG,iBAyBhF;AAED,eAAe,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiple-workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/migrations/multiple-workflows.ts"],"names":[],"mappings":"AAGA,iBAAe,4BAA4B,CAAC,EAAE,eAAe,EAAE,YAAY,EAAE,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"multiple-workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/migrations/multiple-workflows.ts"],"names":[],"mappings":"AAGA,iBAAe,4BAA4B,CAAC,EAAE,eAAe,EAAE,YAAY,EAAE,EAAE,GAAG,iBAuBjF;AAED,eAAe,4BAA4B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../server/src/register.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAO,MAAM,eAAe,CAAC;yBAqGzB,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;AAAzD,
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../server/src/register.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAO,MAAM,eAAe,CAAC;yBAqGzB,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;AAAzD,wBA2BE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignees.d.ts","sourceRoot":"","sources":["../../../../server/src/services/assignees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;yBAQ/B,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;6BAIhB,MAAM,GAAG,MAAM,SAAS,GAAG,CAAC,WAAW;IAUtE;;OAEG;yCAEe;QACd,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,SACM,GAAG,CAAC,WAAW,cACV,MAAM,GAAG,IAAI;;AAzB/B,
|
|
1
|
+
{"version":3,"file":"assignees.d.ts","sourceRoot":"","sources":["../../../../server/src/services/assignees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;yBAQ/B,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;6BAIhB,MAAM,GAAG,MAAM,SAAS,GAAG,CAAC,WAAW;IAUtE;;OAEG;yCAEe;QACd,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,SACM,GAAG,CAAC,WAAW,cACV,MAAM,GAAG,IAAI;;AAzB/B,wBAyEE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-service-middleware.d.ts","sourceRoot":"","sources":["../../../../server/src/services/document-service-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;;;;;;
|
|
1
|
+
{"version":3,"file":"document-service-middleware.d.ts","sourceRoot":"","sources":["../../../../server/src/services/document-service-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;;;;;;AAsJ7C,wBAIG"}
|
|
@@ -126,7 +126,7 @@ declare const _default: {
|
|
|
126
126
|
computeMetrics(): Promise<{
|
|
127
127
|
numberOfActiveWorkflows: number;
|
|
128
128
|
avgStagesCount: number;
|
|
129
|
-
maxStagesCount:
|
|
129
|
+
maxStagesCount: number | undefined;
|
|
130
130
|
activatedContentTypes: number;
|
|
131
131
|
}>;
|
|
132
132
|
sendMetrics(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;oBAqByiE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAA+pB,CAAC;gCAAoB,CAAC;sBAAM,CAAC;;oBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAXvvF,wBAUE"}
|
|
@@ -5,7 +5,7 @@ declare const _default: ({ strapi }: {
|
|
|
5
5
|
computeMetrics(): Promise<{
|
|
6
6
|
numberOfActiveWorkflows: number;
|
|
7
7
|
avgStagesCount: number;
|
|
8
|
-
maxStagesCount:
|
|
8
|
+
maxStagesCount: number | undefined;
|
|
9
9
|
activatedContentTypes: number;
|
|
10
10
|
}>;
|
|
11
11
|
sendMetrics(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"weekly-metrics.d.ts","sourceRoot":"","sources":["../../../../../server/src/services/metrics/weekly-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;yBAU1B,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;;;;;;;;;;;AAAnD,
|
|
1
|
+
{"version":3,"file":"weekly-metrics.d.ts","sourceRoot":"","sources":["../../../../../server/src/services/metrics/weekly-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;yBAU1B,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;;;;;;;;;;;AAAnD,wBAgEE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stage-permissions.d.ts","sourceRoot":"","sources":["../../../../server/src/services/stage-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"stage-permissions.d.ts","sourceRoot":"","sources":["../../../../server/src/services/stage-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;yBAQ1B,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;6CAkB5C;QACD,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB;8BAgB+B;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE;6CAOpF;QACD,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB;gCAeiC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;4BAGzD;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE;gBAIlC,MAAM,aAAa,MAAM;oCAqBC,MAAM;IAqB5C;;;OAGG;+CACwC;QACzC,WAAW,CAAC,EAAE;YAAE,gBAAgB,CAAC,EAAE;gBAAE,EAAE,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YAAC,IAAI,CAAC,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAA;aAAE,GAAG,MAAM,CAAA;SAAE,EAAE,CAAC;KACxF;;AAvHL,wBA6IE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../server/src/services/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../server/src/services/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;yBAQ1B,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;;;;;uDAMI,GAAG;IAWtD;;;;OAIG;mCAC4B,GAAG;4CAcY,GAAG;IASjD;;;;;OAKG;;;AAlDP,wBA2DE"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type { Core } from '@strapi/types';
|
|
1
|
+
import type { Core, Data } from '@strapi/types';
|
|
2
|
+
/** A workflow that lost content types to another one, as read after the write. */
|
|
3
|
+
export interface ContentTypeTransfer {
|
|
4
|
+
workflowId: Data.ID;
|
|
5
|
+
name: string;
|
|
6
|
+
before: string[];
|
|
7
|
+
after: string[];
|
|
8
|
+
}
|
|
2
9
|
declare const _default: ({ strapi }: {
|
|
3
10
|
strapi: Core.Strapi;
|
|
4
11
|
}) => {
|
|
@@ -9,13 +16,13 @@ declare const _default: ({ strapi }: {
|
|
|
9
16
|
* @param {Array<string>} options.destContentTypes - The content types assigned to the new workflow
|
|
10
17
|
* @param {Workflow.Stage} options.stageId - The new stage to assign the entities to
|
|
11
18
|
*/
|
|
12
|
-
migrate({ srcContentTypes, destContentTypes, stageId }: any): Promise<
|
|
19
|
+
migrate({ srcContentTypes, destContentTypes, stageId, }: any): Promise<ContentTypeTransfer[]>;
|
|
13
20
|
/**
|
|
14
21
|
* Filters the content types assigned to a workflow
|
|
15
22
|
* @param {Workflow} srcWorkflow - The workflow to transfer from
|
|
16
23
|
* @param {string} uid - The content type uid
|
|
17
24
|
*/
|
|
18
|
-
transferContentTypes(srcWorkflow: any, uid: any): Promise<
|
|
25
|
+
transferContentTypes(srcWorkflow: any, uid: any): Promise<ContentTypeTransfer>;
|
|
19
26
|
};
|
|
20
27
|
export default _default;
|
|
21
28
|
//# sourceMappingURL=workflow-content-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-content-types.d.ts","sourceRoot":"","sources":["../../../../server/src/services/workflow-content-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow-content-types.d.ts","sourceRoot":"","sources":["../../../../server/src/services/workflow-content-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAMhD,kFAAkF;AAClF,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;yBAEe,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;IAiB/C;;;;;;OAMG;6DAKA,GAAG,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IA6CvC;;;;OAIG;sCACqC,GAAG,OAAO,GAAG,GAAG,OAAO,CAAC,mBAAmB,CAAC;;AA9ExF,wBAiGE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/services/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/services/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;yBAkC1B,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;IAmB/C;;;;;OAKG;gBACc,GAAG;IAapB;;;;;OAKG;iBACU,GAAG,SAAQ;QAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE;IAW1C;;;;;OAKG;iBACgB;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE;IAgEhC;;;;;;OAMG;qBACoB,GAAG,QAAQ,GAAG;IAkGrC;;;;;;OAMG;qBACoB,GAAG,QAAQ,GAAG;IAwCrC;;;OAGG;;IAKH;;;;;OAKG;6BAC4B,GAAG,SAAQ,GAAG;IAM7C;;;;;;;OAOG;+BAC8B,GAAG;IAOpC;;;;;OAKG;4CAC2C,GAAG;IAcjD;;;;;;OAMG;0CACmC,GAAG,YAAY,GAAG;;AAnV5D,wBA8VE"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Core } from '@strapi/types';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
2
|
+
/** Returns the content types that can use review workflow stages. */
|
|
3
|
+
export declare const getVisibleContentTypesUID: (contentTypes: Core.Strapi["contentTypes"]) => Array<keyof Core.Strapi["contentTypes"]>;
|
|
4
|
+
/** Checks whether a content type stores a review workflow stage. */
|
|
5
|
+
export declare const hasStageAttribute: (contentType: unknown) => boolean;
|
|
4
6
|
export declare const getWorkflowContentTypeFilter: ({ strapi }: {
|
|
5
7
|
strapi: Core.Strapi;
|
|
6
8
|
}, contentType: any) => {
|
|
@@ -10,13 +12,15 @@ export declare const getWorkflowContentTypeFilter: ({ strapi }: {
|
|
|
10
12
|
$contains: string;
|
|
11
13
|
$jsonSupersetOf?: undefined;
|
|
12
14
|
};
|
|
13
|
-
|
|
14
|
-
export declare const
|
|
15
|
+
/** Constrains the workflow limit to the supported range. */
|
|
16
|
+
export declare const clampMaxWorkflows: (value: number) => number;
|
|
17
|
+
/** Constrains the stage limit to the supported range. */
|
|
18
|
+
export declare const clampMaxStagesPerWorkflow: (value: number) => number;
|
|
15
19
|
declare const _default: {
|
|
16
|
-
clampMaxWorkflows:
|
|
17
|
-
clampMaxStagesPerWorkflow:
|
|
18
|
-
getVisibleContentTypesUID: (
|
|
19
|
-
hasStageAttribute:
|
|
20
|
+
clampMaxWorkflows: (value: number) => number;
|
|
21
|
+
clampMaxStagesPerWorkflow: (value: number) => number;
|
|
22
|
+
getVisibleContentTypesUID: (contentTypes: Core.Strapi["contentTypes"]) => Array<keyof Core.Strapi["contentTypes"]>;
|
|
23
|
+
hasStageAttribute: (contentType: unknown) => boolean;
|
|
20
24
|
getWorkflowContentTypeFilter: ({ strapi }: {
|
|
21
25
|
strapi: Core.Strapi;
|
|
22
26
|
}, contentType: any) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/utils/review-workflows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAQ1C,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"review-workflows.d.ts","sourceRoot":"","sources":["../../../../server/src/utils/review-workflows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAQ1C,qEAAqE;AACrE,eAAO,MAAM,yBAAyB,GAAI,cAAc,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAQ5E,KAAK,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;AAEhD,oEAAoE;AACpE,eAAO,MAAM,iBAAiB,GAAI,aAAa,OAAO,YACI,CAAC;AAE3D,eAAO,MAAM,4BAA4B,GACvC,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE,EACnC,aAAa,GAAG;;;;;;CAMjB,CAAC;AAEF,4DAA4D;AAC5D,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,WAAmC,CAAC;AACnF,yDAAyD;AACzD,eAAO,MAAM,yBAAyB,GAAI,OAAO,MAAM,WACb,CAAC;;+BAHF,MAAM;uCAEE,MAAM;8CA3BC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAQ5E,KAAK,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;qCAGA,OAAO;+CAIxC;QAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;KAAE,eACtB,GAAG;;;;;;;;AAclB,wBAME"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var lodash = require('lodash');
|
|
4
4
|
var workflows = require('../constants/workflows.js');
|
|
5
5
|
|
|
6
|
-
const getVisibleContentTypesUID =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
]);
|
|
12
|
-
const hasStageAttribute = fp.has([
|
|
13
|
-
'attributes',
|
|
14
|
-
workflows.ENTITY_STAGE_ATTRIBUTE
|
|
15
|
-
]);
|
|
6
|
+
/** Returns the content types that can use review workflow stages. */ const getVisibleContentTypesUID = (contentTypes)=>Object.keys(lodash.pickBy(contentTypes, (value)=>lodash.get(value, 'pluginOptions.content-manager.visible', true) && !lodash.get(value, 'options.noStageAttribute', false)));
|
|
7
|
+
/** Checks whether a content type stores a review workflow stage. */ const hasStageAttribute = (contentType)=>lodash.has(contentType, [
|
|
8
|
+
'attributes',
|
|
9
|
+
workflows.ENTITY_STAGE_ATTRIBUTE
|
|
10
|
+
]);
|
|
16
11
|
const getWorkflowContentTypeFilter = ({ strapi }, contentType)=>{
|
|
17
12
|
if (strapi.db.dialect.supportsOperator('$jsonSupersetOf')) {
|
|
18
13
|
return {
|
|
@@ -25,8 +20,8 @@ const getWorkflowContentTypeFilter = ({ strapi }, contentType)=>{
|
|
|
25
20
|
$contains: `"${contentType}"`
|
|
26
21
|
};
|
|
27
22
|
};
|
|
28
|
-
const clampMaxWorkflows =
|
|
29
|
-
const clampMaxStagesPerWorkflow =
|
|
23
|
+
/** Constrains the workflow limit to the supported range. */ const clampMaxWorkflows = (value)=>lodash.clamp(value, 1, workflows.MAX_WORKFLOWS);
|
|
24
|
+
/** Constrains the stage limit to the supported range. */ const clampMaxStagesPerWorkflow = (value)=>lodash.clamp(value, 1, workflows.MAX_STAGES_PER_WORKFLOW);
|
|
30
25
|
|
|
31
26
|
exports.clampMaxStagesPerWorkflow = clampMaxStagesPerWorkflow;
|
|
32
27
|
exports.clampMaxWorkflows = clampMaxWorkflows;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-workflows.js","sources":["../../../server/src/utils/review-workflows.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport {
|
|
1
|
+
{"version":3,"file":"review-workflows.js","sources":["../../../server/src/utils/review-workflows.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport { get, pickBy, has, clamp } from 'lodash';\nimport {\n ENTITY_STAGE_ATTRIBUTE,\n MAX_WORKFLOWS,\n MAX_STAGES_PER_WORKFLOW,\n} from '../constants/workflows';\n\n/** Returns the content types that can use review workflow stages. */\nexport const getVisibleContentTypesUID = (contentTypes: Core.Strapi['contentTypes']) =>\n Object.keys(\n pickBy(\n contentTypes,\n (value) =>\n get(value, 'pluginOptions.content-manager.visible', true) &&\n !get(value, 'options.noStageAttribute', false)\n )\n ) as Array<keyof Core.Strapi['contentTypes']>;\n\n/** Checks whether a content type stores a review workflow stage. */\nexport const hasStageAttribute = (contentType: unknown) =>\n has(contentType, ['attributes', ENTITY_STAGE_ATTRIBUTE]);\n\nexport const getWorkflowContentTypeFilter = (\n { strapi }: { strapi: Core.Strapi },\n contentType: any\n) => {\n if (strapi.db.dialect.supportsOperator('$jsonSupersetOf')) {\n return { $jsonSupersetOf: JSON.stringify([contentType]) };\n }\n return { $contains: `\"${contentType}\"` };\n};\n\n/** Constrains the workflow limit to the supported range. */\nexport const clampMaxWorkflows = (value: number) => clamp(value, 1, MAX_WORKFLOWS);\n/** Constrains the stage limit to the supported range. */\nexport const clampMaxStagesPerWorkflow = (value: number) =>\n clamp(value, 1, MAX_STAGES_PER_WORKFLOW);\n\nexport default {\n clampMaxWorkflows,\n clampMaxStagesPerWorkflow,\n getVisibleContentTypesUID,\n hasStageAttribute,\n getWorkflowContentTypeFilter,\n};\n"],"names":["getVisibleContentTypesUID","contentTypes","Object","keys","pickBy","value","get","hasStageAttribute","contentType","has","ENTITY_STAGE_ATTRIBUTE","getWorkflowContentTypeFilter","strapi","db","dialect","supportsOperator","$jsonSupersetOf","JSON","stringify","$contains","clampMaxWorkflows","clamp","MAX_WORKFLOWS","clampMaxStagesPerWorkflow","MAX_STAGES_PER_WORKFLOW"],"mappings":";;;;;AAQA,sEACO,MAAMA,yBAAAA,GAA4B,CAACC,YAAAA,GACxCC,MAAAA,CAAOC,IAAI,CACTC,aAAAA,CACEH,cACA,CAACI,KAAAA,GACCC,WAAID,KAAAA,EAAO,uCAAA,EAAyC,SACpD,CAACC,UAAAA,CAAID,KAAAA,EAAO,0BAAA,EAA4B,KAAA,CAAA,CAAA;AAIhD,qEACO,MAAME,oBAAoB,CAACC,WAAAA,GAChCC,WAAID,WAAAA,EAAa;AAAC,QAAA,YAAA;AAAcE,QAAAA;KAAuB;MAE5CC,4BAAAA,GAA+B,CAC1C,EAAEC,MAAM,EAA2B,EACnCJ,WAAAA,GAAAA;AAEA,IAAA,IAAII,OAAOC,EAAE,CAACC,OAAO,CAACC,gBAAgB,CAAC,iBAAA,CAAA,EAAoB;QACzD,OAAO;YAAEC,eAAAA,EAAiBC,IAAAA,CAAKC,SAAS,CAAC;AAACV,gBAAAA;AAAY,aAAA;AAAE,SAAA;AAC1D,IAAA;IACA,OAAO;AAAEW,QAAAA,SAAAA,EAAW,CAAC,CAAC,EAAEX,WAAAA,CAAY,CAAC;AAAE,KAAA;AACzC;AAEA,6DACO,MAAMY,iBAAAA,GAAoB,CAACf,KAAAA,GAAkBgB,YAAAA,CAAMhB,KAAAA,EAAO,CAAA,EAAGiB,uBAAAA;AACpE,0DACO,MAAMC,yBAAAA,GAA4B,CAAClB,KAAAA,GACxCgB,YAAAA,CAAMhB,KAAAA,EAAO,CAAA,EAAGmB,iCAAAA;;;;;;;;"}
|