@fluid-app/portal-sdk 0.1.101 → 0.1.102
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/{AppDownloadScreen-rO--O0pk.mjs → AppDownloadScreen-BUyo5t28.mjs} +2 -2
- package/dist/{AppDownloadScreen-rO--O0pk.mjs.map → AppDownloadScreen-BUyo5t28.mjs.map} +1 -1
- package/dist/{AppDownloadScreen-CwLZzr-7.cjs → AppDownloadScreen-D7TgBBNp.cjs} +2 -2
- package/dist/{AppDownloadScreen-BcK2snUL.cjs → AppDownloadScreen-DRXJupWZ.cjs} +2 -2
- package/dist/{AppDownloadScreen-BcK2snUL.cjs.map → AppDownloadScreen-DRXJupWZ.cjs.map} +1 -1
- package/dist/{ContactsScreen-D4WQ59ib.cjs → ContactsScreen-8yKH9Vmm.cjs} +2 -2
- package/dist/{ContactsScreen-BGwqGlpV.mjs → ContactsScreen-CHZ-SGpD.mjs} +2 -2
- package/dist/{ContactsScreen-BGwqGlpV.mjs.map → ContactsScreen-CHZ-SGpD.mjs.map} +1 -1
- package/dist/{ContactsScreen-CkSeaPyz.cjs → ContactsScreen-DXDkh7cU.cjs} +2 -2
- package/dist/{ContactsScreen-CkSeaPyz.cjs.map → ContactsScreen-DXDkh7cU.cjs.map} +1 -1
- package/dist/{FluidProvider-CWYquEIF.mjs → FluidProvider-BPFyPU7u.mjs} +81 -32
- package/dist/FluidProvider-BPFyPU7u.mjs.map +1 -0
- package/dist/{FluidProvider-CyzA2g75.cjs → FluidProvider-CUiOFaDp.cjs} +81 -32
- package/dist/FluidProvider-CUiOFaDp.cjs.map +1 -0
- package/dist/{MessagingScreen-Cgx3jwpr.cjs → MessagingScreen-CuVoDjwR.cjs} +4 -9
- package/dist/MessagingScreen-CuVoDjwR.cjs.map +1 -0
- package/dist/{MessagingScreen-DKigg2jz.mjs → MessagingScreen-D2GGSkix.mjs} +2 -2
- package/dist/{MessagingScreen-CGS7aG1A.cjs → MessagingScreen-V7ribzpo.cjs} +2 -2
- package/dist/{MessagingScreen-CBuI3fu6.mjs → MessagingScreen-pS-W5HIk.mjs} +4 -9
- package/dist/MessagingScreen-pS-W5HIk.mjs.map +1 -0
- package/dist/{MySiteScreen-Bvyx63pT.mjs → MySiteScreen-CSs9d6TQ.mjs} +2 -2
- package/dist/{MySiteScreen-Bvyx63pT.mjs.map → MySiteScreen-CSs9d6TQ.mjs.map} +1 -1
- package/dist/{MySiteScreen-BSFb-n7n.cjs → MySiteScreen-DjtoRz-f.cjs} +2 -2
- package/dist/{MySiteScreen-BSFb-n7n.cjs.map → MySiteScreen-DjtoRz-f.cjs.map} +1 -1
- package/dist/{MySiteScreen-2IzxVfpO.cjs → MySiteScreen-DtpHDP-m.cjs} +2 -2
- package/dist/{OrdersScreen-Djdeji9g.mjs → OrdersScreen-BUm_cDrS.mjs} +3 -3
- package/dist/{OrdersScreen-Djdeji9g.mjs.map → OrdersScreen-BUm_cDrS.mjs.map} +1 -1
- package/dist/{OrdersScreen-Bf4o3Kty.cjs → OrdersScreen-DNAtzcu5.cjs} +3 -3
- package/dist/{OrdersScreen-Bf4o3Kty.cjs.map → OrdersScreen-DNAtzcu5.cjs.map} +1 -1
- package/dist/{OrdersScreen-DCzYEgsP.cjs → OrdersScreen-NSLW9EyM.cjs} +2 -2
- package/dist/{ProductsScreen-PJ95OcSX.cjs → ProductsScreen-0K31iqTS.cjs} +4 -4
- package/dist/{ProductsScreen-PJ95OcSX.cjs.map → ProductsScreen-0K31iqTS.cjs.map} +1 -1
- package/dist/{ProductsScreen-DZiugPVb.mjs → ProductsScreen-CQlvW2cC.mjs} +3 -3
- package/dist/{ProductsScreen-DZnKtPBp.cjs → ProductsScreen-CSgVSuOa.cjs} +3 -3
- package/dist/{ProductsScreen-6J79mnIB.mjs → ProductsScreen-Cc5LjAOS.mjs} +4 -4
- package/dist/{ProductsScreen-6J79mnIB.mjs.map → ProductsScreen-Cc5LjAOS.mjs.map} +1 -1
- package/dist/{ProfileScreen-DtmReqa8.cjs → ProfileScreen-BRSE-yT7.cjs} +3 -3
- package/dist/{ProfileScreen-DtmReqa8.cjs.map → ProfileScreen-BRSE-yT7.cjs.map} +1 -1
- package/dist/{ProfileScreen-B46jd4Ic.cjs → ProfileScreen-CxLqoYTU.cjs} +2 -2
- package/dist/{ProfileScreen-CUsGRCB7.mjs → ProfileScreen-DXdLGjJE.mjs} +3 -3
- package/dist/{ProfileScreen-CUsGRCB7.mjs.map → ProfileScreen-DXdLGjJE.mjs.map} +1 -1
- package/dist/{ShareablesScreen-Cy7w85IH.mjs → ShareablesScreen-C3ZUhqHP.mjs} +5 -5
- package/dist/{ShareablesScreen-Cy7w85IH.mjs.map → ShareablesScreen-C3ZUhqHP.mjs.map} +1 -1
- package/dist/{ShareablesScreen-Dk5EQGMa.cjs → ShareablesScreen-TAJ2R5pG.cjs} +3 -3
- package/dist/{ShareablesScreen-CVT7u2hN.cjs → ShareablesScreen-baTkO1KB.cjs} +5 -5
- package/dist/{ShareablesScreen-CVT7u2hN.cjs.map → ShareablesScreen-baTkO1KB.cjs.map} +1 -1
- package/dist/{ShareablesScreen-DFAVIeqB.mjs → ShareablesScreen-h02BeiT8.mjs} +3 -3
- package/dist/{ShopScreen-DgBjP_8D.cjs → ShopScreen-BI5rtJQk.cjs} +4 -4
- package/dist/{ShopScreen-DgBjP_8D.cjs.map → ShopScreen-BI5rtJQk.cjs.map} +1 -1
- package/dist/{ShopScreen-wYtLEGXo.cjs → ShopScreen-BULLgDDI.cjs} +2 -2
- package/dist/{ShopScreen-AGvcqUii.mjs → ShopScreen-DJUhx1ly.mjs} +4 -4
- package/dist/{ShopScreen-AGvcqUii.mjs.map → ShopScreen-DJUhx1ly.mjs.map} +1 -1
- package/dist/{SubscriptionsScreen-BrLlvFJn.cjs → SubscriptionsScreen-BYCEYtcZ.cjs} +3 -3
- package/dist/{SubscriptionsScreen-BrLlvFJn.cjs.map → SubscriptionsScreen-BYCEYtcZ.cjs.map} +1 -1
- package/dist/{SubscriptionsScreen-C5YWtYfE.mjs → SubscriptionsScreen-CWwp5Po6.mjs} +3 -3
- package/dist/{SubscriptionsScreen-C5YWtYfE.mjs.map → SubscriptionsScreen-CWwp5Po6.mjs.map} +1 -1
- package/dist/{SubscriptionsScreen-BqOb2kYR.cjs → SubscriptionsScreen-hkhnXy8j.cjs} +2 -2
- package/dist/index.cjs +54 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -28
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +45 -28
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +54 -52
- package/dist/index.mjs.map +1 -1
- package/dist/{src-BrwLqPPh.mjs → src-DjlwUaws.mjs} +40 -12
- package/dist/src-DjlwUaws.mjs.map +1 -0
- package/dist/{src-Dlsw83js.cjs → src-xEfkv04t.cjs} +40 -12
- package/dist/src-xEfkv04t.cjs.map +1 -0
- package/dist/{use-account-clients-Dsqx0mKw.mjs → use-account-clients-3pKJ6EI1.mjs} +2 -2
- package/dist/{use-account-clients-Dsqx0mKw.mjs.map → use-account-clients-3pKJ6EI1.mjs.map} +1 -1
- package/dist/{use-account-clients-CkDfPpCR.cjs → use-account-clients-Bqc-31kE.cjs} +2 -2
- package/dist/{use-account-clients-CkDfPpCR.cjs.map → use-account-clients-Bqc-31kE.cjs.map} +1 -1
- package/dist/{use-current-user-BMI-LR9t.mjs → use-current-user-BRmRkzNy.mjs} +3 -3
- package/dist/{use-current-user-BMI-LR9t.mjs.map → use-current-user-BRmRkzNy.mjs.map} +1 -1
- package/dist/{use-current-user-LLJ1GtNB.cjs → use-current-user-DqzI6jzQ.cjs} +3 -3
- package/dist/{use-current-user-LLJ1GtNB.cjs.map → use-current-user-DqzI6jzQ.cjs.map} +1 -1
- package/dist/{use-customer-account-DZW_YY9d.cjs → use-customer-account-CHspwp0z.cjs} +3 -3
- package/dist/{use-customer-account-DZW_YY9d.cjs.map → use-customer-account-CHspwp0z.cjs.map} +1 -1
- package/dist/{use-customer-account-DzOD3vLz.mjs → use-customer-account-D83uR5o6.mjs} +3 -3
- package/dist/{use-customer-account-DzOD3vLz.mjs.map → use-customer-account-D83uR5o6.mjs.map} +1 -1
- package/dist/{use-fluid-api-Kw0AKvCs.cjs → use-fluid-api-CRZCVY8_.cjs} +2 -2
- package/dist/{use-fluid-api-Kw0AKvCs.cjs.map → use-fluid-api-CRZCVY8_.cjs.map} +1 -1
- package/dist/{use-fluid-api-CaSYWFuj.mjs → use-fluid-api-Cap4tsCe.mjs} +2 -2
- package/dist/{use-fluid-api-CaSYWFuj.mjs.map → use-fluid-api-Cap4tsCe.mjs.map} +1 -1
- package/package.json +12 -12
- package/dist/FluidProvider-CWYquEIF.mjs.map +0 -1
- package/dist/FluidProvider-CyzA2g75.cjs.map +0 -1
- package/dist/MessagingScreen-CBuI3fu6.mjs.map +0 -1
- package/dist/MessagingScreen-Cgx3jwpr.cjs.map +0 -1
- package/dist/src-BrwLqPPh.mjs.map +0 -1
- package/dist/src-Dlsw83js.cjs.map +0 -1
|
@@ -67,7 +67,7 @@ var ApiError$1 = class ApiError$1 extends Error {
|
|
|
67
67
|
* Creates a configured fetch client instance
|
|
68
68
|
*/
|
|
69
69
|
function createFetchClient(config) {
|
|
70
|
-
const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {} } = config;
|
|
70
|
+
const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {}, credentials } = config;
|
|
71
71
|
/**
|
|
72
72
|
* Build headers for a request
|
|
73
73
|
*/
|
|
@@ -156,6 +156,7 @@ function createFetchClient(config) {
|
|
|
156
156
|
method,
|
|
157
157
|
headers
|
|
158
158
|
};
|
|
159
|
+
if (credentials) fetchOptions.credentials = credentials;
|
|
159
160
|
const serializedBody = body && method !== "GET" ? JSON.stringify(body) : null;
|
|
160
161
|
if (serializedBody) fetchOptions.body = serializedBody;
|
|
161
162
|
if (signal) fetchOptions.signal = signal;
|
|
@@ -180,6 +181,7 @@ function createFetchClient(config) {
|
|
|
180
181
|
headers,
|
|
181
182
|
body: formData
|
|
182
183
|
};
|
|
184
|
+
if (credentials) fetchOptions.credentials = credentials;
|
|
183
185
|
if (signal) fetchOptions.signal = signal;
|
|
184
186
|
response = await fetch(url, fetchOptions);
|
|
185
187
|
} catch (networkError) {
|
|
@@ -3698,6 +3700,13 @@ function extractErrorMessage(data, fallback) {
|
|
|
3698
3700
|
return fallback;
|
|
3699
3701
|
}
|
|
3700
3702
|
/**
|
|
3703
|
+
* Type guard to detect whether a parsed JSON value is an API envelope.
|
|
3704
|
+
* Envelopes always have numeric `status` and a `data` key.
|
|
3705
|
+
*/
|
|
3706
|
+
function isApiEnvelope(value) {
|
|
3707
|
+
return typeof value === "object" && value !== null && "status" in value && typeof value.status === "number" && "data" in value;
|
|
3708
|
+
}
|
|
3709
|
+
/**
|
|
3701
3710
|
* Creates a configured Fluid API client instance
|
|
3702
3711
|
*/
|
|
3703
3712
|
function createFluidClient(config) {
|
|
@@ -3707,22 +3716,19 @@ function createFluidClient(config) {
|
|
|
3707
3716
|
baseUrl,
|
|
3708
3717
|
...getAuthToken ? { getAuthToken } : {},
|
|
3709
3718
|
onAuthError: effectiveOnAuthError,
|
|
3710
|
-
defaultHeaders
|
|
3719
|
+
defaultHeaders,
|
|
3720
|
+
credentials: "include"
|
|
3711
3721
|
});
|
|
3712
3722
|
/**
|
|
3713
|
-
* Build headers for a request
|
|
3723
|
+
* Build headers for a request.
|
|
3724
|
+
* Auth is handled by session cookies via `credentials: 'include'` on fetch calls.
|
|
3714
3725
|
*/
|
|
3715
|
-
|
|
3716
|
-
|
|
3726
|
+
function buildHeaders(customHeaders) {
|
|
3727
|
+
return {
|
|
3717
3728
|
"Content-Type": "application/json",
|
|
3718
3729
|
...defaultHeaders,
|
|
3719
3730
|
...customHeaders
|
|
3720
3731
|
};
|
|
3721
|
-
if (getAuthToken) {
|
|
3722
|
-
const token = await getAuthToken();
|
|
3723
|
-
if (token) headers.Authorization = `Bearer ${token}`;
|
|
3724
|
-
}
|
|
3725
|
-
return headers;
|
|
3726
3732
|
}
|
|
3727
3733
|
/**
|
|
3728
3734
|
* Build URL with query parameters (Rails-compatible)
|
|
@@ -3730,7 +3736,7 @@ function createFluidClient(config) {
|
|
|
3730
3736
|
function buildUrl(endpoint, params) {
|
|
3731
3737
|
const normalizedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
3732
3738
|
const normalizedEndpoint = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
|
|
3733
|
-
const url = new URL(normalizedBase + normalizedEndpoint);
|
|
3739
|
+
const url = normalizedBase ? new URL(normalizedBase + normalizedEndpoint) : new URL(normalizedEndpoint, typeof window !== "undefined" ? window.location.origin : "http://localhost");
|
|
3734
3740
|
if (params) for (const [key, value] of Object.entries(params)) {
|
|
3735
3741
|
if (value === void 0 || value === null) continue;
|
|
3736
3742
|
if (Array.isArray(value)) for (const item of value) url.searchParams.append(`${key}[]`, String(item));
|
|
@@ -3754,12 +3760,13 @@ function createFluidClient(config) {
|
|
|
3754
3760
|
async function request(endpoint, options = {}) {
|
|
3755
3761
|
const { method = defaultRequestOptions.method, headers: customHeaders, params, body, signal } = options;
|
|
3756
3762
|
const url = buildUrl(endpoint, method === HTTP_METHODS.GET ? params : void 0);
|
|
3757
|
-
const headers =
|
|
3763
|
+
const headers = buildHeaders(customHeaders);
|
|
3758
3764
|
let response;
|
|
3759
3765
|
try {
|
|
3760
3766
|
const fetchOptions = {
|
|
3761
3767
|
method,
|
|
3762
|
-
headers
|
|
3768
|
+
headers,
|
|
3769
|
+
credentials: "include"
|
|
3763
3770
|
};
|
|
3764
3771
|
if (signal !== void 0) fetchOptions.signal = signal;
|
|
3765
3772
|
if (body && method !== HTTP_METHODS.GET) fetchOptions.body = JSON.stringify(body);
|
|
@@ -3782,9 +3789,9 @@ function createFluidClient(config) {
|
|
|
3782
3789
|
}
|
|
3783
3790
|
if (response.status === 204 || response.headers.get("content-length") === "0") return null;
|
|
3784
3791
|
try {
|
|
3785
|
-
const
|
|
3786
|
-
if (
|
|
3787
|
-
return data;
|
|
3792
|
+
const raw = await response.json();
|
|
3793
|
+
if (raw === null || raw === void 0) throw new ApiError("Unexpected null/undefined in JSON response", response.status, null);
|
|
3794
|
+
return isApiEnvelope(raw) ? raw.data : raw;
|
|
3788
3795
|
} catch (parseError) {
|
|
3789
3796
|
if (isApiError(parseError)) throw parseError;
|
|
3790
3797
|
throw new ApiError("Failed to parse response as JSON", response.status, null);
|
|
@@ -3819,6 +3826,51 @@ function createFluidClient(config) {
|
|
|
3819
3826
|
}
|
|
3820
3827
|
}
|
|
3821
3828
|
/**
|
|
3829
|
+
* Request wrapper for paginated list endpoints.
|
|
3830
|
+
* Parses the API envelope and returns both `data` and cursor pagination metadata.
|
|
3831
|
+
* Falls back gracefully when the response is not an envelope.
|
|
3832
|
+
*/
|
|
3833
|
+
async function requestPaginated(endpoint, options = {}) {
|
|
3834
|
+
const { method = defaultRequestOptions.method, headers: customHeaders, params, body, signal } = options;
|
|
3835
|
+
const url = buildUrl(endpoint, method === HTTP_METHODS.GET ? params : void 0);
|
|
3836
|
+
const headers = buildHeaders(customHeaders);
|
|
3837
|
+
let response;
|
|
3838
|
+
try {
|
|
3839
|
+
const fetchOptions = {
|
|
3840
|
+
method,
|
|
3841
|
+
headers,
|
|
3842
|
+
credentials: "include"
|
|
3843
|
+
};
|
|
3844
|
+
if (signal !== void 0) fetchOptions.signal = signal;
|
|
3845
|
+
if (body && method !== HTTP_METHODS.GET) fetchOptions.body = JSON.stringify(body);
|
|
3846
|
+
response = await fetch(url, fetchOptions);
|
|
3847
|
+
} catch (networkError) {
|
|
3848
|
+
throw new ApiError(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
3849
|
+
}
|
|
3850
|
+
if (response.status === 401) {
|
|
3851
|
+
effectiveOnAuthError();
|
|
3852
|
+
throw new ApiError("Authentication required", 401, null);
|
|
3853
|
+
}
|
|
3854
|
+
if (!response.ok) try {
|
|
3855
|
+
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
3856
|
+
const errorData = await response.json();
|
|
3857
|
+
throw new ApiError(extractErrorMessage(errorData, `${method} request failed`), response.status, "errors" in errorData ? errorData.errors : errorData);
|
|
3858
|
+
} else throw new ApiError(`${method} request failed with status ${response.status}`, response.status, null);
|
|
3859
|
+
} catch (error) {
|
|
3860
|
+
if (isApiError(error)) throw error;
|
|
3861
|
+
throw new ApiError(`${method} request failed with status ${response.status}`, response.status, null);
|
|
3862
|
+
}
|
|
3863
|
+
const raw = await response.json();
|
|
3864
|
+
if (isApiEnvelope(raw)) return {
|
|
3865
|
+
data: raw.data,
|
|
3866
|
+
pagination: raw.meta.pagination
|
|
3867
|
+
};
|
|
3868
|
+
return {
|
|
3869
|
+
data: raw,
|
|
3870
|
+
pagination: void 0
|
|
3871
|
+
};
|
|
3872
|
+
}
|
|
3873
|
+
/**
|
|
3822
3874
|
* Helper to safely convert typed params to Record<string, unknown>.
|
|
3823
3875
|
* Type assertion required: TypeScript's structural typing allows any object
|
|
3824
3876
|
* to be treated as Record<string, unknown> when we only need to iterate
|
|
@@ -3868,11 +3920,17 @@ function createFluidClient(config) {
|
|
|
3868
3920
|
patch,
|
|
3869
3921
|
delete: del,
|
|
3870
3922
|
products: {
|
|
3871
|
-
list: (params) =>
|
|
3923
|
+
list: (params) => requestPaginated("/api/company/v1/products", {
|
|
3924
|
+
method: HTTP_METHODS.GET,
|
|
3925
|
+
params: toParams(params)
|
|
3926
|
+
}),
|
|
3872
3927
|
get: (id) => get(`/api/company/v1/products/${id}`),
|
|
3873
|
-
search: (query, params) =>
|
|
3874
|
-
|
|
3875
|
-
|
|
3928
|
+
search: (query, params) => requestPaginated("/api/company/v1/products", {
|
|
3929
|
+
method: HTTP_METHODS.GET,
|
|
3930
|
+
params: {
|
|
3931
|
+
search_query: query,
|
|
3932
|
+
...toParams(params)
|
|
3933
|
+
}
|
|
3876
3934
|
})
|
|
3877
3935
|
},
|
|
3878
3936
|
orders: {
|
|
@@ -4302,10 +4360,7 @@ const FluidContext = (0, react.createContext)(null);
|
|
|
4302
4360
|
* function App() {
|
|
4303
4361
|
* return (
|
|
4304
4362
|
* <FluidProvider
|
|
4305
|
-
* config={{
|
|
4306
|
-
* baseUrl: "https://api.fluid.app/api",
|
|
4307
|
-
* getAuthToken: () => localStorage.getItem("token"),
|
|
4308
|
-
* }}
|
|
4363
|
+
* config={{ baseUrl: "" }}
|
|
4309
4364
|
* >
|
|
4310
4365
|
* <YourApp />
|
|
4311
4366
|
* </FluidProvider>
|
|
@@ -4334,13 +4389,7 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
|
|
|
4334
4389
|
config: configRef.current
|
|
4335
4390
|
}), [client]);
|
|
4336
4391
|
const getApiHeaders = (0, react.useCallback)(() => {
|
|
4337
|
-
|
|
4338
|
-
const getAuthToken = configRef.current.getAuthToken;
|
|
4339
|
-
if (typeof getAuthToken === "function") {
|
|
4340
|
-
const tokenOrPromise = getAuthToken();
|
|
4341
|
-
if (typeof tokenOrPromise === "string") headers.Authorization = `Bearer ${tokenOrPromise}`;
|
|
4342
|
-
}
|
|
4343
|
-
return headers;
|
|
4392
|
+
return { "Content-Type": "application/json" };
|
|
4344
4393
|
}, []);
|
|
4345
4394
|
const dataSourceBaseUrl = (0, react.useMemo)(() => {
|
|
4346
4395
|
const base = config.baseUrl.replace(/\/+$/, "");
|
|
@@ -4893,4 +4942,4 @@ Object.defineProperty(exports, "widgetPropertySchemas", {
|
|
|
4893
4942
|
}
|
|
4894
4943
|
});
|
|
4895
4944
|
|
|
4896
|
-
//# sourceMappingURL=FluidProvider-
|
|
4945
|
+
//# sourceMappingURL=FluidProvider-CUiOFaDp.cjs.map
|