@axiom-lattice/pg-stores 3.1.4 → 3.1.6
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 +8 -8
- package/CHANGELOG.md +17 -0
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/PostgreSQLAgentWebAppStore.migrations.test.ts +2 -1
- package/src/__tests__/PostgreSQLAgentWebAppStore.test.ts +1 -0
- package/src/createPgStoreConfig.ts +2 -0
- package/src/migrations/add_agent_web_apps_identity_migration.ts +18 -0
- package/src/stores/PostgreSQLAgentWebAppStore.ts +25 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiom-lattice/pg-stores",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"description": "PG stores implementation for Axiom Lattice framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@langchain/core": "1.1.30",
|
|
26
26
|
"pg": "^8.16.3",
|
|
27
27
|
"uuid": "^9.0.1",
|
|
28
|
-
"@axiom-lattice/core": "4.2.
|
|
29
|
-
"@axiom-lattice/protocols": "4.1.
|
|
28
|
+
"@axiom-lattice/core": "4.2.6",
|
|
29
|
+
"@axiom-lattice/protocols": "4.1.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/jest": "^29.5.14",
|
|
@@ -45,8 +45,9 @@ describe("PostgreSQLAgentWebAppStore standalone migrations", () => {
|
|
|
45
45
|
|
|
46
46
|
await store.initialize();
|
|
47
47
|
|
|
48
|
-
expect(recordedMigrationNames).toEqual(["create_agent_web_apps_table"]);
|
|
48
|
+
expect(recordedMigrationNames).toEqual(["create_agent_web_apps_table", "add_agent_web_apps_identity"]);
|
|
49
49
|
expect(clientSql.some((sql) => sql.includes("CREATE TABLE IF NOT EXISTS lattice_agent_web_apps"))).toBe(true);
|
|
50
|
+
expect(clientSql.some((sql) => sql.includes("ADD COLUMN IF NOT EXISTS identity"))).toBe(true);
|
|
50
51
|
expect(clientSql.some((sql) => sql.includes("status VARCHAR(32) NOT NULL DEFAULT 'draft'"))).toBe(true);
|
|
51
52
|
expect(clientSql.some((sql) => sql.includes(
|
|
52
53
|
"CONSTRAINT chk_lattice_agent_web_apps_status CHECK (status IN ('draft', 'active', 'disabled'))",
|
|
@@ -80,6 +80,7 @@ import {
|
|
|
80
80
|
addProjectLifecycleEventIndex,
|
|
81
81
|
} from "./migrations/task_work_items_migration";
|
|
82
82
|
import { createAgentWebAppsTable } from "./migrations/agent_web_apps_migration";
|
|
83
|
+
import { addAgentWebAppsIdentity } from "./migrations/add_agent_web_apps_identity_migration";
|
|
83
84
|
import { createCapabilityBundlesTable } from "./migrations/capability_bundle_migration";
|
|
84
85
|
import { createProjectRoomTables } from "./migrations/project_room_migration";
|
|
85
86
|
import { PostgreSQLCapabilityBundleStore } from "./stores/PostgreSQLCapabilityBundleStore";
|
|
@@ -153,6 +154,7 @@ export async function createPgStoreConfig(connectionString: string) {
|
|
|
153
154
|
mm.register(createProjectRoomTables); // v172
|
|
154
155
|
mm.register(addTrustedRunContextColumn); // v173
|
|
155
156
|
mm.register(addProjectLifecycleEventIndex); // v175
|
|
157
|
+
mm.register(addAgentWebAppsIdentity); // v176
|
|
156
158
|
|
|
157
159
|
await mm.migrate();
|
|
158
160
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PoolClient } from "pg";
|
|
2
|
+
|
|
3
|
+
import type { Migration } from "./migration";
|
|
4
|
+
|
|
5
|
+
export const addAgentWebAppsIdentity: Migration = {
|
|
6
|
+
version: 176,
|
|
7
|
+
name: "add_agent_web_apps_identity",
|
|
8
|
+
up: async (client: PoolClient) => {
|
|
9
|
+
await client.query(
|
|
10
|
+
"ALTER TABLE lattice_agent_web_apps ADD COLUMN IF NOT EXISTS identity JSONB",
|
|
11
|
+
);
|
|
12
|
+
},
|
|
13
|
+
down: async (client: PoolClient) => {
|
|
14
|
+
await client.query(
|
|
15
|
+
"ALTER TABLE lattice_agent_web_apps DROP COLUMN IF EXISTS identity",
|
|
16
|
+
);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -14,6 +14,7 @@ import { Pool } from "pg";
|
|
|
14
14
|
import type { PoolConfig } from "pg";
|
|
15
15
|
|
|
16
16
|
import { createAgentWebAppsTable } from "../migrations/agent_web_apps_migration";
|
|
17
|
+
import { addAgentWebAppsIdentity } from "../migrations/add_agent_web_apps_identity_migration";
|
|
17
18
|
import { MigrationManager } from "../migrations/migration";
|
|
18
19
|
|
|
19
20
|
export interface PostgreSQLAgentWebAppStoreOptions {
|
|
@@ -33,6 +34,7 @@ type AgentWebAppRow = {
|
|
|
33
34
|
scope: unknown;
|
|
34
35
|
features: unknown;
|
|
35
36
|
appearance: unknown;
|
|
37
|
+
identity: unknown;
|
|
36
38
|
created_at: Date;
|
|
37
39
|
updated_at: Date;
|
|
38
40
|
};
|
|
@@ -64,7 +66,8 @@ function isFeatures(value: unknown): value is AgentWebAppFeatures {
|
|
|
64
66
|
&& typeof value.threadManagement === "boolean"
|
|
65
67
|
&& typeof value.attachments === "boolean"
|
|
66
68
|
&& typeof value.hitl === "boolean"
|
|
67
|
-
&& typeof value.genUI === "boolean"
|
|
69
|
+
&& typeof value.genUI === "boolean"
|
|
70
|
+
&& (value.files === undefined || typeof value.files === "boolean");
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
function isAppearance(value: unknown): value is AgentWebAppAppearance {
|
|
@@ -74,6 +77,18 @@ function isAppearance(value: unknown): value is AgentWebAppAppearance {
|
|
|
74
77
|
&& (value.primaryColor === undefined || typeof value.primaryColor === "string");
|
|
75
78
|
}
|
|
76
79
|
|
|
80
|
+
function isIdentity(value: unknown): boolean {
|
|
81
|
+
if (value === null || value === undefined) return true;
|
|
82
|
+
if (!isRecord(value)) return false;
|
|
83
|
+
const policyOk = value.policy === "unverified" || value.policy === "verified" || value.policy === "both";
|
|
84
|
+
const issuersOk = Array.isArray(value.issuers)
|
|
85
|
+
&& value.issuers.every((issuer) => isRecord(issuer)
|
|
86
|
+
&& typeof issuer.iss === "string"
|
|
87
|
+
&& typeof issuer.aud === "string"
|
|
88
|
+
&& (issuer.alg === "HS256" || issuer.alg === "RS256"));
|
|
89
|
+
return policyOk && issuersOk;
|
|
90
|
+
}
|
|
91
|
+
|
|
77
92
|
function isStatus(value: unknown): value is AgentWebAppStatus {
|
|
78
93
|
return value === "draft" || value === "active" || value === "disabled";
|
|
79
94
|
}
|
|
@@ -85,6 +100,7 @@ function mapRow(row: AgentWebAppRow): AgentWebApp {
|
|
|
85
100
|
|| !isScope(row.scope)
|
|
86
101
|
|| !isFeatures(row.features)
|
|
87
102
|
|| !isAppearance(row.appearance)
|
|
103
|
+
|| !isIdentity(row.identity)
|
|
88
104
|
) {
|
|
89
105
|
throw new Error(`Invalid agent web app row: ${row.id}`);
|
|
90
106
|
}
|
|
@@ -100,6 +116,7 @@ function mapRow(row: AgentWebAppRow): AgentWebApp {
|
|
|
100
116
|
scope: row.scope,
|
|
101
117
|
features: row.features,
|
|
102
118
|
appearance: row.appearance,
|
|
119
|
+
identity: row.identity === null ? undefined : (row.identity as AgentWebApp["identity"]),
|
|
103
120
|
createdAt: row.created_at,
|
|
104
121
|
updatedAt: row.updated_at,
|
|
105
122
|
};
|
|
@@ -128,6 +145,7 @@ export class PostgreSQLAgentWebAppStore implements AgentWebAppStore {
|
|
|
128
145
|
|
|
129
146
|
this.migrationManager = new MigrationManager(this.pool);
|
|
130
147
|
this.migrationManager.register(createAgentWebAppsTable);
|
|
148
|
+
this.migrationManager.register(addAgentWebAppsIdentity);
|
|
131
149
|
|
|
132
150
|
if (options.autoMigrate !== false) {
|
|
133
151
|
this.startInitialization();
|
|
@@ -200,8 +218,8 @@ export class PostgreSQLAgentWebAppStore implements AgentWebAppStore {
|
|
|
200
218
|
const id = `webapp_${randomUUID().replace(/-/g, "")}`;
|
|
201
219
|
const result = await this.pool.query<AgentWebAppRow>(
|
|
202
220
|
`INSERT INTO lattice_agent_web_apps
|
|
203
|
-
(id, tenant_id, assistant_id, name, description, status, integration, scope, features, appearance)
|
|
204
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb, $8::jsonb, $9::jsonb, $10::jsonb)
|
|
221
|
+
(id, tenant_id, assistant_id, name, description, status, integration, scope, features, appearance, identity)
|
|
222
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb, $8::jsonb, $9::jsonb, $10::jsonb, $11::jsonb)
|
|
205
223
|
RETURNING *`,
|
|
206
224
|
[
|
|
207
225
|
id,
|
|
@@ -214,6 +232,7 @@ export class PostgreSQLAgentWebAppStore implements AgentWebAppStore {
|
|
|
214
232
|
JSON.stringify(input.scope),
|
|
215
233
|
JSON.stringify(input.features),
|
|
216
234
|
JSON.stringify(input.appearance),
|
|
235
|
+
input.identity ? JSON.stringify(input.identity) : null,
|
|
217
236
|
],
|
|
218
237
|
);
|
|
219
238
|
return mapRow(result.rows[0]);
|
|
@@ -246,6 +265,9 @@ export class PostgreSQLAgentWebAppStore implements AgentWebAppStore {
|
|
|
246
265
|
if (patch.appearance !== undefined) {
|
|
247
266
|
add("appearance", JSON.stringify(patch.appearance));
|
|
248
267
|
}
|
|
268
|
+
if (patch.identity !== undefined) {
|
|
269
|
+
add("identity", JSON.stringify(patch.identity));
|
|
270
|
+
}
|
|
249
271
|
if (patch.status !== undefined) add("status", patch.status);
|
|
250
272
|
|
|
251
273
|
if (assignments.length === 0) return this.getById(tenantId, webAppId);
|