@axiom-lattice/pg-stores 3.1.5 → 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 +9 -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/dist/index.mjs
CHANGED
|
@@ -6320,6 +6320,22 @@ var createAgentWebAppsTable = {
|
|
|
6320
6320
|
}
|
|
6321
6321
|
};
|
|
6322
6322
|
|
|
6323
|
+
// src/migrations/add_agent_web_apps_identity_migration.ts
|
|
6324
|
+
var addAgentWebAppsIdentity = {
|
|
6325
|
+
version: 176,
|
|
6326
|
+
name: "add_agent_web_apps_identity",
|
|
6327
|
+
up: async (client) => {
|
|
6328
|
+
await client.query(
|
|
6329
|
+
"ALTER TABLE lattice_agent_web_apps ADD COLUMN IF NOT EXISTS identity JSONB"
|
|
6330
|
+
);
|
|
6331
|
+
},
|
|
6332
|
+
down: async (client) => {
|
|
6333
|
+
await client.query(
|
|
6334
|
+
"ALTER TABLE lattice_agent_web_apps DROP COLUMN IF EXISTS identity"
|
|
6335
|
+
);
|
|
6336
|
+
}
|
|
6337
|
+
};
|
|
6338
|
+
|
|
6323
6339
|
// src/stores/PostgreSQLAgentWebAppStore.ts
|
|
6324
6340
|
function isRecord(value) {
|
|
6325
6341
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -6334,16 +6350,23 @@ function isScope(value) {
|
|
|
6334
6350
|
return isRecord(value) && typeof value.defaultProjectId === "string" && isStringArray(value.allowedProjectIds) && (value.defaultModelKey === void 0 || typeof value.defaultModelKey === "string") && (value.allowedModelKeys === void 0 || isStringArray(value.allowedModelKeys));
|
|
6335
6351
|
}
|
|
6336
6352
|
function isFeatures(value) {
|
|
6337
|
-
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";
|
|
6353
|
+
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");
|
|
6338
6354
|
}
|
|
6339
6355
|
function isAppearance(value) {
|
|
6340
6356
|
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");
|
|
6341
6357
|
}
|
|
6358
|
+
function isIdentity(value) {
|
|
6359
|
+
if (value === null || value === void 0) return true;
|
|
6360
|
+
if (!isRecord(value)) return false;
|
|
6361
|
+
const policyOk = value.policy === "unverified" || value.policy === "verified" || value.policy === "both";
|
|
6362
|
+
const issuersOk = Array.isArray(value.issuers) && value.issuers.every((issuer) => isRecord(issuer) && typeof issuer.iss === "string" && typeof issuer.aud === "string" && (issuer.alg === "HS256" || issuer.alg === "RS256"));
|
|
6363
|
+
return policyOk && issuersOk;
|
|
6364
|
+
}
|
|
6342
6365
|
function isStatus(value) {
|
|
6343
6366
|
return value === "draft" || value === "active" || value === "disabled";
|
|
6344
6367
|
}
|
|
6345
6368
|
function mapRow(row) {
|
|
6346
|
-
if (!isStatus(row.status) || !isIntegration(row.integration) || !isScope(row.scope) || !isFeatures(row.features) || !isAppearance(row.appearance)) {
|
|
6369
|
+
if (!isStatus(row.status) || !isIntegration(row.integration) || !isScope(row.scope) || !isFeatures(row.features) || !isAppearance(row.appearance) || !isIdentity(row.identity)) {
|
|
6347
6370
|
throw new Error(`Invalid agent web app row: ${row.id}`);
|
|
6348
6371
|
}
|
|
6349
6372
|
return {
|
|
@@ -6357,6 +6380,7 @@ function mapRow(row) {
|
|
|
6357
6380
|
scope: row.scope,
|
|
6358
6381
|
features: row.features,
|
|
6359
6382
|
appearance: row.appearance,
|
|
6383
|
+
identity: row.identity === null ? void 0 : row.identity,
|
|
6360
6384
|
createdAt: row.created_at,
|
|
6361
6385
|
updatedAt: row.updated_at
|
|
6362
6386
|
};
|
|
@@ -6377,6 +6401,7 @@ var PostgreSQLAgentWebAppStore = class {
|
|
|
6377
6401
|
})();
|
|
6378
6402
|
this.migrationManager = new MigrationManager(this.pool);
|
|
6379
6403
|
this.migrationManager.register(createAgentWebAppsTable);
|
|
6404
|
+
this.migrationManager.register(addAgentWebAppsIdentity);
|
|
6380
6405
|
if (options.autoMigrate !== false) {
|
|
6381
6406
|
this.startInitialization();
|
|
6382
6407
|
}
|
|
@@ -6437,8 +6462,8 @@ var PostgreSQLAgentWebAppStore = class {
|
|
|
6437
6462
|
const id = `webapp_${randomUUID2().replace(/-/g, "")}`;
|
|
6438
6463
|
const result = await this.pool.query(
|
|
6439
6464
|
`INSERT INTO lattice_agent_web_apps
|
|
6440
|
-
(id, tenant_id, assistant_id, name, description, status, integration, scope, features, appearance)
|
|
6441
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb, $8::jsonb, $9::jsonb, $10::jsonb)
|
|
6465
|
+
(id, tenant_id, assistant_id, name, description, status, integration, scope, features, appearance, identity)
|
|
6466
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb, $8::jsonb, $9::jsonb, $10::jsonb, $11::jsonb)
|
|
6442
6467
|
RETURNING *`,
|
|
6443
6468
|
[
|
|
6444
6469
|
id,
|
|
@@ -6450,7 +6475,8 @@ var PostgreSQLAgentWebAppStore = class {
|
|
|
6450
6475
|
JSON.stringify(input.integration),
|
|
6451
6476
|
JSON.stringify(input.scope),
|
|
6452
6477
|
JSON.stringify(input.features),
|
|
6453
|
-
JSON.stringify(input.appearance)
|
|
6478
|
+
JSON.stringify(input.appearance),
|
|
6479
|
+
input.identity ? JSON.stringify(input.identity) : null
|
|
6454
6480
|
]
|
|
6455
6481
|
);
|
|
6456
6482
|
return mapRow(result.rows[0]);
|
|
@@ -6476,6 +6502,9 @@ var PostgreSQLAgentWebAppStore = class {
|
|
|
6476
6502
|
if (patch.appearance !== void 0) {
|
|
6477
6503
|
add("appearance", JSON.stringify(patch.appearance));
|
|
6478
6504
|
}
|
|
6505
|
+
if (patch.identity !== void 0) {
|
|
6506
|
+
add("identity", JSON.stringify(patch.identity));
|
|
6507
|
+
}
|
|
6479
6508
|
if (patch.status !== void 0) add("status", patch.status);
|
|
6480
6509
|
if (assignments.length === 0) return this.getById(tenantId, webAppId);
|
|
6481
6510
|
values.push(tenantId, webAppId);
|
|
@@ -10424,6 +10453,7 @@ async function createPgStoreConfig(connectionString) {
|
|
|
10424
10453
|
mm.register(createProjectRoomTables);
|
|
10425
10454
|
mm.register(addTrustedRunContextColumn);
|
|
10426
10455
|
mm.register(addProjectLifecycleEventIndex);
|
|
10456
|
+
mm.register(addAgentWebAppsIdentity);
|
|
10427
10457
|
await mm.migrate();
|
|
10428
10458
|
const checkpoint = PostgresSaver.fromConnString(connectionString);
|
|
10429
10459
|
checkpoint.setup().catch((err) => {
|