@startinblox/core 0.19.0-beta.2 → 0.19.0-beta.20
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.
- package/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css → assets/MarkerCluster-614dea0a.css} +0 -0
- package/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css → assets/MarkerCluster.Default-61258232.css} +0 -0
- package/dist/assets/en-e53105c5.js +14 -0
- package/dist/assets/en-e53105c5.js.map +1 -0
- package/dist/assets/fr-a7fcdb64.js +14 -0
- package/dist/assets/fr-a7fcdb64.js.map +1 -0
- package/dist/{_snowpack/pkg/fusejs.js → assets/helpers-bf15809c.js} +398 -454
- package/dist/assets/helpers-bf15809c.js.map +1 -0
- package/dist/{_snowpack/pkg/leaflet/dist/leaflet.css → assets/leaflet-3c081932.css} +3 -3
- package/dist/helpers.js +18 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.js +54606 -48
- package/dist/index.js.map +1 -0
- package/package.json +7 -22
- package/dist/_snowpack/pkg/autolinker.js +0 -4429
- package/dist/_snowpack/pkg/autolinker.js.map +0 -1
- package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js +0 -353
- package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js.map +0 -1
- package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js +0 -26
- package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js.map +0 -1
- package/dist/_snowpack/pkg/common/decode-26fbf385.js +0 -185
- package/dist/_snowpack/pkg/common/decode-26fbf385.js.map +0 -1
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js +0 -1104
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js.map +0 -1
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js +0 -26198
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +0 -1
- package/dist/_snowpack/pkg/dialog-polyfill.js +0 -826
- package/dist/_snowpack/pkg/dialog-polyfill.js.map +0 -1
- package/dist/_snowpack/pkg/fusejs.js.map +0 -1
- package/dist/_snowpack/pkg/import-map.json +0 -25
- package/dist/_snowpack/pkg/jsonld-context-parser.js +0 -836
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map +0 -1
- package/dist/_snowpack/pkg/jsonld.js +0 -11760
- package/dist/_snowpack/pkg/jsonld.js.map +0 -1
- package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -39
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -48
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -87
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html.js +0 -94
- package/dist/_snowpack/pkg/lit-html.js.map +0 -1
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js +0 -68
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +0 -1
- package/dist/_snowpack/pkg/markdown-it.js +0 -11307
- package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
- package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -971
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
- package/dist/_snowpack/pkg/quill.js +0 -14441
- package/dist/_snowpack/pkg/quill.js.map +0 -1
- package/dist/_snowpack/pkg/slim-select.js +0 -714
- package/dist/_snowpack/pkg/slim-select.js.map +0 -1
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1149
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/tui-calendar.js +0 -46503
- package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
- package/dist/components/solid-ac-checker.js +0 -45
- package/dist/components/solid-calendar.js +0 -66
- package/dist/components/solid-delete.js +0 -96
- package/dist/components/solid-display.js +0 -150
- package/dist/components/solid-form-search.js +0 -173
- package/dist/components/solid-form.js +0 -257
- package/dist/components/solid-lang.js +0 -35
- package/dist/components/solid-map.js +0 -204
- package/dist/components/solid-table.js +0 -181
- package/dist/components/solid-widget.js +0 -72
- package/dist/import.css +0 -4
- package/dist/libs/Component.js +0 -13
- package/dist/libs/ComponentFactory.js +0 -165
- package/dist/libs/Compositor.js +0 -96
- package/dist/libs/Sib.js +0 -44
- package/dist/libs/filter.js +0 -184
- package/dist/libs/helpers.js +0 -185
- package/dist/libs/interfaces.js +0 -6
- package/dist/libs/lit-helpers.js +0 -139
- package/dist/libs/polyfills.js +0 -35
- package/dist/libs/store/custom-getter.js +0 -313
- package/dist/libs/store/server-pagination.js +0 -19
- package/dist/libs/store/server-search.js +0 -32
- package/dist/libs/store/store.js +0 -560
- package/dist/locales/en.json +0 -10
- package/dist/locales/en.json.proxy.js +0 -2
- package/dist/locales/fr.json +0 -10
- package/dist/locales/fr.json.proxy.js +0 -2
- package/dist/mixins/attributeBinderMixin.js +0 -113
- package/dist/mixins/contextMixin.js +0 -26
- package/dist/mixins/counterMixin.js +0 -54
- package/dist/mixins/federationMixin.js +0 -57
- package/dist/mixins/filterMixin.js +0 -152
- package/dist/mixins/grouperMixin.js +0 -73
- package/dist/mixins/highlighterMixin.js +0 -36
- package/dist/mixins/interfaces.js +0 -6
- package/dist/mixins/listMixin.js +0 -116
- package/dist/mixins/nextMixin.js +0 -23
- package/dist/mixins/paginateMixin.js +0 -97
- package/dist/mixins/requiredMixin.js +0 -38
- package/dist/mixins/serverPaginationMixin.js +0 -122
- package/dist/mixins/sorterMixin.js +0 -131
- package/dist/mixins/storeMixin.js +0 -139
- package/dist/mixins/translationMixin.js +0 -58
- package/dist/mixins/validationMixin.js +0 -95
- package/dist/mixins/widgetMixin.js +0 -364
- package/dist/new-widgets/attributeMixins/actionMixin.js +0 -13
- package/dist/new-widgets/attributeMixins/blankMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/index.js +0 -19
- package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -27
- package/dist/new-widgets/attributeMixins/numberMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -16
- package/dist/new-widgets/attributeMixins/telMixin.js +0 -7
- package/dist/new-widgets/baseWidgetMixin.js +0 -109
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -96
- package/dist/new-widgets/callbackMixins/index.js +0 -7
- package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -37
- package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
- package/dist/new-widgets/interfaces.js +0 -1
- package/dist/new-widgets/new-widget-factory.js +0 -91
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -26
- package/dist/new-widgets/templateAdditionMixins/index.js +0 -13
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -16
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -18
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -29
- package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -54
- package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -423
- package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -11
- package/dist/new-widgets/templates/index.js +0 -6
- package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -16
- package/dist/new-widgets/templatesDependencies/altMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -60
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -34
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -10
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -41
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -59
- package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -82
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/formMixin.js +0 -56
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -10
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -13
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -125
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
- package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -100
- package/dist/new-widgets/templatesDependencies/setMixin.js +0 -9
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -9
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -14
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -29
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -12
- package/dist/new-widgets/valueTransformationMixins/index.js +0 -15
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -30
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -13
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -21
- package/dist/solid-template-element.js +0 -144
- package/dist/style/default-theme.css.proxy.js +0 -10
- package/dist/widgets/baseWidget.js +0 -267
- package/dist/widgets/widget-factory.js +0 -20
- /package/dist/{style/default-theme.css → assets/default-theme-d0f20a8a.css} +0 -0
- /package/dist/{_snowpack/pkg/quill/dist/quill.snow.css → assets/quill.snow-8f222e44.css} +0 -0
- /package/dist/{new-widgets/callbackMixins/slimselect.css → assets/slimselect-43e3ebc8.css} +0 -0
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export function formatAttributesToServerSearchOptions(elementAttributes) {
|
|
2
|
-
const attributes = new Map(Array.from(elementAttributes).map(({
|
|
3
|
-
name,
|
|
4
|
-
value
|
|
5
|
-
}) => [name, value]));
|
|
6
|
-
const fields = attributes.get('server-search-fields')?.split(",").map(field => field.trim());
|
|
7
|
-
const value = attributes.get('server-search-value')?.trim();
|
|
8
|
-
const method = attributes.get('server-search-method')?.trim();
|
|
9
|
-
return {
|
|
10
|
-
fields: fields && fields.length > 0 ? fields : undefined,
|
|
11
|
-
value: value ? value : undefined,
|
|
12
|
-
method: method ? method : undefined
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export function mergeServerSearchOptions(attributesOptions, dynamicOptions) {
|
|
16
|
-
const fields = attributesOptions?.fields ?? dynamicOptions?.fields;
|
|
17
|
-
const value = dynamicOptions?.value ?? attributesOptions?.value;
|
|
18
|
-
const method = attributesOptions?.method ?? dynamicOptions?.method;
|
|
19
|
-
if (!fields || fields.length === 0 || !value) return;
|
|
20
|
-
return {
|
|
21
|
-
fields,
|
|
22
|
-
value,
|
|
23
|
-
method
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export function appendServerSearchToIri(iri, options) {
|
|
27
|
-
const first = iri.includes('?') ? '&' : '?';
|
|
28
|
-
const fields = options.fields.map(encodeURIComponent).join(',');
|
|
29
|
-
const value = encodeURIComponent(options.value);
|
|
30
|
-
const method = encodeURIComponent(options.method ?? 'ibasic');
|
|
31
|
-
return `${iri}${first}search-fields=${fields}&search-terms=${value}&search-method=${method}`;
|
|
32
|
-
}
|
package/dist/libs/store/store.js
DELETED
|
@@ -1,560 +0,0 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
-
import JSONLDContextParser from '../../_snowpack/pkg/jsonld-context-parser.js';
|
|
5
|
-
//@ts-ignore
|
|
6
|
-
import PubSub from 'https://cdn.skypack.dev/pubsub-js';
|
|
7
|
-
import jsonld from '../../_snowpack/pkg/jsonld.js';
|
|
8
|
-
import { CustomGetter } from './custom-getter.js';
|
|
9
|
-
import { appendServerSearchToIri } from './server-search.js';
|
|
10
|
-
import { appendServerPaginationToIri } from './server-pagination.js';
|
|
11
|
-
const ContextParser = JSONLDContextParser.ContextParser;
|
|
12
|
-
const myParser = new ContextParser();
|
|
13
|
-
export const base_context = {
|
|
14
|
-
'@vocab': 'http://happy-dev.fr/owl/#',
|
|
15
|
-
rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
|
16
|
-
rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
|
|
17
|
-
ldp: 'http://www.w3.org/ns/ldp#',
|
|
18
|
-
foaf: 'http://xmlns.com/foaf/0.1/',
|
|
19
|
-
name: 'rdfs:label',
|
|
20
|
-
acl: 'http://www.w3.org/ns/auth/acl#',
|
|
21
|
-
permissions: 'acl:accessControl',
|
|
22
|
-
mode: 'acl:mode',
|
|
23
|
-
geo: "http://www.w3.org/2003/01/geo/wgs84_pos#",
|
|
24
|
-
lat: "geo:lat",
|
|
25
|
-
lng: "geo:long"
|
|
26
|
-
};
|
|
27
|
-
class Store {
|
|
28
|
-
constructor(storeOptions) {
|
|
29
|
-
this.storeOptions = storeOptions;
|
|
30
|
-
_defineProperty(this, "cache", void 0);
|
|
31
|
-
_defineProperty(this, "subscriptionIndex", void 0);
|
|
32
|
-
// index of all the containers per resource
|
|
33
|
-
_defineProperty(this, "subscriptionVirtualContainersIndex", void 0);
|
|
34
|
-
// index of all the containers per resource
|
|
35
|
-
_defineProperty(this, "loadingList", void 0);
|
|
36
|
-
_defineProperty(this, "headers", void 0);
|
|
37
|
-
_defineProperty(this, "fetch", void 0);
|
|
38
|
-
_defineProperty(this, "session", void 0);
|
|
39
|
-
_defineProperty(this, "resolveResource", function (id, resolve) {
|
|
40
|
-
const handler = function (event) {
|
|
41
|
-
if (event.detail.id === id) {
|
|
42
|
-
resolve(event.detail.resource);
|
|
43
|
-
// TODO : callback
|
|
44
|
-
document.removeEventListener('resourceReady', handler);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
return handler;
|
|
48
|
-
});
|
|
49
|
-
this.cache = new Map();
|
|
50
|
-
this.subscriptionIndex = new Map();
|
|
51
|
-
this.subscriptionVirtualContainersIndex = new Map();
|
|
52
|
-
this.loadingList = new Set();
|
|
53
|
-
this.headers = {
|
|
54
|
-
'Accept': 'application/ld+json',
|
|
55
|
-
'Content-Type': 'application/ld+json',
|
|
56
|
-
'Cache-Control': 'must-revalidate'
|
|
57
|
-
};
|
|
58
|
-
this.fetch = this.storeOptions.fetchMethod;
|
|
59
|
-
this.session = this.storeOptions.session;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Fetch data and cache it
|
|
64
|
-
* @param id - uri of the resource to fetch
|
|
65
|
-
* @param context - context used to expand id and predicates when accessing the resource
|
|
66
|
-
* @param parentId - uri of the parent caller used to expand uri for local files
|
|
67
|
-
* @param localData - data to put in cache
|
|
68
|
-
* @param forceFetch - force the fetch of data
|
|
69
|
-
* @param serverPagination - Server pagination options
|
|
70
|
-
* @param serverSearch - Server search options
|
|
71
|
-
* @param predicateName - predicate name if we target a specific predicate from the resource, useful for arrays
|
|
72
|
-
*
|
|
73
|
-
* @returns The fetched resource
|
|
74
|
-
*
|
|
75
|
-
* @async
|
|
76
|
-
*/
|
|
77
|
-
async getData(id, context = {}, parentId = "", localData, forceFetch = false, serverPagination, serverSearch) {
|
|
78
|
-
let key = id;
|
|
79
|
-
if (serverPagination) {
|
|
80
|
-
key = id + "#p" + serverPagination.limit + "?o" + serverPagination.offset;
|
|
81
|
-
}
|
|
82
|
-
if (serverSearch) {
|
|
83
|
-
key = appendServerSearchToIri(key, serverSearch);
|
|
84
|
-
}
|
|
85
|
-
if (localData == null && this.cache.has(key) && !this.loadingList.has(key)) {
|
|
86
|
-
const resource = this.get(key);
|
|
87
|
-
if (resource && resource.isFullResource?.() && !forceFetch) return resource; // if resource is not complete, re-fetch it
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return new Promise(async resolve => {
|
|
91
|
-
document.addEventListener('resourceReady', this.resolveResource(key, resolve));
|
|
92
|
-
if (this.loadingList.has(key)) return;
|
|
93
|
-
this.loadingList.add(key);
|
|
94
|
-
|
|
95
|
-
// Generate proxy
|
|
96
|
-
const clientContext = await myParser.parse(context);
|
|
97
|
-
let resource = null;
|
|
98
|
-
if (this._isLocalId(id)) {
|
|
99
|
-
if (localData == null) localData = {};
|
|
100
|
-
localData["@id"] = id;
|
|
101
|
-
resource = localData;
|
|
102
|
-
} else try {
|
|
103
|
-
resource = localData || (await this.fetchData(id, clientContext, parentId, serverPagination, serverSearch));
|
|
104
|
-
} catch (error) {
|
|
105
|
-
console.error(error);
|
|
106
|
-
}
|
|
107
|
-
if (!resource) {
|
|
108
|
-
this.loadingList.delete(key);
|
|
109
|
-
resolve(null);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const serverContext = await myParser.parse([resource['@context'] || {}]);
|
|
113
|
-
// const resourceProxy = new CustomGetter(key, resource, clientContext, serverContext, parentId ? parentId : key, serverPagination, serverSearch).getProxy();
|
|
114
|
-
// Cache proxy
|
|
115
|
-
await this.cacheGraph(resource, clientContext, serverContext, parentId ? parentId : key, serverPagination, serverSearch);
|
|
116
|
-
this.loadingList.delete(key);
|
|
117
|
-
document.dispatchEvent(new CustomEvent('resourceReady', {
|
|
118
|
-
detail: {
|
|
119
|
-
id: key,
|
|
120
|
-
resource: this.get(key)
|
|
121
|
-
}
|
|
122
|
-
}));
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
async fetchAuthn(iri, options) {
|
|
126
|
-
let authenticated = false;
|
|
127
|
-
if (this.session) authenticated = await this.session;
|
|
128
|
-
if (this.fetch && authenticated) {
|
|
129
|
-
// authenticated
|
|
130
|
-
return this.fetch.then(fn => fn(iri, options));
|
|
131
|
-
} else {
|
|
132
|
-
// anonymous
|
|
133
|
-
if (options.headers) options.headers = this._convertHeaders(options.headers);
|
|
134
|
-
return fetch(iri, options).then(function (response) {
|
|
135
|
-
if (options.method === "PURGE" && !response.ok && response.status === 404) {
|
|
136
|
-
const err = new Error("PURGE call is returning 404");
|
|
137
|
-
throw err;
|
|
138
|
-
}
|
|
139
|
-
return response;
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Fetch resource
|
|
146
|
-
* @param id - id of the resource
|
|
147
|
-
* @param context - context used to expand id
|
|
148
|
-
* @param idParent - id of the caller resource. Needed to expand id
|
|
149
|
-
* @param serverPagination - Server pagination query params
|
|
150
|
-
* @param serverSearch - Server search query params
|
|
151
|
-
* @returns data in json
|
|
152
|
-
*/
|
|
153
|
-
async fetchData(id, context = {}, parentId = "", serverPagination, serverSearch) {
|
|
154
|
-
let iri = this._getAbsoluteIri(id, context, parentId);
|
|
155
|
-
if (serverPagination) iri = appendServerPaginationToIri(iri, serverPagination);
|
|
156
|
-
if (serverSearch) iri = appendServerSearchToIri(iri, serverSearch);
|
|
157
|
-
const headers = {
|
|
158
|
-
...this.headers,
|
|
159
|
-
'accept-language': this._getLanguage()
|
|
160
|
-
// 'Prefer' : 'return=representation; max-triple-count="100"' // Commenting out for now as it raises CORS errors
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Fetch data with authentication if available (sib-auth)
|
|
165
|
-
* @param iri - iri to call
|
|
166
|
-
* @param options - options of the request
|
|
167
|
-
* @returns - response
|
|
168
|
-
*/
|
|
169
|
-
return this.fetchAuthn(iri, {
|
|
170
|
-
method: 'GET',
|
|
171
|
-
headers: headers,
|
|
172
|
-
credentials: 'include'
|
|
173
|
-
}).then(response => {
|
|
174
|
-
if (!response.ok) return;
|
|
175
|
-
return response.json();
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Cache the whole graph
|
|
181
|
-
* @param resource - graph fetched
|
|
182
|
-
* @param clientContext - context of the client app
|
|
183
|
-
* @param parentContext - context of the server
|
|
184
|
-
* @param parentId - id of the parent caller
|
|
185
|
-
* @param serverPagination - Server pagination query params
|
|
186
|
-
* @param serverSearch - Server search query params
|
|
187
|
-
*/
|
|
188
|
-
async cacheGraph(resource, clientContext, parentContext, parentId, serverPagination, serverSearch) {
|
|
189
|
-
const flattenedResources = await jsonld.flatten(resource);
|
|
190
|
-
const compactedResources = await Promise.all(flattenedResources.map(r => jsonld.compact(r, {})));
|
|
191
|
-
for (let resource of compactedResources) {
|
|
192
|
-
let id = resource['@id'] || resource['id'];
|
|
193
|
-
let key = resource['@id'] || resource['id'];
|
|
194
|
-
if (!key) console.log('No key or id for resource:', resource);
|
|
195
|
-
if (key === '/') key = parentId;
|
|
196
|
-
if (key.startsWith('_:b')) key = key + parentId; // anonymous node -> change key before saving in cache
|
|
197
|
-
|
|
198
|
-
// We have to add the server search and pagination attributes again here to the resource cache key
|
|
199
|
-
if (key === id && resource['@type'] == this.getExpandedPredicate("ldp:Container", clientContext)) {
|
|
200
|
-
// Add only pagination and search params to the original resource
|
|
201
|
-
if (serverPagination) key = key + "#p" + serverPagination.limit + "?o" + serverPagination.offset;
|
|
202
|
-
if (serverSearch) key = appendServerSearchToIri(key, serverSearch);
|
|
203
|
-
}
|
|
204
|
-
const resourceProxy = new CustomGetter(key, resource, clientContext, parentContext, parentId, serverPagination, serverSearch).getProxy();
|
|
205
|
-
if (resourceProxy.isContainer()) this.subscribeChildren(resourceProxy, id);
|
|
206
|
-
if (this.get(key)) {
|
|
207
|
-
// if already cached, merge data
|
|
208
|
-
this.cache.get(key).merge(resourceProxy);
|
|
209
|
-
} else {
|
|
210
|
-
// else, put in cache
|
|
211
|
-
this.cacheResource(key, resourceProxy);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Put proxy in cache
|
|
218
|
-
* @param key
|
|
219
|
-
* @param resourceProxy
|
|
220
|
-
*/
|
|
221
|
-
cacheResource(key, resourceProxy) {
|
|
222
|
-
this.cache.set(key, resourceProxy);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Update fetch
|
|
227
|
-
* @param method - 'POST', 'PATCH', 'PUT', '_LOCAL'
|
|
228
|
-
* @param resource - resource to send
|
|
229
|
-
* @param id - uri to update
|
|
230
|
-
* @returns - object
|
|
231
|
-
*/
|
|
232
|
-
async _fetch(method, resource, id) {
|
|
233
|
-
if (method !== '_LOCAL') return this.fetchAuthn(id, {
|
|
234
|
-
method: method,
|
|
235
|
-
headers: this.headers,
|
|
236
|
-
body: JSON.stringify(resource),
|
|
237
|
-
credentials: 'include'
|
|
238
|
-
});
|
|
239
|
-
const resourceProxy = store.get(id);
|
|
240
|
-
const clientContext = resourceProxy ? {
|
|
241
|
-
...resourceProxy.clientContext,
|
|
242
|
-
...resource['@context']
|
|
243
|
-
} : resource['@context'];
|
|
244
|
-
this.clearCache(id);
|
|
245
|
-
await this.getData(id, clientContext, '', resource);
|
|
246
|
-
return {
|
|
247
|
-
ok: true
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Subscribe all the children of a container to its parent
|
|
253
|
-
* @param container
|
|
254
|
-
*/
|
|
255
|
-
subscribeChildren(container, containerId) {
|
|
256
|
-
if (!container['ldp:contains']) return;
|
|
257
|
-
for (let res of container['ldp:contains']) {
|
|
258
|
-
this.subscribeResourceTo(containerId, res['@id'] || res['id']);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Update a resource
|
|
264
|
-
* @param method - can be POST, PUT or PATCH
|
|
265
|
-
* @param resource - content of the updated resource
|
|
266
|
-
* @param id - id of the resource to update
|
|
267
|
-
* @returns void
|
|
268
|
-
*/
|
|
269
|
-
async _updateResource(method, resource, id) {
|
|
270
|
-
if (!['POST', 'PUT', 'PATCH', '_LOCAL'].includes(method)) throw new Error('Error: method not allowed');
|
|
271
|
-
const context = await myParser.parse([resource['@context'] || {}]); // parse context before expandTerm
|
|
272
|
-
const expandedId = this._getExpandedId(id, context);
|
|
273
|
-
return this._fetch(method, resource, id).then(async response => {
|
|
274
|
-
if (response.ok) {
|
|
275
|
-
if (method !== '_LOCAL') {
|
|
276
|
-
// await this.purge(id);
|
|
277
|
-
this.clearCache(expandedId);
|
|
278
|
-
} // clear cache
|
|
279
|
-
this.getData(expandedId, resource['@context']).then(async () => {
|
|
280
|
-
// re-fetch data
|
|
281
|
-
const nestedResources = await this.getNestedResources(resource, id);
|
|
282
|
-
const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];
|
|
283
|
-
const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];
|
|
284
|
-
return this.refreshResources([...nestedResources, ...resourcesToRefresh]) // refresh related resources
|
|
285
|
-
.then(resourceIds => this.notifyResources([expandedId, ...resourceIds, ...resourcesToNotify])); // notify components
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
return response.headers?.get('Location') || null;
|
|
289
|
-
} else {
|
|
290
|
-
throw response;
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Clear cache and refetch data for a list of ids
|
|
297
|
-
* @param resourceIds -
|
|
298
|
-
* @returns - all the resource ids
|
|
299
|
-
*/
|
|
300
|
-
async refreshResources(resourceIds) {
|
|
301
|
-
resourceIds = [...new Set(resourceIds.filter(id => this.cache.has(id)))]; // remove duplicates and not cached resources
|
|
302
|
-
const resourceWithContexts = resourceIds.map(resourceId => ({
|
|
303
|
-
"id": resourceId,
|
|
304
|
-
"context": store.get(resourceId)?.clientContext
|
|
305
|
-
}));
|
|
306
|
-
for (const resource of resourceWithContexts) {
|
|
307
|
-
if (!this._isLocalId(resource.id)) this.clearCache(resource.id);
|
|
308
|
-
}
|
|
309
|
-
await Promise.all(resourceWithContexts.map(({
|
|
310
|
-
id,
|
|
311
|
-
context
|
|
312
|
-
}) => this.getData(id, context || base_context)));
|
|
313
|
-
return resourceIds;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Notifies all components for a list of ids
|
|
317
|
-
* @param resourceIds -
|
|
318
|
-
*/
|
|
319
|
-
async notifyResources(resourceIds) {
|
|
320
|
-
resourceIds = [...new Set(resourceIds)]; // remove duplicates
|
|
321
|
-
for (const id of resourceIds) PubSub.publish(id);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Return id of nested properties of a resource
|
|
326
|
-
* @param resource - object
|
|
327
|
-
* @param id - string
|
|
328
|
-
*/
|
|
329
|
-
async getNestedResources(resource, id) {
|
|
330
|
-
const cachedResource = store.get(id);
|
|
331
|
-
if (!cachedResource || cachedResource.isContainer?.()) return [];
|
|
332
|
-
let nestedProperties = [];
|
|
333
|
-
const excludeKeys = ['@context'];
|
|
334
|
-
for (let p of Object.keys(resource)) {
|
|
335
|
-
if (resource[p] && typeof resource[p] === 'object' && !excludeKeys.includes(p) && resource[p]['@id']) {
|
|
336
|
-
nestedProperties.push(resource[p]['@id']);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return nestedProperties;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Returns the resource with id from the cache
|
|
344
|
-
* @param id - id of the resource to retrieve
|
|
345
|
-
*
|
|
346
|
-
* @returns Resource (Proxy) if in the cache, null otherwise
|
|
347
|
-
*/
|
|
348
|
-
get(id, serverSearch) {
|
|
349
|
-
if (serverSearch) {
|
|
350
|
-
id = appendServerSearchToIri(id, serverSearch);
|
|
351
|
-
}
|
|
352
|
-
return this.cache.get(id) || null;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Removes a resource from the cache
|
|
357
|
-
* @param id - id of the resource to remove from the cache
|
|
358
|
-
*/
|
|
359
|
-
clearCache(id) {
|
|
360
|
-
if (this.cache.has(id)) {
|
|
361
|
-
// For federation, clear each source
|
|
362
|
-
const resource = this.cache.get(id);
|
|
363
|
-
if (resource['@type'] === 'ldp:Container') {
|
|
364
|
-
resource['ldp:contains'].forEach(child => {
|
|
365
|
-
if (child && child['@type'] === 'ldp:Container') this.cache.delete(child['@id']);
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
this.cache.delete(id);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Send data to create a local resource in a container
|
|
374
|
-
* @param resource - resource to create
|
|
375
|
-
* @param id - uri of the container to add resource. should start with ``
|
|
376
|
-
*
|
|
377
|
-
* @returns id of the posted resource
|
|
378
|
-
*/
|
|
379
|
-
async setLocalData(resource, id) {
|
|
380
|
-
return this._updateResource('_LOCAL', resource, id);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Send a POST request to create a resource in a container
|
|
385
|
-
* @param resource - resource to create
|
|
386
|
-
* @param id - uri of the container to add resource
|
|
387
|
-
*
|
|
388
|
-
* @returns id of the posted resource
|
|
389
|
-
*/
|
|
390
|
-
async post(resource, id) {
|
|
391
|
-
return this._updateResource('POST', resource, id);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Send a PUT request to edit a resource
|
|
396
|
-
* @param resource - resource data to send
|
|
397
|
-
* @param id - uri of the resource to edit
|
|
398
|
-
*
|
|
399
|
-
* @returns id of the edited resource
|
|
400
|
-
*/
|
|
401
|
-
async put(resource, id) {
|
|
402
|
-
return this._updateResource('PUT', resource, id);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Send a PATCH request to edit a resource
|
|
407
|
-
* @param resource - resource data to send
|
|
408
|
-
* @param id - uri of the resource to patch
|
|
409
|
-
*
|
|
410
|
-
* @returns id of the edited resource
|
|
411
|
-
*/
|
|
412
|
-
async patch(resource, id) {
|
|
413
|
-
return this._updateResource('PATCH', resource, id);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Send a PURGE request to remove a resource from REDIS AD cache
|
|
418
|
-
* @param id - uri of the resource to patch
|
|
419
|
-
*
|
|
420
|
-
* @returns id of the edited resource
|
|
421
|
-
*/
|
|
422
|
-
async purge(id) {
|
|
423
|
-
await this.fetchAuthn(id, {
|
|
424
|
-
method: "PURGE",
|
|
425
|
-
headers: this.headers
|
|
426
|
-
}).catch(function (error) {
|
|
427
|
-
console.warn('No purge method allowed: ' + error);
|
|
428
|
-
});
|
|
429
|
-
try {
|
|
430
|
-
const fullURL = new URL(id);
|
|
431
|
-
var pathArray = fullURL.pathname.split('/');
|
|
432
|
-
var containerUrl = fullURL.origin + '/' + pathArray[1] + '/';
|
|
433
|
-
const headers = {
|
|
434
|
-
...this.headers,
|
|
435
|
-
'X-Cache-Purge-Match': 'startswith'
|
|
436
|
-
};
|
|
437
|
-
await this.fetchAuthn(containerUrl, {
|
|
438
|
-
method: "PURGE",
|
|
439
|
-
headers: headers
|
|
440
|
-
}).catch(function (error) {
|
|
441
|
-
console.warn('No purge method allowed: ' + error);
|
|
442
|
-
});
|
|
443
|
-
} catch (error) {
|
|
444
|
-
console.warn('The resource ID is not a complete URL: ' + error);
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* Send a DELETE request to delete a resource
|
|
451
|
-
* @param id - uri of the resource to delete
|
|
452
|
-
* @param context - can be used to expand id
|
|
453
|
-
*
|
|
454
|
-
* @returns id of the deleted resource
|
|
455
|
-
*/
|
|
456
|
-
async delete(id, context = {}) {
|
|
457
|
-
const expandedId = this._getExpandedId(id, context);
|
|
458
|
-
const deleted = await this.fetchAuthn(expandedId, {
|
|
459
|
-
method: 'DELETE',
|
|
460
|
-
headers: this.headers,
|
|
461
|
-
credentials: 'include'
|
|
462
|
-
});
|
|
463
|
-
// await this.purge(id);
|
|
464
|
-
|
|
465
|
-
const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];
|
|
466
|
-
const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];
|
|
467
|
-
this.refreshResources([...resourcesToNotify, ...resourcesToRefresh]).then(resourceIds => this.notifyResources(resourceIds));
|
|
468
|
-
return deleted;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Convert headers object to Headers
|
|
473
|
-
* @param headersObject - object
|
|
474
|
-
* @returns {Headers}
|
|
475
|
-
*/
|
|
476
|
-
_convertHeaders(headersObject) {
|
|
477
|
-
const headers = new Headers();
|
|
478
|
-
for (const [key, value] of Object.entries(headersObject)) {
|
|
479
|
-
headers.set(key, value);
|
|
480
|
-
}
|
|
481
|
-
return headers;
|
|
482
|
-
}
|
|
483
|
-
_getExpandedId(id, context) {
|
|
484
|
-
return context && Object.keys(context) ? ContextParser.expandTerm(id, context) : id;
|
|
485
|
-
}
|
|
486
|
-
getExpandedPredicate(property, context) {
|
|
487
|
-
return ContextParser.expandTerm(property, context, true);
|
|
488
|
-
}
|
|
489
|
-
_isLocalId(id) {
|
|
490
|
-
return id.startsWith('store://local.');
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* Make a resource listen changes of another one
|
|
495
|
-
* @param resourceId - id of the resource which needs to be updated
|
|
496
|
-
* @param nestedResourceId - id of the resource which will change
|
|
497
|
-
*/
|
|
498
|
-
subscribeResourceTo(resourceId, nestedResourceId) {
|
|
499
|
-
const existingSubscriptions = this.subscriptionIndex.get(nestedResourceId) || [];
|
|
500
|
-
this.subscriptionIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, resourceId])]);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Make a virtual container listen for changes of a resource
|
|
505
|
-
* @param virtualContainerId - id of the container which needs to be updated
|
|
506
|
-
* @param nestedResourceId - id of the resource which will change
|
|
507
|
-
*/
|
|
508
|
-
subscribeVirtualContainerTo(virtualContainerId, nestedResourceId) {
|
|
509
|
-
const existingSubscriptions = this.subscriptionVirtualContainersIndex.get(nestedResourceId) || [];
|
|
510
|
-
this.subscriptionVirtualContainersIndex.set(nestedResourceId, [...new Set([...existingSubscriptions, virtualContainerId])]);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* Return absolute IRI of the resource
|
|
515
|
-
* @param id
|
|
516
|
-
* @param context
|
|
517
|
-
* @param parentId
|
|
518
|
-
*/
|
|
519
|
-
_getAbsoluteIri(id, context, parentId) {
|
|
520
|
-
let iri = ContextParser.expandTerm(id, context); // expand if reduced ids
|
|
521
|
-
if (parentId && !parentId.startsWith('store://local')) {
|
|
522
|
-
// and get full URL from parent caller for local files
|
|
523
|
-
let parentIri = new URL(parentId, document.location.href).href;
|
|
524
|
-
iri = new URL(iri, parentIri).href;
|
|
525
|
-
} else {
|
|
526
|
-
iri = new URL(iri, document.location.href).href;
|
|
527
|
-
}
|
|
528
|
-
return iri;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* Return language of the users
|
|
533
|
-
*/
|
|
534
|
-
_getLanguage() {
|
|
535
|
-
return localStorage.getItem('language') || window.navigator.language.slice(0, 2);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Save the preferred language of the user
|
|
540
|
-
* @param selectedLanguageCode
|
|
541
|
-
*/
|
|
542
|
-
selectLanguage(selectedLanguageCode) {
|
|
543
|
-
localStorage.setItem('language', selectedLanguageCode);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
let store;
|
|
547
|
-
if (window.sibStore) {
|
|
548
|
-
store = window.sibStore;
|
|
549
|
-
} else {
|
|
550
|
-
const sibAuth = document.querySelector('sib-auth');
|
|
551
|
-
const storeOptions = {};
|
|
552
|
-
if (sibAuth) {
|
|
553
|
-
const sibAuthDefined = customElements.whenDefined(sibAuth.localName);
|
|
554
|
-
storeOptions.session = sibAuthDefined.then(() => sibAuth.session);
|
|
555
|
-
storeOptions.fetchMethod = sibAuthDefined.then(() => sibAuth.getFetch());
|
|
556
|
-
}
|
|
557
|
-
store = new Store(storeOptions);
|
|
558
|
-
window.sibStore = store;
|
|
559
|
-
}
|
|
560
|
-
export { store };
|
package/dist/locales/en.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"autocompletion.placeholder": "Select a value",
|
|
3
|
-
"autocompletion.searchPlaceholder": "Search",
|
|
4
|
-
"autocompletion.searchText": "No result",
|
|
5
|
-
"solid-delete.button": "Delete",
|
|
6
|
-
"solid-form.submit-button": "Submit",
|
|
7
|
-
"validation.message": "Please, confirm your choice",
|
|
8
|
-
"validation.submit-text": "Yes",
|
|
9
|
-
"validation.cancel-text": "Cancel"
|
|
10
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
let json = {"autocompletion.placeholder":"Select a value","autocompletion.searchPlaceholder":"Search","autocompletion.searchText":"No result","solid-delete.button":"Delete","solid-form.submit-button":"Submit","validation.message":"Please, confirm your choice","validation.submit-text":"Yes","validation.cancel-text":"Cancel"};
|
|
2
|
-
export default json;
|
package/dist/locales/fr.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"autocompletion.placeholder": "Sélectionner une valeur",
|
|
3
|
-
"autocompletion.searchPlaceholder": "Rechercher",
|
|
4
|
-
"autocompletion.searchText": "Aucun résultat",
|
|
5
|
-
"solid-delete.button": "Supprimer",
|
|
6
|
-
"solid-form.submit-button": "Envoyer",
|
|
7
|
-
"validation.message": "Merci de confirmer votre choix",
|
|
8
|
-
"validation.submit-text": "Oui",
|
|
9
|
-
"validation.cancel-text": "Annuler"
|
|
10
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
let json = {"autocompletion.placeholder":"Sélectionner une valeur","autocompletion.searchPlaceholder":"Rechercher","autocompletion.searchText":"Aucun résultat","solid-delete.button":"Supprimer","solid-form.submit-button":"Envoyer","validation.message":"Merci de confirmer votre choix","validation.submit-text":"Oui","validation.cancel-text":"Annuler"};
|
|
2
|
-
export default json;
|