@nocobase/server 2.1.0-alpha.13 → 2.1.0-alpha.15
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 +1 -1
- package/lib/app-supervisor/index.js +13 -2
- package/lib/application.d.ts +1 -2
- package/lib/application.js +3 -24
- package/lib/commands/pm.js +30 -0
- package/lib/gateway/index.d.ts +3 -3
- package/lib/gateway/index.js +10 -5
- package/lib/gateway/utils.d.ts +5 -0
- package/lib/gateway/utils.js +31 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/plugin-manager/plugin-manager.d.ts +6 -2
- package/lib/plugin-manager/plugin-manager.js +19 -1
- package/lib/plugin.js +1 -0
- package/lib/worker-mode.d.ts +19 -0
- package/lib/worker-mode.js +67 -0
- package/package.json +17 -17
|
@@ -47,6 +47,7 @@ var import_lodash = __toESM(require("lodash"));
|
|
|
47
47
|
var import_utils = require("@nocobase/utils");
|
|
48
48
|
var import_events = require("events");
|
|
49
49
|
var import_application = __toESM(require("../application"));
|
|
50
|
+
var import_worker_mode = require("../worker-mode");
|
|
50
51
|
var import_main_only_adapter = require("./main-only-adapter");
|
|
51
52
|
var import_handler = require("../errors/handler");
|
|
52
53
|
var import_condition_registry = require("./condition-registry");
|
|
@@ -288,6 +289,10 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
288
289
|
return this.discoveryAdapter.getAppStatus(appName, defaultStatus);
|
|
289
290
|
}
|
|
290
291
|
async setAppStatus(appName, status, options = {}) {
|
|
292
|
+
if ((0, import_worker_mode.isTransient)()) {
|
|
293
|
+
this.logger.debug("App running as worker, status will not be set", { appName, status });
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
291
296
|
this.logger.debug("Setting app status", { appName, status });
|
|
292
297
|
return this.discoveryAdapter.setAppStatus(appName, status, options);
|
|
293
298
|
}
|
|
@@ -329,7 +334,7 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
329
334
|
};
|
|
330
335
|
}
|
|
331
336
|
const app = new import_application.default(options);
|
|
332
|
-
if (hook ??
|
|
337
|
+
if (hook ?? !(0, import_worker_mode.isTransient)()) {
|
|
333
338
|
app.on("afterStart", async () => {
|
|
334
339
|
await this.sendSyncMessage(mainApp, {
|
|
335
340
|
type: "app:started",
|
|
@@ -356,6 +361,9 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
356
361
|
this.registerCommandHandler(app);
|
|
357
362
|
app.on("afterStart", async (app2) => {
|
|
358
363
|
var _a, _b;
|
|
364
|
+
if ((0, import_worker_mode.isTransient)()) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
359
367
|
await app2.syncMessageManager.subscribe(
|
|
360
368
|
"app_supervisor:sync",
|
|
361
369
|
async (message) => {
|
|
@@ -390,6 +398,9 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
390
398
|
}
|
|
391
399
|
});
|
|
392
400
|
app.on("afterDestroy", async (app2) => {
|
|
401
|
+
if ((0, import_worker_mode.isTransient)()) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
393
404
|
await this.unregisterEnvironment();
|
|
394
405
|
});
|
|
395
406
|
return app;
|
|
@@ -586,7 +597,7 @@ const _AppSupervisor = class _AppSupervisor extends import_events.EventEmitter {
|
|
|
586
597
|
return super.on(eventName, listener);
|
|
587
598
|
}
|
|
588
599
|
bindAppEvents(app) {
|
|
589
|
-
if (
|
|
600
|
+
if ((0, import_worker_mode.isTransient)()) {
|
|
590
601
|
return;
|
|
591
602
|
}
|
|
592
603
|
app.on("afterDestroy", async () => {
|
package/lib/application.d.ts
CHANGED
|
@@ -270,8 +270,7 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
270
270
|
protected _aesEncryptor: AesEncryptor;
|
|
271
271
|
get aesEncryptor(): AesEncryptor;
|
|
272
272
|
/**
|
|
273
|
-
*
|
|
274
|
-
* @experimental
|
|
273
|
+
* @deprecated use {@link serving} from './worker-mode' instead.
|
|
275
274
|
*/
|
|
276
275
|
serving(key?: string): boolean;
|
|
277
276
|
/**
|
package/lib/application.js
CHANGED
|
@@ -87,6 +87,7 @@ var import_redis_connection_manager = require("./redis-connection-manager");
|
|
|
87
87
|
var import_service_container = require("./service-container");
|
|
88
88
|
var import_snowflake_id_field = require("./snowflake-id-field");
|
|
89
89
|
var import_worker_id_allocator = require("./worker-id-allocator");
|
|
90
|
+
var import_worker_mode = require("./worker-mode");
|
|
90
91
|
const _Application = class _Application extends import_koa.default {
|
|
91
92
|
constructor(options) {
|
|
92
93
|
super();
|
|
@@ -282,32 +283,10 @@ const _Application = class _Application extends import_koa.default {
|
|
|
282
283
|
return this._aesEncryptor;
|
|
283
284
|
}
|
|
284
285
|
/**
|
|
285
|
-
*
|
|
286
|
-
* @experimental
|
|
286
|
+
* @deprecated use {@link serving} from './worker-mode' instead.
|
|
287
287
|
*/
|
|
288
288
|
serving(key) {
|
|
289
|
-
|
|
290
|
-
if (!WORKER_MODE) {
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
if (WORKER_MODE === "-") {
|
|
294
|
-
return false;
|
|
295
|
-
}
|
|
296
|
-
const topics = WORKER_MODE.trim().split(",");
|
|
297
|
-
if (key) {
|
|
298
|
-
if (WORKER_MODE === "*") {
|
|
299
|
-
return true;
|
|
300
|
-
}
|
|
301
|
-
if (topics.includes(key)) {
|
|
302
|
-
return true;
|
|
303
|
-
}
|
|
304
|
-
return false;
|
|
305
|
-
} else {
|
|
306
|
-
if (topics.includes("!")) {
|
|
307
|
-
return true;
|
|
308
|
-
}
|
|
309
|
-
return false;
|
|
310
|
-
}
|
|
289
|
+
return (0, import_worker_mode.serving)(key);
|
|
311
290
|
}
|
|
312
291
|
/**
|
|
313
292
|
* @internal
|
package/lib/commands/pm.js
CHANGED
|
@@ -32,9 +32,39 @@ __export(pm_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(pm_exports);
|
|
33
33
|
var import_app_supervisor = require("../app-supervisor");
|
|
34
34
|
var import_plugin_command_error = require("../errors/plugin-command-error");
|
|
35
|
+
var import_plugin_manager = require("../plugin-manager");
|
|
36
|
+
var import_findPackageNames = require("../plugin-manager/findPackageNames");
|
|
35
37
|
/* istanbul ignore file -- @preserve */
|
|
36
38
|
var pm_default = /* @__PURE__ */ __name((app) => {
|
|
37
39
|
const pm = app.command("pm");
|
|
40
|
+
pm.command("list").action(async () => {
|
|
41
|
+
const plugins1 = await (0, import_findPackageNames.findBuiltInPlugins)();
|
|
42
|
+
const plugins2 = await (0, import_findPackageNames.findLocalPlugins)();
|
|
43
|
+
let enabledPlugins = [];
|
|
44
|
+
try {
|
|
45
|
+
enabledPlugins = (await app.pm.repository.find({
|
|
46
|
+
filter: {
|
|
47
|
+
enabled: true
|
|
48
|
+
}
|
|
49
|
+
})).map((item) => item.packageName);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
}
|
|
52
|
+
const items = await Promise.all(
|
|
53
|
+
[...plugins1, ...plugins2].map(async (name) => {
|
|
54
|
+
const item = await import_plugin_manager.PluginManager.parseName(name);
|
|
55
|
+
const json = await import_plugin_manager.PluginManager.getPackageJson(item.packageName);
|
|
56
|
+
return {
|
|
57
|
+
displayName: json.displayName || name,
|
|
58
|
+
packageName: item.packageName,
|
|
59
|
+
enabled: enabledPlugins.includes(item.packageName),
|
|
60
|
+
description: json.description
|
|
61
|
+
};
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
console.log("--- BEGIN_PLUGIN_LIST_JSON ---");
|
|
65
|
+
console.log(JSON.stringify(items));
|
|
66
|
+
console.log("--- END_PLUGIN_LIST_JSON ---");
|
|
67
|
+
});
|
|
38
68
|
pm.command("create").argument("plugin").option("--force-recreate").action(async (plugin, options) => {
|
|
39
69
|
await app.pm.create(plugin, options);
|
|
40
70
|
});
|
package/lib/gateway/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { IPCSocketClient } from './ipc-socket-client';
|
|
|
19
19
|
import { IPCSocketServer } from './ipc-socket-server';
|
|
20
20
|
import { WSServer } from './ws-server';
|
|
21
21
|
import { Duplex } from 'node:stream';
|
|
22
|
+
export { getHost, getHostname } from './utils';
|
|
22
23
|
export interface IncomingRequest {
|
|
23
24
|
url: string;
|
|
24
25
|
headers: any;
|
|
@@ -40,7 +41,7 @@ interface RunOptions {
|
|
|
40
41
|
mainAppOptions: ApplicationOptions;
|
|
41
42
|
}
|
|
42
43
|
export interface AppSelectorMiddlewareContext {
|
|
43
|
-
req: IncomingRequest;
|
|
44
|
+
req: IncomingMessage | IncomingRequest;
|
|
44
45
|
resolvedAppName: string | null;
|
|
45
46
|
}
|
|
46
47
|
export declare class Gateway extends EventEmitter {
|
|
@@ -86,7 +87,7 @@ export declare class Gateway extends EventEmitter {
|
|
|
86
87
|
private renderV2IndexHtml;
|
|
87
88
|
requestHandler(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
88
89
|
getAppSelectorMiddlewares(): Toposort<AppSelectorMiddleware>;
|
|
89
|
-
getRequestHandleAppName(req: IncomingRequest): Promise<string>;
|
|
90
|
+
getRequestHandleAppName(req: IncomingMessage | IncomingRequest): Promise<string>;
|
|
90
91
|
getCallback(): any;
|
|
91
92
|
watch(): Promise<void>;
|
|
92
93
|
run(options: RunOptions): Promise<void>;
|
|
@@ -106,4 +107,3 @@ export declare class Gateway extends EventEmitter {
|
|
|
106
107
|
static registerWsHandler(wsServer: (req: IncomingMessage, socket: Duplex, head: Buffer, app: Application) => boolean | void): void;
|
|
107
108
|
static unregisterWsHandler(wsServer: (req: IncomingMessage, socket: Duplex, head: Buffer, app: Application) => boolean | void): void;
|
|
108
109
|
}
|
|
109
|
-
export {};
|
package/lib/gateway/index.js
CHANGED
|
@@ -39,7 +39,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
39
39
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
40
40
|
var gateway_exports = {};
|
|
41
41
|
__export(gateway_exports, {
|
|
42
|
-
Gateway: () => Gateway
|
|
42
|
+
Gateway: () => Gateway,
|
|
43
|
+
getHost: () => import_utils4.getHost,
|
|
44
|
+
getHostname: () => import_utils4.getHostname
|
|
43
45
|
});
|
|
44
46
|
module.exports = __toCommonJS(gateway_exports);
|
|
45
47
|
var import_logger = require("@nocobase/logger");
|
|
@@ -67,6 +69,7 @@ var import_utils3 = require("./utils");
|
|
|
67
69
|
var import_ws_server = require("./ws-server");
|
|
68
70
|
var import_node_worker_threads = require("node:worker_threads");
|
|
69
71
|
var import_node_process = __toESM(require("node:process"));
|
|
72
|
+
var import_utils4 = require("./utils");
|
|
70
73
|
const compress = (0, import_node_util.promisify)((0, import_compression.default)());
|
|
71
74
|
function normalizeBasePath(path = "") {
|
|
72
75
|
const normalized = path.replace(/\/+/g, "/").replace(/\/$/, "");
|
|
@@ -164,12 +167,12 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
164
167
|
const appName = (_a = import_qs.default.parse(parsedUrl.query)) == null ? void 0 : _a.__appName;
|
|
165
168
|
const apiBasePath = normalizeBasePath(import_node_process.default.env.API_BASE_PATH || "/api");
|
|
166
169
|
const appPathPrefix = `${apiBasePath}/__app/`;
|
|
167
|
-
if (appName) {
|
|
168
|
-
ctx.resolvedAppName = appName;
|
|
169
|
-
}
|
|
170
170
|
if (req.headers["x-app"]) {
|
|
171
171
|
ctx.resolvedAppName = req.headers["x-app"];
|
|
172
172
|
}
|
|
173
|
+
if (appName) {
|
|
174
|
+
ctx.resolvedAppName = appName;
|
|
175
|
+
}
|
|
173
176
|
if ((_b = parsedUrl.pathname) == null ? void 0 : _b.startsWith(appPathPrefix)) {
|
|
174
177
|
const restPath = parsedUrl.pathname.slice(appPathPrefix.length);
|
|
175
178
|
const [pathAppName, ...segments] = restPath.split("/");
|
|
@@ -655,5 +658,7 @@ __publicField(_Gateway, "wsServers", []);
|
|
|
655
658
|
let Gateway = _Gateway;
|
|
656
659
|
// Annotate the CommonJS export names for ESM import in node:
|
|
657
660
|
0 && (module.exports = {
|
|
658
|
-
Gateway
|
|
661
|
+
Gateway,
|
|
662
|
+
getHost,
|
|
663
|
+
getHostname
|
|
659
664
|
});
|
package/lib/gateway/utils.d.ts
CHANGED
|
@@ -6,7 +6,12 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
/// <reference types="node" />
|
|
10
|
+
import { IncomingMessage } from 'http';
|
|
11
|
+
import { IncomingRequest } from '.';
|
|
9
12
|
export declare function resolvePublicPath(appPublicPath?: string): string;
|
|
10
13
|
export declare function resolveV2PublicPath(appPublicPath?: string): string;
|
|
11
14
|
export declare function rewriteV2AssetPublicPath(html: string, assetPublicPath: string): string;
|
|
12
15
|
export declare function injectRuntimeScript(html: string, runtimeScript: string): string;
|
|
16
|
+
export declare function getHost(req: IncomingMessage | IncomingRequest): any;
|
|
17
|
+
export declare function getHostname(req: IncomingMessage | IncomingRequest): any;
|
package/lib/gateway/utils.js
CHANGED
|
@@ -27,6 +27,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var utils_exports = {};
|
|
29
29
|
__export(utils_exports, {
|
|
30
|
+
getHost: () => getHost,
|
|
31
|
+
getHostname: () => getHostname,
|
|
30
32
|
injectRuntimeScript: () => injectRuntimeScript,
|
|
31
33
|
resolvePublicPath: () => resolvePublicPath,
|
|
32
34
|
resolveV2PublicPath: () => resolveV2PublicPath,
|
|
@@ -75,8 +77,37 @@ ${moduleScriptMatch[0]}`);
|
|
|
75
77
|
${html}`;
|
|
76
78
|
}
|
|
77
79
|
__name(injectRuntimeScript, "injectRuntimeScript");
|
|
80
|
+
function splitCommaSeparatedValues(value, limit) {
|
|
81
|
+
return value.split(",", limit).map((v) => v.trim());
|
|
82
|
+
}
|
|
83
|
+
__name(splitCommaSeparatedValues, "splitCommaSeparatedValues");
|
|
84
|
+
function getHost(req) {
|
|
85
|
+
let host = req.headers["x-forwarded-host"];
|
|
86
|
+
if (!host) {
|
|
87
|
+
host = req.headers[":authority"] || req.headers["host"];
|
|
88
|
+
}
|
|
89
|
+
if (!host) return "";
|
|
90
|
+
host = splitCommaSeparatedValues(host, 1)[0];
|
|
91
|
+
if (host.includes("@")) {
|
|
92
|
+
try {
|
|
93
|
+
host = new URL(`http://${host}`).host;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return host;
|
|
99
|
+
}
|
|
100
|
+
__name(getHost, "getHost");
|
|
101
|
+
function getHostname(req) {
|
|
102
|
+
const host = getHost(req);
|
|
103
|
+
if (!host) return "";
|
|
104
|
+
return host.split(":", 1)[0];
|
|
105
|
+
}
|
|
106
|
+
__name(getHostname, "getHostname");
|
|
78
107
|
// Annotate the CommonJS export names for ESM import in node:
|
|
79
108
|
0 && (module.exports = {
|
|
109
|
+
getHost,
|
|
110
|
+
getHostname,
|
|
80
111
|
injectRuntimeScript,
|
|
81
112
|
resolvePublicPath,
|
|
82
113
|
resolveV2PublicPath,
|
package/lib/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './plugin-manager';
|
|
|
20
20
|
export * from './pub-sub-manager';
|
|
21
21
|
export * from './event-queue';
|
|
22
22
|
export * from './worker-id-allocator';
|
|
23
|
+
export * from './worker-mode';
|
|
23
24
|
export * from './redis-connection-manager';
|
|
24
25
|
export * from './main-data-source';
|
|
25
26
|
export declare const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
|
package/lib/index.js
CHANGED
|
@@ -63,6 +63,7 @@ __reExport(src_exports, require("./plugin-manager"), module.exports);
|
|
|
63
63
|
__reExport(src_exports, require("./pub-sub-manager"), module.exports);
|
|
64
64
|
__reExport(src_exports, require("./event-queue"), module.exports);
|
|
65
65
|
__reExport(src_exports, require("./worker-id-allocator"), module.exports);
|
|
66
|
+
__reExport(src_exports, require("./worker-mode"), module.exports);
|
|
66
67
|
__reExport(src_exports, require("./redis-connection-manager"), module.exports);
|
|
67
68
|
__reExport(src_exports, require("./main-data-source"), module.exports);
|
|
68
69
|
var import_findPackageNames = require("./plugin-manager/findPackageNames");
|
|
@@ -92,6 +93,7 @@ const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
|
|
|
92
93
|
...require("./pub-sub-manager"),
|
|
93
94
|
...require("./event-queue"),
|
|
94
95
|
...require("./worker-id-allocator"),
|
|
96
|
+
...require("./worker-mode"),
|
|
95
97
|
...require("./redis-connection-manager"),
|
|
96
98
|
...require("./main-data-source")
|
|
97
99
|
});
|
|
@@ -13,7 +13,6 @@ import Application from '../application';
|
|
|
13
13
|
import { Plugin } from '../plugin';
|
|
14
14
|
import { PluginManagerRepository } from './plugin-manager-repository';
|
|
15
15
|
import { PluginData } from './types';
|
|
16
|
-
import { checkAndGetCompatible } from './utils';
|
|
17
16
|
export declare const sleep: (timeout?: number) => Promise<unknown>;
|
|
18
17
|
export interface PluginManagerOptions {
|
|
19
18
|
app: Application;
|
|
@@ -29,7 +28,12 @@ export declare class AddPresetError extends Error {
|
|
|
29
28
|
}
|
|
30
29
|
export declare class PluginManager {
|
|
31
30
|
options: PluginManagerOptions;
|
|
32
|
-
static
|
|
31
|
+
private static compatibleCache;
|
|
32
|
+
private static compatiblePending;
|
|
33
|
+
static checkAndGetCompatible(packageName: string): Promise<{
|
|
34
|
+
isCompatible: boolean;
|
|
35
|
+
depsCompatible: import("./utils").DepCompatible[];
|
|
36
|
+
}>;
|
|
33
37
|
/**
|
|
34
38
|
* @internal
|
|
35
39
|
*/
|
|
@@ -101,6 +101,23 @@ const _PluginManager = class _PluginManager {
|
|
|
101
101
|
});
|
|
102
102
|
this.app.resourceManager.use(import_middleware.uploadMiddleware, { tag: "upload", after: "acl" });
|
|
103
103
|
}
|
|
104
|
+
static async checkAndGetCompatible(packageName) {
|
|
105
|
+
if (this.compatibleCache.has(packageName)) {
|
|
106
|
+
return this.compatibleCache.get(packageName);
|
|
107
|
+
}
|
|
108
|
+
const pending = this.compatiblePending.get(packageName);
|
|
109
|
+
if (pending) {
|
|
110
|
+
return pending;
|
|
111
|
+
}
|
|
112
|
+
const task = (0, import_utils2.checkAndGetCompatible)(packageName).then((compatible) => {
|
|
113
|
+
this.compatibleCache.set(packageName, compatible);
|
|
114
|
+
return compatible;
|
|
115
|
+
}).finally(() => {
|
|
116
|
+
this.compatiblePending.delete(packageName);
|
|
117
|
+
});
|
|
118
|
+
this.compatiblePending.set(packageName, task);
|
|
119
|
+
return task;
|
|
120
|
+
}
|
|
104
121
|
/**
|
|
105
122
|
* @internal
|
|
106
123
|
*/
|
|
@@ -1108,7 +1125,8 @@ const _PluginManager = class _PluginManager {
|
|
|
1108
1125
|
}
|
|
1109
1126
|
};
|
|
1110
1127
|
__name(_PluginManager, "PluginManager");
|
|
1111
|
-
__publicField(_PluginManager, "
|
|
1128
|
+
__publicField(_PluginManager, "compatibleCache", /* @__PURE__ */ new Map());
|
|
1129
|
+
__publicField(_PluginManager, "compatiblePending", /* @__PURE__ */ new Map());
|
|
1112
1130
|
__publicField(_PluginManager, "parsedNames", {});
|
|
1113
1131
|
let PluginManager = _PluginManager;
|
|
1114
1132
|
var plugin_manager_default = PluginManager;
|
package/lib/plugin.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Check if the application is running in transient mode (WORKER_MODE === '-'),
|
|
11
|
+
* which means it is a short-lived subprocess spawned to execute a command and then exit.
|
|
12
|
+
* @experimental
|
|
13
|
+
*/
|
|
14
|
+
export declare function isTransient(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Check if the application is serving as a specific worker.
|
|
17
|
+
* @experimental
|
|
18
|
+
*/
|
|
19
|
+
export declare function serving(key?: string): boolean;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var worker_mode_exports = {};
|
|
29
|
+
__export(worker_mode_exports, {
|
|
30
|
+
isTransient: () => isTransient,
|
|
31
|
+
serving: () => serving
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(worker_mode_exports);
|
|
34
|
+
function isTransient() {
|
|
35
|
+
return process.env.WORKER_MODE === "-";
|
|
36
|
+
}
|
|
37
|
+
__name(isTransient, "isTransient");
|
|
38
|
+
function serving(key) {
|
|
39
|
+
const { WORKER_MODE = "" } = process.env;
|
|
40
|
+
if (!WORKER_MODE) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (WORKER_MODE === "-") {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const topics = WORKER_MODE.trim().split(",");
|
|
47
|
+
if (key) {
|
|
48
|
+
if (WORKER_MODE === "*") {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (topics.includes(key)) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
} else {
|
|
56
|
+
if (topics.includes("!")) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
__name(serving, "serving");
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
isTransient,
|
|
66
|
+
serving
|
|
67
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.15",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"@koa/cors": "^5.0.0",
|
|
11
11
|
"@koa/multer": "^3.1.0",
|
|
12
12
|
"@koa/router": "^13.1.0",
|
|
13
|
-
"@nocobase/acl": "2.1.0-alpha.
|
|
14
|
-
"@nocobase/actions": "2.1.0-alpha.
|
|
15
|
-
"@nocobase/ai": "2.1.0-alpha.
|
|
16
|
-
"@nocobase/auth": "2.1.0-alpha.
|
|
17
|
-
"@nocobase/cache": "2.1.0-alpha.
|
|
18
|
-
"@nocobase/data-source-manager": "2.1.0-alpha.
|
|
19
|
-
"@nocobase/database": "2.1.0-alpha.
|
|
20
|
-
"@nocobase/evaluators": "2.1.0-alpha.
|
|
21
|
-
"@nocobase/lock-manager": "2.1.0-alpha.
|
|
22
|
-
"@nocobase/logger": "2.1.0-alpha.
|
|
23
|
-
"@nocobase/resourcer": "2.1.0-alpha.
|
|
24
|
-
"@nocobase/sdk": "2.1.0-alpha.
|
|
25
|
-
"@nocobase/snowflake-id": "2.1.0-alpha.
|
|
26
|
-
"@nocobase/telemetry": "2.1.0-alpha.
|
|
27
|
-
"@nocobase/utils": "2.1.0-alpha.
|
|
13
|
+
"@nocobase/acl": "2.1.0-alpha.15",
|
|
14
|
+
"@nocobase/actions": "2.1.0-alpha.15",
|
|
15
|
+
"@nocobase/ai": "2.1.0-alpha.15",
|
|
16
|
+
"@nocobase/auth": "2.1.0-alpha.15",
|
|
17
|
+
"@nocobase/cache": "2.1.0-alpha.15",
|
|
18
|
+
"@nocobase/data-source-manager": "2.1.0-alpha.15",
|
|
19
|
+
"@nocobase/database": "2.1.0-alpha.15",
|
|
20
|
+
"@nocobase/evaluators": "2.1.0-alpha.15",
|
|
21
|
+
"@nocobase/lock-manager": "2.1.0-alpha.15",
|
|
22
|
+
"@nocobase/logger": "2.1.0-alpha.15",
|
|
23
|
+
"@nocobase/resourcer": "2.1.0-alpha.15",
|
|
24
|
+
"@nocobase/sdk": "2.1.0-alpha.15",
|
|
25
|
+
"@nocobase/snowflake-id": "2.1.0-alpha.15",
|
|
26
|
+
"@nocobase/telemetry": "2.1.0-alpha.15",
|
|
27
|
+
"@nocobase/utils": "2.1.0-alpha.15",
|
|
28
28
|
"@types/decompress": "4.2.7",
|
|
29
29
|
"@types/ini": "^1.3.31",
|
|
30
30
|
"@types/koa-send": "^4.1.3",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@types/serve-handler": "^6.1.1",
|
|
62
62
|
"@types/ws": "^8.5.5"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "7c86e75b0af4b9f532c8ebf5ef96a7423b0ab60e"
|
|
65
65
|
}
|