@query-farm/vgi 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/attach-ticket.d.ts +18 -7
- package/dist/client-entry.js +215 -91
- package/dist/client-entry.js.map +10 -9
- package/dist/codec/asd.d.ts +3 -1
- package/dist/codec/conform.d.ts +51 -0
- package/dist/errors.d.ts +5 -1
- package/dist/index.core.d.ts +1 -1
- package/dist/index.js +218 -39
- package/dist/index.js.map +17 -16
- package/dist/protocol/handlers/shared.d.ts +2 -1
- package/dist/protocol/serializers/shared.d.ts +2 -1
- package/dist/rpc-server.d.ts +2 -2
- package/dist/serve-entry.js +259 -89
- package/dist/serve-entry.js.map +13 -12
- package/dist/worker-cf-entry.js +201 -30
- package/dist/worker-cf-entry.js.map +17 -16
- package/package.json +3 -3
- package/src/attach-ticket.ts +41 -13
- package/src/catalog/composite.ts +2 -1
- package/src/catalog/interface.ts +5 -4
- package/src/catalog/read-only.ts +8 -6
- package/src/client/client.ts +13 -5
- package/src/codec/asd.ts +5 -2
- package/src/codec/conform.ts +193 -0
- package/src/errors.ts +27 -7
- package/src/functions/registry.ts +3 -2
- package/src/http/fetch.ts +1 -1
- package/src/index.core.ts +3 -1
- package/src/protocol/handlers/shared.ts +8 -2
- package/src/protocol/serializers/bind.ts +3 -1
- package/src/protocol/serializers/shared.ts +5 -2
- 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.
|
|
575
|
+
### Token introspection and grants (`vgi_rpc.Identity.v2`)
|
|
576
576
|
|
|
577
|
-
A worker opts into `vgi_rpc.Identity.
|
|
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
|
package/dist/attach-ticket.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
/**
|
|
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
|
package/dist/client-entry.js
CHANGED
|
@@ -13,6 +13,79 @@ var __export = (target, all) => {
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
// src/arrow/impl-arrowjs/index.ts
|
|
17
|
+
var exports_impl_arrowjs = {};
|
|
18
|
+
__export(exports_impl_arrowjs, {
|
|
19
|
+
DateUnit: () => DateUnit,
|
|
20
|
+
IntervalUnit: () => IntervalUnit,
|
|
21
|
+
TimeUnit: () => TimeUnit,
|
|
22
|
+
UnionMode: () => UnionMode,
|
|
23
|
+
adoptArrowJsShape: () => adoptArrowJsShape,
|
|
24
|
+
backend: () => backend,
|
|
25
|
+
batchFromColumns: () => batchFromColumns,
|
|
26
|
+
batchFromRows: () => batchFromRows,
|
|
27
|
+
batchToScalarDict: () => batchToScalarDict,
|
|
28
|
+
batchToSecretDict: () => batchToSecretDict,
|
|
29
|
+
binary: () => binary,
|
|
30
|
+
bool: () => bool,
|
|
31
|
+
buildStatisticsBatch: () => buildStatisticsBatch,
|
|
32
|
+
columnFromArray: () => columnFromArray,
|
|
33
|
+
date: () => date,
|
|
34
|
+
dateDay: () => dateDay,
|
|
35
|
+
dateMillisecond: () => dateMillisecond,
|
|
36
|
+
decimal: () => decimal,
|
|
37
|
+
decimal128: () => decimal128,
|
|
38
|
+
decimal256: () => decimal256,
|
|
39
|
+
decodeDictValue: () => decodeDictValue,
|
|
40
|
+
denseUnion: () => denseUnion,
|
|
41
|
+
deserializeBatch: () => deserializeBatch,
|
|
42
|
+
deserializeSchema: () => deserializeSchema,
|
|
43
|
+
dictionary: () => dictionary,
|
|
44
|
+
duration: () => duration,
|
|
45
|
+
emptyBatch: () => emptyBatch,
|
|
46
|
+
field: () => field,
|
|
47
|
+
filterBatch: () => filterBatch,
|
|
48
|
+
fixedSizeBinary: () => fixedSizeBinary,
|
|
49
|
+
fixedSizeList: () => fixedSizeList,
|
|
50
|
+
float16: () => float16,
|
|
51
|
+
float32: () => float32,
|
|
52
|
+
float64: () => float64,
|
|
53
|
+
int: () => int,
|
|
54
|
+
int16: () => int16,
|
|
55
|
+
int32: () => int32,
|
|
56
|
+
int64: () => int64,
|
|
57
|
+
int8: () => int8,
|
|
58
|
+
interval: () => interval,
|
|
59
|
+
iterRows: () => iterRows,
|
|
60
|
+
largeBinary: () => largeBinary,
|
|
61
|
+
largeUtf8: () => largeUtf8,
|
|
62
|
+
list: () => list,
|
|
63
|
+
map: () => map,
|
|
64
|
+
nullType: () => nullType,
|
|
65
|
+
projectBatch: () => projectBatch,
|
|
66
|
+
projectSchema: () => projectSchema,
|
|
67
|
+
readCanonicalValue: () => readCanonicalValue,
|
|
68
|
+
safeNumber: () => safeNumber,
|
|
69
|
+
schema: () => schema,
|
|
70
|
+
serializeBatch: () => serializeBatch,
|
|
71
|
+
serializeSchema: () => serializeSchema,
|
|
72
|
+
sparseUnion: () => sparseUnion,
|
|
73
|
+
struct: () => struct,
|
|
74
|
+
time: () => time,
|
|
75
|
+
timeMicrosecond: () => timeMicrosecond,
|
|
76
|
+
timeMillisecond: () => timeMillisecond,
|
|
77
|
+
timeNanosecond: () => timeNanosecond,
|
|
78
|
+
timeSecond: () => timeSecond,
|
|
79
|
+
timestamp: () => timestamp,
|
|
80
|
+
uint16: () => uint16,
|
|
81
|
+
uint32: () => uint32,
|
|
82
|
+
uint64: () => uint64,
|
|
83
|
+
uint8: () => uint8,
|
|
84
|
+
union: () => union,
|
|
85
|
+
utf8: () => utf8,
|
|
86
|
+
withBatchMetadata: () => withBatchMetadata
|
|
87
|
+
});
|
|
88
|
+
|
|
16
89
|
// src/arrow/predicates.ts
|
|
17
90
|
var TypeId = {
|
|
18
91
|
Null: 1,
|
|
@@ -40,9 +113,15 @@ var TypeId = {
|
|
|
40
113
|
function isInt(t) {
|
|
41
114
|
return t.typeId === TypeId.Int;
|
|
42
115
|
}
|
|
116
|
+
function isFloat(t) {
|
|
117
|
+
return t.typeId === TypeId.Float;
|
|
118
|
+
}
|
|
43
119
|
function isBinary(t) {
|
|
44
120
|
return t.typeId === TypeId.Binary || t.typeId === TypeId.LargeBinary;
|
|
45
121
|
}
|
|
122
|
+
function isUtf8(t) {
|
|
123
|
+
return t.typeId === TypeId.Utf8 || t.typeId === TypeId.LargeUtf8;
|
|
124
|
+
}
|
|
46
125
|
function isBool(t) {
|
|
47
126
|
return t.typeId === TypeId.Bool;
|
|
48
127
|
}
|
|
@@ -94,79 +173,6 @@ function typeSignature(t) {
|
|
|
94
173
|
return Array.isArray(a.children) ? `${t.typeId}<${kids()}>` : String(t.typeId);
|
|
95
174
|
}
|
|
96
175
|
}
|
|
97
|
-
// src/arrow/impl-arrowjs/index.ts
|
|
98
|
-
var exports_impl_arrowjs = {};
|
|
99
|
-
__export(exports_impl_arrowjs, {
|
|
100
|
-
DateUnit: () => DateUnit,
|
|
101
|
-
IntervalUnit: () => IntervalUnit,
|
|
102
|
-
TimeUnit: () => TimeUnit,
|
|
103
|
-
UnionMode: () => UnionMode,
|
|
104
|
-
adoptArrowJsShape: () => adoptArrowJsShape,
|
|
105
|
-
backend: () => backend,
|
|
106
|
-
batchFromColumns: () => batchFromColumns,
|
|
107
|
-
batchFromRows: () => batchFromRows,
|
|
108
|
-
batchToScalarDict: () => batchToScalarDict,
|
|
109
|
-
batchToSecretDict: () => batchToSecretDict,
|
|
110
|
-
binary: () => binary,
|
|
111
|
-
bool: () => bool,
|
|
112
|
-
buildStatisticsBatch: () => buildStatisticsBatch,
|
|
113
|
-
columnFromArray: () => columnFromArray,
|
|
114
|
-
date: () => date,
|
|
115
|
-
dateDay: () => dateDay,
|
|
116
|
-
dateMillisecond: () => dateMillisecond,
|
|
117
|
-
decimal: () => decimal,
|
|
118
|
-
decimal128: () => decimal128,
|
|
119
|
-
decimal256: () => decimal256,
|
|
120
|
-
decodeDictValue: () => decodeDictValue,
|
|
121
|
-
denseUnion: () => denseUnion,
|
|
122
|
-
deserializeBatch: () => deserializeBatch,
|
|
123
|
-
deserializeSchema: () => deserializeSchema,
|
|
124
|
-
dictionary: () => dictionary,
|
|
125
|
-
duration: () => duration,
|
|
126
|
-
emptyBatch: () => emptyBatch,
|
|
127
|
-
field: () => field,
|
|
128
|
-
filterBatch: () => filterBatch,
|
|
129
|
-
fixedSizeBinary: () => fixedSizeBinary,
|
|
130
|
-
fixedSizeList: () => fixedSizeList,
|
|
131
|
-
float16: () => float16,
|
|
132
|
-
float32: () => float32,
|
|
133
|
-
float64: () => float64,
|
|
134
|
-
int: () => int,
|
|
135
|
-
int16: () => int16,
|
|
136
|
-
int32: () => int32,
|
|
137
|
-
int64: () => int64,
|
|
138
|
-
int8: () => int8,
|
|
139
|
-
interval: () => interval,
|
|
140
|
-
iterRows: () => iterRows,
|
|
141
|
-
largeBinary: () => largeBinary,
|
|
142
|
-
largeUtf8: () => largeUtf8,
|
|
143
|
-
list: () => list,
|
|
144
|
-
map: () => map,
|
|
145
|
-
nullType: () => nullType,
|
|
146
|
-
projectBatch: () => projectBatch,
|
|
147
|
-
projectSchema: () => projectSchema,
|
|
148
|
-
readCanonicalValue: () => readCanonicalValue,
|
|
149
|
-
safeNumber: () => safeNumber,
|
|
150
|
-
schema: () => schema,
|
|
151
|
-
serializeBatch: () => serializeBatch,
|
|
152
|
-
serializeSchema: () => serializeSchema,
|
|
153
|
-
sparseUnion: () => sparseUnion,
|
|
154
|
-
struct: () => struct,
|
|
155
|
-
time: () => time,
|
|
156
|
-
timeMicrosecond: () => timeMicrosecond,
|
|
157
|
-
timeMillisecond: () => timeMillisecond,
|
|
158
|
-
timeNanosecond: () => timeNanosecond,
|
|
159
|
-
timeSecond: () => timeSecond,
|
|
160
|
-
timestamp: () => timestamp,
|
|
161
|
-
uint16: () => uint16,
|
|
162
|
-
uint32: () => uint32,
|
|
163
|
-
uint64: () => uint64,
|
|
164
|
-
uint8: () => uint8,
|
|
165
|
-
union: () => union,
|
|
166
|
-
utf8: () => utf8,
|
|
167
|
-
withBatchMetadata: () => withBatchMetadata
|
|
168
|
-
});
|
|
169
|
-
|
|
170
176
|
// src/arrow/impl-arrowjs/schema.ts
|
|
171
177
|
import {
|
|
172
178
|
Schema as A_Schema,
|
|
@@ -2073,6 +2079,116 @@ function toUint8Array(val) {
|
|
|
2073
2079
|
return new Uint8Array(0);
|
|
2074
2080
|
}
|
|
2075
2081
|
|
|
2082
|
+
// src/codec/conform.ts
|
|
2083
|
+
var OPTIONAL_ITEM_FIELDS = new Set(["argument_names"]);
|
|
2084
|
+
function children(type) {
|
|
2085
|
+
return type.children ?? [];
|
|
2086
|
+
}
|
|
2087
|
+
function mapValueType(type) {
|
|
2088
|
+
const entries = children(type)[0].type;
|
|
2089
|
+
return children(entries)[1].type;
|
|
2090
|
+
}
|
|
2091
|
+
function mapPairs(raw) {
|
|
2092
|
+
if (Array.isArray(raw))
|
|
2093
|
+
return raw.map((e) => Array.isArray(e) ? [e[0], e[1]] : [e?.key, e?.value]);
|
|
2094
|
+
if (raw instanceof Map)
|
|
2095
|
+
return Array.from(raw.entries());
|
|
2096
|
+
if (typeof raw[Symbol.iterator] === "function")
|
|
2097
|
+
return Array.from(raw);
|
|
2098
|
+
return Object.entries(raw);
|
|
2099
|
+
}
|
|
2100
|
+
function zeroValue(type) {
|
|
2101
|
+
if (isUtf8(type) || isDictionary(type))
|
|
2102
|
+
return "";
|
|
2103
|
+
if (isBinary(type))
|
|
2104
|
+
return new Uint8Array(0);
|
|
2105
|
+
if (isBool(type))
|
|
2106
|
+
return false;
|
|
2107
|
+
if (isInt(type))
|
|
2108
|
+
return type.bitWidth === 64 ? 0n : 0;
|
|
2109
|
+
if (isFloat(type))
|
|
2110
|
+
return 0;
|
|
2111
|
+
if (isList(type) || isMap(type))
|
|
2112
|
+
return [];
|
|
2113
|
+
if (isStruct(type)) {
|
|
2114
|
+
const out = {};
|
|
2115
|
+
for (const c of children(type))
|
|
2116
|
+
out[c.name] = c.nullable ? null : conformValue(c.type, undefined, false, c.name);
|
|
2117
|
+
return out;
|
|
2118
|
+
}
|
|
2119
|
+
return null;
|
|
2120
|
+
}
|
|
2121
|
+
var HAS_CONTAINER = new WeakMap;
|
|
2122
|
+
function hasContainer(type) {
|
|
2123
|
+
const cached = HAS_CONTAINER.get(type);
|
|
2124
|
+
if (cached !== undefined)
|
|
2125
|
+
return cached;
|
|
2126
|
+
let has = isList(type) || isMap(type);
|
|
2127
|
+
if (!has && isStruct(type))
|
|
2128
|
+
has = children(type).some((c) => hasContainer(c.type));
|
|
2129
|
+
HAS_CONTAINER.set(type, has);
|
|
2130
|
+
return has;
|
|
2131
|
+
}
|
|
2132
|
+
function conformValue(type, value, nullable, name) {
|
|
2133
|
+
if (value == null) {
|
|
2134
|
+
if (nullable)
|
|
2135
|
+
return value ?? null;
|
|
2136
|
+
if (isList(type) || isMap(type))
|
|
2137
|
+
return [];
|
|
2138
|
+
return value;
|
|
2139
|
+
}
|
|
2140
|
+
if (!hasContainer(type))
|
|
2141
|
+
return value;
|
|
2142
|
+
if (isList(type)) {
|
|
2143
|
+
const itemType = children(type)[0].type;
|
|
2144
|
+
const itemsNullable = OPTIONAL_ITEM_FIELDS.has(name);
|
|
2145
|
+
const items = Array.isArray(value) ? value : Array.from(value);
|
|
2146
|
+
let changed = !Array.isArray(value);
|
|
2147
|
+
const out = items.map((item) => {
|
|
2148
|
+
const next = item == null && !itemsNullable ? zeroValue(itemType) : conformValue(itemType, item, true, name);
|
|
2149
|
+
if (next !== item)
|
|
2150
|
+
changed = true;
|
|
2151
|
+
return next;
|
|
2152
|
+
});
|
|
2153
|
+
return changed ? out : value;
|
|
2154
|
+
}
|
|
2155
|
+
if (isMap(type)) {
|
|
2156
|
+
const valueType = mapValueType(type);
|
|
2157
|
+
const pairs = mapPairs(value);
|
|
2158
|
+
let changed = false;
|
|
2159
|
+
const out = pairs.map(([k, v]) => {
|
|
2160
|
+
const next = v == null ? zeroValue(valueType) : conformValue(valueType, v, true, name);
|
|
2161
|
+
if (next !== v)
|
|
2162
|
+
changed = true;
|
|
2163
|
+
return [k, next];
|
|
2164
|
+
});
|
|
2165
|
+
return changed ? out : value;
|
|
2166
|
+
}
|
|
2167
|
+
if (isStruct(type)) {
|
|
2168
|
+
let out = null;
|
|
2169
|
+
for (const c of children(type)) {
|
|
2170
|
+
const v = value[c.name];
|
|
2171
|
+
const next = conformValue(c.type, v, c.nullable, c.name);
|
|
2172
|
+
if (next !== v) {
|
|
2173
|
+
(out ??= { ...value })[c.name] = next;
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
return out ?? value;
|
|
2177
|
+
}
|
|
2178
|
+
return value;
|
|
2179
|
+
}
|
|
2180
|
+
function conformRecord(schema, obj) {
|
|
2181
|
+
let out = null;
|
|
2182
|
+
for (const f of schema.fields) {
|
|
2183
|
+
const v = obj[f.name];
|
|
2184
|
+
const next = conformValue(f.type, v, f.nullable, f.name);
|
|
2185
|
+
if (next !== v) {
|
|
2186
|
+
(out ??= { ...obj })[f.name] = next;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
return out ?? obj;
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2076
2192
|
// src/protocol/serializers/shared.ts
|
|
2077
2193
|
function toUint8Array2(val) {
|
|
2078
2194
|
if (typeof val === "string")
|
|
@@ -2085,8 +2201,9 @@ function toUint8Array2(val) {
|
|
|
2085
2201
|
}
|
|
2086
2202
|
function buildSingleRowBatch(schema, values) {
|
|
2087
2203
|
const cols = {};
|
|
2204
|
+
const row = conformRecord(schema, values);
|
|
2088
2205
|
for (const f of schema.fields) {
|
|
2089
|
-
let val =
|
|
2206
|
+
let val = row[f.name];
|
|
2090
2207
|
if (isInt(f.type) && f.type.bitWidth === 64 && typeof val === "number") {
|
|
2091
2208
|
val = BigInt(val);
|
|
2092
2209
|
}
|
|
@@ -2126,7 +2243,7 @@ function serializeBindRequest(req) {
|
|
|
2126
2243
|
return buildSingleRowBatch(BIND_REQUEST_SCHEMA, {
|
|
2127
2244
|
function_name: req.function_name,
|
|
2128
2245
|
arguments: serializeArguments(req.arguments),
|
|
2129
|
-
function_type: req.function_type,
|
|
2246
|
+
function_type: req.function_type == null ? req.function_type : String(req.function_type).toUpperCase(),
|
|
2130
2247
|
input_schema: req.input_schema ? serializeSchema(req.input_schema) : null,
|
|
2131
2248
|
settings: req.settings ? serializeBatch(req.settings) : null,
|
|
2132
2249
|
secrets: req.secrets ? serializeBatch(req.secrets) : null,
|
|
@@ -2222,9 +2339,12 @@ function deserializeGlobalInitResponse(params) {
|
|
|
2222
2339
|
}
|
|
2223
2340
|
// src/errors.ts
|
|
2224
2341
|
class VgiError extends Error {
|
|
2225
|
-
|
|
2342
|
+
errorCode;
|
|
2343
|
+
constructor(message, code) {
|
|
2226
2344
|
super(message);
|
|
2227
2345
|
this.name = "VgiError";
|
|
2346
|
+
if (code !== undefined)
|
|
2347
|
+
this.errorCode = code;
|
|
2228
2348
|
}
|
|
2229
2349
|
}
|
|
2230
2350
|
|
|
@@ -2237,42 +2357,42 @@ class RowCountMismatchError extends VgiError {
|
|
|
2237
2357
|
|
|
2238
2358
|
class FunctionNotFoundError extends VgiError {
|
|
2239
2359
|
constructor(name, available) {
|
|
2240
|
-
super(`Unknown function '${name}'
|
|
2360
|
+
super(`Unknown function '${name}'`, "NOT_FOUND");
|
|
2241
2361
|
this.name = "FunctionNotFoundError";
|
|
2242
2362
|
}
|
|
2243
2363
|
}
|
|
2244
2364
|
|
|
2245
2365
|
class CatalogReadOnlyError extends VgiError {
|
|
2246
2366
|
constructor(operation) {
|
|
2247
|
-
super(`catalog is read-only: ${operation} is not supported
|
|
2367
|
+
super(`catalog is read-only: ${operation} is not supported`, "FAILED_PRECONDITION");
|
|
2248
2368
|
this.name = "CatalogReadOnlyError";
|
|
2249
2369
|
}
|
|
2250
2370
|
}
|
|
2251
2371
|
|
|
2252
2372
|
class CatalogNotFoundError extends VgiError {
|
|
2253
2373
|
constructor(entity, name) {
|
|
2254
|
-
super(`${entity} '${name}' not found
|
|
2374
|
+
super(`${entity} '${name}' not found`, "NOT_FOUND");
|
|
2255
2375
|
this.name = "CatalogNotFoundError";
|
|
2256
2376
|
}
|
|
2257
2377
|
}
|
|
2258
2378
|
|
|
2259
2379
|
class CatalogAlreadyExistsError extends VgiError {
|
|
2260
2380
|
constructor(entity, name) {
|
|
2261
|
-
super(`${entity} '${name}' already exists
|
|
2381
|
+
super(`${entity} '${name}' already exists`, "ALREADY_EXISTS");
|
|
2262
2382
|
this.name = "CatalogAlreadyExistsError";
|
|
2263
2383
|
}
|
|
2264
2384
|
}
|
|
2265
2385
|
|
|
2266
2386
|
class ArgumentValidationError extends VgiError {
|
|
2267
2387
|
constructor(message) {
|
|
2268
|
-
super(message);
|
|
2388
|
+
super(message, "INVALID_ARGUMENT");
|
|
2269
2389
|
this.name = "ArgumentValidationError";
|
|
2270
2390
|
}
|
|
2271
2391
|
}
|
|
2272
2392
|
|
|
2273
2393
|
class NoCatalogError extends VgiError {
|
|
2274
2394
|
constructor() {
|
|
2275
|
-
super("No catalog is configured for this worker");
|
|
2395
|
+
super("No catalog is configured for this worker", "UNIMPLEMENTED");
|
|
2276
2396
|
this.name = "NoCatalogError";
|
|
2277
2397
|
}
|
|
2278
2398
|
}
|
|
@@ -2284,7 +2404,7 @@ function normalizeSchemaPath(path) {
|
|
|
2284
2404
|
|
|
2285
2405
|
// src/codec/asd.ts
|
|
2286
2406
|
function encodeASD(schema, obj) {
|
|
2287
|
-
return serializeBatch(batchFromRows([sortMapsForSchema(schema, obj)], schema));
|
|
2407
|
+
return serializeBatch(batchFromRows([sortMapsForSchema(schema, conformRecord(schema, obj))], schema));
|
|
2288
2408
|
}
|
|
2289
2409
|
function compareCodePoints(a, b) {
|
|
2290
2410
|
const n = Math.min(a.length, b.length);
|
|
@@ -2301,7 +2421,7 @@ function compareCodePoints(a, b) {
|
|
|
2301
2421
|
}
|
|
2302
2422
|
return a.length - b.length;
|
|
2303
2423
|
}
|
|
2304
|
-
function
|
|
2424
|
+
function mapPairs2(raw) {
|
|
2305
2425
|
if (Array.isArray(raw))
|
|
2306
2426
|
return raw.map((e) => Array.isArray(e) ? [e[0], e[1]] : [e?.key, e?.value]);
|
|
2307
2427
|
if (raw instanceof Map)
|
|
@@ -2336,7 +2456,7 @@ function sortMapsForType(type, value) {
|
|
|
2336
2456
|
if (isMap(type)) {
|
|
2337
2457
|
const entries = type.children[0].type;
|
|
2338
2458
|
const valueType = entries.children[1].type;
|
|
2339
|
-
return
|
|
2459
|
+
return mapPairs2(value).map(([k, v]) => [k, sortMapsForType(valueType, v)]).sort((x, y) => compareKeys(x[0], y[0]));
|
|
2340
2460
|
}
|
|
2341
2461
|
if (isList(type)) {
|
|
2342
2462
|
const child = type.children[0].type;
|
|
@@ -3619,6 +3739,10 @@ function toAsyncIterator(input) {
|
|
|
3619
3739
|
}
|
|
3620
3740
|
|
|
3621
3741
|
// src/client/client.ts
|
|
3742
|
+
function onConflictName(onConflict) {
|
|
3743
|
+
return String(onConflict).toUpperCase();
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3622
3746
|
class VgiClient {
|
|
3623
3747
|
rpc;
|
|
3624
3748
|
defaultAttachOpaqueData;
|
|
@@ -4074,7 +4198,7 @@ class VgiClient {
|
|
|
4074
4198
|
}
|
|
4075
4199
|
await this.rpc.call("catalog_create", {
|
|
4076
4200
|
name,
|
|
4077
|
-
on_conflict: onConflict,
|
|
4201
|
+
on_conflict: onConflictName(onConflict),
|
|
4078
4202
|
options: wireOptions
|
|
4079
4203
|
});
|
|
4080
4204
|
}
|
|
@@ -4142,7 +4266,7 @@ class VgiClient {
|
|
|
4142
4266
|
await this.rpc.call("catalog_schema_create", {
|
|
4143
4267
|
attach_opaque_data: attachOpaqueData,
|
|
4144
4268
|
path: normalizeSchemaPath(path),
|
|
4145
|
-
on_conflict: opts?.onConflict ?? "error",
|
|
4269
|
+
on_conflict: onConflictName(opts?.onConflict ?? "error"),
|
|
4146
4270
|
comment: opts?.comment ?? null,
|
|
4147
4271
|
tags: tagsMap,
|
|
4148
4272
|
transaction_opaque_data: opts?.transactionOpaqueData ?? null
|
|
@@ -4221,7 +4345,7 @@ class VgiClient {
|
|
|
4221
4345
|
schema_path: normalizeSchemaPath(schemaPath),
|
|
4222
4346
|
name,
|
|
4223
4347
|
columns,
|
|
4224
|
-
on_conflict: onConflict,
|
|
4348
|
+
on_conflict: onConflictName(onConflict),
|
|
4225
4349
|
not_null_constraints: notNullConstraints ?? null,
|
|
4226
4350
|
unique_constraints: uniqueConstraints ?? null,
|
|
4227
4351
|
check_constraints: checkConstraints ?? null,
|
|
@@ -4375,7 +4499,7 @@ class VgiClient {
|
|
|
4375
4499
|
schema_path: normalizeSchemaPath(schemaPath),
|
|
4376
4500
|
name,
|
|
4377
4501
|
definition,
|
|
4378
|
-
on_conflict: onConflict,
|
|
4502
|
+
on_conflict: onConflictName(onConflict),
|
|
4379
4503
|
transaction_opaque_data: transactionOpaqueData ?? null
|
|
4380
4504
|
});
|
|
4381
4505
|
}
|
|
@@ -4442,7 +4566,7 @@ class VgiClient {
|
|
|
4442
4566
|
macro_type: [macroType],
|
|
4443
4567
|
parameters: [parameters],
|
|
4444
4568
|
definition: [definition],
|
|
4445
|
-
on_conflict: [onConflict],
|
|
4569
|
+
on_conflict: [onConflictName(onConflict)],
|
|
4446
4570
|
parameter_default_values: [parameterDefaultValues ?? null],
|
|
4447
4571
|
arguments_schema: [argumentsSchema ?? null],
|
|
4448
4572
|
transaction_opaque_data: [transactionOpaqueData ?? null]
|
|
@@ -4640,4 +4764,4 @@ export {
|
|
|
4640
4764
|
typeSignature
|
|
4641
4765
|
};
|
|
4642
4766
|
|
|
4643
|
-
//# debugId=
|
|
4767
|
+
//# debugId=586BBE791F5462D664756E2164756E21
|