@hotmeshio/hotmesh 0.31.1 → 0.31.3

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.31.1",
3
+ "version": "0.31.3",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -1,10 +1,11 @@
1
- import { AccumulateConfig, BatchFilledEntry } from '../../types/hmsh_escalations';
1
+ import { AccumulateConfig, BatchFilledEntry, FlagBatchItemParams } from '../../types/hmsh_escalations';
2
2
  /**
3
3
  * Folds a `batch` declaration into the escalation's storage shape:
4
4
  * queryable facets in `metadata` (`batch_pending`, `batch_count`,
5
5
  * `batch_keys`) and the payload accumulator in `envelope`
6
6
  * (`batch_items: {}`). `partialOnTimeout` is stored beside the items so
7
- * the expiry statement delivers the filled items instead of `false`.
7
+ * the expiry statement delivers the filled items instead of `false`;
8
+ * `wakeOnFlag` is stored the same way so a flag ends the wait.
8
9
  * `filled` entries start satisfied: they are left out of `batch_pending`
9
10
  * and written into `batch_items`, `batch_filled_at`, and (when an entry
10
11
  * names an actor) `batch_filled_by`. Pure
@@ -15,8 +16,16 @@ import { AccumulateConfig, BatchFilledEntry } from '../../types/hmsh_escalations
15
16
  export declare function foldBatchConfig<T extends {
16
17
  batch?: string[];
17
18
  partialOnTimeout?: boolean;
19
+ wakeOnFlag?: boolean;
18
20
  filled?: Record<string, BatchFilledEntry>;
19
21
  accumulate?: AccumulateConfig;
20
22
  metadata?: Record<string, unknown>;
21
23
  envelope?: Record<string, unknown>;
22
- }>(config: T): Omit<T, 'batch' | 'partialOnTimeout' | 'filled'>;
24
+ }>(config: T): Omit<T, 'batch' | 'partialOnTimeout' | 'wakeOnFlag' | 'filled'>;
25
+ /**
26
+ * Validates a `flagBatchItem()` request before any read or write: exactly
27
+ * one row selector, a non-empty key and label within their limits, object
28
+ * `payload` and `metadata`, a non-empty `actor`, and no reserved batch key
29
+ * in the metadata patch. Throws on the first violation.
30
+ */
31
+ export declare function assertBatchFlagParams(params: FlagBatchItemParams): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.foldBatchConfig = void 0;
3
+ exports.assertBatchFlagParams = exports.foldBatchConfig = void 0;
4
4
  const hmsh_escalations_1 = require("../../types/hmsh_escalations");
5
5
  const RESERVED_METADATA_KEYS = new Set([
6
6
  hmsh_escalations_1.ESCALATION_BATCH_PENDING_KEY,
@@ -12,6 +12,8 @@ const RESERVED_ENVELOPE_KEYS = new Set([
12
12
  hmsh_escalations_1.ESCALATION_BATCH_FILLED_AT_KEY,
13
13
  hmsh_escalations_1.ESCALATION_BATCH_FILLED_BY_KEY,
14
14
  hmsh_escalations_1.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY,
15
+ hmsh_escalations_1.ESCALATION_BATCH_FLAGS_KEY,
16
+ hmsh_escalations_1.ESCALATION_BATCH_WAKE_ON_FLAG_KEY,
15
17
  ]);
16
18
  /**
17
19
  * Validates `filled` against the declared keys and splits it into the
@@ -65,7 +67,8 @@ function foldFilledEntries(batch, filled) {
65
67
  * queryable facets in `metadata` (`batch_pending`, `batch_count`,
66
68
  * `batch_keys`) and the payload accumulator in `envelope`
67
69
  * (`batch_items: {}`). `partialOnTimeout` is stored beside the items so
68
- * the expiry statement delivers the filled items instead of `false`.
70
+ * the expiry statement delivers the filled items instead of `false`;
71
+ * `wakeOnFlag` is stored the same way so a flag ends the wait.
69
72
  * `filled` entries start satisfied: they are left out of `batch_pending`
70
73
  * and written into `batch_items`, `batch_filled_at`, and (when an entry
71
74
  * names an actor) `batch_filled_by`. Pure
@@ -74,11 +77,14 @@ function foldFilledEntries(batch, filled) {
74
77
  * durable write.
75
78
  */
76
79
  function foldBatchConfig(config) {
77
- const { batch, partialOnTimeout, filled, ...rest } = config;
80
+ const { batch, partialOnTimeout, wakeOnFlag, filled, ...rest } = config;
78
81
  if (!batch) {
79
82
  if (partialOnTimeout !== undefined) {
80
83
  throw new Error('partialOnTimeout requires a batch declaration');
81
84
  }
85
+ if (wakeOnFlag !== undefined) {
86
+ throw new Error('wakeOnFlag requires a batch declaration');
87
+ }
82
88
  if (filled !== undefined) {
83
89
  throw new Error('filled requires a batch declaration');
84
90
  }
@@ -90,6 +96,9 @@ function foldBatchConfig(config) {
90
96
  if (partialOnTimeout !== undefined && typeof partialOnTimeout !== 'boolean') {
91
97
  throw new Error('partialOnTimeout must be a boolean');
92
98
  }
99
+ if (wakeOnFlag !== undefined && typeof wakeOnFlag !== 'boolean') {
100
+ throw new Error('wakeOnFlag must be a boolean');
101
+ }
93
102
  if (!Array.isArray(batch) || batch.length === 0) {
94
103
  throw new Error('batch must be a non-empty array of item keys');
95
104
  }
@@ -135,7 +144,52 @@ function foldBatchConfig(config) {
135
144
  ...(partialOnTimeout
136
145
  ? { [hmsh_escalations_1.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY]: true }
137
146
  : {}),
147
+ ...(wakeOnFlag ? { [hmsh_escalations_1.ESCALATION_BATCH_WAKE_ON_FLAG_KEY]: true } : {}),
138
148
  },
139
149
  };
140
150
  }
141
151
  exports.foldBatchConfig = foldBatchConfig;
152
+ /**
153
+ * Validates a `flagBatchItem()` request before any read or write: exactly
154
+ * one row selector, a non-empty key and label within their limits, object
155
+ * `payload` and `metadata`, a non-empty `actor`, and no reserved batch key
156
+ * in the metadata patch. Throws on the first violation.
157
+ */
158
+ function assertBatchFlagParams(params) {
159
+ const { id, signalKey, itemKey, label, payload, actor, metadata } = params;
160
+ if ((id ? 1 : 0) + (signalKey ? 1 : 0) !== 1) {
161
+ throw new Error('flagBatchItem requires exactly one of `id` or `signalKey`');
162
+ }
163
+ if (typeof itemKey !== 'string' || itemKey.length === 0) {
164
+ throw new Error('itemKey must be a non-empty string');
165
+ }
166
+ if (itemKey.length > hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH) {
167
+ throw new Error(`itemKey must be at most ${hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH} characters`);
168
+ }
169
+ if (typeof label !== 'string' || label.length === 0) {
170
+ throw new Error('label must be a non-empty string');
171
+ }
172
+ if (label.length > hmsh_escalations_1.ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH) {
173
+ throw new Error(`label must be at most ${hmsh_escalations_1.ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH} characters`);
174
+ }
175
+ if (payload !== undefined && !isPlainObject(payload)) {
176
+ throw new Error('payload must be an object');
177
+ }
178
+ if (actor !== undefined &&
179
+ (typeof actor !== 'string' || actor.length === 0)) {
180
+ throw new Error('actor must be a non-empty string');
181
+ }
182
+ if (metadata !== undefined) {
183
+ if (!isPlainObject(metadata))
184
+ throw new Error('metadata must be an object');
185
+ for (const reserved of RESERVED_METADATA_KEYS) {
186
+ if (reserved in metadata) {
187
+ throw new Error(`metadata key '${reserved}' is reserved for batch state`);
188
+ }
189
+ }
190
+ }
191
+ }
192
+ exports.assertBatchFlagParams = assertBatchFlagParams;
193
+ function isPlainObject(value) {
194
+ return !!value && typeof value === 'object' && !Array.isArray(value);
195
+ }
@@ -1,7 +1,7 @@
1
1
  import { HotMesh } from '../hotmesh';
2
2
  import { EventsConfig } from '../../types/system_events';
3
3
  import { Connection } from '../../types/durable';
4
- import { EscalationEntry, ClaimEscalationResult, ClaimByMetadataResult, ReleaseEscalationResult, ResolveEscalationResult, CancelEscalationResult, ListEscalationsParams, StatsEscalationsParams, EscalationStats, CreateEscalationParams, UpdateEscalationParams, AppendMilestonesParams, ClaimEscalationParams, ClaimByMetadataParams, ReleaseEscalationParams, ResolveEscalationParams, ResolveByMetadataParams, EscalateToRoleParams, MigrateEscalationParams, ClaimManyParams, EscalateManyToRoleParams, UpdateManyPriorityParams, ResolveManyParams, ResolveAllOrNoneParams, ResolveAllOrNoneResult, PruneEscalationsParams, PruneEscalationsResult, ClaimManyByQueryParams, ResolveBatchItemParams, ResolveBatchItemByMetadataParams, ResolveBatchItemResult, AccumulateItemParams, AccumulateItemByMetadataParams, AccumulateItemResult, RemoveAccumulatedItemParams, RemoveAccumulatedItemByMetadataParams, RemoveAccumulatedItemResult } from '../../types/hmsh_escalations';
4
+ import { EscalationEntry, ClaimEscalationResult, ClaimByMetadataResult, ReleaseEscalationResult, ResolveEscalationResult, CancelEscalationResult, ListEscalationsParams, StatsEscalationsParams, EscalationStats, CreateEscalationParams, UpdateEscalationParams, AppendMilestonesParams, ClaimEscalationParams, ClaimByMetadataParams, ReleaseEscalationParams, ResolveEscalationParams, ResolveByMetadataParams, EscalateToRoleParams, MigrateEscalationParams, ClaimManyParams, EscalateManyToRoleParams, UpdateManyPriorityParams, ResolveManyParams, ResolveAllOrNoneParams, ResolveAllOrNoneResult, PruneEscalationsParams, PruneEscalationsResult, ClaimManyByQueryParams, ResolveBatchItemParams, ResolveBatchItemByMetadataParams, ResolveBatchItemResult, AccumulateItemParams, AccumulateItemByMetadataParams, AccumulateItemResult, RemoveAccumulatedItemParams, RemoveAccumulatedItemByMetadataParams, RemoveAccumulatedItemResult, FlagBatchItemParams, FlagBatchItemResult, UnflagBatchItemParams, UnflagBatchItemResult } from '../../types/hmsh_escalations';
5
5
  /**
6
6
  * Reserved signal-payload key carrying resolution provenance
7
7
  * (`EscalationResolution`) to the waiting workflow. The `$` prefix marks the
@@ -250,6 +250,26 @@ export declare class EscalationClientService {
250
250
  * for the fill contract.
251
251
  */
252
252
  resolveBatchItemByMetadata(params: ResolveBatchItemByMetadataParams, namespace?: string): Promise<ResolveBatchItemResult>;
253
+ /**
254
+ * Flags ONE pending key of a batch escalation (for example, `Missing`).
255
+ * One atomic statement writes `envelope.batch_flags[itemKey]` with the
256
+ * label, optional payload and actor, and the database clock, only while
257
+ * the row and the key are pending. The key stays pending: a later fill
258
+ * still lands and still counts toward completion.
259
+ *
260
+ * On a row whose wait declared `wakeOnFlag`, the same statement resolves
261
+ * the row and the waiter wakes with the items filled so far, `$flags`,
262
+ * and `$trigger: 'flag'` (outcome `completed`); the wake commits with the
263
+ * resolve, as on a completing fill. Otherwise the outcome is `flagged`
264
+ * and the wait continues. Flagging a flagged key replaces its flag.
265
+ */
266
+ flagBatchItem(params: FlagBatchItemParams, namespace?: string): Promise<FlagBatchItemResult>;
267
+ /**
268
+ * Clears ONE key's flag while the row is pending ("found it"). Only that
269
+ * key's entry is removed; items, pending keys and status are untouched.
270
+ * A key without a flag answers `not-flagged`.
271
+ */
272
+ unflagBatchItem(params: UnflagBatchItemParams, namespace?: string): Promise<UnflagBatchItemResult>;
253
273
  private _previewAccumulateRow;
254
274
  /**
255
275
  * Pre-builds one side's wake with a placeholder payload; the store
@@ -288,7 +308,8 @@ export declare class EscalationClientService {
288
308
  * Adds are claim-agnostic by default; pass `assertClaim` for the same
289
309
  * claim-lock assertion as `resolve()` on the container row. Pass
290
310
  * `metadata` to merge an outcome patch into the container's GIN-indexed
291
- * metadata in the same UPDATE (reserved accumulate keys are rejected).
311
+ * metadata in the same UPDATE, and `reciprocal.metadata` to merge one
312
+ * into the reciprocal's (reserved accumulate keys are rejected).
292
313
  * A repeated key answers `duplicate-item` without touching the row
293
314
  * unless the accumulator was declared `unique: false`, which replaces
294
315
  * the entry in place.
@@ -6,8 +6,10 @@ const utils_1 = require("../../modules/utils");
6
6
  const hotmesh_1 = require("../hotmesh");
7
7
  const types_1 = require("../../types");
8
8
  const stream_1 = require("../../types/stream");
9
+ const hmsh_escalations_1 = require("../../types/hmsh_escalations");
9
10
  const factory_1 = require("../durable/schemas/factory");
10
11
  const accumulate_1 = require("./accumulate");
12
+ const batch_1 = require("./batch");
11
13
  /**
12
14
  * Reserved signal-payload key carrying resolution provenance
13
15
  * (`EscalationResolution`) to the waiting workflow. The `$` prefix marks the
@@ -582,6 +584,67 @@ class EscalationClientService {
582
584
  const dbResult = await store.resolveEscalationBatchItemByMetadata(params, wakeCommand ?? undefined, preview ? this._batchResolutionJson(preview.id, params.resolvedBy) : null);
583
585
  return this._settleBatchItemResult(ns, dbResult, params.resolvedBy);
584
586
  }
587
+ /**
588
+ * Flags ONE pending key of a batch escalation (for example, `Missing`).
589
+ * One atomic statement writes `envelope.batch_flags[itemKey]` with the
590
+ * label, optional payload and actor, and the database clock, only while
591
+ * the row and the key are pending. The key stays pending: a later fill
592
+ * still lands and still counts toward completion.
593
+ *
594
+ * On a row whose wait declared `wakeOnFlag`, the same statement resolves
595
+ * the row and the waiter wakes with the items filled so far, `$flags`,
596
+ * and `$trigger: 'flag'` (outcome `completed`); the wake commits with the
597
+ * resolve, as on a completing fill. Otherwise the outcome is `flagged`
598
+ * and the wait continues. Flagging a flagged key replaces its flag.
599
+ */
600
+ async flagBatchItem(params, namespace) {
601
+ (0, batch_1.assertBatchFlagParams)(params);
602
+ const ns = params.namespace ?? namespace ?? factory_1.APP_ID;
603
+ const hm = await this._engine(null, ns);
604
+ const store = hm.engine.store;
605
+ //the wake is built only for a row that declared wakeOnFlag at creation;
606
+ //the declaration never changes, so the preview decides it safely
607
+ const preview = params.id
608
+ ? await store.getEscalation(params.id, params.namespace)
609
+ : await store.getEscalationBySignalKey(params.signalKey, params.namespace);
610
+ let wakeCommand = null;
611
+ if (preview?.signal_key &&
612
+ preview.envelope?.[hmsh_escalations_1.ESCALATION_BATCH_WAKE_ON_FLAG_KEY] === true) {
613
+ wakeCommand = await this._buildWakeCommand(ns, preview.topic, preview.signal_key, {});
614
+ }
615
+ const dbResult = await store.flagEscalationBatchItem(params, wakeCommand ?? undefined, preview ? this._batchResolutionJson(preview.id, params.resolvedBy) : null);
616
+ if (!dbResult.ok)
617
+ return dbResult;
618
+ if (dbResult.outcome === 'completed') {
619
+ if (dbResult.signalKey && !dbResult.wakeEnqueued) {
620
+ await this._deliverEscalationSignal(ns, dbResult.topic, {
621
+ id: dbResult.signalKey,
622
+ data: this._signalData(dbResult.entry.resolver_payload ?? {}, dbResult.entry.id, params.resolvedBy),
623
+ });
624
+ }
625
+ this._emit('resolved', dbResult.entry);
626
+ }
627
+ else {
628
+ this._emit('flagged', dbResult.entry);
629
+ }
630
+ return { ok: true, outcome: dbResult.outcome, entry: dbResult.entry };
631
+ }
632
+ /**
633
+ * Clears ONE key's flag while the row is pending ("found it"). Only that
634
+ * key's entry is removed; items, pending keys and status are untouched.
635
+ * A key without a flag answers `not-flagged`.
636
+ */
637
+ async unflagBatchItem(params, namespace) {
638
+ if (typeof params.itemKey !== 'string' || params.itemKey.length === 0) {
639
+ throw new Error('itemKey must be a non-empty string');
640
+ }
641
+ const ns = params.namespace ?? namespace ?? factory_1.APP_ID;
642
+ const hm = await this._engine(null, ns);
643
+ const result = await hm.engine.store.unflagEscalationBatchItem(params);
644
+ if (result.ok)
645
+ this._emit('unflagged', result.entry);
646
+ return result;
647
+ }
585
648
  // ─── Open accumulation ──────────────────────────────────────────────────────
586
649
  async _previewAccumulateRow(store, selector, namespace) {
587
650
  if (selector.id) {
@@ -696,7 +759,8 @@ class EscalationClientService {
696
759
  * Adds are claim-agnostic by default; pass `assertClaim` for the same
697
760
  * claim-lock assertion as `resolve()` on the container row. Pass
698
761
  * `metadata` to merge an outcome patch into the container's GIN-indexed
699
- * metadata in the same UPDATE (reserved accumulate keys are rejected).
762
+ * metadata in the same UPDATE, and `reciprocal.metadata` to merge one
763
+ * into the reciprocal's (reserved accumulate keys are rejected).
700
764
  * A repeated key answers `duplicate-item` without touching the row
701
765
  * unless the accumulator was declared `unique: false`, which replaces
702
766
  * the entry in place.
@@ -707,6 +771,7 @@ class EscalationClientService {
707
771
  }
708
772
  (0, accumulate_1.assertAccumulateItemKey)(params.itemKey);
709
773
  this._assertAccumulatePatch(params.metadata);
774
+ this._assertAccumulatePatch(params.reciprocal?.metadata);
710
775
  const ns = params.namespace ?? namespace ?? factory_1.APP_ID;
711
776
  const hm = await this._engine(null, ns);
712
777
  const store = hm.engine.store;
@@ -723,6 +788,7 @@ class EscalationClientService {
723
788
  async accumulateItemByMetadata(params, namespace) {
724
789
  (0, accumulate_1.assertAccumulateItemKey)(params.itemKey);
725
790
  this._assertAccumulatePatch(params.metadata);
791
+ this._assertAccumulatePatch(params.reciprocal?.metadata);
726
792
  const ns = params.namespace ?? namespace ?? factory_1.APP_ID;
727
793
  const hm = await this._engine(null, ns);
728
794
  const store = hm.engine.store;
@@ -2,6 +2,7 @@ import { AccumulateConfig, BatchFilledEntry } from '../../types/hmsh_escalations
2
2
  type Foldable = {
3
3
  batch?: string[];
4
4
  partialOnTimeout?: boolean;
5
+ wakeOnFlag?: boolean;
5
6
  filled?: Record<string, BatchFilledEntry>;
6
7
  accumulate?: AccumulateConfig;
7
8
  metadata?: Record<string, unknown>;
@@ -13,5 +14,5 @@ type Foldable = {
13
14
  * config through untouched. The single entry point for both the
14
15
  * `condition()` path and standalone `create()`.
15
16
  */
16
- export declare function foldEscalationConfig<T extends Foldable>(config: T): Omit<T, 'batch' | 'partialOnTimeout' | 'filled' | 'accumulate'>;
17
+ export declare function foldEscalationConfig<T extends Foldable>(config: T): Omit<T, 'batch' | 'partialOnTimeout' | 'wakeOnFlag' | 'filled' | 'accumulate'>;
17
18
  export {};
@@ -10,7 +10,7 @@ const batch_1 = require("./batch");
10
10
  * `condition()` path and standalone `create()`.
11
11
  */
12
12
  function foldEscalationConfig(config) {
13
- const { batch, partialOnTimeout, filled, accumulate, ...rest } = config;
13
+ const { batch, partialOnTimeout, wakeOnFlag, filled, accumulate, ...rest } = config;
14
14
  if (batch) {
15
15
  if (accumulate) {
16
16
  throw new Error('accumulate and batch are mutually exclusive');
@@ -19,6 +19,7 @@ function foldEscalationConfig(config) {
19
19
  ...rest,
20
20
  batch,
21
21
  partialOnTimeout,
22
+ wakeOnFlag,
22
23
  filled,
23
24
  });
24
25
  }
@@ -26,6 +27,9 @@ function foldEscalationConfig(config) {
26
27
  if (filled !== undefined) {
27
28
  throw new Error('filled applies to batch only');
28
29
  }
30
+ if (wakeOnFlag !== undefined) {
31
+ throw new Error('wakeOnFlag applies to batch only');
32
+ }
29
33
  return (0, accumulate_1.foldAccumulateConfig)({ ...rest, accumulate });
30
34
  }
31
35
  if (partialOnTimeout !== undefined) {
@@ -34,6 +38,9 @@ function foldEscalationConfig(config) {
34
38
  if (filled !== undefined) {
35
39
  throw new Error('filled requires a batch declaration');
36
40
  }
41
+ if (wakeOnFlag !== undefined) {
42
+ throw new Error('wakeOnFlag requires a batch declaration');
43
+ }
37
44
  return rest;
38
45
  }
39
46
  exports.foldEscalationConfig = foldEscalationConfig;
@@ -68,4 +68,4 @@ export { ESCALATION_RESOLUTION_KEY } from './client';
68
68
  export { foldBatchConfig } from './batch';
69
69
  export { foldAccumulateConfig, assertAccumulateItemKey } from './accumulate';
70
70
  export { foldEscalationConfig } from './fold';
71
- export { ESCALATION_BATCH_PENDING_KEY, ESCALATION_BATCH_COUNT_KEY, ESCALATION_BATCH_KEYS_KEY, ESCALATION_BATCH_ITEMS_KEY, ESCALATION_BATCH_FILLED_AT_KEY, ESCALATION_BATCH_FILLED_BY_KEY, ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY, ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH, ESCALATION_ACCUMULATE_COUNT_KEY, ESCALATION_ACCUMULATE_MAX_KEY, ESCALATION_ACCUMULATE_KEYS_KEY, ESCALATION_ACCUMULATE_ITEMS_KEY, ESCALATION_ACCUMULATE_CONFIG_KEY, ESCALATION_ACCUMULATED_KEY, ESCALATION_TRIGGER_KEY, } from '../../types/hmsh_escalations';
71
+ export { ESCALATION_BATCH_PENDING_KEY, ESCALATION_BATCH_COUNT_KEY, ESCALATION_BATCH_KEYS_KEY, ESCALATION_BATCH_ITEMS_KEY, ESCALATION_BATCH_FILLED_AT_KEY, ESCALATION_BATCH_FILLED_BY_KEY, ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY, ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH, ESCALATION_BATCH_FLAGS_KEY, ESCALATION_BATCH_WAKE_ON_FLAG_KEY, ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH, ESCALATION_FLAGS_KEY, ESCALATION_ACCUMULATE_COUNT_KEY, ESCALATION_ACCUMULATE_MAX_KEY, ESCALATION_ACCUMULATE_KEYS_KEY, ESCALATION_ACCUMULATE_ITEMS_KEY, ESCALATION_ACCUMULATE_CONFIG_KEY, ESCALATION_ACCUMULATED_KEY, ESCALATION_TRIGGER_KEY, } from '../../types/hmsh_escalations';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ESCALATION_TRIGGER_KEY = exports.ESCALATION_ACCUMULATED_KEY = exports.ESCALATION_ACCUMULATE_CONFIG_KEY = exports.ESCALATION_ACCUMULATE_ITEMS_KEY = exports.ESCALATION_ACCUMULATE_KEYS_KEY = exports.ESCALATION_ACCUMULATE_MAX_KEY = exports.ESCALATION_ACCUMULATE_COUNT_KEY = exports.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = exports.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY = exports.ESCALATION_BATCH_FILLED_BY_KEY = exports.ESCALATION_BATCH_FILLED_AT_KEY = exports.ESCALATION_BATCH_ITEMS_KEY = exports.ESCALATION_BATCH_KEYS_KEY = exports.ESCALATION_BATCH_COUNT_KEY = exports.ESCALATION_BATCH_PENDING_KEY = exports.foldEscalationConfig = exports.assertAccumulateItemKey = exports.foldAccumulateConfig = exports.foldBatchConfig = exports.ESCALATION_RESOLUTION_KEY = exports.EscalationClientService = exports.Escalations = void 0;
3
+ exports.ESCALATION_TRIGGER_KEY = exports.ESCALATION_ACCUMULATED_KEY = exports.ESCALATION_ACCUMULATE_CONFIG_KEY = exports.ESCALATION_ACCUMULATE_ITEMS_KEY = exports.ESCALATION_ACCUMULATE_KEYS_KEY = exports.ESCALATION_ACCUMULATE_MAX_KEY = exports.ESCALATION_ACCUMULATE_COUNT_KEY = exports.ESCALATION_FLAGS_KEY = exports.ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH = exports.ESCALATION_BATCH_WAKE_ON_FLAG_KEY = exports.ESCALATION_BATCH_FLAGS_KEY = exports.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = exports.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY = exports.ESCALATION_BATCH_FILLED_BY_KEY = exports.ESCALATION_BATCH_FILLED_AT_KEY = exports.ESCALATION_BATCH_ITEMS_KEY = exports.ESCALATION_BATCH_KEYS_KEY = exports.ESCALATION_BATCH_COUNT_KEY = exports.ESCALATION_BATCH_PENDING_KEY = exports.foldEscalationConfig = exports.assertAccumulateItemKey = exports.foldAccumulateConfig = exports.foldBatchConfig = exports.ESCALATION_RESOLUTION_KEY = exports.EscalationClientService = exports.Escalations = void 0;
4
4
  const utils_1 = require("../../modules/utils");
5
5
  const client_1 = require("./client");
6
6
  Object.defineProperty(exports, "EscalationClientService", { enumerable: true, get: function () { return client_1.EscalationClientService; } });
@@ -87,6 +87,10 @@ Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_AT_KEY", { enumerable: t
87
87
  Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_BY_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FILLED_BY_KEY; } });
88
88
  Object.defineProperty(exports, "ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY; } });
89
89
  Object.defineProperty(exports, "ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH; } });
90
+ Object.defineProperty(exports, "ESCALATION_BATCH_FLAGS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FLAGS_KEY; } });
91
+ Object.defineProperty(exports, "ESCALATION_BATCH_WAKE_ON_FLAG_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_WAKE_ON_FLAG_KEY; } });
92
+ Object.defineProperty(exports, "ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH; } });
93
+ Object.defineProperty(exports, "ESCALATION_FLAGS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_FLAGS_KEY; } });
90
94
  Object.defineProperty(exports, "ESCALATION_ACCUMULATE_COUNT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_ACCUMULATE_COUNT_KEY; } });
91
95
  Object.defineProperty(exports, "ESCALATION_ACCUMULATE_MAX_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_ACCUMULATE_MAX_KEY; } });
92
96
  Object.defineProperty(exports, "ESCALATION_ACCUMULATE_KEYS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_ACCUMULATE_KEYS_KEY; } });
@@ -63,6 +63,8 @@ export interface AccumulateStatementInput {
63
63
  payload: Record<string, unknown> | null;
64
64
  reciprocalPayload: Record<string, unknown> | null;
65
65
  metadata: Record<string, unknown> | null;
66
+ /** Merged into the reciprocal row's metadata, as `metadata` is into the container's. */
67
+ reciprocalMetadata?: Record<string, unknown> | null;
66
68
  actor: string | null;
67
69
  assertClaim: string | null;
68
70
  wakes: AccumulateWake[];
@@ -204,6 +204,7 @@ function buildAccumulateStatement(input) {
204
204
  const expected = p.add(input.reciprocal ? 2 : 1);
205
205
  const head = targetCtes(input.primary, input.reciprocal, input.namespace, p, itemKey, payload, rPayload);
206
206
  const { ctes: wakeSql, counts: wakeCounts } = wakeCtes(input.wakes, input.appId, input.schemaName, p);
207
+ const rMeta = p.add(input.reciprocalMetadata ? JSON.stringify(input.reciprocalMetadata) : null);
207
208
  const newKeys = `CASE WHEN s.keys ? s.item_key THEN s.keys ELSE s.keys || to_jsonb(s.item_key) END`;
208
209
  const newCount = `jsonb_array_length(${newKeys})`;
209
210
  const entry = `jsonb_build_object('at', to_jsonb(NOW()))
@@ -230,7 +231,7 @@ function buildAccumulateStatement(input) {
230
231
  SET envelope = COALESCE(e.envelope, '{}'::jsonb)
231
232
  || jsonb_build_object('${ITEMS}', ${newItems}),
232
233
  metadata = COALESCE(e.metadata, '{}'::jsonb)
233
- || CASE WHEN s.is_primary THEN COALESCE(${meta}::jsonb, '{}'::jsonb) ELSE '{}'::jsonb END
234
+ || COALESCE(CASE WHEN s.is_primary THEN ${meta}::jsonb ELSE ${rMeta}::jsonb END, '{}'::jsonb)
234
235
  || jsonb_build_object('${KEYS}', ${newKeys}, '${COUNT}', ${newCount}),
235
236
  status = CASE WHEN ${complete} THEN 'resolved' ELSE e.status END,
236
237
  resolved_at = CASE WHEN ${complete} THEN NOW() ELSE e.resolved_at END,
@@ -0,0 +1,66 @@
1
+ import { FlagBatchItemResult, UnflagBatchItemResult } from '../../../../types/hmsh_escalations';
2
+ import { AccumulateWake } from './escalation-accumulate';
3
+ /**
4
+ * SQL builders for the batch flag store operations. Each builder is a pure
5
+ * function of its input; the provider owns the connection. One statement
6
+ * locks the row, writes only while the row and the key are pending, and
7
+ * classifies the outcome. A flag never changes `batch_pending`, so every
8
+ * fill and completion path reads the row as before.
9
+ */
10
+ export type BatchRowSelector = {
11
+ kind: 'id';
12
+ id: string;
13
+ } | {
14
+ kind: 'signalKey';
15
+ signalKey: string;
16
+ };
17
+ /** The flag value as the caller supplies it; the statement stamps `at`. */
18
+ export interface BatchFlagValue {
19
+ label: string;
20
+ payload?: Record<string, unknown>;
21
+ actor?: string;
22
+ }
23
+ export interface FlagStatementInput {
24
+ selector: BatchRowSelector;
25
+ namespace?: string;
26
+ itemKey: string;
27
+ flag: BatchFlagValue;
28
+ metadata: Record<string, unknown> | null;
29
+ /** Present when the row declared `wakeOnFlag`; fires only if the row resolves. */
30
+ wake: AccumulateWake | null;
31
+ appId: string;
32
+ schemaName: string;
33
+ }
34
+ export interface UnflagStatementInput {
35
+ selector: BatchRowSelector;
36
+ namespace?: string;
37
+ itemKey: string;
38
+ }
39
+ /** A provider result: the public result plus what the client needs to settle a wake. */
40
+ export type FlagRowResult = FlagBatchItemResult & {
41
+ signalKey?: string | null;
42
+ topic?: string | null;
43
+ wakeEnqueued?: boolean;
44
+ };
45
+ /**
46
+ * Flag one pending batch key. The flag lands in `envelope.batch_flags`
47
+ * beside the items, stamped with the database clock. On a row that
48
+ * declared `wakeOnFlag` the same UPDATE resolves the row with the items
49
+ * filled so far, `$flags`, and `$trigger: 'flag'`, and the wake commits
50
+ * with it. A key already filled, a row no longer pending, or a race lost to
51
+ * the completing fill writes nothing.
52
+ */
53
+ export declare function buildFlagStatement(input: FlagStatementInput): {
54
+ sql: string;
55
+ values: unknown[];
56
+ };
57
+ /**
58
+ * Clear one key's flag while the row is pending. Removes only that key's
59
+ * entry; the row's status, items and pending keys are untouched.
60
+ */
61
+ export declare function buildUnflagStatement(input: UnflagStatementInput): {
62
+ sql: string;
63
+ values: unknown[];
64
+ };
65
+ export declare function mapFlagRow(row: any): FlagRowResult;
66
+ export declare function mapUnflagRow(row: any): UnflagBatchItemResult;
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapUnflagRow = exports.mapFlagRow = exports.buildUnflagStatement = exports.buildFlagStatement = void 0;
4
+ const hmsh_escalations_1 = require("../../../../types/hmsh_escalations");
5
+ const escalation_accumulate_1 = require("./escalation-accumulate");
6
+ const FLAGS = hmsh_escalations_1.ESCALATION_BATCH_FLAGS_KEY;
7
+ const ITEMS = hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY;
8
+ const PENDING = hmsh_escalations_1.ESCALATION_BATCH_PENDING_KEY;
9
+ const KEYS = hmsh_escalations_1.ESCALATION_BATCH_KEYS_KEY;
10
+ const COUNT = hmsh_escalations_1.ESCALATION_BATCH_COUNT_KEY;
11
+ const WAKE_ON_FLAG = hmsh_escalations_1.ESCALATION_BATCH_WAKE_ON_FLAG_KEY;
12
+ function targetCte(selector, namespace, p) {
13
+ const column = selector.kind === 'id' ? 'id' : 'signal_key';
14
+ const value = p.add(selector.kind === 'id' ? selector.id : selector.signalKey);
15
+ const ns = namespace ? ` AND namespace = ${p.add(namespace)}` : '';
16
+ return `target AS MATERIALIZED (
17
+ SELECT id, signal_key, topic, status,
18
+ metadata->'${KEYS}' AS batch_keys,
19
+ metadata->'${PENDING}' AS batch_pending,
20
+ envelope->'${FLAGS}' AS batch_flags,
21
+ COALESCE((envelope->>'${WAKE_ON_FLAG}')::boolean, false) AS wake_on_flag
22
+ FROM public.hmsh_escalations
23
+ WHERE ${column} = ${value}${ns}
24
+ LIMIT 1 FOR UPDATE
25
+ )`;
26
+ }
27
+ /** Outcome cases shared by both statements, after the success case. */
28
+ function refusalCases(key, fallback) {
29
+ return `WHEN t.id IS NULL THEN 'not-found'
30
+ WHEN t.status <> 'pending' THEN 'blocked'
31
+ WHEN jsonb_typeof(t.batch_pending) IS DISTINCT FROM 'array' THEN 'not-batch'
32
+ WHEN NOT COALESCE(t.batch_keys ? ${key}::text, false) THEN 'unknown-item'
33
+ ELSE '${fallback}'`;
34
+ }
35
+ /**
36
+ * Flag one pending batch key. The flag lands in `envelope.batch_flags`
37
+ * beside the items, stamped with the database clock. On a row that
38
+ * declared `wakeOnFlag` the same UPDATE resolves the row with the items
39
+ * filled so far, `$flags`, and `$trigger: 'flag'`, and the wake commits
40
+ * with it. A key already filled, a row no longer pending, or a race lost to
41
+ * the completing fill writes nothing.
42
+ */
43
+ function buildFlagStatement(input) {
44
+ const p = new escalation_accumulate_1.SqlParams();
45
+ const target = targetCte(input.selector, input.namespace, p);
46
+ const key = p.add(input.itemKey);
47
+ const flag = p.add(JSON.stringify(input.flag));
48
+ const meta = p.add(input.metadata ? JSON.stringify(input.metadata) : null);
49
+ const flags = `(COALESCE(e.envelope->'${FLAGS}', '{}'::jsonb)
50
+ || jsonb_build_object(${key}::text,
51
+ ${flag}::jsonb || jsonb_build_object('at', to_jsonb(NOW()))))`;
52
+ const wake = wakeCte(input.wake, input.appId, input.schemaName, p);
53
+ const sql = `
54
+ WITH ${target},
55
+ written AS (
56
+ UPDATE public.hmsh_escalations e
57
+ SET envelope = COALESCE(e.envelope, '{}'::jsonb)
58
+ || jsonb_build_object('${FLAGS}', ${flags}),
59
+ metadata = COALESCE(e.metadata, '{}'::jsonb)
60
+ || COALESCE(${meta}::jsonb, '{}'::jsonb)
61
+ || jsonb_build_object(
62
+ '${PENDING}', e.metadata->'${PENDING}',
63
+ '${COUNT}', e.metadata->'${COUNT}',
64
+ '${KEYS}', e.metadata->'${KEYS}'),
65
+ status = CASE WHEN t.wake_on_flag THEN 'resolved' ELSE e.status END,
66
+ resolved_at = CASE WHEN t.wake_on_flag THEN NOW() ELSE e.resolved_at END,
67
+ resolver_payload = CASE WHEN t.wake_on_flag
68
+ THEN COALESCE(e.envelope->'${ITEMS}', '{}'::jsonb)
69
+ || jsonb_build_object('${hmsh_escalations_1.ESCALATION_FLAGS_KEY}', ${flags},
70
+ '${hmsh_escalations_1.ESCALATION_TRIGGER_KEY}', 'flag')
71
+ ELSE e.resolver_payload END,
72
+ updated_at = NOW()
73
+ FROM target t
74
+ WHERE e.id = t.id
75
+ AND t.status = 'pending'
76
+ AND jsonb_typeof(t.batch_pending) = 'array'
77
+ AND t.batch_pending ? ${key}::text
78
+ RETURNING e.*
79
+ )${wake.cte}
80
+ SELECT t.id, t.status AS prior_status, t.signal_key, t.topic,
81
+ CASE
82
+ WHEN w.id IS NOT NULL AND w.status = 'resolved' THEN 'completed'
83
+ WHEN w.id IS NOT NULL THEN 'flagged'
84
+ ${refusalCases(key, 'already-filled')}
85
+ END AS outcome,
86
+ row_to_json(w.*) AS entry_json,
87
+ ${wake.count}
88
+ FROM (SELECT * FROM target) t
89
+ FULL OUTER JOIN (SELECT * FROM written) w ON w.id = t.id`;
90
+ return { sql, values: p.values };
91
+ }
92
+ exports.buildFlagStatement = buildFlagStatement;
93
+ /**
94
+ * Clear one key's flag while the row is pending. Removes only that key's
95
+ * entry; the row's status, items and pending keys are untouched.
96
+ */
97
+ function buildUnflagStatement(input) {
98
+ const p = new escalation_accumulate_1.SqlParams();
99
+ const target = targetCte(input.selector, input.namespace, p);
100
+ const key = p.add(input.itemKey);
101
+ const sql = `
102
+ WITH ${target},
103
+ written AS (
104
+ UPDATE public.hmsh_escalations e
105
+ SET envelope = e.envelope
106
+ || jsonb_build_object('${FLAGS}', (e.envelope->'${FLAGS}') - ${key}::text),
107
+ updated_at = NOW()
108
+ FROM target t
109
+ WHERE e.id = t.id
110
+ AND t.status = 'pending'
111
+ AND jsonb_typeof(t.batch_pending) = 'array'
112
+ AND jsonb_typeof(t.batch_flags) = 'object'
113
+ AND t.batch_flags ? ${key}::text
114
+ RETURNING e.*
115
+ )
116
+ SELECT t.id, t.status AS prior_status,
117
+ CASE
118
+ WHEN w.id IS NOT NULL THEN 'unflagged'
119
+ ${refusalCases(key, 'not-flagged')}
120
+ END AS outcome,
121
+ row_to_json(w.*) AS entry_json
122
+ FROM (SELECT * FROM target) t
123
+ FULL OUTER JOIN (SELECT * FROM written) w ON w.id = t.id`;
124
+ return { sql, values: p.values };
125
+ }
126
+ exports.buildUnflagStatement = buildUnflagStatement;
127
+ function wakeCte(wake, appId, schemaName, p) {
128
+ if (!wake)
129
+ return { cte: '', count: '0::int AS wake_count' };
130
+ const app = p.add(appId);
131
+ const msg = p.add(wake.command.message);
132
+ const sk = p.add(wake.command.forSignalKey);
133
+ const res = p.add(wake.resolutionJson);
134
+ return {
135
+ cte: `,
136
+ wake AS (
137
+ INSERT INTO ${schemaName}.engine_streams (stream_name, message, priority)
138
+ SELECT ${app},
139
+ jsonb_set(${msg}::jsonb, '{data,data}',
140
+ w.resolver_payload::jsonb || COALESCE(${res}::jsonb, '{}'::jsonb))::text,
141
+ 5
142
+ FROM written w
143
+ WHERE w.status = 'resolved' AND w.signal_key = ${sk}
144
+ RETURNING id
145
+ )`,
146
+ count: '(SELECT COUNT(*) FROM wake)::int AS wake_count',
147
+ };
148
+ }
149
+ /** `blocked` names the row's prior terminal status. */
150
+ function blockedOutcome(priorStatus) {
151
+ if (priorStatus === 'cancelled')
152
+ return 'already-cancelled';
153
+ if (priorStatus === 'expired')
154
+ return 'already-expired';
155
+ return 'already-resolved';
156
+ }
157
+ function mapFlagRow(row) {
158
+ if (!row || row.outcome === 'not-found')
159
+ return { ok: false, outcome: 'not-found' };
160
+ if (row.outcome === 'flagged' || row.outcome === 'completed') {
161
+ return {
162
+ ok: true,
163
+ outcome: row.outcome,
164
+ entry: row.entry_json,
165
+ signalKey: row.signal_key,
166
+ topic: row.topic,
167
+ wakeEnqueued: row.wake_count > 0,
168
+ };
169
+ }
170
+ if (row.outcome === 'blocked')
171
+ return { ok: false, outcome: blockedOutcome(row.prior_status) };
172
+ return { ok: false, outcome: row.outcome };
173
+ }
174
+ exports.mapFlagRow = mapFlagRow;
175
+ function mapUnflagRow(row) {
176
+ if (!row || row.outcome === 'not-found')
177
+ return { ok: false, outcome: 'not-found' };
178
+ if (row.outcome === 'unflagged')
179
+ return { ok: true, outcome: 'unflagged', entry: row.entry_json };
180
+ if (row.outcome === 'blocked')
181
+ return { ok: false, outcome: blockedOutcome(row.prior_status) };
182
+ return { ok: false, outcome: row.outcome };
183
+ }
184
+ exports.mapUnflagRow = mapUnflagRow;
@@ -13,6 +13,7 @@ import { WorkListTaskType } from '../../../../types/task';
13
13
  import { ThrottleOptions } from '../../../../types/quorum';
14
14
  import { StoreService } from '../..';
15
15
  import { AccumulateWake } from './escalation-accumulate';
16
+ import { FlagRowResult } from './escalation-batch-flag';
16
17
  import { PostgresClientType } from '../../../../types';
17
18
  import { KVSQL } from './kvsql';
18
19
  import { KVTables } from './kvtables';
@@ -374,6 +375,15 @@ declare class PostgresStoreService extends StoreService<ProviderClient, Provider
374
375
  topic?: string | null;
375
376
  wakeEnqueued?: boolean;
376
377
  }>;
378
+ /**
379
+ * Flags one pending batch key in one statement. See `buildFlagStatement`.
380
+ * `wakeCommand` is passed only for a row that declared `wakeOnFlag`; the
381
+ * wake commits with the resolve. `resolutionJson` rides the wake only.
382
+ */
383
+ flagEscalationBatchItem(params: import('../../../../types/hmsh_escalations').FlagBatchItemParams, wakeCommand?: import('../../../../types/hmsh_escalations').EscalationWakeCommand, resolutionJson?: string | null): Promise<FlagRowResult>;
384
+ /** Clears one key's flag while the row is pending. See `buildUnflagStatement`. */
385
+ unflagEscalationBatchItem(params: import('../../../../types/hmsh_escalations').UnflagBatchItemParams): Promise<import('../../../../types/hmsh_escalations').UnflagBatchItemResult>;
386
+ private _batchSelector;
377
387
  private _accumulateSelector;
378
388
  private _mapAccumulateRows;
379
389
  /**
@@ -35,6 +35,7 @@ const cache_1 = require("../../cache");
35
35
  const __1 = require("../..");
36
36
  const fold_1 = require("../../../escalations/fold");
37
37
  const escalation_accumulate_1 = require("./escalation-accumulate");
38
+ const escalation_batch_flag_1 = require("./escalation-batch-flag");
38
39
  const kvsql_1 = require("./kvsql");
39
40
  const kvtables_1 = require("./kvtables");
40
41
  const time_notify_1 = require("./time-notify");
@@ -2337,6 +2338,49 @@ class PostgresStoreService extends __1.StoreService {
2337
2338
  const result = await this.pgClient.query(this._batchItemStatement(targetCTE, 2, 3, 4, 5, 7, wakeCTE, wakeCount), sqlParams);
2338
2339
  return this._mapBatchItemRow(result.rows[0]);
2339
2340
  }
2341
+ /**
2342
+ * Flags one pending batch key in one statement. See `buildFlagStatement`.
2343
+ * `wakeCommand` is passed only for a row that declared `wakeOnFlag`; the
2344
+ * wake commits with the resolve. `resolutionJson` rides the wake only.
2345
+ */
2346
+ async flagEscalationBatchItem(params, wakeCommand, resolutionJson) {
2347
+ const { sql, values } = (0, escalation_batch_flag_1.buildFlagStatement)({
2348
+ selector: this._batchSelector(params, 'flagBatchItem'),
2349
+ namespace: params.namespace,
2350
+ itemKey: params.itemKey,
2351
+ flag: {
2352
+ label: params.label,
2353
+ ...(params.payload ? { payload: params.payload } : {}),
2354
+ ...(params.actor ? { actor: params.actor } : {}),
2355
+ },
2356
+ metadata: params.metadata ?? null,
2357
+ wake: wakeCommand
2358
+ ? { command: wakeCommand, resolutionJson: resolutionJson ?? null }
2359
+ : null,
2360
+ appId: this.appId,
2361
+ schemaName: this.kvsql().safeName(this.appId),
2362
+ });
2363
+ const result = await this.pgClient.query(sql, values);
2364
+ return (0, escalation_batch_flag_1.mapFlagRow)(result.rows[0]);
2365
+ }
2366
+ /** Clears one key's flag while the row is pending. See `buildUnflagStatement`. */
2367
+ async unflagEscalationBatchItem(params) {
2368
+ const { sql, values } = (0, escalation_batch_flag_1.buildUnflagStatement)({
2369
+ selector: this._batchSelector(params, 'unflagBatchItem'),
2370
+ namespace: params.namespace,
2371
+ itemKey: params.itemKey,
2372
+ });
2373
+ const result = await this.pgClient.query(sql, values);
2374
+ return (0, escalation_batch_flag_1.mapUnflagRow)(result.rows[0]);
2375
+ }
2376
+ _batchSelector(sel, label) {
2377
+ if ((sel.id ? 1 : 0) + (sel.signalKey ? 1 : 0) !== 1) {
2378
+ throw new Error(`${label} requires exactly one of \`id\` or \`signalKey\``);
2379
+ }
2380
+ return sel.id
2381
+ ? { kind: 'id', id: sel.id }
2382
+ : { kind: 'signalKey', signalKey: sel.signalKey };
2383
+ }
2340
2384
  _accumulateSelector(sel, label) {
2341
2385
  const forms = (sel.id ? 1 : 0) + (sel.signalKey ? 1 : 0) + (sel.key !== undefined ? 1 : 0);
2342
2386
  if (forms !== 1) {
@@ -2440,6 +2484,7 @@ class PostgresStoreService extends __1.StoreService {
2440
2484
  payload: params.payload ?? null,
2441
2485
  reciprocalPayload: params.reciprocal?.payload ?? null,
2442
2486
  metadata: params.metadata ?? null,
2487
+ reciprocalMetadata: params.reciprocal?.metadata ?? null,
2443
2488
  actor: params.actor ?? null,
2444
2489
  assertClaim: params.assertClaim ?? null,
2445
2490
  wakes,
@@ -36,6 +36,13 @@ export interface ConditionQueueConfig {
36
36
  * existing batch waiters are unchanged.
37
37
  */
38
38
  partialOnTimeout?: boolean;
39
+ /**
40
+ * With `batch`, a `flagBatchItem()` call ends the wait: the row resolves
41
+ * and the wait resumes with the items filled so far, the flags
42
+ * (`$flags`), and `$trigger: 'flag'`. Off by default: a flag is then
43
+ * recorded on the row and the wait continues.
44
+ */
45
+ wakeOnFlag?: boolean;
39
46
  /**
40
47
  * With `batch`, entries already satisfied when the row is created (for
41
48
  * example, received before the wait began). Each key must be declared in
@@ -356,6 +363,8 @@ export interface CreateEscalationParams {
356
363
  batch?: string[];
357
364
  /** See {@link ConditionQueueConfig.partialOnTimeout}. */
358
365
  partialOnTimeout?: boolean;
366
+ /** See {@link ConditionQueueConfig.wakeOnFlag}. */
367
+ wakeOnFlag?: boolean;
359
368
  /** See {@link ConditionQueueConfig.filled}. */
360
369
  filled?: Record<string, BatchFilledEntry>;
361
370
  /**
@@ -509,6 +518,18 @@ export declare const ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = 128;
509
518
  /** Envelope key: set by `partialOnTimeout` on a batch row so the expiry
510
519
  * statement knows to deliver the filled items with `$trigger: 'timeout'`. */
511
520
  export declare const ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY = "batch_partial_on_timeout";
521
+ /** Envelope key: per-item flags (`Record<itemKey, BatchItemFlag>`), written
522
+ * by `flagBatchItem()` while the key is pending and cleared by
523
+ * `unflagBatchItem()`. A flagged key stays pending and can still be filled. */
524
+ export declare const ESCALATION_BATCH_FLAGS_KEY = "batch_flags";
525
+ /** Envelope key: set by `wakeOnFlag` on a batch row so the flag statement
526
+ * resolves the row and wakes the waiter. */
527
+ export declare const ESCALATION_BATCH_WAKE_ON_FLAG_KEY = "batch_wake_on_flag";
528
+ /** Reserved signal-payload key: the flags delivered when a flag ends the
529
+ * wait (`wakeOnFlag`). */
530
+ export declare const ESCALATION_FLAGS_KEY = "$flags";
531
+ /** Flag labels are non-empty strings up to this length. */
532
+ export declare const ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH = 128;
512
533
  /** Metadata facet: number of items currently held. Recomputed from
513
534
  * `accumulate_keys` in every add/remove statement so the two never drift. */
514
535
  export declare const ESCALATION_ACCUMULATE_COUNT_KEY = "accumulate_count";
@@ -529,7 +550,7 @@ export declare const ESCALATION_ACCUMULATE_CONFIG_KEY = "accumulate_config";
529
550
  * waiter of an accumulator row. */
530
551
  export declare const ESCALATION_ACCUMULATED_KEY = "$accumulated";
531
552
  /** Reserved signal-payload key: which terminal path delivered the
532
- * collection (`count` | `timeout` | `resolve`). */
553
+ * collection (`count` | `timeout` | `resolve`; `flag` on a batch row). */
533
554
  export declare const ESCALATION_TRIGGER_KEY = "$trigger";
534
555
  export interface AccumulateConfig {
535
556
  /** Count trigger. Absent means unbounded: only `timeout` or a manual
@@ -579,6 +600,12 @@ export interface AccumulateReciprocalSelector {
579
600
  roles?: string[];
580
601
  /** Stored as the reciprocal entry's payload. */
581
602
  payload?: Record<string, unknown>;
603
+ /**
604
+ * Merged into the reciprocal row's GIN-indexed metadata in the same
605
+ * UPDATE, as `metadata` is into the container's. Reserved accumulate
606
+ * keys are rejected.
607
+ */
608
+ metadata?: Record<string, unknown>;
582
609
  }
583
610
  /**
584
611
  * Outcome of an `accumulateItem()` call.
@@ -770,6 +797,63 @@ export type ResolveBatchItemResult = {
770
797
  ok: false;
771
798
  outcome: Exclude<BatchItemOutcome, 'completed' | 'accepted'>;
772
799
  };
800
+ /** One flag on a batch item, stored under `envelope.batch_flags[itemKey]`. */
801
+ export interface BatchItemFlag {
802
+ label: string;
803
+ payload?: Record<string, unknown>;
804
+ actor?: string;
805
+ /** Database clock, stamped by the flag statement. */
806
+ at: string;
807
+ }
808
+ export interface FlagBatchItemParams {
809
+ /** Row selector — exactly one of `id` | `signalKey`. */
810
+ id?: string;
811
+ signalKey?: string;
812
+ namespace?: string;
813
+ /** A declared batch key that is still pending. */
814
+ itemKey: string;
815
+ /** What the flag says, e.g. `Missing`. */
816
+ label: string;
817
+ /** Detail stored with the flag and delivered with `$flags`. */
818
+ payload?: Record<string, unknown>;
819
+ /** Recorded on the flag. */
820
+ actor?: string;
821
+ /** Merge patch for the row's `metadata`, in the same UPDATE. Reserved
822
+ * batch keys are rejected. */
823
+ metadata?: Record<string, unknown>;
824
+ /** Delivered under `$resolution` when the flag ends the wait. */
825
+ resolvedBy?: ResolvedByIdentity;
826
+ }
827
+ export interface UnflagBatchItemParams {
828
+ /** Row selector — exactly one of `id` | `signalKey`. */
829
+ id?: string;
830
+ signalKey?: string;
831
+ namespace?: string;
832
+ itemKey: string;
833
+ }
834
+ /**
835
+ * `flagged`: the flag is stored and the row stays pending. `completed`: the
836
+ * row declared `wakeOnFlag`, so it resolved and the waiter woke.
837
+ * `already-filled`: the key is declared but no longer pending.
838
+ */
839
+ export type FlagBatchItemOutcome = 'flagged' | 'completed' | 'already-filled' | 'unknown-item' | 'not-batch' | 'not-found' | 'already-resolved' | 'already-cancelled' | 'already-expired';
840
+ export type FlagBatchItemResult = {
841
+ ok: true;
842
+ outcome: 'flagged' | 'completed';
843
+ entry: EscalationEntry;
844
+ } | {
845
+ ok: false;
846
+ outcome: Exclude<FlagBatchItemOutcome, 'flagged' | 'completed'>;
847
+ };
848
+ export type UnflagBatchItemOutcome = 'unflagged' | 'not-flagged' | 'unknown-item' | 'not-batch' | 'not-found' | 'already-resolved' | 'already-cancelled' | 'already-expired';
849
+ export type UnflagBatchItemResult = {
850
+ ok: true;
851
+ outcome: 'unflagged';
852
+ entry: EscalationEntry;
853
+ } | {
854
+ ok: false;
855
+ outcome: Exclude<UnflagBatchItemOutcome, 'unflagged'>;
856
+ };
773
857
  /**
774
858
  * Query selector for `claimManyByQuery()` — the filterable subset of
775
859
  * `ListEscalationsParams` that describes a claimable population. `status` is
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ESCALATION_TRIGGER_KEY = exports.ESCALATION_ACCUMULATED_KEY = exports.ESCALATION_ACCUMULATE_CONFIG_KEY = exports.ESCALATION_ACCUMULATE_ITEMS_KEY = exports.ESCALATION_ACCUMULATE_KEYS_KEY = exports.ESCALATION_ACCUMULATE_MAX_KEY = exports.ESCALATION_ACCUMULATE_COUNT_KEY = exports.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY = exports.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = exports.ESCALATION_BATCH_FILLED_BY_KEY = exports.ESCALATION_BATCH_FILLED_AT_KEY = exports.ESCALATION_BATCH_ITEMS_KEY = exports.ESCALATION_BATCH_KEYS_KEY = exports.ESCALATION_BATCH_COUNT_KEY = exports.ESCALATION_BATCH_PENDING_KEY = void 0;
3
+ exports.ESCALATION_TRIGGER_KEY = exports.ESCALATION_ACCUMULATED_KEY = exports.ESCALATION_ACCUMULATE_CONFIG_KEY = exports.ESCALATION_ACCUMULATE_ITEMS_KEY = exports.ESCALATION_ACCUMULATE_KEYS_KEY = exports.ESCALATION_ACCUMULATE_MAX_KEY = exports.ESCALATION_ACCUMULATE_COUNT_KEY = exports.ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH = exports.ESCALATION_FLAGS_KEY = exports.ESCALATION_BATCH_WAKE_ON_FLAG_KEY = exports.ESCALATION_BATCH_FLAGS_KEY = exports.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY = exports.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = exports.ESCALATION_BATCH_FILLED_BY_KEY = exports.ESCALATION_BATCH_FILLED_AT_KEY = exports.ESCALATION_BATCH_ITEMS_KEY = exports.ESCALATION_BATCH_KEYS_KEY = exports.ESCALATION_BATCH_COUNT_KEY = exports.ESCALATION_BATCH_PENDING_KEY = void 0;
4
4
  // ─── Batch accumulation ───────────────────────────────────────────────────────
5
5
  /** Metadata facet: item keys still awaiting submission (jsonb string array).
6
6
  * `metadata @> '{"batch_pending":["x"]}'` finds rows still missing item `x`. */
@@ -30,6 +30,18 @@ exports.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = 128;
30
30
  /** Envelope key: set by `partialOnTimeout` on a batch row so the expiry
31
31
  * statement knows to deliver the filled items with `$trigger: 'timeout'`. */
32
32
  exports.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY = 'batch_partial_on_timeout';
33
+ /** Envelope key: per-item flags (`Record<itemKey, BatchItemFlag>`), written
34
+ * by `flagBatchItem()` while the key is pending and cleared by
35
+ * `unflagBatchItem()`. A flagged key stays pending and can still be filled. */
36
+ exports.ESCALATION_BATCH_FLAGS_KEY = 'batch_flags';
37
+ /** Envelope key: set by `wakeOnFlag` on a batch row so the flag statement
38
+ * resolves the row and wakes the waiter. */
39
+ exports.ESCALATION_BATCH_WAKE_ON_FLAG_KEY = 'batch_wake_on_flag';
40
+ /** Reserved signal-payload key: the flags delivered when a flag ends the
41
+ * wait (`wakeOnFlag`). */
42
+ exports.ESCALATION_FLAGS_KEY = '$flags';
43
+ /** Flag labels are non-empty strings up to this length. */
44
+ exports.ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH = 128;
33
45
  // ─── Open accumulation ────────────────────────────────────────────────────────
34
46
  /** Metadata facet: number of items currently held. Recomputed from
35
47
  * `accumulate_keys` in every add/remove statement so the two never drift. */
@@ -51,5 +63,5 @@ exports.ESCALATION_ACCUMULATE_CONFIG_KEY = 'accumulate_config';
51
63
  * waiter of an accumulator row. */
52
64
  exports.ESCALATION_ACCUMULATED_KEY = '$accumulated';
53
65
  /** Reserved signal-payload key: which terminal path delivered the
54
- * collection (`count` | `timeout` | `resolve`). */
66
+ * collection (`count` | `timeout` | `resolve`; `flag` on a batch row). */
55
67
  exports.ESCALATION_TRIGGER_KEY = '$trigger';
@@ -25,5 +25,5 @@ export { ReclaimedMessageType, RetryPolicy, RouterConfig, StreamCode, StreamConf
25
25
  export { context, Context, Counter, Meter, metrics, propagation, SpanContext, Span, SpanStatus, SpanStatusCode, SpanKind, trace, Tracer, ValueType, } from './telemetry';
26
26
  export { WorkListTaskType } from './task';
27
27
  export { TransitionMatch, TransitionRule, Transitions } from './transition';
28
- export { ConditionQueueConfig, EscalationEntry, ClaimEscalationResult, ClaimByMetadataResult, ReleaseEscalationResult, ResolveEscalationResult, CancelEscalationResult, ListEscalationsParams, CreateEscalationParams, UpdateEscalationParams, AppendMilestonesParams, ClaimEscalationParams, ClaimByMetadataParams, ReleaseEscalationParams, ResolveEscalationParams, ResolveByMetadataParams, ResolveAllOrNoneItem, ResolveAllOrNoneParams, ResolveAllOrNoneBlockReason, ResolveAllOrNoneResult, EscalateToRoleParams, MigrateEscalationParams, EscalationResolution, ResolvedByIdentity, ClaimManyQuerySelector, ClaimManyByQueryParams, BatchItemOutcome, ResolveBatchItemParams, ResolveBatchItemByMetadataParams, ResolveBatchItemResult, ESCALATION_BATCH_PENDING_KEY, ESCALATION_BATCH_COUNT_KEY, ESCALATION_BATCH_KEYS_KEY, ESCALATION_BATCH_ITEMS_KEY, ESCALATION_BATCH_FILLED_AT_KEY, ESCALATION_BATCH_FILLED_BY_KEY, ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY, ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH, BatchFilledEntry, AccumulateConfig, AccumulatedEntry, AccumulatedItem, AccumulatorTrigger, AccumulatorResult, AccumulateReciprocalSelector, AccumulateItemOutcome, AccumulateItemParams, AccumulateItemByMetadataParams, AccumulateReciprocalResult, AccumulateItemResult, RemoveAccumulatedItemOutcome, RemoveAccumulatedItemParams, RemoveAccumulatedItemByMetadataParams, RemoveAccumulatedItemResult, ExpireEscalationResult, ESCALATION_ACCUMULATE_COUNT_KEY, ESCALATION_ACCUMULATE_MAX_KEY, ESCALATION_ACCUMULATE_KEYS_KEY, ESCALATION_ACCUMULATE_ITEMS_KEY, ESCALATION_ACCUMULATE_CONFIG_KEY, ESCALATION_ACCUMULATED_KEY, ESCALATION_TRIGGER_KEY, } from './hmsh_escalations';
28
+ export { ConditionQueueConfig, EscalationEntry, ClaimEscalationResult, ClaimByMetadataResult, ReleaseEscalationResult, ResolveEscalationResult, CancelEscalationResult, ListEscalationsParams, CreateEscalationParams, UpdateEscalationParams, AppendMilestonesParams, ClaimEscalationParams, ClaimByMetadataParams, ReleaseEscalationParams, ResolveEscalationParams, ResolveByMetadataParams, ResolveAllOrNoneItem, ResolveAllOrNoneParams, ResolveAllOrNoneBlockReason, ResolveAllOrNoneResult, EscalateToRoleParams, MigrateEscalationParams, EscalationResolution, ResolvedByIdentity, ClaimManyQuerySelector, ClaimManyByQueryParams, BatchItemOutcome, ResolveBatchItemParams, ResolveBatchItemByMetadataParams, ResolveBatchItemResult, ESCALATION_BATCH_PENDING_KEY, ESCALATION_BATCH_COUNT_KEY, ESCALATION_BATCH_KEYS_KEY, ESCALATION_BATCH_ITEMS_KEY, ESCALATION_BATCH_FILLED_AT_KEY, ESCALATION_BATCH_FILLED_BY_KEY, ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY, ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH, ESCALATION_BATCH_FLAGS_KEY, ESCALATION_BATCH_WAKE_ON_FLAG_KEY, ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH, ESCALATION_FLAGS_KEY, BatchItemFlag, FlagBatchItemParams, FlagBatchItemOutcome, FlagBatchItemResult, UnflagBatchItemParams, UnflagBatchItemOutcome, UnflagBatchItemResult, BatchFilledEntry, AccumulateConfig, AccumulatedEntry, AccumulatedItem, AccumulatorTrigger, AccumulatorResult, AccumulateReciprocalSelector, AccumulateItemOutcome, AccumulateItemParams, AccumulateItemByMetadataParams, AccumulateReciprocalResult, AccumulateItemResult, RemoveAccumulatedItemOutcome, RemoveAccumulatedItemParams, RemoveAccumulatedItemByMetadataParams, RemoveAccumulatedItemResult, ExpireEscalationResult, ESCALATION_ACCUMULATE_COUNT_KEY, ESCALATION_ACCUMULATE_MAX_KEY, ESCALATION_ACCUMULATE_KEYS_KEY, ESCALATION_ACCUMULATE_ITEMS_KEY, ESCALATION_ACCUMULATE_CONFIG_KEY, ESCALATION_ACCUMULATED_KEY, ESCALATION_TRIGGER_KEY, } from './hmsh_escalations';
29
29
  export { EscalationVerb, EngineVerb, WorkerVerb, SystemEvent, EventsConfig } from './system_events';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ESCALATION_TRIGGER_KEY = exports.ESCALATION_ACCUMULATED_KEY = exports.ESCALATION_ACCUMULATE_CONFIG_KEY = exports.ESCALATION_ACCUMULATE_ITEMS_KEY = exports.ESCALATION_ACCUMULATE_KEYS_KEY = exports.ESCALATION_ACCUMULATE_MAX_KEY = exports.ESCALATION_ACCUMULATE_COUNT_KEY = exports.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = exports.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY = exports.ESCALATION_BATCH_FILLED_BY_KEY = exports.ESCALATION_BATCH_FILLED_AT_KEY = exports.ESCALATION_BATCH_ITEMS_KEY = exports.ESCALATION_BATCH_KEYS_KEY = exports.ESCALATION_BATCH_COUNT_KEY = exports.ESCALATION_BATCH_PENDING_KEY = exports.ValueType = exports.trace = exports.SpanKind = exports.SpanStatusCode = exports.propagation = exports.metrics = exports.context = exports.StreamStatus = exports.StreamRole = exports.StreamDataType = exports.KeyType = exports.HookGate = exports.CollationFaultType = void 0;
3
+ exports.ESCALATION_TRIGGER_KEY = exports.ESCALATION_ACCUMULATED_KEY = exports.ESCALATION_ACCUMULATE_CONFIG_KEY = exports.ESCALATION_ACCUMULATE_ITEMS_KEY = exports.ESCALATION_ACCUMULATE_KEYS_KEY = exports.ESCALATION_ACCUMULATE_MAX_KEY = exports.ESCALATION_ACCUMULATE_COUNT_KEY = exports.ESCALATION_FLAGS_KEY = exports.ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH = exports.ESCALATION_BATCH_WAKE_ON_FLAG_KEY = exports.ESCALATION_BATCH_FLAGS_KEY = exports.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = exports.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY = exports.ESCALATION_BATCH_FILLED_BY_KEY = exports.ESCALATION_BATCH_FILLED_AT_KEY = exports.ESCALATION_BATCH_ITEMS_KEY = exports.ESCALATION_BATCH_KEYS_KEY = exports.ESCALATION_BATCH_COUNT_KEY = exports.ESCALATION_BATCH_PENDING_KEY = exports.ValueType = exports.trace = exports.SpanKind = exports.SpanStatusCode = exports.propagation = exports.metrics = exports.context = exports.StreamStatus = exports.StreamRole = exports.StreamDataType = exports.KeyType = exports.HookGate = exports.CollationFaultType = void 0;
4
4
  var collator_1 = require("./collator");
5
5
  Object.defineProperty(exports, "CollationFaultType", { enumerable: true, get: function () { return collator_1.CollationFaultType; } });
6
6
  var hook_1 = require("./hook");
@@ -28,6 +28,10 @@ Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_AT_KEY", { enumerable: t
28
28
  Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_BY_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FILLED_BY_KEY; } });
29
29
  Object.defineProperty(exports, "ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY; } });
30
30
  Object.defineProperty(exports, "ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH; } });
31
+ Object.defineProperty(exports, "ESCALATION_BATCH_FLAGS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FLAGS_KEY; } });
32
+ Object.defineProperty(exports, "ESCALATION_BATCH_WAKE_ON_FLAG_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_WAKE_ON_FLAG_KEY; } });
33
+ Object.defineProperty(exports, "ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FLAG_LABEL_MAX_LENGTH; } });
34
+ Object.defineProperty(exports, "ESCALATION_FLAGS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_FLAGS_KEY; } });
31
35
  Object.defineProperty(exports, "ESCALATION_ACCUMULATE_COUNT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_ACCUMULATE_COUNT_KEY; } });
32
36
  Object.defineProperty(exports, "ESCALATION_ACCUMULATE_MAX_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_ACCUMULATE_MAX_KEY; } });
33
37
  Object.defineProperty(exports, "ESCALATION_ACCUMULATE_KEYS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_ACCUMULATE_KEYS_KEY; } });
@@ -115,7 +115,7 @@
115
115
  * ```
116
116
  */
117
117
  /** Verbs for escalation lifecycle transitions. */
118
- export type EscalationVerb = 'created' | 'claimed' | 'released' | 'reassigned' | 'resolved' | 'cancelled' | 'expired' | 'batch-item' | 'accumulated' | 'removed';
118
+ export type EscalationVerb = 'created' | 'claimed' | 'released' | 'reassigned' | 'resolved' | 'cancelled' | 'expired' | 'batch-item' | 'flagged' | 'unflagged' | 'accumulated' | 'removed';
119
119
  /** Verbs for engine lifecycle transitions. */
120
120
  export type EngineVerb = 'started' | 'stopped' | 'deployed';
121
121
  /** Verbs for worker lifecycle transitions. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.31.1",
3
+ "version": "0.31.3",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",