@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.
Files changed (74) hide show
  1. package/.github/PULL_REQUEST_TEMPLATE.md +13 -0
  2. package/.github/workflows/ci.yml +39 -0
  3. package/.mcp.json +1 -3
  4. package/biome.json +1 -1
  5. package/bun.lock +38 -35
  6. package/data/apps_launchpad/component/badge.ttl +2 -1
  7. package/data/apps_launchpad/component/button.ttl +2 -1
  8. package/data/apps_launchpad/component/combobox.ttl +2 -1
  9. package/data/apps_launchpad/component/text_input.ttl +2 -1
  10. package/data/apps_launchpad/component/tooltip.ttl +2 -1
  11. package/data/global/component/announcement.ttl +1 -1
  12. package/data/global/component/button.ttl +3 -1
  13. package/data/global/component/code_snippet.ttl +1 -1
  14. package/data/global/component/heading.ttl +3 -2
  15. package/data/global/component/tile.ttl +1 -1
  16. package/data/global/component/tooltip.ttl +38 -19
  17. package/data/global/pattern/dropdown_button.ttl +1 -1
  18. package/data/global/pattern/timeline.ttl +8 -4
  19. package/definitions/ontology.ttl +108 -161
  20. package/package.json +1 -1
  21. package/skills/anatomy-author/SKILL.md +5 -0
  22. package/skills/component-specifier/SKILL.md +5 -2
  23. package/skills/design-auditor/SKILL.md +5 -0
  24. package/source.json +7 -2
  25. package/src/cli.ts +33 -33
  26. package/src/collect/generateTurtle.tests.ts +181 -176
  27. package/src/collect/generateTurtle.ts +189 -138
  28. package/src/collect/index.ts +5 -2
  29. package/src/collect/scanAnnotations.tests.ts +116 -110
  30. package/src/collect/scanAnnotations.ts +35 -33
  31. package/src/collect/types.ts +34 -33
  32. package/src/collect/validateCollectConfig.tests.ts +135 -112
  33. package/src/collect/validateCollectConfig.ts +60 -54
  34. package/src/collect-implementations.ts +101 -88
  35. package/src/commands/extract.tests.ts +31 -32
  36. package/src/commands/extract.ts +29 -27
  37. package/src/commands/index.ts +1 -1
  38. package/src/commands/list.tests.ts +13 -14
  39. package/src/commands/list.ts +9 -9
  40. package/src/commands/transform.tests.ts +21 -21
  41. package/src/commands/transform.ts +118 -114
  42. package/src/config/types.ts +40 -40
  43. package/src/config/validateConfig.tests.ts +31 -31
  44. package/src/config/validateConfig.ts +9 -9
  45. package/src/constants.ts +7 -8
  46. package/src/graph/GraphStore.tests.ts +111 -111
  47. package/src/graph/GraphStore.ts +205 -189
  48. package/src/graph/PrefixMap.tests.ts +124 -122
  49. package/src/graph/PrefixMap.ts +77 -77
  50. package/src/graph/buildUri.tests.ts +116 -116
  51. package/src/graph/buildUri.ts +45 -45
  52. package/src/graph/index.ts +2 -2
  53. package/src/graph/types.ts +3 -3
  54. package/src/providers/CodaProvider.tests.ts +233 -233
  55. package/src/providers/CodaProvider.ts +145 -145
  56. package/src/providers/CodaProvider.types.generated.ts +12484 -12123
  57. package/src/providers/index.ts +13 -13
  58. package/src/serializers/JSONSerializer.tests.ts +64 -64
  59. package/src/serializers/JSONSerializer.ts +51 -51
  60. package/src/serializers/TTLSerializer.tests.ts +45 -45
  61. package/src/serializers/TTLSerializer.ts +64 -57
  62. package/src/serializers/index.ts +4 -1
  63. package/src/serializers/types.ts +3 -3
  64. package/src/transform/resolveReferences.tests.ts +47 -43
  65. package/src/transform/resolveReferences.ts +18 -18
  66. package/src/transform/resolveValue.tests.ts +55 -49
  67. package/src/transform/resolveValue.ts +48 -48
  68. package/src/transform/transform.tests.ts +90 -77
  69. package/src/transform/transform.ts +77 -77
  70. package/src/transform/transformRow.tests.ts +372 -356
  71. package/src/transform/transformRow.ts +222 -191
  72. package/src/transform/types.ts +4 -4
  73. package/tsconfig.json +2 -1
  74. package/.gemini/settings.json +0 -14
@@ -1,4 +1,4 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
2
  import CodaProvider from "./CodaProvider.js";
3
3
 
4
4
  // Mock fetch globally
@@ -6,236 +6,236 @@ const mockFetch = vi.fn();
6
6
  global.fetch = mockFetch;
7
7
 
8
8
  describe("CodaProvider", () => {
9
- const apiKey = "test-api-key";
10
- let provider: CodaProvider;
11
- let originalEnv: string | undefined;
12
-
13
- beforeEach(() => {
14
- originalEnv = process.env.CODA_API_KEY;
15
- process.env.CODA_API_KEY = apiKey;
16
- provider = new CodaProvider();
17
- mockFetch.mockReset();
18
- });
19
-
20
- afterEach(() => {
21
- process.env.CODA_API_KEY = originalEnv;
22
- vi.restoreAllMocks();
23
- });
24
-
25
- describe("listTables", () => {
26
- it("should fetch and return table metadata", async () => {
27
- const mockResponse = {
28
- items: [
29
- {
30
- id: "grid-abc123",
31
- name: "Components",
32
- displayColumn: { id: "c-1", name: "Name" },
33
- },
34
- {
35
- id: "grid-def456",
36
- name: "Tiers",
37
- displayColumn: { id: "c-2", name: "Name" },
38
- },
39
- ],
40
- };
41
-
42
- mockFetch.mockResolvedValueOnce({
43
- ok: true,
44
- json: () => Promise.resolve(mockResponse),
45
- });
46
-
47
- const tables = await provider.listTables("dNyzE_TLZDh");
48
-
49
- expect(mockFetch).toHaveBeenCalledWith(
50
- "https://coda.io/apis/v1/docs/dNyzE_TLZDh/tables",
51
- expect.objectContaining({
52
- headers: expect.objectContaining({
53
- Authorization: "Bearer test-api-key",
54
- }),
55
- }),
56
- );
57
-
58
- expect(tables).toEqual([
59
- { id: "grid-abc123", name: "Components" },
60
- { id: "grid-def456", name: "Tiers" },
61
- ]);
62
- });
63
-
64
- it("should throw on API error", async () => {
65
- mockFetch.mockResolvedValueOnce({
66
- ok: false,
67
- status: 401,
68
- statusText: "Unauthorized",
69
- });
70
-
71
- await expect(provider.listTables("dNyzE_TLZDh")).rejects.toThrow(
72
- "Coda API error: 401 Unauthorized",
73
- );
74
- });
75
-
76
- it("should handle pagination", async () => {
77
- // First page
78
- mockFetch.mockResolvedValueOnce({
79
- ok: true,
80
- json: () =>
81
- Promise.resolve({
82
- items: [{ id: "grid-1", name: "Table1", displayColumn: null }],
83
- nextPageToken: "token123",
84
- }),
85
- });
86
-
87
- // Second page
88
- mockFetch.mockResolvedValueOnce({
89
- ok: true,
90
- json: () =>
91
- Promise.resolve({
92
- items: [{ id: "grid-2", name: "Table2", displayColumn: null }],
93
- }),
94
- });
95
-
96
- const tables = await provider.listTables("doc123");
97
-
98
- expect(mockFetch).toHaveBeenCalledTimes(2);
99
- expect(tables).toHaveLength(2);
100
- expect(tables[1].id).toBe("grid-2");
101
- });
102
- });
103
-
104
- describe("fetchTable", () => {
105
- it("should fetch all rows from a table", async () => {
106
- const mockResponse = {
107
- items: [
108
- {
109
- id: "i-row1",
110
- values: {
111
- "c-Name": "Button",
112
- "c-Description": "A clickable button",
113
- "c-Version": "1.0.0",
114
- },
115
- },
116
- {
117
- id: "i-row2",
118
- values: {
119
- "c-Name": "Modal",
120
- "c-Description": "A dialog overlay",
121
- "c-Version": "2.0.0",
122
- },
123
- },
124
- ],
125
- };
126
-
127
- mockFetch.mockResolvedValueOnce({
128
- ok: true,
129
- json: () => Promise.resolve(mockResponse),
130
- });
131
-
132
- const rows = await provider.fetchTable("dNyzE_TLZDh", "grid-abc123");
133
-
134
- expect(mockFetch).toHaveBeenCalledWith(
135
- expect.stringContaining(
136
- "https://coda.io/apis/v1/docs/dNyzE_TLZDh/tables/grid-abc123/rows",
137
- ),
138
- expect.objectContaining({
139
- headers: expect.objectContaining({
140
- Authorization: "Bearer test-api-key",
141
- }),
142
- }),
143
- );
144
-
145
- expect(rows).toEqual([
146
- {
147
- _codaId: "i-row1",
148
- Name: "Button",
149
- Description: "A clickable button",
150
- Version: "1.0.0",
151
- },
152
- {
153
- _codaId: "i-row2",
154
- Name: "Modal",
155
- Description: "A dialog overlay",
156
- Version: "2.0.0",
157
- },
158
- ]);
159
- });
160
-
161
- it("should handle pagination for large tables", async () => {
162
- // First page
163
- mockFetch.mockResolvedValueOnce({
164
- ok: true,
165
- json: () =>
166
- Promise.resolve({
167
- items: [{ id: "i-row1", values: { "c-Name": "Item1" } }],
168
- nextPageToken: "page2token",
169
- }),
170
- });
171
-
172
- // Second page
173
- mockFetch.mockResolvedValueOnce({
174
- ok: true,
175
- json: () =>
176
- Promise.resolve({
177
- items: [{ id: "i-row2", values: { "c-Name": "Item2" } }],
178
- }),
179
- });
180
-
181
- const rows = await provider.fetchTable("doc123", "grid-abc");
182
-
183
- expect(mockFetch).toHaveBeenCalledTimes(2);
184
- expect(rows).toHaveLength(2);
185
- });
186
-
187
- it("should normalize column names (strip c- prefix)", async () => {
188
- mockFetch.mockResolvedValueOnce({
189
- ok: true,
190
- json: () =>
191
- Promise.resolve({
192
- items: [
193
- {
194
- id: "i-row1",
195
- values: {
196
- "c-MyColumn": "value1",
197
- "c-Another Column": "value2",
198
- },
199
- },
200
- ],
201
- }),
202
- });
203
-
204
- const rows = await provider.fetchTable("doc", "grid");
205
-
206
- expect(rows[0]).toEqual({
207
- _codaId: "i-row1",
208
- MyColumn: "value1",
209
- "Another Column": "value2",
210
- });
211
- });
212
- });
213
-
214
- describe("fetchTableColumns", () => {
215
- it("should fetch column metadata for a table", async () => {
216
- const textFormat = { type: "text", isArray: false };
217
- const lookupFormat = { type: "lookup", isArray: false };
218
-
219
- const mockResponse = {
220
- items: [
221
- { id: "c-Name", name: "Name", format: textFormat },
222
- { id: "c-Version", name: "Version", format: textFormat },
223
- { id: "c-Tier", name: "Tier", format: lookupFormat },
224
- ],
225
- };
226
-
227
- mockFetch.mockResolvedValueOnce({
228
- ok: true,
229
- json: () => Promise.resolve(mockResponse),
230
- });
231
-
232
- const columns = await provider.fetchTableColumns("doc", "grid");
233
-
234
- expect(columns).toEqual([
235
- { id: "c-Name", name: "Name", type: "text", format: textFormat },
236
- { id: "c-Version", name: "Version", type: "text", format: textFormat },
237
- { id: "c-Tier", name: "Tier", type: "lookup", format: lookupFormat },
238
- ]);
239
- });
240
- });
9
+ const apiKey = "test-api-key";
10
+ let provider: CodaProvider;
11
+ let originalEnv: string | undefined;
12
+
13
+ beforeEach(() => {
14
+ originalEnv = process.env.CODA_API_KEY;
15
+ process.env.CODA_API_KEY = apiKey;
16
+ provider = new CodaProvider();
17
+ mockFetch.mockReset();
18
+ });
19
+
20
+ afterEach(() => {
21
+ process.env.CODA_API_KEY = originalEnv;
22
+ vi.restoreAllMocks();
23
+ });
24
+
25
+ describe("listTables", () => {
26
+ it("should fetch and return table metadata", async () => {
27
+ const mockResponse = {
28
+ items: [
29
+ {
30
+ id: "grid-abc123",
31
+ name: "Components",
32
+ displayColumn: { id: "c-1", name: "Name" },
33
+ },
34
+ {
35
+ id: "grid-def456",
36
+ name: "Tiers",
37
+ displayColumn: { id: "c-2", name: "Name" },
38
+ },
39
+ ],
40
+ };
41
+
42
+ mockFetch.mockResolvedValueOnce({
43
+ ok: true,
44
+ json: () => Promise.resolve(mockResponse),
45
+ });
46
+
47
+ const tables = await provider.listTables("dNyzE_TLZDh");
48
+
49
+ expect(mockFetch).toHaveBeenCalledWith(
50
+ "https://coda.io/apis/v1/docs/dNyzE_TLZDh/tables",
51
+ expect.objectContaining({
52
+ headers: expect.objectContaining({
53
+ Authorization: "Bearer test-api-key",
54
+ }),
55
+ }),
56
+ );
57
+
58
+ expect(tables).toEqual([
59
+ { id: "grid-abc123", name: "Components" },
60
+ { id: "grid-def456", name: "Tiers" },
61
+ ]);
62
+ });
63
+
64
+ it("should throw on API error", async () => {
65
+ mockFetch.mockResolvedValueOnce({
66
+ ok: false,
67
+ status: 401,
68
+ statusText: "Unauthorized",
69
+ });
70
+
71
+ await expect(provider.listTables("dNyzE_TLZDh")).rejects.toThrow(
72
+ "Coda API error: 401 Unauthorized",
73
+ );
74
+ });
75
+
76
+ it("should handle pagination", async () => {
77
+ // First page
78
+ mockFetch.mockResolvedValueOnce({
79
+ ok: true,
80
+ json: () =>
81
+ Promise.resolve({
82
+ items: [{ id: "grid-1", name: "Table1", displayColumn: null }],
83
+ nextPageToken: "token123",
84
+ }),
85
+ });
86
+
87
+ // Second page
88
+ mockFetch.mockResolvedValueOnce({
89
+ ok: true,
90
+ json: () =>
91
+ Promise.resolve({
92
+ items: [{ id: "grid-2", name: "Table2", displayColumn: null }],
93
+ }),
94
+ });
95
+
96
+ const tables = await provider.listTables("doc123");
97
+
98
+ expect(mockFetch).toHaveBeenCalledTimes(2);
99
+ expect(tables).toHaveLength(2);
100
+ expect(tables[1].id).toBe("grid-2");
101
+ });
102
+ });
103
+
104
+ describe("fetchTable", () => {
105
+ it("should fetch all rows from a table", async () => {
106
+ const mockResponse = {
107
+ items: [
108
+ {
109
+ id: "i-row1",
110
+ values: {
111
+ "c-Name": "Button",
112
+ "c-Description": "A clickable button",
113
+ "c-Version": "1.0.0",
114
+ },
115
+ },
116
+ {
117
+ id: "i-row2",
118
+ values: {
119
+ "c-Name": "Modal",
120
+ "c-Description": "A dialog overlay",
121
+ "c-Version": "2.0.0",
122
+ },
123
+ },
124
+ ],
125
+ };
126
+
127
+ mockFetch.mockResolvedValueOnce({
128
+ ok: true,
129
+ json: () => Promise.resolve(mockResponse),
130
+ });
131
+
132
+ const rows = await provider.fetchTable("dNyzE_TLZDh", "grid-abc123");
133
+
134
+ expect(mockFetch).toHaveBeenCalledWith(
135
+ expect.stringContaining(
136
+ "https://coda.io/apis/v1/docs/dNyzE_TLZDh/tables/grid-abc123/rows",
137
+ ),
138
+ expect.objectContaining({
139
+ headers: expect.objectContaining({
140
+ Authorization: "Bearer test-api-key",
141
+ }),
142
+ }),
143
+ );
144
+
145
+ expect(rows).toEqual([
146
+ {
147
+ _codaId: "i-row1",
148
+ Name: "Button",
149
+ Description: "A clickable button",
150
+ Version: "1.0.0",
151
+ },
152
+ {
153
+ _codaId: "i-row2",
154
+ Name: "Modal",
155
+ Description: "A dialog overlay",
156
+ Version: "2.0.0",
157
+ },
158
+ ]);
159
+ });
160
+
161
+ it("should handle pagination for large tables", async () => {
162
+ // First page
163
+ mockFetch.mockResolvedValueOnce({
164
+ ok: true,
165
+ json: () =>
166
+ Promise.resolve({
167
+ items: [{ id: "i-row1", values: { "c-Name": "Item1" } }],
168
+ nextPageToken: "page2token",
169
+ }),
170
+ });
171
+
172
+ // Second page
173
+ mockFetch.mockResolvedValueOnce({
174
+ ok: true,
175
+ json: () =>
176
+ Promise.resolve({
177
+ items: [{ id: "i-row2", values: { "c-Name": "Item2" } }],
178
+ }),
179
+ });
180
+
181
+ const rows = await provider.fetchTable("doc123", "grid-abc");
182
+
183
+ expect(mockFetch).toHaveBeenCalledTimes(2);
184
+ expect(rows).toHaveLength(2);
185
+ });
186
+
187
+ it("should normalize column names (strip c- prefix)", async () => {
188
+ mockFetch.mockResolvedValueOnce({
189
+ ok: true,
190
+ json: () =>
191
+ Promise.resolve({
192
+ items: [
193
+ {
194
+ id: "i-row1",
195
+ values: {
196
+ "c-MyColumn": "value1",
197
+ "c-Another Column": "value2",
198
+ },
199
+ },
200
+ ],
201
+ }),
202
+ });
203
+
204
+ const rows = await provider.fetchTable("doc", "grid");
205
+
206
+ expect(rows[0]).toEqual({
207
+ _codaId: "i-row1",
208
+ MyColumn: "value1",
209
+ "Another Column": "value2",
210
+ });
211
+ });
212
+ });
213
+
214
+ describe("fetchTableColumns", () => {
215
+ it("should fetch column metadata for a table", async () => {
216
+ const textFormat = { type: "text", isArray: false };
217
+ const lookupFormat = { type: "lookup", isArray: false };
218
+
219
+ const mockResponse = {
220
+ items: [
221
+ { id: "c-Name", name: "Name", format: textFormat },
222
+ { id: "c-Version", name: "Version", format: textFormat },
223
+ { id: "c-Tier", name: "Tier", format: lookupFormat },
224
+ ],
225
+ };
226
+
227
+ mockFetch.mockResolvedValueOnce({
228
+ ok: true,
229
+ json: () => Promise.resolve(mockResponse),
230
+ });
231
+
232
+ const columns = await provider.fetchTableColumns("doc", "grid");
233
+
234
+ expect(columns).toEqual([
235
+ { id: "c-Name", name: "Name", type: "text", format: textFormat },
236
+ { id: "c-Version", name: "Version", type: "text", format: textFormat },
237
+ { id: "c-Tier", name: "Tier", type: "lookup", format: lookupFormat },
238
+ ]);
239
+ });
240
+ });
241
241
  });