@malloy-publisher/server 0.0.172 → 0.0.173

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.
@@ -1327,8 +1327,10 @@ paths:
1327
1327
  operationId: compile-model-source
1328
1328
  summary: Compile Malloy source code
1329
1329
  description: |
1330
- Compiles Malloy source code in the context of a specific model's directory,
1331
- allowing relative imports to resolve correctly against sibling model files.
1330
+ Compiles Malloy source code in the context of a specific model file.
1331
+ The submitted source is appended to the full model content, giving it
1332
+ access to all sources, imports, and queries defined in the model.
1333
+ Relative imports resolve correctly against sibling model files.
1332
1334
  Returns compilation status and any problems (errors or warnings) found.
1333
1335
  parameters:
1334
1336
  - name: projectName
package/dist/server.js CHANGED
@@ -230419,8 +230419,11 @@ class Project {
230419
230419
  const virtualUri = `file://${path7.join(modelDir, "__compile_check.malloy")}`;
230420
230420
  const virtualUrl = new URL(virtualUri);
230421
230421
  const modelPath = path7.join(this.projectPath, packageName, modelName);
230422
- const preamble = await extractPreamble(modelPath);
230423
- const fullSource = preamble ? `${preamble}
230422
+ let modelContent = "";
230423
+ try {
230424
+ modelContent = await fs6.promises.readFile(modelPath, "utf8");
230425
+ } catch {}
230426
+ const fullSource = modelContent ? `${modelContent}
230424
230427
  ${source}` : source;
230425
230428
  const interceptingReader = {
230426
230429
  readURL: async (url2) => {
@@ -230699,28 +230702,6 @@ ${source}` : source;
230699
230702
  logger.info(`Removed DuckLake connection ${connectionName} from project ${this.projectName}`);
230700
230703
  }
230701
230704
  }
230702
- async function extractPreamble(modelPath) {
230703
- try {
230704
- const content = await fs6.promises.readFile(modelPath, "utf8");
230705
- return extractPreambleFromSource(content);
230706
- } catch {
230707
- return "";
230708
- }
230709
- }
230710
- function extractPreambleFromSource(content) {
230711
- const lines = content.split(`
230712
- `);
230713
- const preambleLines = [];
230714
- for (const line of lines) {
230715
- const trimmed2 = line.trim();
230716
- if (trimmed2.startsWith("source:") || trimmed2.startsWith("query:") || trimmed2.startsWith("run:")) {
230717
- break;
230718
- }
230719
- preambleLines.push(line);
230720
- }
230721
- return preambleLines.join(`
230722
- `).trimEnd();
230723
- }
230724
230705
 
230725
230706
  // src/service/project_store.ts
230726
230707
  var AZURE_SUPPORTED_SCHEMES2 = ["https://", "http://", "abfss://", "az://"];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@malloy-publisher/server",
3
3
  "description": "Malloy Publisher Server",
4
- "version": "0.0.172",
4
+ "version": "0.0.173",
5
5
  "main": "dist/server.js",
6
6
  "bin": {
7
7
  "malloy-publisher": "dist/server.js"
@@ -180,11 +180,17 @@ export class Project {
180
180
  const virtualUri = `file://${path.join(modelDir, "__compile_check.malloy")}`;
181
181
  const virtualUrl = new URL(virtualUri);
182
182
 
183
- // Read the model file and extract its preamble (pragmas + imports) so that
184
- // the user's query inherits the model's import context.
183
+ // Read the full model file so the submitted source inherits the model's
184
+ // complete namespace imports, source definitions, queries, etc.
185
185
  const modelPath = path.join(this.projectPath, packageName, modelName);
186
- const preamble = await extractPreamble(modelPath);
187
- const fullSource = preamble ? `${preamble}\n${source}` : source;
186
+ let modelContent = "";
187
+ try {
188
+ modelContent = await fs.promises.readFile(modelPath, "utf8");
189
+ } catch {
190
+ // If the model file can't be read, proceed with empty content
191
+ // and let compilation surface any errors naturally.
192
+ }
193
+ const fullSource = modelContent ? `${modelContent}\n${source}` : source;
188
194
 
189
195
  // Create a URL Reader that serves the source string for the virtual file,
190
196
  // but falls back to the disk for everything else (imports).