@hotmeshio/hotmesh 0.28.1 → 0.29.1

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.
@@ -0,0 +1,313 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildRemoveStatement = exports.buildAccumulateStatement = exports.resolveWakeMessageSql = exports.timeoutPayloadSql = exports.resolvePayloadSql = exports.accumulatedCollectionSql = exports.isAccumulatorSql = exports.SqlParams = void 0;
4
+ const hmsh_escalations_1 = require("../../../../types/hmsh_escalations");
5
+ /**
6
+ * SQL builders for the accumulator store operations. Every builder is a
7
+ * pure function of parameter positions; the provider owns the connection
8
+ * and the result mapping. Two rows (container and reciprocal) are locked
9
+ * in one ordered CTE and written by one UPDATE gated on both being
10
+ * eligible, so a reciprocal add is both-or-neither by construction.
11
+ */
12
+ /** Collects statement parameters and hands back their `$n` placeholders. */
13
+ class SqlParams {
14
+ constructor() {
15
+ this.values = [];
16
+ }
17
+ add(value) {
18
+ this.values.push(value);
19
+ return `$${this.values.length}`;
20
+ }
21
+ }
22
+ exports.SqlParams = SqlParams;
23
+ const ITEMS = hmsh_escalations_1.ESCALATION_ACCUMULATE_ITEMS_KEY;
24
+ const CONFIG = hmsh_escalations_1.ESCALATION_ACCUMULATE_CONFIG_KEY;
25
+ const KEYS = hmsh_escalations_1.ESCALATION_ACCUMULATE_KEYS_KEY;
26
+ const COUNT = hmsh_escalations_1.ESCALATION_ACCUMULATE_COUNT_KEY;
27
+ const MAX = hmsh_escalations_1.ESCALATION_ACCUMULATE_MAX_KEY;
28
+ /** True when the row's envelope carries an accumulator item store. */
29
+ function isAccumulatorSql(envelopeExpr) {
30
+ return `COALESCE(jsonb_typeof(${envelopeExpr}->'${ITEMS}') = 'object', false)`;
31
+ }
32
+ exports.isAccumulatorSql = isAccumulatorSql;
33
+ /**
34
+ * The delivered collection for an item store expression: `$accumulated`
35
+ * ordered by each entry's database-clock `at`, plus the `$trigger` that
36
+ * ended the wait.
37
+ */
38
+ function accumulatedCollectionSql(itemsExpr, trigger) {
39
+ return `jsonb_build_object(
40
+ '${hmsh_escalations_1.ESCALATION_ACCUMULATED_KEY}',
41
+ (SELECT COALESCE(jsonb_agg(jsonb_build_object('itemKey', kv.key) || kv.value
42
+ ORDER BY (kv.value->>'at')::timestamptz, kv.key), '[]'::jsonb)
43
+ FROM jsonb_each(${itemsExpr}) AS kv),
44
+ '${hmsh_escalations_1.ESCALATION_TRIGGER_KEY}', '${trigger}')`;
45
+ }
46
+ exports.accumulatedCollectionSql = accumulatedCollectionSql;
47
+ /**
48
+ * The stored `resolver_payload` for a manual resolve: the collection merged
49
+ * with the resolver's payload on an accumulator row, the payload alone on
50
+ * any other row.
51
+ */
52
+ function resolvePayloadSql(rowAlias, payloadParam) {
53
+ return `CASE WHEN ${isAccumulatorSql(`${rowAlias}.envelope`)}
54
+ THEN ${accumulatedCollectionSql(`${rowAlias}.envelope->'${ITEMS}'`, 'resolve')}
55
+ || COALESCE(${payloadParam}::jsonb, '{}'::jsonb)
56
+ ELSE ${payloadParam}::jsonb END`;
57
+ }
58
+ exports.resolvePayloadSql = resolvePayloadSql;
59
+ /**
60
+ * The `resolver_payload` written by the timeout path: an accumulator
61
+ * delivers its collection, a batch row with `partialOnTimeout` delivers the
62
+ * items filled so far, every other row keeps its column untouched.
63
+ */
64
+ function timeoutPayloadSql(rowAlias) {
65
+ const env = `${rowAlias}.envelope`;
66
+ return `CASE
67
+ WHEN ${isAccumulatorSql(env)}
68
+ THEN ${accumulatedCollectionSql(`${env}->'${ITEMS}'`, 'timeout')}
69
+ WHEN jsonb_typeof(${env}->'${hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY}') = 'object'
70
+ AND COALESCE((${env}->>'${hmsh_escalations_1.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY}')::boolean, false)
71
+ THEN (${env}->'${hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY}')
72
+ || jsonb_build_object('${hmsh_escalations_1.ESCALATION_TRIGGER_KEY}', 'timeout')
73
+ ELSE ${rowAlias}.resolver_payload END`;
74
+ }
75
+ exports.timeoutPayloadSql = timeoutPayloadSql;
76
+ /**
77
+ * The wake message for a resolve statement: on an accumulator row the
78
+ * `{data,data}` slot is rewritten from the committed `resolver_payload`
79
+ * (plus `$resolution`), so the waiter receives exactly what the row stores.
80
+ */
81
+ function resolveWakeMessageSql(fromCTE, messageParam, resolutionParam) {
82
+ return `CASE WHEN ${isAccumulatorSql(`${fromCTE}.envelope`)}
83
+ THEN jsonb_set(${messageParam}::jsonb, '{data,data}',
84
+ ${fromCTE}.resolver_payload::jsonb || COALESCE(${resolutionParam}::jsonb, '{}'::jsonb))::text
85
+ ELSE ${messageParam}::text END`;
86
+ }
87
+ exports.resolveWakeMessageSql = resolveWakeMessageSql;
88
+ function claimPredicateSql(alias, claimParam) {
89
+ return `(${claimParam}::text IS NULL
90
+ OR ${alias}.assigned_to IS NULL
91
+ OR ${alias}.assigned_until IS NULL
92
+ OR (${alias}.assigned_to = ${claimParam}::text AND ${alias}.assigned_until > NOW())
93
+ OR (${alias}.assigned_to <> ${claimParam}::text AND ${alias}.assigned_until <= NOW()))`;
94
+ }
95
+ function pickCte(name, selector, namespace, p) {
96
+ if (!selector)
97
+ return `${name} AS MATERIALIZED (SELECT NULL::uuid AS id WHERE FALSE)`;
98
+ const ns = namespace ? ` AND e.namespace = ${p.add(namespace)}` : '';
99
+ const from = `FROM public.hmsh_escalations e`;
100
+ switch (selector.kind) {
101
+ case 'id':
102
+ return `${name} AS MATERIALIZED (SELECT e.id ${from} WHERE e.id = ${p.add(selector.id)}${ns} LIMIT 1)`;
103
+ case 'signalKey':
104
+ return `${name} AS MATERIALIZED (SELECT e.id ${from} WHERE e.signal_key = ${p.add(selector.signalKey)}${ns} LIMIT 1)`;
105
+ case 'metadata': {
106
+ // The facet names a container: only a pending row carrying the
107
+ // accumulator declaration qualifies, so a release or remediation row
108
+ // sharing the facet (or a closed older generation) is never picked.
109
+ const filter = p.add(JSON.stringify({ [selector.key]: selector.value }));
110
+ const roles = p.add(selector.roles ?? null);
111
+ return `${name} AS MATERIALIZED (
112
+ SELECT e.id ${from}
113
+ WHERE e.metadata @> ${filter}::jsonb
114
+ AND e.metadata ? '${COUNT}'
115
+ AND (${roles}::text[] IS NULL OR e.role = ANY(${roles}::text[]))
116
+ AND e.status = 'pending'${ns}
117
+ ORDER BY e.priority ASC, e.created_at ASC
118
+ LIMIT 1)`;
119
+ }
120
+ }
121
+ }
122
+ /**
123
+ * The shared head of both item statements: pick the container (and the
124
+ * reciprocal), lock both in id order in ONE CTE, and derive each side's
125
+ * item key, payload, and partner id. The reciprocal's item key is the
126
+ * container's id; each side's `other_id` becomes its entry's
127
+ * `reciprocalId`.
128
+ */
129
+ function targetCtes(primary, reciprocal, namespace, p, itemKeyParam, payloadParam, reciprocalPayloadParam) {
130
+ const payload = payloadParam ? `${payloadParam}::jsonb` : 'NULL::jsonb';
131
+ const rPayload = reciprocalPayloadParam
132
+ ? `${reciprocalPayloadParam}::jsonb`
133
+ : 'NULL::jsonb';
134
+ return `
135
+ ${pickCte('primary_pick', primary, namespace, p)},
136
+ ${pickCte('reciprocal_pick', reciprocal, namespace, p)},
137
+ target AS MATERIALIZED (
138
+ SELECT e.id, e.signal_key, e.topic, e.status, e.assigned_to, e.assigned_until,
139
+ e.metadata, e.envelope,
140
+ (e.id = (SELECT id FROM primary_pick)) AS is_primary
141
+ FROM public.hmsh_escalations e
142
+ WHERE e.id IN (SELECT id FROM primary_pick UNION SELECT id FROM reciprocal_pick)
143
+ ORDER BY e.id
144
+ FOR UPDATE
145
+ ),
146
+ sides AS (
147
+ SELECT t.*,
148
+ CASE WHEN t.is_primary THEN ${itemKeyParam}::text
149
+ ELSE (SELECT p.id::text FROM target p WHERE p.is_primary) END AS item_key,
150
+ CASE WHEN t.is_primary THEN ${payload} ELSE ${rPayload} END AS item_payload,
151
+ (SELECT o.id::text FROM target o WHERE o.is_primary <> t.is_primary) AS other_id,
152
+ COALESCE((t.envelope->'${CONFIG}'->>'unique')::boolean, true) AS is_unique,
153
+ COALESCE((t.envelope->'${CONFIG}'->>'resolveAtMax')::boolean, true) AS resolve_at_max,
154
+ (t.metadata->>'${MAX}')::int AS max_items,
155
+ COALESCE(t.envelope->'${ITEMS}', '{}'::jsonb) AS items,
156
+ COALESCE(t.metadata->'${KEYS}', '[]'::jsonb) AS keys
157
+ FROM target t
158
+ )`;
159
+ }
160
+ function wakeCtes(wakes, appId, schemaName, p) {
161
+ if (!wakes.length)
162
+ return { ctes: '', counts: `ARRAY[]::int[] AS wake_counts` };
163
+ const app = p.add(appId);
164
+ const names = [];
165
+ const ctes = wakes
166
+ .map((wake, i) => {
167
+ const name = `wake_${i}`;
168
+ names.push(name);
169
+ const msg = p.add(wake.command.message);
170
+ const sk = p.add(wake.command.forSignalKey);
171
+ const res = p.add(wake.resolutionJson);
172
+ return `,
173
+ ${name} AS (
174
+ INSERT INTO ${schemaName}.engine_streams (stream_name, message, priority)
175
+ SELECT ${app},
176
+ jsonb_set(${msg}::jsonb, '{data,data}',
177
+ w.resolver_payload::jsonb || COALESCE(${res}::jsonb, '{}'::jsonb))::text,
178
+ 5
179
+ FROM written w
180
+ WHERE w.status = 'resolved' AND w.signal_key = ${sk}
181
+ RETURNING id
182
+ )`;
183
+ })
184
+ .join('');
185
+ const counts = `ARRAY[${names.map((n) => `(SELECT COUNT(*) FROM ${n})::int`).join(', ')}] AS wake_counts`;
186
+ return { ctes, counts };
187
+ }
188
+ /**
189
+ * One statement: guarded append of one item on the container (and the
190
+ * container's id on the reciprocal), facet recompute, resolve-at-max with
191
+ * the ordered collection as `resolver_payload`, per-side wake enqueue, and
192
+ * per-side outcome classification. Both writes or neither.
193
+ */
194
+ function buildAccumulateStatement(input) {
195
+ const p = new SqlParams();
196
+ const itemKey = p.add(input.itemKey);
197
+ const payload = p.add(input.payload === null ? null : JSON.stringify(input.payload));
198
+ const rPayload = p.add(input.reciprocalPayload === null
199
+ ? null
200
+ : JSON.stringify(input.reciprocalPayload));
201
+ const meta = p.add(input.metadata ? JSON.stringify(input.metadata) : null);
202
+ const actor = p.add(input.actor);
203
+ const claim = p.add(input.assertClaim);
204
+ const expected = p.add(input.reciprocal ? 2 : 1);
205
+ const head = targetCtes(input.primary, input.reciprocal, input.namespace, p, itemKey, payload, rPayload);
206
+ const { ctes: wakeSql, counts: wakeCounts } = wakeCtes(input.wakes, input.appId, input.schemaName, p);
207
+ const newKeys = `CASE WHEN s.keys ? s.item_key THEN s.keys ELSE s.keys || to_jsonb(s.item_key) END`;
208
+ const newCount = `jsonb_array_length(${newKeys})`;
209
+ const entry = `jsonb_build_object('at', to_jsonb(NOW()))
210
+ || CASE WHEN s.item_payload IS NULL THEN '{}'::jsonb ELSE jsonb_build_object('payload', s.item_payload) END
211
+ || CASE WHEN ${actor}::text IS NULL THEN '{}'::jsonb ELSE jsonb_build_object('actor', ${actor}::text) END
212
+ || CASE WHEN s.other_id IS NULL THEN '{}'::jsonb ELSE jsonb_build_object('reciprocalId', s.other_id) END`;
213
+ const newItems = `s.items || jsonb_build_object(s.item_key, ${entry})`;
214
+ const complete = `(s.max_items IS NOT NULL AND s.resolve_at_max AND ${newCount} >= s.max_items)`;
215
+ const isFull = `(s.max_items IS NOT NULL AND NOT (s.items ? s.item_key) AND jsonb_array_length(s.keys) >= s.max_items)`;
216
+ const isDuplicate = `(s.is_unique AND s.items ? s.item_key)`;
217
+ const sql = `
218
+ WITH ${head},
219
+ eligible AS (
220
+ SELECT s.id FROM sides s
221
+ WHERE s.status = 'pending'
222
+ AND ${isAccumulatorSql('s.envelope')}
223
+ AND s.item_key IS NOT NULL
224
+ AND (NOT s.is_primary OR ${claimPredicateSql('s', claim)})
225
+ AND NOT ${isDuplicate}
226
+ AND NOT ${isFull}
227
+ ),
228
+ written AS (
229
+ UPDATE public.hmsh_escalations e
230
+ SET envelope = COALESCE(e.envelope, '{}'::jsonb)
231
+ || jsonb_build_object('${ITEMS}', ${newItems}),
232
+ metadata = COALESCE(e.metadata, '{}'::jsonb)
233
+ || CASE WHEN s.is_primary THEN COALESCE(${meta}::jsonb, '{}'::jsonb) ELSE '{}'::jsonb END
234
+ || jsonb_build_object('${KEYS}', ${newKeys}, '${COUNT}', ${newCount}),
235
+ status = CASE WHEN ${complete} THEN 'resolved' ELSE e.status END,
236
+ resolved_at = CASE WHEN ${complete} THEN NOW() ELSE e.resolved_at END,
237
+ resolver_payload = CASE WHEN ${complete}
238
+ THEN ${accumulatedCollectionSql(newItems, 'count')}
239
+ ELSE e.resolver_payload END,
240
+ updated_at = NOW()
241
+ FROM sides s
242
+ WHERE e.id = s.id
243
+ AND (SELECT COUNT(*) FROM eligible) = ${expected}::int
244
+ AND (SELECT COUNT(*) FROM target) = ${expected}::int
245
+ RETURNING e.*
246
+ )${wakeSql}
247
+ SELECT s.id, s.is_primary, s.status AS prior_status, s.signal_key, s.topic, s.assigned_to,
248
+ CASE
249
+ WHEN w.id IS NOT NULL AND w.status = 'resolved' THEN 'completed'
250
+ WHEN w.id IS NOT NULL THEN 'accepted'
251
+ WHEN s.status <> 'pending' THEN 'blocked'
252
+ WHEN NOT ${isAccumulatorSql('s.envelope')} THEN 'not-accumulator'
253
+ WHEN s.is_primary AND NOT ${claimPredicateSql('s', claim)} THEN 'claim-blocked'
254
+ WHEN ${isDuplicate} THEN 'duplicate-item'
255
+ WHEN ${isFull} THEN 'full'
256
+ ELSE 'gated'
257
+ END AS outcome,
258
+ row_to_json(w.*) AS entry_json,
259
+ ${wakeCounts}
260
+ FROM sides s
261
+ LEFT JOIN written w ON w.id = s.id
262
+ ORDER BY s.is_primary DESC`;
263
+ return { sql, values: p.values };
264
+ }
265
+ exports.buildAccumulateStatement = buildAccumulateStatement;
266
+ /**
267
+ * One statement: guarded removal of one held item from the container (and
268
+ * of the container's id from the reciprocal), facet recompute, no wake and
269
+ * no status change. Both writes or neither.
270
+ */
271
+ function buildRemoveStatement(input) {
272
+ const p = new SqlParams();
273
+ const itemKey = p.add(input.itemKey);
274
+ const expected = p.add(input.reciprocal ? 2 : 1);
275
+ const head = targetCtes(input.primary, input.reciprocal, input.namespace, p, itemKey, null, null);
276
+ const newKeys = `s.keys - s.item_key`;
277
+ const sql = `
278
+ WITH ${head},
279
+ eligible AS (
280
+ SELECT s.id FROM sides s
281
+ WHERE s.status = 'pending'
282
+ AND ${isAccumulatorSql('s.envelope')}
283
+ AND s.item_key IS NOT NULL
284
+ AND s.items ? s.item_key
285
+ ),
286
+ written AS (
287
+ UPDATE public.hmsh_escalations e
288
+ SET envelope = COALESCE(e.envelope, '{}'::jsonb)
289
+ || jsonb_build_object('${ITEMS}', s.items - s.item_key),
290
+ metadata = COALESCE(e.metadata, '{}'::jsonb)
291
+ || jsonb_build_object('${KEYS}', ${newKeys}, '${COUNT}', jsonb_array_length(${newKeys})),
292
+ updated_at = NOW()
293
+ FROM sides s
294
+ WHERE e.id = s.id
295
+ AND (SELECT COUNT(*) FROM eligible) = ${expected}::int
296
+ AND (SELECT COUNT(*) FROM target) = ${expected}::int
297
+ RETURNING e.*
298
+ )
299
+ SELECT s.id, s.is_primary, s.status AS prior_status,
300
+ CASE
301
+ WHEN w.id IS NOT NULL THEN 'removed'
302
+ WHEN s.status <> 'pending' THEN 'blocked'
303
+ WHEN NOT ${isAccumulatorSql('s.envelope')} THEN 'not-accumulator'
304
+ WHEN NOT (s.items ? s.item_key) THEN 'item-absent'
305
+ ELSE 'gated'
306
+ END AS outcome,
307
+ row_to_json(w.*) AS entry_json
308
+ FROM sides s
309
+ LEFT JOIN written w ON w.id = s.id
310
+ ORDER BY s.is_primary DESC`;
311
+ return { sql, values: p.values };
312
+ }
313
+ exports.buildRemoveStatement = buildRemoveStatement;
@@ -12,6 +12,7 @@ import { JobInterruptOptions } from '../../../../types/job';
12
12
  import { WorkListTaskType } from '../../../../types/task';
13
13
  import { ThrottleOptions } from '../../../../types/quorum';
14
14
  import { StoreService } from '../..';
15
+ import { AccumulateWake } from './escalation-accumulate';
15
16
  import { PostgresClientType } from '../../../../types';
16
17
  import { KVSQL } from './kvsql';
17
18
  import { KVTables } from './kvtables';
@@ -282,10 +283,14 @@ declare class PostgresStoreService extends StoreService<ProviderClient, Provider
282
283
  * Transition a wait's escalation row to `expired` when its resume timer
283
284
  * fires first (`condition(signalId, { ..., timeout })`). Guarded by
284
285
  * `status = 'pending'`: a signal that won the race already resolved the
285
- * row and is never touched. Returns the expired row, or null when no
286
- * pending row carried the key (signal won, or the wait had no escalation).
287
- */
288
- expireEscalationBySignalKey(signalKey: string, namespace?: string, appId?: string): Promise<import('../../../../types/hmsh_escalations').EscalationEntry | null>;
286
+ * row and is never touched. An accumulator row (or a batch row with
287
+ * `partialOnTimeout`) has its `resolver_payload` set to the delivered
288
+ * collection in the same UPDATE, so row truth and the waiter's value
289
+ * agree. Returns the expired row plus the row's prior status, so the
290
+ * caller can tell "a resolve won" (row exists, not pending) from "no
291
+ * row" (the wait carried no escalation).
292
+ */
293
+ expireEscalationBySignalKey(signalKey: string, namespace?: string, appId?: string): Promise<import('../../../../types/hmsh_escalations').ExpireEscalationResult>;
289
294
  private _escalationFilterConditions;
290
295
  listEscalations(params?: import('../../../../types/hmsh_escalations').ListEscalationsParams): Promise<import('../../../../types/hmsh_escalations').EscalationEntry[]>;
291
296
  countEscalations(params?: import('../../../../types/hmsh_escalations').ListEscalationsParams): Promise<number>;
@@ -301,7 +306,7 @@ declare class PostgresStoreService extends StoreService<ProviderClient, Provider
301
306
  * into. Appends the wake params to `params` in place.
302
307
  */
303
308
  private composeEscalationWakeCTE;
304
- resolveEscalation(params: import('../../../../types/hmsh_escalations').ResolveEscalationParams, wakeCommand?: import('../../../../types/hmsh_escalations').EscalationWakeCommand): Promise<import('../../../../types/hmsh_escalations').ResolveEscalationResult & {
309
+ resolveEscalation(params: import('../../../../types/hmsh_escalations').ResolveEscalationParams, wakeCommand?: import('../../../../types/hmsh_escalations').EscalationWakeCommand, resolutionJson?: string | null): Promise<import('../../../../types/hmsh_escalations').ResolveEscalationResult & {
305
310
  signalKey?: string | null;
306
311
  topic?: string | null;
307
312
  wakeEnqueued?: boolean;
@@ -317,7 +322,7 @@ declare class PostgresStoreService extends StoreService<ProviderClient, Provider
317
322
  signalKey: string | null;
318
323
  topic: string | null;
319
324
  } | null>;
320
- resolveEscalationByMetadata(params: import('../../../../types/hmsh_escalations').ResolveByMetadataParams, wakeCommand?: import('../../../../types/hmsh_escalations').EscalationWakeCommand): Promise<import('../../../../types/hmsh_escalations').ResolveEscalationResult & {
325
+ resolveEscalationByMetadata(params: import('../../../../types/hmsh_escalations').ResolveByMetadataParams, wakeCommand?: import('../../../../types/hmsh_escalations').EscalationWakeCommand, resolutionJson?: string | null): Promise<import('../../../../types/hmsh_escalations').ResolveEscalationResult & {
321
326
  signalKey?: string | null;
322
327
  topic?: string | null;
323
328
  wakeEnqueued?: boolean;
@@ -368,6 +373,58 @@ declare class PostgresStoreService extends StoreService<ProviderClient, Provider
368
373
  topic?: string | null;
369
374
  wakeEnqueued?: boolean;
370
375
  }>;
376
+ private _accumulateSelector;
377
+ private _mapAccumulateRows;
378
+ /**
379
+ * Appends one item to an accumulator escalation, and the container's id
380
+ * to the reciprocal row when one is named, in ONE statement: both rows
381
+ * locked in id order, both guards evaluated before either write, both
382
+ * writes or neither. A side reaching `max` (with `resolveAtMax`) resolves
383
+ * with the ordered collection as `resolver_payload` and its wake commits
384
+ * in the same statement. See `buildAccumulateStatement`.
385
+ */
386
+ accumulateEscalationItem(params: import('../../../../types/hmsh_escalations').AccumulateItemParams, wakes?: AccumulateWake[]): Promise<import("../../../../types").AccumulateItemResult & {
387
+ wake?: {
388
+ primary: {
389
+ signalKey: string;
390
+ topic: string;
391
+ wakeEnqueued: boolean;
392
+ };
393
+ reciprocal?: {
394
+ signalKey: string;
395
+ topic: string;
396
+ wakeEnqueued: boolean;
397
+ };
398
+ };
399
+ }>;
400
+ /** By-metadata form of `accumulateEscalationItem`, mirroring the
401
+ * `resolveEscalationByMetadata` selector. No claim assertion. */
402
+ accumulateEscalationItemByMetadata(params: import('../../../../types/hmsh_escalations').AccumulateItemByMetadataParams, wakes?: AccumulateWake[]): Promise<import("../../../../types").AccumulateItemResult & {
403
+ wake?: {
404
+ primary: {
405
+ signalKey: string;
406
+ topic: string;
407
+ wakeEnqueued: boolean;
408
+ };
409
+ reciprocal?: {
410
+ signalKey: string;
411
+ topic: string;
412
+ wakeEnqueued: boolean;
413
+ };
414
+ };
415
+ }>;
416
+ private _runAccumulate;
417
+ private _mapRemoveRows;
418
+ /**
419
+ * Removes one held item from an accumulator escalation (and the
420
+ * container's id from the reciprocal row when named) in ONE guarded
421
+ * statement. Never wakes the waiter and never changes status. See
422
+ * `buildRemoveStatement`.
423
+ */
424
+ removeAccumulatedEscalationItem(params: import('../../../../types/hmsh_escalations').RemoveAccumulatedItemParams): Promise<import('../../../../types/hmsh_escalations').RemoveAccumulatedItemResult>;
425
+ /** By-metadata form of `removeAccumulatedEscalationItem`. */
426
+ removeAccumulatedEscalationItemByMetadata(params: import('../../../../types/hmsh_escalations').RemoveAccumulatedItemByMetadataParams): Promise<import('../../../../types/hmsh_escalations').RemoveAccumulatedItemResult>;
427
+ private _runRemove;
371
428
  cancelEscalation(id: string, namespace?: string, wakeCommand?: import('../../../../types/hmsh_escalations').EscalationWakeCommand): Promise<import('../../../../types/hmsh_escalations').CancelEscalationResult & {
372
429
  wakeEnqueued?: boolean;
373
430
  }>;
@@ -399,7 +456,7 @@ declare class PostgresStoreService extends StoreService<ProviderClient, Provider
399
456
  * names each blocking row and why. Same durability contract as
400
457
  * `resolveEscalation`: each wake commits WITH its row's resolve.
401
458
  */
402
- resolveAllOrNoneEscalations(params: import('../../../../types/hmsh_escalations').ResolveAllOrNoneParams, wakeCommands?: import('../../../../types/hmsh_escalations').EscalationWakeCommand[]): Promise<{
459
+ resolveAllOrNoneEscalations(params: import('../../../../types/hmsh_escalations').ResolveAllOrNoneParams, wakeCommands?: import('../../../../types/hmsh_escalations').EscalationWakeCommand[], resolutionJsons?: (string | null)[]): Promise<{
403
460
  ok: true;
404
461
  entries: import('../../../../types/hmsh_escalations').EscalationEntry[];
405
462
  wakeCount: number;