@query-farm/vgi 0.44.0 → 0.46.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/README.md +8 -1
- 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 +2 -2
- package/dist/arrow/impl-flechette/index.d.ts +1 -1
- package/dist/arrow/impl-flechette/ipc.d.ts +6 -0
- package/dist/arrow/impl-flechette/schema.d.ts +19 -5
- 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/client.d.ts +20 -1
- package/dist/client-entry.js +189 -37
- package/dist/client-entry.js.map +15 -12
- package/dist/codec/asd.d.ts +4 -0
- package/dist/functions/continuation.d.ts +69 -0
- package/dist/functions/table-in-out.d.ts +51 -7
- package/dist/functions/types.d.ts +20 -0
- package/dist/generated/vgi-client.d.ts +7 -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.core.d.ts +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +981 -138
- package/dist/index.js.map +31 -25
- package/dist/protocol/dispatch.d.ts +1 -1
- package/dist/protocol/handlers/catalog/contents.d.ts +4 -4
- package/dist/serve-entry.js +643 -81
- package/dist/serve-entry.js.map +22 -18
- package/dist/util/parent-rows.d.ts +8 -0
- package/dist/worker-cf-entry.d.ts +1 -1
- package/dist/worker-cf-entry.js +821 -131
- package/dist/worker-cf-entry.js.map +29 -24
- package/package.json +4 -4
- 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 +14 -7
- 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 +6 -2
- package/src/catalog/s3-publication.ts +81 -0
- package/src/client/client.ts +82 -30
- package/src/codec/asd.ts +40 -1
- package/src/codec/conform.ts +2 -1
- package/src/filter-pushdown/collector.ts +17 -1
- package/src/functions/continuation.ts +202 -0
- package/src/functions/table-in-out.ts +131 -56
- package/src/functions/types.ts +20 -0
- package/src/generated/vgi-client.ts +8 -16
- package/src/generated/vgi-protocol-schemas.ts +14 -6
- package/src/generated/vgi-protocol-types.ts +39 -5
- package/src/generated/vgi-service.ts +4 -3
- package/src/index.core.ts +6 -0
- 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
- package/src/protocol/handlers/function.ts +12 -0
- package/src/protocol/state-serializer.ts +7 -1
- package/src/util/parent-rows.ts +41 -0
- package/src/worker-cf-entry.ts +3 -0
package/README.md
CHANGED
|
@@ -226,7 +226,14 @@ Five factories, each mapping to a DuckDB function shape with its own lifecycle:
|
|
|
226
226
|
- **`defineTableInOutFunction`** — table-in / table-out
|
|
227
227
|
(`SELECT * FROM f(TABLE t, …)`). Per-partition `state`, a streaming `process` per
|
|
228
228
|
input batch, and a `finalize` that sees every worker's state — for windowing,
|
|
229
|
-
reshaping, enrichment, sessionization.
|
|
229
|
+
reshaping, enrichment, sessionization. `defineRowTransformFunction` is its
|
|
230
|
+
blended form, whose positional args are per-row input columns
|
|
231
|
+
(`FROM t, f(t.x)`); `inputRowsPerCall` caps the input rows one call receives.
|
|
232
|
+
Either can answer one input with several replies (an upstream API read a page
|
|
233
|
+
at a time): emit each reply but the last with `moreOutputMetadata(true)`, and
|
|
234
|
+
implement `resume(params, state, out)`, which the framework calls for each
|
|
235
|
+
next reply. It continues from `initialState`'s state alone, which over HTTP
|
|
236
|
+
rides the stream's state token, so keep positions there, not rows.
|
|
230
237
|
- **`defineTableBufferingFunction`** — table-in / table-out that must observe **all**
|
|
231
238
|
input before producing output (global sort, top-N, pivot). Sink (`process`) →
|
|
232
239
|
`combine` → source (`finalize`), with explicit sink/source ordering controls.
|
|
@@ -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,10 +6,10 @@ 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
|
+
* Date32 columns: canonical day-number -> JS Date; Date64 stays ms-bigint. Map columns:
|
|
13
13
|
* canonical Array<[k,v]> -> Map. Struct/List recurse. Everything else passes
|
|
14
14
|
* through.
|
|
15
15
|
*/
|
|
@@ -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;
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
import { TimeUnit as F_TimeUnit, DateUnit as F_DateUnit, IntervalUnit as F_IntervalUnit, UnionMode as F_UnionMode } from "@query-farm/flechette";
|
|
2
1
|
import type { VgiField, VgiSchema, VgiDataType } from "../types.js";
|
|
3
|
-
export declare const TimeUnit:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
export declare const TimeUnit: {
|
|
3
|
+
readonly SECOND: 0;
|
|
4
|
+
readonly MILLISECOND: 1;
|
|
5
|
+
readonly MICROSECOND: 2;
|
|
6
|
+
readonly NANOSECOND: 3;
|
|
7
|
+
};
|
|
8
|
+
export declare const DateUnit: {
|
|
9
|
+
readonly DAY: 0;
|
|
10
|
+
readonly MILLISECOND: 1;
|
|
11
|
+
};
|
|
12
|
+
export declare const IntervalUnit: {
|
|
13
|
+
readonly YEAR_MONTH: 0;
|
|
14
|
+
readonly DAY_TIME: 1;
|
|
15
|
+
readonly MONTH_DAY_NANO: 2;
|
|
16
|
+
};
|
|
17
|
+
export declare const UnionMode: {
|
|
18
|
+
readonly Sparse: 0;
|
|
19
|
+
readonly Dense: 1;
|
|
20
|
+
};
|
|
7
21
|
export declare function schema(fields: readonly VgiField[], metadata?: Map<string, string>): VgiSchema;
|
|
8
22
|
export declare function field(name: string, type: VgiDataType, nullable?: boolean, metadata?: Map<string, string>): VgiField;
|
|
9
23
|
export declare const nullType: () => VgiDataType;
|
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/client.d.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { type VgiBatch } from "../arrow/index.js";
|
|
2
|
-
import type { RpcClient } from "@query-farm/vgi-rpc";
|
|
2
|
+
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
6
|
import type { VgiClientOptions, TableFunctionOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, CatalogMacroType, CatalogAttachOptions, AttachOptionValue, CatalogSnapshot, LoadCatalogOptions } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Send one input batch on a table-in-out exchange and yield the rows of every
|
|
9
|
+
* reply it gets (continued output, docs/table_in_out.md "Continued Output").
|
|
10
|
+
*
|
|
11
|
+
* A reply saying `vgi.status: HAVE_MORE_OUTPUT` has more output for the same
|
|
12
|
+
* input: ask for the next with a continuation tick (a zero-row batch of the
|
|
13
|
+
* input schema carrying `vgi.status: CONTINUE`) until a reply stops saying
|
|
14
|
+
* more. Only then may the next input go out, or the input close. The row-level
|
|
15
|
+
* `StreamSession.exchange` drops reply metadata, so this uses the raw exchange
|
|
16
|
+
* every transport's session implements.
|
|
17
|
+
*
|
|
18
|
+
* Refused, as the extension refuses them: `not_modified` on a reply that says
|
|
19
|
+
* more or answers a tick (a 304 stands for an input's whole output), and the
|
|
20
|
+
* worker ending the stream while output is pending.
|
|
21
|
+
*
|
|
22
|
+
* Exported for tests only (not re-exported from the package entry points).
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export declare function exchangeContinued(session: StreamSession, functionName: string, input: VgiBatch): AsyncGenerator<Record<string, any>[]>;
|
|
7
26
|
/**
|
|
8
27
|
* High-level client for calling VGI worker functions and catalog API.
|
|
9
28
|
*
|