@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,145 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CredentialBinding,
|
|
3
|
+
CredentialBindingKey,
|
|
4
|
+
CredentialHealth,
|
|
5
|
+
CredentialInstanceId,
|
|
6
|
+
CredentialInstanceRecord as CoreCredentialInstanceRecord,
|
|
7
|
+
CredentialJsonRecord,
|
|
8
|
+
CredentialSessionService,
|
|
9
|
+
CredentialHealthTester as CoreCredentialHealthTester,
|
|
10
|
+
CredentialSessionFactory as CoreCredentialSessionFactory,
|
|
11
|
+
CredentialSessionFactoryArgs,
|
|
12
|
+
AnyCredentialType,
|
|
13
|
+
CredentialType as CoreCredentialType,
|
|
14
|
+
} from "@codemation/core";
|
|
15
|
+
|
|
16
|
+
export type JsonRecord = CredentialJsonRecord;
|
|
17
|
+
|
|
18
|
+
export type CredentialSecretRef = Readonly<
|
|
19
|
+
| { kind: "db" }
|
|
20
|
+
| {
|
|
21
|
+
kind: "env";
|
|
22
|
+
envByField: Readonly<Record<string, string>>;
|
|
23
|
+
}
|
|
24
|
+
| {
|
|
25
|
+
kind: "code";
|
|
26
|
+
value: JsonRecord;
|
|
27
|
+
}
|
|
28
|
+
>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Persisted credential instance for the host store (stricter `CredentialSecretRef` than core's envelope).
|
|
32
|
+
*/
|
|
33
|
+
export type CredentialInstanceRecord<TPublicConfig extends JsonRecord = JsonRecord> = Readonly<
|
|
34
|
+
Omit<CoreCredentialInstanceRecord<TPublicConfig>, "secretRef"> & { secretRef: CredentialSecretRef }
|
|
35
|
+
>;
|
|
36
|
+
|
|
37
|
+
export type CredentialSecretMaterialRecord = Readonly<{
|
|
38
|
+
instanceId: CredentialInstanceId;
|
|
39
|
+
encryptedJson: string;
|
|
40
|
+
encryptionKeyId: string;
|
|
41
|
+
schemaVersion: number;
|
|
42
|
+
updatedAt: string;
|
|
43
|
+
}>;
|
|
44
|
+
|
|
45
|
+
export type CredentialOAuth2MaterialMetadata = Readonly<{
|
|
46
|
+
providerId: string;
|
|
47
|
+
connectedEmail?: string;
|
|
48
|
+
connectedAt?: string;
|
|
49
|
+
scopes: ReadonlyArray<string>;
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
53
|
+
export type CredentialOAuth2MaterialRecord = Readonly<
|
|
54
|
+
{
|
|
55
|
+
instanceId: CredentialInstanceId;
|
|
56
|
+
} & CredentialSecretMaterialRecord &
|
|
57
|
+
CredentialOAuth2MaterialMetadata
|
|
58
|
+
>;
|
|
59
|
+
|
|
60
|
+
export type CredentialOAuth2StateRecord = Readonly<{
|
|
61
|
+
state: string;
|
|
62
|
+
instanceId: CredentialInstanceId;
|
|
63
|
+
codeVerifier?: string;
|
|
64
|
+
providerId?: string;
|
|
65
|
+
requestedScopes: ReadonlyArray<string>;
|
|
66
|
+
createdAt: string;
|
|
67
|
+
expiresAt: string;
|
|
68
|
+
}>;
|
|
69
|
+
|
|
70
|
+
export type CredentialTestRecord = Readonly<{
|
|
71
|
+
testId: string;
|
|
72
|
+
instanceId: CredentialInstanceId;
|
|
73
|
+
health: CredentialHealth;
|
|
74
|
+
testedAt: string;
|
|
75
|
+
expiresAt?: string;
|
|
76
|
+
}>;
|
|
77
|
+
|
|
78
|
+
export interface CredentialStore {
|
|
79
|
+
listInstances(): Promise<ReadonlyArray<CredentialInstanceRecord>>;
|
|
80
|
+
getInstance(instanceId: CredentialInstanceId): Promise<CredentialInstanceRecord | undefined>;
|
|
81
|
+
saveInstance(
|
|
82
|
+
args: Readonly<{
|
|
83
|
+
instance: CredentialInstanceRecord;
|
|
84
|
+
secretMaterial?: CredentialSecretMaterialRecord;
|
|
85
|
+
}>,
|
|
86
|
+
): Promise<void>;
|
|
87
|
+
deleteInstance(instanceId: CredentialInstanceId): Promise<void>;
|
|
88
|
+
getSecretMaterial(instanceId: CredentialInstanceId): Promise<CredentialSecretMaterialRecord | undefined>;
|
|
89
|
+
createOAuth2State(record: CredentialOAuth2StateRecord): Promise<void>;
|
|
90
|
+
consumeOAuth2State(state: string): Promise<CredentialOAuth2StateRecord | undefined>;
|
|
91
|
+
getOAuth2Material(instanceId: CredentialInstanceId): Promise<CredentialOAuth2MaterialRecord | undefined>;
|
|
92
|
+
saveOAuth2Material(
|
|
93
|
+
args: Readonly<{
|
|
94
|
+
instanceId: CredentialInstanceId;
|
|
95
|
+
encryptedJson: string;
|
|
96
|
+
encryptionKeyId: string;
|
|
97
|
+
schemaVersion: number;
|
|
98
|
+
metadata: CredentialOAuth2MaterialMetadata;
|
|
99
|
+
}>,
|
|
100
|
+
): Promise<void>;
|
|
101
|
+
deleteOAuth2Material(instanceId: CredentialInstanceId): Promise<void>;
|
|
102
|
+
upsertBinding(binding: CredentialBinding): Promise<void>;
|
|
103
|
+
getBinding(key: CredentialBindingKey): Promise<CredentialBinding | undefined>;
|
|
104
|
+
listBindingsByWorkflowId(workflowId: string): Promise<ReadonlyArray<CredentialBinding>>;
|
|
105
|
+
saveTestResult(record: CredentialTestRecord): Promise<void>;
|
|
106
|
+
getLatestTestResult(instanceId: CredentialInstanceId): Promise<CredentialTestRecord | undefined>;
|
|
107
|
+
getLatestTestResults(
|
|
108
|
+
instanceIds: ReadonlyArray<CredentialInstanceId>,
|
|
109
|
+
): Promise<ReadonlyMap<CredentialInstanceId, CredentialTestRecord>>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type CredentialSessionFactory<
|
|
113
|
+
TPublicConfig extends JsonRecord = JsonRecord,
|
|
114
|
+
TMaterial extends JsonRecord = JsonRecord,
|
|
115
|
+
TSession = unknown,
|
|
116
|
+
> = CoreCredentialSessionFactory<TPublicConfig, TMaterial, TSession>;
|
|
117
|
+
|
|
118
|
+
export type CredentialHealthTester<
|
|
119
|
+
TPublicConfig extends JsonRecord = JsonRecord,
|
|
120
|
+
TMaterial extends JsonRecord = JsonRecord,
|
|
121
|
+
> = CoreCredentialHealthTester<TPublicConfig, TMaterial>;
|
|
122
|
+
|
|
123
|
+
export type CredentialType<
|
|
124
|
+
TPublicConfig extends JsonRecord = JsonRecord,
|
|
125
|
+
TMaterial extends JsonRecord = JsonRecord,
|
|
126
|
+
TSession = unknown,
|
|
127
|
+
> = CoreCredentialType<TPublicConfig, TMaterial, TSession>;
|
|
128
|
+
|
|
129
|
+
export type { AnyCredentialType, CredentialSessionFactoryArgs };
|
|
130
|
+
|
|
131
|
+
export type MutableCredentialSessionService = CredentialSessionService &
|
|
132
|
+
Readonly<{
|
|
133
|
+
evictInstance(instanceId: CredentialInstanceId): void;
|
|
134
|
+
evictBinding(bindingKey: CredentialBindingKey): void;
|
|
135
|
+
}>;
|
|
136
|
+
|
|
137
|
+
export { CredentialTypeRegistryImpl } from "./CredentialTypeRegistryImpl";
|
|
138
|
+
export { CredentialBindingService } from "./CredentialBindingService";
|
|
139
|
+
export { CredentialInstanceService } from "./CredentialInstanceService";
|
|
140
|
+
export { CredentialMaterialResolver } from "./CredentialMaterialResolver";
|
|
141
|
+
export { CredentialRuntimeMaterialService } from "./CredentialRuntimeMaterialService";
|
|
142
|
+
export { CredentialFieldEnvOverlayService } from "./CredentialFieldEnvOverlayService";
|
|
143
|
+
export { CredentialSecretCipher } from "./CredentialSecretCipher";
|
|
144
|
+
export { CredentialSessionServiceImpl } from "./CredentialSessionServiceImpl";
|
|
145
|
+
export { CredentialTestService } from "./CredentialTestService";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CredentialBindingKey,
|
|
3
|
+
CredentialInstanceId,
|
|
4
|
+
CredentialSessionService,
|
|
5
|
+
WorkflowRepository,
|
|
6
|
+
} from "@codemation/core";
|
|
7
|
+
|
|
8
|
+
import { CoreTokens, CredentialUnboundError, inject, injectable } from "@codemation/core";
|
|
9
|
+
|
|
10
|
+
import { ApplicationRequestError } from "../../application/ApplicationRequestError";
|
|
11
|
+
|
|
12
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
13
|
+
|
|
14
|
+
import { WorkflowCredentialNodeResolver } from "./WorkflowCredentialNodeResolver";
|
|
15
|
+
import { CredentialFieldEnvOverlayService } from "./CredentialFieldEnvOverlayService";
|
|
16
|
+
import { CredentialRuntimeMaterialService } from "./CredentialRuntimeMaterialService";
|
|
17
|
+
import type { CredentialStore } from "./CredentialServices";
|
|
18
|
+
import { CredentialTypeRegistryImpl } from "./CredentialServices";
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class CredentialSessionServiceImpl implements CredentialSessionService {
|
|
22
|
+
private readonly cachedSessionsByInstanceId = new Map<CredentialInstanceId, Promise<unknown>>();
|
|
23
|
+
private readonly cachedInstanceIdsByBindingKey = new Map<string, CredentialInstanceId>();
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
@inject(ApplicationTokens.CredentialStore)
|
|
27
|
+
private readonly credentialStore: CredentialStore,
|
|
28
|
+
@inject(CredentialRuntimeMaterialService)
|
|
29
|
+
private readonly credentialRuntimeMaterialService: CredentialRuntimeMaterialService,
|
|
30
|
+
@inject(CredentialFieldEnvOverlayService)
|
|
31
|
+
private readonly credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService,
|
|
32
|
+
@inject(CredentialTypeRegistryImpl)
|
|
33
|
+
private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,
|
|
34
|
+
@inject(CoreTokens.WorkflowRepository)
|
|
35
|
+
private readonly workflowRepository: WorkflowRepository,
|
|
36
|
+
@inject(WorkflowCredentialNodeResolver)
|
|
37
|
+
private readonly workflowCredentialNodeResolver: WorkflowCredentialNodeResolver,
|
|
38
|
+
) {}
|
|
39
|
+
|
|
40
|
+
async getSession<TSession = unknown>(
|
|
41
|
+
args: Readonly<{ workflowId: string; nodeId: string; slotKey: string }>,
|
|
42
|
+
): Promise<TSession> {
|
|
43
|
+
const workflow = this.workflowRepository.get(decodeURIComponent(args.workflowId));
|
|
44
|
+
const displayLabel = workflow
|
|
45
|
+
? this.workflowCredentialNodeResolver.describeCredentialNodeDisplay(workflow, args.nodeId)
|
|
46
|
+
: undefined;
|
|
47
|
+
const requirement = workflow
|
|
48
|
+
? this.workflowCredentialNodeResolver.findRequirement(workflow, args.nodeId, args.slotKey)?.requirement
|
|
49
|
+
: undefined;
|
|
50
|
+
const bindingKey: CredentialBindingKey = {
|
|
51
|
+
workflowId: args.workflowId,
|
|
52
|
+
nodeId: args.nodeId,
|
|
53
|
+
slotKey: args.slotKey,
|
|
54
|
+
};
|
|
55
|
+
const binding = await this.credentialStore.getBinding(bindingKey);
|
|
56
|
+
if (!binding) {
|
|
57
|
+
const unbound = new CredentialUnboundError(bindingKey, requirement?.acceptedTypes ?? []);
|
|
58
|
+
if (displayLabel) {
|
|
59
|
+
throw new Error(`${displayLabel}: ${unbound.message}`, { cause: unbound });
|
|
60
|
+
}
|
|
61
|
+
throw unbound;
|
|
62
|
+
}
|
|
63
|
+
const bindingCacheKey = this.toBindingKeyString(bindingKey);
|
|
64
|
+
this.cachedInstanceIdsByBindingKey.set(bindingCacheKey, binding.instanceId);
|
|
65
|
+
const cachedSession = this.cachedSessionsByInstanceId.get(binding.instanceId);
|
|
66
|
+
if (cachedSession) {
|
|
67
|
+
return (await cachedSession) as TSession;
|
|
68
|
+
}
|
|
69
|
+
const nextSessionPromise = this.createSession(binding.instanceId, displayLabel).catch((error) => {
|
|
70
|
+
this.cachedSessionsByInstanceId.delete(binding.instanceId);
|
|
71
|
+
throw error;
|
|
72
|
+
});
|
|
73
|
+
this.cachedSessionsByInstanceId.set(binding.instanceId, nextSessionPromise);
|
|
74
|
+
return (await nextSessionPromise) as TSession;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
evictInstance(instanceId: CredentialInstanceId): void {
|
|
78
|
+
this.cachedSessionsByInstanceId.delete(instanceId);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
evictBinding(bindingKey: CredentialBindingKey): void {
|
|
82
|
+
const cacheKey = this.toBindingKeyString(bindingKey);
|
|
83
|
+
const instanceId = this.cachedInstanceIdsByBindingKey.get(cacheKey);
|
|
84
|
+
if (instanceId) {
|
|
85
|
+
this.cachedSessionsByInstanceId.delete(instanceId);
|
|
86
|
+
}
|
|
87
|
+
this.cachedInstanceIdsByBindingKey.delete(cacheKey);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private async createSession(instanceId: CredentialInstanceId, displayLabel?: string): Promise<unknown> {
|
|
91
|
+
const instance = await this.credentialStore.getInstance(instanceId);
|
|
92
|
+
if (!instance) {
|
|
93
|
+
throw new ApplicationRequestError(404, `Unknown credential instance: ${instanceId}`);
|
|
94
|
+
}
|
|
95
|
+
const credentialType = this.credentialTypeRegistry.getCredentialType(instance.typeId);
|
|
96
|
+
if (!credentialType) {
|
|
97
|
+
const prefix = displayLabel ? `${displayLabel}: ` : "";
|
|
98
|
+
throw new ApplicationRequestError(
|
|
99
|
+
400,
|
|
100
|
+
`${prefix}Credential type "${instance.typeId}" is not registered in this runtime (binding points at an unknown type).`,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const material = await this.credentialRuntimeMaterialService.compose(instance);
|
|
104
|
+
const { resolvedPublicConfig, resolvedMaterial } = this.credentialFieldEnvOverlayService.apply({
|
|
105
|
+
definition: credentialType.definition,
|
|
106
|
+
publicConfig: instance.publicConfig,
|
|
107
|
+
material,
|
|
108
|
+
});
|
|
109
|
+
return await credentialType.createSession({
|
|
110
|
+
instance,
|
|
111
|
+
material: resolvedMaterial,
|
|
112
|
+
publicConfig: resolvedPublicConfig,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private toBindingKeyString(bindingKey: CredentialBindingKey): string {
|
|
117
|
+
return `${bindingKey.workflowId}:${bindingKey.nodeId}:${bindingKey.slotKey}`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import type { CredentialHealth, CredentialInstanceId, CredentialTypeId } from "@codemation/core";
|
|
4
|
+
|
|
5
|
+
import { CoreTokens, inject, injectable } from "@codemation/core";
|
|
6
|
+
|
|
7
|
+
import { ApplicationRequestError } from "../../application/ApplicationRequestError";
|
|
8
|
+
|
|
9
|
+
import { ApplicationTokens } from "../../applicationTokens";
|
|
10
|
+
|
|
11
|
+
import { CredentialFieldEnvOverlayService } from "./CredentialFieldEnvOverlayService";
|
|
12
|
+
import { CredentialInstanceService } from "./CredentialInstanceService";
|
|
13
|
+
import { CredentialRuntimeMaterialService } from "./CredentialRuntimeMaterialService";
|
|
14
|
+
import type { CredentialStore, AnyCredentialType, MutableCredentialSessionService } from "./CredentialServices";
|
|
15
|
+
import { CredentialTypeRegistryImpl } from "./CredentialServices";
|
|
16
|
+
|
|
17
|
+
@injectable()
|
|
18
|
+
export class CredentialTestService {
|
|
19
|
+
constructor(
|
|
20
|
+
@inject(CredentialInstanceService)
|
|
21
|
+
private readonly credentialInstanceService: CredentialInstanceService,
|
|
22
|
+
@inject(CredentialRuntimeMaterialService)
|
|
23
|
+
private readonly credentialRuntimeMaterialService: CredentialRuntimeMaterialService,
|
|
24
|
+
@inject(CredentialFieldEnvOverlayService)
|
|
25
|
+
private readonly credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService,
|
|
26
|
+
@inject(CredentialTypeRegistryImpl)
|
|
27
|
+
private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,
|
|
28
|
+
@inject(ApplicationTokens.CredentialStore)
|
|
29
|
+
private readonly credentialStore: CredentialStore,
|
|
30
|
+
@inject(CoreTokens.CredentialSessionService)
|
|
31
|
+
private readonly credentialSessionService: MutableCredentialSessionService,
|
|
32
|
+
) {}
|
|
33
|
+
|
|
34
|
+
async test(instanceId: CredentialInstanceId): Promise<CredentialHealth> {
|
|
35
|
+
const instance = await this.credentialInstanceService.requireInstance(instanceId);
|
|
36
|
+
const credentialType = this.requireCredentialType(instance.typeId);
|
|
37
|
+
const material = await this.credentialRuntimeMaterialService.compose(instance);
|
|
38
|
+
const { resolvedPublicConfig, resolvedMaterial } = this.credentialFieldEnvOverlayService.apply({
|
|
39
|
+
definition: credentialType.definition,
|
|
40
|
+
publicConfig: instance.publicConfig,
|
|
41
|
+
material,
|
|
42
|
+
});
|
|
43
|
+
const health = await credentialType.test({
|
|
44
|
+
instance,
|
|
45
|
+
material: resolvedMaterial,
|
|
46
|
+
publicConfig: resolvedPublicConfig,
|
|
47
|
+
});
|
|
48
|
+
const testedAt = health.testedAt ?? new Date().toISOString();
|
|
49
|
+
await this.credentialStore.saveTestResult({
|
|
50
|
+
testId: randomUUID(),
|
|
51
|
+
instanceId,
|
|
52
|
+
health: {
|
|
53
|
+
...health,
|
|
54
|
+
testedAt,
|
|
55
|
+
},
|
|
56
|
+
testedAt,
|
|
57
|
+
expiresAt: health.expiresAt,
|
|
58
|
+
});
|
|
59
|
+
this.credentialSessionService.evictInstance(instanceId);
|
|
60
|
+
return {
|
|
61
|
+
...health,
|
|
62
|
+
testedAt,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private requireCredentialType(typeId: CredentialTypeId): AnyCredentialType {
|
|
67
|
+
const credentialType = this.credentialTypeRegistry.getCredentialType(typeId);
|
|
68
|
+
if (!credentialType) {
|
|
69
|
+
throw new ApplicationRequestError(400, `Unknown credential type: ${typeId}`);
|
|
70
|
+
}
|
|
71
|
+
return credentialType;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CredentialTypeDefinition, CredentialTypeId, CredentialTypeRegistry } from "@codemation/core";
|
|
2
|
+
|
|
3
|
+
import { injectable } from "@codemation/core";
|
|
4
|
+
|
|
5
|
+
import type { AnyCredentialType, CredentialType } from "./CredentialServices";
|
|
6
|
+
|
|
7
|
+
@injectable()
|
|
8
|
+
export class CredentialTypeRegistryImpl implements CredentialTypeRegistry {
|
|
9
|
+
private readonly credentialTypesById = new Map<CredentialTypeId, AnyCredentialType>();
|
|
10
|
+
|
|
11
|
+
register(type: CredentialType<any, any, unknown>): void {
|
|
12
|
+
if (this.credentialTypesById.has(type.definition.typeId)) {
|
|
13
|
+
throw new Error(`Credential type already registered: ${type.definition.typeId}`);
|
|
14
|
+
}
|
|
15
|
+
this.credentialTypesById.set(type.definition.typeId, type);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
listTypes(): ReadonlyArray<CredentialTypeDefinition> {
|
|
19
|
+
return [...this.credentialTypesById.values()].map((entry) => entry.definition);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined {
|
|
23
|
+
return this.credentialTypesById.get(typeId)?.definition;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getCredentialType(typeId: CredentialTypeId): AnyCredentialType | undefined {
|
|
27
|
+
return this.credentialTypesById.get(typeId);
|
|
28
|
+
}
|
|
29
|
+
}
|