@cagov/ca-ds 0.0.0-stage → 1.0.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 (100) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +600 -2
  3. package/bin/ca-ds.js +5 -0
  4. package/package.json +62 -4
  5. package/src/cli/add.js +134 -0
  6. package/src/cli/build.js +15 -0
  7. package/src/cli/diff.js +39 -0
  8. package/src/cli/eject.js +112 -0
  9. package/src/cli/exit.js +22 -0
  10. package/src/cli/format.js +52 -0
  11. package/src/cli/init.js +148 -0
  12. package/src/cli/install.js +178 -0
  13. package/src/cli/items.js +10 -0
  14. package/src/cli/login.js +331 -0
  15. package/src/cli/main.js +108 -0
  16. package/src/cli/new.js +230 -0
  17. package/src/cli/outdated.js +74 -0
  18. package/src/cli/pack.js +75 -0
  19. package/src/cli/preview.js +31 -0
  20. package/src/cli/publish.js +295 -0
  21. package/src/cli/pull.js +208 -0
  22. package/src/cli/remote.js +52 -0
  23. package/src/cli/remove.js +69 -0
  24. package/src/cli/update.js +223 -0
  25. package/src/cli/validate.js +131 -0
  26. package/src/lib/browser.js +12 -0
  27. package/src/lib/build.js +249 -0
  28. package/src/lib/bundle.js +148 -0
  29. package/src/lib/catalog.js +44 -0
  30. package/src/lib/checks.js +31 -0
  31. package/src/lib/collection.js +65 -0
  32. package/src/lib/emblem.js +29 -0
  33. package/src/lib/fixtures.js +59 -0
  34. package/src/lib/floor.js +79 -0
  35. package/src/lib/glyph.js +148 -0
  36. package/src/lib/image.js +138 -0
  37. package/src/lib/json-text.js +213 -0
  38. package/src/lib/keys.js +322 -0
  39. package/src/lib/links.js +321 -0
  40. package/src/lib/markdown.js +408 -0
  41. package/src/lib/merge.js +93 -0
  42. package/src/lib/pack.js +30 -0
  43. package/src/lib/page-schema.js +368 -0
  44. package/src/lib/page.js +372 -0
  45. package/src/lib/patch.js +9 -0
  46. package/src/lib/regions.js +173 -0
  47. package/src/lib/registry.js +371 -0
  48. package/src/lib/release.js +119 -0
  49. package/src/lib/repoints.js +120 -0
  50. package/src/lib/resolve.js +32 -0
  51. package/src/lib/schema.js +28 -0
  52. package/src/lib/serial.js +4 -0
  53. package/src/lib/serialize.js +444 -0
  54. package/src/lib/structured.js +72 -0
  55. package/src/lib/system.js +13 -0
  56. package/src/lib/targets.js +85 -0
  57. package/src/lib/terms.js +11 -0
  58. package/src/lib/token-view.js +289 -0
  59. package/src/lib/tokens.js +247 -0
  60. package/src/lib/version.js +34 -0
  61. package/src/preview/frame.js +75 -0
  62. package/src/preview/pages.js +128 -0
  63. package/src/preview/preview.css +58 -0
  64. package/src/preview/screenshots.js +72 -0
  65. package/src/preview/server.js +378 -0
  66. package/src/preview/shell.js +153 -0
  67. package/src/schema/a11y.schema.json +56 -0
  68. package/src/schema/collection.lock.schema.json +58 -0
  69. package/src/schema/collection.schema.json +65 -0
  70. package/src/schema/composition.schema.json +98 -0
  71. package/src/schema/contract.schema.json +116 -0
  72. package/src/schema/interface.schema.json +257 -0
  73. package/src/schema/item.schema.json +362 -0
  74. package/src/schema/release.schema.json +39 -0
  75. package/src/schema/system.schema.json +75 -0
  76. package/src/schema/variants.schema.json +60 -0
  77. package/src/validate/collection.js +19 -0
  78. package/src/validate/collisions.js +124 -0
  79. package/src/validate/context.js +357 -0
  80. package/src/validate/facts.js +253 -0
  81. package/src/validate/files.js +103 -0
  82. package/src/validate/findings.js +19 -0
  83. package/src/validate/glyphs.js +126 -0
  84. package/src/validate/html.js +215 -0
  85. package/src/validate/imports.js +29 -0
  86. package/src/validate/index.js +75 -0
  87. package/src/validate/item.js +47 -0
  88. package/src/validate/links.js +113 -0
  89. package/src/validate/manifest.js +147 -0
  90. package/src/validate/media.js +65 -0
  91. package/src/validate/page.js +74 -0
  92. package/src/validate/prefixes.js +58 -0
  93. package/src/validate/relations.js +310 -0
  94. package/src/validate/release.js +109 -0
  95. package/src/validate/skill.js +122 -0
  96. package/src/validate/structured.js +335 -0
  97. package/src/validate/tasc.js +80 -0
  98. package/src/validate/template.js +129 -0
  99. package/src/validate/tokens.js +154 -0
  100. package/src/validate/zip.js +40 -0
@@ -0,0 +1,368 @@
1
+ // Resolved data, never read from the interfaces, so the package reads no item. A package test holds each
2
+ // entry to a subset of its item's interface. An entry left out on purpose names the rule or reason.
3
+ //
4
+ // A NODES entry: tag, slot, match (identity class), group, content (inline|text|empty|block|list-item, or
5
+ // parts [{ nodes|group, min = 1, max = 1, null for no limit }]), except, attrs [{ name, kind, required }]
6
+ // (kind: an array of values, or boolean|text|id|integer|url|media|blank), classes (groups, one class each),
7
+ // item, atom, viewOnly, mark, site.
8
+ // viewOnly attributes render as data-* in the editor's view, since the real one would change the view while
9
+ // it's edited.
10
+
11
+ const ROLES = [
12
+ 'ca-text-default',
13
+ 'ca-text-heading-0',
14
+ 'ca-text-heading-1',
15
+ 'ca-text-heading-2',
16
+ 'ca-text-heading-3',
17
+ 'ca-text-heading-4',
18
+ 'ca-text-heading-5',
19
+ 'ca-text-heading-6',
20
+ 'ca-text-content-large',
21
+ 'ca-text-content-default',
22
+ 'ca-text-content-small',
23
+ 'ca-text-caption-large',
24
+ 'ca-text-caption-default',
25
+ 'ca-text-caption-small',
26
+ 'ca-text-label-default',
27
+ 'ca-text-label-small',
28
+ ];
29
+ const ALIGN = ['ca-text-align-start', 'ca-text-align-center', 'ca-text-align-end', 'ca-text-align-justify'];
30
+ const TEXT_CLASSES = [ROLES, ['ca-lede'], ['ca-font-sans'], ['ca-font-weight-regular', 'ca-font-weight-medium', 'ca-font-weight-semibold'], ALIGN];
31
+
32
+ const WRAPPER_CLASSES = [['ca-prose'], ALIGN];
33
+
34
+ const BUTTON_CLASSES = [['ca-button-ghost', 'ca-button-subtle', 'ca-button-outline'], ['ca-button-soft']];
35
+
36
+ // icon.css's glyphs alone: a page carries no stylesheet to register another Material Symbols id.
37
+ const GLYPHS = [
38
+ 'menu',
39
+ 'menu_open',
40
+ 'search',
41
+ 'person',
42
+ 'expand_more',
43
+ 'vertical_align_top',
44
+ 'info',
45
+ 'check_circle',
46
+ 'warning',
47
+ 'report',
48
+ 'expand_circle_right',
49
+ 'close',
50
+ 'unfold_more',
51
+ 'arrow_upward',
52
+ 'arrow_downward',
53
+ 'arrow_forward',
54
+ 'chevron_left',
55
+ 'chevron_right',
56
+ 'first_page',
57
+ 'last_page',
58
+ 'account_balance',
59
+ 'lock',
60
+ ];
61
+
62
+ const integers = (from, to) => Array.from({ length: to - from + 1 }, (_, i) => String(from + i));
63
+
64
+ const CONTAINER_ATTRS = [
65
+ { name: 'align', kind: ['start', 'center', 'end'] },
66
+ { name: 'size', kind: ['small', 'medium', 'large', 'full'] },
67
+ { name: 'columns', kind: integers(1, 5) },
68
+ { name: 'grid', kind: 'boolean' },
69
+ { name: 'gap', kind: integers(0, 10) },
70
+ { name: 'gap-x', kind: integers(0, 10) },
71
+ { name: 'gap-y', kind: integers(0, 10) },
72
+ { name: 'bleed', kind: 'boolean' },
73
+ ];
74
+
75
+ const HEADING = (level) => ({ tag: `h${level}`, group: 'block', content: 'inline', attrs: [{ name: 'id', kind: 'id' }], classes: TEXT_CLASSES });
76
+ const WRAPPER = (tag) => ({ tag, group: 'block', content: 'block', classes: WRAPPER_CLASSES });
77
+
78
+ // Rendered by the docs site at request time, as text alone.
79
+ export const SERVER_VALUE = 'cads-value';
80
+ export const SERVER_VALUE_NAMES = ['component-count', 'tokens-count', 'template-count', 'guidance-count', 'skill-count', 'media-count', 'latest-release'];
81
+
82
+ export const SITE_ICONS = ['components', 'tokens', 'templates', 'guidance', 'skills', 'media', 'releases', 'bundles'].map((name) => `/icons/${name}.svg`);
83
+
84
+ export const NODES = {
85
+ // Marks, outermost first, so a link never splits.
86
+ link: {
87
+ tag: 'a',
88
+ group: 'inline',
89
+ mark: true,
90
+ content: 'inline',
91
+ attrs: [
92
+ { name: 'href', kind: 'url', required: true },
93
+ { name: 'data-card-target', kind: 'boolean' },
94
+ ],
95
+ },
96
+ strong: { tag: 'strong', group: 'inline', mark: true, content: 'inline' },
97
+ em: { tag: 'em', group: 'inline', mark: true, content: 'inline' },
98
+ code: { tag: 'code', group: 'inline', mark: true, content: 'inline' },
99
+ break: { tag: 'br', group: 'inline', content: 'empty' },
100
+
101
+ paragraph: { tag: 'p', group: 'block', content: 'inline', classes: TEXT_CLASSES },
102
+ h1: HEADING(1),
103
+ h2: HEADING(2),
104
+ h3: HEADING(3),
105
+ h4: HEADING(4),
106
+ h5: HEADING(5),
107
+ h6: HEADING(6),
108
+ 'bullet-list': { tag: 'ul', group: 'block', content: [{ nodes: ['list-item'], max: null }], attrs: [{ name: 'role', kind: ['list'] }] },
109
+ 'ordered-list': { tag: 'ol', group: 'block', content: [{ nodes: ['list-item'], max: null }], attrs: [{ name: 'start', kind: 'integer' }] },
110
+ 'list-item': { tag: 'li', content: 'list-item' },
111
+ blockquote: { tag: 'blockquote', group: 'block', content: 'block' },
112
+ div: WRAPPER('div'),
113
+ section: WRAPPER('section'),
114
+ article: WRAPPER('article'),
115
+ aside: WRAPPER('aside'),
116
+
117
+ // No srcset, so the page checklist's bare-image-sizes rule holds.
118
+ image: {
119
+ tag: 'img',
120
+ group: 'block',
121
+ content: 'empty',
122
+ atom: true,
123
+ attrs: [
124
+ { name: 'src', kind: 'media', required: true },
125
+ { name: 'alt', kind: 'text', required: true },
126
+ { name: 'width', kind: 'integer' },
127
+ { name: 'height', kind: 'integer' },
128
+ ],
129
+ },
130
+ figure: { tag: 'figure', group: 'block', content: [{ nodes: ['image'] }, { nodes: ['figcaption'], min: 0 }] },
131
+ figcaption: { tag: 'figcaption', content: 'inline', classes: TEXT_CLASSES },
132
+
133
+ divider: { tag: 'hr', group: 'block', content: 'empty', atom: true },
134
+
135
+ icon: {
136
+ tag: 'ca-icon',
137
+ group: 'inline',
138
+ content: 'empty',
139
+ atom: true,
140
+ item: 'standard/icon',
141
+ attrs: [
142
+ { name: 'name', kind: GLYPHS },
143
+ { name: 'size', kind: ['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'] },
144
+ { name: 'trim', kind: 'boolean' },
145
+ { name: 'role', kind: ['img'] },
146
+ { name: 'aria-label', kind: 'text' },
147
+ ],
148
+ },
149
+
150
+ // No disabled link, since a page's button links navigate: link-has-destination.
151
+ 'button-link': {
152
+ tag: 'a',
153
+ match: 'ca-button',
154
+ group: 'block',
155
+ content: 'inline',
156
+ except: ['link'],
157
+ item: 'standard/button',
158
+ attrs: [{ name: 'href', kind: 'url', required: true }],
159
+ classes: BUTTON_CLASSES,
160
+ },
161
+
162
+ // Inline presentations alone (sitewide-in-alert-row), no multiple or miscellaneous intent
163
+ // (multiple-sitewide-only, intent-settled), and no revealed, which the script sets.
164
+ alert: {
165
+ tag: 'ca-alert',
166
+ group: 'block',
167
+ item: 'standard/alert',
168
+ attrs: [
169
+ { name: 'presentation', kind: ['inline-content', 'inline-form'], required: true },
170
+ { name: 'intent', kind: ['information', 'success', 'warning', 'error'], required: true },
171
+ { name: 'dismissible', kind: 'boolean' },
172
+ { name: 'data-alert-key', kind: 'text' },
173
+ { name: 'id', kind: 'id' },
174
+ ],
175
+ // A dismissible alert starts hidden, and the script would add its button to the view.
176
+ viewOnly: ['dismissible'],
177
+ content: [{ nodes: ['alert-icon'] }, { nodes: ['alert-title'] }, { nodes: ['alert-body-paragraph', 'alert-body-list'], min: 0 }, { nodes: ['alert-dismiss'], min: 0 }],
178
+ },
179
+ 'alert-icon': { tag: 'ca-icon', slot: 'alert-icon', content: 'empty', atom: true, item: 'standard/icon' },
180
+ 'alert-title': { tag: 'p', slot: 'alert-title', content: 'inline', item: 'standard/alert' },
181
+ 'alert-body-paragraph': { tag: 'p', slot: 'alert-body', content: 'inline', item: 'standard/alert' },
182
+ 'alert-body-list': { tag: 'ul', slot: 'alert-body', content: [{ nodes: ['list-item'], max: null }], item: 'standard/alert' },
183
+ 'alert-dismiss': {
184
+ tag: 'button',
185
+ slot: 'alert-dismiss',
186
+ atom: true,
187
+ item: 'standard/alert',
188
+ attrs: [{ name: 'type', kind: ['button'], required: true }],
189
+ content: [{ nodes: ['dismiss-icon'] }, { nodes: ['hidden-label'] }],
190
+ },
191
+ 'dismiss-icon': { tag: 'ca-icon', content: 'empty', item: 'standard/icon', attrs: [{ name: 'name', kind: ['close'], required: true }] },
192
+ 'hidden-label': { tag: 'span', match: 'ca-visually-hidden', content: 'text', item: 'standard/visually-hidden' },
193
+
194
+ accordion: {
195
+ tag: 'ca-accordion',
196
+ group: 'block',
197
+ item: 'standard/accordion',
198
+ attrs: [{ name: 'surface', kind: ['outlined', 'shaded'] }],
199
+ content: [{ nodes: ['accordion-item'], max: null }],
200
+ },
201
+ 'accordion-item': {
202
+ tag: 'details',
203
+ item: 'standard/accordion',
204
+ attrs: [
205
+ { name: 'name', kind: 'text' },
206
+ { name: 'open', kind: 'boolean' },
207
+ ],
208
+ // A named group closes its siblings, so the view holds every item open.
209
+ viewOnly: ['name', 'open'],
210
+ content: [{ nodes: ['accordion-summary'] }, { group: 'block', max: null, except: ['accordion'] }],
211
+ },
212
+ 'accordion-summary': { tag: 'summary', content: 'text', item: 'standard/accordion' },
213
+
214
+ card: {
215
+ tag: 'ca-card',
216
+ group: 'block',
217
+ item: 'standard/card',
218
+ attrs: [
219
+ { name: 'surface', kind: ['tinted', 'outlined', 'bare', 'promo', 'promo-inverse'] },
220
+ { name: 'elevated', kind: 'boolean' },
221
+ { name: 'orientation', kind: ['vertical', 'horizontal'] },
222
+ { name: 'media', kind: ['bleed', 'inset'] },
223
+ { name: 'media-fit', kind: ['cover', 'contain', 'fill'] },
224
+ { name: 'interactive', kind: 'boolean' },
225
+ ],
226
+ content: [{ nodes: ['card-media'], min: 0 }, { nodes: ['card-content'] }, { nodes: ['card-footer-link', 'card-footer-button', 'card-footer-indicator'], min: 0 }],
227
+ },
228
+ 'card-media': {
229
+ tag: 'img',
230
+ slot: 'card-media',
231
+ content: 'empty',
232
+ atom: true,
233
+ item: 'standard/card',
234
+ attrs: [
235
+ { name: 'src', kind: 'media', required: true },
236
+ { name: 'alt', kind: 'text', required: true },
237
+ ],
238
+ },
239
+ 'card-content': { tag: 'div', slot: 'card-content', content: [{ nodes: ['site-icon'], min: 0 }, { group: 'block', max: null, except: ['card'] }], item: 'standard/card' },
240
+ // Decorative, since the card's title names the thing.
241
+ 'site-icon': {
242
+ tag: 'img',
243
+ match: 'card-icon',
244
+ content: 'empty',
245
+ atom: true,
246
+ site: true,
247
+ attrs: [
248
+ { name: 'src', kind: SITE_ICONS, required: true },
249
+ { name: 'width', kind: 'integer' },
250
+ { name: 'height', kind: 'integer' },
251
+ { name: 'alt', kind: 'blank', required: true },
252
+ ],
253
+ },
254
+ 'card-footer-link': { tag: 'a', slot: 'card-footer', content: 'inline', except: ['link'], item: 'standard/card', attrs: [{ name: 'href', kind: 'url', required: true }] },
255
+ 'card-footer-button': {
256
+ tag: 'a',
257
+ slot: 'card-footer',
258
+ match: 'ca-button',
259
+ content: 'inline',
260
+ except: ['link'],
261
+ item: 'standard/button',
262
+ attrs: [{ name: 'href', kind: 'url', required: true }],
263
+ classes: BUTTON_CLASSES,
264
+ },
265
+ 'card-footer-indicator': { tag: 'div', slot: 'card-footer', atom: true, item: 'standard/card', content: [{ nodes: ['indicator-icon'] }, { nodes: ['indicator-label'], min: 0 }] },
266
+ 'indicator-icon': { tag: 'ca-icon', content: 'empty', item: 'standard/icon' },
267
+ 'indicator-label': { tag: 'span', content: 'text', item: 'standard/card' },
268
+
269
+ // No .ca-table-stacked, which needs a role on every part and a data-label on every cell, and no
270
+ // <ca-enhanced-table>, which sorts and expands by script.
271
+ 'table-scroll': {
272
+ tag: 'ca-table-scroll',
273
+ group: 'block',
274
+ item: 'standard/table',
275
+ attrs: [{ name: 'sticky-header', kind: 'boolean' }],
276
+ content: [{ nodes: ['table'] }],
277
+ },
278
+ table: {
279
+ tag: 'table',
280
+ group: 'block',
281
+ classes: [['ca-table-banded'], ['ca-table-divided'], ['ca-table-bordered'], ['ca-table-hover']],
282
+ content: [{ nodes: ['caption'] }, { nodes: ['table-head'], min: 0 }, { nodes: ['table-body'], max: null }, { nodes: ['table-foot'], min: 0 }],
283
+ },
284
+ caption: { tag: 'caption', content: 'inline' },
285
+ 'table-head': { tag: 'thead', content: [{ nodes: ['row'], max: null }] },
286
+ 'table-body': { tag: 'tbody', content: [{ nodes: ['row'], max: null }] },
287
+ 'table-foot': { tag: 'tfoot', content: [{ nodes: ['row'], max: null }] },
288
+ row: { tag: 'tr', content: [{ nodes: ['header-cell', 'cell'], max: null }] },
289
+ 'header-cell': {
290
+ tag: 'th',
291
+ content: 'inline',
292
+ classes: [ALIGN],
293
+ attrs: [
294
+ { name: 'scope', kind: ['col', 'colgroup', 'row', 'rowgroup'], required: true },
295
+ { name: 'colspan', kind: 'integer' },
296
+ { name: 'rowspan', kind: 'integer' },
297
+ ],
298
+ },
299
+ cell: {
300
+ tag: 'td',
301
+ content: 'inline',
302
+ classes: [ALIGN],
303
+ attrs: [
304
+ { name: 'colspan', kind: 'integer' },
305
+ { name: 'rowspan', kind: 'integer' },
306
+ ],
307
+ },
308
+
309
+ container: {
310
+ tag: 'ca-container',
311
+ group: 'block',
312
+ item: 'standard/container',
313
+ attrs: CONTAINER_ATTRS,
314
+ content: 'block',
315
+ },
316
+
317
+ // No group, since TOP alone holds it. No untreated overlay, whose rule asks for a contrast measurement.
318
+ hero: {
319
+ tag: 'ca-hero',
320
+ item: 'standard/hero',
321
+ attrs: [
322
+ { name: 'treatment', kind: ['plain', 'image', 'split'] },
323
+ { name: 'overlay', kind: ['scrim', 'box', 'glass', 'glass-inverse'] },
324
+ ],
325
+ content: [{ nodes: ['hero-image'], min: 0 }, { nodes: ['hero-content'] }],
326
+ },
327
+ 'hero-image': {
328
+ tag: 'img',
329
+ slot: 'hero-image',
330
+ content: 'empty',
331
+ atom: true,
332
+ item: 'standard/hero',
333
+ attrs: [
334
+ { name: 'src', kind: 'media', required: true },
335
+ { name: 'alt', kind: 'blank', required: true },
336
+ ],
337
+ },
338
+ 'hero-content': {
339
+ tag: 'div',
340
+ slot: 'hero-content',
341
+ item: 'standard/hero',
342
+ classes: [['ca-prose']],
343
+ content: [{ nodes: ['h1'] }, { nodes: ['paragraph'], min: 0 }, { nodes: ['button-link'], min: 0 }],
344
+ },
345
+
346
+ // The shell keeps the footer's branding and attribution line.
347
+ 'footer-links': {
348
+ tag: 'nav',
349
+ match: 'ca-footer-links',
350
+ group: 'block',
351
+ item: 'standard/footer',
352
+ attrs: [{ name: 'aria-label', kind: 'text', required: true }],
353
+ content: 'block',
354
+ },
355
+ 'footer-group': { tag: 'div', match: 'ca-footer-group', group: 'block', item: 'standard/footer', content: 'block' },
356
+ 'footer-legal': { tag: 'div', match: 'ca-footer-legal', group: 'block', item: 'standard/footer', content: 'block' },
357
+
358
+ 'server-value': {
359
+ tag: SERVER_VALUE,
360
+ group: 'inline',
361
+ content: 'empty',
362
+ atom: true,
363
+ site: true,
364
+ attrs: [{ name: 'name', kind: SERVER_VALUE_NAMES, required: true }],
365
+ },
366
+ };
367
+
368
+ export const TOP = [{ nodes: ['hero'], min: 0 }, { group: 'block', min: 0, max: null }];