@startinblox/core 0.17.21-beta.8 → 0.17.21-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -826,8 +826,9 @@ class CustomGetter {
826
826
 
827
827
  switch (property) {
828
828
  case '@id':
829
- return this.getCompactedIri(this.resource['@id']);
830
- // Compact @id if possible
829
+ if (this.resource['@id']) return this.getCompactedIri(this.resource['@id']); // Compact @id if possible
830
+ else console.log(this.resource, this.resource['@id']);
831
+ return;
831
832
 
832
833
  case '@type':
833
834
  return this.resource['@type'];
@@ -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;AAC9C,YAAMC,OA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;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","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;AA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xL,QAAL,CAAc,KAAd,CAArB,CAAP,CADF,CACqD;AADrD,iBAGE8B,OAAO,CAACwB,GAAR,CAAY,KAAKtD,QAAjB,EAA2B,KAAKA,QAAL,CAAc,KAAd,CAA3B;AACA;;AACJ,eAAK,OAAL;AACE,mBAAO,KAAKA,QAAL,CAAc,OAAd,CAAP;AAA+B;;AACjC,eAAK,YAAL;AACE,mBAAO,KAAK4K,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,KAAK3J,aAAZ;AAA2B;;AAC7B,eAAK,MAAL;AACE;;AACF;AACE,mBAAOzB,QAAQ,CAACmB,GAAT,CAAa8J,QAAb,CAAP;AApBJ;AAsBD;AA3BoB,KAAhB,CAAP;AA6BD;;AAvNgB","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 if (this.resource['@id'])\n return this.getCompactedIri(this.resource['@id']); // Compact @id if possible\n else\n console.log(this.resource, this.resource['@id']);\n return;\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}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "0.17.21-beta.8",
3
+ "version": "0.17.21-beta.9",
4
4
  "description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",