@startinblox/core 0.17.21-beta.1 → 0.17.21-beta.11

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 (264) hide show
  1. package/dist/_snowpack/env.js +3 -0
  2. package/dist/_snowpack/pkg/autolinker.js +4281 -0
  3. package/dist/_snowpack/pkg/autolinker.js.map +1 -0
  4. package/dist/_snowpack/pkg/autolinker.js.map.proxy.js +1 -0
  5. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js +377 -0
  6. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map +1 -0
  7. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map.proxy.js +1 -0
  8. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js +22 -0
  9. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map +1 -0
  10. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map.proxy.js +1 -0
  11. package/dist/_snowpack/pkg/common/decode-a4c334cf.js +216 -0
  12. package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map +1 -0
  13. package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map.proxy.js +1 -0
  14. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js +1119 -0
  15. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map +1 -0
  16. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map.proxy.js +1 -0
  17. package/dist/_snowpack/pkg/delta-markdown-for-quill.js +25677 -0
  18. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +1 -0
  19. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map.proxy.js +1 -0
  20. package/dist/_snowpack/pkg/dialog-polyfill.js +859 -0
  21. package/dist/_snowpack/pkg/dialog-polyfill.js.map +1 -0
  22. package/dist/_snowpack/pkg/dialog-polyfill.js.map.proxy.js +1 -0
  23. package/dist/_snowpack/pkg/fusejs.js +1783 -0
  24. package/dist/_snowpack/pkg/fusejs.js.map +1 -0
  25. package/dist/_snowpack/pkg/fusejs.js.map.proxy.js +1 -0
  26. package/dist/_snowpack/pkg/import-map.json +23 -0
  27. package/dist/_snowpack/pkg/jsonld-context-parser.js +804 -0
  28. package/dist/_snowpack/pkg/jsonld-context-parser.js.map +1 -0
  29. package/dist/_snowpack/pkg/jsonld-context-parser.js.map.proxy.js +1 -0
  30. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css +640 -0
  31. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +10 -0
  32. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +60 -0
  33. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +10 -0
  34. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +14 -0
  35. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +10 -0
  36. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +40 -0
  37. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +1 -0
  38. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map.proxy.js +1 -0
  39. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +46 -0
  40. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +1 -0
  41. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map.proxy.js +1 -0
  42. package/dist/_snowpack/pkg/lit-html/directives/until.js +88 -0
  43. package/dist/_snowpack/pkg/lit-html/directives/until.js.map +1 -0
  44. package/dist/_snowpack/pkg/lit-html/directives/until.js.map.proxy.js +1 -0
  45. package/dist/_snowpack/pkg/lit-html.js +92 -0
  46. package/dist/_snowpack/pkg/lit-html.js.map +1 -0
  47. package/dist/_snowpack/pkg/lit-html.js.map.proxy.js +1 -0
  48. package/dist/_snowpack/pkg/markdown-it.js +11860 -0
  49. package/dist/_snowpack/pkg/markdown-it.js.map +1 -0
  50. package/dist/_snowpack/pkg/markdown-it.js.map.proxy.js +1 -0
  51. package/dist/_snowpack/pkg/quill/dist/quill.snow.css +945 -0
  52. package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +10 -0
  53. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +1029 -0
  54. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +1 -0
  55. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map.proxy.js +1 -0
  56. package/dist/_snowpack/pkg/quill.js +13382 -0
  57. package/dist/_snowpack/pkg/quill.js.map +1 -0
  58. package/dist/_snowpack/pkg/quill.js.map.proxy.js +1 -0
  59. package/dist/_snowpack/pkg/slim-select.js +4 -0
  60. package/dist/_snowpack/pkg/slim-select.js.map +1 -0
  61. package/dist/_snowpack/pkg/slim-select.js.map.proxy.js +1 -0
  62. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +1164 -0
  63. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +10 -0
  64. package/dist/_snowpack/pkg/tui-calendar.js +42285 -0
  65. package/dist/_snowpack/pkg/tui-calendar.js.map +1 -0
  66. package/dist/_snowpack/pkg/tui-calendar.js.map.proxy.js +1 -0
  67. package/dist/components/solid-ac-checker.js +51 -0
  68. package/dist/components/solid-ac-checker.js.map +1 -0
  69. package/dist/components/solid-calendar.js +87 -0
  70. package/dist/components/solid-calendar.js.map +1 -0
  71. package/dist/components/solid-delete.js +111 -0
  72. package/dist/components/solid-delete.js.map +1 -0
  73. package/dist/components/solid-display.js +194 -0
  74. package/dist/components/solid-display.js.map +1 -0
  75. package/dist/components/solid-form-search.js +226 -0
  76. package/dist/components/solid-form-search.js.map +1 -0
  77. package/dist/components/solid-form.js +358 -0
  78. package/dist/components/solid-form.js.map +1 -0
  79. package/dist/components/solid-lang.js +46 -0
  80. package/dist/components/solid-lang.js.map +1 -0
  81. package/dist/components/solid-map.js +242 -0
  82. package/dist/components/solid-map.js.map +1 -0
  83. package/dist/components/solid-table.js +263 -0
  84. package/dist/components/solid-table.js.map +1 -0
  85. package/dist/components/solid-widget.js +94 -0
  86. package/dist/components/solid-widget.js.map +1 -0
  87. package/dist/import.css +4 -0
  88. package/dist/index.js +43 -0
  89. package/dist/index.js.map +1 -0
  90. package/dist/libs/Component.js +19 -0
  91. package/dist/libs/Component.js.map +1 -0
  92. package/dist/libs/ComponentFactory.js +196 -0
  93. package/dist/libs/ComponentFactory.js.map +1 -0
  94. package/dist/libs/Compositor.js +103 -0
  95. package/dist/libs/Compositor.js.map +1 -0
  96. package/dist/libs/Sib.js +58 -0
  97. package/dist/libs/Sib.js.map +1 -0
  98. package/dist/libs/filter.js +214 -0
  99. package/dist/libs/filter.js.map +1 -0
  100. package/dist/libs/helpers.js +219 -0
  101. package/dist/libs/helpers.js.map +1 -0
  102. package/dist/libs/interfaces.js +6 -0
  103. package/dist/libs/interfaces.js.map +1 -0
  104. package/dist/libs/lit-helpers.js +169 -0
  105. package/dist/libs/lit-helpers.js.map +1 -0
  106. package/dist/libs/polyfills.js +40 -0
  107. package/dist/libs/polyfills.js.map +1 -0
  108. package/dist/libs/store/server-pagination.js +20 -0
  109. package/dist/libs/store/server-pagination.js.map +1 -0
  110. package/dist/libs/store/store.js +879 -0
  111. package/dist/libs/store/store.js.map +1 -0
  112. package/dist/locales/en.json +10 -0
  113. package/dist/locales/en.json.proxy.js +2 -0
  114. package/dist/locales/fr.json +10 -0
  115. package/dist/locales/fr.json.proxy.js +2 -0
  116. package/dist/mixins/attributeBinderMixin.js +126 -0
  117. package/dist/mixins/attributeBinderMixin.js.map +1 -0
  118. package/dist/mixins/contextMixin.js +28 -0
  119. package/dist/mixins/contextMixin.js.map +1 -0
  120. package/dist/mixins/counterMixin.js +75 -0
  121. package/dist/mixins/counterMixin.js.map +1 -0
  122. package/dist/mixins/federationMixin.js +65 -0
  123. package/dist/mixins/federationMixin.js.map +1 -0
  124. package/dist/mixins/filterMixin.js +136 -0
  125. package/dist/mixins/filterMixin.js.map +1 -0
  126. package/dist/mixins/grouperMixin.js +80 -0
  127. package/dist/mixins/grouperMixin.js.map +1 -0
  128. package/dist/mixins/highlighterMixin.js +42 -0
  129. package/dist/mixins/highlighterMixin.js.map +1 -0
  130. package/dist/mixins/interfaces.js +8 -0
  131. package/dist/mixins/interfaces.js.map +1 -0
  132. package/dist/mixins/listMixin.js +138 -0
  133. package/dist/mixins/listMixin.js.map +1 -0
  134. package/dist/mixins/nextMixin.js +26 -0
  135. package/dist/mixins/nextMixin.js.map +1 -0
  136. package/dist/mixins/paginateMixin.js +110 -0
  137. package/dist/mixins/paginateMixin.js.map +1 -0
  138. package/dist/mixins/requiredMixin.js +34 -0
  139. package/dist/mixins/requiredMixin.js.map +1 -0
  140. package/dist/mixins/serverPaginationMixin.js +130 -0
  141. package/dist/mixins/serverPaginationMixin.js.map +1 -0
  142. package/dist/mixins/sorterMixin.js +149 -0
  143. package/dist/mixins/sorterMixin.js.map +1 -0
  144. package/dist/mixins/storeMixin.js +111 -0
  145. package/dist/mixins/storeMixin.js.map +1 -0
  146. package/dist/mixins/translationMixin.js +68 -0
  147. package/dist/mixins/translationMixin.js.map +1 -0
  148. package/dist/mixins/validationMixin.js +113 -0
  149. package/dist/mixins/validationMixin.js.map +1 -0
  150. package/dist/mixins/widgetMixin.js +451 -0
  151. package/dist/mixins/widgetMixin.js.map +1 -0
  152. package/dist/new-widgets/attributeMixins/actionMixin.js +14 -0
  153. package/dist/new-widgets/attributeMixins/actionMixin.js.map +1 -0
  154. package/dist/new-widgets/attributeMixins/blankMixin.js +10 -0
  155. package/dist/new-widgets/attributeMixins/blankMixin.js.map +1 -0
  156. package/dist/new-widgets/attributeMixins/booleanMixin.js +10 -0
  157. package/dist/new-widgets/attributeMixins/booleanMixin.js.map +1 -0
  158. package/dist/new-widgets/attributeMixins/index.js +20 -0
  159. package/dist/new-widgets/attributeMixins/index.js.map +1 -0
  160. package/dist/new-widgets/attributeMixins/mailtoMixin.js +10 -0
  161. package/dist/new-widgets/attributeMixins/mailtoMixin.js.map +1 -0
  162. package/dist/new-widgets/attributeMixins/multipleMixin.js +28 -0
  163. package/dist/new-widgets/attributeMixins/multipleMixin.js.map +1 -0
  164. package/dist/new-widgets/attributeMixins/numberMixin.js +10 -0
  165. package/dist/new-widgets/attributeMixins/numberMixin.js.map +1 -0
  166. package/dist/new-widgets/attributeMixins/placeholderMixin.js +19 -0
  167. package/dist/new-widgets/attributeMixins/placeholderMixin.js.map +1 -0
  168. package/dist/new-widgets/attributeMixins/telMixin.js +10 -0
  169. package/dist/new-widgets/attributeMixins/telMixin.js.map +1 -0
  170. package/dist/new-widgets/baseWidgetMixin.js +122 -0
  171. package/dist/new-widgets/baseWidgetMixin.js.map +1 -0
  172. package/dist/new-widgets/callbackMixins/autocompletionMixin.js +104 -0
  173. package/dist/new-widgets/callbackMixins/autocompletionMixin.js.map +1 -0
  174. package/dist/new-widgets/callbackMixins/index.js +8 -0
  175. package/dist/new-widgets/callbackMixins/index.js.map +1 -0
  176. package/dist/new-widgets/callbackMixins/richtextMixin.js +42 -0
  177. package/dist/new-widgets/callbackMixins/richtextMixin.js.map +1 -0
  178. package/dist/new-widgets/callbackMixins/slimselect.css +2 -0
  179. package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +10 -0
  180. package/dist/new-widgets/new-widget-factory.js +96 -0
  181. package/dist/new-widgets/new-widget-factory.js.map +1 -0
  182. package/dist/new-widgets/templateAdditionMixins/addableMixin.js +41 -0
  183. package/dist/new-widgets/templateAdditionMixins/addableMixin.js.map +1 -0
  184. package/dist/new-widgets/templateAdditionMixins/index.js +14 -0
  185. package/dist/new-widgets/templateAdditionMixins/index.js.map +1 -0
  186. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +29 -0
  187. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js.map +1 -0
  188. package/dist/new-widgets/templateAdditionMixins/labelMixin.js +31 -0
  189. package/dist/new-widgets/templateAdditionMixins/labelMixin.js.map +1 -0
  190. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +36 -0
  191. package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +1 -0
  192. package/dist/new-widgets/templates/displayTemplatesDirectory.js +90 -0
  193. package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +1 -0
  194. package/dist/new-widgets/templates/formTemplatesDirectory.js +397 -0
  195. package/dist/new-widgets/templates/formTemplatesDirectory.js.map +1 -0
  196. package/dist/new-widgets/templates/groupTemplatesDirectory.js +21 -0
  197. package/dist/new-widgets/templates/groupTemplatesDirectory.js.map +1 -0
  198. package/dist/new-widgets/templates/index.js +7 -0
  199. package/dist/new-widgets/templates/index.js.map +1 -0
  200. package/dist/new-widgets/templates/setTemplatesDirectory.js +49 -0
  201. package/dist/new-widgets/templates/setTemplatesDirectory.js.map +1 -0
  202. package/dist/new-widgets/templatesDependencies/altMixin.js +13 -0
  203. package/dist/new-widgets/templatesDependencies/altMixin.js.map +1 -0
  204. package/dist/new-widgets/templatesDependencies/editableMixin.js +77 -0
  205. package/dist/new-widgets/templatesDependencies/editableMixin.js.map +1 -0
  206. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +38 -0
  207. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js.map +1 -0
  208. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +14 -0
  209. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js.map +1 -0
  210. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +51 -0
  211. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js.map +1 -0
  212. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +66 -0
  213. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js.map +1 -0
  214. package/dist/new-widgets/templatesDependencies/formFileMixin.js +81 -0
  215. package/dist/new-widgets/templatesDependencies/formFileMixin.js.map +1 -0
  216. package/dist/new-widgets/templatesDependencies/formLengthMixin.js +19 -0
  217. package/dist/new-widgets/templatesDependencies/formLengthMixin.js.map +1 -0
  218. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +19 -0
  219. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js.map +1 -0
  220. package/dist/new-widgets/templatesDependencies/formMixin.js +66 -0
  221. package/dist/new-widgets/templatesDependencies/formMixin.js.map +1 -0
  222. package/dist/new-widgets/templatesDependencies/formNumberMixin.js +14 -0
  223. package/dist/new-widgets/templatesDependencies/formNumberMixin.js.map +1 -0
  224. package/dist/new-widgets/templatesDependencies/formRadioMixin.js +16 -0
  225. package/dist/new-widgets/templatesDependencies/formRadioMixin.js.map +1 -0
  226. package/dist/new-widgets/templatesDependencies/formStepMixin.js +13 -0
  227. package/dist/new-widgets/templatesDependencies/formStepMixin.js.map +1 -0
  228. package/dist/new-widgets/templatesDependencies/linkTextMixin.js +14 -0
  229. package/dist/new-widgets/templatesDependencies/linkTextMixin.js.map +1 -0
  230. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +125 -0
  231. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +1 -0
  232. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +74 -0
  233. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js.map +1 -0
  234. package/dist/new-widgets/templatesDependencies/patternMixin.js +19 -0
  235. package/dist/new-widgets/templatesDependencies/patternMixin.js.map +1 -0
  236. package/dist/new-widgets/templatesDependencies/rangeMixin.js +110 -0
  237. package/dist/new-widgets/templatesDependencies/rangeMixin.js.map +1 -0
  238. package/dist/new-widgets/templatesDependencies/setMixin.js +12 -0
  239. package/dist/new-widgets/templatesDependencies/setMixin.js.map +1 -0
  240. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +12 -0
  241. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js.map +1 -0
  242. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +18 -0
  243. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js.map +1 -0
  244. package/dist/new-widgets/valueTransformationMixins/dateMixin.js +35 -0
  245. package/dist/new-widgets/valueTransformationMixins/dateMixin.js.map +1 -0
  246. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +16 -0
  247. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js.map +1 -0
  248. package/dist/new-widgets/valueTransformationMixins/index.js +16 -0
  249. package/dist/new-widgets/valueTransformationMixins/index.js.map +1 -0
  250. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +25 -0
  251. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js.map +1 -0
  252. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +17 -0
  253. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js.map +1 -0
  254. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +27 -0
  255. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js.map +1 -0
  256. package/dist/solid-template-element.js +164 -0
  257. package/dist/solid-template-element.js.map +1 -0
  258. package/dist/style/default-theme.css +24 -0
  259. package/dist/style/default-theme.css.proxy.js +10 -0
  260. package/dist/widgets/baseWidget.js +334 -0
  261. package/dist/widgets/baseWidget.js.map +1 -0
  262. package/dist/widgets/widget-factory.js +24 -0
  263. package/dist/widgets/widget-factory.js.map +1 -0
  264. package/package.json +1 -1
@@ -0,0 +1,879 @@
1
+ let _Symbol$toPrimitive;
2
+
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+
5
+ import JSONLDContextParser from '../../_snowpack/pkg/jsonld-context-parser.js'; //@ts-ignore
6
+
7
+ import PubSub from 'https://cdn.skypack.dev/pubsub-js';
8
+ import { appendServerPaginationToIri } from './server-pagination.js';
9
+ const ContextParser = JSONLDContextParser.ContextParser;
10
+ const myParser = new ContextParser();
11
+ export const base_context = {
12
+ '@vocab': 'http://happy-dev.fr/owl/#',
13
+ rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
14
+ rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
15
+ ldp: 'http://www.w3.org/ns/ldp#',
16
+ foaf: 'http://xmlns.com/foaf/0.1/',
17
+ name: 'rdfs:label',
18
+ acl: 'http://www.w3.org/ns/auth/acl#',
19
+ permissions: 'acl:accessControl',
20
+ mode: 'acl:mode',
21
+ geo: "http://www.w3.org/2003/01/geo/wgs84_pos#",
22
+ lat: "geo:lat",
23
+ lng: "geo:long"
24
+ };
25
+
26
+ class Store {
27
+ // index of all the containers per resource
28
+ // index of all the containers per resource
29
+ constructor(storeOptions) {
30
+ this.storeOptions = storeOptions;
31
+
32
+ _defineProperty(this, "cache", void 0);
33
+
34
+ _defineProperty(this, "subscriptionIndex", void 0);
35
+
36
+ _defineProperty(this, "subscriptionVirtualContainersIndex", void 0);
37
+
38
+ _defineProperty(this, "loadingList", void 0);
39
+
40
+ _defineProperty(this, "headers", void 0);
41
+
42
+ _defineProperty(this, "fetch", void 0);
43
+
44
+ _defineProperty(this, "session", void 0);
45
+
46
+ _defineProperty(this, "resolveResource", function (id, resolve) {
47
+ const handler = function (event) {
48
+ if (event.detail.id === id) {
49
+ resolve(event.detail.resource); // TODO : callback
50
+
51
+ document.removeEventListener('resourceReady', handler);
52
+ }
53
+ };
54
+
55
+ return handler;
56
+ });
57
+
58
+ this.cache = new Map();
59
+ this.subscriptionIndex = new Map();
60
+ this.subscriptionVirtualContainersIndex = new Map();
61
+ this.loadingList = new Set();
62
+ this.headers = {
63
+ 'Content-Type': 'application/ld+json',
64
+ 'Cache-Control': 'must-revalidate'
65
+ };
66
+ this.fetch = this.storeOptions.fetchMethod;
67
+ this.session = this.storeOptions.session;
68
+ }
69
+ /**
70
+ * Fetch data and cache it
71
+ * @param id - uri of the resource to fetch
72
+ * @param context - context used to expand id and predicates when accessing the resource
73
+ * @param parentId - uri of the parent caller used to expand uri for local files
74
+ * @param localData - data to put in cache
75
+ * @param forceFetch - force the fetch of data
76
+ *
77
+ * @returns The fetched resource
78
+ *
79
+ * @async
80
+ */
81
+
82
+
83
+ async getData(id, context = {}, parentId = "", localData, forceFetch = false, serverPagination) {
84
+ let key = id;
85
+
86
+ if (serverPagination) {
87
+ key = id + "#p" + serverPagination.limit + "?o" + serverPagination.offset;
88
+ }
89
+
90
+ if (localData == null && this.cache.has(key) && !this.loadingList.has(key)) {
91
+ var _resource$isFullResou;
92
+
93
+ const resource = this.get(key);
94
+ if (resource && (_resource$isFullResou = resource.isFullResource) !== null && _resource$isFullResou !== void 0 && _resource$isFullResou.call(resource) && !forceFetch) return resource; // if resource is not complete, re-fetch it
95
+ }
96
+
97
+ return new Promise(async resolve => {
98
+ document.addEventListener('resourceReady', this.resolveResource(key, resolve));
99
+ if (this.loadingList.has(key)) return;
100
+ this.loadingList.add(key); // Generate proxy
101
+
102
+ const clientContext = await myParser.parse(context);
103
+ let resource = null;
104
+
105
+ if (this._isLocalId(id)) {
106
+ if (localData == null) localData = {};
107
+ localData["@id"] = id;
108
+ resource = localData;
109
+ } else try {
110
+ resource = localData || (await this.fetchData(id, clientContext, parentId, serverPagination));
111
+ } catch (error) {
112
+ console.error(error);
113
+ }
114
+
115
+ if (!resource) {
116
+ this.loadingList.delete(key);
117
+ resolve(null);
118
+ return;
119
+ }
120
+
121
+ const serverContext = await myParser.parse([resource['@context'] || {}]);
122
+ const resourceProxy = new CustomGetter(key, resource, clientContext, serverContext, parentId ? parentId : key, serverPagination).getProxy(); // Cache proxy
123
+
124
+ await this.cacheGraph(key, resourceProxy, clientContext, serverContext, parentId ? parentId : key, serverPagination);
125
+ this.loadingList.delete(key);
126
+ document.dispatchEvent(new CustomEvent('resourceReady', {
127
+ detail: {
128
+ id: key,
129
+ resource: this.get(key)
130
+ }
131
+ }));
132
+ });
133
+ }
134
+
135
+ async fetchAuthn(iri, options) {
136
+ let authenticated = false;
137
+ if (this.session) authenticated = await this.session;
138
+
139
+ if (this.fetch && authenticated) {
140
+ // authenticated
141
+ return this.fetch.then(fn => fn(iri, options));
142
+ } else {
143
+ // anonymous
144
+ if (options.headers) options.headers = this._convertHeaders(options.headers);
145
+ return fetch(iri, options).then(function (response) {
146
+ if (options.method === "PURGE" && !response.ok && response.status === 404) {
147
+ const err = new Error("PURGE call is returning 404");
148
+ throw err;
149
+ }
150
+
151
+ return response;
152
+ });
153
+ }
154
+ }
155
+
156
+ async fetchData(id, context = {}, parentId = "", serverPagination) {
157
+ let iri = this._getAbsoluteIri(id, context, parentId);
158
+
159
+ if (serverPagination) iri = appendServerPaginationToIri(iri, serverPagination);
160
+ const headers = { ...this.headers,
161
+ 'accept-language': this._getLanguage(),
162
+ 'Prefer': 'return=representation; max-triple-count="500"'
163
+ };
164
+ return this.fetchAuthn(iri, {
165
+ method: 'GET',
166
+ headers: headers,
167
+ credentials: 'include'
168
+ }).then(response => {
169
+ if (!response.ok) return;
170
+ return response.json();
171
+ });
172
+ }
173
+
174
+ async cacheGraph(key, resource, clientContext, parentContext, parentId, serverPagination) {
175
+ if (resource.properties) {
176
+ // if proxy, cache it
177
+ if (this.get(key) && this.cache.get(key).merge) {
178
+ // if already cached, merge data
179
+ this.cache.get(key).merge(resource);
180
+ ;
181
+ } else {
182
+ // else, put in cache
183
+ this.cache.set(key, resource);
184
+ }
185
+ } // Cache nested resources
186
+
187
+
188
+ if (resource.getSubObjects) {
189
+ for (let res of resource.getSubObjects()) {
190
+ let newParentContext = parentContext; // If additional context in resource, use it to expand properties
191
+
192
+ if (res['@context']) newParentContext = await myParser.parse({ ...parentContext,
193
+ ...res['@context']
194
+ });
195
+ const resourceProxy = new CustomGetter(res['@id'], res, clientContext, newParentContext, parentId).getProxy(); // this.subscribeResourceTo(resource['@id'], res['@id']); // removed to prevent useless updates
196
+
197
+ await this.cacheGraph(res['@id'], resourceProxy, clientContext, parentContext, parentId, serverPagination);
198
+ }
199
+ } // Cache children of container
200
+
201
+
202
+ if (resource['@type'] == "ldp:Container" && resource.getChildren) {
203
+ const cacheChildrenPromises = []; //TODO: return complete object without the need for the fetch data from the cacheGraph
204
+
205
+ for (let res of await resource.getChildren()) {
206
+ this.subscribeResourceTo(resource['@id'], res['@id']);
207
+ cacheChildrenPromises.push(this.cacheGraph(res['@id'], res, clientContext, parentContext, parentId, serverPagination));
208
+ }
209
+
210
+ await Promise.all(cacheChildrenPromises);
211
+ return;
212
+ } // Create proxy, (fetch data) and cache resource
213
+
214
+
215
+ if (resource['@id'] && !resource.properties) {
216
+ if (resource['@id'].match(/^b\d+$/)) return; // not anonymous node
217
+ // Fetch data if
218
+
219
+ if (resource['@type'] === "sib:federatedContainer" && resource['@cache'] !== 'false') {
220
+ // if object is federated container
221
+ await this.getData(resource['@id'], clientContext, parentId); // then init graph
222
+
223
+ return;
224
+ }
225
+
226
+ const resourceProxy = new CustomGetter(key, resource, clientContext, parentContext, parentId).getProxy();
227
+ await this.cacheGraph(key, resourceProxy, clientContext, parentContext, parentId);
228
+ }
229
+ }
230
+ /**
231
+ * Update fetch
232
+ * @param method - 'POST', 'PATCH', 'PUT', '_LOCAL'
233
+ * @param resource - resource to send
234
+ * @param id - uri to update
235
+ * @returns - object
236
+ */
237
+
238
+
239
+ async _fetch(method, resource, id) {
240
+ if (method !== '_LOCAL') return this.fetchAuthn(id, {
241
+ method: method,
242
+ headers: this.headers,
243
+ body: JSON.stringify(resource),
244
+ credentials: 'include'
245
+ });
246
+ const resourceProxy = store.get(id);
247
+ const clientContext = resourceProxy ? resourceProxy.clientContext : resource['@context'];
248
+ this.clearCache(id);
249
+ await this.getData(id, clientContext, '', resource);
250
+ return {
251
+ ok: true
252
+ };
253
+ }
254
+
255
+ async _updateResource(method, resource, id) {
256
+ if (!['POST', 'PUT', 'PATCH', '_LOCAL'].includes(method)) throw new Error('Error: method not allowed');
257
+ const context = await myParser.parse([resource['@context'] || {}]); // parse context before expandTerm
258
+
259
+ const expandedId = this._getExpandedId(id, context);
260
+
261
+ return this._fetch(method, resource, id).then(async response => {
262
+ if (response.ok) {
263
+ var _response$headers;
264
+
265
+ if (method !== '_LOCAL') {
266
+ // await this.purge(id);
267
+ this.clearCache(expandedId);
268
+ } // clear cache
269
+
270
+
271
+ this.getData(expandedId, resource['@context']).then(async () => {
272
+ // re-fetch data
273
+ const nestedResources = await this.getNestedResources(resource, id);
274
+ const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];
275
+ const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];
276
+ return this.refreshResources([...nestedResources, ...resourcesToRefresh]) // refresh related resources
277
+ .then(resourceIds => this.notifyResources([expandedId, ...resourceIds, ...resourcesToNotify])); // notify components
278
+ });
279
+ return ((_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.get('Location')) || null;
280
+ } else {
281
+ throw response;
282
+ }
283
+ });
284
+ }
285
+ /**
286
+ * Clear cache and refetch data for a list of ids
287
+ * @param resourceIds -
288
+ * @returns - all the resource ids
289
+ */
290
+
291
+
292
+ async refreshResources(resourceIds) {
293
+ resourceIds = [...new Set(resourceIds.filter(id => this.cache.has(id)))]; // remove duplicates and not cached resources
294
+
295
+ const resourceWithContexts = resourceIds.map(resourceId => {
296
+ var _store$get;
297
+
298
+ return {
299
+ "id": resourceId,
300
+ "context": (_store$get = store.get(resourceId)) === null || _store$get === void 0 ? void 0 : _store$get.clientContext
301
+ };
302
+ });
303
+
304
+ for (const resource of resourceWithContexts) {
305
+ if (!this._isLocalId(resource.id)) this.clearCache(resource.id);
306
+ }
307
+
308
+ await Promise.all(resourceWithContexts.map(({
309
+ id,
310
+ context
311
+ }) => this.getData(id, context || base_context)));
312
+ return resourceIds;
313
+ }
314
+ /**
315
+ * Notifies all components for a list of ids
316
+ * @param resourceIds -
317
+ */
318
+
319
+
320
+ async notifyResources(resourceIds) {
321
+ resourceIds = [...new Set(resourceIds)]; // remove duplicates
322
+
323
+ for (const id of resourceIds) PubSub.publish(id);
324
+ }
325
+ /**
326
+ * Return id of nested properties of a resource
327
+ * @param resource - object
328
+ * @param id - string
329
+ */
330
+
331
+
332
+ async getNestedResources(resource, id) {
333
+ var _cachedResource$isCon;
334
+
335
+ const cachedResource = store.get(id);
336
+ if (!cachedResource || (_cachedResource$isCon = cachedResource.isContainer) !== null && _cachedResource$isCon !== void 0 && _cachedResource$isCon.call(cachedResource)) return [];
337
+ let nestedProperties = [];
338
+ const excludeKeys = ['@context'];
339
+
340
+ for (let p of Object.keys(resource)) {
341
+ if (resource[p] && typeof resource[p] === 'object' && !excludeKeys.includes(p) && resource[p]['@id']) {
342
+ nestedProperties.push(resource[p]['@id']);
343
+ }
344
+ }
345
+
346
+ return nestedProperties;
347
+ }
348
+ /**
349
+ * Returns the resource with id from the cache
350
+ * @param id - id of the resource to retrieve
351
+ *
352
+ * @returns Resource (Proxy) if in the cache, null otherwise
353
+ */
354
+
355
+
356
+ get(id) {
357
+ return this.cache.get(id) || null;
358
+ }
359
+ /**
360
+ * Removes a resource from the cache
361
+ * @param id - id of the resource to remove from the cache
362
+ */
363
+
364
+
365
+ clearCache(id) {
366
+ if (this.cache.has(id)) {
367
+ // For federation, clear each source
368
+ const resource = this.cache.get(id);
369
+
370
+ if (resource['@type'] === 'ldp:Container') {
371
+ resource['ldp:contains'].forEach(child => {
372
+ if (child && child['@type'] === 'ldp:Container') this.cache.delete(child['@id']);
373
+ });
374
+ }
375
+
376
+ this.cache.delete(id);
377
+ }
378
+ }
379
+ /**
380
+ * Send data to create a local resource in a container
381
+ * @param resource - resource to create
382
+ * @param id - uri of the container to add resource. should start with ``
383
+ *
384
+ * @returns id of the posted resource
385
+ */
386
+
387
+
388
+ async setLocalData(resource, id) {
389
+ return this._updateResource('_LOCAL', resource, id);
390
+ }
391
+ /**
392
+ * Send a POST request to create a resource in a container
393
+ * @param resource - resource to create
394
+ * @param id - uri of the container to add resource
395
+ *
396
+ * @returns id of the posted resource
397
+ */
398
+
399
+
400
+ async post(resource, id) {
401
+ return this._updateResource('POST', resource, id);
402
+ }
403
+ /**
404
+ * Send a PUT request to edit a resource
405
+ * @param resource - resource data to send
406
+ * @param id - uri of the resource to edit
407
+ *
408
+ * @returns id of the edited resource
409
+ */
410
+
411
+
412
+ async put(resource, id) {
413
+ return this._updateResource('PUT', resource, id);
414
+ }
415
+ /**
416
+ * Send a PATCH request to edit a resource
417
+ * @param resource - resource data to send
418
+ * @param id - uri of the resource to patch
419
+ *
420
+ * @returns id of the edited resource
421
+ */
422
+
423
+
424
+ async patch(resource, id) {
425
+ return this._updateResource('PATCH', resource, id);
426
+ }
427
+ /**
428
+ * Send a PURGE request to remove a resource from REDIS AD cache
429
+ * @param id - uri of the resource to patch
430
+ *
431
+ * @returns id of the edited resource
432
+ */
433
+
434
+
435
+ async purge(id) {
436
+ await this.fetchAuthn(id, {
437
+ method: "PURGE",
438
+ headers: this.headers
439
+ }).catch(function (error) {
440
+ console.warn('No purge method allowed: ' + error);
441
+ });
442
+
443
+ try {
444
+ const fullURL = new URL(id);
445
+ var pathArray = fullURL.pathname.split('/');
446
+ var containerUrl = fullURL.origin + '/' + pathArray[1] + '/';
447
+ const headers = { ...this.headers,
448
+ 'X-Cache-Purge-Match': 'startswith'
449
+ };
450
+ await this.fetchAuthn(containerUrl, {
451
+ method: "PURGE",
452
+ headers: headers
453
+ }).catch(function (error) {
454
+ console.warn('No purge method allowed: ' + error);
455
+ });
456
+ } catch (error) {
457
+ console.warn('The resource ID is not a complete URL: ' + error);
458
+ return;
459
+ }
460
+ }
461
+ /**
462
+ * Send a DELETE request to delete a resource
463
+ * @param id - uri of the resource to delete
464
+ * @param context - can be used to expand id
465
+ *
466
+ * @returns id of the deleted resource
467
+ */
468
+
469
+
470
+ async delete(id, context = {}) {
471
+ const expandedId = this._getExpandedId(id, context);
472
+
473
+ const deleted = await this.fetchAuthn(expandedId, {
474
+ method: 'DELETE',
475
+ headers: this.headers,
476
+ credentials: 'include'
477
+ }); // await this.purge(id);
478
+
479
+ const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];
480
+ const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];
481
+ this.refreshResources([...resourcesToNotify, ...resourcesToRefresh]).then(resourceIds => this.notifyResources(resourceIds));
482
+ return deleted;
483
+ }
484
+ /**
485
+ * Convert headers object to Headers
486
+ * @param headersObject - object
487
+ * @returns {Headers}
488
+ */
489
+
490
+
491
+ _convertHeaders(headersObject) {
492
+ const headers = new Headers();
493
+
494
+ for (const [key, value] of Object.entries(headersObject)) {
495
+ headers.set(key, value);
496
+ }
497
+
498
+ return headers;
499
+ }
500
+
501
+ _getExpandedId(id, context) {
502
+ return context && Object.keys(context) ? ContextParser.expandTerm(id, context) : id;
503
+ }
504
+
505
+ _isLocalId(id) {
506
+ return id.startsWith('store://local.');
507
+ }
508
+ /**
509
+ * Make a resource listen changes of another one
510
+ * @param resourceId - id of the resource which needs to be updated
511
+ * @param nestedResourceId - id of the resource which will change
512
+ */
513
+
514
+
515
+ subscribeResourceTo(resourceId, nestedResourceId) {
516
+ const existingSubscriptions = this.subscriptionIndex.get(nestedResourceId) || [];
517
+ this.subscriptionIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, resourceId])]);
518
+ }
519
+ /**
520
+ * Make a virtual container listen for changes of a resource
521
+ * @param virtualContainerId - id of the container which needs to be updated
522
+ * @param nestedResourceId - id of the resource which will change
523
+ */
524
+
525
+
526
+ subscribeVirtualContainerTo(virtualContainerId, nestedResourceId) {
527
+ const existingSubscriptions = this.subscriptionVirtualContainersIndex.get(nestedResourceId) || [];
528
+ this.subscriptionVirtualContainersIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, virtualContainerId])]);
529
+ }
530
+ /**
531
+ * Return absolute IRI of the resource
532
+ * @param id
533
+ * @param context
534
+ * @param parentId
535
+ */
536
+
537
+
538
+ _getAbsoluteIri(id, context, parentId) {
539
+ let iri = ContextParser.expandTerm(id, context); // expand if reduced ids
540
+
541
+ if (parentId) {
542
+ // and get full URL from parent caller for local files
543
+ let parentIri = new URL(parentId, document.location.href).href;
544
+ iri = new URL(iri, parentIri).href;
545
+ } else {
546
+ iri = new URL(iri, document.location.href).href;
547
+ }
548
+
549
+ return iri;
550
+ }
551
+ /**
552
+ * Check if object is a full resource
553
+ * @param resource
554
+ */
555
+
556
+
557
+ _resourceIsComplete(resource) {
558
+ return !!(Object.keys(resource).filter(p => !p.startsWith('@')).length > 0 && resource['@id']);
559
+ }
560
+ /**
561
+ * Return language of the users
562
+ */
563
+
564
+
565
+ _getLanguage() {
566
+ return localStorage.getItem('language') || window.navigator.language.slice(0, 2);
567
+ }
568
+ /**
569
+ * Save the preferred language of the user
570
+ * @param selectedLanguageCode
571
+ */
572
+
573
+
574
+ selectLanguage(selectedLanguageCode) {
575
+ localStorage.setItem('language', selectedLanguageCode);
576
+ }
577
+
578
+ }
579
+
580
+ let store;
581
+
582
+ if (window.sibStore) {
583
+ store = window.sibStore;
584
+ } else {
585
+ const sibAuth = document.querySelector('sib-auth');
586
+ const storeOptions = {};
587
+
588
+ if (sibAuth) {
589
+ const sibAuthDefined = customElements.whenDefined(sibAuth.localName);
590
+ storeOptions.session = sibAuthDefined.then(() => sibAuth.session);
591
+ storeOptions.fetchMethod = sibAuthDefined.then(() => sibAuth.getFetch());
592
+ }
593
+
594
+ store = new Store(storeOptions);
595
+ window.sibStore = store;
596
+ }
597
+
598
+ export { store };
599
+ _Symbol$toPrimitive = Symbol.toPrimitive;
600
+
601
+ class CustomGetter {
602
+ // content of the requested resource
603
+ // context given by the app
604
+ // context given by the server
605
+ // id of the parent resource, used to get the absolute url of the current resource
606
+ // pagination attributes to give to server
607
+ constructor(resourceId, resource, clientContext, serverContext = {}, parentId = "", serverPagination = {}) {
608
+ _defineProperty(this, "resource", void 0);
609
+
610
+ _defineProperty(this, "resourceId", void 0);
611
+
612
+ _defineProperty(this, "clientContext", void 0);
613
+
614
+ _defineProperty(this, "serverContext", void 0);
615
+
616
+ _defineProperty(this, "parentId", void 0);
617
+
618
+ _defineProperty(this, "serverPagination", void 0);
619
+
620
+ this.clientContext = clientContext;
621
+ this.serverContext = serverContext;
622
+ this.parentId = parentId;
623
+ this.resource = this.expandProperties({ ...resource
624
+ }, serverContext);
625
+ this.resourceId = resourceId;
626
+ this.serverPagination = serverPagination;
627
+ }
628
+ /**
629
+ * Expand all predicates of a resource with a given context
630
+ * @param resource: object
631
+ * @param context: object
632
+ */
633
+
634
+
635
+ expandProperties(resource, context) {
636
+ for (let prop of Object.keys(resource)) {
637
+ if (!prop) continue;
638
+ this.objectReplaceProperty(resource, prop, ContextParser.expandTerm(prop, context, true));
639
+ }
640
+
641
+ return resource;
642
+ }
643
+ /**
644
+ * Change the key of an object
645
+ * @param object: object
646
+ * @param oldProp: string - current key
647
+ * @param newProp: string - new key to set
648
+ */
649
+
650
+
651
+ objectReplaceProperty(object, oldProp, newProp) {
652
+ if (newProp !== oldProp) {
653
+ Object.defineProperty(object, newProp, Object.getOwnPropertyDescriptor(object, oldProp) || '');
654
+ delete object[oldProp];
655
+ }
656
+ }
657
+ /**
658
+ * Get the property of a resource for a given path
659
+ * @param path: string
660
+ */
661
+
662
+
663
+ async get(path) {
664
+ if (!path) return;
665
+ const path1 = path.split('.');
666
+ const path2 = [];
667
+ let value;
668
+
669
+ if (!this.isFullResource()) {
670
+ // if resource is not complete, fetch it first
671
+ await this.getResource(this.resourceId, this.clientContext, this.parentId);
672
+ }
673
+
674
+ while (true) {
675
+ try {
676
+ value = this.resource[this.getExpandedPredicate(path1[0])];
677
+ } catch (e) {
678
+ break;
679
+ }
680
+
681
+ if (path1.length <= 1) break; // no dot path
682
+
683
+ const lastPath1El = path1.pop();
684
+ if (lastPath1El) path2.unshift(lastPath1El);
685
+ }
686
+
687
+ if (path2.length === 0) {
688
+ // end of the path
689
+ if (!value || !value['@id']) return value; // no value or not a resource
690
+
691
+ return await this.getResource(value['@id'], this.clientContext, this.parentId || this.resourceId); // return complete resource
692
+ }
693
+
694
+ if (!value) return undefined;
695
+ let resource = await this.getResource(value['@id'], this.clientContext, this.parentId || this.resourceId);
696
+ store.subscribeResourceTo(this.resourceId, value['@id']);
697
+ return resource ? await resource[path2.join('.')] : undefined; // return value
698
+ }
699
+ /**
700
+ * Cache resource in the store, and return the created proxy
701
+ * @param id
702
+ * @param context
703
+ * @param iriParent
704
+ * @param forceFetch
705
+ */
706
+
707
+
708
+ async getResource(id, context, iriParent, forceFetch = false) {
709
+ return store.getData(id, context, iriParent, undefined, forceFetch);
710
+ }
711
+ /**
712
+ * Return true if the resource is a container
713
+ */
714
+
715
+
716
+ isContainer() {
717
+ return this.resource["@type"] == "ldp:Container" || this.resource["@type"] == "sib:federatedContainer";
718
+ }
719
+ /**
720
+ * Get all properties of a resource
721
+ */
722
+
723
+
724
+ getProperties() {
725
+ return Object.keys(this.resource).map(prop => this.getCompactedPredicate(prop));
726
+ }
727
+ /**
728
+ * Get children of container as objects
729
+ */
730
+
731
+
732
+ getChildren() {
733
+ return this.resource[this.getExpandedPredicate("ldp:contains")] || [];
734
+ }
735
+ /**
736
+ * Get children of container as Proxys
737
+ */
738
+
739
+
740
+ getLdpContains() {
741
+ const children = this.resource[this.getExpandedPredicate("ldp:contains")];
742
+ return children ? children.map(res => store.get(res['@id'])) : [];
743
+ }
744
+ /**
745
+ * Get all nested resource or containers which contains datas
746
+ */
747
+
748
+
749
+ getSubObjects() {
750
+ let subObjects = [];
751
+
752
+ for (let p of Object.keys(this.resource)) {
753
+ let property = this.resource[p];
754
+ if (!this.isFullNestedResource(property)) continue; // if not a resource, stop
755
+
756
+ if (property['@type'] == "ldp:Container" && (property['ldp:contains'] == undefined || property['ldp:contains'].length >= 1 && !this.isFullNestedResource(property['ldp:contains'][0]))) continue; // if not a full container
757
+
758
+ subObjects.push(property);
759
+ }
760
+
761
+ return subObjects;
762
+ }
763
+
764
+ merge(resource) {
765
+ this.resource = { ...this.getResourceData(),
766
+ ...resource.getResourceData()
767
+ };
768
+ }
769
+
770
+ getResourceData() {
771
+ return this.resource;
772
+ }
773
+ /**
774
+ * return true if prop is a resource with an @id and some properties
775
+ * @param prop
776
+ */
777
+
778
+
779
+ isFullNestedResource(prop) {
780
+ return prop && typeof prop == "object" && prop['@id'] != undefined && Object.keys(prop).filter(p => !p.startsWith('@')).length > 0;
781
+ }
782
+ /**
783
+ * return true resource seems complete
784
+ * @param prop
785
+ */
786
+
787
+
788
+ isFullResource() {
789
+ return Object.keys(this.resource).filter(p => !p.startsWith('@')).length > 0;
790
+ }
791
+
792
+ async getPermissions() {
793
+ const permissionPredicate = this.getExpandedPredicate("permissions");
794
+ let permissions = this.resource[permissionPredicate];
795
+
796
+ if (!permissions) {
797
+ // if no permission, re-fetch data
798
+ await this.getResource(this.resourceId, this.clientContext, this.parentId, true);
799
+ permissions = this.resource[permissionPredicate];
800
+ }
801
+
802
+ return permissions ? permissions.map(perm => ContextParser.expandTerm(perm.mode['@type'], this.serverContext, true)) : [];
803
+ }
804
+ /**
805
+ * Remove the resource from the cache
806
+ */
807
+
808
+
809
+ clearCache() {
810
+ store.clearCache(this.resourceId);
811
+ }
812
+
813
+ getExpandedPredicate(property) {
814
+ return ContextParser.expandTerm(property, this.clientContext, true);
815
+ }
816
+
817
+ getCompactedPredicate(property) {
818
+ return ContextParser.compactIri(property, this.clientContext, true);
819
+ }
820
+
821
+ getCompactedIri(id) {
822
+ return ContextParser.compactIri(id, this.clientContext);
823
+ }
824
+
825
+ toString() {
826
+ return this.getCompactedIri(this.resource['@id']);
827
+ }
828
+
829
+ [_Symbol$toPrimitive]() {
830
+ return this.getCompactedIri(this.resource['@id']);
831
+ }
832
+ /**
833
+ * Returns a Proxy which handles the different get requests
834
+ */
835
+
836
+
837
+ getProxy() {
838
+ return new Proxy(this, {
839
+ get: (resource, property) => {
840
+ if (!this.resource) return undefined;
841
+ if (typeof resource[property] === 'function') return resource[property].bind(resource);
842
+
843
+ switch (property) {
844
+ case '@id':
845
+ if (this.resource['@id']) return this.getCompactedIri(this.resource['@id']); // Compact @id if possible
846
+ else console.log(this.resource, this.resource['@id']);
847
+ return;
848
+
849
+ case '@type':
850
+ return this.resource['@type'];
851
+ // return synchronously
852
+
853
+ case 'properties':
854
+ return this.getProperties();
855
+
856
+ case 'ldp:contains':
857
+ return this.getLdpContains();
858
+ // returns standard arrays synchronously
859
+
860
+ case 'permissions':
861
+ return this.getPermissions();
862
+ // get expanded permissions
863
+
864
+ case 'clientContext':
865
+ return this.clientContext;
866
+ // get saved client context to re-fetch easily a resource
867
+
868
+ case 'then':
869
+ return;
870
+
871
+ default:
872
+ return resource.get(property);
873
+ }
874
+ }
875
+ });
876
+ }
877
+
878
+ }
879
+ //# sourceMappingURL=store.js.map