space-data-module-sdk 0.9.15 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/_shell/consumer-assets.html +1 -1
- package/docs/assets/sdn-chrome/sdn-chrome.js +1 -1
- package/docs/assets/vendor/sdn-stack-nav/{1.0.1/sdn-stack-nav.24eb3001afc5448a90cef87e53bb4e599c0ae4dc9e14bafb6d1236e0233c6008.js → 1.2.0/sdn-stack-nav.ba268c55a1551bcacc390ac01347c319335a1660787b55b4b239df00fc3c1a4c.js} +5 -0
- package/docs/browser-wasmedge-isomorphic.html +1 -1
- package/docs/byo-wasm-quickstart.html +1 -1
- package/docs/conformance.html +1 -1
- package/docs/events-abi.html +1 -1
- package/docs/families/analytics.html +1 -1
- package/docs/families/attitude.html +1 -1
- package/docs/families/behavior.html +1 -1
- package/docs/families/breakup.html +1 -1
- package/docs/families/conjunction.html +1 -1
- package/docs/families/data-source.html +1 -1
- package/docs/families/effects.html +1 -1
- package/docs/families/environment.html +1 -1
- package/docs/families/estimation.html +1 -1
- package/docs/families/gnc.html +1 -1
- package/docs/families/maneuver.html +1 -1
- package/docs/families/obstruction.html +1 -1
- package/docs/families/propagator.html +1 -1
- package/docs/families/propulsion.html +1 -1
- package/docs/families/reentry.html +1 -1
- package/docs/families/rf.html +1 -1
- package/docs/families/scheduler.html +1 -1
- package/docs/families/sensor.html +1 -1
- package/docs/families/signature.html +1 -1
- package/docs/flatsql-host-contract.html +16 -44
- package/docs/flatsql-host-contract.md +35 -107
- package/docs/flatsql-streaming-standard.html +14 -9
- package/docs/flatsql-streaming-standard.md +15 -10
- package/docs/gpu-module-abi.html +1 -1
- package/docs/index.html +1 -1
- package/docs/isomorphic-pthreads.html +1 -1
- package/docs/isomorphic-sdn-runtime-plan.html +1 -1
- package/docs/language-runtime-matrix.html +1 -1
- package/docs/module-bundle-runtime-plan.html +1 -1
- package/docs/module-publication-standard.html +1 -1
- package/docs/node-red-default-node-parity.html +1 -1
- package/docs/protect-and-sign.html +1 -1
- package/docs/protocol-installation.html +1 -1
- package/docs/publication-submission.html +1 -1
- package/docs/secrets-capability.html +1 -1
- package/docs/testing-harness.html +2 -2
- package/docs/testing-harness.md +7 -1
- package/docs/tri-runtime-parity-gate.html +1 -1
- package/docs/tri-runtime-parity.html +1 -1
- package/package.json +6 -6
- package/parity/gate.json +3 -3
- package/src/host/browserHost.js +2 -1
- package/src/index.d.ts +25 -11
- package/src/runtime-host/flatbufferStreamIngestor.js +49 -170
- package/src/runtime-host/flatsqlQueryProtocol.js +76 -0
- package/src/runtime-host/flatsqlRuntimeStore.js +79 -278
- package/src/runtime-host/index.js +3 -1
- package/src/testing/parityGate.js +1 -1
- package/src/utils/walletCurves.js +7 -0
- package/src/utils/wasmCrypto.js +2 -1
- /package/docs/assets/vendor/sdn-stack-nav/{1.0.1 → 1.2.0}/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css +0 -0
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<!-- SDN_CONSUMER_ASSETS_START -->
|
|
15
15
|
<link rel="stylesheet" href="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" crossorigin="anonymous">
|
|
16
16
|
<script defer src="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" crossorigin="anonymous" data-sdn-wallet-public-client="v1"></script>
|
|
17
|
-
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0
|
|
17
|
+
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.2.0/sdn-stack-nav.ba268c55a1551bcacc390ac01347c319335a1660787b55b4b239df00fc3c1a4c.js" integrity="sha384-4BDI84CnpZ83otmTHK/KzA5+4pw8q5l+3LInURbEVJY96/iLGzCZUZsCyxjZ1Kpb" crossorigin="anonymous" data-nav-style-url="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.2.0/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css" data-nav-style-integrity="sha384-c4M8Fg+kYaeOYYtJVr7jJsde24IhSWkWaRyAOHEZU9jozhRck089aw+mnHwxymds" data-wallet-client-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" data-wallet-client-integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" data-wallet-style-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" data-wallet-style-integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" data-wallet-client-id="sdn-module-sdk-pages-v1" data-wallet-callback-uri="https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html" data-wallet-registry-sha256="63784143e2ad8e2542d22148ff4a0a4da7a10f4b3f9909ae91a20dc0f60db06b"></script>
|
|
18
18
|
<!-- SDN_CONSUMER_ASSETS_END -->
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<!-- SDN_CONSUMER_ASSETS_START -->
|
|
15
15
|
<link rel="stylesheet" href="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" crossorigin="anonymous">
|
|
16
16
|
<script defer src="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" crossorigin="anonymous" data-sdn-wallet-public-client="v1"></script>
|
|
17
|
-
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0
|
|
17
|
+
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.2.0/sdn-stack-nav.ba268c55a1551bcacc390ac01347c319335a1660787b55b4b239df00fc3c1a4c.js" integrity="sha384-4BDI84CnpZ83otmTHK/KzA5+4pw8q5l+3LInURbEVJY96/iLGzCZUZsCyxjZ1Kpb" crossorigin="anonymous" data-nav-style-url="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.2.0/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css" data-nav-style-integrity="sha384-c4M8Fg+kYaeOYYtJVr7jJsde24IhSWkWaRyAOHEZU9jozhRck089aw+mnHwxymds" data-wallet-client-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" data-wallet-client-integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" data-wallet-style-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" data-wallet-style-integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" data-wallet-client-id="sdn-module-sdk-pages-v1" data-wallet-callback-uri="https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html" data-wallet-registry-sha256="63784143e2ad8e2542d22148ff4a0a4da7a10f4b3f9909ae91a20dc0f60db06b"></script>
|
|
18
18
|
<!-- SDN_CONSUMER_ASSETS_END -->
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<!-- SDN_CONSUMER_ASSETS_START -->
|
|
15
15
|
<link rel="stylesheet" href="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" crossorigin="anonymous">
|
|
16
16
|
<script defer src="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" crossorigin="anonymous" data-sdn-wallet-public-client="v1"></script>
|
|
17
|
-
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0
|
|
17
|
+
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.2.0/sdn-stack-nav.ba268c55a1551bcacc390ac01347c319335a1660787b55b4b239df00fc3c1a4c.js" integrity="sha384-4BDI84CnpZ83otmTHK/KzA5+4pw8q5l+3LInURbEVJY96/iLGzCZUZsCyxjZ1Kpb" crossorigin="anonymous" data-nav-style-url="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.2.0/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css" data-nav-style-integrity="sha384-c4M8Fg+kYaeOYYtJVr7jJsde24IhSWkWaRyAOHEZU9jozhRck089aw+mnHwxymds" data-wallet-client-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" data-wallet-client-integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" data-wallet-style-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" data-wallet-style-integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" data-wallet-client-id="sdn-module-sdk-pages-v1" data-wallet-callback-uri="https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html" data-wallet-registry-sha256="63784143e2ad8e2542d22148ff4a0a4da7a10f4b3f9909ae91a20dc0f60db06b"></script>
|
|
18
18
|
<!-- SDN_CONSUMER_ASSETS_END -->
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
|
@@ -175,7 +175,7 @@ const response = await harness.invokeModule("beta", {
|
|
|
175
175
|
<li><code>resolveRecord({ regionId, recordIndex })</code></li>
|
|
176
176
|
</ul>
|
|
177
177
|
<p>In-process <code>createRuntimeHost()</code> also exposes <code>registerExternalRegion(...)</code>, <code>setRegionRecordCount(...)</code>, and <code>resolveRecordView(...)</code> for hosts that already own resident buffers and need transient region descriptors without turning raw addresses into durable harness identity. Those helpers are not part of the current process/WasmEdge control protocol, which remains copy-based.</p>
|
|
178
|
-
<p>For outer transport ingest, the runtime-host surface also exposes <code>createFlatBufferStreamIngestor(...)</code>. That helper is intentionally outside the module invoke ABI. It accepts little-endian size-prefixed FlatBuffer stream chunks and appends durable rows through <code>createFlatSqlRuntimeStore()</code
|
|
178
|
+
<p>For outer transport ingest, the runtime-host surface also exposes <code>createFlatBufferStreamIngestor(...)</code>. That helper is intentionally outside the module invoke ABI. It accepts little-endian size-prefixed FlatBuffer stream chunks and appends durable rows through <code>createFlatSqlRuntimeStore()</code>. Provide compiled binary schemas through <code>schemas</code> or <code>resolveSchema</code>; payloads are FlatBuffer <code>Uint8Array</code>s. Row operations and <code>pushBytes</code>/<code>finish</code> are asynchronous and must be awaited. <code>query</code> constructs SDS QRP outside FlatSQL; <code>encodeFlatSqlQuery</code> and <code>decodeFlatSqlResult</code> expose this codec to other consumers. Integers outside JavaScript's safe range stay <code>bigint</code>. Close the row store when its owning host shuts down. No payload map or text-schema compiler remains in the runtime store.</p>
|
|
179
179
|
<p>Identity rules remain:</p>
|
|
180
180
|
<ul>
|
|
181
181
|
<li>standards rows are addressed by <code>($SCHEMA_FILE_ID, rowId)</code></li>
|
package/docs/testing-harness.md
CHANGED
|
@@ -110,7 +110,13 @@ current process/WasmEdge control protocol, which remains copy-based.
|
|
|
110
110
|
For outer transport ingest, the runtime-host surface also exposes
|
|
111
111
|
`createFlatBufferStreamIngestor(...)`. That helper is intentionally outside the
|
|
112
112
|
module invoke ABI. It accepts little-endian size-prefixed FlatBuffer stream
|
|
113
|
-
chunks and appends durable rows through `createFlatSqlRuntimeStore()`.
|
|
113
|
+
chunks and appends durable rows through `createFlatSqlRuntimeStore()`. Provide compiled binary schemas through `schemas` or
|
|
114
|
+
`resolveSchema`; payloads are FlatBuffer `Uint8Array`s. Row operations and
|
|
115
|
+
`pushBytes`/`finish` are asynchronous and must be awaited. `query` constructs SDS
|
|
116
|
+
QRP outside FlatSQL; `encodeFlatSqlQuery` and `decodeFlatSqlResult` expose this
|
|
117
|
+
codec to other consumers. Integers outside JavaScript's safe range stay `bigint`.
|
|
118
|
+
Close the row store when its owning host shuts down. No payload map or text-schema
|
|
119
|
+
compiler remains in the runtime store.
|
|
114
120
|
|
|
115
121
|
Identity rules remain:
|
|
116
122
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<!-- SDN_CONSUMER_ASSETS_START -->
|
|
15
15
|
<link rel="stylesheet" href="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" crossorigin="anonymous">
|
|
16
16
|
<script defer src="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" crossorigin="anonymous" data-sdn-wallet-public-client="v1"></script>
|
|
17
|
-
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0
|
|
17
|
+
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.2.0/sdn-stack-nav.ba268c55a1551bcacc390ac01347c319335a1660787b55b4b239df00fc3c1a4c.js" integrity="sha384-4BDI84CnpZ83otmTHK/KzA5+4pw8q5l+3LInURbEVJY96/iLGzCZUZsCyxjZ1Kpb" crossorigin="anonymous" data-nav-style-url="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.2.0/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css" data-nav-style-integrity="sha384-c4M8Fg+kYaeOYYtJVr7jJsde24IhSWkWaRyAOHEZU9jozhRck089aw+mnHwxymds" data-wallet-client-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" data-wallet-client-integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" data-wallet-style-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" data-wallet-style-integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" data-wallet-client-id="sdn-module-sdk-pages-v1" data-wallet-callback-uri="https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html" data-wallet-registry-sha256="63784143e2ad8e2542d22148ff4a0a4da7a10f4b3f9909ae91a20dc0f60db06b"></script>
|
|
18
18
|
<!-- SDN_CONSUMER_ASSETS_END -->
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<!-- SDN_CONSUMER_ASSETS_START -->
|
|
15
15
|
<link rel="stylesheet" href="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" crossorigin="anonymous">
|
|
16
16
|
<script defer src="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" crossorigin="anonymous" data-sdn-wallet-public-client="v1"></script>
|
|
17
|
-
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.0
|
|
17
|
+
<script defer src="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.2.0/sdn-stack-nav.ba268c55a1551bcacc390ac01347c319335a1660787b55b4b239df00fc3c1a4c.js" integrity="sha384-4BDI84CnpZ83otmTHK/KzA5+4pw8q5l+3LInURbEVJY96/iLGzCZUZsCyxjZ1Kpb" crossorigin="anonymous" data-nav-style-url="/space-data-module-sdk/assets/vendor/sdn-stack-nav/1.2.0/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css" data-nav-style-integrity="sha384-c4M8Fg+kYaeOYYtJVr7jJsde24IhSWkWaRyAOHEZU9jozhRck089aw+mnHwxymds" data-wallet-client-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js" data-wallet-client-integrity="sha384-FNcHq8FI7eBz2YUhfO3jNfmdObbCXmfg4ugmBEHzXW/KBpbUdJXqIzpn30OWJBuB" data-wallet-style-url="/space-data-module-sdk/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" data-wallet-style-integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" data-wallet-client-id="sdn-module-sdk-pages-v1" data-wallet-callback-uri="https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html" data-wallet-registry-sha256="63784143e2ad8e2542d22148ff4a0a4da7a10f4b3f9909ae91a20dc0f60db06b"></script>
|
|
18
18
|
<!-- SDN_CONSUMER_ASSETS_END -->
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "space-data-module-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Module SDK for building, validating, signing, and deploying WebAssembly modules on the Space Data Network.",
|
|
6
6
|
"type": "module",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"templates/"
|
|
93
93
|
],
|
|
94
94
|
"scripts": {
|
|
95
|
-
"test": "
|
|
95
|
+
"test": "node scripts/flatsql-release-e2e.mjs",
|
|
96
96
|
"test:host-surfaces": "node --test test/node-host.test.js test/host-abi.test.js test/browser-host.test.js test/browser-module-harness.test.js test/testing-harness.test.js",
|
|
97
97
|
"test:runtime-matrix": "SPACE_DATA_MODULE_SDK_ENABLE_RUNTIME_MATRIX=1 node --test test/runtime-matrix.test.js",
|
|
98
98
|
"test:parity": "node --test test/parity-harness.test.js",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"check:reference-frame": "node scripts/check-reference-frame-uniqueness.mjs",
|
|
120
120
|
"generate:propagator-abi": "node scripts/generate-propagator-abi.mjs",
|
|
121
121
|
"generate:vectors": "node ./examples/single-file-bundle/generate-vectors.mjs",
|
|
122
|
-
"prepublishOnly": "npm test && npm run check:compliance",
|
|
122
|
+
"prepublishOnly": "npm test && npm run check:compliance && npm run check:generated-bindings",
|
|
123
123
|
"playground:build": "node ./playground/build.mjs",
|
|
124
124
|
"playground:serve": "node ./playground/build.mjs && node ./playground/server.mjs",
|
|
125
125
|
"playground:gate": "node ./playground/build.mjs && node ./playground/test/browser-gate.mjs",
|
|
@@ -128,8 +128,8 @@
|
|
|
128
128
|
"dependencies": {
|
|
129
129
|
"flatbuffers": "^25.9.23",
|
|
130
130
|
"flatc-wasm": "^26.1.32",
|
|
131
|
-
"flatsql": "
|
|
132
|
-
"hd-wallet-wasm": "2.
|
|
131
|
+
"flatsql": "3.12.0",
|
|
132
|
+
"hd-wallet-wasm": "2.2.2",
|
|
133
133
|
"sdn-emception": "1.0.0",
|
|
134
134
|
"spacedatastandards.org": "1.261.0"
|
|
135
135
|
},
|
|
@@ -139,6 +139,6 @@
|
|
|
139
139
|
"playwright-core": "1.63.0"
|
|
140
140
|
},
|
|
141
141
|
"engines": {
|
|
142
|
-
"node": ">=
|
|
142
|
+
"node": ">=24.0.0"
|
|
143
143
|
}
|
|
144
144
|
}
|
package/parity/gate.json
CHANGED
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"note": "The SAME module after publication: signature/manifest records appended as a trailing custom section. Proves the record-stripping path yields a loadable payload that instantiates identically in all lanes — a published artifact must never be a fourth runtime."
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
"id": "flatsql-
|
|
22
|
-
"packagePath": "flatsql/wasm/flatsql
|
|
21
|
+
"id": "flatsql-unified",
|
|
22
|
+
"packagePath": "flatsql/wasm/flatsql.wasm",
|
|
23
23
|
"surface": "flatsql-engine",
|
|
24
24
|
"profile": "library",
|
|
25
|
-
"note": "
|
|
25
|
+
"note": "One unified FlatSQL binary, WASI preview1 threads plus the seven declared FlatSQL I/O imports. The binary query/ingest/reopen E2E runs it through the real SDK runtime store."
|
|
26
26
|
}
|
|
27
27
|
]
|
|
28
28
|
}
|
package/src/host/browserHost.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
toUint8Array,
|
|
14
14
|
} from "../utils/encoding.js";
|
|
15
15
|
import { derSignatureToRaw, rawSignatureToDer } from "../utils/ecdsaDer.js";
|
|
16
|
+
import { SECP256K1_CURVE } from "../utils/walletCurves.js";
|
|
16
17
|
import {
|
|
17
18
|
parseCronExpression,
|
|
18
19
|
matchesCronExpression,
|
|
@@ -913,7 +914,7 @@ export class BrowserHost {
|
|
|
913
914
|
);
|
|
914
915
|
}
|
|
915
916
|
return new Uint8Array(
|
|
916
|
-
wasmWallet.curves.publicKeyFromPrivate(toUint8Array(privateKey)),
|
|
917
|
+
wasmWallet.curves.publicKeyFromPrivate(toUint8Array(privateKey), SECP256K1_CURVE),
|
|
917
918
|
);
|
|
918
919
|
},
|
|
919
920
|
sign: (message, privateKey) => {
|
package/src/index.d.ts
CHANGED
|
@@ -405,7 +405,7 @@ export interface RowHandle {
|
|
|
405
405
|
|
|
406
406
|
export interface RuntimeRowView {
|
|
407
407
|
handle: RowHandle;
|
|
408
|
-
payload:
|
|
408
|
+
payload: Uint8Array;
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
export interface RuntimeRowQueryResult {
|
|
@@ -430,18 +430,29 @@ export interface FlatBufferStreamIngestContext {
|
|
|
430
430
|
stats: FlatBufferStreamIngestStats;
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
+
export type FlatSqlQueryParam = null | boolean | number | bigint | string | Uint8Array;
|
|
434
|
+
export interface FlatSqlRuntimeStoreOptions {
|
|
435
|
+
engine?: import("flatsql").FlatSQLOptions;
|
|
436
|
+
database?: import("flatsql").FlatSQL;
|
|
437
|
+
schemas?: import("flatsql").BinarySchema[];
|
|
438
|
+
resolveSchema?: (fileIdentifier: string) => import("flatsql").BinarySchema | Promise<import("flatsql").BinarySchema>;
|
|
439
|
+
}
|
|
433
440
|
export interface FlatSqlRuntimeStore {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
441
|
+
registerSchema(schema: import("flatsql").BinarySchema): Promise<void>;
|
|
442
|
+
appendRow(options: { schemaFileId: string; payload: Uint8Array }): Promise<RowHandle>;
|
|
443
|
+
listRows(schemaFileId?: string | null): Promise<RuntimeRowView[]>;
|
|
444
|
+
query(sql: string, params?: FlatSqlQueryParam[], limits?: import("flatsql").QueryOptions): Promise<RuntimeRowQueryResult>;
|
|
445
|
+
resolveRow(handle: RowHandle): Promise<RuntimeRowView | null>;
|
|
446
|
+
close(): Promise<void>;
|
|
438
447
|
}
|
|
448
|
+
export function encodeFlatSqlQuery(sql: string, parameters?: FlatSqlQueryParam[]): Uint8Array;
|
|
449
|
+
export function decodeFlatSqlResult(bytes: Uint8Array): RuntimeRowQueryResult;
|
|
439
450
|
|
|
440
451
|
export interface FlatBufferStreamIngestor {
|
|
441
452
|
rows: FlatSqlRuntimeStore;
|
|
442
453
|
stats: FlatBufferStreamIngestStats;
|
|
443
|
-
pushBytes(data: Uint8Array | ArrayBuffer | ArrayBufferView): number
|
|
444
|
-
finish(): 0
|
|
454
|
+
pushBytes(data: Uint8Array | ArrayBuffer | ArrayBufferView): Promise<number>;
|
|
455
|
+
finish(): Promise<0>;
|
|
445
456
|
}
|
|
446
457
|
|
|
447
458
|
export interface RuntimeRegionDescriptor {
|
|
@@ -561,28 +572,31 @@ export interface RuntimeHost {
|
|
|
561
572
|
}
|
|
562
573
|
|
|
563
574
|
export function createFlatBufferStreamIngestor(options?: {
|
|
575
|
+
store?: FlatSqlRuntimeStoreOptions;
|
|
576
|
+
maxFrameBytes?: number;
|
|
564
577
|
rows?: FlatSqlRuntimeStore;
|
|
565
578
|
frameRouter?:
|
|
566
579
|
| ((
|
|
567
580
|
payload: Uint8Array,
|
|
568
581
|
context: FlatBufferStreamIngestContext,
|
|
569
|
-
) => boolean | void)
|
|
582
|
+
) => boolean | void | Promise<boolean | void>)
|
|
570
583
|
| Record<
|
|
571
584
|
string,
|
|
572
585
|
(
|
|
573
586
|
payload: Uint8Array,
|
|
574
587
|
context: FlatBufferStreamIngestContext,
|
|
575
|
-
) => boolean | void
|
|
588
|
+
) => boolean | void | Promise<boolean | void>
|
|
576
589
|
>;
|
|
577
590
|
appendFrame?: (
|
|
578
591
|
payload: Uint8Array,
|
|
579
592
|
context: FlatBufferStreamIngestContext,
|
|
580
|
-
) => void
|
|
593
|
+
) => void | Promise<void>;
|
|
581
594
|
}): FlatBufferStreamIngestor;
|
|
582
|
-
export function createFlatSqlRuntimeStore(): FlatSqlRuntimeStore;
|
|
595
|
+
export function createFlatSqlRuntimeStore(options?: FlatSqlRuntimeStoreOptions): FlatSqlRuntimeStore;
|
|
583
596
|
export function createRuntimeRegionStore(): RuntimeRegionStore;
|
|
584
597
|
export function createModuleRegistry(): RuntimeModuleRegistry;
|
|
585
598
|
export function createRuntimeHost(options?: {
|
|
599
|
+
rowStore?: FlatSqlRuntimeStoreOptions;
|
|
586
600
|
rows?: FlatSqlRuntimeStore;
|
|
587
601
|
regions?: RuntimeRegionStore;
|
|
588
602
|
moduleRegistry?: RuntimeModuleRegistry;
|
|
@@ -1,181 +1,60 @@
|
|
|
1
1
|
import { createFlatSqlRuntimeStore } from "./flatsqlRuntimeStore.js";
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
if (data instanceof Uint8Array)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (data instanceof ArrayBuffer) {
|
|
8
|
-
return new Uint8Array(data);
|
|
9
|
-
}
|
|
10
|
-
if (ArrayBuffer.isView(data)) {
|
|
11
|
-
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
12
|
-
}
|
|
13
|
-
throw new TypeError(
|
|
14
|
-
"FlatBuffer stream ingestor expects Uint8Array, ArrayBuffer, or ArrayBufferView chunks.",
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function concatUint8Arrays(chunks) {
|
|
19
|
-
let totalLength = 0;
|
|
20
|
-
for (let index = 0; index < chunks.length; index += 1) {
|
|
21
|
-
totalLength += chunks[index].byteLength;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const combined = new Uint8Array(totalLength);
|
|
25
|
-
let offset = 0;
|
|
26
|
-
for (let index = 0; index < chunks.length; index += 1) {
|
|
27
|
-
combined.set(chunks[index], offset);
|
|
28
|
-
offset += chunks[index].byteLength;
|
|
29
|
-
}
|
|
30
|
-
return combined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function readFrameSize(bytes, offset) {
|
|
34
|
-
return (
|
|
35
|
-
bytes[offset] |
|
|
36
|
-
(bytes[offset + 1] << 8) |
|
|
37
|
-
(bytes[offset + 2] << 16) |
|
|
38
|
-
((bytes[offset + 3] << 24) >>> 0)
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function readFileIdentifier(payload) {
|
|
43
|
-
if (!(payload instanceof Uint8Array) || payload.byteLength < 8) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
return String.fromCharCode(payload[4], payload[5], payload[6], payload[7]);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function normalizeSchemaFileId(fileIdentifier) {
|
|
50
|
-
if (typeof fileIdentifier !== "string") {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const normalized = fileIdentifier.trim();
|
|
54
|
-
return normalized.length > 0 ? normalized : null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function resolveRouteHandler(frameRouter, rawFileIdentifier, schemaFileId) {
|
|
58
|
-
if (typeof frameRouter === "function") {
|
|
59
|
-
return frameRouter;
|
|
60
|
-
}
|
|
61
|
-
if (!frameRouter || typeof frameRouter !== "object") {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
if (typeof frameRouter[schemaFileId] === "function") {
|
|
65
|
-
return frameRouter[schemaFileId];
|
|
66
|
-
}
|
|
67
|
-
if (typeof frameRouter[rawFileIdentifier] === "function") {
|
|
68
|
-
return frameRouter[rawFileIdentifier];
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
3
|
+
function bytesOf(data) {
|
|
4
|
+
if (data instanceof ArrayBuffer) return new Uint8Array(data);
|
|
5
|
+
if (ArrayBuffer.isView(data)) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
6
|
+
throw new TypeError("FlatBuffer stream chunks must be binary buffers");
|
|
71
7
|
}
|
|
72
8
|
|
|
9
|
+
/** Ordered, backpressured ingestion. Await pushBytes before supplying the next
|
|
10
|
+
* chunk. A failed route/write makes the stream terminal rather than dropping a
|
|
11
|
+
* record and advancing its frame counter. */
|
|
73
12
|
export function createFlatBufferStreamIngestor(options = {}) {
|
|
74
|
-
const rows = options.rows ?? createFlatSqlRuntimeStore();
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
chunksReceived
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
function pushBytes(data) {
|
|
102
|
-
const bytes = toUint8Array(data);
|
|
103
|
-
stats.bytesReceived += bytes.byteLength;
|
|
104
|
-
stats.chunksReceived += 1;
|
|
105
|
-
|
|
106
|
-
const combined =
|
|
107
|
-
pending.byteLength > 0 ? concatUint8Arrays([pending, bytes]) : bytes;
|
|
108
|
-
|
|
109
|
-
let offset = 0;
|
|
110
|
-
let appendedCount = 0;
|
|
111
|
-
|
|
112
|
-
while (offset + 4 <= combined.byteLength) {
|
|
113
|
-
const frameSize = readFrameSize(combined, offset);
|
|
114
|
-
if (frameSize <= 0) {
|
|
115
|
-
stats.parseErrors += 1;
|
|
116
|
-
throw new Error("Invalid FlatBuffer stream frame size.");
|
|
117
|
-
}
|
|
118
|
-
if (offset + 4 + frameSize > combined.byteLength) {
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const payload = combined.subarray(offset + 4, offset + 4 + frameSize);
|
|
123
|
-
const rawFileIdentifier = readFileIdentifier(payload);
|
|
124
|
-
const schemaFileId = normalizeSchemaFileId(rawFileIdentifier);
|
|
125
|
-
if (!schemaFileId) {
|
|
126
|
-
stats.parseErrors += 1;
|
|
127
|
-
throw new Error(
|
|
128
|
-
"FlatBuffer stream frame is missing a readable file identifier.",
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const context = {
|
|
133
|
-
rawFileIdentifier,
|
|
134
|
-
schemaFileId,
|
|
135
|
-
rows,
|
|
136
|
-
stats,
|
|
137
|
-
};
|
|
138
|
-
const routeHandler = resolveRouteHandler(
|
|
139
|
-
frameRouter,
|
|
140
|
-
rawFileIdentifier,
|
|
141
|
-
schemaFileId,
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
stats.framesDecoded += 1;
|
|
145
|
-
if (routeHandler) {
|
|
146
|
-
const routeResult = routeHandler(payload, context);
|
|
147
|
-
if (routeResult !== false) {
|
|
148
|
-
stats.framesRouted += 1;
|
|
149
|
-
offset += 4 + frameSize;
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
13
|
+
const rows = options.rows ?? createFlatSqlRuntimeStore(options.store);
|
|
14
|
+
const maxFrameBytes = options.maxFrameBytes ?? 16 * 1024 * 1024;
|
|
15
|
+
if (!Number.isSafeInteger(maxFrameBytes) || maxFrameBytes < 8) throw new RangeError("Invalid frame byte limit");
|
|
16
|
+
const stats = { bytesReceived: 0, chunksReceived: 0, framesDecoded: 0, framesAppended: 0, framesRouted: 0, parseErrors: 0 };
|
|
17
|
+
let pending = new Uint8Array(), tail = Promise.resolve(), failed, finished = false;
|
|
18
|
+
async function ingest(bytes) {
|
|
19
|
+
if (failed) throw failed;
|
|
20
|
+
stats.bytesReceived += bytes.length; stats.chunksReceived++;
|
|
21
|
+
const combined = new Uint8Array(pending.length + bytes.length);
|
|
22
|
+
combined.set(pending); combined.set(bytes, pending.length);
|
|
23
|
+
let at = 0, appended = 0;
|
|
24
|
+
while (at + 4 <= combined.length) {
|
|
25
|
+
const size = new DataView(combined.buffer, at, 4).getUint32(0, true);
|
|
26
|
+
if (size < 8 || size > maxFrameBytes) { stats.parseErrors++; throw new Error("Invalid FlatBuffer stream frame size"); }
|
|
27
|
+
if (size > combined.length - at - 4) break;
|
|
28
|
+
const payload = combined.subarray(at + 4, at + 4 + size);
|
|
29
|
+
const schemaFileId = String.fromCharCode(...payload.subarray(4, 8));
|
|
30
|
+
if (!/^[\x20-\x7e]{4}$/.test(schemaFileId)) { stats.parseErrors++; throw new Error("Missing FlatBuffer file identifier"); }
|
|
31
|
+
const context = { rawFileIdentifier: schemaFileId, schemaFileId, rows, stats };
|
|
32
|
+
const route = typeof options.frameRouter === "function" ? options.frameRouter : options.frameRouter?.[schemaFileId];
|
|
33
|
+
stats.framesDecoded++;
|
|
34
|
+
if (route && await route(payload, context) !== false) stats.framesRouted++;
|
|
35
|
+
else {
|
|
36
|
+
if (options.appendFrame) await options.appendFrame(payload, context);
|
|
37
|
+
else await rows.appendRow({ schemaFileId, payload });
|
|
38
|
+
stats.framesAppended++; appended++;
|
|
152
39
|
}
|
|
153
|
-
|
|
154
|
-
appendDecodedFrame(payload, context);
|
|
155
|
-
stats.framesAppended += 1;
|
|
156
|
-
appendedCount += 1;
|
|
157
|
-
offset += 4 + frameSize;
|
|
40
|
+
at += size + 4;
|
|
158
41
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
offset < combined.byteLength
|
|
162
|
-
? combined.slice(offset)
|
|
163
|
-
: new Uint8Array(0);
|
|
164
|
-
|
|
165
|
-
return appendedCount;
|
|
42
|
+
pending = combined.slice(at);
|
|
43
|
+
return appended;
|
|
166
44
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
45
|
+
function pushBytes(data) {
|
|
46
|
+
if (finished) return Promise.reject(new Error("FlatBuffer stream is finished"));
|
|
47
|
+
const bytes = bytesOf(data).slice();
|
|
48
|
+
const result = tail.then(() => ingest(bytes));
|
|
49
|
+
tail = result.catch(error => { failed = error; });
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
async function finish() {
|
|
53
|
+
finished = true;
|
|
54
|
+
await tail;
|
|
55
|
+
if (failed) throw failed;
|
|
56
|
+
if (pending.length) throw new Error("FlatBuffer stream ended with a partial frame");
|
|
172
57
|
return 0;
|
|
173
58
|
}
|
|
174
|
-
|
|
175
|
-
return {
|
|
176
|
-
rows,
|
|
177
|
-
stats,
|
|
178
|
-
pushBytes,
|
|
179
|
-
finish,
|
|
180
|
-
};
|
|
59
|
+
return { rows, stats, pushBytes, finish };
|
|
181
60
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// SDK-side SDS conversion. FlatSQL itself receives and emits only FlatBuffers.
|
|
2
|
+
import { Builder, ByteBuffer } from "flatbuffers";
|
|
3
|
+
import { QRP } from "spacedatastandards.org/lib/js/QRP/QRP.js";
|
|
4
|
+
import { QRPValue } from "spacedatastandards.org/lib/js/QRP/QRPValue.js";
|
|
5
|
+
import { qrpValueKind as K } from "spacedatastandards.org/lib/js/QRP/qrpValueKind.js";
|
|
6
|
+
import { qrpRepresentation } from "spacedatastandards.org/lib/js/QRP/qrpRepresentation.js";
|
|
7
|
+
import { qrpKind } from "spacedatastandards.org/lib/js/QRP/qrpKind.js";
|
|
8
|
+
|
|
9
|
+
export function encodeFlatSqlQuery(sql, parameters = []) {
|
|
10
|
+
if (typeof sql !== "string" || !sql.trim()) throw new TypeError("SQL must be a nonempty string");
|
|
11
|
+
const b = new Builder(512), text = b.createString(sql);
|
|
12
|
+
const values = parameters.map(value => {
|
|
13
|
+
let kind = K.Null, data = 0;
|
|
14
|
+
if (typeof value === "string") { kind = K.Text; data = b.createString(value); }
|
|
15
|
+
else if (value instanceof Uint8Array) { kind = K.Bytes; data = QRPValue.createBytesValueVector(b, value); }
|
|
16
|
+
else if (typeof value === "boolean") kind = K.Bool;
|
|
17
|
+
else if (typeof value === "bigint" || (typeof value === "number" && Number.isSafeInteger(value))) {
|
|
18
|
+
kind = K.Int; value = BigInt(value);
|
|
19
|
+
if (value < -(1n << 63n) || value >= (1n << 63n)) throw new RangeError("SQL integer exceeds int64");
|
|
20
|
+
} else if (typeof value === "number" && Number.isFinite(value)) kind = K.Float;
|
|
21
|
+
else if (value !== null) throw new TypeError("SQL values are null, boolean, finite number, bigint, string or Uint8Array");
|
|
22
|
+
QRPValue.startQRPValue(b); QRPValue.addKind(b, kind);
|
|
23
|
+
if (kind === K.Text) QRPValue.addTextValue(b, data);
|
|
24
|
+
if (kind === K.Bytes) QRPValue.addBytesValue(b, data);
|
|
25
|
+
if (kind === K.Bool) QRPValue.addBoolValue(b, value);
|
|
26
|
+
if (kind === K.Int) QRPValue.addIntValue(b, value);
|
|
27
|
+
if (kind === K.Float) QRPValue.addFloatValue(b, value);
|
|
28
|
+
return QRPValue.endQRPValue(b);
|
|
29
|
+
});
|
|
30
|
+
const params = QRP.createParametersVector(b, values);
|
|
31
|
+
QRP.startQRP(b); QRP.addSql(b, text); QRP.addParameters(b, params);
|
|
32
|
+
QRP.addRepresentation(b, qrpRepresentation.FlatBuffer);
|
|
33
|
+
QRP.finishSizePrefixedQRPBuffer(b, QRP.endQRP(b));
|
|
34
|
+
return b.asUint8Array().slice();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function decodeFlatSqlResult(stream) {
|
|
38
|
+
if (!(stream instanceof Uint8Array)) throw new TypeError("QRP result must be Uint8Array");
|
|
39
|
+
let columns = [], ended = false;
|
|
40
|
+
const rows = [];
|
|
41
|
+
for (let at = 0; at < stream.length;) {
|
|
42
|
+
if (ended || stream.length - at < 4) throw new Error("Invalid QRP stream boundary");
|
|
43
|
+
const size = new DataView(stream.buffer, stream.byteOffset + at, 4).getUint32(0, true);
|
|
44
|
+
if (size < 8 || size > stream.length - at - 4) throw new Error("Truncated QRP frame");
|
|
45
|
+
const frame = stream.subarray(at, at + size + 4);
|
|
46
|
+
if (String.fromCharCode(...frame.subarray(8, 12)) !== "$QRP") throw new Error("Expected SDS QRP");
|
|
47
|
+
const page = QRP.getSizePrefixedRootAsQRP(new ByteBuffer(frame));
|
|
48
|
+
if (![qrpKind.Page, qrpKind.Error].includes(page.KIND()) || page.REPRESENTATION() !== qrpRepresentation.FlatBuffer) throw new Error("Unexpected QRP response kind");
|
|
49
|
+
if (page.ERROR_CODE() || page.KIND() === qrpKind.Error) throw new Error(`FlatSQL ${page.ERROR_CODE()}: ${page.MESSAGE()}`);
|
|
50
|
+
if (page.columnsLength() > size / 4 || page.rowsLength() > size / 4) throw new Error("Invalid QRP vector length");
|
|
51
|
+
if (page.columnsLength()) {
|
|
52
|
+
const next = Array.from({ length: page.columnsLength() }, (_, i) => page.COLUMNS(i).NAME());
|
|
53
|
+
if (columns.length && (columns.length !== next.length || columns.some((name, i) => name !== next[i]))) throw new Error("QRP columns changed");
|
|
54
|
+
columns = next;
|
|
55
|
+
}
|
|
56
|
+
for (let i = 0; i < page.rowsLength(); ++i) {
|
|
57
|
+
const row = page.ROWS(i);
|
|
58
|
+
if (row.cellsLength() !== columns.length) throw new Error("QRP row width mismatch");
|
|
59
|
+
rows.push(Array.from({ length: columns.length }, (_, j) => {
|
|
60
|
+
const c = row.CELLS(j);
|
|
61
|
+
switch (c.KIND()) {
|
|
62
|
+
case K.Null: return null;
|
|
63
|
+
case K.Bool: return c.BOOL_VALUE();
|
|
64
|
+
case K.Int: { const value = c.INT_VALUE(); return value <= BigInt(Number.MAX_SAFE_INTEGER) && value >= BigInt(Number.MIN_SAFE_INTEGER) ? Number(value) : value; }
|
|
65
|
+
case K.Float: return c.FLOAT_VALUE();
|
|
66
|
+
case K.Text: return c.TEXT_VALUE();
|
|
67
|
+
case K.Bytes: return c.bytesValueArray()?.slice() ?? new Uint8Array();
|
|
68
|
+
default: throw new Error("Unknown QRP cell kind");
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
ended = !page.PARTIAL(); at += size + 4;
|
|
73
|
+
}
|
|
74
|
+
if (!ended) throw new Error("QRP result has no terminal page");
|
|
75
|
+
return { columns, rows, rowCount: rows.length };
|
|
76
|
+
}
|