@notis_ai/cli 0.2.14 → 0.2.16

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 (299) hide show
  1. package/README.md +83 -21
  2. package/dist/agent-hooks/notis-agent-hook.mjs +20168 -0
  3. package/{skills → dist/base-skills}/notis-apps/SKILL.md +167 -72
  4. package/{skills → dist/base-skills}/notis-cli/SKILL.md +86 -28
  5. package/dist/base-skills/notis-query/SKILL.md +705 -0
  6. package/dist/skill-sync/index.js +1528 -0
  7. package/dist/skill-sync/index.js.map +7 -0
  8. package/package.json +5 -2
  9. package/skills/notis-apps/cli.md +39 -18
  10. package/skills/notis-cli/AGENT_INSTRUCTIONS.md +39 -0
  11. package/skills/notis-onboarding/BRIEF.md +16 -0
  12. package/src/agent-hook-entry.js +5 -0
  13. package/src/cli.js +23 -14
  14. package/src/command-specs/agents.js +392 -0
  15. package/src/command-specs/apps.js +1021 -424
  16. package/src/command-specs/auth.js +63 -10
  17. package/src/command-specs/index.js +6 -0
  18. package/src/command-specs/onboarding.js +69 -5
  19. package/src/command-specs/skills.js +56 -0
  20. package/src/runtime/agent-memory-state.js +126 -0
  21. package/src/runtime/agent-setup.js +383 -0
  22. package/src/runtime/app-dev-consumers.js +154 -0
  23. package/src/runtime/app-dev-host-lock.js +80 -0
  24. package/src/runtime/app-dev-process-identity.js +111 -0
  25. package/src/runtime/app-dev-roots.js +284 -0
  26. package/src/runtime/app-dev-server.js +447 -29
  27. package/src/runtime/app-dev-sessions.js +105 -145
  28. package/src/runtime/app-platform.js +1314 -166
  29. package/src/runtime/app-registry-scaffolds.js +367 -0
  30. package/src/runtime/base-skills.d.ts +20 -0
  31. package/src/runtime/base-skills.js +167 -0
  32. package/src/runtime/login-listener.js +15 -0
  33. package/src/runtime/oauth.js +1506 -141
  34. package/src/runtime/output.js +7 -0
  35. package/src/runtime/ports.js +16 -0
  36. package/src/runtime/profiles.js +19 -16
  37. package/src/runtime/skill-sync/cloud-client.ts +96 -0
  38. package/src/runtime/skill-sync/index.ts +644 -0
  39. package/src/runtime/skill-sync/local-scanner.ts +1046 -0
  40. package/src/runtime/skill-sync/symlink-manager.ts +383 -0
  41. package/src/runtime/skill-sync/sync-plan.ts +22 -0
  42. package/src/runtime/skill-sync/types.ts +103 -0
  43. package/src/runtime/skill-sync/write-cloud-skill.ts +50 -0
  44. package/src/runtime/store-screenshot.js +6 -1
  45. package/src/runtime/sync-skills.d.ts +37 -0
  46. package/src/runtime/sync-skills.js +231 -0
  47. package/template/app/layout.tsx +5 -1
  48. package/template/notis.config.ts +1 -0
  49. package/template/packages/sdk/package.json +2 -1
  50. package/template/packages/sdk/src/components/DocumentEditor.tsx +13 -3
  51. package/template/packages/sdk/src/components/MarkdownEditor.tsx +121 -0
  52. package/template/packages/sdk/src/components/MultiSelectActionBar.tsx +43 -119
  53. package/template/packages/sdk/src/components/MultiSelectCheckbox.tsx +5 -1
  54. package/template/packages/sdk/src/components/MultiSelectDragOverlay.tsx +1 -1
  55. package/template/packages/sdk/src/components/NotisSelectionBoundary.tsx +55 -0
  56. package/template/packages/sdk/src/components/ShortcutHints.tsx +56 -0
  57. package/template/packages/sdk/src/config.ts +25 -0
  58. package/template/packages/sdk/src/documents.ts +7 -1
  59. package/template/packages/sdk/src/hooks/useActiveResource.ts +19 -0
  60. package/template/packages/sdk/src/hooks/useCollectionInteractions.ts +726 -0
  61. package/template/packages/sdk/src/hooks/useHandover.ts +3 -0
  62. package/template/packages/sdk/src/hooks/useMultiSelect.ts +44 -482
  63. package/template/packages/sdk/src/hooks/useNotis.ts +3 -0
  64. package/template/packages/sdk/src/hooks/useNotisNavigation.ts +7 -4
  65. package/template/packages/sdk/src/hooks/useTool.ts +5 -4
  66. package/template/packages/sdk/src/index.ts +47 -2
  67. package/template/packages/sdk/src/interactions/actions.ts +46 -0
  68. package/template/packages/sdk/src/interactions/shortcuts.tsx +634 -0
  69. package/template/packages/sdk/src/interactions.ts +41 -0
  70. package/template/packages/sdk/src/provider.tsx +2 -1
  71. package/template/packages/sdk/src/runtime.ts +92 -4
  72. package/dist/scaffolds/notis-database/CHANGELOG.md +0 -5
  73. package/dist/scaffolds/notis-database/app/globals.css +0 -44
  74. package/dist/scaffolds/notis-database/app/layout.tsx +0 -6
  75. package/dist/scaffolds/notis-database/app/page.tsx +0 -1088
  76. package/dist/scaffolds/notis-database/components/ui/badge.tsx +0 -28
  77. package/dist/scaffolds/notis-database/components/ui/button.tsx +0 -53
  78. package/dist/scaffolds/notis-database/components/ui/card.tsx +0 -56
  79. package/dist/scaffolds/notis-database/components/ui/table.tsx +0 -120
  80. package/dist/scaffolds/notis-database/components.json +0 -20
  81. package/dist/scaffolds/notis-database/index.html +0 -12
  82. package/dist/scaffolds/notis-database/lib/types.ts +0 -132
  83. package/dist/scaffolds/notis-database/lib/utils.ts +0 -6
  84. package/dist/scaffolds/notis-database/metadata/screenshot-1.png +0 -0
  85. package/dist/scaffolds/notis-database/metadata/screenshot-2.png +0 -0
  86. package/dist/scaffolds/notis-database/metadata/screenshot-3.png +0 -0
  87. package/dist/scaffolds/notis-database/metadata/screenshot-4.png +0 -0
  88. package/dist/scaffolds/notis-database/metadata/screenshot-5.png +0 -0
  89. package/dist/scaffolds/notis-database/metadata/screenshot-fixtures.json +0 -1839
  90. package/dist/scaffolds/notis-database/notis.config.ts +0 -73
  91. package/dist/scaffolds/notis-database/package-lock.json +0 -3935
  92. package/dist/scaffolds/notis-database/package.json +0 -32
  93. package/dist/scaffolds/notis-database/packages/sdk/package.json +0 -36
  94. package/dist/scaffolds/notis-database/packages/sdk/src/components/DocumentEditor.tsx +0 -93
  95. package/dist/scaffolds/notis-database/packages/sdk/src/components/Markdown.tsx +0 -60
  96. package/dist/scaffolds/notis-database/packages/sdk/src/components/MultiSelectActionBar.tsx +0 -278
  97. package/dist/scaffolds/notis-database/packages/sdk/src/components/MultiSelectCheckbox.tsx +0 -91
  98. package/dist/scaffolds/notis-database/packages/sdk/src/components/MultiSelectDragOverlay.tsx +0 -39
  99. package/dist/scaffolds/notis-database/packages/sdk/src/config.ts +0 -234
  100. package/dist/scaffolds/notis-database/packages/sdk/src/documents.ts +0 -250
  101. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useBackend.ts +0 -41
  102. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useCloudComputer.ts +0 -97
  103. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useDatabaseSchema.ts +0 -85
  104. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useDatabaseSubscription.ts +0 -76
  105. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useDocument.ts +0 -78
  106. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useDocuments.ts +0 -121
  107. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useHandover.ts +0 -75
  108. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useMultiSelect.ts +0 -539
  109. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useNotis.ts +0 -34
  110. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useNotisNavigation.ts +0 -49
  111. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useTool.ts +0 -64
  112. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useTools.ts +0 -56
  113. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useTopBarSearch.ts +0 -73
  114. package/dist/scaffolds/notis-database/packages/sdk/src/hooks/useUpsertDocument.ts +0 -95
  115. package/dist/scaffolds/notis-database/packages/sdk/src/index.ts +0 -100
  116. package/dist/scaffolds/notis-database/packages/sdk/src/provider.tsx +0 -43
  117. package/dist/scaffolds/notis-database/packages/sdk/src/runtime.ts +0 -351
  118. package/dist/scaffolds/notis-database/packages/sdk/src/styles.css +0 -186
  119. package/dist/scaffolds/notis-database/packages/sdk/src/ui.ts +0 -15
  120. package/dist/scaffolds/notis-database/packages/sdk/src/vite.ts +0 -56
  121. package/dist/scaffolds/notis-database/packages/sdk/tsconfig.json +0 -15
  122. package/dist/scaffolds/notis-database/postcss.config.mjs +0 -8
  123. package/dist/scaffolds/notis-database/src/dev-main.tsx +0 -23
  124. package/dist/scaffolds/notis-database/src/mock-runtime.ts +0 -561
  125. package/dist/scaffolds/notis-database/tailwind.config.ts +0 -59
  126. package/dist/scaffolds/notis-database/tsconfig.json +0 -23
  127. package/dist/scaffolds/notis-database/vite.config.ts +0 -22
  128. package/dist/scaffolds/notis-journal/CHANGELOG.md +0 -29
  129. package/dist/scaffolds/notis-journal/app/globals.css +0 -37
  130. package/dist/scaffolds/notis-journal/app/insights/page.tsx +0 -513
  131. package/dist/scaffolds/notis-journal/app/journal-core.tsx +0 -362
  132. package/dist/scaffolds/notis-journal/app/journal-ui.tsx +0 -337
  133. package/dist/scaffolds/notis-journal/app/layout.tsx +0 -6
  134. package/dist/scaffolds/notis-journal/app/page.tsx +0 -486
  135. package/dist/scaffolds/notis-journal/components/ui/badge.tsx +0 -28
  136. package/dist/scaffolds/notis-journal/components/ui/button.tsx +0 -53
  137. package/dist/scaffolds/notis-journal/components/ui/card.tsx +0 -56
  138. package/dist/scaffolds/notis-journal/components.json +0 -20
  139. package/dist/scaffolds/notis-journal/index.html +0 -12
  140. package/dist/scaffolds/notis-journal/lib/utils.ts +0 -6
  141. package/dist/scaffolds/notis-journal/metadata/screenshot-1.png +0 -0
  142. package/dist/scaffolds/notis-journal/metadata/screenshot-2.png +0 -0
  143. package/dist/scaffolds/notis-journal/metadata/screenshot-3.png +0 -0
  144. package/dist/scaffolds/notis-journal/metadata/screenshot-4.png +0 -0
  145. package/dist/scaffolds/notis-journal/metadata/screenshot-5.png +0 -0
  146. package/dist/scaffolds/notis-journal/metadata/screenshot-6.png +0 -0
  147. package/dist/scaffolds/notis-journal/metadata/screenshot-fixtures.json +0 -132
  148. package/dist/scaffolds/notis-journal/notis.config.ts +0 -93
  149. package/dist/scaffolds/notis-journal/package-lock.json +0 -4615
  150. package/dist/scaffolds/notis-journal/package.json +0 -34
  151. package/dist/scaffolds/notis-journal/packages/sdk/package.json +0 -36
  152. package/dist/scaffolds/notis-journal/packages/sdk/src/components/DocumentEditor.tsx +0 -93
  153. package/dist/scaffolds/notis-journal/packages/sdk/src/components/Markdown.tsx +0 -60
  154. package/dist/scaffolds/notis-journal/packages/sdk/src/components/MultiSelectActionBar.tsx +0 -278
  155. package/dist/scaffolds/notis-journal/packages/sdk/src/components/MultiSelectCheckbox.tsx +0 -91
  156. package/dist/scaffolds/notis-journal/packages/sdk/src/components/MultiSelectDragOverlay.tsx +0 -39
  157. package/dist/scaffolds/notis-journal/packages/sdk/src/config.ts +0 -234
  158. package/dist/scaffolds/notis-journal/packages/sdk/src/documents.ts +0 -250
  159. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useBackend.ts +0 -41
  160. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useCloudComputer.ts +0 -97
  161. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useDatabaseSchema.ts +0 -85
  162. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useDatabaseSubscription.ts +0 -76
  163. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useDocument.ts +0 -78
  164. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useDocuments.ts +0 -121
  165. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useHandover.ts +0 -75
  166. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useMultiSelect.ts +0 -539
  167. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useNotis.ts +0 -34
  168. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useNotisNavigation.ts +0 -49
  169. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useTool.ts +0 -64
  170. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useTools.ts +0 -56
  171. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useTopBarSearch.ts +0 -73
  172. package/dist/scaffolds/notis-journal/packages/sdk/src/hooks/useUpsertDocument.ts +0 -95
  173. package/dist/scaffolds/notis-journal/packages/sdk/src/index.ts +0 -100
  174. package/dist/scaffolds/notis-journal/packages/sdk/src/provider.tsx +0 -43
  175. package/dist/scaffolds/notis-journal/packages/sdk/src/runtime.ts +0 -351
  176. package/dist/scaffolds/notis-journal/packages/sdk/src/styles.css +0 -186
  177. package/dist/scaffolds/notis-journal/packages/sdk/src/ui.ts +0 -15
  178. package/dist/scaffolds/notis-journal/packages/sdk/src/vite.ts +0 -56
  179. package/dist/scaffolds/notis-journal/packages/sdk/tsconfig.json +0 -15
  180. package/dist/scaffolds/notis-journal/postcss.config.mjs +0 -8
  181. package/dist/scaffolds/notis-journal/skills/journal-onboarding/SKILL.md +0 -120
  182. package/dist/scaffolds/notis-journal/src/dev-main.tsx +0 -58
  183. package/dist/scaffolds/notis-journal/src/mock-runtime.ts +0 -199
  184. package/dist/scaffolds/notis-journal/tailwind.config.ts +0 -58
  185. package/dist/scaffolds/notis-journal/tsconfig.json +0 -23
  186. package/dist/scaffolds/notis-journal/vite.config.ts +0 -10
  187. package/dist/scaffolds/notis-notes/CHANGELOG.md +0 -5
  188. package/dist/scaffolds/notis-notes/app/globals.css +0 -3
  189. package/dist/scaffolds/notis-notes/app/layout.tsx +0 -6
  190. package/dist/scaffolds/notis-notes/app/page.tsx +0 -1943
  191. package/dist/scaffolds/notis-notes/app/phosphor-icons.ts +0 -596
  192. package/dist/scaffolds/notis-notes/components/ui/badge.tsx +0 -28
  193. package/dist/scaffolds/notis-notes/components/ui/button.tsx +0 -53
  194. package/dist/scaffolds/notis-notes/components/ui/card.tsx +0 -56
  195. package/dist/scaffolds/notis-notes/components.json +0 -20
  196. package/dist/scaffolds/notis-notes/lib/utils.ts +0 -6
  197. package/dist/scaffolds/notis-notes/lib/visible-properties.ts +0 -144
  198. package/dist/scaffolds/notis-notes/metadata/screenshot-1.png +0 -0
  199. package/dist/scaffolds/notis-notes/metadata/screenshot-2.png +0 -0
  200. package/dist/scaffolds/notis-notes/metadata/screenshot-3.png +0 -0
  201. package/dist/scaffolds/notis-notes/metadata/screenshot-4.png +0 -0
  202. package/dist/scaffolds/notis-notes/metadata/screenshot-5.png +0 -0
  203. package/dist/scaffolds/notis-notes/metadata/screenshot-fixtures.json +0 -752
  204. package/dist/scaffolds/notis-notes/notis.config.ts +0 -80
  205. package/dist/scaffolds/notis-notes/package-lock.json +0 -4636
  206. package/dist/scaffolds/notis-notes/package.json +0 -35
  207. package/dist/scaffolds/notis-notes/packages/sdk/package.json +0 -36
  208. package/dist/scaffolds/notis-notes/packages/sdk/src/components/DocumentEditor.tsx +0 -93
  209. package/dist/scaffolds/notis-notes/packages/sdk/src/components/Markdown.tsx +0 -60
  210. package/dist/scaffolds/notis-notes/packages/sdk/src/components/MultiSelectActionBar.tsx +0 -278
  211. package/dist/scaffolds/notis-notes/packages/sdk/src/components/MultiSelectCheckbox.tsx +0 -91
  212. package/dist/scaffolds/notis-notes/packages/sdk/src/components/MultiSelectDragOverlay.tsx +0 -39
  213. package/dist/scaffolds/notis-notes/packages/sdk/src/config.ts +0 -234
  214. package/dist/scaffolds/notis-notes/packages/sdk/src/documents.ts +0 -250
  215. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useBackend.ts +0 -41
  216. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useCloudComputer.ts +0 -97
  217. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useDatabaseSchema.ts +0 -85
  218. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useDatabaseSubscription.ts +0 -76
  219. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useDocument.ts +0 -78
  220. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useDocuments.ts +0 -121
  221. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useHandover.ts +0 -75
  222. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useMultiSelect.ts +0 -539
  223. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useNotis.ts +0 -34
  224. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useNotisNavigation.ts +0 -49
  225. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useTool.ts +0 -64
  226. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useTools.ts +0 -56
  227. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useTopBarSearch.ts +0 -73
  228. package/dist/scaffolds/notis-notes/packages/sdk/src/hooks/useUpsertDocument.ts +0 -95
  229. package/dist/scaffolds/notis-notes/packages/sdk/src/index.ts +0 -100
  230. package/dist/scaffolds/notis-notes/packages/sdk/src/provider.tsx +0 -43
  231. package/dist/scaffolds/notis-notes/packages/sdk/src/runtime.ts +0 -351
  232. package/dist/scaffolds/notis-notes/packages/sdk/src/styles.css +0 -186
  233. package/dist/scaffolds/notis-notes/packages/sdk/src/ui.ts +0 -15
  234. package/dist/scaffolds/notis-notes/packages/sdk/src/vite.ts +0 -56
  235. package/dist/scaffolds/notis-notes/packages/sdk/tsconfig.json +0 -15
  236. package/dist/scaffolds/notis-notes/postcss.config.mjs +0 -8
  237. package/dist/scaffolds/notis-notes/tailwind.config.ts +0 -58
  238. package/dist/scaffolds/notis-notes/tsconfig.json +0 -23
  239. package/dist/scaffolds/notis-notes/vite.config.ts +0 -10
  240. package/dist/scaffolds/notis-random/CHANGELOG.md +0 -15
  241. package/dist/scaffolds/notis-random/README.md +0 -33
  242. package/dist/scaffolds/notis-random/app/globals.css +0 -11
  243. package/dist/scaffolds/notis-random/app/history/page.tsx +0 -67
  244. package/dist/scaffolds/notis-random/app/layout.tsx +0 -7
  245. package/dist/scaffolds/notis-random/app/page.tsx +0 -289
  246. package/dist/scaffolds/notis-random/components/ui/button.tsx +0 -50
  247. package/dist/scaffolds/notis-random/components/ui/card.tsx +0 -16
  248. package/dist/scaffolds/notis-random/components/ui/input.tsx +0 -23
  249. package/dist/scaffolds/notis-random/components.json +0 -20
  250. package/dist/scaffolds/notis-random/index.html +0 -12
  251. package/dist/scaffolds/notis-random/lib/notis-tools.ts +0 -128
  252. package/dist/scaffolds/notis-random/lib/rng.ts +0 -202
  253. package/dist/scaffolds/notis-random/lib/roll-record.ts +0 -189
  254. package/dist/scaffolds/notis-random/lib/utils.ts +0 -25
  255. package/dist/scaffolds/notis-random/metadata/screenshot-1.png +0 -0
  256. package/dist/scaffolds/notis-random/metadata/screenshot-2.png +0 -0
  257. package/dist/scaffolds/notis-random/metadata/screenshot-3.png +0 -0
  258. package/dist/scaffolds/notis-random/metadata/screenshot-4.png +0 -0
  259. package/dist/scaffolds/notis-random/metadata/screenshot-5.png +0 -0
  260. package/dist/scaffolds/notis-random/metadata/screenshot-fixtures.json +0 -753
  261. package/dist/scaffolds/notis-random/notis.config.ts +0 -86
  262. package/dist/scaffolds/notis-random/package-lock.json +0 -4513
  263. package/dist/scaffolds/notis-random/package.json +0 -36
  264. package/dist/scaffolds/notis-random/packages/sdk/package.json +0 -36
  265. package/dist/scaffolds/notis-random/packages/sdk/src/components/DocumentEditor.tsx +0 -93
  266. package/dist/scaffolds/notis-random/packages/sdk/src/components/Markdown.tsx +0 -60
  267. package/dist/scaffolds/notis-random/packages/sdk/src/components/MultiSelectActionBar.tsx +0 -278
  268. package/dist/scaffolds/notis-random/packages/sdk/src/components/MultiSelectCheckbox.tsx +0 -91
  269. package/dist/scaffolds/notis-random/packages/sdk/src/components/MultiSelectDragOverlay.tsx +0 -39
  270. package/dist/scaffolds/notis-random/packages/sdk/src/config.ts +0 -234
  271. package/dist/scaffolds/notis-random/packages/sdk/src/documents.ts +0 -250
  272. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useBackend.ts +0 -41
  273. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useCloudComputer.ts +0 -97
  274. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useDatabaseSchema.ts +0 -85
  275. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useDatabaseSubscription.ts +0 -76
  276. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useDocument.ts +0 -78
  277. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useDocuments.ts +0 -121
  278. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useHandover.ts +0 -75
  279. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useMultiSelect.ts +0 -539
  280. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useNotis.ts +0 -34
  281. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useNotisNavigation.ts +0 -49
  282. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useTool.ts +0 -64
  283. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useTools.ts +0 -56
  284. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useTopBarSearch.ts +0 -73
  285. package/dist/scaffolds/notis-random/packages/sdk/src/hooks/useUpsertDocument.ts +0 -95
  286. package/dist/scaffolds/notis-random/packages/sdk/src/index.ts +0 -100
  287. package/dist/scaffolds/notis-random/packages/sdk/src/provider.tsx +0 -43
  288. package/dist/scaffolds/notis-random/packages/sdk/src/runtime.ts +0 -351
  289. package/dist/scaffolds/notis-random/packages/sdk/src/styles.css +0 -186
  290. package/dist/scaffolds/notis-random/packages/sdk/src/ui.ts +0 -15
  291. package/dist/scaffolds/notis-random/packages/sdk/src/vite.ts +0 -56
  292. package/dist/scaffolds/notis-random/packages/sdk/tsconfig.json +0 -15
  293. package/dist/scaffolds/notis-random/postcss.config.mjs +0 -6
  294. package/dist/scaffolds/notis-random/src/dev-main.tsx +0 -70
  295. package/dist/scaffolds/notis-random/src/mock-runtime.ts +0 -129
  296. package/dist/scaffolds/notis-random/tailwind.config.ts +0 -50
  297. package/dist/scaffolds/notis-random/tsconfig.json +0 -23
  298. package/dist/scaffolds/notis-random/vite.config.ts +0 -11
  299. package/dist/scaffolds.json +0 -49
@@ -1,1088 +0,0 @@
1
- 'use client';
2
-
3
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
- import { normalizeDocumentRecord, useTool, useTopBarSearch } from '@notis/sdk';
5
- import { WarningCircleIcon as AlertCircle, AtIcon as AtSign, CalendarIcon as Calendar, CheckSquareIcon as CheckSquare, CaretDownIcon as ChevronDown, CircleIcon as Circle, CircleIcon as CircleDot, DatabaseIcon as Database, FileTextIcon as FileText, HashIcon as Hash, LinkIcon as Link2, ListChecksIcon as ListChecks, CircleNotchIcon as Loader2, EnvelopeIcon as Mail, PaperclipIcon as Paperclip, PhoneIcon as Phone, SigmaIcon as Sigma, TagIcon as Tag, TextTIcon as Type, UserIcon as User } from '@phosphor-icons/react';
6
-
7
- import { Badge } from '@/components/ui/badge';
8
- import {
9
- Table,
10
- TableBody,
11
- TableCell,
12
- TableHead,
13
- TableHeader,
14
- TableRow,
15
- } from '@/components/ui/table';
16
- import { cn } from '@/lib/utils';
17
- import type {
18
- DatabaseCatalogRow,
19
- DatabaseDetail,
20
- DatabaseDocument,
21
- DatabaseProperty,
22
- DocumentPropertyValue,
23
- GetDatabaseArgs,
24
- GetDatabaseResult,
25
- ListDatabasesArgs,
26
- ListDatabasesResult,
27
- QueryDatabaseArgs,
28
- QueryDatabaseResult,
29
- } from '@/lib/types';
30
-
31
- const TYPE_LABEL: Record<string, string> = {
32
- title: 'Text',
33
- rich_text: 'Text',
34
- number: 'Number',
35
- select: 'Select',
36
- multi_select: 'Multi-select',
37
- status: 'Status',
38
- checkbox: 'Checkbox',
39
- url: 'URL',
40
- email: 'Email',
41
- phone_number: 'Phone',
42
- date: 'Date',
43
- files: 'Files',
44
- relation: 'Relation',
45
- formula: 'Formula',
46
- people: 'People',
47
- };
48
-
49
- function PropertyTypeIcon({ type }: { type: string }) {
50
- const className = 'h-3.5 w-3.5 text-muted-foreground';
51
- switch (type) {
52
- case 'title':
53
- return <FileText className={className} />;
54
- case 'rich_text':
55
- return <Type className={className} />;
56
- case 'number':
57
- return <Hash className={className} />;
58
- case 'select':
59
- return <CircleDot className={className} />;
60
- case 'multi_select':
61
- return <Tag className={className} />;
62
- case 'status':
63
- return <Circle className={className} />;
64
- case 'checkbox':
65
- return <CheckSquare className={className} />;
66
- case 'url':
67
- return <Link2 className={className} />;
68
- case 'email':
69
- return <Mail className={className} />;
70
- case 'phone_number':
71
- return <Phone className={className} />;
72
- case 'date':
73
- return <Calendar className={className} />;
74
- case 'files':
75
- return <Paperclip className={className} />;
76
- case 'relation':
77
- return <Link2 className={className} />;
78
- case 'formula':
79
- return <Sigma className={className} />;
80
- case 'people':
81
- return <User className={className} />;
82
- default:
83
- return <AtSign className={className} />;
84
- }
85
- }
86
-
87
- const TILE_TINTS = [
88
- 'bg-blue-100/70 text-blue-900 dark:bg-blue-500/15 dark:text-blue-200',
89
- 'bg-amber-100/70 text-amber-900 dark:bg-amber-500/15 dark:text-amber-200',
90
- 'bg-pink-100/70 text-pink-900 dark:bg-pink-500/15 dark:text-pink-200',
91
- 'bg-emerald-100/70 text-emerald-900 dark:bg-emerald-500/15 dark:text-emerald-200',
92
- 'bg-violet-100/70 text-violet-900 dark:bg-violet-500/15 dark:text-violet-200',
93
- 'bg-rose-100/70 text-rose-900 dark:bg-rose-500/15 dark:text-rose-200',
94
- 'bg-sky-100/70 text-sky-900 dark:bg-sky-500/15 dark:text-sky-200',
95
- 'bg-orange-100/70 text-orange-900 dark:bg-orange-500/15 dark:text-orange-200',
96
- ];
97
-
98
- function tileTintFor(seed: string | null | undefined): string {
99
- if (!seed) return TILE_TINTS[0];
100
- let hash = 0;
101
- for (let i = 0; i < seed.length; i++) {
102
- hash = (hash * 31 + seed.charCodeAt(i)) >>> 0;
103
- }
104
- return TILE_TINTS[hash % TILE_TINTS.length];
105
- }
106
-
107
- function compactNumber(n: number | null | undefined): string {
108
- if (typeof n !== 'number' || !Number.isFinite(n)) return '0';
109
- return new Intl.NumberFormat('en-US').format(n);
110
- }
111
-
112
- function resolvedDocumentCount(
113
- database: Pick<DatabaseCatalogRow, 'documents_count' | 'successful_documents' | 'total_documents'> | null | undefined,
114
- ): number {
115
- const count = database?.documents_count ?? database?.successful_documents ?? database?.total_documents;
116
- if (typeof count !== 'number' || !Number.isFinite(count)) return 0;
117
- return Math.max(0, count);
118
- }
119
-
120
- function formatDateTime(value: string | null | undefined): string {
121
- if (!value) return '—';
122
- const parsed = new Date(value);
123
- if (Number.isNaN(parsed.getTime())) return value;
124
- return new Intl.DateTimeFormat('en-US', {
125
- month: 'short',
126
- day: 'numeric',
127
- year: 'numeric',
128
- hour: 'numeric',
129
- minute: '2-digit',
130
- }).format(parsed);
131
- }
132
-
133
- function formatDate(value: string | null | undefined): string {
134
- if (!value) return '—';
135
- const parsed = new Date(value);
136
- if (Number.isNaN(parsed.getTime())) return value;
137
- return new Intl.DateTimeFormat('en-US', {
138
- month: 'short',
139
- day: 'numeric',
140
- year: 'numeric',
141
- }).format(parsed);
142
- }
143
-
144
- function textFromRichText(value: unknown): string {
145
- if (typeof value === 'string') return value;
146
- if (!Array.isArray(value)) return '';
147
- return value
148
- .map((chunk) => {
149
- if (!chunk || typeof chunk !== 'object') return '';
150
- const item = chunk as Record<string, unknown>;
151
- if (typeof item.plain_text === 'string') return item.plain_text;
152
- const text = item.text;
153
- if (text && typeof text === 'object') {
154
- const content = (text as Record<string, unknown>).content;
155
- if (typeof content === 'string') return content;
156
- }
157
- if (typeof item.content === 'string') return item.content;
158
- return '';
159
- })
160
- .join('');
161
- }
162
-
163
- function relationLabel(value: unknown, noun: string): string {
164
- const count = Array.isArray(value) ? value.length : 0;
165
- return `${compactNumber(count)} ${noun}${count === 1 ? '' : 's'}`;
166
- }
167
-
168
- const SELECT_TINTS: Record<string, string> = {
169
- default: 'bg-muted text-foreground',
170
- gray: 'bg-zinc-200 text-zinc-800 dark:bg-zinc-500/20 dark:text-zinc-200',
171
- brown: 'bg-amber-200/60 text-amber-900 dark:bg-amber-500/20 dark:text-amber-200',
172
- orange: 'bg-orange-100 text-orange-900 dark:bg-orange-500/20 dark:text-orange-200',
173
- yellow: 'bg-amber-100 text-amber-900 dark:bg-amber-500/20 dark:text-amber-200',
174
- green: 'bg-emerald-100 text-emerald-900 dark:bg-emerald-500/20 dark:text-emerald-200',
175
- blue: 'bg-sky-100 text-sky-900 dark:bg-sky-500/20 dark:text-sky-200',
176
- purple: 'bg-violet-100 text-violet-900 dark:bg-violet-500/20 dark:text-violet-200',
177
- pink: 'bg-pink-100 text-pink-900 dark:bg-pink-500/20 dark:text-pink-200',
178
- red: 'bg-rose-100 text-rose-900 dark:bg-rose-500/20 dark:text-rose-200',
179
- };
180
-
181
- function selectTint(color: string | null | undefined): string {
182
- if (!color) return SELECT_TINTS.default;
183
- return SELECT_TINTS[color] ?? SELECT_TINTS.default;
184
- }
185
-
186
- type Group = {
187
- key: string;
188
- label: string;
189
- rows: DatabaseCatalogRow[];
190
- };
191
-
192
- function groupRows(rows: DatabaseCatalogRow[]): Group[] {
193
- const map = new Map<string, Group>();
194
- for (const row of rows) {
195
- const key = row.owner_app_id ?? '__workspace__';
196
- const label = row.owner_app_name ?? 'Workspace';
197
- if (!map.has(key)) {
198
- map.set(key, { key, label, rows: [] });
199
- }
200
- map.get(key)!.rows.push(row);
201
- }
202
- for (const group of map.values()) {
203
- group.rows.sort((a, b) => (a.name ?? '').localeCompare(b.name ?? ''));
204
- }
205
- return Array.from(map.values()).sort((a, b) => a.label.localeCompare(b.label));
206
- }
207
-
208
- function relationCount(database: DatabaseDetail | null): number {
209
- if (!database?.schema?.properties) return 0;
210
- return database.schema.properties.filter((p) => p.type === 'relation').length;
211
- }
212
-
213
- function nonRelationProps(database: DatabaseDetail | null): DatabaseProperty[] {
214
- if (!database?.schema?.properties) return [];
215
- return database.schema.properties.filter((p) => p.type !== 'relation');
216
- }
217
-
218
- function relationProps(database: DatabaseDetail | null): DatabaseProperty[] {
219
- if (!database?.schema?.properties) return [];
220
- return database.schema.properties.filter((p) => p.type === 'relation');
221
- }
222
-
223
- type ActiveTab = 'properties' | 'relations' | 'documents';
224
-
225
- export default function CatalogPage() {
226
- const listDatabases = useTool<ListDatabasesArgs, ListDatabasesResult>(
227
- 'LOCAL_NOTIS_DATABASE_LIST_DATABASES',
228
- );
229
- const getDatabase = useTool<GetDatabaseArgs, GetDatabaseResult>(
230
- 'LOCAL_NOTIS_DATABASE_GET_DATABASE',
231
- );
232
- const queryDatabase = useTool<QueryDatabaseArgs, QueryDatabaseResult>(
233
- 'LOCAL_NOTIS_DATABASE_QUERY',
234
- );
235
-
236
- const [rows, setRows] = useState<DatabaseCatalogRow[]>([]);
237
- const [listError, setListError] = useState<string | null>(null);
238
- const [listLoading, setListLoading] = useState(true);
239
-
240
- const [selectedId, setSelectedId] = useState<string | null>(null);
241
- const [collapsedGroups, setCollapsedGroups] = useState<Record<string, boolean>>({});
242
- const [search, setSearch] = useState('');
243
-
244
- const [detail, setDetail] = useState<DatabaseDetail | null>(null);
245
- const [detailError, setDetailError] = useState<string | null>(null);
246
- const [detailLoading, setDetailLoading] = useState(false);
247
- const [activeTab, setActiveTab] = useState<ActiveTab>('properties');
248
-
249
- const detailRequestId = useRef(0);
250
- const documentRequestId = useRef(0);
251
-
252
- const [documents, setDocuments] = useState<DatabaseDocument[]>([]);
253
- const [documentsLoading, setDocumentsLoading] = useState(false);
254
- const [documentsError, setDocumentsError] = useState<string | null>(null);
255
-
256
- const listCall = listDatabases.call;
257
- useEffect(() => {
258
- let cancelled = false;
259
- setListLoading(true);
260
- setListError(null);
261
- listCall({} as ListDatabasesArgs)
262
- .then((result) => {
263
- if (cancelled) return;
264
- const next = (result?.databases ?? []).filter((db): db is DatabaseCatalogRow =>
265
- Boolean(db && typeof db.id === 'string'),
266
- );
267
- setRows(next);
268
- setSelectedId((current) => {
269
- if (current && next.some((row) => row.id === current)) return current;
270
- return next[0]?.id ?? null;
271
- });
272
- })
273
- .catch((err: unknown) => {
274
- if (cancelled) return;
275
- setListError(err instanceof Error ? err.message : 'Failed to load databases.');
276
- })
277
- .finally(() => {
278
- if (!cancelled) setListLoading(false);
279
- });
280
- return () => {
281
- cancelled = true;
282
- };
283
- }, [listCall]);
284
-
285
- const getCall = getDatabase.call;
286
- useEffect(() => {
287
- if (!selectedId) {
288
- setDetail(null);
289
- setDetailError(null);
290
- setDetailLoading(false);
291
- return;
292
- }
293
- const requestId = ++detailRequestId.current;
294
- setDetailLoading(true);
295
- setDetailError(null);
296
- setActiveTab('properties');
297
- setDocuments([]);
298
- setDocumentsError(null);
299
- setDocumentsLoading(false);
300
- getCall({ database_id: selectedId })
301
- .then((result) => {
302
- if (requestId !== detailRequestId.current) return;
303
- if (result && 'database' in result && result.database) {
304
- setDetail(result.database);
305
- } else {
306
- const message =
307
- result && 'message' in result && typeof result.message === 'string'
308
- ? result.message
309
- : 'Database not found.';
310
- setDetail(null);
311
- setDetailError(message);
312
- }
313
- })
314
- .catch((err: unknown) => {
315
- if (requestId !== detailRequestId.current) return;
316
- setDetail(null);
317
- setDetailError(err instanceof Error ? err.message : 'Failed to load database.');
318
- })
319
- .finally(() => {
320
- if (requestId === detailRequestId.current) setDetailLoading(false);
321
- });
322
- }, [selectedId, getCall]);
323
-
324
- const queryCall = queryDatabase.call;
325
- useEffect(() => {
326
- if (activeTab !== 'documents') return;
327
- if (!detail) return;
328
-
329
- const databaseId = detail.id;
330
- if (!databaseId) {
331
- setDocuments([]);
332
- setDocumentsError('This database does not have a stable ID.');
333
- setDocumentsLoading(false);
334
- return;
335
- }
336
-
337
- const requestId = ++documentRequestId.current;
338
- setDocuments([]);
339
- setDocumentsError(null);
340
- setDocumentsLoading(true);
341
-
342
- const loadDocuments = async () => {
343
- const pageSize = 100;
344
- const maxPages = 1000;
345
- let offset = 0;
346
- let collected: DatabaseDocument[] = [];
347
-
348
- for (let page = 0; page < maxPages; page += 1) {
349
- const result = await queryCall({
350
- database_id: databaseId,
351
- query: { page_size: pageSize },
352
- offset,
353
- });
354
- if (requestId !== documentRequestId.current) return;
355
-
356
- if (!result || result.status === 'error') {
357
- throw new Error(result?.message || 'Failed to load documents.');
358
- }
359
-
360
- collected = [
361
- ...collected,
362
- ...(result.documents ?? []).map((document) => normalizeDocumentRecord(document)),
363
- ];
364
- setDocuments(collected);
365
-
366
- if (!result.has_more) return;
367
- if (typeof result.next_offset !== 'number') {
368
- throw new Error('The document query did not return the next page offset.');
369
- }
370
- offset = result.next_offset;
371
- }
372
-
373
- throw new Error('Document query exceeded the pagination safety limit.');
374
- };
375
-
376
- loadDocuments()
377
- .catch((err: unknown) => {
378
- if (requestId !== documentRequestId.current) return;
379
- setDocumentsError(err instanceof Error ? err.message : 'Failed to load documents.');
380
- })
381
- .finally(() => {
382
- if (requestId === documentRequestId.current) setDocumentsLoading(false);
383
- });
384
-
385
- return () => {
386
- if (requestId === documentRequestId.current) {
387
- documentRequestId.current += 1;
388
- }
389
- };
390
- }, [activeTab, detail, queryCall]);
391
-
392
- const handleSearchChange = useCallback((next: string) => setSearch(next), []);
393
- useTopBarSearch({
394
- value: search,
395
- onChange: handleSearchChange,
396
- placeholder: 'Search databases',
397
- });
398
-
399
- const filteredRows = useMemo(() => {
400
- const q = search.trim().toLowerCase();
401
- if (!q) return rows;
402
- return rows.filter((row) => {
403
- const haystack = [row.name, row.slug, row.description, row.owner_app_name]
404
- .filter((v): v is string => typeof v === 'string')
405
- .join(' ')
406
- .toLowerCase();
407
- return haystack.includes(q);
408
- });
409
- }, [rows, search]);
410
-
411
- const groups = useMemo(() => groupRows(filteredRows), [filteredRows]);
412
- const docCount = resolvedDocumentCount(detail);
413
- const relCount = relationCount(detail);
414
- const propCount = nonRelationProps(detail).length;
415
-
416
- return (
417
- <div
418
- data-store-screenshot="catalog"
419
- className="flex h-screen w-full overflow-hidden bg-background text-foreground antialiased"
420
- >
421
- <aside className="flex h-full w-[288px] flex-shrink-0 flex-col border-r border-border bg-background">
422
- <div className="flex items-baseline justify-between gap-2 px-4 pb-3 pt-4">
423
- <h1 className="text-lg font-semibold tracking-tight">Databases</h1>
424
- <span className="text-[11px] tabular-nums text-muted-foreground">
425
- {compactNumber(rows.length)}
426
- </span>
427
- </div>
428
-
429
- <div className="flex-1 overflow-y-auto px-2.5 pb-4">
430
- {listLoading ? (
431
- <ListSkeleton />
432
- ) : listError ? (
433
- <ListError message={listError} />
434
- ) : groups.length === 0 ? (
435
- <ListEmpty hasSearch={Boolean(search.trim())} />
436
- ) : (
437
- groups.map((group) => {
438
- const collapsed = collapsedGroups[group.key];
439
- return (
440
- <div key={group.key} className="mt-2 first:mt-0">
441
- <button
442
- type="button"
443
- onClick={() =>
444
- setCollapsedGroups((prev) => ({
445
- ...prev,
446
- [group.key]: !prev[group.key],
447
- }))
448
- }
449
- className="flex w-full items-center gap-1.5 px-2 pb-1.5 pt-1 text-left transition-colors hover:text-foreground"
450
- >
451
- <ChevronDown
452
- className={cn(
453
- 'h-2.5 w-2.5 text-foreground transition-transform',
454
- collapsed && '-rotate-90',
455
- )}
456
- />
457
- <span className="text-[11px] font-medium uppercase tracking-[0.06em] text-muted-foreground">
458
- {group.label}
459
- </span>
460
- <span className="ml-1 h-px flex-1 bg-border/70" />
461
- </button>
462
- {!collapsed &&
463
- group.rows.map((row) => (
464
- <CatalogRow
465
- key={row.id}
466
- row={row}
467
- active={row.id === selectedId}
468
- onSelect={() => setSelectedId(row.id)}
469
- />
470
- ))}
471
- </div>
472
- );
473
- })
474
- )}
475
- </div>
476
- </aside>
477
-
478
- <section className="flex h-full min-w-0 flex-1 flex-col overflow-hidden bg-background">
479
- {listLoading || detailLoading || (selectedId && !detail && !detailError) ? (
480
- <DetailSkeleton />
481
- ) : detailError ? (
482
- <DetailError message={detailError} />
483
- ) : !detail ? (
484
- <DetailEmpty hasRows={rows.length > 0} />
485
- ) : (
486
- <>
487
- <DetailHeader
488
- database={detail}
489
- activeTab={activeTab}
490
- onTabChange={setActiveTab}
491
- propCount={propCount}
492
- relCount={relCount}
493
- docCount={docCount}
494
- />
495
- <div className="flex-1 overflow-y-auto px-4 py-2">
496
- {activeTab === 'properties' && (
497
- <PropertyList properties={nonRelationProps(detail)} />
498
- )}
499
- {activeTab === 'relations' && (
500
- <RelationsList properties={relationProps(detail)} />
501
- )}
502
- {activeTab === 'documents' && (
503
- <DocumentsTable
504
- database={detail}
505
- documents={documents}
506
- loading={documentsLoading}
507
- error={documentsError}
508
- expectedCount={docCount}
509
- />
510
- )}
511
- </div>
512
- </>
513
- )}
514
- </section>
515
- </div>
516
- );
517
- }
518
-
519
- function CatalogRow({
520
- row,
521
- active,
522
- onSelect,
523
- }: {
524
- row: DatabaseCatalogRow;
525
- active: boolean;
526
- onSelect: () => void;
527
- }) {
528
- const docs = resolvedDocumentCount(row);
529
- const tint = tileTintFor(row.slug ?? row.id);
530
- return (
531
- <button
532
- type="button"
533
- onClick={onSelect}
534
- className={cn(
535
- 'flex w-full items-center gap-2.5 rounded-md p-2 text-left transition-colors',
536
- active ? 'bg-foreground text-background' : 'hover:bg-muted/60 text-foreground',
537
- )}
538
- >
539
- <span
540
- className={cn(
541
- 'flex size-6 flex-shrink-0 items-center justify-center rounded-md',
542
- active ? 'bg-background/15 text-background' : tint,
543
- )}
544
- >
545
- <Database className="h-3 w-3" />
546
- </span>
547
- <span className="flex min-w-0 flex-1 flex-col gap-0.5">
548
- <span
549
- className={cn(
550
- 'truncate text-[13px] font-medium tracking-[-0.005em]',
551
- active ? 'text-background' : 'text-foreground',
552
- )}
553
- >
554
- {row.name ?? row.slug ?? 'Untitled'}
555
- </span>
556
- <span
557
- className={cn(
558
- 'truncate text-[11px] tabular-nums',
559
- active ? 'text-background/60' : 'text-muted-foreground',
560
- )}
561
- >
562
- {compactNumber(docs)} docs
563
- </span>
564
- </span>
565
- </button>
566
- );
567
- }
568
-
569
- function ListSkeleton() {
570
- return (
571
- <div className="space-y-1.5 p-1.5">
572
- {[0, 1, 2, 3, 4].map((i) => (
573
- <div
574
- key={i}
575
- className="flex items-center gap-2.5 rounded-md p-2"
576
- >
577
- <div className="size-6 animate-pulse rounded-md bg-muted" />
578
- <div className="flex flex-1 flex-col gap-1.5">
579
- <div className="h-3 w-24 animate-pulse rounded bg-muted" />
580
- <div className="h-2 w-16 animate-pulse rounded bg-muted/70" />
581
- </div>
582
- </div>
583
- ))}
584
- </div>
585
- );
586
- }
587
-
588
- function ListError({ message }: { message: string }) {
589
- return (
590
- <div className="mt-6 flex flex-col items-center gap-2 rounded-md border border-dashed border-border px-3 py-6 text-center">
591
- <AlertCircle className="h-4 w-4 text-destructive" />
592
- <p className="text-xs text-muted-foreground">{message}</p>
593
- </div>
594
- );
595
- }
596
-
597
- function ListEmpty({ hasSearch }: { hasSearch: boolean }) {
598
- return (
599
- <div className="mt-12 flex flex-col items-center px-3 text-center">
600
- <Database className="mb-3 h-8 w-8 text-muted-foreground/30" strokeWidth={1.5} />
601
- <p className="text-sm font-medium text-foreground">
602
- {hasSearch ? 'No matches' : 'No databases yet'}
603
- </p>
604
- <p className="mt-1 max-w-[220px] text-[11px] text-muted-foreground">
605
- {hasSearch
606
- ? 'Try a different name or app.'
607
- : 'Databases created in your Notis workspace will appear here.'}
608
- </p>
609
- </div>
610
- );
611
- }
612
-
613
- function DetailSkeleton() {
614
- return (
615
- <div className="flex flex-1 items-center justify-center">
616
- <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
617
- </div>
618
- );
619
- }
620
-
621
- function DetailError({ message }: { message: string }) {
622
- return (
623
- <div className="flex flex-1 flex-col items-center justify-center gap-2 px-10 text-center">
624
- <AlertCircle className="h-6 w-6 text-destructive" />
625
- <p className="text-sm font-medium text-foreground">Couldn't load this database</p>
626
- <p className="max-w-[42ch] text-xs text-muted-foreground">{message}</p>
627
- </div>
628
- );
629
- }
630
-
631
- function DetailEmpty({ hasRows }: { hasRows: boolean }) {
632
- return (
633
- <div className="flex flex-1 flex-col items-center justify-center gap-3 px-10 text-center">
634
- <Database className="h-10 w-10 text-muted-foreground/25" strokeWidth={1.4} />
635
- <p className="text-sm font-semibold text-foreground">
636
- {hasRows ? 'Select a database' : 'No databases yet'}
637
- </p>
638
- <p className="max-w-[42ch] text-xs text-muted-foreground">
639
- {hasRows
640
- ? 'Pick a database on the left to view its schema, properties, and relations.'
641
- : 'Databases created in your Notis workspace will appear here.'}
642
- </p>
643
- </div>
644
- );
645
- }
646
-
647
- function DetailHeader({
648
- database,
649
- activeTab,
650
- onTabChange,
651
- propCount,
652
- relCount,
653
- docCount,
654
- }: {
655
- database: DatabaseDetail;
656
- activeTab: ActiveTab;
657
- onTabChange: (tab: ActiveTab) => void;
658
- propCount: number;
659
- relCount: number;
660
- docCount: number;
661
- }) {
662
- const tint = tileTintFor(database.slug ?? database.id);
663
- const eyebrow = [database.owner_app_name ?? 'Workspace', 'Database']
664
- .filter(Boolean)
665
- .join(' · ');
666
-
667
- return (
668
- <header className="flex flex-col gap-3.5 border-b border-border px-10 pb-5 pt-9">
669
- <div className="flex items-center gap-3.5">
670
- <span
671
- className={cn(
672
- 'flex size-11 flex-shrink-0 items-center justify-center rounded-[11px]',
673
- tint,
674
- )}
675
- >
676
- <Database className="h-[22px] w-[22px]" strokeWidth={1.7} />
677
- </span>
678
- <div className="flex min-w-0 flex-1 flex-col gap-0.5">
679
- <span className="text-[11px] font-medium uppercase tracking-[0.06em] text-muted-foreground">
680
- {eyebrow.toUpperCase()}
681
- </span>
682
- <h2 className="truncate text-2xl font-semibold tracking-[-0.02em] text-foreground">
683
- {database.name ?? database.slug ?? 'Untitled database'}
684
- </h2>
685
- </div>
686
- </div>
687
-
688
- {database.description ? (
689
- <p className="max-w-[60ch] text-sm leading-6 text-muted-foreground">
690
- {database.description}
691
- </p>
692
- ) : null}
693
-
694
- <div className="mt-1.5 flex items-center gap-1">
695
- <TabButton
696
- icon={<ListChecks className="h-3 w-3" />}
697
- label="Properties"
698
- count={propCount}
699
- active={activeTab === 'properties'}
700
- tab="properties"
701
- onClick={() => onTabChange('properties')}
702
- />
703
- <TabButton
704
- icon={<Link2 className="h-3 w-3" />}
705
- label="Relations"
706
- count={relCount}
707
- active={activeTab === 'relations'}
708
- tab="relations"
709
- onClick={() => onTabChange('relations')}
710
- />
711
- <TabButton
712
- icon={<Database className="h-3 w-3" />}
713
- label="Documents"
714
- count={docCount}
715
- active={activeTab === 'documents'}
716
- tab="documents"
717
- onClick={() => onTabChange('documents')}
718
- />
719
- </div>
720
- </header>
721
- );
722
- }
723
-
724
- function TabButton({
725
- icon,
726
- label,
727
- count,
728
- active,
729
- tab,
730
- onClick,
731
- }: {
732
- icon: React.ReactNode;
733
- label: string;
734
- count: number;
735
- active: boolean;
736
- tab: ActiveTab;
737
- onClick: () => void;
738
- }) {
739
- return (
740
- <button
741
- type="button"
742
- data-tab={tab}
743
- onClick={onClick}
744
- className={cn(
745
- 'flex items-center gap-1.5 px-3.5 py-1.5 text-[12.5px] transition-colors',
746
- active
747
- ? 'border-b-[1.5px] border-foreground font-medium text-foreground'
748
- : 'text-muted-foreground hover:text-foreground',
749
- )}
750
- >
751
- {icon}
752
- <span>{label}</span>
753
- <span className={cn('tabular-nums', active ? 'text-muted-foreground' : 'text-muted-foreground/70')}>
754
- {compactNumber(count)}
755
- </span>
756
- </button>
757
- );
758
- }
759
-
760
- function PropertyList({ properties }: { properties: DatabaseProperty[] }) {
761
- if (properties.length === 0) {
762
- return <SectionEmpty label="No properties defined." />;
763
- }
764
- return (
765
- <div className="flex flex-col">
766
- {properties.map((prop, index) => (
767
- <PropertyRow key={prop.id} property={prop} striped={index % 2 === 1} />
768
- ))}
769
- </div>
770
- );
771
- }
772
-
773
- function PropertyRow({ property, striped }: { property: DatabaseProperty; striped: boolean }) {
774
- const typeLabel = TYPE_LABEL[property.type] ?? property.type;
775
- const isTitle = property.type === 'title';
776
- const options = property.options ?? [];
777
-
778
- return (
779
- <div
780
- className={cn(
781
- 'flex flex-col gap-1.5 rounded-lg px-4 py-3.5',
782
- striped && 'bg-muted/40',
783
- )}
784
- >
785
- <div className="flex items-center gap-2.5">
786
- <PropertyTypeIcon type={property.type} />
787
- <span className="text-[13.5px] font-semibold tracking-[-0.005em] text-foreground">
788
- {property.name ?? 'Untitled'}
789
- </span>
790
- {isTitle ? (
791
- <Badge
792
- variant="secondary"
793
- className="rounded-sm border-transparent bg-foreground/[0.08] px-1.5 py-px text-[10.5px] font-medium uppercase tracking-[0.02em] text-muted-foreground"
794
- >
795
- Title
796
- </Badge>
797
- ) : null}
798
- <span className="flex-1" />
799
- <span className="text-[11px] text-muted-foreground">{typeLabel}</span>
800
- </div>
801
-
802
- {options.length > 0 ? (
803
- <div className="flex flex-wrap items-center gap-1.5 pl-6">
804
- {options.map((option, index) => (
805
- <span
806
- key={option.id ?? option.name ?? index}
807
- className={cn(
808
- 'inline-flex items-center rounded-full px-2.5 py-0.5 text-[11px] font-medium',
809
- selectTint(option.color),
810
- )}
811
- >
812
- {option.name ?? '—'}
813
- </span>
814
- ))}
815
- </div>
816
- ) : null}
817
-
818
- {property.format ? (
819
- <div className="pl-6">
820
- <span className="inline-flex items-center rounded-md border border-border bg-card px-2 py-0.5 text-[11px] text-muted-foreground">
821
- Format · {property.format}
822
- </span>
823
- </div>
824
- ) : null}
825
-
826
- {property.expression ? (
827
- <div className="max-w-[60ch] pl-6">
828
- <code className="block truncate rounded-md bg-muted/60 px-2 py-1 font-mono text-[11px] text-muted-foreground">
829
- {property.expression}
830
- </code>
831
- </div>
832
- ) : null}
833
-
834
- {property.description ? (
835
- <div className="max-w-[52ch] pl-6">
836
- <p className="text-[13px] leading-5 text-muted-foreground">{property.description}</p>
837
- </div>
838
- ) : null}
839
- </div>
840
- );
841
- }
842
-
843
- function RelationsList({ properties }: { properties: DatabaseProperty[] }) {
844
- if (properties.length === 0) {
845
- return <SectionEmpty label="No relations defined." />;
846
- }
847
- return (
848
- <div className="flex flex-col">
849
- {properties.map((prop, index) => (
850
- <RelationRow key={prop.id} property={prop} striped={index % 2 === 1} />
851
- ))}
852
- </div>
853
- );
854
- }
855
-
856
- function RelationRow({ property, striped }: { property: DatabaseProperty; striped: boolean }) {
857
- const target = property.relation_target;
858
- return (
859
- <div
860
- className={cn(
861
- 'flex flex-col gap-1.5 rounded-lg px-4 py-3.5',
862
- striped && 'bg-muted/40',
863
- )}
864
- >
865
- <div className="flex items-center gap-2.5">
866
- <Link2 className="h-3.5 w-3.5 text-muted-foreground" />
867
- <span className="text-[13.5px] font-semibold tracking-[-0.005em] text-foreground">
868
- {property.name ?? 'Untitled'}
869
- </span>
870
- <span className="flex-1" />
871
- <span className="text-[11px] text-muted-foreground">Relation</span>
872
- </div>
873
- <div className="flex items-center gap-1.5 pl-6">
874
- <span className="text-[11px] text-muted-foreground">→</span>
875
- <span className="inline-flex items-center gap-1.5 rounded-md border border-border bg-card px-2 py-0.5 text-[11.5px] font-medium text-foreground">
876
- <Database className="h-3 w-3 text-muted-foreground" />
877
- {target?.database_name ?? target?.database_slug ?? 'Unknown database'}
878
- </span>
879
- </div>
880
- {property.description ? (
881
- <div className="max-w-[52ch] pl-6">
882
- <p className="text-[13px] leading-5 text-muted-foreground">{property.description}</p>
883
- </div>
884
- ) : null}
885
- </div>
886
- );
887
- }
888
-
889
- function DocumentsTable({
890
- database,
891
- documents,
892
- loading,
893
- error,
894
- expectedCount,
895
- }: {
896
- database: DatabaseDetail;
897
- documents: DatabaseDocument[];
898
- loading: boolean;
899
- error: string | null;
900
- expectedCount: number;
901
- }) {
902
- const properties = (database.schema?.properties ?? []).filter((property) => property.type !== 'title');
903
-
904
- if (loading && documents.length === 0) {
905
- return (
906
- <div className="flex flex-col items-center justify-center gap-2 py-16 text-center">
907
- <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
908
- <p className="text-[12.5px] text-muted-foreground">Loading documents</p>
909
- </div>
910
- );
911
- }
912
-
913
- if (error) {
914
- return (
915
- <div className="flex flex-col items-center justify-center gap-2 py-16 text-center">
916
- <AlertCircle className="h-5 w-5 text-destructive" />
917
- <p className="text-sm font-medium text-foreground">Couldn't load documents</p>
918
- <p className="max-w-[44ch] text-[12.5px] text-muted-foreground">{error}</p>
919
- </div>
920
- );
921
- }
922
-
923
- if (documents.length === 0) {
924
- return <DocumentsEmpty count={expectedCount} />;
925
- }
926
-
927
- return (
928
- <div className="flex flex-col gap-2">
929
- <div className="flex items-center justify-between gap-3 px-1">
930
- <p className="text-[12.5px] text-muted-foreground">
931
- {compactNumber(documents.length)} loaded
932
- </p>
933
- {loading ? (
934
- <div className="flex items-center gap-1.5 text-[12.5px] text-muted-foreground">
935
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
936
- <span>Loading more</span>
937
- </div>
938
- ) : null}
939
- </div>
940
- <div className="rounded-md border border-border bg-card">
941
- <Table>
942
- <TableHeader>
943
- <TableRow>
944
- <TableHead className="min-w-[260px]">Document</TableHead>
945
- <TableHead className="min-w-[150px]">Created</TableHead>
946
- <TableHead className="min-w-[150px]">Last edited</TableHead>
947
- {properties.map((property) => (
948
- <TableHead key={property.id} className="min-w-[160px]">
949
- {property.name ?? property.id}
950
- </TableHead>
951
- ))}
952
- </TableRow>
953
- </TableHeader>
954
- <TableBody>
955
- {documents.map((document) => (
956
- <TableRow key={document.id}>
957
- <TableCell className="min-w-[260px]">
958
- <div className="flex min-w-0 flex-col gap-1">
959
- <span className="truncate font-medium text-foreground">
960
- {document.title || 'Untitled document'}
961
- </span>
962
- <span className="truncate font-mono text-[11px] text-muted-foreground">
963
- {document.id}
964
- </span>
965
- </div>
966
- </TableCell>
967
- <TableCell className="whitespace-nowrap text-muted-foreground">
968
- {formatDateTime(document.createdAt)}
969
- </TableCell>
970
- <TableCell className="whitespace-nowrap text-muted-foreground">
971
- {formatDateTime(document.lastEditedTime)}
972
- </TableCell>
973
- {properties.map((property) => {
974
- const propertyName = property.name ?? property.id;
975
- return (
976
- <TableCell key={`${document.id}-${property.id}`} className="max-w-[260px]">
977
- <PropertyValue
978
- property={property}
979
- value={document.properties?.[propertyName]}
980
- />
981
- </TableCell>
982
- );
983
- })}
984
- </TableRow>
985
- ))}
986
- </TableBody>
987
- </Table>
988
- </div>
989
- </div>
990
- );
991
- }
992
-
993
- function DocumentsEmpty({ count }: { count: number }) {
994
- return (
995
- <div className="flex flex-col items-center justify-center gap-2 py-16 text-center">
996
- <Database className="h-8 w-8 text-muted-foreground/25" strokeWidth={1.4} />
997
- <p className="text-sm font-medium text-foreground">{compactNumber(count)} documents</p>
998
- </div>
999
- );
1000
- }
1001
-
1002
- function PropertyValue({
1003
- property,
1004
- value,
1005
- }: {
1006
- property: DatabaseProperty;
1007
- value: DocumentPropertyValue | undefined;
1008
- }) {
1009
- if (value == null || value === '') return <MutedDash />;
1010
-
1011
- switch (property.type) {
1012
- case 'title':
1013
- case 'rich_text':
1014
- return <TextValue value={typeof value === 'string' ? value : stringifyFallback(value)} />;
1015
- case 'number':
1016
- return <TextValue value={typeof value === 'number' ? compactNumber(value) : ''} />;
1017
- case 'select':
1018
- case 'status':
1019
- if (typeof value !== 'string') return <MutedDash />;
1020
- return (
1021
- <Badge variant="secondary" className="rounded-sm px-1.5 py-px">
1022
- {value}
1023
- </Badge>
1024
- );
1025
- case 'multi_select': {
1026
- const options = Array.isArray(value) ? value : [];
1027
- if (options.length === 0) return <MutedDash />;
1028
- return (
1029
- <div className="flex max-w-[240px] flex-wrap gap-1">
1030
- {options.map((option, index) => {
1031
- const label = typeof option === 'string' ? option : stringifyFallback(option);
1032
- return (
1033
- <Badge
1034
- key={`${label}-${index}`}
1035
- variant="secondary"
1036
- className="rounded-sm px-1.5 py-px"
1037
- >
1038
- {label || 'Untitled'}
1039
- </Badge>
1040
- );
1041
- })}
1042
- </div>
1043
- );
1044
- }
1045
- case 'checkbox':
1046
- return <TextValue value={value === true ? 'Yes' : 'No'} />;
1047
- case 'date':
1048
- return <TextValue value={typeof value === 'string' ? formatDate(value) : ''} />;
1049
- case 'url':
1050
- case 'email':
1051
- case 'phone_number':
1052
- return <TextValue value={typeof value === 'string' ? value : ''} />;
1053
- case 'relation':
1054
- case 'people':
1055
- case 'files':
1056
- return <TextValue value={relationLabel(value, property.type === 'people' ? 'person' : property.type === 'files' ? 'file' : 'linked record')} />;
1057
- default:
1058
- return <TextValue value={stringifyFallback(value)} />;
1059
- }
1060
- }
1061
-
1062
- function TextValue({ value }: { value: string }) {
1063
- if (!value) return <MutedDash />;
1064
- return <span className="block truncate text-[12.5px] text-foreground">{value}</span>;
1065
- }
1066
-
1067
- function MutedDash() {
1068
- return <span className="text-muted-foreground/60">—</span>;
1069
- }
1070
-
1071
- function stringifyFallback(value: unknown): string {
1072
- if (value == null) return '';
1073
- if (typeof value === 'string') return value;
1074
- if (typeof value === 'number' || typeof value === 'boolean') return String(value);
1075
- try {
1076
- return JSON.stringify(value);
1077
- } catch {
1078
- return '';
1079
- }
1080
- }
1081
-
1082
- function SectionEmpty({ label }: { label: string }) {
1083
- return (
1084
- <div className="flex flex-col items-center justify-center gap-1 py-12 text-center">
1085
- <p className="text-[12.5px] text-muted-foreground">{label}</p>
1086
- </div>
1087
- );
1088
- }