@startinblox/core 0.19.0-beta.1 → 0.19.0-beta.3
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 +54523 -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 -344
- 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 -358
- 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 -116
- 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,344 +0,0 @@
|
|
|
1
|
-
let _Symbol$toPrimitive;
|
|
2
|
-
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; }
|
|
3
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
4
|
-
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); }
|
|
5
|
-
import JSONLDContextParser from '../../_snowpack/pkg/jsonld-context-parser.js';
|
|
6
|
-
import { store } from './store.js';
|
|
7
|
-
const ContextParser = JSONLDContextParser.ContextParser;
|
|
8
|
-
_Symbol$toPrimitive = Symbol.toPrimitive;
|
|
9
|
-
export class CustomGetter {
|
|
10
|
-
// search attributes to give to server
|
|
11
|
-
|
|
12
|
-
constructor(resourceId, resource, clientContext, serverContext, parentId = "", serverPagination = {}, serverSearch = {}) {
|
|
13
|
-
_defineProperty(this, "resource", void 0);
|
|
14
|
-
// content of the requested resource
|
|
15
|
-
_defineProperty(this, "resourceId", void 0);
|
|
16
|
-
_defineProperty(this, "clientContext", void 0);
|
|
17
|
-
// context given by the app
|
|
18
|
-
_defineProperty(this, "serverContext", void 0);
|
|
19
|
-
// context given by the server
|
|
20
|
-
_defineProperty(this, "parentId", void 0);
|
|
21
|
-
// id of the parent resource, used to get the absolute url of the current resource
|
|
22
|
-
_defineProperty(this, "containerTypes", void 0);
|
|
23
|
-
// types of resources interpreted as containers
|
|
24
|
-
_defineProperty(this, "serverPagination", void 0);
|
|
25
|
-
// pagination attributes to give to server
|
|
26
|
-
_defineProperty(this, "serverSearch", void 0);
|
|
27
|
-
this.clientContext = clientContext;
|
|
28
|
-
this.serverContext = serverContext;
|
|
29
|
-
this.parentId = parentId;
|
|
30
|
-
this.resource = resource;
|
|
31
|
-
// this.resource = this.expandProperties({ ...resource }, serverContext);
|
|
32
|
-
this.resourceId = resourceId;
|
|
33
|
-
this.serverPagination = serverPagination;
|
|
34
|
-
this.serverSearch = serverSearch;
|
|
35
|
-
this.containerTypes = [this.getExpandedPredicate("ldp:Container"), this.getExpandedPredicate("ldp:BasicContainer"), this.getExpandedPredicate("ldp:DirectContainer"), this.getExpandedPredicate("ldp:IndirectContainer"), "sib:federatedContainer"];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// /**
|
|
39
|
-
// * Expand all predicates of a resource with a given context
|
|
40
|
-
// * @param resource: object
|
|
41
|
-
// * @param context: object
|
|
42
|
-
// */
|
|
43
|
-
// expandProperties(resource: object, context: object | string) {
|
|
44
|
-
// for (let prop of Object.keys(resource)) {
|
|
45
|
-
// if (!prop) continue;
|
|
46
|
-
// this.objectReplaceProperty(resource, prop, ContextParser.expandTerm(prop, context as JSONLDContextParser.IJsonLdContextNormalized, true));
|
|
47
|
-
// }
|
|
48
|
-
// return resource
|
|
49
|
-
// }
|
|
50
|
-
|
|
51
|
-
// /**
|
|
52
|
-
// * Change the key of an object
|
|
53
|
-
// * @param object: object
|
|
54
|
-
// * @param oldProp: string - current key
|
|
55
|
-
// * @param newProp: string - new key to set
|
|
56
|
-
// */
|
|
57
|
-
// objectReplaceProperty(object: object, oldProp: string, newProp: string) {
|
|
58
|
-
// if (newProp !== oldProp) {
|
|
59
|
-
// Object.defineProperty(
|
|
60
|
-
// object,
|
|
61
|
-
// newProp,
|
|
62
|
-
// Object.getOwnPropertyDescriptor(object, oldProp) || ''
|
|
63
|
-
// );
|
|
64
|
-
// delete object[oldProp];
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Get the property of a resource for a given path
|
|
70
|
-
* Which means that if the resource is not complete, it will fetch it
|
|
71
|
-
* And that we handle the `.` notation, traversing the path recursively
|
|
72
|
-
* @param path: string
|
|
73
|
-
*/
|
|
74
|
-
async get(path) {
|
|
75
|
-
if (!path) return;
|
|
76
|
-
|
|
77
|
-
// Specific case where the predicates is a full IRI, avoid splitting it on the dot notation
|
|
78
|
-
try {
|
|
79
|
-
let isUrl = new URL(path);
|
|
80
|
-
// If the path is an absolute url, we need to fetch the resource
|
|
81
|
-
if (isUrl) {
|
|
82
|
-
let value = this.resource[this.getExpandedPredicate(path)];
|
|
83
|
-
return value ? value : undefined;
|
|
84
|
-
}
|
|
85
|
-
} catch (e) {
|
|
86
|
-
// Split the path on each dots
|
|
87
|
-
const path1 = path.split('.');
|
|
88
|
-
|
|
89
|
-
// Intermediate path var to request each resource individually until the path traversal is completed
|
|
90
|
-
const path2 = [];
|
|
91
|
-
|
|
92
|
-
// Actual value found from the store, if any
|
|
93
|
-
let value;
|
|
94
|
-
if (!this.isFullResource()) {
|
|
95
|
-
// if resource is not complete, fetch it first
|
|
96
|
-
await this.getResource(this.resourceId, {
|
|
97
|
-
...this.clientContext,
|
|
98
|
-
...this.serverContext
|
|
99
|
-
}, this.parentId);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// If the path contains dot, we need to traverse the path recursively
|
|
103
|
-
// We do that by poping one element from path1 at each step and affecting it to path2
|
|
104
|
-
// Trying to get the value from it
|
|
105
|
-
while (true) {
|
|
106
|
-
try {
|
|
107
|
-
value = this.resource[this.getExpandedPredicate(path1[0])];
|
|
108
|
-
} catch (e) {
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
if (path1.length <= 1) break; // no dot path
|
|
112
|
-
const lastPath1El = path1.pop();
|
|
113
|
-
if (lastPath1El) path2.unshift(lastPath1El);
|
|
114
|
-
}
|
|
115
|
-
if (path2.length === 0) {
|
|
116
|
-
// end of the path
|
|
117
|
-
if (!value || !value['@id']) return this.getLiteralValue(value); // no value or not a resource
|
|
118
|
-
return await this.getResource(value['@id'], {
|
|
119
|
-
...this.clientContext,
|
|
120
|
-
...this.serverContext
|
|
121
|
-
}, this.parentId || this.resourceId); // return complete resource
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (!value) return undefined;
|
|
125
|
-
let resource = await this.getResource(value['@id'], {
|
|
126
|
-
...this.clientContext,
|
|
127
|
-
...this.serverContext
|
|
128
|
-
}, this.parentId || this.resourceId);
|
|
129
|
-
store.subscribeResourceTo(this.resourceId, value['@id']);
|
|
130
|
-
return resource ? await resource[path2.join('.')] : undefined; // return value
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Return value depending of the current language
|
|
136
|
-
* @param value
|
|
137
|
-
* @returns
|
|
138
|
-
*/
|
|
139
|
-
getLiteralValue(value) {
|
|
140
|
-
if (typeof value === "object") {
|
|
141
|
-
// value object: https://www.w3.org/TR/json-ld11/#value-objects
|
|
142
|
-
if (value['@value']) {
|
|
143
|
-
// 1 language
|
|
144
|
-
return value['@value'];
|
|
145
|
-
} else if (Array.isArray(value)) {
|
|
146
|
-
// multiple languages
|
|
147
|
-
if (value.length === 0) return null;
|
|
148
|
-
const ln = store._getLanguage();
|
|
149
|
-
let translatedValue = value.find(v => v['@language'] && v['@language'] === ln); // find current language
|
|
150
|
-
if (!translatedValue) translatedValue = value.find(v => v['@language'] && v['@language'] === 'en'); // default to en
|
|
151
|
-
return translatedValue ? translatedValue['@value'] || null : null;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return value; // simple value
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Cache resource in the store, and return the created proxy
|
|
159
|
-
* @param id
|
|
160
|
-
* @param context
|
|
161
|
-
* @param iriParent
|
|
162
|
-
*/
|
|
163
|
-
async getResource(id, context, iriParent, forceFetch = false) {
|
|
164
|
-
if (id.startsWith('_:b')) return store.get(id + iriParent); // anonymous node = get from cache
|
|
165
|
-
return store.getData(id, context, iriParent, undefined, forceFetch);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Return true if the resource is a container
|
|
170
|
-
*/
|
|
171
|
-
isContainer() {
|
|
172
|
-
if (this.resource["@type"]) {
|
|
173
|
-
// @type is an array
|
|
174
|
-
if (Array.isArray(this.resource["@type"])) return this.containerTypes.some(type => this.resource["@type"].includes(type));
|
|
175
|
-
return this.containerTypes.includes(this.resource["@type"]);
|
|
176
|
-
} else if (this.resource["type"]) {
|
|
177
|
-
if (Array.isArray(this.resource["type"])) return this.containerTypes.some(type => this.resource["type"].includes(type));
|
|
178
|
-
return this.containerTypes.includes(this.resource["type"]);
|
|
179
|
-
}
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Return true if the given key in the current resource in an array
|
|
185
|
-
*/
|
|
186
|
-
isArray() {
|
|
187
|
-
if (Array.isArray(this.resource)) return true;
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Get all properties of a resource
|
|
193
|
-
*/
|
|
194
|
-
getProperties() {
|
|
195
|
-
return Object.keys(this.resource).map(prop => this.getCompactedPredicate(prop));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Get children of container as objects
|
|
200
|
-
*/
|
|
201
|
-
getChildren(predicateName) {
|
|
202
|
-
return this.resource[this.getExpandedPredicate(predicateName)] || [];
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Get children of container as Proxys
|
|
207
|
-
*/
|
|
208
|
-
getLdpContains() {
|
|
209
|
-
let children = this.resource[this.getExpandedPredicate("ldp:contains")];
|
|
210
|
-
if (!children) return null;
|
|
211
|
-
if (!Array.isArray(children)) children = [children]; // convert to array if compacted to 1 resource
|
|
212
|
-
|
|
213
|
-
let result = children ? children.map(res => {
|
|
214
|
-
let resource = store.get(res['@id']);
|
|
215
|
-
if (resource) return resource;
|
|
216
|
-
|
|
217
|
-
// if not in cache, generate the basic resource
|
|
218
|
-
resource = new CustomGetter(res['@id'], {
|
|
219
|
-
'@id': res['@id']
|
|
220
|
-
}, this.clientContext, this.serverContext, this.parentId).getProxy();
|
|
221
|
-
store.cacheResource(res['@id'], resource); // put it in cache
|
|
222
|
-
return resource; // and return it
|
|
223
|
-
}) : [];
|
|
224
|
-
return result;
|
|
225
|
-
}
|
|
226
|
-
merge(resource) {
|
|
227
|
-
this.resource = {
|
|
228
|
-
...this.getResourceData(),
|
|
229
|
-
...resource.getResourceData()
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
getResourceData() {
|
|
233
|
-
return this.resource;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* return true resource seems complete
|
|
238
|
-
* @param prop
|
|
239
|
-
*/
|
|
240
|
-
isFullResource() {
|
|
241
|
-
return Object.keys(this.resource).filter(p => !p.startsWith('@')).length > 0 // has some properties
|
|
242
|
-
|| this.resource['@id'].startsWith('_:b'); // anonymous node = always full resource
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Get permissions of a resource
|
|
247
|
-
* @param resourceId
|
|
248
|
-
* @returns
|
|
249
|
-
*/
|
|
250
|
-
async getPermissions() {
|
|
251
|
-
let permissionsIds = this.resource[this.getExpandedPredicate("permissions")];
|
|
252
|
-
if (!permissionsIds) {
|
|
253
|
-
// if no permission, re-fetch data from store
|
|
254
|
-
await this.getResource(this.resourceId, {
|
|
255
|
-
...this.clientContext,
|
|
256
|
-
...this.serverContext
|
|
257
|
-
}, this.parentId, true);
|
|
258
|
-
permissionsIds = this.resource[this.getExpandedPredicate("permissions")];
|
|
259
|
-
}
|
|
260
|
-
if (!permissionsIds) return [];
|
|
261
|
-
if (!Array.isArray(permissionsIds)) permissionsIds = [permissionsIds]; // convert to array if compacted to 1 resource
|
|
262
|
-
const permissions = await Promise.all(permissionsIds.map(p => store.get(p['@id'] + this.parentId)) // get anonymous node from store
|
|
263
|
-
.map(p => p ? p['mode.@type'] : ''));
|
|
264
|
-
return permissions ? permissions.map(perm => ContextParser.expandTerm(perm, this.serverContext, true)) : [];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* returns compacted @type of resource
|
|
269
|
-
*/
|
|
270
|
-
getType() {
|
|
271
|
-
return this.resource['@type'] ? this.getCompactedIri(this.resource['@type']) : '';
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Remove the resource from the cache
|
|
276
|
-
*/
|
|
277
|
-
clearCache() {
|
|
278
|
-
store.clearCache(this.resourceId);
|
|
279
|
-
}
|
|
280
|
-
getExpandedPredicate(property) {
|
|
281
|
-
return ContextParser.expandTerm(property, {
|
|
282
|
-
...this.clientContext,
|
|
283
|
-
...this.serverContext
|
|
284
|
-
}, true);
|
|
285
|
-
}
|
|
286
|
-
getCompactedPredicate(property) {
|
|
287
|
-
return ContextParser.compactIri(property, {
|
|
288
|
-
...this.clientContext,
|
|
289
|
-
...this.serverContext
|
|
290
|
-
}, true);
|
|
291
|
-
}
|
|
292
|
-
getCompactedIri(id) {
|
|
293
|
-
return ContextParser.compactIri(id, {
|
|
294
|
-
...this.clientContext,
|
|
295
|
-
...this.serverContext
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
toString() {
|
|
299
|
-
return this.getCompactedIri(this.resource['@id']);
|
|
300
|
-
}
|
|
301
|
-
[_Symbol$toPrimitive]() {
|
|
302
|
-
return this.getCompactedIri(this.resource['@id']);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Returns a Proxy which handles the different get requests
|
|
307
|
-
*/
|
|
308
|
-
getProxy() {
|
|
309
|
-
return new Proxy(this, {
|
|
310
|
-
get: (resource, property) => {
|
|
311
|
-
if (!this.resource) return undefined;
|
|
312
|
-
if (typeof resource[property] === 'function') return resource[property].bind(resource);
|
|
313
|
-
switch (property) {
|
|
314
|
-
case '@id':
|
|
315
|
-
if (this.resource['@id']) return this.getCompactedIri(this.resource['@id']); // Compact @id if possible
|
|
316
|
-
else console.log(this.resource, this.resource['@id']);
|
|
317
|
-
return;
|
|
318
|
-
case '@type':
|
|
319
|
-
return this.resource['@type'];
|
|
320
|
-
// return synchronously
|
|
321
|
-
case 'properties':
|
|
322
|
-
return this.getProperties();
|
|
323
|
-
case 'ldp:contains':
|
|
324
|
-
return this.getLdpContains();
|
|
325
|
-
// returns standard arrays synchronously
|
|
326
|
-
case 'permissions':
|
|
327
|
-
return this.getPermissions();
|
|
328
|
-
// get expanded permissions
|
|
329
|
-
case 'clientContext':
|
|
330
|
-
return this.clientContext;
|
|
331
|
-
// get saved client context to re-fetch easily a resource
|
|
332
|
-
case 'serverContext':
|
|
333
|
-
return this.serverContext;
|
|
334
|
-
// get saved client context to re-fetch easily a resource
|
|
335
|
-
case 'then':
|
|
336
|
-
return;
|
|
337
|
-
default:
|
|
338
|
-
// FIXME: missing 'await'
|
|
339
|
-
return resource.get(property);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export function formatAttributesToServerPaginationOptions(elementAttributes) {
|
|
2
|
-
const attributes = new Map(Array.from(elementAttributes).map(({
|
|
3
|
-
name,
|
|
4
|
-
value
|
|
5
|
-
}) => [name, value]));
|
|
6
|
-
const limit = attributes.get('limit');
|
|
7
|
-
const offset = attributes.get('offset');
|
|
8
|
-
if (!offset || !limit) return;
|
|
9
|
-
return {
|
|
10
|
-
limit: limit,
|
|
11
|
-
offset: offset
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export function appendServerPaginationToIri(iri, options) {
|
|
15
|
-
const first = iri.includes('?') ? '&' : '?';
|
|
16
|
-
const limit = options.limit;
|
|
17
|
-
const offset = options.offset;
|
|
18
|
-
return `${iri}${first}limit=${limit}&offset=${offset}`;
|
|
19
|
-
}
|
|
@@ -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
|
-
}
|