@shapesos/clay 0.11.0 → 0.12.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.
- package/README.md +60 -0
- package/dist/artifacts.cjs +858 -132
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.d.cts +38 -5
- package/dist/artifacts.d.ts +38 -5
- package/dist/artifacts.js +13 -3
- package/dist/blocks.cjs +1185 -467
- package/dist/blocks.cjs.map +1 -1
- package/dist/blocks.css +1 -1
- package/dist/blocks.d.cts +23 -10
- package/dist/blocks.d.ts +23 -10
- package/dist/blocks.js +6 -3
- package/dist/chart.cjs +594 -0
- package/dist/chart.cjs.map +1 -0
- package/dist/chart.d.cts +439 -0
- package/dist/chart.d.ts +439 -0
- package/dist/chart.js +32 -0
- package/dist/chat.cjs +1207 -489
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.d.cts +3 -2
- package/dist/chat.d.ts +3 -2
- package/dist/chat.js +7 -4
- package/dist/{chunk-MXOPG747.js → chunk-36CB624W.js} +7 -7
- package/dist/chunk-36CB624W.js.map +1 -0
- package/dist/{chunk-L35M3OD5.js → chunk-4MZZH3WX.js} +5 -11
- package/dist/chunk-4MZZH3WX.js.map +1 -0
- package/dist/chunk-AQEJRMRN.js +1 -0
- package/dist/chunk-AQEJRMRN.js.map +1 -0
- package/dist/{chunk-OUW6PUEB.js → chunk-FFX3CAOX.js} +7 -7
- package/dist/chunk-P6GUNIAE.js +11 -0
- package/dist/chunk-P6GUNIAE.js.map +1 -0
- package/dist/chunk-QXGYMDIA.js +477 -0
- package/dist/chunk-QXGYMDIA.js.map +1 -0
- package/dist/{chunk-BX5TCEPR.js → chunk-Z5JWF24N.js} +388 -105
- package/dist/chunk-Z5JWF24N.js.map +1 -0
- package/dist/index.cjs +924 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +23 -15
- package/dist/table.js +2 -1
- package/dist/types-B2aYk82c.d.cts +29 -0
- package/dist/types-B2aYk82c.d.ts +29 -0
- package/dist/types-C0BvwliI.d.cts +332 -0
- package/dist/types-C5bFH4v3.d.ts +332 -0
- package/dist/{types-DuuRI4ll.d.cts → types-DCutaXjZ.d.cts} +16 -1
- package/dist/{types-C9XX-Uhk.d.ts → types-uPfn67Dc.d.ts} +16 -1
- package/package.json +13 -1
- package/dist/chunk-BX5TCEPR.js.map +0 -1
- package/dist/chunk-L35M3OD5.js.map +0 -1
- package/dist/chunk-MEJESPTZ.js +0 -1
- package/dist/chunk-MXOPG747.js.map +0 -1
- package/dist/types-3Gzk7cRt.d.cts +0 -121
- package/dist/types-3Gzk7cRt.d.ts +0 -121
- /package/dist/{chunk-MEJESPTZ.js.map → chart.js.map} +0 -0
- /package/dist/{chunk-OUW6PUEB.js.map → chunk-FFX3CAOX.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ColorToken, TypographyStyle, TypographyType, colors, fontFamilies, typographyMixin, typographyStyles, typographyTypes } from './tokens.cjs';
|
|
2
2
|
export { ArtifactRefBlock, ArtifactRefBlockService, Block, BlockContext, BlockContextValue, BlockServices, TextBlockService, useBlockContext } from './blocks.cjs';
|
|
3
|
-
export { A as ArtifactRefBlockRecord, B as BlockComponentProps, a as BlockRecord, b as BlockService, c as BlockType, T as TextBlockRecord, d as blockTypes } from './types-
|
|
4
|
-
export { A as
|
|
5
|
-
export { ArtifactDownloadButton, ArtifactDownloadButtonProps, ArtifactServices, TableArtifact, artifactToClipboardText, isSafeDownloadUrl } from './artifacts.cjs';
|
|
3
|
+
export { A as ArtifactRefBlockRecord, B as BlockComponentProps, a as BlockRecord, b as BlockService, c as BlockType, T as TextBlockRecord, d as blockTypes } from './types-DCutaXjZ.cjs';
|
|
4
|
+
export { A as ArtifactDataRow, a as ArtifactLabelsMap, b as ArtifactRecord, c as ArtifactService, d as ArtifactServiceProps, e as ArtifactType, B as BarChartConfig, C as ChartArtifactLabels, f as ChartArtifactRecord, g as ChartConfig, h as ChartStats, D as DEFAULT_CHART_ARTIFACT_LABELS, i as DEFAULT_TABLE_ARTIFACT_LABELS, L as LineChartConfig, P as PieChartConfig, T as TableArtifactLabels, j as TableArtifactRecord, k as TableColumn, l as TableConfig, m as TableRow, n as TableStats, o as artifactTypes } from './types-C0BvwliI.cjs';
|
|
5
|
+
export { ArtifactDownloadButton, ArtifactDownloadButtonProps, ArtifactServices, ChartArtifact, TableArtifact, artifactToClipboardText, isSafeDownloadUrl } from './artifacts.cjs';
|
|
6
6
|
export { ChatContext, ChatContextValue, ChatMessage, ChatMessageType, MESSAGE_ROLE, MessageRole, copyMessageText, useChatContext, useCopyToClipboard } from './chat.cjs';
|
|
7
7
|
export { Icon, IconButton, IconButtonProps, IconButtonSize, IconButtonVariant, IconProps } from './icon.cjs';
|
|
8
8
|
export { IconCtrl, KEYBOARD_SHORTCUT_VARIANTS, KeyIcon, KeyboardShortcut, KeyboardShortcutProps, KeyboardShortcutVariant } from './keyboard-shortcut.cjs';
|
|
@@ -10,6 +10,7 @@ export { Lottie, LottieAnimationData, LottieProps, LottieRef } from './lottie.cj
|
|
|
10
10
|
export { TextArea, TextAreaProps } from './text-area.cjs';
|
|
11
11
|
export { MarkdownTable, convertTableToCSV, escapeCsvField, markdownToPlainText, mergeRefs, parseMarkdownTable } from './utils.cjs';
|
|
12
12
|
export { BUTTON_INTENT, BUTTON_SIZE, BUTTON_VARIANT, Button, ButtonIntent, ButtonProps, ButtonSize, ButtonVariant, ICON_POSITION, IconPosition } from './button.cjs';
|
|
13
|
+
export { C as ChartSeries, a as ChartVariant } from './types-B2aYk82c.cjs';
|
|
13
14
|
import 'react';
|
|
14
15
|
import 'react/jsx-runtime';
|
|
15
16
|
import 'lottie-web';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ColorToken, TypographyStyle, TypographyType, colors, fontFamilies, typographyMixin, typographyStyles, typographyTypes } from './tokens.js';
|
|
2
2
|
export { ArtifactRefBlock, ArtifactRefBlockService, Block, BlockContext, BlockContextValue, BlockServices, TextBlockService, useBlockContext } from './blocks.js';
|
|
3
|
-
export { A as ArtifactRefBlockRecord, B as BlockComponentProps, a as BlockRecord, b as BlockService, c as BlockType, T as TextBlockRecord, d as blockTypes } from './types-
|
|
4
|
-
export { A as
|
|
5
|
-
export { ArtifactDownloadButton, ArtifactDownloadButtonProps, ArtifactServices, TableArtifact, artifactToClipboardText, isSafeDownloadUrl } from './artifacts.js';
|
|
3
|
+
export { A as ArtifactRefBlockRecord, B as BlockComponentProps, a as BlockRecord, b as BlockService, c as BlockType, T as TextBlockRecord, d as blockTypes } from './types-uPfn67Dc.js';
|
|
4
|
+
export { A as ArtifactDataRow, a as ArtifactLabelsMap, b as ArtifactRecord, c as ArtifactService, d as ArtifactServiceProps, e as ArtifactType, B as BarChartConfig, C as ChartArtifactLabels, f as ChartArtifactRecord, g as ChartConfig, h as ChartStats, D as DEFAULT_CHART_ARTIFACT_LABELS, i as DEFAULT_TABLE_ARTIFACT_LABELS, L as LineChartConfig, P as PieChartConfig, T as TableArtifactLabels, j as TableArtifactRecord, k as TableColumn, l as TableConfig, m as TableRow, n as TableStats, o as artifactTypes } from './types-C5bFH4v3.js';
|
|
5
|
+
export { ArtifactDownloadButton, ArtifactDownloadButtonProps, ArtifactServices, ChartArtifact, TableArtifact, artifactToClipboardText, isSafeDownloadUrl } from './artifacts.js';
|
|
6
6
|
export { ChatContext, ChatContextValue, ChatMessage, ChatMessageType, MESSAGE_ROLE, MessageRole, copyMessageText, useChatContext, useCopyToClipboard } from './chat.js';
|
|
7
7
|
export { Icon, IconButton, IconButtonProps, IconButtonSize, IconButtonVariant, IconProps } from './icon.js';
|
|
8
8
|
export { IconCtrl, KEYBOARD_SHORTCUT_VARIANTS, KeyIcon, KeyboardShortcut, KeyboardShortcutProps, KeyboardShortcutVariant } from './keyboard-shortcut.js';
|
|
@@ -10,6 +10,7 @@ export { Lottie, LottieAnimationData, LottieProps, LottieRef } from './lottie.js
|
|
|
10
10
|
export { TextArea, TextAreaProps } from './text-area.js';
|
|
11
11
|
export { MarkdownTable, convertTableToCSV, escapeCsvField, markdownToPlainText, mergeRefs, parseMarkdownTable } from './utils.js';
|
|
12
12
|
export { BUTTON_INTENT, BUTTON_SIZE, BUTTON_VARIANT, Button, ButtonIntent, ButtonProps, ButtonSize, ButtonVariant, ICON_POSITION, IconPosition } from './button.js';
|
|
13
|
+
export { C as ChartSeries, a as ChartVariant } from './types-B2aYk82c.js';
|
|
13
14
|
import 'react';
|
|
14
15
|
import 'react/jsx-runtime';
|
|
15
16
|
import 'lottie-web';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Lottie
|
|
3
|
+
} from "./chunk-BIATJTD4.js";
|
|
1
4
|
import {
|
|
2
5
|
TextArea
|
|
3
6
|
} from "./chunk-WPQQVKWY.js";
|
|
@@ -21,7 +24,6 @@ import {
|
|
|
21
24
|
Button,
|
|
22
25
|
ICON_POSITION
|
|
23
26
|
} from "./chunk-EDICS62G.js";
|
|
24
|
-
import "./chunk-C77QMQNT.js";
|
|
25
27
|
import {
|
|
26
28
|
ChatContext,
|
|
27
29
|
ChatMessage,
|
|
@@ -29,7 +31,7 @@ import {
|
|
|
29
31
|
copyMessageText,
|
|
30
32
|
useChatContext,
|
|
31
33
|
useCopyToClipboard
|
|
32
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-FFX3CAOX.js";
|
|
33
35
|
import {
|
|
34
36
|
BlockContext,
|
|
35
37
|
useBlockContext
|
|
@@ -41,26 +43,32 @@ import {
|
|
|
41
43
|
BlockServices,
|
|
42
44
|
TextBlockService,
|
|
43
45
|
blockTypes
|
|
44
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-36CB624W.js";
|
|
45
47
|
import {
|
|
46
48
|
markdownToPlainText
|
|
47
49
|
} from "./chunk-NMKKU2UG.js";
|
|
48
|
-
import
|
|
49
|
-
fontFamilies,
|
|
50
|
-
typographyMixin,
|
|
51
|
-
typographyStyles,
|
|
52
|
-
typographyTypes
|
|
53
|
-
} from "./chunk-SV24ONND.js";
|
|
54
|
-
import "./chunk-MEJESPTZ.js";
|
|
50
|
+
import "./chunk-AQEJRMRN.js";
|
|
55
51
|
import {
|
|
56
52
|
ArtifactDownloadButton,
|
|
57
53
|
ArtifactServices,
|
|
54
|
+
ChartArtifact,
|
|
55
|
+
DEFAULT_CHART_ARTIFACT_LABELS,
|
|
56
|
+
DEFAULT_TABLE_ARTIFACT_LABELS,
|
|
58
57
|
TableArtifact,
|
|
59
58
|
artifactToClipboardText,
|
|
60
59
|
artifactTypes,
|
|
61
60
|
isSafeDownloadUrl
|
|
62
|
-
} from "./chunk-
|
|
63
|
-
import "./chunk-
|
|
61
|
+
} from "./chunk-Z5JWF24N.js";
|
|
62
|
+
import "./chunk-QXGYMDIA.js";
|
|
63
|
+
import "./chunk-C77QMQNT.js";
|
|
64
|
+
import {
|
|
65
|
+
fontFamilies,
|
|
66
|
+
typographyMixin,
|
|
67
|
+
typographyStyles,
|
|
68
|
+
typographyTypes
|
|
69
|
+
} from "./chunk-SV24ONND.js";
|
|
70
|
+
import "./chunk-4MZZH3WX.js";
|
|
71
|
+
import "./chunk-P6GUNIAE.js";
|
|
64
72
|
import "./chunk-72TJUKMV.js";
|
|
65
73
|
import {
|
|
66
74
|
IconButton
|
|
@@ -71,9 +79,6 @@ import {
|
|
|
71
79
|
import {
|
|
72
80
|
colors
|
|
73
81
|
} from "./chunk-JF3P66JF.js";
|
|
74
|
-
import {
|
|
75
|
-
Lottie
|
|
76
|
-
} from "./chunk-BIATJTD4.js";
|
|
77
82
|
import "./chunk-5WRI5ZAA.js";
|
|
78
83
|
export {
|
|
79
84
|
ArtifactDownloadButton,
|
|
@@ -87,8 +92,11 @@ export {
|
|
|
87
92
|
BlockContext,
|
|
88
93
|
BlockServices,
|
|
89
94
|
Button,
|
|
95
|
+
ChartArtifact,
|
|
90
96
|
ChatContext,
|
|
91
97
|
ChatMessage,
|
|
98
|
+
DEFAULT_CHART_ARTIFACT_LABELS,
|
|
99
|
+
DEFAULT_TABLE_ARTIFACT_LABELS,
|
|
92
100
|
ICON_POSITION,
|
|
93
101
|
Icon,
|
|
94
102
|
IconButton,
|
package/dist/table.js
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for clay's chart library.
|
|
3
|
+
*
|
|
4
|
+
* Two layers consume these:
|
|
5
|
+
*
|
|
6
|
+
* 1. The high-level chart components (`<BarChart>`, `<LineChart>`, `<PieChart>`) — single-call
|
|
7
|
+
* convenience renderers with sensible defaults.
|
|
8
|
+
* 2. The artifact-side `ChartConfig` (in `@/components/artifacts/types`) — wire-protocol shape
|
|
9
|
+
* that drives the artifact renderer. `artifacts/types` re-exports `ChartSeries` and
|
|
10
|
+
* `ChartVariant` from here so both layers share one canonical type.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* A single series in a multi-series chart. Used by `<LineChart>` and `<BarChart>`.
|
|
14
|
+
*/
|
|
15
|
+
interface ChartSeries {
|
|
16
|
+
/** Must match a property name on every row in the chart's `data`. The value at this property
|
|
17
|
+
* is plotted (coerced to number if necessary). */
|
|
18
|
+
key: string;
|
|
19
|
+
/** Human-readable name shown in legend + tooltip. Defaults to `key` if missing, but always
|
|
20
|
+
* pass a label for clarity. */
|
|
21
|
+
label: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Variant discriminator — used by code that selects a chart type at runtime (the artifact
|
|
25
|
+
* renderer, for example). Each variant maps to a dedicated high-level component.
|
|
26
|
+
*/
|
|
27
|
+
type ChartVariant = "LINE" | "BAR" | "PIE";
|
|
28
|
+
|
|
29
|
+
export type { ChartSeries as C, ChartVariant as a };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for clay's chart library.
|
|
3
|
+
*
|
|
4
|
+
* Two layers consume these:
|
|
5
|
+
*
|
|
6
|
+
* 1. The high-level chart components (`<BarChart>`, `<LineChart>`, `<PieChart>`) — single-call
|
|
7
|
+
* convenience renderers with sensible defaults.
|
|
8
|
+
* 2. The artifact-side `ChartConfig` (in `@/components/artifacts/types`) — wire-protocol shape
|
|
9
|
+
* that drives the artifact renderer. `artifacts/types` re-exports `ChartSeries` and
|
|
10
|
+
* `ChartVariant` from here so both layers share one canonical type.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* A single series in a multi-series chart. Used by `<LineChart>` and `<BarChart>`.
|
|
14
|
+
*/
|
|
15
|
+
interface ChartSeries {
|
|
16
|
+
/** Must match a property name on every row in the chart's `data`. The value at this property
|
|
17
|
+
* is plotted (coerced to number if necessary). */
|
|
18
|
+
key: string;
|
|
19
|
+
/** Human-readable name shown in legend + tooltip. Defaults to `key` if missing, but always
|
|
20
|
+
* pass a label for clarity. */
|
|
21
|
+
label: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Variant discriminator — used by code that selects a chart type at runtime (the artifact
|
|
25
|
+
* renderer, for example). Each variant maps to a dedicated high-level component.
|
|
26
|
+
*/
|
|
27
|
+
type ChartVariant = "LINE" | "BAR" | "PIE";
|
|
28
|
+
|
|
29
|
+
export type { ChartSeries as C, ChartVariant as a };
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { C as ChartSeries } from './types-B2aYk82c.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shared artifact primitives — the discriminator constant and the cross-variant `ArtifactBase`
|
|
6
|
+
* shape that every concrete artifact record extends.
|
|
7
|
+
*
|
|
8
|
+
* Pulled into its own file so the per-type `types.ts` files (`table-artifact/types.ts`,
|
|
9
|
+
* `chart-artifact/types.ts`) and the union assembler (`artifacts/types.ts`) can all depend on
|
|
10
|
+
* one canonical source without creating a circular module graph between them.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Artifact-type discriminator constants. Uppercase to match the server-side `artifactTypes`
|
|
14
|
+
* constant — io-server stores `artifact.type === "TABLE"` (aligned with the GraphQL enum).
|
|
15
|
+
*/
|
|
16
|
+
declare const artifactTypes: {
|
|
17
|
+
readonly TABLE: "TABLE";
|
|
18
|
+
readonly CHART: "CHART";
|
|
19
|
+
};
|
|
20
|
+
/** Discriminator for artifact types. Additive — new types extend this union. */
|
|
21
|
+
type ArtifactType = (typeof artifactTypes)[keyof typeof artifactTypes];
|
|
22
|
+
/** Common shape every artifact record carries. Discriminated by `type`. */
|
|
23
|
+
interface ArtifactBase<TType extends ArtifactType, TConfig> {
|
|
24
|
+
/** Artifact-type discriminator. */
|
|
25
|
+
type: TType;
|
|
26
|
+
/** Human-readable label. Nullable when the artifact has no title. */
|
|
27
|
+
title: string | null;
|
|
28
|
+
/** Rendering config — shape varies per artifact type. */
|
|
29
|
+
config: TConfig;
|
|
30
|
+
/** Protected-asset metadata pointing to the underlying data payload. Null while the asset is unavailable. */
|
|
31
|
+
protectedAsset: {
|
|
32
|
+
/** Time-limited URL the renderer fetches the artifact's data from. */
|
|
33
|
+
presignedUrl: string;
|
|
34
|
+
} | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A row inside an artifact's parsed CSV. Every cell is the raw string from the CSV (or `null`
|
|
38
|
+
* for the empty string). Used by every artifact kind whose data wire is a CSV (`TABLE`, `CHART`).
|
|
39
|
+
* The renderer never coerces — type-aware formatting is a server concern (the CSV's contents
|
|
40
|
+
* are what the user sees).
|
|
41
|
+
*/
|
|
42
|
+
type ArtifactDataRow = Record<string, string | null>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Rendering config for a `BAR` chart. `xKey` selects the categorical axis; each series
|
|
46
|
+
* contributes one `<Bar>`. `stacked` collapses all series onto a single stack-id (so they sum
|
|
47
|
+
* vertically); when false / omitted bars are grouped side-by-side per x-tick.
|
|
48
|
+
*/
|
|
49
|
+
interface BarChartConfig extends ChartConfigBase {
|
|
50
|
+
variant: "BAR";
|
|
51
|
+
/** CSV column key used as the x-axis. */
|
|
52
|
+
xKey: string;
|
|
53
|
+
/** When true, stack all series on one stack-id. When false / omitted, group bars side-by-side. */
|
|
54
|
+
stacked?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Rendering config for a `LINE` chart. `xKey` selects the categorical/temporal axis from the
|
|
59
|
+
* CSV; each series contributes one `<Line>` overlaid against that axis.
|
|
60
|
+
*/
|
|
61
|
+
interface LineChartConfig extends ChartConfigBase {
|
|
62
|
+
variant: "LINE";
|
|
63
|
+
/** CSV column key used as the x-axis. */
|
|
64
|
+
xKey: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Rendering config for a `PIE` chart. `categoryKey` names the slice; `valueKey` carries the
|
|
69
|
+
* slice's numeric magnitude. One row of CSV becomes one slice. The base's `series` array is
|
|
70
|
+
* always empty for pie — colors are resolved by row index from the palette.
|
|
71
|
+
*/
|
|
72
|
+
interface PieChartConfig extends ChartConfigBase {
|
|
73
|
+
variant: "PIE";
|
|
74
|
+
/** CSV column key used as the slice label. */
|
|
75
|
+
categoryKey: string;
|
|
76
|
+
/** CSV column key used as the slice numeric value. */
|
|
77
|
+
valueKey: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Discriminated union of all supported chart variant configs. Assembled here (not in the parent
|
|
82
|
+
* `types.ts`) because the union depends on each variant service file as its single source of
|
|
83
|
+
* truth for that variant's config type.
|
|
84
|
+
*
|
|
85
|
+
* Extension pattern: add a new variant by creating one `*-chart-variant-service.ts` file and
|
|
86
|
+
* extending this union + the `ChartVariantServices` map below. No edits to the dispatcher.
|
|
87
|
+
*/
|
|
88
|
+
type ChartConfig = LineChartConfig | BarChartConfig | PieChartConfig;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Optional stats embedded in `ChartConfig` so clients can pre-render UI before fetching the
|
|
92
|
+
* actual CSV (e.g. a skeleton sized to the eventual row count). Mirrors `TableStats`.
|
|
93
|
+
*/
|
|
94
|
+
interface ChartStats {
|
|
95
|
+
/** Total number of rows in the materialised CSV. */
|
|
96
|
+
rowCount: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Cross-variant base for `ChartConfig`. Carries the fields every variant shares — series
|
|
100
|
+
* descriptors and optional stats. Per-variant config interfaces (in `chart-variant-services/`)
|
|
101
|
+
* extend this with their own required fields.
|
|
102
|
+
*
|
|
103
|
+
* Note: `series` is always present on the wire (matching the GraphQL `[ChartSeries!]!` shape)
|
|
104
|
+
* even for PIE — PIE just receives an empty array. Keeping it on the base mirrors the wire shape
|
|
105
|
+
* exactly and avoids TS object-literal freshness errors for callers that explicitly set
|
|
106
|
+
* `series: []` on a pie config.
|
|
107
|
+
*/
|
|
108
|
+
interface ChartConfigBase {
|
|
109
|
+
/** Series descriptors in render order. LINE/BAR consume these; PIE ignores in favour of `categoryKey`+`valueKey`. */
|
|
110
|
+
series: ChartSeries[];
|
|
111
|
+
/** Optional metadata describing the underlying data — used for loading-state UI. */
|
|
112
|
+
stats?: ChartStats;
|
|
113
|
+
}
|
|
114
|
+
/** Concrete chart artifact record. */
|
|
115
|
+
type ChartArtifactRecord = ArtifactBase<typeof artifactTypes.CHART, ChartConfig>;
|
|
116
|
+
/**
|
|
117
|
+
* Localized labels for the `CHART` artifact's user-facing strings. Covers action buttons AND
|
|
118
|
+
* status messages — see `TableArtifactLabels` for the same shape philosophy. Extends as the
|
|
119
|
+
* chart artifact grows its action set (e.g. future `copyAsPng`); optional keys document
|
|
120
|
+
* anticipated additions without forcing every consumer to provide them today.
|
|
121
|
+
*/
|
|
122
|
+
interface ChartArtifactLabels {
|
|
123
|
+
/** Tooltip + aria-label on the Download CSV button in the chart artifact header. */
|
|
124
|
+
download: string;
|
|
125
|
+
/** Status message shown when no presigned URL is available or the chart config is malformed. */
|
|
126
|
+
unavailable: string;
|
|
127
|
+
/** Status message shown when the fetch / parse fails at runtime. */
|
|
128
|
+
loadError: string;
|
|
129
|
+
/** Status message shown while the CSV is being fetched. */
|
|
130
|
+
loading: string;
|
|
131
|
+
/** Status message shown when the fetched CSV has zero data rows. */
|
|
132
|
+
empty: string;
|
|
133
|
+
/**
|
|
134
|
+
* Category labels treated as the "Others" bucket in pie charts (case-insensitive). Matching
|
|
135
|
+
* slices are pinned to the end of the sweep and rendered in neutral grey. The agent writes a
|
|
136
|
+
* translated bucket name in non-English UIs (e.g. "אחרים", "Otros") — consumer passes the
|
|
137
|
+
* localized list here so clay can detect the bucket regardless of language. English fallback
|
|
138
|
+
* is `["Others", "Other"]`. Pass `[]` to disable Others detection (every slice from the palette).
|
|
139
|
+
*/
|
|
140
|
+
othersCategoryLabels: readonly string[];
|
|
141
|
+
}
|
|
142
|
+
/** English fallback for `ChartArtifactLabels`. Used when the consumer hasn't passed `labels`. */
|
|
143
|
+
declare const DEFAULT_CHART_ARTIFACT_LABELS: ChartArtifactLabels;
|
|
144
|
+
/**
|
|
145
|
+
* Consumer-supplied side-effect callbacks for actions on the chart artifact. Mirrors
|
|
146
|
+
* `ChartArtifactLabels`'s shape philosophy: one entry per action this artifact exposes
|
|
147
|
+
* (download today; future "Copy as PNG" etc.). Every callback is optional — consumers wire
|
|
148
|
+
* only the actions they care about. The artifact passes its own `ChartArtifactRecord` as the
|
|
149
|
+
* only argument so consumers can derive analytics context (title, config.variant, etc.) without
|
|
150
|
+
* a per-block closure at every render site.
|
|
151
|
+
*
|
|
152
|
+
* The callback fires alongside the default browser behaviour (e.g. `onDownload` does not
|
|
153
|
+
* prevent the anchor's download navigation) — it's purely for analytics / observability hooks.
|
|
154
|
+
*/
|
|
155
|
+
interface ChartArtifactCallbacks {
|
|
156
|
+
/** Fires when the Download CSV button is clicked. Browser-native download still happens. */
|
|
157
|
+
onDownload?: (artifact: ChartArtifactRecord) => void;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* A single column descriptor for a `TableArtifact`. Carries the ORDER and LABEL for the
|
|
162
|
+
* rendered table — `key` selects a column from the CSV header; `label` overrides the rendered
|
|
163
|
+
* header text. The CSV is always the source of truth for the data shape; clay never coerces,
|
|
164
|
+
* reformats, or interprets cell values.
|
|
165
|
+
*/
|
|
166
|
+
interface TableColumn {
|
|
167
|
+
/** Matches a header in the CSV. Required. Used to project + order the CSV's columns. */
|
|
168
|
+
key: string;
|
|
169
|
+
/** Human-readable header text. Required. */
|
|
170
|
+
label: string;
|
|
171
|
+
/**
|
|
172
|
+
* Accepted in the wire payload but not consulted by the renderer — every cell is rendered as
|
|
173
|
+
* the raw CSV string (or empty for null). Format conversion is a server concern; if a column
|
|
174
|
+
* needs to be "Yes/No" instead of "true/false", the server should emit it that way in the CSV.
|
|
175
|
+
* Kept in the interface so callers that pass `type` (e.g. io-client) don't get a type error.
|
|
176
|
+
*/
|
|
177
|
+
type?: "string" | "number" | "date" | "boolean";
|
|
178
|
+
/**
|
|
179
|
+
* Accepted in the wire payload but not consulted by the renderer — every column is left-aligned
|
|
180
|
+
* by design. Kept in the interface for forward-compat; restore per-column alignment by editing
|
|
181
|
+
* `table-artifact-content.tsx` if a future use case justifies it.
|
|
182
|
+
*/
|
|
183
|
+
align?: "left" | "center" | "right";
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Optional stats embedded in `TableConfig` so clients can pre-render UI before fetching the
|
|
187
|
+
* actual data payload (e.g. N loading shimmers sized to the eventual row count).
|
|
188
|
+
*
|
|
189
|
+
* Backward-compat: optional everywhere — older artifacts persisted before this field shipped
|
|
190
|
+
* still validate. The renderer falls back to a single status-message line when `stats` is absent.
|
|
191
|
+
*/
|
|
192
|
+
interface TableStats {
|
|
193
|
+
/** Total number of rows in the materialised CSV. Lets the loading branch render shimmers. */
|
|
194
|
+
rowCount: number;
|
|
195
|
+
}
|
|
196
|
+
/** Rendering config for a table artifact, stored at `artifact.config` (JSONB on the server). */
|
|
197
|
+
interface TableConfig {
|
|
198
|
+
/** Column descriptors in render order. */
|
|
199
|
+
columns: TableColumn[];
|
|
200
|
+
/** Optional metadata describing the underlying data — used for loading-state UI. */
|
|
201
|
+
stats?: TableStats;
|
|
202
|
+
}
|
|
203
|
+
/** Alias retained for callers typed against the table-specific name. */
|
|
204
|
+
type TableRow = ArtifactDataRow;
|
|
205
|
+
/** Concrete table artifact record. */
|
|
206
|
+
type TableArtifactRecord = ArtifactBase<typeof artifactTypes.TABLE, TableConfig>;
|
|
207
|
+
/**
|
|
208
|
+
* Localized labels for the `TABLE` artifact's user-facing strings. Covers both action buttons
|
|
209
|
+
* (download today; future "Copy as CSV", etc.) AND status messages (loading / error / empty /
|
|
210
|
+
* unavailable). Consumer passes the bag from their i18n layer; clay falls back to English
|
|
211
|
+
* defaults when omitted (per-key Partial merge).
|
|
212
|
+
*/
|
|
213
|
+
interface TableArtifactLabels {
|
|
214
|
+
/** Tooltip + aria-label on the Download CSV button in the table artifact header. */
|
|
215
|
+
download: string;
|
|
216
|
+
/**
|
|
217
|
+
* Status message shown when no presigned URL is available (permanent server-side absence) or
|
|
218
|
+
* the artifact config is malformed. Both states reduce to "the underlying file isn't usable".
|
|
219
|
+
*/
|
|
220
|
+
unavailable: string;
|
|
221
|
+
/** Status message shown when the fetch / parse fails at runtime (transient). */
|
|
222
|
+
loadError: string;
|
|
223
|
+
/** Status message shown while the CSV is being fetched and `stats.rowCount` is not known. */
|
|
224
|
+
loading: string;
|
|
225
|
+
/** Empty-state row inside the table body when the fetched CSV has zero data rows. */
|
|
226
|
+
empty: string;
|
|
227
|
+
}
|
|
228
|
+
/** English fallback for `TableArtifactLabels`. Used when the consumer hasn't passed `labels`. */
|
|
229
|
+
declare const DEFAULT_TABLE_ARTIFACT_LABELS: TableArtifactLabels;
|
|
230
|
+
/**
|
|
231
|
+
* Consumer-supplied side-effect callbacks for actions on the table artifact. Mirrors
|
|
232
|
+
* `ChartArtifactCallbacks` — see that interface for the shape philosophy. Every callback is
|
|
233
|
+
* optional; the artifact passes its own `TableArtifactRecord` as the only argument so consumers
|
|
234
|
+
* can derive analytics context without a per-block closure at every render site.
|
|
235
|
+
*/
|
|
236
|
+
interface TableArtifactCallbacks {
|
|
237
|
+
/** Fires when the Download CSV button is clicked. Browser-native download still happens. */
|
|
238
|
+
onDownload?: (artifact: TableArtifactRecord) => void;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Artifact-domain types — wire-protocol shapes shared between artifact components, block-services,
|
|
243
|
+
* and consumers. Splits responsibilities across three layers so each artifact kind owns its own
|
|
244
|
+
* `types.ts` and this file assembles the cross-type union + service contract:
|
|
245
|
+
*
|
|
246
|
+
* 1. **`artifact-base.ts`** — discriminator (`artifactTypes`), `ArtifactBase<TType, TConfig>`, and
|
|
247
|
+
* `ArtifactDataRow`. Pulled out so each per-type `types.ts` and this assembler can depend on
|
|
248
|
+
* one canonical base without a circular module graph.
|
|
249
|
+
* 2. **`<type>-artifact/types.ts`** — per-artifact-type records, configs, labels, and defaults.
|
|
250
|
+
* Variant-specific types (e.g. `LineChartConfig`) live in even deeper per-variant service files.
|
|
251
|
+
* 3. **This file** — the cross-type `ArtifactRecord` union, the labels map keyed by artifact type,
|
|
252
|
+
* and the `ArtifactService<TArtifact, TLabels>` registry contract used by the dispatcher.
|
|
253
|
+
*
|
|
254
|
+
* Mirrored from the agent / io-server contract — see the `chat-typed-content-blocks-and-artifacts`
|
|
255
|
+
* plan, §6.4 (table contract).
|
|
256
|
+
*/
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Per-artifact-type labels map. Lets a consumer pass labels for every artifact kind in a single
|
|
260
|
+
* bag at the block layer (`<ArtifactRefBlock>` payload); the dispatcher routes the matching slice
|
|
261
|
+
* (`labels[artifact.type]`) to the concrete artifact component.
|
|
262
|
+
*
|
|
263
|
+
* Extension pattern: add a new field here when adding a new artifact type. Keep the field
|
|
264
|
+
* optional so older consumers don't break on upgrade.
|
|
265
|
+
*/
|
|
266
|
+
interface ArtifactLabelsMap {
|
|
267
|
+
TABLE: TableArtifactLabels;
|
|
268
|
+
CHART: ChartArtifactLabels;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Per-artifact-type callbacks map. Sibling to `ArtifactLabelsMap` — consumer passes a single
|
|
272
|
+
* bag at the block layer covering every artifact type's action callbacks (today: `onDownload`).
|
|
273
|
+
* Used for analytics / observability hooks — every callback is optional and fires alongside
|
|
274
|
+
* the default browser behaviour (it does NOT replace it).
|
|
275
|
+
*
|
|
276
|
+
* Each callback receives its artifact-type's `ArtifactBase`-derived record so consumers can
|
|
277
|
+
* derive analytics context (title, config, etc.) from one wiring at the chat-surface level
|
|
278
|
+
* instead of per-block closures.
|
|
279
|
+
*/
|
|
280
|
+
interface ArtifactCallbacksMap {
|
|
281
|
+
TABLE: TableArtifactCallbacks;
|
|
282
|
+
CHART: ChartArtifactCallbacks;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Discriminated union of all supported artifacts. Extension pattern: add the new branch here AND
|
|
286
|
+
* in the `ArtifactServices` map (single source of truth for the type→component mapping). Older
|
|
287
|
+
* clay versions that don't know about a new type silently render nothing — see `ArtifactRefBlock`
|
|
288
|
+
* guard.
|
|
289
|
+
*/
|
|
290
|
+
type ArtifactRecord = TableArtifactRecord | ChartArtifactRecord;
|
|
291
|
+
/**
|
|
292
|
+
* Props every concrete artifact component receives from the dispatcher.
|
|
293
|
+
*
|
|
294
|
+
* `labels` is the FULL `ArtifactLabelsMap` bag — every artifact component receives the same
|
|
295
|
+
* shape and reads its own slice internally (`labels?.TABLE`, `labels?.CHART`). One uniform prop
|
|
296
|
+
* type across all artifact components keeps the block-layer dispatcher a generic forward — no
|
|
297
|
+
* per-type branch, no cast, no map-key extraction at the seam.
|
|
298
|
+
*/
|
|
299
|
+
interface ArtifactServiceProps<TArtifact extends ArtifactRecord = ArtifactRecord> {
|
|
300
|
+
/** The artifact metadata (config + presigned URL). */
|
|
301
|
+
artifact: TArtifact;
|
|
302
|
+
/**
|
|
303
|
+
* Optional localized labels keyed by artifact type. Each artifact component reads only its
|
|
304
|
+
* own slice (`labels?.TABLE` or `labels?.CHART`); anything omitted falls back to the English
|
|
305
|
+
* default (per-key `Partial` merge against `DEFAULT_*_ARTIFACT_LABELS`).
|
|
306
|
+
*/
|
|
307
|
+
labels?: Partial<ArtifactLabelsMap>;
|
|
308
|
+
/**
|
|
309
|
+
* Optional side-effect callbacks keyed by artifact type — for analytics / observability hooks
|
|
310
|
+
* (e.g. tracking a download event). Each artifact component reads only its own slice
|
|
311
|
+
* (`callbacks?.TABLE`, `callbacks?.CHART`). Callbacks fire alongside the default browser
|
|
312
|
+
* behaviour and do not replace it.
|
|
313
|
+
*/
|
|
314
|
+
callbacks?: Partial<ArtifactCallbacksMap>;
|
|
315
|
+
}
|
|
316
|
+
/** Per-artifact-type service — registry entry that pairs a discriminator with its concrete component. */
|
|
317
|
+
interface ArtifactService<TArtifact extends ArtifactRecord = ArtifactRecord> {
|
|
318
|
+
/** Discriminator value this service handles. */
|
|
319
|
+
type: (typeof artifactTypes)[keyof typeof artifactTypes];
|
|
320
|
+
/** React component that renders an artifact of this type — composes ai-elements primitives
|
|
321
|
+
* (`Artifact`, `ArtifactHeader`, `ArtifactTitle`, `ArtifactActions`, `ArtifactContent`) directly. */
|
|
322
|
+
Component: ComponentType<ArtifactServiceProps<TArtifact>>;
|
|
323
|
+
/**
|
|
324
|
+
* Returns a plain-text / markdown string suitable for clipboard copy.
|
|
325
|
+
*
|
|
326
|
+
* Called by `ArtifactRefBlockService.toClipboardText` when the user copies a message that
|
|
327
|
+
* contains this artifact. Must be pure and synchronous.
|
|
328
|
+
*/
|
|
329
|
+
toClipboardText: (artifact: TArtifact) => string;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export { type ArtifactDataRow as A, type BarChartConfig as B, type ChartArtifactLabels as C, DEFAULT_CHART_ARTIFACT_LABELS as D, type LineChartConfig as L, type PieChartConfig as P, type TableArtifactLabels as T, type ArtifactLabelsMap as a, type ArtifactRecord as b, type ArtifactService as c, type ArtifactServiceProps as d, type ArtifactType as e, type ChartArtifactRecord as f, type ChartConfig as g, type ChartStats as h, DEFAULT_TABLE_ARTIFACT_LABELS as i, type TableArtifactRecord as j, type TableColumn as k, type TableConfig as l, type TableRow as m, type TableStats as n, artifactTypes as o, type ArtifactCallbacksMap as p };
|