@codemation/host 0.0.1
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/README.md +75 -0
- package/dist/CodemationConfig-XCkSV2dj.d.ts +168 -0
- package/dist/CodemationConsumerConfigLoader-Dmm2TzAA.d.ts +61 -0
- package/dist/CodemationConsumerConfigLoader-scS_RQMy.js +334 -0
- package/dist/CodemationConsumerConfigLoader-scS_RQMy.js.map +1 -0
- package/dist/CodemationFrontendBootstrapRequest-CE6DjOWJ.js +5768 -0
- package/dist/CodemationFrontendBootstrapRequest-CE6DjOWJ.js.map +1 -0
- package/dist/CodemationPluginListMerger-BNmaoXQL.js +49 -0
- package/dist/CodemationPluginListMerger-BNmaoXQL.js.map +1 -0
- package/dist/CodemationPluginListMerger-BRYqEk0y.d.ts +793 -0
- package/dist/CodemationWhitelabelConfig-DgbjgtrR.d.ts +48 -0
- package/dist/ConsoleLogger-ClPU7jtc.js +35 -0
- package/dist/ConsoleLogger-ClPU7jtc.js.map +1 -0
- package/dist/CredentialServices-BKBGe7l3.js +1030 -0
- package/dist/CredentialServices-BKBGe7l3.js.map +1 -0
- package/dist/CredentialServices-DpDpm8mL.d.ts +291 -0
- package/dist/LogLevelPolicy-4cq9z0TI.d.ts +37 -0
- package/dist/PrismaMigrationDeployer-B1E_gYz7.js +8212 -0
- package/dist/PrismaMigrationDeployer-B1E_gYz7.js.map +1 -0
- package/dist/ServerLoggerFactory-BRHxIDS7.js +340 -0
- package/dist/ServerLoggerFactory-BRHxIDS7.js.map +1 -0
- package/dist/WorkflowViewContracts-DCLpTn25.d.ts +47 -0
- package/dist/chunk-7V6ThxGB.js +39 -0
- package/dist/client-Yh7-CQud.d.ts +21995 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.js +15 -0
- package/dist/client.js.map +1 -0
- package/dist/consumer.d.ts +5 -0
- package/dist/consumer.js +7 -0
- package/dist/credentials.d.ts +50 -0
- package/dist/credentials.js +11 -0
- package/dist/credentials.js.map +1 -0
- package/dist/decorate-B-N_5S4p.js +10 -0
- package/dist/decorateParam-BTcc3KNk.js +15 -0
- package/dist/devServerSidecar.d.ts +52 -0
- package/dist/devServerSidecar.js +131 -0
- package/dist/devServerSidecar.js.map +1 -0
- package/dist/index-Bs4F1IsC.d.ts +1044 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +14 -0
- package/dist/nextServer.d.ts +89 -0
- package/dist/nextServer.js +127 -0
- package/dist/nextServer.js.map +1 -0
- package/dist/persistenceServer-K5eqlZm3.d.ts +36 -0
- package/dist/persistenceServer-W9uRw0dJ.js +19 -0
- package/dist/persistenceServer-W9uRw0dJ.js.map +1 -0
- package/dist/persistenceServer.d.ts +6 -0
- package/dist/persistenceServer.js +6 -0
- package/dist/server-BBdsATju.d.ts +132 -0
- package/dist/server-BiHSuA13.js +175 -0
- package/dist/server-BiHSuA13.js.map +1 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.js +13 -0
- package/package.json +152 -0
- package/playwright.config.ts +74 -0
- package/prisma/migrations/20260315063514_init/migration.sql +16 -0
- package/prisma/migrations/20260316090000_workflow_debugger_overlay/migration.sql +9 -0
- package/prisma/migrations/20260317120000_trigger_state_store/migration.sql +3 -0
- package/prisma/migrations/20260317153000_trigger_setup_state/migration.sql +8 -0
- package/prisma/migrations/20260318110000_credentials_v2/migration.sql +49 -0
- package/prisma/migrations/20260319110000_credential_oauth2_material/migration.sql +28 -0
- package/prisma/migrations/20260319200000_codemation_auth_tables/migration.sql +56 -0
- package/prisma/migrations/20260320140000_user_invites_account_status/migration.sql +20 -0
- package/prisma/migrations/20260325120000_workflow_activation/migration.sql +8 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +179 -0
- package/prisma.config.ts +12 -0
- package/scripts/ensure-prisma-runtime-sourcemaps.mjs +42 -0
- package/scripts/integration-database-global-setup.mjs +30 -0
- package/src/application/ApplicationRequestError.ts +12 -0
- package/src/application/auth/AuthenticatedPrincipal.ts +5 -0
- package/src/application/auth/SessionVerifier.ts +5 -0
- package/src/application/binary/OverlayPinnedBinaryUploadService.ts +119 -0
- package/src/application/binary/RunBinaryAttachmentLookupService.ts +139 -0
- package/src/application/binary/RunStateBinaryStorageKeysCollector.ts +57 -0
- package/src/application/bus/Command.ts +3 -0
- package/src/application/bus/CommandBus.ts +5 -0
- package/src/application/bus/CommandHandler.ts +5 -0
- package/src/application/bus/DomainEvent.ts +1 -0
- package/src/application/bus/DomainEventBus.ts +5 -0
- package/src/application/bus/DomainEventHandler.ts +5 -0
- package/src/application/bus/Query.ts +3 -0
- package/src/application/bus/QueryBus.ts +5 -0
- package/src/application/bus/QueryHandler.ts +5 -0
- package/src/application/commands/AcceptUserInviteCommand.ts +10 -0
- package/src/application/commands/AcceptUserInviteCommandHandler.ts +19 -0
- package/src/application/commands/CopyRunToWorkflowDebuggerCommand.ts +14 -0
- package/src/application/commands/CopyRunToWorkflowDebuggerCommandHandler.ts +56 -0
- package/src/application/commands/CreateCredentialInstanceCommand.ts +9 -0
- package/src/application/commands/CreateCredentialInstanceCommandHandler.ts +28 -0
- package/src/application/commands/CredentialCommandHandlers.ts +10 -0
- package/src/application/commands/DeleteCredentialInstanceCommand.ts +7 -0
- package/src/application/commands/DeleteCredentialInstanceCommandHandler.ts +27 -0
- package/src/application/commands/HandleWebhookInvocationCommand.ts +12 -0
- package/src/application/commands/HandleWebhookInvocationCommandHandler.ts +42 -0
- package/src/application/commands/InviteUserCommand.ts +12 -0
- package/src/application/commands/InviteUserCommandHandler.ts +22 -0
- package/src/application/commands/RegenerateUserInviteCommand.ts +12 -0
- package/src/application/commands/RegenerateUserInviteCommandHandler.ts +24 -0
- package/src/application/commands/ReplaceMutableRunWorkflowSnapshotCommand.ts +12 -0
- package/src/application/commands/ReplaceMutableRunWorkflowSnapshotCommandHandler.ts +47 -0
- package/src/application/commands/ReplaceWorkflowDebuggerOverlayCommand.ts +14 -0
- package/src/application/commands/ReplaceWorkflowDebuggerOverlayCommandHandler.ts +35 -0
- package/src/application/commands/ReplayWorkflowNodeCommand.ts +12 -0
- package/src/application/commands/ReplayWorkflowNodeCommandHandler.ts +164 -0
- package/src/application/commands/SetPinnedNodeInputCommand.ts +13 -0
- package/src/application/commands/SetPinnedNodeInputCommandHandler.ts +50 -0
- package/src/application/commands/SetWorkflowActivationCommand.ts +10 -0
- package/src/application/commands/SetWorkflowActivationCommandHandler.ts +39 -0
- package/src/application/commands/StartWorkflowRunCommand.ts +8 -0
- package/src/application/commands/StartWorkflowRunCommandHandler.ts +286 -0
- package/src/application/commands/TestCredentialInstanceCommand.ts +9 -0
- package/src/application/commands/TestCredentialInstanceCommandHandler.ts +28 -0
- package/src/application/commands/UpdateCredentialInstanceCommand.ts +12 -0
- package/src/application/commands/UpdateCredentialInstanceCommandHandler.ts +28 -0
- package/src/application/commands/UpdateUserAccountStatusCommand.ts +12 -0
- package/src/application/commands/UpdateUserAccountStatusCommandHandler.ts +24 -0
- package/src/application/commands/UploadOverlayPinnedBinaryCommand.ts +16 -0
- package/src/application/commands/UploadOverlayPinnedBinaryCommandHandler.ts +31 -0
- package/src/application/commands/UpsertCredentialBindingCommand.ts +11 -0
- package/src/application/commands/UpsertCredentialBindingCommandHandler.ts +28 -0
- package/src/application/commands/UpsertLocalBootstrapUserCommand.ts +12 -0
- package/src/application/commands/UpsertLocalBootstrapUserCommandHandler.ts +24 -0
- package/src/application/commands/UserAccountCommandHandlers.ts +10 -0
- package/src/application/contracts/CredentialContractsRegistry.ts +88 -0
- package/src/application/contracts/RunContracts.ts +41 -0
- package/src/application/contracts/WorkflowDebuggerContracts.ts +12 -0
- package/src/application/contracts/WorkflowViewContracts.ts +40 -0
- package/src/application/contracts/WorkflowWebsocketMessage.ts +8 -0
- package/src/application/contracts/userDirectoryContracts.types.ts +60 -0
- package/src/application/dev/BootRuntimeSnapshotHolder.ts +19 -0
- package/src/application/dev/BootRuntimeSummary.types.ts +11 -0
- package/src/application/dev/DevBootstrapSummaryAssembler.ts +84 -0
- package/src/application/dev/DevBootstrapSummaryJson.types.ts +9 -0
- package/src/application/logging/LogFilter.ts +7 -0
- package/src/application/logging/Logger.ts +10 -0
- package/src/application/mapping/DataMapper.ts +3 -0
- package/src/application/mapping/WorkflowDefinitionMapper.ts +171 -0
- package/src/application/mapping/WorkflowPolicyUiPresentationFactory.ts +39 -0
- package/src/application/queries/CredentialQueryHandlers.ts +12 -0
- package/src/application/queries/GetCredentialFieldEnvStatusQuery.ts +5 -0
- package/src/application/queries/GetCredentialFieldEnvStatusQueryHandler.ts +52 -0
- package/src/application/queries/GetCredentialInstanceQuery.ts +9 -0
- package/src/application/queries/GetCredentialInstanceQueryHandler.ts +27 -0
- package/src/application/queries/GetCredentialInstanceWithSecretsQuery.ts +9 -0
- package/src/application/queries/GetCredentialInstanceWithSecretsQueryHandler.ts +27 -0
- package/src/application/queries/GetRunBinaryAttachmentQuery.ts +11 -0
- package/src/application/queries/GetRunBinaryAttachmentQueryHandler.ts +23 -0
- package/src/application/queries/GetRunStateQuery.ts +8 -0
- package/src/application/queries/GetRunStateQueryHandler.ts +21 -0
- package/src/application/queries/GetWorkflowCredentialHealthQuery.ts +9 -0
- package/src/application/queries/GetWorkflowCredentialHealthQueryHandler.ts +27 -0
- package/src/application/queries/GetWorkflowDebuggerOverlayQuery.ts +8 -0
- package/src/application/queries/GetWorkflowDebuggerOverlayQueryHandler.ts +28 -0
- package/src/application/queries/GetWorkflowDetailQuery.ts +8 -0
- package/src/application/queries/GetWorkflowDetailQueryHandler.ts +24 -0
- package/src/application/queries/GetWorkflowOverlayBinaryAttachmentQuery.ts +11 -0
- package/src/application/queries/GetWorkflowOverlayBinaryAttachmentQueryHandler.ts +23 -0
- package/src/application/queries/GetWorkflowSummariesQuery.ts +4 -0
- package/src/application/queries/GetWorkflowSummariesQueryHandler.ts +23 -0
- package/src/application/queries/ListCredentialInstancesQuery.ts +5 -0
- package/src/application/queries/ListCredentialInstancesQueryHandler.ts +27 -0
- package/src/application/queries/ListCredentialTypesQuery.ts +5 -0
- package/src/application/queries/ListCredentialTypesQueryHandler.ts +28 -0
- package/src/application/queries/ListUserAccountsQuery.ts +5 -0
- package/src/application/queries/ListUserAccountsQueryHandler.ts +22 -0
- package/src/application/queries/ListWorkflowRunsQuery.ts +8 -0
- package/src/application/queries/ListWorkflowRunsQueryHandler.ts +21 -0
- package/src/application/queries/UserAccountQueryHandlers.ts +4 -0
- package/src/application/queries/VerifyUserInviteQuery.ts +9 -0
- package/src/application/queries/VerifyUserInviteQueryHandler.ts +21 -0
- package/src/application/runs/WorkflowRunRetentionPruneScheduler.ts +98 -0
- package/src/application/websocket/WorkflowRunEventWebsocketRelay.ts +36 -0
- package/src/application/websocket/WorkflowWebsocketPublisher.ts +5 -0
- package/src/application/workflows/WebhookEndpointPathValidator.ts +35 -0
- package/src/application/workflows/WorkflowDebuggerOverlayStateFactory.ts +122 -0
- package/src/applicationTokens.ts +72 -0
- package/src/bootstrap/CodemationBootstrapRequest.ts +27 -0
- package/src/bootstrap/CodemationContainerFactory.ts +310 -0
- package/src/bootstrap/CodemationContainerRegistration.ts +23 -0
- package/src/bootstrap/CodemationContainerRegistrationRegistrar.ts +42 -0
- package/src/bootstrap/CodemationFrontendBootstrapRequest.ts +16 -0
- package/src/bootstrap/CodemationWorkerBootstrapRequest.ts +19 -0
- package/src/bootstrap/PreparedCodemationRuntime.ts +37 -0
- package/src/bootstrap/PreparedCodemationRuntimeFactory.ts +308 -0
- package/src/bootstrap/boot/CliRuntimeBootService.ts +27 -0
- package/src/bootstrap/boot/FrontendRuntimeBootService.ts +86 -0
- package/src/bootstrap/boot/WorkerRuntimeBootService.ts +64 -0
- package/src/bootstrap/runtime/AppConfigFactory.ts +57 -0
- package/src/bootstrap/runtime/ResolvedImplementationSelectionFactory.ts +118 -0
- package/src/client.ts +3 -0
- package/src/codemationApplication.ts +311 -0
- package/src/consumer.ts +4 -0
- package/src/credentials.ts +24 -0
- package/src/devServerSidecar.ts +10 -0
- package/src/domain/credentials/CredentialBindingService.ts +139 -0
- package/src/domain/credentials/CredentialFieldEnvOverlayService.ts +60 -0
- package/src/domain/credentials/CredentialInstanceService.ts +391 -0
- package/src/domain/credentials/CredentialMaterialResolver.ts +55 -0
- package/src/domain/credentials/CredentialRuntimeMaterialService.ts +39 -0
- package/src/domain/credentials/CredentialSecretCipher.ts +70 -0
- package/src/domain/credentials/CredentialServices.ts +145 -0
- package/src/domain/credentials/CredentialSessionServiceImpl.ts +119 -0
- package/src/domain/credentials/CredentialTestService.ts +73 -0
- package/src/domain/credentials/CredentialTypeRegistryImpl.ts +29 -0
- package/src/domain/credentials/OAuth2ConnectServiceFactory.ts +396 -0
- package/src/domain/credentials/OAuth2ProviderRegistry.ts +75 -0
- package/src/domain/credentials/WorkflowCredentialNodeResolver.ts +246 -0
- package/src/domain/runs/WorkflowRunRepository.ts +11 -0
- package/src/domain/users/UserAccountServiceRegistry.ts +315 -0
- package/src/domain/users/userLoginMethodLabels.types.ts +29 -0
- package/src/domain/workflows/WorkflowActivationPreflight.ts +32 -0
- package/src/domain/workflows/WorkflowActivationPreflightRules.ts +77 -0
- package/src/domain/workflows/WorkflowActivationRepository.ts +9 -0
- package/src/domain/workflows/WorkflowDebuggerOverlayRepository.ts +7 -0
- package/src/domain/workflows/WorkflowDebuggerOverlayState.ts +8 -0
- package/src/domain/workflows/WorkflowDefinitionRepository.ts +11 -0
- package/src/index.ts +58 -0
- package/src/infrastructure/auth/AuthJsSessionVerifier.ts +26 -0
- package/src/infrastructure/auth/DevelopmentSessionBypassVerifier.ts +12 -0
- package/src/infrastructure/binary/BinaryBodyNodeReadableFactory.ts +22 -0
- package/src/infrastructure/binary/CountingSha256Transform.ts +26 -0
- package/src/infrastructure/binary/LocalFilesystemBinaryStorageRegistry.ts +86 -0
- package/src/infrastructure/config/CodemationPluginRegistrar.ts +44 -0
- package/src/infrastructure/credentials/FrameworkBuiltinCredentialTypesRegistrar.ts +21 -0
- package/src/infrastructure/credentials/OpenAiApiKeyCredentialHealthTester.ts +89 -0
- package/src/infrastructure/credentials/OpenAiApiKeyCredentialShapes.types.ts +15 -0
- package/src/infrastructure/credentials/OpenAiApiKeyCredentialTypeFactory.ts +47 -0
- package/src/infrastructure/di/HandlesCommandRegistry.ts +24 -0
- package/src/infrastructure/di/HandlesDomainEventRegistry.ts +24 -0
- package/src/infrastructure/di/HandlesQueryRegistry.ts +24 -0
- package/src/infrastructure/di/InMemoryCommandBus.ts +47 -0
- package/src/infrastructure/di/InMemoryDomainEventBus.ts +47 -0
- package/src/infrastructure/di/InMemoryQueryBus.ts +45 -0
- package/src/infrastructure/ids/CodemationIdFactory.ts +12 -0
- package/src/infrastructure/logging/BrowserLogger.ts +1 -0
- package/src/infrastructure/logging/BrowserLoggerFactory.ts +14 -0
- package/src/infrastructure/logging/ConsoleLogger.ts +41 -0
- package/src/infrastructure/logging/FilteringLogger.ts +38 -0
- package/src/infrastructure/logging/LogLevelPolicy.ts +148 -0
- package/src/infrastructure/logging/LogLevelPolicyFactory.ts +16 -0
- package/src/infrastructure/logging/PerformanceLogPolicy.ts +10 -0
- package/src/infrastructure/logging/PerformanceLogPolicyFactory.ts +14 -0
- package/src/infrastructure/logging/ServerLogger.ts +1 -0
- package/src/infrastructure/logging/ServerLoggerFactory.ts +28 -0
- package/src/infrastructure/persistence/CodemationPostgresPrismaClientFactory.ts +9 -0
- package/src/infrastructure/persistence/CredentialPersistenceStore.ts +139 -0
- package/src/infrastructure/persistence/DatabasePersistenceResolver.ts +91 -0
- package/src/infrastructure/persistence/InMemoryTriggerSetupStateRepository.ts +23 -0
- package/src/infrastructure/persistence/InMemoryWorkflowActivationRepository.ts +18 -0
- package/src/infrastructure/persistence/InMemoryWorkflowDebuggerOverlayRepository.ts +16 -0
- package/src/infrastructure/persistence/InMemoryWorkflowRunRepository.ts +94 -0
- package/src/infrastructure/persistence/PrismaClientFactory.ts +26 -0
- package/src/infrastructure/persistence/PrismaCredentialStore.ts +368 -0
- package/src/infrastructure/persistence/PrismaMigrationDeployer.ts +184 -0
- package/src/infrastructure/persistence/PrismaTriggerSetupStateRepository.ts +68 -0
- package/src/infrastructure/persistence/PrismaWorkflowActivationRepository.ts +36 -0
- package/src/infrastructure/persistence/PrismaWorkflowDebuggerOverlayRepository.ts +65 -0
- package/src/infrastructure/persistence/PrismaWorkflowRunRepository.ts +243 -0
- package/src/infrastructure/persistence/RuntimeWorkflowActivationPolicy.ts +27 -0
- package/src/infrastructure/persistence/SchedulerPersistenceCompatibilityValidator.ts +20 -0
- package/src/infrastructure/persistence/WorkflowDefinitionRepositoryAdapter.ts +31 -0
- package/src/infrastructure/persistence/WorkflowRunRepository.ts +46 -0
- package/src/infrastructure/persistence/generated/prisma/client.d.ts +1 -0
- package/src/infrastructure/persistence/generated/prisma/default.d.ts +1 -0
- package/src/infrastructure/persistence/generated/prisma/edge.d.ts +1 -0
- package/src/infrastructure/persistence/generated/prisma/index.d.ts +4766 -0
- package/src/infrastructure/persistence/generated/prisma/package.json +144 -0
- package/src/infrastructure/persistence/generated/prisma/query_compiler_fast_bg.wasm +0 -0
- package/src/infrastructure/persistence/generated/prisma/runtime/client.d.ts +3358 -0
- package/src/infrastructure/persistence/generated/prisma/runtime/index-browser.d.ts +90 -0
- package/src/infrastructure/persistence/generated/prisma/schema.prisma +35 -0
- package/src/infrastructure/persistence/generated/prisma/wasm-edge-light-loader.mjs +5 -0
- package/src/infrastructure/persistence/generated/prisma/wasm-worker-loader.mjs +5 -0
- package/src/infrastructure/persistence/generated/prisma-client/client.d.ts +1 -0
- package/src/infrastructure/persistence/generated/prisma-client/client.js +5 -0
- package/src/infrastructure/persistence/generated/prisma-client/default.d.ts +1 -0
- package/src/infrastructure/persistence/generated/prisma-client/default.js +5 -0
- package/src/infrastructure/persistence/generated/prisma-client/edge.d.ts +1 -0
- package/src/infrastructure/persistence/generated/prisma-client/edge.js +299 -0
- package/src/infrastructure/persistence/generated/prisma-client/index-browser.js +325 -0
- package/src/infrastructure/persistence/generated/prisma-client/index.d.ts +21623 -0
- package/src/infrastructure/persistence/generated/prisma-client/index.js +299 -0
- package/src/infrastructure/persistence/generated/prisma-client/package.json +144 -0
- package/src/infrastructure/persistence/generated/prisma-client/query_compiler_fast_bg.js +2 -0
- package/src/infrastructure/persistence/generated/prisma-client/query_compiler_fast_bg.wasm +0 -0
- package/src/infrastructure/persistence/generated/prisma-client/query_compiler_fast_bg.wasm-base64.js +2 -0
- package/src/infrastructure/persistence/generated/prisma-client/runtime/client.d.ts +3358 -0
- package/src/infrastructure/persistence/generated/prisma-client/runtime/client.js +86 -0
- package/src/infrastructure/persistence/generated/prisma-client/runtime/client.js.map +1 -0
- package/src/infrastructure/persistence/generated/prisma-client/runtime/index-browser.d.ts +90 -0
- package/src/infrastructure/persistence/generated/prisma-client/runtime/index-browser.js +6 -0
- package/src/infrastructure/persistence/generated/prisma-client/runtime/index-browser.js.map +1 -0
- package/src/infrastructure/persistence/generated/prisma-client/runtime/wasm-compiler-edge.js +76 -0
- package/src/infrastructure/persistence/generated/prisma-client/runtime/wasm-compiler-edge.js.map +1 -0
- package/src/infrastructure/persistence/generated/prisma-client/schema.prisma +179 -0
- package/src/infrastructure/persistence/generated/prisma-client/wasm-edge-light-loader.mjs +5 -0
- package/src/infrastructure/persistence/generated/prisma-client/wasm-worker-loader.mjs +5 -0
- package/src/infrastructure/runtime/LiveWorkflowRepository.ts +14 -0
- package/src/infrastructure/runtime/WorkerRuntimeScheduler.ts +35 -0
- package/src/infrastructure/server/http/ServerHttpRouteParams.ts +1 -0
- package/src/infrastructure/webhooks/RequestToWebhookItemMapper.ts +128 -0
- package/src/nextServer.ts +31 -0
- package/src/persistenceServer.ts +5 -0
- package/src/presentation/config/AppConfig.ts +25 -0
- package/src/presentation/config/CodemationAppContext.ts +19 -0
- package/src/presentation/config/CodemationApplicationFacade.ts +5 -0
- package/src/presentation/config/CodemationAuthConfig.ts +31 -0
- package/src/presentation/config/CodemationClassToken.ts +3 -0
- package/src/presentation/config/CodemationConfig.ts +86 -0
- package/src/presentation/config/CodemationConfigNormalizer.ts +179 -0
- package/src/presentation/config/CodemationLogConfig.ts +22 -0
- package/src/presentation/config/CodemationPackageManifest.ts +9 -0
- package/src/presentation/config/CodemationPlugin.ts +20 -0
- package/src/presentation/config/CodemationPluginListMerger.ts +46 -0
- package/src/presentation/config/CodemationWhitelabelConfig.ts +9 -0
- package/src/presentation/config/CodemationWorkflowDiscovery.ts +3 -0
- package/src/presentation/http/ApiPaths.ts +165 -0
- package/src/presentation/http/CodemationServerGatewayFactory.ts +120 -0
- package/src/presentation/http/HttpRequestJsonBodyReader.ts +12 -0
- package/src/presentation/http/ServerHttpErrorResponseFactory.ts +33 -0
- package/src/presentation/http/ServerHttpRouteParams.ts +1 -0
- package/src/presentation/http/hono/CodemationHonoApiAppFactory.ts +64 -0
- package/src/presentation/http/hono/HonoApiRouteRegistrar.ts +5 -0
- package/src/presentation/http/hono/HonoHttpAnonymousRoutePolicyRegistry.ts +27 -0
- package/src/presentation/http/hono/registrars/BinaryHonoApiRouteRegistrar.ts +21 -0
- package/src/presentation/http/hono/registrars/CredentialHonoApiRouteRegistrar.ts +34 -0
- package/src/presentation/http/hono/registrars/DevHonoApiRouteRegistrar.ts +17 -0
- package/src/presentation/http/hono/registrars/OAuth2HonoApiRouteRegistrar.ts +18 -0
- package/src/presentation/http/hono/registrars/RunHonoApiRouteRegistrar.ts +31 -0
- package/src/presentation/http/hono/registrars/UserHonoApiRouteRegistrar.ts +24 -0
- package/src/presentation/http/hono/registrars/WebhookHonoApiRouteRegistrar.ts +23 -0
- package/src/presentation/http/hono/registrars/WhitelabelHonoApiRouteRegistrar.ts +18 -0
- package/src/presentation/http/hono/registrars/WorkflowHonoApiRouteRegistrar.ts +33 -0
- package/src/presentation/http/routeHandlers/BinaryHttpRouteHandlerFactory.ts +101 -0
- package/src/presentation/http/routeHandlers/CredentialHttpRouteHandler.ts +129 -0
- package/src/presentation/http/routeHandlers/DevBootstrapSummaryHttpRouteHandler.ts +21 -0
- package/src/presentation/http/routeHandlers/OAuth2HttpRouteHandlerFactory.ts +129 -0
- package/src/presentation/http/routeHandlers/RunHttpRouteHandler.ts +82 -0
- package/src/presentation/http/routeHandlers/UserHttpRouteHandlerFactory.ts +109 -0
- package/src/presentation/http/routeHandlers/WebhookHttpRouteHandler.ts +42 -0
- package/src/presentation/http/routeHandlers/WhitelabelLogoHttpRouteHandler.ts +96 -0
- package/src/presentation/http/routeHandlers/WorkflowHttpRouteHandler.ts +104 -0
- package/src/presentation/server/CodemationConsumerAppResolver.ts +82 -0
- package/src/presentation/server/CodemationConsumerConfigExportsResolver.ts +33 -0
- package/src/presentation/server/CodemationConsumerConfigLoader.ts +270 -0
- package/src/presentation/server/CodemationPluginDiscovery.ts +151 -0
- package/src/presentation/server/CodemationTsyringeParamInfoReader.ts +26 -0
- package/src/presentation/server/CodemationTsyringeTypeInfoRegistrar.ts +121 -0
- package/src/presentation/server/DevelopmentRuntimeRouteGuard.ts +59 -0
- package/src/presentation/server/DiscoveredWorkflowsEmptyMessageFactory.ts +11 -0
- package/src/presentation/server/WorkflowDefinitionExportsResolver.ts +24 -0
- package/src/presentation/server/WorkflowDiscoveryPathSegmentsComputer.ts +53 -0
- package/src/presentation/server/WorkflowModulePathFinder.ts +47 -0
- package/src/presentation/websocket/WorkflowWebsocketServer.ts +169 -0
- package/src/server.ts +14 -0
- package/tsconfig.json +10 -0
- package/vitest.shared.ts +45 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { inject, injectAll, injectable } from "@codemation/core";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import type { SessionVerifier } from "../../../application/auth/SessionVerifier";
|
|
4
|
+
import { ApplicationTokens } from "../../../applicationTokens";
|
|
5
|
+
import { BinaryHttpRouteHandler } from "../routeHandlers/BinaryHttpRouteHandlerFactory";
|
|
6
|
+
import { ServerHttpErrorResponseFactory } from "../ServerHttpErrorResponseFactory";
|
|
7
|
+
import type { HonoApiRouteRegistrar } from "./HonoApiRouteRegistrar";
|
|
8
|
+
import { HonoHttpAnonymousRoutePolicy } from "./HonoHttpAnonymousRoutePolicyRegistry";
|
|
9
|
+
|
|
10
|
+
@injectable()
|
|
11
|
+
export class CodemationHonoApiApp {
|
|
12
|
+
private readonly app: Hono;
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
@inject(ApplicationTokens.SessionVerifier)
|
|
16
|
+
sessionVerifier: SessionVerifier,
|
|
17
|
+
@injectAll(ApplicationTokens.HonoApiRouteRegistrar)
|
|
18
|
+
registrars: ReadonlyArray<HonoApiRouteRegistrar>,
|
|
19
|
+
@inject(BinaryHttpRouteHandler)
|
|
20
|
+
binaryHttpRouteHandler: BinaryHttpRouteHandler,
|
|
21
|
+
) {
|
|
22
|
+
const app = new Hono().basePath("/api");
|
|
23
|
+
app.onError((error, _c) => ServerHttpErrorResponseFactory.fromUnknown(error));
|
|
24
|
+
app.use("*", async (c, next) => {
|
|
25
|
+
if (HonoHttpAnonymousRoutePolicy.isAnonymousRoute(c.req.raw)) {
|
|
26
|
+
await next();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const principal = await sessionVerifier.verify(c.req.raw);
|
|
30
|
+
if (!principal) {
|
|
31
|
+
return c.json({ error: "Unauthorized" }, 401);
|
|
32
|
+
}
|
|
33
|
+
await next();
|
|
34
|
+
});
|
|
35
|
+
for (const registrar of registrars) {
|
|
36
|
+
registrar.register(app);
|
|
37
|
+
}
|
|
38
|
+
app.get("/workflows/:workflowId/debugger-overlay/binary/:binaryId/content", (c) =>
|
|
39
|
+
binaryHttpRouteHandler.getWorkflowOverlayBinaryContent(c.req.raw, {
|
|
40
|
+
workflowId: c.req.param("workflowId"),
|
|
41
|
+
binaryId: c.req.param("binaryId"),
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
app.post("/workflows/:workflowId/debugger-overlay/binary/upload", (c) =>
|
|
45
|
+
binaryHttpRouteHandler.postWorkflowDebuggerOverlayBinaryUpload(c.req.raw, {
|
|
46
|
+
workflowId: c.req.param("workflowId"),
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
app.notFound((c) => {
|
|
50
|
+
const method = c.req.method.toUpperCase();
|
|
51
|
+
const url = new URL(c.req.url);
|
|
52
|
+
return c.json({ error: `Unknown API route: ${method} ${url.pathname}` }, 404);
|
|
53
|
+
});
|
|
54
|
+
this.app = app;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
getHono(): Hono {
|
|
58
|
+
return this.app;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
fetch(request: Request): Response | Promise<Response> {
|
|
62
|
+
return this.app.fetch(request);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ApiPaths } from "../ApiPaths";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Routes that must remain callable without an authenticated Codemation session.
|
|
5
|
+
* @see ApiPaths — keep in sync with webhook + dev-only endpoints.
|
|
6
|
+
*/
|
|
7
|
+
export class HonoHttpAnonymousRoutePolicy {
|
|
8
|
+
private static readonly webhookPrefix = `${ApiPaths.webhooks()}/`;
|
|
9
|
+
|
|
10
|
+
static isAnonymousRoute(request: Request): boolean {
|
|
11
|
+
const url = new URL(request.url);
|
|
12
|
+
const pathname = url.pathname;
|
|
13
|
+
if (pathname === ApiPaths.webhooks() || pathname.startsWith(this.webhookPrefix)) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
if (pathname === "/api/dev/runtime" || pathname === "/api/dev/bootstrap-summary") {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
if (pathname === ApiPaths.userInviteVerify() || pathname === ApiPaths.userInviteAccept()) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (pathname === ApiPaths.whitelabelLogo()) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { inject, injectable, registry } from "@codemation/core";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { ApplicationTokens } from "../../../../applicationTokens";
|
|
4
|
+
import { BinaryHttpRouteHandler } from "../../routeHandlers/BinaryHttpRouteHandlerFactory";
|
|
5
|
+
import type { HonoApiRouteRegistrar } from "../HonoApiRouteRegistrar";
|
|
6
|
+
|
|
7
|
+
/** Run-scoped binary content. Workflow overlay binary GET/POST are registered on {@link CodemationHonoApiApp} after route registrars. */
|
|
8
|
+
@injectable()
|
|
9
|
+
@registry([{ token: ApplicationTokens.HonoApiRouteRegistrar, useClass: BinaryHonoApiRouteRegistrar }])
|
|
10
|
+
export class BinaryHonoApiRouteRegistrar implements HonoApiRouteRegistrar {
|
|
11
|
+
constructor(@inject(BinaryHttpRouteHandler) private readonly handler: BinaryHttpRouteHandler) {}
|
|
12
|
+
|
|
13
|
+
register(app: Hono): void {
|
|
14
|
+
app.get("/runs/:runId/binary/:binaryId/content", (c) =>
|
|
15
|
+
this.handler.getRunBinaryContent(c.req.raw, {
|
|
16
|
+
runId: c.req.param("runId"),
|
|
17
|
+
binaryId: c.req.param("binaryId"),
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { inject, injectable, registry } from "@codemation/core";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { ApplicationTokens } from "../../../../applicationTokens";
|
|
4
|
+
import { CredentialHttpRouteHandler } from "../../routeHandlers/CredentialHttpRouteHandler";
|
|
5
|
+
import type { HonoApiRouteRegistrar } from "../HonoApiRouteRegistrar";
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
@registry([{ token: ApplicationTokens.HonoApiRouteRegistrar, useClass: CredentialHonoApiRouteRegistrar }])
|
|
9
|
+
export class CredentialHonoApiRouteRegistrar implements HonoApiRouteRegistrar {
|
|
10
|
+
constructor(@inject(CredentialHttpRouteHandler) private readonly handler: CredentialHttpRouteHandler) {}
|
|
11
|
+
|
|
12
|
+
register(app: Hono): void {
|
|
13
|
+
app.get("/credentials/types", (_c) => this.handler.getCredentialTypes());
|
|
14
|
+
app.get("/credentials/env-status", (_c) => this.handler.getCredentialFieldEnvStatus());
|
|
15
|
+
app.get("/credentials/instances", (_c) => this.handler.getCredentialInstances());
|
|
16
|
+
app.get("/workflows/:workflowId/credential-health", (c) =>
|
|
17
|
+
this.handler.getWorkflowCredentialHealth(c.req.raw, { workflowId: c.req.param("workflowId") }),
|
|
18
|
+
);
|
|
19
|
+
app.get("/credentials/instances/:instanceId", (c) =>
|
|
20
|
+
this.handler.getCredentialInstance(c.req.raw, { instanceId: c.req.param("instanceId") }),
|
|
21
|
+
);
|
|
22
|
+
app.post("/credentials/instances", (c) => this.handler.postCredentialInstance(c.req.raw));
|
|
23
|
+
app.put("/credentials/instances/:instanceId", (c) =>
|
|
24
|
+
this.handler.putCredentialInstance(c.req.raw, { instanceId: c.req.param("instanceId") }),
|
|
25
|
+
);
|
|
26
|
+
app.delete("/credentials/instances/:instanceId", (c) =>
|
|
27
|
+
this.handler.deleteCredentialInstance(c.req.raw, { instanceId: c.req.param("instanceId") }),
|
|
28
|
+
);
|
|
29
|
+
app.put("/credential-bindings", (c) => this.handler.putCredentialBinding(c.req.raw));
|
|
30
|
+
app.post("/credentials/instances/:instanceId/test", (c) =>
|
|
31
|
+
this.handler.postCredentialInstanceTest(c.req.raw, { instanceId: c.req.param("instanceId") }),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { inject, injectable, registry } from "@codemation/core";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { ApplicationTokens } from "../../../../applicationTokens";
|
|
4
|
+
import { DevBootstrapSummaryHttpRouteHandler } from "../../routeHandlers/DevBootstrapSummaryHttpRouteHandler";
|
|
5
|
+
import type { HonoApiRouteRegistrar } from "../HonoApiRouteRegistrar";
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
@registry([{ token: ApplicationTokens.HonoApiRouteRegistrar, useClass: DevHonoApiRouteRegistrar }])
|
|
9
|
+
export class DevHonoApiRouteRegistrar implements HonoApiRouteRegistrar {
|
|
10
|
+
constructor(
|
|
11
|
+
@inject(DevBootstrapSummaryHttpRouteHandler) private readonly handler: DevBootstrapSummaryHttpRouteHandler,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
register(app: Hono): void {
|
|
15
|
+
app.get("/dev/bootstrap-summary", () => this.handler.getSummary());
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { inject, injectable, registry } from "@codemation/core";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { ApplicationTokens } from "../../../../applicationTokens";
|
|
4
|
+
import { OAuth2HttpRouteHandler } from "../../routeHandlers/OAuth2HttpRouteHandlerFactory";
|
|
5
|
+
import type { HonoApiRouteRegistrar } from "../HonoApiRouteRegistrar";
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
@registry([{ token: ApplicationTokens.HonoApiRouteRegistrar, useClass: OAuth2HonoApiRouteRegistrar }])
|
|
9
|
+
export class OAuth2HonoApiRouteRegistrar implements HonoApiRouteRegistrar {
|
|
10
|
+
constructor(@inject(OAuth2HttpRouteHandler) private readonly handler: OAuth2HttpRouteHandler) {}
|
|
11
|
+
|
|
12
|
+
register(app: Hono): void {
|
|
13
|
+
app.get("/oauth2/auth", (c) => this.handler.getAuthRedirect(c.req.raw));
|
|
14
|
+
app.get("/oauth2/callback", (c) => this.handler.getCallback(c.req.raw));
|
|
15
|
+
app.get("/oauth2/redirect-uri", (c) => this.handler.getRedirectUri(c.req.raw));
|
|
16
|
+
app.post("/oauth2/disconnect", (c) => this.handler.postDisconnect(c.req.raw));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { inject, injectable, registry } from "@codemation/core";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { ApplicationTokens } from "../../../../applicationTokens";
|
|
4
|
+
import { RunHttpRouteHandler } from "../../routeHandlers/RunHttpRouteHandler";
|
|
5
|
+
import type { HonoApiRouteRegistrar } from "../HonoApiRouteRegistrar";
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
@registry([{ token: ApplicationTokens.HonoApiRouteRegistrar, useClass: RunHonoApiRouteRegistrar }])
|
|
9
|
+
export class RunHonoApiRouteRegistrar implements HonoApiRouteRegistrar {
|
|
10
|
+
constructor(@inject(RunHttpRouteHandler) private readonly handler: RunHttpRouteHandler) {}
|
|
11
|
+
|
|
12
|
+
register(app: Hono): void {
|
|
13
|
+
app.get("/runs/:runId", (c) => this.handler.getRun(c.req.raw, { runId: c.req.param("runId") }));
|
|
14
|
+
app.post("/runs", (c) => this.handler.postRuns(c.req.raw, {}));
|
|
15
|
+
app.patch("/runs/:runId/workflow-snapshot", (c) =>
|
|
16
|
+
this.handler.patchRunWorkflowSnapshot(c.req.raw, { runId: c.req.param("runId") }),
|
|
17
|
+
);
|
|
18
|
+
app.patch("/runs/:runId/nodes/:nodeId/pin", (c) =>
|
|
19
|
+
this.handler.patchRunNodePin(c.req.raw, {
|
|
20
|
+
runId: c.req.param("runId"),
|
|
21
|
+
nodeId: c.req.param("nodeId"),
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
app.post("/runs/:runId/nodes/:nodeId/run", (c) =>
|
|
25
|
+
this.handler.postRunNode(c.req.raw, {
|
|
26
|
+
runId: c.req.param("runId"),
|
|
27
|
+
nodeId: c.req.param("nodeId"),
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { inject, injectable, registry } from "@codemation/core";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { ApplicationTokens } from "../../../../applicationTokens";
|
|
4
|
+
import { UserHttpRouteHandler } from "../../routeHandlers/UserHttpRouteHandlerFactory";
|
|
5
|
+
import type { HonoApiRouteRegistrar } from "../HonoApiRouteRegistrar";
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
@registry([{ token: ApplicationTokens.HonoApiRouteRegistrar, useClass: UserHonoApiRouteRegistrar }])
|
|
9
|
+
export class UserHonoApiRouteRegistrar implements HonoApiRouteRegistrar {
|
|
10
|
+
constructor(@inject(UserHttpRouteHandler) private readonly handler: UserHttpRouteHandler) {}
|
|
11
|
+
|
|
12
|
+
register(app: Hono): void {
|
|
13
|
+
app.get("/users/invites/verify", (c) => this.handler.getInviteVerify(c.req.raw));
|
|
14
|
+
app.post("/users/invites/accept", (c) => this.handler.postAcceptInvite(c.req.raw));
|
|
15
|
+
app.get("/users", (_c) => this.handler.getUsers());
|
|
16
|
+
app.post("/users/invites", (c) => this.handler.postInvite(c.req.raw));
|
|
17
|
+
app.post("/users/:userId/invites/regenerate", (c) =>
|
|
18
|
+
this.handler.postRegenerateInvite(c.req.raw, { userId: c.req.param("userId") }),
|
|
19
|
+
);
|
|
20
|
+
app.patch("/users/:userId/status", (c) =>
|
|
21
|
+
this.handler.patchUserStatus(c.req.raw, { userId: c.req.param("userId") }),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { inject, injectable, registry } from "@codemation/core";
|
|
2
|
+
import type { Context } from "hono";
|
|
3
|
+
import { Hono } from "hono";
|
|
4
|
+
import { ApplicationTokens } from "../../../../applicationTokens";
|
|
5
|
+
import { WebhookHttpRouteHandler } from "../../routeHandlers/WebhookHttpRouteHandler";
|
|
6
|
+
import type { HonoApiRouteRegistrar } from "../HonoApiRouteRegistrar";
|
|
7
|
+
|
|
8
|
+
@injectable()
|
|
9
|
+
@registry([{ token: ApplicationTokens.HonoApiRouteRegistrar, useClass: WebhookHonoApiRouteRegistrar }])
|
|
10
|
+
export class WebhookHonoApiRouteRegistrar implements HonoApiRouteRegistrar {
|
|
11
|
+
constructor(@inject(WebhookHttpRouteHandler) private readonly handler: WebhookHttpRouteHandler) {}
|
|
12
|
+
|
|
13
|
+
register(app: Hono): void {
|
|
14
|
+
const path = "/webhooks/:endpointPath";
|
|
15
|
+
const handle = (c: Context) =>
|
|
16
|
+
this.handler.postWebhook(c.req.raw, { endpointPath: c.req.param("endpointPath") ?? "" });
|
|
17
|
+
app.get(path, handle);
|
|
18
|
+
app.post(path, handle);
|
|
19
|
+
app.put(path, handle);
|
|
20
|
+
app.patch(path, handle);
|
|
21
|
+
app.delete(path, handle);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { inject, injectable, registry } from "@codemation/core";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { ApplicationTokens } from "../../../../applicationTokens";
|
|
4
|
+
import { WhitelabelLogoHttpRouteHandler } from "../../routeHandlers/WhitelabelLogoHttpRouteHandler";
|
|
5
|
+
import type { HonoApiRouteRegistrar } from "../HonoApiRouteRegistrar";
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
@registry([{ token: ApplicationTokens.HonoApiRouteRegistrar, useClass: WhitelabelHonoApiRouteRegistrar }])
|
|
9
|
+
export class WhitelabelHonoApiRouteRegistrar implements HonoApiRouteRegistrar {
|
|
10
|
+
constructor(
|
|
11
|
+
@inject(WhitelabelLogoHttpRouteHandler)
|
|
12
|
+
private readonly whitelabelLogoHttpRouteHandler: WhitelabelLogoHttpRouteHandler,
|
|
13
|
+
) {}
|
|
14
|
+
|
|
15
|
+
register(app: Hono): void {
|
|
16
|
+
app.get("/whitelabel/logo", () => this.whitelabelLogoHttpRouteHandler.getLogo());
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { inject, injectable, registry } from "@codemation/core";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { ApplicationTokens } from "../../../../applicationTokens";
|
|
4
|
+
import { WorkflowHttpRouteHandler } from "../../routeHandlers/WorkflowHttpRouteHandler";
|
|
5
|
+
import type { HonoApiRouteRegistrar } from "../HonoApiRouteRegistrar";
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
@registry([{ token: ApplicationTokens.HonoApiRouteRegistrar, useClass: WorkflowHonoApiRouteRegistrar }])
|
|
9
|
+
export class WorkflowHonoApiRouteRegistrar implements HonoApiRouteRegistrar {
|
|
10
|
+
constructor(@inject(WorkflowHttpRouteHandler) private readonly handler: WorkflowHttpRouteHandler) {}
|
|
11
|
+
|
|
12
|
+
register(app: Hono): void {
|
|
13
|
+
app.get("/workflows", (c) => this.handler.getWorkflows(c.req.raw, {}));
|
|
14
|
+
app.get("/workflows/:workflowId/runs", (c) =>
|
|
15
|
+
this.handler.getWorkflowRuns(c.req.raw, { workflowId: c.req.param("workflowId") }),
|
|
16
|
+
);
|
|
17
|
+
app.get("/workflows/:workflowId/debugger-overlay", (c) =>
|
|
18
|
+
this.handler.getWorkflowDebuggerOverlay(c.req.raw, { workflowId: c.req.param("workflowId") }),
|
|
19
|
+
);
|
|
20
|
+
app.put("/workflows/:workflowId/debugger-overlay", (c) =>
|
|
21
|
+
this.handler.putWorkflowDebuggerOverlay(c.req.raw, { workflowId: c.req.param("workflowId") }),
|
|
22
|
+
);
|
|
23
|
+
app.post("/workflows/:workflowId/debugger-overlay/copy-run", (c) =>
|
|
24
|
+
this.handler.postCopyWorkflowDebuggerOverlay(c.req.raw, { workflowId: c.req.param("workflowId") }),
|
|
25
|
+
);
|
|
26
|
+
app.get("/workflows/:workflowId", (c) =>
|
|
27
|
+
this.handler.getWorkflow(c.req.raw, { workflowId: c.req.param("workflowId") }),
|
|
28
|
+
);
|
|
29
|
+
app.patch("/workflows/:workflowId/activation", (c) =>
|
|
30
|
+
this.handler.patchWorkflowActivation(c.req.raw, { workflowId: c.req.param("workflowId") }),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { BinaryAttachment, BinaryBody, BinaryStorage } from "@codemation/core";
|
|
2
|
+
import { CoreTokens, inject, injectable } from "@codemation/core";
|
|
3
|
+
import type { CommandBus } from "../../../application/bus/CommandBus";
|
|
4
|
+
import type { QueryBus } from "../../../application/bus/QueryBus";
|
|
5
|
+
import { UploadOverlayPinnedBinaryCommand } from "../../../application/commands/UploadOverlayPinnedBinaryCommand";
|
|
6
|
+
import { GetRunBinaryAttachmentQuery } from "../../../application/queries/GetRunBinaryAttachmentQuery";
|
|
7
|
+
import { GetWorkflowOverlayBinaryAttachmentQuery } from "../../../application/queries/GetWorkflowOverlayBinaryAttachmentQuery";
|
|
8
|
+
import { ApplicationTokens } from "../../../applicationTokens";
|
|
9
|
+
import { ServerHttpErrorResponseFactory } from "../ServerHttpErrorResponseFactory";
|
|
10
|
+
import type { ServerHttpRouteParams } from "../ServerHttpRouteParams";
|
|
11
|
+
|
|
12
|
+
@injectable()
|
|
13
|
+
export class BinaryHttpRouteHandler {
|
|
14
|
+
constructor(
|
|
15
|
+
@inject(ApplicationTokens.QueryBus)
|
|
16
|
+
private readonly queryBus: QueryBus,
|
|
17
|
+
@inject(ApplicationTokens.CommandBus)
|
|
18
|
+
private readonly commandBus: CommandBus,
|
|
19
|
+
@inject(CoreTokens.BinaryStorage)
|
|
20
|
+
private readonly binaryStorage: BinaryStorage,
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
async getRunBinaryContent(_: Request, params: ServerHttpRouteParams): Promise<Response> {
|
|
24
|
+
try {
|
|
25
|
+
const attachment = await this.queryBus.execute(new GetRunBinaryAttachmentQuery(params.runId!, params.binaryId!));
|
|
26
|
+
return await this.createBinaryResponse(attachment);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async getWorkflowOverlayBinaryContent(_: Request, params: ServerHttpRouteParams): Promise<Response> {
|
|
33
|
+
try {
|
|
34
|
+
const attachment = await this.queryBus.execute(
|
|
35
|
+
new GetWorkflowOverlayBinaryAttachmentQuery(params.workflowId!, params.binaryId!),
|
|
36
|
+
);
|
|
37
|
+
return await this.createBinaryResponse(attachment);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async postWorkflowDebuggerOverlayBinaryUpload(request: Request, params: ServerHttpRouteParams): Promise<Response> {
|
|
44
|
+
try {
|
|
45
|
+
const workflowId = params.workflowId!;
|
|
46
|
+
const form = await request.formData();
|
|
47
|
+
const fileEntry = form.get("file");
|
|
48
|
+
const nodeId = String(form.get("nodeId") ?? "").trim();
|
|
49
|
+
const attachmentName = String(form.get("attachmentName") ?? "file").trim() || "file";
|
|
50
|
+
const itemIndexRaw = form.get("itemIndex");
|
|
51
|
+
const itemIndex = typeof itemIndexRaw === "string" ? Number.parseInt(itemIndexRaw, 10) : Number(itemIndexRaw);
|
|
52
|
+
if (!nodeId) {
|
|
53
|
+
return Response.json({ error: "nodeId is required" }, { status: 400 });
|
|
54
|
+
}
|
|
55
|
+
if (!Number.isFinite(itemIndex) || itemIndex < 0) {
|
|
56
|
+
return Response.json({ error: "itemIndex must be a non-negative integer" }, { status: 400 });
|
|
57
|
+
}
|
|
58
|
+
if (!(fileEntry instanceof Blob) || fileEntry.size === 0) {
|
|
59
|
+
return Response.json({ error: "file is required" }, { status: 400 });
|
|
60
|
+
}
|
|
61
|
+
const mimeType = fileEntry.type && fileEntry.type.trim() ? fileEntry.type : "application/octet-stream";
|
|
62
|
+
const filename = fileEntry instanceof File ? fileEntry.name : undefined;
|
|
63
|
+
/** `Blob#stream()` is a web `ReadableStream`; core `BinaryBody` uses the same stream type under Node’s typings. */
|
|
64
|
+
const body = fileEntry.stream() as BinaryBody;
|
|
65
|
+
const attachment = await this.commandBus.execute(
|
|
66
|
+
new UploadOverlayPinnedBinaryCommand(workflowId, nodeId, itemIndex, attachmentName, mimeType, body, filename),
|
|
67
|
+
);
|
|
68
|
+
return Response.json({ attachment }, { status: 201 });
|
|
69
|
+
} catch (error) {
|
|
70
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private async createBinaryResponse(attachment: BinaryAttachment | undefined): Promise<Response> {
|
|
75
|
+
if (!attachment) {
|
|
76
|
+
return Response.json({ error: "Unknown binary attachment" }, { status: 404 });
|
|
77
|
+
}
|
|
78
|
+
const stored = await this.binaryStorage.openReadStream(attachment.storageKey);
|
|
79
|
+
if (!stored) {
|
|
80
|
+
return Response.json({ error: "Binary attachment content is unavailable" }, { status: 404 });
|
|
81
|
+
}
|
|
82
|
+
const headers = new Headers();
|
|
83
|
+
headers.set("content-type", attachment.mimeType);
|
|
84
|
+
headers.set("content-length", String(stored.size ?? attachment.size));
|
|
85
|
+
headers.set("content-disposition", this.createContentDisposition(attachment));
|
|
86
|
+
return new Response(stored.body as unknown as BodyInit, {
|
|
87
|
+
status: 200,
|
|
88
|
+
headers,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private createContentDisposition(attachment: BinaryAttachment): string {
|
|
93
|
+
const dispositionType = attachment.previewKind === "download" ? "attachment" : "inline";
|
|
94
|
+
const filename = this.escapeFilename(attachment.filename ?? `${attachment.id}`);
|
|
95
|
+
return `${dispositionType}; filename="${filename}"`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private escapeFilename(value: string): string {
|
|
99
|
+
return value.replace(/"/g, "");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { inject, injectable } from "@codemation/core";
|
|
2
|
+
import { HttpRequestJsonBodyReader } from "../HttpRequestJsonBodyReader";
|
|
3
|
+
import type { CommandBus } from "../../../application/bus/CommandBus";
|
|
4
|
+
import type { QueryBus } from "../../../application/bus/QueryBus";
|
|
5
|
+
import {
|
|
6
|
+
CreateCredentialInstanceCommand,
|
|
7
|
+
DeleteCredentialInstanceCommand,
|
|
8
|
+
TestCredentialInstanceCommand,
|
|
9
|
+
UpdateCredentialInstanceCommand,
|
|
10
|
+
UpsertCredentialBindingCommand,
|
|
11
|
+
} from "../../../application/commands/CredentialCommandHandlers";
|
|
12
|
+
import type {
|
|
13
|
+
CreateCredentialInstanceRequest,
|
|
14
|
+
UpdateCredentialInstanceRequest,
|
|
15
|
+
UpsertCredentialBindingRequest,
|
|
16
|
+
} from "../../../application/contracts/CredentialContractsRegistry";
|
|
17
|
+
import {
|
|
18
|
+
GetCredentialFieldEnvStatusQuery,
|
|
19
|
+
GetCredentialInstanceQuery,
|
|
20
|
+
GetCredentialInstanceWithSecretsQuery,
|
|
21
|
+
GetWorkflowCredentialHealthQuery,
|
|
22
|
+
ListCredentialInstancesQuery,
|
|
23
|
+
ListCredentialTypesQuery,
|
|
24
|
+
} from "../../../application/queries/CredentialQueryHandlers";
|
|
25
|
+
import { ApplicationTokens } from "../../../applicationTokens";
|
|
26
|
+
import { ServerHttpErrorResponseFactory } from "../ServerHttpErrorResponseFactory";
|
|
27
|
+
import type { ServerHttpRouteParams } from "../ServerHttpRouteParams";
|
|
28
|
+
|
|
29
|
+
@injectable()
|
|
30
|
+
export class CredentialHttpRouteHandler {
|
|
31
|
+
constructor(
|
|
32
|
+
@inject(ApplicationTokens.QueryBus)
|
|
33
|
+
private readonly queryBus: QueryBus,
|
|
34
|
+
@inject(ApplicationTokens.CommandBus)
|
|
35
|
+
private readonly commandBus: CommandBus,
|
|
36
|
+
) {}
|
|
37
|
+
|
|
38
|
+
async getCredentialTypes(): Promise<Response> {
|
|
39
|
+
try {
|
|
40
|
+
return Response.json(await this.queryBus.execute(new ListCredentialTypesQuery()));
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async getCredentialFieldEnvStatus(): Promise<Response> {
|
|
47
|
+
try {
|
|
48
|
+
return Response.json(await this.queryBus.execute(new GetCredentialFieldEnvStatusQuery()));
|
|
49
|
+
} catch (error) {
|
|
50
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async getCredentialInstances(): Promise<Response> {
|
|
55
|
+
try {
|
|
56
|
+
return Response.json(await this.queryBus.execute(new ListCredentialInstancesQuery()));
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async getCredentialInstance(request: Request, params: ServerHttpRouteParams): Promise<Response> {
|
|
63
|
+
try {
|
|
64
|
+
const withSecrets = new URL(request.url).searchParams.get("withSecrets") === "1";
|
|
65
|
+
const instance = withSecrets
|
|
66
|
+
? await this.queryBus.execute(new GetCredentialInstanceWithSecretsQuery(params.instanceId!))
|
|
67
|
+
: await this.queryBus.execute(new GetCredentialInstanceQuery(params.instanceId!));
|
|
68
|
+
if (!instance) {
|
|
69
|
+
return Response.json({ error: "Unknown credential instance" }, { status: 404 });
|
|
70
|
+
}
|
|
71
|
+
return Response.json(instance);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async postCredentialInstance(request: Request): Promise<Response> {
|
|
78
|
+
try {
|
|
79
|
+
const body = await HttpRequestJsonBodyReader.readJsonBody<CreateCredentialInstanceRequest>(request);
|
|
80
|
+
return Response.json(await this.commandBus.execute(new CreateCredentialInstanceCommand(body)));
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async putCredentialInstance(request: Request, params: ServerHttpRouteParams): Promise<Response> {
|
|
87
|
+
try {
|
|
88
|
+
const body = await HttpRequestJsonBodyReader.readJsonBody<UpdateCredentialInstanceRequest>(request);
|
|
89
|
+
return Response.json(
|
|
90
|
+
await this.commandBus.execute(new UpdateCredentialInstanceCommand(params.instanceId!, body)),
|
|
91
|
+
);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async deleteCredentialInstance(_: Request, params: ServerHttpRouteParams): Promise<Response> {
|
|
98
|
+
try {
|
|
99
|
+
return Response.json(await this.commandBus.execute(new DeleteCredentialInstanceCommand(params.instanceId!)));
|
|
100
|
+
} catch (error) {
|
|
101
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async putCredentialBinding(request: Request): Promise<Response> {
|
|
106
|
+
try {
|
|
107
|
+
const body = await HttpRequestJsonBodyReader.readJsonBody<UpsertCredentialBindingRequest>(request);
|
|
108
|
+
return Response.json(await this.commandBus.execute(new UpsertCredentialBindingCommand(body)));
|
|
109
|
+
} catch (error) {
|
|
110
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async postCredentialInstanceTest(_: Request, params: ServerHttpRouteParams): Promise<Response> {
|
|
115
|
+
try {
|
|
116
|
+
return Response.json(await this.commandBus.execute(new TestCredentialInstanceCommand(params.instanceId!)));
|
|
117
|
+
} catch (error) {
|
|
118
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async getWorkflowCredentialHealth(_: Request, params: ServerHttpRouteParams): Promise<Response> {
|
|
123
|
+
try {
|
|
124
|
+
return Response.json(await this.queryBus.execute(new GetWorkflowCredentialHealthQuery(params.workflowId!)));
|
|
125
|
+
} catch (error) {
|
|
126
|
+
return ServerHttpErrorResponseFactory.fromUnknown(error);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { inject, injectable } from "@codemation/core";
|
|
2
|
+
import { DevBootstrapSummaryAssembler } from "../../../application/dev/DevBootstrapSummaryAssembler";
|
|
3
|
+
|
|
4
|
+
@injectable()
|
|
5
|
+
export class DevBootstrapSummaryHttpRouteHandler {
|
|
6
|
+
constructor(@inject(DevBootstrapSummaryAssembler) private readonly assembler: DevBootstrapSummaryAssembler) {}
|
|
7
|
+
|
|
8
|
+
getSummary(): Response {
|
|
9
|
+
const payload = this.assembler.assemble();
|
|
10
|
+
if (!payload) {
|
|
11
|
+
return new Response(JSON.stringify({ error: "Runtime summary not ready" }), {
|
|
12
|
+
status: 503,
|
|
13
|
+
headers: { "content-type": "application/json" },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return new Response(JSON.stringify(payload), {
|
|
17
|
+
status: 200,
|
|
18
|
+
headers: { "content-type": "application/json" },
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|