@ydtb/tk-scope-app 0.14.7

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 (504) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -0
  3. package/dist/src/auth/AuthStrategyGate.d.ts +27 -0
  4. package/dist/src/auth/AuthStrategyGate.d.ts.map +1 -0
  5. package/dist/src/auth/AuthStrategyGate.js +58 -0
  6. package/dist/src/auth/AuthStrategyGate.js.map +1 -0
  7. package/dist/src/auth/components/DefaultDeviceLogin.d.ts +7 -0
  8. package/dist/src/auth/components/DefaultDeviceLogin.d.ts.map +1 -0
  9. package/dist/src/auth/components/DefaultDeviceLogin.js +21 -0
  10. package/dist/src/auth/components/DefaultDeviceLogin.js.map +1 -0
  11. package/dist/src/auth/components/DefaultPinLogin.d.ts +8 -0
  12. package/dist/src/auth/components/DefaultPinLogin.d.ts.map +1 -0
  13. package/dist/src/auth/components/DefaultPinLogin.js +85 -0
  14. package/dist/src/auth/components/DefaultPinLogin.js.map +1 -0
  15. package/dist/src/auth/components/DefaultSessionLogin.d.ts +7 -0
  16. package/dist/src/auth/components/DefaultSessionLogin.d.ts.map +1 -0
  17. package/dist/src/auth/components/DefaultSessionLogin.js +21 -0
  18. package/dist/src/auth/components/DefaultSessionLogin.js.map +1 -0
  19. package/dist/src/auth/components/index.d.ts +12 -0
  20. package/dist/src/auth/components/index.d.ts.map +1 -0
  21. package/dist/src/auth/components/index.js +21 -0
  22. package/dist/src/auth/components/index.js.map +1 -0
  23. package/dist/src/auth/index.d.ts +8 -0
  24. package/dist/src/auth/index.d.ts.map +1 -0
  25. package/dist/src/auth/index.js +7 -0
  26. package/dist/src/auth/index.js.map +1 -0
  27. package/dist/src/auth/persistence/pin-storage.d.ts +19 -0
  28. package/dist/src/auth/persistence/pin-storage.d.ts.map +1 -0
  29. package/dist/src/auth/persistence/pin-storage.js +80 -0
  30. package/dist/src/auth/persistence/pin-storage.js.map +1 -0
  31. package/dist/src/auth/strategies/device.d.ts +16 -0
  32. package/dist/src/auth/strategies/device.d.ts.map +1 -0
  33. package/dist/src/auth/strategies/device.js +51 -0
  34. package/dist/src/auth/strategies/device.js.map +1 -0
  35. package/dist/src/auth/strategies/index.d.ts +13 -0
  36. package/dist/src/auth/strategies/index.d.ts.map +1 -0
  37. package/dist/src/auth/strategies/index.js +24 -0
  38. package/dist/src/auth/strategies/index.js.map +1 -0
  39. package/dist/src/auth/strategies/none.d.ts +9 -0
  40. package/dist/src/auth/strategies/none.d.ts.map +1 -0
  41. package/dist/src/auth/strategies/none.js +10 -0
  42. package/dist/src/auth/strategies/none.js.map +1 -0
  43. package/dist/src/auth/strategies/pin.d.ts +9 -0
  44. package/dist/src/auth/strategies/pin.d.ts.map +1 -0
  45. package/dist/src/auth/strategies/pin.js +48 -0
  46. package/dist/src/auth/strategies/pin.js.map +1 -0
  47. package/dist/src/auth/strategies/session.d.ts +9 -0
  48. package/dist/src/auth/strategies/session.d.ts.map +1 -0
  49. package/dist/src/auth/strategies/session.js +42 -0
  50. package/dist/src/auth/strategies/session.js.map +1 -0
  51. package/dist/src/auth/types.d.ts +2 -0
  52. package/dist/src/auth/types.d.ts.map +1 -0
  53. package/dist/src/auth/types.js +2 -0
  54. package/dist/src/auth/types.js.map +1 -0
  55. package/dist/src/client.d.ts +63 -0
  56. package/dist/src/client.d.ts.map +1 -0
  57. package/dist/src/client.js +81 -0
  58. package/dist/src/client.js.map +1 -0
  59. package/dist/src/components/BackendErrorGate.d.ts +10 -0
  60. package/dist/src/components/BackendErrorGate.d.ts.map +1 -0
  61. package/dist/src/components/BackendErrorGate.js +19 -0
  62. package/dist/src/components/BackendErrorGate.js.map +1 -0
  63. package/dist/src/components/ErrorBoundary.d.ts +17 -0
  64. package/dist/src/components/ErrorBoundary.d.ts.map +1 -0
  65. package/dist/src/components/ErrorBoundary.js +23 -0
  66. package/dist/src/components/ErrorBoundary.js.map +1 -0
  67. package/dist/src/components/NotificationPanel.d.ts +9 -0
  68. package/dist/src/components/NotificationPanel.d.ts.map +1 -0
  69. package/dist/src/components/NotificationPanel.js +146 -0
  70. package/dist/src/components/NotificationPanel.js.map +1 -0
  71. package/dist/src/components/scope/ChildScopeDetailPage.d.ts +8 -0
  72. package/dist/src/components/scope/ChildScopeDetailPage.d.ts.map +1 -0
  73. package/dist/src/components/scope/ChildScopeDetailPage.js +79 -0
  74. package/dist/src/components/scope/ChildScopeDetailPage.js.map +1 -0
  75. package/dist/src/components/scope/ChildScopeListPage.d.ts +6 -0
  76. package/dist/src/components/scope/ChildScopeListPage.d.ts.map +1 -0
  77. package/dist/src/components/scope/ChildScopeListPage.js +111 -0
  78. package/dist/src/components/scope/ChildScopeListPage.js.map +1 -0
  79. package/dist/src/components/scope/CreateChildScopeButton.d.ts +14 -0
  80. package/dist/src/components/scope/CreateChildScopeButton.d.ts.map +1 -0
  81. package/dist/src/components/scope/CreateChildScopeButton.js +18 -0
  82. package/dist/src/components/scope/CreateChildScopeButton.js.map +1 -0
  83. package/dist/src/components/scope/CreateScopeDialog.d.ts +9 -0
  84. package/dist/src/components/scope/CreateScopeDialog.d.ts.map +1 -0
  85. package/dist/src/components/scope/CreateScopeDialog.js +137 -0
  86. package/dist/src/components/scope/CreateScopeDialog.js.map +1 -0
  87. package/dist/src/components/scope/JoinScopeDialog.d.ts +8 -0
  88. package/dist/src/components/scope/JoinScopeDialog.d.ts.map +1 -0
  89. package/dist/src/components/scope/JoinScopeDialog.js +115 -0
  90. package/dist/src/components/scope/JoinScopeDialog.js.map +1 -0
  91. package/dist/src/components/scope/ProfileScopeSection.d.ts +11 -0
  92. package/dist/src/components/scope/ProfileScopeSection.d.ts.map +1 -0
  93. package/dist/src/components/scope/ProfileScopeSection.js +63 -0
  94. package/dist/src/components/scope/ProfileScopeSection.js.map +1 -0
  95. package/dist/src/components/scope/ScopeSwitcher.d.ts +14 -0
  96. package/dist/src/components/scope/ScopeSwitcher.d.ts.map +1 -0
  97. package/dist/src/components/scope/ScopeSwitcher.js +131 -0
  98. package/dist/src/components/scope/ScopeSwitcher.js.map +1 -0
  99. package/dist/src/components/scope/SwitchScopeDialog.d.ts +8 -0
  100. package/dist/src/components/scope/SwitchScopeDialog.d.ts.map +1 -0
  101. package/dist/src/components/scope/SwitchScopeDialog.js +60 -0
  102. package/dist/src/components/scope/SwitchScopeDialog.js.map +1 -0
  103. package/dist/src/components/scope/useChildScopePermissions.d.ts +7 -0
  104. package/dist/src/components/scope/useChildScopePermissions.d.ts.map +1 -0
  105. package/dist/src/components/scope/useChildScopePermissions.js +34 -0
  106. package/dist/src/components/scope/useChildScopePermissions.js.map +1 -0
  107. package/dist/src/contexts/auth/AuthContext.d.ts +13 -0
  108. package/dist/src/contexts/auth/AuthContext.d.ts.map +1 -0
  109. package/dist/src/contexts/auth/AuthContext.js +23 -0
  110. package/dist/src/contexts/auth/AuthContext.js.map +1 -0
  111. package/dist/src/contexts/backend/BackendStatusContext.d.ts +21 -0
  112. package/dist/src/contexts/backend/BackendStatusContext.d.ts.map +1 -0
  113. package/dist/src/contexts/backend/BackendStatusContext.js +36 -0
  114. package/dist/src/contexts/backend/BackendStatusContext.js.map +1 -0
  115. package/dist/src/contexts/command/CommandContext.d.ts +30 -0
  116. package/dist/src/contexts/command/CommandContext.d.ts.map +1 -0
  117. package/dist/src/contexts/command/CommandContext.js +75 -0
  118. package/dist/src/contexts/command/CommandContext.js.map +1 -0
  119. package/dist/src/contexts/command/PanelSlotsContext.d.ts +2 -0
  120. package/dist/src/contexts/command/PanelSlotsContext.d.ts.map +1 -0
  121. package/dist/src/contexts/command/PanelSlotsContext.js +2 -0
  122. package/dist/src/contexts/command/PanelSlotsContext.js.map +1 -0
  123. package/dist/src/contexts/command/PanelStackContext.d.ts +2 -0
  124. package/dist/src/contexts/command/PanelStackContext.d.ts.map +1 -0
  125. package/dist/src/contexts/command/PanelStackContext.js +2 -0
  126. package/dist/src/contexts/command/PanelStackContext.js.map +1 -0
  127. package/dist/src/contexts/command/SearchPanelContext.d.ts +55 -0
  128. package/dist/src/contexts/command/SearchPanelContext.d.ts.map +1 -0
  129. package/dist/src/contexts/command/SearchPanelContext.js +327 -0
  130. package/dist/src/contexts/command/SearchPanelContext.js.map +1 -0
  131. package/dist/src/contexts/config/AppConfigContext.d.ts +8 -0
  132. package/dist/src/contexts/config/AppConfigContext.d.ts.map +1 -0
  133. package/dist/src/contexts/config/AppConfigContext.js +21 -0
  134. package/dist/src/contexts/config/AppConfigContext.js.map +1 -0
  135. package/dist/src/contexts/help/HelpContext.d.ts +30 -0
  136. package/dist/src/contexts/help/HelpContext.d.ts.map +1 -0
  137. package/dist/src/contexts/help/HelpContext.js +73 -0
  138. package/dist/src/contexts/help/HelpContext.js.map +1 -0
  139. package/dist/src/contexts/index.d.ts +10 -0
  140. package/dist/src/contexts/index.d.ts.map +1 -0
  141. package/dist/src/contexts/index.js +10 -0
  142. package/dist/src/contexts/index.js.map +1 -0
  143. package/dist/src/contexts/navigation/NavigationContext.d.ts +23 -0
  144. package/dist/src/contexts/navigation/NavigationContext.d.ts.map +1 -0
  145. package/dist/src/contexts/navigation/NavigationContext.js +294 -0
  146. package/dist/src/contexts/navigation/NavigationContext.js.map +1 -0
  147. package/dist/src/contexts/navigation/NavigationRegistryContext.d.ts +9 -0
  148. package/dist/src/contexts/navigation/NavigationRegistryContext.d.ts.map +1 -0
  149. package/dist/src/contexts/navigation/NavigationRegistryContext.js +17 -0
  150. package/dist/src/contexts/navigation/NavigationRegistryContext.js.map +1 -0
  151. package/dist/src/contexts/scope/ScopeContext.d.ts +40 -0
  152. package/dist/src/contexts/scope/ScopeContext.d.ts.map +1 -0
  153. package/dist/src/contexts/scope/ScopeContext.js +141 -0
  154. package/dist/src/contexts/scope/ScopeContext.js.map +1 -0
  155. package/dist/src/contexts/scope/index.d.ts +3 -0
  156. package/dist/src/contexts/scope/index.d.ts.map +1 -0
  157. package/dist/src/contexts/scope/index.js +3 -0
  158. package/dist/src/contexts/scope/index.js.map +1 -0
  159. package/dist/src/contexts/scope/scopeRef.d.ts +10 -0
  160. package/dist/src/contexts/scope/scopeRef.d.ts.map +1 -0
  161. package/dist/src/contexts/scope/scopeRef.js +10 -0
  162. package/dist/src/contexts/scope/scopeRef.js.map +1 -0
  163. package/dist/src/contexts/sidebar/use-sidebar.d.ts +2 -0
  164. package/dist/src/contexts/sidebar/use-sidebar.d.ts.map +1 -0
  165. package/dist/src/contexts/sidebar/use-sidebar.js +2 -0
  166. package/dist/src/contexts/sidebar/use-sidebar.js.map +1 -0
  167. package/dist/src/contexts/theme/ThemeContext.d.ts +21 -0
  168. package/dist/src/contexts/theme/ThemeContext.d.ts.map +1 -0
  169. package/dist/src/contexts/theme/ThemeContext.js +79 -0
  170. package/dist/src/contexts/theme/ThemeContext.js.map +1 -0
  171. package/dist/src/create-app.d.ts +47 -0
  172. package/dist/src/create-app.d.ts.map +1 -0
  173. package/dist/src/create-app.js +242 -0
  174. package/dist/src/create-app.js.map +1 -0
  175. package/dist/src/dashboard/command/CommandDialog.d.ts +2 -0
  176. package/dist/src/dashboard/command/CommandDialog.d.ts.map +1 -0
  177. package/dist/src/dashboard/command/CommandDialog.js +18 -0
  178. package/dist/src/dashboard/command/CommandDialog.js.map +1 -0
  179. package/dist/src/dashboard/command/SearchPanelBody.d.ts +2 -0
  180. package/dist/src/dashboard/command/SearchPanelBody.d.ts.map +1 -0
  181. package/dist/src/dashboard/command/SearchPanelBody.js +178 -0
  182. package/dist/src/dashboard/command/SearchPanelBody.js.map +1 -0
  183. package/dist/src/dashboard/command/SearchPanelHeader.d.ts +2 -0
  184. package/dist/src/dashboard/command/SearchPanelHeader.d.ts.map +1 -0
  185. package/dist/src/dashboard/command/SearchPanelHeader.js +13 -0
  186. package/dist/src/dashboard/command/SearchPanelHeader.js.map +1 -0
  187. package/dist/src/dashboard/command/panels/GeneralPanel.d.ts +9 -0
  188. package/dist/src/dashboard/command/panels/GeneralPanel.d.ts.map +1 -0
  189. package/dist/src/dashboard/command/panels/GeneralPanel.js +12 -0
  190. package/dist/src/dashboard/command/panels/GeneralPanel.js.map +1 -0
  191. package/dist/src/dashboard/command/panels/NavigationPanel.d.ts +2 -0
  192. package/dist/src/dashboard/command/panels/NavigationPanel.d.ts.map +1 -0
  193. package/dist/src/dashboard/command/panels/NavigationPanel.js +74 -0
  194. package/dist/src/dashboard/command/panels/NavigationPanel.js.map +1 -0
  195. package/dist/src/dashboard/command/panels/PlaceholderPanel.d.ts +9 -0
  196. package/dist/src/dashboard/command/panels/PlaceholderPanel.d.ts.map +1 -0
  197. package/dist/src/dashboard/command/panels/PlaceholderPanel.js +12 -0
  198. package/dist/src/dashboard/command/panels/PlaceholderPanel.js.map +1 -0
  199. package/dist/src/dashboard/command/panels/ProfilePanel.d.ts +2 -0
  200. package/dist/src/dashboard/command/panels/ProfilePanel.d.ts.map +1 -0
  201. package/dist/src/dashboard/command/panels/ProfilePanel.js +133 -0
  202. package/dist/src/dashboard/command/panels/ProfilePanel.js.map +1 -0
  203. package/dist/src/dashboard/command/panels/SecurityPanel.d.ts +2 -0
  204. package/dist/src/dashboard/command/panels/SecurityPanel.d.ts.map +1 -0
  205. package/dist/src/dashboard/command/panels/SecurityPanel.js +237 -0
  206. package/dist/src/dashboard/command/panels/SecurityPanel.js.map +1 -0
  207. package/dist/src/dashboard/command/panels/ThemePanel.d.ts +2 -0
  208. package/dist/src/dashboard/command/panels/ThemePanel.d.ts.map +1 -0
  209. package/dist/src/dashboard/command/panels/ThemePanel.js +11 -0
  210. package/dist/src/dashboard/command/panels/ThemePanel.js.map +1 -0
  211. package/dist/src/dashboard/headers/MainHeader.d.ts +16 -0
  212. package/dist/src/dashboard/headers/MainHeader.d.ts.map +1 -0
  213. package/dist/src/dashboard/headers/MainHeader.js +16 -0
  214. package/dist/src/dashboard/headers/MainHeader.js.map +1 -0
  215. package/dist/src/dashboard/headers/MainHeaderDesktop.d.ts +4 -0
  216. package/dist/src/dashboard/headers/MainHeaderDesktop.d.ts.map +1 -0
  217. package/dist/src/dashboard/headers/MainHeaderDesktop.js +120 -0
  218. package/dist/src/dashboard/headers/MainHeaderDesktop.js.map +1 -0
  219. package/dist/src/dashboard/headers/MainHeaderMobile.d.ts +4 -0
  220. package/dist/src/dashboard/headers/MainHeaderMobile.d.ts.map +1 -0
  221. package/dist/src/dashboard/headers/MainHeaderMobile.js +14 -0
  222. package/dist/src/dashboard/headers/MainHeaderMobile.js.map +1 -0
  223. package/dist/src/dashboard/headers/NotificationsPopover.d.ts +2 -0
  224. package/dist/src/dashboard/headers/NotificationsPopover.d.ts.map +1 -0
  225. package/dist/src/dashboard/headers/NotificationsPopover.js +14 -0
  226. package/dist/src/dashboard/headers/NotificationsPopover.js.map +1 -0
  227. package/dist/src/dashboard/headers/ProfilePopover.d.ts +2 -0
  228. package/dist/src/dashboard/headers/ProfilePopover.d.ts.map +1 -0
  229. package/dist/src/dashboard/headers/ProfilePopover.js +83 -0
  230. package/dist/src/dashboard/headers/ProfilePopover.js.map +1 -0
  231. package/dist/src/dashboard/headers/ToolHeader.d.ts +2 -0
  232. package/dist/src/dashboard/headers/ToolHeader.d.ts.map +1 -0
  233. package/dist/src/dashboard/headers/ToolHeader.js +16 -0
  234. package/dist/src/dashboard/headers/ToolHeader.js.map +1 -0
  235. package/dist/src/dashboard/help/HelpPanel.d.ts +3 -0
  236. package/dist/src/dashboard/help/HelpPanel.d.ts.map +1 -0
  237. package/dist/src/dashboard/help/HelpPanel.js +451 -0
  238. package/dist/src/dashboard/help/HelpPanel.js.map +1 -0
  239. package/dist/src/dashboard/index.d.ts +16 -0
  240. package/dist/src/dashboard/index.d.ts.map +1 -0
  241. package/dist/src/dashboard/index.js +16 -0
  242. package/dist/src/dashboard/index.js.map +1 -0
  243. package/dist/src/dashboard/layout/DashboardLayout.d.ts +23 -0
  244. package/dist/src/dashboard/layout/DashboardLayout.d.ts.map +1 -0
  245. package/dist/src/dashboard/layout/DashboardLayout.js +15 -0
  246. package/dist/src/dashboard/layout/DashboardLayout.js.map +1 -0
  247. package/dist/src/dashboard/layout/DashboardSidebarContent.d.ts +2 -0
  248. package/dist/src/dashboard/layout/DashboardSidebarContent.d.ts.map +1 -0
  249. package/dist/src/dashboard/layout/DashboardSidebarContent.js +33 -0
  250. package/dist/src/dashboard/layout/DashboardSidebarContent.js.map +1 -0
  251. package/dist/src/dashboard/layout/SidebarDrawer.d.ts +2 -0
  252. package/dist/src/dashboard/layout/SidebarDrawer.d.ts.map +1 -0
  253. package/dist/src/dashboard/layout/SidebarDrawer.js +33 -0
  254. package/dist/src/dashboard/layout/SidebarDrawer.js.map +1 -0
  255. package/dist/src/dashboard/layout/ToolSidebar.d.ts +9 -0
  256. package/dist/src/dashboard/layout/ToolSidebar.d.ts.map +1 -0
  257. package/dist/src/dashboard/layout/ToolSidebar.js +11 -0
  258. package/dist/src/dashboard/layout/ToolSidebar.js.map +1 -0
  259. package/dist/src/dashboard/navigation/IconRail.d.ts +11 -0
  260. package/dist/src/dashboard/navigation/IconRail.d.ts.map +1 -0
  261. package/dist/src/dashboard/navigation/IconRail.js +47 -0
  262. package/dist/src/dashboard/navigation/IconRail.js.map +1 -0
  263. package/dist/src/dashboard/navigation/MoreToolsPopover.d.ts +2 -0
  264. package/dist/src/dashboard/navigation/MoreToolsPopover.d.ts.map +1 -0
  265. package/dist/src/dashboard/navigation/MoreToolsPopover.js +22 -0
  266. package/dist/src/dashboard/navigation/MoreToolsPopover.js.map +1 -0
  267. package/dist/src/dashboard/navigation/icon-rail.d.ts +8 -0
  268. package/dist/src/dashboard/navigation/icon-rail.d.ts.map +1 -0
  269. package/dist/src/dashboard/navigation/icon-rail.js +36 -0
  270. package/dist/src/dashboard/navigation/icon-rail.js.map +1 -0
  271. package/dist/src/dashboard/navigation/use-active-tool.d.ts +2 -0
  272. package/dist/src/dashboard/navigation/use-active-tool.d.ts.map +1 -0
  273. package/dist/src/dashboard/navigation/use-active-tool.js +41 -0
  274. package/dist/src/dashboard/navigation/use-active-tool.js.map +1 -0
  275. package/dist/src/dashboard/settings/ThemeSettings.d.ts +2 -0
  276. package/dist/src/dashboard/settings/ThemeSettings.d.ts.map +1 -0
  277. package/dist/src/dashboard/settings/ThemeSettings.js +49 -0
  278. package/dist/src/dashboard/settings/ThemeSettings.js.map +1 -0
  279. package/dist/src/guards/SetupGate.d.ts +9 -0
  280. package/dist/src/guards/SetupGate.d.ts.map +1 -0
  281. package/dist/src/guards/SetupGate.js +30 -0
  282. package/dist/src/guards/SetupGate.js.map +1 -0
  283. package/dist/src/guards/UnifiedGuard.d.ts +32 -0
  284. package/dist/src/guards/UnifiedGuard.d.ts.map +1 -0
  285. package/dist/src/guards/UnifiedGuard.js +258 -0
  286. package/dist/src/guards/UnifiedGuard.js.map +1 -0
  287. package/dist/src/guards/index.d.ts +3 -0
  288. package/dist/src/guards/index.d.ts.map +1 -0
  289. package/dist/src/guards/index.js +3 -0
  290. package/dist/src/guards/index.js.map +1 -0
  291. package/dist/src/hooks/index.d.ts +9 -0
  292. package/dist/src/hooks/index.d.ts.map +1 -0
  293. package/dist/src/hooks/index.js +9 -0
  294. package/dist/src/hooks/index.js.map +1 -0
  295. package/dist/src/hooks/useCheckAccess.d.ts +16 -0
  296. package/dist/src/hooks/useCheckAccess.d.ts.map +1 -0
  297. package/dist/src/hooks/useCheckAccess.js +25 -0
  298. package/dist/src/hooks/useCheckAccess.js.map +1 -0
  299. package/dist/src/hooks/useCreateScope.d.ts +42 -0
  300. package/dist/src/hooks/useCreateScope.d.ts.map +1 -0
  301. package/dist/src/hooks/useCreateScope.js +28 -0
  302. package/dist/src/hooks/useCreateScope.js.map +1 -0
  303. package/dist/src/hooks/useInvitations.d.ts +82 -0
  304. package/dist/src/hooks/useInvitations.d.ts.map +1 -0
  305. package/dist/src/hooks/useInvitations.js +39 -0
  306. package/dist/src/hooks/useInvitations.js.map +1 -0
  307. package/dist/src/hooks/useJoinCode.d.ts +52 -0
  308. package/dist/src/hooks/useJoinCode.d.ts.map +1 -0
  309. package/dist/src/hooks/useJoinCode.js +37 -0
  310. package/dist/src/hooks/useJoinCode.js.map +1 -0
  311. package/dist/src/hooks/usePreference.d.ts +20 -0
  312. package/dist/src/hooks/usePreference.d.ts.map +1 -0
  313. package/dist/src/hooks/usePreference.js +132 -0
  314. package/dist/src/hooks/usePreference.js.map +1 -0
  315. package/dist/src/hooks/useScopeList.d.ts +32 -0
  316. package/dist/src/hooks/useScopeList.d.ts.map +1 -0
  317. package/dist/src/hooks/useScopeList.js +24 -0
  318. package/dist/src/hooks/useScopeList.js.map +1 -0
  319. package/dist/src/hooks/useScopeMenuPolicy.d.ts +23 -0
  320. package/dist/src/hooks/useScopeMenuPolicy.d.ts.map +1 -0
  321. package/dist/src/hooks/useScopeMenuPolicy.js +59 -0
  322. package/dist/src/hooks/useScopeMenuPolicy.js.map +1 -0
  323. package/dist/src/hooks/useScopePermissions.d.ts +9 -0
  324. package/dist/src/hooks/useScopePermissions.d.ts.map +1 -0
  325. package/dist/src/hooks/useScopePermissions.js +84 -0
  326. package/dist/src/hooks/useScopePermissions.js.map +1 -0
  327. package/dist/src/lib/api-client.d.ts +27 -0
  328. package/dist/src/lib/api-client.d.ts.map +1 -0
  329. package/dist/src/lib/api-client.js +45 -0
  330. package/dist/src/lib/api-client.js.map +1 -0
  331. package/dist/src/lib/backend-status.d.ts +14 -0
  332. package/dist/src/lib/backend-status.d.ts.map +1 -0
  333. package/dist/src/lib/backend-status.js +27 -0
  334. package/dist/src/lib/backend-status.js.map +1 -0
  335. package/dist/src/lib/config.d.ts +71 -0
  336. package/dist/src/lib/config.d.ts.map +1 -0
  337. package/dist/src/lib/config.js +7 -0
  338. package/dist/src/lib/config.js.map +1 -0
  339. package/dist/src/lib/icon-resolver.d.ts +2 -0
  340. package/dist/src/lib/icon-resolver.d.ts.map +1 -0
  341. package/dist/src/lib/icon-resolver.js +2 -0
  342. package/dist/src/lib/icon-resolver.js.map +1 -0
  343. package/dist/src/lib/index.d.ts +13 -0
  344. package/dist/src/lib/index.d.ts.map +1 -0
  345. package/dist/src/lib/index.js +13 -0
  346. package/dist/src/lib/index.js.map +1 -0
  347. package/dist/src/lib/navigation-tools.d.ts +27 -0
  348. package/dist/src/lib/navigation-tools.d.ts.map +1 -0
  349. package/dist/src/lib/navigation-tools.js +49 -0
  350. package/dist/src/lib/navigation-tools.js.map +1 -0
  351. package/dist/src/lib/onboarding-registry.d.ts +14 -0
  352. package/dist/src/lib/onboarding-registry.d.ts.map +1 -0
  353. package/dist/src/lib/onboarding-registry.js +12 -0
  354. package/dist/src/lib/onboarding-registry.js.map +1 -0
  355. package/dist/src/lib/permissions-store.d.ts +12 -0
  356. package/dist/src/lib/permissions-store.d.ts.map +1 -0
  357. package/dist/src/lib/permissions-store.js +12 -0
  358. package/dist/src/lib/permissions-store.js.map +1 -0
  359. package/dist/src/lib/platform-api.d.ts +3527 -0
  360. package/dist/src/lib/platform-api.d.ts.map +1 -0
  361. package/dist/src/lib/platform-api.js +26 -0
  362. package/dist/src/lib/platform-api.js.map +1 -0
  363. package/dist/src/lib/resolve-redirect.d.ts +36 -0
  364. package/dist/src/lib/resolve-redirect.d.ts.map +1 -0
  365. package/dist/src/lib/resolve-redirect.js +91 -0
  366. package/dist/src/lib/resolve-redirect.js.map +1 -0
  367. package/dist/src/lib/scope-menu-policy.d.ts +13 -0
  368. package/dist/src/lib/scope-menu-policy.d.ts.map +1 -0
  369. package/dist/src/lib/scope-menu-policy.js +15 -0
  370. package/dist/src/lib/scope-menu-policy.js.map +1 -0
  371. package/dist/src/lib/scope-query-keys.d.ts +38 -0
  372. package/dist/src/lib/scope-query-keys.d.ts.map +1 -0
  373. package/dist/src/lib/scope-query-keys.js +35 -0
  374. package/dist/src/lib/scope-query-keys.js.map +1 -0
  375. package/dist/src/lib/scopeLink.d.ts +24 -0
  376. package/dist/src/lib/scopeLink.d.ts.map +1 -0
  377. package/dist/src/lib/scopeLink.js +57 -0
  378. package/dist/src/lib/scopeLink.js.map +1 -0
  379. package/dist/src/lib/tool-api-types.d.ts +40 -0
  380. package/dist/src/lib/tool-api-types.d.ts.map +1 -0
  381. package/dist/src/lib/tool-api-types.js +23 -0
  382. package/dist/src/lib/tool-api-types.js.map +1 -0
  383. package/dist/src/lib/types.d.ts +122 -0
  384. package/dist/src/lib/types.d.ts.map +1 -0
  385. package/dist/src/lib/types.js +47 -0
  386. package/dist/src/lib/types.js.map +1 -0
  387. package/dist/src/lib/withDashboardChrome.d.ts +18 -0
  388. package/dist/src/lib/withDashboardChrome.d.ts.map +1 -0
  389. package/dist/src/lib/withDashboardChrome.js +46 -0
  390. package/dist/src/lib/withDashboardChrome.js.map +1 -0
  391. package/dist/src/onboarding/CreateScopeWizardStep.d.ts +14 -0
  392. package/dist/src/onboarding/CreateScopeWizardStep.d.ts.map +1 -0
  393. package/dist/src/onboarding/CreateScopeWizardStep.js +109 -0
  394. package/dist/src/onboarding/CreateScopeWizardStep.js.map +1 -0
  395. package/dist/src/onboarding/ResolveStep.d.ts +17 -0
  396. package/dist/src/onboarding/ResolveStep.d.ts.map +1 -0
  397. package/dist/src/onboarding/ResolveStep.js +101 -0
  398. package/dist/src/onboarding/ResolveStep.js.map +1 -0
  399. package/dist/src/onboarding/StepProps.d.ts +10 -0
  400. package/dist/src/onboarding/StepProps.d.ts.map +1 -0
  401. package/dist/src/onboarding/StepProps.js +2 -0
  402. package/dist/src/onboarding/StepProps.js.map +1 -0
  403. package/dist/src/onboarding/WizardContext.d.ts +20 -0
  404. package/dist/src/onboarding/WizardContext.d.ts.map +1 -0
  405. package/dist/src/onboarding/WizardContext.js +17 -0
  406. package/dist/src/onboarding/WizardContext.js.map +1 -0
  407. package/dist/src/onboarding/WizardPage.d.ts +18 -0
  408. package/dist/src/onboarding/WizardPage.d.ts.map +1 -0
  409. package/dist/src/onboarding/WizardPage.js +9 -0
  410. package/dist/src/onboarding/WizardPage.js.map +1 -0
  411. package/dist/src/onboarding/WizardShell.d.ts +43 -0
  412. package/dist/src/onboarding/WizardShell.d.ts.map +1 -0
  413. package/dist/src/onboarding/WizardShell.js +162 -0
  414. package/dist/src/onboarding/WizardShell.js.map +1 -0
  415. package/dist/src/onboarding/index.d.ts +11 -0
  416. package/dist/src/onboarding/index.d.ts.map +1 -0
  417. package/dist/src/onboarding/index.js +8 -0
  418. package/dist/src/onboarding/index.js.map +1 -0
  419. package/dist/src/onboarding/sortSteps.d.ts +15 -0
  420. package/dist/src/onboarding/sortSteps.d.ts.map +1 -0
  421. package/dist/src/onboarding/sortSteps.js +93 -0
  422. package/dist/src/onboarding/sortSteps.js.map +1 -0
  423. package/dist/src/onboarding/steps/AddPasskeyStep.d.ts +3 -0
  424. package/dist/src/onboarding/steps/AddPasskeyStep.d.ts.map +1 -0
  425. package/dist/src/onboarding/steps/AddPasskeyStep.js +54 -0
  426. package/dist/src/onboarding/steps/AddPasskeyStep.js.map +1 -0
  427. package/dist/src/onboarding/steps/SetupWizardPage.d.ts +2 -0
  428. package/dist/src/onboarding/steps/SetupWizardPage.d.ts.map +1 -0
  429. package/dist/src/onboarding/steps/SetupWizardPage.js +93 -0
  430. package/dist/src/onboarding/steps/SetupWizardPage.js.map +1 -0
  431. package/dist/src/onboarding/steps/setup-steps.d.ts +6 -0
  432. package/dist/src/onboarding/steps/setup-steps.d.ts.map +1 -0
  433. package/dist/src/onboarding/steps/setup-steps.js +75 -0
  434. package/dist/src/onboarding/steps/setup-steps.js.map +1 -0
  435. package/dist/src/pages/AcceptInvitePage.d.ts +2 -0
  436. package/dist/src/pages/AcceptInvitePage.d.ts.map +1 -0
  437. package/dist/src/pages/AcceptInvitePage.js +103 -0
  438. package/dist/src/pages/AcceptInvitePage.js.map +1 -0
  439. package/dist/src/pages/BackendErrorPage.d.ts +6 -0
  440. package/dist/src/pages/BackendErrorPage.d.ts.map +1 -0
  441. package/dist/src/pages/BackendErrorPage.js +6 -0
  442. package/dist/src/pages/BackendErrorPage.js.map +1 -0
  443. package/dist/src/pages/ContextSelectionPage.d.ts +2 -0
  444. package/dist/src/pages/ContextSelectionPage.d.ts.map +1 -0
  445. package/dist/src/pages/ContextSelectionPage.js +166 -0
  446. package/dist/src/pages/ContextSelectionPage.js.map +1 -0
  447. package/dist/src/pages/DefaultCreateScopePage.d.ts +17 -0
  448. package/dist/src/pages/DefaultCreateScopePage.d.ts.map +1 -0
  449. package/dist/src/pages/DefaultCreateScopePage.js +50 -0
  450. package/dist/src/pages/DefaultCreateScopePage.js.map +1 -0
  451. package/dist/src/pages/ForgotPasswordPage.d.ts +2 -0
  452. package/dist/src/pages/ForgotPasswordPage.d.ts.map +1 -0
  453. package/dist/src/pages/ForgotPasswordPage.js +44 -0
  454. package/dist/src/pages/ForgotPasswordPage.js.map +1 -0
  455. package/dist/src/pages/GetStartedPage.d.ts +6 -0
  456. package/dist/src/pages/GetStartedPage.d.ts.map +1 -0
  457. package/dist/src/pages/GetStartedPage.js +49 -0
  458. package/dist/src/pages/GetStartedPage.js.map +1 -0
  459. package/dist/src/pages/InviteErrorPage.d.ts +2 -0
  460. package/dist/src/pages/InviteErrorPage.d.ts.map +1 -0
  461. package/dist/src/pages/InviteErrorPage.js +42 -0
  462. package/dist/src/pages/InviteErrorPage.js.map +1 -0
  463. package/dist/src/pages/LoginPage.d.ts +2 -0
  464. package/dist/src/pages/LoginPage.d.ts.map +1 -0
  465. package/dist/src/pages/LoginPage.js +63 -0
  466. package/dist/src/pages/LoginPage.js.map +1 -0
  467. package/dist/src/pages/NoAccessPage.d.ts +2 -0
  468. package/dist/src/pages/NoAccessPage.d.ts.map +1 -0
  469. package/dist/src/pages/NoAccessPage.js +35 -0
  470. package/dist/src/pages/NoAccessPage.js.map +1 -0
  471. package/dist/src/pages/NotFoundPage.d.ts +2 -0
  472. package/dist/src/pages/NotFoundPage.d.ts.map +1 -0
  473. package/dist/src/pages/NotFoundPage.js +8 -0
  474. package/dist/src/pages/NotFoundPage.js.map +1 -0
  475. package/dist/src/pages/PostLoginResolver.d.ts +9 -0
  476. package/dist/src/pages/PostLoginResolver.d.ts.map +1 -0
  477. package/dist/src/pages/PostLoginResolver.js +50 -0
  478. package/dist/src/pages/PostLoginResolver.js.map +1 -0
  479. package/dist/src/pages/ProfilePage.d.ts +2 -0
  480. package/dist/src/pages/ProfilePage.d.ts.map +1 -0
  481. package/dist/src/pages/ProfilePage.js +353 -0
  482. package/dist/src/pages/ProfilePage.js.map +1 -0
  483. package/dist/src/pages/ResetPasswordPage.d.ts +2 -0
  484. package/dist/src/pages/ResetPasswordPage.d.ts.map +1 -0
  485. package/dist/src/pages/ResetPasswordPage.js +55 -0
  486. package/dist/src/pages/ResetPasswordPage.js.map +1 -0
  487. package/dist/src/pages/SignupPage.d.ts +2 -0
  488. package/dist/src/pages/SignupPage.d.ts.map +1 -0
  489. package/dist/src/pages/SignupPage.js +54 -0
  490. package/dist/src/pages/SignupPage.js.map +1 -0
  491. package/dist/src/pages/index.d.ts +15 -0
  492. package/dist/src/pages/index.d.ts.map +1 -0
  493. package/dist/src/pages/index.js +15 -0
  494. package/dist/src/pages/index.js.map +1 -0
  495. package/dist/src/platform-surface.d.ts +26 -0
  496. package/dist/src/platform-surface.d.ts.map +1 -0
  497. package/dist/src/platform-surface.js +302 -0
  498. package/dist/src/platform-surface.js.map +1 -0
  499. package/dist/testing/index.d.ts +2 -0
  500. package/dist/testing/index.d.ts.map +1 -0
  501. package/dist/testing/index.js +2 -0
  502. package/dist/testing/index.js.map +1 -0
  503. package/dist/tsconfig.tsbuildinfo +1 -0
  504. package/package.json +119 -0
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Join code hooks — validate + redeem.
3
+ *
4
+ * Adapts the scope extension's joinCodes.use endpoint to match the
5
+ * old authClient.scope.joinCode.validate/redeem API shape.
6
+ *
7
+ * Used by JoinScopeDialog.
8
+ */
9
+ import { joinCodesApi } from "../lib/platform-api.js";
10
+ /**
11
+ * Validate a join code. Returns the old-style { valid, scope, error } shape.
12
+ *
13
+ * The scope extension's `use` endpoint throws on invalid codes rather than
14
+ * returning `{ valid: false }`. This function adapts that to the shape
15
+ * JoinScopeDialog expects.
16
+ */
17
+ export async function validateJoinCode(code) {
18
+ try {
19
+ const result = await joinCodesApi.$client.use({ code });
20
+ const scope = result;
21
+ if (scope?.scope) {
22
+ return { valid: true, scope: scope.scope };
23
+ }
24
+ return { valid: false, error: "Invalid or expired code" };
25
+ }
26
+ catch (err) {
27
+ const message = err instanceof Error ? err.message : "Invalid or expired code";
28
+ return { valid: false, error: message };
29
+ }
30
+ }
31
+ /**
32
+ * Redeem a join code (join the scope).
33
+ */
34
+ export async function redeemJoinCode(code) {
35
+ return joinCodesApi.$client.use({ code });
36
+ }
37
+ //# sourceMappingURL=useJoinCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useJoinCode.js","sourceRoot":"","sources":["../../../src/hooks/useJoinCode.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAQrD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAY;IACjD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;QACvD,MAAM,KAAK,GAAG,MAAuE,CAAA;QACrF,IAAI,KAAK,EAAE,KAAK,EAAE,CAAC;YACjB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAA;QAC5C,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,yBAAyB,EAAE,CAAA;IAC3D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,yBAAyB,CAAA;QAC9E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;IACzC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY;IAC/C,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;AAC3C,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Generic React hook for reading and writing user preferences with
3
+ * localStorage fallback and server sync via TanStack Query + oRPC.
4
+ *
5
+ * 1. On mount: initialData from localStorage (instant, avoids flash).
6
+ * 2. useQuery fetches server value via oRPC in the background.
7
+ * 3. If the API returns a value, updates localStorage cache.
8
+ * 4. If the API fails (offline), continues using localStorage value.
9
+ * 5. `setValue`: writes to localStorage immediately (optimistic), updates
10
+ * query cache, then fires `preferences.set` to persist server-side.
11
+ */
12
+ export declare function usePreference<T>(key: string, defaultValue: T, options?: {
13
+ scope?: string;
14
+ scopeId?: string;
15
+ }): {
16
+ value: T;
17
+ setValue: (newValue: T) => void;
18
+ isLoading: boolean;
19
+ };
20
+ //# sourceMappingURL=usePreference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePreference.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePreference.ts"],"names":[],"mappings":"AAmCA;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,EACf,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7C;IACD,KAAK,EAAE,CAAC,CAAA;IACR,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAA;IAC/B,SAAS,EAAE,OAAO,CAAA;CACnB,CAgGA"}
@@ -0,0 +1,132 @@
1
+ import { useCallback, useEffect, useMemo, useRef } from "react";
2
+ import { useQuery, useQueryClient } from "@ydtb/tk-scope-query-client";
3
+ import { useAuth } from "../contexts/auth/AuthContext.js";
4
+ import { preferencesApi } from "../lib/platform-api.js";
5
+ /**
6
+ * Build the localStorage key for a preference.
7
+ * Format: `ydtb-pref:{key}` or `ydtb-pref:{scopeId}:{key}` if scope-scoped.
8
+ */
9
+ function storageKey(key, scope, scopeId) {
10
+ return scope && scopeId ? `ydtb-pref:${scope}:${scopeId}:${key}` : `ydtb-pref:${key}`;
11
+ }
12
+ function readFromStorage(lsKey, defaultValue) {
13
+ if (typeof window === "undefined")
14
+ return defaultValue;
15
+ try {
16
+ const raw = localStorage.getItem(lsKey);
17
+ if (raw !== null) {
18
+ return JSON.parse(raw);
19
+ }
20
+ }
21
+ catch {
22
+ // ignore parse / access errors
23
+ }
24
+ return defaultValue;
25
+ }
26
+ function writeToStorage(lsKey, value) {
27
+ if (typeof window === "undefined")
28
+ return;
29
+ try {
30
+ localStorage.setItem(lsKey, JSON.stringify(value));
31
+ }
32
+ catch {
33
+ // ignore quota / access errors
34
+ }
35
+ }
36
+ /**
37
+ * Generic React hook for reading and writing user preferences with
38
+ * localStorage fallback and server sync via TanStack Query + oRPC.
39
+ *
40
+ * 1. On mount: initialData from localStorage (instant, avoids flash).
41
+ * 2. useQuery fetches server value via oRPC in the background.
42
+ * 3. If the API returns a value, updates localStorage cache.
43
+ * 4. If the API fails (offline), continues using localStorage value.
44
+ * 5. `setValue`: writes to localStorage immediately (optimistic), updates
45
+ * query cache, then fires `preferences.set` to persist server-side.
46
+ */
47
+ export function usePreference(key, defaultValue, options) {
48
+ const { session } = useAuth();
49
+ const scope = options?.scope;
50
+ const scopeId = options?.scopeId;
51
+ const lsKey = storageKey(key, scope, scopeId);
52
+ const queryClient = useQueryClient();
53
+ // Read localStorage value once for initialData
54
+ const initialDataRef = useRef(readFromStorage(lsKey, defaultValue));
55
+ const queryOptions = preferencesApi.get.queryOptions({
56
+ input: scope && scopeId ? { key, scope, scopeId } : { key },
57
+ });
58
+ const { data: serverResult, isLoading } = useQuery({
59
+ ...queryOptions,
60
+ // Skip when not authenticated — localStorage value is sufficient
61
+ enabled: !!session,
62
+ // Use placeholderData instead of initialData to avoid type mismatch
63
+ // while still preventing flash (shows localStorage value until server responds)
64
+ placeholderData: {
65
+ key,
66
+ value: JSON.stringify(initialDataRef.current),
67
+ scope: scope ?? "global",
68
+ scopeId: scopeId ?? null,
69
+ },
70
+ });
71
+ // Parse the server value, falling back to default.
72
+ // Memoize on the serialized string so consumers get a stable reference
73
+ // (JSON.parse creates a new object every call, which would break
74
+ // reference-equality checks in useEffect deps downstream).
75
+ const serializedValue = serverResult?.value ?? null;
76
+ const defaultValueRef = useRef(defaultValue);
77
+ defaultValueRef.current = defaultValue;
78
+ const value = useMemo(() => {
79
+ try {
80
+ if (serializedValue !== null && serializedValue !== undefined) {
81
+ return JSON.parse(serializedValue);
82
+ }
83
+ }
84
+ catch {
85
+ // ignore parse errors
86
+ }
87
+ return defaultValueRef.current;
88
+ }, [serializedValue]);
89
+ // Sync server value to localStorage when query data updates
90
+ const prevValueRef = useRef(null);
91
+ useEffect(() => {
92
+ const serialized = serverResult?.value ?? null;
93
+ if (serialized !== null && serialized !== prevValueRef.current) {
94
+ prevValueRef.current = serialized;
95
+ try {
96
+ const parsed = JSON.parse(serialized);
97
+ writeToStorage(lsKey, parsed);
98
+ }
99
+ catch {
100
+ // ignore
101
+ }
102
+ }
103
+ }, [serverResult, lsKey]);
104
+ const queryKeyRef = useRef(queryOptions.queryKey);
105
+ queryKeyRef.current = queryOptions.queryKey;
106
+ const setValue = useCallback((newValue) => {
107
+ const serialized = JSON.stringify(newValue);
108
+ // Optimistic local update
109
+ writeToStorage(lsKey, newValue);
110
+ // Update the query cache immediately
111
+ queryClient.setQueryData(queryKeyRef.current, {
112
+ key,
113
+ value: serialized,
114
+ scope: scope ?? "global",
115
+ scopeId: scopeId ?? null,
116
+ });
117
+ // Fire-and-forget server persist (skip when not authenticated)
118
+ if (session) {
119
+ preferencesApi.$client
120
+ .set({
121
+ key,
122
+ value: serialized,
123
+ ...(scope && scopeId ? { scope, scopeId } : {}),
124
+ })
125
+ .catch(() => {
126
+ // Silently ignore — localStorage already has the value
127
+ });
128
+ }
129
+ }, [key, scope, scopeId, lsKey, queryClient, session]);
130
+ return { value, setValue, isLoading };
131
+ }
132
+ //# sourceMappingURL=usePreference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePreference.js","sourceRoot":"","sources":["../../../src/hooks/usePreference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAkC,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEvD;;;GAGG;AACH,SAAS,UAAU,CAAC,GAAW,EAAE,KAAc,EAAE,OAAgB;IAC/D,OAAO,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,aAAa,KAAK,IAAI,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,aAAa,GAAG,EAAE,CAAA;AACvF,CAAC;AAED,SAAS,eAAe,CAAI,KAAa,EAAE,YAAe;IACxD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,YAAY,CAAA;IACtD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACvC,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAM,CAAA;QAC7B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,+BAA+B;IACjC,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC;AAED,SAAS,cAAc,CAAI,KAAa,EAAE,KAAQ;IAChD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAM;IACzC,IAAI,CAAC;QACH,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,SA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AQ,CAAC,CAAA;QAE3C,0BAA0B;QAC1B,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAE/B,qCAAqC;QACrC,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE;YAC5C,GAAG;YACH,KAAK,EAAE,UAAU;YACjB,KAAK,EAAE,KAAK,IAAI,QAAQ;YACxB,OAAO,EAAE,OAAO,IAAI,IAAI;SACzB,CAAC,CAAA;QAEF,+DAA+D;QAC/D,IAAI,OAAO,EAAE,CAAC;YACZ,cAAc,CAAC,OAAO;iBACnB,GAAG,CAAC;gBACH,GAAG;gBACH,KAAK,EAAE,UAAU;gBACjB,GAAG,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAChD,CAAC;iBACD,KAAK,CAAC,GAAG,EAAE;gBACV,uDAAuD;YACzD,CAAC,CAAC,CAAA;QACN,CAAC;IACH,CAAC,EACD,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CACnD,CAAA;IAED,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAA;AACvC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Scope listing hook.
3
+ *
4
+ * Single source of truth for fetching user's scope memberships.
5
+ * Used by ScopeSwitcher, SwitchScopeDialog, ProfileScopeSection,
6
+ * and MainHeaderDesktop.
7
+ */
8
+ export interface ScopeListItem {
9
+ id: string;
10
+ type: string;
11
+ name: string;
12
+ slug: string | null;
13
+ logo: string | null;
14
+ parentScope: string | null;
15
+ parentScopeId: string | null;
16
+ role: string;
17
+ metadata?: unknown;
18
+ childScopeCount?: number;
19
+ }
20
+ /**
21
+ * Fetch all scopes the current user is a member of.
22
+ * Optionally filter by scope type.
23
+ */
24
+ export declare function useScopeList(options?: {
25
+ type?: string;
26
+ enabled?: boolean;
27
+ staleTime?: number;
28
+ }): {
29
+ scopes: ScopeListItem[];
30
+ isPending: boolean;
31
+ };
32
+ //# sourceMappingURL=useScopeList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScopeList.d.ts","sourceRoot":"","sources":["../../../src/hooks/useScopeList.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE;;;EAY9F"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Scope listing hook.
3
+ *
4
+ * Single source of truth for fetching user's scope memberships.
5
+ * Used by ScopeSwitcher, SwitchScopeDialog, ProfileScopeSection,
6
+ * and MainHeaderDesktop.
7
+ */
8
+ import { useQuery } from "@ydtb/tk-scope-query-client";
9
+ import { scopeApi } from "../lib/platform-api.js";
10
+ /**
11
+ * Fetch all scopes the current user is a member of.
12
+ * Optionally filter by scope type.
13
+ */
14
+ export function useScopeList(options) {
15
+ const { type, enabled = true, staleTime } = options ?? {};
16
+ const { data, isPending } = useQuery({
17
+ ...scopeApi.list.queryOptions({ input: { type } }),
18
+ enabled,
19
+ ...(staleTime !== undefined ? { staleTime } : {}),
20
+ });
21
+ const scopes = (data?.scopes ?? []);
22
+ return { scopes, isPending };
23
+ }
24
+ //# sourceMappingURL=useScopeList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScopeList.js","sourceRoot":"","sources":["../../../src/hooks/useScopeList.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAejD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,OAAkE;IAC7F,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAEzD,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;QACnC,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;QAClD,OAAO;QACP,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClD,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,CAAoB,CAAA;IAEtD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;AAC9B,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type ScopeMenuMode, type ScopeTypeInfo } from "@ydtb/tk-scope/client";
2
+ import { type ScopeListItem } from "./useScopeList.ts";
3
+ export interface ScopeMenuPolicy {
4
+ mode: ScopeMenuMode;
5
+ scopeConfig?: ScopeTypeInfo;
6
+ childScopeType: string | null;
7
+ childScopeConfig?: ScopeTypeInfo;
8
+ currentScope: ScopeListItem | null;
9
+ parentScope: ScopeListItem | null;
10
+ siblingScopes: ScopeListItem[];
11
+ childScopes: ScopeListItem[];
12
+ allScopes: ScopeListItem[];
13
+ canSwitchScopes: boolean;
14
+ canViewChildScopes: boolean;
15
+ canCreateChildScopes: boolean;
16
+ hasSwitchTarget: boolean;
17
+ hasChildScopes: boolean;
18
+ hasCreateChildAction: boolean;
19
+ showScopeMenu: boolean;
20
+ isLoadingScopes: boolean;
21
+ }
22
+ export declare function useScopeMenuPolicy(): ScopeMenuPolicy;
23
+ //# sourceMappingURL=useScopeMenuPolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScopeMenuPolicy.d.ts","sourceRoot":"","sources":["../../../src/hooks/useScopeMenuPolicy.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAA;AAO9B,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEpE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAA;IACnB,WAAW,CAAC,EAAE,aAAa,CAAA;IAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,gBAAgB,CAAC,EAAE,aAAa,CAAA;IAChC,YAAY,EAAE,aAAa,GAAG,IAAI,CAAA;IAClC,WAAW,EAAE,aAAa,GAAG,IAAI,CAAA;IACjC,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,WAAW,EAAE,aAAa,EAAE,CAAA;IAC5B,SAAS,EAAE,aAAa,EAAE,CAAA;IAC1B,eAAe,EAAE,OAAO,CAAA;IACxB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,oBAAoB,EAAE,OAAO,CAAA;IAC7B,eAAe,EAAE,OAAO,CAAA;IACxB,cAAc,EAAE,OAAO,CAAA;IACvB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,aAAa,EAAE,OAAO,CAAA;IACtB,eAAe,EAAE,OAAO,CAAA;CACzB;AAED,wBAAgB,kBAAkB,IAAI,eAAe,CA8DpD"}
@@ -0,0 +1,59 @@
1
+ import { useMemo } from "react";
2
+ import { queryChildScopeTypes, queryScopeType, } from "@ydtb/tk-scope/client";
3
+ import { useScopeContext } from "../contexts/scope/ScopeContext.js";
4
+ import { useCurrentPermissions } from "../lib/permissions-store.js";
5
+ import { canCreateChildScopeAction, getScopeMenuVisibility, } from "../lib/scope-menu-policy.js";
6
+ import { useScopeList } from "./useScopeList.js";
7
+ export function useScopeMenuPolicy() {
8
+ const { scopeId, scopeType, entity } = useScopeContext();
9
+ const permissions = useCurrentPermissions();
10
+ const { scopes: allScopes, isPending: isLoadingScopes } = useScopeList({ staleTime: 30_000 });
11
+ return useMemo(() => {
12
+ const scopeConfig = scopeType ? queryScopeType(scopeType) : undefined;
13
+ const mode = scopeConfig?.scopeMenu ?? "auto";
14
+ const childScopeType = scopeType ? (queryChildScopeTypes(scopeType)[0] ?? null) : null;
15
+ const childScopeConfig = childScopeType ? queryScopeType(childScopeType) : undefined;
16
+ const currentScope = allScopes.find((scope) => scope.id === scopeId) ?? null;
17
+ const parentScopeId = entity?.parentScopeId ?? currentScope?.parentScopeId ?? null;
18
+ const parentScope = parentScopeId
19
+ ? (allScopes.find((scope) => scope.id === parentScopeId) ?? null)
20
+ : null;
21
+ const siblingScopes = allScopes.filter((scope) => scope.parentScopeId === parentScopeId && scope.id !== scopeId);
22
+ const childScopes = allScopes.filter((scope) => scope.parentScopeId === scopeId);
23
+ const effectivePermissions = permissions.loaded ? permissions.effectivePermissions : [];
24
+ const canSwitchScopes = effectivePermissions.includes("scope.switch");
25
+ const canViewChildScopes = effectivePermissions.includes("scope.children.view");
26
+ const canCreateChildScopes = effectivePermissions.includes("scope.children.create");
27
+ const hasSwitchTarget = Boolean(parentScope) || siblingScopes.length > 0 || allScopes.length > 1;
28
+ const hasChildScopes = childScopes.length > 0;
29
+ const hasCreateChildAction = canCreateChildScopeAction(childScopeConfig?.selfCreate, Boolean(childScopeType));
30
+ return {
31
+ mode,
32
+ scopeConfig,
33
+ childScopeType,
34
+ childScopeConfig,
35
+ currentScope,
36
+ parentScope,
37
+ siblingScopes,
38
+ childScopes,
39
+ allScopes,
40
+ canSwitchScopes,
41
+ canViewChildScopes,
42
+ canCreateChildScopes,
43
+ hasSwitchTarget,
44
+ hasChildScopes,
45
+ hasCreateChildAction,
46
+ showScopeMenu: getScopeMenuVisibility({
47
+ mode,
48
+ canSwitchScopes,
49
+ hasSwitchTarget,
50
+ canViewChildScopes,
51
+ hasChildScopes,
52
+ canCreateChildScopes,
53
+ hasCreateChildAction,
54
+ }),
55
+ isLoadingScopes,
56
+ };
57
+ }, [allScopes, entity?.parentScopeId, isLoadingScopes, permissions, scopeId, scopeType]);
58
+ }
59
+ //# sourceMappingURL=useScopeMenuPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScopeMenuPolicy.js","sourceRoot":"","sources":["../../../src/hooks/useScopeMenuPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EACL,oBAAoB,EACpB,cAAc,GAGf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAoC,CAAA;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EACL,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,YAAY,EAAsB,MAAM,mBAAmB,CAAA;AAsBpE,MAAM,UAAU,kBAAkB;IAChC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,eAAe,EAAE,CAAA;IACxD,MAAM,WAAW,GAAG,qBAAqB,EAAE,CAAA;IAC3C,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,YAAY,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAA;IAE7F,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAA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C,CAAA;QACrE,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAA;QAC/E,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAA;QAEnF,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;QAChG,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAA;QAC7C,MAAM,oBAAoB,GAAG,yBAAyB,CACpD,gBAAgB,EAAE,UAAU,EAC5B,OAAO,CAAC,cAAc,CAAC,CACxB,CAAA;QAED,OAAO;YACL,IAAI;YACJ,WAAW;YACX,cAAc;YACd,gBAAgB;YAChB,YAAY;YACZ,WAAW;YACX,aAAa;YACb,WAAW;YACX,SAAS;YACT,eAAe;YACf,kBAAkB;YAClB,oBAAoB;YACpB,eAAe;YACf,cAAc;YACd,oBAAoB;YACpB,aAAa,EAAE,sBAAsB,CAAC;gBACpC,IAAI;gBACJ,eAAe;gBACf,eAAe;gBACf,kBAAkB;gBAClB,cAAc;gBACd,oBAAoB;gBACpB,oBAAoB;aACrB,CAAC;YACF,eAAe;SAChB,CAAA;IACH,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAA;AAC1F,CAAC"}
@@ -0,0 +1,9 @@
1
+ interface ScopePermissionsOptions {
2
+ /** Set to false to skip permission resolution (e.g., null-scope guards). */
3
+ enabled?: boolean;
4
+ /** Current scope type so singleton scopes can resolve a stable scopeId. */
5
+ scope?: string | null;
6
+ }
7
+ export declare function useScopePermissions(options?: ScopePermissionsOptions): void;
8
+ export {};
9
+ //# sourceMappingURL=useScopePermissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScopePermissions.d.ts","sourceRoot":"","sources":["../../../src/hooks/useScopePermissions.ts"],"names":[],"mappings":"AAuBA,UAAU,uBAAuB;IAC/B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAwE3E"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Shared hook that resolves permissions for the current scope.
3
+ *
4
+ * Reads the active scope from `useScopeContext()`, gets the membership via
5
+ * `scopeApi.get`, resolves permissions via `permissionsApi.resolve`,
6
+ * and pushes the result into the
7
+ * shell-level permissions provider via `useSetCurrentPermissions()`.
8
+ *
9
+ * Called from UnifiedGuard's PostScopeSteps — runs immediately after
10
+ * scope validates so permissions are loaded before onboarding and
11
+ * permission gates check them downstream.
12
+ */
13
+ import { useEffect } from "react";
14
+ import { useQuery } from "@ydtb/tk-scope-query-client";
15
+ import { scopeApi, permissionsApi } from "../lib/platform-api.js";
16
+ import { useSetCurrentPermissions } from "../lib/permissions-store.js";
17
+ import { useScopeContext } from "../contexts/scope/ScopeContext.js";
18
+ import { useAppConfig } from "../contexts/config/AppConfigContext.js";
19
+ import { useSetBackendUnreachable } from "../contexts/backend/BackendStatusContext.js";
20
+ import { scopeHasUrlScopeId } from "@ydtb/tk-scope/client";
21
+ import { isNetworkError } from "../lib/backend-status.js";
22
+ export function useScopePermissions(options) {
23
+ const hookEnabled = options?.enabled ?? true;
24
+ const scope = options?.scope ?? null;
25
+ const { scopeId, entity } = useScopeContext();
26
+ const appConfig = useAppConfig();
27
+ const setCurrentPermissions = useSetCurrentPermissions();
28
+ const setBackendUnreachable = useSetBackendUnreachable();
29
+ const singletonScopeId = scope && !scopeHasUrlScopeId(scope) ? (appConfig.server?.rootSetup?.scopeId ?? scope) : null;
30
+ const effectiveScopeId = hookEnabled ? (scopeId ?? entity?.id ?? singletonScopeId) : null;
31
+ // Reset permissions immediately when scope changes
32
+ useEffect(() => {
33
+ if (!effectiveScopeId)
34
+ return;
35
+ setCurrentPermissions({
36
+ tier: "member",
37
+ effectivePermissions: [],
38
+ loaded: false,
39
+ });
40
+ }, [effectiveScopeId, setCurrentPermissions]);
41
+ // Step 1: Fetch scope + membership to get memberId
42
+ const { data: scopeData, isPending: accessPending } = useQuery({
43
+ ...scopeApi.get.queryOptions({ input: { scopeId: effectiveScopeId } }),
44
+ enabled: !!effectiveScopeId,
45
+ });
46
+ const memberId = scopeData?.membership?.id ?? "";
47
+ // Step 2: Resolve permissions for the member
48
+ const { data: resolved, isPending: permsPending, error, } = useQuery({
49
+ ...permissionsApi.resolve.queryOptions({
50
+ input: { memberId },
51
+ }),
52
+ enabled: !!memberId,
53
+ });
54
+ const isLoading = accessPending || (!!memberId && permsPending);
55
+ // Sync resolved permissions into the store
56
+ useEffect(() => {
57
+ if (!hookEnabled)
58
+ return;
59
+ if (isLoading)
60
+ return;
61
+ if (error) {
62
+ if (isNetworkError(error)) {
63
+ setBackendUnreachable(true);
64
+ return;
65
+ }
66
+ // Non-network error — set empty permissions
67
+ setCurrentPermissions({
68
+ tier: "member",
69
+ effectivePermissions: [],
70
+ loaded: true,
71
+ });
72
+ return;
73
+ }
74
+ if (!resolved)
75
+ return;
76
+ const data = resolved;
77
+ setCurrentPermissions({
78
+ tier: data.tier,
79
+ effectivePermissions: data.effectivePermissions,
80
+ loaded: true,
81
+ });
82
+ }, [hookEnabled, isLoading, resolved, error, setCurrentPermissions, setBackendUnreachable]);
83
+ }
84
+ //# sourceMappingURL=useScopePermissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScopePermissions.js","sourceRoot":"","sources":["../../../src/hooks/useScopePermissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CA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AM;QAErB,MAAM,IAAI,GAAG,QAA4D,CAAA;QACzE,qBAAqB,CAAC;YACpB,IAAI,EAAE,IAAI,CAAC,IAAkB;YAC7B,oBAAoB,EAAE,IAAI,CAAC,oBAAqC;YAChE,MAAM,EAAE,IAAI;SACb,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,CAAA;AAC7F,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Anvil-compatible oRPC client factory.
3
+ *
4
+ * Replaces `createOrpcClient` from `@ydtb/compose/client` (old compose system).
5
+ * Uses `@ydtb/core-client` descriptors + `RPCLink` + `createORPCClient` to
6
+ * produce typed TanStack Query-integrated clients that match the Anvil server's
7
+ * `fromOrpc()` + `RPCHandler` wire format.
8
+ *
9
+ * Usage:
10
+ * import { createToolClient } from '../lib/api-client.ts'
11
+ * const contactsApi = createToolClient<ContactsRouter>('contacts')
12
+ * // In components:
13
+ * const { data } = useQuery(contactsApi.list.queryOptions({ input: { ... } }))
14
+ */
15
+ import { configureApiClients } from "@ydtb/core-client";
16
+ import type { AnyRouter, RouterClient } from "@orpc/server";
17
+ export { configureApiClients };
18
+ /**
19
+ * Create a typed oRPC client for a tool or platform router.
20
+ *
21
+ * The client is scope-aware (injects x-scope-id/x-scope-type headers)
22
+ * and produces TanStack Query integration (.queryOptions(), .mutationOptions()).
23
+ */
24
+ export declare function createToolClient<TRouter extends AnyRouter>(toolId: string): import("@orpc/tanstack-query").RouterUtils<RouterClient<TRouter>> & {
25
+ $client: RouterClient<TRouter>;
26
+ };
27
+ //# sourceMappingURL=api-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAmB,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAIxE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3D,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAE9B;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EAAE,MAAM,EAAE,MAAM,GAkBlE,oEAAoB;IAAE,OAAO,wBAAe;CAAE,CACrD"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Anvil-compatible oRPC client factory.
3
+ *
4
+ * Replaces `createOrpcClient` from `@ydtb/compose/client` (old compose system).
5
+ * Uses `@ydtb/core-client` descriptors + `RPCLink` + `createORPCClient` to
6
+ * produce typed TanStack Query-integrated clients that match the Anvil server's
7
+ * `fromOrpc()` + `RPCHandler` wire format.
8
+ *
9
+ * Usage:
10
+ * import { createToolClient } from '../lib/api-client.ts'
11
+ * const contactsApi = createToolClient<ContactsRouter>('contacts')
12
+ * // In components:
13
+ * const { data } = useQuery(contactsApi.list.queryOptions({ input: { ... } }))
14
+ */
15
+ import { createApiClient, configureApiClients } from "@ydtb/core-client";
16
+ import { RPCLink } from "@orpc/client/fetch";
17
+ import { createORPCClient } from "@orpc/client";
18
+ import { createTanstackQueryUtils } from "@orpc/tanstack-query";
19
+ // Re-export configureApiClients so main.tsx only imports from this module
20
+ export { configureApiClients };
21
+ /**
22
+ * Create a typed oRPC client for a tool or platform router.
23
+ *
24
+ * The client is scope-aware (injects x-scope-id/x-scope-type headers)
25
+ * and produces TanStack Query integration (.queryOptions(), .mutationOptions()).
26
+ */
27
+ export function createToolClient(toolId) {
28
+ const descriptor = createApiClient(toolId);
29
+ const link = new RPCLink({
30
+ url: descriptor.url,
31
+ headers: descriptor.headers,
32
+ });
33
+ const client = createORPCClient(link);
34
+ const queryUtils = createTanstackQueryUtils(client);
35
+ // Expose raw client as $client for imperative calls (fire-and-forget mutations etc.)
36
+ const $client = client;
37
+ return new Proxy(queryUtils, {
38
+ get(target, prop, receiver) {
39
+ if (prop === "$client")
40
+ return $client;
41
+ return Reflect.get(target, prop, receiver);
42
+ },
43
+ });
44
+ }
45
+ //# sourceMappingURL=api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAG/D,0EAA0E;AAC1E,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAE9B;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAA4B,MAAc;IACxE,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,CAAA;IAE1C,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC;QACvB,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,OAAO,EAAE,UAAU,CAAC,OAAO;KAC5B,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,gBAAgB,CAAwB,IAAI,CAAC,CAAA;IAC5D,MAAM,UAAU,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAA;IAEnD,qFAAqF;IACrF,MAAM,OAAO,GAAG,MAAM,CAAA;IACtB,OAAO,IAAI,KAAK,CAAC,UAAU,EAAE;QAC3B,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;YACxB,IAAI,IAAI,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAA;YACtC,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;QAC5C,CAAC;KACF,CAAmD,CAAA;AACtD,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Backend-status helpers.
3
+ *
4
+ * Backend reachability state now lives in `BackendStatusProvider`, where
5
+ * permission resolution can update it through React context instead of a
6
+ * module-level pub-sub store. The only shared utility left here is the
7
+ * network-error detector used by that resolver.
8
+ */
9
+ /**
10
+ * Checks if an error represents a network-level failure (backend unreachable).
11
+ * Does NOT match HTTP errors like 403, 404, 500 — only connection failures.
12
+ */
13
+ export declare function isNetworkError(error: unknown): boolean;
14
+ //# sourceMappingURL=backend-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend-status.d.ts","sourceRoot":"","sources":["../../../src/lib/backend-status.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAgBtD"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Backend-status helpers.
3
+ *
4
+ * Backend reachability state now lives in `BackendStatusProvider`, where
5
+ * permission resolution can update it through React context instead of a
6
+ * module-level pub-sub store. The only shared utility left here is the
7
+ * network-error detector used by that resolver.
8
+ */
9
+ /**
10
+ * Checks if an error represents a network-level failure (backend unreachable).
11
+ * Does NOT match HTTP errors like 403, 404, 500 — only connection failures.
12
+ */
13
+ export function isNetworkError(error) {
14
+ if (!error)
15
+ return false;
16
+ const message = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
17
+ return (message.includes("fetch") ||
18
+ message.includes("network") ||
19
+ message.includes("aborted") ||
20
+ message.includes("connectionrefused") ||
21
+ message.includes("timedout") ||
22
+ message.includes("err_connection") ||
23
+ message.includes("failed to fetch") ||
24
+ message.includes("load failed") ||
25
+ message.includes("networkerror"));
26
+ }
27
+ //# sourceMappingURL=backend-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend-status.js","sourceRoot":"","sources":["../../../src/lib/backend-status.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IAExB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IAElG,OAAO,CACL,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC3B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC5B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CACjC,CAAA;AACH,CAAC"}