@hotmeshio/hotmesh 0.13.0 → 0.14.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.
- package/README.md +18 -22
- package/build/modules/enums.d.ts +60 -5
- package/build/modules/enums.js +62 -7
- package/build/modules/errors.d.ts +15 -3
- package/build/modules/errors.js +17 -2
- package/build/package.json +6 -1
- package/build/services/activities/activity/context.d.ts +22 -0
- package/build/services/activities/activity/context.js +76 -0
- package/build/services/activities/activity/index.d.ts +116 -0
- package/build/services/activities/activity/index.js +299 -0
- package/build/services/activities/activity/mapping.d.ts +12 -0
- package/build/services/activities/activity/mapping.js +63 -0
- package/build/services/activities/activity/process.d.ts +28 -0
- package/build/services/activities/activity/process.js +100 -0
- package/build/services/activities/activity/protocol.d.ts +39 -0
- package/build/services/activities/activity/protocol.js +151 -0
- package/build/services/activities/activity/state.d.ts +40 -0
- package/build/services/activities/activity/state.js +143 -0
- package/build/services/activities/activity/transition.d.ts +23 -0
- package/build/services/activities/activity/transition.js +71 -0
- package/build/services/activities/activity/verify.d.ts +22 -0
- package/build/services/activities/activity/verify.js +85 -0
- package/build/services/activities/await.d.ts +1 -4
- package/build/services/activities/await.js +2 -36
- package/build/services/activities/cycle.d.ts +1 -11
- package/build/services/activities/cycle.js +3 -46
- package/build/services/activities/hook.d.ts +2 -11
- package/build/services/activities/hook.js +30 -50
- package/build/services/activities/interrupt.d.ts +2 -4
- package/build/services/activities/interrupt.js +4 -38
- package/build/services/activities/signal.d.ts +1 -11
- package/build/services/activities/signal.js +3 -48
- package/build/services/activities/trigger.d.ts +1 -3
- package/build/services/activities/trigger.js +0 -3
- package/build/services/activities/worker.d.ts +3 -6
- package/build/services/activities/worker.js +4 -40
- package/build/services/connector/factory.d.ts +6 -0
- package/build/services/connector/factory.js +24 -0
- package/build/services/durable/activity.d.ts +1 -1
- package/build/services/durable/activity.js +2 -2
- package/build/services/durable/client.d.ts +24 -29
- package/build/services/durable/client.js +24 -29
- package/build/services/durable/connection.d.ts +13 -7
- package/build/services/durable/connection.js +13 -7
- package/build/services/durable/handle.d.ts +58 -40
- package/build/services/durable/handle.js +60 -40
- package/build/services/durable/index.d.ts +148 -286
- package/build/services/durable/index.js +157 -292
- package/build/services/durable/interceptor.d.ts +43 -33
- package/build/services/durable/interceptor.js +59 -39
- package/build/services/durable/schemas/factory.d.ts +1 -1
- package/build/services/durable/schemas/factory.js +168 -38
- package/build/services/durable/telemetry.d.ts +80 -0
- package/build/services/durable/telemetry.js +137 -0
- package/build/services/durable/worker.d.ts +100 -21
- package/build/services/durable/worker.js +304 -63
- package/build/services/durable/workflow/all.d.ts +1 -1
- package/build/services/durable/workflow/all.js +1 -1
- package/build/services/durable/workflow/cancellationScope.d.ts +104 -0
- package/build/services/durable/workflow/cancellationScope.js +139 -0
- package/build/services/durable/workflow/common.d.ts +5 -4
- package/build/services/durable/workflow/common.js +6 -1
- package/build/services/durable/workflow/{waitFor.d.ts → condition.d.ts} +9 -8
- package/build/services/durable/workflow/{waitFor.js → condition.js} +44 -11
- package/build/services/durable/workflow/continueAsNew.d.ts +65 -0
- package/build/services/durable/workflow/continueAsNew.js +92 -0
- package/build/services/durable/workflow/didRun.d.ts +1 -1
- package/build/services/durable/workflow/didRun.js +3 -3
- package/build/services/durable/workflow/enrich.d.ts +5 -0
- package/build/services/durable/workflow/enrich.js +5 -0
- package/build/services/durable/workflow/entityMethods.d.ts +7 -0
- package/build/services/durable/workflow/entityMethods.js +7 -0
- package/build/services/durable/workflow/execHook.js +3 -3
- package/build/services/durable/workflow/execHookBatch.js +2 -2
- package/build/services/durable/workflow/{execChild.d.ts → executeChild.d.ts} +4 -40
- package/build/services/durable/workflow/{execChild.js → executeChild.js} +36 -45
- package/build/services/durable/workflow/hook.d.ts +1 -1
- package/build/services/durable/workflow/hook.js +4 -3
- package/build/services/durable/workflow/index.d.ts +45 -50
- package/build/services/durable/workflow/index.js +46 -51
- package/build/services/durable/workflow/interruption.d.ts +7 -6
- package/build/services/durable/workflow/interruption.js +11 -7
- package/build/services/durable/workflow/patched.d.ts +72 -0
- package/build/services/durable/workflow/patched.js +110 -0
- package/build/services/durable/workflow/proxyActivities.d.ts +7 -7
- package/build/services/durable/workflow/proxyActivities.js +50 -15
- package/build/services/durable/workflow/searchMethods.d.ts +7 -0
- package/build/services/durable/workflow/searchMethods.js +7 -0
- package/build/services/durable/workflow/signal.d.ts +4 -4
- package/build/services/durable/workflow/signal.js +4 -4
- package/build/services/durable/workflow/{sleepFor.d.ts → sleep.d.ts} +7 -7
- package/build/services/durable/workflow/{sleepFor.js → sleep.js} +39 -10
- package/build/services/durable/workflow/terminate.d.ts +55 -0
- package/build/services/durable/workflow/{interrupt.js → terminate.js} +21 -21
- package/build/services/durable/workflow/trace.js +2 -2
- package/build/services/durable/workflow/uuid4.d.ts +14 -0
- package/build/services/durable/workflow/uuid4.js +39 -0
- package/build/services/durable/workflow/{context.d.ts → workflowInfo.d.ts} +5 -5
- package/build/services/durable/workflow/{context.js → workflowInfo.js} +7 -7
- package/build/services/engine/compiler.d.ts +19 -0
- package/build/services/engine/compiler.js +20 -0
- package/build/services/engine/completion.d.ts +46 -0
- package/build/services/engine/completion.js +145 -0
- package/build/services/engine/dispatch.d.ts +24 -0
- package/build/services/engine/dispatch.js +98 -0
- package/build/services/engine/index.d.ts +49 -81
- package/build/services/engine/index.js +175 -573
- package/build/services/engine/init.d.ts +42 -0
- package/build/services/engine/init.js +74 -0
- package/build/services/engine/pubsub.d.ts +50 -0
- package/build/services/engine/pubsub.js +118 -0
- package/build/services/engine/reporting.d.ts +20 -0
- package/build/services/engine/reporting.js +38 -0
- package/build/services/engine/schema.d.ts +23 -0
- package/build/services/engine/schema.js +62 -0
- package/build/services/engine/signal.d.ts +57 -0
- package/build/services/engine/signal.js +117 -0
- package/build/services/engine/state.d.ts +35 -0
- package/build/services/engine/state.js +61 -0
- package/build/services/engine/version.d.ts +31 -0
- package/build/services/engine/version.js +73 -0
- package/build/services/hotmesh/deployment.d.ts +21 -0
- package/build/services/hotmesh/deployment.js +25 -0
- package/build/services/hotmesh/index.d.ts +141 -532
- package/build/services/hotmesh/index.js +222 -673
- package/build/services/hotmesh/init.d.ts +42 -0
- package/build/services/hotmesh/init.js +93 -0
- package/build/services/hotmesh/jobs.d.ts +67 -0
- package/build/services/hotmesh/jobs.js +99 -0
- package/build/services/hotmesh/pubsub.d.ts +38 -0
- package/build/services/hotmesh/pubsub.js +54 -0
- package/build/services/hotmesh/quorum.d.ts +30 -0
- package/build/services/hotmesh/quorum.js +62 -0
- package/build/services/hotmesh/validation.d.ts +6 -0
- package/build/services/hotmesh/validation.js +28 -0
- package/build/services/quorum/index.js +1 -0
- package/build/services/router/consumption/index.d.ts +11 -5
- package/build/services/router/consumption/index.js +24 -17
- package/build/services/router/error-handling/index.d.ts +2 -2
- package/build/services/router/error-handling/index.js +14 -14
- package/build/services/router/index.d.ts +1 -1
- package/build/services/router/index.js +2 -2
- package/build/services/serializer/index.d.ts +22 -0
- package/build/services/serializer/index.js +39 -1
- package/build/services/store/index.d.ts +1 -0
- package/build/services/store/providers/postgres/exporter-sql.d.ts +2 -2
- package/build/services/store/providers/postgres/exporter-sql.js +4 -4
- package/build/services/store/providers/postgres/kvtables.js +7 -6
- package/build/services/store/providers/postgres/kvtypes/hash/basic.js +67 -52
- package/build/services/store/providers/postgres/kvtypes/hash/jsonb.js +87 -72
- package/build/services/store/providers/postgres/kvtypes/hash/udata.js +106 -79
- package/build/services/store/providers/postgres/kvtypes/hash/utils.d.ts +16 -0
- package/build/services/store/providers/postgres/kvtypes/hash/utils.js +29 -16
- package/build/services/store/providers/postgres/postgres.d.ts +1 -0
- package/build/services/store/providers/postgres/postgres.js +14 -4
- package/build/services/stream/factory.d.ts +3 -1
- package/build/services/stream/factory.js +2 -2
- package/build/services/stream/index.d.ts +1 -0
- package/build/services/stream/providers/nats/nats.d.ts +1 -0
- package/build/services/stream/providers/nats/nats.js +1 -0
- package/build/services/stream/providers/postgres/credentials.d.ts +56 -0
- package/build/services/stream/providers/postgres/credentials.js +129 -0
- package/build/services/stream/providers/postgres/kvtables.js +18 -0
- package/build/services/stream/providers/postgres/messages.js +7 -7
- package/build/services/stream/providers/postgres/notifications.js +16 -2
- package/build/services/stream/providers/postgres/postgres.d.ts +7 -0
- package/build/services/stream/providers/postgres/postgres.js +35 -4
- package/build/services/stream/providers/postgres/procedures.d.ts +21 -0
- package/build/services/stream/providers/postgres/procedures.js +213 -0
- package/build/services/stream/providers/postgres/secured.d.ts +34 -0
- package/build/services/stream/providers/postgres/secured.js +146 -0
- package/build/services/stream/providers/postgres/stats.d.ts +1 -0
- package/build/services/stream/providers/postgres/stats.js +1 -0
- package/build/services/stream/registry.d.ts +1 -1
- package/build/services/stream/registry.js +5 -2
- package/build/services/telemetry/index.d.ts +10 -1
- package/build/services/telemetry/index.js +40 -7
- package/build/services/worker/credentials.d.ts +51 -0
- package/build/services/worker/credentials.js +87 -0
- package/build/services/worker/index.d.ts +2 -2
- package/build/services/worker/index.js +7 -6
- package/build/types/codec.d.ts +84 -0
- package/build/types/codec.js +2 -0
- package/build/types/durable.d.ts +104 -28
- package/build/types/error.d.ts +10 -1
- package/build/types/hotmesh.d.ts +67 -4
- package/build/types/index.d.ts +2 -1
- package/build/types/provider.d.ts +2 -2
- package/build/types/quorum.d.ts +35 -1
- package/build/types/stream.d.ts +12 -6
- package/package.json +6 -1
- package/build/services/activities/activity.d.ts +0 -192
- package/build/services/activities/activity.js +0 -786
- package/build/services/durable/workflow/interrupt.d.ts +0 -55
|
@@ -23,6 +23,7 @@ function createJsonbOperations(context) {
|
|
|
23
23
|
let sql = '';
|
|
24
24
|
if (options?.nx) {
|
|
25
25
|
if (replayId) {
|
|
26
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
26
27
|
sql = `
|
|
27
28
|
WITH inserted_job AS (
|
|
28
29
|
INSERT INTO ${tableName} (id, key, context)
|
|
@@ -34,16 +35,16 @@ function createJsonbOperations(context) {
|
|
|
34
35
|
RETURNING id, context::text as new_value
|
|
35
36
|
),
|
|
36
37
|
replay_insert AS (
|
|
37
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
38
|
-
SELECT id, $3, new_value, $
|
|
38
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
39
|
+
SELECT id, $3, $4, new_value, $5
|
|
39
40
|
FROM inserted_job
|
|
40
|
-
ON CONFLICT (job_id,
|
|
41
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
41
42
|
SET value = EXCLUDED.value
|
|
42
43
|
RETURNING 1
|
|
43
44
|
)
|
|
44
45
|
SELECT new_value FROM inserted_job
|
|
45
46
|
`;
|
|
46
|
-
params.push(key, fields['@context'],
|
|
47
|
+
params.push(key, fields['@context'], replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
47
48
|
}
|
|
48
49
|
else {
|
|
49
50
|
sql = `
|
|
@@ -60,6 +61,7 @@ function createJsonbOperations(context) {
|
|
|
60
61
|
}
|
|
61
62
|
else {
|
|
62
63
|
if (replayId) {
|
|
64
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
63
65
|
sql = `
|
|
64
66
|
WITH updated_job AS (
|
|
65
67
|
UPDATE ${tableName}
|
|
@@ -68,16 +70,16 @@ function createJsonbOperations(context) {
|
|
|
68
70
|
RETURNING id, context::text as new_value
|
|
69
71
|
),
|
|
70
72
|
replay_insert AS (
|
|
71
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
72
|
-
SELECT id, $3, new_value, $
|
|
73
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
74
|
+
SELECT id, $3, $4, new_value, $5
|
|
73
75
|
FROM updated_job
|
|
74
|
-
ON CONFLICT (job_id,
|
|
76
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
75
77
|
SET value = EXCLUDED.value
|
|
76
78
|
RETURNING 1
|
|
77
79
|
)
|
|
78
80
|
SELECT new_value FROM updated_job
|
|
79
81
|
`;
|
|
80
|
-
params.push(key, fields['@context'],
|
|
82
|
+
params.push(key, fields['@context'], replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
81
83
|
}
|
|
82
84
|
else {
|
|
83
85
|
sql = `
|
|
@@ -110,12 +112,13 @@ function createJsonbOperations(context) {
|
|
|
110
112
|
}
|
|
111
113
|
else {
|
|
112
114
|
if (replayId) {
|
|
115
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
113
116
|
sql = `
|
|
114
117
|
WITH updated_job AS (
|
|
115
118
|
UPDATE ${tableName}
|
|
116
119
|
SET context = (
|
|
117
120
|
WITH RECURSIVE deep_merge(original, new_data, result) AS (
|
|
118
|
-
SELECT
|
|
121
|
+
SELECT
|
|
119
122
|
COALESCE(context, '{}'::jsonb) as original,
|
|
120
123
|
$2::jsonb as new_data,
|
|
121
124
|
COALESCE(context, '{}'::jsonb) as result
|
|
@@ -123,11 +126,11 @@ function createJsonbOperations(context) {
|
|
|
123
126
|
WHERE key = $1 AND is_live
|
|
124
127
|
),
|
|
125
128
|
merged_data AS (
|
|
126
|
-
SELECT
|
|
129
|
+
SELECT
|
|
127
130
|
(
|
|
128
131
|
SELECT jsonb_object_agg(
|
|
129
132
|
key,
|
|
130
|
-
CASE
|
|
133
|
+
CASE
|
|
131
134
|
WHEN jsonb_typeof(original -> key) = 'object' AND jsonb_typeof(new_data -> key) = 'object'
|
|
132
135
|
THEN (
|
|
133
136
|
WITH nested_keys AS (
|
|
@@ -135,7 +138,7 @@ function createJsonbOperations(context) {
|
|
|
135
138
|
)
|
|
136
139
|
SELECT jsonb_object_agg(
|
|
137
140
|
nested_key,
|
|
138
|
-
CASE
|
|
141
|
+
CASE
|
|
139
142
|
WHEN (new_data -> key) ? nested_key
|
|
140
143
|
THEN (new_data -> key) -> nested_key
|
|
141
144
|
ELSE (original -> key) -> nested_key
|
|
@@ -160,27 +163,27 @@ function createJsonbOperations(context) {
|
|
|
160
163
|
RETURNING id, context::text as new_value
|
|
161
164
|
),
|
|
162
165
|
replay_insert AS (
|
|
163
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
164
|
-
SELECT id, $3, new_value, $
|
|
166
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
167
|
+
SELECT id, $3, $4, new_value, $5
|
|
165
168
|
FROM updated_job
|
|
166
|
-
ON CONFLICT (job_id,
|
|
169
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
167
170
|
SET value = EXCLUDED.value
|
|
168
171
|
RETURNING 1
|
|
169
172
|
)
|
|
170
173
|
SELECT new_value FROM updated_job
|
|
171
174
|
`;
|
|
172
|
-
params.push(key, fields['@context:merge'],
|
|
175
|
+
params.push(key, fields['@context:merge'], replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
173
176
|
}
|
|
174
177
|
else {
|
|
175
178
|
sql = `
|
|
176
179
|
UPDATE ${tableName}
|
|
177
180
|
SET context = (
|
|
178
181
|
WITH merged_data AS (
|
|
179
|
-
SELECT
|
|
182
|
+
SELECT
|
|
180
183
|
(
|
|
181
184
|
SELECT jsonb_object_agg(
|
|
182
185
|
key,
|
|
183
|
-
CASE
|
|
186
|
+
CASE
|
|
184
187
|
WHEN jsonb_typeof(original -> key) = 'object' AND jsonb_typeof(new_data -> key) = 'object'
|
|
185
188
|
THEN (
|
|
186
189
|
WITH nested_keys AS (
|
|
@@ -188,7 +191,7 @@ function createJsonbOperations(context) {
|
|
|
188
191
|
)
|
|
189
192
|
SELECT jsonb_object_agg(
|
|
190
193
|
nested_key,
|
|
191
|
-
CASE
|
|
194
|
+
CASE
|
|
192
195
|
WHEN (new_data -> key) ? nested_key
|
|
193
196
|
THEN (new_data -> key) -> nested_key
|
|
194
197
|
ELSE (original -> key) -> nested_key
|
|
@@ -206,7 +209,7 @@ function createJsonbOperations(context) {
|
|
|
206
209
|
) all_keys
|
|
207
210
|
) as merged_context
|
|
208
211
|
FROM (
|
|
209
|
-
SELECT
|
|
212
|
+
SELECT
|
|
210
213
|
COALESCE(context, '{}'::jsonb) as original,
|
|
211
214
|
$2::jsonb as new_data
|
|
212
215
|
FROM ${tableName}
|
|
@@ -233,6 +236,7 @@ function createJsonbOperations(context) {
|
|
|
233
236
|
if (pathParts.length === 1) {
|
|
234
237
|
// Simple key deletion
|
|
235
238
|
if (replayId) {
|
|
239
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
236
240
|
sql = `
|
|
237
241
|
WITH updated_job AS (
|
|
238
242
|
UPDATE ${tableName}
|
|
@@ -241,16 +245,16 @@ function createJsonbOperations(context) {
|
|
|
241
245
|
RETURNING id, context::text as new_value
|
|
242
246
|
),
|
|
243
247
|
replay_insert AS (
|
|
244
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
245
|
-
SELECT id, $3, new_value, $
|
|
248
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
249
|
+
SELECT id, $3, $4, new_value, $5
|
|
246
250
|
FROM updated_job
|
|
247
|
-
ON CONFLICT (job_id,
|
|
251
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
248
252
|
SET value = EXCLUDED.value
|
|
249
253
|
RETURNING 1
|
|
250
254
|
)
|
|
251
255
|
SELECT new_value FROM updated_job
|
|
252
256
|
`;
|
|
253
|
-
params.push(key, path,
|
|
257
|
+
params.push(key, path, replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
254
258
|
}
|
|
255
259
|
else {
|
|
256
260
|
sql = `
|
|
@@ -265,6 +269,7 @@ function createJsonbOperations(context) {
|
|
|
265
269
|
else {
|
|
266
270
|
// Nested path deletion using jsonb_set with null to remove
|
|
267
271
|
if (replayId) {
|
|
272
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
268
273
|
sql = `
|
|
269
274
|
WITH updated_job AS (
|
|
270
275
|
UPDATE ${tableName}
|
|
@@ -273,16 +278,16 @@ function createJsonbOperations(context) {
|
|
|
273
278
|
RETURNING id, context::text as new_value
|
|
274
279
|
),
|
|
275
280
|
replay_insert AS (
|
|
276
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
277
|
-
SELECT id, $3, new_value, $
|
|
281
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
282
|
+
SELECT id, $3, $4, new_value, $5
|
|
278
283
|
FROM updated_job
|
|
279
|
-
ON CONFLICT (job_id,
|
|
284
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
280
285
|
SET value = EXCLUDED.value
|
|
281
286
|
RETURNING 1
|
|
282
287
|
)
|
|
283
288
|
SELECT new_value FROM updated_job
|
|
284
289
|
`;
|
|
285
|
-
params.push(key, pathParts,
|
|
290
|
+
params.push(key, pathParts, replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
286
291
|
}
|
|
287
292
|
else {
|
|
288
293
|
sql = `
|
|
@@ -304,6 +309,7 @@ function createJsonbOperations(context) {
|
|
|
304
309
|
const params = [];
|
|
305
310
|
let sql = '';
|
|
306
311
|
if (replayId) {
|
|
312
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
307
313
|
sql = `
|
|
308
314
|
WITH updated_job AS (
|
|
309
315
|
UPDATE ${tableName}
|
|
@@ -317,16 +323,16 @@ function createJsonbOperations(context) {
|
|
|
317
323
|
RETURNING id, (context #> $2::text[])::text as new_value
|
|
318
324
|
),
|
|
319
325
|
replay_insert AS (
|
|
320
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
321
|
-
SELECT id, $4, new_value, $
|
|
326
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
327
|
+
SELECT id, $4, $5, new_value, $6
|
|
322
328
|
FROM updated_job
|
|
323
|
-
ON CONFLICT (job_id,
|
|
329
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
324
330
|
SET value = EXCLUDED.value
|
|
325
331
|
RETURNING 1
|
|
326
332
|
)
|
|
327
333
|
SELECT new_value FROM updated_job
|
|
328
334
|
`;
|
|
329
|
-
params.push(key, pathParts, JSON.stringify([value]),
|
|
335
|
+
params.push(key, pathParts, JSON.stringify([value]), replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
330
336
|
}
|
|
331
337
|
else {
|
|
332
338
|
sql = `
|
|
@@ -352,6 +358,7 @@ function createJsonbOperations(context) {
|
|
|
352
358
|
const params = [];
|
|
353
359
|
let sql = '';
|
|
354
360
|
if (replayId) {
|
|
361
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
355
362
|
sql = `
|
|
356
363
|
WITH updated_job AS (
|
|
357
364
|
UPDATE ${tableName}
|
|
@@ -365,16 +372,16 @@ function createJsonbOperations(context) {
|
|
|
365
372
|
RETURNING id, (context #> $2::text[])::text as new_value
|
|
366
373
|
),
|
|
367
374
|
replay_insert AS (
|
|
368
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
369
|
-
SELECT id, $4, new_value, $
|
|
375
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
376
|
+
SELECT id, $4, $5, new_value, $6
|
|
370
377
|
FROM updated_job
|
|
371
|
-
ON CONFLICT (job_id,
|
|
378
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
372
379
|
SET value = EXCLUDED.value
|
|
373
380
|
RETURNING 1
|
|
374
381
|
)
|
|
375
382
|
SELECT new_value FROM updated_job
|
|
376
383
|
`;
|
|
377
|
-
params.push(key, pathParts, JSON.stringify([value]),
|
|
384
|
+
params.push(key, pathParts, JSON.stringify([value]), replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
378
385
|
}
|
|
379
386
|
else {
|
|
380
387
|
sql = `
|
|
@@ -400,6 +407,7 @@ function createJsonbOperations(context) {
|
|
|
400
407
|
const params = [];
|
|
401
408
|
let sql = '';
|
|
402
409
|
if (replayId) {
|
|
410
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
403
411
|
sql = `
|
|
404
412
|
WITH updated_job AS (
|
|
405
413
|
UPDATE ${tableName}
|
|
@@ -420,16 +428,16 @@ function createJsonbOperations(context) {
|
|
|
420
428
|
RETURNING id, (context #> $2::text[])::text as new_value
|
|
421
429
|
),
|
|
422
430
|
replay_insert AS (
|
|
423
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
424
|
-
SELECT id, $4, new_value, $
|
|
431
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
432
|
+
SELECT id, $4, $5, new_value, $6
|
|
425
433
|
FROM updated_job
|
|
426
|
-
ON CONFLICT (job_id,
|
|
434
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
427
435
|
SET value = EXCLUDED.value
|
|
428
436
|
RETURNING 1
|
|
429
437
|
)
|
|
430
438
|
SELECT new_value FROM updated_job
|
|
431
439
|
`;
|
|
432
|
-
params.push(key, pathParts, index,
|
|
440
|
+
params.push(key, pathParts, index, replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
433
441
|
}
|
|
434
442
|
else {
|
|
435
443
|
sql = `
|
|
@@ -462,6 +470,7 @@ function createJsonbOperations(context) {
|
|
|
462
470
|
const params = [];
|
|
463
471
|
let sql = '';
|
|
464
472
|
if (replayId) {
|
|
473
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
465
474
|
sql = `
|
|
466
475
|
WITH updated_job AS (
|
|
467
476
|
UPDATE ${tableName}
|
|
@@ -475,16 +484,16 @@ function createJsonbOperations(context) {
|
|
|
475
484
|
RETURNING id, (context #> $2::text[])::text as new_value
|
|
476
485
|
),
|
|
477
486
|
replay_insert AS (
|
|
478
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
479
|
-
SELECT id, $4, new_value, $
|
|
487
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
488
|
+
SELECT id, $4, $5, new_value, $6
|
|
480
489
|
FROM updated_job
|
|
481
|
-
ON CONFLICT (job_id,
|
|
490
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
482
491
|
SET value = EXCLUDED.value
|
|
483
492
|
RETURNING 1
|
|
484
493
|
)
|
|
485
494
|
SELECT new_value FROM updated_job
|
|
486
495
|
`;
|
|
487
|
-
params.push(key, pathParts, value,
|
|
496
|
+
params.push(key, pathParts, value, replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
488
497
|
}
|
|
489
498
|
else {
|
|
490
499
|
sql = `
|
|
@@ -510,6 +519,7 @@ function createJsonbOperations(context) {
|
|
|
510
519
|
const params = [];
|
|
511
520
|
let sql = '';
|
|
512
521
|
if (replayId) {
|
|
522
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
513
523
|
sql = `
|
|
514
524
|
WITH updated_job AS (
|
|
515
525
|
UPDATE ${tableName}
|
|
@@ -523,16 +533,16 @@ function createJsonbOperations(context) {
|
|
|
523
533
|
RETURNING id, (context #> $2::text[])::text as new_value
|
|
524
534
|
),
|
|
525
535
|
replay_insert AS (
|
|
526
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
527
|
-
SELECT id, $3, new_value, $
|
|
536
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
537
|
+
SELECT id, $3, $4, new_value, $5
|
|
528
538
|
FROM updated_job
|
|
529
|
-
ON CONFLICT (job_id,
|
|
539
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
530
540
|
SET value = EXCLUDED.value
|
|
531
541
|
RETURNING 1
|
|
532
542
|
)
|
|
533
543
|
SELECT new_value FROM updated_job
|
|
534
544
|
`;
|
|
535
|
-
params.push(key, pathParts,
|
|
545
|
+
params.push(key, pathParts, replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
536
546
|
}
|
|
537
547
|
else {
|
|
538
548
|
sql = `
|
|
@@ -558,11 +568,12 @@ function createJsonbOperations(context) {
|
|
|
558
568
|
const params = [];
|
|
559
569
|
let sql = '';
|
|
560
570
|
if (replayId) {
|
|
571
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
561
572
|
sql = `
|
|
562
573
|
WITH updated_job AS (
|
|
563
574
|
UPDATE ${tableName}
|
|
564
|
-
SET context = CASE
|
|
565
|
-
WHEN context #> $2::text[] IS NULL THEN
|
|
575
|
+
SET context = CASE
|
|
576
|
+
WHEN context #> $2::text[] IS NULL THEN
|
|
566
577
|
jsonb_set(COALESCE(context, '{}'::jsonb), $2::text[], $3::jsonb, true)
|
|
567
578
|
ELSE context
|
|
568
579
|
END
|
|
@@ -570,22 +581,22 @@ function createJsonbOperations(context) {
|
|
|
570
581
|
RETURNING id, (context #> $2::text[])::text as new_value
|
|
571
582
|
),
|
|
572
583
|
replay_insert AS (
|
|
573
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
574
|
-
SELECT id, $4, new_value, $
|
|
584
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
585
|
+
SELECT id, $4, $5, new_value, $6
|
|
575
586
|
FROM updated_job
|
|
576
|
-
ON CONFLICT (job_id,
|
|
587
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
577
588
|
SET value = EXCLUDED.value
|
|
578
589
|
RETURNING 1
|
|
579
590
|
)
|
|
580
591
|
SELECT new_value FROM updated_job
|
|
581
592
|
`;
|
|
582
|
-
params.push(key, pathParts, JSON.stringify(value),
|
|
593
|
+
params.push(key, pathParts, JSON.stringify(value), replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
583
594
|
}
|
|
584
595
|
else {
|
|
585
596
|
sql = `
|
|
586
597
|
UPDATE ${tableName}
|
|
587
|
-
SET context = CASE
|
|
588
|
-
WHEN context #> $2::text[] IS NULL THEN
|
|
598
|
+
SET context = CASE
|
|
599
|
+
WHEN context #> $2::text[] IS NULL THEN
|
|
589
600
|
jsonb_set(COALESCE(context, '{}'::jsonb), $2::text[], $3::jsonb, true)
|
|
590
601
|
ELSE context
|
|
591
602
|
END
|
|
@@ -601,27 +612,29 @@ function createJsonbOperations(context) {
|
|
|
601
612
|
const getField = Object.keys(fields).find((k) => k.startsWith('@context:get:'));
|
|
602
613
|
const pathKey = getField.replace('@context:get:', '');
|
|
603
614
|
const pathParts = JSON.parse(fields[getField]);
|
|
615
|
+
const { symbol: getSym, dimension: getDim } = (0, utils_1.splitField)(getField);
|
|
604
616
|
const params = [];
|
|
605
617
|
// Extract the specific path and store it as a temporary field
|
|
606
618
|
const sql = `
|
|
607
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
608
|
-
SELECT
|
|
619
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
620
|
+
SELECT
|
|
609
621
|
job.id,
|
|
610
622
|
$2,
|
|
611
|
-
|
|
612
|
-
$4
|
|
623
|
+
$3,
|
|
624
|
+
COALESCE((job.context #> $4::text[])::text, 'null'),
|
|
625
|
+
$5
|
|
613
626
|
FROM (
|
|
614
627
|
SELECT id, context FROM ${tableName} WHERE key = $1 AND is_live
|
|
615
628
|
) AS job
|
|
616
|
-
ON CONFLICT (job_id,
|
|
629
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
617
630
|
SET value = COALESCE((
|
|
618
|
-
SELECT context #> $
|
|
619
|
-
FROM ${tableName}
|
|
631
|
+
SELECT context #> $4::text[]
|
|
632
|
+
FROM ${tableName}
|
|
620
633
|
WHERE key = $1 AND is_live
|
|
621
634
|
)::text, 'null')
|
|
622
635
|
RETURNING 1 as count
|
|
623
636
|
`;
|
|
624
|
-
params.push(key,
|
|
637
|
+
params.push(key, getSym, getDim, pathParts, (0, utils_1.deriveType)(getField));
|
|
625
638
|
return { sql, params };
|
|
626
639
|
}
|
|
627
640
|
function handleContextGet(key, fields, options) {
|
|
@@ -633,6 +646,7 @@ function createJsonbOperations(context) {
|
|
|
633
646
|
if (path === '') {
|
|
634
647
|
// Get entire context
|
|
635
648
|
if (replayId) {
|
|
649
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
636
650
|
sql = `
|
|
637
651
|
WITH job_data AS (
|
|
638
652
|
SELECT id, context::text as context_value
|
|
@@ -640,17 +654,17 @@ function createJsonbOperations(context) {
|
|
|
640
654
|
WHERE key = $1 AND is_live
|
|
641
655
|
),
|
|
642
656
|
replay_insert AS (
|
|
643
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
644
|
-
SELECT id, $2, context_value, $
|
|
657
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
658
|
+
SELECT id, $2, $3, context_value, $4
|
|
645
659
|
FROM job_data
|
|
646
660
|
WHERE id IS NOT NULL
|
|
647
|
-
ON CONFLICT (job_id,
|
|
661
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
648
662
|
SET value = EXCLUDED.value
|
|
649
663
|
RETURNING 1
|
|
650
664
|
)
|
|
651
665
|
SELECT context_value as new_value FROM job_data
|
|
652
666
|
`;
|
|
653
|
-
params.push(key,
|
|
667
|
+
params.push(key, replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
654
668
|
}
|
|
655
669
|
else {
|
|
656
670
|
sql = `
|
|
@@ -665,6 +679,7 @@ function createJsonbOperations(context) {
|
|
|
665
679
|
// Get specific path
|
|
666
680
|
const pathParts = path.split('.');
|
|
667
681
|
if (replayId) {
|
|
682
|
+
const { symbol: replaySym, dimension: replayDim } = (0, utils_1.splitField)(replayId);
|
|
668
683
|
sql = `
|
|
669
684
|
WITH job_data AS (
|
|
670
685
|
SELECT id, COALESCE((context #> $2::text[])::text, 'null') as path_value
|
|
@@ -672,17 +687,17 @@ function createJsonbOperations(context) {
|
|
|
672
687
|
WHERE key = $1 AND is_live
|
|
673
688
|
),
|
|
674
689
|
replay_insert AS (
|
|
675
|
-
INSERT INTO ${tableName}_attributes (job_id,
|
|
676
|
-
SELECT id, $3, path_value, $
|
|
690
|
+
INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
|
|
691
|
+
SELECT id, $3, $4, path_value, $5
|
|
677
692
|
FROM job_data
|
|
678
693
|
WHERE id IS NOT NULL
|
|
679
|
-
ON CONFLICT (job_id,
|
|
694
|
+
ON CONFLICT (job_id, symbol, dimension) DO UPDATE
|
|
680
695
|
SET value = EXCLUDED.value
|
|
681
696
|
RETURNING 1
|
|
682
697
|
)
|
|
683
698
|
SELECT path_value as new_value FROM job_data
|
|
684
699
|
`;
|
|
685
|
-
params.push(key, pathParts,
|
|
700
|
+
params.push(key, pathParts, replaySym, replayDim, (0, utils_1.deriveType)(replayId));
|
|
686
701
|
}
|
|
687
702
|
else {
|
|
688
703
|
sql = `
|