@hotmeshio/hotmesh 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/package.json +1 -1
- package/build/services/durable/workflow/condition.d.ts +14 -0
- package/build/services/durable/workflow/condition.js +14 -0
- package/build/services/escalations/batch.d.ts +7 -3
- package/build/services/escalations/batch.js +64 -6
- package/build/services/escalations/client.d.ts +4 -2
- package/build/services/escalations/client.js +4 -2
- package/build/services/escalations/fold.d.ts +3 -2
- package/build/services/escalations/fold.js +13 -2
- package/build/services/escalations/index.d.ts +1 -1
- package/build/services/escalations/index.js +2 -1
- package/build/services/hotmesh/index.js +4 -0
- package/build/services/store/providers/postgres/postgres.d.ts +2 -1
- package/build/services/store/providers/postgres/postgres.js +16 -7
- package/build/services/stream/index.d.ts +15 -0
- package/build/services/stream/index.js +23 -0
- package/build/services/stream/providers/postgres/postgres.js +2 -0
- package/build/services/stream/providers/postgres/scout.d.ts +10 -0
- package/build/services/stream/providers/postgres/scout.js +38 -4
- package/build/types/hmsh_escalations.d.ts +32 -0
- package/build/types/hmsh_escalations.js +5 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.js +2 -1
- package/package.json +1 -1
package/build/package.json
CHANGED
|
@@ -111,6 +111,20 @@ import { ConditionQueueConfig } from '../../../types/hmsh_escalations';
|
|
|
111
111
|
* `resolve()` on a batch row remains an admin override that resolves the
|
|
112
112
|
* whole row with the payload given.
|
|
113
113
|
*
|
|
114
|
+
* Entries already satisfied before the wait begins go in `filled`, keyed
|
|
115
|
+
* by item key with their `payload`, `at` (from the source of record), and
|
|
116
|
+
* optional `actor`. They start the row with that progress and are
|
|
117
|
+
* delivered with the collection. A `filled` that covers every key throws,
|
|
118
|
+
* so the caller skips the wait.
|
|
119
|
+
*
|
|
120
|
+
* ```typescript
|
|
121
|
+
* await Durable.workflow.condition(signalId, {
|
|
122
|
+
* role: 'assembly',
|
|
123
|
+
* batch: ['cut', 'weld', 'paint'],
|
|
124
|
+
* filled: { cut: { payload: { station: 'cut-1' }, at: cutAt, actor: 'user-7' } },
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
114
128
|
* ## Placement: call escalation-bearing waits from main workflow code
|
|
115
129
|
*
|
|
116
130
|
* The resolve/signal delivery pipeline routes to the main flow's waiter.
|
|
@@ -117,6 +117,20 @@ const didRun_1 = require("./didRun");
|
|
|
117
117
|
* `resolve()` on a batch row remains an admin override that resolves the
|
|
118
118
|
* whole row with the payload given.
|
|
119
119
|
*
|
|
120
|
+
* Entries already satisfied before the wait begins go in `filled`, keyed
|
|
121
|
+
* by item key with their `payload`, `at` (from the source of record), and
|
|
122
|
+
* optional `actor`. They start the row with that progress and are
|
|
123
|
+
* delivered with the collection. A `filled` that covers every key throws,
|
|
124
|
+
* so the caller skips the wait.
|
|
125
|
+
*
|
|
126
|
+
* ```typescript
|
|
127
|
+
* await Durable.workflow.condition(signalId, {
|
|
128
|
+
* role: 'assembly',
|
|
129
|
+
* batch: ['cut', 'weld', 'paint'],
|
|
130
|
+
* filled: { cut: { payload: { station: 'cut-1' }, at: cutAt, actor: 'user-7' } },
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
120
134
|
* ## Placement: call escalation-bearing waits from main workflow code
|
|
121
135
|
*
|
|
122
136
|
* The resolve/signal delivery pipeline routes to the main flow's waiter.
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { AccumulateConfig } from '../../types/hmsh_escalations';
|
|
1
|
+
import { AccumulateConfig, BatchFilledEntry } 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
|
+
* `filled` entries start satisfied: they are left out of `batch_pending`
|
|
9
|
+
* and written into `batch_items`, `batch_filled_at`, and (when an entry
|
|
10
|
+
* names an actor) `batch_filled_by`. Pure
|
|
8
11
|
* and deterministic — safe on the replayed `condition()` path. Throws
|
|
9
12
|
* synchronously on an invalid declaration so a bad batch never reaches a
|
|
10
13
|
* durable write.
|
|
@@ -12,7 +15,8 @@ import { AccumulateConfig } from '../../types/hmsh_escalations';
|
|
|
12
15
|
export declare function foldBatchConfig<T extends {
|
|
13
16
|
batch?: string[];
|
|
14
17
|
partialOnTimeout?: boolean;
|
|
18
|
+
filled?: Record<string, BatchFilledEntry>;
|
|
15
19
|
accumulate?: AccumulateConfig;
|
|
16
20
|
metadata?: Record<string, unknown>;
|
|
17
21
|
envelope?: Record<string, unknown>;
|
|
18
|
-
}>(config: T): Omit<T, 'batch' | 'partialOnTimeout'>;
|
|
22
|
+
}>(config: T): Omit<T, 'batch' | 'partialOnTimeout' | 'filled'>;
|
|
@@ -10,24 +10,78 @@ const RESERVED_METADATA_KEYS = new Set([
|
|
|
10
10
|
const RESERVED_ENVELOPE_KEYS = new Set([
|
|
11
11
|
hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY,
|
|
12
12
|
hmsh_escalations_1.ESCALATION_BATCH_FILLED_AT_KEY,
|
|
13
|
+
hmsh_escalations_1.ESCALATION_BATCH_FILLED_BY_KEY,
|
|
13
14
|
hmsh_escalations_1.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY,
|
|
14
15
|
]);
|
|
16
|
+
/**
|
|
17
|
+
* Validates `filled` against the declared keys and splits it into the
|
|
18
|
+
* envelope maps. Pure: `at` is normalized from the caller's value, never
|
|
19
|
+
* read from a clock.
|
|
20
|
+
*/
|
|
21
|
+
function foldFilledEntries(batch, filled) {
|
|
22
|
+
const folded = {
|
|
23
|
+
pending: [...batch],
|
|
24
|
+
items: {},
|
|
25
|
+
filledAt: {},
|
|
26
|
+
filledBy: {},
|
|
27
|
+
};
|
|
28
|
+
if (filled === undefined)
|
|
29
|
+
return folded;
|
|
30
|
+
if (!filled || typeof filled !== 'object' || Array.isArray(filled)) {
|
|
31
|
+
throw new Error('filled must be an object keyed by batch item key');
|
|
32
|
+
}
|
|
33
|
+
for (const [key, entry] of Object.entries(filled)) {
|
|
34
|
+
if (!batch.includes(key)) {
|
|
35
|
+
throw new Error(`filled key '${key}' is not declared in batch`);
|
|
36
|
+
}
|
|
37
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
38
|
+
throw new Error(`filled['${key}'] must be an object`);
|
|
39
|
+
}
|
|
40
|
+
const { payload, at, actor } = entry;
|
|
41
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
42
|
+
throw new Error(`filled['${key}'].payload must be an object`);
|
|
43
|
+
}
|
|
44
|
+
const time = typeof at === 'string' ? Date.parse(at) : NaN;
|
|
45
|
+
if (Number.isNaN(time)) {
|
|
46
|
+
throw new Error(`filled['${key}'].at must be an ISO-8601 timestamp`);
|
|
47
|
+
}
|
|
48
|
+
if (actor !== undefined &&
|
|
49
|
+
(typeof actor !== 'string' || actor.length === 0)) {
|
|
50
|
+
throw new Error(`filled['${key}'].actor must be a non-empty string`);
|
|
51
|
+
}
|
|
52
|
+
folded.items[key] = payload;
|
|
53
|
+
folded.filledAt[key] = new Date(time).toISOString();
|
|
54
|
+
if (actor !== undefined)
|
|
55
|
+
folded.filledBy[key] = actor;
|
|
56
|
+
}
|
|
57
|
+
folded.pending = batch.filter((key) => !(key in folded.items));
|
|
58
|
+
if (folded.pending.length === 0) {
|
|
59
|
+
throw new Error('filled satisfies every batch key; there is nothing to wait for');
|
|
60
|
+
}
|
|
61
|
+
return folded;
|
|
62
|
+
}
|
|
15
63
|
/**
|
|
16
64
|
* Folds a `batch` declaration into the escalation's storage shape:
|
|
17
65
|
* queryable facets in `metadata` (`batch_pending`, `batch_count`,
|
|
18
66
|
* `batch_keys`) and the payload accumulator in `envelope`
|
|
19
67
|
* (`batch_items: {}`). `partialOnTimeout` is stored beside the items so
|
|
20
|
-
* the expiry statement delivers the filled items instead of `false`.
|
|
68
|
+
* the expiry statement delivers the filled items instead of `false`.
|
|
69
|
+
* `filled` entries start satisfied: they are left out of `batch_pending`
|
|
70
|
+
* and written into `batch_items`, `batch_filled_at`, and (when an entry
|
|
71
|
+
* names an actor) `batch_filled_by`. Pure
|
|
21
72
|
* and deterministic — safe on the replayed `condition()` path. Throws
|
|
22
73
|
* synchronously on an invalid declaration so a bad batch never reaches a
|
|
23
74
|
* durable write.
|
|
24
75
|
*/
|
|
25
76
|
function foldBatchConfig(config) {
|
|
26
|
-
const { batch, partialOnTimeout, ...rest } = config;
|
|
77
|
+
const { batch, partialOnTimeout, filled, ...rest } = config;
|
|
27
78
|
if (!batch) {
|
|
28
79
|
if (partialOnTimeout !== undefined) {
|
|
29
80
|
throw new Error('partialOnTimeout requires a batch declaration');
|
|
30
81
|
}
|
|
82
|
+
if (filled !== undefined) {
|
|
83
|
+
throw new Error('filled requires a batch declaration');
|
|
84
|
+
}
|
|
31
85
|
return rest;
|
|
32
86
|
}
|
|
33
87
|
if (rest.accumulate) {
|
|
@@ -62,18 +116,22 @@ function foldBatchConfig(config) {
|
|
|
62
116
|
throw new Error(`envelope key '${reserved}' is reserved for batch state`);
|
|
63
117
|
}
|
|
64
118
|
}
|
|
119
|
+
const fills = foldFilledEntries(batch, filled);
|
|
65
120
|
return {
|
|
66
121
|
...rest,
|
|
67
122
|
metadata: {
|
|
68
123
|
...(rest.metadata ?? {}),
|
|
69
|
-
[hmsh_escalations_1.ESCALATION_BATCH_PENDING_KEY]:
|
|
70
|
-
[hmsh_escalations_1.ESCALATION_BATCH_COUNT_KEY]:
|
|
124
|
+
[hmsh_escalations_1.ESCALATION_BATCH_PENDING_KEY]: fills.pending,
|
|
125
|
+
[hmsh_escalations_1.ESCALATION_BATCH_COUNT_KEY]: fills.pending.length,
|
|
71
126
|
[hmsh_escalations_1.ESCALATION_BATCH_KEYS_KEY]: [...batch],
|
|
72
127
|
},
|
|
73
128
|
envelope: {
|
|
74
129
|
...(rest.envelope ?? {}),
|
|
75
|
-
[hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY]:
|
|
76
|
-
[hmsh_escalations_1.ESCALATION_BATCH_FILLED_AT_KEY]:
|
|
130
|
+
[hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY]: fills.items,
|
|
131
|
+
[hmsh_escalations_1.ESCALATION_BATCH_FILLED_AT_KEY]: fills.filledAt,
|
|
132
|
+
...(Object.keys(fills.filledBy).length
|
|
133
|
+
? { [hmsh_escalations_1.ESCALATION_BATCH_FILLED_BY_KEY]: fills.filledBy }
|
|
134
|
+
: {}),
|
|
77
135
|
...(partialOnTimeout
|
|
78
136
|
? { [hmsh_escalations_1.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY]: true }
|
|
79
137
|
: {}),
|
|
@@ -233,8 +233,10 @@ export declare class EscalationClientService {
|
|
|
233
233
|
* from multiple principals. Pass `assertClaim` to opt into the same
|
|
234
234
|
* claim-lock assertion as `resolve()`. Pass `metadata` to merge an outcome
|
|
235
235
|
* patch into the row's GIN-indexed metadata in the same UPDATE (reserved
|
|
236
|
-
* batch keys cannot be overridden). Pass `
|
|
237
|
-
*
|
|
236
|
+
* batch keys cannot be overridden). Pass `actor` to record who filled
|
|
237
|
+
* the item under `envelope.batch_filled_by[itemKey]` in the same UPDATE.
|
|
238
|
+
* Pass `resolvedBy` on submissions to deliver `$resolution` provenance
|
|
239
|
+
* with the completing item's signal.
|
|
238
240
|
*
|
|
239
241
|
* A duplicate submission of an already-filled key returns
|
|
240
242
|
* `outcome: 'duplicate-item'` without touching the row — safe under
|
|
@@ -530,8 +530,10 @@ class EscalationClientService {
|
|
|
530
530
|
* from multiple principals. Pass `assertClaim` to opt into the same
|
|
531
531
|
* claim-lock assertion as `resolve()`. Pass `metadata` to merge an outcome
|
|
532
532
|
* patch into the row's GIN-indexed metadata in the same UPDATE (reserved
|
|
533
|
-
* batch keys cannot be overridden). Pass `
|
|
534
|
-
*
|
|
533
|
+
* batch keys cannot be overridden). Pass `actor` to record who filled
|
|
534
|
+
* the item under `envelope.batch_filled_by[itemKey]` in the same UPDATE.
|
|
535
|
+
* Pass `resolvedBy` on submissions to deliver `$resolution` provenance
|
|
536
|
+
* with the completing item's signal.
|
|
535
537
|
*
|
|
536
538
|
* A duplicate submission of an already-filled key returns
|
|
537
539
|
* `outcome: 'duplicate-item'` without touching the row — safe under
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { AccumulateConfig } from '../../types/hmsh_escalations';
|
|
1
|
+
import { AccumulateConfig, BatchFilledEntry } from '../../types/hmsh_escalations';
|
|
2
2
|
type Foldable = {
|
|
3
3
|
batch?: string[];
|
|
4
4
|
partialOnTimeout?: boolean;
|
|
5
|
+
filled?: Record<string, BatchFilledEntry>;
|
|
5
6
|
accumulate?: AccumulateConfig;
|
|
6
7
|
metadata?: Record<string, unknown>;
|
|
7
8
|
envelope?: Record<string, unknown>;
|
|
@@ -12,5 +13,5 @@ type Foldable = {
|
|
|
12
13
|
* config through untouched. The single entry point for both the
|
|
13
14
|
* `condition()` path and standalone `create()`.
|
|
14
15
|
*/
|
|
15
|
-
export declare function foldEscalationConfig<T extends Foldable>(config: T): Omit<T, 'batch' | 'partialOnTimeout' | 'accumulate'>;
|
|
16
|
+
export declare function foldEscalationConfig<T extends Foldable>(config: T): Omit<T, 'batch' | 'partialOnTimeout' | 'filled' | 'accumulate'>;
|
|
16
17
|
export {};
|
|
@@ -10,19 +10,30 @@ const batch_1 = require("./batch");
|
|
|
10
10
|
* `condition()` path and standalone `create()`.
|
|
11
11
|
*/
|
|
12
12
|
function foldEscalationConfig(config) {
|
|
13
|
-
const { batch, partialOnTimeout, accumulate, ...rest } = config;
|
|
13
|
+
const { batch, partialOnTimeout, filled, accumulate, ...rest } = config;
|
|
14
14
|
if (batch) {
|
|
15
15
|
if (accumulate) {
|
|
16
16
|
throw new Error('accumulate and batch are mutually exclusive');
|
|
17
17
|
}
|
|
18
|
-
return (0, batch_1.foldBatchConfig)({
|
|
18
|
+
return (0, batch_1.foldBatchConfig)({
|
|
19
|
+
...rest,
|
|
20
|
+
batch,
|
|
21
|
+
partialOnTimeout,
|
|
22
|
+
filled,
|
|
23
|
+
});
|
|
19
24
|
}
|
|
20
25
|
if (accumulate) {
|
|
26
|
+
if (filled !== undefined) {
|
|
27
|
+
throw new Error('filled applies to batch only');
|
|
28
|
+
}
|
|
21
29
|
return (0, accumulate_1.foldAccumulateConfig)({ ...rest, accumulate });
|
|
22
30
|
}
|
|
23
31
|
if (partialOnTimeout !== undefined) {
|
|
24
32
|
throw new Error('partialOnTimeout requires a batch declaration');
|
|
25
33
|
}
|
|
34
|
+
if (filled !== undefined) {
|
|
35
|
+
throw new Error('filled requires a batch declaration');
|
|
36
|
+
}
|
|
26
37
|
return rest;
|
|
27
38
|
}
|
|
28
39
|
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_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_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_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_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; } });
|
|
@@ -84,6 +84,7 @@ Object.defineProperty(exports, "ESCALATION_BATCH_COUNT_KEY", { enumerable: true,
|
|
|
84
84
|
Object.defineProperty(exports, "ESCALATION_BATCH_KEYS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_KEYS_KEY; } });
|
|
85
85
|
Object.defineProperty(exports, "ESCALATION_BATCH_ITEMS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY; } });
|
|
86
86
|
Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_AT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FILLED_AT_KEY; } });
|
|
87
|
+
Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_BY_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FILLED_BY_KEY; } });
|
|
87
88
|
Object.defineProperty(exports, "ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY; } });
|
|
88
89
|
Object.defineProperty(exports, "ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH; } });
|
|
89
90
|
Object.defineProperty(exports, "ESCALATION_ACCUMULATE_COUNT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_ACCUMULATE_COUNT_KEY; } });
|
|
@@ -28,6 +28,7 @@ const utils_1 = require("../../modules/utils");
|
|
|
28
28
|
const factory_1 = require("../connector/factory");
|
|
29
29
|
const logger_1 = require("../logger");
|
|
30
30
|
const router_1 = require("../router");
|
|
31
|
+
const stream_1 = require("../stream");
|
|
31
32
|
const registry_1 = require("../stream/registry");
|
|
32
33
|
// Submodules
|
|
33
34
|
const Validation = __importStar(require("./validation"));
|
|
@@ -503,6 +504,9 @@ class HotMesh {
|
|
|
503
504
|
this.disconnecting = true;
|
|
504
505
|
try {
|
|
505
506
|
await router_1.Router.stopConsuming();
|
|
507
|
+
//streams outside a consuming router (extra engines, clients,
|
|
508
|
+
//readonly routers) stop their pollers before the disconnect
|
|
509
|
+
await stream_1.StreamService.stopAll();
|
|
506
510
|
//the stopped consumers are forgotten so a later init in this
|
|
507
511
|
//process starts live ones instead of reusing stopped routers
|
|
508
512
|
registry_1.StreamConsumerRegistry.clear();
|
|
@@ -341,7 +341,8 @@ declare class PostgresStoreService extends StoreService<ProviderClient, Provider
|
|
|
341
341
|
/**
|
|
342
342
|
* The shared body of both batch-item store ops: guarded fill of one item
|
|
343
343
|
* into `envelope.batch_items` (with its `batch_filled_at` stamp — the
|
|
344
|
-
* database clock, row truth
|
|
344
|
+
* database clock, row truth — and, when an actor is named, its
|
|
345
|
+
* `batch_filled_by` entry), `batch_pending`/`batch_count` recompute,
|
|
345
346
|
* resolve-on-last-item with the assembled collection as
|
|
346
347
|
* `resolver_payload`, wake enqueue, and outcome classification — one
|
|
347
348
|
* atomic statement. `targetCTE` supplies the row selector; it must expose
|
|
@@ -2159,14 +2159,15 @@ class PostgresStoreService extends __1.StoreService {
|
|
|
2159
2159
|
/**
|
|
2160
2160
|
* The shared body of both batch-item store ops: guarded fill of one item
|
|
2161
2161
|
* into `envelope.batch_items` (with its `batch_filled_at` stamp — the
|
|
2162
|
-
* database clock, row truth
|
|
2162
|
+
* database clock, row truth — and, when an actor is named, its
|
|
2163
|
+
* `batch_filled_by` entry), `batch_pending`/`batch_count` recompute,
|
|
2163
2164
|
* resolve-on-last-item with the assembled collection as
|
|
2164
2165
|
* `resolver_payload`, wake enqueue, and outcome classification — one
|
|
2165
2166
|
* atomic statement. `targetCTE` supplies the row selector; it must expose
|
|
2166
2167
|
* id, signal_key, topic, status, assigned_to, assigned_until, batch_keys,
|
|
2167
2168
|
* batch_pending.
|
|
2168
2169
|
*/
|
|
2169
|
-
_batchItemStatement(targetCTE, itemKeyIdx, payloadIdx, metaIdx, claimIdx, wakeCTE, wakeCount) {
|
|
2170
|
+
_batchItemStatement(targetCTE, itemKeyIdx, payloadIdx, metaIdx, claimIdx, actorIdx, wakeCTE, wakeCount) {
|
|
2170
2171
|
const remaining = `jsonb_array_length((e.metadata->'batch_pending') - $${itemKeyIdx}::text)`;
|
|
2171
2172
|
return `
|
|
2172
2173
|
WITH target AS MATERIALIZED (${targetCTE}),
|
|
@@ -2179,7 +2180,13 @@ class PostgresStoreService extends __1.StoreService {
|
|
|
2179
2180
|
|| jsonb_build_object($${itemKeyIdx}::text, $${payloadIdx}::jsonb),
|
|
2180
2181
|
'batch_filled_at',
|
|
2181
2182
|
COALESCE(e.envelope->'batch_filled_at', '{}'::jsonb)
|
|
2182
|
-
|| jsonb_build_object($${itemKeyIdx}::text, to_jsonb(NOW())))
|
|
2183
|
+
|| jsonb_build_object($${itemKeyIdx}::text, to_jsonb(NOW())))
|
|
2184
|
+
|| CASE WHEN $${actorIdx}::text IS NULL THEN '{}'::jsonb
|
|
2185
|
+
ELSE jsonb_build_object(
|
|
2186
|
+
'batch_filled_by',
|
|
2187
|
+
COALESCE(e.envelope->'batch_filled_by', '{}'::jsonb)
|
|
2188
|
+
|| jsonb_build_object($${itemKeyIdx}::text, $${actorIdx}::text))
|
|
2189
|
+
END,
|
|
2183
2190
|
metadata = COALESCE(e.metadata, '{}'::jsonb)
|
|
2184
2191
|
|| COALESCE($${metaIdx}::jsonb, '{}'::jsonb)
|
|
2185
2192
|
|| jsonb_build_object(
|
|
@@ -2264,7 +2271,7 @@ class PostgresStoreService extends __1.StoreService {
|
|
|
2264
2271
|
* collection ONLY (never into the stored `resolver_payload`).
|
|
2265
2272
|
*/
|
|
2266
2273
|
async resolveEscalationBatchItem(params, wakeCommand, resolutionJson) {
|
|
2267
|
-
const { id, signalKey, namespace, itemKey, payload, metadata, assertClaim } = params;
|
|
2274
|
+
const { id, signalKey, namespace, itemKey, payload, metadata, assertClaim, actor } = params;
|
|
2268
2275
|
if ((id ? 1 : 0) + (signalKey ? 1 : 0) !== 1) {
|
|
2269
2276
|
throw new Error('resolveBatchItem requires exactly one of `id` or `signalKey`');
|
|
2270
2277
|
}
|
|
@@ -2274,6 +2281,7 @@ class PostgresStoreService extends __1.StoreService {
|
|
|
2274
2281
|
JSON.stringify(payload ?? {}),
|
|
2275
2282
|
metadata ? JSON.stringify(metadata) : null,
|
|
2276
2283
|
assertClaim ?? null,
|
|
2284
|
+
actor ?? null,
|
|
2277
2285
|
];
|
|
2278
2286
|
let nsClause = '';
|
|
2279
2287
|
if (namespace) {
|
|
@@ -2288,7 +2296,7 @@ class PostgresStoreService extends __1.StoreService {
|
|
|
2288
2296
|
FROM public.hmsh_escalations
|
|
2289
2297
|
WHERE ${id ? 'id' : 'signal_key'} = $1${nsClause}
|
|
2290
2298
|
LIMIT 1 FOR UPDATE`;
|
|
2291
|
-
const result = await this.pgClient.query(this._batchItemStatement(targetCTE, 2, 3, 4, 5, wakeCTE, wakeCount), sqlParams);
|
|
2299
|
+
const result = await this.pgClient.query(this._batchItemStatement(targetCTE, 2, 3, 4, 5, 6, wakeCTE, wakeCount), sqlParams);
|
|
2292
2300
|
return this._mapBatchItemRow(result.rows[0], assertClaim ?? undefined);
|
|
2293
2301
|
}
|
|
2294
2302
|
/**
|
|
@@ -2298,7 +2306,7 @@ class PostgresStoreService extends __1.StoreService {
|
|
|
2298
2306
|
* variant, matching the by-metadata precedent.
|
|
2299
2307
|
*/
|
|
2300
2308
|
async resolveEscalationBatchItemByMetadata(params, wakeCommand, resolutionJson) {
|
|
2301
|
-
const { key, value, roles, namespace, itemKey, payload, metadata } = params;
|
|
2309
|
+
const { key, value, roles, namespace, itemKey, payload, metadata, actor } = params;
|
|
2302
2310
|
const filter = JSON.stringify({ [key]: value });
|
|
2303
2311
|
const sqlParams = [
|
|
2304
2312
|
filter,
|
|
@@ -2307,6 +2315,7 @@ class PostgresStoreService extends __1.StoreService {
|
|
|
2307
2315
|
metadata ? JSON.stringify(metadata) : null,
|
|
2308
2316
|
null,
|
|
2309
2317
|
roles ?? null,
|
|
2318
|
+
actor ?? null,
|
|
2310
2319
|
];
|
|
2311
2320
|
let nsClause = '';
|
|
2312
2321
|
if (namespace) {
|
|
@@ -2325,7 +2334,7 @@ class PostgresStoreService extends __1.StoreService {
|
|
|
2325
2334
|
AND status IN ('pending', 'cancelled')
|
|
2326
2335
|
ORDER BY priority ASC, created_at ASC
|
|
2327
2336
|
LIMIT 1 FOR UPDATE`;
|
|
2328
|
-
const result = await this.pgClient.query(this._batchItemStatement(targetCTE, 2, 3, 4, 5, wakeCTE, wakeCount), sqlParams);
|
|
2337
|
+
const result = await this.pgClient.query(this._batchItemStatement(targetCTE, 2, 3, 4, 5, 7, wakeCTE, wakeCount), sqlParams);
|
|
2329
2338
|
return this._mapBatchItemRow(result.rows[0]);
|
|
2330
2339
|
}
|
|
2331
2340
|
_accumulateSelector(sel, label) {
|
|
@@ -10,6 +10,21 @@ export declare abstract class StreamService<ClientProvider extends ProviderClien
|
|
|
10
10
|
protected logger: ILogger;
|
|
11
11
|
protected appId: string;
|
|
12
12
|
protected config: StreamConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Services running background work (pollers, scouts) in this process.
|
|
15
|
+
* `HotMesh.stop()` drains them through {@link StreamService.stopAll}, so
|
|
16
|
+
* no loop outlives the connections it queries.
|
|
17
|
+
*/
|
|
18
|
+
private static running;
|
|
19
|
+
/** Registers this service's background work for process shutdown. */
|
|
20
|
+
protected trackBackgroundWork(): void;
|
|
21
|
+
/** Forgets this service once its own `cleanup()` has run. */
|
|
22
|
+
protected untrackBackgroundWork(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Runs `cleanup()` on every service still running background work.
|
|
25
|
+
* Each cleanup logs its own faults; one failure never blocks the rest.
|
|
26
|
+
*/
|
|
27
|
+
static stopAll(): Promise<void>;
|
|
13
28
|
constructor(streamClient: ClientProvider, storeClient: ProviderClient, config?: StreamConfig);
|
|
14
29
|
abstract init(namespace: string, appId: string, logger: ILogger): Promise<void>;
|
|
15
30
|
abstract mintKey(type: KeyType, params: KeyStoreParams): string;
|
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StreamService = void 0;
|
|
4
4
|
class StreamService {
|
|
5
|
+
/** Registers this service's background work for process shutdown. */
|
|
6
|
+
trackBackgroundWork() {
|
|
7
|
+
StreamService.running.add(this);
|
|
8
|
+
}
|
|
9
|
+
/** Forgets this service once its own `cleanup()` has run. */
|
|
10
|
+
untrackBackgroundWork() {
|
|
11
|
+
StreamService.running.delete(this);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Runs `cleanup()` on every service still running background work.
|
|
15
|
+
* Each cleanup logs its own faults; one failure never blocks the rest.
|
|
16
|
+
*/
|
|
17
|
+
static async stopAll() {
|
|
18
|
+
const services = [...StreamService.running];
|
|
19
|
+
StreamService.running.clear();
|
|
20
|
+
await Promise.all(services.map((service) => Promise.resolve(service.cleanup?.()).catch(() => undefined)));
|
|
21
|
+
}
|
|
5
22
|
constructor(streamClient, storeClient, config = {}) {
|
|
6
23
|
// Adaptive reservation timeout — set by the consumption manager
|
|
7
24
|
// based on stream depth. Providers read this when reserving messages.
|
|
@@ -13,4 +30,10 @@ class StreamService {
|
|
|
13
30
|
this.config = config;
|
|
14
31
|
}
|
|
15
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Services running background work (pollers, scouts) in this process.
|
|
35
|
+
* `HotMesh.stop()` drains them through {@link StreamService.stopAll}, so
|
|
36
|
+
* no loop outlives the connections it queries.
|
|
37
|
+
*/
|
|
38
|
+
StreamService.running = new Set();
|
|
16
39
|
exports.StreamService = StreamService;
|
|
@@ -80,6 +80,7 @@ class PostgresStreamService extends index_1.StreamService {
|
|
|
80
80
|
this.notificationManager.setupClientNotificationHandler(this);
|
|
81
81
|
this.notificationManager.startClientFallbackPoller(this.checkForMissedMessages.bind(this));
|
|
82
82
|
this.scoutManager?.startRouterScoutPoller();
|
|
83
|
+
this.trackBackgroundWork();
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
isNotificationsEnabled() {
|
|
@@ -415,6 +416,7 @@ class PostgresStreamService extends index_1.StreamService {
|
|
|
415
416
|
};
|
|
416
417
|
}
|
|
417
418
|
async cleanup() {
|
|
419
|
+
this.untrackBackgroundWork();
|
|
418
420
|
if (this.scoutManager) {
|
|
419
421
|
await this.scoutManager.stopRouterScoutPoller();
|
|
420
422
|
}
|
|
@@ -15,6 +15,8 @@ export declare class ScoutManager {
|
|
|
15
15
|
private logger;
|
|
16
16
|
private isScout;
|
|
17
17
|
private shouldStopScout;
|
|
18
|
+
private roleResetTimer;
|
|
19
|
+
private pause;
|
|
18
20
|
private pollCount;
|
|
19
21
|
private totalNotifications;
|
|
20
22
|
private scoutStartTime;
|
|
@@ -36,6 +38,14 @@ export declare class ScoutManager {
|
|
|
36
38
|
* Main polling loop for the router scout.
|
|
37
39
|
*/
|
|
38
40
|
private pollForVisibleMessagesLoop;
|
|
41
|
+
/**
|
|
42
|
+
* A loop pause that `stopRouterScoutPoller()` ends early, so a stopped
|
|
43
|
+
* scout leaves no timer behind.
|
|
44
|
+
*/
|
|
45
|
+
private pauseFor;
|
|
46
|
+
private endPause;
|
|
47
|
+
/** True once `stopRouterScoutPoller()` has run. */
|
|
48
|
+
isStopped(): boolean;
|
|
39
49
|
/**
|
|
40
50
|
* Poll for visible messages and trigger notifications for any found.
|
|
41
51
|
*/
|
|
@@ -17,6 +17,8 @@ class ScoutManager {
|
|
|
17
17
|
this.logger = logger;
|
|
18
18
|
this.isScout = false;
|
|
19
19
|
this.shouldStopScout = false;
|
|
20
|
+
this.roleResetTimer = null;
|
|
21
|
+
this.pause = null;
|
|
20
22
|
// Polling metrics
|
|
21
23
|
this.pollCount = 0;
|
|
22
24
|
this.totalNotifications = 0;
|
|
@@ -42,6 +44,11 @@ class ScoutManager {
|
|
|
42
44
|
*/
|
|
43
45
|
async stopRouterScoutPoller() {
|
|
44
46
|
this.shouldStopScout = true;
|
|
47
|
+
if (this.roleResetTimer) {
|
|
48
|
+
clearTimeout(this.roleResetTimer);
|
|
49
|
+
this.roleResetTimer = null;
|
|
50
|
+
}
|
|
51
|
+
this.endPause();
|
|
45
52
|
if (this.isScout) {
|
|
46
53
|
await this.releaseScoutRole('router');
|
|
47
54
|
this.isScout = false;
|
|
@@ -62,7 +69,8 @@ class ScoutManager {
|
|
|
62
69
|
this.logger.debug('postgres-stream-router-scout-role-acquired', {
|
|
63
70
|
appId: this.appId,
|
|
64
71
|
});
|
|
65
|
-
setTimeout(() => {
|
|
72
|
+
this.roleResetTimer = setTimeout(() => {
|
|
73
|
+
this.roleResetTimer = null;
|
|
66
74
|
this.isScout = false;
|
|
67
75
|
this.scoutStartTime = null;
|
|
68
76
|
}, enums_1.HMSH_ROUTER_SCOUT_INTERVAL_SECONDS * 1000);
|
|
@@ -81,19 +89,45 @@ class ScoutManager {
|
|
|
81
89
|
// We're the scout - poll for visible messages frequently
|
|
82
90
|
await this.pollForVisibleMessages();
|
|
83
91
|
// Sleep for the short polling interval
|
|
84
|
-
await
|
|
92
|
+
await this.pauseFor(this.getRouterScoutInterval());
|
|
85
93
|
}
|
|
86
94
|
else {
|
|
87
95
|
// Not the scout - sleep longer before trying to acquire role again
|
|
88
|
-
await
|
|
96
|
+
await this.pauseFor(enums_1.HMSH_ROUTER_SCOUT_INTERVAL_SECONDS * 1000);
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
99
|
catch (error) {
|
|
92
100
|
this.logger.error('postgres-stream-router-scout-loop-error', { error });
|
|
93
|
-
await
|
|
101
|
+
await this.pauseFor(1000); // Brief pause on error
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* A loop pause that `stopRouterScoutPoller()` ends early, so a stopped
|
|
107
|
+
* scout leaves no timer behind.
|
|
108
|
+
*/
|
|
109
|
+
pauseFor(ms) {
|
|
110
|
+
if (this.shouldStopScout)
|
|
111
|
+
return Promise.resolve();
|
|
112
|
+
return new Promise((resolve) => {
|
|
113
|
+
const timer = setTimeout(() => {
|
|
114
|
+
this.pause = null;
|
|
115
|
+
resolve();
|
|
116
|
+
}, ms);
|
|
117
|
+
this.pause = { timer, resolve };
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
endPause() {
|
|
121
|
+
if (!this.pause)
|
|
122
|
+
return;
|
|
123
|
+
clearTimeout(this.pause.timer);
|
|
124
|
+
this.pause.resolve();
|
|
125
|
+
this.pause = null;
|
|
126
|
+
}
|
|
127
|
+
/** True once `stopRouterScoutPoller()` has run. */
|
|
128
|
+
isStopped() {
|
|
129
|
+
return this.shouldStopScout;
|
|
130
|
+
}
|
|
97
131
|
/**
|
|
98
132
|
* Poll for visible messages and trigger notifications for any found.
|
|
99
133
|
*/
|
|
@@ -36,6 +36,18 @@ export interface ConditionQueueConfig {
|
|
|
36
36
|
* existing batch waiters are unchanged.
|
|
37
37
|
*/
|
|
38
38
|
partialOnTimeout?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* With `batch`, entries already satisfied when the row is created (for
|
|
41
|
+
* example, received before the wait began). Each key must be declared in
|
|
42
|
+
* `batch`; at least one key must remain open. The entries are folded into
|
|
43
|
+
* the same creation INSERT: `batch_pending` / `batch_count` start without
|
|
44
|
+
* them, and `batch_items` / `batch_filled_at` / `batch_filled_by` hold
|
|
45
|
+
* their payload, time, and actor, so progress and completion count them
|
|
46
|
+
* and the completing signal delivers them with the rest. Pure input:
|
|
47
|
+
* `at` comes from the source of record, never a fresh clock in the
|
|
48
|
+
* workflow, so the replayed `condition()` folds the same row.
|
|
49
|
+
*/
|
|
50
|
+
filled?: Record<string, BatchFilledEntry>;
|
|
39
51
|
/**
|
|
40
52
|
* Declares the wait as an open accumulator: items arrive over time via
|
|
41
53
|
* `accumulateItem()` and the collection is delivered on every terminal
|
|
@@ -344,6 +356,8 @@ export interface CreateEscalationParams {
|
|
|
344
356
|
batch?: string[];
|
|
345
357
|
/** See {@link ConditionQueueConfig.partialOnTimeout}. */
|
|
346
358
|
partialOnTimeout?: boolean;
|
|
359
|
+
/** See {@link ConditionQueueConfig.filled}. */
|
|
360
|
+
filled?: Record<string, BatchFilledEntry>;
|
|
347
361
|
/**
|
|
348
362
|
* Declares the row as an open accumulator. See
|
|
349
363
|
* {@link ConditionQueueConfig.accumulate}. Standalone rows (no
|
|
@@ -475,6 +489,19 @@ export declare const ESCALATION_BATCH_ITEMS_KEY = "batch_items";
|
|
|
475
489
|
* stamped by the DATABASE clock inside the same guarded fill statement —
|
|
476
490
|
* row truth, not caller clocks. The attempt timeline for free. */
|
|
477
491
|
export declare const ESCALATION_BATCH_FILLED_AT_KEY = "batch_filled_at";
|
|
492
|
+
/** Envelope key: per-item actors (`Record<itemKey, string>`), written by a
|
|
493
|
+
* fill that names an `actor` and by `filled` entries that carry one. Absent
|
|
494
|
+
* until the first attributed fill. */
|
|
495
|
+
export declare const ESCALATION_BATCH_FILLED_BY_KEY = "batch_filled_by";
|
|
496
|
+
/** One batch entry satisfied at creation. See {@link ConditionQueueConfig.filled}. */
|
|
497
|
+
export interface BatchFilledEntry<P = Record<string, unknown>> {
|
|
498
|
+
/** Stored under `envelope.batch_items[itemKey]`, delivered with the collection. */
|
|
499
|
+
payload: P;
|
|
500
|
+
/** ISO-8601: when the entry was satisfied, from the source of record. */
|
|
501
|
+
at: string;
|
|
502
|
+
/** Stored under `envelope.batch_filled_by[itemKey]`. */
|
|
503
|
+
actor?: string;
|
|
504
|
+
}
|
|
478
505
|
/** Item keys are non-empty strings up to this length. Any characters are
|
|
479
506
|
* accepted (keys are always parameterized and stored as jsonb text); prefer
|
|
480
507
|
* URL/query-friendly names (e.g. `u1-L`) for endpoint ergonomics. */
|
|
@@ -707,6 +734,9 @@ export interface ResolveBatchItemParams {
|
|
|
707
734
|
* claim-agnostic without it (multiple contributors are the norm). See
|
|
708
735
|
* {@link ResolveEscalationParams.assertClaim}. */
|
|
709
736
|
assertClaim?: string;
|
|
737
|
+
/** Recorded under `envelope.batch_filled_by[itemKey]` in the same
|
|
738
|
+
* statement as the fill. */
|
|
739
|
+
actor?: string;
|
|
710
740
|
/** Resolver identity. Delivered under `$resolution` ONLY on the completing
|
|
711
741
|
* item's signal. See {@link ResolveEscalationParams.resolvedBy}. */
|
|
712
742
|
resolvedBy?: ResolvedByIdentity;
|
|
@@ -722,6 +752,8 @@ export interface ResolveBatchItemByMetadataParams {
|
|
|
722
752
|
/** Merge patch for the matched row's `metadata` — distinct from the
|
|
723
753
|
* `key`/`value` selector. */
|
|
724
754
|
metadata?: Record<string, unknown>;
|
|
755
|
+
/** See {@link ResolveBatchItemParams.actor}. */
|
|
756
|
+
actor?: string;
|
|
725
757
|
resolvedBy?: ResolvedByIdentity;
|
|
726
758
|
}
|
|
727
759
|
/**
|
|
@@ -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_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_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`. */
|
|
@@ -19,6 +19,10 @@ exports.ESCALATION_BATCH_ITEMS_KEY = 'batch_items';
|
|
|
19
19
|
* stamped by the DATABASE clock inside the same guarded fill statement —
|
|
20
20
|
* row truth, not caller clocks. The attempt timeline for free. */
|
|
21
21
|
exports.ESCALATION_BATCH_FILLED_AT_KEY = 'batch_filled_at';
|
|
22
|
+
/** Envelope key: per-item actors (`Record<itemKey, string>`), written by a
|
|
23
|
+
* fill that names an `actor` and by `filled` entries that carry one. Absent
|
|
24
|
+
* until the first attributed fill. */
|
|
25
|
+
exports.ESCALATION_BATCH_FILLED_BY_KEY = 'batch_filled_by';
|
|
22
26
|
/** Item keys are non-empty strings up to this length. Any characters are
|
|
23
27
|
* accepted (keys are always parameterized and stored as jsonb text); prefer
|
|
24
28
|
* URL/query-friendly names (e.g. `u1-L`) for endpoint ergonomics. */
|
package/build/types/index.d.ts
CHANGED
|
@@ -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_PARTIAL_ON_TIMEOUT_KEY, ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH, 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, 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';
|
package/build/types/index.js
CHANGED
|
@@ -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_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_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");
|
|
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "ESCALATION_BATCH_COUNT_KEY", { enumerable: true,
|
|
|
25
25
|
Object.defineProperty(exports, "ESCALATION_BATCH_KEYS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_KEYS_KEY; } });
|
|
26
26
|
Object.defineProperty(exports, "ESCALATION_BATCH_ITEMS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY; } });
|
|
27
27
|
Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_AT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FILLED_AT_KEY; } });
|
|
28
|
+
Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_BY_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FILLED_BY_KEY; } });
|
|
28
29
|
Object.defineProperty(exports, "ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_PARTIAL_ON_TIMEOUT_KEY; } });
|
|
29
30
|
Object.defineProperty(exports, "ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH; } });
|
|
30
31
|
Object.defineProperty(exports, "ESCALATION_ACCUMULATE_COUNT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_ACCUMULATE_COUNT_KEY; } });
|