@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,205 @@
1
+ import net from 'node:net';
2
+ import { CleanOptions, Collection, SyncOptions } from '@tachybase/database';
3
+ import { Constructable } from '@tachybase/utils';
4
+ import Application from '../application';
5
+ import { Plugin } from '../plugin';
6
+ import { PluginManagerRepository } from './plugin-manager-repository';
7
+ import { PluginData } from './types';
8
+ export declare const sleep: (timeout?: number) => Promise<unknown>;
9
+ export interface PluginManagerOptions {
10
+ app: Application;
11
+ plugins?: any[];
12
+ }
13
+ export interface InstallOptions {
14
+ cliArgs?: any[];
15
+ clean?: CleanOptions | boolean;
16
+ force?: boolean;
17
+ sync?: SyncOptions;
18
+ }
19
+ export declare class AddPresetError extends Error {
20
+ }
21
+ export declare class PluginManager {
22
+ options: PluginManagerOptions;
23
+ /**
24
+ * @internal
25
+ */
26
+ app: Application;
27
+ /**
28
+ * @internal
29
+ */
30
+ collection: Collection;
31
+ /**
32
+ * @internal
33
+ */
34
+ pluginInstances: Map<Constructable<Plugin>, Plugin>;
35
+ /**
36
+ * @internal
37
+ */
38
+ pluginAliases: Map<string, Plugin>;
39
+ /**
40
+ * @internal
41
+ */
42
+ server: net.Server;
43
+ /**
44
+ * @internal
45
+ */
46
+ _repository: PluginManagerRepository;
47
+ /**
48
+ * @internal
49
+ */
50
+ constructor(options: PluginManagerOptions);
51
+ get repository(): PluginManagerRepository;
52
+ /**
53
+ * @internal
54
+ */
55
+ static getPackageJson(packageName: string): Promise<any>;
56
+ /**
57
+ * @internal
58
+ */
59
+ static getPackageName(name: string): Promise<string>;
60
+ /**
61
+ * @internal
62
+ */
63
+ static getPluginPkgPrefix(): string[];
64
+ /**
65
+ * @internal
66
+ */
67
+ static findPackage(name: string): Promise<string>;
68
+ /**
69
+ * @internal
70
+ */
71
+ static clearCache(packageName: string): void;
72
+ /**
73
+ * @internal
74
+ */
75
+ static resolvePlugin(pluginName: string | typeof Plugin, isUpgrade?: boolean, isPkg?: boolean): Promise<any>;
76
+ addPreset(plugin: string | typeof Plugin, options?: any): void;
77
+ getPlugins(): Map<Constructable<Plugin>, Plugin>;
78
+ getAliases(): MapIterator<string>;
79
+ get<T extends Plugin>(name: string): Plugin | undefined;
80
+ get<T extends Plugin>(name: Constructable<T>): T | undefined;
81
+ get<T extends Plugin>(name: string | Constructable<T>): Plugin | undefined;
82
+ has<T extends Plugin>(name: string | Constructable<T>): boolean;
83
+ del<T extends Plugin>(name: string | Constructable<T>): void;
84
+ create(pluginName: string, options?: {
85
+ forceRecreate?: boolean;
86
+ }): Promise<void>;
87
+ add(plugin?: any, options?: any, insert?: boolean, isUpgrade?: boolean): Promise<void>;
88
+ /**
89
+ * @internal
90
+ */
91
+ initPlugins(): Promise<void>;
92
+ /**
93
+ * @internal
94
+ */
95
+ loadCommands(): Promise<void>;
96
+ load(options?: any): Promise<void>;
97
+ install(options?: InstallOptions): Promise<void>;
98
+ enable(name: string | string[]): Promise<void>;
99
+ disable(name: string | string[]): Promise<void>;
100
+ remove(name: string | string[], options?: {
101
+ removeDir?: boolean;
102
+ force?: boolean;
103
+ }): Promise<void>;
104
+ /**
105
+ * @deprecated
106
+ */
107
+ loadOne(plugin: Plugin): Promise<void>;
108
+ /**
109
+ * @internal
110
+ */
111
+ addViaCLI(urlOrName: string, options?: PluginData): Promise<void>;
112
+ /**
113
+ * @internal
114
+ */
115
+ addByNpm(options: {
116
+ packageName: string;
117
+ name?: string;
118
+ registry: string;
119
+ authToken?: string;
120
+ }): Promise<void>;
121
+ /**
122
+ * @internal
123
+ */
124
+ addByFile(options: {
125
+ file: string;
126
+ registry?: string;
127
+ authToken?: string;
128
+ type?: string;
129
+ name?: string;
130
+ }): Promise<void>;
131
+ /**
132
+ * @internal
133
+ */
134
+ addByCompressedFileUrl(options: {
135
+ compressedFileUrl: string;
136
+ registry?: string;
137
+ authToken?: string;
138
+ type?: string;
139
+ name?: string;
140
+ }): Promise<void>;
141
+ update(options: PluginData): Promise<void>;
142
+ /**
143
+ * @internal
144
+ */
145
+ upgradeByNpm(values: PluginData): Promise<void>;
146
+ /**
147
+ * @internal
148
+ */
149
+ upgradeByCompressedFileUrl(options: PluginData): Promise<void>;
150
+ /**
151
+ * @internal
152
+ */
153
+ getNameByPackageName(packageName: string): string;
154
+ list(options?: any): Promise<any[]>;
155
+ /**
156
+ * @internal
157
+ */
158
+ getNpmVersionList(name: string): Promise<string[]>;
159
+ /**
160
+ * @internal
161
+ */
162
+ loadPresetMigrations(): Promise<{
163
+ beforeLoad: {
164
+ up: () => Promise<void>;
165
+ };
166
+ afterSync: {
167
+ up: () => Promise<void>;
168
+ };
169
+ afterLoad: {
170
+ up: () => Promise<void>;
171
+ };
172
+ }>;
173
+ /**
174
+ * @internal
175
+ */
176
+ loadOtherMigrations(): Promise<{
177
+ beforeLoad: {
178
+ up: () => Promise<void>;
179
+ };
180
+ afterSync: {
181
+ up: () => Promise<void>;
182
+ };
183
+ afterLoad: {
184
+ up: () => Promise<void>;
185
+ };
186
+ }>;
187
+ /**
188
+ * @internal
189
+ */
190
+ loadPresetPlugins(): Promise<void>;
191
+ upgrade(): Promise<void>;
192
+ /**
193
+ * @internal
194
+ */
195
+ initOtherPlugins(): Promise<void>;
196
+ /**
197
+ * @internal
198
+ */
199
+ initPresetPlugins(): Promise<void>;
200
+ /**
201
+ * @internal
202
+ */
203
+ initRuntimePlugins(): Promise<void>;
204
+ }
205
+ export default PluginManager;