@nocobase/server 0.20.0-alpha.9 → 0.21.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/acl/available-action.js +2 -1
- package/lib/application.d.ts +138 -8
- package/lib/application.js +120 -15
- package/lib/commands/console.js +1 -1
- package/lib/commands/index.js +2 -0
- package/lib/commands/pm.js +11 -4
- package/lib/commands/start.js +19 -2
- package/lib/gateway/index.js +10 -7
- package/lib/gateway/ws-server.js +5 -1
- package/lib/helper.js +1 -11
- package/lib/locale/locale.js +4 -1
- package/lib/locale/resource.js +4 -1
- package/lib/main-data-source.js +10 -0
- package/lib/middlewares/data-wrapping.js +1 -0
- package/lib/middlewares/db2resource.js +1 -8
- package/lib/middlewares/validate-filter-params.d.ts +1 -0
- package/lib/middlewares/validate-filter-params.js +33 -0
- package/lib/plugin-manager/clientStaticUtils.js +2 -2
- package/lib/plugin-manager/options/resource.js +4 -1
- package/lib/plugin-manager/plugin-manager-repository.d.ts +15 -0
- package/lib/plugin-manager/plugin-manager-repository.js +15 -0
- package/lib/plugin-manager/plugin-manager.d.ts +90 -2
- package/lib/plugin-manager/plugin-manager.js +147 -15
- package/lib/plugin-manager/utils.js +11 -3
- package/lib/plugin.d.ts +45 -9
- package/lib/plugin.js +64 -28
- package/package.json +14 -14
|
@@ -47,11 +47,12 @@ const availableActions = {
|
|
|
47
47
|
update: {
|
|
48
48
|
displayName: '{{t("Edit")}}',
|
|
49
49
|
type: "old-data",
|
|
50
|
-
aliases: ["update", "move"],
|
|
50
|
+
aliases: ["update", "move", "add", "set", "remove", "toggle"],
|
|
51
51
|
allowConfigureFields: true
|
|
52
52
|
},
|
|
53
53
|
destroy: {
|
|
54
54
|
displayName: '{{t("Delete")}}',
|
|
55
|
+
aliases: ["destroy"],
|
|
55
56
|
type: "old-data"
|
|
56
57
|
}
|
|
57
58
|
};
|
package/lib/application.d.ts
CHANGED
|
@@ -22,9 +22,16 @@ import { InstallOptions, PluginManager } from './plugin-manager';
|
|
|
22
22
|
import { DataSourceManager, SequelizeDataSource } from '@nocobase/data-source-manager';
|
|
23
23
|
export type PluginType = string | typeof Plugin;
|
|
24
24
|
export type PluginConfiguration = PluginType | [PluginType, any];
|
|
25
|
-
export interface
|
|
25
|
+
export interface ResourceManagerOptions {
|
|
26
26
|
prefix?: string;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* this interface is deprecated and should not be used.
|
|
30
|
+
* @deprecated
|
|
31
|
+
* use {@link ResourceManagerOptions} instead
|
|
32
|
+
*/
|
|
33
|
+
export interface ResourcerOptions extends ResourceManagerOptions {
|
|
34
|
+
}
|
|
28
35
|
export interface AppLoggerOptions {
|
|
29
36
|
request: RequestLoggerOptions;
|
|
30
37
|
system: SystemLoggerOptions;
|
|
@@ -35,7 +42,13 @@ export interface AppTelemetryOptions extends TelemetryOptions {
|
|
|
35
42
|
export interface ApplicationOptions {
|
|
36
43
|
database?: IDatabaseOptions | Database;
|
|
37
44
|
cacheManager?: CacheManagerOptions;
|
|
38
|
-
|
|
45
|
+
/**
|
|
46
|
+
* this property is deprecated and should not be used.
|
|
47
|
+
* @deprecated
|
|
48
|
+
* use {@link ApplicationOptions.resourceManager} instead
|
|
49
|
+
*/
|
|
50
|
+
resourcer?: ResourceManagerOptions;
|
|
51
|
+
resourceManager?: ResourceManagerOptions;
|
|
39
52
|
bodyParser?: any;
|
|
40
53
|
cors?: any;
|
|
41
54
|
dataWrapping?: boolean;
|
|
@@ -44,9 +57,15 @@ export interface ApplicationOptions {
|
|
|
44
57
|
plugins?: PluginConfiguration[];
|
|
45
58
|
acl?: boolean;
|
|
46
59
|
logger?: AppLoggerOptions;
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
47
63
|
pmSock?: string;
|
|
48
64
|
name?: string;
|
|
49
65
|
authManager?: AuthManagerOptions;
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
50
69
|
perfHooks?: boolean;
|
|
51
70
|
telemetry?: AppTelemetryOptions;
|
|
52
71
|
}
|
|
@@ -65,6 +84,12 @@ interface ActionsOptions {
|
|
|
65
84
|
resourceName?: string;
|
|
66
85
|
resourceNames?: string[];
|
|
67
86
|
}
|
|
87
|
+
interface LoadOptions {
|
|
88
|
+
reload?: boolean;
|
|
89
|
+
hooks?: boolean;
|
|
90
|
+
sync?: boolean;
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
}
|
|
68
93
|
interface StartOptions {
|
|
69
94
|
cliArgs?: any[];
|
|
70
95
|
dbSync?: boolean;
|
|
@@ -83,19 +108,41 @@ export type MaintainingCommandStatus = {
|
|
|
83
108
|
};
|
|
84
109
|
export declare class Application<StateT = DefaultState, ContextT = DefaultContext> extends Koa implements AsyncEmitter {
|
|
85
110
|
options: ApplicationOptions;
|
|
111
|
+
/**
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
86
114
|
middleware: any;
|
|
115
|
+
/**
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
87
118
|
stopped: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
88
122
|
ready: boolean;
|
|
89
123
|
emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
|
|
124
|
+
/**
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
90
127
|
rawOptions: ApplicationOptions;
|
|
128
|
+
/**
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
91
131
|
activatedCommand: {
|
|
92
132
|
name: string;
|
|
93
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
94
137
|
running: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
95
141
|
perfHistograms: Map<string, RecordableHistogram>;
|
|
96
142
|
protected plugins: Map<string, Plugin<any>>;
|
|
97
143
|
protected _appSupervisor: AppSupervisor;
|
|
98
144
|
protected _started: boolean;
|
|
145
|
+
protected _logger: SystemLogger;
|
|
99
146
|
private _authenticated;
|
|
100
147
|
private _maintaining;
|
|
101
148
|
private _maintainingCommandStatus;
|
|
@@ -103,20 +150,34 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
103
150
|
private _actionCommand;
|
|
104
151
|
constructor(options: ApplicationOptions);
|
|
105
152
|
protected _loaded: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
106
156
|
get loaded(): boolean;
|
|
107
157
|
private _maintainingMessage;
|
|
158
|
+
/**
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
108
161
|
get maintainingMessage(): string;
|
|
109
162
|
protected _cronJobManager: CronJobManager;
|
|
110
163
|
get cronJobManager(): CronJobManager;
|
|
111
164
|
get mainDataSource(): SequelizeDataSource;
|
|
112
165
|
get db(): Database;
|
|
113
|
-
protected _logger: SystemLogger;
|
|
114
166
|
get logger(): SystemLogger;
|
|
115
|
-
get
|
|
167
|
+
get resourceManager(): import("@nocobase/resourcer").ResourceManager;
|
|
168
|
+
/**
|
|
169
|
+
* This method is deprecated and should not be used.
|
|
170
|
+
* Use {@link #resourceManager} instead.
|
|
171
|
+
* @deprecated
|
|
172
|
+
*/
|
|
173
|
+
get resourcer(): import("@nocobase/resourcer").ResourceManager;
|
|
116
174
|
protected _cacheManager: CacheManager;
|
|
117
175
|
get cacheManager(): CacheManager;
|
|
118
176
|
protected _cache: Cache;
|
|
119
177
|
get cache(): Cache;
|
|
178
|
+
/**
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
120
181
|
set cache(cache: Cache);
|
|
121
182
|
protected _cli: AppCommand;
|
|
122
183
|
get cli(): AppCommand;
|
|
@@ -128,6 +189,11 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
128
189
|
protected _authManager: AuthManager;
|
|
129
190
|
get authManager(): AuthManager;
|
|
130
191
|
protected _locales: Locale;
|
|
192
|
+
/**
|
|
193
|
+
* This method is deprecated and should not be used.
|
|
194
|
+
* Use {@link #localeManager} instead.
|
|
195
|
+
* @deprecated
|
|
196
|
+
*/
|
|
131
197
|
get locales(): Locale;
|
|
132
198
|
get localeManager(): Locale;
|
|
133
199
|
protected _telemetry: Telemetry;
|
|
@@ -138,39 +204,88 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
138
204
|
get name(): string;
|
|
139
205
|
protected _dataSourceManager: DataSourceManager;
|
|
140
206
|
get dataSourceManager(): DataSourceManager;
|
|
207
|
+
/**
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
141
210
|
getMaintaining(): MaintainingCommandStatus;
|
|
211
|
+
/**
|
|
212
|
+
* @internal
|
|
213
|
+
*/
|
|
142
214
|
setMaintaining(_maintainingCommandStatus: MaintainingCommandStatus): void;
|
|
215
|
+
/**
|
|
216
|
+
* @internal
|
|
217
|
+
*/
|
|
143
218
|
setMaintainingMessage(message: string): void;
|
|
219
|
+
/**
|
|
220
|
+
* This method is deprecated and should not be used.
|
|
221
|
+
* Use {@link #this.version.get()} instead.
|
|
222
|
+
* @deprecated
|
|
223
|
+
*/
|
|
144
224
|
getVersion(): string;
|
|
145
225
|
/**
|
|
226
|
+
* This method is deprecated and should not be used.
|
|
227
|
+
* Use {@link #this.pm.addPreset()} instead.
|
|
146
228
|
* @deprecated
|
|
147
229
|
*/
|
|
148
230
|
plugin<O = any>(pluginClass: any, options?: O): void;
|
|
149
231
|
use<NewStateT = {}, NewContextT = {}>(middleware: Koa.Middleware<StateT & NewStateT, ContextT & NewContextT>, options?: ToposortOptions): this;
|
|
232
|
+
/**
|
|
233
|
+
* @internal
|
|
234
|
+
*/
|
|
150
235
|
callback(): (req: IncomingMessage, res: ServerResponse) => any;
|
|
236
|
+
/**
|
|
237
|
+
* This method is deprecated and should not be used.
|
|
238
|
+
* Use {@link #this.db.collection()} instead.
|
|
239
|
+
* @deprecated
|
|
240
|
+
*/
|
|
151
241
|
collection(options: CollectionOptions): import("@nocobase/database").Collection<any, any>;
|
|
242
|
+
/**
|
|
243
|
+
* This method is deprecated and should not be used.
|
|
244
|
+
* Use {@link #this.resourceManager.define()} instead.
|
|
245
|
+
* @deprecated
|
|
246
|
+
*/
|
|
152
247
|
resource(options: ResourceOptions): import("@nocobase/resourcer").Resource;
|
|
248
|
+
/**
|
|
249
|
+
* This method is deprecated and should not be used.
|
|
250
|
+
* Use {@link #this.resourceManager.registerActionHandlers()} instead.
|
|
251
|
+
* @deprecated
|
|
252
|
+
*/
|
|
153
253
|
actions(handlers: any, options?: ActionsOptions): void;
|
|
154
254
|
command(name: string, desc?: string, opts?: CommandOptions): AppCommand;
|
|
155
255
|
findCommand(name: string): Command;
|
|
156
|
-
|
|
256
|
+
/**
|
|
257
|
+
* @internal
|
|
258
|
+
*/
|
|
157
259
|
reInit(): Promise<void>;
|
|
158
|
-
load(options?:
|
|
159
|
-
reload(options?:
|
|
260
|
+
load(options?: LoadOptions): Promise<void>;
|
|
261
|
+
reload(options?: LoadOptions): Promise<void>;
|
|
160
262
|
/**
|
|
263
|
+
* This method is deprecated and should not be used.
|
|
264
|
+
* Use {@link this.pm.get()} instead.
|
|
161
265
|
* @deprecated
|
|
162
266
|
*/
|
|
163
267
|
getPlugin<P extends Plugin>(name: string | typeof Plugin): P;
|
|
268
|
+
/**
|
|
269
|
+
* This method is deprecated and should not be used.
|
|
270
|
+
* Use {@link this.runAsCLI()} instead.
|
|
271
|
+
* @deprecated
|
|
272
|
+
*/
|
|
164
273
|
parse(argv?: string[]): Promise<AppCommand>;
|
|
165
274
|
authenticate(): Promise<void>;
|
|
166
275
|
runCommand(command: string, ...args: any[]): Promise<AppCommand>;
|
|
167
276
|
runCommandThrowError(command: string, ...args: any[]): Promise<AppCommand>;
|
|
168
|
-
|
|
277
|
+
protected createCLI(): AppCommand;
|
|
278
|
+
/**
|
|
279
|
+
* @internal
|
|
280
|
+
*/
|
|
169
281
|
loadMigrations(options: any): Promise<{
|
|
170
282
|
beforeLoad: any[];
|
|
171
283
|
afterSync: any[];
|
|
172
284
|
afterLoad: any[];
|
|
173
285
|
}>;
|
|
286
|
+
/**
|
|
287
|
+
* @internal
|
|
288
|
+
*/
|
|
174
289
|
loadCoreMigrations(): Promise<{
|
|
175
290
|
beforeLoad: {
|
|
176
291
|
up: () => Promise<void>;
|
|
@@ -182,14 +297,26 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
182
297
|
up: () => Promise<void>;
|
|
183
298
|
};
|
|
184
299
|
}>;
|
|
300
|
+
/**
|
|
301
|
+
* @internal
|
|
302
|
+
*/
|
|
185
303
|
loadPluginCommands(): Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* @internal
|
|
306
|
+
*/
|
|
186
307
|
runAsCLI(argv?: string[], options?: ParseOptions & {
|
|
187
308
|
throwError?: boolean;
|
|
188
309
|
reqId?: string;
|
|
189
310
|
}): Promise<AppCommand>;
|
|
190
311
|
start(options?: StartOptions): Promise<void>;
|
|
312
|
+
/**
|
|
313
|
+
* @internal
|
|
314
|
+
*/
|
|
191
315
|
emitStartedEvent(options?: StartOptions): Promise<void>;
|
|
192
316
|
isStarted(): Promise<boolean>;
|
|
317
|
+
/**
|
|
318
|
+
* @internal
|
|
319
|
+
*/
|
|
193
320
|
tryReloadOrRestart(options?: StartOptions): Promise<void>;
|
|
194
321
|
restart(options?: StartOptions): Promise<void>;
|
|
195
322
|
stop(options?: any): Promise<void>;
|
|
@@ -201,6 +328,9 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
201
328
|
appName: string;
|
|
202
329
|
name: string;
|
|
203
330
|
};
|
|
331
|
+
/**
|
|
332
|
+
* @internal
|
|
333
|
+
*/
|
|
204
334
|
reInitEvents(): void;
|
|
205
335
|
createLogger(options: LoggerOptions): import("winston").Logger;
|
|
206
336
|
protected init(): void;
|
package/lib/application.js
CHANGED
|
@@ -59,6 +59,7 @@ var import_plugin_manager = require("./plugin-manager");
|
|
|
59
59
|
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
60
60
|
var import_package = __toESM(require("../package.json"));
|
|
61
61
|
var import_main_data_source = require("./main-data-source");
|
|
62
|
+
var import_validate_filter_params = __toESM(require("./middlewares/validate-filter-params"));
|
|
62
63
|
const _Application = class _Application extends import_koa.default {
|
|
63
64
|
constructor(options) {
|
|
64
65
|
super();
|
|
@@ -68,25 +69,50 @@ const _Application = class _Application extends import_koa.default {
|
|
|
68
69
|
this.init();
|
|
69
70
|
this._appSupervisor.addApp(this);
|
|
70
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
71
75
|
stopped = false;
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
72
79
|
ready = false;
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
73
83
|
rawOptions;
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
74
87
|
activatedCommand = null;
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
75
91
|
running = false;
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
76
95
|
perfHistograms = /* @__PURE__ */ new Map();
|
|
77
96
|
plugins = /* @__PURE__ */ new Map();
|
|
78
97
|
_appSupervisor = import_app_supervisor.AppSupervisor.getInstance();
|
|
79
98
|
_started;
|
|
99
|
+
_logger;
|
|
80
100
|
_authenticated = false;
|
|
81
101
|
_maintaining = false;
|
|
82
102
|
_maintainingCommandStatus;
|
|
83
103
|
_maintainingStatusBeforeCommand;
|
|
84
104
|
_actionCommand;
|
|
85
105
|
_loaded;
|
|
106
|
+
/**
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
86
109
|
get loaded() {
|
|
87
110
|
return this._loaded;
|
|
88
111
|
}
|
|
89
112
|
_maintainingMessage;
|
|
113
|
+
/**
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
90
116
|
get maintainingMessage() {
|
|
91
117
|
return this._maintainingMessage;
|
|
92
118
|
}
|
|
@@ -104,10 +130,17 @@ const _Application = class _Application extends import_koa.default {
|
|
|
104
130
|
}
|
|
105
131
|
return this.mainDataSource.collectionManager.db;
|
|
106
132
|
}
|
|
107
|
-
_logger;
|
|
108
133
|
get logger() {
|
|
109
134
|
return this._logger;
|
|
110
135
|
}
|
|
136
|
+
get resourceManager() {
|
|
137
|
+
return this.mainDataSource.resourceManager;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* This method is deprecated and should not be used.
|
|
141
|
+
* Use {@link #resourceManager} instead.
|
|
142
|
+
* @deprecated
|
|
143
|
+
*/
|
|
111
144
|
get resourcer() {
|
|
112
145
|
return this.mainDataSource.resourceManager;
|
|
113
146
|
}
|
|
@@ -119,6 +152,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
119
152
|
get cache() {
|
|
120
153
|
return this._cache;
|
|
121
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
122
158
|
set cache(cache) {
|
|
123
159
|
this._cache = cache;
|
|
124
160
|
}
|
|
@@ -142,6 +178,11 @@ const _Application = class _Application extends import_koa.default {
|
|
|
142
178
|
return this._authManager;
|
|
143
179
|
}
|
|
144
180
|
_locales;
|
|
181
|
+
/**
|
|
182
|
+
* This method is deprecated and should not be used.
|
|
183
|
+
* Use {@link #localeManager} instead.
|
|
184
|
+
* @deprecated
|
|
185
|
+
*/
|
|
145
186
|
get locales() {
|
|
146
187
|
return this._locales;
|
|
147
188
|
}
|
|
@@ -166,9 +207,15 @@ const _Application = class _Application extends import_koa.default {
|
|
|
166
207
|
get dataSourceManager() {
|
|
167
208
|
return this._dataSourceManager;
|
|
168
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
169
213
|
getMaintaining() {
|
|
170
214
|
return this._maintainingCommandStatus;
|
|
171
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* @internal
|
|
218
|
+
*/
|
|
172
219
|
setMaintaining(_maintainingCommandStatus) {
|
|
173
220
|
this._maintainingCommandStatus = _maintainingCommandStatus;
|
|
174
221
|
this.emit("maintaining", _maintainingCommandStatus);
|
|
@@ -178,6 +225,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
178
225
|
}
|
|
179
226
|
this._maintaining = true;
|
|
180
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* @internal
|
|
230
|
+
*/
|
|
181
231
|
setMaintainingMessage(message) {
|
|
182
232
|
this._maintainingMessage = message;
|
|
183
233
|
this.emit("maintainingMessageChanged", {
|
|
@@ -185,10 +235,17 @@ const _Application = class _Application extends import_koa.default {
|
|
|
185
235
|
maintainingStatus: this._maintainingCommandStatus
|
|
186
236
|
});
|
|
187
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* This method is deprecated and should not be used.
|
|
240
|
+
* Use {@link #this.version.get()} instead.
|
|
241
|
+
* @deprecated
|
|
242
|
+
*/
|
|
188
243
|
getVersion() {
|
|
189
244
|
return import_package.default.version;
|
|
190
245
|
}
|
|
191
246
|
/**
|
|
247
|
+
* This method is deprecated and should not be used.
|
|
248
|
+
* Use {@link #this.pm.addPreset()} instead.
|
|
192
249
|
* @deprecated
|
|
193
250
|
*/
|
|
194
251
|
plugin(pluginClass, options) {
|
|
@@ -200,6 +257,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
200
257
|
this.middleware.add(middleware, options);
|
|
201
258
|
return this;
|
|
202
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* @internal
|
|
262
|
+
*/
|
|
203
263
|
callback() {
|
|
204
264
|
const fn = (0, import_koa_compose.default)(this.middleware.nodes);
|
|
205
265
|
if (!this.listenerCount("error"))
|
|
@@ -209,14 +269,29 @@ const _Application = class _Application extends import_koa.default {
|
|
|
209
269
|
return this.handleRequest(ctx, fn);
|
|
210
270
|
};
|
|
211
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* This method is deprecated and should not be used.
|
|
274
|
+
* Use {@link #this.db.collection()} instead.
|
|
275
|
+
* @deprecated
|
|
276
|
+
*/
|
|
212
277
|
collection(options) {
|
|
213
278
|
return this.db.collection(options);
|
|
214
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* This method is deprecated and should not be used.
|
|
282
|
+
* Use {@link #this.resourceManager.define()} instead.
|
|
283
|
+
* @deprecated
|
|
284
|
+
*/
|
|
215
285
|
resource(options) {
|
|
216
|
-
return this.
|
|
286
|
+
return this.resourceManager.define(options);
|
|
217
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* This method is deprecated and should not be used.
|
|
290
|
+
* Use {@link #this.resourceManager.registerActionHandlers()} instead.
|
|
291
|
+
* @deprecated
|
|
292
|
+
*/
|
|
218
293
|
actions(handlers, options) {
|
|
219
|
-
return this.
|
|
294
|
+
return this.resourceManager.registerActionHandlers(handlers);
|
|
220
295
|
}
|
|
221
296
|
command(name, desc, opts) {
|
|
222
297
|
return this.cli.command(name, desc, opts).allowUnknownOption();
|
|
@@ -224,8 +299,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
224
299
|
findCommand(name) {
|
|
225
300
|
return this.cli._findCommand(name);
|
|
226
301
|
}
|
|
227
|
-
|
|
228
|
-
|
|
302
|
+
/**
|
|
303
|
+
* @internal
|
|
304
|
+
*/
|
|
229
305
|
async reInit() {
|
|
230
306
|
if (!this._loaded) {
|
|
231
307
|
return;
|
|
@@ -300,11 +376,18 @@ const _Application = class _Application extends import_koa.default {
|
|
|
300
376
|
this.log.debug(`finish reload`, { method: "reload" });
|
|
301
377
|
}
|
|
302
378
|
/**
|
|
379
|
+
* This method is deprecated and should not be used.
|
|
380
|
+
* Use {@link this.pm.get()} instead.
|
|
303
381
|
* @deprecated
|
|
304
382
|
*/
|
|
305
383
|
getPlugin(name) {
|
|
306
384
|
return this.pm.get(name);
|
|
307
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* This method is deprecated and should not be used.
|
|
388
|
+
* Use {@link this.runAsCLI()} instead.
|
|
389
|
+
* @deprecated
|
|
390
|
+
*/
|
|
308
391
|
async parse(argv = process.argv) {
|
|
309
392
|
return this.runAsCLI(argv);
|
|
310
393
|
}
|
|
@@ -323,7 +406,7 @@ const _Application = class _Application extends import_koa.default {
|
|
|
323
406
|
async runCommandThrowError(command, ...args) {
|
|
324
407
|
return await this.runAsCLI([command, ...args], { from: "user", throwError: true });
|
|
325
408
|
}
|
|
326
|
-
|
|
409
|
+
createCLI() {
|
|
327
410
|
const command = new import_app_command.AppCommand("nocobase").usage("[command] [options]").hook("preAction", async (_, actionCommand) => {
|
|
328
411
|
this._actionCommand = actionCommand;
|
|
329
412
|
this.activatedCommand = {
|
|
@@ -354,6 +437,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
354
437
|
});
|
|
355
438
|
return command;
|
|
356
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* @internal
|
|
442
|
+
*/
|
|
357
443
|
async loadMigrations(options) {
|
|
358
444
|
const { directory, context, namespace } = options;
|
|
359
445
|
const migrations = {
|
|
@@ -379,6 +465,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
379
465
|
}
|
|
380
466
|
return migrations;
|
|
381
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* @internal
|
|
470
|
+
*/
|
|
382
471
|
async loadCoreMigrations() {
|
|
383
472
|
const migrations = await this.loadMigrations({
|
|
384
473
|
directory: (0, import_path.resolve)(__dirname, "migrations"),
|
|
@@ -408,15 +497,21 @@ const _Application = class _Application extends import_koa.default {
|
|
|
408
497
|
}
|
|
409
498
|
};
|
|
410
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
* @internal
|
|
502
|
+
*/
|
|
411
503
|
async loadPluginCommands() {
|
|
412
504
|
this.log.debug("load plugin commands");
|
|
413
505
|
await this.pm.loadCommands();
|
|
414
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* @internal
|
|
509
|
+
*/
|
|
415
510
|
async runAsCLI(argv = process.argv, options) {
|
|
416
511
|
if (this.activatedCommand) {
|
|
417
512
|
return;
|
|
418
513
|
}
|
|
419
|
-
if (options.reqId) {
|
|
514
|
+
if (options == null ? void 0 : options.reqId) {
|
|
420
515
|
this.context.reqId = options.reqId;
|
|
421
516
|
this._logger = this._logger.child({ reqId: this.context.reqId });
|
|
422
517
|
}
|
|
@@ -445,6 +540,8 @@ const _Application = class _Application extends import_koa.default {
|
|
|
445
540
|
});
|
|
446
541
|
if (options == null ? void 0 : options.throwError) {
|
|
447
542
|
throw error;
|
|
543
|
+
} else {
|
|
544
|
+
this.log.error(error);
|
|
448
545
|
}
|
|
449
546
|
} finally {
|
|
450
547
|
const _actionCommand = this._actionCommand;
|
|
@@ -482,6 +579,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
482
579
|
await this.emitStartedEvent(options);
|
|
483
580
|
this.stopped = false;
|
|
484
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* @internal
|
|
584
|
+
*/
|
|
485
585
|
async emitStartedEvent(options = {}) {
|
|
486
586
|
await this.emitAsync("__started", this, {
|
|
487
587
|
maintainingStatus: import_lodash.default.cloneDeep(this._maintainingCommandStatus),
|
|
@@ -491,6 +591,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
491
591
|
async isStarted() {
|
|
492
592
|
return this._started;
|
|
493
593
|
}
|
|
594
|
+
/**
|
|
595
|
+
* @internal
|
|
596
|
+
*/
|
|
494
597
|
async tryReloadOrRestart(options = {}) {
|
|
495
598
|
if (this._started) {
|
|
496
599
|
await this.restart(options);
|
|
@@ -620,6 +723,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
620
723
|
name: this.name
|
|
621
724
|
};
|
|
622
725
|
}
|
|
726
|
+
/**
|
|
727
|
+
* @internal
|
|
728
|
+
*/
|
|
623
729
|
reInitEvents() {
|
|
624
730
|
for (const eventName of this.eventNames()) {
|
|
625
731
|
for (const listener of this.listeners(eventName)) {
|
|
@@ -657,10 +763,11 @@ const _Application = class _Application extends import_koa.default {
|
|
|
657
763
|
}
|
|
658
764
|
this.createMainDataSource(options);
|
|
659
765
|
this._cronJobManager = new import_cron_job_manager.CronJobManager(this);
|
|
660
|
-
this._cli = this.
|
|
766
|
+
this._cli = this.createCLI();
|
|
661
767
|
this._i18n = (0, import_helper.createI18n)(options);
|
|
662
768
|
this.context.db = this.db;
|
|
663
|
-
this.context.resourcer = this.
|
|
769
|
+
this.context.resourcer = this.resourceManager;
|
|
770
|
+
this.context.resourceManager = this.resourceManager;
|
|
664
771
|
this.context.cacheManager = this._cacheManager;
|
|
665
772
|
this.context.cache = this._cache;
|
|
666
773
|
const plugins = this._pm ? this._pm.options.plugins : options.plugins;
|
|
@@ -678,15 +785,12 @@ const _Application = class _Application extends import_koa.default {
|
|
|
678
785
|
default: "basic",
|
|
679
786
|
...this.options.authManager || {}
|
|
680
787
|
});
|
|
681
|
-
this.
|
|
788
|
+
this.resourceManager.define({
|
|
682
789
|
name: "auth",
|
|
683
790
|
actions: import_auth.actions
|
|
684
791
|
});
|
|
685
792
|
this._dataSourceManager.use(this._authManager.middleware(), { tag: "auth" });
|
|
686
|
-
this.
|
|
687
|
-
if (this.options.acl !== false) {
|
|
688
|
-
this.resourcer.use(this.acl.middleware(), { tag: "acl", after: ["auth"] });
|
|
689
|
-
}
|
|
793
|
+
this._dataSourceManager.use(import_validate_filter_params.default, { tag: "validate-filter-params", before: ["auth"] });
|
|
690
794
|
this._locales = new import_locale.Locale((0, import_helper.createAppProxy)(this));
|
|
691
795
|
if (options.perfHooks) {
|
|
692
796
|
(0, import_helper.enablePerfHooks)(this);
|
|
@@ -703,7 +807,8 @@ const _Application = class _Application extends import_koa.default {
|
|
|
703
807
|
name: "main",
|
|
704
808
|
database: this.createDatabase(options),
|
|
705
809
|
acl: (0, import_acl.createACL)(),
|
|
706
|
-
resourceManager: (0, import_helper.createResourcer)(options)
|
|
810
|
+
resourceManager: (0, import_helper.createResourcer)(options),
|
|
811
|
+
useACL: options.acl
|
|
707
812
|
});
|
|
708
813
|
this._dataSourceManager = new import_data_source_manager.DataSourceManager();
|
|
709
814
|
this.dataSourceManager.dataSources.set("main", mainDataSourceInstance);
|
package/lib/commands/console.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(console_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(console_exports);
|
|
24
24
|
const REPL = require("repl");
|
|
25
25
|
var console_default = /* @__PURE__ */ __name((app) => {
|
|
26
|
-
app.command("console").action(async () => {
|
|
26
|
+
app.command("console").preload().action(async () => {
|
|
27
27
|
await app.start();
|
|
28
28
|
const repl = REPL.start("nocobase > ").context.app = app;
|
|
29
29
|
repl.on("exit", async function(err) {
|
package/lib/commands/index.js
CHANGED
|
@@ -43,7 +43,9 @@ var import_restart = __toESM(require("./restart"));
|
|
|
43
43
|
var import_start = __toESM(require("./start"));
|
|
44
44
|
var import_stop = __toESM(require("./stop"));
|
|
45
45
|
var import_upgrade = __toESM(require("./upgrade"));
|
|
46
|
+
var import_console = __toESM(require("./console"));
|
|
46
47
|
function registerCli(app) {
|
|
48
|
+
(0, import_console.default)(app);
|
|
47
49
|
(0, import_db_auth.default)(app);
|
|
48
50
|
(0, import_create_migration.default)(app);
|
|
49
51
|
(0, import_db_clean.default)(app);
|
package/lib/commands/pm.js
CHANGED
|
@@ -42,7 +42,7 @@ var pm_default = /* @__PURE__ */ __name((app) => {
|
|
|
42
42
|
try {
|
|
43
43
|
await app.pm.addViaCLI(name, import_lodash.default.cloneDeep(options));
|
|
44
44
|
} catch (error) {
|
|
45
|
-
throw new import_plugin_command_error.PluginCommandError(`Failed to add plugin:
|
|
45
|
+
throw new import_plugin_command_error.PluginCommandError(`Failed to add plugin`, { cause: error });
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
pm.command("update").ipc().argument("<packageName>").option("--path [path]").option("--url [url]").option("--registry [registry]").option("--auth-token [authToken]").option("--version [version]").action(async (packageName, options) => {
|
|
@@ -52,21 +52,28 @@ var pm_default = /* @__PURE__ */ __name((app) => {
|
|
|
52
52
|
packageName
|
|
53
53
|
});
|
|
54
54
|
} catch (error) {
|
|
55
|
-
throw new import_plugin_command_error.PluginCommandError(`Failed to update plugin:
|
|
55
|
+
throw new import_plugin_command_error.PluginCommandError(`Failed to update plugin`, { cause: error });
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
pm.command("enable-all").ipc().preload().action(async () => {
|
|
59
|
+
try {
|
|
60
|
+
await app.pm.enable("*");
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw new import_plugin_command_error.PluginCommandError(`Failed to enable plugin`, { cause: error });
|
|
56
63
|
}
|
|
57
64
|
});
|
|
58
65
|
pm.command("enable").ipc().preload().arguments("<plugins...>").action(async (plugins) => {
|
|
59
66
|
try {
|
|
60
67
|
await app.pm.enable(plugins);
|
|
61
68
|
} catch (error) {
|
|
62
|
-
throw new import_plugin_command_error.PluginCommandError(`Failed to enable plugin:
|
|
69
|
+
throw new import_plugin_command_error.PluginCommandError(`Failed to enable plugin`, { cause: error });
|
|
63
70
|
}
|
|
64
71
|
});
|
|
65
72
|
pm.command("disable").ipc().preload().arguments("<plugins...>").action(async (plugins) => {
|
|
66
73
|
try {
|
|
67
74
|
await app.pm.disable(plugins);
|
|
68
75
|
} catch (error) {
|
|
69
|
-
throw new import_plugin_command_error.PluginCommandError(`Failed to disable plugin:
|
|
76
|
+
throw new import_plugin_command_error.PluginCommandError(`Failed to disable plugin`, { cause: error });
|
|
70
77
|
}
|
|
71
78
|
});
|
|
72
79
|
pm.command("remove").auth().arguments("<plugins...>").option("--force").option("--remove-dir").action(async (plugins, options) => {
|