@carlonicora/nextjs-jsonapi 2.4.0 → 2.5.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 (85) hide show
  1. package/dist/{BlockNoteEditor-7WGCH2KB.js → BlockNoteEditor-TIMGYKAA.js} +19 -19
  2. package/dist/{BlockNoteEditor-7WGCH2KB.js.map → BlockNoteEditor-TIMGYKAA.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-GWAV5ESO.mjs → BlockNoteEditor-YFJMXJEU.mjs} +4 -4
  4. package/dist/billing/index.js +362 -362
  5. package/dist/billing/index.mjs +3 -3
  6. package/dist/{chunk-GYGMEDVS.js → chunk-7HKJNUW7.js} +755 -746
  7. package/dist/chunk-7HKJNUW7.js.map +1 -0
  8. package/dist/{chunk-3LVSA7IM.mjs → chunk-DJWNNV52.mjs} +2 -2
  9. package/dist/{chunk-LCCRUWWY.mjs → chunk-FS4RVV3K.mjs} +241 -1
  10. package/dist/chunk-FS4RVV3K.mjs.map +1 -0
  11. package/dist/{chunk-M2EGUO2F.mjs → chunk-G4YS52SO.mjs} +16 -7
  12. package/dist/chunk-G4YS52SO.mjs.map +1 -0
  13. package/dist/{chunk-TOKHHZSP.js → chunk-OTEDZ6YW.js} +7 -7
  14. package/dist/{chunk-TOKHHZSP.js.map → chunk-OTEDZ6YW.js.map} +1 -1
  15. package/dist/{chunk-V66AZWPG.js → chunk-RTOC53EZ.js} +246 -6
  16. package/dist/chunk-RTOC53EZ.js.map +1 -0
  17. package/dist/client/index.js +4 -4
  18. package/dist/client/index.mjs +3 -3
  19. package/dist/components/index.d.mts +16 -1
  20. package/dist/components/index.d.ts +16 -1
  21. package/dist/components/index.js +4 -4
  22. package/dist/components/index.mjs +3 -3
  23. package/dist/{tokenusage-admin.module-5wJ_tZTj.d.ts → config-BIjrg5wd.d.ts} +39 -1
  24. package/dist/{tokenusage-admin.module-DQVT4O4j.d.mts → config-BRUjtCd1.d.mts} +39 -1
  25. package/dist/contexts/index.js +4 -4
  26. package/dist/contexts/index.mjs +3 -3
  27. package/dist/core/index.d.mts +5 -2
  28. package/dist/core/index.d.ts +5 -2
  29. package/dist/core/index.js +8 -2
  30. package/dist/core/index.js.map +1 -1
  31. package/dist/core/index.mjs +7 -1
  32. package/dist/features/help/index.js +37 -37
  33. package/dist/features/help/index.mjs +3 -3
  34. package/dist/features/tokenusage/index.d.mts +413 -14
  35. package/dist/features/tokenusage/index.d.ts +413 -14
  36. package/dist/features/tokenusage/index.js +481 -120
  37. package/dist/features/tokenusage/index.js.map +1 -1
  38. package/dist/features/tokenusage/index.mjs +431 -70
  39. package/dist/features/tokenusage/index.mjs.map +1 -1
  40. package/dist/index.d.mts +2 -2
  41. package/dist/index.d.ts +2 -2
  42. package/dist/index.js +9 -3
  43. package/dist/index.js.map +1 -1
  44. package/dist/index.mjs +8 -2
  45. package/dist/server/index.js +3 -3
  46. package/dist/server/index.mjs +1 -1
  47. package/package.json +1 -1
  48. package/src/core/index.ts +10 -0
  49. package/src/core/registry/ModuleRegistry.ts +4 -0
  50. package/src/features/tokenusage/components/TokenUsageAdminContainer.tsx +20 -4
  51. package/src/features/tokenusage/components/TokenUsageAdminTiles.tsx +31 -18
  52. package/src/features/tokenusage/components/TokenUsageBreakdownTable.tsx +13 -13
  53. package/src/features/tokenusage/components/TokenUsageRankedBar.tsx +24 -7
  54. package/src/features/tokenusage/components/TokenUsageReportContainer.tsx +102 -0
  55. package/src/features/tokenusage/components/TokenUsageReportFilterBar.tsx +34 -0
  56. package/src/features/tokenusage/components/TokenUsageReportTiles.tsx +161 -0
  57. package/src/features/tokenusage/components/TokenUsageTimelineChart.tsx +15 -13
  58. package/src/features/tokenusage/components/__tests__/TokenUsageAdminTiles.spec.tsx +4 -2
  59. package/src/features/tokenusage/components/__tests__/TokenUsageRankedBar.spec.tsx +3 -1
  60. package/src/features/tokenusage/contexts/TokenUsageAdminContext.tsx +6 -3
  61. package/src/features/tokenusage/contexts/TokenUsageReportContext.tsx +199 -0
  62. package/src/features/tokenusage/data/TokenUsageReportService.ts +65 -0
  63. package/src/features/tokenusage/data/index.ts +9 -0
  64. package/src/features/tokenusage/data/tokenusage-report-breakdown.interface.ts +12 -0
  65. package/src/features/tokenusage/data/tokenusage-report-breakdown.ts +94 -0
  66. package/src/features/tokenusage/data/tokenusage-report-summary.interface.ts +12 -0
  67. package/src/features/tokenusage/data/tokenusage-report-summary.ts +87 -0
  68. package/src/features/tokenusage/data/tokenusage-report-timeline.interface.ts +13 -0
  69. package/src/features/tokenusage/data/tokenusage-report-timeline.ts +94 -0
  70. package/src/features/tokenusage/data/tokenusage-report.types.ts +51 -0
  71. package/src/features/tokenusage/i18n-keys.ts +28 -0
  72. package/src/features/tokenusage/index.ts +18 -0
  73. package/src/features/tokenusage/lib/config.ts +22 -0
  74. package/src/features/tokenusage/lib/formatters.ts +100 -0
  75. package/src/features/tokenusage/lib/metrics.ts +8 -26
  76. package/src/features/tokenusage/lib/palette.ts +41 -14
  77. package/src/features/tokenusage/tokenusage-admin.module.ts +4 -0
  78. package/src/features/tokenusage/tokenusage.modules.ts +40 -0
  79. package/src/shadcnui/ui/chart.tsx +30 -3
  80. package/dist/chunk-GYGMEDVS.js.map +0 -1
  81. package/dist/chunk-LCCRUWWY.mjs.map +0 -1
  82. package/dist/chunk-M2EGUO2F.mjs.map +0 -1
  83. package/dist/chunk-V66AZWPG.js.map +0 -1
  84. /package/dist/{BlockNoteEditor-GWAV5ESO.mjs.map → BlockNoteEditor-YFJMXJEU.mjs.map} +0 -0
  85. /package/dist/{chunk-3LVSA7IM.mjs.map → chunk-DJWNNV52.mjs.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  AbstractService,
3
3
  EndpointCreator,
4
4
  Modules
5
- } from "./chunk-LCCRUWWY.mjs";
5
+ } from "./chunk-FS4RVV3K.mjs";
6
6
  import {
7
7
  setBootstrapper
8
8
  } from "./chunk-E5YA5Z5X.mjs";
@@ -296,4 +296,4 @@ export {
296
296
  ACTION_TYPES,
297
297
  RbacService
298
298
  };
299
- //# sourceMappingURL=chunk-3LVSA7IM.mjs.map
299
+ //# sourceMappingURL=chunk-DJWNNV52.mjs.map
@@ -8089,6 +8089,240 @@ var TokenUsageAdminSummaryModule = /* @__PURE__ */ __name((factory) => factory({
8089
8089
  var TokenUsageAdminTimelineModule = /* @__PURE__ */ __name((factory) => factory({ name: "tokenusages/administration/timeline", model: TokenUsageAdminTimeline }), "TokenUsageAdminTimelineModule");
8090
8090
  var TokenUsageAdminBreakdownModule = /* @__PURE__ */ __name((factory) => factory({ name: "tokenusages/administration/breakdown", model: TokenUsageAdminBreakdown }), "TokenUsageAdminBreakdownModule");
8091
8091
 
8092
+ // src/features/tokenusage/data/tokenusage-report-breakdown.ts
8093
+ var TokenUsageReportBreakdown = class extends AbstractApiData {
8094
+ static {
8095
+ __name(this, "TokenUsageReportBreakdown");
8096
+ }
8097
+ _label = "";
8098
+ _sublabel;
8099
+ _cost = 0;
8100
+ _credits = 0;
8101
+ _tokensIn = 0;
8102
+ _tokensOut = 0;
8103
+ _cached = 0;
8104
+ _calls = 0;
8105
+ get label() {
8106
+ return this._label;
8107
+ }
8108
+ get sublabel() {
8109
+ return this._sublabel;
8110
+ }
8111
+ get cost() {
8112
+ return this._cost;
8113
+ }
8114
+ get credits() {
8115
+ return this._credits;
8116
+ }
8117
+ get tokensIn() {
8118
+ return this._tokensIn;
8119
+ }
8120
+ get tokensOut() {
8121
+ return this._tokensOut;
8122
+ }
8123
+ get cached() {
8124
+ return this._cached;
8125
+ }
8126
+ get calls() {
8127
+ return this._calls;
8128
+ }
8129
+ rehydrate(data) {
8130
+ super.rehydrate(data);
8131
+ const attrs = data.jsonApi.attributes;
8132
+ this._label = attrs.label ?? "";
8133
+ this._sublabel = attrs.sublabel ?? void 0;
8134
+ this._cost = attrs.cost ?? 0;
8135
+ this._credits = attrs.credits ?? 0;
8136
+ this._tokensIn = attrs.tokensIn ?? 0;
8137
+ this._tokensOut = attrs.tokensOut ?? 0;
8138
+ this._cached = attrs.cached ?? 0;
8139
+ this._calls = attrs.calls ?? 0;
8140
+ return this;
8141
+ }
8142
+ createJsonApi(data) {
8143
+ const response = {
8144
+ data: {
8145
+ type: Modules.TokenUsageReportBreakdown.name,
8146
+ id: data.id,
8147
+ attributes: {},
8148
+ relationships: {}
8149
+ },
8150
+ included: []
8151
+ };
8152
+ if (data.label !== void 0) response.data.attributes.label = data.label;
8153
+ if (data.sublabel !== void 0) response.data.attributes.sublabel = data.sublabel;
8154
+ if (data.cost !== void 0) response.data.attributes.cost = data.cost;
8155
+ if (data.credits !== void 0) response.data.attributes.credits = data.credits;
8156
+ if (data.tokensIn !== void 0) response.data.attributes.tokensIn = data.tokensIn;
8157
+ if (data.tokensOut !== void 0) response.data.attributes.tokensOut = data.tokensOut;
8158
+ if (data.cached !== void 0) response.data.attributes.cached = data.cached;
8159
+ if (data.calls !== void 0) response.data.attributes.calls = data.calls;
8160
+ return response;
8161
+ }
8162
+ };
8163
+
8164
+ // src/features/tokenusage/data/tokenusage-report-summary.ts
8165
+ var TokenUsageReportSummary = class extends AbstractApiData {
8166
+ static {
8167
+ __name(this, "TokenUsageReportSummary");
8168
+ }
8169
+ _window = "";
8170
+ _cost = 0;
8171
+ _credits = 0;
8172
+ _tokensIn = 0;
8173
+ _tokensOut = 0;
8174
+ _cached = 0;
8175
+ _calls = 0;
8176
+ get window() {
8177
+ return this._window;
8178
+ }
8179
+ get cost() {
8180
+ return this._cost;
8181
+ }
8182
+ get credits() {
8183
+ return this._credits;
8184
+ }
8185
+ get tokensIn() {
8186
+ return this._tokensIn;
8187
+ }
8188
+ get tokensOut() {
8189
+ return this._tokensOut;
8190
+ }
8191
+ get cached() {
8192
+ return this._cached;
8193
+ }
8194
+ get calls() {
8195
+ return this._calls;
8196
+ }
8197
+ rehydrate(data) {
8198
+ super.rehydrate(data);
8199
+ const attrs = data.jsonApi.attributes;
8200
+ this._window = attrs.window ?? "";
8201
+ this._cost = attrs.cost ?? 0;
8202
+ this._credits = attrs.credits ?? 0;
8203
+ this._tokensIn = attrs.tokensIn ?? 0;
8204
+ this._tokensOut = attrs.tokensOut ?? 0;
8205
+ this._cached = attrs.cached ?? 0;
8206
+ this._calls = attrs.calls ?? 0;
8207
+ return this;
8208
+ }
8209
+ createJsonApi(data) {
8210
+ const response = {
8211
+ data: {
8212
+ type: Modules.TokenUsageReportSummary.name,
8213
+ id: data.id,
8214
+ attributes: {},
8215
+ relationships: {}
8216
+ },
8217
+ included: []
8218
+ };
8219
+ if (data.window !== void 0) response.data.attributes.window = data.window;
8220
+ if (data.cost !== void 0) response.data.attributes.cost = data.cost;
8221
+ if (data.credits !== void 0) response.data.attributes.credits = data.credits;
8222
+ if (data.tokensIn !== void 0) response.data.attributes.tokensIn = data.tokensIn;
8223
+ if (data.tokensOut !== void 0) response.data.attributes.tokensOut = data.tokensOut;
8224
+ if (data.cached !== void 0) response.data.attributes.cached = data.cached;
8225
+ if (data.calls !== void 0) response.data.attributes.calls = data.calls;
8226
+ return response;
8227
+ }
8228
+ };
8229
+
8230
+ // src/features/tokenusage/data/tokenusage-report-timeline.ts
8231
+ var TokenUsageReportTimeline = class extends AbstractApiData {
8232
+ static {
8233
+ __name(this, "TokenUsageReportTimeline");
8234
+ }
8235
+ _bucket = /* @__PURE__ */ new Date(0);
8236
+ _series = "";
8237
+ _cost = 0;
8238
+ _credits = 0;
8239
+ _tokensIn = 0;
8240
+ _tokensOut = 0;
8241
+ _cached = 0;
8242
+ _calls = 0;
8243
+ get bucket() {
8244
+ return this._bucket;
8245
+ }
8246
+ get series() {
8247
+ return this._series;
8248
+ }
8249
+ get cost() {
8250
+ return this._cost;
8251
+ }
8252
+ get credits() {
8253
+ return this._credits;
8254
+ }
8255
+ get tokensIn() {
8256
+ return this._tokensIn;
8257
+ }
8258
+ get tokensOut() {
8259
+ return this._tokensOut;
8260
+ }
8261
+ get cached() {
8262
+ return this._cached;
8263
+ }
8264
+ get calls() {
8265
+ return this._calls;
8266
+ }
8267
+ rehydrate(data) {
8268
+ super.rehydrate(data);
8269
+ const attrs = data.jsonApi.attributes;
8270
+ this._bucket = attrs.bucket ? new Date(attrs.bucket) : /* @__PURE__ */ new Date(0);
8271
+ this._series = attrs.series ?? "";
8272
+ this._cost = attrs.cost ?? 0;
8273
+ this._credits = attrs.credits ?? 0;
8274
+ this._tokensIn = attrs.tokensIn ?? 0;
8275
+ this._tokensOut = attrs.tokensOut ?? 0;
8276
+ this._cached = attrs.cached ?? 0;
8277
+ this._calls = attrs.calls ?? 0;
8278
+ return this;
8279
+ }
8280
+ createJsonApi(data) {
8281
+ const response = {
8282
+ data: {
8283
+ type: Modules.TokenUsageReportTimeline.name,
8284
+ id: data.id,
8285
+ attributes: {},
8286
+ relationships: {}
8287
+ },
8288
+ included: []
8289
+ };
8290
+ if (data.bucket !== void 0) response.data.attributes.bucket = formatLocalDate(data.bucket);
8291
+ if (data.series !== void 0) response.data.attributes.series = data.series;
8292
+ if (data.cost !== void 0) response.data.attributes.cost = data.cost;
8293
+ if (data.credits !== void 0) response.data.attributes.credits = data.credits;
8294
+ if (data.tokensIn !== void 0) response.data.attributes.tokensIn = data.tokensIn;
8295
+ if (data.tokensOut !== void 0) response.data.attributes.tokensOut = data.tokensOut;
8296
+ if (data.cached !== void 0) response.data.attributes.cached = data.cached;
8297
+ if (data.calls !== void 0) response.data.attributes.calls = data.calls;
8298
+ return response;
8299
+ }
8300
+ };
8301
+
8302
+ // src/features/tokenusage/tokenusage.modules.ts
8303
+ var tokenUsageModules = /* @__PURE__ */ __name((factory) => ({
8304
+ TokenUsageAdminSummary: factory({ name: "tokenusages/administration/summary", model: TokenUsageAdminSummary }),
8305
+ TokenUsageAdminTimeline: factory({ name: "tokenusages/administration/timeline", model: TokenUsageAdminTimeline }),
8306
+ TokenUsageAdminBreakdown: factory({
8307
+ name: "tokenusages/administration/breakdown",
8308
+ model: TokenUsageAdminBreakdown
8309
+ }),
8310
+ TokenUsageReportSummary: factory({ name: "tokenusages/reports/summary", model: TokenUsageReportSummary }),
8311
+ TokenUsageReportTimeline: factory({ name: "tokenusages/reports/timeline", model: TokenUsageReportTimeline }),
8312
+ TokenUsageReportBreakdown: factory({ name: "tokenusages/reports/breakdown", model: TokenUsageReportBreakdown })
8313
+ }), "tokenUsageModules");
8314
+
8315
+ // src/features/tokenusage/lib/config.ts
8316
+ var currency = "EUR";
8317
+ function configureTokenUsage(config) {
8318
+ currency = config.currency;
8319
+ }
8320
+ __name(configureTokenUsage, "configureTokenUsage");
8321
+ function getTokenUsageCurrency() {
8322
+ return currency;
8323
+ }
8324
+ __name(getTokenUsageCurrency, "getTokenUsageCurrency");
8325
+
8092
8326
  // src/features/audit-log/data/audit-log.ts
8093
8327
  var AuditLog = class extends AbstractApiData {
8094
8328
  static {
@@ -8383,8 +8617,14 @@ export {
8383
8617
  TokenUsageAdminSummaryModule,
8384
8618
  TokenUsageAdminTimelineModule,
8385
8619
  TokenUsageAdminBreakdownModule,
8620
+ TokenUsageReportBreakdown,
8621
+ TokenUsageReportSummary,
8622
+ TokenUsageReportTimeline,
8623
+ tokenUsageModules,
8624
+ configureTokenUsage,
8625
+ getTokenUsageCurrency,
8386
8626
  AuditLog,
8387
8627
  AuditLogService,
8388
8628
  AuditLogModule
8389
8629
  };
8390
- //# sourceMappingURL=chunk-LCCRUWWY.mjs.map
8630
+ //# sourceMappingURL=chunk-FS4RVV3K.mjs.map