@fluid-app/portal-sdk 0.1.100 → 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.
Files changed (92) hide show
  1. package/dist/{AppDownloadScreen-rO--O0pk.mjs → AppDownloadScreen-BUyo5t28.mjs} +2 -2
  2. package/dist/{AppDownloadScreen-rO--O0pk.mjs.map → AppDownloadScreen-BUyo5t28.mjs.map} +1 -1
  3. package/dist/{AppDownloadScreen-CwLZzr-7.cjs → AppDownloadScreen-D7TgBBNp.cjs} +2 -2
  4. package/dist/{AppDownloadScreen-BcK2snUL.cjs → AppDownloadScreen-DRXJupWZ.cjs} +2 -2
  5. package/dist/{AppDownloadScreen-BcK2snUL.cjs.map → AppDownloadScreen-DRXJupWZ.cjs.map} +1 -1
  6. package/dist/{ContactsScreen-D4WQ59ib.cjs → ContactsScreen-8yKH9Vmm.cjs} +2 -2
  7. package/dist/{ContactsScreen-BGwqGlpV.mjs → ContactsScreen-CHZ-SGpD.mjs} +2 -2
  8. package/dist/{ContactsScreen-BGwqGlpV.mjs.map → ContactsScreen-CHZ-SGpD.mjs.map} +1 -1
  9. package/dist/{ContactsScreen-CkSeaPyz.cjs → ContactsScreen-DXDkh7cU.cjs} +2 -2
  10. package/dist/{ContactsScreen-CkSeaPyz.cjs.map → ContactsScreen-DXDkh7cU.cjs.map} +1 -1
  11. package/dist/{FluidProvider-CWYquEIF.mjs → FluidProvider-BPFyPU7u.mjs} +81 -32
  12. package/dist/FluidProvider-BPFyPU7u.mjs.map +1 -0
  13. package/dist/{FluidProvider-CyzA2g75.cjs → FluidProvider-CUiOFaDp.cjs} +81 -32
  14. package/dist/FluidProvider-CUiOFaDp.cjs.map +1 -0
  15. package/dist/{MessagingScreen-Cgx3jwpr.cjs → MessagingScreen-CuVoDjwR.cjs} +4 -9
  16. package/dist/MessagingScreen-CuVoDjwR.cjs.map +1 -0
  17. package/dist/{MessagingScreen-84R1a-lD.mjs → MessagingScreen-D2GGSkix.mjs} +2 -3
  18. package/dist/{MessagingScreen-CGS7aG1A.cjs → MessagingScreen-V7ribzpo.cjs} +2 -2
  19. package/dist/{MessagingScreen-CBuI3fu6.mjs → MessagingScreen-pS-W5HIk.mjs} +4 -9
  20. package/dist/MessagingScreen-pS-W5HIk.mjs.map +1 -0
  21. package/dist/{MySiteScreen-Bvyx63pT.mjs → MySiteScreen-CSs9d6TQ.mjs} +2 -2
  22. package/dist/{MySiteScreen-Bvyx63pT.mjs.map → MySiteScreen-CSs9d6TQ.mjs.map} +1 -1
  23. package/dist/{MySiteScreen-BSFb-n7n.cjs → MySiteScreen-DjtoRz-f.cjs} +2 -2
  24. package/dist/{MySiteScreen-BSFb-n7n.cjs.map → MySiteScreen-DjtoRz-f.cjs.map} +1 -1
  25. package/dist/{MySiteScreen-2IzxVfpO.cjs → MySiteScreen-DtpHDP-m.cjs} +2 -2
  26. package/dist/{OrdersScreen-Djdeji9g.mjs → OrdersScreen-BUm_cDrS.mjs} +3 -3
  27. package/dist/{OrdersScreen-Djdeji9g.mjs.map → OrdersScreen-BUm_cDrS.mjs.map} +1 -1
  28. package/dist/{OrdersScreen-Bf4o3Kty.cjs → OrdersScreen-DNAtzcu5.cjs} +3 -3
  29. package/dist/{OrdersScreen-Bf4o3Kty.cjs.map → OrdersScreen-DNAtzcu5.cjs.map} +1 -1
  30. package/dist/{OrdersScreen-DCzYEgsP.cjs → OrdersScreen-NSLW9EyM.cjs} +2 -2
  31. package/dist/{ProductsScreen-PJ95OcSX.cjs → ProductsScreen-0K31iqTS.cjs} +4 -4
  32. package/dist/{ProductsScreen-PJ95OcSX.cjs.map → ProductsScreen-0K31iqTS.cjs.map} +1 -1
  33. package/dist/{ProductsScreen-DbHS3p4U.mjs → ProductsScreen-CQlvW2cC.mjs} +3 -7
  34. package/dist/{ProductsScreen-DZnKtPBp.cjs → ProductsScreen-CSgVSuOa.cjs} +3 -3
  35. package/dist/{ProductsScreen-6J79mnIB.mjs → ProductsScreen-Cc5LjAOS.mjs} +4 -4
  36. package/dist/{ProductsScreen-6J79mnIB.mjs.map → ProductsScreen-Cc5LjAOS.mjs.map} +1 -1
  37. package/dist/{ProfileScreen-DtmReqa8.cjs → ProfileScreen-BRSE-yT7.cjs} +3 -3
  38. package/dist/{ProfileScreen-DtmReqa8.cjs.map → ProfileScreen-BRSE-yT7.cjs.map} +1 -1
  39. package/dist/{ProfileScreen-B46jd4Ic.cjs → ProfileScreen-CxLqoYTU.cjs} +2 -2
  40. package/dist/{ProfileScreen-CUsGRCB7.mjs → ProfileScreen-DXdLGjJE.mjs} +3 -3
  41. package/dist/{ProfileScreen-CUsGRCB7.mjs.map → ProfileScreen-DXdLGjJE.mjs.map} +1 -1
  42. package/dist/{ShareablesScreen-Cy7w85IH.mjs → ShareablesScreen-C3ZUhqHP.mjs} +5 -5
  43. package/dist/{ShareablesScreen-Cy7w85IH.mjs.map → ShareablesScreen-C3ZUhqHP.mjs.map} +1 -1
  44. package/dist/{ShareablesScreen-Dk5EQGMa.cjs → ShareablesScreen-TAJ2R5pG.cjs} +3 -3
  45. package/dist/{ShareablesScreen-CVT7u2hN.cjs → ShareablesScreen-baTkO1KB.cjs} +5 -5
  46. package/dist/{ShareablesScreen-CVT7u2hN.cjs.map → ShareablesScreen-baTkO1KB.cjs.map} +1 -1
  47. package/dist/{ShareablesScreen-DUpaH8VU.mjs → ShareablesScreen-h02BeiT8.mjs} +3 -7
  48. package/dist/{ShopScreen-DgBjP_8D.cjs → ShopScreen-BI5rtJQk.cjs} +4 -4
  49. package/dist/{ShopScreen-DgBjP_8D.cjs.map → ShopScreen-BI5rtJQk.cjs.map} +1 -1
  50. package/dist/{ShopScreen-wYtLEGXo.cjs → ShopScreen-BULLgDDI.cjs} +2 -2
  51. package/dist/{ShopScreen-AGvcqUii.mjs → ShopScreen-DJUhx1ly.mjs} +4 -4
  52. package/dist/{ShopScreen-AGvcqUii.mjs.map → ShopScreen-DJUhx1ly.mjs.map} +1 -1
  53. package/dist/{SubscriptionsScreen-BrLlvFJn.cjs → SubscriptionsScreen-BYCEYtcZ.cjs} +3 -3
  54. package/dist/{SubscriptionsScreen-BrLlvFJn.cjs.map → SubscriptionsScreen-BYCEYtcZ.cjs.map} +1 -1
  55. package/dist/{SubscriptionsScreen-C5YWtYfE.mjs → SubscriptionsScreen-CWwp5Po6.mjs} +3 -3
  56. package/dist/{SubscriptionsScreen-C5YWtYfE.mjs.map → SubscriptionsScreen-CWwp5Po6.mjs.map} +1 -1
  57. package/dist/{SubscriptionsScreen-BqOb2kYR.cjs → SubscriptionsScreen-hkhnXy8j.cjs} +2 -2
  58. package/dist/index.cjs +54 -52
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +47 -28
  61. package/dist/index.d.cts.map +1 -1
  62. package/dist/index.d.mts +47 -28
  63. package/dist/index.d.mts.map +1 -1
  64. package/dist/index.mjs +54 -52
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/{src-BrwLqPPh.mjs → src-DjlwUaws.mjs} +40 -12
  67. package/dist/src-DjlwUaws.mjs.map +1 -0
  68. package/dist/{src-Dlsw83js.cjs → src-xEfkv04t.cjs} +40 -12
  69. package/dist/src-xEfkv04t.cjs.map +1 -0
  70. package/dist/{use-account-clients-Dsqx0mKw.mjs → use-account-clients-3pKJ6EI1.mjs} +2 -2
  71. package/dist/{use-account-clients-Dsqx0mKw.mjs.map → use-account-clients-3pKJ6EI1.mjs.map} +1 -1
  72. package/dist/{use-account-clients-CkDfPpCR.cjs → use-account-clients-Bqc-31kE.cjs} +2 -2
  73. package/dist/{use-account-clients-CkDfPpCR.cjs.map → use-account-clients-Bqc-31kE.cjs.map} +1 -1
  74. package/dist/{use-current-user-BMI-LR9t.mjs → use-current-user-BRmRkzNy.mjs} +3 -3
  75. package/dist/{use-current-user-BMI-LR9t.mjs.map → use-current-user-BRmRkzNy.mjs.map} +1 -1
  76. package/dist/{use-current-user-LLJ1GtNB.cjs → use-current-user-DqzI6jzQ.cjs} +3 -3
  77. package/dist/{use-current-user-LLJ1GtNB.cjs.map → use-current-user-DqzI6jzQ.cjs.map} +1 -1
  78. package/dist/{use-customer-account-DZW_YY9d.cjs → use-customer-account-CHspwp0z.cjs} +3 -3
  79. package/dist/{use-customer-account-DZW_YY9d.cjs.map → use-customer-account-CHspwp0z.cjs.map} +1 -1
  80. package/dist/{use-customer-account-DzOD3vLz.mjs → use-customer-account-D83uR5o6.mjs} +3 -3
  81. package/dist/{use-customer-account-DzOD3vLz.mjs.map → use-customer-account-D83uR5o6.mjs.map} +1 -1
  82. package/dist/{use-fluid-api-Kw0AKvCs.cjs → use-fluid-api-CRZCVY8_.cjs} +2 -2
  83. package/dist/{use-fluid-api-Kw0AKvCs.cjs.map → use-fluid-api-CRZCVY8_.cjs.map} +1 -1
  84. package/dist/{use-fluid-api-CaSYWFuj.mjs → use-fluid-api-Cap4tsCe.mjs} +2 -2
  85. package/dist/{use-fluid-api-CaSYWFuj.mjs.map → use-fluid-api-Cap4tsCe.mjs.map} +1 -1
  86. package/package.json +12 -12
  87. package/dist/FluidProvider-CWYquEIF.mjs.map +0 -1
  88. package/dist/FluidProvider-CyzA2g75.cjs.map +0 -1
  89. package/dist/MessagingScreen-CBuI3fu6.mjs.map +0 -1
  90. package/dist/MessagingScreen-Cgx3jwpr.cjs.map +0 -1
  91. package/dist/src-BrwLqPPh.mjs.map +0 -1
  92. package/dist/src-Dlsw83js.cjs.map +0 -1
@@ -55,7 +55,7 @@ var ApiError$1 = class ApiError$1 extends Error {
55
55
  * Creates a configured fetch client instance
56
56
  */
57
57
  function createFetchClient(config) {
58
- const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {} } = config;
58
+ const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {}, credentials } = config;
59
59
  /**
60
60
  * Build headers for a request
61
61
  */
@@ -144,6 +144,7 @@ function createFetchClient(config) {
144
144
  method,
145
145
  headers
146
146
  };
147
+ if (credentials) fetchOptions.credentials = credentials;
147
148
  const serializedBody = body && method !== "GET" ? JSON.stringify(body) : null;
148
149
  if (serializedBody) fetchOptions.body = serializedBody;
149
150
  if (signal) fetchOptions.signal = signal;
@@ -168,6 +169,7 @@ function createFetchClient(config) {
168
169
  headers,
169
170
  body: formData
170
171
  };
172
+ if (credentials) fetchOptions.credentials = credentials;
171
173
  if (signal) fetchOptions.signal = signal;
172
174
  response = await fetch(url, fetchOptions);
173
175
  } catch (networkError) {
@@ -3718,6 +3720,13 @@ function extractErrorMessage(data, fallback) {
3718
3720
  return fallback;
3719
3721
  }
3720
3722
  /**
3723
+ * Type guard to detect whether a parsed JSON value is an API envelope.
3724
+ * Envelopes always have numeric `status` and a `data` key.
3725
+ */
3726
+ function isApiEnvelope(value) {
3727
+ return typeof value === "object" && value !== null && "status" in value && typeof value.status === "number" && "data" in value;
3728
+ }
3729
+ /**
3721
3730
  * Creates a configured Fluid API client instance
3722
3731
  */
3723
3732
  function createFluidClient(config) {
@@ -3727,22 +3736,19 @@ function createFluidClient(config) {
3727
3736
  baseUrl,
3728
3737
  ...getAuthToken ? { getAuthToken } : {},
3729
3738
  onAuthError: effectiveOnAuthError,
3730
- defaultHeaders
3739
+ defaultHeaders,
3740
+ credentials: "include"
3731
3741
  });
3732
3742
  /**
3733
- * Build headers for a request
3743
+ * Build headers for a request.
3744
+ * Auth is handled by session cookies via `credentials: 'include'` on fetch calls.
3734
3745
  */
3735
- async function buildHeaders(customHeaders) {
3736
- const headers = {
3746
+ function buildHeaders(customHeaders) {
3747
+ return {
3737
3748
  "Content-Type": "application/json",
3738
3749
  ...defaultHeaders,
3739
3750
  ...customHeaders
3740
3751
  };
3741
- if (getAuthToken) {
3742
- const token = await getAuthToken();
3743
- if (token) headers.Authorization = `Bearer ${token}`;
3744
- }
3745
- return headers;
3746
3752
  }
3747
3753
  /**
3748
3754
  * Build URL with query parameters (Rails-compatible)
@@ -3750,7 +3756,7 @@ function createFluidClient(config) {
3750
3756
  function buildUrl(endpoint, params) {
3751
3757
  const normalizedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
3752
3758
  const normalizedEndpoint = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
3753
- const url = new URL(normalizedBase + normalizedEndpoint);
3759
+ const url = normalizedBase ? new URL(normalizedBase + normalizedEndpoint) : new URL(normalizedEndpoint, typeof window !== "undefined" ? window.location.origin : "http://localhost");
3754
3760
  if (params) for (const [key, value] of Object.entries(params)) {
3755
3761
  if (value === void 0 || value === null) continue;
3756
3762
  if (Array.isArray(value)) for (const item of value) url.searchParams.append(`${key}[]`, String(item));
@@ -3774,12 +3780,13 @@ function createFluidClient(config) {
3774
3780
  async function request(endpoint, options = {}) {
3775
3781
  const { method = defaultRequestOptions.method, headers: customHeaders, params, body, signal } = options;
3776
3782
  const url = buildUrl(endpoint, method === HTTP_METHODS.GET ? params : void 0);
3777
- const headers = await buildHeaders(customHeaders);
3783
+ const headers = buildHeaders(customHeaders);
3778
3784
  let response;
3779
3785
  try {
3780
3786
  const fetchOptions = {
3781
3787
  method,
3782
- headers
3788
+ headers,
3789
+ credentials: "include"
3783
3790
  };
3784
3791
  if (signal !== void 0) fetchOptions.signal = signal;
3785
3792
  if (body && method !== HTTP_METHODS.GET) fetchOptions.body = JSON.stringify(body);
@@ -3802,9 +3809,9 @@ function createFluidClient(config) {
3802
3809
  }
3803
3810
  if (response.status === 204 || response.headers.get("content-length") === "0") return null;
3804
3811
  try {
3805
- const data = await response.json();
3806
- if (data === null || data === void 0) throw new ApiError("Unexpected null/undefined in JSON response", response.status, null);
3807
- return data;
3812
+ const raw = await response.json();
3813
+ if (raw === null || raw === void 0) throw new ApiError("Unexpected null/undefined in JSON response", response.status, null);
3814
+ return isApiEnvelope(raw) ? raw.data : raw;
3808
3815
  } catch (parseError) {
3809
3816
  if (isApiError(parseError)) throw parseError;
3810
3817
  throw new ApiError("Failed to parse response as JSON", response.status, null);
@@ -3839,6 +3846,51 @@ function createFluidClient(config) {
3839
3846
  }
3840
3847
  }
3841
3848
  /**
3849
+ * Request wrapper for paginated list endpoints.
3850
+ * Parses the API envelope and returns both `data` and cursor pagination metadata.
3851
+ * Falls back gracefully when the response is not an envelope.
3852
+ */
3853
+ async function requestPaginated(endpoint, options = {}) {
3854
+ const { method = defaultRequestOptions.method, headers: customHeaders, params, body, signal } = options;
3855
+ const url = buildUrl(endpoint, method === HTTP_METHODS.GET ? params : void 0);
3856
+ const headers = buildHeaders(customHeaders);
3857
+ let response;
3858
+ try {
3859
+ const fetchOptions = {
3860
+ method,
3861
+ headers,
3862
+ credentials: "include"
3863
+ };
3864
+ if (signal !== void 0) fetchOptions.signal = signal;
3865
+ if (body && method !== HTTP_METHODS.GET) fetchOptions.body = JSON.stringify(body);
3866
+ response = await fetch(url, fetchOptions);
3867
+ } catch (networkError) {
3868
+ throw new ApiError(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
3869
+ }
3870
+ if (response.status === 401) {
3871
+ effectiveOnAuthError();
3872
+ throw new ApiError("Authentication required", 401, null);
3873
+ }
3874
+ if (!response.ok) try {
3875
+ if (response.headers.get("content-type")?.includes("application/json")) {
3876
+ const errorData = await response.json();
3877
+ throw new ApiError(extractErrorMessage(errorData, `${method} request failed`), response.status, "errors" in errorData ? errorData.errors : errorData);
3878
+ } else throw new ApiError(`${method} request failed with status ${response.status}`, response.status, null);
3879
+ } catch (error) {
3880
+ if (isApiError(error)) throw error;
3881
+ throw new ApiError(`${method} request failed with status ${response.status}`, response.status, null);
3882
+ }
3883
+ const raw = await response.json();
3884
+ if (isApiEnvelope(raw)) return {
3885
+ data: raw.data,
3886
+ pagination: raw.meta.pagination
3887
+ };
3888
+ return {
3889
+ data: raw,
3890
+ pagination: void 0
3891
+ };
3892
+ }
3893
+ /**
3842
3894
  * Helper to safely convert typed params to Record<string, unknown>.
3843
3895
  * Type assertion required: TypeScript's structural typing allows any object
3844
3896
  * to be treated as Record<string, unknown> when we only need to iterate
@@ -3888,11 +3940,17 @@ function createFluidClient(config) {
3888
3940
  patch,
3889
3941
  delete: del,
3890
3942
  products: {
3891
- list: (params) => get("/api/company/v1/products", params),
3943
+ list: (params) => requestPaginated("/api/company/v1/products", {
3944
+ method: HTTP_METHODS.GET,
3945
+ params: toParams(params)
3946
+ }),
3892
3947
  get: (id) => get(`/api/company/v1/products/${id}`),
3893
- search: (query, params) => get("/api/company/v1/products", {
3894
- search_query: query,
3895
- ...params
3948
+ search: (query, params) => requestPaginated("/api/company/v1/products", {
3949
+ method: HTTP_METHODS.GET,
3950
+ params: {
3951
+ search_query: query,
3952
+ ...toParams(params)
3953
+ }
3896
3954
  })
3897
3955
  },
3898
3956
  orders: {
@@ -4322,10 +4380,7 @@ const FluidContext = createContext(null);
4322
4380
  * function App() {
4323
4381
  * return (
4324
4382
  * <FluidProvider
4325
- * config={{
4326
- * baseUrl: "https://api.fluid.app/api",
4327
- * getAuthToken: () => localStorage.getItem("token"),
4328
- * }}
4383
+ * config={{ baseUrl: "" }}
4329
4384
  * >
4330
4385
  * <YourApp />
4331
4386
  * </FluidProvider>
@@ -4354,13 +4409,7 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
4354
4409
  config: configRef.current
4355
4410
  }), [client]);
4356
4411
  const getApiHeaders = useCallback(() => {
4357
- const headers = { "Content-Type": "application/json" };
4358
- const getAuthToken = configRef.current.getAuthToken;
4359
- if (typeof getAuthToken === "function") {
4360
- const tokenOrPromise = getAuthToken();
4361
- if (typeof tokenOrPromise === "string") headers.Authorization = `Bearer ${tokenOrPromise}`;
4362
- }
4363
- return headers;
4412
+ return { "Content-Type": "application/json" };
4364
4413
  }, []);
4365
4414
  const dataSourceBaseUrl = useMemo(() => {
4366
4415
  const base = config.baseUrl.replace(/\/+$/, "");
@@ -4458,4 +4507,4 @@ function useFluidContext() {
4458
4507
  //#endregion
4459
4508
  export { extractTokenFromUrl as $, DEFAULT_FONT_SIZES as A, mergeDarkOverrides as B, buildThemeDefinition as C, serialiseTheme as D, deserialiseTheme as E, getDefaultThemeDefinition as F, RADIUS_KEYS as G, resolveTheme as H, generateThemeCSS as I, DEFAULT_AUTH_URL as J, SEMANTIC_COLOR_NAMES as K, deriveDarkVariant as L, DEFAULT_SPACING as M, DEFAULT_THEME_ID as N, DEFAULT_COLORS as O, DEFAULT_THEME_NAME as P, extractCompanyTokenFromUrl as Q, generateShades as R, removeTheme as S, createFetchClient as St, transformThemes as T, FONT_FAMILY_KEYS as U, parseColor as V, FONT_SIZE_KEYS as W, cleanTokenFromUrl as X, createDefaultAuthRedirect as Y, extractAllTokensFromUrl as Z, toNavigationItem as _, createPersister as _t, createScreen as a, decodeToken as at, applyTheme as b, useFluidPayApi as bt, FluidAuthProvider as c, isTokenExpired as ct, useThemeContext as d, AUTH_CONSTANTS as dt, hasTokenInUrl as et, ApiError as f, STORAGE_KEYS as ft, transformManifestToRepAppData as g, useFluidOsApiOptional as gt, toRawManifest as h, isUserType as ht, widgetPropertySchemas as i, storeToken as it, DEFAULT_RADII as j, DEFAULT_FONT_FAMILIES as k, useFluidAuthContext as l, isValidToken as lt, isApiError as m, USER_TYPES as mt, useFluidContext as n, getStoredToken as nt, createWidgetFromShareable as o, getTokenExpiration as ot, createFluidClient as p, URL_PARAMS as pt, SHADE_STEPS as q, DEFAULT_SDK_WIDGET_REGISTRY as r, hasStoredToken as rt, createWidgetRegistry as s, getTokenTimeRemaining as st, FluidProvider as t, clearTokens as tt, FluidThemeProvider as u, validateToken as ut, normalizeComponentTree as v, deleteDatabase as vt, getActiveThemeId as w, removeAllThemes as x, ApiError$1 as xt, toScreenDefinition as y, useCountryStates as yt, getForegroundColor as z };
4460
4509
 
4461
- //# sourceMappingURL=FluidProvider-CWYquEIF.mjs.map
4510
+ //# sourceMappingURL=FluidProvider-BPFyPU7u.mjs.map