@malloy-publisher/server 0.0.244 → 0.0.246
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -5
- package/dist/app/api-doc.yaml +323 -20
- package/dist/app/assets/{EnvironmentPage-BEvyNJlI.js → EnvironmentPage-EjXlK1AR.js} +1 -1
- package/dist/app/assets/{HomePage-BOJ5_n2P.js → HomePage-BDg82oe3.js} +1 -1
- package/dist/app/assets/{LightMode-DiRk-oG_.js → LightMode-CM8J0nPB.js} +1 -1
- package/dist/app/assets/{MainPage-CvWxTRF_.js → MainPage-CkkdimtC.js} +1 -1
- package/dist/app/assets/{MaterializationsPage-DTkN3KGF.js → MaterializationsPage-DvVS2HMi.js} +1 -1
- package/dist/app/assets/{ModelPage-C-Ds_tSI.js → ModelPage-Bz2je31A.js} +1 -1
- package/dist/app/assets/{PackagePage-C9kY78dt.js → PackagePage-BUJU3qB3.js} +1 -1
- package/dist/app/assets/{RouteError-dWMSDw8R.js → RouteError-oqZTfMol.js} +1 -1
- package/dist/app/assets/{ThemeEditorPage-EDVJy_ps.js → ThemeEditorPage-W-V8hngE.js} +1 -1
- package/dist/app/assets/{WorkbookPage-6kCZgXzD.js → WorkbookPage-IQFxsQGR.js} +1 -1
- package/dist/app/assets/{core-CbOoBenI.es-m46Eq2w-.js → core-BCwj9ZvB.es-C610H3gu.js} +1 -1
- package/dist/app/assets/{index-CzHda4nF.js → index-1xafiaYB.js} +1 -1
- package/dist/app/assets/{index-CmKKDEOJ.js → index-BUhTsFh9.js} +1 -1
- package/dist/app/assets/{index-B8MmVXwE.js → index-DJ-3RN5W.js} +4 -4
- package/dist/app/assets/{index-Bofgo-1r.js → index-Dxotbpnc.js} +1 -1
- package/dist/app/index.html +1 -1
- package/dist/instrumentation.mjs +10 -9
- package/dist/package_load_worker.mjs +209 -188
- package/dist/server.mjs +106862 -105526
- package/dist/sshcrypto-vd2k5hq9.node +0 -0
- package/package.json +4 -2
- package/publisher.config.example.bigquery.json +33 -0
- package/publisher.config.example.duckdb.json +23 -0
- package/dist/sshcrypto-8m50vnmb.node +0 -0
|
@@ -11447,6 +11447,56 @@ var init_logger = __esm(() => {
|
|
|
11447
11447
|
SENSITIVE_KEYS = new Set(SENSITIVE_KEY_NAMES.map((name) => name.toLowerCase()));
|
|
11448
11448
|
});
|
|
11449
11449
|
|
|
11450
|
+
// src/data_styles.ts
|
|
11451
|
+
function compileDataStyles(styles) {
|
|
11452
|
+
try {
|
|
11453
|
+
return JSON.parse(styles);
|
|
11454
|
+
} catch (error) {
|
|
11455
|
+
throw new Error(`Error compiling data styles: ${error}`);
|
|
11456
|
+
}
|
|
11457
|
+
}
|
|
11458
|
+
async function dataStylesForFile(url, text, urlReader) {
|
|
11459
|
+
const PREFIX = "--! styles ";
|
|
11460
|
+
let styles = {};
|
|
11461
|
+
for (const line of text.split(`
|
|
11462
|
+
`)) {
|
|
11463
|
+
if (line.startsWith(PREFIX)) {
|
|
11464
|
+
const fileName = line.trimEnd().substring(PREFIX.length);
|
|
11465
|
+
let stylesText;
|
|
11466
|
+
try {
|
|
11467
|
+
stylesText = await urlReader.readURL(new URL(fileName, url));
|
|
11468
|
+
} catch (error) {
|
|
11469
|
+
logger.error(`Error loading data style '${fileName}': ${error}`);
|
|
11470
|
+
stylesText = "{}";
|
|
11471
|
+
}
|
|
11472
|
+
styles = { ...styles, ...compileDataStyles(stylesText) };
|
|
11473
|
+
}
|
|
11474
|
+
}
|
|
11475
|
+
return styles;
|
|
11476
|
+
}
|
|
11477
|
+
|
|
11478
|
+
class HackyDataStylesAccumulator {
|
|
11479
|
+
urlReader;
|
|
11480
|
+
dataStyles = {};
|
|
11481
|
+
constructor(urlReader) {
|
|
11482
|
+
this.urlReader = urlReader;
|
|
11483
|
+
}
|
|
11484
|
+
async readURL(url) {
|
|
11485
|
+
const contents = await this.urlReader.readURL(url);
|
|
11486
|
+
this.dataStyles = {
|
|
11487
|
+
...this.dataStyles,
|
|
11488
|
+
...await dataStylesForFile(url.toString(), contents, this.urlReader)
|
|
11489
|
+
};
|
|
11490
|
+
return contents;
|
|
11491
|
+
}
|
|
11492
|
+
getHackyAccumulatedDataStyles() {
|
|
11493
|
+
return this.dataStyles;
|
|
11494
|
+
}
|
|
11495
|
+
}
|
|
11496
|
+
var init_data_styles = __esm(() => {
|
|
11497
|
+
init_logger();
|
|
11498
|
+
});
|
|
11499
|
+
|
|
11450
11500
|
// src/errors.ts
|
|
11451
11501
|
import { MalloyError } from "@malloydata/malloy";
|
|
11452
11502
|
function internalErrorToHttpError(error) {
|
|
@@ -11629,81 +11679,7 @@ var init_errors = __esm(() => {
|
|
|
11629
11679
|
};
|
|
11630
11680
|
});
|
|
11631
11681
|
|
|
11632
|
-
// src/package_load/package_load_worker.ts
|
|
11633
|
-
init_constants();
|
|
11634
|
-
var import_recursive_readdir = __toESM(require_recursive_readdir(), 1);
|
|
11635
|
-
import {
|
|
11636
|
-
contextOverlay,
|
|
11637
|
-
MalloyConfig,
|
|
11638
|
-
MalloyError as MalloyError2,
|
|
11639
|
-
modelDefToModelInfo,
|
|
11640
|
-
Runtime
|
|
11641
|
-
} from "@malloydata/malloy";
|
|
11642
|
-
import {
|
|
11643
|
-
MalloySQLParser,
|
|
11644
|
-
MalloySQLStatementType
|
|
11645
|
-
} from "@malloydata/malloy-sql";
|
|
11646
|
-
import * as fs2 from "fs";
|
|
11647
|
-
import * as path2 from "path";
|
|
11648
|
-
import { parentPort, threadId } from "node:worker_threads";
|
|
11649
|
-
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "url";
|
|
11650
|
-
|
|
11651
|
-
// src/data_styles.ts
|
|
11652
|
-
init_logger();
|
|
11653
|
-
function compileDataStyles(styles) {
|
|
11654
|
-
try {
|
|
11655
|
-
return JSON.parse(styles);
|
|
11656
|
-
} catch (error) {
|
|
11657
|
-
throw new Error(`Error compiling data styles: ${error}`);
|
|
11658
|
-
}
|
|
11659
|
-
}
|
|
11660
|
-
async function dataStylesForFile(url, text, urlReader) {
|
|
11661
|
-
const PREFIX = "--! styles ";
|
|
11662
|
-
let styles = {};
|
|
11663
|
-
for (const line of text.split(`
|
|
11664
|
-
`)) {
|
|
11665
|
-
if (line.startsWith(PREFIX)) {
|
|
11666
|
-
const fileName = line.trimEnd().substring(PREFIX.length);
|
|
11667
|
-
let stylesText;
|
|
11668
|
-
try {
|
|
11669
|
-
stylesText = await urlReader.readURL(new URL(fileName, url));
|
|
11670
|
-
} catch (error) {
|
|
11671
|
-
logger.error(`Error loading data style '${fileName}': ${error}`);
|
|
11672
|
-
stylesText = "{}";
|
|
11673
|
-
}
|
|
11674
|
-
styles = { ...styles, ...compileDataStyles(stylesText) };
|
|
11675
|
-
}
|
|
11676
|
-
}
|
|
11677
|
-
return styles;
|
|
11678
|
-
}
|
|
11679
|
-
|
|
11680
|
-
class HackyDataStylesAccumulator {
|
|
11681
|
-
urlReader;
|
|
11682
|
-
dataStyles = {};
|
|
11683
|
-
constructor(urlReader) {
|
|
11684
|
-
this.urlReader = urlReader;
|
|
11685
|
-
}
|
|
11686
|
-
async readURL(url) {
|
|
11687
|
-
const contents = await this.urlReader.readURL(url);
|
|
11688
|
-
this.dataStyles = {
|
|
11689
|
-
...this.dataStyles,
|
|
11690
|
-
...await dataStylesForFile(url.toString(), contents, this.urlReader)
|
|
11691
|
-
};
|
|
11692
|
-
return contents;
|
|
11693
|
-
}
|
|
11694
|
-
getHackyAccumulatedDataStyles() {
|
|
11695
|
-
return this.dataStyles;
|
|
11696
|
-
}
|
|
11697
|
-
}
|
|
11698
|
-
|
|
11699
|
-
// src/package_load/package_load_worker.ts
|
|
11700
|
-
init_errors();
|
|
11701
|
-
|
|
11702
11682
|
// src/service/authorize.ts
|
|
11703
|
-
init_errors();
|
|
11704
|
-
var AUTHORIZE_TAG = String.raw`##?\(\s*authorize\s*\)`;
|
|
11705
|
-
var AUTHORIZE_ANNOTATION_ANYWHERE = new RegExp(AUTHORIZE_TAG);
|
|
11706
|
-
var AUTHORIZE_ANNOTATION_PREFIX = new RegExp(`^${AUTHORIZE_TAG}`);
|
|
11707
11683
|
function assertNoCallerAuthorizeAnnotation(callerText) {
|
|
11708
11684
|
if (!AUTHORIZE_ANNOTATION_ANYWHERE.test(callerText))
|
|
11709
11685
|
return;
|
|
@@ -11723,8 +11699,6 @@ ${givenDecls.map((g) => ` ${g.name} :: ${g.type}`).join(`
|
|
|
11723
11699
|
limit: 1
|
|
11724
11700
|
}`;
|
|
11725
11701
|
}
|
|
11726
|
-
var GIVEN_REF_PATTERN = /\$([A-Za-z_][A-Za-z0-9_]*)/g;
|
|
11727
|
-
var STRING_LITERAL_PATTERN = /'(?:\\.|[^'\\])*'/g;
|
|
11728
11702
|
function referencedGivenNames(expr) {
|
|
11729
11703
|
const scanned = expr.replace(STRING_LITERAL_PATTERN, "''");
|
|
11730
11704
|
const names = [];
|
|
@@ -11898,92 +11872,15 @@ function unwrapQuotedExpression(body) {
|
|
|
11898
11872
|
}
|
|
11899
11873
|
return expr;
|
|
11900
11874
|
}
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
return raw;
|
|
11911
|
-
}
|
|
11912
|
-
throw new Error(`Invalid "scope" in the package manifest: ${JSON.stringify(raw)}. ` + `Expected "version" or "package" (default "package").`);
|
|
11913
|
-
}
|
|
11914
|
-
function resolvePackageScope(rootRaw, materializationRaw) {
|
|
11915
|
-
const envelopeRaw = materializationRaw && typeof materializationRaw === "object" ? materializationRaw.scope : undefined;
|
|
11916
|
-
const rootDeclared = rootRaw !== undefined && rootRaw !== null;
|
|
11917
|
-
const envelopeDeclared = envelopeRaw !== undefined && envelopeRaw !== null;
|
|
11918
|
-
const rootScope = parsePackageScope(rootRaw);
|
|
11919
|
-
const envelopeScope = parsePackageScope(envelopeRaw);
|
|
11920
|
-
if (rootDeclared && envelopeDeclared) {
|
|
11921
|
-
if (rootScope !== envelopeScope) {
|
|
11922
|
-
throw new Error(`Conflicting "scope" in publisher.json: root "${rootScope}" vs ` + `"materialization.scope" "${envelopeScope}". The package cannot ` + `load until they agree. Edit "materialization": { "scope": ... } ` + `to the value you want and delete the root-level "scope" (the ` + `server rewrites both homes on its next manifest write).`);
|
|
11923
|
-
}
|
|
11924
|
-
return { scope: envelopeScope, warnings: [] };
|
|
11925
|
-
}
|
|
11926
|
-
if (rootDeclared) {
|
|
11927
|
-
return { scope: rootScope, warnings: [SCOPE_ROOT_DEPRECATION] };
|
|
11928
|
-
}
|
|
11929
|
-
return { scope: envelopeScope, warnings: [] };
|
|
11930
|
-
}
|
|
11931
|
-
var SCOPE_ROOT_DEPRECATION = `"scope" at the manifest root is deprecated: declare it as ` + `"materialization": { "scope": ... } alongside the other build knobs. The ` + `root form still works and will be removed in a future release; until then ` + `the server keeps both homes in sync when it writes the manifest, so an ` + `older publisher still reads the right value.`;
|
|
11932
|
-
function parseFreshness(raw) {
|
|
11933
|
-
if (!raw || typeof raw !== "object") {
|
|
11934
|
-
return null;
|
|
11935
|
-
}
|
|
11936
|
-
const { window: window2, fallback } = raw;
|
|
11937
|
-
const freshness = {};
|
|
11938
|
-
if (typeof window2 === "string") {
|
|
11939
|
-
freshness.window = window2;
|
|
11940
|
-
}
|
|
11941
|
-
if (typeof fallback === "string" && FRESHNESS_FALLBACKS.includes(fallback)) {
|
|
11942
|
-
freshness.fallback = fallback;
|
|
11943
|
-
}
|
|
11944
|
-
return freshness;
|
|
11945
|
-
}
|
|
11946
|
-
function parseQueryMetadata(raw) {
|
|
11947
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
11948
|
-
return { metadata: null, warnings: [] };
|
|
11949
|
-
}
|
|
11950
|
-
const out = {};
|
|
11951
|
-
const warnings = [];
|
|
11952
|
-
for (const [name, value] of Object.entries(raw)) {
|
|
11953
|
-
if (typeof value === "string") {
|
|
11954
|
-
out[name] = value;
|
|
11955
|
-
} else {
|
|
11956
|
-
warnings.push(`materialization.queryMetadata: property '${name}' must be a ` + `string (got ${value === null ? "null" : typeof value}); it is ` + `not attached to any statement`);
|
|
11957
|
-
}
|
|
11958
|
-
}
|
|
11959
|
-
return {
|
|
11960
|
-
metadata: Object.keys(out).length > 0 ? out : null,
|
|
11961
|
-
warnings
|
|
11962
|
-
};
|
|
11963
|
-
}
|
|
11964
|
-
function parsePackageMaterialization(raw) {
|
|
11965
|
-
if (!raw || typeof raw !== "object") {
|
|
11966
|
-
return null;
|
|
11967
|
-
}
|
|
11968
|
-
const { schedule, freshness, queryMetadata } = raw;
|
|
11969
|
-
return {
|
|
11970
|
-
schedule: typeof schedule === "string" ? schedule : null,
|
|
11971
|
-
freshness: parseFreshness(freshness),
|
|
11972
|
-
queryMetadata: parseQueryMetadata(queryMetadata).metadata
|
|
11973
|
-
};
|
|
11974
|
-
}
|
|
11975
|
-
function packageMaterializationWarnings(raw) {
|
|
11976
|
-
if (!raw || typeof raw !== "object") {
|
|
11977
|
-
return [];
|
|
11978
|
-
}
|
|
11979
|
-
const { queryMetadata } = raw;
|
|
11980
|
-
return parseQueryMetadata(queryMetadata).warnings;
|
|
11981
|
-
}
|
|
11982
|
-
|
|
11983
|
-
// src/service/source_extraction.ts
|
|
11984
|
-
import {
|
|
11985
|
-
isSourceDef
|
|
11986
|
-
} from "@malloydata/malloy";
|
|
11875
|
+
var AUTHORIZE_TAG, AUTHORIZE_ANNOTATION_ANYWHERE, AUTHORIZE_ANNOTATION_PREFIX, GIVEN_REF_PATTERN, STRING_LITERAL_PATTERN;
|
|
11876
|
+
var init_authorize = __esm(() => {
|
|
11877
|
+
init_errors();
|
|
11878
|
+
AUTHORIZE_TAG = String.raw`##?\(\s*authorize\s*\)`;
|
|
11879
|
+
AUTHORIZE_ANNOTATION_ANYWHERE = new RegExp(AUTHORIZE_TAG);
|
|
11880
|
+
AUTHORIZE_ANNOTATION_PREFIX = new RegExp(`^${AUTHORIZE_TAG}`);
|
|
11881
|
+
GIVEN_REF_PATTERN = /\$([A-Za-z_][A-Za-z0-9_]*)/g;
|
|
11882
|
+
STRING_LITERAL_PATTERN = /'(?:\\.|[^'\\])*'/g;
|
|
11883
|
+
});
|
|
11987
11884
|
|
|
11988
11885
|
// src/service/annotations.ts
|
|
11989
11886
|
import { Annotations } from "@malloydata/malloy";
|
|
@@ -12045,16 +11942,9 @@ function annotationTexts(annote) {
|
|
|
12045
11942
|
function ownLevelNoteTexts(annote) {
|
|
12046
11943
|
return [...annote?.blockNotes ?? [], ...annote?.notes ?? []].map((note) => note.text);
|
|
12047
11944
|
}
|
|
11945
|
+
var init_annotations = () => {};
|
|
12048
11946
|
|
|
12049
11947
|
// src/service/filter.ts
|
|
12050
|
-
var VALID_FILTER_TYPES = new Set([
|
|
12051
|
-
"equal",
|
|
12052
|
-
"in",
|
|
12053
|
-
"like",
|
|
12054
|
-
"greater_than",
|
|
12055
|
-
"less_than"
|
|
12056
|
-
]);
|
|
12057
|
-
var ANNOTATION_PREFIX = "#(filter)";
|
|
12058
11948
|
function parseFilterAnnotation(annotation) {
|
|
12059
11949
|
const trimmed = annotation.trim();
|
|
12060
11950
|
if (!trimmed.startsWith(ANNOTATION_PREFIX)) {
|
|
@@ -12130,8 +12020,6 @@ function isBooleanLiteral(v) {
|
|
|
12130
12020
|
const lower = v.toLowerCase();
|
|
12131
12021
|
return lower === "true" || lower === "false";
|
|
12132
12022
|
}
|
|
12133
|
-
var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
12134
|
-
var ISO_TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/;
|
|
12135
12023
|
function isDateLiteral(v) {
|
|
12136
12024
|
return ISO_DATE_RE.test(v) || ISO_TIMESTAMP_RE.test(v);
|
|
12137
12025
|
}
|
|
@@ -12200,13 +12088,6 @@ function injectFilterRefinement(query, filterClause) {
|
|
|
12200
12088
|
return `${query.trimEnd()}
|
|
12201
12089
|
+ {where: ${filterClause}}`;
|
|
12202
12090
|
}
|
|
12203
|
-
|
|
12204
|
-
class FilterValidationError extends Error {
|
|
12205
|
-
constructor(message) {
|
|
12206
|
-
super(message);
|
|
12207
|
-
this.name = "FilterValidationError";
|
|
12208
|
-
}
|
|
12209
|
-
}
|
|
12210
12091
|
function tokenize(input) {
|
|
12211
12092
|
const tokens = [];
|
|
12212
12093
|
let current = "";
|
|
@@ -12236,8 +12117,29 @@ function tokenize(input) {
|
|
|
12236
12117
|
}
|
|
12237
12118
|
return tokens;
|
|
12238
12119
|
}
|
|
12120
|
+
var VALID_FILTER_TYPES, ANNOTATION_PREFIX = "#(filter)", ISO_DATE_RE, ISO_TIMESTAMP_RE, FilterValidationError;
|
|
12121
|
+
var init_filter = __esm(() => {
|
|
12122
|
+
VALID_FILTER_TYPES = new Set([
|
|
12123
|
+
"equal",
|
|
12124
|
+
"in",
|
|
12125
|
+
"like",
|
|
12126
|
+
"greater_than",
|
|
12127
|
+
"less_than"
|
|
12128
|
+
]);
|
|
12129
|
+
ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
12130
|
+
ISO_TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/;
|
|
12131
|
+
FilterValidationError = class FilterValidationError extends Error {
|
|
12132
|
+
constructor(message) {
|
|
12133
|
+
super(message);
|
|
12134
|
+
this.name = "FilterValidationError";
|
|
12135
|
+
}
|
|
12136
|
+
};
|
|
12137
|
+
});
|
|
12239
12138
|
|
|
12240
12139
|
// src/service/source_extraction.ts
|
|
12140
|
+
import {
|
|
12141
|
+
isSourceDef
|
|
12142
|
+
} from "@malloydata/malloy";
|
|
12241
12143
|
function extractSourcesFromModelDef(modelDef, givens, onParseError) {
|
|
12242
12144
|
const filterMap = new Map;
|
|
12243
12145
|
const authorizeMap = new Map;
|
|
@@ -12330,6 +12232,11 @@ function extractQueriesFromModelDef(modelDef) {
|
|
|
12330
12232
|
annotations: annotationTexts(queryObj.annotations)
|
|
12331
12233
|
}));
|
|
12332
12234
|
}
|
|
12235
|
+
var init_source_extraction = __esm(() => {
|
|
12236
|
+
init_annotations();
|
|
12237
|
+
init_authorize();
|
|
12238
|
+
init_filter();
|
|
12239
|
+
});
|
|
12333
12240
|
|
|
12334
12241
|
// src/service/given.ts
|
|
12335
12242
|
function malloyGivenToApi(given) {
|
|
@@ -12342,26 +12249,140 @@ function malloyGivenToApi(given) {
|
|
|
12342
12249
|
default: given._internal?.defaultText
|
|
12343
12250
|
};
|
|
12344
12251
|
}
|
|
12252
|
+
var init_given = __esm(() => {
|
|
12253
|
+
init_annotations();
|
|
12254
|
+
});
|
|
12345
12255
|
|
|
12346
12256
|
// src/utils.ts
|
|
12347
12257
|
import * as fs from "fs";
|
|
12348
12258
|
import * as path from "path";
|
|
12349
12259
|
import { fileURLToPath } from "url";
|
|
12350
|
-
var URL_READER = {
|
|
12351
|
-
readURL: (url) => {
|
|
12352
|
-
let path2 = url.toString();
|
|
12353
|
-
if (url.protocol == "file:") {
|
|
12354
|
-
path2 = fileURLToPath(url);
|
|
12355
|
-
}
|
|
12356
|
-
return fs.promises.readFile(path2, "utf8");
|
|
12357
|
-
}
|
|
12358
|
-
};
|
|
12359
12260
|
function ignoreDotfiles(file) {
|
|
12360
12261
|
return path.basename(file).startsWith(".");
|
|
12361
12262
|
}
|
|
12362
12263
|
function errMessage(err) {
|
|
12363
12264
|
return err instanceof Error ? err.message : String(err);
|
|
12364
12265
|
}
|
|
12266
|
+
var URL_READER;
|
|
12267
|
+
var init_utils = __esm(() => {
|
|
12268
|
+
URL_READER = {
|
|
12269
|
+
readURL: (url) => {
|
|
12270
|
+
let path2 = url.toString();
|
|
12271
|
+
if (url.protocol == "file:") {
|
|
12272
|
+
path2 = fileURLToPath(url);
|
|
12273
|
+
}
|
|
12274
|
+
return fs.promises.readFile(path2, "utf8");
|
|
12275
|
+
}
|
|
12276
|
+
};
|
|
12277
|
+
});
|
|
12278
|
+
|
|
12279
|
+
// src/package_load/package_load_worker.ts
|
|
12280
|
+
init_constants();
|
|
12281
|
+
init_data_styles();
|
|
12282
|
+
init_errors();
|
|
12283
|
+
init_authorize();
|
|
12284
|
+
var import_recursive_readdir = __toESM(require_recursive_readdir(), 1);
|
|
12285
|
+
import {
|
|
12286
|
+
contextOverlay,
|
|
12287
|
+
MalloyConfig,
|
|
12288
|
+
MalloyError as MalloyError2,
|
|
12289
|
+
modelDefToModelInfo,
|
|
12290
|
+
Runtime
|
|
12291
|
+
} from "@malloydata/malloy";
|
|
12292
|
+
import {
|
|
12293
|
+
MalloySQLParser,
|
|
12294
|
+
MalloySQLStatementType
|
|
12295
|
+
} from "@malloydata/malloy-sql";
|
|
12296
|
+
import * as fs2 from "fs";
|
|
12297
|
+
import * as path2 from "path";
|
|
12298
|
+
import { parentPort, threadId } from "node:worker_threads";
|
|
12299
|
+
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "url";
|
|
12300
|
+
|
|
12301
|
+
// src/service/package_manifest.ts
|
|
12302
|
+
var FRESHNESS_FALLBACKS = ["live", "stale_ok", "fail"];
|
|
12303
|
+
var PACKAGE_SCOPES = ["version", "package"];
|
|
12304
|
+
function parsePackageScope(raw) {
|
|
12305
|
+
if (raw === undefined || raw === null) {
|
|
12306
|
+
return "package";
|
|
12307
|
+
}
|
|
12308
|
+
if (PACKAGE_SCOPES.includes(raw)) {
|
|
12309
|
+
return raw;
|
|
12310
|
+
}
|
|
12311
|
+
throw new Error(`Invalid "scope" in the package manifest: ${JSON.stringify(raw)}. ` + `Expected "version" or "package" (default "package").`);
|
|
12312
|
+
}
|
|
12313
|
+
function resolvePackageScope(rootRaw, materializationRaw) {
|
|
12314
|
+
const envelopeRaw = materializationRaw && typeof materializationRaw === "object" ? materializationRaw.scope : undefined;
|
|
12315
|
+
const rootDeclared = rootRaw !== undefined && rootRaw !== null;
|
|
12316
|
+
const envelopeDeclared = envelopeRaw !== undefined && envelopeRaw !== null;
|
|
12317
|
+
const rootScope = parsePackageScope(rootRaw);
|
|
12318
|
+
const envelopeScope = parsePackageScope(envelopeRaw);
|
|
12319
|
+
if (rootDeclared && envelopeDeclared) {
|
|
12320
|
+
if (rootScope !== envelopeScope) {
|
|
12321
|
+
throw new Error(`Conflicting "scope" in publisher.json: root "${rootScope}" vs ` + `"materialization.scope" "${envelopeScope}". The package cannot ` + `load until they agree. Edit "materialization": { "scope": ... } ` + `to the value you want and delete the root-level "scope" (the ` + `server rewrites both homes on its next manifest write).`);
|
|
12322
|
+
}
|
|
12323
|
+
return { scope: envelopeScope, warnings: [] };
|
|
12324
|
+
}
|
|
12325
|
+
if (rootDeclared) {
|
|
12326
|
+
return { scope: rootScope, warnings: [SCOPE_ROOT_DEPRECATION] };
|
|
12327
|
+
}
|
|
12328
|
+
return { scope: envelopeScope, warnings: [] };
|
|
12329
|
+
}
|
|
12330
|
+
var SCOPE_ROOT_DEPRECATION = `"scope" at the manifest root is deprecated: declare it as ` + `"materialization": { "scope": ... } alongside the other build knobs. The ` + `root form still works and will be removed in a future release; until then ` + `the server keeps both homes in sync when it writes the manifest, so an ` + `older publisher still reads the right value.`;
|
|
12331
|
+
function parseFreshness(raw) {
|
|
12332
|
+
if (!raw || typeof raw !== "object") {
|
|
12333
|
+
return null;
|
|
12334
|
+
}
|
|
12335
|
+
const { window: window2, fallback } = raw;
|
|
12336
|
+
const freshness = {};
|
|
12337
|
+
if (typeof window2 === "string") {
|
|
12338
|
+
freshness.window = window2;
|
|
12339
|
+
}
|
|
12340
|
+
if (typeof fallback === "string" && FRESHNESS_FALLBACKS.includes(fallback)) {
|
|
12341
|
+
freshness.fallback = fallback;
|
|
12342
|
+
}
|
|
12343
|
+
return freshness;
|
|
12344
|
+
}
|
|
12345
|
+
function parseQueryMetadata(raw) {
|
|
12346
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
12347
|
+
return { metadata: null, warnings: [] };
|
|
12348
|
+
}
|
|
12349
|
+
const out = {};
|
|
12350
|
+
const warnings = [];
|
|
12351
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
12352
|
+
if (typeof value === "string") {
|
|
12353
|
+
out[name] = value;
|
|
12354
|
+
} else {
|
|
12355
|
+
warnings.push(`materialization.queryMetadata: property '${name}' must be a ` + `string (got ${value === null ? "null" : typeof value}); it is ` + `not attached to any statement`);
|
|
12356
|
+
}
|
|
12357
|
+
}
|
|
12358
|
+
return {
|
|
12359
|
+
metadata: Object.keys(out).length > 0 ? out : null,
|
|
12360
|
+
warnings
|
|
12361
|
+
};
|
|
12362
|
+
}
|
|
12363
|
+
function parsePackageMaterialization(raw) {
|
|
12364
|
+
if (!raw || typeof raw !== "object") {
|
|
12365
|
+
return null;
|
|
12366
|
+
}
|
|
12367
|
+
const { schedule, freshness, queryMetadata } = raw;
|
|
12368
|
+
return {
|
|
12369
|
+
schedule: typeof schedule === "string" ? schedule : null,
|
|
12370
|
+
freshness: parseFreshness(freshness),
|
|
12371
|
+
queryMetadata: parseQueryMetadata(queryMetadata).metadata
|
|
12372
|
+
};
|
|
12373
|
+
}
|
|
12374
|
+
function packageMaterializationWarnings(raw) {
|
|
12375
|
+
if (!raw || typeof raw !== "object") {
|
|
12376
|
+
return [];
|
|
12377
|
+
}
|
|
12378
|
+
const { queryMetadata } = raw;
|
|
12379
|
+
return parseQueryMetadata(queryMetadata).warnings;
|
|
12380
|
+
}
|
|
12381
|
+
|
|
12382
|
+
// src/package_load/package_load_worker.ts
|
|
12383
|
+
init_source_extraction();
|
|
12384
|
+
init_given();
|
|
12385
|
+
init_utils();
|
|
12365
12386
|
|
|
12366
12387
|
// src/package_load/rpc_wait_accountant.ts
|
|
12367
12388
|
class RpcWaitAccountant {
|