@strapi/content-manager 5.55.1 → 5.57.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.
Files changed (205) hide show
  1. package/dist/admin/components/ConfigurationForm/Form.js +3 -3
  2. package/dist/admin/components/ConfigurationForm/Form.js.map +1 -1
  3. package/dist/admin/components/ConfigurationForm/Form.mjs +2 -2
  4. package/dist/admin/components/ConfigurationForm/Form.mjs.map +1 -1
  5. package/dist/admin/components/RelativeTime.js +9 -0
  6. package/dist/admin/components/RelativeTime.js.map +1 -1
  7. package/dist/admin/components/RelativeTime.mjs +10 -1
  8. package/dist/admin/components/RelativeTime.mjs.map +1 -1
  9. package/dist/admin/features/DocumentRBAC.js +0 -3
  10. package/dist/admin/features/DocumentRBAC.js.map +1 -1
  11. package/dist/admin/features/DocumentRBAC.mjs +1 -4
  12. package/dist/admin/features/DocumentRBAC.mjs.map +1 -1
  13. package/dist/admin/history/components/VersionContent.js +3 -3
  14. package/dist/admin/history/components/VersionContent.js.map +1 -1
  15. package/dist/admin/history/components/VersionContent.mjs +2 -2
  16. package/dist/admin/history/components/VersionContent.mjs.map +1 -1
  17. package/dist/admin/history/pages/History.js +2 -1
  18. package/dist/admin/history/pages/History.js.map +1 -1
  19. package/dist/admin/history/pages/History.mjs +3 -2
  20. package/dist/admin/history/pages/History.mjs.map +1 -1
  21. package/dist/admin/pages/EditView/EditViewPage.js +2 -2
  22. package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
  23. package/dist/admin/pages/EditView/EditViewPage.mjs +2 -2
  24. package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
  25. package/dist/admin/pages/EditView/components/DocumentActions.js +170 -131
  26. package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
  27. package/dist/admin/pages/EditView/components/DocumentActions.mjs +173 -135
  28. package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
  29. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +1 -0
  30. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
  31. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +1 -0
  32. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js +3 -3
  34. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs +2 -2
  36. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
  37. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +143 -30
  38. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
  39. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +143 -32
  40. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +22 -5
  42. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  43. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +22 -5
  44. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  45. package/dist/admin/pages/EditView/utils/data.js +3 -3
  46. package/dist/admin/pages/EditView/utils/data.js.map +1 -1
  47. package/dist/admin/pages/EditView/utils/data.mjs +2 -2
  48. package/dist/admin/pages/EditView/utils/data.mjs.map +1 -1
  49. package/dist/admin/pages/ListView/ListViewPage.js +4 -3
  50. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  51. package/dist/admin/pages/ListView/ListViewPage.mjs +4 -3
  52. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  53. package/dist/admin/preview/pages/Preview.js +2 -1
  54. package/dist/admin/preview/pages/Preview.js.map +1 -1
  55. package/dist/admin/preview/pages/Preview.mjs +3 -2
  56. package/dist/admin/preview/pages/Preview.mjs.map +1 -1
  57. package/dist/admin/services/documents.js +3 -2
  58. package/dist/admin/services/documents.js.map +1 -1
  59. package/dist/admin/services/documents.mjs +2 -2
  60. package/dist/admin/services/documents.mjs.map +1 -1
  61. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +2 -1
  62. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +44 -5
  63. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +2 -2
  64. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +4 -4
  65. package/dist/admin/src/services/documents.d.ts +10 -2
  66. package/dist/admin/translations/en.json.js +2 -0
  67. package/dist/admin/translations/en.json.js.map +1 -1
  68. package/dist/admin/translations/en.json.mjs +2 -0
  69. package/dist/admin/translations/en.json.mjs.map +1 -1
  70. package/dist/admin/utils/validation.js +3 -3
  71. package/dist/admin/utils/validation.js.map +1 -1
  72. package/dist/admin/utils/validation.mjs +2 -2
  73. package/dist/admin/utils/validation.mjs.map +1 -1
  74. package/dist/server/controllers/collection-types.js +4 -4
  75. package/dist/server/controllers/collection-types.js.map +1 -1
  76. package/dist/server/controllers/collection-types.mjs +4 -4
  77. package/dist/server/controllers/collection-types.mjs.map +1 -1
  78. package/dist/server/controllers/content-types.js +5 -7
  79. package/dist/server/controllers/content-types.js.map +1 -1
  80. package/dist/server/controllers/content-types.mjs +5 -7
  81. package/dist/server/controllers/content-types.mjs.map +1 -1
  82. package/dist/server/controllers/relations.js +22 -14
  83. package/dist/server/controllers/relations.js.map +1 -1
  84. package/dist/server/controllers/relations.mjs +21 -13
  85. package/dist/server/controllers/relations.mjs.map +1 -1
  86. package/dist/server/controllers/utils/clone.js +3 -4
  87. package/dist/server/controllers/utils/clone.js.map +1 -1
  88. package/dist/server/controllers/utils/clone.mjs +4 -5
  89. package/dist/server/controllers/utils/clone.mjs.map +1 -1
  90. package/dist/server/controllers/validation/index.js +1 -1
  91. package/dist/server/controllers/validation/index.mjs +1 -1
  92. package/dist/server/history/controllers/history-version.js +3 -3
  93. package/dist/server/history/controllers/history-version.js.map +1 -1
  94. package/dist/server/history/controllers/history-version.mjs +3 -3
  95. package/dist/server/history/controllers/history-version.mjs.map +1 -1
  96. package/dist/server/history/services/history.js +4 -4
  97. package/dist/server/history/services/history.js.map +1 -1
  98. package/dist/server/history/services/history.mjs +4 -4
  99. package/dist/server/history/services/history.mjs.map +1 -1
  100. package/dist/server/history/services/lifecycles.js +8 -8
  101. package/dist/server/history/services/lifecycles.js.map +1 -1
  102. package/dist/server/history/services/lifecycles.mjs +3 -3
  103. package/dist/server/history/services/lifecycles.mjs.map +1 -1
  104. package/dist/server/history/services/utils.js +7 -10
  105. package/dist/server/history/services/utils.js.map +1 -1
  106. package/dist/server/history/services/utils.mjs +5 -8
  107. package/dist/server/history/services/utils.mjs.map +1 -1
  108. package/dist/server/mcp/permissions.js +2 -2
  109. package/dist/server/mcp/permissions.js.map +1 -1
  110. package/dist/server/mcp/permissions.mjs +2 -2
  111. package/dist/server/mcp/permissions.mjs.map +1 -1
  112. package/dist/server/mcp/register-content-manager-mcp-tools.js +7 -5
  113. package/dist/server/mcp/register-content-manager-mcp-tools.js.map +1 -1
  114. package/dist/server/mcp/register-content-manager-mcp-tools.mjs +7 -5
  115. package/dist/server/mcp/register-content-manager-mcp-tools.mjs.map +1 -1
  116. package/dist/server/preview/controllers/previewScript.js +30 -15
  117. package/dist/server/preview/controllers/validation/preview.js +3 -3
  118. package/dist/server/preview/controllers/validation/preview.js.map +1 -1
  119. package/dist/server/preview/controllers/validation/preview.mjs +3 -3
  120. package/dist/server/preview/controllers/validation/preview.mjs.map +1 -1
  121. package/dist/server/services/components.js +3 -3
  122. package/dist/server/services/components.js.map +1 -1
  123. package/dist/server/services/components.mjs +3 -3
  124. package/dist/server/services/components.mjs.map +1 -1
  125. package/dist/server/services/content-structure.js +2 -2
  126. package/dist/server/services/content-structure.js.map +1 -1
  127. package/dist/server/services/content-structure.mjs +2 -2
  128. package/dist/server/services/content-structure.mjs.map +1 -1
  129. package/dist/server/services/content-types.js +3 -3
  130. package/dist/server/services/content-types.js.map +1 -1
  131. package/dist/server/services/content-types.mjs +3 -3
  132. package/dist/server/services/content-types.mjs.map +1 -1
  133. package/dist/server/services/data-mapper.js +3 -3
  134. package/dist/server/services/data-mapper.js.map +1 -1
  135. package/dist/server/services/data-mapper.mjs +3 -3
  136. package/dist/server/services/data-mapper.mjs.map +1 -1
  137. package/dist/server/services/document-manager.js +6 -6
  138. package/dist/server/services/document-manager.js.map +1 -1
  139. package/dist/server/services/document-manager.mjs +6 -6
  140. package/dist/server/services/document-manager.mjs.map +1 -1
  141. package/dist/server/services/document-metadata.js +29 -31
  142. package/dist/server/services/document-metadata.js.map +1 -1
  143. package/dist/server/services/document-metadata.mjs +29 -31
  144. package/dist/server/services/document-metadata.mjs.map +1 -1
  145. package/dist/server/services/metrics.js +3 -3
  146. package/dist/server/services/metrics.js.map +1 -1
  147. package/dist/server/services/metrics.mjs +3 -3
  148. package/dist/server/services/metrics.mjs.map +1 -1
  149. package/dist/server/services/permission-checker.js +2 -2
  150. package/dist/server/services/permission-checker.js.map +1 -1
  151. package/dist/server/services/permission-checker.mjs +1 -1
  152. package/dist/server/services/permission-checker.mjs.map +1 -1
  153. package/dist/server/services/permission.js +2 -3
  154. package/dist/server/services/permission.js.map +1 -1
  155. package/dist/server/services/permission.mjs +2 -3
  156. package/dist/server/services/permission.mjs.map +1 -1
  157. package/dist/server/services/populate-builder.js +4 -4
  158. package/dist/server/services/populate-builder.js.map +1 -1
  159. package/dist/server/services/populate-builder.mjs +4 -4
  160. package/dist/server/services/populate-builder.mjs.map +1 -1
  161. package/dist/server/services/utils/configuration/attributes.js +1 -2
  162. package/dist/server/services/utils/configuration/attributes.js.map +1 -1
  163. package/dist/server/services/utils/configuration/attributes.mjs +2 -3
  164. package/dist/server/services/utils/configuration/attributes.mjs.map +1 -1
  165. package/dist/server/services/utils/configuration/settings.js +4 -7
  166. package/dist/server/services/utils/configuration/settings.js.map +1 -1
  167. package/dist/server/services/utils/configuration/settings.mjs +2 -5
  168. package/dist/server/services/utils/configuration/settings.mjs.map +1 -1
  169. package/dist/server/services/utils/draft.js +8 -7
  170. package/dist/server/services/utils/draft.js.map +1 -1
  171. package/dist/server/services/utils/draft.mjs +6 -5
  172. package/dist/server/services/utils/draft.mjs.map +1 -1
  173. package/dist/server/services/utils/populate.js +10 -11
  174. package/dist/server/services/utils/populate.js.map +1 -1
  175. package/dist/server/services/utils/populate.mjs +9 -10
  176. package/dist/server/services/utils/populate.mjs.map +1 -1
  177. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  178. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  179. package/dist/server/src/history/services/utils.d.ts +2 -2
  180. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  181. package/dist/server/src/index.d.ts +1 -1
  182. package/dist/server/src/index.d.ts.map +1 -1
  183. package/dist/server/src/mcp/permissions.d.ts +1 -1
  184. package/dist/server/src/mcp/permissions.d.ts.map +1 -1
  185. package/dist/server/src/mcp/register-content-manager-mcp-tools.d.ts +3 -1
  186. package/dist/server/src/mcp/register-content-manager-mcp-tools.d.ts.map +1 -1
  187. package/dist/server/src/mcp/types.d.ts +2 -2
  188. package/dist/server/src/services/content-types.d.ts.map +1 -1
  189. package/dist/server/src/services/data-mapper.d.ts +1 -1
  190. package/dist/server/src/services/data-mapper.d.ts.map +1 -1
  191. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  192. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  193. package/dist/server/src/services/index.d.ts +1 -1
  194. package/dist/server/src/services/index.d.ts.map +1 -1
  195. package/dist/server/src/services/metrics.d.ts.map +1 -1
  196. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  197. package/dist/server/src/services/permission.d.ts.map +1 -1
  198. package/dist/server/src/services/populate-builder.d.ts.map +1 -1
  199. package/dist/server/src/services/utils/configuration/index.d.ts +10 -1
  200. package/dist/server/src/services/utils/configuration/index.d.ts.map +1 -1
  201. package/dist/server/src/services/utils/configuration/settings.d.ts +10 -1
  202. package/dist/server/src/services/utils/configuration/settings.d.ts.map +1 -1
  203. package/dist/server/src/services/utils/draft.d.ts.map +1 -1
  204. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  205. package/package.json +10 -10
@@ -5,19 +5,21 @@ var index = require('../utils/index.js');
5
5
 
6
6
  /**
7
7
  * Registers derived content-type MCP tools via strapi.ai.mcp.registerTool().
8
- * Must be called from the plugin register phase, before the MCP HTTP server starts.
8
+ * Must be called from the plugin bootstrap phase: after every plugin's register (so the
9
+ * localization provider is installed and locale rows are readable) and before the MCP HTTP
10
+ * server starts.
9
11
  */ const registerContentManagerMcpTools = async ({ strapi })=>{
10
12
  // Performance only: registerTool() is safe when MCP is disabled (definitions are stored but
11
13
  // never exposed). Skip the expensive derivation below when the MCP server will not start.
12
14
  if (strapi.ai.mcp.isEnabled() !== true) {
13
15
  return;
14
16
  }
15
- const i18nPlugin = strapi.plugin('i18n');
16
17
  let localeCodes = null;
17
18
  let defaultLocale = null;
18
- if (i18nPlugin !== undefined) {
19
- localeCodes = (await i18nPlugin.service('locales').find()).map((locale)=>locale.code);
20
- defaultLocale = await i18nPlugin.service('locales').getDefaultLocale();
19
+ if (strapi.localization.isEnabled() === true) {
20
+ // The tuple type is a lie for zero locales; consumers guard on length > 0 before z.enum.
21
+ localeCodes = (await strapi.localization.getLocales()).map((locale)=>locale.code);
22
+ defaultLocale = await strapi.localization.getDefaultLocale();
21
23
  }
22
24
  const models = index.getService('content-types').findDisplayedContentTypes();
23
25
  const tools = deriveContentTypeMcpTools.deriveDisplayedContentTypeMcpToolDefinitions(strapi, models, {
@@ -1 +1 @@
1
- {"version":3,"file":"register-content-manager-mcp-tools.js","sources":["../../../server/src/mcp/register-content-manager-mcp-tools.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { deriveDisplayedContentTypeMcpToolDefinitions } from './derive-content-type-mcp-tools';\nimport { getService } from '../utils';\n\n/**\n * Registers derived content-type MCP tools via strapi.ai.mcp.registerTool().\n * Must be called from the plugin register phase, before the MCP HTTP server starts.\n */\nexport const registerContentManagerMcpTools = async ({\n strapi,\n}: {\n strapi: Core.Strapi;\n}): Promise<void> => {\n // Performance only: registerTool() is safe when MCP is disabled (definitions are stored but\n // never exposed). Skip the expensive derivation below when the MCP server will not start.\n if (strapi.ai.mcp.isEnabled() !== true) {\n return;\n }\n\n const i18nPlugin = strapi.plugin('i18n');\n\n let localeCodes = null;\n let defaultLocale: string | null = null;\n if (i18nPlugin !== undefined) {\n localeCodes = (await i18nPlugin.service('locales').find()).map(\n (locale: { code: string }) => locale.code\n ) as [string, ...string[]];\n defaultLocale = await i18nPlugin.service('locales').getDefaultLocale();\n }\n\n const models = getService('content-types').findDisplayedContentTypes();\n const tools = deriveDisplayedContentTypeMcpToolDefinitions(strapi, models, {\n localeCodes,\n defaultLocale,\n });\n\n for (const tool of tools) {\n strapi.ai.mcp.registerTool(tool);\n }\n};\n"],"names":["registerContentManagerMcpTools","strapi","ai","mcp","isEnabled","i18nPlugin","plugin","localeCodes","defaultLocale","undefined","service","find","map","locale","code","getDefaultLocale","models","getService","findDisplayedContentTypes","tools","deriveDisplayedContentTypeMcpToolDefinitions","tool","registerTool"],"mappings":";;;;;AAKA;;;AAGC,IACM,MAAMA,8BAAAA,GAAiC,OAAO,EACnDC,MAAM,EAGP,GAAA;;;AAGC,IAAA,IAAIA,OAAOC,EAAE,CAACC,GAAG,CAACC,SAAS,OAAO,IAAA,EAAM;AACtC,QAAA;AACF,IAAA;IAEA,MAAMC,UAAAA,GAAaJ,MAAAA,CAAOK,MAAM,CAAC,MAAA,CAAA;AAEjC,IAAA,IAAIC,WAAAA,GAAc,IAAA;AAClB,IAAA,IAAIC,aAAAA,GAA+B,IAAA;AACnC,IAAA,IAAIH,eAAeI,SAAAA,EAAW;AAC5BF,QAAAA,WAAAA,GAAc,CAAC,MAAMF,UAAAA,CAAWK,OAAO,CAAC,SAAA,CAAA,CAAWC,IAAI,EAAC,EAAGC,GAAG,CAC5D,CAACC,MAAAA,GAA6BA,OAAOC,IAAI,CAAA;AAE3CN,QAAAA,aAAAA,GAAgB,MAAMH,UAAAA,CAAWK,OAAO,CAAC,WAAWK,gBAAgB,EAAA;AACtE,IAAA;IAEA,MAAMC,MAAAA,GAASC,gBAAAA,CAAW,eAAA,CAAA,CAAiBC,yBAAyB,EAAA;IACpE,MAAMC,KAAAA,GAAQC,sEAAAA,CAA6CnB,MAAAA,EAAQe,MAAAA,EAAQ;AACzET,QAAAA,WAAAA;AACAC,QAAAA;AACF,KAAA,CAAA;IAEA,KAAK,MAAMa,QAAQF,KAAAA,CAAO;AACxBlB,QAAAA,MAAAA,CAAOC,EAAE,CAACC,GAAG,CAACmB,YAAY,CAACD,IAAAA,CAAAA;AAC7B,IAAA;AACF;;;;"}
1
+ {"version":3,"file":"register-content-manager-mcp-tools.js","sources":["../../../server/src/mcp/register-content-manager-mcp-tools.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { deriveDisplayedContentTypeMcpToolDefinitions } from './derive-content-type-mcp-tools';\nimport { getService } from '../utils';\n\n/**\n * Registers derived content-type MCP tools via strapi.ai.mcp.registerTool().\n * Must be called from the plugin bootstrap phase: after every plugin's register (so the\n * localization provider is installed and locale rows are readable) and before the MCP HTTP\n * server starts.\n */\nexport const registerContentManagerMcpTools = async ({\n strapi,\n}: {\n strapi: Core.Strapi;\n}): Promise<void> => {\n // Performance only: registerTool() is safe when MCP is disabled (definitions are stored but\n // never exposed). Skip the expensive derivation below when the MCP server will not start.\n if (strapi.ai.mcp.isEnabled() !== true) {\n return;\n }\n\n let localeCodes: [string, ...string[]] | null = null;\n let defaultLocale: string | null = null;\n if (strapi.localization.isEnabled() === true) {\n // The tuple type is a lie for zero locales; consumers guard on length > 0 before z.enum.\n localeCodes = (await strapi.localization.getLocales()).map((locale) => locale.code) as [\n string,\n ...string[],\n ];\n defaultLocale = await strapi.localization.getDefaultLocale();\n }\n\n const models = getService('content-types').findDisplayedContentTypes();\n const tools = deriveDisplayedContentTypeMcpToolDefinitions(strapi, models, {\n localeCodes,\n defaultLocale,\n });\n\n for (const tool of tools) {\n strapi.ai.mcp.registerTool(tool);\n }\n};\n"],"names":["registerContentManagerMcpTools","strapi","ai","mcp","isEnabled","localeCodes","defaultLocale","localization","getLocales","map","locale","code","getDefaultLocale","models","getService","findDisplayedContentTypes","tools","deriveDisplayedContentTypeMcpToolDefinitions","tool","registerTool"],"mappings":";;;;;AAKA;;;;;AAKC,IACM,MAAMA,8BAAAA,GAAiC,OAAO,EACnDC,MAAM,EAGP,GAAA;;;AAGC,IAAA,IAAIA,OAAOC,EAAE,CAACC,GAAG,CAACC,SAAS,OAAO,IAAA,EAAM;AACtC,QAAA;AACF,IAAA;AAEA,IAAA,IAAIC,WAAAA,GAA4C,IAAA;AAChD,IAAA,IAAIC,aAAAA,GAA+B,IAAA;AACnC,IAAA,IAAIL,MAAAA,CAAOM,YAAY,CAACH,SAAS,OAAO,IAAA,EAAM;;AAE5CC,QAAAA,WAAAA,GAAc,CAAC,MAAMJ,MAAAA,CAAOM,YAAY,CAACC,UAAU,EAAC,EAAGC,GAAG,CAAC,CAACC,MAAAA,GAAWA,OAAOC,IAAI,CAAA;AAIlFL,QAAAA,aAAAA,GAAgB,MAAML,MAAAA,CAAOM,YAAY,CAACK,gBAAgB,EAAA;AAC5D,IAAA;IAEA,MAAMC,MAAAA,GAASC,gBAAAA,CAAW,eAAA,CAAA,CAAiBC,yBAAyB,EAAA;IACpE,MAAMC,KAAAA,GAAQC,sEAAAA,CAA6ChB,MAAAA,EAAQY,MAAAA,EAAQ;AACzER,QAAAA,WAAAA;AACAC,QAAAA;AACF,KAAA,CAAA;IAEA,KAAK,MAAMY,QAAQF,KAAAA,CAAO;AACxBf,QAAAA,MAAAA,CAAOC,EAAE,CAACC,GAAG,CAACgB,YAAY,CAACD,IAAAA,CAAAA;AAC7B,IAAA;AACF;;;;"}
@@ -3,19 +3,21 @@ import { getService } from '../utils/index.mjs';
3
3
 
4
4
  /**
5
5
  * Registers derived content-type MCP tools via strapi.ai.mcp.registerTool().
6
- * Must be called from the plugin register phase, before the MCP HTTP server starts.
6
+ * Must be called from the plugin bootstrap phase: after every plugin's register (so the
7
+ * localization provider is installed and locale rows are readable) and before the MCP HTTP
8
+ * server starts.
7
9
  */ const registerContentManagerMcpTools = async ({ strapi })=>{
8
10
  // Performance only: registerTool() is safe when MCP is disabled (definitions are stored but
9
11
  // never exposed). Skip the expensive derivation below when the MCP server will not start.
10
12
  if (strapi.ai.mcp.isEnabled() !== true) {
11
13
  return;
12
14
  }
13
- const i18nPlugin = strapi.plugin('i18n');
14
15
  let localeCodes = null;
15
16
  let defaultLocale = null;
16
- if (i18nPlugin !== undefined) {
17
- localeCodes = (await i18nPlugin.service('locales').find()).map((locale)=>locale.code);
18
- defaultLocale = await i18nPlugin.service('locales').getDefaultLocale();
17
+ if (strapi.localization.isEnabled() === true) {
18
+ // The tuple type is a lie for zero locales; consumers guard on length > 0 before z.enum.
19
+ localeCodes = (await strapi.localization.getLocales()).map((locale)=>locale.code);
20
+ defaultLocale = await strapi.localization.getDefaultLocale();
19
21
  }
20
22
  const models = getService('content-types').findDisplayedContentTypes();
21
23
  const tools = deriveDisplayedContentTypeMcpToolDefinitions(strapi, models, {
@@ -1 +1 @@
1
- {"version":3,"file":"register-content-manager-mcp-tools.mjs","sources":["../../../server/src/mcp/register-content-manager-mcp-tools.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { deriveDisplayedContentTypeMcpToolDefinitions } from './derive-content-type-mcp-tools';\nimport { getService } from '../utils';\n\n/**\n * Registers derived content-type MCP tools via strapi.ai.mcp.registerTool().\n * Must be called from the plugin register phase, before the MCP HTTP server starts.\n */\nexport const registerContentManagerMcpTools = async ({\n strapi,\n}: {\n strapi: Core.Strapi;\n}): Promise<void> => {\n // Performance only: registerTool() is safe when MCP is disabled (definitions are stored but\n // never exposed). Skip the expensive derivation below when the MCP server will not start.\n if (strapi.ai.mcp.isEnabled() !== true) {\n return;\n }\n\n const i18nPlugin = strapi.plugin('i18n');\n\n let localeCodes = null;\n let defaultLocale: string | null = null;\n if (i18nPlugin !== undefined) {\n localeCodes = (await i18nPlugin.service('locales').find()).map(\n (locale: { code: string }) => locale.code\n ) as [string, ...string[]];\n defaultLocale = await i18nPlugin.service('locales').getDefaultLocale();\n }\n\n const models = getService('content-types').findDisplayedContentTypes();\n const tools = deriveDisplayedContentTypeMcpToolDefinitions(strapi, models, {\n localeCodes,\n defaultLocale,\n });\n\n for (const tool of tools) {\n strapi.ai.mcp.registerTool(tool);\n }\n};\n"],"names":["registerContentManagerMcpTools","strapi","ai","mcp","isEnabled","i18nPlugin","plugin","localeCodes","defaultLocale","undefined","service","find","map","locale","code","getDefaultLocale","models","getService","findDisplayedContentTypes","tools","deriveDisplayedContentTypeMcpToolDefinitions","tool","registerTool"],"mappings":";;;AAKA;;;AAGC,IACM,MAAMA,8BAAAA,GAAiC,OAAO,EACnDC,MAAM,EAGP,GAAA;;;AAGC,IAAA,IAAIA,OAAOC,EAAE,CAACC,GAAG,CAACC,SAAS,OAAO,IAAA,EAAM;AACtC,QAAA;AACF,IAAA;IAEA,MAAMC,UAAAA,GAAaJ,MAAAA,CAAOK,MAAM,CAAC,MAAA,CAAA;AAEjC,IAAA,IAAIC,WAAAA,GAAc,IAAA;AAClB,IAAA,IAAIC,aAAAA,GAA+B,IAAA;AACnC,IAAA,IAAIH,eAAeI,SAAAA,EAAW;AAC5BF,QAAAA,WAAAA,GAAc,CAAC,MAAMF,UAAAA,CAAWK,OAAO,CAAC,SAAA,CAAA,CAAWC,IAAI,EAAC,EAAGC,GAAG,CAC5D,CAACC,MAAAA,GAA6BA,OAAOC,IAAI,CAAA;AAE3CN,QAAAA,aAAAA,GAAgB,MAAMH,UAAAA,CAAWK,OAAO,CAAC,WAAWK,gBAAgB,EAAA;AACtE,IAAA;IAEA,MAAMC,MAAAA,GAASC,UAAAA,CAAW,eAAA,CAAA,CAAiBC,yBAAyB,EAAA;IACpE,MAAMC,KAAAA,GAAQC,4CAAAA,CAA6CnB,MAAAA,EAAQe,MAAAA,EAAQ;AACzET,QAAAA,WAAAA;AACAC,QAAAA;AACF,KAAA,CAAA;IAEA,KAAK,MAAMa,QAAQF,KAAAA,CAAO;AACxBlB,QAAAA,MAAAA,CAAOC,EAAE,CAACC,GAAG,CAACmB,YAAY,CAACD,IAAAA,CAAAA;AAC7B,IAAA;AACF;;;;"}
1
+ {"version":3,"file":"register-content-manager-mcp-tools.mjs","sources":["../../../server/src/mcp/register-content-manager-mcp-tools.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { deriveDisplayedContentTypeMcpToolDefinitions } from './derive-content-type-mcp-tools';\nimport { getService } from '../utils';\n\n/**\n * Registers derived content-type MCP tools via strapi.ai.mcp.registerTool().\n * Must be called from the plugin bootstrap phase: after every plugin's register (so the\n * localization provider is installed and locale rows are readable) and before the MCP HTTP\n * server starts.\n */\nexport const registerContentManagerMcpTools = async ({\n strapi,\n}: {\n strapi: Core.Strapi;\n}): Promise<void> => {\n // Performance only: registerTool() is safe when MCP is disabled (definitions are stored but\n // never exposed). Skip the expensive derivation below when the MCP server will not start.\n if (strapi.ai.mcp.isEnabled() !== true) {\n return;\n }\n\n let localeCodes: [string, ...string[]] | null = null;\n let defaultLocale: string | null = null;\n if (strapi.localization.isEnabled() === true) {\n // The tuple type is a lie for zero locales; consumers guard on length > 0 before z.enum.\n localeCodes = (await strapi.localization.getLocales()).map((locale) => locale.code) as [\n string,\n ...string[],\n ];\n defaultLocale = await strapi.localization.getDefaultLocale();\n }\n\n const models = getService('content-types').findDisplayedContentTypes();\n const tools = deriveDisplayedContentTypeMcpToolDefinitions(strapi, models, {\n localeCodes,\n defaultLocale,\n });\n\n for (const tool of tools) {\n strapi.ai.mcp.registerTool(tool);\n }\n};\n"],"names":["registerContentManagerMcpTools","strapi","ai","mcp","isEnabled","localeCodes","defaultLocale","localization","getLocales","map","locale","code","getDefaultLocale","models","getService","findDisplayedContentTypes","tools","deriveDisplayedContentTypeMcpToolDefinitions","tool","registerTool"],"mappings":";;;AAKA;;;;;AAKC,IACM,MAAMA,8BAAAA,GAAiC,OAAO,EACnDC,MAAM,EAGP,GAAA;;;AAGC,IAAA,IAAIA,OAAOC,EAAE,CAACC,GAAG,CAACC,SAAS,OAAO,IAAA,EAAM;AACtC,QAAA;AACF,IAAA;AAEA,IAAA,IAAIC,WAAAA,GAA4C,IAAA;AAChD,IAAA,IAAIC,aAAAA,GAA+B,IAAA;AACnC,IAAA,IAAIL,MAAAA,CAAOM,YAAY,CAACH,SAAS,OAAO,IAAA,EAAM;;AAE5CC,QAAAA,WAAAA,GAAc,CAAC,MAAMJ,MAAAA,CAAOM,YAAY,CAACC,UAAU,EAAC,EAAGC,GAAG,CAAC,CAACC,MAAAA,GAAWA,OAAOC,IAAI,CAAA;AAIlFL,QAAAA,aAAAA,GAAgB,MAAML,MAAAA,CAAOM,YAAY,CAACK,gBAAgB,EAAA;AAC5D,IAAA;IAEA,MAAMC,MAAAA,GAASC,UAAAA,CAAW,eAAA,CAAA,CAAiBC,yBAAyB,EAAA;IACpE,MAAMC,KAAAA,GAAQC,4CAAAA,CAA6ChB,MAAAA,EAAQY,MAAAA,EAAQ;AACzER,QAAAA,WAAAA;AACAC,QAAAA;AACF,KAAA,CAAA;IAEA,KAAK,MAAMY,QAAQF,KAAAA,CAAO;AACxBf,QAAAA,MAAAA,CAAOC,EAAE,CAACC,GAAG,CAACgB,YAAY,CAACD,IAAAA,CAAAA;AAC7B,IAAA;AACF;;;;"}
@@ -39,6 +39,7 @@
39
39
  * @property {string} [STRAPI_HIGHLIGHT_ACTIVE_COLOR] Optional override for the highlight active color, injected by the admin.
40
40
  * @property {boolean} [STRAPI_DISABLE_STEGA_DECODING] Optional flag to disable steganography decoding, injected by the admin.
41
41
  * @property {() => void} [__strapi_previewCleanup] Optional cleanup function, injected by the admin.
42
+ * @property {number} [__strapi_previewRunId] Id of the latest run of this script in the page.
42
43
  */
43
44
 
44
45
  /**
@@ -50,6 +51,11 @@ function previewScript(config) {
50
51
  /** @type {typeof window & WindowExtensions} */
51
52
  const win = window;
52
53
 
54
+ // The script can be injected more than once in the same page (e.g. React StrictMode or a
55
+ // remount posting previewReady twice). Only the latest run may set up; see Orchestration.
56
+ const runId = (win.__strapi_previewRunId ?? 0) + 1;
57
+ win.__strapi_previewRunId = runId;
58
+
53
59
  /* -----------------------------------------------------------------------------------------------
54
60
  * Params
55
61
  * ---------------------------------------------------------------------------------------------*/
@@ -514,12 +520,6 @@ function previewScript(config) {
514
520
  };
515
521
 
516
522
  const createHighlightStyles = () => {
517
- const existingStyles = document.getElementById(HIGHLIGHT_STYLES_ID);
518
- // Remove existing styles to avoid duplicates
519
- if (existingStyles) {
520
- existingStyles.remove();
521
- }
522
-
523
523
  const styleElement = document.createElement('style');
524
524
  styleElement.id = HIGHLIGHT_STYLES_ID;
525
525
  styleElement.textContent = `
@@ -548,8 +548,6 @@ function previewScript(config) {
548
548
  };
549
549
 
550
550
  const createOverlaySystem = () => {
551
- // Clean up before creating a new overlay so we can safely call previewScript multiple times
552
- win.__strapi_previewCleanup?.();
553
551
  document.getElementById(OVERLAY_ID)?.remove();
554
552
 
555
553
  const overlay = document.createElement('div');
@@ -1916,6 +1914,7 @@ function previewScript(config) {
1916
1914
  };
1917
1915
 
1918
1916
  /**
1917
+ * @param {HTMLStyleElement} styleElement
1919
1918
  * @param {HTMLElement} overlay
1920
1919
  * @param {ReturnType<typeof setupObservers>} observers
1921
1920
  * @param {ReturnType<typeof setupScrollManagement>} scrollManager
@@ -1923,6 +1922,7 @@ function previewScript(config) {
1923
1922
  * @param {HighlightManager} highlightManager
1924
1923
  */
1925
1924
  const createCleanupSystem = (
1925
+ styleElement,
1926
1926
  overlay,
1927
1927
  observers,
1928
1928
  scrollManager,
@@ -1948,11 +1948,9 @@ function previewScript(config) {
1948
1948
  element.removeEventListener(type, handler);
1949
1949
  });
1950
1950
 
1951
- // Clean up CSS styles
1952
- const existingStyles = document.getElementById(HIGHLIGHT_STYLES_ID);
1953
- if (existingStyles) {
1954
- existingStyles.remove();
1955
- }
1951
+ // Remove this run's own element, not whatever currently holds the id: a newer run may
1952
+ // already have created a stylesheet with the same id.
1953
+ styleElement.remove();
1956
1954
 
1957
1955
  overlay.remove();
1958
1956
  };
@@ -1965,12 +1963,29 @@ function previewScript(config) {
1965
1963
  setupStegaDOMObserver()
1966
1964
  .catch(() => undefined)
1967
1965
  .then((stegaObserver) => {
1968
- createHighlightStyles();
1966
+ // A newer run started while this one was loading the stega decoder: let it win, and
1967
+ // don't leave this run's observer behind.
1968
+ if (runId !== win.__strapi_previewRunId) {
1969
+ stegaObserver?.disconnect();
1970
+ return;
1971
+ }
1972
+
1973
+ // Last run wins: tear the previous run down completely before setting up.
1974
+ win.__strapi_previewCleanup?.();
1975
+
1976
+ const styleElement = createHighlightStyles();
1969
1977
  const overlay = createOverlaySystem();
1970
1978
  const highlightManager = createHighlightManager(overlay);
1971
1979
  const observers = setupObservers(highlightManager, stegaObserver);
1972
1980
  const scrollManager = setupScrollManagement(highlightManager);
1973
1981
  const eventHandlers = setupEventHandlers(highlightManager);
1974
- createCleanupSystem(overlay, observers, scrollManager, eventHandlers, highlightManager);
1982
+ createCleanupSystem(
1983
+ styleElement,
1984
+ overlay,
1985
+ observers,
1986
+ scrollManager,
1987
+ eventHandlers,
1988
+ highlightManager
1989
+ );
1975
1990
  });
1976
1991
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('lodash/fp');
3
+ var _ = require('lodash');
4
4
  var strapiUtils = require('@strapi/utils');
5
5
 
6
6
  const getPreviewUrlSchema = strapiUtils.z.object({
@@ -12,11 +12,11 @@ const getPreviewUrlSchema = strapiUtils.z.object({
12
12
  const validatePreviewUrl = async (strapi, uid, params)=>{
13
13
  // Validate the request parameters format
14
14
  strapiUtils.validateZodSchema(getPreviewUrlSchema)(params);
15
- const newParams = fp.pick([
15
+ const newParams = _.pick(params, [
16
16
  'documentId',
17
17
  'locale',
18
18
  'status'
19
- ], params);
19
+ ]);
20
20
  const model = strapi.getModel(uid);
21
21
  // If it's not a collection type or single type
22
22
  if (!model || model.modelType !== 'contentType') {
@@ -1 +1 @@
1
- {"version":3,"file":"preview.js","sources":["../../../../../server/src/preview/controllers/validation/preview.ts"],"sourcesContent":["import { pick } from 'lodash/fp';\n\nimport type { Core, UID } from '@strapi/types';\nimport { z, validateZodSchema, errors } from '@strapi/utils';\n\nimport { Preview } from '../../../../../shared/contracts';\nimport type { HandlerParams } from '../../services/preview-config';\n\nconst getPreviewUrlSchema = z.object({\n // Will be undefined for single types\n documentId: z.string().optional(),\n locale: z.string().nullable().optional(),\n status: z.string().optional(),\n});\n\nexport const validatePreviewUrl = async (\n strapi: Core.Strapi,\n uid: UID.ContentType,\n params: Preview.GetPreviewUrl.Request['query']\n): Promise<HandlerParams> => {\n // Validate the request parameters format\n validateZodSchema(getPreviewUrlSchema)(params);\n\n const newParams = pick(['documentId', 'locale', 'status'], params) as HandlerParams;\n const model = strapi.getModel(uid);\n\n // If it's not a collection type or single type\n if (!model || model.modelType !== 'contentType') {\n throw new errors.ValidationError('Invalid content type');\n }\n\n // Document id is not required for single types\n const isSingleType = model?.kind === 'singleType';\n if (!isSingleType && !params.documentId) {\n throw new errors.ValidationError('documentId is required for Collection Types');\n }\n\n // Fill the documentId if it's a single type\n if (isSingleType) {\n const doc = await strapi.documents(uid).findFirst();\n\n if (!doc) {\n throw new errors.NotFoundError('Document not found');\n }\n\n newParams.documentId = doc?.documentId;\n }\n\n /**\n * If status is not specified, follow the following rules:\n * - D&P disabled: status is considered published\n * - D&P enabled: status is considered draft\n */\n if (!newParams.status) {\n const isDPEnabled = model?.options?.draftAndPublish;\n newParams.status = isDPEnabled ? 'draft' : 'published';\n }\n\n return newParams;\n};\n"],"names":["getPreviewUrlSchema","z","object","documentId","string","optional","locale","nullable","status","validatePreviewUrl","strapi","uid","params","validateZodSchema","newParams","pick","model","getModel","modelType","errors","ValidationError","isSingleType","kind","doc","documents","findFirst","NotFoundError","isDPEnabled","options","draftAndPublish"],"mappings":";;;;;AAQA,MAAMA,mBAAAA,GAAsBC,aAAAA,CAAEC,MAAM,CAAC;;IAEnCC,UAAAA,EAAYF,aAAAA,CAAEG,MAAM,EAAA,CAAGC,QAAQ,EAAA;AAC/BC,IAAAA,MAAAA,EAAQL,aAAAA,CAAEG,MAAM,EAAA,CAAGG,QAAQ,GAAGF,QAAQ,EAAA;IACtCG,MAAAA,EAAQP,aAAAA,CAAEG,MAAM,EAAA,CAAGC,QAAQ;AAC7B,CAAA,CAAA;AAEO,MAAMI,kBAAAA,GAAqB,OAChCC,MAAAA,EACAC,GAAAA,EACAC,MAAAA,GAAAA;;AAGAC,IAAAA,6BAAAA,CAAkBb,mBAAAA,CAAAA,CAAqBY,MAAAA,CAAAA;AAEvC,IAAA,MAAME,YAAYC,OAAAA,CAAK;AAAC,QAAA,YAAA;AAAc,QAAA,QAAA;AAAU,QAAA;KAAS,EAAEH,MAAAA,CAAAA;IAC3D,MAAMI,KAAAA,GAAQN,MAAAA,CAAOO,QAAQ,CAACN,GAAAA,CAAAA;;AAG9B,IAAA,IAAI,CAACK,KAAAA,IAASA,KAAAA,CAAME,SAAS,KAAK,aAAA,EAAe;QAC/C,MAAM,IAAIC,kBAAAA,CAAOC,eAAe,CAAC,sBAAA,CAAA;AACnC,IAAA;;IAGA,MAAMC,YAAAA,GAAeL,OAAOM,IAAAA,KAAS,YAAA;AACrC,IAAA,IAAI,CAACD,YAAAA,IAAgB,CAACT,MAAAA,CAAOT,UAAU,EAAE;QACvC,MAAM,IAAIgB,kBAAAA,CAAOC,eAAe,CAAC,6CAAA,CAAA;AACnC,IAAA;;AAGA,IAAA,IAAIC,YAAAA,EAAc;AAChB,QAAA,MAAME,MAAM,MAAMb,MAAAA,CAAOc,SAAS,CAACb,KAAKc,SAAS,EAAA;AAEjD,QAAA,IAAI,CAACF,GAAAA,EAAK;YACR,MAAM,IAAIJ,kBAAAA,CAAOO,aAAa,CAAC,oBAAA,CAAA;AACjC,QAAA;QAEAZ,SAAAA,CAAUX,UAAU,GAAGoB,GAAAA,EAAKpB,UAAAA;AAC9B,IAAA;AAEA;;;;AAIC,MACD,IAAI,CAACW,SAAAA,CAAUN,MAAM,EAAE;QACrB,MAAMmB,WAAAA,GAAcX,OAAOY,OAAAA,EAASC,eAAAA;QACpCf,SAAAA,CAAUN,MAAM,GAAGmB,WAAAA,GAAc,OAAA,GAAU,WAAA;AAC7C,IAAA;IAEA,OAAOb,SAAAA;AACT;;;;"}
1
+ {"version":3,"file":"preview.js","sources":["../../../../../server/src/preview/controllers/validation/preview.ts"],"sourcesContent":["import { pick } from 'lodash';\n\nimport type { Core, UID } from '@strapi/types';\nimport { z, validateZodSchema, errors } from '@strapi/utils';\n\nimport { Preview } from '../../../../../shared/contracts';\nimport type { HandlerParams } from '../../services/preview-config';\n\nconst getPreviewUrlSchema = z.object({\n // Will be undefined for single types\n documentId: z.string().optional(),\n locale: z.string().nullable().optional(),\n status: z.string().optional(),\n});\n\nexport const validatePreviewUrl = async (\n strapi: Core.Strapi,\n uid: UID.ContentType,\n params: Preview.GetPreviewUrl.Request['query']\n): Promise<HandlerParams> => {\n // Validate the request parameters format\n validateZodSchema(getPreviewUrlSchema)(params);\n\n const newParams = pick(params, ['documentId', 'locale', 'status']) as HandlerParams;\n const model = strapi.getModel(uid);\n\n // If it's not a collection type or single type\n if (!model || model.modelType !== 'contentType') {\n throw new errors.ValidationError('Invalid content type');\n }\n\n // Document id is not required for single types\n const isSingleType = model?.kind === 'singleType';\n if (!isSingleType && !params.documentId) {\n throw new errors.ValidationError('documentId is required for Collection Types');\n }\n\n // Fill the documentId if it's a single type\n if (isSingleType) {\n const doc = await strapi.documents(uid).findFirst();\n\n if (!doc) {\n throw new errors.NotFoundError('Document not found');\n }\n\n newParams.documentId = doc?.documentId;\n }\n\n /**\n * If status is not specified, follow the following rules:\n * - D&P disabled: status is considered published\n * - D&P enabled: status is considered draft\n */\n if (!newParams.status) {\n const isDPEnabled = model?.options?.draftAndPublish;\n newParams.status = isDPEnabled ? 'draft' : 'published';\n }\n\n return newParams;\n};\n"],"names":["getPreviewUrlSchema","z","object","documentId","string","optional","locale","nullable","status","validatePreviewUrl","strapi","uid","params","validateZodSchema","newParams","pick","model","getModel","modelType","errors","ValidationError","isSingleType","kind","doc","documents","findFirst","NotFoundError","isDPEnabled","options","draftAndPublish"],"mappings":";;;;;AAQA,MAAMA,mBAAAA,GAAsBC,aAAAA,CAAEC,MAAM,CAAC;;IAEnCC,UAAAA,EAAYF,aAAAA,CAAEG,MAAM,EAAA,CAAGC,QAAQ,EAAA;AAC/BC,IAAAA,MAAAA,EAAQL,aAAAA,CAAEG,MAAM,EAAA,CAAGG,QAAQ,GAAGF,QAAQ,EAAA;IACtCG,MAAAA,EAAQP,aAAAA,CAAEG,MAAM,EAAA,CAAGC,QAAQ;AAC7B,CAAA,CAAA;AAEO,MAAMI,kBAAAA,GAAqB,OAChCC,MAAAA,EACAC,GAAAA,EACAC,MAAAA,GAAAA;;AAGAC,IAAAA,6BAAAA,CAAkBb,mBAAAA,CAAAA,CAAqBY,MAAAA,CAAAA;IAEvC,MAAME,SAAAA,GAAYC,OAAKH,MAAAA,EAAQ;AAAC,QAAA,YAAA;AAAc,QAAA,QAAA;AAAU,QAAA;AAAS,KAAA,CAAA;IACjE,MAAMI,KAAAA,GAAQN,MAAAA,CAAOO,QAAQ,CAACN,GAAAA,CAAAA;;AAG9B,IAAA,IAAI,CAACK,KAAAA,IAASA,KAAAA,CAAME,SAAS,KAAK,aAAA,EAAe;QAC/C,MAAM,IAAIC,kBAAAA,CAAOC,eAAe,CAAC,sBAAA,CAAA;AACnC,IAAA;;IAGA,MAAMC,YAAAA,GAAeL,OAAOM,IAAAA,KAAS,YAAA;AACrC,IAAA,IAAI,CAACD,YAAAA,IAAgB,CAACT,MAAAA,CAAOT,UAAU,EAAE;QACvC,MAAM,IAAIgB,kBAAAA,CAAOC,eAAe,CAAC,6CAAA,CAAA;AACnC,IAAA;;AAGA,IAAA,IAAIC,YAAAA,EAAc;AAChB,QAAA,MAAME,MAAM,MAAMb,MAAAA,CAAOc,SAAS,CAACb,KAAKc,SAAS,EAAA;AAEjD,QAAA,IAAI,CAACF,GAAAA,EAAK;YACR,MAAM,IAAIJ,kBAAAA,CAAOO,aAAa,CAAC,oBAAA,CAAA;AACjC,QAAA;QAEAZ,SAAAA,CAAUX,UAAU,GAAGoB,GAAAA,EAAKpB,UAAAA;AAC9B,IAAA;AAEA;;;;AAIC,MACD,IAAI,CAACW,SAAAA,CAAUN,MAAM,EAAE;QACrB,MAAMmB,WAAAA,GAAcX,OAAOY,OAAAA,EAASC,eAAAA;QACpCf,SAAAA,CAAUN,MAAM,GAAGmB,WAAAA,GAAc,OAAA,GAAU,WAAA;AAC7C,IAAA;IAEA,OAAOb,SAAAA;AACT;;;;"}
@@ -1,4 +1,4 @@
1
- import { pick } from 'lodash/fp';
1
+ import { pick } from 'lodash';
2
2
  import { z, validateZodSchema, errors } from '@strapi/utils';
3
3
 
4
4
  const getPreviewUrlSchema = z.object({
@@ -10,11 +10,11 @@ const getPreviewUrlSchema = z.object({
10
10
  const validatePreviewUrl = async (strapi, uid, params)=>{
11
11
  // Validate the request parameters format
12
12
  validateZodSchema(getPreviewUrlSchema)(params);
13
- const newParams = pick([
13
+ const newParams = pick(params, [
14
14
  'documentId',
15
15
  'locale',
16
16
  'status'
17
- ], params);
17
+ ]);
18
18
  const model = strapi.getModel(uid);
19
19
  // If it's not a collection type or single type
20
20
  if (!model || model.modelType !== 'contentType') {
@@ -1 +1 @@
1
- {"version":3,"file":"preview.mjs","sources":["../../../../../server/src/preview/controllers/validation/preview.ts"],"sourcesContent":["import { pick } from 'lodash/fp';\n\nimport type { Core, UID } from '@strapi/types';\nimport { z, validateZodSchema, errors } from '@strapi/utils';\n\nimport { Preview } from '../../../../../shared/contracts';\nimport type { HandlerParams } from '../../services/preview-config';\n\nconst getPreviewUrlSchema = z.object({\n // Will be undefined for single types\n documentId: z.string().optional(),\n locale: z.string().nullable().optional(),\n status: z.string().optional(),\n});\n\nexport const validatePreviewUrl = async (\n strapi: Core.Strapi,\n uid: UID.ContentType,\n params: Preview.GetPreviewUrl.Request['query']\n): Promise<HandlerParams> => {\n // Validate the request parameters format\n validateZodSchema(getPreviewUrlSchema)(params);\n\n const newParams = pick(['documentId', 'locale', 'status'], params) as HandlerParams;\n const model = strapi.getModel(uid);\n\n // If it's not a collection type or single type\n if (!model || model.modelType !== 'contentType') {\n throw new errors.ValidationError('Invalid content type');\n }\n\n // Document id is not required for single types\n const isSingleType = model?.kind === 'singleType';\n if (!isSingleType && !params.documentId) {\n throw new errors.ValidationError('documentId is required for Collection Types');\n }\n\n // Fill the documentId if it's a single type\n if (isSingleType) {\n const doc = await strapi.documents(uid).findFirst();\n\n if (!doc) {\n throw new errors.NotFoundError('Document not found');\n }\n\n newParams.documentId = doc?.documentId;\n }\n\n /**\n * If status is not specified, follow the following rules:\n * - D&P disabled: status is considered published\n * - D&P enabled: status is considered draft\n */\n if (!newParams.status) {\n const isDPEnabled = model?.options?.draftAndPublish;\n newParams.status = isDPEnabled ? 'draft' : 'published';\n }\n\n return newParams;\n};\n"],"names":["getPreviewUrlSchema","z","object","documentId","string","optional","locale","nullable","status","validatePreviewUrl","strapi","uid","params","validateZodSchema","newParams","pick","model","getModel","modelType","errors","ValidationError","isSingleType","kind","doc","documents","findFirst","NotFoundError","isDPEnabled","options","draftAndPublish"],"mappings":";;;AAQA,MAAMA,mBAAAA,GAAsBC,CAAAA,CAAEC,MAAM,CAAC;;IAEnCC,UAAAA,EAAYF,CAAAA,CAAEG,MAAM,EAAA,CAAGC,QAAQ,EAAA;AAC/BC,IAAAA,MAAAA,EAAQL,CAAAA,CAAEG,MAAM,EAAA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AAM,GAAGmB,WAAAA,GAAc,OAAA,GAAU,WAAA;AAC7C,IAAA;IAEA,OAAOb,SAAAA;AACT;;;;"}
1
+ {"version":3,"file":"preview.mjs","sources":["../../../../../server/src/preview/controllers/validation/preview.ts"],"sourcesContent":["import { pick } from 'lodash';\n\nimport type { Core, UID } from '@strapi/types';\nimport { z, validateZodSchema, errors } from '@strapi/utils';\n\nimport { Preview } from '../../../../../shared/contracts';\nimport type { HandlerParams } from '../../services/preview-config';\n\nconst getPreviewUrlSchema = z.object({\n // Will be undefined for single types\n documentId: z.string().optional(),\n locale: z.string().nullable().optional(),\n status: z.string().optional(),\n});\n\nexport const validatePreviewUrl = async (\n strapi: Core.Strapi,\n uid: UID.ContentType,\n params: Preview.GetPreviewUrl.Request['query']\n): Promise<HandlerParams> => {\n // Validate the request parameters format\n validateZodSchema(getPreviewUrlSchema)(params);\n\n const newParams = pick(params, ['documentId', 'locale', 'status']) as HandlerParams;\n const model = strapi.getModel(uid);\n\n // If it's not a collection type or single type\n if (!model || model.modelType !== 'contentType') {\n throw new errors.ValidationError('Invalid content type');\n }\n\n // Document id is not required for single types\n const isSingleType = model?.kind === 'singleType';\n if (!isSingleType && !params.documentId) {\n throw new errors.ValidationError('documentId is required for Collection Types');\n }\n\n // Fill the documentId if it's a single type\n if (isSingleType) {\n const doc = await strapi.documents(uid).findFirst();\n\n if (!doc) {\n throw new errors.NotFoundError('Document not found');\n }\n\n newParams.documentId = doc?.documentId;\n }\n\n /**\n * If status is not specified, follow the following rules:\n * - D&P disabled: status is considered published\n * - D&P enabled: status is considered draft\n */\n if (!newParams.status) {\n const isDPEnabled = model?.options?.draftAndPublish;\n newParams.status = isDPEnabled ? 'draft' : 'published';\n }\n\n return newParams;\n};\n"],"names":["getPreviewUrlSchema","z","object","documentId","string","optional","locale","nullable","status","validatePreviewUrl","strapi","uid","params","validateZodSchema","newParams","pick","model","getModel","modelType","errors","ValidationError","isSingleType","kind","doc","documents","findFirst","NotFoundError","isDPEnabled","options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SAAAA,CAAUX,UAAU,GAAGoB,GAAAA,EAAKpB,UAAAA;AAC9B,IAAA;AAEA;;;;AAIC,MACD,IAAI,CAACW,SAAAA,CAAUN,MAAM,EAAE;QACrB,MAAMmB,WAAAA,GAAcX,OAAOY,OAAAA,EAASC,eAAAA;QACpCf,SAAAA,CAAUN,MAAM,GAAGmB,WAAAA,GAAc,OAAA,GAAU,WAAA;AAC7C,IAAA;IAEA,OAAOb,SAAAA;AACT;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('lodash/fp');
3
+ var _ = require('lodash');
4
4
  var index = require('../utils/index.js');
5
5
  var store = require('./utils/store.js');
6
6
  var configuration = require('./configuration.js');
@@ -12,7 +12,7 @@ const configurationService = configuration({
12
12
  prefix: STORE_KEY_PREFIX,
13
13
  getModels () {
14
14
  const { toContentManagerModel } = index.getService('data-mapper');
15
- return fp.mapValues(toContentManagerModel, strapi.components);
15
+ return _.mapValues(strapi.components, (value)=>toContentManagerModel(value));
16
16
  }
17
17
  });
18
18
  var components = (({ strapi: strapi1 })=>({
@@ -23,7 +23,7 @@ var components = (({ strapi: strapi1 })=>({
23
23
  findComponent (uid) {
24
24
  const { toContentManagerModel } = index.getService('data-mapper');
25
25
  const component = strapi1.components[uid];
26
- return fp.isNil(component) ? component : toContentManagerModel(component);
26
+ return component == null ? component : toContentManagerModel(component);
27
27
  },
28
28
  async findConfiguration (component) {
29
29
  const configuration = await configurationService.getConfiguration(component.uid);
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":["../../../server/src/services/components.ts"],"sourcesContent":["import { isNil, mapValues } from 'lodash/fp';\n\nimport type { UID, Struct, Core } from '@strapi/types';\nimport type { Configuration } from '../../../shared/contracts/content-types';\nimport type { ConfigurationUpdate } from './configuration';\n\nimport { getService } from '../utils';\nimport storeUtils from './utils/store';\nimport createConfigurationService from './configuration';\n\nconst STORE_KEY_PREFIX = 'components';\n\nconst configurationService = createConfigurationService({\n storeUtils,\n isComponent: true,\n prefix: STORE_KEY_PREFIX,\n getModels() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return mapValues(toContentManagerModel, strapi.components);\n },\n});\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => ({\n findAllComponents() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return Object.values(strapi.components).map(toContentManagerModel);\n },\n\n findComponent(uid: UID.Component) {\n const { toContentManagerModel } = getService('data-mapper');\n\n const component = strapi.components[uid];\n\n return isNil(component) ? component : toContentManagerModel(component);\n },\n\n async findConfiguration(component: Struct.ComponentSchema) {\n const configuration: Configuration = await configurationService.getConfiguration(component.uid);\n\n return {\n uid: component.uid,\n category: component.category,\n ...configuration,\n };\n },\n\n async updateConfiguration(\n component: Struct.ComponentSchema,\n newConfiguration: ConfigurationUpdate\n ) {\n await configurationService.setConfiguration(component.uid, newConfiguration);\n\n return this.findConfiguration(component);\n },\n\n /**\n * Batch load component configurations.\n *\n * Collects all component UIDs upfront, then loads configurations in a single\n * batch query instead of sequential queries per component.\n */\n async findComponentsConfigurations(model: Struct.ComponentSchema) {\n // Cache on request state so the same request can reuse configs\n const requestState = strapi.requestContext?.get?.()?.state as\n | { __componentsConfigurationsCache?: Map<string, Record<string, Configuration>> }\n | undefined;\n const requestCache = requestState?.__componentsConfigurationsCache;\n\n const componentUids = new Set<UID.Component>();\n\n const collectComponentUids = (schema: Struct.ComponentSchema) => {\n for (const key of Object.keys(schema.attributes)) {\n const attribute = schema.attributes[key];\n\n if (attribute.type === 'component') {\n const uid = attribute.component;\n if (!componentUids.has(uid)) {\n componentUids.add(uid);\n const nestedComponent = this.findComponent(uid);\n if (nestedComponent) {\n collectComponentUids(nestedComponent);\n }\n }\n }\n\n if (attribute.type === 'dynamiczone') {\n for (const uid of attribute.components) {\n if (!componentUids.has(uid)) {\n componentUids.add(uid);\n const nestedComponent = this.findComponent(uid);\n if (nestedComponent) {\n collectComponentUids(nestedComponent);\n }\n }\n }\n }\n }\n };\n\n collectComponentUids(model);\n\n if (componentUids.size === 0) {\n return {};\n }\n\n // Key format must match configuration.ts uidToStoreKey: `${prefix}::${uid}`\n const uidsArray = Array.from(componentUids);\n const prefixedKeys = uidsArray.map((uid) => `components::${uid}`);\n const cacheKey = prefixedKeys.slice().sort().join('|');\n if (requestCache?.has(cacheKey)) {\n return requestCache.get(cacheKey)! as Record<\n string,\n Configuration & { category: string; isComponent: boolean }\n >;\n }\n\n const configs = await storeUtils.getModelConfigurations(prefixedKeys);\n\n const componentsMap: Record<\n string,\n Configuration & { category: string; isComponent: boolean }\n > = {};\n\n for (const uid of uidsArray) {\n const component = this.findComponent(uid);\n const configKey = `components::${uid}`;\n // Fallback must include proper layouts structure for frontend compatibility\n const configuration = configs[configKey] || {\n settings: {},\n metadatas: {},\n layouts: { list: [], edit: [] },\n };\n\n componentsMap[uid] = {\n uid: component.uid,\n category: component.category,\n ...configuration,\n };\n }\n\n if (requestState) {\n if (!requestState.__componentsConfigurationsCache) {\n requestState.__componentsConfigurationsCache = new Map();\n }\n requestState.__componentsConfigurationsCache.set(cacheKey, componentsMap);\n }\n\n return componentsMap;\n },\n\n syncConfigurations() {\n return configurationService.syncConfigurations();\n },\n});\n"],"names":["STORE_KEY_PREFIX","configurationService","createConfigurationService","storeUtils","isComponent","prefix","getModels","toContentManagerModel","getService","mapValues","strapi","components","findAllComponents","Object","values","map","findComponent","uid","component","isNil","findConfiguration","configuration","getConfiguration","category","updateConfiguration","newConfiguration","setConfiguration","findComponentsConfigurations","model","requestState","requestContext","get","state","requestCache","__componentsConfigurationsCache","componentUids","Set","collectComponentUids","schema","key","keys","attributes","attribute","type","has","add","nestedComponent","size","uidsArray","Array","from","prefixedKeys","cacheKey","slice","sort","join","configs","getModelConfigurations","componentsMap","configKey","settings","metadatas","layouts","list","edit","Map","set","syncConfigurations"],"mappings":";;;;;;;AAUA,MAAMA,gBAAAA,GAAmB,YAAA;AAEzB,MAAMC,uBAAuBC,aAAAA,CAA2B;AACtDC,gBAAAA,KAAAA;IACAC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,QAAAA,EAAU,EAAC;AACXC,oBAAAA,SAAAA,EAAW,EAAC;oBACZC,OAAAA,EAAS;AAAEC,wBAAAA,IAAAA,EAAM,EAAE;AAAEC,wBAAAA,IAAAA,EAAM;AAAG;AAChC,iBAAA;gBAEAN,aAAa,CAACzC,IAAI,GAAG;AACnBA,oBAAAA,GAAAA,EAAKC,UAAUD,GAAG;AAClBM,oBAAAA,QAAAA,EAAUL,UAAUK,QAAQ;AAC5B,oBAAA,GAAGF;AACL,iBAAA;AACF,YAAA;AAEA,YAAA,IAAIQ,YAAAA,EAAc;gBAChB,IAAI,CAACA,YAAAA,CAAaK,+BAA+B,EAAE;oBACjDL,YAAAA,CAAaK,+BAA+B,GAAG,IAAI+B,GAAAA,EAAAA;AACrD,gBAAA;AACApC,gBAAAA,YAAAA,CAAaK,+BAA+B,CAACgC,GAAG,CAACd,QAAAA,EAAUM,aAAAA,CAAAA;AAC7D,YAAA;YAEA,OAAOA,aAAAA;AACT,QAAA,CAAA;AAEAS,QAAAA,kBAAAA,CAAAA,GAAAA;AACE,YAAA,OAAOlE,qBAAqBkE,kBAAkB,EAAA;AAChD,QAAA;AACF,KAAA,CAAC;;;;"}
1
+ {"version":3,"file":"components.js","sources":["../../../server/src/services/components.ts"],"sourcesContent":["import { mapValues } from 'lodash';\n\nimport type { UID, Struct, Core } from '@strapi/types';\nimport type { Configuration } from '../../../shared/contracts/content-types';\nimport type { ConfigurationUpdate } from './configuration';\n\nimport { getService } from '../utils';\nimport storeUtils from './utils/store';\nimport createConfigurationService from './configuration';\n\nconst STORE_KEY_PREFIX = 'components';\n\nconst configurationService = createConfigurationService({\n storeUtils,\n isComponent: true,\n prefix: STORE_KEY_PREFIX,\n getModels() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return mapValues(strapi.components, (value) => toContentManagerModel(value));\n },\n});\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => ({\n findAllComponents() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return Object.values(strapi.components).map(toContentManagerModel);\n },\n\n findComponent(uid: UID.Component) {\n const { toContentManagerModel } = getService('data-mapper');\n\n const component = strapi.components[uid];\n\n return component == null ? component : toContentManagerModel(component);\n },\n\n async findConfiguration(component: Struct.ComponentSchema) {\n const configuration: Configuration = await configurationService.getConfiguration(component.uid);\n\n return {\n uid: component.uid,\n category: component.category,\n ...configuration,\n };\n },\n\n async updateConfiguration(\n component: Struct.ComponentSchema,\n newConfiguration: ConfigurationUpdate\n ) {\n await configurationService.setConfiguration(component.uid, newConfiguration);\n\n return this.findConfiguration(component);\n },\n\n /**\n * Batch load component configurations.\n *\n * Collects all component UIDs upfront, then loads configurations in a single\n * batch query instead of sequential queries per component.\n */\n async findComponentsConfigurations(model: Struct.ComponentSchema) {\n // Cache on request state so the same request can reuse configs\n const requestState = strapi.requestContext?.get?.()?.state as\n | { __componentsConfigurationsCache?: Map<string, Record<string, Configuration>> }\n | undefined;\n const requestCache = requestState?.__componentsConfigurationsCache;\n\n const componentUids = new Set<UID.Component>();\n\n const collectComponentUids = (schema: Struct.ComponentSchema) => {\n for (const key of Object.keys(schema.attributes)) {\n const attribute = schema.attributes[key];\n\n if (attribute.type === 'component') {\n const uid = attribute.component;\n if (!componentUids.has(uid)) {\n componentUids.add(uid);\n const nestedComponent = this.findComponent(uid);\n if (nestedComponent) {\n collectComponentUids(nestedComponent);\n }\n }\n }\n\n if (attribute.type === 'dynamiczone') {\n for (const uid of attribute.components) {\n if (!componentUids.has(uid)) {\n componentUids.add(uid);\n const nestedComponent = this.findComponent(uid);\n if (nestedComponent) {\n collectComponentUids(nestedComponent);\n }\n }\n }\n }\n }\n };\n\n collectComponentUids(model);\n\n if (componentUids.size === 0) {\n return {};\n }\n\n // Key format must match configuration.ts uidToStoreKey: `${prefix}::${uid}`\n const uidsArray = Array.from(componentUids);\n const prefixedKeys = uidsArray.map((uid) => `components::${uid}`);\n const cacheKey = prefixedKeys.slice().sort().join('|');\n if (requestCache?.has(cacheKey)) {\n return requestCache.get(cacheKey)! as Record<\n string,\n Configuration & { category: string; isComponent: boolean }\n >;\n }\n\n const configs = await storeUtils.getModelConfigurations(prefixedKeys);\n\n const componentsMap: Record<\n string,\n Configuration & { category: string; isComponent: boolean }\n > = {};\n\n for (const uid of uidsArray) {\n const component = this.findComponent(uid);\n const configKey = `components::${uid}`;\n // Fallback must include proper layouts structure for frontend compatibility\n const configuration = configs[configKey] || {\n settings: {},\n metadatas: {},\n layouts: { list: [], edit: [] },\n };\n\n componentsMap[uid] = {\n uid: component.uid,\n category: component.category,\n ...configuration,\n };\n }\n\n if (requestState) {\n if (!requestState.__componentsConfigurationsCache) {\n requestState.__componentsConfigurationsCache = new Map();\n }\n requestState.__componentsConfigurationsCache.set(cacheKey, componentsMap);\n }\n\n return componentsMap;\n },\n\n syncConfigurations() {\n return configurationService.syncConfigurations();\n },\n});\n"],"names":["STORE_KEY_PREFIX","configurationService","createConfigurationService","storeUtils","isComponent","prefix","getModels","toContentManagerModel","getService","mapValues","strapi","components","value","findAllComponents","Object","values","map","findComponent","uid","component","findConfiguration","configuration","getConfiguration","category","updateConfiguration","newConfiguration","setConfiguration","findComponentsConfigurations","model","requestState","requestContext","get","state","requestCache","__componentsConfigurationsCache","componentUids","Set","collectComponentUids","schema","key","keys","attributes","attribute","type","has","add","nestedComponent","size","uidsArray","Array","from","prefixedKeys","cacheKey","slice","sort","join","configs","getModelConfigurations","componentsMap","configKey","settings","metadatas","layouts","list","edit","Map","set","syncConfigurations"],"mappings":";;;;;;;AAUA,MAAMA,gBAAAA,GAAmB,YAAA;AAEzB,MAAMC,uBAAuBC,aAAAA,CAA2B;AACtDC,gBAAAA,KAAAA;IACAC,WAAAA,EAAa,IAAA;IACbC,MAAAA,EAAQL,gBAAAA;AACRM,IAAAA,SAAAA,CAAAA,GAAAA;AACE,QAAA,MAAM,EAAEC,qBAAqB,EAAE,GAAGC,gBAAAA,CAAW,aAAA,CAAA;AAE7C,QAAA,OAAOC,YAAUC,MAAAA,CAAOC,UAAU,EAA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,GAAG;AACnBA,oBAAAA,GAAAA,EAAKC,UAAUD,GAAG;AAClBK,oBAAAA,QAAAA,EAAUJ,UAAUI,QAAQ;AAC5B,oBAAA,GAAGF;AACL,iBAAA;AACF,YAAA;AAEA,YAAA,IAAIQ,YAAAA,EAAc;gBAChB,IAAI,CAACA,YAAAA,CAAaK,+BAA+B,EAAE;oBACjDL,YAAAA,CAAaK,+BAA+B,GAAG,IAAI+B,GAAAA,EAAAA;AACrD,gBAAA;AACApC,gBAAAA,YAAAA,CAAaK,+BAA+B,CAACgC,GAAG,CAACd,QAAAA,EAAUM,aAAAA,CAAAA;AAC7D,YAAA;YAEA,OAAOA,aAAAA;AACT,QAAA,CAAA;AAEAS,QAAAA,kBAAAA,CAAAA,GAAAA;AACE,YAAA,OAAOlE,qBAAqBkE,kBAAkB,EAAA;AAChD,QAAA;AACF,KAAA,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- import { isNil, mapValues } from 'lodash/fp';
1
+ import { mapValues } from 'lodash';
2
2
  import { getService } from '../utils/index.mjs';
3
3
  import storeUtils from './utils/store.mjs';
4
4
  import createConfigurationService from './configuration.mjs';
@@ -10,7 +10,7 @@ const configurationService = createConfigurationService({
10
10
  prefix: STORE_KEY_PREFIX,
11
11
  getModels () {
12
12
  const { toContentManagerModel } = getService('data-mapper');
13
- return mapValues(toContentManagerModel, strapi.components);
13
+ return mapValues(strapi.components, (value)=>toContentManagerModel(value));
14
14
  }
15
15
  });
16
16
  var components = (({ strapi: strapi1 })=>({
@@ -21,7 +21,7 @@ var components = (({ strapi: strapi1 })=>({
21
21
  findComponent (uid) {
22
22
  const { toContentManagerModel } = getService('data-mapper');
23
23
  const component = strapi1.components[uid];
24
- return isNil(component) ? component : toContentManagerModel(component);
24
+ return component == null ? component : toContentManagerModel(component);
25
25
  },
26
26
  async findConfiguration (component) {
27
27
  const configuration = await configurationService.getConfiguration(component.uid);
@@ -1 +1 @@
1
- {"version":3,"file":"components.mjs","sources":["../../../server/src/services/components.ts"],"sourcesContent":["import { isNil, mapValues } from 'lodash/fp';\n\nimport type { UID, Struct, Core } from '@strapi/types';\nimport type { Configuration } from '../../../shared/contracts/content-types';\nimport type { ConfigurationUpdate } from './configuration';\n\nimport { getService } from '../utils';\nimport storeUtils from './utils/store';\nimport createConfigurationService from './configuration';\n\nconst STORE_KEY_PREFIX = 'components';\n\nconst configurationService = createConfigurationService({\n storeUtils,\n isComponent: true,\n prefix: STORE_KEY_PREFIX,\n getModels() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return mapValues(toContentManagerModel, strapi.components);\n },\n});\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => ({\n findAllComponents() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return Object.values(strapi.components).map(toContentManagerModel);\n },\n\n findComponent(uid: UID.Component) {\n const { toContentManagerModel } = getService('data-mapper');\n\n const component = strapi.components[uid];\n\n return isNil(component) ? component : toContentManagerModel(component);\n },\n\n async findConfiguration(component: Struct.ComponentSchema) {\n const configuration: Configuration = await configurationService.getConfiguration(component.uid);\n\n return {\n uid: component.uid,\n category: component.category,\n ...configuration,\n };\n },\n\n async updateConfiguration(\n component: Struct.ComponentSchema,\n newConfiguration: ConfigurationUpdate\n ) {\n await configurationService.setConfiguration(component.uid, newConfiguration);\n\n return this.findConfiguration(component);\n },\n\n /**\n * Batch load component configurations.\n *\n * Collects all component UIDs upfront, then loads configurations in a single\n * batch query instead of sequential queries per component.\n */\n async findComponentsConfigurations(model: Struct.ComponentSchema) {\n // Cache on request state so the same request can reuse configs\n const requestState = strapi.requestContext?.get?.()?.state as\n | { __componentsConfigurationsCache?: Map<string, Record<string, Configuration>> }\n | undefined;\n const requestCache = requestState?.__componentsConfigurationsCache;\n\n const componentUids = new Set<UID.Component>();\n\n const collectComponentUids = (schema: Struct.ComponentSchema) => {\n for (const key of Object.keys(schema.attributes)) {\n const attribute = schema.attributes[key];\n\n if (attribute.type === 'component') {\n const uid = attribute.component;\n if (!componentUids.has(uid)) {\n componentUids.add(uid);\n const nestedComponent = this.findComponent(uid);\n if (nestedComponent) {\n collectComponentUids(nestedComponent);\n }\n }\n }\n\n if (attribute.type === 'dynamiczone') {\n for (const uid of attribute.components) {\n if (!componentUids.has(uid)) {\n componentUids.add(uid);\n const nestedComponent = this.findComponent(uid);\n if (nestedComponent) {\n collectComponentUids(nestedComponent);\n }\n }\n }\n }\n }\n };\n\n collectComponentUids(model);\n\n if (componentUids.size === 0) {\n return {};\n }\n\n // Key format must match configuration.ts uidToStoreKey: `${prefix}::${uid}`\n const uidsArray = Array.from(componentUids);\n const prefixedKeys = uidsArray.map((uid) => `components::${uid}`);\n const cacheKey = prefixedKeys.slice().sort().join('|');\n if (requestCache?.has(cacheKey)) {\n return requestCache.get(cacheKey)! as Record<\n string,\n Configuration & { category: string; isComponent: boolean }\n >;\n }\n\n const configs = await storeUtils.getModelConfigurations(prefixedKeys);\n\n const componentsMap: Record<\n string,\n Configuration & { category: string; isComponent: boolean }\n > = {};\n\n for (const uid of uidsArray) {\n const component = this.findComponent(uid);\n const configKey = `components::${uid}`;\n // Fallback must include proper layouts structure for frontend compatibility\n const configuration = configs[configKey] || {\n settings: {},\n metadatas: {},\n layouts: { list: [], edit: [] },\n };\n\n componentsMap[uid] = {\n uid: component.uid,\n category: component.category,\n ...configuration,\n };\n }\n\n if (requestState) {\n if (!requestState.__componentsConfigurationsCache) {\n requestState.__componentsConfigurationsCache = new Map();\n }\n requestState.__componentsConfigurationsCache.set(cacheKey, componentsMap);\n }\n\n return componentsMap;\n },\n\n syncConfigurations() {\n return configurationService.syncConfigurations();\n },\n});\n"],"names":["STORE_KEY_PREFIX","configurationService","createConfigurationService","storeUtils","isComponent","prefix","getModels","toContentManagerModel","getService","mapValues","strapi","components","findAllComponents","Object","values","map","findComponent","uid","component","isNil","findConfiguration","configuration","getConfiguration","category","updateConfiguration","newConfiguration","setConfiguration","findComponentsConfigurations","model","requestState","requestContext","get","state","requestCache","__componentsConfigurationsCache","componentUids","Set","collectComponentUids","schema","key","keys","attributes","attribute","type","has","add","nestedComponent","size","uidsArray","Array","from","prefixedKeys","cacheKey","slice","sort","join","configs","getModelConfigurations","componentsMap","configKey","settings","metadatas","layouts","list","edit","Map","set","syncConfigurations"],"mappings":";;;;;AAUA,MAAMA,gBAAAA,GAAmB,YAAA;AAEzB,MAAMC,uBAAuBC,0BAAAA,CAA2B;AACtDC,IAAAA,UAAAA;IACAC,WAAAA,EAAa,IAAA;IACbC,MAAAA,EAAQL,gBAAAA;AACRM,IAAAA,SAAAA,CAAAA,GAAAA;AACE,QAAA,MAAM,EAAEC,qBAAqB,EAAE,GAAGC,UAAAA,CAAW,aAAA,CAAA;QAE7C,OAAOC,SAAAA,CAAUF,qBAAAA,EAAuBG,MAAAA,CAAOC,UAAU,CAAA;AAC3D,IAAA;AACF,CAAA,CAAA;AAEA,iBAAe,CAAA,CAAC,EAAED,QAAAA,OAAM,EAA2B,IAAM;AACvDE,QAAAA,iBAAAA,CAAAA,GAAAA;AACE,YAAA,MAAM,EAAEL,qBAAqB,EAAE,GAAGC,UAAAA,CAAW,aAAA,CAAA;AAE7C,YAAA,OAAOK,OAAOC,MAAM,CAACJ,QAAOC,UAAU,CAAA,CAAEI,GAAG,CAACR,qBAAAA,CAAAA;AAC9C,QAAA,CAAA;AAEAS,QAAAA,aAAAA,CAAAA,CAAcC,GAAkB,EAAA;AAC9B,YAAA,MAAM,EAAEV,qBAAqB,EAAE,GAAGC,UAAAA,CAAW,aAAA,CAAA;AAE7C,YAAA,MAAMU,SAAAA,GAAYR,OAAAA,CAAOC,UAAU,CAACM,GAAAA,CAAI;YAExC,OAAOE,KAAAA,CAAMD,SAAAA,CAAAA,GAAaA,SAAAA,GAAYX,qBAAAA,CAAsBW,SAAAA,CAAAA;AAC9D,QAAA,CAAA;AAEA,QAAA,MAAME,mBAAkBF,SAAiC,EAAA;AACvD,YAAA,MAAMG,gBAA+B,MAAMpB,oBAAAA,CAAqBqB,gBAAgB,CAACJ,UAAUD,GAAG,CAA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,SAAAA,CAAW;AAC3B,gBAAA,MAAM9B,SAAAA,GAAY,IAAI,CAACF,aAAa,CAACC,GAAAA,CAAAA;AACrC,gBAAA,MAAM0C,SAAAA,GAAY,CAAC,YAAY,EAAE1C,GAAAA,CAAAA,CAAK;;AAEtC,gBAAA,MAAMI,aAAAA,GAAgBmC,OAAO,CAACG,SAAAA,CAAU,IAAI;AAC1CC,oBAAAA,QAAAA,EAAU,EAAC;AACXC,oBAAAA,SAAAA,EAAW,EAAC;oBACZC,OAAAA,EAAS;AAAEC,wBAAAA,IAAAA,EAAM,EAAE;AAAEC,wBAAAA,IAAAA,EAAM;AAAG;AAChC,iBAAA;gBAEAN,aAAa,CAACzC,IAAI,GAAG;AACnBA,oBAAAA,GAAAA,EAAKC,UAAUD,GAAG;AAClBM,oBAAAA,QAAAA,EAAUL,UAAUK,QAAQ;AAC5B,oBAAA,GAAGF;AACL,iBAAA;AACF,YAAA;AAEA,YAAA,IAAIQ,YAAAA,EAAc;gBAChB,IAAI,CAACA,YAAAA,CAAaK,+BAA+B,EAAE;oBACjDL,YAAAA,CAAaK,+BAA+B,GAAG,IAAI+B,GAAAA,EAAAA;AACrD,gBAAA;AACApC,gBAAAA,YAAAA,CAAaK,+BAA+B,CAACgC,GAAG,CAACd,QAAAA,EAAUM,aAAAA,CAAAA;AAC7D,YAAA;YAEA,OAAOA,aAAAA;AACT,QAAA,CAAA;AAEAS,QAAAA,kBAAAA,CAAAA,GAAAA;AACE,YAAA,OAAOlE,qBAAqBkE,kBAAkB,EAAA;AAChD,QAAA;AACF,KAAA,CAAC;;;;"}
1
+ {"version":3,"file":"components.mjs","sources":["../../../server/src/services/components.ts"],"sourcesContent":["import { mapValues } from 'lodash';\n\nimport type { UID, Struct, Core } from '@strapi/types';\nimport type { Configuration } from '../../../shared/contracts/content-types';\nimport type { ConfigurationUpdate } from './configuration';\n\nimport { getService } from '../utils';\nimport storeUtils from './utils/store';\nimport createConfigurationService from './configuration';\n\nconst STORE_KEY_PREFIX = 'components';\n\nconst configurationService = createConfigurationService({\n storeUtils,\n isComponent: true,\n prefix: STORE_KEY_PREFIX,\n getModels() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return mapValues(strapi.components, (value) => toContentManagerModel(value));\n },\n});\n\nexport default ({ strapi }: { strapi: Core.Strapi }) => ({\n findAllComponents() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return Object.values(strapi.components).map(toContentManagerModel);\n },\n\n findComponent(uid: UID.Component) {\n const { toContentManagerModel } = getService('data-mapper');\n\n const component = strapi.components[uid];\n\n return component == null ? component : toContentManagerModel(component);\n },\n\n async findConfiguration(component: Struct.ComponentSchema) {\n const configuration: Configuration = await configurationService.getConfiguration(component.uid);\n\n return {\n uid: component.uid,\n category: component.category,\n ...configuration,\n };\n },\n\n async updateConfiguration(\n component: Struct.ComponentSchema,\n newConfiguration: ConfigurationUpdate\n ) {\n await configurationService.setConfiguration(component.uid, newConfiguration);\n\n return this.findConfiguration(component);\n },\n\n /**\n * Batch load component configurations.\n *\n * Collects all component UIDs upfront, then loads configurations in a single\n * batch query instead of sequential queries per component.\n */\n async findComponentsConfigurations(model: Struct.ComponentSchema) {\n // Cache on request state so the same request can reuse configs\n const requestState = strapi.requestContext?.get?.()?.state as\n | { __componentsConfigurationsCache?: Map<string, Record<string, Configuration>> }\n | undefined;\n const requestCache = requestState?.__componentsConfigurationsCache;\n\n const componentUids = new Set<UID.Component>();\n\n const collectComponentUids = (schema: Struct.ComponentSchema) => {\n for (const key of Object.keys(schema.attributes)) {\n const attribute = schema.attributes[key];\n\n if (attribute.type === 'component') {\n const uid = attribute.component;\n if (!componentUids.has(uid)) {\n componentUids.add(uid);\n const nestedComponent = this.findComponent(uid);\n if (nestedComponent) {\n collectComponentUids(nestedComponent);\n }\n }\n }\n\n if (attribute.type === 'dynamiczone') {\n for (const uid of attribute.components) {\n if (!componentUids.has(uid)) {\n componentUids.add(uid);\n const nestedComponent = this.findComponent(uid);\n if (nestedComponent) {\n collectComponentUids(nestedComponent);\n }\n }\n }\n }\n }\n };\n\n collectComponentUids(model);\n\n if (componentUids.size === 0) {\n return {};\n }\n\n // Key format must match configuration.ts uidToStoreKey: `${prefix}::${uid}`\n const uidsArray = Array.from(componentUids);\n const prefixedKeys = uidsArray.map((uid) => `components::${uid}`);\n const cacheKey = prefixedKeys.slice().sort().join('|');\n if (requestCache?.has(cacheKey)) {\n return requestCache.get(cacheKey)! as Record<\n string,\n Configuration & { category: string; isComponent: boolean }\n >;\n }\n\n const configs = await storeUtils.getModelConfigurations(prefixedKeys);\n\n const componentsMap: Record<\n string,\n Configuration & { category: string; isComponent: boolean }\n > = {};\n\n for (const uid of uidsArray) {\n const component = this.findComponent(uid);\n const configKey = `components::${uid}`;\n // Fallback must include proper layouts structure for frontend compatibility\n const configuration = configs[configKey] || {\n settings: {},\n metadatas: {},\n layouts: { list: [], edit: [] },\n };\n\n componentsMap[uid] = {\n uid: component.uid,\n category: component.category,\n ...configuration,\n };\n }\n\n if (requestState) {\n if (!requestState.__componentsConfigurationsCache) {\n requestState.__componentsConfigurationsCache = new Map();\n }\n requestState.__componentsConfigurationsCache.set(cacheKey, componentsMap);\n }\n\n return componentsMap;\n },\n\n syncConfigurations() {\n return configurationService.syncConfigurations();\n },\n});\n"],"names":["STORE_KEY_PREFIX","configurationService","createConfigurationService","storeUtils","isComponent","prefix","getModels","toContentManagerModel","getService","mapValues","strapi","components","value","findAllComponents","Object","values","map","findComponent","uid","component","findConfiguration","configuration","getConfiguration","category","updateConfiguration","newConfiguration","setConfiguration","findComponentsConfigurations","model","requestState","requestContext","get","state","requestCache","__componentsConfigurationsCache","componentUids","Set","collectComponentUids","schema","key","keys","attributes","attribute","type","has","add","nestedComponent","size","uidsArray","Array","from","prefixedKeys","cacheKey","slice","sort","join","configs","getModelConfigurations","componentsMap","configKey","settings","metadatas","layouts","list","edit","Map","set","syncConfigurations"],"mappings":";;;;;AAUA,MAAMA,gBAAAA,GAAmB,YAAA;AAEzB,MAAMC,uBAAuBC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aAAAA,GAAgBmC,OAAO,CAACG,SAAAA,CAAU,IAAI;AAC1CC,oBAAAA,QAAAA,EAAU,EAAC;AACXC,oBAAAA,SAAAA,EAAW,EAAC;oBACZC,OAAAA,EAAS;AAAEC,wBAAAA,IAAAA,EAAM,EAAE;AAAEC,wBAAAA,IAAAA,EAAM;AAAG;AAChC,iBAAA;gBAEAN,aAAa,CAACxC,IAAI,GAAG;AACnBA,oBAAAA,GAAAA,EAAKC,UAAUD,GAAG;AAClBK,oBAAAA,QAAAA,EAAUJ,UAAUI,QAAQ;AAC5B,oBAAA,GAAGF;AACL,iBAAA;AACF,YAAA;AAEA,YAAA,IAAIQ,YAAAA,EAAc;gBAChB,IAAI,CAACA,YAAAA,CAAaK,+BAA+B,EAAE;oBACjDL,YAAAA,CAAaK,+BAA+B,GAAG,IAAI+B,GAAAA,EAAAA;AACrD,gBAAA;AACApC,gBAAAA,YAAAA,CAAaK,+BAA+B,CAACgC,GAAG,CAACd,QAAAA,EAAUM,aAAAA,CAAAA;AAC7D,YAAA;YAEA,OAAOA,aAAAA;AACT,QAAA,CAAA;AAEAS,QAAAA,kBAAAA,CAAAA,GAAAA;AACE,YAAA,OAAOlE,qBAAqBkE,kBAAkB,EAAA;AAChD,QAAA;AACF,KAAA,CAAC;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('lodash/fp');
3
+ var _ = require('lodash');
4
4
 
5
5
  const isInternalUid = (uid)=>{
6
6
  return uid.startsWith('admin::') || uid.startsWith('strapi::');
@@ -8,7 +8,7 @@ const isInternalUid = (uid)=>{
8
8
  const createContentStructureService = ({ strapi })=>{
9
9
  const coreContentStructure = strapi.get('content-structure');
10
10
  const isContentTypeVisible = (model)=>{
11
- return fp.getOr(true, 'pluginOptions.content-manager.visible', model) === true;
11
+ return _.get(model, 'pluginOptions.content-manager.visible', true) === true;
12
12
  };
13
13
  /**
14
14
  * Whether a content type may appear in the folder nav: a known, user-facing type
@@ -1 +1 @@
1
- {"version":3,"file":"content-structure.js","sources":["../../../server/src/services/content-structure.ts"],"sourcesContent":["import type { Core, Modules, UID, Struct } from '@strapi/types';\nimport { getOr } from 'lodash/fp';\n\ninterface CoreContentStructureService {\n getCleanedFile(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n resolve(): Promise<Modules.ContentStructure.ResolvedContentStructure>;\n}\n\ntype ResolvedGroupNode = Modules.ContentStructure.ResolvedGroupNode;\n\nconst isInternalUid = (uid: string): boolean => {\n return uid.startsWith('admin::') || uid.startsWith('strapi::');\n};\n\nconst createContentStructureService = ({ strapi }: { strapi: Core.Strapi }) => {\n const coreContentStructure: CoreContentStructureService = strapi.get('content-structure');\n\n const isContentTypeVisible = (model: Struct.ContentTypeSchema) => {\n return getOr(true, 'pluginOptions.content-manager.visible', model) === true;\n };\n\n /**\n * Whether a content type may appear in the folder nav: a known, user-facing type\n * that is neither internal nor hidden via pluginOptions.\n */\n const isFileableContentType = (uid: UID.ContentType): boolean => {\n const schema = strapi.contentTypes[uid];\n\n if (!schema) {\n return false;\n }\n\n if (isInternalUid(uid)) {\n return false;\n }\n\n return isContentTypeVisible(schema);\n };\n\n const pruneNode = (node: ResolvedGroupNode): ResolvedGroupNode => {\n const children = node.children\n .filter((child) => {\n return child.type !== 'contentType' || isFileableContentType(child.uid);\n })\n .map((child) => {\n return child.type === 'group' ? pruneNode(child) : child;\n });\n\n return { ...node, children };\n };\n\n return {\n async getContentStructure(): Promise<Modules.ContentStructure.ResolvedContentStructure | null> {\n const cleaned = await coreContentStructure.getCleanedFile();\n\n if (!cleaned) {\n return null;\n }\n\n const resolved = await coreContentStructure.resolve();\n\n return {\n collectionTypes: resolved.collectionTypes.map(pruneNode),\n singleTypes: resolved.singleTypes.map(pruneNode),\n };\n },\n };\n};\n\nexport default createContentStructureService;\n"],"names":["isInternalUid","uid","startsWith","createContentStructureService","strapi","coreContentStructure","get","isContentTypeVisible","model","getOr","isFileableContentType","schema","contentTypes","pruneNode","node","children","filter","child","type","map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,OAAO;AAAE,YAAA,GAAGH,IAAI;AAAEC,YAAAA;AAAS,SAAA;AAC7B,IAAA,CAAA;IAEA,OAAO;QACL,MAAMK,mBAAAA,CAAAA,GAAAA;YACJ,MAAMC,OAAAA,GAAU,MAAMhB,oBAAAA,CAAqBiB,cAAc,EAAA;AAEzD,YAAA,IAAI,CAACD,OAAAA,EAAS;gBACZ,OAAO,IAAA;AACT,YAAA;YAEA,MAAME,QAAAA,GAAW,MAAMlB,oBAAAA,CAAqBmB,OAAO,EAAA;YAEnD,OAAO;AACLC,gBAAAA,eAAAA,EAAiBF,QAAAA,CAASE,eAAe,CAACN,GAAG,CAACN,SAAAA,CAAAA;AAC9Ca,gBAAAA,WAAAA,EAAaH,QAAAA,CAASG,WAAW,CAACP,GAAG,CAACN,SAAAA;AACxC,aAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"content-structure.js","sources":["../../../server/src/services/content-structure.ts"],"sourcesContent":["import type { Core, Modules, UID, Struct } from '@strapi/types';\nimport { get } from 'lodash';\n\ninterface CoreContentStructureService {\n getCleanedFile(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n resolve(): Promise<Modules.ContentStructure.ResolvedContentStructure>;\n}\n\ntype ResolvedGroupNode = Modules.ContentStructure.ResolvedGroupNode;\n\nconst isInternalUid = (uid: string): boolean => {\n return uid.startsWith('admin::') || uid.startsWith('strapi::');\n};\n\nconst createContentStructureService = ({ strapi }: { strapi: Core.Strapi }) => {\n const coreContentStructure: CoreContentStructureService = strapi.get('content-structure');\n\n const isContentTypeVisible = (model: Struct.ContentTypeSchema) => {\n return get(model, 'pluginOptions.content-manager.visible', true) === true;\n };\n\n /**\n * Whether a content type may appear in the folder nav: a known, user-facing type\n * that is neither internal nor hidden via pluginOptions.\n */\n const isFileableContentType = (uid: UID.ContentType): boolean => {\n const schema = strapi.contentTypes[uid];\n\n if (!schema) {\n return false;\n }\n\n if (isInternalUid(uid)) {\n return false;\n }\n\n return isContentTypeVisible(schema);\n };\n\n const pruneNode = (node: ResolvedGroupNode): ResolvedGroupNode => {\n const children = node.children\n .filter((child) => {\n return child.type !== 'contentType' || isFileableContentType(child.uid);\n })\n .map((child) => {\n return child.type === 'group' ? pruneNode(child) : child;\n });\n\n return { ...node, children };\n };\n\n return {\n async getContentStructure(): Promise<Modules.ContentStructure.ResolvedContentStructure | null> {\n const cleaned = await coreContentStructure.getCleanedFile();\n\n if (!cleaned) {\n return null;\n }\n\n const resolved = await coreContentStructure.resolve();\n\n return {\n collectionTypes: resolved.collectionTypes.map(pruneNode),\n singleTypes: resolved.singleTypes.map(pruneNode),\n };\n },\n };\n};\n\nexport default createContentStructureService;\n"],"names":["isInternalUid","uid","startsWith","createContentStructureService","strapi","coreContentStructure","get","isContentTypeVisible","model","isFileableContentType","schema","contentTypes","pruneNode","node","children","filter","child","type","map","getContentStructure","cleaned","getCleanedFile","resolved","resolve","collectionTypes","singleTypes"],"mappings":";;;;AAUA,MAAMA,gBAAgB,CAACC,GAAAA,GAAAA;AACrB,IAAA,OAAOA,IAAIC,UAAU,CAAC,SAAA,CAAA,IAAcD,GAAAA,CAAIC,UAAU,CAAC,UAAA,CAAA;AACrD,CAAA;AAEA,MAAMC,6BAAAA,GAAgC,CAAC,EAAEC,MAAM,EAA2B,GAAA;IACxE,MAAMC,oBAAAA,GAAoDD,MAAAA,CAAOE,GAAG,CAAC,mBAAA,CAAA;AAErE,IAAA,MAAMC,uBAAuB,CAACC,KAAAA,GAAAA;QAC5B,OAAOF,KAAAA,CAAIE,KAAAA,EAAO,uCAAA,EAAyC,IAAA,CAAA,KAAU,IAAA;AACvE,IAAA,CAAA;AAEA;;;MAIA,MAAMC,wBAAwB,CAACR,GAAAA,GAAAA;AAC7B,QAAA,MAAMS,MAAAA,GAASN,MAAAA,CAAOO,YAAY,CAACV,GAAAA,CAAI;AAEvC,QAAA,IAAI,CAACS,MAAAA,EAAQ;YACX,OAAO,KAAA;AACT,QAAA;AAEA,QAAA,IAAIV,cAAcC,GAAAA,CAAAA,EAAM;YACtB,OAAO,KAAA;AACT,QAAA;AAEA,QAAA,OAAOM,oBAAAA,CAAqBG,MAAAA,CAAAA;AAC9B,IAAA,CAAA;AAEA,IAAA,MAAME,YAAY,CAACC,IAAAA,GAAAA;AACjB,QAAA,MAAMC,WAAWD,IAAAA,CAAKC,QAAQ,CAC3BC,MAAM,CAAC,CAACC,KAAAA,GAAAA;AACP,YAAA,OAAOA,MAAMC,IAAI,KAAK,aAAA,IAAiBR,qBAAAA,CAAsBO,MAAMf,GAAG,CAAA;QACxE,CAAA,CAAA,CACCiB,GAAG,CAAC,CAACF,KAAAA,GAAAA;AACJ,YAAA,OAAOA,KAAAA,CAAMC,IAAI,KAAK,OAAA,GAAUL,UAAUI,KAAAA,CAAAA,GAASA,KAAAA;AACrD,QAAA,CAAA,CAAA;QAEF,OAAO;AAAE,YAAA,GAAGH,IAAI;AAAEC,YAAAA;AAAS,SAAA;AAC7B,IAAA,CAAA;IAEA,OAAO;QACL,MAAMK,mBAAAA,CAAAA,GAAAA;YACJ,MAAMC,OAAAA,GAAU,MAAMf,oBAAAA,CAAqBgB,cAAc,EAAA;AAEzD,YAAA,IAAI,CAACD,OAAAA,EAAS;gBACZ,OAAO,IAAA;AACT,YAAA;YAEA,MAAME,QAAAA,GAAW,MAAMjB,oBAAAA,CAAqBkB,OAAO,EAAA;YAEnD,OAAO;AACLC,gBAAAA,eAAAA,EAAiBF,QAAAA,CAASE,eAAe,CAACN,GAAG,CAACN,SAAAA,CAAAA;AAC9Ca,gBAAAA,WAAAA,EAAaH,QAAAA,CAASG,WAAW,CAACP,GAAG,CAACN,SAAAA;AACxC,aAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
@@ -1,4 +1,4 @@
1
- import { getOr } from 'lodash/fp';
1
+ import { get } from 'lodash';
2
2
 
3
3
  const isInternalUid = (uid)=>{
4
4
  return uid.startsWith('admin::') || uid.startsWith('strapi::');
@@ -6,7 +6,7 @@ const isInternalUid = (uid)=>{
6
6
  const createContentStructureService = ({ strapi })=>{
7
7
  const coreContentStructure = strapi.get('content-structure');
8
8
  const isContentTypeVisible = (model)=>{
9
- return getOr(true, 'pluginOptions.content-manager.visible', model) === true;
9
+ return get(model, 'pluginOptions.content-manager.visible', true) === true;
10
10
  };
11
11
  /**
12
12
  * Whether a content type may appear in the folder nav: a known, user-facing type
@@ -1 +1 @@
1
- {"version":3,"file":"content-structure.mjs","sources":["../../../server/src/services/content-structure.ts"],"sourcesContent":["import type { Core, Modules, UID, Struct } from '@strapi/types';\nimport { getOr } from 'lodash/fp';\n\ninterface CoreContentStructureService {\n getCleanedFile(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n resolve(): Promise<Modules.ContentStructure.ResolvedContentStructure>;\n}\n\ntype ResolvedGroupNode = Modules.ContentStructure.ResolvedGroupNode;\n\nconst isInternalUid = (uid: string): boolean => {\n return uid.startsWith('admin::') || uid.startsWith('strapi::');\n};\n\nconst createContentStructureService = ({ strapi }: { strapi: Core.Strapi }) => {\n const coreContentStructure: CoreContentStructureService = strapi.get('content-structure');\n\n const isContentTypeVisible = (model: Struct.ContentTypeSchema) => {\n return getOr(true, 'pluginOptions.content-manager.visible', model) === true;\n };\n\n /**\n * Whether a content type may appear in the folder nav: a known, user-facing type\n * that is neither internal nor hidden via pluginOptions.\n */\n const isFileableContentType = (uid: UID.ContentType): boolean => {\n const schema = strapi.contentTypes[uid];\n\n if (!schema) {\n return false;\n }\n\n if (isInternalUid(uid)) {\n return false;\n }\n\n return isContentTypeVisible(schema);\n };\n\n const pruneNode = (node: ResolvedGroupNode): ResolvedGroupNode => {\n const children = node.children\n .filter((child) => {\n return child.type !== 'contentType' || isFileableContentType(child.uid);\n })\n .map((child) => {\n return child.type === 'group' ? pruneNode(child) : child;\n });\n\n return { ...node, children };\n };\n\n return {\n async getContentStructure(): Promise<Modules.ContentStructure.ResolvedContentStructure | null> {\n const cleaned = await coreContentStructure.getCleanedFile();\n\n if (!cleaned) {\n return null;\n }\n\n const resolved = await coreContentStructure.resolve();\n\n return {\n collectionTypes: resolved.collectionTypes.map(pruneNode),\n singleTypes: resolved.singleTypes.map(pruneNode),\n };\n },\n };\n};\n\nexport default createContentStructureService;\n"],"names":["isInternalUid","uid","startsWith","createContentStructureService","strapi","coreContentStructure","get","isContentTypeVisible","model","getOr","isFileableContentType","schema","contentTypes","pruneNode","node","children","filter","child","type","map","getContentStructure","cleaned","getCleanedFile","resolved","resolve","collectionTypes","singleTypes"],"mappings":";;AAUA,MAAMA,gBAAgB,CAACC,GAAAA,GAAAA;AACrB,IAAA,OAAOA,IAAIC,UAAU,CAAC,SAAA,CAAA,IAAcD,GAAAA,CAAIC,UAAU,CAAC,UAAA,CAAA;AACrD,CAAA;AAEA,MAAMC,6BAAAA,GAAgC,CAAC,EAAEC,MAAM,EAA2B,GAAA;IACxE,MAAMC,oBAAAA,GAAoDD,MAAAA,CAAOE,GAAG,CAAC,mBAAA,CAAA;AAErE,IAAA,MAAMC,uBAAuB,CAACC,KAAAA,GAAAA;QAC5B,OAAOC,KAAAA,CAAM,IAAA,EAAM,uCAAA,EAAyCD,KAAAA,CAAAA,KAAW,IAAA;AACzE,IAAA,CAAA;AAEA;;;MAIA,MAAME,wBAAwB,CAACT,GAAAA,GAAAA;AAC7B,QAAA,MAAMU,MAAAA,GAASP,MAAAA,CAAOQ,YAAY,CAACX,GAAAA,CAAI;AAEvC,QAAA,IAAI,CAACU,MAAAA,EAAQ;YACX,OAAO,KAAA;AACT,QAAA;AAEA,QAAA,IAAIX,cAAcC,GAAAA,CAAAA,EAAM;YACtB,OAAO,KAAA;AACT,QAAA;AAEA,QAAA,OAAOM,oBAAAA,CAAqBI,MAAAA,CAAAA;AAC9B,IAAA,CAAA;AAEA,IAAA,MAAME,YAAY,CAACC,IAAAA,GAAAA;AACjB,QAAA,MAAMC,WAAWD,IAAAA,CAAKC,QAAQ,CAC3BC,MAAM,CAAC,CAACC,KAAAA,GAAAA;AACP,YAAA,OAAOA,MAAMC,IAAI,KAAK,aAAA,IAAiBR,qBAAAA,CAAsBO,MAAMhB,GAAG,CAAA;QACxE,CAAA,CAAA,CACCkB,GAAG,CAAC,CAACF,KAAAA,GAAAA;AACJ,YAAA,OAAOA,KAAAA,CAAMC,IAAI,KAAK,OAAA,GAAUL,UAAUI,KAAAA,CAAAA,GAASA,KAAAA;AACrD,QAAA,CAAA,CAAA;QAEF,OAAO;AAAE,YAAA,GAAGH,IAAI;AAAEC,YAAAA;AAAS,SAAA;AAC7B,IAAA,CAAA;IAEA,OAAO;QACL,MAAMK,mBAAAA,CAAAA,GAAAA;YACJ,MAAMC,OAAAA,GAAU,MAAMhB,oBAAAA,CAAqBiB,cAAc,EAAA;AAEzD,YAAA,IAAI,CAACD,OAAAA,EAAS;gBACZ,OAAO,IAAA;AACT,YAAA;YAEA,MAAME,QAAAA,GAAW,MAAMlB,oBAAAA,CAAqBmB,OAAO,EAAA;YAEnD,OAAO;AACLC,gBAAAA,eAAAA,EAAiBF,QAAAA,CAASE,eAAe,CAACN,GAAG,CAACN,SAAAA,CAAAA;AAC9Ca,gBAAAA,WAAAA,EAAaH,QAAAA,CAASG,WAAW,CAACP,GAAG,CAACN,SAAAA;AACxC,aAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"content-structure.mjs","sources":["../../../server/src/services/content-structure.ts"],"sourcesContent":["import type { Core, Modules, UID, Struct } from '@strapi/types';\nimport { get } from 'lodash';\n\ninterface CoreContentStructureService {\n getCleanedFile(): Promise<Modules.ContentStructure.ContentStructureFile | null>;\n resolve(): Promise<Modules.ContentStructure.ResolvedContentStructure>;\n}\n\ntype ResolvedGroupNode = Modules.ContentStructure.ResolvedGroupNode;\n\nconst isInternalUid = (uid: string): boolean => {\n return uid.startsWith('admin::') || uid.startsWith('strapi::');\n};\n\nconst createContentStructureService = ({ strapi }: { strapi: Core.Strapi }) => {\n const coreContentStructure: CoreContentStructureService = strapi.get('content-structure');\n\n const isContentTypeVisible = (model: Struct.ContentTypeSchema) => {\n return get(model, 'pluginOptions.content-manager.visible', true) === true;\n };\n\n /**\n * Whether a content type may appear in the folder nav: a known, user-facing type\n * that is neither internal nor hidden via pluginOptions.\n */\n const isFileableContentType = (uid: UID.ContentType): boolean => {\n const schema = strapi.contentTypes[uid];\n\n if (!schema) {\n return false;\n }\n\n if (isInternalUid(uid)) {\n return false;\n }\n\n return isContentTypeVisible(schema);\n };\n\n const pruneNode = (node: ResolvedGroupNode): ResolvedGroupNode => {\n const children = node.children\n .filter((child) => {\n return child.type !== 'contentType' || isFileableContentType(child.uid);\n })\n .map((child) => {\n return child.type === 'group' ? pruneNode(child) : child;\n });\n\n return { ...node, children };\n };\n\n return {\n async getContentStructure(): Promise<Modules.ContentStructure.ResolvedContentStructure | null> {\n const cleaned = await coreContentStructure.getCleanedFile();\n\n if (!cleaned) {\n return null;\n }\n\n const resolved = await coreContentStructure.resolve();\n\n return {\n collectionTypes: resolved.collectionTypes.map(pruneNode),\n singleTypes: resolved.singleTypes.map(pruneNode),\n };\n },\n };\n};\n\nexport default createContentStructureService;\n"],"names":["isInternalUid","uid","startsWith","createContentStructureService","strapi","coreContentStructure","get","isContentTypeVisible","model","isFileableContentType","schema","contentTypes","pruneNode","node","children","filter","child","type","map","getContentStructure","cleaned","getCleanedFile","resolved","resolve","collectionTypes","singleTypes"],"mappings":";;AAUA,MAAMA,gBAAgB,CAACC,GAAAA,GAAAA;AACrB,IAAA,OAAOA,IAAIC,UAAU,CAAC,SAAA,CAAA,IAAcD,GAAAA,CAAIC,UAAU,CAAC,UAAA,CAAA;AACrD,CAAA;AAEA,MAAMC,6BAAAA,GAAgC,CAAC,EAAEC,MAAM,EAA2B,GAAA;IACxE,MAAMC,oBAAAA,GAAoDD,MAAAA,CAAOE,GAAG,CAAC,mBAAA,CAAA;AAErE,IAAA,MAAMC,uBAAuB,CAACC,KAAAA,GAAAA;QAC5B,OAAOF,GAAAA,CAAIE,KAAAA,EAAO,uCAAA,EAAyC,IAAA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CAASG,WAAW,CAACP,GAAG,CAACN,SAAAA;AACxC,aAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var fp = require('lodash/fp');
3
+ var _ = require('lodash');
4
4
  var strapiUtils = require('@strapi/utils');
5
5
  var index = require('../utils/index.js');
6
6
  var store = require('./utils/store.js');
@@ -11,7 +11,7 @@ const configurationService = configuration({
11
11
  prefix: 'content_types',
12
12
  getModels () {
13
13
  const { toContentManagerModel } = index.getService('data-mapper');
14
- return fp.mapValues(toContentManagerModel, strapi.contentTypes);
14
+ return _.mapValues(strapi.contentTypes, (value)=>toContentManagerModel(value));
15
15
  }
16
16
  });
17
17
  const service = ({ strapi: strapi1 })=>({
@@ -22,7 +22,7 @@ const service = ({ strapi: strapi1 })=>({
22
22
  findContentType (uid) {
23
23
  const { toContentManagerModel } = index.getService('data-mapper');
24
24
  const contentType = strapi1.contentTypes[uid];
25
- return fp.isNil(contentType) ? contentType : toContentManagerModel(contentType);
25
+ return contentType == null ? contentType : toContentManagerModel(contentType);
26
26
  },
27
27
  findDisplayedContentTypes () {
28
28
  return this.findAllContentTypes().filter(// TODO
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.js","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import { isNil, mapValues } from 'lodash/fp';\nimport { contentTypes as contentTypesUtils } from '@strapi/utils';\n\nimport type { UID, Struct, Core } from '@strapi/types';\n\nimport type { ConfigurationUpdate } from './configuration';\n\nimport { getService } from '../utils';\nimport storeUtils from './utils/store';\nimport createConfigurationService from './configuration';\n\nconst configurationService = createConfigurationService({\n storeUtils,\n prefix: 'content_types',\n getModels() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return mapValues(toContentManagerModel, strapi.contentTypes);\n },\n});\n\nconst service = ({ strapi }: { strapi: Core.Strapi }) => ({\n findAllContentTypes() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return Object.values(strapi.contentTypes).map(toContentManagerModel);\n },\n\n findContentType(uid: UID.ContentType) {\n const { toContentManagerModel } = getService('data-mapper');\n\n const contentType = strapi.contentTypes[uid];\n\n return isNil(contentType) ? contentType : toContentManagerModel(contentType);\n },\n\n findDisplayedContentTypes() {\n return this.findAllContentTypes().filter(\n // TODO\n // @ts-expect-error should be resolved from data-mapper types\n ({ isDisplayed }: { isDisplayed: boolean }) => isDisplayed === true\n );\n },\n\n findContentTypesByKind(kind: { kind: Struct.ContentTypeKind | undefined }) {\n if (!kind) {\n return this.findAllContentTypes();\n }\n\n // @ts-expect-error TODO when adding types\n return this.findAllContentTypes().filter(contentTypesUtils.isKind(kind));\n },\n\n async findConfiguration(contentType: Struct.ContentTypeSchema) {\n const configuration = await configurationService.getConfiguration(contentType.uid);\n\n return {\n uid: contentType.uid,\n ...configuration,\n };\n },\n\n async updateConfiguration(\n contentType: Struct.ContentTypeSchema,\n newConfiguration: ConfigurationUpdate\n ) {\n await configurationService.setConfiguration(contentType.uid, newConfiguration);\n\n return this.findConfiguration(contentType);\n },\n\n findComponentsConfigurations(contentType: Struct.ContentTypeSchema) {\n // delegate to componentService\n return getService('components').findComponentsConfigurations(contentType);\n },\n\n syncConfigurations() {\n return configurationService.syncConfigurations();\n },\n});\n\nexport default service;\n"],"names":["configurationService","createConfigurationService","storeUtils","prefix","getModels","toContentManagerModel","getService","mapValues","strapi","contentTypes","service","findAllContentTypes","Object","values","map","findContentType","uid","contentType","isNil","findDisplayedContentTypes","filter","isDisplayed","findContentTypesByKind","kind","contentTypesUtils","isKind","findConfiguration","configuration","getConfiguration","updateConfiguration","newConfiguration","setConfiguration","findComponentsConfigurations","syncConfigurations"],"mappings":";;;;;;;;AAWA,MAAMA,uBAAuBC,aAAAA,CAA2B;AACtDC,gBAAAA,KAAAA;IACAC,MAAAA,EAAQ,eAAA;AACRC,IAAAA,SAAAA,CAAAA,GAAAA;AACE,QAAA,MAAM,EAAEC,qBAAqB,EAAE,GAAGC,gBAAAA,CAAW,aAAA,CAAA;QAE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AAA,CAAqB4B,gBAAgB,CAACX,YAAYD,GAAG,CAAA;YAEjF,OAAO;AACLA,gBAAAA,GAAAA,EAAKC,YAAYD,GAAG;AACpB,gBAAA,GAAGW;AACL,aAAA;AACF,QAAA,CAAA;QAEA,MAAME,mBAAAA,CAAAA,CACJZ,WAAqC,EACrCa,gBAAqC,EAAA;AAErC,YAAA,MAAM9B,oBAAAA,CAAqB+B,gBAAgB,CAACd,WAAAA,CAAYD,GAAG,EAAEc,gBAAAA,CAAAA;YAE7D,OAAO,IAAI,CAACJ,iBAAiB,CAACT,WAAAA,CAAAA;AAChC,QAAA,CAAA;AAEAe,QAAAA,4BAAAA,CAAAA,CAA6Bf,WAAqC,EAAA;;YAEhE,OAAOX,gBAAAA,CAAW,YAAA,CAAA,CAAc0B,4BAA4B,CAACf,WAAAA,CAAAA;AAC/D,QAAA,CAAA;AAEAgB,QAAAA,kBAAAA,CAAAA,GAAAA;AACE,YAAA,OAAOjC,qBAAqBiC,kBAAkB,EAAA;AAChD,QAAA;KACF;;;;"}
1
+ {"version":3,"file":"content-types.js","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import { mapValues } from 'lodash';\n\nimport { contentTypes as contentTypesUtils } from '@strapi/utils';\n\nimport type { UID, Struct, Core } from '@strapi/types';\n\nimport type { ConfigurationUpdate } from './configuration';\n\nimport { getService } from '../utils';\nimport storeUtils from './utils/store';\nimport createConfigurationService from './configuration';\n\nconst configurationService = createConfigurationService({\n storeUtils,\n prefix: 'content_types',\n getModels() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return mapValues(strapi.contentTypes, (value) => toContentManagerModel(value));\n },\n});\n\nconst service = ({ strapi }: { strapi: Core.Strapi }) => ({\n findAllContentTypes() {\n const { toContentManagerModel } = getService('data-mapper');\n\n return Object.values(strapi.contentTypes).map(toContentManagerModel);\n },\n\n findContentType(uid: UID.ContentType) {\n const { toContentManagerModel } = getService('data-mapper');\n\n const contentType = strapi.contentTypes[uid];\n\n return contentType == null ? contentType : toContentManagerModel(contentType);\n },\n\n findDisplayedContentTypes() {\n return this.findAllContentTypes().filter(\n // TODO\n // @ts-expect-error should be resolved from data-mapper types\n ({ isDisplayed }: { isDisplayed: boolean }) => isDisplayed === true\n );\n },\n\n findContentTypesByKind(kind: { kind: Struct.ContentTypeKind | undefined }) {\n if (!kind) {\n return this.findAllContentTypes();\n }\n\n // @ts-expect-error TODO when adding types\n return this.findAllContentTypes().filter(contentTypesUtils.isKind(kind));\n },\n\n async findConfiguration(contentType: Struct.ContentTypeSchema) {\n const configuration = await configurationService.getConfiguration(contentType.uid);\n\n return {\n uid: contentType.uid,\n ...configuration,\n };\n },\n\n async updateConfiguration(\n contentType: Struct.ContentTypeSchema,\n newConfiguration: ConfigurationUpdate\n ) {\n await configurationService.setConfiguration(contentType.uid, newConfiguration);\n\n return this.findConfiguration(contentType);\n },\n\n findComponentsConfigurations(contentType: Struct.ContentTypeSchema) {\n // delegate to componentService\n return getService('components').findComponentsConfigurations(contentType);\n },\n\n syncConfigurations() {\n return configurationService.syncConfigurations();\n },\n});\n\nexport default service;\n"],"names":["configurationService","createConfigurationService","storeUtils","prefix","getModels","toContentManagerModel","getService","mapValues","strapi","contentTypes","value","service","findAllContentTypes","Object","values","map","findContentType","uid","contentType","findDisplayedContentTypes","filter","isDisplayed","findContentTypesByKind","kind","contentTypesUtils","isKind","findConfiguration","configuration","getConfiguration","updateConfiguration","newConfiguration","setConfiguration","findComponentsConfigurations","syncConfigurations"],"mappings":";;;;;;;;AAYA,MAAMA,uBAAuBC,aAAAA,CAA2B;AACtDC,gBAAAA,KAAAA;IACAC,MAAAA,EAAQ,eAAA;AACRC,IAAAA,SAAAA,CAAAA,GAAAA;AACE,QAAA,MAAM,EAAEC,qBAAqB,EAAE,GAAGC,gBAAAA,CAAW,aAAA,CAAA;AAE7C,QAAA,OAAOC,YAAUC,MAAAA,CAAOC,YAAY,EAAE,CAACC,QAAUL,qBAAAA,CAAsBK,KAAAA,CAAAA,CAAAA;AACzE,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