@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,88 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CredentialHealth,
|
|
3
|
+
CredentialInstanceId,
|
|
4
|
+
CredentialMaterialSourceKind,
|
|
5
|
+
CredentialRequirement,
|
|
6
|
+
CredentialSetupStatus,
|
|
7
|
+
CredentialTypeDefinition,
|
|
8
|
+
CredentialTypeId,
|
|
9
|
+
} from "@codemation/core";
|
|
10
|
+
|
|
11
|
+
export type CredentialInstanceDto = Readonly<{
|
|
12
|
+
instanceId: CredentialInstanceId;
|
|
13
|
+
typeId: CredentialTypeId;
|
|
14
|
+
displayName: string;
|
|
15
|
+
sourceKind: CredentialMaterialSourceKind;
|
|
16
|
+
publicConfig: Readonly<Record<string, unknown>>;
|
|
17
|
+
tags: ReadonlyArray<string>;
|
|
18
|
+
setupStatus: CredentialSetupStatus;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
latestHealth?: CredentialHealth;
|
|
22
|
+
oauth2Connection?: CredentialOAuth2ConnectionDto;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
export type CredentialOAuth2ConnectionDto = Readonly<{
|
|
26
|
+
status: "connected" | "disconnected";
|
|
27
|
+
providerId: string;
|
|
28
|
+
connectedEmail?: string;
|
|
29
|
+
connectedAt?: string;
|
|
30
|
+
scopes: ReadonlyArray<string>;
|
|
31
|
+
updatedAt?: string;
|
|
32
|
+
}>;
|
|
33
|
+
|
|
34
|
+
export type CredentialInstanceWithSecretsDto = CredentialInstanceDto &
|
|
35
|
+
Readonly<{
|
|
36
|
+
secretConfig?: Readonly<Record<string, string>>;
|
|
37
|
+
envSecretRefs?: Readonly<Record<string, string>>;
|
|
38
|
+
}>;
|
|
39
|
+
|
|
40
|
+
export type WorkflowCredentialHealthSlotDto = Readonly<{
|
|
41
|
+
workflowId: string;
|
|
42
|
+
nodeId: string;
|
|
43
|
+
nodeName?: string;
|
|
44
|
+
requirement: CredentialRequirement;
|
|
45
|
+
instance?: Pick<CredentialInstanceDto, "instanceId" | "typeId" | "displayName" | "setupStatus">;
|
|
46
|
+
health: Readonly<{
|
|
47
|
+
status: "unbound" | "optional-unbound" | "unknown" | "healthy" | "failing";
|
|
48
|
+
message?: string;
|
|
49
|
+
testedAt?: string;
|
|
50
|
+
}>;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
53
|
+
export type WorkflowCredentialHealthDto = Readonly<{
|
|
54
|
+
workflowId: string;
|
|
55
|
+
slots: ReadonlyArray<WorkflowCredentialHealthSlotDto>;
|
|
56
|
+
}>;
|
|
57
|
+
|
|
58
|
+
export type CreateCredentialInstanceRequest = Readonly<{
|
|
59
|
+
typeId: CredentialTypeId;
|
|
60
|
+
displayName: string;
|
|
61
|
+
sourceKind: CredentialMaterialSourceKind;
|
|
62
|
+
publicConfig?: Readonly<Record<string, unknown>>;
|
|
63
|
+
secretConfig?: Readonly<Record<string, unknown>>;
|
|
64
|
+
envSecretRefs?: Readonly<Record<string, string>>;
|
|
65
|
+
tags?: ReadonlyArray<string>;
|
|
66
|
+
}>;
|
|
67
|
+
|
|
68
|
+
export type UpdateCredentialInstanceRequest = Readonly<{
|
|
69
|
+
displayName?: string;
|
|
70
|
+
publicConfig?: Readonly<Record<string, unknown>>;
|
|
71
|
+
secretConfig?: Readonly<Record<string, unknown>>;
|
|
72
|
+
envSecretRefs?: Readonly<Record<string, string>>;
|
|
73
|
+
tags?: ReadonlyArray<string>;
|
|
74
|
+
setupStatus?: CredentialSetupStatus;
|
|
75
|
+
}>;
|
|
76
|
+
|
|
77
|
+
export type UpsertCredentialBindingRequest = Readonly<{
|
|
78
|
+
workflowId: string;
|
|
79
|
+
nodeId: string;
|
|
80
|
+
slotKey: string;
|
|
81
|
+
instanceId: CredentialInstanceId;
|
|
82
|
+
}>;
|
|
83
|
+
|
|
84
|
+
export class CredentialResponseMapper {
|
|
85
|
+
static toTypeDefinitionList(types: ReadonlyArray<CredentialTypeDefinition>): ReadonlyArray<CredentialTypeDefinition> {
|
|
86
|
+
return [...types];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Items, PersistedMutableRunState, PersistedRunState, RunCurrentState } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
export type CreateRunRequest = Readonly<{
|
|
4
|
+
workflowId?: string;
|
|
5
|
+
items?: Items;
|
|
6
|
+
synthesizeTriggerItems?: boolean;
|
|
7
|
+
currentState?: RunCurrentState;
|
|
8
|
+
startAt?: string;
|
|
9
|
+
stopAt?: string;
|
|
10
|
+
clearFromNodeId?: string;
|
|
11
|
+
mode?: "manual" | "debug";
|
|
12
|
+
sourceRunId?: string;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
export type UpdateRunWorkflowSnapshotRequest = Readonly<{
|
|
16
|
+
workflowSnapshot?: PersistedRunState["workflowSnapshot"];
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export type UpdateRunNodePinRequest = Readonly<{
|
|
20
|
+
items?: Items;
|
|
21
|
+
}>;
|
|
22
|
+
|
|
23
|
+
export type RunNodeRequest = Readonly<{
|
|
24
|
+
items?: Items;
|
|
25
|
+
synthesizeTriggerItems?: boolean;
|
|
26
|
+
mode?: "manual" | "debug";
|
|
27
|
+
}>;
|
|
28
|
+
|
|
29
|
+
export type RunCommandResult = Readonly<{
|
|
30
|
+
runId: string;
|
|
31
|
+
workflowId: string;
|
|
32
|
+
startedAt?: string;
|
|
33
|
+
status: string;
|
|
34
|
+
state: PersistedRunState | null;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export type MutableRunNodeInputState = Readonly<{
|
|
38
|
+
state: PersistedRunState;
|
|
39
|
+
mutableState: PersistedMutableRunState;
|
|
40
|
+
nodeId: string;
|
|
41
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RunCurrentState } from "@codemation/core";
|
|
2
|
+
import type { WorkflowDebuggerOverlayState } from "../../domain/workflows/WorkflowDebuggerOverlayState";
|
|
3
|
+
|
|
4
|
+
export type UpdateWorkflowDebuggerOverlayRequest = Readonly<{
|
|
5
|
+
currentState?: RunCurrentState;
|
|
6
|
+
}>;
|
|
7
|
+
|
|
8
|
+
export type CopyRunToWorkflowDebuggerRequest = Readonly<{
|
|
9
|
+
sourceRunId?: string;
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
export type WorkflowDebuggerOverlayResponse = WorkflowDebuggerOverlayState;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type WorkflowNodeDto = Readonly<{
|
|
2
|
+
id: string;
|
|
3
|
+
kind: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
type: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
parentNodeId?: string;
|
|
9
|
+
/** Short retry policy label for canvas/properties (e.g. fixed / exponential). */
|
|
10
|
+
retryPolicySummary?: string;
|
|
11
|
+
/** Whether this node declares a node-level error handler. */
|
|
12
|
+
hasNodeErrorHandler?: boolean;
|
|
13
|
+
/** When true, downstream nodes may run even when this node outputs zero items. */
|
|
14
|
+
continueWhenEmptyOutput?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
export type WorkflowEdgeDto = Readonly<{
|
|
18
|
+
from: Readonly<{ nodeId: string; output: string }>;
|
|
19
|
+
to: Readonly<{ nodeId: string; input: string }>;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export type WorkflowDto = Readonly<{
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
/** When true, trigger setup runs and webhooks are registered for this workflow. */
|
|
26
|
+
active: boolean;
|
|
27
|
+
nodes: ReadonlyArray<WorkflowNodeDto>;
|
|
28
|
+
edges: ReadonlyArray<WorkflowEdgeDto>;
|
|
29
|
+
/** Workflow-level error hook configured on the definition. */
|
|
30
|
+
hasWorkflowErrorHandler?: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
|
|
33
|
+
export type WorkflowSummary = Readonly<{
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
/** When true, trigger setup runs and webhooks are registered for this workflow. */
|
|
37
|
+
active: boolean;
|
|
38
|
+
/** Path under workflow discovery root: folders + workflow file stem. */
|
|
39
|
+
discoveryPathSegments: readonly string[];
|
|
40
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RunEvent } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
export type WorkflowWebsocketMessage =
|
|
4
|
+
| Readonly<{ kind: "event"; event: RunEvent }>
|
|
5
|
+
| Readonly<{ kind: "workflowChanged"; workflowId: string }>
|
|
6
|
+
| Readonly<{ kind: "devBuildStarted"; workflowId: string; buildVersion?: string }>
|
|
7
|
+
| Readonly<{ kind: "devBuildCompleted"; workflowId: string; buildVersion: string }>
|
|
8
|
+
| Readonly<{ kind: "devBuildFailed"; workflowId: string; message: string }>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type UserAccountStatus = "invited" | "active" | "inactive";
|
|
2
|
+
|
|
3
|
+
export type UserAccountDto = Readonly<{
|
|
4
|
+
id: string;
|
|
5
|
+
email: string;
|
|
6
|
+
status: UserAccountStatus;
|
|
7
|
+
inviteExpiresAt: string | null;
|
|
8
|
+
/** Ways the user can sign in (password + linked OAuth / OIDC / email-link accounts). */
|
|
9
|
+
loginMethods: ReadonlyArray<string>;
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
/** Wire/cache payloads may omit `loginMethods` (older servers or partial JSON). */
|
|
13
|
+
export type UserAccountDtoInput = Readonly<
|
|
14
|
+
Omit<UserAccountDto, "loginMethods"> & { loginMethods?: ReadonlyArray<string> | undefined }
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
export type InviteUserResponseDto = Readonly<{
|
|
18
|
+
user: UserAccountDto;
|
|
19
|
+
inviteUrl: string;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export function withUserAccountLoginMethodsDefaults(input: UserAccountDtoInput): UserAccountDto {
|
|
23
|
+
const loginMethods = input.loginMethods;
|
|
24
|
+
return {
|
|
25
|
+
...input,
|
|
26
|
+
loginMethods: Array.isArray(loginMethods) ? loginMethods : [],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function withInviteUserResponseLoginMethodsDefaults(
|
|
31
|
+
input: Readonly<{ user: UserAccountDtoInput; inviteUrl: string }>,
|
|
32
|
+
): InviteUserResponseDto {
|
|
33
|
+
return {
|
|
34
|
+
inviteUrl: input.inviteUrl,
|
|
35
|
+
user: withUserAccountLoginMethodsDefaults(input.user),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type VerifyUserInviteResponseDto = Readonly<{
|
|
40
|
+
valid: boolean;
|
|
41
|
+
email?: string;
|
|
42
|
+
}>;
|
|
43
|
+
|
|
44
|
+
export type InviteUserRequestDto = Readonly<{
|
|
45
|
+
email: string;
|
|
46
|
+
}>;
|
|
47
|
+
|
|
48
|
+
export type AcceptUserInviteRequestDto = Readonly<{
|
|
49
|
+
token: string;
|
|
50
|
+
password: string;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
53
|
+
export type UpdateUserAccountStatusRequestDto = Readonly<{
|
|
54
|
+
status: UserAccountStatus;
|
|
55
|
+
}>;
|
|
56
|
+
|
|
57
|
+
/** Result of CLI/bootstrap `upsert` for a local password user (distinct from invite-based onboarding). */
|
|
58
|
+
export type UpsertLocalBootstrapUserResultDto = Readonly<{
|
|
59
|
+
outcome: "created" | "updated";
|
|
60
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { injectable } from "@codemation/core";
|
|
2
|
+
import type { BootRuntimeSummary } from "./BootRuntimeSummary.types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Holds the latest {@link BootRuntimeSummary} after {@link CodemationApplication} prepare wiring.
|
|
6
|
+
* Avoids injecting {@link CodemationApplication} into dev diagnostics (circular ESM graph with assembler).
|
|
7
|
+
*/
|
|
8
|
+
@injectable()
|
|
9
|
+
export class BootRuntimeSnapshotHolder {
|
|
10
|
+
private snapshot: BootRuntimeSummary | null = null;
|
|
11
|
+
|
|
12
|
+
set(snapshot: BootRuntimeSummary | null): void {
|
|
13
|
+
this.snapshot = snapshot;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get(): BootRuntimeSummary | null {
|
|
17
|
+
return this.snapshot;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ResolvedDatabasePersistence } from "../../infrastructure/persistence/DatabasePersistenceResolver";
|
|
2
|
+
import type { CodemationEventBusKind, CodemationSchedulerKind } from "../../presentation/config/CodemationConfig";
|
|
3
|
+
|
|
4
|
+
/** Resolved persistence + scheduler wiring captured at host prepare time (dev banner / diagnostics). */
|
|
5
|
+
export type BootRuntimeSummary = Readonly<{
|
|
6
|
+
databasePersistence: ResolvedDatabasePersistence;
|
|
7
|
+
eventBusKind: CodemationEventBusKind;
|
|
8
|
+
queuePrefix: string;
|
|
9
|
+
schedulerKind: CodemationSchedulerKind;
|
|
10
|
+
redisUrl?: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CoreTokens, inject, injectable } from "@codemation/core";
|
|
2
|
+
import type { WorkflowRepository } from "@codemation/core";
|
|
3
|
+
import { BootRuntimeSnapshotHolder } from "./BootRuntimeSnapshotHolder";
|
|
4
|
+
import { LogLevelPolicyFactory } from "../../infrastructure/logging/LogLevelPolicyFactory";
|
|
5
|
+
import { RuntimeWorkflowActivationPolicy } from "../../infrastructure/persistence/RuntimeWorkflowActivationPolicy";
|
|
6
|
+
import type { BootRuntimeSummary } from "./BootRuntimeSummary.types";
|
|
7
|
+
import type { DevBootstrapSummaryJson } from "./DevBootstrapSummaryJson.types";
|
|
8
|
+
|
|
9
|
+
@injectable()
|
|
10
|
+
export class DevBootstrapSummaryAssembler {
|
|
11
|
+
constructor(
|
|
12
|
+
@inject(BootRuntimeSnapshotHolder) private readonly bootRuntimeSnapshot: BootRuntimeSnapshotHolder,
|
|
13
|
+
@inject(LogLevelPolicyFactory) private readonly logLevelPolicyFactory: LogLevelPolicyFactory,
|
|
14
|
+
@inject(RuntimeWorkflowActivationPolicy) private readonly workflowActivationPolicy: RuntimeWorkflowActivationPolicy,
|
|
15
|
+
@inject(CoreTokens.WorkflowRepository) private readonly workflowRepository: WorkflowRepository,
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
assemble(): DevBootstrapSummaryJson | null {
|
|
19
|
+
const summary = this.bootRuntimeSnapshot.get();
|
|
20
|
+
if (!summary) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const envRaw = process.env.CODEMATION_LOG_LEVEL?.trim();
|
|
24
|
+
const min = this.logLevelPolicyFactory.create().resolveMin();
|
|
25
|
+
const logLevel = envRaw && envRaw.length > 0 ? `${min} (CODEMATION_LOG_LEVEL=${envRaw})` : `${min}`;
|
|
26
|
+
const workflows = [...this.workflowRepository.list()].sort((a, b) => a.name.localeCompare(b.name));
|
|
27
|
+
const active = workflows
|
|
28
|
+
.filter((w) => this.workflowActivationPolicy.isActive(w.id))
|
|
29
|
+
.map((w) => ({ id: w.id, name: w.name }));
|
|
30
|
+
return {
|
|
31
|
+
logLevel,
|
|
32
|
+
codemationLogLevelEnv: envRaw && envRaw.length > 0 ? envRaw : undefined,
|
|
33
|
+
databaseLabel: this.formatDatabase(summary),
|
|
34
|
+
schedulerLabel: this.formatScheduler(summary),
|
|
35
|
+
eventBusLabel: this.formatEventBus(summary),
|
|
36
|
+
redisUrlRedacted: this.formatRedis(summary),
|
|
37
|
+
activeWorkflows: active,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private formatDatabase(summary: BootRuntimeSummary): string {
|
|
42
|
+
const p = summary.databasePersistence;
|
|
43
|
+
if (p.kind === "none") {
|
|
44
|
+
return "in-memory (no Prisma persistence)";
|
|
45
|
+
}
|
|
46
|
+
if (p.kind === "pglite") {
|
|
47
|
+
return `PGlite — ${p.dataDir}`;
|
|
48
|
+
}
|
|
49
|
+
return `PostgreSQL — ${this.redactUrlForDisplay(p.databaseUrl)}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private formatScheduler(summary: BootRuntimeSummary): string {
|
|
53
|
+
if (summary.schedulerKind === "local") {
|
|
54
|
+
return "inline (this process)";
|
|
55
|
+
}
|
|
56
|
+
return `BullMQ — queue prefix "${summary.queuePrefix}"`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private formatEventBus(summary: BootRuntimeSummary): string {
|
|
60
|
+
if (summary.eventBusKind === "memory") {
|
|
61
|
+
return "in-memory";
|
|
62
|
+
}
|
|
63
|
+
return "Redis";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private formatRedis(summary: BootRuntimeSummary): string | undefined {
|
|
67
|
+
if (!summary.redisUrl || summary.redisUrl.trim().length === 0) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return this.redactUrlForDisplay(summary.redisUrl);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private redactUrlForDisplay(raw: string): string {
|
|
74
|
+
try {
|
|
75
|
+
const parsed = new URL(raw);
|
|
76
|
+
if (parsed.password) {
|
|
77
|
+
parsed.password = "***";
|
|
78
|
+
}
|
|
79
|
+
return parsed.toString();
|
|
80
|
+
} catch {
|
|
81
|
+
return "(unparseable URL)";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type DevBootstrapSummaryJson = Readonly<{
|
|
2
|
+
logLevel: string;
|
|
3
|
+
codemationLogLevelEnv?: string;
|
|
4
|
+
databaseLabel: string;
|
|
5
|
+
schedulerLabel: string;
|
|
6
|
+
eventBusLabel: string;
|
|
7
|
+
redisUrlRedacted?: string;
|
|
8
|
+
activeWorkflows: ReadonlyArray<Readonly<{ id: string; name: string }>>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Logger {
|
|
2
|
+
info(message: string, exception?: Error): void;
|
|
3
|
+
warn(message: string, exception?: Error): void;
|
|
4
|
+
error(message: string, exception?: Error): void;
|
|
5
|
+
debug(message: string, exception?: Error): void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface LoggerFactory {
|
|
9
|
+
create(scope: string): Logger;
|
|
10
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChatModelConfig,
|
|
3
|
+
NodeDefinition,
|
|
4
|
+
ToolConfig,
|
|
5
|
+
WorkflowActivationPolicy,
|
|
6
|
+
WorkflowDefinition,
|
|
7
|
+
} from "@codemation/core";
|
|
8
|
+
import { AgentConfigInspector, ConnectionNodeIdFactory, CoreTokens, inject, injectable } from "@codemation/core";
|
|
9
|
+
import type { WorkflowDto, WorkflowNodeDto, WorkflowSummary } from "../contracts/WorkflowViewContracts";
|
|
10
|
+
import type { DataMapper } from "./DataMapper";
|
|
11
|
+
import { WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory";
|
|
12
|
+
|
|
13
|
+
@injectable()
|
|
14
|
+
export class WorkflowDefinitionMapper implements DataMapper<WorkflowDefinition, WorkflowDto> {
|
|
15
|
+
constructor(
|
|
16
|
+
@inject(WorkflowPolicyUiPresentationFactory)
|
|
17
|
+
private readonly policyUi: WorkflowPolicyUiPresentationFactory,
|
|
18
|
+
@inject(CoreTokens.WorkflowActivationPolicy)
|
|
19
|
+
private readonly workflowActivationPolicy: WorkflowActivationPolicy,
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
async map(workflow: WorkflowDefinition): Promise<WorkflowDto> {
|
|
23
|
+
return this.mapSync(workflow);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
mapSync(workflow: WorkflowDefinition): WorkflowDto {
|
|
27
|
+
return {
|
|
28
|
+
id: workflow.id,
|
|
29
|
+
name: workflow.name,
|
|
30
|
+
active: this.workflowActivationPolicy.isActive(workflow.id),
|
|
31
|
+
hasWorkflowErrorHandler: this.policyUi.workflowHasErrorHandler(workflow),
|
|
32
|
+
nodes: this.toNodes(workflow),
|
|
33
|
+
edges: this.toEdges(workflow),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
toSummary(workflow: WorkflowDefinition): WorkflowSummary {
|
|
38
|
+
return {
|
|
39
|
+
id: workflow.id,
|
|
40
|
+
name: workflow.name,
|
|
41
|
+
active: this.workflowActivationPolicy.isActive(workflow.id),
|
|
42
|
+
discoveryPathSegments: workflow.discoveryPathSegments ?? [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private buildConnectionChildMeta(
|
|
47
|
+
workflow: WorkflowDefinition,
|
|
48
|
+
): ReadonlyMap<string, Readonly<{ parentNodeId: string; connectionName: string }>> {
|
|
49
|
+
const map = new Map<string, Readonly<{ parentNodeId: string; connectionName: string }>>();
|
|
50
|
+
for (const c of workflow.connections ?? []) {
|
|
51
|
+
for (const childId of c.childNodeIds) {
|
|
52
|
+
map.set(childId, { parentNodeId: c.parentNodeId, connectionName: c.connectionName });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return map;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private agentHasConnectionMetadata(workflow: WorkflowDefinition, agentNodeId: string): boolean {
|
|
59
|
+
return (workflow.connections ?? []).some((c) => c.parentNodeId === agentNodeId);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private toNodes(workflow: WorkflowDefinition): ReadonlyArray<WorkflowNodeDto> {
|
|
63
|
+
const connectionChildMeta = this.buildConnectionChildMeta(workflow);
|
|
64
|
+
const nodes: WorkflowNodeDto[] = [];
|
|
65
|
+
for (const node of workflow.nodes) {
|
|
66
|
+
const conn = connectionChildMeta.get(node.id);
|
|
67
|
+
if (conn) {
|
|
68
|
+
const role = conn.connectionName === "llm" ? "languageModel" : "tool";
|
|
69
|
+
nodes.push({
|
|
70
|
+
id: node.id,
|
|
71
|
+
kind: node.kind,
|
|
72
|
+
name: node.name ?? node.config?.name,
|
|
73
|
+
type: this.nodeTypeName(node),
|
|
74
|
+
role,
|
|
75
|
+
icon: node.config?.icon,
|
|
76
|
+
retryPolicySummary: this.policyUi.nodeRetrySummary(node.config),
|
|
77
|
+
hasNodeErrorHandler: this.policyUi.nodeHasErrorHandler(node.config),
|
|
78
|
+
parentNodeId: conn.parentNodeId,
|
|
79
|
+
});
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
nodes.push({
|
|
83
|
+
id: node.id,
|
|
84
|
+
kind: node.kind,
|
|
85
|
+
name: node.name ?? node.config?.name,
|
|
86
|
+
type: this.nodeTypeName(node),
|
|
87
|
+
role: AgentConfigInspector.isAgentNodeConfig(node.config) ? "agent" : "workflowNode",
|
|
88
|
+
icon: node.config?.icon,
|
|
89
|
+
retryPolicySummary: this.policyUi.nodeRetrySummary(node.config),
|
|
90
|
+
hasNodeErrorHandler: this.policyUi.nodeHasErrorHandler(node.config),
|
|
91
|
+
});
|
|
92
|
+
if (AgentConfigInspector.isAgentNodeConfig(node.config) && !this.agentHasConnectionMetadata(workflow, node.id)) {
|
|
93
|
+
nodes.push(this.createLanguageModelNode(node, node.config.chatModel));
|
|
94
|
+
for (const toolConfig of node.config.tools ?? []) {
|
|
95
|
+
nodes.push(this.createToolNode(node, toolConfig));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return nodes;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private toEdges(workflow: WorkflowDefinition): WorkflowDto["edges"] {
|
|
103
|
+
const edges = [...workflow.edges];
|
|
104
|
+
for (const node of workflow.nodes) {
|
|
105
|
+
if (!AgentConfigInspector.isAgentNodeConfig(node.config)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (this.agentHasConnectionMetadata(workflow, node.id)) {
|
|
109
|
+
for (const c of workflow.connections ?? []) {
|
|
110
|
+
if (c.parentNodeId !== node.id) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
for (const childId of c.childNodeIds) {
|
|
114
|
+
edges.push({
|
|
115
|
+
from: { nodeId: node.id, output: "main" },
|
|
116
|
+
to: { nodeId: childId, input: "in" },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
edges.push({
|
|
123
|
+
from: { nodeId: node.id, output: "main" },
|
|
124
|
+
to: { nodeId: ConnectionNodeIdFactory.languageModelConnectionNodeId(node.id), input: "in" },
|
|
125
|
+
});
|
|
126
|
+
for (const toolConfig of node.config.tools ?? []) {
|
|
127
|
+
edges.push({
|
|
128
|
+
from: { nodeId: node.id, output: "main" },
|
|
129
|
+
to: { nodeId: ConnectionNodeIdFactory.toolConnectionNodeId(node.id, toolConfig.name), input: "in" },
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return edges;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private createLanguageModelNode(node: NodeDefinition, chatModel: ChatModelConfig): WorkflowNodeDto {
|
|
137
|
+
return {
|
|
138
|
+
id: ConnectionNodeIdFactory.languageModelConnectionNodeId(node.id),
|
|
139
|
+
kind: "node",
|
|
140
|
+
name: chatModel.presentation?.label ?? chatModel.name,
|
|
141
|
+
type: chatModel.name,
|
|
142
|
+
role: "languageModel",
|
|
143
|
+
icon: chatModel.presentation?.icon,
|
|
144
|
+
parentNodeId: node.id,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private createToolNode(node: NodeDefinition, toolConfig: ToolConfig): WorkflowNodeDto {
|
|
149
|
+
return {
|
|
150
|
+
id: ConnectionNodeIdFactory.toolConnectionNodeId(node.id, toolConfig.name),
|
|
151
|
+
kind: "node",
|
|
152
|
+
name: toolConfig.presentation?.label ?? toolConfig.name,
|
|
153
|
+
type: toolConfig.name,
|
|
154
|
+
role: "tool",
|
|
155
|
+
icon: toolConfig.presentation?.icon,
|
|
156
|
+
parentNodeId: node.id,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private nodeTypeName(node: NodeDefinition): string {
|
|
161
|
+
const configToken = node.config?.type as Readonly<{ name?: unknown }> | undefined;
|
|
162
|
+
if (typeof configToken?.name === "string" && configToken.name) {
|
|
163
|
+
return configToken.name;
|
|
164
|
+
}
|
|
165
|
+
const nodeToken = node.type as Readonly<{ name?: unknown }> | undefined;
|
|
166
|
+
if (typeof nodeToken?.name === "string" && nodeToken.name) {
|
|
167
|
+
return nodeToken.name;
|
|
168
|
+
}
|
|
169
|
+
return "Node";
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { NodeDefinition, RetryPolicySpec, WorkflowDefinition } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
/** UI-facing policy labels derived from workflow/node definitions (live or hydrated snapshot). */
|
|
4
|
+
export class WorkflowPolicyUiPresentationFactory {
|
|
5
|
+
workflowHasErrorHandler(workflow: WorkflowDefinition): boolean {
|
|
6
|
+
return workflow.workflowErrorHandler !== undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
nodeRetrySummary(config: NodeDefinition["config"]): string | undefined {
|
|
10
|
+
const spec = config.retryPolicy as RetryPolicySpec | undefined;
|
|
11
|
+
if (!spec) return undefined;
|
|
12
|
+
if (spec.kind === "none") return "Retry: off";
|
|
13
|
+
if (spec.kind === "fixed") return `Retry: ${spec.maxAttempts}x @ ${spec.delayMs}ms`;
|
|
14
|
+
if (spec.kind === "exponential") {
|
|
15
|
+
const jitter = spec.jitter ? ", jitter" : "";
|
|
16
|
+
return `Retry: exp ${spec.maxAttempts}x from ${spec.initialDelayMs}ms (x${spec.multiplier}${jitter})`;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
nodeHasErrorHandler(config: NodeDefinition["config"]): boolean {
|
|
22
|
+
return config.nodeErrorHandler !== undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
snapshotNodeRetrySummary(config: unknown): string | undefined {
|
|
26
|
+
const record = this.asRecord(config);
|
|
27
|
+
const spec = record.retryPolicy as RetryPolicySpec | undefined;
|
|
28
|
+
if (!spec || typeof spec !== "object") return undefined;
|
|
29
|
+
return this.nodeRetrySummary({ retryPolicy: spec } as NodeDefinition["config"]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
snapshotNodeHasErrorHandler(config: unknown): boolean {
|
|
33
|
+
return this.asRecord(config).nodeErrorHandler !== undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private asRecord(value: unknown): Readonly<Record<string, unknown>> {
|
|
37
|
+
return value !== null && typeof value === "object" ? (value as Record<string, unknown>) : {};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { GetCredentialInstanceQuery } from "./GetCredentialInstanceQuery";
|
|
2
|
+
export { GetCredentialInstanceQueryHandler } from "./GetCredentialInstanceQueryHandler";
|
|
3
|
+
export { GetCredentialInstanceWithSecretsQuery } from "./GetCredentialInstanceWithSecretsQuery";
|
|
4
|
+
export { GetCredentialInstanceWithSecretsQueryHandler } from "./GetCredentialInstanceWithSecretsQueryHandler";
|
|
5
|
+
export { GetWorkflowCredentialHealthQuery } from "./GetWorkflowCredentialHealthQuery";
|
|
6
|
+
export { GetWorkflowCredentialHealthQueryHandler } from "./GetWorkflowCredentialHealthQueryHandler";
|
|
7
|
+
export { ListCredentialInstancesQuery } from "./ListCredentialInstancesQuery";
|
|
8
|
+
export { ListCredentialInstancesQueryHandler } from "./ListCredentialInstancesQueryHandler";
|
|
9
|
+
export { ListCredentialTypesQuery } from "./ListCredentialTypesQuery";
|
|
10
|
+
export { ListCredentialTypesQueryHandler } from "./ListCredentialTypesQueryHandler";
|
|
11
|
+
export { GetCredentialFieldEnvStatusQuery } from "./GetCredentialFieldEnvStatusQuery";
|
|
12
|
+
export { GetCredentialFieldEnvStatusQueryHandler } from "./GetCredentialFieldEnvStatusQueryHandler";
|