mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 07:33:17 +00:00
Adjusting typings
This commit is contained in:
parent
ecb5c6717c
commit
d4bbbcf4d0
@ -1,8 +1,8 @@
|
||||
import type { Attribute, Schema } from '@strapi/strapi';
|
||||
import type { Attribute, Common, Schema } from '@strapi/strapi';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
import * as componentsService from '@strapi/strapi/lib/services/entity-service/components';
|
||||
|
||||
import { assign, isArray, isEmpty, isObject, map, omit, size } from 'lodash/fp';
|
||||
|
||||
const sanitizeComponentLikeAttributes = <T extends Schema.ContentType>(
|
||||
@ -25,18 +25,27 @@ const createEntityQuery = (strapi: Strapi.Loaded): any => {
|
||||
async assignToEntity(uid: string, data: any) {
|
||||
const model = strapi.getModel(uid);
|
||||
|
||||
const entityComponents = await componentsService.createComponents(uid, data);
|
||||
const entityComponents = await strapi.componentsService.createComponents(
|
||||
uid as Common.UID.Schema,
|
||||
data
|
||||
);
|
||||
const dataWithoutComponents = sanitizeComponentLikeAttributes(model, data);
|
||||
|
||||
return assign(entityComponents, dataWithoutComponents);
|
||||
},
|
||||
|
||||
async get<T extends object>(uid: string, entity: T) {
|
||||
return componentsService.getComponents(uid, entity);
|
||||
return strapi.componentsService.getComponents(uid as Common.UID.Schema, entity as any);
|
||||
},
|
||||
|
||||
delete<T extends object>(uid: string, componentsToDelete: T) {
|
||||
return componentsService.deleteComponents(uid, componentsToDelete, { loadComponents: false });
|
||||
return strapi.componentsService.deleteComponents(
|
||||
uid as Common.UID.Schema,
|
||||
componentsToDelete as any,
|
||||
{
|
||||
loadComponents: false,
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -49,6 +49,7 @@ import getNumberOfDynamicZones from './services/utils/dynamic-zones';
|
||||
import sanitizersRegistry from './core/registries/sanitizers';
|
||||
import validatorsRegistry from './core/registries/validators';
|
||||
import convertCustomFieldType from './utils/convert-custom-field-type';
|
||||
import * as componentsService from './services/entity-service/components';
|
||||
|
||||
// TODO: move somewhere else
|
||||
import * as draftAndPublishSync from './migrations/draft-publish';
|
||||
@ -144,6 +145,8 @@ class Strapi {
|
||||
|
||||
entityService?: EntityService;
|
||||
|
||||
componentsService: typeof componentsService;
|
||||
|
||||
telemetry: ReturnType<typeof createTelemetry>;
|
||||
|
||||
requestContext: typeof requestContext;
|
||||
@ -216,6 +219,7 @@ class Strapi {
|
||||
this.requestContext = requestContext;
|
||||
this.customFields = createCustomFields(this);
|
||||
this.fetch = createStrapiFetch(this);
|
||||
this.componentsService = componentsService;
|
||||
|
||||
createUpdateNotifier(this).notify();
|
||||
|
||||
|
||||
@ -353,7 +353,7 @@ const buildRelationsStore = <TUID extends Common.UID.ContentType | Common.UID.Co
|
||||
return {};
|
||||
}
|
||||
|
||||
const currentModel: Common.Schemas[TUID] = strapi.getModel(uid);
|
||||
const currentModel = strapi.getModel(uid);
|
||||
|
||||
return Object.keys(currentModel.attributes).reduce((result, attributeName: string) => {
|
||||
const attribute = currentModel.attributes[attributeName];
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
"outDir": "dist",
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/**"]
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
"compilerOptions": {
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src", "admin.d.ts"],
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
"compilerOptions": {
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src", "admin.d.ts"],
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user