@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,52 @@
|
|
|
1
|
+
import type { CredentialFieldSchema } from "@codemation/core";
|
|
2
|
+
import { inject } from "@codemation/core";
|
|
3
|
+
|
|
4
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
5
|
+
import type { AppConfig } from "../../presentation/config/AppConfig";
|
|
6
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
7
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
8
|
+
import { CredentialTypeRegistryImpl } from "../../domain/credentials/CredentialServices";
|
|
9
|
+
|
|
10
|
+
import { GetCredentialFieldEnvStatusQuery, type CredentialFieldEnvStatusDto } from "./GetCredentialFieldEnvStatusQuery";
|
|
11
|
+
|
|
12
|
+
@HandlesQuery.for(GetCredentialFieldEnvStatusQuery)
|
|
13
|
+
export class GetCredentialFieldEnvStatusQueryHandler extends QueryHandler<
|
|
14
|
+
GetCredentialFieldEnvStatusQuery,
|
|
15
|
+
CredentialFieldEnvStatusDto
|
|
16
|
+
> {
|
|
17
|
+
constructor(
|
|
18
|
+
@inject(CredentialTypeRegistryImpl)
|
|
19
|
+
private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,
|
|
20
|
+
@inject(ApplicationTokens.AppConfig)
|
|
21
|
+
private readonly appConfig: AppConfig,
|
|
22
|
+
) {
|
|
23
|
+
super();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async execute(): Promise<CredentialFieldEnvStatusDto> {
|
|
27
|
+
const names = new Set<string>();
|
|
28
|
+
for (const type of this.credentialTypeRegistry.listTypes()) {
|
|
29
|
+
for (const n of this.collectEnvVarNames(type.publicFields)) {
|
|
30
|
+
names.add(n);
|
|
31
|
+
}
|
|
32
|
+
for (const n of this.collectEnvVarNames(type.secretFields)) {
|
|
33
|
+
names.add(n);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const out: Record<string, boolean> = {};
|
|
37
|
+
for (const name of names) {
|
|
38
|
+
const v = this.appConfig.env[name];
|
|
39
|
+
out[name] = typeof v === "string" && v.length > 0;
|
|
40
|
+
}
|
|
41
|
+
return Object.freeze(out);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private collectEnvVarNames(fields: ReadonlyArray<CredentialFieldSchema> | undefined): ReadonlyArray<string> {
|
|
45
|
+
if (!fields) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return fields
|
|
49
|
+
.map((f) => f.envVarName)
|
|
50
|
+
.filter((name): name is string => typeof name === "string" && name.trim().length > 0);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CredentialInstanceDto } from "../contracts/CredentialContractsRegistry";
|
|
2
|
+
|
|
3
|
+
import { Query } from "../bus/Query";
|
|
4
|
+
|
|
5
|
+
export class GetCredentialInstanceQuery extends Query<CredentialInstanceDto | undefined> {
|
|
6
|
+
constructor(public readonly instanceId: string) {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import type { CredentialInstanceDto } from "../contracts/CredentialContractsRegistry";
|
|
4
|
+
|
|
5
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
8
|
+
|
|
9
|
+
import { CredentialInstanceService } from "../../domain/credentials/CredentialServices";
|
|
10
|
+
import { GetCredentialInstanceQuery } from "./GetCredentialInstanceQuery";
|
|
11
|
+
|
|
12
|
+
@HandlesQuery.for(GetCredentialInstanceQuery)
|
|
13
|
+
export class GetCredentialInstanceQueryHandler extends QueryHandler<
|
|
14
|
+
GetCredentialInstanceQuery,
|
|
15
|
+
CredentialInstanceDto | undefined
|
|
16
|
+
> {
|
|
17
|
+
constructor(
|
|
18
|
+
@inject(CredentialInstanceService)
|
|
19
|
+
private readonly credentialInstanceService: CredentialInstanceService,
|
|
20
|
+
) {
|
|
21
|
+
super();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async execute(query: GetCredentialInstanceQuery): Promise<CredentialInstanceDto | undefined> {
|
|
25
|
+
return await this.credentialInstanceService.getInstance(query.instanceId);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CredentialInstanceWithSecretsDto } from "../contracts/CredentialContractsRegistry";
|
|
2
|
+
|
|
3
|
+
import { Query } from "../bus/Query";
|
|
4
|
+
|
|
5
|
+
export class GetCredentialInstanceWithSecretsQuery extends Query<CredentialInstanceWithSecretsDto | undefined> {
|
|
6
|
+
constructor(public readonly instanceId: string) {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import type { CredentialInstanceWithSecretsDto } from "../contracts/CredentialContractsRegistry";
|
|
4
|
+
|
|
5
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
8
|
+
|
|
9
|
+
import { CredentialInstanceService } from "../../domain/credentials/CredentialServices";
|
|
10
|
+
import { GetCredentialInstanceWithSecretsQuery } from "./GetCredentialInstanceWithSecretsQuery";
|
|
11
|
+
|
|
12
|
+
@HandlesQuery.for(GetCredentialInstanceWithSecretsQuery)
|
|
13
|
+
export class GetCredentialInstanceWithSecretsQueryHandler extends QueryHandler<
|
|
14
|
+
GetCredentialInstanceWithSecretsQuery,
|
|
15
|
+
CredentialInstanceWithSecretsDto | undefined
|
|
16
|
+
> {
|
|
17
|
+
constructor(
|
|
18
|
+
@inject(CredentialInstanceService)
|
|
19
|
+
private readonly credentialInstanceService: CredentialInstanceService,
|
|
20
|
+
) {
|
|
21
|
+
super();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async execute(query: GetCredentialInstanceWithSecretsQuery): Promise<CredentialInstanceWithSecretsDto | undefined> {
|
|
25
|
+
return await this.credentialInstanceService.getInstanceWithSecrets(query.instanceId);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BinaryAttachment } from "@codemation/core";
|
|
2
|
+
import { Query } from "../bus/Query";
|
|
3
|
+
|
|
4
|
+
export class GetRunBinaryAttachmentQuery extends Query<BinaryAttachment | undefined> {
|
|
5
|
+
constructor(
|
|
6
|
+
public readonly runId: string,
|
|
7
|
+
public readonly binaryId: string,
|
|
8
|
+
) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BinaryAttachment } from "@codemation/core";
|
|
2
|
+
import { inject } from "@codemation/core";
|
|
3
|
+
import { RunBinaryAttachmentLookupService } from "../binary/RunBinaryAttachmentLookupService";
|
|
4
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
5
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
6
|
+
import { GetRunBinaryAttachmentQuery } from "./GetRunBinaryAttachmentQuery";
|
|
7
|
+
|
|
8
|
+
@HandlesQuery.for(GetRunBinaryAttachmentQuery)
|
|
9
|
+
export class GetRunBinaryAttachmentQueryHandler extends QueryHandler<
|
|
10
|
+
GetRunBinaryAttachmentQuery,
|
|
11
|
+
BinaryAttachment | undefined
|
|
12
|
+
> {
|
|
13
|
+
constructor(
|
|
14
|
+
@inject(RunBinaryAttachmentLookupService)
|
|
15
|
+
private readonly lookupService: RunBinaryAttachmentLookupService,
|
|
16
|
+
) {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async execute(query: GetRunBinaryAttachmentQuery): Promise<BinaryAttachment | undefined> {
|
|
21
|
+
return this.lookupService.findForRun(query.runId, query.binaryId);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PersistedRunState } from "@codemation/core";
|
|
2
|
+
import { inject } from "@codemation/core";
|
|
3
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
4
|
+
import type { WorkflowRunRepository } from "../../domain/runs/WorkflowRunRepository";
|
|
5
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
6
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
7
|
+
import { GetRunStateQuery } from "./GetRunStateQuery";
|
|
8
|
+
|
|
9
|
+
@HandlesQuery.for(GetRunStateQuery)
|
|
10
|
+
export class GetRunStateQueryHandler extends QueryHandler<GetRunStateQuery, PersistedRunState | undefined> {
|
|
11
|
+
constructor(
|
|
12
|
+
@inject(ApplicationTokens.WorkflowRunRepository)
|
|
13
|
+
private readonly workflowRunRepository: WorkflowRunRepository,
|
|
14
|
+
) {
|
|
15
|
+
super();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async execute(query: GetRunStateQuery): Promise<PersistedRunState | undefined> {
|
|
19
|
+
return await this.workflowRunRepository.load(query.runId);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WorkflowCredentialHealthDto } from "../contracts/CredentialContractsRegistry";
|
|
2
|
+
|
|
3
|
+
import { Query } from "../bus/Query";
|
|
4
|
+
|
|
5
|
+
export class GetWorkflowCredentialHealthQuery extends Query<WorkflowCredentialHealthDto> {
|
|
6
|
+
constructor(public readonly workflowId: string) {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import type { WorkflowCredentialHealthDto } from "../contracts/CredentialContractsRegistry";
|
|
4
|
+
|
|
5
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
8
|
+
|
|
9
|
+
import { CredentialBindingService } from "../../domain/credentials/CredentialServices";
|
|
10
|
+
import { GetWorkflowCredentialHealthQuery } from "./GetWorkflowCredentialHealthQuery";
|
|
11
|
+
|
|
12
|
+
@HandlesQuery.for(GetWorkflowCredentialHealthQuery)
|
|
13
|
+
export class GetWorkflowCredentialHealthQueryHandler extends QueryHandler<
|
|
14
|
+
GetWorkflowCredentialHealthQuery,
|
|
15
|
+
WorkflowCredentialHealthDto
|
|
16
|
+
> {
|
|
17
|
+
constructor(
|
|
18
|
+
@inject(CredentialBindingService)
|
|
19
|
+
private readonly credentialBindingService: CredentialBindingService,
|
|
20
|
+
) {
|
|
21
|
+
super();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async execute(query: GetWorkflowCredentialHealthQuery): Promise<WorkflowCredentialHealthDto> {
|
|
25
|
+
return await this.credentialBindingService.listWorkflowHealth(query.workflowId);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorkflowDebuggerOverlayState } from "../../domain/workflows/WorkflowDebuggerOverlayState";
|
|
2
|
+
import { Query } from "../bus/Query";
|
|
3
|
+
|
|
4
|
+
export class GetWorkflowDebuggerOverlayQuery extends Query<WorkflowDebuggerOverlayState> {
|
|
5
|
+
constructor(public readonly workflowId: string) {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
3
|
+
import type { WorkflowDebuggerOverlayRepository } from "../../domain/workflows/WorkflowDebuggerOverlayRepository";
|
|
4
|
+
import type { WorkflowDebuggerOverlayState } from "../../domain/workflows/WorkflowDebuggerOverlayState";
|
|
5
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
6
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
7
|
+
import { WorkflowDebuggerOverlayStateFactory } from "../workflows/WorkflowDebuggerOverlayStateFactory";
|
|
8
|
+
import { GetWorkflowDebuggerOverlayQuery } from "./GetWorkflowDebuggerOverlayQuery";
|
|
9
|
+
|
|
10
|
+
@HandlesQuery.for(GetWorkflowDebuggerOverlayQuery)
|
|
11
|
+
export class GetWorkflowDebuggerOverlayQueryHandler extends QueryHandler<
|
|
12
|
+
GetWorkflowDebuggerOverlayQuery,
|
|
13
|
+
WorkflowDebuggerOverlayState
|
|
14
|
+
> {
|
|
15
|
+
constructor(
|
|
16
|
+
@inject(ApplicationTokens.WorkflowDebuggerOverlayRepository)
|
|
17
|
+
private readonly workflowDebuggerOverlayRepository: WorkflowDebuggerOverlayRepository,
|
|
18
|
+
) {
|
|
19
|
+
super();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async execute(query: GetWorkflowDebuggerOverlayQuery): Promise<WorkflowDebuggerOverlayState> {
|
|
23
|
+
return (
|
|
24
|
+
(await this.workflowDebuggerOverlayRepository.load(query.workflowId)) ??
|
|
25
|
+
WorkflowDebuggerOverlayStateFactory.createEmpty(query.workflowId)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { WorkflowDefinition } from "@codemation/core";
|
|
2
|
+
import { inject } from "@codemation/core";
|
|
3
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
4
|
+
import type { WorkflowDefinitionRepository } from "../../domain/workflows/WorkflowDefinitionRepository";
|
|
5
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
6
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
7
|
+
import { GetWorkflowDetailQuery } from "./GetWorkflowDetailQuery";
|
|
8
|
+
|
|
9
|
+
@HandlesQuery.for(GetWorkflowDetailQuery)
|
|
10
|
+
export class GetWorkflowDetailQueryHandler extends QueryHandler<
|
|
11
|
+
GetWorkflowDetailQuery,
|
|
12
|
+
WorkflowDefinition | undefined
|
|
13
|
+
> {
|
|
14
|
+
constructor(
|
|
15
|
+
@inject(ApplicationTokens.WorkflowDefinitionRepository)
|
|
16
|
+
private readonly workflowDefinitionRepository: WorkflowDefinitionRepository,
|
|
17
|
+
) {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async execute(query: GetWorkflowDetailQuery): Promise<WorkflowDefinition | undefined> {
|
|
22
|
+
return await this.workflowDefinitionRepository.getDefinition(query.workflowId);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BinaryAttachment } from "@codemation/core";
|
|
2
|
+
import { Query } from "../bus/Query";
|
|
3
|
+
|
|
4
|
+
export class GetWorkflowOverlayBinaryAttachmentQuery extends Query<BinaryAttachment | undefined> {
|
|
5
|
+
constructor(
|
|
6
|
+
public readonly workflowId: string,
|
|
7
|
+
public readonly binaryId: string,
|
|
8
|
+
) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BinaryAttachment } from "@codemation/core";
|
|
2
|
+
import { inject } from "@codemation/core";
|
|
3
|
+
import { RunBinaryAttachmentLookupService } from "../binary/RunBinaryAttachmentLookupService";
|
|
4
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
5
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
6
|
+
import { GetWorkflowOverlayBinaryAttachmentQuery } from "./GetWorkflowOverlayBinaryAttachmentQuery";
|
|
7
|
+
|
|
8
|
+
@HandlesQuery.for(GetWorkflowOverlayBinaryAttachmentQuery)
|
|
9
|
+
export class GetWorkflowOverlayBinaryAttachmentQueryHandler extends QueryHandler<
|
|
10
|
+
GetWorkflowOverlayBinaryAttachmentQuery,
|
|
11
|
+
BinaryAttachment | undefined
|
|
12
|
+
> {
|
|
13
|
+
constructor(
|
|
14
|
+
@inject(RunBinaryAttachmentLookupService)
|
|
15
|
+
private readonly lookupService: RunBinaryAttachmentLookupService,
|
|
16
|
+
) {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async execute(query: GetWorkflowOverlayBinaryAttachmentQuery): Promise<BinaryAttachment | undefined> {
|
|
21
|
+
return this.lookupService.findForWorkflowOverlay(query.workflowId, query.binaryId);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WorkflowDefinition, WorkflowRepository } from "@codemation/core";
|
|
2
|
+
import { CoreTokens, inject } from "@codemation/core";
|
|
3
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
4
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
5
|
+
import { GetWorkflowSummariesQuery } from "./GetWorkflowSummariesQuery";
|
|
6
|
+
|
|
7
|
+
@HandlesQuery.for(GetWorkflowSummariesQuery)
|
|
8
|
+
export class GetWorkflowSummariesQueryHandler extends QueryHandler<
|
|
9
|
+
GetWorkflowSummariesQuery,
|
|
10
|
+
ReadonlyArray<WorkflowDefinition>
|
|
11
|
+
> {
|
|
12
|
+
constructor(
|
|
13
|
+
@inject(CoreTokens.WorkflowRepository)
|
|
14
|
+
private readonly workflowRepository: WorkflowRepository,
|
|
15
|
+
) {
|
|
16
|
+
super();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async execute(query: GetWorkflowSummariesQuery): Promise<ReadonlyArray<WorkflowDefinition>> {
|
|
20
|
+
void query;
|
|
21
|
+
return [...this.workflowRepository.list()];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import type { CredentialInstanceDto } from "../contracts/CredentialContractsRegistry";
|
|
4
|
+
|
|
5
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
8
|
+
|
|
9
|
+
import { CredentialInstanceService } from "../../domain/credentials/CredentialServices";
|
|
10
|
+
import { ListCredentialInstancesQuery } from "./ListCredentialInstancesQuery";
|
|
11
|
+
|
|
12
|
+
@HandlesQuery.for(ListCredentialInstancesQuery)
|
|
13
|
+
export class ListCredentialInstancesQueryHandler extends QueryHandler<
|
|
14
|
+
ListCredentialInstancesQuery,
|
|
15
|
+
ReadonlyArray<CredentialInstanceDto>
|
|
16
|
+
> {
|
|
17
|
+
constructor(
|
|
18
|
+
@inject(CredentialInstanceService)
|
|
19
|
+
private readonly credentialInstanceService: CredentialInstanceService,
|
|
20
|
+
) {
|
|
21
|
+
super();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async execute(): Promise<ReadonlyArray<CredentialInstanceDto>> {
|
|
25
|
+
return await this.credentialInstanceService.listInstances();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CredentialTypeDefinition } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import { inject } from "@codemation/core";
|
|
4
|
+
|
|
5
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
8
|
+
|
|
9
|
+
import { CredentialTypeRegistryImpl } from "../../domain/credentials/CredentialTypeRegistryImpl";
|
|
10
|
+
|
|
11
|
+
import { ListCredentialTypesQuery } from "./ListCredentialTypesQuery";
|
|
12
|
+
|
|
13
|
+
@HandlesQuery.for(ListCredentialTypesQuery)
|
|
14
|
+
export class ListCredentialTypesQueryHandler extends QueryHandler<
|
|
15
|
+
ListCredentialTypesQuery,
|
|
16
|
+
ReadonlyArray<CredentialTypeDefinition>
|
|
17
|
+
> {
|
|
18
|
+
constructor(
|
|
19
|
+
@inject(CredentialTypeRegistryImpl)
|
|
20
|
+
private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,
|
|
21
|
+
) {
|
|
22
|
+
super();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async execute(): Promise<ReadonlyArray<CredentialTypeDefinition>> {
|
|
26
|
+
return this.credentialTypeRegistry.listTypes();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import type { UserAccountDto } from "../contracts/userDirectoryContracts.types";
|
|
4
|
+
|
|
5
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
8
|
+
|
|
9
|
+
import { UserAccountService } from "../../domain/users/UserAccountServiceRegistry";
|
|
10
|
+
|
|
11
|
+
import { ListUserAccountsQuery } from "./ListUserAccountsQuery";
|
|
12
|
+
|
|
13
|
+
@HandlesQuery.for(ListUserAccountsQuery)
|
|
14
|
+
export class ListUserAccountsQueryHandler extends QueryHandler<ListUserAccountsQuery, ReadonlyArray<UserAccountDto>> {
|
|
15
|
+
constructor(@inject(UserAccountService) private readonly userAccounts: UserAccountService) {
|
|
16
|
+
super();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async execute(_query: ListUserAccountsQuery): Promise<ReadonlyArray<UserAccountDto>> {
|
|
20
|
+
return await this.userAccounts.listUsers();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RunSummary } from "@codemation/core";
|
|
2
|
+
import { inject } from "@codemation/core";
|
|
3
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
4
|
+
import type { WorkflowRunRepository } from "../../domain/runs/WorkflowRunRepository";
|
|
5
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
6
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
7
|
+
import { ListWorkflowRunsQuery } from "./ListWorkflowRunsQuery";
|
|
8
|
+
|
|
9
|
+
@HandlesQuery.for(ListWorkflowRunsQuery)
|
|
10
|
+
export class ListWorkflowRunsQueryHandler extends QueryHandler<ListWorkflowRunsQuery, ReadonlyArray<RunSummary>> {
|
|
11
|
+
constructor(
|
|
12
|
+
@inject(ApplicationTokens.WorkflowRunRepository)
|
|
13
|
+
private readonly workflowRunRepository: WorkflowRunRepository,
|
|
14
|
+
) {
|
|
15
|
+
super();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async execute(query: ListWorkflowRunsQuery): Promise<ReadonlyArray<RunSummary>> {
|
|
19
|
+
return await this.workflowRunRepository.listRuns({ workflowId: query.workflowId, limit: 50 });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ListUserAccountsQuery } from "./ListUserAccountsQuery";
|
|
2
|
+
export { ListUserAccountsQueryHandler } from "./ListUserAccountsQueryHandler";
|
|
3
|
+
export { VerifyUserInviteQuery } from "./VerifyUserInviteQuery";
|
|
4
|
+
export { VerifyUserInviteQueryHandler } from "./VerifyUserInviteQueryHandler";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { VerifyUserInviteResponseDto } from "../contracts/userDirectoryContracts.types";
|
|
2
|
+
|
|
3
|
+
import { Query } from "../bus/Query";
|
|
4
|
+
|
|
5
|
+
export class VerifyUserInviteQuery extends Query<VerifyUserInviteResponseDto> {
|
|
6
|
+
constructor(public readonly token: string) {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import type { VerifyUserInviteResponseDto } from "../contracts/userDirectoryContracts.types";
|
|
4
|
+
|
|
5
|
+
import { QueryHandler } from "../bus/QueryHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesQuery } from "../../infrastructure/di/HandlesQueryRegistry";
|
|
8
|
+
|
|
9
|
+
import { UserAccountService } from "../../domain/users/UserAccountServiceRegistry";
|
|
10
|
+
import { VerifyUserInviteQuery } from "./VerifyUserInviteQuery";
|
|
11
|
+
|
|
12
|
+
@HandlesQuery.for(VerifyUserInviteQuery)
|
|
13
|
+
export class VerifyUserInviteQueryHandler extends QueryHandler<VerifyUserInviteQuery, VerifyUserInviteResponseDto> {
|
|
14
|
+
constructor(@inject(UserAccountService) private readonly userAccounts: UserAccountService) {
|
|
15
|
+
super();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async execute(query: VerifyUserInviteQuery): Promise<VerifyUserInviteResponseDto> {
|
|
19
|
+
return await this.userAccounts.verifyInviteToken(query.token);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { BinaryStorage, Clock, RunId, WorkflowId } from "@codemation/core";
|
|
2
|
+
import { CoreTokens, RunFinishedAtFactory } from "@codemation/core";
|
|
3
|
+
import { inject, injectable } from "@codemation/core";
|
|
4
|
+
import type { Logger } from "../logging/Logger";
|
|
5
|
+
import { RunStateBinaryStorageKeysCollector } from "../binary/RunStateBinaryStorageKeysCollector";
|
|
6
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
7
|
+
import type { AppConfig } from "../../presentation/config/AppConfig";
|
|
8
|
+
import type { WorkflowRunRepository } from "../../domain/runs/WorkflowRunRepository";
|
|
9
|
+
import { ServerLoggerFactory } from "../../infrastructure/logging/ServerLoggerFactory";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Periodically deletes terminal workflow runs whose age exceeds the effective retention
|
|
13
|
+
* (`policySnapshot.retentionSeconds` or `CODEMATION_RUN_RETENTION_DEFAULT_SECONDS`),
|
|
14
|
+
* and removes binary blobs referenced from run state via {@link BinaryStorage}.
|
|
15
|
+
*/
|
|
16
|
+
@injectable()
|
|
17
|
+
export class WorkflowRunRetentionPruneScheduler {
|
|
18
|
+
private timer: ReturnType<typeof setInterval> | undefined;
|
|
19
|
+
private readonly logger: Logger;
|
|
20
|
+
private readonly binaryKeysCollector = new RunStateBinaryStorageKeysCollector();
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
@inject(ApplicationTokens.Clock) private readonly clock: Clock,
|
|
24
|
+
@inject(ApplicationTokens.WorkflowRunRepository) private readonly runs: WorkflowRunRepository,
|
|
25
|
+
@inject(CoreTokens.BinaryStorage) private readonly binaryStorage: BinaryStorage,
|
|
26
|
+
@inject(ApplicationTokens.AppConfig) private readonly appConfig: AppConfig,
|
|
27
|
+
@inject(ServerLoggerFactory) loggerFactory: ServerLoggerFactory,
|
|
28
|
+
) {
|
|
29
|
+
this.logger = loggerFactory.create("codemation.runRetentionPrune");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
start(): void {
|
|
33
|
+
if (this.appConfig.env.CODEMATION_RUN_PRUNE_ENABLED === "false") {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (this.timer) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const intervalMs = Number(this.appConfig.env.CODEMATION_RUN_PRUNE_INTERVAL_MS ?? 60_000);
|
|
40
|
+
this.timer = setInterval(() => {
|
|
41
|
+
void this.runOnce().catch((error: unknown) => {
|
|
42
|
+
this.logger.warn(`Run retention prune tick failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
43
|
+
});
|
|
44
|
+
}, intervalMs);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
stop(): void {
|
|
48
|
+
if (this.timer) {
|
|
49
|
+
clearInterval(this.timer);
|
|
50
|
+
this.timer = undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Exposed for tests; production path is the interval started by {@link start}. */
|
|
55
|
+
async runOnce(): Promise<void> {
|
|
56
|
+
this.logger.debug("Run retention prune: starting check");
|
|
57
|
+
|
|
58
|
+
const defaultRetentionSec = Number(this.appConfig.env.CODEMATION_RUN_RETENTION_DEFAULT_SECONDS ?? 86_400);
|
|
59
|
+
const summaries = await this.runs.listRuns({ limit: 500 });
|
|
60
|
+
const nowMs = this.clock.now().getTime();
|
|
61
|
+
|
|
62
|
+
let foundCount = 0;
|
|
63
|
+
let prunedCount = 0;
|
|
64
|
+
for (const s of summaries) {
|
|
65
|
+
if (s.status !== "completed" && s.status !== "failed") {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const state = await this.runs.load(s.runId);
|
|
69
|
+
if (!state) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const retentionSec = state.policySnapshot?.retentionSeconds ?? defaultRetentionSec;
|
|
73
|
+
const finishedAt = RunFinishedAtFactory.resolveIso(state) ?? s.finishedAt;
|
|
74
|
+
if (!finishedAt) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const ageMs = nowMs - Date.parse(finishedAt);
|
|
78
|
+
if (ageMs <= retentionSec * 1000) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const runId = s.runId as RunId;
|
|
83
|
+
const workflowId = s.workflowId as WorkflowId;
|
|
84
|
+
foundCount += 1;
|
|
85
|
+
|
|
86
|
+
const storageKeys = this.binaryKeysCollector.collectFromRunState(state);
|
|
87
|
+
for (const key of storageKeys) {
|
|
88
|
+
await this.binaryStorage.delete(key);
|
|
89
|
+
}
|
|
90
|
+
await this.runs.deleteRun(runId);
|
|
91
|
+
prunedCount += 1;
|
|
92
|
+
this.logger.debug(`Run retention prune: pruned run ${runId} for workflow ${workflowId}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
this.logger.info(`Run retention prune: found ${foundCount} run(s) to prune`);
|
|
96
|
+
this.logger.info(`Run retention prune: pruned ${prunedCount} run(s)`);
|
|
97
|
+
}
|
|
98
|
+
}
|