@query-farm/vgi 0.37.0 → 0.38.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 (48) hide show
  1. package/README.md +74 -0
  2. package/dist/catalog/attach-option.d.ts +11 -8
  3. package/dist/catalog/composite.d.ts +23 -1
  4. package/dist/catalog/contents-digest.d.ts +25 -0
  5. package/dist/catalog/interface.d.ts +107 -2
  6. package/dist/catalog/read-only.d.ts +45 -1
  7. package/dist/client/client.d.ts +19 -1
  8. package/dist/client-entry.js +141 -4
  9. package/dist/client-entry.js.map +10 -9
  10. package/dist/codec/asd.d.ts +8 -0
  11. package/dist/generated/vgi-client.d.ts +19 -0
  12. package/dist/generated/vgi-protocol-schemas.d.ts +3 -0
  13. package/dist/generated/vgi-protocol-types.d.ts +26 -0
  14. package/dist/http/fetch.d.ts +2 -1
  15. package/dist/index.core.d.ts +5 -2
  16. package/dist/index.js +574 -36
  17. package/dist/index.js.map +21 -17
  18. package/dist/protocol/handlers/catalog/contents.d.ts +27 -0
  19. package/dist/rpc-server.d.ts +97 -0
  20. package/dist/serve-entry.d.ts +2 -1
  21. package/dist/serve-entry.js +405 -25
  22. package/dist/serve-entry.js.map +18 -14
  23. package/dist/worker-cf-entry.d.ts +3 -0
  24. package/dist/worker-cf-entry.js +528 -31
  25. package/dist/worker-cf-entry.js.map +21 -17
  26. package/dist/worker.d.ts +9 -1
  27. package/package.json +3 -3
  28. package/src/catalog/attach-option.ts +11 -8
  29. package/src/catalog/composite.ts +81 -0
  30. package/src/catalog/contents-digest.ts +78 -0
  31. package/src/catalog/interface.ts +167 -5
  32. package/src/catalog/read-only.ts +68 -6
  33. package/src/client/client.ts +53 -0
  34. package/src/codec/asd.ts +96 -1
  35. package/src/generated/vgi-client.ts +22 -1
  36. package/src/generated/vgi-protocol-schemas.ts +30 -1
  37. package/src/generated/vgi-protocol-types.ts +126 -0
  38. package/src/http/fetch.ts +10 -2
  39. package/src/index.core.ts +21 -2
  40. package/src/protocol/dispatch.ts +1 -1
  41. package/src/protocol/handlers/catalog/admin.ts +35 -26
  42. package/src/protocol/handlers/catalog/contents.ts +162 -0
  43. package/src/protocol/handlers/catalog/macro.ts +2 -1
  44. package/src/protocol/handlers/catalog/shared.ts +12 -1
  45. package/src/rpc-server.ts +273 -0
  46. package/src/serve-entry.ts +7 -1
  47. package/src/worker-cf-entry.ts +8 -0
  48. package/src/worker.ts +24 -6
@@ -18,6 +18,14 @@ import { type VgiSchema } from "../arrow/index.js";
18
18
  * Matches Python's `ArrowSerializableDataclass.serialize_to_bytes()`.
19
19
  */
20
20
  export declare function encodeASD(schema: VgiSchema, obj: Record<string, any>): Uint8Array;
21
+ /** Compare two strings by Unicode code point (= UTF-8 byte order). */
22
+ export declare function compareCodePoints(a: string, b: string): number;
23
+ /**
24
+ * `obj` with every map-typed field (at any depth) as a key-sorted pair list.
25
+ * Returns `obj` itself when the schema has no map column. Never mutates `obj`
26
+ * (catalog items may be frozen and shared).
27
+ */
28
+ export declare function sortMapsForSchema(schema: VgiSchema, obj: Record<string, any>): Record<string, any>;
21
29
  /**
22
30
  * Decode a single-row Arrow IPC stream into a typed object using `schema`.
23
31
  * Matches Python's `ArrowSerializableDataclass.deserialize_from_bytes()`.
@@ -357,10 +357,29 @@ export interface CatalogAttachResult {
357
357
  global_function_prefix: string;
358
358
  resolved_data_version?: string | null;
359
359
  resolved_implementation_version?: string | null;
360
+ supports_catalog_contents: boolean;
360
361
  }
361
362
  export interface CatalogsResponse {
362
363
  items: CatalogInfo[];
363
364
  }
365
+ export interface SchemaContents {
366
+ path: string[];
367
+ schema: Uint8Array;
368
+ tables: Uint8Array[];
369
+ views: Uint8Array[];
370
+ scalar_functions: Uint8Array[];
371
+ aggregate_functions: Uint8Array[];
372
+ table_functions: Uint8Array[];
373
+ scalar_macros: Uint8Array[];
374
+ table_macros: Uint8Array[];
375
+ indexes: Uint8Array[];
376
+ }
377
+ export interface CatalogContentsResponse {
378
+ catalog_version: number;
379
+ etag?: string | null;
380
+ not_modified: boolean;
381
+ schemas: SchemaContents[];
382
+ }
364
383
  export interface CopyFromFormatsResponse {
365
384
  items: Uint8Array[];
366
385
  }
@@ -12,6 +12,7 @@ export declare const ScanBranchSchema: import("../index.core.js").VgiSchema;
12
12
  export declare const ScanSplitSchema: import("../index.core.js").VgiSchema;
13
13
  export declare const AttachCatalogInfoSchema: import("../index.core.js").VgiSchema;
14
14
  export declare const ForeignKeyInfoSchema: import("../index.core.js").VgiSchema;
15
+ export declare const SchemaContentsSchema: import("../index.core.js").VgiSchema;
15
16
  export declare const AggregateBindRequestSchema: import("../index.core.js").VgiSchema;
16
17
  export declare const AggregateCombineRequestSchema: import("../index.core.js").VgiSchema;
17
18
  export declare const AggregateDestructorRequestSchema: import("../index.core.js").VgiSchema;
@@ -57,6 +58,7 @@ export declare const AggregateWindowInitResultSchema: import("../index.core.js")
57
58
  export declare const BindResultSchema: import("../index.core.js").VgiSchema;
58
59
  export declare const CatalogAttachResultSchema: import("../index.core.js").VgiSchema;
59
60
  export declare const CatalogCatalogsResultSchema: import("../index.core.js").VgiSchema;
61
+ export declare const CatalogContentsResultSchema: import("../index.core.js").VgiSchema;
60
62
  export declare const CatalogCopyFromFormatsResultSchema: import("../index.core.js").VgiSchema;
61
63
  export declare const CatalogIndexGetResultSchema: import("../index.core.js").VgiSchema;
62
64
  export declare const CatalogMacroGetResultSchema: import("../index.core.js").VgiSchema;
@@ -92,6 +94,7 @@ export declare const AggregateWindowInitParamsSchema: import("../index.core.js")
92
94
  export declare const BindParamsSchema: import("../index.core.js").VgiSchema;
93
95
  export declare const CatalogAttachParamsSchema: import("../index.core.js").VgiSchema;
94
96
  export declare const CatalogCatalogsParamsSchema: import("../index.core.js").VgiSchema;
97
+ export declare const CatalogContentsParamsSchema: import("../index.core.js").VgiSchema;
95
98
  export declare const CatalogCopyFromFormatsParamsSchema: import("../index.core.js").VgiSchema;
96
99
  export declare const CatalogCreateParamsSchema: import("../index.core.js").VgiSchema;
97
100
  export declare const CatalogDetachParamsSchema: import("../index.core.js").VgiSchema;
@@ -0,0 +1,26 @@
1
+ import type { CatalogAttachResult, CatalogContentsResponse, SchemaContents } from "./vgi-client.js";
2
+ export type { CatalogAttachResult, CatalogContentsResponse, SchemaContents };
3
+ /** Fields of `CatalogAttachResult` that have a protocol default. */
4
+ export type CatalogAttachResultDefaultedField = "attach_opaque_data_required" | "default_schema" | "settings" | "secret_types" | "attach_catalogs" | "comment" | "tags" | "supports_column_statistics" | "global_functions" | "global_function_prefix" | "supports_catalog_contents";
5
+ /** `CatalogAttachResult` with every field that has a protocol default optional. */
6
+ export type CatalogAttachResultInit = Omit<CatalogAttachResult, CatalogAttachResultDefaultedField> & Partial<Pick<CatalogAttachResult, CatalogAttachResultDefaultedField>>;
7
+ /** Build a complete `CatalogAttachResult`, filling the protocol defaults, in wire order. */
8
+ export declare function buildCatalogAttachResult(init: CatalogAttachResultInit): CatalogAttachResult;
9
+ export declare const encodeCatalogAttachResult: (v: CatalogAttachResult) => Uint8Array;
10
+ export declare const decodeCatalogAttachResult: (b: Uint8Array) => CatalogAttachResult;
11
+ /** Fields of `SchemaContents` that have a protocol default. */
12
+ export type SchemaContentsDefaultedField = "tables" | "views" | "scalar_functions" | "aggregate_functions" | "table_functions" | "scalar_macros" | "table_macros" | "indexes";
13
+ /** `SchemaContents` with every field that has a protocol default optional. */
14
+ export type SchemaContentsInit = Omit<SchemaContents, SchemaContentsDefaultedField> & Partial<Pick<SchemaContents, SchemaContentsDefaultedField>>;
15
+ /** Build a complete `SchemaContents`, filling the protocol defaults, in wire order. */
16
+ export declare function buildSchemaContents(init: SchemaContentsInit): SchemaContents;
17
+ export declare const encodeSchemaContents: (v: SchemaContents) => Uint8Array;
18
+ export declare const decodeSchemaContents: (b: Uint8Array) => SchemaContents;
19
+ /** Fields of `CatalogContentsResponse` that have a protocol default. */
20
+ export type CatalogContentsResponseDefaultedField = "etag" | "not_modified" | "schemas";
21
+ /** `CatalogContentsResponse` with every field that has a protocol default optional. */
22
+ export type CatalogContentsResponseInit = Omit<CatalogContentsResponse, CatalogContentsResponseDefaultedField> & Partial<Pick<CatalogContentsResponse, CatalogContentsResponseDefaultedField>>;
23
+ /** Build a complete `CatalogContentsResponse`, filling the protocol defaults, in wire order. */
24
+ export declare function buildCatalogContentsResponse(init: CatalogContentsResponseInit): CatalogContentsResponse;
25
+ export declare const encodeCatalogContentsResponse: (v: CatalogContentsResponse) => Uint8Array;
26
+ export declare const decodeCatalogContentsResponse: (b: Uint8Array) => CatalogContentsResponse;
@@ -1,7 +1,8 @@
1
1
  import { type AuthenticateFn, type PeerAuthenticationPolicy, type PeerIdentityProvider, type PeerResolutionOptions } from "@query-farm/vgi-rpc";
2
2
  import { type ProtocolConfig } from "../protocol/dispatch.js";
3
3
  import { type LandingInfo } from "./landing.js";
4
- export interface VgiFetchOptions {
4
+ import { type HostingOptions } from "../rpc-server.js";
5
+ export interface VgiFetchOptions extends HostingOptions {
5
6
  /** Wire-protocol config (registry + catalogInterface). */
6
7
  protocol: ProtocolConfig;
7
8
  /** HMAC key for state-token signing. Pass a stable, secret 32-byte key
@@ -7,9 +7,9 @@ export { defineTableBufferingFunction, type TableBufferingConfig, type TableBuff
7
7
  export { defineCopyFromFunction, type CopyFromFunctionConfig, type CopyFromOption, type CopyFromReadParams, } from "./functions/copy-from.js";
8
8
  export { defineCopyToFunction, type CopyToFunctionConfig, type CopyToOption, type CopyToWriteParams, type CopyToCloseParams, } from "./functions/copy-to.js";
9
9
  export type { VgiFunction, FunctionMeta, StreamHandlers, FunctionExample, HandlerState } from "./functions/types.js";
10
- export { CatalogInterface, type CatalogAttachResult, type SchemaInfo, encodeSchemaInfo, decodeSchemaInfo, type TableInfo, encodeTableInfo, decodeTableInfo, type ViewInfo, encodeViewInfo, decodeViewInfo, type CatalogInfo, encodeCatalogInfo, decodeCatalogInfo, type FunctionInfo, encodeFunctionInfo, decodeFunctionInfo, type FunctionInfoOptions, type MacroInfo, encodeMacroInfo, decodeMacroInfo, type MacroType, type CopyFromFormatInfo, encodeCopyFromFormatInfo, type AttachOpaqueData, type TransactionOpaqueData, buildScanBranchesResult, encodeFormatOptions, type ScanBranchInput } from "./catalog/interface.js";
10
+ export { CatalogInterface, type CatalogAttachResult, type CatalogAttachResultInit, buildCatalogAttachResult, type SchemaContentsInfo, type CatalogContentsResult, type SchemaInfo, encodeSchemaInfo, decodeSchemaInfo, type TableInfo, encodeTableInfo, decodeTableInfo, type ViewInfo, encodeViewInfo, decodeViewInfo, type CatalogInfo, encodeCatalogInfo, decodeCatalogInfo, type FunctionInfo, encodeFunctionInfo, decodeFunctionInfo, type FunctionInfoOptions, type MacroInfo, encodeMacroInfo, decodeMacroInfo, type MacroType, type CopyFromFormatInfo, encodeCopyFromFormatInfo, type AttachOpaqueData, type TransactionOpaqueData, buildScanBranchesResult, encodeFormatOptions, type ScanBranchInput } from "./catalog/interface.js";
11
11
  export type { CatalogDescriptor, SchemaDescriptor, TableDescriptor, ViewDescriptor, MacroDescriptor, SettingDescriptor, SecretTypeDescriptor, ForeignKeyDef, DefaultValue } from "./catalog/descriptors.js";
12
- export { ReadOnlyCatalogInterface } from "./catalog/read-only.js";
12
+ export { ReadOnlyCatalogInterface, READ_ONLY_ITEM_ATTACH_ID } from "./catalog/read-only.js";
13
13
  export { CompositeCatalogInterface } from "./catalog/composite.js";
14
14
  export { FunctionRegistry } from "./functions/registry.js";
15
15
  export { FunctionType, FunctionStability, NullHandling, ArgumentMonotonicity, OrderPreservation, OrderDependence, DistinctDependence, TableInOutPhase, DEFAULT_MAX_WORKERS, } from "./types.js";
@@ -43,4 +43,7 @@ export type { VgiClientOptions, TableFunctionOptions, ScalarFunctionOptions, Tab
43
43
  export { str, bytes, int, int32, float, float32, bool, toSchema, OutputCollector, AuthContext } from "@query-farm/vgi-rpc";
44
44
  export { subprocessConnect, httpConnect, tcpConnect } from "@query-farm/vgi-rpc";
45
45
  export type { RpcClient, StreamSession, LogMessage } from "@query-farm/vgi-rpc";
46
+ export { buildRpcServer, INTROSPECT_PRINCIPALS_ENV, type BuildRpcServerOptions, type HostingOptions, type ServerTransport, } from "./rpc-server.js";
47
+ export { AuthUnavailableError, GrantRefusedError, IdentityUnavailableError, StatusError, } from "@query-farm/vgi-rpc";
48
+ export type { GrantMinter, IssuedGrant, TokenIdentity, TokenResolver } from "@query-farm/vgi-rpc";
46
49
  export { normalizeSchemaPath, schemaPathDisplay, schemaPathKey, schemaPathsEqual, type SchemaPath } from "./schema-path.js";