@fluid-app/portal-sdk 0.1.129 → 0.1.130
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-DTxo4z3_.cjs → AppDownloadScreen-ChKim_6A.cjs} +2 -2
- package/dist/{AppDownloadScreen-DTxo4z3_.cjs.map → AppDownloadScreen-ChKim_6A.cjs.map} +1 -1
- package/dist/{AppDownloadScreen-BoGSdsJk.mjs → AppDownloadScreen-DGHd6hYM.mjs} +2 -2
- package/dist/{AppDownloadScreen-BoGSdsJk.mjs.map → AppDownloadScreen-DGHd6hYM.mjs.map} +1 -1
- package/dist/{AppDownloadScreen-Chxavsr_.cjs → AppDownloadScreen-DpyV1tJw.cjs} +2 -2
- package/dist/{ContactsScreen-BKOHursc.mjs → ContactsScreen-Bcea6126.mjs} +3 -3
- package/dist/{ContactsScreen-BKOHursc.mjs.map → ContactsScreen-Bcea6126.mjs.map} +1 -1
- package/dist/{ContactsScreen-DN8Qt2Ih.cjs → ContactsScreen-CsIGZaWy.cjs} +4 -4
- package/dist/{ContactsScreen-DN8Qt2Ih.cjs.map → ContactsScreen-CsIGZaWy.cjs.map} +1 -1
- package/dist/{ContactsScreen-FrVLbjGO.cjs → ContactsScreen-OBDC1046.cjs} +4 -4
- package/dist/{FluidProvider-CgTeGUnF.mjs → FluidProvider-BJQSXofR.mjs} +198 -615
- package/dist/FluidProvider-BJQSXofR.mjs.map +1 -0
- package/dist/{FluidProvider-BMMu_rp3.cjs → FluidProvider-DvqnkjZI.cjs} +196 -625
- package/dist/FluidProvider-DvqnkjZI.cjs.map +1 -0
- package/dist/{MessagingScreen-Bvq3Dd5i.mjs → MessagingScreen-B48ksZOJ.mjs} +3 -3
- package/dist/{MessagingScreen-Bvq3Dd5i.mjs.map → MessagingScreen-B48ksZOJ.mjs.map} +1 -1
- package/dist/{MessagingScreen-DMDXiH97.mjs → MessagingScreen-COGo4S9K.mjs} +2 -2
- package/dist/{MessagingScreen-DgbNN4BF.cjs → MessagingScreen-DYgiatey.cjs} +3 -3
- package/dist/{MessagingScreen-DgbNN4BF.cjs.map → MessagingScreen-DYgiatey.cjs.map} +1 -1
- package/dist/{MessagingScreen-bzzXjQMu.cjs → MessagingScreen-QyUOxYXl.cjs} +2 -2
- package/dist/{MySiteScreen-nV8x9xyy.cjs → MySiteScreen-ByIJ6CkU.cjs} +2 -2
- package/dist/{MySiteScreen-nV8x9xyy.cjs.map → MySiteScreen-ByIJ6CkU.cjs.map} +1 -1
- package/dist/{MySiteScreen-BJH5-RNT.mjs → MySiteScreen-DZ0ru6Bn.mjs} +2 -2
- package/dist/{MySiteScreen-BJH5-RNT.mjs.map → MySiteScreen-DZ0ru6Bn.mjs.map} +1 -1
- package/dist/{MySiteScreen-CYZpUYTn.cjs → MySiteScreen-DrWUJJiH.cjs} +2 -2
- package/dist/{OrdersScreen-BL__flBE.cjs → OrdersScreen-CkvoeTvK.cjs} +3 -3
- package/dist/OrdersScreen-D_7TJgZ4.mjs +561 -0
- package/dist/OrdersScreen-D_7TJgZ4.mjs.map +1 -0
- package/dist/OrdersScreen-DyYYjl9I.cjs +568 -0
- package/dist/OrdersScreen-DyYYjl9I.cjs.map +1 -0
- package/dist/{ProductsScreen-BIYHPaBZ.cjs → ProductsScreen-B8NmyIJy.cjs} +3 -3
- package/dist/{ProductsScreen-COwahI-V.mjs → ProductsScreen-CMnhqsSA.mjs} +5 -5
- package/dist/{ProductsScreen-COwahI-V.mjs.map → ProductsScreen-CMnhqsSA.mjs.map} +1 -1
- package/dist/{ProductsScreen-D6h-r9ht.mjs → ProductsScreen-DzNmbwVi.mjs} +3 -3
- package/dist/{ProductsScreen-C8UfVLRr.cjs → ProductsScreen-Z1hx1YZQ.cjs} +5 -5
- package/dist/{ProductsScreen-C8UfVLRr.cjs.map → ProductsScreen-Z1hx1YZQ.cjs.map} +1 -1
- package/dist/{ProfileScreen-CZp_NrjO.cjs → ProfileScreen-B81Ovmh_.cjs} +2 -2
- package/dist/{ProfileScreen-FYGHStqM.cjs → ProfileScreen-CYTxOGeW.cjs} +526 -137
- package/dist/ProfileScreen-CYTxOGeW.cjs.map +1 -0
- package/dist/{ProfileScreen-BKRn8AqI.mjs → ProfileScreen-QOXtyrJi.mjs} +522 -133
- package/dist/ProfileScreen-QOXtyrJi.mjs.map +1 -0
- package/dist/{ShareablesScreen-BEPVTMeI.cjs → ShareablesScreen-1HpfEjyd.cjs} +7 -7
- package/dist/{ShareablesScreen-BEPVTMeI.cjs.map → ShareablesScreen-1HpfEjyd.cjs.map} +1 -1
- package/dist/{ShareablesScreen-BrC5LGtU.cjs → ShareablesScreen-BXO8MpAy.cjs} +3 -3
- package/dist/{ShareablesScreen-BXzxUg0E.mjs → ShareablesScreen-DSsMJJh_.mjs} +7 -7
- package/dist/{ShareablesScreen-BXzxUg0E.mjs.map → ShareablesScreen-DSsMJJh_.mjs.map} +1 -1
- package/dist/{ShareablesScreen-aMnwEOAH.mjs → ShareablesScreen-Oo3jMHX6.mjs} +3 -3
- package/dist/{ShopScreen-CHH0cx2P.cjs → ShopScreen-BDcWpmi7.cjs} +4 -4
- package/dist/{ShopScreen-CHH0cx2P.cjs.map → ShopScreen-BDcWpmi7.cjs.map} +1 -1
- package/dist/{ShopScreen-8OQhLeLt.cjs → ShopScreen-CWxOPn7H.cjs} +2 -2
- package/dist/{ShopScreen-Yi9sOX_2.mjs → ShopScreen-DsReuJ7P.mjs} +4 -4
- package/dist/{ShopScreen-Yi9sOX_2.mjs.map → ShopScreen-DsReuJ7P.mjs.map} +1 -1
- package/dist/{SubscriptionsScreen-oApGaq11.cjs → SubscriptionsScreen-B8mLGt5-.cjs} +27 -10
- package/dist/SubscriptionsScreen-B8mLGt5-.cjs.map +1 -0
- package/dist/{SubscriptionsScreen-C2F3HNJS.cjs → SubscriptionsScreen-C2zbEjMC.cjs} +4 -4
- package/dist/{SubscriptionsScreen-CZ-1jSO2.mjs → SubscriptionsScreen-DZxLo4up.mjs} +21 -4
- package/dist/SubscriptionsScreen-DZxLo4up.mjs.map +1 -0
- package/dist/index.cjs +37 -37
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +37 -37
- package/dist/order-status-badge-KooNqnAs.mjs +262 -0
- package/dist/order-status-badge-KooNqnAs.mjs.map +1 -0
- package/dist/order-status-badge-cwqA8dZ-.cjs +304 -0
- package/dist/order-status-badge-cwqA8dZ-.cjs.map +1 -0
- package/dist/portal_tenant-CP5Ce8Jn.cjs +261 -0
- package/dist/portal_tenant-CP5Ce8Jn.cjs.map +1 -0
- package/dist/portal_tenant-CWy4Zg2t.mjs +166 -0
- package/dist/portal_tenant-CWy4Zg2t.mjs.map +1 -0
- package/dist/src-BOIW-KES.mjs +3 -0
- package/dist/src-CzwiFO_J.cjs +3 -0
- package/dist/{src-BMUEjfhg.mjs → src-Dgo44BGe.mjs} +1 -1
- package/dist/{src-BMUEjfhg.mjs.map → src-Dgo44BGe.mjs.map} +1 -1
- package/dist/{src-BJdOxgpp.cjs → src-DkhHoxnS.cjs} +1 -1
- package/dist/{src-BJdOxgpp.cjs.map → src-DkhHoxnS.cjs.map} +1 -1
- package/dist/use-account-clients-Dim60sir.mjs +451 -0
- package/dist/use-account-clients-Dim60sir.mjs.map +1 -0
- package/dist/use-account-clients-DoJW3KTx.cjs +481 -0
- package/dist/use-account-clients-DoJW3KTx.cjs.map +1 -0
- package/dist/{use-current-user-DCk55_Qn.mjs → use-current-user-Baxj7HJt.mjs} +3 -3
- package/dist/{use-current-user-DCk55_Qn.mjs.map → use-current-user-Baxj7HJt.mjs.map} +1 -1
- package/dist/{use-current-user-BR5_zaoZ.cjs → use-current-user-BcZWV7oU.cjs} +3 -3
- package/dist/{use-current-user-BR5_zaoZ.cjs.map → use-current-user-BcZWV7oU.cjs.map} +1 -1
- package/dist/{use-fluid-api-CmCAH10d.mjs → use-fluid-api-BP05Cf-f.mjs} +2 -2
- package/dist/{use-fluid-api-CmCAH10d.mjs.map → use-fluid-api-BP05Cf-f.mjs.map} +1 -1
- package/dist/{use-fluid-api-C1KeHB7q.cjs → use-fluid-api-Ds8BInAZ.cjs} +2 -2
- package/dist/{use-fluid-api-C1KeHB7q.cjs.map → use-fluid-api-Ds8BInAZ.cjs.map} +1 -1
- package/dist/{use-fluid-auth-BQEV7ylM.mjs → use-fluid-auth-C-Qpl8j4.mjs} +2 -2
- package/dist/{use-fluid-auth-BQEV7ylM.mjs.map → use-fluid-auth-C-Qpl8j4.mjs.map} +1 -1
- package/dist/{use-fluid-auth-CyKaXLbW.cjs → use-fluid-auth-sGNMgfnt.cjs} +2 -2
- package/dist/{use-fluid-auth-CyKaXLbW.cjs.map → use-fluid-auth-sGNMgfnt.cjs.map} +1 -1
- package/dist/{use-portal-products-client-pptYMuSw.cjs → use-portal-products-client-DKYkBjm-.cjs} +7 -48
- package/dist/use-portal-products-client-DKYkBjm-.cjs.map +1 -0
- package/dist/{use-portal-products-client-BL1xVtex.mjs → use-portal-products-client-s2qtZjhU.mjs} +3 -44
- package/dist/use-portal-products-client-s2qtZjhU.mjs.map +1 -0
- package/package.json +13 -12
- package/dist/FluidProvider-BMMu_rp3.cjs.map +0 -1
- package/dist/FluidProvider-CgTeGUnF.mjs.map +0 -1
- package/dist/OrdersScreen-BLb3_KtI.mjs +0 -176
- package/dist/OrdersScreen-BLb3_KtI.mjs.map +0 -1
- package/dist/OrdersScreen-uL3mRk1h.cjs +0 -183
- package/dist/OrdersScreen-uL3mRk1h.cjs.map +0 -1
- package/dist/ProfileScreen-BKRn8AqI.mjs.map +0 -1
- package/dist/ProfileScreen-FYGHStqM.cjs.map +0 -1
- package/dist/SubscriptionsScreen-CZ-1jSO2.mjs.map +0 -1
- package/dist/SubscriptionsScreen-oApGaq11.cjs.map +0 -1
- package/dist/order-detail-DHXdE4Cl.cjs +0 -961
- package/dist/order-detail-DHXdE4Cl.cjs.map +0 -1
- package/dist/order-detail-iZm_R0TX.mjs +0 -931
- package/dist/order-detail-iZm_R0TX.mjs.map +0 -1
- package/dist/src-BJSTFxSO.mjs +0 -1
- package/dist/src-DMVR26Fk.cjs +0 -1
- package/dist/use-account-clients-CL6rr17o.cjs +0 -214
- package/dist/use-account-clients-CL6rr17o.cjs.map +0 -1
- package/dist/use-account-clients-CMjRB5On.mjs +0 -190
- package/dist/use-account-clients-CMjRB5On.mjs.map +0 -1
- package/dist/use-customer-account-BAolVc3q.mjs +0 -22
- package/dist/use-customer-account-BAolVc3q.mjs.map +0 -1
- package/dist/use-customer-account-DSsXbcme.cjs +0 -28
- package/dist/use-customer-account-DSsXbcme.cjs.map +0 -1
- package/dist/use-portal-products-client-BL1xVtex.mjs.map +0 -1
- package/dist/use-portal-products-client-pptYMuSw.cjs.map +0 -1
|
@@ -24,577 +24,10 @@ import { t as TableWidget } from "./TableWidget-BdweC58Z.mjs";
|
|
|
24
24
|
import { t as ToDoWidget } from "./ToDoWidget-D52-GT7f.mjs";
|
|
25
25
|
import { t as VideoWidget } from "./VideoWidget-pKCO_EOy.mjs";
|
|
26
26
|
import { createContext, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
27
|
-
import { QueryClient, QueryClientProvider
|
|
27
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
28
28
|
import { jsx } from "react/jsx-runtime";
|
|
29
29
|
import { z } from "zod";
|
|
30
30
|
import Color from "colorjs.io";
|
|
31
|
-
//#region ../../platform/api-client-core/src/fetch-client.ts
|
|
32
|
-
/**
|
|
33
|
-
* API Error class compatible with fluid-admin's ApiError
|
|
34
|
-
*/
|
|
35
|
-
var ApiError$1 = class ApiError$1 extends Error {
|
|
36
|
-
status;
|
|
37
|
-
data;
|
|
38
|
-
constructor(message, status, data) {
|
|
39
|
-
super(message);
|
|
40
|
-
this.name = "ApiError";
|
|
41
|
-
this.status = status;
|
|
42
|
-
this.data = data;
|
|
43
|
-
if ("captureStackTrace" in Error) Error.captureStackTrace(this, ApiError$1);
|
|
44
|
-
}
|
|
45
|
-
toJSON() {
|
|
46
|
-
return {
|
|
47
|
-
name: this.name,
|
|
48
|
-
message: this.message,
|
|
49
|
-
status: this.status,
|
|
50
|
-
data: this.data
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Creates a configured fetch client instance
|
|
56
|
-
*/
|
|
57
|
-
function createFetchClient(config) {
|
|
58
|
-
const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {}, credentials } = config;
|
|
59
|
-
/**
|
|
60
|
-
* Build headers for a request
|
|
61
|
-
*/
|
|
62
|
-
async function buildHeaders(customHeaders) {
|
|
63
|
-
const headers = {
|
|
64
|
-
Accept: "application/json",
|
|
65
|
-
"Content-Type": "application/json",
|
|
66
|
-
...defaultHeaders,
|
|
67
|
-
...customHeaders
|
|
68
|
-
};
|
|
69
|
-
if (getAuthToken) {
|
|
70
|
-
const token = await getAuthToken();
|
|
71
|
-
if (token) headers.Authorization = `Bearer ${token}`;
|
|
72
|
-
}
|
|
73
|
-
return headers;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Join baseUrl + endpoint via string concatenation (matches fetchApi).
|
|
77
|
-
* Using `new URL(endpoint, baseUrl)` would strip any path prefix from
|
|
78
|
-
* baseUrl (e.g. "/api") when the endpoint starts with "/".
|
|
79
|
-
*/
|
|
80
|
-
function joinUrl(endpoint) {
|
|
81
|
-
return `${baseUrl}${endpoint}`;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Build URL with query parameters for GET requests
|
|
85
|
-
* Compatible with fluid-admin's query param handling
|
|
86
|
-
*/
|
|
87
|
-
function buildUrl(endpoint, params) {
|
|
88
|
-
const fullUrl = joinUrl(endpoint);
|
|
89
|
-
if (!params || Object.keys(params).length === 0) return fullUrl;
|
|
90
|
-
const queryString = new URLSearchParams();
|
|
91
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
92
|
-
if (value === void 0 || value === null) return;
|
|
93
|
-
if (Array.isArray(value)) value.forEach((item) => queryString.append(`${key}[]`, String(item)));
|
|
94
|
-
else if (typeof value === "object") Object.entries(value).forEach(([subKey, subValue]) => {
|
|
95
|
-
if (subValue === void 0 || subValue === null) return;
|
|
96
|
-
if (Array.isArray(subValue)) subValue.forEach((item) => queryString.append(`${key}[${subKey}][]`, String(item)));
|
|
97
|
-
else queryString.append(`${key}[${subKey}]`, String(subValue));
|
|
98
|
-
});
|
|
99
|
-
else queryString.append(key, String(value));
|
|
100
|
-
});
|
|
101
|
-
const qs = queryString.toString();
|
|
102
|
-
return qs ? `${fullUrl}?${qs}` : fullUrl;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Shared response handler for both JSON and FormData requests.
|
|
106
|
-
* Handles auth errors, non-OK responses, 204 No Content, and JSON parsing.
|
|
107
|
-
*/
|
|
108
|
-
async function handleResponse(response, method, _url) {
|
|
109
|
-
if (response.status === 401 && onAuthError) onAuthError();
|
|
110
|
-
if (!response.ok) {
|
|
111
|
-
const errorText = await response.text().catch(() => "");
|
|
112
|
-
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
113
|
-
let data;
|
|
114
|
-
try {
|
|
115
|
-
data = JSON.parse(errorText);
|
|
116
|
-
} catch {
|
|
117
|
-
throw new ApiError$1(errorText.slice(0, 200) || `${method} request failed with status ${response.status}`, response.status, null);
|
|
118
|
-
}
|
|
119
|
-
throw new ApiError$1(data.message || data.error_message || `${method} request failed`, response.status, data.errors || data);
|
|
120
|
-
} else throw new ApiError$1(`${method} request failed with status ${response.status}`, response.status, null);
|
|
121
|
-
}
|
|
122
|
-
if (response.status === 204 || response.headers.get("content-length") === "0") return null;
|
|
123
|
-
if (response.headers.get("content-type")?.includes("application/json")) try {
|
|
124
|
-
return await response.json();
|
|
125
|
-
} catch {
|
|
126
|
-
try {
|
|
127
|
-
return await response.text();
|
|
128
|
-
} catch {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Main request function
|
|
136
|
-
*/
|
|
137
|
-
async function request(endpoint, options = {}) {
|
|
138
|
-
const { method = "GET", headers: customHeaders, params, body, signal } = options;
|
|
139
|
-
const url = params ? buildUrl(endpoint, params) : joinUrl(endpoint);
|
|
140
|
-
const headers = await buildHeaders(customHeaders);
|
|
141
|
-
let response;
|
|
142
|
-
try {
|
|
143
|
-
const fetchOptions = {
|
|
144
|
-
method,
|
|
145
|
-
headers
|
|
146
|
-
};
|
|
147
|
-
if (credentials) fetchOptions.credentials = credentials;
|
|
148
|
-
const serializedBody = body && method !== "GET" ? JSON.stringify(body) : null;
|
|
149
|
-
if (serializedBody) fetchOptions.body = serializedBody;
|
|
150
|
-
if (signal) fetchOptions.signal = signal;
|
|
151
|
-
response = await fetch(url, fetchOptions);
|
|
152
|
-
} catch (networkError) {
|
|
153
|
-
throw new ApiError$1(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
154
|
-
}
|
|
155
|
-
return handleResponse(response, method, url);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Request with FormData (for file uploads)
|
|
159
|
-
*/
|
|
160
|
-
async function requestWithFormData(endpoint, formData, options = {}) {
|
|
161
|
-
const { method = "POST", headers: customHeaders, signal } = options;
|
|
162
|
-
const url = joinUrl(endpoint);
|
|
163
|
-
const headers = await buildHeaders(customHeaders);
|
|
164
|
-
delete headers["Content-Type"];
|
|
165
|
-
let response;
|
|
166
|
-
try {
|
|
167
|
-
const fetchOptions = {
|
|
168
|
-
method,
|
|
169
|
-
headers,
|
|
170
|
-
body: formData
|
|
171
|
-
};
|
|
172
|
-
if (credentials) fetchOptions.credentials = credentials;
|
|
173
|
-
if (signal) fetchOptions.signal = signal;
|
|
174
|
-
response = await fetch(url, fetchOptions);
|
|
175
|
-
} catch (networkError) {
|
|
176
|
-
throw new ApiError$1(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
177
|
-
}
|
|
178
|
-
return handleResponse(response, method, url);
|
|
179
|
-
}
|
|
180
|
-
return {
|
|
181
|
-
request,
|
|
182
|
-
requestWithFormData,
|
|
183
|
-
get: (endpoint, params, options) => request(endpoint, {
|
|
184
|
-
...options,
|
|
185
|
-
method: "GET",
|
|
186
|
-
...params && { params }
|
|
187
|
-
}),
|
|
188
|
-
post: (endpoint, body, options) => request(endpoint, {
|
|
189
|
-
...options,
|
|
190
|
-
method: "POST",
|
|
191
|
-
body
|
|
192
|
-
}),
|
|
193
|
-
put: (endpoint, body, options) => request(endpoint, {
|
|
194
|
-
...options,
|
|
195
|
-
method: "PUT",
|
|
196
|
-
body
|
|
197
|
-
}),
|
|
198
|
-
patch: (endpoint, body, options) => request(endpoint, {
|
|
199
|
-
...options,
|
|
200
|
-
method: "PATCH",
|
|
201
|
-
body
|
|
202
|
-
}),
|
|
203
|
-
delete: (endpoint, options) => request(endpoint, {
|
|
204
|
-
...options,
|
|
205
|
-
method: "DELETE"
|
|
206
|
-
})
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
//#endregion
|
|
210
|
-
//#region ../../fluid-pay/api-client/src/namespaces/customers.ts
|
|
211
|
-
/**
|
|
212
|
-
* Fetch the current customer's account info.
|
|
213
|
-
* Endpoint: GET /fluid_pay/me?jwt={jwt}
|
|
214
|
-
*/
|
|
215
|
-
async function fetchCustomerAccount(client, jwt) {
|
|
216
|
-
return client.get(`/fluid_pay/me`, { jwt });
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Update customer profile (name, phone, language).
|
|
220
|
-
* Endpoint: PATCH /fluid_pay/update_me?jwt={jwt}
|
|
221
|
-
*/
|
|
222
|
-
async function updateCustomer(client, jwt, body) {
|
|
223
|
-
return client.patch(`/fluid_pay/update_me?jwt=${jwt}`, { fluid_pay_account: body });
|
|
224
|
-
}
|
|
225
|
-
//#endregion
|
|
226
|
-
//#region ../../fluid-pay/api-client/src/namespaces/addresses.ts
|
|
227
|
-
/**
|
|
228
|
-
* Fetch all customer addresses.
|
|
229
|
-
* Endpoint: GET /fluid_pay/addresses?jwt={jwt}
|
|
230
|
-
*/
|
|
231
|
-
async function fetchCustomerAddresses(client, jwt) {
|
|
232
|
-
return client.get("/fluid_pay/addresses", {
|
|
233
|
-
jwt,
|
|
234
|
-
page: "1",
|
|
235
|
-
per_page: "100"
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Create a new customer address.
|
|
240
|
-
* Endpoint: POST /fluid_pay/create_address?jwt={jwt}
|
|
241
|
-
*/
|
|
242
|
-
async function createCustomerAddress(client, jwt, body) {
|
|
243
|
-
return client.post(`/fluid_pay/create_address?jwt=${jwt}`, body);
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Update an existing customer address.
|
|
247
|
-
* Endpoint: PATCH /fluid_pay/update_address/{addressId}?jwt={jwt}
|
|
248
|
-
*/
|
|
249
|
-
async function updateCustomerAddress(client, jwt, addressId, body) {
|
|
250
|
-
return client.patch(`/fluid_pay/update_address/${addressId}?jwt=${jwt}`, body);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Delete a customer address.
|
|
254
|
-
* Endpoint: DELETE /fluid_pay/delete_address/{addressId}?jwt={jwt}
|
|
255
|
-
*/
|
|
256
|
-
async function deleteCustomerAddress(client, jwt, addressId) {
|
|
257
|
-
return client.delete(`/fluid_pay/delete_address/${addressId}?jwt=${jwt}`);
|
|
258
|
-
}
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region ../../fluid-pay/api-client/src/namespaces/payment-methods.ts
|
|
261
|
-
/**
|
|
262
|
-
* Fetch all customer payment methods.
|
|
263
|
-
* Endpoint: GET /fluid_pay/payment_methods?jwt={jwt}
|
|
264
|
-
*/
|
|
265
|
-
async function fetchCustomerPaymentMethods(client, jwt, countryCode) {
|
|
266
|
-
const params = {
|
|
267
|
-
jwt,
|
|
268
|
-
page: "1",
|
|
269
|
-
per_page: "100"
|
|
270
|
-
};
|
|
271
|
-
if (countryCode) params.country_code = countryCode;
|
|
272
|
-
return client.get("/fluid_pay/payment_methods", params);
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Add a credit card to the customer's account.
|
|
276
|
-
* Endpoint: POST /fluid_pay/create_payment_method?jwt={jwt}
|
|
277
|
-
*/
|
|
278
|
-
async function addCreditCardToCustomer(client, jwt, data) {
|
|
279
|
-
return client.post(`/fluid_pay/create_payment_method?jwt=${jwt}`, data);
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Delete a customer payment method.
|
|
283
|
-
* Endpoint: DELETE /fluid_pay/delete_payment_method/{id}?jwt={jwt}
|
|
284
|
-
*/
|
|
285
|
-
async function deleteCustomerPaymentMethod(client, jwt, paymentMethodId) {
|
|
286
|
-
return client.delete(`/fluid_pay/delete_payment_method/${paymentMethodId}?jwt=${jwt}`);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Set a payment method as default.
|
|
290
|
-
* Endpoint: PATCH /fluid_pay/update_payment_method/{id}?jwt={jwt}
|
|
291
|
-
*/
|
|
292
|
-
async function updateDefaultPaymentMethod(client, jwt, paymentMethodId) {
|
|
293
|
-
return client.patch(`/fluid_pay/update_payment_method/${paymentMethodId}?jwt=${jwt}`);
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Update a payment method (default status, billing address).
|
|
297
|
-
* Endpoint: PATCH /fluid_pay/update_payment_method/{id}?jwt={jwt}
|
|
298
|
-
*/
|
|
299
|
-
async function updatePaymentMethod(client, jwt, paymentMethodId, body) {
|
|
300
|
-
return client.patch(`/fluid_pay/update_payment_method/${paymentMethodId}?jwt=${jwt}`, body);
|
|
301
|
-
}
|
|
302
|
-
//#endregion
|
|
303
|
-
//#region ../../fluid-pay/api-client/src/namespaces/vault.ts
|
|
304
|
-
/**
|
|
305
|
-
* Fetch VGS vault credentials for the customer's payment account.
|
|
306
|
-
* Endpoint: GET /fluid_pay/vault?jwt={jwt}
|
|
307
|
-
*/
|
|
308
|
-
async function fetchVaultCredentialsForPaymentAccount(client, jwt) {
|
|
309
|
-
return client.get("/fluid_pay/vault", { jwt });
|
|
310
|
-
}
|
|
311
|
-
//#endregion
|
|
312
|
-
//#region ../../fluid-pay/api-client/src/adapter.ts
|
|
313
|
-
function createFluidPayApi(client) {
|
|
314
|
-
return {
|
|
315
|
-
customers: {
|
|
316
|
-
fetchAccount: (jwt) => fetchCustomerAccount(client, jwt),
|
|
317
|
-
update: (jwt, body) => updateCustomer(client, jwt, body)
|
|
318
|
-
},
|
|
319
|
-
addresses: {
|
|
320
|
-
fetchAll: (jwt) => fetchCustomerAddresses(client, jwt),
|
|
321
|
-
create: (jwt, body) => createCustomerAddress(client, jwt, body),
|
|
322
|
-
update: (jwt, addressId, body) => updateCustomerAddress(client, jwt, addressId, body),
|
|
323
|
-
delete: (jwt, addressId) => deleteCustomerAddress(client, jwt, addressId)
|
|
324
|
-
},
|
|
325
|
-
paymentMethods: {
|
|
326
|
-
fetchAll: (jwt, countryCode) => fetchCustomerPaymentMethods(client, jwt, countryCode),
|
|
327
|
-
addCreditCard: (jwt, data) => addCreditCardToCustomer(client, jwt, data),
|
|
328
|
-
delete: (jwt, paymentMethodId) => deleteCustomerPaymentMethod(client, jwt, paymentMethodId),
|
|
329
|
-
updateDefault: (jwt, paymentMethodId) => updateDefaultPaymentMethod(client, jwt, paymentMethodId),
|
|
330
|
-
update: (jwt, paymentMethodId, body) => updatePaymentMethod(client, jwt, paymentMethodId, body)
|
|
331
|
-
},
|
|
332
|
-
vault: { fetchCredentials: (jwt) => fetchVaultCredentialsForPaymentAccount(client, jwt) }
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
//#endregion
|
|
336
|
-
//#region ../../fluid-pay/core/src/context.ts
|
|
337
|
-
const FluidPayApiContext = createContext(null);
|
|
338
|
-
const FluidPayApiProvider = FluidPayApiContext.Provider;
|
|
339
|
-
function useFluidPayApi() {
|
|
340
|
-
const api = useContext(FluidPayApiContext);
|
|
341
|
-
if (!api) throw new Error("useFluidPayApi must be used within a FluidPayCoreProvider");
|
|
342
|
-
return api;
|
|
343
|
-
}
|
|
344
|
-
//#endregion
|
|
345
|
-
//#region ../../fluid-pay/core/src/provider.tsx
|
|
346
|
-
function FluidPayCoreProvider({ api, children }) {
|
|
347
|
-
return /* @__PURE__ */ jsx(FluidPayApiProvider, {
|
|
348
|
-
value: api,
|
|
349
|
-
children
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
//#endregion
|
|
353
|
-
//#region ../../fluid-pay/core/src/utils/country-config.ts
|
|
354
|
-
const US_STATES = [
|
|
355
|
-
{
|
|
356
|
-
name: "Alabama",
|
|
357
|
-
isoCode: "AL"
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
name: "Alaska",
|
|
361
|
-
isoCode: "AK"
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
name: "Arizona",
|
|
365
|
-
isoCode: "AZ"
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
name: "Arkansas",
|
|
369
|
-
isoCode: "AR"
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
name: "California",
|
|
373
|
-
isoCode: "CA"
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
name: "Colorado",
|
|
377
|
-
isoCode: "CO"
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
name: "Connecticut",
|
|
381
|
-
isoCode: "CT"
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
name: "Delaware",
|
|
385
|
-
isoCode: "DE"
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
name: "Florida",
|
|
389
|
-
isoCode: "FL"
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
name: "Georgia",
|
|
393
|
-
isoCode: "GA"
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
name: "Hawaii",
|
|
397
|
-
isoCode: "HI"
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
name: "Idaho",
|
|
401
|
-
isoCode: "ID"
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
name: "Illinois",
|
|
405
|
-
isoCode: "IL"
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
name: "Indiana",
|
|
409
|
-
isoCode: "IN"
|
|
410
|
-
},
|
|
411
|
-
{
|
|
412
|
-
name: "Iowa",
|
|
413
|
-
isoCode: "IA"
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
name: "Kansas",
|
|
417
|
-
isoCode: "KS"
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
name: "Kentucky",
|
|
421
|
-
isoCode: "KY"
|
|
422
|
-
},
|
|
423
|
-
{
|
|
424
|
-
name: "Louisiana",
|
|
425
|
-
isoCode: "LA"
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
name: "Maine",
|
|
429
|
-
isoCode: "ME"
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
name: "Maryland",
|
|
433
|
-
isoCode: "MD"
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
name: "Massachusetts",
|
|
437
|
-
isoCode: "MA"
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
name: "Michigan",
|
|
441
|
-
isoCode: "MI"
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
name: "Minnesota",
|
|
445
|
-
isoCode: "MN"
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
name: "Mississippi",
|
|
449
|
-
isoCode: "MS"
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
name: "Missouri",
|
|
453
|
-
isoCode: "MO"
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
name: "Montana",
|
|
457
|
-
isoCode: "MT"
|
|
458
|
-
},
|
|
459
|
-
{
|
|
460
|
-
name: "Nebraska",
|
|
461
|
-
isoCode: "NE"
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
name: "Nevada",
|
|
465
|
-
isoCode: "NV"
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
name: "New Hampshire",
|
|
469
|
-
isoCode: "NH"
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
name: "New Jersey",
|
|
473
|
-
isoCode: "NJ"
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
name: "New Mexico",
|
|
477
|
-
isoCode: "NM"
|
|
478
|
-
},
|
|
479
|
-
{
|
|
480
|
-
name: "New York",
|
|
481
|
-
isoCode: "NY"
|
|
482
|
-
},
|
|
483
|
-
{
|
|
484
|
-
name: "North Carolina",
|
|
485
|
-
isoCode: "NC"
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
name: "North Dakota",
|
|
489
|
-
isoCode: "ND"
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
name: "Ohio",
|
|
493
|
-
isoCode: "OH"
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
name: "Oklahoma",
|
|
497
|
-
isoCode: "OK"
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
name: "Oregon",
|
|
501
|
-
isoCode: "OR"
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
name: "Pennsylvania",
|
|
505
|
-
isoCode: "PA"
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
name: "Rhode Island",
|
|
509
|
-
isoCode: "RI"
|
|
510
|
-
},
|
|
511
|
-
{
|
|
512
|
-
name: "South Carolina",
|
|
513
|
-
isoCode: "SC"
|
|
514
|
-
},
|
|
515
|
-
{
|
|
516
|
-
name: "South Dakota",
|
|
517
|
-
isoCode: "SD"
|
|
518
|
-
},
|
|
519
|
-
{
|
|
520
|
-
name: "Tennessee",
|
|
521
|
-
isoCode: "TN"
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
name: "Texas",
|
|
525
|
-
isoCode: "TX"
|
|
526
|
-
},
|
|
527
|
-
{
|
|
528
|
-
name: "Utah",
|
|
529
|
-
isoCode: "UT"
|
|
530
|
-
},
|
|
531
|
-
{
|
|
532
|
-
name: "Vermont",
|
|
533
|
-
isoCode: "VT"
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
name: "Virginia",
|
|
537
|
-
isoCode: "VA"
|
|
538
|
-
},
|
|
539
|
-
{
|
|
540
|
-
name: "Washington",
|
|
541
|
-
isoCode: "WA"
|
|
542
|
-
},
|
|
543
|
-
{
|
|
544
|
-
name: "West Virginia",
|
|
545
|
-
isoCode: "WV"
|
|
546
|
-
},
|
|
547
|
-
{
|
|
548
|
-
name: "Wisconsin",
|
|
549
|
-
isoCode: "WI"
|
|
550
|
-
},
|
|
551
|
-
{
|
|
552
|
-
name: "Wyoming",
|
|
553
|
-
isoCode: "WY"
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
name: "District of Columbia",
|
|
557
|
-
isoCode: "DC"
|
|
558
|
-
}
|
|
559
|
-
];
|
|
560
|
-
const COUNTRY_CONFIGS = {
|
|
561
|
-
US: {
|
|
562
|
-
regionLabel: "State",
|
|
563
|
-
postalLabel: "ZIP Code"
|
|
564
|
-
},
|
|
565
|
-
JP: {
|
|
566
|
-
regionLabel: "Prefecture",
|
|
567
|
-
postalLabel: "Postal Code"
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
const DEFAULT_REGION_CONFIG = {
|
|
571
|
-
regionLabel: "Province",
|
|
572
|
-
postalLabel: "Postal Code"
|
|
573
|
-
};
|
|
574
|
-
function getRegionConfig(countryCode) {
|
|
575
|
-
return COUNTRY_CONFIGS[countryCode] ?? DEFAULT_REGION_CONFIG;
|
|
576
|
-
}
|
|
577
|
-
//#endregion
|
|
578
|
-
//#region ../../fluid-pay/core/src/hooks/use-country-states.ts
|
|
579
|
-
function useCountryStates() {
|
|
580
|
-
const [selectedCountry, setSelectedCountry] = useState("US");
|
|
581
|
-
const [stateOptions, setStateOptions] = useState(US_STATES);
|
|
582
|
-
return {
|
|
583
|
-
handleCountryChange: useCallback((selectedCountryCode, fetchStates) => {
|
|
584
|
-
setSelectedCountry(selectedCountryCode);
|
|
585
|
-
if (selectedCountryCode === "US") setStateOptions(US_STATES);
|
|
586
|
-
else if (fetchStates) fetchStates(selectedCountryCode).then((states) => setStateOptions(states)).catch((error) => {
|
|
587
|
-
console.error("Failed to fetch states:", error);
|
|
588
|
-
setStateOptions([]);
|
|
589
|
-
});
|
|
590
|
-
else setStateOptions([]);
|
|
591
|
-
}, []),
|
|
592
|
-
stateOptions,
|
|
593
|
-
config: getRegionConfig(selectedCountry),
|
|
594
|
-
selectedCountry
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
//#endregion
|
|
598
31
|
//#region ../../../node_modules/.pnpm/@tanstack+query-core@5.90.12/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
|
|
599
32
|
var defaultTimeoutProvider = {
|
|
600
33
|
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
@@ -1049,6 +482,185 @@ function useFluidOsApiOptional() {
|
|
|
1049
482
|
return builderApi ?? readApi;
|
|
1050
483
|
}
|
|
1051
484
|
//#endregion
|
|
485
|
+
//#region ../../platform/api-client-core/src/fetch-client.ts
|
|
486
|
+
/**
|
|
487
|
+
* API Error class compatible with fluid-admin's ApiError
|
|
488
|
+
*/
|
|
489
|
+
var ApiError$1 = class ApiError$1 extends Error {
|
|
490
|
+
status;
|
|
491
|
+
data;
|
|
492
|
+
constructor(message, status, data) {
|
|
493
|
+
super(message);
|
|
494
|
+
this.name = "ApiError";
|
|
495
|
+
this.status = status;
|
|
496
|
+
this.data = data;
|
|
497
|
+
if ("captureStackTrace" in Error) Error.captureStackTrace(this, ApiError$1);
|
|
498
|
+
}
|
|
499
|
+
toJSON() {
|
|
500
|
+
return {
|
|
501
|
+
name: this.name,
|
|
502
|
+
message: this.message,
|
|
503
|
+
status: this.status,
|
|
504
|
+
data: this.data
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Creates a configured fetch client instance
|
|
510
|
+
*/
|
|
511
|
+
function createFetchClient(config) {
|
|
512
|
+
const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {}, credentials } = config;
|
|
513
|
+
/**
|
|
514
|
+
* Build headers for a request
|
|
515
|
+
*/
|
|
516
|
+
async function buildHeaders(customHeaders) {
|
|
517
|
+
const headers = {
|
|
518
|
+
Accept: "application/json",
|
|
519
|
+
"Content-Type": "application/json",
|
|
520
|
+
...defaultHeaders,
|
|
521
|
+
...customHeaders
|
|
522
|
+
};
|
|
523
|
+
if (getAuthToken) {
|
|
524
|
+
const token = await getAuthToken();
|
|
525
|
+
if (token) headers.Authorization = `Bearer ${token}`;
|
|
526
|
+
}
|
|
527
|
+
return headers;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Join baseUrl + endpoint via string concatenation (matches fetchApi).
|
|
531
|
+
* Using `new URL(endpoint, baseUrl)` would strip any path prefix from
|
|
532
|
+
* baseUrl (e.g. "/api") when the endpoint starts with "/".
|
|
533
|
+
*/
|
|
534
|
+
function joinUrl(endpoint) {
|
|
535
|
+
return `${baseUrl}${endpoint}`;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Build URL with query parameters for GET requests
|
|
539
|
+
* Compatible with fluid-admin's query param handling
|
|
540
|
+
*/
|
|
541
|
+
function buildUrl(endpoint, params) {
|
|
542
|
+
const fullUrl = joinUrl(endpoint);
|
|
543
|
+
if (!params || Object.keys(params).length === 0) return fullUrl;
|
|
544
|
+
const queryString = new URLSearchParams();
|
|
545
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
546
|
+
if (value === void 0 || value === null) return;
|
|
547
|
+
if (Array.isArray(value)) value.forEach((item) => queryString.append(`${key}[]`, String(item)));
|
|
548
|
+
else if (typeof value === "object") Object.entries(value).forEach(([subKey, subValue]) => {
|
|
549
|
+
if (subValue === void 0 || subValue === null) return;
|
|
550
|
+
if (Array.isArray(subValue)) subValue.forEach((item) => queryString.append(`${key}[${subKey}][]`, String(item)));
|
|
551
|
+
else queryString.append(`${key}[${subKey}]`, String(subValue));
|
|
552
|
+
});
|
|
553
|
+
else queryString.append(key, String(value));
|
|
554
|
+
});
|
|
555
|
+
const qs = queryString.toString();
|
|
556
|
+
return qs ? `${fullUrl}?${qs}` : fullUrl;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Shared response handler for both JSON and FormData requests.
|
|
560
|
+
* Handles auth errors, non-OK responses, 204 No Content, and JSON parsing.
|
|
561
|
+
*/
|
|
562
|
+
async function handleResponse(response, method, _url) {
|
|
563
|
+
if (response.status === 401 && onAuthError) onAuthError();
|
|
564
|
+
if (!response.ok) {
|
|
565
|
+
const errorText = await response.text().catch(() => "");
|
|
566
|
+
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
567
|
+
let data;
|
|
568
|
+
try {
|
|
569
|
+
data = JSON.parse(errorText);
|
|
570
|
+
} catch {
|
|
571
|
+
throw new ApiError$1(errorText.slice(0, 200) || `${method} request failed with status ${response.status}`, response.status, null);
|
|
572
|
+
}
|
|
573
|
+
throw new ApiError$1(data.message || data.error_message || `${method} request failed`, response.status, data.errors || data);
|
|
574
|
+
} else throw new ApiError$1(`${method} request failed with status ${response.status}`, response.status, null);
|
|
575
|
+
}
|
|
576
|
+
if (response.status === 204 || response.headers.get("content-length") === "0") return null;
|
|
577
|
+
if (response.headers.get("content-type")?.includes("application/json")) try {
|
|
578
|
+
return await response.json();
|
|
579
|
+
} catch {
|
|
580
|
+
try {
|
|
581
|
+
return await response.text();
|
|
582
|
+
} catch {
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return null;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Main request function
|
|
590
|
+
*/
|
|
591
|
+
async function request(endpoint, options = {}) {
|
|
592
|
+
const { method = "GET", headers: customHeaders, params, body, signal } = options;
|
|
593
|
+
const url = params ? buildUrl(endpoint, params) : joinUrl(endpoint);
|
|
594
|
+
const headers = await buildHeaders(customHeaders);
|
|
595
|
+
let response;
|
|
596
|
+
try {
|
|
597
|
+
const fetchOptions = {
|
|
598
|
+
method,
|
|
599
|
+
headers
|
|
600
|
+
};
|
|
601
|
+
if (credentials) fetchOptions.credentials = credentials;
|
|
602
|
+
const serializedBody = body && method !== "GET" ? JSON.stringify(body) : null;
|
|
603
|
+
if (serializedBody) fetchOptions.body = serializedBody;
|
|
604
|
+
if (signal) fetchOptions.signal = signal;
|
|
605
|
+
response = await fetch(url, fetchOptions);
|
|
606
|
+
} catch (networkError) {
|
|
607
|
+
throw new ApiError$1(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
608
|
+
}
|
|
609
|
+
return handleResponse(response, method, url);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Request with FormData (for file uploads)
|
|
613
|
+
*/
|
|
614
|
+
async function requestWithFormData(endpoint, formData, options = {}) {
|
|
615
|
+
const { method = "POST", headers: customHeaders, signal } = options;
|
|
616
|
+
const url = joinUrl(endpoint);
|
|
617
|
+
const headers = await buildHeaders(customHeaders);
|
|
618
|
+
delete headers["Content-Type"];
|
|
619
|
+
let response;
|
|
620
|
+
try {
|
|
621
|
+
const fetchOptions = {
|
|
622
|
+
method,
|
|
623
|
+
headers,
|
|
624
|
+
body: formData
|
|
625
|
+
};
|
|
626
|
+
if (credentials) fetchOptions.credentials = credentials;
|
|
627
|
+
if (signal) fetchOptions.signal = signal;
|
|
628
|
+
response = await fetch(url, fetchOptions);
|
|
629
|
+
} catch (networkError) {
|
|
630
|
+
throw new ApiError$1(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
631
|
+
}
|
|
632
|
+
return handleResponse(response, method, url);
|
|
633
|
+
}
|
|
634
|
+
return {
|
|
635
|
+
request,
|
|
636
|
+
requestWithFormData,
|
|
637
|
+
get: (endpoint, params, options) => request(endpoint, {
|
|
638
|
+
...options,
|
|
639
|
+
method: "GET",
|
|
640
|
+
...params && { params }
|
|
641
|
+
}),
|
|
642
|
+
post: (endpoint, body, options) => request(endpoint, {
|
|
643
|
+
...options,
|
|
644
|
+
method: "POST",
|
|
645
|
+
body
|
|
646
|
+
}),
|
|
647
|
+
put: (endpoint, body, options) => request(endpoint, {
|
|
648
|
+
...options,
|
|
649
|
+
method: "PUT",
|
|
650
|
+
body
|
|
651
|
+
}),
|
|
652
|
+
patch: (endpoint, body, options) => request(endpoint, {
|
|
653
|
+
...options,
|
|
654
|
+
method: "PATCH",
|
|
655
|
+
body
|
|
656
|
+
}),
|
|
657
|
+
delete: (endpoint, options) => request(endpoint, {
|
|
658
|
+
...options,
|
|
659
|
+
method: "DELETE"
|
|
660
|
+
})
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
//#endregion
|
|
1052
664
|
//#region ../../api-clients/fluidos/src/namespaces/fluid_os.ts
|
|
1053
665
|
/**
|
|
1054
666
|
* Get active Fluid OS definition
|
|
@@ -2813,11 +2425,13 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
|
|
|
2813
2425
|
onAuthError: () => configRef.current.onAuthError?.()
|
|
2814
2426
|
}), [config.baseUrl]);
|
|
2815
2427
|
const fluidOsApi = useMemo(() => createFluidOsReadAdapter(client.fetchClient), [client.fetchClient]);
|
|
2428
|
+
const csrfToken = typeof document !== "undefined" ? document.querySelector("meta[name=\"csrf-token\"]")?.getAttribute("content") : null;
|
|
2816
2429
|
const portalTenantClient = useMemo(() => createFetchClient({
|
|
2817
2430
|
baseUrl: configRef.current.baseUrl,
|
|
2818
2431
|
onAuthError: () => configRef.current.onAuthError?.(),
|
|
2819
|
-
credentials: "include"
|
|
2820
|
-
|
|
2432
|
+
credentials: "include",
|
|
2433
|
+
defaultHeaders: { ...csrfToken ? { "X-CSRF-Token": csrfToken } : {} }
|
|
2434
|
+
}), [config.baseUrl, csrfToken]);
|
|
2821
2435
|
const contextValue = useMemo(() => ({
|
|
2822
2436
|
client,
|
|
2823
2437
|
config: configRef.current
|
|
@@ -2850,13 +2464,12 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
|
|
|
2850
2464
|
value: portalTenantClient,
|
|
2851
2465
|
children: /* @__PURE__ */ jsx(FluidOsApiProvider, {
|
|
2852
2466
|
value: fluidOsApi,
|
|
2853
|
-
children: /* @__PURE__ */ jsx(
|
|
2467
|
+
children: /* @__PURE__ */ jsx(ProviderStack, {
|
|
2854
2468
|
baseUrl: dataSourceBaseUrl,
|
|
2855
2469
|
getApiHeaders,
|
|
2856
2470
|
variables: effectiveVariables,
|
|
2857
2471
|
registry,
|
|
2858
2472
|
themeProviderProps,
|
|
2859
|
-
onAuthError: config.onAuthError,
|
|
2860
2473
|
children
|
|
2861
2474
|
})
|
|
2862
2475
|
})
|
|
@@ -2865,49 +2478,19 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
|
|
|
2865
2478
|
});
|
|
2866
2479
|
}
|
|
2867
2480
|
/**
|
|
2868
|
-
* Inner component that
|
|
2481
|
+
* Inner component that sets up data source providers and theme.
|
|
2869
2482
|
* Must be rendered inside FluidContext.Provider + QueryClientProvider.
|
|
2870
|
-
* Inlines the customer account fetch to avoid a circular dependency
|
|
2871
|
-
* (FluidProvider → useCustomerAccount → useFluidPayApi → FluidProvider).
|
|
2872
2483
|
*/
|
|
2873
|
-
function
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
onAuthError: () => onAuthErrorRef.current?.()
|
|
2884
|
-
}));
|
|
2885
|
-
}, [baseUrl]);
|
|
2886
|
-
const { data: customerData } = useQuery({
|
|
2887
|
-
queryKey: ["fluidPayAccount", userId],
|
|
2888
|
-
queryFn: () => fluidPayApi.customers.fetchAccount(""),
|
|
2889
|
-
enabled: isAuthenticated
|
|
2890
|
-
});
|
|
2891
|
-
const customerId = customerData?.customer?.id;
|
|
2892
|
-
return /* @__PURE__ */ jsx(FluidPayCoreProvider, {
|
|
2893
|
-
api: fluidPayApi,
|
|
2894
|
-
children: /* @__PURE__ */ jsx(DataSourceRegistryProvider, {
|
|
2895
|
-
baseUrl,
|
|
2896
|
-
getApiHeaders,
|
|
2897
|
-
variables: useMemo(() => {
|
|
2898
|
-
const base = variables ?? {};
|
|
2899
|
-
if (customerId == null) return variables;
|
|
2900
|
-
return {
|
|
2901
|
-
...base,
|
|
2902
|
-
customer_id: String(customerId)
|
|
2903
|
-
};
|
|
2904
|
-
}, [variables, customerId]),
|
|
2905
|
-
children: /* @__PURE__ */ jsx(RegistryProvider, {
|
|
2906
|
-
registry,
|
|
2907
|
-
children: /* @__PURE__ */ jsx(FluidThemeProvider, {
|
|
2908
|
-
...themeProviderProps,
|
|
2909
|
-
children
|
|
2910
|
-
})
|
|
2484
|
+
function ProviderStack({ baseUrl, getApiHeaders, variables, registry, themeProviderProps, children }) {
|
|
2485
|
+
return /* @__PURE__ */ jsx(DataSourceRegistryProvider, {
|
|
2486
|
+
baseUrl,
|
|
2487
|
+
getApiHeaders,
|
|
2488
|
+
variables,
|
|
2489
|
+
children: /* @__PURE__ */ jsx(RegistryProvider, {
|
|
2490
|
+
registry,
|
|
2491
|
+
children: /* @__PURE__ */ jsx(FluidThemeProvider, {
|
|
2492
|
+
...themeProviderProps,
|
|
2493
|
+
children
|
|
2911
2494
|
})
|
|
2912
2495
|
})
|
|
2913
2496
|
});
|
|
@@ -2922,6 +2505,6 @@ function useFluidContext() {
|
|
|
2922
2505
|
return context;
|
|
2923
2506
|
}
|
|
2924
2507
|
//#endregion
|
|
2925
|
-
export { AUTH_CONSTANTS as $, DEFAULT_FONT_FAMILIES as A, getForegroundColor as B, removeTheme as C, deserialiseTheme as D, transformThemes as E, DEFAULT_THEME_NAME as F, FONT_SIZE_KEYS as G, parseColor as H, getDefaultThemeDefinition as I, SHADE_STEPS as J, RADIUS_KEYS as K, generateThemeCSS as L, DEFAULT_RADII as M, DEFAULT_SPACING as N, serialiseTheme as O, DEFAULT_THEME_ID as P, clearTokens as Q, deriveDarkVariant as R, removeAllThemes as S, getActiveThemeId as T, resolveTheme as U, mergeDarkOverrides as V, FONT_FAMILY_KEYS as W, createDefaultAuthRedirect as X, DEFAULT_AUTH_URL as Y, cleanTokenFromUrl as Z, transformManifestToRepAppData as _, createScreen as a,
|
|
2508
|
+
export { AUTH_CONSTANTS as $, DEFAULT_FONT_FAMILIES as A, getForegroundColor as B, removeTheme as C, deserialiseTheme as D, transformThemes as E, DEFAULT_THEME_NAME as F, FONT_SIZE_KEYS as G, parseColor as H, getDefaultThemeDefinition as I, SHADE_STEPS as J, RADIUS_KEYS as K, generateThemeCSS as L, DEFAULT_RADII as M, DEFAULT_SPACING as N, serialiseTheme as O, DEFAULT_THEME_ID as P, clearTokens as Q, deriveDarkVariant as R, removeAllThemes as S, getActiveThemeId as T, resolveTheme as U, mergeDarkOverrides as V, FONT_FAMILY_KEYS as W, createDefaultAuthRedirect as X, DEFAULT_AUTH_URL as Y, cleanTokenFromUrl as Z, transformManifestToRepAppData as _, createScreen as a, createPersister as at, toScreenDefinition as b, FluidAuthProvider as c, FluidThemeProvider as d, USER_TYPES as et, useThemeContext as f, toRawManifest as g, isApiError as h, widgetPropertySchemas as i, useFluidOsApiOptional as it, DEFAULT_FONT_SIZES as j, DEFAULT_COLORS as k, useFluidAuthContext as l, createFluidClient as m, useFluidContext as n, ApiError$1 as nt, createWidgetFromShareable as o, deleteDatabase as ot, ApiError as p, SEMANTIC_COLOR_NAMES as q, DEFAULT_SDK_WIDGET_REGISTRY as r, createFetchClient as rt, createWidgetRegistry as s, FluidProvider as t, isUserType as tt, usePortalTenantClient as u, toNavigationItem as v, buildThemeDefinition as w, applyTheme as x, normalizeComponentTree as y, generateShades as z };
|
|
2926
2509
|
|
|
2927
|
-
//# sourceMappingURL=FluidProvider-
|
|
2510
|
+
//# sourceMappingURL=FluidProvider-BJQSXofR.mjs.map
|