@carlonicora/nextjs-jsonapi 3.25.0 → 3.26.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/dist/{BlockNoteEditor-46O3JC4Z.mjs → BlockNoteEditor-VET2JD72.mjs} +13 -3
- package/dist/{BlockNoteEditor-46O3JC4Z.mjs.map → BlockNoteEditor-VET2JD72.mjs.map} +1 -1
- package/dist/{BlockNoteEditor-HKS6AXDA.js → BlockNoteEditor-WUC2NRGI.js} +20 -10
- package/dist/BlockNoteEditor-WUC2NRGI.js.map +1 -0
- package/dist/billing/index.js +335 -335
- package/dist/billing/index.mjs +1 -1
- package/dist/{chunk-Y3OKEQGL.js → chunk-425GLYXN.js} +580 -363
- package/dist/chunk-425GLYXN.js.map +1 -0
- package/dist/{chunk-XDYILJ2S.mjs → chunk-7SJ4HKDR.mjs} +548 -331
- package/dist/chunk-7SJ4HKDR.mjs.map +1 -0
- package/dist/{chunk-KLV6RLDE.js → chunk-GKDHYB2R.js} +2 -2
- package/dist/chunk-GKDHYB2R.js.map +1 -0
- package/dist/{chunk-4Z2UONN2.mjs → chunk-U65JPKO3.mjs} +2 -2
- package/dist/chunk-U65JPKO3.mjs.map +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client/index.mjs +1 -1
- package/dist/components/index.d.mts +16 -3
- package/dist/components/index.d.ts +16 -3
- package/dist/components/index.js +4 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +3 -1
- package/dist/contexts/index.js +2 -2
- package/dist/contexts/index.mjs +1 -1
- package/dist/features/analytics/index.js +100 -100
- package/dist/features/analytics/index.js.map +1 -1
- package/dist/features/analytics/index.mjs +5 -5
- package/dist/features/analytics/index.mjs.map +1 -1
- package/dist/features/help/index.js +36 -36
- package/dist/features/help/index.js.map +1 -1
- package/dist/features/help/index.mjs +6 -6
- package/dist/features/help/index.mjs.map +1 -1
- package/dist/features/tokenusage/index.js +103 -103
- package/dist/features/tokenusage/index.js.map +1 -1
- package/dist/features/tokenusage/index.mjs +4 -4
- package/dist/features/tokenusage/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/containers/PageContainer.tsx +3 -1
- package/src/components/containers/RoundPageContainer.tsx +63 -16
- package/src/components/containers/RoundPageContainerTitle.tsx +75 -35
- package/src/components/editors/BlockNoteEditor.tsx +13 -1
- package/src/components/forms/EntityMultiSelector.tsx +4 -4
- package/src/components/forms/EntitySelector.tsx +4 -4
- package/src/components/forms/FormBlockNote.tsx +27 -1
- package/src/components/forms/FormCheckbox.tsx +3 -2
- package/src/components/forms/__tests__/useEditorDialog.test.ts +47 -0
- package/src/components/forms/useEditorDialog.ts +22 -0
- package/src/components/navigations/Breadcrumb.tsx +45 -16
- package/src/components/navigations/Header.tsx +18 -3
- package/src/components/navigations/MobileNavigationBar.tsx +12 -0
- package/src/components/navigations/__tests__/MobileNavigationBar.spec.tsx +17 -0
- package/src/components/tables/ContentListTable.tsx +52 -32
- package/src/features/analytics/components/AnalyticsAdminFilterBar.tsx +9 -6
- package/src/features/analytics/components/AnalyticsBreakdownTable.tsx +2 -1
- package/src/features/assistant/components/parts/AssistantBlockNoteComposer.tsx +3 -1
- package/src/features/assistant/components/parts/AssistantComposer.tsx +3 -1
- package/src/features/assistant-message/components/MessageItem.tsx +2 -2
- package/src/features/assistant-message/components/parts/tabs/CitationsTab.tsx +25 -5
- package/src/features/auth/components/containers/AuthContainer.tsx +8 -1
- package/src/features/company/components/details/CompanyContent.tsx +3 -1
- package/src/features/company/components/details/CompanyDetails.tsx +9 -1
- package/src/features/company/components/details/TokenStatusIndicator.tsx +42 -13
- package/src/features/help/components/HelpHeader.tsx +7 -5
- package/src/features/tokenusage/components/TokenUsageAdminFilterBar.tsx +9 -6
- package/src/features/tokenusage/lib/__tests__/formatters.spec.ts +21 -0
- package/src/features/tokenusage/lib/formatters.ts +5 -1
- package/src/shadcnui/ui/button.tsx +1 -1
- package/src/shadcnui/ui/checkbox.tsx +1 -1
- package/src/shadcnui/ui/command.tsx +7 -4
- package/src/shadcnui/ui/dialog.tsx +2 -0
- package/src/shadcnui/ui/input.tsx +1 -1
- package/src/shadcnui/ui/popover.tsx +9 -0
- package/src/shadcnui/ui/select.tsx +1 -1
- package/src/shadcnui/ui/sheet.tsx +8 -1
- package/src/shadcnui/ui/table.tsx +5 -2
- package/src/shadcnui/ui/textarea.tsx +1 -1
- package/dist/BlockNoteEditor-HKS6AXDA.js.map +0 -1
- package/dist/chunk-4Z2UONN2.mjs.map +0 -1
- package/dist/chunk-KLV6RLDE.js.map +0 -1
- package/dist/chunk-XDYILJ2S.mjs.map +0 -1
- package/dist/chunk-Y3OKEQGL.js.map +0 -1
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkGKDHYB2Rjs = require('../../chunk-GKDHYB2R.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
@@ -37,7 +37,7 @@ var _chunkKLV6RLDEjs = require('../../chunk-KLV6RLDE.js');
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _chunk425GLYXNjs = require('../../chunk-425GLYXN.js');
|
|
41
41
|
require('../../chunk-4Z45NYPR.js');
|
|
42
42
|
|
|
43
43
|
|
|
@@ -80,15 +80,15 @@ function TokenUsageAdminFilterBar({ granularity, companyId, metric, companies, o
|
|
|
80
80
|
...Object.fromEntries(companies.map((company) => [company.id, company.label]))
|
|
81
81
|
};
|
|
82
82
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
83
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
84
|
-
|
|
83
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "max-md:w-full max-md:[&_#date]:w-full", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
84
|
+
_chunk425GLYXNjs.DateRangeSelector,
|
|
85
85
|
{
|
|
86
86
|
onDateChange: (range) => {
|
|
87
87
|
if (!_optionalChain([range, 'optionalAccess', _ => _.from]) || !_optionalChain([range, 'optionalAccess', _2 => _2.to])) return;
|
|
88
88
|
onChange({ from: range.from.toISOString(), to: range.to.toISOString() });
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
),
|
|
91
|
+
) }),
|
|
92
92
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
93
93
|
Segmented,
|
|
94
94
|
{
|
|
@@ -116,16 +116,16 @@ function TokenUsageAdminFilterBar({ granularity, companyId, metric, companies, o
|
|
|
116
116
|
}
|
|
117
117
|
),
|
|
118
118
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
119
|
-
|
|
119
|
+
_chunk425GLYXNjs.Select,
|
|
120
120
|
{
|
|
121
121
|
items: companyItems,
|
|
122
122
|
value: _nullishCoalesce(companyId, () => ( ALL_COMPANIES)),
|
|
123
123
|
onValueChange: (value) => onChange({ companyId: !value || value === ALL_COMPANIES ? void 0 : value }),
|
|
124
124
|
children: [
|
|
125
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
126
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
127
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
128
|
-
companies.map((company) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
125
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.SelectTrigger, { className: "w-56", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.SelectValue, { placeholder: t("token_usage.admin.all_companies") }) }),
|
|
126
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.SelectContent, { children: [
|
|
127
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.SelectItem, { value: ALL_COMPANIES, children: t("token_usage.admin.all_companies") }),
|
|
128
|
+
companies.map((company) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.SelectItem, { value: company.id, children: company.label }, company.id))
|
|
129
129
|
] })
|
|
130
130
|
]
|
|
131
131
|
}
|
|
@@ -148,7 +148,7 @@ function Segmented({
|
|
|
148
148
|
children: options.map((option) => {
|
|
149
149
|
const selected = option.value === value;
|
|
150
150
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
151
|
-
|
|
151
|
+
_chunk425GLYXNjs.Button,
|
|
152
152
|
{
|
|
153
153
|
type: "button",
|
|
154
154
|
size: "sm",
|
|
@@ -230,7 +230,7 @@ var TokenUsageAdminProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
|
|
|
230
230
|
pageUrl = TOKEN_USAGE_ADMIN_PAGE_URL
|
|
231
231
|
}) => {
|
|
232
232
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
233
|
-
const generateUrl =
|
|
233
|
+
const generateUrl = _chunk425GLYXNjs.usePageUrlGenerator.call(void 0, );
|
|
234
234
|
const [filters, setFilterState] = _react.useState.call(void 0, () => {
|
|
235
235
|
const range = defaultRange();
|
|
236
236
|
return {
|
|
@@ -348,7 +348,7 @@ var TokenUsageAdminProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
|
|
|
348
348
|
error
|
|
349
349
|
]
|
|
350
350
|
);
|
|
351
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
351
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminContext.Provider, { value: contextValue, children }) });
|
|
352
352
|
}, "TokenUsageAdminProvider");
|
|
353
353
|
var useTokenUsageAdmin = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
354
354
|
const ctx = _react.useContext.call(void 0, TokenUsageAdminContext);
|
|
@@ -369,7 +369,7 @@ var _lucidereact = require('lucide-react');
|
|
|
369
369
|
var ZERO = { cost: 0, credits: 0, tokensIn: 0, tokensOut: 0, cached: 0, calls: 0 };
|
|
370
370
|
function TokenUsageAdminTiles({ summary, metric, singleCustomerMode }) {
|
|
371
371
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
372
|
-
const { decimal, metricValue: formatValue, currency, percent } =
|
|
372
|
+
const { decimal, metricValue: formatValue, currency, percent } = _chunkGKDHYB2Rjs.useUsageFormatters.call(void 0, );
|
|
373
373
|
const rowFor = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (scope, window) => _nullishCoalesce(summary.find((r) => r.scope === scope && r.window === window), () => ( ZERO)), "rowFor");
|
|
374
374
|
const customerCurrent = rowFor("customer", "current");
|
|
375
375
|
const customerPrevious = rowFor("customer", "previous");
|
|
@@ -378,7 +378,7 @@ function TokenUsageAdminTiles({ summary, metric, singleCustomerMode }) {
|
|
|
378
378
|
const totalCurrent = rowFor("total", "current");
|
|
379
379
|
const totalPrevious = rowFor("total", "previous");
|
|
380
380
|
const averagePerCall = totalCurrent.calls ? totalCurrent.cost / totalCurrent.calls : 0;
|
|
381
|
-
const cacheHit =
|
|
381
|
+
const cacheHit = _chunkGKDHYB2Rjs.cacheHitPercentage.call(void 0, totalCurrent.cached, totalCurrent.tokensIn);
|
|
382
382
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-3", children: [
|
|
383
383
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkCAKOFJZDjs.cn.call(void 0, "grid gap-3", singleCustomerMode ? "sm:grid-cols-1" : "sm:grid-cols-2"), children: [
|
|
384
384
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -386,8 +386,8 @@ function TokenUsageAdminTiles({ summary, metric, singleCustomerMode }) {
|
|
|
386
386
|
{
|
|
387
387
|
testId: "tile-customer",
|
|
388
388
|
label: t("token_usage.admin.customer_spend"),
|
|
389
|
-
value: formatValue(
|
|
390
|
-
delta:
|
|
389
|
+
value: formatValue(_chunkGKDHYB2Rjs.metricValue.call(void 0, customerCurrent, metric), metric),
|
|
390
|
+
delta: _chunkGKDHYB2Rjs.percentageDelta.call(void 0, _chunkGKDHYB2Rjs.metricValue.call(void 0, customerCurrent, metric), _chunkGKDHYB2Rjs.metricValue.call(void 0, customerPrevious, metric)),
|
|
391
391
|
previousLabel: t("token_usage.admin.vs_previous"),
|
|
392
392
|
decimal
|
|
393
393
|
}
|
|
@@ -397,8 +397,8 @@ function TokenUsageAdminTiles({ summary, metric, singleCustomerMode }) {
|
|
|
397
397
|
{
|
|
398
398
|
testId: "tile-platform",
|
|
399
399
|
label: t("token_usage.admin.platform_spend"),
|
|
400
|
-
value: formatValue(
|
|
401
|
-
delta:
|
|
400
|
+
value: formatValue(_chunkGKDHYB2Rjs.metricValue.call(void 0, platformCurrent, metric), metric),
|
|
401
|
+
delta: _chunkGKDHYB2Rjs.percentageDelta.call(void 0, _chunkGKDHYB2Rjs.metricValue.call(void 0, platformCurrent, metric), _chunkGKDHYB2Rjs.metricValue.call(void 0, platformPrevious, metric)),
|
|
402
402
|
previousLabel: t("token_usage.admin.vs_previous"),
|
|
403
403
|
decimal
|
|
404
404
|
}
|
|
@@ -410,8 +410,8 @@ function TokenUsageAdminTiles({ summary, metric, singleCustomerMode }) {
|
|
|
410
410
|
{
|
|
411
411
|
testId: "tile-total",
|
|
412
412
|
label: t("token_usage.admin.total_cost"),
|
|
413
|
-
value: formatValue(
|
|
414
|
-
delta:
|
|
413
|
+
value: formatValue(_chunkGKDHYB2Rjs.metricValue.call(void 0, totalCurrent, metric), metric),
|
|
414
|
+
delta: _chunkGKDHYB2Rjs.percentageDelta.call(void 0, _chunkGKDHYB2Rjs.metricValue.call(void 0, totalCurrent, metric), _chunkGKDHYB2Rjs.metricValue.call(void 0, totalPrevious, metric)),
|
|
415
415
|
decimal
|
|
416
416
|
}
|
|
417
417
|
),
|
|
@@ -445,7 +445,7 @@ function LeadTile({
|
|
|
445
445
|
previousLabel,
|
|
446
446
|
decimal
|
|
447
447
|
}) {
|
|
448
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
448
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.Card, { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.CardContent, { className: "grid gap-1", children: [
|
|
449
449
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: label }),
|
|
450
450
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-primary text-xl font-semibold tabular-nums", children: value }),
|
|
451
451
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-1", children: [
|
|
@@ -462,7 +462,7 @@ function SupportingTile({
|
|
|
462
462
|
delta,
|
|
463
463
|
decimal
|
|
464
464
|
}) {
|
|
465
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
465
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.Card, { "data-testid": testId, size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.CardContent, { className: "grid gap-1", children: [
|
|
466
466
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: label }),
|
|
467
467
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-2", children: [
|
|
468
468
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: value }),
|
|
@@ -506,10 +506,10 @@ _chunk7QVYU63Ejs.__name.call(void 0, Delta, "Delta");
|
|
|
506
506
|
|
|
507
507
|
function TokenUsageBreakdownTable({ rows, metric }) {
|
|
508
508
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
509
|
-
const { decimal, metricValue: formatValue, percent, compare } =
|
|
509
|
+
const { decimal, metricValue: formatValue, percent, compare } = _chunkGKDHYB2Rjs.useUsageFormatters.call(void 0, );
|
|
510
510
|
const [sort, setSort] = _react.useState.call(void 0, void 0);
|
|
511
511
|
const showActiveUsers = rows.some((row) => row.activeUsers !== void 0);
|
|
512
|
-
const total = _react.useMemo.call(void 0, () => rows.reduce((sum, row) => sum +
|
|
512
|
+
const total = _react.useMemo.call(void 0, () => rows.reduce((sum, row) => sum + _chunkGKDHYB2Rjs.metricValue.call(void 0, row, metric), 0), [rows, metric]);
|
|
513
513
|
const sortValue = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (row, key) => {
|
|
514
514
|
switch (key) {
|
|
515
515
|
case "label":
|
|
@@ -519,9 +519,9 @@ function TokenUsageBreakdownTable({ rows, metric }) {
|
|
|
519
519
|
case "activeUsers":
|
|
520
520
|
return _nullishCoalesce(row.activeUsers, () => ( 0));
|
|
521
521
|
case "cacheHit":
|
|
522
|
-
return
|
|
522
|
+
return _chunkGKDHYB2Rjs.cacheHitPercentage.call(void 0, row.cached, row.tokensIn);
|
|
523
523
|
case "share":
|
|
524
|
-
return
|
|
524
|
+
return _chunkGKDHYB2Rjs.metricValue.call(void 0, row, metric);
|
|
525
525
|
default:
|
|
526
526
|
return row[key];
|
|
527
527
|
}
|
|
@@ -559,8 +559,8 @@ function TokenUsageBreakdownTable({ rows, metric }) {
|
|
|
559
559
|
// The package's <Table> wraps itself in an `overflow-x-clip` container, which
|
|
560
560
|
// would swallow the overflow before this scroller ever saw it — hence the
|
|
561
561
|
// child override. Wide metric tables must scroll, never widen the page.
|
|
562
|
-
/* @__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,
|
|
563
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
562
|
+
/* @__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, _chunk425GLYXNjs.Table, { children: [
|
|
563
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableRow, { children: columns.map((column) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableHead, { className: _chunkCAKOFJZDjs.cn.call(void 0, column.numeric && "text-end"), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
564
564
|
"button",
|
|
565
565
|
{
|
|
566
566
|
type: "button",
|
|
@@ -575,20 +575,20 @@ function TokenUsageBreakdownTable({ rows, metric }) {
|
|
|
575
575
|
]
|
|
576
576
|
}
|
|
577
577
|
) }, column.key)) }) }),
|
|
578
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
579
|
-
const value =
|
|
578
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableBody, { children: sortedRows.map((row) => {
|
|
579
|
+
const value = _chunkGKDHYB2Rjs.metricValue.call(void 0, row, metric);
|
|
580
580
|
const share = total > 0 ? value / total * 100 : 0;
|
|
581
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
582
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
583
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
584
|
-
showActiveUsers && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
585
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
586
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
587
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
588
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
589
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
590
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
591
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
581
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.TableRow, { "data-testid": `breakdown-row-${row.id}`, children: [
|
|
582
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableCell, { className: "text-xs", children: row.id === "other" ? t("token_usage.admin.other") : row.label }),
|
|
583
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableCell, { className: "text-muted-foreground text-xs", children: _nullishCoalesce(row.sublabel, () => ( "")) }),
|
|
584
|
+
showActiveUsers && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableCell, { className: "text-end text-xs tabular-nums", children: row.activeUsers === void 0 ? "" : decimal(row.activeUsers, 0) }),
|
|
585
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.calls, 0) }),
|
|
586
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensIn, 0) }),
|
|
587
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableCell, { className: "text-end text-xs tabular-nums", children: decimal(row.tokensOut, 0) }),
|
|
588
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableCell, { className: "text-end text-xs tabular-nums", children: percent(_chunkGKDHYB2Rjs.cacheHitPercentage.call(void 0, row.cached, row.tokensIn)) }),
|
|
589
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.cost, "cost") }),
|
|
590
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableCell, { className: "text-end text-xs tabular-nums", children: formatValue(row.credits, "credits") }),
|
|
591
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.TableCell, { className: "text-end text-xs tabular-nums", children: percent(share) })
|
|
592
592
|
] }, row.id);
|
|
593
593
|
}) })
|
|
594
594
|
] }) })
|
|
@@ -617,7 +617,7 @@ var operationLabel = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (type,
|
|
|
617
617
|
|
|
618
618
|
function TokenUsageRankedBar({ rows, metric, emptyLabel, labelsAreOperationTypes = false }) {
|
|
619
619
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
620
|
-
const { metricValue: formatValue, percent } =
|
|
620
|
+
const { metricValue: formatValue, percent } = _chunkGKDHYB2Rjs.useUsageFormatters.call(void 0, );
|
|
621
621
|
const renderLabel = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (row) => {
|
|
622
622
|
if (row.id === "other") return t("token_usage.admin.other");
|
|
623
623
|
if (!labelsAreOperationTypes) return row.label;
|
|
@@ -630,13 +630,13 @@ function TokenUsageRankedBar({ rows, metric, emptyLabel, labelsAreOperationTypes
|
|
|
630
630
|
if (rows.length === 0) {
|
|
631
631
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground py-6 text-center text-sm", children: emptyLabel });
|
|
632
632
|
}
|
|
633
|
-
const values = rows.map((row) =>
|
|
633
|
+
const values = rows.map((row) => _chunkGKDHYB2Rjs.metricValue.call(void 0, row, metric));
|
|
634
634
|
const total = values.reduce((sum, value) => sum + value, 0);
|
|
635
635
|
const max = Math.max(...values, 0);
|
|
636
636
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "grid gap-0.5", children: rows.map((row, index) => {
|
|
637
637
|
const value = values[index];
|
|
638
638
|
const isOther = row.id === "other";
|
|
639
|
-
const step = isOther ?
|
|
639
|
+
const step = isOther ? _chunkGKDHYB2Rjs.SEQUENTIAL_RAMP.length - 1 : Math.min(index, _chunkGKDHYB2Rjs.SEQUENTIAL_RAMP.length - 1);
|
|
640
640
|
const width = max > 0 ? value / max * 100 : 0;
|
|
641
641
|
const share = total > 0 ? value / total * 100 : 0;
|
|
642
642
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-x-3 gap-y-0.5 py-0.5", children: [
|
|
@@ -648,7 +648,7 @@ function TokenUsageRankedBar({ rows, metric, emptyLabel, labelsAreOperationTypes
|
|
|
648
648
|
"data-testid": `ranked-fill-${row.id}`,
|
|
649
649
|
"data-ramp-step": String(step),
|
|
650
650
|
className: "h-full rounded-r-[4px]",
|
|
651
|
-
style: { width: `${width}%`, backgroundColor:
|
|
651
|
+
style: { width: `${width}%`, backgroundColor: _chunkGKDHYB2Rjs.SEQUENTIAL_RAMP[step] }
|
|
652
652
|
}
|
|
653
653
|
) })
|
|
654
654
|
] }),
|
|
@@ -698,7 +698,7 @@ var inferGranularity = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (buc
|
|
|
698
698
|
}, "inferGranularity");
|
|
699
699
|
function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
|
|
700
700
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
701
|
-
const { compact, bucketDate, metricValue: formatValue } =
|
|
701
|
+
const { compact, bucketDate, metricValue: formatValue } = _chunkGKDHYB2Rjs.useUsageFormatters.call(void 0, );
|
|
702
702
|
const { resolvedTheme } = _nextthemes.useTheme.call(void 0, );
|
|
703
703
|
const mode = resolvedTheme === "dark" ? "dark" : "light";
|
|
704
704
|
const { chartData, seriesKeys } = _react.useMemo.call(void 0, () => {
|
|
@@ -706,8 +706,8 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
|
|
|
706
706
|
const totals = /* @__PURE__ */ new Map();
|
|
707
707
|
for (const row of rows) totals.set(row.series, (_nullishCoalesce(totals.get(row.series), () => ( 0))) + metricValue2(row, metric));
|
|
708
708
|
const ranked = [...totals.entries()].sort((a, b) => b[1] - a[1]).map(([series]) => series);
|
|
709
|
-
const named = ranked.slice(0,
|
|
710
|
-
const folded = new Set(ranked.slice(
|
|
709
|
+
const named = ranked.slice(0, _chunkGKDHYB2Rjs.CATEGORICAL_CEILING);
|
|
710
|
+
const folded = new Set(ranked.slice(_chunkGKDHYB2Rjs.CATEGORICAL_CEILING));
|
|
711
711
|
const keys = folded.size > 0 ? [...named, OTHER_SERIES] : named;
|
|
712
712
|
const byBucket = /* @__PURE__ */ new Map();
|
|
713
713
|
for (const row of rows) {
|
|
@@ -747,7 +747,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
|
|
|
747
747
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: className ? `text-muted-foreground text-sm ${className}` : "text-muted-foreground text-sm", children: t.has(key) ? t(key) : "No data in the selected period" });
|
|
748
748
|
}
|
|
749
749
|
const granularity = inferGranularity(chartData.map((entry) => entry.bucket));
|
|
750
|
-
const seriesColorFor = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (series, index) => series === OTHER_SERIES ?
|
|
750
|
+
const seriesColorFor = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (series, index) => series === OTHER_SERIES ? _chunkGKDHYB2Rjs.OTHER_COLOR : _chunkGKDHYB2Rjs.seriesColor.call(void 0, index, mode), "seriesColorFor");
|
|
751
751
|
return (
|
|
752
752
|
// The chart is a coordinate system, not prose: recharts lays the axes and the
|
|
753
753
|
// stacked bars out left-to-right, so the whole chart stays an LTR island even
|
|
@@ -756,7 +756,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
|
|
|
756
756
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className, dir: "ltr", children: [
|
|
757
757
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", "data-testid": "timeline-data", children: JSON.stringify(chartData) }),
|
|
758
758
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", "data-testid": "timeline-series", children: JSON.stringify(seriesKeys) }),
|
|
759
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
759
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.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
760
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _recharts.CartesianGrid, { vertical: false }),
|
|
761
761
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
762
762
|
_recharts.XAxis,
|
|
@@ -780,10 +780,10 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
|
|
|
780
780
|
}
|
|
781
781
|
),
|
|
782
782
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
783
|
-
|
|
783
|
+
_chunk425GLYXNjs.ChartTooltip,
|
|
784
784
|
{
|
|
785
785
|
content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
786
|
-
|
|
786
|
+
_chunk425GLYXNjs.ChartTooltipContent,
|
|
787
787
|
{
|
|
788
788
|
labelFormatter: (value) => bucketDate(String(value), granularity),
|
|
789
789
|
valueFormatter: (value) => formatValue(Number(value), metric),
|
|
@@ -792,7 +792,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
|
|
|
792
792
|
)
|
|
793
793
|
}
|
|
794
794
|
),
|
|
795
|
-
seriesKeys.length >= 2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
795
|
+
seriesKeys.length >= 2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.ChartLegend, { content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.ChartLegendContent, {}) }) : null,
|
|
796
796
|
seriesKeys.map((series, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
797
797
|
_recharts.Bar,
|
|
798
798
|
{
|
|
@@ -844,19 +844,19 @@ function TokenUsageAdminContainer() {
|
|
|
844
844
|
[t]
|
|
845
845
|
);
|
|
846
846
|
if (error) {
|
|
847
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
847
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
|
|
848
848
|
}
|
|
849
|
-
if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
849
|
+
if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.RoundPageContainer, { fullWidth: true, forceHeader: true });
|
|
850
850
|
const emptyLabel = t("token_usage.admin.no_data");
|
|
851
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
851
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.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
852
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageAdminTiles, { summary, metric: filters.metric, singleCustomerMode: hidePlatform }),
|
|
853
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
854
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
855
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
856
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
853
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.Card, { children: [
|
|
854
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.CardHeader, { children: [
|
|
855
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardTitle, { children: t("token_usage.admin.usage_over_time") }),
|
|
856
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardAction, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
857
857
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.admin.stack_by") }),
|
|
858
858
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
859
|
-
|
|
859
|
+
_chunk425GLYXNjs.Select,
|
|
860
860
|
{
|
|
861
861
|
items: stackByItems,
|
|
862
862
|
value: filters.stackBy,
|
|
@@ -864,29 +864,29 @@ function TokenUsageAdminContainer() {
|
|
|
864
864
|
if (value) setFilters({ stackBy: value });
|
|
865
865
|
},
|
|
866
866
|
children: [
|
|
867
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
868
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
867
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.SelectTrigger, { size: "sm", className: "w-36", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.SelectValue, {}) }),
|
|
868
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.SelectContent, { children: STACK_BY_VALUES.map((value) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.SelectItem, { value, children: stackByItems[value] }, value)) })
|
|
869
869
|
]
|
|
870
870
|
}
|
|
871
871
|
)
|
|
872
872
|
] }) })
|
|
873
873
|
] }),
|
|
874
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
874
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: filters.metric, stackBy: filters.stackBy }) })
|
|
875
875
|
] }),
|
|
876
876
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
877
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
878
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
879
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
877
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.Card, { children: [
|
|
878
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardTitle, { children: t("token_usage.admin.by_company") }) }),
|
|
879
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byCompany, metric: filters.metric, emptyLabel }) })
|
|
880
880
|
] }),
|
|
881
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
882
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
883
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
881
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.Card, { children: [
|
|
882
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardTitle, { children: t("token_usage.admin.by_user") }) }),
|
|
883
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byUser, metric: filters.metric, emptyLabel }) })
|
|
884
884
|
] })
|
|
885
885
|
] }),
|
|
886
886
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkCAKOFJZDjs.cn.call(void 0, "grid gap-4", !hidePlatform && "md:grid-cols-2"), children: [
|
|
887
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
888
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
889
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
887
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.Card, { children: [
|
|
888
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardTitle, { children: t("token_usage.admin.customer_by_operation") }) }),
|
|
889
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
890
890
|
TokenUsageRankedBar,
|
|
891
891
|
{
|
|
892
892
|
rows: byCustomerOperation,
|
|
@@ -896,9 +896,9 @@ function TokenUsageAdminContainer() {
|
|
|
896
896
|
}
|
|
897
897
|
) })
|
|
898
898
|
] }),
|
|
899
|
-
!hidePlatform && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
900
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
901
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
899
|
+
!hidePlatform && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.Card, { children: [
|
|
900
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardTitle, { children: t("token_usage.admin.platform_by_operation") }) }),
|
|
901
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
902
902
|
TokenUsageRankedBar,
|
|
903
903
|
{
|
|
904
904
|
rows: byOperation,
|
|
@@ -909,9 +909,9 @@ function TokenUsageAdminContainer() {
|
|
|
909
909
|
) })
|
|
910
910
|
] })
|
|
911
911
|
] }),
|
|
912
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
913
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
914
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
912
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.Card, { children: [
|
|
913
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardTitle, { children: t("token_usage.admin.detail") }) }),
|
|
914
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageBreakdownTable, { rows: byCompany, metric: filters.metric }) })
|
|
915
915
|
] })
|
|
916
916
|
] }) });
|
|
917
917
|
}
|
|
@@ -1032,7 +1032,7 @@ var TOKEN_USAGE_REPORT_I18N_KEYS = [
|
|
|
1032
1032
|
|
|
1033
1033
|
function TokenUsageReportFilterBar({ onChange }) {
|
|
1034
1034
|
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,
|
|
1035
|
-
|
|
1035
|
+
_chunk425GLYXNjs.DateRangeSelector,
|
|
1036
1036
|
{
|
|
1037
1037
|
onDateChange: (range) => {
|
|
1038
1038
|
if (!_optionalChain([range, 'optionalAccess', _5 => _5.from]) || !_optionalChain([range, 'optionalAccess', _6 => _6.to])) return;
|
|
@@ -1065,7 +1065,7 @@ var TokenUsageReportProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
|
|
|
1065
1065
|
pageUrl = TOKEN_USAGE_REPORT_PAGE_URL
|
|
1066
1066
|
}) => {
|
|
1067
1067
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1068
|
-
const generateUrl =
|
|
1068
|
+
const generateUrl = _chunk425GLYXNjs.usePageUrlGenerator.call(void 0, );
|
|
1069
1069
|
const [filters, setFilterState] = _react.useState.call(void 0, () => {
|
|
1070
1070
|
const range = defaultRange2();
|
|
1071
1071
|
return { from: _nullishCoalesce(initialFrom, () => ( range.from)), to: _nullishCoalesce(initialTo, () => ( range.to)) };
|
|
@@ -1129,7 +1129,7 @@ var TokenUsageReportProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void
|
|
|
1129
1129
|
() => ({ summary, timeline, byOperation, byTarget, targetPanelTitleKey, filters, setFilters, isLoading, error }),
|
|
1130
1130
|
[summary, timeline, byOperation, byTarget, targetPanelTitleKey, filters, setFilters, isLoading, error]
|
|
1131
1131
|
);
|
|
1132
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1132
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportContext.Provider, { value: contextValue, children }) });
|
|
1133
1133
|
}, "TokenUsageReportProvider");
|
|
1134
1134
|
var useTokenUsageReport = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
1135
1135
|
const ctx = _react.useContext.call(void 0, TokenUsageReportContext);
|
|
@@ -1149,7 +1149,7 @@ var useTokenUsageReport = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (
|
|
|
1149
1149
|
var ZERO2 = { cost: 0, credits: 0, tokensIn: 0, tokensOut: 0, cached: 0, calls: 0 };
|
|
1150
1150
|
function TokenUsageReportTiles({ summary, metric, balances }) {
|
|
1151
1151
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1152
|
-
const { decimal, metricValue: formatValue } =
|
|
1152
|
+
const { decimal, metricValue: formatValue } = _chunkGKDHYB2Rjs.useUsageFormatters.call(void 0, );
|
|
1153
1153
|
const rowFor = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (window) => _nullishCoalesce(summary.find((row) => row.window === window), () => ( ZERO2)), "rowFor");
|
|
1154
1154
|
const current = rowFor("current");
|
|
1155
1155
|
const previous = rowFor("previous");
|
|
@@ -1157,15 +1157,15 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
|
|
|
1157
1157
|
const monthlyColor = monthlyPercentage > 75 ? "text-success" : monthlyPercentage >= 5 ? "text-warning" : "text-destructive";
|
|
1158
1158
|
const whole = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (value) => decimal(Math.max(0, Math.floor(value)), 0), "whole");
|
|
1159
1159
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-3", children: [
|
|
1160
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1160
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.Card, { "data-testid": "tile-used", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.CardContent, { className: "grid gap-1", children: [
|
|
1161
1161
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.used_in_period") }),
|
|
1162
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-primary text-xl font-semibold tabular-nums", children: formatValue(
|
|
1162
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-primary text-xl font-semibold tabular-nums", children: formatValue(_chunkGKDHYB2Rjs.metricValue.call(void 0, current, metric), metric) }),
|
|
1163
1163
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-center gap-1", children: [
|
|
1164
1164
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1165
1165
|
Delta2,
|
|
1166
1166
|
{
|
|
1167
1167
|
testId: "tile-used-delta",
|
|
1168
|
-
delta:
|
|
1168
|
+
delta: _chunkGKDHYB2Rjs.percentageDelta.call(void 0, _chunkGKDHYB2Rjs.metricValue.call(void 0, current, metric), _chunkGKDHYB2Rjs.metricValue.call(void 0, previous, metric)),
|
|
1169
1169
|
decimal
|
|
1170
1170
|
}
|
|
1171
1171
|
),
|
|
@@ -1173,7 +1173,7 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
|
|
|
1173
1173
|
] })
|
|
1174
1174
|
] }) }),
|
|
1175
1175
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid gap-3 sm:grid-cols-3", children: [
|
|
1176
|
-
balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1176
|
+
balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.Card, { "data-testid": "tile-monthly", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.CardContent, { className: "grid gap-1", children: [
|
|
1177
1177
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.monthly_left") }),
|
|
1178
1178
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex items-baseline gap-1", children: [
|
|
1179
1179
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "data-testid": "tile-monthly-value", className: _chunkCAKOFJZDjs.cn.call(void 0, "text-sm font-medium tabular-nums", monthlyColor), children: whole(balances.availableMonthlyCredits) }),
|
|
@@ -1183,11 +1183,11 @@ function TokenUsageReportTiles({ summary, metric, balances }) {
|
|
|
1183
1183
|
] })
|
|
1184
1184
|
] })
|
|
1185
1185
|
] }) }),
|
|
1186
|
-
balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1186
|
+
balances && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.Card, { "data-testid": "tile-extra", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.CardContent, { className: "grid gap-1", children: [
|
|
1187
1187
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.extra_credits") }),
|
|
1188
1188
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: whole(balances.availableExtraCredits) })
|
|
1189
1189
|
] }) }),
|
|
1190
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1190
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.Card, { "data-testid": "tile-calls", size: "sm", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.CardContent, { className: "grid gap-1", children: [
|
|
1191
1191
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("token_usage.report.calls") }),
|
|
1192
1192
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium tabular-nums", children: decimal(current.calls, 0) })
|
|
1193
1193
|
] }) })
|
|
@@ -1229,21 +1229,21 @@ function TokenUsageReportContainer({ balances = null }) {
|
|
|
1229
1229
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1230
1230
|
const { summary, timeline, byOperation, byTarget, isLoading, error, targetPanelTitleKey } = useTokenUsageReport();
|
|
1231
1231
|
if (error) {
|
|
1232
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1232
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.RoundPageContainer, { fullWidth: true, forceHeader: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) }) }) }) });
|
|
1233
1233
|
}
|
|
1234
|
-
if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1234
|
+
if (isLoading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.RoundPageContainer, { fullWidth: true, forceHeader: true });
|
|
1235
1235
|
const emptyLabel = t("token_usage.report.no_data");
|
|
1236
1236
|
const targetTitle = targetPanelTitleKey && byTarget.length > 0 ? t(targetPanelTitleKey) : void 0;
|
|
1237
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1237
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.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
1238
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageReportTiles, { summary, metric: "credits", balances }),
|
|
1239
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1240
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1241
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1239
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.Card, { children: [
|
|
1240
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardTitle, { children: t("token_usage.report.usage_over_time") }) }),
|
|
1241
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageTimelineChart, { rows: timeline, metric: "credits", stackBy: "type" }) })
|
|
1242
1242
|
] }),
|
|
1243
1243
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkCAKOFJZDjs.cn.call(void 0, "grid gap-4", targetTitle && "md:grid-cols-2"), children: [
|
|
1244
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1245
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1246
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1244
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.Card, { children: [
|
|
1245
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardTitle, { children: t("token_usage.report.by_operation") }) }),
|
|
1246
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1247
1247
|
TokenUsageRankedBar,
|
|
1248
1248
|
{
|
|
1249
1249
|
rows: byOperation,
|
|
@@ -1253,9 +1253,9 @@ function TokenUsageReportContainer({ balances = null }) {
|
|
|
1253
1253
|
}
|
|
1254
1254
|
) })
|
|
1255
1255
|
] }),
|
|
1256
|
-
targetTitle && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1257
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1258
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1256
|
+
targetTitle && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk425GLYXNjs.Card, { children: [
|
|
1257
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardTitle, { children: targetTitle }) }),
|
|
1258
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk425GLYXNjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenUsageRankedBar, { rows: byTarget, metric: "credits", emptyLabel }) })
|
|
1259
1259
|
] })
|
|
1260
1260
|
] })
|
|
1261
1261
|
] }) });
|
|
@@ -1293,5 +1293,5 @@ _chunk7QVYU63Ejs.__name.call(void 0, TokenUsageReportContainer, "TokenUsageRepor
|
|
|
1293
1293
|
|
|
1294
1294
|
|
|
1295
1295
|
|
|
1296
|
-
exports.TOKEN_USAGE_ADMIN_I18N_KEYS = TOKEN_USAGE_ADMIN_I18N_KEYS; exports.TOKEN_USAGE_REPORT_I18N_KEYS = TOKEN_USAGE_REPORT_I18N_KEYS; exports.TokenUsageAdminBreakdown = _chunkCAKOFJZDjs.TokenUsageAdminBreakdown; exports.TokenUsageAdminBreakdownModule = _chunkCAKOFJZDjs.TokenUsageAdminBreakdownModule; exports.TokenUsageAdminContainer = TokenUsageAdminContainer; exports.TokenUsageAdminFilterBar = TokenUsageAdminFilterBar; exports.TokenUsageAdminProvider = TokenUsageAdminProvider; exports.TokenUsageAdminService = TokenUsageAdminService; exports.TokenUsageAdminSummary = _chunkCAKOFJZDjs.TokenUsageAdminSummary; exports.TokenUsageAdminSummaryModule = _chunkCAKOFJZDjs.TokenUsageAdminSummaryModule; exports.TokenUsageAdminTiles = TokenUsageAdminTiles; exports.TokenUsageAdminTimeline = _chunkCAKOFJZDjs.TokenUsageAdminTimeline; exports.TokenUsageAdminTimelineModule = _chunkCAKOFJZDjs.TokenUsageAdminTimelineModule; exports.TokenUsageBreakdownTable = TokenUsageBreakdownTable; exports.TokenUsageRankedBar = TokenUsageRankedBar; exports.TokenUsageReportBreakdown = _chunkCAKOFJZDjs.TokenUsageReportBreakdown; exports.TokenUsageReportContainer = TokenUsageReportContainer; exports.TokenUsageReportFilterBar = TokenUsageReportFilterBar; exports.TokenUsageReportProvider = TokenUsageReportProvider; exports.TokenUsageReportService = TokenUsageReportService; exports.TokenUsageReportSummary = _chunkCAKOFJZDjs.TokenUsageReportSummary; exports.TokenUsageReportTiles = TokenUsageReportTiles; exports.TokenUsageReportTimeline = _chunkCAKOFJZDjs.TokenUsageReportTimeline; exports.TokenUsageTimelineChart = TokenUsageTimelineChart; exports.configureTokenUsage = _chunkCAKOFJZDjs.configureTokenUsage; exports.createUsageFormatters =
|
|
1296
|
+
exports.TOKEN_USAGE_ADMIN_I18N_KEYS = TOKEN_USAGE_ADMIN_I18N_KEYS; exports.TOKEN_USAGE_REPORT_I18N_KEYS = TOKEN_USAGE_REPORT_I18N_KEYS; exports.TokenUsageAdminBreakdown = _chunkCAKOFJZDjs.TokenUsageAdminBreakdown; exports.TokenUsageAdminBreakdownModule = _chunkCAKOFJZDjs.TokenUsageAdminBreakdownModule; exports.TokenUsageAdminContainer = TokenUsageAdminContainer; exports.TokenUsageAdminFilterBar = TokenUsageAdminFilterBar; exports.TokenUsageAdminProvider = TokenUsageAdminProvider; exports.TokenUsageAdminService = TokenUsageAdminService; exports.TokenUsageAdminSummary = _chunkCAKOFJZDjs.TokenUsageAdminSummary; exports.TokenUsageAdminSummaryModule = _chunkCAKOFJZDjs.TokenUsageAdminSummaryModule; exports.TokenUsageAdminTiles = TokenUsageAdminTiles; exports.TokenUsageAdminTimeline = _chunkCAKOFJZDjs.TokenUsageAdminTimeline; exports.TokenUsageAdminTimelineModule = _chunkCAKOFJZDjs.TokenUsageAdminTimelineModule; exports.TokenUsageBreakdownTable = TokenUsageBreakdownTable; exports.TokenUsageRankedBar = TokenUsageRankedBar; exports.TokenUsageReportBreakdown = _chunkCAKOFJZDjs.TokenUsageReportBreakdown; exports.TokenUsageReportContainer = TokenUsageReportContainer; exports.TokenUsageReportFilterBar = TokenUsageReportFilterBar; exports.TokenUsageReportProvider = TokenUsageReportProvider; exports.TokenUsageReportService = TokenUsageReportService; exports.TokenUsageReportSummary = _chunkCAKOFJZDjs.TokenUsageReportSummary; exports.TokenUsageReportTiles = TokenUsageReportTiles; exports.TokenUsageReportTimeline = _chunkCAKOFJZDjs.TokenUsageReportTimeline; exports.TokenUsageTimelineChart = TokenUsageTimelineChart; exports.configureTokenUsage = _chunkCAKOFJZDjs.configureTokenUsage; exports.createUsageFormatters = _chunkGKDHYB2Rjs.createUsageFormatters; exports.getTokenUsageCurrency = _chunkCAKOFJZDjs.getTokenUsageCurrency; exports.tokenUsageModules = _chunkCAKOFJZDjs.tokenUsageModules; exports.useTokenUsageAdmin = useTokenUsageAdmin; exports.useTokenUsageReport = useTokenUsageReport; exports.useUsageFormatters = _chunkGKDHYB2Rjs.useUsageFormatters;
|
|
1297
1297
|
//# sourceMappingURL=index.js.map
|