ggaction 0.0.7 → 0.0.9
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/CHANGELOG.md +42 -0
- package/README.md +33 -5
- package/knowledge/action-cards.json +10941 -0
- package/knowledge/intent-taxonomy.json +183 -0
- package/knowledge/mcp-resources.json +95 -0
- package/knowledge/task-packet.schema.json +159 -0
- package/knowledge/task-resolver.js +1230 -0
- package/package.json +10 -1
- package/src/actions/basic.js +3 -3
- package/src/actions/categoryOrder/index.js +111 -0
- package/src/actions/coordinates/actions.js +4 -0
- package/src/actions/data/index.js +6 -0
- package/src/actions/data/timeUnit.js +48 -0
- package/src/actions/encodings/angle.js +77 -0
- package/src/actions/encodings/color/index.js +17 -13
- package/src/actions/encodings/color/layout.js +2 -0
- package/src/actions/encodings/color/policy.js +3 -0
- package/src/actions/encodings/index.js +2 -0
- package/src/actions/encodings/position/policies/area.js +40 -2
- package/src/actions/encodings/position/policies/bar.js +6 -0
- package/src/actions/encodings/position/policies/index.js +2 -0
- package/src/actions/encodings/position/policies/line.js +5 -1
- package/src/actions/encodings/position/policies/tick.js +19 -0
- package/src/actions/encodings/remove.js +1 -1
- package/src/actions/guides/legends/categorical/actions.js +23 -6
- package/src/actions/guides/legends/categorical/index.js +93 -2
- package/src/actions/guides/legends/categorical/symbols.js +2 -76
- package/src/actions/guides/legends/continuous/common.js +17 -5
- package/src/actions/guides/legends/continuous/gradient.js +12 -8
- package/src/actions/guides/legends/continuous/opacity.js +70 -17
- package/src/actions/guides/legends/edit.js +13 -8
- package/src/actions/guides/legends/lane.js +468 -0
- package/src/actions/guides/legends/remove.js +3 -7
- package/src/actions/index.js +3 -1
- package/src/actions/marks/area/actions.js +3 -1
- package/src/actions/marks/area/materialize.js +12 -3
- package/src/actions/marks/index.js +2 -0
- package/src/actions/marks/point/materialize.js +17 -5
- package/src/actions/marks/tick/actions.js +225 -0
- package/src/actions/marks/tick/index.js +1 -0
- package/src/actions/primitives/index.js +27 -0
- package/src/actions/primitives/semantic.js +22 -185
- package/src/actions/primitives/semanticAction.js +188 -0
- package/src/actions/primitives/semanticValidation/dataset.js +7 -3
- package/src/actions/primitives/semanticValidation/index.js +28 -15
- package/src/actions/primitives/semanticValidation/layer.js +22 -16
- package/src/actions/scales/consumers/index.js +8 -0
- package/src/actions/scales/consumers/seriesLayout.js +22 -2
- package/src/actions/scales/materialize.js +2 -0
- package/src/actions/selection/actions.js +5 -2
- package/src/core/vocabulary.js +7 -3
- package/src/grammar/areaSeries.js +112 -2
- package/src/grammar/categoryOrder.js +138 -0
- package/src/grammar/direction.js +46 -0
- package/src/grammar/facets/index.js +1 -1
- package/src/grammar/pointShapes.js +34 -6
- package/src/grammar/positionCompatibility.js +4 -0
- package/src/grammar/schemas/semanticPath.js +2 -1
- package/src/grammar/seriesLayout.js +10 -2
- package/src/grammar/timeUnit.js +108 -0
- package/src/grammar/transformTopology.js +18 -0
- package/src/grammar/transforms.js +25 -18
- package/src/grammar/window.js +73 -7
- package/src/layout/legendLane.js +338 -0
- package/src/materialization/dataProvenance.js +2 -2
- package/src/materialization/marks/capabilities.js +9 -0
- package/src/materialization/marks/index.js +2 -1
- package/src/materialization/marks/pathOrder.js +2 -2
- package/src/materialization/marks/policies.js +13 -0
- package/src/materialization/scales/policies/series.js +9 -0
- package/src/materialization/scales/resolve.js +25 -3
- package/src/materialization/selection/items/index.js +1 -0
- package/src/materialization/selection/items/path.js +4 -1
- package/src/materialization/selection/items/tick.js +42 -0
- package/src/materialization/selection/policies/index.js +2 -0
- package/src/materialization/selection/policies/tick.js +10 -0
- package/src/mcp/adapter.js +206 -0
- package/src/mcp/cli.js +11 -0
- package/src/mcp/server.js +101 -0
- package/types/index.d.ts +10 -0
- package/types/program.d.ts +96 -3
- package/src/actions/coordinates/index.js +0 -5
- package/src/actions/primitives/semanticValue.js +0 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
import { searchGgaction } from "../../knowledge/task-resolver.js";
|
|
6
|
+
|
|
7
|
+
const packageRoot = fileURLToPath(new URL("../../", import.meta.url));
|
|
8
|
+
const cardsArtifact = JSON.parse(readFileSync(
|
|
9
|
+
path.join(packageRoot, "knowledge/action-cards.json"),
|
|
10
|
+
"utf8"
|
|
11
|
+
));
|
|
12
|
+
const resourcesArtifact = JSON.parse(readFileSync(
|
|
13
|
+
path.join(packageRoot, "knowledge/mcp-resources.json"),
|
|
14
|
+
"utf8"
|
|
15
|
+
));
|
|
16
|
+
|
|
17
|
+
const cards = new Map(cardsArtifact.cards.map(card => [card.name, card]));
|
|
18
|
+
const recipes = new Map(resourcesArtifact.recipes.map(recipe => [recipe.id, recipe]));
|
|
19
|
+
const docs = new Map(resourcesArtifact.docs.map(section => [section.id, section]));
|
|
20
|
+
|
|
21
|
+
function unique(values) {
|
|
22
|
+
return [...new Set(values)];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const SEARCH_TOOL_NAME = "search_ggaction";
|
|
26
|
+
export const OVERVIEW_URI = "ggaction://overview";
|
|
27
|
+
|
|
28
|
+
export const SEARCH_TOOL = Object.freeze({
|
|
29
|
+
name: SEARCH_TOOL_NAME,
|
|
30
|
+
title: "Search ggaction authoring knowledge",
|
|
31
|
+
description: "Resolve one complete ggaction chart request into a bounded ordered task packet with exact imports, authoring prerequisites, executable immutable steps, terminal unsupported constraints, and explicit unresolved decisions.",
|
|
32
|
+
inputSchema: Object.freeze({
|
|
33
|
+
type: "object",
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
required: ["query"],
|
|
36
|
+
properties: Object.freeze({
|
|
37
|
+
query: Object.freeze({
|
|
38
|
+
type: "string",
|
|
39
|
+
minLength: 1,
|
|
40
|
+
maxLength: 500,
|
|
41
|
+
description: "The exact user chart-authoring request, including chart, encodings, guides, layout, and output format. Do not append dataset contents, code scaffolding, or evaluator instructions."
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
}),
|
|
45
|
+
annotations: Object.freeze({
|
|
46
|
+
readOnlyHint: true,
|
|
47
|
+
destructiveHint: false,
|
|
48
|
+
idempotentHint: true,
|
|
49
|
+
openWorldHint: false
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export class KnowledgeResourceError extends Error {
|
|
54
|
+
constructor(message) {
|
|
55
|
+
super(message);
|
|
56
|
+
this.name = "KnowledgeResourceError";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function jsonResource(uri, value) {
|
|
61
|
+
return Object.freeze({
|
|
62
|
+
uri,
|
|
63
|
+
mimeType: "application/json",
|
|
64
|
+
text: JSON.stringify(value)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function markdownResource(uri, value) {
|
|
69
|
+
return Object.freeze({
|
|
70
|
+
uri,
|
|
71
|
+
mimeType: "text/markdown",
|
|
72
|
+
text: `${value.text}\n\nCanonical public route: ${value.route}`
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function encodedUri(owner, id) {
|
|
77
|
+
return `ggaction://${owner}/${encodeURIComponent(id)}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function parseResourceUri(uri) {
|
|
81
|
+
let parsed;
|
|
82
|
+
try {
|
|
83
|
+
parsed = new URL(uri);
|
|
84
|
+
} catch {
|
|
85
|
+
throw new KnowledgeResourceError(`Invalid knowledge resource URI: ${uri}`);
|
|
86
|
+
}
|
|
87
|
+
if (parsed.protocol !== "ggaction:" || parsed.search || parsed.hash) {
|
|
88
|
+
throw new KnowledgeResourceError(`Unsupported knowledge resource URI: ${uri}`);
|
|
89
|
+
}
|
|
90
|
+
const segments = parsed.pathname.split("/").filter(Boolean);
|
|
91
|
+
return { owner: parsed.hostname, segments };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function searchGgactionText(query) {
|
|
95
|
+
return JSON.stringify(searchGgaction(query));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function docsFallbackResources(packet) {
|
|
99
|
+
if (!packet || !Array.isArray(packet.unresolved) || packet.unresolved.length === 0) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
for (const entry of packet.unresolved) {
|
|
103
|
+
if (!Array.isArray(entry.resources) || entry.resources.length === 0) {
|
|
104
|
+
throw new KnowledgeResourceError(
|
|
105
|
+
`Unresolved constraint ${entry.constraint ?? "unknown"} has no explicit documentation resource.`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const resources = unique(packet.unresolved.flatMap(entry => entry.resources));
|
|
110
|
+
return resources.map(uri => {
|
|
111
|
+
const { owner, segments } = parseResourceUri(uri);
|
|
112
|
+
if (owner !== "docs" || segments.length !== 1) {
|
|
113
|
+
throw new KnowledgeResourceError(`Invalid unresolved documentation resource: ${uri}`);
|
|
114
|
+
}
|
|
115
|
+
const id = decodeURIComponent(segments[0]);
|
|
116
|
+
const section = docs.get(id);
|
|
117
|
+
if (!section) {
|
|
118
|
+
throw new KnowledgeResourceError(`Unknown unresolved documentation resource: ${uri}`);
|
|
119
|
+
}
|
|
120
|
+
return Object.freeze({
|
|
121
|
+
uri,
|
|
122
|
+
name: section.title,
|
|
123
|
+
description: `Read only for the unresolved constraint; public route ${section.route}.`,
|
|
124
|
+
mimeType: "text/markdown"
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function listKnowledgeResources() {
|
|
130
|
+
return [
|
|
131
|
+
Object.freeze({
|
|
132
|
+
uri: OVERVIEW_URI,
|
|
133
|
+
name: resourcesArtifact.overview.title,
|
|
134
|
+
description: "Small MCP-first routing instructions; no complete documentation preload.",
|
|
135
|
+
mimeType: "application/json"
|
|
136
|
+
}),
|
|
137
|
+
...resourcesArtifact.recipes.map(recipe => Object.freeze({
|
|
138
|
+
uri: encodedUri("recipes", recipe.id),
|
|
139
|
+
name: recipe.title,
|
|
140
|
+
description: recipe.summary,
|
|
141
|
+
mimeType: "application/json"
|
|
142
|
+
}))
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function listKnowledgeResourceTemplates() {
|
|
147
|
+
return [
|
|
148
|
+
Object.freeze({
|
|
149
|
+
uriTemplate: "ggaction://actions/{name}",
|
|
150
|
+
name: "Exact compact action card",
|
|
151
|
+
description: "Read one exact action card by current public action name.",
|
|
152
|
+
mimeType: "application/json"
|
|
153
|
+
}),
|
|
154
|
+
Object.freeze({
|
|
155
|
+
uriTemplate: "ggaction://docs/{section}",
|
|
156
|
+
name: "Unresolved-only bounded documentation section",
|
|
157
|
+
description: "Read only a section recommended by the latest search_ggaction unresolved result.",
|
|
158
|
+
mimeType: "text/markdown"
|
|
159
|
+
})
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function readKnowledgeResource(uri, { allowedDocs = [] } = {}) {
|
|
164
|
+
if (uri === OVERVIEW_URI) {
|
|
165
|
+
return jsonResource(uri, {
|
|
166
|
+
schemaVersion: resourcesArtifact.schemaVersion,
|
|
167
|
+
title: resourcesArtifact.overview.title,
|
|
168
|
+
text: resourcesArtifact.overview.text
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const { owner, segments } = parseResourceUri(uri);
|
|
173
|
+
if (segments.length !== 1) {
|
|
174
|
+
throw new KnowledgeResourceError(`Unknown knowledge resource URI: ${uri}`);
|
|
175
|
+
}
|
|
176
|
+
const id = decodeURIComponent(segments[0]);
|
|
177
|
+
if (owner === "actions") {
|
|
178
|
+
const card = cards.get(id);
|
|
179
|
+
if (!card) throw new KnowledgeResourceError(`Unknown ggaction action: ${id}`);
|
|
180
|
+
return jsonResource(uri, card);
|
|
181
|
+
}
|
|
182
|
+
if (owner === "recipes") {
|
|
183
|
+
const recipe = recipes.get(id);
|
|
184
|
+
if (!recipe) throw new KnowledgeResourceError(`Unknown ggaction recipe: ${id}`);
|
|
185
|
+
return jsonResource(uri, {
|
|
186
|
+
schemaVersion: resourcesArtifact.schemaVersion,
|
|
187
|
+
...recipe,
|
|
188
|
+
packet: searchGgaction(recipe.query)
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (owner === "docs") {
|
|
192
|
+
if (!new Set(allowedDocs).has(uri)) {
|
|
193
|
+
throw new KnowledgeResourceError(
|
|
194
|
+
"Documentation resources are available only when recommended by the latest unresolved search result."
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
const section = docs.get(id);
|
|
198
|
+
if (!section) throw new KnowledgeResourceError(`Unknown docs fallback section: ${id}`);
|
|
199
|
+
return markdownResource(uri, section);
|
|
200
|
+
}
|
|
201
|
+
throw new KnowledgeResourceError(`Unknown knowledge resource URI: ${uri}`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (cardsArtifact.schemaVersion !== 1 || resourcesArtifact.schemaVersion !== 2) {
|
|
205
|
+
throw new Error("MCP action cards must use schemaVersion 1 and resources schemaVersion 2.");
|
|
206
|
+
}
|
package/src/mcp/cli.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { runGgactionMcpServer } from "./server.js";
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
await runGgactionMcpServer();
|
|
7
|
+
} catch (error) {
|
|
8
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9
|
+
process.stderr.write(`ggaction MCP failed: ${message}\n`);
|
|
10
|
+
process.exitCode = 1;
|
|
11
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import {
|
|
4
|
+
CallToolRequestSchema,
|
|
5
|
+
ErrorCode,
|
|
6
|
+
ListResourcesRequestSchema,
|
|
7
|
+
ListResourceTemplatesRequestSchema,
|
|
8
|
+
ListToolsRequestSchema,
|
|
9
|
+
McpError,
|
|
10
|
+
ReadResourceRequestSchema
|
|
11
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
docsFallbackResources,
|
|
15
|
+
KnowledgeResourceError,
|
|
16
|
+
listKnowledgeResources,
|
|
17
|
+
listKnowledgeResourceTemplates,
|
|
18
|
+
readKnowledgeResource,
|
|
19
|
+
SEARCH_TOOL,
|
|
20
|
+
SEARCH_TOOL_NAME,
|
|
21
|
+
searchGgactionText
|
|
22
|
+
} from "./adapter.js";
|
|
23
|
+
|
|
24
|
+
const SERVER_INFO = Object.freeze({ name: "ggaction", version: "1.0.0" });
|
|
25
|
+
|
|
26
|
+
function toolError(error) {
|
|
27
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
28
|
+
return {
|
|
29
|
+
content: [{ type: "text", text: JSON.stringify({ error: message }) }],
|
|
30
|
+
isError: true
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function validateToolArguments(args) {
|
|
35
|
+
if (!args || typeof args !== "object" || Array.isArray(args)) {
|
|
36
|
+
throw new TypeError("search_ggaction arguments must be an object with one query string.");
|
|
37
|
+
}
|
|
38
|
+
const names = Object.keys(args);
|
|
39
|
+
if (names.length !== 1 || names[0] !== "query") {
|
|
40
|
+
throw new TypeError("search_ggaction accepts exactly one argument: query.");
|
|
41
|
+
}
|
|
42
|
+
return args.query;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function createGgactionMcpServer() {
|
|
46
|
+
const server = new Server(SERVER_INFO, {
|
|
47
|
+
capabilities: { tools: {}, resources: {} },
|
|
48
|
+
instructions: "Call search_ggaction once with only the exact user task; do not append dataset contents, code scaffolding, or evaluator instructions. Use authoring imports, initialization, prerequisites, and immutable steps in order. Treat unsupported entries as terminal limitations. Read only the resource URIs attached to unresolved entries. The server is read-only and does not execute chart code."
|
|
49
|
+
});
|
|
50
|
+
let allowedDocs = new Set();
|
|
51
|
+
|
|
52
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
53
|
+
tools: [SEARCH_TOOL]
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
server.setRequestHandler(CallToolRequestSchema, async request => {
|
|
57
|
+
if (request.params.name !== SEARCH_TOOL_NAME) {
|
|
58
|
+
throw new McpError(ErrorCode.InvalidParams, `Unknown tool: ${request.params.name}`);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const query = validateToolArguments(request.params.arguments);
|
|
62
|
+
const text = searchGgactionText(query);
|
|
63
|
+
const packet = JSON.parse(text);
|
|
64
|
+
allowedDocs = new Set(docsFallbackResources(packet).map(resource => resource.uri));
|
|
65
|
+
return { content: [{ type: "text", text }] };
|
|
66
|
+
} catch (error) {
|
|
67
|
+
allowedDocs = new Set();
|
|
68
|
+
return toolError(error);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
73
|
+
resources: listKnowledgeResources()
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => ({
|
|
77
|
+
resourceTemplates: listKnowledgeResourceTemplates()
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
server.setRequestHandler(ReadResourceRequestSchema, async request => {
|
|
81
|
+
try {
|
|
82
|
+
const resource = readKnowledgeResource(request.params.uri, {
|
|
83
|
+
allowedDocs: [...allowedDocs]
|
|
84
|
+
});
|
|
85
|
+
return { contents: [resource] };
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (error instanceof KnowledgeResourceError) {
|
|
88
|
+
throw new McpError(ErrorCode.InvalidParams, error.message);
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return server;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function runGgactionMcpServer() {
|
|
98
|
+
const server = createGgactionMcpServer();
|
|
99
|
+
await server.connect(new StdioServerTransport());
|
|
100
|
+
return server;
|
|
101
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ export type {
|
|
|
23
23
|
Bin2DOutputFields,
|
|
24
24
|
CanvasOptions,
|
|
25
25
|
CategoricalEncodingOptions,
|
|
26
|
+
CategoryOrder,
|
|
27
|
+
CategoryOrderSummary,
|
|
28
|
+
CategoryValue,
|
|
26
29
|
ColorLayout,
|
|
27
30
|
ColorEncodingOptions,
|
|
28
31
|
CompleteAxisOptions,
|
|
@@ -66,6 +69,7 @@ export type {
|
|
|
66
69
|
DatasetFilterTransform,
|
|
67
70
|
DatasetIntervalOutputFields,
|
|
68
71
|
DatasetIntervalTransform,
|
|
72
|
+
DatasetTimeUnitTransform,
|
|
69
73
|
DatasetWindowOperation,
|
|
70
74
|
DatasetWindowSort,
|
|
71
75
|
DatasetWindowTransform,
|
|
@@ -141,6 +145,7 @@ export type {
|
|
|
141
145
|
ContinuousColorScaleOptions,
|
|
142
146
|
OpacityEncodingOptions,
|
|
143
147
|
OpacityScaleOptions,
|
|
148
|
+
OrderCategoriesOptions,
|
|
144
149
|
OffsetScaleOptions,
|
|
145
150
|
PathOrderEncodingOptions,
|
|
146
151
|
ParallelCoordinatesEncodingOptions,
|
|
@@ -153,6 +158,7 @@ export type {
|
|
|
153
158
|
Palette,
|
|
154
159
|
PaletteName,
|
|
155
160
|
PositionEncodingOptions,
|
|
161
|
+
YPositionEncodingOptions,
|
|
156
162
|
RulePositionEncodingOptions,
|
|
157
163
|
SecondaryPositionEncodingOptions,
|
|
158
164
|
RegressionBandOptions,
|
|
@@ -165,6 +171,7 @@ export type {
|
|
|
165
171
|
EditRegressionOptions,
|
|
166
172
|
EditRectMarkOptions,
|
|
167
173
|
RemoveAxisOptions,
|
|
174
|
+
RemoveCategoryOrderOptions,
|
|
168
175
|
RemoveGridOptions,
|
|
169
176
|
RemoveJitterOptions,
|
|
170
177
|
RemoveLabelLayoutOptions,
|
|
@@ -175,6 +182,7 @@ export type {
|
|
|
175
182
|
ScaleOptions,
|
|
176
183
|
ScaleType,
|
|
177
184
|
StackMode,
|
|
185
|
+
YStackMode,
|
|
178
186
|
SemanticCoordinate,
|
|
179
187
|
SemanticDataset,
|
|
180
188
|
SemanticLayer,
|
|
@@ -186,6 +194,8 @@ export type {
|
|
|
186
194
|
StrokeWidthScaleOptions,
|
|
187
195
|
ThetaEncodingOptions,
|
|
188
196
|
ThetaScaleOptions,
|
|
197
|
+
TimeUnit,
|
|
198
|
+
TimeUnitDataOptions,
|
|
189
199
|
TraceNode,
|
|
190
200
|
TitleOptions,
|
|
191
201
|
EditTitleOptions,
|
package/types/program.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ export type ScaleType =
|
|
|
78
78
|
| "quantile"
|
|
79
79
|
| "threshold";
|
|
80
80
|
export type StackMode = "zero" | "normalize" | null;
|
|
81
|
+
export type YStackMode = StackMode | "center";
|
|
81
82
|
export type CompositionAlign = "start" | "center" | "end";
|
|
82
83
|
export interface CompositionPadding {
|
|
83
84
|
top?: number;
|
|
@@ -370,6 +371,15 @@ export type WindowOperation =
|
|
|
370
371
|
as: string;
|
|
371
372
|
offset?: number;
|
|
372
373
|
default?: unknown;
|
|
374
|
+
}
|
|
375
|
+
| {
|
|
376
|
+
op: "movingMean" | "movingSum";
|
|
377
|
+
field: string;
|
|
378
|
+
as: string;
|
|
379
|
+
frame: {
|
|
380
|
+
preceding: number;
|
|
381
|
+
following?: number;
|
|
382
|
+
};
|
|
373
383
|
};
|
|
374
384
|
export interface DatasetWindowSort {
|
|
375
385
|
readonly field: string;
|
|
@@ -388,6 +398,15 @@ export type DatasetWindowOperation =
|
|
|
388
398
|
readonly as: string;
|
|
389
399
|
readonly offset: number;
|
|
390
400
|
readonly default: unknown;
|
|
401
|
+
}
|
|
402
|
+
| {
|
|
403
|
+
readonly op: "movingMean" | "movingSum";
|
|
404
|
+
readonly field: string;
|
|
405
|
+
readonly as: string;
|
|
406
|
+
readonly frame: {
|
|
407
|
+
readonly preceding: number;
|
|
408
|
+
readonly following: number;
|
|
409
|
+
};
|
|
391
410
|
};
|
|
392
411
|
export interface DatasetWindowTransform {
|
|
393
412
|
readonly type: "window";
|
|
@@ -395,6 +414,20 @@ export interface DatasetWindowTransform {
|
|
|
395
414
|
readonly sortBy: readonly DatasetWindowSort[];
|
|
396
415
|
readonly operations: readonly DatasetWindowOperation[];
|
|
397
416
|
}
|
|
417
|
+
export type TimeUnit =
|
|
418
|
+
| "year"
|
|
419
|
+
| "quarter"
|
|
420
|
+
| "month"
|
|
421
|
+
| "day"
|
|
422
|
+
| "hour"
|
|
423
|
+
| "minute"
|
|
424
|
+
| "second";
|
|
425
|
+
export interface DatasetTimeUnitTransform {
|
|
426
|
+
readonly type: "timeUnit";
|
|
427
|
+
readonly field: string;
|
|
428
|
+
readonly unit: TimeUnit;
|
|
429
|
+
readonly as: string;
|
|
430
|
+
}
|
|
398
431
|
export interface Bin2DCounts {
|
|
399
432
|
x: number;
|
|
400
433
|
y: number;
|
|
@@ -451,6 +484,7 @@ export type DatasetTransform =
|
|
|
451
484
|
| DatasetDensityTransform
|
|
452
485
|
| DatasetHorizonTransform
|
|
453
486
|
| DatasetIntervalTransform
|
|
487
|
+
| DatasetTimeUnitTransform
|
|
454
488
|
| DatasetWindowTransform;
|
|
455
489
|
export interface CreateDerivedDataOptions {
|
|
456
490
|
id: string;
|
|
@@ -518,7 +552,8 @@ export type ColorLayout =
|
|
|
518
552
|
| "fill"
|
|
519
553
|
| "group"
|
|
520
554
|
| "overlay"
|
|
521
|
-
| "diverging"
|
|
555
|
+
| "diverging"
|
|
556
|
+
| "center";
|
|
522
557
|
export type ScalarAggregateOperation =
|
|
523
558
|
| "count" | "sum" | "mean" | "median" | "min" | "max"
|
|
524
559
|
| "distinct" | "valid" | "missing"
|
|
@@ -918,6 +953,9 @@ export interface PositionEncodingOptions {
|
|
|
918
953
|
stack?: StackMode;
|
|
919
954
|
}
|
|
920
955
|
|
|
956
|
+
export type YPositionEncodingOptions =
|
|
957
|
+
Omit<PositionEncodingOptions, "stack"> & { stack?: YStackMode };
|
|
958
|
+
|
|
921
959
|
export interface ThetaScaleOptions {
|
|
922
960
|
id?: string;
|
|
923
961
|
type?: "linear" | "time" | "band" | "point";
|
|
@@ -1111,6 +1149,14 @@ export interface WindowDataOptions {
|
|
|
1111
1149
|
operations: readonly WindowOperation[];
|
|
1112
1150
|
}
|
|
1113
1151
|
|
|
1152
|
+
export interface TimeUnitDataOptions {
|
|
1153
|
+
id: string;
|
|
1154
|
+
source?: string;
|
|
1155
|
+
field: string;
|
|
1156
|
+
unit: TimeUnit;
|
|
1157
|
+
as: string;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1114
1160
|
export interface Bin2DDataOptions {
|
|
1115
1161
|
id: string;
|
|
1116
1162
|
source?: string;
|
|
@@ -2098,6 +2144,31 @@ export interface RemovePathOrderOptions {
|
|
|
2098
2144
|
target?: string;
|
|
2099
2145
|
}
|
|
2100
2146
|
|
|
2147
|
+
export type CategoryValue = string | number | boolean;
|
|
2148
|
+
export type CategoryOrderSummary = {
|
|
2149
|
+
field: string;
|
|
2150
|
+
aggregate: "sum" | "mean" | "min" | "max";
|
|
2151
|
+
};
|
|
2152
|
+
export type CategoryOrder =
|
|
2153
|
+
| {
|
|
2154
|
+
values: readonly CategoryValue[];
|
|
2155
|
+
by?: never;
|
|
2156
|
+
direction?: never;
|
|
2157
|
+
}
|
|
2158
|
+
| {
|
|
2159
|
+
values?: never;
|
|
2160
|
+
by: "category" | "count" | CategoryOrderSummary;
|
|
2161
|
+
direction?: "ascending" | "descending";
|
|
2162
|
+
};
|
|
2163
|
+
export type OrderCategoriesOptions = {
|
|
2164
|
+
target?: string;
|
|
2165
|
+
channel: "x" | "y";
|
|
2166
|
+
} & CategoryOrder;
|
|
2167
|
+
export interface RemoveCategoryOrderOptions {
|
|
2168
|
+
target?: string;
|
|
2169
|
+
channel: "x" | "y";
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2101
2172
|
export interface TitleOptions {
|
|
2102
2173
|
text: string;
|
|
2103
2174
|
subtitle?: string;
|
|
@@ -2143,6 +2214,7 @@ export class ChartProgram {
|
|
|
2143
2214
|
createDensityData(options: DensityDataOptions): ChartProgram;
|
|
2144
2215
|
createRegressionData(options: RegressionDataOptions): ChartProgram;
|
|
2145
2216
|
createIntervalData(options: IntervalDataOptions): ChartProgram;
|
|
2217
|
+
createTimeUnitData(options: TimeUnitDataOptions): ChartProgram;
|
|
2146
2218
|
createWindowData(options: WindowDataOptions): ChartProgram;
|
|
2147
2219
|
createBin2DData(options: Bin2DDataOptions): ChartProgram;
|
|
2148
2220
|
editBin2DData(options: EditBin2DDataOptions): ChartProgram;
|
|
@@ -2164,6 +2236,21 @@ export class ChartProgram {
|
|
|
2164
2236
|
stroke?: string | false;
|
|
2165
2237
|
strokeWidth?: number;
|
|
2166
2238
|
}): ChartProgram;
|
|
2239
|
+
createTickMark(options?: {
|
|
2240
|
+
id?: string;
|
|
2241
|
+
data?: string;
|
|
2242
|
+
length?: number;
|
|
2243
|
+
stroke?: string;
|
|
2244
|
+
strokeWidth?: number;
|
|
2245
|
+
opacity?: number;
|
|
2246
|
+
}): ChartProgram;
|
|
2247
|
+
editTickMark(options: {
|
|
2248
|
+
target?: string;
|
|
2249
|
+
length?: number;
|
|
2250
|
+
stroke?: string;
|
|
2251
|
+
strokeWidth?: number;
|
|
2252
|
+
opacity?: number;
|
|
2253
|
+
}): ChartProgram;
|
|
2167
2254
|
jitterPoints(options: JitterPointsOptions): ChartProgram;
|
|
2168
2255
|
removeJitter(options?: RemoveJitterOptions): ChartProgram;
|
|
2169
2256
|
createLineMark(options?: {
|
|
@@ -2243,7 +2330,7 @@ export class ChartProgram {
|
|
|
2243
2330
|
}): ChartProgram;
|
|
2244
2331
|
|
|
2245
2332
|
encodeX(options: PositionEncodingOptions | RulePositionEncodingOptions): ChartProgram;
|
|
2246
|
-
encodeY(options:
|
|
2333
|
+
encodeY(options: YPositionEncodingOptions | RulePositionEncodingOptions): ChartProgram;
|
|
2247
2334
|
encodeTheta(options: ThetaEncodingOptions): ChartProgram;
|
|
2248
2335
|
encodeR(options: RadialEncodingOptions): ChartProgram;
|
|
2249
2336
|
encodeX2(options: SecondaryPositionEncodingOptions): ChartProgram;
|
|
@@ -2251,6 +2338,10 @@ export class ChartProgram {
|
|
|
2251
2338
|
encodeStrokeDash(options: StrokeDashEncodingOptions): ChartProgram;
|
|
2252
2339
|
encodeSize(options: { field: string; target?: string; fieldType?: "quantitative"; scale?: ScaleOptions }): ChartProgram;
|
|
2253
2340
|
encodeShape(options: { field: string; target?: string; fieldType?: "nominal"; scale?: ScaleOptions }): ChartProgram;
|
|
2341
|
+
encodeAngle(options:
|
|
2342
|
+
| { target?: string; value: number; field?: never; fieldType?: never }
|
|
2343
|
+
| { target?: string; field: string; fieldType?: "quantitative"; value?: never }
|
|
2344
|
+
): ChartProgram;
|
|
2254
2345
|
encodeOpacity(options: OpacityEncodingOptions): ChartProgram;
|
|
2255
2346
|
encodeRadius(options: { value: number; target?: string }): ChartProgram;
|
|
2256
2347
|
encodePointRadius(options: { value: number; target?: string }): ChartProgram;
|
|
@@ -2276,14 +2367,16 @@ export class ChartProgram {
|
|
|
2276
2367
|
}): ChartProgram;
|
|
2277
2368
|
encodeGroup(options: { field: string; target?: string; fieldType?: "nominal" }): ChartProgram;
|
|
2278
2369
|
encodePathOrder(options: PathOrderEncodingOptions): ChartProgram;
|
|
2370
|
+
orderCategories(options: OrderCategoriesOptions): ChartProgram;
|
|
2279
2371
|
encodeParallelCoordinates(options: ParallelCoordinatesEncodingOptions): ChartProgram;
|
|
2280
2372
|
removePathOrder(options?: RemovePathOrderOptions): ChartProgram;
|
|
2373
|
+
removeCategoryOrder(options: RemoveCategoryOrderOptions): ChartProgram;
|
|
2281
2374
|
removeEncoding(options: {
|
|
2282
2375
|
target?: string;
|
|
2283
2376
|
channel:
|
|
2284
2377
|
| "x" | "y" | "x2" | "y2" | "xOffset" | "yOffset"
|
|
2285
2378
|
| "theta" | "radius" | "color" | "strokeDash" | "strokeWidth"
|
|
2286
|
-
| "size" | "shape" | "group" | "opacity" | "text";
|
|
2379
|
+
| "size" | "shape" | "angle" | "group" | "opacity" | "text";
|
|
2287
2380
|
}): ChartProgram;
|
|
2288
2381
|
encodeText(options: TextEncodingOptions): ChartProgram;
|
|
2289
2382
|
encodeHistogram(options: HistogramEncodingOptions): ChartProgram;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { validateSemanticValue } from "./semanticValidation/index.js";
|