@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.
Files changed (122) hide show
  1. package/dist/{AppDownloadScreen-DTxo4z3_.cjs → AppDownloadScreen-ChKim_6A.cjs} +2 -2
  2. package/dist/{AppDownloadScreen-DTxo4z3_.cjs.map → AppDownloadScreen-ChKim_6A.cjs.map} +1 -1
  3. package/dist/{AppDownloadScreen-BoGSdsJk.mjs → AppDownloadScreen-DGHd6hYM.mjs} +2 -2
  4. package/dist/{AppDownloadScreen-BoGSdsJk.mjs.map → AppDownloadScreen-DGHd6hYM.mjs.map} +1 -1
  5. package/dist/{AppDownloadScreen-Chxavsr_.cjs → AppDownloadScreen-DpyV1tJw.cjs} +2 -2
  6. package/dist/{ContactsScreen-BKOHursc.mjs → ContactsScreen-Bcea6126.mjs} +3 -3
  7. package/dist/{ContactsScreen-BKOHursc.mjs.map → ContactsScreen-Bcea6126.mjs.map} +1 -1
  8. package/dist/{ContactsScreen-DN8Qt2Ih.cjs → ContactsScreen-CsIGZaWy.cjs} +4 -4
  9. package/dist/{ContactsScreen-DN8Qt2Ih.cjs.map → ContactsScreen-CsIGZaWy.cjs.map} +1 -1
  10. package/dist/{ContactsScreen-FrVLbjGO.cjs → ContactsScreen-OBDC1046.cjs} +4 -4
  11. package/dist/{FluidProvider-CgTeGUnF.mjs → FluidProvider-BJQSXofR.mjs} +198 -615
  12. package/dist/FluidProvider-BJQSXofR.mjs.map +1 -0
  13. package/dist/{FluidProvider-BMMu_rp3.cjs → FluidProvider-DvqnkjZI.cjs} +196 -625
  14. package/dist/FluidProvider-DvqnkjZI.cjs.map +1 -0
  15. package/dist/{MessagingScreen-Bvq3Dd5i.mjs → MessagingScreen-B48ksZOJ.mjs} +3 -3
  16. package/dist/{MessagingScreen-Bvq3Dd5i.mjs.map → MessagingScreen-B48ksZOJ.mjs.map} +1 -1
  17. package/dist/{MessagingScreen-DMDXiH97.mjs → MessagingScreen-COGo4S9K.mjs} +2 -2
  18. package/dist/{MessagingScreen-DgbNN4BF.cjs → MessagingScreen-DYgiatey.cjs} +3 -3
  19. package/dist/{MessagingScreen-DgbNN4BF.cjs.map → MessagingScreen-DYgiatey.cjs.map} +1 -1
  20. package/dist/{MessagingScreen-bzzXjQMu.cjs → MessagingScreen-QyUOxYXl.cjs} +2 -2
  21. package/dist/{MySiteScreen-nV8x9xyy.cjs → MySiteScreen-ByIJ6CkU.cjs} +2 -2
  22. package/dist/{MySiteScreen-nV8x9xyy.cjs.map → MySiteScreen-ByIJ6CkU.cjs.map} +1 -1
  23. package/dist/{MySiteScreen-BJH5-RNT.mjs → MySiteScreen-DZ0ru6Bn.mjs} +2 -2
  24. package/dist/{MySiteScreen-BJH5-RNT.mjs.map → MySiteScreen-DZ0ru6Bn.mjs.map} +1 -1
  25. package/dist/{MySiteScreen-CYZpUYTn.cjs → MySiteScreen-DrWUJJiH.cjs} +2 -2
  26. package/dist/{OrdersScreen-BL__flBE.cjs → OrdersScreen-CkvoeTvK.cjs} +3 -3
  27. package/dist/OrdersScreen-D_7TJgZ4.mjs +561 -0
  28. package/dist/OrdersScreen-D_7TJgZ4.mjs.map +1 -0
  29. package/dist/OrdersScreen-DyYYjl9I.cjs +568 -0
  30. package/dist/OrdersScreen-DyYYjl9I.cjs.map +1 -0
  31. package/dist/{ProductsScreen-BIYHPaBZ.cjs → ProductsScreen-B8NmyIJy.cjs} +3 -3
  32. package/dist/{ProductsScreen-COwahI-V.mjs → ProductsScreen-CMnhqsSA.mjs} +5 -5
  33. package/dist/{ProductsScreen-COwahI-V.mjs.map → ProductsScreen-CMnhqsSA.mjs.map} +1 -1
  34. package/dist/{ProductsScreen-D6h-r9ht.mjs → ProductsScreen-DzNmbwVi.mjs} +3 -3
  35. package/dist/{ProductsScreen-C8UfVLRr.cjs → ProductsScreen-Z1hx1YZQ.cjs} +5 -5
  36. package/dist/{ProductsScreen-C8UfVLRr.cjs.map → ProductsScreen-Z1hx1YZQ.cjs.map} +1 -1
  37. package/dist/{ProfileScreen-CZp_NrjO.cjs → ProfileScreen-B81Ovmh_.cjs} +2 -2
  38. package/dist/{ProfileScreen-FYGHStqM.cjs → ProfileScreen-CYTxOGeW.cjs} +526 -137
  39. package/dist/ProfileScreen-CYTxOGeW.cjs.map +1 -0
  40. package/dist/{ProfileScreen-BKRn8AqI.mjs → ProfileScreen-QOXtyrJi.mjs} +522 -133
  41. package/dist/ProfileScreen-QOXtyrJi.mjs.map +1 -0
  42. package/dist/{ShareablesScreen-BEPVTMeI.cjs → ShareablesScreen-1HpfEjyd.cjs} +7 -7
  43. package/dist/{ShareablesScreen-BEPVTMeI.cjs.map → ShareablesScreen-1HpfEjyd.cjs.map} +1 -1
  44. package/dist/{ShareablesScreen-BrC5LGtU.cjs → ShareablesScreen-BXO8MpAy.cjs} +3 -3
  45. package/dist/{ShareablesScreen-BXzxUg0E.mjs → ShareablesScreen-DSsMJJh_.mjs} +7 -7
  46. package/dist/{ShareablesScreen-BXzxUg0E.mjs.map → ShareablesScreen-DSsMJJh_.mjs.map} +1 -1
  47. package/dist/{ShareablesScreen-aMnwEOAH.mjs → ShareablesScreen-Oo3jMHX6.mjs} +3 -3
  48. package/dist/{ShopScreen-CHH0cx2P.cjs → ShopScreen-BDcWpmi7.cjs} +4 -4
  49. package/dist/{ShopScreen-CHH0cx2P.cjs.map → ShopScreen-BDcWpmi7.cjs.map} +1 -1
  50. package/dist/{ShopScreen-8OQhLeLt.cjs → ShopScreen-CWxOPn7H.cjs} +2 -2
  51. package/dist/{ShopScreen-Yi9sOX_2.mjs → ShopScreen-DsReuJ7P.mjs} +4 -4
  52. package/dist/{ShopScreen-Yi9sOX_2.mjs.map → ShopScreen-DsReuJ7P.mjs.map} +1 -1
  53. package/dist/{SubscriptionsScreen-oApGaq11.cjs → SubscriptionsScreen-B8mLGt5-.cjs} +27 -10
  54. package/dist/SubscriptionsScreen-B8mLGt5-.cjs.map +1 -0
  55. package/dist/{SubscriptionsScreen-C2F3HNJS.cjs → SubscriptionsScreen-C2zbEjMC.cjs} +4 -4
  56. package/dist/{SubscriptionsScreen-CZ-1jSO2.mjs → SubscriptionsScreen-DZxLo4up.mjs} +21 -4
  57. package/dist/SubscriptionsScreen-DZxLo4up.mjs.map +1 -0
  58. package/dist/index.cjs +37 -37
  59. package/dist/index.d.cts.map +1 -1
  60. package/dist/index.d.mts.map +1 -1
  61. package/dist/index.mjs +37 -37
  62. package/dist/order-status-badge-KooNqnAs.mjs +262 -0
  63. package/dist/order-status-badge-KooNqnAs.mjs.map +1 -0
  64. package/dist/order-status-badge-cwqA8dZ-.cjs +304 -0
  65. package/dist/order-status-badge-cwqA8dZ-.cjs.map +1 -0
  66. package/dist/portal_tenant-CP5Ce8Jn.cjs +261 -0
  67. package/dist/portal_tenant-CP5Ce8Jn.cjs.map +1 -0
  68. package/dist/portal_tenant-CWy4Zg2t.mjs +166 -0
  69. package/dist/portal_tenant-CWy4Zg2t.mjs.map +1 -0
  70. package/dist/src-BOIW-KES.mjs +3 -0
  71. package/dist/src-CzwiFO_J.cjs +3 -0
  72. package/dist/{src-BMUEjfhg.mjs → src-Dgo44BGe.mjs} +1 -1
  73. package/dist/{src-BMUEjfhg.mjs.map → src-Dgo44BGe.mjs.map} +1 -1
  74. package/dist/{src-BJdOxgpp.cjs → src-DkhHoxnS.cjs} +1 -1
  75. package/dist/{src-BJdOxgpp.cjs.map → src-DkhHoxnS.cjs.map} +1 -1
  76. package/dist/use-account-clients-Dim60sir.mjs +451 -0
  77. package/dist/use-account-clients-Dim60sir.mjs.map +1 -0
  78. package/dist/use-account-clients-DoJW3KTx.cjs +481 -0
  79. package/dist/use-account-clients-DoJW3KTx.cjs.map +1 -0
  80. package/dist/{use-current-user-DCk55_Qn.mjs → use-current-user-Baxj7HJt.mjs} +3 -3
  81. package/dist/{use-current-user-DCk55_Qn.mjs.map → use-current-user-Baxj7HJt.mjs.map} +1 -1
  82. package/dist/{use-current-user-BR5_zaoZ.cjs → use-current-user-BcZWV7oU.cjs} +3 -3
  83. package/dist/{use-current-user-BR5_zaoZ.cjs.map → use-current-user-BcZWV7oU.cjs.map} +1 -1
  84. package/dist/{use-fluid-api-CmCAH10d.mjs → use-fluid-api-BP05Cf-f.mjs} +2 -2
  85. package/dist/{use-fluid-api-CmCAH10d.mjs.map → use-fluid-api-BP05Cf-f.mjs.map} +1 -1
  86. package/dist/{use-fluid-api-C1KeHB7q.cjs → use-fluid-api-Ds8BInAZ.cjs} +2 -2
  87. package/dist/{use-fluid-api-C1KeHB7q.cjs.map → use-fluid-api-Ds8BInAZ.cjs.map} +1 -1
  88. package/dist/{use-fluid-auth-BQEV7ylM.mjs → use-fluid-auth-C-Qpl8j4.mjs} +2 -2
  89. package/dist/{use-fluid-auth-BQEV7ylM.mjs.map → use-fluid-auth-C-Qpl8j4.mjs.map} +1 -1
  90. package/dist/{use-fluid-auth-CyKaXLbW.cjs → use-fluid-auth-sGNMgfnt.cjs} +2 -2
  91. package/dist/{use-fluid-auth-CyKaXLbW.cjs.map → use-fluid-auth-sGNMgfnt.cjs.map} +1 -1
  92. package/dist/{use-portal-products-client-pptYMuSw.cjs → use-portal-products-client-DKYkBjm-.cjs} +7 -48
  93. package/dist/use-portal-products-client-DKYkBjm-.cjs.map +1 -0
  94. package/dist/{use-portal-products-client-BL1xVtex.mjs → use-portal-products-client-s2qtZjhU.mjs} +3 -44
  95. package/dist/use-portal-products-client-s2qtZjhU.mjs.map +1 -0
  96. package/package.json +13 -12
  97. package/dist/FluidProvider-BMMu_rp3.cjs.map +0 -1
  98. package/dist/FluidProvider-CgTeGUnF.mjs.map +0 -1
  99. package/dist/OrdersScreen-BLb3_KtI.mjs +0 -176
  100. package/dist/OrdersScreen-BLb3_KtI.mjs.map +0 -1
  101. package/dist/OrdersScreen-uL3mRk1h.cjs +0 -183
  102. package/dist/OrdersScreen-uL3mRk1h.cjs.map +0 -1
  103. package/dist/ProfileScreen-BKRn8AqI.mjs.map +0 -1
  104. package/dist/ProfileScreen-FYGHStqM.cjs.map +0 -1
  105. package/dist/SubscriptionsScreen-CZ-1jSO2.mjs.map +0 -1
  106. package/dist/SubscriptionsScreen-oApGaq11.cjs.map +0 -1
  107. package/dist/order-detail-DHXdE4Cl.cjs +0 -961
  108. package/dist/order-detail-DHXdE4Cl.cjs.map +0 -1
  109. package/dist/order-detail-iZm_R0TX.mjs +0 -931
  110. package/dist/order-detail-iZm_R0TX.mjs.map +0 -1
  111. package/dist/src-BJSTFxSO.mjs +0 -1
  112. package/dist/src-DMVR26Fk.cjs +0 -1
  113. package/dist/use-account-clients-CL6rr17o.cjs +0 -214
  114. package/dist/use-account-clients-CL6rr17o.cjs.map +0 -1
  115. package/dist/use-account-clients-CMjRB5On.mjs +0 -190
  116. package/dist/use-account-clients-CMjRB5On.mjs.map +0 -1
  117. package/dist/use-customer-account-BAolVc3q.mjs +0 -22
  118. package/dist/use-customer-account-BAolVc3q.mjs.map +0 -1
  119. package/dist/use-customer-account-DSsXbcme.cjs +0 -28
  120. package/dist/use-customer-account-DSsXbcme.cjs.map +0 -1
  121. package/dist/use-portal-products-client-BL1xVtex.mjs.map +0 -1
  122. package/dist/use-portal-products-client-pptYMuSw.cjs.map +0 -1
@@ -0,0 +1,451 @@
1
+ import { n as useFluidContext, rt as createFetchClient, u as usePortalTenantClient } from "./FluidProvider-BJQSXofR.mjs";
2
+ import { d as subscriptions_pause, f as subscriptions_reactivate, g as subscriptions_update, h as subscriptions_skip, i as orders_show, l as subscriptions_cancel, m as subscriptions_show, n as account_update, p as subscriptions_resume, r as orders_list, t as account_show, u as subscriptions_list } from "./portal_tenant-CWy4Zg2t.mjs";
3
+ import { useMemo } from "react";
4
+ //#region ../../subscriptions/api-client/src/portal-tenant-adapter.ts
5
+ /**
6
+ * Maps the BFF meta envelope to the port's expected shape.
7
+ */
8
+ function mapMeta$1(raw) {
9
+ return {
10
+ request_id: raw.request_id ?? "",
11
+ timestamp: raw.timestamp ?? ""
12
+ };
13
+ }
14
+ /**
15
+ * Maps a BFF subscription detail response to the port's SubscriptionDetail.
16
+ *
17
+ * The BFF returns a flat Subscription schema while the port expects a richly
18
+ * nested SubscriptionDetailSubscription. Both represent the same underlying
19
+ * data — the consuming portal UI only accesses the subset of fields the BFF
20
+ * provides. The explicit field mapping ensures the envelope structure is
21
+ * correct, while the subscription data passes through at runtime.
22
+ */
23
+ function mapSubscriptionDetail(response) {
24
+ return {
25
+ subscription: response.subscription ?? {},
26
+ meta: response.meta ? mapMeta$1(response.meta) : void 0
27
+ };
28
+ }
29
+ function mapSubscriptionList(response) {
30
+ return {
31
+ subscriptions: response.subscriptions ?? [],
32
+ meta: mapMeta$1(response.meta ?? {})
33
+ };
34
+ }
35
+ /**
36
+ * Creates a SubscriptionsApi-compatible adapter backed by the portal-tenant BFF.
37
+ *
38
+ * Uses async/await with explicit field mapping. The BFF returns simplified
39
+ * subscription types compared to the full admin API; the adapter maps the
40
+ * response envelope and provides runtime defaults for optional fields.
41
+ */
42
+ function createPortalSubscriptionsAdapter(client) {
43
+ return {
44
+ fetchCustomerSubscriptions: async (params) => {
45
+ return mapSubscriptionList(await subscriptions_list(client, {
46
+ "page[cursor]": params.cursor,
47
+ "page[limit]": params.limit ?? params.perPage
48
+ }));
49
+ },
50
+ fetchSubscription: async (subscriptionToken) => {
51
+ return mapSubscriptionDetail(await subscriptions_show(client, subscriptionToken));
52
+ },
53
+ pauseSubscription: async (subscriptionToken, _params) => {
54
+ return mapSubscriptionDetail(await subscriptions_pause(client, subscriptionToken));
55
+ },
56
+ resumeSubscription: async (subscriptionToken, _params) => {
57
+ return mapSubscriptionDetail(await subscriptions_resume(client, subscriptionToken));
58
+ },
59
+ skipSubscription: async (subscriptionToken, _params) => {
60
+ return mapSubscriptionDetail(await subscriptions_skip(client, subscriptionToken));
61
+ },
62
+ cancelSubscription: async (subscriptionToken, _customerId) => {
63
+ return mapSubscriptionDetail(await subscriptions_cancel(client, subscriptionToken));
64
+ },
65
+ reactivateSubscription: async (subscriptionToken, _params) => {
66
+ return mapSubscriptionDetail(await subscriptions_reactivate(client, subscriptionToken));
67
+ },
68
+ updateSubscriptionInfo: async (subscriptionToken, body) => {
69
+ return mapSubscriptionDetail(await subscriptions_update(client, subscriptionToken, { subscription: { payment_method_id: body.payment_method_id } }));
70
+ }
71
+ };
72
+ }
73
+ //#endregion
74
+ //#region ../../orders/api-client/src/portal-tenant-adapter.ts
75
+ /**
76
+ * Creates an OrdersApi adapter backed by the portal-tenant BFF.
77
+ *
78
+ * Maps the generated portal-tenant namespace functions to the abstract
79
+ * OrdersApi port, closing over the FetchClient so consumers don't need
80
+ * to pass it per-call.
81
+ */
82
+ function mapOrder(raw) {
83
+ return {
84
+ id: raw.id ?? 0,
85
+ token: raw.token ?? "",
86
+ status: raw.status ?? "pending",
87
+ total: raw.total ?? "0",
88
+ currency: raw.currency ?? "",
89
+ line_items: (raw.line_items ?? []).map((li) => ({
90
+ id: li.id ?? 0,
91
+ product_id: li.product_id ?? 0,
92
+ product_name: li.product_name ?? "",
93
+ quantity: li.quantity ?? 0,
94
+ price: li.price ?? "0",
95
+ total: li.total ?? "0"
96
+ })),
97
+ customer_name: raw.customer_name ?? null,
98
+ customer_email: raw.customer_email ?? null,
99
+ created_at: raw.created_at ?? "",
100
+ updated_at: raw.updated_at ?? ""
101
+ };
102
+ }
103
+ function mapMeta(raw) {
104
+ return {
105
+ request_id: raw?.request_id ?? "",
106
+ timestamp: raw?.timestamp ?? "",
107
+ pagination: {
108
+ cursor: raw?.pagination?.cursor ?? null,
109
+ limit: raw?.pagination?.limit ?? 25,
110
+ next_cursor: raw?.pagination?.next_cursor ?? null,
111
+ prev_cursor: raw?.pagination?.prev_cursor ?? null
112
+ }
113
+ };
114
+ }
115
+ function createPortalTenantOrdersAdapter(client) {
116
+ return {
117
+ fetchOrderById: async (id) => {
118
+ const response = await orders_show(client, id);
119
+ return {
120
+ order: mapOrder(response.order ?? {}),
121
+ meta: {
122
+ request_id: response.meta?.request_id ?? "",
123
+ timestamp: response.meta?.timestamp ?? ""
124
+ }
125
+ };
126
+ },
127
+ fetchOrders: async (params) => {
128
+ const response = await orders_list(client, {
129
+ "page[cursor]": params.cursor,
130
+ "page[limit]": params.limit,
131
+ status: params.status
132
+ });
133
+ return {
134
+ orders: (response.orders ?? []).map(mapOrder),
135
+ meta: mapMeta(response.meta)
136
+ };
137
+ }
138
+ };
139
+ }
140
+ //#endregion
141
+ //#region src/adapters/orders-api-adapter.ts
142
+ /**
143
+ * Creates an OrdersApi adapter for the portal-tenant BFF.
144
+ *
145
+ * Delegates to the existing clean adapter in orders/api-client which maps
146
+ * BFF responses to PortalTenantOrder types. The legacy methods (fetchOrder,
147
+ * fetchCustomerOrders) are not used by portal UI — portal-specific hooks
148
+ * call fetchOrders/fetchOrderById directly.
149
+ */
150
+ function createPortalOrdersAdapter(client) {
151
+ const bffAdapter = createPortalTenantOrdersAdapter(client);
152
+ return {
153
+ fetchOrder: () => {
154
+ throw new Error("Use fetchOrderById for portal-tenant context");
155
+ },
156
+ fetchCustomerOrders: () => {
157
+ throw new Error("Use fetchOrders for portal-tenant context");
158
+ },
159
+ fetchOrderById: bffAdapter.fetchOrderById,
160
+ fetchOrders: bffAdapter.fetchOrders
161
+ };
162
+ }
163
+ //#endregion
164
+ //#region src/adapters/account-api-adapter.ts
165
+ function mapAccount(raw) {
166
+ return {
167
+ id: raw.id ?? 0,
168
+ member_type: raw.member_type ?? "rep",
169
+ first_name: raw.first_name ?? "",
170
+ last_name: raw.last_name ?? "",
171
+ email: raw.email ?? "",
172
+ phone: raw.phone ?? null,
173
+ bio: raw.bio ?? null,
174
+ avatar_url: raw.avatar_url ?? null,
175
+ slug: raw.slug ?? "",
176
+ social_links: raw.social_links ?? null
177
+ };
178
+ }
179
+ function createAccountApiAdapter(client) {
180
+ return {
181
+ fetchAccount: async () => {
182
+ const response = await account_show(client);
183
+ return {
184
+ account: mapAccount(response.account ?? {}),
185
+ meta: {
186
+ request_id: response.meta?.request_id ?? "",
187
+ timestamp: response.meta?.timestamp ?? ""
188
+ }
189
+ };
190
+ },
191
+ updateAccount: async (body) => {
192
+ const response = await account_update(client, body);
193
+ return {
194
+ account: mapAccount(response.account ?? {}),
195
+ meta: {
196
+ request_id: response.meta?.request_id ?? "",
197
+ timestamp: response.meta?.timestamp ?? ""
198
+ }
199
+ };
200
+ }
201
+ };
202
+ }
203
+ //#endregion
204
+ //#region ../../api-clients/portal-tenant-pay/src/namespaces/portal_tenant_pay.ts
205
+ /**
206
+ * List addresses
207
+ * Returns addresses associated with the member's customer record in this tenant.
208
+ *
209
+ * @param client - Fetch client instance
210
+ * @param [params] - params
211
+ */
212
+ async function addresses_list(client, params) {
213
+ return client.get(`/api/pay/addresses`, params);
214
+ }
215
+ /**
216
+ * Create an address
217
+ * Adds a new address to the member's customer record. If an identical address already exists it is returned instead of creating a duplicate.
218
+ *
219
+ * @param client - Fetch client instance
220
+ * @param body - body
221
+ */
222
+ async function addresses_create(client, body) {
223
+ return client.post(`/api/pay/addresses`, body);
224
+ }
225
+ /**
226
+ * Update an address
227
+ * Creates a new address with the merged attributes and discards the old one, preserving references from existing orders.
228
+ *
229
+ * @param client - Fetch client instance
230
+ * @param id - id
231
+ * @param body - body
232
+ */
233
+ async function addresses_update(client, id, body) {
234
+ return client.patch(`/api/pay/addresses/${id}`, body);
235
+ }
236
+ /**
237
+ * Delete an address
238
+ * Removes an address from the member's customer record. The default address cannot be removed.
239
+ *
240
+ * @param client - Fetch client instance
241
+ * @param id - id
242
+ */
243
+ async function addresses_destroy(client, id) {
244
+ return client.delete(`/api/pay/addresses/${id}`);
245
+ }
246
+ /**
247
+ * List payment methods
248
+ * Returns displayable payment methods on the member's customer record, excluding Apple Pay sources.
249
+ *
250
+ * @param client - Fetch client instance
251
+ * @param [params] - params
252
+ */
253
+ async function payment_methods_list(client, params) {
254
+ return client.get(`/api/pay/payment_methods`, params);
255
+ }
256
+ /**
257
+ * Create a payment method
258
+ * Tokenizes and stores a new payment method via the vault provider. Requires a vault token obtained from the vault credentials endpoint.
259
+ *
260
+ * @param client - Fetch client instance
261
+ * @param body - body
262
+ */
263
+ async function payment_methods_create(client, body) {
264
+ return client.post(`/api/pay/payment_methods`, body);
265
+ }
266
+ /**
267
+ * Update a payment method
268
+ * Updates a payment method's attributes. Currently supports setting a payment method as the default.
269
+ *
270
+ * @param client - Fetch client instance
271
+ * @param id - id
272
+ * @param body - body
273
+ */
274
+ async function payment_methods_update(client, id, body) {
275
+ return client.patch(`/api/pay/payment_methods/${id}`, body);
276
+ }
277
+ /**
278
+ * Delete a payment method
279
+ * Removes a payment method from the member's customer record. If the removed method was the default, the default is cleared.
280
+ *
281
+ * @param client - Fetch client instance
282
+ * @param id - id
283
+ */
284
+ async function payment_methods_destroy(client, id) {
285
+ return client.delete(`/api/pay/payment_methods/${id}`);
286
+ }
287
+ /**
288
+ * Get vault credentials
289
+ * Returns a short-lived vault token and environment identifier for initializing the client-side payment vault SDK.
290
+ *
291
+ * @param client - Fetch client instance
292
+
293
+ */
294
+ async function payment_methods_vault_show(client) {
295
+ return client.get(`/api/pay/payment_methods/vault`);
296
+ }
297
+ /**
298
+ * List points ledger entries
299
+ * Returns loyalty points ledger entries for the member's customer record in this tenant, ordered by most recent first.
300
+ *
301
+ * @param client - Fetch client instance
302
+ * @param [params] - params
303
+ */
304
+ async function points_ledgers_list(client, params) {
305
+ return client.get(`/api/pay/points_ledgers`, params);
306
+ }
307
+ //#endregion
308
+ //#region src/adapters/pay-api-adapter.ts
309
+ function mapAddress(raw) {
310
+ return {
311
+ id: raw.id ?? 0,
312
+ street1: raw.street1 ?? "",
313
+ street2: raw.street2 ?? null,
314
+ city: raw.city ?? "",
315
+ state: raw.state ?? "",
316
+ zip: raw.zip ?? "",
317
+ country: raw.country ?? "",
318
+ default: raw.default ?? false,
319
+ created_at: raw.created_at ?? null,
320
+ updated_at: raw.updated_at ?? null
321
+ };
322
+ }
323
+ function mapPaymentMethod(raw) {
324
+ return {
325
+ id: raw.id ?? 0,
326
+ type: raw.type ?? "card",
327
+ brand: raw.brand ?? null,
328
+ last_four: raw.last_four ?? "",
329
+ exp_month: raw.exp_month ?? null,
330
+ exp_year: raw.exp_year ?? null,
331
+ default: raw.default ?? false,
332
+ created_at: raw.created_at ?? null,
333
+ updated_at: raw.updated_at ?? null
334
+ };
335
+ }
336
+ function createPortalTenantPayAdapter(client) {
337
+ return {
338
+ fetchAddresses: async () => {
339
+ const response = await addresses_list(client);
340
+ return {
341
+ addresses: (response.addresses ?? []).map(mapAddress),
342
+ meta: {
343
+ request_id: response.meta?.request_id ?? "",
344
+ timestamp: response.meta?.timestamp ?? ""
345
+ }
346
+ };
347
+ },
348
+ createAddress: async (body) => {
349
+ await addresses_create(client, body);
350
+ },
351
+ updateAddress: async (addressId, body) => {
352
+ await addresses_update(client, addressId, body);
353
+ },
354
+ deleteAddress: async (addressId) => {
355
+ await addresses_destroy(client, addressId);
356
+ },
357
+ fetchPaymentMethods: async () => {
358
+ const response = await payment_methods_list(client);
359
+ return {
360
+ payment_methods: (response.payment_methods ?? []).map(mapPaymentMethod),
361
+ meta: {
362
+ request_id: response.meta?.request_id ?? "",
363
+ timestamp: response.meta?.timestamp ?? ""
364
+ }
365
+ };
366
+ },
367
+ createPaymentMethod: async (body) => {
368
+ await payment_methods_create(client, body);
369
+ },
370
+ updatePaymentMethod: async (paymentMethodId, body) => {
371
+ await payment_methods_update(client, paymentMethodId, body);
372
+ },
373
+ deletePaymentMethod: async (paymentMethodId) => {
374
+ await payment_methods_destroy(client, paymentMethodId);
375
+ },
376
+ fetchVaultCredentials: async () => {
377
+ const response = await payment_methods_vault_show(client);
378
+ return {
379
+ vault: {
380
+ token: response.vault?.token ?? null,
381
+ environment: response.vault?.environment ?? "production"
382
+ },
383
+ meta: {
384
+ request_id: response.meta?.request_id ?? "",
385
+ timestamp: response.meta?.timestamp ?? ""
386
+ }
387
+ };
388
+ },
389
+ fetchPointsLedgers: async () => {
390
+ const response = await points_ledgers_list(client);
391
+ return {
392
+ points_ledgers: (response.points_ledgers ?? []).map((entry) => ({
393
+ id: entry.id ?? 0,
394
+ amount: entry.amount ?? 0,
395
+ total_balance: entry.total_balance ?? 0,
396
+ metadata: entry.metadata ?? null,
397
+ created_at: entry.created_at ?? ""
398
+ })),
399
+ meta: {
400
+ request_id: response.meta?.request_id ?? "",
401
+ timestamp: response.meta?.timestamp ?? ""
402
+ }
403
+ };
404
+ }
405
+ };
406
+ }
407
+ //#endregion
408
+ //#region src/account/use-account-clients.ts
409
+ function useOrdersApi() {
410
+ const client = usePortalTenantClient();
411
+ return useMemo(() => createPortalOrdersAdapter(client), [client]);
412
+ }
413
+ function useSubscriptionsApiClient() {
414
+ const client = usePortalTenantClient();
415
+ return useMemo(() => createPortalSubscriptionsAdapter(client), [client]);
416
+ }
417
+ function useAccountApi() {
418
+ const client = usePortalTenantClient();
419
+ return useMemo(() => createAccountApiAdapter(client), [client]);
420
+ }
421
+ function usePayApi() {
422
+ const client = usePortalTenantClient();
423
+ return useMemo(() => createPortalTenantPayAdapter(client), [client]);
424
+ }
425
+ /**
426
+ * Ensures baseUrl ends with /api.
427
+ * Uncovered endpoints (e.g. /countries, points ledgers) use paths without the
428
+ * /api prefix, so the base URL must include it.
429
+ */
430
+ function withApiPrefix(baseUrl) {
431
+ const base = baseUrl.replace(/\/+$/, "");
432
+ return base.endsWith("/api") ? base : `${base}/api`;
433
+ }
434
+ /**
435
+ * Generic SDK fetch client for endpoints not covered by domain-specific clients
436
+ * (e.g. /countries, /v202506/customers/:id/points_ledgers).
437
+ * Creates a FetchClient with /api-prefixed baseUrl since these endpoints
438
+ * use paths like /countries (not /api/countries).
439
+ */
440
+ function useSdkClient() {
441
+ const { config } = useFluidContext();
442
+ return useMemo(() => createFetchClient({
443
+ baseUrl: withApiPrefix(config.baseUrl),
444
+ onAuthError: config.onAuthError,
445
+ credentials: "include"
446
+ }), [config.baseUrl, config.onAuthError]);
447
+ }
448
+ //#endregion
449
+ export { useSubscriptionsApiClient as a, useSdkClient as i, useOrdersApi as n, usePayApi as r, useAccountApi as t };
450
+
451
+ //# sourceMappingURL=use-account-clients-Dim60sir.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-account-clients-Dim60sir.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","portalTenant.account_show","portalTenant.account_update","portalTenantPay.addresses_list","portalTenantPay.addresses_create","portalTenantPay.addresses_update","portalTenantPay.addresses_destroy","portalTenantPay.payment_methods_list","portalTenantPay.payment_methods_create","portalTenantPay.payment_methods_update","portalTenantPay.payment_methods_destroy","portalTenantPay.payment_methods_vault_show","portalTenantPay.points_ledgers_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/adapters/account-api-adapter.ts","../../../api-clients/portal-tenant-pay/src/namespaces/portal_tenant_pay.ts","../src/adapters/pay-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 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 fetchOrder: () => {\n throw new Error(\"Use fetchOrderById for portal-tenant context\");\n },\n fetchCustomerOrders: () => {\n throw new Error(\"Use fetchOrders for portal-tenant context\");\n },\n fetchOrderById: bffAdapter.fetchOrderById,\n fetchOrders: bffAdapter.fetchOrders,\n };\n}\n","import type { AccountApi } from \"@fluid-app/portal-core/account-api\";\nimport type {\n AccountMemberType,\n AccountRep,\n AccountResponse,\n UpdateAccountBody,\n} from \"@fluid-app/portal-core/account-types\";\nimport type { FetchClient } from \"@fluid-app/portal-tenant-api-client\";\nimport { portalTenant } from \"@fluid-app/portal-tenant-api-client\";\n\nfunction mapAccount(\n raw: NonNullable<\n Awaited<ReturnType<typeof portalTenant.account_show>>[\"account\"]\n >,\n): AccountRep {\n return {\n id: raw.id ?? 0,\n member_type: (raw.member_type ?? \"rep\") satisfies AccountMemberType,\n first_name: raw.first_name ?? \"\",\n last_name: raw.last_name ?? \"\",\n email: raw.email ?? \"\",\n phone: raw.phone ?? null,\n bio: raw.bio ?? null,\n avatar_url: raw.avatar_url ?? null,\n slug: raw.slug ?? \"\",\n social_links: (raw.social_links ?? null) as Record<string, string> | null,\n } satisfies AccountRep;\n}\n\nexport function createAccountApiAdapter(client: FetchClient): AccountApi {\n return {\n fetchAccount: async () => {\n const response = await portalTenant.account_show(client);\n return {\n account: mapAccount(response.account ?? {}),\n meta: {\n request_id: response.meta?.request_id ?? \"\",\n timestamp: response.meta?.timestamp ?? \"\",\n },\n } satisfies AccountResponse;\n },\n\n updateAccount: async (body: UpdateAccountBody) => {\n const response = await portalTenant.account_update(client, body);\n return {\n account: mapAccount(response.account ?? {}),\n meta: {\n request_id: response.meta?.request_id ?? \"\",\n timestamp: response.meta?.timestamp ?? \"\",\n },\n } satisfies AccountResponse;\n },\n };\n}\n","/**\n * Generated API client functions for portal_tenant_pay\n *\n * DO NOT EDIT THIS FILE DIRECTLY\n * This file is auto-generated. To update:\n * 1. Update the OpenAPI spec file\n * 2. Run: pnpm generate\n */\n\nimport type { FetchClient } from \"../lib/fetch-client\";\nimport type { operations } from \"../generated/portal-tenant-pay\";\n\n// ============================================================================\n// addresses\n// ============================================================================\n\n/**\n * List addresses\n * Returns addresses associated with the member's customer record in this tenant.\n *\n * @param client - Fetch client instance\n * @param [params] - params\n */\nexport async function addresses_list(\n client: FetchClient,\n params?: operations[\"addresses_list\"][\"parameters\"][\"query\"],\n): Promise<\n operations[\"addresses_list\"][\"responses\"][200][\"content\"][\"application/json\"]\n> {\n return client.get(`/api/pay/addresses`, params);\n}\n\n/**\n * Create an address\n * Adds a new address to the member's customer record. If an identical address already exists it is returned instead of creating a duplicate.\n *\n * @param client - Fetch client instance\n * @param body - body\n */\nexport async function addresses_create(\n client: FetchClient,\n body: operations[\"addresses_create\"][\"requestBody\"][\"content\"][\"application/json\"],\n): Promise<\n operations[\"addresses_create\"][\"responses\"][200][\"content\"][\"application/json\"]\n> {\n return client.post(`/api/pay/addresses`, body);\n}\n\n/**\n * Update an address\n * Creates a new address with the merged attributes and discards the old one, preserving references from existing orders.\n *\n * @param client - Fetch client instance\n * @param id - id\n * @param body - body\n */\nexport async function addresses_update(\n client: FetchClient,\n id: string | number,\n body: operations[\"addresses_update\"][\"requestBody\"][\"content\"][\"application/json\"],\n): Promise<\n operations[\"addresses_update\"][\"responses\"][200][\"content\"][\"application/json\"]\n> {\n return client.patch(`/api/pay/addresses/${id}`, body);\n}\n\n/**\n * Delete an address\n * Removes an address from the member's customer record. The default address cannot be removed.\n *\n * @param client - Fetch client instance\n * @param id - id\n */\nexport async function addresses_destroy(\n client: FetchClient,\n id: string | number,\n): Promise<\n operations[\"addresses_destroy\"][\"responses\"][200][\"content\"][\"application/json\"]\n> {\n return client.delete(`/api/pay/addresses/${id}`);\n}\n\n// ============================================================================\n// payment-methods\n// ============================================================================\n\n/**\n * List payment methods\n * Returns displayable payment methods on the member's customer record, excluding Apple Pay sources.\n *\n * @param client - Fetch client instance\n * @param [params] - params\n */\nexport async function payment_methods_list(\n client: FetchClient,\n params?: operations[\"payment_methods_list\"][\"parameters\"][\"query\"],\n): Promise<\n operations[\"payment_methods_list\"][\"responses\"][200][\"content\"][\"application/json\"]\n> {\n return client.get(`/api/pay/payment_methods`, params);\n}\n\n/**\n * Create a payment method\n * Tokenizes and stores a new payment method via the vault provider. Requires a vault token obtained from the vault credentials endpoint.\n *\n * @param client - Fetch client instance\n * @param body - body\n */\nexport async function payment_methods_create(\n client: FetchClient,\n body: operations[\"payment_methods_create\"][\"requestBody\"][\"content\"][\"application/json\"],\n): Promise<\n operations[\"payment_methods_create\"][\"responses\"][201][\"content\"][\"application/json\"]\n> {\n return client.post(`/api/pay/payment_methods`, body);\n}\n\n/**\n * Update a payment method\n * Updates a payment method's attributes. Currently supports setting a payment method as the default.\n *\n * @param client - Fetch client instance\n * @param id - id\n * @param body - body\n */\nexport async function payment_methods_update(\n client: FetchClient,\n id: string | number,\n body: operations[\"payment_methods_update\"][\"requestBody\"][\"content\"][\"application/json\"],\n): Promise<\n operations[\"payment_methods_update\"][\"responses\"][200][\"content\"][\"application/json\"]\n> {\n return client.patch(`/api/pay/payment_methods/${id}`, body);\n}\n\n/**\n * Delete a payment method\n * Removes a payment method from the member's customer record. If the removed method was the default, the default is cleared.\n *\n * @param client - Fetch client instance\n * @param id - id\n */\nexport async function payment_methods_destroy(\n client: FetchClient,\n id: string | number,\n): Promise<\n operations[\"payment_methods_destroy\"][\"responses\"][200][\"content\"][\"application/json\"]\n> {\n return client.delete(`/api/pay/payment_methods/${id}`);\n}\n\n/**\n * Get vault credentials\n * Returns a short-lived vault token and environment identifier for initializing the client-side payment vault SDK.\n *\n * @param client - Fetch client instance\n \n */\nexport async function payment_methods_vault_show(\n client: FetchClient,\n): Promise<\n operations[\"payment_methods_vault_show\"][\"responses\"][200][\"content\"][\"application/json\"]\n> {\n return client.get(`/api/pay/payment_methods/vault`);\n}\n\n// ============================================================================\n// points-ledgers\n// ============================================================================\n\n/**\n * List points ledger entries\n * Returns loyalty points ledger entries for the member's customer record in this tenant, ordered by most recent first.\n *\n * @param client - Fetch client instance\n * @param [params] - params\n */\nexport async function points_ledgers_list(\n client: FetchClient,\n params?: operations[\"points_ledgers_list\"][\"parameters\"][\"query\"],\n): Promise<\n operations[\"points_ledgers_list\"][\"responses\"][200][\"content\"][\"application/json\"]\n> {\n return client.get(`/api/pay/points_ledgers`, params);\n}\n","import type { PayApi } from \"@fluid-app/portal-core/pay-api\";\nimport type {\n PayAddress,\n PayPaymentMethod,\n CreateAddressBody,\n CreatePaymentMethodBody,\n UpdatePaymentMethodBody,\n VaultResponse,\n PointsLedgersResponse,\n} from \"@fluid-app/portal-core/pay-types\";\nimport type { FetchClient } from \"@fluid-app/portal-tenant-api-client\";\nimport { portalTenantPay } from \"@fluid-app/portal-tenant-pay-api-client\";\n\n// ---------------------------------------------------------------------------\n// BFF response type helpers\n// ---------------------------------------------------------------------------\n\ntype BffAddress = NonNullable<\n Awaited<ReturnType<typeof portalTenantPay.addresses_list>>[\"addresses\"]\n>[number];\n\ntype BffPaymentMethod = NonNullable<\n Awaited<\n ReturnType<typeof portalTenantPay.payment_methods_list>\n >[\"payment_methods\"]\n>[number];\n\n// ---------------------------------------------------------------------------\n// BFF → port type mappers\n// ---------------------------------------------------------------------------\n\nfunction mapAddress(raw: BffAddress): PayAddress {\n return {\n id: raw.id ?? 0,\n street1: raw.street1 ?? \"\",\n street2: raw.street2 ?? null,\n city: raw.city ?? \"\",\n state: raw.state ?? \"\",\n zip: raw.zip ?? \"\",\n country: raw.country ?? \"\",\n default: raw.default ?? false,\n created_at: raw.created_at ?? null,\n updated_at: raw.updated_at ?? null,\n };\n}\n\nfunction mapPaymentMethod(raw: BffPaymentMethod): PayPaymentMethod {\n return {\n id: raw.id ?? 0,\n type: raw.type ?? \"card\",\n brand: raw.brand ?? null,\n last_four: raw.last_four ?? \"\",\n exp_month: raw.exp_month ?? null,\n exp_year: raw.exp_year ?? null,\n default: raw.default ?? false,\n created_at: raw.created_at ?? null,\n updated_at: raw.updated_at ?? null,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Adapter factory\n// ---------------------------------------------------------------------------\n\nexport function createPortalTenantPayAdapter(client: FetchClient): PayApi {\n return {\n fetchAddresses: async () => {\n const response = await portalTenantPay.addresses_list(client);\n return {\n addresses: (response.addresses ?? []).map(mapAddress),\n meta: {\n request_id: response.meta?.request_id ?? \"\",\n timestamp: response.meta?.timestamp ?? \"\",\n },\n };\n },\n\n createAddress: async (body: CreateAddressBody) => {\n await portalTenantPay.addresses_create(client, body);\n },\n\n updateAddress: async (addressId: number, body: CreateAddressBody) => {\n await portalTenantPay.addresses_update(client, addressId, body);\n },\n\n deleteAddress: async (addressId: number) => {\n await portalTenantPay.addresses_destroy(client, addressId);\n },\n\n fetchPaymentMethods: async () => {\n const response = await portalTenantPay.payment_methods_list(client);\n return {\n payment_methods: (response.payment_methods ?? []).map(mapPaymentMethod),\n meta: {\n request_id: response.meta?.request_id ?? \"\",\n timestamp: response.meta?.timestamp ?? \"\",\n },\n };\n },\n\n createPaymentMethod: async (body: CreatePaymentMethodBody) => {\n await portalTenantPay.payment_methods_create(client, body);\n },\n\n updatePaymentMethod: async (\n paymentMethodId: number,\n body: UpdatePaymentMethodBody,\n ) => {\n await portalTenantPay.payment_methods_update(\n client,\n paymentMethodId,\n body,\n );\n },\n\n deletePaymentMethod: async (paymentMethodId: number) => {\n await portalTenantPay.payment_methods_destroy(client, paymentMethodId);\n },\n\n fetchVaultCredentials: async () => {\n const response = await portalTenantPay.payment_methods_vault_show(client);\n return {\n vault: {\n token: response.vault?.token ?? null,\n environment: response.vault?.environment ?? \"production\",\n },\n meta: {\n request_id: response.meta?.request_id ?? \"\",\n timestamp: response.meta?.timestamp ?? \"\",\n },\n } satisfies VaultResponse;\n },\n\n fetchPointsLedgers: async () => {\n const response = await portalTenantPay.points_ledgers_list(client);\n return {\n points_ledgers: (response.points_ledgers ?? []).map((entry) => ({\n id: entry.id ?? 0,\n amount: entry.amount ?? 0,\n total_balance: entry.total_balance ?? 0,\n metadata: (entry.metadata as Record<string, unknown>) ?? null,\n created_at: entry.created_at ?? \"\",\n })),\n meta: {\n request_id: response.meta?.request_id ?? \"\",\n timestamp: response.meta?.timestamp ?? \"\",\n },\n } satisfies PointsLedgersResponse;\n },\n };\n}\n","import { useMemo } from \"react\";\nimport type { OrdersApi } from \"@fluid-app/orders-core\";\nimport type { SubscriptionsApi } from \"@fluid-app/subscriptions-core\";\nimport type { AccountApi } from \"@fluid-app/portal-core/account-api\";\nimport type { PayApi } from \"@fluid-app/portal-core/pay-api\";\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 { createAccountApiAdapter } from \"../adapters/account-api-adapter\";\nimport { createPortalTenantPayAdapter } from \"../adapters/pay-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\nexport function useAccountApi(): AccountApi {\n const client = usePortalTenantClient();\n\n return useMemo(() => createAccountApiAdapter(client), [client]);\n}\n\nexport function usePayApi(): PayApi {\n const client = usePortalTenantClient();\n\n return useMemo(() => createPortalTenantPayAdapter(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,YACG;AAKH,UAAO,sBAJU,MAAMC,oBACrB,QACA,kBACD,CACqC;;EAGxC,oBAAoB,OAClB,mBACA,YACG;AAKH,UAAO,sBAJU,MAAMC,qBACrB,QACA,kBACD,CACqC;;EAGxC,kBAAkB,OAChB,mBACA,YACG;AAKH,UAAO,sBAJU,MAAMC,mBACrB,QACA,kBACD,CACqC;;EA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