@query-farm/vgi 0.48.0 → 0.48.1

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 (95) hide show
  1. package/dist/arguments/argument-spec.d.ts +17 -11
  2. package/dist/catalog/descriptors.d.ts +2 -2
  3. package/dist/catalog/publication.d.ts +7 -7
  4. package/dist/client/client.d.ts +9 -3
  5. package/dist/client/errors.d.ts +2 -2
  6. package/dist/client/types.d.ts +21 -0
  7. package/dist/client-entry.d.ts +1 -1
  8. package/dist/client-entry.js +31 -7
  9. package/dist/client-entry.js.map +20 -20
  10. package/dist/filter-pushdown/deserialize.d.ts +1 -1
  11. package/dist/filter-pushdown/types.d.ts +10 -10
  12. package/dist/functions/scalar.d.ts +1 -1
  13. package/dist/functions/table-buffering.d.ts +20 -20
  14. package/dist/functions/table-in-out.d.ts +4 -4
  15. package/dist/functions/table.d.ts +7 -7
  16. package/dist/functions/types.d.ts +47 -47
  17. package/dist/http/fetch.d.ts +10 -10
  18. package/dist/index.core.d.ts +1 -1
  19. package/dist/index.js +155 -94
  20. package/dist/index.js.map +53 -52
  21. package/dist/protocol/dispatch.d.ts +3 -3
  22. package/dist/protocol/handlers/function.d.ts +2 -2
  23. package/dist/protocol/serializers/cardinality.d.ts +4 -1
  24. package/dist/protocol/types.d.ts +5 -5
  25. package/dist/rpc-server.d.ts +6 -6
  26. package/dist/serve-entry.d.ts +16 -16
  27. package/dist/serve-entry.js +42 -21
  28. package/dist/serve-entry.js.map +38 -37
  29. package/dist/split-token.d.ts +6 -6
  30. package/dist/types.d.ts +9 -2
  31. package/dist/util/defined.d.ts +21 -0
  32. package/dist/worker-cf-entry.js +120 -85
  33. package/dist/worker-cf-entry.js.map +51 -50
  34. package/dist/worker.d.ts +2 -2
  35. package/package.json +6 -4
  36. package/src/arguments/argument-spec.ts +17 -11
  37. package/src/arrow/codec/registry.ts +2 -2
  38. package/src/arrow/impl-arrowjs/build.ts +1 -1
  39. package/src/arrow/impl-arrowjs/canonical.ts +23 -23
  40. package/src/arrow/impl-arrowjs/empty.ts +2 -2
  41. package/src/arrow/impl-arrowjs/ipc.ts +2 -2
  42. package/src/arrow/impl-arrowjs/iterate.ts +2 -2
  43. package/src/arrow/impl-arrowjs/project.ts +2 -2
  44. package/src/arrow/impl-flechette/build.ts +2 -1
  45. package/src/arrow/impl-flechette/canonical.ts +10 -9
  46. package/src/arrow/impl-flechette/compat.ts +3 -3
  47. package/src/arrow/impl-flechette/message-meta.ts +5 -4
  48. package/src/arrow/impl-flechette/statistics.ts +2 -2
  49. package/src/attach-ticket.ts +2 -2
  50. package/src/catalog/column-metadata.ts +1 -1
  51. package/src/catalog/composite.ts +2 -2
  52. package/src/catalog/constraints.ts +9 -9
  53. package/src/catalog/descriptors.ts +1 -1
  54. package/src/catalog/interface.ts +12 -12
  55. package/src/catalog/publication.ts +9 -8
  56. package/src/catalog/read-only.ts +9 -8
  57. package/src/catalog/sql-grammar.ts +6 -6
  58. package/src/client/client.ts +52 -15
  59. package/src/client/errors.ts +1 -1
  60. package/src/client/types.ts +23 -0
  61. package/src/client-entry.ts +2 -0
  62. package/src/codec/asd.ts +3 -3
  63. package/src/codec/conform.ts +3 -3
  64. package/src/filter-pushdown/collector.ts +1 -1
  65. package/src/filter-pushdown/deserialize.ts +13 -10
  66. package/src/filter-pushdown/evaluate.ts +3 -2
  67. package/src/filter-pushdown/history.ts +3 -2
  68. package/src/filter-pushdown/types.ts +10 -10
  69. package/src/functions/continuation.ts +1 -1
  70. package/src/functions/projection.ts +1 -1
  71. package/src/functions/registry.ts +14 -14
  72. package/src/functions/scalar.ts +3 -3
  73. package/src/functions/storage-cf-do.ts +2 -2
  74. package/src/functions/table-buffering.ts +25 -21
  75. package/src/functions/table-in-out.ts +8 -8
  76. package/src/functions/table.ts +27 -25
  77. package/src/functions/types.ts +47 -47
  78. package/src/generated/vgi-service.ts +5 -3
  79. package/src/http/fetch.ts +17 -12
  80. package/src/index.core.ts +2 -0
  81. package/src/protocol/carried-init-request.ts +1 -1
  82. package/src/protocol/dispatch.ts +3 -3
  83. package/src/protocol/handlers/aggregate.ts +8 -7
  84. package/src/protocol/handlers/catalog/shared.ts +1 -1
  85. package/src/protocol/handlers/function.ts +2 -2
  86. package/src/protocol/serializers/cardinality.ts +16 -3
  87. package/src/protocol/state-serializer.ts +1 -1
  88. package/src/protocol/types.ts +5 -5
  89. package/src/rpc-server.ts +13 -12
  90. package/src/serve-entry.ts +18 -18
  91. package/src/split-token.ts +10 -9
  92. package/src/types.ts +9 -2
  93. package/src/util/defined.ts +30 -0
  94. package/src/util/parent-rows.ts +2 -2
  95. package/src/worker.ts +15 -14
@@ -3,11 +3,11 @@ export interface ArgumentSpec {
3
3
  name: string;
4
4
  position: number | string;
5
5
  arrowType: VgiDataType;
6
- isTableInput?: boolean;
7
- isAnyType?: boolean;
8
- isVarargs?: boolean;
9
- isConst?: boolean;
10
- doc?: string;
6
+ isTableInput?: boolean | undefined;
7
+ isAnyType?: boolean | undefined;
8
+ isVarargs?: boolean | undefined;
9
+ isConst?: boolean | undefined;
10
+ doc?: string | undefined;
11
11
  /**
12
12
  * Discovery-facing constraint metadata, pre-encoded to their surfaced UTF-8
13
13
  * forms (presence-only — `undefined` means the constraint is absent and the
@@ -15,10 +15,10 @@ export interface ArgumentSpec {
15
15
  * `ArgumentSpec.default_json` / `choices_json` / `range_notation` / `pattern`
16
16
  * so `argumentSpecsToSchema`/`schemaToArgumentSpecs` round-trip symmetrically.
17
17
  */
18
- defaultJson?: string;
19
- choicesJson?: string;
20
- rangeNotation?: string;
21
- pattern?: string;
18
+ defaultJson?: string | undefined;
19
+ choicesJson?: string | undefined;
20
+ rangeNotation?: string | undefined;
21
+ pattern?: string | undefined;
22
22
  }
23
23
  /**
24
24
  * Raw per-argument constraint declarations, as authored on a function's
@@ -36,7 +36,11 @@ export interface ArgumentConstraints {
36
36
  gt?: number;
37
37
  /** Exclusive upper bound (`<`). */
38
38
  lt?: number;
39
- /** Regex the value must match (surfaced as `vgi_pattern`, as-is). */
39
+ /**
40
+ * Regex the value must match (surfaced as `vgi_pattern`, as-is). Matching is
41
+ * an UNANCHORED search (JSON Schema / ECMA-262 semantics, same across SDKs):
42
+ * `"\\d"` accepts `"ab1"`. Anchor with `^...$` to require a full match.
43
+ */
40
44
  pattern?: string;
41
45
  /** Default value (JSON-encoded into `vgi_default`); optional args only. */
42
46
  default?: unknown;
@@ -117,7 +121,9 @@ export declare function assertArrowTypes(types: Record<string, unknown> | undefi
117
121
  * Enforce a bind-time const value against its declared {@link ArgumentConstraints},
118
122
  * throwing {@link ArgumentValidationError} on violation. Mirrors the Python SDK's
119
123
  * `Arg._validate`: numeric range (`ge`/`le`/`gt`/`lt`), closed choice set, and
120
- * regex `pattern`. A `null`/`undefined` value skips its value constraints.
124
+ * regex `pattern` (an unanchored search — `RegExp.prototype.test`, matching the
125
+ * JSON Schema `pattern` keyword). A `null`/`undefined` value skips its value
126
+ * constraints.
121
127
  */
122
128
  export declare function validateConstConstraints(name: string, constraints: ArgumentConstraints, value: unknown): void;
123
129
  /**
@@ -85,8 +85,8 @@ export interface TableDescriptor {
85
85
  * tables; static-column tables don't have a function to call.
86
86
  */
87
87
  inlinedCardinality?: {
88
- estimate: bigint;
89
- max: bigint;
88
+ estimate: number | bigint;
89
+ max: number | bigint;
90
90
  };
91
91
  comment?: string;
92
92
  tags?: Record<string, string>;
@@ -11,7 +11,7 @@ export interface SnapshotIdentity {
11
11
  export interface SnapshotRequest {
12
12
  catalog: CatalogInterface;
13
13
  attachOpaqueData: AttachOpaqueData;
14
- callContext?: CallContext;
14
+ callContext?: CallContext | undefined;
15
15
  catalogVersion: number;
16
16
  }
17
17
  export interface CatalogPublicationManifest {
@@ -29,9 +29,9 @@ export interface CatalogPublicationManifest {
29
29
  rawSize: number;
30
30
  storedSize: number;
31
31
  url: string;
32
- objectId?: string;
33
- expiresAt?: number;
34
- retainUntil?: number;
32
+ objectId?: string | undefined;
33
+ expiresAt?: number | undefined;
34
+ retainUntil?: number | undefined;
35
35
  stable: boolean;
36
36
  validated: true;
37
37
  }
@@ -87,9 +87,9 @@ export declare class MemoryCatalogPublicationRepository implements CatalogPublic
87
87
  rawSize: number;
88
88
  storedSize: number;
89
89
  url: string;
90
- objectId?: string;
91
- expiresAt?: number;
92
- retainUntil?: number;
90
+ objectId?: string | undefined;
91
+ expiresAt?: number | undefined;
92
+ retainUntil?: number | undefined;
93
93
  stable: boolean;
94
94
  validated: true;
95
95
  }>>;
@@ -3,7 +3,7 @@ import type { RpcClient, StreamSession } from "@query-farm/vgi-rpc";
3
3
  import { type SchemaInfo, type TableInfo, type ViewInfo, type FunctionInfo, type MacroInfo, type MacroType, type CatalogAttachResult, type SchemaContentsInfo, type IndexInfo, type AttachOpaqueData, type TransactionOpaqueData, type CatalogInfo, type ScanFunctionResult } from "../catalog/interface.js";
4
4
  import { VgiClientError } from "./errors.js";
5
5
  export { VgiClientError };
6
- import type { VgiClientOptions, TableFunctionOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, CatalogMacroType, CatalogAttachOptions, AttachOptionValue, CatalogSnapshot, LoadCatalogOptions } from "./types.js";
6
+ import type { VgiClientOptions, TableFunctionOptions, TableFunctionRowsOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, CatalogMacroType, CatalogAttachOptions, AttachOptionValue, CatalogSnapshot, LoadCatalogOptions } from "./types.js";
7
7
  /**
8
8
  * Send one input batch on a table-in-out exchange and yield the rows of every
9
9
  * reply it gets (continued output, docs/table_in_out.md "Continued Output").
@@ -75,8 +75,14 @@ export declare class VgiClient {
75
75
  tableInOutFunctionRows(opts: TableInOutFunctionOptions): AsyncGenerator<Record<string, any>[]>;
76
76
  /** Call a table-in-out function, yielding output as RecordBatch instances. */
77
77
  tableInOutFunction(opts: TableInOutFunctionOptions): AsyncGenerator<VgiBatch>;
78
- /** Call a table function, yielding output as row objects. */
79
- tableFunctionRows(opts: TableFunctionOptions): AsyncGenerator<Record<string, any>[]>;
78
+ /**
79
+ * Call a table function, yielding output as row objects.
80
+ *
81
+ * int64/uint64 columns follow `opts.int64` (see {@link Int64Mode}); pass
82
+ * `int64: "bigint"` to get a `bigint` for every value instead of a
83
+ * magnitude-dependent mix of `number` and `bigint`.
84
+ */
85
+ tableFunctionRows(opts: TableFunctionRowsOptions): AsyncGenerator<Record<string, any>[]>;
80
86
  /**
81
87
  * List all catalogs with their advertised version metadata.
82
88
  *
@@ -7,8 +7,8 @@ export declare class VgiClientError extends Error {
7
7
  /** Underlying error type from the worker (e.g. "ValueError"), when known. */
8
8
  readonly errorType?: string;
9
9
  constructor(message: string, options?: {
10
- remoteTraceback?: string;
11
- errorType?: string;
10
+ remoteTraceback?: string | undefined;
11
+ errorType?: string | undefined;
12
12
  cause?: unknown;
13
13
  });
14
14
  /**
@@ -84,6 +84,27 @@ export interface TableFunctionOptions {
84
84
  /** Invoked after bind, before init. Receives the bind response. */
85
85
  onBind?: BindResultCallback;
86
86
  }
87
+ /**
88
+ * How {@link VgiClient.tableFunctionRows} surfaces int64/uint64 column
89
+ * values. Same vocabulary as `@query-farm/vgi-rpc`'s client `int64` option.
90
+ *
91
+ * - `"number-if-safe"`: values within `Number.MAX_SAFE_INTEGER` become
92
+ * `number`, larger ones stay `bigint` (one column can hold both).
93
+ * - `"bigint"`: every value stays a `bigint` — one JS type per column.
94
+ */
95
+ export type Int64Mode = "number-if-safe" | "bigint";
96
+ /** Options for {@link VgiClient.tableFunctionRows}. */
97
+ export interface TableFunctionRowsOptions extends TableFunctionOptions {
98
+ /**
99
+ * Surfacing of top-level int64/uint64 output columns (see {@link Int64Mode}).
100
+ * When omitted, rows are returned as the underlying `RpcClient` produced
101
+ * them — `"number-if-safe"` unless that client was created with
102
+ * `int64: "bigint"` (`@query-farm/vgi-rpc` >= 0.29.6). Setting it here
103
+ * overrides the client either way. The omitted-default may become
104
+ * `"bigint"` in a future minor release; pass it explicitly to pin it.
105
+ */
106
+ int64?: Int64Mode;
107
+ }
87
108
  /** Options for calling a scalar function. */
88
109
  export interface ScalarFunctionOptions {
89
110
  /** Name of the function to call. */
@@ -1,5 +1,5 @@
1
1
  export { VgiClient, VgiClientError } from "./client/client.js";
2
- export type { VgiClientOptions, TableFunctionOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, } from "./client/types.js";
2
+ export type { VgiClientOptions, TableFunctionOptions, TableFunctionRowsOptions, Int64Mode, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, } from "./client/types.js";
3
3
  export { Arguments } from "./arguments/arguments.js";
4
4
  export { type ArgumentSpec, argumentSpecsToSchema, schemaToArgumentSpecs, } from "./arguments/argument-spec.js";
5
5
  export { FunctionType, FunctionStability, NullHandling, ArgumentMonotonicity, OrderPreservation, OrderDependence, DistinctDependence, TableInOutPhase, } from "./types.js";
@@ -5703,6 +5703,26 @@ function toAsyncIterator(input) {
5703
5703
  }
5704
5704
 
5705
5705
  // src/client/client.ts
5706
+ function int64ColumnNames(s) {
5707
+ if (!s)
5708
+ return [];
5709
+ return s.fields.filter((f) => isInt(f.type) && f.type.bitWidth === 64).map((f) => f.name);
5710
+ }
5711
+ var MIN_SAFE_BIGINT = BigInt(Number.MIN_SAFE_INTEGER);
5712
+ var MAX_SAFE_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);
5713
+ function applyInt64Mode(rows, columns, mode) {
5714
+ for (const row of rows) {
5715
+ for (const name of columns) {
5716
+ const v = row[name];
5717
+ if (mode === "bigint") {
5718
+ if (typeof v === "number" && Number.isInteger(v))
5719
+ row[name] = BigInt(v);
5720
+ } else if (typeof v === "bigint" && v >= MIN_SAFE_BIGINT && v <= MAX_SAFE_BIGINT) {
5721
+ row[name] = Number(v);
5722
+ }
5723
+ }
5724
+ }
5725
+ }
5706
5726
  function onConflictName(onConflict) {
5707
5727
  return String(onConflict).toUpperCase();
5708
5728
  }
@@ -5994,10 +6014,14 @@ class VgiClient {
5994
6014
  tablesample: opts.tablesample,
5995
6015
  joinKeys: opts.joinKeys
5996
6016
  });
6017
+ const int64Columns = opts.int64 === undefined ? [] : int64ColumnNames(bindResp.output_schema);
5997
6018
  try {
5998
6019
  for await (const rows of session) {
5999
- if (rows.length > 0)
6000
- yield rows;
6020
+ if (rows.length === 0)
6021
+ continue;
6022
+ if (int64Columns.length > 0)
6023
+ applyInt64Mode(rows, int64Columns, opts.int64);
6024
+ yield rows;
6001
6025
  }
6002
6026
  } finally {
6003
6027
  session.close();
@@ -6239,7 +6263,7 @@ class VgiClient {
6239
6263
  return null;
6240
6264
  const inner = unwrapResult(result);
6241
6265
  const items = deserializeInfoList(inner.items, decodeSchemaInfo);
6242
- return items.length > 0 ? items[0] : null;
6266
+ return items[0] ?? null;
6243
6267
  }
6244
6268
  async schemaCreate(attachOpaqueData, path, opts) {
6245
6269
  const tagsMap = opts?.tags ? new Map(Object.entries(opts.tags)) : null;
@@ -6317,7 +6341,7 @@ class VgiClient {
6317
6341
  return null;
6318
6342
  const inner = unwrapResult(result);
6319
6343
  const items = deserializeInfoList(inner.items, decodeTableInfo);
6320
- return items.length > 0 ? items[0] : null;
6344
+ return items[0] ?? null;
6321
6345
  }
6322
6346
  async tableCreate(attachOpaqueData, schemaPath, name, columns, onConflict, constraintDefinitions = [], transactionOpaqueData) {
6323
6347
  await this.rpc.call("catalog_table_create", {
@@ -6485,7 +6509,7 @@ class VgiClient {
6485
6509
  return null;
6486
6510
  const inner = unwrapResult(result);
6487
6511
  const items = deserializeInfoList(inner.items, decodeViewInfo);
6488
- return items.length > 0 ? items[0] : null;
6512
+ return items[0] ?? null;
6489
6513
  }
6490
6514
  async viewCreate(attachOpaqueData, schemaPath, name, definition, onConflict, transactionOpaqueData, aliases, security = "regular", comment, tags, columnComments) {
6491
6515
  await this.rpc.call("catalog_view_create", {
@@ -6554,7 +6578,7 @@ class VgiClient {
6554
6578
  return null;
6555
6579
  const inner = unwrapResult(result);
6556
6580
  const items = deserializeInfoList(inner.items, decodeMacroInfo);
6557
- return items.length > 0 ? items[0] : null;
6581
+ return items[0] ?? null;
6558
6582
  }
6559
6583
  async schemaContentsMacros(attachOpaqueData, path, type, transactionOpaqueData) {
6560
6584
  const result = await this.rpc.call("catalog_schema_contents_macros", {
@@ -6849,4 +6873,4 @@ export {
6849
6873
  validateTableConstraints
6850
6874
  };
6851
6875
 
6852
- //# debugId=53223F3F99D7E12364756E2164756E21
6876
+ //# debugId=F1A002FFA544727064756E2164756E21