@codemation/host 0.6.0 → 0.8.0

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.
Files changed (226) hide show
  1. package/CHANGELOG.md +483 -0
  2. package/dist/{ApiPaths-CLTHphYZ.js → ApiPaths-Dv1dcHu_.js} +4 -4
  3. package/dist/ApiPaths-Dv1dcHu_.js.map +1 -0
  4. package/dist/{AppConfigFactory-YnveXE9k.d.ts → AppConfigFactory-BT0y0LVC.d.ts} +8490 -5548
  5. package/dist/{AppConfigFactory-C6q-CSKb.js → AppConfigFactory-Cx4qQvRk.js} +112 -52
  6. package/dist/AppConfigFactory-Cx4qQvRk.js.map +1 -0
  7. package/dist/{AppContainerFactory-qaqc-R1D.js → AppContainerFactory-DRTjG7nG.js} +7298 -1732
  8. package/dist/AppContainerFactory-DRTjG7nG.js.map +1 -0
  9. package/dist/{CodemationAppContext-DRu1Dpri.d.ts → CodemationAppContext-CGFYVcSb.d.ts} +14 -4
  10. package/dist/{CodemationAuthoring.types-DZl-sJaM.js → CodemationAuthoring.types-BteaR3Dc.js} +19 -6
  11. package/dist/CodemationAuthoring.types-BteaR3Dc.js.map +1 -0
  12. package/dist/{CodemationAuthoring.types-fBRppnmi.d.ts → CodemationAuthoring.types-DiKKogum.d.ts} +30 -5
  13. package/dist/{CodemationConfigNormalizer-DVko3cVN.d.ts → CodemationConfigNormalizer-48f-T66P.d.ts} +3 -3
  14. package/dist/{CodemationConsumerConfigLoader-BeAUS144.js → CodemationConsumerConfigLoader-By-6tuGc.js} +81 -10
  15. package/dist/CodemationConsumerConfigLoader-By-6tuGc.js.map +1 -0
  16. package/dist/{CodemationConsumerConfigLoader-DJWr86f-.d.ts → CodemationConsumerConfigLoader-_PIYqwVx.d.ts} +18 -2
  17. package/dist/{CodemationPluginListMerger-B-W5Fa_X.js → CodemationPluginListMerger-D1B1IEbt.js} +1 -1
  18. package/dist/{CodemationPluginListMerger-B-W5Fa_X.js.map → CodemationPluginListMerger-D1B1IEbt.js.map} +1 -1
  19. package/dist/{CodemationPluginListMerger-DGc-jfa2.d.ts → CodemationPluginListMerger-DP7djJ9S.d.ts} +151 -19
  20. package/dist/CodemationTsyringeTypeInfoRegistrar-Bj6FJYFz.js +97 -0
  21. package/dist/CodemationTsyringeTypeInfoRegistrar-Bj6FJYFz.js.map +1 -0
  22. package/dist/{CodemationWhitelabelConfig-CWbcyQqn.d.ts → CodemationWhitelabelConfig-Ca2mCUeC.d.ts} +2 -2
  23. package/dist/{CollectionContracts.types-DdpHft0i.d.ts → CollectionContracts.types-DDyFYT_D.d.ts} +1 -1
  24. package/dist/{CredentialContractsRegistry-DrMIDSw8.d.ts → CredentialContractsRegistry-Bq2bq28t.d.ts} +2 -2
  25. package/dist/{CredentialServices-UfvHB-rN.d.ts → CredentialServices-BLloBztI.d.ts} +65 -20
  26. package/dist/{CredentialServices-CgxwguAv.js → CredentialServices-Dk8yypeL.js} +310 -51
  27. package/dist/CredentialServices-Dk8yypeL.js.map +1 -0
  28. package/dist/InternalHonoApiRouteRegistrar-c7t3KnV_.d.ts +17 -0
  29. package/dist/InternalPingRegistrar-DY3kSfxP.js +221 -0
  30. package/dist/InternalPingRegistrar-DY3kSfxP.js.map +1 -0
  31. package/dist/{ItemsInputNormalizer-C-KHg9Mo.d.ts → ItemsInputNormalizer-_RwIfRIQ.d.ts} +89 -25
  32. package/dist/{LogLevelPolicyFactory-CampWO0l.d.ts → LogLevelPolicyFactory-ewCHLDLn.d.ts} +2 -2
  33. package/dist/{PublicFrontendBootstrap-DzBgwOnG.d.ts → PublicFrontendBootstrap-Cev3qK46.d.ts} +9 -2
  34. package/dist/PublicFrontendBootstrapFactory-Dv04tJ-6.d.ts +82 -0
  35. package/dist/{PublicFrontendBootstrapJsonCodec-Cl_DLRh0.d.ts → PublicFrontendBootstrapJsonCodec-CXG9Dxft.d.ts} +3 -3
  36. package/dist/{PublicFrontendBootstrapJsonCodec-DzqvA0uo.js → PublicFrontendBootstrapJsonCodec-CegIF_ne.js} +7 -2
  37. package/dist/PublicFrontendBootstrapJsonCodec-CegIF_ne.js.map +1 -0
  38. package/dist/ServerLoggerFactory-Ckk52S3w.js +223 -0
  39. package/dist/ServerLoggerFactory-Ckk52S3w.js.map +1 -0
  40. package/dist/{TelemetryContracts-DbaNomrH.d.ts → TelemetryContracts-BtDx84Cp.d.ts} +13 -4
  41. package/dist/{WorkflowPolicyUiPresentationFactory-DQEY-h_S.d.ts → WorkflowPolicyUiPresentationFactory-6MyjCvBO.d.ts} +2 -2
  42. package/dist/{WorkflowPolicyUiPresentationFactory-DhPqQ9aB.js → WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js} +1 -1
  43. package/dist/{WorkflowPolicyUiPresentationFactory-DhPqQ9aB.js.map → WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js.map} +1 -1
  44. package/dist/{WorkflowViewContracts-CzK2KFuz.d.ts → WorkflowViewContracts-B7aFQcIw.d.ts} +10 -1
  45. package/dist/authoring.d.ts +5 -5
  46. package/dist/authoring.js +1 -1
  47. package/dist/client.d.ts +4 -4
  48. package/dist/client.js +2 -2
  49. package/dist/consumer.d.ts +6 -6
  50. package/dist/consumer.js +2 -2
  51. package/dist/credentials.d.ts +6 -6
  52. package/dist/credentials.js +1 -1
  53. package/dist/devServerSidecar.d.ts +2 -2
  54. package/dist/devServerSidecar.js +1 -94
  55. package/dist/devServerSidecar.js.map +1 -1
  56. package/dist/dto.d.ts +6 -6
  57. package/dist/{index-BbBk26m0.d.ts → index-DilAYwnH.d.ts} +49 -3
  58. package/dist/index.d.ts +141 -21
  59. package/dist/index.js +109 -14
  60. package/dist/index.js.map +1 -0
  61. package/dist/mapping.d.ts +2 -2
  62. package/dist/mapping.js +1 -1
  63. package/dist/nextServer.d.ts +42 -113
  64. package/dist/nextServer.js +9 -7
  65. package/dist/pairing.d.ts +93 -0
  66. package/dist/pairing.js +5 -0
  67. package/dist/pairing.types-snfZ_OzB.d.ts +19 -0
  68. package/dist/persistenceServer-B71RGvSj.d.ts +30 -0
  69. package/dist/{persistenceServer-CmsIKnO9.js → persistenceServer-C-hH4z6l.js} +2 -2
  70. package/dist/{persistenceServer-CmsIKnO9.js.map → persistenceServer-C-hH4z6l.js.map} +1 -1
  71. package/dist/persistenceServer.d.ts +8 -8
  72. package/dist/persistenceServer.js +3 -3
  73. package/dist/{server-MUNGsBYK.d.ts → server-09PKasWR.d.ts} +21 -6
  74. package/dist/{server-CJFfY67o.js → server-vtRCPgRJ.js} +7 -6
  75. package/dist/{server-CJFfY67o.js.map → server-vtRCPgRJ.js.map} +1 -1
  76. package/dist/server.d.ts +14 -14
  77. package/dist/server.js +13 -11
  78. package/package.json +47 -58
  79. package/prisma/migrations/20260519000000_workflow_audit_log/migration.sql +23 -0
  80. package/prisma/migrations/20260519100000_storage_growth_fixes/migration.sql +61 -0
  81. package/prisma/migrations.sqlite/20260519000000_workflow_audit_log/migration.sql +21 -0
  82. package/prisma/migrations.sqlite/20260519100000_storage_growth_fixes/migration.sql +29 -0
  83. package/prisma/schema.postgresql.prisma +55 -17
  84. package/prisma/schema.sqlite.prisma +55 -17
  85. package/prisma-generated/prisma-postgresql-client/edge.js +33 -5
  86. package/prisma-generated/prisma-postgresql-client/index-browser.js +29 -1
  87. package/prisma-generated/prisma-postgresql-client/index.d.ts +8933 -5716
  88. package/prisma-generated/prisma-postgresql-client/index.js +33 -5
  89. package/prisma-generated/prisma-postgresql-client/package.json +1 -1
  90. package/prisma-generated/prisma-postgresql-client/schema.prisma +38 -0
  91. package/prisma-generated/prisma-sqlite-client/edge.js +33 -5
  92. package/prisma-generated/prisma-sqlite-client/index-browser.js +29 -1
  93. package/prisma-generated/prisma-sqlite-client/index.d.ts +8925 -5713
  94. package/prisma-generated/prisma-sqlite-client/index.js +33 -5
  95. package/prisma-generated/prisma-sqlite-client/package.json +1 -1
  96. package/prisma-generated/prisma-sqlite-client/schema.prisma +38 -0
  97. package/scripts/check-collections.mjs +18 -0
  98. package/scripts/generate-prisma-clients.mjs +20 -11
  99. package/src/application/WorkflowAuditLogPruneScheduler.ts +96 -0
  100. package/src/application/auth/AuthenticatedPrincipal.ts +4 -0
  101. package/src/application/commands/StartWorkflowRunCommandHandler.ts +4 -0
  102. package/src/application/contracts/WorkflowViewContracts.ts +6 -0
  103. package/src/application/contracts/WorkflowWebsocketMessage.ts +3 -1
  104. package/src/application/mapping/WorkflowDefinitionMapper.ts +40 -1
  105. package/src/application/runs/WorkflowRunRetentionPruneScheduler.ts +7 -1
  106. package/src/application/telemetry/OtelExecutionTelemetry.types.ts +5 -0
  107. package/src/application/telemetry/OtelExecutionTelemetryFactory.ts +4 -0
  108. package/src/application/telemetry/StoredTelemetrySpanScope.ts +6 -2
  109. package/src/application/telemetry/TelemetryRetentionTimestampFactory.ts +27 -17
  110. package/src/application/telemetry/TelemetrySpanPublisher.ts +11 -0
  111. package/src/application/websocket/TelemetrySpanWebsocketRelay.ts +31 -0
  112. package/src/applicationTokens.ts +20 -1
  113. package/src/audit/IAuditEmitter.ts +32 -0
  114. package/src/audit/PrismaWorkflowAuditLogRepository.ts +34 -0
  115. package/src/audit/WorkflowAuditLogWriter.ts +125 -0
  116. package/src/auth/managed/ManagedAuthConfig.ts +29 -0
  117. package/src/auth/managed/ManagedAuthMiddleware.ts +52 -0
  118. package/src/auth/managed/ManagedCorsMiddleware.ts +43 -0
  119. package/src/auth/managed/ManagedModeBootGuard.ts +27 -0
  120. package/src/auth/managed/index.ts +5 -0
  121. package/src/bootstrap/AppContainerFactory.ts +295 -29
  122. package/src/bootstrap/AppContainerLifecycle.ts +31 -0
  123. package/src/bootstrap/perf/BootTimer.ts +168 -0
  124. package/src/bootstrap/runtime/AppConfigFactory.ts +21 -65
  125. package/src/bootstrap/runtime/FrontendRuntime.ts +4 -1
  126. package/src/bootstrap/runtime/HeadlessApiRuntime.ts +47 -0
  127. package/src/bootstrap/runtime/WorkerRuntime.ts +2 -1
  128. package/src/credentials/BrokerClient.ts +49 -0
  129. package/src/credentials/BrokerRefreshError.ts +12 -0
  130. package/src/credentials/BrokerRefreshInvalidGrantError.ts +13 -0
  131. package/src/credentials/ControlPlaneCatalogFetcher.ts +261 -0
  132. package/src/credentials/CredentialOAuth2MaterialReader.ts +136 -0
  133. package/src/credentials/InternalCredentialsListRegistrar.ts +48 -0
  134. package/src/credentials/InternalCredentialsPushRegistrar.ts +125 -0
  135. package/src/credentials/LocalOAuthFlowExecutor.ts +316 -0
  136. package/src/credentials/ManagedOAuthFlowExecutor.ts +94 -0
  137. package/src/credentials/ManagedOAuthRefreshInvalidGrantError.ts +13 -0
  138. package/src/credentials/catalogTypes.ts +4 -0
  139. package/src/credentials/refresh/CredentialDisconnectedError.ts +11 -0
  140. package/src/domain/credentials/CredentialBindingService.ts +54 -2
  141. package/src/domain/credentials/CredentialKeyRotatedError.ts +22 -0
  142. package/src/domain/credentials/CredentialSecretCipher.ts +68 -6
  143. package/src/domain/credentials/CredentialTypeRegistryImpl.ts +117 -10
  144. package/src/domain/credentials/OAuth2RedirectUriResolver.ts +79 -0
  145. package/src/domain/credentials/WorkflowCredentialNodeResolver.ts +14 -5
  146. package/src/domain/telemetry/TelemetryContracts.ts +7 -1
  147. package/src/domain/workflows/WorkflowActivationPreflight.ts +24 -1
  148. package/src/domain/workflows/WorkflowActivationPreflightRules.ts +40 -1
  149. package/src/index.ts +9 -0
  150. package/src/infrastructure/binary/LocalFilesystemBinaryStorageRegistry.ts +29 -1
  151. package/src/infrastructure/binary/S3BinaryStorage.ts +169 -0
  152. package/src/infrastructure/binary/S3BinaryStorageConfig.ts +17 -0
  153. package/src/infrastructure/config/CodemationPluginRegistrar.ts +3 -1
  154. package/src/infrastructure/persistence/CodemationDatabaseUrlParser.ts +41 -0
  155. package/src/infrastructure/persistence/InMemoryTelemetryArtifactStore.ts +8 -3
  156. package/src/infrastructure/persistence/PrismaMigrationDeployer.ts +21 -13
  157. package/src/infrastructure/persistence/PrismaTelemetryArtifactStore.ts +43 -8
  158. package/src/infrastructure/persistence/PrismaWorkflowRunRepository.ts +26 -3
  159. package/src/infrastructure/persistence/PrismaWorkflowSnapshotRepository.ts +48 -0
  160. package/src/mcp/AgentMcpIntegrationImpl.ts +344 -0
  161. package/src/mcp/McpClientFactory.ts +29 -0
  162. package/src/mcp/McpConnectionPool.ts +184 -0
  163. package/src/mcp/McpConnectionPool.types.ts +12 -0
  164. package/src/mcp/McpServerCatalog.ts +104 -0
  165. package/src/mcp/index.ts +5 -0
  166. package/src/pairing/HmacRequestSigner.ts +32 -0
  167. package/src/pairing/IncomingHmacVerifier.ts +82 -0
  168. package/src/pairing/InternalHmacAuthMiddleware.ts +33 -0
  169. package/src/pairing/InternalPingRegistrar.ts +25 -0
  170. package/src/pairing/PairedFetch.ts +33 -0
  171. package/src/pairing/PairingConfigFactory.ts +35 -0
  172. package/src/pairing/PairingConfigToken.ts +6 -0
  173. package/src/pairing/index.ts +14 -0
  174. package/src/pairing/pairing.types.ts +18 -0
  175. package/src/pairing.ts +17 -0
  176. package/src/persistenceServer.ts +1 -0
  177. package/src/presentation/config/AppConfig.ts +7 -1
  178. package/src/presentation/config/CodemationAuthConfig.ts +1 -1
  179. package/src/presentation/config/CodemationAuthoring.types.ts +60 -5
  180. package/src/presentation/config/CodemationConfig.ts +9 -0
  181. package/src/presentation/config/CodemationConfigNormalizer.ts +39 -1
  182. package/src/presentation/config/CodemationPlugin.ts +2 -1
  183. package/src/presentation/frontend/CodemationFrontendAuthSnapshot.ts +5 -0
  184. package/src/presentation/frontend/CodemationFrontendAuthSnapshotFactory.ts +7 -1
  185. package/src/presentation/frontend/PublicFrontendBootstrap.ts +2 -0
  186. package/src/presentation/frontend/PublicFrontendBootstrapFactory.ts +5 -1
  187. package/src/presentation/frontend/PublicFrontendBootstrapJsonCodec.ts +4 -1
  188. package/src/presentation/http/ApiPaths.ts +4 -4
  189. package/src/presentation/http/HeadlessHttpServerFactory.ts +56 -0
  190. package/src/presentation/http/ServerHttpErrorResponseFactory.ts +39 -2
  191. package/src/presentation/http/hono/CodemationHonoApiAppFactory.ts +33 -8
  192. package/src/presentation/http/hono/InternalHonoApiRouteRegistrar.ts +12 -0
  193. package/src/presentation/http/hono/registrars/ManagedMeHonoApiRouteRegistrar.ts +35 -0
  194. package/src/presentation/http/hono/registrars/OAuth2HonoApiRouteRegistrar.ts +2 -2
  195. package/src/presentation/http/routeHandlers/CredentialHttpRouteHandler.ts +28 -0
  196. package/src/presentation/http/routeHandlers/OAuth2HttpRouteHandlerFactory.ts +98 -41
  197. package/src/presentation/server/CodemationConsumerConfigLoader.ts +59 -7
  198. package/src/presentation/server/CodemationPluginDiscovery.ts +5 -0
  199. package/src/presentation/server/WorkflowDefinitionExportsResolver.ts +18 -0
  200. package/src/presentation/server/WorkflowModulePathFinder.ts +12 -1
  201. package/src/presentation/websocket/ManagedWebsocketAuthenticator.ts +50 -0
  202. package/src/presentation/websocket/WebsocketAuthenticator.types.ts +12 -0
  203. package/src/presentation/websocket/WorkflowWebsocketServer.ts +24 -3
  204. package/src/presentation/websocket/WorkflowWebsocketServerFactory.ts +16 -0
  205. package/src/process/ExecaProcessRunner.ts +41 -0
  206. package/src/process/ProcessRunner.types.ts +39 -0
  207. package/src/server.ts +2 -0
  208. package/src/workflows/InternalWorkflowActivationRegistrar.ts +42 -0
  209. package/src/workflows/InternalWorkflowDetailRegistrar.ts +33 -0
  210. package/src/workflows/InternalWorkflowTestRunRegistrar.ts +91 -0
  211. package/src/workflows/InternalWorkflowsListRegistrar.ts +28 -0
  212. package/src/workflows/discovery/WorkflowDirectoryDiscoverer.ts +79 -0
  213. package/tsconfig.json +2 -0
  214. package/vitest.shared.ts +5 -0
  215. package/dist/ApiPaths-CLTHphYZ.js.map +0 -1
  216. package/dist/AppConfigFactory-C6q-CSKb.js.map +0 -1
  217. package/dist/AppContainerFactory-qaqc-R1D.js.map +0 -1
  218. package/dist/CodemationAuthoring.types-DZl-sJaM.js.map +0 -1
  219. package/dist/CodemationConsumerConfigLoader-BeAUS144.js.map +0 -1
  220. package/dist/CredentialServices-CgxwguAv.js.map +0 -1
  221. package/dist/PublicFrontendBootstrapFactory-Cb2pLmDd.d.ts +0 -45
  222. package/dist/PublicFrontendBootstrapJsonCodec-DzqvA0uo.js.map +0 -1
  223. package/dist/ServerLoggerFactory-BKSIh9Xv.js +0 -98
  224. package/dist/ServerLoggerFactory-BKSIh9Xv.js.map +0 -1
  225. package/dist/persistenceServer-vtJAGDat.d.ts +0 -9
  226. package/src/domain/credentials/OAuth2ConnectServiceFactory.ts +0 -411
package/dist/index.d.ts CHANGED
@@ -1,23 +1,25 @@
1
- import "./index-BbBk26m0.js";
2
- import "./ItemsInputNormalizer-C-KHg9Mo.js";
3
- import { a as defineCodemationApp, i as FriendlyCodemationExecutionConfig, n as DefinePluginOptions, o as definePlugin, r as FriendlyCodemationDatabaseConfig, s as workflow, t as DefineCodemationAppOptions } from "./CodemationAuthoring.types-fBRppnmi.js";
4
- import { S as CodemationWorkflowDiscovery, _ as CodemationEngineExecutionLimitsConfig, a as AppPluginLoadSummary, b as CodemationSchedulerConfig, c as CodemationPluginContext, d as CodemationAppSchedulerConfig, f as CodemationAppSchedulerKind, g as CodemationDatabaseKind, h as CodemationDatabaseConfig, l as CodemationPluginPackageMetadata, m as CodemationConfig, n as CodemationRegistrationContextBase, o as CodemationPlugin, p as CodemationApplicationRuntimeConfig, r as AppConfig, s as CodemationPluginConfig, t as CodemationAppContext, u as CodemationAppDefinition, v as CodemationEventBusConfig, w as CodemationClassToken, x as CodemationSchedulerKind, y as CodemationEventBusKind } from "./CodemationAppContext-DRu1Dpri.js";
5
- import { a as CodemationAuthConfig, c as CodemationAuthOidcProviderConfig, i as CodemationLogRule, n as CodemationLogConfig, o as CodemationAuthKind, r as CodemationLogLevelName, s as CodemationAuthOAuthProviderConfig, t as CodemationWhitelabelConfig } from "./CodemationWhitelabelConfig-CWbcyQqn.js";
6
- import "./LogLevelPolicyFactory-CampWO0l.js";
7
- import { a as ApiPaths, i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-Cl_DLRh0.js";
8
- import { a as CodemationFrontendAuthSnapshot, i as CodemationFrontendAuthProviderSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-DzBgwOnG.js";
9
- import "./CodemationConfigNormalizer-DVko3cVN.js";
10
- import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-DJWr86f-.js";
11
- import "./CredentialServices-UfvHB-rN.js";
12
- import "./CredentialContractsRegistry-DrMIDSw8.js";
13
- import "./TelemetryContracts-DbaNomrH.js";
14
- import "./WorkflowViewContracts-CzK2KFuz.js";
15
- import { a as CollectionSummaryDto, f as UpsertLocalBootstrapUserResultDto, i as CollectionRowDto, o as ListCollectionRowsResponseDto, p as UserAccountDto, s as SyncCollectionsResponseDto, t as CollectionDetailDto } from "./CollectionContracts.types-DdpHft0i.js";
16
- import { b as CommandBus, c as FrontendRuntime, g as AppContainerFactory, h as AppContainerLifecycle, m as DatabaseMigrations, n as CodemationBootstrapRequest, p as CollectionSchemaSyncerHolder, r as ApplicationTokens, s as WorkerRuntime, t as CodemationPluginListMerger, v as QueryBus, x as Command, y as Query } from "./CodemationPluginListMerger-DGc-jfa2.js";
17
- import { r as PrismaDatabaseClient, t as AppConfigFactory } from "./AppConfigFactory-YnveXE9k.js";
18
- import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-vtJAGDat.js";
19
- import { c as CodemationServerGateway } from "./server-MUNGsBYK.js";
20
- import { i as CodemationFrontendAuthSnapshotFactory, n as InternalAuthBootstrapFactory, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-Cb2pLmDd.js";
1
+ import "./index-DilAYwnH.js";
2
+ import { $ as PersistedRunState, R as Items, tt as RunCurrentState } from "./ItemsInputNormalizer-_RwIfRIQ.js";
3
+ import { a as defineCodemationApp, i as FriendlyCodemationExecutionConfig, n as DefinePluginOptions, o as definePlugin, r as FriendlyCodemationDatabaseConfig, s as workflow, t as DefineCodemationAppOptions } from "./CodemationAuthoring.types-DiKKogum.js";
4
+ import { S as CodemationWorkflowDiscovery, _ as CodemationEngineExecutionLimitsConfig, a as AppPluginLoadSummary, b as CodemationSchedulerConfig, c as CodemationPluginContext, d as CodemationAppSchedulerConfig, f as CodemationAppSchedulerKind, g as CodemationDatabaseKind, h as CodemationDatabaseConfig, l as CodemationPluginPackageMetadata, m as CodemationConfig, n as CodemationRegistrationContextBase, o as CodemationPlugin, p as CodemationApplicationRuntimeConfig, r as AppConfig, s as CodemationPluginConfig, t as CodemationAppContext, u as CodemationAppDefinition, v as CodemationEventBusConfig, w as CodemationClassToken, x as CodemationSchedulerKind, y as CodemationEventBusKind } from "./CodemationAppContext-CGFYVcSb.js";
5
+ import { a as CodemationAuthConfig, c as CodemationAuthOidcProviderConfig, i as CodemationLogRule, l as Logger, n as CodemationLogConfig, o as CodemationAuthKind, r as CodemationLogLevelName, s as CodemationAuthOAuthProviderConfig, t as CodemationWhitelabelConfig } from "./CodemationWhitelabelConfig-Ca2mCUeC.js";
6
+ import "./LogLevelPolicyFactory-ewCHLDLn.js";
7
+ import { a as ApiPaths, i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-CXG9Dxft.js";
8
+ import { a as CodemationFrontendAuthSnapshot, i as CodemationFrontendAuthProviderSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-Cev3qK46.js";
9
+ import "./CodemationConfigNormalizer-48f-T66P.js";
10
+ import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-_PIYqwVx.js";
11
+ import "./CredentialServices-BLloBztI.js";
12
+ import "./CredentialContractsRegistry-Bq2bq28t.js";
13
+ import "./TelemetryContracts-BtDx84Cp.js";
14
+ import "./WorkflowViewContracts-B7aFQcIw.js";
15
+ import { a as CollectionSummaryDto, f as UpsertLocalBootstrapUserResultDto, i as CollectionRowDto, o as ListCollectionRowsResponseDto, p as UserAccountDto, s as SyncCollectionsResponseDto, t as CollectionDetailDto } from "./CollectionContracts.types-DDyFYT_D.js";
16
+ import { C as Command, S as CommandBus, _ as AppContainerLifecycle, a as CodemationHonoApiApp, b as QueryBus, g as DatabaseMigrations, h as CollectionSchemaSyncerHolder, l as WorkerRuntime, n as CodemationBootstrapRequest, r as ApplicationTokens, t as CodemationPluginListMerger, u as FrontendRuntime, v as AppContainerFactory, x as Query, y as WorkflowWebsocketServer } from "./CodemationPluginListMerger-DP7djJ9S.js";
17
+ import { r as PrismaDatabaseClient, t as AppConfigFactory } from "./AppConfigFactory-BT0y0LVC.js";
18
+ import "./InternalHonoApiRouteRegistrar-c7t3KnV_.js";
19
+ import { i as CodemationFrontendAuthSnapshotFactory, n as InternalAuthBootstrapFactory, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-Dv04tJ-6.js";
20
+ import { n as CodemationPostgresPrismaClientFactory } from "./persistenceServer-B71RGvSj.js";
21
+ import { c as CodemationServerGateway } from "./server-09PKasWR.js";
22
+ import { Server } from "node:http";
21
23
 
22
24
  //#region src/application/queries/ListUserAccountsQuery.d.ts
23
25
  declare class ListUserAccountsQuery extends Query<ReadonlyArray<UserAccountDto>> {}
@@ -29,6 +31,82 @@ declare class UpsertLocalBootstrapUserCommand extends Command<UpsertLocalBootstr
29
31
  constructor(email: string, password: string);
30
32
  }
31
33
  //#endregion
34
+ //#region src/bootstrap/perf/BootTimer.d.ts
35
+ /**
36
+ * Lightweight boot-phase timer. Designed for diagnosing slow `pnpm dev` cold starts.
37
+ *
38
+ * Usage: every meaningful boot phase wraps its async work in
39
+ * `await BootTimer.measureAsync("phase.name", async () => { ... })`
40
+ * (or the sync `measure` for non-async work). When `--trace-boot` is set on the CLI
41
+ * the timer records each phase in a tree, prints a pretty tree to stderr at the end
42
+ * of boot, and writes the same tree to `tmp/boot-trace.json` for diffing later.
43
+ *
44
+ * When disabled (default), every method is a near-zero-cost passthrough — no allocation,
45
+ * no Date.now() calls, no tree construction. Safe to leave instrumentation in production
46
+ * code paths.
47
+ */
48
+ type BootTracePhase = Readonly<{
49
+ name: string;
50
+ ms: number;
51
+ pct: number;
52
+ children: ReadonlyArray<BootTracePhase>;
53
+ }>;
54
+ declare class BootTimer {
55
+ private static enabled;
56
+ private static root;
57
+ private static current;
58
+ /** Enable boot tracing for the lifetime of the current process. Idempotent. */
59
+ static enable(): void;
60
+ static isEnabled(): boolean;
61
+ /** Wrap an async phase. Pass-through when disabled. */
62
+ static measureAsync<T>(name: string, fn: () => Promise<T>): Promise<T>;
63
+ /** Wrap a sync phase. Pass-through when disabled. */
64
+ static measure<T>(name: string, fn: () => T): T;
65
+ /**
66
+ * Manual start/stop for fire-and-forget phases (e.g. a spawned child process you only
67
+ * stop once a readiness probe succeeds). Returns the stop function.
68
+ */
69
+ static start(name: string): () => void;
70
+ /** Print the tree to stderr and write JSON to the given path. Finalizes the root span. */
71
+ static finish(outputJsonPath?: string): Promise<void>;
72
+ /** Return a plain-object snapshot of the current tree (for tests / diffing). */
73
+ static snapshot(): BootTracePhase;
74
+ /** Test helper: reset all state. Do not call in production code. */
75
+ static reset(): void;
76
+ private static pushPhase;
77
+ private static popPhase;
78
+ }
79
+ //#endregion
80
+ //#region src/presentation/websocket/WorkflowWebsocketServerFactory.d.ts
81
+ declare class WorkflowWebsocketServerFactory {
82
+ create(appConfig: AppConfig): WorkflowWebsocketServer;
83
+ }
84
+ //#endregion
85
+ //#region src/presentation/http/HeadlessHttpServerFactory.d.ts
86
+ /**
87
+ * Creates a Node.js http.Server that bridges IncomingMessage to Hono's Fetch API.
88
+ * Used by {@link import("../../bootstrap/runtime/HeadlessApiRuntime").HeadlessApiRuntime}
89
+ * to serve the Hono API without Next.js.
90
+ */
91
+ declare class HeadlessHttpServerFactory {
92
+ create(honoApp: CodemationHonoApiApp, port: number, logger: Logger): Server;
93
+ }
94
+ //#endregion
95
+ //#region src/bootstrap/runtime/HeadlessApiRuntime.d.ts
96
+ /**
97
+ * Boots the Codemation API + WebSocket servers without the Next.js UI process.
98
+ * Used by `codemation serve web --headless` for workspace pod containers where the
99
+ * UI is served externally (e.g. from the control-plane's customer-ui).
100
+ */
101
+ declare class HeadlessApiRuntime {
102
+ private readonly appContainerFactory;
103
+ private readonly websocketServerFactory;
104
+ private readonly httpServerFactory;
105
+ private readonly logger;
106
+ constructor(appContainerFactory: AppContainerFactory, websocketServerFactory: WorkflowWebsocketServerFactory, httpServerFactory: HeadlessHttpServerFactory, logger: Logger);
107
+ start(appConfig: AppConfig): Promise<void>;
108
+ }
109
+ //#endregion
32
110
  //#region src/application/collections/ListCollectionsQuery.d.ts
33
111
  declare class ListCollectionsQuery extends Query<ReadonlyArray<CollectionSummaryDto>> {}
34
112
  //#endregion
@@ -84,10 +162,52 @@ declare class SyncCollectionsCommand extends Command<SyncCollectionsResponseDto>
84
162
  constructor(dryRun: boolean);
85
163
  }
86
164
  //#endregion
165
+ //#region src/application/contracts/RunContracts.d.ts
166
+ type CreateRunRequest = Readonly<{
167
+ workflowId?: string;
168
+ items?: Items;
169
+ synthesizeTriggerItems?: boolean;
170
+ currentState?: RunCurrentState;
171
+ startAt?: string;
172
+ stopAt?: string;
173
+ clearFromNodeId?: string;
174
+ mode?: "manual" | "debug";
175
+ sourceRunId?: string;
176
+ }>;
177
+ type RunCommandResult = Readonly<{
178
+ runId: string;
179
+ workflowId: string;
180
+ startedAt?: string;
181
+ status: string;
182
+ state: PersistedRunState | null;
183
+ }>;
184
+ //#endregion
185
+ //#region src/application/commands/StartWorkflowRunCommand.d.ts
186
+ declare class StartWorkflowRunCommand extends Command<RunCommandResult> {
187
+ readonly body: CreateRunRequest;
188
+ constructor(body: CreateRunRequest);
189
+ }
190
+ //#endregion
191
+ //#region src/application/ApplicationRequestError.d.ts
192
+ declare class ApplicationRequestError extends Error {
193
+ readonly status: number;
194
+ readonly payload: Readonly<{
195
+ error: string;
196
+ errors?: ReadonlyArray<string>;
197
+ }>;
198
+ constructor(status: number, message: string, errors?: ReadonlyArray<string>);
199
+ }
200
+ //#endregion
201
+ //#region src/application/queries/GetRunStateQuery.d.ts
202
+ declare class GetRunStateQuery extends Query<PersistedRunState | undefined> {
203
+ readonly runId: string;
204
+ constructor(runId: string);
205
+ }
206
+ //#endregion
87
207
  //#region src/presentation/config/CodemationPackageManifest.d.ts
88
208
  interface CodemationPackageManifest {
89
209
  readonly plugin?: string;
90
210
  }
91
211
  //#endregion
92
- export { ApiPaths, type AppConfig, AppConfigFactory, AppContainerFactory, AppContainerLifecycle, type AppPluginLoadSummary, ApplicationTokens, type CodemationAppContext, type CodemationAppDefinition, type CodemationAppSchedulerConfig, type CodemationAppSchedulerKind, type CodemationApplicationRuntimeConfig, type CodemationAuthConfig, type CodemationAuthKind, type CodemationAuthOAuthProviderConfig, type CodemationAuthOidcProviderConfig, CodemationBootstrapRequest, type CodemationClassToken, type CodemationConfig, CodemationConsumerConfigLoader, type CodemationDatabaseConfig, type CodemationDatabaseKind, type CodemationEngineExecutionLimitsConfig, type CodemationEventBusConfig, type CodemationEventBusKind, type CodemationFrontendAuthProviderSnapshot, type CodemationFrontendAuthSnapshot, CodemationFrontendAuthSnapshotFactory, CodemationFrontendAuthSnapshotJsonCodec, type CodemationLogConfig, type CodemationLogLevelName, type CodemationLogRule, type CodemationPackageManifest, type CodemationPlugin, type CodemationPluginConfig, type CodemationPluginContext, CodemationPluginListMerger, CodemationPluginPackageMetadata, CodemationPostgresPrismaClientFactory, type CodemationRegistrationContextBase, type CodemationSchedulerConfig, type CodemationSchedulerKind, CodemationServerGateway, type CodemationWhitelabelConfig, type CodemationWorkflowDiscovery, CollectionSchemaSyncerHolder, type CommandBus, DatabaseMigrations, type DefineCodemationAppOptions, type DefinePluginOptions, DeleteCollectionRowCommand, type FriendlyCodemationDatabaseConfig, type FriendlyCodemationExecutionConfig, type FrontendAppConfig, FrontendAppConfigFactory, FrontendAppConfigJsonCodec, FrontendRuntime, GetCollectionQuery, GetCollectionRowQuery, InsertCollectionRowCommand, type InternalAuthBootstrap, InternalAuthBootstrapFactory, InternalAuthBootstrapJsonCodec, ListCollectionRowsQuery, ListCollectionsQuery, ListUserAccountsQuery, type PrismaDatabaseClient as PrismaClient, type PublicFrontendBootstrap, PublicFrontendBootstrapFactory, PublicFrontendBootstrapJsonCodec, type QueryBus, SyncCollectionsCommand, UpdateCollectionRowCommand, UpsertLocalBootstrapUserCommand, type UpsertLocalBootstrapUserResultDto, WorkerRuntime, defineCodemationApp, definePlugin, workflow };
212
+ export { ApiPaths, type AppConfig, AppConfigFactory, AppContainerFactory, AppContainerLifecycle, type AppPluginLoadSummary, ApplicationRequestError, ApplicationTokens, BootTimer, type BootTracePhase, type CodemationAppContext, type CodemationAppDefinition, type CodemationAppSchedulerConfig, type CodemationAppSchedulerKind, type CodemationApplicationRuntimeConfig, type CodemationAuthConfig, type CodemationAuthKind, type CodemationAuthOAuthProviderConfig, type CodemationAuthOidcProviderConfig, CodemationBootstrapRequest, type CodemationClassToken, type CodemationConfig, CodemationConsumerConfigLoader, type CodemationDatabaseConfig, type CodemationDatabaseKind, type CodemationEngineExecutionLimitsConfig, type CodemationEventBusConfig, type CodemationEventBusKind, type CodemationFrontendAuthProviderSnapshot, type CodemationFrontendAuthSnapshot, CodemationFrontendAuthSnapshotFactory, CodemationFrontendAuthSnapshotJsonCodec, type CodemationLogConfig, type CodemationLogLevelName, type CodemationLogRule, type CodemationPackageManifest, type CodemationPlugin, type CodemationPluginConfig, type CodemationPluginContext, CodemationPluginListMerger, CodemationPluginPackageMetadata, CodemationPostgresPrismaClientFactory, type CodemationRegistrationContextBase, type CodemationSchedulerConfig, type CodemationSchedulerKind, CodemationServerGateway, type CodemationWhitelabelConfig, type CodemationWorkflowDiscovery, CollectionSchemaSyncerHolder, type CommandBus, DatabaseMigrations, type DefineCodemationAppOptions, type DefinePluginOptions, DeleteCollectionRowCommand, type FriendlyCodemationDatabaseConfig, type FriendlyCodemationExecutionConfig, type FrontendAppConfig, FrontendAppConfigFactory, FrontendAppConfigJsonCodec, FrontendRuntime, GetCollectionQuery, GetCollectionRowQuery, GetRunStateQuery, HeadlessApiRuntime, HeadlessHttpServerFactory, InsertCollectionRowCommand, type InternalAuthBootstrap, InternalAuthBootstrapFactory, InternalAuthBootstrapJsonCodec, ListCollectionRowsQuery, ListCollectionsQuery, ListUserAccountsQuery, type PrismaDatabaseClient as PrismaClient, type PublicFrontendBootstrap, PublicFrontendBootstrapFactory, PublicFrontendBootstrapJsonCodec, type QueryBus, type RunCommandResult, StartWorkflowRunCommand, SyncCollectionsCommand, UpdateCollectionRowCommand, UpsertLocalBootstrapUserCommand, type UpsertLocalBootstrapUserResultDto, WorkerRuntime, WorkflowWebsocketServerFactory, defineCodemationApp, definePlugin, workflow };
93
213
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,18 +1,113 @@
1
- import { n as definePlugin, t as defineCodemationApp } from "./CodemationAuthoring.types-DZl-sJaM.js";
2
- import "./LogLevelPolicyFactory-DCUzIN6G.js";
3
- import { t as ApiPaths } from "./ApiPaths-CLTHphYZ.js";
4
- import { i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-DzqvA0uo.js";
5
- import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-BeAUS144.js";
6
- import "./ServerLoggerFactory-BKSIh9Xv.js";
1
+ import { n as definePlugin, t as defineCodemationApp } from "./CodemationAuthoring.types-BteaR3Dc.js";
2
+ import { n as logLevelPolicyFactory } from "./LogLevelPolicyFactory-DCUzIN6G.js";
3
+ import { t as ApiPaths } from "./ApiPaths-Dv1dcHu_.js";
4
+ import { i as CodemationFrontendAuthSnapshotJsonCodec, n as InternalAuthBootstrapJsonCodec, r as FrontendAppConfigJsonCodec, t as PublicFrontendBootstrapJsonCodec } from "./PublicFrontendBootstrapJsonCodec-CegIF_ne.js";
5
+ import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-By-6tuGc.js";
6
+ import { o as BootTimer, t as ServerLoggerFactory } from "./ServerLoggerFactory-Ckk52S3w.js";
7
7
  import "./decorateParam-BWxkAUSj.js";
8
8
  import "./decorate-CXWmflG_.js";
9
- import { d as ApplicationTokens } from "./CredentialServices-CgxwguAv.js";
10
- import { D as CodemationFrontendAuthSnapshotFactory, E as FrontendAppConfigFactory, N as UpsertLocalBootstrapUserCommand, P as ListUserAccountsQuery, T as InternalAuthBootstrapFactory, a as GetCollectionQuery, c as InsertCollectionRowCommand, d as FrontendRuntime, f as CollectionSchemaSyncerHolder, i as GetCollectionRowQuery, l as DeleteCollectionRowCommand, m as AppContainerLifecycle, n as ListCollectionsQuery, o as UpdateCollectionRowCommand, p as DatabaseMigrations, r as ListCollectionRowsQuery, s as SyncCollectionsCommand, t as AppContainerFactory, u as WorkerRuntime, w as PublicFrontendBootstrapFactory } from "./AppContainerFactory-qaqc-R1D.js";
11
- import "./WorkflowPolicyUiPresentationFactory-DhPqQ9aB.js";
12
- import { n as CodemationPluginPackageMetadata, t as AppConfigFactory } from "./AppConfigFactory-C6q-CSKb.js";
13
- import { n as CodemationBootstrapRequest, t as CodemationPluginListMerger } from "./CodemationPluginListMerger-B-W5Fa_X.js";
14
- import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-CmsIKnO9.js";
15
- import { r as CodemationServerGateway } from "./server-CJFfY67o.js";
9
+ import { f as ApplicationRequestError, m as ApplicationTokens } from "./CredentialServices-Dk8yypeL.js";
10
+ import "./CodemationTsyringeTypeInfoRegistrar-Bj6FJYFz.js";
11
+ import { C as CodemationHonoApiApp, D as FrontendAppConfigFactory, E as InternalAuthBootstrapFactory, F as StartWorkflowRunCommand, I as UpsertLocalBootstrapUserCommand, L as ListUserAccountsQuery, N as GetRunStateQuery, O as CodemationFrontendAuthSnapshotFactory, T as PublicFrontendBootstrapFactory, a as GetCollectionQuery, c as InsertCollectionRowCommand, d as FrontendRuntime, f as CollectionSchemaSyncerHolder, i as GetCollectionRowQuery, k as WorkflowWebsocketServer, l as DeleteCollectionRowCommand, m as AppContainerLifecycle, n as ListCollectionsQuery, o as UpdateCollectionRowCommand, p as DatabaseMigrations, r as ListCollectionRowsQuery, s as SyncCollectionsCommand, t as AppContainerFactory, u as WorkerRuntime } from "./AppContainerFactory-DRTjG7nG.js";
12
+ import "./WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js";
13
+ import "./InternalPingRegistrar-DY3kSfxP.js";
14
+ import { r as CodemationPluginPackageMetadata, t as AppConfigFactory } from "./AppConfigFactory-Cx4qQvRk.js";
15
+ import { n as CodemationBootstrapRequest, t as CodemationPluginListMerger } from "./CodemationPluginListMerger-D1B1IEbt.js";
16
+ import { t as CodemationPostgresPrismaClientFactory } from "./persistenceServer-C-hH4z6l.js";
17
+ import { r as CodemationServerGateway } from "./server-vtRCPgRJ.js";
16
18
  import { workflow } from "@codemation/core-nodes";
19
+ import { createServer } from "node:http";
17
20
 
18
- export { ApiPaths, AppConfigFactory, AppContainerFactory, AppContainerLifecycle, ApplicationTokens, CodemationBootstrapRequest, CodemationConsumerConfigLoader, CodemationFrontendAuthSnapshotFactory, CodemationFrontendAuthSnapshotJsonCodec, CodemationPluginListMerger, CodemationPluginPackageMetadata, CodemationPostgresPrismaClientFactory, CodemationServerGateway, CollectionSchemaSyncerHolder, DatabaseMigrations, DeleteCollectionRowCommand, FrontendAppConfigFactory, FrontendAppConfigJsonCodec, FrontendRuntime, GetCollectionQuery, GetCollectionRowQuery, InsertCollectionRowCommand, InternalAuthBootstrapFactory, InternalAuthBootstrapJsonCodec, ListCollectionRowsQuery, ListCollectionsQuery, ListUserAccountsQuery, PublicFrontendBootstrapFactory, PublicFrontendBootstrapJsonCodec, SyncCollectionsCommand, UpdateCollectionRowCommand, UpsertLocalBootstrapUserCommand, WorkerRuntime, defineCodemationApp, definePlugin, workflow };
21
+ //#region src/bootstrap/runtime/HeadlessApiRuntime.ts
22
+ /**
23
+ * Boots the Codemation API + WebSocket servers without the Next.js UI process.
24
+ * Used by `codemation serve web --headless` for workspace pod containers where the
25
+ * UI is served externally (e.g. from the control-plane's customer-ui).
26
+ */
27
+ var HeadlessApiRuntime = class {
28
+ constructor(appContainerFactory, websocketServerFactory, httpServerFactory, logger) {
29
+ this.appContainerFactory = appContainerFactory;
30
+ this.websocketServerFactory = websocketServerFactory;
31
+ this.httpServerFactory = httpServerFactory;
32
+ this.logger = logger;
33
+ }
34
+ async start(appConfig) {
35
+ const port = Number(appConfig.env.PORT ?? 4001);
36
+ this.logger.info(`Starting codemation headless API runtime`);
37
+ this.logger.info(`HTTP port: ${port}, WS port: ${appConfig.webSocketPort}`);
38
+ const websocketServer = this.websocketServerFactory.create(appConfig);
39
+ const container = await this.appContainerFactory.create({
40
+ appConfig,
41
+ sharedWorkflowWebsocketServer: websocketServer
42
+ });
43
+ await container.resolve(FrontendRuntime).start();
44
+ const honoApp = container.resolve(CodemationHonoApiApp);
45
+ const httpServer = this.httpServerFactory.create(honoApp, port, this.logger);
46
+ await new Promise((resolve) => {
47
+ httpServer.listen(port, () => {
48
+ this.logger.info(`codemation headless API listening on port ${port}`);
49
+ resolve();
50
+ });
51
+ });
52
+ }
53
+ };
54
+
55
+ //#endregion
56
+ //#region src/presentation/websocket/WorkflowWebsocketServerFactory.ts
57
+ const loggerFactory = new ServerLoggerFactory(logLevelPolicyFactory);
58
+ var WorkflowWebsocketServerFactory = class {
59
+ create(appConfig) {
60
+ return new WorkflowWebsocketServer(appConfig.webSocketPort, appConfig.webSocketBindHost, loggerFactory.create("codemation-websocket.server"));
61
+ }
62
+ };
63
+
64
+ //#endregion
65
+ //#region src/presentation/http/HeadlessHttpServerFactory.ts
66
+ /**
67
+ * Creates a Node.js http.Server that bridges IncomingMessage to Hono's Fetch API.
68
+ * Used by {@link import("../../bootstrap/runtime/HeadlessApiRuntime").HeadlessApiRuntime}
69
+ * to serve the Hono API without Next.js.
70
+ */
71
+ var HeadlessHttpServerFactory = class {
72
+ create(honoApp, port, logger) {
73
+ return createServer((req, res) => {
74
+ const url = new URL(req.url ?? "/", `http://${req.headers.host ?? `127.0.0.1:${port}`}`);
75
+ const headers = new Headers();
76
+ for (const [key, value] of Object.entries(req.headers)) {
77
+ if (value === void 0) continue;
78
+ if (Array.isArray(value)) for (const v of value) headers.append(key, v);
79
+ else headers.set(key, value);
80
+ }
81
+ const chunks = [];
82
+ req.on("data", (chunk) => chunks.push(chunk));
83
+ req.on("end", () => {
84
+ const body = chunks.length > 0 ? Buffer.concat(chunks) : null;
85
+ const fetchRequest = new Request(url, {
86
+ method: req.method ?? "GET",
87
+ headers,
88
+ body: body?.byteLength ? body : void 0,
89
+ duplex: "half"
90
+ });
91
+ Promise.resolve(honoApp.fetch(fetchRequest)).then(async (fetchResponse) => {
92
+ const responseHeaders = {};
93
+ fetchResponse.headers.forEach((value, key) => {
94
+ responseHeaders[key] = value;
95
+ });
96
+ res.writeHead(fetchResponse.status, responseHeaders);
97
+ const responseBody = await fetchResponse.arrayBuffer();
98
+ res.end(Buffer.from(responseBody));
99
+ }).catch((err) => {
100
+ logger.error("Unhandled request error", err instanceof Error ? err : new Error(String(err)));
101
+ if (!res.headersSent) {
102
+ res.writeHead(500);
103
+ res.end("Internal server error");
104
+ }
105
+ });
106
+ });
107
+ });
108
+ }
109
+ };
110
+
111
+ //#endregion
112
+ export { ApiPaths, AppConfigFactory, AppContainerFactory, AppContainerLifecycle, ApplicationRequestError, ApplicationTokens, BootTimer, CodemationBootstrapRequest, CodemationConsumerConfigLoader, CodemationFrontendAuthSnapshotFactory, CodemationFrontendAuthSnapshotJsonCodec, CodemationPluginListMerger, CodemationPluginPackageMetadata, CodemationPostgresPrismaClientFactory, CodemationServerGateway, CollectionSchemaSyncerHolder, DatabaseMigrations, DeleteCollectionRowCommand, FrontendAppConfigFactory, FrontendAppConfigJsonCodec, FrontendRuntime, GetCollectionQuery, GetCollectionRowQuery, GetRunStateQuery, HeadlessApiRuntime, HeadlessHttpServerFactory, InsertCollectionRowCommand, InternalAuthBootstrapFactory, InternalAuthBootstrapJsonCodec, ListCollectionRowsQuery, ListCollectionsQuery, ListUserAccountsQuery, PublicFrontendBootstrapFactory, PublicFrontendBootstrapJsonCodec, StartWorkflowRunCommand, SyncCollectionsCommand, UpdateCollectionRowCommand, UpsertLocalBootstrapUserCommand, WorkerRuntime, WorkflowWebsocketServerFactory, defineCodemationApp, definePlugin, workflow };
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["appContainerFactory: AppContainerFactory","websocketServerFactory: WorkflowWebsocketServerFactory","httpServerFactory: HeadlessHttpServerFactory","logger: Logger","chunks: Buffer[]","responseHeaders: Record<string, string>"],"sources":["../src/bootstrap/runtime/HeadlessApiRuntime.ts","../src/presentation/websocket/WorkflowWebsocketServerFactory.ts","../src/presentation/http/HeadlessHttpServerFactory.ts"],"sourcesContent":["import type { AppConfig } from \"../../presentation/config/AppConfig\";\nimport type { AppContainerFactory } from \"../AppContainerFactory\";\nimport { FrontendRuntime } from \"./FrontendRuntime\";\nimport { CodemationHonoApiApp } from \"../../presentation/http/hono/CodemationHonoApiAppFactory\";\nimport type { WorkflowWebsocketServerFactory } from \"../../presentation/websocket/WorkflowWebsocketServerFactory\";\nimport type { HeadlessHttpServerFactory } from \"../../presentation/http/HeadlessHttpServerFactory\";\nimport type { Logger } from \"../../application/logging/Logger\";\n\n/**\n * Boots the Codemation API + WebSocket servers without the Next.js UI process.\n * Used by `codemation serve web --headless` for workspace pod containers where the\n * UI is served externally (e.g. from the control-plane's customer-ui).\n */\nexport class HeadlessApiRuntime {\n constructor(\n private readonly appContainerFactory: AppContainerFactory,\n private readonly websocketServerFactory: WorkflowWebsocketServerFactory,\n private readonly httpServerFactory: HeadlessHttpServerFactory,\n private readonly logger: Logger,\n ) {}\n\n async start(appConfig: AppConfig): Promise<void> {\n const port = Number(appConfig.env.PORT ?? 4001);\n\n this.logger.info(`Starting codemation headless API runtime`);\n this.logger.info(`HTTP port: ${port}, WS port: ${appConfig.webSocketPort}`);\n\n const websocketServer = this.websocketServerFactory.create(appConfig);\n\n const container = await this.appContainerFactory.create({\n appConfig,\n sharedWorkflowWebsocketServer: websocketServer,\n });\n\n await container.resolve(FrontendRuntime).start();\n\n const honoApp = container.resolve(CodemationHonoApiApp);\n const httpServer = this.httpServerFactory.create(honoApp, port, this.logger);\n\n await new Promise<void>((resolve) => {\n httpServer.listen(port, () => {\n this.logger.info(`codemation headless API listening on port ${port}`);\n resolve();\n });\n });\n }\n}\n","import type { AppConfig } from \"../config/AppConfig\";\nimport { WorkflowWebsocketServer } from \"./WorkflowWebsocketServer\";\nimport { logLevelPolicyFactory } from \"../../infrastructure/logging/LogLevelPolicyFactory\";\nimport { ServerLoggerFactory } from \"../../infrastructure/logging/ServerLoggerFactory\";\n\nconst loggerFactory = new ServerLoggerFactory(logLevelPolicyFactory);\n\nexport class WorkflowWebsocketServerFactory {\n create(appConfig: AppConfig): WorkflowWebsocketServer {\n return new WorkflowWebsocketServer(\n appConfig.webSocketPort,\n appConfig.webSocketBindHost,\n loggerFactory.create(\"codemation-websocket.server\"),\n );\n }\n}\n","import { createServer, type Server } from \"node:http\";\nimport type { Logger } from \"../../application/logging/Logger\";\nimport type { CodemationHonoApiApp } from \"./hono/CodemationHonoApiAppFactory\";\n\n/**\n * Creates a Node.js http.Server that bridges IncomingMessage to Hono's Fetch API.\n * Used by {@link import(\"../../bootstrap/runtime/HeadlessApiRuntime\").HeadlessApiRuntime}\n * to serve the Hono API without Next.js.\n */\nexport class HeadlessHttpServerFactory {\n create(honoApp: CodemationHonoApiApp, port: number, logger: Logger): Server {\n return createServer((req, res) => {\n const url = new URL(req.url ?? \"/\", `http://${req.headers.host ?? `127.0.0.1:${port}`}`);\n const headers = new Headers();\n for (const [key, value] of Object.entries(req.headers)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n for (const v of value) headers.append(key, v);\n } else {\n headers.set(key, value);\n }\n }\n const chunks: Buffer[] = [];\n req.on(\"data\", (chunk: Buffer) => chunks.push(chunk));\n req.on(\"end\", () => {\n // eslint-disable-next-line codemation/no-buffer-everything -- node:http bridge; no streaming alternative when adapting IncomingMessage to Fetch API Request\n const body = chunks.length > 0 ? Buffer.concat(chunks) : null;\n const fetchRequest = new Request(url, {\n method: req.method ?? \"GET\",\n headers,\n body: body?.byteLength ? body : undefined,\n // @ts-expect-error — Node's Request needs duplex for streaming; required in some runtimes\n duplex: \"half\",\n });\n Promise.resolve(honoApp.fetch(fetchRequest))\n .then(async (fetchResponse: Response) => {\n const responseHeaders: Record<string, string> = {};\n fetchResponse.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n res.writeHead(fetchResponse.status, responseHeaders);\n // eslint-disable-next-line codemation/no-buffer-everything -- node:http bridge; Hono Fetch Response must be fully buffered to write to ServerResponse\n const responseBody = await fetchResponse.arrayBuffer();\n res.end(Buffer.from(responseBody));\n })\n .catch((err: unknown) => {\n logger.error(\"Unhandled request error\", err instanceof Error ? err : new Error(String(err)));\n if (!res.headersSent) {\n res.writeHead(500);\n res.end(\"Internal server error\");\n }\n });\n });\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAa,qBAAb,MAAgC;CAC9B,YACE,AAAiBA,qBACjB,AAAiBC,wBACjB,AAAiBC,mBACjB,AAAiBC,QACjB;EAJiB;EACA;EACA;EACA;;CAGnB,MAAM,MAAM,WAAqC;EAC/C,MAAM,OAAO,OAAO,UAAU,IAAI,QAAQ,KAAK;AAE/C,OAAK,OAAO,KAAK,2CAA2C;AAC5D,OAAK,OAAO,KAAK,cAAc,KAAK,aAAa,UAAU,gBAAgB;EAE3E,MAAM,kBAAkB,KAAK,uBAAuB,OAAO,UAAU;EAErE,MAAM,YAAY,MAAM,KAAK,oBAAoB,OAAO;GACtD;GACA,+BAA+B;GAChC,CAAC;AAEF,QAAM,UAAU,QAAQ,gBAAgB,CAAC,OAAO;EAEhD,MAAM,UAAU,UAAU,QAAQ,qBAAqB;EACvD,MAAM,aAAa,KAAK,kBAAkB,OAAO,SAAS,MAAM,KAAK,OAAO;AAE5E,QAAM,IAAI,SAAe,YAAY;AACnC,cAAW,OAAO,YAAY;AAC5B,SAAK,OAAO,KAAK,6CAA6C,OAAO;AACrE,aAAS;KACT;IACF;;;;;;ACvCN,MAAM,gBAAgB,IAAI,oBAAoB,sBAAsB;AAEpE,IAAa,iCAAb,MAA4C;CAC1C,OAAO,WAA+C;AACpD,SAAO,IAAI,wBACT,UAAU,eACV,UAAU,mBACV,cAAc,OAAO,8BAA8B,CACpD;;;;;;;;;;;ACJL,IAAa,4BAAb,MAAuC;CACrC,OAAO,SAA+B,MAAc,QAAwB;AAC1E,SAAO,cAAc,KAAK,QAAQ;GAChC,MAAM,MAAM,IAAI,IAAI,IAAI,OAAO,KAAK,UAAU,IAAI,QAAQ,QAAQ,aAAa,SAAS;GACxF,MAAM,UAAU,IAAI,SAAS;AAC7B,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,QAAQ,EAAE;AACtD,QAAI,UAAU,OAAW;AACzB,QAAI,MAAM,QAAQ,MAAM,CACtB,MAAK,MAAM,KAAK,MAAO,SAAQ,OAAO,KAAK,EAAE;QAE7C,SAAQ,IAAI,KAAK,MAAM;;GAG3B,MAAMC,SAAmB,EAAE;AAC3B,OAAI,GAAG,SAAS,UAAkB,OAAO,KAAK,MAAM,CAAC;AACrD,OAAI,GAAG,aAAa;IAElB,MAAM,OAAO,OAAO,SAAS,IAAI,OAAO,OAAO,OAAO,GAAG;IACzD,MAAM,eAAe,IAAI,QAAQ,KAAK;KACpC,QAAQ,IAAI,UAAU;KACtB;KACA,MAAM,MAAM,aAAa,OAAO;KAEhC,QAAQ;KACT,CAAC;AACF,YAAQ,QAAQ,QAAQ,MAAM,aAAa,CAAC,CACzC,KAAK,OAAO,kBAA4B;KACvC,MAAMC,kBAA0C,EAAE;AAClD,mBAAc,QAAQ,SAAS,OAAO,QAAQ;AAC5C,sBAAgB,OAAO;OACvB;AACF,SAAI,UAAU,cAAc,QAAQ,gBAAgB;KAEpD,MAAM,eAAe,MAAM,cAAc,aAAa;AACtD,SAAI,IAAI,OAAO,KAAK,aAAa,CAAC;MAClC,CACD,OAAO,QAAiB;AACvB,YAAO,MAAM,2BAA2B,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,IAAI,CAAC,CAAC;AAC5F,SAAI,CAAC,IAAI,aAAa;AACpB,UAAI,UAAU,IAAI;AAClB,UAAI,IAAI,wBAAwB;;MAElC;KACJ;IACF"}
package/dist/mapping.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import "./ItemsInputNormalizer-C-KHg9Mo.js";
2
- import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-DQEY-h_S.js";
1
+ import "./ItemsInputNormalizer-_RwIfRIQ.js";
2
+ import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-6MyjCvBO.js";
3
3
  export { WorkflowPolicyUiPresentationFactory };
package/dist/mapping.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-DhPqQ9aB.js";
1
+ import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js";
2
2
 
3
3
  export { WorkflowPolicyUiPresentationFactory };
@@ -1,19 +1,20 @@
1
- import { t as RunIntentService } from "./index-BbBk26m0.js";
2
- import { Ct as CredentialTypeDefinition, E as WebhookInvocationMatch, F as BinaryAttachment, G as RunIdFactory, I as Item, J as WorkflowDefinition, P as ActivationIdFactory, _t as CredentialOAuth2AuthDefinition, o as BinaryStorage, w as WorkflowActivationPolicy } from "./ItemsInputNormalizer-C-KHg9Mo.js";
3
- import { r as AppConfig } from "./CodemationAppContext-DRu1Dpri.js";
4
- import { l as Logger, u as LoggerFactory } from "./CodemationWhitelabelConfig-CWbcyQqn.js";
5
- import { n as logLevelPolicyFactory, t as LogLevelPolicyFactory } from "./LogLevelPolicyFactory-CampWO0l.js";
6
- import { a as CodemationFrontendAuthSnapshot, i as CodemationFrontendAuthProviderSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-DzBgwOnG.js";
7
- import "./CodemationConfigNormalizer-DVko3cVN.js";
8
- import { a as CredentialInstanceService, c as CredentialSecretCipher, i as CredentialBindingService, l as CredentialFieldEnvOverlayService, o as CredentialOAuth2ScopeResolver, r as CredentialRuntimeMaterialService, s as CredentialMaterialResolver, t as CredentialStore, u as CredentialTypeRegistryImpl } from "./CredentialServices-UfvHB-rN.js";
9
- import "./CredentialContractsRegistry-DrMIDSw8.js";
10
- import "./TelemetryContracts-DbaNomrH.js";
11
- import { i as WorkflowSummary, t as WorkflowDto } from "./WorkflowViewContracts-CzK2KFuz.js";
12
- import { _ as WorkflowWebsocketServer, a as WorkflowDebuggerOverlayRepository, b as CommandBus, c as FrontendRuntime, d as LogFilter, f as WorkflowRunRepository, g as AppContainerFactory, h as AppContainerLifecycle, i as HonoApiRouteRegistrar, l as WorkflowRunRetentionPruneScheduler, m as DatabaseMigrations, n as CodemationBootstrapRequest, o as SessionVerifier, r as ApplicationTokens, s as WorkerRuntime, t as CodemationPluginListMerger, u as ServerLoggerFactory, v as QueryBus } from "./CodemationPluginListMerger-DGc-jfa2.js";
13
- import { t as AppConfigFactory } from "./AppConfigFactory-YnveXE9k.js";
14
- import { n as InternalAuthBootstrapFactory, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-Cb2pLmDd.js";
15
- import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-DQEY-h_S.js";
16
- import { Hono } from "hono";
1
+ import { n as RunIntentService, t as OAuthFlowExecutor } from "./index-DilAYwnH.js";
2
+ import { D as WebhookInvocationMatch, F as ActivationIdFactory, I as BinaryAttachment, L as Item, X as WorkflowDefinition, o as BinaryStorage, q as RunIdFactory, w as WorkflowActivationPolicy } from "./ItemsInputNormalizer-_RwIfRIQ.js";
3
+ import { r as AppConfig } from "./CodemationAppContext-CGFYVcSb.js";
4
+ import { l as Logger, u as LoggerFactory } from "./CodemationWhitelabelConfig-Ca2mCUeC.js";
5
+ import { n as logLevelPolicyFactory, t as LogLevelPolicyFactory } from "./LogLevelPolicyFactory-ewCHLDLn.js";
6
+ import { a as CodemationFrontendAuthSnapshot, i as CodemationFrontendAuthProviderSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-Cev3qK46.js";
7
+ import "./CodemationConfigNormalizer-48f-T66P.js";
8
+ import { a as CredentialSecretCipher, i as CredentialInstanceService, o as McpServerCatalog, r as CredentialBindingService, t as CredentialStore } from "./CredentialServices-BLloBztI.js";
9
+ import "./CredentialContractsRegistry-Bq2bq28t.js";
10
+ import "./TelemetryContracts-BtDx84Cp.js";
11
+ import { i as WorkflowSummary, t as WorkflowDto } from "./WorkflowViewContracts-B7aFQcIw.js";
12
+ import { S as CommandBus, _ as AppContainerLifecycle, a as CodemationHonoApiApp, b as QueryBus, c as SessionVerifier, d as WorkflowRunRetentionPruneScheduler, f as ServerLoggerFactory, g as DatabaseMigrations, i as WorkflowDebuggerOverlayRepository, l as WorkerRuntime, m as WorkflowRunRepository, n as CodemationBootstrapRequest, o as BinaryHttpRouteHandler, p as LogFilter, r as ApplicationTokens, s as ServerHttpRouteParams, t as CodemationPluginListMerger, u as FrontendRuntime, v as AppContainerFactory, y as WorkflowWebsocketServer } from "./CodemationPluginListMerger-DP7djJ9S.js";
13
+ import { t as AppConfigFactory } from "./AppConfigFactory-BT0y0LVC.js";
14
+ import "./InternalHonoApiRouteRegistrar-c7t3KnV_.js";
15
+ import { n as InternalAuthBootstrapFactory, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-Dv04tJ-6.js";
16
+ import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-6MyjCvBO.js";
17
+ import { t as PairingConfig } from "./pairing.types-snfZ_OzB.js";
17
18
 
18
19
  //#region src/application/dev/DevBootstrapSummaryJson.types.d.ts
19
20
  type DevBootstrapSummaryJson = Readonly<{
@@ -91,7 +92,8 @@ interface DataMapper<TSource, TTarget> {
91
92
  declare class WorkflowDefinitionMapper implements DataMapper<WorkflowDefinition, WorkflowDto> {
92
93
  private readonly policyUi;
93
94
  private readonly workflowActivationPolicy;
94
- constructor(policyUi: WorkflowPolicyUiPresentationFactory, workflowActivationPolicy: WorkflowActivationPolicy);
95
+ private readonly mcpCatalog;
96
+ constructor(policyUi: WorkflowPolicyUiPresentationFactory, workflowActivationPolicy: WorkflowActivationPolicy, mcpCatalog: McpServerCatalog);
95
97
  map(workflow: WorkflowDefinition): Promise<WorkflowDto>;
96
98
  mapSync(workflow: WorkflowDefinition): WorkflowDto;
97
99
  toSummary(workflow: WorkflowDefinition): WorkflowSummary;
@@ -109,6 +111,7 @@ declare class WorkflowDefinitionMapper implements DataMapper<WorkflowDefinition,
109
111
  * Omit optional port fields when undefined so persisted snapshot DTOs (which never serialize
110
112
  * undefined keys) stay aligned with live workflow mapping.
111
113
  */
114
+ private readInspectorSummary;
112
115
  private nodePortFieldsFromConfig;
113
116
  private nodeTypeName;
114
117
  }
@@ -128,36 +131,13 @@ declare class RequestToWebhookItemMapper {
128
131
  private toQuery;
129
132
  }
130
133
  //#endregion
131
- //#region src/presentation/http/ServerHttpRouteParams.d.ts
132
- type ServerHttpRouteParams = Readonly<Record<string, string>>;
133
- //#endregion
134
- //#region src/presentation/http/routeHandlers/BinaryHttpRouteHandlerFactory.d.ts
135
- declare class BinaryHttpRouteHandler {
136
- private readonly queryBus;
137
- private readonly commandBus;
138
- private readonly binaryStorage;
139
- constructor(queryBus: QueryBus, commandBus: CommandBus, binaryStorage: BinaryStorage);
140
- getRunBinaryContent(_: Request, params: ServerHttpRouteParams): Promise<Response>;
141
- getWorkflowOverlayBinaryContent(_: Request, params: ServerHttpRouteParams): Promise<Response>;
142
- postWorkflowDebuggerOverlayBinaryUpload(request: Request, params: ServerHttpRouteParams): Promise<Response>;
143
- private createBinaryResponse;
144
- private createContentDisposition;
145
- private escapeFilename;
146
- }
147
- //#endregion
148
- //#region src/presentation/http/hono/CodemationHonoApiAppFactory.d.ts
149
- declare class CodemationHonoApiApp {
150
- private readonly app;
151
- constructor(sessionVerifier: SessionVerifier, registrars: ReadonlyArray<HonoApiRouteRegistrar>, binaryHttpRouteHandler: BinaryHttpRouteHandler);
152
- getHono(): Hono;
153
- fetch(request: Request): Response | Promise<Response>;
154
- }
155
- //#endregion
156
134
  //#region src/presentation/http/routeHandlers/CredentialHttpRouteHandler.d.ts
157
135
  declare class CredentialHttpRouteHandler {
158
136
  private readonly queryBus;
159
137
  private readonly commandBus;
160
- constructor(queryBus: QueryBus, commandBus: CommandBus);
138
+ private readonly sessionVerifier;
139
+ private readonly pairingConfig;
140
+ constructor(queryBus: QueryBus, commandBus: CommandBus, sessionVerifier: SessionVerifier, pairingConfig: PairingConfig | null);
161
141
  getCredentialTypes(): Promise<Response>;
162
142
  getCredentialFieldEnvStatus(): Promise<Response>;
163
143
  getCredentialInstances(): Promise<Response>;
@@ -170,87 +150,36 @@ declare class CredentialHttpRouteHandler {
170
150
  getWorkflowCredentialHealth(_: Request, params: ServerHttpRouteParams): Promise<Response>;
171
151
  }
172
152
  //#endregion
173
- //#region src/domain/credentials/OAuth2ProviderRegistry.d.ts
174
- type JsonRecord = Readonly<Record<string, unknown>>;
175
- type OAuth2ResolvedProvider = Readonly<{
176
- providerId: string;
177
- authorizeUrl: string;
178
- tokenUrl: string;
179
- userInfoUrl?: string;
180
- }>;
181
- declare class OAuth2ProviderRegistry {
182
- private static readonly googleProvider;
183
- resolve(definition: CredentialTypeDefinition, publicConfig: JsonRecord): OAuth2ResolvedProvider;
184
- resolveClientId(auth: CredentialOAuth2AuthDefinition, publicConfig: JsonRecord): string;
185
- resolveClientSecretFieldKey(auth: CredentialOAuth2AuthDefinition): string;
186
- private resolveBuiltInProvider;
187
- private resolveTemplateProvider;
188
- private expandTemplate;
189
- private resolvePublicConfigProvider;
190
- }
191
- //#endregion
192
- //#region src/domain/credentials/OAuth2ConnectServiceFactory.d.ts
193
- type OAuth2AuthRedirectResult = Readonly<{
194
- instanceId: string;
195
- redirectUri: string;
196
- redirectUrl: string;
197
- }>;
198
- type OAuth2CallbackResult = Readonly<{
199
- instanceId: string;
200
- connectedEmail?: string;
201
- }>;
202
- declare class OAuth2ConnectService {
203
- private readonly credentialStore;
204
- private readonly credentialInstanceService;
205
- private readonly credentialTypeRegistry;
206
- private readonly credentialRuntimeMaterialService;
207
- private readonly credentialFieldEnvOverlayService;
208
- private readonly credentialMaterialResolver;
209
- private readonly credentialSecretCipher;
210
- private readonly credentialOAuth2ScopeResolver;
211
- private readonly oauth2ProviderRegistry;
153
+ //#region src/domain/credentials/OAuth2RedirectUriResolver.d.ts
154
+ /**
155
+ * Resolves the canonical OAuth2 redirect URI from the public base URL or request origin.
156
+ * The redirect URI always points to `/api/oauth2/callback`, which is the URL operators
157
+ * register with their OAuth provider.
158
+ */
159
+ declare class OAuth2RedirectUriResolver {
212
160
  private readonly appConfig;
213
- private static readonly stateTtlMs;
214
- constructor(credentialStore: CredentialStore, credentialInstanceService: CredentialInstanceService, credentialTypeRegistry: CredentialTypeRegistryImpl, credentialRuntimeMaterialService: CredentialRuntimeMaterialService, credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService, credentialMaterialResolver: CredentialMaterialResolver, credentialSecretCipher: CredentialSecretCipher, credentialOAuth2ScopeResolver: CredentialOAuth2ScopeResolver, oauth2ProviderRegistry: OAuth2ProviderRegistry, appConfig: AppConfig);
215
- createAuthRedirect(instanceId: string, requestOrigin: string): Promise<OAuth2AuthRedirectResult>;
216
- handleCallback(args: Readonly<{
217
- code?: string | null;
218
- state?: string | null;
219
- requestOrigin: string;
220
- }>): Promise<OAuth2CallbackResult>;
221
- getRedirectUri(requestOrigin: string): string;
161
+ constructor(appConfig: AppConfig);
162
+ resolve(requestOrigin: string): string;
222
163
  /**
223
- * `new URL(path, base)` requires `base` to be an absolute URL with a scheme.
224
- * Misconfigured CODEMATION_PUBLIC_BASE_URL (e.g. `localhost:3000` without http://) or odd
225
- * forwarded headers otherwise throw TypeError: Invalid URL.
226
- *
227
- * Comma-separated values (proxy chains or copy-paste mistakes like `http,http`) use the
228
- * first segment only; obviously invalid hostnames are rejected.
164
+ * Ensures the base URL has an http/https scheme. Comma-separated values (proxy chains) use
165
+ * the first segment only.
229
166
  */
230
- private ensureAbsoluteUrlForOAuth2Base;
231
- private requireOAuth2Type;
232
- private exchangeAuthorizationCode;
233
- private mergeTokenMaterial;
234
- private resolveExpiry;
235
- private resolveGrantedScopes;
236
- private resolveConnectedEmail;
237
- private findEmail;
238
- private parseJsonRecord;
239
- private createTokenExchangeErrorMessage;
240
- private createOpaqueValue;
241
- private createPkceCodeChallenge;
167
+ private ensureAbsoluteUrl;
242
168
  private normalizeBaseUrl;
243
169
  }
244
170
  //#endregion
245
171
  //#region src/presentation/http/routeHandlers/OAuth2HttpRouteHandlerFactory.d.ts
246
172
  declare class OAuth2HttpRouteHandler {
247
- private readonly oauth2ConnectService;
173
+ private readonly redirectUriResolver;
248
174
  private readonly credentialInstanceService;
249
- constructor(oauth2ConnectService: OAuth2ConnectService, credentialInstanceService: CredentialInstanceService);
250
- getAuthRedirect(request: Request): Promise<Response>;
251
- getCallback(request: Request): Promise<Response>;
175
+ private readonly oauthFlowExecutor;
176
+ private readonly credentialStore;
177
+ private readonly credentialSecretCipher;
178
+ constructor(redirectUriResolver: OAuth2RedirectUriResolver, credentialInstanceService: CredentialInstanceService, oauthFlowExecutor: OAuthFlowExecutor, credentialStore: CredentialStore, credentialSecretCipher: CredentialSecretCipher);
252
179
  getRedirectUri(request: Request): Promise<Response>;
253
180
  postDisconnect(request: Request): Promise<Response>;
181
+ postOAuthStart(request: Request): Promise<Response>;
182
+ getOAuthCallback(request: Request): Promise<Response>;
254
183
  private resolveRequestOrigin;
255
184
  /** Proxies may send comma-separated lists (chain); use the first host/proto only. */
256
185
  private static firstCommaSeparatedValue;
@@ -1,12 +1,14 @@
1
1
  import { n as logLevelPolicyFactory, t as LogLevelPolicyFactory } from "./LogLevelPolicyFactory-DCUzIN6G.js";
2
- import "./ApiPaths-CLTHphYZ.js";
3
- import { a as FilteringLogger, i as PerformanceLogPolicy, n as PerformanceLogPolicyFactory, r as performanceLogPolicyFactory, t as ServerLoggerFactory } from "./ServerLoggerFactory-BKSIh9Xv.js";
2
+ import "./ApiPaths-Dv1dcHu_.js";
3
+ import { a as FilteringLogger, i as PerformanceLogPolicy, n as PerformanceLogPolicyFactory, r as performanceLogPolicyFactory, t as ServerLoggerFactory } from "./ServerLoggerFactory-Ckk52S3w.js";
4
4
  import "./decorateParam-BWxkAUSj.js";
5
5
  import "./decorate-CXWmflG_.js";
6
- import { a as CredentialInstanceService, d as ApplicationTokens, i as CredentialBindingService } from "./CredentialServices-CgxwguAv.js";
7
- import { C as BinaryHttpRouteHandler, E as FrontendAppConfigFactory, M as RunBinaryAttachmentLookupService, O as WorkflowWebsocketServer, S as CodemationHonoApiApp, T as InternalAuthBootstrapFactory, _ as WebhookHttpRouteHandler, b as OAuth2HttpRouteHandler, d as FrontendRuntime, g as WorkflowHttpRouteHandler, h as WorkflowRunRetentionPruneScheduler, k as WorkflowDefinitionMapper, m as AppContainerLifecycle, p as DatabaseMigrations, t as AppContainerFactory, u as WorkerRuntime, v as RequestToWebhookItemMapper, w as PublicFrontendBootstrapFactory, x as CredentialHttpRouteHandler, y as RunHttpRouteHandler } from "./AppContainerFactory-qaqc-R1D.js";
8
- import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-DhPqQ9aB.js";
9
- import { t as AppConfigFactory } from "./AppConfigFactory-C6q-CSKb.js";
10
- import { n as CodemationBootstrapRequest, t as CodemationPluginListMerger } from "./CodemationPluginListMerger-B-W5Fa_X.js";
6
+ import { a as CredentialInstanceService, i as CredentialBindingService, m as ApplicationTokens } from "./CredentialServices-Dk8yypeL.js";
7
+ import "./CodemationTsyringeTypeInfoRegistrar-Bj6FJYFz.js";
8
+ import { A as WorkflowDefinitionMapper, C as CodemationHonoApiApp, D as FrontendAppConfigFactory, E as InternalAuthBootstrapFactory, P as RunBinaryAttachmentLookupService, S as CredentialHttpRouteHandler, T as PublicFrontendBootstrapFactory, _ as WorkflowHttpRouteHandler, b as RunHttpRouteHandler, d as FrontendRuntime, h as WorkflowRunRetentionPruneScheduler, k as WorkflowWebsocketServer, m as AppContainerLifecycle, p as DatabaseMigrations, t as AppContainerFactory, u as WorkerRuntime, v as WebhookHttpRouteHandler, w as BinaryHttpRouteHandler, x as OAuth2HttpRouteHandler, y as RequestToWebhookItemMapper } from "./AppContainerFactory-DRTjG7nG.js";
9
+ import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js";
10
+ import "./InternalPingRegistrar-DY3kSfxP.js";
11
+ import { t as AppConfigFactory } from "./AppConfigFactory-Cx4qQvRk.js";
12
+ import { n as CodemationBootstrapRequest, t as CodemationPluginListMerger } from "./CodemationPluginListMerger-D1B1IEbt.js";
11
13
 
12
14
  export { AppConfigFactory, AppContainerFactory, AppContainerLifecycle, ApplicationTokens, BinaryHttpRouteHandler, CodemationBootstrapRequest, CodemationHonoApiApp, CodemationPluginListMerger, CredentialBindingService, CredentialHttpRouteHandler, CredentialInstanceService, DatabaseMigrations, FilteringLogger, FrontendAppConfigFactory, FrontendRuntime, InternalAuthBootstrapFactory, LogLevelPolicyFactory, OAuth2HttpRouteHandler, PerformanceLogPolicy, PerformanceLogPolicyFactory, PublicFrontendBootstrapFactory, RequestToWebhookItemMapper, RunBinaryAttachmentLookupService, RunHttpRouteHandler, ServerLoggerFactory, WebhookHttpRouteHandler, WorkerRuntime, WorkflowDefinitionMapper, WorkflowHttpRouteHandler, WorkflowPolicyUiPresentationFactory, WorkflowRunRetentionPruneScheduler, WorkflowWebsocketServer, logLevelPolicyFactory, performanceLogPolicyFactory };