@metamask-previews/bridge-status-controller 73.1.0-preview-e12e4a38f → 74.0.0-preview-4f9d41d
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/CHANGELOG.md +9 -1
- package/dist/bridge-status-controller.cjs +167 -21
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +6 -1
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +6 -1
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +167 -21
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/constants.cjs +1 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +1 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs +12 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -1
- package/dist/quote-status-manager/constants.cjs +181 -0
- package/dist/quote-status-manager/constants.cjs.map +1 -0
- package/dist/quote-status-manager/constants.d.cts +137 -0
- package/dist/quote-status-manager/constants.d.cts.map +1 -0
- package/dist/quote-status-manager/constants.d.mts +137 -0
- package/dist/quote-status-manager/constants.d.mts.map +1 -0
- package/dist/quote-status-manager/constants.mjs +178 -0
- package/dist/quote-status-manager/constants.mjs.map +1 -0
- package/dist/quote-status-manager/errors.cjs +51 -0
- package/dist/quote-status-manager/errors.cjs.map +1 -0
- package/dist/quote-status-manager/errors.d.cts +45 -0
- package/dist/quote-status-manager/errors.d.cts.map +1 -0
- package/dist/quote-status-manager/errors.d.mts +45 -0
- package/dist/quote-status-manager/errors.d.mts.map +1 -0
- package/dist/quote-status-manager/errors.mjs +46 -0
- package/dist/quote-status-manager/errors.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.cjs +241 -0
- package/dist/quote-status-manager/quote-status-api-service.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.d.cts +93 -0
- package/dist/quote-status-manager/quote-status-api-service.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.d.mts +93 -0
- package/dist/quote-status-manager/quote-status-api-service.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-api-service.mjs +237 -0
- package/dist/quote-status-manager/quote-status-api-service.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.cjs +271 -0
- package/dist/quote-status-manager/quote-status-entry-store.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.cts +144 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.mts +144 -0
- package/dist/quote-status-manager/quote-status-entry-store.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-entry-store.mjs +267 -0
- package/dist/quote-status-manager/quote-status-entry-store.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.cjs +29 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.cts +32 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.mts +32 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.mjs +25 -0
- package/dist/quote-status-manager/quote-status-get-with-retry-outcome.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.cjs +107 -0
- package/dist/quote-status-manager/quote-status-state-fsm.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.cts +57 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.mts +57 -0
- package/dist/quote-status-manager/quote-status-state-fsm.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-state-fsm.mjs +103 -0
- package/dist/quote-status-manager/quote-status-state-fsm.mjs.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.cjs +27 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.cjs.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.cts +30 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.cts.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.mts +30 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.mts.map +1 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.mjs +23 -0
- package/dist/quote-status-manager/quote-status-update-with-retry-outcome.mjs.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.cjs +477 -0
- package/dist/quote-status-manager/quotes-status-manager.cjs.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.d.cts +124 -0
- package/dist/quote-status-manager/quotes-status-manager.d.cts.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.d.mts +124 -0
- package/dist/quote-status-manager/quotes-status-manager.d.mts.map +1 -0
- package/dist/quote-status-manager/quotes-status-manager.mjs +473 -0
- package/dist/quote-status-manager/quotes-status-manager.mjs.map +1 -0
- package/dist/quote-status-manager/types.cjs +8 -0
- package/dist/quote-status-manager/types.cjs.map +1 -0
- package/dist/quote-status-manager/types.d.cts +145 -0
- package/dist/quote-status-manager/types.d.cts.map +1 -0
- package/dist/quote-status-manager/types.d.mts +145 -0
- package/dist/quote-status-manager/types.d.mts.map +1 -0
- package/dist/quote-status-manager/types.mjs +6 -0
- package/dist/quote-status-manager/types.mjs.map +1 -0
- package/dist/quote-status-manager/utils.cjs +11 -0
- package/dist/quote-status-manager/utils.cjs.map +1 -0
- package/dist/quote-status-manager/utils.d.cts +7 -0
- package/dist/quote-status-manager/utils.d.cts.map +1 -0
- package/dist/quote-status-manager/utils.d.mts +7 -0
- package/dist/quote-status-manager/utils.d.mts.map +1 -0
- package/dist/quote-status-manager/utils.mjs +7 -0
- package/dist/quote-status-manager/utils.mjs.map +1 -0
- package/dist/quote-status-manager/validators.cjs +44 -0
- package/dist/quote-status-manager/validators.cjs.map +1 -0
- package/dist/quote-status-manager/validators.d.cts +172 -0
- package/dist/quote-status-manager/validators.d.cts.map +1 -0
- package/dist/quote-status-manager/validators.d.mts +172 -0
- package/dist/quote-status-manager/validators.d.mts.map +1 -0
- package/dist/quote-status-manager/validators.mjs +39 -0
- package/dist/quote-status-manager/validators.mjs.map +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +15 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +15 -3
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -1
- package/dist/utils/history.cjs +1 -0
- package/dist/utils/history.cjs.map +1 -1
- package/dist/utils/history.d.cts.map +1 -1
- package/dist/utils/history.d.mts.map +1 -1
- package/dist/utils/history.mjs +1 -0
- package/dist/utils/history.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { QuoteStatusEntryStoreOptions, QuoteStatusPersistEntry, QuoteStatusRuntimeEntry } from "./types.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* In-memory store for quote status update entries.
|
|
4
|
+
*
|
|
5
|
+
* The store deduplicates entries by key, tracks timestamps used for retries and
|
|
6
|
+
* TTL eviction, and persists a cloned snapshot on each mutating operation.
|
|
7
|
+
*/
|
|
8
|
+
export declare class QuoteStatusEntryStore {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a deterministic key for persisted quote status entries.
|
|
12
|
+
*
|
|
13
|
+
* @param entry - Entry identity fields.
|
|
14
|
+
* @param entry.quoteId - Quote identifier.
|
|
15
|
+
* @param entry.srcTxHash - Source transaction hash.
|
|
16
|
+
* @returns Stable key in `${quoteId}:${srcTxHash}` format.
|
|
17
|
+
*/
|
|
18
|
+
static hash(entry: Pick<QuoteStatusPersistEntry, 'quoteId' | 'srcTxHash'>): string;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a quote status entry store.
|
|
21
|
+
*
|
|
22
|
+
* @param options - Store dependencies and retention configuration.
|
|
23
|
+
* @param options.onPersistUpdates - Callback invoked with cloned snapshot updates.
|
|
24
|
+
* @param options.entryTtlMs - Entry time-to-live in milliseconds.
|
|
25
|
+
* @param options.initial - Optional initial persisted entries used to seed the store.
|
|
26
|
+
*/
|
|
27
|
+
constructor({ onPersistUpdates, entryTtlMs, initial, }: QuoteStatusEntryStoreOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Adds a new entry when the key is not already present.
|
|
30
|
+
*
|
|
31
|
+
* If an entry already exists, only a missing `txMetaId` is backfilled to avoid
|
|
32
|
+
* resetting timestamps and creating duplicate submission updates.
|
|
33
|
+
*
|
|
34
|
+
* @param key - Unique map key for the entry.
|
|
35
|
+
* @param value - Entry payload without internal timestamps.
|
|
36
|
+
* @param value.quoteId - Quote identifier.
|
|
37
|
+
* @param value.srcTxHash - Source transaction hash.
|
|
38
|
+
* @param value.status - Latest quote status.
|
|
39
|
+
* @param value.txMetaId - Optional transaction metadata identifier.
|
|
40
|
+
* @returns The tracked entry (the existing one when the key is already
|
|
41
|
+
* present, otherwise the newly created entry).
|
|
42
|
+
*/
|
|
43
|
+
put(key: string, value: Omit<QuoteStatusRuntimeEntry, 'createdAt' | 'lastAttemptAt'>): QuoteStatusRuntimeEntry;
|
|
44
|
+
/**
|
|
45
|
+
* Returns an iterator over all tracked entries.
|
|
46
|
+
*
|
|
47
|
+
* Stale entries are transitioned to {@link QuoteStatusState.Expired} first (but
|
|
48
|
+
* kept in the store), so the iterator reflects their up-to-date terminal state.
|
|
49
|
+
*
|
|
50
|
+
* @returns An iterator over the currently tracked entries.
|
|
51
|
+
*/
|
|
52
|
+
values(): IterableIterator<QuoteStatusRuntimeEntry>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns every tracked entry matching the provided quote identifier.
|
|
55
|
+
*
|
|
56
|
+
* Stale entries are transitioned to {@link QuoteStatusState.Expired} first so
|
|
57
|
+
* callers observe their up-to-date terminal state.
|
|
58
|
+
*
|
|
59
|
+
* @param quoteId - Quote identifier to match.
|
|
60
|
+
* @returns The matching entries (empty when none exist).
|
|
61
|
+
*/
|
|
62
|
+
getByQuoteId(quoteId: string): QuoteStatusRuntimeEntry[];
|
|
63
|
+
/**
|
|
64
|
+
* Number of entries currently tracked by the store.
|
|
65
|
+
*
|
|
66
|
+
* Note that this includes terminal entries (`Completed`/`Expired`), which are
|
|
67
|
+
* retained rather than evicted; call {@link expireStaleEntries} (or
|
|
68
|
+
* {@link values}) first when an up-to-date view of entry states is required.
|
|
69
|
+
*
|
|
70
|
+
* @returns The count of tracked entries.
|
|
71
|
+
*/
|
|
72
|
+
get size(): number;
|
|
73
|
+
/**
|
|
74
|
+
* Looks up an entry by its transaction metadata identifier.
|
|
75
|
+
*
|
|
76
|
+
* If the matching entry has exceeded its TTL it is transitioned to
|
|
77
|
+
* {@link QuoteStatusState.Expired} (but kept) before being returned.
|
|
78
|
+
*
|
|
79
|
+
* @param txMetaId - Transaction metadata identifier to search for.
|
|
80
|
+
* @returns The matching entry, or `null` if none exists.
|
|
81
|
+
*/
|
|
82
|
+
getByTxMetaId(txMetaId: string): QuoteStatusRuntimeEntry | null;
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves an entry by key.
|
|
85
|
+
*
|
|
86
|
+
* If the entry has exceeded its TTL it is transitioned to
|
|
87
|
+
* {@link QuoteStatusState.Expired} (but kept) before being returned.
|
|
88
|
+
*
|
|
89
|
+
* @param key - Unique map key for the entry.
|
|
90
|
+
* @returns The matching entry, or `null` if absent.
|
|
91
|
+
*/
|
|
92
|
+
get(key: string): QuoteStatusRuntimeEntry | null;
|
|
93
|
+
/**
|
|
94
|
+
* Persists the current snapshot after an in-place mutation of a tracked entry.
|
|
95
|
+
*
|
|
96
|
+
* Used when fields such as `lastAttemptAt` are mutated directly on an entry
|
|
97
|
+
* the caller already holds. No-ops if the entry is no longer tracked (e.g. the
|
|
98
|
+
* store was cleared in the meantime), so persistence only reflects live entries.
|
|
99
|
+
*
|
|
100
|
+
* @param entry - The mutated entry to persist.
|
|
101
|
+
*/
|
|
102
|
+
update(entry: QuoteStatusRuntimeEntry): void;
|
|
103
|
+
/**
|
|
104
|
+
* Transitions every stale entry to {@link QuoteStatusState.Expired}, keeping it
|
|
105
|
+
* in the store.
|
|
106
|
+
*
|
|
107
|
+
* Expired entries are retained so that later interactions with the same quote
|
|
108
|
+
* (e.g. a duplicate `reportSubmitted`) can be recognized and rejected. Each
|
|
109
|
+
* transition persists the updated snapshot via the entry's FSM subscription;
|
|
110
|
+
* already-terminal entries cannot transition and are left untouched.
|
|
111
|
+
*/
|
|
112
|
+
expireStaleEntries(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Determines whether an entry has outlived the configured TTL.
|
|
115
|
+
*
|
|
116
|
+
* Expiry is measured from the entry's `createdAt` timestamp, not its last
|
|
117
|
+
* attempt, so an entry's total lifetime is bounded regardless of retries.
|
|
118
|
+
*
|
|
119
|
+
* @param entry - Entry to check.
|
|
120
|
+
* @returns `true` if the entry's age exceeds the TTL.
|
|
121
|
+
*/
|
|
122
|
+
entryHasExpired(entry: QuoteStatusRuntimeEntry): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Transitions an entry to {@link QuoteStatusState.Expired} (keeping it) if it
|
|
125
|
+
* has exceeded its TTL.
|
|
126
|
+
*
|
|
127
|
+
* The transition persists the updated snapshot via the entry's FSM
|
|
128
|
+
* subscription. Already-terminal entries cannot transition and are left
|
|
129
|
+
* untouched.
|
|
130
|
+
*
|
|
131
|
+
* @param entry - Entry to check and possibly expire.
|
|
132
|
+
* @returns `true` if the entry was stale, otherwise `false`.
|
|
133
|
+
*/
|
|
134
|
+
expireEntryIfStale(entry: QuoteStatusRuntimeEntry): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Removes every entry from the store.
|
|
137
|
+
*
|
|
138
|
+
* Detaches each entry's FSM listeners before clearing to prevent leaks and
|
|
139
|
+
* stale persist callbacks. Does not emit a persistence update; callers are
|
|
140
|
+
* expected to use this during teardown.
|
|
141
|
+
*/
|
|
142
|
+
clear(): void;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=quote-status-entry-store.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-status-entry-store.d.cts","sourceRoot":"","sources":["../../src/quote-status-manager/quote-status-entry-store.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,uBAAuB,EACxB,oBAAgB;AAEjB;;;;;GAKG;AACH,qBAAa,qBAAqB;;IAKhC;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,CACT,KAAK,EAAE,IAAI,CAAC,uBAAuB,EAAE,SAAS,GAAG,WAAW,CAAC,GAC5D,MAAM;IAQT;;;;;;;OAOG;gBACS,EACV,gBAAgB,EAChB,UAAU,EACV,OAAO,GACR,EAAE,4BAA4B;IAqC/B;;;;;;;;;;;;;;OAcG;IACH,GAAG,CACD,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,IAAI,CAAC,uBAAuB,EAAE,WAAW,GAAG,eAAe,CAAC,GAClE,uBAAuB;IAyB1B;;;;;;;OAOG;IACH,MAAM,IAAI,gBAAgB,CAAC,uBAAuB,CAAC;IAKnD;;;;;;;;OAQG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB,EAAE;IAaxD;;;;;;;;OAQG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;;;;OAQG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI;IAW/D;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI;IAUhD;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,IAAI;IAuB5C;;;;;;;;OAQG;IACH,kBAAkB,IAAI,IAAI;IAQ1B;;;;;;;;OAQG;IACH,eAAe,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO;IAKxD;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO;IAS3D;;;;;;OAMG;IACH,KAAK,IAAI,IAAI;CAOd"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { QuoteStatusEntryStoreOptions, QuoteStatusPersistEntry, QuoteStatusRuntimeEntry } from "./types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* In-memory store for quote status update entries.
|
|
4
|
+
*
|
|
5
|
+
* The store deduplicates entries by key, tracks timestamps used for retries and
|
|
6
|
+
* TTL eviction, and persists a cloned snapshot on each mutating operation.
|
|
7
|
+
*/
|
|
8
|
+
export declare class QuoteStatusEntryStore {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a deterministic key for persisted quote status entries.
|
|
12
|
+
*
|
|
13
|
+
* @param entry - Entry identity fields.
|
|
14
|
+
* @param entry.quoteId - Quote identifier.
|
|
15
|
+
* @param entry.srcTxHash - Source transaction hash.
|
|
16
|
+
* @returns Stable key in `${quoteId}:${srcTxHash}` format.
|
|
17
|
+
*/
|
|
18
|
+
static hash(entry: Pick<QuoteStatusPersistEntry, 'quoteId' | 'srcTxHash'>): string;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a quote status entry store.
|
|
21
|
+
*
|
|
22
|
+
* @param options - Store dependencies and retention configuration.
|
|
23
|
+
* @param options.onPersistUpdates - Callback invoked with cloned snapshot updates.
|
|
24
|
+
* @param options.entryTtlMs - Entry time-to-live in milliseconds.
|
|
25
|
+
* @param options.initial - Optional initial persisted entries used to seed the store.
|
|
26
|
+
*/
|
|
27
|
+
constructor({ onPersistUpdates, entryTtlMs, initial, }: QuoteStatusEntryStoreOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Adds a new entry when the key is not already present.
|
|
30
|
+
*
|
|
31
|
+
* If an entry already exists, only a missing `txMetaId` is backfilled to avoid
|
|
32
|
+
* resetting timestamps and creating duplicate submission updates.
|
|
33
|
+
*
|
|
34
|
+
* @param key - Unique map key for the entry.
|
|
35
|
+
* @param value - Entry payload without internal timestamps.
|
|
36
|
+
* @param value.quoteId - Quote identifier.
|
|
37
|
+
* @param value.srcTxHash - Source transaction hash.
|
|
38
|
+
* @param value.status - Latest quote status.
|
|
39
|
+
* @param value.txMetaId - Optional transaction metadata identifier.
|
|
40
|
+
* @returns The tracked entry (the existing one when the key is already
|
|
41
|
+
* present, otherwise the newly created entry).
|
|
42
|
+
*/
|
|
43
|
+
put(key: string, value: Omit<QuoteStatusRuntimeEntry, 'createdAt' | 'lastAttemptAt'>): QuoteStatusRuntimeEntry;
|
|
44
|
+
/**
|
|
45
|
+
* Returns an iterator over all tracked entries.
|
|
46
|
+
*
|
|
47
|
+
* Stale entries are transitioned to {@link QuoteStatusState.Expired} first (but
|
|
48
|
+
* kept in the store), so the iterator reflects their up-to-date terminal state.
|
|
49
|
+
*
|
|
50
|
+
* @returns An iterator over the currently tracked entries.
|
|
51
|
+
*/
|
|
52
|
+
values(): IterableIterator<QuoteStatusRuntimeEntry>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns every tracked entry matching the provided quote identifier.
|
|
55
|
+
*
|
|
56
|
+
* Stale entries are transitioned to {@link QuoteStatusState.Expired} first so
|
|
57
|
+
* callers observe their up-to-date terminal state.
|
|
58
|
+
*
|
|
59
|
+
* @param quoteId - Quote identifier to match.
|
|
60
|
+
* @returns The matching entries (empty when none exist).
|
|
61
|
+
*/
|
|
62
|
+
getByQuoteId(quoteId: string): QuoteStatusRuntimeEntry[];
|
|
63
|
+
/**
|
|
64
|
+
* Number of entries currently tracked by the store.
|
|
65
|
+
*
|
|
66
|
+
* Note that this includes terminal entries (`Completed`/`Expired`), which are
|
|
67
|
+
* retained rather than evicted; call {@link expireStaleEntries} (or
|
|
68
|
+
* {@link values}) first when an up-to-date view of entry states is required.
|
|
69
|
+
*
|
|
70
|
+
* @returns The count of tracked entries.
|
|
71
|
+
*/
|
|
72
|
+
get size(): number;
|
|
73
|
+
/**
|
|
74
|
+
* Looks up an entry by its transaction metadata identifier.
|
|
75
|
+
*
|
|
76
|
+
* If the matching entry has exceeded its TTL it is transitioned to
|
|
77
|
+
* {@link QuoteStatusState.Expired} (but kept) before being returned.
|
|
78
|
+
*
|
|
79
|
+
* @param txMetaId - Transaction metadata identifier to search for.
|
|
80
|
+
* @returns The matching entry, or `null` if none exists.
|
|
81
|
+
*/
|
|
82
|
+
getByTxMetaId(txMetaId: string): QuoteStatusRuntimeEntry | null;
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves an entry by key.
|
|
85
|
+
*
|
|
86
|
+
* If the entry has exceeded its TTL it is transitioned to
|
|
87
|
+
* {@link QuoteStatusState.Expired} (but kept) before being returned.
|
|
88
|
+
*
|
|
89
|
+
* @param key - Unique map key for the entry.
|
|
90
|
+
* @returns The matching entry, or `null` if absent.
|
|
91
|
+
*/
|
|
92
|
+
get(key: string): QuoteStatusRuntimeEntry | null;
|
|
93
|
+
/**
|
|
94
|
+
* Persists the current snapshot after an in-place mutation of a tracked entry.
|
|
95
|
+
*
|
|
96
|
+
* Used when fields such as `lastAttemptAt` are mutated directly on an entry
|
|
97
|
+
* the caller already holds. No-ops if the entry is no longer tracked (e.g. the
|
|
98
|
+
* store was cleared in the meantime), so persistence only reflects live entries.
|
|
99
|
+
*
|
|
100
|
+
* @param entry - The mutated entry to persist.
|
|
101
|
+
*/
|
|
102
|
+
update(entry: QuoteStatusRuntimeEntry): void;
|
|
103
|
+
/**
|
|
104
|
+
* Transitions every stale entry to {@link QuoteStatusState.Expired}, keeping it
|
|
105
|
+
* in the store.
|
|
106
|
+
*
|
|
107
|
+
* Expired entries are retained so that later interactions with the same quote
|
|
108
|
+
* (e.g. a duplicate `reportSubmitted`) can be recognized and rejected. Each
|
|
109
|
+
* transition persists the updated snapshot via the entry's FSM subscription;
|
|
110
|
+
* already-terminal entries cannot transition and are left untouched.
|
|
111
|
+
*/
|
|
112
|
+
expireStaleEntries(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Determines whether an entry has outlived the configured TTL.
|
|
115
|
+
*
|
|
116
|
+
* Expiry is measured from the entry's `createdAt` timestamp, not its last
|
|
117
|
+
* attempt, so an entry's total lifetime is bounded regardless of retries.
|
|
118
|
+
*
|
|
119
|
+
* @param entry - Entry to check.
|
|
120
|
+
* @returns `true` if the entry's age exceeds the TTL.
|
|
121
|
+
*/
|
|
122
|
+
entryHasExpired(entry: QuoteStatusRuntimeEntry): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Transitions an entry to {@link QuoteStatusState.Expired} (keeping it) if it
|
|
125
|
+
* has exceeded its TTL.
|
|
126
|
+
*
|
|
127
|
+
* The transition persists the updated snapshot via the entry's FSM
|
|
128
|
+
* subscription. Already-terminal entries cannot transition and are left
|
|
129
|
+
* untouched.
|
|
130
|
+
*
|
|
131
|
+
* @param entry - Entry to check and possibly expire.
|
|
132
|
+
* @returns `true` if the entry was stale, otherwise `false`.
|
|
133
|
+
*/
|
|
134
|
+
expireEntryIfStale(entry: QuoteStatusRuntimeEntry): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Removes every entry from the store.
|
|
137
|
+
*
|
|
138
|
+
* Detaches each entry's FSM listeners before clearing to prevent leaks and
|
|
139
|
+
* stale persist callbacks. Does not emit a persistence update; callers are
|
|
140
|
+
* expected to use this during teardown.
|
|
141
|
+
*/
|
|
142
|
+
clear(): void;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=quote-status-entry-store.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-status-entry-store.d.mts","sourceRoot":"","sources":["../../src/quote-status-manager/quote-status-entry-store.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,uBAAuB,EACxB,oBAAgB;AAEjB;;;;;GAKG;AACH,qBAAa,qBAAqB;;IAKhC;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,CACT,KAAK,EAAE,IAAI,CAAC,uBAAuB,EAAE,SAAS,GAAG,WAAW,CAAC,GAC5D,MAAM;IAQT;;;;;;;OAOG;gBACS,EACV,gBAAgB,EAChB,UAAU,EACV,OAAO,GACR,EAAE,4BAA4B;IAqC/B;;;;;;;;;;;;;;OAcG;IACH,GAAG,CACD,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,IAAI,CAAC,uBAAuB,EAAE,WAAW,GAAG,eAAe,CAAC,GAClE,uBAAuB;IAyB1B;;;;;;;OAOG;IACH,MAAM,IAAI,gBAAgB,CAAC,uBAAuB,CAAC;IAKnD;;;;;;;;OAQG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB,EAAE;IAaxD;;;;;;;;OAQG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;;;;OAQG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI;IAW/D;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI;IAUhD;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,IAAI;IAuB5C;;;;;;;;OAQG;IACH,kBAAkB,IAAI,IAAI;IAQ1B;;;;;;;;OAQG;IACH,eAAe,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO;IAKxD;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO;IAS3D;;;;;;OAMG;IACH,KAAK,IAAI,IAAI;CAOd"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _QuoteStatusEntryStore_instances, _QuoteStatusEntryStore_items, _QuoteStatusEntryStore_entryTtlMs, _QuoteStatusEntryStore_onPersistUpdates, _QuoteStatusEntryStore_subscribeToStatusUpdates, _QuoteStatusEntryStore_persistToState;
|
|
13
|
+
import { QuoteStatusState } from "./constants.mjs";
|
|
14
|
+
import { QuoteStatusStateFsm } from "./quote-status-state-fsm.mjs";
|
|
15
|
+
/**
|
|
16
|
+
* In-memory store for quote status update entries.
|
|
17
|
+
*
|
|
18
|
+
* The store deduplicates entries by key, tracks timestamps used for retries and
|
|
19
|
+
* TTL eviction, and persists a cloned snapshot on each mutating operation.
|
|
20
|
+
*/
|
|
21
|
+
export class QuoteStatusEntryStore {
|
|
22
|
+
/**
|
|
23
|
+
* Creates a deterministic key for persisted quote status entries.
|
|
24
|
+
*
|
|
25
|
+
* @param entry - Entry identity fields.
|
|
26
|
+
* @param entry.quoteId - Quote identifier.
|
|
27
|
+
* @param entry.srcTxHash - Source transaction hash.
|
|
28
|
+
* @returns Stable key in `${quoteId}:${srcTxHash}` format.
|
|
29
|
+
*/
|
|
30
|
+
static hash(entry) {
|
|
31
|
+
return `${entry.quoteId}:${entry.srcTxHash}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates a quote status entry store.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Store dependencies and retention configuration.
|
|
37
|
+
* @param options.onPersistUpdates - Callback invoked with cloned snapshot updates.
|
|
38
|
+
* @param options.entryTtlMs - Entry time-to-live in milliseconds.
|
|
39
|
+
* @param options.initial - Optional initial persisted entries used to seed the store.
|
|
40
|
+
*/
|
|
41
|
+
constructor({ onPersistUpdates, entryTtlMs, initial, }) {
|
|
42
|
+
_QuoteStatusEntryStore_instances.add(this);
|
|
43
|
+
_QuoteStatusEntryStore_items.set(this, void 0);
|
|
44
|
+
_QuoteStatusEntryStore_entryTtlMs.set(this, void 0);
|
|
45
|
+
_QuoteStatusEntryStore_onPersistUpdates.set(this, void 0);
|
|
46
|
+
__classPrivateFieldSet(this, _QuoteStatusEntryStore_onPersistUpdates, onPersistUpdates, "f");
|
|
47
|
+
__classPrivateFieldSet(this, _QuoteStatusEntryStore_entryTtlMs, entryTtlMs, "f");
|
|
48
|
+
__classPrivateFieldSet(this, _QuoteStatusEntryStore_items, new Map(Object.entries(initial ?? {}).map(([key, entry]) => {
|
|
49
|
+
const quoteStatusStateFsm = new QuoteStatusStateFsm(entry.status);
|
|
50
|
+
return [
|
|
51
|
+
key,
|
|
52
|
+
// Entries from `initialDeferredUpdates` come from Immer-managed controller
|
|
53
|
+
// state, which deep-freezes all nested objects. Cloning each entry here
|
|
54
|
+
// ensures the in-memory queue holds mutable objects so that mutations
|
|
55
|
+
// (e.g. updating `status` or `lastAttemptAt`) work correctly without
|
|
56
|
+
// throwing a "read only property" error.
|
|
57
|
+
{ ...entry, status: quoteStatusStateFsm },
|
|
58
|
+
];
|
|
59
|
+
})), "f");
|
|
60
|
+
// Subscribe each seeded FSM after the map (and `#onPersistUpdates`) are set
|
|
61
|
+
// so that any later state transition persists the updated snapshot.
|
|
62
|
+
for (const entry of __classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").values()) {
|
|
63
|
+
__classPrivateFieldGet(this, _QuoteStatusEntryStore_instances, "m", _QuoteStatusEntryStore_subscribeToStatusUpdates).call(this, entry);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Adds a new entry when the key is not already present.
|
|
68
|
+
*
|
|
69
|
+
* If an entry already exists, only a missing `txMetaId` is backfilled to avoid
|
|
70
|
+
* resetting timestamps and creating duplicate submission updates.
|
|
71
|
+
*
|
|
72
|
+
* @param key - Unique map key for the entry.
|
|
73
|
+
* @param value - Entry payload without internal timestamps.
|
|
74
|
+
* @param value.quoteId - Quote identifier.
|
|
75
|
+
* @param value.srcTxHash - Source transaction hash.
|
|
76
|
+
* @param value.status - Latest quote status.
|
|
77
|
+
* @param value.txMetaId - Optional transaction metadata identifier.
|
|
78
|
+
* @returns The tracked entry (the existing one when the key is already
|
|
79
|
+
* present, otherwise the newly created entry).
|
|
80
|
+
*/
|
|
81
|
+
put(key, value) {
|
|
82
|
+
// If an entry for this key is already in the queue
|
|
83
|
+
// do not overwrite it. Re-enqueueing would reset state and
|
|
84
|
+
// could cause duplicate SUBMITTED events.
|
|
85
|
+
const existing = __classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").get(key);
|
|
86
|
+
if (existing) {
|
|
87
|
+
if (!existing.txMetaId && value.txMetaId) {
|
|
88
|
+
existing.txMetaId = value.txMetaId;
|
|
89
|
+
__classPrivateFieldGet(this, _QuoteStatusEntryStore_instances, "m", _QuoteStatusEntryStore_persistToState).call(this);
|
|
90
|
+
}
|
|
91
|
+
return existing;
|
|
92
|
+
}
|
|
93
|
+
const now = Date.now();
|
|
94
|
+
const entry = {
|
|
95
|
+
...value,
|
|
96
|
+
createdAt: now,
|
|
97
|
+
lastAttemptAt: now,
|
|
98
|
+
};
|
|
99
|
+
__classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").set(key, entry);
|
|
100
|
+
__classPrivateFieldGet(this, _QuoteStatusEntryStore_instances, "m", _QuoteStatusEntryStore_subscribeToStatusUpdates).call(this, entry);
|
|
101
|
+
__classPrivateFieldGet(this, _QuoteStatusEntryStore_instances, "m", _QuoteStatusEntryStore_persistToState).call(this);
|
|
102
|
+
return entry;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Returns an iterator over all tracked entries.
|
|
106
|
+
*
|
|
107
|
+
* Stale entries are transitioned to {@link QuoteStatusState.Expired} first (but
|
|
108
|
+
* kept in the store), so the iterator reflects their up-to-date terminal state.
|
|
109
|
+
*
|
|
110
|
+
* @returns An iterator over the currently tracked entries.
|
|
111
|
+
*/
|
|
112
|
+
values() {
|
|
113
|
+
this.expireStaleEntries();
|
|
114
|
+
return __classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").values();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Returns every tracked entry matching the provided quote identifier.
|
|
118
|
+
*
|
|
119
|
+
* Stale entries are transitioned to {@link QuoteStatusState.Expired} first so
|
|
120
|
+
* callers observe their up-to-date terminal state.
|
|
121
|
+
*
|
|
122
|
+
* @param quoteId - Quote identifier to match.
|
|
123
|
+
* @returns The matching entries (empty when none exist).
|
|
124
|
+
*/
|
|
125
|
+
getByQuoteId(quoteId) {
|
|
126
|
+
this.expireStaleEntries();
|
|
127
|
+
const matches = [];
|
|
128
|
+
for (const entry of __classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").values()) {
|
|
129
|
+
if (entry.quoteId === quoteId) {
|
|
130
|
+
matches.push(entry);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return matches;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Number of entries currently tracked by the store.
|
|
137
|
+
*
|
|
138
|
+
* Note that this includes terminal entries (`Completed`/`Expired`), which are
|
|
139
|
+
* retained rather than evicted; call {@link expireStaleEntries} (or
|
|
140
|
+
* {@link values}) first when an up-to-date view of entry states is required.
|
|
141
|
+
*
|
|
142
|
+
* @returns The count of tracked entries.
|
|
143
|
+
*/
|
|
144
|
+
get size() {
|
|
145
|
+
return __classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").size;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Looks up an entry by its transaction metadata identifier.
|
|
149
|
+
*
|
|
150
|
+
* If the matching entry has exceeded its TTL it is transitioned to
|
|
151
|
+
* {@link QuoteStatusState.Expired} (but kept) before being returned.
|
|
152
|
+
*
|
|
153
|
+
* @param txMetaId - Transaction metadata identifier to search for.
|
|
154
|
+
* @returns The matching entry, or `null` if none exists.
|
|
155
|
+
*/
|
|
156
|
+
getByTxMetaId(txMetaId) {
|
|
157
|
+
for (const entry of __classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").values()) {
|
|
158
|
+
if (entry.txMetaId === txMetaId) {
|
|
159
|
+
this.expireEntryIfStale(entry);
|
|
160
|
+
return entry;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Retrieves an entry by key.
|
|
167
|
+
*
|
|
168
|
+
* If the entry has exceeded its TTL it is transitioned to
|
|
169
|
+
* {@link QuoteStatusState.Expired} (but kept) before being returned.
|
|
170
|
+
*
|
|
171
|
+
* @param key - Unique map key for the entry.
|
|
172
|
+
* @returns The matching entry, or `null` if absent.
|
|
173
|
+
*/
|
|
174
|
+
get(key) {
|
|
175
|
+
const entry = __classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").get(key);
|
|
176
|
+
if (!entry) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
this.expireEntryIfStale(entry);
|
|
180
|
+
return entry;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Persists the current snapshot after an in-place mutation of a tracked entry.
|
|
184
|
+
*
|
|
185
|
+
* Used when fields such as `lastAttemptAt` are mutated directly on an entry
|
|
186
|
+
* the caller already holds. No-ops if the entry is no longer tracked (e.g. the
|
|
187
|
+
* store was cleared in the meantime), so persistence only reflects live entries.
|
|
188
|
+
*
|
|
189
|
+
* @param entry - The mutated entry to persist.
|
|
190
|
+
*/
|
|
191
|
+
update(entry) {
|
|
192
|
+
if (!__classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").has(QuoteStatusEntryStore.hash(entry))) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
__classPrivateFieldGet(this, _QuoteStatusEntryStore_instances, "m", _QuoteStatusEntryStore_persistToState).call(this);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Transitions every stale entry to {@link QuoteStatusState.Expired}, keeping it
|
|
199
|
+
* in the store.
|
|
200
|
+
*
|
|
201
|
+
* Expired entries are retained so that later interactions with the same quote
|
|
202
|
+
* (e.g. a duplicate `reportSubmitted`) can be recognized and rejected. Each
|
|
203
|
+
* transition persists the updated snapshot via the entry's FSM subscription;
|
|
204
|
+
* already-terminal entries cannot transition and are left untouched.
|
|
205
|
+
*/
|
|
206
|
+
expireStaleEntries() {
|
|
207
|
+
for (const entry of __classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").values()) {
|
|
208
|
+
if (this.entryHasExpired(entry)) {
|
|
209
|
+
entry.status.transitionTo(QuoteStatusState.Expired);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Determines whether an entry has outlived the configured TTL.
|
|
215
|
+
*
|
|
216
|
+
* Expiry is measured from the entry's `createdAt` timestamp, not its last
|
|
217
|
+
* attempt, so an entry's total lifetime is bounded regardless of retries.
|
|
218
|
+
*
|
|
219
|
+
* @param entry - Entry to check.
|
|
220
|
+
* @returns `true` if the entry's age exceeds the TTL.
|
|
221
|
+
*/
|
|
222
|
+
entryHasExpired(entry) {
|
|
223
|
+
const now = Date.now();
|
|
224
|
+
return now - entry.createdAt > __classPrivateFieldGet(this, _QuoteStatusEntryStore_entryTtlMs, "f");
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Transitions an entry to {@link QuoteStatusState.Expired} (keeping it) if it
|
|
228
|
+
* has exceeded its TTL.
|
|
229
|
+
*
|
|
230
|
+
* The transition persists the updated snapshot via the entry's FSM
|
|
231
|
+
* subscription. Already-terminal entries cannot transition and are left
|
|
232
|
+
* untouched.
|
|
233
|
+
*
|
|
234
|
+
* @param entry - Entry to check and possibly expire.
|
|
235
|
+
* @returns `true` if the entry was stale, otherwise `false`.
|
|
236
|
+
*/
|
|
237
|
+
expireEntryIfStale(entry) {
|
|
238
|
+
if (this.entryHasExpired(entry)) {
|
|
239
|
+
entry.status.transitionTo(QuoteStatusState.Expired);
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Removes every entry from the store.
|
|
246
|
+
*
|
|
247
|
+
* Detaches each entry's FSM listeners before clearing to prevent leaks and
|
|
248
|
+
* stale persist callbacks. Does not emit a persistence update; callers are
|
|
249
|
+
* expected to use this during teardown.
|
|
250
|
+
*/
|
|
251
|
+
clear() {
|
|
252
|
+
for (const entry of __classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").values()) {
|
|
253
|
+
entry.status.removeAllListeners();
|
|
254
|
+
}
|
|
255
|
+
__classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f").clear();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
_QuoteStatusEntryStore_items = new WeakMap(), _QuoteStatusEntryStore_entryTtlMs = new WeakMap(), _QuoteStatusEntryStore_onPersistUpdates = new WeakMap(), _QuoteStatusEntryStore_instances = new WeakSet(), _QuoteStatusEntryStore_subscribeToStatusUpdates = function _QuoteStatusEntryStore_subscribeToStatusUpdates(entry) {
|
|
259
|
+
entry.status.onStateUpdate(() => __classPrivateFieldGet(this, _QuoteStatusEntryStore_instances, "m", _QuoteStatusEntryStore_persistToState).call(this));
|
|
260
|
+
}, _QuoteStatusEntryStore_persistToState = function _QuoteStatusEntryStore_persistToState() {
|
|
261
|
+
const cloned = {};
|
|
262
|
+
for (const [key, entry] of __classPrivateFieldGet(this, _QuoteStatusEntryStore_items, "f")) {
|
|
263
|
+
cloned[key] = { ...entry, status: entry.status.state };
|
|
264
|
+
}
|
|
265
|
+
__classPrivateFieldGet(this, _QuoteStatusEntryStore_onPersistUpdates, "f").call(this, cloned);
|
|
266
|
+
};
|
|
267
|
+
//# sourceMappingURL=quote-status-entry-store.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-status-entry-store.mjs","sourceRoot":"","sources":["../../src/quote-status-manager/quote-status-entry-store.ts"],"names":[],"mappings":"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","sourcesContent":["import { QuoteStatusState } from './constants';\nimport { QuoteStatusStateFsm } from './quote-status-state-fsm';\nimport {\n QuoteStatusEntryStoreOptions,\n QuoteStatusPersistEntry,\n QuoteStatusRuntimeEntry,\n} from './types';\n\n/**\n * In-memory store for quote status update entries.\n *\n * The store deduplicates entries by key, tracks timestamps used for retries and\n * TTL eviction, and persists a cloned snapshot on each mutating operation.\n */\nexport class QuoteStatusEntryStore {\n readonly #items: Map<string, QuoteStatusRuntimeEntry>;\n\n readonly #entryTtlMs: number;\n\n /**\n * Creates a deterministic key for persisted quote status entries.\n *\n * @param entry - Entry identity fields.\n * @param entry.quoteId - Quote identifier.\n * @param entry.srcTxHash - Source transaction hash.\n * @returns Stable key in `${quoteId}:${srcTxHash}` format.\n */\n static hash(\n entry: Pick<QuoteStatusPersistEntry, 'quoteId' | 'srcTxHash'>,\n ): string {\n return `${entry.quoteId}:${entry.srcTxHash}`;\n }\n\n readonly #onPersistUpdates: (\n updates: Record<string, QuoteStatusPersistEntry>,\n ) => void;\n\n /**\n * Creates a quote status entry store.\n *\n * @param options - Store dependencies and retention configuration.\n * @param options.onPersistUpdates - Callback invoked with cloned snapshot updates.\n * @param options.entryTtlMs - Entry time-to-live in milliseconds.\n * @param options.initial - Optional initial persisted entries used to seed the store.\n */\n constructor({\n onPersistUpdates,\n entryTtlMs,\n initial,\n }: QuoteStatusEntryStoreOptions) {\n this.#onPersistUpdates = onPersistUpdates;\n this.#entryTtlMs = entryTtlMs;\n this.#items = new Map(\n Object.entries(initial ?? {}).map(([key, entry]) => {\n const quoteStatusStateFsm = new QuoteStatusStateFsm(entry.status);\n\n return [\n key,\n // Entries from `initialDeferredUpdates` come from Immer-managed controller\n // state, which deep-freezes all nested objects. Cloning each entry here\n // ensures the in-memory queue holds mutable objects so that mutations\n // (e.g. updating `status` or `lastAttemptAt`) work correctly without\n // throwing a \"read only property\" error.\n { ...entry, status: quoteStatusStateFsm },\n ];\n }),\n );\n\n // Subscribe each seeded FSM after the map (and `#onPersistUpdates`) are set\n // so that any later state transition persists the updated snapshot.\n for (const entry of this.#items.values()) {\n this.#subscribeToStatusUpdates(entry);\n }\n }\n\n /**\n * Subscribes the entry's FSM so that every state transition persists the\n * current snapshot. Kept in one place so seeded and runtime-added entries\n * behave identically.\n *\n * @param entry - Entry whose FSM should trigger persistence on transition.\n */\n #subscribeToStatusUpdates(entry: QuoteStatusRuntimeEntry): void {\n entry.status.onStateUpdate(() => this.#persistToState());\n }\n\n /**\n * Adds a new entry when the key is not already present.\n *\n * If an entry already exists, only a missing `txMetaId` is backfilled to avoid\n * resetting timestamps and creating duplicate submission updates.\n *\n * @param key - Unique map key for the entry.\n * @param value - Entry payload without internal timestamps.\n * @param value.quoteId - Quote identifier.\n * @param value.srcTxHash - Source transaction hash.\n * @param value.status - Latest quote status.\n * @param value.txMetaId - Optional transaction metadata identifier.\n * @returns The tracked entry (the existing one when the key is already\n * present, otherwise the newly created entry).\n */\n put(\n key: string,\n value: Omit<QuoteStatusRuntimeEntry, 'createdAt' | 'lastAttemptAt'>,\n ): QuoteStatusRuntimeEntry {\n // If an entry for this key is already in the queue\n // do not overwrite it. Re-enqueueing would reset state and\n // could cause duplicate SUBMITTED events.\n const existing = this.#items.get(key);\n if (existing) {\n if (!existing.txMetaId && value.txMetaId) {\n existing.txMetaId = value.txMetaId;\n this.#persistToState();\n }\n return existing;\n }\n\n const now = Date.now();\n const entry: QuoteStatusRuntimeEntry = {\n ...value,\n createdAt: now,\n lastAttemptAt: now,\n };\n this.#items.set(key, entry);\n this.#subscribeToStatusUpdates(entry);\n this.#persistToState();\n return entry;\n }\n\n /**\n * Returns an iterator over all tracked entries.\n *\n * Stale entries are transitioned to {@link QuoteStatusState.Expired} first (but\n * kept in the store), so the iterator reflects their up-to-date terminal state.\n *\n * @returns An iterator over the currently tracked entries.\n */\n values(): IterableIterator<QuoteStatusRuntimeEntry> {\n this.expireStaleEntries();\n return this.#items.values();\n }\n\n /**\n * Returns every tracked entry matching the provided quote identifier.\n *\n * Stale entries are transitioned to {@link QuoteStatusState.Expired} first so\n * callers observe their up-to-date terminal state.\n *\n * @param quoteId - Quote identifier to match.\n * @returns The matching entries (empty when none exist).\n */\n getByQuoteId(quoteId: string): QuoteStatusRuntimeEntry[] {\n this.expireStaleEntries();\n\n const matches: QuoteStatusRuntimeEntry[] = [];\n for (const entry of this.#items.values()) {\n if (entry.quoteId === quoteId) {\n matches.push(entry);\n }\n }\n\n return matches;\n }\n\n /**\n * Number of entries currently tracked by the store.\n *\n * Note that this includes terminal entries (`Completed`/`Expired`), which are\n * retained rather than evicted; call {@link expireStaleEntries} (or\n * {@link values}) first when an up-to-date view of entry states is required.\n *\n * @returns The count of tracked entries.\n */\n get size(): number {\n return this.#items.size;\n }\n\n /**\n * Looks up an entry by its transaction metadata identifier.\n *\n * If the matching entry has exceeded its TTL it is transitioned to\n * {@link QuoteStatusState.Expired} (but kept) before being returned.\n *\n * @param txMetaId - Transaction metadata identifier to search for.\n * @returns The matching entry, or `null` if none exists.\n */\n getByTxMetaId(txMetaId: string): QuoteStatusRuntimeEntry | null {\n for (const entry of this.#items.values()) {\n if (entry.txMetaId === txMetaId) {\n this.expireEntryIfStale(entry);\n return entry;\n }\n }\n\n return null;\n }\n\n /**\n * Retrieves an entry by key.\n *\n * If the entry has exceeded its TTL it is transitioned to\n * {@link QuoteStatusState.Expired} (but kept) before being returned.\n *\n * @param key - Unique map key for the entry.\n * @returns The matching entry, or `null` if absent.\n */\n get(key: string): QuoteStatusRuntimeEntry | null {\n const entry = this.#items.get(key);\n if (!entry) {\n return null;\n }\n\n this.expireEntryIfStale(entry);\n return entry;\n }\n\n /**\n * Persists the current snapshot after an in-place mutation of a tracked entry.\n *\n * Used when fields such as `lastAttemptAt` are mutated directly on an entry\n * the caller already holds. No-ops if the entry is no longer tracked (e.g. the\n * store was cleared in the meantime), so persistence only reflects live entries.\n *\n * @param entry - The mutated entry to persist.\n */\n update(entry: QuoteStatusRuntimeEntry): void {\n if (!this.#items.has(QuoteStatusEntryStore.hash(entry))) {\n return;\n }\n\n this.#persistToState();\n }\n\n /**\n * Emits a cloned, serializable snapshot of all tracked entries via the\n * `onPersistUpdates` callback.\n *\n * Each entry's FSM is flattened to its plain `status` value so the snapshot\n * contains no class instances and is safe to store in controller state.\n */\n #persistToState(): void {\n const cloned: Record<string, QuoteStatusPersistEntry> = {};\n for (const [key, entry] of this.#items) {\n cloned[key] = { ...entry, status: entry.status.state };\n }\n this.#onPersistUpdates(cloned);\n }\n\n /**\n * Transitions every stale entry to {@link QuoteStatusState.Expired}, keeping it\n * in the store.\n *\n * Expired entries are retained so that later interactions with the same quote\n * (e.g. a duplicate `reportSubmitted`) can be recognized and rejected. Each\n * transition persists the updated snapshot via the entry's FSM subscription;\n * already-terminal entries cannot transition and are left untouched.\n */\n expireStaleEntries(): void {\n for (const entry of this.#items.values()) {\n if (this.entryHasExpired(entry)) {\n entry.status.transitionTo(QuoteStatusState.Expired);\n }\n }\n }\n\n /**\n * Determines whether an entry has outlived the configured TTL.\n *\n * Expiry is measured from the entry's `createdAt` timestamp, not its last\n * attempt, so an entry's total lifetime is bounded regardless of retries.\n *\n * @param entry - Entry to check.\n * @returns `true` if the entry's age exceeds the TTL.\n */\n entryHasExpired(entry: QuoteStatusRuntimeEntry): boolean {\n const now = Date.now();\n return now - entry.createdAt > this.#entryTtlMs;\n }\n\n /**\n * Transitions an entry to {@link QuoteStatusState.Expired} (keeping it) if it\n * has exceeded its TTL.\n *\n * The transition persists the updated snapshot via the entry's FSM\n * subscription. Already-terminal entries cannot transition and are left\n * untouched.\n *\n * @param entry - Entry to check and possibly expire.\n * @returns `true` if the entry was stale, otherwise `false`.\n */\n expireEntryIfStale(entry: QuoteStatusRuntimeEntry): boolean {\n if (this.entryHasExpired(entry)) {\n entry.status.transitionTo(QuoteStatusState.Expired);\n return true;\n }\n\n return false;\n }\n\n /**\n * Removes every entry from the store.\n *\n * Detaches each entry's FSM listeners before clearing to prevent leaks and\n * stale persist callbacks. Does not emit a persistence update; callers are\n * expected to use this during teardown.\n */\n clear(): void {\n for (const entry of this.#items.values()) {\n entry.status.removeAllListeners();\n }\n\n this.#items.clear();\n }\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuoteStatusGetWithRetryOutcome = void 0;
|
|
4
|
+
const constants_1 = require("./constants.cjs");
|
|
5
|
+
const errors_1 = require("./errors.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* Result of a retrying quote status fetch
|
|
8
|
+
* ({@link QuoteStatusApiService.getQuoteStatusWithRetry}).
|
|
9
|
+
*
|
|
10
|
+
* Represents how a fetch attempt resolved so callers can branch on the
|
|
11
|
+
* outcome without having to re-interpret raw HTTP responses or thrown errors.
|
|
12
|
+
* The discriminating {@link type} indicates whether the fetch was accepted,
|
|
13
|
+
* was interrupted, or exhausted its retries. The optional {@link response}
|
|
14
|
+
* carries the backend quote status payload when the fetch succeeded.
|
|
15
|
+
*/
|
|
16
|
+
class QuoteStatusGetWithRetryOutcome {
|
|
17
|
+
/**
|
|
18
|
+
* @param outcome - The outcome type describing how the fetch resolved.
|
|
19
|
+
* @param response - Optional backend quote status payload when accepted.
|
|
20
|
+
* @param error - Optional quote status fetch error when the outcome is non-retryable.
|
|
21
|
+
*/
|
|
22
|
+
constructor(outcome, response, error) {
|
|
23
|
+
this.type = outcome;
|
|
24
|
+
this.response = response;
|
|
25
|
+
this.error = error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.QuoteStatusGetWithRetryOutcome = QuoteStatusGetWithRetryOutcome;
|
|
29
|
+
//# sourceMappingURL=quote-status-get-with-retry-outcome.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-status-get-with-retry-outcome.cjs","sourceRoot":"","sources":["../../src/quote-status-manager/quote-status-get-with-retry-outcome.ts"],"names":[],"mappings":";;;AAAA,+CAAmE;AACnE,yCAA+C;AAG/C;;;;;;;;;GASG;AACH,MAAa,8BAA8B;IAczC;;;;OAIG;IACH,YACE,OAA6C,EAC7C,QAAiC,EACjC,KAA2B;QAE3B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AA5BD,wEA4BC","sourcesContent":["import { QuoteStatusFetchWithRetryOutcomeType } from './constants';\nimport { QuoteStatusGetError } from './errors';\nimport { QuoteStatusGetResponse } from './types';\n\n/**\n * Result of a retrying quote status fetch\n * ({@link QuoteStatusApiService.getQuoteStatusWithRetry}).\n *\n * Represents how a fetch attempt resolved so callers can branch on the\n * outcome without having to re-interpret raw HTTP responses or thrown errors.\n * The discriminating {@link type} indicates whether the fetch was accepted,\n * was interrupted, or exhausted its retries. The optional {@link response}\n * carries the backend quote status payload when the fetch succeeded.\n */\nexport class QuoteStatusGetWithRetryOutcome {\n /**\n * Discriminant describing how the fetch attempt resolved.\n */\n readonly type: QuoteStatusFetchWithRetryOutcomeType;\n\n /**\n * Backend quote status payload when the fetch was accepted\n * ({@link QuoteStatusFetchWithRetryOutcomeType.Accepted}).\n */\n readonly response?: QuoteStatusGetResponse;\n\n readonly error?: QuoteStatusGetError;\n\n /**\n * @param outcome - The outcome type describing how the fetch resolved.\n * @param response - Optional backend quote status payload when accepted.\n * @param error - Optional quote status fetch error when the outcome is non-retryable.\n */\n constructor(\n outcome: QuoteStatusFetchWithRetryOutcomeType,\n response?: QuoteStatusGetResponse,\n error?: QuoteStatusGetError,\n ) {\n this.type = outcome;\n this.response = response;\n this.error = error;\n }\n}\n"]}
|