@canonical/design-system 0.1.1 → 0.1.2
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/.github/PULL_REQUEST_TEMPLATE.md +13 -0
- package/.github/workflows/ci.yml +39 -0
- package/.mcp.json +1 -3
- package/biome.json +1 -1
- package/bun.lock +38 -35
- package/data/apps_launchpad/component/badge.ttl +2 -1
- package/data/apps_launchpad/component/button.ttl +2 -1
- package/data/apps_launchpad/component/combobox.ttl +2 -1
- package/data/apps_launchpad/component/text_input.ttl +2 -1
- package/data/apps_launchpad/component/tooltip.ttl +2 -1
- package/data/global/component/announcement.ttl +1 -1
- package/data/global/component/button.ttl +3 -1
- package/data/global/component/code_snippet.ttl +1 -1
- package/data/global/component/heading.ttl +3 -2
- package/data/global/component/tile.ttl +1 -1
- package/data/global/component/tooltip.ttl +38 -19
- package/data/global/pattern/dropdown_button.ttl +1 -1
- package/data/global/pattern/timeline.ttl +8 -4
- package/definitions/ontology.ttl +108 -161
- package/package.json +1 -1
- package/skills/anatomy-author/SKILL.md +5 -0
- package/skills/component-specifier/SKILL.md +5 -2
- package/skills/design-auditor/SKILL.md +5 -0
- package/source.json +7 -2
- package/src/cli.ts +33 -33
- package/src/collect/generateTurtle.tests.ts +181 -176
- package/src/collect/generateTurtle.ts +189 -138
- package/src/collect/index.ts +5 -2
- package/src/collect/scanAnnotations.tests.ts +116 -110
- package/src/collect/scanAnnotations.ts +35 -33
- package/src/collect/types.ts +34 -33
- package/src/collect/validateCollectConfig.tests.ts +135 -112
- package/src/collect/validateCollectConfig.ts +60 -54
- package/src/collect-implementations.ts +101 -88
- package/src/commands/extract.tests.ts +31 -32
- package/src/commands/extract.ts +29 -27
- package/src/commands/index.ts +1 -1
- package/src/commands/list.tests.ts +13 -14
- package/src/commands/list.ts +9 -9
- package/src/commands/transform.tests.ts +21 -21
- package/src/commands/transform.ts +118 -114
- package/src/config/types.ts +40 -40
- package/src/config/validateConfig.tests.ts +31 -31
- package/src/config/validateConfig.ts +9 -9
- package/src/constants.ts +7 -8
- package/src/graph/GraphStore.tests.ts +111 -111
- package/src/graph/GraphStore.ts +205 -189
- package/src/graph/PrefixMap.tests.ts +124 -122
- package/src/graph/PrefixMap.ts +77 -77
- package/src/graph/buildUri.tests.ts +116 -116
- package/src/graph/buildUri.ts +45 -45
- package/src/graph/index.ts +2 -2
- package/src/graph/types.ts +3 -3
- package/src/providers/CodaProvider.tests.ts +233 -233
- package/src/providers/CodaProvider.ts +145 -145
- package/src/providers/CodaProvider.types.generated.ts +12484 -12123
- package/src/providers/index.ts +13 -13
- package/src/serializers/JSONSerializer.tests.ts +64 -64
- package/src/serializers/JSONSerializer.ts +51 -51
- package/src/serializers/TTLSerializer.tests.ts +45 -45
- package/src/serializers/TTLSerializer.ts +64 -57
- package/src/serializers/index.ts +4 -1
- package/src/serializers/types.ts +3 -3
- package/src/transform/resolveReferences.tests.ts +47 -43
- package/src/transform/resolveReferences.ts +18 -18
- package/src/transform/resolveValue.tests.ts +55 -49
- package/src/transform/resolveValue.ts +48 -48
- package/src/transform/transform.tests.ts +90 -77
- package/src/transform/transform.ts +77 -77
- package/src/transform/transformRow.tests.ts +372 -356
- package/src/transform/transformRow.ts +222 -191
- package/src/transform/types.ts +4 -4
- package/tsconfig.json +2 -1
- package/.gemini/settings.json +0 -14
|
@@ -2,24 +2,24 @@ import type { TransformConfig } from "../config/types.js";
|
|
|
2
2
|
import { GraphStore, PrefixMap } from "../graph/index.js";
|
|
3
3
|
import resolveReferences from "./resolveReferences.js";
|
|
4
4
|
import transformRow from "./transformRow.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { InlineDataMap, ReferenceMap } from "./types.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Extracted data structure from the extract command
|
|
9
9
|
*/
|
|
10
10
|
interface ExtractedData {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
document: string;
|
|
12
|
+
extractedAt: string;
|
|
13
|
+
tables: Record<string, Array<Record<string, unknown>>>;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Result of the transform operation
|
|
18
18
|
*/
|
|
19
19
|
export interface TransformResult {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
store: GraphStore;
|
|
21
|
+
prefixes: PrefixMap;
|
|
22
|
+
subjects: string[];
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -29,83 +29,83 @@ export interface TransformResult {
|
|
|
29
29
|
* for cross-table lookups, then transforms each row into quads.
|
|
30
30
|
*/
|
|
31
31
|
export default function transform(
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
config: TransformConfig,
|
|
33
|
+
extractedData: ExtractedData,
|
|
34
34
|
): TransformResult {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const store = new GraphStore();
|
|
36
|
+
const subjects: string[] = [];
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
// Build reference maps for all reference tables
|
|
39
|
+
const mergedRefMap: ReferenceMap = new Map();
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
if (config.references) {
|
|
42
|
+
for (const [tableName, refConfig] of Object.entries(config.references)) {
|
|
43
|
+
const tableData = extractedData.tables[tableName];
|
|
44
|
+
if (tableData) {
|
|
45
|
+
const refMap = resolveReferences(tableData, refConfig);
|
|
46
|
+
// Merge into the combined map
|
|
47
|
+
for (const [key, value] of refMap) {
|
|
48
|
+
mergedRefMap.set(key, value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// Collect all prefixes from table contexts
|
|
55
|
+
const prefixes = new PrefixMap();
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
// Build inline data maps for all tables (indexed by _codaId and common name columns)
|
|
58
|
+
const inlineData: Record<string, InlineDataMap> = {};
|
|
59
|
+
const nameColumns = ["name", "property name", "Name"];
|
|
60
|
+
for (const [tableName, tableData] of Object.entries(extractedData.tables)) {
|
|
61
|
+
const dataMap: InlineDataMap = new Map();
|
|
62
|
+
for (const row of tableData) {
|
|
63
|
+
// Index by Coda ID
|
|
64
|
+
const codaId = row._codaId as string;
|
|
65
|
+
if (codaId) {
|
|
66
|
+
dataMap.set(codaId, row);
|
|
67
|
+
}
|
|
68
|
+
// Also index by common name columns for name-based lookups
|
|
69
|
+
for (const col of nameColumns) {
|
|
70
|
+
const nameValue = row[col];
|
|
71
|
+
if (typeof nameValue === "string" && nameValue.length > 0) {
|
|
72
|
+
dataMap.set(nameValue.toLowerCase(), row);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
inlineData[tableName] = dataMap;
|
|
77
|
+
}
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
// Transform each configured table
|
|
80
|
+
for (const [tableName, tableConfig] of Object.entries(config.tables)) {
|
|
81
|
+
const tableData = extractedData.tables[tableName];
|
|
82
|
+
if (!tableData) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
// Extract prefixes from this table's context
|
|
87
|
+
const tablePrefixes = PrefixMap.fromContext(
|
|
88
|
+
tableConfig["@context"] as Record<string, unknown>,
|
|
89
|
+
);
|
|
90
|
+
for (const [prefix, namespace] of tablePrefixes.entries()) {
|
|
91
|
+
prefixes.add(prefix, namespace);
|
|
92
|
+
}
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
94
|
+
// Transform each row
|
|
95
|
+
for (const row of tableData) {
|
|
96
|
+
const subjectUri = transformRow(
|
|
97
|
+
row,
|
|
98
|
+
tableConfig,
|
|
99
|
+
store,
|
|
100
|
+
prefixes,
|
|
101
|
+
mergedRefMap,
|
|
102
|
+
inlineData,
|
|
103
|
+
);
|
|
104
|
+
if (subjectUri !== null) {
|
|
105
|
+
subjects.push(subjectUri);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
return { store, prefixes, subjects };
|
|
111
111
|
}
|