mirror of
https://github.com/strapi/strapi.git
synced 2025-06-27 00:41:25 +00:00
chore: touch ups
This commit is contained in:
parent
92055a7fb1
commit
cffeb3f30b
@ -4,5 +4,4 @@ dist
|
|||||||
build
|
build
|
||||||
.strapi
|
.strapi
|
||||||
/.nx/cache
|
/.nx/cache
|
||||||
|
/.nx/workspace-data
|
||||||
/.nx/workspace-data
|
|
||||||
|
@ -43,7 +43,7 @@ export { useHistory } from './features/BackButton';
|
|||||||
* Hooks
|
* Hooks
|
||||||
*/
|
*/
|
||||||
export { useInjectReducer } from './hooks/useInjectReducer';
|
export { useInjectReducer } from './hooks/useInjectReducer';
|
||||||
export { useAPIErrorHandler, type ApiError } from './hooks/useAPIErrorHandler';
|
export { useAPIErrorHandler } from './hooks/useAPIErrorHandler';
|
||||||
export { useQueryParams } from './hooks/useQueryParams';
|
export { useQueryParams } from './hooks/useQueryParams';
|
||||||
export { useFetchClient } from './hooks/useFetchClient';
|
export { useFetchClient } from './hooks/useFetchClient';
|
||||||
export { useFocusInputField } from './hooks/useFocusInputField';
|
export { useFocusInputField } from './hooks/useFocusInputField';
|
||||||
@ -71,14 +71,7 @@ export type { RBACContext, RBACMiddleware } from './core/apis/rbac';
|
|||||||
* Utils
|
* Utils
|
||||||
*/
|
*/
|
||||||
export { translatedErrors } from './utils/translatedErrors';
|
export { translatedErrors } from './utils/translatedErrors';
|
||||||
export { getFetchClient, isFetchError, FetchError } from './utils/getFetchClient';
|
export * from './utils/getFetchClient';
|
||||||
export type {
|
|
||||||
ErrorResponse,
|
|
||||||
FetchClient,
|
|
||||||
FetchConfig,
|
|
||||||
FetchOptions,
|
|
||||||
FetchResponse,
|
|
||||||
} from './utils/getFetchClient';
|
|
||||||
export * from './utils/baseQuery';
|
export * from './utils/baseQuery';
|
||||||
export * from './services/api';
|
export * from './services/api';
|
||||||
export type { CMAdminConfiguration } from './types/adminConfiguration';
|
export type { CMAdminConfiguration } from './types/adminConfiguration';
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { createAuditLogsLifecycleService } from '../lifecycles';
|
import { createAuditLogsLifecycleService } from '../lifecycles';
|
||||||
import createEventHub from '../../../../../../../core/src/services/event-hub';
|
|
||||||
import { scheduleJob } from 'node-schedule';
|
import { scheduleJob } from 'node-schedule';
|
||||||
|
|
||||||
import '@strapi/types';
|
import '@strapi/types';
|
||||||
@ -51,7 +50,16 @@ describe('Audit logs service', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
eventHub: {
|
eventHub: {
|
||||||
...createEventHub(),
|
subs: {} as Record<string, (...args: unknown[]) => unknown>,
|
||||||
|
emit(eventName: string, ...args: unknown[]) {
|
||||||
|
this.subs[eventName](...args);
|
||||||
|
},
|
||||||
|
on(eventName: string, func: (...args: unknown[]) => unknown) {
|
||||||
|
this.subs[eventName] = func;
|
||||||
|
return () => {
|
||||||
|
delete this.subs[eventName];
|
||||||
|
};
|
||||||
|
},
|
||||||
subscribe: mockSubscribe,
|
subscribe: mockSubscribe,
|
||||||
},
|
},
|
||||||
hook: () => ({
|
hook: () => ({
|
||||||
@ -71,6 +79,9 @@ describe('Audit logs service', () => {
|
|||||||
// Should not subscribe to events at first
|
// Should not subscribe to events at first
|
||||||
const lifecycle = createAuditLogsLifecycleService(strapi);
|
const lifecycle = createAuditLogsLifecycleService(strapi);
|
||||||
await lifecycle.register();
|
await lifecycle.register();
|
||||||
|
const destroySpy = jest.spyOn(lifecycle, 'destroy');
|
||||||
|
const registerSpy = jest.spyOn(lifecycle, 'register');
|
||||||
|
|
||||||
expect(mockSubscribe).not.toHaveBeenCalled();
|
expect(mockSubscribe).not.toHaveBeenCalled();
|
||||||
|
|
||||||
// Should subscribe to events when license gets enabled
|
// Should subscribe to events when license gets enabled
|
||||||
@ -83,10 +94,9 @@ describe('Audit logs service', () => {
|
|||||||
jest.mocked(strapi.ee.features.isEnabled).mockImplementationOnce(() => false);
|
jest.mocked(strapi.ee.features.isEnabled).mockImplementationOnce(() => false);
|
||||||
await strapi.eventHub.emit('ee.disable');
|
await strapi.eventHub.emit('ee.disable');
|
||||||
expect(mockSubscribe).not.toHaveBeenCalled();
|
expect(mockSubscribe).not.toHaveBeenCalled();
|
||||||
|
expect(destroySpy).toHaveBeenCalled();
|
||||||
|
|
||||||
// Should recreate the service when license updates
|
// Should recreate the service when license updates
|
||||||
const destroySpy = jest.spyOn(lifecycle, 'destroy');
|
|
||||||
const registerSpy = jest.spyOn(lifecycle, 'register');
|
|
||||||
await strapi.eventHub.emit('ee.update');
|
await strapi.eventHub.emit('ee.update');
|
||||||
expect(destroySpy).toHaveBeenCalled();
|
expect(destroySpy).toHaveBeenCalled();
|
||||||
expect(registerSpy).toHaveBeenCalled();
|
expect(registerSpy).toHaveBeenCalled();
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
"url": "https://strapi.io"
|
"url": "https://strapi.io"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"module": "./dist/index.mjs",
|
||||||
|
"source": "./src/index.ts",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import type { Schema } from '@strapi/types';
|
import type { Struct } from '@strapi/types';
|
||||||
import { createService } from '../index';
|
import { createService } from '../index';
|
||||||
import { CollectionTypeService } from '../collection-type';
|
import { CollectionTypeService } from '../collection-type';
|
||||||
import { SingleTypeService } from '../single-type';
|
import { SingleTypeService } from '../single-type';
|
||||||
|
|
||||||
const singleType: Schema.SingleType = {
|
const singleType: Struct.SingleTypeSchema = {
|
||||||
kind: 'singleType',
|
kind: 'singleType',
|
||||||
modelType: 'contentType',
|
modelType: 'contentType',
|
||||||
uid: 'api::testModel.testModel',
|
uid: 'api::testModel.testModel',
|
||||||
@ -20,10 +20,12 @@ const singleType: Schema.SingleType = {
|
|||||||
describe('Default Service', () => {
|
describe('Default Service', () => {
|
||||||
describe('Collection Type', () => {
|
describe('Collection Type', () => {
|
||||||
test('Creates default actions', () => {
|
test('Creates default actions', () => {
|
||||||
const contentType: Schema.ContentType = {
|
const contentType: Struct.ContentTypeSchema = {
|
||||||
kind: 'collectionType',
|
kind: 'collectionType',
|
||||||
modelType: 'contentType',
|
modelType: 'contentType',
|
||||||
uid: 'testModel',
|
uid: 'api::testModel.testModel',
|
||||||
|
globalId: 'testModel',
|
||||||
|
modelName: 'testModel',
|
||||||
attributes: {},
|
attributes: {},
|
||||||
info: {
|
info: {
|
||||||
singularName: 'test-model',
|
singularName: 'test-model',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import type { Schema, Common } from '@strapi/types';
|
import type { Schema, Internal } from '@strapi/types';
|
||||||
|
|
||||||
const createSchemaFromAttributes = (
|
const createSchemaFromAttributes = (
|
||||||
uid: Common.UID.ContentType,
|
uid: Internal.UID.ContentType,
|
||||||
attributes: Schema.Attributes,
|
attributes: Schema.Attributes,
|
||||||
singularName?: string,
|
singularName?: string,
|
||||||
pluralName?: string,
|
pluralName?: string,
|
||||||
@ -26,9 +26,9 @@ const createSchemaFromAttributes = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CATEGORY_UID = 'api::category.category' as Common.UID.ContentType;
|
export const CATEGORY_UID = 'api::category.category' as Internal.UID.ContentType;
|
||||||
export const PRODUCT_UID = 'api::product.product' as Common.UID.ContentType;
|
export const PRODUCT_UID = 'api::product.product' as Internal.UID.ContentType;
|
||||||
export const SHOP_UID = 'api::shop.shop' as Common.UID.ContentType;
|
export const SHOP_UID = 'api::shop.shop' as Internal.UID.ContentType;
|
||||||
|
|
||||||
export const models: Record<string, Schema.ContentType> = {
|
export const models: Record<string, Schema.ContentType> = {
|
||||||
[CATEGORY_UID]: createSchemaFromAttributes(
|
[CATEGORY_UID]: createSchemaFromAttributes(
|
||||||
|
@ -7,7 +7,6 @@ import chalk from 'chalk';
|
|||||||
import { env } from '@strapi/utils';
|
import { env } from '@strapi/utils';
|
||||||
import type { Core } from '@strapi/types';
|
import type { Core } from '@strapi/types';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
import pkg from '../../../package.json';
|
import pkg from '../../../package.json';
|
||||||
|
|
||||||
const CHECK_INTERVAL = 1000 * 60 * 60 * 24 * 1; // 1 day
|
const CHECK_INTERVAL = 1000 * 60 * 60 * 24 * 1; // 1 day
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable check-file/filename-naming-convention */
|
|
||||||
|
|
||||||
import { REVIEW_WORKFLOW_COLUMNS } from '../routes/content-manager/model/constants';
|
import { REVIEW_WORKFLOW_COLUMNS } from '../routes/content-manager/model/constants';
|
||||||
|
|
||||||
import type { ListFieldLayout, ListLayout } from '@strapi/content-manager/strapi-admin';
|
import type { ListFieldLayout, ListLayout } from '@strapi/content-manager/strapi-admin';
|
||||||
|
@ -11,8 +11,6 @@ const command: StrapiCommand = () => {
|
|||||||
return createCommand('version')
|
return createCommand('version')
|
||||||
.description('Output the version of Strapi')
|
.description('Output the version of Strapi')
|
||||||
.action(() => {
|
.action(() => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
|
|
||||||
process.stdout.write(`${version}\n`);
|
process.stdout.write(`${version}\n`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
@ -4,6 +4,8 @@ import { FOLDER_MODEL_UID } from '../../../constants';
|
|||||||
import { folderExists } from './utils';
|
import { folderExists } from './utils';
|
||||||
import { isFolderOrChild } from '../../utils/folders';
|
import { isFolderOrChild } from '../../utils/folders';
|
||||||
|
|
||||||
|
import type { Folder } from '../../../types';
|
||||||
|
|
||||||
const validateDeleteManyFoldersFilesSchema = yup
|
const validateDeleteManyFoldersFilesSchema = yup
|
||||||
.object()
|
.object()
|
||||||
.shape({
|
.shape({
|
||||||
@ -67,14 +69,14 @@ const validateMoveFoldersNotInsideThemselvesSchema = yup
|
|||||||
where: { id: destinationFolderId },
|
where: { id: destinationFolderId },
|
||||||
});
|
});
|
||||||
|
|
||||||
const folders = await strapi.db.query(FOLDER_MODEL_UID).findMany({
|
const folders: Folder[] = await strapi.db.query(FOLDER_MODEL_UID).findMany({
|
||||||
select: ['name', 'path'],
|
select: ['name', 'path'],
|
||||||
where: { id: { $in: folderIds } },
|
where: { id: { $in: folderIds } },
|
||||||
});
|
});
|
||||||
|
|
||||||
const unmovableFoldersNames = folders
|
const unmovableFoldersNames = folders
|
||||||
.filter((folder: any) => isFolderOrChild(destinationFolder, folder))
|
.filter((folder) => isFolderOrChild(destinationFolder, folder))
|
||||||
.map((f: any) => f.name);
|
.map((f) => f.name);
|
||||||
|
|
||||||
if (unmovableFoldersNames.length > 0) {
|
if (unmovableFoldersNames.length > 0) {
|
||||||
return this.createError({
|
return this.createError({
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
"resources"
|
"resources"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "run-p build:code build:types",
|
"build": "run -T npm-run-all clean --parallel build:code build:types",
|
||||||
"build:code": "run -T rollup -c",
|
"build:code": "run -T rollup -c",
|
||||||
"build:types": "run -T tsc -p tsconfig.build.json --emitDeclarationOnly",
|
"build:types": "run -T tsc -p tsconfig.build.json --emitDeclarationOnly",
|
||||||
"clean": "run -T rimraf ./dist",
|
"clean": "run -T rimraf ./dist",
|
||||||
|
@ -114,7 +114,7 @@ describe('Filtering API', () => {
|
|||||||
await builder.cleanup();
|
await builder.cleanup();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.only('Basic filters', () => {
|
describe('Basic filters', () => {
|
||||||
describe('Filter $and', () => {
|
describe('Filter $and', () => {
|
||||||
test('Should return an array with matching entities', async () => {
|
test('Should return an array with matching entities', async () => {
|
||||||
const res = await rq({
|
const res = await rq({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user