@startinblox/core 2.0.6-beta.10 → 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.
|
@@ -2,7 +2,7 @@ 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
4
|
import { q as mergeContexts, o as getRawContext, n as normalizeContext } from "./helpers-DtCY-jxq.js";
|
|
5
|
-
import { S as StoreService } from "./store-
|
|
5
|
+
import { S as StoreService } from "./store-BPx-Ghbc.js";
|
|
6
6
|
const store = StoreService.getInstance();
|
|
7
7
|
class CustomGetter {
|
|
8
8
|
// search attributes to give to server
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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 { g as getDefaultExportFromCjs, S as StoreService, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as StoreType, d as StoreFactory, h as hasSetLocalData, e as hasQueryIndex, __tla as __tla_0 } from "./store-
|
|
4
|
+
import { g as getDefaultExportFromCjs, S as StoreService, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as StoreType, d as StoreFactory, h as hasSetLocalData, e as hasQueryIndex, __tla as __tla_0 } from "./store-BPx-Ghbc.js";
|
|
5
5
|
import { d as defineComponent, n as normalizeContext, u as uniqID, f as fuzzyCompare, a as asyncQuerySelector, i as importInlineCSS, b as importCSS, c as doesResourceContainList, e as findClosingBracketMatchIndex, p as parseFieldsString, g as evalTemplateString, h as compare, j as generalComparator, t as transformArrayToContainer, s as setDeepProperty } from "./helpers-DtCY-jxq.js";
|
|
6
|
-
import { __tla as __tla_1 } from "./store-
|
|
7
|
-
import { A, D } from "./store-
|
|
6
|
+
import { __tla as __tla_1 } from "./store-BPx-Ghbc.js";
|
|
7
|
+
import { A, D } from "./store-BPx-Ghbc.js";
|
|
8
8
|
import { k } from "./helpers-DtCY-jxq.js";
|
|
9
9
|
let index$4, BaseWidgetMixin, index$3, CounterMixin, DspCatalogDisplay, EdcAssetsDisplay, FederationMixin, FilterMixin, GrouperMixin, HighlighterMixin, ListMixin, NextMixin, PaginateMixin, RequiredMixin, Sib, SolidAcChecker, SolidDelete, SolidDisplay, SolidForm, SolidFormSearch, SolidLang, SolidMemberAdd, SolidMemberDelete, SolidMembership, SolidTable, SolidTemplateElement, SolidWidget, SorterMixin, StoreMixin, index$2, index$1, index, TranslationMixin, ValidationMixin, WidgetMixin, b, o$2, newWidgetFactory, D2, o$1, m, widgetFactory;
|
|
10
10
|
let __tla = Promise.all([
|
|
@@ -754,7 +754,17 @@ let __tla = (async () => {
|
|
|
754
754
|
return response.json();
|
|
755
755
|
}
|
|
756
756
|
async ensureAuthenticated() {
|
|
757
|
-
|
|
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
|
+
}
|
|
758
768
|
switch (this.config.authMethod) {
|
|
759
769
|
case "dsp-api-key":
|
|
760
770
|
if (!this.config.dspApiKey) {
|
|
@@ -765,6 +775,7 @@ let __tla = (async () => {
|
|
|
765
775
|
...this.headers,
|
|
766
776
|
"X-Api-Key": this.authToken
|
|
767
777
|
};
|
|
778
|
+
console.log("\u{1F510} [DSP Store] Set X-Api-Key header");
|
|
768
779
|
break;
|
|
769
780
|
case "bearer":
|
|
770
781
|
if (!this.config.bearerToken) {
|
|
@@ -1937,33 +1948,88 @@ let __tla = (async () => {
|
|
|
1937
1948
|
function getFederatedCatalogueAPIWrapper(baseUrl, loginOptions, fetch2) {
|
|
1938
1949
|
return new FederatedCatalogueAPIWrapper(loginOptions, baseUrl, fetch2);
|
|
1939
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;
|
|
1997
|
+
}
|
|
1940
1998
|
class FederatedCatalogueStore {
|
|
1941
1999
|
constructor(cfg) {
|
|
1942
2000
|
__publicField(this, "cache");
|
|
1943
|
-
__publicField(this, "fcApi");
|
|
2001
|
+
__publicField(this, "fcApi", null);
|
|
1944
2002
|
__publicField(this, "metadataManager");
|
|
1945
2003
|
__publicField(this, "enableCaching");
|
|
1946
2004
|
__publicField(this, "cleanupAuth");
|
|
1947
2005
|
__publicField(this, "isFetching", false);
|
|
1948
2006
|
__publicField(this, "pendingGetData", null);
|
|
1949
|
-
__publicField(this, "resolveFetch", (event) => {
|
|
2007
|
+
__publicField(this, "resolveFetch", async (event) => {
|
|
1950
2008
|
if (!this.cfg.endpoint) {
|
|
1951
2009
|
throw new Error("Missing required `endpoint` in StoreConfig for FederatedCatalogueStore");
|
|
1952
2010
|
}
|
|
1953
2011
|
if (event.detail.fetch) {
|
|
1954
|
-
|
|
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();
|
|
1955
2021
|
}
|
|
1956
2022
|
});
|
|
1957
2023
|
this.cfg = cfg;
|
|
1958
2024
|
if (!this.cfg.endpoint) {
|
|
1959
2025
|
throw new Error("Missing required `endpoint` in StoreConfig for FederatedCatalogueStore");
|
|
1960
2026
|
}
|
|
1961
|
-
const fetchAuth = AuthFetchResolver.getAuthFetch();
|
|
1962
2027
|
this.cleanupAuth = AuthFetchResolver.onAuthActivated(this.resolveFetch.bind(this));
|
|
1963
|
-
if (
|
|
1964
|
-
|
|
1965
|
-
} else {
|
|
2028
|
+
if (this.cfg.login) {
|
|
2029
|
+
const fetchAuth = AuthFetchResolver.getAuthFetch();
|
|
1966
2030
|
this.fcApi = getFederatedCatalogueAPIWrapper(this.cfg.endpoint, this.cfg.login, fetchAuth);
|
|
2031
|
+
} else {
|
|
2032
|
+
this.initializeWithOidcAuth();
|
|
1967
2033
|
}
|
|
1968
2034
|
this.cache = new InMemoryCacheManager();
|
|
1969
2035
|
this.enableCaching = this.cfg.enableLocalStorageMetadata === true;
|
|
@@ -1979,6 +2045,48 @@ let __tla = (async () => {
|
|
|
1979
2045
|
var _a2;
|
|
1980
2046
|
(_a2 = this.cleanupAuth) == null ? void 0 : _a2.call(this);
|
|
1981
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
|
+
}
|
|
1982
2090
|
handlePageReload() {
|
|
1983
2091
|
var _a2, _b;
|
|
1984
2092
|
try {
|
|
@@ -2020,7 +2128,8 @@ let __tla = (async () => {
|
|
|
2020
2128
|
var _a2;
|
|
2021
2129
|
const targetType = this.resolveTargetType(args);
|
|
2022
2130
|
if (!this.fcApi) {
|
|
2023
|
-
|
|
2131
|
+
console.warn("[FederatedCatalogueStore] API not initialized yet, waiting for auth activation");
|
|
2132
|
+
return await this.initLocalDataSourceContainer();
|
|
2024
2133
|
}
|
|
2025
2134
|
const cacheIsValid = this.enableCaching && ((_a2 = this.metadataManager) == null ? void 0 : _a2.isCacheValid());
|
|
2026
2135
|
const hasCached = this.hasCachedData();
|
|
@@ -2161,7 +2270,8 @@ let __tla = (async () => {
|
|
|
2161
2270
|
}
|
|
2162
2271
|
async getFullData(_targetType) {
|
|
2163
2272
|
if (!this.fcApi) {
|
|
2164
|
-
|
|
2273
|
+
console.warn("[FederatedCatalogueStore] API not initialized yet, waiting for auth");
|
|
2274
|
+
return await this.initLocalDataSourceContainer();
|
|
2165
2275
|
}
|
|
2166
2276
|
const resource = await this.initLocalDataSourceContainer();
|
|
2167
2277
|
const dataset2 = await this.fcApi.getAllSelfDescriptions();
|
|
@@ -20164,6 +20274,7 @@ let __tla = (async () => {
|
|
|
20164
20274
|
if (hasRequiredBrowser$3) return browser$3.exports;
|
|
20165
20275
|
hasRequiredBrowser$3 = 1;
|
|
20166
20276
|
(function(module, exports$1) {
|
|
20277
|
+
var define_process_env_default = {};
|
|
20167
20278
|
exports$1.formatArgs = formatArgs;
|
|
20168
20279
|
exports$1.save = save;
|
|
20169
20280
|
exports$1.load = load;
|
|
@@ -20305,7 +20416,7 @@ let __tla = (async () => {
|
|
|
20305
20416
|
} catch (error2) {
|
|
20306
20417
|
}
|
|
20307
20418
|
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
20308
|
-
r =
|
|
20419
|
+
r = define_process_env_default.DEBUG;
|
|
20309
20420
|
}
|
|
20310
20421
|
return r;
|
|
20311
20422
|
}
|
|
@@ -29532,7 +29643,7 @@ sh:property [
|
|
|
29532
29643
|
window.dispatchEvent(event);
|
|
29533
29644
|
}
|
|
29534
29645
|
async initGetter() {
|
|
29535
|
-
const { CustomGetter } = await import("./custom-getter-
|
|
29646
|
+
const { CustomGetter } = await import("./custom-getter-BUGtV5pI.js");
|
|
29536
29647
|
return CustomGetter;
|
|
29537
29648
|
}
|
|
29538
29649
|
disconnectedCallback() {
|
package/dist/store.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startinblox/core",
|
|
3
|
-
"version": "2.0.6-beta.
|
|
3
|
+
"version": "2.0.6-beta.11",
|
|
4
4
|
"description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|