@query-farm/vgi 0.38.0 → 0.39.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/client/client.d.ts +31 -2
- package/dist/client/types.d.ts +56 -1
- package/dist/client-entry.js +99 -8
- package/dist/client-entry.js.map +4 -4
- package/dist/functions/copy-to.d.ts +1 -1
- package/dist/index.core.d.ts +1 -1
- package/dist/index.js +99 -8
- package/dist/index.js.map +6 -6
- package/dist/serve-entry.js.map +1 -1
- package/dist/worker-cf-entry.js.map +3 -3
- package/package.json +1 -1
- package/src/client/client.ts +148 -0
- package/src/client/types.ts +58 -1
- package/src/codec/asd.ts +12 -8
- package/src/functions/copy-to.ts +1 -1
- package/src/index.core.ts +2 -0
|
@@ -30,7 +30,7 @@ export interface CopyToOption {
|
|
|
30
30
|
* Optional allowed value set, validated worker-side at bind. Mirrors
|
|
31
31
|
* vgi-python's `Arg(..., choices=[...])`.
|
|
32
32
|
*/
|
|
33
|
-
choices?: unknown[];
|
|
33
|
+
choices?: readonly unknown[];
|
|
34
34
|
/**
|
|
35
35
|
* Optional inclusive lower bound for numeric options, validated worker-side at
|
|
36
36
|
* bind. Mirrors vgi-python's `Arg(..., ge=...)`.
|
package/dist/index.core.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export type { ScalarComputeRow, ScalarOutputValue, ScalarComputeResult } from ".
|
|
|
39
39
|
export { type FunctionStorage, type WorkerStateKey, FunctionStorageSqlite, BoundStorage, UnknownInvocationError, resolveStorageFromEnv, setStorage, storage as functionStorage, } from "./functions/storage.js";
|
|
40
40
|
export { FunctionStorageCfDo, type FetchLike } from "./functions/storage-cf-do.js";
|
|
41
41
|
export { VgiClient, VgiClientError } from "./client/client.js";
|
|
42
|
-
export type { VgiClientOptions, TableFunctionOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType as ClientCatalogFunctionType, CatalogAttachOptions, AttachOptionValue, } from "./client/types.js";
|
|
42
|
+
export type { VgiClientOptions, TableFunctionOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType as ClientCatalogFunctionType, CatalogAttachOptions, AttachOptionValue, CatalogSnapshot, LoadCatalogOptions, } from "./client/types.js";
|
|
43
43
|
export { str, bytes, int, int32, float, float32, bool, toSchema, OutputCollector, AuthContext } from "@query-farm/vgi-rpc";
|
|
44
44
|
export { subprocessConnect, httpConnect, tcpConnect } from "@query-farm/vgi-rpc";
|
|
45
45
|
export type { RpcClient, StreamSession, LogMessage } from "@query-farm/vgi-rpc";
|
package/dist/index.js
CHANGED
|
@@ -7139,21 +7139,23 @@ function normalizeValue(raw, type) {
|
|
|
7139
7139
|
return out;
|
|
7140
7140
|
}
|
|
7141
7141
|
if (isMap(type)) {
|
|
7142
|
+
const entries = type.children[0].type;
|
|
7143
|
+
const valueType = entries.children[1].type;
|
|
7142
7144
|
const out = {};
|
|
7145
|
+
const put = (k, v) => {
|
|
7146
|
+
out[String(k)] = normalizeValue(v, valueType);
|
|
7147
|
+
};
|
|
7143
7148
|
if (raw[Symbol.iterator]) {
|
|
7144
7149
|
for (const entry of raw) {
|
|
7145
7150
|
if (Array.isArray(entry)) {
|
|
7146
|
-
|
|
7151
|
+
put(entry[0], entry[1]);
|
|
7147
7152
|
} else if (entry && typeof entry === "object") {
|
|
7148
|
-
|
|
7149
|
-
const v = entry.value ?? entry[1];
|
|
7150
|
-
out[String(k)] = v == null ? "" : String(v);
|
|
7153
|
+
put(entry.key ?? entry[0], entry.value ?? entry[1]);
|
|
7151
7154
|
}
|
|
7152
7155
|
}
|
|
7153
7156
|
} else if (typeof raw === "object") {
|
|
7154
|
-
for (const [k, v] of Object.entries(raw))
|
|
7155
|
-
|
|
7156
|
-
}
|
|
7157
|
+
for (const [k, v] of Object.entries(raw))
|
|
7158
|
+
put(k, v);
|
|
7157
7159
|
}
|
|
7158
7160
|
return out;
|
|
7159
7161
|
}
|
|
@@ -13226,6 +13228,84 @@ class VgiClient {
|
|
|
13226
13228
|
schemas
|
|
13227
13229
|
};
|
|
13228
13230
|
}
|
|
13231
|
+
async loadCatalog(attach, opts) {
|
|
13232
|
+
const attachOpaqueData = attach.attach_opaque_data;
|
|
13233
|
+
const previous = opts?.previous ?? null;
|
|
13234
|
+
const useContents = attach.supports_catalog_contents === true && opts?.useCatalogContents !== false && opts?.transactionOpaqueData == null;
|
|
13235
|
+
if (!useContents) {
|
|
13236
|
+
return this._loadCatalogPerSchema(attachOpaqueData, opts?.transactionOpaqueData, null);
|
|
13237
|
+
}
|
|
13238
|
+
let fallbackError = null;
|
|
13239
|
+
const ifNoneMatch = previous?.etag ?? null;
|
|
13240
|
+
const knownVersion = previous?.catalog_version ?? 0;
|
|
13241
|
+
for (let attempt = 0;attempt < 2; attempt++) {
|
|
13242
|
+
let response;
|
|
13243
|
+
try {
|
|
13244
|
+
response = await this.catalogContents(attachOpaqueData, ifNoneMatch);
|
|
13245
|
+
} catch (err) {
|
|
13246
|
+
fallbackError = err instanceof Error ? err.message : String(err);
|
|
13247
|
+
break;
|
|
13248
|
+
}
|
|
13249
|
+
if (response.not_modified) {
|
|
13250
|
+
if (previous == null || ifNoneMatch == null) {
|
|
13251
|
+
fallbackError = "catalog_contents answered not_modified to an unconditional request";
|
|
13252
|
+
break;
|
|
13253
|
+
}
|
|
13254
|
+
return {
|
|
13255
|
+
...previous,
|
|
13256
|
+
catalog_version: response.catalog_version !== 0 ? response.catalog_version : previous.catalog_version,
|
|
13257
|
+
etag: response.etag ?? ifNoneMatch,
|
|
13258
|
+
not_modified: true,
|
|
13259
|
+
fallback_error: null
|
|
13260
|
+
};
|
|
13261
|
+
}
|
|
13262
|
+
if (response.catalog_version !== 0 && knownVersion !== 0 && response.catalog_version < knownVersion) {
|
|
13263
|
+
fallbackError = `catalog_contents snapshot version ${response.catalog_version} is older than the known version ${knownVersion}`;
|
|
13264
|
+
continue;
|
|
13265
|
+
}
|
|
13266
|
+
return {
|
|
13267
|
+
catalog_version: response.catalog_version,
|
|
13268
|
+
etag: response.etag,
|
|
13269
|
+
source: "catalog_contents",
|
|
13270
|
+
not_modified: false,
|
|
13271
|
+
fallback_error: null,
|
|
13272
|
+
schemas: response.schemas
|
|
13273
|
+
};
|
|
13274
|
+
}
|
|
13275
|
+
return this._loadCatalogPerSchema(attachOpaqueData, undefined, fallbackError);
|
|
13276
|
+
}
|
|
13277
|
+
async _loadCatalogPerSchema(attachOpaqueData, transactionOpaqueData, fallbackError) {
|
|
13278
|
+
const schemas = await this.schemas(attachOpaqueData, transactionOpaqueData);
|
|
13279
|
+
const out = [];
|
|
13280
|
+
for (const schema of schemas) {
|
|
13281
|
+
const counts = schema.estimated_object_count ?? {};
|
|
13282
|
+
const path = schema.path;
|
|
13283
|
+
const has = (kind) => {
|
|
13284
|
+
const n = counts[kind];
|
|
13285
|
+
return n == null || Number(n) !== 0;
|
|
13286
|
+
};
|
|
13287
|
+
const t = transactionOpaqueData;
|
|
13288
|
+
out.push({
|
|
13289
|
+
schema,
|
|
13290
|
+
tables: has("table") ? await this.schemaContentsTables(attachOpaqueData, path, t) : [],
|
|
13291
|
+
views: has("view") ? await this.schemaContentsViews(attachOpaqueData, path, t) : [],
|
|
13292
|
+
scalar_functions: has("scalar_function") ? await this.schemaContentsFunctions(attachOpaqueData, path, "SCALAR_FUNCTION", t) : [],
|
|
13293
|
+
aggregate_functions: has("aggregate_function") ? await this.schemaContentsFunctions(attachOpaqueData, path, "AGGREGATE_FUNCTION", t) : [],
|
|
13294
|
+
table_functions: has("table_function") ? await this.schemaContentsFunctions(attachOpaqueData, path, "TABLE_FUNCTION", t) : [],
|
|
13295
|
+
scalar_macros: has("macro") ? await this.schemaContentsMacros(attachOpaqueData, path, "SCALAR_MACRO", t) : [],
|
|
13296
|
+
table_macros: has("macro") ? await this.schemaContentsMacros(attachOpaqueData, path, "TABLE_MACRO", t) : [],
|
|
13297
|
+
indexes: has("index") ? await this.schemaContentsIndexes(attachOpaqueData, path, t) : []
|
|
13298
|
+
});
|
|
13299
|
+
}
|
|
13300
|
+
return {
|
|
13301
|
+
catalog_version: null,
|
|
13302
|
+
etag: null,
|
|
13303
|
+
source: "per_schema",
|
|
13304
|
+
not_modified: false,
|
|
13305
|
+
fallback_error: fallbackError,
|
|
13306
|
+
schemas: out
|
|
13307
|
+
};
|
|
13308
|
+
}
|
|
13229
13309
|
async catalogDetach(attachOpaqueData) {
|
|
13230
13310
|
await this.rpc.call("catalog_detach", { attach_opaque_data: attachOpaqueData });
|
|
13231
13311
|
}
|
|
@@ -13364,6 +13444,17 @@ class VgiClient {
|
|
|
13364
13444
|
const inner = unwrapResult(result);
|
|
13365
13445
|
return deserializeInfoList(inner.items, decodeFunctionInfo);
|
|
13366
13446
|
}
|
|
13447
|
+
async schemaContentsIndexes(attachOpaqueData, path, transactionOpaqueData) {
|
|
13448
|
+
const result = await this.rpc.call("catalog_schema_contents_indexes", {
|
|
13449
|
+
attach_opaque_data: attachOpaqueData,
|
|
13450
|
+
path: normalizeSchemaPath(path),
|
|
13451
|
+
transaction_opaque_data: transactionOpaqueData ?? null
|
|
13452
|
+
});
|
|
13453
|
+
if (!result)
|
|
13454
|
+
return [];
|
|
13455
|
+
const inner = unwrapResult(result);
|
|
13456
|
+
return deserializeInfoList(inner.items, decodeIndexInfo);
|
|
13457
|
+
}
|
|
13367
13458
|
async tableGet(attachOpaqueData, schemaPath, name, transactionOpaqueData) {
|
|
13368
13459
|
const result = await this.rpc.call("catalog_table_get", {
|
|
13369
13460
|
attach_opaque_data: attachOpaqueData,
|
|
@@ -14159,4 +14250,4 @@ export {
|
|
|
14159
14250
|
utf82 as utf8
|
|
14160
14251
|
};
|
|
14161
14252
|
|
|
14162
|
-
//# debugId=
|
|
14253
|
+
//# debugId=03676B1C4ED9A21664756E2164756E21
|