@startinblox/core 2.0.6-beta.1 → 2.0.6-beta.11
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/{custom-getter-cITbP3Tj.js → custom-getter-BUGtV5pI.js} +2 -2
- package/dist/{helpers-vZrb1UDN.js → helpers-DtCY-jxq.js} +33 -33
- package/dist/helpers.js +1 -1
- package/dist/index.js +23867 -15380
- package/dist/{store-_JtvdYph.js → store-BPx-Ghbc.js} +1628 -363
- package/dist/store.js +2 -1
- package/package.json +2 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { l as isUrlOrRelativePath, m as jsonldContextParserExports, o as getRawContext, n as normalizeContext, q as mergeContexts, c as doesResourceContainList, r as requireJsonldContextParser, v as requireErrorCoded, w as requireLink } from "./helpers-
|
|
5
|
-
let StoreService, formatAttributesToServerSearchOptions, base_context, StoreType, StoreFactory, hasQueryIndex, formatAttributesToServerPaginationOptions, getDefaultExportFromCjs, hasSetLocalData, sibStore, mergeServerSearchOptions, semantizer;
|
|
4
|
+
import { l as isUrlOrRelativePath, m as jsonldContextParserExports, o as getRawContext, n as normalizeContext, q as mergeContexts, c as doesResourceContainList, r as requireJsonldContextParser, v as requireErrorCoded, w as requireLink } from "./helpers-DtCY-jxq.js";
|
|
5
|
+
let AuthFetchResolver, DEFAULT_AUTH_SELECTORS, StoreService, formatAttributesToServerSearchOptions, base_context, StoreType, StoreFactory, hasQueryIndex, formatAttributesToServerPaginationOptions, getDefaultExportFromCjs, hasSetLocalData, sibStore, mergeServerSearchOptions, semantizer;
|
|
6
6
|
let __tla = (async () => {
|
|
7
7
|
var _a;
|
|
8
8
|
getDefaultExportFromCjs = function(x) {
|
|
9
9
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
10
10
|
};
|
|
11
11
|
function getAugmentedNamespace(n) {
|
|
12
|
-
if (n
|
|
12
|
+
if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
|
|
13
13
|
var f = n.default;
|
|
14
14
|
if (typeof f == "function") {
|
|
15
15
|
var a = function a2() {
|
|
@@ -162,7 +162,21 @@ let __tla = (async () => {
|
|
|
162
162
|
return false;
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
class
|
|
165
|
+
class AssetValidationError extends Error {
|
|
166
|
+
constructor(message, assetId, validationType, reason, details) {
|
|
167
|
+
super(message);
|
|
168
|
+
__publicField(this, "assetId");
|
|
169
|
+
__publicField(this, "validationType");
|
|
170
|
+
__publicField(this, "reason");
|
|
171
|
+
__publicField(this, "details");
|
|
172
|
+
this.name = "AssetValidationError";
|
|
173
|
+
this.assetId = assetId;
|
|
174
|
+
this.validationType = validationType;
|
|
175
|
+
this.reason = reason;
|
|
176
|
+
this.details = details;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const _DataspaceConnectorStore = class _DataspaceConnectorStore {
|
|
166
180
|
constructor(config) {
|
|
167
181
|
__publicField(this, "cache");
|
|
168
182
|
__publicField(this, "session");
|
|
@@ -184,6 +198,12 @@ let __tla = (async () => {
|
|
|
184
198
|
Accept: "application/json"
|
|
185
199
|
};
|
|
186
200
|
}
|
|
201
|
+
_makeAssetAgreementKey(assetId, providerParticipantId) {
|
|
202
|
+
if (providerParticipantId) {
|
|
203
|
+
return `${assetId}:${providerParticipantId}`;
|
|
204
|
+
}
|
|
205
|
+
return assetId;
|
|
206
|
+
}
|
|
187
207
|
validateConfig(config) {
|
|
188
208
|
const required = [
|
|
189
209
|
"catalogEndpoint",
|
|
@@ -254,6 +274,21 @@ let __tla = (async () => {
|
|
|
254
274
|
}
|
|
255
275
|
async negotiateContract(counterPartyAddress, _offerId, policy, counterPartyId) {
|
|
256
276
|
await this.ensureAuthenticated();
|
|
277
|
+
console.log("[DataspaceConnectorStore] Received policy for negotiation:", policy);
|
|
278
|
+
console.log("[DataspaceConnectorStore] Policy keys:", Object.keys(policy));
|
|
279
|
+
const cleanPolicy = {};
|
|
280
|
+
for (const key in policy) {
|
|
281
|
+
if (!/^\d+$/.test(key)) {
|
|
282
|
+
cleanPolicy[key] = policy[key];
|
|
283
|
+
} else {
|
|
284
|
+
console.warn(`[DataspaceConnectorStore] Removing numeric key "${key}" from policy`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
console.log("[DataspaceConnectorStore] Cleaned policy keys:", Object.keys(cleanPolicy));
|
|
288
|
+
const targetAssetId = _offerId || cleanPolicy.target || cleanPolicy["odrl:target"] || policy.target || policy["odrl:target"];
|
|
289
|
+
if (!targetAssetId) {
|
|
290
|
+
console.warn("[DataspaceConnectorStore] No target asset ID found for negotiation");
|
|
291
|
+
}
|
|
257
292
|
const negotiationRequest = {
|
|
258
293
|
"@context": {
|
|
259
294
|
"@vocab": "https://w3id.org/edc/v0.0.1/ns/"
|
|
@@ -264,12 +299,15 @@ let __tla = (async () => {
|
|
|
264
299
|
protocol: "dataspace-protocol-http",
|
|
265
300
|
policy: {
|
|
266
301
|
"@context": "http://www.w3.org/ns/odrl.jsonld",
|
|
267
|
-
|
|
268
|
-
"@type": "Offer",
|
|
269
|
-
assigner: counterPartyId || "provider",
|
|
270
|
-
target:
|
|
302
|
+
...cleanPolicy,
|
|
303
|
+
"@type": "odrl:Offer",
|
|
304
|
+
assigner: cleanPolicy.assigner || policy.assigner || counterPartyId || "provider",
|
|
305
|
+
target: targetAssetId,
|
|
306
|
+
"odrl:target": targetAssetId
|
|
271
307
|
}
|
|
272
308
|
};
|
|
309
|
+
console.log("[DataspaceConnectorStore] Contract negotiation request:", JSON.stringify(negotiationRequest, null, 2));
|
|
310
|
+
console.log("[DataspaceConnectorStore] \u{1F50D} POSTing negotiation to consumer connector:", this.config.contractNegotiationEndpoint);
|
|
273
311
|
const response = await this.fetchAuthn(this.config.contractNegotiationEndpoint, {
|
|
274
312
|
method: "POST",
|
|
275
313
|
headers: this.headers,
|
|
@@ -291,7 +329,7 @@ let __tla = (async () => {
|
|
|
291
329
|
getNegotiationStatus(negotiationId) {
|
|
292
330
|
return this._getNegotiationStatus(negotiationId);
|
|
293
331
|
}
|
|
294
|
-
async getContractAgreement(negotiationId) {
|
|
332
|
+
async getContractAgreement(negotiationId, providerParticipantId) {
|
|
295
333
|
await this.ensureAuthenticated();
|
|
296
334
|
try {
|
|
297
335
|
const response = await this.fetchAuthn(`${this.config.contractNegotiationEndpoint}/${negotiationId}/agreement`, {
|
|
@@ -306,9 +344,11 @@ let __tla = (async () => {
|
|
|
306
344
|
this.contractAgreements.set(agreement["@id"], agreement);
|
|
307
345
|
const assetId = agreement.assetId;
|
|
308
346
|
if (assetId) {
|
|
309
|
-
const
|
|
347
|
+
const key = this._makeAssetAgreementKey(assetId, providerParticipantId);
|
|
348
|
+
const existing = this.assetAgreements.get(key);
|
|
310
349
|
const mapping = {
|
|
311
350
|
assetId,
|
|
351
|
+
providerParticipantId,
|
|
312
352
|
catalogId: existing == null ? void 0 : existing.catalogId,
|
|
313
353
|
agreementId: agreement["@id"],
|
|
314
354
|
agreement,
|
|
@@ -318,7 +358,7 @@ let __tla = (async () => {
|
|
|
318
358
|
createdAt: (existing == null ? void 0 : existing.createdAt) || Date.now(),
|
|
319
359
|
lastUpdated: Date.now()
|
|
320
360
|
};
|
|
321
|
-
this.assetAgreements.set(
|
|
361
|
+
this.assetAgreements.set(key, mapping);
|
|
322
362
|
}
|
|
323
363
|
return agreement;
|
|
324
364
|
} catch (error2) {
|
|
@@ -326,8 +366,9 @@ let __tla = (async () => {
|
|
|
326
366
|
return null;
|
|
327
367
|
}
|
|
328
368
|
}
|
|
329
|
-
getStoredContractAgreement(assetId) {
|
|
330
|
-
const
|
|
369
|
+
getStoredContractAgreement(assetId, providerParticipantId) {
|
|
370
|
+
const key = this._makeAssetAgreementKey(assetId, providerParticipantId);
|
|
371
|
+
const mapping = this.assetAgreements.get(key);
|
|
331
372
|
return (mapping == null ? void 0 : mapping.agreement) || null;
|
|
332
373
|
}
|
|
333
374
|
async getAllContractNegotiations() {
|
|
@@ -388,11 +429,12 @@ let __tla = (async () => {
|
|
|
388
429
|
getAllAssetAgreements() {
|
|
389
430
|
return Array.from(this.assetAgreements.values());
|
|
390
431
|
}
|
|
391
|
-
getAssetAgreement(assetId) {
|
|
392
|
-
|
|
432
|
+
getAssetAgreement(assetId, providerParticipantId) {
|
|
433
|
+
const key = this._makeAssetAgreementKey(assetId, providerParticipantId);
|
|
434
|
+
return this.assetAgreements.get(key) || null;
|
|
393
435
|
}
|
|
394
|
-
hasValidAgreement(assetId) {
|
|
395
|
-
const agreement = this.getAssetAgreement(assetId);
|
|
436
|
+
hasValidAgreement(assetId, providerParticipantId) {
|
|
437
|
+
const agreement = this.getAssetAgreement(assetId, providerParticipantId);
|
|
396
438
|
return agreement !== null;
|
|
397
439
|
}
|
|
398
440
|
async initiateTransfer(counterPartyAddress, contractId, dataDestination) {
|
|
@@ -420,7 +462,7 @@ let __tla = (async () => {
|
|
|
420
462
|
this.transferProcesses.set(transferId, transfer);
|
|
421
463
|
return transferId;
|
|
422
464
|
}
|
|
423
|
-
async initiateEDRTransfer(assetId, counterPartyAddress, contractId) {
|
|
465
|
+
async initiateEDRTransfer(assetId, counterPartyAddress, contractId, providerParticipantId) {
|
|
424
466
|
await this.ensureAuthenticated();
|
|
425
467
|
const edrRequest = {
|
|
426
468
|
"@context": {
|
|
@@ -447,11 +489,12 @@ let __tla = (async () => {
|
|
|
447
489
|
}
|
|
448
490
|
const edrResponse = await response.json();
|
|
449
491
|
const transferId = edrResponse["@id"];
|
|
450
|
-
const
|
|
492
|
+
const key = this._makeAssetAgreementKey(assetId, providerParticipantId);
|
|
493
|
+
const mapping = this.assetAgreements.get(key);
|
|
451
494
|
if (mapping) {
|
|
452
495
|
mapping.transferId = transferId;
|
|
453
496
|
mapping.lastUpdated = Date.now();
|
|
454
|
-
this.assetAgreements.set(
|
|
497
|
+
this.assetAgreements.set(key, mapping);
|
|
455
498
|
}
|
|
456
499
|
return transferId;
|
|
457
500
|
}
|
|
@@ -529,7 +572,8 @@ let __tla = (async () => {
|
|
|
529
572
|
}
|
|
530
573
|
async accessAssetData(assetId, counterPartyAddress, policy, counterPartyId, additionalPath) {
|
|
531
574
|
try {
|
|
532
|
-
const
|
|
575
|
+
const key = this._makeAssetAgreementKey(assetId, counterPartyId);
|
|
576
|
+
const existingMapping = this.assetAgreements.get(key);
|
|
533
577
|
if ((existingMapping == null ? void 0 : existingMapping.edrToken) && existingMapping.transferId) {
|
|
534
578
|
const edrDataAddress = this.edrTokens.get(existingMapping.transferId);
|
|
535
579
|
if (edrDataAddress) {
|
|
@@ -546,13 +590,13 @@ let __tla = (async () => {
|
|
|
546
590
|
throw error2;
|
|
547
591
|
}
|
|
548
592
|
}
|
|
549
|
-
async continueAssetAccess(negotiationId, assetId, counterPartyAddress, additionalPath) {
|
|
593
|
+
async continueAssetAccess(negotiationId, assetId, counterPartyAddress, additionalPath, providerParticipantId) {
|
|
550
594
|
try {
|
|
551
|
-
const agreement = await this.getContractAgreement(negotiationId);
|
|
595
|
+
const agreement = await this.getContractAgreement(negotiationId, providerParticipantId);
|
|
552
596
|
if (!agreement) {
|
|
553
597
|
throw new Error("Failed to retrieve contract agreement");
|
|
554
598
|
}
|
|
555
|
-
const transferId = await this.initiateEDRTransfer(assetId, counterPartyAddress, agreement["@id"]);
|
|
599
|
+
const transferId = await this.initiateEDRTransfer(assetId, counterPartyAddress, agreement["@id"], providerParticipantId);
|
|
556
600
|
const edrDataAddress = await this.getEDRToken(transferId);
|
|
557
601
|
if (!edrDataAddress) {
|
|
558
602
|
throw new Error("Failed to retrieve EDR token");
|
|
@@ -564,8 +608,9 @@ let __tla = (async () => {
|
|
|
564
608
|
throw error2;
|
|
565
609
|
}
|
|
566
610
|
}
|
|
567
|
-
async accessStoredAssetData(assetId, additionalPath) {
|
|
568
|
-
const
|
|
611
|
+
async accessStoredAssetData(assetId, additionalPath, providerParticipantId) {
|
|
612
|
+
const key = this._makeAssetAgreementKey(assetId, providerParticipantId);
|
|
613
|
+
const mapping = this.assetAgreements.get(key);
|
|
569
614
|
if (!(mapping == null ? void 0 : mapping.transferId)) {
|
|
570
615
|
throw new Error(`No stored transfer information for asset: ${assetId}`);
|
|
571
616
|
}
|
|
@@ -575,6 +620,107 @@ let __tla = (async () => {
|
|
|
575
620
|
}
|
|
576
621
|
return await this.fetchWithEDRToken(edrDataAddress, additionalPath);
|
|
577
622
|
}
|
|
623
|
+
async fetchProtectedResource(resourceUrl, consumerParticipantId, consumerConnectorUrl, providerConnectorUrl, existingAgreementId, maxNegotiationRetries = 30, negotiationRetryDelay = 2e3) {
|
|
624
|
+
console.log(`\u{1F510} Requesting protected resource: ${resourceUrl}`);
|
|
625
|
+
if (existingAgreementId) {
|
|
626
|
+
console.log(`\u{1F4DC} Using existing agreement: ${existingAgreementId}`);
|
|
627
|
+
return await this._fetchWithAgreement(resourceUrl, consumerParticipantId, consumerConnectorUrl, existingAgreementId);
|
|
628
|
+
}
|
|
629
|
+
const initialResponse = await fetch(resourceUrl, {
|
|
630
|
+
method: "GET",
|
|
631
|
+
headers: {
|
|
632
|
+
"DSP-PARTICIPANT-ID": consumerParticipantId,
|
|
633
|
+
"DSP-CONSUMER-CONNECTORURL": consumerConnectorUrl,
|
|
634
|
+
Accept: "application/ld+json"
|
|
635
|
+
},
|
|
636
|
+
mode: "cors"
|
|
637
|
+
});
|
|
638
|
+
if (initialResponse.ok) {
|
|
639
|
+
const data2 = await initialResponse.json();
|
|
640
|
+
console.log("\u2705 Resource accessed successfully (no agreement required)");
|
|
641
|
+
return data2;
|
|
642
|
+
}
|
|
643
|
+
if (initialResponse.status !== 449) {
|
|
644
|
+
const errorText = await initialResponse.text();
|
|
645
|
+
throw new Error(`Unexpected response: ${initialResponse.status} ${initialResponse.statusText} - ${errorText}`);
|
|
646
|
+
}
|
|
647
|
+
const contractInfo = await this._handlePolicyDiscovery(initialResponse, providerConnectorUrl, maxNegotiationRetries, negotiationRetryDelay);
|
|
648
|
+
console.log("\u{1F504} Retrying resource request with agreement...");
|
|
649
|
+
const data = await this._fetchWithAgreement(resourceUrl, consumerParticipantId, consumerConnectorUrl, contractInfo.agreementId);
|
|
650
|
+
if (data && typeof data === "object") {
|
|
651
|
+
data[_DataspaceConnectorStore.AUTO_NEGOTIATED_CONTRACT_KEY] = {
|
|
652
|
+
agreementId: contractInfo.agreementId,
|
|
653
|
+
negotiationId: contractInfo.negotiationId,
|
|
654
|
+
assetId: contractInfo.assetId,
|
|
655
|
+
providerId: contractInfo.providerId,
|
|
656
|
+
providerConnectorUrl,
|
|
657
|
+
policy: contractInfo.policy,
|
|
658
|
+
resourceUrl
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
return data;
|
|
662
|
+
}
|
|
663
|
+
async _handlePolicyDiscovery(initialResponse, providerConnectorUrl, maxNegotiationRetries, negotiationRetryDelay) {
|
|
664
|
+
console.log("\u{1F4CB} Contract negotiation required (449 response)");
|
|
665
|
+
const errorResponse = await initialResponse.json();
|
|
666
|
+
const suggestedPolicies = errorResponse.suggested_policies;
|
|
667
|
+
if (!suggestedPolicies || suggestedPolicies.length === 0) {
|
|
668
|
+
throw new Error("No suggested policies returned in 449 response");
|
|
669
|
+
}
|
|
670
|
+
const bestPolicy = suggestedPolicies.reduce((best, current) => {
|
|
671
|
+
return current.openness_score > best.openness_score ? current : best;
|
|
672
|
+
});
|
|
673
|
+
console.log(`\u{1F4DC} Selected policy: ${bestPolicy.policy_id} (openness: ${bestPolicy.openness_score})`);
|
|
674
|
+
const providerId = errorResponse.provider_id || errorResponse.participant_id;
|
|
675
|
+
const assetId = errorResponse.asset_id;
|
|
676
|
+
console.log(`\u{1F3E2} Provider ID for negotiation: ${providerId}`);
|
|
677
|
+
console.log("\u{1F91D} Initiating contract negotiation...");
|
|
678
|
+
const negotiationId = await this.negotiateContract(providerConnectorUrl, assetId, bestPolicy.policy, providerId);
|
|
679
|
+
console.log(`\u{1F4DD} Negotiation initiated: ${negotiationId}`);
|
|
680
|
+
for (let attempt = 1; attempt <= maxNegotiationRetries; attempt++) {
|
|
681
|
+
await new Promise((resolve) => setTimeout(resolve, negotiationRetryDelay));
|
|
682
|
+
const status = await this._getNegotiationStatus(negotiationId);
|
|
683
|
+
console.log(`\u23F3 Negotiation status (${attempt}/${maxNegotiationRetries}): ${status.state}`);
|
|
684
|
+
if (status.state === "FINALIZED") {
|
|
685
|
+
const agreement = await this.getContractAgreement(negotiationId, providerId);
|
|
686
|
+
if (!agreement) {
|
|
687
|
+
throw new Error(`Failed to retrieve contract agreement for negotiation ${negotiationId}`);
|
|
688
|
+
}
|
|
689
|
+
console.log(`\u2705 Agreement obtained: ${agreement["@id"]}`);
|
|
690
|
+
return {
|
|
691
|
+
agreementId: agreement["@id"],
|
|
692
|
+
negotiationId,
|
|
693
|
+
assetId,
|
|
694
|
+
providerId,
|
|
695
|
+
policy: bestPolicy.policy
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
if (status.state === "TERMINATED") {
|
|
699
|
+
throw new Error(`Negotiation terminated: ${status.errorDetail || "Unknown reason"}`);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
throw new Error(`Negotiation ${negotiationId} failed or timed out after ${maxNegotiationRetries} attempts`);
|
|
703
|
+
}
|
|
704
|
+
async _fetchWithAgreement(resourceUrl, consumerParticipantId, providerConnectorUrl, agreementId) {
|
|
705
|
+
console.log(`\u{1F510} Requesting protected resource: ${resourceUrl} (with agreement)`);
|
|
706
|
+
const response = await fetch(resourceUrl, {
|
|
707
|
+
method: "GET",
|
|
708
|
+
headers: {
|
|
709
|
+
"DSP-PARTICIPANT-ID": consumerParticipantId,
|
|
710
|
+
"DSP-CONSUMER-CONNECTORURL": providerConnectorUrl,
|
|
711
|
+
"DSP-AGREEMENT-ID": agreementId,
|
|
712
|
+
Accept: "application/ld+json"
|
|
713
|
+
},
|
|
714
|
+
mode: "cors"
|
|
715
|
+
});
|
|
716
|
+
if (!response.ok) {
|
|
717
|
+
const errorText = await response.text();
|
|
718
|
+
throw new Error(`Failed to access protected resource: ${response.status} ${response.statusText} - ${errorText}`);
|
|
719
|
+
}
|
|
720
|
+
const data = await response.json();
|
|
721
|
+
console.log("\u2705 Resource accessed successfully");
|
|
722
|
+
return data;
|
|
723
|
+
}
|
|
578
724
|
async fetchThroughDataspace(resourceId) {
|
|
579
725
|
try {
|
|
580
726
|
const catalog = await this.getCatalog();
|
|
@@ -608,17 +754,28 @@ let __tla = (async () => {
|
|
|
608
754
|
return response.json();
|
|
609
755
|
}
|
|
610
756
|
async ensureAuthenticated() {
|
|
611
|
-
|
|
757
|
+
var _a2;
|
|
758
|
+
console.log("\u{1F510} [DSP Store] ensureAuthenticated called:", {
|
|
759
|
+
hasAuthToken: !!this.authToken,
|
|
760
|
+
authMethod: this.config.authMethod,
|
|
761
|
+
hasDspApiKey: !!this.config.dspApiKey,
|
|
762
|
+
currentHeaders: Object.keys(this.headers || {})
|
|
763
|
+
});
|
|
764
|
+
if (this.authToken && ((_a2 = this.headers) == null ? void 0 : _a2["X-Api-Key"])) {
|
|
765
|
+
console.log("\u{1F510} [DSP Store] Already authenticated, skipping");
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
612
768
|
switch (this.config.authMethod) {
|
|
613
|
-
case "
|
|
614
|
-
if (!this.config.
|
|
615
|
-
throw new Error("
|
|
769
|
+
case "dsp-api-key":
|
|
770
|
+
if (!this.config.dspApiKey) {
|
|
771
|
+
throw new Error("DSP API key required but not provided. Set dspApiKey in configuration.");
|
|
616
772
|
}
|
|
617
|
-
this.authToken = this.config.
|
|
773
|
+
this.authToken = this.config.dspApiKey;
|
|
618
774
|
this.headers = {
|
|
619
775
|
...this.headers,
|
|
620
776
|
"X-Api-Key": this.authToken
|
|
621
777
|
};
|
|
778
|
+
console.log("\u{1F510} [DSP Store] Set X-Api-Key header");
|
|
622
779
|
break;
|
|
623
780
|
case "bearer":
|
|
624
781
|
if (!this.config.bearerToken) {
|
|
@@ -900,39 +1057,60 @@ let __tla = (async () => {
|
|
|
900
1057
|
}
|
|
901
1058
|
async updateAsset(assetId, assetInput) {
|
|
902
1059
|
await this.ensureAuthenticated();
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
"
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
1060
|
+
const hasAgreement = this.hasValidAgreement(assetId);
|
|
1061
|
+
if (hasAgreement) {
|
|
1062
|
+
const message = `Cannot update asset ${assetId}: Asset has active contract agreements. Deleting an asset with agreements would invalidate existing contracts. Please terminate or complete all negotiations first.`;
|
|
1063
|
+
throw new AssetValidationError(message, assetId, "update", "agreements");
|
|
1064
|
+
}
|
|
1065
|
+
const negotiations = await this.getAllContractNegotiations();
|
|
1066
|
+
const activeNegotiations = negotiations.filter((neg) => neg.state !== "FINALIZED" && neg.state !== "TERMINATED" && neg.assetId === assetId);
|
|
1067
|
+
if (activeNegotiations.length > 0) {
|
|
1068
|
+
const message = `Cannot update asset ${assetId}: Asset has ${activeNegotiations.length} active contract negotiation(s). Please wait for negotiations to complete or terminate them first.`;
|
|
1069
|
+
throw new AssetValidationError(message, assetId, "update", "negotiations", {
|
|
1070
|
+
negotiationCount: activeNegotiations.length,
|
|
1071
|
+
negotiations: activeNegotiations
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
console.log(`\u26A0\uFE0F Using DELETE + POST pattern to update asset ${assetId}`);
|
|
1075
|
+
try {
|
|
1076
|
+
const deleted = await this.deleteAsset(assetId, true);
|
|
1077
|
+
if (!deleted) {
|
|
1078
|
+
throw new Error(`Failed to delete existing asset ${assetId} for update`);
|
|
1079
|
+
}
|
|
1080
|
+
} catch (deleteError) {
|
|
1081
|
+
if (deleteError instanceof AssetValidationError) {
|
|
1082
|
+
throw new AssetValidationError(deleteError.message.replace("Cannot delete", "Cannot update"), assetId, "update", deleteError.reason, deleteError.details);
|
|
1083
|
+
}
|
|
1084
|
+
throw deleteError;
|
|
1085
|
+
}
|
|
1086
|
+
try {
|
|
1087
|
+
const updatedAsset = await this.createAsset(assetInput);
|
|
1088
|
+
console.log(`\u2705 Asset ${assetId} updated successfully via DELETE + POST`);
|
|
1089
|
+
return updatedAsset;
|
|
1090
|
+
} catch (createError) {
|
|
1091
|
+
console.error(`\u274C Critical: Failed to recreate asset ${assetId} after deletion`, createError);
|
|
1092
|
+
const errorMessage = createError instanceof Error ? createError.message : String(createError);
|
|
1093
|
+
throw new Error(`Failed to recreate asset after deletion: ${errorMessage}. Asset ${assetId} has been deleted but not recreated.`);
|
|
923
1094
|
}
|
|
924
|
-
const updatedAsset = {
|
|
925
|
-
"@type": "Asset",
|
|
926
|
-
"@id": assetInput["@id"],
|
|
927
|
-
properties: assetInput.properties,
|
|
928
|
-
dataAddress: assetInput.dataAddress,
|
|
929
|
-
createdAt: Date.now()
|
|
930
|
-
};
|
|
931
|
-
await this.cache.set(assetId, updatedAsset);
|
|
932
|
-
return updatedAsset;
|
|
933
1095
|
}
|
|
934
|
-
async deleteAsset(assetId) {
|
|
1096
|
+
async deleteAsset(assetId, skipAgreementCheck = false) {
|
|
935
1097
|
await this.ensureAuthenticated();
|
|
1098
|
+
if (!skipAgreementCheck) {
|
|
1099
|
+
const hasAgreement = this.hasValidAgreement(assetId);
|
|
1100
|
+
if (hasAgreement) {
|
|
1101
|
+
const message = `Cannot delete asset ${assetId}: Asset has active contract agreements. Deleting an asset with agreements would invalidate existing contracts. Please terminate or complete all negotiations first.`;
|
|
1102
|
+
throw new AssetValidationError(message, assetId, "delete", "agreements");
|
|
1103
|
+
}
|
|
1104
|
+
const negotiations = await this.getAllContractNegotiations();
|
|
1105
|
+
const activeNegotiations = negotiations.filter((neg) => neg.state !== "FINALIZED" && neg.state !== "TERMINATED" && neg.assetId === assetId);
|
|
1106
|
+
if (activeNegotiations.length > 0) {
|
|
1107
|
+
const message = `Cannot delete asset ${assetId}: Asset has ${activeNegotiations.length} active contract negotiation(s). Please wait for negotiations to complete or terminate them first.`;
|
|
1108
|
+
throw new AssetValidationError(message, assetId, "delete", "negotiations", {
|
|
1109
|
+
negotiationCount: activeNegotiations.length,
|
|
1110
|
+
negotiations: activeNegotiations
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
936
1114
|
const apiVersion = this.config.apiVersion || "v3";
|
|
937
1115
|
const assetsEndpoint = this.config.assetsEndpoint || this.config.catalogEndpoint.replace("/catalog/request", apiVersion === "v3" ? "/assets" : "/assets");
|
|
938
1116
|
const response = await this.fetchAuthn(`${assetsEndpoint}/${assetId}`, {
|
|
@@ -941,9 +1119,28 @@ let __tla = (async () => {
|
|
|
941
1119
|
});
|
|
942
1120
|
if (!response.ok) {
|
|
943
1121
|
const errorText = await response.text();
|
|
1122
|
+
if (response.status === 409) {
|
|
1123
|
+
try {
|
|
1124
|
+
const errorDetails = JSON.parse(errorText);
|
|
1125
|
+
const errorMessage = Array.isArray(errorDetails) && errorDetails.length > 0 ? errorDetails[0].message : errorText;
|
|
1126
|
+
const message = `Cannot delete asset ${assetId}: ${errorMessage}`;
|
|
1127
|
+
throw new AssetValidationError(message, assetId, "delete", "agreements", {
|
|
1128
|
+
apiResponse: errorDetails
|
|
1129
|
+
});
|
|
1130
|
+
} catch (parseError) {
|
|
1131
|
+
if (parseError instanceof AssetValidationError) {
|
|
1132
|
+
throw parseError;
|
|
1133
|
+
}
|
|
1134
|
+
const message = `Cannot delete asset ${assetId}: ${errorText}`;
|
|
1135
|
+
throw new AssetValidationError(message, assetId, "delete", "agreements", {
|
|
1136
|
+
rawError: errorText
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
944
1140
|
throw new Error(`Failed to delete asset: ${response.status} ${response.statusText} - ${errorText}`);
|
|
945
1141
|
}
|
|
946
1142
|
await this.cache.delete(assetId);
|
|
1143
|
+
this.assetAgreements.delete(assetId);
|
|
947
1144
|
return true;
|
|
948
1145
|
}
|
|
949
1146
|
async getAllPolicies(querySpec) {
|
|
@@ -1203,29 +1400,352 @@ let __tla = (async () => {
|
|
|
1203
1400
|
getExpandedPredicate(property, _context) {
|
|
1204
1401
|
return property;
|
|
1205
1402
|
}
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1403
|
+
};
|
|
1404
|
+
__publicField(_DataspaceConnectorStore, "AUTO_NEGOTIATED_CONTRACT_KEY", "__autoNegotiatedContract");
|
|
1405
|
+
let DataspaceConnectorStore = _DataspaceConnectorStore;
|
|
1406
|
+
class DataspaceConnectorStoreAdapter {
|
|
1208
1407
|
constructor() {
|
|
1209
1408
|
}
|
|
1210
1409
|
static getStoreInstance(cfg) {
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1410
|
+
var _a2;
|
|
1411
|
+
if (!cfg) {
|
|
1412
|
+
throw new Error("DataspaceConnectorStore configuration is required");
|
|
1413
|
+
}
|
|
1414
|
+
const dspConfig = cfg;
|
|
1415
|
+
console.log("\u{1F3ED} [DataspaceConnectorStoreAdapter.getStoreInstance] Creating new store with config:", {
|
|
1416
|
+
endpoint: dspConfig.endpoint,
|
|
1417
|
+
catalogEndpoint: dspConfig.catalogEndpoint,
|
|
1418
|
+
negotiationEndpoint: dspConfig.contractNegotiationEndpoint
|
|
1419
|
+
});
|
|
1420
|
+
const newStore = new DataspaceConnectorStore(dspConfig);
|
|
1421
|
+
console.log("\u2705 [DataspaceConnectorStoreAdapter.getStoreInstance] Created store:", {
|
|
1422
|
+
storeType: typeof newStore,
|
|
1423
|
+
configEndpoint: (_a2 = newStore.config) == null ? void 0 : _a2.endpoint
|
|
1424
|
+
});
|
|
1425
|
+
return newStore;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
DEFAULT_AUTH_SELECTORS = [
|
|
1429
|
+
"sib-auth-oidc",
|
|
1430
|
+
"sib-auth"
|
|
1431
|
+
];
|
|
1432
|
+
function findAuthElement(selectors = [
|
|
1433
|
+
...DEFAULT_AUTH_SELECTORS
|
|
1434
|
+
]) {
|
|
1435
|
+
for (const selector of selectors) {
|
|
1436
|
+
const element = document.querySelector(selector);
|
|
1437
|
+
if (element && typeof element.getFetch === "function") {
|
|
1438
|
+
return element;
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
return null;
|
|
1442
|
+
}
|
|
1443
|
+
function getAuthFetch(selectors) {
|
|
1444
|
+
const authElement = findAuthElement(selectors);
|
|
1445
|
+
if (authElement) {
|
|
1446
|
+
try {
|
|
1447
|
+
const authFetch = authElement.getFetch();
|
|
1448
|
+
if (typeof authFetch === "function") {
|
|
1449
|
+
return authFetch;
|
|
1214
1450
|
}
|
|
1215
|
-
|
|
1451
|
+
} catch (error2) {
|
|
1452
|
+
console.warn("[AuthFetchResolver] Error getting auth fetch:", error2);
|
|
1216
1453
|
}
|
|
1217
|
-
return _DataspaceConnectorStoreAdapter.store;
|
|
1218
1454
|
}
|
|
1455
|
+
return fetch.bind(globalThis);
|
|
1456
|
+
}
|
|
1457
|
+
function onAuthActivated(callback, eventName = "sib-auth:activated") {
|
|
1458
|
+
const handler2 = (event) => {
|
|
1459
|
+
var _a2;
|
|
1460
|
+
if (((_a2 = event.detail) == null ? void 0 : _a2.fetch) && typeof event.detail.fetch === "function") {
|
|
1461
|
+
callback(event);
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
document.addEventListener(eventName, handler2);
|
|
1465
|
+
return () => {
|
|
1466
|
+
document.removeEventListener(eventName, handler2);
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
async function waitForAuthElement(selectors = [
|
|
1470
|
+
...DEFAULT_AUTH_SELECTORS
|
|
1471
|
+
], timeout = 5e3) {
|
|
1472
|
+
const existing = findAuthElement(selectors);
|
|
1473
|
+
if (existing) {
|
|
1474
|
+
return existing;
|
|
1475
|
+
}
|
|
1476
|
+
return new Promise((resolve, reject) => {
|
|
1477
|
+
const observer = new MutationObserver(() => {
|
|
1478
|
+
const element = findAuthElement(selectors);
|
|
1479
|
+
if (element) {
|
|
1480
|
+
observer.disconnect();
|
|
1481
|
+
resolve(element);
|
|
1482
|
+
}
|
|
1483
|
+
});
|
|
1484
|
+
observer.observe(document.body, {
|
|
1485
|
+
childList: true,
|
|
1486
|
+
subtree: true
|
|
1487
|
+
});
|
|
1488
|
+
setTimeout(() => {
|
|
1489
|
+
observer.disconnect();
|
|
1490
|
+
reject(new Error(`No auth element found with selectors: ${selectors.join(", ")}`));
|
|
1491
|
+
}, timeout);
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
AuthFetchResolver = {
|
|
1495
|
+
findAuthElement,
|
|
1496
|
+
getAuthFetch,
|
|
1497
|
+
onAuthActivated,
|
|
1498
|
+
waitForAuthElement
|
|
1219
1499
|
};
|
|
1220
|
-
|
|
1221
|
-
|
|
1500
|
+
const _LocalStorageCacheMetadataManager = class _LocalStorageCacheMetadataManager {
|
|
1501
|
+
constructor(endpoint, ttlMs = _LocalStorageCacheMetadataManager.DEFAULT_TTL_MS) {
|
|
1502
|
+
this.endpoint = endpoint;
|
|
1503
|
+
this.ttlMs = ttlMs;
|
|
1504
|
+
this.cleanupOldCacheFormat();
|
|
1505
|
+
}
|
|
1506
|
+
cleanupOldCacheFormat() {
|
|
1507
|
+
try {
|
|
1508
|
+
const endpointHash = this.endpoint.replace(/[^a-zA-Z0-9]/g, "");
|
|
1509
|
+
const oldKey = `fc-cache-meta-${endpointHash}`;
|
|
1510
|
+
if (localStorage.getItem(oldKey)) {
|
|
1511
|
+
localStorage.removeItem(oldKey);
|
|
1512
|
+
}
|
|
1513
|
+
} catch (error2) {
|
|
1514
|
+
console.warn("[LocalStorageCache] Error cleaning up old cache format:", error2);
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
getStorageKey() {
|
|
1518
|
+
const endpointHash = this.endpoint.replace(/[^a-zA-Z0-9]/g, "");
|
|
1519
|
+
return `${_LocalStorageCacheMetadataManager.STORAGE_KEY_PREFIX}-${endpointHash}`;
|
|
1520
|
+
}
|
|
1521
|
+
getCacheData() {
|
|
1522
|
+
try {
|
|
1523
|
+
const key = this.getStorageKey();
|
|
1524
|
+
const data = localStorage.getItem(key);
|
|
1525
|
+
if (!data) {
|
|
1526
|
+
return null;
|
|
1527
|
+
}
|
|
1528
|
+
const parsed = JSON.parse(data);
|
|
1529
|
+
const items = /* @__PURE__ */ new Map();
|
|
1530
|
+
if (parsed.items) {
|
|
1531
|
+
for (const [hash, metadata] of Object.entries(parsed.items)) {
|
|
1532
|
+
items.set(hash, metadata);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
return {
|
|
1536
|
+
version: parsed.version,
|
|
1537
|
+
lastFetchTimestamp: parsed.lastFetchTimestamp,
|
|
1538
|
+
cacheExpirationTimestamp: parsed.cacheExpirationTimestamp,
|
|
1539
|
+
resource: parsed.resource,
|
|
1540
|
+
items
|
|
1541
|
+
};
|
|
1542
|
+
} catch (error2) {
|
|
1543
|
+
console.error("[LocalStorageCache] Error reading cache data:", error2);
|
|
1544
|
+
return null;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
getCacheMetadata() {
|
|
1548
|
+
return this.getCacheData();
|
|
1549
|
+
}
|
|
1550
|
+
setCacheData(cacheData) {
|
|
1551
|
+
try {
|
|
1552
|
+
const key = this.getStorageKey();
|
|
1553
|
+
const itemsObj = {};
|
|
1554
|
+
cacheData.items.forEach((value, hash) => {
|
|
1555
|
+
itemsObj[hash] = value;
|
|
1556
|
+
});
|
|
1557
|
+
const data = JSON.stringify({
|
|
1558
|
+
version: cacheData.version,
|
|
1559
|
+
lastFetchTimestamp: cacheData.lastFetchTimestamp,
|
|
1560
|
+
cacheExpirationTimestamp: cacheData.cacheExpirationTimestamp,
|
|
1561
|
+
resource: cacheData.resource,
|
|
1562
|
+
items: itemsObj
|
|
1563
|
+
});
|
|
1564
|
+
localStorage.setItem(key, data);
|
|
1565
|
+
return true;
|
|
1566
|
+
} catch (error2) {
|
|
1567
|
+
console.error("[LocalStorageCache] Error writing cache data:", error2);
|
|
1568
|
+
return false;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
setCacheMetadata(cacheData) {
|
|
1572
|
+
return this.setCacheData(cacheData);
|
|
1573
|
+
}
|
|
1574
|
+
isCacheValid() {
|
|
1575
|
+
const cacheData = this.getCacheData();
|
|
1576
|
+
if (!cacheData) {
|
|
1577
|
+
return false;
|
|
1578
|
+
}
|
|
1579
|
+
if (cacheData.version !== _LocalStorageCacheMetadataManager.CACHE_VERSION) {
|
|
1580
|
+
console.log("[LocalStorageCache] Cache version mismatch, invalidating");
|
|
1581
|
+
return false;
|
|
1582
|
+
}
|
|
1583
|
+
const now = Date.now();
|
|
1584
|
+
if (now > cacheData.cacheExpirationTimestamp) {
|
|
1585
|
+
console.log("[LocalStorageCache] Cache TTL expired");
|
|
1586
|
+
return false;
|
|
1587
|
+
}
|
|
1588
|
+
return true;
|
|
1589
|
+
}
|
|
1590
|
+
getResource() {
|
|
1591
|
+
const cacheData = this.getCacheData();
|
|
1592
|
+
return (cacheData == null ? void 0 : cacheData.resource) || null;
|
|
1593
|
+
}
|
|
1594
|
+
getKnownHashes() {
|
|
1595
|
+
const cacheData = this.getCacheData();
|
|
1596
|
+
if (!cacheData) {
|
|
1597
|
+
return /* @__PURE__ */ new Set();
|
|
1598
|
+
}
|
|
1599
|
+
return new Set(cacheData.items.keys());
|
|
1600
|
+
}
|
|
1601
|
+
getItemMetadata(sdHash) {
|
|
1602
|
+
const cacheData = this.getCacheData();
|
|
1603
|
+
if (!cacheData) {
|
|
1604
|
+
return null;
|
|
1605
|
+
}
|
|
1606
|
+
return cacheData.items.get(sdHash) || null;
|
|
1607
|
+
}
|
|
1608
|
+
updateCache(resource, items) {
|
|
1609
|
+
const now = Date.now();
|
|
1610
|
+
let cacheData = this.getCacheData();
|
|
1611
|
+
if (!cacheData || !this.isCacheValid()) {
|
|
1612
|
+
cacheData = {
|
|
1613
|
+
version: _LocalStorageCacheMetadataManager.CACHE_VERSION,
|
|
1614
|
+
lastFetchTimestamp: now,
|
|
1615
|
+
cacheExpirationTimestamp: now + this.ttlMs,
|
|
1616
|
+
resource,
|
|
1617
|
+
items: /* @__PURE__ */ new Map()
|
|
1618
|
+
};
|
|
1619
|
+
} else {
|
|
1620
|
+
cacheData.resource = resource;
|
|
1621
|
+
}
|
|
1622
|
+
for (const item of items) {
|
|
1623
|
+
cacheData.items.set(item.sdHash, {
|
|
1624
|
+
...item,
|
|
1625
|
+
cachedAt: now
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
cacheData.lastFetchTimestamp = now;
|
|
1629
|
+
return this.setCacheData(cacheData);
|
|
1630
|
+
}
|
|
1631
|
+
removeItems(sdHashes) {
|
|
1632
|
+
var _a2;
|
|
1633
|
+
const cacheData = this.getCacheData();
|
|
1634
|
+
if (!cacheData) {
|
|
1635
|
+
return false;
|
|
1636
|
+
}
|
|
1637
|
+
for (const hash of sdHashes) {
|
|
1638
|
+
cacheData.items.delete(hash);
|
|
1639
|
+
}
|
|
1640
|
+
if ((_a2 = cacheData.resource) == null ? void 0 : _a2["ldp:contains"]) {
|
|
1641
|
+
const resourceIdsToRemove = /* @__PURE__ */ new Set();
|
|
1642
|
+
for (const hash of sdHashes) {
|
|
1643
|
+
const meta = cacheData.items.get(hash);
|
|
1644
|
+
if (meta) {
|
|
1645
|
+
resourceIdsToRemove.add(meta.resourceId);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
cacheData.resource["ldp:contains"] = cacheData.resource["ldp:contains"].filter((item) => !resourceIdsToRemove.has(item["@id"]));
|
|
1649
|
+
}
|
|
1650
|
+
return this.setCacheData(cacheData);
|
|
1651
|
+
}
|
|
1652
|
+
clear() {
|
|
1653
|
+
try {
|
|
1654
|
+
const key = this.getStorageKey();
|
|
1655
|
+
localStorage.removeItem(key);
|
|
1656
|
+
return true;
|
|
1657
|
+
} catch (error2) {
|
|
1658
|
+
console.error("[LocalStorageCache] Error clearing cache data:", error2);
|
|
1659
|
+
return false;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
getCacheStats() {
|
|
1663
|
+
const cacheData = this.getCacheData();
|
|
1664
|
+
if (!cacheData) {
|
|
1665
|
+
return {
|
|
1666
|
+
itemCount: 0,
|
|
1667
|
+
lastFetch: null,
|
|
1668
|
+
expiresAt: null,
|
|
1669
|
+
isValid: false
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
return {
|
|
1673
|
+
itemCount: cacheData.items.size,
|
|
1674
|
+
lastFetch: new Date(cacheData.lastFetchTimestamp),
|
|
1675
|
+
expiresAt: new Date(cacheData.cacheExpirationTimestamp),
|
|
1676
|
+
isValid: this.isCacheValid()
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
__publicField(_LocalStorageCacheMetadataManager, "STORAGE_KEY_PREFIX", "fc-cache-data");
|
|
1681
|
+
__publicField(_LocalStorageCacheMetadataManager, "CACHE_VERSION", "2.0.0");
|
|
1682
|
+
__publicField(_LocalStorageCacheMetadataManager, "DEFAULT_TTL_MS", 2 * 60 * 60 * 1e3);
|
|
1683
|
+
let LocalStorageCacheMetadataManager = _LocalStorageCacheMetadataManager;
|
|
1222
1684
|
class FederatedCatalogueAPIWrapper {
|
|
1223
|
-
constructor(options, fcBaseUrl) {
|
|
1685
|
+
constructor(options, fcBaseUrl, fetchAuth) {
|
|
1224
1686
|
__publicField(this, "fcBaseUrl");
|
|
1225
|
-
__publicField(this, "
|
|
1687
|
+
__publicField(this, "loginOptions");
|
|
1688
|
+
__publicField(this, "tokenState", null);
|
|
1689
|
+
__publicField(this, "tokenRefreshBuffer", 5 * 60 * 1e3);
|
|
1690
|
+
__publicField(this, "isRefreshing", false);
|
|
1691
|
+
__publicField(this, "refreshPromise", null);
|
|
1692
|
+
__publicField(this, "STORAGE_KEY", "fc_token_state");
|
|
1693
|
+
__publicField(this, "_fetch");
|
|
1694
|
+
__publicField(this, "useKeycloakAuth");
|
|
1226
1695
|
this.fcBaseUrl = fcBaseUrl;
|
|
1227
|
-
|
|
1228
|
-
|
|
1696
|
+
this.loginOptions = options;
|
|
1697
|
+
if (fetchAuth && (!options.kc_url || options.kc_url === "")) {
|
|
1698
|
+
this._fetch = fetchAuth;
|
|
1699
|
+
this.useKeycloakAuth = false;
|
|
1700
|
+
} else {
|
|
1701
|
+
this._fetch = fetch.bind(globalThis);
|
|
1702
|
+
this.useKeycloakAuth = true;
|
|
1703
|
+
this.loadTokenState();
|
|
1704
|
+
}
|
|
1705
|
+
if (this.useKeycloakAuth) {
|
|
1706
|
+
try {
|
|
1707
|
+
this.firstConnect(options);
|
|
1708
|
+
} catch (e) {
|
|
1709
|
+
console.log("Error while establishing the first connection", e);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
saveTokenState() {
|
|
1714
|
+
if (this.tokenState) {
|
|
1715
|
+
try {
|
|
1716
|
+
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(this.tokenState));
|
|
1717
|
+
console.log("\u{1F4BE} [FederatedCatalogueAPIWrapper] Token state saved to localStorage");
|
|
1718
|
+
} catch (error2) {
|
|
1719
|
+
console.error("Failed to save token state to localStorage:", error2);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
loadTokenState() {
|
|
1724
|
+
var _a2, _b, _c;
|
|
1725
|
+
try {
|
|
1726
|
+
const stored = localStorage.getItem(this.STORAGE_KEY);
|
|
1727
|
+
if (stored) {
|
|
1728
|
+
this.tokenState = JSON.parse(stored);
|
|
1729
|
+
console.log("\u{1F4C2} [FederatedCatalogueAPIWrapper] Token state loaded from localStorage:", {
|
|
1730
|
+
hasAccessToken: !!((_a2 = this.tokenState) == null ? void 0 : _a2.access_token),
|
|
1731
|
+
hasRefreshToken: !!((_b = this.tokenState) == null ? void 0 : _b.refresh_token),
|
|
1732
|
+
expiresAt: (_c = this.tokenState) == null ? void 0 : _c.expires_at,
|
|
1733
|
+
isExpired: this.tokenState ? Date.now() >= this.tokenState.expires_at : "N/A"
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
} catch (error2) {
|
|
1737
|
+
console.error("Failed to load token state from localStorage:", error2);
|
|
1738
|
+
this.clearTokenState();
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
clearTokenState() {
|
|
1742
|
+
this.tokenState = null;
|
|
1743
|
+
try {
|
|
1744
|
+
localStorage.removeItem(this.STORAGE_KEY);
|
|
1745
|
+
console.log("\u{1F5D1}\uFE0F [FederatedCatalogueAPIWrapper] Token state cleared");
|
|
1746
|
+
} catch (error2) {
|
|
1747
|
+
console.error("Failed to clear token state from localStorage:", error2);
|
|
1748
|
+
}
|
|
1229
1749
|
}
|
|
1230
1750
|
async firstConnect(options) {
|
|
1231
1751
|
const body = new URLSearchParams({
|
|
@@ -1239,7 +1759,7 @@ let __tla = (async () => {
|
|
|
1239
1759
|
const headers = new Headers({
|
|
1240
1760
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
1241
1761
|
});
|
|
1242
|
-
const response = await
|
|
1762
|
+
const response = await this._fetch(options.kc_url, {
|
|
1243
1763
|
method: "POST",
|
|
1244
1764
|
headers,
|
|
1245
1765
|
body
|
|
@@ -1251,28 +1771,130 @@ let __tla = (async () => {
|
|
|
1251
1771
|
cause: data
|
|
1252
1772
|
});
|
|
1253
1773
|
}
|
|
1774
|
+
this.tokenState = {
|
|
1775
|
+
access_token: token,
|
|
1776
|
+
refresh_token: data.refresh_token || null,
|
|
1777
|
+
expires_at: Date.now() + (data.expires_in || 3600) * 1e3
|
|
1778
|
+
};
|
|
1779
|
+
this.saveTokenState();
|
|
1254
1780
|
return token;
|
|
1255
1781
|
}
|
|
1256
|
-
async
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1782
|
+
async refreshToken() {
|
|
1783
|
+
if (this.isRefreshing && this.refreshPromise) {
|
|
1784
|
+
return this.refreshPromise;
|
|
1785
|
+
}
|
|
1786
|
+
this.isRefreshing = true;
|
|
1787
|
+
this.refreshPromise = this._performRefresh();
|
|
1788
|
+
try {
|
|
1789
|
+
const token = await this.refreshPromise;
|
|
1790
|
+
return token;
|
|
1791
|
+
} finally {
|
|
1792
|
+
this.isRefreshing = false;
|
|
1793
|
+
this.refreshPromise = null;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
async _performRefresh() {
|
|
1797
|
+
var _a2;
|
|
1798
|
+
if (!((_a2 = this.tokenState) == null ? void 0 : _a2.refresh_token)) {
|
|
1799
|
+
console.log("No refresh token available, re-authenticating with credentials");
|
|
1800
|
+
return this.firstConnect(this.loginOptions);
|
|
1801
|
+
}
|
|
1802
|
+
try {
|
|
1803
|
+
const body = new URLSearchParams({
|
|
1804
|
+
grant_type: "refresh_token",
|
|
1805
|
+
client_id: this.loginOptions.kc_client_id,
|
|
1806
|
+
client_secret: this.loginOptions.kc_client_secret,
|
|
1807
|
+
refresh_token: this.tokenState.refresh_token
|
|
1808
|
+
});
|
|
1809
|
+
const headers = new Headers({
|
|
1810
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1811
|
+
});
|
|
1812
|
+
const response = await this._fetch(this.loginOptions.kc_url, {
|
|
1813
|
+
method: "POST",
|
|
1814
|
+
headers,
|
|
1815
|
+
body
|
|
1816
|
+
});
|
|
1817
|
+
if (!response.ok) {
|
|
1818
|
+
console.warn("Token refresh failed, re-authenticating with credentials");
|
|
1819
|
+
return this.firstConnect(this.loginOptions);
|
|
1820
|
+
}
|
|
1821
|
+
const data = await response.json();
|
|
1822
|
+
const token = data.access_token;
|
|
1823
|
+
if (token == null) {
|
|
1824
|
+
throw new Error("Token refresh failed: no access_token in response", {
|
|
1825
|
+
cause: data
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
this.tokenState = {
|
|
1829
|
+
access_token: token,
|
|
1830
|
+
refresh_token: data.refresh_token || this.tokenState.refresh_token,
|
|
1831
|
+
expires_at: Date.now() + (data.expires_in || 3600) * 1e3
|
|
1832
|
+
};
|
|
1833
|
+
this.saveTokenState();
|
|
1834
|
+
return token;
|
|
1835
|
+
} catch (error2) {
|
|
1836
|
+
console.error("Error refreshing token:", error2);
|
|
1837
|
+
this.clearTokenState();
|
|
1838
|
+
return this.firstConnect(this.loginOptions);
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
async getValidToken() {
|
|
1842
|
+
if (!this.tokenState) {
|
|
1843
|
+
return await this.firstConnect(this.loginOptions);
|
|
1844
|
+
}
|
|
1845
|
+
const now = Date.now();
|
|
1846
|
+
const isExpiringSoon = now >= this.tokenState.expires_at - this.tokenRefreshBuffer;
|
|
1847
|
+
if (isExpiringSoon) {
|
|
1848
|
+
return await this.refreshToken();
|
|
1849
|
+
}
|
|
1850
|
+
return this.tokenState.access_token;
|
|
1851
|
+
}
|
|
1852
|
+
async fetchWithAuth(url2, options = {}) {
|
|
1853
|
+
var _a2;
|
|
1854
|
+
if (!this.useKeycloakAuth) {
|
|
1855
|
+
return this._fetch(url2, options);
|
|
1856
|
+
}
|
|
1857
|
+
const token = await this.getValidToken();
|
|
1858
|
+
const headers = new Headers(options.headers);
|
|
1859
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
1860
|
+
let response = await this._fetch(url2, {
|
|
1861
|
+
...options,
|
|
1263
1862
|
headers
|
|
1264
1863
|
});
|
|
1864
|
+
if (response.status === 401 || response.status === 403) {
|
|
1865
|
+
console.log(`\u{1F510} [FederatedCatalogueAPIWrapper] Authentication failed (${response.status}) for ${url2}`);
|
|
1866
|
+
console.log("\u{1F504} [FederatedCatalogueAPIWrapper] Attempting token refresh...", {
|
|
1867
|
+
hasRefreshToken: !!((_a2 = this.tokenState) == null ? void 0 : _a2.refresh_token),
|
|
1868
|
+
tokenExpired: this.tokenState ? Date.now() >= this.tokenState.expires_at : "N/A"
|
|
1869
|
+
});
|
|
1870
|
+
try {
|
|
1871
|
+
const newToken = await this.refreshToken();
|
|
1872
|
+
console.log("\u2705 [FederatedCatalogueAPIWrapper] Token refreshed successfully, retrying request...");
|
|
1873
|
+
headers.set("Authorization", `Bearer ${newToken}`);
|
|
1874
|
+
response = await this._fetch(url2, {
|
|
1875
|
+
...options,
|
|
1876
|
+
headers
|
|
1877
|
+
});
|
|
1878
|
+
if (response.status === 401 || response.status === 403) {
|
|
1879
|
+
console.error(`\u274C [FederatedCatalogueAPIWrapper] Authentication still failed after token refresh (${response.status}). Please check credentials.`);
|
|
1880
|
+
} else {
|
|
1881
|
+
console.log(`\u2705 [FederatedCatalogueAPIWrapper] Retry succeeded with status ${response.status}`);
|
|
1882
|
+
}
|
|
1883
|
+
} catch (error2) {
|
|
1884
|
+
console.error("\u274C [FederatedCatalogueAPIWrapper] Failed to refresh token:", error2);
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
return response;
|
|
1888
|
+
}
|
|
1889
|
+
async getAllSelfDescriptions() {
|
|
1890
|
+
const url2 = `${this.fcBaseUrl}/self-descriptions`;
|
|
1891
|
+
const response = await this.fetchWithAuth(url2);
|
|
1265
1892
|
return await response.json();
|
|
1266
1893
|
}
|
|
1267
1894
|
async getSelfDescriptionByHash(sdHash) {
|
|
1268
|
-
const token = await this.connect();
|
|
1269
1895
|
const url2 = `${this.fcBaseUrl}/self-descriptions/${sdHash}`;
|
|
1270
|
-
const
|
|
1271
|
-
|
|
1272
|
-
});
|
|
1273
|
-
const response = await fetch(url2, {
|
|
1274
|
-
method: "GET",
|
|
1275
|
-
headers
|
|
1896
|
+
const response = await this.fetchWithAuth(url2, {
|
|
1897
|
+
method: "GET"
|
|
1276
1898
|
});
|
|
1277
1899
|
if (!response.ok) throw new Error(`GET /self-descriptions/${sdHash} failed: ${response.status} ${response.statusText}`, {
|
|
1278
1900
|
cause: response
|
|
@@ -1280,19 +1902,16 @@ let __tla = (async () => {
|
|
|
1280
1902
|
return await response.json();
|
|
1281
1903
|
}
|
|
1282
1904
|
async postQuery(statement, parameters = {}) {
|
|
1283
|
-
const token = await this.connect();
|
|
1284
1905
|
const url2 = `${this.fcBaseUrl}/query`;
|
|
1285
|
-
const headers = new Headers({
|
|
1286
|
-
Authorization: `Bearer ${token}`,
|
|
1287
|
-
"Content-Type": "application/json"
|
|
1288
|
-
});
|
|
1289
1906
|
const body = JSON.stringify({
|
|
1290
1907
|
statement,
|
|
1291
1908
|
parameters
|
|
1292
1909
|
});
|
|
1293
|
-
const response = await
|
|
1910
|
+
const response = await this.fetchWithAuth(url2, {
|
|
1294
1911
|
method: "POST",
|
|
1295
|
-
headers
|
|
1912
|
+
headers: {
|
|
1913
|
+
"Content-Type": "application/json"
|
|
1914
|
+
},
|
|
1296
1915
|
body
|
|
1297
1916
|
});
|
|
1298
1917
|
if (!response.ok) {
|
|
@@ -1303,12 +1922,7 @@ let __tla = (async () => {
|
|
|
1303
1922
|
return await response.json();
|
|
1304
1923
|
}
|
|
1305
1924
|
async postQuerySearch(statement, parameters = {}, queryLanguage = "OPENCYPHER", annotations) {
|
|
1306
|
-
const token = await this.connect();
|
|
1307
1925
|
const url2 = `${this.fcBaseUrl}/query/search`;
|
|
1308
|
-
const headers = new Headers({
|
|
1309
|
-
Authorization: `Bearer ${token}`,
|
|
1310
|
-
"Content-Type": "application/json"
|
|
1311
|
-
});
|
|
1312
1926
|
const body = JSON.stringify({
|
|
1313
1927
|
statement,
|
|
1314
1928
|
parameters,
|
|
@@ -1316,9 +1930,11 @@ let __tla = (async () => {
|
|
|
1316
1930
|
queryLanguage
|
|
1317
1931
|
}
|
|
1318
1932
|
});
|
|
1319
|
-
const response = await
|
|
1933
|
+
const response = await this.fetchWithAuth(url2, {
|
|
1320
1934
|
method: "POST",
|
|
1321
|
-
headers
|
|
1935
|
+
headers: {
|
|
1936
|
+
"Content-Type": "application/json"
|
|
1937
|
+
},
|
|
1322
1938
|
body
|
|
1323
1939
|
});
|
|
1324
1940
|
if (!response.ok) {
|
|
@@ -1329,55 +1945,371 @@ let __tla = (async () => {
|
|
|
1329
1945
|
return await response.json();
|
|
1330
1946
|
}
|
|
1331
1947
|
}
|
|
1332
|
-
function getFederatedCatalogueAPIWrapper(baseUrl,
|
|
1333
|
-
|
|
1334
|
-
|
|
1948
|
+
function getFederatedCatalogueAPIWrapper(baseUrl, loginOptions, fetch2) {
|
|
1949
|
+
return new FederatedCatalogueAPIWrapper(loginOptions, baseUrl, fetch2);
|
|
1950
|
+
}
|
|
1951
|
+
async function checkAuthElementReady(authElement) {
|
|
1952
|
+
var _a2, _b, _c;
|
|
1953
|
+
try {
|
|
1954
|
+
if (typeof authElement.isAuthenticated === "function") {
|
|
1955
|
+
const isAuth = await authElement.isAuthenticated();
|
|
1956
|
+
if (isAuth) {
|
|
1957
|
+
return true;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
if (typeof authElement.getAccessToken === "function") {
|
|
1961
|
+
const token = await authElement.getAccessToken();
|
|
1962
|
+
if (token) {
|
|
1963
|
+
return true;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
const provider = authElement.querySelector("sib-auth-provider-oidc");
|
|
1967
|
+
const authority = (_a2 = provider == null ? void 0 : provider.dataset) == null ? void 0 : _a2.authority;
|
|
1968
|
+
const clientId = ((_b = provider == null ? void 0 : provider.dataset) == null ? void 0 : _b.clientId) || ((_c = provider == null ? void 0 : provider.dataset) == null ? void 0 : _c.clientName);
|
|
1969
|
+
if (authority && clientId) {
|
|
1970
|
+
const storageKey = `oidc.user:${authority}:${clientId}`;
|
|
1971
|
+
const stored = localStorage.getItem(storageKey);
|
|
1972
|
+
if (stored) {
|
|
1973
|
+
const user = JSON.parse(stored);
|
|
1974
|
+
if (user.expires_at && user.expires_at * 1e3 > Date.now() && user.access_token) {
|
|
1975
|
+
return true;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
} catch (error2) {
|
|
1980
|
+
console.warn("[FederatedCatalogueStore] Error checking auth ready:", error2);
|
|
1981
|
+
}
|
|
1982
|
+
return false;
|
|
1983
|
+
}
|
|
1984
|
+
async function waitForAuthReady(maxWaitMs = 5e3) {
|
|
1985
|
+
const startTime = Date.now();
|
|
1986
|
+
const checkInterval = 100;
|
|
1987
|
+
while (Date.now() - startTime < maxWaitMs) {
|
|
1988
|
+
const authElement = AuthFetchResolver.findAuthElement();
|
|
1989
|
+
if (authElement && await checkAuthElementReady(authElement)) {
|
|
1990
|
+
console.log("[FederatedCatalogueStore] Auth is now ready");
|
|
1991
|
+
return true;
|
|
1992
|
+
}
|
|
1993
|
+
await new Promise((resolve) => setTimeout(resolve, checkInterval));
|
|
1994
|
+
}
|
|
1995
|
+
console.warn(`[FederatedCatalogueStore] Timed out waiting for auth after ${maxWaitMs}ms`);
|
|
1996
|
+
return false;
|
|
1335
1997
|
}
|
|
1336
1998
|
class FederatedCatalogueStore {
|
|
1337
1999
|
constructor(cfg) {
|
|
1338
2000
|
__publicField(this, "cache");
|
|
1339
|
-
__publicField(this, "
|
|
1340
|
-
__publicField(this, "
|
|
2001
|
+
__publicField(this, "fcApi", null);
|
|
2002
|
+
__publicField(this, "metadataManager");
|
|
2003
|
+
__publicField(this, "enableCaching");
|
|
2004
|
+
__publicField(this, "cleanupAuth");
|
|
2005
|
+
__publicField(this, "isFetching", false);
|
|
2006
|
+
__publicField(this, "pendingGetData", null);
|
|
2007
|
+
__publicField(this, "resolveFetch", async (event) => {
|
|
2008
|
+
if (!this.cfg.endpoint) {
|
|
2009
|
+
throw new Error("Missing required `endpoint` in StoreConfig for FederatedCatalogueStore");
|
|
2010
|
+
}
|
|
2011
|
+
if (event.detail.fetch) {
|
|
2012
|
+
console.log("[FederatedCatalogueStore] Auth activation event received, verifying token is ready...");
|
|
2013
|
+
const isReady = await waitForAuthReady(5e3);
|
|
2014
|
+
if (!isReady) {
|
|
2015
|
+
console.warn("[FederatedCatalogueStore] Auth activation event received but token not ready, skipping initialization");
|
|
2016
|
+
return;
|
|
2017
|
+
}
|
|
2018
|
+
this.fcApi = getFederatedCatalogueAPIWrapper(this.cfg.endpoint, {}, event.detail.fetch);
|
|
2019
|
+
console.log("[FederatedCatalogueStore] Auth verified and ready, triggering data refetch");
|
|
2020
|
+
this.triggerRefetch();
|
|
2021
|
+
}
|
|
2022
|
+
});
|
|
1341
2023
|
this.cfg = cfg;
|
|
1342
|
-
if (!this.cfg.login) {
|
|
1343
|
-
throw new Error("Login must be provided for FederatedCatalogueStore");
|
|
1344
|
-
}
|
|
1345
2024
|
if (!this.cfg.endpoint) {
|
|
1346
2025
|
throw new Error("Missing required `endpoint` in StoreConfig for FederatedCatalogueStore");
|
|
1347
2026
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
2027
|
+
this.cleanupAuth = AuthFetchResolver.onAuthActivated(this.resolveFetch.bind(this));
|
|
2028
|
+
if (this.cfg.login) {
|
|
2029
|
+
const fetchAuth = AuthFetchResolver.getAuthFetch();
|
|
2030
|
+
this.fcApi = getFederatedCatalogueAPIWrapper(this.cfg.endpoint, this.cfg.login, fetchAuth);
|
|
2031
|
+
} else {
|
|
2032
|
+
this.initializeWithOidcAuth();
|
|
1350
2033
|
}
|
|
1351
|
-
this.fcApi = getFederatedCatalogueAPIWrapper(this.cfg.endpoint, this.cfg.login, this.cfg.optionsServer);
|
|
1352
2034
|
this.cache = new InMemoryCacheManager();
|
|
2035
|
+
this.enableCaching = this.cfg.enableLocalStorageMetadata === true;
|
|
2036
|
+
if (this.enableCaching && this.cfg.endpoint) {
|
|
2037
|
+
const cacheTTL = this.cfg.cacheTTL || 2 * 60 * 60 * 1e3;
|
|
2038
|
+
this.metadataManager = new LocalStorageCacheMetadataManager(this.cfg.endpoint, cacheTTL);
|
|
2039
|
+
this.handlePageReload();
|
|
2040
|
+
} else {
|
|
2041
|
+
this.metadataManager = null;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
disconnectedCallback() {
|
|
2045
|
+
var _a2;
|
|
2046
|
+
(_a2 = this.cleanupAuth) == null ? void 0 : _a2.call(this);
|
|
2047
|
+
}
|
|
2048
|
+
async initializeWithOidcAuth() {
|
|
2049
|
+
var _a2;
|
|
2050
|
+
if (!this.cfg.endpoint) {
|
|
2051
|
+
console.warn("[FederatedCatalogueStore] No endpoint configured, skipping OIDC initialization");
|
|
2052
|
+
return;
|
|
2053
|
+
}
|
|
2054
|
+
const authElement = AuthFetchResolver.findAuthElement();
|
|
2055
|
+
if (!authElement) {
|
|
2056
|
+
console.log("[FederatedCatalogueStore] No auth element found, initializing with basic fetch (anonymous mode)");
|
|
2057
|
+
this.fcApi = getFederatedCatalogueAPIWrapper(this.cfg.endpoint, {}, fetch.bind(window));
|
|
2058
|
+
return;
|
|
2059
|
+
}
|
|
2060
|
+
const isReady = await checkAuthElementReady(authElement);
|
|
2061
|
+
if (isReady) {
|
|
2062
|
+
const fetchAuth = (_a2 = authElement.getFetch) == null ? void 0 : _a2.call(authElement);
|
|
2063
|
+
if (typeof fetchAuth === "function") {
|
|
2064
|
+
console.log("[FederatedCatalogueStore] Auth is ready, initializing fcApi");
|
|
2065
|
+
this.fcApi = getFederatedCatalogueAPIWrapper(this.cfg.endpoint, {}, fetchAuth);
|
|
2066
|
+
}
|
|
2067
|
+
} else {
|
|
2068
|
+
console.log("[FederatedCatalogueStore] Auth not ready yet, will wait for activation event");
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
async triggerRefetch() {
|
|
2072
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
2073
|
+
const resourceId = this.cfg.endpoint || this.buildContainerId();
|
|
2074
|
+
document.dispatchEvent(new CustomEvent("save", {
|
|
2075
|
+
detail: {
|
|
2076
|
+
resource: {
|
|
2077
|
+
"@id": resourceId
|
|
2078
|
+
}
|
|
2079
|
+
},
|
|
2080
|
+
bubbles: true
|
|
2081
|
+
}));
|
|
2082
|
+
document.dispatchEvent(new CustomEvent("fc-store-auth-ready", {
|
|
2083
|
+
detail: {
|
|
2084
|
+
storeEndpoint: this.cfg.endpoint,
|
|
2085
|
+
containerId: resourceId
|
|
2086
|
+
},
|
|
2087
|
+
bubbles: true
|
|
2088
|
+
}));
|
|
2089
|
+
}
|
|
2090
|
+
handlePageReload() {
|
|
2091
|
+
var _a2, _b;
|
|
2092
|
+
try {
|
|
2093
|
+
const SESSION_KEY = "fc-session-id";
|
|
2094
|
+
let sessionId = sessionStorage.getItem(SESSION_KEY);
|
|
2095
|
+
if (!sessionId) {
|
|
2096
|
+
sessionId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
2097
|
+
sessionStorage.setItem(SESSION_KEY, sessionId);
|
|
2098
|
+
(_a2 = this.metadataManager) == null ? void 0 : _a2.clear();
|
|
2099
|
+
}
|
|
2100
|
+
const stats = (_b = this.metadataManager) == null ? void 0 : _b.getCacheStats();
|
|
2101
|
+
if (stats) {
|
|
2102
|
+
}
|
|
2103
|
+
} catch (error2) {
|
|
2104
|
+
console.warn("[FederatedCatalogueStore] Error handling page reload:", error2);
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
resolveTargetType(args) {
|
|
2108
|
+
if (typeof args === "string") return args;
|
|
2109
|
+
if (typeof args === "object" && args !== null) {
|
|
2110
|
+
return args.targetType ?? args.id ?? "";
|
|
2111
|
+
}
|
|
2112
|
+
return "";
|
|
2113
|
+
}
|
|
2114
|
+
buildContainerId(containerType = "default") {
|
|
2115
|
+
var _a2;
|
|
2116
|
+
const endpointHash = ((_a2 = this.cfg.endpoint) == null ? void 0 : _a2.replace(/[^a-zA-Z0-9]/g, "")) || "unknown";
|
|
2117
|
+
return `store://local.fc-${endpointHash}-${containerType}/`;
|
|
1353
2118
|
}
|
|
1354
2119
|
async getData(args) {
|
|
1355
|
-
|
|
2120
|
+
if (this.isFetching) {
|
|
2121
|
+
if (this.pendingGetData) {
|
|
2122
|
+
return this.pendingGetData;
|
|
2123
|
+
}
|
|
2124
|
+
return null;
|
|
2125
|
+
}
|
|
2126
|
+
this.isFetching = true;
|
|
2127
|
+
const executeGetData = async () => {
|
|
2128
|
+
var _a2;
|
|
2129
|
+
const targetType = this.resolveTargetType(args);
|
|
2130
|
+
if (!this.fcApi) {
|
|
2131
|
+
console.warn("[FederatedCatalogueStore] API not initialized yet, waiting for auth activation");
|
|
2132
|
+
return await this.initLocalDataSourceContainer();
|
|
2133
|
+
}
|
|
2134
|
+
const cacheIsValid = this.enableCaching && ((_a2 = this.metadataManager) == null ? void 0 : _a2.isCacheValid());
|
|
2135
|
+
const hasCached = this.hasCachedData();
|
|
2136
|
+
if (cacheIsValid && hasCached) {
|
|
2137
|
+
return await this.getDeltaUpdatedData(targetType);
|
|
2138
|
+
}
|
|
2139
|
+
if (cacheIsValid && !hasCached && this.metadataManager) {
|
|
2140
|
+
this.metadataManager.clear();
|
|
2141
|
+
}
|
|
2142
|
+
return await this.getFullData(targetType);
|
|
2143
|
+
};
|
|
2144
|
+
this.pendingGetData = executeGetData().finally(() => {
|
|
2145
|
+
this.isFetching = false;
|
|
2146
|
+
this.pendingGetData = null;
|
|
2147
|
+
});
|
|
2148
|
+
return this.pendingGetData;
|
|
2149
|
+
}
|
|
2150
|
+
hasCachedData() {
|
|
2151
|
+
try {
|
|
2152
|
+
if (!this.metadataManager) {
|
|
2153
|
+
return false;
|
|
2154
|
+
}
|
|
2155
|
+
const resource = this.metadataManager.getResource();
|
|
2156
|
+
const hasResourceData = !!((resource == null ? void 0 : resource["ldp:contains"]) && resource["ldp:contains"].length > 0);
|
|
2157
|
+
const metadataItemCount = this.metadataManager.getCacheStats().itemCount || 0;
|
|
2158
|
+
return hasResourceData && metadataItemCount > 0;
|
|
2159
|
+
} catch (error2) {
|
|
2160
|
+
console.error("[FederatedCatalogueStore] Error checking cached data:", error2);
|
|
2161
|
+
return false;
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
async getDeltaUpdatedData(targetType) {
|
|
2165
|
+
if (!this.fcApi || !this.metadataManager) {
|
|
2166
|
+
return await this.getFullData(targetType);
|
|
2167
|
+
}
|
|
2168
|
+
try {
|
|
2169
|
+
const apiList = await this.fcApi.getAllSelfDescriptions();
|
|
2170
|
+
if (!apiList || !apiList.items) {
|
|
2171
|
+
console.warn("[FederatedCatalogueStore] No items returned from API");
|
|
2172
|
+
return await this.getFullData(targetType);
|
|
2173
|
+
}
|
|
2174
|
+
const resource = this.metadataManager.getResource();
|
|
2175
|
+
if (!resource) {
|
|
2176
|
+
return await this.getFullData(targetType);
|
|
2177
|
+
}
|
|
2178
|
+
if (!resource["@id"]) {
|
|
2179
|
+
resource["@id"] = this.buildContainerId();
|
|
2180
|
+
}
|
|
2181
|
+
if (!resource["ldp:contains"]) {
|
|
2182
|
+
resource["ldp:contains"] = [];
|
|
2183
|
+
}
|
|
2184
|
+
const knownHashes = this.metadataManager.getKnownHashes();
|
|
2185
|
+
const items = (apiList == null ? void 0 : apiList.items) || [];
|
|
2186
|
+
if (!Array.isArray(items)) {
|
|
2187
|
+
console.warn("[FederatedCatalogueStore] apiList.items is not an array");
|
|
2188
|
+
return resource;
|
|
2189
|
+
}
|
|
2190
|
+
const apiHashes = new Set(items.map((item) => item.meta.sdHash));
|
|
2191
|
+
const newHashes = [];
|
|
2192
|
+
const updatedHashes = [];
|
|
2193
|
+
const deletedHashes = [];
|
|
2194
|
+
for (const item of items) {
|
|
2195
|
+
const hash = item.meta.sdHash;
|
|
2196
|
+
if (!knownHashes.has(hash)) {
|
|
2197
|
+
newHashes.push(hash);
|
|
2198
|
+
} else {
|
|
2199
|
+
const cachedMeta = this.metadataManager.getItemMetadata(hash);
|
|
2200
|
+
if (cachedMeta) {
|
|
2201
|
+
if (item.meta.uploadDatetime > cachedMeta.uploadDatetime || item.meta.statusDatetime > cachedMeta.statusDatetime) {
|
|
2202
|
+
updatedHashes.push(hash);
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
for (const hash of knownHashes) {
|
|
2208
|
+
if (!apiHashes.has(hash)) {
|
|
2209
|
+
deletedHashes.push(hash);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
const toFetch = [
|
|
2213
|
+
...newHashes,
|
|
2214
|
+
...updatedHashes
|
|
2215
|
+
];
|
|
2216
|
+
const newMetadata = [];
|
|
2217
|
+
if (toFetch.length > 0) {
|
|
2218
|
+
for (const hash of toFetch) {
|
|
2219
|
+
try {
|
|
2220
|
+
const sd = await this.fcApi.getSelfDescriptionByHash(hash);
|
|
2221
|
+
if (sd) {
|
|
2222
|
+
const mappedResource = this.mapSourceToDestination(sd, {
|
|
2223
|
+
temsServiceBase: this.cfg.temsServiceBase,
|
|
2224
|
+
temsCategoryBase: this.cfg.temsCategoryBase,
|
|
2225
|
+
temsImageBase: this.cfg.temsImageBase,
|
|
2226
|
+
temsProviderBase: this.cfg.temsProviderBase
|
|
2227
|
+
});
|
|
2228
|
+
if (updatedHashes.includes(hash)) {
|
|
2229
|
+
const index = resource["ldp:contains"].findIndex((r) => r["@id"] === mappedResource["@id"]);
|
|
2230
|
+
if (index !== -1) {
|
|
2231
|
+
resource["ldp:contains"].splice(index, 1);
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
resource["ldp:contains"].push(mappedResource);
|
|
2235
|
+
const apiItem = apiList.items.find((i) => i.meta.sdHash === hash);
|
|
2236
|
+
if (apiItem) {
|
|
2237
|
+
newMetadata.push({
|
|
2238
|
+
sdHash: hash,
|
|
2239
|
+
uploadDatetime: apiItem.meta.uploadDatetime,
|
|
2240
|
+
statusDatetime: apiItem.meta.statusDatetime,
|
|
2241
|
+
cachedAt: Date.now(),
|
|
2242
|
+
resourceId: mappedResource["@id"]
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
} catch (error2) {
|
|
2247
|
+
console.error(`[FederatedCatalogueStore] Error fetching hash ${hash}:`, error2);
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
if (deletedHashes.length > 0) {
|
|
2252
|
+
this.metadataManager.removeItems(deletedHashes);
|
|
2253
|
+
}
|
|
2254
|
+
if (newMetadata.length > 0) {
|
|
2255
|
+
this.metadataManager.updateCache(resource, newMetadata);
|
|
2256
|
+
}
|
|
2257
|
+
document.dispatchEvent(new CustomEvent("save", {
|
|
2258
|
+
detail: {
|
|
2259
|
+
resource: {
|
|
2260
|
+
"@id": resource == null ? void 0 : resource["@id"]
|
|
2261
|
+
}
|
|
2262
|
+
},
|
|
2263
|
+
bubbles: true
|
|
2264
|
+
}));
|
|
2265
|
+
return resource;
|
|
2266
|
+
} catch (error2) {
|
|
2267
|
+
console.error("[FederatedCatalogueStore] Delta update failed, falling back to full fetch:", error2);
|
|
2268
|
+
return await this.getFullData(targetType);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
async getFullData(_targetType) {
|
|
1356
2272
|
if (!this.fcApi) {
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
2273
|
+
console.warn("[FederatedCatalogueStore] API not initialized yet, waiting for auth");
|
|
2274
|
+
return await this.initLocalDataSourceContainer();
|
|
2275
|
+
}
|
|
2276
|
+
const resource = await this.initLocalDataSourceContainer();
|
|
2277
|
+
const dataset2 = await this.fcApi.getAllSelfDescriptions();
|
|
2278
|
+
const newMetadata = [];
|
|
2279
|
+
if ((dataset2 == null ? void 0 : dataset2.items) && Array.isArray(dataset2.items)) {
|
|
2280
|
+
for (const item of dataset2.items) {
|
|
2281
|
+
const sd = await this.fcApi.getSelfDescriptionByHash(item.meta.sdHash);
|
|
1365
2282
|
if (sd) {
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
2283
|
+
try {
|
|
2284
|
+
const mappedResource = this.mapSourceToDestination(sd, {
|
|
2285
|
+
temsServiceBase: this.cfg.temsServiceBase,
|
|
2286
|
+
temsCategoryBase: this.cfg.temsCategoryBase,
|
|
2287
|
+
temsImageBase: this.cfg.temsImageBase,
|
|
2288
|
+
temsProviderBase: this.cfg.temsProviderBase
|
|
2289
|
+
});
|
|
2290
|
+
resource["ldp:contains"].push(mappedResource);
|
|
2291
|
+
if (this.enableCaching) {
|
|
2292
|
+
newMetadata.push({
|
|
2293
|
+
sdHash: item.meta.sdHash,
|
|
2294
|
+
uploadDatetime: item.meta.uploadDatetime,
|
|
2295
|
+
statusDatetime: item.meta.statusDatetime,
|
|
2296
|
+
cachedAt: Date.now(),
|
|
2297
|
+
resourceId: mappedResource["@id"]
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
} catch (error2) {
|
|
2301
|
+
console.error("[FederatedCatalogueStore] Error mapping resource:", error2);
|
|
2302
|
+
}
|
|
1373
2303
|
}
|
|
1374
2304
|
}
|
|
1375
|
-
|
|
2305
|
+
}
|
|
2306
|
+
if (this.enableCaching && this.metadataManager && newMetadata.length > 0) {
|
|
2307
|
+
this.metadataManager.updateCache(resource, newMetadata);
|
|
1376
2308
|
}
|
|
1377
2309
|
document.dispatchEvent(new CustomEvent("save", {
|
|
1378
2310
|
detail: {
|
|
1379
2311
|
resource: {
|
|
1380
|
-
"@id": resource["@id"]
|
|
2312
|
+
"@id": resource == null ? void 0 : resource["@id"]
|
|
1381
2313
|
}
|
|
1382
2314
|
},
|
|
1383
2315
|
bubbles: true
|
|
@@ -1385,11 +2317,8 @@ let __tla = (async () => {
|
|
|
1385
2317
|
return resource;
|
|
1386
2318
|
}
|
|
1387
2319
|
async initLocalDataSourceContainer(dataSrc = "", containerType = "default") {
|
|
1388
|
-
var _a2;
|
|
1389
|
-
const endpointHash = ((_a2 = this.cfg.endpoint) == null ? void 0 : _a2.replace(/[^a-zA-Z0-9]/g, "")) || "unknown";
|
|
1390
|
-
const idField = `fc-${endpointHash}-${containerType}`;
|
|
1391
2320
|
if (!dataSrc) {
|
|
1392
|
-
dataSrc =
|
|
2321
|
+
dataSrc = this.buildContainerId(containerType);
|
|
1393
2322
|
}
|
|
1394
2323
|
const localContainer = {
|
|
1395
2324
|
"@context": "https://cdn.startinblox.com/owl/context.jsonld",
|
|
@@ -1450,10 +2379,10 @@ let __tla = (async () => {
|
|
|
1450
2379
|
}
|
|
1451
2380
|
subscribeResourceTo(_resourceId, _nestedResourceId) {
|
|
1452
2381
|
}
|
|
1453
|
-
fetchAuthn(_iri, _options) {
|
|
1454
|
-
return Promise.resolve({});
|
|
2382
|
+
async fetchAuthn(_iri, _options) {
|
|
2383
|
+
return await Promise.resolve({});
|
|
1455
2384
|
}
|
|
1456
|
-
async setLocalData(resource, id
|
|
2385
|
+
async setLocalData(resource, id) {
|
|
1457
2386
|
try {
|
|
1458
2387
|
const resourceWithId = {
|
|
1459
2388
|
...resource,
|
|
@@ -1477,8 +2406,39 @@ let __tla = (async () => {
|
|
|
1477
2406
|
bubbles: true
|
|
1478
2407
|
}));
|
|
1479
2408
|
}
|
|
2409
|
+
stripUrnPrefix(id, prefix) {
|
|
2410
|
+
if (id == null ? void 0 : id.startsWith(prefix)) {
|
|
2411
|
+
return id.substring(prefix.length);
|
|
2412
|
+
}
|
|
2413
|
+
return id;
|
|
2414
|
+
}
|
|
2415
|
+
stripTemsUrnFromPolicy(obj) {
|
|
2416
|
+
if (obj === null || obj === void 0) {
|
|
2417
|
+
return obj;
|
|
2418
|
+
}
|
|
2419
|
+
if (typeof obj === "string") {
|
|
2420
|
+
return this.stripUrnPrefix(obj, "urn:tems:");
|
|
2421
|
+
}
|
|
2422
|
+
if (Array.isArray(obj)) {
|
|
2423
|
+
return obj.map((item) => this.stripTemsUrnFromPolicy(item));
|
|
2424
|
+
}
|
|
2425
|
+
if (typeof obj === "object") {
|
|
2426
|
+
const result = {};
|
|
2427
|
+
for (const key in obj) {
|
|
2428
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
2429
|
+
if (key === "@id") {
|
|
2430
|
+
result[key] = this.stripUrnPrefix(obj[key], "urn:tems:");
|
|
2431
|
+
} else {
|
|
2432
|
+
result[key] = this.stripTemsUrnFromPolicy(obj[key]);
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
return result;
|
|
2437
|
+
}
|
|
2438
|
+
return obj;
|
|
2439
|
+
}
|
|
1480
2440
|
mapSourceToDestination(src, opts) {
|
|
1481
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2441
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1482
2442
|
const vc = src.verifiableCredential;
|
|
1483
2443
|
const cs = vc.credentialSubject;
|
|
1484
2444
|
let catInfo;
|
|
@@ -1489,9 +2449,16 @@ let __tla = (async () => {
|
|
|
1489
2449
|
usedKey = "service";
|
|
1490
2450
|
type = "tems:Service";
|
|
1491
2451
|
} else if (cs["dcat:dataset"] && cs["dcat:dataset"].length > 0) {
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
2452
|
+
const dataset2 = cs["dcat:dataset"][0];
|
|
2453
|
+
if (dataset2["dcat:service"]) {
|
|
2454
|
+
catInfo = dataset2["dcat:service"];
|
|
2455
|
+
usedKey = "nested-service";
|
|
2456
|
+
type = "tems:Service";
|
|
2457
|
+
} else {
|
|
2458
|
+
catInfo = dataset2;
|
|
2459
|
+
usedKey = "dataset";
|
|
2460
|
+
type = "tems:DataOffer";
|
|
2461
|
+
}
|
|
1495
2462
|
} else {
|
|
1496
2463
|
throw new Error("Expected either credentialSubject['dcat:service'] or a non-empty array in ['dcat:dataset']");
|
|
1497
2464
|
}
|
|
@@ -1500,7 +2467,7 @@ let __tla = (async () => {
|
|
|
1500
2467
|
const serviceId = `${opts.temsServiceBase}${encodeURIComponent(slug)}/`;
|
|
1501
2468
|
const creation_date = vc.issuanceDate;
|
|
1502
2469
|
const update_date = vc.expirationDate;
|
|
1503
|
-
const name = catInfo["dcterms:title"];
|
|
2470
|
+
const name = catInfo["dcterms:title"] || catInfo["dct:title"];
|
|
1504
2471
|
const description = catInfo["rdfs:comment"];
|
|
1505
2472
|
const keywords = catInfo["dcat:keyword"] || [];
|
|
1506
2473
|
const long_description = keywords.length > 0 ? `Keywords: ${keywords.join(", ")}` : "";
|
|
@@ -1540,19 +2507,24 @@ let __tla = (async () => {
|
|
|
1540
2507
|
const contact_url = catInfo["dcat:endpointDescription"] || "";
|
|
1541
2508
|
const documentation_url = contact_url || "";
|
|
1542
2509
|
let service_url = catInfo["dcat:endpointURL"] || "";
|
|
2510
|
+
if (!service_url) {
|
|
2511
|
+
console.warn("[FederatedCatalogueStore] dcat:endpointURL is missing from dcat:service. Available fields:", Object.keys(catInfo));
|
|
2512
|
+
}
|
|
1543
2513
|
if (service_url.includes("demo.isan.org")) service_url = new URL(service_url).origin;
|
|
1544
2514
|
let providerRef;
|
|
1545
2515
|
if (usedKey === "service") {
|
|
1546
2516
|
providerRef = ((_d = cs["gax-core:operatedBy"]) == null ? void 0 : _d["@id"]) || "";
|
|
2517
|
+
} else if (usedKey === "nested-service") {
|
|
2518
|
+
providerRef = ((_e = cs["gax-core:operatedBy"]) == null ? void 0 : _e["@id"]) || ((_f = cs["gax-core:offeredBy"]) == null ? void 0 : _f["@id"]) || "";
|
|
1547
2519
|
} else {
|
|
1548
|
-
providerRef = ((
|
|
2520
|
+
providerRef = ((_g = cs["gax-core:offeredBy"]) == null ? void 0 : _g["@id"]) || "";
|
|
1549
2521
|
}
|
|
1550
2522
|
const providerSlug = providerRef.split(":").pop() + String(Math.random()) || "0";
|
|
1551
|
-
const providerLogo = ((
|
|
2523
|
+
const providerLogo = ((_i = (_h = catInfo["dcterms:creator"]) == null ? void 0 : _h["foaf:thumbnail"]) == null ? void 0 : _i["rdf:resource"]) || "";
|
|
1552
2524
|
const provider = {
|
|
1553
2525
|
"@id": `${opts.temsProviderBase}${encodeURIComponent(providerSlug)}/`,
|
|
1554
2526
|
"@type": "tems:Provider",
|
|
1555
|
-
name: ((
|
|
2527
|
+
name: ((_j = catInfo["dcterms:creator"]) == null ? void 0 : _j["foaf:name"]) || "",
|
|
1556
2528
|
image: {
|
|
1557
2529
|
"@id": `${opts.temsImageBase}${encodeURIComponent(providerLogo.split("/").pop() || "0")}/`,
|
|
1558
2530
|
"@type": "tems:Image",
|
|
@@ -1562,6 +2534,49 @@ let __tla = (async () => {
|
|
|
1562
2534
|
}
|
|
1563
2535
|
};
|
|
1564
2536
|
const data_offers = [];
|
|
2537
|
+
const counterPartyAddress = cs["dcat:endpointURL"];
|
|
2538
|
+
const counterPartyId = cs["dspace:participantId"];
|
|
2539
|
+
const assetId = this.stripUrnPrefix(cs["@id"], "urn:uuid:");
|
|
2540
|
+
let datasetId;
|
|
2541
|
+
let policy;
|
|
2542
|
+
let policies = [];
|
|
2543
|
+
if (cs["dcat:dataset"] && cs["dcat:dataset"].length > 0) {
|
|
2544
|
+
const dataset2 = cs["dcat:dataset"][0];
|
|
2545
|
+
if (dataset2["@id"]) {
|
|
2546
|
+
datasetId = this.stripUrnPrefix(dataset2["@id"], "urn:uuid:");
|
|
2547
|
+
}
|
|
2548
|
+
if (dataset2["odrl:hasPolicy"]) {
|
|
2549
|
+
const rawPolicy = dataset2["odrl:hasPolicy"];
|
|
2550
|
+
const processSinglePolicy = (policyObj) => {
|
|
2551
|
+
const processedPolicy = this.stripTemsUrnFromPolicy(JSON.parse(JSON.stringify(policyObj)));
|
|
2552
|
+
if (datasetId) {
|
|
2553
|
+
processedPolicy.target = datasetId;
|
|
2554
|
+
}
|
|
2555
|
+
return processedPolicy;
|
|
2556
|
+
};
|
|
2557
|
+
if (Array.isArray(rawPolicy)) {
|
|
2558
|
+
policies = rawPolicy.map(processSinglePolicy);
|
|
2559
|
+
policy = policies[0];
|
|
2560
|
+
} else {
|
|
2561
|
+
policy = processSinglePolicy(rawPolicy);
|
|
2562
|
+
policies = [
|
|
2563
|
+
policy
|
|
2564
|
+
];
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
console.log("[FederatedCatalogueStore] \u{1F50D} Policy processing for", name, ":", {
|
|
2569
|
+
hasPolicy: !!policy,
|
|
2570
|
+
policiesCount: policies.length,
|
|
2571
|
+
policy: policy ? {
|
|
2572
|
+
"@id": policy["@id"],
|
|
2573
|
+
hasTarget: !!policy.target
|
|
2574
|
+
} : null,
|
|
2575
|
+
policies: policies.map((p) => ({
|
|
2576
|
+
"@id": p["@id"],
|
|
2577
|
+
hasTarget: !!p.target
|
|
2578
|
+
}))
|
|
2579
|
+
});
|
|
1565
2580
|
const dest = {
|
|
1566
2581
|
"@id": serviceId,
|
|
1567
2582
|
creation_date,
|
|
@@ -1585,12 +2600,35 @@ let __tla = (async () => {
|
|
|
1585
2600
|
url: service_url,
|
|
1586
2601
|
provider,
|
|
1587
2602
|
data_offers,
|
|
1588
|
-
"@type": type
|
|
2603
|
+
"@type": type,
|
|
2604
|
+
...counterPartyAddress && {
|
|
2605
|
+
counterPartyAddress
|
|
2606
|
+
},
|
|
2607
|
+
...counterPartyId && {
|
|
2608
|
+
counterPartyId
|
|
2609
|
+
},
|
|
2610
|
+
...assetId && {
|
|
2611
|
+
assetId
|
|
2612
|
+
},
|
|
2613
|
+
...datasetId && {
|
|
2614
|
+
datasetId
|
|
2615
|
+
},
|
|
2616
|
+
...policy && {
|
|
2617
|
+
policy
|
|
2618
|
+
},
|
|
2619
|
+
...policies.length > 0 && {
|
|
2620
|
+
policies
|
|
2621
|
+
}
|
|
1589
2622
|
};
|
|
2623
|
+
console.log("[FederatedCatalogueStore] \u{1F50D} Destination object contract fields:", {
|
|
2624
|
+
hasPolicy: "policy" in dest,
|
|
2625
|
+
hasPolicies: "policies" in dest,
|
|
2626
|
+
policiesValue: dest.policies
|
|
2627
|
+
});
|
|
1590
2628
|
return dest;
|
|
1591
2629
|
}
|
|
1592
2630
|
}
|
|
1593
|
-
|
|
2631
|
+
class FederatedCatalogueStoreAdapter {
|
|
1594
2632
|
constructor() {
|
|
1595
2633
|
}
|
|
1596
2634
|
static validateConfiguration(cfg) {
|
|
@@ -1606,18 +2644,13 @@ let __tla = (async () => {
|
|
|
1606
2644
|
}
|
|
1607
2645
|
}
|
|
1608
2646
|
static getStoreInstance(cfg) {
|
|
1609
|
-
if (!
|
|
1610
|
-
|
|
1611
|
-
throw new Error("[FederatedCatalogueStoreAdapter] configuration is required");
|
|
1612
|
-
}
|
|
1613
|
-
_FederatedCatalogueStoreAdapter.validateConfiguration(cfg);
|
|
1614
|
-
_FederatedCatalogueStoreAdapter.store = new FederatedCatalogueStore(cfg);
|
|
2647
|
+
if (!cfg) {
|
|
2648
|
+
throw new Error("[FederatedCatalogueStoreAdapter] configuration is required");
|
|
1615
2649
|
}
|
|
1616
|
-
|
|
2650
|
+
FederatedCatalogueStoreAdapter.validateConfiguration(cfg);
|
|
2651
|
+
return new FederatedCatalogueStore(cfg);
|
|
1617
2652
|
}
|
|
1618
|
-
}
|
|
1619
|
-
__publicField(_FederatedCatalogueStoreAdapter, "store");
|
|
1620
|
-
let FederatedCatalogueStoreAdapter = _FederatedCatalogueStoreAdapter;
|
|
2653
|
+
}
|
|
1621
2654
|
var lib = {};
|
|
1622
2655
|
var IdentifierIssuer_1;
|
|
1623
2656
|
var hasRequiredIdentifierIssuer;
|
|
@@ -2934,7 +3967,7 @@ let __tla = (async () => {
|
|
|
2934
3967
|
function requireLib() {
|
|
2935
3968
|
if (hasRequiredLib) return lib;
|
|
2936
3969
|
hasRequiredLib = 1;
|
|
2937
|
-
(function(exports) {
|
|
3970
|
+
(function(exports$1) {
|
|
2938
3971
|
const URDNA2015 = requireURDNA2015();
|
|
2939
3972
|
const URGNA20122 = requireURGNA2012();
|
|
2940
3973
|
const URDNA2015Sync = requireURDNA2015Sync();
|
|
@@ -2946,19 +3979,19 @@ let __tla = (async () => {
|
|
|
2946
3979
|
}
|
|
2947
3980
|
function _inputToDataset(input) {
|
|
2948
3981
|
if (!Array.isArray(input)) {
|
|
2949
|
-
return exports.NQuads.legacyDatasetToQuads(input);
|
|
3982
|
+
return exports$1.NQuads.legacyDatasetToQuads(input);
|
|
2950
3983
|
}
|
|
2951
3984
|
return input;
|
|
2952
3985
|
}
|
|
2953
|
-
exports.NQuads = requireNQuads$1();
|
|
2954
|
-
exports.IdentifierIssuer = requireIdentifierIssuer();
|
|
2955
|
-
exports._rdfCanonizeNative = function(api) {
|
|
3986
|
+
exports$1.NQuads = requireNQuads$1();
|
|
3987
|
+
exports$1.IdentifierIssuer = requireIdentifierIssuer();
|
|
3988
|
+
exports$1._rdfCanonizeNative = function(api) {
|
|
2956
3989
|
if (api) {
|
|
2957
3990
|
rdfCanonizeNative = api;
|
|
2958
3991
|
}
|
|
2959
3992
|
return rdfCanonizeNative;
|
|
2960
3993
|
};
|
|
2961
|
-
exports.canonize = async function(input, options) {
|
|
3994
|
+
exports$1.canonize = async function(input, options) {
|
|
2962
3995
|
const dataset2 = _inputToDataset(input);
|
|
2963
3996
|
if (options.useNative) {
|
|
2964
3997
|
if (!rdfCanonizeNative) {
|
|
@@ -2983,7 +4016,7 @@ let __tla = (async () => {
|
|
|
2983
4016
|
}
|
|
2984
4017
|
throw new Error("Invalid RDF Dataset Canonicalization algorithm: " + options.algorithm);
|
|
2985
4018
|
};
|
|
2986
|
-
exports._canonizeSync = function(input, options) {
|
|
4019
|
+
exports$1._canonizeSync = function(input, options) {
|
|
2987
4020
|
const dataset2 = _inputToDataset(input);
|
|
2988
4021
|
if (options.useNative) {
|
|
2989
4022
|
if (!rdfCanonizeNative) {
|
|
@@ -9809,7 +10842,7 @@ let __tla = (async () => {
|
|
|
9809
10842
|
function requirePubsub() {
|
|
9810
10843
|
if (hasRequiredPubsub) return pubsub$1.exports;
|
|
9811
10844
|
hasRequiredPubsub = 1;
|
|
9812
|
-
(function(module, exports) {
|
|
10845
|
+
(function(module, exports$1) {
|
|
9813
10846
|
(function(root, factory2) {
|
|
9814
10847
|
var PubSub2 = {};
|
|
9815
10848
|
if (root.PubSub) {
|
|
@@ -9821,10 +10854,10 @@ let __tla = (async () => {
|
|
|
9821
10854
|
}
|
|
9822
10855
|
{
|
|
9823
10856
|
if (module !== void 0 && module.exports) {
|
|
9824
|
-
exports = module.exports = PubSub2;
|
|
10857
|
+
exports$1 = module.exports = PubSub2;
|
|
9825
10858
|
}
|
|
9826
|
-
exports.PubSub = PubSub2;
|
|
9827
|
-
module.exports = exports = PubSub2;
|
|
10859
|
+
exports$1.PubSub = PubSub2;
|
|
10860
|
+
module.exports = exports$1 = PubSub2;
|
|
9828
10861
|
}
|
|
9829
10862
|
})(typeof window === "object" && window || pubsub || globalThis, function(PubSub2) {
|
|
9830
10863
|
var messages = {}, lastUid = -1, ALL_SUBSCRIBING_MSG = "*";
|
|
@@ -10597,15 +11630,15 @@ let __tla = (async () => {
|
|
|
10597
11630
|
function requireBuffer() {
|
|
10598
11631
|
if (hasRequiredBuffer) return buffer;
|
|
10599
11632
|
hasRequiredBuffer = 1;
|
|
10600
|
-
(function(exports) {
|
|
11633
|
+
(function(exports$1) {
|
|
10601
11634
|
const base64 = requireBase64Js();
|
|
10602
11635
|
const ieee7542 = requireIeee754();
|
|
10603
11636
|
const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
|
10604
|
-
exports.Buffer = Buffer2;
|
|
10605
|
-
exports.SlowBuffer = SlowBuffer;
|
|
10606
|
-
exports.INSPECT_MAX_BYTES = 50;
|
|
11637
|
+
exports$1.Buffer = Buffer2;
|
|
11638
|
+
exports$1.SlowBuffer = SlowBuffer;
|
|
11639
|
+
exports$1.INSPECT_MAX_BYTES = 50;
|
|
10607
11640
|
const K_MAX_LENGTH = 2147483647;
|
|
10608
|
-
exports.kMaxLength = K_MAX_LENGTH;
|
|
11641
|
+
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
10609
11642
|
Buffer2.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
10610
11643
|
if (!Buffer2.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
|
|
10611
11644
|
console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");
|
|
@@ -11019,7 +12052,7 @@ let __tla = (async () => {
|
|
|
11019
12052
|
};
|
|
11020
12053
|
Buffer2.prototype.inspect = function inspect2() {
|
|
11021
12054
|
let str = "";
|
|
11022
|
-
const max = exports.INSPECT_MAX_BYTES;
|
|
12055
|
+
const max = exports$1.INSPECT_MAX_BYTES;
|
|
11023
12056
|
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
|
|
11024
12057
|
if (this.length > max) str += " ... ";
|
|
11025
12058
|
return "<Buffer " + str + ">";
|
|
@@ -12110,7 +13143,7 @@ let __tla = (async () => {
|
|
|
12110
13143
|
function numberIsNaN(obj) {
|
|
12111
13144
|
return obj !== obj;
|
|
12112
13145
|
}
|
|
12113
|
-
const hexSliceLookupTable = function() {
|
|
13146
|
+
const hexSliceLookupTable = (function() {
|
|
12114
13147
|
const alphabet = "0123456789abcdef";
|
|
12115
13148
|
const table = new Array(256);
|
|
12116
13149
|
for (let i = 0; i < 16; ++i) {
|
|
@@ -12120,7 +13153,7 @@ let __tla = (async () => {
|
|
|
12120
13153
|
}
|
|
12121
13154
|
}
|
|
12122
13155
|
return table;
|
|
12123
|
-
}();
|
|
13156
|
+
})();
|
|
12124
13157
|
function defineBigIntMethod(fn) {
|
|
12125
13158
|
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
|
|
12126
13159
|
}
|
|
@@ -12211,7 +13244,7 @@ let __tla = (async () => {
|
|
|
12211
13244
|
function copyBuffer(src, target, offset) {
|
|
12212
13245
|
Buffer2.prototype.copy.call(src, target, offset);
|
|
12213
13246
|
}
|
|
12214
|
-
buffer_list$1 = function() {
|
|
13247
|
+
buffer_list$1 = (function() {
|
|
12215
13248
|
function BufferList() {
|
|
12216
13249
|
_classCallCheck(this, BufferList);
|
|
12217
13250
|
this.head = null;
|
|
@@ -12379,7 +13412,7 @@ let __tla = (async () => {
|
|
|
12379
13412
|
}
|
|
12380
13413
|
]);
|
|
12381
13414
|
return BufferList;
|
|
12382
|
-
}();
|
|
13415
|
+
})();
|
|
12383
13416
|
return buffer_list$1;
|
|
12384
13417
|
}
|
|
12385
13418
|
var destroy_1$1;
|
|
@@ -12493,13 +13526,13 @@ let __tla = (async () => {
|
|
|
12493
13526
|
return message(arg1, arg2, arg3);
|
|
12494
13527
|
}
|
|
12495
13528
|
}
|
|
12496
|
-
var NodeError = function(_Base) {
|
|
13529
|
+
var NodeError = (function(_Base) {
|
|
12497
13530
|
_inheritsLoose(NodeError2, _Base);
|
|
12498
13531
|
function NodeError2(arg1, arg2, arg3) {
|
|
12499
13532
|
return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
|
|
12500
13533
|
}
|
|
12501
13534
|
return NodeError2;
|
|
12502
|
-
}(Base);
|
|
13535
|
+
})(Base);
|
|
12503
13536
|
NodeError.prototype.name = Base.name;
|
|
12504
13537
|
NodeError.prototype.code = code;
|
|
12505
13538
|
codes[code] = NodeError;
|
|
@@ -13194,7 +14227,7 @@ let __tla = (async () => {
|
|
|
13194
14227
|
function requireSafeBuffer() {
|
|
13195
14228
|
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
13196
14229
|
hasRequiredSafeBuffer = 1;
|
|
13197
|
-
(function(module, exports) {
|
|
14230
|
+
(function(module, exports$1) {
|
|
13198
14231
|
var buffer2 = requireBuffer();
|
|
13199
14232
|
var Buffer2 = buffer2.Buffer;
|
|
13200
14233
|
function copyProps(src, dst) {
|
|
@@ -13205,8 +14238,8 @@ let __tla = (async () => {
|
|
|
13205
14238
|
if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
|
|
13206
14239
|
module.exports = buffer2;
|
|
13207
14240
|
} else {
|
|
13208
|
-
copyProps(buffer2, exports);
|
|
13209
|
-
exports.Buffer = SafeBuffer;
|
|
14241
|
+
copyProps(buffer2, exports$1);
|
|
14242
|
+
exports$1.Buffer = SafeBuffer;
|
|
13210
14243
|
}
|
|
13211
14244
|
function SafeBuffer(arg, encodingOrOffset, length) {
|
|
13212
14245
|
return Buffer2(arg, encodingOrOffset, length);
|
|
@@ -14393,11 +15426,11 @@ let __tla = (async () => {
|
|
|
14393
15426
|
});
|
|
14394
15427
|
for (var i in stream2) {
|
|
14395
15428
|
if (this[i] === void 0 && typeof stream2[i] === "function") {
|
|
14396
|
-
this[i] = /* @__PURE__ */ function methodWrap(method) {
|
|
15429
|
+
this[i] = /* @__PURE__ */ (function methodWrap(method) {
|
|
14397
15430
|
return function methodWrapReturnFunction() {
|
|
14398
15431
|
return stream2[method].apply(stream2, arguments);
|
|
14399
15432
|
};
|
|
14400
|
-
}(i);
|
|
15433
|
+
})(i);
|
|
14401
15434
|
}
|
|
14402
15435
|
}
|
|
14403
15436
|
for (var n = 0; n < kProxyEvents.length; n++) {
|
|
@@ -19163,50 +20196,64 @@ let __tla = (async () => {
|
|
|
19163
20196
|
createDebug.namespaces = namespaces2;
|
|
19164
20197
|
createDebug.names = [];
|
|
19165
20198
|
createDebug.skips = [];
|
|
19166
|
-
|
|
19167
|
-
|
|
19168
|
-
|
|
19169
|
-
|
|
19170
|
-
|
|
19171
|
-
|
|
20199
|
+
const split = (typeof namespaces2 === "string" ? namespaces2 : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
20200
|
+
for (const ns2 of split) {
|
|
20201
|
+
if (ns2[0] === "-") {
|
|
20202
|
+
createDebug.skips.push(ns2.slice(1));
|
|
20203
|
+
} else {
|
|
20204
|
+
createDebug.names.push(ns2);
|
|
19172
20205
|
}
|
|
19173
|
-
|
|
19174
|
-
|
|
19175
|
-
|
|
20206
|
+
}
|
|
20207
|
+
}
|
|
20208
|
+
function matchesTemplate(search, template) {
|
|
20209
|
+
let searchIndex = 0;
|
|
20210
|
+
let templateIndex = 0;
|
|
20211
|
+
let starIndex = -1;
|
|
20212
|
+
let matchIndex = 0;
|
|
20213
|
+
while (searchIndex < search.length) {
|
|
20214
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
20215
|
+
if (template[templateIndex] === "*") {
|
|
20216
|
+
starIndex = templateIndex;
|
|
20217
|
+
matchIndex = searchIndex;
|
|
20218
|
+
templateIndex++;
|
|
20219
|
+
} else {
|
|
20220
|
+
searchIndex++;
|
|
20221
|
+
templateIndex++;
|
|
20222
|
+
}
|
|
20223
|
+
} else if (starIndex !== -1) {
|
|
20224
|
+
templateIndex = starIndex + 1;
|
|
20225
|
+
matchIndex++;
|
|
20226
|
+
searchIndex = matchIndex;
|
|
19176
20227
|
} else {
|
|
19177
|
-
|
|
20228
|
+
return false;
|
|
19178
20229
|
}
|
|
19179
20230
|
}
|
|
20231
|
+
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
20232
|
+
templateIndex++;
|
|
20233
|
+
}
|
|
20234
|
+
return templateIndex === template.length;
|
|
19180
20235
|
}
|
|
19181
20236
|
function disable() {
|
|
19182
20237
|
const namespaces2 = [
|
|
19183
|
-
...createDebug.names
|
|
19184
|
-
...createDebug.skips.map(
|
|
20238
|
+
...createDebug.names,
|
|
20239
|
+
...createDebug.skips.map((namespace2) => "-" + namespace2)
|
|
19185
20240
|
].join(",");
|
|
19186
20241
|
createDebug.enable("");
|
|
19187
20242
|
return namespaces2;
|
|
19188
20243
|
}
|
|
19189
20244
|
function enabled(name) {
|
|
19190
|
-
|
|
19191
|
-
|
|
19192
|
-
}
|
|
19193
|
-
let i;
|
|
19194
|
-
let len;
|
|
19195
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
19196
|
-
if (createDebug.skips[i].test(name)) {
|
|
20245
|
+
for (const skip of createDebug.skips) {
|
|
20246
|
+
if (matchesTemplate(name, skip)) {
|
|
19197
20247
|
return false;
|
|
19198
20248
|
}
|
|
19199
20249
|
}
|
|
19200
|
-
for (
|
|
19201
|
-
if (
|
|
20250
|
+
for (const ns2 of createDebug.names) {
|
|
20251
|
+
if (matchesTemplate(name, ns2)) {
|
|
19202
20252
|
return true;
|
|
19203
20253
|
}
|
|
19204
20254
|
}
|
|
19205
20255
|
return false;
|
|
19206
20256
|
}
|
|
19207
|
-
function toNamespace(regexp) {
|
|
19208
|
-
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
19209
|
-
}
|
|
19210
20257
|
function coerce(val) {
|
|
19211
20258
|
if (val instanceof Error) {
|
|
19212
20259
|
return val.stack || val.message;
|
|
@@ -19226,13 +20273,14 @@ let __tla = (async () => {
|
|
|
19226
20273
|
function requireBrowser$3() {
|
|
19227
20274
|
if (hasRequiredBrowser$3) return browser$3.exports;
|
|
19228
20275
|
hasRequiredBrowser$3 = 1;
|
|
19229
|
-
(function(module, exports) {
|
|
19230
|
-
|
|
19231
|
-
exports.
|
|
19232
|
-
exports.
|
|
19233
|
-
exports.
|
|
19234
|
-
exports.
|
|
19235
|
-
exports.
|
|
20276
|
+
(function(module, exports$1) {
|
|
20277
|
+
var define_process_env_default = {};
|
|
20278
|
+
exports$1.formatArgs = formatArgs;
|
|
20279
|
+
exports$1.save = save;
|
|
20280
|
+
exports$1.load = load;
|
|
20281
|
+
exports$1.useColors = useColors;
|
|
20282
|
+
exports$1.storage = localstorage();
|
|
20283
|
+
exports$1.destroy = /* @__PURE__ */ (() => {
|
|
19236
20284
|
let warned = false;
|
|
19237
20285
|
return () => {
|
|
19238
20286
|
if (!warned) {
|
|
@@ -19241,7 +20289,7 @@ let __tla = (async () => {
|
|
|
19241
20289
|
}
|
|
19242
20290
|
};
|
|
19243
20291
|
})();
|
|
19244
|
-
exports.colors = [
|
|
20292
|
+
exports$1.colors = [
|
|
19245
20293
|
"#0000CC",
|
|
19246
20294
|
"#0000FF",
|
|
19247
20295
|
"#0033CC",
|
|
@@ -19326,7 +20374,8 @@ let __tla = (async () => {
|
|
|
19326
20374
|
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
19327
20375
|
return false;
|
|
19328
20376
|
}
|
|
19329
|
-
|
|
20377
|
+
let m;
|
|
20378
|
+
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
19330
20379
|
}
|
|
19331
20380
|
function formatArgs(args) {
|
|
19332
20381
|
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
@@ -19348,14 +20397,14 @@ let __tla = (async () => {
|
|
|
19348
20397
|
});
|
|
19349
20398
|
args.splice(lastC, 0, c);
|
|
19350
20399
|
}
|
|
19351
|
-
exports.log = console.debug || console.log || (() => {
|
|
20400
|
+
exports$1.log = console.debug || console.log || (() => {
|
|
19352
20401
|
});
|
|
19353
20402
|
function save(namespaces2) {
|
|
19354
20403
|
try {
|
|
19355
20404
|
if (namespaces2) {
|
|
19356
|
-
exports.storage.setItem("debug", namespaces2);
|
|
20405
|
+
exports$1.storage.setItem("debug", namespaces2);
|
|
19357
20406
|
} else {
|
|
19358
|
-
exports.storage.removeItem("debug");
|
|
20407
|
+
exports$1.storage.removeItem("debug");
|
|
19359
20408
|
}
|
|
19360
20409
|
} catch (error2) {
|
|
19361
20410
|
}
|
|
@@ -19363,11 +20412,11 @@ let __tla = (async () => {
|
|
|
19363
20412
|
function load() {
|
|
19364
20413
|
let r;
|
|
19365
20414
|
try {
|
|
19366
|
-
r = exports.storage.getItem("debug");
|
|
20415
|
+
r = exports$1.storage.getItem("debug") || exports$1.storage.getItem("DEBUG");
|
|
19367
20416
|
} catch (error2) {
|
|
19368
20417
|
}
|
|
19369
20418
|
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
19370
|
-
r =
|
|
20419
|
+
r = define_process_env_default.DEBUG;
|
|
19371
20420
|
}
|
|
19372
20421
|
return r;
|
|
19373
20422
|
}
|
|
@@ -19377,7 +20426,7 @@ let __tla = (async () => {
|
|
|
19377
20426
|
} catch (error2) {
|
|
19378
20427
|
}
|
|
19379
20428
|
}
|
|
19380
|
-
module.exports = requireCommon()(exports);
|
|
20429
|
+
module.exports = requireCommon()(exports$1);
|
|
19381
20430
|
const { formatters } = module.exports;
|
|
19382
20431
|
formatters.j = function(v) {
|
|
19383
20432
|
try {
|
|
@@ -20222,8 +21271,8 @@ let __tla = (async () => {
|
|
|
20222
21271
|
function requireRdfDataFactory() {
|
|
20223
21272
|
if (hasRequiredRdfDataFactory) return rdfDataFactory;
|
|
20224
21273
|
hasRequiredRdfDataFactory = 1;
|
|
20225
|
-
(function(exports) {
|
|
20226
|
-
var __createBinding = rdfDataFactory && rdfDataFactory.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
21274
|
+
(function(exports$1) {
|
|
21275
|
+
var __createBinding = rdfDataFactory && rdfDataFactory.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
20227
21276
|
if (k2 === void 0) k2 = k;
|
|
20228
21277
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20229
21278
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
@@ -20235,23 +21284,23 @@ let __tla = (async () => {
|
|
|
20235
21284
|
};
|
|
20236
21285
|
}
|
|
20237
21286
|
Object.defineProperty(o, k2, desc);
|
|
20238
|
-
} : function(o, m, k, k2) {
|
|
21287
|
+
}) : (function(o, m, k, k2) {
|
|
20239
21288
|
if (k2 === void 0) k2 = k;
|
|
20240
21289
|
o[k2] = m[k];
|
|
20241
|
-
});
|
|
20242
|
-
var __exportStar = rdfDataFactory && rdfDataFactory.__exportStar || function(m,
|
|
20243
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(
|
|
21290
|
+
}));
|
|
21291
|
+
var __exportStar = rdfDataFactory && rdfDataFactory.__exportStar || function(m, exports$12) {
|
|
21292
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$12, p)) __createBinding(exports$12, m, p);
|
|
20244
21293
|
};
|
|
20245
|
-
Object.defineProperty(exports, "__esModule", {
|
|
21294
|
+
Object.defineProperty(exports$1, "__esModule", {
|
|
20246
21295
|
value: true
|
|
20247
21296
|
});
|
|
20248
|
-
__exportStar(requireBlankNode(), exports);
|
|
20249
|
-
__exportStar(requireDataFactory(), exports);
|
|
20250
|
-
__exportStar(requireDefaultGraph(), exports);
|
|
20251
|
-
__exportStar(requireLiteral(), exports);
|
|
20252
|
-
__exportStar(requireNamedNode(), exports);
|
|
20253
|
-
__exportStar(requireQuad(), exports);
|
|
20254
|
-
__exportStar(requireVariable(), exports);
|
|
21297
|
+
__exportStar(requireBlankNode(), exports$1);
|
|
21298
|
+
__exportStar(requireDataFactory(), exports$1);
|
|
21299
|
+
__exportStar(requireDefaultGraph(), exports$1);
|
|
21300
|
+
__exportStar(requireLiteral(), exports$1);
|
|
21301
|
+
__exportStar(requireNamedNode(), exports$1);
|
|
21302
|
+
__exportStar(requireQuad(), exports$1);
|
|
21303
|
+
__exportStar(requireVariable(), exports$1);
|
|
20255
21304
|
})(rdfDataFactory);
|
|
20256
21305
|
return rdfDataFactory;
|
|
20257
21306
|
}
|
|
@@ -20555,8 +21604,8 @@ let __tla = (async () => {
|
|
|
20555
21604
|
function requireHandler() {
|
|
20556
21605
|
if (hasRequiredHandler) return handler;
|
|
20557
21606
|
hasRequiredHandler = 1;
|
|
20558
|
-
(function(exports) {
|
|
20559
|
-
var __createBinding = handler && handler.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
21607
|
+
(function(exports$1) {
|
|
21608
|
+
var __createBinding = handler && handler.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
20560
21609
|
if (k2 === void 0) k2 = k;
|
|
20561
21610
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20562
21611
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
@@ -20568,21 +21617,21 @@ let __tla = (async () => {
|
|
|
20568
21617
|
};
|
|
20569
21618
|
}
|
|
20570
21619
|
Object.defineProperty(o, k2, desc);
|
|
20571
|
-
} : function(o, m, k, k2) {
|
|
21620
|
+
}) : (function(o, m, k, k2) {
|
|
20572
21621
|
if (k2 === void 0) k2 = k;
|
|
20573
21622
|
o[k2] = m[k];
|
|
20574
|
-
});
|
|
20575
|
-
var __exportStar = handler && handler.__exportStar || function(m,
|
|
20576
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(
|
|
21623
|
+
}));
|
|
21624
|
+
var __exportStar = handler && handler.__exportStar || function(m, exports$12) {
|
|
21625
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$12, p)) __createBinding(exports$12, m, p);
|
|
20577
21626
|
};
|
|
20578
|
-
Object.defineProperty(exports, "__esModule", {
|
|
21627
|
+
Object.defineProperty(exports$1, "__esModule", {
|
|
20579
21628
|
value: true
|
|
20580
21629
|
});
|
|
20581
|
-
__exportStar(requireTypeHandlerBoolean(), exports);
|
|
20582
|
-
__exportStar(requireTypeHandlerDate(), exports);
|
|
20583
|
-
__exportStar(requireTypeHandlerNumberDouble(), exports);
|
|
20584
|
-
__exportStar(requireTypeHandlerNumberInteger(), exports);
|
|
20585
|
-
__exportStar(requireTypeHandlerString(), exports);
|
|
21630
|
+
__exportStar(requireTypeHandlerBoolean(), exports$1);
|
|
21631
|
+
__exportStar(requireTypeHandlerDate(), exports$1);
|
|
21632
|
+
__exportStar(requireTypeHandlerNumberDouble(), exports$1);
|
|
21633
|
+
__exportStar(requireTypeHandlerNumberInteger(), exports$1);
|
|
21634
|
+
__exportStar(requireTypeHandlerString(), exports$1);
|
|
20586
21635
|
})(handler);
|
|
20587
21636
|
return handler;
|
|
20588
21637
|
}
|
|
@@ -20600,8 +21649,8 @@ let __tla = (async () => {
|
|
|
20600
21649
|
function requireRdfLiteral() {
|
|
20601
21650
|
if (hasRequiredRdfLiteral) return rdfLiteral;
|
|
20602
21651
|
hasRequiredRdfLiteral = 1;
|
|
20603
|
-
(function(exports) {
|
|
20604
|
-
var __createBinding = rdfLiteral && rdfLiteral.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
21652
|
+
(function(exports$1) {
|
|
21653
|
+
var __createBinding = rdfLiteral && rdfLiteral.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
20605
21654
|
if (k2 === void 0) k2 = k;
|
|
20606
21655
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20607
21656
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
@@ -20613,27 +21662,27 @@ let __tla = (async () => {
|
|
|
20613
21662
|
};
|
|
20614
21663
|
}
|
|
20615
21664
|
Object.defineProperty(o, k2, desc);
|
|
20616
|
-
} : function(o, m, k, k2) {
|
|
21665
|
+
}) : (function(o, m, k, k2) {
|
|
20617
21666
|
if (k2 === void 0) k2 = k;
|
|
20618
21667
|
o[k2] = m[k];
|
|
20619
|
-
});
|
|
20620
|
-
var __exportStar = rdfLiteral && rdfLiteral.__exportStar || function(m,
|
|
20621
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(
|
|
21668
|
+
}));
|
|
21669
|
+
var __exportStar = rdfLiteral && rdfLiteral.__exportStar || function(m, exports$12) {
|
|
21670
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$12, p)) __createBinding(exports$12, m, p);
|
|
20622
21671
|
};
|
|
20623
|
-
Object.defineProperty(exports, "__esModule", {
|
|
21672
|
+
Object.defineProperty(exports$1, "__esModule", {
|
|
20624
21673
|
value: true
|
|
20625
21674
|
});
|
|
20626
|
-
exports.fromRdf = fromRdf2;
|
|
20627
|
-
exports.toRdf = toRdf2;
|
|
20628
|
-
exports.getTermRaw = getTermRaw;
|
|
20629
|
-
exports.getSupportedRdfDatatypes = getSupportedRdfDatatypes;
|
|
20630
|
-
exports.getSupportedJavaScriptPrimitives = getSupportedJavaScriptPrimitives;
|
|
21675
|
+
exports$1.fromRdf = fromRdf2;
|
|
21676
|
+
exports$1.toRdf = toRdf2;
|
|
21677
|
+
exports$1.getTermRaw = getTermRaw;
|
|
21678
|
+
exports$1.getSupportedRdfDatatypes = getSupportedRdfDatatypes;
|
|
21679
|
+
exports$1.getSupportedJavaScriptPrimitives = getSupportedJavaScriptPrimitives;
|
|
20631
21680
|
const rdf_data_factory_1 = requireRdfDataFactory();
|
|
20632
21681
|
const handler_1 = requireHandler();
|
|
20633
21682
|
const Translator_1 = requireTranslator();
|
|
20634
|
-
__exportStar(requireHandler(), exports);
|
|
20635
|
-
__exportStar(requireITypeHandler(), exports);
|
|
20636
|
-
__exportStar(requireTranslator(), exports);
|
|
21683
|
+
__exportStar(requireHandler(), exports$1);
|
|
21684
|
+
__exportStar(requireITypeHandler(), exports$1);
|
|
21685
|
+
__exportStar(requireTranslator(), exports$1);
|
|
20637
21686
|
const DF = new rdf_data_factory_1.DataFactory();
|
|
20638
21687
|
const translator = new Translator_1.Translator();
|
|
20639
21688
|
translator.registerHandler(new handler_1.TypeHandlerString(), handler_1.TypeHandlerString.TYPES.map((t) => DF.namedNode(t)), [
|
|
@@ -24971,8 +26020,8 @@ let __tla = (async () => {
|
|
|
24971
26020
|
this.pipes = [];
|
|
24972
26021
|
this.flowing = null;
|
|
24973
26022
|
this[kPaused] = null;
|
|
24974
|
-
if (options && options.emitClose === false) this.state &=
|
|
24975
|
-
if (options && options.autoDestroy === false) this.state &=
|
|
26023
|
+
if (options && options.emitClose === false) this.state &= ~kEmitClose;
|
|
26024
|
+
if (options && options.autoDestroy === false) this.state &= ~kAutoDestroy;
|
|
24976
26025
|
this.errored = null;
|
|
24977
26026
|
this.defaultEncoding = options && options.defaultEncoding || "utf8";
|
|
24978
26027
|
this.awaitDrainWriters = null;
|
|
@@ -25053,7 +26102,7 @@ let __tla = (async () => {
|
|
|
25053
26102
|
if (err) {
|
|
25054
26103
|
errorOrDestroy(stream2, err);
|
|
25055
26104
|
} else if (chunk === null) {
|
|
25056
|
-
state2.state &=
|
|
26105
|
+
state2.state &= ~kReading;
|
|
25057
26106
|
onEofChunk(stream2, state2);
|
|
25058
26107
|
} else if ((state2.state & kObjectMode) !== 0 || chunk && chunk.length > 0) {
|
|
25059
26108
|
if (addToFront) {
|
|
@@ -25065,7 +26114,7 @@ let __tla = (async () => {
|
|
|
25065
26114
|
} else if (state2.destroyed || state2.errored) {
|
|
25066
26115
|
return false;
|
|
25067
26116
|
} else {
|
|
25068
|
-
state2.state &=
|
|
26117
|
+
state2.state &= ~kReading;
|
|
25069
26118
|
if (state2.decoder && !encoding) {
|
|
25070
26119
|
chunk = state2.decoder.write(chunk);
|
|
25071
26120
|
if (state2.objectMode || chunk.length !== 0) addChunk(stream2, state2, chunk, false);
|
|
@@ -25075,7 +26124,7 @@ let __tla = (async () => {
|
|
|
25075
26124
|
}
|
|
25076
26125
|
}
|
|
25077
26126
|
} else if (!addToFront) {
|
|
25078
|
-
state2.state &=
|
|
26127
|
+
state2.state &= ~kReading;
|
|
25079
26128
|
maybeReadMore(stream2, state2);
|
|
25080
26129
|
}
|
|
25081
26130
|
return !state2.ended && (state2.length < state2.highWaterMark || state2.length === 0);
|
|
@@ -25150,7 +26199,7 @@ let __tla = (async () => {
|
|
|
25150
26199
|
const state2 = this._readableState;
|
|
25151
26200
|
const nOrig = n;
|
|
25152
26201
|
if (n > state2.highWaterMark) state2.highWaterMark = computeNewHighWaterMark(n);
|
|
25153
|
-
if (n !== 0) state2.state &=
|
|
26202
|
+
if (n !== 0) state2.state &= ~kEmittedReadable;
|
|
25154
26203
|
if (n === 0 && state2.needReadable && ((state2.highWaterMark !== 0 ? state2.length >= state2.highWaterMark : state2.length > 0) || state2.ended)) {
|
|
25155
26204
|
debug2("read: emitReadable", state2.length, state2.ended);
|
|
25156
26205
|
if (state2.length === 0 && state2.ended) endReadable(this);
|
|
@@ -25180,7 +26229,7 @@ let __tla = (async () => {
|
|
|
25180
26229
|
} catch (err) {
|
|
25181
26230
|
errorOrDestroy(this, err);
|
|
25182
26231
|
}
|
|
25183
|
-
state2.state &=
|
|
26232
|
+
state2.state &= ~kSync;
|
|
25184
26233
|
if (!state2.reading) n = howMuchToRead(nOrig, state2);
|
|
25185
26234
|
}
|
|
25186
26235
|
let ret;
|
|
@@ -26556,7 +27605,7 @@ let __tla = (async () => {
|
|
|
26556
27605
|
let { promise, resolve } = createDeferredPromise();
|
|
26557
27606
|
const ac = new AbortController();
|
|
26558
27607
|
const signal = ac.signal;
|
|
26559
|
-
const value = fn(async function* () {
|
|
27608
|
+
const value = fn((async function* () {
|
|
26560
27609
|
while (true) {
|
|
26561
27610
|
const _promise = promise;
|
|
26562
27611
|
promise = null;
|
|
@@ -26569,7 +27618,7 @@ let __tla = (async () => {
|
|
|
26569
27618
|
({ promise, resolve } = createDeferredPromise());
|
|
26570
27619
|
yield chunk;
|
|
26571
27620
|
}
|
|
26572
|
-
}(), {
|
|
27621
|
+
})(), {
|
|
26573
27622
|
signal
|
|
26574
27623
|
});
|
|
26575
27624
|
return {
|
|
@@ -28112,6 +29161,25 @@ let __tla = (async () => {
|
|
|
28112
29161
|
constructor(dataFetcher) {
|
|
28113
29162
|
this.dataFetcher = dataFetcher;
|
|
28114
29163
|
}
|
|
29164
|
+
getGlobalIndexLoader() {
|
|
29165
|
+
return globalThis.SEMANTIZER_INDEX_LOADER;
|
|
29166
|
+
}
|
|
29167
|
+
getGlobalQuadStreamLoader() {
|
|
29168
|
+
return globalThis.SEMANTIZER_QUAD_STREAM_LOADER;
|
|
29169
|
+
}
|
|
29170
|
+
buildHttpHeaders(dspHeaders) {
|
|
29171
|
+
const headers = {};
|
|
29172
|
+
if (dspHeaders == null ? void 0 : dspHeaders.agreementId) {
|
|
29173
|
+
headers["DSP-AGREEMENT-ID"] = dspHeaders.agreementId;
|
|
29174
|
+
}
|
|
29175
|
+
if (dspHeaders == null ? void 0 : dspHeaders.participantId) {
|
|
29176
|
+
headers["DSP-PARTICIPANT-ID"] = dspHeaders.participantId;
|
|
29177
|
+
}
|
|
29178
|
+
if (dspHeaders == null ? void 0 : dspHeaders.consumerConnectorUrl) {
|
|
29179
|
+
headers["DSP-CONSUMER-CONNECTORURL"] = dspHeaders.consumerConnectorUrl;
|
|
29180
|
+
}
|
|
29181
|
+
return headers;
|
|
29182
|
+
}
|
|
28115
29183
|
isValidUrl(url2) {
|
|
28116
29184
|
if (!url2 || typeof url2 !== "string") {
|
|
28117
29185
|
return false;
|
|
@@ -28126,19 +29194,39 @@ let __tla = (async () => {
|
|
|
28126
29194
|
hasValidIndexUrl(options) {
|
|
28127
29195
|
return this.isValidUrl(options.dataSrcIndex ?? "") || this.isValidUrl(options.dataSrcProfile ?? "");
|
|
28128
29196
|
}
|
|
29197
|
+
hasValidIndexSource(options) {
|
|
29198
|
+
return this.hasValidIndexUrl(options) || options.indexData !== void 0 && options.indexData !== null;
|
|
29199
|
+
}
|
|
29200
|
+
async buildIndexFromJsonLd(jsonLdData) {
|
|
29201
|
+
const jsonString = JSON.stringify(jsonLdData);
|
|
29202
|
+
const base64Data = btoa(unescape(encodeURIComponent(jsonString)));
|
|
29203
|
+
const dataUrl = `data:application/ld+json;base64,${base64Data}`;
|
|
29204
|
+
const index = await SEMANTIZER.load(dataUrl, indexFactory);
|
|
29205
|
+
return index;
|
|
29206
|
+
}
|
|
28129
29207
|
async query(options) {
|
|
28130
|
-
|
|
28131
|
-
|
|
28132
|
-
|
|
28133
|
-
|
|
28134
|
-
|
|
28135
|
-
|
|
28136
|
-
|
|
28137
|
-
|
|
28138
|
-
|
|
28139
|
-
if (!
|
|
28140
|
-
|
|
28141
|
-
|
|
29208
|
+
const dspHttpHeaders = this.buildHttpHeaders(options.dspHeaders);
|
|
29209
|
+
const hasDspHeaders = Object.keys(dspHttpHeaders).length > 0;
|
|
29210
|
+
if (hasDspHeaders) {
|
|
29211
|
+
console.log("[SolidIndexingSearchProvider] Setting DSP headers on global loaders:", dspHttpHeaders);
|
|
29212
|
+
this.getGlobalIndexLoader().setCustomHeaders(dspHttpHeaders);
|
|
29213
|
+
this.getGlobalQuadStreamLoader().setCustomHeaders(dspHttpHeaders);
|
|
29214
|
+
}
|
|
29215
|
+
let indexUri = null;
|
|
29216
|
+
const hasDirectData = options.indexData !== void 0 && options.indexData !== null;
|
|
29217
|
+
if (!hasDirectData) {
|
|
29218
|
+
if (options.dataSrcIndex) {
|
|
29219
|
+
indexUri = options.dataSrcIndex;
|
|
29220
|
+
} else if (options.dataSrcProfile) {
|
|
29221
|
+
indexUri = await this.discoverIndexFromProfile(options.dataSrcProfile);
|
|
29222
|
+
} else {
|
|
29223
|
+
console.warn("Either dataSrcIndex, dataSrcProfile, or indexData must be specified");
|
|
29224
|
+
return [];
|
|
29225
|
+
}
|
|
29226
|
+
if (!this.isValidUrl(indexUri)) {
|
|
29227
|
+
console.warn("\u26A0\uFE0F [SolidIndexingSearchProvider.queryIndex] Invalid index URI, returning empty results");
|
|
29228
|
+
return [];
|
|
29229
|
+
}
|
|
28142
29230
|
}
|
|
28143
29231
|
const filterFields = Object.entries(options.filterValues);
|
|
28144
29232
|
const firstField = filterFields[0];
|
|
@@ -28167,10 +29255,28 @@ let __tla = (async () => {
|
|
|
28167
29255
|
subIndexShapeGraph.addAll(parser.parse(subIndexShape));
|
|
28168
29256
|
const shaclValidator = new ValidatorImpl();
|
|
28169
29257
|
const entryTransformer = new EntryStreamTransformerDefaultImpl(SEMANTIZER);
|
|
29258
|
+
console.log("[SolidIndexingSearchProvider] Generated shapes for query:");
|
|
29259
|
+
console.log("[SolidIndexingSearchProvider] - targetShape:", targetShape);
|
|
29260
|
+
console.log("[SolidIndexingSearchProvider] - subIndexShape:", subIndexShape);
|
|
29261
|
+
console.log("[SolidIndexingSearchProvider] - finalShape:", finalShape);
|
|
28170
29262
|
const finalIndexStrategy = new IndexStrategyFinalShapeDefaultImpl(finalIndexShapeGraph, subIndexShapeGraph, shaclValidator, entryTransformer);
|
|
28171
29263
|
const shaclStrategy = new IndexQueryingStrategyShaclUsingFinalIndex(targetShapeGraph, finalIndexStrategy, shaclValidator, entryTransformer);
|
|
28172
|
-
|
|
29264
|
+
let index;
|
|
29265
|
+
if (hasDirectData && options.indexData) {
|
|
29266
|
+
index = await this.buildIndexFromJsonLd(options.indexData);
|
|
29267
|
+
} else if (indexUri) {
|
|
29268
|
+
index = await SEMANTIZER.load(indexUri, indexFactory);
|
|
29269
|
+
} else {
|
|
29270
|
+
console.warn("\u26A0\uFE0F [SolidIndexingSearchProvider.queryIndex] No index source available");
|
|
29271
|
+
return [];
|
|
29272
|
+
}
|
|
29273
|
+
console.log("[SolidIndexingSearchProvider] Starting index query...");
|
|
29274
|
+
console.log("[SolidIndexingSearchProvider] Index loaded, starting query with shaclStrategy");
|
|
28173
29275
|
const resultStream = index.mixins.index.query(shaclStrategy);
|
|
29276
|
+
resultStream.on("error", (err) => {
|
|
29277
|
+
console.error("[SolidIndexingSearchProvider] Stream error:", err);
|
|
29278
|
+
});
|
|
29279
|
+
const skipResourceFetch = options.skipResourceFetch === true;
|
|
28174
29280
|
return new Promise((resolve, reject) => {
|
|
28175
29281
|
const resultIds = [];
|
|
28176
29282
|
const resources = [];
|
|
@@ -28178,15 +29284,24 @@ let __tla = (async () => {
|
|
|
28178
29284
|
let streamEnded = false;
|
|
28179
29285
|
const checkComplete = () => {
|
|
28180
29286
|
if (streamEnded && pendingFetches === 0) {
|
|
28181
|
-
|
|
29287
|
+
if (skipResourceFetch) {
|
|
29288
|
+
resolve(resultIds.map((id) => ({
|
|
29289
|
+
"@id": id
|
|
29290
|
+
})));
|
|
29291
|
+
} else {
|
|
29292
|
+
resolve(resources);
|
|
29293
|
+
}
|
|
28182
29294
|
}
|
|
28183
29295
|
};
|
|
28184
29296
|
resultStream.on("data", async (result) => {
|
|
28185
29297
|
if (result.value) {
|
|
28186
29298
|
resultIds.push(result.value);
|
|
29299
|
+
if (skipResourceFetch) {
|
|
29300
|
+
return;
|
|
29301
|
+
}
|
|
28187
29302
|
pendingFetches++;
|
|
28188
29303
|
try {
|
|
28189
|
-
const resource = await this.dataFetcher(result.value);
|
|
29304
|
+
const resource = await this.dataFetcher(result.value, hasDspHeaders ? dspHttpHeaders : void 0);
|
|
28190
29305
|
if (resource) {
|
|
28191
29306
|
resources.push(resource);
|
|
28192
29307
|
} else {
|
|
@@ -28206,6 +29321,10 @@ let __tla = (async () => {
|
|
|
28206
29321
|
});
|
|
28207
29322
|
resultStream.on("end", () => {
|
|
28208
29323
|
streamEnded = true;
|
|
29324
|
+
if (hasDspHeaders) {
|
|
29325
|
+
this.getGlobalIndexLoader().clearCustomHeaders();
|
|
29326
|
+
this.getGlobalQuadStreamLoader().clearCustomHeaders();
|
|
29327
|
+
}
|
|
28209
29328
|
checkComplete();
|
|
28210
29329
|
});
|
|
28211
29330
|
});
|
|
@@ -28226,7 +29345,8 @@ let __tla = (async () => {
|
|
|
28226
29345
|
filterValues: {
|
|
28227
29346
|
[propertyName]: filterValue
|
|
28228
29347
|
},
|
|
28229
|
-
exactMatchMapping: options.exactMatchMapping
|
|
29348
|
+
exactMatchMapping: options.exactMatchMapping,
|
|
29349
|
+
dspHeaders: options.dspHeaders
|
|
28230
29350
|
};
|
|
28231
29351
|
return this.query(queryOptions);
|
|
28232
29352
|
});
|
|
@@ -28467,9 +29587,9 @@ sh:property [
|
|
|
28467
29587
|
__publicField(this, "loadingList");
|
|
28468
29588
|
__publicField(this, "headers");
|
|
28469
29589
|
__publicField(this, "fetch");
|
|
28470
|
-
__publicField(this, "session");
|
|
28471
29590
|
__publicField(this, "contextParser");
|
|
28472
29591
|
__publicField(this, "searchProvider");
|
|
29592
|
+
__publicField(this, "cleanupAuth");
|
|
28473
29593
|
__publicField(this, "resolveResource", (id, resolve) => {
|
|
28474
29594
|
const handler2 = (event) => {
|
|
28475
29595
|
if (event.detail.id === id) {
|
|
@@ -28483,6 +29603,11 @@ sh:property [
|
|
|
28483
29603
|
};
|
|
28484
29604
|
return handler2;
|
|
28485
29605
|
});
|
|
29606
|
+
__publicField(this, "resolveFetch", (event) => {
|
|
29607
|
+
if (event.detail.fetch) {
|
|
29608
|
+
this.fetch = event.detail.fetch.bind ? event.detail.fetch.bind(globalThis) : event.detail.fetch;
|
|
29609
|
+
}
|
|
29610
|
+
});
|
|
28486
29611
|
this.storeOptions = storeOptions;
|
|
28487
29612
|
this.cache = this.storeOptions.cacheManager ?? new InMemoryCacheManager();
|
|
28488
29613
|
this.subscriptionIndex = /* @__PURE__ */ new Map();
|
|
@@ -28493,15 +29618,38 @@ sh:property [
|
|
|
28493
29618
|
"Content-Type": "application/ld+json",
|
|
28494
29619
|
"Cache-Control": "must-revalidate"
|
|
28495
29620
|
};
|
|
28496
|
-
this.fetch = this.storeOptions.fetchMethod;
|
|
28497
|
-
this.session = this.storeOptions.session;
|
|
28498
29621
|
this.contextParser = new jsonldContextParserExports.ContextParser();
|
|
28499
|
-
|
|
29622
|
+
const headersAwareDataFetcher = (id, customHeaders) => {
|
|
29623
|
+
return this.getData(id, void 0, void 0, void 0, false, void 0, void 0, customHeaders);
|
|
29624
|
+
};
|
|
29625
|
+
this.searchProvider = new SolidIndexingSearchProvider(headersAwareDataFetcher);
|
|
29626
|
+
if (this.storeOptions.fetchMethod) {
|
|
29627
|
+
this.fetch = this.storeOptions.fetchMethod.bind(globalThis);
|
|
29628
|
+
} else {
|
|
29629
|
+
const authFetch = AuthFetchResolver.getAuthFetch();
|
|
29630
|
+
this.fetch = authFetch.bind ? authFetch.bind(globalThis) : authFetch;
|
|
29631
|
+
this.cleanupAuth = AuthFetchResolver.onAuthActivated(this.resolveFetch.bind(this));
|
|
29632
|
+
}
|
|
29633
|
+
if (!this.fetch) {
|
|
29634
|
+
this.fetch = fetch;
|
|
29635
|
+
}
|
|
29636
|
+
const event = new CustomEvent("sib-core:loaded", {
|
|
29637
|
+
bubbles: true,
|
|
29638
|
+
composed: true,
|
|
29639
|
+
detail: {
|
|
29640
|
+
store: this
|
|
29641
|
+
}
|
|
29642
|
+
});
|
|
29643
|
+
window.dispatchEvent(event);
|
|
28500
29644
|
}
|
|
28501
29645
|
async initGetter() {
|
|
28502
|
-
const { CustomGetter } = await import("./custom-getter-
|
|
29646
|
+
const { CustomGetter } = await import("./custom-getter-BUGtV5pI.js");
|
|
28503
29647
|
return CustomGetter;
|
|
28504
29648
|
}
|
|
29649
|
+
disconnectedCallback() {
|
|
29650
|
+
var _a2;
|
|
29651
|
+
(_a2 = this.cleanupAuth) == null ? void 0 : _a2.call(this);
|
|
29652
|
+
}
|
|
28505
29653
|
async getData(id, context2, parentId, localData, forceFetch, serverPagination, serverSearch, headers, bypassLoadingList) {
|
|
28506
29654
|
var _a2;
|
|
28507
29655
|
let key = id;
|
|
@@ -28567,17 +29715,7 @@ sh:property [
|
|
|
28567
29715
|
if (!this.fetch) {
|
|
28568
29716
|
console.warn("No fetch method available");
|
|
28569
29717
|
}
|
|
28570
|
-
|
|
28571
|
-
if (this.session) authenticated = await this.session;
|
|
28572
|
-
if (this.fetch && authenticated) {
|
|
28573
|
-
return this.fetch.then((fn) => {
|
|
28574
|
-
return fn(iri, options);
|
|
28575
|
-
});
|
|
28576
|
-
}
|
|
28577
|
-
if (options.headers) {
|
|
28578
|
-
options.headers = this._convertHeaders(options.headers);
|
|
28579
|
-
}
|
|
28580
|
-
return fetch(iri, options).then((response) => response);
|
|
29718
|
+
return await this.fetch(iri, options);
|
|
28581
29719
|
}
|
|
28582
29720
|
async fetchData(id, context2 = null, parentId = "", serverPagination, serverSearch, headers) {
|
|
28583
29721
|
let iri = this._getAbsoluteIri(id, context2, parentId);
|
|
@@ -28820,19 +29958,19 @@ sh:property [
|
|
|
28820
29958
|
]);
|
|
28821
29959
|
}
|
|
28822
29960
|
_getAbsoluteIri(id, context2, parentId) {
|
|
29961
|
+
var _a2;
|
|
28823
29962
|
let iri = normalizeContext(context2, base_context).expandTerm(id);
|
|
28824
29963
|
if (!iri) return "";
|
|
28825
|
-
|
|
28826
|
-
const
|
|
28827
|
-
|
|
28828
|
-
|
|
28829
|
-
iri = new URL(iri,
|
|
29964
|
+
try {
|
|
29965
|
+
const baseHref = ((_a2 = document == null ? void 0 : document.location) == null ? void 0 : _a2.href) || "";
|
|
29966
|
+
const canUseParent = parentId && !parentId.startsWith("store://local");
|
|
29967
|
+
const base = canUseParent ? new URL(parentId, baseHref).href : baseHref;
|
|
29968
|
+
iri = new URL(iri, base).href;
|
|
29969
|
+
} catch (err) {
|
|
29970
|
+
console.log("[LDPStore _getAbsoluteIri()]", err);
|
|
28830
29971
|
}
|
|
28831
29972
|
return iri;
|
|
28832
29973
|
}
|
|
28833
|
-
async getSession() {
|
|
28834
|
-
return await this.session;
|
|
28835
|
-
}
|
|
28836
29974
|
_getLanguage() {
|
|
28837
29975
|
return localStorage.getItem("language") || window.navigator.language.slice(0, 2);
|
|
28838
29976
|
}
|
|
@@ -28850,9 +29988,11 @@ sh:property [
|
|
|
28850
29988
|
if (window.sibStore) {
|
|
28851
29989
|
return window.sibStore;
|
|
28852
29990
|
}
|
|
28853
|
-
const
|
|
28854
|
-
|
|
28855
|
-
|
|
29991
|
+
const store = new LdpStore({
|
|
29992
|
+
..._cfg == null ? void 0 : _cfg.options
|
|
29993
|
+
});
|
|
29994
|
+
window.sibStore = store;
|
|
29995
|
+
return store;
|
|
28856
29996
|
}
|
|
28857
29997
|
const _LdpStoreAdapter = class _LdpStoreAdapter {
|
|
28858
29998
|
constructor() {
|
|
@@ -28866,11 +30006,11 @@ sh:property [
|
|
|
28866
30006
|
};
|
|
28867
30007
|
__publicField(_LdpStoreAdapter, "store");
|
|
28868
30008
|
let LdpStoreAdapter = _LdpStoreAdapter;
|
|
28869
|
-
hasQueryIndex = function(
|
|
28870
|
-
return "queryIndex" in
|
|
30009
|
+
hasQueryIndex = function(store) {
|
|
30010
|
+
return "queryIndex" in store && typeof store.queryIndex === "function";
|
|
28871
30011
|
};
|
|
28872
|
-
hasSetLocalData = function(
|
|
28873
|
-
return "setLocalData" in
|
|
30012
|
+
hasSetLocalData = function(store) {
|
|
30013
|
+
return "setLocalData" in store && typeof store.setLocalData === "function";
|
|
28874
30014
|
};
|
|
28875
30015
|
StoreType = ((StoreType2) => {
|
|
28876
30016
|
StoreType2["LDP"] = "ldp";
|
|
@@ -28895,37 +30035,106 @@ sh:property [
|
|
|
28895
30035
|
StoreFactory.register(StoreType.FederatedCatalogue, FederatedCatalogueStoreAdapter);
|
|
28896
30036
|
StoreFactory.register(StoreType.DataspaceConnector, DataspaceConnectorStoreAdapter);
|
|
28897
30037
|
StoreService = (_a = class {
|
|
28898
|
-
static
|
|
28899
|
-
|
|
28900
|
-
|
|
28901
|
-
|
|
30038
|
+
static addStore(name, config) {
|
|
30039
|
+
var _a2;
|
|
30040
|
+
const trimmedName = name.trim();
|
|
30041
|
+
if (!trimmedName) {
|
|
30042
|
+
throw new Error("[StoreService] Store name cannot be empty.");
|
|
30043
|
+
}
|
|
30044
|
+
if (!config) {
|
|
30045
|
+
throw new Error("[StoreService] Store configuration is required.");
|
|
30046
|
+
}
|
|
30047
|
+
console.log(`\u{1F527} [StoreService.addStore] Adding store "${trimmedName}":`, {
|
|
30048
|
+
storeType: config.type,
|
|
30049
|
+
endpoint: config.endpoint,
|
|
30050
|
+
alreadyExists: StoreService.stores.has(trimmedName)
|
|
30051
|
+
});
|
|
30052
|
+
if (StoreService.stores.has(trimmedName)) {
|
|
30053
|
+
StoreService.logWarning(`Store with name "${trimmedName}" already exists. Overwriting.`);
|
|
30054
|
+
}
|
|
30055
|
+
const store = StoreFactory.create(config);
|
|
30056
|
+
console.log(`\u2705 [StoreService.addStore] Created store for "${trimmedName}":`, {
|
|
30057
|
+
storeType: typeof store,
|
|
30058
|
+
storeConfig: store.config,
|
|
30059
|
+
storeEndpoint: (_a2 = store.config) == null ? void 0 : _a2.endpoint
|
|
30060
|
+
});
|
|
30061
|
+
StoreService.stores.set(trimmedName, {
|
|
30062
|
+
store,
|
|
30063
|
+
config
|
|
30064
|
+
});
|
|
30065
|
+
return store;
|
|
30066
|
+
}
|
|
30067
|
+
static getStore(name) {
|
|
30068
|
+
var _a2;
|
|
30069
|
+
const storeName = StoreService.resolveStoreName(name);
|
|
30070
|
+
if (!storeName) {
|
|
30071
|
+
return null;
|
|
28902
30072
|
}
|
|
28903
|
-
|
|
30073
|
+
const instance = StoreService.stores.get(storeName);
|
|
30074
|
+
if (!instance) {
|
|
30075
|
+
if (storeName === StoreService.defaultStoreName) {
|
|
30076
|
+
return StoreService.fallbackInitIfNeeded();
|
|
30077
|
+
}
|
|
30078
|
+
StoreService.logWarning(`Store with name "${storeName}" not found.`);
|
|
30079
|
+
return null;
|
|
30080
|
+
}
|
|
30081
|
+
console.log(`\u{1F4E6} [StoreService.getStore] Retrieving store "${storeName}":`, {
|
|
30082
|
+
found: !!instance,
|
|
30083
|
+
storeEndpoint: (_a2 = instance.store.config) == null ? void 0 : _a2.endpoint,
|
|
30084
|
+
configEndpoint: instance.config.endpoint
|
|
30085
|
+
});
|
|
30086
|
+
return instance.store;
|
|
30087
|
+
}
|
|
30088
|
+
static setDefaultStore(name) {
|
|
30089
|
+
if (!(name == null ? void 0 : name.trim())) {
|
|
30090
|
+
throw new Error("[StoreService] Store name cannot be empty.");
|
|
30091
|
+
}
|
|
30092
|
+
if (!StoreService.stores.has(name)) {
|
|
30093
|
+
throw new Error(`[StoreService] Store with name "${name}" not found.`);
|
|
30094
|
+
}
|
|
30095
|
+
StoreService.defaultStoreName = name;
|
|
30096
|
+
}
|
|
30097
|
+
static init(config) {
|
|
30098
|
+
const storeConfig = config ?? {
|
|
28904
30099
|
type: StoreType.LDP
|
|
28905
30100
|
};
|
|
28906
|
-
|
|
28907
|
-
StoreService.
|
|
30101
|
+
StoreService.addStore(StoreService.defaultStoreName, storeConfig);
|
|
30102
|
+
StoreService.setDefaultStore(StoreService.defaultStoreName);
|
|
28908
30103
|
}
|
|
28909
30104
|
static fallbackInitIfNeeded() {
|
|
28910
|
-
|
|
30105
|
+
let instance = StoreService.stores.get(StoreService.defaultStoreName);
|
|
30106
|
+
if (!instance) {
|
|
28911
30107
|
const defaultConfig = {
|
|
28912
30108
|
type: StoreType.LDP
|
|
28913
30109
|
};
|
|
28914
|
-
const
|
|
28915
|
-
|
|
28916
|
-
|
|
30110
|
+
const store = StoreFactory.create(defaultConfig);
|
|
30111
|
+
instance = {
|
|
30112
|
+
store,
|
|
30113
|
+
config: defaultConfig
|
|
30114
|
+
};
|
|
30115
|
+
StoreService.stores.set(StoreService.defaultStoreName, instance);
|
|
28917
30116
|
}
|
|
28918
|
-
return
|
|
30117
|
+
return instance.store;
|
|
28919
30118
|
}
|
|
28920
30119
|
static getInstance() {
|
|
28921
|
-
|
|
28922
|
-
|
|
28923
|
-
|
|
30120
|
+
const store = StoreService.getStore(StoreService.defaultStoreName);
|
|
30121
|
+
if (!store) {
|
|
30122
|
+
throw new Error("[StoreService] Failed to get or create default store instance.");
|
|
30123
|
+
}
|
|
30124
|
+
return store;
|
|
30125
|
+
}
|
|
30126
|
+
static getConfig(name) {
|
|
30127
|
+
const storeName = StoreService.resolveStoreName(name);
|
|
30128
|
+
const instance = StoreService.stores.get(storeName);
|
|
30129
|
+
return (instance == null ? void 0 : instance.config) || null;
|
|
30130
|
+
}
|
|
30131
|
+
static resolveStoreName(name) {
|
|
30132
|
+
return (name == null ? void 0 : name.trim()) || StoreService.defaultStoreName;
|
|
28924
30133
|
}
|
|
28925
|
-
static
|
|
28926
|
-
|
|
30134
|
+
static logWarning(message) {
|
|
30135
|
+
console.warn(`[StoreService] ${message}`);
|
|
28927
30136
|
}
|
|
28928
|
-
}, __publicField(_a, "
|
|
30137
|
+
}, __publicField(_a, "stores", /* @__PURE__ */ new Map()), __publicField(_a, "defaultStoreName", "default"), _a);
|
|
28929
30138
|
var __awaiter$3 = function(thisArg, _arguments, P, generator) {
|
|
28930
30139
|
function adopt(value) {
|
|
28931
30140
|
return value instanceof P ? value : new P(function(resolve) {
|
|
@@ -29156,8 +30365,8 @@ sh:property [
|
|
|
29156
30365
|
setLoader(loader) {
|
|
29157
30366
|
this._loader = loader;
|
|
29158
30367
|
}
|
|
29159
|
-
setLoaderQuadStream(
|
|
29160
|
-
this._loaderQuadStream =
|
|
30368
|
+
setLoaderQuadStream(loaderQuadStream2) {
|
|
30369
|
+
this._loaderQuadStream = loaderQuadStream2;
|
|
29161
30370
|
}
|
|
29162
30371
|
setRdfDataModelFactory(dataFactory) {
|
|
29163
30372
|
this._rdfModelDataFactory = dataFactory;
|
|
@@ -32742,8 +33951,8 @@ sh:property [
|
|
|
32742
33951
|
function requireJsonldStreamingParser() {
|
|
32743
33952
|
if (hasRequiredJsonldStreamingParser) return jsonldStreamingParser;
|
|
32744
33953
|
hasRequiredJsonldStreamingParser = 1;
|
|
32745
|
-
(function(exports) {
|
|
32746
|
-
var __createBinding = jsonldStreamingParser && jsonldStreamingParser.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
33954
|
+
(function(exports$1) {
|
|
33955
|
+
var __createBinding = jsonldStreamingParser && jsonldStreamingParser.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
32747
33956
|
if (k2 === void 0) k2 = k;
|
|
32748
33957
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32749
33958
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
@@ -32755,17 +33964,17 @@ sh:property [
|
|
|
32755
33964
|
};
|
|
32756
33965
|
}
|
|
32757
33966
|
Object.defineProperty(o, k2, desc);
|
|
32758
|
-
} : function(o, m, k, k2) {
|
|
33967
|
+
}) : (function(o, m, k, k2) {
|
|
32759
33968
|
if (k2 === void 0) k2 = k;
|
|
32760
33969
|
o[k2] = m[k];
|
|
32761
|
-
});
|
|
32762
|
-
var __exportStar = jsonldStreamingParser && jsonldStreamingParser.__exportStar || function(m,
|
|
32763
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(
|
|
33970
|
+
}));
|
|
33971
|
+
var __exportStar = jsonldStreamingParser && jsonldStreamingParser.__exportStar || function(m, exports$12) {
|
|
33972
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$12, p)) __createBinding(exports$12, m, p);
|
|
32764
33973
|
};
|
|
32765
|
-
Object.defineProperty(exports, "__esModule", {
|
|
33974
|
+
Object.defineProperty(exports$1, "__esModule", {
|
|
32766
33975
|
value: true
|
|
32767
33976
|
});
|
|
32768
|
-
__exportStar(requireJsonLdParser(), exports);
|
|
33977
|
+
__exportStar(requireJsonLdParser(), exports$1);
|
|
32769
33978
|
})(jsonldStreamingParser);
|
|
32770
33979
|
return jsonldStreamingParser;
|
|
32771
33980
|
}
|
|
@@ -32853,17 +34062,35 @@ sh:property [
|
|
|
32853
34062
|
this.getSemantizer().logError(this, message, options);
|
|
32854
34063
|
}
|
|
32855
34064
|
}
|
|
32856
|
-
const store$1 = StoreService.getInstance();
|
|
32857
34065
|
class LoaderQuadStreamCore extends LoaderBase {
|
|
34066
|
+
constructor() {
|
|
34067
|
+
super(...arguments);
|
|
34068
|
+
__publicField(this, "customHeaders", {});
|
|
34069
|
+
}
|
|
32858
34070
|
getLoggingComponent() {
|
|
32859
34071
|
return {
|
|
32860
34072
|
type: "PACKAGE",
|
|
32861
34073
|
name: "loader-quad-stream-core"
|
|
32862
34074
|
};
|
|
32863
34075
|
}
|
|
34076
|
+
setCustomHeaders(headers) {
|
|
34077
|
+
console.log("[LoaderQuadStreamCore] setCustomHeaders called:", headers);
|
|
34078
|
+
this.customHeaders = headers;
|
|
34079
|
+
}
|
|
34080
|
+
clearCustomHeaders() {
|
|
34081
|
+
console.log("[LoaderQuadStreamCore] clearCustomHeaders called");
|
|
34082
|
+
this.customHeaders = {};
|
|
34083
|
+
}
|
|
32864
34084
|
async load(uri, _otherFetch) {
|
|
32865
|
-
const
|
|
32866
|
-
const
|
|
34085
|
+
const store = StoreService.getInstance();
|
|
34086
|
+
const headers = {
|
|
34087
|
+
...store.headers,
|
|
34088
|
+
...this.customHeaders
|
|
34089
|
+
};
|
|
34090
|
+
console.log("[LoaderQuadStreamCore] Loading URI:", uri);
|
|
34091
|
+
console.log("[LoaderQuadStreamCore] Custom headers:", this.customHeaders);
|
|
34092
|
+
console.log("[LoaderQuadStreamCore] Final headers:", headers);
|
|
34093
|
+
const response = await store.fetchAuthn(uri, {
|
|
32867
34094
|
method: "GET",
|
|
32868
34095
|
headers,
|
|
32869
34096
|
credentials: "include"
|
|
@@ -32883,16 +34110,34 @@ sh:property [
|
|
|
32883
34110
|
return quads;
|
|
32884
34111
|
}
|
|
32885
34112
|
}
|
|
32886
|
-
const store = StoreService.getInstance();
|
|
32887
34113
|
class IndexLoader extends LoaderBase {
|
|
34114
|
+
constructor() {
|
|
34115
|
+
super(...arguments);
|
|
34116
|
+
__publicField(this, "customHeaders", {});
|
|
34117
|
+
}
|
|
32888
34118
|
getLoggingComponent() {
|
|
32889
34119
|
return {
|
|
32890
34120
|
type: "PACKAGE",
|
|
32891
34121
|
name: "loader-quad-stream-core"
|
|
32892
34122
|
};
|
|
32893
34123
|
}
|
|
34124
|
+
setCustomHeaders(headers) {
|
|
34125
|
+
console.log("[IndexLoader] setCustomHeaders called:", headers);
|
|
34126
|
+
this.customHeaders = headers;
|
|
34127
|
+
}
|
|
34128
|
+
clearCustomHeaders() {
|
|
34129
|
+
console.log("[IndexLoader] clearCustomHeaders called");
|
|
34130
|
+
this.customHeaders = {};
|
|
34131
|
+
}
|
|
32894
34132
|
async load(uri) {
|
|
32895
|
-
const
|
|
34133
|
+
const store = StoreService.getInstance();
|
|
34134
|
+
const headers = {
|
|
34135
|
+
...store.headers,
|
|
34136
|
+
...this.customHeaders
|
|
34137
|
+
};
|
|
34138
|
+
console.log("[IndexLoader] Loading URI:", uri);
|
|
34139
|
+
console.log("[IndexLoader] Custom headers:", this.customHeaders);
|
|
34140
|
+
console.log("[IndexLoader] Final headers:", headers);
|
|
32896
34141
|
const response = await store.fetchAuthn(uri, {
|
|
32897
34142
|
method: "GET",
|
|
32898
34143
|
headers,
|
|
@@ -32929,19 +34174,37 @@ sh:property [
|
|
|
32929
34174
|
return quadsRes;
|
|
32930
34175
|
}
|
|
32931
34176
|
}
|
|
34177
|
+
const indexLoader = new IndexLoader();
|
|
34178
|
+
const loaderQuadStream = new LoaderQuadStreamCore();
|
|
32932
34179
|
const semantizer$1 = new SemantizerImpl(new ConfigurationImpl({
|
|
32933
|
-
loader:
|
|
32934
|
-
loaderQuadStream
|
|
34180
|
+
loader: indexLoader,
|
|
34181
|
+
loaderQuadStream,
|
|
32935
34182
|
datasetImpl: DatasetMixin(DatasetCoreRdfjsImpl),
|
|
32936
34183
|
rdfModelDataFactory: factory$3,
|
|
32937
34184
|
mixinFactoryImpl: MixinFactoryImpl,
|
|
32938
34185
|
datasetBaseFactoryImpl: DatasetBaseFactoryImpl
|
|
32939
34186
|
}));
|
|
32940
|
-
|
|
32941
|
-
|
|
32942
|
-
|
|
32943
|
-
|
|
32944
|
-
|
|
34187
|
+
if (!globalThis.SEMANTIZER) {
|
|
34188
|
+
Object.defineProperty(globalThis, "SEMANTIZER", {
|
|
34189
|
+
value: semantizer$1,
|
|
34190
|
+
writable: false,
|
|
34191
|
+
configurable: true
|
|
34192
|
+
});
|
|
34193
|
+
}
|
|
34194
|
+
if (!globalThis.SEMANTIZER_INDEX_LOADER) {
|
|
34195
|
+
Object.defineProperty(globalThis, "SEMANTIZER_INDEX_LOADER", {
|
|
34196
|
+
value: indexLoader,
|
|
34197
|
+
writable: false,
|
|
34198
|
+
configurable: true
|
|
34199
|
+
});
|
|
34200
|
+
}
|
|
34201
|
+
if (!globalThis.SEMANTIZER_QUAD_STREAM_LOADER) {
|
|
34202
|
+
Object.defineProperty(globalThis, "SEMANTIZER_QUAD_STREAM_LOADER", {
|
|
34203
|
+
value: loaderQuadStream,
|
|
34204
|
+
writable: false,
|
|
34205
|
+
configurable: true
|
|
34206
|
+
});
|
|
34207
|
+
}
|
|
32945
34208
|
if (typeof window !== "undefined") {
|
|
32946
34209
|
if (typeof window.process === "undefined") {
|
|
32947
34210
|
window.process = {
|
|
@@ -32969,6 +34232,8 @@ sh:property [
|
|
|
32969
34232
|
semantizer = globalThis.SEMANTIZER;
|
|
32970
34233
|
})();
|
|
32971
34234
|
export {
|
|
34235
|
+
AuthFetchResolver as A,
|
|
34236
|
+
DEFAULT_AUTH_SELECTORS as D,
|
|
32972
34237
|
StoreService as S,
|
|
32973
34238
|
__tla,
|
|
32974
34239
|
formatAttributesToServerSearchOptions as a,
|