@carlonicora/nextjs-jsonapi 6.15.0 → 6.17.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 (118) hide show
  1. package/dist/{BlockNoteEditor-UIAX72XW.js → BlockNoteEditor-FAUTV5FW.js} +20 -20
  2. package/dist/{BlockNoteEditor-UIAX72XW.js.map → BlockNoteEditor-FAUTV5FW.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-I3J6YYXK.mjs → BlockNoteEditor-IGUHTERQ.mjs} +5 -5
  4. package/dist/{BlockNoteViewer-HIUAJQRI.mjs → BlockNoteViewer-X4UEVI2A.mjs} +3 -3
  5. package/dist/{BlockNoteViewer-APBOPT4B.js → BlockNoteViewer-XYKFY77F.js} +4 -4
  6. package/dist/{BlockNoteViewer-APBOPT4B.js.map → BlockNoteViewer-XYKFY77F.js.map} +1 -1
  7. package/dist/EmailPurpose-DOsSqM5K.d.mts +3 -0
  8. package/dist/EmailPurpose-DOsSqM5K.d.ts +3 -0
  9. package/dist/billing/index.js +492 -492
  10. package/dist/billing/index.mjs +4 -4
  11. package/dist/{chunk-RT7XFGIN.js → chunk-4OCBNCKH.js} +1041 -999
  12. package/dist/chunk-4OCBNCKH.js.map +1 -0
  13. package/dist/{chunk-4XLDBOSE.js → chunk-A7Y5YW7Q.js} +1 -1
  14. package/dist/{chunk-4XLDBOSE.js.map → chunk-A7Y5YW7Q.js.map} +1 -1
  15. package/dist/{chunk-ZYSNJKOP.js → chunk-DFA566KY.js} +4 -4
  16. package/dist/{chunk-ZYSNJKOP.js.map → chunk-DFA566KY.js.map} +1 -1
  17. package/dist/{chunk-DJXSCARG.js → chunk-I5BQLY7V.js} +9 -9
  18. package/dist/{chunk-DJXSCARG.js.map → chunk-I5BQLY7V.js.map} +1 -1
  19. package/dist/{chunk-RFKSJIQB.mjs → chunk-KMPBSOFB.mjs} +138 -5
  20. package/dist/chunk-KMPBSOFB.mjs.map +1 -0
  21. package/dist/{chunk-UOTHRJD2.mjs → chunk-OKBJEIOP.mjs} +1 -1
  22. package/dist/chunk-OKBJEIOP.mjs.map +1 -0
  23. package/dist/{chunk-PMESKNKL.js → chunk-OO2DBP6L.js} +1106 -973
  24. package/dist/chunk-OO2DBP6L.js.map +1 -0
  25. package/dist/{chunk-RYY7USSW.mjs → chunk-RINMQQZH.mjs} +56 -14
  26. package/dist/{chunk-RYY7USSW.mjs.map → chunk-RINMQQZH.mjs.map} +1 -1
  27. package/dist/{chunk-HAW5PNJG.mjs → chunk-TY5YWBLL.mjs} +3 -3
  28. package/dist/{chunk-OUEYZOLB.mjs → chunk-YVKWACDP.mjs} +2 -2
  29. package/dist/client/index.js +5 -5
  30. package/dist/client/index.mjs +4 -4
  31. package/dist/components/index.d.mts +10 -3
  32. package/dist/components/index.d.ts +10 -3
  33. package/dist/components/index.js +5 -5
  34. package/dist/components/index.mjs +4 -4
  35. package/dist/contexts/index.js +5 -5
  36. package/dist/contexts/index.mjs +4 -4
  37. package/dist/core/index.d.mts +92 -7
  38. package/dist/core/index.d.ts +92 -7
  39. package/dist/core/index.js +7 -3
  40. package/dist/core/index.js.map +1 -1
  41. package/dist/core/index.mjs +6 -2
  42. package/dist/{email-automation-enrollment.fields-BZvF14qx.d.mts → email-automation-enrollment.fields-CPsgxLif.d.mts} +11 -1
  43. package/dist/{email-automation-enrollment.fields-Cp3VMzFq.d.ts → email-automation-enrollment.fields-CVicSamF.d.ts} +11 -1
  44. package/dist/email-automations/index.d.mts +19 -5
  45. package/dist/email-automations/index.d.ts +19 -5
  46. package/dist/email-automations/index.js +356 -129
  47. package/dist/email-automations/index.js.map +1 -1
  48. package/dist/email-automations/index.mjs +306 -79
  49. package/dist/email-automations/index.mjs.map +1 -1
  50. package/dist/features/analytics/index.js +121 -121
  51. package/dist/features/analytics/index.mjs +4 -4
  52. package/dist/features/analytics/server.js +5 -5
  53. package/dist/features/analytics/server.mjs +3 -3
  54. package/dist/features/blog/index.js +151 -151
  55. package/dist/features/blog/index.mjs +4 -4
  56. package/dist/features/blog/server.js +17 -17
  57. package/dist/features/blog/server.mjs +2 -2
  58. package/dist/features/help/index.js +38 -38
  59. package/dist/features/help/index.mjs +4 -4
  60. package/dist/features/tokenusage/index.js +127 -127
  61. package/dist/features/tokenusage/index.mjs +4 -4
  62. package/dist/index.d.mts +4 -3
  63. package/dist/index.d.ts +4 -3
  64. package/dist/index.js +8 -4
  65. package/dist/index.js.map +1 -1
  66. package/dist/index.mjs +7 -3
  67. package/dist/offline/index.js +14 -14
  68. package/dist/offline/index.mjs +1 -1
  69. package/dist/{referral-admin.interface-RVO-ZTJz.d.mts → referral-admin.interface-DTj4LzXx.d.mts} +3 -0
  70. package/dist/{referral-admin.interface-CnytdDaQ.d.ts → referral-admin.interface-DeSCw3Pp.d.ts} +3 -0
  71. package/dist/server/index.js +4 -4
  72. package/dist/server/index.mjs +3 -3
  73. package/messages/en.json +35 -3
  74. package/messages/it.json +35 -3
  75. package/package.json +1 -1
  76. package/src/core/index.ts +1 -0
  77. package/src/core/registry/ModuleRegistry.ts +1 -0
  78. package/src/features/email-automation/EmailAutomationCandidateModule.ts +12 -0
  79. package/src/features/email-automation/EmailAutomationModule.ts +1 -0
  80. package/src/features/email-automation/components/__tests__/EmailAutomationEditor.spec.tsx +74 -9
  81. package/src/features/email-automation/components/forms/EmailAutomationAddPersonDialog.tsx +226 -0
  82. package/src/features/email-automation/components/forms/EmailAutomationEditor.tsx +23 -0
  83. package/src/features/email-automation/components/forms/EmailStepEditor.tsx +7 -3
  84. package/src/features/email-automation/components/index.ts +1 -0
  85. package/src/features/email-automation/components/lists/EmailAutomationRecipientsList.tsx +38 -20
  86. package/src/features/email-automation/components/lists/EmailAutomationsList.tsx +1 -0
  87. package/src/features/email-automation/components/unsubscribe/EmailUnsubscribe.tsx +9 -4
  88. package/src/features/email-automation/data/EmailAutomation.ts +9 -0
  89. package/src/features/email-automation/data/EmailAutomationCandidate.ts +66 -0
  90. package/src/features/email-automation/data/EmailAutomationCandidateInterface.ts +19 -0
  91. package/src/features/email-automation/data/EmailAutomationEnrollment.ts +16 -2
  92. package/src/features/email-automation/data/EmailAutomationEnrollmentInterface.ts +7 -0
  93. package/src/features/email-automation/data/EmailAutomationInterface.ts +3 -0
  94. package/src/features/email-automation/data/EmailAutomationService.ts +53 -1
  95. package/src/features/email-automation/data/EmailPurpose.ts +1 -0
  96. package/src/features/email-automation/data/__tests__/email-automation-models.spec.ts +70 -0
  97. package/src/features/email-automation/data/email-automation.fields.ts +1 -0
  98. package/src/features/email-automation/data/index.ts +2 -0
  99. package/src/features/email-automation/hooks/useEmailAutomationTableStructure.tsx +19 -0
  100. package/src/features/email-automation/index.ts +2 -0
  101. package/src/features/email-blast/EmailBlastModule.ts +1 -0
  102. package/src/features/email-blast/components/forms/EmailBlastEditor.tsx +33 -4
  103. package/src/features/email-blast/components/lists/EmailBlastsList.tsx +1 -0
  104. package/src/features/email-blast/data/EmailBlast.ts +10 -1
  105. package/src/features/email-blast/data/EmailBlastInterface.ts +3 -0
  106. package/src/features/email-blast/data/__tests__/EmailBlast.spec.ts +18 -0
  107. package/src/features/email-blast/data/email-blast.fields.ts +1 -0
  108. package/src/features/email-blast/hooks/useEmailBlastTableStructure.tsx +15 -0
  109. package/src/features/notification/components/notifications/PushNotificationProvider.tsx +14 -2
  110. package/src/features/notification/components/notifications/__tests__/PushNotificationProvider.spec.tsx +11 -0
  111. package/dist/chunk-PMESKNKL.js.map +0 -1
  112. package/dist/chunk-RFKSJIQB.mjs.map +0 -1
  113. package/dist/chunk-RT7XFGIN.js.map +0 -1
  114. package/dist/chunk-UOTHRJD2.mjs.map +0 -1
  115. /package/dist/{BlockNoteEditor-I3J6YYXK.mjs.map → BlockNoteEditor-IGUHTERQ.mjs.map} +0 -0
  116. /package/dist/{BlockNoteViewer-HIUAJQRI.mjs.map → BlockNoteViewer-X4UEVI2A.mjs.map} +0 -0
  117. /package/dist/{chunk-HAW5PNJG.mjs.map → chunk-TY5YWBLL.mjs.map} +0 -0
  118. /package/dist/{chunk-OUEYZOLB.mjs.map → chunk-YVKWACDP.mjs.map} +0 -0
@@ -19,7 +19,7 @@ import {
19
19
  isReferralEnabled,
20
20
  isRegistrationAllowed,
21
21
  useWaitlistText
22
- } from "./chunk-HAW5PNJG.mjs";
22
+ } from "./chunk-TY5YWBLL.mjs";
23
23
  import {
24
24
  getRoleId,
25
25
  isRolesConfigured
@@ -96,7 +96,7 @@ import {
96
96
  useIsMobile,
97
97
  validateItalianTaxCode,
98
98
  validatePartitaIva
99
- } from "./chunk-RFKSJIQB.mjs";
99
+ } from "./chunk-KMPBSOFB.mjs";
100
100
  import {
101
101
  useOfflineState
102
102
  } from "./chunk-OY65RYD3.mjs";
@@ -110,7 +110,7 @@ import {
110
110
  useI18nLocale,
111
111
  useI18nRouter,
112
112
  useI18nTranslations
113
- } from "./chunk-UOTHRJD2.mjs";
113
+ } from "./chunk-OKBJEIOP.mjs";
114
114
  import {
115
115
  CURRENT_USER_STORAGE_KEY
116
116
  } from "./chunk-AUD6ZLBB.mjs";
@@ -10852,7 +10852,7 @@ import { useRef as useRef18 } from "react";
10852
10852
  import dynamic from "next/dynamic";
10853
10853
  import React18 from "react";
10854
10854
  import { jsx as jsx91 } from "react/jsx-runtime";
10855
- var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-I3J6YYXK.mjs"), {
10855
+ var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-IGUHTERQ.mjs"), {
10856
10856
  ssr: false
10857
10857
  });
10858
10858
  var BlockNoteEditorContainer = React18.memo(/* @__PURE__ */ __name(function EditorContainer(props) {
@@ -17085,7 +17085,7 @@ __name(BlockNoteEditorMentionSuggestionMenu, "BlockNoteEditorMentionSuggestionMe
17085
17085
  import dynamic2 from "next/dynamic";
17086
17086
  import React29 from "react";
17087
17087
  import { jsx as jsx178 } from "react/jsx-runtime";
17088
- var BlockNoteViewer = dynamic2(() => import("./BlockNoteViewer-HIUAJQRI.mjs").then((m) => m.BlockNoteViewer), { ssr: false });
17088
+ var BlockNoteViewer = dynamic2(() => import("./BlockNoteViewer-X4UEVI2A.mjs").then((m) => m.BlockNoteViewer), { ssr: false });
17089
17089
  var BlockNoteViewerContainer = React29.memo(/* @__PURE__ */ __name(function ViewerContainer(props) {
17090
17090
  return /* @__PURE__ */ jsx178(BlockNoteViewer, { ...props });
17091
17091
  }, "ViewerContainer"));
@@ -23121,6 +23121,17 @@ var useEmailBlastTableStructure = /* @__PURE__ */ __name((params) => {
23121
23121
  enableSorting: false,
23122
23122
  enableHiding: false
23123
23123
  }),
23124
+ ["purpose" /* purpose */]: () => ({
23125
+ id: "purpose",
23126
+ accessorKey: "purpose",
23127
+ header: t("emailBlasts.list.columns.purpose"),
23128
+ cell: /* @__PURE__ */ __name(({ row }) => {
23129
+ const blast = row.original.jsonApiData;
23130
+ return blast.purpose === "service" ? /* @__PURE__ */ jsx245(Badge, { variant: "softBlue", children: t("emailPurpose.service") }) : /* @__PURE__ */ jsx245(Badge, { variant: "softGray", children: t("emailPurpose.marketing") });
23131
+ }, "cell"),
23132
+ enableSorting: false,
23133
+ enableHiding: false
23134
+ }),
23124
23135
  ["status" /* status */]: () => ({
23125
23136
  id: "status",
23126
23137
  accessorKey: "status",
@@ -23167,7 +23178,8 @@ import { useForm as useForm12 } from "react-hook-form";
23167
23178
  import { v4 as v413 } from "uuid";
23168
23179
  import { z as z13 } from "zod";
23169
23180
  import { Fragment as Fragment47, jsx as jsx246, jsxs as jsxs143 } from "react/jsx-runtime";
23170
- var TEMPLATE_VARIABLES = ["{{name}}", "{{email}}", "{{url}}", "{{unsubscribeAllUrl}}"];
23181
+ var TEMPLATE_VARIABLES = ["{{name}}", "{{email}}", "{{url}}"];
23182
+ var MARKETING_ONLY_VARIABLES = ["{{unsubscribeAllUrl}}"];
23171
23183
  function EmailBlastEditorInternal({
23172
23184
  blast,
23173
23185
  propagateChanges,
@@ -23188,7 +23200,8 @@ function EmailBlastEditorInternal({
23188
23200
  body: z13.string().min(1, { message: t("emailBlasts.editor.fields.body.error") }),
23189
23201
  replyTo: z13.string().refine((value) => value === "" || z13.email().safeParse(value).success, {
23190
23202
  message: t("emailBlasts.editor.fields.replyTo.error")
23191
- })
23203
+ }),
23204
+ purpose: z13.enum(["service", "marketing"], { message: t("emailPurpose.error") })
23192
23205
  }),
23193
23206
  [t]
23194
23207
  );
@@ -23197,7 +23210,9 @@ function EmailBlastEditorInternal({
23197
23210
  id: blast?.id ?? v413(),
23198
23211
  subject: blast?.subject ?? "",
23199
23212
  body: blast?.body ?? "",
23200
- replyTo: blast?.replyTo ?? ""
23213
+ replyTo: blast?.replyTo ?? "",
23214
+ // No preselected value on create: the form refuses to save without a choice.
23215
+ purpose: blast?.purpose ?? ""
23201
23216
  }),
23202
23217
  [blast]
23203
23218
  );
@@ -23205,6 +23220,15 @@ function EmailBlastEditorInternal({
23205
23220
  resolver: zodResolver12(formSchema),
23206
23221
  defaultValues: getDefaultValues()
23207
23222
  });
23223
+ const purpose = form.watch("purpose");
23224
+ const templateVariables = purpose === "service" ? TEMPLATE_VARIABLES : [...TEMPLATE_VARIABLES, ...MARKETING_ONLY_VARIABLES];
23225
+ const purposeValues = useMemo46(
23226
+ () => [
23227
+ { id: "service", text: t("emailPurpose.service") },
23228
+ { id: "marketing", text: t("emailPurpose.marketing") }
23229
+ ],
23230
+ [t]
23231
+ );
23208
23232
  return /* @__PURE__ */ jsx246(
23209
23233
  EditorSheet,
23210
23234
  {
@@ -23223,7 +23247,8 @@ function EmailBlastEditorInternal({
23223
23247
  id: values.id,
23224
23248
  subject: values.subject,
23225
23249
  body: values.body,
23226
- replyTo: values.replyTo || void 0
23250
+ replyTo: values.replyTo || void 0,
23251
+ purpose: values.purpose
23227
23252
  };
23228
23253
  return isEdit ? await EmailBlastService.update(payload) : await EmailBlastService.create(payload);
23229
23254
  },
@@ -23235,6 +23260,18 @@ function EmailBlastEditorInternal({
23235
23260
  onDialogOpenChange,
23236
23261
  children: /* @__PURE__ */ jsxs143("div", { className: "flex w-full flex-col gap-y-4", children: [
23237
23262
  /* @__PURE__ */ jsx246(FormInput, { form, id: "subject", name: t("emailBlasts.editor.fields.subject.label"), isRequired: true }),
23263
+ /* @__PURE__ */ jsx246(
23264
+ FormSelect,
23265
+ {
23266
+ form,
23267
+ id: "purpose",
23268
+ name: t("emailPurpose.label"),
23269
+ placeholder: t("emailPurpose.placeholder"),
23270
+ values: purposeValues,
23271
+ description: purpose === "service" ? t("emailPurpose.serviceWarning") : void 0,
23272
+ isRequired: true
23273
+ }
23274
+ ),
23238
23275
  /* @__PURE__ */ jsx246(FormInput, { form, id: "replyTo", name: t("emailBlasts.editor.fields.replyTo.label") }),
23239
23276
  /* @__PURE__ */ jsx246(
23240
23277
  FormTextarea,
@@ -23248,9 +23285,9 @@ function EmailBlastEditorInternal({
23248
23285
  /* @__PURE__ */ jsxs143("span", { className: "block", children: [
23249
23286
  t("emailBlasts.editor.variablesHint"),
23250
23287
  " ",
23251
- TEMPLATE_VARIABLES.map((variable) => /* @__PURE__ */ jsx246("span", { className: "me-2 text-foreground", children: variable }, variable))
23288
+ templateVariables.map((variable) => /* @__PURE__ */ jsx246("span", { className: "me-2 text-foreground", children: variable }, variable))
23252
23289
  ] }),
23253
- /* @__PURE__ */ jsx246("span", { className: "mt-1 block", children: t("emailBlasts.editor.unsubscribeHint") })
23290
+ /* @__PURE__ */ jsx246("span", { className: "mt-1 block", children: purpose === "service" ? t("emailBlasts.editor.serviceHint") : t("emailBlasts.editor.unsubscribeHint") })
23254
23291
  ] })
23255
23292
  }
23256
23293
  )
@@ -23281,6 +23318,7 @@ function EmailBlastsList({ fullWidth } = {}) {
23281
23318
  data,
23282
23319
  fields: [
23283
23320
  "subject" /* subject */,
23321
+ "purpose" /* purpose */,
23284
23322
  "status" /* status */,
23285
23323
  "sentAt" /* sentAt */,
23286
23324
  "sent" /* sent */,
@@ -26960,9 +26998,13 @@ __name(NotificationModal, "NotificationModal");
26960
26998
 
26961
26999
  // src/features/notification/components/notifications/PushNotificationProvider.tsx
26962
27000
  import { Fragment as Fragment62, jsx as jsx302 } from "react/jsx-runtime";
26963
- function PushNotificationProvider({ children }) {
27001
+ function PushNotificationProvider({
27002
+ children,
27003
+ excludedRoleIds = []
27004
+ }) {
26964
27005
  const { currentUser, hasRole } = useCurrentUserContext();
26965
- usePushNotifications_default({ currentUser: currentUser ?? void 0, canSubscribe: !hasRole(getRoleId().Administrator) });
27006
+ const canSubscribe = !hasRole(getRoleId().Administrator) && !excludedRoleIds.some((roleId) => hasRole(roleId));
27007
+ usePushNotifications_default({ currentUser: currentUser ?? void 0, canSubscribe });
26966
27008
  return /* @__PURE__ */ jsx302(Fragment62, { children });
26967
27009
  }
26968
27010
  __name(PushNotificationProvider, "PushNotificationProvider");
@@ -30788,4 +30830,4 @@ export {
30788
30830
  useOAuthClients,
30789
30831
  useOAuthClient
30790
30832
  };
30791
- //# sourceMappingURL=chunk-RYY7USSW.mjs.map
30833
+ //# sourceMappingURL=chunk-RINMQQZH.mjs.map