@axiom-lattice/core 4.2.11 → 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 +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -4005,6 +4005,7 @@ interface InMemoryProjectRoomTransaction {
|
|
|
4005
4005
|
getMessageByIdempotency(tenantId: string, roomId: string, idempotencyKey: string): ProjectRoomMessage | undefined;
|
|
4006
4006
|
getMessages(): ProjectRoomMessage[];
|
|
4007
4007
|
setMessage(message: ProjectRoomMessage): void;
|
|
4008
|
+
deleteMessage(tenantId: string, id: string): boolean;
|
|
4008
4009
|
nextTimestamp(previous?: Date): Date;
|
|
4009
4010
|
}
|
|
4010
4011
|
/**
|
|
@@ -4340,6 +4341,17 @@ declare class InMemoryProjectRoomMessageStore implements ProjectRoomMessageStore
|
|
|
4340
4341
|
after: Date;
|
|
4341
4342
|
excludeAuthorUserId?: string;
|
|
4342
4343
|
}): Promise<number>;
|
|
4344
|
+
/**
|
|
4345
|
+
* Deletes one bounded batch of chat messages older than a horizon.
|
|
4346
|
+
*
|
|
4347
|
+
* @param input - Exclusive upper time bound and requested batch size (clamped to 1..1000).
|
|
4348
|
+
* @returns The number of deleted rows.
|
|
4349
|
+
* @remarks Only `source: "user" | "agent"` rows are eligible; task/system events are retained.
|
|
4350
|
+
*/
|
|
4351
|
+
deleteChatOlderThan(input: {
|
|
4352
|
+
before: Date;
|
|
4353
|
+
limit: number;
|
|
4354
|
+
}): Promise<number>;
|
|
4343
4355
|
private createInTransaction;
|
|
4344
4356
|
}
|
|
4345
4357
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4005,6 +4005,7 @@ interface InMemoryProjectRoomTransaction {
|
|
|
4005
4005
|
getMessageByIdempotency(tenantId: string, roomId: string, idempotencyKey: string): ProjectRoomMessage | undefined;
|
|
4006
4006
|
getMessages(): ProjectRoomMessage[];
|
|
4007
4007
|
setMessage(message: ProjectRoomMessage): void;
|
|
4008
|
+
deleteMessage(tenantId: string, id: string): boolean;
|
|
4008
4009
|
nextTimestamp(previous?: Date): Date;
|
|
4009
4010
|
}
|
|
4010
4011
|
/**
|
|
@@ -4340,6 +4341,17 @@ declare class InMemoryProjectRoomMessageStore implements ProjectRoomMessageStore
|
|
|
4340
4341
|
after: Date;
|
|
4341
4342
|
excludeAuthorUserId?: string;
|
|
4342
4343
|
}): Promise<number>;
|
|
4344
|
+
/**
|
|
4345
|
+
* Deletes one bounded batch of chat messages older than a horizon.
|
|
4346
|
+
*
|
|
4347
|
+
* @param input - Exclusive upper time bound and requested batch size (clamped to 1..1000).
|
|
4348
|
+
* @returns The number of deleted rows.
|
|
4349
|
+
* @remarks Only `source: "user" | "agent"` rows are eligible; task/system events are retained.
|
|
4350
|
+
*/
|
|
4351
|
+
deleteChatOlderThan(input: {
|
|
4352
|
+
before: Date;
|
|
4353
|
+
limit: number;
|
|
4354
|
+
}): Promise<number>;
|
|
4343
4355
|
private createInTransaction;
|
|
4344
4356
|
}
|
|
4345
4357
|
|
package/dist/index.js
CHANGED
|
@@ -4237,6 +4237,17 @@ var InMemoryProjectRoomCoordinator = class {
|
|
|
4237
4237
|
}
|
|
4238
4238
|
this.messages.set(JSON.stringify([message.tenantId, message.id]), storedMessage);
|
|
4239
4239
|
},
|
|
4240
|
+
deleteMessage: (tenantId2, id) => {
|
|
4241
|
+
assertActive();
|
|
4242
|
+
const key5 = JSON.stringify([tenantId2, id]);
|
|
4243
|
+
const message = this.messages.get(key5);
|
|
4244
|
+
if (message === void 0) return false;
|
|
4245
|
+
this.messages.delete(key5);
|
|
4246
|
+
if (message.idempotencyKey !== void 0) {
|
|
4247
|
+
this.messageIdsByIdempotency.delete(JSON.stringify([tenantId2, message.roomId, message.idempotencyKey]));
|
|
4248
|
+
}
|
|
4249
|
+
return true;
|
|
4250
|
+
},
|
|
4240
4251
|
nextTimestamp: (previousTimestamp) => {
|
|
4241
4252
|
assertActive();
|
|
4242
4253
|
const current = this.clock().getTime();
|
|
@@ -4642,6 +4653,25 @@ var InMemoryProjectRoomMessageStore = class {
|
|
|
4642
4653
|
const horizon = Date.prototype.getTime.call(input.after);
|
|
4643
4654
|
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);
|
|
4644
4655
|
}
|
|
4656
|
+
/**
|
|
4657
|
+
* Deletes one bounded batch of chat messages older than a horizon.
|
|
4658
|
+
*
|
|
4659
|
+
* @param input - Exclusive upper time bound and requested batch size (clamped to 1..1000).
|
|
4660
|
+
* @returns The number of deleted rows.
|
|
4661
|
+
* @remarks Only `source: "user" | "agent"` rows are eligible; task/system events are retained.
|
|
4662
|
+
*/
|
|
4663
|
+
async deleteChatOlderThan(input) {
|
|
4664
|
+
if (!validDate(input.before)) {
|
|
4665
|
+
throw new RangeError("Project room message retention horizon date is invalid");
|
|
4666
|
+
}
|
|
4667
|
+
const horizon = Date.prototype.getTime.call(input.before);
|
|
4668
|
+
const limit = Math.min(1e3, Math.max(1, Math.trunc(Number.isFinite(input.limit) ? input.limit : 1)));
|
|
4669
|
+
return this.coordinator.runExclusive((transaction) => {
|
|
4670
|
+
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);
|
|
4671
|
+
for (const message of candidates) transaction.deleteMessage(message.tenantId, message.id);
|
|
4672
|
+
return candidates.length;
|
|
4673
|
+
});
|
|
4674
|
+
}
|
|
4645
4675
|
createInTransaction(transaction, input) {
|
|
4646
4676
|
if (transaction.getMessage(input.tenantId, input.id) !== void 0) {
|
|
4647
4677
|
throw new ProjectRoomMessageIdConflictError(input.tenantId, input.id);
|