@strapi/content-manager 5.48.0 → 5.48.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/admin/features/DocumentRBAC.js +9 -1
  2. package/dist/admin/features/DocumentRBAC.js.map +1 -1
  3. package/dist/admin/features/DocumentRBAC.mjs +9 -1
  4. package/dist/admin/features/DocumentRBAC.mjs.map +1 -1
  5. package/dist/admin/hooks/useContentTypeSchema.js +37 -17
  6. package/dist/admin/hooks/useContentTypeSchema.js.map +1 -1
  7. package/dist/admin/hooks/useContentTypeSchema.mjs +37 -17
  8. package/dist/admin/hooks/useContentTypeSchema.mjs.map +1 -1
  9. package/dist/admin/hooks/useDocumentLayout.js +43 -4
  10. package/dist/admin/hooks/useDocumentLayout.js.map +1 -1
  11. package/dist/admin/hooks/useDocumentLayout.mjs +43 -4
  12. package/dist/admin/hooks/useDocumentLayout.mjs.map +1 -1
  13. package/dist/admin/pages/ComponentConfigurationPage.js +6 -3
  14. package/dist/admin/pages/ComponentConfigurationPage.js.map +1 -1
  15. package/dist/admin/pages/ComponentConfigurationPage.mjs +6 -3
  16. package/dist/admin/pages/ComponentConfigurationPage.mjs.map +1 -1
  17. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +5 -2
  18. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
  19. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +5 -2
  20. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
  21. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +11 -2
  22. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +11 -2
  24. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js +9 -4
  26. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
  27. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs +9 -4
  28. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
  29. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/PreviewWysiwyg.js +2 -26
  30. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/PreviewWysiwyg.js.map +1 -1
  31. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/PreviewWysiwyg.mjs +2 -26
  32. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/PreviewWysiwyg.mjs.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/utils/sanitizer.js +72 -0
  34. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/utils/sanitizer.js.map +1 -0
  35. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/utils/sanitizer.mjs +70 -0
  36. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/utils/sanitizer.mjs.map +1 -0
  37. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js +4 -8
  38. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js.map +1 -1
  39. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs +5 -9
  40. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs.map +1 -1
  41. package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.js +6 -10
  42. package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.js.map +1 -1
  43. package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.mjs +6 -10
  44. package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.mjs.map +1 -1
  45. package/dist/admin/pages/ListView/components/Filters.js +7 -9
  46. package/dist/admin/pages/ListView/components/Filters.js.map +1 -1
  47. package/dist/admin/pages/ListView/components/Filters.mjs +7 -9
  48. package/dist/admin/pages/ListView/components/Filters.mjs.map +1 -1
  49. package/dist/admin/pages/ListView/components/TableCells/Media.js +5 -4
  50. package/dist/admin/pages/ListView/components/TableCells/Media.js.map +1 -1
  51. package/dist/admin/pages/ListView/components/TableCells/Media.mjs +5 -4
  52. package/dist/admin/pages/ListView/components/TableCells/Media.mjs.map +1 -1
  53. package/dist/admin/pages/formatComponentConfigurationEditLayout.js +15 -9
  54. package/dist/admin/pages/formatComponentConfigurationEditLayout.js.map +1 -1
  55. package/dist/admin/pages/formatComponentConfigurationEditLayout.mjs +15 -9
  56. package/dist/admin/pages/formatComponentConfigurationEditLayout.mjs.map +1 -1
  57. package/dist/admin/services/components.js +3 -2
  58. package/dist/admin/services/components.js.map +1 -1
  59. package/dist/admin/services/components.mjs +3 -2
  60. package/dist/admin/services/components.mjs.map +1 -1
  61. package/dist/admin/services/contentTypes.js +4 -3
  62. package/dist/admin/services/contentTypes.js.map +1 -1
  63. package/dist/admin/services/contentTypes.mjs +4 -3
  64. package/dist/admin/services/contentTypes.mjs.map +1 -1
  65. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +1 -1
  66. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/sanitizer.d.ts +2 -0
  67. package/dist/admin/src/pages/ListConfiguration/components/SortDisplayedFields.d.ts +2 -2
  68. package/dist/admin/src/pages/ListView/components/TableCells/Media.d.ts +2 -2
  69. package/dist/admin/src/pages/formatComponentConfigurationEditLayout.d.ts +3 -1
  70. package/dist/admin/src/utils/layouts/normalizeContentManagerLayout.d.ts +24 -0
  71. package/dist/admin/translations/en.json.js +1 -0
  72. package/dist/admin/translations/en.json.js.map +1 -1
  73. package/dist/admin/translations/en.json.mjs +1 -0
  74. package/dist/admin/translations/en.json.mjs.map +1 -1
  75. package/dist/admin/utils/attributes.js +17 -2
  76. package/dist/admin/utils/attributes.js.map +1 -1
  77. package/dist/admin/utils/attributes.mjs +17 -2
  78. package/dist/admin/utils/attributes.mjs.map +1 -1
  79. package/dist/admin/utils/layouts/normalizeContentManagerLayout.js +329 -0
  80. package/dist/admin/utils/layouts/normalizeContentManagerLayout.js.map +1 -0
  81. package/dist/admin/utils/layouts/normalizeContentManagerLayout.mjs +321 -0
  82. package/dist/admin/utils/layouts/normalizeContentManagerLayout.mjs.map +1 -0
  83. package/dist/server/controllers/collection-types.js +7 -2
  84. package/dist/server/controllers/collection-types.js.map +1 -1
  85. package/dist/server/controllers/collection-types.mjs +7 -2
  86. package/dist/server/controllers/collection-types.mjs.map +1 -1
  87. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  88. package/package.json +7 -7
@@ -1,3 +1,4 @@
1
+ import { normalizeContentTypeConfigurationUpdateResponse, normalizeContentTypeSettingsResponse, normalizeContentTypeConfigurationResponse } from '../utils/layouts/normalizeContentManagerLayout.mjs';
1
2
  import { contentManagerApi } from './api.mjs';
2
3
 
3
4
  const contentTypesApi = contentManagerApi.injectEndpoints({
@@ -7,7 +8,7 @@ const contentTypesApi = contentManagerApi.injectEndpoints({
7
8
  url: `/content-manager/content-types/${uid}/configuration`,
8
9
  method: 'GET'
9
10
  }),
10
- transformResponse: (response)=>response.data,
11
+ transformResponse: (response, _meta, uid)=>normalizeContentTypeConfigurationResponse(response.data, uid),
11
12
  providesTags: (_result, _error, uid)=>[
12
13
  {
13
14
  type: 'ContentTypesConfiguration',
@@ -21,7 +22,7 @@ const contentTypesApi = contentManagerApi.injectEndpoints({
21
22
  }),
22
23
  getAllContentTypeSettings: builder.query({
23
24
  query: ()=>'/content-manager/content-types-settings',
24
- transformResponse: (response)=>response.data,
25
+ transformResponse: (response)=>normalizeContentTypeSettingsResponse(response.data),
25
26
  providesTags: [
26
27
  {
27
28
  type: 'ContentTypeSettings',
@@ -35,7 +36,7 @@ const contentTypesApi = contentManagerApi.injectEndpoints({
35
36
  method: 'PUT',
36
37
  data: body
37
38
  }),
38
- transformResponse: (response)=>response.data,
39
+ transformResponse: (response)=>normalizeContentTypeConfigurationUpdateResponse(response.data),
39
40
  invalidatesTags: (_result, _error, { uid })=>[
40
41
  {
41
42
  type: 'ContentTypesConfiguration',
@@ -1 +1 @@
1
- {"version":3,"file":"contentTypes.mjs","sources":["../../../admin/src/services/contentTypes.ts"],"sourcesContent":["import {\n FindContentTypeConfiguration,\n UpdateContentTypeConfiguration,\n FindContentTypesSettings,\n} from '../../../shared/contracts/content-types';\n\nimport { contentManagerApi } from './api';\n\nconst contentTypesApi = contentManagerApi.injectEndpoints({\n endpoints: (builder) => ({\n getContentTypeConfiguration: builder.query<\n FindContentTypeConfiguration.Response['data'],\n string\n >({\n query: (uid) => ({\n url: `/content-manager/content-types/${uid}/configuration`,\n method: 'GET',\n }),\n transformResponse: (response: FindContentTypeConfiguration.Response) => response.data,\n providesTags: (_result, _error, uid) => [\n { type: 'ContentTypesConfiguration', id: uid },\n { type: 'ContentTypeSettings', id: 'LIST' },\n ],\n }),\n getAllContentTypeSettings: builder.query<FindContentTypesSettings.Response['data'], void>({\n query: () => '/content-manager/content-types-settings',\n transformResponse: (response: FindContentTypesSettings.Response) => response.data,\n providesTags: [{ type: 'ContentTypeSettings', id: 'LIST' }],\n }),\n updateContentTypeConfiguration: builder.mutation<\n UpdateContentTypeConfiguration.Response['data'],\n UpdateContentTypeConfiguration.Request['body'] & {\n uid: string;\n }\n >({\n query: ({ uid, ...body }) => ({\n url: `/content-manager/content-types/${uid}/configuration`,\n method: 'PUT',\n data: body,\n }),\n transformResponse: (response: UpdateContentTypeConfiguration.Response) => response.data,\n invalidatesTags: (_result, _error, { uid }) => [\n { type: 'ContentTypesConfiguration', id: uid },\n { type: 'ContentTypeSettings', id: 'LIST' },\n // Is this necessary?\n { type: 'InitialData' },\n ],\n }),\n }),\n});\n\nconst {\n useGetContentTypeConfigurationQuery,\n useGetAllContentTypeSettingsQuery,\n useUpdateContentTypeConfigurationMutation,\n} = contentTypesApi;\n\nexport {\n useGetContentTypeConfigurationQuery,\n useGetAllContentTypeSettingsQuery,\n useUpdateContentTypeConfigurationMutation,\n};\n"],"names":["contentTypesApi","contentManagerApi","injectEndpoints","endpoints","builder","getContentTypeConfiguration","query","uid","url","method","transformResponse","response","data","providesTags","_result","_error","type","id","getAllContentTypeSettings","updateContentTypeConfiguration","mutation","body","invalidatesTags","useGetContentTypeConfigurationQuery","useGetAllContentTypeSettingsQuery","useUpdateContentTypeConfigurationMutation"],"mappings":";;AAQA,MAAMA,eAAAA,GAAkBC,iBAAAA,CAAkBC,eAAe,CAAC;IACxDC,SAAAA,EAAW,CAACC,WAAa;YACvBC,2BAAAA,EAA6BD,OAAAA,CAAQE,KAAK,CAGxC;gBACAA,KAAAA,EAAO,CAACC,OAAS;AACfC,wBAAAA,GAAAA,EAAK,CAAC,+BAA+B,EAAED,GAAAA,CAAI,cAAc,CAAC;wBAC1DE,MAAAA,EAAQ;qBACV,CAAA;gBACAC,iBAAAA,EAAmB,CAACC,QAAAA,GAAoDA,QAAAA,CAASC,IAAI;gBACrFC,YAAAA,EAAc,CAACC,OAAAA,EAASC,MAAAA,EAAQR,GAAAA,GAAQ;AACtC,wBAAA;4BAAES,IAAAA,EAAM,2BAAA;4BAA6BC,EAAAA,EAAIV;AAAI,yBAAA;AAC7C,wBAAA;4BAAES,IAAAA,EAAM,qBAAA;4BAAuBC,EAAAA,EAAI;AAAO;AAC3C;AACH,aAAA,CAAA;YACAC,yBAAAA,EAA2Bd,OAAAA,CAAQE,KAAK,CAAkD;AACxFA,gBAAAA,KAAAA,EAAO,IAAM,yCAAA;gBACbI,iBAAAA,EAAmB,CAACC,QAAAA,GAAgDA,QAAAA,CAASC,IAAI;gBACjFC,YAAAA,EAAc;AAAC,oBAAA;wBAAEG,IAAAA,EAAM,qBAAA;wBAAuBC,EAAAA,EAAI;AAAO;AAAE;AAC7D,aAAA,CAAA;YACAE,8BAAAA,EAAgCf,OAAAA,CAAQgB,QAAQ,CAK9C;AACAd,gBAAAA,KAAAA,EAAO,CAAC,EAAEC,GAAG,EAAE,GAAGc,IAAAA,EAAM,IAAM;AAC5Bb,wBAAAA,GAAAA,EAAK,CAAC,+BAA+B,EAAED,GAAAA,CAAI,cAAc,CAAC;wBAC1DE,MAAAA,EAAQ,KAAA;wBACRG,IAAAA,EAAMS;qBACR,CAAA;gBACAX,iBAAAA,EAAmB,CAACC,QAAAA,GAAsDA,QAAAA,CAASC,IAAI;AACvFU,gBAAAA,eAAAA,EAAiB,CAACR,OAAAA,EAASC,MAAAA,EAAQ,EAAER,GAAG,EAAE,GAAK;AAC7C,wBAAA;4BAAES,IAAAA,EAAM,2BAAA;4BAA6BC,EAAAA,EAAIV;AAAI,yBAAA;AAC7C,wBAAA;4BAAES,IAAAA,EAAM,qBAAA;4BAAuBC,EAAAA,EAAI;AAAO,yBAAA;;AAE1C,wBAAA;4BAAED,IAAAA,EAAM;AAAc;AACvB;AACH,aAAA;SACF;AACF,CAAA,CAAA;AAEA,MAAM,EACJO,mCAAmC,EACnCC,iCAAiC,EACjCC,yCAAyC,EAC1C,GAAGzB;;;;"}
1
+ {"version":3,"file":"contentTypes.mjs","sources":["../../../admin/src/services/contentTypes.ts"],"sourcesContent":["import {\n FindContentTypeConfiguration,\n UpdateContentTypeConfiguration,\n FindContentTypesSettings,\n} from '../../../shared/contracts/content-types';\nimport {\n normalizeContentTypeConfigurationResponse,\n normalizeContentTypeConfigurationUpdateResponse,\n normalizeContentTypeSettingsResponse,\n} from '../utils/layouts/normalizeContentManagerLayout';\n\nimport { contentManagerApi } from './api';\n\nconst contentTypesApi = contentManagerApi.injectEndpoints({\n endpoints: (builder) => ({\n getContentTypeConfiguration: builder.query<\n FindContentTypeConfiguration.Response['data'],\n string\n >({\n query: (uid) => ({\n url: `/content-manager/content-types/${uid}/configuration`,\n method: 'GET',\n }),\n transformResponse: (response: FindContentTypeConfiguration.Response, _meta, uid) =>\n normalizeContentTypeConfigurationResponse(response.data, uid),\n providesTags: (_result, _error, uid) => [\n { type: 'ContentTypesConfiguration', id: uid },\n { type: 'ContentTypeSettings', id: 'LIST' },\n ],\n }),\n getAllContentTypeSettings: builder.query<FindContentTypesSettings.Response['data'], void>({\n query: () => '/content-manager/content-types-settings',\n transformResponse: (response: FindContentTypesSettings.Response) =>\n normalizeContentTypeSettingsResponse(response.data),\n providesTags: [{ type: 'ContentTypeSettings', id: 'LIST' }],\n }),\n updateContentTypeConfiguration: builder.mutation<\n UpdateContentTypeConfiguration.Response['data'],\n UpdateContentTypeConfiguration.Request['body'] & {\n uid: string;\n }\n >({\n query: ({ uid, ...body }) => ({\n url: `/content-manager/content-types/${uid}/configuration`,\n method: 'PUT',\n data: body,\n }),\n transformResponse: (response: UpdateContentTypeConfiguration.Response) =>\n normalizeContentTypeConfigurationUpdateResponse(response.data),\n invalidatesTags: (_result, _error, { uid }) => [\n { type: 'ContentTypesConfiguration', id: uid },\n { type: 'ContentTypeSettings', id: 'LIST' },\n // Is this necessary?\n { type: 'InitialData' },\n ],\n }),\n }),\n});\n\nconst {\n useGetContentTypeConfigurationQuery,\n useGetAllContentTypeSettingsQuery,\n useUpdateContentTypeConfigurationMutation,\n} = contentTypesApi;\n\nexport {\n useGetContentTypeConfigurationQuery,\n useGetAllContentTypeSettingsQuery,\n useUpdateContentTypeConfigurationMutation,\n};\n"],"names":["contentTypesApi","contentManagerApi","injectEndpoints","endpoints","builder","getContentTypeConfiguration","query","uid","url","method","transformResponse","response","_meta","normalizeContentTypeConfigurationResponse","data","providesTags","_result","_error","type","id","getAllContentTypeSettings","normalizeContentTypeSettingsResponse","updateContentTypeConfiguration","mutation","body","normalizeContentTypeConfigurationUpdateResponse","invalidatesTags","useGetContentTypeConfigurationQuery","useGetAllContentTypeSettingsQuery","useUpdateContentTypeConfigurationMutation"],"mappings":";;;AAaA,MAAMA,eAAAA,GAAkBC,iBAAAA,CAAkBC,eAAe,CAAC;IACxDC,SAAAA,EAAW,CAACC,WAAa;YACvBC,2BAAAA,EAA6BD,OAAAA,CAAQE,KAAK,CAGxC;gBACAA,KAAAA,EAAO,CAACC,OAAS;AACfC,wBAAAA,GAAAA,EAAK,CAAC,+BAA+B,EAAED,GAAAA,CAAI,cAAc,CAAC;wBAC1DE,MAAAA,EAAQ;qBACV,CAAA;AACAC,gBAAAA,iBAAAA,EAAmB,CAACC,QAAAA,EAAiDC,KAAAA,EAAOL,MAC1EM,yCAAAA,CAA0CF,QAAAA,CAASG,IAAI,EAAEP,GAAAA,CAAAA;gBAC3DQ,YAAAA,EAAc,CAACC,OAAAA,EAASC,MAAAA,EAAQV,GAAAA,GAAQ;AACtC,wBAAA;4BAAEW,IAAAA,EAAM,2BAAA;4BAA6BC,EAAAA,EAAIZ;AAAI,yBAAA;AAC7C,wBAAA;4BAAEW,IAAAA,EAAM,qBAAA;4BAAuBC,EAAAA,EAAI;AAAO;AAC3C;AACH,aAAA,CAAA;YACAC,yBAAAA,EAA2BhB,OAAAA,CAAQE,KAAK,CAAkD;AACxFA,gBAAAA,KAAAA,EAAO,IAAM,yCAAA;AACbI,gBAAAA,iBAAAA,EAAmB,CAACC,QAAAA,GAClBU,oCAAAA,CAAqCV,QAAAA,CAASG,IAAI,CAAA;gBACpDC,YAAAA,EAAc;AAAC,oBAAA;wBAAEG,IAAAA,EAAM,qBAAA;wBAAuBC,EAAAA,EAAI;AAAO;AAAE;AAC7D,aAAA,CAAA;YACAG,8BAAAA,EAAgClB,OAAAA,CAAQmB,QAAQ,CAK9C;AACAjB,gBAAAA,KAAAA,EAAO,CAAC,EAAEC,GAAG,EAAE,GAAGiB,IAAAA,EAAM,IAAM;AAC5BhB,wBAAAA,GAAAA,EAAK,CAAC,+BAA+B,EAAED,GAAAA,CAAI,cAAc,CAAC;wBAC1DE,MAAAA,EAAQ,KAAA;wBACRK,IAAAA,EAAMU;qBACR,CAAA;AACAd,gBAAAA,iBAAAA,EAAmB,CAACC,QAAAA,GAClBc,+CAAAA,CAAgDd,QAAAA,CAASG,IAAI,CAAA;AAC/DY,gBAAAA,eAAAA,EAAiB,CAACV,OAAAA,EAASC,MAAAA,EAAQ,EAAEV,GAAG,EAAE,GAAK;AAC7C,wBAAA;4BAAEW,IAAAA,EAAM,2BAAA;4BAA6BC,EAAAA,EAAIZ;AAAI,yBAAA;AAC7C,wBAAA;4BAAEW,IAAAA,EAAM,qBAAA;4BAAuBC,EAAAA,EAAI;AAAO,yBAAA;;AAE1C,wBAAA;4BAAED,IAAAA,EAAM;AAAc;AACvB;AACH,aAAA;SACF;AACF,CAAA,CAAA;AAEA,MAAM,EACJS,mCAAmC,EACnCC,iCAAiC,EACjCC,yCAAyC,EAC1C,GAAG7B;;;;"}
@@ -3,7 +3,7 @@ import { type UseDragAndDropOptions } from '../../../../../hooks/useDragAndDrop'
3
3
  import { type InputRendererProps } from '../../InputRenderer';
4
4
  import type { ComponentPickerProps } from './ComponentPicker';
5
5
  interface DynamicComponentProps extends Pick<UseDragAndDropOptions, 'onGrabItem' | 'onDropItem' | 'onCancel'>, Pick<ComponentPickerProps, 'dynamicComponentsByCategory'> {
6
- componentUid: string;
6
+ componentUid?: string;
7
7
  disabled?: boolean;
8
8
  index: number;
9
9
  name: string;
@@ -0,0 +1,2 @@
1
+ declare const sanitize: (html: string) => string;
2
+ export { sanitize };
@@ -1,6 +1,6 @@
1
1
  import type { ListLayout } from '../../../hooks/useDocumentLayout';
2
- interface SortDisplayedFieldsProps extends Pick<ListLayout, 'layout'> {
2
+ interface SortDisplayedFieldsProps extends Pick<ListLayout, 'metadatas'> {
3
3
  }
4
- declare const SortDisplayedFields: () => import("react/jsx-runtime").JSX.Element;
4
+ declare const SortDisplayedFields: ({ metadatas }: SortDisplayedFieldsProps) => import("react/jsx-runtime").JSX.Element;
5
5
  export { SortDisplayedFields };
6
6
  export type { SortDisplayedFieldsProps };
@@ -8,8 +8,8 @@ interface MediaFile {
8
8
  url?: string;
9
9
  };
10
10
  };
11
- mime: string;
12
- name: string;
11
+ mime?: string | null;
12
+ name?: string | null;
13
13
  url: string;
14
14
  }
15
15
  interface MediaSingleProps extends MediaFile {
@@ -1,6 +1,7 @@
1
1
  import { ComponentsDictionary } from '../hooks/useContentTypeSchema';
2
2
  import { EditLayout } from '../hooks/useDocumentLayout';
3
3
  import type { Component, FindComponentConfiguration } from '../../../shared/contracts/components';
4
+ import type { Schema } from '../hooks/useDocument';
4
5
  /**
5
6
  * Formats API configuration + schemas into the shape expected by the component
6
7
  * "Configure the view" form. Matches the ListView / content-type path: nested
@@ -8,8 +9,9 @@ import type { Component, FindComponentConfiguration } from '../../../shared/cont
8
9
  * and full component schemas so `getMainField` can resolve fields inside nested
9
10
  * component attributes (see #25509).
10
11
  */
11
- declare const formatComponentConfigurationEditLayout: (data: FindComponentConfiguration.Response['data'], { schema, components }: {
12
+ declare const formatComponentConfigurationEditLayout: (data: FindComponentConfiguration.Response['data'], { schema, components, schemas, }: {
12
13
  schema?: Component;
13
14
  components: ComponentsDictionary;
15
+ schemas?: Schema[];
14
16
  }) => EditLayout;
15
17
  export { formatComponentConfigurationEditLayout };
@@ -0,0 +1,24 @@
1
+ import type { Component, FindComponentConfiguration } from '../../../../shared/contracts/components';
2
+ import type { FindContentTypeConfiguration, FindContentTypesSettings, UpdateContentTypeConfiguration } from '../../../../shared/contracts/content-types';
3
+ import type { ComponentsDictionary, Schema } from '../../hooks/useDocument';
4
+ type ContentTypeConfigurationData = FindContentTypeConfiguration.Response['data'];
5
+ type ComponentConfigurationData = FindComponentConfiguration.Response['data'];
6
+ type ComponentConfigurationResponseData = ComponentConfigurationData['component'];
7
+ type NormalizationContext = {
8
+ components: ComponentsDictionary;
9
+ schema?: Schema | Component;
10
+ schemas: Schema[];
11
+ };
12
+ type ComponentNormalizationContext = {
13
+ components: ComponentsDictionary;
14
+ schema?: Component;
15
+ schemas: Schema[];
16
+ };
17
+ declare const normalizeContentTypeConfigurationResponse: (data: unknown, uid?: string) => FindContentTypeConfiguration.Response['data'];
18
+ declare const normalizeContentTypeConfigurationUpdateResponse: (data: unknown) => UpdateContentTypeConfiguration.Response['data'];
19
+ declare const normalizeComponentConfigurationResponse: (data: unknown, uid?: string) => FindComponentConfiguration.Response['data'];
20
+ declare const normalizeComponentConfigurationUpdateResponse: (data: unknown) => ComponentConfigurationResponseData;
21
+ declare const normalizeContentTypeSettingsResponse: (data: unknown) => FindContentTypesSettings.Response['data'];
22
+ declare const normalizeContentManagerLayout: (data: ContentTypeConfigurationData, context: NormalizationContext) => ContentTypeConfigurationData;
23
+ declare const normalizeComponentConfigurationLayout: (data: ComponentConfigurationData, context: ComponentNormalizationContext) => ComponentConfigurationData;
24
+ export { normalizeContentManagerLayout, normalizeComponentConfigurationLayout, normalizeContentTypeConfigurationResponse, normalizeContentTypeConfigurationUpdateResponse, normalizeComponentConfigurationResponse, normalizeComponentConfigurationUpdateResponse, normalizeContentTypeSettingsResponse, };
@@ -47,6 +47,7 @@ var en = {
47
47
  "components.DynamicZone.move-up-label": "Move component up",
48
48
  "components.DynamicZone.pick-compo": "Pick one component",
49
49
  "components.DynamicZone.required": "Component is required",
50
+ "components.DynamicZone.unknown-component": "Unknown component",
50
51
  "components.DynamicZone.move-up": "Move up",
51
52
  "components.DynamicZone.move-down": "Move down",
52
53
  "components.EmptyAttributesBlock.button": "Go to settings page",
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -43,6 +43,7 @@ var en = {
43
43
  "components.DynamicZone.move-up-label": "Move component up",
44
44
  "components.DynamicZone.pick-compo": "Pick one component",
45
45
  "components.DynamicZone.required": "Component is required",
46
+ "components.DynamicZone.unknown-component": "Unknown component",
46
47
  "components.DynamicZone.move-up": "Move up",
47
48
  "components.DynamicZone.move-down": "Move down",
48
49
  "components.EmptyAttributesBlock.button": "Go to settings page",
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -22,10 +22,25 @@ const checkIfAttributeIsDisplayable = (attribute)=>{
22
22
  if (!mainFieldName) {
23
23
  return undefined;
24
24
  }
25
- const mainFieldType = attribute.type === 'component' ? components[attribute.component].attributes[mainFieldName].type : schemas.find((schema)=>schema.uid === attribute.targetModel)?.attributes[mainFieldName].type;
25
+ if (attribute.type === 'component') {
26
+ const mainFieldType = components[attribute.component]?.attributes?.[mainFieldName]?.type;
27
+ return {
28
+ name: mainFieldType ? mainFieldName : 'id',
29
+ type: mainFieldType ?? 'custom'
30
+ };
31
+ }
32
+ if (attribute.type === 'relation') {
33
+ const target = 'targetModel' in attribute ? attribute.targetModel : 'target' in attribute ? attribute.target : undefined;
34
+ const targetSchema = schemas.find((schema)=>schema.uid === target);
35
+ const mainFieldType = targetSchema?.attributes?.[mainFieldName]?.type;
36
+ return {
37
+ name: !targetSchema || mainFieldType ? mainFieldName : 'id',
38
+ type: mainFieldType ?? 'custom'
39
+ };
40
+ }
26
41
  return {
27
42
  name: mainFieldName,
28
- type: mainFieldType ?? 'string'
43
+ type: 'string'
29
44
  };
30
45
  };
31
46
 
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.js","sources":["../../../admin/src/utils/attributes.ts"],"sourcesContent":["import type { ComponentsDictionary, Schema } from '../hooks/useDocument';\nimport type { Schema as SchemaUtils } from '@strapi/types';\n\nconst checkIfAttributeIsDisplayable = (attribute: SchemaUtils.Attribute.AnyAttribute) => {\n const { type } = attribute;\n\n if (type === 'relation') {\n return !attribute.relation.toLowerCase().includes('morph');\n }\n\n return !['json', 'dynamiczone', 'richtext', 'password', 'blocks'].includes(type) && !!type;\n};\n\ninterface MainField {\n name: string;\n type: SchemaUtils.Attribute.Kind | 'custom';\n}\n\n/**\n * @internal\n * @description given an attribute, content-type schemas & component schemas, find the mainField name & type.\n * If the attribute does not need a `mainField` then we return undefined. If we do not find the type\n * of the field, we assume it's a string #sensible-defaults\n */\nconst getMainField = (\n attribute: SchemaUtils.Attribute.AnyAttribute,\n mainFieldName: string | undefined,\n { schemas, components }: { schemas: Schema[]; components: ComponentsDictionary }\n): MainField | undefined => {\n if (!mainFieldName) {\n return undefined;\n }\n\n const mainFieldType =\n attribute.type === 'component'\n ? components[attribute.component].attributes[mainFieldName].type\n : // @ts-expect-error `targetModel` does exist on the attribute for a relation.\n schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName]\n .type;\n\n return {\n name: mainFieldName,\n type: mainFieldType ?? 'string',\n };\n};\n\nexport { checkIfAttributeIsDisplayable, getMainField };\nexport type { MainField };\n"],"names":["checkIfAttributeIsDisplayable","attribute","type","relation","toLowerCase","includes","getMainField","mainFieldName","schemas","components","undefined","mainFieldType","component","attributes","find","schema","uid","targetModel","name"],"mappings":";;AAGA,MAAMA,gCAAgC,CAACC,SAAAA,GAAAA;IACrC,MAAM,EAAEC,IAAI,EAAE,GAAGD,SAAAA;AAEjB,IAAA,IAAIC,SAAS,UAAA,EAAY;AACvB,QAAA,OAAO,CAACD,SAAAA,CAAUE,QAAQ,CAACC,WAAW,EAAA,CAAGC,QAAQ,CAAC,OAAA,CAAA;AACpD,IAAA;AAEA,IAAA,OAAO,CAAC;AAAC,QAAA,MAAA;AAAQ,QAAA,aAAA;AAAe,QAAA,UAAA;AAAY,QAAA,UAAA;AAAY,QAAA;AAAS,KAAA,CAACA,QAAQ,CAACH,IAAAA,CAAAA,IAAS,CAAC,CAACA,IAAAA;AACxF;AAOA;;;;;IAMA,MAAMI,eAAe,CACnBL,SAAAA,EACAM,eACA,EAAEC,OAAO,EAAEC,UAAU,EAA2D,GAAA;AAEhF,IAAA,IAAI,CAACF,aAAAA,EAAe;QAClB,OAAOG,SAAAA;AACT,IAAA;AAEA,IAAA,MAAMC,aAAAA,GACJV,SAAAA,CAAUC,IAAI,KAAK,WAAA,GACfO,UAAU,CAACR,SAAAA,CAAUW,SAAS,CAAC,CAACC,UAAU,CAACN,aAAAA,CAAc,CAACL,IAAI,GAE9DM,OAAAA,CAAQM,IAAI,CAAC,CAACC,SAAWA,MAAAA,CAAOC,GAAG,KAAKf,SAAAA,CAAUgB,WAAW,CAAA,EAAGJ,UAAU,CAACN,cAAc,CACtFL,IAAAA;IAET,OAAO;QACLgB,IAAAA,EAAMX,aAAAA;AACNL,QAAAA,IAAAA,EAAMS,aAAAA,IAAiB;AACzB,KAAA;AACF;;;;;"}
1
+ {"version":3,"file":"attributes.js","sources":["../../../admin/src/utils/attributes.ts"],"sourcesContent":["import type { ComponentsDictionary, Schema } from '../hooks/useDocument';\nimport type { Schema as SchemaUtils } from '@strapi/types';\n\nconst checkIfAttributeIsDisplayable = (attribute: SchemaUtils.Attribute.AnyAttribute) => {\n const { type } = attribute;\n\n if (type === 'relation') {\n return !attribute.relation.toLowerCase().includes('morph');\n }\n\n return !['json', 'dynamiczone', 'richtext', 'password', 'blocks'].includes(type) && !!type;\n};\n\ninterface MainField {\n name: string;\n type: SchemaUtils.Attribute.Kind | 'custom';\n}\n\n/**\n * @internal\n * @description given an attribute, content-type schemas & component schemas, find the mainField name & type.\n * If the attribute does not need a `mainField` then we return undefined. If we do not find the type\n * of the field, we assume it's a string #sensible-defaults\n */\nconst getMainField = (\n attribute: SchemaUtils.Attribute.AnyAttribute,\n mainFieldName: string | undefined,\n { schemas, components }: { schemas: Schema[]; components: ComponentsDictionary }\n): MainField | undefined => {\n if (!mainFieldName) {\n return undefined;\n }\n\n if (attribute.type === 'component') {\n const mainFieldType = components[attribute.component]?.attributes?.[mainFieldName]?.type;\n\n return {\n name: mainFieldType ? mainFieldName : 'id',\n type: mainFieldType ?? 'custom',\n };\n }\n\n if (attribute.type === 'relation') {\n const target =\n 'targetModel' in attribute\n ? attribute.targetModel\n : 'target' in attribute\n ? attribute.target\n : undefined;\n const targetSchema = schemas.find((schema) => schema.uid === target);\n const mainFieldType = targetSchema?.attributes?.[mainFieldName]?.type;\n\n return {\n name: !targetSchema || mainFieldType ? mainFieldName : 'id',\n type: mainFieldType ?? 'custom',\n };\n }\n\n return {\n name: mainFieldName,\n type: 'string',\n };\n};\n\nexport { checkIfAttributeIsDisplayable, getMainField };\nexport type { MainField };\n"],"names":["checkIfAttributeIsDisplayable","attribute","type","relation","toLowerCase","includes","getMainField","mainFieldName","schemas","components","undefined","mainFieldType","component","attributes","name","target","targetModel","targetSchema","find","schema","uid"],"mappings":";;AAGA,MAAMA,gCAAgC,CAACC,SAAAA,GAAAA;IACrC,MAAM,EAAEC,IAAI,EAAE,GAAGD,SAAAA;AAEjB,IAAA,IAAIC,SAAS,UAAA,EAAY;AACvB,QAAA,OAAO,CAACD,SAAAA,CAAUE,QAAQ,CAACC,WAAW,EAAA,CAAGC,QAAQ,CAAC,OAAA,CAAA;AACpD,IAAA;AAEA,IAAA,OAAO,CAAC;AAAC,QAAA,MAAA;AAAQ,QAAA,aAAA;AAAe,QAAA,UAAA;AAAY,QAAA,UAAA;AAAY,QAAA;AAAS,KAAA,CAACA,QAAQ,CAACH,IAAAA,CAAAA,IAAS,CAAC,CAACA,IAAAA;AACxF;AAOA;;;;;IAMA,MAAMI,eAAe,CACnBL,SAAAA,EACAM,eACA,EAAEC,OAAO,EAAEC,UAAU,EAA2D,GAAA;AAEhF,IAAA,IAAI,CAACF,aAAAA,EAAe;QAClB,OAAOG,SAAAA;AACT,IAAA;IAEA,IAAIT,SAAAA,CAAUC,IAAI,KAAK,WAAA,EAAa;QAClC,MAAMS,aAAAA,GAAgBF,UAAU,CAACR,SAAAA,CAAUW,SAAS,CAAC,EAAEC,UAAAA,GAAaN,aAAAA,CAAc,EAAEL,IAAAA;QAEpF,OAAO;AACLY,YAAAA,IAAAA,EAAMH,gBAAgBJ,aAAAA,GAAgB,IAAA;AACtCL,YAAAA,IAAAA,EAAMS,aAAAA,IAAiB;AACzB,SAAA;AACF,IAAA;IAEA,IAAIV,SAAAA,CAAUC,IAAI,KAAK,UAAA,EAAY;QACjC,MAAMa,MAAAA,GACJ,aAAA,IAAiBd,SAAAA,GACbA,SAAAA,CAAUe,WAAW,GACrB,QAAA,IAAYf,SAAAA,GACVA,SAAAA,CAAUc,MAAM,GAChBL,SAAAA;QACR,MAAMO,YAAAA,GAAeT,QAAQU,IAAI,CAAC,CAACC,MAAAA,GAAWA,MAAAA,CAAOC,GAAG,KAAKL,MAAAA,CAAAA;AAC7D,QAAA,MAAMJ,aAAAA,GAAgBM,YAAAA,EAAcJ,UAAAA,GAAaN,cAAc,EAAEL,IAAAA;QAEjE,OAAO;YACLY,IAAAA,EAAM,CAACG,YAAAA,IAAgBN,aAAAA,GAAgBJ,aAAAA,GAAgB,IAAA;AACvDL,YAAAA,IAAAA,EAAMS,aAAAA,IAAiB;AACzB,SAAA;AACF,IAAA;IAEA,OAAO;QACLG,IAAAA,EAAMP,aAAAA;QACNL,IAAAA,EAAM;AACR,KAAA;AACF;;;;;"}
@@ -20,10 +20,25 @@ const checkIfAttributeIsDisplayable = (attribute)=>{
20
20
  if (!mainFieldName) {
21
21
  return undefined;
22
22
  }
23
- const mainFieldType = attribute.type === 'component' ? components[attribute.component].attributes[mainFieldName].type : schemas.find((schema)=>schema.uid === attribute.targetModel)?.attributes[mainFieldName].type;
23
+ if (attribute.type === 'component') {
24
+ const mainFieldType = components[attribute.component]?.attributes?.[mainFieldName]?.type;
25
+ return {
26
+ name: mainFieldType ? mainFieldName : 'id',
27
+ type: mainFieldType ?? 'custom'
28
+ };
29
+ }
30
+ if (attribute.type === 'relation') {
31
+ const target = 'targetModel' in attribute ? attribute.targetModel : 'target' in attribute ? attribute.target : undefined;
32
+ const targetSchema = schemas.find((schema)=>schema.uid === target);
33
+ const mainFieldType = targetSchema?.attributes?.[mainFieldName]?.type;
34
+ return {
35
+ name: !targetSchema || mainFieldType ? mainFieldName : 'id',
36
+ type: mainFieldType ?? 'custom'
37
+ };
38
+ }
24
39
  return {
25
40
  name: mainFieldName,
26
- type: mainFieldType ?? 'string'
41
+ type: 'string'
27
42
  };
28
43
  };
29
44
 
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.mjs","sources":["../../../admin/src/utils/attributes.ts"],"sourcesContent":["import type { ComponentsDictionary, Schema } from '../hooks/useDocument';\nimport type { Schema as SchemaUtils } from '@strapi/types';\n\nconst checkIfAttributeIsDisplayable = (attribute: SchemaUtils.Attribute.AnyAttribute) => {\n const { type } = attribute;\n\n if (type === 'relation') {\n return !attribute.relation.toLowerCase().includes('morph');\n }\n\n return !['json', 'dynamiczone', 'richtext', 'password', 'blocks'].includes(type) && !!type;\n};\n\ninterface MainField {\n name: string;\n type: SchemaUtils.Attribute.Kind | 'custom';\n}\n\n/**\n * @internal\n * @description given an attribute, content-type schemas & component schemas, find the mainField name & type.\n * If the attribute does not need a `mainField` then we return undefined. If we do not find the type\n * of the field, we assume it's a string #sensible-defaults\n */\nconst getMainField = (\n attribute: SchemaUtils.Attribute.AnyAttribute,\n mainFieldName: string | undefined,\n { schemas, components }: { schemas: Schema[]; components: ComponentsDictionary }\n): MainField | undefined => {\n if (!mainFieldName) {\n return undefined;\n }\n\n const mainFieldType =\n attribute.type === 'component'\n ? components[attribute.component].attributes[mainFieldName].type\n : // @ts-expect-error `targetModel` does exist on the attribute for a relation.\n schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName]\n .type;\n\n return {\n name: mainFieldName,\n type: mainFieldType ?? 'string',\n };\n};\n\nexport { checkIfAttributeIsDisplayable, getMainField };\nexport type { MainField };\n"],"names":["checkIfAttributeIsDisplayable","attribute","type","relation","toLowerCase","includes","getMainField","mainFieldName","schemas","components","undefined","mainFieldType","component","attributes","find","schema","uid","targetModel","name"],"mappings":"AAGA,MAAMA,gCAAgC,CAACC,SAAAA,GAAAA;IACrC,MAAM,EAAEC,IAAI,EAAE,GAAGD,SAAAA;AAEjB,IAAA,IAAIC,SAAS,UAAA,EAAY;AACvB,QAAA,OAAO,CAACD,SAAAA,CAAUE,QAAQ,CAACC,WAAW,EAAA,CAAGC,QAAQ,CAAC,OAAA,CAAA;AACpD,IAAA;AAEA,IAAA,OAAO,CAAC;AAAC,QAAA,MAAA;AAAQ,QAAA,aAAA;AAAe,QAAA,UAAA;AAAY,QAAA,UAAA;AAAY,QAAA;AAAS,KAAA,CAACA,QAAQ,CAACH,IAAAA,CAAAA,IAAS,CAAC,CAACA,IAAAA;AACxF;AAOA;;;;;IAMA,MAAMI,eAAe,CACnBL,SAAAA,EACAM,eACA,EAAEC,OAAO,EAAEC,UAAU,EAA2D,GAAA;AAEhF,IAAA,IAAI,CAACF,aAAAA,EAAe;QAClB,OAAOG,SAAAA;AACT,IAAA;AAEA,IAAA,MAAMC,aAAAA,GACJV,SAAAA,CAAUC,IAAI,KAAK,WAAA,GACfO,UAAU,CAACR,SAAAA,CAAUW,SAAS,CAAC,CAACC,UAAU,CAACN,aAAAA,CAAc,CAACL,IAAI,GAE9DM,OAAAA,CAAQM,IAAI,CAAC,CAACC,SAAWA,MAAAA,CAAOC,GAAG,KAAKf,SAAAA,CAAUgB,WAAW,CAAA,EAAGJ,UAAU,CAACN,cAAc,CACtFL,IAAAA;IAET,OAAO;QACLgB,IAAAA,EAAMX,aAAAA;AACNL,QAAAA,IAAAA,EAAMS,aAAAA,IAAiB;AACzB,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"attributes.mjs","sources":["../../../admin/src/utils/attributes.ts"],"sourcesContent":["import type { ComponentsDictionary, Schema } from '../hooks/useDocument';\nimport type { Schema as SchemaUtils } from '@strapi/types';\n\nconst checkIfAttributeIsDisplayable = (attribute: SchemaUtils.Attribute.AnyAttribute) => {\n const { type } = attribute;\n\n if (type === 'relation') {\n return !attribute.relation.toLowerCase().includes('morph');\n }\n\n return !['json', 'dynamiczone', 'richtext', 'password', 'blocks'].includes(type) && !!type;\n};\n\ninterface MainField {\n name: string;\n type: SchemaUtils.Attribute.Kind | 'custom';\n}\n\n/**\n * @internal\n * @description given an attribute, content-type schemas & component schemas, find the mainField name & type.\n * If the attribute does not need a `mainField` then we return undefined. If we do not find the type\n * of the field, we assume it's a string #sensible-defaults\n */\nconst getMainField = (\n attribute: SchemaUtils.Attribute.AnyAttribute,\n mainFieldName: string | undefined,\n { schemas, components }: { schemas: Schema[]; components: ComponentsDictionary }\n): MainField | undefined => {\n if (!mainFieldName) {\n return undefined;\n }\n\n if (attribute.type === 'component') {\n const mainFieldType = components[attribute.component]?.attributes?.[mainFieldName]?.type;\n\n return {\n name: mainFieldType ? mainFieldName : 'id',\n type: mainFieldType ?? 'custom',\n };\n }\n\n if (attribute.type === 'relation') {\n const target =\n 'targetModel' in attribute\n ? attribute.targetModel\n : 'target' in attribute\n ? attribute.target\n : undefined;\n const targetSchema = schemas.find((schema) => schema.uid === target);\n const mainFieldType = targetSchema?.attributes?.[mainFieldName]?.type;\n\n return {\n name: !targetSchema || mainFieldType ? mainFieldName : 'id',\n type: mainFieldType ?? 'custom',\n };\n }\n\n return {\n name: mainFieldName,\n type: 'string',\n };\n};\n\nexport { checkIfAttributeIsDisplayable, getMainField };\nexport type { MainField };\n"],"names":["checkIfAttributeIsDisplayable","attribute","type","relation","toLowerCase","includes","getMainField","mainFieldName","schemas","components","undefined","mainFieldType","component","attributes","name","target","targetModel","targetSchema","find","schema","uid"],"mappings":"AAGA,MAAMA,gCAAgC,CAACC,SAAAA,GAAAA;IACrC,MAAM,EAAEC,IAAI,EAAE,GAAGD,SAAAA;AAEjB,IAAA,IAAIC,SAAS,UAAA,EAAY;AACvB,QAAA,OAAO,CAACD,SAAAA,CAAUE,QAAQ,CAACC,WAAW,EAAA,CAAGC,QAAQ,CAAC,OAAA,CAAA;AACpD,IAAA;AAEA,IAAA,OAAO,CAAC;AAAC,QAAA,MAAA;AAAQ,QAAA,aAAA;AAAe,QAAA,UAAA;AAAY,QAAA,UAAA;AAAY,QAAA;AAAS,KAAA,CAACA,QAAQ,CAACH,IAAAA,CAAAA,IAAS,CAAC,CAACA,IAAAA;AACxF;AAOA;;;;;IAMA,MAAMI,eAAe,CACnBL,SAAAA,EACAM,eACA,EAAEC,OAAO,EAAEC,UAAU,EAA2D,GAAA;AAEhF,IAAA,IAAI,CAACF,aAAAA,EAAe;QAClB,OAAOG,SAAAA;AACT,IAAA;IAEA,IAAIT,SAAAA,CAAUC,IAAI,KAAK,WAAA,EAAa;QAClC,MAAMS,aAAAA,GAAgBF,UAAU,CAACR,SAAAA,CAAUW,SAAS,CAAC,EAAEC,UAAAA,GAAaN,aAAAA,CAAc,EAAEL,IAAAA;QAEpF,OAAO;AACLY,YAAAA,IAAAA,EAAMH,gBAAgBJ,aAAAA,GAAgB,IAAA;AACtCL,YAAAA,IAAAA,EAAMS,aAAAA,IAAiB;AACzB,SAAA;AACF,IAAA;IAEA,IAAIV,SAAAA,CAAUC,IAAI,KAAK,UAAA,EAAY;QACjC,MAAMa,MAAAA,GACJ,aAAA,IAAiBd,SAAAA,GACbA,SAAAA,CAAUe,WAAW,GACrB,QAAA,IAAYf,SAAAA,GACVA,SAAAA,CAAUc,MAAM,GAChBL,SAAAA;QACR,MAAMO,YAAAA,GAAeT,QAAQU,IAAI,CAAC,CAACC,MAAAA,GAAWA,MAAAA,CAAOC,GAAG,KAAKL,MAAAA,CAAAA;AAC7D,QAAA,MAAMJ,aAAAA,GAAgBM,YAAAA,EAAcJ,UAAAA,GAAaN,cAAc,EAAEL,IAAAA;QAEjE,OAAO;YACLY,IAAAA,EAAM,CAACG,YAAAA,IAAgBN,aAAAA,GAAgBJ,aAAAA,GAAgB,IAAA;AACvDL,YAAAA,IAAAA,EAAMS,aAAAA,IAAiB;AACzB,SAAA;AACF,IAAA;IAEA,OAAO;QACLG,IAAAA,EAAMP,aAAAA;QACNL,IAAAA,EAAM;AACR,KAAA;AACF;;;;"}
@@ -0,0 +1,329 @@
1
+ 'use strict';
2
+
3
+ const DEFAULT_RESPONSE_SETTINGS = {
4
+ bulkable: true,
5
+ filterable: true,
6
+ searchable: true,
7
+ pageSize: 10,
8
+ mainField: 'id',
9
+ defaultSortBy: '',
10
+ defaultSortOrder: 'ASC'
11
+ };
12
+ const isRecord = (value)=>{
13
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
14
+ };
15
+ const warnOnceInDevelopment = (()=>{
16
+ const warnings = new Set();
17
+ return (message)=>{
18
+ if (process.env.NODE_ENV !== 'development' || warnings.has(message)) {
19
+ return;
20
+ }
21
+ warnings.add(message);
22
+ console.warn(`[Content Manager] ${message}`);
23
+ };
24
+ })();
25
+ const normalizeResponseSettings = (settings, path)=>{
26
+ if (!isRecord(settings)) {
27
+ warnOnceInDevelopment(`Received malformed settings at "${path}". Falling back to defaults.`);
28
+ }
29
+ return {
30
+ ...DEFAULT_RESPONSE_SETTINGS,
31
+ ...isRecord(settings) ? settings : {}
32
+ };
33
+ };
34
+ const normalizeResponseMetadatas = (metadatas, path)=>{
35
+ if (!isRecord(metadatas)) {
36
+ warnOnceInDevelopment(`Received malformed metadatas at "${path}". Falling back to empty.`);
37
+ return {};
38
+ }
39
+ return Object.entries(metadatas).reduce((acc, [name, metadata])=>{
40
+ const metadataRecord = isRecord(metadata) ? metadata : {};
41
+ if (!isRecord(metadata)) {
42
+ warnOnceInDevelopment(`Received malformed metadata for "${path}.${name}". Repairing entry.`);
43
+ }
44
+ if (!isRecord(metadataRecord.edit)) {
45
+ warnOnceInDevelopment(`Received malformed edit metadata for "${path}.${name}". Falling back to empty.`);
46
+ }
47
+ if (!isRecord(metadataRecord.list)) {
48
+ warnOnceInDevelopment(`Received malformed list metadata for "${path}.${name}". Falling back to empty.`);
49
+ }
50
+ acc[name] = {
51
+ edit: isRecord(metadataRecord.edit) ? metadataRecord.edit : {},
52
+ list: isRecord(metadataRecord.list) ? metadataRecord.list : {}
53
+ };
54
+ return acc;
55
+ }, {});
56
+ };
57
+ const normalizeResponseLayouts = (layouts, path)=>{
58
+ if (!isRecord(layouts)) {
59
+ warnOnceInDevelopment(`Received malformed layouts at "${path}". Falling back to empty.`);
60
+ return {
61
+ edit: [],
62
+ list: []
63
+ };
64
+ }
65
+ if (!Array.isArray(layouts.edit)) {
66
+ warnOnceInDevelopment(`Received malformed edit layout at "${path}". Falling back to empty.`);
67
+ }
68
+ if (!Array.isArray(layouts.list)) {
69
+ warnOnceInDevelopment(`Received malformed list layout at "${path}". Falling back to empty.`);
70
+ }
71
+ return {
72
+ edit: Array.isArray(layouts.edit) ? layouts.edit.map((row, rowIndex)=>{
73
+ if (!Array.isArray(row)) {
74
+ warnOnceInDevelopment(`Dropped malformed edit layout row "${path}.edit.${rowIndex}".`);
75
+ return [];
76
+ }
77
+ return row.filter((field, fieldIndex)=>{
78
+ const isValidField = isRecord(field) && typeof field.name === 'string' && typeof field.size === 'number';
79
+ if (!isValidField) {
80
+ warnOnceInDevelopment(`Dropped malformed edit layout field "${path}.edit.${rowIndex}.${fieldIndex}".`);
81
+ }
82
+ return isValidField;
83
+ });
84
+ }) : [],
85
+ list: Array.isArray(layouts.list) ? layouts.list.filter((field, index)=>{
86
+ const isValidField = typeof field === 'string';
87
+ if (!isValidField) {
88
+ warnOnceInDevelopment(`Dropped malformed list layout field "${path}.list.${index}".`);
89
+ }
90
+ return isValidField;
91
+ }) : []
92
+ };
93
+ };
94
+ const normalizeConfigurationResponse = (configuration, uid, path = uid ?? 'configuration')=>{
95
+ if (!isRecord(configuration)) {
96
+ warnOnceInDevelopment(`Received malformed configuration at "${path}". Repairing entry.`);
97
+ }
98
+ const configurationRecord = isRecord(configuration) ? configuration : {};
99
+ return {
100
+ ...configurationRecord,
101
+ ...uid ? {
102
+ uid
103
+ } : {},
104
+ settings: normalizeResponseSettings(configurationRecord.settings, `${path}.settings`),
105
+ metadatas: normalizeResponseMetadatas(configurationRecord.metadatas, `${path}.metadatas`),
106
+ layouts: normalizeResponseLayouts(configurationRecord.layouts, `${path}.layouts`)
107
+ };
108
+ };
109
+ const normalizeComponentsRecord = (components)=>{
110
+ if (!isRecord(components)) {
111
+ warnOnceInDevelopment('Received malformed component configuration record. Falling back to empty.');
112
+ return {};
113
+ }
114
+ return Object.entries(components).reduce((acc, [uid, configuration])=>{
115
+ acc[uid] = normalizeConfigurationResponse(configuration, uid, `components.${uid}`);
116
+ return acc;
117
+ }, {});
118
+ };
119
+ const normalizeContentTypeConfigurationResponse = (data, uid)=>{
120
+ if (!isRecord(data)) {
121
+ warnOnceInDevelopment('Received malformed content-type configuration response. Repairing data.');
122
+ }
123
+ const dataRecord = isRecord(data) ? data : {};
124
+ return {
125
+ contentType: normalizeConfigurationResponse(dataRecord.contentType, uid, 'contentType'),
126
+ components: normalizeComponentsRecord(dataRecord.components)
127
+ };
128
+ };
129
+ const normalizeContentTypeConfigurationUpdateResponse = (data)=>{
130
+ if (!isRecord(data)) {
131
+ warnOnceInDevelopment('Received malformed content-type configuration update response. Repairing data.');
132
+ }
133
+ const dataRecord = isRecord(data) ? data : {};
134
+ return {
135
+ contentType: normalizeConfigurationResponse(dataRecord.contentType, undefined, 'contentType'),
136
+ components: normalizeComponentsRecord(dataRecord.components)
137
+ };
138
+ };
139
+ const normalizeComponentConfigurationResponse = (data, uid)=>{
140
+ if (!isRecord(data)) {
141
+ warnOnceInDevelopment('Received malformed component configuration response. Repairing data.');
142
+ }
143
+ const dataRecord = isRecord(data) ? data : {};
144
+ return {
145
+ component: normalizeConfigurationResponse(dataRecord.component, uid, 'component'),
146
+ components: normalizeComponentsRecord(dataRecord.components)
147
+ };
148
+ };
149
+ const normalizeComponentConfigurationUpdateResponse = (data)=>{
150
+ return normalizeConfigurationResponse(data, undefined, 'component');
151
+ };
152
+ const normalizeContentTypeSettingsResponse = (data)=>{
153
+ if (!Array.isArray(data)) {
154
+ warnOnceInDevelopment('Received malformed content-type settings response. Falling back to empty.');
155
+ return [];
156
+ }
157
+ return data.filter((entry, index)=>{
158
+ const isValidEntry = isRecord(entry);
159
+ if (!isValidEntry) {
160
+ warnOnceInDevelopment(`Dropped malformed content-type settings entry "${index}".`);
161
+ }
162
+ return isValidEntry;
163
+ }).filter((entry)=>{
164
+ const hasUid = typeof entry.uid === 'string';
165
+ if (!hasUid) {
166
+ warnOnceInDevelopment('Dropped content-type settings entry without a uid.');
167
+ }
168
+ return hasUid;
169
+ }).map((entry)=>({
170
+ uid: entry.uid,
171
+ settings: normalizeResponseSettings(entry.settings, `contentTypeSettings.${entry.uid}`)
172
+ }));
173
+ };
174
+ const hasAttribute = (attributes, name)=>{
175
+ return Boolean(name && attributes?.[name]);
176
+ };
177
+ const getTargetAttributes = (attribute, { components, schemas })=>{
178
+ if (attribute.type === 'component') {
179
+ return components[attribute.component]?.attributes;
180
+ }
181
+ if (attribute.type === 'relation') {
182
+ const target = 'targetModel' in attribute ? attribute.targetModel : 'target' in attribute ? attribute.target : undefined;
183
+ return schemas.find((schema)=>schema.uid === target)?.attributes;
184
+ }
185
+ return undefined;
186
+ };
187
+ const hasTargetSchema = (attribute, { schemas })=>{
188
+ if (attribute.type !== 'relation') {
189
+ return true;
190
+ }
191
+ const target = 'targetModel' in attribute ? attribute.targetModel : 'target' in attribute ? attribute.target : undefined;
192
+ return schemas.some((schema)=>schema.uid === target);
193
+ };
194
+ const normalizeMainField = (attribute, mainField, context, path)=>{
195
+ if (!mainField) {
196
+ return mainField;
197
+ }
198
+ const targetAttributes = getTargetAttributes(attribute, context);
199
+ if (!targetAttributes) {
200
+ if (attribute.type === 'relation' && !hasTargetSchema(attribute, context)) {
201
+ return mainField;
202
+ }
203
+ if (attribute.type !== 'component' && attribute.type !== 'relation') {
204
+ return mainField;
205
+ }
206
+ warnOnceInDevelopment(`Reset invalid mainField "${mainField}" at "${path}" to "id".`);
207
+ return 'id';
208
+ }
209
+ if (hasAttribute(targetAttributes, mainField)) {
210
+ return mainField;
211
+ }
212
+ warnOnceInDevelopment(`Reset invalid mainField "${mainField}" at "${path}" to "id".`);
213
+ return 'id';
214
+ };
215
+ const normalizeSettings = (settings, attributes, path)=>{
216
+ if (!settings.mainField || hasAttribute(attributes, settings.mainField) || settings.mainField === 'id') {
217
+ return settings;
218
+ }
219
+ warnOnceInDevelopment(`Reset invalid mainField "${settings.mainField}" at "${path}" to "id".`);
220
+ return {
221
+ ...settings,
222
+ mainField: 'id'
223
+ };
224
+ };
225
+ const hasResolvableComponent = (attribute, context)=>{
226
+ if (!attribute || !('component' in attribute) || typeof attribute.component !== 'string') {
227
+ return true;
228
+ }
229
+ return Boolean(context.components[attribute.component]);
230
+ };
231
+ const normalizeMetadatas = (metadatas, attributes, context, path)=>{
232
+ return Object.entries(metadatas).reduce((acc, [name, metadata])=>{
233
+ const attribute = attributes?.[name];
234
+ if (!attribute) {
235
+ warnOnceInDevelopment(`Dropped metadata for unknown field "${path}.metadatas.${name}".`);
236
+ return acc;
237
+ }
238
+ if (!hasResolvableComponent(attribute, context)) {
239
+ warnOnceInDevelopment(`Dropped metadata for field "${path}.metadatas.${name}" because its component schema is unavailable.`);
240
+ return acc;
241
+ }
242
+ acc[name] = {
243
+ edit: {
244
+ ...metadata.edit,
245
+ // `mainField` is present at runtime for component/relation edit metadata.
246
+ ...'mainField' in metadata.edit ? {
247
+ mainField: normalizeMainField(attribute, metadata.edit.mainField, context, `${path}.metadatas.${name}.edit.mainField`)
248
+ } : {}
249
+ },
250
+ list: {
251
+ ...metadata.list,
252
+ mainField: normalizeMainField(attribute, metadata.list.mainField, context, `${path}.metadatas.${name}.list.mainField`)
253
+ }
254
+ };
255
+ return acc;
256
+ }, {});
257
+ };
258
+ const normalizeLayouts = (layouts, attributes, metadatas, context, path)=>{
259
+ const hasRenderableField = (name)=>{
260
+ const attribute = attributes?.[name];
261
+ return Boolean(attribute && metadatas[name] && hasResolvableComponent(attribute, context));
262
+ };
263
+ return {
264
+ edit: (layouts.edit ?? []).map((row, rowIndex)=>row.filter((field)=>{
265
+ const isRenderable = hasRenderableField(field.name);
266
+ if (!isRenderable) {
267
+ warnOnceInDevelopment(`Dropped non-renderable edit layout field "${path}.layouts.edit.${rowIndex}.${field.name}".`);
268
+ }
269
+ return isRenderable;
270
+ })).filter((row)=>row.length > 0),
271
+ list: (layouts.list ?? []).filter((name, index)=>{
272
+ const isRenderable = hasRenderableField(name);
273
+ if (!isRenderable) {
274
+ warnOnceInDevelopment(`Dropped non-renderable list layout field "${path}.layouts.list.${index}.${name}".`);
275
+ }
276
+ return isRenderable;
277
+ })
278
+ };
279
+ };
280
+ const normalizeConfiguration = (configuration, attributes, context)=>{
281
+ const path = configuration.uid ?? 'configuration';
282
+ const metadatas = normalizeMetadatas(configuration.metadatas, attributes, context, path);
283
+ const layouts = normalizeLayouts(configuration.layouts, attributes, metadatas, context, path);
284
+ return {
285
+ ...configuration,
286
+ settings: normalizeSettings(configuration.settings, attributes, `${path}.settings.mainField`),
287
+ metadatas,
288
+ layouts
289
+ };
290
+ };
291
+ const normalizeComponents = (componentConfigurations, context)=>{
292
+ return Object.entries(componentConfigurations).reduce((acc, [uid, configuration])=>{
293
+ const componentSchema = context.components[uid];
294
+ if (!componentSchema) {
295
+ return acc;
296
+ }
297
+ acc[uid] = normalizeConfiguration(configuration, componentSchema.attributes, context);
298
+ return acc;
299
+ }, {});
300
+ };
301
+ const normalizeContentManagerLayout = (data, context)=>{
302
+ const normalizedComponents = normalizeComponents(data.components, context);
303
+ return {
304
+ contentType: normalizeConfiguration(data.contentType, context.schema?.attributes, context),
305
+ components: normalizedComponents
306
+ };
307
+ };
308
+ const normalizeComponentConfigurationLayout = (data, context)=>{
309
+ const normalizedComponents = normalizeComponents(data.components, {
310
+ components: context.components,
311
+ schemas: context.schemas
312
+ });
313
+ return {
314
+ component: normalizeConfiguration(data.component, context.schema?.attributes, {
315
+ components: context.components,
316
+ schemas: context.schemas
317
+ }),
318
+ components: normalizedComponents
319
+ };
320
+ };
321
+
322
+ exports.normalizeComponentConfigurationLayout = normalizeComponentConfigurationLayout;
323
+ exports.normalizeComponentConfigurationResponse = normalizeComponentConfigurationResponse;
324
+ exports.normalizeComponentConfigurationUpdateResponse = normalizeComponentConfigurationUpdateResponse;
325
+ exports.normalizeContentManagerLayout = normalizeContentManagerLayout;
326
+ exports.normalizeContentTypeConfigurationResponse = normalizeContentTypeConfigurationResponse;
327
+ exports.normalizeContentTypeConfigurationUpdateResponse = normalizeContentTypeConfigurationUpdateResponse;
328
+ exports.normalizeContentTypeSettingsResponse = normalizeContentTypeSettingsResponse;
329
+ //# sourceMappingURL=normalizeContentManagerLayout.js.map