@nocobase/server 0.20.0-alpha.9 → 0.21.0-alpha.2
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 +109 -4
- package/lib/application.js +117 -14
- package/lib/commands/console.js +1 -1
- package/lib/commands/index.js +2 -0
- package/lib/commands/pm.js +4 -4
- package/lib/commands/start.js +19 -2
- package/lib/gateway/index.js +10 -7
- package/lib/helper.js +1 -11
- package/lib/locale/locale.js +3 -0
- 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 +88 -1
- package/lib/plugin-manager/plugin-manager.js +107 -6
- 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
|
@@ -83,19 +83,41 @@ export type MaintainingCommandStatus = {
|
|
|
83
83
|
};
|
|
84
84
|
export declare class Application<StateT = DefaultState, ContextT = DefaultContext> extends Koa implements AsyncEmitter {
|
|
85
85
|
options: ApplicationOptions;
|
|
86
|
+
/**
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
86
89
|
middleware: any;
|
|
90
|
+
/**
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
87
93
|
stopped: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
88
97
|
ready: boolean;
|
|
89
98
|
emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
|
|
99
|
+
/**
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
90
102
|
rawOptions: ApplicationOptions;
|
|
103
|
+
/**
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
91
106
|
activatedCommand: {
|
|
92
107
|
name: string;
|
|
93
108
|
};
|
|
109
|
+
/**
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
94
112
|
running: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
95
116
|
perfHistograms: Map<string, RecordableHistogram>;
|
|
96
117
|
protected plugins: Map<string, Plugin<any>>;
|
|
97
118
|
protected _appSupervisor: AppSupervisor;
|
|
98
119
|
protected _started: boolean;
|
|
120
|
+
protected _logger: SystemLogger;
|
|
99
121
|
private _authenticated;
|
|
100
122
|
private _maintaining;
|
|
101
123
|
private _maintainingCommandStatus;
|
|
@@ -103,20 +125,34 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
103
125
|
private _actionCommand;
|
|
104
126
|
constructor(options: ApplicationOptions);
|
|
105
127
|
protected _loaded: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
106
131
|
get loaded(): boolean;
|
|
107
132
|
private _maintainingMessage;
|
|
133
|
+
/**
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
108
136
|
get maintainingMessage(): string;
|
|
109
137
|
protected _cronJobManager: CronJobManager;
|
|
110
138
|
get cronJobManager(): CronJobManager;
|
|
111
139
|
get mainDataSource(): SequelizeDataSource;
|
|
112
140
|
get db(): Database;
|
|
113
|
-
protected _logger: SystemLogger;
|
|
114
141
|
get logger(): SystemLogger;
|
|
115
|
-
get
|
|
142
|
+
get resourceManager(): import("@nocobase/resourcer").ResourceManager;
|
|
143
|
+
/**
|
|
144
|
+
* This method is deprecated and should not be used.
|
|
145
|
+
* Use {@link #resourceManager} instead.
|
|
146
|
+
* @deprecated
|
|
147
|
+
*/
|
|
148
|
+
get resourcer(): import("@nocobase/resourcer").ResourceManager;
|
|
116
149
|
protected _cacheManager: CacheManager;
|
|
117
150
|
get cacheManager(): CacheManager;
|
|
118
151
|
protected _cache: Cache;
|
|
119
152
|
get cache(): Cache;
|
|
153
|
+
/**
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
120
156
|
set cache(cache: Cache);
|
|
121
157
|
protected _cli: AppCommand;
|
|
122
158
|
get cli(): AppCommand;
|
|
@@ -128,6 +164,11 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
128
164
|
protected _authManager: AuthManager;
|
|
129
165
|
get authManager(): AuthManager;
|
|
130
166
|
protected _locales: Locale;
|
|
167
|
+
/**
|
|
168
|
+
* This method is deprecated and should not be used.
|
|
169
|
+
* Use {@link #localeManager} instead.
|
|
170
|
+
* @deprecated
|
|
171
|
+
*/
|
|
131
172
|
get locales(): Locale;
|
|
132
173
|
get localeManager(): Locale;
|
|
133
174
|
protected _telemetry: Telemetry;
|
|
@@ -138,39 +179,88 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
138
179
|
get name(): string;
|
|
139
180
|
protected _dataSourceManager: DataSourceManager;
|
|
140
181
|
get dataSourceManager(): DataSourceManager;
|
|
182
|
+
/**
|
|
183
|
+
* @internal
|
|
184
|
+
*/
|
|
141
185
|
getMaintaining(): MaintainingCommandStatus;
|
|
186
|
+
/**
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
142
189
|
setMaintaining(_maintainingCommandStatus: MaintainingCommandStatus): void;
|
|
190
|
+
/**
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
143
193
|
setMaintainingMessage(message: string): void;
|
|
194
|
+
/**
|
|
195
|
+
* This method is deprecated and should not be used.
|
|
196
|
+
* Use {@link #this.version.get()} instead.
|
|
197
|
+
* @deprecated
|
|
198
|
+
*/
|
|
144
199
|
getVersion(): string;
|
|
145
200
|
/**
|
|
201
|
+
* This method is deprecated and should not be used.
|
|
202
|
+
* Use {@link #this.pm.addPreset()} instead.
|
|
146
203
|
* @deprecated
|
|
147
204
|
*/
|
|
148
205
|
plugin<O = any>(pluginClass: any, options?: O): void;
|
|
149
206
|
use<NewStateT = {}, NewContextT = {}>(middleware: Koa.Middleware<StateT & NewStateT, ContextT & NewContextT>, options?: ToposortOptions): this;
|
|
207
|
+
/**
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
150
210
|
callback(): (req: IncomingMessage, res: ServerResponse) => any;
|
|
211
|
+
/**
|
|
212
|
+
* This method is deprecated and should not be used.
|
|
213
|
+
* Use {@link #this.db.collection()} instead.
|
|
214
|
+
* @deprecated
|
|
215
|
+
*/
|
|
151
216
|
collection(options: CollectionOptions): import("@nocobase/database").Collection<any, any>;
|
|
217
|
+
/**
|
|
218
|
+
* This method is deprecated and should not be used.
|
|
219
|
+
* Use {@link #this.resourceManager.define()} instead.
|
|
220
|
+
* @deprecated
|
|
221
|
+
*/
|
|
152
222
|
resource(options: ResourceOptions): import("@nocobase/resourcer").Resource;
|
|
223
|
+
/**
|
|
224
|
+
* This method is deprecated and should not be used.
|
|
225
|
+
* Use {@link #this.resourceManager.registerActionHandlers()} instead.
|
|
226
|
+
* @deprecated
|
|
227
|
+
*/
|
|
153
228
|
actions(handlers: any, options?: ActionsOptions): void;
|
|
154
229
|
command(name: string, desc?: string, opts?: CommandOptions): AppCommand;
|
|
155
230
|
findCommand(name: string): Command;
|
|
156
|
-
|
|
231
|
+
/**
|
|
232
|
+
* @internal
|
|
233
|
+
*/
|
|
157
234
|
reInit(): Promise<void>;
|
|
158
235
|
load(options?: any): Promise<void>;
|
|
159
236
|
reload(options?: any): Promise<void>;
|
|
160
237
|
/**
|
|
238
|
+
* This method is deprecated and should not be used.
|
|
239
|
+
* Use {@link this.pm.get()} instead.
|
|
161
240
|
* @deprecated
|
|
162
241
|
*/
|
|
163
242
|
getPlugin<P extends Plugin>(name: string | typeof Plugin): P;
|
|
243
|
+
/**
|
|
244
|
+
* This method is deprecated and should not be used.
|
|
245
|
+
* Use {@link this.runAsCLI()} instead.
|
|
246
|
+
* @deprecated
|
|
247
|
+
*/
|
|
164
248
|
parse(argv?: string[]): Promise<AppCommand>;
|
|
165
249
|
authenticate(): Promise<void>;
|
|
166
250
|
runCommand(command: string, ...args: any[]): Promise<AppCommand>;
|
|
167
251
|
runCommandThrowError(command: string, ...args: any[]): Promise<AppCommand>;
|
|
168
|
-
|
|
252
|
+
protected createCLI(): AppCommand;
|
|
253
|
+
/**
|
|
254
|
+
* @internal
|
|
255
|
+
*/
|
|
169
256
|
loadMigrations(options: any): Promise<{
|
|
170
257
|
beforeLoad: any[];
|
|
171
258
|
afterSync: any[];
|
|
172
259
|
afterLoad: any[];
|
|
173
260
|
}>;
|
|
261
|
+
/**
|
|
262
|
+
* @internal
|
|
263
|
+
*/
|
|
174
264
|
loadCoreMigrations(): Promise<{
|
|
175
265
|
beforeLoad: {
|
|
176
266
|
up: () => Promise<void>;
|
|
@@ -182,14 +272,26 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
182
272
|
up: () => Promise<void>;
|
|
183
273
|
};
|
|
184
274
|
}>;
|
|
275
|
+
/**
|
|
276
|
+
* @internal
|
|
277
|
+
*/
|
|
185
278
|
loadPluginCommands(): Promise<void>;
|
|
279
|
+
/**
|
|
280
|
+
* @internal
|
|
281
|
+
*/
|
|
186
282
|
runAsCLI(argv?: string[], options?: ParseOptions & {
|
|
187
283
|
throwError?: boolean;
|
|
188
284
|
reqId?: string;
|
|
189
285
|
}): Promise<AppCommand>;
|
|
190
286
|
start(options?: StartOptions): Promise<void>;
|
|
287
|
+
/**
|
|
288
|
+
* @internal
|
|
289
|
+
*/
|
|
191
290
|
emitStartedEvent(options?: StartOptions): Promise<void>;
|
|
192
291
|
isStarted(): Promise<boolean>;
|
|
292
|
+
/**
|
|
293
|
+
* @internal
|
|
294
|
+
*/
|
|
193
295
|
tryReloadOrRestart(options?: StartOptions): Promise<void>;
|
|
194
296
|
restart(options?: StartOptions): Promise<void>;
|
|
195
297
|
stop(options?: any): Promise<void>;
|
|
@@ -201,6 +303,9 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
201
303
|
appName: string;
|
|
202
304
|
name: string;
|
|
203
305
|
};
|
|
306
|
+
/**
|
|
307
|
+
* @internal
|
|
308
|
+
*/
|
|
204
309
|
reInitEvents(): void;
|
|
205
310
|
createLogger(options: LoggerOptions): import("winston").Logger;
|
|
206
311
|
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,10 +497,16 @@ 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;
|
|
@@ -482,6 +577,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
482
577
|
await this.emitStartedEvent(options);
|
|
483
578
|
this.stopped = false;
|
|
484
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* @internal
|
|
582
|
+
*/
|
|
485
583
|
async emitStartedEvent(options = {}) {
|
|
486
584
|
await this.emitAsync("__started", this, {
|
|
487
585
|
maintainingStatus: import_lodash.default.cloneDeep(this._maintainingCommandStatus),
|
|
@@ -491,6 +589,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
491
589
|
async isStarted() {
|
|
492
590
|
return this._started;
|
|
493
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* @internal
|
|
594
|
+
*/
|
|
494
595
|
async tryReloadOrRestart(options = {}) {
|
|
495
596
|
if (this._started) {
|
|
496
597
|
await this.restart(options);
|
|
@@ -620,6 +721,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
620
721
|
name: this.name
|
|
621
722
|
};
|
|
622
723
|
}
|
|
724
|
+
/**
|
|
725
|
+
* @internal
|
|
726
|
+
*/
|
|
623
727
|
reInitEvents() {
|
|
624
728
|
for (const eventName of this.eventNames()) {
|
|
625
729
|
for (const listener of this.listeners(eventName)) {
|
|
@@ -657,10 +761,11 @@ const _Application = class _Application extends import_koa.default {
|
|
|
657
761
|
}
|
|
658
762
|
this.createMainDataSource(options);
|
|
659
763
|
this._cronJobManager = new import_cron_job_manager.CronJobManager(this);
|
|
660
|
-
this._cli = this.
|
|
764
|
+
this._cli = this.createCLI();
|
|
661
765
|
this._i18n = (0, import_helper.createI18n)(options);
|
|
662
766
|
this.context.db = this.db;
|
|
663
|
-
this.context.resourcer = this.
|
|
767
|
+
this.context.resourcer = this.resourceManager;
|
|
768
|
+
this.context.resourceManager = this.resourceManager;
|
|
664
769
|
this.context.cacheManager = this._cacheManager;
|
|
665
770
|
this.context.cache = this._cache;
|
|
666
771
|
const plugins = this._pm ? this._pm.options.plugins : options.plugins;
|
|
@@ -678,15 +783,12 @@ const _Application = class _Application extends import_koa.default {
|
|
|
678
783
|
default: "basic",
|
|
679
784
|
...this.options.authManager || {}
|
|
680
785
|
});
|
|
681
|
-
this.
|
|
786
|
+
this.resourceManager.define({
|
|
682
787
|
name: "auth",
|
|
683
788
|
actions: import_auth.actions
|
|
684
789
|
});
|
|
685
790
|
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
|
-
}
|
|
791
|
+
this._dataSourceManager.use(import_validate_filter_params.default, { tag: "validate-filter-params", before: ["auth"] });
|
|
690
792
|
this._locales = new import_locale.Locale((0, import_helper.createAppProxy)(this));
|
|
691
793
|
if (options.perfHooks) {
|
|
692
794
|
(0, import_helper.enablePerfHooks)(this);
|
|
@@ -703,7 +805,8 @@ const _Application = class _Application extends import_koa.default {
|
|
|
703
805
|
name: "main",
|
|
704
806
|
database: this.createDatabase(options),
|
|
705
807
|
acl: (0, import_acl.createACL)(),
|
|
706
|
-
resourceManager: (0, import_helper.createResourcer)(options)
|
|
808
|
+
resourceManager: (0, import_helper.createResourcer)(options),
|
|
809
|
+
useACL: options.acl
|
|
707
810
|
});
|
|
708
811
|
this._dataSourceManager = new import_data_source_manager.DataSourceManager();
|
|
709
812
|
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,21 @@ 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
56
|
}
|
|
57
57
|
});
|
|
58
58
|
pm.command("enable").ipc().preload().arguments("<plugins...>").action(async (plugins) => {
|
|
59
59
|
try {
|
|
60
60
|
await app.pm.enable(plugins);
|
|
61
61
|
} catch (error) {
|
|
62
|
-
throw new import_plugin_command_error.PluginCommandError(`Failed to enable plugin:
|
|
62
|
+
throw new import_plugin_command_error.PluginCommandError(`Failed to enable plugin`, { cause: error });
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
pm.command("disable").ipc().preload().arguments("<plugins...>").action(async (plugins) => {
|
|
66
66
|
try {
|
|
67
67
|
await app.pm.disable(plugins);
|
|
68
68
|
} catch (error) {
|
|
69
|
-
throw new import_plugin_command_error.PluginCommandError(`Failed to disable plugin:
|
|
69
|
+
throw new import_plugin_command_error.PluginCommandError(`Failed to disable plugin`, { cause: error });
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
pm.command("remove").auth().arguments("<plugins...>").option("--force").option("--remove-dir").action(async (plugins, options) => {
|
package/lib/commands/start.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
8
|
var __export = (target, all) => {
|
|
@@ -15,18 +17,33 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var start_exports = {};
|
|
20
30
|
__export(start_exports, {
|
|
21
31
|
default: () => start_default
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(start_exports);
|
|
34
|
+
var import_utils = require("@nocobase/utils");
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_path = require("path");
|
|
24
37
|
var import_application_not_install = require("../errors/application-not-install");
|
|
25
38
|
var start_default = /* @__PURE__ */ __name((app) => {
|
|
26
39
|
app.command("start").auth().option("--db-sync").option("--quickstart").action(async (...cliArgs) => {
|
|
27
40
|
const [options] = cliArgs;
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
const file = (0, import_path.resolve)(process.cwd(), "storage/app-upgrading");
|
|
42
|
+
const upgrading = await (0, import_utils.fsExists)(file);
|
|
43
|
+
if (upgrading) {
|
|
44
|
+
await app.upgrade();
|
|
45
|
+
await import_fs.default.promises.rm(file);
|
|
46
|
+
} else if (options.quickstart) {
|
|
30
47
|
if (await app.isInstalled()) {
|
|
31
48
|
await app.upgrade();
|
|
32
49
|
} else {
|