@carlonicora/nextjs-jsonapi 3.24.2 → 3.25.0
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/{AssistantMessageInterface-1Kbz8RVs.d.ts → AssistantMessageInterface-CubxuBIJ.d.ts} +1 -1
- package/dist/{AssistantMessageInterface-CoxJyuFM.d.mts → AssistantMessageInterface-sHjI2zPN.d.mts} +1 -1
- package/dist/{BlockNoteEditor-65HR6ULV.mjs → BlockNoteEditor-46O3JC4Z.mjs} +5 -5
- package/dist/{BlockNoteEditor-35D4R7HJ.js → BlockNoteEditor-HKS6AXDA.js} +20 -20
- package/dist/{BlockNoteEditor-35D4R7HJ.js.map → BlockNoteEditor-HKS6AXDA.js.map} +1 -1
- package/dist/{BlockNoteViewer-QDXDVYEM.js → BlockNoteViewer-7BFNTN4E.js} +4 -4
- package/dist/{BlockNoteViewer-QDXDVYEM.js.map → BlockNoteViewer-7BFNTN4E.js.map} +1 -1
- package/dist/{BlockNoteViewer-KDKGUIG5.mjs → BlockNoteViewer-KRTAFTUX.mjs} +3 -3
- package/dist/{HandbookSectionInterface-OePKPbqN.d.ts → HandbookSectionInterface-Ck1wZJ81.d.ts} +1 -1
- package/dist/{HandbookSectionInterface-BYsmnPEz.d.mts → HandbookSectionInterface-DgYH--Ik.d.mts} +1 -1
- package/dist/JsonApiRequest-TE5WD3WS.js +26 -0
- package/dist/{JsonApiRequest-G625QAH5.js.map → JsonApiRequest-TE5WD3WS.js.map} +1 -1
- package/dist/{JsonApiRequest-RRMNV7YE.mjs → JsonApiRequest-UHOWNI3O.mjs} +2 -2
- package/dist/analytics.modules-CfczU12P.d.ts +25 -0
- package/dist/analytics.modules-pzGwMASI.d.mts +25 -0
- package/dist/{auth.interface-BC1jp_ni.d.ts → auth.interface-BzI4onI_.d.ts} +1 -1
- package/dist/{auth.interface-dR2-6gPM.d.mts → auth.interface-Df4vXbNz.d.mts} +1 -1
- package/dist/billing/index.js +402 -402
- package/dist/billing/index.mjs +4 -4
- package/dist/{chunk-YXRVPEEJ.js → chunk-26MQIJNB.js} +1 -1
- package/dist/{chunk-YXRVPEEJ.js.map → chunk-26MQIJNB.js.map} +1 -1
- package/dist/{chunk-T76WLDE5.mjs → chunk-37DMFVLN.mjs} +1 -1
- package/dist/chunk-4Z2UONN2.mjs +110 -0
- package/dist/chunk-4Z2UONN2.mjs.map +1 -0
- package/dist/{chunk-3AR4KA5D.js → chunk-4Z45NYPR.js} +13 -13
- package/dist/{chunk-3AR4KA5D.js.map → chunk-4Z45NYPR.js.map} +1 -1
- package/dist/chunk-7B4E42R5.mjs +280 -0
- package/dist/chunk-7B4E42R5.mjs.map +1 -0
- package/dist/{chunk-U7QVISQS.js → chunk-CAKOFJZD.js} +450 -40
- package/dist/chunk-CAKOFJZD.js.map +1 -0
- package/dist/{chunk-IBVKPLHT.mjs → chunk-E3I4MT53.mjs} +422 -12
- package/dist/chunk-E3I4MT53.mjs.map +1 -0
- package/dist/chunk-GHFMKH3M.js +280 -0
- package/dist/chunk-GHFMKH3M.js.map +1 -0
- package/dist/chunk-KLV6RLDE.js +110 -0
- package/dist/chunk-KLV6RLDE.js.map +1 -0
- package/dist/{chunk-ZJI5ZZW5.mjs → chunk-Q6J2ICKO.mjs} +3 -3
- package/dist/{chunk-4O7R2Z2O.mjs → chunk-XDYILJ2S.mjs} +1749 -1737
- package/dist/{chunk-4O7R2Z2O.mjs.map → chunk-XDYILJ2S.mjs.map} +1 -1
- package/dist/{chunk-2XCUAHQT.js → chunk-Y3OKEQGL.js} +1126 -1114
- package/dist/chunk-Y3OKEQGL.js.map +1 -0
- package/dist/client/index.d.mts +6 -5
- package/dist/client/index.d.ts +6 -5
- package/dist/client/index.js +5 -5
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +4 -4
- package/dist/components/index.d.mts +17 -7
- package/dist/components/index.d.ts +17 -7
- package/dist/components/index.js +5 -5
- package/dist/components/index.mjs +4 -4
- package/dist/{config-B6UB7j69.d.ts → config-3N1LSrcC.d.ts} +1 -1
- package/dist/{config-Cd5xTEfZ.d.ts → config-AVtuvfM1.d.ts} +1 -1
- package/dist/{config-n-ZpPmOL.d.mts → config-BSKTYDoh.d.mts} +1 -1
- package/dist/{config-YyhFHxkU.d.mts → config-BmufyEj6.d.mts} +1 -1
- package/dist/contexts/index.d.mts +5 -4
- package/dist/contexts/index.d.ts +5 -4
- package/dist/contexts/index.js +5 -5
- package/dist/contexts/index.mjs +4 -4
- package/dist/core/index.d.mts +31 -14
- package/dist/core/index.d.ts +31 -14
- package/dist/core/index.js +9 -5
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +8 -4
- package/dist/features/analytics/index.css +30 -0
- package/dist/features/analytics/index.css.map +1 -0
- package/dist/features/analytics/index.d.mts +508 -0
- package/dist/features/analytics/index.d.ts +508 -0
- package/dist/features/analytics/index.js +1166 -0
- package/dist/features/analytics/index.js.map +1 -0
- package/dist/features/analytics/index.mjs +1166 -0
- package/dist/features/analytics/index.mjs.map +1 -0
- package/dist/features/analytics/server.d.mts +28 -0
- package/dist/features/analytics/server.d.ts +28 -0
- package/dist/features/analytics/server.js +41 -0
- package/dist/features/analytics/server.js.map +1 -0
- package/dist/features/analytics/server.mjs +41 -0
- package/dist/features/analytics/server.mjs.map +1 -0
- package/dist/features/help/index.d.mts +2 -2
- package/dist/features/help/index.d.ts +2 -2
- package/dist/features/help/index.js +38 -38
- package/dist/features/help/index.mjs +4 -4
- package/dist/features/tokenusage/index.d.mts +2 -2
- package/dist/features/tokenusage/index.d.ts +2 -2
- package/dist/features/tokenusage/index.js +139 -221
- package/dist/features/tokenusage/index.js.map +1 -1
- package/dist/features/tokenusage/index.mjs +26 -108
- package/dist/features/tokenusage/index.mjs.map +1 -1
- package/dist/index.d.mts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -5
- package/dist/notification.interface-BNCvnVCW.d.ts +34 -0
- package/dist/notification.interface-P_pNfzZQ.d.mts +34 -0
- package/dist/{s3.service-Bqr-fQmi.d.ts → s3.service-CbUa6a-8.d.ts} +3 -2
- package/dist/{s3.service-Buiy1ncj.d.mts → s3.service-DAp8FbuG.d.mts} +3 -2
- package/dist/server/index.d.mts +5 -4
- package/dist/server/index.d.ts +5 -4
- package/dist/server/index.js +39 -279
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +20 -260
- package/dist/server/index.mjs.map +1 -1
- package/dist/{types-bsm8Fp55.d.ts → types-Cn153-mH.d.ts} +1 -1
- package/dist/{types-Bq_UA8Lg.d.mts → types-D0uLYV2P.d.mts} +1 -1
- package/dist/{usePageUrlGenerator-J_ECv-oQ.d.ts → usePageUrlGenerator-B-3FRKBD.d.ts} +1 -1
- package/dist/{usePageUrlGenerator-uKBjAKqC.d.mts → usePageUrlGenerator-CCJ_cdQy.d.mts} +1 -1
- package/dist/{useSocket-BcH7l7B8.d.mts → useSocket-B9gTbuCj.d.mts} +1 -1
- package/dist/{useSocket-DCZd_eJk.d.ts → useSocket-BHVIyigI.d.ts} +1 -1
- package/dist/{notification.interface-MnRt1Tjm.d.mts → user.interface-CSaGWFbg.d.mts} +1 -31
- package/dist/{notification.interface-CjzV_KII.d.ts → user.interface-CrmwJLYW.d.ts} +1 -31
- package/package.json +11 -1
- package/src/client/index.ts +2 -0
- package/src/core/index.ts +4 -0
- package/src/core/registry/ModuleRegistry.ts +7 -0
- package/src/features/__tests__/i18n-keys.contract.spec.ts +1 -0
- package/src/features/analytics/__tests__/server-entry.spec.tsx +64 -0
- package/src/features/analytics/analytics.modules.ts +30 -0
- package/src/features/analytics/components/AnalyticsAdminContainer.tsx +97 -0
- package/src/features/analytics/components/AnalyticsAdminFilterBar.tsx +117 -0
- package/src/features/analytics/components/AnalyticsAdminPageContainer.tsx +25 -0
- package/src/features/analytics/components/AnalyticsAdminTiles.tsx +191 -0
- package/src/features/analytics/components/AnalyticsBreakdownTable.tsx +104 -0
- package/src/features/analytics/components/AnalyticsJourneyContainer.tsx +246 -0
- package/src/features/analytics/components/AnalyticsJourneyPageContainer.tsx +14 -0
- package/src/features/analytics/components/AnalyticsSessionsTable.tsx +107 -0
- package/src/features/analytics/components/AnalyticsTimelineChart.tsx +175 -0
- package/src/features/analytics/components/AnalyticsTracker.tsx +112 -0
- package/src/features/analytics/components/__tests__/AnalyticsAdminTiles.spec.tsx +39 -0
- package/src/features/analytics/components/__tests__/AnalyticsBreakdownTable.spec.tsx +39 -0
- package/src/features/analytics/components/__tests__/AnalyticsJourneyContainer.spec.tsx +124 -0
- package/src/features/analytics/components/__tests__/AnalyticsPageContainers.spec.tsx +117 -0
- package/src/features/analytics/components/__tests__/AnalyticsSessionsTable.spec.tsx +121 -0
- package/src/features/analytics/components/__tests__/AnalyticsTimelineChart.spec.tsx +35 -0
- package/src/features/analytics/components/__tests__/AnalyticsTracker.spec.tsx +248 -0
- package/src/features/analytics/components/server/AnalyticsAdminPage.tsx +28 -0
- package/src/features/analytics/components/server/AnalyticsJourneyPage.tsx +25 -0
- package/src/features/analytics/contexts/AnalyticsAdminContext.tsx +273 -0
- package/src/features/analytics/contexts/__tests__/AnalyticsAdminContext.spec.tsx +140 -0
- package/src/features/analytics/data/AnalyticsAdminService.ts +91 -0
- package/src/features/analytics/data/AnalyticsService.ts +23 -0
- package/src/features/analytics/data/__tests__/AnalyticsAdminService.spec.ts +117 -0
- package/src/features/analytics/data/__tests__/AnalyticsService.spec.ts +56 -0
- package/src/features/analytics/data/__tests__/models.spec.ts +300 -0
- package/src/features/analytics/data/analytics-breakdown.interface.ts +9 -0
- package/src/features/analytics/data/analytics-breakdown.ts +65 -0
- package/src/features/analytics/data/analytics-event.interface.ts +7 -0
- package/src/features/analytics/data/analytics-event.ts +63 -0
- package/src/features/analytics/data/analytics-page-view.interface.ts +9 -0
- package/src/features/analytics/data/analytics-page-view.ts +57 -0
- package/src/features/analytics/data/analytics-session.interface.ts +23 -0
- package/src/features/analytics/data/analytics-session.ts +144 -0
- package/src/features/analytics/data/analytics-summary.interface.ts +11 -0
- package/src/features/analytics/data/analytics-summary.ts +79 -0
- package/src/features/analytics/data/analytics-timeline.interface.ts +10 -0
- package/src/features/analytics/data/analytics-timeline.ts +67 -0
- package/src/features/analytics/data/analytics.types.ts +97 -0
- package/src/features/analytics/data/index.ts +15 -0
- package/src/features/analytics/i18n-keys.ts +76 -0
- package/src/features/analytics/index.ts +31 -0
- package/src/features/analytics/lib/__tests__/utm.spec.ts +20 -0
- package/src/features/analytics/lib/__tests__/visitorCookie.spec.ts +63 -0
- package/src/features/analytics/lib/utm.ts +29 -0
- package/src/features/analytics/lib/visitorCookie.ts +32 -0
- package/src/features/analytics/server-entry.ts +8 -0
- package/src/features/waitlist/components/lists/WaitlistList.tsx +68 -121
- package/src/features/waitlist/data/WaitlistService.ts +2 -2
- package/src/features/waitlist/data/index.ts +1 -0
- package/src/features/waitlist/data/waitlist.fields.ts +8 -0
- package/src/features/waitlist/hooks/useWaitlistTableStructure.tsx +69 -30
- package/dist/JsonApiRequest-G625QAH5.js +0 -26
- package/dist/chunk-2XCUAHQT.js.map +0 -1
- package/dist/chunk-IBVKPLHT.mjs.map +0 -1
- package/dist/chunk-U7QVISQS.js.map +0 -1
- /package/dist/{BlockNoteEditor-65HR6ULV.mjs.map → BlockNoteEditor-46O3JC4Z.mjs.map} +0 -0
- /package/dist/{BlockNoteViewer-KDKGUIG5.mjs.map → BlockNoteViewer-KRTAFTUX.mjs.map} +0 -0
- /package/dist/{JsonApiRequest-RRMNV7YE.mjs.map → JsonApiRequest-UHOWNI3O.mjs.map} +0 -0
- /package/dist/{chunk-T76WLDE5.mjs.map → chunk-37DMFVLN.mjs.map} +0 -0
- /package/dist/{chunk-ZJI5ZZW5.mjs.map → chunk-Q6J2ICKO.mjs.map} +0 -0
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
CATEGORICAL_CEILING,
|
|
4
|
+
OTHER_COLOR,
|
|
5
|
+
SEQUENTIAL_RAMP,
|
|
6
|
+
cacheHitPercentage,
|
|
7
|
+
createUsageFormatters,
|
|
8
|
+
metricValue,
|
|
9
|
+
percentageDelta,
|
|
10
|
+
seriesColor,
|
|
11
|
+
useUsageFormatters
|
|
12
|
+
} from "../../chunk-4Z2UONN2.mjs";
|
|
2
13
|
import {
|
|
3
14
|
Button,
|
|
4
15
|
Card,
|
|
@@ -26,8 +37,8 @@ import {
|
|
|
26
37
|
TableHeader,
|
|
27
38
|
TableRow,
|
|
28
39
|
usePageUrlGenerator
|
|
29
|
-
} from "../../chunk-
|
|
30
|
-
import "../../chunk-
|
|
40
|
+
} from "../../chunk-XDYILJ2S.mjs";
|
|
41
|
+
import "../../chunk-Q6J2ICKO.mjs";
|
|
31
42
|
import {
|
|
32
43
|
AbstractService,
|
|
33
44
|
EndpointCreator,
|
|
@@ -45,10 +56,10 @@ import {
|
|
|
45
56
|
configureTokenUsage,
|
|
46
57
|
getTokenUsageCurrency,
|
|
47
58
|
tokenUsageModules
|
|
48
|
-
} from "../../chunk-
|
|
59
|
+
} from "../../chunk-E3I4MT53.mjs";
|
|
60
|
+
import "../../chunk-37DMFVLN.mjs";
|
|
49
61
|
import "../../chunk-AUXK7QSA.mjs";
|
|
50
62
|
import "../../chunk-PI56A4DG.mjs";
|
|
51
|
-
import "../../chunk-T76WLDE5.mjs";
|
|
52
63
|
import "../../chunk-VOXD3ZLY.mjs";
|
|
53
64
|
import {
|
|
54
65
|
__name
|
|
@@ -349,74 +360,11 @@ var useTokenUsageAdmin = /* @__PURE__ */ __name(() => {
|
|
|
349
360
|
|
|
350
361
|
// src/features/tokenusage/components/TokenUsageAdminContainer.tsx
|
|
351
362
|
import { useTranslations as useTranslations7 } from "next-intl";
|
|
352
|
-
import { useMemo as
|
|
363
|
+
import { useMemo as useMemo4 } from "react";
|
|
353
364
|
|
|
354
365
|
// src/features/tokenusage/components/TokenUsageAdminTiles.tsx
|
|
355
366
|
import { ArrowDownIcon, ArrowUpIcon } from "lucide-react";
|
|
356
367
|
import { useTranslations as useTranslations3 } from "next-intl";
|
|
357
|
-
|
|
358
|
-
// src/features/tokenusage/lib/formatters.ts
|
|
359
|
-
import { useLocale } from "next-intl";
|
|
360
|
-
import { useMemo as useMemo2 } from "react";
|
|
361
|
-
function createUsageFormatters(locale, currency) {
|
|
362
|
-
const symbol = new Intl.NumberFormat(locale, { style: "currency", currency, currencyDisplay: "narrowSymbol" }).formatToParts(0).find((part) => part.type === "currency")?.value ?? currency;
|
|
363
|
-
const decimal = /* @__PURE__ */ __name((value, decimals) => value.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }), "decimal");
|
|
364
|
-
const dayFormat = new Intl.DateTimeFormat(locale, { day: "numeric", month: "short", timeZone: "UTC" });
|
|
365
|
-
const monthFormat = new Intl.DateTimeFormat(locale, { month: "short", year: "numeric", timeZone: "UTC" });
|
|
366
|
-
const compactFormat = new Intl.NumberFormat(locale, { notation: "compact", maximumFractionDigits: 1 });
|
|
367
|
-
const collator = new Intl.Collator(locale);
|
|
368
|
-
return {
|
|
369
|
-
decimal,
|
|
370
|
-
metricValue(value, metric) {
|
|
371
|
-
if (metric === "cost") return `${symbol} ${decimal(value, 2)}`;
|
|
372
|
-
if (metric === "credits") return decimal(value, 1);
|
|
373
|
-
return decimal(value, 0);
|
|
374
|
-
},
|
|
375
|
-
currency(value, decimals) {
|
|
376
|
-
return `${symbol} ${decimal(value, decimals)}`;
|
|
377
|
-
},
|
|
378
|
-
percent(value, decimals = 1) {
|
|
379
|
-
return `${decimal(value, decimals)} %`;
|
|
380
|
-
},
|
|
381
|
-
compact(value) {
|
|
382
|
-
return compactFormat.format(value);
|
|
383
|
-
},
|
|
384
|
-
bucketDate(iso, granularity) {
|
|
385
|
-
const date = /* @__PURE__ */ new Date(`${iso}T00:00:00.000Z`);
|
|
386
|
-
return granularity === "month" ? monthFormat.format(date) : dayFormat.format(date);
|
|
387
|
-
},
|
|
388
|
-
compare(a, b) {
|
|
389
|
-
return collator.compare(a, b);
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
__name(createUsageFormatters, "createUsageFormatters");
|
|
394
|
-
function useUsageFormatters() {
|
|
395
|
-
const locale = useLocale();
|
|
396
|
-
const currency = getTokenUsageCurrency();
|
|
397
|
-
return useMemo2(() => createUsageFormatters(locale, currency), [locale, currency]);
|
|
398
|
-
}
|
|
399
|
-
__name(useUsageFormatters, "useUsageFormatters");
|
|
400
|
-
|
|
401
|
-
// src/features/tokenusage/lib/metrics.ts
|
|
402
|
-
function metricValue(row, metric) {
|
|
403
|
-
if (metric === "cost") return row.cost;
|
|
404
|
-
if (metric === "credits") return row.credits;
|
|
405
|
-
return row.tokensIn + row.tokensOut;
|
|
406
|
-
}
|
|
407
|
-
__name(metricValue, "metricValue");
|
|
408
|
-
function cacheHitPercentage(cached, tokensIn) {
|
|
409
|
-
if (!tokensIn) return 0;
|
|
410
|
-
return cached / tokensIn * 100;
|
|
411
|
-
}
|
|
412
|
-
__name(cacheHitPercentage, "cacheHitPercentage");
|
|
413
|
-
function percentageDelta(current, previous) {
|
|
414
|
-
if (!previous) return void 0;
|
|
415
|
-
return Math.round((current - previous) / previous * 100);
|
|
416
|
-
}
|
|
417
|
-
__name(percentageDelta, "percentageDelta");
|
|
418
|
-
|
|
419
|
-
// src/features/tokenusage/components/TokenUsageAdminTiles.tsx
|
|
420
368
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
421
369
|
var ZERO = { cost: 0, credits: 0, tokensIn: 0, tokensOut: 0, cached: 0, calls: 0 };
|
|
422
370
|
function TokenUsageAdminTiles({ summary, metric, singleCustomerMode }) {
|
|
@@ -554,14 +502,14 @@ __name(Delta, "Delta");
|
|
|
554
502
|
// src/features/tokenusage/components/TokenUsageBreakdownTable.tsx
|
|
555
503
|
import { ArrowDownIcon as ArrowDownIcon2, ArrowUpIcon as ArrowUpIcon2 } from "lucide-react";
|
|
556
504
|
import { useTranslations as useTranslations4 } from "next-intl";
|
|
557
|
-
import { useMemo as
|
|
505
|
+
import { useMemo as useMemo2, useState as useState2 } from "react";
|
|
558
506
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
559
507
|
function TokenUsageBreakdownTable({ rows, metric }) {
|
|
560
508
|
const t = useTranslations4();
|
|
561
509
|
const { decimal, metricValue: formatValue, percent, compare } = useUsageFormatters();
|
|
562
510
|
const [sort, setSort] = useState2(void 0);
|
|
563
511
|
const showActiveUsers = rows.some((row) => row.activeUsers !== void 0);
|
|
564
|
-
const total =
|
|
512
|
+
const total = useMemo2(() => rows.reduce((sum, row) => sum + metricValue(row, metric), 0), [rows, metric]);
|
|
565
513
|
const sortValue = /* @__PURE__ */ __name((row, key) => {
|
|
566
514
|
switch (key) {
|
|
567
515
|
case "label":
|
|
@@ -578,7 +526,7 @@ function TokenUsageBreakdownTable({ rows, metric }) {
|
|
|
578
526
|
return row[key];
|
|
579
527
|
}
|
|
580
528
|
}, "sortValue");
|
|
581
|
-
const sortedRows =
|
|
529
|
+
const sortedRows = useMemo2(() => {
|
|
582
530
|
if (!sort) return rows;
|
|
583
531
|
const factor = sort.direction === "desc" ? -1 : 1;
|
|
584
532
|
return [...rows].sort((a, b) => {
|
|
@@ -665,36 +613,6 @@ var operationLabel = /* @__PURE__ */ __name((type, translate, has) => {
|
|
|
665
613
|
return has(key) ? translate(key) : type;
|
|
666
614
|
}, "operationLabel");
|
|
667
615
|
|
|
668
|
-
// src/features/tokenusage/lib/palette.ts
|
|
669
|
-
var CATEGORICAL_LIGHT = [
|
|
670
|
-
"#2a78d6",
|
|
671
|
-
"#eb6834",
|
|
672
|
-
"#1baf7a",
|
|
673
|
-
"#eda100",
|
|
674
|
-
"#e87ba4",
|
|
675
|
-
"#008300",
|
|
676
|
-
"#4a3aa7"
|
|
677
|
-
];
|
|
678
|
-
var CATEGORICAL_DARK = [
|
|
679
|
-
"#3987e5",
|
|
680
|
-
"#d95926",
|
|
681
|
-
"#199e70",
|
|
682
|
-
"#c98500",
|
|
683
|
-
"#d55181",
|
|
684
|
-
"#008300",
|
|
685
|
-
"#9085e9"
|
|
686
|
-
];
|
|
687
|
-
var CATEGORICAL_CEILING = CATEGORICAL_LIGHT.length;
|
|
688
|
-
var OTHER_COLOR = "#898781";
|
|
689
|
-
var SEQUENTIAL_RAMP_LIGHT = ["#104281", "#1c5cab", "#2a78d6", "#5598e7", "#86b6ef"];
|
|
690
|
-
var SEQUENTIAL_RAMP = SEQUENTIAL_RAMP_LIGHT;
|
|
691
|
-
var categoricalSet = /* @__PURE__ */ __name((mode) => mode === "dark" ? CATEGORICAL_DARK : CATEGORICAL_LIGHT, "categoricalSet");
|
|
692
|
-
function seriesColor(index, mode = "light") {
|
|
693
|
-
if (index < 0 || index >= CATEGORICAL_CEILING) return OTHER_COLOR;
|
|
694
|
-
return categoricalSet(mode)[index];
|
|
695
|
-
}
|
|
696
|
-
__name(seriesColor, "seriesColor");
|
|
697
|
-
|
|
698
616
|
// src/features/tokenusage/components/TokenUsageRankedBar.tsx
|
|
699
617
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
700
618
|
function TokenUsageRankedBar({ rows, metric, emptyLabel, labelsAreOperationTypes = false }) {
|
|
@@ -751,7 +669,7 @@ __name(TokenUsageRankedBar, "TokenUsageRankedBar");
|
|
|
751
669
|
// src/features/tokenusage/components/TokenUsageTimelineChart.tsx
|
|
752
670
|
import { useTranslations as useTranslations6 } from "next-intl";
|
|
753
671
|
import { useTheme } from "next-themes";
|
|
754
|
-
import { useMemo as
|
|
672
|
+
import { useMemo as useMemo3 } from "react";
|
|
755
673
|
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts";
|
|
756
674
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
757
675
|
var OTHER_SERIES = "other";
|
|
@@ -783,7 +701,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
|
|
|
783
701
|
const { compact, bucketDate, metricValue: formatValue } = useUsageFormatters();
|
|
784
702
|
const { resolvedTheme } = useTheme();
|
|
785
703
|
const mode = resolvedTheme === "dark" ? "dark" : "light";
|
|
786
|
-
const { chartData, seriesKeys } =
|
|
704
|
+
const { chartData, seriesKeys } = useMemo3(() => {
|
|
787
705
|
if (rows.length === 0) return { chartData: [], seriesKeys: [] };
|
|
788
706
|
const totals = /* @__PURE__ */ new Map();
|
|
789
707
|
for (const row of rows) totals.set(row.series, (totals.get(row.series) ?? 0) + metricValue2(row, metric));
|
|
@@ -820,7 +738,7 @@ function TokenUsageTimelineChart({ rows, metric, stackBy, className }) {
|
|
|
820
738
|
(key) => t.has(key)
|
|
821
739
|
);
|
|
822
740
|
}, "seriesLabel");
|
|
823
|
-
const chartConfig =
|
|
741
|
+
const chartConfig = useMemo3(
|
|
824
742
|
() => Object.fromEntries(seriesKeys.map((series) => [series, { label: seriesLabel(series) }])),
|
|
825
743
|
[seriesKeys, stackBy]
|
|
826
744
|
);
|
|
@@ -912,12 +830,12 @@ function TokenUsageAdminContainer() {
|
|
|
912
830
|
isLoading,
|
|
913
831
|
error
|
|
914
832
|
} = useTokenUsageAdmin();
|
|
915
|
-
const platformIsEmpty =
|
|
833
|
+
const platformIsEmpty = useMemo4(
|
|
916
834
|
() => summary.filter((row) => row.scope === "platform").every((row) => row.cost === 0 && row.credits === 0 && row.tokensIn === 0 && row.tokensOut === 0),
|
|
917
835
|
[summary]
|
|
918
836
|
);
|
|
919
837
|
const hidePlatform = singleCustomerMode || platformIsEmpty;
|
|
920
|
-
const stackByItems =
|
|
838
|
+
const stackByItems = useMemo4(
|
|
921
839
|
() => ({
|
|
922
840
|
scope: t("token_usage.admin.stack.scope"),
|
|
923
841
|
type: t("token_usage.admin.stack.type"),
|
|
@@ -1108,7 +1026,7 @@ var TOKEN_USAGE_REPORT_I18N_KEYS = [
|
|
|
1108
1026
|
|
|
1109
1027
|
// src/features/tokenusage/contexts/TokenUsageReportContext.tsx
|
|
1110
1028
|
import { useTranslations as useTranslations8 } from "next-intl";
|
|
1111
|
-
import { createContext as createContext2, useCallback as useCallback2, useContext as useContext2, useEffect as useEffect2, useMemo as
|
|
1029
|
+
import { createContext as createContext2, useCallback as useCallback2, useContext as useContext2, useEffect as useEffect2, useMemo as useMemo5, useState as useState3 } from "react";
|
|
1112
1030
|
|
|
1113
1031
|
// src/features/tokenusage/components/TokenUsageReportFilterBar.tsx
|
|
1114
1032
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
@@ -1207,7 +1125,7 @@ var TokenUsageReportProvider = /* @__PURE__ */ __name(({
|
|
|
1207
1125
|
type: t("token_usage.report.title"),
|
|
1208
1126
|
functions: /* @__PURE__ */ jsx9(TokenUsageReportFilterBar, { onChange: setFilters }, "tokenUsageReportFilterBar")
|
|
1209
1127
|
}), "title");
|
|
1210
|
-
const contextValue =
|
|
1128
|
+
const contextValue = useMemo5(
|
|
1211
1129
|
() => ({ summary, timeline, byOperation, byTarget, targetPanelTitleKey, filters, setFilters, isLoading, error }),
|
|
1212
1130
|
[summary, timeline, byOperation, byTarget, targetPanelTitleKey, filters, setFilters, isLoading, error]
|
|
1213
1131
|
);
|