@query-farm/vgi 0.24.2 → 0.25.1
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/catalog/attach-option.d.ts +10 -0
- package/dist/client-entry.d.ts +2 -0
- package/dist/client-entry.js +76 -1
- package/dist/client-entry.js.map +5 -4
- package/dist/http/fetch.d.ts +5 -5
- package/dist/index.core.d.ts +2 -2
- package/dist/index.js +30 -415
- package/dist/index.js.map +5 -6
- package/dist/serve-entry.js +7 -446
- package/dist/serve-entry.js.map +5 -7
- package/dist/worker-cf-entry.d.ts +1 -2
- package/dist/worker-cf-entry.js +2 -414
- package/dist/worker-cf-entry.js.map +6 -7
- package/package.json +3 -3
- package/src/catalog/attach-option.ts +54 -0
- package/src/client-entry.ts +11 -0
- package/src/http/fetch.ts +6 -6
- package/src/index.core.ts +6 -13
- package/src/serve-entry.ts +2 -7
- package/src/worker-cf-entry.ts +4 -4
- package/dist/http/describe-json.d.ts +0 -62
- package/src/http/describe-json.ts +0 -644
package/dist/http/fetch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ProtocolConfig } from "../protocol/dispatch.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { LandingInfo } from "@query-farm/vgi-rpc";
|
|
3
3
|
export interface VgiFetchOptions {
|
|
4
4
|
/** Wire-protocol config (registry + catalogInterface). */
|
|
5
5
|
protocol: Omit<ProtocolConfig, "recoverExchangeState">;
|
|
@@ -21,10 +21,10 @@ export interface VgiFetchOptions {
|
|
|
21
21
|
/** Public source-repository URL, surfaced on the landing page. */
|
|
22
22
|
repositoryUrl?: string;
|
|
23
23
|
/** Enables the standardized VGI landing surface: `GET /` serves the shared
|
|
24
|
-
* landing.html
|
|
25
|
-
* `GET /
|
|
26
|
-
*
|
|
27
|
-
|
|
24
|
+
* landing.html plus a JSON status document carrying this identity, and
|
|
25
|
+
* `GET /vgi-client.js` serves the browser client build the page reads the
|
|
26
|
+
* catalog with. */
|
|
27
|
+
landingInfo?: LandingInfo;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Build a fetch handler suitable for `export default { fetch }` in a CF
|
package/dist/index.core.d.ts
CHANGED
|
@@ -24,9 +24,9 @@ export { metadatasToArrow, arrowToMetadatas } from "./metadata/serialize.js";
|
|
|
24
24
|
export { PushdownFilters, FilteringOutputCollector, deserializeFilters, buildJoinKeysLookup, ComparisonOp, type Filter, type ConstantFilter, type IsNullFilter, type IsNotNullFilter, type InFilter, type AndFilter, type OrFilter, type StructFilter, formatPushedFilters, reprPushedFilters, } from "./filter-pushdown/index.js";
|
|
25
25
|
export { arrowStateSerializer, EXCHANGE_STATE_SCHEMA, serializeUserState, deserializeUserState } from "./protocol/state-serializer.js";
|
|
26
26
|
export { buildVgiProtocol, type ProtocolConfig } from "./protocol/dispatch.js";
|
|
27
|
-
export
|
|
27
|
+
export type { LandingInfo } from "@query-farm/vgi-rpc";
|
|
28
28
|
export { BindResultSchema, ScanFunctionResultSchema } from "./generated/vgi-protocol-schemas.js";
|
|
29
|
-
export { type AttachOptionSpec, serializeAttachOptionSpec, serializeAttachOptionSpecs } from "./catalog/attach-option.js";
|
|
29
|
+
export { type AttachOptionSpec, serializeAttachOptionSpec, serializeAttachOptionSpecs, deserializeAttachOptionSpec, deserializeAttachOptionSpecs } from "./catalog/attach-option.js";
|
|
30
30
|
export { type ColumnStatistics, serializeColumnStatistics } from "./util/statistics.js";
|
|
31
31
|
export { toUint8Array } from "./util/bytes.js";
|
|
32
32
|
export { iterRows, batchFromRows, batchFromColumns, emptyBatch, filterBatch, projectSchema, projectBatch, batchToScalarDict, batchToSecretDict, safeNumber, } from "./util/arrow/index.js";
|
package/dist/index.js
CHANGED
|
@@ -7054,6 +7054,33 @@ function serializeAttachOptionSpec(spec) {
|
|
|
7054
7054
|
function serializeAttachOptionSpecs(specs) {
|
|
7055
7055
|
return Array.from(specs, serializeAttachOptionSpec);
|
|
7056
7056
|
}
|
|
7057
|
+
function deserializeAttachOptionSpec(bytes) {
|
|
7058
|
+
const row = [...iterRows(deserializeBatch(bytes))][0];
|
|
7059
|
+
if (row === undefined) {
|
|
7060
|
+
throw new Error("Cannot deserialize AttachOptionSpec from an empty batch");
|
|
7061
|
+
}
|
|
7062
|
+
const typeSchema = deserializeSchema(toUint8Array(row.type));
|
|
7063
|
+
const type = typeSchema.fields[0].type;
|
|
7064
|
+
let value;
|
|
7065
|
+
const defaultBytes = row.default_value;
|
|
7066
|
+
if (defaultBytes != null) {
|
|
7067
|
+
const asBytes = toUint8Array(defaultBytes);
|
|
7068
|
+
if (asBytes.length > 0) {
|
|
7069
|
+
const defaultRow = [...iterRows(deserializeBatch(asBytes))][0];
|
|
7070
|
+
value = defaultRow?.value;
|
|
7071
|
+
}
|
|
7072
|
+
}
|
|
7073
|
+
return {
|
|
7074
|
+
name: String(row.name),
|
|
7075
|
+
description: String(row.description ?? ""),
|
|
7076
|
+
type,
|
|
7077
|
+
...value === undefined || value === null ? {} : { default: value },
|
|
7078
|
+
required: row.required === true
|
|
7079
|
+
};
|
|
7080
|
+
}
|
|
7081
|
+
function deserializeAttachOptionSpecs(specs) {
|
|
7082
|
+
return Array.from(specs, deserializeAttachOptionSpec);
|
|
7083
|
+
}
|
|
7057
7084
|
|
|
7058
7085
|
class MissingAttachOptionsError extends Error {
|
|
7059
7086
|
missing;
|
|
@@ -10506,415 +10533,6 @@ function buildVgiProtocol(config) {
|
|
|
10506
10533
|
registerCatalogMethods(protocol, config.catalogInterface, config.catalogName, config.signingKey);
|
|
10507
10534
|
return protocol;
|
|
10508
10535
|
}
|
|
10509
|
-
// src/http/describe-json.ts
|
|
10510
|
-
init_arrow();
|
|
10511
|
-
var LANDING_SCHEMA_VERSION = 1;
|
|
10512
|
-
var CUPOLA_BASE = "https://cupola.query-farm.services";
|
|
10513
|
-
var STRING_TAGS = {
|
|
10514
|
-
title: "vgi.title",
|
|
10515
|
-
doc_md: "vgi.doc_md",
|
|
10516
|
-
source_url: "vgi.source_url",
|
|
10517
|
-
license: "vgi.license",
|
|
10518
|
-
author: "vgi.author",
|
|
10519
|
-
copyright: "vgi.copyright",
|
|
10520
|
-
support_contact: "vgi.support_contact",
|
|
10521
|
-
support_policy_url: "vgi.support_policy_url"
|
|
10522
|
-
};
|
|
10523
|
-
var KEYWORDS_TAG = "vgi.keywords";
|
|
10524
|
-
function typeToString(type) {
|
|
10525
|
-
if (isNull(type))
|
|
10526
|
-
return "NULL";
|
|
10527
|
-
if (isUtf8(type))
|
|
10528
|
-
return "VARCHAR";
|
|
10529
|
-
if (isBinary(type))
|
|
10530
|
-
return "BLOB";
|
|
10531
|
-
if (isBool(type))
|
|
10532
|
-
return "BOOLEAN";
|
|
10533
|
-
if (isInt(type)) {
|
|
10534
|
-
const bw = type.bitWidth ?? 32;
|
|
10535
|
-
return bw === 64 ? "BIGINT" : "INTEGER";
|
|
10536
|
-
}
|
|
10537
|
-
if (isFloat(type)) {
|
|
10538
|
-
const precision = type.precision ?? 2;
|
|
10539
|
-
return precision === 1 ? "FLOAT" : "DOUBLE";
|
|
10540
|
-
}
|
|
10541
|
-
const s = type.toString?.();
|
|
10542
|
-
return s ?? String(type.typeId);
|
|
10543
|
-
}
|
|
10544
|
-
function arrowTypeString(type) {
|
|
10545
|
-
if (isNull(type))
|
|
10546
|
-
return "null";
|
|
10547
|
-
if (isBool(type))
|
|
10548
|
-
return "bool";
|
|
10549
|
-
if (isUtf8(type))
|
|
10550
|
-
return "string";
|
|
10551
|
-
if (isBinary(type))
|
|
10552
|
-
return "binary";
|
|
10553
|
-
if (isInt(type)) {
|
|
10554
|
-
const bw = type.bitWidth ?? 32;
|
|
10555
|
-
const signed = type.isSigned ?? type.signed ?? true;
|
|
10556
|
-
return `${signed ? "" : "u"}int${bw}`;
|
|
10557
|
-
}
|
|
10558
|
-
if (isFloat(type)) {
|
|
10559
|
-
const precision = type.precision ?? 2;
|
|
10560
|
-
return precision === 0 ? "halffloat" : precision === 1 ? "float" : "double";
|
|
10561
|
-
}
|
|
10562
|
-
const s = type.toString?.();
|
|
10563
|
-
return (s ?? String(type.typeId)).toLowerCase();
|
|
10564
|
-
}
|
|
10565
|
-
function fieldMeta(field3, key) {
|
|
10566
|
-
return field3.metadata.get(key);
|
|
10567
|
-
}
|
|
10568
|
-
function fieldToColumn(field3) {
|
|
10569
|
-
const col = { name: field3.name, type: typeToString(field3.type) };
|
|
10570
|
-
const comment = fieldMeta(field3, "comment") ?? fieldMeta(field3, VGI_DOC_KEY);
|
|
10571
|
-
if (comment)
|
|
10572
|
-
col.comment = comment;
|
|
10573
|
-
return col;
|
|
10574
|
-
}
|
|
10575
|
-
function readSchemaSafe(bytes) {
|
|
10576
|
-
if (!bytes || bytes.length === 0)
|
|
10577
|
-
return null;
|
|
10578
|
-
try {
|
|
10579
|
-
return deserializeSchema(bytes);
|
|
10580
|
-
} catch {
|
|
10581
|
-
return null;
|
|
10582
|
-
}
|
|
10583
|
-
}
|
|
10584
|
-
function functionDisplayType(fn) {
|
|
10585
|
-
const t = String(fn.function_type).toUpperCase();
|
|
10586
|
-
if (t === "SCALAR")
|
|
10587
|
-
return "scalar";
|
|
10588
|
-
if (t === "AGGREGATE")
|
|
10589
|
-
return "aggregate";
|
|
10590
|
-
if (fn.has_finalize)
|
|
10591
|
-
return "table_in_out";
|
|
10592
|
-
return "table";
|
|
10593
|
-
}
|
|
10594
|
-
function functionReturns(fn) {
|
|
10595
|
-
const schema3 = readSchemaSafe(fn.output_schema);
|
|
10596
|
-
if (schema3 === null || schema3.fields.length === 0)
|
|
10597
|
-
return;
|
|
10598
|
-
const t = String(fn.function_type).toUpperCase();
|
|
10599
|
-
if (t === "SCALAR" || t === "AGGREGATE") {
|
|
10600
|
-
return typeToString(schema3.fields[0].type);
|
|
10601
|
-
}
|
|
10602
|
-
const cols = schema3.fields.map((f) => `${f.name} ${typeToString(f.type)}`).join(", ");
|
|
10603
|
-
return `TABLE(${cols})`;
|
|
10604
|
-
}
|
|
10605
|
-
function functionArgs(fn) {
|
|
10606
|
-
const schema3 = readSchemaSafe(fn.arguments);
|
|
10607
|
-
if (schema3 === null)
|
|
10608
|
-
return [];
|
|
10609
|
-
const args = [];
|
|
10610
|
-
for (const field3 of schema3.fields) {
|
|
10611
|
-
if (fieldMeta(field3, VGI_TYPE_KEY) === VGI_TYPE_TABLE)
|
|
10612
|
-
continue;
|
|
10613
|
-
const arg = { name: field3.name, type: typeToString(field3.type) };
|
|
10614
|
-
if (fieldMeta(field3, VGI_ARG_KEY) === VGI_ARG_NAMED)
|
|
10615
|
-
arg.named = true;
|
|
10616
|
-
const doc = fieldMeta(field3, VGI_DOC_KEY);
|
|
10617
|
-
if (doc)
|
|
10618
|
-
arg.desc = doc;
|
|
10619
|
-
const rawDefault = fieldMeta(field3, VGI_DEFAULT_KEY);
|
|
10620
|
-
if (rawDefault !== undefined) {
|
|
10621
|
-
try {
|
|
10622
|
-
arg.default = JSON.stringify(JSON.parse(rawDefault));
|
|
10623
|
-
} catch {
|
|
10624
|
-
arg.default = rawDefault;
|
|
10625
|
-
}
|
|
10626
|
-
}
|
|
10627
|
-
args.push(arg);
|
|
10628
|
-
}
|
|
10629
|
-
return args;
|
|
10630
|
-
}
|
|
10631
|
-
function macroDisplayType(m) {
|
|
10632
|
-
return String(m.macro_type).toUpperCase() === "SCALAR" ? "scalar" : "table";
|
|
10633
|
-
}
|
|
10634
|
-
function macroDefaultJson(value) {
|
|
10635
|
-
if (typeof value === "bigint")
|
|
10636
|
-
return value.toString();
|
|
10637
|
-
try {
|
|
10638
|
-
return JSON.stringify(value);
|
|
10639
|
-
} catch {
|
|
10640
|
-
return String(value);
|
|
10641
|
-
}
|
|
10642
|
-
}
|
|
10643
|
-
function macroArgs(m) {
|
|
10644
|
-
const defaults = new Map;
|
|
10645
|
-
const defBytes = m.parameter_default_values;
|
|
10646
|
-
if (defBytes && defBytes.length > 0) {
|
|
10647
|
-
try {
|
|
10648
|
-
const batch = deserializeBatch(defBytes);
|
|
10649
|
-
for (const field3 of batch.schema.fields) {
|
|
10650
|
-
try {
|
|
10651
|
-
defaults.set(field3.name, batch.getChild(field3.name)?.get(0));
|
|
10652
|
-
} catch {}
|
|
10653
|
-
}
|
|
10654
|
-
} catch {}
|
|
10655
|
-
}
|
|
10656
|
-
const schema3 = readSchemaSafe(m.arguments_schema);
|
|
10657
|
-
const fields = schema3 ? schema3.fields : null;
|
|
10658
|
-
const fieldByName = new Map;
|
|
10659
|
-
if (fields)
|
|
10660
|
-
for (const f of fields)
|
|
10661
|
-
fieldByName.set(f.name, f);
|
|
10662
|
-
const names = fields ? fields.map((f) => f.name) : m.parameters;
|
|
10663
|
-
const args = [];
|
|
10664
|
-
for (const name of names) {
|
|
10665
|
-
const field3 = fieldByName.get(name);
|
|
10666
|
-
const arg = field3 !== undefined && !isNull(field3.type) ? { name, type: arrowTypeString(field3.type) } : { name, type: "ANY" };
|
|
10667
|
-
const doc = field3 !== undefined ? fieldMeta(field3, VGI_DOC_KEY) : undefined;
|
|
10668
|
-
if (doc)
|
|
10669
|
-
arg.desc = doc;
|
|
10670
|
-
if (defaults.has(name)) {
|
|
10671
|
-
arg.named = true;
|
|
10672
|
-
arg.default = macroDefaultJson(defaults.get(name));
|
|
10673
|
-
}
|
|
10674
|
-
args.push(arg);
|
|
10675
|
-
}
|
|
10676
|
-
return args;
|
|
10677
|
-
}
|
|
10678
|
-
function macroToObject(m) {
|
|
10679
|
-
return {
|
|
10680
|
-
name: m.name,
|
|
10681
|
-
type: macroDisplayType(m),
|
|
10682
|
-
doc: m.comment ?? "",
|
|
10683
|
-
args: macroArgs(m)
|
|
10684
|
-
};
|
|
10685
|
-
}
|
|
10686
|
-
async function schemaContents(iface, aod, name, kind) {
|
|
10687
|
-
try {
|
|
10688
|
-
if (kind === "TABLE") {
|
|
10689
|
-
return await iface.schemaContentsTables(aod, name);
|
|
10690
|
-
}
|
|
10691
|
-
return await iface.schemaContentsViews(aod, name);
|
|
10692
|
-
} catch {
|
|
10693
|
-
return [];
|
|
10694
|
-
}
|
|
10695
|
-
}
|
|
10696
|
-
async function schemaFunctions(iface, aod, name) {
|
|
10697
|
-
const out = [];
|
|
10698
|
-
for (const kind of ["SCALAR_FUNCTION", "TABLE_FUNCTION", "AGGREGATE_FUNCTION"]) {
|
|
10699
|
-
try {
|
|
10700
|
-
out.push(...await iface.schemaContentsFunctions(aod, name, kind));
|
|
10701
|
-
} catch {}
|
|
10702
|
-
}
|
|
10703
|
-
return out;
|
|
10704
|
-
}
|
|
10705
|
-
async function schemaMacros(iface, aod, name) {
|
|
10706
|
-
const out = [];
|
|
10707
|
-
for (const kind of ["SCALAR_MACRO", "TABLE_MACRO"]) {
|
|
10708
|
-
try {
|
|
10709
|
-
out.push(...await iface.schemaContentsMacros(aod, name, kind));
|
|
10710
|
-
} catch {}
|
|
10711
|
-
}
|
|
10712
|
-
return out;
|
|
10713
|
-
}
|
|
10714
|
-
async function buildSchemas(iface, aod) {
|
|
10715
|
-
let schemaInfos;
|
|
10716
|
-
try {
|
|
10717
|
-
schemaInfos = await iface.schemas(aod);
|
|
10718
|
-
} catch {
|
|
10719
|
-
return { schemas: [], counts: { schemas: 0, tables: 0, views: 0, functions: 0 } };
|
|
10720
|
-
}
|
|
10721
|
-
const schemas = [];
|
|
10722
|
-
const counts = { schemas: 0, tables: 0, views: 0, functions: 0 };
|
|
10723
|
-
for (const si of schemaInfos) {
|
|
10724
|
-
const tablesRaw = await schemaContents(iface, aod, si.name, "TABLE");
|
|
10725
|
-
const viewsRaw = await schemaContents(iface, aod, si.name, "VIEW");
|
|
10726
|
-
const funcsRaw = await schemaFunctions(iface, aod, si.name);
|
|
10727
|
-
const macrosRaw = await schemaMacros(iface, aod, si.name);
|
|
10728
|
-
const tables = tablesRaw.map((t) => {
|
|
10729
|
-
const schema3 = readSchemaSafe(t.columns);
|
|
10730
|
-
return { name: t.name, cols: schema3 ? schema3.fields.length : 0, comment: t.comment ?? "" };
|
|
10731
|
-
});
|
|
10732
|
-
const views = viewsRaw.map((v) => ({
|
|
10733
|
-
name: v.name,
|
|
10734
|
-
cols: Object.keys(v.column_comments ?? {}).length,
|
|
10735
|
-
comment: v.comment ?? "",
|
|
10736
|
-
def: v.definition
|
|
10737
|
-
}));
|
|
10738
|
-
const functions = funcsRaw.map((fn) => {
|
|
10739
|
-
const obj = {
|
|
10740
|
-
name: fn.name,
|
|
10741
|
-
type: functionDisplayType(fn),
|
|
10742
|
-
doc: fn.description ?? "",
|
|
10743
|
-
args: functionArgs(fn)
|
|
10744
|
-
};
|
|
10745
|
-
const ret = functionReturns(fn);
|
|
10746
|
-
if (ret)
|
|
10747
|
-
obj.returns = ret;
|
|
10748
|
-
return obj;
|
|
10749
|
-
});
|
|
10750
|
-
functions.push(...macrosRaw.map((m) => macroToObject(m)));
|
|
10751
|
-
functions.sort((a, b) => String(a.type).localeCompare(String(b.type)) || String(a.name).localeCompare(String(b.name)));
|
|
10752
|
-
const schemaObj = { name: si.name };
|
|
10753
|
-
if (si.comment)
|
|
10754
|
-
schemaObj.doc = si.comment;
|
|
10755
|
-
schemaObj.tables = tables;
|
|
10756
|
-
schemaObj.views = views;
|
|
10757
|
-
schemaObj.functions = functions;
|
|
10758
|
-
schemas.push(schemaObj);
|
|
10759
|
-
counts.schemas += 1;
|
|
10760
|
-
counts.tables += tables.length;
|
|
10761
|
-
counts.views += views.length;
|
|
10762
|
-
counts.functions += functions.length;
|
|
10763
|
-
}
|
|
10764
|
-
return { schemas, counts };
|
|
10765
|
-
}
|
|
10766
|
-
function catalogTags(result) {
|
|
10767
|
-
const tags = result?.tags;
|
|
10768
|
-
if (!tags)
|
|
10769
|
-
return {};
|
|
10770
|
-
const out = {};
|
|
10771
|
-
for (const [key, tag] of Object.entries(STRING_TAGS)) {
|
|
10772
|
-
const val = tags[tag];
|
|
10773
|
-
if (val)
|
|
10774
|
-
out[key] = val;
|
|
10775
|
-
}
|
|
10776
|
-
const kw = tags[KEYWORDS_TAG];
|
|
10777
|
-
if (kw) {
|
|
10778
|
-
try {
|
|
10779
|
-
const parsed = JSON.parse(kw);
|
|
10780
|
-
if (Array.isArray(parsed))
|
|
10781
|
-
out.keywords = parsed.map((k) => String(k));
|
|
10782
|
-
} catch {}
|
|
10783
|
-
}
|
|
10784
|
-
return out;
|
|
10785
|
-
}
|
|
10786
|
-
function decodeAttachOption(bytes) {
|
|
10787
|
-
try {
|
|
10788
|
-
const batch = deserializeBatch(bytes);
|
|
10789
|
-
if (batch.numRows === 0)
|
|
10790
|
-
return null;
|
|
10791
|
-
const name = String(batch.getChild("name")?.get(0) ?? "");
|
|
10792
|
-
const description = String(batch.getChild("description")?.get(0) ?? "");
|
|
10793
|
-
const typeBytes = batch.getChild("type")?.get(0);
|
|
10794
|
-
let type = "";
|
|
10795
|
-
const typeSchema = readSchemaSafe(typeBytes ?? null);
|
|
10796
|
-
if (typeSchema && typeSchema.fields.length > 0)
|
|
10797
|
-
type = typeToString(typeSchema.fields[0].type);
|
|
10798
|
-
let defaultStr = "";
|
|
10799
|
-
const defBytes = batch.getChild("default_value")?.get(0);
|
|
10800
|
-
if (defBytes) {
|
|
10801
|
-
try {
|
|
10802
|
-
const defBatch = deserializeBatch(defBytes);
|
|
10803
|
-
if (defBatch.numRows > 0) {
|
|
10804
|
-
const v = defBatch.getChild("value")?.get(0);
|
|
10805
|
-
defaultStr = v == null ? "" : String(v);
|
|
10806
|
-
}
|
|
10807
|
-
} catch {}
|
|
10808
|
-
}
|
|
10809
|
-
return { name, type, default: defaultStr, description };
|
|
10810
|
-
} catch {
|
|
10811
|
-
return null;
|
|
10812
|
-
}
|
|
10813
|
-
}
|
|
10814
|
-
async function attachCatalog(iface, name) {
|
|
10815
|
-
try {
|
|
10816
|
-
return await iface.attach(name, {}, null, null);
|
|
10817
|
-
} catch {
|
|
10818
|
-
return null;
|
|
10819
|
-
}
|
|
10820
|
-
}
|
|
10821
|
-
async function buildCatalog(iface, name, info) {
|
|
10822
|
-
const result = await attachCatalog(iface, name);
|
|
10823
|
-
const attachOptions = (info?.attach_option_specs ?? []).map((b) => decodeAttachOption(b)).filter((o) => o !== null);
|
|
10824
|
-
const dataVersions = (info?.releases ?? []).map((r) => r.summary ? { spec: r.version, label: r.summary } : { spec: r.version });
|
|
10825
|
-
let impl = info?.implementation_version ?? null;
|
|
10826
|
-
let dvs = info?.data_version_spec ?? null;
|
|
10827
|
-
if (result) {
|
|
10828
|
-
impl = result.resolved_implementation_version ?? impl;
|
|
10829
|
-
dvs = result.resolved_data_version ?? dvs;
|
|
10830
|
-
}
|
|
10831
|
-
let schemas = [];
|
|
10832
|
-
let counts = { schemas: 0, tables: 0, views: 0, functions: 0 };
|
|
10833
|
-
if (result) {
|
|
10834
|
-
const built = await buildSchemas(iface, result.attach_opaque_data);
|
|
10835
|
-
schemas = built.schemas;
|
|
10836
|
-
counts = built.counts;
|
|
10837
|
-
}
|
|
10838
|
-
return {
|
|
10839
|
-
name,
|
|
10840
|
-
implementation_version: impl,
|
|
10841
|
-
data_version_spec: dvs,
|
|
10842
|
-
data_versions: dataVersions,
|
|
10843
|
-
attach_options: attachOptions,
|
|
10844
|
-
tags: catalogTags(result),
|
|
10845
|
-
counts,
|
|
10846
|
-
schemas
|
|
10847
|
-
};
|
|
10848
|
-
}
|
|
10849
|
-
async function catalogInfoByName(iface) {
|
|
10850
|
-
const map3 = new Map;
|
|
10851
|
-
if (typeof iface.catalogsInfo === "function") {
|
|
10852
|
-
try {
|
|
10853
|
-
const infos = await iface.catalogsInfo();
|
|
10854
|
-
for (const info of infos)
|
|
10855
|
-
map3.set(info.name, info);
|
|
10856
|
-
} catch {}
|
|
10857
|
-
}
|
|
10858
|
-
return map3;
|
|
10859
|
-
}
|
|
10860
|
-
async function buildDescribeJson(iface, worker, opts = {}) {
|
|
10861
|
-
const infos = await catalogInfoByName(iface);
|
|
10862
|
-
let names;
|
|
10863
|
-
try {
|
|
10864
|
-
names = iface.catalogs();
|
|
10865
|
-
} catch {
|
|
10866
|
-
names = [];
|
|
10867
|
-
}
|
|
10868
|
-
const catalogs = [];
|
|
10869
|
-
for (const name of names) {
|
|
10870
|
-
catalogs.push(await buildCatalog(iface, name, infos.get(name)));
|
|
10871
|
-
}
|
|
10872
|
-
return {
|
|
10873
|
-
landing_schema_version: LANDING_SCHEMA_VERSION,
|
|
10874
|
-
worker: {
|
|
10875
|
-
name: worker.name,
|
|
10876
|
-
doc: worker.doc ?? "",
|
|
10877
|
-
version: worker.version ?? "unknown",
|
|
10878
|
-
lang: "typescript"
|
|
10879
|
-
},
|
|
10880
|
-
server_id: opts.serverId ?? "",
|
|
10881
|
-
oauth: opts.oauth ?? false,
|
|
10882
|
-
cupola_base: opts.cupolaBase ?? CUPOLA_BASE,
|
|
10883
|
-
catalogs
|
|
10884
|
-
};
|
|
10885
|
-
}
|
|
10886
|
-
async function buildColumnsJson(iface, catalog, schema3, table) {
|
|
10887
|
-
const result = await attachCatalog(iface, catalog);
|
|
10888
|
-
if (!result)
|
|
10889
|
-
return null;
|
|
10890
|
-
const aod = result.attach_opaque_data;
|
|
10891
|
-
const tables = await schemaContents(iface, aod, schema3, "TABLE");
|
|
10892
|
-
for (const t of tables) {
|
|
10893
|
-
if (t.name === table) {
|
|
10894
|
-
const arrow = readSchemaSafe(t.columns);
|
|
10895
|
-
return { columns: (arrow?.fields ?? []).map((f) => fieldToColumn(f)) };
|
|
10896
|
-
}
|
|
10897
|
-
}
|
|
10898
|
-
const views = await schemaContents(iface, aod, schema3, "VIEW");
|
|
10899
|
-
for (const v of views) {
|
|
10900
|
-
if (v.name === table) {
|
|
10901
|
-
return {
|
|
10902
|
-
columns: Object.entries(v.column_comments ?? {}).map(([name, comment]) => ({
|
|
10903
|
-
name,
|
|
10904
|
-
type: "",
|
|
10905
|
-
comment
|
|
10906
|
-
}))
|
|
10907
|
-
};
|
|
10908
|
-
}
|
|
10909
|
-
}
|
|
10910
|
-
return null;
|
|
10911
|
-
}
|
|
10912
|
-
function createLandingDescribe(iface, worker, opts = {}) {
|
|
10913
|
-
return {
|
|
10914
|
-
describe: (ctx) => buildDescribeJson(iface, worker, { ...ctx, cupolaBase: opts.cupolaBase }),
|
|
10915
|
-
columns: (catalog, schema3, table) => buildColumnsJson(iface, catalog, schema3, table)
|
|
10916
|
-
};
|
|
10917
|
-
}
|
|
10918
10536
|
// src/secrets/helpers.ts
|
|
10919
10537
|
function scalarStr(v) {
|
|
10920
10538
|
if (v === null || v === undefined)
|
|
@@ -12072,6 +11690,8 @@ export {
|
|
|
12072
11690
|
deserializeSchema,
|
|
12073
11691
|
deserializeFilters,
|
|
12074
11692
|
deserializeBatch,
|
|
11693
|
+
deserializeAttachOptionSpecs,
|
|
11694
|
+
deserializeAttachOptionSpec,
|
|
12075
11695
|
denseUnion2 as denseUnion,
|
|
12076
11696
|
defineTableInOutFunction,
|
|
12077
11697
|
defineTableFunction,
|
|
@@ -12094,7 +11714,6 @@ export {
|
|
|
12094
11714
|
dateMillisecond2 as dateMillisecond,
|
|
12095
11715
|
dateDay2 as dateDay,
|
|
12096
11716
|
date2 as date,
|
|
12097
|
-
createLandingDescribe,
|
|
12098
11717
|
constraintSpecFields,
|
|
12099
11718
|
columnFromArray,
|
|
12100
11719
|
codecFor,
|
|
@@ -12103,8 +11722,6 @@ export {
|
|
|
12103
11722
|
buildVgiProtocol,
|
|
12104
11723
|
buildScanBranchesResult,
|
|
12105
11724
|
buildJoinKeysLookup,
|
|
12106
|
-
buildDescribeJson,
|
|
12107
|
-
buildColumnsJson,
|
|
12108
11725
|
bool3 as bool,
|
|
12109
11726
|
binary2 as binary,
|
|
12110
11727
|
batchToSecretDict,
|
|
@@ -12152,7 +11769,6 @@ export {
|
|
|
12152
11769
|
OrderDependence,
|
|
12153
11770
|
NullHandling,
|
|
12154
11771
|
NoCatalogError,
|
|
12155
|
-
LANDING_SCHEMA_VERSION,
|
|
12156
11772
|
IntervalUnit2 as IntervalUnit,
|
|
12157
11773
|
GROUP_COLUMN_NAME,
|
|
12158
11774
|
FunctionType,
|
|
@@ -12173,7 +11789,6 @@ export {
|
|
|
12173
11789
|
CatalogInterface,
|
|
12174
11790
|
CatalogFunctionType,
|
|
12175
11791
|
CatalogAlreadyExistsError,
|
|
12176
|
-
CUPOLA_BASE,
|
|
12177
11792
|
CACHE_TTL_KEY,
|
|
12178
11793
|
CACHE_STALE_WHILE_REVALIDATE_KEY,
|
|
12179
11794
|
CACHE_STALE_IF_ERROR_KEY,
|
|
@@ -12197,4 +11812,4 @@ export {
|
|
|
12197
11812
|
ArgumentValidationError
|
|
12198
11813
|
};
|
|
12199
11814
|
|
|
12200
|
-
//# debugId=
|
|
11815
|
+
//# debugId=DE208C45586A782664756E2164756E21
|