@carlonicora/nextjs-jsonapi 4.2.0 → 4.2.2

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.
Files changed (87) hide show
  1. package/dist/{BlockNoteEditor-HXAHDJA7.mjs → BlockNoteEditor-FROUKBVK.mjs} +2 -2
  2. package/dist/{BlockNoteEditor-LLCZDFLZ.js → BlockNoteEditor-SWO3X5CC.js} +9 -9
  3. package/dist/{BlockNoteEditor-LLCZDFLZ.js.map → BlockNoteEditor-SWO3X5CC.js.map} +1 -1
  4. package/dist/billing/index.js +371 -371
  5. package/dist/billing/index.mjs +1 -1
  6. package/dist/{chunk-2VXDZRYY.mjs → chunk-AICMLKWN.mjs} +21 -8
  7. package/dist/chunk-AICMLKWN.mjs.map +1 -0
  8. package/dist/{chunk-VDVIUDY5.js → chunk-GYW7LLBQ.js} +369 -356
  9. package/dist/chunk-GYW7LLBQ.js.map +1 -0
  10. package/dist/client/index.js +2 -2
  11. package/dist/client/index.mjs +1 -1
  12. package/dist/components/index.js +2 -2
  13. package/dist/components/index.mjs +1 -1
  14. package/dist/contexts/index.js +2 -2
  15. package/dist/contexts/index.mjs +1 -1
  16. package/dist/features/analytics/index.js +88 -88
  17. package/dist/features/analytics/index.mjs +1 -1
  18. package/dist/features/help/index.js +31 -31
  19. package/dist/features/help/index.mjs +1 -1
  20. package/dist/features/tokenusage/index.js +75 -75
  21. package/dist/features/tokenusage/index.mjs +1 -1
  22. package/package.json +1 -1
  23. package/src/components/tables/__tests__/ContentListTable.spec.tsx +1 -1
  24. package/src/hooks/__tests__/{useDataListRetriever.test.ts → useDataListRetriever.spec.ts} +57 -0
  25. package/src/hooks/useDataListRetriever.ts +38 -9
  26. package/src/shadcnui/ui/__tests__/{confirm-dialog.test.tsx → confirm-dialog.spec.tsx} +1 -1
  27. package/src/shadcnui/ui/__tests__/{cursor-controls.test.tsx → cursor-controls.spec.tsx} +1 -1
  28. package/src/shadcnui/ui/__tests__/{cursor-menu-items.test.tsx → cursor-menu-items.spec.tsx} +1 -1
  29. package/src/shadcnui/ui/__tests__/{empty-state.test.tsx → empty-state.spec.tsx} +1 -1
  30. package/src/shadcnui/ui/__tests__/{spinner.test.tsx → spinner.spec.tsx} +1 -1
  31. package/dist/chunk-2VXDZRYY.mjs.map +0 -1
  32. package/dist/chunk-VDVIUDY5.js.map +0 -1
  33. /package/dist/{BlockNoteEditor-HXAHDJA7.mjs.map → BlockNoteEditor-FROUKBVK.mjs.map} +0 -0
  34. /package/scripts/{check-rtl-classes.test.ts → check-rtl-classes.spec.ts} +0 -0
  35. /package/src/client/__tests__/{JsonApiClient.test.ts → JsonApiClient.spec.ts} +0 -0
  36. /package/src/client/__tests__/{request.test.ts → request.spec.ts} +0 -0
  37. /package/src/client/hooks/__tests__/{useJsonApiGet.test.tsx → useJsonApiGet.spec.tsx} +0 -0
  38. /package/src/client/hooks/__tests__/{useJsonApiMutation.test.tsx → useJsonApiMutation.spec.tsx} +0 -0
  39. /package/src/client/hooks/__tests__/{useRehydration.test.ts → useRehydration.spec.ts} +0 -0
  40. /package/src/components/editors/__tests__/{BlockNoteEditorAiActions.test.ts → BlockNoteEditorAiActions.spec.ts} +0 -0
  41. /package/src/components/editors/__tests__/{BlockNoteEditorMentionInlineContent.test.ts → BlockNoteEditorMentionInlineContent.spec.ts} +0 -0
  42. /package/src/components/forms/__tests__/{CommonEditorDiscardDialog.test.tsx → CommonEditorDiscardDialog.spec.tsx} +0 -0
  43. /package/src/components/forms/__tests__/{EditorSheet.test.tsx → EditorSheet.spec.tsx} +0 -0
  44. /package/src/components/forms/__tests__/{FormCheckbox.test.tsx → FormCheckbox.spec.tsx} +0 -0
  45. /package/src/components/forms/__tests__/{FormDate.test.tsx → FormDate.spec.tsx} +0 -0
  46. /package/src/components/forms/__tests__/{FormInput.test.tsx → FormInput.spec.tsx} +0 -0
  47. /package/src/components/forms/__tests__/{FormSelect.test.tsx → FormSelect.spec.tsx} +0 -0
  48. /package/src/components/forms/__tests__/{useEditorDialog.test.ts → useEditorDialog.spec.ts} +0 -0
  49. /package/src/components/grids/__tests__/{ContentListGrid.test.tsx → ContentListGrid.spec.tsx} +0 -0
  50. /package/src/components/tables/__tests__/{ContentListTable.test.tsx → ContentListTable.rendering.spec.tsx} +0 -0
  51. /package/src/contexts/__tests__/{DirectionContext.test.tsx → DirectionContext.spec.tsx} +0 -0
  52. /package/src/contexts/__tests__/{SessionContext.test.tsx → SessionContext.spec.tsx} +0 -0
  53. /package/src/contexts/__tests__/{SocketContext.session.test.tsx → SocketContext.session.spec.tsx} +0 -0
  54. /package/src/core/abstracts/__tests__/{AbstractService.locale.test.ts → AbstractService.locale.spec.ts} +0 -0
  55. /package/src/core/endpoint/__tests__/{EndpointCreator.test.ts → EndpointCreator.spec.ts} +0 -0
  56. /package/src/core/factories/__tests__/{JsonApiDataFactory.test.ts → JsonApiDataFactory.spec.ts} +0 -0
  57. /package/src/core/factories/__tests__/{RehydrationFactory.test.ts → RehydrationFactory.spec.ts} +0 -0
  58. /package/src/core/registry/__tests__/{DataClassRegistry.test.ts → DataClassRegistry.spec.ts} +0 -0
  59. /package/src/core/registry/__tests__/{ModuleRegistrar.test.ts → ModuleRegistrar.spec.ts} +0 -0
  60. /package/src/core/registry/__tests__/{viewportStore.test.ts → viewportStore.spec.ts} +0 -0
  61. /package/src/core/utils/__tests__/{translateResponse.test.ts → translateResponse.spec.ts} +0 -0
  62. /package/src/features/ai-connection/data/__tests__/{ai-connection.test.ts → ai-connection.spec.ts} +0 -0
  63. /package/src/features/company/data/{company.test.ts → company.spec.ts} +0 -0
  64. /package/src/features/company/hooks/{useSubscriptionStatus.test.ts → useSubscriptionStatus.spec.ts} +0 -0
  65. /package/src/features/user/data/__tests__/{user.test.ts → user.spec.ts} +0 -0
  66. /package/src/hooks/__tests__/{useDebounce.test.ts → useDebounce.spec.ts} +0 -0
  67. /package/src/hooks/__tests__/{useSocket.render.test.ts → useSocket.render.spec.ts} +0 -0
  68. /package/src/i18n/__tests__/{config.test.ts → config.spec.ts} +0 -0
  69. /package/src/lib/__tests__/{direction.test.ts → direction.spec.ts} +0 -0
  70. /package/src/next-config/__tests__/{createNextConfig.test.ts → createNextConfig.spec.ts} +0 -0
  71. /package/src/server/__tests__/{JsonApiServer.test.ts → JsonApiServer.spec.ts} +0 -0
  72. /package/src/server/__tests__/{ServerSession.read.test.ts → ServerSession.read.spec.ts} +0 -0
  73. /package/src/server/__tests__/{cache.test.ts → cache.spec.ts} +0 -0
  74. /package/src/server/__tests__/{cachedGet.test.ts → cachedGet.spec.ts} +0 -0
  75. /package/src/server/__tests__/{request.test.ts → request.spec.ts} +0 -0
  76. /package/src/shadcnui/ui/__tests__/{sidebar.menu-skeleton.test.tsx → sidebar.menu-skeleton.spec.tsx} +0 -0
  77. /package/src/shadcnui/ui/__tests__/{sidebar.session.test.tsx → sidebar.session.spec.tsx} +0 -0
  78. /package/src/shadcnui/ui/__tests__/{use-ui-text.test.tsx → use-ui-text.spec.tsx} +0 -0
  79. /package/src/unified/__tests__/{JsonApiGet.cache.test.ts → JsonApiGet.cache.spec.ts} +0 -0
  80. /package/src/unified/__tests__/{JsonApiRequest.test.ts → JsonApiRequest.spec.ts} +0 -0
  81. /package/src/utils/__tests__/{date-formatter.test.ts → date-formatter.spec.ts} +0 -0
  82. /package/src/utils/__tests__/{exists.test.ts → exists.spec.ts} +0 -0
  83. /package/src/utils/__tests__/{italian-validators.test.ts → italian-validators.spec.ts} +0 -0
  84. /package/src/utils/__tests__/{map-thenable.test.ts → map-thenable.spec.ts} +0 -0
  85. /package/src/utils/__tests__/{use-mobile.test.tsx → use-mobile.spec.tsx} +0 -0
  86. /package/src/utils/{cn.test.ts → cn.spec.ts} +0 -0
  87. /package/src/utils/{isRemoteImageSrc.test.ts → isRemoteImageSrc.spec.ts} +0 -0
@@ -37,7 +37,7 @@ var _chunkKJMMBUOAjs = require('../../chunk-KJMMBUOA.js');
37
37
 
38
38
 
39
39
 
40
- var _chunkVDVIUDY5js = require('../../chunk-VDVIUDY5.js');
40
+ var _chunkGYW7LLBQjs = require('../../chunk-GYW7LLBQ.js');
41
41
  require('../../chunk-GPXYQMOZ.js');
42
42
  require('../../chunk-G4JR3SFV.js');
43
43
 
@@ -82,7 +82,7 @@ function TokenUsageAdminFilterBar({ granularity, companyId, metric, companies, o
82
82
  };
83
83
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap items-center gap-2", children: [
84
84
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "max-md:w-full max-md:[&_#date]:w-full", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
85
- _chunkVDVIUDY5js.DateRangeSelector,
85
+ _chunkGYW7LLBQjs.DateRangeSelector,
86
86
  {
87
87
  onDateChange: (range) => {
88
88
  if (!_optionalChain([range, 'optionalAccess', _ => _.from]) || !_optionalChain([range, 'optionalAccess', _2 => _2.to])) return;
@@ -117,16 +117,16 @@ function TokenUsageAdminFilterBar({ granularity, companyId, metric, companies, o
117
117
  }
118
118
  ),
119
119
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
120
- _chunkVDVIUDY5js.Select,
120
+ _chunkGYW7LLBQjs.Select,
121
121
  {
122
122
  items: companyItems,
123
123
  value: _nullishCoalesce(companyId, () => ( ALL_COMPANIES)),
124
124
  onValueChange: (value) => onChange({ companyId: !value || value === ALL_COMPANIES ? void 0 : value }),
125
125
  children: [
126
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.SelectTrigger, { className: "w-56", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.SelectValue, { placeholder: t("token_usage.admin.all_companies") }) }),
127
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.SelectContent, { children: [
128
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.SelectItem, { value: ALL_COMPANIES, children: t("token_usage.admin.all_companies") }),
129
- companies.map((company) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.SelectItem, { value: company.id, children: company.label }, company.id))
126
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.SelectTrigger, { className: "w-56", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.SelectValue, { placeholder: t("token_usage.admin.all_companies") }) }),
127
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.SelectContent, { children: [
128
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.SelectItem, { value: ALL_COMPANIES, children: t("token_usage.admin.all_companies") }),
129
+ companies.map((company) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.SelectItem, { value: company.id, children: company.label }, company.id))
130
130
  ] })
131
131
  ]
132
132
  }
@@ -149,7 +149,7 @@ function Segmented({
149
149
  children: options.map((option) => {
150
150
  const selected = option.value === value;
151
151
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
152
- _chunkVDVIUDY5js.Button,
152
+ _chunkGYW7LLBQjs.Button,
153
153
  {
154
154
  type: "button",
155
155
  size: "sm",
@@ -231,7 +231,7 @@ var TokenUsageAdminProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
231
231
  pageUrl = TOKEN_USAGE_ADMIN_PAGE_URL
232
232
  }) => {
233
233
  const t = _nextintl.useTranslations.call(void 0, );
234
- const generateUrl = _chunkVDVIUDY5js.usePageUrlGenerator.call(void 0, );
234
+ const generateUrl = _chunkGYW7LLBQjs.usePageUrlGenerator.call(void 0, );
235
235
  const [filters, setFilterState] = _react.useState.call(void 0, () => {
236
236
  const range = defaultRange();
237
237
  return {
@@ -349,7 +349,7 @@ var TokenUsageAdminProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
349
349
  error
350
350
  ]
351
351
  );
352
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminContext.Provider, { value: contextValue, children }) });
352
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminContext.Provider, { value: contextValue, children }) });
353
353
  }, "TokenUsageAdminProvider");
354
354
  var useTokenUsageAdmin = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
355
355
  const ctx = _react.useContext.call(void 0, TokenUsageAdminContext);
@@ -446,7 +446,7 @@ function LeadTile({
446
446
  previousLabel,
447
447
  decimal
448
448
  }) {
449
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.Card, { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.CardContent, { className: "grid gap-1", children: [
449
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.Card, { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.CardContent, { className: "grid gap-1", children: [
450
450
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: label }),
451
451
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-primary text-xl font-semibold tabular-nums", children: value }),
452
452
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-1", children: [
@@ -463,7 +463,7 @@ function SupportingTile({
463
463
  delta,
464
464
  decimal
465
465
  }) {
466
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.Card, { "data-testid": testId, size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.CardContent, { className: "grid gap-1", children: [
466
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.Card, { "data-testid": testId, size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.CardContent, { className: "grid gap-1", children: [
467
467
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: label }),
468
468
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-2", children: [
469
469
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: value }),
@@ -560,8 +560,8 @@ function TokenUsageBreakdownTable({ rows, metric }) {
560
560
  // The package's <Table> wraps itself in an `overflow-x-clip` container, which
561
561
  // would swallow the overflow before this scroller ever saw it — hence the
562
562
  // child override. Wide metric tables must scroll, never widen the page.
563
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-x-auto [&_[data-slot=table-container]]:overflow-x-visible", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.Table, { children: [
564
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableRow, { children: columns.map((column) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableHead, { className: _chunk4ORLPEK7js.cn.call(void 0, column.numeric && "text-end"), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
563
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-x-auto [&_[data-slot=table-container]]:overflow-x-visible", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.Table, { children: [
564
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableRow, { children: columns.map((column) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableHead, { className: _chunk4ORLPEK7js.cn.call(void 0, column.numeric && "text-end"), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
565
565
  "button",
566
566
  {
567
567
  type: "button",
@@ -576,20 +576,20 @@ function TokenUsageBreakdownTable({ rows, metric }) {
576
576
  ]
577
577
  }
578
578
  ) }, column.key)) }) }),
579
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableBody, { children: sortedRows.map((row) => {
579
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableBody, { children: sortedRows.map((row) => {
580
580
  const value = _chunkKJMMBUOAjs.metricValue.call(void 0, row, metric);
581
581
  const share = total > 0 ? value / total * 100 : 0;
582
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.TableRow, { "data-testid": `breakdown-row-${row.id}`, children: [
583
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableCell, { className: "text-xs", children: row.id === "other" ? t("token_usage.admin.other") : row.label }),
584
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableCell, { className: "text-muted-foreground text-xs", children: _nullishCoalesce(row.sublabel, () => ( "")) }),
585
- showActiveUsers && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableCell, { className: "text-end text-xs tabular-nums", children: row.activeUsers === void 0 ? "" : decimal(row.activeUsers, 0) }),
586
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.calls, 0) }),
587
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensIn, 0) }),
588
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensOut, 0) }),
589
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableCell, { className: "text-end text-xs tabular-nums", children: percent(_chunkKJMMBUOAjs.cacheHitPercentage.call(void 0, row.cached, row.tokensIn)) }),
590
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.cost, "cost") }),
591
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.credits, "credits") }),
592
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.TableCell, { className: "text-end text-xs tabular-nums", children: percent(share) })
582
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.TableRow, { "data-testid": `breakdown-row-${row.id}`, children: [
583
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableCell, { className: "text-xs", children: row.id === "other" ? t("token_usage.admin.other") : row.label }),
584
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableCell, { className: "text-muted-foreground text-xs", children: _nullishCoalesce(row.sublabel, () => ( "")) }),
585
+ showActiveUsers && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableCell, { className: "text-end text-xs tabular-nums", children: row.activeUsers === void 0 ? "" : decimal(row.activeUsers, 0) }),
586
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.calls, 0) }),
587
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensIn, 0) }),
588
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensOut, 0) }),
589
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableCell, { className: "text-end text-xs tabular-nums", children: percent(_chunkKJMMBUOAjs.cacheHitPercentage.call(void 0, row.cached, row.tokensIn)) }),
590
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.cost, "cost") }),
591
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.credits, "credits") }),
592
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.TableCell, { className: "text-end text-xs tabular-nums", children: percent(share) })
593
593
  ] }, row.id);
594
594
  }) })
595
595
  ] }) })
@@ -757,7 +757,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
757
757
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className, dir: "ltr", children: [
758
758
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", "data-testid": "timeline-data", children: JSON.stringify(chartData) }),
759
759
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", "data-testid": "timeline-series", children: JSON.stringify(seriesKeys) }),
760
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.ChartContainer, { config: chartConfig, className: "aspect-auto h-72 w-full", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _recharts.BarChart, { accessibilityLayer: true, data: chartData, margin: { top: 8, right: 8, bottom: 0, left: 0 }, children: [
760
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.ChartContainer, { config: chartConfig, className: "aspect-auto h-72 w-full", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _recharts.BarChart, { accessibilityLayer: true, data: chartData, margin: { top: 8, right: 8, bottom: 0, left: 0 }, children: [
761
761
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _recharts.CartesianGrid, { vertical: false }),
762
762
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
763
763
  _recharts.XAxis,
@@ -781,10 +781,10 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
781
781
  }
782
782
  ),
783
783
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
784
- _chunkVDVIUDY5js.ChartTooltip,
784
+ _chunkGYW7LLBQjs.ChartTooltip,
785
785
  {
786
786
  content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
787
- _chunkVDVIUDY5js.ChartTooltipContent,
787
+ _chunkGYW7LLBQjs.ChartTooltipContent,
788
788
  {
789
789
  labelFormatter: (value) => bucketDate(String(value), granularity),
790
790
  valueFormatter: (value) => formatValue(Number(value), metric),
@@ -793,7 +793,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
793
793
  )
794
794
  }
795
795
  ),
796
- seriesKeys.length >= 2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.ChartLegend, { content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.ChartLegendContent, {}) }) : null,
796
+ seriesKeys.length >= 2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.ChartLegend, { content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.ChartLegendContent, {}) }) : null,
797
797
  seriesKeys.map((series, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
798
798
  _recharts.Bar,
799
799
  {
@@ -845,19 +845,19 @@ function TokenUsageAdminContainer() {
845
845
  [t]
846
846
  );
847
847
  if (error) {
848
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
848
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
849
849
  }
850
- if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.RoundPageContainer, { fullWidth: true, forceHeader: true });
850
+ if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.RoundPageContainer, { fullWidth: true, forceHeader: true });
851
851
  const emptyLabel = t("token_usage.admin.no_data");
852
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
852
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
853
853
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminTiles, { summary, metric: filters.metric, singleCustomerMode: hidePlatform }),
854
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.Card, { children: [
855
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.CardHeader, { children: [
856
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardTitle, { children: t("token_usage.admin.usage_over_time") }),
857
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardAction, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
854
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.Card, { children: [
855
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.CardHeader, { children: [
856
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardTitle, { children: t("token_usage.admin.usage_over_time") }),
857
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardAction, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
858
858
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.admin.stack_by") }),
859
859
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
860
- _chunkVDVIUDY5js.Select,
860
+ _chunkGYW7LLBQjs.Select,
861
861
  {
862
862
  items: stackByItems,
863
863
  value: filters.stackBy,
@@ -865,29 +865,29 @@ function TokenUsageAdminContainer() {
865
865
  if (value) setFilters({ stackBy: value });
866
866
  },
867
867
  children: [
868
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.SelectTrigger, { size: "sm", className: "w-36", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.SelectValue, {}) }),
869
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.SelectContent, { children: STACK_BY_VALUES.map((value) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.SelectItem, { value, children: stackByItems[value] }, value)) })
868
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.SelectTrigger, { size: "sm", className: "w-36", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.SelectValue, {}) }),
869
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.SelectContent, { children: STACK_BY_VALUES.map((value) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.SelectItem, { value, children: stackByItems[value] }, value)) })
870
870
  ]
871
871
  }
872
872
  )
873
873
  ] }) })
874
874
  ] }),
875
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: filters.metric, stackBy: filters.stackBy }) })
875
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: filters.metric, stackBy: filters.stackBy }) })
876
876
  ] }),
877
877
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-4 md:grid-cols-2", children: [
878
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.Card, { children: [
879
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardTitle, { children: t("token_usage.admin.by_company") }) }),
880
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byCompany, metric: filters.metric, emptyLabel }) })
878
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.Card, { children: [
879
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardTitle, { children: t("token_usage.admin.by_company") }) }),
880
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byCompany, metric: filters.metric, emptyLabel }) })
881
881
  ] }),
882
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.Card, { children: [
883
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardTitle, { children: t("token_usage.admin.by_user") }) }),
884
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byUser, metric: filters.metric, emptyLabel }) })
882
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.Card, { children: [
883
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardTitle, { children: t("token_usage.admin.by_user") }) }),
884
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byUser, metric: filters.metric, emptyLabel }) })
885
885
  ] })
886
886
  ] }),
887
887
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk4ORLPEK7js.cn.call(void 0, "grid gap-4", !hidePlatform && "md:grid-cols-2"), children: [
888
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.Card, { children: [
889
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardTitle, { children: t("token_usage.admin.customer_by_operation") }) }),
890
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
888
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.Card, { children: [
889
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardTitle, { children: t("token_usage.admin.customer_by_operation") }) }),
890
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
891
891
  TokenUsageRankedBar,
892
892
  {
893
893
  rows: byCustomerOperation,
@@ -897,9 +897,9 @@ function TokenUsageAdminContainer() {
897
897
  }
898
898
  ) })
899
899
  ] }),
900
- !hidePlatform && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.Card, { children: [
901
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardTitle, { children: t("token_usage.admin.platform_by_operation") }) }),
902
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
900
+ !hidePlatform && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.Card, { children: [
901
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardTitle, { children: t("token_usage.admin.platform_by_operation") }) }),
902
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
903
903
  TokenUsageRankedBar,
904
904
  {
905
905
  rows: byOperation,
@@ -910,9 +910,9 @@ function TokenUsageAdminContainer() {
910
910
  ) })
911
911
  ] })
912
912
  ] }),
913
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.Card, { children: [
914
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardTitle, { children: t("token_usage.admin.detail") }) }),
915
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageBreakdownTable, { rows: byCompany, metric: filters.metric }) })
913
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.Card, { children: [
914
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardTitle, { children: t("token_usage.admin.detail") }) }),
915
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageBreakdownTable, { rows: byCompany, metric: filters.metric }) })
916
916
  ] })
917
917
  ] }) });
918
918
  }
@@ -1033,7 +1033,7 @@ var TOKEN_USAGE_REPORT_I18N_KEYS = [
1033
1033
 
1034
1034
  function TokenUsageReportFilterBar({ onChange }) {
1035
1035
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-help": "tokenusage.filters", className: "flex flex-wrap items-center gap-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1036
- _chunkVDVIUDY5js.DateRangeSelector,
1036
+ _chunkGYW7LLBQjs.DateRangeSelector,
1037
1037
  {
1038
1038
  onDateChange: (range) => {
1039
1039
  if (!_optionalChain([range, 'optionalAccess', _5 => _5.from]) || !_optionalChain([range, 'optionalAccess', _6 => _6.to])) return;
@@ -1066,7 +1066,7 @@ var TokenUsageReportProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
1066
1066
  pageUrl = TOKEN_USAGE_REPORT_PAGE_URL
1067
1067
  }) => {
1068
1068
  const t = _nextintl.useTranslations.call(void 0, );
1069
- const generateUrl = _chunkVDVIUDY5js.usePageUrlGenerator.call(void 0, );
1069
+ const generateUrl = _chunkGYW7LLBQjs.usePageUrlGenerator.call(void 0, );
1070
1070
  const [filters, setFilterState] = _react.useState.call(void 0, () => {
1071
1071
  const range = defaultRange2();
1072
1072
  return { from: _nullishCoalesce(initialFrom, () => ( range.from)), to: _nullishCoalesce(initialTo, () => ( range.to)) };
@@ -1130,7 +1130,7 @@ var TokenUsageReportProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
1130
1130
  () => ({ summary, timeline, byOperation, byTarget, targetPanelTitleKey, filters, setFilters, isLoading, error }),
1131
1131
  [summary, timeline, byOperation, byTarget, targetPanelTitleKey, filters, setFilters, isLoading, error]
1132
1132
  );
1133
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportContext.Provider, { value: contextValue, children }) });
1133
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportContext.Provider, { value: contextValue, children }) });
1134
1134
  }, "TokenUsageReportProvider");
1135
1135
  var useTokenUsageReport = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
1136
1136
  const ctx = _react.useContext.call(void 0, TokenUsageReportContext);
@@ -1158,7 +1158,7 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
1158
1158
  const monthlyColor = monthlyPercentage > 75 ? "text-success" : monthlyPercentage >= 5 ? "text-warning" : "text-destructive";
1159
1159
  const whole = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (value) => decimal(Math.max(0, Math.floor(value)), 0), "whole");
1160
1160
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-3", children: [
1161
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.Card, { "data-testid": "tile-used", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.CardContent, { className: "grid gap-1", children: [
1161
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.Card, { "data-testid": "tile-used", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.CardContent, { className: "grid gap-1", children: [
1162
1162
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.used_in_period") }),
1163
1163
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-primary text-xl font-semibold tabular-nums", children: formatValue(_chunkKJMMBUOAjs.metricValue.call(void 0, current, metric), metric) }),
1164
1164
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-1", children: [
@@ -1174,7 +1174,7 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
1174
1174
  ] })
1175
1175
  ] }) }),
1176
1176
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-3 sm:grid-cols-3", children: [
1177
- balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.Card, { "data-testid": "tile-monthly", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.CardContent, { className: "grid gap-1", children: [
1177
+ balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.Card, { "data-testid": "tile-monthly", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.CardContent, { className: "grid gap-1", children: [
1178
1178
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.monthly_left") }),
1179
1179
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-baseline gap-1", children: [
1180
1180
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "data-testid": "tile-monthly-value", className: _chunk4ORLPEK7js.cn.call(void 0, "text-sm font-medium tabular-nums", monthlyColor), children: whole(balances.availableMonthlyCredits) }),
@@ -1184,11 +1184,11 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
1184
1184
  ] })
1185
1185
  ] })
1186
1186
  ] }) }),
1187
- balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.Card, { "data-testid": "tile-extra", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.CardContent, { className: "grid gap-1", children: [
1187
+ balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.Card, { "data-testid": "tile-extra", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.CardContent, { className: "grid gap-1", children: [
1188
1188
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.extra_credits") }),
1189
1189
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: whole(balances.availableExtraCredits) })
1190
1190
  ] }) }),
1191
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.Card, { "data-testid": "tile-calls", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.CardContent, { className: "grid gap-1", children: [
1191
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.Card, { "data-testid": "tile-calls", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.CardContent, { className: "grid gap-1", children: [
1192
1192
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.calls") }),
1193
1193
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: decimal(current.calls, 0) })
1194
1194
  ] }) })
@@ -1230,21 +1230,21 @@ function TokenUsageReportContainer({ balances = null }) {
1230
1230
  const t = _nextintl.useTranslations.call(void 0, );
1231
1231
  const { summary, timeline, byOperation, byTarget, isLoading, error, targetPanelTitleKey } = useTokenUsageReport();
1232
1232
  if (error) {
1233
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
1233
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
1234
1234
  }
1235
- if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.RoundPageContainer, { fullWidth: true, forceHeader: true });
1235
+ if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.RoundPageContainer, { fullWidth: true, forceHeader: true });
1236
1236
  const emptyLabel = t("token_usage.report.no_data");
1237
1237
  const targetTitle = targetPanelTitleKey && byTarget.length > 0 ? t(targetPanelTitleKey) : void 0;
1238
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
1238
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-4 p-4", children: [
1239
1239
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportTiles, { summary, metric: "credits", balances }),
1240
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.Card, { children: [
1241
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardTitle, { children: t("token_usage.report.usage_over_time") }) }),
1242
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: "credits", stackBy: "type" }) })
1240
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.Card, { children: [
1241
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardTitle, { children: t("token_usage.report.usage_over_time") }) }),
1242
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: "credits", stackBy: "type" }) })
1243
1243
  ] }),
1244
1244
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk4ORLPEK7js.cn.call(void 0, "grid gap-4", targetTitle && "md:grid-cols-2"), children: [
1245
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.Card, { children: [
1246
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardTitle, { children: t("token_usage.report.by_operation") }) }),
1247
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1245
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.Card, { children: [
1246
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardTitle, { children: t("token_usage.report.by_operation") }) }),
1247
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1248
1248
  TokenUsageRankedBar,
1249
1249
  {
1250
1250
  rows: byOperation,
@@ -1254,9 +1254,9 @@ function TokenUsageReportContainer({ balances = null }) {
1254
1254
  }
1255
1255
  ) })
1256
1256
  ] }),
1257
- targetTitle && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkVDVIUDY5js.Card, { children: [
1258
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardTitle, { children: targetTitle }) }),
1259
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkVDVIUDY5js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byTarget, metric: "credits", emptyLabel }) })
1257
+ targetTitle && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkGYW7LLBQjs.Card, { children: [
1258
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardTitle, { children: targetTitle }) }),
1259
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGYW7LLBQjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byTarget, metric: "credits", emptyLabel }) })
1260
1260
  ] })
1261
1261
  ] })
1262
1262
  ] }) });
@@ -37,7 +37,7 @@ import {
37
37
  TableHeader,
38
38
  TableRow,
39
39
  usePageUrlGenerator
40
- } from "../../chunk-2VXDZRYY.mjs";
40
+ } from "../../chunk-AICMLKWN.mjs";
41
41
  import "../../chunk-MQDR6MEE.mjs";
42
42
  import "../../chunk-PW42LRSL.mjs";
43
43
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carlonicora/nextjs-jsonapi",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "Next.js JSON:API client with server/client support and caching",
5
5
  "author": "Carlo Nicora",
6
6
  "license": "GPL-3.0-or-later",
@@ -5,7 +5,7 @@ import { ContentListTable } from "../ContentListTable";
5
5
  // `ContentListTable` imports `useTableGenerator` from the `../../hooks` barrel,
6
6
  // which resolves columns through the table-generator registry. Mocking the
7
7
  // barrel (spreading the actual module so the other exports survive) is the same
8
- // approach the sibling `ContentListTable.test.tsx` in this folder uses; one
8
+ // approach the sibling `ContentListTable.rendering.spec.tsx` in this folder uses; one
9
9
  // plain column is enough here.
10
10
  // `mockColumns.expandToggle` switches the mocked name cell to a button that
11
11
  // toggles row expansion (the `renderExpandedRow` suite), plus a second column so
@@ -1,5 +1,6 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
2
  import { renderHook, waitFor, act } from "@testing-library/react";
3
+ import { Activity, createElement, ReactNode } from "react";
3
4
  import { useDataListRetriever } from "../useDataListRetriever";
4
5
  import { createMockModule, createMockApiData } from "../../testing";
5
6
 
@@ -344,4 +345,60 @@ describe("useDataListRetriever", () => {
344
345
  });
345
346
  });
346
347
  });
348
+
349
+ describe("skipped calls", () => {
350
+ it("still fetches a later search after a call the already-loaded guard skipped", async () => {
351
+ const retriever = vi.fn().mockResolvedValue([createMockApiData({ type: "articles", id: "1" })]);
352
+
353
+ // An inline retriever, as list components write it: a new function each render keeps
354
+ // fetchData's closure current, so the already-loaded guard sees the loaded state.
355
+ const { result } = renderHook(() =>
356
+ useDataListRetriever({ retriever: (params) => retriever(params), module: mockModule, search: "" }),
357
+ );
358
+
359
+ await waitFor(() => expect(result.current.isLoaded).toBe(true));
360
+ expect(retriever).toHaveBeenCalledTimes(1);
361
+
362
+ // Single page, loaded, search unchanged: the guard skips this call.
363
+ act(() => {
364
+ result.current.addAdditionalParameter("filter", "active");
365
+ });
366
+ expect(retriever).toHaveBeenCalledTimes(1);
367
+
368
+ await act(async () => {
369
+ await result.current.search("dragon");
370
+ });
371
+
372
+ await waitFor(() => expect(retriever).toHaveBeenCalledTimes(2));
373
+ expect(retriever.mock.calls[1][0].search).toBe("dragon");
374
+ });
375
+ });
376
+
377
+ describe("hidden route coming back (Activity)", () => {
378
+ it("re-fetches a loaded list when it becomes visible again", async () => {
379
+ const first = [
380
+ createMockApiData({ type: "articles", id: "1" }),
381
+ createMockApiData({ type: "articles", id: "2" }),
382
+ ];
383
+ const second = [createMockApiData({ type: "articles", id: "2" })];
384
+ const retriever = vi.fn().mockResolvedValueOnce(first).mockResolvedValueOnce(second);
385
+
386
+ let mode: "visible" | "hidden" = "visible";
387
+ const wrapper = ({ children }: { children: ReactNode }) => createElement(Activity, { mode }, children);
388
+ const { result, rerender } = renderHook(() => useDataListRetriever({ retriever, module: mockModule }), {
389
+ wrapper,
390
+ });
391
+
392
+ await waitFor(() => expect(result.current.data?.map((item: any) => item.id)).toEqual(["1", "2"]));
393
+ expect(retriever).toHaveBeenCalledTimes(1);
394
+
395
+ mode = "hidden";
396
+ rerender();
397
+ mode = "visible";
398
+ rerender();
399
+
400
+ await waitFor(() => expect(result.current.data?.map((item: any) => item.id)).toEqual(["2"]));
401
+ expect(retriever).toHaveBeenCalledTimes(2);
402
+ });
403
+ });
347
404
  });
@@ -121,7 +121,14 @@ export function useDataListRetriever<T>(params: {
121
121
  );
122
122
 
123
123
  const fetchData = useCallback(
124
- async (fetchParams?: { isRefine?: boolean; isRefresh?: boolean; callNext?: boolean; callPrevious?: boolean }) => {
124
+ async (fetchParams?: {
125
+ isRefine?: boolean;
126
+ isRefresh?: boolean;
127
+ callNext?: boolean;
128
+ callPrevious?: boolean;
129
+ /** Re-fetch even though a single-page list is already loaded. */
130
+ force?: boolean;
131
+ }) => {
125
132
  if (ready === false) return;
126
133
 
127
134
  // Prevent concurrent pagination calls
@@ -132,19 +139,12 @@ export function useDataListRetriever<T>(params: {
132
139
  // Prevent concurrent fetches (unless it's a pagination call)
133
140
  if (isFetchingRef.current && !fetchParams?.callNext && !fetchParams?.callPrevious) return;
134
141
 
135
- // Mark pagination in progress
136
- if (fetchParams?.callNext || fetchParams?.callPrevious) {
137
- isPaginatingRef.current = true;
138
- }
139
-
140
- const thisRequestId = ++requestIdRef.current;
141
- isFetchingRef.current = true;
142
-
143
142
  if (stableParams.requiresSearch === true && fetchParams?.isRefine !== true && fetchParams?.isRefresh !== true) {
144
143
  return;
145
144
  }
146
145
 
147
146
  if (
147
+ fetchParams?.force !== true &&
148
148
  !nextPage &&
149
149
  !previousPage &&
150
150
  isLoaded &&
@@ -155,6 +155,16 @@ export function useDataListRetriever<T>(params: {
155
155
  return;
156
156
  }
157
157
 
158
+ // Marked only once the call will really fetch: set before the early returns above, the
159
+ // flags stayed raised (only the `finally` below clears them) and every later
160
+ // search/filter/refresh call was dropped by the concurrency guards.
161
+ if (fetchParams?.callNext || fetchParams?.callPrevious) {
162
+ isPaginatingRef.current = true;
163
+ }
164
+
165
+ const thisRequestId = ++requestIdRef.current;
166
+ isFetchingRef.current = true;
167
+
158
168
  const currentSearchTerm = searchTermRef.current;
159
169
 
160
170
  setIsLoaded(false);
@@ -288,6 +298,25 @@ export function useDataListRetriever<T>(params: {
288
298
  }
289
299
  }, [ready, fetchData]);
290
300
 
301
+ // Cache Components keeps a visited route alive in a hidden <Activity>: leaving it cleans up
302
+ // its effects, coming back re-runs them with the old state intact. A loaded list would then
303
+ // keep showing rows a write on another page has changed (a record deleted from its detail
304
+ // page stayed listed after the redirect back), so re-fetch when the effects return with data
305
+ // already loaded. The stale rows stay on screen until the response replaces them.
306
+ const fetchDataRef = useRef(fetchData);
307
+ const isLoadedRef = useRef(isLoaded);
308
+ useEffect(() => {
309
+ fetchDataRef.current = fetchData;
310
+ isLoadedRef.current = isLoaded;
311
+ });
312
+ const wasHiddenRef = useRef(false);
313
+ useEffect(() => {
314
+ if (wasHiddenRef.current && isLoadedRef.current) fetchDataRef.current({ isRefresh: true, force: true });
315
+ return () => {
316
+ wasHiddenRef.current = true;
317
+ };
318
+ }, []);
319
+
291
320
  const loadNext = useCallback(
292
321
  async (onlyNewRecords?: boolean) => {
293
322
  if (nextPage) {
@@ -1,4 +1,4 @@
1
- // packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/confirm-dialog.test.tsx
1
+ // packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/confirm-dialog.spec.tsx
2
2
  import { describe, expect, it, vi } from "vitest";
3
3
  import { render, screen } from "@testing-library/react";
4
4
  import userEvent from "@testing-library/user-event";
@@ -1,4 +1,4 @@
1
- // packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/cursor-controls.test.tsx
1
+ // packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/cursor-controls.spec.tsx
2
2
  import { describe, expect, it } from "vitest";
3
3
  import { render, screen } from "@testing-library/react";
4
4
 
@@ -1,4 +1,4 @@
1
- // packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/cursor-menu-items.test.tsx
1
+ // packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/cursor-menu-items.spec.tsx
2
2
  import { describe, expect, it } from "vitest";
3
3
  import { render, screen } from "@testing-library/react";
4
4
 
@@ -1,4 +1,4 @@
1
- // packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/empty-state.test.tsx
1
+ // packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/empty-state.spec.tsx
2
2
  import { describe, expect, it } from "vitest";
3
3
  import { render, screen } from "@testing-library/react";
4
4
  import { InboxIcon } from "lucide-react";
@@ -1,4 +1,4 @@
1
- // packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/spinner.test.tsx
1
+ // packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/spinner.spec.tsx
2
2
  import { describe, expect, it } from "vitest";
3
3
  import { render, screen } from "@testing-library/react";
4
4
  import { Spinner } from "../spinner";