@hotmeshio/hotmesh 0.28.0 → 0.28.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -7,6 +7,10 @@ const RESERVED_METADATA_KEYS = new Set([
7
7
  hmsh_escalations_1.ESCALATION_BATCH_COUNT_KEY,
8
8
  hmsh_escalations_1.ESCALATION_BATCH_KEYS_KEY,
9
9
  ]);
10
+ const RESERVED_ENVELOPE_KEYS = new Set([
11
+ hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY,
12
+ hmsh_escalations_1.ESCALATION_BATCH_FILLED_AT_KEY,
13
+ ]);
10
14
  /**
11
15
  * Folds a `batch` declaration into the escalation's storage shape:
12
16
  * queryable facets in `metadata` (`batch_pending`, `batch_count`,
@@ -27,6 +31,9 @@ function foldBatchConfig(config) {
27
31
  if (typeof key !== 'string' || key.length === 0) {
28
32
  throw new Error('batch item keys must be non-empty strings');
29
33
  }
34
+ if (key.length > hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH) {
35
+ throw new Error(`batch item keys must be at most ${hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH} characters: '${key.slice(0, 32)}…'`);
36
+ }
30
37
  if (seen.has(key)) {
31
38
  throw new Error(`batch item keys must be unique: '${key}'`);
32
39
  }
@@ -37,8 +44,10 @@ function foldBatchConfig(config) {
37
44
  throw new Error(`metadata key '${reserved}' is reserved for batch state`);
38
45
  }
39
46
  }
40
- if (rest.envelope && hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY in rest.envelope) {
41
- throw new Error(`envelope key '${hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY}' is reserved for batch state`);
47
+ for (const reserved of RESERVED_ENVELOPE_KEYS) {
48
+ if (rest.envelope && reserved in rest.envelope) {
49
+ throw new Error(`envelope key '${reserved}' is reserved for batch state`);
50
+ }
42
51
  }
43
52
  return {
44
53
  ...rest,
@@ -51,6 +60,7 @@ function foldBatchConfig(config) {
51
60
  envelope: {
52
61
  ...(rest.envelope ?? {}),
53
62
  [hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY]: {},
63
+ [hmsh_escalations_1.ESCALATION_BATCH_FILLED_AT_KEY]: {},
54
64
  },
55
65
  };
56
66
  }
@@ -66,4 +66,4 @@ export { EscalationsClass as Escalations };
66
66
  export { EscalationClientService };
67
67
  export { ESCALATION_RESOLUTION_KEY } from './client';
68
68
  export { foldBatchConfig } from './batch';
69
- export { ESCALATION_BATCH_PENDING_KEY, ESCALATION_BATCH_COUNT_KEY, ESCALATION_BATCH_KEYS_KEY, ESCALATION_BATCH_ITEMS_KEY, } from '../../types/hmsh_escalations';
69
+ export { ESCALATION_BATCH_PENDING_KEY, ESCALATION_BATCH_COUNT_KEY, ESCALATION_BATCH_KEYS_KEY, ESCALATION_BATCH_ITEMS_KEY, ESCALATION_BATCH_FILLED_AT_KEY, ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH, } from '../../types/hmsh_escalations';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ESCALATION_BATCH_ITEMS_KEY = exports.ESCALATION_BATCH_KEYS_KEY = exports.ESCALATION_BATCH_COUNT_KEY = exports.ESCALATION_BATCH_PENDING_KEY = exports.foldBatchConfig = exports.ESCALATION_RESOLUTION_KEY = exports.EscalationClientService = exports.Escalations = void 0;
3
+ 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 = 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; } });
@@ -78,3 +78,5 @@ Object.defineProperty(exports, "ESCALATION_BATCH_PENDING_KEY", { enumerable: tru
78
78
  Object.defineProperty(exports, "ESCALATION_BATCH_COUNT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_COUNT_KEY; } });
79
79
  Object.defineProperty(exports, "ESCALATION_BATCH_KEYS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_KEYS_KEY; } });
80
80
  Object.defineProperty(exports, "ESCALATION_BATCH_ITEMS_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEMS_KEY; } });
81
+ Object.defineProperty(exports, "ESCALATION_BATCH_FILLED_AT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_FILLED_AT_KEY; } });
82
+ Object.defineProperty(exports, "ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH; } });
@@ -335,7 +335,8 @@ declare class PostgresStoreService extends StoreService<ProviderClient, Provider
335
335
  private composeBatchWakeCTE;
336
336
  /**
337
337
  * The shared body of both batch-item store ops: guarded fill of one item
338
- * into `envelope.batch_items`, `batch_pending`/`batch_count` recompute,
338
+ * into `envelope.batch_items` (with its `batch_filled_at` stamp — the
339
+ * database clock, row truth), `batch_pending`/`batch_count` recompute,
339
340
  * resolve-on-last-item with the assembled collection as
340
341
  * `resolver_payload`, wake enqueue, and outcome classification — one
341
342
  * atomic statement. `targetCTE` supplies the row selector; it must expose
@@ -2126,7 +2126,8 @@ class PostgresStoreService extends __1.StoreService {
2126
2126
  }
2127
2127
  /**
2128
2128
  * The shared body of both batch-item store ops: guarded fill of one item
2129
- * into `envelope.batch_items`, `batch_pending`/`batch_count` recompute,
2129
+ * into `envelope.batch_items` (with its `batch_filled_at` stamp — the
2130
+ * database clock, row truth), `batch_pending`/`batch_count` recompute,
2130
2131
  * resolve-on-last-item with the assembled collection as
2131
2132
  * `resolver_payload`, wake enqueue, and outcome classification — one
2132
2133
  * atomic statement. `targetCTE` supplies the row selector; it must expose
@@ -2140,9 +2141,13 @@ class PostgresStoreService extends __1.StoreService {
2140
2141
  filled AS (
2141
2142
  UPDATE public.hmsh_escalations e
2142
2143
  SET envelope = COALESCE(e.envelope, '{}'::jsonb)
2143
- || jsonb_build_object('batch_items',
2144
+ || jsonb_build_object(
2145
+ 'batch_items',
2144
2146
  COALESCE(e.envelope->'batch_items', '{}'::jsonb)
2145
- || jsonb_build_object($${itemKeyIdx}::text, $${payloadIdx}::jsonb)),
2147
+ || jsonb_build_object($${itemKeyIdx}::text, $${payloadIdx}::jsonb),
2148
+ 'batch_filled_at',
2149
+ COALESCE(e.envelope->'batch_filled_at', '{}'::jsonb)
2150
+ || jsonb_build_object($${itemKeyIdx}::text, to_jsonb(NOW()))),
2146
2151
  metadata = COALESCE(e.metadata, '{}'::jsonb)
2147
2152
  || COALESCE($${metaIdx}::jsonb, '{}'::jsonb)
2148
2153
  || jsonb_build_object(
@@ -441,8 +441,18 @@ export declare const ESCALATION_BATCH_COUNT_KEY = "batch_count";
441
441
  /** Metadata facet: the full declared item-key list, immutable after creation. */
442
442
  export declare const ESCALATION_BATCH_KEYS_KEY = "batch_keys";
443
443
  /** Envelope key: the payload accumulator (`Record<itemKey, payload>`).
444
- * Payloads are plumbing, not facets — they live in the unindexed envelope. */
444
+ * Payloads are plumbing, not facets — they live in the unindexed envelope.
445
+ * Payload keys are caller-owned: the platform will never reserve names
446
+ * inside `batch_items` values. */
445
447
  export declare const ESCALATION_BATCH_ITEMS_KEY = "batch_items";
448
+ /** Envelope key: per-item fill timestamps (`Record<itemKey, iso8601>`),
449
+ * stamped by the DATABASE clock inside the same guarded fill statement —
450
+ * row truth, not caller clocks. The attempt timeline for free. */
451
+ export declare const ESCALATION_BATCH_FILLED_AT_KEY = "batch_filled_at";
452
+ /** Item keys are non-empty strings up to this length. Any characters are
453
+ * accepted (keys are always parameterized and stored as jsonb text); prefer
454
+ * URL/query-friendly names (e.g. `u1-L`) for endpoint ergonomics. */
455
+ export declare const ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = 128;
446
456
  /**
447
457
  * Outcome of a `resolveBatchItem()` call.
448
458
  * - `completed` — this was the LAST item: the row resolved and the waiting
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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_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;
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`. */
@@ -11,5 +11,15 @@ exports.ESCALATION_BATCH_COUNT_KEY = 'batch_count';
11
11
  /** Metadata facet: the full declared item-key list, immutable after creation. */
12
12
  exports.ESCALATION_BATCH_KEYS_KEY = 'batch_keys';
13
13
  /** Envelope key: the payload accumulator (`Record<itemKey, payload>`).
14
- * Payloads are plumbing, not facets — they live in the unindexed envelope. */
14
+ * Payloads are plumbing, not facets — they live in the unindexed envelope.
15
+ * Payload keys are caller-owned: the platform will never reserve names
16
+ * inside `batch_items` values. */
15
17
  exports.ESCALATION_BATCH_ITEMS_KEY = 'batch_items';
18
+ /** Envelope key: per-item fill timestamps (`Record<itemKey, iso8601>`),
19
+ * stamped by the DATABASE clock inside the same guarded fill statement —
20
+ * row truth, not caller clocks. The attempt timeline for free. */
21
+ exports.ESCALATION_BATCH_FILLED_AT_KEY = 'batch_filled_at';
22
+ /** Item keys are non-empty strings up to this length. Any characters are
23
+ * accepted (keys are always parameterized and stored as jsonb text); prefer
24
+ * URL/query-friendly names (e.g. `u1-L`) for endpoint ergonomics. */
25
+ exports.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH = 128;
@@ -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, } 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_ITEM_KEY_MAX_LENGTH, } 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_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_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 = 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");
@@ -24,3 +24,5 @@ Object.defineProperty(exports, "ESCALATION_BATCH_PENDING_KEY", { enumerable: tru
24
24
  Object.defineProperty(exports, "ESCALATION_BATCH_COUNT_KEY", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_COUNT_KEY; } });
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
+ 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_ITEM_KEY_MAX_LENGTH", { enumerable: true, get: function () { return hmsh_escalations_1.ESCALATION_BATCH_ITEM_KEY_MAX_LENGTH; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",