@carlonicora/nextjs-jsonapi 1.62.0 → 1.64.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 (51) hide show
  1. package/dist/{BlockNoteEditor-QQ4XFT4G.js → BlockNoteEditor-JF757BHH.js} +14 -14
  2. package/dist/{BlockNoteEditor-QQ4XFT4G.js.map → BlockNoteEditor-JF757BHH.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-TS62AHRY.mjs → BlockNoteEditor-ZO3ZAPXU.mjs} +4 -4
  4. package/dist/billing/index.js +346 -346
  5. package/dist/billing/index.mjs +3 -3
  6. package/dist/{chunk-BQSMP4NU.js → chunk-2DFE325P.js} +11 -11
  7. package/dist/{chunk-BQSMP4NU.js.map → chunk-2DFE325P.js.map} +1 -1
  8. package/dist/{chunk-K3DKXOEU.mjs → chunk-55FJ5WKS.mjs} +1172 -1224
  9. package/dist/chunk-55FJ5WKS.mjs.map +1 -0
  10. package/dist/{chunk-ZRKQQLYI.js → chunk-5LZGQXBD.js} +769 -821
  11. package/dist/chunk-5LZGQXBD.js.map +1 -0
  12. package/dist/{chunk-NAST4OSM.js → chunk-6YKYRKVU.js} +8 -2
  13. package/dist/chunk-6YKYRKVU.js.map +1 -0
  14. package/dist/{chunk-HRG4EAOG.mjs → chunk-PBD6ZH46.mjs} +2 -2
  15. package/dist/{chunk-YHNDD34Z.mjs → chunk-REWN5GZP.mjs} +8 -2
  16. package/dist/{chunk-YHNDD34Z.mjs.map → chunk-REWN5GZP.mjs.map} +1 -1
  17. package/dist/client/index.js +4 -4
  18. package/dist/client/index.mjs +3 -3
  19. package/dist/components/index.d.mts +11 -8
  20. package/dist/components/index.d.ts +11 -8
  21. package/dist/components/index.js +4 -6
  22. package/dist/components/index.js.map +1 -1
  23. package/dist/components/index.mjs +3 -5
  24. package/dist/contexts/index.d.mts +2 -1
  25. package/dist/contexts/index.d.ts +2 -1
  26. package/dist/contexts/index.js +4 -4
  27. package/dist/contexts/index.mjs +3 -3
  28. package/dist/core/index.js +2 -2
  29. package/dist/core/index.mjs +1 -1
  30. package/dist/index.js +3 -3
  31. package/dist/index.mjs +2 -2
  32. package/dist/scripts/generate-web-module/templates/components/selector.template.d.ts.map +1 -1
  33. package/dist/scripts/generate-web-module/templates/components/selector.template.js +52 -48
  34. package/dist/scripts/generate-web-module/templates/components/selector.template.js.map +1 -1
  35. package/dist/server/index.js +3 -3
  36. package/dist/server/index.mjs +1 -1
  37. package/package.json +1 -1
  38. package/scripts/generate-web-module/templates/components/selector.template.ts +52 -48
  39. package/src/features/company/company.module.ts +3 -1
  40. package/src/features/company/components/containers/CompanyContainer.tsx +7 -2
  41. package/src/features/company/components/details/CompanyDetails.tsx +16 -1
  42. package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +19 -51
  43. package/src/features/company/components/forms/index.ts +0 -1
  44. package/src/features/company/contexts/CompanyContext.tsx +5 -3
  45. package/src/features/user/user.module.ts +3 -1
  46. package/dist/chunk-K3DKXOEU.mjs.map +0 -1
  47. package/dist/chunk-NAST4OSM.js.map +0 -1
  48. package/dist/chunk-ZRKQQLYI.js.map +0 -1
  49. package/src/features/company/components/forms/CompanyConfigurationSecurityForm.tsx +0 -83
  50. /package/dist/{BlockNoteEditor-TS62AHRY.mjs.map → BlockNoteEditor-ZO3ZAPXU.mjs.map} +0 -0
  51. /package/dist/{chunk-HRG4EAOG.mjs.map → chunk-PBD6ZH46.mjs.map} +0 -0
@@ -3,8 +3,8 @@
3
3
  import { zodResolver } from "@hookform/resolvers/zod";
4
4
  import { Settings2Icon } from "lucide-react";
5
5
  import { useTranslations } from "next-intl";
6
- import { useEffect, useMemo, useState } from "react";
7
- import { SubmitHandler, useForm } from "react-hook-form";
6
+ import { ReactNode, useEffect, useState } from "react";
7
+ import { SubmitHandler, UseFormReturn, useForm } from "react-hook-form";
8
8
  import { showToast } from "../../../../utils/toast";
9
9
  import z from "zod";
10
10
  import { CommonEditorButtons, errorToast } from "../../../../components";
@@ -18,44 +18,37 @@ import {
18
18
  DialogTitle,
19
19
  DialogTrigger,
20
20
  Form,
21
- Tabs,
22
- TabsContent,
23
- TabsList,
24
- TabsTrigger,
25
21
  } from "../../../../shadcnui";
26
22
  import { UserInterface } from "../../../user";
27
23
  import { useCurrentUserContext } from "../../../user/contexts";
28
24
  import { UserService } from "../../../user/data/user.service";
29
25
  import { CompanyInput, CompanyInterface } from "../../data";
30
26
  import { CompanyService } from "../../data/company.service";
31
- import { CompanyConfigurationSecurityForm } from "./CompanyConfigurationSecurityForm";
32
27
 
33
28
  type CompanyConfigurationEditorProps = {
34
29
  company: CompanyInterface;
30
+ formSchema: z.ZodObject<any>;
31
+ defaultValues: Record<string, any>;
32
+ buildPayload: (values: Record<string, any>) => Partial<CompanyInput["configurations"]>;
33
+ children: (form: UseFormReturn<any>) => ReactNode;
35
34
  };
36
35
 
37
- function CompanyConfigurationEditorInternal({ company }: CompanyConfigurationEditorProps) {
36
+ function CompanyConfigurationEditorInternal({
37
+ company,
38
+ formSchema,
39
+ defaultValues,
40
+ buildPayload,
41
+ children,
42
+ }: CompanyConfigurationEditorProps) {
38
43
  const [open, setOpen] = useState<boolean>(false);
39
44
  const t = useTranslations();
40
45
  const { setUser } = useCurrentUserContext<UserInterface>();
41
46
 
42
- const defaultValues = useMemo(() => {
43
- return {
44
- isManagedKnowledge: company.configurations?.isManagedKnowledge ?? false,
45
- allowPublicBot: company.configurations?.allowPublicBot ?? false,
46
- };
47
- }, [company.configurations]);
48
-
49
47
  const close = () => {
50
48
  setOpen(false);
51
49
  form.reset();
52
50
  };
53
51
 
54
- const formSchema = z.object({
55
- isManagedKnowledge: z.boolean().optional(),
56
- allowPublicBot: z.boolean().optional(),
57
- });
58
-
59
52
  const form = useForm<z.infer<typeof formSchema>>({
60
53
  resolver: zodResolver(formSchema),
61
54
  defaultValues: defaultValues,
@@ -64,33 +57,26 @@ function CompanyConfigurationEditorInternal({ company }: CompanyConfigurationEdi
64
57
 
65
58
  useEffect(() => {
66
59
  if (open) {
67
- form.reset({
68
- isManagedKnowledge: company.configurations?.isManagedKnowledge ?? false,
69
- allowPublicBot: company.configurations?.allowPublicBot ?? false,
70
- });
60
+ form.reset(defaultValues);
71
61
  }
72
62
  }, [company, open]);
73
63
 
74
64
  const onSubmit: SubmitHandler<z.infer<typeof formSchema>> = async (values) => {
75
65
  const payload: CompanyInput = {
76
66
  id: company.id,
77
- configurations: {
78
- isManagedKnowledge: values.isManagedKnowledge ?? false,
79
- allowPublicBot: values.allowPublicBot ?? false,
80
- },
67
+ configurations: buildPayload(values),
81
68
  };
82
69
 
83
70
  try {
84
71
  await CompanyService.updateConfigurations(payload);
85
72
 
86
- // Refresh user data to update localStorage with new company configurations
87
73
  const fullUser = await UserService.findFullUser();
88
74
  if (fullUser) {
89
75
  setUser(fullUser);
90
76
  }
91
77
 
92
- showToast("Configurations Updated", {
93
- description: `The system configurations have been updated successfully.`,
78
+ showToast(t("features.configuration.updated_title"), {
79
+ description: t("features.configuration.updated_description"),
94
80
  });
95
81
  close();
96
82
  } catch (error) {
@@ -104,7 +90,7 @@ function CompanyConfigurationEditorInternal({ company }: CompanyConfigurationEdi
104
90
  return (
105
91
  <Dialog open={open} onOpenChange={setOpen}>
106
92
  <DialogTrigger>
107
- <Button size="sm" variant={`ghost`} className="cursor-pointer">
93
+ <Button render={<div />} nativeButton={false} size="sm" variant={`ghost`} className="cursor-pointer">
108
94
  <Settings2Icon className="h-3.5 w-3.5" />
109
95
  </Button>
110
96
  </DialogTrigger>
@@ -117,25 +103,7 @@ function CompanyConfigurationEditorInternal({ company }: CompanyConfigurationEdi
117
103
  </DialogHeader>
118
104
  <Form {...form}>
119
105
  <form onSubmit={form.handleSubmit(onSubmit)} className={`flex w-full flex-col gap-y-4`}>
120
- <div className={`flex flex-row gap-x-4`}>
121
- <div className={`flex w-full flex-col justify-start gap-y-4`}>
122
- <Tabs defaultValue={process.env.NEXT_PUBLIC_PRIVATE_INSTALLATION ? "security" : "ai"}>
123
- <TabsList>
124
- <TabsTrigger value="security">Privacy & Security</TabsTrigger>
125
- </TabsList>
126
- <TabsContent value="features">
127
- <div className="space-y-4">
128
- <p className="text-muted-foreground text-sm">
129
- Feature configuration will be implemented in future updates.
130
- </p>
131
- </div>
132
- </TabsContent>
133
- <TabsContent value="security">
134
- <CompanyConfigurationSecurityForm form={form} />
135
- </TabsContent>
136
- </Tabs>
137
- </div>
138
- </div>
106
+ {children(form)}
139
107
  <CommonEditorButtons form={form} setOpen={setOpen} isEdit={true} />
140
108
  </form>
141
109
  </Form>
@@ -1,4 +1,3 @@
1
1
  export * from "./CompanyConfigurationEditor";
2
- export * from "./CompanyConfigurationSecurityForm";
3
2
  export * from "./CompanyDeleter";
4
3
  export * from "./CompanyEditor";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { useTranslations } from "next-intl";
4
- import { createContext, ReactNode, useContext, useState } from "react";
4
+ import { Fragment, createContext, ReactNode, useContext, useState } from "react";
5
5
  import { SharedProvider } from "../../../contexts";
6
6
  import { JsonApiHydratedDataInterface, Modules, rehydrate } from "../../../core";
7
7
  import { usePageUrlGenerator } from "../../../hooks";
@@ -23,6 +23,7 @@ const CompanyContext = createContext<CompanyContextType | undefined>(undefined);
23
23
  type CompanyProviderProps = {
24
24
  children: ReactNode;
25
25
  dehydratedCompany?: JsonApiHydratedDataInterface;
26
+ configurationEditorSlot?: ReactNode;
26
27
  };
27
28
 
28
29
  const defaultContextValue: CompanyContextType = {
@@ -30,7 +31,7 @@ const defaultContextValue: CompanyContextType = {
30
31
  setCompany: () => {},
31
32
  };
32
33
 
33
- export const CompanyProvider = ({ children, dehydratedCompany }: CompanyProviderProps) => {
34
+ export const CompanyProvider = ({ children, dehydratedCompany, configurationEditorSlot }: CompanyProviderProps) => {
34
35
  const generateUrl = usePageUrlGenerator();
35
36
  const t = useTranslations();
36
37
  const { hasPermissionToModule, hasRole } = useCurrentUserContext<UserInterface>();
@@ -71,7 +72,8 @@ export const CompanyProvider = ({ children, dehydratedCompany }: CompanyProvider
71
72
  hasRole(getRoleId().Administrator) ||
72
73
  hasPermissionToModule({ module: Modules.Company, action: Action.Update })
73
74
  ) {
74
- // if (company) functions.push(<CompanyConfigurationEditor key="companyConfigurationEditor" company={company} />);
75
+ if (company && configurationEditorSlot)
76
+ functions.push(<Fragment key="configurationEditorSlot">{configurationEditorSlot}</Fragment>);
75
77
  functions.push(<CompanyEditor key="companyEditor" company={company} propagateChanges={setCompany} />);
76
78
  }
77
79
 
@@ -1,6 +1,7 @@
1
- import { User } from "./data/user";
1
+ import { UsersIcon } from "lucide-react";
2
2
  import { createJsonApiInclusion } from "../../core";
3
3
  import { ModuleFactory } from "../../permissions";
4
+ import { User } from "./data/user";
4
5
 
5
6
  export const UserModule = (factory: ModuleFactory) =>
6
7
  factory({
@@ -8,6 +9,7 @@ export const UserModule = (factory: ModuleFactory) =>
8
9
  name: "users",
9
10
  model: User,
10
11
  moduleId: "04cfc677-0fd2-4f5e-adf4-2483a00c0277",
12
+ icon: UsersIcon,
11
13
  inclusions: {
12
14
  lists: {
13
15
  fields: [