@arpproject/recrate 0.1.7 → 0.1.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/dist/index.d.ts +3 -2
- package/dist/recrate.css +4 -4
- package/dist/recrate.es.js +34674 -114061
- package/package.json +41 -32
- package/.eslintrc.json +0 -37
- package/.storybook/main.ts +0 -40
- package/.storybook/preview.tsx +0 -46
- package/babel.config.json +0 -5
- package/docker-compose.yml +0 -30
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -99
- package/docs/assets/icons.js +0 -18
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -60
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1448
- package/docs/classes/src_crate_builder_CrateManager_crate_manager.CrateManager.html +0 -240
- package/docs/classes/src_crate_builder_CrateManager_profile_manager.ProfileManager.html +0 -42
- package/docs/classes/src_crate_builder_editor_state.EditorState.html +0 -28
- package/docs/classes/src_crate_builder_types.CrateManagerType.html +0 -57
- package/docs/classes/src_crate_builder_types.ProfileManagerType.html +0 -13
- package/docs/functions/src_crate_builder_CrateManager_lib.isURL.html +0 -2
- package/docs/functions/src_crate_builder_CrateManager_lib.mintNewCrate.html +0 -3
- package/docs/functions/src_crate_builder_CrateManager_lib.normalise.html +0 -5
- package/docs/functions/src_crate_builder_CrateManager_lib.normaliseEntityType.html +0 -1
- package/docs/index.html +0 -58
- package/docs/interfaces/src_crate_builder_types.NormalisedCrate.html +0 -3
- package/docs/interfaces/src_crate_builder_types.NormalisedEntityDefinition.html +0 -4
- package/docs/interfaces/src_crate_builder_types.NormalisedProfile.html +0 -9
- package/docs/interfaces/src_crate_builder_types.ProfileLayout.html +0 -2
- package/docs/interfaces/src_crate_builder_types.ProfileLayoutGroup.html +0 -9
- package/docs/interfaces/src_crate_builder_types.UnverifiedCrate.html +0 -3
- package/docs/interfaces/src_crate_builder_types.UnverifiedEntityDefinition.html +0 -4
- package/docs/modules/src_crate_builder_CrateManager_crate_manager.html +0 -2
- package/docs/modules/src_crate_builder_CrateManager_lib.html +0 -6
- package/docs/modules/src_crate_builder_CrateManager_profile_manager.html +0 -2
- package/docs/modules/src_crate_builder_editor_state.html +0 -2
- package/docs/modules/src_crate_builder_types.html +0 -16
- package/docs/types/src_crate_builder_types.EntityReference.html +0 -1
- package/docs/types/src_crate_builder_types.NormalisedContext.html +0 -1
- package/docs/types/src_crate_builder_types.PrimitiveType.html +0 -1
- package/docs/types/src_crate_builder_types.ProfileAssociation.html +0 -1
- package/docs/types/src_crate_builder_types.ProfileInput.html +0 -1
- package/docs/types/src_crate_builder_types.UnverifiedContext.html +0 -1
- package/docs/variables/src_crate_builder_CrateManager_lib.urlProtocols.html +0 -1
- package/index.html +0 -13
- package/load-data-packs.cjs +0 -38
- package/postcss.config.cjs +0 -6
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/marker-icon.png +0 -0
- package/public/marker-shadow.png +0 -0
- package/public/robots.txt +0 -3
- package/react-app-env.d.ts +0 -1
- package/rollup.config.js +0 -26
- package/src/app/App.tsx +0 -13
- package/src/app/EmbeddedComponent.tsx +0 -432
- package/src/app/index.html +0 -20
- package/src/app/index.tsx +0 -19
- package/src/app/lookup.ts +0 -141
- package/src/app/override-styles.css +0 -96
- package/src/crate-builder/CrateManager/contexts/1.1-context.jsonld +0 -2660
- package/src/crate-builder/CrateManager/contexts/1.2-DRAFT-context.jsonld +0 -2918
- package/src/crate-builder/CrateManager/contexts.ts +0 -42
- package/src/crate-builder/CrateManager/crate-manager-benchmarking.spec.ts +0 -31
- package/src/crate-builder/CrateManager/crate-manager-loading-exporting.spec.ts +0 -431
- package/src/crate-builder/CrateManager/crate-manager-operations.spec.ts +0 -298
- package/src/crate-builder/CrateManager/crate-manager.spec.ts +0 -2336
- package/src/crate-builder/CrateManager/crate-manager.ts +0 -2111
- package/src/crate-builder/CrateManager/lib.spec.ts +0 -133
- package/src/crate-builder/CrateManager/lib.ts +0 -170
- package/src/crate-builder/CrateManager/profile-manager.spec.ts +0 -593
- package/src/crate-builder/CrateManager/profile-manager.ts +0 -367
- package/src/crate-builder/CrateManager/schema-type-definitions.json +0 -35122
- package/src/crate-builder/CrateManager/validate-identifier.spec.ts +0 -82
- package/src/crate-builder/CrateManager/validate-identifier.ts +0 -65
- package/src/crate-builder/RenderEntity/Add.tsx +0 -249
- package/src/crate-builder/RenderEntity/AddControl.stories.tsx +0 -126
- package/src/crate-builder/RenderEntity/AddControl.tsx +0 -84
- package/src/crate-builder/RenderEntity/AutoComplete.tsx +0 -215
- package/src/crate-builder/RenderEntity/BulkAdd.tsx +0 -136
- package/src/crate-builder/RenderEntity/DeleteProperty.tsx +0 -33
- package/src/crate-builder/RenderEntity/DialogAddProperty.tsx +0 -83
- package/src/crate-builder/RenderEntity/DialogBrowseEntities.tsx +0 -136
- package/src/crate-builder/RenderEntity/DialogEditContext.tsx +0 -107
- package/src/crate-builder/RenderEntity/DialogPreviewCrate.tsx +0 -54
- package/src/crate-builder/RenderEntity/DialogSaveCrateAsTemplate.tsx +0 -65
- package/src/crate-builder/RenderEntity/DialogSaveEntityTemplate.tsx +0 -87
- package/src/crate-builder/RenderEntity/DisplayPropertyName.stories.tsx +0 -30
- package/src/crate-builder/RenderEntity/DisplayPropertyName.tsx +0 -21
- package/src/crate-builder/RenderEntity/EntityId.tsx +0 -75
- package/src/crate-builder/RenderEntity/EntityName.tsx +0 -49
- package/src/crate-builder/RenderEntity/EntityProperty.tsx +0 -188
- package/src/crate-builder/RenderEntity/EntityPropertyInstance.tsx +0 -255
- package/src/crate-builder/RenderEntity/EntityType.tsx +0 -95
- package/src/crate-builder/RenderEntity/ItemLink.tsx +0 -37
- package/src/crate-builder/RenderEntity/PaginateLinkedEntities.stories.tsx +0 -43
- package/src/crate-builder/RenderEntity/PaginateLinkedEntities.tsx +0 -141
- package/src/crate-builder/RenderEntity/PropertyHelp.tsx +0 -39
- package/src/crate-builder/RenderEntity/RenderControls.tsx +0 -278
- package/src/crate-builder/RenderEntity/RenderLinkedItem.tsx +0 -139
- package/src/crate-builder/RenderEntity/RenderPropertyHelp.tsx +0 -41
- package/src/crate-builder/RenderEntity/RenderReverseConnections.tsx +0 -150
- package/src/crate-builder/RenderEntity/RenderTypes.tsx +0 -102
- package/src/crate-builder/RenderEntity/Shell2.tsx +0 -576
- package/src/crate-builder/RenderEntity/UnlinkEntity.tsx +0 -30
- package/src/crate-builder/RenderEntity/auto-complete.lib.ts +0 -184
- package/src/crate-builder/RenderEntity/keys.ts +0 -4
- package/src/crate-builder/RenderEntity/layout.spec.js +0 -593
- package/src/crate-builder/RenderEntity/layout.ts +0 -220
- package/src/crate-builder/Shell.tsx +0 -337
- package/src/crate-builder/component.css +0 -65
- package/src/crate-builder/editor-state.ts +0 -114
- package/src/crate-builder/emotionCache.ts +0 -8
- package/src/crate-builder/helpers.ts +0 -16
- package/src/crate-builder/i18n.ts +0 -22
- package/src/crate-builder/lib/validate-iri.js +0 -69
- package/src/crate-builder/lib/validate-iri.ts +0 -57
- package/src/crate-builder/locales/en.js +0 -149
- package/src/crate-builder/locales/hu.js +0 -147
- package/src/crate-builder/primitives/Boolean.stories.tsx +0 -33
- package/src/crate-builder/primitives/Boolean.tsx +0 -67
- package/src/crate-builder/primitives/Date.stories.tsx +0 -32
- package/src/crate-builder/primitives/Date.tsx +0 -58
- package/src/crate-builder/primitives/DateTime.stories.tsx +0 -32
- package/src/crate-builder/primitives/DateTime.tsx +0 -64
- package/src/crate-builder/primitives/Geo.stories.tsx +0 -57
- package/src/crate-builder/primitives/Geo.tsx +0 -225
- package/src/crate-builder/primitives/Map.SelectArea.js +0 -359
- package/src/crate-builder/primitives/Map.stories.tsx +0 -61
- package/src/crate-builder/primitives/Map.tsx +0 -124
- package/src/crate-builder/primitives/Number.stories.tsx +0 -74
- package/src/crate-builder/primitives/Number.tsx +0 -166
- package/src/crate-builder/primitives/Select.stories.tsx +0 -66
- package/src/crate-builder/primitives/Select.tsx +0 -121
- package/src/crate-builder/primitives/SelectObject.stories.tsx +0 -29
- package/src/crate-builder/primitives/SelectObject.tsx +0 -105
- package/src/crate-builder/primitives/SelectUrl.stories.tsx +0 -42
- package/src/crate-builder/primitives/SelectUrl.tsx +0 -110
- package/src/crate-builder/primitives/Text.stories.tsx +0 -106
- package/src/crate-builder/primitives/Text.tsx +0 -197
- package/src/crate-builder/primitives/Time.stories.tsx +0 -38
- package/src/crate-builder/primitives/Time.tsx +0 -71
- package/src/crate-builder/primitives/Url.stories.tsx +0 -43
- package/src/crate-builder/primitives/Url.tsx +0 -75
- package/src/crate-builder/primitives/Value.stories.tsx +0 -37
- package/src/crate-builder/primitives/Value.tsx +0 -30
- package/src/crate-builder/primitives/date-libs.ts +0 -12
- package/src/crate-builder/profile-schema.json +0 -145
- package/src/crate-builder/property-definitions.ts +0 -78
- package/src/crate-builder/recrate.css +0 -3
- package/src/crate-builder/store.ts +0 -14
- package/src/crate-builder/tailwind.css +0 -5
- package/src/crate-builder/types.d.ts +0 -318
- package/src/examples/collection/collections-entity-example.json +0 -131
- package/src/examples/collection/crate-builder-entity-example.json +0 -33
- package/src/examples/item/complex-collection/ro-crate-metadata.json +0 -174
- package/src/examples/item/complex-item/ro-crate-metadata.json +0 -769
- package/src/examples/item/crate-with-language.json +0 -38
- package/src/examples/item/empty/ro-crate-metadata.json +0 -20
- package/src/examples/item/item-with-relationship-and-action/ro-crate-metadata.json +0 -66
- package/src/examples/item/large-crate/ro-crate-metadata.json +0 -5762
- package/src/examples/item/multiple-types/ro-crate-metadata.json +0 -20
- package/src/examples/item/ridiculously-big-collection/ro-crate-metadata.json +0 -162977
- package/src/examples/profile/aroma.complex.profile.json +0 -11098
- package/src/examples/profile/aroma.profile.json +0 -9158
- package/src/examples/profile/nyingarn-item-profile.json +0 -426
- package/src/examples/profile/profile-to-test-inverse-associations.json +0 -73
- package/src/examples/profile/profile-to-test-multiple-types.json +0 -31
- package/src/examples/profile/profile-with-all-primitives-and-groups.json +0 -207
- package/src/examples/profile/profile-with-all-primitives.json +0 -244
- package/src/examples/profile/profile-with-constraints.json +0 -446
- package/src/examples/profile/profile-with-resolve.json +0 -57
- package/src/examples/profile/vocabulary-creation-profile.json +0 -231
- package/src/images.d.ts +0 -5
- package/src/index.ts +0 -12
- package/src/types.ts +0 -104
- package/tailwind.config.js +0 -21
- package/tsconfig.app.json +0 -31
- package/tsconfig.json +0 -26
- package/typedoc.json +0 -11
- package/update-deps.sh +0 -4
- package/vite-env.d.ts +0 -1
- package/vite.config.ts +0 -46
|
@@ -1,593 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeAll, vi } from "vitest";
|
|
2
|
-
import { ProfileManager } from "./profile-manager";
|
|
3
|
-
import type { NormalisedEntityDefinition, NormalisedProfile } from "../types";
|
|
4
|
-
|
|
5
|
-
describe("Test working with profiles", () => {
|
|
6
|
-
beforeAll(() => {
|
|
7
|
-
vi.spyOn(console, "debug").mockImplementation(() => {});
|
|
8
|
-
});
|
|
9
|
-
test("get type definition and inputs from the profile", () => {
|
|
10
|
-
const profile: NormalisedProfile = {
|
|
11
|
-
metadata: {} as any,
|
|
12
|
-
classes: {
|
|
13
|
-
Dataset: {
|
|
14
|
-
definition: "override",
|
|
15
|
-
subClassOf: [],
|
|
16
|
-
inputs: [
|
|
17
|
-
{
|
|
18
|
-
id: "https://schema.org/date",
|
|
19
|
-
name: "date",
|
|
20
|
-
label: "Attach a date",
|
|
21
|
-
help: "",
|
|
22
|
-
type: ["Date"],
|
|
23
|
-
required: true,
|
|
24
|
-
multiple: false,
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
const entity = { "@type": ["Dataset"] } as NormalisedEntityDefinition;
|
|
31
|
-
const profileManager = new ProfileManager({ profile });
|
|
32
|
-
let inputs = profileManager.getInputsFromProfile({ entity });
|
|
33
|
-
expect(inputs.length).toEqual(1);
|
|
34
|
-
|
|
35
|
-
let typeHierarchies = profileManager.getEntityTypeHierarchy({ entity });
|
|
36
|
-
expect(typeHierarchies).toEqual(["Dataset", "CreativeWork", "Thing"]);
|
|
37
|
-
});
|
|
38
|
-
test("get type definition from the profile - handle type Array", () => {
|
|
39
|
-
const profile: NormalisedProfile = {
|
|
40
|
-
metadata: {} as any,
|
|
41
|
-
classes: {
|
|
42
|
-
Dataset: {
|
|
43
|
-
definition: "override",
|
|
44
|
-
subClassOf: [],
|
|
45
|
-
inputs: [
|
|
46
|
-
{
|
|
47
|
-
id: "https://schema.org/date",
|
|
48
|
-
name: "date",
|
|
49
|
-
label: "Attach a date",
|
|
50
|
-
help: "",
|
|
51
|
-
type: ["Date"],
|
|
52
|
-
required: true,
|
|
53
|
-
multiple: false,
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
const entity = { "@type": ["Dataset"] } as NormalisedEntityDefinition;
|
|
60
|
-
const profileManager = new ProfileManager({ profile });
|
|
61
|
-
let inputs = profileManager.getInputsFromProfile({ entity });
|
|
62
|
-
expect(inputs.length).toEqual(1);
|
|
63
|
-
|
|
64
|
-
let typeHierarchies = profileManager.getEntityTypeHierarchy({ entity });
|
|
65
|
-
expect(typeHierarchies).toEqual(["Dataset", "CreativeWork", "Thing"]);
|
|
66
|
-
});
|
|
67
|
-
test("get inputs from the profile - handle type Array", () => {
|
|
68
|
-
const profile: NormalisedProfile = {
|
|
69
|
-
metadata: {} as any,
|
|
70
|
-
classes: {
|
|
71
|
-
Dataset: {
|
|
72
|
-
definition: "override",
|
|
73
|
-
subClassOf: [],
|
|
74
|
-
inputs: [
|
|
75
|
-
{
|
|
76
|
-
id: "https://schema.org/date",
|
|
77
|
-
name: "date",
|
|
78
|
-
label: "Attach a date",
|
|
79
|
-
help: "",
|
|
80
|
-
type: ["Date"],
|
|
81
|
-
required: true,
|
|
82
|
-
multiple: false,
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
Other: {
|
|
87
|
-
definition: "override",
|
|
88
|
-
subClassOf: [],
|
|
89
|
-
inputs: [
|
|
90
|
-
{
|
|
91
|
-
id: "https://schema.org/description",
|
|
92
|
-
name: "description",
|
|
93
|
-
help: "",
|
|
94
|
-
type: ["Text"],
|
|
95
|
-
required: true,
|
|
96
|
-
multiple: false,
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
id: "https://schema.org/date",
|
|
100
|
-
name: "date",
|
|
101
|
-
label: "Attach a date",
|
|
102
|
-
help: "",
|
|
103
|
-
type: ["Date"],
|
|
104
|
-
required: true,
|
|
105
|
-
multiple: false,
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
const entity = { "@type": ["Dataset", "Other"] } as NormalisedEntityDefinition;
|
|
112
|
-
const profileManager = new ProfileManager({ profile });
|
|
113
|
-
let inputs = profileManager.getInputsFromProfile({ entity });
|
|
114
|
-
expect(inputs.length).toEqual(2);
|
|
115
|
-
|
|
116
|
-
let typeHierarchies = profileManager.getEntityTypeHierarchy({ entity });
|
|
117
|
-
expect(typeHierarchies).toEqual(["Dataset", "CreativeWork", "Thing", "Other"]);
|
|
118
|
-
});
|
|
119
|
-
test("get type definition - no profile, look in schema.org", () => {
|
|
120
|
-
const profile = undefined;
|
|
121
|
-
const profileManager = new ProfileManager({ profile });
|
|
122
|
-
const entity = { "@type": ["Dataset"] } as NormalisedEntityDefinition;
|
|
123
|
-
let inputs = profileManager.getInputsFromProfile({ entity });
|
|
124
|
-
expect(inputs.length).toEqual(0);
|
|
125
|
-
|
|
126
|
-
let typeHierarchies = profileManager.getEntityTypeHierarchy({ entity });
|
|
127
|
-
expect(typeHierarchies).toEqual(["Dataset", "CreativeWork", "Thing"]);
|
|
128
|
-
});
|
|
129
|
-
test("get type definition - no profile, handle type array, look in schema.org", () => {
|
|
130
|
-
const profile = undefined;
|
|
131
|
-
const profileManager = new ProfileManager({});
|
|
132
|
-
const entity = { "@type": ["Dataset"] } as NormalisedEntityDefinition;
|
|
133
|
-
let inputs = profileManager.getInputsFromProfile({ entity });
|
|
134
|
-
expect(inputs.length).toEqual(0);
|
|
135
|
-
|
|
136
|
-
let typeHierarchies = profileManager.getEntityTypeHierarchy({ entity });
|
|
137
|
-
expect(typeHierarchies).toEqual(["Dataset", "CreativeWork", "Thing"]);
|
|
138
|
-
});
|
|
139
|
-
test("get type definition - none defined in profile", () => {
|
|
140
|
-
const profile: NormalisedProfile = {
|
|
141
|
-
metadata: {} as any,
|
|
142
|
-
classes: {},
|
|
143
|
-
};
|
|
144
|
-
const profileManager = new ProfileManager({ profile });
|
|
145
|
-
const entity = { "@type": ["Dataset"] } as NormalisedEntityDefinition;
|
|
146
|
-
let inputs = profileManager.getInputsFromProfile({ entity });
|
|
147
|
-
expect(inputs.length).toEqual(0);
|
|
148
|
-
|
|
149
|
-
let typeHierarchies = profileManager.getEntityTypeHierarchy({ entity });
|
|
150
|
-
expect(typeHierarchies).toEqual(["Dataset", "CreativeWork", "Thing"]);
|
|
151
|
-
});
|
|
152
|
-
test("get layout information from profile", () => {
|
|
153
|
-
const profile: NormalisedProfile = {
|
|
154
|
-
metadata: {} as any,
|
|
155
|
-
classes: [] as any,
|
|
156
|
-
layouts: [
|
|
157
|
-
{
|
|
158
|
-
appliesTo: ["Dataset"],
|
|
159
|
-
about: {
|
|
160
|
-
name: "about",
|
|
161
|
-
label: "About",
|
|
162
|
-
description: "",
|
|
163
|
-
},
|
|
164
|
-
source: {
|
|
165
|
-
name: "Original Source Information",
|
|
166
|
-
label: "Original Source Information",
|
|
167
|
-
description: "",
|
|
168
|
-
},
|
|
169
|
-
permissions: {
|
|
170
|
-
name: "Permissions",
|
|
171
|
-
label: "Permissions",
|
|
172
|
-
description: "",
|
|
173
|
-
},
|
|
174
|
-
who: {
|
|
175
|
-
name: "Who",
|
|
176
|
-
label: "Who",
|
|
177
|
-
description: "",
|
|
178
|
-
},
|
|
179
|
-
location: {
|
|
180
|
-
name: "Location",
|
|
181
|
-
label: "Location",
|
|
182
|
-
description: "",
|
|
183
|
-
},
|
|
184
|
-
overflow: {
|
|
185
|
-
name: "Other",
|
|
186
|
-
label: "Other",
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
] as any,
|
|
190
|
-
};
|
|
191
|
-
const profileManager = new ProfileManager({ profile });
|
|
192
|
-
let layout = profileManager.getLayout({
|
|
193
|
-
entity: { "@id": "#1", "@type": ["Dataset"] },
|
|
194
|
-
});
|
|
195
|
-
expect(layout).toEqual((profile as any).layouts[0]);
|
|
196
|
-
});
|
|
197
|
-
test("get layout information from profile - no layout", () => {
|
|
198
|
-
const profile: NormalisedProfile = {
|
|
199
|
-
metadata: {} as any,
|
|
200
|
-
classes: [] as any,
|
|
201
|
-
layouts: {} as any,
|
|
202
|
-
};
|
|
203
|
-
const profileManager = new ProfileManager({ profile });
|
|
204
|
-
let layout = profileManager.getLayout({ entity: { "@id": "#1", "@type": ["Thing"] } });
|
|
205
|
-
expect(layout).toBe(null);
|
|
206
|
-
});
|
|
207
|
-
test("get property definition - defined in profile", () => {
|
|
208
|
-
const profile: NormalisedProfile = {
|
|
209
|
-
metadata: {} as any,
|
|
210
|
-
classes: {
|
|
211
|
-
Dataset: {
|
|
212
|
-
definition: "override",
|
|
213
|
-
subClassOf: [],
|
|
214
|
-
inputs: [
|
|
215
|
-
{
|
|
216
|
-
id: "https://schema.org/date",
|
|
217
|
-
name: "date",
|
|
218
|
-
label: "Attach a date",
|
|
219
|
-
help: "",
|
|
220
|
-
type: ["Date"],
|
|
221
|
-
required: true,
|
|
222
|
-
multiple: false,
|
|
223
|
-
},
|
|
224
|
-
],
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
const profileManager = new ProfileManager({ profile });
|
|
229
|
-
const entity = { "@type": ["Dataset"] } as NormalisedEntityDefinition;
|
|
230
|
-
let { propertyDefinition } = profileManager.getPropertyDefinition({
|
|
231
|
-
property: "date",
|
|
232
|
-
entity,
|
|
233
|
-
});
|
|
234
|
-
expect(propertyDefinition.id).toEqual("https://schema.org/date");
|
|
235
|
-
});
|
|
236
|
-
test("get property definition - not defined in profile, lookup schema.org", () => {
|
|
237
|
-
const profileManager = new ProfileManager({ profile: undefined });
|
|
238
|
-
const entity = { "@type": ["Dataset"] } as NormalisedEntityDefinition;
|
|
239
|
-
let { propertyDefinition } = profileManager.getPropertyDefinition({
|
|
240
|
-
property: "dateModified",
|
|
241
|
-
entity,
|
|
242
|
-
});
|
|
243
|
-
expect(propertyDefinition.id).toEqual("http://schema.org/dateModified");
|
|
244
|
-
expect(propertyDefinition.type.sort()).toEqual(["Date", "DateTime"]);
|
|
245
|
-
});
|
|
246
|
-
test("get property definition - not defined in profile or schema.org; create default entry", () => {
|
|
247
|
-
const profile: NormalisedProfile = {
|
|
248
|
-
metadata: {} as any,
|
|
249
|
-
classes: {
|
|
250
|
-
Dataset: {
|
|
251
|
-
definition: "override",
|
|
252
|
-
subClassOf: [],
|
|
253
|
-
inputs: [
|
|
254
|
-
{
|
|
255
|
-
id: "https://schema.org/date",
|
|
256
|
-
name: "date",
|
|
257
|
-
label: "Attach a date",
|
|
258
|
-
help: "",
|
|
259
|
-
type: ["Date"],
|
|
260
|
-
required: true,
|
|
261
|
-
multiple: false,
|
|
262
|
-
},
|
|
263
|
-
],
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
const profileManager = new ProfileManager({ profile });
|
|
268
|
-
const entity = { "@type": ["Dataset"] } as NormalisedEntityDefinition;
|
|
269
|
-
let { propertyDefinition } = profileManager.getPropertyDefinition({
|
|
270
|
-
property: "mojumbo",
|
|
271
|
-
entity,
|
|
272
|
-
});
|
|
273
|
-
expect(propertyDefinition.type).toEqual(["Text"]);
|
|
274
|
-
});
|
|
275
|
-
test("get type hierarchy - type defined in profile, assume schema.org subClass", () => {
|
|
276
|
-
const profile: NormalisedProfile = {
|
|
277
|
-
metadata: {} as any,
|
|
278
|
-
classes: {
|
|
279
|
-
Dataset: {
|
|
280
|
-
definition: "override",
|
|
281
|
-
subClassOf: [],
|
|
282
|
-
inputs: [
|
|
283
|
-
{
|
|
284
|
-
id: "https://schema.org/date",
|
|
285
|
-
name: "date",
|
|
286
|
-
label: "Attach a date",
|
|
287
|
-
help: "",
|
|
288
|
-
type: ["Date"],
|
|
289
|
-
required: true,
|
|
290
|
-
multiple: false,
|
|
291
|
-
},
|
|
292
|
-
],
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
};
|
|
296
|
-
const profileManager = new ProfileManager({ profile });
|
|
297
|
-
let types = profileManager.mapTypeHierarchies({ types: ["Dataset"] });
|
|
298
|
-
expect(types).toEqual(["Dataset", "CreativeWork", "Thing"]);
|
|
299
|
-
});
|
|
300
|
-
test("get type hierarchy - type defined in profile with subClass", () => {
|
|
301
|
-
const profile: NormalisedProfile = {
|
|
302
|
-
metadata: {} as any,
|
|
303
|
-
classes: {
|
|
304
|
-
Dataset: {
|
|
305
|
-
definition: "override",
|
|
306
|
-
subClassOf: ["NoSuchEntity"],
|
|
307
|
-
inputs: [
|
|
308
|
-
{
|
|
309
|
-
id: "https://schema.org/date",
|
|
310
|
-
name: "date",
|
|
311
|
-
label: "Attach a date",
|
|
312
|
-
help: "",
|
|
313
|
-
type: ["Date"],
|
|
314
|
-
required: true,
|
|
315
|
-
multiple: false,
|
|
316
|
-
},
|
|
317
|
-
],
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
};
|
|
321
|
-
const profileManager = new ProfileManager({ profile });
|
|
322
|
-
let types = profileManager.mapTypeHierarchies({ types: ["Dataset"] });
|
|
323
|
-
expect(types).toEqual(["Dataset", "CreativeWork", "Thing", "NoSuchEntity"]);
|
|
324
|
-
});
|
|
325
|
-
test("get type hierarchy - type not defined in profile or schema.org", () => {
|
|
326
|
-
const profile: NormalisedProfile = {
|
|
327
|
-
metadata: {} as any,
|
|
328
|
-
classes: {
|
|
329
|
-
Children: {
|
|
330
|
-
definition: "override",
|
|
331
|
-
subClassOf: [],
|
|
332
|
-
inputs: [],
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
};
|
|
336
|
-
const profileManager = new ProfileManager({ profile });
|
|
337
|
-
let types = profileManager.mapTypeHierarchies({ types: ["Children"] });
|
|
338
|
-
expect(types).toEqual(["Children", "Thing"]);
|
|
339
|
-
});
|
|
340
|
-
test("get inputs for type defined in profile - no subClass in profile, definition override", () => {
|
|
341
|
-
const profile: NormalisedProfile = {
|
|
342
|
-
metadata: {} as any,
|
|
343
|
-
classes: {
|
|
344
|
-
Thing: {
|
|
345
|
-
definition: "override",
|
|
346
|
-
subClassOf: [],
|
|
347
|
-
inputs: [
|
|
348
|
-
{
|
|
349
|
-
id: "https://schema.org/date",
|
|
350
|
-
name: "date",
|
|
351
|
-
label: "Attach a date",
|
|
352
|
-
help: "",
|
|
353
|
-
type: ["Date"],
|
|
354
|
-
required: true,
|
|
355
|
-
multiple: false,
|
|
356
|
-
},
|
|
357
|
-
],
|
|
358
|
-
},
|
|
359
|
-
},
|
|
360
|
-
};
|
|
361
|
-
const profileManager = new ProfileManager({ profile });
|
|
362
|
-
let types = profileManager.mapTypeHierarchies({ types: ["Thing"] });
|
|
363
|
-
expect(types).toEqual(["Thing"]);
|
|
364
|
-
let { inputs } = profileManager.getAllInputs({
|
|
365
|
-
entity: { "@type": ["Thing"] } as NormalisedEntityDefinition,
|
|
366
|
-
});
|
|
367
|
-
let iis = inputs.map((input) => input.id);
|
|
368
|
-
expect(iis).toEqual(["https://schema.org/date"]);
|
|
369
|
-
expect(iis.length).toEqual(1);
|
|
370
|
-
});
|
|
371
|
-
test("get inputs for type defined in profile - no subClass in profile, definition inherit", () => {
|
|
372
|
-
const profile: NormalisedProfile = {
|
|
373
|
-
metadata: {} as any,
|
|
374
|
-
classes: {
|
|
375
|
-
Thing: {
|
|
376
|
-
definition: "inherit",
|
|
377
|
-
subClassOf: [],
|
|
378
|
-
inputs: [
|
|
379
|
-
{
|
|
380
|
-
id: "https://schema.org/date",
|
|
381
|
-
name: "date",
|
|
382
|
-
label: "Attach a date",
|
|
383
|
-
help: "",
|
|
384
|
-
type: ["Date"],
|
|
385
|
-
required: true,
|
|
386
|
-
multiple: false,
|
|
387
|
-
},
|
|
388
|
-
],
|
|
389
|
-
},
|
|
390
|
-
},
|
|
391
|
-
};
|
|
392
|
-
const profileManager = new ProfileManager({ profile });
|
|
393
|
-
let { inputs } = profileManager.getAllInputs({
|
|
394
|
-
entity: { "@type": ["Thing"] } as NormalisedEntityDefinition,
|
|
395
|
-
});
|
|
396
|
-
let iis = inputs.map((input) => input.id);
|
|
397
|
-
expect(iis).toEqual([
|
|
398
|
-
"http://schema.org/additionalType",
|
|
399
|
-
"http://schema.org/alternateName",
|
|
400
|
-
"http://purl.org/dc/terms/conformsTo",
|
|
401
|
-
"https://schema.org/date",
|
|
402
|
-
"http://schema.org/description",
|
|
403
|
-
"http://schema.org/disambiguatingDescription",
|
|
404
|
-
"https://www.ica.org/standards/RiC/ontology#hasCreationDate",
|
|
405
|
-
"https://www.ica.org/standards/RiC/ontology#hasModificationDate",
|
|
406
|
-
"http://schema.org/identifier",
|
|
407
|
-
"http://schema.org/image",
|
|
408
|
-
"http://schema.org/mainEntityOfPage",
|
|
409
|
-
"http://schema.org/name",
|
|
410
|
-
"http://schema.org/potentialAction",
|
|
411
|
-
"http://schema.org/sameAs",
|
|
412
|
-
"http://schema.org/subjectOf",
|
|
413
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsConnectedToRelation",
|
|
414
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsContextOfRelation",
|
|
415
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsSourceOfRelation",
|
|
416
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsTargetOfRelation",
|
|
417
|
-
"http://schema.org/url",
|
|
418
|
-
]);
|
|
419
|
-
expect(inputs.length).toEqual(20);
|
|
420
|
-
});
|
|
421
|
-
test("get inputs for type defined in profile - subClass in profile, definition inherit, props dup'ed", () => {
|
|
422
|
-
const profile: NormalisedProfile = {
|
|
423
|
-
metadata: {} as any,
|
|
424
|
-
classes: {
|
|
425
|
-
Thing: {
|
|
426
|
-
definition: "override",
|
|
427
|
-
subClassOf: ["NoSuchEntity"],
|
|
428
|
-
inputs: [
|
|
429
|
-
{
|
|
430
|
-
id: "https://schema.org/date",
|
|
431
|
-
name: "date",
|
|
432
|
-
label: "Attach a date",
|
|
433
|
-
help: "",
|
|
434
|
-
type: ["Date"],
|
|
435
|
-
required: true,
|
|
436
|
-
multiple: false,
|
|
437
|
-
},
|
|
438
|
-
],
|
|
439
|
-
},
|
|
440
|
-
NoSuchEntity: {
|
|
441
|
-
definition: "override",
|
|
442
|
-
subClassOf: [],
|
|
443
|
-
inputs: [
|
|
444
|
-
{
|
|
445
|
-
id: "https://schema.org/date",
|
|
446
|
-
name: "date",
|
|
447
|
-
label: "Attach a date",
|
|
448
|
-
help: "",
|
|
449
|
-
type: ["Date"],
|
|
450
|
-
required: true,
|
|
451
|
-
multiple: false,
|
|
452
|
-
},
|
|
453
|
-
],
|
|
454
|
-
},
|
|
455
|
-
},
|
|
456
|
-
};
|
|
457
|
-
const profileManager = new ProfileManager({ profile });
|
|
458
|
-
let { inputs } = profileManager.getAllInputs({
|
|
459
|
-
entity: { "@type": ["Thing"] } as NormalisedEntityDefinition,
|
|
460
|
-
});
|
|
461
|
-
let iis = inputs.map((input) => input.id);
|
|
462
|
-
expect(iis).toEqual(["https://schema.org/date"]);
|
|
463
|
-
expect(iis.length).toEqual(1);
|
|
464
|
-
});
|
|
465
|
-
test("get inputs for type defined in profile - subClass in profile, definition inherit", () => {
|
|
466
|
-
const profile: NormalisedProfile = {
|
|
467
|
-
metadata: {} as any,
|
|
468
|
-
classes: {
|
|
469
|
-
Thing: {
|
|
470
|
-
definition: "override",
|
|
471
|
-
subClassOf: ["NoSuchEntity"],
|
|
472
|
-
inputs: [
|
|
473
|
-
{
|
|
474
|
-
id: "https://schema.org/date",
|
|
475
|
-
name: "date",
|
|
476
|
-
label: "Attach a date",
|
|
477
|
-
help: "",
|
|
478
|
-
type: ["Date"],
|
|
479
|
-
required: true,
|
|
480
|
-
multiple: false,
|
|
481
|
-
},
|
|
482
|
-
],
|
|
483
|
-
},
|
|
484
|
-
NoSuchEntity: {
|
|
485
|
-
definition: "override",
|
|
486
|
-
subClassOf: [""],
|
|
487
|
-
inputs: [
|
|
488
|
-
{
|
|
489
|
-
id: "https://schema.org/somethingElse",
|
|
490
|
-
name: "else",
|
|
491
|
-
label: "Attach a date",
|
|
492
|
-
help: "",
|
|
493
|
-
type: ["Date"],
|
|
494
|
-
required: true,
|
|
495
|
-
multiple: false,
|
|
496
|
-
},
|
|
497
|
-
],
|
|
498
|
-
},
|
|
499
|
-
},
|
|
500
|
-
};
|
|
501
|
-
const profileManager = new ProfileManager({ profile });
|
|
502
|
-
let { inputs } = profileManager.getAllInputs({
|
|
503
|
-
entity: { "@type": ["Thing"] } as NormalisedEntityDefinition,
|
|
504
|
-
});
|
|
505
|
-
let iis = inputs.map((input) => input.id);
|
|
506
|
-
expect(iis.sort()).toEqual(["https://schema.org/date", "https://schema.org/somethingElse"]);
|
|
507
|
-
expect(iis.length).toEqual(2);
|
|
508
|
-
});
|
|
509
|
-
test("get inputs for type array defined in profile - test 1", () => {
|
|
510
|
-
const profile: NormalisedProfile = {
|
|
511
|
-
metadata: {} as any,
|
|
512
|
-
classes: {
|
|
513
|
-
"Thing, Intangible": {
|
|
514
|
-
definition: "inherit",
|
|
515
|
-
subClassOf: [],
|
|
516
|
-
inputs: [],
|
|
517
|
-
},
|
|
518
|
-
},
|
|
519
|
-
};
|
|
520
|
-
const profileManager = new ProfileManager({ profile });
|
|
521
|
-
let { inputs } = profileManager.getAllInputs({
|
|
522
|
-
entity: { "@type": ["Thing", "Intangible"] } as NormalisedEntityDefinition,
|
|
523
|
-
});
|
|
524
|
-
let iis = inputs.map((input) => input.id);
|
|
525
|
-
expect(iis).toEqual([
|
|
526
|
-
"http://schema.org/additionalType",
|
|
527
|
-
"http://schema.org/alternateName",
|
|
528
|
-
"http://purl.org/dc/terms/conformsTo",
|
|
529
|
-
"http://schema.org/description",
|
|
530
|
-
"http://schema.org/disambiguatingDescription",
|
|
531
|
-
"https://www.ica.org/standards/RiC/ontology#hasCreationDate",
|
|
532
|
-
"https://www.ica.org/standards/RiC/ontology#hasModificationDate",
|
|
533
|
-
"http://schema.org/identifier",
|
|
534
|
-
"http://schema.org/image",
|
|
535
|
-
"http://schema.org/mainEntityOfPage",
|
|
536
|
-
"http://schema.org/name",
|
|
537
|
-
"http://schema.org/potentialAction",
|
|
538
|
-
"http://schema.org/sameAs",
|
|
539
|
-
"http://schema.org/subjectOf",
|
|
540
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsConnectedToRelation",
|
|
541
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsContextOfRelation",
|
|
542
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsSourceOfRelation",
|
|
543
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsTargetOfRelation",
|
|
544
|
-
"http://schema.org/url",
|
|
545
|
-
]);
|
|
546
|
-
});
|
|
547
|
-
test("get inputs for type array defined in profile - test 2", () => {
|
|
548
|
-
const profile: NormalisedProfile = {
|
|
549
|
-
metadata: {} as any,
|
|
550
|
-
classes: {
|
|
551
|
-
"Thing, MedicalEntity": {
|
|
552
|
-
definition: "inherit",
|
|
553
|
-
subClassOf: [],
|
|
554
|
-
inputs: [],
|
|
555
|
-
},
|
|
556
|
-
},
|
|
557
|
-
};
|
|
558
|
-
const profileManager = new ProfileManager({ profile });
|
|
559
|
-
let { inputs } = profileManager.getAllInputs({
|
|
560
|
-
entity: { "@type": ["Thing", "MedicalEntity"] } as NormalisedEntityDefinition,
|
|
561
|
-
});
|
|
562
|
-
let iis = inputs.map((input) => input.id);
|
|
563
|
-
expect(iis).toEqual([
|
|
564
|
-
"http://schema.org/additionalType",
|
|
565
|
-
"http://schema.org/alternateName",
|
|
566
|
-
"http://schema.org/code",
|
|
567
|
-
"http://purl.org/dc/terms/conformsTo",
|
|
568
|
-
"http://schema.org/description",
|
|
569
|
-
"http://schema.org/disambiguatingDescription",
|
|
570
|
-
"http://schema.org/funding",
|
|
571
|
-
"http://schema.org/guideline",
|
|
572
|
-
"https://www.ica.org/standards/RiC/ontology#hasCreationDate",
|
|
573
|
-
"https://www.ica.org/standards/RiC/ontology#hasModificationDate",
|
|
574
|
-
"http://schema.org/identifier",
|
|
575
|
-
"http://schema.org/image",
|
|
576
|
-
"http://schema.org/legalStatus",
|
|
577
|
-
"http://schema.org/mainEntityOfPage",
|
|
578
|
-
"http://schema.org/medicineSystem",
|
|
579
|
-
"http://schema.org/name",
|
|
580
|
-
"http://schema.org/potentialAction",
|
|
581
|
-
"http://schema.org/recognizingAuthority",
|
|
582
|
-
"http://schema.org/relevantSpecialty",
|
|
583
|
-
"http://schema.org/sameAs",
|
|
584
|
-
"http://schema.org/study",
|
|
585
|
-
"http://schema.org/subjectOf",
|
|
586
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsConnectedToRelation",
|
|
587
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsContextOfRelation",
|
|
588
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsSourceOfRelation",
|
|
589
|
-
"https://www.ica.org/standards/RiC/ontology#thingIsTargetOfRelation",
|
|
590
|
-
"http://schema.org/url",
|
|
591
|
-
]);
|
|
592
|
-
});
|
|
593
|
-
});
|