@malloydata/db-duckdb 0.0.407 → 0.0.408

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.
@@ -128,7 +128,7 @@ function normalizeDuckDBConfig(config) {
128
128
  mustExist: securityPolicy === 'sandboxed',
129
129
  });
130
130
  }
131
- const databasePath = canonicalizeDatabasePath(rawDatabasePath);
131
+ const databasePath = canonicalizeDatabasePath(rawDatabasePath, workingDirectory);
132
132
  const isMotherDuck = isMotherDuckPath(databasePath);
133
133
  if (restricted && !isAllowedClosedNetworkDatabasePath(databasePath)) {
134
134
  throw new DuckDBConfigValidationError(`databasePath "${rawDatabasePath}" is not allowed when securityPolicy is "${securityPolicy}"`);
@@ -343,11 +343,19 @@ function deriveRestrictedSecretDirectory({ requiresSecretNeutralization, tempDir
343
343
  }
344
344
  throw new DuckDBConfigValidationError('restricted DuckDB policies require workingDirectory or tempDirectory so Malloy can isolate persistent DuckDB secrets');
345
345
  }
346
- function canonicalizeDatabasePath(databasePath) {
346
+ // A relative `databasePath` resolves against `workingDirectory` (which itself
347
+ // defaults to the project root via `{config: 'rootDirectory'}`), keeping a
348
+ // config file portable — `databasePath: "analytics.duckdb"` names the database
349
+ // alongside the project regardless of where the host process is launched.
350
+ // `:memory:` and remote schemes are taken as-is; absolute paths ignore the
351
+ // base; with no `workingDirectory` set, a relative path falls back to the cwd.
352
+ function canonicalizeDatabasePath(databasePath, workingDirectory) {
347
353
  if (databasePath === ':memory:' || isLikelyRemoteDatabasePath(databasePath)) {
348
354
  return databasePath;
349
355
  }
350
- return canonicalizeConfigPath(databasePath, 'databasePath');
356
+ return canonicalizeConfigPath(databasePath, 'databasePath', {
357
+ baseDirectory: workingDirectory,
358
+ });
351
359
  }
352
360
  // A config path can arrive as a `file://` URL rather than a plain path —
353
361
  // notably `workingDirectory`, which defaults to `config.rootDirectory` (the
@@ -1,7 +1,8 @@
1
1
  export interface CanonicalPathOptions {
2
2
  mustExist?: boolean;
3
+ baseDirectory?: string;
3
4
  }
4
5
  export declare function isPosixHost(): boolean;
5
- export declare function canonicalizePath(input: string, { mustExist }?: CanonicalPathOptions): string;
6
+ export declare function canonicalizePath(input: string, { mustExist, baseDirectory }?: CanonicalPathOptions): string;
6
7
  export declare function canonicalizePathList(paths: string[]): string[];
7
8
  export declare function isContainedPath(parent: string, child: string): boolean;
@@ -16,11 +16,13 @@ const path_1 = __importDefault(require("path"));
16
16
  function isPosixHost() {
17
17
  return path_1.default.sep === '/';
18
18
  }
19
- function canonicalizePath(input, { mustExist = false } = {}) {
19
+ function canonicalizePath(input, { mustExist = false, baseDirectory } = {}) {
20
20
  if (input.trim() === '') {
21
21
  throw new Error('path must not be empty');
22
22
  }
23
- const resolved = path_1.default.resolve(input);
23
+ const resolved = baseDirectory !== undefined
24
+ ? path_1.default.resolve(baseDirectory, input)
25
+ : path_1.default.resolve(input);
24
26
  const canonical = (() => {
25
27
  try {
26
28
  return fs_1.default.realpathSync.native(resolved);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-duckdb",
3
- "version": "0.0.407",
3
+ "version": "0.0.408",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -61,7 +61,7 @@
61
61
  "dependencies": {
62
62
  "@duckdb/duckdb-wasm": "1.33.1-dev45.0",
63
63
  "@duckdb/node-api": "1.5.3-r.2",
64
- "@malloydata/malloy": "0.0.407",
64
+ "@malloydata/malloy": "0.0.408",
65
65
  "@motherduck/wasm-client": "^0.6.6",
66
66
  "apache-arrow": "^17.0.0",
67
67
  "web-worker": "^1.5.0"