@tego/core 1.3.44

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 (152) hide show
  1. package/LICENSE +201 -0
  2. package/lib/acl/available-action.d.ts +5 -0
  3. package/lib/acl/available-action.js +62 -0
  4. package/lib/acl/index.d.ts +2 -0
  5. package/lib/acl/index.js +49 -0
  6. package/lib/aes-encryptor.d.ts +11 -0
  7. package/lib/aes-encryptor.js +116 -0
  8. package/lib/app-command.d.ts +12 -0
  9. package/lib/app-command.js +76 -0
  10. package/lib/app-supervisor.d.ts +61 -0
  11. package/lib/app-supervisor.js +299 -0
  12. package/lib/application.d.ts +354 -0
  13. package/lib/application.js +878 -0
  14. package/lib/cache/index.d.ts +3 -0
  15. package/lib/cache/index.js +35 -0
  16. package/lib/commands/console.d.ts +3 -0
  17. package/lib/commands/console.js +48 -0
  18. package/lib/commands/create-migration.d.ts +3 -0
  19. package/lib/commands/create-migration.js +80 -0
  20. package/lib/commands/db-auth.d.ts +3 -0
  21. package/lib/commands/db-auth.js +28 -0
  22. package/lib/commands/db-clean.d.ts +3 -0
  23. package/lib/commands/db-clean.js +31 -0
  24. package/lib/commands/db-sync.d.ts +3 -0
  25. package/lib/commands/db-sync.js +40 -0
  26. package/lib/commands/destroy.d.ts +3 -0
  27. package/lib/commands/destroy.js +30 -0
  28. package/lib/commands/index.d.ts +2 -0
  29. package/lib/commands/index.js +71 -0
  30. package/lib/commands/install.d.ts +3 -0
  31. package/lib/commands/install.js +33 -0
  32. package/lib/commands/migrator.d.ts +3 -0
  33. package/lib/commands/migrator.js +31 -0
  34. package/lib/commands/pm.d.ts +3 -0
  35. package/lib/commands/pm.js +75 -0
  36. package/lib/commands/refresh.d.ts +3 -0
  37. package/lib/commands/refresh.js +31 -0
  38. package/lib/commands/restart.d.ts +3 -0
  39. package/lib/commands/restart.js +35 -0
  40. package/lib/commands/start.d.ts +3 -0
  41. package/lib/commands/start.js +74 -0
  42. package/lib/commands/stop.d.ts +3 -0
  43. package/lib/commands/stop.js +34 -0
  44. package/lib/commands/upgrade.d.ts +3 -0
  45. package/lib/commands/upgrade.js +29 -0
  46. package/lib/cron/cron-job-manager.d.ts +25 -0
  47. package/lib/cron/cron-job-manager.js +89 -0
  48. package/lib/environment.d.ts +10 -0
  49. package/lib/environment.js +73 -0
  50. package/lib/errors/application-not-install.d.ts +4 -0
  51. package/lib/errors/application-not-install.js +35 -0
  52. package/lib/errors/handler.d.ts +3 -0
  53. package/lib/errors/handler.js +41 -0
  54. package/lib/errors/plugin-command-error.d.ts +2 -0
  55. package/lib/errors/plugin-command-error.js +31 -0
  56. package/lib/errors/plugin-not-exist.d.ts +2 -0
  57. package/lib/errors/plugin-not-exist.js +31 -0
  58. package/lib/gateway/errors.d.ts +22 -0
  59. package/lib/gateway/errors.js +138 -0
  60. package/lib/gateway/gateway.d.ts +56 -0
  61. package/lib/gateway/gateway.js +408 -0
  62. package/lib/gateway/index.d.ts +2 -0
  63. package/lib/gateway/index.js +30 -0
  64. package/lib/gateway/ipc-socket-client.d.ts +17 -0
  65. package/lib/gateway/ipc-socket-client.js +99 -0
  66. package/lib/gateway/ipc-socket-server.d.ts +12 -0
  67. package/lib/gateway/ipc-socket-server.js +140 -0
  68. package/lib/gateway/types.d.ts +25 -0
  69. package/lib/gateway/types.js +15 -0
  70. package/lib/gateway/ws-server.d.ts +63 -0
  71. package/lib/gateway/ws-server.js +335 -0
  72. package/lib/helper.d.ts +11 -0
  73. package/lib/helper.js +193 -0
  74. package/lib/helpers/application-version.d.ts +10 -0
  75. package/lib/helpers/application-version.js +77 -0
  76. package/lib/helpers/multiple-instance-manager.d.ts +6 -0
  77. package/lib/helpers/multiple-instance-manager.js +40 -0
  78. package/lib/index.d.ts +10 -0
  79. package/lib/index.js +57 -0
  80. package/lib/locale/index.d.ts +1 -0
  81. package/lib/locale/index.js +21 -0
  82. package/lib/locale/locale.d.ts +22 -0
  83. package/lib/locale/locale.js +166 -0
  84. package/lib/locale/resource.d.ts +1 -0
  85. package/lib/locale/resource.js +74 -0
  86. package/lib/main-data-source.d.ts +4 -0
  87. package/lib/main-data-source.js +45 -0
  88. package/lib/middlewares/data-template.d.ts +2 -0
  89. package/lib/middlewares/data-template.js +39 -0
  90. package/lib/middlewares/data-wrapping.d.ts +3 -0
  91. package/lib/middlewares/data-wrapping.js +90 -0
  92. package/lib/middlewares/db2resource.d.ts +6 -0
  93. package/lib/middlewares/db2resource.js +76 -0
  94. package/lib/middlewares/extract-client-ip.d.ts +2 -0
  95. package/lib/middlewares/extract-client-ip.js +37 -0
  96. package/lib/middlewares/i18n.d.ts +1 -0
  97. package/lib/middlewares/i18n.js +44 -0
  98. package/lib/middlewares/index.d.ts +3 -0
  99. package/lib/middlewares/index.js +32 -0
  100. package/lib/middlewares/parse-variables.d.ts +1 -0
  101. package/lib/middlewares/parse-variables.js +84 -0
  102. package/lib/migration.d.ts +12 -0
  103. package/lib/migration.js +47 -0
  104. package/lib/migrations/20230912193824-package-name-unique.d.ts +6 -0
  105. package/lib/migrations/20230912193824-package-name-unique.js +52 -0
  106. package/lib/migrations/20230912294620-update-pkg.d.ts +6 -0
  107. package/lib/migrations/20230912294620-update-pkg.js +58 -0
  108. package/lib/migrations/20240106082756-update-plugins.d.ts +6 -0
  109. package/lib/migrations/20240106082756-update-plugins.js +44 -0
  110. package/lib/migrations/20240705000001-remove-pkgs-approval.d.ts +6 -0
  111. package/lib/migrations/20240705000001-remove-pkgs-approval.js +47 -0
  112. package/lib/notice/index.d.ts +25 -0
  113. package/lib/notice/index.js +91 -0
  114. package/lib/plugin-manager/clientStaticUtils.d.ts +24 -0
  115. package/lib/plugin-manager/clientStaticUtils.js +156 -0
  116. package/lib/plugin-manager/constants.d.ts +7 -0
  117. package/lib/plugin-manager/constants.js +120 -0
  118. package/lib/plugin-manager/deps.d.ts +2 -0
  119. package/lib/plugin-manager/deps.js +68 -0
  120. package/lib/plugin-manager/index.d.ts +2 -0
  121. package/lib/plugin-manager/index.js +23 -0
  122. package/lib/plugin-manager/middleware.d.ts +2 -0
  123. package/lib/plugin-manager/middleware.js +36 -0
  124. package/lib/plugin-manager/options/collection.d.ts +2 -0
  125. package/lib/plugin-manager/options/collection.js +39 -0
  126. package/lib/plugin-manager/options/resource.d.ts +15 -0
  127. package/lib/plugin-manager/options/resource.js +185 -0
  128. package/lib/plugin-manager/plugin-manager-repository.d.ts +27 -0
  129. package/lib/plugin-manager/plugin-manager-repository.js +136 -0
  130. package/lib/plugin-manager/plugin-manager.d.ts +205 -0
  131. package/lib/plugin-manager/plugin-manager.js +1032 -0
  132. package/lib/plugin-manager/types.d.ts +15 -0
  133. package/lib/plugin-manager/types.js +15 -0
  134. package/lib/plugin-manager/utils.d.ts +101 -0
  135. package/lib/plugin-manager/utils.js +513 -0
  136. package/lib/plugin-manager/web-service.d.ts +6 -0
  137. package/lib/plugin-manager/web-service.js +116 -0
  138. package/lib/plugin.d.ts +125 -0
  139. package/lib/plugin.js +359 -0
  140. package/lib/pub-sub-manager/handler-manager.d.ts +28 -0
  141. package/lib/pub-sub-manager/handler-manager.js +149 -0
  142. package/lib/pub-sub-manager/index.d.ts +3 -0
  143. package/lib/pub-sub-manager/index.js +25 -0
  144. package/lib/pub-sub-manager/memory-pub-sub-adapter.d.ts +21 -0
  145. package/lib/pub-sub-manager/memory-pub-sub-adapter.js +82 -0
  146. package/lib/pub-sub-manager/pub-sub-manager.d.ts +19 -0
  147. package/lib/pub-sub-manager/pub-sub-manager.js +108 -0
  148. package/lib/pub-sub-manager/types.d.ts +20 -0
  149. package/lib/pub-sub-manager/types.js +15 -0
  150. package/lib/sync-message-manager.d.ts +16 -0
  151. package/lib/sync-message-manager.js +112 -0
  152. package/package.json +58 -0
@@ -0,0 +1,74 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var start_exports = {};
30
+ __export(start_exports, {
31
+ default: () => start_default
32
+ });
33
+ module.exports = __toCommonJS(start_exports);
34
+ var import_node_fs = __toESM(require("node:fs"));
35
+ var import_node_path = require("node:path");
36
+ var import_node_perf_hooks = require("node:perf_hooks");
37
+ var import_utils = require("@tachybase/utils");
38
+ var import_application_not_install = require("../errors/application-not-install");
39
+ var start_default = /* @__PURE__ */ __name((app) => {
40
+ app.command("start").auth().option("--db-sync").option("--quickstart").action(async (...cliArgs) => {
41
+ const [options] = cliArgs;
42
+ app.logger.debug("start options", options);
43
+ const file = (0, import_node_path.resolve)(process.cwd(), "storage/app-upgrading");
44
+ const upgrading = await (0, import_utils.fsExists)(file);
45
+ if (upgrading) {
46
+ await app.upgrade();
47
+ await import_node_fs.default.promises.rm(file);
48
+ } else if (options.quickstart) {
49
+ if (await app.isInstalled()) {
50
+ await app.upgrade();
51
+ } else {
52
+ await app.install();
53
+ }
54
+ app["_started"] = true;
55
+ await app.restart();
56
+ app.logger.info("app has been started");
57
+ return;
58
+ }
59
+ if (!await app.isInstalled()) {
60
+ app["_started"] = true;
61
+ throw new import_application_not_install.ApplicationNotInstall(
62
+ `Application ${app.name} is not installed, Please run 'pnpm tachybase install' command first`
63
+ );
64
+ }
65
+ await app.load();
66
+ await app.start({
67
+ dbSync: options == null ? void 0 : options.dbSync,
68
+ quickstart: options.quickstart,
69
+ cliArgs,
70
+ checkInstall: true
71
+ });
72
+ app.logger.info(`app has been started at ${import_node_perf_hooks.performance.now().toFixed(2)} ms`);
73
+ });
74
+ }, "default");
@@ -0,0 +1,3 @@
1
+ import Application from '../application';
2
+ declare const _default: (app: Application) => void;
3
+ export default _default;
@@ -0,0 +1,34 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var stop_exports = {};
20
+ __export(stop_exports, {
21
+ default: () => stop_default
22
+ });
23
+ module.exports = __toCommonJS(stop_exports);
24
+ var stop_default = /* @__PURE__ */ __name((app) => {
25
+ app.command("stop").ipc().action(async (...cliArgs) => {
26
+ if (!await app.isStarted()) {
27
+ app.logger.info("app has not started");
28
+ return;
29
+ }
30
+ await app.stop({
31
+ cliArgs
32
+ });
33
+ });
34
+ }, "default");
@@ -0,0 +1,3 @@
1
+ import Application from '../application';
2
+ declare const _default: (app: Application) => void;
3
+ export default _default;
@@ -0,0 +1,29 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var upgrade_exports = {};
20
+ __export(upgrade_exports, {
21
+ default: () => upgrade_default
22
+ });
23
+ module.exports = __toCommonJS(upgrade_exports);
24
+ var upgrade_default = /* @__PURE__ */ __name((app) => {
25
+ app.command("upgrade").ipc().auth().action(async (options) => {
26
+ await app.upgrade(options);
27
+ app.logger.info(`\u2728 TachyBase has been upgraded to v${await app.version.get()}`);
28
+ });
29
+ }, "default");
@@ -0,0 +1,25 @@
1
+ import Application from '../application';
2
+ export interface CronJobParameters {
3
+ cronTime: string;
4
+ onTick: () => void;
5
+ start?: boolean;
6
+ timeZone?: string;
7
+ context?: any;
8
+ }
9
+ export declare class CronJob {
10
+ constructor(params: CronJobParameters);
11
+ start(): void;
12
+ stop(): void;
13
+ }
14
+ export declare class CronJobManager {
15
+ private app;
16
+ private _jobs;
17
+ private _started;
18
+ constructor(app: Application);
19
+ get started(): boolean;
20
+ get jobs(): Set<CronJob>;
21
+ addJob(options: CronJobParameters): CronJob;
22
+ removeJob(job: CronJob): void;
23
+ start(): void;
24
+ stop(): void;
25
+ }
@@ -0,0 +1,89 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var cron_job_manager_exports = {};
20
+ __export(cron_job_manager_exports, {
21
+ CronJob: () => CronJob,
22
+ CronJobManager: () => CronJobManager
23
+ });
24
+ module.exports = __toCommonJS(cron_job_manager_exports);
25
+ const _CronJob = class _CronJob {
26
+ constructor(params) {
27
+ if (params.start !== false) {
28
+ this.start();
29
+ }
30
+ }
31
+ start() {
32
+ console.log("Mock CronJob started");
33
+ }
34
+ stop() {
35
+ console.log("Mock CronJob stopped");
36
+ }
37
+ };
38
+ __name(_CronJob, "CronJob");
39
+ let CronJob = _CronJob;
40
+ const _CronJobManager = class _CronJobManager {
41
+ constructor(app) {
42
+ this.app = app;
43
+ this._jobs = /* @__PURE__ */ new Set();
44
+ this._started = false;
45
+ app.on("beforeStop", async () => {
46
+ this.stop();
47
+ });
48
+ app.on("afterStart", async () => {
49
+ this.start();
50
+ });
51
+ app.on("beforeReload", async () => {
52
+ this.stop();
53
+ });
54
+ }
55
+ get started() {
56
+ return this._started;
57
+ }
58
+ get jobs() {
59
+ return this._jobs;
60
+ }
61
+ addJob(options) {
62
+ const cronJob = new CronJob(options);
63
+ this._jobs.add(cronJob);
64
+ return cronJob;
65
+ }
66
+ removeJob(job) {
67
+ job.stop();
68
+ this._jobs.delete(job);
69
+ }
70
+ start() {
71
+ this._jobs.forEach((job) => {
72
+ job.start();
73
+ });
74
+ this._started = true;
75
+ }
76
+ stop() {
77
+ this._jobs.forEach((job) => {
78
+ job.stop();
79
+ });
80
+ this._started = false;
81
+ }
82
+ };
83
+ __name(_CronJobManager, "CronJobManager");
84
+ let CronJobManager = _CronJobManager;
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ CronJob,
88
+ CronJobManager
89
+ });
@@ -0,0 +1,10 @@
1
+ export declare class Environment {
2
+ private vars;
3
+ setVariable(key: string, value: string): void;
4
+ removeVariable(key: string): void;
5
+ getVariablesAndSecrets(): {};
6
+ getVariables(): {};
7
+ renderJsonTemplate(template: any, options?: {
8
+ omit?: string[];
9
+ }): any;
10
+ }
@@ -0,0 +1,73 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var environment_exports = {};
30
+ __export(environment_exports, {
31
+ Environment: () => Environment
32
+ });
33
+ module.exports = __toCommonJS(environment_exports);
34
+ var import_utils = require("@tachybase/utils");
35
+ var import_lodash = __toESM(require("lodash"));
36
+ const _Environment = class _Environment {
37
+ constructor() {
38
+ this.vars = {};
39
+ }
40
+ setVariable(key, value) {
41
+ this.vars[key] = value;
42
+ }
43
+ removeVariable(key) {
44
+ delete this.vars[key];
45
+ }
46
+ getVariablesAndSecrets() {
47
+ return this.vars;
48
+ }
49
+ getVariables() {
50
+ return this.vars;
51
+ }
52
+ renderJsonTemplate(template, options) {
53
+ if (options == null ? void 0 : options.omit) {
54
+ const omitTemplate = import_lodash.default.omit(template, options.omit);
55
+ const parsed = (0, import_utils.parse)(omitTemplate)({
56
+ $env: this.vars
57
+ });
58
+ for (const key of options.omit) {
59
+ import_lodash.default.set(parsed, key, import_lodash.default.get(template, key));
60
+ }
61
+ return parsed;
62
+ }
63
+ return (0, import_utils.parse)(template)({
64
+ $env: this.vars
65
+ });
66
+ }
67
+ };
68
+ __name(_Environment, "Environment");
69
+ let Environment = _Environment;
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ Environment
73
+ });
@@ -0,0 +1,4 @@
1
+ export declare class ApplicationNotInstall extends Error {
2
+ code: string;
3
+ constructor(message: any);
4
+ }
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var application_not_install_exports = {};
20
+ __export(application_not_install_exports, {
21
+ ApplicationNotInstall: () => ApplicationNotInstall
22
+ });
23
+ module.exports = __toCommonJS(application_not_install_exports);
24
+ const _ApplicationNotInstall = class _ApplicationNotInstall extends Error {
25
+ constructor(message) {
26
+ super(message);
27
+ this.code = "APP_NOT_INSTALLED_ERROR";
28
+ }
29
+ };
30
+ __name(_ApplicationNotInstall, "ApplicationNotInstall");
31
+ let ApplicationNotInstall = _ApplicationNotInstall;
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ ApplicationNotInstall
35
+ });
@@ -0,0 +1,3 @@
1
+ type ErrorLevel = 'fatal' | 'silly' | 'warn';
2
+ export declare function getErrorLevel(e: Error): ErrorLevel;
3
+ export {};
@@ -0,0 +1,41 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var handler_exports = {};
20
+ __export(handler_exports, {
21
+ getErrorLevel: () => getErrorLevel
22
+ });
23
+ module.exports = __toCommonJS(handler_exports);
24
+ var import_plugin_command_error = require("./plugin-command-error");
25
+ function getErrorLevel(e) {
26
+ if (e.code === "commander.unknownCommand") {
27
+ return "silly";
28
+ }
29
+ if (e instanceof import_plugin_command_error.PluginCommandError) {
30
+ return "warn";
31
+ }
32
+ if (e.name === "RestoreCheckError") {
33
+ return "warn";
34
+ }
35
+ return "fatal";
36
+ }
37
+ __name(getErrorLevel, "getErrorLevel");
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ getErrorLevel
41
+ });
@@ -0,0 +1,2 @@
1
+ export declare class PluginCommandError extends Error {
2
+ }
@@ -0,0 +1,31 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var plugin_command_error_exports = {};
20
+ __export(plugin_command_error_exports, {
21
+ PluginCommandError: () => PluginCommandError
22
+ });
23
+ module.exports = __toCommonJS(plugin_command_error_exports);
24
+ const _PluginCommandError = class _PluginCommandError extends Error {
25
+ };
26
+ __name(_PluginCommandError, "PluginCommandError");
27
+ let PluginCommandError = _PluginCommandError;
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ PluginCommandError
31
+ });
@@ -0,0 +1,2 @@
1
+ export declare class PluginNotExist extends Error {
2
+ }
@@ -0,0 +1,31 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var plugin_not_exist_exports = {};
20
+ __export(plugin_not_exist_exports, {
21
+ PluginNotExist: () => PluginNotExist
22
+ });
23
+ module.exports = __toCommonJS(plugin_not_exist_exports);
24
+ const _PluginNotExist = class _PluginNotExist extends Error {
25
+ };
26
+ __name(_PluginNotExist, "PluginNotExist");
27
+ let PluginNotExist = _PluginNotExist;
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ PluginNotExist
31
+ });
@@ -0,0 +1,22 @@
1
+ interface AppError {
2
+ status: number;
3
+ message: any;
4
+ command?: any;
5
+ maintaining: boolean;
6
+ code: any;
7
+ }
8
+ interface AppErrors {
9
+ [key: string]: Omit<AppError, 'code'> & {
10
+ code?: any;
11
+ };
12
+ }
13
+ export declare const errors: AppErrors;
14
+ export declare function getErrorWithCode(errorCode: string): AppError;
15
+ export declare function applyErrorWithArgs(error: AppError, options: any): {
16
+ status: number;
17
+ message: any;
18
+ command?: any;
19
+ maintaining: boolean;
20
+ code: any;
21
+ };
22
+ export {};
@@ -0,0 +1,138 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var errors_exports = {};
30
+ __export(errors_exports, {
31
+ applyErrorWithArgs: () => applyErrorWithArgs,
32
+ errors: () => errors,
33
+ getErrorWithCode: () => getErrorWithCode
34
+ });
35
+ module.exports = __toCommonJS(errors_exports);
36
+ var import_lodash = __toESM(require("lodash"));
37
+ var import_app_supervisor = require("../app-supervisor");
38
+ const errors = {
39
+ APP_NOT_FOUND: {
40
+ status: 404,
41
+ message: /* @__PURE__ */ __name(({ appName }) => `application ${appName} not found`, "message"),
42
+ maintaining: true
43
+ },
44
+ APP_ERROR: {
45
+ status: 503,
46
+ message: /* @__PURE__ */ __name(({ app }) => {
47
+ var _a;
48
+ return (_a = import_app_supervisor.AppSupervisor.getInstance().appErrors[app.name]) == null ? void 0 : _a.message;
49
+ }, "message"),
50
+ code: /* @__PURE__ */ __name(({ app }) => {
51
+ const error = import_app_supervisor.AppSupervisor.getInstance().appErrors[app.name];
52
+ return error["code"] || "APP_ERROR";
53
+ }, "code"),
54
+ command: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().command, "command"),
55
+ maintaining: true
56
+ },
57
+ APP_STARTING: {
58
+ status: 503,
59
+ message: /* @__PURE__ */ __name(({ app }) => app.maintainingMessage, "message"),
60
+ maintaining: true
61
+ },
62
+ APP_STOPPED: {
63
+ status: 503,
64
+ message: /* @__PURE__ */ __name(({ app }) => `application ${app.name} is stopped`, "message"),
65
+ maintaining: true
66
+ },
67
+ APP_INITIALIZED: {
68
+ status: 503,
69
+ message: /* @__PURE__ */ __name(({ app }) => `application ${app.name} is initialized, waiting for command`, "message"),
70
+ maintaining: true
71
+ },
72
+ APP_INITIALIZING: {
73
+ status: 503,
74
+ message: /* @__PURE__ */ __name(({ appName }) => `application ${appName} is initializing`, "message"),
75
+ maintaining: true
76
+ },
77
+ COMMAND_ERROR: {
78
+ status: 503,
79
+ maintaining: true,
80
+ message: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().error.message, "message"),
81
+ command: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().command, "command")
82
+ },
83
+ COMMAND_END: {
84
+ status: 503,
85
+ maintaining: true,
86
+ message: /* @__PURE__ */ __name(({ app }) => `${app.getMaintaining().command.name} running end`, "message"),
87
+ command: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().command, "command")
88
+ },
89
+ APP_COMMANDING: {
90
+ status: 503,
91
+ maintaining: true,
92
+ message: /* @__PURE__ */ __name(({ app, message }) => message || app.maintainingMessage, "message"),
93
+ command: /* @__PURE__ */ __name(({ app, command }) => command || app.getMaintaining().command, "command")
94
+ },
95
+ APP_RUNNING: {
96
+ status: 200,
97
+ maintaining: false,
98
+ message: /* @__PURE__ */ __name(({ message, app }) => message || `application ${app.name} is running`, "message")
99
+ },
100
+ UNKNOWN_ERROR: {
101
+ status: 500,
102
+ message: "unknown error",
103
+ maintaining: true
104
+ }
105
+ };
106
+ function getErrorWithCode(errorCode) {
107
+ const rawCode = errorCode;
108
+ errorCode = import_lodash.default.snakeCase(errorCode).toUpperCase();
109
+ if (!errors[errorCode] && errors[`APP_${errorCode}`]) {
110
+ errorCode = `APP_${errorCode}`;
111
+ }
112
+ if (!errors[errorCode]) {
113
+ errorCode = "UNKNOWN_ERROR";
114
+ }
115
+ const error = import_lodash.default.cloneDeep(errors[errorCode]);
116
+ if (!error.code) {
117
+ error["code"] = errorCode === "UNKNOWN_ERROR" ? rawCode : errorCode;
118
+ }
119
+ return error;
120
+ }
121
+ __name(getErrorWithCode, "getErrorWithCode");
122
+ function applyErrorWithArgs(error, options) {
123
+ const functionKeys = Object.keys(error).filter((key) => typeof error[key] === "function");
124
+ const functionResults = functionKeys.map((key) => {
125
+ return error[key](options);
126
+ });
127
+ return {
128
+ ...error,
129
+ ...import_lodash.default.zipObject(functionKeys, functionResults)
130
+ };
131
+ }
132
+ __name(applyErrorWithArgs, "applyErrorWithArgs");
133
+ // Annotate the CommonJS export names for ESM import in node:
134
+ 0 && (module.exports = {
135
+ applyErrorWithArgs,
136
+ errors,
137
+ getErrorWithCode
138
+ });