@vitnode/core 1.2.0-canary.22 → 1.2.0-canary.23
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.
- package/dist/src/app_admin/core/users/page.js +1 -1
- package/dist/src/components/form/auto-form.js +1 -1
- package/dist/src/components/form/fields/combobox-async.d.ts +21 -0
- package/dist/src/components/form/fields/combobox-async.d.ts.map +1 -0
- package/dist/src/components/form/fields/combobox-async.js +115 -0
- package/dist/src/components/form/fields/combobox.d.ts +2 -1
- package/dist/src/components/form/fields/combobox.d.ts.map +1 -1
- package/dist/src/components/form/fields/combobox.js +4 -5
- package/dist/src/components/table/content.js +1 -1
- package/dist/src/components/table/pagination.js +3 -3
- package/dist/src/components/ui/alert-dialog.js +2 -2
- package/dist/src/components/ui/dialog.d.ts.map +1 -1
- package/dist/src/components/ui/dialog.js +1 -1
- package/dist/src/lib/fetcher/core.d.ts +15 -0
- package/dist/src/lib/fetcher/core.d.ts.map +1 -0
- package/dist/src/lib/fetcher/core.js +39 -0
- package/dist/src/lib/fetcher/helpers-server.d.ts +3 -0
- package/dist/src/lib/fetcher/helpers-server.d.ts.map +1 -0
- package/dist/src/lib/fetcher/helpers-server.js +18 -0
- package/dist/src/lib/fetcher/helpers.d.ts +0 -1
- package/dist/src/lib/fetcher/helpers.d.ts.map +1 -1
- package/dist/src/lib/fetcher/helpers.js +0 -17
- package/dist/src/lib/fetcher-client.d.ts +8 -0
- package/dist/src/lib/fetcher-client.d.ts.map +1 -0
- package/dist/src/lib/fetcher-client.js +11 -0
- package/dist/src/lib/fetcher.d.ts +2 -1
- package/dist/src/lib/fetcher.d.ts.map +1 -1
- package/dist/src/lib/fetcher.js +14 -33
- package/dist/src/lib/helpers/auto-form.d.ts.map +1 -1
- package/dist/src/lib/helpers/auto-form.js +28 -16
- package/dist/src/lib/helpers/auto-form.test.js +49 -0
- package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/item.js +24 -3
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +1 -1
- package/dist/src/views/admin/views/core/test.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/test.js +108 -103
- package/dist/src/views/layouts/theme/header/header.d.ts.map +1 -1
- package/dist/src/views/layouts/theme/header/header.js +24 -21
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/app_admin/core/users/page.tsx +1 -1
- package/src/locales/en.json +2 -0
|
@@ -16,7 +16,7 @@ export default async function Page(props) {
|
|
|
16
16
|
getTranslations('admin.global.nav.users')
|
|
17
17
|
]);
|
|
18
18
|
return /*#__PURE__*/ _jsxs("div", {
|
|
19
|
-
className: "
|
|
19
|
+
className: "p-4",
|
|
20
20
|
children: [
|
|
21
21
|
/*#__PURE__*/ _jsx(HeaderContent, {
|
|
22
22
|
desc: t('desc'),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Button } from '../../../components/ui/button';
|
|
4
|
+
import type { ItemAutoFormComponentProps } from './item';
|
|
5
|
+
export declare function AutoFormComboboxAsync<T extends z.ZodTypeAny>({ label, field, description, shape: _s, placeholder, className, id, searchPlaceholder, fetchData, ...props }: ItemAutoFormComponentProps<T> & Omit<React.ComponentProps<typeof Button>, 'role' | 'variant'> & {
|
|
6
|
+
description?: React.ReactNode;
|
|
7
|
+
fetchData: (params: {
|
|
8
|
+
search: string;
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}[]> | {
|
|
13
|
+
label: string;
|
|
14
|
+
value: string;
|
|
15
|
+
}[];
|
|
16
|
+
id: string;
|
|
17
|
+
label?: React.ReactNode;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
searchPlaceholder?: string;
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=combobox-async.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-async.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/fields/combobox-async.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAK7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAiBhD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,QAAQ,CAAC;AAMzD,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,EAC5D,KAAK,EACL,KAAK,EACL,WAAW,EAEX,KAAK,EAAE,EAAE,EACT,WAAW,EACX,SAAS,EACT,EAAE,EACF,iBAAiB,EACjB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAC9B,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG;IAC9D,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,SAAS,EAAE,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAClC,OAAO,CACL;QACE,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CACJ,GACD;QACE,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACR,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,2CA+FF"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { Check, ChevronsUpDown } from "lucide-react";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { useDebouncedCallback } from "use-debounce";
|
|
7
|
+
import { Button } from "../../ui/button.js";
|
|
8
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "../../ui/command.js";
|
|
9
|
+
import { FormControl, FormItem, FormMessage } from "../../ui/form.js";
|
|
10
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
|
|
11
|
+
import { cn } from "../../../lib/utils.js";
|
|
12
|
+
import { Skeleton } from "../../ui/skeleton.js";
|
|
13
|
+
import { AutoFormDesc } from "../common/desc.js";
|
|
14
|
+
import { AutoFormLabel } from "../common/label.js";
|
|
15
|
+
export function AutoFormComboboxAsync({ label, field, description, // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
+
shape: _s, placeholder, className, id, searchPlaceholder, fetchData, ...props }) {
|
|
17
|
+
const t = useTranslations('core.global');
|
|
18
|
+
const [search, setSearch] = React.useState('');
|
|
19
|
+
const { data, isLoading } = useQuery({
|
|
20
|
+
queryKey: [
|
|
21
|
+
id,
|
|
22
|
+
{
|
|
23
|
+
search
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
queryFn: async ()=>{
|
|
27
|
+
return await fetchData({
|
|
28
|
+
search
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const handleChangeSearch = useDebouncedCallback((value)=>{
|
|
33
|
+
setSearch(value);
|
|
34
|
+
}, 500);
|
|
35
|
+
return /*#__PURE__*/ _jsxs(FormItem, {
|
|
36
|
+
className: "flex flex-col",
|
|
37
|
+
children: [
|
|
38
|
+
label && /*#__PURE__*/ _jsx(AutoFormLabel, {
|
|
39
|
+
children: label
|
|
40
|
+
}),
|
|
41
|
+
/*#__PURE__*/ _jsxs(Popover, {
|
|
42
|
+
children: [
|
|
43
|
+
/*#__PURE__*/ _jsx(PopoverTrigger, {
|
|
44
|
+
asChild: true,
|
|
45
|
+
children: /*#__PURE__*/ _jsx(FormControl, {
|
|
46
|
+
children: /*#__PURE__*/ _jsxs(Button, {
|
|
47
|
+
className: cn('w-[200px] justify-between bg-transparent', !field.value && 'text-muted-foreground', className),
|
|
48
|
+
role: "combobox",
|
|
49
|
+
variant: "outline",
|
|
50
|
+
...props,
|
|
51
|
+
children: [
|
|
52
|
+
field.value && field.value.label ? field.value.label : placeholder ?? t('select_option'),
|
|
53
|
+
/*#__PURE__*/ _jsx(ChevronsUpDown, {
|
|
54
|
+
className: "ml-2 h-4 w-4 shrink-0 opacity-50"
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ _jsx(PopoverContent, {
|
|
61
|
+
className: "w-[200px] p-0",
|
|
62
|
+
children: /*#__PURE__*/ _jsxs(Command, {
|
|
63
|
+
shouldFilter: false,
|
|
64
|
+
children: [
|
|
65
|
+
/*#__PURE__*/ _jsx(CommandInput, {
|
|
66
|
+
onChangeCapture: (e)=>{
|
|
67
|
+
handleChangeSearch(e.currentTarget.value);
|
|
68
|
+
},
|
|
69
|
+
placeholder: searchPlaceholder ?? t('search_placeholder')
|
|
70
|
+
}),
|
|
71
|
+
/*#__PURE__*/ _jsx(CommandList, {
|
|
72
|
+
children: isLoading ? /*#__PURE__*/ _jsxs("div", {
|
|
73
|
+
className: "space-y-2 p-2",
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ _jsx(Skeleton, {
|
|
76
|
+
className: "h-6 rounded-sm"
|
|
77
|
+
}),
|
|
78
|
+
/*#__PURE__*/ _jsx(Skeleton, {
|
|
79
|
+
className: "h-6 rounded-sm"
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
}) : /*#__PURE__*/ _jsx(_Fragment, {
|
|
83
|
+
children: data?.length === 0 ? /*#__PURE__*/ _jsx(CommandEmpty, {
|
|
84
|
+
children: t('results_not_found')
|
|
85
|
+
}) : /*#__PURE__*/ _jsx(CommandGroup, {
|
|
86
|
+
children: (data ?? []).map(({ label, value })=>/*#__PURE__*/ _jsxs(CommandItem, {
|
|
87
|
+
onSelect: ()=>{
|
|
88
|
+
field.onChange({
|
|
89
|
+
label,
|
|
90
|
+
value
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
value: label,
|
|
94
|
+
children: [
|
|
95
|
+
label,
|
|
96
|
+
/*#__PURE__*/ _jsx(Check, {
|
|
97
|
+
className: cn('ml-auto', value === field.value?.value ? 'opacity-100' : 'opacity-0')
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
}, value))
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
}),
|
|
109
|
+
description && /*#__PURE__*/ _jsx(AutoFormDesc, {
|
|
110
|
+
children: description
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ _jsx(FormMessage, {})
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { z } from 'zod';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Button } from '../../../components/ui/button';
|
|
4
4
|
import type { ItemAutoFormComponentProps } from './item';
|
|
5
|
-
export declare function AutoFormCombobox<T extends z.ZodTypeAny>({ label, field, description, shape, placeholder
|
|
5
|
+
export declare function AutoFormCombobox<T extends z.ZodTypeAny>({ label, field, description, shape, placeholder, className, labels, searchPlaceholder, ...props }: ItemAutoFormComponentProps<T> & Omit<React.ComponentProps<typeof Button>, 'role' | 'variant'> & {
|
|
6
6
|
description?: React.ReactNode;
|
|
7
7
|
label?: React.ReactNode;
|
|
8
8
|
labels?: {
|
|
@@ -10,5 +10,6 @@ export declare function AutoFormCombobox<T extends z.ZodTypeAny>({ label, field,
|
|
|
10
10
|
value: string;
|
|
11
11
|
}[];
|
|
12
12
|
placeholder?: string;
|
|
13
|
+
searchPlaceholder?: string;
|
|
13
14
|
}): import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
//# sourceMappingURL=combobox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/fields/combobox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAI7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAkBhD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,QAAQ,CAAC;AAKzD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,EACvD,KAAK,EACL,KAAK,EACL,WAAW,EACX,KAAK,
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/fields/combobox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAI7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAkBhD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,QAAQ,CAAC;AAKzD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,EACvD,KAAK,EACL,KAAK,EACL,WAAW,EACX,KAAK,EACL,WAAW,EACX,SAAS,EACT,MAAW,EACX,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAC9B,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG;IAC9D,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,2CA0EF"}
|
|
@@ -10,8 +10,7 @@ import { getBaseSchema } from "../../../lib/helpers/auto-form.js";
|
|
|
10
10
|
import { cn } from "../../../lib/utils.js";
|
|
11
11
|
import { AutoFormDesc } from "../common/desc.js";
|
|
12
12
|
import { AutoFormLabel } from "../common/label.js";
|
|
13
|
-
export function AutoFormCombobox({ label, field, description, shape,
|
|
14
|
-
placeholder: _, className, labels = [], ...props }) {
|
|
13
|
+
export function AutoFormCombobox({ label, field, description, shape, placeholder, className, labels = [], searchPlaceholder, ...props }) {
|
|
15
14
|
const t = useTranslations('core.global');
|
|
16
15
|
const baseValues = getBaseSchema(shape, true)._def.values;
|
|
17
16
|
const values = baseValues.map((value)=>{
|
|
@@ -38,7 +37,7 @@ placeholder: _, className, labels = [], ...props }) {
|
|
|
38
37
|
variant: "outline",
|
|
39
38
|
...props,
|
|
40
39
|
children: [
|
|
41
|
-
field.value ? values.find(({ value })=>value === field.value)?.label : t('select_option'),
|
|
40
|
+
field.value ? values.find(({ value })=>value === field.value)?.label : placeholder ?? t('select_option'),
|
|
42
41
|
/*#__PURE__*/ _jsx(ChevronsUpDown, {
|
|
43
42
|
className: "ml-2 h-4 w-4 shrink-0 opacity-50"
|
|
44
43
|
})
|
|
@@ -51,12 +50,12 @@ placeholder: _, className, labels = [], ...props }) {
|
|
|
51
50
|
children: /*#__PURE__*/ _jsxs(Command, {
|
|
52
51
|
children: [
|
|
53
52
|
/*#__PURE__*/ _jsx(CommandInput, {
|
|
54
|
-
placeholder:
|
|
53
|
+
placeholder: searchPlaceholder ?? t('search_placeholder')
|
|
55
54
|
}),
|
|
56
55
|
/*#__PURE__*/ _jsxs(CommandList, {
|
|
57
56
|
children: [
|
|
58
57
|
/*#__PURE__*/ _jsx(CommandEmpty, {
|
|
59
|
-
children:
|
|
58
|
+
children: t('results_not_found')
|
|
60
59
|
}),
|
|
61
60
|
/*#__PURE__*/ _jsx(CommandGroup, {
|
|
62
61
|
children: values.map(({ label, value })=>/*#__PURE__*/ _jsxs(CommandItem, {
|
|
@@ -18,7 +18,7 @@ export function ContentDataTable({ columns, edges, pageInfo, order, customNotFou
|
|
|
18
18
|
...props,
|
|
19
19
|
children: [
|
|
20
20
|
/*#__PURE__*/ _jsx(TableHeader, {
|
|
21
|
-
className: "bg-
|
|
21
|
+
className: "bg-card",
|
|
22
22
|
children: /*#__PURE__*/ _jsx(TableRow, {
|
|
23
23
|
children: columns.map((column)=>/*#__PURE__*/ _jsx(TableHead, {
|
|
24
24
|
className: cn(column.className),
|
|
@@ -49,7 +49,7 @@ export const PaginationDataTable = ({ pageInfo: { hasNextPage, hasPreviousPage,
|
|
|
49
49
|
isPending ? /*#__PURE__*/ _jsx(Skeleton, {
|
|
50
50
|
className: "h-9 w-[4.5rem]"
|
|
51
51
|
}) : /*#__PURE__*/ _jsx(SelectTrigger, {
|
|
52
|
-
className: "h-8 w-[4.5rem]",
|
|
52
|
+
className: "bg-card h-8 w-[4.5rem]",
|
|
53
53
|
children: /*#__PURE__*/ _jsx(SelectValue, {})
|
|
54
54
|
}),
|
|
55
55
|
/*#__PURE__*/ _jsx(SelectContent, {
|
|
@@ -68,7 +68,7 @@ export const PaginationDataTable = ({ pageInfo: { hasNextPage, hasPreviousPage,
|
|
|
68
68
|
className: "size-8"
|
|
69
69
|
}) : /*#__PURE__*/ _jsx(Button, {
|
|
70
70
|
"aria-label": t('go_to_prev_page'),
|
|
71
|
-
className: "size-8",
|
|
71
|
+
className: "bg-card size-8",
|
|
72
72
|
disabled: !hasPreviousPage,
|
|
73
73
|
onClick: ()=>{
|
|
74
74
|
startTransition(()=>{
|
|
@@ -93,7 +93,7 @@ export const PaginationDataTable = ({ pageInfo: { hasNextPage, hasPreviousPage,
|
|
|
93
93
|
className: "size-8"
|
|
94
94
|
}) : /*#__PURE__*/ _jsx(Button, {
|
|
95
95
|
"aria-label": t('go_to_next_page'),
|
|
96
|
-
className: "size-8",
|
|
96
|
+
className: "bg-card size-8",
|
|
97
97
|
disabled: !hasNextPage || isPending,
|
|
98
98
|
onClick: ()=>{
|
|
99
99
|
startTransition(()=>{
|
|
@@ -34,7 +34,7 @@ function AlertDialogContent({ className, ...props }) {
|
|
|
34
34
|
children: [
|
|
35
35
|
/*#__PURE__*/ _jsx(AlertDialogOverlay, {}),
|
|
36
36
|
/*#__PURE__*/ _jsx(AlertDialogPrimitive.Content, {
|
|
37
|
-
className: cn('bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg', className),
|
|
37
|
+
className: cn('dark:bg-background bg-card data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg', className),
|
|
38
38
|
"data-slot": "alert-dialog-content",
|
|
39
39
|
...props
|
|
40
40
|
})
|
|
@@ -78,7 +78,7 @@ function AlertDialogAction({ className, ...props }) {
|
|
|
78
78
|
function AlertDialogCancel({ className, ...props }) {
|
|
79
79
|
return /*#__PURE__*/ _jsx(AlertDialogPrimitive.Cancel, {
|
|
80
80
|
className: cn(buttonVariants({
|
|
81
|
-
variant: '
|
|
81
|
+
variant: 'ghost'
|
|
82
82
|
}), className),
|
|
83
83
|
...props
|
|
84
84
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/dialog.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA4B/B,eAAO,MAAM,SAAS;cAZV,OAAO;UACX,OAAO;iBACA,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;cAC3B,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;oCACF,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;CAQI,CAAC;AAE/D,iBAAS,MAAM,CAAC,EACd,YAAY,EACZ,IAAI,EAAE,QAAQ,EACd,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,2CA2DnD;AAED,iBAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,2CAEtD;AAED,iBAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,MAAM,CAAC,2CAErD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAmBpD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,2CAWtD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,QAAQ,EACR,eAAsB,EACtB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,GAAG;IACxD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/dialog.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA4B/B,eAAO,MAAM,SAAS;cAZV,OAAO;UACX,OAAO;iBACA,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;cAC3B,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;oCACF,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;CAQI,CAAC;AAE/D,iBAAS,MAAM,CAAC,EACd,YAAY,EACZ,IAAI,EAAE,QAAQ,EACd,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,2CA2DnD;AAED,iBAAS,aAAa,CAAC,EACrB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,2CAEtD;AAED,iBAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,MAAM,CAAC,2CAErD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAmBpD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,2CAWtD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,QAAQ,EACR,eAAsB,EACtB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,GAAG;IACxD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,2CA+CA;AAED,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,2CAQzE;AAED,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,2CAWzE;AAED,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAQpD;AAED,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,WAAW,CAAC,2CAQ1D;AAED,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,GACd,CAAC"}
|
|
@@ -114,7 +114,7 @@ function DialogContent({ className, children, showCloseButton = true, ...props }
|
|
|
114
114
|
children: [
|
|
115
115
|
/*#__PURE__*/ _jsx(DialogOverlay, {}),
|
|
116
116
|
/*#__PURE__*/ _jsxs(DialogPrimitive.Content, {
|
|
117
|
-
className: cn('bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg', className),
|
|
117
|
+
className: cn('dark:bg-background bg-card data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg', 'max-h-screen overflow-y-scroll', className),
|
|
118
118
|
"data-slot": "dialog-content",
|
|
119
119
|
onInteractOutside: (e)=>{
|
|
120
120
|
// Prevent dismissing the dialog when clicking on a toast
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BaseBuildModuleReturn, BuildModuleReturn } from '../../api/lib/module';
|
|
2
|
+
import type { Route } from '../../api/lib/route';
|
|
3
|
+
import type { FetcherParams, GetModulePaths, GetValidMethodForPath, GetValidPathsForModule, InferResponseType } from './types';
|
|
4
|
+
interface CoreFetcherOptions<M extends string, Routes extends Route[], Modules extends BaseBuildModuleReturn[], ModuleName extends GetModulePaths<M, Modules>, SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>, Method extends GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules> = GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules>> {
|
|
5
|
+
additionalHeaders?: HeadersInit;
|
|
6
|
+
args?: FetcherParams<M, Routes, Modules, ModuleName, SelectedPath, Method>['args'];
|
|
7
|
+
method: Method;
|
|
8
|
+
module: ModuleName;
|
|
9
|
+
options?: Omit<RequestInit, 'body' | 'headers'>;
|
|
10
|
+
path: SelectedPath;
|
|
11
|
+
withPagination?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function coreFetcher<M extends string, Routes extends Route[], Modules extends BaseBuildModuleReturn[], ModuleName extends GetModulePaths<M, Modules>, SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>, Method extends GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules> = GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules>>({ pluginId }: BuildModuleReturn<string, M, Routes, Modules>, { path, method, module, args, options, additionalHeaders, withPagination, }: CoreFetcherOptions<M, Routes, Modules, ModuleName, SelectedPath, Method>): Promise<InferResponseType<M, Routes, Modules, ModuleName, SelectedPath, Method>>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/lib/fetcher/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAKjB,UAAU,kBAAkB,CAC1B,CAAC,SAAS,MAAM,EAChB,MAAM,SAAS,KAAK,EAAE,EACtB,OAAO,SAAS,qBAAqB,EAAE,EACvC,UAAU,SAAS,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7C,YAAY,SAAS,sBAAsB,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3E,MAAM,SAAS,qBAAqB,CAClC,UAAU,EACV,YAAY,EACZ,CAAC,EACD,MAAM,EACN,OAAO,CACR,GAAG,qBAAqB,CAAC,UAAU,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC;IAEvE,iBAAiB,CAAC,EAAE,WAAW,CAAC;IAChC,IAAI,CAAC,EAAE,aAAa,CAClB,CAAC,EACD,MAAM,EACN,OAAO,EACP,UAAU,EACV,YAAY,EACZ,MAAM,CACP,CAAC,MAAM,CAAC,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAChD,IAAI,EAAE,YAAY,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAsB,WAAW,CAC/B,CAAC,SAAS,MAAM,EAChB,MAAM,SAAS,KAAK,EAAE,EACtB,OAAO,SAAS,qBAAqB,EAAE,EACvC,UAAU,SAAS,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7C,YAAY,SAAS,sBAAsB,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3E,MAAM,SAAS,qBAAqB,CAClC,UAAU,EACV,YAAY,EACZ,CAAC,EACD,MAAM,EACN,OAAO,CACR,GAAG,qBAAqB,CAAC,UAAU,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAEvE,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3D,EACE,IAAI,EACJ,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,iBAAsB,EACtB,cAAsB,GACvB,EAAE,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,GAC1E,OAAO,CACR,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,CACxE,CAwDA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CONFIG } from "../config.js";
|
|
2
|
+
import { buildSearchParams } from "./helpers.js";
|
|
3
|
+
export async function coreFetcher({ pluginId }, { path, method, module, args, options, additionalHeaders = {}, withPagination = false }) {
|
|
4
|
+
let currentPath = path;
|
|
5
|
+
// Replace path parameters
|
|
6
|
+
if (args && 'params' in args && args.params) {
|
|
7
|
+
for (const [key, value] of Object.entries(args.params)){
|
|
8
|
+
currentPath = currentPath.replaceAll(`{${key}}`, String(value));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
// Ensure path starts with a slash
|
|
12
|
+
const formattedPath = currentPath.startsWith('/') ? currentPath : `/${currentPath}`;
|
|
13
|
+
// Construct the base URL
|
|
14
|
+
const url = new URL(`/api/${pluginId}/${module}${formattedPath}`, CONFIG.backend.origin);
|
|
15
|
+
// Add query parameters if they exist
|
|
16
|
+
if (args && 'query' in args && args.query) {
|
|
17
|
+
const queryParams = args.query;
|
|
18
|
+
const searchParams = buildSearchParams({
|
|
19
|
+
...args.query,
|
|
20
|
+
...withPagination && {
|
|
21
|
+
first: !queryParams.last ? queryParams.first ?? '10' : undefined,
|
|
22
|
+
search: queryParams.search ?? ''
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
url.search = searchParams.toString();
|
|
26
|
+
}
|
|
27
|
+
// Build headers
|
|
28
|
+
const headers = new Headers({
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
...additionalHeaders
|
|
31
|
+
});
|
|
32
|
+
const response = await fetch(url, {
|
|
33
|
+
method: method.toUpperCase(),
|
|
34
|
+
headers,
|
|
35
|
+
body: args && 'body' in args ? JSON.stringify(args.body) : undefined,
|
|
36
|
+
...options
|
|
37
|
+
});
|
|
38
|
+
return response;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-server.d.ts","sourceRoot":"","sources":["../../../../src/lib/fetcher/helpers-server.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAKrB,eAAO,MAAM,uBAAuB,GAAU,KAAK,QAAQ,kBAkB1D,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { cookies } from "next/headers";
|
|
3
|
+
import { cookieFromStringToObject } from "./cookie-from-string-to-object.js";
|
|
4
|
+
export const handleSetCookiesFetcher = async (res)=>{
|
|
5
|
+
await Promise.all(cookieFromStringToObject(res.headers.getSetCookie()).map(async (cookie)=>{
|
|
6
|
+
const key = Object.keys(cookie)[0];
|
|
7
|
+
const value = Object.values(cookie)[0];
|
|
8
|
+
if (typeof value !== 'string' || typeof key !== 'string') return;
|
|
9
|
+
(await cookies()).set(key, value, {
|
|
10
|
+
domain: cookie.Domain,
|
|
11
|
+
path: cookie.Path,
|
|
12
|
+
expires: new Date(cookie.Expires),
|
|
13
|
+
secure: cookie.Secure,
|
|
14
|
+
httpOnly: cookie.HttpOnly,
|
|
15
|
+
sameSite: cookie.SameSite
|
|
16
|
+
});
|
|
17
|
+
}));
|
|
18
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/lib/fetcher/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/lib/fetcher/helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,oBAkBzE,CAAC"}
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import { cookies } from "next/headers";
|
|
2
|
-
import { cookieFromStringToObject } from "./cookie-from-string-to-object.js";
|
|
3
|
-
export const handleSetCookiesFetcher = async (res)=>{
|
|
4
|
-
await Promise.all(cookieFromStringToObject(res.headers.getSetCookie()).map(async (cookie)=>{
|
|
5
|
-
const key = Object.keys(cookie)[0];
|
|
6
|
-
const value = Object.values(cookie)[0];
|
|
7
|
-
if (typeof value !== 'string' || typeof key !== 'string') return;
|
|
8
|
-
(await cookies()).set(key, value, {
|
|
9
|
-
domain: cookie.Domain,
|
|
10
|
-
path: cookie.Path,
|
|
11
|
-
expires: new Date(cookie.Expires),
|
|
12
|
-
secure: cookie.Secure,
|
|
13
|
-
httpOnly: cookie.HttpOnly,
|
|
14
|
-
sameSite: cookie.SameSite
|
|
15
|
-
});
|
|
16
|
-
}));
|
|
17
|
-
};
|
|
18
1
|
export const buildSearchParams = (query)=>{
|
|
19
2
|
const searchParams = new URLSearchParams();
|
|
20
3
|
for (const [k, v] of Object.entries(query)){
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BaseBuildModuleReturn, BuildModuleReturn } from '../api/lib/module';
|
|
2
|
+
import type { Route } from '../api/lib/route';
|
|
3
|
+
import type { FetcherParams, GetModulePaths, GetValidMethodForPath, GetValidPathsForModule, InferResponseType } from './fetcher/types';
|
|
4
|
+
export declare function fetcherClient<M extends string, Routes extends Route[], Modules extends BaseBuildModuleReturn[], ModuleName extends GetModulePaths<M, Modules>, SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>, Method extends GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules> = GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules>>(moduleReturn: BuildModuleReturn<string, M, Routes, Modules>, { path, method, module, args, options, withPagination, }: FetcherParams<M, Routes, Modules, ModuleName, SelectedPath, Method> & {
|
|
5
|
+
options?: Omit<RequestInit, 'body'>;
|
|
6
|
+
withPagination?: boolean;
|
|
7
|
+
}): Promise<InferResponseType<M, Routes, Modules, ModuleName, SelectedPath, Method>>;
|
|
8
|
+
//# sourceMappingURL=fetcher-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetcher-client.d.ts","sourceRoot":"","sources":["../../../src/lib/fetcher-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAIzB,wBAAsB,aAAa,CACjC,CAAC,SAAS,MAAM,EAChB,MAAM,SAAS,KAAK,EAAE,EACtB,OAAO,SAAS,qBAAqB,EAAE,EACvC,UAAU,SAAS,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7C,YAAY,SAAS,sBAAsB,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3E,MAAM,SAAS,qBAAqB,CAClC,UAAU,EACV,YAAY,EACZ,CAAC,EACD,MAAM,EACN,OAAO,CACR,GAAG,qBAAqB,CAAC,UAAU,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAEvE,YAAY,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3D,EACE,IAAI,EACJ,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,cAAsB,GACvB,EAAE,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,GAAG;IACvE,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GACA,OAAO,CACR,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,CACxE,CASA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { coreFetcher } from "./fetcher/core.js";
|
|
2
|
+
export async function fetcherClient(moduleReturn, { path, method, module, args, options, withPagination = false }) {
|
|
3
|
+
return coreFetcher(moduleReturn, {
|
|
4
|
+
path,
|
|
5
|
+
method,
|
|
6
|
+
module,
|
|
7
|
+
args,
|
|
8
|
+
options,
|
|
9
|
+
withPagination
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import 'server-only';
|
|
1
2
|
import type { BaseBuildModuleReturn, BuildModuleReturn } from '../api/lib/module';
|
|
2
3
|
import type { Route } from '../api/lib/route';
|
|
3
4
|
import type { FetcherParams, GetModulePaths, GetValidMethodForPath, GetValidPathsForModule, InferResponseType } from './fetcher/types';
|
|
4
|
-
export declare function fetcher<M extends string, Routes extends Route[], Modules extends BaseBuildModuleReturn[], ModuleName extends GetModulePaths<M, Modules>, SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>, Method extends GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules> = GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules>>(
|
|
5
|
+
export declare function fetcher<M extends string, Routes extends Route[], Modules extends BaseBuildModuleReturn[], ModuleName extends GetModulePaths<M, Modules>, SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>, Method extends GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules> = GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules>>(moduleReturn: BuildModuleReturn<string, M, Routes, Modules>, { path, method, module, args, options, allowSaveCookies, withPagination, }: FetcherParams<M, Routes, Modules, ModuleName, SelectedPath, Method> & {
|
|
5
6
|
allowSaveCookies?: boolean;
|
|
6
7
|
options?: Omit<RequestInit, 'body'>;
|
|
7
8
|
withPagination?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../src/lib/fetcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../src/lib/fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAKzB,wBAAsB,OAAO,CAC3B,CAAC,SAAS,MAAM,EAChB,MAAM,SAAS,KAAK,EAAE,EACtB,OAAO,SAAS,qBAAqB,EAAE,EACvC,UAAU,SAAS,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7C,YAAY,SAAS,sBAAsB,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3E,MAAM,SAAS,qBAAqB,CAClC,UAAU,EACV,YAAY,EACZ,CAAC,EACD,MAAM,EACN,OAAO,CACR,GAAG,qBAAqB,CAAC,UAAU,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAEvE,YAAY,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3D,EACE,IAAI,EACJ,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,gBAAwB,EACxB,cAAsB,GACvB,EAAE,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,GAAG;IACvE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GACA,OAAO,CACR,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,CACxE,CA+BA"}
|
package/dist/src/lib/fetcher.js
CHANGED
|
@@ -1,45 +1,26 @@
|
|
|
1
|
+
import "server-only";
|
|
1
2
|
import { cookies, headers } from "next/headers";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export async function fetcher(
|
|
5
|
-
let currentPath = path;
|
|
6
|
-
// Replace path parameters
|
|
7
|
-
if (args && 'params' in args && args.params) {
|
|
8
|
-
for (const [key, value] of Object.entries(args.params)){
|
|
9
|
-
currentPath = currentPath.replaceAll(`{${key}}`, String(value));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
// Ensure path starts with a slash
|
|
13
|
-
const formattedPath = currentPath.startsWith('/') ? currentPath : `/${currentPath}`;
|
|
14
|
-
// Construct the base URL
|
|
15
|
-
const url = new URL(`/api/${pluginId}/${module}${formattedPath}`, CONFIG.backend.origin);
|
|
16
|
-
// Add query parameters if they exist
|
|
17
|
-
if (args && 'query' in args && args.query) {
|
|
18
|
-
const queryParams = args.query;
|
|
19
|
-
const searchParams = buildSearchParams({
|
|
20
|
-
...args.query,
|
|
21
|
-
...withPagination && {
|
|
22
|
-
first: !queryParams.last ? queryParams.first ?? '10' : undefined,
|
|
23
|
-
search: queryParams.search ?? ''
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
url.search = searchParams.toString();
|
|
27
|
-
}
|
|
3
|
+
import { coreFetcher } from "./fetcher/core.js";
|
|
4
|
+
import { handleSetCookiesFetcher } from "./fetcher/helpers-server.js";
|
|
5
|
+
export async function fetcher(moduleReturn, { path, method, module, args, options, allowSaveCookies = false, withPagination = false }) {
|
|
28
6
|
const [nextInternalHeaders, cookie] = await Promise.all([
|
|
29
7
|
headers(),
|
|
30
8
|
cookies()
|
|
31
9
|
]);
|
|
32
|
-
const response = await
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
10
|
+
const response = await coreFetcher(moduleReturn, {
|
|
11
|
+
path,
|
|
12
|
+
method,
|
|
13
|
+
module,
|
|
14
|
+
args,
|
|
15
|
+
options,
|
|
16
|
+
withPagination,
|
|
17
|
+
additionalHeaders: {
|
|
36
18
|
Cookie: cookie.toString(),
|
|
37
19
|
['user-agent']: nextInternalHeaders.get('user-agent') ?? 'node',
|
|
38
20
|
['x-forwarded-for']: nextInternalHeaders.get('x-forwarded-for') ?? '0.0.0.0'
|
|
39
|
-
}
|
|
40
|
-
body: args && 'body' in args ? JSON.stringify(args.body) : undefined,
|
|
41
|
-
...options
|
|
21
|
+
}
|
|
42
22
|
});
|
|
23
|
+
// Handle cookies on server-side for successful responses
|
|
43
24
|
if (response.status >= 200 && response.status < 300 && allowSaveCookies) {
|
|
44
25
|
await handleSetCookiesFetcher(response);
|
|
45
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-form.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/auto-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAC7E,IAAI,MAAM,KACT,IAAI,GAAG,CAAC,CAAC,MAMX,CAAC;AAGF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEpD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,kBAAkB,GAEzB,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAUvB;AAMD,wBAAgB,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAClD,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE,OAAO,GAChB,IAAI,GAAG,CAAC,CAYV;AAMD,eAAO,MAAM,WAAW,GAAI,QAAQ,CAAC,CAAC,UAAU,KAAG,MAIlD,CAAC;AAKF,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"auto-form.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/auto-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAC7E,IAAI,MAAM,KACT,IAAI,GAAG,CAAC,CAAC,MAMX,CAAC;AAGF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEpD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,kBAAkB,GAEzB,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAUvB;AAMD,wBAAgB,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAClD,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE,OAAO,GAChB,IAAI,GAAG,CAAC,CAYV;AAMD,eAAO,MAAM,WAAW,GAAI,QAAQ,CAAC,CAAC,UAAU,KAAG,MAIlD,CAAC;AAKF,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,GAAG,OAAO,CA2CvE;AAMD,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EACnE,MAAM,EAAE,MAAM,GACb,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CA8B1C"}
|
|
@@ -37,17 +37,33 @@ export function getObjectFormSchema(schema) {
|
|
|
37
37
|
return baseSchema ? baseSchema._def.typeName : '';
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
|
-
* Search for a "
|
|
40
|
+
* Search for a "ZodDefault" in the Zod stack and return its value.
|
|
41
41
|
*/ export function getDefaultValueInZodStack(schema) {
|
|
42
|
+
// Check if this is a ZodDefault and return its value
|
|
42
43
|
if (schema._def.typeName === z.ZodFirstPartyTypeKind.ZodDefault) {
|
|
43
|
-
|
|
44
|
+
const defaultValue = schema._def.defaultValue();
|
|
45
|
+
// If defaultValue is a function, call it to get the actual value
|
|
46
|
+
return typeof defaultValue === 'function' ? defaultValue() : defaultValue;
|
|
44
47
|
}
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
// Traverse through ZodEffects (like refinements) - check this first as it wraps the actual schema
|
|
49
|
+
if (schema._def.typeName === z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
50
|
+
return getDefaultValueInZodStack(schema._def.schema);
|
|
47
51
|
}
|
|
52
|
+
// Traverse through other types that have schema property
|
|
48
53
|
if ('schema' in schema._def) {
|
|
49
54
|
return getDefaultValueInZodStack(schema._def.schema);
|
|
50
55
|
}
|
|
56
|
+
// Traverse through ZodOptional, ZodNullable, etc.
|
|
57
|
+
if ('innerType' in schema._def) {
|
|
58
|
+
return getDefaultValueInZodStack(schema._def.innerType);
|
|
59
|
+
}
|
|
60
|
+
// Traverse through ZodArray's element type
|
|
61
|
+
if ('type' in schema._def && schema._def.typeName === z.ZodFirstPartyTypeKind.ZodArray) {
|
|
62
|
+
const innerDefault = getDefaultValueInZodStack(schema._def.type);
|
|
63
|
+
return innerDefault !== undefined ? [
|
|
64
|
+
innerDefault
|
|
65
|
+
] : undefined;
|
|
66
|
+
}
|
|
51
67
|
return undefined;
|
|
52
68
|
}
|
|
53
69
|
/**
|
|
@@ -59,23 +75,19 @@ export function getDefaultValues(schema) {
|
|
|
59
75
|
if (!shape) return defaultValues;
|
|
60
76
|
for (const key of Object.keys(shape)){
|
|
61
77
|
const item = shape[key];
|
|
62
|
-
|
|
78
|
+
// First, try to get any default value from the current item (including nested defaults)
|
|
79
|
+
const defaultValue = getDefaultValueInZodStack(item);
|
|
80
|
+
if (defaultValue !== undefined) {
|
|
81
|
+
defaultValues[key] = defaultValue;
|
|
82
|
+
} else if (getBaseType(item) === 'ZodObject') {
|
|
83
|
+
// Only recurse into object shape if there's no default value at the current level
|
|
63
84
|
const baseSchema = getBaseSchema(item);
|
|
64
85
|
if (baseSchema && 'shape' in baseSchema._def) {
|
|
65
86
|
const defaultItems = getDefaultValues(baseSchema);
|
|
66
|
-
if (defaultItems
|
|
67
|
-
|
|
68
|
-
for (const defaultItemKey of Object.keys(defaultItems)){
|
|
69
|
-
obj[defaultItemKey] = defaultItems[defaultItemKey];
|
|
70
|
-
defaultValues[key] = obj;
|
|
71
|
-
}
|
|
87
|
+
if (defaultItems && Object.keys(defaultItems).length > 0) {
|
|
88
|
+
defaultValues[key] = defaultItems;
|
|
72
89
|
}
|
|
73
90
|
}
|
|
74
|
-
} else {
|
|
75
|
-
const defaultValue = getDefaultValueInZodStack(item);
|
|
76
|
-
if (defaultValue !== undefined) {
|
|
77
|
-
defaultValues[key] = defaultValue;
|
|
78
|
-
}
|
|
79
91
|
}
|
|
80
92
|
}
|
|
81
93
|
return defaultValues;
|