space-data-module-sdk 0.8.3 → 0.8.5
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 +117 -20
- package/bin/space-data-module.js +263 -0
- package/docs/.nojekyll +1 -0
- package/docs/AGENTS.md +34 -0
- package/docs/architecture.svg +141 -0
- package/docs/browser-wasmedge-isomorphic.md +179 -0
- package/docs/flatsql-streaming-standard.md +341 -0
- package/docs/gpu-module-abi.md +193 -0
- package/docs/index.html +125 -0
- package/docs/isomorphic-pthreads.md +188 -0
- package/docs/isomorphic-sdn-runtime-plan.md +167 -0
- package/docs/language-runtime-matrix.md +82 -0
- package/docs/manifest-structure.svg +114 -0
- package/docs/module-bundle-runtime-plan.md +19 -0
- package/docs/module-lifecycle.svg +70 -0
- package/docs/module-publication-standard.md +540 -0
- package/docs/node-red-default-node-parity.md +88 -0
- package/docs/protocol-installation.md +196 -0
- package/docs/secrets-capability.md +152 -0
- package/docs/styles.css +288 -0
- package/docs/testing-harness.md +408 -0
- package/docs/tri-runtime-parity.md +132 -0
- package/docs/wallet-callback.html +2 -0
- package/package.json +26 -6
- package/schemas/HttpRequestAbi.fbs +41 -0
- package/schemas/HttpResponseAbi.fbs +36 -0
- package/schemas/PluginManifest.fbs +2 -1
- package/src/AGENTS.md +1 -1
- package/src/app/codec.js +548 -0
- package/src/app/index.js +6 -0
- package/src/browser.js +5 -0
- package/src/bundle/constants.js +1 -0
- package/src/bundle/index.js +15 -0
- package/src/bundle/sigdomain.js +179 -0
- package/src/bundle/signing.js +767 -0
- package/src/bundle/wasm.js +3 -2
- package/src/capabilities.js +3 -0
- package/src/compat/index.js +7 -0
- package/src/compat/sdnLegacy.js +449 -0
- package/src/compiler/compileModule.js +556 -55
- package/src/compiler/flatcSupport.js +41 -27
- package/src/compiler/index.d.ts +2 -0
- package/src/compiler/index.js +18 -0
- package/src/compiler/invokeGlue.js +1212 -183
- package/src/compiler/pthreadArtifactGuard.js +910 -0
- package/src/compiler/sdnShimGenerator.js +323 -0
- package/src/compiler/wasiThreadsToolchain.js +150 -0
- package/src/compliance/index.js +11 -1
- package/src/compliance/legacyWildcardPorts.js +228 -0
- package/src/compliance/pluginCompliance.js +1000 -96
- package/src/field-stream/index.d.ts +31 -0
- package/src/field-stream/index.js +119 -0
- package/src/flow/dependencyStreamBridge.js +234 -0
- package/src/flow/flatsqlLinkShim.js +304 -0
- package/src/flow/flowCodec.js +107 -0
- package/src/flow/flowCompiler.js +2900 -0
- package/src/flow/flowRuntimeHost.js +877 -0
- package/src/flow/index.d.ts +117 -0
- package/src/flow/index.js +31 -0
- package/src/flow/isomorphicFlowHost.js +384 -0
- package/src/flow/jsFlowRuntime.js +275 -0
- package/src/flow/normalize.js +294 -0
- package/src/flow/runtime-src/flow_runtime.cpp +1699 -0
- package/src/flow/vendor/sdn-flow/MethodRegistry.js +400 -0
- package/src/flow/vendor/sdn-flow/constants.js +39 -0
- package/src/flow/vendor/sdn-flow/index.js +29 -0
- package/src/flow/vendor/sdn-flow/normalize.js +506 -0
- package/src/flow/vendor/sdn-flow/wasmCompatibility.js +189 -0
- package/src/generated/http/cpp/HttpRequestAbi_generated.h +285 -0
- package/src/generated/http/cpp/HttpResponseAbi_generated.h +192 -0
- package/src/generated/http/sdn/http/http-header.js +53 -0
- package/src/generated/http/sdn/http/http-header.ts +67 -0
- package/src/generated/http/sdn/http/http-request.js +132 -0
- package/src/generated/http/sdn/http/http-request.ts +179 -0
- package/src/generated/http/sdn/http/http-response.js +144 -0
- package/src/generated/http/sdn/http/http-response.ts +168 -0
- package/src/generated/http/sdn/http.js +11 -0
- package/src/generated/http/sdn/http.ts +4 -0
- package/src/generated/orbpro/flow/backpressure-policy.d.ts +12 -0
- package/src/generated/orbpro/flow/backpressure-policy.d.ts.map +1 -0
- package/src/generated/orbpro/flow/backpressure-policy.js +17 -0
- package/src/generated/orbpro/flow/backpressure-policy.js.map +1 -0
- package/src/generated/orbpro/flow/backpressure-policy.ts +15 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.d.ts +142 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.js +304 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.js.map +1 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.ts +399 -0
- package/src/generated/orbpro/flow/flow-edge.d.ts +113 -0
- package/src/generated/orbpro/flow/flow-edge.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-edge.js +221 -0
- package/src/generated/orbpro/flow/flow-edge.js.map +1 -0
- package/src/generated/orbpro/flow/flow-edge.ts +292 -0
- package/src/generated/orbpro/flow/flow-node.d.ts +80 -0
- package/src/generated/orbpro/flow/flow-node.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-node.js +158 -0
- package/src/generated/orbpro/flow/flow-node.js.map +1 -0
- package/src/generated/orbpro/flow/flow-node.ts +202 -0
- package/src/generated/orbpro/flow/flow-program.d.ts +164 -0
- package/src/generated/orbpro/flow/flow-program.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-program.js +350 -0
- package/src/generated/orbpro/flow/flow-program.js.map +1 -0
- package/src/generated/orbpro/flow/flow-program.ts +477 -0
- package/src/generated/orbpro/flow/flow-trigger.d.ts +108 -0
- package/src/generated/orbpro/flow/flow-trigger.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-trigger.js +207 -0
- package/src/generated/orbpro/flow/flow-trigger.js.map +1 -0
- package/src/generated/orbpro/flow/flow-trigger.ts +276 -0
- package/src/generated/orbpro/flow/node-kind.d.ts +13 -0
- package/src/generated/orbpro/flow/node-kind.d.ts.map +1 -0
- package/src/generated/orbpro/flow/node-kind.js +16 -0
- package/src/generated/orbpro/flow/node-kind.js.map +1 -0
- package/src/generated/orbpro/{invoke.ts → flow/node-kind.ts} +12 -2
- package/src/generated/orbpro/flow/plugin-version-binding.d.ts +52 -0
- package/src/generated/orbpro/flow/plugin-version-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/plugin-version-binding.js +85 -0
- package/src/generated/orbpro/flow/plugin-version-binding.js.map +1 -0
- package/src/generated/orbpro/flow/plugin-version-binding.ts +121 -0
- package/src/generated/orbpro/flow/schema-hash-binding.d.ts +70 -0
- package/src/generated/orbpro/flow/schema-hash-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/schema-hash-binding.js +143 -0
- package/src/generated/orbpro/flow/schema-hash-binding.js.map +1 -0
- package/src/generated/orbpro/flow/schema-hash-binding.ts +189 -0
- package/src/generated/orbpro/flow/trigger-binding.d.ts +71 -0
- package/src/generated/orbpro/flow/trigger-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/trigger-binding.js +142 -0
- package/src/generated/orbpro/flow/trigger-binding.js.map +1 -0
- package/src/generated/orbpro/flow/trigger-binding.ts +181 -0
- package/src/generated/orbpro/flow/trigger-kind.d.ts +14 -0
- package/src/generated/orbpro/flow/trigger-kind.d.ts.map +1 -0
- package/src/generated/orbpro/flow/trigger-kind.js +17 -0
- package/src/generated/orbpro/flow/trigger-kind.js.map +1 -0
- package/src/generated/orbpro/flow/trigger-kind.ts +17 -0
- package/src/generated/orbpro/flow.d.ts +21 -0
- package/src/generated/orbpro/flow.d.ts.map +1 -0
- package/src/generated/orbpro/flow.js +23 -0
- package/src/generated/orbpro/flow.js.map +1 -0
- package/src/generated/orbpro/flow.ts +24 -0
- package/src/generated/orbpro/manifest/capability-kind.d.ts +2 -1
- package/src/generated/orbpro/manifest/capability-kind.js +1 -0
- package/src/generated/orbpro/manifest/capability-kind.ts +1 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.d.ts +93 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.js +160 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.ts +211 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.d.ts +99 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.js +175 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.ts +226 -0
- package/src/generated/orbpro/plugin.js +8 -0
- package/src/generated/orbpro/stream.d.ts +12 -0
- package/src/generated/orbpro/stream.js +14 -0
- package/src/generated/orbpro/stream.ts +15 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.d.ts +52 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.js +106 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.ts +162 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.d.ts +90 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.js +189 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.ts +270 -0
- package/src/generated/spacedatastandards/plg/PLG.d.ts +492 -0
- package/src/generated/spacedatastandards/plg/PLG.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLG.js +1139 -0
- package/src/generated/spacedatastandards/plg/PLG.ts +1600 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.d.ts +63 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.js +138 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.ts +189 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.d.ts +41 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.js +104 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.ts +151 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.d.ts +68 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.js +124 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.ts +184 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.d.ts +58 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.js +126 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.ts +161 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.d.ts +82 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.js +164 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.ts +244 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.d.ts +55 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.js +105 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.ts +162 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.d.ts +42 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.js +83 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.ts +127 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.d.ts +36 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.js +90 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.ts +127 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.d.ts +53 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.js +153 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.ts +210 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.d.ts +70 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.js +149 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.ts +212 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.d.ts +73 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.js +199 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.ts +292 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.d.ts +40 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.js +103 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.ts +148 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.d.ts +41 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.js +82 -0
- package/src/generated/spacedatastandards/plg/{plugin-capability.ts → PluginCapability.ts} +55 -18
- package/src/generated/spacedatastandards/plg/PluginDependency.d.ts +42 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.js +80 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.ts +124 -0
- package/src/generated/spacedatastandards/plg/TAB.d.ts +85 -0
- package/src/generated/spacedatastandards/plg/TAB.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/TAB.js +173 -0
- package/src/generated/spacedatastandards/plg/TAB.ts +228 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.js +20 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.ts +23 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.js +20 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.ts +23 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.d.ts +20 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.js +22 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.ts +25 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.d.ts +10 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.js +12 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.ts +13 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.d.ts +51 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.js +53 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.ts +55 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.d.ts +15 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.js +17 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.ts +19 -0
- package/src/generated/spacedatastandards/plg/main.d.ts +29 -0
- package/src/generated/spacedatastandards/plg/main.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/main.js +30 -0
- package/src/generated/spacedatastandards/plg/main.ts +32 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.d.ts +17 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.js +19 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.ts +21 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.d.ts +82 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.js +84 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.ts +103 -0
- package/src/generated/spacedatastandards/plg/publicationState.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/publicationState.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/publicationState.js +20 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.js +20 -0
- package/src/host/AGENTS.md +2 -2
- package/src/host/abi.js +53 -66
- package/src/host/browserHost.js +355 -8
- package/src/host/cpp/keyslotClient.hpp +231 -0
- package/src/host/cpp/secretsClient.hpp +583 -0
- package/src/host/hostcallWire.js +183 -0
- package/src/host/index.js +2 -0
- package/src/host/isomorphicLoader.js +44 -7
- package/src/host/nodeHost.js +227 -8
- package/src/host/sabHostcallChannel.js +206 -0
- package/src/host/timerDriver.js +203 -0
- package/src/host/wasiShim.js +41 -1
- package/src/host/wasiThreadBrowserWorker.mjs +48 -0
- package/src/host/wasiThreadHost.js +393 -0
- package/src/host/wasiThreadWorker.mjs +32 -0
- package/src/host/wasiThreadWorkerRuntime.js +93 -0
- package/src/http/index.js +339 -0
- package/src/index.d.ts +716 -10
- package/src/index.js +4 -0
- package/src/invoke/codec.js +1202 -128
- package/src/invoke/index.js +5 -1
- package/src/licensing/index.d.ts +2 -0
- package/src/licensing/index.js +2 -0
- package/src/licensing/records.js +287 -8
- package/src/manifest/codec.js +62 -14
- package/src/manifest/index.js +2 -0
- package/src/manifest/legacyToPlg.js +164 -25
- package/src/manifest/normalize.js +1 -0
- package/src/manifest/plgCodec.js +1303 -62
- package/src/manifest/typeRefs.js +162 -24
- package/src/runtime/compiledRuntimeAbi.js +47 -0
- package/src/runtime/compiledRuntimeAbi.json +33 -0
- package/src/runtime/index.d.ts +32 -0
- package/src/runtime/index.js +1 -0
- package/src/runtime-host/index.js +3 -0
- package/src/runtime-host/methodRegistry.js +55 -0
- package/src/standards/index.js +200 -56
- package/src/standards/sharedCatalog.js +16 -0
- package/src/testing/browserModuleHarness.js +604 -31
- package/src/testing/docker/wasmedge-parity.Dockerfile +39 -0
- package/src/testing/index.d.ts +151 -0
- package/src/testing/index.js +21 -0
- package/src/testing/native/wasmedge_emscripten_pthread_runner.c +25 -1
- package/src/testing/parityBrowserRunner.js +138 -0
- package/src/testing/parityHarness.js +616 -0
- package/src/testing/parityLanes.js +537 -0
- package/src/testing/processInvoke.js +29 -21
- package/src/testing/streamInvokeCodec.js +10 -175
- package/src/testing/wasmedgePin.json +6 -0
- package/src/testing/workerModuleHarness.js +242 -0
- package/src/testing/workerModuleHarnessWorker.js +176 -0
- package/src/transport/index.js +3 -0
- package/src/transport/pki.js +299 -11
- package/src/transport/records.js +16 -7
- package/src/utils/ecdsaDer.js +106 -0
- package/src/utils/wasmCrypto.js +0 -43
- package/templates/gpu-module/README.md +48 -0
- package/templates/gpu-module/include/space_data_gpu_abi.h +122 -0
- package/templates/gpu-module/manifest.json +84 -0
- package/schemas/PluginInvokeRequest.fbs +0 -18
- package/schemas/PluginInvokeResponse.fbs +0 -30
- package/schemas/spacedatastandards/PLG.fbs +0 -191
- package/src/generated/orbpro/invoke/plugin-invoke-request.d.ts +0 -51
- package/src/generated/orbpro/invoke/plugin-invoke-request.d.ts.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-request.js +0 -131
- package/src/generated/orbpro/invoke/plugin-invoke-request.js.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-request.ts +0 -173
- package/src/generated/orbpro/invoke/plugin-invoke-response.d.ts +0 -76
- package/src/generated/orbpro/invoke/plugin-invoke-response.d.ts.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-response.js +0 -184
- package/src/generated/orbpro/invoke/plugin-invoke-response.js.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-response.ts +0 -243
- package/src/generated/orbpro/invoke.d.ts +0 -3
- package/src/generated/orbpro/invoke.js +0 -5
- package/src/generated/spacedatastandards/plg/entry-function.js +0 -86
- package/src/generated/spacedatastandards/plg/entry-function.ts +0 -119
- package/src/generated/spacedatastandards/plg/index.js +0 -16
- package/src/generated/spacedatastandards/plg/index.ts +0 -11
- package/src/generated/spacedatastandards/plg/plg.js +0 -657
- package/src/generated/spacedatastandards/plg/plg.ts +0 -924
- package/src/generated/spacedatastandards/plg/plugin-capability.js +0 -66
- package/src/generated/spacedatastandards/plg/plugin-category.js +0 -15
- package/src/generated/spacedatastandards/plg/plugin-category.ts +0 -53
- package/src/generated/spacedatastandards/plg/plugin-dependency.js +0 -63
- package/src/generated/spacedatastandards/plg/plugin-dependency.ts +0 -86
- package/src/generated/spacedatastandards/plg/publication-state.js +0 -9
- package/src/generated/spacedatastandards/plg/purchase-tier.js +0 -9
- /package/src/generated/spacedatastandards/plg/{publication-state.ts → publicationState.ts} +0 -0
- /package/src/generated/spacedatastandards/plg/{purchase-tier.ts → purchaseTier.ts} +0 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { normalizeProgramForSdnFlow } from "./normalize.js";
|
|
2
|
+
|
|
3
|
+
function cloneFrame(frame, portId) {
|
|
4
|
+
return Object.assign({}, frame, {
|
|
5
|
+
portId,
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function normalizeQueueDepth(value, fallback = Infinity) {
|
|
10
|
+
const numeric = Number(value);
|
|
11
|
+
if (!Number.isFinite(numeric) || numeric <= 0) {
|
|
12
|
+
return fallback;
|
|
13
|
+
}
|
|
14
|
+
return Math.max(1, Math.trunc(numeric));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function applyBackpressure(
|
|
18
|
+
queue,
|
|
19
|
+
frames,
|
|
20
|
+
policy = "queue",
|
|
21
|
+
queueDepth = Infinity,
|
|
22
|
+
) {
|
|
23
|
+
const normalizedDepth = normalizeQueueDepth(queueDepth);
|
|
24
|
+
const normalizedPolicy = String(policy ?? "queue")
|
|
25
|
+
.trim()
|
|
26
|
+
.toLowerCase();
|
|
27
|
+
|
|
28
|
+
for (const frame of frames) {
|
|
29
|
+
if (queue.length < normalizedDepth) {
|
|
30
|
+
queue.push(frame);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (normalizedPolicy === "drop-oldest") {
|
|
35
|
+
queue.shift();
|
|
36
|
+
queue.push(frame);
|
|
37
|
+
} else if (normalizedPolicy !== "drop-newest") {
|
|
38
|
+
queue.push(frame);
|
|
39
|
+
if (queue.length > normalizedDepth) {
|
|
40
|
+
queue.splice(0, queue.length - normalizedDepth);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getPortQueues(queueMap, nodeId) {
|
|
47
|
+
let portQueues = queueMap.get(nodeId);
|
|
48
|
+
if (!portQueues) {
|
|
49
|
+
portQueues = new Map();
|
|
50
|
+
queueMap.set(nodeId, portQueues);
|
|
51
|
+
}
|
|
52
|
+
return portQueues;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getFrameQueue(queueMap, nodeId, portId) {
|
|
56
|
+
const portQueues = getPortQueues(queueMap, nodeId);
|
|
57
|
+
let queue = portQueues.get(portId);
|
|
58
|
+
if (!queue) {
|
|
59
|
+
queue = [];
|
|
60
|
+
portQueues.set(portId, queue);
|
|
61
|
+
}
|
|
62
|
+
return queue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function snapshotQueues(queueMap) {
|
|
66
|
+
const snapshot = {};
|
|
67
|
+
for (const [nodeId, portQueues] of queueMap.entries()) {
|
|
68
|
+
snapshot[nodeId] = {};
|
|
69
|
+
for (const [portId, frames] of portQueues.entries()) {
|
|
70
|
+
snapshot[nodeId][portId] = frames.length;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return snapshot;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function drainReadyFrames(queue, maxBatch) {
|
|
77
|
+
if (!Array.isArray(queue) || queue.length === 0) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
return queue.splice(0, Math.min(queue.length, maxBatch));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export class FlowRuntime {
|
|
84
|
+
#registry;
|
|
85
|
+
|
|
86
|
+
#program = null;
|
|
87
|
+
|
|
88
|
+
#queueMap = new Map();
|
|
89
|
+
|
|
90
|
+
#maxInvocationsPerDrain;
|
|
91
|
+
|
|
92
|
+
#onSinkOutput;
|
|
93
|
+
|
|
94
|
+
constructor(options = {}) {
|
|
95
|
+
this.#registry = options.registry ?? null;
|
|
96
|
+
this.#maxInvocationsPerDrain = Math.max(
|
|
97
|
+
1,
|
|
98
|
+
Number(options.maxInvocationsPerDrain ?? 1024) || 1024,
|
|
99
|
+
);
|
|
100
|
+
this.#onSinkOutput =
|
|
101
|
+
typeof options.onSinkOutput === "function" ? options.onSinkOutput : null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
loadProgram(program) {
|
|
105
|
+
this.#program = normalizeProgramForSdnFlow(program);
|
|
106
|
+
this.#queueMap.clear();
|
|
107
|
+
return this.#program;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
getProgram() {
|
|
111
|
+
return this.#program;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
inspectQueues() {
|
|
115
|
+
return snapshotQueues(this.#queueMap);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
enqueueTriggerFrames(triggerId, frames) {
|
|
119
|
+
if (!this.#program) {
|
|
120
|
+
throw new Error("FlowRuntime requires loadProgram() before enqueue.");
|
|
121
|
+
}
|
|
122
|
+
const bindings = this.#program.triggerBindings.filter(
|
|
123
|
+
(binding) => binding.triggerId === triggerId,
|
|
124
|
+
);
|
|
125
|
+
for (const binding of bindings) {
|
|
126
|
+
const queue = getFrameQueue(
|
|
127
|
+
this.#queueMap,
|
|
128
|
+
binding.targetNodeId,
|
|
129
|
+
binding.targetPortId,
|
|
130
|
+
);
|
|
131
|
+
applyBackpressure(
|
|
132
|
+
queue,
|
|
133
|
+
frames.map((frame) => cloneFrame(frame, binding.targetPortId)),
|
|
134
|
+
binding.backpressurePolicy,
|
|
135
|
+
binding.queueDepth,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
enqueueNodeFrames(nodeId, portId, frames, backpressurePolicy, queueDepth) {
|
|
141
|
+
if (!this.#program) {
|
|
142
|
+
throw new Error("FlowRuntime requires loadProgram() before enqueue.");
|
|
143
|
+
}
|
|
144
|
+
const queue = getFrameQueue(this.#queueMap, nodeId, portId);
|
|
145
|
+
applyBackpressure(
|
|
146
|
+
queue,
|
|
147
|
+
frames.map((frame) => cloneFrame(frame, portId)),
|
|
148
|
+
backpressurePolicy,
|
|
149
|
+
queueDepth,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
isIdle() {
|
|
154
|
+
for (const portQueues of this.#queueMap.values()) {
|
|
155
|
+
for (const frames of portQueues.values()) {
|
|
156
|
+
if (frames.length > 0) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async drain(options = {}) {
|
|
165
|
+
if (!this.#program) {
|
|
166
|
+
throw new Error("FlowRuntime requires loadProgram() before drain.");
|
|
167
|
+
}
|
|
168
|
+
if (!this.#registry || typeof this.#registry.invoke !== "function") {
|
|
169
|
+
throw new Error(
|
|
170
|
+
"FlowRuntime requires a MethodRegistry-compatible registry.",
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const maxInvocations = Math.max(
|
|
175
|
+
1,
|
|
176
|
+
Number(options.maxInvocationsPerDrain ?? this.#maxInvocationsPerDrain) ||
|
|
177
|
+
this.#maxInvocationsPerDrain,
|
|
178
|
+
);
|
|
179
|
+
let invocations = 0;
|
|
180
|
+
|
|
181
|
+
while (invocations < maxInvocations) {
|
|
182
|
+
let readyNode = null;
|
|
183
|
+
let descriptor = null;
|
|
184
|
+
let inputs = [];
|
|
185
|
+
|
|
186
|
+
for (const node of this.#program.nodes ?? []) {
|
|
187
|
+
descriptor = this.#registry.getMethod(node.pluginId, node.methodId);
|
|
188
|
+
if (!descriptor) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const maxBatch = Math.max(
|
|
193
|
+
1,
|
|
194
|
+
Number(descriptor.method?.maxBatch ?? 1) || 1,
|
|
195
|
+
);
|
|
196
|
+
const portQueues = getPortQueues(this.#queueMap, node.nodeId);
|
|
197
|
+
const candidateInputs = [];
|
|
198
|
+
let missingRequiredInput = false;
|
|
199
|
+
|
|
200
|
+
for (const port of descriptor.method?.inputPorts ?? []) {
|
|
201
|
+
const queue = portQueues.get(port.portId) ?? [];
|
|
202
|
+
if (port.required !== false && queue.length === 0) {
|
|
203
|
+
missingRequiredInput = true;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
if (queue.length > 0) {
|
|
207
|
+
candidateInputs.push(...drainReadyFrames(queue, maxBatch));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (missingRequiredInput || candidateInputs.length === 0) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
readyNode = node;
|
|
216
|
+
inputs = candidateInputs;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (!readyNode || !descriptor || inputs.length === 0) {
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const response = await this.#registry.invoke({
|
|
225
|
+
pluginId: readyNode.pluginId,
|
|
226
|
+
methodId: readyNode.methodId,
|
|
227
|
+
inputs,
|
|
228
|
+
outputStreamCap: Number(options.outputStreamCap ?? 0) || 0,
|
|
229
|
+
});
|
|
230
|
+
invocations += 1;
|
|
231
|
+
|
|
232
|
+
for (const outputFrame of response.outputs ?? []) {
|
|
233
|
+
const edges = (this.#program.edges ?? []).filter(
|
|
234
|
+
(edge) =>
|
|
235
|
+
edge.fromNodeId === readyNode.nodeId &&
|
|
236
|
+
edge.fromPortId === outputFrame.portId,
|
|
237
|
+
);
|
|
238
|
+
if (edges.length === 0 && this.#onSinkOutput) {
|
|
239
|
+
await this.#onSinkOutput({
|
|
240
|
+
frame: outputFrame,
|
|
241
|
+
node: readyNode,
|
|
242
|
+
descriptor,
|
|
243
|
+
runtime: this,
|
|
244
|
+
});
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
for (const edge of edges) {
|
|
248
|
+
const queue = getFrameQueue(
|
|
249
|
+
this.#queueMap,
|
|
250
|
+
edge.toNodeId,
|
|
251
|
+
edge.toPortId,
|
|
252
|
+
);
|
|
253
|
+
applyBackpressure(
|
|
254
|
+
queue,
|
|
255
|
+
[cloneFrame(outputFrame, edge.toPortId)],
|
|
256
|
+
edge.backpressurePolicy,
|
|
257
|
+
edge.queueDepth,
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (response.yielded === true) {
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
invocations,
|
|
269
|
+
idle: this.isIdle(),
|
|
270
|
+
queues: this.inspectQueues(),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export default FlowRuntime;
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BackpressurePolicy,
|
|
3
|
+
FlowProgramT,
|
|
4
|
+
NodeKind,
|
|
5
|
+
TriggerKind,
|
|
6
|
+
} from "../generated/orbpro/flow.js";
|
|
7
|
+
import {
|
|
8
|
+
DrainPolicy,
|
|
9
|
+
PluginFamily,
|
|
10
|
+
PluginManifestT,
|
|
11
|
+
} from "../generated/orbpro/manifest.js";
|
|
12
|
+
import { decodeFlowProgram, decodePluginManifestPman } from "./flowCodec.js";
|
|
13
|
+
import {
|
|
14
|
+
normalizePayloadSchemaHash,
|
|
15
|
+
normalizePayloadWireFormatName,
|
|
16
|
+
} from "../manifest/typeRefs.js";
|
|
17
|
+
|
|
18
|
+
function enumSymbol(enumType, value, fallback = null) {
|
|
19
|
+
if (typeof value === "number" && enumType[value]) {
|
|
20
|
+
return enumType[value];
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
23
|
+
return value.trim();
|
|
24
|
+
}
|
|
25
|
+
return fallback;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function toKebabEnum(enumType, value, fallback) {
|
|
29
|
+
const symbol = enumSymbol(enumType, value, null);
|
|
30
|
+
if (!symbol) {
|
|
31
|
+
return fallback;
|
|
32
|
+
}
|
|
33
|
+
return symbol.toLowerCase().replace(/_/g, "-");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function toPlainTypeRef(typeRef) {
|
|
37
|
+
const rawSchemaHash = typeRef?.schemaHash ?? typeRef?.SCHEMA_HASH;
|
|
38
|
+
const schemaHash = normalizePayloadSchemaHash(rawSchemaHash) ?? [];
|
|
39
|
+
return {
|
|
40
|
+
schemaName: typeRef?.schemaName ?? typeRef?.SCHEMA_NAME ?? null,
|
|
41
|
+
fileIdentifier:
|
|
42
|
+
typeRef?.fileIdentifier ?? typeRef?.FILE_IDENTIFIER ?? null,
|
|
43
|
+
schemaVersion:
|
|
44
|
+
typeRef?.schemaVersion ?? typeRef?.SCHEMA_VERSION ?? null,
|
|
45
|
+
schemaHash,
|
|
46
|
+
acceptsAnyFlatbuffer: typeRef?.acceptsAnyFlatbuffer === true,
|
|
47
|
+
// WIRE FORMAT IS A DECLARATION, NEVER A DEFAULT-BY-ACCIDENT.
|
|
48
|
+
//
|
|
49
|
+
// This used to read `typeRef?.wireFormat === PayloadWireFormat.AlignedBinary`.
|
|
50
|
+
// The generated enum member is `ALIGNED_BINARY`; `AlignedBinary` does not
|
|
51
|
+
// exist, so that expression was `undefined === undefined` — TRUE — for every
|
|
52
|
+
// type ref that omitted `wireFormat`. The result: every CANONICAL FlatBuffer
|
|
53
|
+
// port type in every manifest normalized to "aligned-binary", so
|
|
54
|
+
// concreteTypesByWireFormat(types, "flatbuffer") found ZERO canonical types
|
|
55
|
+
// on both sides of an edge and resolveEdgeTypeContract fell through to its
|
|
56
|
+
// null return — reported as the self-contradictory
|
|
57
|
+
// "CAQ.fbs/$CAQ does not satisfy CAQ.fbs/$CAQ". Five shipped flow bundles
|
|
58
|
+
// could not be recompiled from main.
|
|
59
|
+
//
|
|
60
|
+
// The single canonical parser lives in ../manifest/typeRefs.js and already
|
|
61
|
+
// handles both the numeric FlatBuffer enum (1) and the string spellings;
|
|
62
|
+
// absent/empty means the default, "flatbuffer".
|
|
63
|
+
wireFormat:
|
|
64
|
+
normalizePayloadWireFormatName(
|
|
65
|
+
typeRef?.wireFormat ?? typeRef?.wire_format ?? typeRef?.WIRE_FORMAT,
|
|
66
|
+
) ?? "flatbuffer",
|
|
67
|
+
rootTypeName:
|
|
68
|
+
typeRef?.rootTypeName ?? typeRef?.rootType ?? typeRef?.ROOT_TYPE ?? null,
|
|
69
|
+
fixedStringLength: Number(typeRef?.fixedStringLength ?? 0),
|
|
70
|
+
byteLength: Number(typeRef?.byteLength ?? 0),
|
|
71
|
+
requiredAlignment: Number(typeRef?.requiredAlignment ?? 0),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function toPlainAcceptedTypeSet(typeSet) {
|
|
76
|
+
return {
|
|
77
|
+
setId: typeSet?.setId ?? null,
|
|
78
|
+
allowedTypes: Array.isArray(typeSet?.allowedTypes)
|
|
79
|
+
? typeSet.allowedTypes.map(toPlainTypeRef)
|
|
80
|
+
: [],
|
|
81
|
+
description: typeSet?.description ?? null,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function toPlainPort(port) {
|
|
86
|
+
return {
|
|
87
|
+
portId: port?.portId ?? "",
|
|
88
|
+
displayName: port?.displayName ?? null,
|
|
89
|
+
acceptedTypeSets: Array.isArray(port?.acceptedTypeSets)
|
|
90
|
+
? port.acceptedTypeSets.map(toPlainAcceptedTypeSet)
|
|
91
|
+
: [],
|
|
92
|
+
minStreams: Number(port?.minStreams ?? 1),
|
|
93
|
+
maxStreams: Number(port?.maxStreams ?? 1),
|
|
94
|
+
required: port?.required !== false,
|
|
95
|
+
description: port?.description ?? null,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function toPlainMethod(method) {
|
|
100
|
+
return {
|
|
101
|
+
methodId: method?.methodId ?? "",
|
|
102
|
+
displayName: method?.displayName ?? null,
|
|
103
|
+
inputPorts: Array.isArray(method?.inputPorts)
|
|
104
|
+
? method.inputPorts.map(toPlainPort)
|
|
105
|
+
: [],
|
|
106
|
+
outputPorts: Array.isArray(method?.outputPorts)
|
|
107
|
+
? method.outputPorts.map(toPlainPort)
|
|
108
|
+
: [],
|
|
109
|
+
maxBatch: Number(method?.maxBatch ?? 1),
|
|
110
|
+
drainPolicy: toKebabEnum(
|
|
111
|
+
DrainPolicy,
|
|
112
|
+
method?.drainPolicy,
|
|
113
|
+
"drain-until-yield",
|
|
114
|
+
),
|
|
115
|
+
description: method?.description ?? null,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function toPlainBuildArtifact(artifact) {
|
|
120
|
+
return {
|
|
121
|
+
artifactId: artifact?.artifactId ?? null,
|
|
122
|
+
kind: artifact?.kind ?? null,
|
|
123
|
+
path: artifact?.path ?? null,
|
|
124
|
+
target: artifact?.target ?? null,
|
|
125
|
+
entrySymbol: artifact?.entrySymbol ?? null,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function toPlainCapability(capability) {
|
|
130
|
+
return capability
|
|
131
|
+
? {
|
|
132
|
+
capability: capability.capability ?? null,
|
|
133
|
+
scope: capability.scope ?? null,
|
|
134
|
+
required: capability.required !== false,
|
|
135
|
+
description: capability.description ?? null,
|
|
136
|
+
}
|
|
137
|
+
: null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function toPlainTimer(timer) {
|
|
141
|
+
return timer
|
|
142
|
+
? {
|
|
143
|
+
timerId: timer.timerId ?? null,
|
|
144
|
+
methodId: timer.methodId ?? null,
|
|
145
|
+
inputPortId: timer.inputPortId ?? null,
|
|
146
|
+
defaultIntervalMs: timer.defaultIntervalMs ?? 0,
|
|
147
|
+
description: timer.description ?? null,
|
|
148
|
+
}
|
|
149
|
+
: null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function toPlainProtocol(protocol) {
|
|
153
|
+
return protocol
|
|
154
|
+
? {
|
|
155
|
+
protocolId: protocol.protocolId ?? null,
|
|
156
|
+
methodId: protocol.methodId ?? null,
|
|
157
|
+
inputPortId: protocol.inputPortId ?? null,
|
|
158
|
+
outputPortId: protocol.outputPortId ?? null,
|
|
159
|
+
description: protocol.description ?? null,
|
|
160
|
+
}
|
|
161
|
+
: null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function asManifest(manifest) {
|
|
165
|
+
if (manifest instanceof PluginManifestT) {
|
|
166
|
+
return manifest;
|
|
167
|
+
}
|
|
168
|
+
if (
|
|
169
|
+
manifest instanceof Uint8Array ||
|
|
170
|
+
manifest instanceof ArrayBuffer ||
|
|
171
|
+
ArrayBuffer.isView(manifest)
|
|
172
|
+
) {
|
|
173
|
+
return decodePluginManifestPman(manifest);
|
|
174
|
+
}
|
|
175
|
+
return Object.assign(new PluginManifestT(), manifest);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function asProgram(program) {
|
|
179
|
+
if (program instanceof FlowProgramT) {
|
|
180
|
+
return program;
|
|
181
|
+
}
|
|
182
|
+
if (
|
|
183
|
+
program instanceof Uint8Array ||
|
|
184
|
+
program instanceof ArrayBuffer ||
|
|
185
|
+
ArrayBuffer.isView(program)
|
|
186
|
+
) {
|
|
187
|
+
return decodeFlowProgram(program);
|
|
188
|
+
}
|
|
189
|
+
return Object.assign(new FlowProgramT(), program);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function normalizeManifestForSdnFlow(manifest) {
|
|
193
|
+
const normalized = asManifest(manifest);
|
|
194
|
+
return {
|
|
195
|
+
pluginId: normalized.pluginId ?? "",
|
|
196
|
+
name: normalized.name ?? null,
|
|
197
|
+
version: normalized.version ?? null,
|
|
198
|
+
pluginFamily: enumSymbol(
|
|
199
|
+
PluginFamily,
|
|
200
|
+
normalized.pluginFamily,
|
|
201
|
+
String(normalized.pluginFamily ?? ""),
|
|
202
|
+
),
|
|
203
|
+
methods: Array.isArray(normalized.methods)
|
|
204
|
+
? normalized.methods.map(toPlainMethod)
|
|
205
|
+
: [],
|
|
206
|
+
capabilities: Array.isArray(normalized.capabilities)
|
|
207
|
+
? normalized.capabilities.map(toPlainCapability).filter(Boolean)
|
|
208
|
+
: [],
|
|
209
|
+
timers: Array.isArray(normalized.timers)
|
|
210
|
+
? normalized.timers.map(toPlainTimer).filter(Boolean)
|
|
211
|
+
: [],
|
|
212
|
+
protocols: Array.isArray(normalized.protocols)
|
|
213
|
+
? normalized.protocols.map(toPlainProtocol).filter(Boolean)
|
|
214
|
+
: [],
|
|
215
|
+
schemasUsed: Array.isArray(normalized.schemasUsed)
|
|
216
|
+
? normalized.schemasUsed.map(toPlainTypeRef)
|
|
217
|
+
: [],
|
|
218
|
+
buildArtifacts: Array.isArray(normalized.buildArtifacts)
|
|
219
|
+
? normalized.buildArtifacts.map(toPlainBuildArtifact)
|
|
220
|
+
: [],
|
|
221
|
+
abiVersion: Number(normalized.abiVersion ?? 1),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export function normalizeProgramForSdnFlow(program) {
|
|
226
|
+
const normalized = asProgram(program);
|
|
227
|
+
return {
|
|
228
|
+
programId: normalized.programId ?? "",
|
|
229
|
+
name: normalized.name ?? null,
|
|
230
|
+
version: normalized.version ?? null,
|
|
231
|
+
nodes: Array.isArray(normalized.nodes)
|
|
232
|
+
? normalized.nodes.map((node) => ({
|
|
233
|
+
nodeId: node?.nodeId ?? "",
|
|
234
|
+
pluginId: node?.pluginId ?? "",
|
|
235
|
+
methodId: node?.methodId ?? "",
|
|
236
|
+
kind: toKebabEnum(NodeKind, node?.kind, "transform"),
|
|
237
|
+
drainPolicy: toKebabEnum(
|
|
238
|
+
DrainPolicy,
|
|
239
|
+
node?.drainPolicy,
|
|
240
|
+
"drain-until-yield",
|
|
241
|
+
),
|
|
242
|
+
timeSliceMicros: Number(node?.timeSliceMicros ?? 0),
|
|
243
|
+
}))
|
|
244
|
+
: [],
|
|
245
|
+
edges: Array.isArray(normalized.edges)
|
|
246
|
+
? normalized.edges.map((edge) => ({
|
|
247
|
+
edgeId: edge?.edgeId ?? "",
|
|
248
|
+
fromNodeId: edge?.fromNodeId ?? "",
|
|
249
|
+
fromPortId: edge?.fromPortId ?? "",
|
|
250
|
+
toNodeId: edge?.toNodeId ?? "",
|
|
251
|
+
toPortId: edge?.toPortId ?? "",
|
|
252
|
+
acceptedTypes: Array.isArray(edge?.acceptedTypes)
|
|
253
|
+
? edge.acceptedTypes.map(toPlainTypeRef)
|
|
254
|
+
: [],
|
|
255
|
+
backpressurePolicy: toKebabEnum(
|
|
256
|
+
BackpressurePolicy,
|
|
257
|
+
edge?.backpressurePolicy,
|
|
258
|
+
"queue",
|
|
259
|
+
),
|
|
260
|
+
queueDepth: Number(edge?.queueDepth ?? 1),
|
|
261
|
+
}))
|
|
262
|
+
: [],
|
|
263
|
+
triggers: Array.isArray(normalized.triggers)
|
|
264
|
+
? normalized.triggers.map((trigger) => ({
|
|
265
|
+
triggerId: trigger?.triggerId ?? "",
|
|
266
|
+
kind: toKebabEnum(TriggerKind, trigger?.kind, "manual"),
|
|
267
|
+
source: trigger?.source ?? null,
|
|
268
|
+
protocolId: trigger?.protocolId ?? null,
|
|
269
|
+
defaultIntervalMs: trigger?.defaultIntervalMs ?? 0,
|
|
270
|
+
acceptedTypes: Array.isArray(trigger?.acceptedTypes)
|
|
271
|
+
? trigger.acceptedTypes.map(toPlainTypeRef)
|
|
272
|
+
: [],
|
|
273
|
+
description: trigger?.description ?? null,
|
|
274
|
+
}))
|
|
275
|
+
: [],
|
|
276
|
+
triggerBindings: Array.isArray(normalized.triggerBindings)
|
|
277
|
+
? normalized.triggerBindings.map((binding) => ({
|
|
278
|
+
triggerId: binding?.triggerId ?? "",
|
|
279
|
+
targetNodeId: binding?.targetNodeId ?? "",
|
|
280
|
+
targetPortId: binding?.targetPortId ?? "",
|
|
281
|
+
backpressurePolicy: toKebabEnum(
|
|
282
|
+
BackpressurePolicy,
|
|
283
|
+
binding?.backpressurePolicy,
|
|
284
|
+
"queue",
|
|
285
|
+
),
|
|
286
|
+
queueDepth: Number(binding?.queueDepth ?? 1),
|
|
287
|
+
}))
|
|
288
|
+
: [],
|
|
289
|
+
requiredPlugins: Array.isArray(normalized.requiredPlugins)
|
|
290
|
+
? [...normalized.requiredPlugins]
|
|
291
|
+
: [],
|
|
292
|
+
description: normalized.description ?? null,
|
|
293
|
+
};
|
|
294
|
+
}
|