@arpproject/recrate 0.1.7 → 0.1.8

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 (188) hide show
  1. package/dist/index.d.ts +3 -2
  2. package/dist/recrate.css +4 -4
  3. package/dist/recrate.es.js +34674 -114061
  4. package/package.json +41 -32
  5. package/.eslintrc.json +0 -37
  6. package/.storybook/main.ts +0 -40
  7. package/.storybook/preview.tsx +0 -46
  8. package/babel.config.json +0 -5
  9. package/docker-compose.yml +0 -30
  10. package/docs/.nojekyll +0 -1
  11. package/docs/assets/highlight.css +0 -99
  12. package/docs/assets/icons.js +0 -18
  13. package/docs/assets/icons.svg +0 -1
  14. package/docs/assets/main.js +0 -60
  15. package/docs/assets/navigation.js +0 -1
  16. package/docs/assets/search.js +0 -1
  17. package/docs/assets/style.css +0 -1448
  18. package/docs/classes/src_crate_builder_CrateManager_crate_manager.CrateManager.html +0 -240
  19. package/docs/classes/src_crate_builder_CrateManager_profile_manager.ProfileManager.html +0 -42
  20. package/docs/classes/src_crate_builder_editor_state.EditorState.html +0 -28
  21. package/docs/classes/src_crate_builder_types.CrateManagerType.html +0 -57
  22. package/docs/classes/src_crate_builder_types.ProfileManagerType.html +0 -13
  23. package/docs/functions/src_crate_builder_CrateManager_lib.isURL.html +0 -2
  24. package/docs/functions/src_crate_builder_CrateManager_lib.mintNewCrate.html +0 -3
  25. package/docs/functions/src_crate_builder_CrateManager_lib.normalise.html +0 -5
  26. package/docs/functions/src_crate_builder_CrateManager_lib.normaliseEntityType.html +0 -1
  27. package/docs/index.html +0 -58
  28. package/docs/interfaces/src_crate_builder_types.NormalisedCrate.html +0 -3
  29. package/docs/interfaces/src_crate_builder_types.NormalisedEntityDefinition.html +0 -4
  30. package/docs/interfaces/src_crate_builder_types.NormalisedProfile.html +0 -9
  31. package/docs/interfaces/src_crate_builder_types.ProfileLayout.html +0 -2
  32. package/docs/interfaces/src_crate_builder_types.ProfileLayoutGroup.html +0 -9
  33. package/docs/interfaces/src_crate_builder_types.UnverifiedCrate.html +0 -3
  34. package/docs/interfaces/src_crate_builder_types.UnverifiedEntityDefinition.html +0 -4
  35. package/docs/modules/src_crate_builder_CrateManager_crate_manager.html +0 -2
  36. package/docs/modules/src_crate_builder_CrateManager_lib.html +0 -6
  37. package/docs/modules/src_crate_builder_CrateManager_profile_manager.html +0 -2
  38. package/docs/modules/src_crate_builder_editor_state.html +0 -2
  39. package/docs/modules/src_crate_builder_types.html +0 -16
  40. package/docs/types/src_crate_builder_types.EntityReference.html +0 -1
  41. package/docs/types/src_crate_builder_types.NormalisedContext.html +0 -1
  42. package/docs/types/src_crate_builder_types.PrimitiveType.html +0 -1
  43. package/docs/types/src_crate_builder_types.ProfileAssociation.html +0 -1
  44. package/docs/types/src_crate_builder_types.ProfileInput.html +0 -1
  45. package/docs/types/src_crate_builder_types.UnverifiedContext.html +0 -1
  46. package/docs/variables/src_crate_builder_CrateManager_lib.urlProtocols.html +0 -1
  47. package/index.html +0 -13
  48. package/load-data-packs.cjs +0 -38
  49. package/postcss.config.cjs +0 -6
  50. package/public/favicon.ico +0 -0
  51. package/public/index.html +0 -43
  52. package/public/logo192.png +0 -0
  53. package/public/logo512.png +0 -0
  54. package/public/manifest.json +0 -25
  55. package/public/marker-icon.png +0 -0
  56. package/public/marker-shadow.png +0 -0
  57. package/public/robots.txt +0 -3
  58. package/react-app-env.d.ts +0 -1
  59. package/rollup.config.js +0 -26
  60. package/src/app/App.tsx +0 -13
  61. package/src/app/EmbeddedComponent.tsx +0 -432
  62. package/src/app/index.html +0 -20
  63. package/src/app/index.tsx +0 -19
  64. package/src/app/lookup.ts +0 -141
  65. package/src/app/override-styles.css +0 -96
  66. package/src/crate-builder/CrateManager/contexts/1.1-context.jsonld +0 -2660
  67. package/src/crate-builder/CrateManager/contexts/1.2-DRAFT-context.jsonld +0 -2918
  68. package/src/crate-builder/CrateManager/contexts.ts +0 -42
  69. package/src/crate-builder/CrateManager/crate-manager-benchmarking.spec.ts +0 -31
  70. package/src/crate-builder/CrateManager/crate-manager-loading-exporting.spec.ts +0 -431
  71. package/src/crate-builder/CrateManager/crate-manager-operations.spec.ts +0 -298
  72. package/src/crate-builder/CrateManager/crate-manager.spec.ts +0 -2336
  73. package/src/crate-builder/CrateManager/crate-manager.ts +0 -2111
  74. package/src/crate-builder/CrateManager/lib.spec.ts +0 -133
  75. package/src/crate-builder/CrateManager/lib.ts +0 -170
  76. package/src/crate-builder/CrateManager/profile-manager.spec.ts +0 -593
  77. package/src/crate-builder/CrateManager/profile-manager.ts +0 -367
  78. package/src/crate-builder/CrateManager/schema-type-definitions.json +0 -35122
  79. package/src/crate-builder/CrateManager/validate-identifier.spec.ts +0 -82
  80. package/src/crate-builder/CrateManager/validate-identifier.ts +0 -65
  81. package/src/crate-builder/RenderEntity/Add.tsx +0 -249
  82. package/src/crate-builder/RenderEntity/AddControl.stories.tsx +0 -126
  83. package/src/crate-builder/RenderEntity/AddControl.tsx +0 -84
  84. package/src/crate-builder/RenderEntity/AutoComplete.tsx +0 -215
  85. package/src/crate-builder/RenderEntity/BulkAdd.tsx +0 -136
  86. package/src/crate-builder/RenderEntity/DeleteProperty.tsx +0 -33
  87. package/src/crate-builder/RenderEntity/DialogAddProperty.tsx +0 -83
  88. package/src/crate-builder/RenderEntity/DialogBrowseEntities.tsx +0 -136
  89. package/src/crate-builder/RenderEntity/DialogEditContext.tsx +0 -107
  90. package/src/crate-builder/RenderEntity/DialogPreviewCrate.tsx +0 -54
  91. package/src/crate-builder/RenderEntity/DialogSaveCrateAsTemplate.tsx +0 -65
  92. package/src/crate-builder/RenderEntity/DialogSaveEntityTemplate.tsx +0 -87
  93. package/src/crate-builder/RenderEntity/DisplayPropertyName.stories.tsx +0 -30
  94. package/src/crate-builder/RenderEntity/DisplayPropertyName.tsx +0 -21
  95. package/src/crate-builder/RenderEntity/EntityId.tsx +0 -75
  96. package/src/crate-builder/RenderEntity/EntityName.tsx +0 -49
  97. package/src/crate-builder/RenderEntity/EntityProperty.tsx +0 -188
  98. package/src/crate-builder/RenderEntity/EntityPropertyInstance.tsx +0 -255
  99. package/src/crate-builder/RenderEntity/EntityType.tsx +0 -95
  100. package/src/crate-builder/RenderEntity/ItemLink.tsx +0 -37
  101. package/src/crate-builder/RenderEntity/PaginateLinkedEntities.stories.tsx +0 -43
  102. package/src/crate-builder/RenderEntity/PaginateLinkedEntities.tsx +0 -141
  103. package/src/crate-builder/RenderEntity/PropertyHelp.tsx +0 -39
  104. package/src/crate-builder/RenderEntity/RenderControls.tsx +0 -278
  105. package/src/crate-builder/RenderEntity/RenderLinkedItem.tsx +0 -139
  106. package/src/crate-builder/RenderEntity/RenderPropertyHelp.tsx +0 -41
  107. package/src/crate-builder/RenderEntity/RenderReverseConnections.tsx +0 -150
  108. package/src/crate-builder/RenderEntity/RenderTypes.tsx +0 -102
  109. package/src/crate-builder/RenderEntity/Shell2.tsx +0 -576
  110. package/src/crate-builder/RenderEntity/UnlinkEntity.tsx +0 -30
  111. package/src/crate-builder/RenderEntity/auto-complete.lib.ts +0 -184
  112. package/src/crate-builder/RenderEntity/keys.ts +0 -4
  113. package/src/crate-builder/RenderEntity/layout.spec.js +0 -593
  114. package/src/crate-builder/RenderEntity/layout.ts +0 -220
  115. package/src/crate-builder/Shell.tsx +0 -337
  116. package/src/crate-builder/component.css +0 -65
  117. package/src/crate-builder/editor-state.ts +0 -114
  118. package/src/crate-builder/emotionCache.ts +0 -8
  119. package/src/crate-builder/helpers.ts +0 -16
  120. package/src/crate-builder/i18n.ts +0 -22
  121. package/src/crate-builder/lib/validate-iri.js +0 -69
  122. package/src/crate-builder/lib/validate-iri.ts +0 -57
  123. package/src/crate-builder/locales/en.js +0 -149
  124. package/src/crate-builder/locales/hu.js +0 -147
  125. package/src/crate-builder/primitives/Boolean.stories.tsx +0 -33
  126. package/src/crate-builder/primitives/Boolean.tsx +0 -67
  127. package/src/crate-builder/primitives/Date.stories.tsx +0 -32
  128. package/src/crate-builder/primitives/Date.tsx +0 -58
  129. package/src/crate-builder/primitives/DateTime.stories.tsx +0 -32
  130. package/src/crate-builder/primitives/DateTime.tsx +0 -64
  131. package/src/crate-builder/primitives/Geo.stories.tsx +0 -57
  132. package/src/crate-builder/primitives/Geo.tsx +0 -225
  133. package/src/crate-builder/primitives/Map.SelectArea.js +0 -359
  134. package/src/crate-builder/primitives/Map.stories.tsx +0 -61
  135. package/src/crate-builder/primitives/Map.tsx +0 -124
  136. package/src/crate-builder/primitives/Number.stories.tsx +0 -74
  137. package/src/crate-builder/primitives/Number.tsx +0 -166
  138. package/src/crate-builder/primitives/Select.stories.tsx +0 -66
  139. package/src/crate-builder/primitives/Select.tsx +0 -121
  140. package/src/crate-builder/primitives/SelectObject.stories.tsx +0 -29
  141. package/src/crate-builder/primitives/SelectObject.tsx +0 -105
  142. package/src/crate-builder/primitives/SelectUrl.stories.tsx +0 -42
  143. package/src/crate-builder/primitives/SelectUrl.tsx +0 -110
  144. package/src/crate-builder/primitives/Text.stories.tsx +0 -106
  145. package/src/crate-builder/primitives/Text.tsx +0 -197
  146. package/src/crate-builder/primitives/Time.stories.tsx +0 -38
  147. package/src/crate-builder/primitives/Time.tsx +0 -71
  148. package/src/crate-builder/primitives/Url.stories.tsx +0 -43
  149. package/src/crate-builder/primitives/Url.tsx +0 -75
  150. package/src/crate-builder/primitives/Value.stories.tsx +0 -37
  151. package/src/crate-builder/primitives/Value.tsx +0 -30
  152. package/src/crate-builder/primitives/date-libs.ts +0 -12
  153. package/src/crate-builder/profile-schema.json +0 -145
  154. package/src/crate-builder/property-definitions.ts +0 -78
  155. package/src/crate-builder/recrate.css +0 -3
  156. package/src/crate-builder/store.ts +0 -14
  157. package/src/crate-builder/tailwind.css +0 -5
  158. package/src/crate-builder/types.d.ts +0 -318
  159. package/src/examples/collection/collections-entity-example.json +0 -131
  160. package/src/examples/collection/crate-builder-entity-example.json +0 -33
  161. package/src/examples/item/complex-collection/ro-crate-metadata.json +0 -174
  162. package/src/examples/item/complex-item/ro-crate-metadata.json +0 -769
  163. package/src/examples/item/crate-with-language.json +0 -38
  164. package/src/examples/item/empty/ro-crate-metadata.json +0 -20
  165. package/src/examples/item/item-with-relationship-and-action/ro-crate-metadata.json +0 -66
  166. package/src/examples/item/large-crate/ro-crate-metadata.json +0 -5762
  167. package/src/examples/item/multiple-types/ro-crate-metadata.json +0 -20
  168. package/src/examples/item/ridiculously-big-collection/ro-crate-metadata.json +0 -162977
  169. package/src/examples/profile/aroma.complex.profile.json +0 -11098
  170. package/src/examples/profile/aroma.profile.json +0 -9158
  171. package/src/examples/profile/nyingarn-item-profile.json +0 -426
  172. package/src/examples/profile/profile-to-test-inverse-associations.json +0 -73
  173. package/src/examples/profile/profile-to-test-multiple-types.json +0 -31
  174. package/src/examples/profile/profile-with-all-primitives-and-groups.json +0 -207
  175. package/src/examples/profile/profile-with-all-primitives.json +0 -244
  176. package/src/examples/profile/profile-with-constraints.json +0 -446
  177. package/src/examples/profile/profile-with-resolve.json +0 -57
  178. package/src/examples/profile/vocabulary-creation-profile.json +0 -231
  179. package/src/images.d.ts +0 -5
  180. package/src/index.ts +0 -12
  181. package/src/types.ts +0 -104
  182. package/tailwind.config.js +0 -21
  183. package/tsconfig.app.json +0 -31
  184. package/tsconfig.json +0 -26
  185. package/typedoc.json +0 -11
  186. package/update-deps.sh +0 -4
  187. package/vite-env.d.ts +0 -1
  188. package/vite.config.ts +0 -46
@@ -1,367 +0,0 @@
1
- import schemaOrgTypeDefinitions from "./schema-type-definitions.json";
2
- import isArray from "lodash/isArray";
3
- import isEmpty from "lodash/isEmpty";
4
- import flattenDeep from "lodash/flattenDeep";
5
- import cloneDeep from "lodash/cloneDeep";
6
- import orderBy from "lodash/orderBy";
7
- import has from "lodash/has";
8
- import compact from "lodash/compact";
9
- import uniq from "lodash/uniq";
10
- import uniqBy from "lodash/uniqBy";
11
- import intersection from "lodash/intersection";
12
- import type {
13
- NormalisedProfile,
14
- NormalisedEntityDefinition,
15
- ProfileLayout,
16
- ProfileInput,
17
- EntityReference,
18
- } from "../types";
19
-
20
- /**
21
- * @class
22
- *
23
- * ProfileManager
24
- *
25
- * A class to work with Describo Profiles
26
- *
27
- * @param {profile} - profile to handle
28
- */
29
- export class ProfileManager {
30
- profile?: NormalisedProfile;
31
- $key?: number;
32
- context?: any;
33
-
34
- constructor({ profile }: { profile?: NormalisedProfile }) {
35
- if (profile) {
36
- this.profile = profile;
37
- this.__processInputs();
38
- }
39
- }
40
-
41
- /**
42
- * Process input definitions for certain types.
43
- *
44
- * For now it takes care of setting 'handlesMultipleValues' for input types, which can have multiple values
45
- * but handle all values themselves and not require a new render property added for each new value. This is the
46
- * case for checbox style selects. It provides the same functionality as a normal select but all values are
47
- * visible and selectable at once and not one by one.
48
- *
49
- * It also makes sure that for radio style selects "multiple" is always set to "false", as radio input only
50
- * provides a single value selected form many.
51
- *
52
- * @private
53
- */
54
- private __processInputs() {
55
- if (!this.profile?.classes) return;
56
-
57
- for (const className in this.profile.classes) {
58
- const classDefinition = this.profile.classes[className];
59
- if (!classDefinition.inputs) continue;
60
-
61
- classDefinition.inputs = classDefinition.inputs.map(input => {
62
- if (input.type.includes("Select") && input.style === "checkbox") {
63
- return {
64
- ...input,
65
- multiple: false, // must set explicitly, otherwise will be set to true implicitly later
66
- handlesMultipleValues: true
67
- };
68
- } else if (input.type.includes("Select") && input.style === "radio") {
69
- return {
70
- ...input,
71
- multiple: false, // on case of radio, it must always be false
72
- };
73
- }
74
-
75
- return input;
76
- });
77
- }
78
- }
79
-
80
- /**
81
- *
82
- * Get the layout for an entity from the profile
83
- *
84
- * Returns the first matching layout from the profile
85
- *
86
- * @param { Object } options
87
- * @param { Object } options.entity - the entity whose layout is required
88
- *
89
- */
90
- getLayout({
91
- entity,
92
- }: {
93
- entity: NormalisedEntityDefinition | EntityReference;
94
- }): ProfileLayout | null {
95
- // no layout defined in profile
96
- if (!this.profile?.layouts || !this.profile.layouts.length) return null;
97
- let layouts = this.profile.layouts;
98
- let layout = layouts.filter((layout) => {
99
- return intersection(layout.appliesTo, (entity as any)["@type"]).length;
100
- });
101
-
102
- // no matching layout found
103
- if (!layout.length) return null;
104
-
105
- // match found - make sure it has about and overflow placeholders
106
- let firstMatchingLayout = layout[0];
107
- if (!firstMatchingLayout.about) {
108
- firstMatchingLayout.about = {
109
- name: "about",
110
- label: "About",
111
- inputs: [],
112
- order: 0,
113
- };
114
- }
115
- if (!firstMatchingLayout.overflow) {
116
- firstMatchingLayout.overflow = {
117
- name: "overflow",
118
- label: "...",
119
- inputs: [],
120
- order: Object.keys(layout).length,
121
- };
122
- }
123
-
124
- // return it
125
- return firstMatchingLayout;
126
- }
127
-
128
- /**
129
- * Get inverse associations from the profile if any are defined
130
- */
131
- getPropertyAssociations(): { [key: string]: { property: string; propertyId: string } } {
132
- if (!this.profile?.propertyAssociations) return {};
133
-
134
- // create the associations both ways and return
135
- const associations: { [key: string]: { property: string; propertyId: string } } = {};
136
- this.profile.propertyAssociations.forEach((a) => {
137
- associations[a.property] = a.inverse;
138
- associations[a.inverse.property] = { property: a.property, propertyId: a.propertyId };
139
- });
140
- return associations;
141
- }
142
-
143
- /**
144
- *
145
- * Get the available classes
146
- * if a profile is defined, get those
147
- *
148
- * Returns the classes defined in the profile if one is applied
149
- * or all of the classes built into the base, schema.org profile
150
- *
151
- */
152
- getClasses() {
153
- if (this.profile?.classes) {
154
- return Object.keys(this.profile?.classes).sort();
155
- } else {
156
- return Object.keys(schemaOrgTypeDefinitions).sort();
157
- }
158
- }
159
-
160
- /**
161
- *
162
- * Return the type hierarchy for the given entity
163
- *
164
- * @param { Object } options
165
- * @param { Object } options.entity - the entity whose hierarchy is required
166
- *
167
- *
168
- */
169
- getEntityTypeHierarchy({ entity }: { entity: NormalisedEntityDefinition }) {
170
- let types = entity["@type"];
171
- types = this.mapTypeHierarchies({ types });
172
- return types;
173
- }
174
-
175
- /**
176
- *
177
- * Given an entity, try to find a definition for the property in the profile or
178
- * right across the hierarchy
179
- *
180
- * @param { Object } options
181
- * @param { Object } options.property - the property to define
182
- * @param { Object } options.entity - the entity this property is a part of
183
- *
184
- */
185
- getPropertyDefinition({
186
- property,
187
- entity,
188
- }: {
189
- property: string;
190
- entity: NormalisedEntityDefinition;
191
- }) {
192
- let propertyDefinition = {} as ProfileInput;
193
- let inputs = this.getInputsFromProfile({ entity });
194
- if (inputs.length) {
195
- // we found an entity definition in the profile - do we have a property definition?
196
- let definition = inputs.filter((p) => p.name.toLowerCase() === property.toLowerCase());
197
- if (definition.length) {
198
- // console.debug(
199
- // "PROFILE property definition:",
200
- // JSON.stringify(propertyDefinition, null, 2)
201
- // );
202
- propertyDefinition = cloneDeep(definition[0]);
203
- }
204
- }
205
- // unable to locate a property definition in the profile - look in schema.org
206
- if (isEmpty(propertyDefinition)) {
207
- let { inputs } = this.getAllInputs({ entity });
208
- let definition = inputs.filter((p) => p.name.toLowerCase() === property.toLowerCase());
209
- if (definition.length) {
210
- // console.debug(
211
- // "SCHEMA ORG property definition:",
212
- // JSON.stringify(propertyDefinition, null, 2)
213
- // );
214
- propertyDefinition = cloneDeep(definition[0]);
215
- }
216
- }
217
-
218
- // unable to locate a property definition in schema.org - create a default one
219
- if (isEmpty(propertyDefinition)) {
220
- // console.debug(
221
- // "DEFAULT property definition:",
222
- // JSON.stringify(propertyDefinition, null, 2)
223
- // );
224
- propertyDefinition = {
225
- id: "",
226
- name: "",
227
- type: ["Text"],
228
- help: "",
229
- multiple: true,
230
- };
231
- }
232
-
233
- if (!isArray(propertyDefinition.type)) {
234
- propertyDefinition.type = [propertyDefinition.type];
235
- }
236
- if (!has(propertyDefinition, "multiple")) propertyDefinition.multiple = true;
237
-
238
- return { propertyDefinition };
239
- }
240
-
241
- /**
242
- *
243
- * Given a set of types, figure out the type hierarchy taking into account
244
- * the parent types that this is a subClassOf
245
- */
246
- mapTypeHierarchies({ types }: { types: string[] }) {
247
- types = cloneDeep(types);
248
- if (!types.includes("Thing")) types.push("Thing");
249
-
250
- types = flattenDeep(
251
- types.map((type) => [type, this.profile?.classes?.[type]?.subClassOf ?? []])
252
- );
253
- types = compact(types);
254
-
255
- types = flattenDeep(
256
- types.map((type) => {
257
- return [
258
- type,
259
- (schemaOrgTypeDefinitions as { [key: string]: { hierarchy: string[] } })[type]
260
- ?.hierarchy ?? ["Thing"],
261
- ];
262
- })
263
- );
264
- types = uniq(types);
265
- return types;
266
- }
267
-
268
- /**
269
- *
270
- * Given an entity, get the inputs defined in the profile
271
- *
272
- * @param { Object } options
273
- * @param { Object } options.entity - the entity
274
- *
275
- */
276
- getInputsFromProfile({ entity }: { entity: NormalisedEntityDefinition }): ProfileInput[] {
277
- let types = entity["@type"];
278
-
279
- let inputs: ProfileInput[] = [];
280
- for (let type of types) {
281
- if (this.profile?.classes?.[type]) {
282
- // yes - get it
283
- inputs = [...inputs, ...cloneDeep(this.profile?.classes?.[type].inputs)];
284
- }
285
-
286
- // if the definition is set to inherit, and this class is a subclass of others,
287
- // go and get those inputs as well
288
- if (
289
- this.profile?.classes?.[type]?.definition === "inherit" &&
290
- this.profile?.classes?.[type]?.subClassOf
291
- ) {
292
- for (let parentClass of this.profile?.classes?.[type]?.subClassOf) {
293
- inputs = [
294
- ...inputs,
295
- ...cloneDeep(this.profile?.classes?.[parentClass]?.inputs ?? []),
296
- ];
297
- }
298
- }
299
- }
300
- return uniqBy(inputs, "id");
301
- }
302
-
303
- /**
304
- *
305
- * Given an entity, get all available inputs by joining the profile with schema.org
306
- *
307
- * @param { Object } options
308
- * @param { Object } options.entity - the entity
309
- */
310
- getAllInputs({ entity }: { entity: NormalisedEntityDefinition }): { inputs: ProfileInput[] } {
311
- // let getInputsFunction = getInputs.bind(this);
312
- const hierarchy = this.getEntityTypeHierarchy({ entity });
313
- let inputs = [];
314
-
315
- const getInputs = (type: string) => {
316
- let inputs = [];
317
- if (this.profile?.classes?.[type]) {
318
- // type defined in profile - get those inputs
319
- inputs.push(this.profile.classes[type].inputs);
320
- }
321
- if (this.profile?.classes?.[type]?.definition === "inherit") {
322
- // profile type definition set to inherit - collect schema.org inputs
323
- inputs.push((schemaOrgTypeDefinitions as any)[type].inputs);
324
- }
325
- if (!this.profile?.classes?.[type]) {
326
- // no definition in profile - collect schema.org inputs
327
- inputs.push((schemaOrgTypeDefinitions as any)?.[type]?.inputs);
328
- }
329
- return inputs;
330
- };
331
-
332
- for (let type of hierarchy) {
333
- inputs.push(getInputs(type));
334
- }
335
- inputs = flattenDeep(inputs);
336
- inputs = compact(inputs);
337
- inputs = uniqBy(inputs, "id");
338
- inputs = orderBy(inputs, "name");
339
- return { inputs };
340
- }
341
-
342
- /**
343
- *
344
- * Try to get a definition from the profile and see if it's override or inherit
345
- *
346
- * If there's an override then return override - otherwise inherit. Exclusive rather than inclusive.
347
- *
348
- * @param { Object } options
349
- * @param { Object } options.entity - the entity
350
- * if there's an override then set to override - otherwise inherit
351
- * be exclusive rather than inclusive
352
- */
353
- getTypeDefinition({ entity }: { entity: NormalisedEntityDefinition }) {
354
- let types = entity["@type"];
355
- let directive = types.map((type) => this.profile?.classes?.[type]?.definition);
356
- return directive.includes("override") ? "override" : "inherit";
357
- }
358
-
359
- /**
360
- * Get an entity label if defined
361
- *
362
- * @property the type name to localise
363
- */
364
- getTypeLabel(type: string) {
365
- return this.profile?.localisation?.[type] ?? type;
366
- }
367
- }