chore: fix build

This commit is contained in:
Convly 2024-03-06 15:22:39 +01:00
parent 8c6c0f1020
commit c16930d5b2
7 changed files with 24 additions and 23 deletions

View File

@ -7,7 +7,7 @@ import { type ReactEditor } from 'slate-react';
import { type LinkEditor } from './src/content-manager/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks';
import type { Schema, Attribute } from '@strapi/types';
import type { Schema, Modules } from '@strapi/types';
declare module 'styled-components' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface

View File

@ -1,10 +1,10 @@
import { errors } from '@strapi/utils';
import type { Common, Strapi, UID } from '@strapi/types';
import type { Core, UID } from '@strapi/types';
import { getService as getContentManagerService } from '../../utils';
import { getService } from '../utils';
import { HistoryVersions } from '../../../../shared/contracts';
const createHistoryVersionController = ({ strapi }: { strapi: Strapi }) => {
const createHistoryVersionController = ({ strapi }: { strapi: Core.Strapi }) => {
return {
async findMany(ctx) {
const contentTypeUid = ctx.query.contentType as UID.ContentType;
@ -37,7 +37,7 @@ const createHistoryVersionController = ({ strapi }: { strapi: Strapi }) => {
return { data: results, meta: { pagination } };
},
} satisfies Common.Controller;
} satisfies Core.Controller;
};
export { createHistoryVersionController };

View File

@ -1,4 +1,4 @@
import type { LoadedStrapi } from '@strapi/types';
import type { Core } from '@strapi/types';
import { omit, pick } from 'lodash/fp';
import { scheduleJob } from 'node-schedule';
@ -8,7 +8,7 @@ import type { HistoryVersions } from '../../../../shared/contracts';
const DEFAULT_RETENTION_DAYS = 90;
const createHistoryService = ({ strapi }: { strapi: LoadedStrapi }) => {
const createHistoryService = ({ strapi }: { strapi: Core.LoadedStrapi }) => {
const state: {
deleteExpiredJob: ReturnType<typeof scheduleJob> | null;
isInitialized: boolean;
@ -19,7 +19,7 @@ const createHistoryService = ({ strapi }: { strapi: LoadedStrapi }) => {
const query = strapi.db.query(HISTORY_VERSION_UID);
const getRetentionDays = (strapi: LoadedStrapi) => {
const getRetentionDays = (strapi: Core.LoadedStrapi) => {
const licenseRetentionDays =
strapi.ee.features.get('cms-content-history')?.options.retentionDays;
const userRetentionDays: number = strapi.config.get('admin.history.retentionDays');

View File

@ -1,8 +1,8 @@
import { Strapi } from '@strapi/types';
import type { Core } from '@strapi/types';
type HistoryServices = typeof import('./services').services;
function getService<T extends keyof HistoryServices>(strapi: Strapi, name: T) {
function getService<T extends keyof HistoryServices>(strapi: Core.Strapi, name: T) {
// Cast is needed because the return type of strapi.service is too vague
return strapi.service(`plugin::content-manager.${name}`) as ReturnType<HistoryServices[T]>;
}

View File

@ -1,4 +1,4 @@
import type { Entity, UID } from '@strapi/types';
import type { Data, UID } from '@strapi/types';
import { type errors } from '@strapi/utils';
/**
@ -8,7 +8,7 @@ import { type errors } from '@strapi/utils';
*/
export interface CreateHistoryVersion {
contentType: UID.ContentType;
relatedDocumentId: Entity.ID;
relatedDocumentId: Data.ID;
locale: string | null;
status: 'draft' | 'published' | 'modified' | null;
data: Record<string, unknown>;
@ -21,10 +21,10 @@ interface Locale {
}
export interface HistoryVersionDataResponse extends Omit<CreateHistoryVersion, 'locale'> {
id: Entity.ID;
id: Data.ID;
createdAt: string;
createdBy?: {
id: Entity.ID;
id: Data.ID;
firstname?: string;
lastname?: string;
username?: string;
@ -50,7 +50,7 @@ export declare namespace GetHistoryVersions {
};
query: {
contentType: UID.ContentType;
documentId?: Entity.ID;
documentId?: Data.ID;
locale?: string;
};
}

View File

@ -6,7 +6,7 @@ import {
convertQueryParams,
contentTypes as contentTypesUtils,
} from '@strapi/utils';
import { Common } from '@strapi/types';
import type { UID } from '@strapi/types';
import { wrapInTransaction, type RepositoryFactoryMethod } from './common';
import * as DP from './draft-and-publish';
@ -29,7 +29,7 @@ import { createDocumentId } from '../../utils/transform-content-types-to-models'
import { getDeepPopulate } from './utils/populate';
import { transformData } from './transform/data';
const transformParamsToQuery = curry((uid: Common.UID.Schema, params: any) => {
const transformParamsToQuery = curry((uid: UID.Schema, params: any) => {
const query = convertQueryParams.transformParamsToQuery(uid, params);
return assoc('where', { ...params?.lookup, ...query.where }, query);
@ -131,9 +131,10 @@ export const createContentTypeRepository: RepositoryFactoryMethod = (uid) => {
});
// Component handling
const componentData = await createComponents(uid, validData as any);
const componentData = await createComponents(uid, validData);
const contentTypeWithoutComponentData = omitComponentData(contentType, validData);
const entryData = applyTransforms(
Object.assign(omitComponentData(contentType, validData), componentData),
Object.assign(contentTypeWithoutComponentData, componentData) as any,
{ contentType }
);
@ -194,14 +195,14 @@ export const createContentTypeRepository: RepositoryFactoryMethod = (uid) => {
const validData = await entityValidator.validateEntityUpdate(
model,
// Omit id fields, the cloned entity id will be generated by the database
omit(['id'], data),
omit(['id'], data) as any,
{ isDraft, ...queryParams?.lookup },
entryToClone
);
const componentData = await cloneComponents(uid, entryToClone, validData);
const entityData = applyTransforms(
Object.assign(omitComponentData(model, validData), componentData),
Object.assign(omitComponentData(model, validData), componentData as any),
{ contentType: model }
);
@ -257,7 +258,7 @@ export const createContentTypeRepository: RepositoryFactoryMethod = (uid) => {
// Component handling
const componentData = await updateComponents(uid, entryToUpdate, validData as any);
const entryData = applyTransforms(
Object.assign(omitComponentData(model, validData), componentData),
Object.assign(omitComponentData(model, validData), componentData as any),
{ contentType: model }
);

View File

@ -1,9 +1,9 @@
import { Common } from '@strapi/types';
import { UID } from '@strapi/types';
import { traverseEntity } from '@strapi/utils';
import { isObject } from 'lodash/fp';
import { switchIdForDocumentId } from '../../utils';
const transformOutputIds = async (uid: Common.UID.Schema, output: Record<string, any>) => {
const transformOutputIds = async (uid: UID.Schema, output: Record<string, any>) => {
return traverseEntity(
({ key, value, attribute }, { set }) => {
// Find relational attributes, and return the document ids