@dudousxd/nestjs-catalog-react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/LICENSE-bklit +21 -0
  2. package/README.md +282 -0
  3. package/dist/AccessConsole.d.ts +40 -0
  4. package/dist/AccessConsole.js +160 -0
  5. package/dist/CatalogManager.d.ts +12 -0
  6. package/dist/CatalogManager.js +123 -0
  7. package/dist/ConnectionPanel.d.ts +41 -0
  8. package/dist/ConnectionPanel.js +228 -0
  9. package/dist/CoverageLedger.d.ts +16 -0
  10. package/dist/CoverageLedger.js +16 -0
  11. package/dist/DashboardBoard.d.ts +10 -0
  12. package/dist/DashboardBoard.js +206 -0
  13. package/dist/EditableField.d.ts +18 -0
  14. package/dist/EditableField.js +61 -0
  15. package/dist/FlowView.d.ts +13 -0
  16. package/dist/FlowView.js +93 -0
  17. package/dist/GovernanceTimeline.d.ts +16 -0
  18. package/dist/GovernanceTimeline.js +93 -0
  19. package/dist/ObjectExplorer.d.ts +9 -0
  20. package/dist/ObjectExplorer.js +153 -0
  21. package/dist/PipelineConsole.d.ts +20 -0
  22. package/dist/PipelineConsole.js +272 -0
  23. package/dist/QueryConsole.d.ts +11 -0
  24. package/dist/QueryConsole.js +144 -0
  25. package/dist/SavedQueryPanel.d.ts +16 -0
  26. package/dist/SavedQueryPanel.js +78 -0
  27. package/dist/TraceExplorer.d.ts +54 -0
  28. package/dist/TraceExplorer.js +342 -0
  29. package/dist/TransformEditor.d.ts +23 -0
  30. package/dist/TransformEditor.js +129 -0
  31. package/dist/WorkflowCanvas.d.ts +24 -0
  32. package/dist/WorkflowCanvas.js +701 -0
  33. package/dist/charts/bklit/animation.d.ts +19 -0
  34. package/dist/charts/bklit/animation.js +28 -0
  35. package/dist/charts/bklit/area-chart-loading.d.ts +33 -0
  36. package/dist/charts/bklit/area-chart-loading.js +30 -0
  37. package/dist/charts/bklit/area-chart.d.ts +47 -0
  38. package/dist/charts/bklit/area-chart.js +65 -0
  39. package/dist/charts/bklit/area-gradient-defs.d.ts +28 -0
  40. package/dist/charts/bklit/area-gradient-defs.js +23 -0
  41. package/dist/charts/bklit/area.d.ts +75 -0
  42. package/dist/charts/bklit/area.js +112 -0
  43. package/dist/charts/bklit/bar-chart-loading.d.ts +16 -0
  44. package/dist/charts/bklit/bar-chart-loading.js +22 -0
  45. package/dist/charts/bklit/bar-chart.d.ts +54 -0
  46. package/dist/charts/bklit/bar-chart.js +440 -0
  47. package/dist/charts/bklit/bar-depth-geometry.d.ts +41 -0
  48. package/dist/charts/bklit/bar-depth-geometry.js +46 -0
  49. package/dist/charts/bklit/bar-squares-layout.d.ts +36 -0
  50. package/dist/charts/bklit/bar-squares-layout.js +46 -0
  51. package/dist/charts/bklit/bar-squares.d.ts +48 -0
  52. package/dist/charts/bklit/bar-squares.js +206 -0
  53. package/dist/charts/bklit/bar-x-axis.d.ts +13 -0
  54. package/dist/charts/bklit/bar-x-axis.js +81 -0
  55. package/dist/charts/bklit/bar-y-axis.d.ts +11 -0
  56. package/dist/charts/bklit/bar-y-axis.js +72 -0
  57. package/dist/charts/bklit/bar.d.ts +40 -0
  58. package/dist/charts/bklit/bar.js +207 -0
  59. package/dist/charts/bklit/chart-child-passthrough.d.ts +25 -0
  60. package/dist/charts/bklit/chart-child-passthrough.js +82 -0
  61. package/dist/charts/bklit/chart-config-context.d.ts +34 -0
  62. package/dist/charts/bklit/chart-config-context.js +55 -0
  63. package/dist/charts/bklit/chart-context.d.ts +207 -0
  64. package/dist/charts/bklit/chart-context.js +200 -0
  65. package/dist/charts/bklit/chart-defs.d.ts +21 -0
  66. package/dist/charts/bklit/chart-defs.js +57 -0
  67. package/dist/charts/bklit/chart-formatters.d.ts +16 -0
  68. package/dist/charts/bklit/chart-formatters.js +26 -0
  69. package/dist/charts/bklit/chart-legend-hover.d.ts +21 -0
  70. package/dist/charts/bklit/chart-legend-hover.js +26 -0
  71. package/dist/charts/bklit/chart-loading-label.d.ts +9 -0
  72. package/dist/charts/bklit/chart-loading-label.js +29 -0
  73. package/dist/charts/bklit/chart-phase.d.ts +39 -0
  74. package/dist/charts/bklit/chart-phase.js +20 -0
  75. package/dist/charts/bklit/chart-reveal-clip.d.ts +32 -0
  76. package/dist/charts/bklit/chart-reveal-clip.js +23 -0
  77. package/dist/charts/bklit/dash-tail-stroke.d.ts +17 -0
  78. package/dist/charts/bklit/dash-tail-stroke.js +21 -0
  79. package/dist/charts/bklit/decimate-time-series.d.ts +18 -0
  80. package/dist/charts/bklit/decimate-time-series.js +120 -0
  81. package/dist/charts/bklit/fade-edges.d.ts +42 -0
  82. package/dist/charts/bklit/fade-edges.js +34 -0
  83. package/dist/charts/bklit/filter-data-by-x-domain.d.ts +13 -0
  84. package/dist/charts/bklit/filter-data-by-x-domain.js +50 -0
  85. package/dist/charts/bklit/generate-chart-skeleton-data.d.ts +24 -0
  86. package/dist/charts/bklit/generate-chart-skeleton-data.js +33 -0
  87. package/dist/charts/bklit/grid.d.ts +57 -0
  88. package/dist/charts/bklit/grid.js +88 -0
  89. package/dist/charts/bklit/highlight-segment-bounds.d.ts +26 -0
  90. package/dist/charts/bklit/highlight-segment-bounds.js +35 -0
  91. package/dist/charts/bklit/highlight-segment.d.ts +30 -0
  92. package/dist/charts/bklit/highlight-segment.js +22 -0
  93. package/dist/charts/bklit/indicator-fade.d.ts +23 -0
  94. package/dist/charts/bklit/indicator-fade.js +41 -0
  95. package/dist/charts/bklit/line-chart-loading.d.ts +33 -0
  96. package/dist/charts/bklit/line-chart-loading.js +30 -0
  97. package/dist/charts/bklit/line-chart.d.ts +45 -0
  98. package/dist/charts/bklit/line-chart.js +99 -0
  99. package/dist/charts/bklit/line-loading-pulse.d.ts +19 -0
  100. package/dist/charts/bklit/line-loading-pulse.js +132 -0
  101. package/dist/charts/bklit/line-loading-timing.d.ts +18 -0
  102. package/dist/charts/bklit/line-loading-timing.js +18 -0
  103. package/dist/charts/bklit/line-series-terminal-marker.d.ts +15 -0
  104. package/dist/charts/bklit/line-series-terminal-marker.js +54 -0
  105. package/dist/charts/bklit/line.d.ts +63 -0
  106. package/dist/charts/bklit/line.js +104 -0
  107. package/dist/charts/bklit/loading-sweep.d.ts +65 -0
  108. package/dist/charts/bklit/loading-sweep.js +182 -0
  109. package/dist/charts/bklit/motion-utils.d.ts +17 -0
  110. package/dist/charts/bklit/motion-utils.js +27 -0
  111. package/dist/charts/bklit/path-stroke-utils.d.ts +28 -0
  112. package/dist/charts/bklit/path-stroke-utils.js +64 -0
  113. package/dist/charts/bklit/pattern-area.d.ts +20 -0
  114. package/dist/charts/bklit/pattern-area.js +27 -0
  115. package/dist/charts/bklit/pattern-preset.d.ts +34 -0
  116. package/dist/charts/bklit/pattern-preset.js +82 -0
  117. package/dist/charts/bklit/projection-config.d.ts +19 -0
  118. package/dist/charts/bklit/projection-config.js +88 -0
  119. package/dist/charts/bklit/projection-line-end-marker.d.ts +14 -0
  120. package/dist/charts/bklit/projection-line-end-marker.js +35 -0
  121. package/dist/charts/bklit/projection-line.d.ts +39 -0
  122. package/dist/charts/bklit/projection-line.js +87 -0
  123. package/dist/charts/bklit/projection-utils.d.ts +54 -0
  124. package/dist/charts/bklit/projection-utils.js +252 -0
  125. package/dist/charts/bklit/reference-area-config.d.ts +18 -0
  126. package/dist/charts/bklit/reference-area-config.js +47 -0
  127. package/dist/charts/bklit/reference-area-registration-context.d.ts +7 -0
  128. package/dist/charts/bklit/reference-area-registration-context.js +15 -0
  129. package/dist/charts/bklit/series-bar-layout.d.ts +26 -0
  130. package/dist/charts/bklit/series-bar-layout.js +39 -0
  131. package/dist/charts/bklit/series-dash-tail-overlay.d.ts +16 -0
  132. package/dist/charts/bklit/series-dash-tail-overlay.js +47 -0
  133. package/dist/charts/bklit/series-highlight-layer.d.ts +31 -0
  134. package/dist/charts/bklit/series-highlight-layer.js +20 -0
  135. package/dist/charts/bklit/series-hover-dim.d.ts +28 -0
  136. package/dist/charts/bklit/series-hover-dim.js +34 -0
  137. package/dist/charts/bklit/series-markers.d.ts +13 -0
  138. package/dist/charts/bklit/series-markers.js +106 -0
  139. package/dist/charts/bklit/series-path-utils.d.ts +18 -0
  140. package/dist/charts/bklit/series-path-utils.js +68 -0
  141. package/dist/charts/bklit/series-point-marker.d.ts +47 -0
  142. package/dist/charts/bklit/series-point-marker.js +47 -0
  143. package/dist/charts/bklit/static-chart-preview-context.d.ts +15 -0
  144. package/dist/charts/bklit/static-chart-preview-context.js +20 -0
  145. package/dist/charts/bklit/time-series-chart-shell.d.ts +46 -0
  146. package/dist/charts/bklit/time-series-chart-shell.js +398 -0
  147. package/dist/charts/bklit/tooltip/chart-tooltip.d.ts +75 -0
  148. package/dist/charts/bklit/tooltip/chart-tooltip.js +158 -0
  149. package/dist/charts/bklit/tooltip/date-ticker.d.ts +10 -0
  150. package/dist/charts/bklit/tooltip/date-ticker.js +85 -0
  151. package/dist/charts/bklit/tooltip/index.d.ts +15 -0
  152. package/dist/charts/bklit/tooltip/index.js +15 -0
  153. package/dist/charts/bklit/tooltip/tooltip-box.d.ts +56 -0
  154. package/dist/charts/bklit/tooltip/tooltip-box.js +122 -0
  155. package/dist/charts/bklit/tooltip/tooltip-content.d.ts +26 -0
  156. package/dist/charts/bklit/tooltip/tooltip-content.js +8 -0
  157. package/dist/charts/bklit/tooltip/tooltip-dot.d.ts +27 -0
  158. package/dist/charts/bklit/tooltip/tooltip-dot.js +62 -0
  159. package/dist/charts/bklit/tooltip/tooltip-indicator.d.ts +44 -0
  160. package/dist/charts/bklit/tooltip/tooltip-indicator.js +73 -0
  161. package/dist/charts/bklit/use-animated-series-path.d.ts +18 -0
  162. package/dist/charts/bklit/use-animated-series-path.js +101 -0
  163. package/dist/charts/bklit/use-animated-y-domains.d.ts +13 -0
  164. package/dist/charts/bklit/use-animated-y-domains.js +158 -0
  165. package/dist/charts/bklit/use-chart-interaction.d.ts +40 -0
  166. package/dist/charts/bklit/use-chart-interaction.js +252 -0
  167. package/dist/charts/bklit/use-chart-phase-orchestrator.d.ts +22 -0
  168. package/dist/charts/bklit/use-chart-phase-orchestrator.js +147 -0
  169. package/dist/charts/bklit/use-enter-complete.d.ts +16 -0
  170. package/dist/charts/bklit/use-enter-complete.js +22 -0
  171. package/dist/charts/bklit/use-grid-shimmer.d.ts +15 -0
  172. package/dist/charts/bklit/use-grid-shimmer.js +71 -0
  173. package/dist/charts/bklit/use-highlight-segment.d.ts +22 -0
  174. package/dist/charts/bklit/use-highlight-segment.js +42 -0
  175. package/dist/charts/bklit/use-mount-progress.d.ts +12 -0
  176. package/dist/charts/bklit/use-mount-progress.js +30 -0
  177. package/dist/charts/bklit/use-scheduled-tooltip.d.ts +8 -0
  178. package/dist/charts/bklit/use-scheduled-tooltip.js +84 -0
  179. package/dist/charts/bklit/visx-pattern.d.ts +27 -0
  180. package/dist/charts/bklit/visx-pattern.js +28 -0
  181. package/dist/charts/bklit/x-axis.d.ts +26 -0
  182. package/dist/charts/bklit/x-axis.js +423 -0
  183. package/dist/charts/bklit/y-axis-scales.d.ts +34 -0
  184. package/dist/charts/bklit/y-axis-scales.js +80 -0
  185. package/dist/charts/bklit/y-axis-ticks.d.ts +20 -0
  186. package/dist/charts/bklit/y-axis-ticks.js +32 -0
  187. package/dist/charts/bklit/y-domain-utils.d.ts +26 -0
  188. package/dist/charts/bklit/y-domain-utils.js +96 -0
  189. package/dist/charts/bklit.d.ts +2 -0
  190. package/dist/charts/bklit.js +90 -0
  191. package/dist/charts/components/shimmering-text.d.ts +31 -0
  192. package/dist/charts/components/shimmering-text.js +39 -0
  193. package/dist/charts/css.d.ts +35 -0
  194. package/dist/charts/css.js +64 -0
  195. package/dist/charts/recharts.d.ts +28 -0
  196. package/dist/charts/recharts.js +48 -0
  197. package/dist/charts/registry.d.ts +34 -0
  198. package/dist/charts/registry.js +60 -0
  199. package/dist/charts/skeleton.d.ts +55 -0
  200. package/dist/charts/skeleton.js +66 -0
  201. package/dist/cn.d.ts +10 -0
  202. package/dist/cn.js +13 -0
  203. package/dist/context.d.ts +346 -0
  204. package/dist/context.js +95 -0
  205. package/dist/index.d.ts +30 -0
  206. package/dist/index.js +65 -0
  207. package/dist/routes.d.ts +70 -0
  208. package/dist/routes.js +73 -0
  209. package/dist/source-fields.d.ts +111 -0
  210. package/dist/source-fields.js +204 -0
  211. package/dist/ui/chart.d.ts +54 -0
  212. package/dist/ui/chart.js +122 -0
  213. package/dist/ui/dialog.d.ts +27 -0
  214. package/dist/ui/dialog.js +24 -0
  215. package/dist/ui/field.d.ts +29 -0
  216. package/dist/ui/field.js +31 -0
  217. package/dist/ui/select.d.ts +42 -0
  218. package/dist/ui/select.js +30 -0
  219. package/dist/ui/sheet.d.ts +38 -0
  220. package/dist/ui/sheet.js +37 -0
  221. package/dist/ui/switch.d.ts +17 -0
  222. package/dist/ui/switch.js +14 -0
  223. package/dist/ui/tabs.d.ts +30 -0
  224. package/dist/ui/tabs.js +36 -0
  225. package/dist/ui/tooltip.d.ts +37 -0
  226. package/dist/ui/tooltip.js +43 -0
  227. package/dist/workflow/graph.d.ts +112 -0
  228. package/dist/workflow/graph.js +297 -0
  229. package/dist/workflow/index.d.ts +16 -0
  230. package/dist/workflow/index.js +16 -0
  231. package/dist/workflow/model.d.ts +151 -0
  232. package/dist/workflow/model.js +97 -0
  233. package/dist/workflow/name.d.ts +28 -0
  234. package/dist/workflow/name.js +28 -0
  235. package/dist/workflow/nodes.d.ts +40 -0
  236. package/dist/workflow/nodes.js +86 -0
  237. package/dist/workflow/validate.d.ts +104 -0
  238. package/dist/workflow/validate.js +199 -0
  239. package/package.json +148 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The paths behind the pipeline and access screens.
3
+ *
4
+ * These deliberately do **not** live in `@dudousxd/nestjs-catalog/client` beside
5
+ * `catalogRoutes`, and the difference is worth being precise about, because it
6
+ * is the difference between a route builder that is a promise and one that is a
7
+ * guess.
8
+ *
9
+ * `catalogRoutes` describes paths the catalog library's own controller serves.
10
+ * Install the library, register the module, and `/catalog/objects/...` exists —
11
+ * the builder is the library documenting itself, and it cannot be wrong.
12
+ *
13
+ * Connectors, transforms and access are the other shape. The library defines
14
+ * their *model* — `CatalogPipelineStore`, `CatalogConnection`, `CatalogPrincipal`
15
+ * — but ships no controller for any of them, because how a deployment exposes
16
+ * the code that reshapes its data, and who may create an account, are decisions
17
+ * that belong to the deployment. Putting `pipelineRoutes` next to `catalogRoutes`
18
+ * would tell a reader that installing the library makes `/pipeline/connectors`
19
+ * answer, and it does not: they would get a 404 with nothing to point at.
20
+ *
21
+ * So the builders live here, in the package that ships the screens that need
22
+ * them, and are stated as a *default* the host can move. The defaults are
23
+ * relative in the same way `catalogRoutes` is — `/pipeline`, not
24
+ * `/api/pipeline` — because the transport is what knows the API prefix, and a
25
+ * screen that hardcoded one app's mount point would be unusable in the next app.
26
+ *
27
+ * What this package therefore asks of a host is an HTTP surface with these
28
+ * shapes, wherever it wants to mount it. That contract is the response types on
29
+ * `CatalogClient` plus these paths, and a host that would rather satisfy it from
30
+ * somewhere else entirely can pass its own base path, or replace the client.
31
+ */
32
+ /** Where the pipeline endpoints sit unless the host says otherwise. */
33
+ export declare const DEFAULT_PIPELINE_BASE_PATH = "/pipeline";
34
+ /** Where the access endpoints sit unless the host says otherwise. */
35
+ export declare const DEFAULT_ACCESS_BASE_PATH = "/access";
36
+ export interface PipelineRoutes {
37
+ capabilities(): string;
38
+ connections(): string;
39
+ connection(id: string): string;
40
+ checkConnection(id: string): string;
41
+ /** Which connectors read through a connection. Named, so a refusal can say. */
42
+ connectionConnectors(id: string): string;
43
+ connectors(): string;
44
+ connector(id: string): string;
45
+ runConnector(id: string): string;
46
+ runs(): string;
47
+ transforms(): string;
48
+ transform(id: string): string;
49
+ tryTransform(): string;
50
+ /**
51
+ * Authored graphs of transforms. GET lists, POST creates or updates.
52
+ *
53
+ * Under the same base as the rest of the pipeline rather than a base of their
54
+ * own, because a workflow is made entirely of connectors and transforms that
55
+ * are already served from here — a host that mounted the pipeline endpoints
56
+ * behind one guard would otherwise have to remember a second mount point with
57
+ * the same guard on it, and the one that forgets exposes the graph editor to
58
+ * everybody.
59
+ */
60
+ workflows(): string;
61
+ workflow(id: string): string;
62
+ runWorkflow(id: string): string;
63
+ }
64
+ export declare function pipelineRoutes(basePath?: string): PipelineRoutes;
65
+ export interface AccessRoutes {
66
+ principals(): string;
67
+ /** GET lists people; POST creates or updates one. */
68
+ people(): string;
69
+ }
70
+ export declare function accessRoutes(basePath?: string): AccessRoutes;
package/dist/routes.js ADDED
@@ -0,0 +1,73 @@
1
+ /**
2
+ * The paths behind the pipeline and access screens.
3
+ *
4
+ * These deliberately do **not** live in `@dudousxd/nestjs-catalog/client` beside
5
+ * `catalogRoutes`, and the difference is worth being precise about, because it
6
+ * is the difference between a route builder that is a promise and one that is a
7
+ * guess.
8
+ *
9
+ * `catalogRoutes` describes paths the catalog library's own controller serves.
10
+ * Install the library, register the module, and `/catalog/objects/...` exists —
11
+ * the builder is the library documenting itself, and it cannot be wrong.
12
+ *
13
+ * Connectors, transforms and access are the other shape. The library defines
14
+ * their *model* — `CatalogPipelineStore`, `CatalogConnection`, `CatalogPrincipal`
15
+ * — but ships no controller for any of them, because how a deployment exposes
16
+ * the code that reshapes its data, and who may create an account, are decisions
17
+ * that belong to the deployment. Putting `pipelineRoutes` next to `catalogRoutes`
18
+ * would tell a reader that installing the library makes `/pipeline/connectors`
19
+ * answer, and it does not: they would get a 404 with nothing to point at.
20
+ *
21
+ * So the builders live here, in the package that ships the screens that need
22
+ * them, and are stated as a *default* the host can move. The defaults are
23
+ * relative in the same way `catalogRoutes` is — `/pipeline`, not
24
+ * `/api/pipeline` — because the transport is what knows the API prefix, and a
25
+ * screen that hardcoded one app's mount point would be unusable in the next app.
26
+ *
27
+ * What this package therefore asks of a host is an HTTP surface with these
28
+ * shapes, wherever it wants to mount it. That contract is the response types on
29
+ * `CatalogClient` plus these paths, and a host that would rather satisfy it from
30
+ * somewhere else entirely can pass its own base path, or replace the client.
31
+ */
32
+ /** Where the pipeline endpoints sit unless the host says otherwise. */
33
+ export const DEFAULT_PIPELINE_BASE_PATH = '/pipeline';
34
+ /** Where the access endpoints sit unless the host says otherwise. */
35
+ export const DEFAULT_ACCESS_BASE_PATH = '/access';
36
+ /**
37
+ * Trailing slashes are stripped rather than rejected.
38
+ *
39
+ * A host that writes `/api/pipeline/` is not making a mistake worth an
40
+ * exception, but concatenating it would produce `/api/pipeline//connectors`,
41
+ * which most routers treat as a different path and answer with a 404 nobody can
42
+ * read from the browser's network tab.
43
+ */
44
+ function normalise(basePath) {
45
+ return basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
46
+ }
47
+ export function pipelineRoutes(basePath = DEFAULT_PIPELINE_BASE_PATH) {
48
+ const base = normalise(basePath);
49
+ return {
50
+ capabilities: () => `${base}/capabilities`,
51
+ connections: () => `${base}/connections`,
52
+ connection: (id) => `${base}/connections/${encodeURIComponent(id)}`,
53
+ checkConnection: (id) => `${base}/connections/${encodeURIComponent(id)}/check`,
54
+ connectionConnectors: (id) => `${base}/connections/${encodeURIComponent(id)}/connectors`,
55
+ connectors: () => `${base}/connectors`,
56
+ connector: (id) => `${base}/connectors/${encodeURIComponent(id)}`,
57
+ runConnector: (id) => `${base}/connectors/${encodeURIComponent(id)}/run`,
58
+ runs: () => `${base}/runs`,
59
+ transforms: () => `${base}/transforms`,
60
+ transform: (id) => `${base}/transforms/${encodeURIComponent(id)}`,
61
+ tryTransform: () => `${base}/transforms/try`,
62
+ workflows: () => `${base}/workflows`,
63
+ workflow: (id) => `${base}/workflows/${encodeURIComponent(id)}`,
64
+ runWorkflow: (id) => `${base}/workflows/${encodeURIComponent(id)}/run`,
65
+ };
66
+ }
67
+ export function accessRoutes(basePath = DEFAULT_ACCESS_BASE_PATH) {
68
+ const base = normalise(basePath);
69
+ return {
70
+ principals: () => `${base}/principals`,
71
+ people: () => `${base}/people`,
72
+ };
73
+ }
@@ -0,0 +1,111 @@
1
+ import type { CatalogConnection, ConnectorKind } from '@dudousxd/nestjs-catalog/client';
2
+ /** A select hands back a string. Narrow it rather than promise it is a kind. */
3
+ export declare function toConnectorKind(value: string): ConnectorKind;
4
+ /** The sources that can be asked what changed. The rest always read it all. */
5
+ export declare function readsIncrementally(kind: ConnectorKind): boolean;
6
+ /** Which kinds can borrow an address from a named connection. */
7
+ export declare function usesConnection(kind: ConnectorKind): boolean;
8
+ export declare const KIND_OPTIONS: {
9
+ value: string;
10
+ label: string;
11
+ }[];
12
+ export declare const FORMAT_OPTIONS: {
13
+ value: string;
14
+ label: string;
15
+ }[];
16
+ /** The value the connection picker uses for "do not use one". */
17
+ export declare const INLINE_CONNECTION = "";
18
+ /**
19
+ * The config, as text fields.
20
+ *
21
+ * Every value is a string even where the stored config holds a number or a
22
+ * boolean, because a half-typed number is not a number and a form that coerces
23
+ * while somebody is still typing eats the keystroke. Conversion happens once,
24
+ * in {@link sourceConfigFrom}.
25
+ */
26
+ export interface SourceDraft {
27
+ url: string;
28
+ path: string;
29
+ query: string;
30
+ format: string;
31
+ records: string;
32
+ bucket: string;
33
+ prefix: string;
34
+ suffix: string;
35
+ endpoint: string;
36
+ region: string;
37
+ forcePathStyle: boolean;
38
+ maxObjectsPerRun: string;
39
+ watermarkColumn: string;
40
+ }
41
+ export declare function sourceDraftFrom(config: Record<string, unknown> | undefined): SourceDraft;
42
+ /**
43
+ * Pasted records, parsed without throwing.
44
+ *
45
+ * A result rather than an exception because one caller parses on save and the
46
+ * other parses on every keystroke, and a half-typed array is the normal state of
47
+ * this field rather than an error worth unwinding for.
48
+ */
49
+ export type RecordsParse = {
50
+ ok: true;
51
+ records: unknown[];
52
+ } | {
53
+ ok: false;
54
+ message: string;
55
+ };
56
+ export declare function parseRecords(text: string): RecordsParse;
57
+ export interface SourceConfigOptions {
58
+ /** True when a named connection supplies the address and the credential. */
59
+ viaConnection: boolean;
60
+ /** True only when the kind can read incrementally *and* is set to. */
61
+ incremental: boolean;
62
+ }
63
+ /**
64
+ * The stored config for one kind, and nothing else.
65
+ *
66
+ * Only the fields this kind actually reads, and — when a connection supplies the
67
+ * address — only the ones specific to this load. Sending the rest would leave a
68
+ * stale url on a SQL source, which reads as configuration somebody meant.
69
+ */
70
+ export declare function sourceConfigFrom(kind: ConnectorKind, draft: SourceDraft, { viaConnection, incremental }: SourceConfigOptions): Record<string, unknown>;
71
+ /**
72
+ * Whether there is enough here to read anything at all.
73
+ *
74
+ * Only the fields without which there is nothing to attempt — a bucket cannot be
75
+ * defaulted the way a prefix can. Everything else is the server's to judge.
76
+ */
77
+ export declare function sourceIsIncomplete(kind: ConnectorKind, draft: SourceDraft, viaConnection: boolean): boolean;
78
+ export declare function connectionOptions(kind: ConnectorKind, connections: CatalogConnection[]): {
79
+ value: string;
80
+ label: string;
81
+ }[];
82
+ /**
83
+ * The address fields for one kind.
84
+ *
85
+ * Rendered by both the connector form and the workflow source inspector, which
86
+ * is the entire point of this module: the two screens configure the same thing
87
+ * and there is exactly one description of what that thing needs.
88
+ */
89
+ export declare function SourceFields({ kind, draft, onChange, viaConnection, disabled, }: {
90
+ kind: ConnectorKind;
91
+ draft: SourceDraft;
92
+ onChange: (draft: SourceDraft) => void;
93
+ viaConnection: boolean;
94
+ disabled?: boolean;
95
+ }): import("react/jsx-runtime").JSX.Element;
96
+ /** Full or incremental, with the per-kind explanation of what that means. */
97
+ export declare function ReadModeFields({ kind, mode, onModeChange, draft, onChange, disabled, }: {
98
+ kind: ConnectorKind;
99
+ mode: 'full' | 'incremental';
100
+ onModeChange: (mode: 'full' | 'incremental') => void;
101
+ draft: SourceDraft;
102
+ onChange: (draft: SourceDraft) => void;
103
+ disabled?: boolean;
104
+ }): import("react/jsx-runtime").JSX.Element | null;
105
+ /** The env var holding the credential — the name of one, never the value. */
106
+ export declare function CredentialField({ kind, value, onChange, disabled, }: {
107
+ kind: ConnectorKind;
108
+ value: string;
109
+ onChange: (value: string) => void;
110
+ disabled?: boolean;
111
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,204 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CONNECTOR_KINDS } from '@dudousxd/nestjs-catalog/client';
3
+ import { cn } from './cn';
4
+ import { FieldGroup, TextAreaField, TextField } from './ui/field';
5
+ import { SelectField } from './ui/select';
6
+ import { Switch } from './ui/switch';
7
+ /**
8
+ * Describing where records are read from, in one place.
9
+ *
10
+ * There are two screens that ask this question and they must ask it the same
11
+ * way. A connector reads from a system; a workflow's **source node** reads from
12
+ * a system. They are the same half of the same idea — the executable model says
13
+ * so, giving a source node the same vocabulary a connector has: a kind, an
14
+ * optional named connection, a config, and the *name* of an environment
15
+ * variable holding the credential. Two forms would mean two answers to "what
16
+ * does an S3 source need", and the one that was updated second would quietly be
17
+ * the one that is right.
18
+ *
19
+ * A source node deliberately does **not** point at a connector. A connector
20
+ * references a workflow, so a source referencing a connector would be circular —
21
+ * and it would give one load two authorities on where its data comes from.
22
+ */
23
+ const MUTED = 'text-zinc-400 dark:text-zinc-500';
24
+ /** A select hands back a string. Narrow it rather than promise it is a kind. */
25
+ export function toConnectorKind(value) {
26
+ return CONNECTOR_KINDS.find((kind) => kind === value) ?? 'http';
27
+ }
28
+ /** The sources that can be asked what changed. The rest always read it all. */
29
+ export function readsIncrementally(kind) {
30
+ return kind === 'sql' || kind === 's3';
31
+ }
32
+ /** Which kinds can borrow an address from a named connection. */
33
+ export function usesConnection(kind) {
34
+ return kind === 'http' || kind === 'sql' || kind === 's3';
35
+ }
36
+ export const KIND_OPTIONS = [
37
+ { value: 'http', label: 'HTTP — a JSON endpoint' },
38
+ { value: 'sql', label: 'SQL — a database query' },
39
+ { value: 'file', label: 'File — CSV, NDJSON or JSON' },
40
+ { value: 's3', label: 'S3 — a bucket prefix' },
41
+ { value: 'inline', label: 'Inline — records pasted below' },
42
+ ];
43
+ export const FORMAT_OPTIONS = [
44
+ { value: '', label: 'Format from the extension' },
45
+ { value: 'csv', label: 'CSV' },
46
+ { value: 'ndjson', label: 'NDJSON' },
47
+ { value: 'json', label: 'JSON' },
48
+ ];
49
+ /** The value the connection picker uses for "do not use one". */
50
+ export const INLINE_CONNECTION = '';
51
+ export function sourceDraftFrom(config) {
52
+ const source = config ?? {};
53
+ const text = (key) => {
54
+ const value = source[key];
55
+ return typeof value === 'string' ? value : '';
56
+ };
57
+ const records = source.records;
58
+ return {
59
+ url: text('url'),
60
+ path: text('path'),
61
+ query: text('query'),
62
+ format: text('format'),
63
+ records: Array.isArray(records) && records.length > 0 ? JSON.stringify(records, null, 2) : '',
64
+ bucket: text('bucket'),
65
+ prefix: text('prefix'),
66
+ suffix: text('suffix'),
67
+ endpoint: text('endpoint'),
68
+ region: text('region'),
69
+ forcePathStyle: source.forcePathStyle === true,
70
+ maxObjectsPerRun: typeof source.maxObjectsPerRun === 'number' ? String(source.maxObjectsPerRun) : '',
71
+ watermarkColumn: text('watermarkColumn'),
72
+ };
73
+ }
74
+ export function parseRecords(text) {
75
+ const trimmed = text.trim();
76
+ if (trimmed.length === 0)
77
+ return { ok: true, records: [] };
78
+ try {
79
+ const parsed = JSON.parse(trimmed);
80
+ if (!Array.isArray(parsed)) {
81
+ return {
82
+ ok: false,
83
+ message: 'Inline records have to be a JSON array. A single object is one record, so wrap it in [ ].',
84
+ };
85
+ }
86
+ return { ok: true, records: parsed };
87
+ }
88
+ catch (error) {
89
+ return {
90
+ ok: false,
91
+ message: `That is not valid JSON: ${error instanceof Error ? error.message : 'it could not be parsed'}.`,
92
+ };
93
+ }
94
+ }
95
+ /**
96
+ * The stored config for one kind, and nothing else.
97
+ *
98
+ * Only the fields this kind actually reads, and — when a connection supplies the
99
+ * address — only the ones specific to this load. Sending the rest would leave a
100
+ * stale url on a SQL source, which reads as configuration somebody meant.
101
+ */
102
+ export function sourceConfigFrom(kind, draft, { viaConnection, incremental }) {
103
+ if (kind === 'http') {
104
+ return {
105
+ ...(viaConnection ? {} : { url: draft.url }),
106
+ ...(draft.path ? { path: draft.path } : {}),
107
+ };
108
+ }
109
+ if (kind === 'sql') {
110
+ return {
111
+ query: draft.query,
112
+ ...(viaConnection || !draft.url ? {} : { url: draft.url }),
113
+ // Only when it will be used. A watermark column left on a source somebody
114
+ // switched back to full reads as a bound that is being applied, and it is
115
+ // not.
116
+ ...(incremental && draft.watermarkColumn ? { watermarkColumn: draft.watermarkColumn } : {}),
117
+ };
118
+ }
119
+ if (kind === 'file') {
120
+ return {
121
+ path: draft.path || draft.url,
122
+ ...(draft.format ? { format: draft.format } : {}),
123
+ };
124
+ }
125
+ if (kind === 's3') {
126
+ return {
127
+ ...(viaConnection
128
+ ? {}
129
+ : {
130
+ bucket: draft.bucket,
131
+ ...(draft.endpoint ? { endpoint: draft.endpoint } : {}),
132
+ ...(draft.region ? { region: draft.region } : {}),
133
+ ...(draft.forcePathStyle ? { forcePathStyle: true } : {}),
134
+ }),
135
+ ...(draft.prefix ? { prefix: draft.prefix } : {}),
136
+ ...(draft.suffix ? { suffix: draft.suffix } : {}),
137
+ ...(draft.format ? { format: draft.format } : {}),
138
+ ...(draft.maxObjectsPerRun ? { maxObjectsPerRun: Number(draft.maxObjectsPerRun) } : {}),
139
+ };
140
+ }
141
+ const parsed = parseRecords(draft.records);
142
+ // Unparseable text keeps the previous records rather than wiping them: the
143
+ // caller shows the message from `parseRecords` and refuses to save.
144
+ return { records: parsed.ok ? parsed.records : [] };
145
+ }
146
+ /**
147
+ * Whether there is enough here to read anything at all.
148
+ *
149
+ * Only the fields without which there is nothing to attempt — a bucket cannot be
150
+ * defaulted the way a prefix can. Everything else is the server's to judge.
151
+ */
152
+ export function sourceIsIncomplete(kind, draft, viaConnection) {
153
+ if (kind === 's3' && !viaConnection)
154
+ return draft.bucket.trim().length === 0;
155
+ if (kind === 'http' && !viaConnection)
156
+ return draft.url.trim().length === 0;
157
+ return false;
158
+ }
159
+ export function connectionOptions(kind, connections) {
160
+ return connections
161
+ .filter((connection) => connection.kind === kind)
162
+ .map((connection) => ({ value: connection.id, label: connection.name }));
163
+ }
164
+ /**
165
+ * The address fields for one kind.
166
+ *
167
+ * Rendered by both the connector form and the workflow source inspector, which
168
+ * is the entire point of this module: the two screens configure the same thing
169
+ * and there is exactly one description of what that thing needs.
170
+ */
171
+ export function SourceFields({ kind, draft, onChange, viaConnection, disabled, }) {
172
+ const set = (patch) => onChange({ ...draft, ...patch });
173
+ if (kind === 'http') {
174
+ return (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [!viaConnection && (_jsx(TextField, { label: "URL", value: draft.url, onChange: (url) => set({ url }), placeholder: "https://\u2026", disabled: disabled })), _jsx(TextField, { label: "Path to the array", value: draft.path, onChange: (path) => set({ path }), placeholder: "e.g. data", disabled: disabled })] }));
175
+ }
176
+ if (kind === 'sql') {
177
+ return (_jsxs("div", { className: "space-y-3", children: [_jsx(TextAreaField, { label: "Query", value: draft.query, onChange: (query) => set({ query }), placeholder: "SELECT \u2026 FROM \u2026", mono: true, disabled: disabled, hint: "Runs inside a read-only transaction, so the database refuses a write whatever the statement parses as." }), !viaConnection && (_jsx(TextField, { label: "URL (optional)", value: draft.url, onChange: (url) => set({ url }), placeholder: "Prefer naming the environment variable below", disabled: disabled }))] }));
178
+ }
179
+ if (kind === 'file') {
180
+ return (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(TextField, { label: "File path or URL", value: draft.path, onChange: (path) => set({ path }), placeholder: "/data/drop.csv or https://\u2026", disabled: disabled }), _jsx(SelectField, { label: "Format", ariaLabel: "Format", value: draft.format, onValueChange: (format) => set({ format }), options: FORMAT_OPTIONS, disabled: disabled })] }));
181
+ }
182
+ if (kind === 's3') {
183
+ return (_jsxs("div", { className: "space-y-3", children: [!viaConnection && (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(TextField, { label: "Bucket", value: draft.bucket, onChange: (bucket) => set({ bucket }), placeholder: "fleet-drops", disabled: disabled }), _jsx(TextField, { label: "Region", value: draft.region, onChange: (region) => set({ region }), placeholder: "Blank uses the environment's", disabled: disabled }), _jsx(TextField, { label: "Endpoint", value: draft.endpoint, onChange: (endpoint) => set({ endpoint }), placeholder: "MinIO, e.g. http://localhost:9000", disabled: disabled })] })), _jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(TextField, { label: "Prefix", value: draft.prefix, onChange: (prefix) => set({ prefix }), placeholder: "drops/mvr/", disabled: disabled }), _jsx(TextField, { label: "Only keys ending in", value: draft.suffix, onChange: (suffix) => set({ suffix }), placeholder: ".csv", disabled: disabled }), _jsx(TextField, { label: "Max objects per run", value: draft.maxObjectsPerRun, onChange: (maxObjectsPerRun) => set({ maxObjectsPerRun }), inputMode: "numeric", disabled: disabled })] }), _jsx(SelectField, { label: "Format", ariaLabel: "Format", value: draft.format, onValueChange: (format) => set({ format }), options: [{ value: '', label: 'Format from each key' }, ...FORMAT_OPTIONS.slice(1)], disabled: disabled }), !viaConnection && (_jsx(Switch, { checked: draft.forcePathStyle, onCheckedChange: (forcePathStyle) => set({ forcePathStyle }), label: "Path-style addressing", hint: "MinIO needs it; AWS does not." }))] }));
184
+ }
185
+ const parsed = parseRecords(draft.records);
186
+ return (_jsx(TextAreaField, { label: "Records", value: draft.records, onChange: (records) => set({ records }), placeholder: '[{ "tag": "AF93E00073" }]', mono: true, rows: 5, disabled: disabled, hint: parsed.ok ? undefined : (_jsx("span", { className: "text-red-600 dark:text-red-400", children: parsed.message })) }));
187
+ }
188
+ /** Full or incremental, with the per-kind explanation of what that means. */
189
+ export function ReadModeFields({ kind, mode, onModeChange, draft, onChange, disabled, }) {
190
+ if (!readsIncrementally(kind))
191
+ return null;
192
+ return (_jsxs(FieldGroup, { title: "Read mode", children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(SelectField, { label: "Mode", ariaLabel: "Read mode", value: mode, onValueChange: (value) => onModeChange(value === 'incremental' ? 'incremental' : 'full'), options: [
193
+ { value: 'full', label: 'Full — read everything, every run' },
194
+ { value: 'incremental', label: 'Incremental — only what changed' },
195
+ ], disabled: disabled }), kind === 'sql' && mode === 'incremental' && (_jsx(TextField, { label: "Watermark column", value: draft.watermarkColumn, onChange: (watermarkColumn) => onChange({ ...draft, watermarkColumn }), placeholder: "updated_at", disabled: disabled }))] }), kind === 'sql' && mode === 'incremental' && (_jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["The query is wrapped as", ' ', _jsx("span", { className: "font-mono", children: "SELECT * FROM (your query) WHERE column > ?" }), " with the value bound, never pasted in. Two things follow from wrapping: the column has to be in what your query selects, and a query with its own LIMIT or GROUP BY is filtered after that step. Leave the column blank and this reads everything."] })), kind === 's3' && mode === 'incremental' && (_jsx("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: "Each run remembers the newest LastModified it read and the keys sitting at exactly that timestamp, so objects written in the same second are neither skipped nor read twice. Objects rewritten in place under a key already read are not picked up again." }))] }));
196
+ }
197
+ /** The env var holding the credential — the name of one, never the value. */
198
+ export function CredentialField({ kind, value, onChange, disabled, }) {
199
+ return (_jsx(TextField, { label: "Credential env var", value: value, onChange: onChange, placeholder: kind === 'sql'
200
+ ? 'Env var holding the connection URL'
201
+ : kind === 's3'
202
+ ? 'accessKeyId:secretAccessKey (optional)'
203
+ : 'Optional', disabled: disabled, hint: "The credential is read from the environment by name at run time. Only the variable name is stored." }));
204
+ }
@@ -0,0 +1,54 @@
1
+ import * as React from 'react';
2
+ import * as RechartsPrimitive from 'recharts';
3
+ /**
4
+ * shadcn/ui's chart primitives, vendored.
5
+ *
6
+ * Vendored rather than imported because that is what shadcn is — components you
7
+ * own. A host already using shadcn gets charts that match the rest of their app
8
+ * exactly, because this *is* the same file they have; one that is not gets
9
+ * Recharts with a sensible wrapper.
10
+ *
11
+ * The part that earns its keep is `ChartStyle`: it turns a `ChartConfig` into
12
+ * `--color-<key>` CSS variables scoped to the chart, so a series is coloured by
13
+ * `fill="var(--color-desktop)"` rather than by an index into a palette array.
14
+ * That means a chart keeps its colours when a series is reordered or removed,
15
+ * which an index never survives.
16
+ */
17
+ declare const THEMES: {
18
+ readonly light: "";
19
+ readonly dark: ".dark";
20
+ };
21
+ export type ChartConfig = {
22
+ [k in string]: {
23
+ label?: React.ReactNode;
24
+ icon?: React.ComponentType;
25
+ } & ({
26
+ color?: string;
27
+ theme?: never;
28
+ } | {
29
+ color?: never;
30
+ theme: Record<keyof typeof THEMES, string>;
31
+ });
32
+ };
33
+ export declare function ChartContainer({ id, className, children, config, ...props }: React.ComponentProps<'div'> & {
34
+ config: ChartConfig;
35
+ children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
36
+ }): import("react/jsx-runtime").JSX.Element;
37
+ export declare const ChartStyle: ({ id, config, }: {
38
+ id: string;
39
+ config: ChartConfig;
40
+ }) => import("react/jsx-runtime").JSX.Element | null;
41
+ export declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
42
+ export declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> & React.ComponentProps<'div'> & {
43
+ hideLabel?: boolean;
44
+ hideIndicator?: boolean;
45
+ indicator?: 'line' | 'dot' | 'dashed';
46
+ nameKey?: string;
47
+ labelKey?: string;
48
+ }): import("react/jsx-runtime").JSX.Element | null;
49
+ export declare const ChartLegend: typeof RechartsPrimitive.Legend;
50
+ export declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, nameKey, }: React.ComponentProps<'div'> & Pick<RechartsPrimitive.LegendProps, 'payload' | 'verticalAlign'> & {
51
+ hideIcon?: boolean;
52
+ nameKey?: string;
53
+ }): import("react/jsx-runtime").JSX.Element | null;
54
+ export {};
@@ -0,0 +1,122 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import * as RechartsPrimitive from 'recharts';
4
+ import { cn } from '../cn';
5
+ /**
6
+ * shadcn/ui's chart primitives, vendored.
7
+ *
8
+ * Vendored rather than imported because that is what shadcn is — components you
9
+ * own. A host already using shadcn gets charts that match the rest of their app
10
+ * exactly, because this *is* the same file they have; one that is not gets
11
+ * Recharts with a sensible wrapper.
12
+ *
13
+ * The part that earns its keep is `ChartStyle`: it turns a `ChartConfig` into
14
+ * `--color-<key>` CSS variables scoped to the chart, so a series is coloured by
15
+ * `fill="var(--color-desktop)"` rather than by an index into a palette array.
16
+ * That means a chart keeps its colours when a series is reordered or removed,
17
+ * which an index never survives.
18
+ */
19
+ const THEMES = { light: '', dark: '.dark' };
20
+ const ChartContext = React.createContext(null);
21
+ function useChart() {
22
+ const context = React.useContext(ChartContext);
23
+ if (!context) {
24
+ throw new Error('useChart must be used within a <ChartContainer />');
25
+ }
26
+ return context;
27
+ }
28
+ export function ChartContainer({ id, className, children, config, ...props }) {
29
+ const uniqueId = React.useId();
30
+ const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`;
31
+ return (_jsx(ChartContext.Provider, { value: { config }, children: _jsxs("div", { "data-slot": "chart", "data-chart": chartId, className: cn('flex aspect-video justify-center text-xs', '[&_.recharts-cartesian-axis-tick_text]:fill-zinc-400', "[&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-zinc-200/50", '[&_.recharts-curve.recharts-tooltip-cursor]:stroke-zinc-200', "[&_.recharts-dot[stroke='#fff']]:stroke-transparent", '[&_.recharts-layer]:outline-hidden', '[&_.recharts-sector]:outline-hidden', '[&_.recharts-surface]:outline-hidden', "dark:[&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-zinc-800/50", className), ...props, children: [_jsx(ChartStyle, { id: chartId, config: config }), _jsx(RechartsPrimitive.ResponsiveContainer, { children: children })] }) }));
32
+ }
33
+ export const ChartStyle = ({ id, config, }) => {
34
+ const colorConfig = Object.entries(config).filter(([, item]) => item.theme || item.color);
35
+ if (!colorConfig.length)
36
+ return null;
37
+ return (_jsx("style", {
38
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: the only way to scope generated CSS variables to one chart instance
39
+ dangerouslySetInnerHTML: {
40
+ __html: Object.entries(THEMES)
41
+ .map(([theme, prefix]) => `
42
+ ${prefix} [data-chart=${id}] {
43
+ ${colorConfig
44
+ .map(([key, itemConfig]) => {
45
+ const color = itemConfig.theme?.[theme] || itemConfig.color;
46
+ return color ? ` --color-${key}: ${color};` : null;
47
+ })
48
+ .filter(Boolean)
49
+ .join('\n')}
50
+ }
51
+ `)
52
+ .join('\n'),
53
+ } }));
54
+ };
55
+ export const ChartTooltip = RechartsPrimitive.Tooltip;
56
+ export function ChartTooltipContent({ active, payload, className, indicator = 'dot', hideLabel = false, hideIndicator = false, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }) {
57
+ const { config } = useChart();
58
+ const tooltipLabel = React.useMemo(() => {
59
+ if (hideLabel || !payload?.length)
60
+ return null;
61
+ const [item] = payload;
62
+ const key = `${labelKey || item?.dataKey || item?.name || 'value'}`;
63
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
64
+ const value = !labelKey && typeof label === 'string'
65
+ ? config[label]?.label || label
66
+ : itemConfig?.label;
67
+ if (labelFormatter) {
68
+ return (_jsx("div", { className: cn('font-medium', labelClassName), children: labelFormatter(value, payload) }));
69
+ }
70
+ if (!value)
71
+ return null;
72
+ return _jsx("div", { className: cn('font-medium', labelClassName), children: value });
73
+ }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
74
+ if (!active || !payload?.length)
75
+ return null;
76
+ const nestLabel = payload.length === 1 && indicator !== 'dot';
77
+ return (_jsxs("div", { className: cn('grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-zinc-200 bg-white px-2.5 py-1.5 text-xs shadow-xl', 'dark:border-zinc-800 dark:bg-zinc-900', className), children: [!nestLabel ? tooltipLabel : null, _jsx("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
78
+ const key = `${nameKey || item.name || item.dataKey || 'value'}`;
79
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
80
+ const indicatorColor = color || item.payload?.fill || item.color;
81
+ return (_jsx("div", { className: cn('flex w-full flex-wrap items-stretch gap-2', '[&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-zinc-400', indicator === 'dot' && 'items-center'), children: formatter && item?.value !== undefined && item.name ? (formatter(item.value, item.name, item, index, item.payload)) : (_jsxs(_Fragment, { children: [itemConfig?.icon ? (_jsx(itemConfig.icon, {})) : (!hideIndicator && (_jsx("div", { className: cn('shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)', {
82
+ 'h-2.5 w-2.5': indicator === 'dot',
83
+ 'w-1': indicator === 'line',
84
+ 'w-0 border-[1.5px] border-dashed bg-transparent': indicator === 'dashed',
85
+ 'my-0.5': nestLabel && indicator === 'dashed',
86
+ }), style: {
87
+ '--color-bg': indicatorColor,
88
+ '--color-border': indicatorColor,
89
+ } }))), _jsxs("div", { className: cn('flex flex-1 justify-between leading-none', nestLabel ? 'items-end' : 'items-center'), children: [_jsxs("div", { className: "grid gap-1.5", children: [nestLabel ? tooltipLabel : null, _jsx("span", { className: "text-zinc-500 dark:text-zinc-400", children: itemConfig?.label || item.name })] }), item.value !== undefined && (_jsx("span", { className: "font-mono font-medium tabular-nums", children: typeof item.value === 'number'
90
+ ? item.value.toLocaleString()
91
+ : String(item.value) }))] })] })) }, item.dataKey ?? index));
92
+ }) })] }));
93
+ }
94
+ export const ChartLegend = RechartsPrimitive.Legend;
95
+ export function ChartLegendContent({ className, hideIcon = false, payload, verticalAlign = 'bottom', nameKey, }) {
96
+ const { config } = useChart();
97
+ if (!payload?.length)
98
+ return null;
99
+ return (_jsx("div", { className: cn('flex items-center justify-center gap-4', verticalAlign === 'top' ? 'pb-3' : 'pt-3', className), children: payload.map((item) => {
100
+ const key = `${nameKey || item.dataKey || 'value'}`;
101
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
102
+ return (_jsxs("div", { className: "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-zinc-400", children: [itemConfig?.icon && !hideIcon ? (_jsx(itemConfig.icon, {})) : (_jsx("div", { className: "h-2 w-2 shrink-0 rounded-[2px]", style: { backgroundColor: item.color } })), itemConfig?.label] }, String(item.value)));
103
+ }) }));
104
+ }
105
+ /** Recharts payload items are loosely shaped; this digs the config key out safely. */
106
+ function getPayloadConfigFromPayload(config, payload, key) {
107
+ if (typeof payload !== 'object' || payload === null)
108
+ return undefined;
109
+ const payloadPayload = 'payload' in payload && typeof payload.payload === 'object' && payload.payload !== null
110
+ ? payload.payload
111
+ : undefined;
112
+ let configLabelKey = key;
113
+ if (key in payload && typeof payload[key] === 'string') {
114
+ configLabelKey = payload[key];
115
+ }
116
+ else if (payloadPayload &&
117
+ key in payloadPayload &&
118
+ typeof payloadPayload[key] === 'string') {
119
+ configLabelKey = payloadPayload[key];
120
+ }
121
+ return configLabelKey in config ? config[configLabelKey] : config[key];
122
+ }