@query-farm/vgi 0.43.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.
Files changed (73) hide show
  1. package/README.md +5 -2
  2. package/dist/arrow/impl-arrowjs/index.d.ts +1 -1
  3. package/dist/arrow/impl-arrowjs/ipc.d.ts +6 -0
  4. package/dist/arrow/impl-flechette/build.d.ts +2 -2
  5. package/dist/arrow/impl-flechette/canonical.d.ts +1 -1
  6. package/dist/arrow/impl-flechette/index.d.ts +1 -1
  7. package/dist/arrow/impl-flechette/ipc.d.ts +6 -0
  8. package/dist/arrow/index.d.ts +1 -1
  9. package/dist/attach-ticket.d.ts +18 -7
  10. package/dist/catalog/contents-codec.d.ts +7 -0
  11. package/dist/catalog/contents-digest.d.ts +2 -1
  12. package/dist/catalog/interface.d.ts +3 -0
  13. package/dist/catalog/publication-envelope.d.ts +1 -0
  14. package/dist/catalog/publication.d.ts +142 -0
  15. package/dist/catalog/s3-publication.d.ts +38 -0
  16. package/dist/client-entry.js +349 -114
  17. package/dist/client-entry.js.map +16 -14
  18. package/dist/codec/asd.d.ts +7 -1
  19. package/dist/codec/conform.d.ts +51 -0
  20. package/dist/errors.d.ts +5 -1
  21. package/dist/generated/vgi-client.d.ts +6 -14
  22. package/dist/generated/vgi-protocol-schemas.d.ts +2 -0
  23. package/dist/generated/vgi-protocol-types.d.ts +26 -3
  24. package/dist/generated/vgi-service.d.ts +3 -3
  25. package/dist/index.core.d.ts +1 -1
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.js +955 -118
  28. package/dist/index.js.map +33 -28
  29. package/dist/protocol/dispatch.d.ts +1 -1
  30. package/dist/protocol/handlers/catalog/contents.d.ts +4 -4
  31. package/dist/protocol/handlers/shared.d.ts +2 -1
  32. package/dist/protocol/serializers/shared.d.ts +2 -1
  33. package/dist/rpc-server.d.ts +2 -2
  34. package/dist/serve-entry.js +867 -165
  35. package/dist/serve-entry.js.map +26 -22
  36. package/dist/worker-cf-entry.js +825 -114
  37. package/dist/worker-cf-entry.js.map +31 -27
  38. package/package.json +3 -3
  39. package/src/arrow/impl-arrowjs/index.ts +1 -0
  40. package/src/arrow/impl-arrowjs/ipc.ts +23 -0
  41. package/src/arrow/impl-flechette/build.ts +4 -2
  42. package/src/arrow/impl-flechette/canonical.ts +7 -2
  43. package/src/arrow/impl-flechette/index.ts +1 -0
  44. package/src/arrow/impl-flechette/ipc.ts +19 -0
  45. package/src/arrow/index.ts +1 -1
  46. package/src/attach-ticket.ts +41 -13
  47. package/src/catalog/composite.ts +2 -1
  48. package/src/catalog/contents-codec.ts +77 -0
  49. package/src/catalog/contents-digest.ts +20 -17
  50. package/src/catalog/interface.ts +8 -4
  51. package/src/catalog/publication-envelope.ts +62 -0
  52. package/src/catalog/publication.ts +290 -0
  53. package/src/catalog/read-only.ts +8 -8
  54. package/src/catalog/s3-publication.ts +81 -0
  55. package/src/client/client.ts +15 -24
  56. package/src/codec/asd.ts +45 -3
  57. package/src/codec/conform.ts +194 -0
  58. package/src/errors.ts +27 -7
  59. package/src/functions/registry.ts +3 -2
  60. package/src/generated/vgi-client.ts +7 -16
  61. package/src/generated/vgi-protocol-schemas.ts +13 -6
  62. package/src/generated/vgi-protocol-types.ts +39 -5
  63. package/src/generated/vgi-service.ts +4 -3
  64. package/src/http/fetch.ts +1 -1
  65. package/src/index.core.ts +3 -1
  66. package/src/index.ts +5 -0
  67. package/src/protocol/dispatch.ts +1 -1
  68. package/src/protocol/handlers/catalog/admin.ts +7 -4
  69. package/src/protocol/handlers/catalog/contents.ts +50 -35
  70. package/src/protocol/handlers/shared.ts +8 -2
  71. package/src/protocol/serializers/bind.ts +3 -1
  72. package/src/protocol/serializers/shared.ts +5 -2
  73. package/src/rpc-server.ts +7 -7
package/README.md CHANGED
@@ -572,9 +572,9 @@ new Worker({ functions, hostedProtocols: () => [reports] }).run();
572
572
  changes how DuckDB's `vgi.v2` calls are dispatched.
573
573
  - The protocol is the unit of optionality: an optional capability is its own protocol.
574
574
 
575
- ### Token introspection and grants (`vgi_rpc.Identity.v1`)
575
+ ### Token introspection and grants (`vgi_rpc.Identity.v2`)
576
576
 
577
- A worker opts into `vgi_rpc.Identity.v1` by supplying `resolveToken` and/or
577
+ A worker opts into `vgi_rpc.Identity.v2` by supplying `resolveToken` and/or
578
578
  `mintGrant` (accepted by `Worker`, `serveVgiWorker`, `createVgiWorkerFetch` and
579
579
  `createVgiFetch`). It is hosted on **HTTP only** — the transport that authenticates
580
580
  callers — and only the methods whose hooks exist are hosted; with neither, the
@@ -672,6 +672,9 @@ ATTACH 'ticket_probe' AS p (TYPE vgi, LOCATION 'https://worker.example.com',
672
672
  options (`invalid_request` with one `BadRequest` violation per field). The lifetime
673
673
  is capped at the grant maximum (`VGI_RPC_GRANT_MAX_TTL_SECONDS`, default 7 days with
674
674
  grant keys); `ttl_seconds: 0` asks for the maximum.
675
+ The reply's `expires_at` is a nullable `timestamp[us, tz=UTC]` (`Date | null` in
676
+ TypeScript), null when the worker sets no maximum lifetime; protocol version
677
+ `2.0.0` (1.0.0 carried float64 unix seconds with `+inf` for "no expiry").
675
678
  - **Redeeming.** `catalog_attach` redeems a `vgi_attach_ticket` option (any letter
676
679
  case) before any catalog code runs: it must be the only option (`invalid_request`),
677
680
  it opens only under the caller's principal and this worker's key
@@ -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;
@@ -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";
@@ -7,8 +7,9 @@ export declare const ATTACH_TICKET_PREFIX = "vgia1.";
7
7
  export declare const ATTACH_TICKET_OPTION = "vgi_attach_ticket";
8
8
  /** Wire name of the protocol hosting `seal_attach`. */
9
9
  export declare const ATTACH_TICKETS_PROTOCOL_NAME = "vgi.attach_tickets.v1";
10
- /** Its declared version. */
11
- export declare const ATTACH_TICKETS_PROTOCOL_VERSION = "1.0.0";
10
+ /** Its declared version. 2.0.0 made `AttachTicket.expires_at` a nullable
11
+ * `timestamp[us, UTC]` (1.0.0: float64 unix seconds, `+inf` = no expiry). */
12
+ export declare const ATTACH_TICKETS_PROTOCOL_VERSION = "2.0.0";
12
13
  /** The envelope's version byte, fixed by this format. */
13
14
  export declare const TICKET_ENVELOPE_VERSION = 1;
14
15
  /** Largest options record (serialized Arrow IPC bytes) a ticket may carry. */
@@ -141,8 +142,21 @@ export declare function callerPrincipal(auth: AuthContext | undefined | null): s
141
142
  export declare function redeemAttachTicket(options: Record<string, unknown>, signingKey: Uint8Array | undefined | null, auth: AuthContext | undefined | null, now?: number): Promise<RestoredAttach | null>;
142
143
  /** `SealAttachRequest`, field for field with vgi-python. */
143
144
  export declare const SEAL_ATTACH_REQUEST_SCHEMA: import("./index.core.js").VgiSchema;
144
- /** `AttachTicket`, field for field with vgi-python. */
145
+ /**
146
+ * `AttachTicket`, field for field with vgi-python: `expires_at` is the UTC
147
+ * instant after which the worker refuses the ticket, null when the worker sets
148
+ * no maximum lifetime.
149
+ */
145
150
  export declare const ATTACH_TICKET_SCHEMA: import("./index.core.js").VgiSchema;
151
+ /** A sealed ticket, as `seal_attach` returns it. */
152
+ export interface AttachTicket {
153
+ /** `vgia1.` text. Not a credential, but never logged. */
154
+ ticket: string;
155
+ /** When the worker stops honouring it; `null` = no expiry. */
156
+ expires_at: Date | null;
157
+ }
158
+ /** Encode an {@link AttachTicket} as a single-row Arrow IPC stream. */
159
+ export declare function encodeAttachTicket(ticket: AttachTicket): Uint8Array;
146
160
  /**
147
161
  * The ticket lifetime ceiling: the worker's grant maximum, or `null`.
148
162
  *
@@ -166,10 +180,7 @@ export interface AttachTicketsConfig {
166
180
  now?: () => number;
167
181
  }
168
182
  /** Validate and seal; the body of `seal_attach`. */
169
- export declare function sealAttach(config: AttachTicketsConfig, request: Record<string, unknown>, auth: AuthContext | undefined): Promise<{
170
- ticket: string;
171
- expires_at: number;
172
- }>;
183
+ export declare function sealAttach(config: AttachTicketsConfig, request: Record<string, unknown>, auth: AuthContext | undefined): Promise<AttachTicket>;
173
184
  /**
174
185
  * Build `vgi.attach_tickets.v1`: one unary method, `seal_attach(request:
175
186
  * SealAttachRequest) -> AttachTicket`, each carried as serialized Arrow IPC
@@ -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(schemas: readonly SchemaContents[]): Promise<string>;
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
+ }