@camstack/server 1.2.195 → 1.2.196

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.
@@ -6292,6 +6292,15 @@ function createCapRouter_pipelineAnalytics(getProvider, createRemoteProxy) {
6292
6292
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
6293
6293
  return p.listTrackMedia(methodInput);
6294
6294
  }),
6295
+ listEventMedia: trpc_middleware_js_1.protectedProcedure
6296
+ .input(types_85.pipelineAnalyticsCapability.methods.listEventMedia.input.loose())
6297
+ .output(types_85.pipelineAnalyticsCapability.methods.listEventMedia.output)
6298
+ .query(async ({ input, ctx }) => {
6299
+ const { nodeId, ...methodInput } = input;
6300
+ const p = resolveProvider('pipeline-analytics', nodeId, () => getProvider(ctx), createRemoteProxy);
6301
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
6302
+ return p.listEventMedia(methodInput);
6303
+ }),
6295
6304
  searchObjectEvents: trpc_middleware_js_1.protectedProcedure
6296
6305
  .input(types_85.pipelineAnalyticsCapability.methods.searchObjectEvents.input.loose())
6297
6306
  .output(types_85.pipelineAnalyticsCapability.methods.searchObjectEvents.output)
@@ -940,8 +940,12 @@ class AddonPackageService {
940
940
  this.requireInstaller();
941
941
  const addonInstaller = this.installer;
942
942
  const previousVersion = this.getInstalledPackageVersion(name);
943
- // getInstalledPackageVersion returns '' when not installed
944
- const isFirstInstall = !previousVersion;
943
+ // `null` = no readable installed copy, which is exactly a first
944
+ // install. This used to test the truthiness of a lookup that answered
945
+ // `'0.0.0'` when it found nothing — always truthy — so a genuine first
946
+ // install took the update path and `applyUpdate` threw "not currently
947
+ // tracked in manifest".
948
+ const isFirstInstall = previousVersion === null;
945
949
  // First-time installs go through the original installFromNpm path;
946
950
  // applyUpdate explicitly refuses when the package isn't tracked yet.
947
951
  // Subsequent updates take the safe path: backup current install,
@@ -979,13 +983,16 @@ class AddonPackageService {
979
983
  const targetDir = path.join(addonsDir, dirName);
980
984
  const packageSpec = version ? `${name}@${version}` : name;
981
985
  await installPackageFromNpm(packageSpec, targetDir);
982
- updatedVersion = this.getInstalledPackageVersion(name);
986
+ // Core packages install FLAT (`<addonsDir>/<dirName>`), which the
987
+ // installer's lookup covers alongside the scoped form.
988
+ const installedVersion = this.getInstalledPackageVersion(name);
989
+ updatedVersion = installedVersion ?? '';
983
990
  // Invalidate cache after update
984
991
  this.cachedUpdates = null;
985
992
  this.logger.info('Core package updated -- restart required', {
986
- meta: { name, updatedVersion },
993
+ meta: { name, updatedVersion: installedVersion },
987
994
  });
988
- this.sendUpdateNotification(name, updatedVersion);
995
+ this.sendUpdateNotification(name, installedVersion);
989
996
  return { success: true, version: updatedVersion, requiresRestart: true };
990
997
  }
991
998
  catch (error) {
@@ -1749,38 +1756,40 @@ class AddonPackageService {
1749
1756
  // Private: general helpers
1750
1757
  // =========================================================================
1751
1758
  /**
1752
- * Read the currently installed version of a package.
1753
- * Checks data/addons/ first, then falls back to Node module resolution.
1754
- * Returns '0.0.0' if not found.
1759
+ * The version of `packageName` INSTALLED RIGHT NOW, or `null` when the hub
1760
+ * has no readable copy.
1761
+ *
1762
+ * Delegates to the installer, which is the one place that knows the on-disk
1763
+ * layout (`<addonsDir>/@camstack/<pkg>/`, with the pre-scope flat form as a
1764
+ * fallback). This method used to restate that path and got it wrong —
1765
+ * `packageName.replace(/^@camstack\//, '')` looked ONLY in the flat form, so
1766
+ * every scoped install missed. It then fell back to
1767
+ * `require.resolve('<pkg>/package.json')`, which cannot succeed either: an
1768
+ * addon is installed under the data directory, not in the hub's own
1769
+ * node_modules. Both misses landed on the literal `'0.0.0'`, and that string
1770
+ * was published on the `addon.updated` event as the version the operator had
1771
+ * been running ("@camstack/addon-terminal 0.0.0 → latest", 2026-08-30).
1772
+ *
1773
+ * `null`, not `'0.0.0'`: a version nobody installed is indistinguishable
1774
+ * from one that was, and the caller must be forced to decide what to say
1775
+ * about "unknown" rather than inherit a number that looks like an answer.
1755
1776
  */
1756
1777
  getInstalledPackageVersion(packageName) {
1757
1778
  try {
1758
- const addonsDir = this.resolveAddonsDir();
1759
- const dirName = packageName.replace(/^@camstack\//, '');
1760
- const pkgJsonPath = path.join(addonsDir, dirName, 'package.json');
1761
- if (fs.existsSync(pkgJsonPath)) {
1762
- const pkgJson = readJsonObject(pkgJsonPath);
1763
- const v = asString(pkgJson?.['version']);
1764
- if (v)
1765
- return v;
1766
- }
1779
+ const installed = this.installer?.getInstalledPackage(packageName) ?? null;
1780
+ const version = installed === null ? '' : asString(installed.version);
1781
+ if (version)
1782
+ return version;
1767
1783
  }
1768
1784
  catch (err) {
1769
- this.logger.debug('Version lookup via fs failed, trying require.resolve', {
1785
+ this.logger.debug('Installed-version lookup failed', {
1770
1786
  meta: { packageName, error: (0, types_1.errMsg)(err) },
1771
1787
  });
1772
1788
  }
1773
- try {
1774
- const pkgJsonPath = require.resolve(`${packageName}/package.json`);
1775
- const pkgJson = readJsonObject(pkgJsonPath);
1776
- return asString(pkgJson?.['version'], '0.0.0');
1777
- }
1778
- catch (err) {
1779
- this.logger.debug('Could not resolve version, returning 0.0.0', {
1780
- meta: { packageName, error: (0, types_1.errMsg)(err) },
1781
- });
1782
- return '0.0.0';
1783
- }
1789
+ this.logger.debug('No readable installed copy — previous version is unknown', {
1790
+ meta: { packageName },
1791
+ });
1792
+ return null;
1784
1793
  }
1785
1794
  /** Only allow @camstack/* scoped packages */
1786
1795
  isAllowedPackage(name) {
@@ -1838,12 +1847,19 @@ class AddonPackageService {
1838
1847
  throw new Error('AddonInstaller is not available -- @camstack/system may not be installed');
1839
1848
  }
1840
1849
  }
1841
- /** Send notification and toast for a successful package update */
1850
+ /**
1851
+ * Send notification and toast for a successful package update.
1852
+ *
1853
+ * `version === null` means the hub could not read back what it just
1854
+ * installed. The sentence then says the package was updated and stops —
1855
+ * never "updated to v0.0.0", which reads as a real version.
1856
+ */
1842
1857
  sendUpdateNotification(name, version) {
1858
+ const sentence = version === null ? `${name} updated` : `${name} updated to v${version}`;
1843
1859
  this.notificationService
1844
1860
  .notify({
1845
1861
  title: 'Package Updated',
1846
- body: `${name} updated to v${version}`,
1862
+ body: sentence,
1847
1863
  format: 'text',
1848
1864
  priority: 3,
1849
1865
  category: 'system',
@@ -1855,7 +1871,7 @@ class AddonPackageService {
1855
1871
  });
1856
1872
  this.toastService.broadcast({
1857
1873
  title: 'Package Updated',
1858
- message: `${name} updated to v${version}`,
1874
+ message: sentence,
1859
1875
  severity: 'info',
1860
1876
  duration: 5000,
1861
1877
  });
@@ -36,6 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.AddonRegistryService = void 0;
38
38
  exports.shouldEvictMissingOnDisk = shouldEvictMissingOnDisk;
39
+ exports.addonUpdatePayload = addonUpdatePayload;
39
40
  exports.shouldEmitProviderRegisteredReady = shouldEmitProviderRegisteredReady;
40
41
  const node_crypto_1 = require("node:crypto");
41
42
  const fs = __importStar(require("node:fs"));
@@ -69,6 +70,28 @@ const runner_spawn_fanout_js_1 = require("./runner-spawn-fanout.js");
69
70
  function shouldEvictMissingOnDisk(entry, id, onDiskIds) {
70
71
  return (entry.source === 'installed' && entry.packageName !== '@camstack/system' && !onDiskIds.has(id));
71
72
  }
73
+ /**
74
+ * The versions an `addon.updated` event states.
75
+ *
76
+ * `fromVersion === null` means the hub could not read what was installed
77
+ * before — a first install, or a tree with no readable `package.json` — and
78
+ * the key is then ABSENT, not present-and-empty. It used to arrive as the
79
+ * literal `'0.0.0'`, which the notification centre printed verbatim: the
80
+ * operator read "@camstack/addon-terminal 0.0.0 → latest" on his phone and
81
+ * had no way to tell that neither number was real (2026-08-30). An absent key
82
+ * the renderer leaves out is the honest form of "unknown"; a version-shaped
83
+ * placeholder is a claim.
84
+ *
85
+ * `toVersion` is never optional — it is what separates a package update from a
86
+ * settings save, which emits the same category carrying no versions at all
87
+ * (`parseAddonUpdateComplete`).
88
+ */
89
+ function addonUpdatePayload(fromVersion, toVersion) {
90
+ return {
91
+ ...(fromVersion !== null ? { fromVersion } : {}),
92
+ toVersion,
93
+ };
94
+ }
72
95
  /**
73
96
  * Type predicate: true when an `ISettingsBackend` also satisfies the
74
97
  * sync `ISettingsStore` contract (system/addon/device key-value ops)
@@ -1511,14 +1534,17 @@ class AddonRegistryService {
1511
1534
  this.healthMonitor.forget(packageName);
1512
1535
  this.addonLoader.clearLoadFailures(packageName);
1513
1536
  }
1514
- /** Emit addon.updated lifecycle event for all addons belonging to a package */
1537
+ /**
1538
+ * Emit `addon.updated` for every addon belonging to a package.
1539
+ *
1540
+ * The payload shape is {@link addonUpdatePayload} — an unknown predecessor
1541
+ * is an ABSENT key, never a placeholder.
1542
+ */
1515
1543
  emitUpdateEvent(packageName, fromVersion, toVersion) {
1544
+ const payload = addonUpdatePayload(fromVersion, toVersion);
1516
1545
  for (const [id, entry] of this.addonEntries) {
1517
1546
  if (entry.packageName === packageName) {
1518
- this.emitAddonLifecycleEvent('addon.updated', id, {
1519
- fromVersion,
1520
- toVersion,
1521
- });
1547
+ this.emitAddonLifecycleEvent('addon.updated', id, payload);
1522
1548
  }
1523
1549
  }
1524
1550
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.195",
3
+ "version": "1.2.196",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",