@hotmeshio/hotmesh 0.3.31 → 0.4.0

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 (254) hide show
  1. package/README.md +128 -823
  2. package/build/index.d.ts +9 -9
  3. package/build/index.js +10 -10
  4. package/build/package.json +22 -21
  5. package/build/types/error.d.ts +5 -5
  6. package/build/types/exporter.d.ts +1 -1
  7. package/build/types/index.d.ts +3 -3
  8. package/build/types/manifest.d.ts +2 -2
  9. package/build/types/{meshflow.d.ts → memflow.d.ts} +15 -15
  10. package/build/types/meshdata.d.ts +3 -3
  11. package/build/types/postgres.d.ts +7 -0
  12. package/build/types/stream.d.ts +3 -0
  13. package/index.ts +11 -11
  14. package/package.json +22 -21
  15. package/typedoc.json +8 -7
  16. package/types/error.ts +5 -5
  17. package/types/exporter.ts +1 -1
  18. package/types/index.ts +7 -7
  19. package/types/manifest.ts +2 -2
  20. package/types/{meshflow.ts → memflow.ts} +15 -15
  21. package/types/meshdata.ts +3 -3
  22. package/types/postgres.ts +9 -0
  23. package/types/stream.ts +4 -0
  24. package/build/modules/enums.d.ts +0 -108
  25. package/build/modules/enums.js +0 -132
  26. package/build/modules/errors.d.ts +0 -124
  27. package/build/modules/errors.js +0 -191
  28. package/build/modules/key.d.ts +0 -66
  29. package/build/modules/key.js +0 -1
  30. package/build/modules/storage.d.ts +0 -3
  31. package/build/modules/storage.js +0 -5
  32. package/build/modules/utils.d.ts +0 -119
  33. package/build/modules/utils.js +0 -1
  34. package/build/services/activities/activity.d.ts +0 -104
  35. package/build/services/activities/activity.js +0 -1
  36. package/build/services/activities/await.d.ts +0 -12
  37. package/build/services/activities/await.js +0 -1
  38. package/build/services/activities/cycle.d.ts +0 -19
  39. package/build/services/activities/cycle.js +0 -1
  40. package/build/services/activities/hook.d.ts +0 -27
  41. package/build/services/activities/hook.js +0 -1
  42. package/build/services/activities/index.d.ts +0 -19
  43. package/build/services/activities/index.js +0 -1
  44. package/build/services/activities/interrupt.d.ts +0 -16
  45. package/build/services/activities/interrupt.js +0 -1
  46. package/build/services/activities/signal.d.ts +0 -20
  47. package/build/services/activities/signal.js +0 -1
  48. package/build/services/activities/trigger.d.ts +0 -37
  49. package/build/services/activities/trigger.js +0 -1
  50. package/build/services/activities/worker.d.ts +0 -12
  51. package/build/services/activities/worker.js +0 -1
  52. package/build/services/collator/index.d.ts +0 -111
  53. package/build/services/collator/index.js +0 -1
  54. package/build/services/compiler/deployer.d.ts +0 -40
  55. package/build/services/compiler/deployer.js +0 -1
  56. package/build/services/compiler/index.d.ts +0 -32
  57. package/build/services/compiler/index.js +0 -1
  58. package/build/services/compiler/validator.d.ts +0 -34
  59. package/build/services/compiler/validator.js +0 -1
  60. package/build/services/connector/factory.d.ts +0 -22
  61. package/build/services/connector/factory.js +0 -99
  62. package/build/services/connector/index.d.ts +0 -30
  63. package/build/services/connector/index.js +0 -54
  64. package/build/services/connector/providers/ioredis.d.ts +0 -9
  65. package/build/services/connector/providers/ioredis.js +0 -26
  66. package/build/services/connector/providers/nats.d.ts +0 -9
  67. package/build/services/connector/providers/nats.js +0 -34
  68. package/build/services/connector/providers/postgres.d.ts +0 -20
  69. package/build/services/connector/providers/postgres.js +0 -102
  70. package/build/services/connector/providers/redis.d.ts +0 -9
  71. package/build/services/connector/providers/redis.js +0 -38
  72. package/build/services/engine/index.d.ts +0 -264
  73. package/build/services/engine/index.js +0 -1
  74. package/build/services/exporter/index.d.ts +0 -44
  75. package/build/services/exporter/index.js +0 -1
  76. package/build/services/hotmesh/index.d.ts +0 -340
  77. package/build/services/hotmesh/index.js +0 -479
  78. package/build/services/logger/index.d.ts +0 -16
  79. package/build/services/logger/index.js +0 -54
  80. package/build/services/mapper/index.d.ts +0 -28
  81. package/build/services/mapper/index.js +0 -1
  82. package/build/services/meshcall/index.d.ts +0 -194
  83. package/build/services/meshcall/index.js +0 -452
  84. package/build/services/meshcall/schemas/factory.d.ts +0 -9
  85. package/build/services/meshcall/schemas/factory.js +0 -189
  86. package/build/services/meshdata/index.d.ts +0 -795
  87. package/build/services/meshdata/index.js +0 -1235
  88. package/build/services/meshflow/client.d.ts +0 -108
  89. package/build/services/meshflow/client.js +0 -371
  90. package/build/services/meshflow/connection.d.ts +0 -23
  91. package/build/services/meshflow/connection.js +0 -33
  92. package/build/services/meshflow/exporter.d.ts +0 -51
  93. package/build/services/meshflow/exporter.js +0 -1
  94. package/build/services/meshflow/handle.d.ts +0 -90
  95. package/build/services/meshflow/handle.js +0 -176
  96. package/build/services/meshflow/index.d.ts +0 -111
  97. package/build/services/meshflow/index.js +0 -117
  98. package/build/services/meshflow/schemas/factory.d.ts +0 -29
  99. package/build/services/meshflow/schemas/factory.js +0 -2492
  100. package/build/services/meshflow/search.d.ts +0 -142
  101. package/build/services/meshflow/search.js +0 -320
  102. package/build/services/meshflow/worker.d.ts +0 -124
  103. package/build/services/meshflow/worker.js +0 -514
  104. package/build/services/meshflow/workflow/all.d.ts +0 -7
  105. package/build/services/meshflow/workflow/all.js +0 -15
  106. package/build/services/meshflow/workflow/common.d.ts +0 -18
  107. package/build/services/meshflow/workflow/common.js +0 -45
  108. package/build/services/meshflow/workflow/context.d.ts +0 -6
  109. package/build/services/meshflow/workflow/context.js +0 -45
  110. package/build/services/meshflow/workflow/didRun.d.ts +0 -7
  111. package/build/services/meshflow/workflow/didRun.js +0 -22
  112. package/build/services/meshflow/workflow/emit.d.ts +0 -11
  113. package/build/services/meshflow/workflow/emit.js +0 -29
  114. package/build/services/meshflow/workflow/enrich.d.ts +0 -9
  115. package/build/services/meshflow/workflow/enrich.js +0 -17
  116. package/build/services/meshflow/workflow/execChild.d.ts +0 -18
  117. package/build/services/meshflow/workflow/execChild.js +0 -102
  118. package/build/services/meshflow/workflow/hook.d.ts +0 -9
  119. package/build/services/meshflow/workflow/hook.js +0 -40
  120. package/build/services/meshflow/workflow/index.d.ts +0 -70
  121. package/build/services/meshflow/workflow/index.js +0 -83
  122. package/build/services/meshflow/workflow/interrupt.d.ts +0 -9
  123. package/build/services/meshflow/workflow/interrupt.js +0 -24
  124. package/build/services/meshflow/workflow/isSideEffectAllowed.d.ts +0 -10
  125. package/build/services/meshflow/workflow/isSideEffectAllowed.js +0 -33
  126. package/build/services/meshflow/workflow/proxyActivities.d.ts +0 -20
  127. package/build/services/meshflow/workflow/proxyActivities.js +0 -97
  128. package/build/services/meshflow/workflow/random.d.ts +0 -6
  129. package/build/services/meshflow/workflow/random.js +0 -16
  130. package/build/services/meshflow/workflow/searchMethods.d.ts +0 -6
  131. package/build/services/meshflow/workflow/searchMethods.js +0 -25
  132. package/build/services/meshflow/workflow/signal.d.ts +0 -7
  133. package/build/services/meshflow/workflow/signal.js +0 -28
  134. package/build/services/meshflow/workflow/sleepFor.d.ts +0 -8
  135. package/build/services/meshflow/workflow/sleepFor.js +0 -35
  136. package/build/services/meshflow/workflow/trace.d.ts +0 -14
  137. package/build/services/meshflow/workflow/trace.js +0 -33
  138. package/build/services/meshflow/workflow/waitFor.d.ts +0 -8
  139. package/build/services/meshflow/workflow/waitFor.js +0 -35
  140. package/build/services/meshos/index.d.ts +0 -293
  141. package/build/services/meshos/index.js +0 -547
  142. package/build/services/pipe/functions/array.d.ts +0 -17
  143. package/build/services/pipe/functions/array.js +0 -1
  144. package/build/services/pipe/functions/bitwise.d.ts +0 -9
  145. package/build/services/pipe/functions/bitwise.js +0 -1
  146. package/build/services/pipe/functions/conditional.d.ts +0 -13
  147. package/build/services/pipe/functions/conditional.js +0 -1
  148. package/build/services/pipe/functions/cron.d.ts +0 -12
  149. package/build/services/pipe/functions/cron.js +0 -1
  150. package/build/services/pipe/functions/date.d.ts +0 -58
  151. package/build/services/pipe/functions/date.js +0 -1
  152. package/build/services/pipe/functions/index.d.ts +0 -29
  153. package/build/services/pipe/functions/index.js +0 -1
  154. package/build/services/pipe/functions/json.d.ts +0 -5
  155. package/build/services/pipe/functions/json.js +0 -1
  156. package/build/services/pipe/functions/logical.d.ts +0 -5
  157. package/build/services/pipe/functions/logical.js +0 -1
  158. package/build/services/pipe/functions/math.d.ts +0 -42
  159. package/build/services/pipe/functions/math.js +0 -1
  160. package/build/services/pipe/functions/number.d.ts +0 -21
  161. package/build/services/pipe/functions/number.js +0 -1
  162. package/build/services/pipe/functions/object.d.ts +0 -25
  163. package/build/services/pipe/functions/object.js +0 -1
  164. package/build/services/pipe/functions/string.d.ts +0 -23
  165. package/build/services/pipe/functions/string.js +0 -1
  166. package/build/services/pipe/functions/symbol.d.ts +0 -12
  167. package/build/services/pipe/functions/symbol.js +0 -1
  168. package/build/services/pipe/functions/unary.d.ts +0 -7
  169. package/build/services/pipe/functions/unary.js +0 -1
  170. package/build/services/pipe/index.d.ts +0 -48
  171. package/build/services/pipe/index.js +0 -1
  172. package/build/services/quorum/index.d.ts +0 -90
  173. package/build/services/quorum/index.js +0 -1
  174. package/build/services/reporter/index.d.ts +0 -50
  175. package/build/services/reporter/index.js +0 -1
  176. package/build/services/router/index.d.ts +0 -60
  177. package/build/services/router/index.js +0 -1
  178. package/build/services/search/factory.d.ts +0 -7
  179. package/build/services/search/factory.js +0 -24
  180. package/build/services/search/index.d.ts +0 -22
  181. package/build/services/search/index.js +0 -10
  182. package/build/services/search/providers/postgres/postgres.d.ts +0 -24
  183. package/build/services/search/providers/postgres/postgres.js +0 -1
  184. package/build/services/search/providers/redis/ioredis.d.ts +0 -18
  185. package/build/services/search/providers/redis/ioredis.js +0 -1
  186. package/build/services/search/providers/redis/redis.d.ts +0 -18
  187. package/build/services/search/providers/redis/redis.js +0 -1
  188. package/build/services/serializer/index.d.ts +0 -42
  189. package/build/services/serializer/index.js +0 -1
  190. package/build/services/store/cache.d.ts +0 -67
  191. package/build/services/store/cache.js +0 -128
  192. package/build/services/store/factory.d.ts +0 -8
  193. package/build/services/store/factory.js +0 -24
  194. package/build/services/store/index.d.ts +0 -89
  195. package/build/services/store/index.js +0 -9
  196. package/build/services/store/providers/postgres/kvsql.d.ts +0 -168
  197. package/build/services/store/providers/postgres/kvsql.js +0 -1
  198. package/build/services/store/providers/postgres/kvtables.d.ts +0 -20
  199. package/build/services/store/providers/postgres/kvtables.js +0 -1
  200. package/build/services/store/providers/postgres/kvtransaction.d.ts +0 -36
  201. package/build/services/store/providers/postgres/kvtransaction.js +0 -1
  202. package/build/services/store/providers/postgres/kvtypes/hash.d.ts +0 -60
  203. package/build/services/store/providers/postgres/kvtypes/hash.js +0 -1
  204. package/build/services/store/providers/postgres/kvtypes/list.d.ts +0 -33
  205. package/build/services/store/providers/postgres/kvtypes/list.js +0 -1
  206. package/build/services/store/providers/postgres/kvtypes/string.d.ts +0 -20
  207. package/build/services/store/providers/postgres/kvtypes/string.js +0 -1
  208. package/build/services/store/providers/postgres/kvtypes/zset.d.ts +0 -41
  209. package/build/services/store/providers/postgres/kvtypes/zset.js +0 -1
  210. package/build/services/store/providers/postgres/postgres.d.ts +0 -145
  211. package/build/services/store/providers/postgres/postgres.js +0 -1
  212. package/build/services/store/providers/redis/_base.d.ts +0 -137
  213. package/build/services/store/providers/redis/_base.js +0 -1
  214. package/build/services/store/providers/redis/ioredis.d.ts +0 -20
  215. package/build/services/store/providers/redis/ioredis.js +0 -1
  216. package/build/services/store/providers/redis/redis.d.ts +0 -18
  217. package/build/services/store/providers/redis/redis.js +0 -1
  218. package/build/services/store/providers/store-initializable.d.ts +0 -5
  219. package/build/services/store/providers/store-initializable.js +0 -1
  220. package/build/services/stream/factory.d.ts +0 -8
  221. package/build/services/stream/factory.js +0 -37
  222. package/build/services/stream/index.d.ts +0 -64
  223. package/build/services/stream/index.js +0 -11
  224. package/build/services/stream/providers/nats/nats.d.ts +0 -59
  225. package/build/services/stream/providers/nats/nats.js +0 -1
  226. package/build/services/stream/providers/postgres/kvtables.d.ts +0 -2
  227. package/build/services/stream/providers/postgres/kvtables.js +0 -1
  228. package/build/services/stream/providers/postgres/postgres.d.ts +0 -88
  229. package/build/services/stream/providers/postgres/postgres.js +0 -1
  230. package/build/services/stream/providers/redis/ioredis.d.ts +0 -60
  231. package/build/services/stream/providers/redis/ioredis.js +0 -1
  232. package/build/services/stream/providers/redis/redis.d.ts +0 -60
  233. package/build/services/stream/providers/redis/redis.js +0 -1
  234. package/build/services/stream/providers/stream-initializable.d.ts +0 -4
  235. package/build/services/stream/providers/stream-initializable.js +0 -1
  236. package/build/services/sub/factory.d.ts +0 -7
  237. package/build/services/sub/factory.js +0 -29
  238. package/build/services/sub/index.d.ts +0 -22
  239. package/build/services/sub/index.js +0 -10
  240. package/build/services/sub/providers/nats/nats.d.ts +0 -19
  241. package/build/services/sub/providers/nats/nats.js +0 -1
  242. package/build/services/sub/providers/postgres/postgres.d.ts +0 -19
  243. package/build/services/sub/providers/postgres/postgres.js +0 -1
  244. package/build/services/sub/providers/redis/ioredis.d.ts +0 -17
  245. package/build/services/sub/providers/redis/ioredis.js +0 -1
  246. package/build/services/sub/providers/redis/redis.d.ts +0 -17
  247. package/build/services/sub/providers/redis/redis.js +0 -1
  248. package/build/services/task/index.d.ts +0 -36
  249. package/build/services/task/index.js +0 -1
  250. package/build/services/telemetry/index.d.ts +0 -52
  251. package/build/services/telemetry/index.js +0 -1
  252. package/build/services/worker/index.d.ts +0 -77
  253. package/build/services/worker/index.js +0 -1
  254. /package/build/types/{meshflow.js → memflow.js} +0 -0
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConnectorService = void 0;
4
- const utils_1 = require("../../modules/utils");
5
- const ioredis_1 = require("./providers/ioredis");
6
- const nats_1 = require("./providers/nats");
7
- const postgres_1 = require("./providers/postgres");
8
- const redis_1 = require("./providers/redis");
9
- class ConnectorService {
10
- static async disconnectAll() {
11
- await redis_1.RedisConnection.disconnectAll();
12
- await ioredis_1.RedisConnection.disconnectAll();
13
- await postgres_1.PostgresConnection.disconnectAll();
14
- await nats_1.NatsConnection.disconnectAll();
15
- }
16
- /**
17
- * Connect to a provider (redis, nats, postgres) and return the native
18
- * client. Connections are handled by the engine and worker routers at
19
- * initialization, but the factory method provided here is useful
20
- * for testing provider configurations.
21
- */
22
- static async connectClient(ProviderConfig) {
23
- const target = {};
24
- await ConnectorService.initClient(ProviderConfig, target, 'client');
25
- return target.client;
26
- }
27
- /**
28
- * Initialize `store`, `stream`, and `subscription` clients for any provider.
29
- * @private
30
- */
31
- static async initClients(target) {
32
- let connection = utils_1.polyfill.providerConfig(target);
33
- if (!('store' in connection)) {
34
- connection = target.connection = {
35
- ...connection,
36
- store: { ...connection },
37
- stream: { ...connection },
38
- sub: { ...connection },
39
- };
40
- }
41
- // Expanded form
42
- if (connection.store) {
43
- await ConnectorService.initClient(connection.store, target, 'store');
44
- }
45
- if (connection.stream) {
46
- await ConnectorService.initClient(connection.stream, target, 'stream');
47
- }
48
- if (connection.sub) {
49
- await ConnectorService.initClient(connection.sub, target, 'sub');
50
- // use store for publishing events if same as subscription
51
- if (connection.sub.class !== connection.store.class) {
52
- //initialize a separate client for publishing events, using
53
- //the same provider as the subscription client
54
- connection.pub = {
55
- class: connection.sub.class,
56
- options: { ...connection.sub.options },
57
- provider: connection.sub.provider,
58
- };
59
- await ConnectorService.initClient(connection.pub, target, 'pub');
60
- }
61
- }
62
- }
63
- /**
64
- * Binds a provider client native instance to the target object.
65
- * @private
66
- */
67
- static async initClient(ProviderConfig, target, field) {
68
- if (target[field]) {
69
- return;
70
- }
71
- const providerClass = ProviderConfig.class;
72
- const options = ProviderConfig.options;
73
- const providerName = ProviderConfig.provider || (0, utils_1.identifyProvider)(providerClass); //e.g. 'postgres.poolclient'
74
- const providerType = providerName.split('.')[0]; //e.g. 'postgres'
75
- let clientInstance;
76
- const id = (0, utils_1.guid)();
77
- switch (providerType) {
78
- case 'redis':
79
- clientInstance = await redis_1.RedisConnection.connect(id, providerClass, options, { provider: providerName });
80
- break;
81
- case 'ioredis':
82
- clientInstance = await ioredis_1.RedisConnection.connect(id, providerClass, options, { provider: providerName });
83
- break;
84
- case 'nats':
85
- clientInstance = await nats_1.NatsConnection.connect(id, providerClass, options, { provider: providerName });
86
- break;
87
- case 'postgres':
88
- //if connecting as a poolClient for subscription, auto connect the client
89
- const bAutoConnect = field === 'sub';
90
- clientInstance = await postgres_1.PostgresConnection.connect(id, providerClass, options, { connect: bAutoConnect, provider: providerName });
91
- break;
92
- default:
93
- throw new Error(`Unknown provider type: ${providerType}`);
94
- }
95
- // Bind the resolved client instance to the target object
96
- target[field] = clientInstance.getClient();
97
- }
98
- }
99
- exports.ConnectorService = ConnectorService;
@@ -1,30 +0,0 @@
1
- import { StringAnyType } from '../../types';
2
- import { ProviderClass, ProviderNativeClient, ProviderOptions } from '../../types/provider';
3
- import { ILogger } from '../logger';
4
- /**
5
- * Abstract class for creating connections to different backend providers.
6
- * All implementations should extend this class and implement
7
- * the following steps:
8
- *
9
- * 1) Add the provider to ./providers/<name>.ts
10
- * 2) Update ./factory.ts to reference the provider
11
- * 3) Register the tag with the `Provider` type in ./types/provider.ts.
12
- * 4) Create the specific provider type file at ./types/<name>.ts
13
- * 5) Update ./modules/utils.ts (identifyProvider) with logic to resolve the provider by inspecting the class/import
14
- */
15
- declare abstract class AbstractConnection<PClass, POptions> {
16
- static logger: ILogger;
17
- static disconnecting: boolean;
18
- protected connection: any | null;
19
- protected static instances: Map<string, AbstractConnection<ProviderClass, ProviderOptions>>;
20
- protected id: string | null;
21
- protected abstract defaultOptions: any;
22
- protected abstract createConnection(client: PClass, options: POptions, config?: StringAnyType): Promise<any>;
23
- abstract getClient(): ProviderNativeClient;
24
- disconnect(): Promise<void>;
25
- protected abstract closeConnection(connection: any): Promise<void>;
26
- static connect<T extends AbstractConnection<ProviderClass, ProviderOptions>>(this: new () => T, id: string, client: ProviderClass, options?: ProviderOptions, //user
27
- config?: StringAnyType): Promise<T>;
28
- static disconnectAll(): Promise<void>;
29
- }
30
- export { AbstractConnection };
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractConnection = void 0;
4
- const logger_1 = require("../logger");
5
- /**
6
- * Abstract class for creating connections to different backend providers.
7
- * All implementations should extend this class and implement
8
- * the following steps:
9
- *
10
- * 1) Add the provider to ./providers/<name>.ts
11
- * 2) Update ./factory.ts to reference the provider
12
- * 3) Register the tag with the `Provider` type in ./types/provider.ts.
13
- * 4) Create the specific provider type file at ./types/<name>.ts
14
- * 5) Update ./modules/utils.ts (identifyProvider) with logic to resolve the provider by inspecting the class/import
15
- */
16
- class AbstractConnection {
17
- constructor() {
18
- this.connection = null;
19
- this.id = null;
20
- }
21
- async disconnect() {
22
- if (this.connection) {
23
- await this.closeConnection(this.connection);
24
- this.connection = null;
25
- }
26
- if (this.id) {
27
- AbstractConnection.instances.delete(this.id);
28
- }
29
- }
30
- static async connect(id, client, options, //user
31
- config) {
32
- if (AbstractConnection.instances.has(id)) {
33
- return AbstractConnection.instances.get(id);
34
- }
35
- const instance = new this();
36
- const opts = options ? { ...options } : { ...instance.defaultOptions };
37
- instance.connection = await instance.createConnection(client, opts, config);
38
- instance.id = id;
39
- AbstractConnection.instances.set(id, instance);
40
- return instance;
41
- }
42
- static async disconnectAll() {
43
- if (!this.disconnecting) {
44
- this.disconnecting = true;
45
- await Promise.all(Array.from(this.instances.values()).map((instance) => instance.disconnect()));
46
- this.instances.clear();
47
- this.disconnecting = false;
48
- }
49
- }
50
- }
51
- exports.AbstractConnection = AbstractConnection;
52
- AbstractConnection.logger = new logger_1.LoggerService('hotmesh', 'system');
53
- AbstractConnection.disconnecting = false;
54
- AbstractConnection.instances = new Map();
@@ -1,9 +0,0 @@
1
- import { AbstractConnection } from '..';
2
- import { IORedisClientOptions as RedisClientOptions, IORedisClassType as RedisClassType, IORedisClientType as RedisClientType } from '../../../types/redis';
3
- declare class RedisConnection extends AbstractConnection<RedisClassType, RedisClientOptions> {
4
- defaultOptions: RedisClientOptions;
5
- createConnection(Redis: RedisClassType, options: RedisClientOptions): Promise<RedisClientType>;
6
- getClient(): RedisClientType;
7
- closeConnection(connection: RedisClientType): Promise<void>;
8
- }
9
- export { RedisConnection };
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RedisConnection = void 0;
4
- const __1 = require("..");
5
- class RedisConnection extends __1.AbstractConnection {
6
- constructor() {
7
- super(...arguments);
8
- this.defaultOptions = {
9
- host: 'localhost',
10
- port: 6379,
11
- };
12
- }
13
- async createConnection(Redis, options) {
14
- return new Redis(options);
15
- }
16
- getClient() {
17
- if (!this.connection) {
18
- throw new Error('Redis client is not connected');
19
- }
20
- return this.connection;
21
- }
22
- async closeConnection(connection) {
23
- await connection.quit();
24
- }
25
- }
26
- exports.RedisConnection = RedisConnection;
@@ -1,9 +0,0 @@
1
- import { AbstractConnection } from '..';
2
- import { NatsClientOptions, NatsClientType, NatsClassType } from '../../../types/nats';
3
- declare class NatsConnection extends AbstractConnection<NatsClassType, NatsClientOptions> {
4
- defaultOptions: NatsClientOptions;
5
- createConnection(Connect: NatsClassType, options: NatsClientOptions): Promise<NatsClientType>;
6
- getClient(): NatsClientType;
7
- closeConnection(connection: NatsClientType): Promise<void>;
8
- }
9
- export { NatsConnection, NatsClientOptions };
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NatsConnection = void 0;
4
- const __1 = require("..");
5
- class NatsConnection extends __1.AbstractConnection {
6
- constructor() {
7
- super(...arguments);
8
- this.defaultOptions = {
9
- servers: ['nats:4222'],
10
- timeout: 5000,
11
- };
12
- }
13
- async createConnection(Connect, options) {
14
- try {
15
- return (await Connect(options));
16
- }
17
- catch (error) {
18
- NatsConnection.logger.error(`nats-provider-connection-failed`, {
19
- error,
20
- });
21
- throw new Error(`nats-provider-connection-failed: ${error.message}`);
22
- }
23
- }
24
- getClient() {
25
- if (!this.connection) {
26
- throw new Error('nats-provider-connection-failed');
27
- }
28
- return this.connection;
29
- }
30
- async closeConnection(connection) {
31
- await connection.close();
32
- }
33
- }
34
- exports.NatsConnection = NatsConnection;
@@ -1,20 +0,0 @@
1
- import { AbstractConnection } from '..';
2
- import { PostgresClientOptions, PostgresClientType, PostgresClassType, PostgresPoolClientType } from '../../../types/postgres';
3
- declare class PostgresConnection extends AbstractConnection<PostgresClassType, PostgresClientOptions> {
4
- defaultOptions: PostgresClientOptions;
5
- protected static poolClientInstances: Set<PostgresPoolClientType>;
6
- protected static connectionInstances: Set<PostgresClientType>;
7
- poolClientInstance: PostgresPoolClientType;
8
- createConnection(clientConstructor: any, options: PostgresClientOptions, config?: {
9
- connect?: boolean;
10
- provider?: string;
11
- }): Promise<PostgresClientType>;
12
- getClient(): PostgresClientType;
13
- static disconnectAll(): Promise<void>;
14
- static disconnectPoolClients(): Promise<void>;
15
- static disconnectConnections(): Promise<void>;
16
- closeConnection(connection: PostgresClientType): Promise<void>;
17
- static isPoolClient(client: any): client is PostgresPoolClientType;
18
- static getTransactionClient(transactionClient: any): Promise<['client' | 'poolclient', PostgresClientType]>;
19
- }
20
- export { PostgresConnection };
@@ -1,102 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostgresConnection = void 0;
4
- const __1 = require("..");
5
- class PostgresConnection extends __1.AbstractConnection {
6
- constructor() {
7
- super(...arguments);
8
- this.defaultOptions = {
9
- host: 'postgres',
10
- port: 5432,
11
- user: 'postgres',
12
- password: 'password',
13
- database: 'hotmesh',
14
- max: 20,
15
- idleTimeoutMillis: 30000,
16
- };
17
- }
18
- async createConnection(clientConstructor, options, config = {}) {
19
- try {
20
- let connection;
21
- if (config.provider === 'postgres.poolclient' ||
22
- PostgresConnection.isPoolClient(clientConstructor)) {
23
- // It's a PoolClient
24
- connection = clientConstructor;
25
- if (config.connect) {
26
- const client = await clientConstructor.connect();
27
- //register the connection singularly to be 'released' later
28
- PostgresConnection.poolClientInstances.add(client);
29
- this.poolClientInstance = client;
30
- }
31
- }
32
- else {
33
- // It's a Client
34
- connection = new clientConstructor(options);
35
- await connection.connect();
36
- await connection.query('SELECT 1');
37
- }
38
- //register the connection statically to be 'ended' later
39
- PostgresConnection.connectionInstances.add(connection);
40
- return connection;
41
- }
42
- catch (error) {
43
- PostgresConnection.logger.error(`postgres-provider-connection-failed`, {
44
- host: options.host ?? 'unknown',
45
- database: options.database ?? 'unknown',
46
- port: options.port ?? 'unknown',
47
- error,
48
- });
49
- throw new Error(`postgres-provider-connection-failed: ${error.message}`);
50
- }
51
- }
52
- getClient() {
53
- if (!this.connection) {
54
- throw new Error('Postgres client is not connected');
55
- }
56
- return this.poolClientInstance || this.connection;
57
- }
58
- static async disconnectAll() {
59
- if (!this.disconnecting) {
60
- this.disconnecting = true;
61
- await this.disconnectPoolClients();
62
- await this.disconnectConnections();
63
- this.disconnecting = false;
64
- }
65
- }
66
- static async disconnectPoolClients() {
67
- Array.from(this.poolClientInstances.values()).map((instance) => {
68
- instance.release();
69
- });
70
- this.poolClientInstances.clear();
71
- }
72
- static async disconnectConnections() {
73
- Array.from(this.connectionInstances.values()).map((instance) => {
74
- instance.end();
75
- });
76
- this.connectionInstances.clear();
77
- }
78
- async closeConnection(connection) {
79
- //no-op (handled by disconnectAll)
80
- }
81
- static isPoolClient(client) {
82
- return !(isNaN(client?.totalCount) && isNaN(client?.idleCount));
83
- }
84
- static async getTransactionClient(transactionClient) {
85
- let client;
86
- let type;
87
- if (PostgresConnection.isPoolClient(transactionClient)) {
88
- type = 'poolclient';
89
- client = await transactionClient.connect();
90
- }
91
- else {
92
- type = 'client';
93
- client = transactionClient;
94
- }
95
- return [type, client];
96
- }
97
- }
98
- exports.PostgresConnection = PostgresConnection;
99
- //statically track all clients (//call 'release')
100
- PostgresConnection.poolClientInstances = new Set();
101
- //statically track all connections (//call 'end')
102
- PostgresConnection.connectionInstances = new Set();
@@ -1,9 +0,0 @@
1
- import { AbstractConnection } from '..';
2
- import { RedisRedisClassType as RedisClassType, RedisRedisClientType as RedisClientType, RedisRedisClientOptions as RedisClientOptions } from '../../../types/redis';
3
- declare class RedisConnection extends AbstractConnection<RedisClassType, RedisClientOptions> {
4
- defaultOptions: RedisClientOptions;
5
- createConnection(Redis: Partial<RedisClassType>, options: RedisClientOptions): Promise<Partial<RedisClientType>>;
6
- getClient(): RedisClientType;
7
- closeConnection(connection: any): Promise<void>;
8
- }
9
- export { RedisConnection, RedisClientType };
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RedisConnection = void 0;
4
- const __1 = require("..");
5
- class RedisConnection extends __1.AbstractConnection {
6
- constructor() {
7
- super(...arguments);
8
- this.defaultOptions = {
9
- socket: {
10
- host: 'localhost',
11
- port: 6379,
12
- tls: false,
13
- },
14
- };
15
- }
16
- async createConnection(Redis, options) {
17
- return new Promise((resolve, reject) => {
18
- const client = Redis.createClient(options);
19
- client.on('error', (error) => {
20
- reject(error);
21
- });
22
- client.on('ready', () => {
23
- resolve(client);
24
- });
25
- client.connect();
26
- });
27
- }
28
- getClient() {
29
- if (!this.connection) {
30
- throw new Error('Redis client is not connected');
31
- }
32
- return this.connection;
33
- }
34
- async closeConnection(connection) {
35
- await connection.quit();
36
- }
37
- }
38
- exports.RedisConnection = RedisConnection;