@mastra/factory 0.0.0 → 0.1.0-alpha.3
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/CHANGELOG.md +23 -0
- package/LICENSE.md +30 -0
- package/dist/auth.d.ts +181 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +370 -0
- package/dist/auth.js.map +1 -0
- package/dist/capabilities/connection.d.ts +9 -0
- package/dist/capabilities/connection.d.ts.map +1 -0
- package/dist/capabilities/connection.js +1 -0
- package/dist/capabilities/connection.js.map +1 -0
- package/dist/capabilities/intake.d.ts +93 -0
- package/dist/capabilities/intake.d.ts.map +1 -0
- package/dist/capabilities/intake.js +1 -0
- package/dist/capabilities/intake.js.map +1 -0
- package/dist/capabilities/version-control.d.ts +239 -0
- package/dist/capabilities/version-control.d.ts.map +1 -0
- package/dist/capabilities/version-control.js +1 -0
- package/dist/capabilities/version-control.js.map +1 -0
- package/dist/factory.d.ts +145 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +38245 -0
- package/dist/factory.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38245 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/base.d.ts +197 -0
- package/dist/integrations/base.d.ts.map +1 -0
- package/dist/integrations/base.js +1 -0
- package/dist/integrations/base.js.map +1 -0
- package/dist/integrations/github/config.d.ts +60 -0
- package/dist/integrations/github/config.d.ts.map +1 -0
- package/dist/integrations/github/config.js +28 -0
- package/dist/integrations/github/config.js.map +1 -0
- package/dist/integrations/github/factory-session.d.ts +12 -0
- package/dist/integrations/github/factory-session.d.ts.map +1 -0
- package/dist/integrations/github/factory-session.js +41 -0
- package/dist/integrations/github/factory-session.js.map +1 -0
- package/dist/integrations/github/integration.d.ts +191 -0
- package/dist/integrations/github/integration.d.ts.map +1 -0
- package/dist/integrations/github/integration.js +3001 -0
- package/dist/integrations/github/integration.js.map +1 -0
- package/dist/integrations/github/issue-triage.d.ts +27 -0
- package/dist/integrations/github/issue-triage.d.ts.map +1 -0
- package/dist/integrations/github/issue-triage.js +82 -0
- package/dist/integrations/github/issue-triage.js.map +1 -0
- package/dist/integrations/github/project-lock.d.ts +78 -0
- package/dist/integrations/github/project-lock.d.ts.map +1 -0
- package/dist/integrations/github/project-lock.js +70 -0
- package/dist/integrations/github/project-lock.js.map +1 -0
- package/dist/integrations/github/provenance.d.ts +27 -0
- package/dist/integrations/github/provenance.d.ts.map +1 -0
- package/dist/integrations/github/provenance.js +104 -0
- package/dist/integrations/github/provenance.js.map +1 -0
- package/dist/integrations/github/routes.d.ts +72 -0
- package/dist/integrations/github/routes.d.ts.map +1 -0
- package/dist/integrations/github/routes.js +1834 -0
- package/dist/integrations/github/routes.js.map +1 -0
- package/dist/integrations/github/sandbox.d.ts +268 -0
- package/dist/integrations/github/sandbox.d.ts.map +1 -0
- package/dist/integrations/github/sandbox.js +381 -0
- package/dist/integrations/github/sandbox.js.map +1 -0
- package/dist/integrations/github/session-subscriptions.d.ts +23 -0
- package/dist/integrations/github/session-subscriptions.d.ts.map +1 -0
- package/dist/integrations/github/session-subscriptions.js +190 -0
- package/dist/integrations/github/session-subscriptions.js.map +1 -0
- package/dist/integrations/github/subscriptions.d.ts +54 -0
- package/dist/integrations/github/subscriptions.d.ts.map +1 -0
- package/dist/integrations/github/subscriptions.js +70 -0
- package/dist/integrations/github/subscriptions.js.map +1 -0
- package/dist/integrations/github/webhook.d.ts +87 -0
- package/dist/integrations/github/webhook.d.ts.map +1 -0
- package/dist/integrations/github/webhook.js +381 -0
- package/dist/integrations/github/webhook.js.map +1 -0
- package/dist/integrations/linear/agent-tools.d.ts +34 -0
- package/dist/integrations/linear/agent-tools.d.ts.map +1 -0
- package/dist/integrations/linear/agent-tools.js +108 -0
- package/dist/integrations/linear/agent-tools.js.map +1 -0
- package/dist/integrations/linear/integration.d.ts +233 -0
- package/dist/integrations/linear/integration.d.ts.map +1 -0
- package/dist/integrations/linear/integration.js +962 -0
- package/dist/integrations/linear/integration.js.map +1 -0
- package/dist/integrations/linear/routes.d.ts +61 -0
- package/dist/integrations/linear/routes.d.ts.map +1 -0
- package/dist/integrations/linear/routes.js +242 -0
- package/dist/integrations/linear/routes.js.map +1 -0
- package/dist/integrations/linear/storage.d.ts +65 -0
- package/dist/integrations/linear/storage.d.ts.map +1 -0
- package/dist/integrations/linear/storage.js +1 -0
- package/dist/integrations/linear/storage.js.map +1 -0
- package/dist/integrations/platform/api-client.d.ts +24 -0
- package/dist/integrations/platform/api-client.d.ts.map +1 -0
- package/dist/integrations/platform/api-client.js +153 -0
- package/dist/integrations/platform/api-client.js.map +1 -0
- package/dist/integrations/platform/github/event-worker.d.ts +44 -0
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -0
- package/dist/integrations/platform/github/event-worker.js +585 -0
- package/dist/integrations/platform/github/event-worker.js.map +1 -0
- package/dist/integrations/platform/github/integration.d.ts +36 -0
- package/dist/integrations/platform/github/integration.d.ts.map +1 -0
- package/dist/integrations/platform/github/integration.js +3253 -0
- package/dist/integrations/platform/github/integration.js.map +1 -0
- package/dist/integrations/platform/linear/integration.d.ts +46 -0
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -0
- package/dist/integrations/platform/linear/integration.js +891 -0
- package/dist/integrations/platform/linear/integration.js.map +1 -0
- package/dist/integrations/workos/integration.d.ts +39 -0
- package/dist/integrations/workos/integration.d.ts.map +1 -0
- package/dist/integrations/workos/integration.js +96 -0
- package/dist/integrations/workos/integration.js.map +1 -0
- package/dist/routes/config.d.ts +220 -0
- package/dist/routes/config.d.ts.map +1 -0
- package/dist/routes/config.js +770 -0
- package/dist/routes/config.js.map +1 -0
- package/dist/routes/fs.d.ts +105 -0
- package/dist/routes/fs.d.ts.map +1 -0
- package/dist/routes/fs.js +294 -0
- package/dist/routes/fs.js.map +1 -0
- package/dist/routes/intake.d.ts +23 -0
- package/dist/routes/intake.d.ts.map +1 -0
- package/dist/routes/intake.js +179 -0
- package/dist/routes/intake.js.map +1 -0
- package/dist/routes/oauth.d.ts +43 -0
- package/dist/routes/oauth.d.ts.map +1 -0
- package/dist/routes/oauth.js +25058 -0
- package/dist/routes/oauth.js.map +1 -0
- package/dist/routes/projects.d.ts +19 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +395 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/provider-credentials.d.ts +81 -0
- package/dist/routes/provider-credentials.d.ts.map +1 -0
- package/dist/routes/provider-credentials.js +68 -0
- package/dist/routes/provider-credentials.js.map +1 -0
- package/dist/routes/route.d.ts +48 -0
- package/dist/routes/route.d.ts.map +1 -0
- package/dist/routes/route.js +11 -0
- package/dist/routes/route.js.map +1 -0
- package/dist/routes/skills.d.ts +30 -0
- package/dist/routes/skills.d.ts.map +1 -0
- package/dist/routes/skills.js +181 -0
- package/dist/routes/skills.js.map +1 -0
- package/dist/routes/surface.d.ts +83 -0
- package/dist/routes/surface.d.ts.map +1 -0
- package/dist/routes/surface.js +28519 -0
- package/dist/routes/surface.js.map +1 -0
- package/dist/routes/tenant-credentials.d.ts +74 -0
- package/dist/routes/tenant-credentials.d.ts.map +1 -0
- package/dist/routes/tenant-credentials.js +181 -0
- package/dist/routes/tenant-credentials.js.map +1 -0
- package/dist/routes/work-items.d.ts +40 -0
- package/dist/routes/work-items.d.ts.map +1 -0
- package/dist/routes/work-items.js +902 -0
- package/dist/routes/work-items.js.map +1 -0
- package/dist/rules/binding-context.d.ts +5 -0
- package/dist/rules/binding-context.d.ts.map +1 -0
- package/dist/rules/binding-context.js +40 -0
- package/dist/rules/binding-context.js.map +1 -0
- package/dist/rules/defaults.d.ts +9 -0
- package/dist/rules/defaults.d.ts.map +1 -0
- package/dist/rules/defaults.js +334 -0
- package/dist/rules/defaults.js.map +1 -0
- package/dist/rules/dispatcher.d.ts +40 -0
- package/dist/rules/dispatcher.d.ts.map +1 -0
- package/dist/rules/dispatcher.js +695 -0
- package/dist/rules/dispatcher.js.map +1 -0
- package/dist/rules/github-service.d.ts +29 -0
- package/dist/rules/github-service.d.ts.map +1 -0
- package/dist/rules/github-service.js +474 -0
- package/dist/rules/github-service.js.map +1 -0
- package/dist/rules/index.d.ts +7 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +583 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/linear-service.d.ts +27 -0
- package/dist/rules/linear-service.d.ts.map +1 -0
- package/dist/rules/linear-service.js +343 -0
- package/dist/rules/linear-service.js.map +1 -0
- package/dist/rules/processor.d.ts +54 -0
- package/dist/rules/processor.d.ts.map +1 -0
- package/dist/rules/processor.js +629 -0
- package/dist/rules/processor.js.map +1 -0
- package/dist/rules/resolve.d.ts +17 -0
- package/dist/rules/resolve.d.ts.map +1 -0
- package/dist/rules/resolve.js +27 -0
- package/dist/rules/resolve.js.map +1 -0
- package/dist/rules/start-coordinator.d.ts +58 -0
- package/dist/rules/start-coordinator.d.ts.map +1 -0
- package/dist/rules/start-coordinator.js +136 -0
- package/dist/rules/start-coordinator.js.map +1 -0
- package/dist/rules/tools.d.ts +10 -0
- package/dist/rules/tools.d.ts.map +1 -0
- package/dist/rules/tools.js +93 -0
- package/dist/rules/tools.js.map +1 -0
- package/dist/rules/transition-service.d.ts +32 -0
- package/dist/rules/transition-service.d.ts.map +1 -0
- package/dist/rules/transition-service.js +474 -0
- package/dist/rules/transition-service.js.map +1 -0
- package/dist/rules/types.d.ts +225 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +33 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/rules/validation.d.ts +11 -0
- package/dist/rules/validation.d.ts.map +1 -0
- package/dist/rules/validation.js +310 -0
- package/dist/rules/validation.js.map +1 -0
- package/dist/sandbox/fleet.d.ts +208 -0
- package/dist/sandbox/fleet.d.ts.map +1 -0
- package/dist/sandbox/fleet.js +259 -0
- package/dist/sandbox/fleet.js.map +1 -0
- package/dist/sandbox/reattach.d.ts +3 -0
- package/dist/sandbox/reattach.d.ts.map +1 -0
- package/dist/sandbox/reattach.js +9 -0
- package/dist/sandbox/reattach.js.map +1 -0
- package/dist/server-error.d.ts +12 -0
- package/dist/server-error.d.ts.map +1 -0
- package/dist/server-error.js +20 -0
- package/dist/server-error.js.map +1 -0
- package/dist/skills/service.d.ts +48 -0
- package/dist/skills/service.d.ts.map +1 -0
- package/dist/skills/service.js +45 -0
- package/dist/skills/service.js.map +1 -0
- package/dist/spa-static.d.ts +34 -0
- package/dist/spa-static.d.ts.map +1 -0
- package/dist/spa-static.js +73 -0
- package/dist/spa-static.js.map +1 -0
- package/dist/state-signing.d.ts +48 -0
- package/dist/state-signing.d.ts.map +1 -0
- package/dist/state-signing.js +48 -0
- package/dist/state-signing.js.map +1 -0
- package/dist/storage/domains/audit/agent-audit.d.ts +27 -0
- package/dist/storage/domains/audit/agent-audit.d.ts.map +1 -0
- package/dist/storage/domains/audit/agent-audit.js +65 -0
- package/dist/storage/domains/audit/agent-audit.js.map +1 -0
- package/dist/storage/domains/audit/base.d.ts +140 -0
- package/dist/storage/domains/audit/base.d.ts.map +1 -0
- package/dist/storage/domains/audit/base.js +127 -0
- package/dist/storage/domains/audit/base.js.map +1 -0
- package/dist/storage/domains/audit/domain.d.ts +69 -0
- package/dist/storage/domains/audit/domain.d.ts.map +1 -0
- package/dist/storage/domains/audit/domain.js +165 -0
- package/dist/storage/domains/audit/domain.js.map +1 -0
- package/dist/storage/domains/credentials/base.d.ts +134 -0
- package/dist/storage/domains/credentials/base.d.ts.map +1 -0
- package/dist/storage/domains/credentials/base.js +257 -0
- package/dist/storage/domains/credentials/base.js.map +1 -0
- package/dist/storage/domains/intake/base.d.ts +38 -0
- package/dist/storage/domains/intake/base.d.ts.map +1 -0
- package/dist/storage/domains/intake/base.js +62 -0
- package/dist/storage/domains/intake/base.js.map +1 -0
- package/dist/storage/domains/integrations/base.d.ts +126 -0
- package/dist/storage/domains/integrations/base.d.ts.map +1 -0
- package/dist/storage/domains/integrations/base.js +252 -0
- package/dist/storage/domains/integrations/base.js.map +1 -0
- package/dist/storage/domains/model-packs/base.d.ts +49 -0
- package/dist/storage/domains/model-packs/base.d.ts.map +1 -0
- package/dist/storage/domains/model-packs/base.js +95 -0
- package/dist/storage/domains/model-packs/base.js.map +1 -0
- package/dist/storage/domains/projects/base.d.ts +55 -0
- package/dist/storage/domains/projects/base.d.ts.map +1 -0
- package/dist/storage/domains/projects/base.js +99 -0
- package/dist/storage/domains/projects/base.js.map +1 -0
- package/dist/storage/domains/queue-health/base.d.ts +52 -0
- package/dist/storage/domains/queue-health/base.d.ts.map +1 -0
- package/dist/storage/domains/queue-health/base.js +87 -0
- package/dist/storage/domains/queue-health/base.js.map +1 -0
- package/dist/storage/domains/source-control/base.d.ts +288 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -0
- package/dist/storage/domains/source-control/base.js +722 -0
- package/dist/storage/domains/source-control/base.js.map +1 -0
- package/dist/storage/domains/source-control/inmemory.d.ts +158 -0
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/source-control/inmemory.js +348 -0
- package/dist/storage/domains/source-control/inmemory.js.map +1 -0
- package/dist/storage/domains/work-items/base.d.ts +412 -0
- package/dist/storage/domains/work-items/base.d.ts.map +1 -0
- package/dist/storage/domains/work-items/base.js +1174 -0
- package/dist/storage/domains/work-items/base.js.map +1 -0
- package/dist/storage/domains/work-items/metrics.d.ts +101 -0
- package/dist/storage/domains/work-items/metrics.d.ts.map +1 -0
- package/dist/storage/domains/work-items/metrics.js +203 -0
- package/dist/storage/domains/work-items/metrics.js.map +1 -0
- package/dist/workspace.d.ts +20 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +364 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +19 -19
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/storage/domains/source-control/base.ts"],"sourcesContent":["import { FactoryStorageDomain, UniqueViolationError } from '@mastra/core/storage';\nimport type { CollectionSchema, FactoryStorageOps } from '@mastra/core/storage';\n\nconst FACTORY_PROJECTS = 'factory_projects';\nconst INSTALLATIONS = 'source_control_installations';\nconst REPOSITORIES = 'source_control_repositories';\nconst CONNECTIONS = 'factory_project_source_control_connections';\nconst PROJECT_REPOSITORIES = 'factory_project_repositories';\nconst SANDBOXES = 'source_control_project_repository_sandboxes';\nconst WORKTREES = 'source_control_worktrees';\nconst SESSIONS = 'source_control_sessions';\n\nexport const SOURCE_CONTROL_SCHEMAS: CollectionSchema[] = [\n {\n name: INSTALLATIONS,\n columns: {\n id: { type: 'uuid-pk' },\n integration_id: { type: 'text' },\n org_id: { type: 'text' },\n connected_by_user_id: { type: 'text' },\n external_id: { type: 'text' },\n account_name: { type: 'text', nullable: true },\n account_type: { type: 'text', nullable: true },\n provider_metadata: { type: 'json' },\n created_at: { type: 'timestamp' },\n },\n uniqueIndexes: [\n {\n name: 'source_control_installations_integration_org_external_unique',\n columns: ['integration_id', 'org_id', 'external_id'],\n },\n ],\n },\n {\n name: REPOSITORIES,\n columns: {\n id: { type: 'uuid-pk' },\n installation_id: { type: 'text' },\n external_id: { type: 'text' },\n slug: { type: 'text' },\n default_branch: { type: 'text', default: 'main' },\n provider_metadata: { type: 'json' },\n created_at: { type: 'timestamp' },\n updated_at: { type: 'timestamp' },\n },\n uniqueIndexes: [\n {\n name: 'source_control_repositories_installation_external_unique',\n columns: ['installation_id', 'external_id'],\n },\n ],\n indexes: [\n {\n name: 'source_control_repositories_installation_slug_idx',\n columns: ['installation_id', 'slug'],\n },\n ],\n },\n {\n name: CONNECTIONS,\n columns: {\n id: { type: 'uuid-pk' },\n factory_project_id: { type: 'text' },\n integration_id: { type: 'text' },\n installation_id: { type: 'text' },\n created_by_user_id: { type: 'text' },\n created_at: { type: 'timestamp' },\n },\n uniqueIndexes: [\n {\n name: 'factory_project_source_control_connections_project_integration_installation_unique',\n columns: ['factory_project_id', 'integration_id', 'installation_id'],\n },\n ],\n indexes: [\n {\n name: 'factory_project_source_control_connections_project_idx',\n columns: ['factory_project_id'],\n },\n ],\n },\n {\n name: PROJECT_REPOSITORIES,\n columns: {\n id: { type: 'uuid-pk' },\n connection_id: { type: 'text' },\n repository_id: { type: 'text' },\n created_by_user_id: { type: 'text' },\n branch: { type: 'text', nullable: true },\n sandbox_provider: { type: 'text' },\n sandbox_workdir: { type: 'text' },\n setup_command: { type: 'text', nullable: true },\n created_at: { type: 'timestamp' },\n updated_at: { type: 'timestamp' },\n },\n uniqueIndexes: [\n {\n name: 'factory_project_repositories_connection_repository_unique',\n columns: ['connection_id', 'repository_id'],\n },\n ],\n indexes: [\n {\n name: 'factory_project_repositories_connection_idx',\n columns: ['connection_id'],\n },\n ],\n },\n {\n name: SANDBOXES,\n columns: {\n id: { type: 'uuid-pk' },\n project_repository_id: { type: 'text' },\n user_id: { type: 'text' },\n sandbox_id: { type: 'text', nullable: true },\n sandbox_workdir: { type: 'text' },\n materialized_at: { type: 'timestamp', nullable: true },\n created_at: { type: 'timestamp' },\n },\n uniqueIndexes: [\n {\n name: 'source_control_project_repository_sandboxes_link_user_unique',\n columns: ['project_repository_id', 'user_id'],\n },\n ],\n },\n {\n name: WORKTREES,\n columns: {\n id: { type: 'uuid-pk' },\n project_repository_id: { type: 'text' },\n user_id: { type: 'text' },\n branch: { type: 'text' },\n base_branch: { type: 'text' },\n worktree_path: { type: 'text' },\n created_at: { type: 'timestamp' },\n },\n uniqueIndexes: [\n {\n name: 'source_control_worktrees_project_repository_user_branch_unique',\n columns: ['project_repository_id', 'user_id', 'branch'],\n },\n ],\n },\n {\n name: SESSIONS,\n columns: {\n id: { type: 'uuid-pk' },\n session_id: { type: 'text' },\n project_repository_id: { type: 'text' },\n org_id: { type: 'text' },\n user_id: { type: 'text' },\n branch: { type: 'text' },\n base_branch: { type: 'text' },\n sandbox_id: { type: 'text', nullable: true },\n sandbox_workdir: { type: 'text', nullable: true },\n materialized_at: { type: 'timestamp', nullable: true },\n created_at: { type: 'timestamp' },\n updated_at: { type: 'timestamp' },\n },\n uniqueIndexes: [\n { name: 'source_control_sessions_session_id_unique', columns: ['session_id'] },\n {\n name: 'source_control_sessions_repository_user_branch_unique',\n columns: ['project_repository_id', 'user_id', 'branch'],\n },\n ],\n },\n];\n\nexport type SourceControlProviderMetadata = Record<string, unknown>;\n\nexport interface SourceControlInstallation {\n id: string;\n integrationId: string;\n orgId: string;\n connectedByUserId: string;\n externalId: string;\n accountName: string | null;\n accountType: string | null;\n providerMetadata: SourceControlProviderMetadata;\n createdAt: Date;\n}\n\nexport interface UpsertSourceControlInstallationInput {\n orgId: string;\n connectedByUserId: string;\n externalId: string;\n accountName?: string | null;\n accountType?: string | null;\n providerMetadata?: SourceControlProviderMetadata;\n}\n\nexport interface SourceControlRepository {\n id: string;\n installationId: string;\n externalId: string;\n slug: string;\n defaultBranch: string;\n providerMetadata: SourceControlProviderMetadata;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface UpsertSourceControlRepositoryInput {\n installationId: string;\n externalId: string;\n slug: string;\n defaultBranch: string;\n providerMetadata?: SourceControlProviderMetadata;\n}\n\nexport interface ProjectSourceControlConnection {\n id: string;\n factoryProjectId: string;\n integrationId: string;\n installationId: string;\n createdByUserId: string;\n createdAt: Date;\n}\n\nexport interface CreateProjectSourceControlConnectionInput {\n orgId: string;\n factoryProjectId: string;\n installationId: string;\n createdByUserId: string;\n}\n\nexport interface ProjectRepository {\n id: string;\n connectionId: string;\n repositoryId: string;\n createdByUserId: string;\n branch: string | null;\n sandboxProvider: string;\n sandboxWorkdir: string;\n setupCommand: string | null;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface ExternalRepositoryProjectTarget {\n orgId: string;\n factoryProjectId: string;\n projectRepository: ProjectRepository;\n}\n\nexport interface LinkProjectRepositoryInput {\n orgId: string;\n connectionId: string;\n repositoryId: string;\n createdByUserId: string;\n branch?: string | null;\n sandboxProvider: string;\n sandboxWorkdir: string;\n setupCommand?: string | null;\n}\n\nexport interface UpdateProjectRepositoryInput {\n branch?: string | null;\n sandboxProvider?: string;\n sandboxWorkdir?: string;\n setupCommand?: string | null;\n}\n\nexport interface ProjectRepositorySandbox {\n id: string;\n projectRepositoryId: string;\n userId: string;\n sandboxId: string | null;\n sandboxWorkdir: string;\n materializedAt: Date | null;\n createdAt: Date;\n}\n\nexport interface SourceControlWorktree {\n id: string;\n projectRepositoryId: string;\n userId: string;\n branch: string;\n baseBranch: string;\n worktreePath: string;\n createdAt: Date;\n}\n\nexport interface UpsertSourceControlWorktreeInput {\n projectRepositoryId: string;\n userId: string;\n branch: string;\n baseBranch: string;\n worktreePath: string;\n}\n\nexport interface SourceControlSession {\n id: string;\n sessionId: string;\n projectRepositoryId: string;\n orgId: string;\n userId: string;\n branch: string;\n baseBranch: string;\n sandboxId: string | null;\n sandboxWorkdir: string | null;\n materializedAt: Date | null;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface CreateSourceControlSessionInput {\n sessionId: string;\n projectRepositoryId: string;\n orgId: string;\n userId: string;\n branch: string;\n baseBranch: string;\n}\n\nexport interface SourceControlStorageHandle {\n readonly integrationId: string;\n readonly installations: {\n list(args: { orgId: string }): Promise<SourceControlInstallation[]>;\n get(args: { orgId: string; id: string }): Promise<SourceControlInstallation | null>;\n findByExternalId(args: { orgId: string; externalId: string }): Promise<SourceControlInstallation | null>;\n upsert(args: UpsertSourceControlInstallationInput): Promise<SourceControlInstallation>;\n delete(args: { orgId: string; id: string }): Promise<boolean>;\n };\n readonly repositories: {\n list(args: { orgId: string; installationId: string }): Promise<SourceControlRepository[]>;\n get(args: { orgId: string; id: string }): Promise<SourceControlRepository | null>;\n findByExternalId(args: {\n orgId: string;\n installationId: string;\n externalId: string;\n }): Promise<SourceControlRepository | null>;\n findBySlug(args: { orgId: string; installationId: string; slug: string }): Promise<SourceControlRepository | null>;\n upsert(args: { orgId: string; input: UpsertSourceControlRepositoryInput }): Promise<SourceControlRepository>;\n };\n readonly connections: {\n list(args: { orgId: string; factoryProjectId: string }): Promise<ProjectSourceControlConnection[]>;\n get(args: { orgId: string; id: string }): Promise<ProjectSourceControlConnection | null>;\n create(args: CreateProjectSourceControlConnectionInput): Promise<ProjectSourceControlConnection>;\n delete(args: { orgId: string; id: string }): Promise<boolean>;\n };\n readonly projectRepositories: {\n list(args: { orgId: string; connectionId: string }): Promise<ProjectRepository[]>;\n listByExternalRepository(args: {\n installationExternalId: string;\n repositoryExternalId: string;\n }): Promise<ExternalRepositoryProjectTarget[]>;\n get(args: { orgId: string; id: string }): Promise<ProjectRepository | null>;\n link(args: LinkProjectRepositoryInput): Promise<ProjectRepository>;\n update(args: { orgId: string; id: string; input: UpdateProjectRepositoryInput }): Promise<ProjectRepository | null>;\n unlink(args: { orgId: string; id: string }): Promise<boolean>;\n };\n readonly sandboxes: {\n getOrCreate(args: { projectRepository: ProjectRepository; userId: string }): Promise<ProjectRepositorySandbox>;\n getById(args: { id: string }): Promise<ProjectRepositorySandbox | null>;\n setSandboxId(args: { id: string; sandboxId: string }): Promise<void>;\n clearBinding(args: { id: string }): Promise<void>;\n markMaterialized(args: { id: string }): Promise<void>;\n };\n readonly worktrees: {\n upsert(args: UpsertSourceControlWorktreeInput): Promise<void>;\n list(args: { projectRepositoryId: string; userId: string }): Promise<SourceControlWorktree[]>;\n get(args: { projectRepositoryId: string; userId: string; branch: string }): Promise<SourceControlWorktree | null>;\n findByPath(args: {\n projectRepositoryId: string;\n userId: string;\n worktreePath: string;\n }): Promise<SourceControlWorktree | null>;\n delete(args: { projectRepositoryId: string; userId: string; branch: string }): Promise<void>;\n };\n readonly sessions: {\n list(args: { projectRepositoryId: string; userId: string }): Promise<SourceControlSession[]>;\n getBySessionId(sessionId: string): Promise<SourceControlSession | null>;\n getForBranch(args: {\n projectRepositoryId: string;\n userId: string;\n branch: string;\n }): Promise<SourceControlSession | null>;\n create(input: CreateSourceControlSessionInput): Promise<SourceControlSession>;\n setSandbox(args: { id: string; sandboxId: string | null; sandboxWorkdir: string }): Promise<void>;\n markMaterialized(args: { id: string }): Promise<void>;\n delete(id: string): Promise<void>;\n };\n}\n\ninterface InstallationDbRow extends Record<string, unknown> {\n id: string;\n integration_id: string;\n org_id: string;\n connected_by_user_id: string;\n external_id: string;\n account_name: string | null;\n account_type: string | null;\n provider_metadata: SourceControlProviderMetadata;\n created_at: Date;\n}\n\ninterface RepositoryDbRow extends Record<string, unknown> {\n id: string;\n installation_id: string;\n external_id: string;\n slug: string;\n default_branch: string;\n provider_metadata: SourceControlProviderMetadata;\n created_at: Date;\n updated_at: Date;\n}\n\ninterface ConnectionDbRow extends Record<string, unknown> {\n id: string;\n factory_project_id: string;\n integration_id: string;\n installation_id: string;\n created_by_user_id: string;\n created_at: Date;\n}\n\ninterface ProjectRepositoryDbRow extends Record<string, unknown> {\n id: string;\n connection_id: string;\n repository_id: string;\n created_by_user_id: string;\n branch: string | null;\n sandbox_provider: string;\n sandbox_workdir: string;\n setup_command: string | null;\n created_at: Date;\n updated_at: Date;\n}\n\ninterface SandboxDbRow extends Record<string, unknown> {\n id: string;\n project_repository_id: string;\n user_id: string;\n sandbox_id: string | null;\n sandbox_workdir: string;\n materialized_at: Date | null;\n created_at: Date;\n}\n\ninterface WorktreeDbRow extends Record<string, unknown> {\n id: string;\n project_repository_id: string;\n user_id: string;\n branch: string;\n base_branch: string;\n worktree_path: string;\n created_at: Date;\n}\n\ninterface SessionDbRow extends Record<string, unknown> {\n id: string;\n session_id: string;\n project_repository_id: string;\n org_id: string;\n user_id: string;\n branch: string;\n base_branch: string;\n sandbox_id: string | null;\n sandbox_workdir: string | null;\n materialized_at: Date | null;\n created_at: Date;\n updated_at: Date;\n}\n\nfunction toInstallation(row: InstallationDbRow): SourceControlInstallation {\n return {\n id: row.id,\n integrationId: row.integration_id,\n orgId: row.org_id,\n connectedByUserId: row.connected_by_user_id,\n externalId: row.external_id,\n accountName: row.account_name,\n accountType: row.account_type,\n providerMetadata: row.provider_metadata,\n createdAt: row.created_at,\n };\n}\n\nfunction toRepository(row: RepositoryDbRow): SourceControlRepository {\n return {\n id: row.id,\n installationId: row.installation_id,\n externalId: row.external_id,\n slug: row.slug,\n defaultBranch: row.default_branch,\n providerMetadata: row.provider_metadata,\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n}\n\nfunction toConnection(row: ConnectionDbRow): ProjectSourceControlConnection {\n return {\n id: row.id,\n factoryProjectId: row.factory_project_id,\n integrationId: row.integration_id,\n installationId: row.installation_id,\n createdByUserId: row.created_by_user_id,\n createdAt: row.created_at,\n };\n}\n\nfunction toProjectRepository(row: ProjectRepositoryDbRow): ProjectRepository {\n return {\n id: row.id,\n connectionId: row.connection_id,\n repositoryId: row.repository_id,\n createdByUserId: row.created_by_user_id,\n branch: row.branch,\n sandboxProvider: row.sandbox_provider,\n sandboxWorkdir: row.sandbox_workdir,\n setupCommand: row.setup_command,\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n}\n\nfunction toSandbox(row: SandboxDbRow): ProjectRepositorySandbox {\n return {\n id: row.id,\n projectRepositoryId: row.project_repository_id,\n userId: row.user_id,\n sandboxId: row.sandbox_id,\n sandboxWorkdir: row.sandbox_workdir,\n materializedAt: row.materialized_at,\n createdAt: row.created_at,\n };\n}\n\nfunction toWorktree(row: WorktreeDbRow): SourceControlWorktree {\n return {\n id: row.id,\n projectRepositoryId: row.project_repository_id,\n userId: row.user_id,\n branch: row.branch,\n baseBranch: row.base_branch,\n worktreePath: row.worktree_path,\n createdAt: row.created_at,\n };\n}\n\nfunction toSession(row: SessionDbRow): SourceControlSession {\n return {\n id: row.id,\n sessionId: row.session_id,\n projectRepositoryId: row.project_repository_id,\n orgId: row.org_id,\n userId: row.user_id,\n branch: row.branch,\n baseBranch: row.base_branch,\n sandboxId: row.sandbox_id,\n sandboxWorkdir: row.sandbox_workdir,\n materializedAt: row.materialized_at,\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n}\n\nexport class SourceControlStorage extends FactoryStorageDomain {\n constructor() {\n super('source-control');\n }\n\n async init(): Promise<void> {\n await this.ensureCollections(SOURCE_CONTROL_SCHEMAS);\n }\n\n async dangerouslyClearAll(): Promise<void> {\n await this.ops.deleteMany(SESSIONS, {});\n await this.ops.deleteMany(WORKTREES, {});\n await this.ops.deleteMany(SANDBOXES, {});\n await this.ops.deleteMany(PROJECT_REPOSITORIES, {});\n await this.ops.deleteMany(CONNECTIONS, {});\n await this.ops.deleteMany(REPOSITORIES, {});\n await this.ops.deleteMany(INSTALLATIONS, {});\n }\n\n forIntegration(integrationId: string): SourceControlStorageHandle {\n if (!integrationId.trim()) throw new Error('[SourceControlStorage] integrationId must not be empty.');\n const db = (): FactoryStorageOps => this.ops;\n\n const getInstallation = async (args: { orgId: string; id: string }): Promise<SourceControlInstallation | null> => {\n const row = await db().findOne<InstallationDbRow>(INSTALLATIONS, {\n id: args.id,\n integration_id: integrationId,\n org_id: args.orgId,\n });\n return row ? toInstallation(row) : null;\n };\n\n const requireInstallation = async (args: { orgId: string; id: string }): Promise<SourceControlInstallation> => {\n const installation = await getInstallation(args);\n if (!installation)\n throw new Error('Source-control installation not found for this organization and integration.');\n return installation;\n };\n\n const getRepository = async (args: { orgId: string; id: string }): Promise<SourceControlRepository | null> => {\n const row = await db().findOne<RepositoryDbRow>(REPOSITORIES, { id: args.id });\n if (!row || !(await getInstallation({ orgId: args.orgId, id: row.installation_id }))) return null;\n return toRepository(row);\n };\n\n const requireRepository = async (args: { orgId: string; id: string }): Promise<SourceControlRepository> => {\n const repository = await getRepository(args);\n if (!repository) throw new Error('Source-control repository not found for this organization and integration.');\n return repository;\n };\n\n const getConnection = async (args: {\n orgId: string;\n id: string;\n }): Promise<ProjectSourceControlConnection | null> => {\n const row = await db().findOne<ConnectionDbRow>(CONNECTIONS, { id: args.id, integration_id: integrationId });\n if (!row) return null;\n const project = await db().findOne<Record<string, unknown>>(FACTORY_PROJECTS, {\n id: row.factory_project_id,\n org_id: args.orgId,\n });\n if (!project || !(await getInstallation({ orgId: args.orgId, id: row.installation_id }))) return null;\n return toConnection(row);\n };\n\n const requireConnection = async (args: { orgId: string; id: string }): Promise<ProjectSourceControlConnection> => {\n const connection = await getConnection(args);\n if (!connection)\n throw new Error('Project source-control connection not found for this organization and integration.');\n return connection;\n };\n\n const getProjectRepository = async (args: { orgId: string; id: string }): Promise<ProjectRepository | null> => {\n const row = await db().findOne<ProjectRepositoryDbRow>(PROJECT_REPOSITORIES, { id: args.id });\n if (!row || !(await getConnection({ orgId: args.orgId, id: row.connection_id }))) return null;\n return toProjectRepository(row);\n };\n\n const getProjectRepositoryById = async (id: string): Promise<ProjectRepository | null> => {\n const row = await db().findOne<ProjectRepositoryDbRow>(PROJECT_REPOSITORIES, { id });\n if (!row) return null;\n const connection = await db().findOne<ConnectionDbRow>(CONNECTIONS, {\n id: row.connection_id,\n integration_id: integrationId,\n });\n return connection ? toProjectRepository(row) : null;\n };\n\n const requireProjectRepositoryById = async (id: string): Promise<ProjectRepository> => {\n const projectRepository = await getProjectRepositoryById(id);\n if (!projectRepository) throw new Error('Project repository not found for this integration.');\n return projectRepository;\n };\n\n const getSandbox = async (id: string): Promise<ProjectRepositorySandbox | null> => {\n const row = await db().findOne<SandboxDbRow>(SANDBOXES, { id });\n if (!row || !(await getProjectRepositoryById(row.project_repository_id))) return null;\n return toSandbox(row);\n };\n\n const requireSandbox = async (id: string): Promise<ProjectRepositorySandbox> => {\n const sandbox = await getSandbox(id);\n if (!sandbox) throw new Error('Project-repository sandbox not found for this integration.');\n return sandbox;\n };\n\n return {\n integrationId,\n installations: {\n list: async ({ orgId }) =>\n (\n await db().findMany<InstallationDbRow>(INSTALLATIONS, {\n integration_id: integrationId,\n org_id: orgId,\n })\n ).map(toInstallation),\n get: getInstallation,\n findByExternalId: async ({ orgId, externalId }) => {\n const row = await db().findOne<InstallationDbRow>(INSTALLATIONS, {\n integration_id: integrationId,\n org_id: orgId,\n external_id: externalId,\n });\n return row ? toInstallation(row) : null;\n },\n upsert: async input => {\n const row = await db().upsertOne<InstallationDbRow>(\n INSTALLATIONS,\n ['integration_id', 'org_id', 'external_id'],\n {\n integration_id: integrationId,\n org_id: input.orgId,\n connected_by_user_id: input.connectedByUserId,\n external_id: input.externalId,\n account_name: input.accountName ?? null,\n account_type: input.accountType ?? null,\n provider_metadata: input.providerMetadata ?? {},\n created_at: new Date(),\n },\n );\n return toInstallation(row);\n },\n delete: async ({ orgId, id }) => {\n const installation = await getInstallation({ orgId, id });\n if (!installation) return false;\n await db().deleteMany(INSTALLATIONS, { id, integration_id: integrationId, org_id: orgId });\n return true;\n },\n },\n repositories: {\n list: async ({ orgId, installationId }) => {\n await requireInstallation({ orgId, id: installationId });\n return (await db().findMany<RepositoryDbRow>(REPOSITORIES, { installation_id: installationId })).map(\n toRepository,\n );\n },\n get: getRepository,\n findByExternalId: async ({ orgId, installationId, externalId }) => {\n await requireInstallation({ orgId, id: installationId });\n const row = await db().findOne<RepositoryDbRow>(REPOSITORIES, {\n installation_id: installationId,\n external_id: externalId,\n });\n return row ? toRepository(row) : null;\n },\n findBySlug: async ({ orgId, installationId, slug }) => {\n await requireInstallation({ orgId, id: installationId });\n const row = await db().findOne<RepositoryDbRow>(REPOSITORIES, { installation_id: installationId, slug });\n return row ? toRepository(row) : null;\n },\n upsert: async ({ orgId, input }) => {\n await requireInstallation({ orgId, id: input.installationId });\n const now = new Date();\n const row = await db().upsertOne<RepositoryDbRow>(REPOSITORIES, ['installation_id', 'external_id'], {\n installation_id: input.installationId,\n external_id: input.externalId,\n slug: input.slug,\n default_branch: input.defaultBranch,\n provider_metadata: input.providerMetadata ?? {},\n created_at: now,\n updated_at: now,\n });\n return toRepository(row);\n },\n },\n connections: {\n list: async ({ orgId, factoryProjectId }) => {\n const project = await db().findOne<Record<string, unknown>>(FACTORY_PROJECTS, {\n id: factoryProjectId,\n org_id: orgId,\n });\n if (!project) return [];\n return (\n await db().findMany<ConnectionDbRow>(CONNECTIONS, {\n factory_project_id: factoryProjectId,\n integration_id: integrationId,\n })\n ).map(toConnection);\n },\n get: getConnection,\n create: async input => {\n const project = await db().findOne<Record<string, unknown>>(FACTORY_PROJECTS, {\n id: input.factoryProjectId,\n org_id: input.orgId,\n });\n if (!project) throw new Error('Factory project not found for this organization.');\n await requireInstallation({ orgId: input.orgId, id: input.installationId });\n try {\n const row = await db().insertOne<ConnectionDbRow>(CONNECTIONS, {\n factory_project_id: input.factoryProjectId,\n integration_id: integrationId,\n installation_id: input.installationId,\n created_by_user_id: input.createdByUserId,\n created_at: new Date(),\n });\n return toConnection(row);\n } catch (error) {\n if (!(error instanceof UniqueViolationError)) throw error;\n const row = await db().findOne<ConnectionDbRow>(CONNECTIONS, {\n factory_project_id: input.factoryProjectId,\n integration_id: integrationId,\n installation_id: input.installationId,\n });\n if (!row) throw error;\n return toConnection(row);\n }\n },\n delete: async ({ orgId, id }) => {\n const connection = await getConnection({ orgId, id });\n if (!connection) return false;\n const projectRepositories = await db().findMany<ProjectRepositoryDbRow>(PROJECT_REPOSITORIES, {\n connection_id: id,\n });\n for (const projectRepository of projectRepositories) {\n await db().deleteMany(SESSIONS, { project_repository_id: projectRepository.id });\n await db().deleteMany(WORKTREES, { project_repository_id: projectRepository.id });\n await db().deleteMany(SANDBOXES, { project_repository_id: projectRepository.id });\n }\n await db().deleteMany(PROJECT_REPOSITORIES, { connection_id: id });\n await db().deleteMany(CONNECTIONS, { id, integration_id: integrationId });\n return true;\n },\n },\n projectRepositories: {\n list: async ({ orgId, connectionId }) => {\n await requireConnection({ orgId, id: connectionId });\n return (\n await db().findMany<ProjectRepositoryDbRow>(PROJECT_REPOSITORIES, { connection_id: connectionId })\n ).map(toProjectRepository);\n },\n listByExternalRepository: async ({ installationExternalId, repositoryExternalId }) => {\n const targets: ExternalRepositoryProjectTarget[] = [];\n const installations = await db().findMany<InstallationDbRow>(INSTALLATIONS, {\n integration_id: integrationId,\n external_id: installationExternalId,\n });\n for (const installation of installations) {\n const repository = await db().findOne<RepositoryDbRow>(REPOSITORIES, {\n installation_id: installation.id,\n external_id: repositoryExternalId,\n });\n if (!repository) continue;\n const links = await db().findMany<ProjectRepositoryDbRow>(PROJECT_REPOSITORIES, {\n repository_id: repository.id,\n });\n for (const link of links) {\n const connection = await db().findOne<ConnectionDbRow>(CONNECTIONS, {\n id: link.connection_id,\n integration_id: integrationId,\n installation_id: installation.id,\n });\n if (!connection) continue;\n const project = await db().findOne<Record<string, unknown>>(FACTORY_PROJECTS, {\n id: connection.factory_project_id,\n org_id: installation.org_id,\n });\n if (!project) continue;\n targets.push({\n orgId: installation.org_id,\n factoryProjectId: connection.factory_project_id,\n projectRepository: toProjectRepository(link),\n });\n }\n }\n return targets;\n },\n get: getProjectRepository,\n link: async input => {\n const connection = await requireConnection({ orgId: input.orgId, id: input.connectionId });\n const repository = await requireRepository({ orgId: input.orgId, id: input.repositoryId });\n if (repository.installationId !== connection.installationId) {\n throw new Error('Repository does not belong to the connection installation.');\n }\n const now = new Date();\n const row = await db().upsertOne<ProjectRepositoryDbRow>(\n PROJECT_REPOSITORIES,\n ['connection_id', 'repository_id'],\n {\n connection_id: input.connectionId,\n repository_id: input.repositoryId,\n created_by_user_id: input.createdByUserId,\n branch: input.branch ?? null,\n sandbox_provider: input.sandboxProvider,\n sandbox_workdir: input.sandboxWorkdir,\n setup_command: input.setupCommand ?? null,\n created_at: now,\n updated_at: now,\n },\n );\n return toProjectRepository(row);\n },\n update: async ({ orgId, id, input }) => {\n const existing = await getProjectRepository({ orgId, id });\n if (!existing) return null;\n const patch: Record<string, unknown> = { updated_at: new Date() };\n if (input.branch !== undefined) patch.branch = input.branch;\n if (input.sandboxProvider !== undefined) patch.sandbox_provider = input.sandboxProvider;\n if (input.sandboxWorkdir !== undefined) patch.sandbox_workdir = input.sandboxWorkdir;\n if (input.setupCommand !== undefined) patch.setup_command = input.setupCommand;\n await db().updateMany(PROJECT_REPOSITORIES, { id }, patch);\n return getProjectRepository({ orgId, id });\n },\n unlink: async ({ orgId, id }) => {\n const existing = await getProjectRepository({ orgId, id });\n if (!existing) return false;\n await db().deleteMany(SESSIONS, { project_repository_id: id });\n await db().deleteMany(WORKTREES, { project_repository_id: id });\n await db().deleteMany(SANDBOXES, { project_repository_id: id });\n await db().deleteMany(PROJECT_REPOSITORIES, { id });\n return true;\n },\n },\n sandboxes: {\n getOrCreate: async ({ projectRepository, userId }) => {\n await requireProjectRepositoryById(projectRepository.id);\n const where = { project_repository_id: projectRepository.id, user_id: userId };\n const existing = await db().findOne<SandboxDbRow>(SANDBOXES, where);\n if (existing) return toSandbox(existing);\n try {\n const row = await db().insertOne<SandboxDbRow>(SANDBOXES, {\n ...where,\n sandbox_id: null,\n sandbox_workdir: projectRepository.sandboxWorkdir,\n materialized_at: null,\n created_at: new Date(),\n });\n return toSandbox(row);\n } catch (error) {\n if (!(error instanceof UniqueViolationError)) throw error;\n const row = await db().findOne<SandboxDbRow>(SANDBOXES, where);\n if (!row) throw error;\n return toSandbox(row);\n }\n },\n getById: ({ id }) => getSandbox(id),\n setSandboxId: async ({ id, sandboxId }) => {\n await requireSandbox(id);\n await db().updateMany(SANDBOXES, { id }, { sandbox_id: sandboxId });\n },\n clearBinding: async ({ id }) => {\n await requireSandbox(id);\n await db().updateMany(SANDBOXES, { id }, { sandbox_id: null, materialized_at: null });\n },\n markMaterialized: async ({ id }) => {\n await requireSandbox(id);\n await db().updateMany(SANDBOXES, { id }, { materialized_at: new Date() });\n },\n },\n worktrees: {\n upsert: async input => {\n await requireProjectRepositoryById(input.projectRepositoryId);\n await db().upsertOne<WorktreeDbRow>(WORKTREES, ['project_repository_id', 'user_id', 'branch'], {\n project_repository_id: input.projectRepositoryId,\n user_id: input.userId,\n branch: input.branch,\n base_branch: input.baseBranch,\n worktree_path: input.worktreePath,\n created_at: new Date(),\n });\n },\n list: async ({ projectRepositoryId, userId }) => {\n if (!(await getProjectRepositoryById(projectRepositoryId))) return [];\n const rows = await db().findMany<WorktreeDbRow>(WORKTREES, {\n project_repository_id: projectRepositoryId,\n user_id: userId,\n });\n return rows.map(toWorktree);\n },\n get: async ({ projectRepositoryId, userId, branch }) => {\n if (!(await getProjectRepositoryById(projectRepositoryId))) return null;\n const row = await db().findOne<WorktreeDbRow>(WORKTREES, {\n project_repository_id: projectRepositoryId,\n user_id: userId,\n branch,\n });\n return row ? toWorktree(row) : null;\n },\n findByPath: async ({ projectRepositoryId, userId, worktreePath }) => {\n if (!(await getProjectRepositoryById(projectRepositoryId))) return null;\n const row = await db().findOne<WorktreeDbRow>(WORKTREES, {\n project_repository_id: projectRepositoryId,\n user_id: userId,\n worktree_path: worktreePath,\n });\n return row ? toWorktree(row) : null;\n },\n delete: async ({ projectRepositoryId, userId, branch }) => {\n await requireProjectRepositoryById(projectRepositoryId);\n await db().deleteMany(WORKTREES, {\n project_repository_id: projectRepositoryId,\n user_id: userId,\n branch,\n });\n },\n },\n sessions: {\n list: async ({ projectRepositoryId, userId }) => {\n if (!(await getProjectRepositoryById(projectRepositoryId))) return [];\n return (\n await db().findMany<SessionDbRow>(SESSIONS, {\n project_repository_id: projectRepositoryId,\n user_id: userId,\n })\n ).map(toSession);\n },\n getBySessionId: async sessionId => {\n const row = await db().findOne<SessionDbRow>(SESSIONS, { session_id: sessionId });\n return row && (await getProjectRepositoryById(row.project_repository_id)) ? toSession(row) : null;\n },\n getForBranch: async ({ projectRepositoryId, userId, branch }) => {\n if (!(await getProjectRepositoryById(projectRepositoryId))) return null;\n const row = await db().findOne<SessionDbRow>(SESSIONS, {\n project_repository_id: projectRepositoryId,\n user_id: userId,\n branch,\n });\n return row ? toSession(row) : null;\n },\n create: async input => {\n await requireProjectRepositoryById(input.projectRepositoryId);\n const existing = await db().findOne<SessionDbRow>(SESSIONS, {\n project_repository_id: input.projectRepositoryId,\n user_id: input.userId,\n branch: input.branch,\n });\n if (existing) return toSession(existing);\n const now = new Date();\n try {\n const row = await db().insertOne<SessionDbRow>(SESSIONS, {\n session_id: input.sessionId,\n project_repository_id: input.projectRepositoryId,\n org_id: input.orgId,\n user_id: input.userId,\n branch: input.branch,\n base_branch: input.baseBranch,\n sandbox_id: null,\n sandbox_workdir: null,\n materialized_at: null,\n created_at: now,\n updated_at: now,\n });\n return toSession(row);\n } catch (error) {\n if (!(error instanceof UniqueViolationError)) throw error;\n const row = await db().findOne<SessionDbRow>(SESSIONS, {\n project_repository_id: input.projectRepositoryId,\n user_id: input.userId,\n branch: input.branch,\n });\n if (!row) throw error;\n return toSession(row);\n }\n },\n setSandbox: async ({ id, sandboxId, sandboxWorkdir }) => {\n await db().updateMany(\n SESSIONS,\n { id },\n { sandbox_id: sandboxId, sandbox_workdir: sandboxWorkdir, updated_at: new Date() },\n );\n },\n markMaterialized: async ({ id }) => {\n await db().updateMany(SESSIONS, { id }, { materialized_at: new Date(), updated_at: new Date() });\n },\n delete: async id => {\n await db().deleteMany(SESSIONS, { id });\n },\n },\n };\n }\n}\n"],"mappings":";AAAA,SAAS,sBAAsB,4BAA4B;AAG3D,IAAM,mBAAmB;AACzB,IAAM,gBAAgB;AACtB,IAAM,eAAe;AACrB,IAAM,cAAc;AACpB,IAAM,uBAAuB;AAC7B,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,WAAW;AAEV,IAAM,yBAA6C;AAAA,EACxD;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,MACP,IAAI,EAAE,MAAM,UAAU;AAAA,MACtB,gBAAgB,EAAE,MAAM,OAAO;AAAA,MAC/B,QAAQ,EAAE,MAAM,OAAO;AAAA,MACvB,sBAAsB,EAAE,MAAM,OAAO;AAAA,MACrC,aAAa,EAAE,MAAM,OAAO;AAAA,MAC5B,cAAc,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,MAC7C,cAAc,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,MAC7C,mBAAmB,EAAE,MAAM,OAAO;AAAA,MAClC,YAAY,EAAE,MAAM,YAAY;AAAA,IAClC;AAAA,IACA,eAAe;AAAA,MACb;AAAA,QACE,MAAM;AAAA,QACN,SAAS,CAAC,kBAAkB,UAAU,aAAa;AAAA,M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;AAAA,QACF;AAAA,QACA,kBAAkB,OAAO,EAAE,GAAG,MAAM;AAClC,gBAAM,GAAG,EAAE,WAAW,UAAU,EAAE,GAAG,GAAG,EAAE,iBAAiB,oBAAI,KAAK,GAAG,YAAY,oBAAI,KAAK,EAAE,CAAC;AAAA,QACjG;AAAA,QACA,QAAQ,OAAM,OAAM;AAClB,gBAAM,GAAG,EAAE,WAAW,UAAU,EAAE,GAAG,CAAC;AAAA,QACxC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { CreateProjectSourceControlConnectionInput, CreateSourceControlSessionInput, ExternalRepositoryProjectTarget, LinkProjectRepositoryInput, ProjectRepository, ProjectRepositorySandbox, ProjectSourceControlConnection, SourceControlInstallation, SourceControlRepository, SourceControlSession, SourceControlStorageHandle, SourceControlWorktree, UpdateProjectRepositoryInput, UpsertSourceControlInstallationInput, UpsertSourceControlRepositoryInput, UpsertSourceControlWorktreeInput } from './base.js';
|
|
2
|
+
/** In-memory provider-scoped source-control handle for route tests. */
|
|
3
|
+
export declare class SourceControlStorageInMemory implements SourceControlStorageHandle {
|
|
4
|
+
readonly integrationId: string;
|
|
5
|
+
installationsRows: SourceControlInstallation[];
|
|
6
|
+
repositoriesRows: SourceControlRepository[];
|
|
7
|
+
connectionsRows: ProjectSourceControlConnection[];
|
|
8
|
+
projectRepositoriesRows: ProjectRepository[];
|
|
9
|
+
sandboxesRows: ProjectRepositorySandbox[];
|
|
10
|
+
worktreesRows: SourceControlWorktree[];
|
|
11
|
+
sessionsRows: SourceControlSession[];
|
|
12
|
+
constructor(integrationId?: string);
|
|
13
|
+
readonly installations: {
|
|
14
|
+
list: ({ orgId }: {
|
|
15
|
+
orgId: string;
|
|
16
|
+
}) => Promise<SourceControlInstallation[]>;
|
|
17
|
+
get: ({ orgId, id }: {
|
|
18
|
+
orgId: string;
|
|
19
|
+
id: string;
|
|
20
|
+
}) => Promise<SourceControlInstallation | null>;
|
|
21
|
+
findByExternalId: ({ orgId, externalId, }: {
|
|
22
|
+
orgId: string;
|
|
23
|
+
externalId: string;
|
|
24
|
+
}) => Promise<SourceControlInstallation | null>;
|
|
25
|
+
upsert: (input: UpsertSourceControlInstallationInput) => Promise<SourceControlInstallation>;
|
|
26
|
+
delete: ({ orgId, id }: {
|
|
27
|
+
orgId: string;
|
|
28
|
+
id: string;
|
|
29
|
+
}) => Promise<boolean>;
|
|
30
|
+
};
|
|
31
|
+
readonly repositories: {
|
|
32
|
+
list: ({ orgId, installationId }: {
|
|
33
|
+
orgId: string;
|
|
34
|
+
installationId: string;
|
|
35
|
+
}) => Promise<SourceControlRepository[]>;
|
|
36
|
+
get: ({ orgId, id }: {
|
|
37
|
+
orgId: string;
|
|
38
|
+
id: string;
|
|
39
|
+
}) => Promise<SourceControlRepository | null>;
|
|
40
|
+
findByExternalId: ({ orgId, installationId, externalId, }: {
|
|
41
|
+
orgId: string;
|
|
42
|
+
installationId: string;
|
|
43
|
+
externalId: string;
|
|
44
|
+
}) => Promise<SourceControlRepository | null>;
|
|
45
|
+
findBySlug: ({ orgId, installationId, slug }: {
|
|
46
|
+
orgId: string;
|
|
47
|
+
installationId: string;
|
|
48
|
+
slug: string;
|
|
49
|
+
}) => Promise<SourceControlRepository | null>;
|
|
50
|
+
upsert: ({ orgId, input, }: {
|
|
51
|
+
orgId: string;
|
|
52
|
+
input: UpsertSourceControlRepositoryInput;
|
|
53
|
+
}) => Promise<SourceControlRepository>;
|
|
54
|
+
};
|
|
55
|
+
readonly connections: {
|
|
56
|
+
list: ({ factoryProjectId }: {
|
|
57
|
+
orgId: string;
|
|
58
|
+
factoryProjectId: string;
|
|
59
|
+
}) => Promise<ProjectSourceControlConnection[]>;
|
|
60
|
+
get: ({ orgId, id }: {
|
|
61
|
+
orgId: string;
|
|
62
|
+
id: string;
|
|
63
|
+
}) => Promise<ProjectSourceControlConnection | null>;
|
|
64
|
+
create: (input: CreateProjectSourceControlConnectionInput) => Promise<ProjectSourceControlConnection>;
|
|
65
|
+
delete: ({ orgId, id }: {
|
|
66
|
+
orgId: string;
|
|
67
|
+
id: string;
|
|
68
|
+
}) => Promise<boolean>;
|
|
69
|
+
};
|
|
70
|
+
readonly projectRepositories: {
|
|
71
|
+
list: ({ orgId, connectionId }: {
|
|
72
|
+
orgId: string;
|
|
73
|
+
connectionId: string;
|
|
74
|
+
}) => Promise<ProjectRepository[]>;
|
|
75
|
+
listByExternalRepository: ({ installationExternalId, repositoryExternalId, }: {
|
|
76
|
+
installationExternalId: string;
|
|
77
|
+
repositoryExternalId: string;
|
|
78
|
+
}) => Promise<ExternalRepositoryProjectTarget[]>;
|
|
79
|
+
get: ({ orgId, id }: {
|
|
80
|
+
orgId: string;
|
|
81
|
+
id: string;
|
|
82
|
+
}) => Promise<ProjectRepository | null>;
|
|
83
|
+
link: (input: LinkProjectRepositoryInput) => Promise<ProjectRepository>;
|
|
84
|
+
update: ({ orgId, id, input, }: {
|
|
85
|
+
orgId: string;
|
|
86
|
+
id: string;
|
|
87
|
+
input: UpdateProjectRepositoryInput;
|
|
88
|
+
}) => Promise<ProjectRepository | null>;
|
|
89
|
+
unlink: ({ orgId, id }: {
|
|
90
|
+
orgId: string;
|
|
91
|
+
id: string;
|
|
92
|
+
}) => Promise<boolean>;
|
|
93
|
+
};
|
|
94
|
+
readonly sandboxes: {
|
|
95
|
+
getOrCreate: ({ projectRepository, userId, }: {
|
|
96
|
+
projectRepository: ProjectRepository;
|
|
97
|
+
userId: string;
|
|
98
|
+
}) => Promise<ProjectRepositorySandbox>;
|
|
99
|
+
getById: ({ id }: {
|
|
100
|
+
id: string;
|
|
101
|
+
}) => Promise<ProjectRepositorySandbox | null>;
|
|
102
|
+
setSandboxId: ({ id, sandboxId }: {
|
|
103
|
+
id: string;
|
|
104
|
+
sandboxId: string;
|
|
105
|
+
}) => Promise<void>;
|
|
106
|
+
clearBinding: ({ id }: {
|
|
107
|
+
id: string;
|
|
108
|
+
}) => Promise<void>;
|
|
109
|
+
markMaterialized: ({ id }: {
|
|
110
|
+
id: string;
|
|
111
|
+
}) => Promise<void>;
|
|
112
|
+
};
|
|
113
|
+
readonly worktrees: {
|
|
114
|
+
upsert: (input: UpsertSourceControlWorktreeInput) => Promise<void>;
|
|
115
|
+
list: ({ projectRepositoryId, userId, }: {
|
|
116
|
+
projectRepositoryId: string;
|
|
117
|
+
userId: string;
|
|
118
|
+
}) => Promise<SourceControlWorktree[]>;
|
|
119
|
+
get: ({ projectRepositoryId, userId, branch, }: {
|
|
120
|
+
projectRepositoryId: string;
|
|
121
|
+
userId: string;
|
|
122
|
+
branch: string;
|
|
123
|
+
}) => Promise<SourceControlWorktree | null>;
|
|
124
|
+
findByPath: ({ projectRepositoryId, userId, worktreePath, }: {
|
|
125
|
+
projectRepositoryId: string;
|
|
126
|
+
userId: string;
|
|
127
|
+
worktreePath: string;
|
|
128
|
+
}) => Promise<SourceControlWorktree | null>;
|
|
129
|
+
delete: ({ projectRepositoryId, userId, branch, }: {
|
|
130
|
+
projectRepositoryId: string;
|
|
131
|
+
userId: string;
|
|
132
|
+
branch: string;
|
|
133
|
+
}) => Promise<void>;
|
|
134
|
+
};
|
|
135
|
+
readonly sessions: {
|
|
136
|
+
list: ({ projectRepositoryId, userId }: {
|
|
137
|
+
projectRepositoryId: string;
|
|
138
|
+
userId: string;
|
|
139
|
+
}) => Promise<SourceControlSession[]>;
|
|
140
|
+
getBySessionId: (sessionId: string) => Promise<SourceControlSession | null>;
|
|
141
|
+
getForBranch: ({ projectRepositoryId, userId, branch, }: {
|
|
142
|
+
projectRepositoryId: string;
|
|
143
|
+
userId: string;
|
|
144
|
+
branch: string;
|
|
145
|
+
}) => Promise<SourceControlSession | null>;
|
|
146
|
+
create: (input: CreateSourceControlSessionInput) => Promise<SourceControlSession>;
|
|
147
|
+
setSandbox: ({ id, sandboxId, sandboxWorkdir, }: {
|
|
148
|
+
id: string;
|
|
149
|
+
sandboxId: string | null;
|
|
150
|
+
sandboxWorkdir: string;
|
|
151
|
+
}) => Promise<void>;
|
|
152
|
+
markMaterialized: ({ id }: {
|
|
153
|
+
id: string;
|
|
154
|
+
}) => Promise<void>;
|
|
155
|
+
delete: (id: string) => Promise<void>;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=inmemory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inmemory.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/source-control/inmemory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yCAAyC,EACzC,+BAA+B,EAC/B,+BAA+B,EAC/B,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,8BAA8B,EAC9B,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EAClC,gCAAgC,EACjC,MAAM,WAAW,CAAC;AAEnB,uEAAuE;AACvE,qBAAa,4BAA6B,YAAW,0BAA0B;IAC7E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,iBAAiB,EAAE,yBAAyB,EAAE,CAAM;IACpD,gBAAgB,EAAE,uBAAuB,EAAE,CAAM;IACjD,eAAe,EAAE,8BAA8B,EAAE,CAAM;IACvD,uBAAuB,EAAE,iBAAiB,EAAE,CAAM;IAClD,aAAa,EAAE,wBAAwB,EAAE,CAAM;IAC/C,aAAa,EAAE,qBAAqB,EAAE,CAAM;IAC5C,YAAY,EAAE,oBAAoB,EAAE,CAAM;gBAE9B,aAAa,SAAW;IAIpC,QAAQ,CAAC,aAAa;0BACI;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,KAAG,OAAO,CAAC,yBAAyB,EAAE,CAAC;6BAErD;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,KAAG,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC;mDAK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,CAAC;SAChB,KAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;wDAMjC;YACD,mBAAmB,EAAE,MAAM,CAAC;YAC5B,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;SAChB,KAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;qEAQtC;YACD,mBAAmB,EAAE,MAAM,CAAC;YAC5B,MAAM,EAAE,MAAM,CAAC;YACf,YAAY,EAAE,MAAM,CAAC;SACtB,KAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;2DAStC;YACD,mBAAmB,EAAE,MAAM,CAAC;YAC5B,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;SAChB,KAAG,OAAO,CAAC,IAAI,CAAC;MASjB;IAEF,QAAQ,CAAC,QAAQ;gDAC+B;YAAE,mBAAmB,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE;oCAE3D,MAAM,KAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;iEAM5E;YACD,mBAAmB,EAAE,MAAM,CAAC;YAC5B,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;SAChB,KAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;wBAIlB,+BAA+B,KAAG,OAAO,CAAC,oBAAoB,CAAC;yDAoBlF;YACD,EAAE,EAAE,MAAM,CAAC;YACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;YACzB,cAAc,EAAE,MAAM,CAAC;SACxB;mCAIgC;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE;qBAI5B,MAAM;MAGzB;CACH"}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// src/storage/domains/source-control/inmemory.ts
|
|
2
|
+
import { randomUUID } from "crypto";
|
|
3
|
+
var SourceControlStorageInMemory = class {
|
|
4
|
+
integrationId;
|
|
5
|
+
installationsRows = [];
|
|
6
|
+
repositoriesRows = [];
|
|
7
|
+
connectionsRows = [];
|
|
8
|
+
projectRepositoriesRows = [];
|
|
9
|
+
sandboxesRows = [];
|
|
10
|
+
worktreesRows = [];
|
|
11
|
+
sessionsRows = [];
|
|
12
|
+
constructor(integrationId = "github") {
|
|
13
|
+
this.integrationId = integrationId;
|
|
14
|
+
}
|
|
15
|
+
installations = {
|
|
16
|
+
list: async ({ orgId }) => this.installationsRows.filter((row) => row.orgId === orgId),
|
|
17
|
+
get: async ({ orgId, id }) => this.installationsRows.find((row) => row.orgId === orgId && row.id === id) ?? null,
|
|
18
|
+
findByExternalId: async ({
|
|
19
|
+
orgId,
|
|
20
|
+
externalId
|
|
21
|
+
}) => this.installationsRows.find((row) => row.orgId === orgId && row.externalId === externalId) ?? null,
|
|
22
|
+
upsert: async (input) => {
|
|
23
|
+
const existing = this.installationsRows.find(
|
|
24
|
+
(row) => row.orgId === input.orgId && row.externalId === input.externalId
|
|
25
|
+
);
|
|
26
|
+
if (existing) {
|
|
27
|
+
Object.assign(existing, {
|
|
28
|
+
connectedByUserId: input.connectedByUserId,
|
|
29
|
+
accountName: input.accountName ?? null,
|
|
30
|
+
accountType: input.accountType ?? null,
|
|
31
|
+
providerMetadata: input.providerMetadata ?? {}
|
|
32
|
+
});
|
|
33
|
+
return existing;
|
|
34
|
+
}
|
|
35
|
+
const created = {
|
|
36
|
+
id: randomUUID(),
|
|
37
|
+
integrationId: this.integrationId,
|
|
38
|
+
orgId: input.orgId,
|
|
39
|
+
connectedByUserId: input.connectedByUserId,
|
|
40
|
+
externalId: input.externalId,
|
|
41
|
+
accountName: input.accountName ?? null,
|
|
42
|
+
accountType: input.accountType ?? null,
|
|
43
|
+
providerMetadata: input.providerMetadata ?? {},
|
|
44
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
45
|
+
};
|
|
46
|
+
this.installationsRows.push(created);
|
|
47
|
+
return created;
|
|
48
|
+
},
|
|
49
|
+
delete: async ({ orgId, id }) => {
|
|
50
|
+
const index = this.installationsRows.findIndex((row) => row.orgId === orgId && row.id === id);
|
|
51
|
+
if (index < 0) return false;
|
|
52
|
+
this.installationsRows.splice(index, 1);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
repositories = {
|
|
57
|
+
list: async ({ orgId, installationId }) => {
|
|
58
|
+
const installation = await this.installations.get({ orgId, id: installationId });
|
|
59
|
+
return installation ? this.repositoriesRows.filter((row) => row.installationId === installationId) : [];
|
|
60
|
+
},
|
|
61
|
+
get: async ({ orgId, id }) => {
|
|
62
|
+
const row = this.repositoriesRows.find((candidate) => candidate.id === id);
|
|
63
|
+
if (!row) return null;
|
|
64
|
+
return await this.installations.get({ orgId, id: row.installationId }) ? row : null;
|
|
65
|
+
},
|
|
66
|
+
findByExternalId: async ({
|
|
67
|
+
orgId,
|
|
68
|
+
installationId,
|
|
69
|
+
externalId
|
|
70
|
+
}) => {
|
|
71
|
+
const rows = await this.repositories.list({ orgId, installationId });
|
|
72
|
+
return rows.find((row) => row.externalId === externalId) ?? null;
|
|
73
|
+
},
|
|
74
|
+
findBySlug: async ({ orgId, installationId, slug }) => {
|
|
75
|
+
const rows = await this.repositories.list({ orgId, installationId });
|
|
76
|
+
return rows.find((row) => row.slug === slug) ?? null;
|
|
77
|
+
},
|
|
78
|
+
upsert: async ({
|
|
79
|
+
orgId,
|
|
80
|
+
input
|
|
81
|
+
}) => {
|
|
82
|
+
if (!await this.installations.get({ orgId, id: input.installationId })) {
|
|
83
|
+
throw new Error("Source-control installation not found");
|
|
84
|
+
}
|
|
85
|
+
const existing = this.repositoriesRows.find(
|
|
86
|
+
(row) => row.installationId === input.installationId && row.externalId === input.externalId
|
|
87
|
+
);
|
|
88
|
+
const now = /* @__PURE__ */ new Date();
|
|
89
|
+
if (existing) {
|
|
90
|
+
Object.assign(existing, {
|
|
91
|
+
slug: input.slug,
|
|
92
|
+
defaultBranch: input.defaultBranch,
|
|
93
|
+
providerMetadata: input.providerMetadata ?? {},
|
|
94
|
+
updatedAt: now
|
|
95
|
+
});
|
|
96
|
+
return existing;
|
|
97
|
+
}
|
|
98
|
+
const created = {
|
|
99
|
+
id: randomUUID(),
|
|
100
|
+
installationId: input.installationId,
|
|
101
|
+
externalId: input.externalId,
|
|
102
|
+
slug: input.slug,
|
|
103
|
+
defaultBranch: input.defaultBranch,
|
|
104
|
+
providerMetadata: input.providerMetadata ?? {},
|
|
105
|
+
createdAt: now,
|
|
106
|
+
updatedAt: now
|
|
107
|
+
};
|
|
108
|
+
this.repositoriesRows.push(created);
|
|
109
|
+
return created;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
connections = {
|
|
113
|
+
list: async ({ factoryProjectId }) => this.connectionsRows.filter((row) => row.factoryProjectId === factoryProjectId),
|
|
114
|
+
get: async ({ orgId, id }) => {
|
|
115
|
+
const row = this.connectionsRows.find((candidate) => candidate.id === id);
|
|
116
|
+
if (!row) return null;
|
|
117
|
+
return await this.installations.get({ orgId, id: row.installationId }) ? row : null;
|
|
118
|
+
},
|
|
119
|
+
create: async (input) => {
|
|
120
|
+
if (!await this.installations.get({ orgId: input.orgId, id: input.installationId })) {
|
|
121
|
+
throw new Error("Source-control installation not found");
|
|
122
|
+
}
|
|
123
|
+
const existing = this.connectionsRows.find(
|
|
124
|
+
(row) => row.factoryProjectId === input.factoryProjectId && row.integrationId === this.integrationId && row.installationId === input.installationId
|
|
125
|
+
);
|
|
126
|
+
if (existing) return existing;
|
|
127
|
+
const created = {
|
|
128
|
+
id: randomUUID(),
|
|
129
|
+
factoryProjectId: input.factoryProjectId,
|
|
130
|
+
integrationId: this.integrationId,
|
|
131
|
+
installationId: input.installationId,
|
|
132
|
+
createdByUserId: input.createdByUserId,
|
|
133
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
134
|
+
};
|
|
135
|
+
this.connectionsRows.push(created);
|
|
136
|
+
return created;
|
|
137
|
+
},
|
|
138
|
+
delete: async ({ orgId, id }) => {
|
|
139
|
+
if (!await this.connections.get({ orgId, id })) return false;
|
|
140
|
+
this.connectionsRows.splice(0, this.connectionsRows.length, ...this.connectionsRows.filter((row) => row.id !== id));
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
projectRepositories = {
|
|
145
|
+
list: async ({ orgId, connectionId }) => await this.connections.get({ orgId, id: connectionId }) ? this.projectRepositoriesRows.filter((row) => row.connectionId === connectionId) : [],
|
|
146
|
+
listByExternalRepository: async ({
|
|
147
|
+
installationExternalId,
|
|
148
|
+
repositoryExternalId
|
|
149
|
+
}) => {
|
|
150
|
+
const targets = [];
|
|
151
|
+
for (const installation of this.installationsRows.filter((row) => row.externalId === installationExternalId)) {
|
|
152
|
+
const repository = this.repositoriesRows.find(
|
|
153
|
+
(row) => row.installationId === installation.id && row.externalId === repositoryExternalId
|
|
154
|
+
);
|
|
155
|
+
if (!repository) continue;
|
|
156
|
+
for (const projectRepository of this.projectRepositoriesRows.filter(
|
|
157
|
+
(row) => row.repositoryId === repository.id
|
|
158
|
+
)) {
|
|
159
|
+
const connection = this.connectionsRows.find(
|
|
160
|
+
(row) => row.id === projectRepository.connectionId && row.installationId === installation.id && row.integrationId === this.integrationId
|
|
161
|
+
);
|
|
162
|
+
if (!connection) continue;
|
|
163
|
+
targets.push({
|
|
164
|
+
orgId: installation.orgId,
|
|
165
|
+
factoryProjectId: connection.factoryProjectId,
|
|
166
|
+
projectRepository
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return targets;
|
|
171
|
+
},
|
|
172
|
+
get: async ({ orgId, id }) => {
|
|
173
|
+
const row = this.projectRepositoriesRows.find((candidate) => candidate.id === id);
|
|
174
|
+
if (!row) return null;
|
|
175
|
+
return await this.connections.get({ orgId, id: row.connectionId }) ? row : null;
|
|
176
|
+
},
|
|
177
|
+
link: async (input) => {
|
|
178
|
+
const connection = await this.connections.get({ orgId: input.orgId, id: input.connectionId });
|
|
179
|
+
const repository = await this.repositories.get({ orgId: input.orgId, id: input.repositoryId });
|
|
180
|
+
if (!connection || !repository || repository.installationId !== connection.installationId) {
|
|
181
|
+
throw new Error("Source-control connection or repository not found");
|
|
182
|
+
}
|
|
183
|
+
const existing = this.projectRepositoriesRows.find(
|
|
184
|
+
(row) => row.connectionId === input.connectionId && row.repositoryId === input.repositoryId
|
|
185
|
+
);
|
|
186
|
+
if (existing) return existing;
|
|
187
|
+
const now = /* @__PURE__ */ new Date();
|
|
188
|
+
const created = {
|
|
189
|
+
id: randomUUID(),
|
|
190
|
+
connectionId: input.connectionId,
|
|
191
|
+
repositoryId: input.repositoryId,
|
|
192
|
+
createdByUserId: input.createdByUserId,
|
|
193
|
+
branch: input.branch ?? null,
|
|
194
|
+
sandboxProvider: input.sandboxProvider,
|
|
195
|
+
sandboxWorkdir: input.sandboxWorkdir,
|
|
196
|
+
setupCommand: input.setupCommand ?? null,
|
|
197
|
+
createdAt: now,
|
|
198
|
+
updatedAt: now
|
|
199
|
+
};
|
|
200
|
+
this.projectRepositoriesRows.push(created);
|
|
201
|
+
return created;
|
|
202
|
+
},
|
|
203
|
+
update: async ({
|
|
204
|
+
orgId,
|
|
205
|
+
id,
|
|
206
|
+
input
|
|
207
|
+
}) => {
|
|
208
|
+
const row = await this.projectRepositories.get({ orgId, id });
|
|
209
|
+
if (!row) return null;
|
|
210
|
+
Object.assign(row, input, { updatedAt: /* @__PURE__ */ new Date() });
|
|
211
|
+
return row;
|
|
212
|
+
},
|
|
213
|
+
unlink: async ({ orgId, id }) => {
|
|
214
|
+
if (!await this.projectRepositories.get({ orgId, id })) return false;
|
|
215
|
+
this.projectRepositoriesRows.splice(
|
|
216
|
+
0,
|
|
217
|
+
this.projectRepositoriesRows.length,
|
|
218
|
+
...this.projectRepositoriesRows.filter((row) => row.id !== id)
|
|
219
|
+
);
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
sandboxes = {
|
|
224
|
+
getOrCreate: async ({
|
|
225
|
+
projectRepository,
|
|
226
|
+
userId
|
|
227
|
+
}) => {
|
|
228
|
+
const existing = this.sandboxesRows.find(
|
|
229
|
+
(row) => row.projectRepositoryId === projectRepository.id && row.userId === userId
|
|
230
|
+
);
|
|
231
|
+
if (existing) return existing;
|
|
232
|
+
const created = {
|
|
233
|
+
id: randomUUID(),
|
|
234
|
+
projectRepositoryId: projectRepository.id,
|
|
235
|
+
userId,
|
|
236
|
+
sandboxId: null,
|
|
237
|
+
sandboxWorkdir: projectRepository.sandboxWorkdir,
|
|
238
|
+
materializedAt: null,
|
|
239
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
240
|
+
};
|
|
241
|
+
this.sandboxesRows.push(created);
|
|
242
|
+
return created;
|
|
243
|
+
},
|
|
244
|
+
getById: async ({ id }) => this.sandboxesRows.find((row) => row.id === id) ?? null,
|
|
245
|
+
setSandboxId: async ({ id, sandboxId }) => {
|
|
246
|
+
const row = this.sandboxesRows.find((candidate) => candidate.id === id);
|
|
247
|
+
if (row) row.sandboxId = sandboxId;
|
|
248
|
+
},
|
|
249
|
+
clearBinding: async ({ id }) => {
|
|
250
|
+
const row = this.sandboxesRows.find((candidate) => candidate.id === id);
|
|
251
|
+
if (row) Object.assign(row, { sandboxId: null, materializedAt: null });
|
|
252
|
+
},
|
|
253
|
+
markMaterialized: async ({ id }) => {
|
|
254
|
+
const row = this.sandboxesRows.find((candidate) => candidate.id === id);
|
|
255
|
+
if (row) row.materializedAt = /* @__PURE__ */ new Date();
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
worktrees = {
|
|
259
|
+
upsert: async (input) => {
|
|
260
|
+
const existing = this.worktreesRows.find(
|
|
261
|
+
(row) => row.projectRepositoryId === input.projectRepositoryId && row.userId === input.userId && row.branch === input.branch
|
|
262
|
+
);
|
|
263
|
+
if (existing) {
|
|
264
|
+
existing.baseBranch = input.baseBranch;
|
|
265
|
+
existing.worktreePath = input.worktreePath;
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
this.worktreesRows.push({ id: randomUUID(), createdAt: /* @__PURE__ */ new Date(), ...input });
|
|
269
|
+
},
|
|
270
|
+
list: async ({
|
|
271
|
+
projectRepositoryId,
|
|
272
|
+
userId
|
|
273
|
+
}) => this.worktreesRows.filter((row) => row.projectRepositoryId === projectRepositoryId && row.userId === userId),
|
|
274
|
+
get: async ({
|
|
275
|
+
projectRepositoryId,
|
|
276
|
+
userId,
|
|
277
|
+
branch
|
|
278
|
+
}) => this.worktreesRows.find(
|
|
279
|
+
(row) => row.projectRepositoryId === projectRepositoryId && row.userId === userId && row.branch === branch
|
|
280
|
+
) ?? null,
|
|
281
|
+
findByPath: async ({
|
|
282
|
+
projectRepositoryId,
|
|
283
|
+
userId,
|
|
284
|
+
worktreePath
|
|
285
|
+
}) => this.worktreesRows.find(
|
|
286
|
+
(row) => row.projectRepositoryId === projectRepositoryId && row.userId === userId && row.worktreePath === worktreePath
|
|
287
|
+
) ?? null,
|
|
288
|
+
delete: async ({
|
|
289
|
+
projectRepositoryId,
|
|
290
|
+
userId,
|
|
291
|
+
branch
|
|
292
|
+
}) => {
|
|
293
|
+
this.worktreesRows.splice(
|
|
294
|
+
0,
|
|
295
|
+
this.worktreesRows.length,
|
|
296
|
+
...this.worktreesRows.filter(
|
|
297
|
+
(row) => !(row.projectRepositoryId === projectRepositoryId && row.userId === userId && row.branch === branch)
|
|
298
|
+
)
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
sessions = {
|
|
303
|
+
list: async ({ projectRepositoryId, userId }) => this.sessionsRows.filter((row) => row.projectRepositoryId === projectRepositoryId && row.userId === userId),
|
|
304
|
+
getBySessionId: async (sessionId) => this.sessionsRows.find((row) => row.sessionId === sessionId) ?? null,
|
|
305
|
+
getForBranch: async ({
|
|
306
|
+
projectRepositoryId,
|
|
307
|
+
userId,
|
|
308
|
+
branch
|
|
309
|
+
}) => this.sessionsRows.find(
|
|
310
|
+
(row) => row.projectRepositoryId === projectRepositoryId && row.userId === userId && row.branch === branch
|
|
311
|
+
) ?? null,
|
|
312
|
+
create: async (input) => {
|
|
313
|
+
const existing = await this.sessions.getForBranch(input);
|
|
314
|
+
if (existing) return existing;
|
|
315
|
+
const now = /* @__PURE__ */ new Date();
|
|
316
|
+
const session = {
|
|
317
|
+
id: randomUUID(),
|
|
318
|
+
...input,
|
|
319
|
+
sandboxId: null,
|
|
320
|
+
sandboxWorkdir: null,
|
|
321
|
+
materializedAt: null,
|
|
322
|
+
createdAt: now,
|
|
323
|
+
updatedAt: now
|
|
324
|
+
};
|
|
325
|
+
this.sessionsRows.push(session);
|
|
326
|
+
return session;
|
|
327
|
+
},
|
|
328
|
+
setSandbox: async ({
|
|
329
|
+
id,
|
|
330
|
+
sandboxId,
|
|
331
|
+
sandboxWorkdir
|
|
332
|
+
}) => {
|
|
333
|
+
const row = this.sessionsRows.find((candidate) => candidate.id === id);
|
|
334
|
+
if (row) Object.assign(row, { sandboxId, sandboxWorkdir, updatedAt: /* @__PURE__ */ new Date() });
|
|
335
|
+
},
|
|
336
|
+
markMaterialized: async ({ id }) => {
|
|
337
|
+
const row = this.sessionsRows.find((candidate) => candidate.id === id);
|
|
338
|
+
if (row) Object.assign(row, { materializedAt: /* @__PURE__ */ new Date(), updatedAt: /* @__PURE__ */ new Date() });
|
|
339
|
+
},
|
|
340
|
+
delete: async (id) => {
|
|
341
|
+
this.sessionsRows.splice(0, this.sessionsRows.length, ...this.sessionsRows.filter((row) => row.id !== id));
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
export {
|
|
346
|
+
SourceControlStorageInMemory
|
|
347
|
+
};
|
|
348
|
+
//# sourceMappingURL=inmemory.js.map
|