@fluid-app/portal-sdk 0.1.158 → 0.1.160
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -196
- package/dist/{FluidProvider-Cqf2kmUc.mjs → FluidProvider-B00jTGTH.mjs} +1510 -1624
- package/dist/FluidProvider-B00jTGTH.mjs.map +1 -0
- package/dist/{FluidProvider-Bc-3uN7M.cjs → FluidProvider-BtGi2jJt.cjs} +1458 -1614
- package/dist/FluidProvider-BtGi2jJt.cjs.map +1 -0
- package/dist/{MessagingScreen-BGqIn-c2.cjs → MessagingScreen-BRCUJDDZ.cjs} +2 -2
- package/dist/{MessagingScreen-CbmuvlH6.mjs → MessagingScreen-BWpSXB8Q.mjs} +2 -2
- package/dist/{MessagingScreen-CbmuvlH6.mjs.map → MessagingScreen-BWpSXB8Q.mjs.map} +1 -1
- package/dist/{MessagingScreen-CBPjP4du.cjs → MessagingScreen-C_OLIWCC.cjs} +2 -2
- package/dist/{MessagingScreen-CBPjP4du.cjs.map → MessagingScreen-C_OLIWCC.cjs.map} +1 -1
- package/dist/{MySiteScreen-DSDLDnCN.cjs → MySiteScreen-B90qzZPe.cjs} +2 -2
- package/dist/{MySiteScreen-Cl6nuU99.cjs → MySiteScreen-DLuHDXB1.cjs} +2 -2
- package/dist/{MySiteScreen-Cl6nuU99.cjs.map → MySiteScreen-DLuHDXB1.cjs.map} +1 -1
- package/dist/{MySiteScreen-BT1PBPsH.mjs → MySiteScreen-VaOB-vWk.mjs} +2 -2
- package/dist/{MySiteScreen-BT1PBPsH.mjs.map → MySiteScreen-VaOB-vWk.mjs.map} +1 -1
- package/dist/{OrdersScreen-OFyr9Wz5.cjs → OrdersScreen-B7puF8He.cjs} +1 -1
- package/dist/{OrdersScreen-C-mM4q1d.mjs → OrdersScreen-CaNiwSih.mjs} +3 -14
- package/dist/OrdersScreen-CaNiwSih.mjs.map +1 -0
- package/dist/{OrdersScreen-BpfUvIio.cjs → OrdersScreen-tSpfcNlK.cjs} +3 -14
- package/dist/OrdersScreen-tSpfcNlK.cjs.map +1 -0
- package/dist/ProductsScreen-B8OynxlP.cjs +13 -0
- package/dist/{ProductsScreen-4WRrJcvw.mjs → ProductsScreen-CbVSNv1l.mjs} +3 -5
- package/dist/ProductsScreen-CbVSNv1l.mjs.map +1 -0
- package/dist/{ProductsScreen-BCs3YKVk.cjs → ProductsScreen-D1bw4ZIH.cjs} +3 -5
- package/dist/ProductsScreen-D1bw4ZIH.cjs.map +1 -0
- package/dist/ProductsScreen-Pq3j09nI.mjs +11 -0
- package/dist/{ProfileScreen-BgyrIQdL.mjs → ProfileScreen-BCHljkWD.mjs} +2 -2
- package/dist/{ProfileScreen-BgyrIQdL.mjs.map → ProfileScreen-BCHljkWD.mjs.map} +1 -1
- package/dist/{ProfileScreen-B0KNWXpV.cjs → ProfileScreen-Bf-lYNzz.cjs} +2 -2
- package/dist/{ProfileScreen-DLLLRNB2.cjs → ProfileScreen-ksdtbydb.cjs} +2 -2
- package/dist/{ProfileScreen-DLLLRNB2.cjs.map → ProfileScreen-ksdtbydb.cjs.map} +1 -1
- package/dist/{ShareablesScreen-ySSwCVSI.cjs → ShareablesScreen-6wgiwi_9.cjs} +3 -5
- package/dist/ShareablesScreen-6wgiwi_9.cjs.map +1 -0
- package/dist/{ShareablesScreen-B8cmh8JC.mjs → ShareablesScreen-BLCukNTk.mjs} +3 -5
- package/dist/{ShareablesScreen-B8cmh8JC.mjs.map → ShareablesScreen-BLCukNTk.mjs.map} +1 -1
- package/dist/ShareablesScreen-CM9OH-Nx.mjs +11 -0
- package/dist/ShareablesScreen-rmLcUhbL.cjs +13 -0
- package/dist/{ShopScreen-DhMo8bvP.cjs → ShopScreen-8KKwwjka.cjs} +3 -3
- package/dist/{ShopScreen-DhMo8bvP.cjs.map → ShopScreen-8KKwwjka.cjs.map} +1 -1
- package/dist/{ShopScreen-BkvyW0pE.cjs → ShopScreen-CjEbB3Q7.cjs} +2 -2
- package/dist/{ShopScreen-BFFGYwdV.mjs → ShopScreen-Dn5LwwYD.mjs} +3 -3
- package/dist/{ShopScreen-BFFGYwdV.mjs.map → ShopScreen-Dn5LwwYD.mjs.map} +1 -1
- package/dist/{SubscriptionsScreen-RScBCcY0.cjs → SubscriptionsScreen-B16wPAoA.cjs} +2 -2
- package/dist/SubscriptionsScreen-B16wPAoA.cjs.map +1 -0
- package/dist/{SubscriptionsScreen-CiNR7JUC.mjs → SubscriptionsScreen-B4cTlgDU.mjs} +2 -2
- package/dist/SubscriptionsScreen-B4cTlgDU.mjs.map +1 -0
- package/dist/{SubscriptionsScreen-DMh-GE6n.cjs → SubscriptionsScreen-nRUMdnx7.cjs} +1 -1
- package/dist/{dist-Bg8UyHyM.cjs → dist-lO2OG0T5.cjs} +1 -1
- package/dist/{dist-Bg8UyHyM.cjs.map → dist-lO2OG0T5.cjs.map} +1 -1
- package/dist/index.cjs +137 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +444 -655
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +444 -655
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +130 -133
- package/dist/index.mjs.map +1 -1
- package/dist/{sortable.esm-Cz-CP2N8.mjs → sortable.esm-DSrWP4x9.mjs} +1 -1
- package/dist/{sortable.esm-Cz-CP2N8.mjs.map → sortable.esm-DSrWP4x9.mjs.map} +1 -1
- package/dist/{use-portal-products-client-BmlUixy4.cjs → use-portal-products-client-BHSBT64s.cjs} +2 -2
- package/dist/use-portal-products-client-BHSBT64s.cjs.map +1 -0
- package/dist/{use-portal-products-client-DQK9nFxT.mjs → use-portal-products-client-tbqk6XUq.mjs} +2 -2
- package/dist/use-portal-products-client-tbqk6XUq.mjs.map +1 -0
- package/dist/{use-portal-shareables-api-KVPj0Jfr.mjs → use-portal-shareables-api-B9B4XTjw.mjs} +107 -201
- package/dist/use-portal-shareables-api-B9B4XTjw.mjs.map +1 -0
- package/dist/{use-portal-shareables-api-D5D6uIJy.cjs → use-portal-shareables-api-MBl0d0eQ.cjs} +106 -206
- package/dist/use-portal-shareables-api-MBl0d0eQ.cjs.map +1 -0
- package/package.json +12 -13
- package/dist/FluidProvider-Bc-3uN7M.cjs.map +0 -1
- package/dist/FluidProvider-Cqf2kmUc.mjs.map +0 -1
- package/dist/OrdersScreen-BpfUvIio.cjs.map +0 -1
- package/dist/OrdersScreen-C-mM4q1d.mjs.map +0 -1
- package/dist/ProductsScreen-4WRrJcvw.mjs.map +0 -1
- package/dist/ProductsScreen-BCs3YKVk.cjs.map +0 -1
- package/dist/ProductsScreen-BR9TN4So.cjs +0 -48
- package/dist/ProductsScreen-BwOjfcNL.mjs +0 -48
- package/dist/ShareablesScreen--j3RCHXe.mjs +0 -48
- package/dist/ShareablesScreen-DbPJOtCF.cjs +0 -48
- package/dist/ShareablesScreen-ySSwCVSI.cjs.map +0 -1
- package/dist/SubscriptionsScreen-CiNR7JUC.mjs.map +0 -1
- package/dist/SubscriptionsScreen-RScBCcY0.cjs.map +0 -1
- package/dist/use-portal-products-client-BmlUixy4.cjs.map +0 -1
- package/dist/use-portal-products-client-DQK9nFxT.mjs.map +0 -1
- package/dist/use-portal-shareables-api-D5D6uIJy.cjs.map +0 -1
- package/dist/use-portal-shareables-api-KVPj0Jfr.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -50,57 +50,6 @@ function App() {
|
|
|
50
50
|
|
|
51
51
|
## Hooks
|
|
52
52
|
|
|
53
|
-
### useFluidApi
|
|
54
|
-
|
|
55
|
-
Access the API client for making requests:
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
import { useFluidApi } from "@fluid-app/portal-sdk";
|
|
59
|
-
import { useQuery } from "@tanstack/react-query";
|
|
60
|
-
|
|
61
|
-
function ProductList() {
|
|
62
|
-
const api = useFluidApi();
|
|
63
|
-
|
|
64
|
-
const { data: products, isLoading } = useQuery({
|
|
65
|
-
queryKey: ["products"],
|
|
66
|
-
queryFn: () => api.products.list({ active: true }),
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
if (isLoading) return <Spinner />;
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<ul>
|
|
73
|
-
{products?.map((product) => (
|
|
74
|
-
<li key={product.id}>{product.name}</li>
|
|
75
|
-
))}
|
|
76
|
-
</ul>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### useCurrentRep
|
|
82
|
-
|
|
83
|
-
Fetch the currently authenticated rep's profile:
|
|
84
|
-
|
|
85
|
-
```tsx
|
|
86
|
-
import { useCurrentRep } from "@fluid-app/portal-sdk";
|
|
87
|
-
|
|
88
|
-
function RepHeader() {
|
|
89
|
-
const { data: rep, isLoading } = useCurrentRep();
|
|
90
|
-
|
|
91
|
-
if (isLoading) return <Skeleton />;
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<div>
|
|
95
|
-
<Avatar src={rep?.avatar_url} />
|
|
96
|
-
<span>
|
|
97
|
-
{rep?.first_name} {rep?.last_name}
|
|
98
|
-
</span>
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
```
|
|
103
|
-
|
|
104
53
|
### useFluidProfile
|
|
105
54
|
|
|
106
55
|
Fetch the portal profile (themes, navigation, screens):
|
|
@@ -123,33 +72,6 @@ function Navigation() {
|
|
|
123
72
|
}
|
|
124
73
|
```
|
|
125
74
|
|
|
126
|
-
### useFluidPermissions
|
|
127
|
-
|
|
128
|
-
Check user permissions with a convenient `can()` helper:
|
|
129
|
-
|
|
130
|
-
```tsx
|
|
131
|
-
import { useFluidPermissions } from "@fluid-app/portal-sdk";
|
|
132
|
-
|
|
133
|
-
function TeamSettings() {
|
|
134
|
-
const { can, isSuperAdmin } = useFluidPermissions();
|
|
135
|
-
|
|
136
|
-
// Check if user can manage team
|
|
137
|
-
if (!can("team", "manage")) {
|
|
138
|
-
return <AccessDenied />;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<div>
|
|
143
|
-
<h1>Team Settings</h1>
|
|
144
|
-
{/* Only show delete button if user has delete permission */}
|
|
145
|
-
{can("team", "delete") && <DeleteTeamButton />}
|
|
146
|
-
</div>
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Available permission actions: `"view"`, `"create"`, `"update"`, `"delete"`, `"settings"`, `"add"`, `"manage"`, `"send"`
|
|
152
|
-
|
|
153
75
|
### useFluidTheme
|
|
154
76
|
|
|
155
77
|
Control theme settings:
|
|
@@ -185,95 +107,6 @@ function ThemeSwitcher({ themes }: { themes: Theme[] }) {
|
|
|
185
107
|
}
|
|
186
108
|
```
|
|
187
109
|
|
|
188
|
-
## API Client
|
|
189
|
-
|
|
190
|
-
The SDK provides a typed API client with methods for common operations:
|
|
191
|
-
|
|
192
|
-
### Products
|
|
193
|
-
|
|
194
|
-
```tsx
|
|
195
|
-
const api = useFluidApi();
|
|
196
|
-
|
|
197
|
-
// List products with optional filters
|
|
198
|
-
const products = await api.products.list({
|
|
199
|
-
active: true,
|
|
200
|
-
page: 1,
|
|
201
|
-
per_page: 20,
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
// Get a single product
|
|
205
|
-
const product = await api.products.get("product-id");
|
|
206
|
-
|
|
207
|
-
// Search products
|
|
208
|
-
const results = await api.products.search("query");
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Orders
|
|
212
|
-
|
|
213
|
-
```tsx
|
|
214
|
-
const api = useFluidApi();
|
|
215
|
-
|
|
216
|
-
// List orders
|
|
217
|
-
const orders = await api.orders.list({
|
|
218
|
-
status: "pending",
|
|
219
|
-
date_from: "2024-01-01",
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// Get a single order
|
|
223
|
-
const order = await api.orders.get("order-id");
|
|
224
|
-
|
|
225
|
-
// Create an order
|
|
226
|
-
const newOrder = await api.orders.create({
|
|
227
|
-
customer_id: "customer-id",
|
|
228
|
-
line_items: [{ product_id: "product-id", quantity: 2 }],
|
|
229
|
-
});
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Reps
|
|
233
|
-
|
|
234
|
-
```tsx
|
|
235
|
-
const api = useFluidApi();
|
|
236
|
-
|
|
237
|
-
// Get current rep profile
|
|
238
|
-
const rep = await api.reps.current();
|
|
239
|
-
|
|
240
|
-
// Update profile
|
|
241
|
-
const updated = await api.reps.updateProfile({
|
|
242
|
-
first_name: "John",
|
|
243
|
-
last_name: "Doe",
|
|
244
|
-
});
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### Analytics
|
|
248
|
-
|
|
249
|
-
```tsx
|
|
250
|
-
const api = useFluidApi();
|
|
251
|
-
|
|
252
|
-
// Get dashboard data
|
|
253
|
-
const dashboard = await api.analytics.dashboard();
|
|
254
|
-
|
|
255
|
-
// Get sales data
|
|
256
|
-
const sales = await api.analytics.sales({
|
|
257
|
-
date_from: "2024-01-01",
|
|
258
|
-
date_to: "2024-12-31",
|
|
259
|
-
group_by: "month",
|
|
260
|
-
});
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
### Custom Requests
|
|
264
|
-
|
|
265
|
-
For endpoints not covered by the typed methods:
|
|
266
|
-
|
|
267
|
-
```tsx
|
|
268
|
-
const api = useFluidApi();
|
|
269
|
-
|
|
270
|
-
// Generic GET request
|
|
271
|
-
const data = await api.get<MyType>("/custom/endpoint", { param: "value" });
|
|
272
|
-
|
|
273
|
-
// Generic POST request
|
|
274
|
-
const result = await api.post<MyType>("/custom/endpoint", { body: "data" });
|
|
275
|
-
```
|
|
276
|
-
|
|
277
110
|
## Providers
|
|
278
111
|
|
|
279
112
|
### FluidProvider
|
|
@@ -336,35 +169,12 @@ All types are exported for use in your application:
|
|
|
336
169
|
import type {
|
|
337
170
|
// Core types
|
|
338
171
|
Profile,
|
|
339
|
-
Theme,
|
|
340
|
-
ThemeConfig,
|
|
341
172
|
Navigation,
|
|
342
173
|
NavigationItem,
|
|
343
174
|
ScreenDefinition,
|
|
344
175
|
|
|
345
|
-
// Permissions
|
|
346
|
-
UserPermissions,
|
|
347
|
-
Permissions,
|
|
348
|
-
PermissionAction,
|
|
349
|
-
ResourcePermissions,
|
|
350
|
-
|
|
351
|
-
// Rep
|
|
352
|
-
Rep,
|
|
353
|
-
UpdateRepData,
|
|
354
|
-
|
|
355
|
-
// API types
|
|
356
|
-
Product,
|
|
357
|
-
ProductListParams,
|
|
358
|
-
Order,
|
|
359
|
-
OrderListParams,
|
|
360
|
-
CreateOrderData,
|
|
361
|
-
DashboardData,
|
|
362
|
-
SalesData,
|
|
363
|
-
SalesParams,
|
|
364
|
-
|
|
365
176
|
// Client types
|
|
366
177
|
FluidSDKConfig,
|
|
367
|
-
FluidClient,
|
|
368
178
|
RequestOptions,
|
|
369
179
|
} from "@fluid-app/portal-sdk";
|
|
370
180
|
```
|
|
@@ -374,11 +184,7 @@ import type {
|
|
|
374
184
|
Query keys are exported for cache invalidation and prefetching:
|
|
375
185
|
|
|
376
186
|
```tsx
|
|
377
|
-
import {
|
|
378
|
-
PROFILE_QUERY_KEY,
|
|
379
|
-
PERMISSIONS_QUERY_KEY,
|
|
380
|
-
CURRENT_REP_QUERY_KEY,
|
|
381
|
-
} from "@fluid-app/portal-sdk";
|
|
187
|
+
import { PROFILE_QUERY_KEY } from "@fluid-app/portal-sdk";
|
|
382
188
|
import { useQueryClient } from "@tanstack/react-query";
|
|
383
189
|
|
|
384
190
|
function RefreshButton() {
|
|
@@ -400,7 +206,7 @@ The SDK provides an `ApiError` class for structured error handling:
|
|
|
400
206
|
import { ApiError, isApiError } from "@fluid-app/portal-sdk";
|
|
401
207
|
|
|
402
208
|
try {
|
|
403
|
-
await
|
|
209
|
+
await someApiCall();
|
|
404
210
|
} catch (error) {
|
|
405
211
|
if (isApiError(error)) {
|
|
406
212
|
console.log("Status:", error.status);
|