{"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,EAA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