node_modules ignore

This commit is contained in:
oier committed 2025-05-08 23:43:47 +02:00
1 parent e19d52f172
commit 4574544c9f
65041 files changed
+10593536

No files matched your search

@@ -0,0 +1,464 @@
'use strict';
var strapiAdmin = require('@strapi/admin/strapi-admin');
// TODO: move this into the admin code & expose an improved version of enhanceEndpoints or a new function
const extendInvalidatesTags = (endpoint, extraTags)=>{
if (!endpoint) {
return;
}
const originalInvalidatesTags = endpoint.invalidatesTags;
const newInvalidatesTags = (result, err, args, meta)=>{
const originalTags = typeof originalInvalidatesTags === 'function' ? originalInvalidatesTags(result, err, args, meta) : originalInvalidatesTags;
return [
...originalTags ?? [],
...extraTags
];
};
Object.assign(endpoint, {
invalidatesTags: newInvalidatesTags
});
};
const releaseApi = strapiAdmin.adminApi.enhanceEndpoints({
addTagTypes: [
'Release',
'ReleaseAction',
'EntriesInRelease',
'ReleaseSettings',
'Document'
],
endpoints: {
updateDocument (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
deleteDocument (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
deleteManyDocuments (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
discardDocument (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
createWorkflow (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
updateWorkflow (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
deleteWorkflow (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
}
}
}).injectEndpoints({
endpoints: (build)=>{
return {
getReleasesForEntry: build.query({
query (params) {
return {
url: '/content-releases/getByDocumentAttached',
method: 'GET',
config: {
params
}
};
},
providesTags: (result)=>result ? [
...result.data.map(({ id })=>({
type: 'Release',
id
})),
{
type: 'Release',
id: 'LIST'
}
] : []
}),
getReleases: build.query({
query ({ page, pageSize, filters } = {
page: 1,
pageSize: 16,
filters: {
releasedAt: {
$notNull: false
}
}
}) {
return {
url: '/content-releases',
method: 'GET',
config: {
params: {
page: page || 1,
pageSize: pageSize || 16,
filters: filters || {
releasedAt: {
$notNull: false
}
}
}
}
};
},
transformResponse (response, meta, arg) {
const releasedAtValue = arg?.filters?.releasedAt?.$notNull;
const isActiveDoneTab = releasedAtValue === 'true';
const newResponse = {
...response,
meta: {
...response.meta,
activeTab: isActiveDoneTab ? 'done' : 'pending'
}
};
return newResponse;
},
providesTags: (result)=>result ? [
...result.data.map(({ id })=>({
type: 'Release',
id
})),
{
type: 'Release',
id: 'LIST'
}
] : [
{
type: 'Release',
id: 'LIST'
}
]
}),
getRelease: build.query({
query ({ id }) {
return {
url: `/content-releases/${id}`,
method: 'GET'
};
},
providesTags: (result, error, arg)=>[
{
type: 'Release',
id: 'LIST'
},
{
type: 'Release',
id: arg.id
}
]
}),
getReleaseActions: build.query({
query ({ releaseId, ...params }) {
return {
url: `/content-releases/${releaseId}/actions`,
method: 'GET',
config: {
params
}
};
},
providesTags: [
{
type: 'ReleaseAction',
id: 'LIST'
}
]
}),
createRelease: build.mutation({
query (data) {
return {
url: '/content-releases',
method: 'POST',
data
};
},
invalidatesTags: [
{
type: 'Release',
id: 'LIST'
}
]
}),
updateRelease: build.mutation({
query ({ id, ...data }) {
return {
url: `/content-releases/${id}`,
method: 'PUT',
data
};
},
invalidatesTags: (result, error, arg)=>[
{
type: 'Release',
id: arg.id
}
]
}),
createReleaseAction: build.mutation({
query ({ body, params }) {
return {
url: `/content-releases/${params.releaseId}/actions`,
method: 'POST',
data: body
};
},
invalidatesTags: [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]
}),
createManyReleaseActions: build.mutation({
query ({ body, params }) {
return {
url: `/content-releases/${params.releaseId}/actions/bulk`,
method: 'POST',
data: body
};
},
invalidatesTags: [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
},
{
type: 'EntriesInRelease'
}
]
}),
updateReleaseAction: build.mutation({
query ({ body, params }) {
return {
url: `/content-releases/${params.releaseId}/actions/${params.actionId}`,
method: 'PUT',
data: body
};
},
invalidatesTags: (res, error, arg)=>[
{
type: 'ReleaseAction',
id: 'LIST'
},
{
type: 'Release',
id: 'LIST'
},
{
type: 'Release',
id: arg.params.releaseId
}
],
async onQueryStarted ({ body, params, query, actionPath }, { dispatch, queryFulfilled }) {
// We need to mimic the same params received by the getReleaseActions query
const paramsWithoutActionId = {
releaseId: params.releaseId,
...query
};
const patchResult = dispatch(releaseApi.util.updateQueryData('getReleaseActions', paramsWithoutActionId, (draft)=>{
const [key, index] = actionPath;
const action = draft.data[key][index];
if (action) {
action.type = body.type;
}
}));
try {
await queryFulfilled;
} catch {
patchResult.undo();
}
}
}),
deleteReleaseAction: build.mutation({
query ({ params }) {
return {
url: `/content-releases/${params.releaseId}/actions/${params.actionId}`,
method: 'DELETE'
};
},
invalidatesTags: (result, error, arg)=>[
{
type: 'Release',
id: 'LIST'
},
{
type: 'Release',
id: arg.params.releaseId
},
{
type: 'ReleaseAction',
id: 'LIST'
},
{
type: 'EntriesInRelease'
}
]
}),
publishRelease: build.mutation({
query ({ id }) {
return {
url: `/content-releases/${id}/publish`,
method: 'POST'
};
},
invalidatesTags: (result, error, arg)=>[
{
type: 'Release',
id: arg.id
},
{
type: 'Document',
id: `ALL_LIST`
}
]
}),
deleteRelease: build.mutation({
query ({ id }) {
return {
url: `/content-releases/${id}`,
method: 'DELETE'
};
},
invalidatesTags: ()=>[
{
type: 'Release',
id: 'LIST'
},
{
type: 'EntriesInRelease'
}
]
}),
getMappedEntriesInReleases: build.query({
query (params) {
return {
url: '/content-releases/mapEntriesToReleases',
method: 'GET',
config: {
params
}
};
},
transformResponse (response) {
return response.data;
},
providesTags: [
{
type: 'EntriesInRelease'
}
]
}),
getReleaseSettings: build.query({
query: ()=>'/content-releases/settings',
providesTags: [
{
type: 'ReleaseSettings'
}
]
}),
updateReleaseSettings: build.mutation({
query (data) {
return {
url: '/content-releases/settings',
method: 'PUT',
data
};
},
invalidatesTags: [
{
type: 'ReleaseSettings'
}
]
})
};
}
});
const { useGetReleasesQuery, useGetReleasesForEntryQuery, useGetReleaseQuery, useGetReleaseActionsQuery, useCreateReleaseMutation, useCreateReleaseActionMutation, useCreateManyReleaseActionsMutation, useUpdateReleaseMutation, useUpdateReleaseActionMutation, usePublishReleaseMutation, useDeleteReleaseActionMutation, useDeleteReleaseMutation, useGetMappedEntriesInReleasesQuery, useGetReleaseSettingsQuery, useUpdateReleaseSettingsMutation } = releaseApi;
exports.releaseApi = releaseApi;
exports.useCreateManyReleaseActionsMutation = useCreateManyReleaseActionsMutation;
exports.useCreateReleaseActionMutation = useCreateReleaseActionMutation;
exports.useCreateReleaseMutation = useCreateReleaseMutation;
exports.useDeleteReleaseActionMutation = useDeleteReleaseActionMutation;
exports.useDeleteReleaseMutation = useDeleteReleaseMutation;
exports.useGetMappedEntriesInReleasesQuery = useGetMappedEntriesInReleasesQuery;
exports.useGetReleaseActionsQuery = useGetReleaseActionsQuery;
exports.useGetReleaseQuery = useGetReleaseQuery;
exports.useGetReleaseSettingsQuery = useGetReleaseSettingsQuery;
exports.useGetReleasesForEntryQuery = useGetReleasesForEntryQuery;
exports.useGetReleasesQuery = useGetReleasesQuery;
exports.usePublishReleaseMutation = usePublishReleaseMutation;
exports.useUpdateReleaseActionMutation = useUpdateReleaseActionMutation;
exports.useUpdateReleaseMutation = useUpdateReleaseMutation;
exports.useUpdateReleaseSettingsMutation = useUpdateReleaseSettingsMutation;
//# sourceMappingURL=release.js.map
@@ -0,0 +1 @@
{"version":3,"file":"release.js","sources":["../../../admin/src/services/release.ts"],"sourcesContent":["import { adminApi } from '@strapi/admin/strapi-admin';\n\nimport {\n CreateReleaseAction,\n CreateManyReleaseActions,\n DeleteReleaseAction,\n} from '../../../shared/contracts/release-actions';\n\nimport type {\n GetReleaseActions,\n UpdateReleaseAction,\n ReleaseActionGroupBy,\n} from '../../../shared/contracts/release-actions';\nimport type {\n CreateRelease,\n DeleteRelease,\n GetReleases,\n GetReleasesByDocumentAttached,\n UpdateRelease,\n GetRelease,\n PublishRelease,\n MapEntriesToReleases,\n} from '../../../shared/contracts/releases';\nimport type { GetSettings, UpdateSettings } from '../../../shared/contracts/settings';\nimport type { EndpointDefinition } from '@reduxjs/toolkit/query';\n\nexport interface GetReleasesQueryParams {\n page?: number;\n pageSize?: number;\n filters?: {\n releasedAt?: {\n // TODO: this should be a boolean, find a way to avoid strings\n $notNull?: boolean | 'true' | 'false';\n };\n };\n}\n\nexport interface GetReleaseActionsQueryParams {\n page?: number;\n pageSize?: number;\n groupBy?: ReleaseActionGroupBy;\n}\n\ntype GetReleasesTabResponse = GetReleases.Response & {\n meta: {\n activeTab: 'pending' | 'done';\n };\n};\n\ntype AnyEndpointDefinition = EndpointDefinition<any, any, any, any>;\n\n// TODO: move this into the admin code & expose an improved version of enhanceEndpoints or a new function\nconst extendInvalidatesTags = (\n endpoint: AnyEndpointDefinition,\n extraTags: string[] | { type: string; id: string }[]\n) => {\n if (!endpoint) {\n return;\n }\n\n const originalInvalidatesTags = endpoint.invalidatesTags;\n\n const newInvalidatesTags: AnyEndpointDefinition['invalidatesTags'] = (\n result,\n err,\n args,\n meta\n ) => {\n const originalTags =\n typeof originalInvalidatesTags === 'function'\n ? originalInvalidatesTags(result, err, args, meta)\n : originalInvalidatesTags;\n\n return [...(originalTags ?? []), ...extraTags];\n };\n\n Object.assign(endpoint, { invalidatesTags: newInvalidatesTags });\n};\n\nconst releaseApi = adminApi\n .enhanceEndpoints({\n addTagTypes: ['Release', 'ReleaseAction', 'EntriesInRelease', 'ReleaseSettings', 'Document'],\n endpoints: {\n updateDocument(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n deleteDocument(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n deleteManyDocuments(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n discardDocument(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n createWorkflow(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n updateWorkflow(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n deleteWorkflow(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n },\n })\n .injectEndpoints({\n endpoints: (build) => {\n return {\n getReleasesForEntry: build.query<\n GetReleasesByDocumentAttached.Response,\n Partial<GetReleasesByDocumentAttached.Request['query']>\n >({\n query(params) {\n return {\n url: '/content-releases/getByDocumentAttached',\n method: 'GET',\n config: {\n params,\n },\n };\n },\n providesTags: (result) =>\n result\n ? [\n ...result.data.map(({ id }) => ({ type: 'Release' as const, id })),\n { type: 'Release', id: 'LIST' },\n ]\n : [],\n }),\n getReleases: build.query<GetReleasesTabResponse, GetReleasesQueryParams | void>({\n query(\n { page, pageSize, filters } = {\n page: 1,\n pageSize: 16,\n filters: {\n releasedAt: {\n $notNull: false,\n },\n },\n }\n )Line truncated
@@ -0,0 +1,447 @@
import { adminApi } from '@strapi/admin/strapi-admin';
// TODO: move this into the admin code & expose an improved version of enhanceEndpoints or a new function
const extendInvalidatesTags = (endpoint, extraTags)=>{
if (!endpoint) {
return;
}
const originalInvalidatesTags = endpoint.invalidatesTags;
const newInvalidatesTags = (result, err, args, meta)=>{
const originalTags = typeof originalInvalidatesTags === 'function' ? originalInvalidatesTags(result, err, args, meta) : originalInvalidatesTags;
return [
...originalTags ?? [],
...extraTags
];
};
Object.assign(endpoint, {
invalidatesTags: newInvalidatesTags
});
};
const releaseApi = adminApi.enhanceEndpoints({
addTagTypes: [
'Release',
'ReleaseAction',
'EntriesInRelease',
'ReleaseSettings',
'Document'
],
endpoints: {
updateDocument (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
deleteDocument (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
deleteManyDocuments (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
discardDocument (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
createWorkflow (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
updateWorkflow (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
},
deleteWorkflow (endpoint) {
extendInvalidatesTags(endpoint, [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]);
}
}
}).injectEndpoints({
endpoints: (build)=>{
return {
getReleasesForEntry: build.query({
query (params) {
return {
url: '/content-releases/getByDocumentAttached',
method: 'GET',
config: {
params
}
};
},
providesTags: (result)=>result ? [
...result.data.map(({ id })=>({
type: 'Release',
id
})),
{
type: 'Release',
id: 'LIST'
}
] : []
}),
getReleases: build.query({
query ({ page, pageSize, filters } = {
page: 1,
pageSize: 16,
filters: {
releasedAt: {
$notNull: false
}
}
}) {
return {
url: '/content-releases',
method: 'GET',
config: {
params: {
page: page || 1,
pageSize: pageSize || 16,
filters: filters || {
releasedAt: {
$notNull: false
}
}
}
}
};
},
transformResponse (response, meta, arg) {
const releasedAtValue = arg?.filters?.releasedAt?.$notNull;
const isActiveDoneTab = releasedAtValue === 'true';
const newResponse = {
...response,
meta: {
...response.meta,
activeTab: isActiveDoneTab ? 'done' : 'pending'
}
};
return newResponse;
},
providesTags: (result)=>result ? [
...result.data.map(({ id })=>({
type: 'Release',
id
})),
{
type: 'Release',
id: 'LIST'
}
] : [
{
type: 'Release',
id: 'LIST'
}
]
}),
getRelease: build.query({
query ({ id }) {
return {
url: `/content-releases/${id}`,
method: 'GET'
};
},
providesTags: (result, error, arg)=>[
{
type: 'Release',
id: 'LIST'
},
{
type: 'Release',
id: arg.id
}
]
}),
getReleaseActions: build.query({
query ({ releaseId, ...params }) {
return {
url: `/content-releases/${releaseId}/actions`,
method: 'GET',
config: {
params
}
};
},
providesTags: [
{
type: 'ReleaseAction',
id: 'LIST'
}
]
}),
createRelease: build.mutation({
query (data) {
return {
url: '/content-releases',
method: 'POST',
data
};
},
invalidatesTags: [
{
type: 'Release',
id: 'LIST'
}
]
}),
updateRelease: build.mutation({
query ({ id, ...data }) {
return {
url: `/content-releases/${id}`,
method: 'PUT',
data
};
},
invalidatesTags: (result, error, arg)=>[
{
type: 'Release',
id: arg.id
}
]
}),
createReleaseAction: build.mutation({
query ({ body, params }) {
return {
url: `/content-releases/${params.releaseId}/actions`,
method: 'POST',
data: body
};
},
invalidatesTags: [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
}
]
}),
createManyReleaseActions: build.mutation({
query ({ body, params }) {
return {
url: `/content-releases/${params.releaseId}/actions/bulk`,
method: 'POST',
data: body
};
},
invalidatesTags: [
{
type: 'Release',
id: 'LIST'
},
{
type: 'ReleaseAction',
id: 'LIST'
},
{
type: 'EntriesInRelease'
}
]
}),
updateReleaseAction: build.mutation({
query ({ body, params }) {
return {
url: `/content-releases/${params.releaseId}/actions/${params.actionId}`,
method: 'PUT',
data: body
};
},
invalidatesTags: (res, error, arg)=>[
{
type: 'ReleaseAction',
id: 'LIST'
},
{
type: 'Release',
id: 'LIST'
},
{
type: 'Release',
id: arg.params.releaseId
}
],
async onQueryStarted ({ body, params, query, actionPath }, { dispatch, queryFulfilled }) {
// We need to mimic the same params received by the getReleaseActions query
const paramsWithoutActionId = {
releaseId: params.releaseId,
...query
};
const patchResult = dispatch(releaseApi.util.updateQueryData('getReleaseActions', paramsWithoutActionId, (draft)=>{
const [key, index] = actionPath;
const action = draft.data[key][index];
if (action) {
action.type = body.type;
}
}));
try {
await queryFulfilled;
} catch {
patchResult.undo();
}
}
}),
deleteReleaseAction: build.mutation({
query ({ params }) {
return {
url: `/content-releases/${params.releaseId}/actions/${params.actionId}`,
method: 'DELETE'
};
},
invalidatesTags: (result, error, arg)=>[
{
type: 'Release',
id: 'LIST'
},
{
type: 'Release',
id: arg.params.releaseId
},
{
type: 'ReleaseAction',
id: 'LIST'
},
{
type: 'EntriesInRelease'
}
]
}),
publishRelease: build.mutation({
query ({ id }) {
return {
url: `/content-releases/${id}/publish`,
method: 'POST'
};
},
invalidatesTags: (result, error, arg)=>[
{
type: 'Release',
id: arg.id
},
{
type: 'Document',
id: `ALL_LIST`
}
]
}),
deleteRelease: build.mutation({
query ({ id }) {
return {
url: `/content-releases/${id}`,
method: 'DELETE'
};
},
invalidatesTags: ()=>[
{
type: 'Release',
id: 'LIST'
},
{
type: 'EntriesInRelease'
}
]
}),
getMappedEntriesInReleases: build.query({
query (params) {
return {
url: '/content-releases/mapEntriesToReleases',
method: 'GET',
config: {
params
}
};
},
transformResponse (response) {
return response.data;
},
providesTags: [
{
type: 'EntriesInRelease'
}
]
}),
getReleaseSettings: build.query({
query: ()=>'/content-releases/settings',
providesTags: [
{
type: 'ReleaseSettings'
}
]
}),
updateReleaseSettings: build.mutation({
query (data) {
return {
url: '/content-releases/settings',
method: 'PUT',
data
};
},
invalidatesTags: [
{
type: 'ReleaseSettings'
}
]
})
};
}
});
const { useGetReleasesQuery, useGetReleasesForEntryQuery, useGetReleaseQuery, useGetReleaseActionsQuery, useCreateReleaseMutation, useCreateReleaseActionMutation, useCreateManyReleaseActionsMutation, useUpdateReleaseMutation, useUpdateReleaseActionMutation, usePublishReleaseMutation, useDeleteReleaseActionMutation, useDeleteReleaseMutation, useGetMappedEntriesInReleasesQuery, useGetReleaseSettingsQuery, useUpdateReleaseSettingsMutation } = releaseApi;
export { releaseApi, useCreateManyReleaseActionsMutation, useCreateReleaseActionMutation, useCreateReleaseMutation, useDeleteReleaseActionMutation, useDeleteReleaseMutation, useGetMappedEntriesInReleasesQuery, useGetReleaseActionsQuery, useGetReleaseQuery, useGetReleaseSettingsQuery, useGetReleasesForEntryQuery, useGetReleasesQuery, usePublishReleaseMutation, useUpdateReleaseActionMutation, useUpdateReleaseMutation, useUpdateReleaseSettingsMutation };
//# sourceMappingURL=release.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"release.mjs","sources":["../../../admin/src/services/release.ts"],"sourcesContent":["import { adminApi } from '@strapi/admin/strapi-admin';\n\nimport {\n CreateReleaseAction,\n CreateManyReleaseActions,\n DeleteReleaseAction,\n} from '../../../shared/contracts/release-actions';\n\nimport type {\n GetReleaseActions,\n UpdateReleaseAction,\n ReleaseActionGroupBy,\n} from '../../../shared/contracts/release-actions';\nimport type {\n CreateRelease,\n DeleteRelease,\n GetReleases,\n GetReleasesByDocumentAttached,\n UpdateRelease,\n GetRelease,\n PublishRelease,\n MapEntriesToReleases,\n} from '../../../shared/contracts/releases';\nimport type { GetSettings, UpdateSettings } from '../../../shared/contracts/settings';\nimport type { EndpointDefinition } from '@reduxjs/toolkit/query';\n\nexport interface GetReleasesQueryParams {\n page?: number;\n pageSize?: number;\n filters?: {\n releasedAt?: {\n // TODO: this should be a boolean, find a way to avoid strings\n $notNull?: boolean | 'true' | 'false';\n };\n };\n}\n\nexport interface GetReleaseActionsQueryParams {\n page?: number;\n pageSize?: number;\n groupBy?: ReleaseActionGroupBy;\n}\n\ntype GetReleasesTabResponse = GetReleases.Response & {\n meta: {\n activeTab: 'pending' | 'done';\n };\n};\n\ntype AnyEndpointDefinition = EndpointDefinition<any, any, any, any>;\n\n// TODO: move this into the admin code & expose an improved version of enhanceEndpoints or a new function\nconst extendInvalidatesTags = (\n endpoint: AnyEndpointDefinition,\n extraTags: string[] | { type: string; id: string }[]\n) => {\n if (!endpoint) {\n return;\n }\n\n const originalInvalidatesTags = endpoint.invalidatesTags;\n\n const newInvalidatesTags: AnyEndpointDefinition['invalidatesTags'] = (\n result,\n err,\n args,\n meta\n ) => {\n const originalTags =\n typeof originalInvalidatesTags === 'function'\n ? originalInvalidatesTags(result, err, args, meta)\n : originalInvalidatesTags;\n\n return [...(originalTags ?? []), ...extraTags];\n };\n\n Object.assign(endpoint, { invalidatesTags: newInvalidatesTags });\n};\n\nconst releaseApi = adminApi\n .enhanceEndpoints({\n addTagTypes: ['Release', 'ReleaseAction', 'EntriesInRelease', 'ReleaseSettings', 'Document'],\n endpoints: {\n updateDocument(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n deleteDocument(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n deleteManyDocuments(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n discardDocument(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n createWorkflow(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n updateWorkflow(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n deleteWorkflow(endpoint: AnyEndpointDefinition) {\n extendInvalidatesTags(endpoint, [\n { type: 'Release', id: 'LIST' },\n { type: 'ReleaseAction', id: 'LIST' },\n ]);\n },\n },\n })\n .injectEndpoints({\n endpoints: (build) => {\n return {\n getReleasesForEntry: build.query<\n GetReleasesByDocumentAttached.Response,\n Partial<GetReleasesByDocumentAttached.Request['query']>\n >({\n query(params) {\n return {\n url: '/content-releases/getByDocumentAttached',\n method: 'GET',\n config: {\n params,\n },\n };\n },\n providesTags: (result) =>\n result\n ? [\n ...result.data.map(({ id }) => ({ type: 'Release' as const, id })),\n { type: 'Release', id: 'LIST' },\n ]\n : [],\n }),\n getReleases: build.query<GetReleasesTabResponse, GetReleasesQueryParams | void>({\n query(\n { page, pageSize, filters } = {\n page: 1,\n pageSize: 16,\n filters: {\n releasedAt: {\n $notNull: false,\n },\n },\n }\n Line truncated