@stigmer/react 3.11.1-dev.20260812192248 → 3.12.1

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 (273) hide show
  1. package/activity/useRecentActivity.d.ts +3 -2
  2. package/activity/useRecentActivity.d.ts.map +1 -1
  3. package/activity/useRecentActivity.js +3 -2
  4. package/activity/useRecentActivity.js.map +1 -1
  5. package/agent/AgentDetailView.d.ts +2 -12
  6. package/agent/AgentDetailView.d.ts.map +1 -1
  7. package/agent/AgentDetailView.js +10 -42
  8. package/agent/AgentDetailView.js.map +1 -1
  9. package/agent/internal/agentToInput.d.ts.map +1 -1
  10. package/agent/internal/agentToInput.js +0 -8
  11. package/agent/internal/agentToInput.js.map +1 -1
  12. package/dependency-graph/DependencyTreeNode.d.ts.map +1 -1
  13. package/dependency-graph/DependencyTreeNode.js +1 -7
  14. package/dependency-graph/DependencyTreeNode.js.map +1 -1
  15. package/dependency-graph/types.d.ts +8 -20
  16. package/dependency-graph/types.d.ts.map +1 -1
  17. package/dependency-graph/useDependencyGraph.d.ts.map +1 -1
  18. package/dependency-graph/useDependencyGraph.js +2 -20
  19. package/dependency-graph/useDependencyGraph.js.map +1 -1
  20. package/execution/useCreateAgentExecution.d.ts +3 -2
  21. package/execution/useCreateAgentExecution.d.ts.map +1 -1
  22. package/execution/useCreateAgentExecution.js.map +1 -1
  23. package/index.d.ts +0 -2
  24. package/index.d.ts.map +1 -1
  25. package/index.js +0 -6
  26. package/index.js.map +1 -1
  27. package/internal/isUnimplemented.d.ts +17 -0
  28. package/internal/isUnimplemented.d.ts.map +1 -0
  29. package/internal/isUnimplemented.js +26 -0
  30. package/internal/isUnimplemented.js.map +1 -0
  31. package/library/useExportResource.d.ts +3 -4
  32. package/library/useExportResource.d.ts.map +1 -1
  33. package/library/useExportResource.js +1 -1
  34. package/library/useExportResource.js.map +1 -1
  35. package/manifest/EditResourceYamlDialog.d.ts.map +1 -1
  36. package/manifest/EditResourceYamlDialog.js.map +1 -1
  37. package/mcp-server/McpServerConnectDialog.js +7 -3
  38. package/mcp-server/McpServerConnectDialog.js.map +1 -1
  39. package/mcp-server/useMcpServerCredentials.d.ts +38 -10
  40. package/mcp-server/useMcpServerCredentials.d.ts.map +1 -1
  41. package/mcp-server/useMcpServerCredentials.js +50 -7
  42. package/mcp-server/useMcpServerCredentials.js.map +1 -1
  43. package/mcp-server/useOrgOAuthApp.d.ts +22 -0
  44. package/mcp-server/useOrgOAuthApp.d.ts.map +1 -1
  45. package/mcp-server/useOrgOAuthApp.js +39 -7
  46. package/mcp-server/useOrgOAuthApp.js.map +1 -1
  47. package/package.json +4 -4
  48. package/session/useSessionConversation.d.ts +4 -2
  49. package/session/useSessionConversation.d.ts.map +1 -1
  50. package/session/useSessionConversation.js.map +1 -1
  51. package/skill/useSkillVersions.d.ts.map +1 -1
  52. package/skill/useSkillVersions.js +1 -9
  53. package/skill/useSkillVersions.js.map +1 -1
  54. package/src/activity/useRecentActivity.ts +3 -2
  55. package/src/agent/AgentDetailView.tsx +6 -130
  56. package/src/agent/internal/__tests__/agentToInput.test.ts +2 -11
  57. package/src/agent/internal/agentToInput.ts +0 -11
  58. package/src/dependency-graph/DependencyTreeNode.tsx +1 -7
  59. package/src/dependency-graph/__tests__/useDependencyGraph.test.ts +18 -34
  60. package/src/dependency-graph/types.ts +8 -20
  61. package/src/dependency-graph/useDependencyGraph.ts +2 -22
  62. package/src/execution/useCreateAgentExecution.ts +3 -2
  63. package/src/index.ts +0 -82
  64. package/src/internal/isUnimplemented.ts +26 -0
  65. package/src/library/useExportResource.ts +3 -4
  66. package/src/manifest/EditResourceYamlDialog.tsx +1 -2
  67. package/src/manifest/__tests__/ApplyManifestDialog.test.tsx +2 -2
  68. package/src/manifest/__tests__/EditResourceYamlDialog.test.tsx +9 -9
  69. package/src/mcp-server/McpServerConnectDialog.tsx +29 -11
  70. package/src/mcp-server/__tests__/VendorApprovalBlocked.surfaces.test.tsx +103 -5
  71. package/src/mcp-server/__tests__/byoaEditionDegradation.test.tsx +323 -0
  72. package/src/mcp-server/__tests__/useMcpServerCredentials.test.tsx +306 -0
  73. package/src/mcp-server/useMcpServerCredentials.ts +87 -19
  74. package/src/mcp-server/useOrgOAuthApp.ts +54 -8
  75. package/src/session/useSessionConversation.ts +4 -2
  76. package/src/skill/useSkillVersions.ts +1 -11
  77. package/src/workflow/WorkflowCanvasEditor.tsx +37 -7
  78. package/src/workflow/WorkflowExecutionGraph.tsx +26 -1
  79. package/src/workflow/WorkflowExecutionViewer.tsx +27 -13
  80. package/src/workflow/WorkflowNode.tsx +5 -2
  81. package/src/workflow/WorkflowRunDialog.tsx +28 -1
  82. package/src/workflow/__tests__/WorkflowExecutionViewer.reconciliation.test.tsx +48 -1
  83. package/src/workflow/__tests__/WorkflowNode.test.tsx +93 -0
  84. package/src/workflow/__tests__/WorkflowRunDialog.test.tsx +127 -0
  85. package/src/workflow/__tests__/graph-history.test.ts +103 -0
  86. package/src/workflow/__tests__/overview-graph.test.ts +17 -0
  87. package/src/workflow/__tests__/useCanvasKeyboardShortcuts.undo.test.ts +115 -0
  88. package/src/workflow/__tests__/useWorkflowCanvas.undo.test.tsx +133 -0
  89. package/src/workflow/instance/CreateWorkflowInstanceDialog.tsx +16 -7
  90. package/src/workflow/instance/useDeleteWorkflowInstance.ts +9 -4
  91. package/src/workflow/layout/registry-dimensions.ts +2 -5
  92. package/src/workflow/node-shell/NodeShell.tsx +4 -0
  93. package/src/workflow/task-type-visual-registry.ts +5 -3
  94. package/src/workflow/useCanvasKeyboardShortcuts.ts +33 -3
  95. package/src/workflow/useGraphHistory.ts +22 -41
  96. package/src/workflow/useWorkflowCanvas.ts +12 -10
  97. package/src/workflow/useWorkflowSave.ts +2 -15
  98. package/src/workflow/workflow-graph-conversions.ts +25 -3
  99. package/styles.css +1 -1
  100. package/workflow/CanvasTransitionEdge.d.ts +1 -1
  101. package/workflow/WorkflowCanvasEditor.d.ts.map +1 -1
  102. package/workflow/WorkflowCanvasEditor.js +31 -6
  103. package/workflow/WorkflowCanvasEditor.js.map +1 -1
  104. package/workflow/WorkflowExecutionGraph.d.ts.map +1 -1
  105. package/workflow/WorkflowExecutionGraph.js +27 -1
  106. package/workflow/WorkflowExecutionGraph.js.map +1 -1
  107. package/workflow/WorkflowExecutionViewer.d.ts.map +1 -1
  108. package/workflow/WorkflowExecutionViewer.js +26 -12
  109. package/workflow/WorkflowExecutionViewer.js.map +1 -1
  110. package/workflow/WorkflowNode.d.ts.map +1 -1
  111. package/workflow/WorkflowNode.js +2 -2
  112. package/workflow/WorkflowNode.js.map +1 -1
  113. package/workflow/WorkflowRunDialog.d.ts +11 -1
  114. package/workflow/WorkflowRunDialog.d.ts.map +1 -1
  115. package/workflow/WorkflowRunDialog.js +16 -2
  116. package/workflow/WorkflowRunDialog.js.map +1 -1
  117. package/workflow/instance/CreateWorkflowInstanceDialog.d.ts.map +1 -1
  118. package/workflow/instance/CreateWorkflowInstanceDialog.js +10 -2
  119. package/workflow/instance/CreateWorkflowInstanceDialog.js.map +1 -1
  120. package/workflow/instance/useDeleteWorkflowInstance.d.ts +9 -4
  121. package/workflow/instance/useDeleteWorkflowInstance.d.ts.map +1 -1
  122. package/workflow/instance/useDeleteWorkflowInstance.js +4 -2
  123. package/workflow/instance/useDeleteWorkflowInstance.js.map +1 -1
  124. package/workflow/layout/registry-dimensions.d.ts.map +1 -1
  125. package/workflow/layout/registry-dimensions.js +2 -5
  126. package/workflow/layout/registry-dimensions.js.map +1 -1
  127. package/workflow/node-shell/NodeShell.js +1 -1
  128. package/workflow/node-shell/NodeShell.js.map +1 -1
  129. package/workflow/task-type-visual-registry.d.ts.map +1 -1
  130. package/workflow/task-type-visual-registry.js +5 -3
  131. package/workflow/task-type-visual-registry.js.map +1 -1
  132. package/workflow/useCanvasKeyboardShortcuts.d.ts +15 -4
  133. package/workflow/useCanvasKeyboardShortcuts.d.ts.map +1 -1
  134. package/workflow/useCanvasKeyboardShortcuts.js +25 -4
  135. package/workflow/useCanvasKeyboardShortcuts.js.map +1 -1
  136. package/workflow/useGraphHistory.d.ts +16 -9
  137. package/workflow/useGraphHistory.d.ts.map +1 -1
  138. package/workflow/useGraphHistory.js +19 -33
  139. package/workflow/useGraphHistory.js.map +1 -1
  140. package/workflow/useWorkflowCanvas.d.ts +1 -3
  141. package/workflow/useWorkflowCanvas.d.ts.map +1 -1
  142. package/workflow/useWorkflowCanvas.js +15 -9
  143. package/workflow/useWorkflowCanvas.js.map +1 -1
  144. package/workflow/useWorkflowSave.d.ts.map +1 -1
  145. package/workflow/useWorkflowSave.js +2 -15
  146. package/workflow/useWorkflowSave.js.map +1 -1
  147. package/workflow/workflow-graph-conversions.d.ts +19 -1
  148. package/workflow/workflow-graph-conversions.d.ts.map +1 -1
  149. package/workflow/workflow-graph-conversions.js +17 -3
  150. package/workflow/workflow-graph-conversions.js.map +1 -1
  151. package/datastore/CollectionRecordsBrowser.d.ts +0 -34
  152. package/datastore/CollectionRecordsBrowser.d.ts.map +0 -1
  153. package/datastore/CollectionRecordsBrowser.js +0 -226
  154. package/datastore/CollectionRecordsBrowser.js.map +0 -1
  155. package/datastore/CollectionSchemaView.d.ts +0 -29
  156. package/datastore/CollectionSchemaView.d.ts.map +0 -1
  157. package/datastore/CollectionSchemaView.js +0 -93
  158. package/datastore/CollectionSchemaView.js.map +0 -1
  159. package/datastore/DatastoreDetailView.d.ts +0 -44
  160. package/datastore/DatastoreDetailView.d.ts.map +0 -1
  161. package/datastore/DatastoreDetailView.js +0 -76
  162. package/datastore/DatastoreDetailView.js.map +0 -1
  163. package/datastore/DatastoreSyncReport.d.ts +0 -19
  164. package/datastore/DatastoreSyncReport.d.ts.map +0 -1
  165. package/datastore/DatastoreSyncReport.js +0 -45
  166. package/datastore/DatastoreSyncReport.js.map +0 -1
  167. package/datastore/DeleteDatastoreDialog.d.ts +0 -35
  168. package/datastore/DeleteDatastoreDialog.d.ts.map +0 -1
  169. package/datastore/DeleteDatastoreDialog.js +0 -90
  170. package/datastore/DeleteDatastoreDialog.js.map +0 -1
  171. package/datastore/FieldValueControl.d.ts +0 -55
  172. package/datastore/FieldValueControl.d.ts.map +0 -1
  173. package/datastore/FieldValueControl.js +0 -138
  174. package/datastore/FieldValueControl.js.map +0 -1
  175. package/datastore/RecordFilterBuilder.d.ts +0 -37
  176. package/datastore/RecordFilterBuilder.d.ts.map +0 -1
  177. package/datastore/RecordFilterBuilder.js +0 -122
  178. package/datastore/RecordFilterBuilder.js.map +0 -1
  179. package/datastore/RecordFormPanel.d.ts +0 -45
  180. package/datastore/RecordFormPanel.d.ts.map +0 -1
  181. package/datastore/RecordFormPanel.js +0 -215
  182. package/datastore/RecordFormPanel.js.map +0 -1
  183. package/datastore/index.d.ts +0 -43
  184. package/datastore/index.d.ts.map +0 -1
  185. package/datastore/index.js +0 -22
  186. package/datastore/index.js.map +0 -1
  187. package/datastore/recordFilter.d.ts +0 -62
  188. package/datastore/recordFilter.d.ts.map +0 -1
  189. package/datastore/recordFilter.js +0 -104
  190. package/datastore/recordFilter.js.map +0 -1
  191. package/datastore/recordValues.d.ts +0 -85
  192. package/datastore/recordValues.d.ts.map +0 -1
  193. package/datastore/recordValues.js +0 -282
  194. package/datastore/recordValues.js.map +0 -1
  195. package/datastore/useDatastore.d.ts +0 -39
  196. package/datastore/useDatastore.d.ts.map +0 -1
  197. package/datastore/useDatastore.js +0 -44
  198. package/datastore/useDatastore.js.map +0 -1
  199. package/datastore/useDatastoreCount.d.ts +0 -50
  200. package/datastore/useDatastoreCount.d.ts.map +0 -1
  201. package/datastore/useDatastoreCount.js +0 -27
  202. package/datastore/useDatastoreCount.js.map +0 -1
  203. package/datastore/useDatastoreDescription.d.ts +0 -54
  204. package/datastore/useDatastoreDescription.d.ts.map +0 -1
  205. package/datastore/useDatastoreDescription.js +0 -50
  206. package/datastore/useDatastoreDescription.js.map +0 -1
  207. package/datastore/useDatastoreList.d.ts +0 -57
  208. package/datastore/useDatastoreList.d.ts.map +0 -1
  209. package/datastore/useDatastoreList.js +0 -29
  210. package/datastore/useDatastoreList.js.map +0 -1
  211. package/datastore/useDatastoreSearch.d.ts +0 -19
  212. package/datastore/useDatastoreSearch.d.ts.map +0 -1
  213. package/datastore/useDatastoreSearch.js +0 -22
  214. package/datastore/useDatastoreSearch.js.map +0 -1
  215. package/datastore/useDeleteDatastore.d.ts +0 -53
  216. package/datastore/useDeleteDatastore.d.ts.map +0 -1
  217. package/datastore/useDeleteDatastore.js +0 -40
  218. package/datastore/useDeleteDatastore.js.map +0 -1
  219. package/datastore/useDeleteRecord.d.ts +0 -34
  220. package/datastore/useDeleteRecord.d.ts.map +0 -1
  221. package/datastore/useDeleteRecord.js +0 -43
  222. package/datastore/useDeleteRecord.js.map +0 -1
  223. package/datastore/useInsertRecord.d.ts +0 -50
  224. package/datastore/useInsertRecord.d.ts.map +0 -1
  225. package/datastore/useInsertRecord.js +0 -55
  226. package/datastore/useInsertRecord.js.map +0 -1
  227. package/datastore/useRecordCollection.d.ts +0 -104
  228. package/datastore/useRecordCollection.d.ts.map +0 -1
  229. package/datastore/useRecordCollection.js +0 -136
  230. package/datastore/useRecordCollection.js.map +0 -1
  231. package/datastore/useRecordList.d.ts +0 -66
  232. package/datastore/useRecordList.d.ts.map +0 -1
  233. package/datastore/useRecordList.js +0 -58
  234. package/datastore/useRecordList.js.map +0 -1
  235. package/datastore/useUpdateRecord.d.ts +0 -52
  236. package/datastore/useUpdateRecord.d.ts.map +0 -1
  237. package/datastore/useUpdateRecord.js +0 -55
  238. package/datastore/useUpdateRecord.js.map +0 -1
  239. package/src/agent/__tests__/AgentDetailView.datastores.test.tsx +0 -166
  240. package/src/datastore/CollectionRecordsBrowser.tsx +0 -571
  241. package/src/datastore/CollectionSchemaView.tsx +0 -247
  242. package/src/datastore/DatastoreDetailView.tsx +0 -201
  243. package/src/datastore/DatastoreSyncReport.tsx +0 -105
  244. package/src/datastore/DeleteDatastoreDialog.tsx +0 -202
  245. package/src/datastore/FieldValueControl.tsx +0 -289
  246. package/src/datastore/RecordFilterBuilder.tsx +0 -422
  247. package/src/datastore/RecordFormPanel.tsx +0 -432
  248. package/src/datastore/__tests__/CollectionRecordsBrowser.test.tsx +0 -245
  249. package/src/datastore/__tests__/DeleteDatastoreDialog.test.tsx +0 -133
  250. package/src/datastore/__tests__/FieldValueControl.test.tsx +0 -160
  251. package/src/datastore/__tests__/RecordFilterBuilder.test.tsx +0 -155
  252. package/src/datastore/__tests__/RecordFormPanel.test.tsx +0 -227
  253. package/src/datastore/__tests__/recordFilter.test.ts +0 -169
  254. package/src/datastore/__tests__/recordMutations.test.tsx +0 -195
  255. package/src/datastore/__tests__/recordValues.test.ts +0 -359
  256. package/src/datastore/__tests__/schemaAndSyncViews.test.tsx +0 -142
  257. package/src/datastore/__tests__/useDatastoreDescription.test.tsx +0 -143
  258. package/src/datastore/__tests__/useRecordCollection.test.tsx +0 -250
  259. package/src/datastore/__tests__/useRecordList.test.tsx +0 -85
  260. package/src/datastore/index.ts +0 -111
  261. package/src/datastore/recordFilter.ts +0 -154
  262. package/src/datastore/recordValues.ts +0 -327
  263. package/src/datastore/useDatastore.ts +0 -67
  264. package/src/datastore/useDatastoreCount.ts +0 -69
  265. package/src/datastore/useDatastoreDescription.ts +0 -90
  266. package/src/datastore/useDatastoreList.ts +0 -79
  267. package/src/datastore/useDatastoreSearch.ts +0 -39
  268. package/src/datastore/useDeleteDatastore.ts +0 -87
  269. package/src/datastore/useDeleteRecord.ts +0 -77
  270. package/src/datastore/useInsertRecord.ts +0 -92
  271. package/src/datastore/useRecordCollection.ts +0 -256
  272. package/src/datastore/useRecordList.ts +0 -131
  273. package/src/datastore/useUpdateRecord.ts +0 -95
@@ -1,247 +0,0 @@
1
- "use client";
2
-
3
- import { cn } from "@stigmer/theme";
4
- import { toJson } from "@bufbuild/protobuf";
5
- import { ValueSchema } from "@bufbuild/protobuf/wkt";
6
- import {
7
- FieldType,
8
- type CollectionDeclaration,
9
- type DatastoreAuthorization,
10
- type DatastoreSpec,
11
- type DatastoreSubject,
12
- } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/spec_pb";
13
- import { Section } from "../resource-detail/Section.js";
14
- import { formatFieldValue } from "./recordValues.js";
15
-
16
- /** Props for {@link CollectionSchemaView}. */
17
- export interface CollectionSchemaViewProps {
18
- /** The datastore spec — the authoritative source for structure (DD-008 SD-5). */
19
- readonly spec: DatastoreSpec;
20
- /** Additional CSS classes for the root container. */
21
- readonly className?: string;
22
- }
23
-
24
- /**
25
- * Structural view of a datastore's declared schema, rendered from the
26
- * loaded resource spec: per-collection typed field tables, the declared
27
- * constraints with their authored messages (the operator's own copy —
28
- * the same bytes agents relay), and the authorization block summary
29
- * (roles, bindings, `default_role` — operator-facing state the
30
- * describe projection deliberately excludes).
31
- *
32
- * Read-only by design: schema changes go through YAML apply, the one
33
- * write path for structure.
34
- *
35
- * All visual properties flow through `--stgm-*` design tokens.
36
- * Zero Console dependencies — safe for platform builder embedding.
37
- */
38
- export function CollectionSchemaView({ spec, className }: CollectionSchemaViewProps) {
39
- return (
40
- <div className={cn("stg:flex stg:flex-col stg:gap-6", className)}>
41
- <AuthorizationSummary authorization={spec.authorization} timezone={spec.timezone} />
42
- {spec.collections.map((coll) => (
43
- <CollectionSchema key={coll.name} collection={coll} />
44
- ))}
45
- </div>
46
- );
47
- }
48
-
49
- // ---------------------------------------------------------------------------
50
- // Authorization block summary
51
- // ---------------------------------------------------------------------------
52
-
53
- function AuthorizationSummary({
54
- authorization,
55
- timezone,
56
- }: {
57
- readonly authorization: DatastoreAuthorization | undefined;
58
- readonly timezone: string;
59
- }) {
60
- const roles = authorization?.roles ?? [];
61
- const bindings = authorization?.bindings ?? [];
62
- const defaultRole = authorization?.defaultRole ?? "";
63
-
64
- return (
65
- <Section title="Authorization">
66
- <div className="stg:flex stg:flex-col stg:gap-3 stg:p-3 stg:text-sm">
67
- <div className="stg:flex stg:flex-wrap stg:items-center stg:gap-2">
68
- <span className="stg:text-xs stg:font-medium stg:text-muted-foreground">Roles</span>
69
- {roles.length === 0 ? (
70
- <span className="stg:text-xs stg:text-muted-foreground">none declared</span>
71
- ) : (
72
- roles.map((r) => (
73
- <span
74
- key={r.name}
75
- className="stg:rounded-full stg:bg-muted stg:px-2 stg:py-0.5 stg:text-xs stg:font-medium stg:text-foreground"
76
- >
77
- {r.name}
78
- </span>
79
- ))
80
- )}
81
- </div>
82
- <div className="stg:flex stg:flex-wrap stg:items-center stg:gap-2">
83
- <span className="stg:text-xs stg:font-medium stg:text-muted-foreground">Default role</span>
84
- {defaultRole ? (
85
- <span className="stg:rounded-full stg:bg-muted stg:px-2 stg:py-0.5 stg:text-xs stg:font-medium stg:text-foreground">
86
- {defaultRole}
87
- </span>
88
- ) : (
89
- <span className="stg:text-xs stg:text-muted-foreground">
90
- none — unbound callers are denied
91
- </span>
92
- )}
93
- </div>
94
- {bindings.length > 0 && (
95
- <div className="stg:flex stg:flex-col stg:gap-1">
96
- <span className="stg:text-xs stg:font-medium stg:text-muted-foreground">
97
- Bindings ({bindings.length})
98
- </span>
99
- <ul className="stg:flex stg:flex-col stg:gap-0.5">
100
- {bindings.map((b, i) => (
101
- <li key={i} className="stg:text-xs stg:text-foreground">
102
- <code className="stg:font-mono">{formatSubject(b.subject)}</code>
103
- <span className="stg:text-muted-foreground"> → </span>
104
- {b.role}
105
- </li>
106
- ))}
107
- </ul>
108
- </div>
109
- )}
110
- {timezone && (
111
- <div className="stg:flex stg:items-center stg:gap-2">
112
- <span className="stg:text-xs stg:font-medium stg:text-muted-foreground">Timezone</span>
113
- <span className="stg:text-xs stg:text-foreground">{timezone}</span>
114
- </div>
115
- )}
116
- </div>
117
- </Section>
118
- );
119
- }
120
-
121
- /**
122
- * Plain kind+value rendering of a datastore subject (DD-008 SD-3: the
123
- * grant system is the privacy boundary; display is honest).
124
- */
125
- export function formatSubject(subject: DatastoreSubject | undefined): string {
126
- switch (subject?.kind.case) {
127
- case "channelSender": {
128
- const s = subject.kind.value;
129
- return `${s.senderKind}:${s.value}`;
130
- }
131
- case "principal": {
132
- const p = subject.kind.value;
133
- return `${p.kind}/${p.id}`;
134
- }
135
- default:
136
- return "unknown";
137
- }
138
- }
139
-
140
- // ---------------------------------------------------------------------------
141
- // Per-collection schema
142
- // ---------------------------------------------------------------------------
143
-
144
- const CONSTRAINT_KIND_LABELS = {
145
- uniques: "unique",
146
- checks: "check",
147
- exists: "exists",
148
- notExists: "not exists",
149
- } as const;
150
-
151
- function CollectionSchema({ collection }: { readonly collection: CollectionDeclaration }) {
152
- const constraints = [
153
- ...collection.uniques.map((c) => ({
154
- kind: CONSTRAINT_KIND_LABELS.uniques,
155
- name: c.name,
156
- fields: c.fields.join(", "),
157
- message: c.message,
158
- })),
159
- ...collection.checks.map((c) => ({
160
- kind: CONSTRAINT_KIND_LABELS.checks,
161
- name: c.name,
162
- fields: "",
163
- message: c.message,
164
- })),
165
- ...collection.exists.map((c) => ({
166
- kind: CONSTRAINT_KIND_LABELS.exists,
167
- name: c.name,
168
- fields: c.collection,
169
- message: c.message,
170
- })),
171
- ...collection.notExists.map((c) => ({
172
- kind: CONSTRAINT_KIND_LABELS.notExists,
173
- name: c.name,
174
- fields: c.collection,
175
- message: c.message,
176
- })),
177
- ];
178
-
179
- return (
180
- <Section title={collection.name} count={collection.fields.length}>
181
- <div className="stg:flex stg:flex-col">
182
- {collection.description && (
183
- <p className="stg:border-b stg:border-border stg:px-3 stg:py-2 stg:text-xs stg:text-muted-foreground">
184
- {collection.description}
185
- </p>
186
- )}
187
-
188
- <table className="stg:w-full stg:text-left stg:text-xs">
189
- <thead>
190
- <tr className="stg:border-b stg:border-border stg:text-muted-foreground">
191
- <th scope="col" className="stg:px-3 stg:py-2 stg:font-medium">Field</th>
192
- <th scope="col" className="stg:px-3 stg:py-2 stg:font-medium">Type</th>
193
- <th scope="col" className="stg:px-3 stg:py-2 stg:font-medium">Required</th>
194
- <th scope="col" className="stg:px-3 stg:py-2 stg:font-medium">Default</th>
195
- <th scope="col" className="stg:px-3 stg:py-2 stg:font-medium">Description</th>
196
- </tr>
197
- </thead>
198
- <tbody>
199
- {collection.fields.map((f) => (
200
- <tr key={f.name} className="stg:border-b stg:border-border stg:last:border-b-0">
201
- <td className="stg:px-3 stg:py-2 stg:font-mono stg:text-foreground">{f.name}</td>
202
- <td className="stg:px-3 stg:py-2 stg:text-foreground">
203
- {FieldType[f.type]}
204
- {f.enumValues.length > 0 && (
205
- <span className="stg:text-muted-foreground">
206
- {" "}
207
- ({f.enumValues.join(" | ")})
208
- </span>
209
- )}
210
- </td>
211
- <td className="stg:px-3 stg:py-2 stg:text-muted-foreground">{f.required ? "yes" : ""}</td>
212
- <td className="stg:px-3 stg:py-2 stg:font-mono stg:text-muted-foreground">
213
- {f.default !== undefined
214
- ? formatFieldValue(f.type, toJson(ValueSchema, f.default))
215
- : ""}
216
- </td>
217
- <td className="stg:px-3 stg:py-2 stg:text-muted-foreground">{f.description}</td>
218
- </tr>
219
- ))}
220
- </tbody>
221
- </table>
222
-
223
- {constraints.length > 0 && (
224
- <div className="stg:border-t stg:border-border">
225
- <h4 className="stg:px-3 stg:pt-2 stg:text-xs stg:font-medium stg:uppercase stg:tracking-wider stg:text-muted-foreground">
226
- Constraints
227
- </h4>
228
- <ul className="stg:flex stg:flex-col stg:gap-1 stg:p-3">
229
- {constraints.map((c) => (
230
- <li key={`${c.kind}:${c.name}`} className="stg:flex stg:flex-wrap stg:items-baseline stg:gap-2 stg:text-xs">
231
- <span className="stg:rounded stg:bg-muted stg:px-1.5 stg:py-0.5 stg:font-medium stg:text-muted-foreground">
232
- {c.kind}
233
- </span>
234
- <code className="stg:font-mono stg:text-foreground">{c.name}</code>
235
- {c.fields && <span className="stg:text-muted-foreground">({c.fields})</span>}
236
- {c.message && (
237
- <span className="stg:text-muted-foreground">— “{c.message}”</span>
238
- )}
239
- </li>
240
- ))}
241
- </ul>
242
- </div>
243
- )}
244
- </div>
245
- </Section>
246
- );
247
- }
@@ -1,201 +0,0 @@
1
- "use client";
2
-
3
- import { useEffect, useState } from "react";
4
- import { cn } from "@stigmer/theme";
5
- import { timestampDate } from "@bufbuild/protobuf/wkt";
6
- import type { Datastore } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/api_pb";
7
- import { ErrorMessage } from "../error/ErrorMessage.js";
8
- import { ResourceDetailShell } from "../resource-detail/ResourceDetailShell.js";
9
- import type { DetailAction, ResourceHeaderMeta } from "../resource-detail/types.js";
10
- import { CollectionRecordsBrowser } from "./CollectionRecordsBrowser.js";
11
- import { CollectionSchemaView } from "./CollectionSchemaView.js";
12
- import { DatastoreSyncReport } from "./DatastoreSyncReport.js";
13
- import { useDatastore } from "./useDatastore.js";
14
-
15
- /** The detail view's tabs. */
16
- export type DatastoreDetailTab = "overview" | "records";
17
-
18
- /** Props for {@link DatastoreDetailView}. */
19
- export interface DatastoreDetailViewProps {
20
- /** Organization slug. */
21
- readonly org: string;
22
- /** Datastore slug. */
23
- readonly slug: string;
24
- /** Primary action rendered as a visible button. */
25
- readonly primaryAction?: DetailAction;
26
- /** Overflow actions (Edit YAML / Export / Delete — assembled at the page level). */
27
- readonly actions?: readonly DetailAction[];
28
- /** Called when the datastore loads or reloads (e.g. breadcrumb label sync). */
29
- readonly onResourceLoad?: (datastore: Datastore) => void;
30
- /** Initial tab for uncontrolled usage. @default "overview" */
31
- readonly defaultTab?: DatastoreDetailTab;
32
- /** Controlled active tab. Uncontrolled (internal state) when omitted. */
33
- readonly activeTab?: DatastoreDetailTab;
34
- /** Tab-change callback for controlled usage. */
35
- readonly onTabChange?: (tab: DatastoreDetailTab) => void;
36
- /** Additional CSS classes for the root container. */
37
- readonly className?: string;
38
- }
39
-
40
- /**
41
- * Self-contained detail view for a Datastore — the Library-resource
42
- * home (DD-008 SD-1): an **Overview** tab (schema, authorization
43
- * summary, and the sync-report health strip — all from the loaded
44
- * resource, the authoritative source for structure and health) and a
45
- * **Records** tab (the browser, whose caller-effective verbs come from
46
- * `describeDatastore`). No version-history affordance —
47
- * `is_versioned: false` (DD-003).
48
- *
49
- * Handles loading, error, and not-found states automatically.
50
- * Zero Console dependencies — safe for platform builder embedding.
51
- * All visual properties flow through `--stgm-*` design tokens.
52
- */
53
- export function DatastoreDetailView({
54
- org,
55
- slug,
56
- primaryAction,
57
- actions,
58
- onResourceLoad,
59
- defaultTab = "overview",
60
- activeTab,
61
- onTabChange,
62
- className,
63
- }: DatastoreDetailViewProps) {
64
- const { datastore, isLoading, error, refetch } = useDatastore(org, slug);
65
-
66
- const [internalTab, setInternalTab] = useState<DatastoreDetailTab>(defaultTab);
67
- const tab = activeTab ?? internalTab;
68
- const setTab = onTabChange ?? setInternalTab;
69
-
70
- useEffect(() => {
71
- if (datastore) onResourceLoad?.(datastore);
72
- }, [datastore, onResourceLoad]);
73
-
74
- if (isLoading) return <LoadingSkeleton className={className} />;
75
- if (error)
76
- return <ErrorMessage error={error} retry={refetch} className={className} />;
77
- if (!datastore) return <NotFoundState className={className} />;
78
-
79
- const meta = datastore.metadata;
80
- const spec = datastore.spec;
81
- const status = datastore.status;
82
- const specAudit = status?.audit?.specAudit;
83
-
84
- const headerMeta: ResourceHeaderMeta = {
85
- name: meta?.name || meta?.slug || "Untitled",
86
- id: meta?.id || "",
87
- org: meta?.org,
88
- slug: meta?.slug,
89
- description: spec?.description,
90
- icon: <DatastoreIcon className="stg:size-6 stg:text-muted-foreground" />,
91
- createdAt: specAudit?.createdAt ? timestampDate(specAudit.createdAt) : null,
92
- updatedAt: specAudit?.updatedAt ? timestampDate(specAudit.updatedAt) : null,
93
- };
94
-
95
- return (
96
- <ResourceDetailShell
97
- header={headerMeta}
98
- primaryAction={primaryAction}
99
- actions={actions}
100
- tabs={[
101
- { id: "overview", label: "Overview" },
102
- { id: "records", label: "Records" },
103
- ]}
104
- activeTab={tab}
105
- onTabChange={(id) => setTab(id as DatastoreDetailTab)}
106
- tabsAriaLabel="Datastore sections"
107
- className={className}
108
- >
109
- {tab === "overview" ? (
110
- <div className="stg:flex stg:flex-col stg:gap-6">
111
- {status && <DatastoreSyncReport status={status} />}
112
- {spec && <CollectionSchemaView spec={spec} />}
113
- </div>
114
- ) : (
115
- spec &&
116
- meta && (
117
- <CollectionRecordsBrowser
118
- org={meta.org}
119
- datastoreSlug={meta.slug}
120
- spec={spec}
121
- />
122
- )
123
- )}
124
- </ResourceDetailShell>
125
- );
126
- }
127
-
128
- // ---------------------------------------------------------------------------
129
- // Non-happy states
130
- // ---------------------------------------------------------------------------
131
-
132
- function LoadingSkeleton({ className }: { readonly className?: string }) {
133
- return (
134
- <div
135
- className={cn("stg:flex stg:flex-col stg:gap-6", className)}
136
- aria-busy="true"
137
- aria-label="Loading datastore details"
138
- >
139
- <div className="stg:flex stg:items-start stg:gap-3">
140
- <div className="stg:mt-1 stg:size-6 stg:shrink-0 stg:animate-pulse stg:rounded stg:bg-muted" />
141
- <div className="stg:flex-1 stg:space-y-2">
142
- <div className="stg:h-5 stg:w-48 stg:animate-pulse stg:rounded stg:bg-muted" />
143
- <div className="stg:h-3 stg:w-64 stg:animate-pulse stg:rounded stg:bg-muted" />
144
- </div>
145
- </div>
146
- <div className="stg:space-y-2">
147
- <div className="stg:h-3 stg:w-28 stg:animate-pulse stg:rounded stg:bg-muted" />
148
- <div
149
- className="stg:animate-pulse stg:rounded-lg stg:border stg:border-border stg:bg-muted-faint"
150
- style={{ height: "160px" }}
151
- />
152
- </div>
153
- <div className="stg:space-y-2">
154
- <div className="stg:h-3 stg:w-20 stg:animate-pulse stg:rounded stg:bg-muted" />
155
- <div
156
- className="stg:animate-pulse stg:rounded-lg stg:border stg:border-border stg:bg-muted-faint"
157
- style={{ height: "240px" }}
158
- />
159
- </div>
160
- </div>
161
- );
162
- }
163
-
164
- function NotFoundState({ className }: { readonly className?: string }) {
165
- return (
166
- <div
167
- role="status"
168
- className={cn("stg:flex stg:flex-col stg:items-center stg:gap-2 stg:py-12 stg:text-center", className)}
169
- >
170
- <DatastoreIcon className="stg:size-10 stg:text-muted-foreground-faint" />
171
- <p className="stg:text-sm stg:font-medium stg:text-muted-foreground">Datastore not found</p>
172
- <p className="stg:text-xs stg:text-muted-foreground-subtle">
173
- This datastore doesn&apos;t exist or you don&apos;t have access to it.
174
- </p>
175
- </div>
176
- );
177
- }
178
-
179
- // ---------------------------------------------------------------------------
180
- // Icon (inline SVG — no icon-library dependency)
181
- // ---------------------------------------------------------------------------
182
-
183
- /** Database-cylinder icon shared by the detail view's states. */
184
- export function DatastoreIcon({ className }: { readonly className?: string }) {
185
- return (
186
- <svg
187
- className={className}
188
- viewBox="0 0 24 24"
189
- fill="none"
190
- stroke="currentColor"
191
- strokeWidth="1.5"
192
- strokeLinecap="round"
193
- strokeLinejoin="round"
194
- aria-hidden="true"
195
- >
196
- <ellipse cx="12" cy="5" rx="8" ry="3" />
197
- <path d="M4 5v6c0 1.66 3.58 3 8 3s8-1.34 8-3V5" />
198
- <path d="M4 11v6c0 1.66 3.58 3 8 3s8-1.34 8-3v-6" />
199
- </svg>
200
- );
201
- }
@@ -1,105 +0,0 @@
1
- "use client";
2
-
3
- import { timestampDate } from "@bufbuild/protobuf/wkt";
4
- import {
5
- CollectionMaterializationState,
6
- DatastoreSyncOutcome,
7
- type DatastoreStatus,
8
- } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/status_pb";
9
- import { Section } from "../resource-detail/Section.js";
10
- import { StatusBadge } from "../resource-workbench/components/StatusBadge.js";
11
-
12
- /** Props for {@link DatastoreSyncReport}. */
13
- export interface DatastoreSyncReportProps {
14
- /** The datastore status — the authoritative source for health (DD-008 SD-5). */
15
- readonly status: DatastoreStatus;
16
- /** Additional CSS classes for the root container. */
17
- readonly className?: string;
18
- }
19
-
20
- /**
21
- * The Overview health strip: projects `DatastoreStatus` — last apply
22
- * outcome, per-collection materialization state, and record counts —
23
- * so the operator can confirm an apply landed without leaving the
24
- * console (the cutover choreography's verification surface, DD-009).
25
- *
26
- * All visual properties flow through `--stgm-*` design tokens.
27
- * Zero Console dependencies — safe for platform builder embedding.
28
- */
29
- export function DatastoreSyncReport({ status, className }: DatastoreSyncReportProps) {
30
- const syncedAt = status.lastSyncedAt
31
- ? timestampDate(status.lastSyncedAt).toLocaleString()
32
- : null;
33
-
34
- return (
35
- <Section title="Sync report" className={className}>
36
- <div className="stg:flex stg:flex-col">
37
- <div className="stg:flex stg:flex-wrap stg:items-center stg:gap-2 stg:border-b stg:border-border stg:px-3 stg:py-2">
38
- <SyncOutcomeBadge outcome={status.lastSyncOutcome} />
39
- {syncedAt && (
40
- <span className="stg:text-xs stg:text-muted-foreground">last synced {syncedAt}</span>
41
- )}
42
- </div>
43
- {status.collections.length === 0 ? (
44
- <p className="stg:px-3 stg:py-2 stg:text-xs stg:text-muted-foreground">
45
- No collections have been synced yet.
46
- </p>
47
- ) : (
48
- <table className="stg:w-full stg:text-left stg:text-xs">
49
- <thead>
50
- <tr className="stg:border-b stg:border-border stg:text-muted-foreground">
51
- <th scope="col" className="stg:px-3 stg:py-2 stg:font-medium">Collection</th>
52
- <th scope="col" className="stg:px-3 stg:py-2 stg:font-medium">State</th>
53
- <th scope="col" className="stg:px-3 stg:py-2 stg:text-right stg:font-medium">Records</th>
54
- </tr>
55
- </thead>
56
- <tbody>
57
- {status.collections.map((coll) => (
58
- <tr key={coll.name} className="stg:border-b stg:border-border stg:last:border-b-0">
59
- <td className="stg:px-3 stg:py-2 stg:font-mono stg:text-foreground">{coll.name}</td>
60
- <td className="stg:px-3 stg:py-2">
61
- <MaterializationBadge state={coll.state} />
62
- </td>
63
- <td className="stg:px-3 stg:py-2 stg:text-right stg:tabular-nums stg:text-foreground">
64
- {String(coll.recordCount)}
65
- </td>
66
- </tr>
67
- ))}
68
- </tbody>
69
- </table>
70
- )}
71
- </div>
72
- </Section>
73
- );
74
- }
75
-
76
- function SyncOutcomeBadge({ outcome }: { readonly outcome: DatastoreSyncOutcome }) {
77
- switch (outcome) {
78
- case DatastoreSyncOutcome.synced:
79
- return <StatusBadge phase="ready" label="synced" />;
80
- case DatastoreSyncOutcome.rejected:
81
- return <StatusBadge phase="failed" label="rejected" />;
82
- default:
83
- return <StatusBadge phase="draft" label="never synced" />;
84
- }
85
- }
86
-
87
- function MaterializationBadge({ state }: { readonly state: CollectionMaterializationState }) {
88
- switch (state) {
89
- case CollectionMaterializationState.active:
90
- return <StatusBadge phase="ready" label="active" />;
91
- case CollectionMaterializationState.pending:
92
- return <StatusBadge phase="pending" label="pending" />;
93
- case CollectionMaterializationState.removed:
94
- // Removed from the spec; data retained until datastore delete.
95
- return (
96
- <StatusBadge
97
- phase="disabled"
98
- label="removed"
99
- tooltip="Removed from the spec — records retained until the datastore is deleted"
100
- />
101
- );
102
- default:
103
- return <StatusBadge phase="draft" label="unknown" />;
104
- }
105
- }