@malloy-publisher/server 0.0.248 → 0.0.249

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.
Files changed (25) hide show
  1. package/dist/app/api-doc.yaml +396 -21
  2. package/dist/app/assets/{EnvironmentPage-DrTRtRHz.js → EnvironmentPage-CB0NkVVs.js} +1 -1
  3. package/dist/app/assets/HomePage-BEfG37L3.js +1 -0
  4. package/dist/app/assets/{LightMode-4Y7DEWAD.js → LightMode--nzFqff1.js} +1 -1
  5. package/dist/app/assets/{MainPage-DKNR-8Vr.js → MainPage-owd1ua9R.js} +2 -2
  6. package/dist/app/assets/{MaterializationsPage-h3ONDcgJ.js → MaterializationsPage-BqaGRrxZ.js} +1 -1
  7. package/dist/app/assets/ModelPage-BydBAuRk.js +1 -0
  8. package/dist/app/assets/{PackagePage-D8mM4T37.js → PackagePage-BDl_rs-E.js} +1 -1
  9. package/dist/app/assets/{RouteError-DzJ0TPOj.js → RouteError-CyReblMg.js} +1 -1
  10. package/dist/app/assets/{ThemeEditorPage-BYvxc5op.js → ThemeEditorPage-zW7ndXQ8.js} +1 -1
  11. package/dist/app/assets/{WorkbookPage-CYOpAw7I.js → WorkbookPage-CzjOTRw8.js} +1 -1
  12. package/dist/app/assets/{core-BuvlzSIX.es-cZHBIpH6.js → core-DFBwNhvb.es-BwyvPM0R.js} +10 -10
  13. package/dist/app/assets/index-Byu4Enw7.js +2 -0
  14. package/dist/app/assets/{index-BgAa2J25.js → index-Cmp8wg1s.js} +1 -1
  15. package/dist/app/assets/{index-BgMR5Uuv.js → index-D6bZJBhc.js} +113 -113
  16. package/dist/app/assets/index-t7IEDVsK.js +615 -0
  17. package/dist/app/index.html +1 -1
  18. package/dist/package_load_worker.mjs +342 -2
  19. package/dist/server.mjs +1726 -134
  20. package/dist/sshcrypto-vd2k5hq9.node +0 -0
  21. package/package.json +2 -1
  22. package/dist/app/assets/HomePage-X_Wozguy.js +0 -1
  23. package/dist/app/assets/ModelPage-B8Qsrbxn.js +0 -1
  24. package/dist/app/assets/index-BwoU1Ko8.js +0 -529
  25. package/dist/app/assets/index-CuaX7xuf.js +0 -18
@@ -11,7 +11,7 @@
11
11
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
12
12
  />
13
13
  <title>Malloy Publisher</title>
14
- <script type="module" crossorigin src="/assets/index-BwoU1Ko8.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-t7IEDVsK.js"></script>
15
15
  <link rel="stylesheet" crossorigin href="/assets/index-5eLCcNmP.css">
16
16
  </head>
17
17
  <body>
@@ -2369,6 +2369,8 @@ function internalErrorToHttpError(error) {
2369
2369
  return httpError(404, error.message);
2370
2370
  } else if (error instanceof ModelNotFoundError) {
2371
2371
  return httpError(404, error.message);
2372
+ } else if (error instanceof DashboardNotFoundError) {
2373
+ return httpError(404, error.message);
2372
2374
  } else if (error instanceof NotQueryableError) {
2373
2375
  return httpError(404, error.message);
2374
2376
  } else if (error instanceof MalloyError) {
@@ -2414,7 +2416,7 @@ function httpError(code, message) {
2414
2416
  }
2415
2417
  };
2416
2418
  }
2417
- var NotImplementedError, BadRequestError, InvalidArgumentError, EnvironmentNotFoundError, PackageNotFoundError, ModelNotFoundError, ConnectionNotFoundError, ConnectionError, DestinationNotFoundError, ConnectionAuthError, UnsupportedCatalogFormatError, ModelCompilationError, MaterializationEligibilityError, FrozenConfigError, AccessDeniedError, NotQueryableError, MaterializationNotFoundError, MaterializationConflictError, InvalidStateTransitionError, ServiceUnavailableError, PayloadTooLargeError, ResponseUnserializableError, QueryTimeoutError;
2419
+ var NotImplementedError, BadRequestError, InvalidArgumentError, EnvironmentNotFoundError, PackageNotFoundError, ModelNotFoundError, DashboardNotFoundError, ConnectionNotFoundError, ConnectionError, DestinationNotFoundError, ConnectionAuthError, UnsupportedCatalogFormatError, ModelCompilationError, MaterializationEligibilityError, FrozenConfigError, AccessDeniedError, NotQueryableError, MaterializationNotFoundError, MaterializationConflictError, InvalidStateTransitionError, ServiceUnavailableError, PayloadTooLargeError, ResponseUnserializableError, QueryTimeoutError;
2418
2420
  var init_errors = __esm(() => {
2419
2421
  init_constants();
2420
2422
  NotImplementedError = class NotImplementedError extends Error {
@@ -2444,6 +2446,11 @@ var init_errors = __esm(() => {
2444
2446
  super(message);
2445
2447
  }
2446
2448
  };
2449
+ DashboardNotFoundError = class DashboardNotFoundError extends Error {
2450
+ constructor(message) {
2451
+ super(message);
2452
+ }
2453
+ };
2447
2454
  ConnectionNotFoundError = class ConnectionNotFoundError extends Error {
2448
2455
  constructor(message) {
2449
2456
  super(message);
@@ -14186,19 +14193,352 @@ var init_source_extraction = __esm(() => {
14186
14193
  init_gate_registry_walk();
14187
14194
  });
14188
14195
 
14196
+ // src/service/motly.ts
14197
+ import { parseAnnotation } from "@malloydata/malloy-tag";
14198
+ function onMotlyRoute(text) {
14199
+ const afterSigil = text.replace(/^##?\|?/, "");
14200
+ return afterSigil === "" || /^[ \t\r\n]/.test(afterSigil);
14201
+ }
14202
+ function hasEnvReference(annotation) {
14203
+ return annotation.includes("@env.");
14204
+ }
14205
+ function pollutionTargets() {
14206
+ const targets = [Object.prototype];
14207
+ for (const key of Object.getOwnPropertyNames(Object.prototype)) {
14208
+ const descriptor = Object.getOwnPropertyDescriptor(Object.prototype, key);
14209
+ if (!descriptor)
14210
+ continue;
14211
+ let value;
14212
+ if ("value" in descriptor) {
14213
+ value = descriptor.value;
14214
+ } else {
14215
+ if (BUILT_IN_PROTO_GETTER === undefined || descriptor.get !== BUILT_IN_PROTO_GETTER) {
14216
+ return;
14217
+ }
14218
+ continue;
14219
+ }
14220
+ if ((typeof value === "object" || typeof value === "function") && value !== null && !targets.includes(value)) {
14221
+ targets.push(value);
14222
+ }
14223
+ }
14224
+ return targets;
14225
+ }
14226
+ function parseGuarded(texts) {
14227
+ const targets = pollutionTargets();
14228
+ if (targets === undefined) {
14229
+ return { tag: undefined, messages: [UNSAFE_TO_PARSE] };
14230
+ }
14231
+ let unreadable = false;
14232
+ const ownNames = (target) => {
14233
+ try {
14234
+ return Object.getOwnPropertyNames(target);
14235
+ } catch {
14236
+ unreadable = true;
14237
+ return [];
14238
+ }
14239
+ };
14240
+ const before = targets.map(ownNames);
14241
+ if (unreadable)
14242
+ return { tag: undefined, messages: [UNSAFE_TO_PARSE] };
14243
+ const undoPollution = () => {
14244
+ let polluted = false;
14245
+ targets.forEach((target, index) => {
14246
+ for (const key of ownNames(target)) {
14247
+ if (before[index].includes(key))
14248
+ continue;
14249
+ polluted = true;
14250
+ try {
14251
+ delete target[key];
14252
+ } catch {}
14253
+ }
14254
+ });
14255
+ return polluted || unreadable;
14256
+ };
14257
+ if (texts.some((text) => text.length > MAX_ANNOTATION_CHARS)) {
14258
+ return { tag: undefined, messages: [ANNOTATION_TOO_LONG] };
14259
+ }
14260
+ try {
14261
+ const result = parseAnnotation([...texts]);
14262
+ if (undoPollution())
14263
+ return { tag: undefined, messages: [UNSAFE_TO_PARSE] };
14264
+ return {
14265
+ tag: result.tag,
14266
+ messages: result.log.map((error) => error.message)
14267
+ };
14268
+ } catch {
14269
+ undoPollution();
14270
+ return { tag: undefined, messages: [UNSAFE_TO_PARSE] };
14271
+ }
14272
+ }
14273
+ function docCommentText(texts) {
14274
+ const lines = texts.filter((text) => /^##?\|?"([ \t\r\n]|$)/.test(text)).map((text) => text.replace(/^##?\|?"[ \t\r\n]?/, "").trimEnd());
14275
+ return lines.some((text) => text.trim().length > 0) ? lines.join(`
14276
+ `) : undefined;
14277
+ }
14278
+ function splitDocComment(texts) {
14279
+ const text = docCommentText(texts);
14280
+ if (text === undefined)
14281
+ return {};
14282
+ const lines = text.split(`
14283
+ `);
14284
+ const titleLine = lines.findIndex((line) => line.trim().length > 0);
14285
+ if (titleLine === -1)
14286
+ return {};
14287
+ const body = lines.slice(titleLine + 1).join(`
14288
+ `).replace(/^[ \t\r\n]+/, "").trimEnd();
14289
+ return {
14290
+ title: lines[titleLine].trim(),
14291
+ body: body.length > 0 ? body : undefined
14292
+ };
14293
+ }
14294
+ function docCommentTitleAndDescription(texts, explicitTitle) {
14295
+ if (explicitTitle !== undefined) {
14296
+ return { title: explicitTitle, description: docCommentText(texts) };
14297
+ }
14298
+ const { title, body } = splitDocComment(texts);
14299
+ return { title, description: body };
14300
+ }
14301
+ function quoteFilterLiterals(annotation) {
14302
+ const VALUE_START = /[=[,]/;
14303
+ const BARE_FILTER_LITERAL = /^([ \t]*)f(['"])((?:\\.|(?!\2)[^\\])*)\2/;
14304
+ let out = "";
14305
+ let i = 0;
14306
+ while (i < annotation.length) {
14307
+ const char = annotation[i];
14308
+ const delimited = endOfDelimited(annotation, i);
14309
+ if (delimited > i) {
14310
+ out += annotation.slice(i, delimited);
14311
+ i = delimited;
14312
+ continue;
14313
+ }
14314
+ if (VALUE_START.test(char)) {
14315
+ const match = BARE_FILTER_LITERAL.exec(annotation.slice(i + 1));
14316
+ if (match) {
14317
+ const body = match[3].replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
14318
+ out += `${char}${match[1]}"f'${body}'"`;
14319
+ i += 1 + match[0].length;
14320
+ continue;
14321
+ }
14322
+ }
14323
+ out += char;
14324
+ i += 1;
14325
+ }
14326
+ return out;
14327
+ }
14328
+ function endOfDelimited(text, start) {
14329
+ const char = text[start];
14330
+ if (char === "`") {
14331
+ let i = start + 1;
14332
+ while (i < text.length) {
14333
+ if (text[i] === "\\") {
14334
+ i += 2;
14335
+ continue;
14336
+ }
14337
+ if (text[i] === "`")
14338
+ return i + 1;
14339
+ if (text[i] === `
14340
+ `)
14341
+ return text.length;
14342
+ i += 1;
14343
+ }
14344
+ return text.length;
14345
+ }
14346
+ if (text.startsWith("<<<", start)) {
14347
+ let lineStart = start + 3;
14348
+ for (;; ) {
14349
+ const newline = text.indexOf(`
14350
+ `, lineStart);
14351
+ const lineEnd = newline === -1 ? text.length : newline;
14352
+ if (text.slice(lineStart, lineEnd).trim() === ">>>")
14353
+ return lineEnd;
14354
+ if (newline === -1)
14355
+ return text.length;
14356
+ lineStart = newline + 1;
14357
+ }
14358
+ }
14359
+ if (char === '"' || char === "'") {
14360
+ const triple = char.repeat(3);
14361
+ if (text.startsWith(triple, start)) {
14362
+ let i2 = start + triple.length;
14363
+ while (i2 < text.length) {
14364
+ if (text[i2] === "\\") {
14365
+ i2 += 2;
14366
+ continue;
14367
+ }
14368
+ if (text.startsWith(triple, i2))
14369
+ return i2 + triple.length;
14370
+ i2 += 1;
14371
+ }
14372
+ return text.length;
14373
+ }
14374
+ let i = start + 1;
14375
+ while (i < text.length) {
14376
+ if (text[i] === "\\") {
14377
+ i += 2;
14378
+ continue;
14379
+ }
14380
+ if (text[i] === char)
14381
+ return i + 1;
14382
+ if (text[i] === `
14383
+ `)
14384
+ return i;
14385
+ i += 1;
14386
+ }
14387
+ return text.length;
14388
+ }
14389
+ return start;
14390
+ }
14391
+ function unwrapFilterLiteral(value) {
14392
+ const match = /^f(['"])([\s\S]*)\1$/.exec(value);
14393
+ return match ? match[2] : value;
14394
+ }
14395
+ function parseMotly(texts) {
14396
+ const onRoute = texts.filter(onMotlyRoute);
14397
+ const motly = onRoute.filter((text) => !hasEnvReference(text));
14398
+ const envDropped = onRoute.length - motly.length;
14399
+ const envErrors = envDropped > 0 ? [ENV_REFERENCE_DROPPED] : [];
14400
+ if (motly.length === 0)
14401
+ return { tag: undefined, errors: envErrors };
14402
+ const direct = parseGuarded(motly);
14403
+ if (direct.messages.length === 0)
14404
+ return { tag: direct.tag, errors: envErrors };
14405
+ const rescued = motly.map((text) => {
14406
+ if (parseGuarded([text]).messages.length === 0)
14407
+ return text;
14408
+ const rewritten = quoteFilterLiterals(text);
14409
+ return parseGuarded([rewritten]).messages.length === 0 ? rewritten : text;
14410
+ });
14411
+ const after = parseGuarded(rescued);
14412
+ return { tag: after.tag, errors: [...envErrors, ...after.messages] };
14413
+ }
14414
+ function tagText(tag, ...path) {
14415
+ try {
14416
+ return tag?.text(...path);
14417
+ } catch {
14418
+ return;
14419
+ }
14420
+ }
14421
+ function tagNumeric(tag, ...path) {
14422
+ try {
14423
+ const raw = tagText(tag, ...path);
14424
+ if (raw === undefined)
14425
+ return;
14426
+ const DECIMAL = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;
14427
+ const text = raw.trim();
14428
+ if (!DECIMAL.test(text))
14429
+ return;
14430
+ const value = Number(text);
14431
+ return Number.isFinite(value) ? value : undefined;
14432
+ } catch {
14433
+ return;
14434
+ }
14435
+ }
14436
+ function motlyTag(texts) {
14437
+ return parseMotly(texts).tag;
14438
+ }
14439
+ function motlyParseErrors(texts) {
14440
+ return parseMotly(texts).errors;
14441
+ }
14442
+ function readAutorun(tag) {
14443
+ return tagText(tag, "autorun") !== "false";
14444
+ }
14445
+ function scalarTypeOf(tag) {
14446
+ try {
14447
+ return tag?.scalarType();
14448
+ } catch {
14449
+ return;
14450
+ }
14451
+ }
14452
+ function authoredDay(isoText) {
14453
+ const value = new Date(isoText);
14454
+ if (Number.isNaN(value.getTime()))
14455
+ return isoText.slice(0, 10);
14456
+ const atUtcMidnight = value.getUTCHours() === 0 && value.getUTCMinutes() === 0 && value.getUTCSeconds() === 0 && value.getUTCMilliseconds() === 0;
14457
+ const year = atUtcMidnight ? value.getUTCFullYear() : value.getFullYear();
14458
+ const month = atUtcMidnight ? value.getUTCMonth() : value.getMonth();
14459
+ const day = atUtcMidnight ? value.getUTCDate() : value.getDate();
14460
+ return `${year}-${String(month + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
14461
+ }
14462
+ function readStartingGivens(tag, declaredType) {
14463
+ const entries = tag?.tag("givens");
14464
+ if (!entries)
14465
+ return;
14466
+ const collected = {};
14467
+ for (const [name, value] of entries.entries()) {
14468
+ const tag2 = value;
14469
+ const text = tagText(tag2);
14470
+ if (text === undefined)
14471
+ continue;
14472
+ const declared = declaredType(name);
14473
+ collected[name] = scalarTypeOf(tag2) === "date" && declared !== "timestamp" && declared !== "timestamptz" ? authoredDay(text) : declared?.startsWith("filter<") ? unwrapFilterLiteral(text) : text;
14474
+ }
14475
+ return Object.keys(collected).length > 0 ? collected : undefined;
14476
+ }
14477
+ var BUILT_IN_PROTO_GETTER, MAX_ANNOTATION_CHARS = 8192, ANNOTATION_TOO_LONG, ENV_REFERENCE_DROPPED = "annotation dropped for carrying an @env. reference", UNSAFE_TO_PARSE = "annotation could not be parsed safely";
14478
+ var init_motly = __esm(() => {
14479
+ BUILT_IN_PROTO_GETTER = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__")?.get;
14480
+ ANNOTATION_TOO_LONG = `annotation exceeds ${MAX_ANNOTATION_CHARS} characters and was not parsed`;
14481
+ });
14482
+
14189
14483
  // src/service/given.ts
14484
+ function presentText(tag, ...path) {
14485
+ const raw = tagText(tag, ...path);
14486
+ return raw !== undefined && raw.trim() !== "" ? raw : undefined;
14487
+ }
14488
+ function readGivenControlSpec(annotationTexts2) {
14489
+ const spec = {};
14490
+ const tag = motlyTag(annotationTexts2);
14491
+ if (!tag)
14492
+ return spec;
14493
+ const label = presentText(tag, "label");
14494
+ if (label !== undefined)
14495
+ spec.label = label;
14496
+ const description = presentText(tag, "description");
14497
+ if (description !== undefined)
14498
+ spec.description = description;
14499
+ const control = tagText(tag, "control");
14500
+ if (control === "select" || control === "multiselect") {
14501
+ spec.control = control;
14502
+ }
14503
+ const rangeMin = tagNumeric(tag, "range_min");
14504
+ if (rangeMin !== undefined)
14505
+ spec.rangeMin = rangeMin;
14506
+ const rangeMax = tagNumeric(tag, "range_max");
14507
+ if (rangeMax !== undefined)
14508
+ spec.rangeMax = rangeMax;
14509
+ const suggest = tag.tag("suggest");
14510
+ if (suggest) {
14511
+ const parsed = {};
14512
+ const query = presentText(suggest, "query");
14513
+ if (query !== undefined)
14514
+ parsed.query = query;
14515
+ const source = presentText(suggest, "source");
14516
+ if (source !== undefined)
14517
+ parsed.source = source;
14518
+ const dimension = presentText(suggest, "dimension");
14519
+ if (dimension !== undefined)
14520
+ parsed.dimension = dimension;
14521
+ const runnable = parsed.query !== undefined || parsed.source !== undefined && parsed.dimension !== undefined;
14522
+ if (runnable)
14523
+ spec.suggest = parsed;
14524
+ }
14525
+ return spec;
14526
+ }
14190
14527
  function malloyGivenToApi(given) {
14191
14528
  const type = given.type;
14192
14529
  const renderedType = type.type === "filter expression" ? `filter<${type.filterType}>` : type.type;
14530
+ const allNotes = given.annotations.forRoute(undefined);
14193
14531
  return {
14194
14532
  name: given.name,
14195
14533
  type: renderedType,
14196
- annotations: given.annotations.forRoute(undefined).filter((note) => !isReservedRoute(note.route)).map((note) => note.text),
14534
+ annotations: allNotes.filter((note) => !isReservedRoute(note.route)).map((note) => note.text),
14535
+ ...readGivenControlSpec(allNotes.map((note) => note.text)),
14197
14536
  default: given._internal?.defaultText
14198
14537
  };
14199
14538
  }
14200
14539
  var init_given = __esm(() => {
14201
14540
  init_annotations();
14541
+ init_motly();
14202
14542
  });
14203
14543
 
14204
14544
  // src/utils.ts