@rolder/kit 3.0.0-alpha.8 → 3.0.0-alpha.9
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/ai/ui/conversation/ConversationContext.d.ts +7 -0
- package/dist/ai/ui/conversation/ConversationContext.js +8 -0
- package/dist/ai/ui/conversation/ConversationProvider.d.ts +2 -0
- package/dist/ai/ui/conversation/ConversationProvider.js +14 -0
- package/dist/ai/ui/conversation/Empty.d.ts +1 -0
- package/dist/ai/ui/conversation/Empty.js +21 -0
- package/dist/ai/ui/conversation/File.d.ts +4 -0
- package/dist/ai/ui/conversation/File.js +42 -0
- package/dist/ai/ui/conversation/FileIcon.d.ts +3 -0
- package/dist/ai/ui/conversation/FileIcon.js +225 -0
- package/dist/ai/ui/conversation/Loader.d.ts +2 -0
- package/dist/ai/ui/conversation/Loader.js +12 -0
- package/dist/ai/ui/conversation/Message.d.ts +4 -0
- package/dist/ai/ui/conversation/Message.js +25 -0
- package/dist/ai/ui/conversation/Root.d.ts +2 -0
- package/dist/ai/ui/conversation/Root.js +26 -0
- package/dist/ai/ui/conversation/index.d.ts +13 -0
- package/dist/ai/ui/conversation/index.js +14 -0
- package/{src/ai/ui/conversation/types.ts → dist/ai/ui/conversation/types.d.ts} +4 -5
- package/dist/ai/ui/conversation/types.js +0 -0
- package/dist/ai/ui/conversation/useChatMessage.d.ts +2 -0
- package/dist/ai/ui/conversation/useChatMessage.js +12 -0
- package/dist/ai/ui/promptInput/File.d.ts +2 -0
- package/dist/ai/ui/promptInput/File.js +117 -0
- package/dist/ai/ui/promptInput/FileIcon.d.ts +3 -0
- package/dist/ai/ui/promptInput/FileIcon.js +225 -0
- package/dist/ai/ui/promptInput/Footer.d.ts +2 -0
- package/dist/ai/ui/promptInput/Footer.js +8 -0
- package/dist/ai/ui/promptInput/PromptInputContext.d.ts +12 -0
- package/dist/ai/ui/promptInput/PromptInputContext.js +8 -0
- package/dist/ai/ui/promptInput/PromptInputProvider.d.ts +2 -0
- package/dist/ai/ui/promptInput/PromptInputProvider.js +50 -0
- package/dist/ai/ui/promptInput/Root.d.ts +3 -0
- package/dist/ai/ui/promptInput/Root.js +17 -0
- package/dist/ai/ui/promptInput/Submit.d.ts +2 -0
- package/dist/ai/ui/promptInput/Submit.js +40 -0
- package/dist/ai/ui/promptInput/Textarea.d.ts +2 -0
- package/dist/ai/ui/promptInput/Textarea.js +33 -0
- package/dist/ai/ui/promptInput/index.d.ts +8 -0
- package/dist/ai/ui/promptInput/index.js +13 -0
- package/dist/ai/ui/promptInput/types.d.ts +11 -0
- package/dist/ai/ui/promptInput/types.js +0 -0
- package/dist/ai/utils/convertFileUIPartBlobToDataURL.d.ts +5 -0
- package/dist/ai/utils/convertFileUIPartBlobToDataURL.js +21 -0
- package/dist/ai/utils/parseAiMessagePart.d.ts +2 -0
- package/dist/ai/utils/parseAiMessagePart.js +12 -0
- package/dist/app/AppDefaults.d.ts +3 -0
- package/dist/app/AppDefaults.js +27 -0
- package/dist/app/DefaultApp.d.ts +6 -0
- package/dist/app/DefaultApp.js +43 -0
- package/dist/app/cookieColorSchemeManager.d.ts +6 -0
- package/dist/app/cookieColorSchemeManager.js +46 -0
- package/dist/app/defaultRequestMiddlewares.d.ts +4 -0
- package/dist/app/defaultRequestMiddlewares.js +24 -0
- package/dist/app/defaultTheme.d.ts +141 -0
- package/dist/app/defaultTheme.js +24 -0
- package/dist/functions/getCookie.d.ts +3 -0
- package/dist/functions/getCookie.js +8 -0
- package/dist/functions/setCookie.d.ts +10 -0
- package/dist/functions/setCookie.js +19 -0
- package/dist/functions/setCookies.d.ts +14 -0
- package/dist/functions/setCookies.js +13 -0
- package/dist/hooks/useMutation.d.ts +4 -0
- package/dist/hooks/useMutation.js +8 -0
- package/dist/hooks/useMutationWithInvalidate.d.ts +4 -0
- package/dist/hooks/useMutationWithInvalidate.js +16 -0
- package/{src/index.ts → dist/index.d.ts} +5 -45
- package/dist/index.js +26 -0
- package/{src → dist}/styles.css +11 -21
- package/dist/surreal/connection.d.ts +9 -0
- package/dist/surreal/connection.js +49 -0
- package/dist/surreal/deafaultCrud.d.ts +2 -0
- package/dist/surreal/deafaultCrud.js +18 -0
- package/dist/surreal/deserialize.d.ts +17 -0
- package/dist/surreal/deserialize.js +46 -0
- package/dist/surreal/encryption.d.ts +6 -0
- package/dist/surreal/encryption.js +30 -0
- package/dist/ui/AnimatedChevron.d.ts +6 -0
- package/dist/ui/AnimatedChevron.js +31 -0
- package/dist/ui/JsonInput.d.ts +2 -0
- package/dist/ui/JsonInput.js +45 -0
- package/dist/ui/RouterLink.d.ts +16 -0
- package/dist/ui/RouterLink.js +36 -0
- package/dist/ui/editor/Content.d.ts +3 -0
- package/dist/ui/editor/Content.js +13 -0
- package/dist/ui/editor/Provider.d.ts +17 -0
- package/dist/ui/editor/Provider.js +80 -0
- package/dist/ui/editor/Root.d.ts +2 -0
- package/dist/ui/editor/Root.js +18 -0
- package/dist/ui/editor/Toolbar.d.ts +5 -0
- package/dist/ui/editor/Toolbar.js +156 -0
- package/dist/ui/editor/index.d.ts +12 -0
- package/dist/ui/editor/index.js +11 -0
- package/dist/ui/editor/types.d.ts +7 -0
- package/dist/ui/editor/types.js +0 -0
- package/dist/ui/error/DefaultError.d.ts +2 -0
- package/dist/ui/error/DefaultError.js +62 -0
- package/dist/ui/error/DefaultNotFound.d.ts +1 -0
- package/dist/ui/error/DefaultNotFound.js +37 -0
- package/dist/ui/error/Forbidden.d.ts +1 -0
- package/dist/ui/error/Forbidden.js +32 -0
- package/dist/ui/error/defaultErrorNotification.d.ts +1 -0
- package/dist/ui/error/defaultErrorNotification.js +8 -0
- package/dist/ui/error/index.js +5 -0
- package/dist/ui/form/blurOnError.d.ts +4 -0
- package/dist/ui/form/blurOnError.js +11 -0
- package/dist/ui/form/buttons/CancelButton.d.ts +5 -0
- package/dist/ui/form/buttons/CancelButton.js +44 -0
- package/dist/ui/form/buttons/SubmitButton.d.ts +5 -0
- package/dist/ui/form/buttons/SubmitButton.js +47 -0
- package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +4 -0
- package/dist/ui/form/buttons/SubscribeActionIcon.js +15 -0
- package/dist/ui/form/buttons/SubscribeButton.d.ts +5 -0
- package/dist/ui/form/buttons/SubscribeButton.js +16 -0
- package/dist/ui/form/buttons/index.js +4 -0
- package/dist/ui/form/context.d.ts +83 -0
- package/dist/ui/form/context.js +26 -0
- package/dist/ui/form/fields/JsonField.d.ts +2 -0
- package/dist/ui/form/fields/JsonField.js +13 -0
- package/dist/ui/form/fields/MultiSelectField.d.ts +2 -0
- package/dist/ui/form/fields/MultiSelectField.js +15 -0
- package/dist/ui/form/fields/NumberField.d.ts +2 -0
- package/dist/ui/form/fields/NumberField.js +15 -0
- package/dist/ui/form/fields/PassowrdField.d.ts +2 -0
- package/dist/ui/form/fields/PassowrdField.js +18 -0
- package/dist/ui/form/fields/SelectField.d.ts +2 -0
- package/dist/ui/form/fields/SelectField.js +15 -0
- package/dist/ui/form/fields/SwitchField.d.ts +2 -0
- package/dist/ui/form/fields/SwitchField.js +15 -0
- package/dist/ui/form/fields/TextField.d.ts +2 -0
- package/dist/ui/form/fields/TextField.js +15 -0
- package/dist/ui/form/fields/TextPassowrdField.d.ts +2 -0
- package/dist/ui/form/fields/TextPassowrdField.js +51 -0
- package/dist/ui/form/fields/TextareaField.d.ts +2 -0
- package/dist/ui/form/fields/TextareaField.js +15 -0
- package/dist/ui/form/fields/index.js +9 -0
- package/dist/ui/form/fieldsSchema.d.ts +12 -0
- package/dist/ui/form/fieldsSchema.js +13 -0
- package/dist/ui/form/index.js +4 -0
- package/dist/ui/hoverPaper/HoverPaper.d.ts +6 -0
- package/dist/ui/hoverPaper/HoverPaper.js +15 -0
- package/dist/ui/hoverPaper/index.js +3 -0
- package/dist/ui/hoverPaper/usePaperHover.d.ts +4 -0
- package/dist/ui/hoverPaper/usePaperHover.js +9 -0
- package/dist/ui/saveInput/JsonInput.d.ts +6 -0
- package/dist/ui/saveInput/JsonInput.js +34 -0
- package/dist/ui/saveInput/NumberInput.d.ts +6 -0
- package/dist/ui/saveInput/NumberInput.js +27 -0
- package/dist/ui/saveInput/SaveInput.d.ts +36 -0
- package/dist/ui/saveInput/SaveInput.js +15 -0
- package/dist/ui/saveInput/Select.d.ts +6 -0
- package/dist/ui/saveInput/Select.js +27 -0
- package/dist/ui/saveInput/Switch.d.ts +6 -0
- package/dist/ui/saveInput/Switch.js +30 -0
- package/dist/ui/saveInput/TextInput.d.ts +6 -0
- package/dist/ui/saveInput/TextInput.js +26 -0
- package/dist/ui/saveInput/Textarea.d.ts +6 -0
- package/dist/ui/saveInput/Textarea.js +26 -0
- package/dist/ui/saveInput/index.js +2 -0
- package/{src/ui/scrollArea/ScrollArea.tsx → dist/ui/scrollArea/ScrollArea.d.ts} +10 -41
- package/dist/ui/scrollArea/ScrollArea.js +30 -0
- package/dist/ui/scrollArea/ScrollAreaButton.d.ts +5 -0
- package/dist/ui/scrollArea/ScrollAreaButton.js +51 -0
- package/dist/ui/scrollArea/ScrollAreaContent.d.ts +6 -0
- package/dist/ui/scrollArea/ScrollAreaContent.js +29 -0
- package/{src/ui/scrollArea/context.tsx → dist/ui/scrollArea/context.d.ts} +3 -18
- package/dist/ui/scrollArea/context.js +10 -0
- package/dist/ui/scrollArea/index.d.ts +3 -0
- package/dist/ui/scrollArea/index.js +3 -0
- package/dist/ui/scrollArea/types.d.ts +65 -0
- package/dist/ui/scrollArea/types.js +0 -0
- package/dist/ui/scrollArea/useScrollArea.d.ts +9 -0
- package/dist/ui/scrollArea/useScrollArea.js +146 -0
- package/package.json +4 -1
- package/rslib.config.ts +0 -21
- package/src/ai/ui/conversation/ConversationContext.ts +0 -21
- package/src/ai/ui/conversation/ConversationProvider.tsx +0 -21
- package/src/ai/ui/conversation/Empty.tsx +0 -15
- package/src/ai/ui/conversation/File.tsx +0 -40
- package/src/ai/ui/conversation/FileIcon.tsx +0 -143
- package/src/ai/ui/conversation/Loader.tsx +0 -8
- package/src/ai/ui/conversation/Message.tsx +0 -34
- package/src/ai/ui/conversation/Root.tsx +0 -24
- package/src/ai/ui/conversation/index.ts +0 -16
- package/src/ai/ui/conversation/useChatMessage.ts +0 -13
- package/src/ai/ui/promptInput/File.tsx +0 -98
- package/src/ai/ui/promptInput/FileIcon.tsx +0 -149
- package/src/ai/ui/promptInput/Footer.tsx +0 -5
- package/src/ai/ui/promptInput/PromptInputContext.ts +0 -24
- package/src/ai/ui/promptInput/PromptInputProvider.tsx +0 -54
- package/src/ai/ui/promptInput/Root.tsx +0 -29
- package/src/ai/ui/promptInput/Submit.tsx +0 -39
- package/src/ai/ui/promptInput/Textarea.tsx +0 -39
- package/src/ai/ui/promptInput/index.ts +0 -15
- package/src/ai/ui/promptInput/types.ts +0 -9
- package/src/ai/utils/convertFileUIPartBlobToDataURL.ts +0 -29
- package/src/ai/utils/parseAiMessagePart.ts +0 -19
- package/src/app/AppDefaults.tsx +0 -21
- package/src/app/DefaultApp.tsx +0 -50
- package/src/app/cookieColorSchemeManager.ts +0 -70
- package/src/app/defaultRequestMiddlewares.ts +0 -22
- package/src/app/defaultTheme.ts +0 -22
- package/src/functions/getCookie.ts +0 -36
- package/src/functions/setCookie.ts +0 -29
- package/src/functions/setCookies.ts +0 -24
- package/src/hooks/useMutation.ts +0 -14
- package/src/hooks/useMutationWithInvalidate.ts +0 -23
- package/src/surreal/connection.ts +0 -72
- package/src/surreal/deafaultCrud.ts +0 -25
- package/src/surreal/deserialize.ts +0 -144
- package/src/surreal/encryption.ts +0 -51
- package/src/ui/AnimatedChevron.tsx +0 -32
- package/src/ui/JsonInput.tsx +0 -52
- package/src/ui/RouterLink.tsx +0 -78
- package/src/ui/editor/Content.tsx +0 -11
- package/src/ui/editor/Provider.tsx +0 -96
- package/src/ui/editor/Root.tsx +0 -25
- package/src/ui/editor/Toolbar.tsx +0 -92
- package/src/ui/editor/index.ts +0 -13
- package/src/ui/editor/types.ts +0 -7
- package/src/ui/error/DefaultError.tsx +0 -60
- package/src/ui/error/DefaultNotFound.tsx +0 -19
- package/src/ui/error/Forbidden.tsx +0 -18
- package/src/ui/error/defaultErrorNotification.ts +0 -9
- package/src/ui/form/blurOnError.ts +0 -21
- package/src/ui/form/buttons/CancelButton.tsx +0 -42
- package/src/ui/form/buttons/SubmitButton.tsx +0 -43
- package/src/ui/form/buttons/SubscribeActionIcon.tsx +0 -18
- package/src/ui/form/buttons/SubscribeButton.tsx +0 -17
- package/src/ui/form/context.ts +0 -45
- package/src/ui/form/fields/JsonField.tsx +0 -16
- package/src/ui/form/fields/MultiSelectField.tsx +0 -17
- package/src/ui/form/fields/NumberField.tsx +0 -17
- package/src/ui/form/fields/PassowrdField.tsx +0 -20
- package/src/ui/form/fields/SelectField.tsx +0 -17
- package/src/ui/form/fields/SwitchField.tsx +0 -17
- package/src/ui/form/fields/TextField.tsx +0 -17
- package/src/ui/form/fields/TextPassowrdField.tsx +0 -51
- package/src/ui/form/fields/TextareaField.tsx +0 -17
- package/src/ui/form/fieldsSchema.ts +0 -24
- package/src/ui/hoverPaper/HoverPaper.tsx +0 -17
- package/src/ui/hoverPaper/usePaperHover.ts +0 -9
- package/src/ui/saveInput/JsonInput.tsx +0 -40
- package/src/ui/saveInput/NumberInput.tsx +0 -40
- package/src/ui/saveInput/SaveInput.tsx +0 -15
- package/src/ui/saveInput/Select.tsx +0 -41
- package/src/ui/saveInput/Switch.tsx +0 -46
- package/src/ui/saveInput/TextInput.tsx +0 -40
- package/src/ui/saveInput/Textarea.tsx +0 -40
- package/src/ui/scrollArea/ARCH.md +0 -204
- package/src/ui/scrollArea/README.md +0 -369
- package/src/ui/scrollArea/ScrollAreaButton.tsx +0 -56
- package/src/ui/scrollArea/ScrollAreaContent.tsx +0 -36
- package/src/ui/scrollArea/index.ts +0 -10
- package/src/ui/scrollArea/types.ts +0 -77
- package/src/ui/scrollArea/useScrollArea.ts +0 -227
- package/tsconfig.json +0 -14
- /package/{src/ui/error/index.ts → dist/ui/error/index.d.ts} +0 -0
- /package/{src/ui/form/buttons/index.ts → dist/ui/form/buttons/index.d.ts} +0 -0
- /package/{src/ui/form/fields/index.ts → dist/ui/form/fields/index.d.ts} +0 -0
- /package/{src/ui/form/index.ts → dist/ui/form/index.d.ts} +0 -0
- /package/{src/ui/hoverPaper/index.ts → dist/ui/hoverPaper/index.d.ts} +0 -0
- /package/{src/ui/saveInput/index.ts → dist/ui/saveInput/index.d.ts} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createMiddleware } from "@tanstack/react-start";
|
|
2
|
+
import { getCookie, getRequestHeader, setCookie } from "@tanstack/react-start/server";
|
|
3
|
+
const defaultRequestMiddlewares_locale = createMiddleware().server(async ({ next })=>{
|
|
4
|
+
const header = getRequestHeader('accept-language');
|
|
5
|
+
const headerLocale = header?.split(',')[0] || 'ru-RU';
|
|
6
|
+
const cookieLocale = getCookie('locale');
|
|
7
|
+
const cookieTz = getCookie('tz');
|
|
8
|
+
const locale = cookieLocale || headerLocale;
|
|
9
|
+
const timeZone = cookieTz || 'UTC';
|
|
10
|
+
setCookie('locale', locale, {
|
|
11
|
+
path: '/',
|
|
12
|
+
maxAge: 31536000
|
|
13
|
+
});
|
|
14
|
+
return next({
|
|
15
|
+
context: {
|
|
16
|
+
locale,
|
|
17
|
+
timeZone
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
const defaultRequestMiddlewares = [
|
|
22
|
+
defaultRequestMiddlewares_locale
|
|
23
|
+
];
|
|
24
|
+
export { defaultRequestMiddlewares };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export declare const defaultTheme: {
|
|
2
|
+
focusRing?: "auto" | "always" | "never" | undefined;
|
|
3
|
+
scale?: number | undefined;
|
|
4
|
+
fontSmoothing?: boolean | undefined;
|
|
5
|
+
white?: string | undefined;
|
|
6
|
+
black?: string | undefined;
|
|
7
|
+
colors?: {
|
|
8
|
+
[x: string & {}]: import("@mantine/core").MantineColorsTuple | undefined;
|
|
9
|
+
dark?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
10
|
+
gray?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
11
|
+
red?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
12
|
+
pink?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
13
|
+
grape?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
14
|
+
violet?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
15
|
+
indigo?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
16
|
+
blue?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
17
|
+
cyan?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
18
|
+
green?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
19
|
+
lime?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
20
|
+
yellow?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
21
|
+
orange?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
22
|
+
teal?: import("@mantine/core").MantineColorsTuple | undefined;
|
|
23
|
+
} | undefined;
|
|
24
|
+
primaryShade?: import("@mantine/core").MantineColorShade | {
|
|
25
|
+
light?: import("@mantine/core").MantineColorShade | undefined;
|
|
26
|
+
dark?: import("@mantine/core").MantineColorShade | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
primaryColor?: string | undefined;
|
|
29
|
+
variantColorResolver?: import("@mantine/core").VariantColorsResolver | undefined;
|
|
30
|
+
autoContrast?: boolean | undefined;
|
|
31
|
+
luminanceThreshold?: number | undefined;
|
|
32
|
+
fontFamily?: string | undefined;
|
|
33
|
+
fontFamilyMonospace?: string | undefined;
|
|
34
|
+
headings?: {
|
|
35
|
+
fontFamily?: string | undefined;
|
|
36
|
+
fontWeight?: string | undefined;
|
|
37
|
+
textWrap?: "balance" | "nowrap" | "wrap" | "stable" | "pretty" | undefined;
|
|
38
|
+
sizes?: {
|
|
39
|
+
h1?: {
|
|
40
|
+
fontSize?: string | undefined;
|
|
41
|
+
fontWeight?: string | undefined;
|
|
42
|
+
lineHeight?: string | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
h2?: {
|
|
45
|
+
fontSize?: string | undefined;
|
|
46
|
+
fontWeight?: string | undefined;
|
|
47
|
+
lineHeight?: string | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
h3?: {
|
|
50
|
+
fontSize?: string | undefined;
|
|
51
|
+
fontWeight?: string | undefined;
|
|
52
|
+
lineHeight?: string | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
h4?: {
|
|
55
|
+
fontSize?: string | undefined;
|
|
56
|
+
fontWeight?: string | undefined;
|
|
57
|
+
lineHeight?: string | undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
h5?: {
|
|
60
|
+
fontSize?: string | undefined;
|
|
61
|
+
fontWeight?: string | undefined;
|
|
62
|
+
lineHeight?: string | undefined;
|
|
63
|
+
} | undefined;
|
|
64
|
+
h6?: {
|
|
65
|
+
fontSize?: string | undefined;
|
|
66
|
+
fontWeight?: string | undefined;
|
|
67
|
+
lineHeight?: string | undefined;
|
|
68
|
+
} | undefined;
|
|
69
|
+
} | undefined;
|
|
70
|
+
} | undefined;
|
|
71
|
+
radius?: {
|
|
72
|
+
[x: string & {}]: string | undefined;
|
|
73
|
+
xs?: string | undefined;
|
|
74
|
+
sm?: string | undefined;
|
|
75
|
+
md?: string | undefined;
|
|
76
|
+
lg?: string | undefined;
|
|
77
|
+
xl?: string | undefined;
|
|
78
|
+
} | undefined;
|
|
79
|
+
defaultRadius?: import("@mantine/core").MantineRadius | undefined;
|
|
80
|
+
spacing?: {
|
|
81
|
+
[x: number]: string | undefined;
|
|
82
|
+
[x: string & {}]: string | undefined;
|
|
83
|
+
xs?: string | undefined;
|
|
84
|
+
sm?: string | undefined;
|
|
85
|
+
md?: string | undefined;
|
|
86
|
+
lg?: string | undefined;
|
|
87
|
+
xl?: string | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
fontSizes?: {
|
|
90
|
+
[x: string & {}]: string | undefined;
|
|
91
|
+
xs?: string | undefined;
|
|
92
|
+
sm?: string | undefined;
|
|
93
|
+
md?: string | undefined;
|
|
94
|
+
lg?: string | undefined;
|
|
95
|
+
xl?: string | undefined;
|
|
96
|
+
} | undefined;
|
|
97
|
+
lineHeights?: {
|
|
98
|
+
[x: string & {}]: string | undefined;
|
|
99
|
+
xs?: string | undefined;
|
|
100
|
+
sm?: string | undefined;
|
|
101
|
+
md?: string | undefined;
|
|
102
|
+
lg?: string | undefined;
|
|
103
|
+
xl?: string | undefined;
|
|
104
|
+
} | undefined;
|
|
105
|
+
breakpoints?: {
|
|
106
|
+
[x: string & {}]: string | undefined;
|
|
107
|
+
xs?: string | undefined;
|
|
108
|
+
sm?: string | undefined;
|
|
109
|
+
md?: string | undefined;
|
|
110
|
+
lg?: string | undefined;
|
|
111
|
+
xl?: string | undefined;
|
|
112
|
+
} | undefined;
|
|
113
|
+
shadows?: {
|
|
114
|
+
[x: string & {}]: string | undefined;
|
|
115
|
+
xs?: string | undefined;
|
|
116
|
+
sm?: string | undefined;
|
|
117
|
+
md?: string | undefined;
|
|
118
|
+
lg?: string | undefined;
|
|
119
|
+
xl?: string | undefined;
|
|
120
|
+
} | undefined;
|
|
121
|
+
respectReducedMotion?: boolean | undefined;
|
|
122
|
+
cursorType?: "default" | "pointer" | undefined;
|
|
123
|
+
defaultGradient?: {
|
|
124
|
+
from?: string | undefined;
|
|
125
|
+
to?: string | undefined;
|
|
126
|
+
deg?: number | undefined;
|
|
127
|
+
} | undefined;
|
|
128
|
+
activeClassName?: string | undefined;
|
|
129
|
+
focusClassName?: string | undefined;
|
|
130
|
+
components?: {
|
|
131
|
+
[x: string]: {
|
|
132
|
+
classNames?: any;
|
|
133
|
+
styles?: any;
|
|
134
|
+
vars?: any;
|
|
135
|
+
defaultProps?: any;
|
|
136
|
+
} | undefined;
|
|
137
|
+
} | undefined;
|
|
138
|
+
other?: {
|
|
139
|
+
[x: string]: any;
|
|
140
|
+
} | undefined;
|
|
141
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Modal, createTheme } from "@mantine/core";
|
|
2
|
+
const defaultTheme = createTheme({
|
|
3
|
+
components: {
|
|
4
|
+
Modal: Modal.extend({
|
|
5
|
+
defaultProps: {
|
|
6
|
+
centered: true,
|
|
7
|
+
padding: 'lg'
|
|
8
|
+
}
|
|
9
|
+
}),
|
|
10
|
+
ModalTitle: Modal.Title.extend({
|
|
11
|
+
defaultProps: {
|
|
12
|
+
pr: 24
|
|
13
|
+
}
|
|
14
|
+
}),
|
|
15
|
+
ModalCloseButton: Modal.CloseButton.extend({
|
|
16
|
+
defaultProps: {
|
|
17
|
+
pos: 'absolute',
|
|
18
|
+
top: 4,
|
|
19
|
+
right: 4
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
export { defaultTheme };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createIsomorphicFn } from "@tanstack/react-start";
|
|
2
|
+
import { getCookie } from "@tanstack/react-start/server";
|
|
3
|
+
import js_cookie from "js-cookie";
|
|
4
|
+
const getCookieImpl = createIsomorphicFn().server((name, defaultValue)=>getCookie(name) || defaultValue).client((name, defaultValue)=>js_cookie.get(name) || defaultValue);
|
|
5
|
+
function getCookie_getCookie(name, defaultValue) {
|
|
6
|
+
return getCookieImpl(name, defaultValue);
|
|
7
|
+
}
|
|
8
|
+
export { getCookie_getCookie as getCookie };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Изоморфная функция для установки значения куки.
|
|
3
|
+
* На клиенте использует библиотеку js-cookie для работы с куками.
|
|
4
|
+
* На сервере использует функции getCookie и setCookie из tanstack start.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} name - Имя куки
|
|
7
|
+
* @param {string} value - Значение куки, если не указано, кука будет удалена
|
|
8
|
+
* @param {number} [expires=7] - Количество дней до истечения срока действия куки (по умолчанию 7 дней)
|
|
9
|
+
*/
|
|
10
|
+
export declare const setCookie: import("@tanstack/start-fn-stubs").IsomorphicFn<[name: string, value?: string | undefined, expires?: number | undefined], void, void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createIsomorphicFn } from "@tanstack/react-start";
|
|
2
|
+
import { deleteCookie, setCookie } from "@tanstack/react-start/server";
|
|
3
|
+
import js_cookie from "js-cookie";
|
|
4
|
+
const setCookie_setCookie = createIsomorphicFn().server((name, value, expires)=>{
|
|
5
|
+
const expiresDate = new Date();
|
|
6
|
+
expiresDate.setDate(expiresDate.getDate() + (expires || 7));
|
|
7
|
+
if (value) setCookie(name, value, {
|
|
8
|
+
expires: expiresDate
|
|
9
|
+
});
|
|
10
|
+
else deleteCookie(name);
|
|
11
|
+
}).client((name, value, expires)=>{
|
|
12
|
+
const expiresDate = new Date();
|
|
13
|
+
expiresDate.setDate(expiresDate.getDate() + (expires || 7));
|
|
14
|
+
if (value) js_cookie.set(name, value, {
|
|
15
|
+
expires: expiresDate
|
|
16
|
+
});
|
|
17
|
+
else js_cookie.remove(name);
|
|
18
|
+
});
|
|
19
|
+
export { setCookie_setCookie as setCookie };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface Cookie {
|
|
2
|
+
name: string;
|
|
3
|
+
value?: string;
|
|
4
|
+
expires?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Клиентская функция для установки значения нескольких куки.
|
|
8
|
+
* На клиенте использует библиотеку js-cookie для работы с куками.
|
|
9
|
+
* На сервере использует функции getCookie и setCookie из tanstack start.
|
|
10
|
+
*
|
|
11
|
+
* @param {Cookie[]} cookies - Массив объектов с данными куки *
|
|
12
|
+
*/
|
|
13
|
+
export declare const setCookies: (cookies: Cookie[]) => void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createClientOnlyFn } from "@tanstack/react-start";
|
|
2
|
+
import js_cookie from "js-cookie";
|
|
3
|
+
const setCookies = createClientOnlyFn((cookies)=>{
|
|
4
|
+
cookies.forEach(({ name, value, expires })=>{
|
|
5
|
+
const expiresDate = new Date();
|
|
6
|
+
expiresDate.setDate(expiresDate.getDate() + (expires || 7));
|
|
7
|
+
if (value) js_cookie.set(name, value, {
|
|
8
|
+
expires: expiresDate
|
|
9
|
+
});
|
|
10
|
+
else js_cookie.remove(name);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
export { setCookies };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type UseMutationOptions } from '@tanstack/react-query';
|
|
2
|
+
export declare const useMutation: <T, K = void>(fn: ({ data }: {
|
|
3
|
+
data: T;
|
|
4
|
+
}) => Promise<K>, options?: Omit<UseMutationOptions<K, Error, T>, "mutationFn">) => import("@tanstack/react-query").UseMutationResult<K, Error, T, unknown>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type UseMutationOptions } from '@tanstack/react-query';
|
|
2
|
+
export declare const useMutationWithInvalidate: <T, K = void>(fn: ({ data }: {
|
|
3
|
+
data: T;
|
|
4
|
+
}) => Promise<K>, queryKey: string[], options?: Omit<UseMutationOptions<K, Error, T>, "mutationFn" | "onSettled">) => import("@tanstack/react-query").UseMutationResult<K, Error, T, unknown>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
2
|
+
const useMutationWithInvalidate = (fn, queryKey, options)=>{
|
|
3
|
+
const queryClient = useQueryClient();
|
|
4
|
+
return useMutation({
|
|
5
|
+
mutationFn: (data)=>fn({
|
|
6
|
+
data
|
|
7
|
+
}),
|
|
8
|
+
onSettled: async (_, error)=>{
|
|
9
|
+
if (!error && queryKey.length) await queryClient.invalidateQueries({
|
|
10
|
+
queryKey
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
...options
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export { useMutationWithInvalidate };
|
|
@@ -1,66 +1,26 @@
|
|
|
1
1
|
/** biome-ignore-all assist/source/organizeImports: <> */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
Conversation,
|
|
6
|
-
type ConversationProps,
|
|
7
|
-
useChatMessage,
|
|
8
|
-
} from './ai/ui/conversation';
|
|
9
|
-
export {
|
|
10
|
-
type Accept,
|
|
11
|
-
PromptInput,
|
|
12
|
-
type PromptInputProps,
|
|
13
|
-
} from './ai/ui/promptInput';
|
|
2
|
+
export { Conversation, type ConversationProps, useChatMessage, } from './ai/ui/conversation';
|
|
3
|
+
export { type Accept, PromptInput, type PromptInputProps, } from './ai/ui/promptInput';
|
|
14
4
|
export { convertFileUIPartBlobToDataURL } from './ai/utils/convertFileUIPartBlobToDataURL';
|
|
15
5
|
export { parseAiMessagePart } from './ai/utils/parseAiMessagePart';
|
|
16
|
-
|
|
17
|
-
//* APP *//
|
|
18
6
|
export { DefaultApp } from './app/DefaultApp';
|
|
19
7
|
export { defaultRequestMiddlewares } from './app/defaultRequestMiddlewares';
|
|
20
8
|
export { defaultTheme } from './app/defaultTheme';
|
|
21
|
-
|
|
22
|
-
//* FUNCTIONS *//
|
|
23
9
|
export { getCookie } from './functions/getCookie';
|
|
24
10
|
export { setCookie } from './functions/setCookie';
|
|
25
11
|
export { setCookies } from './functions/setCookies';
|
|
26
|
-
|
|
27
|
-
//* HOOKS *//
|
|
28
12
|
export { useMutation } from './hooks/useMutation';
|
|
29
13
|
export { useMutationWithInvalidate } from './hooks/useMutationWithInvalidate';
|
|
30
|
-
|
|
31
|
-
//* SURREAL *//
|
|
32
14
|
export { getDB } from './surreal/connection';
|
|
33
15
|
export { surrealDeleteFn, surrealUnsubscribeFn } from './surreal/deafaultCrud';
|
|
34
16
|
export { deserialize } from './surreal/deserialize';
|
|
35
17
|
export { encryptionFn } from './surreal/encryption';
|
|
36
|
-
|
|
37
|
-
//* UI *//
|
|
38
18
|
export { Editor, useEditor } from './ui/editor';
|
|
39
|
-
export {
|
|
40
|
-
DefaultError,
|
|
41
|
-
DefaultNotFound,
|
|
42
|
-
defaultErrorNotification,
|
|
43
|
-
Forbidden,
|
|
44
|
-
} from './ui/error';
|
|
19
|
+
export { DefaultError, DefaultNotFound, defaultErrorNotification, Forbidden, } from './ui/error';
|
|
45
20
|
export { AnimatedChevron } from './ui/AnimatedChevron';
|
|
46
|
-
export {
|
|
47
|
-
useAppForm,
|
|
48
|
-
useFieldContext,
|
|
49
|
-
withForm,
|
|
50
|
-
blurOnError,
|
|
51
|
-
fieldsSchema,
|
|
52
|
-
} from './ui/form';
|
|
21
|
+
export { useAppForm, useFieldContext, withForm, blurOnError, fieldsSchema, } from './ui/form';
|
|
53
22
|
export { HoverPaper, usePaperHover } from './ui/hoverPaper';
|
|
54
23
|
export { JsonInput } from './ui/JsonInput';
|
|
55
24
|
export { RouterLink } from './ui/RouterLink';
|
|
56
25
|
export { SaveInput } from './ui/saveInput';
|
|
57
|
-
export {
|
|
58
|
-
ScrollArea,
|
|
59
|
-
useScrollArea,
|
|
60
|
-
type ScrollAreaContextValue,
|
|
61
|
-
type ScrollAreaHook,
|
|
62
|
-
type ScrollAreaProps,
|
|
63
|
-
type ScrollAreaState,
|
|
64
|
-
type ScrollButtonProps,
|
|
65
|
-
type ScrollPosition,
|
|
66
|
-
} from './ui/scrollArea';
|
|
26
|
+
export { ScrollArea, useScrollArea, type ScrollAreaContextValue, type ScrollAreaHook, type ScrollAreaProps, type ScrollAreaState, type ScrollButtonProps, type ScrollPosition, } from './ui/scrollArea';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Conversation, useChatMessage } from "./ai/ui/conversation/index.js";
|
|
2
|
+
import { PromptInput } from "./ai/ui/promptInput/index.js";
|
|
3
|
+
import { convertFileUIPartBlobToDataURL } from "./ai/utils/convertFileUIPartBlobToDataURL.js";
|
|
4
|
+
import { parseAiMessagePart } from "./ai/utils/parseAiMessagePart.js";
|
|
5
|
+
import { DefaultApp } from "./app/DefaultApp.js";
|
|
6
|
+
import { defaultRequestMiddlewares } from "./app/defaultRequestMiddlewares.js";
|
|
7
|
+
import { defaultTheme } from "./app/defaultTheme.js";
|
|
8
|
+
import { getCookie } from "./functions/getCookie.js";
|
|
9
|
+
import { setCookie } from "./functions/setCookie.js";
|
|
10
|
+
import { setCookies } from "./functions/setCookies.js";
|
|
11
|
+
import { useMutation } from "./hooks/useMutation.js";
|
|
12
|
+
import { useMutationWithInvalidate } from "./hooks/useMutationWithInvalidate.js";
|
|
13
|
+
import { getDB } from "./surreal/connection.js";
|
|
14
|
+
import { surrealDeleteFn, surrealUnsubscribeFn } from "./surreal/deafaultCrud.js";
|
|
15
|
+
import { deserialize } from "./surreal/deserialize.js";
|
|
16
|
+
import { encryptionFn } from "./surreal/encryption.js";
|
|
17
|
+
import { Editor, useEditor } from "./ui/editor/index.js";
|
|
18
|
+
import { DefaultError, DefaultNotFound, Forbidden, defaultErrorNotification } from "./ui/error/index.js";
|
|
19
|
+
import { AnimatedChevron } from "./ui/AnimatedChevron.js";
|
|
20
|
+
import { blurOnError, fieldsSchema, useAppForm, useFieldContext, withForm } from "./ui/form/index.js";
|
|
21
|
+
import { HoverPaper, usePaperHover } from "./ui/hoverPaper/index.js";
|
|
22
|
+
import { JsonInput } from "./ui/JsonInput.js";
|
|
23
|
+
import { RouterLink } from "./ui/RouterLink.js";
|
|
24
|
+
import { SaveInput } from "./ui/saveInput/index.js";
|
|
25
|
+
import { ScrollArea, useScrollArea } from "./ui/scrollArea/index.js";
|
|
26
|
+
export { AnimatedChevron, Conversation, DefaultApp, DefaultError, DefaultNotFound, Editor, Forbidden, HoverPaper, JsonInput, PromptInput, RouterLink, SaveInput, ScrollArea, blurOnError, convertFileUIPartBlobToDataURL, defaultErrorNotification, defaultRequestMiddlewares, defaultTheme, deserialize, encryptionFn, fieldsSchema, getCookie, getDB, parseAiMessagePart, setCookie, setCookies, surrealDeleteFn, surrealUnsubscribeFn, useAppForm, useChatMessage, useEditor, useFieldContext, useMutation, useMutationWithInvalidate, usePaperHover, useScrollArea, withForm };
|
package/{src → dist}/styles.css
RENAMED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
.rolder-prompt-input-root {
|
|
2
|
-
background-color: light-dark(
|
|
3
|
-
var(--mantine-color-white),
|
|
4
|
-
var(--mantine-color-dark-6)
|
|
5
|
-
);
|
|
2
|
+
background-color: light-dark(var(--mantine-color-white), var(--mantine-color-dark-6));
|
|
6
3
|
|
|
7
4
|
&:focus-within {
|
|
8
|
-
outline: none;
|
|
9
5
|
border-color: var(--mantine-primary-color-filled);
|
|
10
|
-
}
|
|
11
|
-
&:focus-within {
|
|
12
|
-
outline: none;
|
|
13
6
|
border-color: var(--mantine-primary-color-filled);
|
|
7
|
+
outline: none;
|
|
14
8
|
}
|
|
15
9
|
}
|
|
16
10
|
|
|
17
11
|
.rolder-prompt-input-textarea {
|
|
18
12
|
border: 0;
|
|
19
|
-
overflow: hidden;
|
|
20
13
|
border-radius: 8px;
|
|
14
|
+
overflow: hidden;
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
.rolder-prompt-input-file-action-action {
|
|
@@ -29,11 +23,7 @@
|
|
|
29
23
|
}
|
|
30
24
|
|
|
31
25
|
.rolder-editor-root {
|
|
32
|
-
--editor-border-color: light-dark(
|
|
33
|
-
var(--mantine-color-gray-3),
|
|
34
|
-
var(--mantine-color-dark-4)
|
|
35
|
-
);
|
|
36
|
-
|
|
26
|
+
--editor-border-color: light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
|
|
37
27
|
border: rem(1px) solid var(--editor-border-color);
|
|
38
28
|
border-radius: var(--mantine-radius-md);
|
|
39
29
|
}
|
|
@@ -49,15 +39,14 @@
|
|
|
49
39
|
}
|
|
50
40
|
|
|
51
41
|
.rolder-hover-paper-root {
|
|
52
|
-
transition: background-color
|
|
42
|
+
transition: background-color .2s ease-in-out;
|
|
43
|
+
|
|
53
44
|
&:hover {
|
|
54
|
-
background-color: light-dark(
|
|
55
|
-
var(--mantine-color-gray-0),
|
|
56
|
-
var(--mantine-color-dark-6)
|
|
57
|
-
);
|
|
58
|
-
transition: background-color 0.2s ease-in-out;
|
|
45
|
+
background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-6));
|
|
59
46
|
cursor: pointer;
|
|
47
|
+
transition: background-color .2s ease-in-out;
|
|
60
48
|
}
|
|
49
|
+
|
|
61
50
|
&[data-disabled] {
|
|
62
51
|
background-color: unset;
|
|
63
52
|
cursor: default;
|
|
@@ -65,8 +54,8 @@
|
|
|
65
54
|
}
|
|
66
55
|
|
|
67
56
|
.rolder-router-link-root {
|
|
68
|
-
text-decoration: none;
|
|
69
57
|
color: inherit;
|
|
58
|
+
text-decoration: none;
|
|
70
59
|
}
|
|
71
60
|
|
|
72
61
|
.rolder-scroll-area-viewport {
|
|
@@ -82,3 +71,4 @@
|
|
|
82
71
|
border-top-right-radius: var(--radius);
|
|
83
72
|
border-bottom-right-radius: var(--radius);
|
|
84
73
|
}
|
|
74
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CodecOptions, Surreal } from 'surrealdb';
|
|
2
|
+
export declare const getDB: (params?: {
|
|
3
|
+
url?: string;
|
|
4
|
+
namespace?: string;
|
|
5
|
+
database?: string;
|
|
6
|
+
username?: string;
|
|
7
|
+
password?: string;
|
|
8
|
+
codecOptions?: CodecOptions;
|
|
9
|
+
} | undefined) => Promise<Surreal>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createServerOnlyFn } from "@tanstack/react-start";
|
|
2
|
+
import { getCookie } from "@tanstack/react-start/server";
|
|
3
|
+
import { DateTime, Surreal } from "surrealdb";
|
|
4
|
+
let db = null;
|
|
5
|
+
const getDB = createServerOnlyFn(async (params = {})=>{
|
|
6
|
+
if (db?.isConnected) return db;
|
|
7
|
+
const locale = getCookie('locale') || 'ru-RU';
|
|
8
|
+
const timeZone = getCookie('tz') || 'UTC';
|
|
9
|
+
const instance = new Surreal({
|
|
10
|
+
codecOptions: params.codecOptions || {
|
|
11
|
+
valueDecodeVisitor (value) {
|
|
12
|
+
if (value instanceof DateTime) return new Date(value.toDate()).toLocaleDateString(locale, {
|
|
13
|
+
hour: 'numeric',
|
|
14
|
+
minute: 'numeric',
|
|
15
|
+
timeZone
|
|
16
|
+
});
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
try {
|
|
22
|
+
const url = params.url || process.env.SURREALDB_URL;
|
|
23
|
+
if (!url) throw new Error('Missing required SurrealDB URL');
|
|
24
|
+
const namespace = params.namespace || process.env.SURREALDB_NAMESPACE;
|
|
25
|
+
if (!namespace) throw new Error('Missing required SurrealDB namespace');
|
|
26
|
+
const database = params.database || process.env.SURREALDB_DATABASE;
|
|
27
|
+
if (!database) throw new Error('Missing required SurrealDB database');
|
|
28
|
+
const username = params.username || process.env.SURREALDB_USERNAME;
|
|
29
|
+
const password = params.password || process.env.SURREALDB_PASSWORD;
|
|
30
|
+
if (username && password) await instance.connect(url, {
|
|
31
|
+
authentication: {
|
|
32
|
+
username,
|
|
33
|
+
password
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
else await instance.connect(url);
|
|
37
|
+
await instance.use({
|
|
38
|
+
namespace,
|
|
39
|
+
database
|
|
40
|
+
});
|
|
41
|
+
db = instance;
|
|
42
|
+
return instance;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Failed to connect to SurrealDB:', error);
|
|
45
|
+
db = null;
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
export { getDB };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const surrealDeleteFn: import("@tanstack/start-client-core").RequiredFetcher<undefined, (data: string) => string, Promise<void>>;
|
|
2
|
+
export declare const surrealUnsubscribeFn: import("@tanstack/start-client-core").RequiredFetcher<undefined, (data: string) => string, Promise<void>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
2
|
+
import { getDB } from "./connection.js";
|
|
3
|
+
import { deserialize } from "./deserialize.js";
|
|
4
|
+
const surrealDeleteFn = createServerFn({
|
|
5
|
+
method: 'POST'
|
|
6
|
+
}).inputValidator((data)=>data).handler(async ({ data })=>{
|
|
7
|
+
const db = await getDB();
|
|
8
|
+
const id = deserialize(data);
|
|
9
|
+
await db.delete(id);
|
|
10
|
+
});
|
|
11
|
+
const surrealUnsubscribeFn = createServerFn({
|
|
12
|
+
method: 'POST'
|
|
13
|
+
}).inputValidator((data)=>data).handler(async ({ data })=>{
|
|
14
|
+
const db = await getDB();
|
|
15
|
+
const live = await db.liveOf(data);
|
|
16
|
+
await live.kill();
|
|
17
|
+
});
|
|
18
|
+
export { surrealDeleteFn, surrealUnsubscribeFn };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RecordId } from 'surrealdb';
|
|
2
|
+
/**
|
|
3
|
+
* Type that converts specified string paths to RecordId, others stay as their original types
|
|
4
|
+
*/
|
|
5
|
+
type DeserializeResult<T, IdPaths extends string = never> = T extends string ? RecordId<string> : T extends (infer U)[] ? U extends object ? {
|
|
6
|
+
[K in keyof U]: K extends IdPaths ? RecordId<string> : U[K];
|
|
7
|
+
}[] : DeserializeResult<U, IdPaths>[] : T extends object ? T extends Date ? T : {
|
|
8
|
+
[K in keyof T]: K extends IdPaths ? RecordId<string> : T[K];
|
|
9
|
+
} : T;
|
|
10
|
+
/**
|
|
11
|
+
* Deserializes DTO back to SurrealDB Record recursively based on specified ID paths
|
|
12
|
+
*/
|
|
13
|
+
export declare function deserialize<T, K extends keyof T & string>(dto: T[], idPaths: K[]): DeserializeResult<T, K>[];
|
|
14
|
+
export declare function deserialize<T, K extends keyof T & string>(dto: T, idPaths: K[]): DeserializeResult<T, K>;
|
|
15
|
+
export declare function deserialize<T>(dto: T[]): DeserializeResult<T>[];
|
|
16
|
+
export declare function deserialize<T>(dto: T): DeserializeResult<T>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { RecordId } from "surrealdb";
|
|
2
|
+
const extractTableName = (str)=>{
|
|
3
|
+
const match = str.match(/^([^:]+):/);
|
|
4
|
+
return match ? match[1] : null;
|
|
5
|
+
};
|
|
6
|
+
const isRecordIdFormat = (str)=>/^[^:]+:.+$/.test(str);
|
|
7
|
+
function deserialize(dto, idPaths) {
|
|
8
|
+
if (Array.isArray(dto)) return dto.map((item)=>convertStringsToRecordIds(item, idPaths || []));
|
|
9
|
+
return convertStringsToRecordIds(dto, idPaths || []);
|
|
10
|
+
}
|
|
11
|
+
const convertStringsToRecordIds = (obj, idPaths, currentPath = '')=>{
|
|
12
|
+
if (null == obj) return obj;
|
|
13
|
+
if (Array.isArray(obj)) {
|
|
14
|
+
if (idPaths.includes(currentPath)) return obj.map((item)=>{
|
|
15
|
+
if ('string' == typeof item && isRecordIdFormat(item)) {
|
|
16
|
+
const tableName = extractTableName(item);
|
|
17
|
+
if (tableName) return new RecordId(tableName, item.split(':')[1]);
|
|
18
|
+
}
|
|
19
|
+
return item;
|
|
20
|
+
});
|
|
21
|
+
return obj.map((item, index)=>convertStringsToRecordIds(item, idPaths, `${currentPath}[${index}]`));
|
|
22
|
+
}
|
|
23
|
+
if ('object' == typeof obj && !(obj instanceof Date)) {
|
|
24
|
+
const result = {};
|
|
25
|
+
for (const [key, value] of Object.entries(obj)){
|
|
26
|
+
const fieldPath = currentPath ? `${currentPath}.${key}` : key;
|
|
27
|
+
if ('string' == typeof value) {
|
|
28
|
+
const shouldConvert = idPaths.includes(fieldPath) && isRecordIdFormat(value);
|
|
29
|
+
if (shouldConvert) {
|
|
30
|
+
const tableName = extractTableName(value);
|
|
31
|
+
if (tableName) result[key] = new RecordId(tableName, value.split(':')[1]);
|
|
32
|
+
else result[key] = value;
|
|
33
|
+
} else result[key] = value;
|
|
34
|
+
} else result[key] = convertStringsToRecordIds(value, idPaths, fieldPath);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
if ('string' == typeof obj) {
|
|
39
|
+
if (0 === idPaths.length && isRecordIdFormat(obj)) {
|
|
40
|
+
const tableName = extractTableName(obj);
|
|
41
|
+
if (tableName) return new RecordId(tableName, obj.split(':')[1]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return obj;
|
|
45
|
+
};
|
|
46
|
+
export { deserialize };
|