@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.
- package/README.md +9 -5
- package/build/package.json +16 -14
- package/build/services/hotmesh/index.d.ts +9 -11
- package/build/services/hotmesh/index.js +9 -11
- package/build/services/memflow/entity.d.ts +168 -4
- package/build/services/memflow/entity.js +177 -15
- package/build/services/memflow/workflow/index.d.ts +2 -4
- package/build/services/memflow/workflow/index.js +2 -4
- package/build/services/memflow/workflow/interruption.d.ts +6 -4
- package/build/services/memflow/workflow/interruption.js +6 -4
- package/build/services/memflow/workflow/waitFor.js +1 -0
- package/build/services/search/index.d.ts +10 -0
- package/build/services/search/providers/postgres/postgres.d.ts +12 -0
- package/build/services/search/providers/postgres/postgres.js +209 -0
- package/build/services/search/providers/redis/ioredis.d.ts +4 -0
- package/build/services/search/providers/redis/ioredis.js +13 -0
- package/build/services/search/providers/redis/redis.d.ts +4 -0
- package/build/services/search/providers/redis/redis.js +13 -0
- package/build/services/store/providers/postgres/kvsql.d.ts +13 -37
- package/build/services/store/providers/postgres/kvsql.js +2 -2
- package/build/services/store/providers/postgres/kvtypes/hash/basic.d.ts +16 -0
- package/build/services/store/providers/postgres/kvtypes/hash/basic.js +480 -0
- package/build/services/store/providers/postgres/kvtypes/hash/expire.d.ts +5 -0
- package/build/services/store/providers/postgres/kvtypes/hash/expire.js +33 -0
- package/build/services/store/providers/postgres/kvtypes/hash/index.d.ts +29 -0
- package/build/services/store/providers/postgres/kvtypes/hash/index.js +190 -0
- package/build/services/store/providers/postgres/kvtypes/hash/jsonb.d.ts +14 -0
- package/build/services/store/providers/postgres/kvtypes/hash/jsonb.js +699 -0
- package/build/services/store/providers/postgres/kvtypes/hash/scan.d.ts +10 -0
- package/build/services/store/providers/postgres/kvtypes/hash/scan.js +91 -0
- package/build/services/store/providers/postgres/kvtypes/hash/types.d.ts +19 -0
- package/build/services/store/providers/postgres/kvtypes/hash/types.js +2 -0
- package/build/services/store/providers/postgres/kvtypes/hash/utils.d.ts +18 -0
- package/build/services/store/providers/postgres/kvtypes/hash/utils.js +90 -0
- package/build/types/memflow.d.ts +1 -1
- package/build/types/meshdata.d.ts +1 -1
- package/package.json +16 -14
- package/build/services/store/providers/postgres/kvtypes/hash.d.ts +0 -60
- package/build/services/store/providers/postgres/kvtypes/hash.js +0 -1287
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.deriveType = exports.isJobsTable = exports.hashModule = void 0;
|
|
18
|
+
const basic_1 = require("./basic");
|
|
19
|
+
const jsonb_1 = require("./jsonb");
|
|
20
|
+
const scan_1 = require("./scan");
|
|
21
|
+
const expire_1 = require("./expire");
|
|
22
|
+
const utils_1 = require("./utils");
|
|
23
|
+
const hashModule = (context) => {
|
|
24
|
+
const basicOps = (0, basic_1.createBasicOperations)(context);
|
|
25
|
+
const jsonbOps = (0, jsonb_1.createJsonbOperations)(context);
|
|
26
|
+
const scanOps = (0, scan_1.createScanOperations)(context);
|
|
27
|
+
const expireOps = (0, expire_1.createExpireOperations)(context);
|
|
28
|
+
return {
|
|
29
|
+
// Basic operations
|
|
30
|
+
...basicOps,
|
|
31
|
+
// Scan operations
|
|
32
|
+
...scanOps,
|
|
33
|
+
// Expire operations
|
|
34
|
+
...expireOps,
|
|
35
|
+
// Enhanced hset that handles JSONB operations
|
|
36
|
+
async hset(key, fields, options, multi) {
|
|
37
|
+
const tableName = context.tableForKey(key, 'hash');
|
|
38
|
+
const isJobsTableResult = (0, utils_1.isJobsTable)(tableName);
|
|
39
|
+
// Handle JSONB operations for jobs tables
|
|
40
|
+
if (isJobsTableResult) {
|
|
41
|
+
// Check for various JSONB operations
|
|
42
|
+
if ('@context' in fields) {
|
|
43
|
+
const { sql, params } = jsonbOps.handleContextSet(key, fields, options);
|
|
44
|
+
return executeJsonbOperation(sql, params, multi);
|
|
45
|
+
}
|
|
46
|
+
else if ('@context:merge' in fields) {
|
|
47
|
+
const { sql, params } = jsonbOps.handleContextMerge(key, fields, options);
|
|
48
|
+
return executeJsonbOperation(sql, params, multi);
|
|
49
|
+
}
|
|
50
|
+
else if ('@context:delete' in fields) {
|
|
51
|
+
const { sql, params } = jsonbOps.handleContextDelete(key, fields, options);
|
|
52
|
+
return executeJsonbOperation(sql, params, multi);
|
|
53
|
+
}
|
|
54
|
+
else if ('@context:append' in fields) {
|
|
55
|
+
const { sql, params } = jsonbOps.handleContextAppend(key, fields, options);
|
|
56
|
+
return executeJsonbOperation(sql, params, multi);
|
|
57
|
+
}
|
|
58
|
+
else if ('@context:prepend' in fields) {
|
|
59
|
+
const { sql, params } = jsonbOps.handleContextPrepend(key, fields, options);
|
|
60
|
+
return executeJsonbOperation(sql, params, multi);
|
|
61
|
+
}
|
|
62
|
+
else if ('@context:remove' in fields) {
|
|
63
|
+
const { sql, params } = jsonbOps.handleContextRemove(key, fields, options);
|
|
64
|
+
return executeJsonbOperation(sql, params, multi);
|
|
65
|
+
}
|
|
66
|
+
else if ('@context:increment' in fields) {
|
|
67
|
+
const { sql, params } = jsonbOps.handleContextIncrement(key, fields, options);
|
|
68
|
+
return executeJsonbOperation(sql, params, multi);
|
|
69
|
+
}
|
|
70
|
+
else if ('@context:toggle' in fields) {
|
|
71
|
+
const { sql, params } = jsonbOps.handleContextToggle(key, fields, options);
|
|
72
|
+
return executeJsonbOperation(sql, params, multi);
|
|
73
|
+
}
|
|
74
|
+
else if ('@context:setIfNotExists' in fields) {
|
|
75
|
+
const { sql, params } = jsonbOps.handleContextSetIfNotExists(key, fields, options);
|
|
76
|
+
return executeJsonbOperation(sql, params, multi);
|
|
77
|
+
}
|
|
78
|
+
else if (Object.keys(fields).some(k => k.startsWith('@context:get:'))) {
|
|
79
|
+
const { sql, params } = jsonbOps.handleContextGetPath(key, fields, options);
|
|
80
|
+
return executeJsonbOperation(sql, params, multi);
|
|
81
|
+
}
|
|
82
|
+
else if ('@context:get' in fields) {
|
|
83
|
+
const { sql, params } = jsonbOps.handleContextGet(key, fields, options);
|
|
84
|
+
return executeJsonbOperation(sql, params, multi);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Fall back to basic hset for all other cases
|
|
88
|
+
return basicOps.hset(key, fields, options, multi);
|
|
89
|
+
},
|
|
90
|
+
// Private methods for internal use by kvsql
|
|
91
|
+
_hset: (key, fields, options) => {
|
|
92
|
+
const tableName = context.tableForKey(key, 'hash');
|
|
93
|
+
const isJobsTableResult = (0, utils_1.isJobsTable)(tableName);
|
|
94
|
+
// Handle JSONB operations for jobs tables
|
|
95
|
+
if (isJobsTableResult) {
|
|
96
|
+
if ('@context' in fields) {
|
|
97
|
+
return jsonbOps.handleContextSet(key, fields, options);
|
|
98
|
+
}
|
|
99
|
+
else if ('@context:merge' in fields) {
|
|
100
|
+
return jsonbOps.handleContextMerge(key, fields, options);
|
|
101
|
+
}
|
|
102
|
+
else if ('@context:delete' in fields) {
|
|
103
|
+
return jsonbOps.handleContextDelete(key, fields, options);
|
|
104
|
+
}
|
|
105
|
+
else if ('@context:append' in fields) {
|
|
106
|
+
return jsonbOps.handleContextAppend(key, fields, options);
|
|
107
|
+
}
|
|
108
|
+
else if ('@context:prepend' in fields) {
|
|
109
|
+
return jsonbOps.handleContextPrepend(key, fields, options);
|
|
110
|
+
}
|
|
111
|
+
else if ('@context:remove' in fields) {
|
|
112
|
+
return jsonbOps.handleContextRemove(key, fields, options);
|
|
113
|
+
}
|
|
114
|
+
else if ('@context:increment' in fields) {
|
|
115
|
+
return jsonbOps.handleContextIncrement(key, fields, options);
|
|
116
|
+
}
|
|
117
|
+
else if ('@context:toggle' in fields) {
|
|
118
|
+
return jsonbOps.handleContextToggle(key, fields, options);
|
|
119
|
+
}
|
|
120
|
+
else if ('@context:setIfNotExists' in fields) {
|
|
121
|
+
return jsonbOps.handleContextSetIfNotExists(key, fields, options);
|
|
122
|
+
}
|
|
123
|
+
else if (Object.keys(fields).some(k => k.startsWith('@context:get:'))) {
|
|
124
|
+
return jsonbOps.handleContextGetPath(key, fields, options);
|
|
125
|
+
}
|
|
126
|
+
else if ('@context:get' in fields) {
|
|
127
|
+
return jsonbOps.handleContextGet(key, fields, options);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Use the imported _hset function
|
|
131
|
+
return (0, basic_1._hset)(context, key, fields, options);
|
|
132
|
+
},
|
|
133
|
+
_hget: (key, field) => {
|
|
134
|
+
return (0, basic_1._hget)(context, key, field);
|
|
135
|
+
},
|
|
136
|
+
_hdel: (key, fields) => {
|
|
137
|
+
return (0, basic_1._hdel)(context, key, fields);
|
|
138
|
+
},
|
|
139
|
+
_hmget: (key, fields) => {
|
|
140
|
+
return (0, basic_1._hmget)(context, key, fields);
|
|
141
|
+
},
|
|
142
|
+
_hincrbyfloat: (key, field, increment) => {
|
|
143
|
+
return (0, basic_1._hincrbyfloat)(context, key, field, increment);
|
|
144
|
+
},
|
|
145
|
+
_hscan: (key, cursor, count, pattern) => {
|
|
146
|
+
return (0, scan_1._hscan)(context, key, cursor, count, pattern);
|
|
147
|
+
},
|
|
148
|
+
_expire: (key, seconds) => {
|
|
149
|
+
return (0, expire_1._expire)(context, key, seconds);
|
|
150
|
+
},
|
|
151
|
+
_scan: (cursor, count, pattern) => {
|
|
152
|
+
return (0, scan_1._scan)(context, cursor, count, pattern);
|
|
153
|
+
},
|
|
154
|
+
// Utility functions
|
|
155
|
+
isJobsTable: utils_1.isJobsTable,
|
|
156
|
+
};
|
|
157
|
+
async function executeJsonbOperation(sql, params, multi) {
|
|
158
|
+
if (multi) {
|
|
159
|
+
multi.addCommand(sql, params, 'any');
|
|
160
|
+
return Promise.resolve(0);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
try {
|
|
164
|
+
const res = await context.pgClient.query(sql, params);
|
|
165
|
+
if (res.rows[0]?.new_value !== undefined) {
|
|
166
|
+
let returnValue;
|
|
167
|
+
try {
|
|
168
|
+
// Try to parse as JSON, fallback to string if it fails
|
|
169
|
+
returnValue = JSON.parse(res.rows[0].new_value);
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
returnValue = res.rows[0].new_value;
|
|
173
|
+
}
|
|
174
|
+
return returnValue;
|
|
175
|
+
}
|
|
176
|
+
return res.rowCount || res.rows[0]?.count || 0;
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
console.error('JSONB operation error', err, sql, params);
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
exports.hashModule = hashModule;
|
|
186
|
+
// Export utility functions for other modules to use
|
|
187
|
+
var utils_2 = require("./utils");
|
|
188
|
+
Object.defineProperty(exports, "isJobsTable", { enumerable: true, get: function () { return utils_2.isJobsTable; } });
|
|
189
|
+
Object.defineProperty(exports, "deriveType", { enumerable: true, get: function () { return utils_2.deriveType; } });
|
|
190
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HashContext, SqlResult, HSetOptions } from './types';
|
|
2
|
+
export declare function createJsonbOperations(context: HashContext['context']): {
|
|
3
|
+
handleContextSet: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
4
|
+
handleContextMerge: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
5
|
+
handleContextDelete: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
6
|
+
handleContextAppend: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
7
|
+
handleContextPrepend: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
8
|
+
handleContextRemove: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
9
|
+
handleContextIncrement: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
10
|
+
handleContextToggle: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
11
|
+
handleContextSetIfNotExists: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
12
|
+
handleContextGet: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
13
|
+
handleContextGetPath: (key: string, fields: Record<string, string>, options?: HSetOptions) => SqlResult;
|
|
14
|
+
};
|