@query-farm/vgi-rpc 0.2.4 → 0.3.2
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 +3 -3
- package/dist/client/connect.d.ts.map +1 -1
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/introspect.d.ts +1 -1
- package/dist/client/introspect.d.ts.map +1 -1
- package/dist/client/ipc.d.ts +1 -1
- package/dist/client/ipc.d.ts.map +1 -1
- package/dist/client/pipe.d.ts +2 -2
- package/dist/client/pipe.d.ts.map +1 -1
- package/dist/client/stream.d.ts +1 -1
- package/dist/client/stream.d.ts.map +1 -1
- package/dist/dispatch/describe.d.ts +1 -1
- package/dist/dispatch/describe.d.ts.map +1 -1
- package/dist/dispatch/stream.d.ts +1 -1
- package/dist/dispatch/stream.d.ts.map +1 -1
- package/dist/dispatch/unary.d.ts.map +1 -1
- package/dist/http/common.d.ts +1 -1
- package/dist/http/common.d.ts.map +1 -1
- package/dist/http/dispatch.d.ts.map +1 -1
- package/dist/http/handler.d.ts.map +1 -1
- package/dist/http/index.d.ts +3 -1
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/token.d.ts.map +1 -1
- package/dist/http/types.d.ts.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2162 -2119
- package/dist/index.js.map +26 -26
- package/dist/protocol.d.ts +1 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/util/schema.d.ts +1 -1
- package/dist/util/schema.d.ts.map +1 -1
- package/dist/util/zstd.d.ts.map +1 -1
- package/dist/wire/reader.d.ts +1 -1
- package/dist/wire/reader.d.ts.map +1 -1
- package/dist/wire/request.d.ts +1 -1
- package/dist/wire/request.d.ts.map +1 -1
- package/dist/wire/response.d.ts +1 -1
- package/dist/wire/response.d.ts.map +1 -1
- package/dist/wire/writer.d.ts +1 -1
- package/dist/wire/writer.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/client/connect.ts +12 -20
- package/src/client/index.ts +8 -8
- package/src/client/introspect.ts +11 -15
- package/src/client/ipc.ts +18 -32
- package/src/client/pipe.ts +17 -37
- package/src/client/stream.ts +20 -46
- package/src/dispatch/describe.ts +15 -27
- package/src/dispatch/stream.ts +7 -21
- package/src/dispatch/unary.ts +1 -2
- package/src/http/common.ts +9 -19
- package/src/http/dispatch.ts +115 -110
- package/src/http/handler.ts +20 -55
- package/src/http/index.ts +3 -1
- package/src/http/token.ts +2 -7
- package/src/http/types.ts +2 -6
- package/src/index.ts +44 -41
- package/src/protocol.ts +8 -8
- package/src/schema.ts +12 -16
- package/src/server.ts +16 -36
- package/src/types.ts +9 -36
- package/src/util/schema.ts +1 -1
- package/src/util/zstd.ts +2 -8
- package/src/wire/reader.ts +2 -4
- package/src/wire/request.ts +4 -15
- package/src/wire/response.ts +9 -25
- package/src/wire/writer.ts +1 -5
package/dist/protocol.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SchemaLike } from "./schema.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type ExchangeFn, type ExchangeInit, type HeaderInit, type MethodDefinition, type ProducerFn, type ProducerInit, type UnaryHandler } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Fluent builder for defining RPC methods.
|
|
5
5
|
* Register unary, producer, and exchange methods, then pass to `VgiRpcServer`.
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAIA,OAA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AAI,EAAE,MAAM,EACZ,MAAM,EAAE;QACN,MAAM,EAAE,UAAU,CAAC;QACnB,WAAW,EAAE,UAAU,CAAC;QACxB,YAAY,EAAE,UAAU,CAAC;QACzB,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;QACtB,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QACxB,YAAY,CAAC,EAAE,UAAU,CAAC;QAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC/B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACrC,GACA,IAAI;IAoBP,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC;CAG5C"}
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Binary, Bool, DataType, Field, Float32, Float64, Int32, Int64, Schema, Utf8 } from "@query-farm/apache-arrow";
|
|
2
2
|
/** Apache Arrow Utf8 type. Use as schema shorthand: `{ name: str }` */
|
|
3
3
|
export declare const str: Utf8;
|
|
4
4
|
/** Apache Arrow Binary type. Use as schema shorthand: `{ data: bytes }` */
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,MAAM,EACN,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,OAAO,EACP,OAAO,EAEP,KAAK,EACL,KAAK,EACL,MAAM,EACN,IAAI,EACL,MAAM,0BAA0B,CAAC;AAMlC,uEAAuE;AACvE,eAAO,MAAM,GAAG,MAAa,CAAC;AAC9B,2EAA2E;AAC3E,eAAO,MAAM,KAAK,QAAe,CAAC;AAClC,yEAAyE;AACzE,eAAO,MAAM,GAAG,OAAc,CAAC;AAC/B,2EAA2E;AAC3E,eAAO,MAAM,KAAK,OAAc,CAAC;AACjC,6EAA6E;AAC7E,eAAO,MAAM,KAAK,SAAgB,CAAC;AACnC,+EAA+E;AAC/E,eAAO,MAAM,OAAO,SAAgB,CAAC;AACrC,wEAAwE;AACxE,eAAO,MAAM,IAAI,MAAa,CAAC;AAM/B;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAC,CAAC;AAEnE;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAcjD;AAiBD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAiBpF"}
|
package/dist/server.d.ts
CHANGED
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAS9C;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAA+D;gBAExE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;IAWzF,gEAAgE;IAC1D,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAwCZ,QAAQ;CA0DvB"}
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAyB,KAAK,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAG3F,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,+CAA+C;AAC/C,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CACjF;AAED,wDAAwD;AACxD,MAAM,MAAM,YAAY,GAAG,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,GAAG,EAAE,UAAU,KACZ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExD,sFAAsF;AACtF,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACpF,0FAA0F;AAC1F,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAE3F,sFAAsF;AACtF,MAAM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M,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/util/schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAA2B,KAAK,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEhF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAQ1D"}
|
package/dist/util/zstd.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zstd.d.ts","sourceRoot":"","sources":["../../src/util/zstd.ts"],"names":[],"mappings":"AAcA,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"zstd.d.ts","sourceRoot":"","sources":["../../src/util/zstd.ts"],"names":[],"mappings":"AAcA,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAerF;AAED,uCAAuC;AACvC,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CASxE"}
|
package/dist/wire/reader.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/wire/reader.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/wire/reader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAqB,KAAK,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAE5F,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,WAAW,CAAS;IAC5B,+EAA+E;IAC/E,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO;WAIM,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IASxG;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IA2BjD;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAY9C;;;;;;;OAOG;IACG,aAAa,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAiB5C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
|
package/dist/wire/request.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/wire/request.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,KAAK,
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/wire/request.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAInF,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,aAAa,CAkE9E"}
|
package/dist/wire/response.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RecordBatch, Schema } from "apache-arrow";
|
|
1
|
+
import { RecordBatch, type Schema } from "@query-farm/apache-arrow";
|
|
2
2
|
/**
|
|
3
3
|
* Coerce values for Int64 schema fields from Number to BigInt.
|
|
4
4
|
* Handles both single values and arrays. Returns a new record with coerced values.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/wire/response.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/wire/response.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,WAAW,EACX,KAAK,MAAM,EAGZ,MAAM,0BAA0B,CAAC;AAGlC;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAc5F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,IAAI,GACvB,WAAW,CAwCb;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,CAiBrH;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GACxB,WAAW,CAeb;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,WAAW,CAyB3F"}
|
package/dist/wire/writer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RecordBatch, type Schema } from "apache-arrow";
|
|
1
|
+
import { type RecordBatch, type Schema } from "@query-farm/apache-arrow";
|
|
2
2
|
/**
|
|
3
3
|
* Writes sequential IPC streams to a file descriptor (e.g., stdout).
|
|
4
4
|
* Each call to writeStream() writes a complete IPC stream: schema + batches + EOS.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/wire/writer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/wire/writer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAA2B,KAAK,MAAM,EAAE,MAAM,0BAA0B,CAAC;AA4BlG;;;;;;GAMG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;gBAEhB,EAAE,GAAE,MAAkB;IAIlC;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI;IAYzD;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB;CAG9C;AAED;;;;;;;;GAQG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;IAC5B,OAAO,CAAC,MAAM,CAAS;gBAEX,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAQtC;;;;;;;;;OASG;IACH,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAM/B;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb;;;OAGG;IACH,OAAO,CAAC,KAAK;CAOd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@query-farm/vgi-rpc",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://vgi-rpc-typescript.query.farm",
|
|
6
6
|
"repository": {
|
|
@@ -22,16 +22,20 @@
|
|
|
22
22
|
"src"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"apache-arrow": "
|
|
25
|
+
"@query-farm/apache-arrow": "*"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
+
"@biomejs/biome": "^2.4.5",
|
|
28
29
|
"@types/bun": "latest"
|
|
29
30
|
},
|
|
30
31
|
"scripts": {
|
|
31
32
|
"build": "bun run build:types && bun run build:js",
|
|
32
33
|
"build:types": "bunx tsc -p tsconfig.build.json",
|
|
33
|
-
"build:js": "bun build ./src/index.ts --outdir dist --target node --format esm --sourcemap=external --external apache-arrow",
|
|
34
|
-
"postinstall": "cd node_modules/apache-arrow && node -e \"const fs=require('fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));p.main='
|
|
35
|
-
"test": "bun test"
|
|
34
|
+
"build:js": "bun build ./src/index.ts --outdir dist --target node --format esm --sourcemap=external --external @query-farm/apache-arrow",
|
|
35
|
+
"postinstall": "cd node_modules/@query-farm/apache-arrow && node -e \"const fs=require('fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));p.main='src/Arrow.node.ts';fs.writeFileSync('package.json',JSON.stringify(p,null,2)+'\\n')\"",
|
|
36
|
+
"test": "bun test",
|
|
37
|
+
"lint": "biome check .",
|
|
38
|
+
"lint:fix": "biome check --write .",
|
|
39
|
+
"format": "biome format --write ."
|
|
36
40
|
}
|
|
37
41
|
}
|
package/src/client/connect.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// © Copyright 2025-2026, Query.Farm LLC - https://query.farm
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { RecordBatch, Schema } from "apache-arrow";
|
|
5
|
-
import {
|
|
4
|
+
import type { RecordBatch, Schema } from "@query-farm/apache-arrow";
|
|
5
|
+
import { LOG_LEVEL_KEY, STATE_KEY } from "../constants.js";
|
|
6
6
|
import { ARROW_CONTENT_TYPE } from "../http/common.js";
|
|
7
|
+
import { httpIntrospect, type MethodInfo, type ServiceDescription } from "./introspect.js";
|
|
7
8
|
import {
|
|
8
9
|
buildRequestIpc,
|
|
9
|
-
readResponseBatches,
|
|
10
10
|
dispatchLogOrError,
|
|
11
11
|
extractBatchRows,
|
|
12
|
+
readResponseBatches,
|
|
12
13
|
readSequentialStreams,
|
|
13
14
|
} from "./ipc.js";
|
|
14
|
-
import { httpIntrospect, type MethodInfo, type ServiceDescription } from "./introspect.js";
|
|
15
15
|
import { HttpStreamSession } from "./stream.js";
|
|
16
|
-
import type { HttpConnectOptions,
|
|
16
|
+
import type { HttpConnectOptions, StreamSession } from "./types.js";
|
|
17
17
|
|
|
18
18
|
type CompressFn = (data: Uint8Array, level: number) => Uint8Array;
|
|
19
19
|
type DecompressFn = (data: Uint8Array) => Uint8Array;
|
|
@@ -25,10 +25,7 @@ export interface RpcClient {
|
|
|
25
25
|
close(): void;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export function httpConnect(
|
|
29
|
-
baseUrl: string,
|
|
30
|
-
options?: HttpConnectOptions,
|
|
31
|
-
): RpcClient {
|
|
28
|
+
export function httpConnect(baseUrl: string, options?: HttpConnectOptions): RpcClient {
|
|
32
29
|
const prefix = (options?.prefix ?? "/vgi").replace(/\/+$/, "");
|
|
33
30
|
const onLog = options?.onLog;
|
|
34
31
|
const compressionLevel = options?.compressionLevel;
|
|
@@ -84,10 +81,7 @@ export function httpConnect(
|
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
return {
|
|
87
|
-
async call(
|
|
88
|
-
method: string,
|
|
89
|
-
params?: Record<string, any>,
|
|
90
|
-
): Promise<Record<string, any> | null> {
|
|
84
|
+
async call(method: string, params?: Record<string, any>): Promise<Record<string, any> | null> {
|
|
91
85
|
await ensureCompression();
|
|
92
86
|
const methods = await ensureMethodCache();
|
|
93
87
|
const info = methods.get(method);
|
|
@@ -135,10 +129,7 @@ export function httpConnect(
|
|
|
135
129
|
return result;
|
|
136
130
|
},
|
|
137
131
|
|
|
138
|
-
async stream(
|
|
139
|
-
method: string,
|
|
140
|
-
params?: Record<string, any>,
|
|
141
|
-
): Promise<HttpStreamSession> {
|
|
132
|
+
async stream(method: string, params?: Record<string, any>): Promise<HttpStreamSession> {
|
|
142
133
|
await ensureCompression();
|
|
143
134
|
const methods = await ensureMethodCache();
|
|
144
135
|
const info = methods.get(method);
|
|
@@ -278,9 +269,10 @@ export function httpConnect(
|
|
|
278
269
|
// response (it carries the server's actual output schema even for
|
|
279
270
|
// zero-row token batches), then pending batch schemas, then describe info.
|
|
280
271
|
const outputSchema =
|
|
281
|
-
(streamSchema && streamSchema.fields.length > 0 ? streamSchema : null)
|
|
282
|
-
|
|
283
|
-
|
|
272
|
+
(streamSchema && streamSchema.fields.length > 0 ? streamSchema : null) ??
|
|
273
|
+
(pendingBatches.length > 0 ? pendingBatches[0].schema : null) ??
|
|
274
|
+
info.outputSchema ??
|
|
275
|
+
info.resultSchema;
|
|
284
276
|
|
|
285
277
|
return new HttpStreamSession({
|
|
286
278
|
baseUrl,
|
package/src/client/index.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export { httpConnect, type RpcClient } from "./connect.js";
|
|
5
|
-
export { httpIntrospect, parseDescribeResponse, type ServiceDescription
|
|
5
|
+
export { httpIntrospect, type MethodInfo, parseDescribeResponse, type ServiceDescription } from "./introspect.js";
|
|
6
|
+
export { PipeStreamSession, pipeConnect, subprocessConnect } from "./pipe.js";
|
|
6
7
|
export { HttpStreamSession } from "./stream.js";
|
|
7
|
-
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type SubprocessConnectOptions,
|
|
8
|
+
export type {
|
|
9
|
+
HttpConnectOptions,
|
|
10
|
+
LogMessage,
|
|
11
|
+
PipeConnectOptions,
|
|
12
|
+
StreamSession,
|
|
13
|
+
SubprocessConnectOptions,
|
|
14
14
|
} from "./types.js";
|
package/src/client/introspect.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
// © Copyright 2025-2026, Query.Farm LLC - https://query.farm
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
DESCRIBE_METHOD_NAME,
|
|
7
|
-
PROTOCOL_NAME_KEY,
|
|
8
|
-
DESCRIBE_VERSION_KEY,
|
|
9
|
-
} from "../constants.js";
|
|
4
|
+
import { Schema as ArrowSchema, type RecordBatch, RecordBatchReader, type Schema } from "@query-farm/apache-arrow";
|
|
5
|
+
import { DESCRIBE_METHOD_NAME, PROTOCOL_NAME_KEY } from "../constants.js";
|
|
10
6
|
import { ARROW_CONTENT_TYPE } from "../http/common.js";
|
|
11
|
-
import { buildRequestIpc,
|
|
12
|
-
import { Schema as ArrowSchema } from "apache-arrow";
|
|
7
|
+
import { buildRequestIpc, dispatchLogOrError, readResponseBatches } from "./ipc.js";
|
|
13
8
|
import type { LogMessage } from "./types.js";
|
|
14
9
|
|
|
15
10
|
export interface MethodInfo {
|
|
@@ -68,7 +63,7 @@ export async function parseDescribeResponse(
|
|
|
68
63
|
const name = dataBatch.getChildAt(0)!.get(i) as string; // name
|
|
69
64
|
const methodType = dataBatch.getChildAt(1)!.get(i) as string; // method_type
|
|
70
65
|
const doc = dataBatch.getChildAt(2)?.get(i) as string | null; // doc
|
|
71
|
-
const
|
|
66
|
+
const _hasReturn = dataBatch.getChildAt(3)!.get(i) as boolean; // has_return
|
|
72
67
|
const paramsIpc = dataBatch.getChildAt(4)!.get(i) as Uint8Array; // params_schema_ipc
|
|
73
68
|
const resultIpc = dataBatch.getChildAt(5)!.get(i) as Uint8Array; // result_schema_ipc
|
|
74
69
|
const paramTypesJson = dataBatch.getChildAt(6)?.get(i) as string | null; // param_types_json
|
|
@@ -81,12 +76,16 @@ export async function parseDescribeResponse(
|
|
|
81
76
|
|
|
82
77
|
let paramTypes: Record<string, string> | undefined;
|
|
83
78
|
if (paramTypesJson) {
|
|
84
|
-
try {
|
|
79
|
+
try {
|
|
80
|
+
paramTypes = JSON.parse(paramTypesJson);
|
|
81
|
+
} catch {}
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
let defaults: Record<string, any> | undefined;
|
|
88
85
|
if (paramDefaultsJson) {
|
|
89
|
-
try {
|
|
86
|
+
try {
|
|
87
|
+
defaults = JSON.parse(paramDefaultsJson);
|
|
88
|
+
} catch {}
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
const info: MethodInfo = {
|
|
@@ -117,10 +116,7 @@ export async function parseDescribeResponse(
|
|
|
117
116
|
/**
|
|
118
117
|
* Send a __describe__ request and return a ServiceDescription.
|
|
119
118
|
*/
|
|
120
|
-
export async function httpIntrospect(
|
|
121
|
-
baseUrl: string,
|
|
122
|
-
options?: { prefix?: string },
|
|
123
|
-
): Promise<ServiceDescription> {
|
|
119
|
+
export async function httpIntrospect(baseUrl: string, options?: { prefix?: string }): Promise<ServiceDescription> {
|
|
124
120
|
const prefix = options?.prefix ?? "/vgi";
|
|
125
121
|
const emptySchema = new ArrowSchema([]);
|
|
126
122
|
const body = buildRequestIpc(emptySchema, {}, DESCRIBE_METHOD_NAME);
|
package/src/client/ipc.ts
CHANGED
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Schema,
|
|
5
|
+
Binary,
|
|
6
|
+
Bool,
|
|
8
7
|
DataType,
|
|
9
8
|
Float64,
|
|
10
9
|
Int64,
|
|
11
|
-
Utf8,
|
|
12
|
-
Bool,
|
|
13
|
-
Binary,
|
|
14
|
-
vectorFromArray,
|
|
15
10
|
makeData,
|
|
11
|
+
RecordBatch,
|
|
12
|
+
RecordBatchReader,
|
|
13
|
+
type Schema,
|
|
16
14
|
Struct,
|
|
17
|
-
|
|
15
|
+
Utf8,
|
|
16
|
+
vectorFromArray,
|
|
17
|
+
} from "@query-farm/apache-arrow";
|
|
18
18
|
import {
|
|
19
|
-
|
|
20
|
-
REQUEST_VERSION_KEY,
|
|
21
|
-
REQUEST_VERSION,
|
|
19
|
+
LOG_EXTRA_KEY,
|
|
22
20
|
LOG_LEVEL_KEY,
|
|
23
21
|
LOG_MESSAGE_KEY,
|
|
24
|
-
|
|
22
|
+
REQUEST_VERSION,
|
|
23
|
+
REQUEST_VERSION_KEY,
|
|
24
|
+
RPC_METHOD_KEY,
|
|
25
25
|
} from "../constants.js";
|
|
26
26
|
import { RpcError } from "../errors.js";
|
|
27
27
|
import { serializeIpcStream } from "../http/common.js";
|
|
28
|
-
import { IpcStreamReader
|
|
28
|
+
import { IpcStreamReader } from "../wire/reader.js";
|
|
29
29
|
import type { LogMessage } from "./types.js";
|
|
30
30
|
|
|
31
31
|
/** Infer an Arrow DataType from a JS value. */
|
|
@@ -80,11 +80,7 @@ function coerceForArrow(type: DataType, value: any): any {
|
|
|
80
80
|
/**
|
|
81
81
|
* Build a 1-row Arrow IPC request batch with method metadata.
|
|
82
82
|
*/
|
|
83
|
-
export function buildRequestIpc(
|
|
84
|
-
schema: Schema,
|
|
85
|
-
params: Record<string, any>,
|
|
86
|
-
method: string,
|
|
87
|
-
): Uint8Array {
|
|
83
|
+
export function buildRequestIpc(schema: Schema, params: Record<string, any>, method: string): Uint8Array {
|
|
88
84
|
const metadata = new Map<string, string>();
|
|
89
85
|
metadata.set(RPC_METHOD_KEY, method);
|
|
90
86
|
metadata.set(REQUEST_VERSION_KEY, REQUEST_VERSION);
|
|
@@ -121,9 +117,7 @@ export function buildRequestIpc(
|
|
|
121
117
|
/**
|
|
122
118
|
* Read schema + all batches from an IPC stream body.
|
|
123
119
|
*/
|
|
124
|
-
export async function readResponseBatches(
|
|
125
|
-
body: Uint8Array,
|
|
126
|
-
): Promise<{ schema: Schema; batches: RecordBatch[] }> {
|
|
120
|
+
export async function readResponseBatches(body: Uint8Array): Promise<{ schema: Schema; batches: RecordBatch[] }> {
|
|
127
121
|
const reader = await RecordBatchReader.from(body);
|
|
128
122
|
await reader.open();
|
|
129
123
|
const schema = reader.schema;
|
|
@@ -140,10 +134,7 @@ export async function readResponseBatches(
|
|
|
140
134
|
* If other level → call onLog.
|
|
141
135
|
* Returns true if the batch was consumed as a log/error.
|
|
142
136
|
*/
|
|
143
|
-
export function dispatchLogOrError(
|
|
144
|
-
batch: RecordBatch,
|
|
145
|
-
onLog?: (msg: LogMessage) => void,
|
|
146
|
-
): boolean {
|
|
137
|
+
export function dispatchLogOrError(batch: RecordBatch, onLog?: (msg: LogMessage) => void): boolean {
|
|
147
138
|
const meta = batch.metadata;
|
|
148
139
|
if (!meta) return false;
|
|
149
140
|
|
|
@@ -194,10 +185,7 @@ export function extractBatchRows(batch: RecordBatch): Record<string, any>[] {
|
|
|
194
185
|
const field = batch.schema.fields[i];
|
|
195
186
|
let value = batch.getChildAt(i)?.get(r);
|
|
196
187
|
if (typeof value === "bigint") {
|
|
197
|
-
if (
|
|
198
|
-
value >= BigInt(Number.MIN_SAFE_INTEGER) &&
|
|
199
|
-
value <= BigInt(Number.MAX_SAFE_INTEGER)
|
|
200
|
-
) {
|
|
188
|
+
if (value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
201
189
|
value = Number(value);
|
|
202
190
|
}
|
|
203
191
|
}
|
|
@@ -212,9 +200,7 @@ export function extractBatchRows(batch: RecordBatch): Record<string, any>[] {
|
|
|
212
200
|
* Read sequential IPC streams from a response body.
|
|
213
201
|
* Returns an IpcStreamReader for reading header + data streams.
|
|
214
202
|
*/
|
|
215
|
-
export async function readSequentialStreams(
|
|
216
|
-
body: Uint8Array,
|
|
217
|
-
): Promise<IpcStreamReader> {
|
|
203
|
+
export async function readSequentialStreams(body: Uint8Array): Promise<IpcStreamReader> {
|
|
218
204
|
const stream = new ReadableStream<Uint8Array>({
|
|
219
205
|
start(controller) {
|
|
220
206
|
controller.enqueue(body);
|
package/src/client/pipe.ts
CHANGED
|
@@ -2,36 +2,22 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
Field,
|
|
6
|
+
makeData,
|
|
5
7
|
RecordBatch,
|
|
6
8
|
RecordBatchStreamWriter,
|
|
7
9
|
Schema,
|
|
8
|
-
Field,
|
|
9
10
|
Struct,
|
|
10
|
-
makeData,
|
|
11
11
|
vectorFromArray,
|
|
12
|
-
} from "apache-arrow";
|
|
12
|
+
} from "@query-farm/apache-arrow";
|
|
13
13
|
import { DESCRIBE_METHOD_NAME } from "../constants.js";
|
|
14
|
+
import { RpcError } from "../errors.js";
|
|
14
15
|
import { serializeIpcStream } from "../http/common.js";
|
|
15
16
|
import { IpcStreamReader } from "../wire/reader.js";
|
|
16
|
-
import {
|
|
17
|
-
inferArrowType,
|
|
18
|
-
buildRequestIpc,
|
|
19
|
-
dispatchLogOrError,
|
|
20
|
-
extractBatchRows,
|
|
21
|
-
} from "./ipc.js";
|
|
22
|
-
import {
|
|
23
|
-
parseDescribeResponse,
|
|
24
|
-
type MethodInfo,
|
|
25
|
-
type ServiceDescription,
|
|
26
|
-
} from "./introspect.js";
|
|
27
|
-
import type {
|
|
28
|
-
LogMessage,
|
|
29
|
-
PipeConnectOptions,
|
|
30
|
-
SubprocessConnectOptions,
|
|
31
|
-
StreamSession,
|
|
32
|
-
} from "./types.js";
|
|
33
17
|
import type { RpcClient } from "./connect.js";
|
|
34
|
-
import {
|
|
18
|
+
import { type MethodInfo, parseDescribeResponse, type ServiceDescription } from "./introspect.js";
|
|
19
|
+
import { buildRequestIpc, dispatchLogOrError, extractBatchRows, inferArrowType } from "./ipc.js";
|
|
20
|
+
import type { LogMessage, PipeConnectOptions, StreamSession, SubprocessConnectOptions } from "./types.js";
|
|
35
21
|
|
|
36
22
|
// ---------------------------------------------------------------------------
|
|
37
23
|
// Writable abstraction
|
|
@@ -195,9 +181,12 @@ export class PipeStreamSession implements StreamSession {
|
|
|
195
181
|
// strictly and its schema typically uses nullable columns.
|
|
196
182
|
const keys = Object.keys(input[0]);
|
|
197
183
|
const fields = keys.map((key) => {
|
|
198
|
-
let sample: any
|
|
184
|
+
let sample: any;
|
|
199
185
|
for (const row of input) {
|
|
200
|
-
if (row[key] != null) {
|
|
186
|
+
if (row[key] != null) {
|
|
187
|
+
sample = row[key];
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
201
190
|
}
|
|
202
191
|
const arrowType = inferArrowType(sample);
|
|
203
192
|
return new Field(key, arrowType, /* nullable */ true);
|
|
@@ -215,7 +204,7 @@ export class PipeStreamSession implements StreamSession {
|
|
|
215
204
|
throw new RpcError(
|
|
216
205
|
"ProtocolError",
|
|
217
206
|
`Exchange input schema changed: expected [${cached.fields.map((f) => f.name).join(", ")}] ` +
|
|
218
|
-
|
|
207
|
+
`but got [${inputSchema.fields.map((f) => f.name).join(", ")}]`,
|
|
219
208
|
"",
|
|
220
209
|
);
|
|
221
210
|
}
|
|
@@ -422,7 +411,7 @@ export function pipeConnect(
|
|
|
422
411
|
if (_busy) {
|
|
423
412
|
throw new Error(
|
|
424
413
|
"Pipe transport is busy — another call or stream is in progress. " +
|
|
425
|
-
|
|
414
|
+
"Pipe connections are single-threaded; wait for the current operation to complete.",
|
|
426
415
|
);
|
|
427
416
|
}
|
|
428
417
|
_busy = true;
|
|
@@ -470,10 +459,7 @@ export function pipeConnect(
|
|
|
470
459
|
}
|
|
471
460
|
|
|
472
461
|
return {
|
|
473
|
-
async call(
|
|
474
|
-
method: string,
|
|
475
|
-
params?: Record<string, any>,
|
|
476
|
-
): Promise<Record<string, any> | null> {
|
|
462
|
+
async call(method: string, params?: Record<string, any>): Promise<Record<string, any> | null> {
|
|
477
463
|
const methods = await ensureMethodCache();
|
|
478
464
|
await acquireBusy();
|
|
479
465
|
try {
|
|
@@ -522,10 +508,7 @@ export function pipeConnect(
|
|
|
522
508
|
}
|
|
523
509
|
},
|
|
524
510
|
|
|
525
|
-
async stream(
|
|
526
|
-
method: string,
|
|
527
|
-
params?: Record<string, any>,
|
|
528
|
-
): Promise<StreamSession> {
|
|
511
|
+
async stream(method: string, params?: Record<string, any>): Promise<StreamSession> {
|
|
529
512
|
const methods = await ensureMethodCache();
|
|
530
513
|
await acquireBusy();
|
|
531
514
|
|
|
@@ -616,10 +599,7 @@ export function pipeConnect(
|
|
|
616
599
|
// subprocessConnect — spawn a process and wrap with pipeConnect
|
|
617
600
|
// ---------------------------------------------------------------------------
|
|
618
601
|
|
|
619
|
-
export function subprocessConnect(
|
|
620
|
-
cmd: string[],
|
|
621
|
-
options?: SubprocessConnectOptions,
|
|
622
|
-
): RpcClient {
|
|
602
|
+
export function subprocessConnect(cmd: string[], options?: SubprocessConnectOptions): RpcClient {
|
|
623
603
|
const proc = Bun.spawn(cmd, {
|
|
624
604
|
stdin: "pipe",
|
|
625
605
|
stdout: "pipe",
|