@shardworks/astrolabe-apparatus 0.1.239 → 0.1.240

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shardworks/astrolabe-apparatus",
3
- "version": "0.1.239",
3
+ "version": "0.1.240",
4
4
  "license": "ISC",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,17 +20,17 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "zod": "4.3.6",
23
- "@shardworks/tools-apparatus": "0.1.239",
24
- "@shardworks/stacks-apparatus": "0.1.239",
25
- "@shardworks/clerk-apparatus": "0.1.239",
26
- "@shardworks/spider-apparatus": "0.1.239",
27
- "@shardworks/loom-apparatus": "0.1.239",
28
- "@shardworks/fabricator-apparatus": "0.1.239",
29
- "@shardworks/animator-apparatus": "0.1.239"
23
+ "@shardworks/stacks-apparatus": "0.1.240",
24
+ "@shardworks/tools-apparatus": "0.1.240",
25
+ "@shardworks/clerk-apparatus": "0.1.240",
26
+ "@shardworks/spider-apparatus": "0.1.240",
27
+ "@shardworks/animator-apparatus": "0.1.240",
28
+ "@shardworks/loom-apparatus": "0.1.240",
29
+ "@shardworks/fabricator-apparatus": "0.1.240"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "25.5.0",
33
- "@shardworks/nexus-core": "0.1.239"
33
+ "@shardworks/nexus-core": "0.1.240"
34
34
  },
35
35
  "files": [
36
36
  "dist",
@@ -444,17 +444,17 @@
444
444
 
445
445
  rows += '<tr>' +
446
446
  '<td>' + esc(r.engineId) + '</td>' +
447
- '<td>' + inputTokens.toLocaleString() + '</td>' +
448
- '<td>' + outputTokens.toLocaleString() + '</td>' +
449
- '<td>$' + cost.toFixed(4) + '</td>' +
447
+ '<td>' + window.NexusFormat.formatTokenCount(inputTokens) + '</td>' +
448
+ '<td>' + window.NexusFormat.formatTokenCount(outputTokens) + '</td>' +
449
+ '<td>' + window.NexusFormat.formatCostUsd(cost) + '</td>' +
450
450
  '</tr>';
451
451
  }
452
452
 
453
453
  rows += '<tr class="cost-total">' +
454
454
  '<td><strong>Total</strong></td>' +
455
- '<td><strong>' + totalInput.toLocaleString() + '</strong></td>' +
456
- '<td><strong>' + totalOutput.toLocaleString() + '</strong></td>' +
457
- '<td><strong>$' + totalCost.toFixed(4) + '</strong></td>' +
455
+ '<td><strong>' + window.NexusFormat.formatTokenCount(totalInput) + '</strong></td>' +
456
+ '<td><strong>' + window.NexusFormat.formatTokenCount(totalOutput) + '</strong></td>' +
457
+ '<td><strong>' + window.NexusFormat.formatCostUsd(totalCost) + '</strong></td>' +
458
458
  '</tr>';
459
459
 
460
460
  el.innerHTML =
@@ -459,3 +459,78 @@ describe('astrolabe.js plan-detail writ cross-link URL', () => {
459
459
  );
460
460
  });
461
461
  });
462
+
463
+ // ── Cost table routes through shared formatter ───────────────────────
464
+
465
+ describe('astrolabe.js cost table delegates to window.NexusFormat', () => {
466
+ // The renderCostTable helper formerly rendered cost via
467
+ // `'$' + cost.toFixed(4)` and token counts via bare `.toLocaleString()`
468
+ // (no locale argument). This drifted from every other dashboard's
469
+ // two-decimal cost and US-locale token grouping. All cost/token
470
+ // rendering must now route through the shared window.NexusFormat
471
+ // namespace served by oculus.
472
+
473
+ it('contains no toFixed(4) drift (legacy precision)', () => {
474
+ assert.doesNotMatch(
475
+ astrolabeJs,
476
+ /toFixed\(4\)/,
477
+ 'astrolabe.js must not use toFixed(4) — shared formatter enforces $x.yy',
478
+ );
479
+ });
480
+
481
+ it('contains no bare .toLocaleString() calls on token counts', () => {
482
+ // formatDate uses toLocaleString() on a Date instance — that is fine.
483
+ // But no numeric .toLocaleString() call should remain, because every
484
+ // locale-formatted integer must route through the shared namespace
485
+ // which pins 'en-US' grouping.
486
+ var numericLocaleMatches =
487
+ astrolabeJs.match(/\b(?:input|output|cost|total)\w*\.toLocaleString\(/gi) || [];
488
+ assert.equal(
489
+ numericLocaleMatches.length,
490
+ 0,
491
+ 'numeric *.toLocaleString() calls must be replaced with window.NexusFormat.formatTokenCount',
492
+ );
493
+ });
494
+
495
+ it('renders per-row cost via window.NexusFormat.formatCostUsd', () => {
496
+ assert.match(
497
+ astrolabeJs,
498
+ /window\.NexusFormat\.formatCostUsd\(cost\)/,
499
+ 'per-row cost cell should render via the shared formatter',
500
+ );
501
+ });
502
+
503
+ it('renders total cost via window.NexusFormat.formatCostUsd', () => {
504
+ assert.match(
505
+ astrolabeJs,
506
+ /window\.NexusFormat\.formatCostUsd\(totalCost\)/,
507
+ 'total cost cell should render via the shared formatter',
508
+ );
509
+ });
510
+
511
+ it('renders per-row token counts via window.NexusFormat.formatTokenCount', () => {
512
+ assert.match(
513
+ astrolabeJs,
514
+ /window\.NexusFormat\.formatTokenCount\(inputTokens\)/,
515
+ 'per-row input token cell should render via the shared formatter',
516
+ );
517
+ assert.match(
518
+ astrolabeJs,
519
+ /window\.NexusFormat\.formatTokenCount\(outputTokens\)/,
520
+ 'per-row output token cell should render via the shared formatter',
521
+ );
522
+ });
523
+
524
+ it('renders total token counts via window.NexusFormat.formatTokenCount', () => {
525
+ assert.match(
526
+ astrolabeJs,
527
+ /window\.NexusFormat\.formatTokenCount\(totalInput\)/,
528
+ 'total input token cell should render via the shared formatter',
529
+ );
530
+ assert.match(
531
+ astrolabeJs,
532
+ /window\.NexusFormat\.formatTokenCount\(totalOutput\)/,
533
+ 'total output token cell should render via the shared formatter',
534
+ );
535
+ });
536
+ });