@fluid-app/portal-sdk 0.1.165 → 0.1.166
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/{FluidProvider-DbLFKavY.cjs → FluidProvider-DMFD--HI.cjs} +16 -270
- package/dist/FluidProvider-DMFD--HI.cjs.map +1 -0
- package/dist/{FluidProvider-BfATASw-.mjs → FluidProvider-qmTRBp3-.mjs} +17 -259
- package/dist/FluidProvider-qmTRBp3-.mjs.map +1 -0
- package/dist/{MessagingScreen-Dhg3eu32.mjs → MessagingScreen-B78wJC_8.mjs} +2 -2
- package/dist/{MessagingScreen-Dhg3eu32.mjs.map → MessagingScreen-B78wJC_8.mjs.map} +1 -1
- package/dist/{MessagingScreen-lFvwnAU6.cjs → MessagingScreen-BlCjptc6.cjs} +3 -3
- package/dist/{MessagingScreen-lFvwnAU6.cjs.map → MessagingScreen-BlCjptc6.cjs.map} +1 -1
- package/dist/{MessagingScreen-Dd0EBrre.cjs → MessagingScreen-DRD8xnXj.cjs} +2 -2
- package/dist/{ProductsScreen-nHmUftQn.mjs → ProductsScreen-C8amMeRh.mjs} +2 -0
- package/dist/{ProfileScreen-DUj4bkhx.cjs → ProfileScreen-CfHE4Ded.cjs} +2 -2
- package/dist/{ProfileScreen-DUj4bkhx.cjs.map → ProfileScreen-CfHE4Ded.cjs.map} +1 -1
- package/dist/{ProfileScreen-BuIxKbXC.mjs → ProfileScreen-Ct-m03oC.mjs} +2 -2
- package/dist/{ProfileScreen-BuIxKbXC.mjs.map → ProfileScreen-Ct-m03oC.mjs.map} +1 -1
- package/dist/{ProfileScreen-uAud2ErT.cjs → ProfileScreen-hD0bjuys.cjs} +2 -2
- package/dist/{ShareablesScreen-CdTyyDRO.mjs → ShareablesScreen-JxVPd89h.mjs} +2 -0
- package/dist/{ShopScreen-BUXUtEuj.cjs → ShopScreen-D9clGspu.cjs} +2 -2
- package/dist/{ShopScreen-BUXUtEuj.cjs.map → ShopScreen-D9clGspu.cjs.map} +1 -1
- package/dist/{ShopScreen-BH6zQndJ.mjs → ShopScreen-DW0puWGa.mjs} +2 -2
- package/dist/{ShopScreen-BH6zQndJ.mjs.map → ShopScreen-DW0puWGa.mjs.map} +1 -1
- package/dist/{ShopScreen-BbucUNI7.cjs → ShopScreen-Dvsz_wyc.cjs} +2 -2
- package/dist/index.cjs +10 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -161
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +24 -161
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +15 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/FluidProvider-BfATASw-.mjs.map +0 -1
- package/dist/FluidProvider-DbLFKavY.cjs.map +0 -1
|
@@ -519,7 +519,7 @@ function useLanguagesApi() {
|
|
|
519
519
|
/**
|
|
520
520
|
* API Error class compatible with fluid-admin's ApiError
|
|
521
521
|
*/
|
|
522
|
-
var ApiError
|
|
522
|
+
var ApiError = class ApiError extends Error {
|
|
523
523
|
status;
|
|
524
524
|
data;
|
|
525
525
|
constructor(message, status, data) {
|
|
@@ -527,7 +527,7 @@ var ApiError$1 = class ApiError$1 extends Error {
|
|
|
527
527
|
this.name = "ApiError";
|
|
528
528
|
this.status = status;
|
|
529
529
|
this.data = data;
|
|
530
|
-
if ("captureStackTrace" in Error) Error.captureStackTrace(this, ApiError
|
|
530
|
+
if ("captureStackTrace" in Error) Error.captureStackTrace(this, ApiError);
|
|
531
531
|
}
|
|
532
532
|
toJSON() {
|
|
533
533
|
return {
|
|
@@ -601,10 +601,10 @@ function createFetchClient(config) {
|
|
|
601
601
|
try {
|
|
602
602
|
data = JSON.parse(errorText);
|
|
603
603
|
} catch {
|
|
604
|
-
throw new ApiError
|
|
604
|
+
throw new ApiError(errorText.slice(0, 200) || `${method} request failed with status ${response.status}`, response.status, null);
|
|
605
605
|
}
|
|
606
|
-
throw new ApiError
|
|
607
|
-
} else throw new ApiError
|
|
606
|
+
throw new ApiError(data.message || data.error_message || `${method} request failed`, response.status, data.errors || data);
|
|
607
|
+
} else throw new ApiError(`${method} request failed with status ${response.status}`, response.status, null);
|
|
608
608
|
}
|
|
609
609
|
if (response.status === 204 || response.headers.get("content-length") === "0") return null;
|
|
610
610
|
if (response.headers.get("content-type")?.includes("application/json")) try {
|
|
@@ -637,7 +637,7 @@ function createFetchClient(config) {
|
|
|
637
637
|
if (signal) fetchOptions.signal = signal;
|
|
638
638
|
response = await fetch(url, fetchOptions);
|
|
639
639
|
} catch (networkError) {
|
|
640
|
-
throw new ApiError
|
|
640
|
+
throw new ApiError(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
641
641
|
}
|
|
642
642
|
return handleResponse(response, method, url);
|
|
643
643
|
}
|
|
@@ -660,7 +660,7 @@ function createFetchClient(config) {
|
|
|
660
660
|
if (signal) fetchOptions.signal = signal;
|
|
661
661
|
response = await fetch(url, fetchOptions);
|
|
662
662
|
} catch (networkError) {
|
|
663
|
-
throw new ApiError
|
|
663
|
+
throw new ApiError(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
664
664
|
}
|
|
665
665
|
return handleResponse(response, method, url);
|
|
666
666
|
}
|
|
@@ -694,247 +694,6 @@ function createFetchClient(config) {
|
|
|
694
694
|
};
|
|
695
695
|
}
|
|
696
696
|
//#endregion
|
|
697
|
-
//#region src/client/types.ts
|
|
698
|
-
/**
|
|
699
|
-
* HTTP methods supported by the API client.
|
|
700
|
-
* Use `as const` for literal type inference and type safety.
|
|
701
|
-
*/
|
|
702
|
-
const HTTP_METHODS = {
|
|
703
|
-
GET: "GET",
|
|
704
|
-
POST: "POST",
|
|
705
|
-
PUT: "PUT",
|
|
706
|
-
PATCH: "PATCH",
|
|
707
|
-
DELETE: "DELETE"
|
|
708
|
-
};
|
|
709
|
-
//#endregion
|
|
710
|
-
//#region src/client/fluid-client.ts
|
|
711
|
-
/**
|
|
712
|
-
* Fluid API Client
|
|
713
|
-
* Adapted from: packages/fluidos-api-client/src/lib/fetch-client.ts
|
|
714
|
-
* Provides authenticated API access with domain-specific methods
|
|
715
|
-
*/
|
|
716
|
-
/**
|
|
717
|
-
* API Error class for structured error handling
|
|
718
|
-
*/
|
|
719
|
-
var ApiError = class ApiError extends Error {
|
|
720
|
-
status;
|
|
721
|
-
data;
|
|
722
|
-
constructor(message, status, data) {
|
|
723
|
-
super(message);
|
|
724
|
-
this.name = "ApiError";
|
|
725
|
-
this.status = status;
|
|
726
|
-
this.data = data;
|
|
727
|
-
const errorWithCapture = Error;
|
|
728
|
-
if (errorWithCapture.captureStackTrace) errorWithCapture.captureStackTrace(this, ApiError);
|
|
729
|
-
}
|
|
730
|
-
toJSON() {
|
|
731
|
-
return {
|
|
732
|
-
name: this.name,
|
|
733
|
-
message: this.message,
|
|
734
|
-
status: this.status,
|
|
735
|
-
data: this.data
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
};
|
|
739
|
-
/**
|
|
740
|
-
* Type guard for ApiError
|
|
741
|
-
*/
|
|
742
|
-
function isApiError(error) {
|
|
743
|
-
return error instanceof ApiError;
|
|
744
|
-
}
|
|
745
|
-
/**
|
|
746
|
-
* Type guard to check if a value is a non-null string
|
|
747
|
-
*/
|
|
748
|
-
function isString(value) {
|
|
749
|
-
return typeof value === "string";
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Extract error message from API response data using `in` operator narrowing.
|
|
753
|
-
* Checks common error message field names in order of precedence.
|
|
754
|
-
*/
|
|
755
|
-
function extractErrorMessage(data, fallback) {
|
|
756
|
-
if ("message" in data && isString(data.message)) return data.message;
|
|
757
|
-
if ("error_message" in data && isString(data.error_message)) return data.error_message;
|
|
758
|
-
if ("error" in data && isString(data.error)) return data.error;
|
|
759
|
-
return fallback;
|
|
760
|
-
}
|
|
761
|
-
/**
|
|
762
|
-
* Type guard to detect whether a parsed JSON value is an API envelope.
|
|
763
|
-
* Envelopes always have numeric `status` and a `data` key.
|
|
764
|
-
*/
|
|
765
|
-
function isApiEnvelope(value) {
|
|
766
|
-
return typeof value === "object" && value !== null && "status" in value && typeof value.status === "number" && "data" in value;
|
|
767
|
-
}
|
|
768
|
-
/**
|
|
769
|
-
* Creates a configured Fluid API client instance
|
|
770
|
-
*/
|
|
771
|
-
function createFluidClient(config) {
|
|
772
|
-
const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {} } = config;
|
|
773
|
-
const fetchClient = createFetchClient({
|
|
774
|
-
baseUrl,
|
|
775
|
-
...getAuthToken ? { getAuthToken } : {},
|
|
776
|
-
onAuthError,
|
|
777
|
-
defaultHeaders,
|
|
778
|
-
credentials: "include"
|
|
779
|
-
});
|
|
780
|
-
/**
|
|
781
|
-
* Build headers for a request.
|
|
782
|
-
* Auth is handled by session cookies via `credentials: 'include'` on fetch calls.
|
|
783
|
-
*/
|
|
784
|
-
function buildHeaders(customHeaders) {
|
|
785
|
-
return {
|
|
786
|
-
"Content-Type": "application/json",
|
|
787
|
-
...defaultHeaders,
|
|
788
|
-
...customHeaders
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* Build URL with query parameters (Rails-compatible)
|
|
793
|
-
*/
|
|
794
|
-
function buildUrl(endpoint, params) {
|
|
795
|
-
const normalizedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
796
|
-
const normalizedEndpoint = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
|
|
797
|
-
const url = normalizedBase ? new URL(normalizedBase + normalizedEndpoint) : new URL(normalizedEndpoint, typeof window !== "undefined" ? window.location.origin : "http://localhost");
|
|
798
|
-
if (params) for (const [key, value] of Object.entries(params)) {
|
|
799
|
-
if (value === void 0 || value === null) continue;
|
|
800
|
-
if (Array.isArray(value)) for (const item of value) url.searchParams.append(`${key}[]`, String(item));
|
|
801
|
-
else if (typeof value === "object") for (const [subKey, subValue] of Object.entries(value)) {
|
|
802
|
-
if (subValue === void 0 || subValue === null) continue;
|
|
803
|
-
if (Array.isArray(subValue)) for (const item of subValue) url.searchParams.append(`${key}[${subKey}][]`, String(item));
|
|
804
|
-
else url.searchParams.append(`${key}[${subKey}]`, String(subValue));
|
|
805
|
-
}
|
|
806
|
-
else url.searchParams.append(key, String(value));
|
|
807
|
-
}
|
|
808
|
-
return url.toString();
|
|
809
|
-
}
|
|
810
|
-
/**
|
|
811
|
-
* Default request options for type-safe defaults.
|
|
812
|
-
* Uses `satisfies` to validate against RequestOptions while preserving literal types.
|
|
813
|
-
*/
|
|
814
|
-
const defaultRequestOptions = { method: HTTP_METHODS.GET };
|
|
815
|
-
/**
|
|
816
|
-
* Main request function
|
|
817
|
-
*/
|
|
818
|
-
async function request(endpoint, options = {}) {
|
|
819
|
-
const { method = defaultRequestOptions.method, headers: customHeaders, params, body, signal } = options;
|
|
820
|
-
const url = buildUrl(endpoint, method === HTTP_METHODS.GET ? params : void 0);
|
|
821
|
-
const headers = buildHeaders(customHeaders);
|
|
822
|
-
let response;
|
|
823
|
-
try {
|
|
824
|
-
const fetchOptions = {
|
|
825
|
-
method,
|
|
826
|
-
headers,
|
|
827
|
-
credentials: "include"
|
|
828
|
-
};
|
|
829
|
-
if (signal !== void 0) fetchOptions.signal = signal;
|
|
830
|
-
if (body && method !== HTTP_METHODS.GET) fetchOptions.body = JSON.stringify(body);
|
|
831
|
-
response = await fetch(url, fetchOptions);
|
|
832
|
-
} catch (networkError) {
|
|
833
|
-
throw new ApiError(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
834
|
-
}
|
|
835
|
-
if (response.status === 401) {
|
|
836
|
-
onAuthError?.();
|
|
837
|
-
throw new ApiError("Authentication required", 401, null);
|
|
838
|
-
}
|
|
839
|
-
if (!response.ok) try {
|
|
840
|
-
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
841
|
-
const data = await response.json();
|
|
842
|
-
throw new ApiError(extractErrorMessage(data, `${method} request failed`), response.status, "errors" in data ? data.errors : data);
|
|
843
|
-
} else throw new ApiError(`${method} request failed with status ${response.status}`, response.status, null);
|
|
844
|
-
} catch (error) {
|
|
845
|
-
if (isApiError(error)) throw error;
|
|
846
|
-
throw new ApiError(`${method} request failed with status ${response.status}`, response.status, null);
|
|
847
|
-
}
|
|
848
|
-
if (response.status === 204 || response.headers.get("content-length") === "0") return null;
|
|
849
|
-
try {
|
|
850
|
-
const raw = await response.json();
|
|
851
|
-
if (raw === null || raw === void 0) throw new ApiError("Unexpected null/undefined in JSON response", response.status, null);
|
|
852
|
-
return isApiEnvelope(raw) ? raw.data : raw;
|
|
853
|
-
} catch (parseError) {
|
|
854
|
-
if (isApiError(parseError)) throw parseError;
|
|
855
|
-
throw new ApiError("Failed to parse response as JSON", response.status, null);
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
/**
|
|
859
|
-
* Request function for endpoints that may return null (204 No Content).
|
|
860
|
-
* Properly types the return as T | null.
|
|
861
|
-
*/
|
|
862
|
-
async function requestNullable(endpoint, options = {}) {
|
|
863
|
-
return request(endpoint, options);
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* Safe request wrapper that returns a discriminated union instead of throwing.
|
|
867
|
-
* Use `isApiSuccess` or `isApiFailure` to narrow the result.
|
|
868
|
-
*/
|
|
869
|
-
async function safeRequest(endpoint, options = {}) {
|
|
870
|
-
try {
|
|
871
|
-
return {
|
|
872
|
-
success: true,
|
|
873
|
-
data: await request(endpoint, options)
|
|
874
|
-
};
|
|
875
|
-
} catch (error) {
|
|
876
|
-
if (isApiError(error)) return {
|
|
877
|
-
success: false,
|
|
878
|
-
error
|
|
879
|
-
};
|
|
880
|
-
return {
|
|
881
|
-
success: false,
|
|
882
|
-
error: new ApiError(error instanceof Error ? error.message : "Unknown error", 0, null)
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* Helper to safely convert typed params to Record<string, unknown>.
|
|
888
|
-
* Type assertion required: TypeScript's structural typing allows any object
|
|
889
|
-
* to be treated as Record<string, unknown> when we only need to iterate
|
|
890
|
-
* over its entries. This is safe because buildUrl only reads properties.
|
|
891
|
-
*/
|
|
892
|
-
function toParams(params) {
|
|
893
|
-
return params;
|
|
894
|
-
}
|
|
895
|
-
const get = (endpoint, params, options) => {
|
|
896
|
-
const baseOptions = {
|
|
897
|
-
...options,
|
|
898
|
-
method: HTTP_METHODS.GET
|
|
899
|
-
};
|
|
900
|
-
const convertedParams = toParams(params);
|
|
901
|
-
return request(endpoint, convertedParams !== void 0 ? {
|
|
902
|
-
...baseOptions,
|
|
903
|
-
params: convertedParams
|
|
904
|
-
} : baseOptions);
|
|
905
|
-
};
|
|
906
|
-
const post = (endpoint, body, options) => request(endpoint, {
|
|
907
|
-
...options,
|
|
908
|
-
method: HTTP_METHODS.POST,
|
|
909
|
-
body
|
|
910
|
-
});
|
|
911
|
-
const put = (endpoint, body, options) => request(endpoint, {
|
|
912
|
-
...options,
|
|
913
|
-
method: HTTP_METHODS.PUT,
|
|
914
|
-
body
|
|
915
|
-
});
|
|
916
|
-
const patch = (endpoint, body, options) => request(endpoint, {
|
|
917
|
-
...options,
|
|
918
|
-
method: HTTP_METHODS.PATCH,
|
|
919
|
-
body
|
|
920
|
-
});
|
|
921
|
-
const del = (endpoint, options) => request(endpoint, {
|
|
922
|
-
...options,
|
|
923
|
-
method: HTTP_METHODS.DELETE
|
|
924
|
-
});
|
|
925
|
-
return {
|
|
926
|
-
fetchClient,
|
|
927
|
-
request,
|
|
928
|
-
requestNullable,
|
|
929
|
-
safeRequest,
|
|
930
|
-
get,
|
|
931
|
-
post,
|
|
932
|
-
put,
|
|
933
|
-
patch,
|
|
934
|
-
delete: del
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
//#endregion
|
|
938
697
|
//#region ../../api-clients/fluidos/src/namespaces/fluid_os.ts
|
|
939
698
|
/**
|
|
940
699
|
* Get active Fluid OS definition
|
|
@@ -2595,12 +2354,14 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
|
|
|
2595
2354
|
}, []);
|
|
2596
2355
|
const configRef = useRef(config);
|
|
2597
2356
|
configRef.current = config;
|
|
2598
|
-
const
|
|
2599
|
-
|
|
2600
|
-
getAuthToken: () => configRef.current.getAuthToken?.() ?? null,
|
|
2601
|
-
onAuthError: () => configRef.current.onAuthError?.()
|
|
2357
|
+
const fluidOsFetchClient = useMemo(() => createFetchClient({
|
|
2358
|
+
baseUrl: configRef.current.baseUrl,
|
|
2359
|
+
...configRef.current.getAuthToken ? { getAuthToken: () => configRef.current.getAuthToken?.() ?? null } : {},
|
|
2360
|
+
onAuthError: () => configRef.current.onAuthError?.(),
|
|
2361
|
+
defaultHeaders: configRef.current.defaultHeaders,
|
|
2362
|
+
credentials: "include"
|
|
2602
2363
|
}), [config.baseUrl]);
|
|
2603
|
-
const fluidOsApi = useMemo(() => createFluidOsReadAdapter(
|
|
2364
|
+
const fluidOsApi = useMemo(() => createFluidOsReadAdapter(fluidOsFetchClient), [fluidOsFetchClient]);
|
|
2604
2365
|
const csrfToken = typeof document !== "undefined" ? document.querySelector("meta[name=\"csrf-token\"]")?.getAttribute("content") : null;
|
|
2605
2366
|
const portalTenantClient = useMemo(() => createFetchClient({
|
|
2606
2367
|
baseUrl: configRef.current.baseUrl,
|
|
@@ -2614,10 +2375,7 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
|
|
|
2614
2375
|
const countriesApi = useMemo(() => createCountriesApiAdapter(portalTenantClient), [portalTenantClient]);
|
|
2615
2376
|
const languagesApi = useMemo(() => createLanguagesApiAdapter(portalTenantClient), [portalTenantClient]);
|
|
2616
2377
|
const mysiteApi = useMemo(() => createMySiteApiAdapter(portalTenantClient), [portalTenantClient]);
|
|
2617
|
-
const contextValue = useMemo(() => ({
|
|
2618
|
-
client,
|
|
2619
|
-
config: configRef.current
|
|
2620
|
-
}), [client]);
|
|
2378
|
+
const contextValue = useMemo(() => ({ config }), [config.baseUrl]);
|
|
2621
2379
|
const getApiHeaders = useCallback(() => {
|
|
2622
2380
|
return { "Content-Type": "application/json" };
|
|
2623
2381
|
}, []);
|
|
@@ -2698,6 +2456,6 @@ function useFluidContext() {
|
|
|
2698
2456
|
return context;
|
|
2699
2457
|
}
|
|
2700
2458
|
//#endregion
|
|
2701
|
-
export { mergeDarkOverrides as A,
|
|
2459
|
+
export { mergeDarkOverrides as A, usePayApi as B, DEFAULT_THEME_ID as C, deriveDarkVariant as D, generateThemeCSS as E, RADIUS_KEYS as F, useFluidOsApi as H, SEMANTIC_COLOR_NAMES as I, SHADE_STEPS as L, resolveTheme as M, FONT_FAMILY_KEYS as N, generateShades as O, FONT_SIZE_KEYS as P, ApiError as R, DEFAULT_SPACING as S, getDefaultThemeDefinition as T, createPersister as U, useAppDefinitionApi as V, deleteDatabase as W, serialiseTheme as _, createScreen as a, DEFAULT_FONT_SIZES as b, FluidThemeProvider as c, removeAllThemes as d, removeTheme as f, deserialiseTheme as g, transformThemes as h, widgetPropertySchemas as i, parseColor as j, getForegroundColor as k, useThemeContext as l, getActiveThemeId as m, useFluidContext as n, createWidgetFromShareable as o, buildThemeDefinition as p, DEFAULT_SDK_WIDGET_REGISTRY as r, createWidgetRegistry as s, FluidProvider as t, applyTheme as u, DEFAULT_COLORS as v, DEFAULT_THEME_NAME as w, DEFAULT_RADII as x, DEFAULT_FONT_FAMILIES as y, useLanguagesApi as z };
|
|
2702
2460
|
|
|
2703
|
-
//# sourceMappingURL=FluidProvider-
|
|
2461
|
+
//# sourceMappingURL=FluidProvider-qmTRBp3-.mjs.map
|