@carlonicora/nextjs-jsonapi 1.141.3 → 1.143.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.
Files changed (117) hide show
  1. package/dist/AbstractService-B0T7h8fX.d.mts +124 -0
  2. package/dist/AbstractService-Cew0PD0L.d.ts +124 -0
  3. package/dist/{AssistantMessageInterface-DH1QwtC_.d.mts → AssistantMessageInterface-Ce8FcllX.d.mts} +1 -1
  4. package/dist/{AssistantMessageInterface-giWvsOrX.d.ts → AssistantMessageInterface-Dh0BpbP2.d.ts} +1 -1
  5. package/dist/{AuthComponent-DdxCFgUZ.d.mts → AuthComponent-Cik96ElA.d.mts} +1 -1
  6. package/dist/{AuthComponent-Cd7lcYif.d.ts → AuthComponent-DTTKu3VK.d.ts} +1 -1
  7. package/dist/{BlockNoteEditor-JTKEBS2W.mjs → BlockNoteEditor-34QM4UR5.mjs} +4 -4
  8. package/dist/{BlockNoteEditor-4OXY6BKF.js → BlockNoteEditor-LMKWUOJG.js} +19 -19
  9. package/dist/{BlockNoteEditor-4OXY6BKF.js.map → BlockNoteEditor-LMKWUOJG.js.map} +1 -1
  10. package/dist/{auth.interface-yivTb46w.d.ts → auth.interface-COmBjh89.d.ts} +1 -1
  11. package/dist/{auth.interface-r3XKYOrQ.d.mts → auth.interface-CkmZqat3.d.mts} +1 -1
  12. package/dist/billing/index.js +357 -357
  13. package/dist/billing/index.mjs +3 -3
  14. package/dist/{chunk-5GVY2M5X.mjs → chunk-BIL2WQEV.mjs} +264 -18
  15. package/dist/chunk-BIL2WQEV.mjs.map +1 -0
  16. package/dist/{chunk-AGKZCRG2.js → chunk-DS4IBFWA.js} +269 -23
  17. package/dist/chunk-DS4IBFWA.js.map +1 -0
  18. package/dist/{chunk-4TGGHNWL.js → chunk-F6PZZ4KI.js} +752 -752
  19. package/dist/chunk-F6PZZ4KI.js.map +1 -0
  20. package/dist/{chunk-KXTTYXJ6.mjs → chunk-HN5ED7OF.mjs} +2 -2
  21. package/dist/{chunk-K76QSQTC.mjs → chunk-UGSOBBZH.mjs} +28 -28
  22. package/dist/chunk-UGSOBBZH.mjs.map +1 -0
  23. package/dist/{chunk-SE2YSAER.js → chunk-UXJAS6C5.js} +7 -7
  24. package/dist/{chunk-SE2YSAER.js.map → chunk-UXJAS6C5.js.map} +1 -1
  25. package/dist/client/index.d.mts +5 -5
  26. package/dist/client/index.d.ts +5 -5
  27. package/dist/client/index.js +4 -4
  28. package/dist/client/index.mjs +3 -3
  29. package/dist/components/index.d.mts +6 -6
  30. package/dist/components/index.d.ts +6 -6
  31. package/dist/components/index.js +4 -4
  32. package/dist/components/index.mjs +3 -3
  33. package/dist/{config-BrkU_Ynz.d.ts → config-Cd5xTEfZ.d.ts} +1 -1
  34. package/dist/{config-snd2ToEB.d.mts → config-YyhFHxkU.d.mts} +1 -1
  35. package/dist/contexts/index.d.mts +4 -4
  36. package/dist/contexts/index.d.ts +4 -4
  37. package/dist/contexts/index.js +4 -4
  38. package/dist/contexts/index.mjs +3 -3
  39. package/dist/core/index.d.mts +24 -60
  40. package/dist/core/index.d.ts +24 -60
  41. package/dist/core/index.js +8 -2
  42. package/dist/core/index.js.map +1 -1
  43. package/dist/core/index.mjs +7 -1
  44. package/dist/features/help/index.d.mts +2 -2
  45. package/dist/features/help/index.d.ts +2 -2
  46. package/dist/features/help/index.js +37 -37
  47. package/dist/features/help/index.mjs +3 -3
  48. package/dist/features/tokenusage/index.css +29 -0
  49. package/dist/features/tokenusage/index.css.map +1 -0
  50. package/dist/features/tokenusage/index.d.mts +388 -0
  51. package/dist/features/tokenusage/index.d.ts +388 -0
  52. package/dist/features/tokenusage/index.js +1012 -0
  53. package/dist/features/tokenusage/index.js.map +1 -0
  54. package/dist/features/tokenusage/index.mjs +1012 -0
  55. package/dist/features/tokenusage/index.mjs.map +1 -0
  56. package/dist/index.d.mts +11 -9
  57. package/dist/index.d.ts +11 -9
  58. package/dist/index.js +9 -3
  59. package/dist/index.js.map +1 -1
  60. package/dist/index.mjs +8 -2
  61. package/dist/{notification.interface-LKFmZndR.d.ts → notification.interface--27exGde.d.ts} +6 -6
  62. package/dist/{notification.interface-B3kNUTZs.d.mts → notification.interface-CG1vqoxg.d.mts} +6 -6
  63. package/dist/{s3.service-BrmeMjtk.d.ts → s3.service-CpwA3sl_.d.ts} +4 -125
  64. package/dist/{s3.service-CXKV_OT-.d.mts → s3.service-Dt6MfuHr.d.mts} +4 -125
  65. package/dist/server/index.d.mts +5 -4
  66. package/dist/server/index.d.ts +5 -4
  67. package/dist/server/index.js +3 -3
  68. package/dist/server/index.mjs +1 -1
  69. package/dist/tokenusage-admin.module-5wJ_tZTj.d.ts +61 -0
  70. package/dist/tokenusage-admin.module-DQVT4O4j.d.mts +61 -0
  71. package/dist/{types-CQSjy7et.d.mts → types-Bq_UA8Lg.d.mts} +1 -1
  72. package/dist/{types-DHOxe8rc.d.ts → types-bsm8Fp55.d.ts} +1 -1
  73. package/dist/{usePageUrlGenerator-tjq2mlDV.d.ts → usePageUrlGenerator-J_ECv-oQ.d.ts} +1 -1
  74. package/dist/{usePageUrlGenerator-uOnyJ6j2.d.mts → usePageUrlGenerator-uKBjAKqC.d.mts} +1 -1
  75. package/dist/{useSocket-BsbaGPqE.d.ts → useSocket-DgGAQW6h.d.ts} +1 -1
  76. package/dist/{useSocket-BSjn1Rlb.d.mts → useSocket-M3YY0aTS.d.mts} +1 -1
  77. package/package.json +6 -1
  78. package/src/core/index.ts +5 -0
  79. package/src/core/registry/ModuleRegistry.ts +4 -0
  80. package/src/features/company/components/details/TokenStatusIndicator.tsx +9 -9
  81. package/src/features/company/data/company.interface.ts +6 -6
  82. package/src/features/company/data/company.ts +17 -17
  83. package/src/features/tokenusage/components/TokenUsageAdminContainer.tsx +189 -0
  84. package/src/features/tokenusage/components/TokenUsageAdminFilterBar.tsx +138 -0
  85. package/src/features/tokenusage/components/TokenUsageAdminTiles.tsx +177 -0
  86. package/src/features/tokenusage/components/TokenUsageBreakdownTable.tsx +160 -0
  87. package/src/features/tokenusage/components/TokenUsageRankedBar.tsx +99 -0
  88. package/src/features/tokenusage/components/TokenUsageTimelineChart.tsx +225 -0
  89. package/src/features/tokenusage/components/__tests__/TokenUsageAdminTiles.spec.tsx +42 -0
  90. package/src/features/tokenusage/components/__tests__/TokenUsageRankedBar.spec.tsx +41 -0
  91. package/src/features/tokenusage/components/__tests__/TokenUsageTimelineChart.spec.tsx +47 -0
  92. package/src/features/tokenusage/contexts/TokenUsageAdminContext.tsx +252 -0
  93. package/src/features/tokenusage/contexts/__tests__/TokenUsageAdminContext.spec.tsx +80 -0
  94. package/src/features/tokenusage/data/TokenUsageAdminService.ts +54 -0
  95. package/src/features/tokenusage/data/__tests__/tokenusage-admin-models.spec.ts +147 -0
  96. package/src/features/tokenusage/data/index.ts +8 -0
  97. package/src/features/tokenusage/data/tokenusage-admin-breakdown.interface.ts +18 -0
  98. package/src/features/tokenusage/data/tokenusage-admin-breakdown.ts +115 -0
  99. package/src/features/tokenusage/data/tokenusage-admin-summary.interface.ts +14 -0
  100. package/src/features/tokenusage/data/tokenusage-admin-summary.ts +90 -0
  101. package/src/features/tokenusage/data/tokenusage-admin-timeline.interface.ts +13 -0
  102. package/src/features/tokenusage/data/tokenusage-admin-timeline.ts +94 -0
  103. package/src/features/tokenusage/data/tokenusage-admin.types.ts +56 -0
  104. package/src/features/tokenusage/i18n-keys.ts +65 -0
  105. package/src/features/tokenusage/index.ts +30 -0
  106. package/src/features/tokenusage/lib/metrics.ts +69 -0
  107. package/src/features/tokenusage/lib/operation-label.ts +41 -0
  108. package/src/features/tokenusage/lib/palette.ts +197 -0
  109. package/src/features/tokenusage/tokenusage-admin.module.ts +22 -0
  110. package/src/features/user/contexts/CurrentUserContext.tsx +18 -18
  111. package/src/features/user/contexts/__tests__/CurrentUserContext.spec.tsx +21 -21
  112. package/dist/chunk-4TGGHNWL.js.map +0 -1
  113. package/dist/chunk-5GVY2M5X.mjs.map +0 -1
  114. package/dist/chunk-AGKZCRG2.js.map +0 -1
  115. package/dist/chunk-K76QSQTC.mjs.map +0 -1
  116. /package/dist/{BlockNoteEditor-JTKEBS2W.mjs.map → BlockNoteEditor-34QM4UR5.mjs.map} +0 -0
  117. /package/dist/{chunk-KXTTYXJ6.mjs.map → chunk-HN5ED7OF.mjs.map} +0 -0
@@ -1,129 +1,8 @@
1
+ import { A as AbstractService, N as NextRef, P as PreviousRef } from './AbstractService-Cew0PD0L.js';
1
2
  import { F as FeatureInterface } from './feature.interface-BO25VLlx.js';
2
- import { e as RoleInterface, U as UserInterface, f as UserInput, c as CompanyInterface, b as CompanyInput, C as ContentInterface, N as NotificationInterface } from './notification.interface-LKFmZndR.js';
3
+ import { e as RoleInterface, U as UserInterface, f as UserInput, c as CompanyInterface, b as CompanyInput, C as ContentInterface, N as NotificationInterface } from './notification.interface--27exGde.js';
3
4
  import { A as ApiDataInterface, J as JsonApiHydratedDataInterface } from './ApiDataInterface-BcZeXy5X.js';
4
- import { A as AuthInput, b as AuthInterface } from './auth.interface-yivTb46w.js';
5
- import { A as ApiRequestDataTypeInterface } from './ApiRequestDataTypeInterface-CYEcRUrh.js';
6
-
7
- declare enum HttpMethod {
8
- GET = "GET",
9
- POST = "POST",
10
- PUT = "PUT",
11
- PATCH = "PATCH",
12
- DELETE = "DELETE"
13
- }
14
- interface NextRef {
15
- next?: string;
16
- }
17
- interface PreviousRef {
18
- previous?: string;
19
- }
20
- interface SelfRef {
21
- self?: string;
22
- }
23
- interface TotalRef {
24
- total?: number;
25
- }
26
- declare function getLastApiTotal(): number | undefined;
27
- declare function clearLastApiTotal(): void;
28
- declare function getLastApiMeta(): Record<string, any> | undefined;
29
- declare function clearLastApiMeta(): void;
30
- /**
31
- * Set a global error handler for API errors (client-side only).
32
- * This handler will be called instead of throwing errors.
33
- */
34
- declare function setGlobalErrorHandler(handler: (status: number, message: string) => void): void;
35
- /**
36
- * Get the current global error handler.
37
- */
38
- declare function getGlobalErrorHandler(): ((status: number, message: string) => void) | null;
39
- /**
40
- * Abstract base class for services that interact with the JSON:API.
41
- * Extend this class to create feature-specific services.
42
- */
43
- declare abstract class AbstractService {
44
- /**
45
- * Extract locale from client-side URL pathname
46
- * URL structure: /{locale}/route-path (e.g., /it/accounts)
47
- * Fallback chain: URL locale → navigator.language → "en"
48
- */
49
- private static getClientLocale;
50
- static next<T>(params: {
51
- type: ApiRequestDataTypeInterface;
52
- endpoint: string;
53
- next?: NextRef;
54
- previous?: PreviousRef;
55
- self?: SelfRef;
56
- total?: TotalRef;
57
- }): Promise<T>;
58
- /**
59
- * Fetch the previous page of results.
60
- */
61
- static previous<T>(params: {
62
- type: ApiRequestDataTypeInterface;
63
- endpoint: string;
64
- next?: NextRef;
65
- previous?: PreviousRef;
66
- self?: SelfRef;
67
- total?: TotalRef;
68
- }): Promise<T>;
69
- /**
70
- * Make an API call with automatic environment detection and error handling.
71
- */
72
- protected static callApi<T>(params: {
73
- type: ApiRequestDataTypeInterface;
74
- method: HttpMethod;
75
- endpoint: string;
76
- companyId?: string;
77
- input?: any;
78
- overridesJsonApiCreation?: boolean;
79
- next?: NextRef;
80
- previous?: PreviousRef;
81
- self?: SelfRef;
82
- total?: TotalRef;
83
- responseType?: ApiRequestDataTypeInterface;
84
- files?: {
85
- [key: string]: File | Blob;
86
- } | File | Blob;
87
- token?: string;
88
- suppressGlobalError?: boolean;
89
- /**
90
- * Per-call override of the API base URL. When omitted, the existing global
91
- * `NEXT_PUBLIC_API_URL` (or `configureJsonApi({ apiUrl })`) resolution is used —
92
- * fully backward compatible. Ignored when `endpoint` starts with "http" (passthrough).
93
- */
94
- baseUrl?: string;
95
- }): Promise<T>;
96
- /**
97
- * Make an API call and return both data and meta from the response.
98
- */
99
- protected static callApiWithMeta<T>(params: {
100
- type: ApiRequestDataTypeInterface;
101
- method: HttpMethod;
102
- endpoint: string;
103
- companyId?: string;
104
- input?: any;
105
- overridesJsonApiCreation?: boolean;
106
- responseType?: ApiRequestDataTypeInterface;
107
- files?: {
108
- [key: string]: File | Blob;
109
- } | File | Blob;
110
- suppressGlobalError?: boolean;
111
- }): Promise<{
112
- data: T;
113
- meta?: Record<string, any>;
114
- }>;
115
- /**
116
- * Get raw JSON:API response data without deserialization.
117
- */
118
- protected static getRawData(params: {
119
- type: ApiRequestDataTypeInterface;
120
- method: HttpMethod;
121
- endpoint: string;
122
- companyId?: string;
123
- baseUrl?: string;
124
- suppressGlobalError?: boolean;
125
- }): Promise<any>;
126
- }
5
+ import { A as AuthInput, b as AuthInterface } from './auth.interface-COmBjh89.js';
127
6
 
128
7
  declare class FeatureService extends AbstractService {
129
8
  static findMany(params: {
@@ -388,4 +267,4 @@ declare class S3Service extends AbstractService {
388
267
  }): Promise<void>;
389
268
  }
390
269
 
391
- export { AuthService as A, CompanyService as C, FeatureService as F, HttpMethod as H, NotificationService as N, PushService as P, RoleService as R, S3Service as S, type TotalRef as T, UserService as U, ContentService as a, AbstractService as b, type NextRef as c, type PreviousRef as d, type SelfRef as e, clearLastApiTotal as f, getLastApiTotal as g, getLastApiMeta as h, clearLastApiMeta as i, getGlobalErrorHandler as j, type TwoFactorChallengeInterface as k, type S3Input as l, type S3Interface as m, setGlobalErrorHandler as s };
270
+ export { AuthService as A, CompanyService as C, FeatureService as F, NotificationService as N, PushService as P, RoleService as R, S3Service as S, type TwoFactorChallengeInterface as T, UserService as U, ContentService as a, type S3Input as b, type S3Interface as c };
@@ -1,129 +1,8 @@
1
+ import { A as AbstractService, N as NextRef, P as PreviousRef } from './AbstractService-B0T7h8fX.mjs';
1
2
  import { F as FeatureInterface } from './feature.interface-CXb1-vNq.mjs';
2
- import { e as RoleInterface, U as UserInterface, f as UserInput, c as CompanyInterface, b as CompanyInput, C as ContentInterface, N as NotificationInterface } from './notification.interface-B3kNUTZs.mjs';
3
+ import { e as RoleInterface, U as UserInterface, f as UserInput, c as CompanyInterface, b as CompanyInput, C as ContentInterface, N as NotificationInterface } from './notification.interface-CG1vqoxg.mjs';
3
4
  import { A as ApiDataInterface, J as JsonApiHydratedDataInterface } from './ApiDataInterface-BcZeXy5X.mjs';
4
- import { A as AuthInput, b as AuthInterface } from './auth.interface-r3XKYOrQ.mjs';
5
- import { A as ApiRequestDataTypeInterface } from './ApiRequestDataTypeInterface-CYEcRUrh.mjs';
6
-
7
- declare enum HttpMethod {
8
- GET = "GET",
9
- POST = "POST",
10
- PUT = "PUT",
11
- PATCH = "PATCH",
12
- DELETE = "DELETE"
13
- }
14
- interface NextRef {
15
- next?: string;
16
- }
17
- interface PreviousRef {
18
- previous?: string;
19
- }
20
- interface SelfRef {
21
- self?: string;
22
- }
23
- interface TotalRef {
24
- total?: number;
25
- }
26
- declare function getLastApiTotal(): number | undefined;
27
- declare function clearLastApiTotal(): void;
28
- declare function getLastApiMeta(): Record<string, any> | undefined;
29
- declare function clearLastApiMeta(): void;
30
- /**
31
- * Set a global error handler for API errors (client-side only).
32
- * This handler will be called instead of throwing errors.
33
- */
34
- declare function setGlobalErrorHandler(handler: (status: number, message: string) => void): void;
35
- /**
36
- * Get the current global error handler.
37
- */
38
- declare function getGlobalErrorHandler(): ((status: number, message: string) => void) | null;
39
- /**
40
- * Abstract base class for services that interact with the JSON:API.
41
- * Extend this class to create feature-specific services.
42
- */
43
- declare abstract class AbstractService {
44
- /**
45
- * Extract locale from client-side URL pathname
46
- * URL structure: /{locale}/route-path (e.g., /it/accounts)
47
- * Fallback chain: URL locale → navigator.language → "en"
48
- */
49
- private static getClientLocale;
50
- static next<T>(params: {
51
- type: ApiRequestDataTypeInterface;
52
- endpoint: string;
53
- next?: NextRef;
54
- previous?: PreviousRef;
55
- self?: SelfRef;
56
- total?: TotalRef;
57
- }): Promise<T>;
58
- /**
59
- * Fetch the previous page of results.
60
- */
61
- static previous<T>(params: {
62
- type: ApiRequestDataTypeInterface;
63
- endpoint: string;
64
- next?: NextRef;
65
- previous?: PreviousRef;
66
- self?: SelfRef;
67
- total?: TotalRef;
68
- }): Promise<T>;
69
- /**
70
- * Make an API call with automatic environment detection and error handling.
71
- */
72
- protected static callApi<T>(params: {
73
- type: ApiRequestDataTypeInterface;
74
- method: HttpMethod;
75
- endpoint: string;
76
- companyId?: string;
77
- input?: any;
78
- overridesJsonApiCreation?: boolean;
79
- next?: NextRef;
80
- previous?: PreviousRef;
81
- self?: SelfRef;
82
- total?: TotalRef;
83
- responseType?: ApiRequestDataTypeInterface;
84
- files?: {
85
- [key: string]: File | Blob;
86
- } | File | Blob;
87
- token?: string;
88
- suppressGlobalError?: boolean;
89
- /**
90
- * Per-call override of the API base URL. When omitted, the existing global
91
- * `NEXT_PUBLIC_API_URL` (or `configureJsonApi({ apiUrl })`) resolution is used —
92
- * fully backward compatible. Ignored when `endpoint` starts with "http" (passthrough).
93
- */
94
- baseUrl?: string;
95
- }): Promise<T>;
96
- /**
97
- * Make an API call and return both data and meta from the response.
98
- */
99
- protected static callApiWithMeta<T>(params: {
100
- type: ApiRequestDataTypeInterface;
101
- method: HttpMethod;
102
- endpoint: string;
103
- companyId?: string;
104
- input?: any;
105
- overridesJsonApiCreation?: boolean;
106
- responseType?: ApiRequestDataTypeInterface;
107
- files?: {
108
- [key: string]: File | Blob;
109
- } | File | Blob;
110
- suppressGlobalError?: boolean;
111
- }): Promise<{
112
- data: T;
113
- meta?: Record<string, any>;
114
- }>;
115
- /**
116
- * Get raw JSON:API response data without deserialization.
117
- */
118
- protected static getRawData(params: {
119
- type: ApiRequestDataTypeInterface;
120
- method: HttpMethod;
121
- endpoint: string;
122
- companyId?: string;
123
- baseUrl?: string;
124
- suppressGlobalError?: boolean;
125
- }): Promise<any>;
126
- }
5
+ import { A as AuthInput, b as AuthInterface } from './auth.interface-CkmZqat3.mjs';
127
6
 
128
7
  declare class FeatureService extends AbstractService {
129
8
  static findMany(params: {
@@ -388,4 +267,4 @@ declare class S3Service extends AbstractService {
388
267
  }): Promise<void>;
389
268
  }
390
269
 
391
- export { AuthService as A, CompanyService as C, FeatureService as F, HttpMethod as H, NotificationService as N, PushService as P, RoleService as R, S3Service as S, type TotalRef as T, UserService as U, ContentService as a, AbstractService as b, type NextRef as c, type PreviousRef as d, type SelfRef as e, clearLastApiTotal as f, getLastApiTotal as g, getLastApiMeta as h, clearLastApiMeta as i, getGlobalErrorHandler as j, type TwoFactorChallengeInterface as k, type S3Input as l, type S3Interface as m, setGlobalErrorHandler as s };
270
+ export { AuthService as A, CompanyService as C, FeatureService as F, NotificationService as N, PushService as P, RoleService as R, S3Service as S, type TwoFactorChallengeInterface as T, UserService as U, ContentService as a, type S3Input as b, type S3Interface as c };
@@ -1,13 +1,14 @@
1
1
  import { A as ApiData } from '../ApiData-DPKNfY-9.mjs';
2
- import { M as ModuleWithPermissions, A as Action } from '../types-CQSjy7et.mjs';
2
+ import { M as ModuleWithPermissions, A as Action } from '../types-Bq_UA8Lg.mjs';
3
3
  import { A as ApiRequestDataTypeInterface } from '../ApiRequestDataTypeInterface-CYEcRUrh.mjs';
4
4
  import { A as ApiResponseInterface } from '../ApiResponseInterface-rsXRL_Hn.mjs';
5
- export { A as ServerAuthService, C as ServerCompanyService, a as ServerContentService, F as ServerFeatureService, N as ServerNotificationService, P as ServerPushService, R as ServerRoleService, S as ServerS3Service, U as ServerUserService } from '../s3.service-CXKV_OT-.mjs';
5
+ export { A as ServerAuthService, C as ServerCompanyService, a as ServerContentService, F as ServerFeatureService, N as ServerNotificationService, P as ServerPushService, R as ServerRoleService, S as ServerS3Service, U as ServerUserService } from '../s3.service-Dt6MfuHr.mjs';
6
6
  import 'lucide-react';
7
7
  import '../ApiDataInterface-BcZeXy5X.mjs';
8
+ import '../AbstractService-B0T7h8fX.mjs';
8
9
  import '../feature.interface-CXb1-vNq.mjs';
9
- import '../notification.interface-B3kNUTZs.mjs';
10
- import '../auth.interface-r3XKYOrQ.mjs';
10
+ import '../notification.interface-CG1vqoxg.mjs';
11
+ import '../auth.interface-CkmZqat3.mjs';
11
12
 
12
13
  type CacheProfile = "seconds" | "minutes" | "hours" | "days" | "weeks" | "max" | "default";
13
14
  /**
@@ -1,13 +1,14 @@
1
1
  import { A as ApiData } from '../ApiData-DPKNfY-9.js';
2
- import { M as ModuleWithPermissions, A as Action } from '../types-DHOxe8rc.js';
2
+ import { M as ModuleWithPermissions, A as Action } from '../types-bsm8Fp55.js';
3
3
  import { A as ApiRequestDataTypeInterface } from '../ApiRequestDataTypeInterface-CYEcRUrh.js';
4
4
  import { A as ApiResponseInterface } from '../ApiResponseInterface-CWLvSCvS.js';
5
- export { A as ServerAuthService, C as ServerCompanyService, a as ServerContentService, F as ServerFeatureService, N as ServerNotificationService, P as ServerPushService, R as ServerRoleService, S as ServerS3Service, U as ServerUserService } from '../s3.service-BrmeMjtk.js';
5
+ export { A as ServerAuthService, C as ServerCompanyService, a as ServerContentService, F as ServerFeatureService, N as ServerNotificationService, P as ServerPushService, R as ServerRoleService, S as ServerS3Service, U as ServerUserService } from '../s3.service-CpwA3sl_.js';
6
6
  import 'lucide-react';
7
7
  import '../ApiDataInterface-BcZeXy5X.js';
8
+ import '../AbstractService-Cew0PD0L.js';
8
9
  import '../feature.interface-BO25VLlx.js';
9
- import '../notification.interface-LKFmZndR.js';
10
- import '../auth.interface-yivTb46w.js';
10
+ import '../notification.interface--27exGde.js';
11
+ import '../auth.interface-COmBjh89.js';
11
12
 
12
13
  type CacheProfile = "seconds" | "minutes" | "hours" | "days" | "weeks" | "max" | "default";
13
14
  /**
@@ -15,7 +15,7 @@ var _chunkIOLU4ASDjs = require('../chunk-IOLU4ASD.js');
15
15
 
16
16
 
17
17
 
18
- var _chunkAGKZCRG2js = require('../chunk-AGKZCRG2.js');
18
+ var _chunkDS4IBFWAjs = require('../chunk-DS4IBFWA.js');
19
19
  require('../chunk-LXKSUWAV.js');
20
20
  require('../chunk-IBS6NI7D.js');
21
21
 
@@ -86,7 +86,7 @@ var ServerSession = class {
86
86
  if (!rawModules) return false;
87
87
  const modules = JSON.parse(_pako.ungzip.call(void 0, Buffer.from(rawModules, "base64"), { toText: true }));
88
88
  const selectedModule = modules.find((module) => module.id === params.module.moduleId);
89
- return _chunkAGKZCRG2js.checkPermissionsFromServer.call(void 0, {
89
+ return _chunkDS4IBFWAjs.checkPermissionsFromServer.call(void 0, {
90
90
  module: params.module,
91
91
  action: params.action,
92
92
  data: params.data,
@@ -296,5 +296,5 @@ _chunk7QVYU63Ejs.__name.call(void 0, ServerJsonApiDelete, "ServerJsonApiDelete")
296
296
 
297
297
 
298
298
 
299
- exports.ServerAuthService = _chunkAGKZCRG2js.AuthService; exports.ServerCompanyService = _chunkAGKZCRG2js.CompanyService; exports.ServerContentService = _chunkAGKZCRG2js.ContentService; exports.ServerFeatureService = _chunkAGKZCRG2js.FeatureService; exports.ServerJsonApiDelete = ServerJsonApiDelete; exports.ServerJsonApiGet = ServerJsonApiGet; exports.ServerJsonApiPatch = ServerJsonApiPatch; exports.ServerJsonApiPost = ServerJsonApiPost; exports.ServerJsonApiPut = ServerJsonApiPut; exports.ServerNotificationService = _chunkAGKZCRG2js.NotificationService; exports.ServerPushService = _chunkAGKZCRG2js.PushService; exports.ServerRoleService = _chunkAGKZCRG2js.RoleService; exports.ServerS3Service = _chunkAGKZCRG2js.S3Service; exports.ServerSession = ServerSession; exports.ServerUserService = _chunkAGKZCRG2js.UserService; exports.configureServerJsonApi = configureServerJsonApi; exports.getServerApiUrl = getServerApiUrl; exports.getServerAppUrl = getServerAppUrl; exports.getServerToken = _chunkYUO55Q5Ajs.getServerToken; exports.getServerTrackablePages = getServerTrackablePages; exports.invalidateCacheTag = invalidateCacheTag; exports.invalidateCacheTags = invalidateCacheTags; exports.serverRequest = _chunkIOLU4ASDjs.serverRequest;
299
+ exports.ServerAuthService = _chunkDS4IBFWAjs.AuthService; exports.ServerCompanyService = _chunkDS4IBFWAjs.CompanyService; exports.ServerContentService = _chunkDS4IBFWAjs.ContentService; exports.ServerFeatureService = _chunkDS4IBFWAjs.FeatureService; exports.ServerJsonApiDelete = ServerJsonApiDelete; exports.ServerJsonApiGet = ServerJsonApiGet; exports.ServerJsonApiPatch = ServerJsonApiPatch; exports.ServerJsonApiPost = ServerJsonApiPost; exports.ServerJsonApiPut = ServerJsonApiPut; exports.ServerNotificationService = _chunkDS4IBFWAjs.NotificationService; exports.ServerPushService = _chunkDS4IBFWAjs.PushService; exports.ServerRoleService = _chunkDS4IBFWAjs.RoleService; exports.ServerS3Service = _chunkDS4IBFWAjs.S3Service; exports.ServerSession = ServerSession; exports.ServerUserService = _chunkDS4IBFWAjs.UserService; exports.configureServerJsonApi = configureServerJsonApi; exports.getServerApiUrl = getServerApiUrl; exports.getServerAppUrl = getServerAppUrl; exports.getServerToken = _chunkYUO55Q5Ajs.getServerToken; exports.getServerTrackablePages = getServerTrackablePages; exports.invalidateCacheTag = invalidateCacheTag; exports.invalidateCacheTags = invalidateCacheTags; exports.serverRequest = _chunkIOLU4ASDjs.serverRequest;
300
300
  //# sourceMappingURL=index.js.map
@@ -15,7 +15,7 @@ import {
15
15
  S3Service,
16
16
  UserService,
17
17
  checkPermissionsFromServer
18
- } from "../chunk-5GVY2M5X.mjs";
18
+ } from "../chunk-BIL2WQEV.mjs";
19
19
  import "../chunk-AUXK7QSA.mjs";
20
20
  import "../chunk-C7C7VY4F.mjs";
21
21
  import {
@@ -0,0 +1,61 @@
1
+ import { A as ApiDataInterface, J as JsonApiHydratedDataInterface } from './ApiDataInterface-BcZeXy5X.js';
2
+ import { A as ApiRequestDataTypeInterface } from './ApiRequestDataTypeInterface-CYEcRUrh.js';
3
+ import { a as ModuleFactory, M as ModuleWithPermissions } from './types-bsm8Fp55.js';
4
+
5
+ declare abstract class AbstractApiData implements ApiDataInterface {
6
+ static identifierFields: string[];
7
+ get identifier(): string;
8
+ protected _jsonApi?: any;
9
+ protected _included?: any[];
10
+ protected _id?: string;
11
+ protected _type?: string;
12
+ protected _createdAt?: Date;
13
+ protected _updatedAt?: Date;
14
+ protected _self?: string;
15
+ get type(): string;
16
+ get id(): string;
17
+ get self(): string | undefined;
18
+ get createdAt(): Date;
19
+ get updatedAt(): Date;
20
+ get included(): any[];
21
+ get jsonApi(): any;
22
+ ingestJsonApi(_data: JsonApiHydratedDataInterface): void;
23
+ generateApiUrl(_params?: any): string;
24
+ createJsonApi(_data?: any): any;
25
+ protected _readIncluded<T extends ApiDataInterface>(data: JsonApiHydratedDataInterface, type: string, dataType: ApiRequestDataTypeInterface): T | T[] | undefined;
26
+ /**
27
+ * Read included relationships with polymorphic type resolution.
28
+ * Determines the correct model class based on the JSON:API type in included data.
29
+ */
30
+ protected _readIncludedPolymorphic<T extends ApiDataInterface>(data: JsonApiHydratedDataInterface, relationshipKey: string, candidateModules: ApiRequestDataTypeInterface[]): T | T[] | undefined;
31
+ /**
32
+ * Read included relationship data and augment with relationship meta properties.
33
+ * Handles both single relationships (one-to-one) and array relationships (one-to-many).
34
+ *
35
+ * For single relationships: meta is read from `relationships[type].meta`
36
+ * For array relationships: per-item meta is read from `relationships[type].data[].meta`
37
+ *
38
+ * @param data - Hydrated JSON:API data
39
+ * @param type - Relationship type key (e.g., "guide", "persons")
40
+ * @param dataType - Module reference for rehydration
41
+ * @returns Related object(s) augmented with meta properties, or undefined
42
+ */
43
+ protected _readIncludedWithMeta<T extends ApiDataInterface, M extends Record<string, any>>(data: JsonApiHydratedDataInterface, type: string, dataType: ApiRequestDataTypeInterface): (T & M) | (T & M)[] | undefined;
44
+ dehydrate(): JsonApiHydratedDataInterface;
45
+ rehydrate(data: JsonApiHydratedDataInterface): this;
46
+ }
47
+
48
+ /**
49
+ * Read-only reporting resources behind the administrative token-usage page.
50
+ * `name` is the endpoint path EndpointCreator builds URLs from; there is no
51
+ * pageUrl because these are not navigable resources.
52
+ *
53
+ * Distinct from the consuming app's own TokenUsage module (name "tokenusages",
54
+ * pageUrl "/tokenusage") — that one is an AppModuleDefinitions entry the package
55
+ * cannot reference, which is why these three exist.
56
+ */
57
+ declare const TokenUsageAdminSummaryModule: (factory: ModuleFactory) => ModuleWithPermissions;
58
+ declare const TokenUsageAdminTimelineModule: (factory: ModuleFactory) => ModuleWithPermissions;
59
+ declare const TokenUsageAdminBreakdownModule: (factory: ModuleFactory) => ModuleWithPermissions;
60
+
61
+ export { AbstractApiData as A, TokenUsageAdminSummaryModule as T, TokenUsageAdminTimelineModule as a, TokenUsageAdminBreakdownModule as b };
@@ -0,0 +1,61 @@
1
+ import { A as ApiDataInterface, J as JsonApiHydratedDataInterface } from './ApiDataInterface-BcZeXy5X.mjs';
2
+ import { A as ApiRequestDataTypeInterface } from './ApiRequestDataTypeInterface-CYEcRUrh.mjs';
3
+ import { a as ModuleFactory, M as ModuleWithPermissions } from './types-Bq_UA8Lg.mjs';
4
+
5
+ declare abstract class AbstractApiData implements ApiDataInterface {
6
+ static identifierFields: string[];
7
+ get identifier(): string;
8
+ protected _jsonApi?: any;
9
+ protected _included?: any[];
10
+ protected _id?: string;
11
+ protected _type?: string;
12
+ protected _createdAt?: Date;
13
+ protected _updatedAt?: Date;
14
+ protected _self?: string;
15
+ get type(): string;
16
+ get id(): string;
17
+ get self(): string | undefined;
18
+ get createdAt(): Date;
19
+ get updatedAt(): Date;
20
+ get included(): any[];
21
+ get jsonApi(): any;
22
+ ingestJsonApi(_data: JsonApiHydratedDataInterface): void;
23
+ generateApiUrl(_params?: any): string;
24
+ createJsonApi(_data?: any): any;
25
+ protected _readIncluded<T extends ApiDataInterface>(data: JsonApiHydratedDataInterface, type: string, dataType: ApiRequestDataTypeInterface): T | T[] | undefined;
26
+ /**
27
+ * Read included relationships with polymorphic type resolution.
28
+ * Determines the correct model class based on the JSON:API type in included data.
29
+ */
30
+ protected _readIncludedPolymorphic<T extends ApiDataInterface>(data: JsonApiHydratedDataInterface, relationshipKey: string, candidateModules: ApiRequestDataTypeInterface[]): T | T[] | undefined;
31
+ /**
32
+ * Read included relationship data and augment with relationship meta properties.
33
+ * Handles both single relationships (one-to-one) and array relationships (one-to-many).
34
+ *
35
+ * For single relationships: meta is read from `relationships[type].meta`
36
+ * For array relationships: per-item meta is read from `relationships[type].data[].meta`
37
+ *
38
+ * @param data - Hydrated JSON:API data
39
+ * @param type - Relationship type key (e.g., "guide", "persons")
40
+ * @param dataType - Module reference for rehydration
41
+ * @returns Related object(s) augmented with meta properties, or undefined
42
+ */
43
+ protected _readIncludedWithMeta<T extends ApiDataInterface, M extends Record<string, any>>(data: JsonApiHydratedDataInterface, type: string, dataType: ApiRequestDataTypeInterface): (T & M) | (T & M)[] | undefined;
44
+ dehydrate(): JsonApiHydratedDataInterface;
45
+ rehydrate(data: JsonApiHydratedDataInterface): this;
46
+ }
47
+
48
+ /**
49
+ * Read-only reporting resources behind the administrative token-usage page.
50
+ * `name` is the endpoint path EndpointCreator builds URLs from; there is no
51
+ * pageUrl because these are not navigable resources.
52
+ *
53
+ * Distinct from the consuming app's own TokenUsage module (name "tokenusages",
54
+ * pageUrl "/tokenusage") — that one is an AppModuleDefinitions entry the package
55
+ * cannot reference, which is why these three exist.
56
+ */
57
+ declare const TokenUsageAdminSummaryModule: (factory: ModuleFactory) => ModuleWithPermissions;
58
+ declare const TokenUsageAdminTimelineModule: (factory: ModuleFactory) => ModuleWithPermissions;
59
+ declare const TokenUsageAdminBreakdownModule: (factory: ModuleFactory) => ModuleWithPermissions;
60
+
61
+ export { AbstractApiData as A, TokenUsageAdminSummaryModule as T, TokenUsageAdminTimelineModule as a, TokenUsageAdminBreakdownModule as b };
@@ -98,4 +98,4 @@ type ModuleFactory = (params: {
98
98
  }>;
99
99
  }) => ModuleWithPermissions;
100
100
 
101
- export { Action as A, type ModuleWithPermissions as M, type PageUrl as P, type PermissionCheck as a, type ModulePermissionDefinition as b, type ModuleDefinition as c, type PermissionConfig as d, type PermissionModule as e, type PermissionUser as f, type ModuleFactory as g };
101
+ export { Action as A, type ModuleWithPermissions as M, type PageUrl as P, type ModuleFactory as a, type PermissionCheck as b, type ModulePermissionDefinition as c, type ModuleDefinition as d, type PermissionConfig as e, type PermissionModule as f, type PermissionUser as g };
@@ -98,4 +98,4 @@ type ModuleFactory = (params: {
98
98
  }>;
99
99
  }) => ModuleWithPermissions;
100
100
 
101
- export { Action as A, type ModuleWithPermissions as M, type PageUrl as P, type PermissionCheck as a, type ModulePermissionDefinition as b, type ModuleDefinition as c, type PermissionConfig as d, type PermissionModule as e, type PermissionUser as f, type ModuleFactory as g };
101
+ export { Action as A, type ModuleWithPermissions as M, type PageUrl as P, type ModuleFactory as a, type PermissionCheck as b, type ModulePermissionDefinition as c, type ModuleDefinition as d, type PermissionConfig as e, type PermissionModule as f, type PermissionUser as g };
@@ -1,4 +1,4 @@
1
- import { P as PageUrl } from './types-DHOxe8rc.js';
1
+ import { P as PageUrl } from './types-bsm8Fp55.js';
2
2
 
3
3
  declare function usePageUrlGenerator(): (params: {
4
4
  page?: PageUrl | string;
@@ -1,4 +1,4 @@
1
- import { P as PageUrl } from './types-CQSjy7et.mjs';
1
+ import { P as PageUrl } from './types-Bq_UA8Lg.mjs';
2
2
 
3
3
  declare function usePageUrlGenerator(): (params: {
4
4
  page?: PageUrl | string;
@@ -1,4 +1,4 @@
1
- import { N as NotificationInterface } from './notification.interface-LKFmZndR.js';
1
+ import { N as NotificationInterface } from './notification.interface--27exGde.js';
2
2
 
3
3
  interface UseSocketOptions {
4
4
  token: string;
@@ -1,4 +1,4 @@
1
- import { N as NotificationInterface } from './notification.interface-B3kNUTZs.mjs';
1
+ import { N as NotificationInterface } from './notification.interface-CG1vqoxg.mjs';
2
2
 
3
3
  interface UseSocketOptions {
4
4
  token: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carlonicora/nextjs-jsonapi",
3
- "version": "1.141.3",
3
+ "version": "1.143.0",
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",
@@ -62,6 +62,11 @@
62
62
  "types": "./dist/features/help/server.d.ts",
63
63
  "import": "./dist/features/help/server.mjs",
64
64
  "require": "./dist/features/help/server.js"
65
+ },
66
+ "./tokenusage": {
67
+ "types": "./dist/features/tokenusage/index.d.ts",
68
+ "import": "./dist/features/tokenusage/index.mjs",
69
+ "require": "./dist/features/tokenusage/index.js"
65
70
  }
66
71
  },
67
72
  "scripts": {
package/src/core/index.ts CHANGED
@@ -91,4 +91,9 @@ export * from "../features/rbac/rbac.module";
91
91
  export * from "../features/referral/data";
92
92
  export * from "../features/referral/referral.module";
93
93
  export * from "../features/referral/referral-stats.module";
94
+ // Administrative token-usage reporting modules. Exported from core (not only
95
+ // from the client-marked ./tokenusage barrel) so a consuming app can register
96
+ // them in its bootstrapper without pulling the feature's client bundle —
97
+ // same placement as waitlist-stats and referral-stats above.
98
+ export * from "../features/tokenusage/tokenusage-admin.module";
94
99
  export * from "../features/audit-log";
@@ -58,6 +58,10 @@ export interface FoundationModuleDefinitions {
58
58
  RbacMatrix: ModuleWithPermissions;
59
59
  // Audit modules
60
60
  AuditLog: ModuleWithPermissions;
61
+ // Administrative token-usage reporting modules
62
+ TokenUsageAdminSummary: ModuleWithPermissions;
63
+ TokenUsageAdminTimeline: ModuleWithPermissions;
64
+ TokenUsageAdminBreakdown: ModuleWithPermissions;
61
65
  }
62
66
 
63
67
  // App-specific modules - apps will augment this interface ONLY
@@ -31,12 +31,12 @@ export function TokenStatusIndicator({ className, size = "md", showExtraPages =
31
31
  // Don't render if no company data
32
32
  if (!company) return null;
33
33
 
34
- const monthlyTokens = company.monthlyTokens;
35
- const availableMonthlyTokens = company.availableMonthlyTokens;
36
- const availableExtraTokens = company.availableExtraTokens;
34
+ const monthlyCredits = company.monthlyCredits;
35
+ const availableMonthlyCredits = company.availableMonthlyCredits;
36
+ const availableExtraCredits = company.availableExtraCredits;
37
37
 
38
38
  // Calculate percentage of available monthly pages
39
- const percentage = monthlyTokens > 0 ? (availableMonthlyTokens / monthlyTokens) * 100 : 0;
39
+ const percentage = monthlyCredits > 0 ? (availableMonthlyCredits / monthlyCredits) * 100 : 0;
40
40
 
41
41
  const sizeClasses = {
42
42
  sm: "h-4 w-4",
@@ -91,7 +91,7 @@ export function TokenStatusIndicator({ className, size = "md", showExtraPages =
91
91
  {t("billing.tokens.monthly", { defaultValue: "Monthly Pages" })}:
92
92
  </span>
93
93
  <span className={cn("font-medium", getStatusColor())}>
94
- {availableMonthlyTokens} / {monthlyTokens}
94
+ {availableMonthlyCredits} / {monthlyCredits}
95
95
  </span>
96
96
  </div>
97
97
  <div className="flex items-center justify-between gap-4">
@@ -108,7 +108,7 @@ export function TokenStatusIndicator({ className, size = "md", showExtraPages =
108
108
  <span className="text-muted-foreground">
109
109
  {t("billing.tokens.available_extra", { defaultValue: "Extra Pages" })}:
110
110
  </span>
111
- <span className="font-medium text-blue-500">{availableExtraTokens}</span>
111
+ <span className="font-medium text-blue-500">{availableExtraCredits}</span>
112
112
  </div>
113
113
  <Link href="/settings/billing?action=subscribe" className="w-full flex justify-end my-4">
114
114
  <Button variant="outline" size="sm">
@@ -127,11 +127,11 @@ export function TokenStatusIndicator({ className, size = "md", showExtraPages =
127
127
  aria-label={t("billing.tokens.status", { defaultValue: "Page Status" })}
128
128
  >
129
129
  {getBatteryIcon()}
130
- <span className={cn(textSize, "text-muted-foreground font-medium")}>{availableMonthlyTokens}</span>
131
- {showExtraPages && availableExtraTokens > 0 && (
130
+ <span className={cn(textSize, "text-muted-foreground font-medium")}>{availableMonthlyCredits}</span>
131
+ {showExtraPages && availableExtraCredits > 0 && (
132
132
  <div className="inline-flex items-center gap-0.5">
133
133
  <PlusCircle className={cn(smallIconSize, "text-blue-500")} />
134
- <span className={cn(textSize, "text-blue-500 font-medium")}>{availableExtraTokens}</span>
134
+ <span className={cn(textSize, "text-blue-500 font-medium")}>{availableExtraCredits}</span>
135
135
  </div>
136
136
  )}
137
137
  </div>
@@ -8,9 +8,9 @@ export type CompanyInput = {
8
8
  logo?: string;
9
9
  configurations?: any;
10
10
 
11
- monthlyTokens?: number;
12
- availableMonthlyTokens?: number;
13
- availableExtraTokens?: number;
11
+ monthlyCredits?: number;
12
+ availableMonthlyCredits?: number;
13
+ availableExtraCredits?: number;
14
14
 
15
15
  featureIds?: string[];
16
16
  moduleIds?: string[];
@@ -34,9 +34,9 @@ export interface CompanyInterface extends ApiDataInterface {
34
34
 
35
35
  get isActiveSubscription(): boolean;
36
36
 
37
- get monthlyTokens(): number;
38
- get availableMonthlyTokens(): number;
39
- get availableExtraTokens(): number;
37
+ get monthlyCredits(): number;
38
+ get availableMonthlyCredits(): number;
39
+ get availableExtraCredits(): number;
40
40
 
41
41
  get features(): FeatureInterface[];
42
42
  get modules(): ModuleInterface[];