@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,50 @@
|
|
|
1
|
+
import { ItemsInputNormalizer, inject, type PersistedRunState } from "@codemation/core";
|
|
2
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
3
|
+
import type { WorkflowRunRepository } from "../../domain/runs/WorkflowRunRepository";
|
|
4
|
+
import { HandlesCommand } from "../../infrastructure/di/HandlesCommandRegistry";
|
|
5
|
+
import { ApplicationRequestError } from "../ApplicationRequestError";
|
|
6
|
+
import { CommandHandler } from "../bus/CommandHandler";
|
|
7
|
+
import { SetPinnedNodeInputCommand } from "./SetPinnedNodeInputCommand";
|
|
8
|
+
|
|
9
|
+
@HandlesCommand.forCommand(SetPinnedNodeInputCommand)
|
|
10
|
+
export class SetPinnedNodeInputCommandHandler extends CommandHandler<SetPinnedNodeInputCommand, PersistedRunState> {
|
|
11
|
+
constructor(
|
|
12
|
+
@inject(ApplicationTokens.WorkflowRunRepository)
|
|
13
|
+
private readonly workflowRunRepository: WorkflowRunRepository,
|
|
14
|
+
@inject(ItemsInputNormalizer)
|
|
15
|
+
private readonly itemsInputNormalizer: ItemsInputNormalizer,
|
|
16
|
+
) {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async execute(command: SetPinnedNodeInputCommand): Promise<PersistedRunState> {
|
|
21
|
+
const state = await this.workflowRunRepository.load(command.runId);
|
|
22
|
+
if (!state) {
|
|
23
|
+
throw new ApplicationRequestError(404, "Unknown runId");
|
|
24
|
+
}
|
|
25
|
+
if (!state.executionOptions?.isMutable) {
|
|
26
|
+
throw new ApplicationRequestError(403, `Run ${state.runId} is immutable`);
|
|
27
|
+
}
|
|
28
|
+
const decodedNodeId = decodeURIComponent(command.nodeId);
|
|
29
|
+
const pinnedItems =
|
|
30
|
+
command.body.items == null ? undefined : this.itemsInputNormalizer.normalize(command.body.items);
|
|
31
|
+
const nextNodesById = {
|
|
32
|
+
...(state.mutableState?.nodesById ?? {}),
|
|
33
|
+
[decodedNodeId]: {
|
|
34
|
+
...(state.mutableState?.nodesById?.[decodedNodeId] ?? {}),
|
|
35
|
+
pinnedOutputsByPort: pinnedItems ? { main: pinnedItems } : undefined,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
await this.workflowRunRepository.save({
|
|
39
|
+
...state,
|
|
40
|
+
mutableState: {
|
|
41
|
+
nodesById: nextNodesById,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const updated = await this.workflowRunRepository.load(state.runId);
|
|
45
|
+
if (!updated) {
|
|
46
|
+
throw new ApplicationRequestError(404, "Unknown runId");
|
|
47
|
+
}
|
|
48
|
+
return updated;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
import { Engine } from "@codemation/core/bootstrap";
|
|
3
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
4
|
+
import { WorkflowActivationPreflight } from "../../domain/workflows/WorkflowActivationPreflight";
|
|
5
|
+
import type { WorkflowActivationRepository } from "../../domain/workflows/WorkflowActivationRepository";
|
|
6
|
+
import { RuntimeWorkflowActivationPolicy } from "../../infrastructure/persistence/RuntimeWorkflowActivationPolicy";
|
|
7
|
+
import { HandlesCommand } from "../../infrastructure/di/HandlesCommandRegistry";
|
|
8
|
+
import { CommandHandler } from "../bus/CommandHandler";
|
|
9
|
+
import { SetWorkflowActivationCommand } from "./SetWorkflowActivationCommand";
|
|
10
|
+
|
|
11
|
+
@HandlesCommand.forCommand(SetWorkflowActivationCommand)
|
|
12
|
+
export class SetWorkflowActivationCommandHandler extends CommandHandler<
|
|
13
|
+
SetWorkflowActivationCommand,
|
|
14
|
+
Readonly<{ active: boolean }>
|
|
15
|
+
> {
|
|
16
|
+
constructor(
|
|
17
|
+
@inject(ApplicationTokens.WorkflowActivationRepository)
|
|
18
|
+
private readonly workflowActivationRepository: WorkflowActivationRepository,
|
|
19
|
+
@inject(RuntimeWorkflowActivationPolicy)
|
|
20
|
+
private readonly workflowActivationPolicy: RuntimeWorkflowActivationPolicy,
|
|
21
|
+
@inject(Engine)
|
|
22
|
+
private readonly engine: Engine,
|
|
23
|
+
@inject(WorkflowActivationPreflight)
|
|
24
|
+
private readonly workflowActivationPreflight: WorkflowActivationPreflight,
|
|
25
|
+
) {
|
|
26
|
+
super();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async execute(command: SetWorkflowActivationCommand): Promise<Readonly<{ active: boolean }>> {
|
|
30
|
+
const workflowId = decodeURIComponent(command.workflowId);
|
|
31
|
+
if (command.active) {
|
|
32
|
+
await this.workflowActivationPreflight.assertCanActivate(command.workflowId);
|
|
33
|
+
}
|
|
34
|
+
await this.workflowActivationRepository.upsert(workflowId, command.active);
|
|
35
|
+
this.workflowActivationPolicy.set(workflowId, command.active);
|
|
36
|
+
await this.engine.syncWorkflowTriggersForActivation(workflowId);
|
|
37
|
+
return { active: command.active };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from "../bus/Command";
|
|
2
|
+
import type { CreateRunRequest, RunCommandResult } from "../contracts/RunContracts";
|
|
3
|
+
|
|
4
|
+
export class StartWorkflowRunCommand extends Command<RunCommandResult> {
|
|
5
|
+
constructor(public readonly body: CreateRunRequest) {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Items,
|
|
3
|
+
NodeId,
|
|
4
|
+
PersistedMutableRunState,
|
|
5
|
+
PersistedRunState,
|
|
6
|
+
RunCurrentState,
|
|
7
|
+
RunStopCondition,
|
|
8
|
+
WorkflowDefinition,
|
|
9
|
+
} from "@codemation/core";
|
|
10
|
+
import { ItemsInputNormalizer, inject } from "@codemation/core";
|
|
11
|
+
import { RunIntentService } from "@codemation/core/bootstrap";
|
|
12
|
+
import { Engine } from "@codemation/core/bootstrap";
|
|
13
|
+
import type { Logger, LoggerFactory } from "../logging/Logger";
|
|
14
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
15
|
+
import type { WorkflowRunRepository } from "../../domain/runs/WorkflowRunRepository";
|
|
16
|
+
import type { WorkflowDebuggerOverlayRepository } from "../../domain/workflows/WorkflowDebuggerOverlayRepository";
|
|
17
|
+
import type { WorkflowDefinitionRepository } from "../../domain/workflows/WorkflowDefinitionRepository";
|
|
18
|
+
import { HandlesCommand } from "../../infrastructure/di/HandlesCommandRegistry";
|
|
19
|
+
import { ApplicationRequestError } from "../ApplicationRequestError";
|
|
20
|
+
import { CommandHandler } from "../bus/CommandHandler";
|
|
21
|
+
import type { CreateRunRequest, RunCommandResult } from "../contracts/RunContracts";
|
|
22
|
+
import { WorkflowDebuggerOverlayStateFactory } from "../workflows/WorkflowDebuggerOverlayStateFactory";
|
|
23
|
+
import { StartWorkflowRunCommand } from "./StartWorkflowRunCommand";
|
|
24
|
+
|
|
25
|
+
@HandlesCommand.forCommand(StartWorkflowRunCommand)
|
|
26
|
+
export class StartWorkflowRunCommandHandler extends CommandHandler<StartWorkflowRunCommand, RunCommandResult> {
|
|
27
|
+
private readonly routesLog: Logger;
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
@inject(Engine)
|
|
31
|
+
private readonly engine: Engine,
|
|
32
|
+
@inject(ItemsInputNormalizer)
|
|
33
|
+
private readonly itemsInputNormalizer: ItemsInputNormalizer,
|
|
34
|
+
@inject(RunIntentService)
|
|
35
|
+
private readonly runIntentService: RunIntentService,
|
|
36
|
+
@inject(ApplicationTokens.WorkflowDefinitionRepository)
|
|
37
|
+
private readonly workflowDefinitionRepository: WorkflowDefinitionRepository,
|
|
38
|
+
@inject(ApplicationTokens.WorkflowRunRepository)
|
|
39
|
+
private readonly workflowRunRepository: WorkflowRunRepository,
|
|
40
|
+
@inject(ApplicationTokens.WorkflowDebuggerOverlayRepository)
|
|
41
|
+
private readonly workflowDebuggerOverlayRepository: WorkflowDebuggerOverlayRepository,
|
|
42
|
+
@inject(ApplicationTokens.LoggerFactory)
|
|
43
|
+
loggerFactory: LoggerFactory,
|
|
44
|
+
) {
|
|
45
|
+
super();
|
|
46
|
+
this.routesLog = loggerFactory.create("codemation-routes.server");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async execute(command: StartWorkflowRunCommand): Promise<RunCommandResult> {
|
|
50
|
+
const body = command.body;
|
|
51
|
+
if (!body.workflowId) {
|
|
52
|
+
throw new ApplicationRequestError(400, "Missing workflowId");
|
|
53
|
+
}
|
|
54
|
+
const sourceState =
|
|
55
|
+
body.sourceRunId && !body.currentState ? await this.workflowRunRepository.load(body.sourceRunId) : undefined;
|
|
56
|
+
const debuggerOverlay = await this.workflowDebuggerOverlayRepository.load(body.workflowId);
|
|
57
|
+
const workflow = await this.resolveWorkflow(body);
|
|
58
|
+
if (!workflow) {
|
|
59
|
+
throw new ApplicationRequestError(404, "Unknown workflowId");
|
|
60
|
+
}
|
|
61
|
+
const executionOptions = body.mode
|
|
62
|
+
? {
|
|
63
|
+
mode: body.mode,
|
|
64
|
+
sourceWorkflowId: body.workflowId,
|
|
65
|
+
sourceRunId: body.sourceRunId ?? debuggerOverlay?.copiedFromRunId,
|
|
66
|
+
derivedFromRunId: body.sourceRunId ?? debuggerOverlay?.copiedFromRunId,
|
|
67
|
+
}
|
|
68
|
+
: undefined;
|
|
69
|
+
const legacyStartNodeId = body.startAt as NodeId | undefined;
|
|
70
|
+
const clearFromNodeId = body.clearFromNodeId as NodeId | undefined;
|
|
71
|
+
const requestedItems = await this.resolveRequestedItems({
|
|
72
|
+
workflow,
|
|
73
|
+
body,
|
|
74
|
+
clearFromNodeId,
|
|
75
|
+
});
|
|
76
|
+
const items = this.resolveRunRequestItems(workflow, legacyStartNodeId, requestedItems);
|
|
77
|
+
const currentState = this.createCurrentState({
|
|
78
|
+
workflowId: body.workflowId,
|
|
79
|
+
requestedCurrentState: body.currentState,
|
|
80
|
+
sourceState,
|
|
81
|
+
debuggerOverlay,
|
|
82
|
+
});
|
|
83
|
+
const result =
|
|
84
|
+
legacyStartNodeId && this.hasReusableCurrentState(currentState) && !clearFromNodeId
|
|
85
|
+
? await this.runIntentService.rerunFromNode({
|
|
86
|
+
workflow,
|
|
87
|
+
nodeId: legacyStartNodeId,
|
|
88
|
+
currentState,
|
|
89
|
+
items: requestedItems,
|
|
90
|
+
executionOptions,
|
|
91
|
+
workflowSnapshot: sourceState?.workflowSnapshot,
|
|
92
|
+
mutableState: this.cloneMutableState(currentState.mutableState),
|
|
93
|
+
})
|
|
94
|
+
: await this.runIntentService.startWorkflow({
|
|
95
|
+
workflow,
|
|
96
|
+
startAt: legacyStartNodeId && !body.sourceRunId && !body.stopAt ? legacyStartNodeId : undefined,
|
|
97
|
+
items,
|
|
98
|
+
executionOptions,
|
|
99
|
+
workflowSnapshot: sourceState?.workflowSnapshot,
|
|
100
|
+
mutableState: this.cloneMutableState(currentState.mutableState),
|
|
101
|
+
currentState,
|
|
102
|
+
reset: this.createResetRequest(clearFromNodeId),
|
|
103
|
+
stopCondition:
|
|
104
|
+
legacyStartNodeId && !body.sourceRunId && !body.currentState && !body.stopAt
|
|
105
|
+
? undefined
|
|
106
|
+
: this.createStopCondition(body.stopAt),
|
|
107
|
+
});
|
|
108
|
+
const state = (await this.workflowRunRepository.load(result.runId)) ?? null;
|
|
109
|
+
this.routesLog.info(
|
|
110
|
+
`postRun workflow=${workflow.id} runId=${result.runId} status=${result.status} persistedStatus=${state?.status ?? "missing"}`,
|
|
111
|
+
);
|
|
112
|
+
return {
|
|
113
|
+
runId: result.runId,
|
|
114
|
+
workflowId: result.workflowId,
|
|
115
|
+
startedAt: result.startedAt,
|
|
116
|
+
status: result.status,
|
|
117
|
+
state,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private async resolveWorkflow(body: CreateRunRequest): Promise<WorkflowDefinition | undefined> {
|
|
122
|
+
if (body.currentState) {
|
|
123
|
+
if (!body.workflowId) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
return await this.workflowDefinitionRepository.getDefinition(body.workflowId);
|
|
127
|
+
}
|
|
128
|
+
if (body.sourceRunId) {
|
|
129
|
+
const sourceState = await this.workflowRunRepository.load(body.sourceRunId);
|
|
130
|
+
if (!sourceState) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
return this.engine.resolveWorkflowSnapshot({
|
|
134
|
+
workflowId: sourceState.workflowId,
|
|
135
|
+
workflowSnapshot: sourceState.workflowSnapshot,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (!body.workflowId) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
return await this.workflowDefinitionRepository.getDefinition(body.workflowId);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private resolveRunRequestItems(workflow: WorkflowDefinition, startAt: string | undefined, items?: Items): Items {
|
|
145
|
+
if (items !== undefined) {
|
|
146
|
+
return items;
|
|
147
|
+
}
|
|
148
|
+
return this.isTriggerStart(workflow, startAt) ? [] : [{ json: {} }];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private async resolveRequestedItems(
|
|
152
|
+
args: Readonly<{
|
|
153
|
+
workflow: WorkflowDefinition;
|
|
154
|
+
body: CreateRunRequest;
|
|
155
|
+
clearFromNodeId: NodeId | undefined;
|
|
156
|
+
}>,
|
|
157
|
+
): Promise<Items | undefined> {
|
|
158
|
+
const triggerNodeId = this.resolveTriggerTestNodeId(args);
|
|
159
|
+
const normalizedItems = args.body.items == null ? undefined : this.itemsInputNormalizer.normalize(args.body.items);
|
|
160
|
+
if (!this.shouldSynthesizeTriggerItems(args.body, triggerNodeId, normalizedItems)) {
|
|
161
|
+
return normalizedItems;
|
|
162
|
+
}
|
|
163
|
+
return await this.engine.createTriggerTestItems({
|
|
164
|
+
workflow: args.workflow,
|
|
165
|
+
nodeId: triggerNodeId!,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private isTriggerStart(workflow: WorkflowDefinition, startAt: string | undefined): boolean {
|
|
170
|
+
const resolvedStartAt =
|
|
171
|
+
startAt ?? workflow.nodes.find((node) => node.kind === "trigger")?.id ?? workflow.nodes[0]?.id;
|
|
172
|
+
const startNode = resolvedStartAt ? workflow.nodes.find((node) => node.id === resolvedStartAt) : undefined;
|
|
173
|
+
return startNode?.kind === "trigger";
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private resolveTriggerTestNodeId(
|
|
177
|
+
args: Readonly<{
|
|
178
|
+
workflow: WorkflowDefinition;
|
|
179
|
+
body: CreateRunRequest;
|
|
180
|
+
clearFromNodeId: NodeId | undefined;
|
|
181
|
+
}>,
|
|
182
|
+
): NodeId | undefined {
|
|
183
|
+
const stopAtNodeId = args.body.stopAt as NodeId | undefined;
|
|
184
|
+
if (stopAtNodeId && this.isTriggerNode(args.workflow, stopAtNodeId)) {
|
|
185
|
+
return stopAtNodeId;
|
|
186
|
+
}
|
|
187
|
+
if (!args.body.sourceRunId && !args.clearFromNodeId && !stopAtNodeId) {
|
|
188
|
+
if (args.body.currentState && !args.body.synthesizeTriggerItems) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
return args.workflow.nodes.find((node) => node.kind === "trigger")?.id;
|
|
192
|
+
}
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private shouldSynthesizeTriggerItems(
|
|
197
|
+
body: CreateRunRequest,
|
|
198
|
+
triggerNodeId: NodeId | undefined,
|
|
199
|
+
normalizedItems: Items | undefined,
|
|
200
|
+
): boolean {
|
|
201
|
+
if (!triggerNodeId) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
if (body.synthesizeTriggerItems) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
if (normalizedItems && normalizedItems.length > 0) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
return body.stopAt === triggerNodeId;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private isTriggerNode(workflow: WorkflowDefinition, nodeId: NodeId): boolean {
|
|
214
|
+
return workflow.nodes.find((node) => node.id === nodeId)?.kind === "trigger";
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
private cloneMutableState(mutableState: PersistedRunState["mutableState"]): PersistedMutableRunState | undefined {
|
|
218
|
+
if (!mutableState) {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
return JSON.parse(JSON.stringify(mutableState)) as PersistedMutableRunState;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private cloneRunCurrentState(state: PersistedRunState | undefined): RunCurrentState {
|
|
225
|
+
if (!state) {
|
|
226
|
+
return WorkflowDebuggerOverlayStateFactory.cloneCurrentState(undefined);
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
outputsByNode: JSON.parse(JSON.stringify(state.outputsByNode)) as RunCurrentState["outputsByNode"],
|
|
230
|
+
nodeSnapshotsByNodeId: JSON.parse(
|
|
231
|
+
JSON.stringify(state.nodeSnapshotsByNodeId),
|
|
232
|
+
) as RunCurrentState["nodeSnapshotsByNodeId"],
|
|
233
|
+
mutableState: this.cloneMutableState(state.mutableState),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private createCurrentState(
|
|
238
|
+
args: Readonly<{
|
|
239
|
+
workflowId: string;
|
|
240
|
+
requestedCurrentState: RunCurrentState | undefined;
|
|
241
|
+
sourceState: PersistedRunState | undefined;
|
|
242
|
+
debuggerOverlay: Awaited<ReturnType<WorkflowDebuggerOverlayRepository["load"]>>;
|
|
243
|
+
}>,
|
|
244
|
+
): RunCurrentState {
|
|
245
|
+
if (args.requestedCurrentState) {
|
|
246
|
+
return WorkflowDebuggerOverlayStateFactory.cloneCurrentState(args.requestedCurrentState);
|
|
247
|
+
}
|
|
248
|
+
const baseCurrentState = args.sourceState
|
|
249
|
+
? this.cloneRunCurrentState(args.sourceState)
|
|
250
|
+
: WorkflowDebuggerOverlayStateFactory.cloneCurrentState(args.debuggerOverlay?.currentState);
|
|
251
|
+
if (!args.sourceState || !args.debuggerOverlay || args.debuggerOverlay.workflowId !== args.workflowId) {
|
|
252
|
+
return baseCurrentState;
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
...baseCurrentState,
|
|
256
|
+
mutableState: this.cloneMutableState(args.debuggerOverlay.currentState.mutableState),
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
private createStopCondition(stopAtNodeId: string | undefined): RunStopCondition {
|
|
261
|
+
if (!stopAtNodeId) {
|
|
262
|
+
return { kind: "workflowCompleted" };
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
kind: "nodeCompleted",
|
|
266
|
+
nodeId: stopAtNodeId as NodeId,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
private createResetRequest(clearFromNodeId: NodeId | undefined): Readonly<{ clearFromNodeId: NodeId }> | undefined {
|
|
271
|
+
if (!clearFromNodeId) {
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
clearFromNodeId,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private hasReusableCurrentState(currentState: RunCurrentState): boolean {
|
|
280
|
+
return (
|
|
281
|
+
Object.keys(currentState.outputsByNode).length > 0 ||
|
|
282
|
+
Object.keys(currentState.nodeSnapshotsByNodeId).length > 0 ||
|
|
283
|
+
Object.keys(currentState.mutableState?.nodesById ?? {}).length > 0
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CredentialHealth } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import { inject } from "@codemation/core";
|
|
4
|
+
|
|
5
|
+
import { CommandHandler } from "../bus/CommandHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesCommand } from "../../infrastructure/di/HandlesCommandRegistry";
|
|
8
|
+
|
|
9
|
+
import { TestCredentialInstanceCommand } from "./TestCredentialInstanceCommand";
|
|
10
|
+
|
|
11
|
+
import { CredentialTestService } from "../../domain/credentials/CredentialServices";
|
|
12
|
+
|
|
13
|
+
@HandlesCommand.forCommand(TestCredentialInstanceCommand)
|
|
14
|
+
export class TestCredentialInstanceCommandHandler extends CommandHandler<
|
|
15
|
+
TestCredentialInstanceCommand,
|
|
16
|
+
CredentialHealth
|
|
17
|
+
> {
|
|
18
|
+
constructor(
|
|
19
|
+
@inject(CredentialTestService)
|
|
20
|
+
private readonly credentialTestService: CredentialTestService,
|
|
21
|
+
) {
|
|
22
|
+
super();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async execute(command: TestCredentialInstanceCommand): Promise<CredentialHealth> {
|
|
26
|
+
return await this.credentialTestService.test(command.instanceId);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CredentialInstanceDto, UpdateCredentialInstanceRequest } from "../contracts/CredentialContractsRegistry";
|
|
2
|
+
|
|
3
|
+
import { Command } from "../bus/Command";
|
|
4
|
+
|
|
5
|
+
export class UpdateCredentialInstanceCommand extends Command<CredentialInstanceDto> {
|
|
6
|
+
constructor(
|
|
7
|
+
public readonly instanceId: string,
|
|
8
|
+
public readonly body: UpdateCredentialInstanceRequest,
|
|
9
|
+
) {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import type { CredentialInstanceDto } from "../contracts/CredentialContractsRegistry";
|
|
4
|
+
|
|
5
|
+
import { CommandHandler } from "../bus/CommandHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesCommand } from "../../infrastructure/di/HandlesCommandRegistry";
|
|
8
|
+
|
|
9
|
+
import { UpdateCredentialInstanceCommand } from "./UpdateCredentialInstanceCommand";
|
|
10
|
+
|
|
11
|
+
import { CredentialInstanceService } from "../../domain/credentials/CredentialServices";
|
|
12
|
+
|
|
13
|
+
@HandlesCommand.forCommand(UpdateCredentialInstanceCommand)
|
|
14
|
+
export class UpdateCredentialInstanceCommandHandler extends CommandHandler<
|
|
15
|
+
UpdateCredentialInstanceCommand,
|
|
16
|
+
CredentialInstanceDto
|
|
17
|
+
> {
|
|
18
|
+
constructor(
|
|
19
|
+
@inject(CredentialInstanceService)
|
|
20
|
+
private readonly credentialInstanceService: CredentialInstanceService,
|
|
21
|
+
) {
|
|
22
|
+
super();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async execute(command: UpdateCredentialInstanceCommand): Promise<CredentialInstanceDto> {
|
|
26
|
+
return await this.credentialInstanceService.update(command.instanceId, command.body);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UserAccountDto, UserAccountStatus } from "../contracts/userDirectoryContracts.types";
|
|
2
|
+
|
|
3
|
+
import { Command } from "../bus/Command";
|
|
4
|
+
|
|
5
|
+
export class UpdateUserAccountStatusCommand extends Command<UserAccountDto> {
|
|
6
|
+
constructor(
|
|
7
|
+
public readonly userId: string,
|
|
8
|
+
public readonly status: UserAccountStatus,
|
|
9
|
+
) {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import type { UserAccountDto } from "../contracts/userDirectoryContracts.types";
|
|
4
|
+
|
|
5
|
+
import { CommandHandler } from "../bus/CommandHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesCommand } from "../../infrastructure/di/HandlesCommandRegistry";
|
|
8
|
+
|
|
9
|
+
import { UserAccountService } from "../../domain/users/UserAccountServiceRegistry";
|
|
10
|
+
import { UpdateUserAccountStatusCommand } from "./UpdateUserAccountStatusCommand";
|
|
11
|
+
|
|
12
|
+
@HandlesCommand.forCommand(UpdateUserAccountStatusCommand)
|
|
13
|
+
export class UpdateUserAccountStatusCommandHandler extends CommandHandler<
|
|
14
|
+
UpdateUserAccountStatusCommand,
|
|
15
|
+
UserAccountDto
|
|
16
|
+
> {
|
|
17
|
+
constructor(@inject(UserAccountService) private readonly userAccounts: UserAccountService) {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async execute(command: UpdateUserAccountStatusCommand): Promise<UserAccountDto> {
|
|
22
|
+
return await this.userAccounts.updateAccountStatus(command.userId, command.status);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BinaryAttachment, BinaryBody } from "@codemation/core";
|
|
2
|
+
import { Command } from "../bus/Command";
|
|
3
|
+
|
|
4
|
+
export class UploadOverlayPinnedBinaryCommand extends Command<BinaryAttachment> {
|
|
5
|
+
constructor(
|
|
6
|
+
public readonly workflowId: string,
|
|
7
|
+
public readonly nodeId: string,
|
|
8
|
+
public readonly itemIndex: number,
|
|
9
|
+
public readonly attachmentName: string,
|
|
10
|
+
public readonly mimeType: string,
|
|
11
|
+
public readonly body: BinaryBody,
|
|
12
|
+
public readonly filename?: string,
|
|
13
|
+
) {
|
|
14
|
+
super();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
import type { BinaryAttachment } from "@codemation/core";
|
|
3
|
+
import { HandlesCommand } from "../../infrastructure/di/HandlesCommandRegistry";
|
|
4
|
+
import { OverlayPinnedBinaryUploadService } from "../binary/OverlayPinnedBinaryUploadService";
|
|
5
|
+
import { CommandHandler } from "../bus/CommandHandler";
|
|
6
|
+
import { UploadOverlayPinnedBinaryCommand } from "./UploadOverlayPinnedBinaryCommand";
|
|
7
|
+
|
|
8
|
+
@HandlesCommand.forCommand(UploadOverlayPinnedBinaryCommand)
|
|
9
|
+
export class UploadOverlayPinnedBinaryCommandHandler extends CommandHandler<
|
|
10
|
+
UploadOverlayPinnedBinaryCommand,
|
|
11
|
+
BinaryAttachment
|
|
12
|
+
> {
|
|
13
|
+
constructor(
|
|
14
|
+
@inject(OverlayPinnedBinaryUploadService)
|
|
15
|
+
private readonly overlayPinnedBinaryUpload: OverlayPinnedBinaryUploadService,
|
|
16
|
+
) {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async execute(command: UploadOverlayPinnedBinaryCommand): Promise<BinaryAttachment> {
|
|
21
|
+
return this.overlayPinnedBinaryUpload.attach({
|
|
22
|
+
workflowId: command.workflowId,
|
|
23
|
+
nodeId: command.nodeId,
|
|
24
|
+
itemIndex: command.itemIndex,
|
|
25
|
+
name: command.attachmentName,
|
|
26
|
+
mimeType: command.mimeType,
|
|
27
|
+
body: command.body,
|
|
28
|
+
filename: command.filename,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CredentialBinding } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import type { UpsertCredentialBindingRequest } from "../contracts/CredentialContractsRegistry";
|
|
4
|
+
|
|
5
|
+
import { Command } from "../bus/Command";
|
|
6
|
+
|
|
7
|
+
export class UpsertCredentialBindingCommand extends Command<CredentialBinding> {
|
|
8
|
+
constructor(public readonly body: UpsertCredentialBindingRequest) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CredentialBinding } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import { inject } from "@codemation/core";
|
|
4
|
+
|
|
5
|
+
import { CommandHandler } from "../bus/CommandHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesCommand } from "../../infrastructure/di/HandlesCommandRegistry";
|
|
8
|
+
|
|
9
|
+
import { UpsertCredentialBindingCommand } from "./UpsertCredentialBindingCommand";
|
|
10
|
+
|
|
11
|
+
import { CredentialBindingService } from "../../domain/credentials/CredentialServices";
|
|
12
|
+
|
|
13
|
+
@HandlesCommand.forCommand(UpsertCredentialBindingCommand)
|
|
14
|
+
export class UpsertCredentialBindingCommandHandler extends CommandHandler<
|
|
15
|
+
UpsertCredentialBindingCommand,
|
|
16
|
+
CredentialBinding
|
|
17
|
+
> {
|
|
18
|
+
constructor(
|
|
19
|
+
@inject(CredentialBindingService)
|
|
20
|
+
private readonly credentialBindingService: CredentialBindingService,
|
|
21
|
+
) {
|
|
22
|
+
super();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async execute(command: UpsertCredentialBindingCommand): Promise<CredentialBinding> {
|
|
26
|
+
return await this.credentialBindingService.upsertBinding(command.body);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UpsertLocalBootstrapUserResultDto } from "../contracts/userDirectoryContracts.types";
|
|
2
|
+
|
|
3
|
+
import { Command } from "../bus/Command";
|
|
4
|
+
|
|
5
|
+
export class UpsertLocalBootstrapUserCommand extends Command<UpsertLocalBootstrapUserResultDto> {
|
|
6
|
+
constructor(
|
|
7
|
+
public readonly email: string,
|
|
8
|
+
public readonly password: string,
|
|
9
|
+
) {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { inject } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import type { UpsertLocalBootstrapUserResultDto } from "../contracts/userDirectoryContracts.types";
|
|
4
|
+
|
|
5
|
+
import { CommandHandler } from "../bus/CommandHandler";
|
|
6
|
+
|
|
7
|
+
import { HandlesCommand } from "../../infrastructure/di/HandlesCommandRegistry";
|
|
8
|
+
|
|
9
|
+
import { UserAccountService } from "../../domain/users/UserAccountServiceRegistry";
|
|
10
|
+
import { UpsertLocalBootstrapUserCommand } from "./UpsertLocalBootstrapUserCommand";
|
|
11
|
+
|
|
12
|
+
@HandlesCommand.forCommand(UpsertLocalBootstrapUserCommand)
|
|
13
|
+
export class UpsertLocalBootstrapUserCommandHandler extends CommandHandler<
|
|
14
|
+
UpsertLocalBootstrapUserCommand,
|
|
15
|
+
UpsertLocalBootstrapUserResultDto
|
|
16
|
+
> {
|
|
17
|
+
constructor(@inject(UserAccountService) private readonly userAccounts: UserAccountService) {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async execute(command: UpsertLocalBootstrapUserCommand): Promise<UpsertLocalBootstrapUserResultDto> {
|
|
22
|
+
return await this.userAccounts.upsertBootstrapLocalUser(command.email, command.password);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { AcceptUserInviteCommand } from "./AcceptUserInviteCommand";
|
|
2
|
+
export { AcceptUserInviteCommandHandler } from "./AcceptUserInviteCommandHandler";
|
|
3
|
+
export { InviteUserCommand } from "./InviteUserCommand";
|
|
4
|
+
export { InviteUserCommandHandler } from "./InviteUserCommandHandler";
|
|
5
|
+
export { RegenerateUserInviteCommand } from "./RegenerateUserInviteCommand";
|
|
6
|
+
export { RegenerateUserInviteCommandHandler } from "./RegenerateUserInviteCommandHandler";
|
|
7
|
+
export { UpdateUserAccountStatusCommand } from "./UpdateUserAccountStatusCommand";
|
|
8
|
+
export { UpdateUserAccountStatusCommandHandler } from "./UpdateUserAccountStatusCommandHandler";
|
|
9
|
+
export { UpsertLocalBootstrapUserCommand } from "./UpsertLocalBootstrapUserCommand";
|
|
10
|
+
export { UpsertLocalBootstrapUserCommandHandler } from "./UpsertLocalBootstrapUserCommandHandler";
|