@strapi/core 0.0.0-experimental.a407f3bc8fb79a53cf7975140864526b6ddbac4b → 0.0.0-experimental.e3e48deb89bd0a1b6cc69b698696566fa7854a95

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.
Files changed (189) hide show
  1. package/dist/Strapi.d.ts +5 -3
  2. package/dist/Strapi.d.ts.map +1 -1
  3. package/dist/Strapi.js +19 -7
  4. package/dist/Strapi.js.map +1 -1
  5. package/dist/Strapi.mjs +19 -7
  6. package/dist/Strapi.mjs.map +1 -1
  7. package/dist/configuration/index.d.ts.map +1 -1
  8. package/dist/configuration/index.js +4 -4
  9. package/dist/configuration/index.js.map +1 -1
  10. package/dist/configuration/index.mjs +1 -1
  11. package/dist/configuration/index.mjs.map +1 -1
  12. package/dist/configuration/urls.d.ts +8 -0
  13. package/dist/configuration/urls.d.ts.map +1 -0
  14. package/dist/configuration/urls.js +68 -0
  15. package/dist/configuration/urls.js.map +1 -0
  16. package/dist/configuration/urls.mjs +66 -0
  17. package/dist/configuration/urls.mjs.map +1 -0
  18. package/dist/core-api/controller/index.d.ts.map +1 -1
  19. package/dist/core-api/controller/index.js +6 -1
  20. package/dist/core-api/controller/index.js.map +1 -1
  21. package/dist/core-api/controller/index.mjs +6 -1
  22. package/dist/core-api/controller/index.mjs.map +1 -1
  23. package/dist/core-api/controller/transform.d.ts +8 -7
  24. package/dist/core-api/controller/transform.d.ts.map +1 -1
  25. package/dist/core-api/controller/transform.js +18 -9
  26. package/dist/core-api/controller/transform.js.map +1 -1
  27. package/dist/core-api/controller/transform.mjs +18 -9
  28. package/dist/core-api/controller/transform.mjs.map +1 -1
  29. package/dist/core-api/service/single-type.d.ts +1 -1
  30. package/dist/core-api/service/single-type.d.ts.map +1 -1
  31. package/dist/core-api/service/single-type.js +3 -4
  32. package/dist/core-api/service/single-type.js.map +1 -1
  33. package/dist/core-api/service/single-type.mjs +3 -4
  34. package/dist/core-api/service/single-type.mjs.map +1 -1
  35. package/dist/domain/content-type/index.d.ts.map +1 -1
  36. package/dist/domain/content-type/index.js +3 -0
  37. package/dist/domain/content-type/index.js.map +1 -1
  38. package/dist/domain/content-type/index.mjs +3 -0
  39. package/dist/domain/content-type/index.mjs.map +1 -1
  40. package/dist/domain/content-type/validator.d.ts.map +1 -1
  41. package/dist/domain/content-type/validator.js +1 -1
  42. package/dist/domain/content-type/validator.js.map +1 -1
  43. package/dist/domain/content-type/validator.mjs +2 -2
  44. package/dist/domain/content-type/validator.mjs.map +1 -1
  45. package/dist/domain/module/index.d.ts.map +1 -1
  46. package/dist/domain/module/index.js +2 -3
  47. package/dist/domain/module/index.js.map +1 -1
  48. package/dist/domain/module/index.mjs +2 -3
  49. package/dist/domain/module/index.mjs.map +1 -1
  50. package/dist/ee/index.js.map +1 -1
  51. package/dist/ee/index.mjs.map +1 -1
  52. package/dist/loaders/apis.js +1 -1
  53. package/dist/loaders/apis.js.map +1 -1
  54. package/dist/loaders/apis.mjs +2 -2
  55. package/dist/loaders/apis.mjs.map +1 -1
  56. package/dist/loaders/plugins/get-enabled-plugins.js +1 -1
  57. package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
  58. package/dist/loaders/plugins/get-enabled-plugins.mjs +2 -2
  59. package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
  60. package/dist/middlewares/security.d.ts.map +1 -1
  61. package/dist/middlewares/security.js +2 -2
  62. package/dist/middlewares/security.js.map +1 -1
  63. package/dist/middlewares/security.mjs +2 -2
  64. package/dist/middlewares/security.mjs.map +1 -1
  65. package/dist/migrations/draft-publish.d.ts +17 -0
  66. package/dist/migrations/draft-publish.d.ts.map +1 -0
  67. package/dist/migrations/draft-publish.js +59 -0
  68. package/dist/migrations/draft-publish.js.map +1 -0
  69. package/dist/migrations/draft-publish.mjs +59 -0
  70. package/dist/migrations/draft-publish.mjs.map +1 -0
  71. package/dist/registries/config.d.ts +2 -2
  72. package/dist/registries/config.d.ts.map +1 -1
  73. package/dist/registries/config.js +14 -6
  74. package/dist/registries/config.js.map +1 -1
  75. package/dist/registries/config.mjs +15 -5
  76. package/dist/registries/config.mjs.map +1 -1
  77. package/dist/services/document-service/common.d.ts +2 -2
  78. package/dist/services/document-service/common.d.ts.map +1 -1
  79. package/dist/services/document-service/common.js.map +1 -1
  80. package/dist/services/document-service/common.mjs.map +1 -1
  81. package/dist/services/document-service/draft-and-publish.d.ts +9 -23
  82. package/dist/services/document-service/draft-and-publish.d.ts.map +1 -1
  83. package/dist/services/document-service/draft-and-publish.js +37 -9
  84. package/dist/services/document-service/draft-and-publish.js.map +1 -1
  85. package/dist/services/document-service/draft-and-publish.mjs +38 -10
  86. package/dist/services/document-service/draft-and-publish.mjs.map +1 -1
  87. package/dist/services/document-service/index.js +5 -5
  88. package/dist/services/document-service/index.js.map +1 -1
  89. package/dist/services/document-service/index.mjs +1 -1
  90. package/dist/services/document-service/index.mjs.map +1 -1
  91. package/dist/services/document-service/repository.d.ts +3 -0
  92. package/dist/services/document-service/repository.d.ts.map +1 -0
  93. package/dist/services/document-service/repository.js +295 -0
  94. package/dist/services/document-service/repository.js.map +1 -0
  95. package/dist/services/document-service/repository.mjs +295 -0
  96. package/dist/services/document-service/repository.mjs.map +1 -0
  97. package/dist/services/document-service/transform/id-map.d.ts +1 -1
  98. package/dist/services/document-service/transform/id-map.d.ts.map +1 -1
  99. package/dist/services/document-service/transform/id-map.js +15 -9
  100. package/dist/services/document-service/transform/id-map.js.map +1 -1
  101. package/dist/services/document-service/transform/id-map.mjs +16 -10
  102. package/dist/services/document-service/transform/id-map.mjs.map +1 -1
  103. package/dist/services/document-service/transform/id-transform.d.ts +4 -18
  104. package/dist/services/document-service/transform/id-transform.d.ts.map +1 -1
  105. package/dist/services/document-service/transform/id-transform.js +18 -12
  106. package/dist/services/document-service/transform/id-transform.js.map +1 -1
  107. package/dist/services/document-service/transform/id-transform.mjs +18 -12
  108. package/dist/services/document-service/transform/id-transform.mjs.map +1 -1
  109. package/dist/services/document-service/transform/populate.d.ts +5 -2
  110. package/dist/services/document-service/transform/populate.d.ts.map +1 -1
  111. package/dist/services/document-service/transform/populate.js.map +1 -1
  112. package/dist/services/document-service/transform/populate.mjs.map +1 -1
  113. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts +1 -1
  114. package/dist/services/document-service/transform/relations/extract/data-ids.d.ts.map +1 -1
  115. package/dist/services/document-service/transform/relations/extract/data-ids.js +23 -12
  116. package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
  117. package/dist/services/document-service/transform/relations/extract/data-ids.mjs +23 -12
  118. package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
  119. package/dist/services/document-service/transform/relations/transform/data-ids.d.ts +1 -1
  120. package/dist/services/document-service/transform/relations/transform/data-ids.d.ts.map +1 -1
  121. package/dist/services/document-service/transform/relations/transform/data-ids.js +61 -37
  122. package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
  123. package/dist/services/document-service/transform/relations/transform/data-ids.mjs +62 -38
  124. package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
  125. package/dist/services/document-service/transform/relations/utils/dp.d.ts +10 -0
  126. package/dist/services/document-service/transform/relations/utils/dp.d.ts.map +1 -0
  127. package/dist/services/document-service/transform/relations/utils/dp.js +25 -0
  128. package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -0
  129. package/dist/services/document-service/transform/relations/utils/dp.mjs +25 -0
  130. package/dist/services/document-service/transform/relations/utils/dp.mjs.map +1 -0
  131. package/dist/services/document-service/transform/relations/utils/types.d.ts +4 -1
  132. package/dist/services/document-service/transform/relations/utils/types.d.ts.map +1 -1
  133. package/dist/services/document-service/transform/types.d.ts +1 -1
  134. package/dist/services/document-service/transform/types.d.ts.map +1 -1
  135. package/dist/services/document-service/utils/populate.d.ts +8 -1
  136. package/dist/services/document-service/utils/populate.d.ts.map +1 -1
  137. package/dist/services/document-service/utils/populate.js +5 -5
  138. package/dist/services/document-service/utils/populate.js.map +1 -1
  139. package/dist/services/document-service/utils/populate.mjs +5 -5
  140. package/dist/services/document-service/utils/populate.mjs.map +1 -1
  141. package/dist/services/entity-service/components.d.ts +1 -4
  142. package/dist/services/entity-service/components.d.ts.map +1 -1
  143. package/dist/services/entity-service/components.js +13 -99
  144. package/dist/services/entity-service/components.js.map +1 -1
  145. package/dist/services/entity-service/components.mjs +14 -100
  146. package/dist/services/entity-service/components.mjs.map +1 -1
  147. package/dist/services/entity-service/index.d.ts +1 -3
  148. package/dist/services/entity-service/index.d.ts.map +1 -1
  149. package/dist/services/entity-service/index.js +34 -199
  150. package/dist/services/entity-service/index.js.map +1 -1
  151. package/dist/services/entity-service/index.mjs +27 -192
  152. package/dist/services/entity-service/index.mjs.map +1 -1
  153. package/dist/services/entity-service/params.d.ts +4 -4
  154. package/dist/services/entity-service/params.d.ts.map +1 -1
  155. package/dist/services/entity-service/params.js +1 -1
  156. package/dist/services/entity-service/params.js.map +1 -1
  157. package/dist/services/entity-service/params.mjs +1 -1
  158. package/dist/services/entity-service/params.mjs.map +1 -1
  159. package/dist/services/entity-validator/index.js +1 -1
  160. package/dist/services/entity-validator/index.js.map +1 -1
  161. package/dist/services/entity-validator/index.mjs +1 -1
  162. package/dist/services/entity-validator/index.mjs.map +1 -1
  163. package/dist/utils/is-initialized.js +1 -1
  164. package/dist/utils/is-initialized.js.map +1 -1
  165. package/dist/utils/is-initialized.mjs +1 -1
  166. package/dist/utils/is-initialized.mjs.map +1 -1
  167. package/dist/utils/load-config-file.js +1 -1
  168. package/dist/utils/load-config-file.js.map +1 -1
  169. package/dist/utils/load-config-file.mjs +2 -2
  170. package/dist/utils/load-config-file.mjs.map +1 -1
  171. package/package.json +14 -14
  172. package/dist/services/document-service/document-engine.d.ts +0 -8
  173. package/dist/services/document-service/document-engine.d.ts.map +0 -1
  174. package/dist/services/document-service/document-engine.js +0 -241
  175. package/dist/services/document-service/document-engine.js.map +0 -1
  176. package/dist/services/document-service/document-engine.mjs +0 -242
  177. package/dist/services/document-service/document-engine.mjs.map +0 -1
  178. package/dist/services/document-service/repositories/content-type.d.ts +0 -3
  179. package/dist/services/document-service/repositories/content-type.d.ts.map +0 -1
  180. package/dist/services/document-service/repositories/content-type.js +0 -139
  181. package/dist/services/document-service/repositories/content-type.js.map +0 -1
  182. package/dist/services/document-service/repositories/content-type.mjs +0 -139
  183. package/dist/services/document-service/repositories/content-type.mjs.map +0 -1
  184. package/dist/services/utils/upload-files.d.ts +0 -8
  185. package/dist/services/utils/upload-files.d.ts.map +0 -1
  186. package/dist/services/utils/upload-files.js +0 -64
  187. package/dist/services/utils/upload-files.js.map +0 -1
  188. package/dist/services/utils/upload-files.mjs +0 -63
  189. package/dist/services/utils/upload-files.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"get-enabled-plugins.js","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { isKebabCase } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/plugin-content-manager',\n '@strapi/plugin-content-type-builder',\n '@strapi/plugin-email',\n '@strapi/plugin-upload',\n '@strapi/content-releases',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n const packageInfo = require(packagePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: packageInfo.strapi,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["get","isKebabCase","join","dirname","resolve","existsSync","statSync","strapi","getUserPluginsConfig","_","map","prop","pickBy","pipe","defaultsDeep"],"mappings":";;;;;;;;;;AA+BA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqBA,IAAAA,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAAC,eAAuB;AAC7C,MAAA,CAACC,YAAAA,YAAY,UAAU,GAAG;AAC5B,UAAM,IAAI,MAAM,gBAAgB,UAAU,8CAA8C;AAAA,EAC1F;AACF;AAEA,MAAM,wBAAwB,CAAC,gBAA6C;AACtE,MAAA,OAAO,gBAAgB,WAAW;AAC7B,WAAA,EAAE,SAAS;EACpB;AAEA,QAAM,sBAAmE;AAAA,IACvE,SAAS,YAAY;AAAA,EAAA;AAGvB,MAAI,aAAa,SAAS;AACxB,QAAI,eAAe;AAEnB,QAAI,YAAY,UAAU;AAIT,qBAAAC,KAAAA,KAAK,YAAY,SAAS,IAAI;AAAA,IAAA,OACxC;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aAAa,YAAY;AAAA,QAC3B;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAEA,QAAM,kBAA+B,CAAA;AAC/B,QAAA,oBAAoB,MAAMM,qBAAAA;AAEhCC,aAAAA,QAAE,QAAQ,mBAAmB,CAAC,aAAa,eAAe;AACxD,uBAAmB,UAAU;AAE7B,oBAAgB,UAAU,IAAI;AAAA,MAC5B,GAAG,sBAAsB,WAAW;AAAA,MACpC,MAAM,CAAC;AAAA,IAAA;AAGT,UAAM,EAAE,aAAA,IAAiB,gBAAgB,UAAU;AAGnD,QAAI,cAAc;AACV,YAAA,cAAcP,KAAAA,KAAK,cAAc,cAAc;AAC/C,YAAA,cAAc,QAAQ,WAAW;AAEnC,UAAA,eAAe,WAAW,GAAG;AAC/B,wBAAgB,UAAU,EAAE,OAAO,YAAY,UAAU,CAAA;AAAA,MAC3D;AAAA,IACF;AAAA,EAAA,CACD;AAED,QAAM,0BAA0BQ,IAAAA,IAAIC,IAAAA,KAAK,cAAc,GAAG,eAAe;AACzE,QAAM,iCAAiCC,IAAA;AAAA,IACrC,CAAC,MAAM,CAAC,wBAAwB,SAAS,EAAE,YAAY;AAAA,IACvD;AAAA,EAAA;AAGF,QAAM,iBAAiBC,IAAA;AAAA,IACrBC,IAAAA,aAAa,eAAe;AAAA,IAC5BA,IAAAA,aAAa,8BAA8B;AAAA,IAC3CF,IAAAA,OAAO,CAAC,MAAkB,EAAE,OAAO;AAAA,IACnC,eAAe;AAEV,SAAA;AACT;;"}
1
+ {"version":3,"file":"get-enabled-plugins.js","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { strings } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/plugin-content-manager',\n '@strapi/plugin-content-type-builder',\n '@strapi/plugin-email',\n '@strapi/plugin-upload',\n '@strapi/content-releases',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!strings.isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n const packageInfo = require(packagePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: packageInfo.strapi,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["get","strings","join","dirname","resolve","existsSync","statSync","strapi","getUserPluginsConfig","_","map","prop","pickBy","pipe","defaultsDeep"],"mappings":";;;;;;;;;;AA+BA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqBA,IAAAA,IAA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rBC,IAAAA,aAAa,eAAe;AAAA,IAC5BA,IAAAA,aAAa,8BAA8B;AAAA,IAC3CF,IAAAA,OAAO,CAAC,MAAkB,EAAE,OAAO;AAAA,IACnC,eAAe;AAEV,SAAA;AACT;;"}
@@ -2,7 +2,7 @@ import { join, dirname, resolve } from "path";
2
2
  import { existsSync, statSync } from "fs";
3
3
  import _ from "lodash";
4
4
  import { map, prop, pickBy, pipe, defaultsDeep, get } from "lodash/fp";
5
- import { isKebabCase } from "@strapi/utils";
5
+ import { strings } from "@strapi/utils";
6
6
  import { getUserPluginsConfig } from "./get-user-plugins-config.mjs";
7
7
  const INTERNAL_PLUGINS = [
8
8
  "@strapi/plugin-content-manager",
@@ -13,7 +13,7 @@ const INTERNAL_PLUGINS = [
13
13
  ];
14
14
  const isStrapiPlugin = (info) => get("strapi.kind", info) === "plugin";
15
15
  const validatePluginName = (pluginName) => {
16
- if (!isKebabCase(pluginName)) {
16
+ if (!strings.isKebabCase(pluginName)) {
17
17
  throw new Error(`Plugin name "${pluginName}" is not in kebab (an-example-of-kebab-case)`);
18
18
  }
19
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"get-enabled-plugins.mjs","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { isKebabCase } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/plugin-content-manager',\n '@strapi/plugin-content-type-builder',\n '@strapi/plugin-email',\n '@strapi/plugin-upload',\n '@strapi/content-releases',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n const packageInfo = require(packagePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: packageInfo.strapi,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["strapi"],"mappings":";;;;;;AA+BA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqB,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAAC,eAAuB;AAC7C,MAAA,CAAC,YAAY,UAAU,GAAG;AAC5B,UAAM,IAAI,MAAM,gBAAgB,UAAU,8CAA8C;AAAA,EAC1F;AACF;AAEA,MAAM,wBAAwB,CAAC,gBAA6C;AACtE,MAAA,OAAO,gBAAgB,WAAW;AAC7B,WAAA,EAAE,SAAS;EACpB;AAEA,QAAM,sBAAmE;AAAA,IACvE,SAAS,YAAY;AAAA,EAA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S,MAAM,SAAS,aAAa,UAAU,QAAQ;AAAA,QAClF,MAAM;AAAA,UACJ,GAAG,YAAY;AAAA,UACf,aAAa,YAAY;AAAA,QAC3B;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAEA,QAAM,kBAA+B,CAAA;AAC/B,QAAA,oBAAoB,MAAM;AAEhC,IAAE,QAAQ,mBAAmB,CAAC,aAAa,eAAe;AACxD,uBAAmB,UAAU;AAE7B,oBAAgB,UAAU,IAAI;AAAA,MAC5B,GAAG,sBAAsB,WAAW;AAAA,MACpC,MAAM,CAAC;AAAA,IAAA;AAGT,UAAM,EAAE,aAAA,IAAiB,gBAAgB,UAAU;AAGnD,QAAI,cAAc;AACV,YAAA,cAAc,KAAK,cAAc,cAAc;AAC/C,YAAA,cAAc,QAAQ,WAAW;AAEnC,UAAA,eAAe,WAAW,GAAG;AAC/B,wBAAgB,UAAU,EAAE,OAAO,YAAY,UAAU,CAAA;AAAA,MAC3D;AAAA,IACF;AAAA,EAAA,CACD;AAED,QAAM,0BAA0B,IAAI,KAAK,cAAc,GAAG,eAAe;AACzE,QAAM,iCAAiC;AAAA,IACrC,CAAC,MAAM,CAAC,wBAAwB,SAAS,EAAE,YAAY;AAAA,IACvD;AAAA,EAAA;AAGF,QAAM,iBAAiB;AAAA,IACrB,aAAa,eAAe;AAAA,IAC5B,aAAa,8BAA8B;AAAA,IAC3C,OAAO,CAAC,MAAkB,EAAE,OAAO;AAAA,IACnC,eAAe;AAEV,SAAA;AACT;"}
1
+ {"version":3,"file":"get-enabled-plugins.mjs","sources":["../../../src/loaders/plugins/get-enabled-plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { dirname, join, resolve } from 'path';\nimport { statSync, existsSync } from 'fs';\nimport _ from 'lodash';\nimport { get, pickBy, defaultsDeep, map, prop, pipe } from 'lodash/fp';\nimport { strings } from '@strapi/utils';\nimport type { Strapi } from '@strapi/types';\nimport { getUserPluginsConfig } from './get-user-plugins-config';\n\ninterface PluginMeta {\n enabled: boolean;\n pathToPlugin?: string;\n info: Record<string, unknown>;\n}\n\ntype PluginMetas = Record<string, PluginMeta>;\n\ninterface PluginInfo {\n name: string;\n kind: string;\n}\n\ninterface PluginDeclaration {\n enabled: boolean;\n resolve: string;\n isModule: boolean;\n}\n\n/**\n * otherwise known as \"core features\"\n */\nconst INTERNAL_PLUGINS = [\n '@strapi/plugin-content-manager',\n '@strapi/plugin-content-type-builder',\n '@strapi/plugin-email',\n '@strapi/plugin-upload',\n '@strapi/content-releases',\n];\n\nconst isStrapiPlugin = (info: PluginInfo) => get('strapi.kind', info) === 'plugin';\n\nconst validatePluginName = (pluginName: string) => {\n if (!strings.isKebabCase(pluginName)) {\n throw new Error(`Plugin name \"${pluginName}\" is not in kebab (an-example-of-kebab-case)`);\n }\n};\n\nconst toDetailedDeclaration = (declaration: boolean | PluginDeclaration) => {\n if (typeof declaration === 'boolean') {\n return { enabled: declaration };\n }\n\n const detailedDeclaration: { enabled: boolean; pathToPlugin?: string } = {\n enabled: declaration.enabled,\n };\n\n if (declaration?.resolve) {\n let pathToPlugin = '';\n\n if (declaration.isModule) {\n /**\n * we only want the node_module here, not the package.json\n */\n pathToPlugin = join(declaration.resolve, '..');\n } else {\n try {\n pathToPlugin = dirname(require.resolve(declaration.resolve));\n } catch (e) {\n pathToPlugin = resolve(strapi.dirs.app.root, declaration.resolve);\n\n if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {\n throw new Error(`${declaration.resolve} couldn't be resolved`);\n }\n }\n }\n\n detailedDeclaration.pathToPlugin = pathToPlugin;\n }\n\n return detailedDeclaration;\n};\n\nexport const getEnabledPlugins = async (strapi: Strapi, { client } = { client: false }) => {\n const internalPlugins: PluginMetas = {};\n\n for (const dep of INTERNAL_PLUGINS) {\n const packagePath = join(dep, 'package.json');\n const packageInfo = require(packagePath);\n\n validatePluginName(packageInfo.strapi.name);\n internalPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: packageInfo.strapi,\n };\n }\n\n const installedPlugins: PluginMetas = {};\n const dependencies = strapi.config.get('info.dependencies', {});\n\n for (const dep of Object.keys(dependencies)) {\n const packagePath = join(dep, 'package.json');\n let packageInfo;\n try {\n packageInfo = require(packagePath);\n } catch {\n continue;\n }\n\n if (isStrapiPlugin(packageInfo)) {\n validatePluginName(packageInfo.strapi.name);\n installedPlugins[packageInfo.strapi.name] = {\n ...toDetailedDeclaration({ enabled: true, resolve: packagePath, isModule: client }),\n info: {\n ...packageInfo.strapi,\n packageName: packageInfo.name,\n },\n };\n }\n }\n\n const declaredPlugins: PluginMetas = {};\n const userPluginsConfig = await getUserPluginsConfig();\n\n _.forEach(userPluginsConfig, (declaration, pluginName) => {\n validatePluginName(pluginName);\n\n declaredPlugins[pluginName] = {\n ...toDetailedDeclaration(declaration),\n info: {},\n };\n\n const { pathToPlugin } = declaredPlugins[pluginName];\n\n // for manually resolved plugins\n if (pathToPlugin) {\n const packagePath = join(pathToPlugin, 'package.json');\n const packageInfo = require(packagePath);\n\n if (isStrapiPlugin(packageInfo)) {\n declaredPlugins[pluginName].info = packageInfo.strapi || {};\n }\n }\n });\n\n const declaredPluginsResolves = map(prop('pathToPlugin'), declaredPlugins);\n const installedPluginsNotAlreadyUsed = pickBy(\n (p) => !declaredPluginsResolves.includes(p.pathToPlugin),\n installedPlugins\n );\n\n const enabledPlugins = pipe(\n defaultsDeep(declaredPlugins),\n defaultsDeep(installedPluginsNotAlreadyUsed),\n pickBy((p: PluginMeta) => p.enabled)\n )(internalPlugins);\n\n return enabledPlugins;\n};\n"],"names":["strapi"],"mappings":";;;;;;AA+BA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CAAC,SAAqB,IAAI,eAAe,IAAI,MAAM;AAE1E,MAAM,qBAAqB,CAAC,eAAuB;AACjD,MAAI,CAAC,QAAQ,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ts"],"names":[],"mappings":"AACA,OAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA0B3D,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAsDnD,CAAC"}
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/middlewares/security.ts"],"names":[],"mappings":"AACA,OAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA0B3D,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAkEnD,CAAC"}
@@ -55,12 +55,12 @@ const security = (config, { strapi }) => (ctx, next) => {
55
55
  }
56
56
  });
57
57
  }
58
- if (ctx.method === "GET" && ["/admin"].some((str) => ctx.path.startsWith(str))) {
58
+ if (process.env.NODE_ENV === "development" && ctx.method === "GET" && ["/admin"].some((str) => ctx.path.startsWith(str))) {
59
59
  helmetConfig = _.merge(helmetConfig, {
60
60
  contentSecurityPolicy: {
61
61
  directives: {
62
62
  "script-src": ["'self'", "'unsafe-inline'"],
63
- "connect-src": ["'self'", "https:", "ws:"]
63
+ "connect-src": ["'self'", "http:", "https:", "ws:"]
64
64
  }
65
65
  }
66
66
  });
@@ -1 +1 @@
1
- {"version":3,"file":"security.js","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\n upgradeInsecureRequests: null,\n },\n },\n xssFilter: false,\n hsts: {\n maxAge: 31536000,\n includeSubDomains: true,\n },\n frameguard: {\n action: 'sameorigin',\n },\n};\n\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n const directives: {\n 'script-src': string[];\n 'img-src': string[];\n 'manifest-src': string[];\n 'frame-src': string[];\n } = {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n 'manifest-src': [],\n 'frame-src': [],\n };\n\n // if apollo graphql playground is enabled, add exceptions for it\n if (strapi.plugin('graphql')?.service('utils').playground.isEnabled()) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n\n directives['script-src'].push(`https: 'unsafe-inline'`);\n directives['img-src'].push(`'apollo-server-landing-page.cdn.apollographql.com'`);\n directives['manifest-src'].push(`'self'`);\n directives['manifest-src'].push('apollo-server-landing-page.cdn.apollographql.com');\n directives['frame-src'].push(`'self'`);\n directives['frame-src'].push('sandbox.embed.apollographql.com');\n }\n\n // TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n if (ctx.method === 'GET' && ['/admin'].some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":["defaultsDeep","merge","helmet"],"mappings":";;;;;;AAOA,MAAM,WAAmB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,IACrB,aAAa;AAAA,IACb,YAAY;AAAA,MACV,eAAe,CAAC,UAAU,QAAQ;AAAA,MAClC,WAAW,CAAC,UAAU,SAAS,SAAS,iCAAiC;AAAA,MACzE,aAAa,CAAC,UAAU,SAAS,OAAO;AAAA,MACxC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EACV;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuBA,EAAAA,aAAa,UAAU,MAAM;AAElD,QAAA,eAAe,CAAC,gBAAgB;AAEtC,QAAM,aAKF;AAAA,IACF,cAAc,CAAC,UAAU,mBAAmB,kBAAkB;AAAA,IAC9D,WAAW,CAAC,UAAU,SAAS,oBAAoB,WAAW;AAAA,IAC9D,gBAAgB,CAAC;AAAA,IACjB,aAAa,CAAC;AAAA,EAAA;AAIZ,MAAA,OAAO,OAAO,SAAS,GAAG,QAAQ,OAAO,EAAE,WAAW,aAAa;AACrE,UAAM,EAAE,QAAQ,UAAA,IAAc,OAAO,OAAO,SAAS;AACxC,iBAAA,KAAK,UAAU,UAAU,CAAC;AAE5B,eAAA,YAAY,EAAE,KAAK,wBAAwB;AAC3C,eAAA,SAAS,EAAE,KAAK,oDAAoD;AACpE,eAAA,cAAc,EAAE,KAAK,QAAQ;AAC7B,eAAA,cAAc,EAAE,KAAK,kDAAkD;AACvE,eAAA,WAAW,EAAE,KAAK,QAAQ;AAC1B,eAAA,WAAW,EAAE,KAAK,iCAAiC;AAAA,EAChE;AAGA,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAChF,mBAAeC,QAAM,cAAc;AAAA,MACjC,2BAA2B;AAAA;AAAA,MAC3B,uBAAuB;AAAA,QACrB;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,MAAI,IAAI,WAAW,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAC9E,mBAAeA,QAAM,cAAc;AAAA,MACjC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,iBAAiB;AAAA,UAC1C,eAAe,CAAC,UAAU,UAAU,KAAK;AAAA,QAC3C;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAOC,gBAAO,QAAA,YAAY,EAAE,KAAK,IAAI;AACvC;;"}
1
+ {"version":3,"file":"security.js","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\n upgradeInsecureRequests: null,\n },\n },\n xssFilter: false,\n hsts: {\n maxAge: 31536000,\n includeSubDomains: true,\n },\n frameguard: {\n action: 'sameorigin',\n },\n};\n\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n const directives: {\n 'script-src': string[];\n 'img-src': string[];\n 'manifest-src': string[];\n 'frame-src': string[];\n } = {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n 'manifest-src': [],\n 'frame-src': [],\n };\n\n // if apollo graphql playground is enabled, add exceptions for it\n if (strapi.plugin('graphql')?.service('utils').playground.isEnabled()) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n\n directives['script-src'].push(`https: 'unsafe-inline'`);\n directives['img-src'].push(`'apollo-server-landing-page.cdn.apollographql.com'`);\n directives['manifest-src'].push(`'self'`);\n directives['manifest-src'].push('apollo-server-landing-page.cdn.apollographql.com');\n directives['frame-src'].push(`'self'`);\n directives['frame-src'].push('sandbox.embed.apollographql.com');\n }\n\n // TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n /**\n * These are for vite's watch mode so it can accurately\n * connect to the HMR websocket & reconnect on failure\n * or when the server restarts.\n *\n * It only applies in development, and only on GET requests\n * that are part of the admin route.\n */\n if (\n process.env.NODE_ENV === 'development' &&\n ctx.method === 'GET' &&\n ['/admin'].some((str) => ctx.path.startsWith(str))\n ) {\n helmetConfig = merge(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'http:', 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":["defaultsDeep","merge","helmet"],"mappings":";;;;;;AAOA,MAAM,WAAmB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,IACrB,aAAa;AAAA,IACb,YAAY;AAAA,MACV,eAAe,CAAC,UAAU,QAAQ;AAAA,MAClC,WAAW,CAAC,UAAU,SAAS,SAAS,iCAAiC;AAAA,MACzE,aAAa,CAAC,UAAU,SAAS,OAAO;AAAA,MACxC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EACV;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuBA,EAAAA,aAAa,UAAU,MAAM;AAElD,QAAA,eAAe,CAAC,gBAAgB;AAEtC,QAAM,aAKF;AAAA,IACF,cAAc,CAAC,UAAU,mBAAmB,kBAAkB;AAAA,IAC9D,WAAW,CAAC,UAAU,SAAS,oBAAoB,WAAW;AAAA,IAC9D,gBAAgB,CAAC;AAAA,IACjB,aAAa,CAAC;AAAA,EAAA;AAIZ,MAAA,OAAO,OAAO,SAAS,GAAG,QAAQ,OAAO,EAAE,WAAW,aAAa;AACrE,UAAM,EAAE,QAAQ,UAAA,IAAc,OAAO,OAAO,SAAS;AACxC,iBAAA,KAAK,UAAU,UAAU,CAAC;AAE5B,eAAA,YAAY,EAAE,KAAK,wBAAwB;AAC3C,eAAA,SAAS,EAAE,KAAK,oDAAoD;AACpE,eAAA,cAAc,EAAE,KAAK,QAAQ;AAC7B,eAAA,cAAc,EAAE,KAAK,kDAAkD;AACvE,eAAA,WAAW,EAAE,KAAK,QAAQ;AAC1B,eAAA,WAAW,EAAE,KAAK,iCAAiC;AAAA,EAChE;AAGA,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAChF,mBAAeC,QAAM,cAAc;AAAA,MACjC,2BAA2B;AAAA;AAAA,MAC3B,uBAAuB;AAAA,QACrB;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAUA,MACE,QAAQ,IAAI,aAAa,iBACzB,IAAI,WAAW,SACf,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GACjD;AACA,mBAAeA,QAAM,cAAc;AAAA,MACjC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,iBAAiB;AAAA,UAC1C,eAAe,CAAC,UAAU,SAAS,UAAU,KAAK;AAAA,QACpD;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAOC,gBAAO,QAAA,YAAY,EAAE,KAAK,IAAI;AACvC;;"}
@@ -51,12 +51,12 @@ const security = (config, { strapi }) => (ctx, next) => {
51
51
  }
52
52
  });
53
53
  }
54
- if (ctx.method === "GET" && ["/admin"].some((str) => ctx.path.startsWith(str))) {
54
+ if (process.env.NODE_ENV === "development" && ctx.method === "GET" && ["/admin"].some((str) => ctx.path.startsWith(str))) {
55
55
  helmetConfig = merge(helmetConfig, {
56
56
  contentSecurityPolicy: {
57
57
  directives: {
58
58
  "script-src": ["'self'", "'unsafe-inline'"],
59
- "connect-src": ["'self'", "https:", "ws:"]
59
+ "connect-src": ["'self'", "http:", "https:", "ws:"]
60
60
  }
61
61
  }
62
62
  });
@@ -1 +1 @@
1
- {"version":3,"file":"security.mjs","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\n upgradeInsecureRequests: null,\n },\n },\n xssFilter: false,\n hsts: {\n maxAge: 31536000,\n includeSubDomains: true,\n },\n frameguard: {\n action: 'sameorigin',\n },\n};\n\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n const directives: {\n 'script-src': string[];\n 'img-src': string[];\n 'manifest-src': string[];\n 'frame-src': string[];\n } = {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n 'manifest-src': [],\n 'frame-src': [],\n };\n\n // if apollo graphql playground is enabled, add exceptions for it\n if (strapi.plugin('graphql')?.service('utils').playground.isEnabled()) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n\n directives['script-src'].push(`https: 'unsafe-inline'`);\n directives['img-src'].push(`'apollo-server-landing-page.cdn.apollographql.com'`);\n directives['manifest-src'].push(`'self'`);\n directives['manifest-src'].push('apollo-server-landing-page.cdn.apollographql.com');\n directives['frame-src'].push(`'self'`);\n directives['frame-src'].push('sandbox.embed.apollographql.com');\n }\n\n // TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n if (ctx.method === 'GET' && ['/admin'].some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":[],"mappings":";;AAOA,MAAM,WAAmB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,IACrB,aAAa;AAAA,IACb,YAAY;AAAA,MACV,eAAe,CAAC,UAAU,QAAQ;AAAA,MAClC,WAAW,CAAC,UAAU,SAAS,SAAS,iCAAiC;AAAA,MACzE,aAAa,CAAC,UAAU,SAAS,OAAO;AAAA,MACxC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EACV;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuB,aAAa,UAAU,MAAM;AAElD,QAAA,eAAe,CAAC,gBAAgB;AAEtC,QAAM,aAKF;AAAA,IACF,cAAc,CAAC,UAAU,mBAAmB,kBAAkB;AAAA,IAC9D,WAAW,CAAC,UAAU,SAAS,oBAAoB,WAAW;AAAA,IAC9D,gBAAgB,CAAC;AAAA,IACjB,aAAa,CAAC;AAAA,EAAA;AAIZ,MAAA,OAAO,OAAO,SAAS,GAAG,QAAQ,OAAO,EAAE,WAAW,aAAa;AACrE,UAAM,EAAE,QAAQ,UAAA,IAAc,OAAO,OAAO,SAAS;AACxC,iBAAA,KAAK,UAAU,UAAU,CAAC;AAE5B,eAAA,YAAY,EAAE,KAAK,wBAAwB;AAC3C,eAAA,SAAS,EAAE,KAAK,oDAAoD;AACpE,eAAA,cAAc,EAAE,KAAK,QAAQ;AAC7B,eAAA,cAAc,EAAE,KAAK,kDAAkD;AACvE,eAAA,WAAW,EAAE,KAAK,QAAQ;AAC1B,eAAA,WAAW,EAAE,KAAK,iCAAiC;AAAA,EAChE;AAGA,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAChF,mBAAe,MAAM,cAAc;AAAA,MACjC,2BAA2B;AAAA;AAAA,MAC3B,uBAAuB;AAAA,QACrB;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,MAAI,IAAI,WAAW,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAC9E,mBAAe,MAAM,cAAc;AAAA,MACjC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,iBAAiB;AAAA,UAC1C,eAAe,CAAC,UAAU,UAAU,KAAK;AAAA,QAC3C;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAO,OAAO,YAAY,EAAE,KAAK,IAAI;AACvC;"}
1
+ {"version":3,"file":"security.mjs","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\n upgradeInsecureRequests: null,\n },\n },\n xssFilter: false,\n hsts: {\n maxAge: 31536000,\n includeSubDomains: true,\n },\n frameguard: {\n action: 'sameorigin',\n },\n};\n\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n const directives: {\n 'script-src': string[];\n 'img-src': string[];\n 'manifest-src': string[];\n 'frame-src': string[];\n } = {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n 'manifest-src': [],\n 'frame-src': [],\n };\n\n // if apollo graphql playground is enabled, add exceptions for it\n if (strapi.plugin('graphql')?.service('utils').playground.isEnabled()) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n\n directives['script-src'].push(`https: 'unsafe-inline'`);\n directives['img-src'].push(`'apollo-server-landing-page.cdn.apollographql.com'`);\n directives['manifest-src'].push(`'self'`);\n directives['manifest-src'].push('apollo-server-landing-page.cdn.apollographql.com');\n directives['frame-src'].push(`'self'`);\n directives['frame-src'].push('sandbox.embed.apollographql.com');\n }\n\n // TODO: we shouldn't combine playground exceptions with documentation for all routes, we should first check the path and then return exceptions specific to that\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n crossOriginEmbedderPolicy: false, // TODO: only use this for graphql playground\n contentSecurityPolicy: {\n directives,\n },\n });\n }\n\n /**\n * These are for vite's watch mode so it can accurately\n * connect to the HMR websocket & reconnect on failure\n * or when the server restarts.\n *\n * It only applies in development, and only on GET requests\n * that are part of the admin route.\n */\n if (\n process.env.NODE_ENV === 'development' &&\n ctx.method === 'GET' &&\n ['/admin'].some((str) => ctx.path.startsWith(str))\n ) {\n helmetConfig = merge(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'http:', 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":[],"mappings":";;AAOA,MAAM,WAAmB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,IACrB,aAAa;AAAA,IACb,YAAY;AAAA,MACV,eAAe,CAAC,UAAU,QAAQ;AAAA,MAClC,WAAW,CAAC,UAAU,SAAS,SAAS,iCAAiC;AAAA,MACzE,aAAa,CAAC,UAAU,SAAS,OAAO;AAAA,MACxC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EACV;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuB,aAAa,UAAU,MAAM;AAElD,QAAA,eAAe,CAAC,gBAAgB;AAEtC,QAAM,aAKF;AAAA,IACF,cAAc,CAAC,UAAU,mBAAmB,kBAAkB;AAAA,IAC9D,WAAW,CAAC,UAAU,SAAS,oBAAoB,WAAW;AAAA,IAC9D,gBAAgB,CAAC;AAAA,IACjB,aAAa,CAAC;AAAA,EAAA;AAIZ,MAAA,OAAO,OAAO,SAAS,GAAG,QAAQ,OAAO,EAAE,WAAW,aAAa;AACrE,UAAM,EAAE,QAAQ,UAAA,IAAc,OAAO,OAAO,SAAS;AACxC,iBAAA,KAAK,UAAU,UAAU,CAAC;AAE5B,eAAA,YAAY,EAAE,KAAK,wBAAwB;AAC3C,eAAA,SAAS,EAAE,KAAK,oDAAoD;AACpE,eAAA,cAAc,EAAE,KAAK,QAAQ;AAC7B,eAAA,cAAc,EAAE,KAAK,kDAAkD;AACvE,eAAA,WAAW,EAAE,KAAK,QAAQ;AAC1B,eAAA,WAAW,EAAE,KAAK,iCAAiC;AAAA,EAChE;AAGA,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAChF,mBAAe,MAAM,cAAc;AAAA,MACjC,2BAA2B;AAAA;AAAA,MAC3B,uBAAuB;AAAA,QACrB;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAUA,MACE,QAAQ,IAAI,aAAa,iBACzB,IAAI,WAAW,SACf,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GACjD;AACA,mBAAe,MAAM,cAAc;AAAA,MACjC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,iBAAiB;AAAA,UAC1C,eAAe,CAAC,UAAU,SAAS,UAAU,KAAK;AAAA,QACpD;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAO,OAAO,YAAY,EAAE,KAAK,IAAI;AACvC;"}
@@ -0,0 +1,17 @@
1
+ import { Schema } from '@strapi/types';
2
+ interface Input {
3
+ oldContentTypes: Record<string, Schema.ContentType>;
4
+ contentTypes: Record<string, Schema.ContentType>;
5
+ }
6
+ /**
7
+ * Enable draft and publish for content types.
8
+ *
9
+ * Draft and publish disabled content types will have their entries published,
10
+ * this migration clones those entries as drafts.
11
+ *
12
+ * TODO: Clone components, dynamic zones and relations
13
+ */
14
+ declare const enableDraftAndPublish: ({ oldContentTypes, contentTypes }: Input) => Promise<void>;
15
+ declare const disableDraftAndPublish: ({ oldContentTypes, contentTypes }: Input) => Promise<void>;
16
+ export { enableDraftAndPublish as enable, disableDraftAndPublish as disable };
17
+ //# sourceMappingURL=draft-publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-publish.d.ts","sourceRoot":"","sources":["../../src/migrations/draft-publish.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,UAAU,KAAK;IACb,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACpD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;CAClD;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,qBAAqB,sCAA6C,KAAK,kBAkE5E,CAAC;AAEF,QAAA,MAAM,sBAAsB,sCAA6C,KAAK,kBAqB7E,CAAC;AAEF,OAAO,EAAE,qBAAqB,IAAI,MAAM,EAAE,sBAAsB,IAAI,OAAO,EAAE,CAAC"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const strapiUtils = require("@strapi/utils");
4
+ const enableDraftAndPublish = async ({ oldContentTypes, contentTypes }) => {
5
+ if (!oldContentTypes) {
6
+ return;
7
+ }
8
+ for (const uid in contentTypes) {
9
+ if (!oldContentTypes[uid]) {
10
+ continue;
11
+ }
12
+ const oldContentType = oldContentTypes[uid];
13
+ const contentType = contentTypes[uid];
14
+ if (!strapiUtils.contentTypes.hasDraftAndPublish(oldContentType) && strapiUtils.contentTypes.hasDraftAndPublish(contentType)) {
15
+ const metadata = strapi.db.metadata.get(uid);
16
+ const attributes = Object.values(metadata.attributes).reduce((acc, attribute) => {
17
+ if (["id"].includes(attribute.columnName)) {
18
+ return acc;
19
+ }
20
+ if (strapiUtils.contentTypes.isScalarAttribute(attribute)) {
21
+ acc.push(attribute.columnName);
22
+ }
23
+ return acc;
24
+ }, []);
25
+ const qb = strapi.db?.getConnection();
26
+ await qb.into(qb.raw(`${metadata.tableName} (${attributes.join(", ")})`)).insert((subQb) => {
27
+ subQb.select(
28
+ ...attributes.map((att) => {
29
+ if (att === "published_at") {
30
+ return qb.raw("NULL as published_at");
31
+ }
32
+ if (att === "updated_at") {
33
+ return qb.raw(`? as updated_at`, [/* @__PURE__ */ new Date()]);
34
+ }
35
+ return att;
36
+ })
37
+ ).from(metadata.tableName).whereNotNull("published_at");
38
+ });
39
+ }
40
+ }
41
+ };
42
+ const disableDraftAndPublish = async ({ oldContentTypes, contentTypes }) => {
43
+ if (!oldContentTypes) {
44
+ return;
45
+ }
46
+ for (const uid in contentTypes) {
47
+ if (!oldContentTypes[uid]) {
48
+ continue;
49
+ }
50
+ const oldContentType = oldContentTypes[uid];
51
+ const contentType = contentTypes[uid];
52
+ if (strapiUtils.contentTypes.hasDraftAndPublish(oldContentType) && !strapiUtils.contentTypes.hasDraftAndPublish(contentType)) {
53
+ await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();
54
+ }
55
+ }
56
+ };
57
+ exports.disable = disableDraftAndPublish;
58
+ exports.enable = enableDraftAndPublish;
59
+ //# sourceMappingURL=draft-publish.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-publish.js","sources":["../../src/migrations/draft-publish.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils } from '@strapi/utils';\nimport { Schema } from '@strapi/types';\n\ninterface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\n/**\n * Enable draft and publish for content types.\n *\n * Draft and publish disabled content types will have their entries published,\n * this migration clones those entries as drafts.\n *\n * TODO: Clone components, dynamic zones and relations\n */\nconst enableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n // run the after content types migrations\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was enabled set publishedAt to eq createdAt\n if (\n !contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n const metadata = strapi.db.metadata.get(uid);\n\n // Extract all scalar attributes to use in the insert query\n const attributes = Object.values(metadata.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypesUtils.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n const qb = strapi.db?.getConnection();\n await qb\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(qb.raw(`${metadata.tableName} (${attributes.join(', ')})`))\n .insert((subQb: typeof qb) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...attributes.map((att) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return qb.raw('NULL as published_at');\n }\n\n if (att === 'updated_at') {\n return qb.raw(`? as updated_at`, [new Date()]);\n }\n\n return att;\n })\n )\n .from(metadata.tableName)\n .whereNotNull('published_at');\n });\n }\n }\n};\n\nconst disableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was disabled remove unpublish content before sync\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();\n }\n }\n};\n\nexport { enableDraftAndPublish as enable, disableDraftAndPublish as disable };\n"],"names":["contentTypesUtils"],"mappings":";;;AAgBA,MAAM,wBAAwB,OAAO,EAAE,iBAAiB,mBAA0B;AAChF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAIA,aAAW,OAAO,cAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IACF;AAEM,UAAA,iBAAiB,g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AAAA,aAAkB,mBAAmB,cAAc,KACnD,CAACA,yBAAkB,mBAAmB,WAAW,GACjD;AACA,YAAM,OAAO,IAAI,aAAa,GAAG,EAAE,OAAA,EAAS,MAAM,EAAE,cAAc,MAAM,EAAE,QAAQ;AAAA,IACpF;AAAA,EACF;AACF;;;"}
@@ -0,0 +1,59 @@
1
+ import { contentTypes } from "@strapi/utils";
2
+ const enableDraftAndPublish = async ({ oldContentTypes, contentTypes: contentTypes$1 }) => {
3
+ if (!oldContentTypes) {
4
+ return;
5
+ }
6
+ for (const uid in contentTypes$1) {
7
+ if (!oldContentTypes[uid]) {
8
+ continue;
9
+ }
10
+ const oldContentType = oldContentTypes[uid];
11
+ const contentType = contentTypes$1[uid];
12
+ if (!contentTypes.hasDraftAndPublish(oldContentType) && contentTypes.hasDraftAndPublish(contentType)) {
13
+ const metadata = strapi.db.metadata.get(uid);
14
+ const attributes = Object.values(metadata.attributes).reduce((acc, attribute) => {
15
+ if (["id"].includes(attribute.columnName)) {
16
+ return acc;
17
+ }
18
+ if (contentTypes.isScalarAttribute(attribute)) {
19
+ acc.push(attribute.columnName);
20
+ }
21
+ return acc;
22
+ }, []);
23
+ const qb = strapi.db?.getConnection();
24
+ await qb.into(qb.raw(`${metadata.tableName} (${attributes.join(", ")})`)).insert((subQb) => {
25
+ subQb.select(
26
+ ...attributes.map((att) => {
27
+ if (att === "published_at") {
28
+ return qb.raw("NULL as published_at");
29
+ }
30
+ if (att === "updated_at") {
31
+ return qb.raw(`? as updated_at`, [/* @__PURE__ */ new Date()]);
32
+ }
33
+ return att;
34
+ })
35
+ ).from(metadata.tableName).whereNotNull("published_at");
36
+ });
37
+ }
38
+ }
39
+ };
40
+ const disableDraftAndPublish = async ({ oldContentTypes, contentTypes: contentTypes$1 }) => {
41
+ if (!oldContentTypes) {
42
+ return;
43
+ }
44
+ for (const uid in contentTypes$1) {
45
+ if (!oldContentTypes[uid]) {
46
+ continue;
47
+ }
48
+ const oldContentType = oldContentTypes[uid];
49
+ const contentType = contentTypes$1[uid];
50
+ if (contentTypes.hasDraftAndPublish(oldContentType) && !contentTypes.hasDraftAndPublish(contentType)) {
51
+ await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();
52
+ }
53
+ }
54
+ };
55
+ export {
56
+ disableDraftAndPublish as disable,
57
+ enableDraftAndPublish as enable
58
+ };
59
+ //# sourceMappingURL=draft-publish.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-publish.mjs","sources":["../../src/migrations/draft-publish.ts"],"sourcesContent":["import { contentTypes as contentTypesUtils } from '@strapi/utils';\nimport { Schema } from '@strapi/types';\n\ninterface Input {\n oldContentTypes: Record<string, Schema.ContentType>;\n contentTypes: Record<string, Schema.ContentType>;\n}\n\n/**\n * Enable draft and publish for content types.\n *\n * Draft and publish disabled content types will have their entries published,\n * this migration clones those entries as drafts.\n *\n * TODO: Clone components, dynamic zones and relations\n */\nconst enableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n // run the after content types migrations\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was enabled set publishedAt to eq createdAt\n if (\n !contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n const metadata = strapi.db.metadata.get(uid);\n\n // Extract all scalar attributes to use in the insert query\n const attributes = Object.values(metadata.attributes).reduce((acc, attribute: any) => {\n if (['id'].includes(attribute.columnName)) {\n return acc;\n }\n\n if (contentTypesUtils.isScalarAttribute(attribute)) {\n acc.push(attribute.columnName);\n }\n\n return acc;\n }, [] as string[]);\n\n /**\n * INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n * SELECT columnName1, columnName2, columnName3, ...\n * FROM tableName\n */\n const qb = strapi.db?.getConnection();\n await qb\n // INSERT INTO tableName (columnName1, columnName2, columnName3, ...)\n .into(qb.raw(`${metadata.tableName} (${attributes.join(', ')})`))\n .insert((subQb: typeof qb) => {\n // SELECT columnName1, columnName2, columnName3, ...\n subQb\n .select(\n ...attributes.map((att) => {\n // Override 'publishedAt' and 'updatedAt' attributes\n if (att === 'published_at') {\n return qb.raw('NULL as published_at');\n }\n\n if (att === 'updated_at') {\n return qb.raw(`? as updated_at`, [new Date()]);\n }\n\n return att;\n })\n )\n .from(metadata.tableName)\n .whereNotNull('published_at');\n });\n }\n }\n};\n\nconst disableDraftAndPublish = async ({ oldContentTypes, contentTypes }: Input) => {\n if (!oldContentTypes) {\n return;\n }\n\n for (const uid in contentTypes) {\n if (!oldContentTypes[uid]) {\n continue;\n }\n\n const oldContentType = oldContentTypes[uid];\n const contentType = contentTypes[uid];\n\n // if d&p was disabled remove unpublish content before sync\n if (\n contentTypesUtils.hasDraftAndPublish(oldContentType) &&\n !contentTypesUtils.hasDraftAndPublish(contentType)\n ) {\n await strapi.db?.queryBuilder(uid).delete().where({ published_at: null }).execute();\n }\n }\n};\n\nexport { enableDraftAndPublish as enable, disableDraftAndPublish as disable };\n"],"names":["contentTypes","contentTypesUtils"],"mappings":";AAgBA,MAAM,wBAAwB,OAAO,EAAE,iBAAiBA,cAAAA,qBAA0B;AAChF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAIA,aAAW,OAAOA,gBAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IACF;AAEM,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAcA,eAAa,GAAG;AAIlC,QAAA,CAACC,aAAkB,mBAAmB,cAAc,KACpDA,aAAkB,mBAAmB,WAAW,GAChD;AACA,YAAM,WAAW,OAAO,GAAG,SAAS,IAAI,GAAG;AAGrC,YAAA,aAAa,OAAO,OAAO,SAAS,UAAU,EAAE,OAAO,CAAC,KAAK,cAAmB;AACpF,YAAI,CAAC,IAAI,EAAE,SAAS,UAAU,UAAU,GAAG;AAClC,iBAAA;AAAA,QACT;AAEI,YAAAA,aAAkB,kBAAkB,SAAS,GAAG;AAC9C,cAAA,KAAK,UAAU,UAAU;AAAA,QAC/B;AAEO,eAAA;AAAA,MACT,GAAG,CAAc,CAAA;AAOX,YAAA,KAAK,OAAO,IAAI,cAAc;AACpC,YAAM,GAEH,KAAK,GAAG,IAAI,GAAG,SAAS,SAAS,KAAK,WAAW,KAAK,IAAI,CAAC,GAAG,CAAC,EAC/D,OAAO,CAAC,UAAqB;AAGzB,cAAA;AAAA,UACC,GAAG,WAAW,IAAI,CAAC,QAAQ;AAEzB,gBAAI,QAAQ,gBAAgB;AACnB,qBAAA,GAAG,IAAI,sBAAsB;AAAA,YACtC;AAEA,gBAAI,QAAQ,cAAc;AACxB,qBAAO,GAAG,IAAI,mBAAmB,CAAK,oBAAA,KAAM,CAAA,CAAC;AAAA,YAC/C;AAEO,mBAAA;AAAA,UAAA,CACR;AAAA,QAAA,EAEF,KAAK,SAAS,SAAS,EACvB,aAAa,cAAc;AAAA,MAAA,CAC/B;AAAA,IACL;AAAA,EACF;AACF;AAEA,MAAM,yBAAyB,OAAO,EAAE,iBAAiBD,cAAAA,qBAA0B;AACjF,MAAI,CAAC,iBAAiB;AACpB;AAAA,EACF;AAEA,aAAW,OAAOA,gBAAc;AAC1B,QAAA,CAAC,gBAAgB,GAAG,GAAG;AACzB;AAAA,IACF;AAEM,UAAA,iBAAiB,gBAAgB,GAAG;AACpC,UAAA,cAAcA,eAAa,GAAG;AAIlC,QAAAC,aAAkB,mBAAmB,cAAc,KACnD,CAACA,aAAkB,mBAAmB,WAAW,GACjD;AACA,YAAM,OAAO,IAAI,aAAa,GAAG,EAAE,OAAA,EAAS,MAAM,EAAE,cAAc,MAAM,EAAE,QAAQ;AAAA,IACpF;AAAA,EACF;AACF;"}
@@ -1,4 +1,4 @@
1
- import type { ConfigProvider } from '@strapi/types';
2
- declare const _default: (initialConfig?: {}) => ConfigProvider;
1
+ import type { ConfigProvider, LoadedStrapi, Strapi } from '@strapi/types';
2
+ declare const _default: (initialConfig?: {}, strapi?: Strapi | LoadedStrapi) => ConfigProvider;
3
3
  export default _default;
4
4
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/registries/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;gDAKf,cAAc;AAAnD,wBAgBE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/registries/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;sDAK7B,MAAM,GAAG,YAAY,KAAG,cAAc;AAAnF,wBAgCE"}
@@ -1,21 +1,29 @@
1
1
  "use strict";
2
2
  const _ = require("lodash");
3
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
4
- const ___default = /* @__PURE__ */ _interopDefault(_);
5
- const config = (initialConfig = {}) => {
3
+ const config = (initialConfig = {}, strapi) => {
6
4
  const _config = { ...initialConfig };
5
+ const transformDeprecatedPaths = (path) => {
6
+ if (_.isString(path) && path.startsWith("plugin.")) {
7
+ const newPath = path.replace("plugin.", "plugin::");
8
+ (strapi?.log?.warn ?? console.warn)(
9
+ `Using dot notation for model config namespaces is deprecated, for example "plugin::myplugin" should be used instead of "plugin.myplugin". Modifying requested path ${path} to ${newPath}`
10
+ );
11
+ return newPath;
12
+ }
13
+ return path;
14
+ };
7
15
  return {
8
16
  ..._config,
9
17
  // TODO: to remove
10
18
  get(path, defaultValue) {
11
- return ___default.default.get(_config, path, defaultValue);
19
+ return _.get(_config, transformDeprecatedPaths(path), defaultValue);
12
20
  },
13
21
  set(path, val) {
14
- ___default.default.set(_config, path, val);
22
+ _.set(_config, transformDeprecatedPaths(path), val);
15
23
  return this;
16
24
  },
17
25
  has(path) {
18
- return ___default.default.has(_config, path);
26
+ return _.has(_config, path);
19
27
  }
20
28
  };
21
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../src/registries/config.ts"],"sourcesContent":["import type { ConfigProvider } from '@strapi/types';\nimport _, { PropertyName } from 'lodash';\n\ntype Config = Record<string, unknown>;\n\nexport default (initialConfig = {}): ConfigProvider => {\n const _config: Config = { ...initialConfig }; // not deep clone because it would break some config\n\n return {\n ..._config, // TODO: to remove\n get(path: PropertyName, defaultValue?: unknown) {\n return _.get(_config, path, defaultValue);\n },\n set(path: PropertyName, val: unknown) {\n _.set(_config, path, val);\n return this;\n },\n has(path: PropertyName) {\n return _.has(_config, path);\n },\n };\n};\n"],"names":["_"],"mappings":";;;;AAKA,MAAA,SAAe,CAAC,gBAAgB,CAAA,MAAuB;AAC/C,QAAA,UAAkB,EAAE,GAAG;AAEtB,SAAA;AAAA,IACL,GAAG;AAAA;AAAA,IACH,IAAI,MAAoB,cAAwB;AAC9C,aAAOA,WAAE,QAAA,IAAI,SAAS,MAAM,YAAY;AAAA,IAC1C;AAAA,IACA,IAAI,MAAoB,KAAc;AAClCA,iBAAAA,QAAA,IAAI,SAAS,MAAM,GAAG;AACjB,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAoB;AACf,aAAAA,mBAAE,IAAI,SAAS,IAAI;AAAA,IAC5B;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"config.js","sources":["../../src/registries/config.ts"],"sourcesContent":["import type { ConfigProvider, LoadedStrapi, Strapi } from '@strapi/types';\nimport { get, set, has, isString, type PropertyName } from 'lodash';\n\ntype Config = Record<string, unknown>;\n\nexport default (initialConfig = {}, strapi?: Strapi | LoadedStrapi): ConfigProvider => {\n const _config: Config = { ...initialConfig }; // not deep clone because it would break some config\n\n // Accessing model configs with dot (.) was deprecated between v4->v5, but to avoid a major breaking change\n // we will still support certain namespaces, currently only 'plugin.'\n const transformDeprecatedPaths = (path: PropertyName) => {\n if (isString(path) && path.startsWith('plugin.')) {\n const newPath = path.replace('plugin.', 'plugin::');\n\n // strapi logger may not be loaded yet, so fall back to console\n (strapi?.log?.warn ?? console.warn)(\n `Using dot notation for model config namespaces is deprecated, for example \"plugin::myplugin\" should be used instead of \"plugin.myplugin\". Modifying requested path ${path} to ${newPath}`\n );\n return newPath;\n }\n\n return path;\n };\n\n return {\n ..._config, // TODO: to remove\n get(path: PropertyName, defaultValue?: unknown) {\n return get(_config, transformDeprecatedPaths(path), defaultValue);\n },\n set(path: PropertyName, val: unknown) {\n set(_config, transformDeprecatedPaths(path), val);\n return this;\n },\n has(path: PropertyName) {\n return has(_config, path);\n },\n };\n};\n"],"names":["isString","get","set","has"],"mappings":";;AAKA,MAAA,SAAe,CAAC,gBAAgB,CAAC,GAAG,WAAmD;AAC/E,QAAA,UAAkB,EAAE,GAAG;AAIvB,QAAA,2BAA2B,CAAC,SAAuB;AACvD,QAAIA,EAAAA,SAAS,IAAI,KAAK,KAAK,WAAW,SAAS,GAAG;AAChD,YAAM,UAAU,KAAK,QAAQ,WAAW,UAAU;AAGjD,OAAA,QAAQ,KAAK,QAAQ,QAAQ;AAAA,QAC5B,sKAAsK,IAAI,OAAO,OAAO;AAAA,MAAA;AAEnL,aAAA;AAAA,IACT;AAEO,WAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,GAAG;AAAA;AAAA,IACH,IAAI,MAAoB,cAAwB;AAC9C,aAAOC,EAAAA,IAAI,SAAS,yBAAyB,IAAI,GAAG,YAAY;AAAA,IAClE;AAAA,IACA,IAAI,MAAoB,KAAc;AACpCC,QAAAA,IAAI,SAAS,yBAAyB,IAAI,GAAG,GAAG;AACzC,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAoB;AACf,aAAAC,EAAA,IAAI,SAAS,IAAI;AAAA,IAC1B;AAAA,EAAA;AAEJ;;"}
@@ -1,18 +1,28 @@
1
- import _ from "lodash";
2
- const config = (initialConfig = {}) => {
1
+ import { get, set, has, isString } from "lodash";
2
+ const config = (initialConfig = {}, strapi) => {
3
3
  const _config = { ...initialConfig };
4
+ const transformDeprecatedPaths = (path) => {
5
+ if (isString(path) && path.startsWith("plugin.")) {
6
+ const newPath = path.replace("plugin.", "plugin::");
7
+ (strapi?.log?.warn ?? console.warn)(
8
+ `Using dot notation for model config namespaces is deprecated, for example "plugin::myplugin" should be used instead of "plugin.myplugin". Modifying requested path ${path} to ${newPath}`
9
+ );
10
+ return newPath;
11
+ }
12
+ return path;
13
+ };
4
14
  return {
5
15
  ..._config,
6
16
  // TODO: to remove
7
17
  get(path, defaultValue) {
8
- return _.get(_config, path, defaultValue);
18
+ return get(_config, transformDeprecatedPaths(path), defaultValue);
9
19
  },
10
20
  set(path, val) {
11
- _.set(_config, path, val);
21
+ set(_config, transformDeprecatedPaths(path), val);
12
22
  return this;
13
23
  },
14
24
  has(path) {
15
- return _.has(_config, path);
25
+ return has(_config, path);
16
26
  }
17
27
  };
18
28
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.mjs","sources":["../../src/registries/config.ts"],"sourcesContent":["import type { ConfigProvider } from '@strapi/types';\nimport _, { PropertyName } from 'lodash';\n\ntype Config = Record<string, unknown>;\n\nexport default (initialConfig = {}): ConfigProvider => {\n const _config: Config = { ...initialConfig }; // not deep clone because it would break some config\n\n return {\n ..._config, // TODO: to remove\n get(path: PropertyName, defaultValue?: unknown) {\n return _.get(_config, path, defaultValue);\n },\n set(path: PropertyName, val: unknown) {\n _.set(_config, path, val);\n return this;\n },\n has(path: PropertyName) {\n return _.has(_config, path);\n },\n };\n};\n"],"names":[],"mappings":";AAKA,MAAA,SAAe,CAAC,gBAAgB,CAAA,MAAuB;AAC/C,QAAA,UAAkB,EAAE,GAAG;AAEtB,SAAA;AAAA,IACL,GAAG;AAAA;AAAA,IACH,IAAI,MAAoB,cAAwB;AAC9C,aAAO,EAAE,IAAI,SAAS,MAAM,YAAY;AAAA,IAC1C;AAAA,IACA,IAAI,MAAoB,KAAc;AAClC,QAAA,IAAI,SAAS,MAAM,GAAG;AACjB,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAoB;AACf,aAAA,EAAE,IAAI,SAAS,IAAI;AAAA,IAC5B;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"config.mjs","sources":["../../src/registries/config.ts"],"sourcesContent":["import type { ConfigProvider, LoadedStrapi, Strapi } from '@strapi/types';\nimport { get, set, has, isString, type PropertyName } from 'lodash';\n\ntype Config = Record<string, unknown>;\n\nexport default (initialConfig = {}, strapi?: Strapi | LoadedStrapi): ConfigProvider => {\n const _config: Config = { ...initialConfig }; // not deep clone because it would break some config\n\n // Accessing model configs with dot (.) was deprecated between v4->v5, but to avoid a major breaking change\n // we will still support certain namespaces, currently only 'plugin.'\n const transformDeprecatedPaths = (path: PropertyName) => {\n if (isString(path) && path.startsWith('plugin.')) {\n const newPath = path.replace('plugin.', 'plugin::');\n\n // strapi logger may not be loaded yet, so fall back to console\n (strapi?.log?.warn ?? console.warn)(\n `Using dot notation for model config namespaces is deprecated, for example \"plugin::myplugin\" should be used instead of \"plugin.myplugin\". Modifying requested path ${path} to ${newPath}`\n );\n return newPath;\n }\n\n return path;\n };\n\n return {\n ..._config, // TODO: to remove\n get(path: PropertyName, defaultValue?: unknown) {\n return get(_config, transformDeprecatedPaths(path), defaultValue);\n },\n set(path: PropertyName, val: unknown) {\n set(_config, transformDeprecatedPaths(path), val);\n return this;\n },\n has(path: PropertyName) {\n return has(_config, path);\n },\n };\n};\n"],"names":[],"mappings":";AAKA,MAAA,SAAe,CAAC,gBAAgB,CAAC,GAAG,WAAmD;AAC/E,QAAA,UAAkB,EAAE,GAAG;AAIvB,QAAA,2BAA2B,CAAC,SAAuB;AACvD,QAAI,SAAS,IAAI,KAAK,KAAK,WAAW,SAAS,GAAG;AAChD,YAAM,UAAU,KAAK,QAAQ,WAAW,UAAU;AAGjD,OAAA,QAAQ,KAAK,QAAQ,QAAQ;AAAA,QAC5B,sKAAsK,IAAI,OAAO,OAAO;AAAA,MAAA;AAEnL,aAAA;AAAA,IACT;AAEO,WAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,GAAG;AAAA;AAAA,IACH,IAAI,MAAoB,cAAwB;AAC9C,aAAO,IAAI,SAAS,yBAAyB,IAAI,GAAG,YAAY;AAAA,IAClE;AAAA,IACA,IAAI,MAAoB,KAAc;AACpC,UAAI,SAAS,yBAAyB,IAAI,GAAG,GAAG;AACzC,aAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAoB;AACf,aAAA,IAAI,SAAS,IAAI;AAAA,IAC1B;AAAA,EAAA;AAEJ;"}
@@ -1,4 +1,4 @@
1
- import type { Common } from '@strapi/types';
2
- export type RepositoryFactoryMethod = (uid: Common.UID.CollectionType) => any;
1
+ import type { Common, Documents } from '@strapi/types';
2
+ export type RepositoryFactoryMethod = (uid: Common.UID.CollectionType) => Documents.ServiceInstance;
3
3
  export declare const wrapInTransaction: (fn: (...args: any) => any) => (...args: any[]) => Promise<any>;
4
4
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,cAAc,KAAK,GAAG,CAAC;AAE9E,eAAO,MAAM,iBAAiB,iBAAkB,GAAG,KAAK,GAAG,eACxC,GAAG,EAAE,iBACvB,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,eAAe,CAAC;AAEpG,eAAO,MAAM,iBAAiB,iBAAkB,GAAG,KAAK,GAAG,eACxC,GAAG,EAAE,iBACvB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sources":["../../../src/services/document-service/common.ts"],"sourcesContent":["import type { Common } from '@strapi/types';\n\nexport type RepositoryFactoryMethod = (uid: Common.UID.CollectionType) => any;\n\nexport const wrapInTransaction = (fn: (...args: any) => any) => {\n return (...args: any[]) => strapi.db.transaction?.(() => fn(...args));\n};\n"],"names":[],"mappings":";;AAIa,MAAA,oBAAoB,CAAC,OAA8B;AACvD,SAAA,IAAI,SAAgB,OAAO,GAAG,cAAc,MAAM,GAAG,GAAG,IAAI,CAAC;AACtE;;"}
1
+ {"version":3,"file":"common.js","sources":["../../../src/services/document-service/common.ts"],"sourcesContent":["import type { Common, Documents } from '@strapi/types';\n\nexport type RepositoryFactoryMethod = (uid: Common.UID.CollectionType) => Documents.ServiceInstance;\n\nexport const wrapInTransaction = (fn: (...args: any) => any) => {\n return (...args: any[]) => strapi.db.transaction?.(() => fn(...args));\n};\n"],"names":[],"mappings":";;AAIa,MAAA,oBAAoB,CAAC,OAA8B;AACvD,SAAA,IAAI,SAAgB,OAAO,GAAG,cAAc,MAAM,GAAG,GAAG,IAAI,CAAC;AACtE;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"common.mjs","sources":["../../../src/services/document-service/common.ts"],"sourcesContent":["import type { Common } from '@strapi/types';\n\nexport type RepositoryFactoryMethod = (uid: Common.UID.CollectionType) => any;\n\nexport const wrapInTransaction = (fn: (...args: any) => any) => {\n return (...args: any[]) => strapi.db.transaction?.(() => fn(...args));\n};\n"],"names":[],"mappings":"AAIa,MAAA,oBAAoB,CAAC,OAA8B;AACvD,SAAA,IAAI,SAAgB,OAAO,GAAG,cAAc,MAAM,GAAG,GAAG,IAAI,CAAC;AACtE;"}
1
+ {"version":3,"file":"common.mjs","sources":["../../../src/services/document-service/common.ts"],"sourcesContent":["import type { Common, Documents } from '@strapi/types';\n\nexport type RepositoryFactoryMethod = (uid: Common.UID.CollectionType) => Documents.ServiceInstance;\n\nexport const wrapInTransaction = (fn: (...args: any) => any) => {\n return (...args: any[]) => strapi.db.transaction?.(() => fn(...args));\n};\n"],"names":[],"mappings":"AAIa,MAAA,oBAAoB,CAAC,OAA8B;AACvD,SAAA,IAAI,SAAgB,OAAO,GAAG,cAAc,MAAM,GAAG,GAAG,IAAI,CAAC;AACtE;"}
@@ -1,24 +1,10 @@
1
- import { Documents } from '@strapi/types';
2
- type ParamsTransform = (params: Documents.Params.All) => Documents.Params.All;
3
- /**
4
- * Sets status to draft only
5
- */
6
- export declare const setStatusToDraft: ParamsTransform;
7
- /**
8
- * Adds a default status of `draft` to the params
9
- */
10
- export declare const defaultToDraft: ParamsTransform;
11
- /**
12
- * In mutating actions we don't want user to set the publishedAt attribute.
13
- */
14
- export declare const filterDataPublishedAt: ParamsTransform;
15
- /**
16
- * Add status lookup query to the params
17
- */
18
- export declare const statusToLookup: ParamsTransform;
19
- /**
20
- * Translate publication status parameter into the data that will be saved
21
- */
22
- export declare const statusToData: ParamsTransform;
23
- export {};
1
+ /// <reference types="lodash" />
2
+ import { Schema, Documents } from '@strapi/types';
3
+ declare const setStatusToDraftCurry: import("lodash").CurriedFunction2<Schema.SingleType | Schema.CollectionType, Documents.Params.All, Documents.Params.All>;
4
+ declare const defaultToDraftCurry: import("lodash").CurriedFunction1<Documents.Params.All, Documents.Params.All>;
5
+ declare const defaultStatusCurry: import("lodash").CurriedFunction2<Schema.SingleType | Schema.CollectionType, Documents.Params.All, Documents.Params.All>;
6
+ declare const filterDataPublishedAtCurry: import("lodash").CurriedFunction1<Documents.Params.All, Documents.Params.All>;
7
+ declare const statusToLookupCurry: import("lodash").CurriedFunction2<Schema.SingleType | Schema.CollectionType, Documents.Params.All, Documents.Params.All>;
8
+ declare const statusToDataCurry: import("lodash").CurriedFunction2<Schema.SingleType | Schema.CollectionType, Documents.Params.All, Documents.Params.All>;
9
+ export { setStatusToDraftCurry as setStatusToDraft, defaultToDraftCurry as defaultToDraft, defaultStatusCurry as defaultStatus, filterDataPublishedAtCurry as filterDataPublishedAt, statusToLookupCurry as statusToLookup, statusToDataCurry as statusToData, };
24
10
  //# sourceMappingURL=draft-and-publish.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"draft-and-publish.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/draft-and-publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,KAAK,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAA0C,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,eAO5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,eAMnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,eAa5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,eAW1B,CAAC"}
1
+ {"version":3,"file":"draft-and-publish.d.ts","sourceRoot":"","sources":["../../../src/services/document-service/draft-and-publish.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAwGlD,QAAA,MAAM,qBAAqB,0HAA0B,CAAC;AACtD,QAAA,MAAM,mBAAmB,+EAAwB,CAAC;AAClD,QAAA,MAAM,kBAAkB,0HAAuB,CAAC;AAChD,QAAA,MAAM,0BAA0B,+EAA+B,CAAC;AAChE,QAAA,MAAM,mBAAmB,0HAAwB,CAAC;AAClD,QAAA,MAAM,iBAAiB,0HAAsB,CAAC;AAE9C,OAAO,EACL,qBAAqB,IAAI,gBAAgB,EACzC,mBAAmB,IAAI,cAAc,EACrC,kBAAkB,IAAI,aAAa,EACnC,0BAA0B,IAAI,qBAAqB,EACnD,mBAAmB,IAAI,cAAc,EACrC,iBAAiB,IAAI,YAAY,GAClC,CAAC"}