@startinblox/core 2.0.2-beta.1 → 2.0.2
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/{fr-BZZDTsmw.js → fr-ClQZ5-J-.js} +2 -2
- package/dist/{helpers-dFpcGbvl.js → helpers-4GFJ8HI8.js} +5 -5
- package/dist/helpers.js +4 -4
- package/dist/index.js +92601 -96139
- package/dist/store-CJ6fs7JU.js +9905 -0
- package/dist/store.js +2 -14
- package/package.json +2 -3
- package/dist/custom-getter-D66QA0eN.js +0 -274
- package/dist/store-BUP_Lw_8.js +0 -9002
- /package/dist/{en-BySYJZMr.js → en-D7xQ8_VL.js} +0 -0
- /package/dist/{quill.snow-C_A_QkE8.js → quill.snow-BMrontFB.js} +0 -0
- /package/dist/{slimselect-NFLzJMfV.js → slimselect-CT2Oyr_0.js} +0 -0
package/dist/store.js
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { b, e, a, s } from "./store-BUP_Lw_8.js";
|
|
3
|
-
Promise.all([
|
|
4
|
-
(() => {
|
|
5
|
-
try {
|
|
6
|
-
return __tla_0;
|
|
7
|
-
} catch {
|
|
8
|
-
}
|
|
9
|
-
})()
|
|
10
|
-
]).then(async () => {
|
|
11
|
-
});
|
|
1
|
+
import { b, s } from "./store-CJ6fs7JU.js";
|
|
12
2
|
export {
|
|
13
3
|
b as baseContext,
|
|
14
|
-
|
|
15
|
-
a as getStoreAsync,
|
|
16
|
-
s as sibStore
|
|
4
|
+
s as store
|
|
17
5
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startinblox/core",
|
|
3
|
-
"version": "2.0.2
|
|
3
|
+
"version": "2.0.2",
|
|
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",
|
|
@@ -92,8 +92,7 @@
|
|
|
92
92
|
"semver": "7.7.1",
|
|
93
93
|
"slim-select": "^2.10.0",
|
|
94
94
|
"typescript": "^5.8.2",
|
|
95
|
-
"vite": "^6.2.1"
|
|
96
|
-
"vite-plugin-top-level-await": "^1.5.0"
|
|
95
|
+
"vite": "^6.2.1"
|
|
97
96
|
},
|
|
98
97
|
"dependencies": {
|
|
99
98
|
"cors": "^2.8.5",
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { q as mergeContexts, n as normalizeContext, o as getRawContext } from "./helpers-dFpcGbvl.js";
|
|
5
|
-
import { e as getStore, __tla as __tla_0 } from "./store-BUP_Lw_8.js";
|
|
6
|
-
let CustomGetter;
|
|
7
|
-
let __tla = Promise.all([
|
|
8
|
-
(() => {
|
|
9
|
-
try {
|
|
10
|
-
return __tla_0;
|
|
11
|
-
} catch {
|
|
12
|
-
}
|
|
13
|
-
})()
|
|
14
|
-
]).then(async () => {
|
|
15
|
-
const store = getStore();
|
|
16
|
-
CustomGetter = class {
|
|
17
|
-
constructor(resourceId, resource, clientContext, serverContext, parentId = "", serverPagination = {}, serverSearch = {}) {
|
|
18
|
-
__publicField(this, "resource");
|
|
19
|
-
__publicField(this, "resourceId");
|
|
20
|
-
__publicField(this, "clientContext");
|
|
21
|
-
__publicField(this, "serverContext");
|
|
22
|
-
__publicField(this, "parentId");
|
|
23
|
-
__publicField(this, "listTypes");
|
|
24
|
-
__publicField(this, "serverPagination");
|
|
25
|
-
__publicField(this, "serverSearch");
|
|
26
|
-
this.clientContext = clientContext;
|
|
27
|
-
this.serverContext = serverContext;
|
|
28
|
-
this.parentId = parentId;
|
|
29
|
-
this.resource = resource;
|
|
30
|
-
this.resourceId = resourceId;
|
|
31
|
-
this.serverPagination = serverPagination;
|
|
32
|
-
this.serverSearch = serverSearch;
|
|
33
|
-
this.listTypes = [
|
|
34
|
-
this.getExpandedPredicate("ldp:Container"),
|
|
35
|
-
this.getExpandedPredicate("dcat:Catalog"),
|
|
36
|
-
this.getExpandedPredicate("ldp:BasicContainer"),
|
|
37
|
-
this.getExpandedPredicate("ldp:DirectContainer"),
|
|
38
|
-
this.getExpandedPredicate("ldp:IndirectContainer"),
|
|
39
|
-
this.getExpandedPredicate("sib:federatedContainer")
|
|
40
|
-
].filter(Boolean);
|
|
41
|
-
}
|
|
42
|
-
async get(path) {
|
|
43
|
-
if (!path) return;
|
|
44
|
-
try {
|
|
45
|
-
const isUrl = new URL(path);
|
|
46
|
-
if (!isUrl.protocol.startsWith("http")) throw new Error("Not a valid HTTP url");
|
|
47
|
-
if (isUrl) {
|
|
48
|
-
let resources = await this.getList(path);
|
|
49
|
-
if (!resources || Array.isArray(resources) && resources.length === 0) return void 0;
|
|
50
|
-
if (!Array.isArray(resources)) resources = [
|
|
51
|
-
resources
|
|
52
|
-
];
|
|
53
|
-
const result = resources ? Promise.all(resources.map(async (res) => {
|
|
54
|
-
let resource = await store.get(res["@id"]);
|
|
55
|
-
if (resource) return resource;
|
|
56
|
-
resource = new CustomGetter(res["@id"], {
|
|
57
|
-
"@id": res["@id"]
|
|
58
|
-
}, this.clientContext, this.serverContext, this.parentId).getProxy();
|
|
59
|
-
await store.cacheResource(res["@id"], resource);
|
|
60
|
-
return resource;
|
|
61
|
-
})) : [];
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
} catch {
|
|
65
|
-
if (!path.split) return void 0;
|
|
66
|
-
const path1 = path.split(".");
|
|
67
|
-
const path2 = [];
|
|
68
|
-
let value;
|
|
69
|
-
if (!this.isFullResource()) {
|
|
70
|
-
await this.getResource(this.resourceId, {
|
|
71
|
-
...this.clientContext,
|
|
72
|
-
...this.serverContext
|
|
73
|
-
}, this.parentId);
|
|
74
|
-
}
|
|
75
|
-
while (true) {
|
|
76
|
-
value = await this.getList(path1[0]);
|
|
77
|
-
if (path1.length <= 1) break;
|
|
78
|
-
const lastPath1El = path1.pop();
|
|
79
|
-
if (lastPath1El) path2.unshift(lastPath1El);
|
|
80
|
-
}
|
|
81
|
-
if (path2.length === 0) {
|
|
82
|
-
if (!value || !value["@id"]) return this.getLiteralValue(value);
|
|
83
|
-
return await this.getResource(value["@id"], mergeContexts(this.clientContext, this.serverContext), this.parentId || this.resourceId);
|
|
84
|
-
}
|
|
85
|
-
if (!value || !value["@id"]) return void 0;
|
|
86
|
-
const resource = await this.getResource(value["@id"], mergeContexts(this.clientContext, this.serverContext), this.parentId || this.resourceId);
|
|
87
|
-
store.subscribeResourceTo(this.resourceId, value["@id"]);
|
|
88
|
-
return resource ? await resource[path2.join(".")] : void 0;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
static getEmptyResource(id, clientContext, parentContext) {
|
|
92
|
-
return new CustomGetter(id, {
|
|
93
|
-
"@id": id
|
|
94
|
-
}, clientContext, parentContext).getProxy();
|
|
95
|
-
}
|
|
96
|
-
getLiteralValue(value) {
|
|
97
|
-
if (typeof value !== "object" || value === null) return value;
|
|
98
|
-
if (value["@value"]) return value["@value"];
|
|
99
|
-
if (!Array.isArray(value)) return value;
|
|
100
|
-
if (value.length === 0) return null;
|
|
101
|
-
if (!Array.isArray(value[0])) return value;
|
|
102
|
-
const ln = store._getLanguage();
|
|
103
|
-
let translatedValue = value.find((v) => v["@language"] && v["@language"] === ln);
|
|
104
|
-
if (!translatedValue) translatedValue = value.find((v) => v["@language"] && v["@language"] === "en");
|
|
105
|
-
return (translatedValue == null ? void 0 : translatedValue["@value"]) ?? null;
|
|
106
|
-
}
|
|
107
|
-
async getResource(id, context, iriParent, forceFetch = false) {
|
|
108
|
-
if (id.startsWith("_:b")) return await store.get(id + iriParent);
|
|
109
|
-
return await store.getData(id, context, iriParent, void 0, forceFetch);
|
|
110
|
-
}
|
|
111
|
-
isContainer() {
|
|
112
|
-
if (this.resource["@type"]) {
|
|
113
|
-
if (Array.isArray(this.resource["@type"])) return this.listTypes.some((type) => this.resource["@type"].includes(type));
|
|
114
|
-
return this.listTypes.includes(this.resource["@type"]);
|
|
115
|
-
}
|
|
116
|
-
if (!this.resource.type) return false;
|
|
117
|
-
if (Array.isArray(this.resource.type)) return this.listTypes.some((type) => this.resource.type.includes(type));
|
|
118
|
-
return this.listTypes.includes(this.resource.type);
|
|
119
|
-
}
|
|
120
|
-
isArray() {
|
|
121
|
-
if (Array.isArray(this.resource)) return true;
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
getProperties() {
|
|
125
|
-
return Object.keys(this.resource).map((prop) => this.getCompactedPredicate(prop));
|
|
126
|
-
}
|
|
127
|
-
async getList(predicateName) {
|
|
128
|
-
let value = await this.resource[predicateName];
|
|
129
|
-
if (!value) {
|
|
130
|
-
const index = this.getExpandedPredicate(predicateName);
|
|
131
|
-
if (index) {
|
|
132
|
-
value = await this.resource[index];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (value === void 0 || value === null) {
|
|
136
|
-
return [];
|
|
137
|
-
}
|
|
138
|
-
return value;
|
|
139
|
-
}
|
|
140
|
-
async getListAndCacheIt(predicate) {
|
|
141
|
-
let children = await this.getList(predicate);
|
|
142
|
-
if (!children) return null;
|
|
143
|
-
if (!Array.isArray(children)) children = [
|
|
144
|
-
children
|
|
145
|
-
];
|
|
146
|
-
const result = children ? await Promise.all(children.map(async (res) => {
|
|
147
|
-
let resource = await store.get(res["@id"]);
|
|
148
|
-
if (resource) return resource;
|
|
149
|
-
resource = new CustomGetter(res["@id"], {
|
|
150
|
-
"@id": res["@id"]
|
|
151
|
-
}, this.clientContext, this.serverContext, this.parentId).getProxy();
|
|
152
|
-
await store.cacheResource(res["@id"], resource);
|
|
153
|
-
return resource;
|
|
154
|
-
})) : [];
|
|
155
|
-
return result;
|
|
156
|
-
}
|
|
157
|
-
async getDcatDataset() {
|
|
158
|
-
return await this.getListAndCacheIt("dcat:dataset");
|
|
159
|
-
}
|
|
160
|
-
async getLdpContains() {
|
|
161
|
-
return await this.getListAndCacheIt("ldp:contains");
|
|
162
|
-
}
|
|
163
|
-
merge(resource) {
|
|
164
|
-
this.resource = {
|
|
165
|
-
...this.getResourceData(),
|
|
166
|
-
...resource.getResourceData()
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
getResourceData() {
|
|
170
|
-
return this.resource;
|
|
171
|
-
}
|
|
172
|
-
async getContainerList() {
|
|
173
|
-
if (this.hasType("ldp:Container")) {
|
|
174
|
-
return await this.getLdpContains();
|
|
175
|
-
}
|
|
176
|
-
if (this.getType() === "dcat:Catalog") {
|
|
177
|
-
return await this.getDcatDataset();
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
isFullResource() {
|
|
182
|
-
const propertiesKeys = Object.keys(this.resource).filter((p) => !p.startsWith("@"));
|
|
183
|
-
if (this.resource["@id"].startsWith("_:b")) return true;
|
|
184
|
-
if (propertiesKeys.length === 1 && propertiesKeys[0] === this.getExpandedPredicate("permissions")) return false;
|
|
185
|
-
if (propertiesKeys.length > 0) return true;
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
async getPermissions() {
|
|
189
|
-
const perms = this.getExpandedPredicate("permissions");
|
|
190
|
-
if (!perms) return [];
|
|
191
|
-
let permissions = this.resource[perms];
|
|
192
|
-
if (!permissions) {
|
|
193
|
-
await this.getResource(this.resourceId, {
|
|
194
|
-
...this.clientContext,
|
|
195
|
-
...this.serverContext
|
|
196
|
-
}, this.parentId, true);
|
|
197
|
-
permissions = this.resource[perms];
|
|
198
|
-
}
|
|
199
|
-
if (!Array.isArray(permissions)) permissions = [
|
|
200
|
-
permissions
|
|
201
|
-
];
|
|
202
|
-
return permissions ? permissions : [];
|
|
203
|
-
}
|
|
204
|
-
getType() {
|
|
205
|
-
if (Array.isArray(this.resource["@type"])) {
|
|
206
|
-
return this.resource["@type"].map((type) => this.getCompactedIri(type));
|
|
207
|
-
}
|
|
208
|
-
return this.resource["@type"] ? this.getCompactedIri(this.resource["@type"]) : "";
|
|
209
|
-
}
|
|
210
|
-
hasType(type) {
|
|
211
|
-
const types = this.getType();
|
|
212
|
-
if (!types) return false;
|
|
213
|
-
if (Array.isArray(types)) {
|
|
214
|
-
return types.includes(this.getCompactedIri(type));
|
|
215
|
-
}
|
|
216
|
-
return types === this.getCompactedIri(type);
|
|
217
|
-
}
|
|
218
|
-
async clearCache() {
|
|
219
|
-
await store.clearCache(this.resourceId);
|
|
220
|
-
}
|
|
221
|
-
getExpandedPredicate(property) {
|
|
222
|
-
const context = normalizeContext(mergeContexts(this.clientContext, this.serverContext));
|
|
223
|
-
return context.expandTerm(property, true);
|
|
224
|
-
}
|
|
225
|
-
getCompactedPredicate(property) {
|
|
226
|
-
const context = normalizeContext(mergeContexts(this.clientContext, this.serverContext));
|
|
227
|
-
return context.compactIri(property, true);
|
|
228
|
-
}
|
|
229
|
-
getCompactedIri(id) {
|
|
230
|
-
const context = normalizeContext(mergeContexts(this.clientContext, this.serverContext));
|
|
231
|
-
return context.compactIri(id);
|
|
232
|
-
}
|
|
233
|
-
toString() {
|
|
234
|
-
return this.getCompactedIri(this.resource["@id"]);
|
|
235
|
-
}
|
|
236
|
-
[Symbol.toPrimitive]() {
|
|
237
|
-
return this.getCompactedIri(this.resource["@id"]);
|
|
238
|
-
}
|
|
239
|
-
getProxy() {
|
|
240
|
-
return new Proxy(this, {
|
|
241
|
-
get: (resource, property) => {
|
|
242
|
-
if (!this.resource) return void 0;
|
|
243
|
-
if (typeof resource[property] === "function") return resource[property].bind(resource);
|
|
244
|
-
switch (property) {
|
|
245
|
-
case "@id":
|
|
246
|
-
if (this.resource["@id"]) return this.getCompactedIri(this.resource["@id"]);
|
|
247
|
-
return;
|
|
248
|
-
case "@type":
|
|
249
|
-
return this.resource["@type"];
|
|
250
|
-
case "properties":
|
|
251
|
-
return this.getProperties();
|
|
252
|
-
case "ldp:contains":
|
|
253
|
-
case "listPredicate":
|
|
254
|
-
return this.getContainerList();
|
|
255
|
-
case "permissions":
|
|
256
|
-
return this.getPermissions();
|
|
257
|
-
case "clientContext":
|
|
258
|
-
return getRawContext(this.clientContext);
|
|
259
|
-
case "serverContext":
|
|
260
|
-
return getRawContext(this.serverContext);
|
|
261
|
-
case "then":
|
|
262
|
-
return;
|
|
263
|
-
default:
|
|
264
|
-
return resource.get(property);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
});
|
|
271
|
-
export {
|
|
272
|
-
CustomGetter,
|
|
273
|
-
__tla
|
|
274
|
-
};
|