@nocobase/server 0.20.0-alpha.8 → 0.21.0-alpha.1
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 +102 -3
- package/lib/application.js +100 -5
- package/lib/commands/console.js +1 -1
- package/lib/commands/index.js +2 -0
- package/lib/commands/pm.js +4 -4
- package/lib/gateway/index.js +10 -7
- package/lib/locale/locale.js +3 -0
- package/lib/locale/resource.js +4 -1
- 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 +98 -5
- 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,28 @@ 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
142
|
get resourcer(): import("@nocobase/data-source-manager").ResourceManager;
|
|
116
143
|
protected _cacheManager: CacheManager;
|
|
117
144
|
get cacheManager(): CacheManager;
|
|
118
145
|
protected _cache: Cache;
|
|
119
146
|
get cache(): Cache;
|
|
147
|
+
/**
|
|
148
|
+
* @internal
|
|
149
|
+
*/
|
|
120
150
|
set cache(cache: Cache);
|
|
121
151
|
protected _cli: AppCommand;
|
|
122
152
|
get cli(): AppCommand;
|
|
@@ -128,6 +158,11 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
128
158
|
protected _authManager: AuthManager;
|
|
129
159
|
get authManager(): AuthManager;
|
|
130
160
|
protected _locales: Locale;
|
|
161
|
+
/**
|
|
162
|
+
* This method is deprecated and should not be used.
|
|
163
|
+
* Use {@link #localeManager} instead.
|
|
164
|
+
* @deprecated
|
|
165
|
+
*/
|
|
131
166
|
get locales(): Locale;
|
|
132
167
|
get localeManager(): Locale;
|
|
133
168
|
protected _telemetry: Telemetry;
|
|
@@ -138,39 +173,88 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
138
173
|
get name(): string;
|
|
139
174
|
protected _dataSourceManager: DataSourceManager;
|
|
140
175
|
get dataSourceManager(): DataSourceManager;
|
|
176
|
+
/**
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
141
179
|
getMaintaining(): MaintainingCommandStatus;
|
|
180
|
+
/**
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
142
183
|
setMaintaining(_maintainingCommandStatus: MaintainingCommandStatus): void;
|
|
184
|
+
/**
|
|
185
|
+
* @internal
|
|
186
|
+
*/
|
|
143
187
|
setMaintainingMessage(message: string): void;
|
|
188
|
+
/**
|
|
189
|
+
* This method is deprecated and should not be used.
|
|
190
|
+
* Use {@link #this.version.get()} instead.
|
|
191
|
+
* @deprecated
|
|
192
|
+
*/
|
|
144
193
|
getVersion(): string;
|
|
145
194
|
/**
|
|
195
|
+
* This method is deprecated and should not be used.
|
|
196
|
+
* Use {@link #this.pm.addPreset()} instead.
|
|
146
197
|
* @deprecated
|
|
147
198
|
*/
|
|
148
199
|
plugin<O = any>(pluginClass: any, options?: O): void;
|
|
149
200
|
use<NewStateT = {}, NewContextT = {}>(middleware: Koa.Middleware<StateT & NewStateT, ContextT & NewContextT>, options?: ToposortOptions): this;
|
|
201
|
+
/**
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
150
204
|
callback(): (req: IncomingMessage, res: ServerResponse) => any;
|
|
205
|
+
/**
|
|
206
|
+
* This method is deprecated and should not be used.
|
|
207
|
+
* Use {@link #this.db.collection()} instead.
|
|
208
|
+
* @deprecated
|
|
209
|
+
*/
|
|
151
210
|
collection(options: CollectionOptions): import("@nocobase/database").Collection<any, any>;
|
|
211
|
+
/**
|
|
212
|
+
* This method is deprecated and should not be used.
|
|
213
|
+
* Use {@link #this.resourcer.define()} instead.
|
|
214
|
+
* @deprecated
|
|
215
|
+
*/
|
|
152
216
|
resource(options: ResourceOptions): import("@nocobase/resourcer").Resource;
|
|
217
|
+
/**
|
|
218
|
+
* This method is deprecated and should not be used.
|
|
219
|
+
* Use {@link #this.resourcer.registerActions()} instead.
|
|
220
|
+
* @deprecated
|
|
221
|
+
*/
|
|
153
222
|
actions(handlers: any, options?: ActionsOptions): void;
|
|
154
223
|
command(name: string, desc?: string, opts?: CommandOptions): AppCommand;
|
|
155
224
|
findCommand(name: string): Command;
|
|
156
|
-
|
|
225
|
+
/**
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
157
228
|
reInit(): Promise<void>;
|
|
158
229
|
load(options?: any): Promise<void>;
|
|
159
230
|
reload(options?: any): Promise<void>;
|
|
160
231
|
/**
|
|
232
|
+
* This method is deprecated and should not be used.
|
|
233
|
+
* Use {@link this.pm.get()} instead.
|
|
161
234
|
* @deprecated
|
|
162
235
|
*/
|
|
163
236
|
getPlugin<P extends Plugin>(name: string | typeof Plugin): P;
|
|
237
|
+
/**
|
|
238
|
+
* This method is deprecated and should not be used.
|
|
239
|
+
* Use {@link this.runAsCLI()} instead.
|
|
240
|
+
* @deprecated
|
|
241
|
+
*/
|
|
164
242
|
parse(argv?: string[]): Promise<AppCommand>;
|
|
165
243
|
authenticate(): Promise<void>;
|
|
166
244
|
runCommand(command: string, ...args: any[]): Promise<AppCommand>;
|
|
167
245
|
runCommandThrowError(command: string, ...args: any[]): Promise<AppCommand>;
|
|
168
|
-
|
|
246
|
+
protected createCLI(): AppCommand;
|
|
247
|
+
/**
|
|
248
|
+
* @internal
|
|
249
|
+
*/
|
|
169
250
|
loadMigrations(options: any): Promise<{
|
|
170
251
|
beforeLoad: any[];
|
|
171
252
|
afterSync: any[];
|
|
172
253
|
afterLoad: any[];
|
|
173
254
|
}>;
|
|
255
|
+
/**
|
|
256
|
+
* @internal
|
|
257
|
+
*/
|
|
174
258
|
loadCoreMigrations(): Promise<{
|
|
175
259
|
beforeLoad: {
|
|
176
260
|
up: () => Promise<void>;
|
|
@@ -182,14 +266,26 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
182
266
|
up: () => Promise<void>;
|
|
183
267
|
};
|
|
184
268
|
}>;
|
|
269
|
+
/**
|
|
270
|
+
* @internal
|
|
271
|
+
*/
|
|
185
272
|
loadPluginCommands(): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* @internal
|
|
275
|
+
*/
|
|
186
276
|
runAsCLI(argv?: string[], options?: ParseOptions & {
|
|
187
277
|
throwError?: boolean;
|
|
188
278
|
reqId?: string;
|
|
189
279
|
}): Promise<AppCommand>;
|
|
190
280
|
start(options?: StartOptions): Promise<void>;
|
|
281
|
+
/**
|
|
282
|
+
* @internal
|
|
283
|
+
*/
|
|
191
284
|
emitStartedEvent(options?: StartOptions): Promise<void>;
|
|
192
285
|
isStarted(): Promise<boolean>;
|
|
286
|
+
/**
|
|
287
|
+
* @internal
|
|
288
|
+
*/
|
|
193
289
|
tryReloadOrRestart(options?: StartOptions): Promise<void>;
|
|
194
290
|
restart(options?: StartOptions): Promise<void>;
|
|
195
291
|
stop(options?: any): Promise<void>;
|
|
@@ -201,6 +297,9 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
201
297
|
appName: string;
|
|
202
298
|
name: string;
|
|
203
299
|
};
|
|
300
|
+
/**
|
|
301
|
+
* @internal
|
|
302
|
+
*/
|
|
204
303
|
reInitEvents(): void;
|
|
205
304
|
createLogger(options: LoggerOptions): import("winston").Logger;
|
|
206
305
|
protected init(): void;
|
package/lib/application.js
CHANGED
|
@@ -68,25 +68,50 @@ const _Application = class _Application extends import_koa.default {
|
|
|
68
68
|
this.init();
|
|
69
69
|
this._appSupervisor.addApp(this);
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
71
74
|
stopped = false;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
72
78
|
ready = false;
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
73
82
|
rawOptions;
|
|
83
|
+
/**
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
74
86
|
activatedCommand = null;
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
75
90
|
running = false;
|
|
91
|
+
/**
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
76
94
|
perfHistograms = /* @__PURE__ */ new Map();
|
|
77
95
|
plugins = /* @__PURE__ */ new Map();
|
|
78
96
|
_appSupervisor = import_app_supervisor.AppSupervisor.getInstance();
|
|
79
97
|
_started;
|
|
98
|
+
_logger;
|
|
80
99
|
_authenticated = false;
|
|
81
100
|
_maintaining = false;
|
|
82
101
|
_maintainingCommandStatus;
|
|
83
102
|
_maintainingStatusBeforeCommand;
|
|
84
103
|
_actionCommand;
|
|
85
104
|
_loaded;
|
|
105
|
+
/**
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
86
108
|
get loaded() {
|
|
87
109
|
return this._loaded;
|
|
88
110
|
}
|
|
89
111
|
_maintainingMessage;
|
|
112
|
+
/**
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
90
115
|
get maintainingMessage() {
|
|
91
116
|
return this._maintainingMessage;
|
|
92
117
|
}
|
|
@@ -104,7 +129,6 @@ const _Application = class _Application extends import_koa.default {
|
|
|
104
129
|
}
|
|
105
130
|
return this.mainDataSource.collectionManager.db;
|
|
106
131
|
}
|
|
107
|
-
_logger;
|
|
108
132
|
get logger() {
|
|
109
133
|
return this._logger;
|
|
110
134
|
}
|
|
@@ -119,6 +143,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
119
143
|
get cache() {
|
|
120
144
|
return this._cache;
|
|
121
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
122
149
|
set cache(cache) {
|
|
123
150
|
this._cache = cache;
|
|
124
151
|
}
|
|
@@ -142,6 +169,11 @@ const _Application = class _Application extends import_koa.default {
|
|
|
142
169
|
return this._authManager;
|
|
143
170
|
}
|
|
144
171
|
_locales;
|
|
172
|
+
/**
|
|
173
|
+
* This method is deprecated and should not be used.
|
|
174
|
+
* Use {@link #localeManager} instead.
|
|
175
|
+
* @deprecated
|
|
176
|
+
*/
|
|
145
177
|
get locales() {
|
|
146
178
|
return this._locales;
|
|
147
179
|
}
|
|
@@ -166,9 +198,15 @@ const _Application = class _Application extends import_koa.default {
|
|
|
166
198
|
get dataSourceManager() {
|
|
167
199
|
return this._dataSourceManager;
|
|
168
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
169
204
|
getMaintaining() {
|
|
170
205
|
return this._maintainingCommandStatus;
|
|
171
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
172
210
|
setMaintaining(_maintainingCommandStatus) {
|
|
173
211
|
this._maintainingCommandStatus = _maintainingCommandStatus;
|
|
174
212
|
this.emit("maintaining", _maintainingCommandStatus);
|
|
@@ -178,6 +216,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
178
216
|
}
|
|
179
217
|
this._maintaining = true;
|
|
180
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* @internal
|
|
221
|
+
*/
|
|
181
222
|
setMaintainingMessage(message) {
|
|
182
223
|
this._maintainingMessage = message;
|
|
183
224
|
this.emit("maintainingMessageChanged", {
|
|
@@ -185,10 +226,17 @@ const _Application = class _Application extends import_koa.default {
|
|
|
185
226
|
maintainingStatus: this._maintainingCommandStatus
|
|
186
227
|
});
|
|
187
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* This method is deprecated and should not be used.
|
|
231
|
+
* Use {@link #this.version.get()} instead.
|
|
232
|
+
* @deprecated
|
|
233
|
+
*/
|
|
188
234
|
getVersion() {
|
|
189
235
|
return import_package.default.version;
|
|
190
236
|
}
|
|
191
237
|
/**
|
|
238
|
+
* This method is deprecated and should not be used.
|
|
239
|
+
* Use {@link #this.pm.addPreset()} instead.
|
|
192
240
|
* @deprecated
|
|
193
241
|
*/
|
|
194
242
|
plugin(pluginClass, options) {
|
|
@@ -200,6 +248,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
200
248
|
this.middleware.add(middleware, options);
|
|
201
249
|
return this;
|
|
202
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* @internal
|
|
253
|
+
*/
|
|
203
254
|
callback() {
|
|
204
255
|
const fn = (0, import_koa_compose.default)(this.middleware.nodes);
|
|
205
256
|
if (!this.listenerCount("error"))
|
|
@@ -209,12 +260,27 @@ const _Application = class _Application extends import_koa.default {
|
|
|
209
260
|
return this.handleRequest(ctx, fn);
|
|
210
261
|
};
|
|
211
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* This method is deprecated and should not be used.
|
|
265
|
+
* Use {@link #this.db.collection()} instead.
|
|
266
|
+
* @deprecated
|
|
267
|
+
*/
|
|
212
268
|
collection(options) {
|
|
213
269
|
return this.db.collection(options);
|
|
214
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* This method is deprecated and should not be used.
|
|
273
|
+
* Use {@link #this.resourcer.define()} instead.
|
|
274
|
+
* @deprecated
|
|
275
|
+
*/
|
|
215
276
|
resource(options) {
|
|
216
277
|
return this.resourcer.define(options);
|
|
217
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* This method is deprecated and should not be used.
|
|
281
|
+
* Use {@link #this.resourcer.registerActions()} instead.
|
|
282
|
+
* @deprecated
|
|
283
|
+
*/
|
|
218
284
|
actions(handlers, options) {
|
|
219
285
|
return this.resourcer.registerActions(handlers);
|
|
220
286
|
}
|
|
@@ -224,8 +290,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
224
290
|
findCommand(name) {
|
|
225
291
|
return this.cli._findCommand(name);
|
|
226
292
|
}
|
|
227
|
-
|
|
228
|
-
|
|
293
|
+
/**
|
|
294
|
+
* @internal
|
|
295
|
+
*/
|
|
229
296
|
async reInit() {
|
|
230
297
|
if (!this._loaded) {
|
|
231
298
|
return;
|
|
@@ -300,11 +367,18 @@ const _Application = class _Application extends import_koa.default {
|
|
|
300
367
|
this.log.debug(`finish reload`, { method: "reload" });
|
|
301
368
|
}
|
|
302
369
|
/**
|
|
370
|
+
* This method is deprecated and should not be used.
|
|
371
|
+
* Use {@link this.pm.get()} instead.
|
|
303
372
|
* @deprecated
|
|
304
373
|
*/
|
|
305
374
|
getPlugin(name) {
|
|
306
375
|
return this.pm.get(name);
|
|
307
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* This method is deprecated and should not be used.
|
|
379
|
+
* Use {@link this.runAsCLI()} instead.
|
|
380
|
+
* @deprecated
|
|
381
|
+
*/
|
|
308
382
|
async parse(argv = process.argv) {
|
|
309
383
|
return this.runAsCLI(argv);
|
|
310
384
|
}
|
|
@@ -323,7 +397,7 @@ const _Application = class _Application extends import_koa.default {
|
|
|
323
397
|
async runCommandThrowError(command, ...args) {
|
|
324
398
|
return await this.runAsCLI([command, ...args], { from: "user", throwError: true });
|
|
325
399
|
}
|
|
326
|
-
|
|
400
|
+
createCLI() {
|
|
327
401
|
const command = new import_app_command.AppCommand("nocobase").usage("[command] [options]").hook("preAction", async (_, actionCommand) => {
|
|
328
402
|
this._actionCommand = actionCommand;
|
|
329
403
|
this.activatedCommand = {
|
|
@@ -354,6 +428,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
354
428
|
});
|
|
355
429
|
return command;
|
|
356
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* @internal
|
|
433
|
+
*/
|
|
357
434
|
async loadMigrations(options) {
|
|
358
435
|
const { directory, context, namespace } = options;
|
|
359
436
|
const migrations = {
|
|
@@ -379,6 +456,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
379
456
|
}
|
|
380
457
|
return migrations;
|
|
381
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* @internal
|
|
461
|
+
*/
|
|
382
462
|
async loadCoreMigrations() {
|
|
383
463
|
const migrations = await this.loadMigrations({
|
|
384
464
|
directory: (0, import_path.resolve)(__dirname, "migrations"),
|
|
@@ -408,10 +488,16 @@ const _Application = class _Application extends import_koa.default {
|
|
|
408
488
|
}
|
|
409
489
|
};
|
|
410
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* @internal
|
|
493
|
+
*/
|
|
411
494
|
async loadPluginCommands() {
|
|
412
495
|
this.log.debug("load plugin commands");
|
|
413
496
|
await this.pm.loadCommands();
|
|
414
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* @internal
|
|
500
|
+
*/
|
|
415
501
|
async runAsCLI(argv = process.argv, options) {
|
|
416
502
|
if (this.activatedCommand) {
|
|
417
503
|
return;
|
|
@@ -482,6 +568,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
482
568
|
await this.emitStartedEvent(options);
|
|
483
569
|
this.stopped = false;
|
|
484
570
|
}
|
|
571
|
+
/**
|
|
572
|
+
* @internal
|
|
573
|
+
*/
|
|
485
574
|
async emitStartedEvent(options = {}) {
|
|
486
575
|
await this.emitAsync("__started", this, {
|
|
487
576
|
maintainingStatus: import_lodash.default.cloneDeep(this._maintainingCommandStatus),
|
|
@@ -491,6 +580,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
491
580
|
async isStarted() {
|
|
492
581
|
return this._started;
|
|
493
582
|
}
|
|
583
|
+
/**
|
|
584
|
+
* @internal
|
|
585
|
+
*/
|
|
494
586
|
async tryReloadOrRestart(options = {}) {
|
|
495
587
|
if (this._started) {
|
|
496
588
|
await this.restart(options);
|
|
@@ -620,6 +712,9 @@ const _Application = class _Application extends import_koa.default {
|
|
|
620
712
|
name: this.name
|
|
621
713
|
};
|
|
622
714
|
}
|
|
715
|
+
/**
|
|
716
|
+
* @internal
|
|
717
|
+
*/
|
|
623
718
|
reInitEvents() {
|
|
624
719
|
for (const eventName of this.eventNames()) {
|
|
625
720
|
for (const listener of this.listeners(eventName)) {
|
|
@@ -657,7 +752,7 @@ const _Application = class _Application extends import_koa.default {
|
|
|
657
752
|
}
|
|
658
753
|
this.createMainDataSource(options);
|
|
659
754
|
this._cronJobManager = new import_cron_job_manager.CronJobManager(this);
|
|
660
|
-
this._cli = this.
|
|
755
|
+
this._cli = this.createCLI();
|
|
661
756
|
this._i18n = (0, import_helper.createI18n)(options);
|
|
662
757
|
this.context.db = this.db;
|
|
663
758
|
this.context.resourcer = this.resourcer;
|
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/gateway/index.js
CHANGED
|
@@ -153,23 +153,25 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
153
153
|
}
|
|
154
154
|
async requestHandler(req, res) {
|
|
155
155
|
const { pathname } = (0, import_url.parse)(req.url);
|
|
156
|
-
|
|
156
|
+
const { PLUGIN_STATICS_PATH, APP_PUBLIC_PATH } = process.env;
|
|
157
|
+
if (pathname.endsWith("/__umi/api/bundle-status")) {
|
|
157
158
|
res.statusCode = 200;
|
|
158
159
|
res.end("ok");
|
|
159
160
|
return;
|
|
160
161
|
}
|
|
161
|
-
if (pathname.startsWith("
|
|
162
|
+
if (pathname.startsWith(APP_PUBLIC_PATH + "storage/uploads/")) {
|
|
163
|
+
req.url = req.url.substring(APP_PUBLIC_PATH.length - 1);
|
|
162
164
|
await compress(req, res);
|
|
163
165
|
return (0, import_serve_handler.default)(req, res, {
|
|
164
166
|
public: (0, import_path.resolve)(process.cwd()),
|
|
165
167
|
directoryListing: false
|
|
166
168
|
});
|
|
167
169
|
}
|
|
168
|
-
if (pathname.startsWith(
|
|
170
|
+
if (pathname.startsWith(PLUGIN_STATICS_PATH) && !pathname.includes("/server/")) {
|
|
169
171
|
await compress(req, res);
|
|
170
172
|
const packageName = (0, import_plugin_manager.getPackageNameByExposeUrl)(pathname);
|
|
171
173
|
const publicDir = (0, import_plugin_manager.getPackageDirByExposeUrl)(pathname);
|
|
172
|
-
const destination = pathname.replace(
|
|
174
|
+
const destination = pathname.replace(PLUGIN_STATICS_PATH, "").replace(packageName, "");
|
|
173
175
|
return (0, import_serve_handler.default)(req, res, {
|
|
174
176
|
public: publicDir,
|
|
175
177
|
rewrites: [
|
|
@@ -180,7 +182,8 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
180
182
|
]
|
|
181
183
|
});
|
|
182
184
|
}
|
|
183
|
-
if (!pathname.startsWith(
|
|
185
|
+
if (!pathname.startsWith(process.env.API_BASE_PATH)) {
|
|
186
|
+
req.url = req.url.substring(APP_PUBLIC_PATH.length - 1);
|
|
184
187
|
await compress(req, res);
|
|
185
188
|
return (0, import_serve_handler.default)(req, res, {
|
|
186
189
|
public: `${process.env.APP_PACKAGE_ROOT}/dist/client`,
|
|
@@ -279,14 +282,14 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
279
282
|
throwError: true,
|
|
280
283
|
from: "node"
|
|
281
284
|
}).then(async () => {
|
|
282
|
-
if (!await mainApp.isStarted()) {
|
|
285
|
+
if (!isStart && !await mainApp.isStarted()) {
|
|
283
286
|
await mainApp.stop({ logging: false });
|
|
284
287
|
}
|
|
285
288
|
}).catch(async (e) => {
|
|
286
289
|
if (e.code !== "commander.helpDisplayed") {
|
|
287
290
|
mainApp.log.error(e);
|
|
288
291
|
}
|
|
289
|
-
if (!await mainApp.isStarted()) {
|
|
292
|
+
if (!isStart && !await mainApp.isStarted()) {
|
|
290
293
|
await mainApp.stop({ logging: false });
|
|
291
294
|
}
|
|
292
295
|
});
|
package/lib/locale/locale.js
CHANGED
|
@@ -78,6 +78,9 @@ const _Locale = class _Locale {
|
|
|
78
78
|
}
|
|
79
79
|
async getCacheResources(lang) {
|
|
80
80
|
this.resourceCached.set(lang, true);
|
|
81
|
+
if (process.env.APP_ENV !== "production") {
|
|
82
|
+
await this.cache.reset();
|
|
83
|
+
}
|
|
81
84
|
return await this.wrapCache(`resources:${lang}`, () => this.getResources(lang));
|
|
82
85
|
}
|
|
83
86
|
getResources(lang) {
|
package/lib/locale/resource.js
CHANGED
|
@@ -55,7 +55,10 @@ const getResource = /* @__PURE__ */ __name((packageName, lang, isPlugin = true)
|
|
|
55
55
|
for (const prefix of prefixes) {
|
|
56
56
|
try {
|
|
57
57
|
const file = `${packageName}/${prefix}/locale/${lang}`;
|
|
58
|
-
require.resolve(file);
|
|
58
|
+
const f = require.resolve(file);
|
|
59
|
+
if (process.env.APP_ENV !== "production") {
|
|
60
|
+
delete require.cache[f];
|
|
61
|
+
}
|
|
59
62
|
const resource = (0, import_utils.requireModule)(file);
|
|
60
63
|
resources.push(resource);
|
|
61
64
|
} catch (error) {
|
|
@@ -73,7 +73,7 @@ function getPackageFilePathWithExistCheck(packageName, filePath) {
|
|
|
73
73
|
}
|
|
74
74
|
__name(getPackageFilePathWithExistCheck, "getPackageFilePathWithExistCheck");
|
|
75
75
|
function getExposeUrl(packageName, filePath) {
|
|
76
|
-
return `${PLUGIN_STATICS_PATH}${packageName}/${filePath}`;
|
|
76
|
+
return `${process.env.PLUGIN_STATICS_PATH}${packageName}/${filePath}`;
|
|
77
77
|
}
|
|
78
78
|
__name(getExposeUrl, "getExposeUrl");
|
|
79
79
|
function getExposeReadmeUrl(packageName, lang) {
|
|
@@ -92,7 +92,7 @@ function getExposeChangelogUrl(packageName) {
|
|
|
92
92
|
}
|
|
93
93
|
__name(getExposeChangelogUrl, "getExposeChangelogUrl");
|
|
94
94
|
function getPackageNameByExposeUrl(pathname) {
|
|
95
|
-
pathname = pathname.replace(PLUGIN_STATICS_PATH, "");
|
|
95
|
+
pathname = pathname.replace(process.env.PLUGIN_STATICS_PATH, "");
|
|
96
96
|
const pathArr = pathname.split("/");
|
|
97
97
|
if (pathname.startsWith("@")) {
|
|
98
98
|
return pathArr.slice(0, 2).join("/");
|
|
@@ -155,7 +155,10 @@ var resource_default = {
|
|
|
155
155
|
try {
|
|
156
156
|
return {
|
|
157
157
|
...item.toJSON(),
|
|
158
|
-
url: `${(0, import_clientStaticUtils.getExposeUrl)(
|
|
158
|
+
url: `${process.env.APP_SERVER_BASE_URL}${(0, import_clientStaticUtils.getExposeUrl)(
|
|
159
|
+
item.packageName,
|
|
160
|
+
PLUGIN_CLIENT_ENTRY_FILE
|
|
161
|
+
)}?version=${item.version}`
|
|
159
162
|
};
|
|
160
163
|
} catch {
|
|
161
164
|
return false;
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { Repository } from '@nocobase/database';
|
|
2
2
|
import { PluginManager } from './plugin-manager';
|
|
3
3
|
export declare class PluginManagerRepository extends Repository {
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
4
7
|
pm: PluginManager;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
5
11
|
setPluginManager(pm: PluginManager): void;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated
|
|
14
|
+
*/
|
|
6
15
|
remove(name: string | string[]): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
7
19
|
enable(name: string | string[]): Promise<string[]>;
|
|
8
20
|
updateVersions(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated
|
|
23
|
+
*/
|
|
9
24
|
disable(name: string | string[]): Promise<string[]>;
|
|
10
25
|
getItems(): Promise<any>;
|
|
11
26
|
init(): Promise<void>;
|