@codemation/core 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 +30 -0
- package/dist/EngineExecutionLimitsPolicy-8MEFIYx1.d.cts +160 -0
- package/dist/EngineExecutionLimitsPolicy-BWAXW9D6.d.cts +160 -0
- package/dist/EngineExecutionLimitsPolicy-Bp8PS1Ss.d.cts +159 -0
- package/dist/EngineExecutionLimitsPolicy-CLxcN-D2.d.ts +159 -0
- package/dist/EngineExecutionLimitsPolicy-DZXuix51.d.ts +160 -0
- package/dist/EngineExecutionLimitsPolicy-Gfz6ngFd.d.ts +160 -0
- package/dist/EngineFactory-CBnntY3J.cjs +3152 -0
- package/dist/EngineFactory-CBnntY3J.cjs.map +1 -0
- package/dist/EngineFactory-Cwn3R2YA.js +3087 -0
- package/dist/EngineFactory-Cwn3R2YA.js.map +1 -0
- package/dist/EngineFactory-DWCnNocp.js +3063 -0
- package/dist/EngineFactory-DWCnNocp.js.map +1 -0
- package/dist/EngineFactory-DhPFou4p.cjs +3188 -0
- package/dist/EngineFactory-DhPFou4p.cjs.map +1 -0
- package/dist/EngineFactory-l_9xmBtv.cjs +3190 -0
- package/dist/EngineFactory-l_9xmBtv.cjs.map +1 -0
- package/dist/EngineFactory-w-aOWuqh.js +3089 -0
- package/dist/EngineFactory-w-aOWuqh.js.map +1 -0
- package/dist/InMemoryLiveWorkflowRepository-1J9MHN_I.js +18 -0
- package/dist/InMemoryLiveWorkflowRepository-1J9MHN_I.js.map +1 -0
- package/dist/InMemoryLiveWorkflowRepository-BTzHpQ6e.cjs +151 -0
- package/dist/InMemoryLiveWorkflowRepository-BTzHpQ6e.cjs.map +1 -0
- package/dist/InMemoryLiveWorkflowRepository-BoLNnVLg.js +139 -0
- package/dist/InMemoryLiveWorkflowRepository-BoLNnVLg.js.map +1 -0
- package/dist/InMemoryLiveWorkflowRepository-CULNqv96.d.ts +1300 -0
- package/dist/InMemoryLiveWorkflowRepository-D6eiiXxF.d.cts +1168 -0
- package/dist/InMemoryLiveWorkflowRepository-D7l8cjdZ.d.cts +1130 -0
- package/dist/InMemoryLiveWorkflowRepository-DL7LmC9S.d.ts +1340 -0
- package/dist/InMemoryLiveWorkflowRepository-jnv-OnOP.d.ts +1300 -0
- package/dist/InMemoryLiveWorkflowRepository-xny1_Z6i.cjs +24 -0
- package/dist/InMemoryLiveWorkflowRepository-xny1_Z6i.cjs.map +1 -0
- package/dist/InMemoryLiveWorkflowRepository-xr7b4kvi.d.ts +1338 -0
- package/dist/InMemoryWorkflowCatalog-BIdFpwbK.d.ts +1205 -0
- package/dist/InMemoryWorkflowCatalog-BW00_3N3.d.cts +12 -0
- package/dist/InMemoryWorkflowCatalog-BiYHGoPw.cjs +24 -0
- package/dist/InMemoryWorkflowCatalog-BiYHGoPw.cjs.map +1 -0
- package/dist/InMemoryWorkflowCatalog-BrG0ApMO.d.cts +1115 -0
- package/dist/InMemoryWorkflowCatalog-BzrAr--Y.js +139 -0
- package/dist/InMemoryWorkflowCatalog-BzrAr--Y.js.map +1 -0
- package/dist/InMemoryWorkflowCatalog-C-EJlJ7y.d.cts +1120 -0
- package/dist/InMemoryWorkflowCatalog-C4482bpw.cjs +24 -0
- package/dist/InMemoryWorkflowCatalog-C4482bpw.cjs.map +1 -0
- package/dist/InMemoryWorkflowCatalog-CZ0kZpOv.d.ts +1289 -0
- package/dist/InMemoryWorkflowCatalog-C_ACeLyW.d.cts +1119 -0
- package/dist/InMemoryWorkflowCatalog-CiHWIu5E.d.cts +12 -0
- package/dist/InMemoryWorkflowCatalog-CkH7gkya.js +18 -0
- package/dist/InMemoryWorkflowCatalog-CkH7gkya.js.map +1 -0
- package/dist/InMemoryWorkflowCatalog-CnpZVJM9.d.ts +1205 -0
- package/dist/InMemoryWorkflowCatalog-Cu68S8YR.js +18 -0
- package/dist/InMemoryWorkflowCatalog-Cu68S8YR.js.map +1 -0
- package/dist/InMemoryWorkflowCatalog-D2w9nMj2.cjs +151 -0
- package/dist/InMemoryWorkflowCatalog-D2w9nMj2.cjs.map +1 -0
- package/dist/InMemoryWorkflowCatalog-D5eMxEf7.js +18 -0
- package/dist/InMemoryWorkflowCatalog-D5eMxEf7.js.map +1 -0
- package/dist/InMemoryWorkflowCatalog-D5nCp2yZ.d.ts +1267 -0
- package/dist/InMemoryWorkflowCatalog-DIq0bjqN.d.ts +12 -0
- package/dist/InMemoryWorkflowCatalog-DLgaEaw_.d.ts +1288 -0
- package/dist/InMemoryWorkflowCatalog-DNBFdK-x.d.cts +1120 -0
- package/dist/InMemoryWorkflowCatalog-DQBkCzb7.cjs +24 -0
- package/dist/InMemoryWorkflowCatalog-DQBkCzb7.cjs.map +1 -0
- package/dist/InMemoryWorkflowCatalog-DS4-eX6i.d.cts +1118 -0
- package/dist/InMemoryWorkflowCatalog-DdVfy8MY.d.ts +12 -0
- package/dist/InMemoryWorkflowCatalog-DeVZu3g8.d.ts +12 -0
- package/dist/InMemoryWorkflowCatalog-GxkQjvt5.d.ts +1200 -0
- package/dist/InMemoryWorkflowCatalog-qaVRn1Lc.d.cts +1115 -0
- package/dist/InMemoryWorkflowCatalog-z1aIT4TC.d.cts +12 -0
- package/dist/InMemoryWorkflowRegistry-BBuOovLL.d.ts +1007 -0
- package/dist/InMemoryWorkflowRegistry-BIFnSl3k.d.ts +1201 -0
- package/dist/InMemoryWorkflowRegistry-BnGilthz.d.ts +1137 -0
- package/dist/InMemoryWorkflowRegistry-CEp5I8No.d.ts +1146 -0
- package/dist/InMemoryWorkflowRegistry-CHyMB9jW.d.cts +976 -0
- package/dist/InMemoryWorkflowRegistry-CUN7K86m.d.cts +1061 -0
- package/dist/InMemoryWorkflowRegistry-CVfHyELh.d.cts +971 -0
- package/dist/InMemoryWorkflowRegistry-CXXJrwAr.d.cts +1052 -0
- package/dist/InMemoryWorkflowRegistry-DDGfPTJy.d.ts +1013 -0
- package/dist/InMemoryWorkflowRegistry-DnYSOoT5.d.ts +1120 -0
- package/dist/InMemoryWorkflowRegistry-Dp5GiFF2.d.cts +1035 -0
- package/dist/InMemoryWorkflowRegistry-DypDBeOw.d.cts +1116 -0
- package/dist/InMemoryWorkflowRegistry-SzwJCAxT.d.ts +1012 -0
- package/dist/InMemoryWorkflowRegistry-jupvqyGc.d.cts +977 -0
- package/dist/InMemoryWorkflowRegistry-rAdKVWYT.d.ts +1117 -0
- package/dist/InProcessRetryRunner-BBNPkXjy.d.cts +292 -0
- package/dist/PersistedWorkflowSnapshotFactory-7RkOL3Kg.d.ts +14 -0
- package/dist/PersistedWorkflowSnapshotFactory-BmANa46W.cjs +141 -0
- package/dist/PersistedWorkflowSnapshotFactory-BmANa46W.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Bwb_etSt.js +118 -0
- package/dist/PersistedWorkflowSnapshotFactory-Bwb_etSt.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-CRkKGNV6.js +123 -0
- package/dist/PersistedWorkflowSnapshotFactory-CRkKGNV6.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-CZolnGy5.js +101 -0
- package/dist/PersistedWorkflowSnapshotFactory-CZolnGy5.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Ca_oysOv.cjs +131 -0
- package/dist/PersistedWorkflowSnapshotFactory-Ca_oysOv.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-CqIcShnX.js +103 -0
- package/dist/PersistedWorkflowSnapshotFactory-CqIcShnX.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-D-tBk4_G.js +119 -0
- package/dist/PersistedWorkflowSnapshotFactory-D-tBk4_G.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-D4cXl2e2.cjs +131 -0
- package/dist/PersistedWorkflowSnapshotFactory-D4cXl2e2.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-DINoP12r.cjs +131 -0
- package/dist/PersistedWorkflowSnapshotFactory-DINoP12r.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-DJAwSuHU.js +103 -0
- package/dist/PersistedWorkflowSnapshotFactory-DJAwSuHU.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-DSUjVCcf.cjs +131 -0
- package/dist/PersistedWorkflowSnapshotFactory-DSUjVCcf.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-DdHuhkDb.cjs +107 -0
- package/dist/PersistedWorkflowSnapshotFactory-DdHuhkDb.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Dqc6NHis.js +119 -0
- package/dist/PersistedWorkflowSnapshotFactory-Dqc6NHis.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Dxa2dSrw.cjs +130 -0
- package/dist/PersistedWorkflowSnapshotFactory-Dxa2dSrw.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Ep79Ah1G.js +123 -0
- package/dist/PersistedWorkflowSnapshotFactory-Ep79Ah1G.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-GyLfRuiJ.js +119 -0
- package/dist/PersistedWorkflowSnapshotFactory-GyLfRuiJ.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-HTpBsBzn.js +102 -0
- package/dist/PersistedWorkflowSnapshotFactory-HTpBsBzn.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-LVmaaf3t.cjs +141 -0
- package/dist/PersistedWorkflowSnapshotFactory-LVmaaf3t.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-PZCpo2ZS.js +119 -0
- package/dist/PersistedWorkflowSnapshotFactory-PZCpo2ZS.js.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-UjQ1SJev.cjs +109 -0
- package/dist/PersistedWorkflowSnapshotFactory-UjQ1SJev.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Y8kCrhcy.cjs +109 -0
- package/dist/PersistedWorkflowSnapshotFactory-Y8kCrhcy.cjs.map +1 -0
- package/dist/PersistedWorkflowSnapshotFactory-Z_nB-fmB.cjs +108 -0
- package/dist/PersistedWorkflowSnapshotFactory-Z_nB-fmB.cjs.map +1 -0
- package/dist/RunIntentService-1EE6N8ZL.cjs +963 -0
- package/dist/RunIntentService-1EE6N8ZL.cjs.map +1 -0
- package/dist/RunIntentService-2ivFmNQh.cjs +3462 -0
- package/dist/RunIntentService-2ivFmNQh.cjs.map +1 -0
- package/dist/RunIntentService-B0sUL5q-.js +761 -0
- package/dist/RunIntentService-B0sUL5q-.js.map +1 -0
- package/dist/RunIntentService-BFVbsOcg.js +3131 -0
- package/dist/RunIntentService-BFVbsOcg.js.map +1 -0
- package/dist/RunIntentService-BsBOwpVN.cjs +1051 -0
- package/dist/RunIntentService-BsBOwpVN.cjs.map +1 -0
- package/dist/RunIntentService-CSk3ETyn.js +858 -0
- package/dist/RunIntentService-CSk3ETyn.js.map +1 -0
- package/dist/RunIntentService-Ckn3u3tA.d.cts +326 -0
- package/dist/RunIntentService-DEo6GTTo.d.cts +289 -0
- package/dist/RunIntentService-DKrGtL0B.js +782 -0
- package/dist/RunIntentService-DKrGtL0B.js.map +1 -0
- package/dist/RunIntentService-DNOJc1R7.cjs +942 -0
- package/dist/RunIntentService-DNOJc1R7.cjs.map +1 -0
- package/dist/RunIntentService-Dq3pV53j.d.cts +289 -0
- package/dist/RunIntentService-NKobsfMQ.d.cts +274 -0
- package/dist/WorkflowSnapshotCodec-C3fuuS_R.d.cts +22 -0
- package/dist/WorkflowSnapshotCodec-CUudUo6f.js +123 -0
- package/dist/WorkflowSnapshotCodec-CUudUo6f.js.map +1 -0
- package/dist/WorkflowSnapshotCodec-CuCPQZTc.cjs +129 -0
- package/dist/WorkflowSnapshotCodec-CuCPQZTc.cjs.map +1 -0
- package/dist/WorkflowSnapshotCodec-DLiXQNvV.d.cts +22 -0
- package/dist/WorkflowSnapshotCodec-DNtdrZ7l.d.cts +22 -0
- package/dist/WorkflowSnapshotCodec-DTdWkoW_.d.cts +22 -0
- package/dist/bootstrap/index.cjs +1028 -0
- package/dist/bootstrap/index.cjs.map +1 -0
- package/dist/bootstrap/index.d.cts +311 -0
- package/dist/bootstrap/index.d.ts +83 -0
- package/dist/bootstrap/index.js +994 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/credentialTypes-B5h3dI7r.d.cts +1107 -0
- package/dist/credentialTypes-B9okPCVo.d.cts +963 -0
- package/dist/credentialTypes-BFL70rgZ.d.cts +964 -0
- package/dist/credentialTypes-BGkh1O07.d.ts +1010 -0
- package/dist/credentialTypes-BNLi4Q7u.d.ts +1030 -0
- package/dist/credentialTypes-CeSoZGj3.d.cts +994 -0
- package/dist/credentialTypes-CpHc32Ig.d.cts +984 -0
- package/dist/credentialTypes-D0m7MQQl.d.cts +1107 -0
- package/dist/credentialTypes-D4nL2sUd.d.ts +1000 -0
- package/dist/credentialTypes-DBYK2Qbu.d.ts +999 -0
- package/dist/credentialTypes-DMJVy0r1.d.ts +1000 -0
- package/dist/credentialTypes-DhUAjYQp.d.ts +1020 -0
- package/dist/credentialTypes-gGITj5KL.d.cts +964 -0
- package/dist/credentialTypes-r3KVBJBE.d.cts +974 -0
- package/dist/diTokens-ClO27tjK.cjs +34 -0
- package/dist/diTokens-ClO27tjK.cjs.map +1 -0
- package/dist/diTokens-CoHBkwG6.js +28 -0
- package/dist/diTokens-CoHBkwG6.js.map +1 -0
- package/dist/index-6Doxmfnd.d.ts +857 -0
- package/dist/index-9g6Pfe9Z.d.ts +689 -0
- package/dist/index-AZ72Ej-K.d.ts +920 -0
- package/dist/index-BEk9V-q-.d.ts +667 -0
- package/dist/index-Bjt7_7oS.d.ts +1192 -0
- package/dist/index-CFGxsYXy.d.ts +708 -0
- package/dist/index-C_u8xFgn.d.ts +690 -0
- package/dist/index-CpbfsvOJ.d.ts +1192 -0
- package/dist/index-CsReNJN_.d.ts +859 -0
- package/dist/index-D5iNnXaW.d.ts +667 -0
- package/dist/index-DD_Eft1q.d.ts +708 -0
- package/dist/index-DiSYUe0G.d.ts +1192 -0
- package/dist/index-gIcH60sp.d.ts +674 -0
- package/dist/index.cjs +520 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +345 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +412 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime-BIvd-1JA.cjs +4112 -0
- package/dist/runtime-BIvd-1JA.cjs.map +1 -0
- package/dist/runtime-D3eWKSQK.cjs +3986 -0
- package/dist/runtime-D3eWKSQK.cjs.map +1 -0
- package/dist/runtime-Dvp4xAjg.js +3799 -0
- package/dist/runtime-Dvp4xAjg.js.map +1 -0
- package/dist/runtime-vc76SSAa.js +3685 -0
- package/dist/runtime-vc76SSAa.js.map +1 -0
- package/dist/runtimeTypes-BK0b8SaG.d.cts +884 -0
- package/dist/runtimeTypes-CoYZkYQq.d.cts +851 -0
- package/dist/runtimeTypes-D-Pm0Uas.d.cts +849 -0
- package/dist/testing.cjs +18 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +19 -0
- package/dist/testing.d.ts +18 -0
- package/dist/testing.js +16 -0
- package/dist/testing.js.map +1 -0
- package/dist/types-Cb5UK7Y6.d.ts +857 -0
- package/package.json +66 -0
- package/src/ai/AiHost.ts +115 -0
- package/src/binaries/DefaultExecutionBinaryServiceFactory.ts +37 -0
- package/src/binaries/DefaultNodeBinaryAttachmentServiceFactory.ts +120 -0
- package/src/binaries/UnavailableBinaryStorage.ts +19 -0
- package/src/binaries/index.ts +2 -0
- package/src/bootstrap/index.ts +46 -0
- package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +180 -0
- package/src/bootstrap/runtime/EngineRuntimeRegistration.types.ts +43 -0
- package/src/bootstrap/runtime/index.ts +6 -0
- package/src/browser.ts +8 -0
- package/src/contracts/Clock.ts +10 -0
- package/src/contracts/ExpRetryPolicy.ts +23 -0
- package/src/contracts/NoRetryPolicy.ts +5 -0
- package/src/contracts/RetryPolicy.ts +23 -0
- package/src/contracts/credentialTypes.ts +194 -0
- package/src/contracts/index.ts +6 -0
- package/src/contracts/retryPolicySpec.types.ts +30 -0
- package/src/contracts/runFinishedAtFactory.ts +19 -0
- package/src/contracts/runTypes.ts +314 -0
- package/src/contracts/runtimeTypes.ts +373 -0
- package/src/contracts/webhookTypes.ts +49 -0
- package/src/contracts/workflowActivationPolicy.ts +16 -0
- package/src/contracts/workflowTypes.ts +280 -0
- package/src/di/CoreTokens.ts +60 -0
- package/src/di/index.ts +24 -0
- package/src/events/EventPublishingWorkflowExecutionRepository.ts +67 -0
- package/src/events/InMemoryRunEventBusRegistry.ts +37 -0
- package/src/events/InMemoryRunEventSubscription.ts +9 -0
- package/src/events/NodeEventPublisher.ts +22 -0
- package/src/events/index.ts +4 -0
- package/src/events/runEvents.ts +54 -0
- package/src/execution/ActivationEnqueueService.ts +125 -0
- package/src/execution/CredentialResolverFactory.ts +39 -0
- package/src/execution/DefaultAsyncSleeper.ts +9 -0
- package/src/execution/DefaultExecutionContextFactory.ts +48 -0
- package/src/execution/InProcessRetryRunner.ts +115 -0
- package/src/execution/InProcessRetryRunnerFactory.ts +8 -0
- package/src/execution/NodeActivationRequestComposer.ts +113 -0
- package/src/execution/NodeExecutionSnapshotFactory.ts +152 -0
- package/src/execution/NodeExecutor.ts +43 -0
- package/src/execution/NodeExecutorFactory.ts +10 -0
- package/src/execution/NodeInputsByPortFactory.ts +14 -0
- package/src/execution/NodeInstanceFactory.ts +32 -0
- package/src/execution/NodeInstanceFactoryFactory.ts +9 -0
- package/src/execution/NodeRunStateWriter.ts +185 -0
- package/src/execution/NodeRunStateWriterFactory.ts +29 -0
- package/src/execution/PersistedRunStateTerminalBuilder.ts +25 -0
- package/src/execution/RunStateSemantics.ts +158 -0
- package/src/execution/WorkflowRunExecutionContextFactory.ts +45 -0
- package/src/execution/asyncSleeper.types.ts +3 -0
- package/src/execution/index.ts +26 -0
- package/src/index.ts +18 -0
- package/src/orchestration/Engine.ts +229 -0
- package/src/orchestration/EngineWaiters.ts +37 -0
- package/src/orchestration/RunContinuationService.ts +810 -0
- package/src/orchestration/RunStartService.ts +449 -0
- package/src/orchestration/TriggerRuntimeService.ts +260 -0
- package/src/orchestration/index.ts +5 -0
- package/src/planning/CurrentStateFrontierPlanner.ts +400 -0
- package/src/planning/EngineWorkflowPlanningFactory.ts +63 -0
- package/src/planning/RunQueuePlanner.ts +302 -0
- package/src/planning/WorkflowTopologyPlanner.ts +77 -0
- package/src/planning/index.ts +4 -0
- package/src/policies/WorkflowPolicyErrorServices.ts +38 -0
- package/src/policies/executionLimits/EngineExecutionLimitsPolicy.ts +66 -0
- package/src/policies/executionLimits/EngineExecutionLimitsPolicyFactory.ts +14 -0
- package/src/policies/index.ts +10 -0
- package/src/policies/storage/RunPolicySnapshotFactory.ts +23 -0
- package/src/policies/storage/RunTerminalPersistenceCoordinator.ts +29 -0
- package/src/policies/storage/WorkflowStoragePolicyEvaluator.ts +39 -0
- package/src/runStorage/BinaryBodyBufferReader.ts +57 -0
- package/src/runStorage/BinaryBodyReadableStreamFactory.ts +21 -0
- package/src/runStorage/InMemoryBinaryStorageRegistry.ts +53 -0
- package/src/runStorage/InMemoryRunData.ts +33 -0
- package/src/runStorage/InMemoryRunDataFactory.ts +8 -0
- package/src/runStorage/InMemoryWorkflowExecutionRepository.ts +95 -0
- package/src/runStorage/RunSummaryMapper.ts +17 -0
- package/src/runStorage/index.ts +7 -0
- package/src/runtime/EngineFactory.ts +151 -0
- package/src/runtime/EngineWorkflowRunnerService.ts +39 -0
- package/src/runtime/EngineWorkflowRunnerServiceFactory.ts +11 -0
- package/src/runtime/InMemoryLiveWorkflowRepository.ts +20 -0
- package/src/runtime/RunIntentService.ts +175 -0
- package/src/runtime/RunIntentServiceFactory.ts +11 -0
- package/src/runtime/WorkflowRepositoryWebhookTriggerMatcher.ts +144 -0
- package/src/runtime/WorkflowRepositoryWebhookTriggerMatcherFactory.ts +13 -0
- package/src/runtime/index.ts +9 -0
- package/src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts +25 -0
- package/src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts +46 -0
- package/src/runtime-types/PersistedRuntimeTypeNameResolver.ts +14 -0
- package/src/runtime-types/StackTraceCallSitePathResolver.ts +25 -0
- package/src/runtime-types/persistedRuntimeTypeModelRegistry.ts +33 -0
- package/src/runtime-types/runtimeTypeDecorators.types.ts +46 -0
- package/src/scheduler/ConfigDrivenOffloadPolicy.ts +28 -0
- package/src/scheduler/DefaultDrivingScheduler.ts +100 -0
- package/src/scheduler/HintOnlyOffloadPolicy.ts +9 -0
- package/src/scheduler/InlineDrivingScheduler.ts +145 -0
- package/src/scheduler/InlineDrivingSchedulerFactory.ts +9 -0
- package/src/scheduler/LocalOnlyScheduler.ts +7 -0
- package/src/serialization/ItemsInputNormalizer.ts +36 -0
- package/src/testing/RejectingCredentialSessionService.ts +15 -0
- package/src/testing.ts +6 -0
- package/src/types/index.ts +12 -0
- package/src/workflow/definition/ConnectionInvocationIdFactory.ts +17 -0
- package/src/workflow/definition/ConnectionNodeIdFactory.ts +42 -0
- package/src/workflow/definition/WorkflowExecutableNodeClassifier.ts +71 -0
- package/src/workflow/definition/WorkflowExecutableNodeClassifierFactory.ts +9 -0
- package/src/workflow/dsl/ChainCursorResolver.ts +103 -0
- package/src/workflow/dsl/WhenBuilder.ts +57 -0
- package/src/workflow/dsl/WorkflowBuilder.ts +55 -0
- package/src/workflow/dsl/workflowBuilderTypes.ts +63 -0
- package/src/workflow/graph/DefaultWorkflowGraphFactory.ts +8 -0
- package/src/workflow/graph/ExecutableGraph.ts +24 -0
- package/src/workflow/index.ts +11 -0
- package/src/workflowSnapshots/MissingRuntimeExecutionMarker.ts +5 -0
- package/src/workflowSnapshots/MissingRuntimeFallbacksFactory.ts +27 -0
- package/src/workflowSnapshots/MissingRuntimeNode.ts +12 -0
- package/src/workflowSnapshots/MissingRuntimeNodeConfig.ts +14 -0
- package/src/workflowSnapshots/MissingRuntimeNodeToken.ts +1 -0
- package/src/workflowSnapshots/MissingRuntimeTrigger.ts +16 -0
- package/src/workflowSnapshots/MissingRuntimeTriggerConfig.ts +14 -0
- package/src/workflowSnapshots/MissingRuntimeTriggerToken.ts +1 -0
- package/src/workflowSnapshots/PersistedRuntimeTypeIdFactory.ts +19 -0
- package/src/workflowSnapshots/PersistedWorkflowTokenRegistry.ts +89 -0
- package/src/workflowSnapshots/PersistedWorkflowTokenRegistryFactory.ts +2 -0
- package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +177 -0
- package/src/workflowSnapshots/WorkflowSnapshotResolver.ts +102 -0
- package/src/workflowSnapshots/index.ts +12 -0
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +10 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorkflowDefinition, WorkflowGraph, WorkflowGraphFactory } from "../../types";
|
|
2
|
+
import { ExecutableGraph } from "./ExecutableGraph";
|
|
3
|
+
|
|
4
|
+
export class DefaultWorkflowGraphFactory implements WorkflowGraphFactory {
|
|
5
|
+
create(def: WorkflowDefinition): WorkflowGraph {
|
|
6
|
+
return new ExecutableGraph(def);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { InputPortKey, NodeId, OutputPortKey, WorkflowDefinition, WorkflowGraph } from "../../types";
|
|
2
|
+
|
|
3
|
+
export class ExecutableGraph implements WorkflowGraph {
|
|
4
|
+
private readonly outgoingByNodeAndPort = new Map<
|
|
5
|
+
NodeId,
|
|
6
|
+
Map<OutputPortKey, Array<Readonly<{ nodeId: NodeId; input: InputPortKey }>>>
|
|
7
|
+
>();
|
|
8
|
+
|
|
9
|
+
constructor(def: WorkflowDefinition) {
|
|
10
|
+
for (const e of def.edges) {
|
|
11
|
+
const byPort =
|
|
12
|
+
this.outgoingByNodeAndPort.get(e.from.nodeId) ??
|
|
13
|
+
new Map<OutputPortKey, Array<Readonly<{ nodeId: NodeId; input: InputPortKey }>>>();
|
|
14
|
+
const next = byPort.get(e.from.output) ?? [];
|
|
15
|
+
next.push({ nodeId: e.to.nodeId, input: e.to.input });
|
|
16
|
+
byPort.set(e.from.output, next);
|
|
17
|
+
this.outgoingByNodeAndPort.set(e.from.nodeId, byPort);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
next(nodeId: NodeId, output: OutputPortKey): Array<Readonly<{ nodeId: NodeId; input: InputPortKey }>> {
|
|
22
|
+
return this.outgoingByNodeAndPort.get(nodeId)?.get(output) ?? [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { WorkflowBuilder } from "./dsl/WorkflowBuilder";
|
|
2
|
+
export { ChainCursor } from "./dsl/ChainCursorResolver";
|
|
3
|
+
export { WhenBuilder } from "./dsl/WhenBuilder";
|
|
4
|
+
export * from "./dsl/workflowBuilderTypes";
|
|
5
|
+
|
|
6
|
+
export { ConnectionInvocationIdFactory } from "./definition/ConnectionInvocationIdFactory";
|
|
7
|
+
export { ConnectionNodeIdFactory } from "./definition/ConnectionNodeIdFactory";
|
|
8
|
+
export { WorkflowExecutableNodeClassifier } from "./definition/WorkflowExecutableNodeClassifier";
|
|
9
|
+
export * from "./definition/WorkflowExecutableNodeClassifierFactory";
|
|
10
|
+
|
|
11
|
+
export { DefaultWorkflowGraphFactory } from "./graph/DefaultWorkflowGraphFactory";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { NodeDefinition, PersistedWorkflowSnapshotNode } from "../types";
|
|
2
|
+
|
|
3
|
+
import { MissingRuntimeNodeConfig } from "./MissingRuntimeNodeConfig";
|
|
4
|
+
import { MissingRuntimeNodeToken } from "./MissingRuntimeNodeToken";
|
|
5
|
+
import { MissingRuntimeTriggerConfig } from "./MissingRuntimeTriggerConfig";
|
|
6
|
+
import { MissingRuntimeTriggerToken } from "./MissingRuntimeTriggerToken";
|
|
7
|
+
|
|
8
|
+
export class MissingRuntimeFallbacks {
|
|
9
|
+
createDefinition(snapshotNode: PersistedWorkflowSnapshotNode): NodeDefinition {
|
|
10
|
+
if (snapshotNode.kind === "trigger") {
|
|
11
|
+
return {
|
|
12
|
+
id: snapshotNode.id,
|
|
13
|
+
kind: "trigger",
|
|
14
|
+
name: snapshotNode.name,
|
|
15
|
+
type: MissingRuntimeTriggerToken,
|
|
16
|
+
config: new MissingRuntimeTriggerConfig(snapshotNode.name ?? snapshotNode.id, snapshotNode.nodeTokenId),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
id: snapshotNode.id,
|
|
21
|
+
kind: "node",
|
|
22
|
+
name: snapshotNode.name,
|
|
23
|
+
type: MissingRuntimeNodeToken,
|
|
24
|
+
config: new MissingRuntimeNodeConfig(snapshotNode.name ?? snapshotNode.id, snapshotNode.nodeTokenId),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Items, Node, NodeOutputs } from "../types";
|
|
2
|
+
|
|
3
|
+
import { MissingRuntimeNodeConfig } from "./MissingRuntimeNodeConfig";
|
|
4
|
+
|
|
5
|
+
export class MissingRuntimeNode implements Node<MissingRuntimeNodeConfig> {
|
|
6
|
+
readonly kind = "node" as const;
|
|
7
|
+
readonly outputPorts = ["main"] as const;
|
|
8
|
+
|
|
9
|
+
async execute(items: Items): Promise<NodeOutputs> {
|
|
10
|
+
return { main: items };
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NodeConfigBase } from "../types";
|
|
2
|
+
|
|
3
|
+
import { MissingRuntimeNodeToken } from "./MissingRuntimeNodeToken";
|
|
4
|
+
|
|
5
|
+
export class MissingRuntimeNodeConfig implements NodeConfigBase {
|
|
6
|
+
readonly kind = "node" as const;
|
|
7
|
+
readonly type = MissingRuntimeNodeToken;
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
public readonly name: string,
|
|
11
|
+
public readonly missingTokenId?: string,
|
|
12
|
+
public readonly missingRuntime = true,
|
|
13
|
+
) {}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class MissingRuntimeNodeToken {}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExecutableTriggerNode, Items, NodeOutputs, TriggerSetupContext } from "../types";
|
|
2
|
+
|
|
3
|
+
import { MissingRuntimeTriggerConfig } from "./MissingRuntimeTriggerConfig";
|
|
4
|
+
|
|
5
|
+
export class MissingRuntimeTrigger implements ExecutableTriggerNode<MissingRuntimeTriggerConfig> {
|
|
6
|
+
readonly kind = "trigger" as const;
|
|
7
|
+
readonly outputPorts = ["main"] as const;
|
|
8
|
+
|
|
9
|
+
async setup(_ctx: TriggerSetupContext<MissingRuntimeTriggerConfig>): Promise<undefined> {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async execute(items: Items): Promise<NodeOutputs> {
|
|
14
|
+
return { main: items };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NodeConfigBase } from "../types";
|
|
2
|
+
|
|
3
|
+
import { MissingRuntimeTriggerToken } from "./MissingRuntimeTriggerToken";
|
|
4
|
+
|
|
5
|
+
export class MissingRuntimeTriggerConfig implements NodeConfigBase {
|
|
6
|
+
readonly kind = "trigger" as const;
|
|
7
|
+
readonly type = MissingRuntimeTriggerToken;
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
public readonly name: string,
|
|
11
|
+
public readonly missingTokenId?: string,
|
|
12
|
+
public readonly missingRuntime = true,
|
|
13
|
+
) {}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class MissingRuntimeTriggerToken {}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TypeToken } from "../di";
|
|
2
|
+
|
|
3
|
+
import { getPersistedRuntimeTypeMetadata } from "../runtime-types/runtimeTypeDecorators.types";
|
|
4
|
+
|
|
5
|
+
import type { PersistedTokenId } from "../types";
|
|
6
|
+
|
|
7
|
+
export class PersistedRuntimeTypeIdFactory {
|
|
8
|
+
static fromMetadata(args: Readonly<{ type: TypeToken<unknown> }>): PersistedTokenId | undefined {
|
|
9
|
+
const metadata = getPersistedRuntimeTypeMetadata(args.type);
|
|
10
|
+
if (!metadata) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const packageName = metadata.packageName;
|
|
14
|
+
if (!packageName) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return `${packageName}::${metadata.persistedName}` as PersistedTokenId;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { TypeToken } from "../di";
|
|
2
|
+
|
|
3
|
+
import type { PersistedTokenId, WorkflowDefinition } from "../types";
|
|
4
|
+
|
|
5
|
+
import { PersistedRuntimeTypeIdFactory } from "./PersistedRuntimeTypeIdFactory";
|
|
6
|
+
|
|
7
|
+
export class PersistedWorkflowTokenRegistry {
|
|
8
|
+
private readonly tokensById = new Map<PersistedTokenId, TypeToken<unknown>>();
|
|
9
|
+
private readonly tokenIdsByToken = new Map<TypeToken<unknown>, PersistedTokenId>();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Register a token with its package ID. Token ID is inferred as `packageId::tokenName`.
|
|
13
|
+
*/
|
|
14
|
+
register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): PersistedTokenId {
|
|
15
|
+
const tokenName = persistedNameOverride ?? this.displayNameForTypeToken(type);
|
|
16
|
+
const tokenId = `${packageId}::${tokenName}` as PersistedTokenId;
|
|
17
|
+
this.tokensById.set(tokenId, type);
|
|
18
|
+
this.tokenIdsByToken.set(type, tokenId);
|
|
19
|
+
return tokenId;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Register all decorated runtime types discovered in workflows.
|
|
24
|
+
*/
|
|
25
|
+
registerFromWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void {
|
|
26
|
+
for (const workflow of workflows) {
|
|
27
|
+
for (const node of workflow.nodes) {
|
|
28
|
+
this.registerDecoratedType(node.type);
|
|
29
|
+
this.registerDecoratedType(node.config.type);
|
|
30
|
+
this.registerNestedTypes(node.config);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private registerDecoratedType(type: TypeToken<unknown>): void {
|
|
36
|
+
if (this.tokenIdsByToken.has(type)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type });
|
|
40
|
+
if (!tokenId) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.tokensById.set(tokenId, type);
|
|
44
|
+
this.tokenIdsByToken.set(type, tokenId);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private registerNestedTypes(value: unknown): void {
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
for (const entry of value) this.registerNestedTypes(entry);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!value || typeof value !== "object") return;
|
|
53
|
+
const record = value as Record<string, unknown>;
|
|
54
|
+
const type = this.asTypeToken(record.type);
|
|
55
|
+
if (type) this.registerDecoratedType(type);
|
|
56
|
+
for (const v of Object.values(record)) this.registerNestedTypes(v);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private displayNameForTypeToken(token: TypeToken<unknown>): string {
|
|
60
|
+
if (typeof token === "function" && token.name) return token.name;
|
|
61
|
+
if (typeof token === "string") return token;
|
|
62
|
+
return "";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private asTypeToken(value: unknown): TypeToken<unknown> | undefined {
|
|
66
|
+
if (typeof value === "function" || typeof value === "string" || typeof value === "symbol") {
|
|
67
|
+
return value as TypeToken<unknown>;
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getTokenId(token: TypeToken<unknown>): PersistedTokenId | undefined {
|
|
73
|
+
const existing = this.tokenIdsByToken.get(token);
|
|
74
|
+
if (existing) {
|
|
75
|
+
return existing;
|
|
76
|
+
}
|
|
77
|
+
const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type: token });
|
|
78
|
+
if (!tokenId) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
this.tokensById.set(tokenId, token);
|
|
82
|
+
this.tokenIdsByToken.set(token, tokenId);
|
|
83
|
+
return tokenId;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
resolve(tokenId: PersistedTokenId): TypeToken<unknown> | undefined {
|
|
87
|
+
return this.tokensById.get(tokenId);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { TypeToken } from "../di";
|
|
2
|
+
import type {
|
|
3
|
+
NodeConfigBase,
|
|
4
|
+
PersistedTokenId,
|
|
5
|
+
PersistedWorkflowSnapshot,
|
|
6
|
+
PersistedWorkflowSnapshotNode,
|
|
7
|
+
PersistedWorkflowTokenRegistryLike,
|
|
8
|
+
WorkflowDefinition,
|
|
9
|
+
} from "../types";
|
|
10
|
+
|
|
11
|
+
export class WorkflowSnapshotCodec {
|
|
12
|
+
constructor(private readonly tokenRegistry: PersistedWorkflowTokenRegistryLike) {}
|
|
13
|
+
|
|
14
|
+
create(workflow: WorkflowDefinition): PersistedWorkflowSnapshot {
|
|
15
|
+
return {
|
|
16
|
+
id: workflow.id,
|
|
17
|
+
name: workflow.name,
|
|
18
|
+
workflowErrorHandlerConfigured: workflow.workflowErrorHandler !== undefined,
|
|
19
|
+
...(workflow.connections !== undefined && workflow.connections.length > 0
|
|
20
|
+
? { connections: workflow.connections }
|
|
21
|
+
: {}),
|
|
22
|
+
nodes: workflow.nodes.map((node) => ({
|
|
23
|
+
id: node.id,
|
|
24
|
+
kind: node.kind,
|
|
25
|
+
name: node.name,
|
|
26
|
+
nodeTokenId: this.resolveTokenId(node.type),
|
|
27
|
+
configTokenId: this.resolveTokenId(node.config.type),
|
|
28
|
+
tokenName: this.resolveTokenName(node.type),
|
|
29
|
+
configTokenName: this.resolveTokenName(node.config.type),
|
|
30
|
+
config: this.serializeConfig(node.config),
|
|
31
|
+
})),
|
|
32
|
+
edges: workflow.edges.map((edge) => ({
|
|
33
|
+
from: { nodeId: edge.from.nodeId, output: edge.from.output },
|
|
34
|
+
to: { nodeId: edge.to.nodeId, input: edge.to.input },
|
|
35
|
+
})),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
hydrate(snapshotNode: PersistedWorkflowSnapshotNode, liveConfig: NodeConfigBase): NodeConfigBase {
|
|
40
|
+
const hydrated = this.mergeValue(liveConfig, snapshotNode.config);
|
|
41
|
+
const configToken = this.tokenRegistry.resolve(snapshotNode.configTokenId);
|
|
42
|
+
Object.assign(hydrated, {
|
|
43
|
+
type: configToken ?? liveConfig.type,
|
|
44
|
+
kind: snapshotNode.kind,
|
|
45
|
+
});
|
|
46
|
+
if (snapshotNode.name && !("name" in hydrated && hydrated.name)) {
|
|
47
|
+
Object.assign(hydrated, { name: snapshotNode.name });
|
|
48
|
+
}
|
|
49
|
+
return hydrated as unknown as NodeConfigBase;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private serializeConfig(config: NodeConfigBase): unknown {
|
|
53
|
+
try {
|
|
54
|
+
const cloned = JSON.parse(JSON.stringify(config)) as Record<string, unknown>;
|
|
55
|
+
this.injectTokenIds(cloned, config as unknown as Record<string, unknown>);
|
|
56
|
+
return cloned;
|
|
57
|
+
} catch {
|
|
58
|
+
const fallback: Record<string, unknown> = {
|
|
59
|
+
kind: config.kind,
|
|
60
|
+
name: config.name,
|
|
61
|
+
id: config.id,
|
|
62
|
+
icon: config.icon,
|
|
63
|
+
execution: config.execution,
|
|
64
|
+
};
|
|
65
|
+
this.injectTokenIds(fallback, config as unknown as Record<string, unknown>);
|
|
66
|
+
return fallback;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private injectTokenIds(target: Record<string, unknown>, source: Record<string, unknown>): void {
|
|
71
|
+
const type = this.asTypeToken(source.type);
|
|
72
|
+
if (type) {
|
|
73
|
+
target.tokenId = this.tokenRegistry.getTokenId(type) ?? this.resolveTokenName(type) ?? "unknown";
|
|
74
|
+
}
|
|
75
|
+
for (const [key, value] of Object.entries(source)) {
|
|
76
|
+
if (key === "type" || value == null) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (Array.isArray(value)) {
|
|
80
|
+
const targetArray = target[key];
|
|
81
|
+
if (Array.isArray(targetArray)) {
|
|
82
|
+
value.forEach((item, index) => {
|
|
83
|
+
if (item && typeof item === "object" && targetArray[index] && typeof targetArray[index] === "object") {
|
|
84
|
+
this.injectTokenIds(targetArray[index] as Record<string, unknown>, item as Record<string, unknown>);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (typeof value === "object") {
|
|
91
|
+
const targetValue = target[key];
|
|
92
|
+
if (targetValue && typeof targetValue === "object") {
|
|
93
|
+
this.injectTokenIds(targetValue as Record<string, unknown>, value as Record<string, unknown>);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private mergeValue(liveValue: unknown, snapshotValue: unknown): Record<string, unknown> {
|
|
100
|
+
const liveRecord = this.asRecord(liveValue);
|
|
101
|
+
const snapshotRecord = this.asRecord(snapshotValue);
|
|
102
|
+
const hydrated = Object.create(
|
|
103
|
+
liveValue && typeof liveValue === "object"
|
|
104
|
+
? (Object.getPrototypeOf(liveValue) ?? Object.prototype)
|
|
105
|
+
: Object.prototype,
|
|
106
|
+
) as Record<string, unknown>;
|
|
107
|
+
|
|
108
|
+
for (const [key, value] of Object.entries(snapshotRecord)) {
|
|
109
|
+
hydrated[key] = this.mergeNestedValue(liveRecord[key], value);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
this.restoreNonSerializableProperties(liveRecord, hydrated);
|
|
113
|
+
this.restoreTypeProperty(hydrated);
|
|
114
|
+
return hydrated;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private mergeNestedValue(liveValue: unknown, snapshotValue: unknown): unknown {
|
|
118
|
+
if (Array.isArray(snapshotValue)) {
|
|
119
|
+
const liveArray = Array.isArray(liveValue) ? liveValue : [];
|
|
120
|
+
return snapshotValue.map((entry, index) => this.mergeNestedValue(liveArray[index], entry));
|
|
121
|
+
}
|
|
122
|
+
if (snapshotValue && typeof snapshotValue === "object") {
|
|
123
|
+
return this.mergeValue(liveValue, snapshotValue);
|
|
124
|
+
}
|
|
125
|
+
return snapshotValue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private restoreNonSerializableProperties(
|
|
129
|
+
liveRecord: Record<string, unknown>,
|
|
130
|
+
hydrated: Record<string, unknown>,
|
|
131
|
+
): void {
|
|
132
|
+
for (const [key, value] of Object.entries(liveRecord)) {
|
|
133
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
134
|
+
hydrated[key] = value;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private restoreTypeProperty(record: Record<string, unknown>): void {
|
|
140
|
+
const tokenId = typeof record.tokenId === "string" ? record.tokenId : undefined;
|
|
141
|
+
if (!tokenId) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const type = this.tokenRegistry.resolve(tokenId as PersistedTokenId);
|
|
145
|
+
if (type) {
|
|
146
|
+
record.type = type;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private resolveTokenId(token: TypeToken<unknown>): PersistedTokenId {
|
|
151
|
+
return (this.tokenRegistry.getTokenId(token) ?? this.resolveTokenName(token) ?? "unknown") as PersistedTokenId;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private resolveTokenName(token: TypeToken<unknown>): string | undefined {
|
|
155
|
+
if (typeof token === "function" && token.name) {
|
|
156
|
+
return token.name;
|
|
157
|
+
}
|
|
158
|
+
if (typeof token === "string") {
|
|
159
|
+
return token;
|
|
160
|
+
}
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private asTypeToken(value: unknown): TypeToken<unknown> | undefined {
|
|
165
|
+
if (typeof value === "function" || typeof value === "string" || typeof value === "symbol") {
|
|
166
|
+
return value as TypeToken<unknown>;
|
|
167
|
+
}
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private asRecord(value: unknown): Record<string, unknown> {
|
|
172
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
173
|
+
return {};
|
|
174
|
+
}
|
|
175
|
+
return { ...(value as Record<string, unknown>) };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { TypeToken } from "../di";
|
|
2
|
+
import type {
|
|
3
|
+
NodeDefinition,
|
|
4
|
+
PersistedWorkflowSnapshot,
|
|
5
|
+
PersistedWorkflowTokenRegistryLike,
|
|
6
|
+
WorkflowDefinition,
|
|
7
|
+
WorkflowId,
|
|
8
|
+
WorkflowRepository,
|
|
9
|
+
} from "../types";
|
|
10
|
+
|
|
11
|
+
import { MissingRuntimeFallbacks } from "./MissingRuntimeFallbacksFactory";
|
|
12
|
+
import { WorkflowSnapshotCodec } from "./WorkflowSnapshotCodec";
|
|
13
|
+
|
|
14
|
+
export class WorkflowSnapshotResolver {
|
|
15
|
+
constructor(
|
|
16
|
+
private readonly workflowRepository: WorkflowRepository,
|
|
17
|
+
private readonly tokenRegistry: PersistedWorkflowTokenRegistryLike,
|
|
18
|
+
private readonly codec: WorkflowSnapshotCodec,
|
|
19
|
+
private readonly missingRuntimeFallbacks: MissingRuntimeFallbacks,
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
resolve(args: {
|
|
23
|
+
workflowId: WorkflowId;
|
|
24
|
+
workflowSnapshot?: PersistedWorkflowSnapshot;
|
|
25
|
+
}): WorkflowDefinition | undefined {
|
|
26
|
+
const liveWorkflow = this.workflowRepository.get(args.workflowId);
|
|
27
|
+
if (!args.workflowSnapshot) {
|
|
28
|
+
return liveWorkflow;
|
|
29
|
+
}
|
|
30
|
+
if (!liveWorkflow) {
|
|
31
|
+
return this.rebuildWorkflow(args.workflowSnapshot, undefined);
|
|
32
|
+
}
|
|
33
|
+
return this.rebuildWorkflow(args.workflowSnapshot, liveWorkflow);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private rebuildWorkflow(
|
|
37
|
+
snapshot: PersistedWorkflowSnapshot,
|
|
38
|
+
liveWorkflow: WorkflowDefinition | undefined,
|
|
39
|
+
): WorkflowDefinition {
|
|
40
|
+
const liveNodesById = new Map((liveWorkflow?.nodes ?? []).map((node) => [node.id, node] as const));
|
|
41
|
+
const nodes = snapshot.nodes.map((snapshotNode) => {
|
|
42
|
+
const liveNode = liveNodesById.get(snapshotNode.id);
|
|
43
|
+
if (!this.isCompatibleLiveNode(liveNode, snapshotNode)) {
|
|
44
|
+
return this.missingRuntimeFallbacks.createDefinition(snapshotNode);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
id: snapshotNode.id,
|
|
48
|
+
kind: snapshotNode.kind,
|
|
49
|
+
name: snapshotNode.name ?? liveNode.name,
|
|
50
|
+
type: liveNode.type,
|
|
51
|
+
config: this.codec.hydrate(snapshotNode, liveNode.config),
|
|
52
|
+
} satisfies NodeDefinition;
|
|
53
|
+
});
|
|
54
|
+
const nodeIds = new Set(nodes.map((node) => node.id));
|
|
55
|
+
const connectionsFromSnapshot =
|
|
56
|
+
snapshot.connections
|
|
57
|
+
?.map((connection) => ({
|
|
58
|
+
...connection,
|
|
59
|
+
childNodeIds: connection.childNodeIds.filter((childId) => nodeIds.has(childId)),
|
|
60
|
+
}))
|
|
61
|
+
.filter((connection) => connection.childNodeIds.length > 0) ?? [];
|
|
62
|
+
return {
|
|
63
|
+
id: snapshot.id,
|
|
64
|
+
name: snapshot.name,
|
|
65
|
+
nodes,
|
|
66
|
+
edges: snapshot.edges.filter((edge) => nodeIds.has(edge.from.nodeId) && nodeIds.has(edge.to.nodeId)),
|
|
67
|
+
...(connectionsFromSnapshot.length > 0 ? { connections: connectionsFromSnapshot } : {}),
|
|
68
|
+
...(liveWorkflow?.discoveryPathSegments !== undefined
|
|
69
|
+
? { discoveryPathSegments: liveWorkflow.discoveryPathSegments }
|
|
70
|
+
: {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private isCompatibleLiveNode(
|
|
75
|
+
liveNode: WorkflowDefinition["nodes"][number] | undefined,
|
|
76
|
+
snapshotNode: PersistedWorkflowSnapshot["nodes"][number],
|
|
77
|
+
): liveNode is WorkflowDefinition["nodes"][number] {
|
|
78
|
+
if (!liveNode || liveNode.kind !== snapshotNode.kind) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (!snapshotNode.nodeTokenId || !snapshotNode.configTokenId) {
|
|
82
|
+
throw new Error(`Persisted workflow snapshot node "${snapshotNode.id}" is missing stable token ids.`);
|
|
83
|
+
}
|
|
84
|
+
const liveNodeTokenId = this.resolveLiveTokenId(liveNode.type);
|
|
85
|
+
const liveConfigTokenId = this.resolveLiveTokenId(liveNode.config.type);
|
|
86
|
+
return liveNodeTokenId === snapshotNode.nodeTokenId && liveConfigTokenId === snapshotNode.configTokenId;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private resolveLiveTokenId(type: TypeToken<unknown>): string | undefined {
|
|
90
|
+
const registeredTokenId = this.tokenRegistry.getTokenId(type);
|
|
91
|
+
if (registeredTokenId) {
|
|
92
|
+
return registeredTokenId;
|
|
93
|
+
}
|
|
94
|
+
if (typeof type === "function" && type.name) {
|
|
95
|
+
return type.name;
|
|
96
|
+
}
|
|
97
|
+
if (typeof type === "string") {
|
|
98
|
+
return type;
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { MissingRuntimeExecutionMarker } from "./MissingRuntimeExecutionMarker";
|
|
2
|
+
export { MissingRuntimeFallbacks } from "./MissingRuntimeFallbacksFactory";
|
|
3
|
+
export { MissingRuntimeNode } from "./MissingRuntimeNode";
|
|
4
|
+
export { MissingRuntimeNodeConfig } from "./MissingRuntimeNodeConfig";
|
|
5
|
+
export { MissingRuntimeNodeToken } from "./MissingRuntimeNodeToken";
|
|
6
|
+
export { MissingRuntimeTrigger } from "./MissingRuntimeTrigger";
|
|
7
|
+
export { MissingRuntimeTriggerConfig } from "./MissingRuntimeTriggerConfig";
|
|
8
|
+
export { MissingRuntimeTriggerToken } from "./MissingRuntimeTriggerToken";
|
|
9
|
+
export { PersistedRuntimeTypeIdFactory } from "./PersistedRuntimeTypeIdFactory";
|
|
10
|
+
export { PersistedWorkflowTokenRegistry } from "./PersistedWorkflowTokenRegistryFactory";
|
|
11
|
+
export { WorkflowSnapshotCodec } from "./WorkflowSnapshotCodec";
|
|
12
|
+
export { WorkflowSnapshotResolver } from "./WorkflowSnapshotResolver";
|
package/tsconfig.json
ADDED
package/tsdown.config.ts
ADDED