@malloydata/malloy 0.0.346 → 0.0.348

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.
@@ -342,6 +342,8 @@ export interface BuildPlan {
342
342
  graphs: BuildGraph[];
343
343
  /** Map from sourceId to PersistSource for accessing source details */
344
344
  sources: Record<string, PersistSource>;
345
+ /** Errors and warnings from parsing #@ annotations on persistable sources */
346
+ tagParseLog: LogMessage[];
345
347
  }
346
348
  /**
347
349
  * A wrapper around a source that has #@ persist annotation.
@@ -906,18 +906,19 @@ class Model {
906
906
  throw new Error('Model must have ##! experimental.persistence to use getBuildPlan()');
907
907
  }
908
908
  const allDeps = [];
909
+ const tagParseLog = [];
909
910
  // Walk all objects in the model to find persistent dependencies
910
911
  for (const obj of Object.values(this.modelDef.contents)) {
911
912
  if (obj.type === 'query' || (0, model_1.isSourceDef)(obj)) {
912
- allDeps.push(...(0, persist_utils_1.findPersistentDependencies)(obj, this.modelDef));
913
+ allDeps.push(...(0, persist_utils_1.findPersistentDependencies)(obj, this.modelDef, tagParseLog));
913
914
  }
914
915
  }
915
916
  // Also walk queryList (unnamed queries)
916
917
  for (const query of this.modelDef.queryList) {
917
- allDeps.push(...(0, persist_utils_1.findPersistentDependencies)(query, this.modelDef));
918
+ allDeps.push(...(0, persist_utils_1.findPersistentDependencies)(query, this.modelDef, tagParseLog));
918
919
  }
919
920
  if (allDeps.length === 0) {
920
- return { graphs: [], sources: {} };
921
+ return { graphs: [], sources: {}, tagParseLog };
921
922
  }
922
923
  // Find the minimal set of root graphs
923
924
  const rootNodes = (0, persist_utils_1.minimalBuildGraph)(allDeps);
@@ -952,7 +953,7 @@ class Model {
952
953
  for (const [connectionName, nodes] of graphsByConnection) {
953
954
  graphs.push({ connectionName, nodes: [nodes] });
954
955
  }
955
- return { graphs, sources: sourcesMap };
956
+ return { graphs, sources: sourcesMap, tagParseLog };
956
957
  }
957
958
  }
958
959
  exports.Model = Model;
@@ -578,17 +578,24 @@ class QueryMaterializer extends FluentState {
578
578
  };
579
579
  // Use manifest from options if provided, otherwise fall back to Runtime's manifest.
580
580
  // Pass an empty {} in options to explicitly suppress manifest substitution.
581
- const buildManifest = (_a = mergedOptions.buildManifest) !== null && _a !== void 0 ? _a : this.runtime.buildManifest;
581
+ const explicitManifest = mergedOptions.buildManifest !== undefined;
582
+ let buildManifest = (_a = mergedOptions.buildManifest) !== null && _a !== void 0 ? _a : this.runtime.buildManifest;
582
583
  // If we have a manifest, compute connectionDigests for manifest lookups
583
584
  // TODO: This is inefficient - we call getBuildPlan just to find connection names.
584
585
  // Consider adding a listConnections() method to LookupConnection, or caching this.
585
586
  let connectionDigests;
586
587
  if (buildManifest) {
587
- // Require experimental.persistence compiler flag to use buildManifest
588
588
  const modelTag = preparedQuery.model.tagParse({ prefix: /^##! / }).tag;
589
589
  if (!modelTag.has('experimental', 'persistence')) {
590
- throw new Error('Model must have ##! experimental.persistence to use buildManifest');
590
+ if (explicitManifest) {
591
+ // Explicitly passed manifest requires persistence support
592
+ throw new Error('Model must have ##! experimental.persistence to use buildManifest');
593
+ }
594
+ // Runtime-level manifest (e.g. from config): silently ignore
595
+ buildManifest = undefined;
591
596
  }
597
+ }
598
+ if (buildManifest) {
592
599
  const plan = preparedQuery.model.getBuildPlan();
593
600
  const connectionNames = new Set(Object.values(plan.sources).map(s => s.connectionName));
594
601
  connectionDigests = (0, model_1.mkSafeRecord)();
@@ -1,4 +1,5 @@
1
1
  import type { ModelDef, SourceDef, Query } from './malloy_types';
2
+ import type { LogMessage } from '../lang';
2
3
  import type { BuildNode } from '../api/foundation/types';
3
4
  /**
4
5
  * Find persistent dependencies for a source or query, returning a nested DAG.
@@ -30,7 +31,7 @@ import type { BuildNode } from '../api/foundation/types';
30
31
  * @param modelDef The model definition containing the source registry
31
32
  * @returns Array of BuildNode representing the persistent dependency DAG
32
33
  */
33
- export declare function findPersistentDependencies(root: SourceDef | Query, modelDef: ModelDef): BuildNode[];
34
+ export declare function findPersistentDependencies(root: SourceDef | Query, modelDef: ModelDef, tagParseLog?: LogMessage[]): BuildNode[];
34
35
  /**
35
36
  * Find the minimal set of root build graphs from a forest of BuildNodes.
36
37
  *
@@ -18,24 +18,33 @@ function resolveSource(modelDef, name) {
18
18
  }
19
19
  /**
20
20
  * Check if a source has the #@ persist annotation.
21
+ * Returns both the persist flag and any tag parse errors.
21
22
  */
22
23
  function checkPersistAnnotation(source) {
23
24
  if (!source.annotation)
24
- return false;
25
- const { tag } = (0, annotation_1.annotationToTag)(source.annotation, { prefix: /^#@ / });
26
- return tag.has('persist');
25
+ return { persist: false, log: [] };
26
+ const { tag, log } = (0, annotation_1.annotationToTag)(source.annotation, { prefix: /^#@ / });
27
+ return { persist: tag.has('persist'), log };
27
28
  }
28
29
  /**
29
30
  * Check if a sourceID is persistent, using lazy evaluation and caching.
30
31
  * Sets the persist flag on the registry entry as a side effect.
32
+ * Appends any tag parse errors to the provided log array.
31
33
  */
32
- function isPersistent(sourceID, modelDef) {
34
+ function isPersistent(sourceID, modelDef, tagParseLog) {
33
35
  const value = modelDef.sourceRegistry[sourceID];
34
36
  if (!value)
35
37
  return false;
36
38
  if (value.persist === undefined) {
37
39
  const sourceDef = (0, source_def_utils_1.resolveSourceID)(modelDef, sourceID);
38
- value.persist = sourceDef ? checkPersistAnnotation(sourceDef) : false;
40
+ if (sourceDef) {
41
+ const result = checkPersistAnnotation(sourceDef);
42
+ value.persist = result.persist;
43
+ tagParseLog.push(...result.log);
44
+ }
45
+ else {
46
+ value.persist = false;
47
+ }
39
48
  }
40
49
  return value.persist;
41
50
  }
@@ -69,7 +78,7 @@ function isPersistent(sourceID, modelDef) {
69
78
  * @param modelDef The model definition containing the source registry
70
79
  * @returns Array of BuildNode representing the persistent dependency DAG
71
80
  */
72
- function findPersistentDependencies(root, modelDef) {
81
+ function findPersistentDependencies(root, modelDef, tagParseLog = []) {
73
82
  const visited = new Set();
74
83
  function processSourceID(sourceID) {
75
84
  if (visited.has(sourceID)) {
@@ -81,7 +90,7 @@ function findPersistentDependencies(root, modelDef) {
81
90
  return [];
82
91
  }
83
92
  const childDeps = processSourceDef(sourceDef);
84
- const persistent = isPersistent(sourceID, modelDef);
93
+ const persistent = isPersistent(sourceID, modelDef, tagParseLog);
85
94
  if (persistent) {
86
95
  return [{ sourceID, dependsOn: childDeps }];
87
96
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.346";
1
+ export declare const MALLOY_VERSION = "0.0.348";
package/dist/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MALLOY_VERSION = void 0;
4
4
  // generated with 'generate-version-file' script; do not edit manually
5
- exports.MALLOY_VERSION = '0.0.346';
5
+ exports.MALLOY_VERSION = '0.0.348';
6
6
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.346",
3
+ "version": "0.0.348",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -45,9 +45,9 @@
45
45
  "generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
46
46
  },
47
47
  "dependencies": {
48
- "@malloydata/malloy-filter": "0.0.346",
49
- "@malloydata/malloy-interfaces": "0.0.346",
50
- "@malloydata/malloy-tag": "0.0.346",
48
+ "@malloydata/malloy-filter": "0.0.348",
49
+ "@malloydata/malloy-interfaces": "0.0.348",
50
+ "@malloydata/malloy-tag": "0.0.348",
51
51
  "@noble/hashes": "^1.8.0",
52
52
  "antlr4ts": "^0.5.0-alpha.4",
53
53
  "assert": "^2.0.0",