@canonical/design-system 0.1.0 → 0.1.1
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/.gemini/settings.json +14 -0
- package/.github/ISSUE_TEMPLATE/propose-changes-to-existing-ui-block.md +14 -0
- package/.github/ISSUE_TEMPLATE/propose-new-ui-block.md +26 -0
- package/.github/workflows/sync-coda-manual.yml +12 -0
- package/.github/workflows/sync-coda-scheduled.yml +13 -0
- package/.github/workflows/sync-coda.yml +38 -0
- package/.mcp.json +8 -2
- package/GEMINI.md +2 -0
- package/README.md +71 -51
- package/data/apps/component/file_tree.ttl +6 -7
- package/data/apps/component/key_value_pair.ttl +6 -7
- package/data/apps/component/navigation.ttl +6 -7
- package/data/apps/component/notification.ttl +7 -0
- package/data/apps/component/skeleton_loading.ttl +6 -7
- package/data/apps/component/status_bar.ttl +6 -7
- package/data/apps/component/toolbar.ttl +6 -7
- package/data/apps/group/notifications.ttl +7 -0
- package/data/apps/layout/application_layout.ttl +8 -7
- package/data/apps/layout/content_layout.ttl +9 -0
- package/data/apps/layout/empty_layout.ttl +6 -7
- package/data/apps/layout/list_page_layout.ttl +6 -7
- package/data/apps/layout/settings_page_layout.ttl +6 -7
- package/data/apps/layout/view_layout.ttl +9 -0
- package/data/apps/pattern/code_diff.ttl +6 -7
- package/data/apps/pattern/data_table.ttl +6 -7
- package/data/apps/pattern/destructive_modal.ttl +6 -7
- package/data/apps/pattern/key_value_summary.ttl +6 -7
- package/data/apps/pattern/keyboard_shortcuts.ttl +6 -7
- package/data/apps/pattern/notification_center.ttl +6 -7
- package/data/apps/pattern/side_panel.ttl +6 -7
- package/data/apps/pattern/sidepanel_stacked.ttl +6 -7
- package/data/apps/subcomponent/file_tree-node.ttl +7 -0
- package/data/apps.ttl +3 -4
- package/data/apps_anbox/component/copy_to_clipboard.ttl +7 -0
- package/data/apps_anbox/pattern/side_menu.ttl +13 -0
- package/data/apps_anbox.ttl +4 -0
- package/data/apps_juju/pattern/single_select_multi_layered.ttl +7 -0
- package/data/apps_juju.ttl +4 -0
- package/data/apps_landscape/component/password_constraints.ttl +32 -0
- package/data/apps_landscape.ttl +4 -0
- package/data/apps_launchpad/component/badge.ttl +22 -0
- package/data/apps_launchpad/component/breadcrumbs.ttl +14 -0
- package/data/apps_launchpad/component/button.ttl +34 -0
- package/data/apps_launchpad/component/checkbox.ttl +28 -0
- package/data/apps_launchpad/component/chip.ttl +42 -0
- package/data/apps_launchpad/component/combobox.ttl +51 -0
- package/data/apps_launchpad/component/description_list.ttl +13 -0
- package/data/apps_launchpad/component/radio.ttl +34 -0
- package/data/apps_launchpad/component/select.ttl +34 -0
- package/data/apps_launchpad/component/switch.ttl +21 -0
- package/data/apps_launchpad/component/text_input.ttl +35 -0
- package/data/apps_launchpad/component/textarea.ttl +35 -0
- package/data/apps_launchpad/component/tooltip.ttl +27 -0
- package/data/apps_launchpad/component/user_avatar.ttl +25 -0
- package/data/apps_launchpad/subcomponent/combobox-checkbox_option.ttl +29 -0
- package/data/apps_launchpad/subcomponent/combobox-footer.ttl +13 -0
- package/data/apps_launchpad/subcomponent/combobox-group.ttl +20 -0
- package/data/apps_launchpad/subcomponent/combobox-helper.ttl +19 -0
- package/data/apps_launchpad/subcomponent/combobox-loading.ttl +13 -0
- package/data/apps_launchpad/subcomponent/combobox-no_results.ttl +13 -0
- package/data/apps_launchpad/subcomponent/combobox-radio_option.ttl +29 -0
- package/data/apps_launchpad/subcomponent/combobox-search.ttl +22 -0
- package/data/apps_launchpad/subcomponent/description_list-item.ttl +19 -0
- package/data/apps_launchpad.ttl +4 -0
- package/data/apps_lxd/component/confirmation_checkbox.ttl +7 -0
- package/data/apps_lxd/component/copy_to_clipboard.ttl +7 -0
- package/data/apps_lxd/view/network_topology.ttl +7 -0
- package/data/apps_lxd.ttl +4 -0
- package/data/apps_portal/component/badge.ttl +7 -0
- package/data/apps_portal.ttl +4 -0
- package/data/apps_workplace/component/label-highlight.ttl +7 -0
- package/data/apps_workplace.ttl +4 -0
- package/data/apps_wpe.ttl +3 -4
- package/data/documentation/layout/documentation_layout.ttl +6 -7
- package/data/documentation/pattern/library_side_navigation.ttl +7 -0
- package/data/documentation.ttl +3 -4
- package/data/global/component/accordion.ttl +11 -12
- package/data/global/component/announcement.ttl +6 -7
- package/data/global/component/badge.ttl +7 -8
- package/data/global/component/breadcrumbs.ttl +13 -0
- package/data/global/component/button.ttl +27 -17
- package/data/global/component/button_link.ttl +7 -0
- package/data/global/component/card.ttl +6 -7
- package/data/global/component/chip.ttl +6 -7
- package/data/global/component/code.ttl +7 -0
- package/data/global/component/code_snippet-content.ttl +7 -0
- package/data/global/component/code_snippet-header.ttl +7 -0
- package/data/global/component/code_snippet.ttl +6 -7
- package/data/global/component/contextual_menu.ttl +6 -7
- package/data/global/component/heading.ttl +11 -12
- package/data/global/component/icon.ttl +12 -12
- package/data/global/component/icon_in_container.ttl +6 -7
- package/data/global/component/keyboard_key.ttl +6 -7
- package/data/global/component/label.ttl +12 -13
- package/data/global/component/notification_inline.ttl +6 -7
- package/data/global/component/notification_toast.ttl +6 -7
- package/data/global/component/pagination.ttl +6 -7
- package/data/global/component/popover.ttl +6 -7
- package/data/global/component/rich_text_editor.ttl +6 -7
- package/data/global/component/search_bar.ttl +6 -7
- package/data/global/component/table.ttl +6 -7
- package/data/global/component/tabs.ttl +6 -7
- package/data/global/component/theme_switcher.ttl +6 -7
- package/data/global/component/tile.ttl +11 -12
- package/data/global/component/tooltip.ttl +182 -7
- package/data/global/group/buttons.ttl +6 -7
- package/data/global/group/cards.ttl +6 -7
- package/data/global/group/code_snippets.ttl +7 -0
- package/data/global/group/keyboard_keys.ttl +7 -0
- package/data/global/group/tiles.ttl +6 -7
- package/data/global/layout/error_layout.ttl +6 -7
- package/data/global/layout/form_layout.ttl +6 -7
- package/data/global/layout/identity_page_form.ttl +6 -7
- package/data/global/modifier/alpha.ttl +5 -5
- package/data/global/modifier/beta.ttl +5 -5
- package/data/global/modifier/caution.ttl +5 -5
- package/data/global/modifier/comfortable.ttl +5 -5
- package/data/global/modifier/completed.ttl +5 -5
- package/data/global/modifier/constructive.ttl +5 -5
- package/data/global/modifier/dark.ttl +5 -5
- package/data/global/modifier/dense.ttl +5 -5
- package/data/global/modifier/destructive.ttl +5 -5
- package/data/global/modifier/editable.ttl +5 -5
- package/data/global/modifier/elevated.ttl +5 -5
- package/data/global/modifier/error.ttl +5 -5
- package/data/global/modifier/experimental.ttl +5 -5
- package/data/global/modifier/failed.ttl +5 -5
- package/data/global/modifier/focused.ttl +5 -5
- package/data/global/modifier/highlighted.ttl +5 -5
- package/data/global/modifier/in_progress.ttl +5 -5
- package/data/global/modifier/information.ttl +5 -5
- package/data/global/modifier/light.ttl +5 -5
- package/data/global/modifier/loading.ttl +5 -5
- package/data/global/modifier/muted.ttl +5 -5
- package/data/global/modifier/paper.ttl +5 -5
- package/data/global/modifier/planned.ttl +5 -5
- package/data/global/modifier/primary.ttl +5 -5
- package/data/global/modifier/secondary.ttl +5 -5
- package/data/global/modifier/stable.ttl +5 -5
- package/data/global/modifier/success.ttl +5 -5
- package/data/global/modifier/tertiary.ttl +5 -5
- package/data/global/modifier/warning.ttl +5 -5
- package/data/global/modifier/wireframe.ttl +5 -5
- package/data/global/modifier_family/_color_luminosity.ttl +5 -6
- package/data/global/modifier_family/_emphasis.ttl +5 -6
- package/data/global/modifier_family/_other.ttl +5 -6
- package/data/global/modifier_family/anticipation.ttl +5 -6
- package/data/global/modifier_family/criticality.ttl +5 -6
- package/data/global/modifier_family/density.ttl +5 -6
- package/data/global/modifier_family/importance.ttl +5 -6
- package/data/global/modifier_family/lifecycle.ttl +5 -6
- package/data/global/modifier_family/release.ttl +5 -6
- package/data/global/pattern/dropdown_button.ttl +7 -0
- package/data/global/pattern/info_table.ttl +6 -7
- package/data/global/pattern/modal.ttl +6 -7
- package/data/global/pattern/navigation.ttl +6 -7
- package/data/global/pattern/stepper.ttl +6 -7
- package/data/global/pattern/table_of_contents.ttl +6 -7
- package/data/global/pattern/timeline.ttl +60 -12
- package/data/global/subcomponent/accordion-item.ttl +15 -16
- package/data/global/subcomponent/breadcrumbs-item.ttl +15 -16
- package/data/global/subcomponent/card-content.ttl +11 -12
- package/data/global/subcomponent/card-header.ttl +11 -12
- package/data/global/subcomponent/card-image.ttl +16 -17
- package/data/global/subcomponent/card-thumbnail.ttl +7 -0
- package/data/global/subcomponent/divider.ttl +6 -7
- package/data/global/subcomponent/modal-content.ttl +6 -7
- package/data/global/subcomponent/modal-footer.ttl +6 -7
- package/data/global/subcomponent/modal-header.ttl +6 -7
- package/data/global/subcomponent/spinner.ttl +6 -7
- package/data/global/subcomponent/table-cell.ttl +6 -7
- package/data/global/subcomponent/table-row.ttl +6 -7
- package/data/global/subcomponent/tile-content.ttl +11 -12
- package/data/global/subcomponent/tile-header.ttl +11 -12
- package/data/global/subcomponent/timeline-content.ttl +11 -12
- package/data/global/subcomponent/timeline-event.ttl +42 -27
- package/data/global/subcomponent/timeline-expansion_indicator.ttl +7 -0
- package/data/global/subcomponent/timeline-header.ttl +6 -7
- package/data/global/view/settings_view.ttl +7 -0
- package/data/global.ttl +3 -4
- package/data/global_form/component/checkbox_input.ttl +6 -7
- package/data/global_form/component/choices_input.ttl +6 -7
- package/data/global_form/component/combobox_input.ttl +6 -7
- package/data/global_form/component/custom_choices_input.ttl +6 -7
- package/data/global_form/component/datepicker_input.ttl +6 -7
- package/data/global_form/component/rating_input.ttl +6 -7
- package/data/global_form/component/rich_text_input.ttl +7 -0
- package/data/global_form/component/segmented_control_input.ttl +6 -7
- package/data/global_form/component/slider_input.ttl +6 -7
- package/data/global_form/component/switch_input.ttl +6 -7
- package/data/global_form/component/text_input.ttl +6 -7
- package/data/global_form/component/textarea_input.ttl +6 -7
- package/data/global_form/component/wysiwginput.ttl +6 -7
- package/data/global_form/pattern/field.ttl +6 -7
- package/data/global_form/pattern/form.ttl +6 -7
- package/data/global_form/subcomponent/field-description.ttl +6 -7
- package/data/global_form/subcomponent/field-label.ttl +6 -7
- package/data/global_form.ttl +3 -4
- package/data/site/component/blog_card.ttl +7 -0
- package/data/site/component/quote.ttl +6 -7
- package/data/site/component/rule.ttl +6 -7
- package/data/site/component/section.ttl +6 -7
- package/data/site/group/blog_cards.ttl +7 -0
- package/data/site/layout/blog_page_layout.ttl +7 -0
- package/data/site/layout/case_study_layout.ttl +7 -0
- package/data/site/layout/site_layout.ttl +6 -7
- package/data/site/pattern/hero-github.ttl +6 -7
- package/data/site/pattern/hero.ttl +6 -7
- package/data/site/pattern/info_table.ttl +6 -7
- package/data/site/pattern/pricing_section.ttl +7 -0
- package/data/site/pattern/pricing_table.ttl +7 -0
- package/data/site/pattern/read_more_section.ttl +7 -0
- package/data/site/pattern/skip_link.ttl +6 -7
- package/data/site.ttl +3 -4
- package/data/sites_webcomponentsprototype/component/blog_cards.ttl +7 -0
- package/data/sites_webcomponentsprototype/component/ctablock.ttl +7 -0
- package/data/sites_webcomponentsprototype/component/list.ttl +7 -0
- package/data/sites_webcomponentsprototype/component/tabs.ttl +7 -0
- package/data/sites_webcomponentsprototype/layout/site_layout.ttl +8 -0
- package/data/sites_webcomponentsprototype/pattern/basic_section.ttl +7 -0
- package/data/sites_webcomponentsprototype/pattern/blog_section.ttl +7 -0
- package/data/sites_webcomponentsprototype/pattern/ctasection.ttl +7 -0
- package/data/sites_webcomponentsprototype/pattern/equal_heights.ttl +7 -0
- package/data/sites_webcomponentsprototype/pattern/hero.ttl +7 -0
- package/data/sites_webcomponentsprototype/pattern/logo_section.ttl +7 -0
- package/data/sites_webcomponentsprototype/pattern/quote_wrapper.ttl +7 -0
- package/data/sites_webcomponentsprototype/pattern/tiered_list.ttl +7 -0
- package/data/sites_webcomponentsprototype.ttl +4 -0
- package/data/stores.ttl +3 -4
- package/definitions/ontology.ttl +39 -25
- package/package.json +8 -8
- package/skills/anatomy-author/SKILL.md +9 -9
- package/skills/component-specifier/SKILL.md +81 -85
- package/skills/design-auditor/SKILL.md +45 -45
- package/source.json +35 -33
- package/src/collect/generateTurtle.tests.ts +21 -38
- package/src/commands/transform.ts +27 -3
- package/src/config/source.schema.json +9 -0
- package/src/config/types.ts +7 -0
- package/src/constants.ts +6 -7
- package/src/graph/GraphStore.tests.ts +23 -23
- package/src/graph/GraphStore.ts +2 -2
- package/src/graph/PrefixMap.tests.ts +16 -16
- package/src/graph/PrefixMap.ts +1 -1
- package/src/graph/buildUri.tests.ts +26 -13
- package/src/graph/buildUri.ts +17 -5
- package/src/serializers/JSONSerializer.tests.ts +2 -5
- package/src/serializers/TTLSerializer.tests.ts +2 -4
- package/src/serializers/TTLSerializer.ts +2 -2
- package/src/transform/resolveReferences.tests.ts +2 -2
- package/src/transform/transform.tests.ts +5 -7
- package/src/transform/transform.ts +3 -1
- package/src/transform/transformRow.tests.ts +149 -50
- package/src/transform/transformRow.ts +27 -3
- package/data/global/component/link.ttl +0 -8
- package/data/global/pattern/breadcrumbs.ttl +0 -14
- package/data/global/pattern/select_button.ttl +0 -8
- package/data/global/subcomponent/timeline-footer.ttl +0 -8
- package/session/A.DSL.md +0 -429
- package/session/B.NOTES.md +0 -84
- package/session/global.component.accordion.yaml +0 -13
- package/session/global.component.button.yaml +0 -26
- package/session/global.component.card.yaml +0 -24
- package/session/global.component.icon.yaml +0 -7
- package/session/global.component.label.yaml +0 -7
- package/session/global.component.tile.yaml +0 -21
- package/session/global.component.timeline.yaml +0 -20
- package/session/global.pattern.breadcrumbs.yaml +0 -13
- package/session/global.subcomponent.accordion-item.yaml +0 -37
- package/session/global.subcomponent.breadcrumbs-item.yaml +0 -21
- package/session/global.subcomponent.card-content.yaml +0 -7
- package/session/global.subcomponent.card-header.yaml +0 -22
- package/session/global.subcomponent.card-image.yaml +0 -7
- package/session/global.subcomponent.tile-content.yaml +0 -7
- package/session/global.subcomponent.tile-header.yaml +0 -8
- package/session/global.subcomponent.timeline-content.yaml +0 -13
- package/session/global.subcomponent.timeline-event.yaml +0 -20
- package/session/global.subcomponent.timeline-footer.yaml +0 -9
- package/session/global.subcomponent.timeline-header.yaml +0 -18
|
@@ -6,21 +6,21 @@ import type { ReferenceMap } from "./types.js";
|
|
|
6
6
|
|
|
7
7
|
const buttonUri = `${NAMESPACES.ds}global:component:button`;
|
|
8
8
|
const globalUri = `${NAMESPACES.ds}global`;
|
|
9
|
-
const componentType = `${NAMESPACES.
|
|
9
|
+
const componentType = `${NAMESPACES.ds}Component`;
|
|
10
10
|
|
|
11
11
|
describe("transformRow", () => {
|
|
12
12
|
it("should add type quad from class config", () => {
|
|
13
13
|
const store = new GraphStore();
|
|
14
14
|
const prefixes = new PrefixMap();
|
|
15
|
-
prefixes.add("
|
|
15
|
+
prefixes.add("ds", NAMESPACES.ds);
|
|
16
16
|
|
|
17
17
|
const row = { name: "Button", uri: buttonUri };
|
|
18
18
|
const config = {
|
|
19
19
|
"@context": {
|
|
20
|
-
|
|
21
|
-
name: "
|
|
20
|
+
ds: NAMESPACES.ds,
|
|
21
|
+
name: "ds:name",
|
|
22
22
|
},
|
|
23
|
-
class: "
|
|
23
|
+
class: "ds:Component",
|
|
24
24
|
uriTemplate: "{uri}",
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -35,16 +35,16 @@ describe("transformRow", () => {
|
|
|
35
35
|
it("should add literal properties", () => {
|
|
36
36
|
const store = new GraphStore();
|
|
37
37
|
const prefixes = new PrefixMap();
|
|
38
|
-
prefixes.add("
|
|
38
|
+
prefixes.add("ds", NAMESPACES.ds);
|
|
39
39
|
|
|
40
40
|
const row = { name: "Button", description: "A clickable button", uri: buttonUri };
|
|
41
41
|
const config = {
|
|
42
42
|
"@context": {
|
|
43
|
-
|
|
44
|
-
name: "
|
|
45
|
-
description: "
|
|
43
|
+
ds: NAMESPACES.ds,
|
|
44
|
+
name: "ds:name",
|
|
45
|
+
description: "ds:summary",
|
|
46
46
|
},
|
|
47
|
-
class: "
|
|
47
|
+
class: "ds:Component",
|
|
48
48
|
uriTemplate: "{uri}",
|
|
49
49
|
};
|
|
50
50
|
|
|
@@ -58,7 +58,6 @@ describe("transformRow", () => {
|
|
|
58
58
|
it("should resolve reference properties to URIs", () => {
|
|
59
59
|
const store = new GraphStore();
|
|
60
60
|
const prefixes = new PrefixMap();
|
|
61
|
-
prefixes.add("dso", NAMESPACES.dso);
|
|
62
61
|
prefixes.add("ds", NAMESPACES.ds);
|
|
63
62
|
|
|
64
63
|
const refMap: ReferenceMap = new Map([
|
|
@@ -68,12 +67,11 @@ describe("transformRow", () => {
|
|
|
68
67
|
const row = { name: "Button", tier: "Global", uri: buttonUri };
|
|
69
68
|
const config = {
|
|
70
69
|
"@context": {
|
|
71
|
-
dso: NAMESPACES.dso,
|
|
72
70
|
ds: NAMESPACES.ds,
|
|
73
|
-
name: "
|
|
74
|
-
tier: { "@id": "
|
|
71
|
+
name: "ds:name",
|
|
72
|
+
tier: { "@id": "ds:tier", "@type": "@id" },
|
|
75
73
|
},
|
|
76
|
-
class: "
|
|
74
|
+
class: "ds:Component",
|
|
77
75
|
uriTemplate: "{uri}",
|
|
78
76
|
};
|
|
79
77
|
|
|
@@ -87,46 +85,46 @@ describe("transformRow", () => {
|
|
|
87
85
|
it("should skip null/undefined values", () => {
|
|
88
86
|
const store = new GraphStore();
|
|
89
87
|
const prefixes = new PrefixMap();
|
|
90
|
-
prefixes.add("
|
|
88
|
+
prefixes.add("ds", NAMESPACES.ds);
|
|
91
89
|
|
|
92
90
|
const row = { name: "Button", description: null, uri: buttonUri };
|
|
93
91
|
const config = {
|
|
94
92
|
"@context": {
|
|
95
|
-
|
|
96
|
-
name: "
|
|
97
|
-
description: "
|
|
93
|
+
ds: NAMESPACES.ds,
|
|
94
|
+
name: "ds:name",
|
|
95
|
+
description: "ds:summary",
|
|
98
96
|
},
|
|
99
|
-
class: "
|
|
97
|
+
class: "ds:Component",
|
|
100
98
|
uriTemplate: "{uri}",
|
|
101
99
|
};
|
|
102
100
|
|
|
103
101
|
transformRow(row, config, store, prefixes, new Map());
|
|
104
102
|
|
|
105
103
|
const quads = store.getQuads();
|
|
106
|
-
const descQuad = quads.find((q) => q.predicate.value === PREDICATES.
|
|
104
|
+
const descQuad = quads.find((q) => q.predicate.value === PREDICATES.summary);
|
|
107
105
|
expect(descQuad).toBeUndefined();
|
|
108
106
|
});
|
|
109
107
|
|
|
110
108
|
it("should add empty string literals", () => {
|
|
111
109
|
const store = new GraphStore();
|
|
112
110
|
const prefixes = new PrefixMap();
|
|
113
|
-
prefixes.add("
|
|
111
|
+
prefixes.add("ds", NAMESPACES.ds);
|
|
114
112
|
|
|
115
113
|
const row = { name: "Button", description: "", uri: buttonUri };
|
|
116
114
|
const config = {
|
|
117
115
|
"@context": {
|
|
118
|
-
|
|
119
|
-
name: "
|
|
120
|
-
description: "
|
|
116
|
+
ds: NAMESPACES.ds,
|
|
117
|
+
name: "ds:name",
|
|
118
|
+
description: "ds:summary",
|
|
121
119
|
},
|
|
122
|
-
class: "
|
|
120
|
+
class: "ds:Component",
|
|
123
121
|
uriTemplate: "{uri}",
|
|
124
122
|
};
|
|
125
123
|
|
|
126
124
|
transformRow(row, config, store, prefixes, new Map());
|
|
127
125
|
|
|
128
126
|
const quads = store.getQuads();
|
|
129
|
-
const descQuad = quads.find((q) => q.predicate.value === PREDICATES.
|
|
127
|
+
const descQuad = quads.find((q) => q.predicate.value === PREDICATES.summary);
|
|
130
128
|
expect(descQuad).toBeDefined();
|
|
131
129
|
expect(descQuad?.object.value).toBe("");
|
|
132
130
|
});
|
|
@@ -134,7 +132,7 @@ describe("transformRow", () => {
|
|
|
134
132
|
it("should handle dynamic class from row data", () => {
|
|
135
133
|
const store = new GraphStore();
|
|
136
134
|
const prefixes = new PrefixMap();
|
|
137
|
-
prefixes.add("
|
|
135
|
+
prefixes.add("ds", NAMESPACES.ds);
|
|
138
136
|
|
|
139
137
|
const refMap: ReferenceMap = new Map([
|
|
140
138
|
["component", componentType],
|
|
@@ -143,8 +141,8 @@ describe("transformRow", () => {
|
|
|
143
141
|
const row = { name: "Button", type: "Component", uri: buttonUri };
|
|
144
142
|
const config = {
|
|
145
143
|
"@context": {
|
|
146
|
-
|
|
147
|
-
name: "
|
|
144
|
+
ds: NAMESPACES.ds,
|
|
145
|
+
name: "ds:name",
|
|
148
146
|
},
|
|
149
147
|
class: "{type}",
|
|
150
148
|
uriTemplate: "{uri}",
|
|
@@ -160,12 +158,12 @@ describe("transformRow", () => {
|
|
|
160
158
|
it("should return the subject URI", () => {
|
|
161
159
|
const store = new GraphStore();
|
|
162
160
|
const prefixes = new PrefixMap();
|
|
163
|
-
prefixes.add("
|
|
161
|
+
prefixes.add("ds", NAMESPACES.ds);
|
|
164
162
|
|
|
165
163
|
const row = { name: "Button", uri: buttonUri };
|
|
166
164
|
const config = {
|
|
167
|
-
"@context": {
|
|
168
|
-
class: "
|
|
165
|
+
"@context": { ds: NAMESPACES.ds, name: "ds:name" },
|
|
166
|
+
class: "ds:Component",
|
|
169
167
|
uriTemplate: "{uri}",
|
|
170
168
|
};
|
|
171
169
|
|
|
@@ -177,28 +175,26 @@ describe("transformRow", () => {
|
|
|
177
175
|
it("should embed inline properties as blank nodes", () => {
|
|
178
176
|
const store = new GraphStore();
|
|
179
177
|
const prefixes = new PrefixMap();
|
|
180
|
-
prefixes.add("dso", NAMESPACES.dso);
|
|
181
178
|
prefixes.add("ds", NAMESPACES.ds);
|
|
182
179
|
|
|
183
180
|
const row = { name: "Button", properties: "prop-1,prop-2", uri: buttonUri };
|
|
184
181
|
const config = {
|
|
185
182
|
"@context": {
|
|
186
|
-
dso: NAMESPACES.dso,
|
|
187
183
|
ds: NAMESPACES.ds,
|
|
188
|
-
name: "
|
|
184
|
+
name: "ds:name",
|
|
189
185
|
properties: {
|
|
190
|
-
"@id": "
|
|
186
|
+
"@id": "ds:hasProperty",
|
|
191
187
|
"@inline": {
|
|
192
188
|
table: "properties",
|
|
193
|
-
class: "
|
|
189
|
+
class: "ds:Property",
|
|
194
190
|
properties: {
|
|
195
|
-
name: "
|
|
196
|
-
type: "
|
|
191
|
+
name: "ds:propertyName",
|
|
192
|
+
type: "ds:propertyType",
|
|
197
193
|
},
|
|
198
194
|
},
|
|
199
195
|
},
|
|
200
196
|
},
|
|
201
|
-
class: "
|
|
197
|
+
class: "ds:Component",
|
|
202
198
|
uriTemplate: "{uri}",
|
|
203
199
|
};
|
|
204
200
|
|
|
@@ -218,7 +214,7 @@ describe("transformRow", () => {
|
|
|
218
214
|
|
|
219
215
|
// Find blank node quads
|
|
220
216
|
const hasPropertyQuads = quads.filter(
|
|
221
|
-
(q) => q.predicate.value === `${NAMESPACES.
|
|
217
|
+
(q) => q.predicate.value === `${NAMESPACES.ds}hasProperty`,
|
|
222
218
|
);
|
|
223
219
|
expect(hasPropertyQuads).toHaveLength(2);
|
|
224
220
|
|
|
@@ -229,28 +225,131 @@ describe("transformRow", () => {
|
|
|
229
225
|
q.predicate.value === PREDICATES.type,
|
|
230
226
|
);
|
|
231
227
|
expect(blankNodeTypes).toHaveLength(2);
|
|
232
|
-
expect(blankNodeTypes[0].object.value).toBe(`${NAMESPACES.
|
|
228
|
+
expect(blankNodeTypes[0].object.value).toBe(`${NAMESPACES.ds}Property`);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
describe("classProperties", () => {
|
|
232
|
+
const layoutUri = `${NAMESPACES.ds}global.layout.app`;
|
|
233
|
+
|
|
234
|
+
it("should apply classProperties when the resolved class matches", () => {
|
|
235
|
+
const store = new GraphStore();
|
|
236
|
+
const prefixes = new PrefixMap();
|
|
237
|
+
prefixes.add("ds", NAMESPACES.ds);
|
|
238
|
+
|
|
239
|
+
const row = {
|
|
240
|
+
name: "App Layout",
|
|
241
|
+
layout_grid_template: "1fr min-content;",
|
|
242
|
+
layout_information_domain: "application",
|
|
243
|
+
uri: layoutUri,
|
|
244
|
+
};
|
|
245
|
+
const config = {
|
|
246
|
+
"@context": { ds: NAMESPACES.ds, name: "ds:name" },
|
|
247
|
+
class: "ds:Layout",
|
|
248
|
+
uriTemplate: "{uri}",
|
|
249
|
+
classProperties: {
|
|
250
|
+
"ds:Layout": {
|
|
251
|
+
layout_grid_template: "ds:grid",
|
|
252
|
+
layout_information_domain: "ds:domain",
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
transformRow(row, config, store, prefixes, new Map());
|
|
258
|
+
|
|
259
|
+
const quads = store.getQuads();
|
|
260
|
+
const gridQuad = quads.find((q) => q.predicate.value === `${NAMESPACES.ds}grid`);
|
|
261
|
+
const domainQuad = quads.find((q) => q.predicate.value === `${NAMESPACES.ds}domain`);
|
|
262
|
+
|
|
263
|
+
expect(gridQuad?.object.value).toBe("1fr min-content;");
|
|
264
|
+
expect(domainQuad?.object.value).toBe("application");
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it("should NOT apply classProperties when the resolved class does not match", () => {
|
|
268
|
+
const store = new GraphStore();
|
|
269
|
+
const prefixes = new PrefixMap();
|
|
270
|
+
prefixes.add("ds", NAMESPACES.ds);
|
|
271
|
+
|
|
272
|
+
const row = {
|
|
273
|
+
name: "Button",
|
|
274
|
+
layout_grid_template: "1fr;",
|
|
275
|
+
layout_information_domain: "view",
|
|
276
|
+
uri: buttonUri,
|
|
277
|
+
};
|
|
278
|
+
const config = {
|
|
279
|
+
"@context": { ds: NAMESPACES.ds, name: "ds:name" },
|
|
280
|
+
class: "ds:Component",
|
|
281
|
+
uriTemplate: "{uri}",
|
|
282
|
+
classProperties: {
|
|
283
|
+
"ds:Layout": {
|
|
284
|
+
layout_grid_template: "ds:grid",
|
|
285
|
+
layout_information_domain: "ds:domain",
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
transformRow(row, config, store, prefixes, new Map());
|
|
291
|
+
|
|
292
|
+
const quads = store.getQuads();
|
|
293
|
+
const gridQuad = quads.find((q) => q.predicate.value === `${NAMESPACES.ds}grid`);
|
|
294
|
+
const domainQuad = quads.find((q) => q.predicate.value === `${NAMESPACES.ds}domain`);
|
|
295
|
+
|
|
296
|
+
expect(gridQuad).toBeUndefined();
|
|
297
|
+
expect(domainQuad).toBeUndefined();
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it("should skip empty classProperty values", () => {
|
|
301
|
+
const store = new GraphStore();
|
|
302
|
+
const prefixes = new PrefixMap();
|
|
303
|
+
prefixes.add("ds", NAMESPACES.ds);
|
|
304
|
+
|
|
305
|
+
const row = {
|
|
306
|
+
name: "App Layout",
|
|
307
|
+
layout_grid_template: "",
|
|
308
|
+
layout_information_domain: null,
|
|
309
|
+
uri: layoutUri,
|
|
310
|
+
};
|
|
311
|
+
const config = {
|
|
312
|
+
"@context": { ds: NAMESPACES.ds, name: "ds:name" },
|
|
313
|
+
class: "ds:Layout",
|
|
314
|
+
uriTemplate: "{uri}",
|
|
315
|
+
classProperties: {
|
|
316
|
+
"ds:Layout": {
|
|
317
|
+
layout_grid_template: "ds:grid",
|
|
318
|
+
layout_information_domain: "ds:domain",
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
transformRow(row, config, store, prefixes, new Map());
|
|
324
|
+
|
|
325
|
+
const quads = store.getQuads();
|
|
326
|
+
const gridQuad = quads.find((q) => q.predicate.value === `${NAMESPACES.ds}grid`);
|
|
327
|
+
const domainQuad = quads.find((q) => q.predicate.value === `${NAMESPACES.ds}domain`);
|
|
328
|
+
|
|
329
|
+
expect(gridQuad).toBeUndefined();
|
|
330
|
+
expect(domainQuad).toBeUndefined();
|
|
331
|
+
});
|
|
233
332
|
});
|
|
234
333
|
|
|
235
334
|
it("should skip inline properties when no matching data", () => {
|
|
236
335
|
const store = new GraphStore();
|
|
237
336
|
const prefixes = new PrefixMap();
|
|
238
|
-
prefixes.add("
|
|
337
|
+
prefixes.add("ds", NAMESPACES.ds);
|
|
239
338
|
|
|
240
339
|
const row = { name: "Button", properties: "unknown-id", uri: buttonUri };
|
|
241
340
|
const config = {
|
|
242
341
|
"@context": {
|
|
243
|
-
|
|
244
|
-
name: "
|
|
342
|
+
ds: NAMESPACES.ds,
|
|
343
|
+
name: "ds:name",
|
|
245
344
|
properties: {
|
|
246
|
-
"@id": "
|
|
345
|
+
"@id": "ds:hasProperty",
|
|
247
346
|
"@inline": {
|
|
248
347
|
table: "properties",
|
|
249
|
-
properties: { name: "
|
|
348
|
+
properties: { name: "ds:propertyName" },
|
|
250
349
|
},
|
|
251
350
|
},
|
|
252
351
|
},
|
|
253
|
-
class: "
|
|
352
|
+
class: "ds:Component",
|
|
254
353
|
uriTemplate: "{uri}",
|
|
255
354
|
};
|
|
256
355
|
|
|
@@ -262,7 +361,7 @@ describe("transformRow", () => {
|
|
|
262
361
|
|
|
263
362
|
const quads = store.getQuads();
|
|
264
363
|
const hasPropertyQuads = quads.filter(
|
|
265
|
-
(q) => q.predicate.value === `${NAMESPACES.
|
|
364
|
+
(q) => q.predicate.value === `${NAMESPACES.ds}hasProperty`,
|
|
266
365
|
);
|
|
267
366
|
expect(hasPropertyQuads).toHaveLength(0);
|
|
268
367
|
});
|
|
@@ -66,13 +66,15 @@ function getPredicateUri(
|
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Resolve the class for @type, supporting templates like "{type}"
|
|
69
|
+
*
|
|
70
|
+
* Returns null when the template cannot be resolved (e.g. empty type column).
|
|
69
71
|
*/
|
|
70
72
|
function resolveClass(
|
|
71
73
|
classConfig: string,
|
|
72
74
|
row: Record<string, unknown>,
|
|
73
75
|
refMap: ReferenceMap,
|
|
74
76
|
prefixes: PrefixMap,
|
|
75
|
-
): string {
|
|
77
|
+
): string | null {
|
|
76
78
|
// Check if class is a template (contains {column})
|
|
77
79
|
if (classConfig.includes("{")) {
|
|
78
80
|
const columnMatch = classConfig.match(/\{(\w+)\}/);
|
|
@@ -87,6 +89,8 @@ function resolveClass(
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
}
|
|
92
|
+
// Template could not be resolved — skip this row
|
|
93
|
+
return null;
|
|
90
94
|
}
|
|
91
95
|
// Expand prefixed URI
|
|
92
96
|
return prefixes.expand(classConfig);
|
|
@@ -136,7 +140,8 @@ function addInlineBlankNodes(
|
|
|
136
140
|
/**
|
|
137
141
|
* Transform a single row into quads and add them to the store
|
|
138
142
|
*
|
|
139
|
-
* @returns The subject URI of the transformed row
|
|
143
|
+
* @returns The subject URI of the transformed row, or null if the row is invalid
|
|
144
|
+
* (e.g. unresolvable class template or empty/malformed URI).
|
|
140
145
|
*/
|
|
141
146
|
export default function transformRow(
|
|
142
147
|
row: Record<string, unknown>,
|
|
@@ -145,10 +150,16 @@ export default function transformRow(
|
|
|
145
150
|
prefixes: PrefixMap,
|
|
146
151
|
refMap: ReferenceMap,
|
|
147
152
|
inlineData: Record<string, InlineDataMap> = {},
|
|
148
|
-
): string {
|
|
153
|
+
): string | null {
|
|
149
154
|
const rawSubjectUri = buildUri(config.uriTemplate, row);
|
|
155
|
+
if (!rawSubjectUri) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
150
158
|
const subjectUri = prefixes.expand(rawSubjectUri);
|
|
151
159
|
const classUri = resolveClass(config.class, row, refMap, prefixes);
|
|
160
|
+
if (!classUri) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
152
163
|
|
|
153
164
|
// Add rdf:type quad
|
|
154
165
|
store.addQuad(subjectUri, `${NAMESPACES.rdf}type`, classUri);
|
|
@@ -216,5 +227,18 @@ export default function transformRow(
|
|
|
216
227
|
}
|
|
217
228
|
}
|
|
218
229
|
|
|
230
|
+
// Apply class-specific literal properties (classProperties in config)
|
|
231
|
+
if (config.classProperties) {
|
|
232
|
+
for (const [classKey, columnMap] of Object.entries(config.classProperties)) {
|
|
233
|
+
if (prefixes.expand(classKey) === classUri) {
|
|
234
|
+
for (const [columnName, predicate] of Object.entries(columnMap)) {
|
|
235
|
+
const rawValue = row[columnName];
|
|
236
|
+
if (rawValue === null || rawValue === undefined || rawValue === "") continue;
|
|
237
|
+
store.addLiteral(subjectUri, prefixes.expand(predicate), String(rawValue));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
219
243
|
return subjectUri;
|
|
220
244
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
@prefix dso: <https://ds.canonical.com/ontology#>.
|
|
2
|
-
@prefix ds: <https://ds.canonical.com/data/>.
|
|
3
|
-
|
|
4
|
-
ds:global.pattern.breadcrumbs a dso:Pattern;
|
|
5
|
-
dso:name "Breadcrumbs";
|
|
6
|
-
dso:description "Breadcrumbs are a navigational aid that shows users their current location within a site's information hierarchy. They provide a clear path from the root of the information hierarchy (IA) to the current page, allowing users to quickly understand where they are and easily navigate back to previous levels in the IA. Breadcrumbs should reflect the IA, not the user's path they took to arrive at the current page. They work best in websites or applications with multiple levels of hierarchy and are particularly useful when users might arrive at deep pages through search or external links.\n";
|
|
7
|
-
dso:anatomyDsl "\n---\nnode:\n uri: global.pattern.breadcrumbs\n styles:\n layout.type: flow\n layout.direction: horizontal\n layout.align: center\n edges:\n - node:\n switch:\n discriminant: Component\n cases:\n undefined:\n uri: global.subcomponent.breadcrumbs-item\n defined:\n role: custom-item-component\n relation:\n cardinality: \"1..*\"\n slotName: items\n";
|
|
8
|
-
dso:tier ds:global;
|
|
9
|
-
dso:hasProperty [
|
|
10
|
-
a dso:Property;
|
|
11
|
-
dso:name "children";
|
|
12
|
-
dso:propertyType "node";
|
|
13
|
-
dso:optional "false"
|
|
14
|
-
].
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
@prefix dso: <https://ds.canonical.com/ontology#>.
|
|
2
|
-
@prefix ds: <https://ds.canonical.com/data/>.
|
|
3
|
-
|
|
4
|
-
ds:global.subcomponent.timeline-footer a dso:Subcomponent;
|
|
5
|
-
dso:name "Timeline.Footer";
|
|
6
|
-
dso:description "";
|
|
7
|
-
dso:anatomyDsl "---\nnode:\n uri: global.subcomponent.timeline-footer\n edges:\n - node:\n role: content\n relation:\n cardinality: \"1\"\n slotName: default\n";
|
|
8
|
-
dso:tier ds:global.
|