@fluid-app/portal-sdk 0.1.142 → 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.
Files changed (111) hide show
  1. package/dist/{AppDownloadScreen-CO-wctCB.cjs → AppDownloadScreen-CxkoYLT6.cjs} +2 -2
  2. package/dist/{AppDownloadScreen-CO-wctCB.cjs.map → AppDownloadScreen-CxkoYLT6.cjs.map} +1 -1
  3. package/dist/{AppDownloadScreen-nz3fgOVF.cjs → AppDownloadScreen-DXZpoE5A.cjs} +2 -2
  4. package/dist/{AppDownloadScreen-Df1OPjkx.mjs → AppDownloadScreen-ga-5O4jr.mjs} +2 -2
  5. package/dist/{AppDownloadScreen-Df1OPjkx.mjs.map → AppDownloadScreen-ga-5O4jr.mjs.map} +1 -1
  6. package/dist/{ContactsScreen-cWDFP8e-.mjs → ContactsScreen-C-xJcR5X.mjs} +6 -6
  7. package/dist/{ContactsScreen-cWDFP8e-.mjs.map → ContactsScreen-C-xJcR5X.mjs.map} +1 -1
  8. package/dist/{ContactsScreen-gJB99SIY.cjs → ContactsScreen-DYkGu477.cjs} +7 -7
  9. package/dist/{ContactsScreen-BPeQemgG.cjs → ContactsScreen-RQ1IENFl.cjs} +6 -6
  10. package/dist/{ContactsScreen-BPeQemgG.cjs.map → ContactsScreen-RQ1IENFl.cjs.map} +1 -1
  11. package/dist/{FluidProvider-BIoYteOA.mjs → FluidProvider-Bs9eWShT.mjs} +279 -9
  12. package/dist/FluidProvider-Bs9eWShT.mjs.map +1 -0
  13. package/dist/{FluidProvider-DAe8xcAD.cjs → FluidProvider-DzCUwDPA.cjs} +290 -20
  14. package/dist/FluidProvider-DzCUwDPA.cjs.map +1 -0
  15. package/dist/{MessagingScreen-BsABB4tn.cjs → MessagingScreen-BmAICPkY.cjs} +4 -4
  16. package/dist/{MessagingScreen-BgY-m0Pm.cjs → MessagingScreen-D7hAjWaG.cjs} +5 -5
  17. package/dist/{MessagingScreen-BgY-m0Pm.cjs.map → MessagingScreen-D7hAjWaG.cjs.map} +1 -1
  18. package/dist/{MessagingScreen-DKXOCrBj.mjs → MessagingScreen-DOcgxDbR.mjs} +4 -4
  19. package/dist/{MessagingScreen-DKXOCrBj.mjs.map → MessagingScreen-DOcgxDbR.mjs.map} +1 -1
  20. package/dist/{MySiteScreen-DVjRy-nI.cjs → MySiteScreen-BMFJLAwJ.cjs} +2 -2
  21. package/dist/{MySiteScreen-DVjRy-nI.cjs.map → MySiteScreen-BMFJLAwJ.cjs.map} +1 -1
  22. package/dist/{MySiteScreen-D8lFT21T.mjs → MySiteScreen-BwCQLYBT.mjs} +2 -2
  23. package/dist/{MySiteScreen-D8lFT21T.mjs.map → MySiteScreen-BwCQLYBT.mjs.map} +1 -1
  24. package/dist/{MySiteScreen-BTF8MZCU.cjs → MySiteScreen-C_-EPLsj.cjs} +2 -2
  25. package/dist/{OrdersScreen-CbCus7pT.cjs → OrdersScreen-DHoIUinY.cjs} +3 -3
  26. package/dist/{OrdersScreen-CbCus7pT.cjs.map → OrdersScreen-DHoIUinY.cjs.map} +1 -1
  27. package/dist/{OrdersScreen-BB_n4hgl.cjs → OrdersScreen-DgBe0kl9.cjs} +3 -3
  28. package/dist/{OrdersScreen-BHtq-tvn.mjs → OrdersScreen-ihhKswAb.mjs} +3 -3
  29. package/dist/{OrdersScreen-BHtq-tvn.mjs.map → OrdersScreen-ihhKswAb.mjs.map} +1 -1
  30. package/dist/{ProductsScreen-CU8nGFN5.mjs → ProductsScreen-BbgYlCfQ.mjs} +6 -6
  31. package/dist/{ProductsScreen-CU8nGFN5.mjs.map → ProductsScreen-BbgYlCfQ.mjs.map} +1 -1
  32. package/dist/{ProductsScreen-CP29k8Z3.cjs → ProductsScreen-BulxEN71.cjs} +7 -7
  33. package/dist/{ProductsScreen-DSgwSnVj.mjs → ProductsScreen-OPY76KpG.mjs} +6 -6
  34. package/dist/{ProductsScreen-CuMgdka9.cjs → ProductsScreen-snrXLhuy.cjs} +6 -6
  35. package/dist/{ProductsScreen-CuMgdka9.cjs.map → ProductsScreen-snrXLhuy.cjs.map} +1 -1
  36. package/dist/{ProfileScreen-CjrhOuY3.cjs → ProfileScreen-CES4uRpE.cjs} +2 -2
  37. package/dist/{ProfileScreen-CDZ632ue.cjs → ProfileScreen-CPCkXse4.cjs} +5 -6
  38. package/dist/{ProfileScreen-CDZ632ue.cjs.map → ProfileScreen-CPCkXse4.cjs.map} +1 -1
  39. package/dist/{ProfileScreen-BajH0_kR.mjs → ProfileScreen-doxUb6Ud.mjs} +3 -4
  40. package/dist/{ProfileScreen-BajH0_kR.mjs.map → ProfileScreen-doxUb6Ud.mjs.map} +1 -1
  41. package/dist/{SearchSort-CyeeUmwC.cjs → SearchSort-DOLoubGE.cjs} +1 -1
  42. package/dist/{SearchSort-CyeeUmwC.cjs.map → SearchSort-DOLoubGE.cjs.map} +1 -1
  43. package/dist/{SearchSort-BXklP8Pq.mjs → SearchSort-LZm-VfF7.mjs} +1 -1
  44. package/dist/{SearchSort-BXklP8Pq.mjs.map → SearchSort-LZm-VfF7.mjs.map} +1 -1
  45. package/dist/{ShareablesScreen-acj-gCLe.cjs → ShareablesScreen-B6-BcjEt.cjs} +7 -7
  46. package/dist/{ShareablesScreen-F3ockfKE.mjs → ShareablesScreen-CJk0udFG.mjs} +7 -7
  47. package/dist/{ShareablesScreen-F3ockfKE.mjs.map → ShareablesScreen-CJk0udFG.mjs.map} +1 -1
  48. package/dist/{ShareablesScreen-ITLkfDHV.cjs → ShareablesScreen-DaQAxGCr.cjs} +7 -7
  49. package/dist/{ShareablesScreen-ITLkfDHV.cjs.map → ShareablesScreen-DaQAxGCr.cjs.map} +1 -1
  50. package/dist/{ShareablesScreen-B63fbgRJ.mjs → ShareablesScreen-yC7UrhhU.mjs} +6 -6
  51. package/dist/{ShopScreen-DdIlnLcB.mjs → ShopScreen-B3kyH-AP.mjs} +5 -5
  52. package/dist/{ShopScreen-DdIlnLcB.mjs.map → ShopScreen-B3kyH-AP.mjs.map} +1 -1
  53. package/dist/{ShopScreen-3Z-9TKeI.cjs → ShopScreen-D6JAjTai.cjs} +5 -5
  54. package/dist/{ShopScreen-3Z-9TKeI.cjs.map → ShopScreen-D6JAjTai.cjs.map} +1 -1
  55. package/dist/{ShopScreen-Bit0Fdgr.cjs → ShopScreen-DUpCS4va.cjs} +3 -3
  56. package/dist/{SubscriptionsScreen-DV5RUV66.cjs → SubscriptionsScreen-CEkKX-O9.cjs} +5 -5
  57. package/dist/{SubscriptionsScreen-DV5RUV66.cjs.map → SubscriptionsScreen-CEkKX-O9.cjs.map} +1 -1
  58. package/dist/{SubscriptionsScreen-B2-iZojm.mjs → SubscriptionsScreen-DlRbMhFz.mjs} +5 -5
  59. package/dist/{SubscriptionsScreen-B2-iZojm.mjs.map → SubscriptionsScreen-DlRbMhFz.mjs.map} +1 -1
  60. package/dist/{SubscriptionsScreen-01RuJl73.cjs → SubscriptionsScreen-jpRkUvPY.cjs} +5 -5
  61. package/dist/{dist-Cl4FsM3V.mjs → dist-B8padP0r.mjs} +2 -2
  62. package/dist/{dist-Cl4FsM3V.mjs.map → dist-B8padP0r.mjs.map} +1 -1
  63. package/dist/{dist-CbeLS2R5.cjs → dist-BoyKnTdv.cjs} +2 -2
  64. package/dist/{dist-CbeLS2R5.cjs.map → dist-BoyKnTdv.cjs.map} +1 -1
  65. package/dist/{dist-BbS_7TvS.cjs → dist-DRVtlgQ1.cjs} +1 -1
  66. package/dist/{dist-BbS_7TvS.cjs.map → dist-DRVtlgQ1.cjs.map} +1 -1
  67. package/dist/{dist-CMGXkSgZ.mjs → dist-NMbUD0qE.mjs} +1 -1
  68. package/dist/{dist-CMGXkSgZ.mjs.map → dist-NMbUD0qE.mjs.map} +1 -1
  69. package/dist/{es-BSkb3AZk.cjs → es-DlWO6buB.cjs} +1 -1
  70. package/dist/{es-BSkb3AZk.cjs.map → es-DlWO6buB.cjs.map} +1 -1
  71. package/dist/index.cjs +41 -41
  72. package/dist/index.d.cts.map +1 -1
  73. package/dist/index.d.mts.map +1 -1
  74. package/dist/index.mjs +40 -40
  75. package/dist/{order-status-badge-DsbuULAc.cjs → order-status-badge-BqoNJ8XK.cjs} +1 -1
  76. package/dist/{order-status-badge-DsbuULAc.cjs.map → order-status-badge-BqoNJ8XK.cjs.map} +1 -1
  77. package/dist/{order-status-badge-B-iGmxDO.mjs → order-status-badge-CkvYyjT7.mjs} +1 -1
  78. package/dist/{order-status-badge-B-iGmxDO.mjs.map → order-status-badge-CkvYyjT7.mjs.map} +1 -1
  79. package/dist/{portal-tenant-product-media-adapter-y_yCswfv.mjs → portal-tenant-product-media-adapter-BHtx3DdM.mjs} +4 -4
  80. package/dist/{portal-tenant-product-media-adapter-y_yCswfv.mjs.map → portal-tenant-product-media-adapter-BHtx3DdM.mjs.map} +1 -1
  81. package/dist/{portal-tenant-product-media-adapter-DmH2iJvp.cjs → portal-tenant-product-media-adapter-qXW0vGG8.cjs} +5 -5
  82. package/dist/{portal-tenant-product-media-adapter-DmH2iJvp.cjs.map → portal-tenant-product-media-adapter-qXW0vGG8.cjs.map} +1 -1
  83. package/dist/use-account-clients-GUakuhX-.cjs +212 -0
  84. package/dist/use-account-clients-GUakuhX-.cjs.map +1 -0
  85. package/dist/use-account-clients-d3FMT7rH.mjs +194 -0
  86. package/dist/use-account-clients-d3FMT7rH.mjs.map +1 -0
  87. package/dist/{use-current-user-DAxsYRk-.mjs → use-current-user-Cjd0lFyc.mjs} +3 -3
  88. package/dist/{use-current-user-DAxsYRk-.mjs.map → use-current-user-Cjd0lFyc.mjs.map} +1 -1
  89. package/dist/{use-current-user-5Kr_1nZZ.cjs → use-current-user-idj1wuKD.cjs} +3 -3
  90. package/dist/{use-current-user-5Kr_1nZZ.cjs.map → use-current-user-idj1wuKD.cjs.map} +1 -1
  91. package/dist/{use-fluid-api-BJ-PZ0Zx.mjs → use-fluid-api-DdMmBE5K.mjs} +2 -2
  92. package/dist/{use-fluid-api-BJ-PZ0Zx.mjs.map → use-fluid-api-DdMmBE5K.mjs.map} +1 -1
  93. package/dist/{use-fluid-api-uEqwymly.cjs → use-fluid-api-DnDH2bby.cjs} +2 -2
  94. package/dist/{use-fluid-api-uEqwymly.cjs.map → use-fluid-api-DnDH2bby.cjs.map} +1 -1
  95. package/dist/{use-fluid-auth-DXDtI7Ep.cjs → use-fluid-auth-CcxpIYkI.cjs} +2 -2
  96. package/dist/{use-fluid-auth-DXDtI7Ep.cjs.map → use-fluid-auth-CcxpIYkI.cjs.map} +1 -1
  97. package/dist/{use-fluid-auth-DrtkGGwT.mjs → use-fluid-auth-_LboeZI9.mjs} +2 -2
  98. package/dist/{use-fluid-auth-DrtkGGwT.mjs.map → use-fluid-auth-_LboeZI9.mjs.map} +1 -1
  99. package/dist/{use-portal-products-client-zvmWMf8p.mjs → use-portal-products-client-DA7Vop2s.mjs} +2 -2
  100. package/dist/{use-portal-products-client-zvmWMf8p.mjs.map → use-portal-products-client-DA7Vop2s.mjs.map} +1 -1
  101. package/dist/{use-portal-products-client-CXZj-fKI.cjs → use-portal-products-client-DAXn2JSf.cjs} +2 -2
  102. package/dist/{use-portal-products-client-CXZj-fKI.cjs.map → use-portal-products-client-DAXn2JSf.cjs.map} +1 -1
  103. package/package.json +13 -13
  104. package/dist/FluidProvider-BIoYteOA.mjs.map +0 -1
  105. package/dist/FluidProvider-DAe8xcAD.cjs.map +0 -1
  106. package/dist/use-account-clients-CNDyBxm7.mjs +0 -446
  107. package/dist/use-account-clients-CNDyBxm7.mjs.map +0 -1
  108. package/dist/use-account-clients-nmrVvm98.cjs +0 -476
  109. package/dist/use-account-clients-nmrVvm98.cjs.map +0 -1
  110. /package/dist/{src-zEMEV1KP.mjs → src-6SxtfYk9.mjs} +0 -0
  111. /package/dist/{src-CzwiFO_J.cjs → src-ClULVolb.cjs} +0 -0
@@ -1,476 +0,0 @@
1
- require("./chunk-9hOWP6kD.cjs");
2
- const require_FluidProvider = require("./FluidProvider-DAe8xcAD.cjs");
3
- let react = require("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 require_FluidProvider.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 require_FluidProvider.subscriptions_show(client, subscriptionToken));
52
- },
53
- pauseSubscription: async (subscriptionToken, _params) => {
54
- return mapSubscriptionDetail(await require_FluidProvider.subscriptions_pause(client, subscriptionToken));
55
- },
56
- resumeSubscription: async (subscriptionToken, _params) => {
57
- return mapSubscriptionDetail(await require_FluidProvider.subscriptions_resume(client, subscriptionToken));
58
- },
59
- skipSubscription: async (subscriptionToken, _params) => {
60
- return mapSubscriptionDetail(await require_FluidProvider.subscriptions_skip(client, subscriptionToken));
61
- },
62
- cancelSubscription: async (subscriptionToken, _customerId) => {
63
- return mapSubscriptionDetail(await require_FluidProvider.subscriptions_cancel(client, subscriptionToken));
64
- },
65
- reactivateSubscription: async (subscriptionToken, _params) => {
66
- return mapSubscriptionDetail(await require_FluidProvider.subscriptions_reactivate(client, subscriptionToken));
67
- },
68
- updateSubscriptionInfo: async (subscriptionToken, body) => {
69
- return mapSubscriptionDetail(await require_FluidProvider.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
- total_points_credited: typeof raw.total_points_credited === "number" ? raw.total_points_credited : void 0,
100
- customer_points_balance: typeof raw.customer_points_balance === "number" ? raw.customer_points_balance : void 0,
101
- created_at: raw.created_at ?? "",
102
- updated_at: raw.updated_at ?? ""
103
- };
104
- }
105
- function mapMeta(raw) {
106
- return {
107
- request_id: raw?.request_id ?? "",
108
- timestamp: raw?.timestamp ?? "",
109
- pagination: {
110
- cursor: raw?.pagination?.cursor ?? null,
111
- limit: raw?.pagination?.limit ?? 25,
112
- next_cursor: raw?.pagination?.next_cursor ?? null,
113
- prev_cursor: raw?.pagination?.prev_cursor ?? null
114
- }
115
- };
116
- }
117
- function createPortalTenantOrdersAdapter(client) {
118
- return {
119
- fetchOrderById: async (id) => {
120
- const response = await require_FluidProvider.orders_show(client, id);
121
- return {
122
- order: mapOrder(response.order ?? {}),
123
- meta: {
124
- request_id: response.meta?.request_id ?? "",
125
- timestamp: response.meta?.timestamp ?? ""
126
- }
127
- };
128
- },
129
- fetchOrders: async (params) => {
130
- const response = await require_FluidProvider.orders_list(client, {
131
- "page[cursor]": params.cursor,
132
- "page[limit]": params.limit,
133
- status: params.status
134
- });
135
- return {
136
- orders: (response.orders ?? []).map(mapOrder),
137
- meta: mapMeta(response.meta)
138
- };
139
- }
140
- };
141
- }
142
- //#endregion
143
- //#region src/adapters/orders-api-adapter.ts
144
- /**
145
- * Creates an OrdersApi adapter for the portal-tenant BFF.
146
- *
147
- * Delegates to the existing clean adapter in orders/api-client which maps
148
- * BFF responses to PortalTenantOrder types. The legacy methods (fetchOrder,
149
- * fetchCustomerOrders) are not used by portal UI — portal-specific hooks
150
- * call fetchOrders/fetchOrderById directly.
151
- */
152
- function createPortalOrdersAdapter(client) {
153
- const bffAdapter = createPortalTenantOrdersAdapter(client);
154
- return {
155
- fetchOrderById: bffAdapter.fetchOrderById,
156
- fetchOrders: bffAdapter.fetchOrders
157
- };
158
- }
159
- //#endregion
160
- //#region src/adapters/account-api-adapter.ts
161
- function mapAccount(raw) {
162
- return {
163
- id: raw.id ?? 0,
164
- member_type: raw.member_type ?? "rep",
165
- first_name: raw.first_name ?? "",
166
- last_name: raw.last_name ?? "",
167
- email: raw.email ?? "",
168
- phone: raw.phone ?? null,
169
- bio: raw.bio ?? null,
170
- avatar_url: raw.avatar_url ?? null,
171
- slug: raw.slug ?? "",
172
- social_links: raw.social_links ?? null
173
- };
174
- }
175
- function createAccountApiAdapter(client) {
176
- return {
177
- fetchAccount: async () => {
178
- const response = await require_FluidProvider.account_show(client);
179
- return {
180
- account: mapAccount(response.account ?? {}),
181
- meta: {
182
- request_id: response.meta?.request_id ?? "",
183
- timestamp: response.meta?.timestamp ?? ""
184
- }
185
- };
186
- },
187
- updateAccount: async (body) => {
188
- const response = await require_FluidProvider.account_update(client, body);
189
- return {
190
- account: mapAccount(response.account ?? {}),
191
- meta: {
192
- request_id: response.meta?.request_id ?? "",
193
- timestamp: response.meta?.timestamp ?? ""
194
- }
195
- };
196
- }
197
- };
198
- }
199
- //#endregion
200
- //#region ../../api-clients/portal-tenant-pay/src/namespaces/portal_tenant_pay.ts
201
- /**
202
- * List addresses
203
- * Returns addresses associated with the member's customer record in this tenant.
204
- *
205
- * @param client - Fetch client instance
206
- * @param [params] - params
207
- */
208
- async function addresses_list(client, params) {
209
- return client.get(`/api/pay/addresses`, params);
210
- }
211
- /**
212
- * Create an address
213
- * Adds a new address to the member's customer record. If an identical address already exists it is returned instead of creating a duplicate.
214
- *
215
- * @param client - Fetch client instance
216
- * @param body - body
217
- */
218
- async function addresses_create(client, body) {
219
- return client.post(`/api/pay/addresses`, body);
220
- }
221
- /**
222
- * Update an address
223
- * Creates a new address with the merged attributes and discards the old one, preserving references from existing orders.
224
- *
225
- * @param client - Fetch client instance
226
- * @param id - id
227
- * @param body - body
228
- */
229
- async function addresses_update(client, id, body) {
230
- return client.patch(`/api/pay/addresses/${id}`, body);
231
- }
232
- /**
233
- * Delete an address
234
- * Removes an address from the member's customer record. The default address cannot be removed.
235
- *
236
- * @param client - Fetch client instance
237
- * @param id - id
238
- */
239
- async function addresses_destroy(client, id) {
240
- return client.delete(`/api/pay/addresses/${id}`);
241
- }
242
- /**
243
- * List payment methods
244
- * Returns displayable payment methods on the member's customer record, excluding Apple Pay sources.
245
- *
246
- * @param client - Fetch client instance
247
- * @param [params] - params
248
- */
249
- async function payment_methods_list(client, params) {
250
- return client.get(`/api/pay/payment_methods`, params);
251
- }
252
- /**
253
- * Create a payment method
254
- * Tokenizes and stores a new payment method via the vault provider. Requires a vault token obtained from the vault credentials endpoint.
255
- *
256
- * @param client - Fetch client instance
257
- * @param body - body
258
- */
259
- async function payment_methods_create(client, body) {
260
- return client.post(`/api/pay/payment_methods`, body);
261
- }
262
- /**
263
- * Update a payment method
264
- * Updates a payment method's attributes. Currently supports setting a payment method as the default.
265
- *
266
- * @param client - Fetch client instance
267
- * @param id - id
268
- * @param body - body
269
- */
270
- async function payment_methods_update(client, id, body) {
271
- return client.patch(`/api/pay/payment_methods/${id}`, body);
272
- }
273
- /**
274
- * Delete a payment method
275
- * Removes a payment method from the member's customer record. If the removed method was the default, the default is cleared.
276
- *
277
- * @param client - Fetch client instance
278
- * @param id - id
279
- */
280
- async function payment_methods_destroy(client, id) {
281
- return client.delete(`/api/pay/payment_methods/${id}`);
282
- }
283
- /**
284
- * Get vault credentials
285
- * Returns a short-lived vault token and environment identifier for initializing the client-side payment vault SDK.
286
- *
287
- * @param client - Fetch client instance
288
-
289
- */
290
- async function payment_methods_vault_show(client) {
291
- return client.get(`/api/pay/payment_methods/vault`);
292
- }
293
- /**
294
- * List points ledger entries
295
- * Returns loyalty points ledger entries for the member's customer record in this tenant, ordered by most recent first.
296
- *
297
- * @param client - Fetch client instance
298
- * @param [params] - params
299
- */
300
- async function points_ledgers_list(client, params) {
301
- return client.get(`/api/pay/points_ledgers`, params);
302
- }
303
- //#endregion
304
- //#region src/adapters/pay-api-adapter.ts
305
- function mapAddress(raw) {
306
- return {
307
- id: raw.id ?? 0,
308
- street1: raw.street1 ?? "",
309
- street2: raw.street2 ?? null,
310
- city: raw.city ?? "",
311
- state: raw.state ?? "",
312
- zip: raw.zip ?? "",
313
- country: raw.country ?? "",
314
- default: raw.default ?? false,
315
- created_at: raw.created_at ?? null,
316
- updated_at: raw.updated_at ?? null
317
- };
318
- }
319
- function mapPaymentMethod(raw) {
320
- return {
321
- id: raw.id ?? 0,
322
- type: raw.type ?? "card",
323
- brand: raw.brand ?? null,
324
- last_four: raw.last_four ?? "",
325
- exp_month: raw.exp_month ?? null,
326
- exp_year: raw.exp_year ?? null,
327
- default: raw.default ?? false,
328
- created_at: raw.created_at ?? null,
329
- updated_at: raw.updated_at ?? null
330
- };
331
- }
332
- function createPortalTenantPayAdapter(client) {
333
- return {
334
- fetchAddresses: async () => {
335
- const response = await addresses_list(client);
336
- return {
337
- addresses: (response.addresses ?? []).map(mapAddress),
338
- meta: {
339
- request_id: response.meta?.request_id ?? "",
340
- timestamp: response.meta?.timestamp ?? ""
341
- }
342
- };
343
- },
344
- createAddress: async (body) => {
345
- await addresses_create(client, body);
346
- },
347
- updateAddress: async (addressId, body) => {
348
- await addresses_update(client, addressId, body);
349
- },
350
- deleteAddress: async (addressId) => {
351
- await addresses_destroy(client, addressId);
352
- },
353
- fetchPaymentMethods: async () => {
354
- const response = await payment_methods_list(client);
355
- return {
356
- payment_methods: (response.payment_methods ?? []).map(mapPaymentMethod),
357
- meta: {
358
- request_id: response.meta?.request_id ?? "",
359
- timestamp: response.meta?.timestamp ?? ""
360
- }
361
- };
362
- },
363
- createPaymentMethod: async (body) => {
364
- await payment_methods_create(client, body);
365
- },
366
- updatePaymentMethod: async (paymentMethodId, body) => {
367
- await payment_methods_update(client, paymentMethodId, body);
368
- },
369
- deletePaymentMethod: async (paymentMethodId) => {
370
- await payment_methods_destroy(client, paymentMethodId);
371
- },
372
- fetchVaultCredentials: async () => {
373
- const response = await payment_methods_vault_show(client);
374
- return {
375
- vault: {
376
- token: response.vault?.token ?? null,
377
- environment: response.vault?.environment ?? "production"
378
- },
379
- meta: {
380
- request_id: response.meta?.request_id ?? "",
381
- timestamp: response.meta?.timestamp ?? ""
382
- }
383
- };
384
- },
385
- fetchPointsLedgers: async () => {
386
- const response = await points_ledgers_list(client);
387
- return {
388
- points_ledgers: (response.points_ledgers ?? []).map((entry) => ({
389
- id: entry.id ?? 0,
390
- amount: entry.amount ?? 0,
391
- total_balance: entry.total_balance ?? 0,
392
- metadata: entry.metadata ?? null,
393
- created_at: entry.created_at ?? ""
394
- })),
395
- meta: {
396
- request_id: response.meta?.request_id ?? "",
397
- timestamp: response.meta?.timestamp ?? ""
398
- }
399
- };
400
- }
401
- };
402
- }
403
- //#endregion
404
- //#region src/account/use-account-clients.ts
405
- function useOrdersApi() {
406
- const client = require_FluidProvider.usePortalTenantClient();
407
- return (0, react.useMemo)(() => createPortalOrdersAdapter(client), [client]);
408
- }
409
- function useSubscriptionsApiClient() {
410
- const client = require_FluidProvider.usePortalTenantClient();
411
- return (0, react.useMemo)(() => createPortalSubscriptionsAdapter(client), [client]);
412
- }
413
- function useAccountApi() {
414
- const client = require_FluidProvider.usePortalTenantClient();
415
- return (0, react.useMemo)(() => createAccountApiAdapter(client), [client]);
416
- }
417
- function usePayApi() {
418
- const client = require_FluidProvider.usePortalTenantClient();
419
- return (0, react.useMemo)(() => createPortalTenantPayAdapter(client), [client]);
420
- }
421
- /**
422
- * Ensures baseUrl ends with /api.
423
- * Uncovered endpoints (e.g. /countries, points ledgers) use paths without the
424
- * /api prefix, so the base URL must include it.
425
- */
426
- function withApiPrefix(baseUrl) {
427
- const base = baseUrl.replace(/\/+$/, "");
428
- return base.endsWith("/api") ? base : `${base}/api`;
429
- }
430
- /**
431
- * Generic SDK fetch client for endpoints not covered by domain-specific clients
432
- * (e.g. /countries, /v202506/customers/:id/points_ledgers).
433
- * Creates a FetchClient with /api-prefixed baseUrl since these endpoints
434
- * use paths like /countries (not /api/countries).
435
- */
436
- function useSdkClient() {
437
- const { config } = require_FluidProvider.useFluidContext();
438
- return (0, react.useMemo)(() => require_FluidProvider.createFetchClient({
439
- baseUrl: withApiPrefix(config.baseUrl),
440
- onAuthError: config.onAuthError,
441
- credentials: "include"
442
- }), [config.baseUrl, config.onAuthError]);
443
- }
444
- //#endregion
445
- Object.defineProperty(exports, "useAccountApi", {
446
- enumerable: true,
447
- get: function() {
448
- return useAccountApi;
449
- }
450
- });
451
- Object.defineProperty(exports, "useOrdersApi", {
452
- enumerable: true,
453
- get: function() {
454
- return useOrdersApi;
455
- }
456
- });
457
- Object.defineProperty(exports, "usePayApi", {
458
- enumerable: true,
459
- get: function() {
460
- return usePayApi;
461
- }
462
- });
463
- Object.defineProperty(exports, "useSdkClient", {
464
- enumerable: true,
465
- get: function() {
466
- return useSdkClient;
467
- }
468
- });
469
- Object.defineProperty(exports, "useSubscriptionsApiClient", {
470
- enumerable: true,
471
- get: function() {
472
- return useSubscriptionsApiClient;
473
- }
474
- });
475
-
476
- //# sourceMappingURL=use-account-clients-nmrVvm98.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-account-clients-nmrVvm98.cjs","names":["mapMeta","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","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/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 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 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,MAAA,sBAAA,mBAAsC,QAAQ;IAC7D,gBAAgB,OAAO;IACvB,eAAe,OAAO,SAAS,OAAO;IACvC,CAAC,CACkC;;EAGtC,mBAAmB,OAAO,sBAA8B;AAKtD,UAAO,sBAJU,MAAA,sBAAA,mBACf,QACA,kBACD,CACqC;;EAGxC,mBAAmB,OACjB,mBACA,YACG;AAKH,UAAO,sBAJU,MAAA,sBAAA,oBACf,QACA,kBACD,CACqC;;EAGxC,oBAAoB,OAClB,mBACA,YACG;AAKH,UAAO,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