@cat-factory/node-server 0.87.9 → 0.88.0

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.
@@ -2,7 +2,7 @@ import { LLM_WARNING_FINISH_REASONS } from '@cat-factory/kernel';
2
2
  import { agentRunKindSchema, decodeInitiativeRow, isWebSearchProvider, } from '@cat-factory/contracts';
3
3
  import { decodeEnum, tryDecodeRows, blockInsertValues, blockPatchToColumns, parseIssueIntakeColumn, serializeIssueIntakeColumn, rowToBlock, rowToExecution, executionToDetail, rowToPipeline, rowToSandboxExperiment, rowToSandboxFixture, rowToSandboxGrade, rowToSandboxPromptVersion, rowToSandboxRun, rowToWorkspace, } from '@cat-factory/server';
4
4
  import { and, asc, count, desc, eq, gte, inArray, isNull, lt, ne, notInArray, or, sql, } from 'drizzle-orm';
5
- import { accountInvitations, passwordResetTokens, accountSettings, localSettings, accounts, agentContextSnapshots, agentSearchQueries, agentRuns, blocks, consensusSessions, incidentEnrichmentConnections, observabilityConnections, packageRegistryConnections, emailConnections, llmCallMetrics, provisioningLog, sharedStacks, memberships, mergeThresholdPresets, releaseHealthConfigs, pipelineScheduleRuns, pipelineSchedules, pipelines, requirementReviews, docInterviewSessions, kaizenGradings, kaizenVerifiedCombos, clarityReviews, binaryArtifacts, brainstormSessions, initiatives, sandboxPromptVersions, sandboxFixtures, sandboxExperiments, sandboxRuns, sandboxGrades, services, tokenUsage, trackerSettings, modelPresets, userIdentities, users, userSettings, workspaceFragmentDefaults, workspaceServices, workspaceSettings, workspaces, } from '../db/schema.js';
5
+ import { accountInvitations, passwordResetTokens, accountSettings, localSettings, accounts, agentContextSnapshots, agentSearchQueries, agentRuns, blocks, consensusSessions, incidentEnrichmentConnections, observabilityConnections, packageRegistryConnections, emailConnections, llmCallMetrics, provisioningLog, sharedStacks, memberships, mergeThresholdPresets, releaseHealthConfigs, testSecrets, pipelineScheduleRuns, pipelineSchedules, pipelines, requirementReviews, docInterviewSessions, kaizenGradings, kaizenVerifiedCombos, clarityReviews, binaryArtifacts, brainstormSessions, initiatives, sandboxPromptVersions, sandboxFixtures, sandboxExperiments, sandboxRuns, sandboxGrades, services, tokenUsage, trackerSettings, modelPresets, userIdentities, users, userSettings, workspaceFragmentDefaults, workspaceServices, workspaceSettings, workspaces, } from '../db/schema.js';
6
6
  // Drizzle/Postgres implementations of the core kernel repository ports. The
7
7
  // row<->domain mapping is the SAME shared mapping the Cloudflare D1 repos use
8
8
  // (@cat-factory/server), so behaviour matches across stores; this layer only owns
@@ -3825,6 +3825,77 @@ class DrizzleReleaseHealthConfigRepository {
3825
3825
  .where(and(eq(releaseHealthConfigs.workspace_id, workspaceId), eq(releaseHealthConfigs.block_id, blockId)));
3826
3826
  }
3827
3827
  }
3828
+ /**
3829
+ * A service frame's sensitive test credentials over Postgres (the Drizzle mirror of the
3830
+ * Worker's `D1TestSecretsRepository`, migration 0044). At most one row per (workspace, block);
3831
+ * `credentials` is a sealed envelope of the `TestSecretEntry[]` JSON, `summary` a non-secret
3832
+ * `TestSecretRef[]` display blob.
3833
+ */
3834
+ export class DrizzleTestSecretsRepository {
3835
+ db;
3836
+ constructor(db) {
3837
+ this.db = db;
3838
+ }
3839
+ async getByBlock(workspaceId, blockId) {
3840
+ const rows = await this.db
3841
+ .select()
3842
+ .from(testSecrets)
3843
+ .where(and(eq(testSecrets.workspace_id, workspaceId), eq(testSecrets.block_id, blockId)))
3844
+ .limit(1);
3845
+ const row = rows[0];
3846
+ if (!row)
3847
+ return null;
3848
+ return {
3849
+ workspaceId: row.workspace_id,
3850
+ blockId: row.block_id,
3851
+ credentials: row.credentials,
3852
+ summary: row.summary,
3853
+ createdAt: row.created_at,
3854
+ updatedAt: row.updated_at,
3855
+ };
3856
+ }
3857
+ async listByWorkspace(workspaceId) {
3858
+ const rows = await this.db
3859
+ .select()
3860
+ .from(testSecrets)
3861
+ .where(eq(testSecrets.workspace_id, workspaceId))
3862
+ .orderBy(testSecrets.block_id);
3863
+ return rows.map((row) => ({
3864
+ workspaceId: row.workspace_id,
3865
+ blockId: row.block_id,
3866
+ credentials: row.credentials,
3867
+ summary: row.summary,
3868
+ createdAt: row.created_at,
3869
+ updatedAt: row.updated_at,
3870
+ }));
3871
+ }
3872
+ async upsert(record) {
3873
+ const values = {
3874
+ workspace_id: record.workspaceId,
3875
+ block_id: record.blockId,
3876
+ credentials: record.credentials,
3877
+ summary: record.summary,
3878
+ created_at: record.createdAt,
3879
+ updated_at: record.updatedAt,
3880
+ };
3881
+ await this.db
3882
+ .insert(testSecrets)
3883
+ .values(values)
3884
+ .onConflictDoUpdate({
3885
+ target: [testSecrets.workspace_id, testSecrets.block_id],
3886
+ set: {
3887
+ credentials: values.credentials,
3888
+ summary: values.summary,
3889
+ updated_at: values.updated_at,
3890
+ },
3891
+ });
3892
+ }
3893
+ async deleteByBlock(workspaceId, blockId) {
3894
+ await this.db
3895
+ .delete(testSecrets)
3896
+ .where(and(eq(testSecrets.workspace_id, workspaceId), eq(testSecrets.block_id, blockId)));
3897
+ }
3898
+ }
3828
3899
  /** Build the Drizzle/Postgres-backed core repositories. */
3829
3900
  export function createDrizzleRepositories(db, clock) {
3830
3901
  return {
@@ -3867,6 +3938,7 @@ export function createDrizzleRepositories(db, clock) {
3867
3938
  incidentEnrichmentConnectionRepository: new DrizzleIncidentEnrichmentConnectionRepository(db),
3868
3939
  accountSettingsRepository: new DrizzleAccountSettingsRepository(db),
3869
3940
  releaseHealthConfigRepository: new DrizzleReleaseHealthConfigRepository(db),
3941
+ testSecretsRepository: new DrizzleTestSecretsRepository(db),
3870
3942
  provisioningLogRepository: new DrizzleProvisioningLogRepository(db),
3871
3943
  };
3872
3944
  }