@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
|
@@ -30,573 +30,6 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
30
30
|
let zod = require("zod");
|
|
31
31
|
let colorjs_io = require("colorjs.io");
|
|
32
32
|
colorjs_io = require_chunk.__toESM(colorjs_io);
|
|
33
|
-
//#region ../../platform/api-client-core/src/fetch-client.ts
|
|
34
|
-
/**
|
|
35
|
-
* API Error class compatible with fluid-admin's ApiError
|
|
36
|
-
*/
|
|
37
|
-
var ApiError$1 = class ApiError$1 extends Error {
|
|
38
|
-
status;
|
|
39
|
-
data;
|
|
40
|
-
constructor(message, status, data) {
|
|
41
|
-
super(message);
|
|
42
|
-
this.name = "ApiError";
|
|
43
|
-
this.status = status;
|
|
44
|
-
this.data = data;
|
|
45
|
-
if ("captureStackTrace" in Error) Error.captureStackTrace(this, ApiError$1);
|
|
46
|
-
}
|
|
47
|
-
toJSON() {
|
|
48
|
-
return {
|
|
49
|
-
name: this.name,
|
|
50
|
-
message: this.message,
|
|
51
|
-
status: this.status,
|
|
52
|
-
data: this.data
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Creates a configured fetch client instance
|
|
58
|
-
*/
|
|
59
|
-
function createFetchClient(config) {
|
|
60
|
-
const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {}, credentials } = config;
|
|
61
|
-
/**
|
|
62
|
-
* Build headers for a request
|
|
63
|
-
*/
|
|
64
|
-
async function buildHeaders(customHeaders) {
|
|
65
|
-
const headers = {
|
|
66
|
-
Accept: "application/json",
|
|
67
|
-
"Content-Type": "application/json",
|
|
68
|
-
...defaultHeaders,
|
|
69
|
-
...customHeaders
|
|
70
|
-
};
|
|
71
|
-
if (getAuthToken) {
|
|
72
|
-
const token = await getAuthToken();
|
|
73
|
-
if (token) headers.Authorization = `Bearer ${token}`;
|
|
74
|
-
}
|
|
75
|
-
return headers;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Join baseUrl + endpoint via string concatenation (matches fetchApi).
|
|
79
|
-
* Using `new URL(endpoint, baseUrl)` would strip any path prefix from
|
|
80
|
-
* baseUrl (e.g. "/api") when the endpoint starts with "/".
|
|
81
|
-
*/
|
|
82
|
-
function joinUrl(endpoint) {
|
|
83
|
-
return `${baseUrl}${endpoint}`;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Build URL with query parameters for GET requests
|
|
87
|
-
* Compatible with fluid-admin's query param handling
|
|
88
|
-
*/
|
|
89
|
-
function buildUrl(endpoint, params) {
|
|
90
|
-
const fullUrl = joinUrl(endpoint);
|
|
91
|
-
if (!params || Object.keys(params).length === 0) return fullUrl;
|
|
92
|
-
const queryString = new URLSearchParams();
|
|
93
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
94
|
-
if (value === void 0 || value === null) return;
|
|
95
|
-
if (Array.isArray(value)) value.forEach((item) => queryString.append(`${key}[]`, String(item)));
|
|
96
|
-
else if (typeof value === "object") Object.entries(value).forEach(([subKey, subValue]) => {
|
|
97
|
-
if (subValue === void 0 || subValue === null) return;
|
|
98
|
-
if (Array.isArray(subValue)) subValue.forEach((item) => queryString.append(`${key}[${subKey}][]`, String(item)));
|
|
99
|
-
else queryString.append(`${key}[${subKey}]`, String(subValue));
|
|
100
|
-
});
|
|
101
|
-
else queryString.append(key, String(value));
|
|
102
|
-
});
|
|
103
|
-
const qs = queryString.toString();
|
|
104
|
-
return qs ? `${fullUrl}?${qs}` : fullUrl;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Shared response handler for both JSON and FormData requests.
|
|
108
|
-
* Handles auth errors, non-OK responses, 204 No Content, and JSON parsing.
|
|
109
|
-
*/
|
|
110
|
-
async function handleResponse(response, method, _url) {
|
|
111
|
-
if (response.status === 401 && onAuthError) onAuthError();
|
|
112
|
-
if (!response.ok) {
|
|
113
|
-
const errorText = await response.text().catch(() => "");
|
|
114
|
-
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
115
|
-
let data;
|
|
116
|
-
try {
|
|
117
|
-
data = JSON.parse(errorText);
|
|
118
|
-
} catch {
|
|
119
|
-
throw new ApiError$1(errorText.slice(0, 200) || `${method} request failed with status ${response.status}`, response.status, null);
|
|
120
|
-
}
|
|
121
|
-
throw new ApiError$1(data.message || data.error_message || `${method} request failed`, response.status, data.errors || data);
|
|
122
|
-
} else throw new ApiError$1(`${method} request failed with status ${response.status}`, response.status, null);
|
|
123
|
-
}
|
|
124
|
-
if (response.status === 204 || response.headers.get("content-length") === "0") return null;
|
|
125
|
-
if (response.headers.get("content-type")?.includes("application/json")) try {
|
|
126
|
-
return await response.json();
|
|
127
|
-
} catch {
|
|
128
|
-
try {
|
|
129
|
-
return await response.text();
|
|
130
|
-
} catch {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Main request function
|
|
138
|
-
*/
|
|
139
|
-
async function request(endpoint, options = {}) {
|
|
140
|
-
const { method = "GET", headers: customHeaders, params, body, signal } = options;
|
|
141
|
-
const url = params ? buildUrl(endpoint, params) : joinUrl(endpoint);
|
|
142
|
-
const headers = await buildHeaders(customHeaders);
|
|
143
|
-
let response;
|
|
144
|
-
try {
|
|
145
|
-
const fetchOptions = {
|
|
146
|
-
method,
|
|
147
|
-
headers
|
|
148
|
-
};
|
|
149
|
-
if (credentials) fetchOptions.credentials = credentials;
|
|
150
|
-
const serializedBody = body && method !== "GET" ? JSON.stringify(body) : null;
|
|
151
|
-
if (serializedBody) fetchOptions.body = serializedBody;
|
|
152
|
-
if (signal) fetchOptions.signal = signal;
|
|
153
|
-
response = await fetch(url, fetchOptions);
|
|
154
|
-
} catch (networkError) {
|
|
155
|
-
throw new ApiError$1(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
156
|
-
}
|
|
157
|
-
return handleResponse(response, method, url);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Request with FormData (for file uploads)
|
|
161
|
-
*/
|
|
162
|
-
async function requestWithFormData(endpoint, formData, options = {}) {
|
|
163
|
-
const { method = "POST", headers: customHeaders, signal } = options;
|
|
164
|
-
const url = joinUrl(endpoint);
|
|
165
|
-
const headers = await buildHeaders(customHeaders);
|
|
166
|
-
delete headers["Content-Type"];
|
|
167
|
-
let response;
|
|
168
|
-
try {
|
|
169
|
-
const fetchOptions = {
|
|
170
|
-
method,
|
|
171
|
-
headers,
|
|
172
|
-
body: formData
|
|
173
|
-
};
|
|
174
|
-
if (credentials) fetchOptions.credentials = credentials;
|
|
175
|
-
if (signal) fetchOptions.signal = signal;
|
|
176
|
-
response = await fetch(url, fetchOptions);
|
|
177
|
-
} catch (networkError) {
|
|
178
|
-
throw new ApiError$1(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
179
|
-
}
|
|
180
|
-
return handleResponse(response, method, url);
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
request,
|
|
184
|
-
requestWithFormData,
|
|
185
|
-
get: (endpoint, params, options) => request(endpoint, {
|
|
186
|
-
...options,
|
|
187
|
-
method: "GET",
|
|
188
|
-
...params && { params }
|
|
189
|
-
}),
|
|
190
|
-
post: (endpoint, body, options) => request(endpoint, {
|
|
191
|
-
...options,
|
|
192
|
-
method: "POST",
|
|
193
|
-
body
|
|
194
|
-
}),
|
|
195
|
-
put: (endpoint, body, options) => request(endpoint, {
|
|
196
|
-
...options,
|
|
197
|
-
method: "PUT",
|
|
198
|
-
body
|
|
199
|
-
}),
|
|
200
|
-
patch: (endpoint, body, options) => request(endpoint, {
|
|
201
|
-
...options,
|
|
202
|
-
method: "PATCH",
|
|
203
|
-
body
|
|
204
|
-
}),
|
|
205
|
-
delete: (endpoint, options) => request(endpoint, {
|
|
206
|
-
...options,
|
|
207
|
-
method: "DELETE"
|
|
208
|
-
})
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
//#endregion
|
|
212
|
-
//#region ../../fluid-pay/api-client/src/namespaces/customers.ts
|
|
213
|
-
/**
|
|
214
|
-
* Fetch the current customer's account info.
|
|
215
|
-
* Endpoint: GET /fluid_pay/me?jwt={jwt}
|
|
216
|
-
*/
|
|
217
|
-
async function fetchCustomerAccount(client, jwt) {
|
|
218
|
-
return client.get(`/fluid_pay/me`, { jwt });
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Update customer profile (name, phone, language).
|
|
222
|
-
* Endpoint: PATCH /fluid_pay/update_me?jwt={jwt}
|
|
223
|
-
*/
|
|
224
|
-
async function updateCustomer(client, jwt, body) {
|
|
225
|
-
return client.patch(`/fluid_pay/update_me?jwt=${jwt}`, { fluid_pay_account: body });
|
|
226
|
-
}
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region ../../fluid-pay/api-client/src/namespaces/addresses.ts
|
|
229
|
-
/**
|
|
230
|
-
* Fetch all customer addresses.
|
|
231
|
-
* Endpoint: GET /fluid_pay/addresses?jwt={jwt}
|
|
232
|
-
*/
|
|
233
|
-
async function fetchCustomerAddresses(client, jwt) {
|
|
234
|
-
return client.get("/fluid_pay/addresses", {
|
|
235
|
-
jwt,
|
|
236
|
-
page: "1",
|
|
237
|
-
per_page: "100"
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Create a new customer address.
|
|
242
|
-
* Endpoint: POST /fluid_pay/create_address?jwt={jwt}
|
|
243
|
-
*/
|
|
244
|
-
async function createCustomerAddress(client, jwt, body) {
|
|
245
|
-
return client.post(`/fluid_pay/create_address?jwt=${jwt}`, body);
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Update an existing customer address.
|
|
249
|
-
* Endpoint: PATCH /fluid_pay/update_address/{addressId}?jwt={jwt}
|
|
250
|
-
*/
|
|
251
|
-
async function updateCustomerAddress(client, jwt, addressId, body) {
|
|
252
|
-
return client.patch(`/fluid_pay/update_address/${addressId}?jwt=${jwt}`, body);
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Delete a customer address.
|
|
256
|
-
* Endpoint: DELETE /fluid_pay/delete_address/{addressId}?jwt={jwt}
|
|
257
|
-
*/
|
|
258
|
-
async function deleteCustomerAddress(client, jwt, addressId) {
|
|
259
|
-
return client.delete(`/fluid_pay/delete_address/${addressId}?jwt=${jwt}`);
|
|
260
|
-
}
|
|
261
|
-
//#endregion
|
|
262
|
-
//#region ../../fluid-pay/api-client/src/namespaces/payment-methods.ts
|
|
263
|
-
/**
|
|
264
|
-
* Fetch all customer payment methods.
|
|
265
|
-
* Endpoint: GET /fluid_pay/payment_methods?jwt={jwt}
|
|
266
|
-
*/
|
|
267
|
-
async function fetchCustomerPaymentMethods(client, jwt, countryCode) {
|
|
268
|
-
const params = {
|
|
269
|
-
jwt,
|
|
270
|
-
page: "1",
|
|
271
|
-
per_page: "100"
|
|
272
|
-
};
|
|
273
|
-
if (countryCode) params.country_code = countryCode;
|
|
274
|
-
return client.get("/fluid_pay/payment_methods", params);
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Add a credit card to the customer's account.
|
|
278
|
-
* Endpoint: POST /fluid_pay/create_payment_method?jwt={jwt}
|
|
279
|
-
*/
|
|
280
|
-
async function addCreditCardToCustomer(client, jwt, data) {
|
|
281
|
-
return client.post(`/fluid_pay/create_payment_method?jwt=${jwt}`, data);
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Delete a customer payment method.
|
|
285
|
-
* Endpoint: DELETE /fluid_pay/delete_payment_method/{id}?jwt={jwt}
|
|
286
|
-
*/
|
|
287
|
-
async function deleteCustomerPaymentMethod(client, jwt, paymentMethodId) {
|
|
288
|
-
return client.delete(`/fluid_pay/delete_payment_method/${paymentMethodId}?jwt=${jwt}`);
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Set a payment method as default.
|
|
292
|
-
* Endpoint: PATCH /fluid_pay/update_payment_method/{id}?jwt={jwt}
|
|
293
|
-
*/
|
|
294
|
-
async function updateDefaultPaymentMethod(client, jwt, paymentMethodId) {
|
|
295
|
-
return client.patch(`/fluid_pay/update_payment_method/${paymentMethodId}?jwt=${jwt}`);
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Update a payment method (default status, billing address).
|
|
299
|
-
* Endpoint: PATCH /fluid_pay/update_payment_method/{id}?jwt={jwt}
|
|
300
|
-
*/
|
|
301
|
-
async function updatePaymentMethod(client, jwt, paymentMethodId, body) {
|
|
302
|
-
return client.patch(`/fluid_pay/update_payment_method/${paymentMethodId}?jwt=${jwt}`, body);
|
|
303
|
-
}
|
|
304
|
-
//#endregion
|
|
305
|
-
//#region ../../fluid-pay/api-client/src/namespaces/vault.ts
|
|
306
|
-
/**
|
|
307
|
-
* Fetch VGS vault credentials for the customer's payment account.
|
|
308
|
-
* Endpoint: GET /fluid_pay/vault?jwt={jwt}
|
|
309
|
-
*/
|
|
310
|
-
async function fetchVaultCredentialsForPaymentAccount(client, jwt) {
|
|
311
|
-
return client.get("/fluid_pay/vault", { jwt });
|
|
312
|
-
}
|
|
313
|
-
//#endregion
|
|
314
|
-
//#region ../../fluid-pay/api-client/src/adapter.ts
|
|
315
|
-
function createFluidPayApi(client) {
|
|
316
|
-
return {
|
|
317
|
-
customers: {
|
|
318
|
-
fetchAccount: (jwt) => fetchCustomerAccount(client, jwt),
|
|
319
|
-
update: (jwt, body) => updateCustomer(client, jwt, body)
|
|
320
|
-
},
|
|
321
|
-
addresses: {
|
|
322
|
-
fetchAll: (jwt) => fetchCustomerAddresses(client, jwt),
|
|
323
|
-
create: (jwt, body) => createCustomerAddress(client, jwt, body),
|
|
324
|
-
update: (jwt, addressId, body) => updateCustomerAddress(client, jwt, addressId, body),
|
|
325
|
-
delete: (jwt, addressId) => deleteCustomerAddress(client, jwt, addressId)
|
|
326
|
-
},
|
|
327
|
-
paymentMethods: {
|
|
328
|
-
fetchAll: (jwt, countryCode) => fetchCustomerPaymentMethods(client, jwt, countryCode),
|
|
329
|
-
addCreditCard: (jwt, data) => addCreditCardToCustomer(client, jwt, data),
|
|
330
|
-
delete: (jwt, paymentMethodId) => deleteCustomerPaymentMethod(client, jwt, paymentMethodId),
|
|
331
|
-
updateDefault: (jwt, paymentMethodId) => updateDefaultPaymentMethod(client, jwt, paymentMethodId),
|
|
332
|
-
update: (jwt, paymentMethodId, body) => updatePaymentMethod(client, jwt, paymentMethodId, body)
|
|
333
|
-
},
|
|
334
|
-
vault: { fetchCredentials: (jwt) => fetchVaultCredentialsForPaymentAccount(client, jwt) }
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
//#endregion
|
|
338
|
-
//#region ../../fluid-pay/core/src/context.ts
|
|
339
|
-
const FluidPayApiContext = (0, react.createContext)(null);
|
|
340
|
-
const FluidPayApiProvider = FluidPayApiContext.Provider;
|
|
341
|
-
function useFluidPayApi() {
|
|
342
|
-
const api = (0, react.useContext)(FluidPayApiContext);
|
|
343
|
-
if (!api) throw new Error("useFluidPayApi must be used within a FluidPayCoreProvider");
|
|
344
|
-
return api;
|
|
345
|
-
}
|
|
346
|
-
//#endregion
|
|
347
|
-
//#region ../../fluid-pay/core/src/provider.tsx
|
|
348
|
-
function FluidPayCoreProvider({ api, children }) {
|
|
349
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FluidPayApiProvider, {
|
|
350
|
-
value: api,
|
|
351
|
-
children
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region ../../fluid-pay/core/src/utils/country-config.ts
|
|
356
|
-
const US_STATES = [
|
|
357
|
-
{
|
|
358
|
-
name: "Alabama",
|
|
359
|
-
isoCode: "AL"
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
name: "Alaska",
|
|
363
|
-
isoCode: "AK"
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
name: "Arizona",
|
|
367
|
-
isoCode: "AZ"
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
name: "Arkansas",
|
|
371
|
-
isoCode: "AR"
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
name: "California",
|
|
375
|
-
isoCode: "CA"
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
name: "Colorado",
|
|
379
|
-
isoCode: "CO"
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
name: "Connecticut",
|
|
383
|
-
isoCode: "CT"
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
name: "Delaware",
|
|
387
|
-
isoCode: "DE"
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
name: "Florida",
|
|
391
|
-
isoCode: "FL"
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
name: "Georgia",
|
|
395
|
-
isoCode: "GA"
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
name: "Hawaii",
|
|
399
|
-
isoCode: "HI"
|
|
400
|
-
},
|
|
401
|
-
{
|
|
402
|
-
name: "Idaho",
|
|
403
|
-
isoCode: "ID"
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
name: "Illinois",
|
|
407
|
-
isoCode: "IL"
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
name: "Indiana",
|
|
411
|
-
isoCode: "IN"
|
|
412
|
-
},
|
|
413
|
-
{
|
|
414
|
-
name: "Iowa",
|
|
415
|
-
isoCode: "IA"
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
name: "Kansas",
|
|
419
|
-
isoCode: "KS"
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
name: "Kentucky",
|
|
423
|
-
isoCode: "KY"
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
name: "Louisiana",
|
|
427
|
-
isoCode: "LA"
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
name: "Maine",
|
|
431
|
-
isoCode: "ME"
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
name: "Maryland",
|
|
435
|
-
isoCode: "MD"
|
|
436
|
-
},
|
|
437
|
-
{
|
|
438
|
-
name: "Massachusetts",
|
|
439
|
-
isoCode: "MA"
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
name: "Michigan",
|
|
443
|
-
isoCode: "MI"
|
|
444
|
-
},
|
|
445
|
-
{
|
|
446
|
-
name: "Minnesota",
|
|
447
|
-
isoCode: "MN"
|
|
448
|
-
},
|
|
449
|
-
{
|
|
450
|
-
name: "Mississippi",
|
|
451
|
-
isoCode: "MS"
|
|
452
|
-
},
|
|
453
|
-
{
|
|
454
|
-
name: "Missouri",
|
|
455
|
-
isoCode: "MO"
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
name: "Montana",
|
|
459
|
-
isoCode: "MT"
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
name: "Nebraska",
|
|
463
|
-
isoCode: "NE"
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
name: "Nevada",
|
|
467
|
-
isoCode: "NV"
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
name: "New Hampshire",
|
|
471
|
-
isoCode: "NH"
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
name: "New Jersey",
|
|
475
|
-
isoCode: "NJ"
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
name: "New Mexico",
|
|
479
|
-
isoCode: "NM"
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
name: "New York",
|
|
483
|
-
isoCode: "NY"
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
name: "North Carolina",
|
|
487
|
-
isoCode: "NC"
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
name: "North Dakota",
|
|
491
|
-
isoCode: "ND"
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
name: "Ohio",
|
|
495
|
-
isoCode: "OH"
|
|
496
|
-
},
|
|
497
|
-
{
|
|
498
|
-
name: "Oklahoma",
|
|
499
|
-
isoCode: "OK"
|
|
500
|
-
},
|
|
501
|
-
{
|
|
502
|
-
name: "Oregon",
|
|
503
|
-
isoCode: "OR"
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
name: "Pennsylvania",
|
|
507
|
-
isoCode: "PA"
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
name: "Rhode Island",
|
|
511
|
-
isoCode: "RI"
|
|
512
|
-
},
|
|
513
|
-
{
|
|
514
|
-
name: "South Carolina",
|
|
515
|
-
isoCode: "SC"
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
name: "South Dakota",
|
|
519
|
-
isoCode: "SD"
|
|
520
|
-
},
|
|
521
|
-
{
|
|
522
|
-
name: "Tennessee",
|
|
523
|
-
isoCode: "TN"
|
|
524
|
-
},
|
|
525
|
-
{
|
|
526
|
-
name: "Texas",
|
|
527
|
-
isoCode: "TX"
|
|
528
|
-
},
|
|
529
|
-
{
|
|
530
|
-
name: "Utah",
|
|
531
|
-
isoCode: "UT"
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
name: "Vermont",
|
|
535
|
-
isoCode: "VT"
|
|
536
|
-
},
|
|
537
|
-
{
|
|
538
|
-
name: "Virginia",
|
|
539
|
-
isoCode: "VA"
|
|
540
|
-
},
|
|
541
|
-
{
|
|
542
|
-
name: "Washington",
|
|
543
|
-
isoCode: "WA"
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
name: "West Virginia",
|
|
547
|
-
isoCode: "WV"
|
|
548
|
-
},
|
|
549
|
-
{
|
|
550
|
-
name: "Wisconsin",
|
|
551
|
-
isoCode: "WI"
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
name: "Wyoming",
|
|
555
|
-
isoCode: "WY"
|
|
556
|
-
},
|
|
557
|
-
{
|
|
558
|
-
name: "District of Columbia",
|
|
559
|
-
isoCode: "DC"
|
|
560
|
-
}
|
|
561
|
-
];
|
|
562
|
-
const COUNTRY_CONFIGS = {
|
|
563
|
-
US: {
|
|
564
|
-
regionLabel: "State",
|
|
565
|
-
postalLabel: "ZIP Code"
|
|
566
|
-
},
|
|
567
|
-
JP: {
|
|
568
|
-
regionLabel: "Prefecture",
|
|
569
|
-
postalLabel: "Postal Code"
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
const DEFAULT_REGION_CONFIG = {
|
|
573
|
-
regionLabel: "Province",
|
|
574
|
-
postalLabel: "Postal Code"
|
|
575
|
-
};
|
|
576
|
-
function getRegionConfig(countryCode) {
|
|
577
|
-
return COUNTRY_CONFIGS[countryCode] ?? DEFAULT_REGION_CONFIG;
|
|
578
|
-
}
|
|
579
|
-
//#endregion
|
|
580
|
-
//#region ../../fluid-pay/core/src/hooks/use-country-states.ts
|
|
581
|
-
function useCountryStates() {
|
|
582
|
-
const [selectedCountry, setSelectedCountry] = (0, react.useState)("US");
|
|
583
|
-
const [stateOptions, setStateOptions] = (0, react.useState)(US_STATES);
|
|
584
|
-
return {
|
|
585
|
-
handleCountryChange: (0, react.useCallback)((selectedCountryCode, fetchStates) => {
|
|
586
|
-
setSelectedCountry(selectedCountryCode);
|
|
587
|
-
if (selectedCountryCode === "US") setStateOptions(US_STATES);
|
|
588
|
-
else if (fetchStates) fetchStates(selectedCountryCode).then((states) => setStateOptions(states)).catch((error) => {
|
|
589
|
-
console.error("Failed to fetch states:", error);
|
|
590
|
-
setStateOptions([]);
|
|
591
|
-
});
|
|
592
|
-
else setStateOptions([]);
|
|
593
|
-
}, []),
|
|
594
|
-
stateOptions,
|
|
595
|
-
config: getRegionConfig(selectedCountry),
|
|
596
|
-
selectedCountry
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
//#endregion
|
|
600
33
|
//#region ../../../node_modules/.pnpm/@tanstack+query-core@5.90.12/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
|
|
601
34
|
var defaultTimeoutProvider = {
|
|
602
35
|
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
@@ -1065,6 +498,185 @@ function useFluidOsApiOptional() {
|
|
|
1065
498
|
return builderApi ?? readApi;
|
|
1066
499
|
}
|
|
1067
500
|
//#endregion
|
|
501
|
+
//#region ../../platform/api-client-core/src/fetch-client.ts
|
|
502
|
+
/**
|
|
503
|
+
* API Error class compatible with fluid-admin's ApiError
|
|
504
|
+
*/
|
|
505
|
+
var ApiError$1 = class ApiError$1 extends Error {
|
|
506
|
+
status;
|
|
507
|
+
data;
|
|
508
|
+
constructor(message, status, data) {
|
|
509
|
+
super(message);
|
|
510
|
+
this.name = "ApiError";
|
|
511
|
+
this.status = status;
|
|
512
|
+
this.data = data;
|
|
513
|
+
if ("captureStackTrace" in Error) Error.captureStackTrace(this, ApiError$1);
|
|
514
|
+
}
|
|
515
|
+
toJSON() {
|
|
516
|
+
return {
|
|
517
|
+
name: this.name,
|
|
518
|
+
message: this.message,
|
|
519
|
+
status: this.status,
|
|
520
|
+
data: this.data
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
/**
|
|
525
|
+
* Creates a configured fetch client instance
|
|
526
|
+
*/
|
|
527
|
+
function createFetchClient(config) {
|
|
528
|
+
const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {}, credentials } = config;
|
|
529
|
+
/**
|
|
530
|
+
* Build headers for a request
|
|
531
|
+
*/
|
|
532
|
+
async function buildHeaders(customHeaders) {
|
|
533
|
+
const headers = {
|
|
534
|
+
Accept: "application/json",
|
|
535
|
+
"Content-Type": "application/json",
|
|
536
|
+
...defaultHeaders,
|
|
537
|
+
...customHeaders
|
|
538
|
+
};
|
|
539
|
+
if (getAuthToken) {
|
|
540
|
+
const token = await getAuthToken();
|
|
541
|
+
if (token) headers.Authorization = `Bearer ${token}`;
|
|
542
|
+
}
|
|
543
|
+
return headers;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Join baseUrl + endpoint via string concatenation (matches fetchApi).
|
|
547
|
+
* Using `new URL(endpoint, baseUrl)` would strip any path prefix from
|
|
548
|
+
* baseUrl (e.g. "/api") when the endpoint starts with "/".
|
|
549
|
+
*/
|
|
550
|
+
function joinUrl(endpoint) {
|
|
551
|
+
return `${baseUrl}${endpoint}`;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Build URL with query parameters for GET requests
|
|
555
|
+
* Compatible with fluid-admin's query param handling
|
|
556
|
+
*/
|
|
557
|
+
function buildUrl(endpoint, params) {
|
|
558
|
+
const fullUrl = joinUrl(endpoint);
|
|
559
|
+
if (!params || Object.keys(params).length === 0) return fullUrl;
|
|
560
|
+
const queryString = new URLSearchParams();
|
|
561
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
562
|
+
if (value === void 0 || value === null) return;
|
|
563
|
+
if (Array.isArray(value)) value.forEach((item) => queryString.append(`${key}[]`, String(item)));
|
|
564
|
+
else if (typeof value === "object") Object.entries(value).forEach(([subKey, subValue]) => {
|
|
565
|
+
if (subValue === void 0 || subValue === null) return;
|
|
566
|
+
if (Array.isArray(subValue)) subValue.forEach((item) => queryString.append(`${key}[${subKey}][]`, String(item)));
|
|
567
|
+
else queryString.append(`${key}[${subKey}]`, String(subValue));
|
|
568
|
+
});
|
|
569
|
+
else queryString.append(key, String(value));
|
|
570
|
+
});
|
|
571
|
+
const qs = queryString.toString();
|
|
572
|
+
return qs ? `${fullUrl}?${qs}` : fullUrl;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Shared response handler for both JSON and FormData requests.
|
|
576
|
+
* Handles auth errors, non-OK responses, 204 No Content, and JSON parsing.
|
|
577
|
+
*/
|
|
578
|
+
async function handleResponse(response, method, _url) {
|
|
579
|
+
if (response.status === 401 && onAuthError) onAuthError();
|
|
580
|
+
if (!response.ok) {
|
|
581
|
+
const errorText = await response.text().catch(() => "");
|
|
582
|
+
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
583
|
+
let data;
|
|
584
|
+
try {
|
|
585
|
+
data = JSON.parse(errorText);
|
|
586
|
+
} catch {
|
|
587
|
+
throw new ApiError$1(errorText.slice(0, 200) || `${method} request failed with status ${response.status}`, response.status, null);
|
|
588
|
+
}
|
|
589
|
+
throw new ApiError$1(data.message || data.error_message || `${method} request failed`, response.status, data.errors || data);
|
|
590
|
+
} else throw new ApiError$1(`${method} request failed with status ${response.status}`, response.status, null);
|
|
591
|
+
}
|
|
592
|
+
if (response.status === 204 || response.headers.get("content-length") === "0") return null;
|
|
593
|
+
if (response.headers.get("content-type")?.includes("application/json")) try {
|
|
594
|
+
return await response.json();
|
|
595
|
+
} catch {
|
|
596
|
+
try {
|
|
597
|
+
return await response.text();
|
|
598
|
+
} catch {
|
|
599
|
+
return null;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Main request function
|
|
606
|
+
*/
|
|
607
|
+
async function request(endpoint, options = {}) {
|
|
608
|
+
const { method = "GET", headers: customHeaders, params, body, signal } = options;
|
|
609
|
+
const url = params ? buildUrl(endpoint, params) : joinUrl(endpoint);
|
|
610
|
+
const headers = await buildHeaders(customHeaders);
|
|
611
|
+
let response;
|
|
612
|
+
try {
|
|
613
|
+
const fetchOptions = {
|
|
614
|
+
method,
|
|
615
|
+
headers
|
|
616
|
+
};
|
|
617
|
+
if (credentials) fetchOptions.credentials = credentials;
|
|
618
|
+
const serializedBody = body && method !== "GET" ? JSON.stringify(body) : null;
|
|
619
|
+
if (serializedBody) fetchOptions.body = serializedBody;
|
|
620
|
+
if (signal) fetchOptions.signal = signal;
|
|
621
|
+
response = await fetch(url, fetchOptions);
|
|
622
|
+
} catch (networkError) {
|
|
623
|
+
throw new ApiError$1(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
624
|
+
}
|
|
625
|
+
return handleResponse(response, method, url);
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Request with FormData (for file uploads)
|
|
629
|
+
*/
|
|
630
|
+
async function requestWithFormData(endpoint, formData, options = {}) {
|
|
631
|
+
const { method = "POST", headers: customHeaders, signal } = options;
|
|
632
|
+
const url = joinUrl(endpoint);
|
|
633
|
+
const headers = await buildHeaders(customHeaders);
|
|
634
|
+
delete headers["Content-Type"];
|
|
635
|
+
let response;
|
|
636
|
+
try {
|
|
637
|
+
const fetchOptions = {
|
|
638
|
+
method,
|
|
639
|
+
headers,
|
|
640
|
+
body: formData
|
|
641
|
+
};
|
|
642
|
+
if (credentials) fetchOptions.credentials = credentials;
|
|
643
|
+
if (signal) fetchOptions.signal = signal;
|
|
644
|
+
response = await fetch(url, fetchOptions);
|
|
645
|
+
} catch (networkError) {
|
|
646
|
+
throw new ApiError$1(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
647
|
+
}
|
|
648
|
+
return handleResponse(response, method, url);
|
|
649
|
+
}
|
|
650
|
+
return {
|
|
651
|
+
request,
|
|
652
|
+
requestWithFormData,
|
|
653
|
+
get: (endpoint, params, options) => request(endpoint, {
|
|
654
|
+
...options,
|
|
655
|
+
method: "GET",
|
|
656
|
+
...params && { params }
|
|
657
|
+
}),
|
|
658
|
+
post: (endpoint, body, options) => request(endpoint, {
|
|
659
|
+
...options,
|
|
660
|
+
method: "POST",
|
|
661
|
+
body
|
|
662
|
+
}),
|
|
663
|
+
put: (endpoint, body, options) => request(endpoint, {
|
|
664
|
+
...options,
|
|
665
|
+
method: "PUT",
|
|
666
|
+
body
|
|
667
|
+
}),
|
|
668
|
+
patch: (endpoint, body, options) => request(endpoint, {
|
|
669
|
+
...options,
|
|
670
|
+
method: "PATCH",
|
|
671
|
+
body
|
|
672
|
+
}),
|
|
673
|
+
delete: (endpoint, options) => request(endpoint, {
|
|
674
|
+
...options,
|
|
675
|
+
method: "DELETE"
|
|
676
|
+
})
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
//#endregion
|
|
1068
680
|
//#region ../../api-clients/fluidos/src/namespaces/fluid_os.ts
|
|
1069
681
|
/**
|
|
1070
682
|
* Get active Fluid OS definition
|
|
@@ -2829,11 +2441,13 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
|
|
|
2829
2441
|
onAuthError: () => configRef.current.onAuthError?.()
|
|
2830
2442
|
}), [config.baseUrl]);
|
|
2831
2443
|
const fluidOsApi = (0, react.useMemo)(() => createFluidOsReadAdapter(client.fetchClient), [client.fetchClient]);
|
|
2444
|
+
const csrfToken = typeof document !== "undefined" ? document.querySelector("meta[name=\"csrf-token\"]")?.getAttribute("content") : null;
|
|
2832
2445
|
const portalTenantClient = (0, react.useMemo)(() => createFetchClient({
|
|
2833
2446
|
baseUrl: configRef.current.baseUrl,
|
|
2834
2447
|
onAuthError: () => configRef.current.onAuthError?.(),
|
|
2835
|
-
credentials: "include"
|
|
2836
|
-
|
|
2448
|
+
credentials: "include",
|
|
2449
|
+
defaultHeaders: { ...csrfToken ? { "X-CSRF-Token": csrfToken } : {} }
|
|
2450
|
+
}), [config.baseUrl, csrfToken]);
|
|
2837
2451
|
const contextValue = (0, react.useMemo)(() => ({
|
|
2838
2452
|
client,
|
|
2839
2453
|
config: configRef.current
|
|
@@ -2866,13 +2480,12 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
|
|
|
2866
2480
|
value: portalTenantClient,
|
|
2867
2481
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FluidOsApiProvider, {
|
|
2868
2482
|
value: fluidOsApi,
|
|
2869
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2483
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProviderStack, {
|
|
2870
2484
|
baseUrl: dataSourceBaseUrl,
|
|
2871
2485
|
getApiHeaders,
|
|
2872
2486
|
variables: effectiveVariables,
|
|
2873
2487
|
registry,
|
|
2874
2488
|
themeProviderProps,
|
|
2875
|
-
onAuthError: config.onAuthError,
|
|
2876
2489
|
children
|
|
2877
2490
|
})
|
|
2878
2491
|
})
|
|
@@ -2881,49 +2494,19 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
|
|
|
2881
2494
|
});
|
|
2882
2495
|
}
|
|
2883
2496
|
/**
|
|
2884
|
-
* Inner component that
|
|
2497
|
+
* Inner component that sets up data source providers and theme.
|
|
2885
2498
|
* Must be rendered inside FluidContext.Provider + QueryClientProvider.
|
|
2886
|
-
* Inlines the customer account fetch to avoid a circular dependency
|
|
2887
|
-
* (FluidProvider → useCustomerAccount → useFluidPayApi → FluidProvider).
|
|
2888
2499
|
*/
|
|
2889
|
-
function
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
onAuthError: () => onAuthErrorRef.current?.()
|
|
2900
|
-
}));
|
|
2901
|
-
}, [baseUrl]);
|
|
2902
|
-
const { data: customerData } = (0, _tanstack_react_query.useQuery)({
|
|
2903
|
-
queryKey: ["fluidPayAccount", userId],
|
|
2904
|
-
queryFn: () => fluidPayApi.customers.fetchAccount(""),
|
|
2905
|
-
enabled: isAuthenticated
|
|
2906
|
-
});
|
|
2907
|
-
const customerId = customerData?.customer?.id;
|
|
2908
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FluidPayCoreProvider, {
|
|
2909
|
-
api: fluidPayApi,
|
|
2910
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PointsWidget.DataSourceRegistryProvider, {
|
|
2911
|
-
baseUrl,
|
|
2912
|
-
getApiHeaders,
|
|
2913
|
-
variables: (0, react.useMemo)(() => {
|
|
2914
|
-
const base = variables ?? {};
|
|
2915
|
-
if (customerId == null) return variables;
|
|
2916
|
-
return {
|
|
2917
|
-
...base,
|
|
2918
|
-
customer_id: String(customerId)
|
|
2919
|
-
};
|
|
2920
|
-
}, [variables, customerId]),
|
|
2921
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ScreenRenderer.RegistryProvider, {
|
|
2922
|
-
registry,
|
|
2923
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FluidThemeProvider, {
|
|
2924
|
-
...themeProviderProps,
|
|
2925
|
-
children
|
|
2926
|
-
})
|
|
2500
|
+
function ProviderStack({ baseUrl, getApiHeaders, variables, registry, themeProviderProps, children }) {
|
|
2501
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PointsWidget.DataSourceRegistryProvider, {
|
|
2502
|
+
baseUrl,
|
|
2503
|
+
getApiHeaders,
|
|
2504
|
+
variables,
|
|
2505
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ScreenRenderer.RegistryProvider, {
|
|
2506
|
+
registry,
|
|
2507
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FluidThemeProvider, {
|
|
2508
|
+
...themeProviderProps,
|
|
2509
|
+
children
|
|
2927
2510
|
})
|
|
2928
2511
|
})
|
|
2929
2512
|
});
|
|
@@ -3262,12 +2845,6 @@ Object.defineProperty(exports, "transformThemes", {
|
|
|
3262
2845
|
return transformThemes;
|
|
3263
2846
|
}
|
|
3264
2847
|
});
|
|
3265
|
-
Object.defineProperty(exports, "useCountryStates", {
|
|
3266
|
-
enumerable: true,
|
|
3267
|
-
get: function() {
|
|
3268
|
-
return useCountryStates;
|
|
3269
|
-
}
|
|
3270
|
-
});
|
|
3271
2848
|
Object.defineProperty(exports, "useFluidAuthContext", {
|
|
3272
2849
|
enumerable: true,
|
|
3273
2850
|
get: function() {
|
|
@@ -3286,12 +2863,6 @@ Object.defineProperty(exports, "useFluidOsApiOptional", {
|
|
|
3286
2863
|
return useFluidOsApiOptional;
|
|
3287
2864
|
}
|
|
3288
2865
|
});
|
|
3289
|
-
Object.defineProperty(exports, "useFluidPayApi", {
|
|
3290
|
-
enumerable: true,
|
|
3291
|
-
get: function() {
|
|
3292
|
-
return useFluidPayApi;
|
|
3293
|
-
}
|
|
3294
|
-
});
|
|
3295
2866
|
Object.defineProperty(exports, "usePortalTenantClient", {
|
|
3296
2867
|
enumerable: true,
|
|
3297
2868
|
get: function() {
|
|
@@ -3311,4 +2882,4 @@ Object.defineProperty(exports, "widgetPropertySchemas", {
|
|
|
3311
2882
|
}
|
|
3312
2883
|
});
|
|
3313
2884
|
|
|
3314
|
-
//# sourceMappingURL=FluidProvider-
|
|
2885
|
+
//# sourceMappingURL=FluidProvider-DvqnkjZI.cjs.map
|