@axiom-lattice/pg-stores 3.1.12 → 3.1.14
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +17 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +45 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/PostgreSQLAgentWebAppStore.test.ts +18 -0
- package/src/__tests__/PostgreSQLProjectRoomMessageStore.test.ts +25 -0
- package/src/createPgStoreConfig.ts +2 -0
- package/src/migrations/project_room_message_retention_migration.ts +23 -0
- package/src/stores/PostgreSQLAgentWebAppStore.ts +10 -1
- package/src/stores/PostgreSQLProjectRoomMessageStore.ts +25 -0
package/dist/index.mjs
CHANGED
|
@@ -6605,8 +6605,11 @@ function isScope(value) {
|
|
|
6605
6605
|
function isFeatures(value) {
|
|
6606
6606
|
return isRecord(value) && typeof value.projectSelector === "boolean" && typeof value.modelSelector === "boolean" && typeof value.threadManagement === "boolean" && typeof value.attachments === "boolean" && typeof value.hitl === "boolean" && typeof value.genUI === "boolean" && (value.files === void 0 || typeof value.files === "boolean");
|
|
6607
6607
|
}
|
|
6608
|
+
function isQuickPrompt(value) {
|
|
6609
|
+
return isRecord(value) && typeof value.label === "string" && typeof value.text === "string";
|
|
6610
|
+
}
|
|
6608
6611
|
function isAppearance(value) {
|
|
6609
|
-
return isRecord(value) && (value.title === void 0 || typeof value.title === "string") && (value.welcomeMessage === void 0 || typeof value.welcomeMessage === "string") && (value.primaryColor === void 0 || typeof value.primaryColor === "string");
|
|
6612
|
+
return isRecord(value) && (value.title === void 0 || typeof value.title === "string") && (value.welcomeMessage === void 0 || typeof value.welcomeMessage === "string") && (value.primaryColor === void 0 || typeof value.primaryColor === "string") && (value.quickPrompts === void 0 || Array.isArray(value.quickPrompts) && value.quickPrompts.every(isQuickPrompt));
|
|
6610
6613
|
}
|
|
6611
6614
|
function isIdentity(value) {
|
|
6612
6615
|
if (value === null || value === void 0) return true;
|
|
@@ -9884,6 +9887,22 @@ var createProjectRoomReadStates = {
|
|
|
9884
9887
|
}
|
|
9885
9888
|
};
|
|
9886
9889
|
|
|
9890
|
+
// src/migrations/project_room_message_retention_migration.ts
|
|
9891
|
+
var addProjectRoomMessageRetentionIndex = {
|
|
9892
|
+
version: 179,
|
|
9893
|
+
name: "add_project_room_message_retention_index",
|
|
9894
|
+
up: async (client) => {
|
|
9895
|
+
await client.query(`
|
|
9896
|
+
CREATE INDEX IF NOT EXISTS idx_lattice_project_room_messages_chat_created
|
|
9897
|
+
ON lattice_project_room_messages (created_at)
|
|
9898
|
+
WHERE source IN ('user', 'agent')
|
|
9899
|
+
`);
|
|
9900
|
+
},
|
|
9901
|
+
down: async (client) => {
|
|
9902
|
+
await client.query("DROP INDEX IF EXISTS idx_lattice_project_room_messages_chat_created");
|
|
9903
|
+
}
|
|
9904
|
+
};
|
|
9905
|
+
|
|
9887
9906
|
// src/migrations/user_push_subscription_migration.ts
|
|
9888
9907
|
var createUserPushSubscriptions = {
|
|
9889
9908
|
version: 178,
|
|
@@ -10728,6 +10747,30 @@ var PostgreSQLProjectRoomMessageStore = class {
|
|
|
10728
10747
|
);
|
|
10729
10748
|
return result.rows[0]?.count ?? 0;
|
|
10730
10749
|
}
|
|
10750
|
+
/**
|
|
10751
|
+
* Deletes one bounded batch of chat messages older than a horizon.
|
|
10752
|
+
*
|
|
10753
|
+
* @param input Exclusive upper time bound and requested batch size (clamped to 1..1000).
|
|
10754
|
+
* @returns The number of deleted rows.
|
|
10755
|
+
* @remarks Only `source IN ('user','agent')` rows are eligible; task/system events are retained.
|
|
10756
|
+
*/
|
|
10757
|
+
async deleteChatOlderThan(input) {
|
|
10758
|
+
if (!(input.before instanceof Date) || Number.isNaN(input.before.getTime())) {
|
|
10759
|
+
throw new RangeError("Project room message retention horizon date is invalid");
|
|
10760
|
+
}
|
|
10761
|
+
const limit = Math.min(1e3, Math.max(1, Math.trunc(Number.isFinite(input.limit) ? input.limit : 1)));
|
|
10762
|
+
const result = await this.pool.query(
|
|
10763
|
+
`DELETE FROM lattice_project_room_messages
|
|
10764
|
+
WHERE ctid IN (
|
|
10765
|
+
SELECT ctid FROM lattice_project_room_messages
|
|
10766
|
+
WHERE created_at < $1 AND source IN ('user','agent')
|
|
10767
|
+
ORDER BY created_at ASC
|
|
10768
|
+
LIMIT $2
|
|
10769
|
+
)`,
|
|
10770
|
+
[input.before, limit]
|
|
10771
|
+
);
|
|
10772
|
+
return result.rowCount ?? 0;
|
|
10773
|
+
}
|
|
10731
10774
|
parameters(input) {
|
|
10732
10775
|
return [
|
|
10733
10776
|
input.id,
|
|
@@ -10905,6 +10948,7 @@ async function createPgStoreConfig(connectionString) {
|
|
|
10905
10948
|
mm.register(addAgentWebAppsIdentity);
|
|
10906
10949
|
mm.register(createProjectRoomReadStates);
|
|
10907
10950
|
mm.register(createUserPushSubscriptions);
|
|
10951
|
+
mm.register(addProjectRoomMessageRetentionIndex);
|
|
10908
10952
|
await mm.migrate();
|
|
10909
10953
|
const checkpoint = PostgresSaver.fromConnString(connectionString);
|
|
10910
10954
|
checkpoint.setup().catch((err) => {
|