@query-farm/vgi 0.42.0 → 0.44.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 (59) hide show
  1. package/README.md +5 -2
  2. package/dist/attach-ticket.d.ts +18 -7
  3. package/dist/client-entry.js +215 -91
  4. package/dist/client-entry.js.map +10 -9
  5. package/dist/codec/asd.d.ts +3 -1
  6. package/dist/codec/conform.d.ts +51 -0
  7. package/dist/errors.d.ts +5 -1
  8. package/dist/generated/vgi-service.d.ts +1315 -0
  9. package/dist/index.core.d.ts +1 -1
  10. package/dist/index.js +2143 -932
  11. package/dist/index.js.map +29 -28
  12. package/dist/protocol/dispatch.d.ts +14 -5
  13. package/dist/protocol/handlers/aggregate.d.ts +3 -2
  14. package/dist/protocol/handlers/catalog/admin.d.ts +2 -2
  15. package/dist/protocol/handlers/catalog/index.d.ts +3 -2
  16. package/dist/protocol/handlers/catalog/index_methods.d.ts +2 -2
  17. package/dist/protocol/handlers/catalog/macro.d.ts +2 -2
  18. package/dist/protocol/handlers/catalog/shared.d.ts +7 -14
  19. package/dist/protocol/handlers/catalog/table.d.ts +2 -2
  20. package/dist/protocol/handlers/catalog/view.d.ts +2 -2
  21. package/dist/protocol/handlers/function.d.ts +3 -2
  22. package/dist/protocol/handlers/shared.d.ts +2 -2
  23. package/dist/protocol/handlers/table-buffering.d.ts +3 -2
  24. package/dist/protocol/handlers/unimplemented.d.ts +4 -17
  25. package/dist/protocol/serializers/shared.d.ts +2 -1
  26. package/dist/rpc-server.d.ts +2 -2
  27. package/dist/serve-entry.js +2104 -903
  28. package/dist/serve-entry.js.map +25 -24
  29. package/dist/worker-cf-entry.js +2045 -842
  30. package/dist/worker-cf-entry.js.map +29 -28
  31. package/package.json +3 -3
  32. package/src/attach-ticket.ts +41 -13
  33. package/src/catalog/composite.ts +2 -1
  34. package/src/catalog/interface.ts +5 -4
  35. package/src/catalog/read-only.ts +8 -6
  36. package/src/client/client.ts +13 -5
  37. package/src/codec/asd.ts +5 -2
  38. package/src/codec/conform.ts +193 -0
  39. package/src/errors.ts +27 -7
  40. package/src/functions/registry.ts +3 -2
  41. package/src/generated/vgi-service.ts +2678 -0
  42. package/src/http/fetch.ts +1 -1
  43. package/src/index.core.ts +3 -1
  44. package/src/protocol/dispatch.ts +40 -29
  45. package/src/protocol/handlers/aggregate.ts +205 -232
  46. package/src/protocol/handlers/catalog/admin.ts +228 -299
  47. package/src/protocol/handlers/catalog/index.ts +17 -16
  48. package/src/protocol/handlers/catalog/index_methods.ts +26 -36
  49. package/src/protocol/handlers/catalog/macro.ts +54 -77
  50. package/src/protocol/handlers/catalog/shared.ts +30 -47
  51. package/src/protocol/handlers/catalog/table.ts +205 -270
  52. package/src/protocol/handlers/catalog/view.ts +59 -85
  53. package/src/protocol/handlers/function.ts +127 -156
  54. package/src/protocol/handlers/shared.ts +8 -6
  55. package/src/protocol/handlers/table-buffering.ts +53 -71
  56. package/src/protocol/handlers/unimplemented.ts +18 -62
  57. package/src/protocol/serializers/bind.ts +3 -1
  58. package/src/protocol/serializers/shared.ts +5 -2
  59. package/src/rpc-server.ts +7 -7
@@ -15,7 +15,9 @@
15
15
  import { type VgiSchema } from "../arrow/index.js";
16
16
  /**
17
17
  * Encode a typed object as a single-row Arrow IPC stream using `schema`.
18
- * Matches Python's `ArrowSerializableDataclass.serialize_to_bytes()`.
18
+ * Matches Python's `ArrowSerializableDataclass.serialize_to_bytes()`, including
19
+ * its container rules: a non-nullable list/map left out or null is written as
20
+ * empty, and list items / map values are never null (see `conformRecord`).
19
21
  */
20
22
  export declare function encodeASD(schema: VgiSchema, obj: Record<string, any>): Uint8Array;
21
23
  /** Compare two strings by Unicode code point (= UTF-8 byte order). */
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Wire conformance for protocol records.
3
+ *
4
+ * vgi-python is the reference for the wire shape, and two of its rules are not
5
+ * expressed by a record's Arrow schema nullability flags alone:
6
+ *
7
+ * 1. A **non-nullable list or map column is never null.** Python's dataclass
8
+ * defaults a `list[...]` / `dict[...]` field to an empty container, so an
9
+ * "absent" list goes out as `[]`. A JS caller that leaves the field out (or
10
+ * passes `null`) would otherwise put a null in a column the schema calls
11
+ * non-null — `CatalogInfo.releases`, `CatalogInfo.attach_option_specs`,
12
+ * ... — which a strict client rejects as a protocol error.
13
+ *
14
+ * 2. **List items and map values are never null** unless the Python annotation
15
+ * says so (`list[str | None]`). pyarrow marks every list item field nullable,
16
+ * so the generated schemas carry `item: nullable=true` everywhere and cannot
17
+ * tell the two apart. In the whole protocol exactly one field has optional
18
+ * items — `argument_names` on `BindRequest` / `AggregateBindRequest` (a
19
+ * positional argument has no name). Every other null item is a bug on the
20
+ * sending side (e.g. `BindResponse.lookup_names` built from an unset secret
21
+ * name, where Python sends `""`).
22
+ *
23
+ * `conformRecord` applies both rules to a record about to be encoded: a null or
24
+ * absent non-nullable list/map becomes empty, and a null list item / map value
25
+ * becomes its type's zero value (`""`, `0`, `false`, empty bytes, empty list),
26
+ * which is also what the C++ client reads such an item as. It never mutates its
27
+ * input (catalog items may be frozen and shared) and returns the input itself
28
+ * when nothing needed changing. Nullable columns, and scalars, pass through
29
+ * untouched: a null in a non-nullable scalar column has no safe default and is
30
+ * left for the caller to fix (see `wireViolations`).
31
+ */
32
+ import { type VgiSchema, type VgiDataType } from "../arrow/index.js";
33
+ /**
34
+ * Top-level / struct-child field names whose list items may legitimately be
35
+ * null (the Python annotation is `list[X | None]`). Derived from vgi-python by
36
+ * walking every protocol dataclass's type hints; keep in sync if the protocol
37
+ * adds another optional-item list.
38
+ */
39
+ export declare const OPTIONAL_ITEM_FIELDS: ReadonlySet<string>;
40
+ /** The value a non-null slot of `type` takes when the sender left it null. */
41
+ export declare function zeroValue(type: VgiDataType): unknown;
42
+ /**
43
+ * `obj` conformed to `schema`'s wire rules (see the module comment). Returns
44
+ * `obj` itself when nothing changed.
45
+ */
46
+ export declare function conformRecord<T extends Record<string, any>>(schema: VgiSchema, obj: T): T;
47
+ /**
48
+ * Column-dict form of `conformRecord` for `batchFromColumns` callers: each
49
+ * value is a one-element array holding the row's value.
50
+ */
51
+ export declare function conformColumns(schema: VgiSchema, columns: Record<string, unknown[]>): Record<string, unknown[]>;
package/dist/errors.d.ts CHANGED
@@ -1,6 +1,10 @@
1
+ import type { ErrorCode } from "@query-farm/vgi-rpc";
1
2
  export declare class VgiError extends Error {
2
- constructor(message: string);
3
+ /** Canonical code hoisted as `vgi_rpc.error_code`; unset means `UNKNOWN`. */
4
+ readonly errorCode?: ErrorCode;
5
+ constructor(message: string, code?: ErrorCode);
3
6
  }
7
+ /** A worker bug (the function returned the wrong number of rows): UNKNOWN. */
4
8
  export declare class RowCountMismatchError extends VgiError {
5
9
  constructor(expected: number, actual: number);
6
10
  }