@carlonicora/nextjs-jsonapi 6.6.0 → 6.8.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 (127) hide show
  1. package/dist/{AssistantMessageInterface-0ZQ1EJKO.d.mts → AssistantMessageInterface-BE3QxI54.d.mts} +1 -1
  2. package/dist/{AssistantMessageInterface-CA-hZ5Wj.d.ts → AssistantMessageInterface-nXpD_d-m.d.ts} +1 -1
  3. package/dist/{BlockNoteEditor-MWGVWNSE.mjs → BlockNoteEditor-D3LDTJCP.mjs} +4 -4
  4. package/dist/{BlockNoteEditor-E4V7AEG2.js → BlockNoteEditor-FB6FQFRF.js} +19 -19
  5. package/dist/{BlockNoteEditor-E4V7AEG2.js.map → BlockNoteEditor-FB6FQFRF.js.map} +1 -1
  6. package/dist/{BlockNoteViewer-LGRKM7OA.js → BlockNoteViewer-LGFMGTYX.js} +3 -3
  7. package/dist/{BlockNoteViewer-LGRKM7OA.js.map → BlockNoteViewer-LGFMGTYX.js.map} +1 -1
  8. package/dist/{BlockNoteViewer-VNU7WVN5.mjs → BlockNoteViewer-YSPYUDZE.mjs} +2 -2
  9. package/dist/{BlogPostInterface-CTGfsR1I.d.ts → BlogPostInterface-2sVqvXFd.d.ts} +1 -1
  10. package/dist/{BlogPostInterface-BN2mXc46.d.mts → BlogPostInterface-BgJLFpaa.d.mts} +1 -1
  11. package/dist/{auth.interface-tsOuc0Fi.d.mts → auth.interface-BAYLbYjs.d.mts} +3 -1
  12. package/dist/{auth.interface-D5606g19.d.ts → auth.interface-BjYwwfy9.d.ts} +3 -1
  13. package/dist/billing/index.js +492 -492
  14. package/dist/billing/index.mjs +3 -3
  15. package/dist/{chunk-RSMBRI3E.mjs → chunk-5HBFQEYU.mjs} +2 -2
  16. package/dist/{chunk-IDV534SJ.mjs → chunk-5HTX4RDA.mjs} +3730 -3537
  17. package/dist/chunk-5HTX4RDA.mjs.map +1 -0
  18. package/dist/{chunk-IQ2XYAB5.mjs → chunk-D44UDP4G.mjs} +2 -2
  19. package/dist/{chunk-F2MZ7GY6.js → chunk-JHT32ODN.js} +4 -4
  20. package/dist/{chunk-F2MZ7GY6.js.map → chunk-JHT32ODN.js.map} +1 -1
  21. package/dist/{chunk-AEVLFZRK.js → chunk-PSLT5JLE.js} +3 -3
  22. package/dist/{chunk-AEVLFZRK.js.map → chunk-PSLT5JLE.js.map} +1 -1
  23. package/dist/{chunk-PDS57QPD.mjs → chunk-TL5O7EGW.mjs} +2 -2
  24. package/dist/{chunk-R2XBVIO5.js → chunk-UT4GVYJE.js} +1067 -874
  25. package/dist/chunk-UT4GVYJE.js.map +1 -0
  26. package/dist/{chunk-OJAIKQR2.js → chunk-UZP7KRAV.js} +432 -233
  27. package/dist/chunk-UZP7KRAV.js.map +1 -0
  28. package/dist/{chunk-7GB5MR77.mjs → chunk-VT5HRZH7.mjs} +200 -1
  29. package/dist/chunk-VT5HRZH7.mjs.map +1 -0
  30. package/dist/{chunk-AMN2XDN5.js → chunk-ZXK2OMCC.js} +8 -8
  31. package/dist/{chunk-AMN2XDN5.js.map → chunk-ZXK2OMCC.js.map} +1 -1
  32. package/dist/client/index.d.mts +3 -3
  33. package/dist/client/index.d.ts +3 -3
  34. package/dist/client/index.js +4 -4
  35. package/dist/client/index.mjs +3 -3
  36. package/dist/components/index.d.mts +41 -6
  37. package/dist/components/index.d.ts +41 -6
  38. package/dist/components/index.js +12 -4
  39. package/dist/components/index.js.map +1 -1
  40. package/dist/components/index.mjs +11 -3
  41. package/dist/contexts/index.d.mts +4 -4
  42. package/dist/contexts/index.d.ts +4 -4
  43. package/dist/contexts/index.js +4 -4
  44. package/dist/contexts/index.mjs +3 -3
  45. package/dist/core/index.d.mts +123 -11
  46. package/dist/core/index.d.ts +123 -11
  47. package/dist/core/index.js +14 -2
  48. package/dist/core/index.js.map +1 -1
  49. package/dist/core/index.mjs +13 -1
  50. package/dist/email-automations/index.js +92 -92
  51. package/dist/email-automations/index.mjs +3 -3
  52. package/dist/features/analytics/index.d.mts +1 -1
  53. package/dist/features/analytics/index.d.ts +1 -1
  54. package/dist/features/analytics/index.js +121 -121
  55. package/dist/features/analytics/index.mjs +4 -4
  56. package/dist/features/analytics/server.js +4 -4
  57. package/dist/features/analytics/server.mjs +2 -2
  58. package/dist/features/blog/index.d.mts +3 -3
  59. package/dist/features/blog/index.d.ts +3 -3
  60. package/dist/features/blog/index.js +150 -150
  61. package/dist/features/blog/index.mjs +3 -3
  62. package/dist/features/blog/server.d.mts +3 -3
  63. package/dist/features/blog/server.d.ts +3 -3
  64. package/dist/features/blog/server.js +16 -16
  65. package/dist/features/blog/server.mjs +1 -1
  66. package/dist/features/help/index.js +37 -37
  67. package/dist/features/help/index.mjs +3 -3
  68. package/dist/features/tokenusage/index.js +127 -127
  69. package/dist/features/tokenusage/index.mjs +4 -4
  70. package/dist/index.d.mts +7 -7
  71. package/dist/index.d.ts +7 -7
  72. package/dist/index.js +15 -3
  73. package/dist/index.js.map +1 -1
  74. package/dist/index.mjs +14 -2
  75. package/dist/{notification.interface-DQReXAD7.d.ts → notification.interface-DQItyY_Q.d.ts} +1 -1
  76. package/dist/{notification.interface-CF5h90U2.d.mts → notification.interface-DoVS5RZB.d.mts} +1 -1
  77. package/dist/{s3.service-BNBD9YTg.d.mts → s3.service-BG136Btz.d.mts} +3 -3
  78. package/dist/{s3.service-Da7C2gtt.d.ts → s3.service-CsrsRPRn.d.ts} +3 -3
  79. package/dist/server/index.d.mts +4 -4
  80. package/dist/server/index.d.ts +4 -4
  81. package/dist/server/index.js +3 -3
  82. package/dist/server/index.mjs +2 -2
  83. package/dist/{useSocket-CwSoq6VS.d.mts → useSocket-C8fqU4od.d.mts} +1 -1
  84. package/dist/{useSocket-BM3q9A0C.d.ts → useSocket-IRHtk2xc.d.ts} +1 -1
  85. package/dist/{user.interface-BYnGJ7ss.d.mts → user.interface-Bm-0TbsB.d.mts} +6 -0
  86. package/dist/{user.interface-BqPjVyJI.d.ts → user.interface-CKBIEvNu.d.ts} +6 -0
  87. package/messages/en.json +24 -0
  88. package/messages/it.json +24 -0
  89. package/package.json +1 -1
  90. package/src/components/index.ts +1 -0
  91. package/src/core/index.ts +5 -0
  92. package/src/core/registry/ModuleRegistry.ts +13 -0
  93. package/src/features/account-deletion/account-deletion.module.ts +13 -0
  94. package/src/features/account-deletion/components/AccountDeletionAdminTrigger.tsx +183 -0
  95. package/src/features/account-deletion/components/AccountDeletionCancelledNotice.tsx +51 -0
  96. package/src/features/account-deletion/components/AccountDeletionKeepContainer.tsx +74 -0
  97. package/src/features/account-deletion/components/index.ts +3 -0
  98. package/src/features/account-deletion/data/__tests__/AccountDeletion.spec.ts +89 -0
  99. package/src/features/account-deletion/data/account-deletion.interface.ts +22 -0
  100. package/src/features/account-deletion/data/account-deletion.service.ts +69 -0
  101. package/src/features/account-deletion/data/account-deletion.ts +90 -0
  102. package/src/features/account-deletion/data/index.ts +3 -0
  103. package/src/features/account-deletion/index.ts +4 -0
  104. package/src/features/account-deletion/utils/__tests__/account-deletion-notice.spec.ts +40 -0
  105. package/src/features/account-deletion/utils/account-deletion-notice.ts +27 -0
  106. package/src/features/account-deletion/utils/index.ts +1 -0
  107. package/src/features/auth/components/forms/Cookies.tsx +3 -0
  108. package/src/features/auth/components/forms/TwoFactorChallenge.tsx +2 -0
  109. package/src/features/auth/data/__tests__/auth.spec.ts +36 -0
  110. package/src/features/auth/data/auth.interface.ts +2 -0
  111. package/src/features/auth/data/auth.service.ts +4 -0
  112. package/src/features/auth/data/auth.ts +7 -0
  113. package/src/features/company/data/company.interface.ts +7 -0
  114. package/src/features/company/data/company.spec.ts +23 -0
  115. package/src/features/company/data/company.ts +6 -0
  116. package/src/features/company/hooks/useSubscriptionStatus.spec.ts +59 -0
  117. package/src/features/company/hooks/useSubscriptionStatus.ts +5 -3
  118. package/src/features/user/contexts/UserContext.tsx +8 -0
  119. package/dist/chunk-7GB5MR77.mjs.map +0 -1
  120. package/dist/chunk-IDV534SJ.mjs.map +0 -1
  121. package/dist/chunk-OJAIKQR2.js.map +0 -1
  122. package/dist/chunk-R2XBVIO5.js.map +0 -1
  123. /package/dist/{BlockNoteEditor-MWGVWNSE.mjs.map → BlockNoteEditor-D3LDTJCP.mjs.map} +0 -0
  124. /package/dist/{BlockNoteViewer-VNU7WVN5.mjs.map → BlockNoteViewer-YSPYUDZE.mjs.map} +0 -0
  125. /package/dist/{chunk-RSMBRI3E.mjs.map → chunk-5HBFQEYU.mjs.map} +0 -0
  126. /package/dist/{chunk-IQ2XYAB5.mjs.map → chunk-D44UDP4G.mjs.map} +0 -0
  127. /package/dist/{chunk-PDS57QPD.mjs.map → chunk-TL5O7EGW.mjs.map} +0 -0
@@ -1038,6 +1038,14 @@ var ModuleRegistryClass = class {
1038
1038
  }
1039
1039
  return module;
1040
1040
  }
1041
+ /**
1042
+ * True when a module is registered under `name`. Never throws, so a component
1043
+ * can check for an opt-in module the app may not have registered.
1044
+ */
1045
+ has(name) {
1046
+ if (this._modules.size === 0) tryBootstrap();
1047
+ return this._modules.has(name);
1048
+ }
1041
1049
  findByName(moduleName) {
1042
1050
  if (this._modules.size === 0) {
1043
1051
  tryBootstrap();
@@ -2572,6 +2580,179 @@ function getValueFromPath(obj, path, userId) {
2572
2580
  }
2573
2581
  __name(getValueFromPath, "getValueFromPath");
2574
2582
 
2583
+ // src/features/account-deletion/data/account-deletion.ts
2584
+ import { v4 as v43 } from "uuid";
2585
+ var AccountDeletion = class extends AbstractApiData {
2586
+ static {
2587
+ __name(this, "AccountDeletion");
2588
+ }
2589
+ _requestedAt;
2590
+ _scheduledAt;
2591
+ _hasDeliverableEmail = false;
2592
+ _hasActiveSubscription = false;
2593
+ _deletesCompany = false;
2594
+ _ownedCount = 0;
2595
+ _otherTables;
2596
+ get requestedAt() {
2597
+ return this._requestedAt;
2598
+ }
2599
+ get scheduledAt() {
2600
+ return this._scheduledAt;
2601
+ }
2602
+ get hasDeliverableEmail() {
2603
+ return this._hasDeliverableEmail;
2604
+ }
2605
+ get hasActiveSubscription() {
2606
+ return this._hasActiveSubscription;
2607
+ }
2608
+ get deletesCompany() {
2609
+ return this._deletesCompany;
2610
+ }
2611
+ get ownedCount() {
2612
+ return this._ownedCount;
2613
+ }
2614
+ get otherTables() {
2615
+ return this._otherTables ?? [];
2616
+ }
2617
+ rehydrate(data) {
2618
+ super.rehydrate(data);
2619
+ const attributes = data.jsonApi.attributes ?? {};
2620
+ this._requestedAt = attributes.requestedAt ? new Date(attributes.requestedAt) : void 0;
2621
+ this._scheduledAt = attributes.scheduledAt ? new Date(attributes.scheduledAt) : void 0;
2622
+ this._hasDeliverableEmail = attributes.hasDeliverableEmail === true;
2623
+ this._hasActiveSubscription = attributes.hasActiveSubscription === true;
2624
+ this._deletesCompany = attributes.deletesCompany === true;
2625
+ this._ownedCount = typeof attributes.ownedCount === "number" ? attributes.ownedCount : 0;
2626
+ this._otherTables = Array.isArray(attributes.otherTables) ? attributes.otherTables : [];
2627
+ return this;
2628
+ }
2629
+ createJsonApi(data) {
2630
+ const response = {
2631
+ data: {
2632
+ type: Modules.AccountDeletion.name,
2633
+ id: data.id,
2634
+ attributes: {
2635
+ confirmation: data.confirmation
2636
+ },
2637
+ meta: {},
2638
+ relationships: {}
2639
+ },
2640
+ included: []
2641
+ };
2642
+ return response;
2643
+ }
2644
+ /**
2645
+ * Body of the public "Keep my account" call. The caller is not signed in and
2646
+ * has no id to send: the API validates a client UUID and ignores its value.
2647
+ */
2648
+ createKeepJsonApi(params) {
2649
+ return {
2650
+ data: {
2651
+ type: Modules.AccountDeletion.name,
2652
+ id: v43(),
2653
+ attributes: {
2654
+ token: params.token
2655
+ }
2656
+ }
2657
+ };
2658
+ }
2659
+ };
2660
+
2661
+ // src/features/account-deletion/account-deletion.module.ts
2662
+ var AccountDeletionModule = /* @__PURE__ */ __name((factory) => factory({
2663
+ name: "account-deletions",
2664
+ pageUrl: "/account-deletions",
2665
+ model: AccountDeletion
2666
+ }), "AccountDeletionModule");
2667
+
2668
+ // src/features/account-deletion/data/account-deletion.service.ts
2669
+ var AccountDeletionService = class extends AbstractService {
2670
+ static {
2671
+ __name(this, "AccountDeletionService");
2672
+ }
2673
+ /**
2674
+ * GET the signed-in user's deletion status and what a deletion would remove.
2675
+ */
2676
+ static async findMine() {
2677
+ return this.callApi({
2678
+ type: Modules.AccountDeletion,
2679
+ method: "GET" /* GET */,
2680
+ endpoint: new EndpointCreator({ endpoint: Modules.AccountDeletion, id: "me" }).generate()
2681
+ });
2682
+ }
2683
+ /**
2684
+ * GET another user's deletion status (platform administrators only).
2685
+ */
2686
+ static async findByUser(params) {
2687
+ return this.callApi({
2688
+ type: Modules.AccountDeletion,
2689
+ method: "GET" /* GET */,
2690
+ endpoint: new EndpointCreator({ endpoint: Modules.AccountDeletion, id: params.userId }).generate()
2691
+ });
2692
+ }
2693
+ /**
2694
+ * POST the signed-in user's own deletion request. `params.id` must be the
2695
+ * signed-in user's id.
2696
+ */
2697
+ static async request(params) {
2698
+ return this.callApi({
2699
+ type: Modules.AccountDeletion,
2700
+ method: "POST" /* POST */,
2701
+ endpoint: new EndpointCreator({ endpoint: Modules.AccountDeletion }).generate(),
2702
+ input: params
2703
+ });
2704
+ }
2705
+ /**
2706
+ * POST a deletion request on behalf of another user (platform administrators
2707
+ * only). Runs the same 7-day request as the user's own.
2708
+ */
2709
+ static async requestForUser(params) {
2710
+ return this.callApi({
2711
+ type: Modules.AccountDeletion,
2712
+ method: "POST" /* POST */,
2713
+ endpoint: new EndpointCreator({ endpoint: Modules.AccountDeletion, id: params.id }).generate(),
2714
+ input: params
2715
+ });
2716
+ }
2717
+ /**
2718
+ * POST the token from the "Keep my account" email link. Public: no session.
2719
+ * Throws on any failure, so the page can show the "link no longer works" text.
2720
+ */
2721
+ static async keep(params) {
2722
+ const accountDeletion = new AccountDeletion();
2723
+ await this.callApi({
2724
+ type: Modules.AccountDeletion,
2725
+ method: "POST" /* POST */,
2726
+ endpoint: new EndpointCreator({ endpoint: Modules.AccountDeletion, id: "keep" }).generate(),
2727
+ input: accountDeletion.createKeepJsonApi({ token: params.token }),
2728
+ overridesJsonApiCreation: true,
2729
+ // OK - model method provides proper structure
2730
+ suppressGlobalError: true
2731
+ });
2732
+ }
2733
+ };
2734
+
2735
+ // src/features/account-deletion/utils/account-deletion-notice.ts
2736
+ var ACCOUNT_DELETION_CANCELLED_KEY = "nja:accountDeletionCancelled";
2737
+ function markAccountDeletionCancelled() {
2738
+ try {
2739
+ sessionStorage.setItem(ACCOUNT_DELETION_CANCELLED_KEY, "1");
2740
+ } catch {
2741
+ }
2742
+ }
2743
+ __name(markAccountDeletionCancelled, "markAccountDeletionCancelled");
2744
+ function consumeAccountDeletionCancelled() {
2745
+ try {
2746
+ const value = sessionStorage.getItem(ACCOUNT_DELETION_CANCELLED_KEY);
2747
+ if (value === null) return false;
2748
+ sessionStorage.removeItem(ACCOUNT_DELETION_CANCELLED_KEY);
2749
+ return true;
2750
+ } catch {
2751
+ return false;
2752
+ }
2753
+ }
2754
+ __name(consumeAccountDeletionCancelled, "consumeAccountDeletionCancelled");
2755
+
2575
2756
  // src/features/auth/data/totp-authenticator.ts
2576
2757
  var TotpAuthenticator = class extends AbstractApiData {
2577
2758
  static {
@@ -3041,6 +3222,11 @@ var Auth = class extends AbstractApiData {
3041
3222
  _token;
3042
3223
  _refreshToken;
3043
3224
  _user;
3225
+ _deletionCancelled = false;
3226
+ /** True on the session created by the login that cancelled a pending account deletion. */
3227
+ get deletionCancelled() {
3228
+ return this._deletionCancelled;
3229
+ }
3044
3230
  get token() {
3045
3231
  if (!this._token) throw new Error("Token is not defined");
3046
3232
  return this._token;
@@ -3057,6 +3243,7 @@ var Auth = class extends AbstractApiData {
3057
3243
  super.rehydrate(data);
3058
3244
  this._token = data.jsonApi.attributes.token ?? void 0;
3059
3245
  this._refreshToken = data.jsonApi.attributes.refreshToken ?? void 0;
3246
+ this._deletionCancelled = data.jsonApi.attributes.deletionCancelled === true;
3060
3247
  this._user = this._readIncluded(data, "user", Modules.User);
3061
3248
  return this;
3062
3249
  }
@@ -3112,6 +3299,7 @@ var AuthService = class extends AbstractService {
3112
3299
  return challenge;
3113
3300
  }
3114
3301
  const auth = apiResponse.data;
3302
+ if (auth.deletionCancelled) markAccountDeletionCancelled();
3115
3303
  const handler = getTokenHandler();
3116
3304
  if (handler) {
3117
3305
  await handler.updateToken({
@@ -6231,6 +6419,7 @@ var Company = class extends AbstractApiData {
6231
6419
  _logoUrl;
6232
6420
  _configurations;
6233
6421
  _isActiveSubscription = false;
6422
+ _trialEndsAt;
6234
6423
  _monthlyCredits = 0;
6235
6424
  _availableMonthlyCredits = 0;
6236
6425
  _availableExtraCredits = 0;
@@ -6264,6 +6453,9 @@ var Company = class extends AbstractApiData {
6264
6453
  get isActiveSubscription() {
6265
6454
  return this._isActiveSubscription ?? false;
6266
6455
  }
6456
+ get trialEndsAt() {
6457
+ return this._trialEndsAt;
6458
+ }
6267
6459
  get monthlyCredits() {
6268
6460
  return this._monthlyCredits ?? 0;
6269
6461
  }
@@ -6334,6 +6526,7 @@ var Company = class extends AbstractApiData {
6334
6526
  this._logo = data.jsonApi.attributes.logo;
6335
6527
  this._logoUrl = data.jsonApi.attributes.logoUrl;
6336
6528
  this._isActiveSubscription = data.jsonApi.attributes.isActiveSubscription ?? false;
6529
+ this._trialEndsAt = data.jsonApi.attributes.trialEndsAt ? new Date(data.jsonApi.attributes.trialEndsAt) : void 0;
6337
6530
  this._monthlyCredits = data.jsonApi.attributes.monthlyCredits ?? 0;
6338
6531
  this._availableMonthlyCredits = data.jsonApi.attributes.availableMonthlyCredits ?? 0;
6339
6532
  this._availableExtraCredits = data.jsonApi.attributes.availableExtraCredits ?? 0;
@@ -12222,6 +12415,12 @@ export {
12222
12415
  checkPermissions,
12223
12416
  checkPermissionsFromServer,
12224
12417
  getValueFromPath,
12418
+ AccountDeletion,
12419
+ AccountDeletionModule,
12420
+ AccountDeletionService,
12421
+ ACCOUNT_DELETION_CANCELLED_KEY,
12422
+ markAccountDeletionCancelled,
12423
+ consumeAccountDeletionCancelled,
12225
12424
  TotpAuthenticator,
12226
12425
  TotpAuthenticatorModule,
12227
12426
  TotpSetup,
@@ -12469,4 +12668,4 @@ export {
12469
12668
  AuditLogService,
12470
12669
  AuditLogModule
12471
12670
  };
12472
- //# sourceMappingURL=chunk-7GB5MR77.mjs.map
12671
+ //# sourceMappingURL=chunk-VT5HRZH7.mjs.map