@startinblox/core 0.17.21-beta.8 → 0.17.23

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 (34) hide show
  1. package/dist/_snowpack/pkg/import-map.json +2 -0
  2. package/dist/_snowpack/pkg/leaflet.js +14066 -0
  3. package/dist/_snowpack/pkg/leaflet.js.map +1 -0
  4. package/dist/_snowpack/pkg/leaflet.js.map.proxy.js +1 -0
  5. package/dist/_snowpack/pkg/leaflet.markercluster.js +2697 -0
  6. package/dist/_snowpack/pkg/leaflet.markercluster.js.map +1 -0
  7. package/dist/_snowpack/pkg/leaflet.markercluster.js.map.proxy.js +1 -0
  8. package/dist/components/solid-ac-checker.js +10 -3
  9. package/dist/components/solid-ac-checker.js.map +1 -1
  10. package/dist/components/solid-display.js +1 -1
  11. package/dist/components/solid-display.js.map +1 -1
  12. package/dist/components/solid-form-search.js.map +1 -1
  13. package/dist/components/solid-map.js +2 -2
  14. package/dist/components/solid-map.js.map +1 -1
  15. package/dist/libs/interfaces.js.map +1 -1
  16. package/dist/libs/store/store.js +10 -70
  17. package/dist/libs/store/store.js.map +1 -1
  18. package/dist/mixins/filterMixin.js +61 -2
  19. package/dist/mixins/filterMixin.js.map +1 -1
  20. package/dist/mixins/widgetMixin.js +2 -2
  21. package/dist/mixins/widgetMixin.js.map +1 -1
  22. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +3 -4
  23. package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +1 -1
  24. package/dist/new-widgets/templates/displayTemplatesDirectory.js +3 -4
  25. package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +1 -1
  26. package/dist/new-widgets/templates/formTemplatesDirectory.js +3 -3
  27. package/dist/new-widgets/templates/formTemplatesDirectory.js.map +1 -1
  28. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -18
  29. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +1 -1
  30. package/package.json +2 -2
  31. package/dist/libs/filter.js +0 -214
  32. package/dist/libs/filter.js.map +0 -1
  33. package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -14
  34. package/dist/new-widgets/templatesDependencies/linkTextMixin.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["solid-form-search.ts"],"names":["Sib","WidgetMixin","AttributeBinderMixin","ContextMixin","newWidgetFactory","html","render","ifDefined","uniqID","SolidFormSearch","name","use","attributes","defaultWidget","type","String","default","submitButton","callback","newValue","oldValue","noRender","populate","submitWidget","undefined","classSubmitButton","value","initialState","error","created","element","closest","autoRangeValues","rangeId","attachedElements","Set","defaultMultipleWidget","defaultSetWidget","values","widgets","forEach","widget","component","getValue","JSON","parse","list","multiple","getWidget","field","isSet","tagName","hasAttribute","idField","setAttribute","widgetAttribute","getAttribute","customElements","get","startsWith","widgetFromTagName","attach","elm","has","add","updateAutoRanges","detach","delete","attr","replace","getValuesOfField","id","ldpContains","Array","from","map","data","context","sibStore","setLocalData","change","resource","dispatchEvent","CustomEvent","bubbles","detail","inputChange","getSubmitTemplate","empty","replaceAttributesData","addEventListener","e","preventDefault","fields","getFields","widgetTemplates","Promise","all","createWidgetTemplate","template","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,aAApB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,oBAAT,QAAqC,gCAArC;AACA,SAASC,YAAT,QAA6B,wBAA7B;AAEA,SAASC,gBAAT,QAAiC,mCAAjC;AAEA,SAASC,IAAT,EAAeC,MAAf,QAA6B,UAA7B;AACA,SAASC,SAAT,QAA0B,gCAA1B;AACA,SAASC,MAAT,QAAuB,iBAAvB;AAGA,OAAO,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,IAAI,EAAE,mBADuB;AAE7BC,EAAAA,GAAG,EAAE,CAACV,WAAD,EAAcC,oBAAd,EAAoCC,YAApC,CAFwB;AAG7BS,EAAAA,UAAU,EAAE;A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B,EAEM,KAAKF,YAAL,KAAsB,QAAtB,GAAiClB,IAAjC,qBACwB,KAAKY,YAAL,IAAqB,EAD7C,IAEEZ,IAFF,qBAG6BE,SAAS,CAAC,KAAKU,YAAL,IAAqBO,SAAtB,CAHtC,CAFN;AASD,GA5I4B;;AA6I7BgE,EAAAA,KAAK,GAAS,CAAE,CA7Ia;;AA8I7B,QAAMlE,QAAN,GAAgC;AAC9B,UAAM,KAAKmE,qBAAL,EAAN;;AACA,QAAG,KAAKxE,YAAL,IAAqB,IAAxB,EAA8B;AAC5B,WAAKa,OAAL,CAAa4D,gBAAb,CAA8B,OAA9B,EAAuC,MAAM,KAAKJ,WAAL,EAA7C;AACD,KAFD,MAEO;AACL,WAAKxD,OAAL,CAAa4D,gBAAb,CAA8B,QAA9B,EAAyCC,CAAD,IAAc;AACpDA,QAAAA,CAAC,CAACC,cAAF;AACA,aAAKN,WAAL;AACD,OAHD;AAID;;AACD,UAAMO,MAAM,GAAG,MAAM,KAAKC,SAAL,EAArB;AACA,UAAMC,eAAe,GAAG,MAAMC,OAAO,CAACC,GAAR,CAAYJ,MAAM,CAAClB,GAAP,CAAY1B,KAAD,IAAmB,KAAKiD,oBAAL,CAA0BjD,KAA1B,CAA9B,CAAZ,CAA9B;AACA,UAAMkD,QAAQ,GAAG9F,IAAH,qBAER0F,eAFQ,EAGR,KAAK9E,YAAL,IAAqB,IAArB,GAA4B,EAA5B,GAAiC,KAAKsE,iBAAL,EAHzB,CAAd;AAMAjF,IAAAA,MAAM,CAAC6F,QAAD,EAAW,KAAKrE,OAAhB,CAAN;AACD;;AAjK4B,CAAxB;AAoKP9B,GAAG,CAACoG,QAAJ,CAAa3F,eAAb","sourcesContent":["import { Sib } from '../libs/Sib';\nimport { WidgetMixin } from '../mixins/widgetMixin';\nimport { AttributeBinderMixin } from '../mixins/attributeBinderMixin';\nimport { ContextMixin } from '../mixins/contextMixin';\nimport type { WidgetInterface } from '../mixins/interfaces';\nimport { newWidgetFactory } from '../new-widgets/new-widget-factory';\n\nimport { html, render } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { uniqID } from '../libs/helpers';\nimport type { SearchQuery } from '../libs/interfaces';\n\nexport const SolidFormSearch = {\n name: 'solid-form-search',\n use: [WidgetMixin, AttributeBinderMixin, ContextMixin],\n attributes: {\n defaultWidget: {\n type: String,\n default: 'solid-form-label-text',\n },\n submitButton: {\n type: String,\n default: null,\n callback: function (newValue: string, oldValue: string) {\n if (this.noRender == null && newValue !== oldValue) this.populate();\n },\n },\n submitWidget: {\n type: String,\n default: undefined\n },\n classSubmitButton: {\n type: String,\n default: undefined,\n },\n noRender: {\n type: String,\n default: null,\n callback: function (value: boolean) {\n if (value === null) this.populate()\n }\n },\n },\n initialState: {\n error: '',\n },\n created() {\n if (this.element.closest('[no-render]')) this.noRender = ''; // if embedded in no-render, apply no-render to himself\n this.autoRangeValues = {};\n this.rangeId = uniqID();\n this.attachedElements = new Set();\n },\n get defaultMultipleWidget(): string {\n return 'solid-multiple-form';\n },\n get defaultSetWidget(): string {\n return 'solid-set-default';\n },\n\n get value(): SearchQuery {\n const values: SearchQuery = {};\n this.widgets.forEach((widget) => {\n const name = (widget.component || widget).name;\n if (name == null) return;\n let value = widget.component ? widget.component.getValue() : widget.value;\n try {\n value = JSON.parse(value);\n } catch {}\n value = {\n type: widget.component.type,\n list: !!widget.component.multiple,\n value: value,\n }\n values[name] = value;\n });\n return values;\n },\n getWidget(field: string, isSet: boolean = false): WidgetInterface {\n let tagName = '';\n // If auto-range-[field] exists, create range-[field] and sets its value\n if(this.element.hasAttribute('auto-range-' + field) && !this.element.hasAttribute('range-' + field)) {\n const idField = `${this.rangeId}_${field}`;\n this.element.setAttribute('range-' + field, 'store://local.' + idField);\n this.populate();\n }\n \n const widgetAttribute = this.element.getAttribute('widget-' + field);\n // Choose widget\n if (!widgetAttribute && (this.element.hasAttribute('range-' + field) || this.element.hasAttribute('enum-' + field))) {\n tagName = 'solid-form-dropdown'\n } else {\n tagName = widgetAttribute || (!isSet ? this.defaultWidget : this.defaultSetWidget);\n }\n // Create widget\n if (!customElements.get(tagName)) { // component does not exist\n if (tagName.startsWith('solid')) newWidgetFactory(tagName); // solid- -> create it\n }\n\n return this.widgetFromTagName(tagName);\n },\n async attach(elm: any) {\n if(this.attachedElements.has(elm)) return;\n this.attachedElements.add(elm);\n await this.updateAutoRanges();\n },\n async detach(elm: any) {\n if(!this.attachedElements.has(elm)) return;\n this.attachedElements.delete(elm);\n await this.updateAutoRanges();\n },\n async updateAutoRanges() {\n for(const attr of (this.element as Element).attributes) {\n if(!attr['name'].startsWith('auto-range-')) continue;\n const field = attr['name'].replace('auto-range-', '');\n const autoRangeValues = new Set();\n for(const elm of this.attachedElements) {\n for(const value of await elm.getValuesOfField(field)) {\n autoRangeValues.add(value);\n }\n }\n const idField = `${this.rangeId}_${field}`;\n const id = `store://local.${idField}`;\n const ldpContains = Array.from(autoRangeValues).map(id => ({'@id' : id}));\n const data = {\n \"@type\": \"ldp:Container\",\n \"@context\": this.context,\n \"ldp:contains\" : ldpContains,\n };\n sibStore.setLocalData(data, id);\n }\n },\n change(resource: object): void {\n this.element.dispatchEvent(\n new CustomEvent('formChange', {\n bubbles: true,\n detail: { resource },\n }),\n );\n },\n async inputChange(): Promise<void> {\n this.change(this.value);\n },\n getSubmitTemplate() {\n return html`\n <div class=${ifDefined(this.classSubmitButton)}>\n ${this.submitWidget === 'button' ? html`\n <button type=\"submit\">${this.submitButton || ''}</button>\n ` : html`\n <input type=\"submit\" value=${ifDefined(this.submitButton || undefined)}>\n `}\n </div>\n ` \n },\n empty(): void {},\n async populate(): Promise<void> {\n await this.replaceAttributesData();\n if(this.submitButton == null) {\n this.element.addEventListener('input', () => this.inputChange());\n } else {\n this.element.addEventListener('submit', (e: Event) => {\n e.preventDefault();\n this.inputChange();\n });\n }\n const fields = await this.getFields();\n const widgetTemplates = await Promise.all(fields.map((field: string) => this.createWidgetTemplate(field)));\n const template = html`\n <form>\n ${widgetTemplates}\n ${this.submitButton == null ? '' : this.getSubmitTemplate()}\n </form>\n `;\n render(template, this.element);\n }\n};\n\nSib.register(SolidFormSearch);"]}
1
+ {"version":3,"sources":["solid-form-search.ts"],"names":["Sib","WidgetMixin","AttributeBinderMixin","ContextMixin","newWidgetFactory","html","render","ifDefined","uniqID","SolidFormSearch","name","use","attributes","defaultWidget","type","String","default","submitButton","callback","newValue","oldValue","noRender","populate","submitWidget","undefined","classSubmitButton","value","initialState","error","created","element","closest","autoRangeValues","rangeId","attachedElements","Set","defaultMultipleWidget","defaultSetWidget","values","widgets","forEach","widget","component","getValue","JSON","parse","list","multiple","getWidget","field","isSet","tagName","hasAttribute","idField","setAttribute","widgetAttribute","getAttribute","customElements","get","startsWith","widgetFromTagName","attach","elm","has","add","updateAutoRanges","detach","delete","attr","replace","getValuesOfField","id","ldpContains","Array","from","map","data","context","sibStore","setLocalData","change","resource","dispatchEvent","CustomEvent","bubbles","detail","inputChange","getSubmitTemplate","empty","replaceAttributesData","addEventListener","e","preventDefault","fields","getFields","widgetTemplates","Promise","all","createWidgetTemplate","template","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,aAApB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,oBAAT,QAAqC,gCAArC;AACA,SAASC,YAAT,QAA6B,wBAA7B;AAEA,SAASC,gBAAT,QAAiC,mCAAjC;AAEA,SAASC,IAAT,EAAeC,MAAf,QAA6B,UAA7B;AACA,SAASC,SAAT,QAA0B,gCAA1B;AACA,SAASC,MAAT,QAAuB,iBAAvB;AAEA,OAAO,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,IAAI,EAAE,mBADuB;AAE7BC,EAAAA,GAAG,EAAE,CAACV,WAAD,EAAcC,oBAAd,EAAoCC,YAApC,CAFwB;AAG7BS,EAAAA,UAAU,EAAE;AACVC,IAAAA,aAAa,EAAE;AACbC,MAAAA,IAAI,EAAEC,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BACwB,KAAKY,YAAL,IAAqB,EAD7C,IAEEZ,IAFF,qBAG6BE,SAAS,CAAC,KAAKU,YAAL,IAAqBO,SAAtB,CAHtC,CAFN;AASD,GA5I4B;;AA6I7BgE,EAAAA,KAAK,GAAS,CAAE,CA7Ia;;AA8I7B,QAAMlE,QAAN,GAAgC;AAC9B,UAAM,KAAKmE,qBAAL,EAAN;;AACA,QAAG,KAAKxE,YAAL,IAAqB,IAAxB,EAA8B;AAC5B,WAAKa,OAAL,CAAa4D,gBAAb,CAA8B,OAA9B,EAAuC,MAAM,KAAKJ,WAAL,EAA7C;AACD,KAFD,MAEO;AACL,WAAKxD,OAAL,CAAa4D,gBAAb,CAA8B,QAA9B,EAAyCC,CAAD,IAAc;AACpDA,QAAAA,CAAC,CAACC,cAAF;AACA,aAAKN,WAAL;AACD,OAHD;AAID;;AACD,UAAMO,MAAM,GAAG,MAAM,KAAKC,SAAL,EAArB;AACA,UAAMC,eAAe,GAAG,MAAMC,OAAO,CAACC,GAAR,CAAYJ,MAAM,CAAClB,GAAP,CAAY1B,KAAD,IAAmB,KAAKiD,oBAAL,CAA0BjD,KAA1B,CAA9B,CAAZ,CAA9B;AACA,UAAMkD,QAAQ,GAAG9F,IAAH,qBAER0F,eAFQ,EAGR,KAAK9E,YAAL,IAAqB,IAArB,GAA4B,EAA5B,GAAiC,KAAKsE,iBAAL,EAHzB,CAAd;AAMAjF,IAAAA,MAAM,CAAC6F,QAAD,EAAW,KAAKrE,OAAhB,CAAN;AACD;;AAjK4B,CAAxB;AAoKP9B,GAAG,CAACoG,QAAJ,CAAa3F,eAAb","sourcesContent":["import { Sib } from '../libs/Sib';\nimport { WidgetMixin } from '../mixins/widgetMixin';\nimport { AttributeBinderMixin } from '../mixins/attributeBinderMixin';\nimport { ContextMixin } from '../mixins/contextMixin';\nimport type { WidgetInterface } from '../mixins/interfaces';\nimport { newWidgetFactory } from '../new-widgets/new-widget-factory';\n\nimport { html, render } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { uniqID } from '../libs/helpers';\n\nexport const SolidFormSearch = {\n name: 'solid-form-search',\n use: [WidgetMixin, AttributeBinderMixin, ContextMixin],\n attributes: {\n defaultWidget: {\n type: String,\n default: 'solid-form-label-text',\n },\n submitButton: {\n type: String,\n default: null,\n callback: function (newValue: string, oldValue: string) {\n if (this.noRender == null && newValue !== oldValue) this.populate();\n },\n },\n submitWidget: {\n type: String,\n default: undefined\n },\n classSubmitButton: {\n type: String,\n default: undefined,\n },\n noRender: {\n type: String,\n default: null,\n callback: function (value: boolean) {\n if (value === null) this.populate()\n }\n },\n },\n initialState: {\n error: '',\n },\n created() {\n if (this.element.closest('[no-render]')) this.noRender = ''; // if embedded in no-render, apply no-render to himself\n this.autoRangeValues = {};\n this.rangeId = uniqID();\n this.attachedElements = new Set();\n },\n get defaultMultipleWidget(): string {\n return 'solid-multiple-form';\n },\n get defaultSetWidget(): string {\n return 'solid-set-default';\n },\n\n get value(): object {\n const values = {};\n this.widgets.forEach((widget) => {\n const name = (widget.component || widget).name;\n if (name == null) return;\n let value = widget.component ? widget.component.getValue() : widget.value;\n try {\n value = JSON.parse(value);\n } catch {}\n value = {\n type: widget.component.type,\n list: !!widget.component.multiple,\n value: value,\n }\n values[name] = value;\n });\n return values;\n },\n getWidget(field: string, isSet: boolean = false): WidgetInterface {\n let tagName = '';\n // If auto-range-[field] exists, create range-[field] and sets its value\n if(this.element.hasAttribute('auto-range-' + field) && !this.element.hasAttribute('range-' + field)) {\n const idField = `${this.rangeId}_${field}`;\n this.element.setAttribute('range-' + field, 'store://local.' + idField);\n this.populate();\n }\n \n const widgetAttribute = this.element.getAttribute('widget-' + field);\n // Choose widget\n if (!widgetAttribute && (this.element.hasAttribute('range-' + field) || this.element.hasAttribute('enum-' + field))) {\n tagName = 'solid-form-dropdown'\n } else {\n tagName = widgetAttribute || (!isSet ? this.defaultWidget : this.defaultSetWidget);\n }\n // Create widget\n if (!customElements.get(tagName)) { // component does not exist\n if (tagName.startsWith('solid')) newWidgetFactory(tagName); // solid- -> create it\n }\n\n return this.widgetFromTagName(tagName);\n },\n async attach(elm: any) {\n if(this.attachedElements.has(elm)) return;\n this.attachedElements.add(elm);\n await this.updateAutoRanges();\n },\n async detach(elm: any) {\n if(!this.attachedElements.has(elm)) return;\n this.attachedElements.delete(elm);\n await this.updateAutoRanges();\n },\n async updateAutoRanges() {\n for(const attr of (this.element as Element).attributes) {\n if(!attr['name'].startsWith('auto-range-')) continue;\n const field = attr['name'].replace('auto-range-', '');\n const autoRangeValues = new Set();\n for(const elm of this.attachedElements) {\n for(const value of await elm.getValuesOfField(field)) {\n autoRangeValues.add(value);\n }\n }\n const idField = `${this.rangeId}_${field}`;\n const id = `store://local.${idField}`;\n const ldpContains = Array.from(autoRangeValues).map(id => ({'@id' : id}));\n const data = {\n \"@type\": \"ldp:Container\",\n \"@context\": this.context,\n \"ldp:contains\" : ldpContains,\n };\n sibStore.setLocalData(data, id);\n }\n },\n change(resource: object): void {\n this.element.dispatchEvent(\n new CustomEvent('formChange', {\n bubbles: true,\n detail: { resource },\n }),\n );\n },\n async inputChange(): Promise<void> {\n this.change(this.value);\n },\n getSubmitTemplate() {\n return html`\n <div class=${ifDefined(this.classSubmitButton)}>\n ${this.submitWidget === 'button' ? html`\n <button type=\"submit\">${this.submitButton || ''}</button>\n ` : html`\n <input type=\"submit\" value=${ifDefined(this.submitButton || undefined)}>\n `}\n </div>\n ` \n },\n empty(): void {},\n async populate(): Promise<void> {\n await this.replaceAttributesData();\n if(this.submitButton == null) {\n this.element.addEventListener('input', () => this.inputChange());\n } else {\n this.element.addEventListener('submit', (e: Event) => {\n e.preventDefault();\n this.inputChange();\n });\n }\n const fields = await this.getFields();\n const widgetTemplates = await Promise.all(fields.map((field: string) => this.createWidgetTemplate(field)));\n const template = html`\n <form>\n ${widgetTemplates}\n ${this.submitButton == null ? '' : this.getSubmitTemplate()}\n </form>\n `;\n render(template, this.element);\n }\n};\n\nSib.register(SolidFormSearch);"]}
@@ -33,9 +33,9 @@ import { store } from '../libs/store/store.js';
33
33
  import { uniqID } from '../libs/helpers.js';
34
34
  import { spread } from '../libs/lit-helpers.js'; //@ts-ignore
35
35
 
36
- import L from 'https://cdn.skypack.dev/leaflet'; // TODO : revert to "leaflet" when apps up to date
36
+ import L from '../_snowpack/pkg/leaflet.js'; // TODO : revert to "leaflet" when apps up to date
37
37
 
38
- import 'https://cdn.skypack.dev/leaflet.markercluster'; // TODO : revert to "leaflet.markercluster" when apps up to date
38
+ import '../_snowpack/pkg/leaflet.markercluster.js'; // TODO : revert to "leaflet.markercluster" when apps up to date
39
39
 
40
40
  import { html, render } from '../_snowpack/pkg/lit-html.js';
41
41
  import { ifDefined } from '../_snowpack/pkg/lit-html/directives/if-defined.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["solid-map.ts"],"names":["Sib","ListMixin","StoreMixin","WidgetMixin","CounterMixin","FilterMixin","FederationMixin","GrouperMixin","NextMixin","store","uniqID","spread","L","html","render","ifDefined","SolidMap","name","use","attributes","clustering","type","Boolean","default","initialState","markers","subscriptions","resetPlanned","hasBeenResetOnce","created","document","body","addEventListener","setTimeout","isVisible","reset","Map","element","offsetParent","attached","id","template","div","querySelector","map","tileLayer","addTo","markersCluster","markerClusterGroup","addLayer","invalidateSize","length","fitBounds","featureGroup","getBounds","fitWorld","planReset","dispatchSelect","event","target","resource","dispatchEvent","CustomEvent","detail","goToNext","appendChildElt","resourceId","groupClass","getData","context","get","set","PubSub","subscribe","updateDOM","lat","lng","icon","divIcon","className","iconSize","iconAnchor","popupAnchor","marker","toString","on","bind","fields","bindPopup","getPopupContent","minWidth","push","attr","startsWith","value","replace","createElement","empty","removeLayer","renderGroup","groupName","sanitizedGroupName","encodeURIComponent","toLowerCase","dataset","renderDOM","resources","listPostProcessors","Promise","all","nextProcessor","shift","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,aAApB;AACA,SAASC,SAAT,QAA0B,qBAA1B;A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C,EAAqC2B,OAArC,CAAnB;AACnB;;AAjNqB,CAAjB;AAoNPrE,GAAG,CAACgH,QAAJ,CAAahG,QAAb","sourcesContent":["import { Sib } from '../libs/Sib';\nimport { ListMixin } from '../mixins/listMixin';\nimport { StoreMixin } from '../mixins/storeMixin';\nimport { WidgetMixin } from '../mixins/widgetMixin';\nimport { CounterMixin } from '../mixins/counterMixin';\nimport { FilterMixin } from '../mixins/filterMixin';\nimport { FederationMixin } from '../mixins/federationMixin';\nimport { GrouperMixin } from '../mixins/grouperMixin';\nimport { NextMixin } from '../mixins/nextMixin';\nimport { store } from '../libs/store/store';\nimport { uniqID } from '../libs/helpers';\nimport { spread } from '../libs/lit-helpers';\n\n//@ts-ignore\nimport L, { MarkerOptions } from 'https://cdn.skypack.dev/leaflet'; // TODO : revert to \"leaflet\" when apps up to date\nimport 'https://cdn.skypack.dev/leaflet.markercluster'; // TODO : revert to \"leaflet.markercluster\" when apps up to date\n\nimport { html, render } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nexport const SolidMap = {\n name: 'solid-map',\n use: [\n WidgetMixin,\n ListMixin,\n StoreMixin,\n GrouperMixin,\n CounterMixin,\n FilterMixin,\n FederationMixin,\n NextMixin,\n ],\n attributes: {\n clustering: {\n type: Boolean,\n default: null\n }\n },\n initialState: {\n markers: {\n default: null\n },\n subscriptions: null,\n resetPlanned: false,\n hasBeenResetOnce: false\n },\n created(): void {\n //@ts-ignore\n import('leaflet/dist/leaflet.css');\n //@ts-ignore\n import('../style/default-theme.css');\n //@ts-ignore\n import('leaflet.markercluster/dist/MarkerCluster.css');\n //@ts-ignore\n import('leaflet.markercluster/dist/MarkerCluster.Default.css');\n\n // reset when it becomes visible to prevent bug https://git.startinblox.com/framework/sib-core/issues/661\n document.body.addEventListener('navigate', () =>\n setTimeout(() => this.isVisible && !this.hasBeenResetOnce && this.reset())\n );\n this.markers = [];\n this.subscriptions = new Map();\n },\n get isVisible() {\n return this.element.offsetParent !== null\n },\n attached(): void {\n const id = uniqID();\n const template = html`\n <div id=${id} style=\"width:100%;height:100%;\"></div>\n `;\n render(template, this.element);\n\n const div = this.element.querySelector(`#${id}`);\n this.map = L.map(div);\n\n L.tileLayer(\n 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png'\n ).addTo(this.map);\n\n if (this.clustering !== null) {\n this.markersCluster = L.markerClusterGroup();\n this.map.addLayer(this.markersCluster);\n }\n },\n reset() {\n if (this.isVisible) { // reset only if visible\n this.map.invalidateSize();\n\n if (this.markers.length) {\n this.map.fitBounds(L.featureGroup(this.markers).getBounds()); // Center map on markers if some available\n } else {\n this.map.fitWorld(); // ... or on the world if not\n }\n this.hasBeenResetOnce = true;\n }\n },\n /**\n * Execute a reset only if none is planned already\n */\n planReset() {\n if (!this.resetPlanned) {\n this.resetPlanned = true;\n setTimeout(() => {\n this.reset();\n this.resetPlanned = false;\n })\n }\n },\n dispatchSelect(event: CustomEvent): void {\n const target = event.target as Element;\n const resource = target['options'].resource;\n this.element.dispatchEvent(\n new CustomEvent('resourceSelect', { detail: { resource: resource } })\n );\n this.goToNext(resource);\n },\n\n /**\n * Override listMixin method: initialize a marker on the map\n * @param resourceId: id of the resource to display\n * @param groupClass: class of the group of markers\n */\n async appendChildElt(resourceId: string, groupClass: string) {\n const resource = await store.getData(resourceId, this.context);\n if (!this.subscriptions.get(resourceId)) {\n this.subscriptions.set(resourceId, PubSub.subscribe(resourceId, () => this.updateDOM()))\n }\n if (!resource) return;\n const lat = await resource['lat'];\n const lng = await resource['lng'];\n\n if (lat && lng) {\n const icon = L.divIcon({ // create the icon, doc here: https://leafletjs.com/reference-1.6.0.html#icon\n className: 'sib-custom-marker ' + groupClass, // default class used for styling\n iconSize: [8, 8],\n iconAnchor: [12, 34],\n popupAnchor: [0,-34]\n });\n\n // create a marker, doc here: https://leafletjs.com/reference-1.6.0.html#marker\n const marker = L.marker(\n [lat.toString(), lng.toString()], \n {resource, icon} as MarkerOptions\n );\n if(this.clustering === null) marker.addTo(this.map);\n else this.markersCluster.addLayer(marker);\n marker.on('click', this.dispatchSelect.bind(this));\n\n if (this.fields !== null) { // show popups only if fields attribute\n marker.bindPopup(() => this.getPopupContent(resourceId), { minWidth: 150 }) // re-generate popup solid-display\n }\n\n this.markers.push(marker);\n }\n },\n /**\n * Generate the solid-display of the popup\n * @param resourceId: id of the popup clicked\n */\n getPopupContent(resourceId: string) {\n const attributes:{[key:string]: string} = {};\n\n for (let attr of this.element.attributes) {\n //copy widget and value attributes\n if (\n attr.name.startsWith('value-') ||\n attr.name.startsWith('label-') ||\n attr.name.startsWith('widget-') ||\n attr.name.startsWith('class-') ||\n attr.name.startsWith('multiple-') ||\n attr.name.startsWith('editable-') ||\n attr.name.startsWith('action-') ||\n attr.name.startsWith('default-') ||\n attr.name == 'extra-context'\n )\n attributes[attr.name] = attr.value;\n if (attr.name.startsWith('child-'))\n attributes[attr.name.replace(/^child-/, '')] = attr.value;\n }\n\n const div = document.createElement('div');\n const template = html`\n <solid-display\n fields=\"${ifDefined(this.fields)}\"\n data-src=\"${resourceId}\"\n ...=${spread(attributes)}\n ></solid-display>\n `;\n render(template, div);\n return div.querySelector('solid-display');\n },\n /**\n * Override widgetMixin method: empty the map\n */\n empty(): void {\n if (!this.map) return;\n if (this.markersCluster) this.map.removeLayer(this.markersCluster);\n for (let marker of this.markers) this.map.removeLayer(marker);\n if(this.clustering !== null) {\n this.markersCluster = L.markerClusterGroup();\n this.map.addLayer(this.markersCluster);\n }\n this.markers = [];\n },\n /**\n * Override groupMixin method\n * @param groupName: value of the group\n */\n renderGroup(groupName: string) {\n const sanitizedGroupName = encodeURIComponent(groupName.toLowerCase()).replace(/%[0-9A-F]{2}/gi, '');\n const div = document.createElement('div'); // used to pass group info to renderDOM\n div.dataset.groupClass = 'group-' + sanitizedGroupName;\n return div;\n },\n /**\n * Override listMixin method: display all the resources\n * @param resources\n * @param listPostProcessors\n * @param div\n * @param context\n */\n async renderDOM(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) {\n const groupClass = div.dataset.groupClass || ''; // get the group class from the useless div element\n await Promise.all(resources.map(resource => this.appendChildElt(resource['@id'], groupClass)))\n this.planReset();\n\n const nextProcessor = listPostProcessors.shift();\n if(nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);\n }\n};\n\nSib.register(SolidMap);"]}
1
+ {"version":3,"sources":["solid-map.ts"],"names":["Sib","ListMixin","StoreMixin","WidgetMixin","CounterMixin","FilterMixin","FederationMixin","GrouperMixin","NextMixin","store","uniqID","spread","L","html","render","ifDefined","SolidMap","name","use","attributes","clustering","type","Boolean","default","initialState","markers","subscriptions","resetPlanned","hasBeenResetOnce","created","document","body","addEventListener","setTimeout","isVisible","reset","Map","element","offsetParent","attached","id","template","div","querySelector","map","tileLayer","addTo","markersCluster","markerClusterGroup","addLayer","invalidateSize","length","fitBounds","featureGroup","getBounds","fitWorld","planReset","dispatchSelect","event","target","resource","dispatchEvent","CustomEvent","detail","goToNext","appendChildElt","resourceId","groupClass","getData","context","get","set","PubSub","subscribe","updateDOM","lat","lng","icon","divIcon","className","iconSize","iconAnchor","popupAnchor","marker","toString","on","bind","fields","bindPopup","getPopupContent","minWidth","push","attr","startsWith","value","replace","createElement","empty","removeLayer","renderGroup","groupName","sanitizedGroupName","encodeURIComponent","toLowerCase","dataset","renderDOM","resources","listPostProcessors","Promise","all","nextProcessor","shift","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,aAApB;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,UAAT,QAA2B,sBAA3B;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,YAAT,QAA6B,wBAA7B;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,eAAT,QAAgC,2BAAhC;AACA,SAASC,YAAT,QAA6B,wBAA7B;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,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D,SAAKtB,OAAL,GAAe,EAAf;AACD,GAxLqB;;AAyLtB;AACF;AACA;AACA;AACE0E,EAAAA,WAAW,CAACC,SAAD,EAAoB;AAC7B,UAAMC,kBAAkB,GAAGC,kBAAkB,CAACF,SAAS,CAACG,WAAV,EAAD,CAAlB,CAA4CR,OAA5C,CAAoD,gBAApD,EAAsE,EAAtE,CAA3B;AACA,UAAMrD,GAAG,GAAGZ,QAAQ,CAACkE,aAAT,CAAuB,KAAvB,CAAZ,CAF6B,CAEc;;AAC3CtD,IAAAA,GAAG,CAAC8D,OAAJ,CAAYrC,UAAZ,GAAyB,WAAWkC,kBAApC;AACA,WAAO3D,GAAP;AACD,GAlMqB;;AAmMtB;AACF;AACA;AACA;AACA;AACA;AACA;AACE,QAAM+D,SAAN,CAAgBC,SAAhB,EAAqCC,kBAArC,EAAqEjE,GAArE,EAAuF2B,OAAvF,EAAwG;AACtG,UAAMF,UAAU,GAAGzB,GAAG,CAAC8D,OAAJ,CAAYrC,UAAZ,IAA0B,EAA7C,CADsG,CACrD;;AACjD,UAAMyC,OAAO,CAACC,GAAR,CAAYH,SAAS,CAAC9D,GAAV,CAAcgB,QAAQ,IAAI,KAAKK,cAAL,CAAoBL,QAAQ,CAAC,KAAD,CAA5B,EAAqCO,UAArC,CAA1B,CAAZ,CAAN;AACA,SAAKX,SAAL;AAEA,UAAMsD,aAAa,GAAGH,kBAAkB,CAACI,KAAnB,EAAtB;AACA,QAAGD,aAAH,EAAkB,MAAMA,aAAa,CAACJ,SAAD,EAAYC,kBAAZ,EAAgCjE,GAAhC,EAAqC2B,OAArC,CAAnB;AACnB;;AAjNqB,CAAjB;AAoNPrE,GAAG,CAACgH,QAAJ,CAAahG,QAAb","sourcesContent":["import { Sib } from '../libs/Sib';\nimport { ListMixin } from '../mixins/listMixin';\nimport { StoreMixin } from '../mixins/storeMixin';\nimport { WidgetMixin } from '../mixins/widgetMixin';\nimport { CounterMixin } from '../mixins/counterMixin';\nimport { FilterMixin } from '../mixins/filterMixin';\nimport { FederationMixin } from '../mixins/federationMixin';\nimport { GrouperMixin } from '../mixins/grouperMixin';\nimport { NextMixin } from '../mixins/nextMixin';\nimport { store } from '../libs/store/store';\nimport { uniqID } from '../libs/helpers';\nimport { spread } from '../libs/lit-helpers';\n\n//@ts-ignore\nimport L, { MarkerOptions } from 'leaflet'; // TODO : revert to \"leaflet\" when apps up to date\nimport 'leaflet.markercluster'; // TODO : revert to \"leaflet.markercluster\" when apps up to date\n\nimport { html, render } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nexport const SolidMap = {\n name: 'solid-map',\n use: [\n WidgetMixin,\n ListMixin,\n StoreMixin,\n GrouperMixin,\n CounterMixin,\n FilterMixin,\n FederationMixin,\n NextMixin,\n ],\n attributes: {\n clustering: {\n type: Boolean,\n default: null\n }\n },\n initialState: {\n markers: {\n default: null\n },\n subscriptions: null,\n resetPlanned: false,\n hasBeenResetOnce: false\n },\n created(): void {\n //@ts-ignore\n import('leaflet/dist/leaflet.css');\n //@ts-ignore\n import('../style/default-theme.css');\n //@ts-ignore\n import('leaflet.markercluster/dist/MarkerCluster.css');\n //@ts-ignore\n import('leaflet.markercluster/dist/MarkerCluster.Default.css');\n\n // reset when it becomes visible to prevent bug https://git.startinblox.com/framework/sib-core/issues/661\n document.body.addEventListener('navigate', () =>\n setTimeout(() => this.isVisible && !this.hasBeenResetOnce && this.reset())\n );\n this.markers = [];\n this.subscriptions = new Map();\n },\n get isVisible() {\n return this.element.offsetParent !== null\n },\n attached(): void {\n const id = uniqID();\n const template = html`\n <div id=${id} style=\"width:100%;height:100%;\"></div>\n `;\n render(template, this.element);\n\n const div = this.element.querySelector(`#${id}`);\n this.map = L.map(div);\n\n L.tileLayer(\n 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png'\n ).addTo(this.map);\n\n if (this.clustering !== null) {\n this.markersCluster = L.markerClusterGroup();\n this.map.addLayer(this.markersCluster);\n }\n },\n reset() {\n if (this.isVisible) { // reset only if visible\n this.map.invalidateSize();\n\n if (this.markers.length) {\n this.map.fitBounds(L.featureGroup(this.markers).getBounds()); // Center map on markers if some available\n } else {\n this.map.fitWorld(); // ... or on the world if not\n }\n this.hasBeenResetOnce = true;\n }\n },\n /**\n * Execute a reset only if none is planned already\n */\n planReset() {\n if (!this.resetPlanned) {\n this.resetPlanned = true;\n setTimeout(() => {\n this.reset();\n this.resetPlanned = false;\n })\n }\n },\n dispatchSelect(event: CustomEvent): void {\n const target = event.target as Element;\n const resource = target['options'].resource;\n this.element.dispatchEvent(\n new CustomEvent('resourceSelect', { detail: { resource: resource } })\n );\n this.goToNext(resource);\n },\n\n /**\n * Override listMixin method: initialize a marker on the map\n * @param resourceId: id of the resource to display\n * @param groupClass: class of the group of markers\n */\n async appendChildElt(resourceId: string, groupClass: string) {\n const resource = await store.getData(resourceId, this.context);\n if (!this.subscriptions.get(resourceId)) {\n this.subscriptions.set(resourceId, PubSub.subscribe(resourceId, () => this.updateDOM()))\n }\n if (!resource) return;\n const lat = await resource['lat'];\n const lng = await resource['lng'];\n\n if (lat && lng) {\n const icon = L.divIcon({ // create the icon, doc here: https://leafletjs.com/reference-1.6.0.html#icon\n className: 'sib-custom-marker ' + groupClass, // default class used for styling\n iconSize: [8, 8],\n iconAnchor: [12, 34],\n popupAnchor: [0,-34]\n });\n\n // create a marker, doc here: https://leafletjs.com/reference-1.6.0.html#marker\n const marker = L.marker(\n [lat.toString(), lng.toString()], \n {resource, icon} as MarkerOptions\n );\n if(this.clustering === null) marker.addTo(this.map);\n else this.markersCluster.addLayer(marker);\n marker.on('click', this.dispatchSelect.bind(this));\n\n if (this.fields !== null) { // show popups only if fields attribute\n marker.bindPopup(() => this.getPopupContent(resourceId), { minWidth: 150 }) // re-generate popup solid-display\n }\n\n this.markers.push(marker);\n }\n },\n /**\n * Generate the solid-display of the popup\n * @param resourceId: id of the popup clicked\n */\n getPopupContent(resourceId: string) {\n const attributes:{[key:string]: string} = {};\n\n for (let attr of this.element.attributes) {\n //copy widget and value attributes\n if (\n attr.name.startsWith('value-') ||\n attr.name.startsWith('label-') ||\n attr.name.startsWith('widget-') ||\n attr.name.startsWith('class-') ||\n attr.name.startsWith('multiple-') ||\n attr.name.startsWith('editable-') ||\n attr.name.startsWith('action-') ||\n attr.name.startsWith('default-') ||\n attr.name == 'extra-context'\n )\n attributes[attr.name] = attr.value;\n if (attr.name.startsWith('child-'))\n attributes[attr.name.replace(/^child-/, '')] = attr.value;\n }\n\n const div = document.createElement('div');\n const template = html`\n <solid-display\n fields=\"${ifDefined(this.fields)}\"\n data-src=\"${resourceId}\"\n ...=${spread(attributes)}\n ></solid-display>\n `;\n render(template, div);\n return div.querySelector('solid-display');\n },\n /**\n * Override widgetMixin method: empty the map\n */\n empty(): void {\n if (!this.map) return;\n if (this.markersCluster) this.map.removeLayer(this.markersCluster);\n for (let marker of this.markers) this.map.removeLayer(marker);\n if(this.clustering !== null) {\n this.markersCluster = L.markerClusterGroup();\n this.map.addLayer(this.markersCluster);\n }\n this.markers = [];\n },\n /**\n * Override groupMixin method\n * @param groupName: value of the group\n */\n renderGroup(groupName: string) {\n const sanitizedGroupName = encodeURIComponent(groupName.toLowerCase()).replace(/%[0-9A-F]{2}/gi, '');\n const div = document.createElement('div'); // used to pass group info to renderDOM\n div.dataset.groupClass = 'group-' + sanitizedGroupName;\n return div;\n },\n /**\n * Override listMixin method: display all the resources\n * @param resources\n * @param listPostProcessors\n * @param div\n * @param context\n */\n async renderDOM(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) {\n const groupClass = div.dataset.groupClass || ''; // get the group class from the useless div element\n await Promise.all(resources.map(resource => this.appendChildElt(resource['@id'], groupClass)))\n this.planReset();\n\n const nextProcessor = listPostProcessors.shift();\n if(nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);\n }\n};\n\nSib.register(SolidMap);"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["interfaces.ts"],"names":[],"mappings":"AAKC;AAUA;AA8BA;AAsBA;AAIA","sourcesContent":["export interface AccessorStaticInterface {\n [key: string]: {\n get: Function;\n set: Function;\n }\n};\n\nexport interface ArrayOfHooksInterface {\n created: HookInterface[];\n attached: HookInterface[];\n detached: HookInterface[];\n}\n\nexport interface AttributeChangedCallbackInterface {\n (newValue: any, oldValue: any): void;\n};\n\nexport interface AttributeDefinitionInterface {\n type?: any;\n default?: any;\n required?: boolean;\n callback?: AttributeChangedCallbackInterface;\n}\n\nexport interface AttributesDefinitionInterface {\n [key: string]: AttributeDefinitionInterface;\n}\n\nexport type ComponentConstructorInterface = new (element: HTMLElement) => ComponentInterface;\n\nexport interface ComponentInterface {\n element: HTMLElement;\n created():void;\n attached():void;\n detached():void;\n\n attributesCallback(key: string, value: any, oldValue: any):void;\n}\n\nexport interface ComponentStaticInterface extends HasAttributesDefinitionInterface, HasInitialStateInterface {\n name: String;\n\n hooks: ArrayOfHooksInterface;\n methods: Map<string, Function>;\n accessors: AccessorStaticInterface;\n};\n\nexport interface HasAttributesDefinitionInterface {\n attributes?: AttributesDefinitionInterface | undefined;\n}\n\nexport interface HasHooksInterface {\n created?: HookInterface;\n attached?: HookInterface;\n detached?: HookInterface;\n}\n\nexport interface HasInitialStateInterface {\n initialState?: object | undefined;\n}\n\nexport interface HasMixinsInterface {\n use?: MixinStaticInterface[] | undefined;\n}\n\nexport interface HookInterface {\n (): void;\n};\n\nexport interface MixinStaticInterface extends HasAttributesDefinitionInterface, HasMixinsInterface, HasInitialStateInterface, HasHooksInterface {\n name: String;\n};\n\nexport interface LocationResourceInterface {\n lat?: HookInterface;\n lng?: HookInterface;\n}\nexport interface Query {\n value: any\n type: \"boolean\" | \"number\" | \"range\" | \"resource\" | \"string\";\n list: boolean\n}\n\nexport interface SearchQuery {\n [key: string]: Query\n}"]}
1
+ {"version":3,"sources":["interfaces.ts"],"names":[],"mappings":"AAKC;AAUA;AA8BA;AAsBA;AAIA","sourcesContent":["export interface AccessorStaticInterface {\n [key: string]: {\n get: Function;\n set: Function;\n }\n};\n\nexport interface ArrayOfHooksInterface {\n created: HookInterface[];\n attached: HookInterface[];\n detached: HookInterface[];\n}\n\nexport interface AttributeChangedCallbackInterface {\n (newValue: any, oldValue: any): void;\n};\n\nexport interface AttributeDefinitionInterface {\n type?: any;\n default?: any;\n required?: boolean;\n callback?: AttributeChangedCallbackInterface;\n}\n\nexport interface AttributesDefinitionInterface {\n [key: string]: AttributeDefinitionInterface;\n}\n\nexport type ComponentConstructorInterface = new (element: HTMLElement) => ComponentInterface;\n\nexport interface ComponentInterface {\n element: HTMLElement;\n created():void;\n attached():void;\n detached():void;\n\n attributesCallback(key: string, value: any, oldValue: any):void;\n}\n\nexport interface ComponentStaticInterface extends HasAttributesDefinitionInterface, HasInitialStateInterface {\n name: String;\n\n hooks: ArrayOfHooksInterface;\n methods: Map<string, Function>;\n accessors: AccessorStaticInterface;\n};\n\nexport interface HasAttributesDefinitionInterface {\n attributes?: AttributesDefinitionInterface | undefined;\n}\n\nexport interface HasHooksInterface {\n created?: HookInterface;\n attached?: HookInterface;\n detached?: HookInterface;\n}\n\nexport interface HasInitialStateInterface {\n initialState?: object | undefined;\n}\n\nexport interface HasMixinsInterface {\n use?: MixinStaticInterface[] | undefined;\n}\n\nexport interface HookInterface {\n (): void;\n};\n\nexport interface MixinStaticInterface extends HasAttributesDefinitionInterface, HasMixinsInterface, HasInitialStateInterface, HasHooksInterface {\n name: String;\n};\n\nexport interface LocationResourceInterface {\n lat?: HookInterface;\n lng?: HookInterface;\n}\n"]}
@@ -59,8 +59,7 @@ class Store {
59
59
  this.subscriptionVirtualContainersIndex = new Map();
60
60
  this.loadingList = new Set();
61
61
  this.headers = {
62
- 'Content-Type': 'application/ld+json',
63
- 'Cache-Control': 'must-revalidate'
62
+ 'Content-Type': 'application/ld+json'
64
63
  };
65
64
  this.fetch = this.storeOptions.fetchMethod;
66
65
  this.session = this.storeOptions.session;
@@ -70,8 +69,6 @@ class Store {
70
69
  * @param id - uri of the resource to fetch
71
70
  * @param context - context used to expand id and predicates when accessing the resource
72
71
  * @param idParent - uri of the parent caller used to expand uri for local files
73
- * @param localData - data to put in cache
74
- * @param forceFetch - force the fetch of data
75
72
  *
76
73
  * @returns The fetched resource
77
74
  *
@@ -79,10 +76,10 @@ class Store {
79
76
  */
80
77
 
81
78
 
82
- async getData(id, context = {}, idParent = "", localData, forceFetch = false) {
79
+ async getData(id, context = {}, idParent = "", localData) {
83
80
  if (localData == null && this.cache.has(id) && !this.loadingList.has(id)) {
84
81
  const resource = this.get(id);
85
- if (resource && resource.isFullResource() && !forceFetch) return resource; // if resource is not complete, re-fetch it
82
+ if (resource && resource.isFullResource()) return resource; // if resource is not complete, re-fetch it
86
83
  }
87
84
 
88
85
  return new Promise(async resolve => {
@@ -133,14 +130,7 @@ class Store {
133
130
  } else {
134
131
  // anonymous
135
132
  if (options.headers) options.headers = this._convertHeaders(options.headers);
136
- return fetch(iri, options).then(function (response) {
137
- if (options.method === "PURGE" && !response.ok && response.status === 404) {
138
- const err = new Error("PURGE call is returning 404");
139
- throw err;
140
- }
141
-
142
- return response;
143
- });
133
+ return fetch(iri, options);
144
134
  }
145
135
  }
146
136
 
@@ -150,7 +140,6 @@ class Store {
150
140
  const headers = { ...this.headers,
151
141
  'accept-language': this._getLanguage()
152
142
  };
153
- console.log("Request Headers:", headers);
154
143
  return this.fetchAuthn(iri, {
155
144
  method: 'GET',
156
145
  headers: headers,
@@ -247,15 +236,11 @@ class Store {
247
236
 
248
237
  const expandedId = this._getExpandedId(id, context);
249
238
 
250
- return this._fetch(method, resource, id).then(async response => {
239
+ return this._fetch(method, resource, id).then(response => {
251
240
  if (response.ok) {
252
241
  var _response$headers;
253
242
 
254
- if (method !== '_LOCAL') {
255
- await this.purge(id);
256
- this.clearCache(expandedId);
257
- } // clear cache
258
-
243
+ if (method !== '_LOCAL') this.clearCache(expandedId); // clear cache
259
244
 
260
245
  this.getData(expandedId, resource['@context']).then(async () => {
261
246
  // re-fetch data
@@ -411,41 +396,6 @@ class Store {
411
396
  async patch(resource, id) {
412
397
  return this._updateResource('PATCH', resource, id);
413
398
  }
414
- /**
415
- * Send a PURGE request to remove a resource from REDIS AD cache
416
- * @param id - uri of the resource to patch
417
- *
418
- * @returns id of the edited resource
419
- */
420
-
421
-
422
- async purge(id) {
423
- console.log('Purging resource ' + id);
424
- await this.fetchAuthn(id, {
425
- method: "PURGE",
426
- headers: this.headers
427
- }).catch(function (error) {
428
- console.warn('No purge method allowed: ' + error);
429
- });
430
-
431
- try {
432
- const fullURL = new URL(id);
433
- var pathArray = fullURL.pathname.split('/');
434
- var containerUrl = fullURL.origin + '/' + pathArray[1] + '/';
435
- const headers = { ...this.headers,
436
- 'X-Cache-Purge-Match': 'startswith'
437
- };
438
- await this.fetchAuthn(containerUrl, {
439
- method: "PURGE",
440
- headers: headers
441
- }).catch(function (error) {
442
- console.warn('No purge method allowed: ' + error);
443
- });
444
- } catch (error) {
445
- console.warn('The resource ID is not a complete URL: ' + error);
446
- return;
447
- }
448
- }
449
399
  /**
450
400
  * Send a DELETE request to delete a resource
451
401
  * @param id - uri of the resource to delete
@@ -463,7 +413,6 @@ class Store {
463
413
  headers: this.headers,
464
414
  credentials: 'include'
465
415
  });
466
- await this.purge(id);
467
416
  const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];
468
417
  const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];
469
418
  this.refreshResources([...resourcesToNotify, ...resourcesToRefresh]).then(resourceIds => this.notifyResources(resourceIds));
@@ -685,12 +634,11 @@ class CustomGetter {
685
634
  * @param id
686
635
  * @param context
687
636
  * @param iriParent
688
- * @param forceFetch
689
637
  */
690
638
 
691
639
 
692
- async getResource(id, context, iriParent, forceFetch = false) {
693
- return store.getData(id, context, iriParent, undefined, forceFetch);
640
+ async getResource(id, context, iriParent) {
641
+ return store.getData(id, context, iriParent);
694
642
  }
695
643
  /**
696
644
  * Return true if the resource is a container
@@ -773,16 +721,8 @@ class CustomGetter {
773
721
  return Object.keys(this.resource).filter(p => !p.startsWith('@')).length > 0;
774
722
  }
775
723
 
776
- async getPermissions() {
777
- const permissionPredicate = this.getExpandedPredicate("permissions");
778
- let permissions = this.resource[permissionPredicate];
779
-
780
- if (!permissions) {
781
- // if no permission, re-fetch data
782
- await this.getResource(this.resourceId, this.clientContext, this.parentId, true);
783
- permissions = this.resource[permissionPredicate];
784
- }
785
-
724
+ getPermissions() {
725
+ const permissions = this.resource[this.getExpandedPredicate("permissions")];
786
726
  return permissions ? permissions.map(perm => ContextParser.expandTerm(perm.mode['@type'], this.serverContext, true)) : [];
787
727
  }
788
728
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["store.ts"],"names":["JSONLDContextParser","PubSub","ContextParser","myParser","base_context","rdf","rdfs","ldp","foaf","name","acl","permissions","mode","geo","lat","lng","Store","constructor","storeOptions","id","resolve","handler","event","detail","resource","document","removeEventListener","cache","Map","subscriptionIndex","subscriptionVirtualContainersIndex","loadingList","Set","headers","fetch","fetchMethod","session","getData","context","idParent","localData","forceFetch","has","get","isFullResource","Promise","addEventListener","resolveResource","add","clientContext","parse","_isLocalId","fetchData","error","console","delete","serverContext","resourceProxy","CustomGetter","getProxy","cacheGraph","dispatchEvent","CustomEvent","fetchAuthn","iri","options","authenticated","then","fn","_convertHeaders","response","method","ok","status","err","Error","_getAbsoluteIri","_getLanguage","log","credentials","json","key","parentContext","parentId","properties","merge","set","getSubObjects","res","newParentContext","getChildren","cacheChildrenPromises","subscribeResourceTo","push","all","match","_fetch","body","JSON","stringify","store","clearCache","_updateResource","includes","expandedId","_getExpandedId","purge","nestedResources","getNestedResources","resourcesToRefresh","resourcesToNotify","refreshResources","resourceIds","notifyResources","filter","resourceWithContexts","map","resourceId","publish","cachedResource","isContainer","nestedProperties","excludeKeys","p","Object","keys","forEach","child","setLocalData","post","put","patch","catch","warn","fullURL","URL","pathArray","pathname","split","containerUrl","origin","deleted","headersObject","Headers","value","entries","expandTerm","startsWith","nestedResourceId","existingSubscriptions","subscribeVirtualContainerTo","virtualContainerId","parentIri","location","href","_resourceIsComplete","length","localStorage","getItem","window","navigator","language","slice","selectLanguage","selectedLanguageCode","setItem","sibStore","sibAuth","querySelector","sibAuthDefined","customElements","whenDefined","localName","getFetch","Symbol","toPrimitive","expandProperties","prop","objectReplaceProperty","object","oldProp","newProp","defineProperty","getOwnPropertyDescriptor","path","path1","path2","getResource","getExpandedPredicate","e","lastPath1El","pop","unshift","undefined","join","iriParent","getProperties","getCompactedPredicate","getLdpContains","children","subObjects","property","isFullNestedResource","getResourceData","getPermissions","permissionPredicate","perm","compactIri","getCompactedIri","toString","Proxy","bind"],"mappings":";;;;AAAA,OAAOA,mBAAP,MAAgC,uBAAhC,C,CACA;;AACA,OAAOC,MAAP,MAAmB,mCAAnB;AAGA,MAAMC,aAAa,GAAGF,mBAAmB,CAACE,aAA1C;AACA,MAAMC,QAAQ,GAAG,IAAID,aAAJ,EAAjB;AAEA,OAAO,MAAME,YAAY,GAAG;AAC1B,YAAU,2BADgB;AAE1BC,EAAAA,GAAG,EAAE,6CAFqB;AAG1BC,EAAAA,IAAI,EAAE,uCAHoB;AAI1BC,EAAAA,GAAG,EAAE,2BAJqB;AAK1BC,EAAAA,IAAI,EAAE,4BALoB;AAM1BC,EAAAA,IAAI,EAAE,YANoB;AAO1BC,EAAAA,GAAG,EAAE,gCAPqB;AAQ1BC,EAAAA,WAAW,EAAE,mBARa;AAS1BC,EAAAA,IAAI,EAAE,UAToB;AAU1BC,EAAAA,GAAG,EAAE,0CAVqB;AAW1BC,EAAAA,GAAG,EAAE,SAXqB;AAY1BC,EAAAA,GAAG,EAAE;AAZqB,CAArB;;AAeP,MAAMC,KAAN,CAAY;AAE2B;AACiB;AAMtDC,EAAAA,WAAW,CAASC,YAAT,EAAqC;AAAA,SAA5BA,YAA4B,GAA5BA,YAA4B;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,6CAyb9B,UAASC,EAAT,EAAqBC,OAArB,EAA8B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AAb,CAAP;AAhBJ;AAkBD;AAvBoB,KAAhB,CAAP;AAyBD;;AAnNgB","sourcesContent":["import JSONLDContextParser from 'jsonld-context-parser';\n//@ts-ignore\nimport PubSub from 'https://cdn.skypack.dev/pubsub-js';\nimport type { Resource } from '../../mixins/interfaces';\n\nconst ContextParser = JSONLDContextParser.ContextParser;\nconst myParser = new ContextParser();\n\nexport const base_context = {\n '@vocab': 'http://happy-dev.fr/owl/#',\n rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n rdfs: 'http://www.w3.org/2000/01/rdf-schema#',\n ldp: 'http://www.w3.org/ns/ldp#',\n foaf: 'http://xmlns.com/foaf/0.1/',\n name: 'rdfs:label',\n acl: 'http://www.w3.org/ns/auth/acl#',\n permissions: 'acl:accessControl',\n mode: 'acl:mode',\n geo: \"http://www.w3.org/2003/01/geo/wgs84_pos#\",\n lat: \"geo:lat\",\n lng: \"geo:long\"\n};\n\nclass Store {\n cache: Map<string, any>;\n subscriptionIndex: Map<string, any>; // index of all the containers per resource\n subscriptionVirtualContainersIndex: Map<string, any>; // index of all the containers per resource\n loadingList: Set<String>;\n headers: object;\n fetch: Promise<any> | undefined;\n session: Promise<any> | undefined;\n\n constructor(private storeOptions: StoreOptions) {\n this.cache = new Map();\n this.subscriptionIndex = new Map();\n this.subscriptionVirtualContainersIndex = new Map();\n this.loadingList = new Set();\n this.headers = {'Content-Type': 'application/ld+json', 'Cache-Control': 'must-revalidate'};\n this.fetch = this.storeOptions.fetchMethod;\n this.session = this.storeOptions.session;\n }\n\n /**\n * Fetch data and cache it\n * @param id - uri of the resource to fetch\n * @param context - context used to expand id and predicates when accessing the resource\n * @param idParent - uri of the parent caller used to expand uri for local files\n * @param localData - data to put in cache\n * @param forceFetch - force the fetch of data\n *\n * @returns The fetched resource\n *\n * @async\n */\n\n async getData(id: string, context:any = {}, idParent = \"\", localData?: object, forceFetch: boolean = false): Promise<Resource|null> {\n if (localData == null && this.cache.has(id) && !this.loadingList.has(id)) {\n const resource = this.get(id);\n if (resource && resource.isFullResource() && !forceFetch) return resource; // if resource is not complete, re-fetch it\n }\n\n return new Promise(async (resolve) => {\n document.addEventListener('resourceReady', this.resolveResource(id, resolve));\n\n if (this.loadingList.has(id)) return;\n this.loadingList.add(id);\n\n // Generate proxy\n const clientContext = await myParser.parse(context);\n let resource: any = null;\n if(this._isLocalId(id)) {\n if(localData == null) localData = {};\n localData[\"@id\"] = id;\n resource = localData;\n } else try {\n resource = localData || await this.fetchData(id, clientContext, idParent);\n } catch (error) { console.error(error) }\n if (!resource) {\n this.loadingList.delete(id);\n resolve(null);\n return;\n }\n const serverContext = await myParser.parse([resource['@context'] || {}]);\n const resourceProxy = new CustomGetter(id, resource, clientContext, serverContext, idParent).getProxy();\n\n // Cache proxy\n await this.cacheGraph(id, resourceProxy, clientContext, serverContext, idParent || id);\n this.loadingList.delete(id);\n document.dispatchEvent(new CustomEvent('resourceReady', { detail: { id: id, resource: this.get(id) } }));\n });\n }\n\n async fetchAuthn(iri: string, options: any) {\n let authenticated = false;\n if (this.session) authenticated = await this.session;\n\n if (this.fetch && authenticated) { // authenticated\n return this.fetch.then(fn => fn(iri, options))\n } else { // anonymous\n if (options.headers) options.headers = this._convertHeaders(options.headers);\n return fetch(iri, options).then(function(response) {\n if (options.method === \"PURGE\" && !response.ok && response.status === 404) {\n const err = new Error(\"PURGE call is returning 404\");\n throw err;\n }\n return response;\n });\n }\n }\n\n async fetchData(id: string, context = {}, idParent = \"\") {\n const iri = this._getAbsoluteIri(id, context, idParent);\n const headers = { ...this.headers, 'accept-language': this._getLanguage() };\n console.log(\"Request Headers:\", headers);\n return this.fetchAuthn(iri, {\n method: 'GET',\n headers: headers,\n credentials: 'include'\n }).then(response => {\n if (!response.ok) return;\n return response.json()\n })\n }\n\n async cacheGraph(key: string, resource: any, clientContext: object, parentContext: object, parentId: string) {\n if (resource.properties) { // if proxy, cache it\n if (this.get(key)) { // if already cached, merge data\n this.cache.get(key).merge(resource);\n } else { // else, put in cache\n this.cache.set(key, resource);\n }\n }\n\n // Cache nested resources\n if (resource.getSubObjects) {\n for (let res of resource.getSubObjects()) {\n let newParentContext = parentContext;\n // If additional context in resource, use it to expand properties\n if (res['@context']) newParentContext = await myParser.parse({ ...parentContext, ...res['@context'] });\n const resourceProxy = new CustomGetter(res['@id'], res, clientContext, newParentContext, parentId).getProxy();\n // this.subscribeResourceTo(resource['@id'], res['@id']); // removed to prevent useless updates\n await this.cacheGraph(res['@id'], resourceProxy, clientContext, parentContext, parentId);\n }\n }\n\n // Cache children of container\n if (resource['@type'] == \"ldp:Container\" && resource.getChildren) {\n const cacheChildrenPromises: Promise<void>[] = [];\n for (let res of resource.getChildren()) {\n this.subscribeResourceTo(resource['@id'], res['@id']);\n cacheChildrenPromises.push(this.cacheGraph(res['@id'], res, clientContext, parentContext, parentId))\n }\n await Promise.all(cacheChildrenPromises);\n return;\n }\n\n // Create proxy, (fetch data) and cache resource\n if (resource['@id'] && !resource.properties) {\n if (resource['@id'].match(/^b\\d+$/)) return; // not anonymous node\n // Fetch data if\n if (resource['@type'] === \"sib:federatedContainer\" && resource['@cache'] !== 'false') { // if object is federated container\n await this.getData(resource['@id'], clientContext, parentId); // then init graph\n return;\n }\n const resourceProxy = new CustomGetter(resource['@id'], resource, clientContext, parentContext, parentId).getProxy();\n await this.cacheGraph(key, resourceProxy, clientContext, parentContext, parentId);\n }\n }\n\n /**\n * Update fetch\n * @param method - 'POST', 'PATCH', 'PUT', '_LOCAL'\n * @param resource - resource to send\n * @param id - uri to update\n * @returns - object\n */\n async _fetch(method: string, resource: object, id: string): Promise<any> {\n if (method !== '_LOCAL')\n return this.fetchAuthn(id, {\n method: method,\n headers: this.headers,\n body: JSON.stringify(resource),\n credentials: 'include'\n });\n\n const resourceProxy = store.get(id);\n const clientContext = resourceProxy ? resourceProxy.clientContext : resource['@context']\n this.clearCache(id);\n await this.getData(id, clientContext, '', resource);\n return {ok: true}\n }\n\n async _updateResource(method: string, resource: object, id: string) {\n if (!['POST', 'PUT', 'PATCH', '_LOCAL'].includes(method)) throw new Error('Error: method not allowed');\n\n const context = await myParser.parse([resource['@context'] || {}]); // parse context before expandTerm\n const expandedId = this._getExpandedId(id, context);\n return this._fetch(method, resource, id).then(async(response) => {\n if (response.ok) {\n if(method !== '_LOCAL') {\n await this.purge(id);\n this.clearCache(expandedId);\n } // clear cache\n this.getData(expandedId, resource['@context']).then(async () => { // re-fetch data\n const nestedResources = await this.getNestedResources(resource, id);\n const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];\n const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];\n\n return this.refreshResources([...nestedResources, ...resourcesToRefresh]) // refresh related resources\n .then(resourceIds => this.notifyResources([expandedId, ...resourceIds, ...resourcesToNotify])); // notify components\n });\n return response.headers?.get('Location') || null;\n } else {\n throw response;\n }\n });\n }\n\n /**\n * Clear cache and refetch data for a list of ids\n * @param resourceIds -\n * @returns - all the resource ids\n */\n async refreshResources(resourceIds: string[]) {\n resourceIds = [...new Set(resourceIds.filter(id => this.cache.has(id)))]; // remove duplicates and not cached resources\n const resourceWithContexts = resourceIds.map(resourceId => ({ \"id\": resourceId, \"context\": store.get(resourceId)?.clientContext }));\n for (const resource of resourceWithContexts) {\n if (!this._isLocalId(resource.id)) this.clearCache(resource.id);\n }\n await Promise.all(resourceWithContexts.map(({ id, context }) => this.getData(id, context || base_context)))\n return resourceIds;\n }\n /**\n * Notifies all components for a list of ids\n * @param resourceIds -\n */\n async notifyResources(resourceIds: string[]) {\n resourceIds = [...new Set(resourceIds)]; // remove duplicates\n for (const id of resourceIds) PubSub.publish(id);\n }\n\n /**\n * Return id of nested properties of a resource\n * @param resource - object\n * @param id - string\n */\n async getNestedResources(resource: object, id: string) {\n const cachedResource = store.get(id);\n if (!cachedResource || cachedResource.isContainer()) return [];\n let nestedProperties:any[] = [];\n const excludeKeys = ['@context'];\n for (let p of Object.keys(resource)) {\n if (resource[p]\n && typeof resource[p] === 'object'\n && !excludeKeys.includes(p)\n && resource[p]['@id']) {\n nestedProperties.push(resource[p]['@id']);\n }\n }\n return nestedProperties;\n }\n\n /**\n * Returns the resource with id from the cache\n * @param id - id of the resource to retrieve\n *\n * @returns Resource (Proxy) if in the cache, null otherwise\n */\n get(id: string): Resource | null {\n return this.cache.get(id) || null;\n }\n\n\n /**\n * Removes a resource from the cache\n * @param id - id of the resource to remove from the cache\n */\n clearCache(id: string): void {\n if (this.cache.has(id)) {\n // For federation, clear each source\n const resource = this.cache.get(id);\n if (resource['@type'] === 'ldp:Container') {\n resource['ldp:contains'].forEach((child: object) => {\n if (child && child['@type'] === 'ldp:Container') this.cache.delete(child['@id'])\n })\n }\n\n this.cache.delete(id);\n }\n }\n\n /**\n * Send data to create a local resource in a container\n * @param resource - resource to create\n * @param id - uri of the container to add resource. should start with ``\n *\n * @returns id of the posted resource\n */\n async setLocalData(resource: object, id: string): Promise<string | null> {\n return this._updateResource('_LOCAL', resource, id);\n }\n\n /**\n * Send a POST request to create a resource in a container\n * @param resource - resource to create\n * @param id - uri of the container to add resource\n *\n * @returns id of the posted resource\n */\n async post(resource: object, id: string): Promise<string | null> {\n return this._updateResource('POST', resource, id);\n }\n\n /**\n * Send a PUT request to edit a resource\n * @param resource - resource data to send\n * @param id - uri of the resource to edit\n *\n * @returns id of the edited resource\n */\n async put(resource: object, id: string): Promise<string | null> {\n return this._updateResource('PUT', resource, id);\n }\n\n /**\n * Send a PATCH request to edit a resource\n * @param resource - resource data to send\n * @param id - uri of the resource to patch\n *\n * @returns id of the edited resource\n */\n async patch(resource: object, id: string): Promise<string | null> {\n return this._updateResource('PATCH', resource, id);\n }\n\n /**\n * Send a PURGE request to remove a resource from REDIS AD cache\n * @param id - uri of the resource to patch\n *\n * @returns id of the edited resource\n */\n async purge(id: string) {\n console.log('Purging resource ' + id);\n await this.fetchAuthn(id, {\n method: \"PURGE\",\n headers: this.headers\n }).catch(function(error) {\n console.warn('No purge method allowed: ' + error)\n });\n\n try {\n const fullURL = new URL(id);\n var pathArray = fullURL.pathname.split('/');\n var containerUrl = fullURL.origin + '/' + pathArray[1] + '/';\n const headers = { ...this.headers, 'X-Cache-Purge-Match': 'startswith' };\n await this.fetchAuthn(containerUrl, {\n method: \"PURGE\",\n headers: headers\n }).catch(function(error) {\n console.warn('No purge method allowed: ' + error)\n });\n } catch (error) {\n console.warn('The resource ID is not a complete URL: ' + error);\n return;\n }\n }\n\n /**\n * Send a DELETE request to delete a resource\n * @param id - uri of the resource to delete\n * @param context - can be used to expand id\n *\n * @returns id of the deleted resource\n */\n async delete(id: string, context: object = {}) {\n const expandedId = this._getExpandedId(id, context);\n const deleted = await this.fetchAuthn(expandedId, {\n method: 'DELETE',\n headers: this.headers,\n credentials: 'include'\n });\n await this.purge(id);\n\n const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];\n const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];\n\n this.refreshResources([...resourcesToNotify, ...resourcesToRefresh])\n .then(resourceIds => this.notifyResources(resourceIds));\n\n return deleted;\n }\n\n /**\n * Convert headers object to Headers\n * @param headersObject - object\n * @returns {Headers}\n */\n _convertHeaders(headersObject: object): Headers {\n const headers = new Headers();\n for (const [key, value] of Object.entries(headersObject)){\n headers.set(key, value as string);\n }\n return headers;\n }\n\n _getExpandedId(id: string, context: object) {\n return (context && Object.keys(context)) ? ContextParser.expandTerm(id, context) : id;\n }\n\n _isLocalId(id: string) {\n return id.startsWith('store://local.');\n }\n\n /**\n * Make a resource listen changes of another one\n * @param resourceId - id of the resource which needs to be updated\n * @param nestedResourceId - id of the resource which will change\n */\n subscribeResourceTo(resourceId: string, nestedResourceId: string) {\n const existingSubscriptions = this.subscriptionIndex.get(nestedResourceId) || [];\n this.subscriptionIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, resourceId])])\n }\n\n /**\n * Make a virtual container listen for changes of a resource\n * @param virtualContainerId - id of the container which needs to be updated\n * @param nestedResourceId - id of the resource which will change\n */\n subscribeVirtualContainerTo(virtualContainerId: string, nestedResourceId: string) {\n const existingSubscriptions = this.subscriptionVirtualContainersIndex.get(nestedResourceId) || [];\n this.subscriptionVirtualContainersIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, virtualContainerId])])\n }\n\n /**\n * Return absolute IRI of the resource\n * @param id\n * @param context\n * @param parentId\n */\n _getAbsoluteIri(id: string, context: object, parentId: string): string {\n let iri = ContextParser.expandTerm(id, context); // expand if reduced ids\n if (parentId) { // and get full URL from parent caller for local files\n let parentIri = new URL(parentId, document.location.href).href;\n iri = new URL(iri, parentIri).href;\n } else {\n iri = new URL(iri, document.location.href).href;\n }\n return iri;\n }\n\n /**\n * Check if object is a full resource\n * @param resource\n */\n _resourceIsComplete(resource: object) {\n return !!(Object.keys(resource).filter(p => !p.startsWith('@')).length > 0 && resource['@id'])\n }\n\n /**\n * Return language of the users\n */\n _getLanguage() {\n return localStorage.getItem('language') || window.navigator.language.slice(0,2);\n }\n\n /**\n * Save the preferred language of the user\n * @param selectedLanguageCode\n */\n selectLanguage(selectedLanguageCode: string) {\n localStorage.setItem('language', selectedLanguageCode);\n }\n\n resolveResource = function(id: string, resolve) {\n const handler = function(event) {\n if (event.detail.id === id) {\n resolve(event.detail.resource);\n // TODO : callback\n document.removeEventListener('resourceReady', handler);\n }\n };\n return handler;\n };\n}\n\nlet store: Store;\nif (window.sibStore) {\n store = window.sibStore;\n} else {\n const sibAuth = document.querySelector('sib-auth');\n const storeOptions: StoreOptions = {}\n\n if (sibAuth) {\n const sibAuthDefined = customElements.whenDefined(sibAuth.localName);\n storeOptions.session = sibAuthDefined.then(() => (sibAuth as any).session)\n storeOptions.fetchMethod = sibAuthDefined.then(() => (sibAuth as any).getFetch())\n }\n\n store = new Store(storeOptions);\n window.sibStore = store;\n}\n\nexport {\n store\n};\n\n\nclass CustomGetter {\n resource: any; // content of the requested resource\n resourceId: string;\n clientContext: object; // context given by the app\n serverContext: object; // context given by the server\n parentId: string; // id of the parent resource, used to get the absolute url of the current resource\n\n constructor(resourceId: string, resource: object, clientContext: object, serverContext: object = {}, parentId: string = \"\") {\n this.clientContext = clientContext;\n this.serverContext = serverContext;\n this.parentId = parentId;\n this.resource = this.expandProperties({ ...resource }, serverContext);\n this.resourceId = resourceId;\n }\n\n /**\n * Expand all predicates of a resource with a given context\n * @param resource: object\n * @param context: object\n */\n expandProperties(resource: object, context: object | string) {\n for (let prop of Object.keys(resource)) {\n if (!prop) continue;\n this.objectReplaceProperty(resource, prop, ContextParser.expandTerm(prop, context as JSONLDContextParser.IJsonLdContextNormalized, true));\n }\n return resource\n }\n\n /**\n * Change the key of an object\n * @param object: object\n * @param oldProp: string - current key\n * @param newProp: string - new key to set\n */\n objectReplaceProperty(object: object, oldProp: string, newProp: string) {\n if (newProp !== oldProp) {\n Object.defineProperty(\n object,\n newProp,\n Object.getOwnPropertyDescriptor(object, oldProp) || ''\n );\n delete object[oldProp];\n }\n }\n\n /**\n * Get the property of a resource for a given path\n * @param path: string\n */\n async get(path: any) {\n if (!path) return;\n const path1: string[] = path.split('.');\n const path2: string[] = [];\n let value: any;\n if (!this.isFullResource()) { // if resource is not complete, fetch it first\n await this.getResource(this.resourceId, this.clientContext, this.parentId);\n }\n while (true) {\n try {\n value = this.resource[this.getExpandedPredicate(path1[0])];\n } catch (e) { break }\n\n if (path1.length <= 1) break; // no dot path\n const lastPath1El = path1.pop();\n if(lastPath1El) path2.unshift(lastPath1El);\n }\n if (path2.length === 0) { // end of the path\n if (!value || !value['@id']) return value; // no value or not a resource\n return await this.getResource(value['@id'], this.clientContext, this.parentId || this.resourceId); // return complete resource\n }\n if (!value) return undefined;\n let resource = await this.getResource(value['@id'], this.clientContext, this.parentId || this.resourceId);\n\n store.subscribeResourceTo(this.resourceId, value['@id']);\n return resource ? await resource[path2.join('.')] : undefined; // return value\n }\n\n /**\n * Cache resource in the store, and return the created proxy\n * @param id\n * @param context\n * @param iriParent\n * @param forceFetch\n */\n async getResource(id: string, context: object, iriParent: string, forceFetch: boolean = false): Promise<Resource | null> {\n return store.getData(id, context, iriParent, undefined, forceFetch);\n }\n\n /**\n * Return true if the resource is a container\n */\n isContainer(): boolean {\n return this.resource[\"@type\"] == \"ldp:Container\" || this.resource[\"@type\"] == \"sib:federatedContainer\";\n }\n\n /**\n * Get all properties of a resource\n */\n getProperties(): string[] {\n return Object.keys(this.resource).map(prop => this.getCompactedPredicate(prop));\n }\n\n /**\n * Get children of container as objects\n */\n getChildren(): object[] {\n return this.resource[this.getExpandedPredicate(\"ldp:contains\")] || [];\n }\n\n /**\n * Get children of container as Proxys\n */\n getLdpContains(): CustomGetter[] {\n const children = this.resource[this.getExpandedPredicate(\"ldp:contains\")];\n return children ? children.map((res: object) => store.get(res['@id'])) : [];\n }\n\n /**\n * Get all nested resource or containers which contains datas\n */\n getSubObjects() {\n let subObjects: any = [];\n for (let p of Object.keys(this.resource)) {\n let property = this.resource[p];\n if (!this.isFullNestedResource(property)) continue; // if not a resource, stop\n if (property['@type'] == \"ldp:Container\" &&\n (property['ldp:contains'] == undefined ||\n (property['ldp:contains'].length >= 1 && !this.isFullNestedResource(property['ldp:contains'][0])))\n ) continue; // if not a full container\n subObjects.push(property)\n }\n return subObjects;\n }\n\n merge(resource: CustomGetter) {\n this.resource = {...this.getResourceData(), ...resource.getResourceData()}\n }\n\n getResourceData(): object { return this.resource }\n\n /**\n * return true if prop is a resource with an @id and some properties\n * @param prop\n */\n isFullNestedResource(prop: any): boolean {\n return prop &&\n typeof prop == \"object\" &&\n prop['@id'] != undefined &&\n Object.keys(prop).filter(p => !p.startsWith('@')).length > 0;\n }\n /**\n * return true resource seems complete\n * @param prop\n */\n isFullResource(): boolean {\n return Object.keys(this.resource).filter(p => !p.startsWith('@')).length > 0;\n }\n\n async getPermissions(): Promise<string[]> {\n const permissionPredicate = this.getExpandedPredicate(\"permissions\");\n let permissions = this.resource[permissionPredicate];\n if (!permissions) { // if no permission, re-fetch data\n await this.getResource(this.resourceId, this.clientContext, this.parentId, true);\n permissions = this.resource[permissionPredicate];\n }\n return permissions ? permissions.map(perm => ContextParser.expandTerm(perm.mode['@type'], this.serverContext, true)) : [];\n }\n\n /**\n * Remove the resource from the cache\n */\n clearCache(): void {\n store.clearCache(this.resourceId);\n }\n\n getExpandedPredicate(property: string) { return ContextParser.expandTerm(property, this.clientContext, true) }\n getCompactedPredicate(property: string) { return ContextParser.compactIri(property, this.clientContext, true) }\n getCompactedIri(id: string) { return ContextParser.compactIri(id, this.clientContext) }\n toString() { return this.getCompactedIri(this.resource['@id']) }\n [Symbol.toPrimitive]() { return this.getCompactedIri(this.resource['@id']) }\n\n\n /**\n * Returns a Proxy which handles the different get requests\n */\n getProxy() {\n return new Proxy(this, {\n get: (resource, property) => {\n if (!this.resource) return undefined;\n if (typeof resource[property] === 'function') return resource[property].bind(resource)\n\n switch (property) {\n case '@id':\n return this.getCompactedIri(this.resource['@id']); // Compact @id if possible\n case '@type':\n return this.resource['@type']; // return synchronously\n case 'properties':\n return this.getProperties();\n case 'ldp:contains':\n return this.getLdpContains(); // returns standard arrays synchronously\n case 'permissions':\n return this.getPermissions(); // get expanded permissions\n case 'clientContext':\n return this.clientContext; // get saved client context to re-fetch easily a resource\n case 'then':\n return;\n default:\n return resource.get(property);\n }\n }\n })\n }\n}"]}
1
+ {"version":3,"sources":["store.ts"],"names":["JSONLDContextParser","PubSub","ContextParser","myParser","base_context","rdf","rdfs","ldp","foaf","name","acl","permissions","mode","geo","lat","lng","Store","constructor","storeOptions","id","resolve","handler","event","detail","resource","document","removeEventListener","cache","Map","subscriptionIndex","subscriptionVirtualContainersIndex","loadingList","Set","headers","fetch","fetchMethod","session","getData","context","idParent","localData","has","get","isFullResource","Promise","addEventListener","resolveResource","add","clientContext","parse","_isLocalId","fetchData","error","console","delete","serverContext","resourceProxy","CustomGetter","getProxy","cacheGraph","dispatchEvent","CustomEvent","fetchAuthn","iri","options","authenticated","then","fn","_convertHeaders","_getAbsoluteIri","_getLanguage","method","credentials","response","ok","json","key","parentContext","parentId","properties","merge","set","getSubObjects","res","newParentContext","getChildren","cacheChildrenPromises","subscribeResourceTo","push","all","match","_fetch","body","JSON","stringify","store","clearCache","_updateResource","includes","Error","expandedId","_getExpandedId","nestedResources","getNestedResources","resourcesToRefresh","resourcesToNotify","refreshResources","resourceIds","notifyResources","filter","resourceWithContexts","map","resourceId","publish","cachedResource","isContainer","nestedProperties","excludeKeys","p","Object","keys","forEach","child","setLocalData","post","put","patch","deleted","headersObject","Headers","value","entries","expandTerm","startsWith","nestedResourceId","existingSubscriptions","subscribeVirtualContainerTo","virtualContainerId","parentIri","URL","location","href","_resourceIsComplete","length","localStorage","getItem","window","navigator","language","slice","selectLanguage","selectedLanguageCode","setItem","sibStore","sibAuth","querySelector","sibAuthDefined","customElements","whenDefined","localName","getFetch","Symbol","toPrimitive","expandProperties","prop","objectReplaceProperty","object","oldProp","newProp","defineProperty","getOwnPropertyDescriptor","path","path1","split","path2","getResource","getExpandedPredicate","e","lastPath1El","pop","unshift","undefined","join","iriParent","getProperties","getCompactedPredicate","getLdpContains","children","subObjects","property","isFullNestedResource","getResourceData","getPermissions","perm","compactIri","getCompactedIri","toString","Proxy","bind"],"mappings":";;;;AAAA,OAAOA,mBAAP,MAAgC,uBAAhC,C,CACA;;AACA,OAAOC,MAAP,MAAmB,mCAAnB;AAGA,MAAMC,aAAa,GAAGF,mBAAmB,CAACE,aAA1C;AACA,MAAMC,QAAQ,GAAG,IAAID,aAAJ,EAAjB;AAEA,OAAO,MAAME,YAAY,GAAG;AAC1B,YAAU,2BADgB;AAE1BC,EAAAA,GAAG,EAAE,6CAFqB;AAG1BC,EAAAA,IAAI,EAAE,uCAHoB;AAI1BC,EAAAA,GAAG,EAAE,2BAJqB;AAK1BC,EAAAA,IAAI,EAAE,4BALoB;AAM1BC,EAAAA,IAAI,EAAE,YANoB;AAO1BC,EAAAA,GAAG,EAAE,gCAPqB;AAQ1BC,EAAAA,WAAW,EAAE,mBARa;AAS1BC,EAAAA,IAAI,EAAE,UAToB;AAU1BC,EAAA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;AACEkC,EAAAA,QAAQ,GAAG;AACT,WAAO,IAAI2I,KAAJ,CAAU,IAAV,EAAgB;AACrB3J,MAAAA,GAAG,EAAE,CAAClB,QAAD,EAAWqK,QAAX,KAAwB;AAC3B,YAAI,CAAC,KAAKrK,QAAV,EAAoB,OAAO6J,SAAP;AACpB,YAAI,OAAO7J,QAAQ,CAACqK,QAAD,CAAf,KAA8B,UAAlC,EAA8C,OAAOrK,QAAQ,CAACqK,QAAD,CAAR,CAAmBS,IAAnB,CAAwB9K,QAAxB,CAAP;;AAE9C,gBAAQqK,QAAR;AACE,eAAK,KAAL;AACE,mBAAO,KAAKM,eAAL,CAAqB,KAAK3K,QAAL,CAAc,KAAd,CAArB,CAAP;AAAmD;;AACrD,eAAK,OAAL;AACE,mBAAO,KAAKA,QAAL,CAAc,OAAd,CAAP;AAA+B;;AACjC,eAAK,YAAL;AACE,mBAAO,KAAKgK,aAAL,EAAP;;AACF,eAAK,cAAL;AACE,mBAAO,KAAKE,cAAL,EAAP;AAA8B;;AAChC,eAAK,aAAL;AACE,mBAAO,KAAKM,cAAL,EAAP;AAA8B;;AAChC,eAAK,eAAL;AACE,mBAAO,KAAKhJ,aAAZ;AAA2B;;AAC7B,eAAK,MAAL;AACE;;AACF;AACE,mBAAOxB,QAAQ,CAACkB,GAAT,CAAamJ,QAAb,CAAP;AAhBJ;AAkBD;AAvBoB,KAAhB,CAAP;AAyBD;;AA7MgB","sourcesContent":["import JSONLDContextParser from 'jsonld-context-parser';\n//@ts-ignore\nimport PubSub from 'https://cdn.skypack.dev/pubsub-js';\nimport type { Resource } from '../../mixins/interfaces';\n\nconst ContextParser = JSONLDContextParser.ContextParser;\nconst myParser = new ContextParser();\n\nexport const base_context = {\n '@vocab': 'http://happy-dev.fr/owl/#',\n rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n rdfs: 'http://www.w3.org/2000/01/rdf-schema#',\n ldp: 'http://www.w3.org/ns/ldp#',\n foaf: 'http://xmlns.com/foaf/0.1/',\n name: 'rdfs:label',\n acl: 'http://www.w3.org/ns/auth/acl#',\n permissions: 'acl:accessControl',\n mode: 'acl:mode',\n geo: \"http://www.w3.org/2003/01/geo/wgs84_pos#\",\n lat: \"geo:lat\",\n lng: \"geo:long\"\n};\n\nclass Store {\n cache: Map<string, any>;\n subscriptionIndex: Map<string, any>; // index of all the containers per resource\n subscriptionVirtualContainersIndex: Map<string, any>; // index of all the containers per resource\n loadingList: Set<String>;\n headers: object;\n fetch: Promise<any> | undefined;\n session: Promise<any> | undefined;\n\n constructor(private storeOptions: StoreOptions) {\n this.cache = new Map();\n this.subscriptionIndex = new Map();\n this.subscriptionVirtualContainersIndex = new Map();\n this.loadingList = new Set();\n this.headers = {'Content-Type': 'application/ld+json'};\n this.fetch = this.storeOptions.fetchMethod;\n this.session = this.storeOptions.session;\n }\n\n /**\n * Fetch data and cache it\n * @param id - uri of the resource to fetch\n * @param context - context used to expand id and predicates when accessing the resource\n * @param idParent - uri of the parent caller used to expand uri for local files\n *\n * @returns The fetched resource\n *\n * @async\n */\n\n async getData(id: string, context:any = {}, idParent = \"\", localData?: object): Promise<Resource|null> {\n if (localData == null && this.cache.has(id) && !this.loadingList.has(id)) {\n const resource = this.get(id);\n if (resource && resource.isFullResource()) return resource; // if resource is not complete, re-fetch it\n }\n\n return new Promise(async (resolve) => {\n document.addEventListener('resourceReady', this.resolveResource(id, resolve));\n\n if (this.loadingList.has(id)) return;\n this.loadingList.add(id);\n\n // Generate proxy\n const clientContext = await myParser.parse(context);\n let resource: any = null;\n if(this._isLocalId(id)) {\n if(localData == null) localData = {};\n localData[\"@id\"] = id;\n resource = localData;\n } else try {\n resource = localData || await this.fetchData(id, clientContext, idParent);\n } catch (error) { console.error(error) }\n if (!resource) {\n this.loadingList.delete(id);\n resolve(null);\n return;\n }\n const serverContext = await myParser.parse([resource['@context'] || {}]);\n const resourceProxy = new CustomGetter(id, resource, clientContext, serverContext, idParent).getProxy();\n\n // Cache proxy\n await this.cacheGraph(id, resourceProxy, clientContext, serverContext, idParent || id);\n this.loadingList.delete(id);\n document.dispatchEvent(new CustomEvent('resourceReady', { detail: { id: id, resource: this.get(id) } }));\n });\n }\n\n async fetchAuthn(iri: string, options: any) {\n let authenticated = false;\n if (this.session) authenticated = await this.session;\n\n if (this.fetch && authenticated) { // authenticated\n return this.fetch.then(fn => fn(iri, options))\n } else { // anonymous\n if (options.headers) options.headers = this._convertHeaders(options.headers);\n return fetch(iri, options);\n }\n }\n\n async fetchData(id: string, context = {}, idParent = \"\") {\n const iri = this._getAbsoluteIri(id, context, idParent);\n const headers = { ...this.headers, 'accept-language': this._getLanguage() };\n return this.fetchAuthn(iri, {\n method: 'GET',\n headers: headers,\n credentials: 'include'\n }).then(response => {\n if (!response.ok) return;\n return response.json()\n })\n }\n\n async cacheGraph(key: string, resource: any, clientContext: object, parentContext: object, parentId: string) {\n if (resource.properties) { // if proxy, cache it\n if (this.get(key)) { // if already cached, merge data\n this.cache.get(key).merge(resource);\n } else { // else, put in cache\n this.cache.set(key, resource);\n }\n }\n\n // Cache nested resources\n if (resource.getSubObjects) {\n for (let res of resource.getSubObjects()) {\n let newParentContext = parentContext;\n // If additional context in resource, use it to expand properties\n if (res['@context']) newParentContext = await myParser.parse({ ...parentContext, ...res['@context'] });\n const resourceProxy = new CustomGetter(res['@id'], res, clientContext, newParentContext, parentId).getProxy();\n // this.subscribeResourceTo(resource['@id'], res['@id']); // removed to prevent useless updates\n await this.cacheGraph(res['@id'], resourceProxy, clientContext, parentContext, parentId);\n }\n }\n\n // Cache children of container\n if (resource['@type'] == \"ldp:Container\" && resource.getChildren) {\n const cacheChildrenPromises: Promise<void>[] = [];\n for (let res of resource.getChildren()) {\n this.subscribeResourceTo(resource['@id'], res['@id']);\n cacheChildrenPromises.push(this.cacheGraph(res['@id'], res, clientContext, parentContext, parentId))\n }\n await Promise.all(cacheChildrenPromises);\n return;\n }\n\n // Create proxy, (fetch data) and cache resource\n if (resource['@id'] && !resource.properties) {\n if (resource['@id'].match(/^b\\d+$/)) return; // not anonymous node\n // Fetch data if\n if (resource['@type'] === \"sib:federatedContainer\" && resource['@cache'] !== 'false') { // if object is federated container\n await this.getData(resource['@id'], clientContext, parentId); // then init graph\n return;\n }\n const resourceProxy = new CustomGetter(resource['@id'], resource, clientContext, parentContext, parentId).getProxy();\n await this.cacheGraph(key, resourceProxy, clientContext, parentContext, parentId);\n }\n }\n\n /**\n * Update fetch\n * @param method - 'POST', 'PATCH', 'PUT', '_LOCAL'\n * @param resource - resource to send\n * @param id - uri to update\n * @returns - object\n */\n async _fetch(method: string, resource: object, id: string): Promise<any> {\n if (method !== '_LOCAL')\n return this.fetchAuthn(id, {\n method: method,\n headers: this.headers,\n body: JSON.stringify(resource),\n credentials: 'include'\n })\n\n const resourceProxy = store.get(id);\n const clientContext = resourceProxy ? resourceProxy.clientContext : resource['@context']\n this.clearCache(id);\n await this.getData(id, clientContext, '', resource);\n return {ok: true}\n }\n\n async _updateResource(method: string, resource: object, id: string) {\n if (!['POST', 'PUT', 'PATCH', '_LOCAL'].includes(method)) throw new Error('Error: method not allowed');\n\n const context = await myParser.parse([resource['@context'] || {}]); // parse context before expandTerm\n const expandedId = this._getExpandedId(id, context);\n return this._fetch(method, resource, id).then(response => {\n if (response.ok) {\n if(method !== '_LOCAL') this.clearCache(expandedId); // clear cache\n this.getData(expandedId, resource['@context']).then(async () => { // re-fetch data\n const nestedResources = await this.getNestedResources(resource, id);\n const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];\n const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];\n\n return this.refreshResources([...nestedResources, ...resourcesToRefresh]) // refresh related resources\n .then(resourceIds => this.notifyResources([expandedId, ...resourceIds, ...resourcesToNotify])); // notify components\n });\n return response.headers?.get('Location') || null;\n } else {\n throw response;\n }\n });\n }\n\n /**\n * Clear cache and refetch data for a list of ids\n * @param resourceIds -\n * @returns - all the resource ids\n */\n async refreshResources(resourceIds: string[]) {\n resourceIds = [...new Set(resourceIds.filter(id => this.cache.has(id)))]; // remove duplicates and not cached resources\n const resourceWithContexts = resourceIds.map(resourceId => ({ \"id\": resourceId, \"context\": store.get(resourceId)?.clientContext }));\n for (const resource of resourceWithContexts) {\n if (!this._isLocalId(resource.id)) this.clearCache(resource.id);\n }\n await Promise.all(resourceWithContexts.map(({ id, context }) => this.getData(id, context || base_context)))\n return resourceIds;\n }\n /**\n * Notifies all components for a list of ids\n * @param resourceIds -\n */\n async notifyResources(resourceIds: string[]) {\n resourceIds = [...new Set(resourceIds)]; // remove duplicates\n for (const id of resourceIds) PubSub.publish(id);\n }\n\n /**\n * Return id of nested properties of a resource\n * @param resource - object\n * @param id - string\n */\n async getNestedResources(resource: object, id: string) {\n const cachedResource = store.get(id);\n if (!cachedResource || cachedResource.isContainer()) return [];\n let nestedProperties:any[] = [];\n const excludeKeys = ['@context'];\n for (let p of Object.keys(resource)) {\n if (resource[p]\n && typeof resource[p] === 'object'\n && !excludeKeys.includes(p)\n && resource[p]['@id']) {\n nestedProperties.push(resource[p]['@id']);\n }\n }\n return nestedProperties;\n }\n\n /**\n * Returns the resource with id from the cache\n * @param id - id of the resource to retrieve\n *\n * @returns Resource (Proxy) if in the cache, null otherwise\n */\n get(id: string): Resource | null {\n return this.cache.get(id) || null;\n }\n\n\n /**\n * Removes a resource from the cache\n * @param id - id of the resource to remove from the cache\n */\n clearCache(id: string): void {\n if (this.cache.has(id)) {\n // For federation, clear each source\n const resource = this.cache.get(id);\n if (resource['@type'] === 'ldp:Container') {\n resource['ldp:contains'].forEach((child: object) => {\n if (child && child['@type'] === 'ldp:Container') this.cache.delete(child['@id'])\n })\n }\n\n this.cache.delete(id);\n }\n }\n\n /**\n * Send data to create a local resource in a container\n * @param resource - resource to create\n * @param id - uri of the container to add resource. should start with ``\n *\n * @returns id of the posted resource\n */\n async setLocalData(resource: object, id: string): Promise<string | null> {\n return this._updateResource('_LOCAL', resource, id);\n }\n\n /**\n * Send a POST request to create a resource in a container\n * @param resource - resource to create\n * @param id - uri of the container to add resource\n *\n * @returns id of the posted resource\n */\n async post(resource: object, id: string): Promise<string | null> {\n return this._updateResource('POST', resource, id);\n }\n\n /**\n * Send a PUT request to edit a resource\n * @param resource - resource data to send\n * @param id - uri of the resource to edit\n *\n * @returns id of the edited resource\n */\n async put(resource: object, id: string): Promise<string | null> {\n return this._updateResource('PUT', resource, id);\n }\n\n /**\n * Send a PATCH request to edit a resource\n * @param resource - resource data to send\n * @param id - uri of the resource to patch\n *\n * @returns id of the edited resource\n */\n async patch(resource: object, id: string): Promise<string | null> {\n return this._updateResource('PATCH', resource, id);\n }\n\n /**\n * Send a DELETE request to delete a resource\n * @param id - uri of the resource to delete\n * @param context - can be used to expand id\n *\n * @returns id of the deleted resource\n */\n async delete(id: string, context: object = {}) {\n const expandedId = this._getExpandedId(id, context);\n const deleted = await this.fetchAuthn(expandedId, {\n method: 'DELETE',\n headers: this.headers,\n credentials: 'include'\n });\n\n const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];\n const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];\n\n this.refreshResources([...resourcesToNotify, ...resourcesToRefresh])\n .then(resourceIds => this.notifyResources(resourceIds));\n\n return deleted;\n }\n\n /**\n * Convert headers object to Headers\n * @param headersObject - object\n * @returns {Headers}\n */\n _convertHeaders(headersObject: object): Headers {\n const headers = new Headers();\n for (const [key, value] of Object.entries(headersObject)){\n headers.set(key, value as string);\n }\n return headers;\n }\n\n _getExpandedId(id: string, context: object) {\n return (context && Object.keys(context)) ? ContextParser.expandTerm(id, context) : id;\n }\n\n _isLocalId(id: string) {\n return id.startsWith('store://local.');\n }\n\n /**\n * Make a resource listen changes of another one\n * @param resourceId - id of the resource which needs to be updated\n * @param nestedResourceId - id of the resource which will change\n */\n subscribeResourceTo(resourceId: string, nestedResourceId: string) {\n const existingSubscriptions = this.subscriptionIndex.get(nestedResourceId) || [];\n this.subscriptionIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, resourceId])])\n }\n\n /**\n * Make a virtual container listen for changes of a resource\n * @param virtualContainerId - id of the container which needs to be updated\n * @param nestedResourceId - id of the resource which will change\n */\n subscribeVirtualContainerTo(virtualContainerId: string, nestedResourceId: string) {\n const existingSubscriptions = this.subscriptionVirtualContainersIndex.get(nestedResourceId) || [];\n this.subscriptionVirtualContainersIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, virtualContainerId])])\n }\n\n /**\n * Return absolute IRI of the resource\n * @param id\n * @param context\n * @param parentId\n */\n _getAbsoluteIri(id: string, context: object, parentId: string): string {\n let iri = ContextParser.expandTerm(id, context); // expand if reduced ids\n if (parentId) { // and get full URL from parent caller for local files\n let parentIri = new URL(parentId, document.location.href).href;\n iri = new URL(iri, parentIri).href;\n } else {\n iri = new URL(iri, document.location.href).href;\n }\n return iri;\n }\n\n /**\n * Check if object is a full resource\n * @param resource\n */\n _resourceIsComplete(resource: object) {\n return !!(Object.keys(resource).filter(p => !p.startsWith('@')).length > 0 && resource['@id'])\n }\n\n /**\n * Return language of the users\n */\n _getLanguage() {\n return localStorage.getItem('language') || window.navigator.language.slice(0,2);\n }\n\n /**\n * Save the preferred language of the user\n * @param selectedLanguageCode\n */\n selectLanguage(selectedLanguageCode: string) {\n localStorage.setItem('language', selectedLanguageCode);\n }\n\n resolveResource = function(id: string, resolve) {\n const handler = function(event) {\n if (event.detail.id === id) {\n resolve(event.detail.resource);\n // TODO : callback\n document.removeEventListener('resourceReady', handler);\n }\n };\n return handler;\n };\n}\n\nlet store: Store;\nif (window.sibStore) {\n store = window.sibStore;\n} else {\n const sibAuth = document.querySelector('sib-auth');\n const storeOptions: StoreOptions = {}\n\n if (sibAuth) {\n const sibAuthDefined = customElements.whenDefined(sibAuth.localName);\n storeOptions.session = sibAuthDefined.then(() => (sibAuth as any).session)\n storeOptions.fetchMethod = sibAuthDefined.then(() => (sibAuth as any).getFetch())\n }\n\n store = new Store(storeOptions);\n window.sibStore = store;\n}\n\nexport {\n store\n};\n\n\nclass CustomGetter {\n resource: any; // content of the requested resource\n resourceId: string;\n clientContext: object; // context given by the app\n serverContext: object; // context given by the server\n parentId: string; // id of the parent resource, used to get the absolute url of the current resource\n\n constructor(resourceId: string, resource: object, clientContext: object, serverContext: object = {}, parentId: string = \"\") {\n this.clientContext = clientContext;\n this.serverContext = serverContext;\n this.parentId = parentId;\n this.resource = this.expandProperties({ ...resource }, serverContext);\n this.resourceId = resourceId;\n }\n\n /**\n * Expand all predicates of a resource with a given context\n * @param resource: object\n * @param context: object\n */\n expandProperties(resource: object, context: object | string) {\n for (let prop of Object.keys(resource)) {\n if (!prop) continue;\n this.objectReplaceProperty(resource, prop, ContextParser.expandTerm(prop, context as JSONLDContextParser.IJsonLdContextNormalized, true));\n }\n return resource\n }\n\n /**\n * Change the key of an object\n * @param object: object\n * @param oldProp: string - current key\n * @param newProp: string - new key to set\n */\n objectReplaceProperty(object: object, oldProp: string, newProp: string) {\n if (newProp !== oldProp) {\n Object.defineProperty(\n object,\n newProp,\n Object.getOwnPropertyDescriptor(object, oldProp) || ''\n );\n delete object[oldProp];\n }\n }\n\n /**\n * Get the property of a resource for a given path\n * @param path: string\n */\n async get(path: any) {\n if (!path) return;\n const path1: string[] = path.split('.');\n const path2: string[] = [];\n let value: any;\n if (!this.isFullResource()) { // if resource is not complete, fetch it first\n await this.getResource(this.resourceId, this.clientContext, this.parentId);\n }\n while (true) {\n try {\n value = this.resource[this.getExpandedPredicate(path1[0])];\n } catch (e) { break }\n\n if (path1.length <= 1) break; // no dot path\n const lastPath1El = path1.pop();\n if(lastPath1El) path2.unshift(lastPath1El);\n }\n if (path2.length === 0) { // end of the path\n if (!value || !value['@id']) return value; // no value or not a resource\n return await this.getResource(value['@id'], this.clientContext, this.parentId || this.resourceId); // return complete resource\n }\n if (!value) return undefined;\n let resource = await this.getResource(value['@id'], this.clientContext, this.parentId || this.resourceId);\n\n store.subscribeResourceTo(this.resourceId, value['@id']);\n return resource ? await resource[path2.join('.')] : undefined; // return value\n }\n\n /**\n * Cache resource in the store, and return the created proxy\n * @param id\n * @param context\n * @param iriParent\n */\n async getResource(id: string, context: object, iriParent: string): Promise<Resource | null> {\n return store.getData(id, context, iriParent);\n }\n\n /**\n * Return true if the resource is a container\n */\n isContainer(): boolean {\n return this.resource[\"@type\"] == \"ldp:Container\" || this.resource[\"@type\"] == \"sib:federatedContainer\";\n }\n\n /**\n * Get all properties of a resource\n */\n getProperties(): string[] {\n return Object.keys(this.resource).map(prop => this.getCompactedPredicate(prop));\n }\n\n /**\n * Get children of container as objects\n */\n getChildren(): object[] {\n return this.resource[this.getExpandedPredicate(\"ldp:contains\")] || [];\n }\n\n /**\n * Get children of container as Proxys\n */\n getLdpContains(): CustomGetter[] {\n const children = this.resource[this.getExpandedPredicate(\"ldp:contains\")];\n return children ? children.map((res: object) => store.get(res['@id'])) : [];\n }\n\n /**\n * Get all nested resource or containers which contains datas\n */\n getSubObjects() {\n let subObjects: any = [];\n for (let p of Object.keys(this.resource)) {\n let property = this.resource[p];\n if (!this.isFullNestedResource(property)) continue; // if not a resource, stop\n if (property['@type'] == \"ldp:Container\" &&\n (property['ldp:contains'] == undefined ||\n (property['ldp:contains'].length >= 1 && !this.isFullNestedResource(property['ldp:contains'][0])))\n ) continue; // if not a full container\n subObjects.push(property)\n }\n return subObjects;\n }\n\n merge(resource: CustomGetter) {\n this.resource = {...this.getResourceData(), ...resource.getResourceData()}\n }\n\n getResourceData(): object { return this.resource }\n\n /**\n * return true if prop is a resource with an @id and some properties\n * @param prop\n */\n isFullNestedResource(prop: any): boolean {\n return prop &&\n typeof prop == \"object\" &&\n prop['@id'] != undefined &&\n Object.keys(prop).filter(p => !p.startsWith('@')).length > 0;\n }\n /**\n * return true resource seems complete\n * @param prop\n */\n isFullResource(): boolean {\n return Object.keys(this.resource).filter(p => !p.startsWith('@')).length > 0;\n }\n\n getPermissions(): string[] {\n const permissions = this.resource[this.getExpandedPredicate(\"permissions\")];\n return permissions ? permissions.map(perm => ContextParser.expandTerm(perm.mode['@type'], this.serverContext, true)) : [];\n }\n\n /**\n * Remove the resource from the cache\n */\n clearCache(): void {\n store.clearCache(this.resourceId);\n }\n\n getExpandedPredicate(property: string) { return ContextParser.expandTerm(property, this.clientContext, true) }\n getCompactedPredicate(property: string) { return ContextParser.compactIri(property, this.clientContext, true) }\n getCompactedIri(id: string) { return ContextParser.compactIri(id, this.clientContext) }\n toString() { return this.getCompactedIri(this.resource['@id']) }\n [Symbol.toPrimitive]() { return this.getCompactedIri(this.resource['@id']) }\n\n\n /**\n * Returns a Proxy which handles the different get requests\n */\n getProxy() {\n return new Proxy(this, {\n get: (resource, property) => {\n if (!this.resource) return undefined;\n if (typeof resource[property] === 'function') return resource[property].bind(resource)\n\n switch (property) {\n case '@id':\n return this.getCompactedIri(this.resource['@id']); // Compact @id if possible\n case '@type':\n return this.resource['@type']; // return synchronously\n case 'properties':\n return this.getProperties();\n case 'ldp:contains':\n return this.getLdpContains(); // returns standard arrays synchronously\n case 'permissions':\n return this.getPermissions(); // get expanded permissions\n case 'clientContext':\n return this.clientContext; // get saved client context to re-fetch easily a resource\n case 'then':\n return;\n default:\n return resource.get(property);\n }\n }\n })\n }\n}"]}