@fluid-app/portal-sdk 0.1.143 → 0.1.144
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-BgG2WT8g.cjs → AppDownloadScreen-CxkoYLT6.cjs} +2 -2
- package/dist/{AppDownloadScreen-BgG2WT8g.cjs.map → AppDownloadScreen-CxkoYLT6.cjs.map} +1 -1
- package/dist/{AppDownloadScreen-CfyCY70_.cjs → AppDownloadScreen-DXZpoE5A.cjs} +2 -2
- package/dist/{AppDownloadScreen-CFBcywVF.mjs → AppDownloadScreen-ga-5O4jr.mjs} +2 -2
- package/dist/{AppDownloadScreen-CFBcywVF.mjs.map → AppDownloadScreen-ga-5O4jr.mjs.map} +1 -1
- package/dist/{ContactsScreen-B0CcTg4i.mjs → ContactsScreen-C-xJcR5X.mjs} +6 -6
- package/dist/{ContactsScreen-B0CcTg4i.mjs.map → ContactsScreen-C-xJcR5X.mjs.map} +1 -1
- package/dist/{ContactsScreen-cq-zMYwU.cjs → ContactsScreen-DYkGu477.cjs} +7 -7
- package/dist/{ContactsScreen-C2SykfSe.cjs → ContactsScreen-RQ1IENFl.cjs} +6 -6
- package/dist/{ContactsScreen-C2SykfSe.cjs.map → ContactsScreen-RQ1IENFl.cjs.map} +1 -1
- package/dist/{FluidProvider-D8lmeIsK.mjs → FluidProvider-Bs9eWShT.mjs} +226 -9
- package/dist/FluidProvider-Bs9eWShT.mjs.map +1 -0
- package/dist/{FluidProvider-9laphShJ.cjs → FluidProvider-DzCUwDPA.cjs} +231 -8
- package/dist/FluidProvider-DzCUwDPA.cjs.map +1 -0
- package/dist/{MessagingScreen-CQGyTGz7.cjs → MessagingScreen-BmAICPkY.cjs} +4 -4
- package/dist/{MessagingScreen-DY8FhtNu.cjs → MessagingScreen-D7hAjWaG.cjs} +5 -5
- package/dist/{MessagingScreen-DY8FhtNu.cjs.map → MessagingScreen-D7hAjWaG.cjs.map} +1 -1
- package/dist/{MessagingScreen-DmwSYXYa.mjs → MessagingScreen-DOcgxDbR.mjs} +4 -4
- package/dist/{MessagingScreen-DmwSYXYa.mjs.map → MessagingScreen-DOcgxDbR.mjs.map} +1 -1
- package/dist/{MySiteScreen-CZf06WvK.cjs → MySiteScreen-BMFJLAwJ.cjs} +2 -2
- package/dist/{MySiteScreen-CZf06WvK.cjs.map → MySiteScreen-BMFJLAwJ.cjs.map} +1 -1
- package/dist/{MySiteScreen-CP4ePv25.mjs → MySiteScreen-BwCQLYBT.mjs} +2 -2
- package/dist/{MySiteScreen-CP4ePv25.mjs.map → MySiteScreen-BwCQLYBT.mjs.map} +1 -1
- package/dist/{MySiteScreen-3uoP4Nro.cjs → MySiteScreen-C_-EPLsj.cjs} +2 -2
- package/dist/{OrdersScreen-B4s3yqWO.cjs → OrdersScreen-DHoIUinY.cjs} +3 -3
- package/dist/{OrdersScreen-B4s3yqWO.cjs.map → OrdersScreen-DHoIUinY.cjs.map} +1 -1
- package/dist/{OrdersScreen-qnOfswUT.cjs → OrdersScreen-DgBe0kl9.cjs} +3 -3
- package/dist/{OrdersScreen-DE1lIZKm.mjs → OrdersScreen-ihhKswAb.mjs} +3 -3
- package/dist/{OrdersScreen-DE1lIZKm.mjs.map → OrdersScreen-ihhKswAb.mjs.map} +1 -1
- package/dist/{ProductsScreen-chLWiA1J.mjs → ProductsScreen-BbgYlCfQ.mjs} +6 -6
- package/dist/{ProductsScreen-chLWiA1J.mjs.map → ProductsScreen-BbgYlCfQ.mjs.map} +1 -1
- package/dist/{ProductsScreen-Bq1Q_T06.cjs → ProductsScreen-BulxEN71.cjs} +7 -7
- package/dist/{ProductsScreen-DA0yNpXn.mjs → ProductsScreen-OPY76KpG.mjs} +6 -7
- package/dist/{ProductsScreen-CC1BM7Ye.cjs → ProductsScreen-snrXLhuy.cjs} +6 -6
- package/dist/{ProductsScreen-CC1BM7Ye.cjs.map → ProductsScreen-snrXLhuy.cjs.map} +1 -1
- package/dist/{ProfileScreen-CxvAKgdU.cjs → ProfileScreen-CES4uRpE.cjs} +2 -2
- package/dist/{ProfileScreen-Dm8EcLVL.cjs → ProfileScreen-CPCkXse4.cjs} +4 -5
- package/dist/{ProfileScreen-Dm8EcLVL.cjs.map → ProfileScreen-CPCkXse4.cjs.map} +1 -1
- package/dist/{ProfileScreen-DmV9jRth.mjs → ProfileScreen-doxUb6Ud.mjs} +3 -4
- package/dist/{ProfileScreen-DmV9jRth.mjs.map → ProfileScreen-doxUb6Ud.mjs.map} +1 -1
- package/dist/{SearchSort-CyeeUmwC.cjs → SearchSort-DOLoubGE.cjs} +1 -1
- package/dist/{SearchSort-CyeeUmwC.cjs.map → SearchSort-DOLoubGE.cjs.map} +1 -1
- package/dist/{SearchSort-BXklP8Pq.mjs → SearchSort-LZm-VfF7.mjs} +1 -1
- package/dist/{SearchSort-BXklP8Pq.mjs.map → SearchSort-LZm-VfF7.mjs.map} +1 -1
- package/dist/{ShareablesScreen-CNmjazDa.cjs → ShareablesScreen-B6-BcjEt.cjs} +7 -7
- package/dist/{ShareablesScreen-B9iGTVVk.mjs → ShareablesScreen-CJk0udFG.mjs} +7 -7
- package/dist/{ShareablesScreen-B9iGTVVk.mjs.map → ShareablesScreen-CJk0udFG.mjs.map} +1 -1
- package/dist/{ShareablesScreen-CVkk0Lpn.cjs → ShareablesScreen-DaQAxGCr.cjs} +7 -7
- package/dist/{ShareablesScreen-CVkk0Lpn.cjs.map → ShareablesScreen-DaQAxGCr.cjs.map} +1 -1
- package/dist/{ShareablesScreen-D7cFD7Sn.mjs → ShareablesScreen-yC7UrhhU.mjs} +6 -7
- package/dist/{ShopScreen-BdyMXm0s.mjs → ShopScreen-B3kyH-AP.mjs} +5 -5
- package/dist/{ShopScreen-BdyMXm0s.mjs.map → ShopScreen-B3kyH-AP.mjs.map} +1 -1
- package/dist/{ShopScreen-B5GJr-kG.cjs → ShopScreen-D6JAjTai.cjs} +5 -5
- package/dist/{ShopScreen-B5GJr-kG.cjs.map → ShopScreen-D6JAjTai.cjs.map} +1 -1
- package/dist/{ShopScreen-Che0Axn9.cjs → ShopScreen-DUpCS4va.cjs} +3 -3
- package/dist/{SubscriptionsScreen-xNd35SPG.cjs → SubscriptionsScreen-CEkKX-O9.cjs} +5 -5
- package/dist/{SubscriptionsScreen-xNd35SPG.cjs.map → SubscriptionsScreen-CEkKX-O9.cjs.map} +1 -1
- package/dist/{SubscriptionsScreen-BqiGuMsz.mjs → SubscriptionsScreen-DlRbMhFz.mjs} +5 -5
- package/dist/{SubscriptionsScreen-BqiGuMsz.mjs.map → SubscriptionsScreen-DlRbMhFz.mjs.map} +1 -1
- package/dist/{SubscriptionsScreen-DHYHBWVD.cjs → SubscriptionsScreen-jpRkUvPY.cjs} +5 -5
- package/dist/{dist-Cl4FsM3V.mjs → dist-B8padP0r.mjs} +2 -2
- package/dist/{dist-Cl4FsM3V.mjs.map → dist-B8padP0r.mjs.map} +1 -1
- package/dist/{dist-CbeLS2R5.cjs → dist-BoyKnTdv.cjs} +2 -2
- package/dist/{dist-CbeLS2R5.cjs.map → dist-BoyKnTdv.cjs.map} +1 -1
- package/dist/{dist-BbS_7TvS.cjs → dist-DRVtlgQ1.cjs} +1 -1
- package/dist/{dist-BbS_7TvS.cjs.map → dist-DRVtlgQ1.cjs.map} +1 -1
- package/dist/{dist-CMGXkSgZ.mjs → dist-NMbUD0qE.mjs} +1 -1
- package/dist/{dist-CMGXkSgZ.mjs.map → dist-NMbUD0qE.mjs.map} +1 -1
- package/dist/{es-BSkb3AZk.cjs → es-DlWO6buB.cjs} +1 -1
- package/dist/{es-BSkb3AZk.cjs.map → es-DlWO6buB.cjs.map} +1 -1
- package/dist/index.cjs +41 -41
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +40 -40
- package/dist/{order-status-badge-DsbuULAc.cjs → order-status-badge-BqoNJ8XK.cjs} +1 -1
- package/dist/{order-status-badge-DsbuULAc.cjs.map → order-status-badge-BqoNJ8XK.cjs.map} +1 -1
- package/dist/{order-status-badge-B-iGmxDO.mjs → order-status-badge-CkvYyjT7.mjs} +1 -1
- package/dist/{order-status-badge-B-iGmxDO.mjs.map → order-status-badge-CkvYyjT7.mjs.map} +1 -1
- package/dist/{portal-tenant-product-media-adapter-y_yCswfv.mjs → portal-tenant-product-media-adapter-BHtx3DdM.mjs} +4 -4
- package/dist/{portal-tenant-product-media-adapter-y_yCswfv.mjs.map → portal-tenant-product-media-adapter-BHtx3DdM.mjs.map} +1 -1
- package/dist/{portal-tenant-product-media-adapter-DmH2iJvp.cjs → portal-tenant-product-media-adapter-qXW0vGG8.cjs} +5 -5
- package/dist/{portal-tenant-product-media-adapter-DmH2iJvp.cjs.map → portal-tenant-product-media-adapter-qXW0vGG8.cjs.map} +1 -1
- package/dist/{use-account-clients-CrfXjWkZ.cjs → use-account-clients-GUakuhX-.cjs} +2 -216
- package/dist/use-account-clients-GUakuhX-.cjs.map +1 -0
- package/dist/{use-account-clients-B6QsWPOL.mjs → use-account-clients-d3FMT7rH.mjs} +3 -211
- package/dist/use-account-clients-d3FMT7rH.mjs.map +1 -0
- package/dist/{use-current-user-tKZEo3eh.mjs → use-current-user-Cjd0lFyc.mjs} +3 -3
- package/dist/{use-current-user-tKZEo3eh.mjs.map → use-current-user-Cjd0lFyc.mjs.map} +1 -1
- package/dist/{use-current-user-BcmQRCRx.cjs → use-current-user-idj1wuKD.cjs} +3 -3
- package/dist/{use-current-user-BcmQRCRx.cjs.map → use-current-user-idj1wuKD.cjs.map} +1 -1
- package/dist/{use-fluid-api-9llkapbM.mjs → use-fluid-api-DdMmBE5K.mjs} +2 -2
- package/dist/{use-fluid-api-9llkapbM.mjs.map → use-fluid-api-DdMmBE5K.mjs.map} +1 -1
- package/dist/{use-fluid-api-Cj5Bow8S.cjs → use-fluid-api-DnDH2bby.cjs} +2 -2
- package/dist/{use-fluid-api-Cj5Bow8S.cjs.map → use-fluid-api-DnDH2bby.cjs.map} +1 -1
- package/dist/{use-fluid-auth-D4NGGBW0.cjs → use-fluid-auth-CcxpIYkI.cjs} +2 -2
- package/dist/{use-fluid-auth-D4NGGBW0.cjs.map → use-fluid-auth-CcxpIYkI.cjs.map} +1 -1
- package/dist/{use-fluid-auth-vb2QMUi4.mjs → use-fluid-auth-_LboeZI9.mjs} +2 -2
- package/dist/{use-fluid-auth-vb2QMUi4.mjs.map → use-fluid-auth-_LboeZI9.mjs.map} +1 -1
- package/dist/{use-portal-products-client-CJjec9vb.mjs → use-portal-products-client-DA7Vop2s.mjs} +2 -2
- package/dist/{use-portal-products-client-CJjec9vb.mjs.map → use-portal-products-client-DA7Vop2s.mjs.map} +1 -1
- package/dist/{use-portal-products-client-3JPetPQU.cjs → use-portal-products-client-DAXn2JSf.cjs} +2 -2
- package/dist/{use-portal-products-client-3JPetPQU.cjs.map → use-portal-products-client-DAXn2JSf.cjs.map} +1 -1
- package/package.json +19 -19
- package/dist/FluidProvider-9laphShJ.cjs.map +0 -1
- package/dist/FluidProvider-D8lmeIsK.mjs.map +0 -1
- package/dist/use-account-clients-B6QsWPOL.mjs.map +0 -1
- package/dist/use-account-clients-CrfXjWkZ.cjs.map +0 -1
- /package/dist/{src-zEMEV1KP.mjs → src-6SxtfYk9.mjs} +0 -0
- /package/dist/{src-CzwiFO_J.cjs → src-ClULVolb.cjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-9hOWP6kD.cjs");
|
|
2
|
-
const require_FluidProvider = require("./FluidProvider-
|
|
2
|
+
const require_FluidProvider = require("./FluidProvider-DzCUwDPA.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
//#region ../../subscriptions/api-client/src/portal-tenant-adapter.ts
|
|
5
5
|
/**
|
|
@@ -157,210 +157,6 @@ function createPortalOrdersAdapter(client) {
|
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
//#endregion
|
|
160
|
-
//#region ../../api-clients/portal-tenant-pay/src/namespaces/portal_tenant_pay.ts
|
|
161
|
-
/**
|
|
162
|
-
* List addresses
|
|
163
|
-
* Returns addresses associated with the member's customer record in this tenant.
|
|
164
|
-
*
|
|
165
|
-
* @param client - Fetch client instance
|
|
166
|
-
* @param [params] - params
|
|
167
|
-
*/
|
|
168
|
-
async function addresses_list(client, params) {
|
|
169
|
-
return client.get(`/api/pay/addresses`, params);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Create an address
|
|
173
|
-
* Adds a new address to the member's customer record. If an identical address already exists it is returned instead of creating a duplicate.
|
|
174
|
-
*
|
|
175
|
-
* @param client - Fetch client instance
|
|
176
|
-
* @param body - body
|
|
177
|
-
*/
|
|
178
|
-
async function addresses_create(client, body) {
|
|
179
|
-
return client.post(`/api/pay/addresses`, body);
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Update an address
|
|
183
|
-
* Creates a new address with the merged attributes and discards the old one, preserving references from existing orders.
|
|
184
|
-
*
|
|
185
|
-
* @param client - Fetch client instance
|
|
186
|
-
* @param id - id
|
|
187
|
-
* @param body - body
|
|
188
|
-
*/
|
|
189
|
-
async function addresses_update(client, id, body) {
|
|
190
|
-
return client.patch(`/api/pay/addresses/${id}`, body);
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Delete an address
|
|
194
|
-
* Removes an address from the member's customer record. The default address cannot be removed.
|
|
195
|
-
*
|
|
196
|
-
* @param client - Fetch client instance
|
|
197
|
-
* @param id - id
|
|
198
|
-
*/
|
|
199
|
-
async function addresses_destroy(client, id) {
|
|
200
|
-
return client.delete(`/api/pay/addresses/${id}`);
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* List payment methods
|
|
204
|
-
* Returns displayable payment methods on the member's customer record, excluding Apple Pay sources.
|
|
205
|
-
*
|
|
206
|
-
* @param client - Fetch client instance
|
|
207
|
-
* @param [params] - params
|
|
208
|
-
*/
|
|
209
|
-
async function payment_methods_list(client, params) {
|
|
210
|
-
return client.get(`/api/pay/payment_methods`, params);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Create a payment method
|
|
214
|
-
* Tokenizes and stores a new payment method via the vault provider. Requires a vault token obtained from the vault credentials endpoint.
|
|
215
|
-
*
|
|
216
|
-
* @param client - Fetch client instance
|
|
217
|
-
* @param body - body
|
|
218
|
-
*/
|
|
219
|
-
async function payment_methods_create(client, body) {
|
|
220
|
-
return client.post(`/api/pay/payment_methods`, body);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Update a payment method
|
|
224
|
-
* Updates a payment method's attributes. Currently supports setting a payment method as the default.
|
|
225
|
-
*
|
|
226
|
-
* @param client - Fetch client instance
|
|
227
|
-
* @param id - id
|
|
228
|
-
* @param body - body
|
|
229
|
-
*/
|
|
230
|
-
async function payment_methods_update(client, id, body) {
|
|
231
|
-
return client.patch(`/api/pay/payment_methods/${id}`, body);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Delete a payment method
|
|
235
|
-
* Removes a payment method from the member's customer record. If the removed method was the default, the default is cleared.
|
|
236
|
-
*
|
|
237
|
-
* @param client - Fetch client instance
|
|
238
|
-
* @param id - id
|
|
239
|
-
*/
|
|
240
|
-
async function payment_methods_destroy(client, id) {
|
|
241
|
-
return client.delete(`/api/pay/payment_methods/${id}`);
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Get vault credentials
|
|
245
|
-
* Returns a short-lived vault token and environment identifier for initializing the client-side payment vault SDK.
|
|
246
|
-
*
|
|
247
|
-
* @param client - Fetch client instance
|
|
248
|
-
|
|
249
|
-
*/
|
|
250
|
-
async function payment_methods_vault_show(client) {
|
|
251
|
-
return client.get(`/api/pay/payment_methods/vault`);
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* List points ledger entries
|
|
255
|
-
* Returns loyalty points ledger entries for the member's customer record in this tenant, ordered by most recent first.
|
|
256
|
-
*
|
|
257
|
-
* @param client - Fetch client instance
|
|
258
|
-
* @param [params] - params
|
|
259
|
-
*/
|
|
260
|
-
async function points_ledgers_list(client, params) {
|
|
261
|
-
return client.get(`/api/pay/points_ledgers`, params);
|
|
262
|
-
}
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region src/adapters/pay-api-adapter.ts
|
|
265
|
-
function mapAddress(raw) {
|
|
266
|
-
return {
|
|
267
|
-
id: raw.id ?? 0,
|
|
268
|
-
street1: raw.street1 ?? "",
|
|
269
|
-
street2: raw.street2 ?? null,
|
|
270
|
-
city: raw.city ?? "",
|
|
271
|
-
state: raw.state ?? "",
|
|
272
|
-
zip: raw.zip ?? "",
|
|
273
|
-
country: raw.country ?? "",
|
|
274
|
-
default: raw.default ?? false,
|
|
275
|
-
created_at: raw.created_at ?? null,
|
|
276
|
-
updated_at: raw.updated_at ?? null
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
function mapPaymentMethod(raw) {
|
|
280
|
-
return {
|
|
281
|
-
id: raw.id ?? 0,
|
|
282
|
-
type: raw.type ?? "card",
|
|
283
|
-
brand: raw.brand ?? null,
|
|
284
|
-
last_four: raw.last_four ?? "",
|
|
285
|
-
exp_month: raw.exp_month ?? null,
|
|
286
|
-
exp_year: raw.exp_year ?? null,
|
|
287
|
-
default: raw.default ?? false,
|
|
288
|
-
created_at: raw.created_at ?? null,
|
|
289
|
-
updated_at: raw.updated_at ?? null
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
function createPortalTenantPayAdapter(client) {
|
|
293
|
-
return {
|
|
294
|
-
fetchAddresses: async () => {
|
|
295
|
-
const response = await addresses_list(client);
|
|
296
|
-
return {
|
|
297
|
-
addresses: (response.addresses ?? []).map(mapAddress),
|
|
298
|
-
meta: {
|
|
299
|
-
request_id: response.meta?.request_id ?? "",
|
|
300
|
-
timestamp: response.meta?.timestamp ?? ""
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
},
|
|
304
|
-
createAddress: async (body) => {
|
|
305
|
-
await addresses_create(client, body);
|
|
306
|
-
},
|
|
307
|
-
updateAddress: async (addressId, body) => {
|
|
308
|
-
await addresses_update(client, addressId, body);
|
|
309
|
-
},
|
|
310
|
-
deleteAddress: async (addressId) => {
|
|
311
|
-
await addresses_destroy(client, addressId);
|
|
312
|
-
},
|
|
313
|
-
fetchPaymentMethods: async () => {
|
|
314
|
-
const response = await payment_methods_list(client);
|
|
315
|
-
return {
|
|
316
|
-
payment_methods: (response.payment_methods ?? []).map(mapPaymentMethod),
|
|
317
|
-
meta: {
|
|
318
|
-
request_id: response.meta?.request_id ?? "",
|
|
319
|
-
timestamp: response.meta?.timestamp ?? ""
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
},
|
|
323
|
-
createPaymentMethod: async (body) => {
|
|
324
|
-
await payment_methods_create(client, body);
|
|
325
|
-
},
|
|
326
|
-
updatePaymentMethod: async (paymentMethodId, body) => {
|
|
327
|
-
await payment_methods_update(client, paymentMethodId, body);
|
|
328
|
-
},
|
|
329
|
-
deletePaymentMethod: async (paymentMethodId) => {
|
|
330
|
-
await payment_methods_destroy(client, paymentMethodId);
|
|
331
|
-
},
|
|
332
|
-
fetchVaultCredentials: async () => {
|
|
333
|
-
const response = await payment_methods_vault_show(client);
|
|
334
|
-
return {
|
|
335
|
-
vault: {
|
|
336
|
-
token: response.vault?.token ?? null,
|
|
337
|
-
environment: response.vault?.environment ?? "production"
|
|
338
|
-
},
|
|
339
|
-
meta: {
|
|
340
|
-
request_id: response.meta?.request_id ?? "",
|
|
341
|
-
timestamp: response.meta?.timestamp ?? ""
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
},
|
|
345
|
-
fetchPointsLedgers: async () => {
|
|
346
|
-
const response = await points_ledgers_list(client);
|
|
347
|
-
return {
|
|
348
|
-
points_ledgers: (response.points_ledgers ?? []).map((entry) => ({
|
|
349
|
-
id: entry.id ?? 0,
|
|
350
|
-
amount: entry.amount ?? 0,
|
|
351
|
-
total_balance: entry.total_balance ?? 0,
|
|
352
|
-
metadata: entry.metadata ?? null,
|
|
353
|
-
created_at: entry.created_at ?? ""
|
|
354
|
-
})),
|
|
355
|
-
meta: {
|
|
356
|
-
request_id: response.meta?.request_id ?? "",
|
|
357
|
-
timestamp: response.meta?.timestamp ?? ""
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
//#endregion
|
|
364
160
|
//#region src/account/use-account-clients.ts
|
|
365
161
|
function useOrdersApi() {
|
|
366
162
|
const client = require_FluidProvider.usePortalTenantClient();
|
|
@@ -370,10 +166,6 @@ function useSubscriptionsApiClient() {
|
|
|
370
166
|
const client = require_FluidProvider.usePortalTenantClient();
|
|
371
167
|
return (0, react.useMemo)(() => createPortalSubscriptionsAdapter(client), [client]);
|
|
372
168
|
}
|
|
373
|
-
function usePayApi() {
|
|
374
|
-
const client = require_FluidProvider.usePortalTenantClient();
|
|
375
|
-
return (0, react.useMemo)(() => createPortalTenantPayAdapter(client), [client]);
|
|
376
|
-
}
|
|
377
169
|
/**
|
|
378
170
|
* Ensures baseUrl ends with /api.
|
|
379
171
|
* Uncovered endpoints (e.g. /countries, points ledgers) use paths without the
|
|
@@ -404,12 +196,6 @@ Object.defineProperty(exports, "useOrdersApi", {
|
|
|
404
196
|
return useOrdersApi;
|
|
405
197
|
}
|
|
406
198
|
});
|
|
407
|
-
Object.defineProperty(exports, "usePayApi", {
|
|
408
|
-
enumerable: true,
|
|
409
|
-
get: function() {
|
|
410
|
-
return usePayApi;
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
199
|
Object.defineProperty(exports, "useSdkClient", {
|
|
414
200
|
enumerable: true,
|
|
415
201
|
get: function() {
|
|
@@ -423,4 +209,4 @@ Object.defineProperty(exports, "useSubscriptionsApiClient", {
|
|
|
423
209
|
}
|
|
424
210
|
});
|
|
425
211
|
|
|
426
|
-
//# sourceMappingURL=use-account-clients-
|
|
212
|
+
//# sourceMappingURL=use-account-clients-GUakuhX-.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-account-clients-GUakuhX-.cjs","names":["mapMeta","usePortalTenantClient","useFluidContext","createFetchClient"],"sources":["../../../subscriptions/api-client/src/portal-tenant-adapter.ts","../../../orders/api-client/src/portal-tenant-adapter.ts","../src/adapters/orders-api-adapter.ts","../src/account/use-account-clients.ts"],"sourcesContent":["import type { SubscriptionsApi } from \"@fluid-app/subscriptions-core\";\nimport type { FetchClient } from \"./lib/fetch-client\";\nimport type { subscriptions } from \"./custom/subscriptions\";\nimport { portalTenant } from \"@fluid-app/portal-tenant-api-client\";\n\n/**\n * Maps the BFF meta envelope to the port's expected shape.\n */\nfunction mapMeta(raw: { request_id?: string | null; timestamp?: string }): {\n request_id: string;\n timestamp: string;\n} {\n return {\n request_id: raw.request_id ?? \"\",\n timestamp: raw.timestamp ?? \"\",\n };\n}\n\ntype BffSubscriptionResponse = Awaited<\n ReturnType<typeof portalTenant.subscriptions_show>\n>;\n\ntype BffListResponse = Awaited<\n ReturnType<typeof portalTenant.subscriptions_list>\n>;\n\n/**\n * Maps a BFF subscription detail response to the port's SubscriptionDetail.\n *\n * The BFF returns a flat Subscription schema while the port expects a richly\n * nested SubscriptionDetailSubscription. Both represent the same underlying\n * data — the consuming portal UI only accesses the subset of fields the BFF\n * provides. The explicit field mapping ensures the envelope structure is\n * correct, while the subscription data passes through at runtime.\n */\nfunction mapSubscriptionDetail(\n response: BffSubscriptionResponse,\n): subscriptions.SubscriptionDetail {\n return {\n subscription: (response.subscription ??\n {}) as unknown as subscriptions.SubscriptionDetailSubscription,\n meta: response.meta ? mapMeta(response.meta) : undefined,\n };\n}\n\nfunction mapSubscriptionList(\n response: BffListResponse,\n): subscriptions.SubscriptionsResponse {\n return {\n subscriptions: (response.subscriptions ??\n []) as unknown as subscriptions.SubscriptionListItem[],\n meta: mapMeta(response.meta ?? {}),\n };\n}\n\n/**\n * Creates a SubscriptionsApi-compatible adapter backed by the portal-tenant BFF.\n *\n * Uses async/await with explicit field mapping. The BFF returns simplified\n * subscription types compared to the full admin API; the adapter maps the\n * response envelope and provides runtime defaults for optional fields.\n */\nexport function createPortalSubscriptionsAdapter(\n client: FetchClient,\n): SubscriptionsApi {\n return {\n fetchCustomerSubscriptions: async (\n params: subscriptions.FetchSubscriptionsParams,\n ) => {\n const response = await portalTenant.subscriptions_list(client, {\n \"page[cursor]\": params.cursor,\n \"page[limit]\": params.limit ?? params.perPage,\n });\n return mapSubscriptionList(response);\n },\n\n fetchSubscription: async (subscriptionToken: string) => {\n const response = await portalTenant.subscriptions_show(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n pauseSubscription: async (\n subscriptionToken: string,\n _params: subscriptions.PauseSubscriptionParams,\n ) => {\n const response = await portalTenant.subscriptions_pause(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n resumeSubscription: async (\n subscriptionToken: string,\n _params: subscriptions.ResumeSubscriptionParams,\n ) => {\n const response = await portalTenant.subscriptions_resume(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n skipSubscription: async (\n subscriptionToken: string,\n _params: subscriptions.SkipSubscriptionParams,\n ) => {\n const response = await portalTenant.subscriptions_skip(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n cancelSubscription: async (\n subscriptionToken: string,\n _customerId?: number,\n ) => {\n const response = await portalTenant.subscriptions_cancel(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n reactivateSubscription: async (\n subscriptionToken: string,\n _params: subscriptions.ReactivateSubscriptionParams,\n ) => {\n const response = await portalTenant.subscriptions_reactivate(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n updateSubscriptionInfo: async (\n subscriptionToken: string,\n body: Pick<subscriptions.UpdateSubscriptionInfoBody, \"payment_method_id\">,\n ) => {\n const response = await portalTenant.subscriptions_update(\n client,\n subscriptionToken,\n { subscription: { payment_method_id: body.payment_method_id } },\n );\n return mapSubscriptionDetail(response);\n },\n };\n}\n","import type { FetchClient } from \"./lib/fetch-client\";\nimport type { OrdersApi } from \"@fluid-app/orders-core\";\nimport type { orders } from \"@fluid-app/orders-core\";\nimport { portalTenant } from \"@fluid-app/portal-tenant-api-client\";\n\n/**\n * Creates an OrdersApi adapter backed by the portal-tenant BFF.\n *\n * Maps the generated portal-tenant namespace functions to the abstract\n * OrdersApi port, closing over the FetchClient so consumers don't need\n * to pass it per-call.\n */\n\nfunction mapOrder(\n raw: NonNullable<\n Awaited<ReturnType<typeof portalTenant.orders_show>>[\"order\"]\n >,\n): orders.PortalTenantOrder {\n return {\n id: raw.id ?? 0,\n token: raw.token ?? \"\",\n status: (raw.status ?? \"pending\") as orders.PortalTenantOrderStatus,\n total: raw.total ?? \"0\",\n currency: raw.currency ?? \"\",\n line_items: (raw.line_items ?? []).map((li) => ({\n id: li.id ?? 0,\n product_id: li.product_id ?? 0,\n product_name: li.product_name ?? \"\",\n quantity: li.quantity ?? 0,\n price: li.price ?? \"0\",\n total: li.total ?? \"0\",\n })),\n customer_name: raw.customer_name ?? null,\n customer_email: raw.customer_email ?? null,\n total_points_credited:\n typeof (raw as Record<string, unknown>).total_points_credited === \"number\"\n ? ((raw as Record<string, unknown>).total_points_credited as number)\n : undefined,\n customer_points_balance:\n typeof (raw as Record<string, unknown>).customer_points_balance ===\n \"number\"\n ? ((raw as Record<string, unknown>).customer_points_balance as number)\n : undefined,\n created_at: raw.created_at ?? \"\",\n updated_at: raw.updated_at ?? \"\",\n } satisfies orders.PortalTenantOrder;\n}\n\nfunction mapMeta(\n raw: Awaited<ReturnType<typeof portalTenant.orders_list>>[\"meta\"] | undefined,\n): orders.PortalTenantMeta {\n return {\n request_id: raw?.request_id ?? \"\",\n timestamp: raw?.timestamp ?? \"\",\n pagination: {\n cursor: raw?.pagination?.cursor ?? null,\n limit: raw?.pagination?.limit ?? 25,\n next_cursor: raw?.pagination?.next_cursor ?? null,\n prev_cursor: raw?.pagination?.prev_cursor ?? null,\n },\n } satisfies orders.PortalTenantMeta;\n}\n\nexport function createPortalTenantOrdersAdapter(\n client: FetchClient,\n): Required<Pick<OrdersApi, \"fetchOrderById\" | \"fetchOrders\">> {\n return {\n fetchOrderById: async (id: number) => {\n const response = await portalTenant.orders_show(client, id);\n return {\n order: mapOrder(response.order ?? {}),\n meta: {\n request_id: response.meta?.request_id ?? \"\",\n timestamp: response.meta?.timestamp ?? \"\",\n },\n } satisfies orders.PortalTenantOrderResponse;\n },\n\n fetchOrders: async (params: orders.PortalTenantFetchOrdersParams) => {\n const response = await portalTenant.orders_list(client, {\n \"page[cursor]\": params.cursor,\n \"page[limit]\": params.limit,\n status: params.status,\n });\n return {\n orders: (response.orders ?? []).map(mapOrder),\n meta: mapMeta(response.meta),\n } satisfies orders.PortalTenantOrdersResponse;\n },\n };\n}\n","import type { OrdersApi } from \"@fluid-app/orders-core\";\nimport type { FetchClient } from \"@fluid-app/portal-tenant-api-client\";\nimport { createPortalTenantOrdersAdapter } from \"@fluid-app/orders-api-client\";\n\n/**\n * Creates an OrdersApi adapter for the portal-tenant BFF.\n *\n * Delegates to the existing clean adapter in orders/api-client which maps\n * BFF responses to PortalTenantOrder types. The legacy methods (fetchOrder,\n * fetchCustomerOrders) are not used by portal UI — portal-specific hooks\n * call fetchOrders/fetchOrderById directly.\n */\nexport function createPortalOrdersAdapter(client: FetchClient): OrdersApi {\n const bffAdapter = createPortalTenantOrdersAdapter(client);\n return {\n fetchOrderById: bffAdapter.fetchOrderById,\n fetchOrders: bffAdapter.fetchOrders,\n };\n}\n","import { useMemo } from \"react\";\nimport type { OrdersApi } from \"@fluid-app/orders-core\";\nimport type { SubscriptionsApi } from \"@fluid-app/subscriptions-core\";\nimport { createPortalSubscriptionsAdapter } from \"@fluid-app/subscriptions-api-client\";\nimport {\n createFetchClient,\n type FetchClient as CoreFetchClient,\n} from \"@fluid-app/api-client-core\";\nimport { createPortalOrdersAdapter } from \"../adapters/orders-api-adapter\";\nimport { usePortalTenantClient } from \"../providers/PortalTenantClientProvider\";\nimport { useFluidContext } from \"../providers/FluidProvider\";\n\n/** API version prefix for versioned endpoints (e.g. points ledger) */\nexport const API_VERSION = \"/v202506\";\n\nexport function useOrdersApi(): OrdersApi {\n const client = usePortalTenantClient();\n\n return useMemo(() => createPortalOrdersAdapter(client), [client]);\n}\n\nexport function useSubscriptionsApiClient(): SubscriptionsApi {\n const client = usePortalTenantClient();\n\n return useMemo(() => createPortalSubscriptionsAdapter(client), [client]);\n}\n\n/**\n * Ensures baseUrl ends with /api.\n * Uncovered endpoints (e.g. /countries, points ledgers) use paths without the\n * /api prefix, so the base URL must include it.\n */\nfunction withApiPrefix(baseUrl: string): string {\n const base = baseUrl.replace(/\\/+$/, \"\");\n return base.endsWith(\"/api\") ? base : `${base}/api`;\n}\n\n/**\n * Generic SDK fetch client for endpoints not covered by domain-specific clients\n * (e.g. /countries, /v202506/customers/:id/points_ledgers).\n * Creates a FetchClient with /api-prefixed baseUrl since these endpoints\n * use paths like /countries (not /api/countries).\n */\nexport function useSdkClient(): CoreFetchClient {\n const { config } = useFluidContext();\n\n return useMemo(\n () =>\n createFetchClient({\n baseUrl: withApiPrefix(config.baseUrl),\n onAuthError: config.onAuthError,\n credentials: \"include\",\n }),\n [config.baseUrl, config.onAuthError],\n );\n}\n"],"mappings":";;;;;;;AAQA,SAASA,UAAQ,KAGf;AACA,QAAO;EACL,YAAY,IAAI,cAAc;EAC9B,WAAW,IAAI,aAAa;EAC7B;;;;;;;;;;;AAoBH,SAAS,sBACP,UACkC;AAClC,QAAO;EACL,cAAe,SAAS,gBACtB,EAAE;EACJ,MAAM,SAAS,OAAOA,UAAQ,SAAS,KAAK,GAAG,KAAA;EAChD;;AAGH,SAAS,oBACP,UACqC;AACrC,QAAO;EACL,eAAgB,SAAS,iBACvB,EAAE;EACJ,MAAMA,UAAQ,SAAS,QAAQ,EAAE,CAAC;EACnC;;;;;;;;;AAUH,SAAgB,iCACd,QACkB;AAClB,QAAO;EACL,4BAA4B,OAC1B,WACG;AAKH,UAAO,oBAJU,M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A,MAAA,eAAqB,iCAAiC,OAAO,EAAE,CAAC,OAAO,CAAC;;;;;;;AAQ1E,SAAS,cAAc,SAAyB;CAC9C,MAAM,OAAO,QAAQ,QAAQ,QAAQ,GAAG;AACxC,QAAO,KAAK,SAAS,OAAO,GAAG,OAAO,GAAG,KAAK;;;;;;;;AAShD,SAAgB,eAAgC;CAC9C,MAAM,EAAE,WAAWC,sBAAAA,iBAAiB;AAEpC,SAAA,GAAA,MAAA,eAEIC,sBAAAA,kBAAkB;EAChB,SAAS,cAAc,OAAO,QAAQ;EACtC,aAAa,OAAO;EACpB,aAAa;EACd,CAAC,EACJ,CAAC,OAAO,SAAS,OAAO,YAAY,CACrC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _t as createFetchClient, ct as subscriptions_cancel, dt as subscriptions_reactivate, ft as subscriptions_resume, ht as subscriptions_update, lt as subscriptions_list, mt as subscriptions_skip, n as useFluidContext, nt as orders_list, pt as subscriptions_show, rt as orders_show, u as usePortalTenantClient, ut as subscriptions_pause } from "./FluidProvider-
|
|
1
|
+
import { _t as createFetchClient, ct as subscriptions_cancel, dt as subscriptions_reactivate, ft as subscriptions_resume, ht as subscriptions_update, lt as subscriptions_list, mt as subscriptions_skip, n as useFluidContext, nt as orders_list, pt as subscriptions_show, rt as orders_show, u as usePortalTenantClient, ut as subscriptions_pause } from "./FluidProvider-Bs9eWShT.mjs";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
//#region ../../subscriptions/api-client/src/portal-tenant-adapter.ts
|
|
4
4
|
/**
|
|
@@ -156,210 +156,6 @@ function createPortalOrdersAdapter(client) {
|
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
//#endregion
|
|
159
|
-
//#region ../../api-clients/portal-tenant-pay/src/namespaces/portal_tenant_pay.ts
|
|
160
|
-
/**
|
|
161
|
-
* List addresses
|
|
162
|
-
* Returns addresses associated with the member's customer record in this tenant.
|
|
163
|
-
*
|
|
164
|
-
* @param client - Fetch client instance
|
|
165
|
-
* @param [params] - params
|
|
166
|
-
*/
|
|
167
|
-
async function addresses_list(client, params) {
|
|
168
|
-
return client.get(`/api/pay/addresses`, params);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Create an address
|
|
172
|
-
* Adds a new address to the member's customer record. If an identical address already exists it is returned instead of creating a duplicate.
|
|
173
|
-
*
|
|
174
|
-
* @param client - Fetch client instance
|
|
175
|
-
* @param body - body
|
|
176
|
-
*/
|
|
177
|
-
async function addresses_create(client, body) {
|
|
178
|
-
return client.post(`/api/pay/addresses`, body);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Update an address
|
|
182
|
-
* Creates a new address with the merged attributes and discards the old one, preserving references from existing orders.
|
|
183
|
-
*
|
|
184
|
-
* @param client - Fetch client instance
|
|
185
|
-
* @param id - id
|
|
186
|
-
* @param body - body
|
|
187
|
-
*/
|
|
188
|
-
async function addresses_update(client, id, body) {
|
|
189
|
-
return client.patch(`/api/pay/addresses/${id}`, body);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Delete an address
|
|
193
|
-
* Removes an address from the member's customer record. The default address cannot be removed.
|
|
194
|
-
*
|
|
195
|
-
* @param client - Fetch client instance
|
|
196
|
-
* @param id - id
|
|
197
|
-
*/
|
|
198
|
-
async function addresses_destroy(client, id) {
|
|
199
|
-
return client.delete(`/api/pay/addresses/${id}`);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* List payment methods
|
|
203
|
-
* Returns displayable payment methods on the member's customer record, excluding Apple Pay sources.
|
|
204
|
-
*
|
|
205
|
-
* @param client - Fetch client instance
|
|
206
|
-
* @param [params] - params
|
|
207
|
-
*/
|
|
208
|
-
async function payment_methods_list(client, params) {
|
|
209
|
-
return client.get(`/api/pay/payment_methods`, params);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Create a payment method
|
|
213
|
-
* Tokenizes and stores a new payment method via the vault provider. Requires a vault token obtained from the vault credentials endpoint.
|
|
214
|
-
*
|
|
215
|
-
* @param client - Fetch client instance
|
|
216
|
-
* @param body - body
|
|
217
|
-
*/
|
|
218
|
-
async function payment_methods_create(client, body) {
|
|
219
|
-
return client.post(`/api/pay/payment_methods`, body);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Update a payment method
|
|
223
|
-
* Updates a payment method's attributes. Currently supports setting a payment method as the default.
|
|
224
|
-
*
|
|
225
|
-
* @param client - Fetch client instance
|
|
226
|
-
* @param id - id
|
|
227
|
-
* @param body - body
|
|
228
|
-
*/
|
|
229
|
-
async function payment_methods_update(client, id, body) {
|
|
230
|
-
return client.patch(`/api/pay/payment_methods/${id}`, body);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Delete a payment method
|
|
234
|
-
* Removes a payment method from the member's customer record. If the removed method was the default, the default is cleared.
|
|
235
|
-
*
|
|
236
|
-
* @param client - Fetch client instance
|
|
237
|
-
* @param id - id
|
|
238
|
-
*/
|
|
239
|
-
async function payment_methods_destroy(client, id) {
|
|
240
|
-
return client.delete(`/api/pay/payment_methods/${id}`);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Get vault credentials
|
|
244
|
-
* Returns a short-lived vault token and environment identifier for initializing the client-side payment vault SDK.
|
|
245
|
-
*
|
|
246
|
-
* @param client - Fetch client instance
|
|
247
|
-
|
|
248
|
-
*/
|
|
249
|
-
async function payment_methods_vault_show(client) {
|
|
250
|
-
return client.get(`/api/pay/payment_methods/vault`);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* List points ledger entries
|
|
254
|
-
* Returns loyalty points ledger entries for the member's customer record in this tenant, ordered by most recent first.
|
|
255
|
-
*
|
|
256
|
-
* @param client - Fetch client instance
|
|
257
|
-
* @param [params] - params
|
|
258
|
-
*/
|
|
259
|
-
async function points_ledgers_list(client, params) {
|
|
260
|
-
return client.get(`/api/pay/points_ledgers`, params);
|
|
261
|
-
}
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/adapters/pay-api-adapter.ts
|
|
264
|
-
function mapAddress(raw) {
|
|
265
|
-
return {
|
|
266
|
-
id: raw.id ?? 0,
|
|
267
|
-
street1: raw.street1 ?? "",
|
|
268
|
-
street2: raw.street2 ?? null,
|
|
269
|
-
city: raw.city ?? "",
|
|
270
|
-
state: raw.state ?? "",
|
|
271
|
-
zip: raw.zip ?? "",
|
|
272
|
-
country: raw.country ?? "",
|
|
273
|
-
default: raw.default ?? false,
|
|
274
|
-
created_at: raw.created_at ?? null,
|
|
275
|
-
updated_at: raw.updated_at ?? null
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
function mapPaymentMethod(raw) {
|
|
279
|
-
return {
|
|
280
|
-
id: raw.id ?? 0,
|
|
281
|
-
type: raw.type ?? "card",
|
|
282
|
-
brand: raw.brand ?? null,
|
|
283
|
-
last_four: raw.last_four ?? "",
|
|
284
|
-
exp_month: raw.exp_month ?? null,
|
|
285
|
-
exp_year: raw.exp_year ?? null,
|
|
286
|
-
default: raw.default ?? false,
|
|
287
|
-
created_at: raw.created_at ?? null,
|
|
288
|
-
updated_at: raw.updated_at ?? null
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function createPortalTenantPayAdapter(client) {
|
|
292
|
-
return {
|
|
293
|
-
fetchAddresses: async () => {
|
|
294
|
-
const response = await addresses_list(client);
|
|
295
|
-
return {
|
|
296
|
-
addresses: (response.addresses ?? []).map(mapAddress),
|
|
297
|
-
meta: {
|
|
298
|
-
request_id: response.meta?.request_id ?? "",
|
|
299
|
-
timestamp: response.meta?.timestamp ?? ""
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
},
|
|
303
|
-
createAddress: async (body) => {
|
|
304
|
-
await addresses_create(client, body);
|
|
305
|
-
},
|
|
306
|
-
updateAddress: async (addressId, body) => {
|
|
307
|
-
await addresses_update(client, addressId, body);
|
|
308
|
-
},
|
|
309
|
-
deleteAddress: async (addressId) => {
|
|
310
|
-
await addresses_destroy(client, addressId);
|
|
311
|
-
},
|
|
312
|
-
fetchPaymentMethods: async () => {
|
|
313
|
-
const response = await payment_methods_list(client);
|
|
314
|
-
return {
|
|
315
|
-
payment_methods: (response.payment_methods ?? []).map(mapPaymentMethod),
|
|
316
|
-
meta: {
|
|
317
|
-
request_id: response.meta?.request_id ?? "",
|
|
318
|
-
timestamp: response.meta?.timestamp ?? ""
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
},
|
|
322
|
-
createPaymentMethod: async (body) => {
|
|
323
|
-
await payment_methods_create(client, body);
|
|
324
|
-
},
|
|
325
|
-
updatePaymentMethod: async (paymentMethodId, body) => {
|
|
326
|
-
await payment_methods_update(client, paymentMethodId, body);
|
|
327
|
-
},
|
|
328
|
-
deletePaymentMethod: async (paymentMethodId) => {
|
|
329
|
-
await payment_methods_destroy(client, paymentMethodId);
|
|
330
|
-
},
|
|
331
|
-
fetchVaultCredentials: async () => {
|
|
332
|
-
const response = await payment_methods_vault_show(client);
|
|
333
|
-
return {
|
|
334
|
-
vault: {
|
|
335
|
-
token: response.vault?.token ?? null,
|
|
336
|
-
environment: response.vault?.environment ?? "production"
|
|
337
|
-
},
|
|
338
|
-
meta: {
|
|
339
|
-
request_id: response.meta?.request_id ?? "",
|
|
340
|
-
timestamp: response.meta?.timestamp ?? ""
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
},
|
|
344
|
-
fetchPointsLedgers: async () => {
|
|
345
|
-
const response = await points_ledgers_list(client);
|
|
346
|
-
return {
|
|
347
|
-
points_ledgers: (response.points_ledgers ?? []).map((entry) => ({
|
|
348
|
-
id: entry.id ?? 0,
|
|
349
|
-
amount: entry.amount ?? 0,
|
|
350
|
-
total_balance: entry.total_balance ?? 0,
|
|
351
|
-
metadata: entry.metadata ?? null,
|
|
352
|
-
created_at: entry.created_at ?? ""
|
|
353
|
-
})),
|
|
354
|
-
meta: {
|
|
355
|
-
request_id: response.meta?.request_id ?? "",
|
|
356
|
-
timestamp: response.meta?.timestamp ?? ""
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
//#endregion
|
|
363
159
|
//#region src/account/use-account-clients.ts
|
|
364
160
|
function useOrdersApi() {
|
|
365
161
|
const client = usePortalTenantClient();
|
|
@@ -369,10 +165,6 @@ function useSubscriptionsApiClient() {
|
|
|
369
165
|
const client = usePortalTenantClient();
|
|
370
166
|
return useMemo(() => createPortalSubscriptionsAdapter(client), [client]);
|
|
371
167
|
}
|
|
372
|
-
function usePayApi() {
|
|
373
|
-
const client = usePortalTenantClient();
|
|
374
|
-
return useMemo(() => createPortalTenantPayAdapter(client), [client]);
|
|
375
|
-
}
|
|
376
168
|
/**
|
|
377
169
|
* Ensures baseUrl ends with /api.
|
|
378
170
|
* Uncovered endpoints (e.g. /countries, points ledgers) use paths without the
|
|
@@ -397,6 +189,6 @@ function useSdkClient() {
|
|
|
397
189
|
}), [config.baseUrl, config.onAuthError]);
|
|
398
190
|
}
|
|
399
191
|
//#endregion
|
|
400
|
-
export {
|
|
192
|
+
export { useSdkClient as n, useSubscriptionsApiClient as r, useOrdersApi as t };
|
|
401
193
|
|
|
402
|
-
//# sourceMappingURL=use-account-clients-
|
|
194
|
+
//# sourceMappingURL=use-account-clients-d3FMT7rH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-account-clients-d3FMT7rH.mjs","names":["mapMeta","portalTenant.subscriptions_list","portalTenant.subscriptions_show","portalTenant.subscriptions_pause","portalTenant.subscriptions_resume","portalTenant.subscriptions_skip","portalTenant.subscriptions_cancel","portalTenant.subscriptions_reactivate","portalTenant.subscriptions_update","portalTenant.orders_show","portalTenant.orders_list"],"sources":["../../../subscriptions/api-client/src/portal-tenant-adapter.ts","../../../orders/api-client/src/portal-tenant-adapter.ts","../src/adapters/orders-api-adapter.ts","../src/account/use-account-clients.ts"],"sourcesContent":["import type { SubscriptionsApi } from \"@fluid-app/subscriptions-core\";\nimport type { FetchClient } from \"./lib/fetch-client\";\nimport type { subscriptions } from \"./custom/subscriptions\";\nimport { portalTenant } from \"@fluid-app/portal-tenant-api-client\";\n\n/**\n * Maps the BFF meta envelope to the port's expected shape.\n */\nfunction mapMeta(raw: { request_id?: string | null; timestamp?: string }): {\n request_id: string;\n timestamp: string;\n} {\n return {\n request_id: raw.request_id ?? \"\",\n timestamp: raw.timestamp ?? \"\",\n };\n}\n\ntype BffSubscriptionResponse = Awaited<\n ReturnType<typeof portalTenant.subscriptions_show>\n>;\n\ntype BffListResponse = Awaited<\n ReturnType<typeof portalTenant.subscriptions_list>\n>;\n\n/**\n * Maps a BFF subscription detail response to the port's SubscriptionDetail.\n *\n * The BFF returns a flat Subscription schema while the port expects a richly\n * nested SubscriptionDetailSubscription. Both represent the same underlying\n * data — the consuming portal UI only accesses the subset of fields the BFF\n * provides. The explicit field mapping ensures the envelope structure is\n * correct, while the subscription data passes through at runtime.\n */\nfunction mapSubscriptionDetail(\n response: BffSubscriptionResponse,\n): subscriptions.SubscriptionDetail {\n return {\n subscription: (response.subscription ??\n {}) as unknown as subscriptions.SubscriptionDetailSubscription,\n meta: response.meta ? mapMeta(response.meta) : undefined,\n };\n}\n\nfunction mapSubscriptionList(\n response: BffListResponse,\n): subscriptions.SubscriptionsResponse {\n return {\n subscriptions: (response.subscriptions ??\n []) as unknown as subscriptions.SubscriptionListItem[],\n meta: mapMeta(response.meta ?? {}),\n };\n}\n\n/**\n * Creates a SubscriptionsApi-compatible adapter backed by the portal-tenant BFF.\n *\n * Uses async/await with explicit field mapping. The BFF returns simplified\n * subscription types compared to the full admin API; the adapter maps the\n * response envelope and provides runtime defaults for optional fields.\n */\nexport function createPortalSubscriptionsAdapter(\n client: FetchClient,\n): SubscriptionsApi {\n return {\n fetchCustomerSubscriptions: async (\n params: subscriptions.FetchSubscriptionsParams,\n ) => {\n const response = await portalTenant.subscriptions_list(client, {\n \"page[cursor]\": params.cursor,\n \"page[limit]\": params.limit ?? params.perPage,\n });\n return mapSubscriptionList(response);\n },\n\n fetchSubscription: async (subscriptionToken: string) => {\n const response = await portalTenant.subscriptions_show(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n pauseSubscription: async (\n subscriptionToken: string,\n _params: subscriptions.PauseSubscriptionParams,\n ) => {\n const response = await portalTenant.subscriptions_pause(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n resumeSubscription: async (\n subscriptionToken: string,\n _params: subscriptions.ResumeSubscriptionParams,\n ) => {\n const response = await portalTenant.subscriptions_resume(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n skipSubscription: async (\n subscriptionToken: string,\n _params: subscriptions.SkipSubscriptionParams,\n ) => {\n const response = await portalTenant.subscriptions_skip(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n cancelSubscription: async (\n subscriptionToken: string,\n _customerId?: number,\n ) => {\n const response = await portalTenant.subscriptions_cancel(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n reactivateSubscription: async (\n subscriptionToken: string,\n _params: subscriptions.ReactivateSubscriptionParams,\n ) => {\n const response = await portalTenant.subscriptions_reactivate(\n client,\n subscriptionToken,\n );\n return mapSubscriptionDetail(response);\n },\n\n updateSubscriptionInfo: async (\n subscriptionToken: string,\n body: Pick<subscriptions.UpdateSubscriptionInfoBody, \"payment_method_id\">,\n ) => {\n const response = await portalTenant.subscriptions_update(\n client,\n subscriptionToken,\n { subscription: { payment_method_id: body.payment_method_id } },\n );\n return mapSubscriptionDetail(response);\n },\n };\n}\n","import type { FetchClient } from \"./lib/fetch-client\";\nimport type { OrdersApi } from \"@fluid-app/orders-core\";\nimport type { orders } from \"@fluid-app/orders-core\";\nimport { portalTenant } from \"@fluid-app/portal-tenant-api-client\";\n\n/**\n * Creates an OrdersApi adapter backed by the portal-tenant BFF.\n *\n * Maps the generated portal-tenant namespace functions to the abstract\n * OrdersApi port, closing over the FetchClient so consumers don't need\n * to pass it per-call.\n */\n\nfunction mapOrder(\n raw: NonNullable<\n Awaited<ReturnType<typeof portalTenant.orders_show>>[\"order\"]\n >,\n): orders.PortalTenantOrder {\n return {\n id: raw.id ?? 0,\n token: raw.token ?? \"\",\n status: (raw.status ?? \"pending\") as orders.PortalTenantOrderStatus,\n total: raw.total ?? \"0\",\n currency: raw.currency ?? \"\",\n line_items: (raw.line_items ?? []).map((li) => ({\n id: li.id ?? 0,\n product_id: li.product_id ?? 0,\n product_name: li.product_name ?? \"\",\n quantity: li.quantity ?? 0,\n price: li.price ?? \"0\",\n total: li.total ?? \"0\",\n })),\n customer_name: raw.customer_name ?? null,\n customer_email: raw.customer_email ?? null,\n total_points_credited:\n typeof (raw as Record<string, unknown>).total_points_credited === \"number\"\n ? ((raw as Record<string, unknown>).total_points_credited as number)\n : undefined,\n customer_points_balance:\n typeof (raw as Record<string, unknown>).customer_points_balance ===\n \"number\"\n ? ((raw as Record<string, unknown>).customer_points_balance as number)\n : undefined,\n created_at: raw.created_at ?? \"\",\n updated_at: raw.updated_at ?? \"\",\n } satisfies orders.PortalTenantOrder;\n}\n\nfunction mapMeta(\n raw: Awaited<ReturnType<typeof portalTenant.orders_list>>[\"meta\"] | undefined,\n): orders.PortalTenantMeta {\n return {\n request_id: raw?.request_id ?? \"\",\n timestamp: raw?.timestamp ?? \"\",\n pagination: {\n cursor: raw?.pagination?.cursor ?? null,\n limit: raw?.pagination?.limit ?? 25,\n next_cursor: raw?.pagination?.next_cursor ?? null,\n prev_cursor: raw?.pagination?.prev_cursor ?? null,\n },\n } satisfies orders.PortalTenantMeta;\n}\n\nexport function createPortalTenantOrdersAdapter(\n client: FetchClient,\n): Required<Pick<OrdersApi, \"fetchOrderById\" | \"fetchOrders\">> {\n return {\n fetchOrderById: async (id: number) => {\n const response = await portalTenant.orders_show(client, id);\n return {\n order: mapOrder(response.order ?? {}),\n meta: {\n request_id: response.meta?.request_id ?? \"\",\n timestamp: response.meta?.timestamp ?? \"\",\n },\n } satisfies orders.PortalTenantOrderResponse;\n },\n\n fetchOrders: async (params: orders.PortalTenantFetchOrdersParams) => {\n const response = await portalTenant.orders_list(client, {\n \"page[cursor]\": params.cursor,\n \"page[limit]\": params.limit,\n status: params.status,\n });\n return {\n orders: (response.orders ?? []).map(mapOrder),\n meta: mapMeta(response.meta),\n } satisfies orders.PortalTenantOrdersResponse;\n },\n };\n}\n","import type { OrdersApi } from \"@fluid-app/orders-core\";\nimport type { FetchClient } from \"@fluid-app/portal-tenant-api-client\";\nimport { createPortalTenantOrdersAdapter } from \"@fluid-app/orders-api-client\";\n\n/**\n * Creates an OrdersApi adapter for the portal-tenant BFF.\n *\n * Delegates to the existing clean adapter in orders/api-client which maps\n * BFF responses to PortalTenantOrder types. The legacy methods (fetchOrder,\n * fetchCustomerOrders) are not used by portal UI — portal-specific hooks\n * call fetchOrders/fetchOrderById directly.\n */\nexport function createPortalOrdersAdapter(client: FetchClient): OrdersApi {\n const bffAdapter = createPortalTenantOrdersAdapter(client);\n return {\n fetchOrderById: bffAdapter.fetchOrderById,\n fetchOrders: bffAdapter.fetchOrders,\n };\n}\n","import { useMemo } from \"react\";\nimport type { OrdersApi } from \"@fluid-app/orders-core\";\nimport type { SubscriptionsApi } from \"@fluid-app/subscriptions-core\";\nimport { createPortalSubscriptionsAdapter } from \"@fluid-app/subscriptions-api-client\";\nimport {\n createFetchClient,\n type FetchClient as CoreFetchClient,\n} from \"@fluid-app/api-client-core\";\nimport { createPortalOrdersAdapter } from \"../adapters/orders-api-adapter\";\nimport { usePortalTenantClient } from \"../providers/PortalTenantClientProvider\";\nimport { useFluidContext } from \"../providers/FluidProvider\";\n\n/** API version prefix for versioned endpoints (e.g. points ledger) */\nexport const API_VERSION = \"/v202506\";\n\nexport function useOrdersApi(): OrdersApi {\n const client = usePortalTenantClient();\n\n return useMemo(() => createPortalOrdersAdapter(client), [client]);\n}\n\nexport function useSubscriptionsApiClient(): SubscriptionsApi {\n const client = usePortalTenantClient();\n\n return useMemo(() => createPortalSubscriptionsAdapter(client), [client]);\n}\n\n/**\n * Ensures baseUrl ends with /api.\n * Uncovered endpoints (e.g. /countries, points ledgers) use paths without the\n * /api prefix, so the base URL must include it.\n */\nfunction withApiPrefix(baseUrl: string): string {\n const base = baseUrl.replace(/\\/+$/, \"\");\n return base.endsWith(\"/api\") ? base : `${base}/api`;\n}\n\n/**\n * Generic SDK fetch client for endpoints not covered by domain-specific clients\n * (e.g. /countries, /v202506/customers/:id/points_ledgers).\n * Creates a FetchClient with /api-prefixed baseUrl since these endpoints\n * use paths like /countries (not /api/countries).\n */\nexport function useSdkClient(): CoreFetchClient {\n const { config } = useFluidContext();\n\n return useMemo(\n () =>\n createFetchClient({\n baseUrl: withApiPrefix(config.baseUrl),\n onAuthError: config.onAuthError,\n credentials: \"include\",\n }),\n [config.baseUrl, config.onAuthError],\n );\n}\n"],"mappings":";;;;;;AAQA,SAASA,UAAQ,KAGf;AACA,QAAO;EACL,YAAY,IAAI,cAAc;EAC9B,WAAW,IAAI,aAAa;EAC7B;;;;;;;;;;;AAoBH,SAAS,sBACP,UACkC;AAClC,QAAO;EACL,cAAe,SAAS,gBACtB,EAAE;EACJ,MAAM,SAAS,OAAOA,UAAQ,SAAS,KAAK,GAAG,KAAA;EAChD;;AAGH,SAAS,oBACP,UACqC;AACrC,QAAO;EACL,eAAgB,SAAS,iBACvB,EAAE;EACJ,MAAMA,UAAQ,SAAS,QAAQ,EAAE,CAAC;EACnC;;;;;;;;;AAUH,SAAgB,iCACd,QACkB;AAClB,QAAO;EACL,4BAA4B,OAC1B,WACG;AAKH,UAAO,oBAJU,MAAMC,mBAAgC,QAAQ;IAC7D,gBAAgB,OAAO;IACvB,eAAe,OAAO,SAAS,OAAO;IACvC,CAAC,CACkC;;EAGtC,mBAAmB,OAAO,sBAA8B;AAKtD,UAAO,sBAJU,MAAMC,mBACrB,QACA,kBACD,CACqC;;EAGxC,mBAAmB,OACjB,mBACA,YAC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AO,QAAQ;EACtC,aAAa,OAAO;EACpB,aAAa;EACd,CAAC,EACJ,CAAC,OAAO,SAAS,OAAO,YAAY,CACrC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as useFluidAuthContext } from "./FluidProvider-
|
|
2
|
-
import { t as useFluidApi } from "./use-fluid-api-
|
|
1
|
+
import { l as useFluidAuthContext } from "./FluidProvider-Bs9eWShT.mjs";
|
|
2
|
+
import { t as useFluidApi } from "./use-fluid-api-DdMmBE5K.mjs";
|
|
3
3
|
import { useCallback, useRef } from "react";
|
|
4
4
|
import { useQuery } from "@tanstack/react-query";
|
|
5
5
|
//#region src/hooks/query-keys.ts
|
|
@@ -98,4 +98,4 @@ function useCurrentUser() {
|
|
|
98
98
|
//#endregion
|
|
99
99
|
export { useCompanyScopedQueryKey as i, useCurrentUser as n, createCompanyQueryKey as r, CURRENT_USER_QUERY_KEY as t };
|
|
100
100
|
|
|
101
|
-
//# sourceMappingURL=use-current-user-
|
|
101
|
+
//# sourceMappingURL=use-current-user-Cjd0lFyc.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-current-user-
|
|
1
|
+
{"version":3,"file":"use-current-user-Cjd0lFyc.mjs","names":[],"sources":["../src/hooks/query-keys.ts","../src/hooks/use-current-user.ts"],"sourcesContent":["/**\n * Company-scoped query key factory for TanStack Query.\n *\n * All portal SDK query keys are prefixed with [\"company\", companyId, ...]\n * so that switching companies naturally invalidates the entire cache scope.\n *\n * The exported `*_QUERY_KEY` constants (e.g. PROFILE_QUERY_KEY) remain as\n * backwards-compatible base keys. The runtime keys used by hooks include the\n * company prefix via {@link createCompanyQueryKey}.\n */\n\nimport { useCallback, useRef } from \"react\";\nimport { useFluidAuthContext } from \"../providers/FluidAuthProvider\";\n\n/**\n * Create a company-scoped query key by prepending [\"company\", companyId].\n *\n * @param companyId - The company ID from the JWT payload\n * @param baseKey - The base query key segments (e.g. [\"fluid\", \"profile\"])\n * @returns A tuple like [\"company\", 42, \"fluid\", \"profile\"]\n *\n * @example\n * ```ts\n * const key = createCompanyQueryKey(42, \"fluid\", \"profile\");\n * // => [\"company\", 42, \"fluid\", \"profile\"]\n * ```\n */\nexport function createCompanyQueryKey(\n companyId: number,\n ...baseKey: readonly string[]\n): readonly [\"company\", number, ...string[]] {\n return [\"company\", companyId, ...baseKey] as const;\n}\n\n/**\n * Hook that returns a `scopeKey` function bound to the current company ID\n * from the auth context. If the user is not authenticated or has no\n * company_id, the base key is returned unscoped (graceful degradation).\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { scopeKey } = useCompanyScopedQueryKey();\n * const queryKey = scopeKey(PROFILE_QUERY_KEY);\n * // => [\"company\", 42, \"fluid\", \"profile\"] (when authenticated)\n * // => [\"fluid\", \"profile\"] (fallback)\n * }\n * ```\n */\nexport function useCompanyScopedQueryKey(): {\n readonly companyId: number | undefined;\n readonly scopeKey: <T extends readonly string[]>(\n baseKey: T,\n ) => readonly (string | number)[];\n} {\n const auth = useFluidAuthContext();\n const companyId = auth.user?.company_id;\n\n // Warn (once per component instance) when an authenticated user has no\n // company_id. This is a security-relevant condition: unscoped keys allow\n // cross-company cache collisions. The warning fires in all environments\n // so that it's visible in production logs if a misconfigured JWT is issued.\n const hasWarnedRef = useRef(false);\n if (auth.isAuthenticated && companyId == null && !hasWarnedRef.current) {\n hasWarnedRef.current = true;\n console.warn(\n \"[portal-sdk] Authenticated user has no company_id in JWT. \" +\n \"Query keys will fall back to unscoped keys, which may cause \" +\n \"cross-company cache collisions. Ensure the JWT includes company_id.\",\n );\n }\n\n const scopeKey = useCallback(\n <T extends readonly string[]>(baseKey: T): readonly (string | number)[] => {\n if (companyId != null) {\n return createCompanyQueryKey(companyId, ...baseKey);\n }\n return baseKey;\n },\n [companyId],\n );\n\n return { companyId, scopeKey } as const;\n}\n","import { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useFluidApi } from \"./use-fluid-api\";\nimport { useCompanyScopedQueryKey } from \"./query-keys\";\nimport type { UserMe } from \"../types/rep\";\n\n/**\n * Base query key for current user data.\n * Kept for backwards compatibility — the runtime key used by the hook\n * includes a company prefix via {@link useCompanyScopedQueryKey}.\n */\nexport const CURRENT_USER_QUERY_KEY = [\"fluid\", \"currentUser\"] as const;\n\n/**\n * Hook to fetch the currently authenticated user's full profile.\n * Returns company, country, and other fields from GET /api/me.\n *\n * @example\n * ```tsx\n * function ShopPage() {\n * const { data: user, isLoading } = useCurrentUser();\n * const subdomain = user?.company?.subdomain;\n * const countryIso = user?.country?.iso ?? \"US\";\n * // ...\n * }\n * ```\n */\nexport function useCurrentUser(): UseQueryResult<UserMe> {\n const api = useFluidApi();\n const { scopeKey } = useCompanyScopedQueryKey();\n\n return useQuery({\n queryKey: scopeKey(CURRENT_USER_QUERY_KEY),\n queryFn: () => api.users.me(),\n staleTime: 5 * 60 * 1000,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,sBACd,WACA,GAAG,SACwC;AAC3C,QAAO;EAAC;EAAW;EAAW,GAAG;EAAQ;;;;;;;;;;;;;;;;;AAkB3C,SAAgB,2BAKd;CACA,MAAM,OAAO,qBAAqB;CAClC,MAAM,YAAY,KAAK,MAAM;CAM7B,MAAM,eAAe,OAAO,MAAM;AAClC,KAAI,KAAK,mBAAmB,aAAa,QAAQ,CAAC,aAAa,SAAS;AACtE,eAAa,UAAU;AACvB,UAAQ,KACN,4LAGD;;AAaH,QAAO;EAAE;EAAW,UAVH,aACe,YAA6C;AACzE,OAAI,aAAa,KACf,QAAO,sBAAsB,WAAW,GAAG,QAAQ;AAErD,UAAO;KAET,CAAC,UAAU,CACZ;EAE6B;;;;;;;;;ACxEhC,MAAa,yBAAyB,CAAC,SAAS,cAAc;;;;;;;;;;;;;;;AAgB9D,SAAgB,iBAAyC;CACvD,MAAM,MAAM,aAAa;CACzB,MAAM,EAAE,aAAa,0BAA0B;AAE/C,QAAO,SAAS;EACd,UAAU,SAAS,uBAAuB;EAC1C,eAAe,IAAI,MAAM,IAAI;EAC7B,WAAW,MAAS;EACrB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./chunk-9hOWP6kD.cjs");
|
|
2
|
-
const require_FluidProvider = require("./FluidProvider-
|
|
3
|
-
const require_use_fluid_api = require("./use-fluid-api-
|
|
2
|
+
const require_FluidProvider = require("./FluidProvider-DzCUwDPA.cjs");
|
|
3
|
+
const require_use_fluid_api = require("./use-fluid-api-DnDH2bby.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
6
6
|
//#region src/hooks/query-keys.ts
|
|
@@ -122,4 +122,4 @@ Object.defineProperty(exports, "useCurrentUser", {
|
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
-
//# sourceMappingURL=use-current-user-
|
|
125
|
+
//# sourceMappingURL=use-current-user-idj1wuKD.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-current-user-
|
|
1
|
+
{"version":3,"file":"use-current-user-idj1wuKD.cjs","names":["useFluidAuthContext","useFluidApi"],"sources":["../src/hooks/query-keys.ts","../src/hooks/use-current-user.ts"],"sourcesContent":["/**\n * Company-scoped query key factory for TanStack Query.\n *\n * All portal SDK query keys are prefixed with [\"company\", companyId, ...]\n * so that switching companies naturally invalidates the entire cache scope.\n *\n * The exported `*_QUERY_KEY` constants (e.g. PROFILE_QUERY_KEY) remain as\n * backwards-compatible base keys. The runtime keys used by hooks include the\n * company prefix via {@link createCompanyQueryKey}.\n */\n\nimport { useCallback, useRef } from \"react\";\nimport { useFluidAuthContext } from \"../providers/FluidAuthProvider\";\n\n/**\n * Create a company-scoped query key by prepending [\"company\", companyId].\n *\n * @param companyId - The company ID from the JWT payload\n * @param baseKey - The base query key segments (e.g. [\"fluid\", \"profile\"])\n * @returns A tuple like [\"company\", 42, \"fluid\", \"profile\"]\n *\n * @example\n * ```ts\n * const key = createCompanyQueryKey(42, \"fluid\", \"profile\");\n * // => [\"company\", 42, \"fluid\", \"profile\"]\n * ```\n */\nexport function createCompanyQueryKey(\n companyId: number,\n ...baseKey: readonly string[]\n): readonly [\"company\", number, ...string[]] {\n return [\"company\", companyId, ...baseKey] as const;\n}\n\n/**\n * Hook that returns a `scopeKey` function bound to the current company ID\n * from the auth context. If the user is not authenticated or has no\n * company_id, the base key is returned unscoped (graceful degradation).\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { scopeKey } = useCompanyScopedQueryKey();\n * const queryKey = scopeKey(PROFILE_QUERY_KEY);\n * // => [\"company\", 42, \"fluid\", \"profile\"] (when authenticated)\n * // => [\"fluid\", \"profile\"] (fallback)\n * }\n * ```\n */\nexport function useCompanyScopedQueryKey(): {\n readonly companyId: number | undefined;\n readonly scopeKey: <T extends readonly string[]>(\n baseKey: T,\n ) => readonly (string | number)[];\n} {\n const auth = useFluidAuthContext();\n const companyId = auth.user?.company_id;\n\n // Warn (once per component instance) when an authenticated user has no\n // company_id. This is a security-relevant condition: unscoped keys allow\n // cross-company cache collisions. The warning fires in all environments\n // so that it's visible in production logs if a misconfigured JWT is issued.\n const hasWarnedRef = useRef(false);\n if (auth.isAuthenticated && companyId == null && !hasWarnedRef.current) {\n hasWarnedRef.current = true;\n console.warn(\n \"[portal-sdk] Authenticated user has no company_id in JWT. \" +\n \"Query keys will fall back to unscoped keys, which may cause \" +\n \"cross-company cache collisions. Ensure the JWT includes company_id.\",\n );\n }\n\n const scopeKey = useCallback(\n <T extends readonly string[]>(baseKey: T): readonly (string | number)[] => {\n if (companyId != null) {\n return createCompanyQueryKey(companyId, ...baseKey);\n }\n return baseKey;\n },\n [companyId],\n );\n\n return { companyId, scopeKey } as const;\n}\n","import { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useFluidApi } from \"./use-fluid-api\";\nimport { useCompanyScopedQueryKey } from \"./query-keys\";\nimport type { UserMe } from \"../types/rep\";\n\n/**\n * Base query key for current user data.\n * Kept for backwards compatibility — the runtime key used by the hook\n * includes a company prefix via {@link useCompanyScopedQueryKey}.\n */\nexport const CURRENT_USER_QUERY_KEY = [\"fluid\", \"currentUser\"] as const;\n\n/**\n * Hook to fetch the currently authenticated user's full profile.\n * Returns company, country, and other fields from GET /api/me.\n *\n * @example\n * ```tsx\n * function ShopPage() {\n * const { data: user, isLoading } = useCurrentUser();\n * const subdomain = user?.company?.subdomain;\n * const countryIso = user?.country?.iso ?? \"US\";\n * // ...\n * }\n * ```\n */\nexport function useCurrentUser(): UseQueryResult<UserMe> {\n const api = useFluidApi();\n const { scopeKey } = useCompanyScopedQueryKey();\n\n return useQuery({\n queryKey: scopeKey(CURRENT_USER_QUERY_KEY),\n queryFn: () => api.users.me(),\n staleTime: 5 * 60 * 1000,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,sBACd,WACA,GAAG,SACwC;AAC3C,QAAO;EAAC;EAAW;EAAW,GAAG;EAAQ;;;;;;;;;;;;;;;;;AAkB3C,SAAgB,2BAKd;CACA,MAAM,OAAOA,sBAAAA,qBAAqB;CAClC,MAAM,YAAY,KAAK,MAAM;CAM7B,MAAM,gBAAA,GAAA,MAAA,QAAsB,MAAM;AAClC,KAAI,KAAK,mBAAmB,aAAa,QAAQ,CAAC,aAAa,SAAS;AACtE,eAAa,UAAU;AACvB,UAAQ,KACN,4LAGD;;AAaH,QAAO;EAAE;EAAW,WAAA,GAAA,MAAA,cATY,YAA6C;AACzE,OAAI,aAAa,KACf,QAAO,sBAAsB,WAAW,GAAG,QAAQ;AAErD,UAAO;KAET,CAAC,UAAU,CACZ;EAE6B;;;;;;;;;ACxEhC,MAAa,yBAAyB,CAAC,SAAS,cAAc;;;;;;;;;;;;;;;AAgB9D,SAAgB,iBAAyC;CACvD,MAAM,MAAMC,sBAAAA,aAAa;CACzB,MAAM,EAAE,aAAa,0BAA0B;AAE/C,SAAA,GAAA,sBAAA,UAAgB;EACd,UAAU,SAAS,uBAAuB;EAC1C,eAAe,IAAI,MAAM,IAAI;EAC7B,WAAW,MAAS;EACrB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as useFluidContext } from "./FluidProvider-
|
|
1
|
+
import { n as useFluidContext } from "./FluidProvider-Bs9eWShT.mjs";
|
|
2
2
|
//#region src/hooks/use-fluid-api.ts
|
|
3
3
|
/**
|
|
4
4
|
* Hook to access the Fluid API client
|
|
@@ -24,4 +24,4 @@ function useFluidApi() {
|
|
|
24
24
|
//#endregion
|
|
25
25
|
export { useFluidApi as t };
|
|
26
26
|
|
|
27
|
-
//# sourceMappingURL=use-fluid-api-
|
|
27
|
+
//# sourceMappingURL=use-fluid-api-DdMmBE5K.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-fluid-api-
|
|
1
|
+
{"version":3,"file":"use-fluid-api-DdMmBE5K.mjs","names":[],"sources":["../src/hooks/use-fluid-api.ts"],"sourcesContent":["import { useFluidContext } from \"../providers/FluidProvider\";\nimport type { FluidClient } from \"../client/fluid-client\";\n\n/**\n * Hook to access the Fluid API client\n *\n * @example\n * ```tsx\n * function UserInfo() {\n * const api = useFluidApi();\n *\n * const { data: user } = useQuery({\n * queryKey: [\"me\"],\n * queryFn: () => api.users.me(),\n * });\n *\n * return <p>Hello, {user?.name}</p>;\n * }\n * ```\n */\nexport function useFluidApi(): FluidClient {\n const { client } = useFluidContext();\n return client;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,cAA2B;CACzC,MAAM,EAAE,WAAW,iBAAiB;AACpC,QAAO"}
|