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
package/src/manifest/plgCodec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Codec for the canonical spacedatastandards.org `PLG` plugin manifest schema
|
|
3
|
-
*
|
|
3
|
+
* generated from the installed SDS package's `schema/PLG/main.fbs`.
|
|
4
4
|
*
|
|
5
5
|
* This codec replaces the older internal `PluginManifest` (`PMAN`) schema as
|
|
6
6
|
* the on-the-wire manifest format embedded in plugin wasm artifacts.
|
|
@@ -13,13 +13,31 @@ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
|
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
EntryFunction,
|
|
16
|
+
FlatBufferTypeRef,
|
|
16
17
|
PLG,
|
|
18
|
+
PLGAcceptedTypeSet,
|
|
19
|
+
PLGBuildArtifact,
|
|
20
|
+
PLGFlowEdge,
|
|
21
|
+
PLGFlowEdgeContract,
|
|
22
|
+
PLGFlowNode,
|
|
23
|
+
PLGFlowTrigger,
|
|
24
|
+
PLGFlowTriggerBinding,
|
|
25
|
+
PLGHostCapability,
|
|
26
|
+
PLGMethodManifest,
|
|
27
|
+
PLGPortManifest,
|
|
28
|
+
PLGProtocolSpec,
|
|
29
|
+
PLGTimerSpec,
|
|
17
30
|
PluginCapability,
|
|
18
31
|
PluginDependency,
|
|
32
|
+
drainBehavior,
|
|
33
|
+
flowEdgeRoutePolicy,
|
|
34
|
+
hostCapabilityKind,
|
|
35
|
+
invokeSurfaceKind,
|
|
36
|
+
payloadWireFormat,
|
|
19
37
|
publicationState,
|
|
20
38
|
purchaseTier,
|
|
21
39
|
pluginCategory,
|
|
22
|
-
} from "../generated/spacedatastandards/plg/
|
|
40
|
+
} from "../generated/spacedatastandards/plg/main.js";
|
|
23
41
|
import { toUint8Array } from "../runtime/bufferLike.js";
|
|
24
42
|
|
|
25
43
|
export const PLG_FILE_IDENTIFIER = "$PLG";
|
|
@@ -78,6 +96,29 @@ function normalizeByteVector(value) {
|
|
|
78
96
|
return null;
|
|
79
97
|
}
|
|
80
98
|
|
|
99
|
+
function normalizeOptionalString(value) {
|
|
100
|
+
if (value === undefined || value === null) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
const normalized = String(value).trim();
|
|
104
|
+
return normalized.length > 0 ? normalized : null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function normalizeUnsignedInteger(value, fallback = 0) {
|
|
108
|
+
const normalized = Number(value ?? fallback);
|
|
109
|
+
if (!Number.isFinite(normalized)) {
|
|
110
|
+
return fallback;
|
|
111
|
+
}
|
|
112
|
+
return Math.max(0, Math.trunc(normalized));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function canonicalEnumKey(value) {
|
|
116
|
+
return String(value ?? "")
|
|
117
|
+
.trim()
|
|
118
|
+
.toLowerCase()
|
|
119
|
+
.replace(/-/g, "_");
|
|
120
|
+
}
|
|
121
|
+
|
|
81
122
|
const pluginTypeByName = Object.freeze({
|
|
82
123
|
sensor: pluginCategory.Sensor,
|
|
83
124
|
propagator: pluginCategory.Propagator,
|
|
@@ -141,6 +182,138 @@ function resolveListingStatus(value) {
|
|
|
141
182
|
return listingStatusByName[key] ?? publicationState.Public;
|
|
142
183
|
}
|
|
143
184
|
|
|
185
|
+
const payloadWireFormatByName = Object.freeze({
|
|
186
|
+
flatbuffer: payloadWireFormat.FLATBUFFER,
|
|
187
|
+
aligned_binary: payloadWireFormat.ALIGNED_BINARY,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
function resolvePayloadWireFormat(value) {
|
|
191
|
+
if (typeof value === "number") {
|
|
192
|
+
return value;
|
|
193
|
+
}
|
|
194
|
+
return payloadWireFormatByName[canonicalEnumKey(value)] ?? payloadWireFormat.FLATBUFFER;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function payloadWireFormatName(value) {
|
|
198
|
+
return resolvePayloadWireFormat(value) === payloadWireFormat.ALIGNED_BINARY
|
|
199
|
+
? "aligned-binary"
|
|
200
|
+
: "flatbuffer";
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const flowEdgeRoutePolicyByName = Object.freeze({
|
|
204
|
+
canonical_only: flowEdgeRoutePolicy.CANONICAL_ONLY,
|
|
205
|
+
aligned_shared_arena_or_canonical:
|
|
206
|
+
flowEdgeRoutePolicy.ALIGNED_SHARED_ARENA_OR_CANONICAL,
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
function resolveFlowEdgeRoutePolicy(value) {
|
|
210
|
+
if (typeof value === "number") return value;
|
|
211
|
+
return flowEdgeRoutePolicyByName[canonicalEnumKey(value)] ??
|
|
212
|
+
flowEdgeRoutePolicy.CANONICAL_ONLY;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function flowEdgeRoutePolicyName(value) {
|
|
216
|
+
return resolveFlowEdgeRoutePolicy(value) ===
|
|
217
|
+
flowEdgeRoutePolicy.ALIGNED_SHARED_ARENA_OR_CANONICAL
|
|
218
|
+
? "aligned-shared-arena-or-canonical"
|
|
219
|
+
: "canonical-only";
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const invokeSurfaceByName = Object.freeze({
|
|
223
|
+
direct: invokeSurfaceKind.DIRECT,
|
|
224
|
+
command: invokeSurfaceKind.COMMAND,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
function resolveInvokeSurface(value) {
|
|
228
|
+
if (typeof value === "number") {
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
231
|
+
return invokeSurfaceByName[canonicalEnumKey(value)] ?? null;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function invokeSurfaceName(value) {
|
|
235
|
+
return resolveInvokeSurface(value) === invokeSurfaceKind.COMMAND
|
|
236
|
+
? "command"
|
|
237
|
+
: "direct";
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const drainPolicyByName = Object.freeze({
|
|
241
|
+
single_shot: drainBehavior.SINGLE_SHOT,
|
|
242
|
+
drain_until_yield: drainBehavior.DRAIN_UNTIL_YIELD,
|
|
243
|
+
drain_to_empty: drainBehavior.DRAIN_TO_EMPTY,
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
function resolveDrainPolicy(value) {
|
|
247
|
+
if (typeof value === "number") {
|
|
248
|
+
return value;
|
|
249
|
+
}
|
|
250
|
+
return drainPolicyByName[canonicalEnumKey(value)] ?? drainBehavior.DRAIN_UNTIL_YIELD;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function drainPolicyName(value) {
|
|
254
|
+
switch (resolveDrainPolicy(value)) {
|
|
255
|
+
case drainBehavior.SINGLE_SHOT:
|
|
256
|
+
return "single-shot";
|
|
257
|
+
case drainBehavior.DRAIN_TO_EMPTY:
|
|
258
|
+
return "drain-to-empty";
|
|
259
|
+
case drainBehavior.DRAIN_UNTIL_YIELD:
|
|
260
|
+
default:
|
|
261
|
+
return "drain-until-yield";
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const hostCapabilityByName = Object.freeze({
|
|
266
|
+
clock: hostCapabilityKind.CLOCK,
|
|
267
|
+
random: hostCapabilityKind.RANDOM,
|
|
268
|
+
logging: hostCapabilityKind.LOGGING,
|
|
269
|
+
timers: hostCapabilityKind.TIMERS,
|
|
270
|
+
pubsub: hostCapabilityKind.PUBSUB,
|
|
271
|
+
protocol_dial: hostCapabilityKind.PROTOCOL_DIAL,
|
|
272
|
+
protocol_handle: hostCapabilityKind.PROTOCOL_HANDLE,
|
|
273
|
+
storage_query: hostCapabilityKind.STORAGE_QUERY,
|
|
274
|
+
scene_access: hostCapabilityKind.SCENE_ACCESS,
|
|
275
|
+
entity_access: hostCapabilityKind.ENTITY_ACCESS,
|
|
276
|
+
render_hooks: hostCapabilityKind.RENDER_HOOKS,
|
|
277
|
+
http: hostCapabilityKind.HTTP,
|
|
278
|
+
filesystem: hostCapabilityKind.FILESYSTEM,
|
|
279
|
+
pipe: hostCapabilityKind.PIPE,
|
|
280
|
+
network: hostCapabilityKind.NETWORK,
|
|
281
|
+
database: hostCapabilityKind.DATABASE,
|
|
282
|
+
storage_adapter: hostCapabilityKind.STORAGE_ADAPTER,
|
|
283
|
+
storage_write: hostCapabilityKind.STORAGE_WRITE,
|
|
284
|
+
wallet_sign: hostCapabilityKind.WALLET_SIGN,
|
|
285
|
+
ipfs: hostCapabilityKind.IPFS,
|
|
286
|
+
tls: hostCapabilityKind.TLS,
|
|
287
|
+
mqtt: hostCapabilityKind.MQTT,
|
|
288
|
+
websocket: hostCapabilityKind.WEBSOCKET,
|
|
289
|
+
tcp: hostCapabilityKind.TCP,
|
|
290
|
+
udp: hostCapabilityKind.UDP,
|
|
291
|
+
process_exec: hostCapabilityKind.PROCESS_EXEC,
|
|
292
|
+
context_read: hostCapabilityKind.CONTEXT_READ,
|
|
293
|
+
context_write: hostCapabilityKind.CONTEXT_WRITE,
|
|
294
|
+
crypto_hash: hostCapabilityKind.CRYPTO_HASH,
|
|
295
|
+
crypto_sign: hostCapabilityKind.CRYPTO_SIGN,
|
|
296
|
+
crypto_verify: hostCapabilityKind.CRYPTO_VERIFY,
|
|
297
|
+
crypto_encrypt: hostCapabilityKind.CRYPTO_ENCRYPT,
|
|
298
|
+
crypto_decrypt: hostCapabilityKind.CRYPTO_DECRYPT,
|
|
299
|
+
crypto_key_agreement: hostCapabilityKind.CRYPTO_KEY_AGREEMENT,
|
|
300
|
+
crypto_kdf: hostCapabilityKind.CRYPTO_KDF,
|
|
301
|
+
schedule_cron: hostCapabilityKind.SCHEDULE_CRON,
|
|
302
|
+
storage_ingest: hostCapabilityKind.STORAGE_INGEST,
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
function resolveHostCapability(value) {
|
|
306
|
+
if (typeof value === "number") {
|
|
307
|
+
return value;
|
|
308
|
+
}
|
|
309
|
+
return hostCapabilityByName[canonicalEnumKey(value)] ?? hostCapabilityKind.CLOCK;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function hostCapabilityName(value) {
|
|
313
|
+
const enumName = hostCapabilityKind[resolveHostCapability(value)];
|
|
314
|
+
return typeof enumName === "string" ? enumName.toLowerCase() : "clock";
|
|
315
|
+
}
|
|
316
|
+
|
|
144
317
|
function addStringVector(builder, values, addVectorHelper) {
|
|
145
318
|
const strings = normalizeStringArray(values);
|
|
146
319
|
if (strings.length === 0) {
|
|
@@ -207,10 +380,17 @@ function addEntryFunction(builder, entry) {
|
|
|
207
380
|
}
|
|
208
381
|
|
|
209
382
|
function addPluginCapability(builder, capability) {
|
|
210
|
-
const
|
|
383
|
+
const source =
|
|
384
|
+
typeof capability === "string" ? { name: capability } : capability ?? {};
|
|
385
|
+
const name =
|
|
386
|
+
typeof source.name === "string"
|
|
387
|
+
? source.name
|
|
388
|
+
: typeof source.capability === "string"
|
|
389
|
+
? source.capability
|
|
390
|
+
: null;
|
|
211
391
|
const version =
|
|
212
|
-
typeof
|
|
213
|
-
const required =
|
|
392
|
+
typeof source.version === "string" ? source.version : null;
|
|
393
|
+
const required = source.required !== false;
|
|
214
394
|
|
|
215
395
|
const nameOffset = name ? builder.createString(name) : 0;
|
|
216
396
|
const versionOffset = version ? builder.createString(version) : 0;
|
|
@@ -268,6 +448,829 @@ function addOffsetVector(builder, offsets) {
|
|
|
268
448
|
return builder.endVector();
|
|
269
449
|
}
|
|
270
450
|
|
|
451
|
+
function addFlatBufferTypeRef(builder, typeRef = {}) {
|
|
452
|
+
if (typeof typeRef === "string") {
|
|
453
|
+
typeRef = { schemaName: typeRef };
|
|
454
|
+
}
|
|
455
|
+
const schemaName = normalizeOptionalString(
|
|
456
|
+
pick(typeRef, "schemaName", "schema_name", "SCHEMA_NAME", "name"),
|
|
457
|
+
);
|
|
458
|
+
const fileIdentifier = normalizeOptionalString(
|
|
459
|
+
pick(typeRef, "fileIdentifier", "file_identifier", "FILE_IDENTIFIER"),
|
|
460
|
+
);
|
|
461
|
+
const schemaVersion = normalizeOptionalString(
|
|
462
|
+
pick(typeRef, "schemaVersion", "schema_version", "SCHEMA_VERSION"),
|
|
463
|
+
);
|
|
464
|
+
const rootType = normalizeOptionalString(
|
|
465
|
+
pick(typeRef, "rootTypeName", "root_type_name", "rootType", "ROOT_TYPE"),
|
|
466
|
+
);
|
|
467
|
+
const schemaHash = normalizeByteVector(
|
|
468
|
+
pick(typeRef, "schemaHash", "schema_hash", "SCHEMA_HASH"),
|
|
469
|
+
);
|
|
470
|
+
const acceptsAnyFlatbuffer = Boolean(
|
|
471
|
+
pick(
|
|
472
|
+
typeRef,
|
|
473
|
+
"acceptsAnyFlatbuffer",
|
|
474
|
+
"accepts_any_flatbuffer",
|
|
475
|
+
"ACCEPTS_ANY_FLATBUFFER",
|
|
476
|
+
) ?? false,
|
|
477
|
+
);
|
|
478
|
+
const wireFormat = resolvePayloadWireFormat(
|
|
479
|
+
pick(typeRef, "wireFormat", "wire_format", "WIRE_FORMAT"),
|
|
480
|
+
);
|
|
481
|
+
const fixedStringLength = normalizeUnsignedInteger(
|
|
482
|
+
pick(typeRef, "fixedStringLength", "fixed_string_length", "FIXED_STRING_LENGTH"),
|
|
483
|
+
);
|
|
484
|
+
const byteLength = normalizeUnsignedInteger(
|
|
485
|
+
pick(typeRef, "byteLength", "byte_length", "BYTE_LENGTH"),
|
|
486
|
+
);
|
|
487
|
+
const requiredAlignment = normalizeUnsignedInteger(
|
|
488
|
+
pick(typeRef, "requiredAlignment", "required_alignment", "REQUIRED_ALIGNMENT"),
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
const schemaNameOffset = schemaName ? builder.createString(schemaName) : 0;
|
|
492
|
+
const fileIdentifierOffset = fileIdentifier
|
|
493
|
+
? builder.createString(fileIdentifier)
|
|
494
|
+
: 0;
|
|
495
|
+
const schemaVersionOffset = schemaVersion ? builder.createString(schemaVersion) : 0;
|
|
496
|
+
const rootTypeOffset = rootType ? builder.createString(rootType) : 0;
|
|
497
|
+
const schemaHashOffset = addByteVector(
|
|
498
|
+
builder,
|
|
499
|
+
schemaHash,
|
|
500
|
+
FlatBufferTypeRef.startSchemaHashVector,
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
FlatBufferTypeRef.startFlatBufferTypeRef(builder);
|
|
504
|
+
if (schemaNameOffset) FlatBufferTypeRef.addSchemaName(builder, schemaNameOffset);
|
|
505
|
+
if (fileIdentifierOffset)
|
|
506
|
+
FlatBufferTypeRef.addFileIdentifier(builder, fileIdentifierOffset);
|
|
507
|
+
if (schemaVersionOffset)
|
|
508
|
+
FlatBufferTypeRef.addSchemaVersion(builder, schemaVersionOffset);
|
|
509
|
+
if (rootTypeOffset) FlatBufferTypeRef.addRootType(builder, rootTypeOffset);
|
|
510
|
+
if (schemaHashOffset) FlatBufferTypeRef.addSchemaHash(builder, schemaHashOffset);
|
|
511
|
+
if (acceptsAnyFlatbuffer)
|
|
512
|
+
FlatBufferTypeRef.addAcceptsAnyFlatbuffer(builder, acceptsAnyFlatbuffer);
|
|
513
|
+
if (wireFormat !== payloadWireFormat.FLATBUFFER)
|
|
514
|
+
FlatBufferTypeRef.addWireFormat(builder, wireFormat);
|
|
515
|
+
if (fixedStringLength > 0)
|
|
516
|
+
FlatBufferTypeRef.addFixedStringLength(builder, fixedStringLength);
|
|
517
|
+
if (byteLength > 0) FlatBufferTypeRef.addByteLength(builder, byteLength);
|
|
518
|
+
if (requiredAlignment > 0)
|
|
519
|
+
FlatBufferTypeRef.addRequiredAlignment(builder, requiredAlignment);
|
|
520
|
+
return FlatBufferTypeRef.endFlatBufferTypeRef(builder);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function typeRefToObject(typeRef) {
|
|
524
|
+
if (!typeRef) {
|
|
525
|
+
return null;
|
|
526
|
+
}
|
|
527
|
+
const schemaHash = typeRef.schemaHashArray?.() ?? null;
|
|
528
|
+
const fixedStringLength = typeRef.FIXED_STRING_LENGTH?.() ?? 0;
|
|
529
|
+
const byteLength = typeRef.BYTE_LENGTH?.() ?? 0;
|
|
530
|
+
const requiredAlignment = typeRef.REQUIRED_ALIGNMENT?.() ?? 0;
|
|
531
|
+
return {
|
|
532
|
+
schemaName: typeRef.SCHEMA_NAME?.() || undefined,
|
|
533
|
+
fileIdentifier: typeRef.FILE_IDENTIFIER?.() || undefined,
|
|
534
|
+
schemaVersion: typeRef.SCHEMA_VERSION?.() || undefined,
|
|
535
|
+
rootTypeName: typeRef.ROOT_TYPE?.() || undefined,
|
|
536
|
+
...(schemaHash && schemaHash.length > 0 ? { schemaHash } : {}),
|
|
537
|
+
...(typeRef.ACCEPTS_ANY_FLATBUFFER?.()
|
|
538
|
+
? { acceptsAnyFlatbuffer: true }
|
|
539
|
+
: {}),
|
|
540
|
+
wireFormat: payloadWireFormatName(typeRef.WIRE_FORMAT?.()),
|
|
541
|
+
...(fixedStringLength > 0 ? { fixedStringLength } : {}),
|
|
542
|
+
...(byteLength > 0 ? { byteLength } : {}),
|
|
543
|
+
...(requiredAlignment > 0 ? { requiredAlignment } : {}),
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function normalizeAllowedWireFormats(typeSet = {}) {
|
|
548
|
+
const values = [];
|
|
549
|
+
const allowedTypes = Array.isArray(typeSet.allowedTypes)
|
|
550
|
+
? typeSet.allowedTypes
|
|
551
|
+
: Array.isArray(typeSet.ALLOWED_TYPES)
|
|
552
|
+
? typeSet.ALLOWED_TYPES
|
|
553
|
+
: [];
|
|
554
|
+
for (const allowedType of allowedTypes) {
|
|
555
|
+
values.push(resolvePayloadWireFormat(allowedType?.wireFormat));
|
|
556
|
+
}
|
|
557
|
+
const unique = [];
|
|
558
|
+
const seen = new Set();
|
|
559
|
+
for (const value of values.length > 0 ? values : [payloadWireFormat.FLATBUFFER]) {
|
|
560
|
+
if (seen.has(value)) {
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
seen.add(value);
|
|
564
|
+
unique.push(value);
|
|
565
|
+
}
|
|
566
|
+
return unique;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function addAcceptedTypeSet(builder, typeSet = {}) {
|
|
570
|
+
const setId = normalizeOptionalString(
|
|
571
|
+
pick(typeSet, "setId", "set_id", "SET_ID"),
|
|
572
|
+
);
|
|
573
|
+
if (!setId) {
|
|
574
|
+
return 0;
|
|
575
|
+
}
|
|
576
|
+
const allowedTypes = Array.isArray(typeSet.allowedTypes)
|
|
577
|
+
? typeSet.allowedTypes
|
|
578
|
+
: Array.isArray(typeSet.ALLOWED_TYPES)
|
|
579
|
+
? typeSet.ALLOWED_TYPES
|
|
580
|
+
: [];
|
|
581
|
+
const allowedTypeOffsets = allowedTypes.map((entry) =>
|
|
582
|
+
addFlatBufferTypeRef(builder, entry),
|
|
583
|
+
);
|
|
584
|
+
const allowedTypesOffset = PLGAcceptedTypeSet.createAllowedTypesVector(
|
|
585
|
+
builder,
|
|
586
|
+
allowedTypeOffsets,
|
|
587
|
+
);
|
|
588
|
+
const allowedWireFormatsOffset =
|
|
589
|
+
PLGAcceptedTypeSet.createAllowedWireFormatsVector(
|
|
590
|
+
builder,
|
|
591
|
+
normalizeAllowedWireFormats(typeSet),
|
|
592
|
+
);
|
|
593
|
+
const description = normalizeOptionalString(
|
|
594
|
+
pick(typeSet, "description", "DESCRIPTION"),
|
|
595
|
+
);
|
|
596
|
+
const setIdOffset = builder.createString(setId);
|
|
597
|
+
const descriptionOffset = description ? builder.createString(description) : 0;
|
|
598
|
+
PLGAcceptedTypeSet.startPLGAcceptedTypeSet(builder);
|
|
599
|
+
PLGAcceptedTypeSet.addSetId(builder, setIdOffset);
|
|
600
|
+
if (allowedTypesOffset)
|
|
601
|
+
PLGAcceptedTypeSet.addAllowedTypes(builder, allowedTypesOffset);
|
|
602
|
+
if (allowedWireFormatsOffset)
|
|
603
|
+
PLGAcceptedTypeSet.addAllowedWireFormats(builder, allowedWireFormatsOffset);
|
|
604
|
+
if (descriptionOffset)
|
|
605
|
+
PLGAcceptedTypeSet.addDescription(builder, descriptionOffset);
|
|
606
|
+
return PLGAcceptedTypeSet.endPLGAcceptedTypeSet(builder);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function acceptedTypeSetToObject(typeSet) {
|
|
610
|
+
const allowedTypes = [];
|
|
611
|
+
const allowedTypeCount = typeSet?.allowedTypesLength?.() ?? 0;
|
|
612
|
+
for (let index = 0; index < allowedTypeCount; index += 1) {
|
|
613
|
+
const value = typeRefToObject(typeSet.ALLOWED_TYPES(index));
|
|
614
|
+
if (value) {
|
|
615
|
+
allowedTypes.push(value);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return {
|
|
619
|
+
setId: typeSet.SET_ID(),
|
|
620
|
+
allowedTypes,
|
|
621
|
+
allowedWireFormats: Array.from(
|
|
622
|
+
typeSet.allowedWireFormatsArray?.() ?? [],
|
|
623
|
+
(value) => payloadWireFormatName(value),
|
|
624
|
+
),
|
|
625
|
+
description: typeSet.DESCRIPTION() || undefined,
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function addPortManifest(builder, port = {}) {
|
|
630
|
+
const portId = normalizeOptionalString(pick(port, "portId", "port_id", "PORT_ID"));
|
|
631
|
+
if (!portId) {
|
|
632
|
+
return 0;
|
|
633
|
+
}
|
|
634
|
+
const acceptedTypeSets = Array.isArray(port.acceptedTypeSets)
|
|
635
|
+
? port.acceptedTypeSets
|
|
636
|
+
: Array.isArray(port.ACCEPTED_TYPE_SETS)
|
|
637
|
+
? port.ACCEPTED_TYPE_SETS
|
|
638
|
+
: [];
|
|
639
|
+
const acceptedTypeSetOffsets = acceptedTypeSets
|
|
640
|
+
.map((entry) => addAcceptedTypeSet(builder, entry))
|
|
641
|
+
.filter(Boolean);
|
|
642
|
+
const acceptedTypeSetsOffset = PLGPortManifest.createAcceptedTypeSetsVector(
|
|
643
|
+
builder,
|
|
644
|
+
acceptedTypeSetOffsets,
|
|
645
|
+
);
|
|
646
|
+
const displayName = normalizeOptionalString(
|
|
647
|
+
pick(port, "displayName", "display_name", "DISPLAY_NAME"),
|
|
648
|
+
);
|
|
649
|
+
const description = normalizeOptionalString(pick(port, "description", "DESCRIPTION"));
|
|
650
|
+
const portIdOffset = builder.createString(portId);
|
|
651
|
+
const displayNameOffset = displayName ? builder.createString(displayName) : 0;
|
|
652
|
+
const descriptionOffset = description ? builder.createString(description) : 0;
|
|
653
|
+
PLGPortManifest.startPLGPortManifest(builder);
|
|
654
|
+
PLGPortManifest.addPortId(builder, portIdOffset);
|
|
655
|
+
if (displayNameOffset) PLGPortManifest.addDisplayName(builder, displayNameOffset);
|
|
656
|
+
if (acceptedTypeSetsOffset)
|
|
657
|
+
PLGPortManifest.addAcceptedTypeSets(builder, acceptedTypeSetsOffset);
|
|
658
|
+
PLGPortManifest.addMinStreams(
|
|
659
|
+
builder,
|
|
660
|
+
normalizeUnsignedInteger(pick(port, "minStreams", "min_streams", "MIN_STREAMS"), 1),
|
|
661
|
+
);
|
|
662
|
+
PLGPortManifest.addMaxStreams(
|
|
663
|
+
builder,
|
|
664
|
+
normalizeUnsignedInteger(pick(port, "maxStreams", "max_streams", "MAX_STREAMS"), 1),
|
|
665
|
+
);
|
|
666
|
+
PLGPortManifest.addRequired(
|
|
667
|
+
builder,
|
|
668
|
+
pick(port, "required", "REQUIRED") !== false,
|
|
669
|
+
);
|
|
670
|
+
if (descriptionOffset) PLGPortManifest.addDescription(builder, descriptionOffset);
|
|
671
|
+
return PLGPortManifest.endPLGPortManifest(builder);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function portManifestToObject(port) {
|
|
675
|
+
const acceptedTypeSets = [];
|
|
676
|
+
const count = port?.acceptedTypeSetsLength?.() ?? 0;
|
|
677
|
+
for (let index = 0; index < count; index += 1) {
|
|
678
|
+
const typeSet = port.ACCEPTED_TYPE_SETS(index);
|
|
679
|
+
if (typeSet) {
|
|
680
|
+
acceptedTypeSets.push(acceptedTypeSetToObject(typeSet));
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return {
|
|
684
|
+
portId: port.PORT_ID(),
|
|
685
|
+
displayName: port.DISPLAY_NAME() || undefined,
|
|
686
|
+
acceptedTypeSets,
|
|
687
|
+
minStreams: port.MIN_STREAMS(),
|
|
688
|
+
maxStreams: port.MAX_STREAMS(),
|
|
689
|
+
required: port.REQUIRED(),
|
|
690
|
+
description: port.DESCRIPTION() || undefined,
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function addMethodManifest(builder, method = {}) {
|
|
695
|
+
const methodId = normalizeOptionalString(
|
|
696
|
+
pick(method, "methodId", "method_id", "METHOD_ID", "name"),
|
|
697
|
+
);
|
|
698
|
+
if (!methodId) {
|
|
699
|
+
return 0;
|
|
700
|
+
}
|
|
701
|
+
const inputPorts = Array.isArray(method.inputPorts)
|
|
702
|
+
? method.inputPorts
|
|
703
|
+
: Array.isArray(method.INPUT_PORTS)
|
|
704
|
+
? method.INPUT_PORTS
|
|
705
|
+
: [];
|
|
706
|
+
const outputPorts = Array.isArray(method.outputPorts)
|
|
707
|
+
? method.outputPorts
|
|
708
|
+
: Array.isArray(method.OUTPUT_PORTS)
|
|
709
|
+
? method.OUTPUT_PORTS
|
|
710
|
+
: [];
|
|
711
|
+
const inputPortOffsets = inputPorts
|
|
712
|
+
.map((port) => addPortManifest(builder, port))
|
|
713
|
+
.filter(Boolean);
|
|
714
|
+
const outputPortOffsets = outputPorts
|
|
715
|
+
.map((port) => addPortManifest(builder, port))
|
|
716
|
+
.filter(Boolean);
|
|
717
|
+
const inputPortsOffset = PLGMethodManifest.createInputPortsVector(
|
|
718
|
+
builder,
|
|
719
|
+
inputPortOffsets,
|
|
720
|
+
);
|
|
721
|
+
const outputPortsOffset = PLGMethodManifest.createOutputPortsVector(
|
|
722
|
+
builder,
|
|
723
|
+
outputPortOffsets,
|
|
724
|
+
);
|
|
725
|
+
const displayName = normalizeOptionalString(
|
|
726
|
+
pick(method, "displayName", "display_name", "DISPLAY_NAME"),
|
|
727
|
+
);
|
|
728
|
+
const description = normalizeOptionalString(
|
|
729
|
+
pick(method, "description", "DESCRIPTION"),
|
|
730
|
+
);
|
|
731
|
+
const methodIdOffset = builder.createString(methodId);
|
|
732
|
+
const displayNameOffset = displayName ? builder.createString(displayName) : 0;
|
|
733
|
+
const descriptionOffset = description ? builder.createString(description) : 0;
|
|
734
|
+
PLGMethodManifest.startPLGMethodManifest(builder);
|
|
735
|
+
PLGMethodManifest.addMethodId(builder, methodIdOffset);
|
|
736
|
+
if (displayNameOffset)
|
|
737
|
+
PLGMethodManifest.addDisplayName(builder, displayNameOffset);
|
|
738
|
+
if (inputPortsOffset) PLGMethodManifest.addInputPorts(builder, inputPortsOffset);
|
|
739
|
+
if (outputPortsOffset)
|
|
740
|
+
PLGMethodManifest.addOutputPorts(builder, outputPortsOffset);
|
|
741
|
+
PLGMethodManifest.addMaxBatch(
|
|
742
|
+
builder,
|
|
743
|
+
normalizeUnsignedInteger(pick(method, "maxBatch", "max_batch", "MAX_BATCH"), 1),
|
|
744
|
+
);
|
|
745
|
+
PLGMethodManifest.addDrainPolicy(
|
|
746
|
+
builder,
|
|
747
|
+
resolveDrainPolicy(pick(method, "drainPolicy", "drain_policy", "DRAIN_POLICY")),
|
|
748
|
+
);
|
|
749
|
+
if (descriptionOffset) PLGMethodManifest.addDescription(builder, descriptionOffset);
|
|
750
|
+
return PLGMethodManifest.endPLGMethodManifest(builder);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function methodManifestToObject(method) {
|
|
754
|
+
const inputPorts = [];
|
|
755
|
+
const outputPorts = [];
|
|
756
|
+
for (let index = 0; index < (method?.inputPortsLength?.() ?? 0); index += 1) {
|
|
757
|
+
const port = method.INPUT_PORTS(index);
|
|
758
|
+
if (port) inputPorts.push(portManifestToObject(port));
|
|
759
|
+
}
|
|
760
|
+
for (let index = 0; index < (method?.outputPortsLength?.() ?? 0); index += 1) {
|
|
761
|
+
const port = method.OUTPUT_PORTS(index);
|
|
762
|
+
if (port) outputPorts.push(portManifestToObject(port));
|
|
763
|
+
}
|
|
764
|
+
return {
|
|
765
|
+
methodId: method.METHOD_ID(),
|
|
766
|
+
displayName: method.DISPLAY_NAME() || undefined,
|
|
767
|
+
inputPorts,
|
|
768
|
+
outputPorts,
|
|
769
|
+
maxBatch: method.MAX_BATCH(),
|
|
770
|
+
drainPolicy: drainPolicyName(method.DRAIN_POLICY()),
|
|
771
|
+
description: method.DESCRIPTION() || undefined,
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
function addHostCapability(builder, capability = {}) {
|
|
776
|
+
const source =
|
|
777
|
+
typeof capability === "string" ? { capability } : capability ?? {};
|
|
778
|
+
const scope = normalizeOptionalString(pick(source, "scope", "SCOPE"));
|
|
779
|
+
const description = normalizeOptionalString(
|
|
780
|
+
pick(source, "description", "DESCRIPTION"),
|
|
781
|
+
);
|
|
782
|
+
const scopeOffset = scope ? builder.createString(scope) : 0;
|
|
783
|
+
const descriptionOffset = description ? builder.createString(description) : 0;
|
|
784
|
+
PLGHostCapability.startPLGHostCapability(builder);
|
|
785
|
+
PLGHostCapability.addCapability(
|
|
786
|
+
builder,
|
|
787
|
+
resolveHostCapability(pick(source, "capability", "CAPABILITY", "name")),
|
|
788
|
+
);
|
|
789
|
+
if (scopeOffset) PLGHostCapability.addScope(builder, scopeOffset);
|
|
790
|
+
PLGHostCapability.addRequired(
|
|
791
|
+
builder,
|
|
792
|
+
pick(source, "required", "REQUIRED") !== false,
|
|
793
|
+
);
|
|
794
|
+
if (descriptionOffset)
|
|
795
|
+
PLGHostCapability.addDescription(builder, descriptionOffset);
|
|
796
|
+
return PLGHostCapability.endPLGHostCapability(builder);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
function hostCapabilityToObject(capability) {
|
|
800
|
+
return {
|
|
801
|
+
capability: hostCapabilityName(capability.CAPABILITY()),
|
|
802
|
+
scope: capability.SCOPE() || undefined,
|
|
803
|
+
required: capability.REQUIRED(),
|
|
804
|
+
description: capability.DESCRIPTION() || undefined,
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
function addTimerSpec(builder, timer = {}) {
|
|
809
|
+
const timerId = normalizeOptionalString(pick(timer, "timerId", "timer_id", "TIMER_ID"));
|
|
810
|
+
const methodId = normalizeOptionalString(pick(timer, "methodId", "method_id", "METHOD_ID"));
|
|
811
|
+
if (!timerId || !methodId) {
|
|
812
|
+
return 0;
|
|
813
|
+
}
|
|
814
|
+
const inputPortId = normalizeOptionalString(
|
|
815
|
+
pick(timer, "inputPortId", "input_port_id", "INPUT_PORT_ID"),
|
|
816
|
+
);
|
|
817
|
+
const description = normalizeOptionalString(pick(timer, "description", "DESCRIPTION"));
|
|
818
|
+
const timerIdOffset = builder.createString(timerId);
|
|
819
|
+
const methodIdOffset = builder.createString(methodId);
|
|
820
|
+
const inputPortIdOffset = inputPortId ? builder.createString(inputPortId) : 0;
|
|
821
|
+
const descriptionOffset = description ? builder.createString(description) : 0;
|
|
822
|
+
PLGTimerSpec.startPLGTimerSpec(builder);
|
|
823
|
+
PLGTimerSpec.addTimerId(builder, timerIdOffset);
|
|
824
|
+
PLGTimerSpec.addMethodId(builder, methodIdOffset);
|
|
825
|
+
if (inputPortIdOffset) PLGTimerSpec.addInputPortId(builder, inputPortIdOffset);
|
|
826
|
+
PLGTimerSpec.addDefaultIntervalMs(
|
|
827
|
+
builder,
|
|
828
|
+
toBigInt(pick(timer, "defaultIntervalMs", "default_interval_ms", "DEFAULT_INTERVAL_MS")),
|
|
829
|
+
);
|
|
830
|
+
if (descriptionOffset) PLGTimerSpec.addDescription(builder, descriptionOffset);
|
|
831
|
+
return PLGTimerSpec.endPLGTimerSpec(builder);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function timerSpecToObject(timer) {
|
|
835
|
+
return {
|
|
836
|
+
timerId: timer.TIMER_ID(),
|
|
837
|
+
methodId: timer.METHOD_ID(),
|
|
838
|
+
inputPortId: timer.INPUT_PORT_ID() || undefined,
|
|
839
|
+
defaultIntervalMs: timer.DEFAULT_INTERVAL_MS(),
|
|
840
|
+
description: timer.DESCRIPTION() || undefined,
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
function addProtocolSpec(builder, protocol = {}) {
|
|
845
|
+
const protocolId = normalizeOptionalString(
|
|
846
|
+
pick(protocol, "protocolId", "protocol_id", "PROTOCOL_ID"),
|
|
847
|
+
);
|
|
848
|
+
const methodId = normalizeOptionalString(
|
|
849
|
+
pick(protocol, "methodId", "method_id", "METHOD_ID"),
|
|
850
|
+
);
|
|
851
|
+
if (!protocolId || !methodId) {
|
|
852
|
+
return 0;
|
|
853
|
+
}
|
|
854
|
+
const stringFields = {
|
|
855
|
+
inputPortId: normalizeOptionalString(
|
|
856
|
+
pick(protocol, "inputPortId", "input_port_id", "INPUT_PORT_ID"),
|
|
857
|
+
),
|
|
858
|
+
outputPortId: normalizeOptionalString(
|
|
859
|
+
pick(protocol, "outputPortId", "output_port_id", "OUTPUT_PORT_ID"),
|
|
860
|
+
),
|
|
861
|
+
description: normalizeOptionalString(pick(protocol, "description", "DESCRIPTION")),
|
|
862
|
+
wireId: normalizeOptionalString(pick(protocol, "wireId", "wire_id", "WIRE_ID")),
|
|
863
|
+
transportKind: normalizeOptionalString(
|
|
864
|
+
pick(protocol, "transportKind", "transport_kind", "TRANSPORT_KIND"),
|
|
865
|
+
),
|
|
866
|
+
role: normalizeOptionalString(pick(protocol, "role", "ROLE")),
|
|
867
|
+
specUri: normalizeOptionalString(pick(protocol, "specUri", "spec_uri", "SPEC_URI")),
|
|
868
|
+
discoveryKey: normalizeOptionalString(
|
|
869
|
+
pick(protocol, "discoveryKey", "discovery_key", "DISCOVERY_KEY"),
|
|
870
|
+
),
|
|
871
|
+
};
|
|
872
|
+
const offsets = Object.fromEntries(
|
|
873
|
+
Object.entries(stringFields).map(([key, value]) => [
|
|
874
|
+
key,
|
|
875
|
+
value ? builder.createString(value) : 0,
|
|
876
|
+
]),
|
|
877
|
+
);
|
|
878
|
+
const protocolIdOffset = builder.createString(protocolId);
|
|
879
|
+
const methodIdOffset = builder.createString(methodId);
|
|
880
|
+
PLGProtocolSpec.startPLGProtocolSpec(builder);
|
|
881
|
+
PLGProtocolSpec.addProtocolId(builder, protocolIdOffset);
|
|
882
|
+
PLGProtocolSpec.addMethodId(builder, methodIdOffset);
|
|
883
|
+
if (offsets.inputPortId) PLGProtocolSpec.addInputPortId(builder, offsets.inputPortId);
|
|
884
|
+
if (offsets.outputPortId)
|
|
885
|
+
PLGProtocolSpec.addOutputPortId(builder, offsets.outputPortId);
|
|
886
|
+
if (offsets.description)
|
|
887
|
+
PLGProtocolSpec.addDescription(builder, offsets.description);
|
|
888
|
+
if (offsets.wireId) PLGProtocolSpec.addWireId(builder, offsets.wireId);
|
|
889
|
+
if (offsets.transportKind)
|
|
890
|
+
PLGProtocolSpec.addTransportKind(builder, offsets.transportKind);
|
|
891
|
+
if (offsets.role) PLGProtocolSpec.addRole(builder, offsets.role);
|
|
892
|
+
if (offsets.specUri) PLGProtocolSpec.addSpecUri(builder, offsets.specUri);
|
|
893
|
+
PLGProtocolSpec.addAutoInstall(
|
|
894
|
+
builder,
|
|
895
|
+
pick(protocol, "autoInstall", "auto_install", "AUTO_INSTALL") !== false,
|
|
896
|
+
);
|
|
897
|
+
PLGProtocolSpec.addAdvertise(
|
|
898
|
+
builder,
|
|
899
|
+
Boolean(pick(protocol, "advertise", "ADVERTISE") ?? false),
|
|
900
|
+
);
|
|
901
|
+
if (offsets.discoveryKey)
|
|
902
|
+
PLGProtocolSpec.addDiscoveryKey(builder, offsets.discoveryKey);
|
|
903
|
+
PLGProtocolSpec.addDefaultPort(
|
|
904
|
+
builder,
|
|
905
|
+
normalizeUnsignedInteger(pick(protocol, "defaultPort", "default_port", "DEFAULT_PORT")),
|
|
906
|
+
);
|
|
907
|
+
PLGProtocolSpec.addRequireSecureTransport(
|
|
908
|
+
builder,
|
|
909
|
+
Boolean(
|
|
910
|
+
pick(
|
|
911
|
+
protocol,
|
|
912
|
+
"requireSecureTransport",
|
|
913
|
+
"require_secure_transport",
|
|
914
|
+
"REQUIRE_SECURE_TRANSPORT",
|
|
915
|
+
) ?? false,
|
|
916
|
+
),
|
|
917
|
+
);
|
|
918
|
+
return PLGProtocolSpec.endPLGProtocolSpec(builder);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
function protocolSpecToObject(protocol) {
|
|
922
|
+
return {
|
|
923
|
+
protocolId: protocol.PROTOCOL_ID(),
|
|
924
|
+
methodId: protocol.METHOD_ID(),
|
|
925
|
+
inputPortId: protocol.INPUT_PORT_ID() || undefined,
|
|
926
|
+
outputPortId: protocol.OUTPUT_PORT_ID() || undefined,
|
|
927
|
+
description: protocol.DESCRIPTION() || undefined,
|
|
928
|
+
wireId: protocol.WIRE_ID() || undefined,
|
|
929
|
+
transportKind: protocol.TRANSPORT_KIND() || undefined,
|
|
930
|
+
role: protocol.ROLE() || undefined,
|
|
931
|
+
specUri: protocol.SPEC_URI() || undefined,
|
|
932
|
+
autoInstall: protocol.AUTO_INSTALL(),
|
|
933
|
+
advertise: protocol.ADVERTISE(),
|
|
934
|
+
discoveryKey: protocol.DISCOVERY_KEY() || undefined,
|
|
935
|
+
defaultPort: protocol.DEFAULT_PORT(),
|
|
936
|
+
requireSecureTransport: protocol.REQUIRE_SECURE_TRANSPORT(),
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
function addBuildArtifact(builder, artifact = {}) {
|
|
941
|
+
const artifactId = normalizeOptionalString(
|
|
942
|
+
pick(artifact, "artifactId", "artifact_id", "ARTIFACT_ID"),
|
|
943
|
+
);
|
|
944
|
+
const path = normalizeOptionalString(pick(artifact, "path", "PATH"));
|
|
945
|
+
if (!artifactId || !path) {
|
|
946
|
+
return 0;
|
|
947
|
+
}
|
|
948
|
+
const kind = normalizeOptionalString(pick(artifact, "kind", "KIND"));
|
|
949
|
+
const target = normalizeOptionalString(pick(artifact, "target", "TARGET"));
|
|
950
|
+
const entrySymbol = normalizeOptionalString(
|
|
951
|
+
pick(artifact, "entrySymbol", "entry_symbol", "ENTRY_SYMBOL"),
|
|
952
|
+
);
|
|
953
|
+
const artifactIdOffset = builder.createString(artifactId);
|
|
954
|
+
const kindOffset = kind ? builder.createString(kind) : 0;
|
|
955
|
+
const pathOffset = builder.createString(path);
|
|
956
|
+
const targetOffset = target ? builder.createString(target) : 0;
|
|
957
|
+
const entrySymbolOffset = entrySymbol ? builder.createString(entrySymbol) : 0;
|
|
958
|
+
PLGBuildArtifact.startPLGBuildArtifact(builder);
|
|
959
|
+
PLGBuildArtifact.addArtifactId(builder, artifactIdOffset);
|
|
960
|
+
if (kindOffset) PLGBuildArtifact.addKind(builder, kindOffset);
|
|
961
|
+
PLGBuildArtifact.addPath(builder, pathOffset);
|
|
962
|
+
if (targetOffset) PLGBuildArtifact.addTarget(builder, targetOffset);
|
|
963
|
+
if (entrySymbolOffset)
|
|
964
|
+
PLGBuildArtifact.addEntrySymbol(builder, entrySymbolOffset);
|
|
965
|
+
return PLGBuildArtifact.endPLGBuildArtifact(builder);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
function buildArtifactToObject(artifact) {
|
|
969
|
+
return {
|
|
970
|
+
artifactId: artifact.ARTIFACT_ID(),
|
|
971
|
+
kind: artifact.KIND() || undefined,
|
|
972
|
+
path: artifact.PATH(),
|
|
973
|
+
target: artifact.TARGET() || undefined,
|
|
974
|
+
entrySymbol: artifact.ENTRY_SYMBOL() || undefined,
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function addFlowNode(builder, node = {}) {
|
|
979
|
+
const nodeId = normalizeOptionalString(
|
|
980
|
+
pick(node, "nodeId", "node_id", "NODE_ID"),
|
|
981
|
+
);
|
|
982
|
+
const pluginId = normalizeOptionalString(
|
|
983
|
+
pick(node, "pluginId", "plugin_id", "PLUGIN_ID"),
|
|
984
|
+
);
|
|
985
|
+
if (!nodeId || !pluginId) {
|
|
986
|
+
throw new TypeError("PLG flow node requires nodeId and pluginId.");
|
|
987
|
+
}
|
|
988
|
+
const methodId = normalizeOptionalString(
|
|
989
|
+
pick(node, "methodId", "method_id", "METHOD_ID"),
|
|
990
|
+
);
|
|
991
|
+
const kind = normalizeOptionalString(pick(node, "kind", "KIND"));
|
|
992
|
+
const dispatchModel = normalizeOptionalString(
|
|
993
|
+
pick(node, "dispatchModel", "dispatch_model", "DISPATCH_MODEL"),
|
|
994
|
+
);
|
|
995
|
+
const config = normalizeByteVector(pick(node, "config", "CONFIG"));
|
|
996
|
+
const nodeIdOffset = builder.createString(nodeId);
|
|
997
|
+
const pluginIdOffset = builder.createString(pluginId);
|
|
998
|
+
const methodIdOffset = methodId ? builder.createString(methodId) : 0;
|
|
999
|
+
const kindOffset = kind ? builder.createString(kind) : 0;
|
|
1000
|
+
const dispatchModelOffset = dispatchModel
|
|
1001
|
+
? builder.createString(dispatchModel)
|
|
1002
|
+
: 0;
|
|
1003
|
+
const configOffset = addByteVector(
|
|
1004
|
+
builder,
|
|
1005
|
+
config,
|
|
1006
|
+
PLGFlowNode.startConfigVector,
|
|
1007
|
+
);
|
|
1008
|
+
PLGFlowNode.startPLGFlowNode(builder);
|
|
1009
|
+
PLGFlowNode.addNodeId(builder, nodeIdOffset);
|
|
1010
|
+
PLGFlowNode.addPluginId(builder, pluginIdOffset);
|
|
1011
|
+
if (methodIdOffset) PLGFlowNode.addMethodId(builder, methodIdOffset);
|
|
1012
|
+
if (kindOffset) PLGFlowNode.addKind(builder, kindOffset);
|
|
1013
|
+
if (dispatchModelOffset)
|
|
1014
|
+
PLGFlowNode.addDispatchModel(builder, dispatchModelOffset);
|
|
1015
|
+
if (configOffset) PLGFlowNode.addConfig(builder, configOffset);
|
|
1016
|
+
const uiX = Number(pick(node, "uiX", "ui_x", "UI_X") ?? 0);
|
|
1017
|
+
const uiY = Number(pick(node, "uiY", "ui_y", "UI_Y") ?? 0);
|
|
1018
|
+
if (Number.isFinite(uiX) && uiX !== 0) PLGFlowNode.addUiX(builder, uiX);
|
|
1019
|
+
if (Number.isFinite(uiY) && uiY !== 0) PLGFlowNode.addUiY(builder, uiY);
|
|
1020
|
+
return PLGFlowNode.endPLGFlowNode(builder);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
function flowNodeToObject(node) {
|
|
1024
|
+
const config = node.configArray?.() ?? null;
|
|
1025
|
+
return {
|
|
1026
|
+
nodeId: node.NODE_ID(),
|
|
1027
|
+
pluginId: node.PLUGIN_ID(),
|
|
1028
|
+
methodId: node.METHOD_ID() || undefined,
|
|
1029
|
+
kind: node.KIND() || undefined,
|
|
1030
|
+
dispatchModel: node.DISPATCH_MODEL() || undefined,
|
|
1031
|
+
...(config && config.length > 0
|
|
1032
|
+
? { config: new Uint8Array(config) }
|
|
1033
|
+
: {}),
|
|
1034
|
+
uiX: node.UI_X(),
|
|
1035
|
+
uiY: node.UI_Y(),
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
function addFlowEdge(builder, edge = {}) {
|
|
1040
|
+
const fromNodeId = normalizeOptionalString(
|
|
1041
|
+
pick(edge, "fromNodeId", "from_node_id", "FROM_NODE_ID"),
|
|
1042
|
+
);
|
|
1043
|
+
const fromPortId = normalizeOptionalString(
|
|
1044
|
+
pick(edge, "fromPortId", "from_port_id", "FROM_PORT_ID"),
|
|
1045
|
+
);
|
|
1046
|
+
const toNodeId = normalizeOptionalString(
|
|
1047
|
+
pick(edge, "toNodeId", "to_node_id", "TO_NODE_ID"),
|
|
1048
|
+
);
|
|
1049
|
+
const toPortId = normalizeOptionalString(
|
|
1050
|
+
pick(edge, "toPortId", "to_port_id", "TO_PORT_ID"),
|
|
1051
|
+
);
|
|
1052
|
+
if (!fromNodeId || !fromPortId || !toNodeId || !toPortId) {
|
|
1053
|
+
const missing = [
|
|
1054
|
+
["fromNodeId", fromNodeId],
|
|
1055
|
+
["fromPortId", fromPortId],
|
|
1056
|
+
["toNodeId", toNodeId],
|
|
1057
|
+
["toPortId", toPortId],
|
|
1058
|
+
]
|
|
1059
|
+
.filter(([, value]) => !value)
|
|
1060
|
+
.map(([field]) => field)
|
|
1061
|
+
.join(", ");
|
|
1062
|
+
throw new TypeError(`PLG flow edge requires ${missing}.`);
|
|
1063
|
+
}
|
|
1064
|
+
const edgeId = normalizeOptionalString(
|
|
1065
|
+
pick(edge, "edgeId", "edge_id", "EDGE_ID"),
|
|
1066
|
+
);
|
|
1067
|
+
const edgeIdOffset = edgeId ? builder.createString(edgeId) : 0;
|
|
1068
|
+
const fromNodeIdOffset = builder.createString(fromNodeId);
|
|
1069
|
+
const fromPortIdOffset = builder.createString(fromPortId);
|
|
1070
|
+
const toNodeIdOffset = builder.createString(toNodeId);
|
|
1071
|
+
const toPortIdOffset = builder.createString(toPortId);
|
|
1072
|
+
const contract = pick(edge, "contract", "CONTRACT");
|
|
1073
|
+
if (!contract) {
|
|
1074
|
+
throw new TypeError("PLG flow edge requires an exact contract.");
|
|
1075
|
+
}
|
|
1076
|
+
const canonicalType = pick(
|
|
1077
|
+
contract,
|
|
1078
|
+
"canonicalType",
|
|
1079
|
+
"canonical_type",
|
|
1080
|
+
"CANONICAL_TYPE",
|
|
1081
|
+
);
|
|
1082
|
+
const opaque =
|
|
1083
|
+
pick(contract, "opaque", "OPAQUE") === true;
|
|
1084
|
+
// $PLG 1.0.13: exactly one of CANONICAL_TYPE or OPAQUE = true. Neither is a
|
|
1085
|
+
// forgotten type; both is a contradiction.
|
|
1086
|
+
if (!canonicalType && !opaque) {
|
|
1087
|
+
throw new TypeError(
|
|
1088
|
+
"PLG flow edge contract requires canonicalType, or OPAQUE = true when the edge carries bytes with no SDS identity by design.",
|
|
1089
|
+
);
|
|
1090
|
+
}
|
|
1091
|
+
if (canonicalType && opaque) {
|
|
1092
|
+
throw new TypeError(
|
|
1093
|
+
"PLG flow edge contract declares both canonicalType and OPAQUE = true; exactly one is permitted.",
|
|
1094
|
+
);
|
|
1095
|
+
}
|
|
1096
|
+
const alignedType = pick(
|
|
1097
|
+
contract,
|
|
1098
|
+
"alignedType",
|
|
1099
|
+
"aligned_type",
|
|
1100
|
+
"ALIGNED_TYPE",
|
|
1101
|
+
);
|
|
1102
|
+
const alignedEligible =
|
|
1103
|
+
pick(contract, "alignedEligible", "aligned_eligible", "ALIGNED_ELIGIBLE") === true;
|
|
1104
|
+
if (opaque && (alignedEligible || alignedType)) {
|
|
1105
|
+
throw new TypeError(
|
|
1106
|
+
"PLG flow edge contract marked OPAQUE cannot be aligned-eligible or carry an alignedType: an opaque edge has no layout to prove.",
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
const canonicalTypeOffset = canonicalType
|
|
1110
|
+
? addFlatBufferTypeRef(builder, canonicalType)
|
|
1111
|
+
: 0;
|
|
1112
|
+
const alignedTypeOffset = alignedType
|
|
1113
|
+
? addFlatBufferTypeRef(builder, alignedType)
|
|
1114
|
+
: 0;
|
|
1115
|
+
PLGFlowEdgeContract.startPLGFlowEdgeContract(builder);
|
|
1116
|
+
if (canonicalTypeOffset) {
|
|
1117
|
+
PLGFlowEdgeContract.addCanonicalType(builder, canonicalTypeOffset);
|
|
1118
|
+
}
|
|
1119
|
+
if (alignedTypeOffset) {
|
|
1120
|
+
PLGFlowEdgeContract.addAlignedType(builder, alignedTypeOffset);
|
|
1121
|
+
}
|
|
1122
|
+
if (opaque) {
|
|
1123
|
+
PLGFlowEdgeContract.addOpaque(builder, true);
|
|
1124
|
+
}
|
|
1125
|
+
PLGFlowEdgeContract.addCanonicalFallbackAvailable(
|
|
1126
|
+
builder,
|
|
1127
|
+
pick(
|
|
1128
|
+
contract,
|
|
1129
|
+
"canonicalFallbackAvailable",
|
|
1130
|
+
"canonical_fallback_available",
|
|
1131
|
+
"CANONICAL_FALLBACK_AVAILABLE",
|
|
1132
|
+
) !== false,
|
|
1133
|
+
);
|
|
1134
|
+
PLGFlowEdgeContract.addAlignedEligible(
|
|
1135
|
+
builder,
|
|
1136
|
+
pick(contract, "alignedEligible", "aligned_eligible", "ALIGNED_ELIGIBLE") === true,
|
|
1137
|
+
);
|
|
1138
|
+
PLGFlowEdgeContract.addRoutePolicy(
|
|
1139
|
+
builder,
|
|
1140
|
+
resolveFlowEdgeRoutePolicy(
|
|
1141
|
+
pick(contract, "routePolicy", "route_policy", "ROUTE_POLICY"),
|
|
1142
|
+
),
|
|
1143
|
+
);
|
|
1144
|
+
const contractOffset = PLGFlowEdgeContract.endPLGFlowEdgeContract(builder);
|
|
1145
|
+
|
|
1146
|
+
PLGFlowEdge.startPLGFlowEdge(builder);
|
|
1147
|
+
if (edgeIdOffset) PLGFlowEdge.addEdgeId(builder, edgeIdOffset);
|
|
1148
|
+
PLGFlowEdge.addFromNodeId(builder, fromNodeIdOffset);
|
|
1149
|
+
PLGFlowEdge.addFromPortId(builder, fromPortIdOffset);
|
|
1150
|
+
PLGFlowEdge.addToNodeId(builder, toNodeIdOffset);
|
|
1151
|
+
PLGFlowEdge.addToPortId(builder, toPortIdOffset);
|
|
1152
|
+
PLGFlowEdge.addContract(builder, contractOffset);
|
|
1153
|
+
return PLGFlowEdge.endPLGFlowEdge(builder);
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
function flowEdgeToObject(edge) {
|
|
1157
|
+
// The VERIFIER half of the $PLG 1.0.13 bargain: the schema left CONTRACT and
|
|
1158
|
+
// CANONICAL_TYPE optional so pre-1.0.13 buffers stay readable, so a SIGNED
|
|
1159
|
+
// edge without a coherent contract is rejected here rather than by flatc.
|
|
1160
|
+
const contract = edge.CONTRACT?.();
|
|
1161
|
+
if (!contract) {
|
|
1162
|
+
throw new TypeError("Decoded PLG flow edge is missing its exact contract.");
|
|
1163
|
+
}
|
|
1164
|
+
const canonicalType = contract.CANONICAL_TYPE?.() ?? null;
|
|
1165
|
+
const opaque = contract.OPAQUE?.() === true;
|
|
1166
|
+
if (!canonicalType && !opaque) {
|
|
1167
|
+
throw new TypeError(
|
|
1168
|
+
"Decoded PLG flow edge contract carries neither CANONICAL_TYPE nor OPAQUE = true.",
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
if (canonicalType && opaque) {
|
|
1172
|
+
throw new TypeError(
|
|
1173
|
+
"Decoded PLG flow edge contract carries both CANONICAL_TYPE and OPAQUE = true; exactly one is permitted.",
|
|
1174
|
+
);
|
|
1175
|
+
}
|
|
1176
|
+
const alignedEligible = contract.ALIGNED_ELIGIBLE();
|
|
1177
|
+
if (opaque && alignedEligible) {
|
|
1178
|
+
throw new TypeError(
|
|
1179
|
+
"Decoded PLG flow edge contract is OPAQUE and ALIGNED_ELIGIBLE; an opaque edge has no layout to prove.",
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
const alignedType = contract.ALIGNED_TYPE?.();
|
|
1183
|
+
return {
|
|
1184
|
+
edgeId: edge.EDGE_ID() || undefined,
|
|
1185
|
+
fromNodeId: edge.FROM_NODE_ID(),
|
|
1186
|
+
fromPortId: edge.FROM_PORT_ID(),
|
|
1187
|
+
toNodeId: edge.TO_NODE_ID(),
|
|
1188
|
+
toPortId: edge.TO_PORT_ID(),
|
|
1189
|
+
contract: {
|
|
1190
|
+
canonicalType: canonicalType ? typeRefToObject(canonicalType) : null,
|
|
1191
|
+
alignedType: alignedType ? typeRefToObject(alignedType) : null,
|
|
1192
|
+
canonicalFallbackAvailable: contract.CANONICAL_FALLBACK_AVAILABLE(),
|
|
1193
|
+
alignedEligible,
|
|
1194
|
+
opaque,
|
|
1195
|
+
routePolicy: flowEdgeRoutePolicyName(contract.ROUTE_POLICY()),
|
|
1196
|
+
},
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
function addFlowTrigger(builder, trigger = {}) {
|
|
1201
|
+
const triggerId = normalizeOptionalString(
|
|
1202
|
+
pick(trigger, "triggerId", "trigger_id", "TRIGGER_ID"),
|
|
1203
|
+
);
|
|
1204
|
+
if (!triggerId) {
|
|
1205
|
+
throw new TypeError("PLG flow trigger requires triggerId.");
|
|
1206
|
+
}
|
|
1207
|
+
const kind = normalizeOptionalString(pick(trigger, "kind", "KIND"));
|
|
1208
|
+
const source = normalizeOptionalString(pick(trigger, "source", "SOURCE"));
|
|
1209
|
+
const httpPath = normalizeOptionalString(
|
|
1210
|
+
pick(trigger, "httpPath", "http_path", "HTTP_PATH"),
|
|
1211
|
+
);
|
|
1212
|
+
const triggerIdOffset = builder.createString(triggerId);
|
|
1213
|
+
const kindOffset = kind ? builder.createString(kind) : 0;
|
|
1214
|
+
const sourceOffset = source ? builder.createString(source) : 0;
|
|
1215
|
+
const httpPathOffset = httpPath ? builder.createString(httpPath) : 0;
|
|
1216
|
+
return PLGFlowTrigger.createPLGFlowTrigger(
|
|
1217
|
+
builder,
|
|
1218
|
+
triggerIdOffset,
|
|
1219
|
+
kindOffset,
|
|
1220
|
+
sourceOffset,
|
|
1221
|
+
toBigInt(
|
|
1222
|
+
pick(
|
|
1223
|
+
trigger,
|
|
1224
|
+
"defaultIntervalMs",
|
|
1225
|
+
"default_interval_ms",
|
|
1226
|
+
"DEFAULT_INTERVAL_MS",
|
|
1227
|
+
),
|
|
1228
|
+
),
|
|
1229
|
+
httpPathOffset,
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
function flowTriggerToObject(trigger) {
|
|
1234
|
+
return {
|
|
1235
|
+
triggerId: trigger.TRIGGER_ID(),
|
|
1236
|
+
kind: trigger.KIND() || undefined,
|
|
1237
|
+
source: trigger.SOURCE() || undefined,
|
|
1238
|
+
defaultIntervalMs: trigger.DEFAULT_INTERVAL_MS(),
|
|
1239
|
+
httpPath: trigger.HTTP_PATH() || undefined,
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
function addFlowTriggerBinding(builder, binding = {}) {
|
|
1244
|
+
const triggerId = normalizeOptionalString(
|
|
1245
|
+
pick(binding, "triggerId", "trigger_id", "TRIGGER_ID"),
|
|
1246
|
+
);
|
|
1247
|
+
const targetNodeId = normalizeOptionalString(
|
|
1248
|
+
pick(binding, "targetNodeId", "target_node_id", "TARGET_NODE_ID"),
|
|
1249
|
+
);
|
|
1250
|
+
const targetPortId = normalizeOptionalString(
|
|
1251
|
+
pick(binding, "targetPortId", "target_port_id", "TARGET_PORT_ID"),
|
|
1252
|
+
);
|
|
1253
|
+
if (!triggerId || !targetNodeId || !targetPortId) {
|
|
1254
|
+
throw new TypeError(
|
|
1255
|
+
"PLG flow trigger binding requires triggerId, targetNodeId, and targetPortId.",
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
return PLGFlowTriggerBinding.createPLGFlowTriggerBinding(
|
|
1259
|
+
builder,
|
|
1260
|
+
builder.createString(triggerId),
|
|
1261
|
+
builder.createString(targetNodeId),
|
|
1262
|
+
builder.createString(targetPortId),
|
|
1263
|
+
);
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
function flowTriggerBindingToObject(binding) {
|
|
1267
|
+
return {
|
|
1268
|
+
triggerId: binding.TRIGGER_ID(),
|
|
1269
|
+
targetNodeId: binding.TARGET_NODE_ID(),
|
|
1270
|
+
targetPortId: binding.TARGET_PORT_ID(),
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
|
|
271
1274
|
/**
|
|
272
1275
|
* Encode a PLG manifest object to a canonical `$PLG`-identified FlatBuffer.
|
|
273
1276
|
* Returns a Uint8Array over a fresh buffer.
|
|
@@ -488,9 +1491,9 @@ export function encodePlgManifest(manifest = {}) {
|
|
|
488
1491
|
? builder.createString(keyId)
|
|
489
1492
|
: 0;
|
|
490
1493
|
|
|
491
|
-
const
|
|
1494
|
+
const allowedXpubsOffset = addStringVector(
|
|
492
1495
|
builder,
|
|
493
|
-
pick(manifest, "
|
|
1496
|
+
pick(manifest, "allowedXpubs", "allowed_xpubs", "ALLOWED_XPUBS"),
|
|
494
1497
|
);
|
|
495
1498
|
|
|
496
1499
|
const maxGrantTimeoutMs = toBigInt(
|
|
@@ -599,6 +1602,145 @@ export function encodePlgManifest(manifest = {}) {
|
|
|
599
1602
|
PLG.startSignatureVector,
|
|
600
1603
|
);
|
|
601
1604
|
|
|
1605
|
+
const invokeSurfaces = pick(
|
|
1606
|
+
manifest,
|
|
1607
|
+
"invokeSurfaces",
|
|
1608
|
+
"invoke_surfaces",
|
|
1609
|
+
"INVOKE_SURFACES",
|
|
1610
|
+
);
|
|
1611
|
+
const invokeSurfaceValues = Array.isArray(invokeSurfaces)
|
|
1612
|
+
? invokeSurfaces.map((entry) => resolveInvokeSurface(entry)).filter((entry) => entry !== null)
|
|
1613
|
+
: [];
|
|
1614
|
+
const invokeSurfacesOffset =
|
|
1615
|
+
invokeSurfaceValues.length > 0
|
|
1616
|
+
? PLG.createInvokeSurfacesVector(builder, invokeSurfaceValues)
|
|
1617
|
+
: 0;
|
|
1618
|
+
|
|
1619
|
+
const methods = pick(manifest, "methods", "METHODS");
|
|
1620
|
+
const methodOffsets = Array.isArray(methods)
|
|
1621
|
+
? methods.map((method) => addMethodManifest(builder, method)).filter(Boolean)
|
|
1622
|
+
: [];
|
|
1623
|
+
const methodsOffset =
|
|
1624
|
+
methodOffsets.length > 0 ? PLG.createMethodsVector(builder, methodOffsets) : 0;
|
|
1625
|
+
|
|
1626
|
+
const hostCapabilities = pick(
|
|
1627
|
+
manifest,
|
|
1628
|
+
"hostCapabilities",
|
|
1629
|
+
"host_capabilities",
|
|
1630
|
+
"HOST_CAPABILITIES",
|
|
1631
|
+
"capabilities",
|
|
1632
|
+
"CAPABILITIES",
|
|
1633
|
+
);
|
|
1634
|
+
const hostCapabilityOffsets = Array.isArray(hostCapabilities)
|
|
1635
|
+
? hostCapabilities.map((capability) => addHostCapability(builder, capability))
|
|
1636
|
+
: [];
|
|
1637
|
+
const hostCapabilitiesOffset =
|
|
1638
|
+
hostCapabilityOffsets.length > 0
|
|
1639
|
+
? PLG.createHostCapabilitiesVector(builder, hostCapabilityOffsets)
|
|
1640
|
+
: 0;
|
|
1641
|
+
|
|
1642
|
+
const timers = pick(manifest, "timers", "TIMERS");
|
|
1643
|
+
const timerOffsets = Array.isArray(timers)
|
|
1644
|
+
? timers.map((timer) => addTimerSpec(builder, timer)).filter(Boolean)
|
|
1645
|
+
: [];
|
|
1646
|
+
const timersOffset =
|
|
1647
|
+
timerOffsets.length > 0 ? PLG.createTimersVector(builder, timerOffsets) : 0;
|
|
1648
|
+
|
|
1649
|
+
const protocols = pick(manifest, "protocols", "PROTOCOLS");
|
|
1650
|
+
const protocolOffsets = Array.isArray(protocols)
|
|
1651
|
+
? protocols.map((protocol) => addProtocolSpec(builder, protocol)).filter(Boolean)
|
|
1652
|
+
: [];
|
|
1653
|
+
const protocolsOffset =
|
|
1654
|
+
protocolOffsets.length > 0
|
|
1655
|
+
? PLG.createProtocolsVector(builder, protocolOffsets)
|
|
1656
|
+
: 0;
|
|
1657
|
+
|
|
1658
|
+
const schemasUsed = pick(
|
|
1659
|
+
manifest,
|
|
1660
|
+
"schemasUsed",
|
|
1661
|
+
"schemas_used",
|
|
1662
|
+
"SCHEMAS_USED",
|
|
1663
|
+
);
|
|
1664
|
+
const schemaUsedOffsets = Array.isArray(schemasUsed)
|
|
1665
|
+
? schemasUsed.map((schema) => addFlatBufferTypeRef(builder, schema))
|
|
1666
|
+
: [];
|
|
1667
|
+
const schemasUsedOffset =
|
|
1668
|
+
schemaUsedOffsets.length > 0
|
|
1669
|
+
? PLG.createSchemasUsedVector(builder, schemaUsedOffsets)
|
|
1670
|
+
: 0;
|
|
1671
|
+
|
|
1672
|
+
const buildArtifacts = pick(
|
|
1673
|
+
manifest,
|
|
1674
|
+
"buildArtifacts",
|
|
1675
|
+
"build_artifacts",
|
|
1676
|
+
"BUILD_ARTIFACTS",
|
|
1677
|
+
);
|
|
1678
|
+
const buildArtifactOffsets = Array.isArray(buildArtifacts)
|
|
1679
|
+
? buildArtifacts.map((artifact) => addBuildArtifact(builder, artifact)).filter(Boolean)
|
|
1680
|
+
: [];
|
|
1681
|
+
const buildArtifactsOffset =
|
|
1682
|
+
buildArtifactOffsets.length > 0
|
|
1683
|
+
? PLG.createBuildArtifactsVector(builder, buildArtifactOffsets)
|
|
1684
|
+
: 0;
|
|
1685
|
+
|
|
1686
|
+
const runtimeTargetsOffset = addStringVector(
|
|
1687
|
+
builder,
|
|
1688
|
+
pick(manifest, "runtimeTargets", "runtime_targets", "RUNTIME_TARGETS"),
|
|
1689
|
+
);
|
|
1690
|
+
|
|
1691
|
+
const flowNodes = pick(manifest, "flowNodes", "flow_nodes", "FLOW_NODES");
|
|
1692
|
+
const flowNodeOffsets = Array.isArray(flowNodes)
|
|
1693
|
+
? flowNodes.map((node) => addFlowNode(builder, node)).filter(Boolean)
|
|
1694
|
+
: [];
|
|
1695
|
+
const flowNodesOffset =
|
|
1696
|
+
flowNodeOffsets.length > 0
|
|
1697
|
+
? PLG.createFlowNodesVector(builder, flowNodeOffsets)
|
|
1698
|
+
: 0;
|
|
1699
|
+
|
|
1700
|
+
const flowEdges = pick(manifest, "flowEdges", "flow_edges", "FLOW_EDGES");
|
|
1701
|
+
const flowEdgeOffsets = Array.isArray(flowEdges)
|
|
1702
|
+
? flowEdges.map((edge) => addFlowEdge(builder, edge)).filter(Boolean)
|
|
1703
|
+
: [];
|
|
1704
|
+
const flowEdgesOffset =
|
|
1705
|
+
flowEdgeOffsets.length > 0
|
|
1706
|
+
? PLG.createFlowEdgesVector(builder, flowEdgeOffsets)
|
|
1707
|
+
: 0;
|
|
1708
|
+
|
|
1709
|
+
const flowTriggers = pick(
|
|
1710
|
+
manifest,
|
|
1711
|
+
"flowTriggers",
|
|
1712
|
+
"flow_triggers",
|
|
1713
|
+
"FLOW_TRIGGERS",
|
|
1714
|
+
);
|
|
1715
|
+
const flowTriggerOffsets = Array.isArray(flowTriggers)
|
|
1716
|
+
? flowTriggers
|
|
1717
|
+
.map((trigger) => addFlowTrigger(builder, trigger))
|
|
1718
|
+
.filter(Boolean)
|
|
1719
|
+
: [];
|
|
1720
|
+
const flowTriggersOffset =
|
|
1721
|
+
flowTriggerOffsets.length > 0
|
|
1722
|
+
? PLG.createFlowTriggersVector(builder, flowTriggerOffsets)
|
|
1723
|
+
: 0;
|
|
1724
|
+
|
|
1725
|
+
const flowTriggerBindings = pick(
|
|
1726
|
+
manifest,
|
|
1727
|
+
"flowTriggerBindings",
|
|
1728
|
+
"flow_trigger_bindings",
|
|
1729
|
+
"FLOW_TRIGGER_BINDINGS",
|
|
1730
|
+
);
|
|
1731
|
+
const flowTriggerBindingOffsets = Array.isArray(flowTriggerBindings)
|
|
1732
|
+
? flowTriggerBindings
|
|
1733
|
+
.map((binding) => addFlowTriggerBinding(builder, binding))
|
|
1734
|
+
.filter(Boolean)
|
|
1735
|
+
: [];
|
|
1736
|
+
const flowTriggerBindingsOffset =
|
|
1737
|
+
flowTriggerBindingOffsets.length > 0
|
|
1738
|
+
? PLG.createFlowTriggerBindingsVector(
|
|
1739
|
+
builder,
|
|
1740
|
+
flowTriggerBindingOffsets,
|
|
1741
|
+
)
|
|
1742
|
+
: 0;
|
|
1743
|
+
|
|
602
1744
|
PLG.startPLG(builder);
|
|
603
1745
|
PLG.addPluginId(builder, pluginIdOffset);
|
|
604
1746
|
PLG.addName(builder, nameOffset);
|
|
@@ -637,8 +1779,8 @@ export function encodePlgManifest(manifest = {}) {
|
|
|
637
1779
|
PLG.addEncrypted(builder, encrypted);
|
|
638
1780
|
if (requiredScopeOffset) PLG.addRequiredScope(builder, requiredScopeOffset);
|
|
639
1781
|
if (keyIdOffset) PLG.addKeyId(builder, keyIdOffset);
|
|
640
|
-
if (
|
|
641
|
-
PLG.
|
|
1782
|
+
if (allowedXpubsOffset)
|
|
1783
|
+
PLG.addAllowedXpubs(builder, allowedXpubsOffset);
|
|
642
1784
|
if (maxGrantTimeoutMs !== 0n)
|
|
643
1785
|
PLG.addMaxGrantTimeoutMs(builder, maxGrantTimeoutMs);
|
|
644
1786
|
if (minPermissionsOffset)
|
|
@@ -657,6 +1799,20 @@ export function encodePlgManifest(manifest = {}) {
|
|
|
657
1799
|
PLG.addAcceptedPaymentMethods(builder, acceptedPaymentMethodsOffset);
|
|
658
1800
|
PLG.addListingStatus(builder, listingStatusValue);
|
|
659
1801
|
if (signatureOffset) PLG.addSignature(builder, signatureOffset);
|
|
1802
|
+
if (invokeSurfacesOffset) PLG.addInvokeSurfaces(builder, invokeSurfacesOffset);
|
|
1803
|
+
if (methodsOffset) PLG.addMethods(builder, methodsOffset);
|
|
1804
|
+
if (hostCapabilitiesOffset)
|
|
1805
|
+
PLG.addHostCapabilities(builder, hostCapabilitiesOffset);
|
|
1806
|
+
if (timersOffset) PLG.addTimers(builder, timersOffset);
|
|
1807
|
+
if (protocolsOffset) PLG.addProtocols(builder, protocolsOffset);
|
|
1808
|
+
if (schemasUsedOffset) PLG.addSchemasUsed(builder, schemasUsedOffset);
|
|
1809
|
+
if (buildArtifactsOffset) PLG.addBuildArtifacts(builder, buildArtifactsOffset);
|
|
1810
|
+
if (runtimeTargetsOffset) PLG.addRuntimeTargets(builder, runtimeTargetsOffset);
|
|
1811
|
+
if (flowNodesOffset) PLG.addFlowNodes(builder, flowNodesOffset);
|
|
1812
|
+
if (flowEdgesOffset) PLG.addFlowEdges(builder, flowEdgesOffset);
|
|
1813
|
+
if (flowTriggersOffset) PLG.addFlowTriggers(builder, flowTriggersOffset);
|
|
1814
|
+
if (flowTriggerBindingsOffset)
|
|
1815
|
+
PLG.addFlowTriggerBindings(builder, flowTriggerBindingsOffset);
|
|
660
1816
|
const rootOffset = PLG.endPLG(builder);
|
|
661
1817
|
PLG.finishPLGBuffer(builder, rootOffset);
|
|
662
1818
|
return builder.asUint8Array();
|
|
@@ -699,17 +1855,17 @@ export function decodePlgManifest(data) {
|
|
|
699
1855
|
? root.entryFunctionsLength()
|
|
700
1856
|
: 0;
|
|
701
1857
|
for (let i = 0; i < entryLen; i++) {
|
|
702
|
-
const entry = root.
|
|
1858
|
+
const entry = root.ENTRY_FUNCTIONS(i);
|
|
703
1859
|
if (!entry) continue;
|
|
704
1860
|
entryFunctions.push({
|
|
705
|
-
name: entry.
|
|
706
|
-
description: entry.
|
|
1861
|
+
name: entry.NAME(),
|
|
1862
|
+
description: entry.DESCRIPTION() || undefined,
|
|
707
1863
|
inputSchemas: readStringVector(
|
|
708
1864
|
entry,
|
|
709
1865
|
"inputSchemasLength",
|
|
710
|
-
"
|
|
1866
|
+
"INPUT_SCHEMAS",
|
|
711
1867
|
),
|
|
712
|
-
outputSchema: entry.
|
|
1868
|
+
outputSchema: entry.OUTPUT_SCHEMA() || undefined,
|
|
713
1869
|
});
|
|
714
1870
|
}
|
|
715
1871
|
|
|
@@ -719,12 +1875,12 @@ export function decodePlgManifest(data) {
|
|
|
719
1875
|
? root.capabilitiesLength()
|
|
720
1876
|
: 0;
|
|
721
1877
|
for (let i = 0; i < capLen; i++) {
|
|
722
|
-
const cap = root.
|
|
1878
|
+
const cap = root.CAPABILITIES(i);
|
|
723
1879
|
if (!cap) continue;
|
|
724
1880
|
capabilities.push({
|
|
725
|
-
name: cap.
|
|
726
|
-
version: cap.
|
|
727
|
-
required: !!cap.
|
|
1881
|
+
name: cap.NAME() || undefined,
|
|
1882
|
+
version: cap.VERSION() || undefined,
|
|
1883
|
+
required: !!cap.REQUIRED(),
|
|
728
1884
|
});
|
|
729
1885
|
}
|
|
730
1886
|
|
|
@@ -734,80 +1890,165 @@ export function decodePlgManifest(data) {
|
|
|
734
1890
|
? root.dependenciesLength()
|
|
735
1891
|
: 0;
|
|
736
1892
|
for (let i = 0; i < depLen; i++) {
|
|
737
|
-
const dep = root.
|
|
1893
|
+
const dep = root.DEPENDENCIES(i);
|
|
738
1894
|
if (!dep) continue;
|
|
739
1895
|
dependencies.push({
|
|
740
|
-
pluginId: dep.
|
|
741
|
-
minVersion: dep.
|
|
742
|
-
maxVersion: dep.
|
|
1896
|
+
pluginId: dep.PLUGIN_ID() || undefined,
|
|
1897
|
+
minVersion: dep.MIN_VERSION() || undefined,
|
|
1898
|
+
maxVersion: dep.MAX_VERSION() || undefined,
|
|
743
1899
|
});
|
|
744
1900
|
}
|
|
745
1901
|
|
|
1902
|
+
const invokeSurfaces = Array.from(
|
|
1903
|
+
root.invokeSurfacesArray?.() ?? [],
|
|
1904
|
+
(value) => invokeSurfaceName(value),
|
|
1905
|
+
);
|
|
1906
|
+
const methods = [];
|
|
1907
|
+
for (let index = 0; index < (root.methodsLength?.() ?? 0); index += 1) {
|
|
1908
|
+
const method = root.METHODS(index);
|
|
1909
|
+
if (method) {
|
|
1910
|
+
methods.push(methodManifestToObject(method));
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
const hostCapabilities = [];
|
|
1914
|
+
for (let index = 0; index < (root.hostCapabilitiesLength?.() ?? 0); index += 1) {
|
|
1915
|
+
const capability = root.HOST_CAPABILITIES(index);
|
|
1916
|
+
if (capability) {
|
|
1917
|
+
hostCapabilities.push(hostCapabilityToObject(capability));
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
const timers = [];
|
|
1921
|
+
for (let index = 0; index < (root.timersLength?.() ?? 0); index += 1) {
|
|
1922
|
+
const timer = root.TIMERS(index);
|
|
1923
|
+
if (timer) {
|
|
1924
|
+
timers.push(timerSpecToObject(timer));
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
const protocols = [];
|
|
1928
|
+
for (let index = 0; index < (root.protocolsLength?.() ?? 0); index += 1) {
|
|
1929
|
+
const protocol = root.PROTOCOLS(index);
|
|
1930
|
+
if (protocol) {
|
|
1931
|
+
protocols.push(protocolSpecToObject(protocol));
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
const schemasUsed = [];
|
|
1935
|
+
for (let index = 0; index < (root.schemasUsedLength?.() ?? 0); index += 1) {
|
|
1936
|
+
const schema = typeRefToObject(root.SCHEMAS_USED(index));
|
|
1937
|
+
if (schema) {
|
|
1938
|
+
schemasUsed.push(schema);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
const buildArtifacts = [];
|
|
1942
|
+
for (let index = 0; index < (root.buildArtifactsLength?.() ?? 0); index += 1) {
|
|
1943
|
+
const artifact = root.BUILD_ARTIFACTS(index);
|
|
1944
|
+
if (artifact) {
|
|
1945
|
+
buildArtifacts.push(buildArtifactToObject(artifact));
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
const flowNodes = [];
|
|
1949
|
+
for (let index = 0; index < (root.flowNodesLength?.() ?? 0); index += 1) {
|
|
1950
|
+
const node = root.FLOW_NODES(index);
|
|
1951
|
+
if (node) flowNodes.push(flowNodeToObject(node));
|
|
1952
|
+
}
|
|
1953
|
+
const flowEdges = [];
|
|
1954
|
+
for (let index = 0; index < (root.flowEdgesLength?.() ?? 0); index += 1) {
|
|
1955
|
+
const edge = root.FLOW_EDGES(index);
|
|
1956
|
+
if (edge) flowEdges.push(flowEdgeToObject(edge));
|
|
1957
|
+
}
|
|
1958
|
+
const flowTriggers = [];
|
|
1959
|
+
for (let index = 0; index < (root.flowTriggersLength?.() ?? 0); index += 1) {
|
|
1960
|
+
const trigger = root.FLOW_TRIGGERS(index);
|
|
1961
|
+
if (trigger) flowTriggers.push(flowTriggerToObject(trigger));
|
|
1962
|
+
}
|
|
1963
|
+
const flowTriggerBindings = [];
|
|
1964
|
+
for (
|
|
1965
|
+
let index = 0;
|
|
1966
|
+
index < (root.flowTriggerBindingsLength?.() ?? 0);
|
|
1967
|
+
index += 1
|
|
1968
|
+
) {
|
|
1969
|
+
const binding = root.FLOW_TRIGGER_BINDINGS(index);
|
|
1970
|
+
if (binding) {
|
|
1971
|
+
flowTriggerBindings.push(flowTriggerBindingToObject(binding));
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
|
|
746
1975
|
return {
|
|
747
|
-
pluginId: root.
|
|
748
|
-
name: root.
|
|
749
|
-
version: root.
|
|
750
|
-
description: root.
|
|
751
|
-
tagline: root.
|
|
752
|
-
pluginType: root.
|
|
753
|
-
publisherName: root.
|
|
754
|
-
publisherHandle: root.
|
|
755
|
-
publisherUrl: root.
|
|
756
|
-
supportUrl: root.
|
|
757
|
-
tags: readStringVector(root, "tagsLength", "
|
|
758
|
-
features: readStringVector(root, "featuresLength", "
|
|
1976
|
+
pluginId: root.PLUGIN_ID(),
|
|
1977
|
+
name: root.NAME(),
|
|
1978
|
+
version: root.VERSION(),
|
|
1979
|
+
description: root.DESCRIPTION() || undefined,
|
|
1980
|
+
tagline: root.TAGLINE() || undefined,
|
|
1981
|
+
pluginType: root.PLUGIN_TYPE(),
|
|
1982
|
+
publisherName: root.PUBLISHER_NAME() || undefined,
|
|
1983
|
+
publisherHandle: root.PUBLISHER_HANDLE() || undefined,
|
|
1984
|
+
publisherUrl: root.PUBLISHER_URL() || undefined,
|
|
1985
|
+
supportUrl: root.SUPPORT_URL() || undefined,
|
|
1986
|
+
tags: readStringVector(root, "tagsLength", "TAGS"),
|
|
1987
|
+
features: readStringVector(root, "featuresLength", "FEATURES"),
|
|
759
1988
|
screenshotUrls: readStringVector(
|
|
760
1989
|
root,
|
|
761
1990
|
"screenshotUrlsLength",
|
|
762
|
-
"
|
|
1991
|
+
"SCREENSHOT_URLS",
|
|
763
1992
|
),
|
|
764
|
-
bannerUrl: root.
|
|
765
|
-
abiVersion: root.
|
|
1993
|
+
bannerUrl: root.BANNER_URL() || undefined,
|
|
1994
|
+
abiVersion: root.ABI_VERSION(),
|
|
766
1995
|
wasmHash: root.wasmHashArray() ?? null,
|
|
767
|
-
wasmSize: root.
|
|
768
|
-
wasmCid: root.
|
|
1996
|
+
wasmSize: root.WASM_SIZE(),
|
|
1997
|
+
wasmCid: root.WASM_CID() || undefined,
|
|
769
1998
|
encryptedWasmHash: root.encryptedWasmHashArray() ?? null,
|
|
770
|
-
encryptedWasmSize: root.
|
|
1999
|
+
encryptedWasmSize: root.ENCRYPTED_WASM_SIZE(),
|
|
771
2000
|
entryFunctions,
|
|
772
2001
|
requiredSchemas: readStringVector(
|
|
773
2002
|
root,
|
|
774
2003
|
"requiredSchemasLength",
|
|
775
|
-
"
|
|
2004
|
+
"REQUIRED_SCHEMAS",
|
|
776
2005
|
),
|
|
777
2006
|
dependencies,
|
|
778
2007
|
capabilities,
|
|
779
|
-
providerPeerId: root.
|
|
780
|
-
providerEpmCid: root.
|
|
781
|
-
encrypted: !!root.
|
|
782
|
-
requiredScope: root.
|
|
783
|
-
keyId: root.
|
|
784
|
-
|
|
2008
|
+
providerPeerId: root.PROVIDER_PEER_ID() || undefined,
|
|
2009
|
+
providerEpmCid: root.PROVIDER_EPM_CID() || undefined,
|
|
2010
|
+
encrypted: !!root.ENCRYPTED(),
|
|
2011
|
+
requiredScope: root.REQUIRED_SCOPE() || undefined,
|
|
2012
|
+
keyId: root.KEY_ID() || undefined,
|
|
2013
|
+
allowedXpubs: readStringVector(
|
|
785
2014
|
root,
|
|
786
|
-
"
|
|
787
|
-
"
|
|
2015
|
+
"allowedXpubsLength",
|
|
2016
|
+
"ALLOWED_XPUBS",
|
|
788
2017
|
),
|
|
789
|
-
maxGrantTimeoutMs: root.
|
|
2018
|
+
maxGrantTimeoutMs: root.MAX_GRANT_TIMEOUT_MS(),
|
|
790
2019
|
minPermissions: readStringVector(
|
|
791
2020
|
root,
|
|
792
2021
|
"minPermissionsLength",
|
|
793
|
-
"
|
|
2022
|
+
"MIN_PERMISSIONS",
|
|
794
2023
|
),
|
|
795
|
-
createdAt: root.
|
|
796
|
-
updatedAt: root.
|
|
797
|
-
documentationUrl: root.
|
|
798
|
-
changelogUrl: root.
|
|
799
|
-
iconUrl: root.
|
|
800
|
-
license: root.
|
|
801
|
-
paymentModel: root.
|
|
802
|
-
priceUsdCents: root.
|
|
803
|
-
subscriptionPeriodDays: root.
|
|
2024
|
+
createdAt: root.CREATED_AT(),
|
|
2025
|
+
updatedAt: root.UPDATED_AT(),
|
|
2026
|
+
documentationUrl: root.DOCUMENTATION_URL() || undefined,
|
|
2027
|
+
changelogUrl: root.CHANGELOG_URL() || undefined,
|
|
2028
|
+
iconUrl: root.ICON_URL() || undefined,
|
|
2029
|
+
license: root.LICENSE() || undefined,
|
|
2030
|
+
paymentModel: root.PAYMENT_MODEL(),
|
|
2031
|
+
priceUsdCents: root.PRICE_USD_CENTS(),
|
|
2032
|
+
subscriptionPeriodDays: root.SUBSCRIPTION_PERIOD_DAYS(),
|
|
804
2033
|
acceptedPaymentMethods: readStringVector(
|
|
805
2034
|
root,
|
|
806
2035
|
"acceptedPaymentMethodsLength",
|
|
807
|
-
"
|
|
2036
|
+
"ACCEPTED_PAYMENT_METHODS",
|
|
808
2037
|
),
|
|
809
|
-
listingStatus: root.
|
|
2038
|
+
listingStatus: root.LISTING_STATUS(),
|
|
810
2039
|
signature: root.signatureArray() ?? null,
|
|
2040
|
+
invokeSurfaces,
|
|
2041
|
+
methods,
|
|
2042
|
+
hostCapabilities,
|
|
2043
|
+
timers,
|
|
2044
|
+
protocols,
|
|
2045
|
+
schemasUsed,
|
|
2046
|
+
buildArtifacts,
|
|
2047
|
+
runtimeTargets: readStringVector(root, "runtimeTargetsLength", "RUNTIME_TARGETS"),
|
|
2048
|
+
flowNodes,
|
|
2049
|
+
flowEdges,
|
|
2050
|
+
flowTriggers,
|
|
2051
|
+
flowTriggerBindings,
|
|
811
2052
|
};
|
|
812
2053
|
}
|
|
813
2054
|
|