@hotmeshio/hotmesh 0.5.6 → 0.5.7

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 (80) hide show
  1. package/README.md +6 -32
  2. package/build/index.d.ts +1 -3
  3. package/build/index.js +1 -5
  4. package/build/modules/enums.d.ts +0 -5
  5. package/build/modules/enums.js +1 -6
  6. package/build/modules/utils.d.ts +1 -1
  7. package/build/modules/utils.js +2 -29
  8. package/build/package.json +4 -16
  9. package/build/services/activities/hook.js +1 -5
  10. package/build/services/compiler/index.d.ts +2 -2
  11. package/build/services/compiler/index.js +4 -4
  12. package/build/services/connector/factory.d.ts +1 -1
  13. package/build/services/connector/factory.js +1 -11
  14. package/build/services/exporter/index.d.ts +8 -8
  15. package/build/services/exporter/index.js +8 -8
  16. package/build/services/memflow/client.js +1 -8
  17. package/build/services/memflow/connection.d.ts +0 -2
  18. package/build/services/memflow/connection.js +0 -2
  19. package/build/services/memflow/exporter.d.ts +3 -3
  20. package/build/services/memflow/exporter.js +3 -3
  21. package/build/services/memflow/index.d.ts +1 -1
  22. package/build/services/memflow/index.js +1 -1
  23. package/build/services/memflow/schemas/factory.js +1 -1
  24. package/build/services/memflow/search.d.ts +11 -4
  25. package/build/services/memflow/search.js +98 -71
  26. package/build/services/memflow/worker.d.ts +1 -1
  27. package/build/services/memflow/worker.js +1 -1
  28. package/build/services/meshcall/index.d.ts +1 -1
  29. package/build/services/meshcall/index.js +1 -1
  30. package/build/services/reporter/index.d.ts +1 -1
  31. package/build/services/reporter/index.js +12 -12
  32. package/build/services/search/factory.js +0 -8
  33. package/build/services/search/providers/postgres/postgres.js +1 -1
  34. package/build/services/store/cache.d.ts +1 -1
  35. package/build/services/store/cache.js +1 -1
  36. package/build/services/store/factory.js +1 -9
  37. package/build/services/store/index.d.ts +1 -1
  38. package/build/services/store/providers/postgres/kvtypes/hash/index.js +57 -0
  39. package/build/services/store/providers/postgres/kvtypes/hash/udata.d.ts +10 -0
  40. package/build/services/store/providers/postgres/kvtypes/hash/udata.js +384 -0
  41. package/build/services/store/providers/postgres/postgres.js +2 -6
  42. package/build/services/stream/factory.js +0 -16
  43. package/build/services/sub/factory.js +0 -8
  44. package/build/services/sub/providers/nats/nats.js +0 -1
  45. package/build/services/task/index.js +0 -1
  46. package/build/types/activity.d.ts +1 -5
  47. package/build/types/hotmesh.d.ts +0 -5
  48. package/build/types/index.d.ts +0 -1
  49. package/build/types/index.js +1 -4
  50. package/build/types/job.d.ts +1 -1
  51. package/build/types/memflow.d.ts +5 -4
  52. package/build/types/meshcall.d.ts +0 -25
  53. package/build/types/provider.d.ts +1 -1
  54. package/build/types/stream.d.ts +1 -6
  55. package/index.ts +0 -4
  56. package/package.json +4 -16
  57. package/build/services/connector/providers/ioredis.d.ts +0 -9
  58. package/build/services/connector/providers/ioredis.js +0 -26
  59. package/build/services/connector/providers/redis.d.ts +0 -9
  60. package/build/services/connector/providers/redis.js +0 -38
  61. package/build/services/search/providers/redis/ioredis.d.ts +0 -23
  62. package/build/services/search/providers/redis/ioredis.js +0 -134
  63. package/build/services/search/providers/redis/redis.d.ts +0 -23
  64. package/build/services/search/providers/redis/redis.js +0 -147
  65. package/build/services/store/providers/redis/_base.d.ts +0 -137
  66. package/build/services/store/providers/redis/_base.js +0 -980
  67. package/build/services/store/providers/redis/ioredis.d.ts +0 -20
  68. package/build/services/store/providers/redis/ioredis.js +0 -180
  69. package/build/services/store/providers/redis/redis.d.ts +0 -18
  70. package/build/services/store/providers/redis/redis.js +0 -199
  71. package/build/services/stream/providers/redis/ioredis.d.ts +0 -61
  72. package/build/services/stream/providers/redis/ioredis.js +0 -272
  73. package/build/services/stream/providers/redis/redis.d.ts +0 -61
  74. package/build/services/stream/providers/redis/redis.js +0 -305
  75. package/build/services/sub/providers/redis/ioredis.d.ts +0 -17
  76. package/build/services/sub/providers/redis/ioredis.js +0 -81
  77. package/build/services/sub/providers/redis/redis.d.ts +0 -17
  78. package/build/services/sub/providers/redis/redis.js +0 -72
  79. package/build/types/redis.d.ts +0 -258
  80. package/build/types/redis.js +0 -11
@@ -1,20 +0,0 @@
1
- import { IORedisClientType as RedisClientType, IORedisMultiType as RedisMultiType } from '../../../../types/redis';
2
- import { StoreInitializable } from '../store-initializable';
3
- import { RedisStoreBase } from './_base';
4
- declare class IORedisStoreService extends RedisStoreBase<RedisClientType, RedisMultiType> implements StoreInitializable {
5
- constructor(storeClient: RedisClientType);
6
- /**
7
- * When in cluster mode, the transact wrapper only
8
- * sends commands to the same node/shard if they share a key.
9
- * All other commands are sent simultaneouslyusing Promise.all
10
- * and are then collated. this is effectiely a wrapper for
11
- * `multi` but is closer to `pipeline` in terms of usage when
12
- * promises are used.
13
- */
14
- transact(): RedisMultiType;
15
- exec(...args: any[]): Promise<string | string[] | string[][]>;
16
- setnxex(key: string, value: string, expireSeconds: number): Promise<boolean>;
17
- hGetAllResult(result: any): any;
18
- addTaskQueues(keys: string[]): Promise<void>;
19
- }
20
- export { IORedisStoreService };
@@ -1,180 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IORedisStoreService = void 0;
4
- const key_1 = require("../../../../modules/key");
5
- const enums_1 = require("../../../../modules/enums");
6
- const _base_1 = require("./_base");
7
- class IORedisStoreService extends _base_1.RedisStoreBase {
8
- constructor(storeClient) {
9
- super(storeClient);
10
- this.commands = {
11
- get: 'get',
12
- set: 'set',
13
- setnx: 'setnx',
14
- del: 'del',
15
- expire: 'expire',
16
- hset: 'hset',
17
- hscan: 'hscan',
18
- hsetnx: 'hsetnx',
19
- hincrby: 'hincrby',
20
- hdel: 'hdel',
21
- hget: 'hget',
22
- hmget: 'hmget',
23
- hgetall: 'hgetall',
24
- hincrbyfloat: 'hincrbyfloat',
25
- zrank: 'zrank',
26
- zrange: 'zrange',
27
- zrangebyscore_withscores: 'zrangebyscore',
28
- zrangebyscore: 'zrangebyscore',
29
- zrem: 'zrem',
30
- zadd: 'zadd',
31
- lmove: 'lmove',
32
- lpop: 'lpop',
33
- lrange: 'lrange',
34
- rename: 'rename',
35
- rpush: 'rpush',
36
- scan: 'scan',
37
- xack: 'xack',
38
- xdel: 'xdel',
39
- };
40
- }
41
- /**
42
- * When in cluster mode, the transact wrapper only
43
- * sends commands to the same node/shard if they share a key.
44
- * All other commands are sent simultaneouslyusing Promise.all
45
- * and are then collated. this is effectiely a wrapper for
46
- * `multi` but is closer to `pipeline` in terms of usage when
47
- * promises are used.
48
- */
49
- transact() {
50
- const my = this;
51
- if (enums_1.HMSH_IS_CLUSTER) {
52
- const commands = [];
53
- const addCommand = (command, args) => {
54
- commands.push({ command, args });
55
- return multiInstance;
56
- };
57
- const multiInstance = {
58
- sendCommand(command) {
59
- return my.storeClient.sendCommand(command);
60
- },
61
- async exec() {
62
- if (commands.length === 0)
63
- return [];
64
- const sameKey = commands.every((cmd) => {
65
- return cmd.args[0] === commands[0].args[0];
66
- });
67
- if (sameKey) {
68
- const multi = my.storeClient.multi();
69
- commands.forEach((cmd) => multi[cmd.command](...cmd.args));
70
- const results = await multi.exec();
71
- return results.map((item) => item);
72
- }
73
- else {
74
- return Promise.all(commands.map((cmd) => my.storeClient[cmd.command](...cmd.args)));
75
- }
76
- },
77
- xadd(key, id, fields, message) {
78
- return addCommand('xadd', [key, id, fields, message]);
79
- },
80
- xack(key, group, id) {
81
- return addCommand('xack', [key, group, id]);
82
- },
83
- xdel(key, id) {
84
- return addCommand('xdel', [key, id]);
85
- },
86
- xlen(key) {
87
- return addCommand('xlen', [key]);
88
- },
89
- xpending(key, group, start, end, count, consumer) {
90
- return addCommand('xpending', [
91
- key,
92
- group,
93
- start,
94
- end,
95
- count,
96
- consumer,
97
- ]);
98
- },
99
- xclaim(key, group, consumer, minIdleTime, id, ...args) {
100
- return addCommand('xclaim', [
101
- key,
102
- group,
103
- consumer,
104
- minIdleTime,
105
- id,
106
- ...args,
107
- ]);
108
- },
109
- del(key) {
110
- return addCommand('del', [key]);
111
- },
112
- expire: function (key, seconds) {
113
- return addCommand('expire', [key, seconds]);
114
- },
115
- hdel(key, itemId) {
116
- return addCommand('hdel', [key, itemId]);
117
- },
118
- hget(key, itemId) {
119
- return addCommand('hget', [key, itemId]);
120
- },
121
- hgetall(key) {
122
- return addCommand('hgetall', [key]);
123
- },
124
- hincrbyfloat(key, itemId, value) {
125
- return addCommand('hincrbyfloat', [key, itemId, value]);
126
- },
127
- hmget(key, itemIds) {
128
- return addCommand('hmget', [key, itemIds]);
129
- },
130
- hset(key, values) {
131
- return addCommand('hset', [key, values]);
132
- },
133
- lrange(key, start, end) {
134
- return addCommand('lrange', [key, start, end]);
135
- },
136
- rpush(key, value) {
137
- return addCommand('rpush', [key, value]);
138
- },
139
- zadd(...args) {
140
- return addCommand('zadd', args);
141
- },
142
- xgroup(command, key, groupName, id, mkStream) {
143
- return addCommand('xgroup', [command, key, groupName, id, mkStream]);
144
- },
145
- };
146
- return multiInstance;
147
- }
148
- return this.storeClient.multi();
149
- }
150
- async exec(...args) {
151
- const response = await this.storeClient.call.apply(this.storeClient, args);
152
- if (typeof response === 'string') {
153
- return response;
154
- }
155
- else if (Array.isArray(response)) {
156
- if (Array.isArray(response[0])) {
157
- return response;
158
- }
159
- return response;
160
- }
161
- return response;
162
- }
163
- async setnxex(key, value, expireSeconds) {
164
- const status = await this.storeClient[this.commands.set](key, value, 'NX', 'EX', expireSeconds.toString());
165
- return this.isSuccessful(status);
166
- }
167
- hGetAllResult(result) {
168
- //ioredis response signature is [null, {}] or [null, null]
169
- return result[1];
170
- }
171
- async addTaskQueues(keys) {
172
- const multi = this.storeClient.multi();
173
- const zsetKey = this.mintKey(key_1.KeyType.WORK_ITEMS, { appId: this.appId });
174
- for (const key of keys) {
175
- multi.zadd(zsetKey, 'NX', Date.now(), key);
176
- }
177
- await multi.exec();
178
- }
179
- }
180
- exports.IORedisStoreService = IORedisStoreService;
@@ -1,18 +0,0 @@
1
- import { StoreInitializable } from '../store-initializable';
2
- import { RedisRedisClientType as RedisClientType, RedisRedisMultiType as RedisMultiType } from '../../../../types/redis';
3
- import { RedisStoreBase } from './_base';
4
- declare class RedisStoreService extends RedisStoreBase<RedisClientType, RedisMultiType> implements StoreInitializable {
5
- constructor(storeClient: RedisClientType);
6
- /**
7
- * When in cluster mode, the transact wrapper only
8
- * sends commands to the same node/shard if they share a key.
9
- * All other commands are sent simultaneouslyusing Promise.all
10
- * and are then collated
11
- */
12
- transact(): RedisMultiType;
13
- exec(...args: any[]): Promise<string | string[] | string[][]>;
14
- setnxex(key: string, value: string, expireSeconds: number): Promise<boolean>;
15
- zAdd(key: string, score: number | string, value: string | number, redisMulti?: RedisMultiType): Promise<any>;
16
- zRangeByScore(key: string, score: number | string, value: string | number): Promise<string | null>;
17
- }
18
- export { RedisStoreService };
@@ -1,199 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RedisStoreService = void 0;
4
- const enums_1 = require("../../../../modules/enums");
5
- const _base_1 = require("./_base");
6
- class RedisStoreService extends _base_1.RedisStoreBase {
7
- constructor(storeClient) {
8
- super(storeClient);
9
- this.commands = {
10
- get: 'GET',
11
- set: 'SET',
12
- setnx: 'SETNX',
13
- del: 'DEL',
14
- expire: 'EXPIRE',
15
- hscan: 'HSCAN',
16
- hset: 'HSET',
17
- hsetnx: 'HSETNX',
18
- hincrby: 'HINCRBY',
19
- hdel: 'HDEL',
20
- hget: 'HGET',
21
- hmget: 'HMGET',
22
- hgetall: 'HGETALL',
23
- hincrbyfloat: 'HINCRBYFLOAT',
24
- zrange: 'ZRANGE',
25
- zrangebyscore_withscores: 'ZRANGEBYSCORE_WITHSCORES',
26
- zrangebyscore: 'ZRANGEBYSCORE',
27
- zrem: 'ZREM',
28
- zadd: 'ZADD',
29
- lmove: 'LMOVE',
30
- lrange: 'LRANGE',
31
- lpop: 'LPOP',
32
- rename: 'RENAME',
33
- rpush: 'RPUSH',
34
- scan: 'SCAN',
35
- xack: 'XACK',
36
- xdel: 'XDEL',
37
- xlen: 'XLEN',
38
- };
39
- }
40
- /**
41
- * When in cluster mode, the transact wrapper only
42
- * sends commands to the same node/shard if they share a key.
43
- * All other commands are sent simultaneouslyusing Promise.all
44
- * and are then collated
45
- */
46
- transact() {
47
- const my = this;
48
- if (enums_1.HMSH_IS_CLUSTER) {
49
- const commands = [];
50
- const addCommand = (command, args) => {
51
- commands.push({ command: command.toUpperCase(), args });
52
- return multiInstance;
53
- };
54
- const multiInstance = {
55
- sendCommand(command, ...args) {
56
- return my.storeClient.sendCommand([command, ...args]);
57
- },
58
- async exec() {
59
- if (commands.length === 0)
60
- return [];
61
- const sameKey = commands.every((cmd) => {
62
- return cmd.args[0] === commands[0].args[0];
63
- });
64
- if (sameKey) {
65
- const multi = my.storeClient.multi();
66
- commands.forEach((cmd) => {
67
- if (cmd.command === 'ZADD') {
68
- return multi.ZADD(cmd.args[0], cmd.args[1], cmd.args[2]);
69
- }
70
- return multi[cmd.command](...cmd.args);
71
- });
72
- const results = await multi.exec();
73
- return results.map((item) => item);
74
- }
75
- else {
76
- return Promise.all(commands.map((cmd) => {
77
- if (cmd.command === 'ZADD') {
78
- return my.storeClient.ZADD(cmd.args[0], cmd.args[1], cmd.args[2]);
79
- }
80
- return my.storeClient[cmd.command](...cmd.args);
81
- }));
82
- }
83
- },
84
- XADD(key, id, fields, message) {
85
- return addCommand('XADD', [key, id, fields, message]);
86
- },
87
- XACK(key, group, id) {
88
- return addCommand('XACK', [key, group, id]);
89
- },
90
- XDEL(key, id) {
91
- return addCommand('XDEL', [key, id]);
92
- },
93
- XLEN(key) {
94
- return addCommand('XLEN', [key]);
95
- },
96
- XCLAIM(key, group, consumer, minIdleTime, id, ...args) {
97
- return addCommand('XCLAIM', [
98
- key,
99
- group,
100
- consumer,
101
- minIdleTime,
102
- id,
103
- ...args,
104
- ]);
105
- },
106
- XPENDING(key, group, start, end, count, consumer) {
107
- return addCommand('XPENDING', [
108
- key,
109
- group,
110
- start,
111
- end,
112
- count,
113
- consumer,
114
- ]);
115
- },
116
- DEL: function (key) {
117
- return addCommand('DEL', [key]);
118
- },
119
- EXPIRE: function (key, seconds) {
120
- return addCommand('EXPIRE', [key, seconds]);
121
- },
122
- HDEL(key, itemId) {
123
- return addCommand('HDEL', [key, itemId]);
124
- },
125
- HGET(key, itemId) {
126
- return addCommand('HGET', [key, itemId]);
127
- },
128
- HGETALL(key) {
129
- return addCommand('HGETALL', [key]);
130
- },
131
- HINCRBYFLOAT(key, itemId, value) {
132
- return addCommand('HINCRBYFLOAT', [key, itemId, value]);
133
- },
134
- HMGET(key, itemIds) {
135
- return addCommand('HMGET', [key, itemIds]);
136
- },
137
- HSET(key, values) {
138
- return addCommand('HSET', [key, values]);
139
- },
140
- LRANGE(key, start, end) {
141
- return addCommand('LRANGE', [key, start, end]);
142
- },
143
- RPUSH(key, items) {
144
- return addCommand('RPUSH', [key, items]);
145
- },
146
- ZADD(key, args, opts) {
147
- return addCommand('ZADD', [key, args, opts]);
148
- },
149
- XGROUP(command, key, groupName, id, mkStream) {
150
- return addCommand('XGROUP', [command, key, groupName, id, mkStream]);
151
- },
152
- EXISTS: function (key) {
153
- throw new Error('Function not implemented.');
154
- },
155
- HMPUSH: function (key, values) {
156
- throw new Error('Function not implemented.');
157
- },
158
- LPUSH: function (key, items) {
159
- throw new Error('Function not implemented.');
160
- },
161
- SET: function (key, value) {
162
- throw new Error('Function not implemented.');
163
- },
164
- ZRANGE_WITHSCORES: function (key, start, end) {
165
- throw new Error('Function not implemented.');
166
- },
167
- ZRANK: function (key, member) {
168
- throw new Error('Function not implemented.');
169
- },
170
- ZSCORE: function (key, value) {
171
- throw new Error('Function not implemented.');
172
- },
173
- };
174
- return multiInstance;
175
- }
176
- return this.storeClient.multi();
177
- }
178
- async exec(...args) {
179
- return await this.storeClient.sendCommand(args);
180
- }
181
- async setnxex(key, value, expireSeconds) {
182
- const status = await this.storeClient[this.commands.set](key, value, { NX: true, EX: expireSeconds });
183
- return this.isSuccessful(status);
184
- }
185
- async zAdd(key, score, value, redisMulti) {
186
- return await (redisMulti || this.storeClient)[this.commands.zadd](key, {
187
- score: score,
188
- value: value.toString(),
189
- });
190
- }
191
- async zRangeByScore(key, score, value) {
192
- const result = await this.storeClient[this.commands.zrangebyscore](key, score, value);
193
- if (result?.length > 0) {
194
- return result[0];
195
- }
196
- return null;
197
- }
198
- }
199
- exports.RedisStoreService = RedisStoreService;
@@ -1,61 +0,0 @@
1
- import { ILogger } from '../../../logger';
2
- import { StreamService } from '../../index';
3
- import { IORedisClientType, IORedisMultiType } from '../../../../types/redis';
4
- import { PublishMessageConfig, StreamConfig, StreamMessage, StreamStats } from '../../../../types/stream';
5
- import { KeyStoreParams, StringAnyType } from '../../../../types';
6
- import { KeyType } from '../../../../modules/key';
7
- import { ProviderTransaction } from '../../../../types/provider';
8
- declare class IORedisStreamService extends StreamService<IORedisClientType, IORedisMultiType> {
9
- constructor(streamClient: IORedisClientType, storeClient: IORedisClientType, config?: StreamConfig);
10
- init(namespace: string, appId: string, logger: ILogger): Promise<void>;
11
- mintKey(type: KeyType, params: KeyStoreParams): string;
12
- transact(): ProviderTransaction;
13
- createStream(streamName: string): Promise<boolean>;
14
- deleteStream(streamName: string): Promise<boolean>;
15
- createConsumerGroup(key: string, groupName: string): Promise<boolean>;
16
- deleteConsumerGroup(streamName: string, groupName: string): Promise<boolean>;
17
- publishMessages(streamName: string, messages: string[], options?: PublishMessageConfig): Promise<string[]>;
18
- consumeMessages(streamName: string, groupName: string, consumerName: string, options?: {
19
- batchSize?: number;
20
- blockTimeout?: number;
21
- }): Promise<StreamMessage[]>;
22
- ackAndDelete(stream: string, group: string, ids: string[]): Promise<number>;
23
- acknowledgeMessages(stream: string, group: string, ids: string[], options?: StringAnyType): Promise<number | IORedisMultiType>;
24
- deleteMessages(stream: string, group: string, ids: string[], options?: StringAnyType): Promise<number | IORedisMultiType>;
25
- getPendingMessages(stream: string, group: string, count?: number, consumer?: string): Promise<[string, string, number, [string, number][]][] | [string, string, number, number] | unknown[]>;
26
- retryMessages(streamName: string, groupName: string, options?: {
27
- consumerName?: string;
28
- minIdleTime?: number;
29
- messageIds?: string[];
30
- delay?: number;
31
- maxRetries?: number;
32
- limit?: number;
33
- }): Promise<StreamMessage[]>;
34
- claimMessage(streamName: string, groupName: string, consumerName: string, minIdleTime: number, messageId: string, ...args: string[]): Promise<StreamMessage>;
35
- getStreamStats(streamName: string): Promise<StreamStats>;
36
- getStreamDepth(streamName: string, options?: {
37
- multi: IORedisMultiType;
38
- }): Promise<number>;
39
- getStreamDepths(streamNames: {
40
- stream: string;
41
- }[]): Promise<{
42
- stream: string;
43
- depth: number;
44
- }[]>;
45
- trimStream(streamName: string, options: {
46
- maxLen?: number;
47
- maxAge?: number;
48
- exactLimit?: boolean;
49
- }): Promise<number>;
50
- getProviderSpecificFeatures(): {
51
- supportsBatching: boolean;
52
- supportsDeadLetterQueue: boolean;
53
- supportsOrdering: boolean;
54
- supportsTrimming: boolean;
55
- supportsRetry: boolean;
56
- supportsNotifications: boolean;
57
- maxMessageSize: number;
58
- maxBatchSize: number;
59
- };
60
- }
61
- export { IORedisStreamService };