@axiom-lattice/core 4.2.12 → 4.2.13
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/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2285,6 +2285,17 @@ var InMemoryProjectRoomCoordinator = class {
|
|
|
2285
2285
|
}
|
|
2286
2286
|
this.messages.set(JSON.stringify([message.tenantId, message.id]), storedMessage);
|
|
2287
2287
|
},
|
|
2288
|
+
deleteMessage: (tenantId2, id) => {
|
|
2289
|
+
assertActive();
|
|
2290
|
+
const key5 = JSON.stringify([tenantId2, id]);
|
|
2291
|
+
const message = this.messages.get(key5);
|
|
2292
|
+
if (message === void 0) return false;
|
|
2293
|
+
this.messages.delete(key5);
|
|
2294
|
+
if (message.idempotencyKey !== void 0) {
|
|
2295
|
+
this.messageIdsByIdempotency.delete(JSON.stringify([tenantId2, message.roomId, message.idempotencyKey]));
|
|
2296
|
+
}
|
|
2297
|
+
return true;
|
|
2298
|
+
},
|
|
2288
2299
|
nextTimestamp: (previousTimestamp) => {
|
|
2289
2300
|
assertActive();
|
|
2290
2301
|
const current = this.clock().getTime();
|
|
@@ -2690,6 +2701,25 @@ var InMemoryProjectRoomMessageStore = class {
|
|
|
2690
2701
|
const horizon = Date.prototype.getTime.call(input.after);
|
|
2691
2702
|
return this.coordinator.runExclusive((transaction) => transaction.getMessages().filter((message) => message.tenantId === input.tenantId && message.roomId === input.roomId && message.createdAt.getTime() > horizon).filter((message) => input.excludeAuthorUserId === void 0 || !(message.author.type === "human" && message.author.userId === input.excludeAuthorUserId)).length);
|
|
2692
2703
|
}
|
|
2704
|
+
/**
|
|
2705
|
+
* Deletes one bounded batch of chat messages older than a horizon.
|
|
2706
|
+
*
|
|
2707
|
+
* @param input - Exclusive upper time bound and requested batch size (clamped to 1..1000).
|
|
2708
|
+
* @returns The number of deleted rows.
|
|
2709
|
+
* @remarks Only `source: "user" | "agent"` rows are eligible; task/system events are retained.
|
|
2710
|
+
*/
|
|
2711
|
+
async deleteChatOlderThan(input) {
|
|
2712
|
+
if (!validDate(input.before)) {
|
|
2713
|
+
throw new RangeError("Project room message retention horizon date is invalid");
|
|
2714
|
+
}
|
|
2715
|
+
const horizon = Date.prototype.getTime.call(input.before);
|
|
2716
|
+
const limit = Math.min(1e3, Math.max(1, Math.trunc(Number.isFinite(input.limit) ? input.limit : 1)));
|
|
2717
|
+
return this.coordinator.runExclusive((transaction) => {
|
|
2718
|
+
const candidates = transaction.getMessages().filter((message) => (message.source === "user" || message.source === "agent") && message.createdAt.getTime() < horizon).sort((left, right) => left.createdAt.getTime() - right.createdAt.getTime() || left.id.localeCompare(right.id)).slice(0, limit);
|
|
2719
|
+
for (const message of candidates) transaction.deleteMessage(message.tenantId, message.id);
|
|
2720
|
+
return candidates.length;
|
|
2721
|
+
});
|
|
2722
|
+
}
|
|
2693
2723
|
createInTransaction(transaction, input) {
|
|
2694
2724
|
if (transaction.getMessage(input.tenantId, input.id) !== void 0) {
|
|
2695
2725
|
throw new ProjectRoomMessageIdConflictError(input.tenantId, input.id);
|