@rolder/kit 3.0.0-alpha.8 → 3.0.0-alpha.80

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 (297) hide show
  1. package/dist/ai/index.d.ts +2 -0
  2. package/dist/ai/index.js +2 -0
  3. package/dist/ai/ui/chat/Empty.d.ts +1 -0
  4. package/dist/ai/ui/chat/Empty.js +21 -0
  5. package/dist/ai/ui/chat/File.d.ts +3 -0
  6. package/dist/ai/ui/chat/File.js +43 -0
  7. package/dist/ai/ui/chat/FileIcon.d.ts +3 -0
  8. package/dist/ai/ui/chat/FileIcon.js +43 -0
  9. package/dist/ai/ui/chat/Loader.d.ts +2 -0
  10. package/dist/ai/ui/chat/Loader.js +13 -0
  11. package/dist/ai/ui/chat/Message.d.ts +3 -0
  12. package/dist/ai/ui/chat/Message.js +23 -0
  13. package/dist/ai/ui/chat/Messages.d.ts +2 -0
  14. package/dist/ai/ui/chat/Messages.js +27 -0
  15. package/dist/ai/ui/chat/Root.d.ts +49 -0
  16. package/dist/ai/ui/chat/Root.js +18 -0
  17. package/dist/ai/ui/chat/chatInput/File.d.ts +2 -0
  18. package/dist/ai/ui/chat/chatInput/File.js +71 -0
  19. package/dist/ai/ui/chat/chatInput/FileIcon.d.ts +3 -0
  20. package/dist/ai/ui/chat/chatInput/FileIcon.js +43 -0
  21. package/dist/ai/ui/chat/chatInput/Footer.d.ts +2 -0
  22. package/dist/ai/ui/chat/chatInput/Footer.js +8 -0
  23. package/dist/ai/ui/chat/chatInput/Root.d.ts +9 -0
  24. package/dist/ai/ui/chat/chatInput/Root.js +24 -0
  25. package/dist/ai/ui/chat/chatInput/Submit.d.ts +2 -0
  26. package/dist/ai/ui/chat/chatInput/Submit.js +23 -0
  27. package/dist/ai/ui/chat/chatInput/Textarea.d.ts +2 -0
  28. package/dist/ai/ui/chat/chatInput/Textarea.js +34 -0
  29. package/dist/ai/ui/chat/chatInput/index.d.ts +7 -0
  30. package/dist/ai/ui/chat/chatInput/index.js +13 -0
  31. package/dist/ai/ui/chat/chatInput/store/file.d.ts +8 -0
  32. package/dist/ai/ui/chat/chatInput/store/file.js +32 -0
  33. package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.d.ts +2 -0
  34. package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.js +21 -0
  35. package/dist/ai/ui/chat/chatInput/store/index.d.ts +2 -0
  36. package/dist/ai/ui/chat/chatInput/store/index.js +2 -0
  37. package/dist/ai/ui/chat/chatInput/store/input.d.ts +13 -0
  38. package/dist/ai/ui/chat/chatInput/store/input.js +81 -0
  39. package/dist/ai/ui/chat/chatInput/store/parseFile.d.ts +2 -0
  40. package/dist/ai/ui/chat/chatInput/store/parseFile.js +23 -0
  41. package/dist/ai/ui/chat/index.d.ts +13 -0
  42. package/dist/ai/ui/chat/index.js +15 -0
  43. package/dist/ai/ui/chat/store/index.d.ts +5 -0
  44. package/dist/ai/ui/chat/store/index.js +5 -0
  45. package/dist/ai/ui/chat/store/messageIds.d.ts +8 -0
  46. package/dist/ai/ui/chat/store/messageIds.js +41 -0
  47. package/dist/ai/ui/chat/store/messagesMap.d.ts +5 -0
  48. package/dist/ai/ui/chat/store/messagesMap.js +15 -0
  49. package/dist/ai/ui/chat/store/send.d.ts +14 -0
  50. package/dist/ai/ui/chat/store/send.js +16 -0
  51. package/dist/ai/ui/chat/store/states.d.ts +11 -0
  52. package/dist/ai/ui/chat/store/states.js +17 -0
  53. package/dist/ai/ui/chat/store/useInitChat.d.ts +3 -0
  54. package/dist/ai/ui/chat/store/useInitChat.js +40 -0
  55. package/dist/ai/ui/index.d.ts +1 -0
  56. package/dist/ai/ui/index.js +1 -0
  57. package/dist/ai/utils/convertFileUIPartBlobToDataURL.d.ts +5 -0
  58. package/dist/ai/utils/convertFileUIPartBlobToDataURL.js +21 -0
  59. package/dist/ai/utils/index.d.ts +2 -0
  60. package/dist/ai/utils/index.js +2 -0
  61. package/dist/ai/utils/parseAiMessagePart.d.ts +2 -0
  62. package/dist/ai/utils/parseAiMessagePart.js +12 -0
  63. package/dist/app/AppDefaults.d.ts +3 -0
  64. package/dist/app/AppDefaults.js +27 -0
  65. package/dist/app/DefaultApp.d.ts +6 -0
  66. package/dist/app/DefaultApp.js +43 -0
  67. package/dist/app/cookieColorSchemeManager.d.ts +6 -0
  68. package/dist/app/cookieColorSchemeManager.js +46 -0
  69. package/dist/app/defaultRequestMiddlewares.d.ts +4 -0
  70. package/dist/app/defaultRequestMiddlewares.js +24 -0
  71. package/dist/app/defaultTheme.d.ts +141 -0
  72. package/dist/app/defaultTheme.js +24 -0
  73. package/dist/app/index.d.ts +4 -0
  74. package/dist/app/index.js +4 -0
  75. package/dist/hooks/index.d.ts +2 -0
  76. package/dist/hooks/index.js +2 -0
  77. package/dist/hooks/useMutation.d.ts +4 -0
  78. package/dist/hooks/useMutation.js +8 -0
  79. package/dist/hooks/useMutationWithInvalidate.d.ts +4 -0
  80. package/dist/hooks/useMutationWithInvalidate.js +16 -0
  81. package/dist/index.d.ts +5 -0
  82. package/dist/index.js +5 -0
  83. package/{src → dist}/styles.css +14 -29
  84. package/dist/tanstackFunctions/cookie/getCookie.d.ts +3 -0
  85. package/dist/tanstackFunctions/cookie/getCookie.js +8 -0
  86. package/dist/tanstackFunctions/cookie/index.d.ts +3 -0
  87. package/dist/tanstackFunctions/cookie/index.js +4 -0
  88. package/dist/tanstackFunctions/cookie/setCookie.d.ts +10 -0
  89. package/dist/tanstackFunctions/cookie/setCookie.js +19 -0
  90. package/dist/tanstackFunctions/cookie/setCookies.d.ts +14 -0
  91. package/dist/tanstackFunctions/cookie/setCookies.js +13 -0
  92. package/dist/tanstackFunctions/index.d.ts +3 -0
  93. package/dist/tanstackFunctions/index.js +3 -0
  94. package/dist/tanstackFunctions/s3/getS3Client.d.ts +2 -0
  95. package/dist/tanstackFunctions/s3/getS3Client.js +18 -0
  96. package/dist/tanstackFunctions/s3/getSignedFileUrlFn.d.ts +4 -0
  97. package/dist/tanstackFunctions/s3/getSignedFileUrlFn.js +21 -0
  98. package/dist/tanstackFunctions/s3/index.d.ts +2 -0
  99. package/dist/tanstackFunctions/s3/index.js +2 -0
  100. package/dist/tanstackFunctions/s3/uploadRequest.d.ts +3 -0
  101. package/dist/tanstackFunctions/s3/uploadRequest.js +21 -0
  102. package/dist/tanstackFunctions/surreal/connection.d.ts +9 -0
  103. package/dist/tanstackFunctions/surreal/connection.js +49 -0
  104. package/dist/tanstackFunctions/surreal/deafaultCrud.d.ts +2 -0
  105. package/dist/tanstackFunctions/surreal/deafaultCrud.js +18 -0
  106. package/dist/tanstackFunctions/surreal/deserialize.d.ts +17 -0
  107. package/dist/tanstackFunctions/surreal/deserialize.js +46 -0
  108. package/dist/tanstackFunctions/surreal/encryption.d.ts +6 -0
  109. package/dist/tanstackFunctions/surreal/encryption.js +30 -0
  110. package/dist/tanstackFunctions/surreal/index.d.ts +4 -0
  111. package/dist/tanstackFunctions/surreal/index.js +4 -0
  112. package/dist/ui/AnimatedChevron.d.ts +6 -0
  113. package/dist/ui/AnimatedChevron.js +13 -0
  114. package/dist/ui/JsonInput.d.ts +2 -0
  115. package/dist/ui/JsonInput.js +45 -0
  116. package/dist/ui/RouterLink.d.ts +16 -0
  117. package/dist/ui/RouterLink.js +36 -0
  118. package/dist/ui/editor/Content.d.ts +3 -0
  119. package/dist/ui/editor/Content.js +13 -0
  120. package/dist/ui/editor/Root.d.ts +8 -0
  121. package/dist/ui/editor/Root.js +55 -0
  122. package/dist/ui/editor/Toolbar.d.ts +5 -0
  123. package/dist/ui/editor/Toolbar.js +138 -0
  124. package/dist/ui/editor/index.d.ts +11 -0
  125. package/dist/ui/editor/index.js +10 -0
  126. package/dist/ui/editor/store.d.ts +6 -0
  127. package/dist/ui/editor/store.js +10 -0
  128. package/dist/ui/error/DefaultError.d.ts +2 -0
  129. package/dist/ui/error/DefaultError.js +62 -0
  130. package/dist/ui/error/DefaultNotFound.d.ts +1 -0
  131. package/dist/ui/error/DefaultNotFound.js +37 -0
  132. package/dist/ui/error/Forbidden.d.ts +1 -0
  133. package/dist/ui/error/Forbidden.js +32 -0
  134. package/dist/ui/error/defaultErrorNotification.d.ts +1 -0
  135. package/dist/ui/error/defaultErrorNotification.js +8 -0
  136. package/dist/ui/error/index.js +5 -0
  137. package/dist/ui/form/blurOnError.d.ts +4 -0
  138. package/dist/ui/form/blurOnError.js +11 -0
  139. package/dist/ui/form/buttons/CancelButton.d.ts +5 -0
  140. package/dist/ui/form/buttons/CancelButton.js +22 -0
  141. package/dist/ui/form/buttons/SubmitButton.d.ts +5 -0
  142. package/dist/ui/form/buttons/SubmitButton.js +22 -0
  143. package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +4 -0
  144. package/dist/ui/form/buttons/SubscribeActionIcon.js +15 -0
  145. package/dist/ui/form/buttons/SubscribeButton.d.ts +5 -0
  146. package/dist/ui/form/buttons/SubscribeButton.js +16 -0
  147. package/dist/ui/form/buttons/index.js +4 -0
  148. package/dist/ui/form/context.d.ts +83 -0
  149. package/dist/ui/form/context.js +26 -0
  150. package/dist/ui/form/fields/JsonField.d.ts +2 -0
  151. package/dist/ui/form/fields/JsonField.js +13 -0
  152. package/dist/ui/form/fields/MultiSelectField.d.ts +2 -0
  153. package/dist/ui/form/fields/MultiSelectField.js +15 -0
  154. package/dist/ui/form/fields/NumberField.d.ts +2 -0
  155. package/dist/ui/form/fields/NumberField.js +15 -0
  156. package/dist/ui/form/fields/PassowrdField.d.ts +2 -0
  157. package/dist/ui/form/fields/PassowrdField.js +18 -0
  158. package/dist/ui/form/fields/SelectField.d.ts +2 -0
  159. package/dist/ui/form/fields/SelectField.js +15 -0
  160. package/dist/ui/form/fields/SwitchField.d.ts +2 -0
  161. package/dist/ui/form/fields/SwitchField.js +15 -0
  162. package/dist/ui/form/fields/TextField.d.ts +2 -0
  163. package/dist/ui/form/fields/TextField.js +15 -0
  164. package/dist/ui/form/fields/TextPassowrdField.d.ts +2 -0
  165. package/dist/ui/form/fields/TextPassowrdField.js +29 -0
  166. package/dist/ui/form/fields/TextareaField.d.ts +2 -0
  167. package/dist/ui/form/fields/TextareaField.js +15 -0
  168. package/dist/ui/form/fields/index.js +9 -0
  169. package/dist/ui/form/fieldsSchema.d.ts +12 -0
  170. package/dist/ui/form/fieldsSchema.js +13 -0
  171. package/dist/ui/form/index.js +4 -0
  172. package/dist/ui/hoverPaper/HoverPaper.d.ts +6 -0
  173. package/dist/ui/hoverPaper/HoverPaper.js +15 -0
  174. package/dist/ui/hoverPaper/index.js +3 -0
  175. package/dist/ui/hoverPaper/usePaperHover.d.ts +4 -0
  176. package/dist/ui/hoverPaper/usePaperHover.js +9 -0
  177. package/dist/ui/index.d.ts +9 -0
  178. package/dist/ui/index.js +9 -0
  179. package/dist/ui/saveInput/JsonInput.d.ts +6 -0
  180. package/dist/ui/saveInput/JsonInput.js +34 -0
  181. package/dist/ui/saveInput/NumberInput.d.ts +6 -0
  182. package/dist/ui/saveInput/NumberInput.js +27 -0
  183. package/dist/ui/saveInput/SaveInput.d.ts +36 -0
  184. package/dist/ui/saveInput/SaveInput.js +15 -0
  185. package/dist/ui/saveInput/Select.d.ts +6 -0
  186. package/dist/ui/saveInput/Select.js +27 -0
  187. package/dist/ui/saveInput/Switch.d.ts +6 -0
  188. package/dist/ui/saveInput/Switch.js +30 -0
  189. package/dist/ui/saveInput/TextInput.d.ts +6 -0
  190. package/dist/ui/saveInput/TextInput.js +26 -0
  191. package/dist/ui/saveInput/Textarea.d.ts +6 -0
  192. package/dist/ui/saveInput/Textarea.js +26 -0
  193. package/dist/ui/saveInput/index.js +2 -0
  194. package/dist/ui/scrollArea/Root.d.ts +7 -0
  195. package/dist/ui/scrollArea/Root.js +42 -0
  196. package/dist/ui/scrollArea/ScrollButton.d.ts +10 -0
  197. package/dist/ui/scrollArea/ScrollButton.js +30 -0
  198. package/dist/ui/scrollArea/index.d.ts +6 -0
  199. package/dist/ui/scrollArea/index.js +7 -0
  200. package/dist/ui/scrollArea/methods.d.ts +4 -0
  201. package/dist/ui/scrollArea/methods.js +32 -0
  202. package/dist/ui/scrollArea/store.d.ts +12 -0
  203. package/dist/ui/scrollArea/store.js +25 -0
  204. package/package.json +40 -28
  205. package/rslib.config.ts +0 -21
  206. package/src/ai/ui/conversation/ConversationContext.ts +0 -21
  207. package/src/ai/ui/conversation/ConversationProvider.tsx +0 -21
  208. package/src/ai/ui/conversation/Empty.tsx +0 -15
  209. package/src/ai/ui/conversation/File.tsx +0 -40
  210. package/src/ai/ui/conversation/FileIcon.tsx +0 -143
  211. package/src/ai/ui/conversation/Loader.tsx +0 -8
  212. package/src/ai/ui/conversation/Message.tsx +0 -34
  213. package/src/ai/ui/conversation/Root.tsx +0 -24
  214. package/src/ai/ui/conversation/index.ts +0 -16
  215. package/src/ai/ui/conversation/types.ts +0 -8
  216. package/src/ai/ui/conversation/useChatMessage.ts +0 -13
  217. package/src/ai/ui/promptInput/File.tsx +0 -98
  218. package/src/ai/ui/promptInput/FileIcon.tsx +0 -149
  219. package/src/ai/ui/promptInput/Footer.tsx +0 -5
  220. package/src/ai/ui/promptInput/PromptInputContext.ts +0 -24
  221. package/src/ai/ui/promptInput/PromptInputProvider.tsx +0 -54
  222. package/src/ai/ui/promptInput/Root.tsx +0 -29
  223. package/src/ai/ui/promptInput/Submit.tsx +0 -39
  224. package/src/ai/ui/promptInput/Textarea.tsx +0 -39
  225. package/src/ai/ui/promptInput/index.ts +0 -15
  226. package/src/ai/ui/promptInput/types.ts +0 -9
  227. package/src/ai/utils/convertFileUIPartBlobToDataURL.ts +0 -29
  228. package/src/ai/utils/parseAiMessagePart.ts +0 -19
  229. package/src/app/AppDefaults.tsx +0 -21
  230. package/src/app/DefaultApp.tsx +0 -50
  231. package/src/app/cookieColorSchemeManager.ts +0 -70
  232. package/src/app/defaultRequestMiddlewares.ts +0 -22
  233. package/src/app/defaultTheme.ts +0 -22
  234. package/src/functions/getCookie.ts +0 -36
  235. package/src/functions/setCookie.ts +0 -29
  236. package/src/functions/setCookies.ts +0 -24
  237. package/src/hooks/useMutation.ts +0 -14
  238. package/src/hooks/useMutationWithInvalidate.ts +0 -23
  239. package/src/index.ts +0 -66
  240. package/src/surreal/connection.ts +0 -72
  241. package/src/surreal/deafaultCrud.ts +0 -25
  242. package/src/surreal/deserialize.ts +0 -144
  243. package/src/surreal/encryption.ts +0 -51
  244. package/src/ui/AnimatedChevron.tsx +0 -32
  245. package/src/ui/JsonInput.tsx +0 -52
  246. package/src/ui/RouterLink.tsx +0 -78
  247. package/src/ui/editor/Content.tsx +0 -11
  248. package/src/ui/editor/Provider.tsx +0 -96
  249. package/src/ui/editor/Root.tsx +0 -25
  250. package/src/ui/editor/Toolbar.tsx +0 -92
  251. package/src/ui/editor/index.ts +0 -13
  252. package/src/ui/editor/types.ts +0 -7
  253. package/src/ui/error/DefaultError.tsx +0 -60
  254. package/src/ui/error/DefaultNotFound.tsx +0 -19
  255. package/src/ui/error/Forbidden.tsx +0 -18
  256. package/src/ui/error/defaultErrorNotification.ts +0 -9
  257. package/src/ui/form/blurOnError.ts +0 -21
  258. package/src/ui/form/buttons/CancelButton.tsx +0 -42
  259. package/src/ui/form/buttons/SubmitButton.tsx +0 -43
  260. package/src/ui/form/buttons/SubscribeActionIcon.tsx +0 -18
  261. package/src/ui/form/buttons/SubscribeButton.tsx +0 -17
  262. package/src/ui/form/context.ts +0 -45
  263. package/src/ui/form/fields/JsonField.tsx +0 -16
  264. package/src/ui/form/fields/MultiSelectField.tsx +0 -17
  265. package/src/ui/form/fields/NumberField.tsx +0 -17
  266. package/src/ui/form/fields/PassowrdField.tsx +0 -20
  267. package/src/ui/form/fields/SelectField.tsx +0 -17
  268. package/src/ui/form/fields/SwitchField.tsx +0 -17
  269. package/src/ui/form/fields/TextField.tsx +0 -17
  270. package/src/ui/form/fields/TextPassowrdField.tsx +0 -51
  271. package/src/ui/form/fields/TextareaField.tsx +0 -17
  272. package/src/ui/form/fieldsSchema.ts +0 -24
  273. package/src/ui/hoverPaper/HoverPaper.tsx +0 -17
  274. package/src/ui/hoverPaper/usePaperHover.ts +0 -9
  275. package/src/ui/saveInput/JsonInput.tsx +0 -40
  276. package/src/ui/saveInput/NumberInput.tsx +0 -40
  277. package/src/ui/saveInput/SaveInput.tsx +0 -15
  278. package/src/ui/saveInput/Select.tsx +0 -41
  279. package/src/ui/saveInput/Switch.tsx +0 -46
  280. package/src/ui/saveInput/TextInput.tsx +0 -40
  281. package/src/ui/saveInput/Textarea.tsx +0 -40
  282. package/src/ui/scrollArea/ARCH.md +0 -204
  283. package/src/ui/scrollArea/README.md +0 -369
  284. package/src/ui/scrollArea/ScrollArea.tsx +0 -93
  285. package/src/ui/scrollArea/ScrollAreaButton.tsx +0 -56
  286. package/src/ui/scrollArea/ScrollAreaContent.tsx +0 -36
  287. package/src/ui/scrollArea/context.tsx +0 -43
  288. package/src/ui/scrollArea/index.ts +0 -10
  289. package/src/ui/scrollArea/types.ts +0 -77
  290. package/src/ui/scrollArea/useScrollArea.ts +0 -227
  291. package/tsconfig.json +0 -14
  292. /package/{src/ui/error/index.ts → dist/ui/error/index.d.ts} +0 -0
  293. /package/{src/ui/form/buttons/index.ts → dist/ui/form/buttons/index.d.ts} +0 -0
  294. /package/{src/ui/form/fields/index.ts → dist/ui/form/fields/index.d.ts} +0 -0
  295. /package/{src/ui/form/index.ts → dist/ui/form/index.d.ts} +0 -0
  296. /package/{src/ui/hoverPaper/index.ts → dist/ui/hoverPaper/index.d.ts} +0 -0
  297. /package/{src/ui/saveInput/index.ts → dist/ui/saveInput/index.d.ts} +0 -0
@@ -1,144 +0,0 @@
1
- import { RecordId } from 'surrealdb';
2
-
3
- /**
4
- * Type that converts specified string paths to RecordId, others stay as their original types
5
- */
6
- type DeserializeResult<T, IdPaths extends string = never> = T extends string
7
- ? RecordId<string> // Plain strings always become RecordId when no paths or when it's root level
8
- : T extends (infer U)[]
9
- ? U extends object
10
- ? {
11
- [K in keyof U]: K extends IdPaths ? RecordId<string> : U[K];
12
- }[]
13
- : DeserializeResult<U, IdPaths>[]
14
- : T extends object
15
- ? T extends Date
16
- ? T
17
- : {
18
- [K in keyof T]: K extends IdPaths ? RecordId<string> : T[K]; // Keep original types for non-ID fields
19
- }
20
- : T;
21
-
22
- /**
23
- * Extract table name from "table:id" format string
24
- */
25
- const extractTableName = (str: string): string | null => {
26
- const match = str.match(/^([^:]+):/);
27
- return match ? match[1] : null;
28
- };
29
-
30
- /**
31
- * Check if string is in "table:id" format
32
- */
33
- const isRecordIdFormat = (str: string): boolean => {
34
- return /^[^:]+:.+$/.test(str);
35
- };
36
-
37
- /**
38
- * Deserializes DTO back to SurrealDB Record recursively based on specified ID paths
39
- */
40
- // Overload for arrays with ID paths
41
- export function deserialize<T, K extends keyof T & string>(
42
- dto: T[],
43
- idPaths: K[],
44
- ): DeserializeResult<T, K>[];
45
- // Overload for single objects with ID paths
46
- export function deserialize<T, K extends keyof T & string>(
47
- dto: T,
48
- idPaths: K[],
49
- ): DeserializeResult<T, K>;
50
- // Overload for arrays without ID paths (treats all strings as potential IDs)
51
- export function deserialize<T>(dto: T[]): DeserializeResult<T>[];
52
- // Overload for single objects without ID paths (treats all strings as potential IDs)
53
- export function deserialize<T>(dto: T): DeserializeResult<T>;
54
-
55
- // Implementation
56
- export function deserialize<T, K extends keyof T & string = never>(
57
- dto: T | T[],
58
- idPaths?: K[],
59
- ): DeserializeResult<T, K> | DeserializeResult<T, K>[] {
60
- if (Array.isArray(dto)) {
61
- return dto.map((item) =>
62
- convertStringsToRecordIds(item, idPaths || []),
63
- ) as DeserializeResult<T, K>[];
64
- }
65
-
66
- return convertStringsToRecordIds(dto, idPaths || []) as DeserializeResult<
67
- T,
68
- K
69
- >;
70
- }
71
-
72
- /**
73
- * Recursively converts string IDs back to RecordId instances based on specified paths
74
- */
75
- const convertStringsToRecordIds = (
76
- obj: unknown,
77
- idPaths: string[],
78
- currentPath = '',
79
- ): unknown => {
80
- if (obj === null || obj === undefined) {
81
- return obj;
82
- }
83
-
84
- // If it's an array, check if the current path matches any idPath
85
- if (Array.isArray(obj)) {
86
- // If this array's path is in idPaths, convert all string elements to RecordIds
87
- if (idPaths.includes(currentPath)) {
88
- return obj.map((item) => {
89
- if (typeof item === 'string' && isRecordIdFormat(item)) {
90
- const tableName = extractTableName(item);
91
- if (tableName) {
92
- return new RecordId(tableName, item.split(':')[1]);
93
- }
94
- }
95
- return item;
96
- });
97
- }
98
- // Otherwise, recursively process each element with indexed path
99
- return obj.map((item, index) =>
100
- convertStringsToRecordIds(item, idPaths, `${currentPath}[${index}]`),
101
- );
102
- }
103
-
104
- // If it's an object, recursively process each property
105
- if (typeof obj === 'object' && !(obj instanceof Date)) {
106
- const result: Record<string, unknown> = {};
107
- for (const [key, value] of Object.entries(obj)) {
108
- const fieldPath = currentPath ? `${currentPath}.${key}` : key;
109
-
110
- if (typeof value === 'string') {
111
- // Only convert if this field path is explicitly in idPaths
112
- const shouldConvert =
113
- idPaths.includes(fieldPath) && isRecordIdFormat(value);
114
-
115
- if (shouldConvert) {
116
- const tableName = extractTableName(value);
117
- if (tableName) {
118
- result[key] = new RecordId(tableName, value.split(':')[1]);
119
- } else {
120
- result[key] = value;
121
- }
122
- } else {
123
- result[key] = value;
124
- }
125
- } else {
126
- result[key] = convertStringsToRecordIds(value, idPaths, fieldPath);
127
- }
128
- }
129
- return result;
130
- }
131
-
132
- // For strings at root level (not in objects) - only convert if no idPaths specified
133
- if (typeof obj === 'string') {
134
- if (idPaths.length === 0 && isRecordIdFormat(obj)) {
135
- const tableName = extractTableName(obj);
136
- if (tableName) {
137
- return new RecordId(tableName, obj.split(':')[1]);
138
- }
139
- }
140
- }
141
-
142
- // For primitive types, return as is
143
- return obj;
144
- };
@@ -1,51 +0,0 @@
1
- import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';
2
- import { createServerOnlyFn } from '@tanstack/react-start';
3
-
4
- type EncryptionInstance = {
5
- encrypt(text: string): string;
6
- decrypt(encryptedText: string): string;
7
- };
8
-
9
- export const encryptionFn = createServerOnlyFn(
10
- (secretHash: string): EncryptionInstance => {
11
- class Encryption {
12
- private key: Buffer;
13
-
14
- constructor(secretHash: string) {
15
- // Создаем 32-байтный ключ из 64-символьного hex хеша
16
- this.key = Buffer.from(secretHash, 'hex');
17
- }
18
-
19
- // Функция для шифрования
20
- encrypt(text: string): string {
21
- const algorithm = 'aes-256-cbc';
22
- const iv = randomBytes(16);
23
-
24
- const cipher = createCipheriv(algorithm, this.key, iv);
25
- let encrypted = cipher.update(text, 'utf8', 'hex');
26
- encrypted += cipher.final('hex');
27
-
28
- // Возвращаем IV + зашифрованные данные
29
- return `${iv.toString('hex')}:${encrypted}`;
30
- }
31
-
32
- // Функция для дешифрования
33
- decrypt(encryptedText: string): string {
34
- const algorithm = 'aes-256-cbc';
35
-
36
- // Разделяем IV и зашифрованные данные
37
- const parts = encryptedText.split(':');
38
- const iv = Buffer.from(parts[0], 'hex');
39
- const encrypted = parts[1];
40
-
41
- const decipher = createDecipheriv(algorithm, this.key, iv);
42
- let decrypted = decipher.update(encrypted, 'hex', 'utf8');
43
- decrypted += decipher.final('utf8');
44
-
45
- return decrypted;
46
- }
47
- }
48
-
49
- return new Encryption(secretHash);
50
- },
51
- );
@@ -1,32 +0,0 @@
1
- import type { SVGProps } from 'react';
2
-
3
- interface Props extends SVGProps<SVGSVGElement> {
4
- expanded?: boolean;
5
- }
6
-
7
- export const AnimatedChevron = ({ expanded, style, ...props }: Props) => {
8
- return (
9
- <svg
10
- xmlns="http://www.w3.org/2000/svg"
11
- width="24"
12
- height="24"
13
- viewBox="0 0 24 24"
14
- fill="none"
15
- stroke="currentColor"
16
- strokeWidth="1.5"
17
- strokeLinecap="round"
18
- strokeLinejoin="round"
19
- role="img"
20
- aria-label="Chevron"
21
- style={{
22
- transition: 'transform 0.2s ease-in-out',
23
- transform: expanded ? 'rotate(-180deg)' : 'rotate(0deg)',
24
- ...style,
25
- }}
26
- {...props}
27
- >
28
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
29
- <path d="M6 9l6 6l6 -6" />
30
- </svg>
31
- );
32
- };
@@ -1,52 +0,0 @@
1
- import { indentSelection } from '@codemirror/commands';
2
- import { json, jsonParseLinter } from '@codemirror/lang-json';
3
- import { linter } from '@codemirror/lint';
4
- import { type EditorView, keymap } from '@codemirror/view';
5
- import { vscodeDark, vscodeLight } from '@uiw/codemirror-theme-vscode';
6
- import CodeMirror, { type ReactCodeMirrorProps } from '@uiw/react-codemirror';
7
- import { getCookie } from '../functions/getCookie';
8
-
9
- const formatJson = (view: EditorView) => {
10
- try {
11
- const text = view.state.doc.toString();
12
- const parsed = JSON.parse(text);
13
- const formatted = JSON.stringify(parsed, null, 2);
14
-
15
- view.dispatch({
16
- changes: {
17
- from: 0,
18
- to: view.state.doc.length,
19
- insert: formatted,
20
- },
21
- });
22
-
23
- return true;
24
- } catch (_) {
25
- // Если JSON невалидный, пробуем просто отступы
26
- return indentSelection(view);
27
- }
28
- };
29
-
30
- const extensions = [
31
- json(),
32
- linter(jsonParseLinter()),
33
- keymap.of([
34
- {
35
- key: 'Mod-Shift-f',
36
- run: formatJson,
37
- },
38
- ]),
39
- ];
40
-
41
- export const JsonInput = (props: ReactCodeMirrorProps) => {
42
- const colorScheme = getCookie('colorScheme');
43
-
44
- return (
45
- <CodeMirror
46
- height="280px"
47
- theme={colorScheme === 'light' ? vscodeLight : vscodeDark}
48
- extensions={extensions}
49
- {...props}
50
- />
51
- );
52
- };
@@ -1,78 +0,0 @@
1
- import {
2
- ActionIcon,
3
- type ActionIconProps,
4
- Anchor,
5
- type AnchorProps,
6
- Button,
7
- type ButtonProps,
8
- UnstyledButton,
9
- type UnstyledButtonProps,
10
- } from '@mantine/core';
11
- import { createLink, type LinkComponent } from '@tanstack/react-router';
12
- import { forwardRef } from 'react';
13
-
14
- interface MantineAnchorProps extends Omit<AnchorProps, 'href'> {}
15
- interface MantineButtonProps extends Omit<ButtonProps, 'href'> {}
16
- interface MantineActionIconProps extends Omit<ActionIconProps, 'href'> {}
17
- interface MantineUnstyledButtonProps
18
- extends Omit<UnstyledButtonProps, 'href'> {}
19
-
20
- // Базовый компонент Anchor
21
- const MantineLinkComponent = forwardRef<HTMLAnchorElement, MantineAnchorProps>(
22
- ({ classNames, ...props }, ref) => {
23
- return (
24
- <Anchor
25
- ref={ref}
26
- classNames={{ root: 'rolder-router-link-root', ...classNames }}
27
- c="inherit"
28
- underline="never"
29
- {...props}
30
- />
31
- );
32
- },
33
- );
34
-
35
- // Компонент Button - передаем все пропсы кроме href
36
- const MantineButtonComponent = forwardRef<
37
- HTMLButtonElement,
38
- MantineButtonProps
39
- >((props, ref) => {
40
- return <Button ref={ref} {...props} />;
41
- });
42
-
43
- // Компонент ActionIcon - передаем все пропсы кроме href
44
- const MantineActionIconComponent = forwardRef<
45
- HTMLButtonElement,
46
- MantineActionIconProps
47
- >((props, ref) => {
48
- return <ActionIcon ref={ref} {...props} />;
49
- });
50
-
51
- // Компонент UnstyledButton - передаем все пропсы кроме href
52
- const MantineUnstyledButtonComponent = forwardRef<
53
- HTMLButtonElement,
54
- MantineUnstyledButtonProps
55
- >((props, ref) => {
56
- return <UnstyledButton ref={ref} {...props} />;
57
- });
58
-
59
- // Создаем RouterLink для каждого компонента
60
- const RouterLinkBase: LinkComponent<typeof MantineLinkComponent> =
61
- createLink(MantineLinkComponent);
62
-
63
- const RouterLinkButton: LinkComponent<typeof MantineButtonComponent> =
64
- createLink(MantineButtonComponent);
65
-
66
- const RouterLinkActionIcon: LinkComponent<typeof MantineActionIconComponent> =
67
- createLink(MantineActionIconComponent);
68
-
69
- const RouterLinkUnstyledButton: LinkComponent<
70
- typeof MantineUnstyledButtonComponent
71
- > = createLink(MantineUnstyledButtonComponent);
72
-
73
- // Экспортируем с namespace pattern
74
- export const RouterLink = Object.assign(RouterLinkBase, {
75
- Button: RouterLinkButton,
76
- ActionIcon: RouterLinkActionIcon,
77
- UnstyledButton: RouterLinkUnstyledButton,
78
- });
@@ -1,11 +0,0 @@
1
- import { RichTextEditor } from '@mantine/tiptap';
2
- import { ScrollArea } from '../scrollArea';
3
-
4
- export const Content = ({ height }: { height: string }) => {
5
- return (
6
- <ScrollArea h={height} autoScroll radius="md">
7
- <RichTextEditor.Content />
8
- <ScrollArea.ScrollButton />
9
- </ScrollArea>
10
- );
11
- };
@@ -1,96 +0,0 @@
1
- import { getTaskListExtension, Link } from '@mantine/tiptap';
2
- import Highlight from '@tiptap/extension-highlight';
3
- import Placeholder from '@tiptap/extension-placeholder';
4
- import { TableKit } from '@tiptap/extension-table';
5
- import TaskItem from '@tiptap/extension-task-item';
6
- import TipTapTaskList from '@tiptap/extension-task-list';
7
- import TextAlign from '@tiptap/extension-text-align';
8
- import type { Editor } from '@tiptap/react';
9
- import { useEditor as useTipTapEditor } from '@tiptap/react';
10
- import StarterKit from '@tiptap/starter-kit';
11
- import { createContext, useContext, useEffect, useState } from 'react';
12
- import type { EditorProps } from './types';
13
-
14
- interface EditorContext {
15
- editor: Editor | null;
16
- editable?: boolean;
17
- setEditable: (value: boolean) => void;
18
- disabledToolbar: boolean;
19
- setDisabledToolbar: (value: boolean) => void;
20
- focused: boolean;
21
- setFocused: (value: boolean) => void;
22
- editedByUser: boolean;
23
- setEditedByUser: (value: boolean) => void;
24
- }
25
-
26
- const EditorContext = createContext<EditorContext | null>(null);
27
-
28
- export const Provider = ({
29
- children,
30
- initialContent,
31
- initialEditable = true,
32
- initialDisabledToolbar,
33
- onChange,
34
- }: EditorProps) => {
35
- const editor = useTipTapEditor({
36
- shouldRerenderOnTransaction: false,
37
- immediatelyRender: false,
38
- extensions: [
39
- StarterKit.configure({ link: false }),
40
- Placeholder.configure({ placeholder: 'Документ пуст' }),
41
- Link,
42
- Highlight,
43
- TextAlign.configure({ types: ['heading', 'paragraph'] }),
44
- getTaskListExtension(TipTapTaskList),
45
- TaskItem.configure({ nested: true }),
46
- TableKit,
47
- ],
48
- content: initialContent,
49
- onUpdate: ({ editor }) => {
50
- onChange?.(editor.getHTML());
51
- },
52
- editable: initialEditable,
53
- });
54
-
55
- const [editable, setEditable] = useState(initialEditable);
56
- const [disabledToolbar, setDisabledToolbar] = useState(
57
- !!initialDisabledToolbar,
58
- );
59
-
60
- const [editedByUser, setEditedByUser] = useState(true);
61
- const [focused, setFocused] = useState(false);
62
-
63
- useEffect(() => {
64
- editor?.on('focus', () => setFocused(true));
65
- editor?.on('blur', () => setFocused(false));
66
- editor?.on('update', ({ transaction }) => {
67
- if (transaction.docChanged && focused) setEditedByUser(true);
68
- if (transaction.docChanged && !focused) setEditedByUser(false);
69
- });
70
- }, [editor, focused]);
71
-
72
- const value: EditorContext = {
73
- editor,
74
- editable,
75
- setEditable,
76
- disabledToolbar,
77
- setDisabledToolbar,
78
- editedByUser,
79
- setEditedByUser,
80
- focused,
81
- setFocused,
82
- };
83
-
84
- return (
85
- <EditorContext.Provider value={value}>{children}</EditorContext.Provider>
86
- );
87
- };
88
-
89
- export const useEditor = () => {
90
- const context = useContext(EditorContext);
91
- if (!context) {
92
- throw new Error('useEditor must be used within EditorProvider');
93
- }
94
-
95
- return context;
96
- };
@@ -1,25 +0,0 @@
1
- import { RichTextEditor, type RichTextEditorProps } from '@mantine/tiptap';
2
- import { useEditor } from './Provider';
3
-
4
- export const Root = ({
5
- children,
6
- classNames,
7
- ...props
8
- }: Omit<RichTextEditorProps, 'editor'>) => {
9
- const { editor } = useEditor();
10
-
11
- return (
12
- <RichTextEditor
13
- editor={editor}
14
- classNames={{
15
- root: 'rolder-editor-root',
16
- content: 'rolder-editor-content',
17
- toolbar: 'rolder-editor-toolbar',
18
- ...classNames,
19
- }}
20
- {...props}
21
- >
22
- {children}
23
- </RichTextEditor>
24
- );
25
- };
@@ -1,92 +0,0 @@
1
- import { Loader } from '@mantine/core';
2
- import { RichTextEditor } from '@mantine/tiptap';
3
- import type { ReactNode } from 'react';
4
- import { useEditor } from './Provider';
5
-
6
- export const Toolbar = ({
7
- saving,
8
- children,
9
- }: {
10
- saving?: boolean;
11
- children?: ReactNode;
12
- }) => {
13
- const { editor, disabledToolbar } = useEditor();
14
-
15
- return !disabledToolbar ? (
16
- <RichTextEditor.Toolbar sticky>
17
- <RichTextEditor.ControlsGroup>
18
- <RichTextEditor.Bold disabled={!editor?.isEditable} />
19
- <RichTextEditor.Italic disabled={!editor?.isEditable} />
20
- <RichTextEditor.Underline disabled={!editor?.isEditable} />
21
- <RichTextEditor.Strikethrough disabled={!editor?.isEditable} />
22
- <RichTextEditor.ClearFormatting disabled={!editor?.isEditable} />
23
- <RichTextEditor.Highlight disabled={!editor?.isEditable} />
24
- <RichTextEditor.Code disabled={!editor?.isEditable} />
25
- </RichTextEditor.ControlsGroup>
26
-
27
- <RichTextEditor.ControlsGroup>
28
- <RichTextEditor.H1 disabled={!editor?.isEditable} />
29
- <RichTextEditor.H2 disabled={!editor?.isEditable} />
30
- <RichTextEditor.H3 disabled={!editor?.isEditable} />
31
- <RichTextEditor.H4 disabled={!editor?.isEditable} />
32
- </RichTextEditor.ControlsGroup>
33
-
34
- <RichTextEditor.ControlsGroup>
35
- <RichTextEditor.Blockquote disabled={!editor?.isEditable} />
36
- <RichTextEditor.Hr disabled={!editor?.isEditable} />
37
- <RichTextEditor.BulletList disabled={!editor?.isEditable} />
38
- <RichTextEditor.OrderedList disabled={!editor?.isEditable} />
39
- </RichTextEditor.ControlsGroup>
40
-
41
- <RichTextEditor.ControlsGroup>
42
- <RichTextEditor.TaskList disabled={!editor?.isEditable} />
43
- <RichTextEditor.TaskListLift disabled={!editor?.isEditable} />
44
- <RichTextEditor.TaskListSink disabled={!editor?.isEditable} />
45
- </RichTextEditor.ControlsGroup>
46
-
47
- <RichTextEditor.ControlsGroup>
48
- <RichTextEditor.Link disabled={!editor?.isEditable} />
49
- <RichTextEditor.Unlink disabled={!editor?.isEditable} />
50
- </RichTextEditor.ControlsGroup>
51
-
52
- <RichTextEditor.ControlsGroup>
53
- <RichTextEditor.AlignLeft disabled={!editor?.isEditable} />
54
- <RichTextEditor.AlignCenter disabled={!editor?.isEditable} />
55
- <RichTextEditor.AlignJustify disabled={!editor?.isEditable} />
56
- <RichTextEditor.AlignRight disabled={!editor?.isEditable} />
57
- </RichTextEditor.ControlsGroup>
58
-
59
- <RichTextEditor.ControlsGroup>
60
- <RichTextEditor.Undo disabled={!editor?.isEditable} />
61
- <RichTextEditor.Redo disabled={!editor?.isEditable} />
62
- </RichTextEditor.ControlsGroup>
63
-
64
- <RichTextEditor.ControlsGroup ml="auto">
65
- {children}
66
-
67
- <RichTextEditor.Control ml="10px" style={{ cursor: 'default' }}>
68
- {saving ? (
69
- <Loader size={14} />
70
- ) : (
71
- <svg
72
- xmlns="http://www.w3.org/2000/svg"
73
- width="16"
74
- height="16"
75
- viewBox="0 0 16 16"
76
- fill="none"
77
- stroke="currentColor"
78
- strokeWidth="1.5"
79
- strokeLinecap="round"
80
- strokeLinejoin="round"
81
- role="img"
82
- aria-label="Saved"
83
- >
84
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
85
- <path d="M5 12l5 5l10 -10" />
86
- </svg>
87
- )}
88
- </RichTextEditor.Control>
89
- </RichTextEditor.ControlsGroup>
90
- </RichTextEditor.Toolbar>
91
- ) : null;
92
- };
@@ -1,13 +0,0 @@
1
- import { Content } from './Content';
2
- import { Provider } from './Provider';
3
- import { Root } from './Root';
4
- import { Toolbar } from './Toolbar';
5
-
6
- export const Editor = {
7
- Root,
8
- Content,
9
- Toolbar,
10
- Provider,
11
- };
12
-
13
- export { useEditor } from './Provider';
@@ -1,7 +0,0 @@
1
- export interface EditorProps {
2
- children: React.ReactNode;
3
- initialContent?: string;
4
- initialEditable?: boolean;
5
- initialDisabledToolbar?: boolean;
6
- onChange?: (value: string) => void;
7
- }
@@ -1,60 +0,0 @@
1
- import { Button, Group, Stack, Title } from '@mantine/core';
2
- import type { ErrorComponentProps } from '@tanstack/react-router';
3
- import { rootRouteId, useMatch, useRouter } from '@tanstack/react-router';
4
- import { RouterLink } from '../RouterLink';
5
-
6
- export const DefaultError = ({ error }: ErrorComponentProps) => {
7
- const router = useRouter();
8
- const isRoot = useMatch({
9
- strict: false,
10
- select: (state) => state.id === rootRouteId,
11
- });
12
-
13
- return (
14
- <Stack align="center" justify="center" gap={0} ta="center" h="100vh">
15
- <Title textWrap="balance" size={65}>
16
- Произошла ошибка!
17
- </Title>
18
- {error.message && (
19
- <Title
20
- order={3}
21
- ml={4}
22
- textWrap="balance"
23
- c="var(--mantine-color-error)"
24
- >
25
- {error.message}
26
- </Title>
27
- )}
28
-
29
- <Group>
30
- <Button
31
- mt="xl"
32
- size="lg"
33
- variant="light"
34
- onClick={() => {
35
- router.invalidate();
36
- }}
37
- >
38
- Попробовать еще раз
39
- </Button>
40
- {isRoot ? (
41
- <RouterLink.Button to="/" mt="xl" size="lg" radius="md">
42
- На главную
43
- </RouterLink.Button>
44
- ) : (
45
- <Button
46
- mt="xl"
47
- radius="md"
48
- size="lg"
49
- onClick={(e) => {
50
- e.preventDefault();
51
- router.history.back();
52
- }}
53
- >
54
- Назад
55
- </Button>
56
- )}
57
- </Group>
58
- </Stack>
59
- );
60
- };
@@ -1,19 +0,0 @@
1
- import { Stack, Text, Title } from '@mantine/core';
2
- import { RouterLink } from '../RouterLink';
3
-
4
- export const DefaultNotFound = () => (
5
- <Stack align="center" justify="center" gap={0} ta="center" h="100vh">
6
- <Text c="dimmed" fw="bold">
7
- 404
8
- </Text>
9
- <Title textWrap="balance" size={65}>
10
- Страница не найдена
11
- </Title>
12
- <Title order={3} ml={4} textWrap="balance" c="dimmed">
13
- Извините, но здесь нет страницы. Возможно она перемещена.
14
- </Title>
15
- <RouterLink.Button to="/" mt="xl" size="lg" radius="md">
16
- На главную
17
- </RouterLink.Button>
18
- </Stack>
19
- );