@query-farm/vgi 0.44.0 → 0.45.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.
- package/dist/arrow/impl-arrowjs/index.d.ts +1 -1
- package/dist/arrow/impl-arrowjs/ipc.d.ts +6 -0
- package/dist/arrow/impl-flechette/build.d.ts +2 -2
- package/dist/arrow/impl-flechette/canonical.d.ts +1 -1
- package/dist/arrow/impl-flechette/index.d.ts +1 -1
- package/dist/arrow/impl-flechette/ipc.d.ts +6 -0
- package/dist/arrow/index.d.ts +1 -1
- package/dist/catalog/contents-codec.d.ts +7 -0
- package/dist/catalog/contents-digest.d.ts +2 -1
- package/dist/catalog/interface.d.ts +3 -0
- package/dist/catalog/publication-envelope.d.ts +1 -0
- package/dist/catalog/publication.d.ts +142 -0
- package/dist/catalog/s3-publication.d.ts +38 -0
- package/dist/client-entry.js +136 -25
- package/dist/client-entry.js.map +13 -12
- package/dist/codec/asd.d.ts +4 -0
- package/dist/generated/vgi-client.d.ts +6 -14
- package/dist/generated/vgi-protocol-schemas.d.ts +2 -0
- package/dist/generated/vgi-protocol-types.d.ts +26 -3
- package/dist/generated/vgi-service.d.ts +3 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.js +739 -81
- package/dist/index.js.map +24 -20
- package/dist/protocol/dispatch.d.ts +1 -1
- package/dist/protocol/handlers/catalog/contents.d.ts +4 -4
- package/dist/serve-entry.js +610 -78
- package/dist/serve-entry.js.map +19 -16
- package/dist/worker-cf-entry.js +626 -86
- package/dist/worker-cf-entry.js.map +21 -18
- package/package.json +3 -3
- package/src/arrow/impl-arrowjs/index.ts +1 -0
- package/src/arrow/impl-arrowjs/ipc.ts +23 -0
- package/src/arrow/impl-flechette/build.ts +4 -2
- package/src/arrow/impl-flechette/canonical.ts +7 -2
- package/src/arrow/impl-flechette/index.ts +1 -0
- package/src/arrow/impl-flechette/ipc.ts +19 -0
- package/src/arrow/index.ts +1 -1
- package/src/catalog/contents-codec.ts +77 -0
- package/src/catalog/contents-digest.ts +20 -17
- package/src/catalog/interface.ts +3 -0
- package/src/catalog/publication-envelope.ts +62 -0
- package/src/catalog/publication.ts +290 -0
- package/src/catalog/read-only.ts +0 -2
- package/src/catalog/s3-publication.ts +81 -0
- package/src/client/client.ts +2 -19
- package/src/codec/asd.ts +40 -1
- package/src/codec/conform.ts +2 -1
- package/src/generated/vgi-client.ts +7 -16
- package/src/generated/vgi-protocol-schemas.ts +13 -6
- package/src/generated/vgi-protocol-types.ts +39 -5
- package/src/generated/vgi-service.ts +4 -3
- package/src/index.ts +5 -0
- package/src/protocol/dispatch.ts +1 -1
- package/src/protocol/handlers/catalog/admin.ts +7 -4
- package/src/protocol/handlers/catalog/contents.ts +50 -35
|
@@ -8,7 +8,7 @@ export { filterBatch } from "./filter.js";
|
|
|
8
8
|
export { projectSchema, projectBatch } from "./project.js";
|
|
9
9
|
export { readCanonicalValue } from "./canonical.js";
|
|
10
10
|
export { withBatchMetadata } from "./metadata.js";
|
|
11
|
-
export { serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, } from "./ipc.js";
|
|
11
|
+
export { serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, deserializeBatches, serializeBatches, serializeCollectionRows, } from "./ipc.js";
|
|
12
12
|
export { buildStatisticsBatch, type ColumnStatistics } from "./statistics.js";
|
|
13
13
|
/**
|
|
14
14
|
* No-op on this backend: arrow-js `RecordBatch`/`Vector` already expose the
|
|
@@ -22,3 +22,9 @@ export declare function serializeBatch(batch: RecordBatch | VgiBatch): Uint8Arra
|
|
|
22
22
|
* Deserialize a RecordBatch from Arrow IPC bytes.
|
|
23
23
|
*/
|
|
24
24
|
export declare function deserializeBatch(bytes: Uint8Array): RecordBatch;
|
|
25
|
+
/** Decode every data batch of a collection stream (including dictionary replacements). */
|
|
26
|
+
export declare function deserializeBatches(bytes: Uint8Array): VgiBatch[];
|
|
27
|
+
/** Write all batches to one IPC stream. */
|
|
28
|
+
export declare function serializeBatches(batches: VgiBatch[], schema: VgiSchema): Uint8Array;
|
|
29
|
+
/** Build shared dictionaries once and emit bounded slices of the collection. */
|
|
30
|
+
export declare function serializeCollectionRows(schema: VgiSchema, rows: Record<string, any>[], maxBatchRows: number): Uint8Array;
|
|
@@ -5,10 +5,10 @@ import type { VgiSchema, VgiBatch, VgiDataType, VgiColumnData } from "../types.j
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function columnFromArray(values: any[], type: VgiDataType): VgiColumnData;
|
|
7
7
|
/** Build a batch from row objects (values are RICH). */
|
|
8
|
-
export declare function batchFromRows(rows: Record<string, any>[], schema: VgiSchema): VgiBatch;
|
|
8
|
+
export declare function batchFromRows(rows: Record<string, any>[], schema: VgiSchema, maxBatchRows?: number): VgiBatch;
|
|
9
9
|
/**
|
|
10
10
|
* Build a batch from column arrays (values are RICH). Each column is converted
|
|
11
11
|
* rich -> canonical via the codec, then the canonical batch writer assembles
|
|
12
12
|
* the flechette Table (preserving per-field nullable + metadata).
|
|
13
13
|
*/
|
|
14
|
-
export declare function batchFromColumns(columns: Record<string, any[]>, schema: VgiSchema, repr?: "rich" | "raw"): VgiBatch;
|
|
14
|
+
export declare function batchFromColumns(columns: Record<string, any[]>, schema: VgiSchema, repr?: "rich" | "raw", maxBatchRows?: number): VgiBatch;
|
|
@@ -6,7 +6,7 @@ export declare function writeCanonicalColumn(type: VgiDataType, canonical: unkno
|
|
|
6
6
|
* per-field `nullable` flag and metadata are preserved on the output schema
|
|
7
7
|
* (tableFromColumns would drop them, which the C++ extension rejects).
|
|
8
8
|
*/
|
|
9
|
-
export declare function writeCanonicalBatch(columns: Record<string, unknown[]>, schema: VgiSchema, numRows: number): VgiBatch;
|
|
9
|
+
export declare function writeCanonicalBatch(columns: Record<string, unknown[]>, schema: VgiSchema, numRows: number, maxBatchRows?: number): VgiBatch;
|
|
10
10
|
/**
|
|
11
11
|
* Convert canonical values into the shape flechette's columnFromArray needs.
|
|
12
12
|
* Date columns: canonical day-number / ms-bigint -> JS Date. Map columns:
|
|
@@ -9,6 +9,6 @@ export { filterBatch } from "./filter.js";
|
|
|
9
9
|
export { projectSchema, projectBatch } from "./project.js";
|
|
10
10
|
export { readCanonicalValue } from "./canonical.js";
|
|
11
11
|
export { withBatchMetadata } from "./metadata.js";
|
|
12
|
-
export { serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, } from "./ipc.js";
|
|
12
|
+
export { serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, deserializeBatches, serializeBatches, serializeCollectionRows, } from "./ipc.js";
|
|
13
13
|
export { buildStatisticsBatch, type ColumnStatistics } from "./statistics.js";
|
|
14
14
|
export { adoptArrowJsShape } from "./compat.js";
|
|
@@ -31,3 +31,9 @@ export declare function serializeBatch(batch: VgiBatch): Uint8Array;
|
|
|
31
31
|
* the subprocess transport's one-batch-per-call convention.
|
|
32
32
|
*/
|
|
33
33
|
export declare function deserializeBatch(input: Uint8Array): VgiBatch;
|
|
34
|
+
/** Flechette resolves all record batches and their dictionaries into one logical table. */
|
|
35
|
+
export declare function deserializeBatches(bytes: Uint8Array): VgiBatch[];
|
|
36
|
+
/** The input batches must share dictionaries; collection encoding builds them together. */
|
|
37
|
+
export declare function serializeBatches(batches: VgiBatch[], schema: VgiSchema): Uint8Array;
|
|
38
|
+
/** Build bounded batches together so their dictionary indices share one value table. */
|
|
39
|
+
export declare function serializeCollectionRows(schema: VgiSchema, rows: Record<string, any>[], maxBatchRows: number): Uint8Array;
|
package/dist/arrow/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { VgiTypeId, VgiDataType, VgiField, VgiSchema, VgiColumn, VgiColumnData, VgiBatch, VgiBackendInfo, TaggedUnion, } from "./types.js";
|
|
2
2
|
export { TypeId, isNull, isInt, isFloat, isBinary, isUtf8, isBool, isDecimal, isDate, isTime, isTimestamp, isInterval, isList, isStruct, isUnion, isFixedSizeBinary, isFixedSizeList, isMap, isDuration, isDictionary, isBatch, typeSignature, } from "./predicates.js";
|
|
3
|
-
export { backend, emptyBatch, batchFromRows, batchFromColumns, columnFromArray, iterRows, batchToScalarDict, batchToSecretDict, safeNumber, decodeDictValue, filterBatch, projectSchema, projectBatch, withBatchMetadata, adoptArrowJsShape, readCanonicalValue, serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, buildStatisticsBatch, } from "#arrow-impl";
|
|
3
|
+
export { backend, emptyBatch, batchFromRows, batchFromColumns, columnFromArray, iterRows, batchToScalarDict, batchToSecretDict, safeNumber, decodeDictValue, filterBatch, projectSchema, projectBatch, withBatchMetadata, adoptArrowJsShape, readCanonicalValue, serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, deserializeBatches, serializeBatches, serializeCollectionRows, buildStatisticsBatch, } from "#arrow-impl";
|
|
4
4
|
export type { ColumnStatistics } from "#arrow-impl";
|
|
5
5
|
export { schema, field, nullType, bool, int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, utf8, largeUtf8, binary, largeBinary, fixedSizeBinary, decimal, decimal128, decimal256, date, dateDay, dateMillisecond, time, timeSecond, timeMillisecond, timeMicrosecond, timeNanosecond, timestamp, duration, interval, timestampSeconds, timestampMillis, timestampMicros, timestampNanos, durationSeconds, durationMillis, durationMicros, durationNanos, list, fixedSizeList, struct, map, dictionary, union, sparseUnion, denseUnion, TimeUnit, DateUnit, IntervalUnit, UnionMode, } from "./schema-types.js";
|
|
6
6
|
export type { NullDescriptor, BoolType, IntType, Int8Type, Int16Type, Int32Type, Int64Type, Uint8Type, Uint16Type, Uint32Type, Uint64Type, FloatType, Utf8Type, LargeUtf8Type, BinaryType, LargeBinaryType, FixedSizeBinaryType, DecimalType, Date32Type, Date64Type, Time32Type, Time64Type, TimestampType, DurationType, IntervalType, ListType, FixedSizeListType, StructType, MapType, DictionaryType, UnionType, TypedField, TUnit, } from "./codec/type-descriptors.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CatalogContentsResponse } from "../generated/vgi-client.js";
|
|
2
|
+
import type { SchemaContentsInfo } from "./interface.js";
|
|
3
|
+
export declare const CATALOG_STREAM_KINDS: readonly ["schemas", "tables", "views", "functions", "macros", "indexes"];
|
|
4
|
+
export type CatalogStreams = Pick<CatalogContentsResponse, typeof CATALOG_STREAM_KINDS[number]>;
|
|
5
|
+
export declare function encodeCatalogStreams(inventory: readonly SchemaContentsInfo[]): CatalogStreams;
|
|
6
|
+
/** Preserve raw path components, overloads and every table-function subtype. */
|
|
7
|
+
export declare function decodeCatalogStreams(response: CatalogContentsResponse, ifNoneMatch?: string | null): SchemaContentsInfo[];
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* snapshot (the same item bytes) gives the same etag in every SDK.
|
|
6
6
|
*/
|
|
7
7
|
import type { SchemaContents } from "../generated/vgi-protocol-types.js";
|
|
8
|
+
import type { CatalogStreams } from "./contents-codec.js";
|
|
8
9
|
/**
|
|
9
10
|
* Hex SHA-256 over a `catalog_contents` snapshot: the `content-hash` etag.
|
|
10
11
|
*
|
|
@@ -22,4 +23,4 @@ import type { SchemaContents } from "../generated/vgi-protocol-types.js";
|
|
|
22
23
|
* @param schemas The snapshot, in wire order.
|
|
23
24
|
* @returns The lowercase hex digest.
|
|
24
25
|
*/
|
|
25
|
-
export declare function catalogContentsDigest(
|
|
26
|
+
export declare function catalogContentsDigest(streams: CatalogStreams | readonly SchemaContents[], version?: number): Promise<string>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CatalogSnapshotPolicy } from "./publication.js";
|
|
1
2
|
export type AttachOpaqueData = Uint8Array;
|
|
2
3
|
export type TransactionOpaqueData = Uint8Array;
|
|
3
4
|
import type { MacroType } from "../generated/vgi-client.js";
|
|
@@ -290,6 +291,8 @@ export interface CatalogContentsResult {
|
|
|
290
291
|
*/
|
|
291
292
|
type Awaitable<T> = T | Promise<T>;
|
|
292
293
|
export declare abstract class CatalogInterface {
|
|
294
|
+
/** Opt-in immutable external delivery for catalog_contents. */
|
|
295
|
+
catalogSnapshotPolicy: CatalogSnapshotPolicy | null;
|
|
293
296
|
/**
|
|
294
297
|
* Opt-in framework etag for `catalog_contents`. `"content-hash"`: when
|
|
295
298
|
* `catalogContents` returns no etag of its own, the worker uses the hex
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function validateCatalogPublicationEnvelope(bytes: Uint8Array): void;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { type ExternalStorage, type ExternalLocationConfig, type CallContext } from "@query-farm/vgi-rpc";
|
|
2
|
+
import type { CatalogContentsResponse } from "../generated/vgi-client.js";
|
|
3
|
+
import type { AttachOpaqueData, CatalogInterface } from "./interface.js";
|
|
4
|
+
export interface SnapshotIdentity {
|
|
5
|
+
catalogNamespace: string;
|
|
6
|
+
sourceRevision: string;
|
|
7
|
+
/** Explicit equivalence class for sharing; omitted by a handler defaults to the sealed attachment hash. */
|
|
8
|
+
visibilityScope?: string;
|
|
9
|
+
catalogVersion: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SnapshotRequest {
|
|
12
|
+
catalog: CatalogInterface;
|
|
13
|
+
attachOpaqueData: AttachOpaqueData;
|
|
14
|
+
callContext?: CallContext;
|
|
15
|
+
catalogVersion: number;
|
|
16
|
+
}
|
|
17
|
+
export interface CatalogPublicationManifest {
|
|
18
|
+
formatVersion: 1;
|
|
19
|
+
/** Unique repository generation for conditional invalidation and URL renewal. */
|
|
20
|
+
manifestId: string;
|
|
21
|
+
key: string;
|
|
22
|
+
protocolName: string;
|
|
23
|
+
protocolVersion: string;
|
|
24
|
+
contractHash: string;
|
|
25
|
+
codecRevision: 1;
|
|
26
|
+
catalogVersion: number;
|
|
27
|
+
etag: string;
|
|
28
|
+
sha256: string;
|
|
29
|
+
rawSize: number;
|
|
30
|
+
storedSize: number;
|
|
31
|
+
url: string;
|
|
32
|
+
objectId?: string;
|
|
33
|
+
expiresAt?: number;
|
|
34
|
+
retainUntil?: number;
|
|
35
|
+
stable: boolean;
|
|
36
|
+
validated: true;
|
|
37
|
+
}
|
|
38
|
+
export interface CatalogPublicationRepository {
|
|
39
|
+
/** Change when storage credentials, namespace or delivery profile change. */
|
|
40
|
+
readonly profile: string;
|
|
41
|
+
readonly storage: ExternalStorage;
|
|
42
|
+
/** Supply a bounded resolver (URL policy, fetch implementation, caps). */
|
|
43
|
+
readonly resolver: ExternalLocationConfig;
|
|
44
|
+
lookup(key: string): Promise<CatalogPublicationManifest | null>;
|
|
45
|
+
/** Atomic create-if-absent; return the committed manifest, including another publisher's winner. */
|
|
46
|
+
commitIfAbsent(manifest: CatalogPublicationManifest): Promise<CatalogPublicationManifest>;
|
|
47
|
+
invalidate(key: string, expected: CatalogPublicationManifest): Promise<void>;
|
|
48
|
+
/** Renew the URL without changing the object's identity, content or retention. */
|
|
49
|
+
renew?(manifest: CatalogPublicationManifest): Promise<CatalogPublicationManifest | null>;
|
|
50
|
+
/** Require either explicit stability or a URL expiration time. */
|
|
51
|
+
describe(url: string): Promise<Pick<CatalogPublicationManifest, "objectId" | "expiresAt" | "retainUntil" | "stable">>;
|
|
52
|
+
}
|
|
53
|
+
export interface CatalogSnapshotPolicy {
|
|
54
|
+
delivery: "ordinary" | "published";
|
|
55
|
+
repository: CatalogPublicationRepository;
|
|
56
|
+
identity(request: SnapshotRequest): SnapshotIdentity | Promise<SnapshotIdentity>;
|
|
57
|
+
onPublicationFailure?: "error" | "ordinary";
|
|
58
|
+
compression?: "identity" | "gzip" | "zstd";
|
|
59
|
+
maxRawBytes?: number;
|
|
60
|
+
maxStoredBytes?: number;
|
|
61
|
+
maxCachedManifests?: number;
|
|
62
|
+
referenceGraceMs?: number;
|
|
63
|
+
/** Optional cheap validator; avoids constructing even a first publication for a conditional hit. */
|
|
64
|
+
etag?(request: SnapshotRequest): string | null | Promise<string | null>;
|
|
65
|
+
}
|
|
66
|
+
/** Memory repository is useful for tests and process-local reuse; storage stays caller-owned. */
|
|
67
|
+
export declare class MemoryCatalogPublicationRepository implements CatalogPublicationRepository {
|
|
68
|
+
readonly profile: string;
|
|
69
|
+
readonly storage: ExternalStorage;
|
|
70
|
+
readonly resolver: ExternalLocationConfig;
|
|
71
|
+
readonly describe: CatalogPublicationRepository["describe"];
|
|
72
|
+
private manifests;
|
|
73
|
+
constructor(profile: string, storage: ExternalStorage, resolver: ExternalLocationConfig, describe: CatalogPublicationRepository["describe"]);
|
|
74
|
+
lookup(key: string): Promise<CatalogPublicationManifest | null>;
|
|
75
|
+
commitIfAbsent(manifest: CatalogPublicationManifest): Promise<Readonly<{
|
|
76
|
+
formatVersion: 1;
|
|
77
|
+
/** Unique repository generation for conditional invalidation and URL renewal. */
|
|
78
|
+
manifestId: string;
|
|
79
|
+
key: string;
|
|
80
|
+
protocolName: string;
|
|
81
|
+
protocolVersion: string;
|
|
82
|
+
contractHash: string;
|
|
83
|
+
codecRevision: 1;
|
|
84
|
+
catalogVersion: number;
|
|
85
|
+
etag: string;
|
|
86
|
+
sha256: string;
|
|
87
|
+
rawSize: number;
|
|
88
|
+
storedSize: number;
|
|
89
|
+
url: string;
|
|
90
|
+
objectId?: string;
|
|
91
|
+
expiresAt?: number;
|
|
92
|
+
retainUntil?: number;
|
|
93
|
+
stable: boolean;
|
|
94
|
+
validated: true;
|
|
95
|
+
}>>;
|
|
96
|
+
invalidate(key: string, expected: CatalogPublicationManifest): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
/** A small S3-compatible client surface; adapters map these conditions to If-None-Match / If-Match. */
|
|
99
|
+
export interface CatalogManifestObjectStore {
|
|
100
|
+
get(key: string): Promise<{
|
|
101
|
+
body: Uint8Array;
|
|
102
|
+
etag: string;
|
|
103
|
+
} | null>;
|
|
104
|
+
put(key: string, body: Uint8Array, condition: {
|
|
105
|
+
ifNoneMatch: "*";
|
|
106
|
+
} | {
|
|
107
|
+
ifMatch: string;
|
|
108
|
+
}): Promise<boolean>;
|
|
109
|
+
delete(key: string, condition: {
|
|
110
|
+
ifMatch: string;
|
|
111
|
+
}): Promise<boolean>;
|
|
112
|
+
}
|
|
113
|
+
/** Durable manifest repository, usable with S3/R2 conditional object operations and any RPC uploader. */
|
|
114
|
+
export declare class S3CatalogPublicationRepository implements CatalogPublicationRepository {
|
|
115
|
+
readonly profile: string;
|
|
116
|
+
readonly storage: ExternalStorage;
|
|
117
|
+
readonly resolver: ExternalLocationConfig;
|
|
118
|
+
private readonly objects;
|
|
119
|
+
readonly describe: CatalogPublicationRepository["describe"];
|
|
120
|
+
private readonly prefix;
|
|
121
|
+
renewReference?: (manifest: CatalogPublicationManifest) => Promise<CatalogPublicationManifest | null>;
|
|
122
|
+
constructor(profile: string, storage: ExternalStorage, resolver: ExternalLocationConfig, objects: CatalogManifestObjectStore, describe: CatalogPublicationRepository["describe"], prefix?: string);
|
|
123
|
+
private objectKey;
|
|
124
|
+
lookup(key: string): Promise<CatalogPublicationManifest | null>;
|
|
125
|
+
commitIfAbsent(manifest: CatalogPublicationManifest): Promise<CatalogPublicationManifest>;
|
|
126
|
+
renew(manifest: CatalogPublicationManifest): Promise<CatalogPublicationManifest | null>;
|
|
127
|
+
invalidate(key: string, expected: CatalogPublicationManifest): Promise<void>;
|
|
128
|
+
}
|
|
129
|
+
export declare class CatalogSnapshotManager {
|
|
130
|
+
readonly policy: CatalogSnapshotPolicy;
|
|
131
|
+
private cached;
|
|
132
|
+
private pending;
|
|
133
|
+
constructor(policy: CatalogSnapshotPolicy);
|
|
134
|
+
private usable;
|
|
135
|
+
key(identity: SnapshotIdentity): Promise<string>;
|
|
136
|
+
private remember;
|
|
137
|
+
invalidate(key: string): Promise<void>;
|
|
138
|
+
private validate;
|
|
139
|
+
import(manifest: CatalogPublicationManifest, identity: SnapshotIdentity): Promise<CatalogPublicationManifest>;
|
|
140
|
+
warm(identity: SnapshotIdentity, build: () => Promise<CatalogContentsResponse>): Promise<CatalogPublicationManifest>;
|
|
141
|
+
private recoverOrPublish;
|
|
142
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ExternalStorage, ExternalLocationConfig } from "@query-farm/vgi-rpc";
|
|
2
|
+
import { S3CatalogPublicationRepository, type CatalogManifestObjectStore, type CatalogPublicationManifest } from "./publication.js";
|
|
3
|
+
/** Sign an S3/R2 request using the application's existing credentials/SDK.
|
|
4
|
+
* Include the supplied headers when signing; they are sent exactly as given. */
|
|
5
|
+
export type CatalogS3Signer = (request: {
|
|
6
|
+
key: string;
|
|
7
|
+
method: "GET" | "PUT" | "DELETE";
|
|
8
|
+
headers: Record<string, string>;
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
url: string;
|
|
11
|
+
expiresAt?: number;
|
|
12
|
+
stable?: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
/** Concrete S3 HTTP adapter with conditional manifest operations and immutable objects.
|
|
15
|
+
* A signer keeps AWS/R2 credentials out of the framework and stored manifests. */
|
|
16
|
+
export declare class S3CatalogObjectStorage implements ExternalStorage, CatalogManifestObjectStore {
|
|
17
|
+
readonly sign: CatalogS3Signer;
|
|
18
|
+
private readonly request;
|
|
19
|
+
private readonly objectPrefix;
|
|
20
|
+
private readonly retentionMs?;
|
|
21
|
+
private locations;
|
|
22
|
+
constructor(sign: CatalogS3Signer, request?: typeof fetch, objectPrefix?: string, retentionMs?: number | undefined);
|
|
23
|
+
upload(data: Uint8Array, contentEncoding: string): Promise<string>;
|
|
24
|
+
describe(url: string): Promise<Pick<CatalogPublicationManifest, "expiresAt" | "objectId" | "retainUntil" | "stable">>;
|
|
25
|
+
get(key: string): Promise<{
|
|
26
|
+
body: Uint8Array<ArrayBuffer>;
|
|
27
|
+
etag: string;
|
|
28
|
+
} | null>;
|
|
29
|
+
put(key: string, body: Uint8Array, condition: {
|
|
30
|
+
ifNoneMatch: "*";
|
|
31
|
+
} | {
|
|
32
|
+
ifMatch: string;
|
|
33
|
+
}): Promise<boolean>;
|
|
34
|
+
delete(key: string, condition: {
|
|
35
|
+
ifMatch: string;
|
|
36
|
+
}): Promise<boolean>;
|
|
37
|
+
repository(profile: string, resolver?: Omit<ExternalLocationConfig, "storage">, manifestPrefix?: string): S3CatalogPublicationRepository;
|
|
38
|
+
}
|
package/dist/client-entry.js
CHANGED
|
@@ -39,6 +39,7 @@ __export(exports_impl_arrowjs, {
|
|
|
39
39
|
decodeDictValue: () => decodeDictValue,
|
|
40
40
|
denseUnion: () => denseUnion,
|
|
41
41
|
deserializeBatch: () => deserializeBatch,
|
|
42
|
+
deserializeBatches: () => deserializeBatches,
|
|
42
43
|
deserializeSchema: () => deserializeSchema,
|
|
43
44
|
dictionary: () => dictionary,
|
|
44
45
|
duration: () => duration,
|
|
@@ -68,6 +69,8 @@ __export(exports_impl_arrowjs, {
|
|
|
68
69
|
safeNumber: () => safeNumber,
|
|
69
70
|
schema: () => schema,
|
|
70
71
|
serializeBatch: () => serializeBatch,
|
|
72
|
+
serializeBatches: () => serializeBatches,
|
|
73
|
+
serializeCollectionRows: () => serializeCollectionRows,
|
|
71
74
|
serializeSchema: () => serializeSchema,
|
|
72
75
|
sparseUnion: () => sparseUnion,
|
|
73
76
|
struct: () => struct,
|
|
@@ -1732,6 +1735,24 @@ function deserializeBatch(bytes) {
|
|
|
1732
1735
|
}
|
|
1733
1736
|
return batches[0];
|
|
1734
1737
|
}
|
|
1738
|
+
function deserializeBatches(bytes) {
|
|
1739
|
+
return [...RecordBatchReader.from(bytes)];
|
|
1740
|
+
}
|
|
1741
|
+
function serializeBatches(batches, schema) {
|
|
1742
|
+
const writer = new RecordBatchStreamWriter;
|
|
1743
|
+
writer.reset(undefined, schema);
|
|
1744
|
+
for (const batch of batches)
|
|
1745
|
+
writer._writeRecordBatch(batch);
|
|
1746
|
+
writer.close();
|
|
1747
|
+
return writer.toUint8Array(true);
|
|
1748
|
+
}
|
|
1749
|
+
function serializeCollectionRows(schema, rows, maxBatchRows) {
|
|
1750
|
+
const batch = batchFromRows(rows, schema);
|
|
1751
|
+
const batches = [];
|
|
1752
|
+
for (let offset = 0;offset < batch.numRows; offset += maxBatchRows)
|
|
1753
|
+
batches.push(batch.slice(offset, offset + maxBatchRows));
|
|
1754
|
+
return serializeBatches(batches, schema);
|
|
1755
|
+
}
|
|
1735
1756
|
// src/arrow/impl-arrowjs/statistics.ts
|
|
1736
1757
|
import {
|
|
1737
1758
|
Field as Field3,
|
|
@@ -2098,7 +2119,9 @@ function mapPairs(raw) {
|
|
|
2098
2119
|
return Object.entries(raw);
|
|
2099
2120
|
}
|
|
2100
2121
|
function zeroValue(type) {
|
|
2101
|
-
if (
|
|
2122
|
+
if (isDictionary(type))
|
|
2123
|
+
return zeroValue(type.dictionary);
|
|
2124
|
+
if (isUtf8(type))
|
|
2102
2125
|
return "";
|
|
2103
2126
|
if (isBinary(type))
|
|
2104
2127
|
return new Uint8Array(0);
|
|
@@ -2537,7 +2560,7 @@ function normalizeValue(raw, type) {
|
|
|
2537
2560
|
return out;
|
|
2538
2561
|
}
|
|
2539
2562
|
if (isDictionary(type)) {
|
|
2540
|
-
return raw
|
|
2563
|
+
return normalizeValue(raw, type.dictionary);
|
|
2541
2564
|
}
|
|
2542
2565
|
if (isBinary(type)) {
|
|
2543
2566
|
return toUint8Array3(raw);
|
|
@@ -2566,6 +2589,35 @@ function toUint8Array3(val) {
|
|
|
2566
2589
|
}
|
|
2567
2590
|
return new Uint8Array(0);
|
|
2568
2591
|
}
|
|
2592
|
+
function decodeASDCollection(schema, bytes) {
|
|
2593
|
+
if (bytes == null)
|
|
2594
|
+
return [];
|
|
2595
|
+
const output = [];
|
|
2596
|
+
const batches = deserializeBatches(bytes);
|
|
2597
|
+
const validateSchema = (actualSchema) => {
|
|
2598
|
+
if (actualSchema.fields.length !== schema.fields.length || schema.fields.some((field, i) => {
|
|
2599
|
+
const actual = actualSchema.fields[i];
|
|
2600
|
+
return actual.name !== field.name || actual.nullable !== field.nullable || typeSignature(actual.type) !== typeSignature(field.type);
|
|
2601
|
+
}))
|
|
2602
|
+
throw new Error("catalog collection has an incompatible metadata schema");
|
|
2603
|
+
};
|
|
2604
|
+
if (batches.length === 0)
|
|
2605
|
+
validateSchema(deserializeSchema(bytes));
|
|
2606
|
+
for (const batch of batches) {
|
|
2607
|
+
validateSchema(batch.schema);
|
|
2608
|
+
for (let row = 0;row < batch.numRows; row++) {
|
|
2609
|
+
const item = {};
|
|
2610
|
+
for (const field of schema.fields) {
|
|
2611
|
+
const value = batch.getChild(field.name)?.get(row);
|
|
2612
|
+
if (value == null && !field.nullable)
|
|
2613
|
+
throw new Error(`catalog collection has null ${field.name}`);
|
|
2614
|
+
item[field.name] = normalizeValue(value, field.type);
|
|
2615
|
+
}
|
|
2616
|
+
output.push(item);
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
return output;
|
|
2620
|
+
}
|
|
2569
2621
|
|
|
2570
2622
|
// src/generated/vgi-protocol-schemas.ts
|
|
2571
2623
|
var CatalogInfoSchema = schema2([
|
|
@@ -2579,7 +2631,6 @@ var CatalogInfoSchema = schema2([
|
|
|
2579
2631
|
var SchemaInfoSchema = schema2([
|
|
2580
2632
|
field2("comment", utf82(), true),
|
|
2581
2633
|
field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
|
|
2582
|
-
field2("attach_opaque_data", binary2(), false),
|
|
2583
2634
|
field2("path", list2(field2("item", utf82(), true)), false),
|
|
2584
2635
|
field2("estimated_object_count", map2(field2("key", utf82(), false), field2("value", int642(), true), false), true)
|
|
2585
2636
|
]);
|
|
@@ -2620,9 +2671,9 @@ var FunctionInfoSchema = schema2([
|
|
|
2620
2671
|
field2("name", utf82(), false),
|
|
2621
2672
|
field2("schema_path", list2(field2("item", utf82(), true)), false),
|
|
2622
2673
|
field2("function_type", dictionary2(utf82(), int162()), false),
|
|
2623
|
-
field2("arguments", binary2(), false),
|
|
2624
|
-
field2("output_schema", binary2(), false),
|
|
2625
|
-
field2("parameter_default_values", binary2(), true),
|
|
2674
|
+
field2("arguments", dictionary2(binary2(), int322()), false),
|
|
2675
|
+
field2("output_schema", dictionary2(binary2(), int322()), false),
|
|
2676
|
+
field2("parameter_default_values", dictionary2(binary2(), int322()), true),
|
|
2626
2677
|
field2("stability", dictionary2(utf82(), int162()), true),
|
|
2627
2678
|
field2("null_handling", dictionary2(utf82(), int162()), true),
|
|
2628
2679
|
field2("argument_monotonicity", list2(field2("item", utf82(), true)), true),
|
|
@@ -3083,7 +3134,12 @@ var CatalogContentsResultSchema = schema2([
|
|
|
3083
3134
|
field2("catalog_version", int642(), false),
|
|
3084
3135
|
field2("etag", utf82(), true),
|
|
3085
3136
|
field2("not_modified", bool2(), false),
|
|
3086
|
-
field2("schemas",
|
|
3137
|
+
field2("schemas", binary2(), true),
|
|
3138
|
+
field2("tables", binary2(), true),
|
|
3139
|
+
field2("views", binary2(), true),
|
|
3140
|
+
field2("functions", binary2(), true),
|
|
3141
|
+
field2("macros", binary2(), true),
|
|
3142
|
+
field2("indexes", binary2(), true)
|
|
3087
3143
|
]);
|
|
3088
3144
|
var CatalogCopyFromFormatsResultSchema = schema2([
|
|
3089
3145
|
field2("items", list2(field2("item", binary2(), true)), false)
|
|
@@ -3702,6 +3758,77 @@ function wrapRpcWithErrorEnrichment(rpc) {
|
|
|
3702
3758
|
};
|
|
3703
3759
|
}
|
|
3704
3760
|
|
|
3761
|
+
// src/catalog/contents-codec.ts
|
|
3762
|
+
var schemaPathKey = (path) => JSON.stringify(path.map((part) => part.toLowerCase()));
|
|
3763
|
+
var CATALOG_STREAM_KINDS = ["schemas", "tables", "views", "functions", "macros", "indexes"];
|
|
3764
|
+
function decodeCatalogStreams(response, ifNoneMatch) {
|
|
3765
|
+
if (response.not_modified) {
|
|
3766
|
+
if (response.etag == null || ifNoneMatch !== undefined && response.etag !== ifNoneMatch || CATALOG_STREAM_KINDS.some((kind) => response[kind] != null)) {
|
|
3767
|
+
throw new Error("invalid catalog_contents not_modified response");
|
|
3768
|
+
}
|
|
3769
|
+
return [];
|
|
3770
|
+
}
|
|
3771
|
+
const infos = decodeASDCollection(SchemaInfoSchema, response.schemas);
|
|
3772
|
+
const schemas = [];
|
|
3773
|
+
const index = new Map;
|
|
3774
|
+
for (const schema of infos) {
|
|
3775
|
+
if (!Array.isArray(schema.path) || schema.path.length === 0)
|
|
3776
|
+
throw new Error("catalog schema has an empty path");
|
|
3777
|
+
const key = schemaPathKey(schema.path);
|
|
3778
|
+
if (index.has(key))
|
|
3779
|
+
throw new Error("catalog contains duplicate schema paths");
|
|
3780
|
+
if (schema.path.length > 1 && !index.has(schemaPathKey(schema.path.slice(0, -1)))) {
|
|
3781
|
+
throw new Error("catalog schema is missing its preceding parent");
|
|
3782
|
+
}
|
|
3783
|
+
const entry = { schema, tables: [], views: [], scalar_functions: [], aggregate_functions: [], table_functions: [], scalar_macros: [], table_macros: [], indexes: [] };
|
|
3784
|
+
index.set(key, entry);
|
|
3785
|
+
schemas.push(entry);
|
|
3786
|
+
}
|
|
3787
|
+
const owner = (item) => {
|
|
3788
|
+
const entry = index.get(schemaPathKey(item.schema_path));
|
|
3789
|
+
if (!entry)
|
|
3790
|
+
throw new Error("catalog object references an absent schema");
|
|
3791
|
+
return entry;
|
|
3792
|
+
};
|
|
3793
|
+
for (const item of decodeASDCollection(TableInfoSchema, response.tables))
|
|
3794
|
+
owner(item).tables.push(item);
|
|
3795
|
+
for (const item of decodeASDCollection(ViewInfoSchema, response.views))
|
|
3796
|
+
owner(item).views.push(item);
|
|
3797
|
+
for (const item of decodeASDCollection(FunctionInfoSchema, response.functions)) {
|
|
3798
|
+
const entry = owner(item);
|
|
3799
|
+
switch (String(item.function_type).toUpperCase()) {
|
|
3800
|
+
case "SCALAR":
|
|
3801
|
+
entry.scalar_functions.push(item);
|
|
3802
|
+
break;
|
|
3803
|
+
case "AGGREGATE":
|
|
3804
|
+
entry.aggregate_functions.push(item);
|
|
3805
|
+
break;
|
|
3806
|
+
case "TABLE":
|
|
3807
|
+
case "TABLE_BUFFERING":
|
|
3808
|
+
entry.table_functions.push(item);
|
|
3809
|
+
break;
|
|
3810
|
+
default:
|
|
3811
|
+
throw new Error(`unknown catalog function type ${item.function_type}`);
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3814
|
+
for (const item of decodeASDCollection(MacroInfoSchema, response.macros)) {
|
|
3815
|
+
const entry = owner(item);
|
|
3816
|
+
switch (String(item.macro_type).toUpperCase()) {
|
|
3817
|
+
case "SCALAR":
|
|
3818
|
+
entry.scalar_macros.push(item);
|
|
3819
|
+
break;
|
|
3820
|
+
case "TABLE":
|
|
3821
|
+
entry.table_macros.push(item);
|
|
3822
|
+
break;
|
|
3823
|
+
default:
|
|
3824
|
+
throw new Error(`unknown catalog macro type ${item.macro_type}`);
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
for (const item of decodeASDCollection(IndexInfoSchema, response.indexes))
|
|
3828
|
+
owner(item).indexes.push(item);
|
|
3829
|
+
return schemas;
|
|
3830
|
+
}
|
|
3831
|
+
|
|
3705
3832
|
// src/client/helpers.ts
|
|
3706
3833
|
function deserializeInfoList(items, deserializeFn) {
|
|
3707
3834
|
if (!items)
|
|
@@ -4075,23 +4202,7 @@ class VgiClient {
|
|
|
4075
4202
|
if (!result)
|
|
4076
4203
|
throw new VgiClientError("catalog_contents returned null");
|
|
4077
4204
|
const response = decodeCatalogContentsResponse(toUint8Array(result.result));
|
|
4078
|
-
const schemas = response
|
|
4079
|
-
const schema = decodeSchemaInfo(c.schema);
|
|
4080
|
-
if (JSON.stringify(c.path) !== JSON.stringify(schema.path)) {
|
|
4081
|
-
throw new VgiClientError(`catalog_contents: SchemaContents.path ${JSON.stringify(c.path)} != SchemaInfo.path ${JSON.stringify(schema.path)}`);
|
|
4082
|
-
}
|
|
4083
|
-
return {
|
|
4084
|
-
schema,
|
|
4085
|
-
tables: c.tables.map(decodeTableInfo),
|
|
4086
|
-
views: c.views.map(decodeViewInfo),
|
|
4087
|
-
scalar_functions: c.scalar_functions.map(decodeFunctionInfo),
|
|
4088
|
-
aggregate_functions: c.aggregate_functions.map(decodeFunctionInfo),
|
|
4089
|
-
table_functions: c.table_functions.map(decodeFunctionInfo),
|
|
4090
|
-
scalar_macros: c.scalar_macros.map(decodeMacroInfo),
|
|
4091
|
-
table_macros: c.table_macros.map(decodeMacroInfo),
|
|
4092
|
-
indexes: c.indexes.map(decodeIndexInfo)
|
|
4093
|
-
};
|
|
4094
|
-
});
|
|
4205
|
+
const schemas = decodeCatalogStreams(response, ifNoneMatch);
|
|
4095
4206
|
return {
|
|
4096
4207
|
catalog_version: Number(response.catalog_version ?? 0),
|
|
4097
4208
|
etag: response.etag ?? null,
|
|
@@ -4764,4 +4875,4 @@ export {
|
|
|
4764
4875
|
typeSignature
|
|
4765
4876
|
};
|
|
4766
4877
|
|
|
4767
|
-
//# debugId=
|
|
4878
|
+
//# debugId=D223782952AA2BC964756E2164756E21
|