@arpproject/recrate 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/.eslintrc.json +37 -0
  2. package/.storybook/main.ts +40 -0
  3. package/.storybook/preview.tsx +46 -0
  4. package/LICENCE +18 -0
  5. package/README.md +83 -0
  6. package/babel.config.json +5 -0
  7. package/dist/app/App.d.ts +2 -0
  8. package/dist/app/EmbeddedComponent.d.ts +3 -0
  9. package/dist/app/index.d.ts +0 -0
  10. package/dist/app/lookup.d.ts +82 -0
  11. package/dist/crate-builder/CrateManager/contexts.d.ts +6 -0
  12. package/dist/crate-builder/CrateManager/crate-manager-benchmarking.spec.d.ts +1 -0
  13. package/dist/crate-builder/CrateManager/crate-manager-loading-exporting.spec.d.ts +1 -0
  14. package/dist/crate-builder/CrateManager/crate-manager-operations.spec.d.ts +0 -0
  15. package/dist/crate-builder/CrateManager/crate-manager.d.ts +641 -0
  16. package/dist/crate-builder/CrateManager/crate-manager.spec.d.ts +1 -0
  17. package/dist/crate-builder/CrateManager/lib.d.ts +26 -0
  18. package/dist/crate-builder/CrateManager/lib.spec.d.ts +1 -0
  19. package/dist/crate-builder/CrateManager/profile-manager.d.ts +143 -0
  20. package/dist/crate-builder/CrateManager/profile-manager.spec.d.ts +1 -0
  21. package/dist/crate-builder/CrateManager/schema-type-definitions.json.d.ts +35125 -0
  22. package/dist/crate-builder/CrateManager/validate-identifier.d.ts +10 -0
  23. package/dist/crate-builder/CrateManager/validate-identifier.spec.d.ts +1 -0
  24. package/dist/crate-builder/RenderEntity/Add.d.ts +26 -0
  25. package/dist/crate-builder/RenderEntity/AddControl.d.ts +14 -0
  26. package/dist/crate-builder/RenderEntity/AddControl.stories.d.ts +29 -0
  27. package/dist/crate-builder/RenderEntity/AutoComplete.d.ts +12 -0
  28. package/dist/crate-builder/RenderEntity/BulkAdd.d.ts +10 -0
  29. package/dist/crate-builder/RenderEntity/DeleteProperty.d.ts +8 -0
  30. package/dist/crate-builder/RenderEntity/DialogAddProperty.d.ts +9 -0
  31. package/dist/crate-builder/RenderEntity/DialogBrowseEntities.d.ts +8 -0
  32. package/dist/crate-builder/RenderEntity/DialogEditContext.d.ts +8 -0
  33. package/dist/crate-builder/RenderEntity/DialogPreviewCrate.d.ts +7 -0
  34. package/dist/crate-builder/RenderEntity/DialogSaveCrateAsTemplate.d.ts +13 -0
  35. package/dist/crate-builder/RenderEntity/DialogSaveEntityTemplate.d.ts +14 -0
  36. package/dist/crate-builder/RenderEntity/DisplayPropertyName.d.ts +8 -0
  37. package/dist/crate-builder/RenderEntity/DisplayPropertyName.stories.d.ts +6 -0
  38. package/dist/crate-builder/RenderEntity/EntityId.d.ts +13 -0
  39. package/dist/crate-builder/RenderEntity/EntityName.d.ts +13 -0
  40. package/dist/crate-builder/RenderEntity/EntityProperty.d.ts +19 -0
  41. package/dist/crate-builder/RenderEntity/EntityPropertyInstance.d.ts +25 -0
  42. package/dist/crate-builder/RenderEntity/EntityType.d.ts +12 -0
  43. package/dist/crate-builder/RenderEntity/ItemLink.d.ts +14 -0
  44. package/dist/crate-builder/RenderEntity/PaginateLinkedEntities.d.ts +23 -0
  45. package/dist/crate-builder/RenderEntity/PaginateLinkedEntities.stories.d.ts +7 -0
  46. package/dist/crate-builder/RenderEntity/PropertyHelp.d.ts +6 -0
  47. package/dist/crate-builder/RenderEntity/RenderControls.d.ts +22 -0
  48. package/dist/crate-builder/RenderEntity/RenderLinkedItem.d.ts +20 -0
  49. package/dist/crate-builder/RenderEntity/RenderPropertyHelp.d.ts +6 -0
  50. package/dist/crate-builder/RenderEntity/RenderReverseConnections.d.ts +16 -0
  51. package/dist/crate-builder/RenderEntity/RenderTypes.d.ts +6 -0
  52. package/dist/crate-builder/RenderEntity/Shell2.d.ts +14 -0
  53. package/dist/crate-builder/RenderEntity/UnlinkEntity.d.ts +14 -0
  54. package/dist/crate-builder/RenderEntity/auto-complete.lib.d.ts +25 -0
  55. package/dist/crate-builder/RenderEntity/keys.d.ts +4 -0
  56. package/dist/crate-builder/RenderEntity/layout.d.ts +14 -0
  57. package/dist/crate-builder/RenderEntity/layout.spec.d.ts +1 -0
  58. package/dist/crate-builder/Shell.d.ts +40 -0
  59. package/dist/crate-builder/editor-state.d.ts +72 -0
  60. package/dist/crate-builder/helpers.d.ts +9 -0
  61. package/dist/crate-builder/i18n.d.ts +2 -0
  62. package/dist/crate-builder/lib/validate-iri.d.ts +6 -0
  63. package/dist/crate-builder/locales/en.d.ts +79 -0
  64. package/dist/crate-builder/locales/hu.d.ts +79 -0
  65. package/dist/crate-builder/primitives/Boolean.d.ts +11 -0
  66. package/dist/crate-builder/primitives/Boolean.stories.d.ts +7 -0
  67. package/dist/crate-builder/primitives/Date.d.ts +11 -0
  68. package/dist/crate-builder/primitives/Date.stories.d.ts +5 -0
  69. package/dist/crate-builder/primitives/DateTime.d.ts +11 -0
  70. package/dist/crate-builder/primitives/DateTime.stories.d.ts +5 -0
  71. package/dist/crate-builder/primitives/Geo.d.ts +12 -0
  72. package/dist/crate-builder/primitives/Geo.stories.d.ts +26 -0
  73. package/dist/crate-builder/primitives/Map.SelectArea.d.ts +9 -0
  74. package/dist/crate-builder/primitives/Map.d.ts +15 -0
  75. package/dist/crate-builder/primitives/Map.stories.d.ts +6 -0
  76. package/dist/crate-builder/primitives/Number.d.ts +16 -0
  77. package/dist/crate-builder/primitives/Number.stories.d.ts +10 -0
  78. package/dist/crate-builder/primitives/Select.d.ts +15 -0
  79. package/dist/crate-builder/primitives/Select.stories.d.ts +9 -0
  80. package/dist/crate-builder/primitives/SelectObject.d.ts +13 -0
  81. package/dist/crate-builder/primitives/SelectObject.stories.d.ts +5 -0
  82. package/dist/crate-builder/primitives/SelectUrl.d.ts +14 -0
  83. package/dist/crate-builder/primitives/SelectUrl.stories.d.ts +7 -0
  84. package/dist/crate-builder/primitives/Text.d.ts +19 -0
  85. package/dist/crate-builder/primitives/Text.stories.d.ts +13 -0
  86. package/dist/crate-builder/primitives/Time.d.ts +11 -0
  87. package/dist/crate-builder/primitives/Time.stories.d.ts +7 -0
  88. package/dist/crate-builder/primitives/Url.d.ts +11 -0
  89. package/dist/crate-builder/primitives/Url.stories.d.ts +7 -0
  90. package/dist/crate-builder/primitives/Value.d.ts +7 -0
  91. package/dist/crate-builder/primitives/Value.stories.d.ts +7 -0
  92. package/dist/crate-builder/primitives/date-libs.d.ts +1 -0
  93. package/dist/crate-builder/property-definitions.d.ts +78 -0
  94. package/dist/crate-builder/store.d.ts +8 -0
  95. package/dist/favicon.ico +0 -0
  96. package/dist/index.d.ts +3 -0
  97. package/dist/index.html +43 -0
  98. package/dist/logo192.png +0 -0
  99. package/dist/logo512.png +0 -0
  100. package/dist/manifest.json +25 -0
  101. package/dist/marker-icon.png +0 -0
  102. package/dist/marker-shadow.png +0 -0
  103. package/dist/recrate.es.js +158699 -0
  104. package/dist/recrate.umd.js +158717 -0
  105. package/dist/robots.txt +3 -0
  106. package/dist/style.css +1721 -0
  107. package/dist/types.d.ts +42 -0
  108. package/docker-compose.yml +30 -0
  109. package/docs/.nojekyll +1 -0
  110. package/docs/assets/highlight.css +99 -0
  111. package/docs/assets/icons.js +18 -0
  112. package/docs/assets/icons.svg +1 -0
  113. package/docs/assets/main.js +60 -0
  114. package/docs/assets/navigation.js +1 -0
  115. package/docs/assets/search.js +1 -0
  116. package/docs/assets/style.css +1448 -0
  117. package/docs/classes/src_crate_builder_CrateManager_crate_manager.CrateManager.html +240 -0
  118. package/docs/classes/src_crate_builder_CrateManager_profile_manager.ProfileManager.html +42 -0
  119. package/docs/classes/src_crate_builder_editor_state.EditorState.html +28 -0
  120. package/docs/classes/src_crate_builder_types.CrateManagerType.html +57 -0
  121. package/docs/classes/src_crate_builder_types.ProfileManagerType.html +13 -0
  122. package/docs/functions/src_crate_builder_CrateManager_lib.isURL.html +2 -0
  123. package/docs/functions/src_crate_builder_CrateManager_lib.mintNewCrate.html +3 -0
  124. package/docs/functions/src_crate_builder_CrateManager_lib.normalise.html +5 -0
  125. package/docs/functions/src_crate_builder_CrateManager_lib.normaliseEntityType.html +1 -0
  126. package/docs/index.html +58 -0
  127. package/docs/interfaces/src_crate_builder_types.NormalisedCrate.html +3 -0
  128. package/docs/interfaces/src_crate_builder_types.NormalisedEntityDefinition.html +4 -0
  129. package/docs/interfaces/src_crate_builder_types.NormalisedProfile.html +9 -0
  130. package/docs/interfaces/src_crate_builder_types.ProfileLayout.html +2 -0
  131. package/docs/interfaces/src_crate_builder_types.ProfileLayoutGroup.html +9 -0
  132. package/docs/interfaces/src_crate_builder_types.UnverifiedCrate.html +3 -0
  133. package/docs/interfaces/src_crate_builder_types.UnverifiedEntityDefinition.html +4 -0
  134. package/docs/modules/src_crate_builder_CrateManager_crate_manager.html +2 -0
  135. package/docs/modules/src_crate_builder_CrateManager_lib.html +6 -0
  136. package/docs/modules/src_crate_builder_CrateManager_profile_manager.html +2 -0
  137. package/docs/modules/src_crate_builder_editor_state.html +2 -0
  138. package/docs/modules/src_crate_builder_types.html +16 -0
  139. package/docs/types/src_crate_builder_types.EntityReference.html +1 -0
  140. package/docs/types/src_crate_builder_types.NormalisedContext.html +1 -0
  141. package/docs/types/src_crate_builder_types.PrimitiveType.html +1 -0
  142. package/docs/types/src_crate_builder_types.ProfileAssociation.html +1 -0
  143. package/docs/types/src_crate_builder_types.ProfileInput.html +1 -0
  144. package/docs/types/src_crate_builder_types.UnverifiedContext.html +1 -0
  145. package/docs/variables/src_crate_builder_CrateManager_lib.urlProtocols.html +1 -0
  146. package/index.html +13 -0
  147. package/load-data-packs.cjs +38 -0
  148. package/package.json +135 -0
  149. package/postcss.config.cjs +6 -0
  150. package/public/favicon.ico +0 -0
  151. package/public/index.html +43 -0
  152. package/public/logo192.png +0 -0
  153. package/public/logo512.png +0 -0
  154. package/public/manifest.json +25 -0
  155. package/public/marker-icon.png +0 -0
  156. package/public/marker-shadow.png +0 -0
  157. package/public/robots.txt +3 -0
  158. package/react-app-env.d.ts +1 -0
  159. package/rollup.config.js +26 -0
  160. package/src/app/App.tsx +13 -0
  161. package/src/app/EmbeddedComponent.tsx +432 -0
  162. package/src/app/index.html +20 -0
  163. package/src/app/index.tsx +19 -0
  164. package/src/app/lookup.ts +141 -0
  165. package/src/app/override-styles.css +96 -0
  166. package/src/crate-builder/CrateManager/contexts/1.1-context.jsonld +2660 -0
  167. package/src/crate-builder/CrateManager/contexts/1.2-DRAFT-context.jsonld +2918 -0
  168. package/src/crate-builder/CrateManager/contexts.ts +42 -0
  169. package/src/crate-builder/CrateManager/crate-manager-benchmarking.spec.ts +31 -0
  170. package/src/crate-builder/CrateManager/crate-manager-loading-exporting.spec.ts +431 -0
  171. package/src/crate-builder/CrateManager/crate-manager-operations.spec.ts +298 -0
  172. package/src/crate-builder/CrateManager/crate-manager.spec.ts +2336 -0
  173. package/src/crate-builder/CrateManager/crate-manager.ts +2111 -0
  174. package/src/crate-builder/CrateManager/lib.spec.ts +133 -0
  175. package/src/crate-builder/CrateManager/lib.ts +170 -0
  176. package/src/crate-builder/CrateManager/profile-manager.spec.ts +593 -0
  177. package/src/crate-builder/CrateManager/profile-manager.ts +367 -0
  178. package/src/crate-builder/CrateManager/schema-type-definitions.json +35122 -0
  179. package/src/crate-builder/CrateManager/validate-identifier.spec.ts +82 -0
  180. package/src/crate-builder/CrateManager/validate-identifier.ts +65 -0
  181. package/src/crate-builder/RenderEntity/Add.tsx +249 -0
  182. package/src/crate-builder/RenderEntity/AddControl.stories.tsx +126 -0
  183. package/src/crate-builder/RenderEntity/AddControl.tsx +84 -0
  184. package/src/crate-builder/RenderEntity/AutoComplete.tsx +215 -0
  185. package/src/crate-builder/RenderEntity/BulkAdd.tsx +136 -0
  186. package/src/crate-builder/RenderEntity/DeleteProperty.tsx +33 -0
  187. package/src/crate-builder/RenderEntity/DialogAddProperty.tsx +83 -0
  188. package/src/crate-builder/RenderEntity/DialogBrowseEntities.tsx +136 -0
  189. package/src/crate-builder/RenderEntity/DialogEditContext.tsx +107 -0
  190. package/src/crate-builder/RenderEntity/DialogPreviewCrate.tsx +54 -0
  191. package/src/crate-builder/RenderEntity/DialogSaveCrateAsTemplate.tsx +65 -0
  192. package/src/crate-builder/RenderEntity/DialogSaveEntityTemplate.tsx +87 -0
  193. package/src/crate-builder/RenderEntity/DisplayPropertyName.stories.tsx +30 -0
  194. package/src/crate-builder/RenderEntity/DisplayPropertyName.tsx +21 -0
  195. package/src/crate-builder/RenderEntity/EntityId.tsx +75 -0
  196. package/src/crate-builder/RenderEntity/EntityName.tsx +49 -0
  197. package/src/crate-builder/RenderEntity/EntityProperty.tsx +188 -0
  198. package/src/crate-builder/RenderEntity/EntityPropertyInstance.tsx +255 -0
  199. package/src/crate-builder/RenderEntity/EntityType.tsx +95 -0
  200. package/src/crate-builder/RenderEntity/ItemLink.tsx +37 -0
  201. package/src/crate-builder/RenderEntity/PaginateLinkedEntities.stories.tsx +43 -0
  202. package/src/crate-builder/RenderEntity/PaginateLinkedEntities.tsx +141 -0
  203. package/src/crate-builder/RenderEntity/PropertyHelp.tsx +39 -0
  204. package/src/crate-builder/RenderEntity/RenderControls.tsx +278 -0
  205. package/src/crate-builder/RenderEntity/RenderLinkedItem.tsx +139 -0
  206. package/src/crate-builder/RenderEntity/RenderPropertyHelp.tsx +41 -0
  207. package/src/crate-builder/RenderEntity/RenderReverseConnections.tsx +150 -0
  208. package/src/crate-builder/RenderEntity/RenderTypes.tsx +102 -0
  209. package/src/crate-builder/RenderEntity/Shell2.tsx +576 -0
  210. package/src/crate-builder/RenderEntity/UnlinkEntity.tsx +30 -0
  211. package/src/crate-builder/RenderEntity/auto-complete.lib.ts +184 -0
  212. package/src/crate-builder/RenderEntity/keys.ts +4 -0
  213. package/src/crate-builder/RenderEntity/layout.spec.js +593 -0
  214. package/src/crate-builder/RenderEntity/layout.ts +220 -0
  215. package/src/crate-builder/Shell.tsx +323 -0
  216. package/src/crate-builder/component.css +65 -0
  217. package/src/crate-builder/editor-state.ts +114 -0
  218. package/src/crate-builder/helpers.ts +16 -0
  219. package/src/crate-builder/i18n.ts +22 -0
  220. package/src/crate-builder/lib/validate-iri.js +69 -0
  221. package/src/crate-builder/lib/validate-iri.ts +57 -0
  222. package/src/crate-builder/locales/en.js +149 -0
  223. package/src/crate-builder/locales/hu.js +147 -0
  224. package/src/crate-builder/primitives/Boolean.stories.tsx +33 -0
  225. package/src/crate-builder/primitives/Boolean.tsx +67 -0
  226. package/src/crate-builder/primitives/Date.stories.tsx +32 -0
  227. package/src/crate-builder/primitives/Date.tsx +58 -0
  228. package/src/crate-builder/primitives/DateTime.stories.tsx +32 -0
  229. package/src/crate-builder/primitives/DateTime.tsx +64 -0
  230. package/src/crate-builder/primitives/Geo.stories.tsx +57 -0
  231. package/src/crate-builder/primitives/Geo.tsx +225 -0
  232. package/src/crate-builder/primitives/Map.SelectArea.js +359 -0
  233. package/src/crate-builder/primitives/Map.stories.tsx +61 -0
  234. package/src/crate-builder/primitives/Map.tsx +124 -0
  235. package/src/crate-builder/primitives/Number.stories.tsx +74 -0
  236. package/src/crate-builder/primitives/Number.tsx +166 -0
  237. package/src/crate-builder/primitives/Select.stories.tsx +66 -0
  238. package/src/crate-builder/primitives/Select.tsx +122 -0
  239. package/src/crate-builder/primitives/SelectObject.stories.tsx +29 -0
  240. package/src/crate-builder/primitives/SelectObject.tsx +105 -0
  241. package/src/crate-builder/primitives/SelectUrl.stories.tsx +42 -0
  242. package/src/crate-builder/primitives/SelectUrl.tsx +110 -0
  243. package/src/crate-builder/primitives/Text.stories.tsx +106 -0
  244. package/src/crate-builder/primitives/Text.tsx +197 -0
  245. package/src/crate-builder/primitives/Time.stories.tsx +38 -0
  246. package/src/crate-builder/primitives/Time.tsx +71 -0
  247. package/src/crate-builder/primitives/Url.stories.tsx +43 -0
  248. package/src/crate-builder/primitives/Url.tsx +75 -0
  249. package/src/crate-builder/primitives/Value.stories.tsx +37 -0
  250. package/src/crate-builder/primitives/Value.tsx +30 -0
  251. package/src/crate-builder/primitives/date-libs.ts +12 -0
  252. package/src/crate-builder/profile-schema.json +145 -0
  253. package/src/crate-builder/property-definitions.ts +78 -0
  254. package/src/crate-builder/store.ts +14 -0
  255. package/src/crate-builder/tailwind.css +7 -0
  256. package/src/crate-builder/types.d.ts +318 -0
  257. package/src/examples/collection/collections-entity-example.json +131 -0
  258. package/src/examples/collection/crate-builder-entity-example.json +33 -0
  259. package/src/examples/item/complex-collection/ro-crate-metadata.json +174 -0
  260. package/src/examples/item/complex-item/ro-crate-metadata.json +769 -0
  261. package/src/examples/item/crate-with-language.json +38 -0
  262. package/src/examples/item/empty/ro-crate-metadata.json +20 -0
  263. package/src/examples/item/item-with-relationship-and-action/ro-crate-metadata.json +66 -0
  264. package/src/examples/item/large-crate/ro-crate-metadata.json +5762 -0
  265. package/src/examples/item/multiple-types/ro-crate-metadata.json +20 -0
  266. package/src/examples/item/ridiculously-big-collection/ro-crate-metadata.json +162977 -0
  267. package/src/examples/profile/aroma.complex.profile.json +11098 -0
  268. package/src/examples/profile/aroma.profile.json +9158 -0
  269. package/src/examples/profile/nyingarn-item-profile.json +426 -0
  270. package/src/examples/profile/profile-to-test-inverse-associations.json +73 -0
  271. package/src/examples/profile/profile-to-test-multiple-types.json +31 -0
  272. package/src/examples/profile/profile-with-all-primitives-and-groups.json +207 -0
  273. package/src/examples/profile/profile-with-all-primitives.json +244 -0
  274. package/src/examples/profile/profile-with-constraints.json +446 -0
  275. package/src/examples/profile/profile-with-resolve.json +57 -0
  276. package/src/examples/profile/vocabulary-creation-profile.json +231 -0
  277. package/src/images.d.ts +5 -0
  278. package/src/index.ts +10 -0
  279. package/src/types.ts +104 -0
  280. package/tailwind.config.js +20 -0
  281. package/tsconfig.app.json +31 -0
  282. package/tsconfig.json +26 -0
  283. package/typedoc.json +11 -0
  284. package/update-deps.sh +4 -0
  285. package/vite-env.d.ts +1 -0
  286. package/vite.config.ts +41 -0
@@ -0,0 +1,641 @@
1
+ import { UnverifiedContext, NormalisedContext, UnverifiedCrate, NormalisedCrate, ProfileManagerType, UnverifiedEntityDefinition, NormalisedEntityDefinition, EntityReference, PrimitiveType, NormalisedProfile } from '../types.js';
2
+ interface errorsInterface {
3
+ hasError: Boolean;
4
+ init: {
5
+ description: string;
6
+ messages: string[];
7
+ };
8
+ missingIdentifier: {
9
+ description: string;
10
+ entity: UnverifiedEntityDefinition[];
11
+ };
12
+ missingTypeDefinition: {
13
+ description: string;
14
+ entity: UnverifiedEntityDefinition[];
15
+ };
16
+ invalidIdentifier: {
17
+ description: string;
18
+ entity: UnverifiedEntityDefinition[];
19
+ };
20
+ clash: {
21
+ description: string;
22
+ messages: string[];
23
+ };
24
+ }
25
+ interface warningsInterface {
26
+ hasWarning: Boolean;
27
+ init: {
28
+ description: string;
29
+ messages: string[];
30
+ };
31
+ invalidIdentifier: {
32
+ description: string;
33
+ entity: UnverifiedEntityDefinition[];
34
+ };
35
+ clash: {
36
+ description: string;
37
+ messages: string[];
38
+ };
39
+ }
40
+ /**
41
+ * @class
42
+ *
43
+ * CrateManager
44
+ *
45
+ * A class to work with RO-Crates
46
+ *
47
+ * @param {crate} - an RO Crate to handle
48
+ */
49
+ export declare class CrateManager {
50
+ crate: {
51
+ "@context": NormalisedContext;
52
+ "@graph": Array<NormalisedEntityDefinition | undefined>;
53
+ };
54
+ pm: ProfileManagerType;
55
+ reverse: {
56
+ [key: string]: any;
57
+ };
58
+ graphLength: number;
59
+ rootDescriptor?: number;
60
+ rootDataset?: number;
61
+ entityIdIndex: {
62
+ [key: string]: number;
63
+ };
64
+ providedContext: UnverifiedContext;
65
+ contextDefinitions: {
66
+ [key: string]: boolean;
67
+ };
68
+ localContext: {
69
+ [key: string]: string;
70
+ };
71
+ entityTypes: {
72
+ [key: string]: number;
73
+ };
74
+ entityTimestamps: Boolean;
75
+ blankNodes: string[];
76
+ coreProperties: string[];
77
+ errors: errorsInterface;
78
+ warnings: warningsInterface;
79
+ constructor({ crate, pm, context, entityTimestamps, }: {
80
+ crate: UnverifiedCrate;
81
+ pm?: ProfileManagerType;
82
+ context?: UnverifiedContext;
83
+ entityTimestamps?: Boolean;
84
+ });
85
+ /** Get the context
86
+ * @returns the crate context
87
+ */
88
+ getContext(): NormalisedContext;
89
+ /**
90
+ * Set the context
91
+ *
92
+ * This is equivalent to a profile author setting a context. It gets
93
+ * used as is and data updates going forward do not get dealth with.
94
+ * @param {*} context
95
+ */
96
+ setContext(context: NormalisedContext): void;
97
+ /**
98
+ * Set a profile
99
+ *
100
+ * CrateManager can set reverse associations if defined in a profile.
101
+ *
102
+ * */
103
+ setProfileManager(pm: ProfileManagerType): void;
104
+ /**
105
+ * Get the root dataset
106
+ *
107
+ * @returns the root dataset entity
108
+ * @example
109
+
110
+ const cm = new CrateManager({ crate })
111
+ let rd = cm.getRootDataset()
112
+
113
+ */
114
+ getRootDataset(): NormalisedEntityDefinition;
115
+ getRootDescriptor(): NormalisedEntityDefinition;
116
+ /**
117
+ * Get an entity
118
+ *
119
+ * @param {Object} options
120
+ * @param {string} options.id - the id of the entity to get
121
+ * @param {boolean} options.stub - if true, only the `@id, @type and name` prop's will be returned. That is,
122
+ * you get a stub entry not the complete entity data.
123
+ * @param {boolean} options.link - if true, all the associated entities are filled out as stubs
124
+ * @param {boolean} options.materialise - if true, the entity will be created if it doesn't exist (consider
125
+ * when URL's point outside the crate, in this case, they will be created as entities inside it)
126
+ * @returns the entity
127
+ *
128
+ * @example
129
+
130
+ const cm = new CrateManager({ crate })
131
+
132
+ // get the full entity
133
+ let rd = cm.getEntity({ id: './' })
134
+
135
+ // return a stub entry
136
+ rd = cm.getEntity({ id: './', stub: true })
137
+
138
+ */
139
+ getEntity({ id, stub, link, materialise, }: {
140
+ id: string;
141
+ stub?: boolean;
142
+ link?: boolean;
143
+ materialise?: boolean;
144
+ }): NormalisedEntityDefinition | undefined;
145
+ /**
146
+ * Get Entity Types
147
+ *
148
+ * @returns an array of entity types, sorted, found in the crate
149
+ */
150
+ getEntityTypes(): string[];
151
+ /**
152
+ * @generator
153
+ *
154
+ * @param {Object} params
155
+ * @param {Number} params.limit - how many entities to return
156
+ * @param {string} params.query - a string to match against @id, @type and name
157
+ * @param {string} params.type - a string to match against @type
158
+ * @yields {entity}
159
+ * @example
160
+
161
+ const cm = new CrateManager({crate})
162
+ let entities = cm.getEntities()
163
+
164
+ for (let entity of entities) {
165
+ ...
166
+ }
167
+
168
+ To get an array just spread the return
169
+ let entities = [ ...cm.getEntities() ]
170
+
171
+ // query @id, @type and name
172
+ entities = cm.getEntities({ query: 'person' })
173
+
174
+ // query @id, @type and name for entites of type Person
175
+ entities = cm.getEntities({ query: 'person', type: 'Person' })
176
+
177
+ // query @id, @type and name for entites of type Person - limit 10 matches
178
+ entities = cm.getEntities({ query: 'person', type: 'Person', limit: 10 })
179
+
180
+ */
181
+ getEntities(params?: {
182
+ limit?: number;
183
+ query?: string;
184
+ type?: string;
185
+ }): Generator<NormalisedEntityDefinition>;
186
+ /**
187
+ *
188
+ * locateEntity
189
+ *
190
+ * Given a set of id's, find the entity or entities that link to all of them.
191
+ * This is really for finding grouping type entities like Relationships and Actions so that
192
+ * you can augment their description.
193
+ * @param { object } params
194
+ * @param { array } params.entityIds - an array of entity id's that are linked to from another entity
195
+ * @param { boolean } params.strict - if true return entities that have exactly entityIds linked. If false,
196
+ * return entities that have at least entityIds linked
197
+ * @returns [] entities matching or undefined
198
+ */
199
+ locateEntity({ entityIds, strict, }: {
200
+ entityIds: string[];
201
+ strict?: boolean;
202
+ }): NormalisedEntityDefinition[] | undefined;
203
+ /**
204
+ * resolveLinkedEntities
205
+ *
206
+ * Given an entity and a profile, if the entity matches a resolve configuration
207
+ * this method will populate the entities linked from the resolve properties
208
+ * defined in the profile.
209
+ *
210
+ * @param {Object} entity
211
+ * @param {Object} profile
212
+ *
213
+ * @returns an array of associations
214
+ * @example
215
+
216
+ // given an entity
217
+ let entity = {
218
+ "@id": "#createAction1",
219
+ "@type": ["CreateAction"],
220
+ name: "A very long named create action to demonstrate what happens with display of long names",
221
+ object: { "@id": "#person2" },
222
+ participant: { "@id": "#participant1" },
223
+ agent: { "@id": "#agent1" },
224
+ };
225
+
226
+ // and a profile with a resolve configuration
227
+ let profile = {
228
+ ...
229
+ resolve: [
230
+ {
231
+ types: [ 'Relationship', 'Related' ],
232
+ properties: [ 'source', 'target' ]
233
+ },
234
+ {
235
+ types: [ 'CreateAction', 'EditAction' ],
236
+ properties: [ 'object', 'participant', 'agent' ]
237
+ }
238
+ ]
239
+ ...
240
+ }
241
+
242
+ // get a list of the associated entities
243
+ console.log(cm.resolveLinkedEntityAssociations({ entity, profile }))
244
+
245
+
246
+ associations === [
247
+ {
248
+ property: 'object',
249
+ '@id': '#person2',
250
+ '@type': [ 'Thing' ],
251
+ name: '#person2'
252
+ },
253
+ {
254
+ property: 'participant',
255
+ '@id': '#participant1',
256
+ '@type': [ 'Thing' ],
257
+ name: '#participant1'
258
+ },
259
+ {
260
+ property: 'agent',
261
+ '@id': '#agent1',
262
+ '@type': [ 'Thing' ],
263
+ name: '#agent1'
264
+ }
265
+ ]
266
+
267
+ */
268
+ resolveLinkedEntityAssociations({ entity, profile, }: {
269
+ entity: NormalisedEntityDefinition;
270
+ profile: NormalisedProfile;
271
+ }): {
272
+ property: string;
273
+ "@id": string;
274
+ "@type": string[];
275
+ name: string;
276
+ }[] | [];
277
+ /**
278
+ * Add an entity to the graph
279
+ *
280
+ * The entity must have '@id' and '@type' defined.
281
+ *
282
+ * @param {Object} entity - an entity definition to add to the crate
283
+ * @returns the entity
284
+ * @example
285
+
286
+ const cm = new CrateManager({ crate })
287
+ let entity = {
288
+ "@id": '#e1',
289
+ "@type": "Person",
290
+ name: 'person1',
291
+ };
292
+ let r = cm.addEntity(entity);
293
+
294
+ */
295
+ addEntity(entity: UnverifiedEntityDefinition): NormalisedEntityDefinition;
296
+ /**
297
+ * Add an entity with a blank node id ('_:...') to the graph.
298
+ *
299
+ * Use this when you want to add a non contextual entity to the graph. In thoses
300
+ * cases providing an `@id` and name don't really make sense even though those properties are still required
301
+ * therefore this method simplifies the process of adding those entity types. For example,
302
+ * Actions (e.g. CreateAction), Relationships, GeoShape, GeoCoordinates etc
303
+ *
304
+ * @param {string} type - the entity type to configure for the new entity
305
+ * @returns the entity
306
+ * @example
307
+
308
+ const cm = new CrateManager({ crate })
309
+ let r = cm.addBlankNode('Relationship);
310
+
311
+ r === {
312
+ '@id': '_:Relationship1',
313
+ '@type': [ 'Relationship' ],
314
+ name: '_:Relationship1'
315
+ }
316
+
317
+ */
318
+ addBlankNode(type: string): NormalisedEntityDefinition;
319
+ /**
320
+ * Add files or folders - use addFile or addFolder in preference to this
321
+ *
322
+ * This is a helper method specifically for adding files and folders in the crate. This method
323
+ * will add the intermediate paths as 'Datasets' (as per the spec) and link everything via the hasPart
324
+ * property as required. It is assumed that the path is relative to the root of the folder.
325
+ *
326
+ * @param {object} params
327
+ * @param {string} params.path - a file or folder path
328
+ * @param {string} params.type - the type of thing being added - File or Dataset
329
+ * @returns the entity
330
+ * @example
331
+
332
+ const cm = new CrateManager({ crate })
333
+ let r = cm.addFileOrFolder('/a/b/c/file.txt);
334
+ */
335
+ addFileOrFolder({ path, type, }: {
336
+ path: string;
337
+ type: string;
338
+ }): NormalisedEntityDefinition;
339
+ /**
340
+ * Add file
341
+ *
342
+ * This is a helper method specifically for adding files to the crate. This method
343
+ * will add the intermediate paths as 'Datasets' (as per the spec) and link everything via the hasPart
344
+ * property as required. It is assumed that the path is relative to the root of the folder.
345
+ *
346
+ * @param {string} path - a file path to add - ensure the file path is relative to the folder root
347
+ * @returns the entity
348
+ * @example
349
+
350
+ const cm = new CrateManager({ crate })
351
+ let r = cm.addFile('/a/b/c/file.txt);
352
+ */
353
+ addFile(path: string): NormalisedEntityDefinition;
354
+ /**
355
+ * Add folder
356
+ *
357
+ * This is a helper method specifically for adding folders to the crate. This method
358
+ * will add the intermediate paths as 'Datasets' (as per the spec) and link everything via the hasPart
359
+ * property as required. It is assumed that the path is relative to the root of the folder.
360
+ *
361
+ * @param {string} path - a folder path to add - ensure the folder path is relative to the folder root
362
+ * @returns the entity
363
+ * @example
364
+
365
+ const cm = new CrateManager({ crate })
366
+ let r = cm.addFolder('/a/b/c);
367
+ */
368
+ addFolder(path: string): NormalisedEntityDefinition;
369
+ /**
370
+ * Delete an entity
371
+ *
372
+ * @param {Object} options
373
+ * @param {string} options.id - the id of the entity to delete from the crate
374
+ *
375
+ * @returns true if successful
376
+ * @example
377
+
378
+ const cm = new CrateManager({ crate })
379
+ cm.deleteEntity({ id: '#e1' })
380
+
381
+ */
382
+ deleteEntity({ id }: {
383
+ id: string;
384
+ }): true | undefined;
385
+ /**
386
+ * Set a property on an entity
387
+ *
388
+ * @param {Object} options
389
+ * @param {options.id} options.id - the id of the entity to add the property to
390
+ * @param {options.property } options.property - the property to add
391
+ * @param {options.value} options.value - the data to add to that property. Can be string or object with '@id'
392
+ * @returns true if successful
393
+ * @example
394
+
395
+ const cm = new CrateManager({ crate })
396
+ const authorId = chance.url();
397
+
398
+ // setting an object reference
399
+ cm.setProperty({ id: "./", property: "author", value: { "@id": authorId } });
400
+
401
+ // setting a text string
402
+ cm.setProperty({ id: "./", property: "author", value: "text" });
403
+
404
+ // setting a number
405
+ cm.setProperty({ id: "./", property: "author", value: 3 });
406
+
407
+ */
408
+ setProperty({ id, property, propertyId, value, }: {
409
+ id: string;
410
+ property: string;
411
+ propertyId?: string;
412
+ value: PrimitiveType | EntityReference;
413
+ }): boolean | undefined;
414
+ /**
415
+ * Update a property on an entity
416
+ *
417
+ * @param {Object} options
418
+ * @param {string} options.id - the id of the entity to add the property to
419
+ * @param {string} options.property - the property to add
420
+ * @param {string} options.idx - the idx of the property array to update
421
+ * @param {string} options.value - the data to add to that property, string or object with '@id'
422
+ * @example
423
+
424
+ const cm = new CrateManager({ crate })
425
+ cm.updateProperty({ id: "./", property: "@id", value: "something else" });
426
+ cm.updateProperty({ id: "./", property: "author", idx: 1, value: "new" });
427
+
428
+ */
429
+ updateProperty({ id, property, idx, value, }: {
430
+ id: string;
431
+ property: string;
432
+ idx?: number;
433
+ value: PrimitiveType | PrimitiveType[] | EntityReference;
434
+ }): NormalisedEntityDefinition | undefined | string;
435
+ /**
436
+ * Delete a specific property from the entity. That is, an instance of a property.
437
+ *
438
+ * @param {Object}
439
+ * @param {string} options.id - the id of the entity to remove the property value from
440
+ * @param {string} options.property - the property
441
+ * @param {string} options.idx - the idx of the property array to delete
442
+ * @example
443
+
444
+ const cm = new CrateManager({ crate })
445
+ cm.deleteProperty({ id: "./", property: "author", idx: 1 });
446
+
447
+ */
448
+ deleteProperty({ id, property, idx }: {
449
+ id: string;
450
+ property: string;
451
+ idx?: number;
452
+ }): void;
453
+ /**
454
+ * Ingest and link a nested json object
455
+ *
456
+ * @param {Object} options
457
+ * @param {string} options.id - the id of the entity to join the data into
458
+ * @param {string} options.property - the property to join the data into
459
+ * @param {string} options.propertyId - the propertyId of the property - ie the url to the definition
460
+ * @param {json} options.json - the data object to join in
461
+ * @example
462
+
463
+ const cm = new CrateManager({ crate })
464
+ let json = {
465
+ ...,
466
+ }
467
+ cm.ingestAndLink({
468
+ id: "./",
469
+ property: "language",
470
+ json,
471
+ });
472
+
473
+ */
474
+ ingestAndLink({ id, property, propertyId, json, }: {
475
+ id: string | undefined;
476
+ property: string | undefined;
477
+ propertyId: string | undefined;
478
+ json: UnverifiedEntityDefinition;
479
+ }): void;
480
+ /**
481
+ * Flatten a nested json object to an array
482
+ *
483
+ * @param {Object} json - a potentially nested data blob to flatten into array
484
+ * @returns an array of objects
485
+ * @example
486
+
487
+ const cm = new CrateManager({ crate })
488
+ let json = {
489
+ ...,
490
+ }
491
+ let arrayOfObjects = cm.flatten(json)
492
+
493
+ */
494
+ flatten(json: UnverifiedEntityDefinition): NormalisedEntityDefinition[];
495
+ /**
496
+ * Link two entities
497
+ *
498
+ * Link two entities via a property. If there is a profile defined
499
+ * and it has reverse associations, then they will be added.
500
+ *
501
+ * @param {Object} options
502
+ * @param {string} options.id - the id of the entity to add the association to
503
+ * @param {string} options.property - the property to add the association to
504
+ * @param {string} options.propertyId - the propertyId of the property - ie the url to the definition
505
+ * @param {object} options.value - an object with '@id' defining the association to create
506
+ * @example
507
+
508
+ const cm = new CrateManager({ crate })
509
+ cm.linkEntity({ id: './', property: 'author', value: { '@id': '#e1' }})
510
+
511
+ **/
512
+ linkEntity({ id, property, propertyId, value, }: {
513
+ id: string;
514
+ property: string;
515
+ propertyId?: string;
516
+ value: {
517
+ "@id": string;
518
+ };
519
+ }): void;
520
+ /**
521
+ * Unlink two entities
522
+ *
523
+ * Remove an association between two entities. If there is a profile defined
524
+ * and it has reverse associations, then they will be removed as well.
525
+ *
526
+ * @param {Object} options
527
+ * @param {string} options.id - the id of the entity to remove the association from
528
+ * @param {string} options.property - the property containing the association
529
+ * @param {object} options.value - an object with '@id' defining the association to remove
530
+ * @example
531
+
532
+ const cm = new CrateManager({ crate })
533
+ const cm = new CrateManager({ crate })
534
+ cm.unlinkEntity({ id: './', property: 'author', value: { '@id': '#e1' }})
535
+
536
+ **/
537
+ unlinkEntity({ id, property, value, stop, }: {
538
+ id: string | undefined;
539
+ property: string | undefined;
540
+ value: {
541
+ "@id": string;
542
+ } | undefined;
543
+ stop?: boolean;
544
+ }): void;
545
+ /**
546
+ * Purge unlinked entities from the crate
547
+ *
548
+ * Clean up the graph and purge any unlinked entities including disconnected subtrees.
549
+ * @example
550
+
551
+ const cm = new CrateManager({ crate })
552
+ cm.purgeUnlinkedEntities()
553
+
554
+ */
555
+ purgeUnlinkedEntities(): void;
556
+ /**
557
+ * Export the RO-Crate
558
+ * @returns the complete ro-crate
559
+ * @example
560
+
561
+ const cm = new CrateManager({ crate })
562
+ let crate = cm.exportCrate()
563
+
564
+ */
565
+ exportCrate(): NormalisedCrate;
566
+ /**
567
+ * exportEntityTemplate
568
+ *
569
+ * Export an entity as a template to be reused.
570
+ * 1. If resolveDepth = 0 then the entity is returned with all associations removed
571
+ * 2. If resolveDepth = 1 then the entity is returned with one level of associations populated but
572
+ * all of their associations will be removed.
573
+ *
574
+ * @param {Object} options
575
+ * @param {String} options.id - the id of the entity to export as a template
576
+ * @param {String} options.resolveDepth - 0 or 1. If 1, linked entities will be joined in
577
+ *
578
+ * @returns entity
579
+ * @example
580
+
581
+ const cm = new CrateManager({ crate })
582
+ let entity = cm.exportEntityTemplate({ id: '#person' })
583
+ let entity = cm.exportEntityTemplate({ id: '#person', resolveDepth: 1 })
584
+
585
+ */
586
+ exportEntityTemplate({ id, resolveDepth, }: {
587
+ id: string;
588
+ resolveDepth?: number;
589
+ }): NormalisedEntityDefinition;
590
+ /**
591
+ * getErrors
592
+ *
593
+ * @returns { errors }
594
+ *
595
+ */
596
+ getErrors(): errorsInterface;
597
+ /**
598
+ * getWarnings
599
+ *
600
+ * @returns { warnings }
601
+ */
602
+ getWarnings(): warningsInterface;
603
+ __updateContext({ name, id }: {
604
+ name: string;
605
+ id?: string;
606
+ }): void;
607
+ /**
608
+ * Normalise context
609
+ *
610
+ * Collapse all objects into a single object
611
+ *
612
+ * @param {*} context
613
+ * @returns context
614
+ */
615
+ __normaliseContext(context: UnverifiedContext): NormalisedContext;
616
+ __storeEntityType(entity: NormalisedEntityDefinition): void;
617
+ __removeEntityType(entity: NormalisedEntityDefinition): void;
618
+ __collectAllDefinitions(context: NormalisedContext): {
619
+ [key: string]: boolean;
620
+ };
621
+ __setError(error: keyof typeof this.errors, entity: string | UnverifiedEntityDefinition): void;
622
+ __setWarning(warning: keyof typeof this.warnings, entity: string | UnverifiedEntityDefinition): void;
623
+ __materialiseEntity({ id }: {
624
+ id: string;
625
+ }): NormalisedEntityDefinition;
626
+ __confirmNoClash({ entity, mintNewId, }: {
627
+ entity: NormalisedEntityDefinition;
628
+ mintNewId?: boolean;
629
+ }): NormalisedEntityDefinition | boolean;
630
+ __updateEntityId({ oldId, newId }: {
631
+ oldId: string;
632
+ newId: string;
633
+ }): NormalisedEntityDefinition | undefined;
634
+ __addReverse({ id, property, value, }: {
635
+ id: string;
636
+ property: string;
637
+ value: EntityReference;
638
+ }): void;
639
+ __removeAssociations(entity: NormalisedEntityDefinition): NormalisedEntityDefinition;
640
+ }
641
+ export {};
@@ -0,0 +1,26 @@
1
+ import { UnverifiedEntityDefinition, NormalisedEntityDefinition } from '../types.js';
2
+ export declare const urlProtocols: string[];
3
+ /**
4
+ *
5
+ * @param {string} value - string to check as a URL: checks 'http','https','ftp', 'arcp'
6
+ */
7
+ export declare function isURL(value: string | number | boolean | undefined | null): boolean;
8
+ /**
9
+ * This method normalises an entity. It checks that the '@type' is sensible, '@id' is valid and sets the name to the '@id' if not set
10
+ *
11
+ * @param {Object} entity - an entity to normalise
12
+ * @param {string} i - if an id is not defined, then it will be set to #e${i}
13
+ *
14
+ * @returns the entity ready for use
15
+ */
16
+ export declare function normalise(entity: UnverifiedEntityDefinition, i: number): NormalisedEntityDefinition;
17
+ export declare function normaliseEntityType({ entity }: {
18
+ entity: UnverifiedEntityDefinition;
19
+ }): string[];
20
+ /**
21
+ *
22
+ * Mint an empty RO-Crate that conforms to the spec
23
+ *
24
+ * @returns a skeleton crate ready to be used
25
+ */
26
+ export declare function mintNewCrate(): {};
@@ -0,0 +1 @@
1
+ export {};