@malloy-publisher/server 0.18.5 → 0.18.6
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/app/api-doc.yaml +37 -12
- package/dist/instrumentation.mjs +1 -1
- package/dist/package_load_worker.mjs +778 -492
- package/dist/server.mjs +1124 -342
- package/package.json +1 -1
|
@@ -197,6 +197,7 @@ function compileInputOf(b) {
|
|
|
197
197
|
holdsOnlyUngatedRows: _ungated,
|
|
198
198
|
retypedColumns: _retyped,
|
|
199
199
|
rollupKey: _rollupKey,
|
|
200
|
+
grainJoinKeys: _grainJoinKeys,
|
|
200
201
|
...read
|
|
201
202
|
} = b;
|
|
202
203
|
input = JSON.stringify(read);
|
|
@@ -337,6 +338,7 @@ var init_key_check = __esm(() => {
|
|
|
337
338
|
pair_level: { nullKey: "fails", onRepeat: "fail_build" },
|
|
338
339
|
rollup_key: { nullKey: "ignored", onRepeat: "record" },
|
|
339
340
|
parent_key: { nullKey: "fails", onRepeat: "record" },
|
|
341
|
+
grain_join_key: { nullKey: "ignored", onRepeat: "record" },
|
|
340
342
|
stored_key: { nullKey: "fails", onRepeat: "record" }
|
|
341
343
|
};
|
|
342
344
|
});
|
|
@@ -18267,6 +18269,536 @@ function keyedOverlay(files) {
|
|
|
18267
18269
|
}
|
|
18268
18270
|
var init_overlay_key = () => {};
|
|
18269
18271
|
|
|
18272
|
+
// src/service/governance/ir/sql_embeds.ts
|
|
18273
|
+
import { isSourceDef as isSourceDef6 } from "@malloydata/malloy";
|
|
18274
|
+
function sqlSelectsWithin(root) {
|
|
18275
|
+
const found = [];
|
|
18276
|
+
const seen = new Set;
|
|
18277
|
+
const stack = [root];
|
|
18278
|
+
while (stack.length > 0) {
|
|
18279
|
+
const node = stack.pop();
|
|
18280
|
+
if (Array.isArray(node)) {
|
|
18281
|
+
stack.push(...node);
|
|
18282
|
+
continue;
|
|
18283
|
+
}
|
|
18284
|
+
if (!isObj(node) || seen.has(node))
|
|
18285
|
+
continue;
|
|
18286
|
+
seen.add(node);
|
|
18287
|
+
if (node.type === "sql_select" && Array.isArray(node.selectSegments)) {
|
|
18288
|
+
found.push(node);
|
|
18289
|
+
}
|
|
18290
|
+
stack.push(...Object.values(node));
|
|
18291
|
+
}
|
|
18292
|
+
return found;
|
|
18293
|
+
}
|
|
18294
|
+
function embeddedStructs(segment, modelDef) {
|
|
18295
|
+
if (segment.type === "query") {
|
|
18296
|
+
const ref = segment.structRef;
|
|
18297
|
+
let base = ref;
|
|
18298
|
+
if (typeof ref === "string")
|
|
18299
|
+
base = modelDef.contents[ref];
|
|
18300
|
+
if (!isObj(base) || !isSourceDef6(base)) {
|
|
18301
|
+
return {
|
|
18302
|
+
unreadable: "its source reference does not resolve in the model",
|
|
18303
|
+
label: typeof ref === "string" ? ref : "<embedded query>"
|
|
18304
|
+
};
|
|
18305
|
+
}
|
|
18306
|
+
const structs = [base];
|
|
18307
|
+
const resolved = segment.compositeResolvedSourceDef;
|
|
18308
|
+
if (isObj(resolved) && isSourceDef6(resolved)) {
|
|
18309
|
+
structs.push(resolved);
|
|
18310
|
+
}
|
|
18311
|
+
return { structs };
|
|
18312
|
+
}
|
|
18313
|
+
if (isSourceDef6(segment)) {
|
|
18314
|
+
return { structs: [segment] };
|
|
18315
|
+
}
|
|
18316
|
+
return {
|
|
18317
|
+
unreadable: `its segment shape (type ${JSON.stringify(segment.type)}) is not one Publisher reads`,
|
|
18318
|
+
label: labelOf(segment)
|
|
18319
|
+
};
|
|
18320
|
+
}
|
|
18321
|
+
var isObj = (value) => typeof value === "object" && value !== null, INLINE_SQL = "<inline sql()>", labelOf = (struct) => {
|
|
18322
|
+
const label = struct.as ?? struct.name;
|
|
18323
|
+
if (typeof label !== "string")
|
|
18324
|
+
return "<unnamed>";
|
|
18325
|
+
return label.startsWith("sql://") ? INLINE_SQL : label;
|
|
18326
|
+
};
|
|
18327
|
+
var init_sql_embeds = () => {};
|
|
18328
|
+
|
|
18329
|
+
// src/service/materialization/text/source_map.ts
|
|
18330
|
+
import { isSourceDef as isSourceDef7 } from "@malloydata/malloy";
|
|
18331
|
+
function structRefSourceId(structRef) {
|
|
18332
|
+
if (typeof structRef === "string")
|
|
18333
|
+
return structRef;
|
|
18334
|
+
const sourceID = structRef?.sourceID;
|
|
18335
|
+
return typeof sourceID === "string" && sourceID.length > 0 ? sourceID : undefined;
|
|
18336
|
+
}
|
|
18337
|
+
function byId(model, id) {
|
|
18338
|
+
const entry = model?.sourceRegistry?.[id]?.entry;
|
|
18339
|
+
if (!entry)
|
|
18340
|
+
return;
|
|
18341
|
+
if (entry.type === "source_registry_reference" && entry.name) {
|
|
18342
|
+
return model?.contents?.[entry.name];
|
|
18343
|
+
}
|
|
18344
|
+
return entry;
|
|
18345
|
+
}
|
|
18346
|
+
function baseEdgeOf(def, modelDef) {
|
|
18347
|
+
const edge = sourceBaseEdge(def, modelDef);
|
|
18348
|
+
return edge && {
|
|
18349
|
+
hop: edge.hop,
|
|
18350
|
+
sourceID: edge.sourceID,
|
|
18351
|
+
def: edge.def
|
|
18352
|
+
};
|
|
18353
|
+
}
|
|
18354
|
+
function compositeMemberIds(def) {
|
|
18355
|
+
if (def.type !== "composite" || !Array.isArray(def.sources))
|
|
18356
|
+
return [];
|
|
18357
|
+
return def.sources.flatMap((member) => {
|
|
18358
|
+
const id = structRefSourceId(member);
|
|
18359
|
+
return id === undefined ? [] : [id];
|
|
18360
|
+
});
|
|
18361
|
+
}
|
|
18362
|
+
function kindOf(def, base) {
|
|
18363
|
+
if (def.type === "composite")
|
|
18364
|
+
return "composite";
|
|
18365
|
+
if (!base)
|
|
18366
|
+
return "table";
|
|
18367
|
+
if (base.hop === "extends")
|
|
18368
|
+
return "extend";
|
|
18369
|
+
if (base.hop === "rename")
|
|
18370
|
+
return "rename";
|
|
18371
|
+
return "query";
|
|
18372
|
+
}
|
|
18373
|
+
function detachedNode(def) {
|
|
18374
|
+
const d = def;
|
|
18375
|
+
if (!d || typeof d !== "object" || typeof d.sourceID !== "string") {
|
|
18376
|
+
return;
|
|
18377
|
+
}
|
|
18378
|
+
const base = baseEdgeOf(d, undefined);
|
|
18379
|
+
return {
|
|
18380
|
+
sourceID: d.sourceID,
|
|
18381
|
+
name: undefined,
|
|
18382
|
+
kind: kindOf(d, base),
|
|
18383
|
+
base,
|
|
18384
|
+
members: compositeMemberIds(d),
|
|
18385
|
+
def: d
|
|
18386
|
+
};
|
|
18387
|
+
}
|
|
18388
|
+
function sourceChain(struct, modelDef) {
|
|
18389
|
+
return SourceMap.of(modelDef).chainOf(struct);
|
|
18390
|
+
}
|
|
18391
|
+
function pipelineReferences(pipeline) {
|
|
18392
|
+
const out = [];
|
|
18393
|
+
let tooDeep = false;
|
|
18394
|
+
const walk = (node, depth) => {
|
|
18395
|
+
if (tooDeep)
|
|
18396
|
+
return;
|
|
18397
|
+
if (depth > MAX_PIPELINE_DEPTH) {
|
|
18398
|
+
tooDeep = true;
|
|
18399
|
+
return;
|
|
18400
|
+
}
|
|
18401
|
+
if (node === null || typeof node !== "object")
|
|
18402
|
+
return;
|
|
18403
|
+
if (Array.isArray(node)) {
|
|
18404
|
+
for (const item of node)
|
|
18405
|
+
walk(item, depth + 1);
|
|
18406
|
+
return;
|
|
18407
|
+
}
|
|
18408
|
+
const record = node;
|
|
18409
|
+
if (typeof record.join === "string") {
|
|
18410
|
+
const sourceID = typeof record.sourceID === "string" ? record.sourceID : undefined;
|
|
18411
|
+
out.push({ sourceID, ref: sourceID ?? node });
|
|
18412
|
+
return;
|
|
18413
|
+
}
|
|
18414
|
+
if (record.structRef !== undefined) {
|
|
18415
|
+
out.push({
|
|
18416
|
+
sourceID: structRefSourceId(record.structRef),
|
|
18417
|
+
ref: record.structRef
|
|
18418
|
+
});
|
|
18419
|
+
}
|
|
18420
|
+
for (const [key, value] of Object.entries(record)) {
|
|
18421
|
+
if (key === "structRef")
|
|
18422
|
+
continue;
|
|
18423
|
+
walk(value, depth + 1);
|
|
18424
|
+
}
|
|
18425
|
+
};
|
|
18426
|
+
walk(pipeline, 0);
|
|
18427
|
+
return tooDeep ? undefined : out;
|
|
18428
|
+
}
|
|
18429
|
+
function reachableSourceIDs(roots, modelDef) {
|
|
18430
|
+
const ids = new Set;
|
|
18431
|
+
const seen = new Set;
|
|
18432
|
+
const add = (value) => {
|
|
18433
|
+
if (typeof value === "string" && value.length > 0)
|
|
18434
|
+
ids.add(value);
|
|
18435
|
+
};
|
|
18436
|
+
const scanWhole = (node, depth) => {
|
|
18437
|
+
if (depth > MAX_PIPELINE_DEPTH || node === null || typeof node !== "object")
|
|
18438
|
+
return;
|
|
18439
|
+
if (Array.isArray(node)) {
|
|
18440
|
+
for (const item of node)
|
|
18441
|
+
scanWhole(item, depth + 1);
|
|
18442
|
+
return;
|
|
18443
|
+
}
|
|
18444
|
+
const record = node;
|
|
18445
|
+
for (const key of ["sourceID", "referenceID", "extends"])
|
|
18446
|
+
add(record[key]);
|
|
18447
|
+
for (const value of Object.values(record))
|
|
18448
|
+
scanWhole(value, depth + 1);
|
|
18449
|
+
};
|
|
18450
|
+
const visitPipeline = (pipeline) => {
|
|
18451
|
+
if (pipeline === undefined)
|
|
18452
|
+
return;
|
|
18453
|
+
const refs = pipelineReferences(pipeline);
|
|
18454
|
+
if (refs === undefined) {
|
|
18455
|
+
scanWhole(pipeline, 0);
|
|
18456
|
+
return;
|
|
18457
|
+
}
|
|
18458
|
+
for (const { sourceID, ref } of refs) {
|
|
18459
|
+
add(sourceID);
|
|
18460
|
+
if (ref !== null && typeof ref === "object")
|
|
18461
|
+
visit(ref);
|
|
18462
|
+
}
|
|
18463
|
+
};
|
|
18464
|
+
const visit = (node) => {
|
|
18465
|
+
if (node === null || typeof node !== "object" || seen.has(node))
|
|
18466
|
+
return;
|
|
18467
|
+
seen.add(node);
|
|
18468
|
+
const def = node;
|
|
18469
|
+
add(def.sourceID);
|
|
18470
|
+
add(def.referenceID);
|
|
18471
|
+
add(def.extends);
|
|
18472
|
+
if (def.structRef !== undefined) {
|
|
18473
|
+
add(structRefSourceId(def.structRef));
|
|
18474
|
+
if (typeof def.structRef === "object")
|
|
18475
|
+
visit(def.structRef);
|
|
18476
|
+
}
|
|
18477
|
+
visitPipeline(def.pipeline);
|
|
18478
|
+
if (def.query) {
|
|
18479
|
+
add(structRefSourceId(def.query.structRef));
|
|
18480
|
+
if (def.query.structRef && typeof def.query.structRef === "object") {
|
|
18481
|
+
visit(def.query.structRef);
|
|
18482
|
+
}
|
|
18483
|
+
visit(def.query.compositeResolvedSourceDef);
|
|
18484
|
+
visitPipeline(def.query.pipeline);
|
|
18485
|
+
}
|
|
18486
|
+
for (const member of def.sources ?? []) {
|
|
18487
|
+
add(structRefSourceId(member));
|
|
18488
|
+
visit(typeof member === "string" ? byId(modelDef, member) : member);
|
|
18489
|
+
}
|
|
18490
|
+
if (modelDef !== undefined && isSourceDef7(node)) {
|
|
18491
|
+
const struct = node;
|
|
18492
|
+
const model = modelDef;
|
|
18493
|
+
const declared = resolveDeclaredSource(struct, model);
|
|
18494
|
+
if (declared.kind === "resolved")
|
|
18495
|
+
visit(declared.source);
|
|
18496
|
+
visit(resolveExtendedSource(struct, model));
|
|
18497
|
+
visit(inferredExtendedSource(struct, model));
|
|
18498
|
+
visit(resolveQuerySourceBase(struct, model));
|
|
18499
|
+
visit(resolveCompositeResolvedBase(struct));
|
|
18500
|
+
}
|
|
18501
|
+
const segments = def.selectSegments;
|
|
18502
|
+
if (Array.isArray(segments)) {
|
|
18503
|
+
for (const segment of segments)
|
|
18504
|
+
visitEmbed(segment);
|
|
18505
|
+
}
|
|
18506
|
+
for (const field of def.fields ?? []) {
|
|
18507
|
+
const f = field;
|
|
18508
|
+
if (typeof f?.join === "string") {
|
|
18509
|
+
add(f.sourceID);
|
|
18510
|
+
visit(field);
|
|
18511
|
+
} else if (f?.pipeline !== undefined) {
|
|
18512
|
+
visitPipeline(f.pipeline);
|
|
18513
|
+
}
|
|
18514
|
+
}
|
|
18515
|
+
};
|
|
18516
|
+
const visitEmbed = (segment) => {
|
|
18517
|
+
if (segment === null || typeof segment !== "object")
|
|
18518
|
+
return;
|
|
18519
|
+
const embed = segment;
|
|
18520
|
+
if ("sql" in embed && embed.type === undefined)
|
|
18521
|
+
return;
|
|
18522
|
+
add(structRefSourceId(embed.structRef));
|
|
18523
|
+
const read = modelDef !== undefined ? embeddedStructs(embed, modelDef) : undefined;
|
|
18524
|
+
if (read !== undefined && "structs" in read) {
|
|
18525
|
+
for (const struct of read.structs)
|
|
18526
|
+
visit(struct);
|
|
18527
|
+
} else {
|
|
18528
|
+
scanWhole(embed, 0);
|
|
18529
|
+
}
|
|
18530
|
+
visitPipeline(embed.pipeline);
|
|
18531
|
+
};
|
|
18532
|
+
for (const root of roots)
|
|
18533
|
+
visit(root);
|
|
18534
|
+
return ids;
|
|
18535
|
+
}
|
|
18536
|
+
function fieldKey(field) {
|
|
18537
|
+
const f = field;
|
|
18538
|
+
if (typeof f?.as === "string")
|
|
18539
|
+
return f.as;
|
|
18540
|
+
return typeof f?.name === "string" ? f.name : "";
|
|
18541
|
+
}
|
|
18542
|
+
function reachPersisted(ctx, name, isPersisted) {
|
|
18543
|
+
const persisted = new Map;
|
|
18544
|
+
const rawLeaves = new Set;
|
|
18545
|
+
const rawVia = new Set;
|
|
18546
|
+
const visited = new Set;
|
|
18547
|
+
const seen = new Set;
|
|
18548
|
+
const defName = (def) => {
|
|
18549
|
+
const id = def.sourceID;
|
|
18550
|
+
return typeof id === "string" ? ctx.sourceNameById.get(id) : undefined;
|
|
18551
|
+
};
|
|
18552
|
+
const reachRaw = (leaf, via) => {
|
|
18553
|
+
rawLeaves.add(leaf);
|
|
18554
|
+
rawVia.add(via);
|
|
18555
|
+
};
|
|
18556
|
+
const nameOf = (sourceID) => sourceID.split("@")[0];
|
|
18557
|
+
const follow = (ref, via) => {
|
|
18558
|
+
if (typeof ref === "string") {
|
|
18559
|
+
const next = ctx.sourceNameById.get(ref);
|
|
18560
|
+
if (next !== undefined) {
|
|
18561
|
+
visit(ctx.contents[next], next, false, via);
|
|
18562
|
+
return;
|
|
18563
|
+
}
|
|
18564
|
+
const refName = nameOf(ref);
|
|
18565
|
+
if (isPersisted(refName, ref)) {
|
|
18566
|
+
visited.add(refName);
|
|
18567
|
+
persisted.set(ref, { name: refName, sourceID: ref });
|
|
18568
|
+
return;
|
|
18569
|
+
}
|
|
18570
|
+
reachRaw(refName, via);
|
|
18571
|
+
return;
|
|
18572
|
+
}
|
|
18573
|
+
if (ref !== null && typeof ref === "object") {
|
|
18574
|
+
const def = ref;
|
|
18575
|
+
visit(def, defName(def), false, via);
|
|
18576
|
+
return;
|
|
18577
|
+
}
|
|
18578
|
+
reachRaw("(unnamed)", via);
|
|
18579
|
+
};
|
|
18580
|
+
const followJoins = (fields, sourceName) => {
|
|
18581
|
+
for (const field of fields ?? []) {
|
|
18582
|
+
const f = field;
|
|
18583
|
+
if (typeof f.join !== "string")
|
|
18584
|
+
continue;
|
|
18585
|
+
follow(typeof f.sourceID === "string" ? f.sourceID : field, sourceName);
|
|
18586
|
+
}
|
|
18587
|
+
};
|
|
18588
|
+
const ownJoins = (def) => {
|
|
18589
|
+
const baseName = typeof def.extends === "string" ? ctx.sourceNameById.get(def.extends) : undefined;
|
|
18590
|
+
const baseFields = new Set((baseName ? ctx.contents[baseName]?.fields ?? [] : []).map(fieldKey));
|
|
18591
|
+
return (def.fields ?? []).filter((f) => !baseFields.has(fieldKey(f)));
|
|
18592
|
+
};
|
|
18593
|
+
const visit = (def, sourceName, root, via) => {
|
|
18594
|
+
const label = sourceName ?? via;
|
|
18595
|
+
if (!def) {
|
|
18596
|
+
reachRaw(label, via);
|
|
18597
|
+
return;
|
|
18598
|
+
}
|
|
18599
|
+
if (seen.has(def))
|
|
18600
|
+
return;
|
|
18601
|
+
seen.add(def);
|
|
18602
|
+
if (!root && sourceName !== undefined)
|
|
18603
|
+
visited.add(sourceName);
|
|
18604
|
+
const sourceID = def.sourceID;
|
|
18605
|
+
if (!root && sourceName !== undefined && typeof sourceID === "string" && isPersisted(sourceName, sourceID)) {
|
|
18606
|
+
persisted.set(sourceID, { name: sourceName, sourceID });
|
|
18607
|
+
if (typeof def.extends === "string") {
|
|
18608
|
+
followJoins(ownJoins(def), sourceName);
|
|
18609
|
+
}
|
|
18610
|
+
return;
|
|
18611
|
+
}
|
|
18612
|
+
const base = typeof def.extends === "string" ? def.extends : def.type === "query_source" ? def.query?.structRef : undefined;
|
|
18613
|
+
if (base === undefined) {
|
|
18614
|
+
const inferred = inferredExtendedSource(def, ctx);
|
|
18615
|
+
if (inferred) {
|
|
18616
|
+
follow(inferred, label);
|
|
18617
|
+
const baseFields = new Set((inferred.fields ?? []).map(fieldKey));
|
|
18618
|
+
followJoins((def.fields ?? []).filter((f) => !baseFields.has(fieldKey(f))), label);
|
|
18619
|
+
return;
|
|
18620
|
+
}
|
|
18621
|
+
reachRaw(label, via);
|
|
18622
|
+
return;
|
|
18623
|
+
}
|
|
18624
|
+
follow(base, label);
|
|
18625
|
+
if (typeof def.extends !== "string") {
|
|
18626
|
+
const refs = pipelineReferences(def.query?.pipeline);
|
|
18627
|
+
for (const { ref } of refs ?? [{ ref: undefined }]) {
|
|
18628
|
+
follow(ref, label);
|
|
18629
|
+
}
|
|
18630
|
+
}
|
|
18631
|
+
followJoins(def.fields, label);
|
|
18632
|
+
};
|
|
18633
|
+
visit(ctx.contents[name], name, true, name);
|
|
18634
|
+
return {
|
|
18635
|
+
persisted: [...persisted.values()],
|
|
18636
|
+
raw: rawLeaves.size > 0,
|
|
18637
|
+
rawLeaves: [...rawLeaves],
|
|
18638
|
+
rawVia: [...rawVia],
|
|
18639
|
+
visited: [...visited]
|
|
18640
|
+
};
|
|
18641
|
+
}
|
|
18642
|
+
var SourceMap, MAX_PIPELINE_DEPTH = 200;
|
|
18643
|
+
var init_source_map = __esm(() => {
|
|
18644
|
+
init_sql_embeds();
|
|
18645
|
+
init_source_graph();
|
|
18646
|
+
SourceMap = class SourceMap {
|
|
18647
|
+
modelDef;
|
|
18648
|
+
static memo = new WeakMap;
|
|
18649
|
+
nodesById = new Map;
|
|
18650
|
+
idsByName = new Map;
|
|
18651
|
+
constructor(modelDef) {
|
|
18652
|
+
this.modelDef = modelDef;
|
|
18653
|
+
const model = modelDef;
|
|
18654
|
+
for (const [name, value] of Object.entries(model?.contents ?? {})) {
|
|
18655
|
+
const def = value;
|
|
18656
|
+
if (typeof def?.sourceID !== "string")
|
|
18657
|
+
continue;
|
|
18658
|
+
this.idsByName.set(name, def.sourceID);
|
|
18659
|
+
this.add(def, name);
|
|
18660
|
+
}
|
|
18661
|
+
for (const id of Object.keys(model?.sourceRegistry ?? {})) {
|
|
18662
|
+
if (this.nodesById.has(id))
|
|
18663
|
+
continue;
|
|
18664
|
+
const def = byId(model, id);
|
|
18665
|
+
if (def && typeof def.sourceID === "string")
|
|
18666
|
+
this.add(def, undefined);
|
|
18667
|
+
}
|
|
18668
|
+
}
|
|
18669
|
+
static of(modelDef) {
|
|
18670
|
+
if (modelDef === null || typeof modelDef !== "object") {
|
|
18671
|
+
return new SourceMap(modelDef);
|
|
18672
|
+
}
|
|
18673
|
+
let map = SourceMap.memo.get(modelDef);
|
|
18674
|
+
if (!map) {
|
|
18675
|
+
map = new SourceMap(modelDef);
|
|
18676
|
+
SourceMap.memo.set(modelDef, map);
|
|
18677
|
+
}
|
|
18678
|
+
return map;
|
|
18679
|
+
}
|
|
18680
|
+
add(def, name) {
|
|
18681
|
+
const sourceID = def.sourceID;
|
|
18682
|
+
if (this.nodesById.has(sourceID))
|
|
18683
|
+
return;
|
|
18684
|
+
const base = baseEdgeOf(def, this.modelDef);
|
|
18685
|
+
this.nodesById.set(sourceID, {
|
|
18686
|
+
sourceID,
|
|
18687
|
+
name,
|
|
18688
|
+
kind: kindOf(def, base),
|
|
18689
|
+
base,
|
|
18690
|
+
members: compositeMemberIds(def),
|
|
18691
|
+
def
|
|
18692
|
+
});
|
|
18693
|
+
}
|
|
18694
|
+
model() {
|
|
18695
|
+
return this.modelDef;
|
|
18696
|
+
}
|
|
18697
|
+
node(sourceID) {
|
|
18698
|
+
return this.nodesById.get(sourceID);
|
|
18699
|
+
}
|
|
18700
|
+
sourceIDOf(name) {
|
|
18701
|
+
return this.idsByName.get(name);
|
|
18702
|
+
}
|
|
18703
|
+
joinsOf(sourceID) {
|
|
18704
|
+
const node = this.nodesById.get(sourceID);
|
|
18705
|
+
return node ? sourceJoins(node.def) : [];
|
|
18706
|
+
}
|
|
18707
|
+
fieldJoinsOf(sourceID) {
|
|
18708
|
+
const node = this.nodesById.get(sourceID);
|
|
18709
|
+
return node ? fieldJoinUsage(node.def) : new Map;
|
|
18710
|
+
}
|
|
18711
|
+
filterJoinsOf(sourceID) {
|
|
18712
|
+
const node = this.nodesById.get(sourceID);
|
|
18713
|
+
return node ? filterJoinReads(node.def) : undefined;
|
|
18714
|
+
}
|
|
18715
|
+
joinedReadsOf(join) {
|
|
18716
|
+
return joinedSourceReads(join);
|
|
18717
|
+
}
|
|
18718
|
+
nodes() {
|
|
18719
|
+
return [...this.nodesById.values()];
|
|
18720
|
+
}
|
|
18721
|
+
chainOf(struct) {
|
|
18722
|
+
const out = [];
|
|
18723
|
+
const seen = new Set;
|
|
18724
|
+
let current = struct;
|
|
18725
|
+
for (let hops = 0;current && hops < 64; hops++) {
|
|
18726
|
+
if (seen.has(current))
|
|
18727
|
+
break;
|
|
18728
|
+
seen.add(current);
|
|
18729
|
+
const id = current.sourceID;
|
|
18730
|
+
if (typeof id === "string" && !out.includes(id))
|
|
18731
|
+
out.push(id);
|
|
18732
|
+
const next = nextSourceInChain(current, this.modelDef);
|
|
18733
|
+
if (!next) {
|
|
18734
|
+
for (const ref of [current.referenceID, current.extends]) {
|
|
18735
|
+
if (typeof ref === "string" && !out.includes(ref))
|
|
18736
|
+
out.push(ref);
|
|
18737
|
+
}
|
|
18738
|
+
}
|
|
18739
|
+
current = next;
|
|
18740
|
+
}
|
|
18741
|
+
return out;
|
|
18742
|
+
}
|
|
18743
|
+
};
|
|
18744
|
+
});
|
|
18745
|
+
|
|
18746
|
+
// src/service/materialization/serve/sql_embed_reads.ts
|
|
18747
|
+
function sqlEmbedReads(modelDefs) {
|
|
18748
|
+
const out = new Map;
|
|
18749
|
+
for (const modelDef of modelDefs) {
|
|
18750
|
+
for (const select of sqlSelectsWithin(modelDef)) {
|
|
18751
|
+
const connection = select.connection;
|
|
18752
|
+
if (typeof connection !== "string")
|
|
18753
|
+
continue;
|
|
18754
|
+
const segments = select.selectSegments.filter((s) => typeof s === "object" && s !== null && !(("sql" in s) && s.type === undefined));
|
|
18755
|
+
if (segments.length === 0)
|
|
18756
|
+
continue;
|
|
18757
|
+
const isQuery = (s) => s.type === "query";
|
|
18758
|
+
const read = {
|
|
18759
|
+
via: labelOf(select),
|
|
18760
|
+
connection,
|
|
18761
|
+
...typeof select.sourceID === "string" ? { sourceID: select.sourceID } : {},
|
|
18762
|
+
reaches: reachableSourceIDs(segments.filter(isQuery), modelDef),
|
|
18763
|
+
bareReaches: reachableSourceIDs(segments.filter((s) => !isQuery(s)), modelDef)
|
|
18764
|
+
};
|
|
18765
|
+
const key = [
|
|
18766
|
+
read.via,
|
|
18767
|
+
connection,
|
|
18768
|
+
[...read.reaches].sort().join(","),
|
|
18769
|
+
[...read.bareReaches].sort().join(",")
|
|
18770
|
+
].join("\x00");
|
|
18771
|
+
if (!out.has(key))
|
|
18772
|
+
out.set(key, read);
|
|
18773
|
+
}
|
|
18774
|
+
}
|
|
18775
|
+
return [...out.values()];
|
|
18776
|
+
}
|
|
18777
|
+
function conflictingSqlEmbeds(reads, sourceID, servedOn, rerooted) {
|
|
18778
|
+
const out = [];
|
|
18779
|
+
for (const read of reads) {
|
|
18780
|
+
if (read.sourceID !== undefined && rerooted(read.sourceID))
|
|
18781
|
+
continue;
|
|
18782
|
+
if (read.bareReaches.has(sourceID)) {
|
|
18783
|
+
out.push({ read, conflict: "bare" });
|
|
18784
|
+
} else if (read.connection !== servedOn && read.reaches.has(sourceID)) {
|
|
18785
|
+
out.push({ read, conflict: "cross_connection" });
|
|
18786
|
+
}
|
|
18787
|
+
}
|
|
18788
|
+
return out;
|
|
18789
|
+
}
|
|
18790
|
+
function ownSqlEmbedReach(struct, modelDef) {
|
|
18791
|
+
const select = struct;
|
|
18792
|
+
if (select?.type !== "sql_select" || !Array.isArray(select.selectSegments)) {
|
|
18793
|
+
return new Set;
|
|
18794
|
+
}
|
|
18795
|
+
return reachableSourceIDs(select.selectSegments.filter((s) => typeof s === "object" && s !== null && !(("sql" in s) && s.type === undefined)), modelDef);
|
|
18796
|
+
}
|
|
18797
|
+
var init_sql_embed_reads = __esm(() => {
|
|
18798
|
+
init_sql_embeds();
|
|
18799
|
+
init_source_map();
|
|
18800
|
+
});
|
|
18801
|
+
|
|
18270
18802
|
// src/service/event_loop_yield.ts
|
|
18271
18803
|
function yieldToEventLoop() {
|
|
18272
18804
|
return new Promise((resolve) => setImmediate(resolve));
|
|
@@ -19062,7 +19594,7 @@ var init_gate_registry_walk = __esm(() => {
|
|
|
19062
19594
|
// src/service/source_extraction.ts
|
|
19063
19595
|
import {
|
|
19064
19596
|
isJoined as isJoined4,
|
|
19065
|
-
isSourceDef as
|
|
19597
|
+
isSourceDef as isSourceDef8
|
|
19066
19598
|
} from "@malloydata/malloy";
|
|
19067
19599
|
function joinFieldNamesUnresolvableDeclaration(field, modelDef) {
|
|
19068
19600
|
const ids = [field.referenceID, field.sourceID].filter((id) => !!id);
|
|
@@ -19073,7 +19605,7 @@ function joinFieldNamesUnresolvableDeclaration(field, modelDef) {
|
|
|
19073
19605
|
if (!entry)
|
|
19074
19606
|
continue;
|
|
19075
19607
|
const declared = entry.type === "source_registry_reference" ? modelDef.contents[entry.name] : entry;
|
|
19076
|
-
if (declared &&
|
|
19608
|
+
if (declared && isSourceDef8(declared))
|
|
19077
19609
|
return false;
|
|
19078
19610
|
}
|
|
19079
19611
|
return true;
|
|
@@ -19091,7 +19623,7 @@ function considerNoteOwner(declaredBy, note, candidate) {
|
|
|
19091
19623
|
}
|
|
19092
19624
|
}
|
|
19093
19625
|
function collectSourceInfos(modelDef) {
|
|
19094
|
-
const names = Object.keys(modelDef.contents).filter((name) =>
|
|
19626
|
+
const names = Object.keys(modelDef.contents).filter((name) => isSourceDef8(modelDef.contents[name]));
|
|
19095
19627
|
const exports = [...new Set([...modelDef.exports, ...names])];
|
|
19096
19628
|
return modelInfoOf({ ...modelDef, exports }).entries.filter((entry) => entry.kind === "source");
|
|
19097
19629
|
}
|
|
@@ -19107,7 +19639,7 @@ function extractSourcesFromModelDef(modelDef, givens, onParseError) {
|
|
|
19107
19639
|
const nearMissAuthorize = [];
|
|
19108
19640
|
const sweptStructs = [];
|
|
19109
19641
|
for (const obj of Object.values(modelDef.contents)) {
|
|
19110
|
-
if (!
|
|
19642
|
+
if (!isSourceDef8(obj))
|
|
19111
19643
|
continue;
|
|
19112
19644
|
const struct = obj;
|
|
19113
19645
|
sweptStructs.push(obj);
|
|
@@ -19127,7 +19659,7 @@ function extractSourcesFromModelDef(modelDef, givens, onParseError) {
|
|
|
19127
19659
|
const entry = value.entry;
|
|
19128
19660
|
if (entry.type === "source_registry_reference")
|
|
19129
19661
|
continue;
|
|
19130
|
-
if (!
|
|
19662
|
+
if (!isSourceDef8(entry))
|
|
19131
19663
|
continue;
|
|
19132
19664
|
sweptStructs.push(entry);
|
|
19133
19665
|
for (const note of ownLevelNotes(entry.annotations)) {
|
|
@@ -19169,7 +19701,7 @@ function extractSourcesFromModelDef(modelDef, givens, onParseError) {
|
|
|
19169
19701
|
});
|
|
19170
19702
|
}
|
|
19171
19703
|
}
|
|
19172
|
-
const sources = Object.values(modelDef.contents).filter((obj) =>
|
|
19704
|
+
const sources = Object.values(modelDef.contents).filter((obj) => isSourceDef8(obj)).map((sourceObj) => {
|
|
19173
19705
|
const struct = sourceObj;
|
|
19174
19706
|
const sourceName = struct.as || struct.name;
|
|
19175
19707
|
const annotations = annotationTexts(struct.annotations);
|
|
@@ -19238,7 +19770,7 @@ function extractSourcesFromModelDef(modelDef, givens, onParseError) {
|
|
|
19238
19770
|
continue;
|
|
19239
19771
|
}
|
|
19240
19772
|
const fieldName = field.as || field.name;
|
|
19241
|
-
if (isJoined4(field) &&
|
|
19773
|
+
if (isJoined4(field) && isSourceDef8(field)) {
|
|
19242
19774
|
const joinedStruct = field;
|
|
19243
19775
|
if (joinFieldNamesUnresolvableDeclaration(joinedStruct, modelDef)) {
|
|
19244
19776
|
continue;
|
|
@@ -19303,54 +19835,6 @@ var init_source_extraction = __esm(() => {
|
|
|
19303
19835
|
});
|
|
19304
19836
|
|
|
19305
19837
|
// src/service/sql_embed_gates.ts
|
|
19306
|
-
import { isSourceDef as isSourceDef7 } from "@malloydata/malloy";
|
|
19307
|
-
function sqlSelectsWithin(root) {
|
|
19308
|
-
const found = [];
|
|
19309
|
-
const seen = new Set;
|
|
19310
|
-
const stack = [root];
|
|
19311
|
-
while (stack.length > 0) {
|
|
19312
|
-
const node = stack.pop();
|
|
19313
|
-
if (Array.isArray(node)) {
|
|
19314
|
-
stack.push(...node);
|
|
19315
|
-
continue;
|
|
19316
|
-
}
|
|
19317
|
-
if (!isObj(node) || seen.has(node))
|
|
19318
|
-
continue;
|
|
19319
|
-
seen.add(node);
|
|
19320
|
-
if (node.type === "sql_select" && Array.isArray(node.selectSegments)) {
|
|
19321
|
-
found.push(node);
|
|
19322
|
-
}
|
|
19323
|
-
stack.push(...Object.values(node));
|
|
19324
|
-
}
|
|
19325
|
-
return found;
|
|
19326
|
-
}
|
|
19327
|
-
function embeddedStructs(segment, modelDef) {
|
|
19328
|
-
if (segment.type === "query") {
|
|
19329
|
-
const ref = segment.structRef;
|
|
19330
|
-
let base = ref;
|
|
19331
|
-
if (typeof ref === "string")
|
|
19332
|
-
base = modelDef.contents[ref];
|
|
19333
|
-
if (!isObj(base) || !isSourceDef7(base)) {
|
|
19334
|
-
return {
|
|
19335
|
-
unreadable: "its source reference does not resolve in the model",
|
|
19336
|
-
label: typeof ref === "string" ? ref : "<embedded query>"
|
|
19337
|
-
};
|
|
19338
|
-
}
|
|
19339
|
-
const structs = [base];
|
|
19340
|
-
const resolved = segment.compositeResolvedSourceDef;
|
|
19341
|
-
if (isObj(resolved) && isSourceDef7(resolved)) {
|
|
19342
|
-
structs.push(resolved);
|
|
19343
|
-
}
|
|
19344
|
-
return { structs };
|
|
19345
|
-
}
|
|
19346
|
-
if (isSourceDef7(segment)) {
|
|
19347
|
-
return { structs: [segment] };
|
|
19348
|
-
}
|
|
19349
|
-
return {
|
|
19350
|
-
unreadable: `its segment shape (type ${JSON.stringify(segment.type)}) is not one Publisher reads`,
|
|
19351
|
-
label: labelOf(segment)
|
|
19352
|
-
};
|
|
19353
|
-
}
|
|
19354
19838
|
function runLabel(query, index, cell) {
|
|
19355
19839
|
const line = isObj(query) ? query.location?.range?.start?.line : undefined;
|
|
19356
19840
|
const at = typeof line === "number" ? `line ${line + 1}` : `#${index + 1}`;
|
|
@@ -19466,13 +19950,8 @@ function assertNoSqlEmbedsOfGatedSources(modelDef, scope = {}) {
|
|
|
19466
19950
|
` + `Malloy compiles the embedded read into the SQL text, where no ` + `#(authorize) or #(access_filter) gate can be enforced, so every ` + `caller would read the gated rows. Query the gated source through ` + `Malloy instead (derive from it with \`->\`, or extend it), so its ` + `gate applies, or remove the gate if the source is meant to be open.`
|
|
19467
19951
|
});
|
|
19468
19952
|
}
|
|
19469
|
-
var isObj = (value) => typeof value === "object" && value !== null, INLINE_SQL = "<inline sql()>", labelOf = (struct) => {
|
|
19470
|
-
const label = struct.as ?? struct.name;
|
|
19471
|
-
if (typeof label !== "string")
|
|
19472
|
-
return "<unnamed>";
|
|
19473
|
-
return label.startsWith("sql://") ? INLINE_SQL : label;
|
|
19474
|
-
};
|
|
19475
19953
|
var init_sql_embed_gates = __esm(() => {
|
|
19954
|
+
init_sql_embeds();
|
|
19476
19955
|
init_errors2();
|
|
19477
19956
|
init_gate_plan();
|
|
19478
19957
|
});
|
|
@@ -20347,401 +20826,6 @@ function offsetOf(text, pos) {
|
|
|
20347
20826
|
return offset + pos.character;
|
|
20348
20827
|
}
|
|
20349
20828
|
|
|
20350
|
-
// src/service/materialization/text/source_map.ts
|
|
20351
|
-
import { isSourceDef as isSourceDef8 } from "@malloydata/malloy";
|
|
20352
|
-
function structRefSourceId(structRef) {
|
|
20353
|
-
if (typeof structRef === "string")
|
|
20354
|
-
return structRef;
|
|
20355
|
-
const sourceID = structRef?.sourceID;
|
|
20356
|
-
return typeof sourceID === "string" && sourceID.length > 0 ? sourceID : undefined;
|
|
20357
|
-
}
|
|
20358
|
-
function byId(model, id) {
|
|
20359
|
-
const entry = model?.sourceRegistry?.[id]?.entry;
|
|
20360
|
-
if (!entry)
|
|
20361
|
-
return;
|
|
20362
|
-
if (entry.type === "source_registry_reference" && entry.name) {
|
|
20363
|
-
return model?.contents?.[entry.name];
|
|
20364
|
-
}
|
|
20365
|
-
return entry;
|
|
20366
|
-
}
|
|
20367
|
-
function baseEdgeOf(def, modelDef) {
|
|
20368
|
-
const edge = sourceBaseEdge(def, modelDef);
|
|
20369
|
-
return edge && {
|
|
20370
|
-
hop: edge.hop,
|
|
20371
|
-
sourceID: edge.sourceID,
|
|
20372
|
-
def: edge.def
|
|
20373
|
-
};
|
|
20374
|
-
}
|
|
20375
|
-
function compositeMemberIds(def) {
|
|
20376
|
-
if (def.type !== "composite" || !Array.isArray(def.sources))
|
|
20377
|
-
return [];
|
|
20378
|
-
return def.sources.flatMap((member) => {
|
|
20379
|
-
const id = structRefSourceId(member);
|
|
20380
|
-
return id === undefined ? [] : [id];
|
|
20381
|
-
});
|
|
20382
|
-
}
|
|
20383
|
-
function kindOf(def, base) {
|
|
20384
|
-
if (def.type === "composite")
|
|
20385
|
-
return "composite";
|
|
20386
|
-
if (!base)
|
|
20387
|
-
return "table";
|
|
20388
|
-
if (base.hop === "extends")
|
|
20389
|
-
return "extend";
|
|
20390
|
-
if (base.hop === "rename")
|
|
20391
|
-
return "rename";
|
|
20392
|
-
return "query";
|
|
20393
|
-
}
|
|
20394
|
-
function detachedNode(def) {
|
|
20395
|
-
const d = def;
|
|
20396
|
-
if (!d || typeof d !== "object" || typeof d.sourceID !== "string") {
|
|
20397
|
-
return;
|
|
20398
|
-
}
|
|
20399
|
-
const base = baseEdgeOf(d, undefined);
|
|
20400
|
-
return {
|
|
20401
|
-
sourceID: d.sourceID,
|
|
20402
|
-
name: undefined,
|
|
20403
|
-
kind: kindOf(d, base),
|
|
20404
|
-
base,
|
|
20405
|
-
members: compositeMemberIds(d),
|
|
20406
|
-
def: d
|
|
20407
|
-
};
|
|
20408
|
-
}
|
|
20409
|
-
function sourceChain(struct, modelDef) {
|
|
20410
|
-
return SourceMap.of(modelDef).chainOf(struct);
|
|
20411
|
-
}
|
|
20412
|
-
function pipelineReferences(pipeline) {
|
|
20413
|
-
const out = [];
|
|
20414
|
-
let tooDeep = false;
|
|
20415
|
-
const walk = (node, depth) => {
|
|
20416
|
-
if (tooDeep)
|
|
20417
|
-
return;
|
|
20418
|
-
if (depth > MAX_PIPELINE_DEPTH) {
|
|
20419
|
-
tooDeep = true;
|
|
20420
|
-
return;
|
|
20421
|
-
}
|
|
20422
|
-
if (node === null || typeof node !== "object")
|
|
20423
|
-
return;
|
|
20424
|
-
if (Array.isArray(node)) {
|
|
20425
|
-
for (const item of node)
|
|
20426
|
-
walk(item, depth + 1);
|
|
20427
|
-
return;
|
|
20428
|
-
}
|
|
20429
|
-
const record = node;
|
|
20430
|
-
if (typeof record.join === "string") {
|
|
20431
|
-
const sourceID = typeof record.sourceID === "string" ? record.sourceID : undefined;
|
|
20432
|
-
out.push({ sourceID, ref: sourceID ?? node });
|
|
20433
|
-
return;
|
|
20434
|
-
}
|
|
20435
|
-
if (record.structRef !== undefined) {
|
|
20436
|
-
out.push({
|
|
20437
|
-
sourceID: structRefSourceId(record.structRef),
|
|
20438
|
-
ref: record.structRef
|
|
20439
|
-
});
|
|
20440
|
-
}
|
|
20441
|
-
for (const [key, value] of Object.entries(record)) {
|
|
20442
|
-
if (key === "structRef")
|
|
20443
|
-
continue;
|
|
20444
|
-
walk(value, depth + 1);
|
|
20445
|
-
}
|
|
20446
|
-
};
|
|
20447
|
-
walk(pipeline, 0);
|
|
20448
|
-
return tooDeep ? undefined : out;
|
|
20449
|
-
}
|
|
20450
|
-
function reachableSourceIDs(roots, modelDef) {
|
|
20451
|
-
const ids = new Set;
|
|
20452
|
-
const seen = new Set;
|
|
20453
|
-
const add = (value) => {
|
|
20454
|
-
if (typeof value === "string" && value.length > 0)
|
|
20455
|
-
ids.add(value);
|
|
20456
|
-
};
|
|
20457
|
-
const scanWhole = (node, depth) => {
|
|
20458
|
-
if (depth > MAX_PIPELINE_DEPTH || node === null || typeof node !== "object")
|
|
20459
|
-
return;
|
|
20460
|
-
if (Array.isArray(node)) {
|
|
20461
|
-
for (const item of node)
|
|
20462
|
-
scanWhole(item, depth + 1);
|
|
20463
|
-
return;
|
|
20464
|
-
}
|
|
20465
|
-
const record = node;
|
|
20466
|
-
for (const key of ["sourceID", "referenceID", "extends"])
|
|
20467
|
-
add(record[key]);
|
|
20468
|
-
for (const value of Object.values(record))
|
|
20469
|
-
scanWhole(value, depth + 1);
|
|
20470
|
-
};
|
|
20471
|
-
const visitPipeline = (pipeline) => {
|
|
20472
|
-
if (pipeline === undefined)
|
|
20473
|
-
return;
|
|
20474
|
-
const refs = pipelineReferences(pipeline);
|
|
20475
|
-
if (refs === undefined) {
|
|
20476
|
-
scanWhole(pipeline, 0);
|
|
20477
|
-
return;
|
|
20478
|
-
}
|
|
20479
|
-
for (const { sourceID, ref } of refs) {
|
|
20480
|
-
add(sourceID);
|
|
20481
|
-
if (ref !== null && typeof ref === "object")
|
|
20482
|
-
visit(ref);
|
|
20483
|
-
}
|
|
20484
|
-
};
|
|
20485
|
-
const visit = (node) => {
|
|
20486
|
-
if (node === null || typeof node !== "object" || seen.has(node))
|
|
20487
|
-
return;
|
|
20488
|
-
seen.add(node);
|
|
20489
|
-
const def = node;
|
|
20490
|
-
add(def.sourceID);
|
|
20491
|
-
add(def.referenceID);
|
|
20492
|
-
add(def.extends);
|
|
20493
|
-
if (def.structRef !== undefined) {
|
|
20494
|
-
add(structRefSourceId(def.structRef));
|
|
20495
|
-
if (typeof def.structRef === "object")
|
|
20496
|
-
visit(def.structRef);
|
|
20497
|
-
}
|
|
20498
|
-
visitPipeline(def.pipeline);
|
|
20499
|
-
if (def.query) {
|
|
20500
|
-
add(structRefSourceId(def.query.structRef));
|
|
20501
|
-
if (def.query.structRef && typeof def.query.structRef === "object") {
|
|
20502
|
-
visit(def.query.structRef);
|
|
20503
|
-
}
|
|
20504
|
-
visit(def.query.compositeResolvedSourceDef);
|
|
20505
|
-
visitPipeline(def.query.pipeline);
|
|
20506
|
-
}
|
|
20507
|
-
for (const member of def.sources ?? []) {
|
|
20508
|
-
add(structRefSourceId(member));
|
|
20509
|
-
visit(typeof member === "string" ? byId(modelDef, member) : member);
|
|
20510
|
-
}
|
|
20511
|
-
if (modelDef !== undefined && isSourceDef8(node)) {
|
|
20512
|
-
const struct = node;
|
|
20513
|
-
const model = modelDef;
|
|
20514
|
-
const declared = resolveDeclaredSource(struct, model);
|
|
20515
|
-
if (declared.kind === "resolved")
|
|
20516
|
-
visit(declared.source);
|
|
20517
|
-
visit(resolveExtendedSource(struct, model));
|
|
20518
|
-
visit(inferredExtendedSource(struct, model));
|
|
20519
|
-
visit(resolveQuerySourceBase(struct, model));
|
|
20520
|
-
visit(resolveCompositeResolvedBase(struct));
|
|
20521
|
-
}
|
|
20522
|
-
for (const field of def.fields ?? []) {
|
|
20523
|
-
const f = field;
|
|
20524
|
-
if (typeof f?.join === "string") {
|
|
20525
|
-
add(f.sourceID);
|
|
20526
|
-
visit(field);
|
|
20527
|
-
} else if (f?.pipeline !== undefined) {
|
|
20528
|
-
visitPipeline(f.pipeline);
|
|
20529
|
-
}
|
|
20530
|
-
}
|
|
20531
|
-
};
|
|
20532
|
-
for (const root of roots)
|
|
20533
|
-
visit(root);
|
|
20534
|
-
return ids;
|
|
20535
|
-
}
|
|
20536
|
-
function fieldKey(field) {
|
|
20537
|
-
const f = field;
|
|
20538
|
-
if (typeof f?.as === "string")
|
|
20539
|
-
return f.as;
|
|
20540
|
-
return typeof f?.name === "string" ? f.name : "";
|
|
20541
|
-
}
|
|
20542
|
-
function reachPersisted(ctx, name, isPersisted) {
|
|
20543
|
-
const persisted = new Map;
|
|
20544
|
-
const rawLeaves = new Set;
|
|
20545
|
-
const rawVia = new Set;
|
|
20546
|
-
const visited = new Set;
|
|
20547
|
-
const seen = new Set;
|
|
20548
|
-
const defName = (def) => {
|
|
20549
|
-
const id = def.sourceID;
|
|
20550
|
-
return typeof id === "string" ? ctx.sourceNameById.get(id) : undefined;
|
|
20551
|
-
};
|
|
20552
|
-
const reachRaw = (leaf, via) => {
|
|
20553
|
-
rawLeaves.add(leaf);
|
|
20554
|
-
rawVia.add(via);
|
|
20555
|
-
};
|
|
20556
|
-
const nameOf = (sourceID) => sourceID.split("@")[0];
|
|
20557
|
-
const follow = (ref, via) => {
|
|
20558
|
-
if (typeof ref === "string") {
|
|
20559
|
-
const next = ctx.sourceNameById.get(ref);
|
|
20560
|
-
if (next !== undefined) {
|
|
20561
|
-
visit(ctx.contents[next], next, false, via);
|
|
20562
|
-
return;
|
|
20563
|
-
}
|
|
20564
|
-
const refName = nameOf(ref);
|
|
20565
|
-
if (isPersisted(refName, ref)) {
|
|
20566
|
-
visited.add(refName);
|
|
20567
|
-
persisted.set(ref, { name: refName, sourceID: ref });
|
|
20568
|
-
return;
|
|
20569
|
-
}
|
|
20570
|
-
reachRaw(refName, via);
|
|
20571
|
-
return;
|
|
20572
|
-
}
|
|
20573
|
-
if (ref !== null && typeof ref === "object") {
|
|
20574
|
-
const def = ref;
|
|
20575
|
-
visit(def, defName(def), false, via);
|
|
20576
|
-
return;
|
|
20577
|
-
}
|
|
20578
|
-
reachRaw("(unnamed)", via);
|
|
20579
|
-
};
|
|
20580
|
-
const followJoins = (fields, sourceName) => {
|
|
20581
|
-
for (const field of fields ?? []) {
|
|
20582
|
-
const f = field;
|
|
20583
|
-
if (typeof f.join !== "string")
|
|
20584
|
-
continue;
|
|
20585
|
-
follow(typeof f.sourceID === "string" ? f.sourceID : field, sourceName);
|
|
20586
|
-
}
|
|
20587
|
-
};
|
|
20588
|
-
const ownJoins = (def) => {
|
|
20589
|
-
const baseName = typeof def.extends === "string" ? ctx.sourceNameById.get(def.extends) : undefined;
|
|
20590
|
-
const baseFields = new Set((baseName ? ctx.contents[baseName]?.fields ?? [] : []).map(fieldKey));
|
|
20591
|
-
return (def.fields ?? []).filter((f) => !baseFields.has(fieldKey(f)));
|
|
20592
|
-
};
|
|
20593
|
-
const visit = (def, sourceName, root, via) => {
|
|
20594
|
-
const label = sourceName ?? via;
|
|
20595
|
-
if (!def) {
|
|
20596
|
-
reachRaw(label, via);
|
|
20597
|
-
return;
|
|
20598
|
-
}
|
|
20599
|
-
if (seen.has(def))
|
|
20600
|
-
return;
|
|
20601
|
-
seen.add(def);
|
|
20602
|
-
if (!root && sourceName !== undefined)
|
|
20603
|
-
visited.add(sourceName);
|
|
20604
|
-
const sourceID = def.sourceID;
|
|
20605
|
-
if (!root && sourceName !== undefined && typeof sourceID === "string" && isPersisted(sourceName, sourceID)) {
|
|
20606
|
-
persisted.set(sourceID, { name: sourceName, sourceID });
|
|
20607
|
-
if (typeof def.extends === "string") {
|
|
20608
|
-
followJoins(ownJoins(def), sourceName);
|
|
20609
|
-
}
|
|
20610
|
-
return;
|
|
20611
|
-
}
|
|
20612
|
-
const base = typeof def.extends === "string" ? def.extends : def.type === "query_source" ? def.query?.structRef : undefined;
|
|
20613
|
-
if (base === undefined) {
|
|
20614
|
-
const inferred = inferredExtendedSource(def, ctx);
|
|
20615
|
-
if (inferred) {
|
|
20616
|
-
follow(inferred, label);
|
|
20617
|
-
const baseFields = new Set((inferred.fields ?? []).map(fieldKey));
|
|
20618
|
-
followJoins((def.fields ?? []).filter((f) => !baseFields.has(fieldKey(f))), label);
|
|
20619
|
-
return;
|
|
20620
|
-
}
|
|
20621
|
-
reachRaw(label, via);
|
|
20622
|
-
return;
|
|
20623
|
-
}
|
|
20624
|
-
follow(base, label);
|
|
20625
|
-
if (typeof def.extends !== "string") {
|
|
20626
|
-
const refs = pipelineReferences(def.query?.pipeline);
|
|
20627
|
-
for (const { ref } of refs ?? [{ ref: undefined }]) {
|
|
20628
|
-
follow(ref, label);
|
|
20629
|
-
}
|
|
20630
|
-
}
|
|
20631
|
-
followJoins(def.fields, label);
|
|
20632
|
-
};
|
|
20633
|
-
visit(ctx.contents[name], name, true, name);
|
|
20634
|
-
return {
|
|
20635
|
-
persisted: [...persisted.values()],
|
|
20636
|
-
raw: rawLeaves.size > 0,
|
|
20637
|
-
rawLeaves: [...rawLeaves],
|
|
20638
|
-
rawVia: [...rawVia],
|
|
20639
|
-
visited: [...visited]
|
|
20640
|
-
};
|
|
20641
|
-
}
|
|
20642
|
-
var SourceMap, MAX_PIPELINE_DEPTH = 200;
|
|
20643
|
-
var init_source_map = __esm(() => {
|
|
20644
|
-
init_source_graph();
|
|
20645
|
-
SourceMap = class SourceMap {
|
|
20646
|
-
modelDef;
|
|
20647
|
-
static memo = new WeakMap;
|
|
20648
|
-
nodesById = new Map;
|
|
20649
|
-
idsByName = new Map;
|
|
20650
|
-
constructor(modelDef) {
|
|
20651
|
-
this.modelDef = modelDef;
|
|
20652
|
-
const model = modelDef;
|
|
20653
|
-
for (const [name, value] of Object.entries(model?.contents ?? {})) {
|
|
20654
|
-
const def = value;
|
|
20655
|
-
if (typeof def?.sourceID !== "string")
|
|
20656
|
-
continue;
|
|
20657
|
-
this.idsByName.set(name, def.sourceID);
|
|
20658
|
-
this.add(def, name);
|
|
20659
|
-
}
|
|
20660
|
-
for (const id of Object.keys(model?.sourceRegistry ?? {})) {
|
|
20661
|
-
if (this.nodesById.has(id))
|
|
20662
|
-
continue;
|
|
20663
|
-
const def = byId(model, id);
|
|
20664
|
-
if (def && typeof def.sourceID === "string")
|
|
20665
|
-
this.add(def, undefined);
|
|
20666
|
-
}
|
|
20667
|
-
}
|
|
20668
|
-
static of(modelDef) {
|
|
20669
|
-
if (modelDef === null || typeof modelDef !== "object") {
|
|
20670
|
-
return new SourceMap(modelDef);
|
|
20671
|
-
}
|
|
20672
|
-
let map = SourceMap.memo.get(modelDef);
|
|
20673
|
-
if (!map) {
|
|
20674
|
-
map = new SourceMap(modelDef);
|
|
20675
|
-
SourceMap.memo.set(modelDef, map);
|
|
20676
|
-
}
|
|
20677
|
-
return map;
|
|
20678
|
-
}
|
|
20679
|
-
add(def, name) {
|
|
20680
|
-
const sourceID = def.sourceID;
|
|
20681
|
-
if (this.nodesById.has(sourceID))
|
|
20682
|
-
return;
|
|
20683
|
-
const base = baseEdgeOf(def, this.modelDef);
|
|
20684
|
-
this.nodesById.set(sourceID, {
|
|
20685
|
-
sourceID,
|
|
20686
|
-
name,
|
|
20687
|
-
kind: kindOf(def, base),
|
|
20688
|
-
base,
|
|
20689
|
-
members: compositeMemberIds(def),
|
|
20690
|
-
def
|
|
20691
|
-
});
|
|
20692
|
-
}
|
|
20693
|
-
model() {
|
|
20694
|
-
return this.modelDef;
|
|
20695
|
-
}
|
|
20696
|
-
node(sourceID) {
|
|
20697
|
-
return this.nodesById.get(sourceID);
|
|
20698
|
-
}
|
|
20699
|
-
sourceIDOf(name) {
|
|
20700
|
-
return this.idsByName.get(name);
|
|
20701
|
-
}
|
|
20702
|
-
joinsOf(sourceID) {
|
|
20703
|
-
const node = this.nodesById.get(sourceID);
|
|
20704
|
-
return node ? sourceJoins(node.def) : [];
|
|
20705
|
-
}
|
|
20706
|
-
fieldJoinsOf(sourceID) {
|
|
20707
|
-
const node = this.nodesById.get(sourceID);
|
|
20708
|
-
return node ? fieldJoinUsage(node.def) : new Map;
|
|
20709
|
-
}
|
|
20710
|
-
filterJoinsOf(sourceID) {
|
|
20711
|
-
const node = this.nodesById.get(sourceID);
|
|
20712
|
-
return node ? filterJoinReads(node.def) : undefined;
|
|
20713
|
-
}
|
|
20714
|
-
joinedReadsOf(join) {
|
|
20715
|
-
return joinedSourceReads(join);
|
|
20716
|
-
}
|
|
20717
|
-
nodes() {
|
|
20718
|
-
return [...this.nodesById.values()];
|
|
20719
|
-
}
|
|
20720
|
-
chainOf(struct) {
|
|
20721
|
-
const out = [];
|
|
20722
|
-
const seen = new Set;
|
|
20723
|
-
let current = struct;
|
|
20724
|
-
for (let hops = 0;current && hops < 64; hops++) {
|
|
20725
|
-
if (seen.has(current))
|
|
20726
|
-
break;
|
|
20727
|
-
seen.add(current);
|
|
20728
|
-
const id = current.sourceID;
|
|
20729
|
-
if (typeof id === "string" && !out.includes(id))
|
|
20730
|
-
out.push(id);
|
|
20731
|
-
const next = nextSourceInChain(current, this.modelDef);
|
|
20732
|
-
if (!next) {
|
|
20733
|
-
for (const ref of [current.referenceID, current.extends]) {
|
|
20734
|
-
if (typeof ref === "string" && !out.includes(ref))
|
|
20735
|
-
out.push(ref);
|
|
20736
|
-
}
|
|
20737
|
-
}
|
|
20738
|
-
current = next;
|
|
20739
|
-
}
|
|
20740
|
-
return out;
|
|
20741
|
-
}
|
|
20742
|
-
};
|
|
20743
|
-
});
|
|
20744
|
-
|
|
20745
20829
|
// src/service/materialization/text/persist_blanking.ts
|
|
20746
20830
|
function sourceNotes(annotations, depth = 0) {
|
|
20747
20831
|
if (!annotations || typeof annotations !== "object" || depth > 64)
|
|
@@ -20851,11 +20935,14 @@ class GeneratedFiles {
|
|
|
20851
20935
|
static over(factory) {
|
|
20852
20936
|
return new GeneratedFiles(factory);
|
|
20853
20937
|
}
|
|
20854
|
-
async loadModel(overlay = new Map) {
|
|
20938
|
+
async loadModel(overlay = new Map, options = {}) {
|
|
20855
20939
|
const { runtime, importBaseURL, modelURL } = await this.runtimeFor(keyedOverlay(overlay));
|
|
20856
20940
|
if (!modelURL)
|
|
20857
20941
|
throw new Error("no package model to load");
|
|
20858
|
-
const materializer = runtime.loadModel(modelURL, {
|
|
20942
|
+
const materializer = runtime.loadModel(modelURL, {
|
|
20943
|
+
importBaseURL,
|
|
20944
|
+
...options.virtualMap ? { virtualMap: options.virtualMap } : {}
|
|
20945
|
+
});
|
|
20859
20946
|
return { runtime, importBaseURL, materializer };
|
|
20860
20947
|
}
|
|
20861
20948
|
runtime(overlay = new Map) {
|
|
@@ -31715,10 +31802,19 @@ function keyUniquenessOfContract(contract, sources, leaves = []) {
|
|
|
31715
31802
|
if (source)
|
|
31716
31803
|
read("leaf", leaf.joinPath, source);
|
|
31717
31804
|
}
|
|
31805
|
+
const grainJoinKeys = {};
|
|
31806
|
+
for (const [name, check] of Object.entries(keys)) {
|
|
31807
|
+
const joinKey = contractKeyWithoutLevel(name, "grain_join");
|
|
31808
|
+
if (joinKey !== undefined && check.level === "grain_join") {
|
|
31809
|
+
grainJoinKeys[joinKey] = passed(check);
|
|
31810
|
+
}
|
|
31811
|
+
}
|
|
31718
31812
|
const anyParent = Object.keys(parentKeys).length > 0;
|
|
31719
|
-
|
|
31813
|
+
const anyGrainJoin = Object.keys(grainJoinKeys).length > 0;
|
|
31814
|
+
if (!own && !anyParent && !anyGrainJoin)
|
|
31720
31815
|
return;
|
|
31721
31816
|
return {
|
|
31817
|
+
...anyGrainJoin ? { grainJoinKeys } : {},
|
|
31722
31818
|
...own ? {
|
|
31723
31819
|
keyColumn: contractKeyWithoutLevel(own[0], "rollup"),
|
|
31724
31820
|
unique: passed(own[1])
|
|
@@ -32219,10 +32315,13 @@ function parseKeyUniqueness(raw) {
|
|
|
32219
32315
|
const own = typeof k.keyColumn === "string" && typeof k.unique === "boolean" ? { keyColumn: k.keyColumn, unique: k.unique } : undefined;
|
|
32220
32316
|
const parentKeys = recordOf(k.parentKeys, "boolean");
|
|
32221
32317
|
const parentKeyColumns = recordOf(k.parentKeyColumns, "string");
|
|
32222
|
-
|
|
32318
|
+
const grainJoinKeys = recordOf(k.grainJoinKeys, "boolean");
|
|
32319
|
+
if (!own && !parentKeys && !parentKeyColumns && !grainJoinKeys) {
|
|
32223
32320
|
return;
|
|
32321
|
+
}
|
|
32224
32322
|
return {
|
|
32225
32323
|
...own ?? {},
|
|
32324
|
+
...grainJoinKeys ? { grainJoinKeys } : {},
|
|
32226
32325
|
...parentKeys ? { parentKeys } : {},
|
|
32227
32326
|
...parentKeyColumns ? { parentKeyColumns } : {}
|
|
32228
32327
|
};
|
|
@@ -32249,21 +32348,27 @@ function rollupKeyOf(entry) {
|
|
|
32249
32348
|
const k = keyUniquenessOf(entry);
|
|
32250
32349
|
return k?.keyColumn !== undefined && k.unique !== undefined ? { keyColumn: k.keyColumn, unique: k.unique } : undefined;
|
|
32251
32350
|
}
|
|
32351
|
+
function grainJoinKeysOf(entry) {
|
|
32352
|
+
return keyUniquenessOf(entry)?.grainJoinKeys;
|
|
32353
|
+
}
|
|
32252
32354
|
function withEntryKeyChecks(binding, entry) {
|
|
32253
32355
|
const {
|
|
32254
32356
|
primaryKeys: _was,
|
|
32255
32357
|
primaryKeyColumns: _wasColumns,
|
|
32256
32358
|
rollupKey: _wasKey,
|
|
32359
|
+
grainJoinKeys: _wasJoinKeys,
|
|
32257
32360
|
...rest
|
|
32258
32361
|
} = binding;
|
|
32259
32362
|
const primaryKeys = primaryKeysOf(entry);
|
|
32260
32363
|
const primaryKeyColumns = primaryKeyColumnsOf(entry);
|
|
32261
32364
|
const rollupKey = isRollupOrigin(entry.origin) ? rollupKeyOf(entry) : undefined;
|
|
32365
|
+
const grainJoinKeys = isRollupOrigin(entry.origin) ? grainJoinKeysOf(entry) : undefined;
|
|
32262
32366
|
return {
|
|
32263
32367
|
...rest,
|
|
32264
32368
|
...primaryKeys ? { primaryKeys } : {},
|
|
32265
32369
|
...primaryKeyColumns ? { primaryKeyColumns } : {},
|
|
32266
|
-
...rollupKey ? { rollupKey } : {}
|
|
32370
|
+
...rollupKey ? { rollupKey } : {},
|
|
32371
|
+
...grainJoinKeys ? { grainJoinKeys } : {}
|
|
32267
32372
|
};
|
|
32268
32373
|
}
|
|
32269
32374
|
function deriveServeBindings(entries, aliasesBySourceName, destinationSchema, sourceIDsFor) {
|
|
@@ -32283,6 +32388,7 @@ function deriveServeBindings(entries, aliasesBySourceName, destinationSchema, so
|
|
|
32283
32388
|
const primaryKeys = primaryKeysOf(entry);
|
|
32284
32389
|
const primaryKeyColumns = primaryKeyColumnsOf(entry);
|
|
32285
32390
|
const rollupKey = isRollupOrigin(entry.origin) ? rollupKeyOf(entry) : undefined;
|
|
32391
|
+
const grainJoinKeys = isRollupOrigin(entry.origin) ? grainJoinKeysOf(entry) : undefined;
|
|
32286
32392
|
for (const sourceName of names) {
|
|
32287
32393
|
const sourceIDs = sourceIDsFor?.(sourceName, entry.sourceEntityId);
|
|
32288
32394
|
bindings.push({
|
|
@@ -32299,7 +32405,8 @@ function deriveServeBindings(entries, aliasesBySourceName, destinationSchema, so
|
|
|
32299
32405
|
freshnessFallback: entry.freshnessFallback,
|
|
32300
32406
|
...primaryKeys ? { primaryKeys } : {},
|
|
32301
32407
|
...primaryKeyColumns ? { primaryKeyColumns } : {},
|
|
32302
|
-
...rollupKey ? { rollupKey } : {}
|
|
32408
|
+
...rollupKey ? { rollupKey } : {},
|
|
32409
|
+
...grainJoinKeys ? { grainJoinKeys } : {}
|
|
32303
32410
|
});
|
|
32304
32411
|
}
|
|
32305
32412
|
}
|
|
@@ -37704,6 +37811,7 @@ async function readSameCatalogThroughDestination(args) {
|
|
|
37704
37811
|
...declaringFiles(args.modelDef, names)
|
|
37705
37812
|
]);
|
|
37706
37813
|
const out = new Map(args.files);
|
|
37814
|
+
const moved = [];
|
|
37707
37815
|
for (const move of moves) {
|
|
37708
37816
|
const paths = [];
|
|
37709
37817
|
for (const url of urls) {
|
|
@@ -37733,13 +37841,24 @@ async function readSameCatalogThroughDestination(args) {
|
|
|
37733
37841
|
const [catalog, schema, table] = destinationTablePath(path, move).split(".");
|
|
37734
37842
|
return [catalog, schema, table];
|
|
37735
37843
|
});
|
|
37736
|
-
|
|
37737
|
-
|
|
37844
|
+
const read = {
|
|
37845
|
+
alias: move.alias,
|
|
37846
|
+
connection: move.connection,
|
|
37847
|
+
schemas: move.schemas,
|
|
37848
|
+
tables
|
|
37849
|
+
};
|
|
37850
|
+
if (!await args.ports.readable(read)) {
|
|
37851
|
+
return {
|
|
37852
|
+
declined: "a table it reads is not a base table, or holds a file outside the connection's storage scope"
|
|
37853
|
+
};
|
|
37738
37854
|
}
|
|
37855
|
+
if (tables.length > 0)
|
|
37856
|
+
moved.push(read);
|
|
37739
37857
|
}
|
|
37740
37858
|
return {
|
|
37741
37859
|
files: out,
|
|
37742
|
-
destinations: new Set(moves.map((m) => m.destination))
|
|
37860
|
+
destinations: new Set(moves.map((m) => m.destination)),
|
|
37861
|
+
moved
|
|
37743
37862
|
};
|
|
37744
37863
|
}
|
|
37745
37864
|
var PLAIN;
|
|
@@ -37839,17 +37958,6 @@ async function sameCatalogScope(config, connection, alias) {
|
|
|
37839
37958
|
const schemas = managedSchemasOf(source);
|
|
37840
37959
|
return schemas && isSameCatalog(connectionConfigOf(source), connectionConfigOf(destination)) ? schemas : undefined;
|
|
37841
37960
|
}
|
|
37842
|
-
async function allBaseTables(config, alias, tables) {
|
|
37843
|
-
const destination = await config.connections.lookupConnection(alias);
|
|
37844
|
-
for (const [catalog, schema, table] of tables) {
|
|
37845
|
-
const result = await destination.runSQL("SELECT table_type FROM information_schema.tables " + `WHERE table_catalog = '${catalog}' ` + `AND lower(table_schema) = lower('${schema}') ` + `AND lower(table_name) = lower('${table}')`);
|
|
37846
|
-
const rows = result.rows;
|
|
37847
|
-
if (rows.length !== 1 || rows[0].table_type !== "BASE TABLE") {
|
|
37848
|
-
return false;
|
|
37849
|
-
}
|
|
37850
|
-
}
|
|
37851
|
-
return true;
|
|
37852
|
-
}
|
|
37853
37961
|
var init_same_catalog_destination = __esm(() => {
|
|
37854
37962
|
init_connection_type();
|
|
37855
37963
|
init_same_catalog_build();
|
|
@@ -38703,6 +38811,21 @@ import {
|
|
|
38703
38811
|
function servedConnectionOf(b) {
|
|
38704
38812
|
return isDatabase(b) ? b.destinationName : servedCopyAlias(b.destinationName);
|
|
38705
38813
|
}
|
|
38814
|
+
function importedFileURLs(modelDef) {
|
|
38815
|
+
const urls = new Set;
|
|
38816
|
+
const walk = (tree, depth) => {
|
|
38817
|
+
if (depth > 64 || typeof tree !== "object" || tree === null)
|
|
38818
|
+
return;
|
|
38819
|
+
for (const [url, below] of Object.entries(tree)) {
|
|
38820
|
+
if (urls.has(url))
|
|
38821
|
+
continue;
|
|
38822
|
+
urls.add(url);
|
|
38823
|
+
walk(below, depth + 1);
|
|
38824
|
+
}
|
|
38825
|
+
};
|
|
38826
|
+
walk(modelDef?.dependencies, 0);
|
|
38827
|
+
return [...urls];
|
|
38828
|
+
}
|
|
38706
38829
|
function leftOutJoinDetail(joins) {
|
|
38707
38830
|
const named = joins.map((j) => {
|
|
38708
38831
|
const join = j.join ?? j.name;
|
|
@@ -38902,6 +39025,7 @@ class ServedCopyServe {
|
|
|
38902
39025
|
...asWritten ? { tableIds: asWritten.tableIds } : {}
|
|
38903
39026
|
});
|
|
38904
39027
|
}
|
|
39028
|
+
await this.recheckSameCatalog(compiled);
|
|
38905
39029
|
const declined = compiled.declined?.get(queryString);
|
|
38906
39030
|
if (declined !== undefined)
|
|
38907
39031
|
throw declined;
|
|
@@ -39111,6 +39235,7 @@ class ServedCopyServe {
|
|
|
39111
39235
|
};
|
|
39112
39236
|
}
|
|
39113
39237
|
async checkJoinVariant(compiled, args) {
|
|
39238
|
+
await this.recheckSameCatalog(compiled);
|
|
39114
39239
|
const decline = (reason, code, callerDetail) => {
|
|
39115
39240
|
throw new LegDecline(code, callerDetail, { message: reason });
|
|
39116
39241
|
};
|
|
@@ -39146,6 +39271,17 @@ class ServedCopyServe {
|
|
|
39146
39271
|
decline
|
|
39147
39272
|
});
|
|
39148
39273
|
}
|
|
39274
|
+
async recheckSameCatalog(compiled) {
|
|
39275
|
+
if (!compiled.sameCatalogRecheck)
|
|
39276
|
+
return;
|
|
39277
|
+
const ok = await compiled.sameCatalogRecheck().catch(() => false);
|
|
39278
|
+
if (ok)
|
|
39279
|
+
return;
|
|
39280
|
+
logger.warn("A served copy's table read through its storage destination is no longer a base table, holds a file outside the managed connection's storage scope, or could not be checked; answering live", { modelPath: this.host.modelPath() });
|
|
39281
|
+
throw new LegDecline("served_copy_not_served", undefined, {
|
|
39282
|
+
message: "a table the served copy reads through its storage destination is no longer a base table, holds a file outside the managed connection's storage scope, or could not be checked"
|
|
39283
|
+
});
|
|
39284
|
+
}
|
|
39149
39285
|
readsRollingWindow(binding) {
|
|
39150
39286
|
return (binding.sourceIDs ?? []).some((id) => rollingWindowsOf(this.materializePlans[id]?.readTimeTerms).length > 0);
|
|
39151
39287
|
}
|
|
@@ -39474,6 +39610,39 @@ class ServedCopyServe {
|
|
|
39474
39610
|
rerootedSpans
|
|
39475
39611
|
};
|
|
39476
39612
|
}
|
|
39613
|
+
ownSqlEmbedReach(struct, modelDef) {
|
|
39614
|
+
return ownSqlEmbedReach(struct, modelDef);
|
|
39615
|
+
}
|
|
39616
|
+
withoutConflictingSqlEmbeds(candidates, map, problems) {
|
|
39617
|
+
const modelDef = this.host.modelDef();
|
|
39618
|
+
const reads = sqlEmbedReads([
|
|
39619
|
+
modelDef,
|
|
39620
|
+
...importedFileURLs(modelDef).map((url) => this.host.siblingModelDef?.(url))
|
|
39621
|
+
]);
|
|
39622
|
+
if (reads.length === 0)
|
|
39623
|
+
return candidates;
|
|
39624
|
+
const rerootedIDs = new Set(candidates.map((c) => c.reroot.sourceID));
|
|
39625
|
+
const rerooted = (sqlSourceID) => {
|
|
39626
|
+
const node = map.node(sqlSourceID);
|
|
39627
|
+
const chain = node ? map.chainOf(node.def) : [sqlSourceID];
|
|
39628
|
+
return chain.some((id) => rerootedIDs.has(id));
|
|
39629
|
+
};
|
|
39630
|
+
return candidates.filter((c) => {
|
|
39631
|
+
const conflicts = conflictingSqlEmbeds(reads, c.reroot.sourceID, servedConnectionOf(c.binding), rerooted);
|
|
39632
|
+
if (conflicts.length === 0)
|
|
39633
|
+
return true;
|
|
39634
|
+
const whole = conflicts.some((x) => x.conflict === "bare");
|
|
39635
|
+
problems.push({
|
|
39636
|
+
sourceName: c.reroot.sourceName,
|
|
39637
|
+
sourceID: c.reroot.sourceID,
|
|
39638
|
+
reason: whole ? "sql_embed_bare" : "sql_embed_cross_connection",
|
|
39639
|
+
detail: [
|
|
39640
|
+
...new Set(conflicts.filter((x) => !whole || x.conflict === "bare").map(({ read }) => `\`${read.via}\` on \`${read.connection}\``))
|
|
39641
|
+
].join(", ")
|
|
39642
|
+
});
|
|
39643
|
+
return false;
|
|
39644
|
+
});
|
|
39645
|
+
}
|
|
39477
39646
|
rerootCandidates(bindings, map, lift, problems, lane, passedOver = new Set, twins, restatesStageZoned = false) {
|
|
39478
39647
|
let candidates = [];
|
|
39479
39648
|
const reservedNames = modelFieldNames(map);
|
|
@@ -39503,6 +39672,7 @@ class ServedCopyServe {
|
|
|
39503
39672
|
const tiers = (byKey.get(keyOf(c)) ?? []).filter((o) => !passedOver.has(o.binding)).map((o) => o.binding.tier);
|
|
39504
39673
|
return servedCopyReadsTier(c.binding.tier, tiers);
|
|
39505
39674
|
});
|
|
39675
|
+
candidates = this.withoutConflictingSqlEmbeds(candidates, map, problems);
|
|
39506
39676
|
const rerootedIDs = new Set(candidates.map((c) => c.reroot.sourceID));
|
|
39507
39677
|
const rerootedNames = new Set(candidates.map((c) => c.reroot.sourceName));
|
|
39508
39678
|
const throughBase = [];
|
|
@@ -39672,7 +39842,7 @@ class ServedCopyServe {
|
|
|
39672
39842
|
const packagePath = this.packagePath;
|
|
39673
39843
|
const packageConfig = this.packageConfig;
|
|
39674
39844
|
const config = servedCopyConfig(packageConfig, destinations(), new Set(rerooted.filter((b) => !isDatabase(b)).map((b) => b.destinationName)));
|
|
39675
|
-
const load = this.passLoader(packagePath, config);
|
|
39845
|
+
const load = this.passLoader(packagePath, config, aliased);
|
|
39676
39846
|
const underAlias = this.underAliasLoader(packagePath, packageConfig, destinations, rerooted);
|
|
39677
39847
|
const loaded = await this.loadCopy(state, copy, overlay, load, lift, config, underAlias);
|
|
39678
39848
|
if (loaded === "retry")
|
|
@@ -39689,7 +39859,6 @@ class ServedCopyServe {
|
|
|
39689
39859
|
};
|
|
39690
39860
|
}
|
|
39691
39861
|
const { materializer, servedDef, servedRuntime, leftOut, files } = loaded;
|
|
39692
|
-
const compiledConfig = loaded.config ?? config;
|
|
39693
39862
|
problems.push(...state.inlinedKept.filter((p) => state.candidates.some((c) => c.reroot.sourceName === p.sourceName)));
|
|
39694
39863
|
state.inlinedKept = [];
|
|
39695
39864
|
problems.push(...state.pairsDropped);
|
|
@@ -39709,10 +39878,11 @@ class ServedCopyServe {
|
|
|
39709
39878
|
materializer,
|
|
39710
39879
|
leftOut,
|
|
39711
39880
|
files,
|
|
39712
|
-
config:
|
|
39881
|
+
config: loaded.config ?? config,
|
|
39713
39882
|
rerooted,
|
|
39714
39883
|
aliased,
|
|
39715
|
-
throughBase
|
|
39884
|
+
throughBase,
|
|
39885
|
+
sameCatalogReads: loaded.sameCatalogReads
|
|
39716
39886
|
});
|
|
39717
39887
|
}
|
|
39718
39888
|
return {
|
|
@@ -39726,12 +39896,20 @@ class ServedCopyServe {
|
|
|
39726
39896
|
};
|
|
39727
39897
|
}
|
|
39728
39898
|
underAliasLoader(packagePath, packageConfig, destinations, rerooted) {
|
|
39899
|
+
const aliased = rerooted.map((b) => ({
|
|
39900
|
+
...b,
|
|
39901
|
+
destinationName: servedConnectionOf(b)
|
|
39902
|
+
}));
|
|
39729
39903
|
return (names) => {
|
|
39730
39904
|
const config = servedCopyConfig(packageConfig, destinations(), new Set(rerooted.filter((b) => !isDatabase(b)).map((b) => b.destinationName)), names);
|
|
39731
|
-
return {
|
|
39905
|
+
return {
|
|
39906
|
+
config,
|
|
39907
|
+
load: this.passLoader(packagePath, config, aliased)
|
|
39908
|
+
};
|
|
39732
39909
|
};
|
|
39733
39910
|
}
|
|
39734
|
-
passLoader(packagePath, config) {
|
|
39911
|
+
passLoader(packagePath, config, aliased) {
|
|
39912
|
+
const virtualMap = buildVirtualMap(aliased);
|
|
39735
39913
|
const modelPath = this.host.modelPath();
|
|
39736
39914
|
const compiler = packageFiles(packagePath, modelPath, config);
|
|
39737
39915
|
return async (files) => {
|
|
@@ -39739,11 +39917,14 @@ class ServedCopyServe {
|
|
|
39739
39917
|
packagePath,
|
|
39740
39918
|
modelPath,
|
|
39741
39919
|
config,
|
|
39742
|
-
files: keyedOverlay(files)
|
|
39920
|
+
files: keyedOverlay(files),
|
|
39921
|
+
virtualMap
|
|
39743
39922
|
});
|
|
39744
39923
|
if (elsewhere)
|
|
39745
39924
|
return elsewhere;
|
|
39746
|
-
const { runtime, materializer } = await compiler.loadModel(files
|
|
39925
|
+
const { runtime, materializer } = await compiler.loadModel(files, {
|
|
39926
|
+
virtualMap
|
|
39927
|
+
});
|
|
39747
39928
|
const model = await materializer.getModel();
|
|
39748
39929
|
return {
|
|
39749
39930
|
materializer,
|
|
@@ -39899,7 +40080,7 @@ class ServedCopyServe {
|
|
|
39899
40080
|
ports: {
|
|
39900
40081
|
scope: (connection, alias) => sameCatalogScope(config, connection, alias),
|
|
39901
40082
|
pathRefusal: (path, connection, schemas) => this.host.managedTablePathRefusal ? this.host.managedTablePathRefusal(path, connection, schemas) : Promise.resolve("no managed scope check is available"),
|
|
39902
|
-
|
|
40083
|
+
readable: (read) => this.host.sameCatalogTablesReadable ? this.host.sameCatalogTablesReadable(config, read) : Promise.resolve(false)
|
|
39903
40084
|
}
|
|
39904
40085
|
}).catch(() => ({ declined: "a read of its connections failed" }));
|
|
39905
40086
|
if ("declined" in moved) {
|
|
@@ -39917,7 +40098,8 @@ class ServedCopyServe {
|
|
|
39917
40098
|
servedRuntime: loaded.runtime,
|
|
39918
40099
|
leftOut: [],
|
|
39919
40100
|
files: keyed,
|
|
39920
|
-
config: aliased
|
|
40101
|
+
config: aliased,
|
|
40102
|
+
sameCatalogReads: moved.moved
|
|
39921
40103
|
};
|
|
39922
40104
|
} catch (again) {
|
|
39923
40105
|
logger.debug("A served copy's same-catalog read does not compile; its joins are left out", {
|
|
@@ -39981,6 +40163,7 @@ class ServedCopyServe {
|
|
|
39981
40163
|
const { key, generation, over, lane, modelDef, servedMap } = built;
|
|
39982
40164
|
const { servedDef, servedRuntime, materializer, leftOut } = built;
|
|
39983
40165
|
const { files, config, rerooted, aliased, throughBase } = built;
|
|
40166
|
+
const sameCatalogReads = built.sameCatalogReads ?? [];
|
|
39984
40167
|
const optOutIDs = new Set;
|
|
39985
40168
|
for (const node of servedMap.nodes()) {
|
|
39986
40169
|
if (optsOutOfPersist(node.def)) {
|
|
@@ -40049,6 +40232,15 @@ class ServedCopyServe {
|
|
|
40049
40232
|
rerooted,
|
|
40050
40233
|
rerootedSourceIDs: rerootedSourceIDsOf(candidates, throughBase),
|
|
40051
40234
|
...throughBase.length > 0 ? { throughBase } : {},
|
|
40235
|
+
...sameCatalogReads.length > 0 ? {
|
|
40236
|
+
sameCatalogRecheck: async () => {
|
|
40237
|
+
const readable = this.host.sameCatalogTablesReadable;
|
|
40238
|
+
if (!readable)
|
|
40239
|
+
return false;
|
|
40240
|
+
const each = await Promise.all(sameCatalogReads.map((r) => readable(config, r)));
|
|
40241
|
+
return each.every(Boolean);
|
|
40242
|
+
}
|
|
40243
|
+
} : {},
|
|
40052
40244
|
aliased,
|
|
40053
40245
|
problems,
|
|
40054
40246
|
pairs: candidates.flatMap((c) => c.reroot.pair ? [
|
|
@@ -41198,6 +41390,7 @@ var init_served_copy_serve = __esm(() => {
|
|
|
41198
41390
|
init_filter_binding_guard();
|
|
41199
41391
|
init_authorize();
|
|
41200
41392
|
init_overlay_key();
|
|
41393
|
+
init_sql_embed_reads();
|
|
41201
41394
|
init_event_loop_yield();
|
|
41202
41395
|
init_package_files();
|
|
41203
41396
|
init_source_map();
|
|
@@ -47702,6 +47895,11 @@ var init_key_check_text = __esm(() => {
|
|
|
47702
47895
|
inline_join_one: { count: "matches", key: undefined, notNull: "is not" },
|
|
47703
47896
|
pair_level: { count: "matches", key: undefined, isNull: "is" },
|
|
47704
47897
|
rollup_key: { count: "key_rows__check", key: undefined, notNull: "!=" },
|
|
47898
|
+
grain_join_key: {
|
|
47899
|
+
count: "key_rows__check",
|
|
47900
|
+
key: undefined,
|
|
47901
|
+
notNull: "!="
|
|
47902
|
+
},
|
|
47705
47903
|
parent_key: { count: "key_rows__check", key: "key__check", isNull: "=" }
|
|
47706
47904
|
};
|
|
47707
47905
|
});
|
|
@@ -49922,6 +50120,7 @@ function pathReadsCurrentTime(g, facts) {
|
|
|
49922
50120
|
}
|
|
49923
50121
|
function joinOneGrainOf(grain, facts) {
|
|
49924
50122
|
const byJoin = new Map;
|
|
50123
|
+
const uncovered = new Set;
|
|
49925
50124
|
const add = (join, entry) => {
|
|
49926
50125
|
if (facts.joins.get(join)?.relationship !== "one")
|
|
49927
50126
|
return;
|
|
@@ -49934,15 +50133,39 @@ function joinOneGrainOf(grain, facts) {
|
|
|
49934
50133
|
const path = grainPathOf(g);
|
|
49935
50134
|
if (path) {
|
|
49936
50135
|
add(path.join, g);
|
|
50136
|
+
const join = facts.joins.get(path.join);
|
|
50137
|
+
if (!join)
|
|
50138
|
+
continue;
|
|
50139
|
+
const field = joinedSourceReads(join).fieldJoins.get(path.field);
|
|
50140
|
+
if (field === undefined || field.joins.size > 0 || field.nested) {
|
|
50141
|
+
uncovered.add(path.join);
|
|
50142
|
+
}
|
|
49937
50143
|
continue;
|
|
49938
50144
|
}
|
|
49939
|
-
|
|
50145
|
+
const usage = facts.joinUsage.get(g);
|
|
50146
|
+
for (const j of usage?.joins ?? [])
|
|
49940
50147
|
add(j, g);
|
|
50148
|
+
const onlyOnes = [...usage?.joins ?? []].every((j) => facts.joins.get(j)?.relationship === "one");
|
|
50149
|
+
if (usage === undefined || usage.nested || !onlyOnes) {
|
|
50150
|
+
for (const j of usage?.joins ?? [])
|
|
50151
|
+
uncovered.add(j);
|
|
50152
|
+
}
|
|
50153
|
+
}
|
|
50154
|
+
for (const join of byJoin.keys()) {
|
|
50155
|
+
const condition = facts.joins.get(join)?.condition;
|
|
50156
|
+
const filter = filterJoinReads(facts.byName.get(join));
|
|
50157
|
+
if (condition === undefined || condition.joins.size > 0 || condition.nested || filter === undefined || filter.joins.size > 0 || filter.nested) {
|
|
50158
|
+
uncovered.add(join);
|
|
50159
|
+
}
|
|
49941
50160
|
}
|
|
49942
50161
|
if (byJoin.size === 0)
|
|
49943
50162
|
return {};
|
|
49944
50163
|
return {
|
|
49945
|
-
joinOneGrain: [...byJoin].sort(([a], [b]) => byCodepoint2(a, b)).map(([join, entries]) => ({
|
|
50164
|
+
joinOneGrain: [...byJoin].sort(([a], [b]) => byCodepoint2(a, b)).map(([join, entries]) => ({
|
|
50165
|
+
join,
|
|
50166
|
+
grain: entries,
|
|
50167
|
+
...uncovered.has(join) ? { uncovered: true } : {}
|
|
50168
|
+
}))
|
|
49946
50169
|
};
|
|
49947
50170
|
}
|
|
49948
50171
|
function exactPathRead(e) {
|
|
@@ -50320,6 +50543,9 @@ function storedKeyChecksOf(plans, needs, primaryKeyOf, sourceIDs) {
|
|
|
50320
50543
|
function parentKeyCheckQuery(name, keyColumn) {
|
|
50321
50544
|
return `run: ${keyCheckPipeline("parent_key", name, keyColumn)}`;
|
|
50322
50545
|
}
|
|
50546
|
+
function grainJoinKeyCheckQuery(name, keyColumn) {
|
|
50547
|
+
return `run: ${keyCheckPipeline("grain_join_key", name, keyColumn)}`;
|
|
50548
|
+
}
|
|
50323
50549
|
function joinOneKey(sourceID, keyColumn) {
|
|
50324
50550
|
return `${sourceID}\x00${keyColumn}`;
|
|
50325
50551
|
}
|
|
@@ -50362,6 +50588,7 @@ var init_rollup_plan = __esm(() => {
|
|
|
50362
50588
|
init_rollup_measure_grammar();
|
|
50363
50589
|
init_table_plans();
|
|
50364
50590
|
init_read_text();
|
|
50591
|
+
init_source_graph();
|
|
50365
50592
|
V1_PREAGGREGATE_NOTE = /^\s*#@\s*-?preaggregate\b/;
|
|
50366
50593
|
scopes = new WeakMap;
|
|
50367
50594
|
LOCK_WORDS = new Set(["and", "in", "true", "false"]);
|
|
@@ -51379,7 +51606,7 @@ function materializedUpstream(sourceID, map) {
|
|
|
51379
51606
|
}
|
|
51380
51607
|
function storedElsewhereReason(upstreams) {
|
|
51381
51608
|
const stored = upstreams.find((u) => u.storage !== undefined);
|
|
51382
|
-
return stored ? `its upstream '${stored.name}' is stored in the storage= destination ` + `'${stored.storage}', whose table a build in the warehouse cannot ` + `read, and a downstream is never built by recomputing its upstream ` + `from raw; it is
|
|
51609
|
+
return stored ? `its upstream '${stored.name}' is stored in the storage= destination ` + `'${stored.storage}', whose table a build in the warehouse cannot ` + `read, and a downstream is never built by recomputing its upstream ` + `from raw; it is answered live` : undefined;
|
|
51383
51610
|
}
|
|
51384
51611
|
function persistOverMaterializedReason(upstreams, destination) {
|
|
51385
51612
|
const stored = upstreams.find((u) => u.materialize && u.storage === destination);
|
|
@@ -51392,7 +51619,7 @@ function placementReason(downstream, upstream) {
|
|
|
51392
51619
|
if (downstream === undefined) {
|
|
51393
51620
|
return storedElsewhereReason([upstream]);
|
|
51394
51621
|
}
|
|
51395
|
-
return `its upstream '${upstream.name}' is stored in the storage= destination ` + `'${upstream.storage}', and it is built into the storage= destination ` + `'${downstream}', which cannot read that table; a downstream is never ` + `built by recomputing its upstream from raw, so it is answered live
|
|
51622
|
+
return `its upstream '${upstream.name}' is stored in the storage= destination ` + `'${upstream.storage}', and it is built into the storage= destination ` + `'${downstream}', which cannot read that table; a downstream is never ` + `built by recomputing its upstream from raw, so it is answered live`;
|
|
51396
51623
|
}
|
|
51397
51624
|
var UPSTREAM_TABLE_UNUSABLE_REASON = "upstream_table_unusable";
|
|
51398
51625
|
var init_downstream_upstreams = __esm(() => {
|
|
@@ -56931,6 +57158,61 @@ async function compileParentKeyChecks(plans, needs, joinedKeys = []) {
|
|
|
56931
57158
|
delete plan.parentKeyChecks;
|
|
56932
57159
|
}
|
|
56933
57160
|
}
|
|
57161
|
+
async function compileGrainJoinKeyChecks(plans, joinsOf, sourceOf, stored) {
|
|
57162
|
+
const compiled = new Map;
|
|
57163
|
+
for (const plan of plans) {
|
|
57164
|
+
if (plan.variant !== true)
|
|
57165
|
+
continue;
|
|
57166
|
+
const checks = [];
|
|
57167
|
+
for (const { join, uncovered } of plan.joinOneGrain ?? []) {
|
|
57168
|
+
if (uncovered) {
|
|
57169
|
+
logger.info("A #(rollup) rollup's grain join key is not checked; queries that read nothing through the join are answered live", {
|
|
57170
|
+
rollup: plan.rollupSourceName,
|
|
57171
|
+
join,
|
|
57172
|
+
reason: "the build joins past it, through another join"
|
|
57173
|
+
});
|
|
57174
|
+
continue;
|
|
57175
|
+
}
|
|
57176
|
+
const j = joinsOf(plan.baseSourceID).find((x) => x.name === join && x.relationship === "one");
|
|
57177
|
+
const source = j?.sourceID ? sourceOf(j.sourceID) : undefined;
|
|
57178
|
+
const why = j?.sourceID === undefined || j.keyColumn === undefined ? "its join is not keyed on one column of a declared source" : source === undefined ? "no model names the joined source" : [...source.reads()].some((id) => stored.has(id)) ? "the joined source reads a table the run stores" : undefined;
|
|
57179
|
+
if (why !== undefined || !j?.sourceID || !j.keyColumn || !source) {
|
|
57180
|
+
logger.info("A #(rollup) rollup's grain join key is not checked; queries that read nothing through the join are answered live", { rollup: plan.rollupSourceName, join, reason: why });
|
|
57181
|
+
continue;
|
|
57182
|
+
}
|
|
57183
|
+
const { sourceID, keyColumn } = j;
|
|
57184
|
+
const key = `${sourceID}\x00${keyColumn}`;
|
|
57185
|
+
let sql = compiled.get(key);
|
|
57186
|
+
if (sql === undefined) {
|
|
57187
|
+
sql = source.compile(grainJoinKeyCheckQuery(source.name, keyColumn)).catch((error) => {
|
|
57188
|
+
logger.warn("A #(rollup) rollup's grain join key check did not compile; queries that read nothing through the join are answered live", {
|
|
57189
|
+
rollup: plan.rollupSourceName,
|
|
57190
|
+
join,
|
|
57191
|
+
source: source.name,
|
|
57192
|
+
keyColumn,
|
|
57193
|
+
code: errorCodeOf(error)
|
|
57194
|
+
});
|
|
57195
|
+
return;
|
|
57196
|
+
});
|
|
57197
|
+
compiled.set(key, sql);
|
|
57198
|
+
}
|
|
57199
|
+
const text = await sql;
|
|
57200
|
+
if (text === undefined)
|
|
57201
|
+
continue;
|
|
57202
|
+
checks.push({
|
|
57203
|
+
join,
|
|
57204
|
+
sourceID,
|
|
57205
|
+
keyColumn,
|
|
57206
|
+
connectionName: source.connectionName,
|
|
57207
|
+
sql: text
|
|
57208
|
+
});
|
|
57209
|
+
}
|
|
57210
|
+
if (checks.length > 0)
|
|
57211
|
+
plan.grainJoinKeyChecks = checks;
|
|
57212
|
+
else
|
|
57213
|
+
delete plan.grainJoinKeyChecks;
|
|
57214
|
+
}
|
|
57215
|
+
}
|
|
56934
57216
|
async function compileRollupKeyChecks(plans, materializer, modelPath) {
|
|
56935
57217
|
for (const plan of plans) {
|
|
56936
57218
|
const text = rollupKeyCheckQuery(plan);
|
|
@@ -58804,7 +59086,7 @@ var init_build_plan = __esm(() => {
|
|
|
58804
59086
|
});
|
|
58805
59087
|
|
|
58806
59088
|
// src/package_load/protocol.ts
|
|
58807
|
-
var PACKAGE_LOAD_PROTOCOL_VERSION =
|
|
59089
|
+
var PACKAGE_LOAD_PROTOCOL_VERSION = 10;
|
|
58808
59090
|
|
|
58809
59091
|
// src/package_load/package_load_worker.ts
|
|
58810
59092
|
init_served_copy_serve();
|
|
@@ -59917,7 +60199,11 @@ async function compileServedCopy(job) {
|
|
|
59917
60199
|
config: buildWorkerMalloyConfig(job)
|
|
59918
60200
|
});
|
|
59919
60201
|
const modelURL = pathToFileURL17(path20.join(job.packagePath, job.modelPath));
|
|
59920
|
-
const
|
|
60202
|
+
const virtualMap = job.virtualMap ? new Map(job.virtualMap.map(([connection, handles]) => [connection, new Map(handles)])) : undefined;
|
|
60203
|
+
const model = await runtime.loadModel(modelURL, {
|
|
60204
|
+
importBaseURL: new URL(".", modelURL),
|
|
60205
|
+
...virtualMap ? { virtualMap } : {}
|
|
60206
|
+
}).getModel();
|
|
59921
60207
|
return done({ modelDef: model._modelDef });
|
|
59922
60208
|
} catch (error) {
|
|
59923
60209
|
return done({ error: serializeError(error) });
|