fix(server): fix build errors

This commit is contained in:
mytharcher 2024-08-21 12:42:24 +08:00
parent 5580dc8fd1
commit 65b6fb7b03
12 changed files with 23 additions and 50 deletions

View File

@ -7,14 +7,23 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { Model, Op } from 'sequelize';
import { BelongsToManyRepository, Collection, HasManyRepository, TargetKey, Model, Op } from '@nocobase/database';
import { Context } from '@nocobase/actions';
import { BelongsToManyRepository, Collection, HasManyRepository, SortField, TargetKey } from '@nocobase/database';
import { Context } from '..';
import { getRepositoryFromParams } from '../utils';
import { SortField } from './sort-field';
export async function move(ctx: Context, next) {
const repository = ctx.databaseRepository || getRepositoryFromParams(ctx);
const repository = ctx.getCurrentRepository();
if (repository.move) {
ctx.body = await repository.move(ctx.action.params);
return next();
}
if (repository.database) {
return ctx.throw(new Error(`Repository can not handle action move for ${ctx.action.resourceName}`));
}
const { sourceId, targetId, targetScope, sticky, method } = ctx.action.params;
let sortField = ctx.action.params.sortField;

View File

@ -42,7 +42,6 @@ export * from './time';
export * from './updatedAt';
export * from './updatedBy';
export * from './url';
export * from './sort';
export * from './uuid';
export * from './nanoid';
export * from './unixTimestamp';

View File

@ -1,29 +0,0 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { Context } from '@nocobase/actions';
export function createMoveAction(databaseMoveAction) {
return async function move(ctx: Context, next) {
const repository = ctx.getCurrentRepository();
if (repository.move) {
ctx.body = await repository.move(ctx.action.params);
await next();
return;
}
if (repository.database) {
ctx.databaseRepository = repository;
return databaseMoveAction(ctx, next);
}
throw new Error(`Repository can not handle action move for ${ctx.action.resourceName}`);
};
}

View File

@ -8,9 +8,7 @@
*/
import { list } from './default-actions/list';
import { createMoveAction } from './default-actions/move';
import { proxyToRepository } from './default-actions/proxy-to-repository';
import globalActions from '@nocobase/actions';
type Actions = { [key: string]: { params: Array<string> | ((ctx: any) => Array<string>); method: string } };
@ -81,6 +79,5 @@ export function loadDefaultActions() {
return carry;
}, {}),
list,
move: createMoveAction(globalActions.move),
};
}

View File

@ -6,7 +6,6 @@
"types": "./lib/index.d.ts",
"license": "AGPL-3.0",
"dependencies": {
"@nocobase/lock-manager": "1.4.0-alpha",
"@nocobase/logger": "1.4.0-alpha",
"@nocobase/utils": "1.4.0-alpha",
"chalk": "^4.1.1",

View File

@ -9,7 +9,6 @@
/* istanbul ignore file -- @preserve */
import { merge } from '@nocobase/utils';
import { LockManager } from '@nocobase/lock-manager';
import { customAlphabet } from 'nanoid';
import fetch from 'node-fetch';
import path from 'path';

View File

@ -27,7 +27,6 @@
"@types/ini": "^1.3.31",
"@types/koa-send": "^4.1.3",
"@types/multer": "^1.4.5",
"async-mutex": "^0.5.0",
"axios": "^0.26.1",
"chalk": "^4.1.1",
"commander": "^9.2.0",

View File

@ -63,7 +63,6 @@ import { Plugin } from './plugin';
import { InstallOptions, PluginManager } from './plugin-manager';
import { createPubSubManager, PubSubManager, PubSubManagerOptions } from './pub-sub-manager';
import { SyncMessageManager } from './sync-message-manager';
import { LockManager, LockManagerOptions } from './lock-manager';
export type PluginType = string | typeof Plugin;
export type PluginConfiguration = PluginType | [PluginType, any];
@ -534,10 +533,6 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
await this.telemetry.shutdown();
}
if (this.lockManager) {
await this.lockManager.close();
}
this.closeLogger();
const oldDb = this.db;

View File

@ -18,5 +18,4 @@ export * from './plugin-manager';
export * from './pub-sub-manager';
export * from './gateway';
export * from './app-supervisor';
export * from './lock-manager';
export const OFFICIAL_PLUGIN_PREFIX = '@nocobase/plugin-';

View File

@ -62,8 +62,8 @@ async function importXlsxAction(ctx: Context, next: Next) {
export async function importXlsx(ctx: Context, next: Next) {
if (mutex.isLocked()) {
throw new Error(
ctx.t(`another export action is running, please try again later.`, {
ns: 'action-export',
ctx.t(`another import action is running, please try again later.`, {
ns: 'action-import',
}),
);
}

View File

@ -4,8 +4,13 @@
"main": "dist/server/index.js",
"dependencies": {},
"peerDependencies": {
"@nocobase/actions": "1.x",
"@nocobase/client": "1.x",
"@nocobase/database": "1.x",
"@nocobase/lock-manager": "1.x",
"@nocobase/server": "1.x",
"@nocobase/test": "1.x"
"@nocobase/test": "1.x",
"lodash": "4.17.21",
"sequelize": "^6.26.0"
}
}

View File

@ -8,3 +8,4 @@
*/
export { default } from './plugin';
export { move } from './action';