@strapi/content-releases 5.18.1 → 5.20.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/admin/index.js +1 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +1 -0
- package/dist/admin/index.mjs.map +1 -1
- package/dist/server/destroy.js +2 -2
- package/dist/server/destroy.js.map +1 -1
- package/dist/server/destroy.mjs +2 -2
- package/dist/server/destroy.mjs.map +1 -1
- package/dist/server/services/scheduling.js +16 -12
- package/dist/server/services/scheduling.js.map +1 -1
- package/dist/server/services/scheduling.mjs +16 -12
- package/dist/server/services/scheduling.mjs.map +1 -1
- package/dist/server/src/destroy.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -4
- package/dist/server/src/services/index.d.ts +4 -4
- package/dist/server/src/services/scheduling.d.ts +4 -5
- package/dist/server/src/services/scheduling.d.ts.map +1 -1
- package/package.json +7 -8
package/dist/admin/index.js
CHANGED
|
@@ -67,6 +67,7 @@ const admin = {
|
|
|
67
67
|
id: `${pluginId.pluginId}.plugin.name`,
|
|
68
68
|
defaultMessage: 'Releases'
|
|
69
69
|
},
|
|
70
|
+
licenseOnly: true,
|
|
70
71
|
permissions: [],
|
|
71
72
|
async Component () {
|
|
72
73
|
const { ProtectedReleasesSettingsPage } = await Promise.resolve().then(function () { return require('./pages/ReleasesSettingsPage.js'); });
|
package/dist/admin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../admin/src/index.ts"],"sourcesContent":["import { PaperPlane } from '@strapi/icons';\n\nimport { ReleaseAction } from './components/ReleaseAction';\nimport { ReleaseActionModalForm } from './components/ReleaseActionModal';\nimport { addColumnToTableHook } from './components/ReleaseListCell';\nimport { Panel as ReleasesPanel } from './components/ReleasesPanel';\nimport { PERMISSIONS } from './constants';\nimport { pluginId } from './pluginId';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n\nimport type { StrapiApp } from '@strapi/admin/strapi-admin';\nimport type {\n DocumentActionComponent,\n BulkActionComponent,\n} from '@strapi/content-manager/strapi-admin';\nimport type { Plugin } from '@strapi/types';\n\n// eslint-disable-next-line import/no-default-export\nconst admin: Plugin.Config.AdminInput = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register(app: StrapiApp) {\n /**\n * Hook that adds the locale column in the Release Details table\n * @constant\n * @type {string}\n */\n app.createHook('ContentReleases/pages/ReleaseDetails/add-locale-in-releases');\n\n if (window.strapi.features.isEnabled('cms-content-releases')) {\n app.addMenuLink({\n to: `plugins/${pluginId}`,\n icon: PaperPlane,\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n Component: () => import('./pages/App').then((mod) => ({ default: mod.App })),\n permissions: PERMISSIONS.main,\n position: 2,\n });\n\n // Insert the releases container into the CM's sidebar on the Edit View\n const contentManagerPluginApis = app.getPlugin('content-manager').apis;\n if (\n 'addEditViewSidePanel' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addEditViewSidePanel === 'function'\n ) {\n contentManagerPluginApis.addEditViewSidePanel([ReleasesPanel]);\n }\n\n // Insert the \"add to release\" action into the CM's Edit View\n if (\n 'addDocumentAction' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addDocumentAction === 'function'\n ) {\n contentManagerPluginApis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'unpublish');\n actions.splice(indexOfDeleteAction, 0, ReleaseActionModalForm);\n return actions;\n });\n }\n\n app.addSettingsLink('global', {\n id: pluginId,\n to: 'releases',\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n permissions: [],\n async Component() {\n const { ProtectedReleasesSettingsPage } = await import('./pages/ReleasesSettingsPage');\n return { default: ProtectedReleasesSettingsPage };\n },\n });\n\n if (\n 'addBulkAction' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addBulkAction === 'function'\n ) {\n contentManagerPluginApis.addBulkAction((actions: BulkActionComponent[]) => {\n // We want to add this action to just before the delete action all the time\n const deleteActionIndex = actions.findIndex((action) => action.type === 'delete');\n\n actions.splice(deleteActionIndex, 0, ReleaseAction);\n return actions;\n });\n }\n\n // Hook that adds a column into the CM's LV table\n app.registerHook('Admin/CM/pages/ListView/inject-column-in-table', addColumnToTableHook);\n } else if (\n !window.strapi.features.isEnabled('cms-content-releases') &&\n window.strapi?.flags?.promoteEE\n ) {\n app.addSettingsLink('global', {\n id: pluginId,\n to: '/plugins/purchase-content-releases',\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n permissions: [],\n async Component() {\n const { PurchaseContentReleases } = await import('./pages/PurchaseContentReleases');\n return { default: PurchaseContentReleases };\n },\n licenseOnly: true,\n });\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, 'content-releases'),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default admin;\n"],"names":["admin","register","app","createHook","window","strapi","features","isEnabled","addMenuLink","to","pluginId","icon","PaperPlane","intlLabel","id","defaultMessage","Component","then","mod","default","App","permissions","PERMISSIONS","main","position","contentManagerPluginApis","getPlugin","apis","addEditViewSidePanel","ReleasesPanel","addDocumentAction","actions","indexOfDeleteAction","findIndex","action","type","splice","ReleaseActionModalForm","addSettingsLink","ProtectedReleasesSettingsPage","addBulkAction","deleteActionIndex","ReleaseAction","registerHook","addColumnToTableHook","flags","promoteEE","PurchaseContentReleases","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../admin/src/index.ts"],"sourcesContent":["import { PaperPlane } from '@strapi/icons';\n\nimport { ReleaseAction } from './components/ReleaseAction';\nimport { ReleaseActionModalForm } from './components/ReleaseActionModal';\nimport { addColumnToTableHook } from './components/ReleaseListCell';\nimport { Panel as ReleasesPanel } from './components/ReleasesPanel';\nimport { PERMISSIONS } from './constants';\nimport { pluginId } from './pluginId';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n\nimport type { StrapiApp } from '@strapi/admin/strapi-admin';\nimport type {\n DocumentActionComponent,\n BulkActionComponent,\n} from '@strapi/content-manager/strapi-admin';\nimport type { Plugin } from '@strapi/types';\n\n// eslint-disable-next-line import/no-default-export\nconst admin: Plugin.Config.AdminInput = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register(app: StrapiApp) {\n /**\n * Hook that adds the locale column in the Release Details table\n * @constant\n * @type {string}\n */\n app.createHook('ContentReleases/pages/ReleaseDetails/add-locale-in-releases');\n\n if (window.strapi.features.isEnabled('cms-content-releases')) {\n app.addMenuLink({\n to: `plugins/${pluginId}`,\n icon: PaperPlane,\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n Component: () => import('./pages/App').then((mod) => ({ default: mod.App })),\n permissions: PERMISSIONS.main,\n position: 2,\n });\n\n // Insert the releases container into the CM's sidebar on the Edit View\n const contentManagerPluginApis = app.getPlugin('content-manager').apis;\n if (\n 'addEditViewSidePanel' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addEditViewSidePanel === 'function'\n ) {\n contentManagerPluginApis.addEditViewSidePanel([ReleasesPanel]);\n }\n\n // Insert the \"add to release\" action into the CM's Edit View\n if (\n 'addDocumentAction' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addDocumentAction === 'function'\n ) {\n contentManagerPluginApis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'unpublish');\n actions.splice(indexOfDeleteAction, 0, ReleaseActionModalForm);\n return actions;\n });\n }\n\n app.addSettingsLink('global', {\n id: pluginId,\n to: 'releases',\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n licenseOnly: true,\n permissions: [],\n async Component() {\n const { ProtectedReleasesSettingsPage } = await import('./pages/ReleasesSettingsPage');\n return { default: ProtectedReleasesSettingsPage };\n },\n });\n\n if (\n 'addBulkAction' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addBulkAction === 'function'\n ) {\n contentManagerPluginApis.addBulkAction((actions: BulkActionComponent[]) => {\n // We want to add this action to just before the delete action all the time\n const deleteActionIndex = actions.findIndex((action) => action.type === 'delete');\n\n actions.splice(deleteActionIndex, 0, ReleaseAction);\n return actions;\n });\n }\n\n // Hook that adds a column into the CM's LV table\n app.registerHook('Admin/CM/pages/ListView/inject-column-in-table', addColumnToTableHook);\n } else if (\n !window.strapi.features.isEnabled('cms-content-releases') &&\n window.strapi?.flags?.promoteEE\n ) {\n app.addSettingsLink('global', {\n id: pluginId,\n to: '/plugins/purchase-content-releases',\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n permissions: [],\n async Component() {\n const { PurchaseContentReleases } = await import('./pages/PurchaseContentReleases');\n return { default: PurchaseContentReleases };\n },\n licenseOnly: true,\n });\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, 'content-releases'),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default admin;\n"],"names":["admin","register","app","createHook","window","strapi","features","isEnabled","addMenuLink","to","pluginId","icon","PaperPlane","intlLabel","id","defaultMessage","Component","then","mod","default","App","permissions","PERMISSIONS","main","position","contentManagerPluginApis","getPlugin","apis","addEditViewSidePanel","ReleasesPanel","addDocumentAction","actions","indexOfDeleteAction","findIndex","action","type","splice","ReleaseActionModalForm","addSettingsLink","licenseOnly","ProtectedReleasesSettingsPage","addBulkAction","deleteActionIndex","ReleaseAction","registerHook","addColumnToTableHook","flags","promoteEE","PurchaseContentReleases","registerTrads","locales","importedTrads","Promise","all","map","locale","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiBA;AACA,MAAMA,KAAkC,GAAA;;AAEtCC,IAAAA,QAAAA,CAAAA,CAASC,GAAc,EAAA;AACrB;;;;QAKAA,GAAAA,CAAIC,UAAU,CAAC,6DAAA,CAAA;AAEf,QAAA,IAAIC,OAAOC,MAAM,CAACC,QAAQ,CAACC,SAAS,CAAC,sBAAyB,CAAA,EAAA;AAC5DL,YAAAA,GAAAA,CAAIM,WAAW,CAAC;AACdC,gBAAAA,EAAAA,EAAI,CAAC,QAAQ,EAAEC,iBAAAA,CAAS,CAAC;gBACzBC,IAAMC,EAAAA,gBAAAA;gBACNC,SAAW,EAAA;AACTC,oBAAAA,EAAAA,EAAI,CAAC,EAAEJ,iBAAS,CAAA,YAAY,CAAC;oBAC7BK,cAAgB,EAAA;AAClB,iBAAA;gBACAC,SAAW,EAAA,IAAM,oDAAO,gBAAA,KAAA,CAAeC,IAAI,CAAC,CAACC,OAAS;AAAEC,4BAAAA,OAAAA,EAASD,IAAIE;yBAAI,CAAA,CAAA;AACzEC,gBAAAA,WAAAA,EAAaC,sBAAYC,IAAI;gBAC7BC,QAAU,EAAA;AACZ,aAAA,CAAA;;AAGA,YAAA,MAAMC,wBAA2BvB,GAAAA,GAAAA,CAAIwB,SAAS,CAAC,mBAAmBC,IAAI;AACtE,YAAA,IACE,0BAA0BF,wBAC1B,IAAA,OAAOA,wBAAyBG,CAAAA,oBAAoB,KAAK,UACzD,EAAA;AACAH,gBAAAA,wBAAAA,CAAyBG,oBAAoB,CAAC;AAACC,oBAAAA;AAAc,iBAAA,CAAA;AAC/D;;AAGA,YAAA,IACE,uBAAuBJ,wBACvB,IAAA,OAAOA,wBAAyBK,CAAAA,iBAAiB,KAAK,UACtD,EAAA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AA,CAAQO,OAAO,CAACR,aAAAA,CAAAA;AACzB;AACF;;;;"}
|
package/dist/admin/index.mjs
CHANGED
package/dist/admin/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["import { PaperPlane } from '@strapi/icons';\n\nimport { ReleaseAction } from './components/ReleaseAction';\nimport { ReleaseActionModalForm } from './components/ReleaseActionModal';\nimport { addColumnToTableHook } from './components/ReleaseListCell';\nimport { Panel as ReleasesPanel } from './components/ReleasesPanel';\nimport { PERMISSIONS } from './constants';\nimport { pluginId } from './pluginId';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n\nimport type { StrapiApp } from '@strapi/admin/strapi-admin';\nimport type {\n DocumentActionComponent,\n BulkActionComponent,\n} from '@strapi/content-manager/strapi-admin';\nimport type { Plugin } from '@strapi/types';\n\n// eslint-disable-next-line import/no-default-export\nconst admin: Plugin.Config.AdminInput = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register(app: StrapiApp) {\n /**\n * Hook that adds the locale column in the Release Details table\n * @constant\n * @type {string}\n */\n app.createHook('ContentReleases/pages/ReleaseDetails/add-locale-in-releases');\n\n if (window.strapi.features.isEnabled('cms-content-releases')) {\n app.addMenuLink({\n to: `plugins/${pluginId}`,\n icon: PaperPlane,\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n Component: () => import('./pages/App').then((mod) => ({ default: mod.App })),\n permissions: PERMISSIONS.main,\n position: 2,\n });\n\n // Insert the releases container into the CM's sidebar on the Edit View\n const contentManagerPluginApis = app.getPlugin('content-manager').apis;\n if (\n 'addEditViewSidePanel' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addEditViewSidePanel === 'function'\n ) {\n contentManagerPluginApis.addEditViewSidePanel([ReleasesPanel]);\n }\n\n // Insert the \"add to release\" action into the CM's Edit View\n if (\n 'addDocumentAction' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addDocumentAction === 'function'\n ) {\n contentManagerPluginApis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'unpublish');\n actions.splice(indexOfDeleteAction, 0, ReleaseActionModalForm);\n return actions;\n });\n }\n\n app.addSettingsLink('global', {\n id: pluginId,\n to: 'releases',\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n permissions: [],\n async Component() {\n const { ProtectedReleasesSettingsPage } = await import('./pages/ReleasesSettingsPage');\n return { default: ProtectedReleasesSettingsPage };\n },\n });\n\n if (\n 'addBulkAction' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addBulkAction === 'function'\n ) {\n contentManagerPluginApis.addBulkAction((actions: BulkActionComponent[]) => {\n // We want to add this action to just before the delete action all the time\n const deleteActionIndex = actions.findIndex((action) => action.type === 'delete');\n\n actions.splice(deleteActionIndex, 0, ReleaseAction);\n return actions;\n });\n }\n\n // Hook that adds a column into the CM's LV table\n app.registerHook('Admin/CM/pages/ListView/inject-column-in-table', addColumnToTableHook);\n } else if (\n !window.strapi.features.isEnabled('cms-content-releases') &&\n window.strapi?.flags?.promoteEE\n ) {\n app.addSettingsLink('global', {\n id: pluginId,\n to: '/plugins/purchase-content-releases',\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n permissions: [],\n async Component() {\n const { PurchaseContentReleases } = await import('./pages/PurchaseContentReleases');\n return { default: PurchaseContentReleases };\n },\n licenseOnly: true,\n });\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, 'content-releases'),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default admin;\n"],"names":["admin","register","app","createHook","window","strapi","features","isEnabled","addMenuLink","to","pluginId","icon","PaperPlane","intlLabel","id","defaultMessage","Component","then","mod","default","App","permissions","PERMISSIONS","main","position","contentManagerPluginApis","getPlugin","apis","addEditViewSidePanel","ReleasesPanel","addDocumentAction","actions","indexOfDeleteAction","findIndex","action","type","splice","ReleaseActionModalForm","addSettingsLink","ProtectedReleasesSettingsPage","addBulkAction","deleteActionIndex","ReleaseAction","registerHook","addColumnToTableHook","flags","promoteEE","PurchaseContentReleases","
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["import { PaperPlane } from '@strapi/icons';\n\nimport { ReleaseAction } from './components/ReleaseAction';\nimport { ReleaseActionModalForm } from './components/ReleaseActionModal';\nimport { addColumnToTableHook } from './components/ReleaseListCell';\nimport { Panel as ReleasesPanel } from './components/ReleasesPanel';\nimport { PERMISSIONS } from './constants';\nimport { pluginId } from './pluginId';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n\nimport type { StrapiApp } from '@strapi/admin/strapi-admin';\nimport type {\n DocumentActionComponent,\n BulkActionComponent,\n} from '@strapi/content-manager/strapi-admin';\nimport type { Plugin } from '@strapi/types';\n\n// eslint-disable-next-line import/no-default-export\nconst admin: Plugin.Config.AdminInput = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register(app: StrapiApp) {\n /**\n * Hook that adds the locale column in the Release Details table\n * @constant\n * @type {string}\n */\n app.createHook('ContentReleases/pages/ReleaseDetails/add-locale-in-releases');\n\n if (window.strapi.features.isEnabled('cms-content-releases')) {\n app.addMenuLink({\n to: `plugins/${pluginId}`,\n icon: PaperPlane,\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n Component: () => import('./pages/App').then((mod) => ({ default: mod.App })),\n permissions: PERMISSIONS.main,\n position: 2,\n });\n\n // Insert the releases container into the CM's sidebar on the Edit View\n const contentManagerPluginApis = app.getPlugin('content-manager').apis;\n if (\n 'addEditViewSidePanel' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addEditViewSidePanel === 'function'\n ) {\n contentManagerPluginApis.addEditViewSidePanel([ReleasesPanel]);\n }\n\n // Insert the \"add to release\" action into the CM's Edit View\n if (\n 'addDocumentAction' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addDocumentAction === 'function'\n ) {\n contentManagerPluginApis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'unpublish');\n actions.splice(indexOfDeleteAction, 0, ReleaseActionModalForm);\n return actions;\n });\n }\n\n app.addSettingsLink('global', {\n id: pluginId,\n to: 'releases',\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n licenseOnly: true,\n permissions: [],\n async Component() {\n const { ProtectedReleasesSettingsPage } = await import('./pages/ReleasesSettingsPage');\n return { default: ProtectedReleasesSettingsPage };\n },\n });\n\n if (\n 'addBulkAction' in contentManagerPluginApis &&\n typeof contentManagerPluginApis.addBulkAction === 'function'\n ) {\n contentManagerPluginApis.addBulkAction((actions: BulkActionComponent[]) => {\n // We want to add this action to just before the delete action all the time\n const deleteActionIndex = actions.findIndex((action) => action.type === 'delete');\n\n actions.splice(deleteActionIndex, 0, ReleaseAction);\n return actions;\n });\n }\n\n // Hook that adds a column into the CM's LV table\n app.registerHook('Admin/CM/pages/ListView/inject-column-in-table', addColumnToTableHook);\n } else if (\n !window.strapi.features.isEnabled('cms-content-releases') &&\n window.strapi?.flags?.promoteEE\n ) {\n app.addSettingsLink('global', {\n id: pluginId,\n to: '/plugins/purchase-content-releases',\n intlLabel: {\n id: `${pluginId}.plugin.name`,\n defaultMessage: 'Releases',\n },\n permissions: [],\n async Component() {\n const { PurchaseContentReleases } = await import('./pages/PurchaseContentReleases');\n return { default: PurchaseContentReleases };\n },\n licenseOnly: true,\n });\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, 'content-releases'),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default admin;\n"],"names":["admin","register","app","createHook","window","strapi","features","isEnabled","addMenuLink","to","pluginId","icon","PaperPlane","intlLabel","id","defaultMessage","Component","then","mod","default","App","permissions","PERMISSIONS","main","position","contentManagerPluginApis","getPlugin","apis","addEditViewSidePanel","ReleasesPanel","addDocumentAction","actions","indexOfDeleteAction","findIndex","action","type","splice","ReleaseActionModalForm","addSettingsLink","licenseOnly","ProtectedReleasesSettingsPage","addBulkAction","deleteActionIndex","ReleaseAction","registerHook","addColumnToTableHook","flags","promoteEE","PurchaseContentReleases","registerTrads","locales","importedTrads","Promise","all","map","locale","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiBA;AACA,MAAMA,KAAkC,GAAA;;AAEtCC,IAAAA,QAAAA,CAAAA,CAASC,GAAc,EAAA;AACrB;;;;QAKAA,GAAAA,CAAIC,UAAU,CAAC,6DAAA,CAAA;AAEf,QAAA,IAAIC,OAAOC,MAAM,CAACC,QAAQ,CAACC,SAAS,CAAC,sBAAyB,CAAA,EAAA;AAC5DL,YAAAA,GAAAA,CAAIM,WAAW,CAAC;AACdC,gBAAAA,EAAAA,EAAI,CAAC,QAAQ,EAAEC,QAAAA,CAAS,CAAC;gBACzBC,IAAMC,EAAAA,UAAAA;gBACNC,SAAW,EAAA;AACTC,oBAAAA,EAAAA,EAAI,CAAC,EAAEJ,QAAS,CAAA,YAAY,CAAC;oBAC7BK,cAAgB,EAAA;AAClB,iBAAA;gBACAC,SAAW,EAAA,IAAM,OAAO,iBAAA,CAAA,CAAeC,IAAI,CAAC,CAACC,OAAS;AAAEC,4BAAAA,OAAAA,EAASD,IAAIE;yBAAI,CAAA,CAAA;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AA;AACX,YAAA,OAAO,iCAAM,CAAC,CAAC,eAAe,EAAEA,MAAO,CAAA,KAAK,CAAC,CAAA,CAC1CtC,IAAI,CAAC,CAAC,EAAEE,OAAAA,EAASqC,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,yBAAyBD,IAAM,EAAA,kBAAA,CAAA;AACrCD,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCG,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPD,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQO,OAAO,CAACR,aAAAA,CAAAA;AACzB;AACF;;;;"}
|
package/dist/server/destroy.js
CHANGED
|
@@ -6,8 +6,8 @@ const destroy = async ({ strapi })=>{
|
|
|
6
6
|
const scheduledJobs = index.getService('scheduling', {
|
|
7
7
|
strapi
|
|
8
8
|
}).getAll();
|
|
9
|
-
for (const [,
|
|
10
|
-
|
|
9
|
+
for (const [, taskName] of scheduledJobs){
|
|
10
|
+
strapi.cron.remove(taskName);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroy.js","sources":["../../server/src/destroy.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"destroy.js","sources":["../../server/src/destroy.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { Release } from '../../shared/contracts/releases';\nimport { getService } from './utils';\n\nexport const destroy = async ({ strapi }: { strapi: Core.Strapi }) => {\n const scheduledJobs: Map<Release['id'], string> = getService('scheduling', {\n strapi,\n }).getAll();\n\n for (const [, taskName] of scheduledJobs) {\n strapi.cron.remove(taskName);\n }\n};\n"],"names":["destroy","strapi","scheduledJobs","getService","getAll","taskName","cron","remove"],"mappings":";;;;AAKaA,MAAAA,OAAAA,GAAU,OAAO,EAAEC,MAAM,EAA2B,GAAA;IAC/D,MAAMC,aAAAA,GAA4CC,iBAAW,YAAc,EAAA;AACzEF,QAAAA;AACF,KAAA,CAAA,CAAGG,MAAM,EAAA;AAET,IAAA,KAAK,MAAM,GAAGC,QAAS,CAAA,IAAIH,aAAe,CAAA;QACxCD,MAAOK,CAAAA,IAAI,CAACC,MAAM,CAACF,QAAAA,CAAAA;AACrB;AACF;;;;"}
|
package/dist/server/destroy.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroy.mjs","sources":["../../server/src/destroy.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"destroy.mjs","sources":["../../server/src/destroy.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { Release } from '../../shared/contracts/releases';\nimport { getService } from './utils';\n\nexport const destroy = async ({ strapi }: { strapi: Core.Strapi }) => {\n const scheduledJobs: Map<Release['id'], string> = getService('scheduling', {\n strapi,\n }).getAll();\n\n for (const [, taskName] of scheduledJobs) {\n strapi.cron.remove(taskName);\n }\n};\n"],"names":["destroy","strapi","scheduledJobs","getService","getAll","taskName","cron","remove"],"mappings":";;AAKaA,MAAAA,OAAAA,GAAU,OAAO,EAAEC,MAAM,EAA2B,GAAA;IAC/D,MAAMC,aAAAA,GAA4CC,WAAW,YAAc,EAAA;AACzEF,QAAAA;AACF,KAAA,CAAA,CAAGG,MAAM,EAAA;AAET,IAAA,KAAK,MAAM,GAAGC,QAAS,CAAA,IAAIH,aAAe,CAAA;QACxCD,MAAOK,CAAAA,IAAI,CAACC,MAAM,CAACF,QAAAA,CAAAA;AACrB;AACF;;;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var nodeSchedule = require('node-schedule');
|
|
4
3
|
var utils = require('@strapi/utils');
|
|
5
4
|
var index = require('../utils/index.js');
|
|
6
5
|
var constants = require('../constants.js');
|
|
@@ -18,26 +17,31 @@ const createSchedulingService = ({ strapi })=>{
|
|
|
18
17
|
if (!release) {
|
|
19
18
|
throw new utils.errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
20
19
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const taskName = `publishRelease_${releaseId}`;
|
|
21
|
+
strapi.cron.add({
|
|
22
|
+
[taskName]: {
|
|
23
|
+
async task () {
|
|
24
|
+
try {
|
|
25
|
+
await index.getService('release', {
|
|
26
|
+
strapi
|
|
27
|
+
}).publish(releaseId);
|
|
28
|
+
// @TODO: Trigger webhook with success message
|
|
29
|
+
} catch (error) {
|
|
30
|
+
// @TODO: Trigger webhook with error message
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
options: scheduleDate
|
|
29
34
|
}
|
|
30
|
-
this.cancel(releaseId);
|
|
31
35
|
});
|
|
32
36
|
if (scheduledJobs.has(releaseId)) {
|
|
33
37
|
this.cancel(releaseId);
|
|
34
38
|
}
|
|
35
|
-
scheduledJobs.set(releaseId,
|
|
39
|
+
scheduledJobs.set(releaseId, taskName);
|
|
36
40
|
return scheduledJobs;
|
|
37
41
|
},
|
|
38
42
|
cancel (releaseId) {
|
|
39
43
|
if (scheduledJobs.has(releaseId)) {
|
|
40
|
-
scheduledJobs.get(releaseId)
|
|
44
|
+
strapi.cron.remove(scheduledJobs.get(releaseId));
|
|
41
45
|
scheduledJobs.delete(releaseId);
|
|
42
46
|
}
|
|
43
47
|
return scheduledJobs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduling.js","sources":["../../../server/src/services/scheduling.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"scheduling.js","sources":["../../../server/src/services/scheduling.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { errors } from '@strapi/utils';\nimport { Release } from '../../../shared/contracts/releases';\nimport { getService } from '../utils';\nimport { RELEASE_MODEL_UID } from '../constants';\n\nconst createSchedulingService = ({ strapi }: { strapi: Core.Strapi }) => {\n const scheduledJobs = new Map<Release['id'], string>();\n\n return {\n async set(releaseId: Release['id'], scheduleDate: Date) {\n const release = await strapi.db\n .query(RELEASE_MODEL_UID)\n .findOne({ where: { id: releaseId, releasedAt: null } });\n\n if (!release) {\n throw new errors.NotFoundError(`No release found for id ${releaseId}`);\n }\n\n const taskName = `publishRelease_${releaseId}`;\n\n strapi.cron.add({\n [taskName]: {\n async task() {\n try {\n await getService('release', { strapi }).publish(releaseId);\n // @TODO: Trigger webhook with success message\n } catch (error) {\n // @TODO: Trigger webhook with error message\n }\n },\n options: scheduleDate,\n },\n });\n\n if (scheduledJobs.has(releaseId)) {\n this.cancel(releaseId);\n }\n\n scheduledJobs.set(releaseId, taskName);\n\n return scheduledJobs;\n },\n\n cancel(releaseId: Release['id']) {\n if (scheduledJobs.has(releaseId)) {\n strapi.cron.remove(scheduledJobs.get(releaseId)!);\n scheduledJobs.delete(releaseId);\n }\n\n return scheduledJobs;\n },\n\n getAll() {\n return scheduledJobs;\n },\n\n /**\n * On bootstrap, we can use this function to make sure to sync the scheduled jobs from the database that are not yet released\n * This is useful in case the server was restarted and the scheduled jobs were lost\n * This also could be used to sync different Strapi instances in case of a cluster\n */\n async syncFromDatabase() {\n const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n scheduledAt: {\n $gte: new Date(),\n },\n releasedAt: null,\n },\n });\n\n for (const release of releases) {\n this.set(release.id, release.scheduledAt);\n }\n\n return scheduledJobs;\n },\n };\n};\n\nexport default createSchedulingService;\n"],"names":["createSchedulingService","strapi","scheduledJobs","Map","set","releaseId","scheduleDate","release","db","query","RELEASE_MODEL_UID","findOne","where","id","releasedAt","errors","NotFoundError","taskName","cron","add","task","getService","publish","error","options","has","cancel","remove","get","delete","getAll","syncFromDatabase","releases","findMany","scheduledAt","$gte","Date"],"mappings":";;;;;;AAOA,MAAMA,uBAA0B,GAAA,CAAC,EAAEC,M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ACS,MAAM,CAACzB,aAAAA,CAAc0B,GAAG,CAACvB,SAAAA,CAAAA,CAAAA;AACrCH,gBAAAA,aAAAA,CAAc2B,MAAM,CAACxB,SAAAA,CAAAA;AACvB;YAEA,OAAOH,aAAAA;AACT,SAAA;AAEA4B,QAAAA,MAAAA,CAAAA,GAAAA;YACE,OAAO5B,aAAAA;AACT,SAAA;AAEA;;;;AAIC,QACD,MAAM6B,gBAAAA,CAAAA,GAAAA;YACJ,MAAMC,QAAAA,GAAW,MAAM/B,MAAOO,CAAAA,EAAE,CAACC,KAAK,CAACC,2BAAmBuB,CAAAA,CAAAA,QAAQ,CAAC;gBACjErB,KAAO,EAAA;oBACLsB,WAAa,EAAA;AACXC,wBAAAA,IAAAA,EAAM,IAAIC,IAAAA;AACZ,qBAAA;oBACAtB,UAAY,EAAA;AACd;AACF,aAAA,CAAA;YAEA,KAAK,MAAMP,WAAWyB,QAAU,CAAA;AAC9B,gBAAA,IAAI,CAAC5B,GAAG,CAACG,QAAQM,EAAE,EAAEN,QAAQ2B,WAAW,CAAA;AAC1C;YAEA,OAAOhC,aAAAA;AACT;AACF,KAAA;AACF;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { scheduleJob } from 'node-schedule';
|
|
2
1
|
import { errors } from '@strapi/utils';
|
|
3
2
|
import { getService } from '../utils/index.mjs';
|
|
4
3
|
import { RELEASE_MODEL_UID } from '../constants.mjs';
|
|
@@ -16,26 +15,31 @@ const createSchedulingService = ({ strapi })=>{
|
|
|
16
15
|
if (!release) {
|
|
17
16
|
throw new errors.NotFoundError(`No release found for id ${releaseId}`);
|
|
18
17
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
const taskName = `publishRelease_${releaseId}`;
|
|
19
|
+
strapi.cron.add({
|
|
20
|
+
[taskName]: {
|
|
21
|
+
async task () {
|
|
22
|
+
try {
|
|
23
|
+
await getService('release', {
|
|
24
|
+
strapi
|
|
25
|
+
}).publish(releaseId);
|
|
26
|
+
// @TODO: Trigger webhook with success message
|
|
27
|
+
} catch (error) {
|
|
28
|
+
// @TODO: Trigger webhook with error message
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
options: scheduleDate
|
|
27
32
|
}
|
|
28
|
-
this.cancel(releaseId);
|
|
29
33
|
});
|
|
30
34
|
if (scheduledJobs.has(releaseId)) {
|
|
31
35
|
this.cancel(releaseId);
|
|
32
36
|
}
|
|
33
|
-
scheduledJobs.set(releaseId,
|
|
37
|
+
scheduledJobs.set(releaseId, taskName);
|
|
34
38
|
return scheduledJobs;
|
|
35
39
|
},
|
|
36
40
|
cancel (releaseId) {
|
|
37
41
|
if (scheduledJobs.has(releaseId)) {
|
|
38
|
-
scheduledJobs.get(releaseId)
|
|
42
|
+
strapi.cron.remove(scheduledJobs.get(releaseId));
|
|
39
43
|
scheduledJobs.delete(releaseId);
|
|
40
44
|
}
|
|
41
45
|
return scheduledJobs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduling.mjs","sources":["../../../server/src/services/scheduling.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"scheduling.mjs","sources":["../../../server/src/services/scheduling.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { errors } from '@strapi/utils';\nimport { Release } from '../../../shared/contracts/releases';\nimport { getService } from '../utils';\nimport { RELEASE_MODEL_UID } from '../constants';\n\nconst createSchedulingService = ({ strapi }: { strapi: Core.Strapi }) => {\n const scheduledJobs = new Map<Release['id'], string>();\n\n return {\n async set(releaseId: Release['id'], scheduleDate: Date) {\n const release = await strapi.db\n .query(RELEASE_MODEL_UID)\n .findOne({ where: { id: releaseId, releasedAt: null } });\n\n if (!release) {\n throw new errors.NotFoundError(`No release found for id ${releaseId}`);\n }\n\n const taskName = `publishRelease_${releaseId}`;\n\n strapi.cron.add({\n [taskName]: {\n async task() {\n try {\n await getService('release', { strapi }).publish(releaseId);\n // @TODO: Trigger webhook with success message\n } catch (error) {\n // @TODO: Trigger webhook with error message\n }\n },\n options: scheduleDate,\n },\n });\n\n if (scheduledJobs.has(releaseId)) {\n this.cancel(releaseId);\n }\n\n scheduledJobs.set(releaseId, taskName);\n\n return scheduledJobs;\n },\n\n cancel(releaseId: Release['id']) {\n if (scheduledJobs.has(releaseId)) {\n strapi.cron.remove(scheduledJobs.get(releaseId)!);\n scheduledJobs.delete(releaseId);\n }\n\n return scheduledJobs;\n },\n\n getAll() {\n return scheduledJobs;\n },\n\n /**\n * On bootstrap, we can use this function to make sure to sync the scheduled jobs from the database that are not yet released\n * This is useful in case the server was restarted and the scheduled jobs were lost\n * This also could be used to sync different Strapi instances in case of a cluster\n */\n async syncFromDatabase() {\n const releases = await strapi.db.query(RELEASE_MODEL_UID).findMany({\n where: {\n scheduledAt: {\n $gte: new Date(),\n },\n releasedAt: null,\n },\n });\n\n for (const release of releases) {\n this.set(release.id, release.scheduledAt);\n }\n\n return scheduledJobs;\n },\n };\n};\n\nexport default createSchedulingService;\n"],"names":["createSchedulingService","strapi","scheduledJobs","Map","set","releaseId","scheduleDate","release","db","query","RELEASE_MODEL_UID","findOne","where","id","releasedAt","errors","NotFoundError","taskName","cron","add","task","getService","publish","error","options","has","cancel","remove","get","delete","getAll","syncFromDatabase","releases","findMany","scheduledAt","$gte","Date"],"mappings":";;;;AAOA,MAAMA,uBAA0B,GAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;AAClE,IAAA,MAAMC,gBAAgB,IAAIC,GAAAA,EAAAA;IAE1B,OAAO;QACL,MAAMC,GAAAA,CAAAA,CAAIC,SAAwB,EAAEC,YAAkB,EAAA;YACpD,MAAMC,OAAAA,GAAU,MAAMN,MAAOO,CAAAA,EAAE,CAC5BC,KAAK,CAACC,iBACNC,CAAAA,CAAAA,OAAO,CAAC;gBAAEC,KAAO,EAAA;oBAAEC,EAAIR,EAAAA,SAAAA;oBAAWS,U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AAM/B,MAAOO,CAAAA,EAAE,CAACC,KAAK,CAACC,iBAAmBuB,CAAAA,CAAAA,QAAQ,CAAC;gBACjErB,KAAO,EAAA;oBACLsB,WAAa,EAAA;AACXC,wBAAAA,IAAAA,EAAM,IAAIC,IAAAA;AACZ,qBAAA;oBACAtB,UAAY,EAAA;AACd;AACF,aAAA,CAAA;YAEA,KAAK,MAAMP,WAAWyB,QAAU,CAAA;AAC9B,gBAAA,IAAI,CAAC5B,GAAG,CAACG,QAAQM,EAAE,EAAEN,QAAQ2B,WAAW,CAAA;AAC1C;YAEA,OAAOhC,aAAAA;AACT;AACF,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../../../server/src/destroy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../../../server/src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAK1C,eAAO,MAAM,OAAO,eAAsB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE,kBAQhE,CAAC"}
|
|
@@ -1914,10 +1914,10 @@ declare const _default: {
|
|
|
1914
1914
|
scheduling: ({ strapi }: {
|
|
1915
1915
|
strapi: import("@strapi/types/dist/core").Strapi;
|
|
1916
1916
|
}) => {
|
|
1917
|
-
set(releaseId: import("@strapi/types/dist/data").ID, scheduleDate: Date): Promise<Map<import("@strapi/types/dist/data").ID,
|
|
1918
|
-
cancel(releaseId: import("@strapi/types/dist/data").ID): Map<import("@strapi/types/dist/data").ID,
|
|
1919
|
-
getAll(): Map<import("@strapi/types/dist/data").ID,
|
|
1920
|
-
syncFromDatabase(): Promise<Map<import("@strapi/types/dist/data").ID,
|
|
1917
|
+
set(releaseId: import("@strapi/types/dist/data").ID, scheduleDate: Date): Promise<Map<import("@strapi/types/dist/data").ID, string>>;
|
|
1918
|
+
cancel(releaseId: import("@strapi/types/dist/data").ID): Map<import("@strapi/types/dist/data").ID, string>;
|
|
1919
|
+
getAll(): Map<import("@strapi/types/dist/data").ID, string>;
|
|
1920
|
+
syncFromDatabase(): Promise<Map<import("@strapi/types/dist/data").ID, string>>;
|
|
1921
1921
|
};
|
|
1922
1922
|
settings: ({ strapi }: {
|
|
1923
1923
|
strapi: import("@strapi/types/dist/core").Strapi;
|
|
@@ -1807,10 +1807,10 @@ export declare const services: {
|
|
|
1807
1807
|
scheduling: ({ strapi }: {
|
|
1808
1808
|
strapi: import("@strapi/types/dist/core").Strapi;
|
|
1809
1809
|
}) => {
|
|
1810
|
-
set(releaseId: import("@strapi/types/dist/data").ID, scheduleDate: Date): Promise<Map<import("@strapi/types/dist/data").ID,
|
|
1811
|
-
cancel(releaseId: import("@strapi/types/dist/data").ID): Map<import("@strapi/types/dist/data").ID,
|
|
1812
|
-
getAll(): Map<import("@strapi/types/dist/data").ID,
|
|
1813
|
-
syncFromDatabase(): Promise<Map<import("@strapi/types/dist/data").ID,
|
|
1810
|
+
set(releaseId: import("@strapi/types/dist/data").ID, scheduleDate: Date): Promise<Map<import("@strapi/types/dist/data").ID, string>>;
|
|
1811
|
+
cancel(releaseId: import("@strapi/types/dist/data").ID): Map<import("@strapi/types/dist/data").ID, string>;
|
|
1812
|
+
getAll(): Map<import("@strapi/types/dist/data").ID, string>;
|
|
1813
|
+
syncFromDatabase(): Promise<Map<import("@strapi/types/dist/data").ID, string>>;
|
|
1814
1814
|
};
|
|
1815
1815
|
settings: ({ strapi }: {
|
|
1816
1816
|
strapi: import("@strapi/types/dist/core").Strapi;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { Job } from 'node-schedule';
|
|
2
1
|
import type { Core } from '@strapi/types';
|
|
3
2
|
import { Release } from '../../../shared/contracts/releases';
|
|
4
3
|
declare const createSchedulingService: ({ strapi }: {
|
|
5
4
|
strapi: Core.Strapi;
|
|
6
5
|
}) => {
|
|
7
|
-
set(releaseId: Release['id'], scheduleDate: Date): Promise<Map<import("@strapi/types/dist/data").ID,
|
|
8
|
-
cancel(releaseId: Release['id']): Map<import("@strapi/types/dist/data").ID,
|
|
9
|
-
getAll(): Map<import("@strapi/types/dist/data").ID,
|
|
6
|
+
set(releaseId: Release['id'], scheduleDate: Date): Promise<Map<import("@strapi/types/dist/data").ID, string>>;
|
|
7
|
+
cancel(releaseId: Release['id']): Map<import("@strapi/types/dist/data").ID, string>;
|
|
8
|
+
getAll(): Map<import("@strapi/types/dist/data").ID, string>;
|
|
10
9
|
/**
|
|
11
10
|
* On bootstrap, we can use this function to make sure to sync the scheduled jobs from the database that are not yet released
|
|
12
11
|
* This is useful in case the server was restarted and the scheduled jobs were lost
|
|
13
12
|
* This also could be used to sync different Strapi instances in case of a cluster
|
|
14
13
|
*/
|
|
15
|
-
syncFromDatabase(): Promise<Map<import("@strapi/types/dist/data").ID,
|
|
14
|
+
syncFromDatabase(): Promise<Map<import("@strapi/types/dist/data").ID, string>>;
|
|
16
15
|
};
|
|
17
16
|
export default createSchedulingService;
|
|
18
17
|
//# sourceMappingURL=scheduling.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduling.d.ts","sourceRoot":"","sources":["../../../../server/src/services/scheduling.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"scheduling.d.ts","sourceRoot":"","sources":["../../../../server/src/services/scheduling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAI7D,QAAA,MAAM,uBAAuB,eAAgB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;mBAI3C,OAAO,CAAC,IAAI,CAAC,gBAAgB,IAAI;sBAkCpC,OAAO,CAAC,IAAI,CAAC;;IAa/B;;;;OAIG;;CAkBN,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/content-releases",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20.0",
|
|
4
4
|
"description": "Strapi plugin for organizing and releasing content",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -59,25 +59,24 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@reduxjs/toolkit": "1.9.7",
|
|
62
|
-
"@strapi/database": "5.
|
|
62
|
+
"@strapi/database": "5.20.0",
|
|
63
63
|
"@strapi/design-system": "2.0.0-rc.29",
|
|
64
64
|
"@strapi/icons": "2.0.0-rc.29",
|
|
65
|
-
"@strapi/types": "5.
|
|
66
|
-
"@strapi/utils": "5.
|
|
65
|
+
"@strapi/types": "5.20.0",
|
|
66
|
+
"@strapi/utils": "5.20.0",
|
|
67
67
|
"date-fns": "2.30.0",
|
|
68
68
|
"date-fns-tz": "2.0.1",
|
|
69
69
|
"formik": "2.4.5",
|
|
70
70
|
"lodash": "4.17.21",
|
|
71
|
-
"node-schedule": "2.1.1",
|
|
72
71
|
"qs": "6.11.1",
|
|
73
72
|
"react-intl": "6.6.2",
|
|
74
73
|
"react-redux": "8.1.3",
|
|
75
74
|
"yup": "0.32.9"
|
|
76
75
|
},
|
|
77
76
|
"devDependencies": {
|
|
78
|
-
"@strapi/admin": "5.
|
|
79
|
-
"@strapi/admin-test-utils": "5.
|
|
80
|
-
"@strapi/content-manager": "5.
|
|
77
|
+
"@strapi/admin": "5.20.0",
|
|
78
|
+
"@strapi/admin-test-utils": "5.20.0",
|
|
79
|
+
"@strapi/content-manager": "5.20.0",
|
|
81
80
|
"@testing-library/dom": "10.1.0",
|
|
82
81
|
"@testing-library/react": "15.0.7",
|
|
83
82
|
"@testing-library/user-event": "14.5.2",
|