@altopelago/sansa 0.11.0 → 0.11.1

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/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ versions may still include breaking changes when the SANSA specifications move.
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.11.1 - 2026-09-14
11
+
12
+ ### Fixed
13
+
14
+ - Fixed optional AEON Core and AES runtime discovery when the packages are
15
+ installed by the calling project with import-only package exports. This
16
+ restores published-package AEON, Telex, and Film query input without
17
+ requiring an explicit module-path environment override.
18
+
10
19
  ## 0.11.0 - 2026-09-14
11
20
 
12
21
  ### Added
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "implementation": "@altopelago/sansa",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "profiles": [
5
5
  "value-semantics-minimum-consumer",
6
6
  "aeon.value.default.v1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altopelago/sansa",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Semantic Address NameSpace Abstraction parser, resolver, and query toolkit.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
- import { existsSync } from 'node:fs';
1
+ import { existsSync, readFileSync } from 'node:fs';
2
2
  import { createRequire } from 'node:module';
3
- import { resolve as resolvePath } from 'node:path';
3
+ import { dirname, isAbsolute, relative, resolve as resolvePath, sep } from 'node:path';
4
4
  import { fileURLToPath, pathToFileURL } from 'node:url';
5
5
  import { evaluateQuery, parseAddress, parseQuery } from '../../src/index.js';
6
6
 
@@ -509,13 +509,12 @@ function aeonCoreCandidates() {
509
509
  });
510
510
  }
511
511
 
512
- try {
512
+ const installed = resolvePackageImportFromCwd('@altopelago/aeon-core');
513
+ if (installed) {
513
514
  candidates.push({
514
515
  label: '@altopelago/aeon-core',
515
- href: pathToFileURL(requireFromCwd.resolve('@altopelago/aeon-core')).href,
516
+ href: installed,
516
517
  });
517
- } catch {
518
- // Optional integration. JSON fixtures and pure Query parsing do not need AEON Core.
519
518
  }
520
519
 
521
520
  const devPath = fileURLToPath(devAeonCoreUrl);
@@ -538,13 +537,12 @@ function aeonAesCandidates() {
538
537
  });
539
538
  }
540
539
 
541
- try {
540
+ const installed = resolvePackageImportFromCwd('@altopelago/aeon-aes');
541
+ if (installed) {
542
542
  candidates.push({
543
543
  label: '@altopelago/aeon-aes',
544
- href: pathToFileURL(requireFromCwd.resolve('@altopelago/aeon-aes')).href,
544
+ href: installed,
545
545
  });
546
- } catch {
547
- // Optional integration. AEON and JSON sources do not need the AES codec.
548
546
  }
549
547
 
550
548
  const devPath = fileURLToPath(devAeonAesUrl);
@@ -558,6 +556,77 @@ function aeonAesCandidates() {
558
556
  return candidates;
559
557
  }
560
558
 
559
+ function resolvePackageImportFromCwd(packageName) {
560
+ try {
561
+ return pathToFileURL(requireFromCwd.resolve(packageName)).href;
562
+ } catch {
563
+ // Import-only packages have no `require` export. Resolve their ESM entry
564
+ // from the calling project's node_modules tree instead.
565
+ }
566
+
567
+ const packageParts = packageName.split('/');
568
+ let directory = resolvePath(process.cwd());
569
+ while (true) {
570
+ const packageRoot = resolvePath(directory, 'node_modules', ...packageParts);
571
+ const manifestPath = resolvePath(packageRoot, 'package.json');
572
+ if (existsSync(manifestPath)) {
573
+ try {
574
+ const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
575
+ const target = packageImportTarget(manifest);
576
+ if (typeof target !== 'string' || !target.startsWith('./')) return undefined;
577
+ const entryPath = resolvePath(packageRoot, target);
578
+ const relativeEntry = relative(packageRoot, entryPath);
579
+ if (!relativeEntry
580
+ || relativeEntry === '..'
581
+ || relativeEntry.startsWith(`..${sep}`)
582
+ || isAbsolute(relativeEntry)
583
+ || !existsSync(entryPath)) {
584
+ return undefined;
585
+ }
586
+ return pathToFileURL(entryPath).href;
587
+ } catch {
588
+ return undefined;
589
+ }
590
+ }
591
+
592
+ const parent = dirname(directory);
593
+ if (parent === directory) return undefined;
594
+ directory = parent;
595
+ }
596
+ }
597
+
598
+ function packageImportTarget(manifest) {
599
+ if (Object.hasOwn(manifest ?? {}, 'exports')) {
600
+ let target = manifest.exports;
601
+ if (target && typeof target === 'object' && !Array.isArray(target)) {
602
+ const keys = Object.keys(target);
603
+ if (keys.some((key) => key.startsWith('.'))) target = target['.'];
604
+ }
605
+ return conditionalImportTarget(target);
606
+ }
607
+ if (typeof manifest?.module === 'string') return manifest.module;
608
+ if (typeof manifest?.main === 'string') return manifest.main;
609
+ return undefined;
610
+ }
611
+
612
+ function conditionalImportTarget(target) {
613
+ if (typeof target === 'string') return target;
614
+ if (Array.isArray(target)) {
615
+ for (const candidate of target) {
616
+ const resolved = conditionalImportTarget(candidate);
617
+ if (resolved) return resolved;
618
+ }
619
+ return undefined;
620
+ }
621
+ if (!target || typeof target !== 'object') return undefined;
622
+ for (const [condition, candidate] of Object.entries(target)) {
623
+ if (!['node', 'import', 'default'].includes(condition)) continue;
624
+ const resolved = conditionalImportTarget(candidate);
625
+ if (resolved) return resolved;
626
+ }
627
+ return undefined;
628
+ }
629
+
561
630
  function moduleHref(specifier) {
562
631
  if (specifier.startsWith('file:')) return specifier;
563
632
  if (specifier.startsWith('.') || specifier.startsWith('/')) {