@nocobase/server 2.1.0-alpha.2 → 2.1.0-alpha.20

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.
Files changed (51) hide show
  1. package/LICENSE +201 -661
  2. package/README.md +79 -10
  3. package/lib/acl/available-action.js +1 -1
  4. package/lib/aes-encryptor.js +3 -2
  5. package/lib/ai/create-docs-index.js +2 -1
  6. package/lib/app-supervisor/app-options-factory.d.ts +1 -0
  7. package/lib/app-supervisor/index.js +15 -1
  8. package/lib/app-supervisor/main-only-adapter.d.ts +1 -1
  9. package/lib/app-supervisor/main-only-adapter.js +17 -12
  10. package/lib/application.d.ts +1 -2
  11. package/lib/application.js +3 -24
  12. package/lib/commands/create-migration.js +1 -1
  13. package/lib/commands/install.js +3 -1
  14. package/lib/commands/pm.js +7 -0
  15. package/lib/commands/start.js +2 -2
  16. package/lib/commands/upgrade.js +3 -1
  17. package/lib/event-queue.js +1 -1
  18. package/lib/gateway/index.d.ts +13 -3
  19. package/lib/gateway/index.js +135 -13
  20. package/lib/gateway/utils.d.ts +17 -0
  21. package/lib/gateway/utils.js +115 -0
  22. package/lib/helper.js +33 -1
  23. package/lib/index.d.ts +1 -0
  24. package/lib/index.js +2 -0
  25. package/lib/main-data-source.js +1 -1
  26. package/lib/plugin-manager/deps.js +2 -1
  27. package/lib/plugin-manager/options/resource.d.ts +11 -1
  28. package/lib/plugin-manager/options/resource.js +153 -53
  29. package/lib/plugin-manager/plugin-manager.d.ts +7 -2
  30. package/lib/plugin-manager/plugin-manager.js +56 -43
  31. package/lib/plugin-manager/utils.d.ts +7 -1
  32. package/lib/plugin-manager/utils.js +33 -9
  33. package/lib/plugin.js +43 -2
  34. package/lib/pub-sub-manager/handler-manager.d.ts +1 -0
  35. package/lib/pub-sub-manager/handler-manager.js +11 -0
  36. package/lib/pub-sub-manager/pub-sub-manager.js +2 -1
  37. package/lib/swagger/app.d.ts +102 -0
  38. package/lib/swagger/app.js +124 -0
  39. package/lib/swagger/base.d.ts +244 -0
  40. package/lib/swagger/base.js +292 -0
  41. package/lib/swagger/collections.d.ts +996 -0
  42. package/lib/swagger/collections.js +1264 -0
  43. package/lib/swagger/index.d.ts +1774 -0
  44. package/lib/swagger/index.js +70 -0
  45. package/lib/swagger/pm.d.ts +462 -0
  46. package/lib/swagger/pm.js +422 -0
  47. package/lib/sync-message-manager.js +8 -1
  48. package/lib/worker-mode.d.ts +19 -0
  49. package/lib/worker-mode.js +67 -0
  50. package/package.json +18 -18
  51. package/lib/swagger/index.json +0 -1569
@@ -0,0 +1,422 @@
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 __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var pm_exports = {};
28
+ __export(pm_exports, {
29
+ default: () => pm_default,
30
+ pmComponents: () => pmComponents
31
+ });
32
+ module.exports = __toCommonJS(pm_exports);
33
+ const pluginNameParameter = {
34
+ name: "filterByTk",
35
+ in: "query",
36
+ description: "Plugin name.",
37
+ required: true,
38
+ schema: {
39
+ type: "string"
40
+ }
41
+ };
42
+ const pluginPmEnableDisableFilterParameter = {
43
+ name: "filterByTk",
44
+ in: "query",
45
+ required: true,
46
+ description: "Plugin package name(s). Pass multiple plugins as a comma-separated list (e.g. `@nocobase/plugin-a,@nocobase/plugin-b`).",
47
+ schema: {
48
+ type: "string"
49
+ }
50
+ };
51
+ const pluginPmAwaitResponseParameter = {
52
+ name: "awaitResponse",
53
+ in: "query",
54
+ required: false,
55
+ description: "When `true`, await the CLI operation and return its result in the response body. When `false` or omitted, start the operation and return promptly (body is usually the plugin name or the `filterByTk` value for enable).",
56
+ schema: {
57
+ type: "boolean",
58
+ default: false
59
+ }
60
+ };
61
+ const pluginListModeParameter = {
62
+ name: "mode",
63
+ in: "query",
64
+ required: false,
65
+ description: "Use `summary` for a compact list (`displayName`, `packageName`, `enabled`, `description`). Omit for full plugin objects (`PMPlugin`), including locale-specific fields from the nocobase plugin.",
66
+ schema: {
67
+ type: "string",
68
+ enum: ["summary"]
69
+ }
70
+ };
71
+ const enabledPluginListResponse = {
72
+ description: "OK",
73
+ content: {
74
+ "application/json": {
75
+ schema: {
76
+ type: "array",
77
+ items: {
78
+ $ref: "#/components/schemas/PMEnabledPlugin"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ };
84
+ const pluginListResponseOneOf = {
85
+ description: "OK. Shape depends on `mode`: full `PMPlugin` list by default, or `PMPluginListSummaryItem` when `mode=summary`.",
86
+ content: {
87
+ "application/json": {
88
+ schema: {
89
+ oneOf: [
90
+ {
91
+ type: "array",
92
+ items: {
93
+ $ref: "#/components/schemas/PMPlugin"
94
+ }
95
+ },
96
+ {
97
+ type: "array",
98
+ items: {
99
+ $ref: "#/components/schemas/PMPluginListSummaryItem"
100
+ }
101
+ }
102
+ ]
103
+ }
104
+ }
105
+ }
106
+ };
107
+ const pluginOperationResponse = {
108
+ description: "OK",
109
+ content: {
110
+ "application/json": {
111
+ schema: {
112
+ oneOf: [
113
+ {
114
+ type: "string",
115
+ example: "ok"
116
+ },
117
+ {
118
+ $ref: "#/components/schemas/PMPluginActionResult"
119
+ }
120
+ ]
121
+ }
122
+ }
123
+ }
124
+ };
125
+ const pmComponents = {
126
+ schemas: {
127
+ PMPluginListSummaryItem: {
128
+ type: "object",
129
+ description: "Compact plugin row returned when listing with `mode=summary`.",
130
+ properties: {
131
+ displayName: {
132
+ type: "string"
133
+ },
134
+ packageName: {
135
+ type: "string"
136
+ },
137
+ enabled: {
138
+ type: "boolean"
139
+ },
140
+ description: {
141
+ type: "string"
142
+ }
143
+ },
144
+ additionalProperties: true
145
+ },
146
+ PMPlugin: {
147
+ type: "object",
148
+ properties: {
149
+ id: {
150
+ type: "integer"
151
+ },
152
+ name: {
153
+ type: "string",
154
+ description: "Plugin short name."
155
+ },
156
+ packageName: {
157
+ type: "string",
158
+ description: "Plugin package name."
159
+ },
160
+ version: {
161
+ type: "string"
162
+ },
163
+ enabled: {
164
+ type: "boolean"
165
+ },
166
+ installed: {
167
+ type: "boolean"
168
+ },
169
+ builtIn: {
170
+ type: "boolean"
171
+ },
172
+ options: {
173
+ type: "object",
174
+ additionalProperties: true
175
+ }
176
+ },
177
+ additionalProperties: true
178
+ },
179
+ PMEnabledPlugin: {
180
+ type: "object",
181
+ properties: {
182
+ name: {
183
+ type: "string"
184
+ },
185
+ packageName: {
186
+ type: "string"
187
+ },
188
+ options: {
189
+ type: "object",
190
+ additionalProperties: true
191
+ },
192
+ url: {
193
+ type: "string",
194
+ description: "Resolved client bundle URL."
195
+ }
196
+ },
197
+ additionalProperties: true
198
+ },
199
+ PMPluginActionResult: {
200
+ type: "string",
201
+ description: "Queued successfully.",
202
+ example: "ok"
203
+ },
204
+ PMInstallOrUpdatePayload: {
205
+ type: "object",
206
+ description: "JSON payload for installing or updating a plugin from npm or a compressed package URL.",
207
+ properties: {
208
+ packageName: {
209
+ type: "string",
210
+ description: "Plugin package name."
211
+ },
212
+ version: {
213
+ type: "string",
214
+ description: "Target plugin version."
215
+ },
216
+ registry: {
217
+ type: "string",
218
+ description: "Custom npm registry URL."
219
+ },
220
+ authToken: {
221
+ type: "string",
222
+ description: "Authentication token used when accessing a private registry."
223
+ },
224
+ compressedFileUrl: {
225
+ type: "string",
226
+ description: "Remote compressed package URL."
227
+ }
228
+ },
229
+ additionalProperties: true
230
+ },
231
+ PMUploadPayload: {
232
+ type: "object",
233
+ description: "Multipart payload for uploading a plugin package file.",
234
+ properties: {
235
+ packageName: {
236
+ type: "string",
237
+ description: "Plugin package name. Required when updating from an uploaded file."
238
+ },
239
+ version: {
240
+ type: "string"
241
+ },
242
+ registry: {
243
+ type: "string"
244
+ },
245
+ authToken: {
246
+ type: "string"
247
+ },
248
+ file: {
249
+ type: "string",
250
+ format: "binary",
251
+ description: "Compressed plugin package file."
252
+ }
253
+ },
254
+ additionalProperties: true
255
+ }
256
+ }
257
+ };
258
+ var pm_default = {
259
+ "/pm:list": {
260
+ get: {
261
+ tags: ["pm"],
262
+ summary: "List available plugins",
263
+ description: "Return plugin metadata from the plugin manager. Pass `mode=summary` for a lightweight list built from discovered packages; omit `mode` for full records (locale-aware via the nocobase plugin).",
264
+ parameters: [pluginListModeParameter],
265
+ responses: {
266
+ 200: pluginListResponseOneOf
267
+ }
268
+ }
269
+ },
270
+ "/pm:get": {
271
+ get: {
272
+ tags: ["pm"],
273
+ summary: "Get plugin details",
274
+ description: "Return metadata for a single plugin.",
275
+ parameters: [pluginNameParameter],
276
+ responses: {
277
+ 200: {
278
+ description: "OK",
279
+ content: {
280
+ "application/json": {
281
+ schema: {
282
+ $ref: "#/components/schemas/PMPlugin"
283
+ }
284
+ }
285
+ }
286
+ }
287
+ }
288
+ }
289
+ },
290
+ "/pm:listEnabled": {
291
+ get: {
292
+ tags: ["pm"],
293
+ summary: "List enabled client plugins",
294
+ description: "Return enabled plugins that expose a `dist/client/index.js` entry.",
295
+ parameters: [],
296
+ responses: {
297
+ 200: enabledPluginListResponse
298
+ }
299
+ }
300
+ },
301
+ "/pm:listEnabledV2": {
302
+ get: {
303
+ tags: ["pm"],
304
+ summary: "List enabled client-v2 plugins",
305
+ description: "Return enabled plugins that expose a `dist/client-v2/index.js` entry.",
306
+ parameters: [],
307
+ responses: {
308
+ 200: enabledPluginListResponse
309
+ }
310
+ }
311
+ },
312
+ // '/pm:npmVersionList': {
313
+ // get: {
314
+ // tags: ['pm'],
315
+ // summary: 'List published plugin versions',
316
+ // description: 'Return all available npm versions for a specific installed plugin.',
317
+ // parameters: [pluginNameParameter],
318
+ // responses: {
319
+ // 200: {
320
+ // description: 'OK',
321
+ // content: {
322
+ // 'application/json': {
323
+ // schema: {
324
+ // type: 'array',
325
+ // items: {
326
+ // type: 'string',
327
+ // },
328
+ // },
329
+ // },
330
+ // },
331
+ // },
332
+ // },
333
+ // },
334
+ // },
335
+ "/pm:add": {
336
+ post: {
337
+ tags: ["pm"],
338
+ summary: "Install a plugin",
339
+ description: "Queue a plugin installation from npm, a remote compressed package URL, or an uploaded package file.",
340
+ requestBody: {
341
+ required: true,
342
+ content: {
343
+ "application/json": {
344
+ schema: {
345
+ $ref: "#/components/schemas/PMInstallOrUpdatePayload"
346
+ }
347
+ },
348
+ "multipart/form-data": {
349
+ schema: {
350
+ $ref: "#/components/schemas/PMUploadPayload"
351
+ }
352
+ }
353
+ }
354
+ },
355
+ responses: {
356
+ 200: pluginOperationResponse
357
+ }
358
+ }
359
+ },
360
+ "/pm:update": {
361
+ post: {
362
+ tags: ["pm"],
363
+ summary: "Update a plugin",
364
+ description: "Queue a plugin update from npm, a remote compressed package URL, or an uploaded package file.",
365
+ requestBody: {
366
+ required: true,
367
+ content: {
368
+ "application/json": {
369
+ schema: {
370
+ $ref: "#/components/schemas/PMInstallOrUpdatePayload"
371
+ }
372
+ },
373
+ "multipart/form-data": {
374
+ schema: {
375
+ $ref: "#/components/schemas/PMUploadPayload"
376
+ }
377
+ }
378
+ }
379
+ },
380
+ responses: {
381
+ 200: pluginOperationResponse
382
+ }
383
+ }
384
+ },
385
+ "/pm:enable": {
386
+ post: {
387
+ tags: ["pm"],
388
+ summary: "Enable a plugin",
389
+ description: "Run plugin enable via the plugin manager. Use `awaitResponse=true` to wait for completion. Multiple plugins can be passed in `filterByTk` as a comma-separated list.",
390
+ parameters: [pluginPmEnableDisableFilterParameter, pluginPmAwaitResponseParameter],
391
+ responses: {
392
+ 200: pluginOperationResponse
393
+ }
394
+ }
395
+ },
396
+ "/pm:disable": {
397
+ post: {
398
+ tags: ["pm"],
399
+ summary: "Disable a plugin",
400
+ description: "Run plugin disable via the plugin manager. Use `awaitResponse=true` to wait for completion. Multiple plugins can be passed in `filterByTk` as a comma-separated list.",
401
+ parameters: [pluginPmEnableDisableFilterParameter, pluginPmAwaitResponseParameter],
402
+ responses: {
403
+ 200: pluginOperationResponse
404
+ }
405
+ }
406
+ },
407
+ "/pm:remove": {
408
+ post: {
409
+ tags: ["pm"],
410
+ summary: "Remove a plugin",
411
+ description: "Queue a removal operation for a plugin.",
412
+ parameters: [pluginNameParameter],
413
+ responses: {
414
+ 200: pluginOperationResponse
415
+ }
416
+ }
417
+ }
418
+ };
419
+ // Annotate the CommonJS export names for ESM import in node:
420
+ 0 && (module.exports = {
421
+ pmComponents
422
+ });
@@ -40,7 +40,14 @@ const _SyncMessageManager = class _SyncMessageManager {
40
40
  if (!plugin.name) {
41
41
  return;
42
42
  }
43
- await this.subscribe(plugin.name, plugin.handleSyncMessage.bind(plugin));
43
+ if (typeof plugin.handleSyncMessage === "function") {
44
+ await this.subscribe(plugin.name, async (...args) => {
45
+ if (app.stopped || app.db.closed()) {
46
+ return;
47
+ }
48
+ return plugin.handleSyncMessage(...args);
49
+ });
50
+ }
44
51
  });
45
52
  }
46
53
  versionManager;
@@ -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,30 +1,30 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "2.1.0-alpha.2",
3
+ "version": "2.1.0-alpha.20",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
- "license": "AGPL-3.0",
6
+ "license": "Apache-2.0",
7
7
  "dependencies": {
8
8
  "@formily/json-schema": "2.x",
9
9
  "@hapi/topo": "^6.0.0",
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.2",
14
- "@nocobase/actions": "2.1.0-alpha.2",
15
- "@nocobase/ai": "2.1.0-alpha.2",
16
- "@nocobase/auth": "2.1.0-alpha.2",
17
- "@nocobase/cache": "2.1.0-alpha.2",
18
- "@nocobase/data-source-manager": "2.1.0-alpha.2",
19
- "@nocobase/database": "2.1.0-alpha.2",
20
- "@nocobase/evaluators": "2.1.0-alpha.2",
21
- "@nocobase/lock-manager": "2.1.0-alpha.2",
22
- "@nocobase/logger": "2.1.0-alpha.2",
23
- "@nocobase/resourcer": "2.1.0-alpha.2",
24
- "@nocobase/sdk": "2.1.0-alpha.2",
25
- "@nocobase/snowflake-id": "2.1.0-alpha.2",
26
- "@nocobase/telemetry": "2.1.0-alpha.2",
27
- "@nocobase/utils": "2.1.0-alpha.2",
13
+ "@nocobase/acl": "2.1.0-alpha.20",
14
+ "@nocobase/actions": "2.1.0-alpha.20",
15
+ "@nocobase/ai": "2.1.0-alpha.20",
16
+ "@nocobase/auth": "2.1.0-alpha.20",
17
+ "@nocobase/cache": "2.1.0-alpha.20",
18
+ "@nocobase/data-source-manager": "2.1.0-alpha.20",
19
+ "@nocobase/database": "2.1.0-alpha.20",
20
+ "@nocobase/evaluators": "2.1.0-alpha.20",
21
+ "@nocobase/lock-manager": "2.1.0-alpha.20",
22
+ "@nocobase/logger": "2.1.0-alpha.20",
23
+ "@nocobase/resourcer": "2.1.0-alpha.20",
24
+ "@nocobase/sdk": "2.1.0-alpha.20",
25
+ "@nocobase/snowflake-id": "2.1.0-alpha.20",
26
+ "@nocobase/telemetry": "2.1.0-alpha.20",
27
+ "@nocobase/utils": "2.1.0-alpha.20",
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": "01afd1b928c72c072947533fb12a61b06e45c985"
64
+ "gitHead": "3d1535db6bf93ca23257faf474afee0d565f54c6"
65
65
  }