@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.
Files changed (194) hide show
  1. package/README.md +18 -22
  2. package/build/modules/enums.d.ts +60 -5
  3. package/build/modules/enums.js +62 -7
  4. package/build/modules/errors.d.ts +15 -3
  5. package/build/modules/errors.js +17 -2
  6. package/build/package.json +6 -1
  7. package/build/services/activities/activity/context.d.ts +22 -0
  8. package/build/services/activities/activity/context.js +76 -0
  9. package/build/services/activities/activity/index.d.ts +116 -0
  10. package/build/services/activities/activity/index.js +299 -0
  11. package/build/services/activities/activity/mapping.d.ts +12 -0
  12. package/build/services/activities/activity/mapping.js +63 -0
  13. package/build/services/activities/activity/process.d.ts +28 -0
  14. package/build/services/activities/activity/process.js +100 -0
  15. package/build/services/activities/activity/protocol.d.ts +39 -0
  16. package/build/services/activities/activity/protocol.js +151 -0
  17. package/build/services/activities/activity/state.d.ts +40 -0
  18. package/build/services/activities/activity/state.js +143 -0
  19. package/build/services/activities/activity/transition.d.ts +23 -0
  20. package/build/services/activities/activity/transition.js +71 -0
  21. package/build/services/activities/activity/verify.d.ts +22 -0
  22. package/build/services/activities/activity/verify.js +85 -0
  23. package/build/services/activities/await.d.ts +1 -4
  24. package/build/services/activities/await.js +2 -36
  25. package/build/services/activities/cycle.d.ts +1 -11
  26. package/build/services/activities/cycle.js +3 -46
  27. package/build/services/activities/hook.d.ts +2 -11
  28. package/build/services/activities/hook.js +30 -50
  29. package/build/services/activities/interrupt.d.ts +2 -4
  30. package/build/services/activities/interrupt.js +4 -38
  31. package/build/services/activities/signal.d.ts +1 -11
  32. package/build/services/activities/signal.js +3 -48
  33. package/build/services/activities/trigger.d.ts +1 -3
  34. package/build/services/activities/trigger.js +0 -3
  35. package/build/services/activities/worker.d.ts +3 -6
  36. package/build/services/activities/worker.js +4 -40
  37. package/build/services/connector/factory.d.ts +6 -0
  38. package/build/services/connector/factory.js +24 -0
  39. package/build/services/durable/activity.d.ts +1 -1
  40. package/build/services/durable/activity.js +2 -2
  41. package/build/services/durable/client.d.ts +24 -29
  42. package/build/services/durable/client.js +24 -29
  43. package/build/services/durable/connection.d.ts +13 -7
  44. package/build/services/durable/connection.js +13 -7
  45. package/build/services/durable/handle.d.ts +58 -40
  46. package/build/services/durable/handle.js +60 -40
  47. package/build/services/durable/index.d.ts +148 -286
  48. package/build/services/durable/index.js +157 -292
  49. package/build/services/durable/interceptor.d.ts +43 -33
  50. package/build/services/durable/interceptor.js +59 -39
  51. package/build/services/durable/schemas/factory.d.ts +1 -1
  52. package/build/services/durable/schemas/factory.js +168 -38
  53. package/build/services/durable/telemetry.d.ts +80 -0
  54. package/build/services/durable/telemetry.js +137 -0
  55. package/build/services/durable/worker.d.ts +100 -21
  56. package/build/services/durable/worker.js +304 -63
  57. package/build/services/durable/workflow/all.d.ts +1 -1
  58. package/build/services/durable/workflow/all.js +1 -1
  59. package/build/services/durable/workflow/cancellationScope.d.ts +104 -0
  60. package/build/services/durable/workflow/cancellationScope.js +139 -0
  61. package/build/services/durable/workflow/common.d.ts +5 -4
  62. package/build/services/durable/workflow/common.js +6 -1
  63. package/build/services/durable/workflow/{waitFor.d.ts → condition.d.ts} +9 -8
  64. package/build/services/durable/workflow/{waitFor.js → condition.js} +44 -11
  65. package/build/services/durable/workflow/continueAsNew.d.ts +65 -0
  66. package/build/services/durable/workflow/continueAsNew.js +92 -0
  67. package/build/services/durable/workflow/didRun.d.ts +1 -1
  68. package/build/services/durable/workflow/didRun.js +3 -3
  69. package/build/services/durable/workflow/enrich.d.ts +5 -0
  70. package/build/services/durable/workflow/enrich.js +5 -0
  71. package/build/services/durable/workflow/entityMethods.d.ts +7 -0
  72. package/build/services/durable/workflow/entityMethods.js +7 -0
  73. package/build/services/durable/workflow/execHook.js +3 -3
  74. package/build/services/durable/workflow/execHookBatch.js +2 -2
  75. package/build/services/durable/workflow/{execChild.d.ts → executeChild.d.ts} +4 -40
  76. package/build/services/durable/workflow/{execChild.js → executeChild.js} +36 -45
  77. package/build/services/durable/workflow/hook.d.ts +1 -1
  78. package/build/services/durable/workflow/hook.js +4 -3
  79. package/build/services/durable/workflow/index.d.ts +45 -50
  80. package/build/services/durable/workflow/index.js +46 -51
  81. package/build/services/durable/workflow/interruption.d.ts +7 -6
  82. package/build/services/durable/workflow/interruption.js +11 -7
  83. package/build/services/durable/workflow/patched.d.ts +72 -0
  84. package/build/services/durable/workflow/patched.js +110 -0
  85. package/build/services/durable/workflow/proxyActivities.d.ts +7 -7
  86. package/build/services/durable/workflow/proxyActivities.js +50 -15
  87. package/build/services/durable/workflow/searchMethods.d.ts +7 -0
  88. package/build/services/durable/workflow/searchMethods.js +7 -0
  89. package/build/services/durable/workflow/signal.d.ts +4 -4
  90. package/build/services/durable/workflow/signal.js +4 -4
  91. package/build/services/durable/workflow/{sleepFor.d.ts → sleep.d.ts} +7 -7
  92. package/build/services/durable/workflow/{sleepFor.js → sleep.js} +39 -10
  93. package/build/services/durable/workflow/terminate.d.ts +55 -0
  94. package/build/services/durable/workflow/{interrupt.js → terminate.js} +21 -21
  95. package/build/services/durable/workflow/trace.js +2 -2
  96. package/build/services/durable/workflow/uuid4.d.ts +14 -0
  97. package/build/services/durable/workflow/uuid4.js +39 -0
  98. package/build/services/durable/workflow/{context.d.ts → workflowInfo.d.ts} +5 -5
  99. package/build/services/durable/workflow/{context.js → workflowInfo.js} +7 -7
  100. package/build/services/engine/compiler.d.ts +19 -0
  101. package/build/services/engine/compiler.js +20 -0
  102. package/build/services/engine/completion.d.ts +46 -0
  103. package/build/services/engine/completion.js +145 -0
  104. package/build/services/engine/dispatch.d.ts +24 -0
  105. package/build/services/engine/dispatch.js +98 -0
  106. package/build/services/engine/index.d.ts +49 -81
  107. package/build/services/engine/index.js +175 -573
  108. package/build/services/engine/init.d.ts +42 -0
  109. package/build/services/engine/init.js +74 -0
  110. package/build/services/engine/pubsub.d.ts +50 -0
  111. package/build/services/engine/pubsub.js +118 -0
  112. package/build/services/engine/reporting.d.ts +20 -0
  113. package/build/services/engine/reporting.js +38 -0
  114. package/build/services/engine/schema.d.ts +23 -0
  115. package/build/services/engine/schema.js +62 -0
  116. package/build/services/engine/signal.d.ts +57 -0
  117. package/build/services/engine/signal.js +117 -0
  118. package/build/services/engine/state.d.ts +35 -0
  119. package/build/services/engine/state.js +61 -0
  120. package/build/services/engine/version.d.ts +31 -0
  121. package/build/services/engine/version.js +73 -0
  122. package/build/services/hotmesh/deployment.d.ts +21 -0
  123. package/build/services/hotmesh/deployment.js +25 -0
  124. package/build/services/hotmesh/index.d.ts +141 -532
  125. package/build/services/hotmesh/index.js +222 -673
  126. package/build/services/hotmesh/init.d.ts +42 -0
  127. package/build/services/hotmesh/init.js +93 -0
  128. package/build/services/hotmesh/jobs.d.ts +67 -0
  129. package/build/services/hotmesh/jobs.js +99 -0
  130. package/build/services/hotmesh/pubsub.d.ts +38 -0
  131. package/build/services/hotmesh/pubsub.js +54 -0
  132. package/build/services/hotmesh/quorum.d.ts +30 -0
  133. package/build/services/hotmesh/quorum.js +62 -0
  134. package/build/services/hotmesh/validation.d.ts +6 -0
  135. package/build/services/hotmesh/validation.js +28 -0
  136. package/build/services/quorum/index.js +1 -0
  137. package/build/services/router/consumption/index.d.ts +11 -5
  138. package/build/services/router/consumption/index.js +24 -17
  139. package/build/services/router/error-handling/index.d.ts +2 -2
  140. package/build/services/router/error-handling/index.js +14 -14
  141. package/build/services/router/index.d.ts +1 -1
  142. package/build/services/router/index.js +2 -2
  143. package/build/services/serializer/index.d.ts +22 -0
  144. package/build/services/serializer/index.js +39 -1
  145. package/build/services/store/index.d.ts +1 -0
  146. package/build/services/store/providers/postgres/exporter-sql.d.ts +2 -2
  147. package/build/services/store/providers/postgres/exporter-sql.js +4 -4
  148. package/build/services/store/providers/postgres/kvtables.js +7 -6
  149. package/build/services/store/providers/postgres/kvtypes/hash/basic.js +67 -52
  150. package/build/services/store/providers/postgres/kvtypes/hash/jsonb.js +87 -72
  151. package/build/services/store/providers/postgres/kvtypes/hash/udata.js +106 -79
  152. package/build/services/store/providers/postgres/kvtypes/hash/utils.d.ts +16 -0
  153. package/build/services/store/providers/postgres/kvtypes/hash/utils.js +29 -16
  154. package/build/services/store/providers/postgres/postgres.d.ts +1 -0
  155. package/build/services/store/providers/postgres/postgres.js +14 -4
  156. package/build/services/stream/factory.d.ts +3 -1
  157. package/build/services/stream/factory.js +2 -2
  158. package/build/services/stream/index.d.ts +1 -0
  159. package/build/services/stream/providers/nats/nats.d.ts +1 -0
  160. package/build/services/stream/providers/nats/nats.js +1 -0
  161. package/build/services/stream/providers/postgres/credentials.d.ts +56 -0
  162. package/build/services/stream/providers/postgres/credentials.js +129 -0
  163. package/build/services/stream/providers/postgres/kvtables.js +18 -0
  164. package/build/services/stream/providers/postgres/messages.js +7 -7
  165. package/build/services/stream/providers/postgres/notifications.js +16 -2
  166. package/build/services/stream/providers/postgres/postgres.d.ts +7 -0
  167. package/build/services/stream/providers/postgres/postgres.js +35 -4
  168. package/build/services/stream/providers/postgres/procedures.d.ts +21 -0
  169. package/build/services/stream/providers/postgres/procedures.js +213 -0
  170. package/build/services/stream/providers/postgres/secured.d.ts +34 -0
  171. package/build/services/stream/providers/postgres/secured.js +146 -0
  172. package/build/services/stream/providers/postgres/stats.d.ts +1 -0
  173. package/build/services/stream/providers/postgres/stats.js +1 -0
  174. package/build/services/stream/registry.d.ts +1 -1
  175. package/build/services/stream/registry.js +5 -2
  176. package/build/services/telemetry/index.d.ts +10 -1
  177. package/build/services/telemetry/index.js +40 -7
  178. package/build/services/worker/credentials.d.ts +51 -0
  179. package/build/services/worker/credentials.js +87 -0
  180. package/build/services/worker/index.d.ts +2 -2
  181. package/build/services/worker/index.js +7 -6
  182. package/build/types/codec.d.ts +84 -0
  183. package/build/types/codec.js +2 -0
  184. package/build/types/durable.d.ts +104 -28
  185. package/build/types/error.d.ts +10 -1
  186. package/build/types/hotmesh.d.ts +67 -4
  187. package/build/types/index.d.ts +2 -1
  188. package/build/types/provider.d.ts +2 -2
  189. package/build/types/quorum.d.ts +35 -1
  190. package/build/types/stream.d.ts +12 -6
  191. package/package.json +6 -1
  192. package/build/services/activities/activity.d.ts +0 -192
  193. package/build/services/activities/activity.js +0 -786
  194. package/build/services/durable/workflow/interrupt.d.ts +0 -55
@@ -306,19 +306,21 @@ function _hset(context, key, fields, options) {
306
306
  const schemaName = context.safeName(context.appId);
307
307
  const conflictAction = options?.nx
308
308
  ? 'ON CONFLICT DO NOTHING'
309
- : `ON CONFLICT (job_id, field) DO UPDATE SET value = EXCLUDED.value`;
309
+ : `ON CONFLICT (job_id, symbol, dimension) DO UPDATE SET value = EXCLUDED.value`;
310
310
  const placeholders = fieldEntries
311
311
  .map(([field, value], index) => {
312
- const baseIndex = index * 3 + 2; // Adjusted baseIndex
313
- params.push(field, value, (0, utils_1.deriveType)(field));
314
- return `($${baseIndex}, $${baseIndex + 1}, $${baseIndex + 2}::${schemaName}.type_enum)`;
312
+ const baseIndex = index * 4 + 2;
313
+ const { symbol, dimension } = (0, utils_1.splitField)(field);
314
+ params.push(symbol, dimension, value, (0, utils_1.deriveType)(field));
315
+ return `($${baseIndex}, $${baseIndex + 1}, $${baseIndex + 2}, $${baseIndex + 3}::${schemaName}.type_enum)`;
315
316
  })
316
317
  .join(', ');
317
318
  sql = `
318
- INSERT INTO ${targetTable} (job_id, field, value, type)
319
- SELECT
319
+ INSERT INTO ${targetTable} (job_id, symbol, dimension, value, type)
320
+ SELECT
320
321
  job.id,
321
- vals.field,
322
+ vals.symbol,
323
+ vals.dimension,
322
324
  vals.value,
323
325
  vals.type
324
326
  FROM (
@@ -326,7 +328,7 @@ function _hset(context, key, fields, options) {
326
328
  ) AS job
327
329
  CROSS JOIN (
328
330
  VALUES ${placeholders}
329
- ) AS vals(field, value, type)
331
+ ) AS vals(symbol, dimension, value, type)
330
332
  ${conflictAction}
331
333
  RETURNING 1 as count
332
334
  `;
@@ -379,6 +381,7 @@ function _hget(context, key, field) {
379
381
  }
380
382
  else if (isJobsTableResult) {
381
383
  // Fetch a specific field from the attributes table for a job
384
+ const { symbol, dimension } = (0, utils_1.splitField)(field);
382
385
  const sql = `
383
386
  SELECT value
384
387
  FROM ${tableName}_attributes
@@ -386,9 +389,9 @@ function _hget(context, key, field) {
386
389
  SELECT id FROM ${tableName}
387
390
  WHERE key = $1 AND is_live
388
391
  )
389
- AND field = $2
392
+ AND symbol = $2 AND dimension = $3
390
393
  `;
391
- return { sql, params: [key, field] };
394
+ return { sql, params: [key, symbol, dimension] };
392
395
  }
393
396
  else {
394
397
  // Non-jobs tables
@@ -406,9 +409,9 @@ function _hdel(context, key, fields) {
406
409
  const tableName = context.tableForKey(key, 'hash');
407
410
  const isJobsTableResult = (0, utils_1.isJobsTable)(tableName);
408
411
  const targetTable = isJobsTableResult ? `${tableName}_attributes` : tableName;
409
- const fieldPlaceholders = fields.map((_, i) => `$${i + 2}`).join(', ');
410
- const params = [key, ...fields];
411
412
  if (isJobsTableResult) {
413
+ const symbols = fields.map((f) => (0, utils_1.splitField)(f).symbol);
414
+ const dimensions = fields.map((f) => (0, utils_1.splitField)(f).dimension);
412
415
  const sql = `
413
416
  WITH valid_job AS (
414
417
  SELECT id
@@ -417,14 +420,16 @@ function _hdel(context, key, fields) {
417
420
  ),
418
421
  deleted AS (
419
422
  DELETE FROM ${targetTable}
420
- WHERE job_id IN (SELECT id FROM valid_job) AND field IN (${fieldPlaceholders})
423
+ WHERE job_id IN (SELECT id FROM valid_job)
424
+ AND (symbol, dimension) IN (SELECT unnest($2::text[]), unnest($3::text[]))
421
425
  RETURNING 1
422
426
  )
423
427
  SELECT COUNT(*) as count FROM deleted
424
428
  `;
425
- return { sql, params };
429
+ return { sql, params: [key, symbols, dimensions] };
426
430
  }
427
431
  else {
432
+ const fieldPlaceholders = fields.map((_, i) => `$${i + 2}`).join(', ');
428
433
  const sql = `
429
434
  WITH deleted AS (
430
435
  DELETE FROM ${targetTable}
@@ -433,7 +438,7 @@ function _hdel(context, key, fields) {
433
438
  )
434
439
  SELECT COUNT(*) as count FROM deleted
435
440
  `;
436
- return { sql, params };
441
+ return { sql, params: [key, ...fields] };
437
442
  }
438
443
  }
439
444
  exports._hdel = _hdel;
@@ -441,43 +446,45 @@ function _hmget(context, key, fields) {
441
446
  const tableName = context.tableForKey(key, 'hash');
442
447
  const isJobsTableResult = (0, utils_1.isJobsTable)(tableName);
443
448
  if (isJobsTableResult) {
449
+ const symbols = fields.map((f) => (0, utils_1.splitField)(f).symbol);
450
+ const dimensions = fields.map((f) => (0, utils_1.splitField)(f).dimension);
444
451
  const sql = `
445
452
  WITH valid_job AS (
446
453
  SELECT id, status, context
447
454
  FROM ${tableName}
448
- WHERE key = $1
455
+ WHERE key = $1
449
456
  AND (expired_at IS NULL OR expired_at > NOW())
450
457
  LIMIT 1
451
458
  ),
452
459
  job_fields AS (
453
460
  -- Include both status and context fields from jobs table
454
- SELECT
461
+ SELECT
455
462
  'status' AS field,
456
463
  status::text AS value
457
464
  FROM valid_job
458
-
465
+
459
466
  UNION ALL
460
-
461
- SELECT
467
+
468
+ SELECT
462
469
  'context' AS field,
463
470
  context::text AS value
464
471
  FROM valid_job
465
-
472
+
466
473
  UNION ALL
467
-
474
+
468
475
  -- Get attribute fields with proper type handling
469
- SELECT
470
- a.field,
476
+ SELECT
477
+ a.symbol || a.dimension AS field,
471
478
  a.value
472
479
  FROM ${tableName}_attributes a
473
480
  JOIN valid_job j ON j.id = a.job_id
474
- WHERE a.field = ANY($2::text[])
481
+ WHERE (a.symbol, a.dimension) IN (SELECT unnest($2::text[]), unnest($3::text[]))
475
482
  )
476
483
  SELECT field, value
477
484
  FROM job_fields
478
485
  ORDER BY field
479
486
  `;
480
- return { sql, params: [key, fields] };
487
+ return { sql, params: [key, symbols, dimensions] };
481
488
  }
482
489
  else {
483
490
  // Non-job tables logic remains the same
@@ -506,15 +513,15 @@ function _hgetall(context, key) {
506
513
  SELECT 'status' AS field, status::text AS value
507
514
  FROM ${tableName}
508
515
  WHERE key = $1 AND is_live
509
-
516
+
510
517
  UNION ALL
511
-
518
+
512
519
  SELECT 'context' AS field, context::text AS value
513
520
  FROM ${tableName}
514
521
  WHERE key = $1 AND is_live
515
522
  ),
516
523
  attribute_data AS (
517
- SELECT field, value
524
+ SELECT symbol || dimension AS field, value
518
525
  FROM ${tableName}_attributes
519
526
  WHERE job_id IN (SELECT id FROM valid_job)
520
527
  )
@@ -549,23 +556,23 @@ function _hincrbyfloat(context, key, field, increment) {
549
556
  return { sql, params: [key, increment] };
550
557
  }
551
558
  else if (isJobsTableResult) {
552
- // Update the condition here
559
+ const { symbol, dimension } = (0, utils_1.splitField)(field);
553
560
  const sql = `
554
561
  WITH valid_job AS (
555
562
  SELECT id
556
563
  FROM ${tableName}
557
564
  WHERE key = $1 AND is_live
558
565
  )
559
- INSERT INTO ${tableName}_attributes (job_id, field, value, type)
560
- SELECT id, $2, ($3::double precision)::text, $4
566
+ INSERT INTO ${tableName}_attributes (job_id, symbol, dimension, value, type)
567
+ SELECT id, $2, $3, ($4::double precision)::text, $5
561
568
  FROM valid_job
562
- ON CONFLICT (job_id, field) DO UPDATE
569
+ ON CONFLICT (job_id, symbol, dimension) DO UPDATE
563
570
  SET
564
- value = ((COALESCE(${tableName}_attributes.value, '0')::double precision) + $3::double precision)::text,
571
+ value = ((COALESCE(${tableName}_attributes.value, '0')::double precision) + $4::double precision)::text,
565
572
  type = EXCLUDED.type
566
573
  RETURNING value;
567
574
  `;
568
- return { sql, params: [key, field, increment, (0, utils_1.deriveType)(field)] };
575
+ return { sql, params: [key, symbol, dimension, increment, (0, utils_1.deriveType)(field)] };
569
576
  }
570
577
  else {
571
578
  const sql = `
@@ -600,26 +607,29 @@ guidField) {
600
607
  throw new Error(`_collateLeg2Entry requires a jobs table key; got table ${jobsTableName}`);
601
608
  }
602
609
  const attrsTable = `${jobsTableName}_attributes`;
610
+ const { symbol: actSym, dimension: actDim } = (0, utils_1.splitField)(activityField);
611
+ const { symbol: guidSym, dimension: guidDim } = (0, utils_1.splitField)(guidField);
603
612
  const sql = `
604
613
  WITH activity_update AS (
605
- INSERT INTO ${attrsTable} (job_id, field, value, type)
606
- SELECT id, $2, ($3::double precision)::text, $4
614
+ INSERT INTO ${attrsTable} (job_id, symbol, dimension, value, type)
615
+ SELECT id, $2, $3, ($4::double precision)::text, $5
607
616
  FROM ${jobsTableName}
608
617
  WHERE key = $1 AND is_live
609
- ON CONFLICT (job_id, field) DO UPDATE
610
- SET value = ((COALESCE(${attrsTable}.value, '0')::double precision) + $3::double precision)::text,
618
+ ON CONFLICT (job_id, symbol, dimension) DO UPDATE
619
+ SET value = ((COALESCE(${attrsTable}.value, '0')::double precision) + $4::double precision)::text,
611
620
  type = EXCLUDED.type
612
621
  RETURNING job_id, value::double precision AS activity_value
613
622
  ),
614
623
  guid_upsert AS (
615
- INSERT INTO ${attrsTable} (job_id, field, value, type)
624
+ INSERT INTO ${attrsTable} (job_id, symbol, dimension, value, type)
616
625
  SELECT
617
626
  job_id,
618
- $5,
627
+ $6,
628
+ $7,
619
629
  ((activity_value::bigint) % 100000000)::text,
620
- $6
630
+ $8
621
631
  FROM activity_update
622
- ON CONFLICT (job_id, field) DO UPDATE
632
+ ON CONFLICT (job_id, symbol, dimension) DO UPDATE
623
633
  SET value = ${attrsTable}.value
624
634
  RETURNING value::double precision AS guid_value
625
635
  )
@@ -631,11 +641,13 @@ guidField) {
631
641
  sql,
632
642
  params: [
633
643
  key,
634
- activityField,
644
+ actSym,
645
+ actDim,
635
646
  increment,
636
647
  (0, utils_1.deriveType)(activityField),
637
- guidField,
638
- (0, utils_1.deriveType)(guidField), // $6
648
+ guidSym,
649
+ guidDim,
650
+ (0, utils_1.deriveType)(guidField), // $8
639
651
  ],
640
652
  };
641
653
  }
@@ -660,6 +672,7 @@ statusDelta, threshold, guidField, guidWeight) {
660
672
  if (!(0, utils_1.isJobsTable)(jobsTableName)) {
661
673
  throw new Error(`_setStatusAndCollateGuid requires a jobs table key; got table ${jobsTableName}`);
662
674
  }
675
+ const { symbol: guidSym, dimension: guidDim } = (0, utils_1.splitField)(guidField);
663
676
  const sql = `
664
677
  WITH status_update AS (
665
678
  UPDATE ${jobsTableName}
@@ -674,14 +687,15 @@ statusDelta, threshold, guidField, guidWeight) {
674
687
  CASE WHEN status_after = $3 THEN ($4::double precision) ELSE 0::double precision END AS guid_increment
675
688
  FROM status_update
676
689
  )
677
- INSERT INTO ${jobsTableName}_attributes (job_id, field, value, type)
690
+ INSERT INTO ${jobsTableName}_attributes (job_id, symbol, dimension, value, type)
678
691
  SELECT
679
692
  job_id,
680
- $5 AS field,
693
+ $5,
694
+ $6,
681
695
  (guid_increment)::text AS value,
682
- $6
696
+ $7
683
697
  FROM hit
684
- ON CONFLICT (job_id, field) DO UPDATE
698
+ ON CONFLICT (job_id, symbol, dimension) DO UPDATE
685
699
  SET
686
700
  value = ((COALESCE(${jobsTableName}_attributes.value, '0')::double precision) + EXCLUDED.value::double precision)::text,
687
701
  type = EXCLUDED.type
@@ -694,8 +708,9 @@ statusDelta, threshold, guidField, guidWeight) {
694
708
  statusDelta,
695
709
  threshold,
696
710
  guidWeight,
697
- guidField,
698
- (0, utils_1.deriveType)(guidField), // $6
711
+ guidSym,
712
+ guidDim,
713
+ (0, utils_1.deriveType)(guidField), // $7
699
714
  ],
700
715
  };
701
716
  }