@query-farm/vgi 0.6.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.
Files changed (206) hide show
  1. package/LICENSE +134 -0
  2. package/README.md +494 -0
  3. package/dist/__dbg.test-d.d.ts +1 -0
  4. package/dist/arguments/argument-spec.d.ts +51 -0
  5. package/dist/arguments/arguments.d.ts +13 -0
  6. package/dist/arrow/codec/branded.d.ts +83 -0
  7. package/dist/arrow/codec/registry.d.ts +29 -0
  8. package/dist/arrow/codec/repr.d.ts +23 -0
  9. package/dist/arrow/codec/type-descriptors.d.ts +109 -0
  10. package/dist/arrow/impl-arrowjs/build.d.ts +19 -0
  11. package/dist/arrow/impl-arrowjs/canonical.d.ts +15 -0
  12. package/dist/arrow/impl-arrowjs/empty.d.ts +7 -0
  13. package/dist/arrow/impl-arrowjs/filter.d.ts +11 -0
  14. package/dist/arrow/impl-arrowjs/index.d.ts +11 -0
  15. package/dist/arrow/impl-arrowjs/ipc.d.ts +24 -0
  16. package/dist/arrow/impl-arrowjs/iterate.d.ts +39 -0
  17. package/dist/arrow/impl-arrowjs/project.d.ts +10 -0
  18. package/dist/arrow/impl-arrowjs/schema.d.ts +62 -0
  19. package/dist/arrow/impl-arrowjs/statistics.d.ts +13 -0
  20. package/dist/arrow/impl-flechette/build.d.ts +14 -0
  21. package/dist/arrow/impl-flechette/canonical.d.ts +18 -0
  22. package/dist/arrow/impl-flechette/empty.d.ts +9 -0
  23. package/dist/arrow/impl-flechette/filter.d.ts +10 -0
  24. package/dist/arrow/impl-flechette/index.d.ts +11 -0
  25. package/dist/arrow/impl-flechette/ipc.d.ts +33 -0
  26. package/dist/arrow/impl-flechette/iterate.d.ts +29 -0
  27. package/dist/arrow/impl-flechette/message-meta.d.ts +10 -0
  28. package/dist/arrow/impl-flechette/normalize-type.d.ts +11 -0
  29. package/dist/arrow/impl-flechette/project.d.ts +3 -0
  30. package/dist/arrow/impl-flechette/schema.d.ts +47 -0
  31. package/dist/arrow/impl-flechette/statistics.d.ts +13 -0
  32. package/dist/arrow/index.d.ts +11 -0
  33. package/dist/arrow/predicates.d.ts +47 -0
  34. package/dist/arrow/repr.test-d.d.ts +52 -0
  35. package/dist/arrow/schema-types.d.ts +71 -0
  36. package/dist/arrow/types.d.ts +57 -0
  37. package/dist/catalog/attach-option.d.ts +33 -0
  38. package/dist/catalog/attach-options.d.ts +30 -0
  39. package/dist/catalog/composite.d.ts +33 -0
  40. package/dist/catalog/descriptors.d.ts +154 -0
  41. package/dist/catalog/interface.d.ts +239 -0
  42. package/dist/catalog/read-only.d.ts +33 -0
  43. package/dist/client/client.d.ts +189 -0
  44. package/dist/client/errors.d.ts +26 -0
  45. package/dist/client/helpers.d.ts +12 -0
  46. package/dist/client/protocol.d.ts +16 -0
  47. package/dist/client/types.d.ts +125 -0
  48. package/dist/client-entry.d.ts +11 -0
  49. package/dist/client-entry.js +48 -0
  50. package/dist/client-entry.js.map +9 -0
  51. package/dist/codec/asd.d.ts +25 -0
  52. package/dist/crypto.d.ts +36 -0
  53. package/dist/errors.d.ts +24 -0
  54. package/dist/filter-pushdown/collector.d.ts +32 -0
  55. package/dist/filter-pushdown/deserialize.d.ts +16 -0
  56. package/dist/filter-pushdown/evaluate.d.ts +51 -0
  57. package/dist/filter-pushdown/index.d.ts +4 -0
  58. package/dist/filter-pushdown/types.d.ts +84 -0
  59. package/dist/functions/aggregate.d.ts +129 -0
  60. package/dist/functions/copy-from.d.ts +81 -0
  61. package/dist/functions/copy-to.d.ts +121 -0
  62. package/dist/functions/registry.d.ts +16 -0
  63. package/dist/functions/scalar.d.ts +98 -0
  64. package/dist/functions/storage-cf-do.d.ts +47 -0
  65. package/dist/functions/storage.d.ts +86 -0
  66. package/dist/functions/table-buffering.d.ts +99 -0
  67. package/dist/functions/table-in-out.d.ts +64 -0
  68. package/dist/functions/table.d.ts +118 -0
  69. package/dist/functions/types.d.ts +157 -0
  70. package/dist/generated/vgi-client.d.ts +466 -0
  71. package/dist/generated/vgi-protocol-schemas.d.ts +115 -0
  72. package/dist/index.core.d.ts +42 -0
  73. package/dist/index.d.ts +2 -0
  74. package/dist/index.js +10888 -0
  75. package/dist/index.js.map +85 -0
  76. package/dist/metadata/resolve.d.ts +3 -0
  77. package/dist/metadata/serialize.d.ts +12 -0
  78. package/dist/metadata/types.d.ts +47 -0
  79. package/dist/protocol/dispatch.d.ts +23 -0
  80. package/dist/protocol/handlers/aggregate.d.ts +3 -0
  81. package/dist/protocol/handlers/catalog/admin.d.ts +3 -0
  82. package/dist/protocol/handlers/catalog/index.d.ts +3 -0
  83. package/dist/protocol/handlers/catalog/index_methods.d.ts +3 -0
  84. package/dist/protocol/handlers/catalog/macro.d.ts +3 -0
  85. package/dist/protocol/handlers/catalog/shared.d.ts +70 -0
  86. package/dist/protocol/handlers/catalog/table.d.ts +3 -0
  87. package/dist/protocol/handlers/catalog/view.d.ts +3 -0
  88. package/dist/protocol/handlers/function.d.ts +8 -0
  89. package/dist/protocol/handlers/shared.d.ts +31 -0
  90. package/dist/protocol/handlers/table-buffering.d.ts +3 -0
  91. package/dist/protocol/serialize.d.ts +4 -0
  92. package/dist/protocol/serializers/arguments.d.ts +3 -0
  93. package/dist/protocol/serializers/bind.d.ts +9 -0
  94. package/dist/protocol/serializers/cardinality.d.ts +7 -0
  95. package/dist/protocol/serializers/init.d.ts +9 -0
  96. package/dist/protocol/serializers/shared.d.ts +12 -0
  97. package/dist/protocol/state-serializer.d.ts +23 -0
  98. package/dist/protocol/types.d.ts +129 -0
  99. package/dist/secrets/helpers.d.ts +15 -0
  100. package/dist/types.d.ts +52 -0
  101. package/dist/util/arrow/index.d.ts +1 -0
  102. package/dist/util/bytes.d.ts +2 -0
  103. package/dist/util/statistics.d.ts +7 -0
  104. package/dist/worker-cf-entry.d.ts +30 -0
  105. package/dist/worker-cf-entry.js +8767 -0
  106. package/dist/worker-cf-entry.js.map +74 -0
  107. package/dist/worker.d.ts +36 -0
  108. package/package.json +96 -0
  109. package/src/arguments/argument-spec.ts +200 -0
  110. package/src/arguments/arguments.ts +81 -0
  111. package/src/arrow/codec/branded.ts +206 -0
  112. package/src/arrow/codec/registry.ts +674 -0
  113. package/src/arrow/codec/repr.ts +181 -0
  114. package/src/arrow/codec/type-descriptors.ts +137 -0
  115. package/src/arrow/impl-arrowjs/build.ts +88 -0
  116. package/src/arrow/impl-arrowjs/canonical.ts +509 -0
  117. package/src/arrow/impl-arrowjs/empty.ts +72 -0
  118. package/src/arrow/impl-arrowjs/filter.ts +53 -0
  119. package/src/arrow/impl-arrowjs/index.ts +54 -0
  120. package/src/arrow/impl-arrowjs/ipc.ts +67 -0
  121. package/src/arrow/impl-arrowjs/iterate.ts +159 -0
  122. package/src/arrow/impl-arrowjs/project.ts +73 -0
  123. package/src/arrow/impl-arrowjs/schema.ts +256 -0
  124. package/src/arrow/impl-arrowjs/statistics.ts +185 -0
  125. package/src/arrow/impl-flechette/build.ts +65 -0
  126. package/src/arrow/impl-flechette/canonical.ts +289 -0
  127. package/src/arrow/impl-flechette/empty.ts +20 -0
  128. package/src/arrow/impl-flechette/filter.ts +42 -0
  129. package/src/arrow/impl-flechette/index.ts +54 -0
  130. package/src/arrow/impl-flechette/ipc.ts +110 -0
  131. package/src/arrow/impl-flechette/iterate.ts +121 -0
  132. package/src/arrow/impl-flechette/message-meta.ts +175 -0
  133. package/src/arrow/impl-flechette/normalize-type.ts +99 -0
  134. package/src/arrow/impl-flechette/project.ts +64 -0
  135. package/src/arrow/impl-flechette/schema.ts +202 -0
  136. package/src/arrow/impl-flechette/statistics.ts +198 -0
  137. package/src/arrow/index.ts +129 -0
  138. package/src/arrow/predicates.ts +66 -0
  139. package/src/arrow/repr.test-d.ts +189 -0
  140. package/src/arrow/schema-types.ts +213 -0
  141. package/src/arrow/types.ts +74 -0
  142. package/src/catalog/attach-option.ts +107 -0
  143. package/src/catalog/attach-options.ts +79 -0
  144. package/src/catalog/composite.ts +180 -0
  145. package/src/catalog/descriptors.ts +164 -0
  146. package/src/catalog/interface.ts +721 -0
  147. package/src/catalog/read-only.ts +909 -0
  148. package/src/client/client.ts +1348 -0
  149. package/src/client/errors.ts +69 -0
  150. package/src/client/helpers.ts +56 -0
  151. package/src/client/protocol.ts +33 -0
  152. package/src/client/types.ts +140 -0
  153. package/src/client-entry.ts +112 -0
  154. package/src/codec/asd.ts +147 -0
  155. package/src/crypto.ts +143 -0
  156. package/src/errors.ts +61 -0
  157. package/src/filter-pushdown/collector.ts +147 -0
  158. package/src/filter-pushdown/deserialize.ts +253 -0
  159. package/src/filter-pushdown/evaluate.ts +591 -0
  160. package/src/filter-pushdown/index.ts +28 -0
  161. package/src/filter-pushdown/types.ts +91 -0
  162. package/src/functions/aggregate.ts +384 -0
  163. package/src/functions/copy-from.ts +282 -0
  164. package/src/functions/copy-to.ts +319 -0
  165. package/src/functions/registry.ts +258 -0
  166. package/src/functions/scalar.ts +356 -0
  167. package/src/functions/storage-cf-do.ts +303 -0
  168. package/src/functions/storage.ts +521 -0
  169. package/src/functions/table-buffering.ts +562 -0
  170. package/src/functions/table-in-out.ts +373 -0
  171. package/src/functions/table.ts +521 -0
  172. package/src/functions/types.ts +192 -0
  173. package/src/generated/vgi-client.ts +560 -0
  174. package/src/generated/vgi-protocol-schemas.ts +864 -0
  175. package/src/index.core.ts +267 -0
  176. package/src/index.ts +11 -0
  177. package/src/metadata/resolve.ts +109 -0
  178. package/src/metadata/serialize.ts +242 -0
  179. package/src/metadata/types.ts +60 -0
  180. package/src/protocol/dispatch.ts +52 -0
  181. package/src/protocol/handlers/aggregate.ts +355 -0
  182. package/src/protocol/handlers/catalog/admin.ts +368 -0
  183. package/src/protocol/handlers/catalog/index.ts +25 -0
  184. package/src/protocol/handlers/catalog/index_methods.ts +65 -0
  185. package/src/protocol/handlers/catalog/macro.ts +114 -0
  186. package/src/protocol/handlers/catalog/shared.ts +291 -0
  187. package/src/protocol/handlers/catalog/table.ts +401 -0
  188. package/src/protocol/handlers/catalog/view.ts +119 -0
  189. package/src/protocol/handlers/function.ts +302 -0
  190. package/src/protocol/handlers/shared.ts +80 -0
  191. package/src/protocol/handlers/table-buffering.ts +207 -0
  192. package/src/protocol/serialize.ts +23 -0
  193. package/src/protocol/serializers/arguments.ts +160 -0
  194. package/src/protocol/serializers/bind.ts +212 -0
  195. package/src/protocol/serializers/cardinality.ts +45 -0
  196. package/src/protocol/serializers/init.ts +247 -0
  197. package/src/protocol/serializers/shared.ts +46 -0
  198. package/src/protocol/state-serializer.ts +181 -0
  199. package/src/protocol/types.ts +153 -0
  200. package/src/secrets/helpers.ts +70 -0
  201. package/src/types.ts +71 -0
  202. package/src/util/arrow/index.ts +23 -0
  203. package/src/util/bytes.ts +14 -0
  204. package/src/util/statistics.ts +40 -0
  205. package/src/worker-cf-entry.ts +172 -0
  206. package/src/worker.ts +212 -0
@@ -0,0 +1,13 @@
1
+ import type { VgiSchema } from "../arrow/index.js";
2
+ export declare class Arguments {
3
+ readonly positional: (any | null)[];
4
+ readonly named: Map<string, any | null>;
5
+ /** Schema of the arguments batch (preserves original Arrow types). */
6
+ readonly argumentsSchema: VgiSchema | null;
7
+ constructor(positional?: (any | null)[], named?: Map<string, any | null>, argumentsSchema?: VgiSchema | null);
8
+ /**
9
+ * Get an argument by position (number) or name (string).
10
+ */
11
+ get(position: number | string, defaultValue?: any): any;
12
+ get length(): number;
13
+ }
@@ -0,0 +1,83 @@
1
+ import { TimeUnit } from "../schema-types.js";
2
+ declare const __brand: unique symbol;
3
+ /** A nominal brand over a base primitive. `Branded<number, 'date32'>` is a
4
+ * `number` at runtime but a distinct type at compile time. */
5
+ export type Branded<Base, Tag extends string> = Base & {
6
+ readonly [__brand]: Tag;
7
+ };
8
+ /** date32 raw: days since the Unix epoch. */
9
+ export type Date32 = Branded<number, "date32">;
10
+ /** date64 raw: milliseconds since the Unix epoch. */
11
+ export type Date64Ms = Branded<bigint, "date64ms">;
12
+ /** time32[s] raw: seconds since midnight. */
13
+ export type Time32S = Branded<number, "time32s">;
14
+ /** time32[ms] raw: milliseconds since midnight. */
15
+ export type Time32Ms = Branded<number, "time32ms">;
16
+ /** time64[us] raw: microseconds since midnight. */
17
+ export type Time64Us = Branded<bigint, "time64us">;
18
+ /** time64[ns] raw: nanoseconds since midnight. */
19
+ export type Time64Ns = Branded<bigint, "time64ns">;
20
+ /** timestamp[s] raw. */
21
+ export type TimestampSeconds = Branded<bigint, "ts_s">;
22
+ /** timestamp[ms] raw. */
23
+ export type TimestampMillis = Branded<bigint, "ts_ms">;
24
+ /** timestamp[us] raw. */
25
+ export type TimestampMicros = Branded<bigint, "ts_us">;
26
+ /** timestamp[ns] raw. */
27
+ export type TimestampNanos = Branded<bigint, "ts_ns">;
28
+ /** duration[s] raw. */
29
+ export type DurationSeconds = Branded<bigint, "dur_s">;
30
+ /** duration[ms] raw. */
31
+ export type DurationMillis = Branded<bigint, "dur_ms">;
32
+ /** duration[us] raw. */
33
+ export type DurationMicros = Branded<bigint, "dur_us">;
34
+ /** duration[ns] raw. */
35
+ export type DurationNanos = Branded<bigint, "dur_ns">;
36
+ /** A decimal's UNSCALED integer (the on-wire representation). */
37
+ export type UnscaledDecimal = Branded<bigint, "decimal_unscaled">;
38
+ /** int64 raw. (Rich int64 is already a plain bigint; the brand makes the
39
+ * declared width explicit in raw mode.) */
40
+ export type Int64 = Branded<bigint, "int64">;
41
+ /** uint64 raw. */
42
+ export type Uint64 = Branded<bigint, "uint64">;
43
+ /** date32 days: validated as a 32-bit integer day-number, then branded. */
44
+ export declare function asDate32(days: number): Date32;
45
+ /** date64 ms: validated as a 64-bit integer, then branded. */
46
+ export declare function asDate64Ms(ms: bigint): Date64Ms;
47
+ /** time32[s]. */
48
+ export declare const asTime32S: (n: number) => Time32S;
49
+ /** time32[ms]. */
50
+ export declare const asTime32Ms: (n: number) => Time32Ms;
51
+ /** time64[us]. */
52
+ export declare const asTime64Us: (b: bigint) => Time64Us;
53
+ /** time64[ns]. */
54
+ export declare const asTime64Ns: (b: bigint) => Time64Ns;
55
+ /** timestamp[s]. */
56
+ export declare const asTimestampSeconds: (b: bigint) => TimestampSeconds;
57
+ /** timestamp[ms]. */
58
+ export declare const asTimestampMillis: (b: bigint) => TimestampMillis;
59
+ /** timestamp[us]. */
60
+ export declare const asTimestampMicros: (b: bigint) => TimestampMicros;
61
+ /** timestamp[ns]. */
62
+ export declare const asTimestampNanos: (b: bigint) => TimestampNanos;
63
+ /** duration[s]. */
64
+ export declare const asDurationSeconds: (b: bigint) => DurationSeconds;
65
+ /** duration[ms]. */
66
+ export declare const asDurationMillis: (b: bigint) => DurationMillis;
67
+ /** duration[us]. */
68
+ export declare const asDurationMicros: (b: bigint) => DurationMicros;
69
+ /** duration[ns]. */
70
+ export declare const asDurationNanos: (b: bigint) => DurationNanos;
71
+ /** A decimal's unscaled integer (validated as a bigint, then branded). */
72
+ export declare function asUnscaledDecimal(unscaled: bigint): UnscaledDecimal;
73
+ /** int64 (validated for signed 64-bit range). */
74
+ export declare const asInt64: (b: bigint) => Int64;
75
+ /** uint64 (validated for unsigned 64-bit range). */
76
+ export declare const asUint64: (b: bigint) => Uint64;
77
+ /** Strip a numeric brand, returning the plain `number`. */
78
+ export declare function fromBrandedNumber(v: Branded<number, string>): number;
79
+ /** Strip a bigint brand, returning the plain `bigint`. */
80
+ export declare function fromBrandedBigInt(v: Branded<bigint, string>): bigint;
81
+ /** Generic unbrand for either base type. */
82
+ export declare function fromBranded<Base, Tag extends string>(v: Branded<Base, Tag>): Base;
83
+ export { TimeUnit };
@@ -0,0 +1,29 @@
1
+ import type { VgiDataType } from "../types.js";
2
+ /** Codec for a single Arrow type. Converts between the author-facing rich
3
+ * representation and the internal canonical pivot. Both directions validate
4
+ * and throw on invalid/lossy input. null/undefined pass through as null.
5
+ *
6
+ * (Raw<->canonical conversions are reserved for a later phase. When added they
7
+ * belong here as `rawToCanonical` / `canonicalToRaw`.) */
8
+ export interface Codec {
9
+ /** Human-readable type label, used in error messages. */
10
+ readonly label: string;
11
+ /** rich author value -> canonical pivot. */
12
+ richToCanonical(value: unknown): unknown;
13
+ /** canonical pivot -> rich author value. */
14
+ canonicalToRich(value: unknown): unknown;
15
+ /** branded raw author value -> canonical pivot. Largely identity on the
16
+ * underlying number/bigint (raw === canonical for every type), but validates
17
+ * and unbrands. Date32/Date64 raw values are plain day-number / ms-bigint,
18
+ * so this differs from richToCanonical only in NOT accepting a JS Date. */
19
+ rawToCanonical(value: unknown): unknown;
20
+ /** canonical pivot -> branded raw author value. Validates and brands
21
+ * (identity at runtime). */
22
+ canonicalToRaw(value: unknown): unknown;
23
+ }
24
+ /**
25
+ * Resolve the {@link Codec} for an Arrow type. Dispatches by `typeId` and
26
+ * reads unit / bitWidth / scale off the type. Composite types recurse into
27
+ * their child codecs.
28
+ */
29
+ export declare function codecFor(type: VgiDataType): Codec;
@@ -0,0 +1,23 @@
1
+ import type { VgiDataType } from "../types.js";
2
+ import type { TypedField, BoolType, IntType, FloatType, Utf8Type, LargeUtf8Type, BinaryType, LargeBinaryType, FixedSizeBinaryType, DecimalType, Date32Type, Date64Type, Time32Type, Time64Type, TimestampType, DurationType, ListType, FixedSizeListType, StructType, MapType, DictionaryType, NullDescriptor, TUnit } from "./type-descriptors.js";
3
+ import type { Date32, Date64Ms, Time32S, Time32Ms, Time64Us, Time64Ns, TimestampSeconds, TimestampMillis, TimestampMicros, TimestampNanos, DurationSeconds, DurationMillis, DurationMicros, DurationNanos, UnscaledDecimal, Int64, Uint64 } from "./branded.js";
4
+ export type { TypedField };
5
+ /** Representation mode selector. */
6
+ export type Repr = "rich" | "raw";
7
+ type RawTimestamp<U extends TUnit> = U extends "s" ? TimestampSeconds : U extends "ms" ? TimestampMillis : U extends "us" ? TimestampMicros : U extends "ns" ? TimestampNanos : bigint;
8
+ type RawDuration<U extends TUnit> = U extends "s" ? DurationSeconds : U extends "ms" ? DurationMillis : U extends "us" ? DurationMicros : U extends "ns" ? DurationNanos : bigint;
9
+ type RawTime32<U extends "s" | "ms"> = U extends "s" ? Time32S : Time32Ms;
10
+ type RawTime64<U extends "us" | "ns"> = U extends "us" ? Time64Us : Time64Ns;
11
+ type RawInt64<Signed extends boolean | undefined> = Signed extends true ? Int64 : Signed extends false ? Uint64 : bigint;
12
+ /** The default author-facing JS value for the Arrow type `T`. */
13
+ export type RichValue<T extends VgiDataType> = T extends NullDescriptor ? null : T extends BoolType ? boolean : T extends IntType<64, infer _S> ? bigint : T extends IntType<8 | 16 | 32, infer _S> ? number : T extends FloatType ? number : T extends Utf8Type ? string : T extends LargeUtf8Type ? string : T extends BinaryType ? Uint8Array : T extends LargeBinaryType ? Uint8Array : T extends FixedSizeBinaryType ? Uint8Array : T extends DecimalType ? bigint : T extends Date32Type ? Date : T extends Date64Type ? Date : T extends Time32Type<"s" | "ms"> ? number : T extends Time64Type<"us" | "ns"> ? bigint : T extends TimestampType<TUnit> ? bigint : T extends DurationType<TUnit> ? bigint : T extends StructType<infer C> ? RichStruct<C> : T extends ListType<infer E> ? Array<RichValue<E> | null> : T extends FixedSizeListType<infer E> ? Array<RichValue<E> | null> : T extends MapType<infer K, infer V> ? Array<[RichValue<K>, RichValue<V> | null]> : T extends DictionaryType<infer V> ? RichValue<V> : unknown;
14
+ type RichStruct<C extends readonly TypedField<string, VgiDataType>[]> = {
15
+ [F in C[number] as F["name"]]: RichValue<F["type"]> | null;
16
+ };
17
+ /** The branded `raw` JS value for the Arrow type `T`. */
18
+ export type RawValue<T extends VgiDataType> = T extends NullDescriptor ? null : T extends BoolType ? boolean : T extends IntType<64, infer S> ? RawInt64<S> : T extends IntType<8 | 16 | 32, infer _S> ? number : T extends FloatType ? number : T extends Utf8Type ? string : T extends LargeUtf8Type ? string : T extends BinaryType ? Uint8Array : T extends LargeBinaryType ? Uint8Array : T extends FixedSizeBinaryType ? Uint8Array : T extends DecimalType ? UnscaledDecimal : T extends Date32Type ? Date32 : T extends Date64Type ? Date64Ms : T extends Time32Type<infer U> ? RawTime32<U> : T extends Time64Type<infer U> ? RawTime64<U> : T extends TimestampType<infer U> ? RawTimestamp<U> : T extends DurationType<infer U> ? RawDuration<U> : T extends StructType<infer C> ? RawStruct<C> : T extends ListType<infer E> ? Array<RawValue<E> | null> : T extends FixedSizeListType<infer E> ? Array<RawValue<E> | null> : T extends MapType<infer K, infer V> ? Array<[RawValue<K>, RawValue<V> | null]> : T extends DictionaryType<infer V> ? RawValue<V> : unknown;
19
+ type RawStruct<C extends readonly TypedField<string, VgiDataType>[]> = {
20
+ [F in C[number] as F["name"]]: RawValue<F["type"]> | null;
21
+ };
22
+ /** The JS value for the Arrow type `T` under representation mode `M`. */
23
+ export type ValueFor<T extends VgiDataType, M extends Repr> = M extends "raw" ? RawValue<T> : RichValue<T>;
@@ -0,0 +1,109 @@
1
+ import type { VgiDataType, VgiField } from "../types.js";
2
+ import { TypeId } from "../predicates.js";
3
+ /** Time/timestamp/duration unit tag (matches the facade `TimeUnit` integers,
4
+ * but expressed as a string literal so it can flow through the type level). */
5
+ export type TUnit = "s" | "ms" | "us" | "ns";
6
+ export interface NullDescriptor extends VgiDataType {
7
+ readonly typeId: typeof TypeId.Null;
8
+ }
9
+ export interface BoolType extends VgiDataType {
10
+ readonly typeId: typeof TypeId.Bool;
11
+ }
12
+ export interface IntType<BW extends 8 | 16 | 32 | 64, Signed extends boolean> extends VgiDataType {
13
+ readonly typeId: typeof TypeId.Int;
14
+ readonly __bitWidth: BW;
15
+ readonly __signed: Signed;
16
+ }
17
+ export type Int8Type = IntType<8, true>;
18
+ export type Int16Type = IntType<16, true>;
19
+ export type Int32Type = IntType<32, true>;
20
+ export type Int64Type = IntType<64, true>;
21
+ export type Uint8Type = IntType<8, false>;
22
+ export type Uint16Type = IntType<16, false>;
23
+ export type Uint32Type = IntType<32, false>;
24
+ export type Uint64Type = IntType<64, false>;
25
+ export interface FloatType extends VgiDataType {
26
+ readonly typeId: typeof TypeId.Float;
27
+ }
28
+ export interface Utf8Type extends VgiDataType {
29
+ readonly typeId: typeof TypeId.Utf8;
30
+ }
31
+ export interface LargeUtf8Type extends VgiDataType {
32
+ readonly typeId: typeof TypeId.LargeUtf8;
33
+ }
34
+ export interface BinaryType extends VgiDataType {
35
+ readonly typeId: typeof TypeId.Binary;
36
+ }
37
+ export interface LargeBinaryType extends VgiDataType {
38
+ readonly typeId: typeof TypeId.LargeBinary;
39
+ }
40
+ export interface FixedSizeBinaryType extends VgiDataType {
41
+ readonly typeId: typeof TypeId.FixedSizeBinary;
42
+ }
43
+ export interface DecimalType extends VgiDataType {
44
+ readonly typeId: typeof TypeId.Decimal;
45
+ }
46
+ /** date32 (unit DAY) — days. */
47
+ export interface Date32Type extends VgiDataType {
48
+ readonly typeId: typeof TypeId.Date;
49
+ readonly __dateUnit: "day";
50
+ }
51
+ /** date64 (unit MILLISECOND) — ms. */
52
+ export interface Date64Type extends VgiDataType {
53
+ readonly typeId: typeof TypeId.Date;
54
+ readonly __dateUnit: "ms";
55
+ }
56
+ /** time32 (bitWidth 32; unit s or ms). */
57
+ export interface Time32Type<U extends "s" | "ms"> extends VgiDataType {
58
+ readonly typeId: typeof TypeId.Time;
59
+ readonly __timeBits: 32;
60
+ readonly __unit: U;
61
+ }
62
+ /** time64 (bitWidth 64; unit us or ns). */
63
+ export interface Time64Type<U extends "us" | "ns"> extends VgiDataType {
64
+ readonly typeId: typeof TypeId.Time;
65
+ readonly __timeBits: 64;
66
+ readonly __unit: U;
67
+ }
68
+ export interface TimestampType<U extends TUnit> extends VgiDataType {
69
+ readonly typeId: typeof TypeId.Timestamp;
70
+ readonly __tsUnit: U;
71
+ }
72
+ export interface DurationType<U extends TUnit> extends VgiDataType {
73
+ readonly typeId: typeof TypeId.Duration;
74
+ readonly __durUnit: U;
75
+ }
76
+ export interface IntervalType extends VgiDataType {
77
+ readonly typeId: typeof TypeId.Interval;
78
+ }
79
+ /** A typed field carrying its child's precise descriptor in the static type. */
80
+ export interface TypedField<Name extends string, T extends VgiDataType> extends VgiField {
81
+ readonly name: Name;
82
+ readonly type: T;
83
+ }
84
+ export interface ListType<T extends VgiDataType> extends VgiDataType {
85
+ readonly typeId: typeof TypeId.List;
86
+ readonly __child?: T;
87
+ }
88
+ export interface FixedSizeListType<T extends VgiDataType> extends VgiDataType {
89
+ readonly typeId: typeof TypeId.FixedSizeList;
90
+ readonly __child?: T;
91
+ }
92
+ /** Struct descriptor carrying its children as a tuple of TypedFields so the
93
+ * value mapping can build a precise `{ name: value }` shape. */
94
+ export interface StructType<Children extends readonly TypedField<string, VgiDataType>[]> extends VgiDataType {
95
+ readonly typeId: typeof TypeId.Struct;
96
+ readonly __children?: Children;
97
+ }
98
+ export interface MapType<K extends VgiDataType, V extends VgiDataType> extends VgiDataType {
99
+ readonly typeId: typeof TypeId.Map;
100
+ readonly __key?: K;
101
+ readonly __value?: V;
102
+ }
103
+ export interface DictionaryType<V extends VgiDataType> extends VgiDataType {
104
+ readonly typeId: typeof TypeId.Dictionary;
105
+ readonly __dictValue?: V;
106
+ }
107
+ export interface UnionType extends VgiDataType {
108
+ readonly typeId: typeof TypeId.Union;
109
+ }
@@ -0,0 +1,19 @@
1
+ import { RecordBatch, Schema } from "@query-farm/apache-arrow";
2
+ import type { VgiSchema, VgiDataType, VgiColumnData } from "../types.js";
3
+ /**
4
+ * Build an opaque column-data handle from a JS array. arrow-js wraps
5
+ * `vectorFromArray` and exposes its first `Data` node. Unlike the public
6
+ * build path, this is a low-level pass-through used by callers that already
7
+ * hold backend-native values, so it does NOT run the codec.
8
+ */
9
+ export declare function columnFromArray(values: any[], type: VgiDataType): VgiColumnData;
10
+ /**
11
+ * Build a RecordBatch from row objects (values are RICH).
12
+ */
13
+ export declare function batchFromRows(rows: Record<string, any>[], schema: Schema | VgiSchema): RecordBatch;
14
+ /**
15
+ * Build a RecordBatch from column arrays (values are RICH). Each column is
16
+ * converted rich -> canonical via the codec, then canonical -> arrow-js column
17
+ * data via the canonical writer.
18
+ */
19
+ export declare function batchFromColumns(columns: Record<string, any[]>, schema: Schema | VgiSchema, repr?: "rich" | "raw"): RecordBatch;
@@ -0,0 +1,15 @@
1
+ import type { VgiDataType, VgiColumnData } from "../types.js";
2
+ /**
3
+ * Build an arrow-js column `Data` node from an array of CANONICAL values for
4
+ * `type`. Folds together what used to be scattered across build.ts
5
+ * (`buildColumnData`, `dateTimeBitWidth`, decimal/bigint/date special-casing).
6
+ */
7
+ export declare function writeCanonicalColumn(type: VgiDataType, canonical: unknown[]): VgiColumnData;
8
+ /**
9
+ * Read a single CANONICAL value at `index` from an arrow-js column (Vector).
10
+ * Reads the underlying typed-array storage for scalars (so it is lossless and
11
+ * never depends on Vector.get()'s lossy/divergent coercions — e.g. arrow-js
12
+ * Vector.get() returns a JS number for timestamp[us], losing precision), and
13
+ * recurses for composites.
14
+ */
15
+ export declare function readCanonicalValue(type: VgiDataType, column: unknown, index: number): unknown;
@@ -0,0 +1,7 @@
1
+ import { RecordBatch, Schema } from "@query-farm/apache-arrow";
2
+ import type { VgiSchema } from "../types.js";
3
+ /**
4
+ * Create an empty (0-row) batch with the given schema. Accepts arrow-js
5
+ * `Schema` or facade `VgiSchema` (cast at the boundary).
6
+ */
7
+ export declare function emptyBatch(schema: Schema | VgiSchema): RecordBatch;
@@ -0,0 +1,11 @@
1
+ import { RecordBatch } from "@query-farm/apache-arrow";
2
+ import type { VgiBatch } from "../types.js";
3
+ /**
4
+ * Filter a RecordBatch using a Uint8Array mask (0=exclude, nonzero=include).
5
+ * Returns a new batch containing only the rows where mask[i] is nonzero.
6
+ *
7
+ * Rows are read in canonical form then mapped back to RICH so the rebuild goes
8
+ * through the same codec/canonical path as every other column build — lossless
9
+ * and identical across backends (never the lossy/raw `Vector.get`).
10
+ */
11
+ export declare function filterBatch(batch: RecordBatch | VgiBatch, mask: Uint8Array): RecordBatch;
@@ -0,0 +1,11 @@
1
+ import type { VgiBackendInfo } from "../types.js";
2
+ export declare const backend: VgiBackendInfo;
3
+ export { schema, field, nullType, bool, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, utf8, binary, fixedSizeBinary, decimal, decimal128, decimal256, date, dateDay, dateMillisecond, time, timeSecond, timeMillisecond, timeMicrosecond, timeNanosecond, timestamp, duration, interval, list, fixedSizeList, struct, map, dictionary, union, sparseUnion, denseUnion, TimeUnit, DateUnit, IntervalUnit, UnionMode, } from "./schema.js";
4
+ export { emptyBatch } from "./empty.js";
5
+ export { batchFromRows, batchFromColumns, columnFromArray } from "./build.js";
6
+ export { iterRows, batchToScalarDict, batchToSecretDict, safeNumber, decodeDictValue, } from "./iterate.js";
7
+ export { filterBatch } from "./filter.js";
8
+ export { projectSchema, projectBatch } from "./project.js";
9
+ export { readCanonicalValue } from "./canonical.js";
10
+ export { serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, } from "./ipc.js";
11
+ export { buildStatisticsBatch, type ColumnStatistics } from "./statistics.js";
@@ -0,0 +1,24 @@
1
+ import { RecordBatch, Schema } from "@query-farm/apache-arrow";
2
+ import type { VgiSchema, VgiBatch } from "../types.js";
3
+ /**
4
+ * Serialize a Schema to Arrow IPC bytes. Accepts arrow-js `Schema` or
5
+ * facade `VgiSchema` (the latter is satisfied structurally by arrow-js
6
+ * Schema instances at runtime).
7
+ */
8
+ export declare function serializeSchema(schema: Schema | VgiSchema): Uint8Array;
9
+ /**
10
+ * Deserialize an Arrow Schema from IPC bytes.
11
+ * Note: In Bun, reader.schema is always undefined, so we must read from the batch.
12
+ *
13
+ * Returns arrow-js's `Schema` (which structurally satisfies VgiSchema).
14
+ */
15
+ export declare function deserializeSchema(bytes: Uint8Array): Schema;
16
+ /**
17
+ * Serialize a RecordBatch to Arrow IPC bytes. Accepts arrow-js `RecordBatch`
18
+ * or facade `VgiBatch`.
19
+ */
20
+ export declare function serializeBatch(batch: RecordBatch | VgiBatch): Uint8Array;
21
+ /**
22
+ * Deserialize a RecordBatch from Arrow IPC bytes.
23
+ */
24
+ export declare function deserializeBatch(bytes: Uint8Array): RecordBatch;
@@ -0,0 +1,39 @@
1
+ import { RecordBatch } from "@query-farm/apache-arrow";
2
+ import type { VgiBatch } from "../types.js";
3
+ /**
4
+ * Iterate rows of a RecordBatch as plain objects, in the RICH representation
5
+ * (Date for date32/date64; canonical otherwise). Reads via the per-backend
6
+ * canonical reader (lossless, backend-agnostic) then maps canonical -> rich
7
+ * through the codec — symmetric with the build path. Accepts arrow-js
8
+ * `RecordBatch` or facade `VgiBatch`.
9
+ */
10
+ export declare function iterRows(batch: RecordBatch | VgiBatch, repr?: "rich" | "raw"): Generator<Record<string, any>>;
11
+ /**
12
+ * Extract single-row batch to a scalar dict, in the RICH representation. Routes
13
+ * through the canonical reader + codec (same as iterRows) so a temporal/decimal
14
+ * setting is represented identically to column data and across backends, and so
15
+ * Dictionary-encoded columns (DuckDB sends these for enum-shaped fields like
16
+ * SchemaObjectType) are decoded — readCanonicalValue handles dictionary decode.
17
+ */
18
+ export declare function batchToScalarDict(batch: RecordBatch | VgiBatch | null): Record<string, any>;
19
+ /**
20
+ * If `value` looks like a Dictionary-encoded Arrow scalar (Vector.get on a
21
+ * dict column on the apache-arrow fork returns the underlying Data, not the
22
+ * decoded string), pull out the decoded value at row `index`. Returns
23
+ * `value` unchanged when it isn't dict-shaped.
24
+ *
25
+ * Used at handler call sites where the incoming `params` came from the RPC
26
+ * layer's row extractor (which doesn't auto-decode dictionaries) and the
27
+ * handler needs the plain string.
28
+ */
29
+ export declare function decodeDictValue(value: any, index?: number): any;
30
+ /**
31
+ * Extract single-row batch to a secret dict (column per secret, each value is a struct).
32
+ * Handles both named secrets (column name = secret type) and scoped secrets
33
+ * (column name = "secret_N" with secret_type in field metadata).
34
+ */
35
+ export declare function batchToSecretDict(batch: RecordBatch | VgiBatch | null): Record<string, Record<string, any>>;
36
+ /**
37
+ * Safe number coercion for BigInt values.
38
+ */
39
+ export declare function safeNumber(value: any): number;
@@ -0,0 +1,10 @@
1
+ import { RecordBatch, Schema } from "@query-farm/apache-arrow";
2
+ import type { VgiSchema, VgiBatch } from "../types.js";
3
+ /**
4
+ * Project a schema by column indices, preserving only selected fields.
5
+ */
6
+ export declare function projectSchema(projectionIds: number[] | null, schema: Schema | VgiSchema): Schema;
7
+ /**
8
+ * Project a RecordBatch by column indices.
9
+ */
10
+ export declare function projectBatch(projectionIds: number[] | null, batch: RecordBatch | VgiBatch): RecordBatch;
@@ -0,0 +1,62 @@
1
+ import { DateUnit as A_DateUnit, TimeUnit as A_TimeUnit, IntervalUnit as A_IntervalUnit, UnionMode as A_UnionMode } from "@query-farm/apache-arrow";
2
+ import type { VgiField, VgiSchema, VgiDataType } from "../types.js";
3
+ export declare const TimeUnit: {
4
+ readonly SECOND: A_TimeUnit.SECOND;
5
+ readonly MILLISECOND: A_TimeUnit.MILLISECOND;
6
+ readonly MICROSECOND: A_TimeUnit.MICROSECOND;
7
+ readonly NANOSECOND: A_TimeUnit.NANOSECOND;
8
+ };
9
+ export declare const DateUnit: {
10
+ readonly DAY: A_DateUnit.DAY;
11
+ readonly MILLISECOND: A_DateUnit.MILLISECOND;
12
+ };
13
+ export declare const IntervalUnit: {
14
+ readonly YEAR_MONTH: A_IntervalUnit.YEAR_MONTH;
15
+ readonly DAY_TIME: A_IntervalUnit.DAY_TIME;
16
+ readonly MONTH_DAY_NANO: A_IntervalUnit.MONTH_DAY_NANO;
17
+ };
18
+ export declare const UnionMode: {
19
+ readonly Sparse: A_UnionMode.Sparse;
20
+ readonly Dense: A_UnionMode.Dense;
21
+ };
22
+ export declare function schema(fields: readonly VgiField[], metadata?: Map<string, string>): VgiSchema;
23
+ export declare function field(name: string, type: VgiDataType, nullable?: boolean, metadata?: Map<string, string>): VgiField;
24
+ export declare const nullType: () => VgiDataType;
25
+ export declare const bool: () => VgiDataType;
26
+ export declare const int8: () => VgiDataType;
27
+ export declare const int16: () => VgiDataType;
28
+ export declare const int32: () => VgiDataType;
29
+ export declare const int64: () => VgiDataType;
30
+ export declare const uint8: () => VgiDataType;
31
+ export declare const uint16: () => VgiDataType;
32
+ export declare const uint32: () => VgiDataType;
33
+ export declare const uint64: () => VgiDataType;
34
+ export declare function int(bitWidth?: 8 | 16 | 32 | 64, signed?: boolean): VgiDataType;
35
+ export declare const float16: () => VgiDataType;
36
+ export declare const float32: () => VgiDataType;
37
+ export declare const float64: () => VgiDataType;
38
+ export declare const utf8: () => VgiDataType;
39
+ export declare const binary: () => VgiDataType;
40
+ export declare const fixedSizeBinary: (byteWidth: number) => VgiDataType;
41
+ export declare function decimal(precision: number, scale: number, bitWidth?: 32 | 64 | 128 | 256): VgiDataType;
42
+ export declare const decimal128: (precision: number, scale: number) => VgiDataType;
43
+ export declare const decimal256: (precision: number, scale: number) => VgiDataType;
44
+ export declare const date: (unit?: number) => VgiDataType;
45
+ export declare const dateDay: () => VgiDataType;
46
+ export declare const dateMillisecond: () => VgiDataType;
47
+ export declare function time(unit?: number, bitWidth?: 32 | 64): VgiDataType;
48
+ export declare const timeSecond: () => VgiDataType;
49
+ export declare const timeMillisecond: () => VgiDataType;
50
+ export declare const timeMicrosecond: () => VgiDataType;
51
+ export declare const timeNanosecond: () => VgiDataType;
52
+ export declare const timestamp: (unit?: number, timezone?: string | null) => VgiDataType;
53
+ export declare const duration: (unit?: number) => VgiDataType;
54
+ export declare const interval: (unit?: number) => VgiDataType;
55
+ export declare function list(child: VgiField | VgiDataType): VgiDataType;
56
+ export declare function fixedSizeList(child: VgiField | VgiDataType, listSize: number): VgiDataType;
57
+ export declare function struct(children: readonly VgiField[]): VgiDataType;
58
+ export declare function map(keyField: VgiField | VgiDataType, valueField: VgiField | VgiDataType, keysSorted?: boolean): VgiDataType;
59
+ export declare function dictionary(valueType: VgiDataType, indexType?: VgiDataType, ordered?: boolean, id?: number): VgiDataType;
60
+ export declare function union(mode: number, children: readonly (VgiField | VgiDataType)[], typeIds?: number[]): VgiDataType;
61
+ export declare const sparseUnion: (children: readonly (VgiField | VgiDataType)[], typeIds?: number[]) => VgiDataType;
62
+ export declare const denseUnion: (children: readonly (VgiField | VgiDataType)[], typeIds?: number[]) => VgiDataType;
@@ -0,0 +1,13 @@
1
+ import type { VgiBatch, VgiDataType } from "../types.js";
2
+ export interface ColumnStatistics {
3
+ columnName: string;
4
+ arrowType: VgiDataType;
5
+ min: any;
6
+ max: any;
7
+ hasNull: boolean;
8
+ hasNotNull: boolean;
9
+ distinctCount: bigint | number | null;
10
+ containsUnicode: boolean | null;
11
+ maxStringLength: bigint | number | null;
12
+ }
13
+ export declare function buildStatisticsBatch(stats: ColumnStatistics[]): VgiBatch;
@@ -0,0 +1,14 @@
1
+ import type { VgiSchema, VgiBatch, VgiDataType, VgiColumnData } from "../types.js";
2
+ /**
3
+ * Build an opaque column-data handle from a JS array. Low-level pass-through
4
+ * for callers that already hold backend-native values; does NOT run the codec.
5
+ */
6
+ export declare function columnFromArray(values: any[], type: VgiDataType): VgiColumnData;
7
+ /** Build a batch from row objects (values are RICH). */
8
+ export declare function batchFromRows(rows: Record<string, any>[], schema: VgiSchema): VgiBatch;
9
+ /**
10
+ * Build a batch from column arrays (values are RICH). Each column is converted
11
+ * rich -> canonical via the codec, then the canonical batch writer assembles
12
+ * the flechette Table (preserving per-field nullable + metadata).
13
+ */
14
+ export declare function batchFromColumns(columns: Record<string, any[]>, schema: VgiSchema, repr?: "rich" | "raw"): VgiBatch;
@@ -0,0 +1,18 @@
1
+ import type { VgiSchema, VgiBatch, VgiDataType, VgiColumnData } from "../types.js";
2
+ /** Build a flechette `Column` from an array of CANONICAL values for `type`. */
3
+ export declare function writeCanonicalColumn(type: VgiDataType, canonical: unknown[]): VgiColumnData;
4
+ /**
5
+ * Build a whole batch (Table) from canonical column arrays. Kept here so the
6
+ * per-field `nullable` flag and metadata are preserved on the output schema
7
+ * (tableFromColumns would drop them, which the C++ extension rejects).
8
+ */
9
+ export declare function writeCanonicalBatch(columns: Record<string, unknown[]>, schema: VgiSchema, numRows: number): VgiBatch;
10
+ /**
11
+ * Convert canonical values into the shape flechette's columnFromArray needs.
12
+ * Date columns: canonical day-number / ms-bigint -> JS Date. Map columns:
13
+ * canonical Array<[k,v]> -> Map. Struct/List recurse. Everything else passes
14
+ * through.
15
+ */
16
+ export declare function prepareForFlechette(type: VgiDataType, values: unknown[]): unknown[];
17
+ /** Read a single CANONICAL value at `index` from a flechette Column. */
18
+ export declare function readCanonicalValue(type: VgiDataType, column: unknown, index: number): unknown;
@@ -0,0 +1,9 @@
1
+ import type { VgiSchema, VgiBatch } from "../types.js";
2
+ /**
3
+ * Create an empty (0-row) batch with the given schema.
4
+ *
5
+ * For each field we build a 0-length column of the matching type. flechette
6
+ * handles complex types (List, Map, Struct, Decimal) without the manual
7
+ * makeData scaffolding the arrow-js backend needs.
8
+ */
9
+ export declare function emptyBatch(schema: VgiSchema): VgiBatch;
@@ -0,0 +1,10 @@
1
+ import type { VgiBatch } from "../types.js";
2
+ /**
3
+ * Filter a batch using a Uint8Array mask (0=exclude, nonzero=include).
4
+ *
5
+ * Rows are read in canonical form then mapped back to RICH so the rebuild goes
6
+ * through the same codec/canonical path as every other column build — lossless,
7
+ * Date-correct (flechette `.at()` returns epoch-ms for dates), and identical to
8
+ * the arrow-js backend.
9
+ */
10
+ export declare function filterBatch(batch: VgiBatch, mask: Uint8Array): VgiBatch;
@@ -0,0 +1,11 @@
1
+ import type { VgiBackendInfo } from "../types.js";
2
+ export declare const backend: VgiBackendInfo;
3
+ export { schema, field, nullType, bool, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, utf8, binary, fixedSizeBinary, decimal, decimal128, decimal256, date, dateDay, dateMillisecond, time, timeSecond, timeMillisecond, timeMicrosecond, timeNanosecond, timestamp, duration, interval, list, fixedSizeList, struct, map, dictionary, union, sparseUnion, denseUnion, TimeUnit, DateUnit, IntervalUnit, UnionMode, } from "./schema.js";
4
+ export { emptyBatch } from "./empty.js";
5
+ export { batchFromRows, batchFromColumns, columnFromArray } from "./build.js";
6
+ export { iterRows, batchToScalarDict, batchToSecretDict, safeNumber, decodeDictValue, } from "./iterate.js";
7
+ export { filterBatch } from "./filter.js";
8
+ export { projectSchema, projectBatch } from "./project.js";
9
+ export { readCanonicalValue } from "./canonical.js";
10
+ export { serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, } from "./ipc.js";
11
+ export { buildStatisticsBatch, type ColumnStatistics } from "./statistics.js";
@@ -0,0 +1,33 @@
1
+ import type { VgiSchema, VgiBatch } from "../types.js";
2
+ /**
3
+ * Serialize a Schema to Arrow IPC bytes.
4
+ *
5
+ * flechette has no schema-only serialization helper, so we encode an empty
6
+ * 0-row table that carries just the schema header. Decoders see the Schema
7
+ * + an immediate EOS marker — same wire shape arrow-js's
8
+ * `RecordBatchStreamWriter.close()` produces for an empty stream.
9
+ */
10
+ export declare function serializeSchema(schema: VgiSchema): Uint8Array;
11
+ /**
12
+ * Deserialize an Arrow Schema from IPC bytes. Returns the schema of the
13
+ * decoded table (which may be 0-row if the source was a schema-only stream).
14
+ */
15
+ export declare function deserializeSchema(bytes: Uint8Array): VgiSchema;
16
+ /**
17
+ * Serialize a RecordBatch to Arrow IPC bytes (stream format).
18
+ *
19
+ * The batch passed in is structurally a flechette Table (1 record batch's
20
+ * worth of data). flechette's `tableToIPC` round-trips it as a complete
21
+ * stream — schema + one batch + EOS — which is what subprocess transport
22
+ * consumers expect per call.
23
+ */
24
+ export declare function serializeBatch(batch: VgiBatch): Uint8Array;
25
+ /**
26
+ * Deserialize a RecordBatch from Arrow IPC bytes.
27
+ *
28
+ * We treat the decoded Table as the "batch" — flechette Tables expose
29
+ * numRows / schema / getChild that satisfy VgiBatch's shape. For
30
+ * multi-batch streams this collapses to a single logical batch, matching
31
+ * the subprocess transport's one-batch-per-call convention.
32
+ */
33
+ export declare function deserializeBatch(bytes: Uint8Array): VgiBatch;
@@ -0,0 +1,29 @@
1
+ import type { VgiBatch } from "../types.js";
2
+ /**
3
+ * Iterate rows of a batch (flechette Table) as plain objects, in the RICH
4
+ * representation (Date for date32/date64; canonical otherwise). Reads via the
5
+ * per-backend canonical reader then maps canonical -> rich through the codec —
6
+ * symmetric with the build path and identical to the arrow-js backend.
7
+ */
8
+ export declare function iterRows(batch: VgiBatch, repr?: "rich" | "raw"): Generator<Record<string, any>>;
9
+ /**
10
+ * Extract a single-row batch as a flat dict { col: value }, in the RICH
11
+ * representation. Routes through the canonical reader + codec (same as iterRows)
12
+ * so a temporal/decimal setting is represented identically to column data and
13
+ * identically to the arrow-js backend.
14
+ */
15
+ export declare function batchToScalarDict(batch: VgiBatch | null): Record<string, any>;
16
+ /**
17
+ * No-op for flechette: dictionary columns auto-decode at extraction time.
18
+ * Provided for parity with impl-arrowjs (where the apache-arrow fork doesn't
19
+ * auto-decode in some paths).
20
+ */
21
+ export declare function decodeDictValue(value: any, _index?: number): any;
22
+ /**
23
+ * Single-row batch → secret dict. Mirrors impl-arrowjs's same-named function.
24
+ */
25
+ export declare function batchToSecretDict(batch: VgiBatch | null): Record<string, Record<string, any>>;
26
+ /**
27
+ * BigInt → number coercion (lossy for values past 2^53).
28
+ */
29
+ export declare function safeNumber(value: any): number;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Walk an Arrow IPC stream and return the first RecordBatch message's
3
+ * (numRows, metadata) — the bits flechette drops on the floor.
4
+ *
5
+ * Returns null if the stream contains no RecordBatch.
6
+ */
7
+ export declare function readFirstRecordBatchMeta(stream: Uint8Array): {
8
+ numRows: number;
9
+ metadata: Map<string, string>;
10
+ } | null;