@nocobase/server 1.2.13-alpha → 1.3.0-alpha.20240710084543

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 (124) hide show
  1. package/package.json +14 -14
  2. package/lib/acl/available-action.d.ts +0 -13
  3. package/lib/acl/available-action.js +0 -71
  4. package/lib/acl/index.d.ts +0 -10
  5. package/lib/acl/index.js +0 -46
  6. package/lib/app-command.d.ts +0 -20
  7. package/lib/app-command.js +0 -82
  8. package/lib/app-supervisor.d.ts +0 -69
  9. package/lib/app-supervisor.js +0 -302
  10. package/lib/application.d.ts +0 -345
  11. package/lib/application.js +0 -876
  12. package/lib/cache/index.d.ts +0 -11
  13. package/lib/cache/index.js +0 -44
  14. package/lib/commands/console.d.ts +0 -11
  15. package/lib/commands/console.js +0 -48
  16. package/lib/commands/create-migration.d.ts +0 -11
  17. package/lib/commands/create-migration.js +0 -79
  18. package/lib/commands/db-auth.d.ts +0 -11
  19. package/lib/commands/db-auth.js +0 -38
  20. package/lib/commands/db-clean.d.ts +0 -11
  21. package/lib/commands/db-clean.js +0 -41
  22. package/lib/commands/db-sync.d.ts +0 -11
  23. package/lib/commands/db-sync.js +0 -50
  24. package/lib/commands/destroy.d.ts +0 -11
  25. package/lib/commands/destroy.js +0 -40
  26. package/lib/commands/index.d.ts +0 -10
  27. package/lib/commands/index.js +0 -82
  28. package/lib/commands/install.d.ts +0 -11
  29. package/lib/commands/install.js +0 -43
  30. package/lib/commands/migrator.d.ts +0 -11
  31. package/lib/commands/migrator.js +0 -41
  32. package/lib/commands/pm.d.ts +0 -11
  33. package/lib/commands/pm.js +0 -98
  34. package/lib/commands/refresh.d.ts +0 -11
  35. package/lib/commands/refresh.js +0 -41
  36. package/lib/commands/restart.d.ts +0 -11
  37. package/lib/commands/restart.js +0 -45
  38. package/lib/commands/start.d.ts +0 -11
  39. package/lib/commands/start.js +0 -85
  40. package/lib/commands/stop.d.ts +0 -11
  41. package/lib/commands/stop.js +0 -44
  42. package/lib/commands/upgrade.d.ts +0 -14
  43. package/lib/commands/upgrade.js +0 -39
  44. package/lib/cron/cron-job-manager.d.ts +0 -22
  45. package/lib/cron/cron-job-manager.js +0 -82
  46. package/lib/errors/application-not-install.d.ts +0 -12
  47. package/lib/errors/application-not-install.js +0 -45
  48. package/lib/errors/handler.d.ts +0 -11
  49. package/lib/errors/handler.js +0 -50
  50. package/lib/errors/plugin-command-error.d.ts +0 -10
  51. package/lib/errors/plugin-command-error.js +0 -40
  52. package/lib/errors/plugin-not-exist.d.ts +0 -10
  53. package/lib/errors/plugin-not-exist.js +0 -40
  54. package/lib/gateway/errors.d.ts +0 -30
  55. package/lib/gateway/errors.js +0 -154
  56. package/lib/gateway/index.d.ts +0 -79
  57. package/lib/gateway/index.js +0 -393
  58. package/lib/gateway/ipc-socket-client.d.ts +0 -27
  59. package/lib/gateway/ipc-socket-client.js +0 -110
  60. package/lib/gateway/ipc-socket-server.d.ts +0 -21
  61. package/lib/gateway/ipc-socket-server.js +0 -150
  62. package/lib/gateway/ws-server.d.ts +0 -36
  63. package/lib/gateway/ws-server.js +0 -196
  64. package/lib/helper.d.ts +0 -18
  65. package/lib/helper.js +0 -193
  66. package/lib/helpers/application-version.d.ts +0 -18
  67. package/lib/helpers/application-version.js +0 -88
  68. package/lib/index.d.ts +0 -17
  69. package/lib/index.js +0 -64
  70. package/lib/locale/index.d.ts +0 -9
  71. package/lib/locale/index.js +0 -30
  72. package/lib/locale/locale.d.ts +0 -38
  73. package/lib/locale/locale.js +0 -174
  74. package/lib/locale/resource.d.ts +0 -9
  75. package/lib/locale/resource.js +0 -87
  76. package/lib/main-data-source.d.ts +0 -12
  77. package/lib/main-data-source.js +0 -57
  78. package/lib/middlewares/data-template.d.ts +0 -10
  79. package/lib/middlewares/data-template.js +0 -146
  80. package/lib/middlewares/data-wrapping.d.ts +0 -11
  81. package/lib/middlewares/data-wrapping.js +0 -100
  82. package/lib/middlewares/i18n.d.ts +0 -9
  83. package/lib/middlewares/i18n.js +0 -53
  84. package/lib/middlewares/index.d.ts +0 -10
  85. package/lib/middlewares/index.js +0 -39
  86. package/lib/middlewares/parse-variables.d.ts +0 -9
  87. package/lib/middlewares/parse-variables.js +0 -95
  88. package/lib/middlewares/validate-filter-params.d.ts +0 -9
  89. package/lib/middlewares/validate-filter-params.js +0 -42
  90. package/lib/migration.d.ts +0 -20
  91. package/lib/migration.js +0 -54
  92. package/lib/migrations/20230912193824-package-name-unique.d.ts +0 -14
  93. package/lib/migrations/20230912193824-package-name-unique.js +0 -59
  94. package/lib/migrations/20230912294620-update-pkg.d.ts +0 -14
  95. package/lib/migrations/20230912294620-update-pkg.js +0 -65
  96. package/lib/migrations/20240106082756-update-plugins.d.ts +0 -14
  97. package/lib/migrations/20240106082756-update-plugins.js +0 -51
  98. package/lib/migrations/20240428235620-rename-plugins.d.ts +0 -14
  99. package/lib/migrations/20240428235620-rename-plugins.js +0 -49
  100. package/lib/plugin-manager/clientStaticUtils.d.ts +0 -31
  101. package/lib/plugin-manager/clientStaticUtils.js +0 -129
  102. package/lib/plugin-manager/constants.d.ts +0 -15
  103. package/lib/plugin-manager/constants.js +0 -135
  104. package/lib/plugin-manager/deps.d.ts +0 -10
  105. package/lib/plugin-manager/deps.js +0 -83
  106. package/lib/plugin-manager/index.d.ts +0 -10
  107. package/lib/plugin-manager/index.js +0 -32
  108. package/lib/plugin-manager/middleware.d.ts +0 -10
  109. package/lib/plugin-manager/middleware.js +0 -45
  110. package/lib/plugin-manager/options/collection.d.ts +0 -10
  111. package/lib/plugin-manager/options/collection.js +0 -47
  112. package/lib/plugin-manager/options/resource.d.ts +0 -23
  113. package/lib/plugin-manager/options/resource.js +0 -186
  114. package/lib/plugin-manager/plugin-manager-repository.d.ts +0 -36
  115. package/lib/plugin-manager/plugin-manager-repository.js +0 -158
  116. package/lib/plugin-manager/plugin-manager.d.ts +0 -206
  117. package/lib/plugin-manager/plugin-manager.js +0 -1100
  118. package/lib/plugin-manager/types.d.ts +0 -23
  119. package/lib/plugin-manager/types.js +0 -24
  120. package/lib/plugin-manager/utils.d.ts +0 -115
  121. package/lib/plugin-manager/utils.js +0 -568
  122. package/lib/plugin.d.ts +0 -99
  123. package/lib/plugin.js +0 -228
  124. package/lib/swagger/index.json +0 -1569
@@ -1,40 +0,0 @@
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 plugin_command_error_exports = {};
29
- __export(plugin_command_error_exports, {
30
- PluginCommandError: () => PluginCommandError
31
- });
32
- module.exports = __toCommonJS(plugin_command_error_exports);
33
- const _PluginCommandError = class _PluginCommandError extends Error {
34
- };
35
- __name(_PluginCommandError, "PluginCommandError");
36
- let PluginCommandError = _PluginCommandError;
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- PluginCommandError
40
- });
@@ -1,10 +0,0 @@
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
- export declare class PluginNotExist extends Error {
10
- }
@@ -1,40 +0,0 @@
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 plugin_not_exist_exports = {};
29
- __export(plugin_not_exist_exports, {
30
- PluginNotExist: () => PluginNotExist
31
- });
32
- module.exports = __toCommonJS(plugin_not_exist_exports);
33
- const _PluginNotExist = class _PluginNotExist extends Error {
34
- };
35
- __name(_PluginNotExist, "PluginNotExist");
36
- let PluginNotExist = _PluginNotExist;
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- PluginNotExist
40
- });
@@ -1,30 +0,0 @@
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
- interface AppError {
10
- status: number;
11
- message: any;
12
- command?: any;
13
- maintaining: boolean;
14
- code: any;
15
- }
16
- interface AppErrors {
17
- [key: string]: Omit<AppError, 'code'> & {
18
- code?: any;
19
- };
20
- }
21
- export declare const errors: AppErrors;
22
- export declare function getErrorWithCode(errorCode: string): AppError;
23
- export declare function applyErrorWithArgs(error: AppError, options: any): {
24
- status: number;
25
- message: any;
26
- command?: any;
27
- maintaining: boolean;
28
- code: any;
29
- };
30
- export {};
@@ -1,154 +0,0 @@
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 __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
- var __export = (target, all) => {
18
- for (var name in all)
19
- __defProp(target, name, { get: all[name], enumerable: true });
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") {
23
- for (let key of __getOwnPropNames(from))
24
- if (!__hasOwnProp.call(to, key) && key !== except)
25
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
- }
27
- return to;
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
- // If the importer is in node compatibility mode or this is not an ESM
31
- // file that has been converted to a CommonJS file using a Babel-
32
- // compatible transform (i.e. "__esModule" has not been set), then set
33
- // "default" to the CommonJS "module.exports" for node compatibility.
34
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
- mod
36
- ));
37
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
- var errors_exports = {};
39
- __export(errors_exports, {
40
- applyErrorWithArgs: () => applyErrorWithArgs,
41
- errors: () => errors,
42
- getErrorWithCode: () => getErrorWithCode
43
- });
44
- module.exports = __toCommonJS(errors_exports);
45
- var import_app_supervisor = require("../app-supervisor");
46
- var import_lodash = __toESM(require("lodash"));
47
- const errors = {
48
- APP_NOT_FOUND: {
49
- status: 404,
50
- message: ({ appName }) => `application ${appName} not found`,
51
- maintaining: true
52
- },
53
- APP_ERROR: {
54
- status: 503,
55
- message: ({ app }) => {
56
- const error = import_app_supervisor.AppSupervisor.getInstance().appErrors[app.name];
57
- if (!error) {
58
- return "";
59
- }
60
- let message = error.message;
61
- if (error.cause) {
62
- message = `${message}: ${error.cause.message}`;
63
- }
64
- return message;
65
- },
66
- code: ({ app }) => {
67
- const error = import_app_supervisor.AppSupervisor.getInstance().appErrors[app.name];
68
- return error["code"] || "APP_ERROR";
69
- },
70
- command: ({ app }) => app.getMaintaining().command,
71
- maintaining: true
72
- },
73
- APP_STARTING: {
74
- status: 503,
75
- message: ({ app }) => app.maintainingMessage,
76
- maintaining: true
77
- },
78
- APP_STOPPED: {
79
- status: 503,
80
- message: ({ app }) => `application ${app.name} is stopped`,
81
- maintaining: true
82
- },
83
- APP_INITIALIZED: {
84
- status: 503,
85
- message: ({ app }) => `application ${app.name} is initialized, waiting for command`,
86
- maintaining: true
87
- },
88
- APP_INITIALIZING: {
89
- status: 503,
90
- message: ({ appName }) => `application ${appName} is initializing`,
91
- maintaining: true
92
- },
93
- COMMAND_ERROR: {
94
- status: 503,
95
- maintaining: true,
96
- message: ({ app }) => app.getMaintaining().error.message,
97
- command: ({ app }) => app.getMaintaining().command
98
- },
99
- COMMAND_END: {
100
- status: 503,
101
- maintaining: true,
102
- message: ({ app }) => `${app.getMaintaining().command.name} running end`,
103
- command: ({ app }) => app.getMaintaining().command
104
- },
105
- APP_COMMANDING: {
106
- status: 503,
107
- maintaining: true,
108
- message: ({ app, message }) => message || app.maintainingMessage,
109
- command: ({ app, command }) => command || app.getMaintaining().command
110
- },
111
- APP_RUNNING: {
112
- status: 200,
113
- maintaining: false,
114
- message: ({ message, app }) => message || `application ${app.name} is running`
115
- },
116
- UNKNOWN_ERROR: {
117
- status: 500,
118
- message: "unknown error",
119
- maintaining: true
120
- }
121
- };
122
- function getErrorWithCode(errorCode) {
123
- const rawCode = errorCode;
124
- errorCode = import_lodash.default.snakeCase(errorCode).toUpperCase();
125
- if (!errors[errorCode] && errors[`APP_${errorCode}`]) {
126
- errorCode = `APP_${errorCode}`;
127
- }
128
- if (!errors[errorCode]) {
129
- errorCode = "UNKNOWN_ERROR";
130
- }
131
- const error = import_lodash.default.cloneDeep(errors[errorCode]);
132
- if (!error.code) {
133
- error["code"] = errorCode == "UNKNOWN_ERROR" ? rawCode : errorCode;
134
- }
135
- return error;
136
- }
137
- __name(getErrorWithCode, "getErrorWithCode");
138
- function applyErrorWithArgs(error, options) {
139
- const functionKeys = Object.keys(error).filter((key) => typeof error[key] === "function");
140
- const functionResults = functionKeys.map((key) => {
141
- return error[key](options);
142
- });
143
- return {
144
- ...error,
145
- ...import_lodash.default.zipObject(functionKeys, functionResults)
146
- };
147
- }
148
- __name(applyErrorWithArgs, "applyErrorWithArgs");
149
- // Annotate the CommonJS export names for ESM import in node:
150
- 0 && (module.exports = {
151
- applyErrorWithArgs,
152
- errors,
153
- getErrorWithCode
154
- });
@@ -1,79 +0,0 @@
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
- /// <reference types="node" />
10
- /// <reference types="node" />
11
- import { SystemLogger } from '@nocobase/logger';
12
- import { Registry, Toposort, ToposortOptions } from '@nocobase/utils';
13
- import { EventEmitter } from 'events';
14
- import http, { IncomingMessage, ServerResponse } from 'http';
15
- import { ApplicationOptions } from '../application';
16
- import { IPCSocketClient } from './ipc-socket-client';
17
- import { IPCSocketServer } from './ipc-socket-server';
18
- export interface IncomingRequest {
19
- url: string;
20
- headers: any;
21
- }
22
- export type AppSelector = (req: IncomingRequest) => string | Promise<string>;
23
- export type AppSelectorMiddleware = (ctx: AppSelectorMiddlewareContext, next: () => Promise<void>) => void;
24
- interface StartHttpServerOptions {
25
- port: number;
26
- host: string;
27
- callback?: (server: http.Server) => void;
28
- }
29
- interface RunOptions {
30
- mainAppOptions: ApplicationOptions;
31
- }
32
- export interface AppSelectorMiddlewareContext {
33
- req: IncomingRequest;
34
- resolvedAppName: string | null;
35
- }
36
- export declare class Gateway extends EventEmitter {
37
- private static instance;
38
- /**
39
- * use main app as default app to handle request
40
- */
41
- selectorMiddlewares: Toposort<AppSelectorMiddleware>;
42
- server: http.Server | null;
43
- ipcSocketServer: IPCSocketServer | null;
44
- loggers: Registry<SystemLogger>;
45
- private port;
46
- private host;
47
- private wsServer;
48
- private socketPath;
49
- private constructor();
50
- static getInstance(options?: any): Gateway;
51
- static getIPCSocketClient(): Promise<false | IPCSocketClient>;
52
- destroy(): void;
53
- reset(): void;
54
- addAppSelectorMiddleware(middleware: AppSelectorMiddleware, options?: ToposortOptions): void;
55
- getLogger(appName: string, res: ServerResponse): import("@nocobase/logger/lib/logger").Logger;
56
- responseError(res: ServerResponse, error: {
57
- status: number;
58
- maintaining: boolean;
59
- message: string;
60
- code: string;
61
- }): void;
62
- responseErrorWithCode(code: any, res: any, options: any): void;
63
- requestHandler(req: IncomingMessage, res: ServerResponse): Promise<void>;
64
- getAppSelectorMiddlewares(): Toposort<AppSelectorMiddleware>;
65
- getRequestHandleAppName(req: IncomingRequest): Promise<string>;
66
- getCallback(): any;
67
- watch(): Promise<void>;
68
- run(options: RunOptions): Promise<void>;
69
- isStart(): boolean;
70
- isHelp(): boolean;
71
- getStartOptions(): import("commander").OptionValues;
72
- start(options: StartHttpServerOptions): void;
73
- startIPCSocketServer(): void;
74
- startHttpServer(options: StartHttpServerOptions): void;
75
- tryConnectToIPCServer(): Promise<false | IPCSocketClient>;
76
- getIPCSocketClient(): Promise<IPCSocketClient>;
77
- close(): void;
78
- }
79
- export {};