@strapi/content-releases 5.30.0 → 5.30.1
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/admin/components/EntryValidationPopover.js.map +1 -1
- package/dist/admin/components/EntryValidationPopover.mjs.map +1 -1
- package/dist/admin/components/RelativeTime.js.map +1 -1
- package/dist/admin/components/RelativeTime.mjs.map +1 -1
- package/dist/admin/components/ReleaseActionMenu.js.map +1 -1
- package/dist/admin/components/ReleaseActionMenu.mjs.map +1 -1
- package/dist/admin/components/ReleaseActionOptions.js.map +1 -1
- package/dist/admin/components/ReleaseActionOptions.mjs.map +1 -1
- package/dist/admin/components/ReleaseListCell.js.map +1 -1
- package/dist/admin/components/ReleaseListCell.mjs.map +1 -1
- package/dist/admin/components/ReleaseModal.js.map +1 -1
- package/dist/admin/components/ReleaseModal.mjs.map +1 -1
- package/dist/admin/components/ReleasesPanel.js.map +1 -1
- package/dist/admin/components/ReleasesPanel.mjs.map +1 -1
- package/dist/admin/components/Widgets.js.map +1 -1
- package/dist/admin/components/Widgets.mjs.map +1 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/pages/ReleaseDetailsPage.js.map +1 -1
- package/dist/admin/pages/ReleaseDetailsPage.mjs.map +1 -1
- package/dist/admin/pages/ReleasesPage.js.map +1 -1
- package/dist/admin/pages/ReleasesPage.mjs.map +1 -1
- package/dist/admin/services/release.js.map +1 -1
- package/dist/admin/services/release.mjs.map +1 -1
- package/dist/admin/src/services/homepage.d.ts +1 -1
- package/dist/admin/src/services/release.d.ts +28 -28
- package/dist/admin/utils/prefixPluginTranslations.js.map +1 -1
- package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -1
- package/dist/admin/utils/time.js.map +1 -1
- package/dist/admin/utils/time.mjs.map +1 -1
- package/dist/admin/validation/schemas.js.map +1 -1
- package/dist/admin/validation/schemas.mjs.map +1 -1
- package/dist/server/controllers/release.js.map +1 -1
- package/dist/server/controllers/release.mjs.map +1 -1
- package/dist/server/services/release-action.js.map +1 -1
- package/dist/server/services/release-action.mjs.map +1 -1
- package/dist/server/services/release.js.map +1 -1
- package/dist/server/services/release.mjs.map +1 -1
- package/dist/server/services/scheduling.js.map +1 -1
- package/dist/server/services/scheduling.mjs.map +1 -1
- package/dist/server/services/validation.js.map +1 -1
- package/dist/server/services/validation.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sources":["../../../server/src/services/validation.ts"],"sourcesContent":["import { errors, contentTypes } from '@strapi/utils';\nimport type { Core, UID } from '@strapi/types';\nimport type { Release, CreateRelease, UpdateRelease } from '../../../shared/contracts/releases';\nimport type { CreateReleaseAction } from '../../../shared/contracts/release-actions';\nimport { RELEASE_MODEL_UID } from '../constants';\n\nexport class AlreadyOnReleaseError extends errors.ApplicationError<'AlreadyOnReleaseError'> {\n constructor(message: string) {\n super(message);\n this.name = 'AlreadyOnReleaseError';\n }\n}\n\nconst createReleaseValidationService = ({ strapi }: { strapi: Core.Strapi }) => ({\n async validateUniqueEntry(\n releaseId: CreateReleaseAction.Request['params']['releaseId'],\n releaseActionArgs: CreateReleaseAction.Request['body']\n ) {\n /**\n * Asserting the type, otherwise TS complains: 'release.actions' is of type 'unknown', even though the types come through for non-populated fields...\n * Possibly related to the comment on GetValues: https://github.com/strapi/strapi/blob/main/packages/core/types/src/modules/entity-service/result.ts\n */\n const release = (await strapi.db.query(RELEASE_MODEL_UID).findOne({\n where: {\n id: releaseId,\n },\n populate: {\n actions: true,\n },\n })) as Release | null;\n\n if (!release) {\n throw new errors.NotFoundError(`No release found for id ${releaseId}`);\n }\n\n const isEntryInRelease = release.actions.some(\n (action) =>\n action.entryDocumentId === releaseActionArgs.entryDocumentId &&\n action.contentType === releaseActionArgs.contentType &&\n (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)\n );\n\n if (isEntryInRelease) {\n throw new AlreadyOnReleaseError(\n `Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ''} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`\n );\n }\n },\n validateEntryData(\n contentTypeUid: CreateReleaseAction.Request['body']['contentType'],\n entryDocumentId: CreateReleaseAction.Request['body']['entryDocumentId']\n ) {\n const contentType = strapi.contentType(contentTypeUid as UID.ContentType);\n\n if (!contentType) {\n throw new errors.NotFoundError(`No content type found for uid ${contentTypeUid}`);\n }\n\n if (!contentTypes.hasDraftAndPublish(contentType)) {\n throw new errors.ValidationError(\n `Content type with uid ${contentTypeUid} does not have draftAndPublish enabled`\n );\n }\n\n if (contentType.kind === 'collectionType' && !entryDocumentId) {\n throw new errors.ValidationError('Document id is required for collection type');\n }\n },\n async validatePendingReleasesLimit() {\n // Use the maximum releases option if it exists, otherwise default to 3\n const featureCfg = strapi.ee.features.get('cms-content-releases');\n\n const maximumPendingReleases =\n (typeof featureCfg === 'object' && featureCfg?.options?.maximumReleases) || 3;\n\n const [, pendingReleasesCount] = await strapi.db.query(RELEASE_MODEL_UID).findWithCount({\n filters: {\n releasedAt: {\n $null: true,\n },\n },\n });\n\n // Unlimited is a number that will never be reached like 9999\n if (pendingReleasesCount >= maximumPendingReleases) {\n throw new errors.ValidationError('You have reached the maximum number of pending releases');\n }\n },\n async validateUniqueNameForPendingRelease(\n name: CreateRelease.Request['body']['name'],\n id?: UpdateRelease.Request['params']['id']\n ) {\n const pendingReleases = (await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n releasedAt: {\n $null: true,\n },\n name,\n ...(id && { id: { $ne: id } }),\n },\n })) as Release[];\n\n const isNameUnique = pendingReleases.length === 0;\n\n if (!isNameUnique) {\n throw new errors.ValidationError(`Release with name ${name} already exists`);\n }\n },\n async validateScheduledAtIsLaterThanNow(\n scheduledAt: CreateRelease.Request['body']['scheduledAt']\n ) {\n if (scheduledAt && new Date(scheduledAt) <= new Date()) {\n throw new errors.ValidationError('Scheduled at must be later than now');\n }\n },\n});\n\nexport default createReleaseValidationService;\n"],"names":["AlreadyOnReleaseError","errors","ApplicationError","
|
|
1
|
+
{"version":3,"file":"validation.js","sources":["../../../server/src/services/validation.ts"],"sourcesContent":["import { errors, contentTypes } from '@strapi/utils';\nimport type { Core, UID } from '@strapi/types';\nimport type { Release, CreateRelease, UpdateRelease } from '../../../shared/contracts/releases';\nimport type { CreateReleaseAction } from '../../../shared/contracts/release-actions';\nimport { RELEASE_MODEL_UID } from '../constants';\n\nexport class AlreadyOnReleaseError extends errors.ApplicationError<'AlreadyOnReleaseError'> {\n constructor(message: string) {\n super(message);\n this.name = 'AlreadyOnReleaseError';\n }\n}\n\nconst createReleaseValidationService = ({ strapi }: { strapi: Core.Strapi }) => ({\n async validateUniqueEntry(\n releaseId: CreateReleaseAction.Request['params']['releaseId'],\n releaseActionArgs: CreateReleaseAction.Request['body']\n ) {\n /**\n * Asserting the type, otherwise TS complains: 'release.actions' is of type 'unknown', even though the types come through for non-populated fields...\n * Possibly related to the comment on GetValues: https://github.com/strapi/strapi/blob/main/packages/core/types/src/modules/entity-service/result.ts\n */\n const release = (await strapi.db.query(RELEASE_MODEL_UID).findOne({\n where: {\n id: releaseId,\n },\n populate: {\n actions: true,\n },\n })) as Release | null;\n\n if (!release) {\n throw new errors.NotFoundError(`No release found for id ${releaseId}`);\n }\n\n const isEntryInRelease = release.actions.some(\n (action) =>\n action.entryDocumentId === releaseActionArgs.entryDocumentId &&\n action.contentType === releaseActionArgs.contentType &&\n (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)\n );\n\n if (isEntryInRelease) {\n throw new AlreadyOnReleaseError(\n `Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ''} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`\n );\n }\n },\n validateEntryData(\n contentTypeUid: CreateReleaseAction.Request['body']['contentType'],\n entryDocumentId: CreateReleaseAction.Request['body']['entryDocumentId']\n ) {\n const contentType = strapi.contentType(contentTypeUid as UID.ContentType);\n\n if (!contentType) {\n throw new errors.NotFoundError(`No content type found for uid ${contentTypeUid}`);\n }\n\n if (!contentTypes.hasDraftAndPublish(contentType)) {\n throw new errors.ValidationError(\n `Content type with uid ${contentTypeUid} does not have draftAndPublish enabled`\n );\n }\n\n if (contentType.kind === 'collectionType' && !entryDocumentId) {\n throw new errors.ValidationError('Document id is required for collection type');\n }\n },\n async validatePendingReleasesLimit() {\n // Use the maximum releases option if it exists, otherwise default to 3\n const featureCfg = strapi.ee.features.get('cms-content-releases');\n\n const maximumPendingReleases =\n (typeof featureCfg === 'object' && featureCfg?.options?.maximumReleases) || 3;\n\n const [, pendingReleasesCount] = await strapi.db.query(RELEASE_MODEL_UID).findWithCount({\n filters: {\n releasedAt: {\n $null: true,\n },\n },\n });\n\n // Unlimited is a number that will never be reached like 9999\n if (pendingReleasesCount >= maximumPendingReleases) {\n throw new errors.ValidationError('You have reached the maximum number of pending releases');\n }\n },\n async validateUniqueNameForPendingRelease(\n name: CreateRelease.Request['body']['name'],\n id?: UpdateRelease.Request['params']['id']\n ) {\n const pendingReleases = (await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n releasedAt: {\n $null: true,\n },\n name,\n ...(id && { id: { $ne: id } }),\n },\n })) as Release[];\n\n const isNameUnique = pendingReleases.length === 0;\n\n if (!isNameUnique) {\n throw new errors.ValidationError(`Release with name ${name} already exists`);\n }\n },\n async validateScheduledAtIsLaterThanNow(\n scheduledAt: CreateRelease.Request['body']['scheduledAt']\n ) {\n if (scheduledAt && new Date(scheduledAt) <= new Date()) {\n throw new errors.ValidationError('Scheduled at must be later than now');\n }\n },\n});\n\nexport default createReleaseValidationService;\n"],"names":["AlreadyOnReleaseError","errors","ApplicationError","message","name","createReleaseValidationService","strapi","validateUniqueEntry","releaseId","releaseActionArgs","release","db","query","RELEASE_MODEL_UID","findOne","where","id","populate","actions","NotFoundError","isEntryInRelease","some","action","entryDocumentId","contentType","locale","validateEntryData","contentTypeUid","contentTypes","hasDraftAndPublish","ValidationError","kind","validatePendingReleasesLimit","featureCfg","ee","features","get","maximumPendingReleases","options","maximumReleases","pendingReleasesCount","findWithCount","filters","releasedAt","$null","validateUniqueNameForPendingRelease","pendingReleases","findMany","$ne","isNameUnique","length","validateScheduledAtIsLaterThanNow","scheduledAt","Date"],"mappings":";;;;;;;AAMO,MAAMA,qBAA8BC,SAAAA,YAAAA,CAAOC,gBAAgB,CAAA;AAChE,IAAA,WAAA,CAAYC,OAAe,CAAE;AAC3B,QAAA,KAAK,CAACA,OAAAA,CAAAA;QACN,IAAI,CAACC,IAAI,GAAG,uBAAA;AACd;AACF;AAEA,MAAMC,iCAAiC,CAAC,EAAEC,MAAM,EAA2B,IAAM;QAC/E,MAAMC,mBAAAA,CAAAA,CACJC,SAA6D,EAC7DC,iBAAsD,EAAA;AAEtD;;;QAIA,MAAMC,OAAW,GAAA,MAAMJ,MAAOK,CAAAA,EAAE,CAACC,KAAK,CAACC,2BAAmBC,CAAAA,CAAAA,OAAO,CAAC;gBAChEC,KAAO,EAAA;oBACLC,EAAIR,EAAAA;AACN,iBAAA;gBACAS,QAAU,EAAA;oBACRC,OAAS,EAAA;AACX;AACF,aAAA,CAAA;AAEA,YAAA,IAAI,CAACR,OAAS,EAAA;AACZ,gBAAA,MAAM,IAAIT,YAAOkB,CAAAA,aAAa,CAAC,CAAC,wBAAwB,EAAEX,SAAW,CAAA,CAAA,CAAA;AACvE;AAEA,YAAA,MAAMY,gBAAmBV,GAAAA,OAAAA,CAAQQ,OAAO,CAACG,IAAI,CAC3C,CAACC,MAAAA,GACCA,MAAOC,CAAAA,eAAe,KAAKd,iBAAAA,CAAkBc,eAAe,IAC5DD,MAAAA,CAAOE,WAAW,KAAKf,iBAAkBe,CAAAA,WAAW,KACnDf,iBAAkBgB,CAAAA,MAAM,GAAGH,MAAAA,CAAOG,MAAM,KAAKhB,iBAAkBgB,CAAAA,MA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{ errors, contentTypes } from '@strapi/utils';\nimport type { Core, UID } from '@strapi/types';\nimport type { Release, CreateRelease, UpdateRelease } from '../../../shared/contracts/releases';\nimport type { CreateReleaseAction } from '../../../shared/contracts/release-actions';\nimport { RELEASE_MODEL_UID } from '../constants';\n\nexport class AlreadyOnReleaseError extends errors.ApplicationError<'AlreadyOnReleaseError'> {\n constructor(message: string) {\n super(message);\n this.name = 'AlreadyOnReleaseError';\n }\n}\n\nconst createReleaseValidationService = ({ strapi }: { strapi: Core.Strapi }) => ({\n async validateUniqueEntry(\n releaseId: CreateReleaseAction.Request['params']['releaseId'],\n releaseActionArgs: CreateReleaseAction.Request['body']\n ) {\n /**\n * Asserting the type, otherwise TS complains: 'release.actions' is of type 'unknown', even though the types come through for non-populated fields...\n * Possibly related to the comment on GetValues: https://github.com/strapi/strapi/blob/main/packages/core/types/src/modules/entity-service/result.ts\n */\n const release = (await strapi.db.query(RELEASE_MODEL_UID).findOne({\n where: {\n id: releaseId,\n },\n populate: {\n actions: true,\n },\n })) as Release | null;\n\n if (!release) {\n throw new errors.NotFoundError(`No release found for id ${releaseId}`);\n }\n\n const isEntryInRelease = release.actions.some(\n (action) =>\n action.entryDocumentId === releaseActionArgs.entryDocumentId &&\n action.contentType === releaseActionArgs.contentType &&\n (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)\n );\n\n if (isEntryInRelease) {\n throw new AlreadyOnReleaseError(\n `Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ''} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`\n );\n }\n },\n validateEntryData(\n contentTypeUid: CreateReleaseAction.Request['body']['contentType'],\n entryDocumentId: CreateReleaseAction.Request['body']['entryDocumentId']\n ) {\n const contentType = strapi.contentType(contentTypeUid as UID.ContentType);\n\n if (!contentType) {\n throw new errors.NotFoundError(`No content type found for uid ${contentTypeUid}`);\n }\n\n if (!contentTypes.hasDraftAndPublish(contentType)) {\n throw new errors.ValidationError(\n `Content type with uid ${contentTypeUid} does not have draftAndPublish enabled`\n );\n }\n\n if (contentType.kind === 'collectionType' && !entryDocumentId) {\n throw new errors.ValidationError('Document id is required for collection type');\n }\n },\n async validatePendingReleasesLimit() {\n // Use the maximum releases option if it exists, otherwise default to 3\n const featureCfg = strapi.ee.features.get('cms-content-releases');\n\n const maximumPendingReleases =\n (typeof featureCfg === 'object' && featureCfg?.options?.maximumReleases) || 3;\n\n const [, pendingReleasesCount] = await strapi.db.query(RELEASE_MODEL_UID).findWithCount({\n filters: {\n releasedAt: {\n $null: true,\n },\n },\n });\n\n // Unlimited is a number that will never be reached like 9999\n if (pendingReleasesCount >= maximumPendingReleases) {\n throw new errors.ValidationError('You have reached the maximum number of pending releases');\n }\n },\n async validateUniqueNameForPendingRelease(\n name: CreateRelease.Request['body']['name'],\n id?: UpdateRelease.Request['params']['id']\n ) {\n const pendingReleases = (await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n releasedAt: {\n $null: true,\n },\n name,\n ...(id && { id: { $ne: id } }),\n },\n })) as Release[];\n\n const isNameUnique = pendingReleases.length === 0;\n\n if (!isNameUnique) {\n throw new errors.ValidationError(`Release with name ${name} already exists`);\n }\n },\n async validateScheduledAtIsLaterThanNow(\n scheduledAt: CreateRelease.Request['body']['scheduledAt']\n ) {\n if (scheduledAt && new Date(scheduledAt) <= new Date()) {\n throw new errors.ValidationError('Scheduled at must be later than now');\n }\n },\n});\n\nexport default createReleaseValidationService;\n"],"names":["AlreadyOnReleaseError","errors","ApplicationError","
|
|
1
|
+
{"version":3,"file":"validation.mjs","sources":["../../../server/src/services/validation.ts"],"sourcesContent":["import { errors, contentTypes } from '@strapi/utils';\nimport type { Core, UID } from '@strapi/types';\nimport type { Release, CreateRelease, UpdateRelease } from '../../../shared/contracts/releases';\nimport type { CreateReleaseAction } from '../../../shared/contracts/release-actions';\nimport { RELEASE_MODEL_UID } from '../constants';\n\nexport class AlreadyOnReleaseError extends errors.ApplicationError<'AlreadyOnReleaseError'> {\n constructor(message: string) {\n super(message);\n this.name = 'AlreadyOnReleaseError';\n }\n}\n\nconst createReleaseValidationService = ({ strapi }: { strapi: Core.Strapi }) => ({\n async validateUniqueEntry(\n releaseId: CreateReleaseAction.Request['params']['releaseId'],\n releaseActionArgs: CreateReleaseAction.Request['body']\n ) {\n /**\n * Asserting the type, otherwise TS complains: 'release.actions' is of type 'unknown', even though the types come through for non-populated fields...\n * Possibly related to the comment on GetValues: https://github.com/strapi/strapi/blob/main/packages/core/types/src/modules/entity-service/result.ts\n */\n const release = (await strapi.db.query(RELEASE_MODEL_UID).findOne({\n where: {\n id: releaseId,\n },\n populate: {\n actions: true,\n },\n })) as Release | null;\n\n if (!release) {\n throw new errors.NotFoundError(`No release found for id ${releaseId}`);\n }\n\n const isEntryInRelease = release.actions.some(\n (action) =>\n action.entryDocumentId === releaseActionArgs.entryDocumentId &&\n action.contentType === releaseActionArgs.contentType &&\n (releaseActionArgs.locale ? action.locale === releaseActionArgs.locale : true)\n );\n\n if (isEntryInRelease) {\n throw new AlreadyOnReleaseError(\n `Entry with documentId ${releaseActionArgs.entryDocumentId}${releaseActionArgs.locale ? `( ${releaseActionArgs.locale})` : ''} and contentType ${releaseActionArgs.contentType} already exists in release with id ${releaseId}`\n );\n }\n },\n validateEntryData(\n contentTypeUid: CreateReleaseAction.Request['body']['contentType'],\n entryDocumentId: CreateReleaseAction.Request['body']['entryDocumentId']\n ) {\n const contentType = strapi.contentType(contentTypeUid as UID.ContentType);\n\n if (!contentType) {\n throw new errors.NotFoundError(`No content type found for uid ${contentTypeUid}`);\n }\n\n if (!contentTypes.hasDraftAndPublish(contentType)) {\n throw new errors.ValidationError(\n `Content type with uid ${contentTypeUid} does not have draftAndPublish enabled`\n );\n }\n\n if (contentType.kind === 'collectionType' && !entryDocumentId) {\n throw new errors.ValidationError('Document id is required for collection type');\n }\n },\n async validatePendingReleasesLimit() {\n // Use the maximum releases option if it exists, otherwise default to 3\n const featureCfg = strapi.ee.features.get('cms-content-releases');\n\n const maximumPendingReleases =\n (typeof featureCfg === 'object' && featureCfg?.options?.maximumReleases) || 3;\n\n const [, pendingReleasesCount] = await strapi.db.query(RELEASE_MODEL_UID).findWithCount({\n filters: {\n releasedAt: {\n $null: true,\n },\n },\n });\n\n // Unlimited is a number that will never be reached like 9999\n if (pendingReleasesCount >= maximumPendingReleases) {\n throw new errors.ValidationError('You have reached the maximum number of pending releases');\n }\n },\n async validateUniqueNameForPendingRelease(\n name: CreateRelease.Request['body']['name'],\n id?: UpdateRelease.Request['params']['id']\n ) {\n const pendingReleases = (await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n releasedAt: {\n $null: true,\n },\n name,\n ...(id && { id: { $ne: id } }),\n },\n })) as Release[];\n\n const isNameUnique = pendingReleases.length === 0;\n\n if (!isNameUnique) {\n throw new errors.ValidationError(`Release with name ${name} already exists`);\n }\n },\n async validateScheduledAtIsLaterThanNow(\n scheduledAt: CreateRelease.Request['body']['scheduledAt']\n ) {\n if (scheduledAt && new Date(scheduledAt) <= new Date()) {\n throw new errors.ValidationError('Scheduled at must be later than now');\n }\n },\n});\n\nexport default createReleaseValidationService;\n"],"names":["AlreadyOnReleaseError","errors","ApplicationError","message","name","createReleaseValidationService","strapi","validateUniqueEntry","releaseId","releaseActionArgs","release","db","query","RELEASE_MODEL_UID","findOne","where","id","populate","actions","NotFoundError","isEntryInRelease","some","action","entryDocumentId","contentType","locale","validateEntryData","contentTypeUid","contentTypes","hasDraftAndPublish","ValidationError","kind","validatePendingReleasesLimit","featureCfg","ee","features","get","maximumPendingReleases","options","maximumReleases","pendingReleasesCount","findWithCount","filters","releasedAt","$null","validateUniqueNameForPendingRelease","pendingReleases","findMany","$ne","isNameUnique","length","validateScheduledAtIsLaterThanNow","scheduledAt","Date"],"mappings":";;;AAMO,MAAMA,qBAA8BC,SAAAA,MAAAA,CAAOC,gBAAgB,CAAA;AAChE,IAAA,WAAA,CAAYC,OAAe,CAAE;AA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3CY,EAA0C,EAAA;YAE1C,MAAM8B,eAAAA,GAAmB,MAAMxC,MAAOK,CAAAA,EAAE,CAACC,KAAK,CAACC,iBAAmBkC,CAAAA,CAAAA,QAAQ,CAAC;gBACzEhC,KAAO,EAAA;oBACL4B,UAAY,EAAA;wBACVC,KAAO,EAAA;AACT,qBAAA;AACAxC,oBAAAA,IAAAA;AACA,oBAAA,GAAIY,EAAM,IAAA;wBAAEA,EAAI,EAAA;4BAAEgC,GAAKhC,EAAAA;AAAG;;AAC5B;AACF,aAAA,CAAA;YAEA,MAAMiC,YAAAA,GAAeH,eAAgBI,CAAAA,MAAM,KAAK,CAAA;AAEhD,YAAA,IAAI,CAACD,YAAc,EAAA;gBACjB,MAAM,IAAIhD,OAAO6B,eAAe,CAAC,CAAC,kBAAkB,EAAE1B,IAAK,CAAA,eAAe,CAAC,CAAA;AAC7E;AACF,SAAA;AACA,QAAA,MAAM+C,mCACJC,WAAyD,EAAA;AAEzD,YAAA,IAAIA,WAAe,IAAA,IAAIC,IAAKD,CAAAA,WAAAA,CAAAA,IAAgB,IAAIC,IAAQ,EAAA,EAAA;gBACtD,MAAM,IAAIpD,MAAO6B,CAAAA,eAAe,CAAC,qCAAA,CAAA;AACnC;AACF;KACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/content-releases",
|
|
3
|
-
"version": "5.30.
|
|
3
|
+
"version": "5.30.1",
|
|
4
4
|
"description": "Strapi plugin for organizing and releasing content",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@reduxjs/toolkit": "1.9.7",
|
|
62
|
-
"@strapi/database": "5.30.
|
|
62
|
+
"@strapi/database": "5.30.1",
|
|
63
63
|
"@strapi/design-system": "2.0.0-rc.30",
|
|
64
64
|
"@strapi/icons": "2.0.0-rc.30",
|
|
65
|
-
"@strapi/types": "5.30.
|
|
66
|
-
"@strapi/utils": "5.30.
|
|
65
|
+
"@strapi/types": "5.30.1",
|
|
66
|
+
"@strapi/utils": "5.30.1",
|
|
67
67
|
"date-fns": "2.30.0",
|
|
68
68
|
"date-fns-tz": "2.0.1",
|
|
69
69
|
"formik": "2.4.5",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"yup": "0.32.9"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@strapi/admin": "5.30.
|
|
78
|
-
"@strapi/admin-test-utils": "5.30.
|
|
79
|
-
"@strapi/content-manager": "5.30.
|
|
77
|
+
"@strapi/admin": "5.30.1",
|
|
78
|
+
"@strapi/admin-test-utils": "5.30.1",
|
|
79
|
+
"@strapi/content-manager": "5.30.1",
|
|
80
80
|
"@testing-library/dom": "10.1.0",
|
|
81
81
|
"@testing-library/react": "15.0.7",
|
|
82
82
|
"@testing-library/user-event": "14.5.2",
|