@manta-eu/react 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (592) hide show
  1. package/README.md +59 -0
  2. package/dist/components/AppErrorBoundary.d.ts.map +1 -1
  3. package/dist/components/AppErrorBoundary.js +14 -11
  4. package/dist/components/AppErrorBoundary.js.map +1 -1
  5. package/dist/components/app-gate/AppGate.d.ts +8 -0
  6. package/dist/components/app-gate/AppGate.d.ts.map +1 -0
  7. package/dist/components/app-gate/AppGate.js +68 -0
  8. package/dist/components/app-gate/AppGate.js.map +1 -0
  9. package/dist/components/app-gate/AwaitingDatastoreStatus.d.ts +7 -0
  10. package/dist/components/app-gate/AwaitingDatastoreStatus.d.ts.map +1 -0
  11. package/dist/components/app-gate/AwaitingDatastoreStatus.js +19 -0
  12. package/dist/components/app-gate/AwaitingDatastoreStatus.js.map +1 -0
  13. package/dist/components/app-gate/EnterDatastoreRoute.d.ts +2 -0
  14. package/dist/components/app-gate/EnterDatastoreRoute.d.ts.map +1 -0
  15. package/dist/components/app-gate/EnterDatastoreRoute.js +25 -0
  16. package/dist/components/app-gate/EnterDatastoreRoute.js.map +1 -0
  17. package/dist/components/app-gate/ErrorRoute.d.ts +2 -0
  18. package/dist/components/app-gate/ErrorRoute.d.ts.map +1 -0
  19. package/dist/components/app-gate/ErrorRoute.js +27 -0
  20. package/dist/components/app-gate/ErrorRoute.js.map +1 -0
  21. package/dist/components/app-gate/FailureAlert.d.ts +5 -0
  22. package/dist/components/app-gate/FailureAlert.d.ts.map +1 -0
  23. package/dist/components/app-gate/FailureAlert.js +9 -0
  24. package/dist/components/app-gate/FailureAlert.js.map +1 -0
  25. package/dist/components/app-gate/NoDatastoreAccess.d.ts +8 -0
  26. package/dist/components/app-gate/NoDatastoreAccess.d.ts.map +1 -0
  27. package/dist/components/app-gate/NoDatastoreAccess.js +9 -0
  28. package/dist/components/app-gate/NoDatastoreAccess.js.map +1 -0
  29. package/dist/components/app-gate/NotFoundRoute.d.ts +2 -0
  30. package/dist/components/app-gate/NotFoundRoute.d.ts.map +1 -0
  31. package/dist/components/app-gate/NotFoundRoute.js +9 -0
  32. package/dist/components/app-gate/NotFoundRoute.js.map +1 -0
  33. package/dist/components/app-gate/PendingInvitations.d.ts +5 -0
  34. package/dist/components/app-gate/PendingInvitations.d.ts.map +1 -0
  35. package/dist/components/app-gate/PendingInvitations.js +58 -0
  36. package/dist/components/app-gate/PendingInvitations.js.map +1 -0
  37. package/dist/components/app-gate/ServiceError.d.ts +8 -0
  38. package/dist/components/app-gate/ServiceError.d.ts.map +1 -0
  39. package/dist/components/app-gate/ServiceError.js +10 -0
  40. package/dist/components/app-gate/ServiceError.js.map +1 -0
  41. package/dist/components/app-gate/index.d.ts +3 -0
  42. package/dist/components/app-gate/index.d.ts.map +1 -0
  43. package/dist/components/app-gate/index.js +3 -0
  44. package/dist/components/app-gate/index.js.map +1 -0
  45. package/dist/components/app-gate/sdk-route-elements.d.ts +23 -0
  46. package/dist/components/app-gate/sdk-route-elements.d.ts.map +1 -0
  47. package/dist/components/app-gate/sdk-route-elements.js +35 -0
  48. package/dist/components/app-gate/sdk-route-elements.js.map +1 -0
  49. package/dist/components/app-shell/AppShell.d.ts +7 -0
  50. package/dist/components/app-shell/AppShell.d.ts.map +1 -0
  51. package/dist/components/app-shell/AppShell.js +10 -0
  52. package/dist/components/app-shell/AppShell.js.map +1 -0
  53. package/dist/components/app-shell/AppShellRoutes.d.ts +9 -0
  54. package/dist/components/app-shell/AppShellRoutes.d.ts.map +1 -0
  55. package/dist/components/app-shell/AppShellRoutes.js +20 -0
  56. package/dist/components/app-shell/AppShellRoutes.js.map +1 -0
  57. package/dist/components/app-shell/GroupDatastores.d.ts +8 -0
  58. package/dist/components/app-shell/GroupDatastores.d.ts.map +1 -0
  59. package/dist/components/app-shell/GroupDatastores.js +15 -0
  60. package/dist/components/app-shell/GroupDatastores.js.map +1 -0
  61. package/dist/components/app-shell/GroupRoute.d.ts +2 -0
  62. package/dist/components/app-shell/GroupRoute.d.ts.map +1 -0
  63. package/dist/components/app-shell/GroupRoute.js +22 -0
  64. package/dist/components/app-shell/GroupRoute.js.map +1 -0
  65. package/dist/components/app-shell/index.d.ts +3 -0
  66. package/dist/components/app-shell/index.d.ts.map +1 -0
  67. package/dist/components/app-shell/index.js +3 -0
  68. package/dist/components/app-shell/index.js.map +1 -0
  69. package/dist/components/authenticated-chat/index.d.ts +1 -2
  70. package/dist/components/authenticated-chat/index.d.ts.map +1 -1
  71. package/dist/components/authenticated-chat/index.js +1 -12
  72. package/dist/components/authenticated-chat/index.js.map +1 -1
  73. package/dist/components/chat-view/Chat.d.ts +2 -1
  74. package/dist/components/chat-view/Chat.d.ts.map +1 -1
  75. package/dist/components/chat-view/Chat.js +3 -2
  76. package/dist/components/chat-view/Chat.js.map +1 -1
  77. package/dist/components/chat-view/MessageItem.d.ts.map +1 -1
  78. package/dist/components/chat-view/MessageItem.js +4 -2
  79. package/dist/components/chat-view/MessageItem.js.map +1 -1
  80. package/dist/components/chat-view/tool-part-rendering.d.ts +1 -0
  81. package/dist/components/chat-view/tool-part-rendering.d.ts.map +1 -1
  82. package/dist/components/chat-view/tool-part-rendering.js +8 -1
  83. package/dist/components/chat-view/tool-part-rendering.js.map +1 -1
  84. package/dist/components/chip/index.d.ts +1 -0
  85. package/dist/components/chip/index.d.ts.map +1 -1
  86. package/dist/components/chip/index.js +2 -1
  87. package/dist/components/chip/index.js.map +1 -1
  88. package/dist/components/embedded-chat/index.d.ts +1 -1
  89. package/dist/components/embedded-chat/index.d.ts.map +1 -1
  90. package/dist/components/embedded-chat/index.js +1 -1
  91. package/dist/components/embedded-chat/index.js.map +1 -1
  92. package/dist/components/input/input-date-time.d.ts +6 -0
  93. package/dist/components/input/input-date-time.d.ts.map +1 -1
  94. package/dist/components/input/input-date-time.js +2 -1
  95. package/dist/components/input/input-date-time.js.map +1 -1
  96. package/dist/components/input/input-date.d.ts +22 -0
  97. package/dist/components/input/input-date.d.ts.map +1 -1
  98. package/dist/components/input/input-date.js +28 -14
  99. package/dist/components/input/input-date.js.map +1 -1
  100. package/dist/components/input/input-time.d.ts +9 -0
  101. package/dist/components/input/input-time.d.ts.map +1 -1
  102. package/dist/components/input/input-time.js +29 -18
  103. package/dist/components/input/input-time.js.map +1 -1
  104. package/dist/components/layouts/RouteLayout.d.ts +0 -9
  105. package/dist/components/layouts/RouteLayout.d.ts.map +1 -1
  106. package/dist/components/layouts/RouteLayout.js +7 -4
  107. package/dist/components/layouts/RouteLayout.js.map +1 -1
  108. package/dist/components/layouts/Sidebar.d.ts +1 -8
  109. package/dist/components/layouts/Sidebar.d.ts.map +1 -1
  110. package/dist/components/layouts/Sidebar.js +7 -14
  111. package/dist/components/layouts/Sidebar.js.map +1 -1
  112. package/dist/components/plan-limits/PlanLimitsDialog.d.ts +20 -0
  113. package/dist/components/plan-limits/PlanLimitsDialog.d.ts.map +1 -0
  114. package/dist/components/plan-limits/PlanLimitsDialog.js +109 -0
  115. package/dist/components/plan-limits/PlanLimitsDialog.js.map +1 -0
  116. package/dist/components/plan-limits/index.d.ts +4 -0
  117. package/dist/components/plan-limits/index.d.ts.map +1 -0
  118. package/dist/components/plan-limits/index.js +2 -0
  119. package/dist/components/plan-limits/index.js.map +1 -0
  120. package/dist/components/plan-limits/plan-limits-client.d.ts +15 -0
  121. package/dist/components/plan-limits/plan-limits-client.d.ts.map +1 -0
  122. package/dist/components/plan-limits/plan-limits-client.js +44 -0
  123. package/dist/components/plan-limits/plan-limits-client.js.map +1 -0
  124. package/dist/components/plan-limits/plan-limits-model.d.ts +66 -0
  125. package/dist/components/plan-limits/plan-limits-model.d.ts.map +1 -0
  126. package/dist/components/plan-limits/plan-limits-model.js +123 -0
  127. package/dist/components/plan-limits/plan-limits-model.js.map +1 -0
  128. package/dist/components/plan-limits/plan-limits-save.d.ts +31 -0
  129. package/dist/components/plan-limits/plan-limits-save.d.ts.map +1 -0
  130. package/dist/components/plan-limits/plan-limits-save.js +43 -0
  131. package/dist/components/plan-limits/plan-limits-save.js.map +1 -0
  132. package/dist/components/planning/PlanLimitsAction.d.ts +6 -0
  133. package/dist/components/planning/PlanLimitsAction.d.ts.map +1 -0
  134. package/dist/components/planning/PlanLimitsAction.js +19 -0
  135. package/dist/components/planning/PlanLimitsAction.js.map +1 -0
  136. package/dist/components/slider/index.d.ts.map +1 -1
  137. package/dist/components/slider/index.js +2 -1
  138. package/dist/components/slider/index.js.map +1 -1
  139. package/dist/datastore-picker/datastore-picker-rows.d.ts +7 -0
  140. package/dist/datastore-picker/datastore-picker-rows.d.ts.map +1 -1
  141. package/dist/datastore-picker/datastore-picker-rows.js +26 -22
  142. package/dist/datastore-picker/datastore-picker-rows.js.map +1 -1
  143. package/dist/globals.css +85 -2
  144. package/dist/hooks/use-action-plans-list.d.ts +3 -0
  145. package/dist/hooks/use-action-plans-list.d.ts.map +1 -1
  146. package/dist/hooks/use-action-plans-list.js +8 -9
  147. package/dist/hooks/use-action-plans-list.js.map +1 -1
  148. package/dist/hooks/use-activity-feed.d.ts +10 -1
  149. package/dist/hooks/use-activity-feed.d.ts.map +1 -1
  150. package/dist/hooks/use-activity-feed.js +9 -11
  151. package/dist/hooks/use-activity-feed.js.map +1 -1
  152. package/dist/hooks/use-entity.d.ts +4 -3
  153. package/dist/hooks/use-entity.d.ts.map +1 -1
  154. package/dist/hooks/use-entity.js +4 -4
  155. package/dist/hooks/use-entity.js.map +1 -1
  156. package/dist/hooks/use-manual-actions.d.ts +1 -1
  157. package/dist/hooks/use-manual-actions.d.ts.map +1 -1
  158. package/dist/hooks/use-manual-actions.js +5 -5
  159. package/dist/hooks/use-manual-actions.js.map +1 -1
  160. package/dist/hooks/use-unsaved-changes-warning.d.ts +2 -0
  161. package/dist/hooks/use-unsaved-changes-warning.d.ts.map +1 -0
  162. package/dist/hooks/use-unsaved-changes-warning.js +13 -0
  163. package/dist/hooks/use-unsaved-changes-warning.js.map +1 -0
  164. package/dist/hooks/useAuth.d.ts.map +1 -1
  165. package/dist/hooks/useAuth.js +4 -3
  166. package/dist/hooks/useAuth.js.map +1 -1
  167. package/dist/hooks/useChatPanelSync.d.ts.map +1 -1
  168. package/dist/hooks/useChatPanelSync.js +2 -3
  169. package/dist/hooks/useChatPanelSync.js.map +1 -1
  170. package/dist/hooks/useDatastoreSelection.d.ts.map +1 -1
  171. package/dist/hooks/useDatastoreSelection.js +11 -4
  172. package/dist/hooks/useDatastoreSelection.js.map +1 -1
  173. package/dist/hooks/useExecuteAction.d.ts +1 -0
  174. package/dist/hooks/useExecuteAction.d.ts.map +1 -1
  175. package/dist/hooks/useExecuteAction.js.map +1 -1
  176. package/dist/hooks/useLoginRedirect.d.ts +6 -0
  177. package/dist/hooks/useLoginRedirect.d.ts.map +1 -0
  178. package/dist/hooks/useLoginRedirect.js +51 -0
  179. package/dist/hooks/useLoginRedirect.js.map +1 -0
  180. package/dist/hooks/usePlanLimits.d.ts +18 -0
  181. package/dist/hooks/usePlanLimits.d.ts.map +1 -0
  182. package/dist/hooks/usePlanLimits.js +56 -0
  183. package/dist/hooks/usePlanLimits.js.map +1 -0
  184. package/dist/ldo-ui.d.ts +1 -1
  185. package/dist/ldo-ui.d.ts.map +1 -1
  186. package/dist/ldo-ui.js.map +1 -1
  187. package/dist/lib/app-tools.d.ts +18 -0
  188. package/dist/lib/app-tools.d.ts.map +1 -0
  189. package/dist/lib/app-tools.js +42 -0
  190. package/dist/lib/app-tools.js.map +1 -0
  191. package/dist/lib/chat-types.d.ts +3 -0
  192. package/dist/lib/chat-types.d.ts.map +1 -1
  193. package/dist/lib/chat-types.js.map +1 -1
  194. package/dist/lib/datastore-route-table.d.ts +3 -0
  195. package/dist/lib/datastore-route-table.d.ts.map +1 -1
  196. package/dist/lib/datastore-route-table.js +6 -0
  197. package/dist/lib/datastore-route-table.js.map +1 -1
  198. package/dist/lib/graphql-error.d.ts +2 -0
  199. package/dist/lib/graphql-error.d.ts.map +1 -0
  200. package/dist/lib/graphql-error.js +7 -0
  201. package/dist/lib/graphql-error.js.map +1 -0
  202. package/dist/lib/update-notice.d.ts +2 -1
  203. package/dist/lib/update-notice.d.ts.map +1 -1
  204. package/dist/lib/update-notice.js +8 -2
  205. package/dist/lib/update-notice.js.map +1 -1
  206. package/dist/providers/ActiveChatProvider.d.ts +2 -0
  207. package/dist/providers/ActiveChatProvider.d.ts.map +1 -1
  208. package/dist/providers/ActiveChatProvider.js +6 -3
  209. package/dist/providers/ActiveChatProvider.js.map +1 -1
  210. package/dist/providers/ActiveDatastoreProvider.d.ts +12 -0
  211. package/dist/providers/ActiveDatastoreProvider.d.ts.map +1 -1
  212. package/dist/providers/ActiveDatastoreProvider.js +114 -11
  213. package/dist/providers/ActiveDatastoreProvider.js.map +1 -1
  214. package/dist/providers/AuthContext.d.ts +1 -0
  215. package/dist/providers/AuthContext.d.ts.map +1 -1
  216. package/dist/providers/AuthContext.js.map +1 -1
  217. package/dist/providers/KnowledgeGraphStateContext.d.ts +2 -2
  218. package/dist/providers/KnowledgeGraphStateContext.d.ts.map +1 -1
  219. package/dist/providers/KnowledgeGraphStateProvider.d.ts.map +1 -1
  220. package/dist/providers/KnowledgeGraphStateProvider.js +8 -49
  221. package/dist/providers/KnowledgeGraphStateProvider.js.map +1 -1
  222. package/dist/providers/MantaClientProvider.d.ts.map +1 -1
  223. package/dist/providers/MantaClientProvider.js +3 -3
  224. package/dist/providers/MantaClientProvider.js.map +1 -1
  225. package/dist/providers/index.d.ts +3 -1
  226. package/dist/providers/index.d.ts.map +1 -1
  227. package/dist/providers/index.js +2 -2
  228. package/dist/providers/index.js.map +1 -1
  229. package/dist/routes/activity/detail/ActivityDetailRoute.d.ts.map +1 -1
  230. package/dist/routes/activity/detail/ActivityDetailRoute.js +1 -3
  231. package/dist/routes/activity/detail/ActivityDetailRoute.js.map +1 -1
  232. package/dist/routes/activity/index.d.ts.map +1 -1
  233. package/dist/routes/activity/index.js +1 -3
  234. package/dist/routes/activity/index.js.map +1 -1
  235. package/dist/routes/chat/index.d.ts +2 -21
  236. package/dist/routes/chat/index.d.ts.map +1 -1
  237. package/dist/routes/chat/index.js +4 -2
  238. package/dist/routes/chat/index.js.map +1 -1
  239. package/dist/routes/data-collection/index.d.ts.map +1 -1
  240. package/dist/routes/data-collection/index.js +1 -3
  241. package/dist/routes/data-collection/index.js.map +1 -1
  242. package/dist/routes/data-explorer/components/DataExplorerLayout.d.ts.map +1 -1
  243. package/dist/routes/data-explorer/components/DataExplorerLayout.js +1 -3
  244. package/dist/routes/data-explorer/components/DataExplorerLayout.js.map +1 -1
  245. package/dist/routes/data-explorer/components/class-detail/UsedByRules.js +2 -2
  246. package/dist/routes/data-explorer/components/class-detail/UsedByRules.js.map +1 -1
  247. package/dist/routes/datastores/index.d.ts.map +1 -1
  248. package/dist/routes/datastores/index.js +2 -2
  249. package/dist/routes/datastores/index.js.map +1 -1
  250. package/dist/routes/explain/index.d.ts.map +1 -1
  251. package/dist/routes/explain/index.js +1 -3
  252. package/dist/routes/explain/index.js.map +1 -1
  253. package/dist/routes/integrations/components/connect-forms/DashConnectForm.d.ts.map +1 -1
  254. package/dist/routes/integrations/components/connect-forms/DashConnectForm.js +0 -1
  255. package/dist/routes/integrations/components/connect-forms/DashConnectForm.js.map +1 -1
  256. package/dist/routes/integrations/components/connect-forms/GoogleAdsConnectForm.d.ts.map +1 -1
  257. package/dist/routes/integrations/components/connect-forms/GoogleAdsConnectForm.js +0 -1
  258. package/dist/routes/integrations/components/connect-forms/GoogleAdsConnectForm.js.map +1 -1
  259. package/dist/routes/integrations/components/connect-forms/GoogleAnalyticsConnectForm.d.ts.map +1 -1
  260. package/dist/routes/integrations/components/connect-forms/GoogleAnalyticsConnectForm.js +0 -1
  261. package/dist/routes/integrations/components/connect-forms/GoogleAnalyticsConnectForm.js.map +1 -1
  262. package/dist/routes/integrations/components/connect-forms/GoogleMerchantCenterConnectForm.d.ts.map +1 -1
  263. package/dist/routes/integrations/components/connect-forms/GoogleMerchantCenterConnectForm.js +0 -1
  264. package/dist/routes/integrations/components/connect-forms/GoogleMerchantCenterConnectForm.js.map +1 -1
  265. package/dist/routes/integrations/components/connect-forms/InferalCredentialConnectForm.d.ts +0 -1
  266. package/dist/routes/integrations/components/connect-forms/InferalCredentialConnectForm.d.ts.map +1 -1
  267. package/dist/routes/integrations/components/connect-forms/InferalCredentialConnectForm.js +3 -2
  268. package/dist/routes/integrations/components/connect-forms/InferalCredentialConnectForm.js.map +1 -1
  269. package/dist/routes/integrations/components/connect-forms/KlaviyoConnectForm.d.ts.map +1 -1
  270. package/dist/routes/integrations/components/connect-forms/KlaviyoConnectForm.js +0 -1
  271. package/dist/routes/integrations/components/connect-forms/KlaviyoConnectForm.js.map +1 -1
  272. package/dist/routes/integrations/components/connect-forms/MicrosoftAdsConnectForm.d.ts.map +1 -1
  273. package/dist/routes/integrations/components/connect-forms/MicrosoftAdsConnectForm.js +0 -1
  274. package/dist/routes/integrations/components/connect-forms/MicrosoftAdsConnectForm.js.map +1 -1
  275. package/dist/routes/integrations/components/connect-forms/OAuthSetupConnectForm.d.ts +0 -1
  276. package/dist/routes/integrations/components/connect-forms/OAuthSetupConnectForm.d.ts.map +1 -1
  277. package/dist/routes/integrations/components/connect-forms/OAuthSetupConnectForm.js +4 -3
  278. package/dist/routes/integrations/components/connect-forms/OAuthSetupConnectForm.js.map +1 -1
  279. package/dist/routes/integrations/components/connect-forms/TriplewhaleConnectForm.d.ts.map +1 -1
  280. package/dist/routes/integrations/components/connect-forms/TriplewhaleConnectForm.js +0 -1
  281. package/dist/routes/integrations/components/connect-forms/TriplewhaleConnectForm.js.map +1 -1
  282. package/dist/routes/integrations/components/connect-forms/WoocommerceConnectForm.d.ts.map +1 -1
  283. package/dist/routes/integrations/components/connect-forms/WoocommerceConnectForm.js +0 -1
  284. package/dist/routes/integrations/components/connect-forms/WoocommerceConnectForm.js.map +1 -1
  285. package/dist/routes/integrations/types.d.ts +2 -1
  286. package/dist/routes/integrations/types.d.ts.map +1 -1
  287. package/dist/routes/integrations/types.js +16 -0
  288. package/dist/routes/integrations/types.js.map +1 -1
  289. package/dist/routes/memories/components/DateValueInput.d.ts +16 -0
  290. package/dist/routes/memories/components/DateValueInput.d.ts.map +1 -0
  291. package/dist/routes/memories/components/DateValueInput.js +35 -0
  292. package/dist/routes/memories/components/DateValueInput.js.map +1 -0
  293. package/dist/routes/memories/components/EntityValuePicker.d.ts +11 -0
  294. package/dist/routes/memories/components/EntityValuePicker.d.ts.map +1 -0
  295. package/dist/routes/memories/components/EntityValuePicker.js +61 -0
  296. package/dist/routes/memories/components/EntityValuePicker.js.map +1 -0
  297. package/dist/routes/memories/components/FieldLabel.d.ts +12 -0
  298. package/dist/routes/memories/components/FieldLabel.d.ts.map +1 -0
  299. package/dist/routes/memories/components/FieldLabel.js +12 -0
  300. package/dist/routes/memories/components/FieldLabel.js.map +1 -0
  301. package/dist/routes/memories/components/ImportanceSlider.d.ts +2 -0
  302. package/dist/routes/memories/components/ImportanceSlider.d.ts.map +1 -1
  303. package/dist/routes/memories/components/ImportanceSlider.js +4 -1
  304. package/dist/routes/memories/components/ImportanceSlider.js.map +1 -1
  305. package/dist/routes/memories/components/MemoriesFilters.d.ts +2 -2
  306. package/dist/routes/memories/components/MemoriesFilters.d.ts.map +1 -1
  307. package/dist/routes/memories/components/MemoriesFilters.js.map +1 -1
  308. package/dist/routes/memories/components/MemoriesPanel.d.ts.map +1 -1
  309. package/dist/routes/memories/components/MemoriesPanel.js +4 -0
  310. package/dist/routes/memories/components/MemoriesPanel.js.map +1 -1
  311. package/dist/routes/memories/components/MemoriesTabPanel.d.ts +2 -2
  312. package/dist/routes/memories/components/MemoriesTabPanel.d.ts.map +1 -1
  313. package/dist/routes/memories/components/MemoryActions.d.ts +2 -0
  314. package/dist/routes/memories/components/MemoryActions.d.ts.map +1 -1
  315. package/dist/routes/memories/components/MemoryActions.js +3 -3
  316. package/dist/routes/memories/components/MemoryActions.js.map +1 -1
  317. package/dist/routes/memories/components/MemoryFields.d.ts +15 -3
  318. package/dist/routes/memories/components/MemoryFields.d.ts.map +1 -1
  319. package/dist/routes/memories/components/MemoryFields.js +34 -5
  320. package/dist/routes/memories/components/MemoryFields.js.map +1 -1
  321. package/dist/routes/memories/components/MemoryFormDialog.d.ts +6 -3
  322. package/dist/routes/memories/components/MemoryFormDialog.d.ts.map +1 -1
  323. package/dist/routes/memories/components/MemoryFormDialog.js +105 -59
  324. package/dist/routes/memories/components/MemoryFormDialog.js.map +1 -1
  325. package/dist/routes/memories/components/MemoryPropertyFields.d.ts +10 -0
  326. package/dist/routes/memories/components/MemoryPropertyFields.d.ts.map +1 -0
  327. package/dist/routes/memories/components/MemoryPropertyFields.js +67 -0
  328. package/dist/routes/memories/components/MemoryPropertyFields.js.map +1 -0
  329. package/dist/routes/memories/components/RuleDraftDialog.d.ts +7 -0
  330. package/dist/routes/memories/components/RuleDraftDialog.d.ts.map +1 -0
  331. package/dist/routes/memories/components/RuleDraftDialog.js +20 -0
  332. package/dist/routes/memories/components/RuleDraftDialog.js.map +1 -0
  333. package/dist/routes/memories/components/SchemasTab.d.ts +17 -2
  334. package/dist/routes/memories/components/SchemasTab.d.ts.map +1 -1
  335. package/dist/routes/memories/components/SchemasTab.js +146 -28
  336. package/dist/routes/memories/components/SchemasTab.js.map +1 -1
  337. package/dist/routes/memories/components/badges.d.ts +7 -0
  338. package/dist/routes/memories/components/badges.d.ts.map +1 -1
  339. package/dist/routes/memories/components/badges.js +11 -3
  340. package/dist/routes/memories/components/badges.js.map +1 -1
  341. package/dist/routes/memories/hooks/useMemoryColumns.d.ts +4 -2
  342. package/dist/routes/memories/hooks/useMemoryColumns.d.ts.map +1 -1
  343. package/dist/routes/memories/hooks/useMemoryColumns.js +31 -15
  344. package/dist/routes/memories/hooks/useMemoryColumns.js.map +1 -1
  345. package/dist/routes/memories/index.d.ts +2 -1
  346. package/dist/routes/memories/index.d.ts.map +1 -1
  347. package/dist/routes/memories/index.js +72 -30
  348. package/dist/routes/memories/index.js.map +1 -1
  349. package/dist/routes/memories/memory-mutation-input.d.ts.map +1 -1
  350. package/dist/routes/memories/memory-mutation-input.js +5 -2
  351. package/dist/routes/memories/memory-mutation-input.js.map +1 -1
  352. package/dist/routes/memories/memory-property-values.d.ts +13 -0
  353. package/dist/routes/memories/memory-property-values.d.ts.map +1 -0
  354. package/dist/routes/memories/memory-property-values.js +40 -0
  355. package/dist/routes/memories/memory-property-values.js.map +1 -0
  356. package/dist/routes/memories/schemas/AllowedValuesField.d.ts +14 -0
  357. package/dist/routes/memories/schemas/AllowedValuesField.d.ts.map +1 -0
  358. package/dist/routes/memories/schemas/AllowedValuesField.js +64 -0
  359. package/dist/routes/memories/schemas/AllowedValuesField.js.map +1 -0
  360. package/dist/routes/memories/schemas/MemorySchemaPage.d.ts +127 -0
  361. package/dist/routes/memories/schemas/MemorySchemaPage.d.ts.map +1 -0
  362. package/dist/routes/memories/schemas/MemorySchemaPage.js +285 -0
  363. package/dist/routes/memories/schemas/MemorySchemaPage.js.map +1 -0
  364. package/dist/routes/memories/schemas/SchemaChangeReviewDialog.d.ts +20 -0
  365. package/dist/routes/memories/schemas/SchemaChangeReviewDialog.d.ts.map +1 -0
  366. package/dist/routes/memories/schemas/SchemaChangeReviewDialog.js +54 -0
  367. package/dist/routes/memories/schemas/SchemaChangeReviewDialog.js.map +1 -0
  368. package/dist/routes/memories/schemas/SchemaConfirmDialog.d.ts +15 -0
  369. package/dist/routes/memories/schemas/SchemaConfirmDialog.d.ts.map +1 -0
  370. package/dist/routes/memories/schemas/SchemaConfirmDialog.js +8 -0
  371. package/dist/routes/memories/schemas/SchemaConfirmDialog.js.map +1 -0
  372. package/dist/routes/memories/schemas/SchemaDetailPage.d.ts +15 -0
  373. package/dist/routes/memories/schemas/SchemaDetailPage.d.ts.map +1 -0
  374. package/dist/routes/memories/schemas/SchemaDetailPage.js +74 -0
  375. package/dist/routes/memories/schemas/SchemaDetailPage.js.map +1 -0
  376. package/dist/routes/memories/schemas/SchemaEditorForm.d.ts +10 -0
  377. package/dist/routes/memories/schemas/SchemaEditorForm.d.ts.map +1 -0
  378. package/dist/routes/memories/schemas/SchemaEditorForm.js +242 -0
  379. package/dist/routes/memories/schemas/SchemaEditorForm.js.map +1 -0
  380. package/dist/routes/memories/schemas/SchemaTemplatesDialog.d.ts +13 -0
  381. package/dist/routes/memories/schemas/SchemaTemplatesDialog.d.ts.map +1 -0
  382. package/dist/routes/memories/schemas/SchemaTemplatesDialog.js +13 -0
  383. package/dist/routes/memories/schemas/SchemaTemplatesDialog.js.map +1 -0
  384. package/dist/routes/memories/schemas/ValueTypeSelect.d.ts +12 -0
  385. package/dist/routes/memories/schemas/ValueTypeSelect.d.ts.map +1 -0
  386. package/dist/routes/memories/schemas/ValueTypeSelect.js +10 -0
  387. package/dist/routes/memories/schemas/ValueTypeSelect.js.map +1 -0
  388. package/dist/routes/memories/schemas/schema-form.d.ts +72 -0
  389. package/dist/routes/memories/schemas/schema-form.d.ts.map +1 -0
  390. package/dist/routes/memories/schemas/schema-form.js +279 -0
  391. package/dist/routes/memories/schemas/schema-form.js.map +1 -0
  392. package/dist/routes/memories/schemas/schema-impact.d.ts +13 -0
  393. package/dist/routes/memories/schemas/schema-impact.d.ts.map +1 -0
  394. package/dist/routes/memories/schemas/schema-impact.js +40 -0
  395. package/dist/routes/memories/schemas/schema-impact.js.map +1 -0
  396. package/dist/routes/memories/schemas/schema-route.d.ts +18 -0
  397. package/dist/routes/memories/schemas/schema-route.d.ts.map +1 -0
  398. package/dist/routes/memories/schemas/schema-route.js +21 -0
  399. package/dist/routes/memories/schemas/schema-route.js.map +1 -0
  400. package/dist/routes/memories/schemas/schema-rule-context.d.ts +17 -0
  401. package/dist/routes/memories/schemas/schema-rule-context.d.ts.map +1 -0
  402. package/dist/routes/memories/schemas/schema-rule-context.js +83 -0
  403. package/dist/routes/memories/schemas/schema-rule-context.js.map +1 -0
  404. package/dist/routes/memories/schemas/schema-table.d.ts +11 -0
  405. package/dist/routes/memories/schemas/schema-table.d.ts.map +1 -0
  406. package/dist/routes/memories/schemas/schema-table.js +34 -0
  407. package/dist/routes/memories/schemas/schema-table.js.map +1 -0
  408. package/dist/routes/memories/schemas/useMemorySchemaMutations.d.ts +32 -0
  409. package/dist/routes/memories/schemas/useMemorySchemaMutations.d.ts.map +1 -0
  410. package/dist/routes/memories/schemas/useMemorySchemaMutations.js +31 -0
  411. package/dist/routes/memories/schemas/useMemorySchemaMutations.js.map +1 -0
  412. package/dist/routes/memories/schemas/useSchemaChangeReview.d.ts +51 -0
  413. package/dist/routes/memories/schemas/useSchemaChangeReview.d.ts.map +1 -0
  414. package/dist/routes/memories/schemas/useSchemaChangeReview.js +175 -0
  415. package/dist/routes/memories/schemas/useSchemaChangeReview.js.map +1 -0
  416. package/dist/routes/memories/schemas/useSchemaLifecycle.d.ts +46 -0
  417. package/dist/routes/memories/schemas/useSchemaLifecycle.d.ts.map +1 -0
  418. package/dist/routes/memories/schemas/useSchemaLifecycle.js +93 -0
  419. package/dist/routes/memories/schemas/useSchemaLifecycle.js.map +1 -0
  420. package/dist/routes/memories/schemas/useSchemasTab.d.ts +18 -0
  421. package/dist/routes/memories/schemas/useSchemasTab.d.ts.map +1 -0
  422. package/dist/routes/memories/schemas/useSchemasTab.js +92 -0
  423. package/dist/routes/memories/schemas/useSchemasTab.js.map +1 -0
  424. package/dist/routes/plans/index.d.ts.map +1 -1
  425. package/dist/routes/plans/index.js +2 -2
  426. package/dist/routes/plans/index.js.map +1 -1
  427. package/dist/routes/rules/components/CreateRuleChatModal.d.ts +7 -1
  428. package/dist/routes/rules/components/CreateRuleChatModal.d.ts.map +1 -1
  429. package/dist/routes/rules/components/CreateRuleChatModal.js +9 -4
  430. package/dist/routes/rules/components/CreateRuleChatModal.js.map +1 -1
  431. package/dist/routes/rules/components/RuleValueControls.d.ts.map +1 -1
  432. package/dist/routes/rules/components/RuleValueControls.js +3 -24
  433. package/dist/routes/rules/components/RuleValueControls.js.map +1 -1
  434. package/dist/routes/rules/components/rule-value-input.d.ts +11 -0
  435. package/dist/routes/rules/components/rule-value-input.d.ts.map +1 -0
  436. package/dist/routes/rules/components/rule-value-input.js +24 -0
  437. package/dist/routes/rules/components/rule-value-input.js.map +1 -0
  438. package/dist/routes/rules/components/rules.utils.d.ts +5 -0
  439. package/dist/routes/rules/components/rules.utils.d.ts.map +1 -1
  440. package/dist/routes/rules/components/rules.utils.js +18 -3
  441. package/dist/routes/rules/components/rules.utils.js.map +1 -1
  442. package/dist/routes/rules/pages.d.ts +1 -1
  443. package/dist/routes/rules/pages.d.ts.map +1 -1
  444. package/dist/routes/rules/pages.js +1 -1
  445. package/dist/routes/rules/pages.js.map +1 -1
  446. package/dist/shared/graph-derived-queries.d.ts.map +1 -1
  447. package/dist/shared/graph-derived-queries.js +4 -1
  448. package/dist/shared/graph-derived-queries.js.map +1 -1
  449. package/dist/worker/index.d.ts +22 -0
  450. package/dist/worker/index.d.ts.map +1 -0
  451. package/dist/worker/index.js +110 -0
  452. package/dist/worker/index.js.map +1 -0
  453. package/dist/worker/policy.d.ts +21 -0
  454. package/dist/worker/policy.d.ts.map +1 -0
  455. package/dist/worker/policy.js +42 -0
  456. package/dist/worker/policy.js.map +1 -0
  457. package/dist/worker/proxy.d.ts +14 -0
  458. package/dist/worker/proxy.d.ts.map +1 -0
  459. package/dist/worker/proxy.js +58 -0
  460. package/dist/worker/proxy.js.map +1 -0
  461. package/dist/worker/session.d.ts +24 -0
  462. package/dist/worker/session.d.ts.map +1 -0
  463. package/dist/worker/session.js +72 -0
  464. package/dist/worker/session.js.map +1 -0
  465. package/package.json +52 -7
  466. package/src/app-subpaths.json +9 -1
  467. package/src/components/AppErrorBoundary.tsx +14 -11
  468. package/src/components/app-gate/AppGate.tsx +122 -0
  469. package/src/components/app-gate/AwaitingDatastoreStatus.tsx +35 -0
  470. package/src/components/app-gate/EnterDatastoreRoute.tsx +30 -0
  471. package/src/components/app-gate/ErrorRoute.tsx +43 -0
  472. package/src/components/app-gate/FailureAlert.tsx +15 -0
  473. package/src/components/app-gate/NoDatastoreAccess.tsx +26 -0
  474. package/src/components/app-gate/NotFoundRoute.tsx +20 -0
  475. package/src/components/app-gate/PendingInvitations.tsx +134 -0
  476. package/src/components/app-gate/ServiceError.tsx +27 -0
  477. package/src/components/app-gate/index.ts +2 -0
  478. package/src/components/app-gate/sdk-route-elements.tsx +46 -0
  479. package/src/components/app-shell/AppShell.tsx +22 -0
  480. package/src/components/app-shell/AppShellRoutes.tsx +34 -0
  481. package/src/components/app-shell/GroupDatastores.tsx +28 -0
  482. package/src/components/app-shell/GroupRoute.tsx +34 -0
  483. package/src/components/app-shell/index.ts +2 -0
  484. package/src/components/authenticated-chat/index.tsx +1 -34
  485. package/src/components/chat-view/Chat.tsx +9 -3
  486. package/src/components/chat-view/MessageItem.tsx +10 -2
  487. package/src/components/chat-view/tool-part-rendering.ts +10 -1
  488. package/src/components/chip/index.tsx +8 -1
  489. package/src/components/embedded-chat/index.tsx +2 -1
  490. package/src/components/input/input-date-time.tsx +10 -3
  491. package/src/components/input/input-date.tsx +93 -21
  492. package/src/components/input/input-time.tsx +59 -26
  493. package/src/components/layouts/RouteLayout.tsx +11 -50
  494. package/src/components/layouts/Sidebar.tsx +21 -23
  495. package/src/components/plan-limits/PlanLimitsDialog.tsx +331 -0
  496. package/src/components/plan-limits/index.tsx +3 -0
  497. package/src/components/plan-limits/plan-limits-client.ts +71 -0
  498. package/src/components/plan-limits/plan-limits-model.ts +180 -0
  499. package/src/components/plan-limits/plan-limits-save.ts +68 -0
  500. package/src/components/planning/PlanLimitsAction.tsx +44 -0
  501. package/src/components/slider/index.tsx +2 -1
  502. package/src/datastore-picker/datastore-picker-rows.ts +36 -20
  503. package/src/hooks/use-action-plans-list.ts +20 -12
  504. package/src/hooks/use-activity-feed.ts +30 -14
  505. package/src/hooks/use-entity.ts +11 -6
  506. package/src/hooks/use-manual-actions.ts +11 -6
  507. package/src/hooks/use-unsaved-changes-warning.ts +12 -0
  508. package/src/hooks/useAuth.ts +5 -3
  509. package/src/hooks/useChatPanelSync.ts +2 -3
  510. package/src/hooks/useDatastoreSelection.ts +10 -4
  511. package/src/hooks/useExecuteAction.ts +2 -0
  512. package/src/hooks/useLoginRedirect.ts +66 -0
  513. package/src/hooks/usePlanLimits.ts +97 -0
  514. package/src/ldo-ui.ts +1 -0
  515. package/src/lib/app-tools.ts +63 -0
  516. package/src/lib/chat-types.ts +5 -0
  517. package/src/lib/datastore-route-table.ts +9 -0
  518. package/src/lib/graphql-error.ts +7 -0
  519. package/src/lib/update-notice.ts +12 -2
  520. package/src/providers/ActiveChatProvider.tsx +8 -3
  521. package/src/providers/ActiveDatastoreProvider.tsx +179 -9
  522. package/src/providers/AuthContext.ts +1 -0
  523. package/src/providers/KnowledgeGraphStateContext.ts +2 -2
  524. package/src/providers/KnowledgeGraphStateProvider.tsx +13 -65
  525. package/src/providers/MantaClientProvider.tsx +8 -3
  526. package/src/providers/index.tsx +7 -4
  527. package/src/routes/activity/detail/ActivityDetailRoute.tsx +1 -10
  528. package/src/routes/activity/index.tsx +1 -10
  529. package/src/routes/chat/index.tsx +11 -47
  530. package/src/routes/data-collection/index.tsx +1 -11
  531. package/src/routes/data-explorer/components/DataExplorerLayout.tsx +1 -11
  532. package/src/routes/data-explorer/components/class-detail/UsedByRules.tsx +2 -2
  533. package/src/routes/datastores/index.tsx +3 -9
  534. package/src/routes/explain/index.tsx +1 -11
  535. package/src/routes/integrations/components/connect-forms/DashConnectForm.tsx +0 -1
  536. package/src/routes/integrations/components/connect-forms/GoogleAdsConnectForm.tsx +0 -1
  537. package/src/routes/integrations/components/connect-forms/GoogleAnalyticsConnectForm.tsx +0 -1
  538. package/src/routes/integrations/components/connect-forms/GoogleMerchantCenterConnectForm.tsx +0 -1
  539. package/src/routes/integrations/components/connect-forms/InferalCredentialConnectForm.tsx +5 -3
  540. package/src/routes/integrations/components/connect-forms/KlaviyoConnectForm.tsx +0 -1
  541. package/src/routes/integrations/components/connect-forms/MicrosoftAdsConnectForm.tsx +0 -1
  542. package/src/routes/integrations/components/connect-forms/OAuthSetupConnectForm.tsx +7 -7
  543. package/src/routes/integrations/components/connect-forms/TriplewhaleConnectForm.tsx +0 -1
  544. package/src/routes/integrations/components/connect-forms/WoocommerceConnectForm.tsx +0 -1
  545. package/src/routes/integrations/types.ts +22 -6
  546. package/src/routes/memories/components/DateValueInput.tsx +72 -0
  547. package/src/routes/memories/components/EntityValuePicker.tsx +132 -0
  548. package/src/routes/memories/components/FieldLabel.tsx +49 -0
  549. package/src/routes/memories/components/ImportanceSlider.tsx +5 -1
  550. package/src/routes/memories/components/MemoriesFilters.tsx +2 -2
  551. package/src/routes/memories/components/MemoriesPanel.tsx +7 -3
  552. package/src/routes/memories/components/MemoriesTabPanel.tsx +2 -2
  553. package/src/routes/memories/components/MemoryActions.tsx +26 -2
  554. package/src/routes/memories/components/MemoryFields.tsx +75 -12
  555. package/src/routes/memories/components/MemoryFormDialog.tsx +305 -199
  556. package/src/routes/memories/components/MemoryPropertyFields.tsx +288 -0
  557. package/src/routes/memories/components/RuleDraftDialog.tsx +35 -0
  558. package/src/routes/memories/components/SchemasTab.tsx +481 -118
  559. package/src/routes/memories/components/badges.tsx +16 -4
  560. package/src/routes/memories/hooks/useMemoryColumns.tsx +69 -35
  561. package/src/routes/memories/index.tsx +125 -51
  562. package/src/routes/memories/memory-mutation-input.ts +5 -2
  563. package/src/routes/memories/memory-property-values.ts +83 -0
  564. package/src/routes/memories/schemas/AllowedValuesField.tsx +188 -0
  565. package/src/routes/memories/schemas/MemorySchemaPage.tsx +476 -0
  566. package/src/routes/memories/schemas/SchemaChangeReviewDialog.tsx +290 -0
  567. package/src/routes/memories/schemas/SchemaConfirmDialog.tsx +62 -0
  568. package/src/routes/memories/schemas/SchemaDetailPage.tsx +373 -0
  569. package/src/routes/memories/schemas/SchemaEditorForm.tsx +990 -0
  570. package/src/routes/memories/schemas/SchemaTemplatesDialog.tsx +81 -0
  571. package/src/routes/memories/schemas/ValueTypeSelect.tsx +37 -0
  572. package/src/routes/memories/schemas/schema-form.ts +360 -0
  573. package/src/routes/memories/schemas/schema-impact.ts +66 -0
  574. package/src/routes/memories/schemas/schema-route.ts +30 -0
  575. package/src/routes/memories/schemas/schema-rule-context.ts +103 -0
  576. package/src/routes/memories/schemas/schema-table.ts +54 -0
  577. package/src/routes/memories/schemas/useMemorySchemaMutations.ts +49 -0
  578. package/src/routes/memories/schemas/useSchemaChangeReview.ts +238 -0
  579. package/src/routes/memories/schemas/useSchemaLifecycle.tsx +151 -0
  580. package/src/routes/memories/schemas/useSchemasTab.ts +119 -0
  581. package/src/routes/plans/index.tsx +3 -14
  582. package/src/routes/rules/components/CreateRuleChatModal.tsx +46 -22
  583. package/src/routes/rules/components/RuleValueControls.tsx +3 -35
  584. package/src/routes/rules/components/rule-value-input.ts +34 -0
  585. package/src/routes/rules/components/rules.utils.ts +25 -3
  586. package/src/routes/rules/pages.ts +5 -1
  587. package/src/shared/graph-derived-queries.ts +6 -0
  588. package/src/themes/manta-dark.css +4 -0
  589. package/src/worker/index.ts +175 -0
  590. package/src/worker/policy.ts +62 -0
  591. package/src/worker/proxy.ts +101 -0
  592. package/src/worker/session.ts +111 -0
@@ -0,0 +1,81 @@
1
+ import type { GQLMemorySchemaTemplatesQuery } from "@manta-eu/client";
2
+ import { humanCount } from "@manta-eu/lib/humanize";
3
+ import { isPresent } from "@manta-eu/lib/present";
4
+ import { Banner } from "#components/banner/index";
5
+ import { Button } from "#components/button/index";
6
+ import { Loader } from "#components/loader/index";
7
+ import {
8
+ Dialog,
9
+ DialogContent,
10
+ DialogDescription,
11
+ DialogFooter,
12
+ DialogHeader,
13
+ DialogTitle,
14
+ } from "#components/modal/index";
15
+
16
+ export type MemorySchemaTemplate = GQLMemorySchemaTemplatesQuery["memorySchemaTemplates"]["templates"][number];
17
+
18
+ export type SchemaTemplatesDialogProps = {
19
+ open: boolean;
20
+ templates: readonly MemorySchemaTemplate[];
21
+ isLoading: boolean;
22
+ errorMessage?: string | null;
23
+ addingIri: string | null;
24
+ onAdd: (templateIri: string) => void;
25
+ onClose: () => void;
26
+ };
27
+
28
+ export function SchemaTemplatesDialog(props: SchemaTemplatesDialogProps) {
29
+ const { open, templates, isLoading, errorMessage, addingIri, onAdd, onClose } = props;
30
+ const available = templates.filter((template) => !template.live);
31
+
32
+ return (
33
+ <Dialog open={open} onOpenChange={(next) => !next && onClose()}>
34
+ <DialogContent className="flex flex-col overflow-hidden">
35
+ <DialogHeader>
36
+ <DialogTitle text="Restore a default schema" />
37
+ <DialogDescription>
38
+ Manta ships these schemas. Restoring one gives this datastore its own copy to edit again.
39
+ </DialogDescription>
40
+ </DialogHeader>
41
+ <div className="-mx-8 flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-8 py-1">
42
+ {errorMessage && <Banner label={errorMessage} className="shrink-0" />}
43
+ {isLoading ? (
44
+ <div className="flex justify-center py-6">
45
+ <Loader className="size-6" />
46
+ </div>
47
+ ) : isPresent(available) ? (
48
+ available.map(({ schema }) => (
49
+ <div key={schema.iri} className="flex items-center gap-3 rounded-lg border border-muted-border p-3">
50
+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">
51
+ <span className="truncate typography-small-medium">{schema.label}</span>
52
+ <span className="typography-tiny text-muted-foreground">
53
+ {schema.description ?? humanCount(schema.properties.length, "property")}
54
+ </span>
55
+ </div>
56
+ <Button
57
+ size="sm"
58
+ variant="secondary"
59
+ disabled={addingIri !== null}
60
+ aria-label={`Restore ${schema.label}`}
61
+ onClick={() => onAdd(schema.iri)}
62
+ >
63
+ {addingIri === schema.iri ? "Restoring…" : "Restore"}
64
+ </Button>
65
+ </div>
66
+ ))
67
+ ) : (
68
+ <p className="py-4 typography-small text-muted-foreground">
69
+ Every default schema is already in this datastore.
70
+ </p>
71
+ )}
72
+ </div>
73
+ <DialogFooter>
74
+ <Button variant="tertiary" onClick={onClose}>
75
+ Close
76
+ </Button>
77
+ </DialogFooter>
78
+ </DialogContent>
79
+ </Dialog>
80
+ );
81
+ }
@@ -0,0 +1,37 @@
1
+ import { GQLMemorySchemaValueType } from "@manta-eu/client";
2
+ import { valueTypeLabels } from "./schema-form";
3
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "#components/select/index";
4
+
5
+ const valueTypes = Object.values(GQLMemorySchemaValueType);
6
+
7
+ export type ValueTypeSelectProps = {
8
+ id: string;
9
+ label: string;
10
+ value: GQLMemorySchemaValueType;
11
+ disabled?: boolean;
12
+ error?: string;
13
+ className?: string;
14
+ onChange: (valueType: GQLMemorySchemaValueType) => void;
15
+ };
16
+
17
+ export function ValueTypeSelect(props: ValueTypeSelectProps) {
18
+ const { id, label, value, disabled, error, className, onChange } = props;
19
+ return (
20
+ <Select
21
+ value={value}
22
+ disabled={disabled}
23
+ onValueChange={(next) => onChange(valueTypes.find((type) => type === next) ?? value)}
24
+ >
25
+ <SelectTrigger label={label} id={id} hiddenLabel error={error} className={className}>
26
+ <SelectValue />
27
+ </SelectTrigger>
28
+ <SelectContent>
29
+ {valueTypes.map((type) => (
30
+ <SelectItem key={type} value={type}>
31
+ {valueTypeLabels[type]}
32
+ </SelectItem>
33
+ ))}
34
+ </SelectContent>
35
+ </Select>
36
+ );
37
+ }
@@ -0,0 +1,360 @@
1
+ import {
2
+ GQLMemoryKind,
3
+ GQLMemorySchemaValueType,
4
+ GQLMemoryScope,
5
+ GQLMemoryVolatility,
6
+ type GQLMemorySchemaFieldsFragment,
7
+ type GQLMemorySchemaDefinitionInput,
8
+ type GQLMemorySchemaPropertyDefinitionInput,
9
+ type GQLMemorySchemaValidationError,
10
+ } from "@manta-eu/client";
11
+ import { memorySchemaLimits } from "@manta-eu/client/shared/memory-schema-limits";
12
+ import {
13
+ checkMemorySchemaProperty,
14
+ deriveMemoryPropertyKey,
15
+ memoryPropertyKeyProblem,
16
+ } from "@manta-eu/client/shared/memory-schema-property";
17
+ import {
18
+ memorySchemaValueTypes,
19
+ parseMemoryValue,
20
+ type CompileMemoryValuePattern,
21
+ } from "@manta-eu/client/shared/memory-schema-values";
22
+ import { humanCount } from "@manta-eu/lib/humanize";
23
+ import { isPresent } from "@manta-eu/lib/present";
24
+
25
+ let compilePattern: CompileMemoryValuePattern | null = null;
26
+
27
+ // RE2 is large, so it loads with the schema editor rather than with the app. Until it has, only the server checks a
28
+ // pattern, and it does so again on every save anyway.
29
+ export async function loadPatternCheck(): Promise<void> {
30
+ compilePattern ??= (await import("@manta-eu/client/shared/memory-schema-pattern")).compileMemoryValuePattern;
31
+ }
32
+
33
+ export const memorySchemaPropertyLimit = memorySchemaLimits.properties;
34
+ export const memorySchemaOptionLimit = memorySchemaLimits.options;
35
+
36
+ export type SchemaOptionForm = { id: string; value: string; label: string; description: string };
37
+
38
+ export type SchemaPropertyForm = {
39
+ id: string;
40
+ path: string | null;
41
+ key: string;
42
+ label: string;
43
+ description: string;
44
+ valueType: GQLMemorySchemaValueType;
45
+ entityClass: string;
46
+ required: boolean;
47
+ multiValued: boolean;
48
+ keyProperty: boolean;
49
+ computed: boolean;
50
+ options: SchemaOptionForm[];
51
+ minValue: string;
52
+ maxValue: string;
53
+ maxLength: string;
54
+ pattern: string;
55
+ defaultValue: string;
56
+ unit: string;
57
+ };
58
+
59
+ export type SchemaForm = {
60
+ key: string;
61
+ label: string;
62
+ description: string;
63
+ defaultMemoryKind: GQLMemoryKind | null;
64
+ defaultVolatility: GQLMemoryVolatility | null;
65
+ defaultImportance: number | null;
66
+ defaultScope: GQLMemoryScope | null;
67
+ extractionEnabled: boolean;
68
+ extractionGuidance: string;
69
+ properties: SchemaPropertyForm[];
70
+ };
71
+
72
+ export const kindLabels: Record<GQLMemoryKind, string> = {
73
+ [GQLMemoryKind.Fact]: "Fact",
74
+ [GQLMemoryKind.Preference]: "Preference",
75
+ [GQLMemoryKind.Objective]: "Objective",
76
+ [GQLMemoryKind.Context]: "Context",
77
+ };
78
+
79
+ export const volatilityLabels: Record<GQLMemoryVolatility, string> = {
80
+ [GQLMemoryVolatility.Stable]: "Stable",
81
+ [GQLMemoryVolatility.Slow]: "Changes slowly",
82
+ [GQLMemoryVolatility.Volatile]: "Changes often",
83
+ };
84
+
85
+ export const scopeLabels: Record<GQLMemoryScope, string> = {
86
+ [GQLMemoryScope.User]: "Personal",
87
+ [GQLMemoryScope.Team]: "Team",
88
+ [GQLMemoryScope.Company]: "Company",
89
+ };
90
+
91
+ export const valueTypeLabels: Record<GQLMemorySchemaValueType, string> = {
92
+ [GQLMemorySchemaValueType.Text]: "Text",
93
+ [GQLMemorySchemaValueType.LongText]: "Long text",
94
+ [GQLMemorySchemaValueType.Integer]: "Whole number",
95
+ [GQLMemorySchemaValueType.Decimal]: "Decimal number",
96
+ [GQLMemorySchemaValueType.Boolean]: "Yes / no",
97
+ [GQLMemorySchemaValueType.Date]: "Date",
98
+ [GQLMemorySchemaValueType.DateTime]: "Date and time",
99
+ [GQLMemorySchemaValueType.Url]: "Web address",
100
+ [GQLMemorySchemaValueType.Entity]: "Linked record",
101
+ };
102
+
103
+ const boundTypes: readonly GQLMemorySchemaValueType[] = [
104
+ GQLMemorySchemaValueType.Integer,
105
+ GQLMemorySchemaValueType.Decimal,
106
+ GQLMemorySchemaValueType.Date,
107
+ GQLMemorySchemaValueType.DateTime,
108
+ ];
109
+ const textTypes: readonly GQLMemorySchemaValueType[] = [
110
+ GQLMemorySchemaValueType.Text,
111
+ GQLMemorySchemaValueType.LongText,
112
+ ];
113
+ const numberTypes: readonly GQLMemorySchemaValueType[] = [
114
+ GQLMemorySchemaValueType.Integer,
115
+ GQLMemorySchemaValueType.Decimal,
116
+ ];
117
+
118
+ // Mirrors which settings the server accepts per type, so switching type never sends one it would refuse.
119
+ export function propertySettings(valueType: GQLMemorySchemaValueType) {
120
+ return {
121
+ options: valueType === GQLMemorySchemaValueType.Text,
122
+ bounds: boundTypes.includes(valueType),
123
+ maxLength: [...textTypes, GQLMemorySchemaValueType.Url].includes(valueType),
124
+ pattern: textTypes.includes(valueType),
125
+ unit: numberTypes.includes(valueType),
126
+ entityClass: valueType === GQLMemorySchemaValueType.Entity,
127
+ keyProperty: valueType !== GQLMemorySchemaValueType.LongText,
128
+ };
129
+ }
130
+
131
+ // Only what the save keeps for this type, so a setting left behind by a type switch is not shown as in effect.
132
+ export function propertyTags(property: SchemaPropertyForm): string[] {
133
+ const settings = propertySettings(property.valueType);
134
+ return [
135
+ property.computed ? "Computed" : property.required ? "Required" : "",
136
+ property.multiValued ? "List" : "",
137
+ settings.keyProperty && property.keyProperty && !property.multiValued && !property.computed ? "Identifies" : "",
138
+ settings.unit ? property.unit.trim() : "",
139
+ settings.options && isPresent(property.options) ? humanCount(property.options.length, "allowed value") : "",
140
+ ].filter(isPresent);
141
+ }
142
+
143
+ export function withValueType(property: SchemaPropertyForm, valueType: GQLMemorySchemaValueType): SchemaPropertyForm {
144
+ const type = memorySchemaValueTypes.find((candidate) => candidate === valueType);
145
+ const kept = (raw: string) => (type !== undefined && parseMemoryValue(type, raw) !== null ? raw : "");
146
+ return {
147
+ ...property,
148
+ valueType,
149
+ minValue: kept(property.minValue),
150
+ maxValue: kept(property.maxValue),
151
+ defaultValue: kept(property.defaultValue),
152
+ };
153
+ }
154
+
155
+ export function newFormId(): string {
156
+ return crypto.randomUUID();
157
+ }
158
+
159
+ export function emptyPropertyForm(): SchemaPropertyForm {
160
+ return {
161
+ id: newFormId(),
162
+ path: null,
163
+ key: "",
164
+ label: "",
165
+ description: "",
166
+ valueType: GQLMemorySchemaValueType.Text,
167
+ entityClass: "",
168
+ required: false,
169
+ multiValued: false,
170
+ keyProperty: false,
171
+ computed: false,
172
+ options: [],
173
+ minValue: "",
174
+ maxValue: "",
175
+ maxLength: "",
176
+ pattern: "",
177
+ defaultValue: "",
178
+ unit: "",
179
+ };
180
+ }
181
+
182
+ export function emptySchemaForm(): SchemaForm {
183
+ return {
184
+ key: "",
185
+ label: "",
186
+ description: "",
187
+ defaultMemoryKind: null,
188
+ defaultVolatility: null,
189
+ defaultImportance: null,
190
+ defaultScope: null,
191
+ extractionEnabled: true,
192
+ extractionGuidance: "",
193
+ properties: [],
194
+ };
195
+ }
196
+
197
+ export function schemaFormFromSchema(schema: GQLMemorySchemaFieldsFragment): SchemaForm {
198
+ return {
199
+ key: "",
200
+ label: schema.label,
201
+ description: schema.description ?? "",
202
+ defaultMemoryKind: schema.defaultMemoryKind ?? null,
203
+ defaultVolatility: schema.defaultVolatility ?? null,
204
+ defaultImportance: schema.defaultImportance ?? null,
205
+ defaultScope: schema.defaultScope ?? null,
206
+ extractionEnabled: schema.extractionEnabled,
207
+ extractionGuidance: schema.extractionGuidance ?? "",
208
+ properties: [...schema.properties]
209
+ .sort((a, b) => a.order - b.order)
210
+ .map((property) => ({
211
+ id: newFormId(),
212
+ path: property.path,
213
+ key: "",
214
+ label: property.label,
215
+ description: property.description ?? "",
216
+ valueType: property.valueType,
217
+ entityClass: property.entityClass ?? "",
218
+ required: property.required,
219
+ multiValued: property.multiValued,
220
+ keyProperty: property.keyProperty,
221
+ computed: property.computed,
222
+ options: property.options.map((option) => ({
223
+ id: newFormId(),
224
+ value: option.value,
225
+ label: option.label ?? "",
226
+ description: option.description ?? "",
227
+ })),
228
+ minValue: property.minValue ?? "",
229
+ maxValue: property.maxValue ?? "",
230
+ maxLength: property.maxLength != null ? String(property.maxLength) : "",
231
+ pattern: property.pattern ?? "",
232
+ defaultValue: property.defaultValue ?? "",
233
+ unit: property.unit ?? "",
234
+ })),
235
+ };
236
+ }
237
+
238
+ function textOrNull(value: string): string | null {
239
+ const trimmed = value.trim();
240
+ return isPresent(trimmed) ? trimmed : null;
241
+ }
242
+
243
+ function maxLengthOrNull(value: string): number | null {
244
+ const trimmed = value.trim();
245
+ return isPresent(trimmed) && /^\d+$/.test(trimmed) ? Number(trimmed) : null;
246
+ }
247
+
248
+ function propertyInput(property: SchemaPropertyForm): GQLMemorySchemaPropertyDefinitionInput {
249
+ const settings = propertySettings(property.valueType);
250
+ const key = textOrNull(property.key);
251
+ return {
252
+ ...(property.path !== null ? { path: property.path } : key !== null ? { key } : {}),
253
+ label: property.label.trim(),
254
+ description: textOrNull(property.description),
255
+ valueType: property.valueType,
256
+ entityClass: settings.entityClass ? textOrNull(property.entityClass) : null,
257
+ required: property.required && !property.computed,
258
+ multiValued: property.multiValued,
259
+ keyProperty: settings.keyProperty && property.keyProperty && !property.multiValued && !property.computed,
260
+ computed: property.computed,
261
+ options: settings.options
262
+ ? property.options.map((option) => ({
263
+ value: option.value.trim(),
264
+ label: textOrNull(option.label),
265
+ description: textOrNull(option.description),
266
+ }))
267
+ : [],
268
+ minValue: settings.bounds ? textOrNull(property.minValue) : null,
269
+ maxValue: settings.bounds ? textOrNull(property.maxValue) : null,
270
+ maxLength: settings.maxLength ? maxLengthOrNull(property.maxLength) : null,
271
+ pattern: settings.pattern ? textOrNull(property.pattern) : null,
272
+ defaultValue: property.computed ? null : textOrNull(property.defaultValue),
273
+ unit: settings.unit ? textOrNull(property.unit) : null,
274
+ };
275
+ }
276
+
277
+ export function schemaDefinitionInput(form: SchemaForm, options: { isNew: boolean }): GQLMemorySchemaDefinitionInput {
278
+ const key = textOrNull(form.key);
279
+ return {
280
+ ...(options.isNew && key !== null ? { key } : {}),
281
+ label: form.label.trim(),
282
+ description: textOrNull(form.description),
283
+ defaultMemoryKind: form.defaultMemoryKind,
284
+ defaultVolatility: form.defaultVolatility,
285
+ defaultImportance: form.defaultImportance,
286
+ defaultScope: form.defaultScope,
287
+ extractionEnabled: form.extractionEnabled,
288
+ extractionGuidance: form.extractionEnabled ? textOrNull(form.extractionGuidance) : null,
289
+ properties: form.properties.map(propertyInput),
290
+ };
291
+ }
292
+
293
+ export type SchemaFormErrors = ReadonlyMap<string, string>;
294
+
295
+ export function propertyFormErrors(
296
+ property: SchemaPropertyForm,
297
+ prefix: string,
298
+ siblings: readonly SchemaPropertyForm[] = [],
299
+ ): Map<string, string> {
300
+ const errors = new Map<string, string>();
301
+ function add(field: string, message: string) {
302
+ if (!errors.has(field)) errors.set(field, message);
303
+ }
304
+
305
+ const maxLength = property.maxLength.trim();
306
+ if (propertySettings(property.valueType).maxLength && isPresent(maxLength) && !/^\d+$/.test(maxLength)) {
307
+ add(`${prefix}.maxLength`, "The maximum length must be a whole number");
308
+ }
309
+ for (const error of checkMemorySchemaProperty(propertyInput(property), prefix, compilePattern).errors)
310
+ add(error.field, error.message);
311
+
312
+ const label = property.label.trim();
313
+ const key = textOrNull(property.key);
314
+ if (property.path === null && (key !== null || isPresent(label))) {
315
+ const problem = memoryPropertyKeyProblem(key ?? deriveMemoryPropertyKey(label));
316
+ if (problem !== null) add(`${prefix}.key`, problem);
317
+ }
318
+ if (isPresent(label)) {
319
+ const clash = siblings.find(
320
+ (other) => other.id !== property.id && other.label.trim().toLowerCase() === label.toLowerCase(),
321
+ );
322
+ if (clash !== undefined) add(`${prefix}.label`, "Another property already uses this label");
323
+ }
324
+ return errors;
325
+ }
326
+
327
+ export function localSchemaFormErrors(form: SchemaForm): SchemaFormErrors {
328
+ const errors = new Map<string, string>();
329
+ form.properties.forEach((property, index) => {
330
+ for (const [field, message] of propertyFormErrors(property, propertyErrorPrefix(index), form.properties)) {
331
+ errors.set(field, message);
332
+ }
333
+ });
334
+ return errors;
335
+ }
336
+
337
+ // The server names a field by its place in the submitted definition, e.g. `properties.2.options.0.value`.
338
+ export function schemaFormErrors(errors: readonly GQLMemorySchemaValidationError[]): SchemaFormErrors {
339
+ const byField = new Map<string, string>();
340
+ for (const { field, message } of errors) {
341
+ if (!byField.has(field)) byField.set(field, message);
342
+ }
343
+ return byField;
344
+ }
345
+
346
+ export function propertyErrorPrefix(index: number): string {
347
+ return `properties.${index}`;
348
+ }
349
+
350
+ export function hasErrorsUnder(errors: SchemaFormErrors, prefix: string): boolean {
351
+ return [...errors.keys()].some((field) => field === prefix || field.startsWith(`${prefix}.`));
352
+ }
353
+
354
+ export function moveItem<T>(items: readonly T[], from: number, to: number): T[] {
355
+ if (to < 0 || to >= items.length || from === to) return [...items];
356
+ const next = [...items];
357
+ const [moved] = next.splice(from, 1);
358
+ if (moved !== undefined) next.splice(to, 0, moved);
359
+ return next;
360
+ }
@@ -0,0 +1,66 @@
1
+ import type {
2
+ GQLMemorySchemaFieldsFragment,
3
+ GQLMemorySchemaMutationResultFragment,
4
+ GQLMemorySchemaOptionRemapInput,
5
+ } from "@manta-eu/client";
6
+ import { isPresent } from "@manta-eu/lib/present";
7
+ import { getRuleDisplayName } from "#routes/rules/components/rules.utils";
8
+
9
+ export type MemorySchemaImpact = NonNullable<GQLMemorySchemaMutationResultFragment["impact"]>;
10
+
11
+ export type RemovedOptionInUse = MemorySchemaImpact["removedOptions"][number];
12
+
13
+ export type OptionRemapChoices = Record<string, string>;
14
+
15
+ export const clearValueChoice = "__clear__";
16
+
17
+ // Longest IRI first, so a rule IRI that is a prefix of another never rewrites part of the longer one.
18
+ export function readableBlockers(impact: Pick<MemorySchemaImpact, "blockers" | "ruleReferences">): string[] {
19
+ const ruleIris = [...new Set(impact.ruleReferences.map((reference) => reference.ruleIri))].sort(
20
+ (a, b) => b.length - a.length,
21
+ );
22
+ return impact.blockers.map((blocker) =>
23
+ ruleIris.reduce((text, ruleIri) => text.split(ruleIri).join(getRuleDisplayName(ruleIri)), blocker),
24
+ );
25
+ }
26
+
27
+ export function remapChoiceKey(option: Pick<RemovedOptionInUse, "path" | "value">): string {
28
+ return `${option.path}\u0000${option.value}`;
29
+ }
30
+
31
+ // A change that moves no stored value and names no rule can be saved without a review step.
32
+ export function impactNeedsReview(impact: MemorySchemaImpact): boolean {
33
+ return (
34
+ isPresent(impact.blockers) ||
35
+ isPresent(impact.ruleReferences) ||
36
+ impact.removedProperties.some((property) => property.memoryCount > 0) ||
37
+ impact.typeChanges.some((change) => change.valueCount > 0) ||
38
+ impact.removedOptions.some((option) => option.memoryCount > 0) ||
39
+ isPresent(impact.limitViolations) ||
40
+ isPresent(impact.multiValueConflicts) ||
41
+ impact.clearedValues.some((property) => property.memoryCount > 0)
42
+ );
43
+ }
44
+
45
+ export function removedOptionsInUse(impact: MemorySchemaImpact): RemovedOptionInUse[] {
46
+ return impact.removedOptions.filter((option) => option.memoryCount > 0);
47
+ }
48
+
49
+ export function remapTargets(proposed: GQLMemorySchemaFieldsFragment | null | undefined, path: string): string[] {
50
+ return proposed?.properties.find((property) => property.path === path)?.allowedValues ?? [];
51
+ }
52
+
53
+ export function optionRemapsInput(
54
+ impact: MemorySchemaImpact,
55
+ choices: OptionRemapChoices,
56
+ ): GQLMemorySchemaOptionRemapInput[] {
57
+ return removedOptionsInUse(impact).flatMap((option) => {
58
+ const choice = choices[remapChoiceKey(option)];
59
+ if (choice === undefined) return [];
60
+ return [{ path: option.path, from: option.value, to: choice === clearValueChoice ? null : choice }];
61
+ });
62
+ }
63
+
64
+ export function hasInvalidValues(impact: MemorySchemaImpact): boolean {
65
+ return impact.typeChanges.some((change) => change.unconvertibleCount > 0) || isPresent(impact.limitViolations);
66
+ }
@@ -0,0 +1,30 @@
1
+ export const memorySchemasPath = "/memories?tab=schemas";
2
+ export const newMemorySchemaPath = "/memories/schemas/new";
3
+
4
+ // The whole IRI names the page: IRIs are opaque, so no part of one is a name to route by.
5
+ export function memorySchemaPath(iri: string): string {
6
+ return `/memories/schemas/${encodeURIComponent(iri)}`;
7
+ }
8
+
9
+ export function memorySchemaEditPath(iri: string): string {
10
+ return `${memorySchemaPath(iri)}/edit`;
11
+ }
12
+
13
+ export function findMemorySchemaByRouteName<T extends { iri: string }>(
14
+ schemas: readonly T[],
15
+ routeName: string,
16
+ ): T | null {
17
+ return schemas.find((schema) => schema.iri === routeName) ?? null;
18
+ }
19
+
20
+ export type MemorySchemaView =
21
+ | { kind: "new" }
22
+ | { kind: "detail"; routeName: string }
23
+ | { kind: "edit"; routeName: string };
24
+
25
+ export function memorySchemaView(pathname: string, schemaName: string | undefined): MemorySchemaView | null {
26
+ const path = pathname.replace(/\/+$/, "");
27
+ if (path.endsWith(newMemorySchemaPath)) return { kind: "new" };
28
+ if (schemaName === undefined || !path.includes("/memories/schemas/")) return null;
29
+ return path.endsWith("/edit") ? { kind: "edit", routeName: schemaName } : { kind: "detail", routeName: schemaName };
30
+ }
@@ -0,0 +1,103 @@
1
+ import {
2
+ GQLMemorySchemaValueType,
3
+ type GQLMemory,
4
+ type GQLMemorySchemaFieldsFragment,
5
+ type GQLMemorySchemaPropertyFieldsFragment,
6
+ } from "@manta-eu/client";
7
+ import { isPresent } from "@manta-eu/lib/present";
8
+ import { valueTypeLabels } from "./schema-form";
9
+ import type { CreateRuleChatSubject } from "#routes/rules/components/CreateRuleChatModal";
10
+
11
+ export type RuleDraftRequest = { key: string; subject: CreateRuleChatSubject; suggestions: string[] };
12
+
13
+ type Schema = GQLMemorySchemaFieldsFragment;
14
+
15
+ type Property = GQLMemorySchemaPropertyFieldsFragment;
16
+
17
+ export function memorySchemaRuleContext(schema: Schema): string {
18
+ const fields = [...schema.properties]
19
+ .sort((a, b) => a.order - b.order)
20
+ .map((property) => {
21
+ const traits = [
22
+ valueTypeLabels[property.valueType],
23
+ property.multiValued ? "list" : null,
24
+ property.computed ? "computed by a rule" : null,
25
+ property.unit ? `unit ${property.unit}` : null,
26
+ isPresent(property.allowedValues) ? `allowed values: ${property.allowedValues.join(", ")}` : null,
27
+ ].filter(isPresent);
28
+ return `- ${property.label} <${property.path}>: ${traits.join("; ")}`;
29
+ });
30
+ return [
31
+ `The rule is about memories of the "${schema.label}" memory schema <${schema.iri}>.`,
32
+ ...(isPresent(fields) ? ["Its fields:", ...fields] : []),
33
+ ].join("\n");
34
+ }
35
+
36
+ const numberTypes: readonly string[] = [GQLMemorySchemaValueType.Integer, GQLMemorySchemaValueType.Decimal];
37
+ const dateTypes: readonly string[] = [GQLMemorySchemaValueType.Date, GQLMemorySchemaValueType.DateTime];
38
+
39
+ export function memorySchemaRuleSuggestions(schema: Schema): string[] {
40
+ const name = schema.label;
41
+ const written = schema.properties.filter((property) => !property.computed);
42
+ const computed = schema.properties.find((property) => property.computed);
43
+ const key = written.find((property) => property.keyProperty);
44
+ const number = written.find((property) => numberTypes.includes(property.valueType));
45
+ const choice = written.find((property) => isPresent(property.options));
46
+ const date = written.find((property) => dateTypes.includes(property.valueType));
47
+ const firstChoice = choice?.options[0];
48
+
49
+ return [
50
+ computed ? `Fill in ${computed.label} on every ${name} memory from its other fields` : null,
51
+ number && key ? `For each ${key.label}, use the latest company ${name}'s ${number.label} as the target` : null,
52
+ number && !key ? `Use the latest company ${name}'s ${number.label} as the target` : null,
53
+ choice && firstChoice
54
+ ? `Flag company ${name} memories whose ${choice.label} is "${firstChoice.label ?? firstChoice.value}"`
55
+ : null,
56
+ date ? `Flag company ${name} memories whose ${date.label} is in the next 14 days` : null,
57
+ ]
58
+ .filter((suggestion): suggestion is string => suggestion !== null)
59
+ .slice(0, 3);
60
+ }
61
+
62
+ export function schemaRuleDraft(schema: Schema): RuleDraftRequest {
63
+ return {
64
+ key: schema.iri,
65
+ subject: { name: schema.label, context: memorySchemaRuleContext(schema) },
66
+ suggestions: memorySchemaRuleSuggestions(schema),
67
+ };
68
+ }
69
+
70
+ export function computedPropertyRuleDraft(schema: Schema, property: Property): RuleDraftRequest {
71
+ return {
72
+ key: `${schema.iri} ${property.path}`,
73
+ subject: {
74
+ name: `${property.label} on ${schema.label}`,
75
+ context: [
76
+ memorySchemaRuleContext(schema),
77
+ `The rule computes ${property.label} <${property.path}>, writing it onto the same memory it reads.`,
78
+ ].join("\n"),
79
+ },
80
+ suggestions: [`Fill in ${property.label} on every ${schema.label} memory from its other fields`],
81
+ };
82
+ }
83
+
84
+ type ExampleMemory = Pick<GQLMemory, "iri" | "label" | "customPropertyValues">;
85
+
86
+ export function memoryRuleDraft(schema: Schema, memory: ExampleMemory): RuleDraftRequest {
87
+ const labelByPath = new Map(schema.properties.map((property) => [property.path, property.label]));
88
+ const values = memory.customPropertyValues
89
+ .filter(({ path, values: given }) => labelByPath.has(path) && isPresent(given))
90
+ .map(({ path, values: given }) => `- ${labelByPath.get(path)}: ${given.join(", ")}`);
91
+ return {
92
+ key: `${schema.iri} ${memory.iri}`,
93
+ subject: {
94
+ name: schema.label,
95
+ context: [
96
+ memorySchemaRuleContext(schema),
97
+ `An example company memory of this schema, "${memory.label}" <${memory.iri}>, holds:`,
98
+ ...(isPresent(values) ? values : ["- no field values yet"]),
99
+ ].join("\n"),
100
+ },
101
+ suggestions: memorySchemaRuleSuggestions(schema),
102
+ };
103
+ }