@hotmeshio/hotmesh 0.5.1 → 0.5.2

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 (39) hide show
  1. package/README.md +9 -5
  2. package/build/package.json +16 -14
  3. package/build/services/hotmesh/index.d.ts +9 -11
  4. package/build/services/hotmesh/index.js +9 -11
  5. package/build/services/memflow/entity.d.ts +168 -4
  6. package/build/services/memflow/entity.js +177 -15
  7. package/build/services/memflow/workflow/index.d.ts +2 -4
  8. package/build/services/memflow/workflow/index.js +2 -4
  9. package/build/services/memflow/workflow/interruption.d.ts +6 -4
  10. package/build/services/memflow/workflow/interruption.js +6 -4
  11. package/build/services/memflow/workflow/waitFor.js +1 -0
  12. package/build/services/search/index.d.ts +10 -0
  13. package/build/services/search/providers/postgres/postgres.d.ts +12 -0
  14. package/build/services/search/providers/postgres/postgres.js +209 -0
  15. package/build/services/search/providers/redis/ioredis.d.ts +4 -0
  16. package/build/services/search/providers/redis/ioredis.js +13 -0
  17. package/build/services/search/providers/redis/redis.d.ts +4 -0
  18. package/build/services/search/providers/redis/redis.js +13 -0
  19. package/build/services/store/providers/postgres/kvsql.d.ts +13 -37
  20. package/build/services/store/providers/postgres/kvsql.js +2 -2
  21. package/build/services/store/providers/postgres/kvtypes/hash/basic.d.ts +16 -0
  22. package/build/services/store/providers/postgres/kvtypes/hash/basic.js +480 -0
  23. package/build/services/store/providers/postgres/kvtypes/hash/expire.d.ts +5 -0
  24. package/build/services/store/providers/postgres/kvtypes/hash/expire.js +33 -0
  25. package/build/services/store/providers/postgres/kvtypes/hash/index.d.ts +29 -0
  26. package/build/services/store/providers/postgres/kvtypes/hash/index.js +190 -0
  27. package/build/services/store/providers/postgres/kvtypes/hash/jsonb.d.ts +14 -0
  28. package/build/services/store/providers/postgres/kvtypes/hash/jsonb.js +699 -0
  29. package/build/services/store/providers/postgres/kvtypes/hash/scan.d.ts +10 -0
  30. package/build/services/store/providers/postgres/kvtypes/hash/scan.js +91 -0
  31. package/build/services/store/providers/postgres/kvtypes/hash/types.d.ts +19 -0
  32. package/build/services/store/providers/postgres/kvtypes/hash/types.js +2 -0
  33. package/build/services/store/providers/postgres/kvtypes/hash/utils.d.ts +18 -0
  34. package/build/services/store/providers/postgres/kvtypes/hash/utils.js +90 -0
  35. package/build/types/memflow.d.ts +1 -1
  36. package/build/types/meshdata.d.ts +1 -1
  37. package/package.json +16 -14
  38. package/build/services/store/providers/postgres/kvtypes/hash.d.ts +0 -60
  39. package/build/services/store/providers/postgres/kvtypes/hash.js +0 -1287
@@ -15,6 +15,7 @@ const random_1 = require("./random");
15
15
  const signal_1 = require("./signal");
16
16
  const hook_1 = require("./hook");
17
17
  const interrupt_1 = require("./interrupt");
18
+ const interruption_1 = require("./interruption");
18
19
  const all_1 = require("./all");
19
20
  const sleepFor_1 = require("./sleepFor");
20
21
  const waitFor_1 = require("./waitFor");
@@ -25,10 +26,6 @@ const entityMethods_1 = require("./entityMethods");
25
26
  * These methods ensure deterministic replay, persistence of state, and error handling across
26
27
  * re-entrant workflow executions.
27
28
  *
28
- * By refactoring the original single-file implementation into submodules,
29
- * we maintain clear separation of concerns and improved maintainability,
30
- * while preserving type information and full functionality.
31
- *
32
29
  * @example
33
30
  * ```typescript
34
31
  * import { MemFlow } from '@hotmeshio/hotmesh';
@@ -80,6 +77,7 @@ WorkflowService.entity = entityMethods_1.entity;
80
77
  WorkflowService.random = random_1.random;
81
78
  WorkflowService.signal = signal_1.signal;
82
79
  WorkflowService.hook = hook_1.hook;
80
+ WorkflowService.didInterrupt = interruption_1.didInterrupt;
83
81
  WorkflowService.interrupt = interrupt_1.interrupt;
84
82
  WorkflowService.all = all_1.all;
85
83
  WorkflowService.sleepFor = sleepFor_1.sleepFor;
@@ -1,18 +1,20 @@
1
1
  /**
2
2
  * Checks if an error is a HotMesh reserved error type that indicates
3
- * a workflow interruption rather than a true error condition.
3
+ * a HotMesh interruption rather than a true error condition.
4
4
  *
5
- * When this returns true, you can safely return from your workflow function.
5
+ * When this returns true, you can safely return rethrow the error.
6
6
  * The workflow engine will handle the interruption automatically.
7
7
  *
8
8
  * @example
9
9
  * ```typescript
10
+ * import { MemFlow } from '@hotmeshio/hotmesh';
11
+ *
10
12
  * try {
11
13
  * await someWorkflowOperation();
12
14
  * } catch (error) {
13
15
  * // Check if this is a HotMesh interruption
14
- * if (didInterrupt(error)) {
15
- * // Rethrow the error if HotMesh interruption
16
+ * if (MemFlow.workflow.didInterrupt(error)) {
17
+ * // Rethrow the error
16
18
  * throw error;
17
19
  * }
18
20
  * // Handle actual error
@@ -4,19 +4,21 @@ exports.didInterrupt = void 0;
4
4
  const errors_1 = require("../../../modules/errors");
5
5
  /**
6
6
  * Checks if an error is a HotMesh reserved error type that indicates
7
- * a workflow interruption rather than a true error condition.
7
+ * a HotMesh interruption rather than a true error condition.
8
8
  *
9
- * When this returns true, you can safely return from your workflow function.
9
+ * When this returns true, you can safely return rethrow the error.
10
10
  * The workflow engine will handle the interruption automatically.
11
11
  *
12
12
  * @example
13
13
  * ```typescript
14
+ * import { MemFlow } from '@hotmeshio/hotmesh';
15
+ *
14
16
  * try {
15
17
  * await someWorkflowOperation();
16
18
  * } catch (error) {
17
19
  * // Check if this is a HotMesh interruption
18
- * if (didInterrupt(error)) {
19
- * // Rethrow the error if HotMesh interruption
20
+ * if (MemFlow.workflow.didInterrupt(error)) {
21
+ * // Rethrow the error
20
22
  * throw error;
21
23
  * }
22
24
  * // Handle actual error
@@ -50,6 +50,7 @@ async function waitFor(signalId) {
50
50
  };
51
51
  interruptionRegistry.push(interruptionMessage);
52
52
  await (0, common_1.sleepImmediate)();
53
+ //if you are seeing this error in the logs, you might have forgotten to `await waitFor(...)`
53
54
  throw new common_1.MemFlowWaitForError(interruptionMessage);
54
55
  }
55
56
  exports.waitFor = waitFor;
@@ -19,5 +19,15 @@ declare abstract class SearchService<ClientProvider extends ProviderClient> {
19
19
  abstract incrementFieldByFloat(key: string, field: string, increment: number): Promise<number>;
20
20
  abstract sendQuery(query: any): Promise<any>;
21
21
  abstract sendIndexedQuery(index: string, query: any[]): Promise<any>;
22
+ abstract findEntities(entity: string, conditions: Record<string, any>, options?: {
23
+ limit?: number;
24
+ offset?: number;
25
+ }): Promise<any[]>;
26
+ abstract findEntityById(entity: string, id: string): Promise<any>;
27
+ abstract findEntitiesByCondition(entity: string, field: string, value: any, operator?: '=' | '!=' | '>' | '<' | '>=' | '<=' | 'LIKE' | 'IN', options?: {
28
+ limit?: number;
29
+ offset?: number;
30
+ }): Promise<any[]>;
31
+ abstract createEntityIndex(entity: string, field: string, indexType?: 'btree' | 'gin' | 'gist'): Promise<void>;
22
32
  }
23
33
  export { SearchService };
@@ -21,5 +21,17 @@ declare class PostgresSearchService extends SearchService<PostgresClientType & P
21
21
  * assume aggregation type query
22
22
  */
23
23
  sendIndexedQuery(type: string, queryParams?: any[]): Promise<any[]>;
24
+ findEntities(entity: string, conditions: Record<string, any>, options?: {
25
+ limit?: number;
26
+ offset?: number;
27
+ }): Promise<any[]>;
28
+ findEntityById(entity: string, id: string): Promise<any>;
29
+ findEntitiesByCondition(entity: string, field: string, value: any, operator?: '=' | '!=' | '>' | '<' | '>=' | '<=' | 'LIKE' | 'IN', options?: {
30
+ limit?: number;
31
+ offset?: number;
32
+ }): Promise<any[]>;
33
+ createEntityIndex(entity: string, field: string, indexType?: 'btree' | 'gin' | 'gist'): Promise<void>;
34
+ private mongoToSqlOperator;
35
+ private inferType;
24
36
  }
25
37
  export { PostgresSearchService };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PostgresSearchService = void 0;
4
4
  const index_1 = require("../../index");
5
5
  const kvsql_1 = require("../../../store/providers/postgres/kvsql");
6
+ const key_1 = require("../../../../modules/key");
6
7
  class PostgresSearchService extends index_1.SearchService {
7
8
  transact() {
8
9
  return this.storeClient.transact();
@@ -145,5 +146,213 @@ class PostgresSearchService extends index_1.SearchService {
145
146
  throw error;
146
147
  }
147
148
  }
149
+ // Entity querying methods for JSONB/SQL operations
150
+ async findEntities(entity, conditions, options) {
151
+ try {
152
+ const schemaName = this.searchClient.safeName(this.appId);
153
+ const tableName = `${schemaName}.${this.searchClient.safeName('jobs')}`;
154
+ // Build WHERE conditions from the conditions object
155
+ const whereConditions = [`entity = $1`];
156
+ const params = [entity];
157
+ let paramIndex = 2;
158
+ for (const [key, value] of Object.entries(conditions)) {
159
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
160
+ // Handle MongoDB-style operators like { $gte: 18 }
161
+ for (const [op, opValue] of Object.entries(value)) {
162
+ const sqlOp = this.mongoToSqlOperator(op);
163
+ whereConditions.push(`(context->>'${key}')::${this.inferType(opValue)} ${sqlOp} $${paramIndex}`);
164
+ params.push(opValue);
165
+ paramIndex++;
166
+ }
167
+ }
168
+ else {
169
+ // Simple equality
170
+ whereConditions.push(`context->>'${key}' = $${paramIndex}`);
171
+ params.push(String(value));
172
+ paramIndex++;
173
+ }
174
+ }
175
+ let sql = `
176
+ SELECT key, context, status
177
+ FROM ${tableName}
178
+ WHERE ${whereConditions.join(' AND ')}
179
+ ORDER BY created_at DESC
180
+ `;
181
+ if (options?.limit) {
182
+ sql += ` LIMIT $${paramIndex}`;
183
+ params.push(options.limit);
184
+ paramIndex++;
185
+ }
186
+ if (options?.offset) {
187
+ sql += ` OFFSET $${paramIndex}`;
188
+ params.push(options.offset);
189
+ }
190
+ const result = await this.pgClient.query(sql, params);
191
+ return result.rows.map(row => ({
192
+ key: row.key,
193
+ context: typeof row.context === 'string' ? JSON.parse(row.context || '{}') : (row.context || {}),
194
+ status: row.status,
195
+ }));
196
+ }
197
+ catch (error) {
198
+ this.logger.error(`postgres-find-entities-error`, { entity, conditions, error });
199
+ throw error;
200
+ }
201
+ }
202
+ async findEntityById(entity, id) {
203
+ try {
204
+ const schemaName = this.searchClient.safeName(this.appId);
205
+ const tableName = `${schemaName}.${this.searchClient.safeName('jobs')}`;
206
+ // Use KeyService to mint the job state key
207
+ const fullKey = key_1.KeyService.mintKey(key_1.HMNS, key_1.KeyType.JOB_STATE, {
208
+ appId: this.appId,
209
+ jobId: id
210
+ });
211
+ const sql = `
212
+ SELECT key, context, status, entity
213
+ FROM ${tableName}
214
+ WHERE entity = $1 AND key = $2
215
+ LIMIT 1
216
+ `;
217
+ const result = await this.pgClient.query(sql, [entity, fullKey]);
218
+ if (result.rows.length === 0) {
219
+ return null;
220
+ }
221
+ const row = result.rows[0];
222
+ return {
223
+ key: row.key,
224
+ context: typeof row.context === 'string' ? JSON.parse(row.context || '{}') : (row.context || {}),
225
+ status: row.status,
226
+ };
227
+ }
228
+ catch (error) {
229
+ this.logger.error(`postgres-find-entity-by-id-error`, { entity, id, error });
230
+ throw error;
231
+ }
232
+ }
233
+ async findEntitiesByCondition(entity, field, value, operator = '=', options) {
234
+ try {
235
+ const schemaName = this.searchClient.safeName(this.appId);
236
+ const tableName = `${schemaName}.${this.searchClient.safeName('jobs')}`;
237
+ const params = [entity];
238
+ let whereCondition;
239
+ let paramIndex = 2;
240
+ if (operator === 'IN') {
241
+ // Handle IN operator with arrays
242
+ const placeholders = Array.isArray(value)
243
+ ? value.map(() => `$${paramIndex++}`).join(',')
244
+ : `$${paramIndex++}`;
245
+ whereCondition = `context->>'${field}' IN (${placeholders})`;
246
+ if (Array.isArray(value)) {
247
+ params.push(...value);
248
+ }
249
+ else {
250
+ params.push(value);
251
+ }
252
+ }
253
+ else if (operator === 'LIKE') {
254
+ whereCondition = `context->>'${field}' LIKE $${paramIndex}`;
255
+ params.push(value);
256
+ paramIndex++;
257
+ }
258
+ else {
259
+ // Handle numeric/comparison operators
260
+ const valueType = this.inferType(value);
261
+ whereCondition = `(context->>'${field}')::${valueType} ${operator} $${paramIndex}`;
262
+ params.push(value);
263
+ paramIndex++;
264
+ }
265
+ let sql = `
266
+ SELECT key, context, status
267
+ FROM ${tableName}
268
+ WHERE entity = $1 AND ${whereCondition}
269
+ ORDER BY created_at DESC
270
+ `;
271
+ if (options?.limit) {
272
+ sql += ` LIMIT $${paramIndex}`;
273
+ params.push(options.limit);
274
+ paramIndex++;
275
+ }
276
+ if (options?.offset) {
277
+ sql += ` OFFSET $${paramIndex}`;
278
+ params.push(options.offset);
279
+ }
280
+ const result = await this.pgClient.query(sql, params);
281
+ return result.rows.map(row => ({
282
+ key: row.key,
283
+ context: typeof row.context === 'string' ? JSON.parse(row.context || '{}') : (row.context || {}),
284
+ status: row.status,
285
+ }));
286
+ }
287
+ catch (error) {
288
+ this.logger.error(`postgres-find-entities-by-condition-error`, {
289
+ entity, field, value, operator, error
290
+ });
291
+ throw error;
292
+ }
293
+ }
294
+ async createEntityIndex(entity, field, indexType = 'btree') {
295
+ try {
296
+ const schemaName = this.searchClient.safeName(this.appId);
297
+ const tableName = `${schemaName}.${this.searchClient.safeName('jobs')}`;
298
+ const indexName = `idx_${this.appId}_${entity}_${field}`.replace(/[^a-zA-Z0-9_]/g, '_');
299
+ let sql;
300
+ if (indexType === 'gin') {
301
+ // GIN index for JSONB operations
302
+ sql = `
303
+ CREATE INDEX IF NOT EXISTS ${indexName}
304
+ ON ${tableName} USING gin (context jsonb_path_ops)
305
+ WHERE entity = '${entity}'
306
+ `;
307
+ }
308
+ else if (indexType === 'gist') {
309
+ // GiST index for specific field
310
+ sql = `
311
+ CREATE EXTENSION IF NOT EXISTS pg_trgm;
312
+ CREATE INDEX IF NOT EXISTS ${indexName}
313
+ ON ${tableName} USING gist ((context->>'${field}') gist_trgm_ops)
314
+ WHERE entity = '${entity}'
315
+ `;
316
+ }
317
+ else {
318
+ // B-tree index for specific field
319
+ sql = `
320
+ CREATE INDEX IF NOT EXISTS ${indexName}
321
+ ON ${tableName} USING btree ((context->>'${field}'))
322
+ WHERE entity = '${entity}'
323
+ `;
324
+ }
325
+ await this.pgClient.query(sql);
326
+ this.logger.info(`postgres-entity-index-created`, { entity, field, indexType, indexName });
327
+ }
328
+ catch (error) {
329
+ this.logger.error(`postgres-create-entity-index-error`, {
330
+ entity, field, indexType, error
331
+ });
332
+ throw error;
333
+ }
334
+ }
335
+ // Helper methods for entity operations
336
+ mongoToSqlOperator(mongoOp) {
337
+ const mapping = {
338
+ '$eq': '=',
339
+ '$ne': '!=',
340
+ '$gt': '>',
341
+ '$gte': '>=',
342
+ '$lt': '<',
343
+ '$lte': '<=',
344
+ '$in': 'IN',
345
+ };
346
+ return mapping[mongoOp] || '=';
347
+ }
348
+ inferType(value) {
349
+ if (typeof value === 'number') {
350
+ return Number.isInteger(value) ? 'integer' : 'numeric';
351
+ }
352
+ if (typeof value === 'boolean') {
353
+ return 'boolean';
354
+ }
355
+ return 'text';
356
+ }
148
357
  }
149
358
  exports.PostgresSearchService = PostgresSearchService;
@@ -15,5 +15,9 @@ declare class IORedisSearchService extends SearchService<IORedisClientType> {
15
15
  incrementFieldByFloat(key: string, field: string, increment: number): Promise<number>;
16
16
  sendQuery(...query: [string, ...string[]]): Promise<any>;
17
17
  sendIndexedQuery(index: string, query: string[]): Promise<string[]>;
18
+ findEntities(): Promise<any[]>;
19
+ findEntityById(): Promise<any>;
20
+ findEntitiesByCondition(): Promise<any[]>;
21
+ createEntityIndex(): Promise<void>;
18
22
  }
19
23
  export { IORedisSearchService };
@@ -117,5 +117,18 @@ class IORedisSearchService extends index_1.SearchService {
117
117
  throw error;
118
118
  }
119
119
  }
120
+ // Entity methods - not implemented for Redis (postgres-specific JSONB operations)
121
+ async findEntities() {
122
+ throw new Error('Entity findEntities not supported in Redis - use PostgreSQL');
123
+ }
124
+ async findEntityById() {
125
+ throw new Error('Entity findEntityById not supported in Redis - use PostgreSQL');
126
+ }
127
+ async findEntitiesByCondition() {
128
+ throw new Error('Entity findEntitiesByCondition not supported in Redis - use PostgreSQL');
129
+ }
130
+ async createEntityIndex() {
131
+ throw new Error('Entity createEntityIndex not supported in Redis - use PostgreSQL');
132
+ }
120
133
  }
121
134
  exports.IORedisSearchService = IORedisSearchService;
@@ -15,5 +15,9 @@ declare class RedisSearchService extends SearchService<RedisRedisClientType> {
15
15
  incrementFieldByFloat(key: string, field: string, increment: number): Promise<number>;
16
16
  sendQuery(...query: any[]): Promise<any>;
17
17
  sendIndexedQuery(index: string, query: string[]): Promise<string[]>;
18
+ findEntities(): Promise<any[]>;
19
+ findEntityById(): Promise<any>;
20
+ findEntitiesByCondition(): Promise<any[]>;
21
+ createEntityIndex(): Promise<void>;
18
22
  }
19
23
  export { RedisSearchService };
@@ -130,5 +130,18 @@ class RedisSearchService extends index_1.SearchService {
130
130
  throw error;
131
131
  }
132
132
  }
133
+ // Entity methods - not implemented for Redis (postgres-specific JSONB operations)
134
+ async findEntities() {
135
+ throw new Error('Entity findEntities not supported in Redis - use PostgreSQL');
136
+ }
137
+ async findEntityById() {
138
+ throw new Error('Entity findEntityById not supported in Redis - use PostgreSQL');
139
+ }
140
+ async findEntitiesByCondition() {
141
+ throw new Error('Entity findEntitiesByCondition not supported in Redis - use PostgreSQL');
142
+ }
143
+ async createEntityIndex() {
144
+ throw new Error('Entity createEntityIndex not supported in Redis - use PostgreSQL');
145
+ }
133
146
  }
134
147
  exports.RedisSearchService = RedisSearchService;
@@ -2,7 +2,7 @@ import { KeyStoreParams } from '../../../../types/hotmesh';
2
2
  import { PostgresClientType } from '../../../../types/postgres';
3
3
  import { ProviderTransaction } from '../../../../types/provider';
4
4
  import { stringModule } from './kvtypes/string';
5
- import { hashModule } from './kvtypes/hash';
5
+ import { hashModule } from './kvtypes/hash/index';
6
6
  import { listModule } from './kvtypes/list';
7
7
  import { zsetModule } from './kvtypes/zset';
8
8
  /**
@@ -30,8 +30,8 @@ export declare class KVSQL {
30
30
  */
31
31
  tableForKey(key: string, stats_type?: 'hash' | 'sorted_set' | 'list'): string;
32
32
  safeName(input: string, prefix?: string): string;
33
- set: (key: string, value: string, options?: import("../../../../types/provider").SetOptions, multi?: ProviderTransaction) => Promise<boolean>;
34
- _set: (key: string, value: string, options?: import("../../../../types/provider").SetOptions) => {
33
+ set: (key: string, value: string, options?: import("./kvtypes/hash/index").SetOptions, multi?: ProviderTransaction) => Promise<boolean>;
34
+ _set: (key: string, value: string, options?: import("./kvtypes/hash/index").SetOptions) => {
35
35
  sql: string;
36
36
  params: any[];
37
37
  };
@@ -47,51 +47,27 @@ export declare class KVSQL {
47
47
  };
48
48
  setnx: (key: string, value: string, multi?: ProviderTransaction) => Promise<boolean>;
49
49
  setnxex: (key: string, value: string, delay: number, multi?: ProviderTransaction) => Promise<boolean>;
50
- hset: (key: string, fields: Record<string, string>, options?: import("../../../../types/provider").HSetOptions, multi?: ProviderTransaction) => Promise<any>;
51
- _hset: (key: string, fields: Record<string, string>, options?: import("../../../../types/provider").HSetOptions) => {
52
- sql: string;
53
- params: any[];
54
- };
50
+ hset: (key: string, fields: Record<string, string>, options?: import("./kvtypes/hash/index").HSetOptions, multi?: any) => Promise<any>;
51
+ _hset: (key: string, fields: Record<string, string>, options?: import("./kvtypes/hash/index").HSetOptions) => import("./kvtypes/hash/types").SqlResult;
55
52
  hsetnx: (key: string, field: string, value: string, multi?: ProviderTransaction, entity?: string) => Promise<number>;
56
53
  hget: (key: string, field: string, multi?: ProviderTransaction) => Promise<string>;
57
- _hget: (key: string, field: string) => {
58
- sql: string;
59
- params: any[];
60
- };
54
+ _hget: (key: string, field: string) => import("./kvtypes/hash/types").SqlResult;
61
55
  hdel: (key: string, fields: string[], multi?: unknown) => Promise<number>;
62
- _hdel: (key: string, fields: string[]) => {
63
- sql: string;
64
- params: any[];
65
- };
56
+ _hdel: (key: string, fields: string[]) => import("./kvtypes/hash/types").SqlResult;
66
57
  hmget: (key: string, fields: string[], multi?: ProviderTransaction) => Promise<string[]>;
67
- _hmget: (key: string, fields: string[]) => {
68
- sql: string;
69
- params: any[];
70
- };
58
+ _hmget: (key: string, fields: string[]) => import("./kvtypes/hash/types").SqlResult;
71
59
  hgetall: (key: string, multi?: ProviderTransaction) => Promise<Record<string, string>>;
72
60
  hincrbyfloat: (key: string, field: string, increment: number, multi?: ProviderTransaction) => Promise<number>;
73
- _hincrbyfloat: (key: string, field: string, increment: number) => {
74
- sql: string;
75
- params: any[];
76
- };
77
- hscan: (key: string, cursor: string, count?: number, pattern?: string, multi?: ProviderTransaction) => Promise<import("../../../../types/provider").HScanResult>;
78
- _hscan: (key: string, cursor: string, count: number, pattern?: string) => {
79
- sql: string;
80
- params: any[];
81
- };
61
+ _hincrbyfloat: (key: string, field: string, increment: number) => import("./kvtypes/hash/types").SqlResult;
62
+ hscan: (key: string, cursor: string, count?: number, pattern?: string, multi?: ProviderTransaction) => Promise<import("./kvtypes/hash/index").HScanResult>;
63
+ _hscan: (key: string, cursor: string, count: number, pattern?: string) => import("./kvtypes/hash/types").SqlResult;
82
64
  expire: (key: string, seconds: number, multi?: ProviderTransaction) => Promise<boolean>;
83
- _expire: (key: string, seconds: number) => {
84
- sql: string;
85
- params: any[];
86
- };
65
+ _expire: (key: string, seconds: number) => import("./kvtypes/hash/types").SqlResult;
87
66
  scan: (cursor: number, count?: number, pattern?: string, multi?: ProviderTransaction) => Promise<{
88
67
  cursor: number;
89
68
  keys: string[];
90
69
  }>;
91
- _scan: (cursor: number, count: number, pattern?: string) => {
92
- sql: string;
93
- params: any[];
94
- };
70
+ _scan: (cursor: number, count: number, pattern?: string) => import("./kvtypes/hash/types").SqlResult;
95
71
  lrange: (key: string, start: number, end: number, multi?: ProviderTransaction) => Promise<string[]>;
96
72
  _lrange: (key: string, start: number, end: number) => {
97
73
  sql: string;
@@ -4,7 +4,7 @@ exports.KVSQL = void 0;
4
4
  const key_1 = require("../../../../modules/key");
5
5
  const kvtransaction_1 = require("./kvtransaction");
6
6
  const string_1 = require("./kvtypes/string");
7
- const hash_1 = require("./kvtypes/hash");
7
+ const index_1 = require("./kvtypes/hash/index");
8
8
  const list_1 = require("./kvtypes/list");
9
9
  const zset_1 = require("./kvtypes/zset");
10
10
  /**
@@ -72,7 +72,7 @@ class KVSQL {
72
72
  this.pgClient = pgClient;
73
73
  this.namespace = namespace;
74
74
  this.appId = appId;
75
- this.hash = (0, hash_1.hashModule)(this);
75
+ this.hash = (0, index_1.hashModule)(this);
76
76
  this.list = (0, list_1.listModule)(this);
77
77
  this.zset = (0, zset_1.zsetModule)(this);
78
78
  this.string = (0, string_1.stringModule)(this);
@@ -0,0 +1,16 @@
1
+ import { HashContext, SqlResult, HSetOptions, ProviderTransaction } from './types';
2
+ export declare function createBasicOperations(context: HashContext['context']): {
3
+ hsetnx(key: string, field: string, value: string, multi?: ProviderTransaction, entity?: string): Promise<number>;
4
+ hset(key: string, fields: Record<string, string>, options?: HSetOptions, multi?: ProviderTransaction): Promise<number | any>;
5
+ hget(key: string, field: string, multi?: ProviderTransaction): Promise<string | null>;
6
+ hdel(key: string, fields: string[], multi?: unknown): Promise<number>;
7
+ hmget(key: string, fields: string[], multi?: ProviderTransaction): Promise<(string | null)[]>;
8
+ hgetall(key: string, multi?: ProviderTransaction): Promise<Record<string, string>>;
9
+ hincrbyfloat(key: string, field: string, increment: number, multi?: ProviderTransaction): Promise<number>;
10
+ };
11
+ export declare function _hset(context: HashContext['context'], key: string, fields: Record<string, string>, options?: HSetOptions): SqlResult;
12
+ export declare function _hget(context: HashContext['context'], key: string, field: string): SqlResult;
13
+ export declare function _hdel(context: HashContext['context'], key: string, fields: string[]): SqlResult;
14
+ export declare function _hmget(context: HashContext['context'], key: string, fields: string[]): SqlResult;
15
+ export declare function _hgetall(context: HashContext['context'], key: string): SqlResult;
16
+ export declare function _hincrbyfloat(context: HashContext['context'], key: string, field: string, increment: number): SqlResult;