@fonderie/react-billing 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +88 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -22
- package/dist/index.d.ts +13 -22
- package/dist/index.js +83 -127
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -20,18 +20,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
FonderieApiError: () =>
|
|
23
|
+
FonderieApiError: () => import_client8.FonderieApiError,
|
|
24
24
|
useBillingPortal: () => useBillingPortal,
|
|
25
25
|
useCheckout: () => useCheckout,
|
|
26
26
|
usePlan: () => usePlan,
|
|
27
|
-
usePlanAdmin: () => usePlanAdmin,
|
|
28
27
|
usePlans: () => usePlans,
|
|
29
|
-
useRecordUsage: () => useRecordUsage,
|
|
30
28
|
useSubscription: () => useSubscription,
|
|
31
|
-
useUsage: () => useUsage
|
|
29
|
+
useUsage: () => useUsage,
|
|
30
|
+
useWalletPreferences: () => useWalletPreferences
|
|
32
31
|
});
|
|
33
32
|
module.exports = __toCommonJS(index_exports);
|
|
34
|
-
var
|
|
33
|
+
var import_client8 = require("@fonderie/client");
|
|
35
34
|
|
|
36
35
|
// src/hooks/useBillingPortal.ts
|
|
37
36
|
var import_client = require("@fonderie/client");
|
|
@@ -120,77 +119,16 @@ function usePlan(clientOrPlanId, maybePlanId) {
|
|
|
120
119
|
return { plan, isLoading, error, refresh };
|
|
121
120
|
}
|
|
122
121
|
|
|
123
|
-
// src/hooks/
|
|
122
|
+
// src/hooks/usePlans.ts
|
|
124
123
|
var import_client4 = require("@fonderie/client");
|
|
125
124
|
var import_react7 = require("@fonderie/react");
|
|
126
125
|
var import_react8 = require("react");
|
|
127
|
-
function usePlanAdmin(client) {
|
|
128
|
-
const billing = (0, import_react7.useFonderieSubClient)(client, (c) => c.billing, "usePlanAdmin");
|
|
129
|
-
const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
|
|
130
|
-
const [error, setError] = (0, import_react8.useState)(null);
|
|
131
|
-
const createPlan = (0, import_react8.useCallback)(
|
|
132
|
-
async (input) => {
|
|
133
|
-
setIsLoading(true);
|
|
134
|
-
setError(null);
|
|
135
|
-
try {
|
|
136
|
-
const { result } = await billing.createPlan(input);
|
|
137
|
-
return result.plan;
|
|
138
|
-
} catch (err) {
|
|
139
|
-
const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
|
|
140
|
-
setError(apiError);
|
|
141
|
-
throw apiError;
|
|
142
|
-
} finally {
|
|
143
|
-
setIsLoading(false);
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
[billing]
|
|
147
|
-
);
|
|
148
|
-
const updatePlan = (0, import_react8.useCallback)(
|
|
149
|
-
async (planId, input) => {
|
|
150
|
-
setIsLoading(true);
|
|
151
|
-
setError(null);
|
|
152
|
-
try {
|
|
153
|
-
const { result } = await billing.updatePlan(planId, input);
|
|
154
|
-
return result.plan;
|
|
155
|
-
} catch (err) {
|
|
156
|
-
const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
|
|
157
|
-
setError(apiError);
|
|
158
|
-
throw apiError;
|
|
159
|
-
} finally {
|
|
160
|
-
setIsLoading(false);
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
[billing]
|
|
164
|
-
);
|
|
165
|
-
const deletePlan = (0, import_react8.useCallback)(
|
|
166
|
-
async (planId) => {
|
|
167
|
-
setIsLoading(true);
|
|
168
|
-
setError(null);
|
|
169
|
-
try {
|
|
170
|
-
await billing.deletePlan(planId);
|
|
171
|
-
} catch (err) {
|
|
172
|
-
const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
|
|
173
|
-
setError(apiError);
|
|
174
|
-
throw apiError;
|
|
175
|
-
} finally {
|
|
176
|
-
setIsLoading(false);
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
[billing]
|
|
180
|
-
);
|
|
181
|
-
return { createPlan, updatePlan, deletePlan, isLoading, error };
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// src/hooks/usePlans.ts
|
|
185
|
-
var import_client5 = require("@fonderie/client");
|
|
186
|
-
var import_react9 = require("@fonderie/react");
|
|
187
|
-
var import_react10 = require("react");
|
|
188
126
|
function usePlans(client) {
|
|
189
|
-
const billing = (0,
|
|
190
|
-
const [plans, setPlans] = (0,
|
|
191
|
-
const [isLoading, setIsLoading] = (0,
|
|
192
|
-
const [error, setError] = (0,
|
|
193
|
-
const refresh = (0,
|
|
127
|
+
const billing = (0, import_react7.useFonderieSubClient)(client, (c) => c.billing, "usePlans");
|
|
128
|
+
const [plans, setPlans] = (0, import_react8.useState)([]);
|
|
129
|
+
const [isLoading, setIsLoading] = (0, import_react8.useState)(true);
|
|
130
|
+
const [error, setError] = (0, import_react8.useState)(null);
|
|
131
|
+
const refresh = (0, import_react8.useCallback)(
|
|
194
132
|
async (opts) => {
|
|
195
133
|
setIsLoading(true);
|
|
196
134
|
setError(null);
|
|
@@ -198,7 +136,7 @@ function usePlans(client) {
|
|
|
198
136
|
const { result } = await billing.listPlans({ bust: opts?.force });
|
|
199
137
|
setPlans(result.plans);
|
|
200
138
|
} catch (err) {
|
|
201
|
-
const apiError = err instanceof
|
|
139
|
+
const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
|
|
202
140
|
setError(apiError);
|
|
203
141
|
} finally {
|
|
204
142
|
setIsLoading(false);
|
|
@@ -206,7 +144,7 @@ function usePlans(client) {
|
|
|
206
144
|
},
|
|
207
145
|
[billing]
|
|
208
146
|
);
|
|
209
|
-
const createPlan = (0,
|
|
147
|
+
const createPlan = (0, import_react8.useCallback)(
|
|
210
148
|
async (input) => {
|
|
211
149
|
setError(null);
|
|
212
150
|
try {
|
|
@@ -214,14 +152,14 @@ function usePlans(client) {
|
|
|
214
152
|
await refresh();
|
|
215
153
|
return result.plan;
|
|
216
154
|
} catch (err) {
|
|
217
|
-
const apiError = err instanceof
|
|
155
|
+
const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
|
|
218
156
|
setError(apiError);
|
|
219
157
|
throw apiError;
|
|
220
158
|
}
|
|
221
159
|
},
|
|
222
160
|
[billing, refresh]
|
|
223
161
|
);
|
|
224
|
-
const updatePlan = (0,
|
|
162
|
+
const updatePlan = (0, import_react8.useCallback)(
|
|
225
163
|
async (planId, input) => {
|
|
226
164
|
setError(null);
|
|
227
165
|
try {
|
|
@@ -229,70 +167,43 @@ function usePlans(client) {
|
|
|
229
167
|
await refresh();
|
|
230
168
|
return result.plan;
|
|
231
169
|
} catch (err) {
|
|
232
|
-
const apiError = err instanceof
|
|
170
|
+
const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
|
|
233
171
|
setError(apiError);
|
|
234
172
|
throw apiError;
|
|
235
173
|
}
|
|
236
174
|
},
|
|
237
175
|
[billing, refresh]
|
|
238
176
|
);
|
|
239
|
-
const deletePlan = (0,
|
|
177
|
+
const deletePlan = (0, import_react8.useCallback)(
|
|
240
178
|
async (planId) => {
|
|
241
179
|
setError(null);
|
|
242
180
|
try {
|
|
243
181
|
await billing.deletePlan(planId);
|
|
244
182
|
await refresh();
|
|
245
183
|
} catch (err) {
|
|
246
|
-
const apiError = err instanceof
|
|
184
|
+
const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
|
|
247
185
|
setError(apiError);
|
|
248
186
|
throw apiError;
|
|
249
187
|
}
|
|
250
188
|
},
|
|
251
189
|
[billing, refresh]
|
|
252
190
|
);
|
|
253
|
-
(0,
|
|
191
|
+
(0, import_react8.useEffect)(() => {
|
|
254
192
|
void refresh();
|
|
255
193
|
}, [refresh]);
|
|
256
194
|
return { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };
|
|
257
195
|
}
|
|
258
196
|
|
|
259
|
-
// src/hooks/useRecordUsage.ts
|
|
260
|
-
var import_client6 = require("@fonderie/client");
|
|
261
|
-
var import_react11 = require("@fonderie/react");
|
|
262
|
-
var import_react12 = require("react");
|
|
263
|
-
function useRecordUsage(client) {
|
|
264
|
-
const billing = (0, import_react11.useFonderieSubClient)(client, (c) => c.billing, "useRecordUsage");
|
|
265
|
-
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
266
|
-
const [error, setError] = (0, import_react12.useState)(null);
|
|
267
|
-
const recordUsage = (0, import_react12.useCallback)(
|
|
268
|
-
async (input) => {
|
|
269
|
-
setIsLoading(true);
|
|
270
|
-
setError(null);
|
|
271
|
-
try {
|
|
272
|
-
await billing.recordUsage(input);
|
|
273
|
-
} catch (err) {
|
|
274
|
-
const apiError = err instanceof import_client6.FonderieApiError ? err : new import_client6.FonderieApiError("unknown", String(err), 0);
|
|
275
|
-
setError(apiError);
|
|
276
|
-
throw apiError;
|
|
277
|
-
} finally {
|
|
278
|
-
setIsLoading(false);
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
[billing]
|
|
282
|
-
);
|
|
283
|
-
return { recordUsage, isLoading, error };
|
|
284
|
-
}
|
|
285
|
-
|
|
286
197
|
// src/hooks/useSubscription.ts
|
|
287
|
-
var
|
|
288
|
-
var
|
|
289
|
-
var
|
|
198
|
+
var import_client5 = require("@fonderie/client");
|
|
199
|
+
var import_react9 = require("@fonderie/react");
|
|
200
|
+
var import_react10 = require("react");
|
|
290
201
|
function useSubscription(client) {
|
|
291
|
-
const billing = (0,
|
|
292
|
-
const [subscription, setSubscription] = (0,
|
|
293
|
-
const [isLoading, setIsLoading] = (0,
|
|
294
|
-
const [error, setError] = (0,
|
|
295
|
-
const refresh = (0,
|
|
202
|
+
const billing = (0, import_react9.useFonderieSubClient)(client, (c) => c.billing, "useSubscription");
|
|
203
|
+
const [subscription, setSubscription] = (0, import_react10.useState)(null);
|
|
204
|
+
const [isLoading, setIsLoading] = (0, import_react10.useState)(true);
|
|
205
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
206
|
+
const refresh = (0, import_react10.useCallback)(
|
|
296
207
|
async (opts) => {
|
|
297
208
|
setIsLoading(true);
|
|
298
209
|
setError(null);
|
|
@@ -300,7 +211,7 @@ function useSubscription(client) {
|
|
|
300
211
|
const { result } = await billing.getSubscription({ bust: opts?.force });
|
|
301
212
|
setSubscription(result.subscription);
|
|
302
213
|
} catch (err) {
|
|
303
|
-
const apiError = err instanceof
|
|
214
|
+
const apiError = err instanceof import_client5.FonderieApiError ? err : new import_client5.FonderieApiError("unknown", String(err), 0);
|
|
304
215
|
if (apiError.status !== 404) setError(apiError);
|
|
305
216
|
setSubscription(null);
|
|
306
217
|
} finally {
|
|
@@ -309,25 +220,25 @@ function useSubscription(client) {
|
|
|
309
220
|
},
|
|
310
221
|
[billing]
|
|
311
222
|
);
|
|
312
|
-
(0,
|
|
223
|
+
(0, import_react10.useEffect)(() => {
|
|
313
224
|
void refresh();
|
|
314
225
|
}, [refresh]);
|
|
315
226
|
return { subscription, isLoading, error, refresh };
|
|
316
227
|
}
|
|
317
228
|
|
|
318
229
|
// src/hooks/useUsage.ts
|
|
319
|
-
var
|
|
320
|
-
var
|
|
321
|
-
var
|
|
230
|
+
var import_client6 = require("@fonderie/client");
|
|
231
|
+
var import_react11 = require("@fonderie/react");
|
|
232
|
+
var import_react12 = require("react");
|
|
322
233
|
function useUsage(clientOrMetric, maybeMetric) {
|
|
323
|
-
const firstIsClient = clientOrMetric === void 0 || clientOrMetric instanceof
|
|
234
|
+
const firstIsClient = clientOrMetric === void 0 || clientOrMetric instanceof import_client6.BillingClient;
|
|
324
235
|
const explicit = firstIsClient ? clientOrMetric : void 0;
|
|
325
236
|
const metric = firstIsClient ? maybeMetric : clientOrMetric;
|
|
326
|
-
const billing = (0,
|
|
327
|
-
const [total, setTotal] = (0,
|
|
328
|
-
const [isLoading, setIsLoading] = (0,
|
|
329
|
-
const [error, setError] = (0,
|
|
330
|
-
const refresh = (0,
|
|
237
|
+
const billing = (0, import_react11.useFonderieSubClient)(explicit, (c) => c.billing, "useUsage");
|
|
238
|
+
const [total, setTotal] = (0, import_react12.useState)(null);
|
|
239
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(true);
|
|
240
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
241
|
+
const refresh = (0, import_react12.useCallback)(
|
|
331
242
|
async (opts) => {
|
|
332
243
|
setIsLoading(true);
|
|
333
244
|
setError(null);
|
|
@@ -335,7 +246,7 @@ function useUsage(clientOrMetric, maybeMetric) {
|
|
|
335
246
|
const { result } = await billing.getUsage(metric, { bust: opts?.force });
|
|
336
247
|
setTotal(result.total);
|
|
337
248
|
} catch (err) {
|
|
338
|
-
const apiError = err instanceof
|
|
249
|
+
const apiError = err instanceof import_client6.FonderieApiError ? err : new import_client6.FonderieApiError("unknown", String(err), 0);
|
|
339
250
|
setError(apiError);
|
|
340
251
|
} finally {
|
|
341
252
|
setIsLoading(false);
|
|
@@ -343,35 +254,79 @@ function useUsage(clientOrMetric, maybeMetric) {
|
|
|
343
254
|
},
|
|
344
255
|
[billing, metric]
|
|
345
256
|
);
|
|
346
|
-
const recordUsage = (0,
|
|
257
|
+
const recordUsage = (0, import_react12.useCallback)(
|
|
347
258
|
async (input) => {
|
|
348
259
|
setError(null);
|
|
349
260
|
try {
|
|
350
261
|
await billing.recordUsage(input);
|
|
351
262
|
await refresh();
|
|
352
263
|
} catch (err) {
|
|
353
|
-
const apiError = err instanceof
|
|
264
|
+
const apiError = err instanceof import_client6.FonderieApiError ? err : new import_client6.FonderieApiError("unknown", String(err), 0);
|
|
354
265
|
setError(apiError);
|
|
355
266
|
throw apiError;
|
|
356
267
|
}
|
|
357
268
|
},
|
|
358
269
|
[billing, refresh]
|
|
359
270
|
);
|
|
360
|
-
(0,
|
|
271
|
+
(0, import_react12.useEffect)(() => {
|
|
361
272
|
void refresh();
|
|
362
273
|
}, [refresh]);
|
|
363
274
|
return { total, isLoading, error, refresh, recordUsage };
|
|
364
275
|
}
|
|
276
|
+
|
|
277
|
+
// src/hooks/useWalletPreferences.ts
|
|
278
|
+
var import_client7 = require("@fonderie/client");
|
|
279
|
+
var import_react13 = require("@fonderie/react");
|
|
280
|
+
var import_react14 = require("react");
|
|
281
|
+
function useWalletPreferences(client) {
|
|
282
|
+
const billing = (0, import_react13.useFonderieSubClient)(client, (c) => c.billing, "useWalletPreferences");
|
|
283
|
+
const [spendPurchased, setSpend] = (0, import_react14.useState)(null);
|
|
284
|
+
const [isLoading, setIsLoading] = (0, import_react14.useState)(true);
|
|
285
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
286
|
+
const refresh = (0, import_react14.useCallback)(
|
|
287
|
+
async (opts) => {
|
|
288
|
+
setIsLoading(true);
|
|
289
|
+
setError(null);
|
|
290
|
+
try {
|
|
291
|
+
const { result } = await billing.getWallet({ bust: opts?.force });
|
|
292
|
+
setSpend(result.wallet.spendPurchased ?? true);
|
|
293
|
+
} catch (err) {
|
|
294
|
+
const apiError = err instanceof import_client7.FonderieApiError ? err : new import_client7.FonderieApiError("unknown", String(err), 0);
|
|
295
|
+
setError(apiError);
|
|
296
|
+
} finally {
|
|
297
|
+
setIsLoading(false);
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
[billing]
|
|
301
|
+
);
|
|
302
|
+
const setSpendPurchased = (0, import_react14.useCallback)(
|
|
303
|
+
async (next) => {
|
|
304
|
+
setError(null);
|
|
305
|
+
try {
|
|
306
|
+
const { result } = await billing.setWalletPreferences({ spendPurchased: next });
|
|
307
|
+
setSpend(result.wallet.spendPurchased ?? next);
|
|
308
|
+
} catch (err) {
|
|
309
|
+
const apiError = err instanceof import_client7.FonderieApiError ? err : new import_client7.FonderieApiError("unknown", String(err), 0);
|
|
310
|
+
setError(apiError);
|
|
311
|
+
throw apiError;
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
[billing]
|
|
315
|
+
);
|
|
316
|
+
(0, import_react14.useEffect)(() => {
|
|
317
|
+
void refresh();
|
|
318
|
+
}, [refresh]);
|
|
319
|
+
return { spendPurchased, isLoading, error, refresh, setSpendPurchased };
|
|
320
|
+
}
|
|
365
321
|
// Annotate the CommonJS export names for ESM import in node:
|
|
366
322
|
0 && (module.exports = {
|
|
367
323
|
FonderieApiError,
|
|
368
324
|
useBillingPortal,
|
|
369
325
|
useCheckout,
|
|
370
326
|
usePlan,
|
|
371
|
-
usePlanAdmin,
|
|
372
327
|
usePlans,
|
|
373
|
-
useRecordUsage,
|
|
374
328
|
useSubscription,
|
|
375
|
-
useUsage
|
|
329
|
+
useUsage,
|
|
330
|
+
useWalletPreferences
|
|
376
331
|
});
|
|
377
332
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/hooks/useBillingPortal.ts","../src/hooks/useCheckout.ts","../src/hooks/usePlan.ts","../src/hooks/usePlanAdmin.ts","../src/hooks/usePlans.ts","../src/hooks/useRecordUsage.ts","../src/hooks/useSubscription.ts","../src/hooks/useUsage.ts"],"sourcesContent":["export type {\n\tBillingClient,\n\tICheckoutInput,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIPlanFeature,\n\tIRecordUsageInput,\n\tISubscriptionDTO,\n\tIUpdatePlanInput,\n\tSubscriberType,\n} from '@fonderie/client';\nexport { FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseBillingPortalReturn,\n\tIUseCheckoutReturn,\n\tIUsePlanAdminReturn,\n\tIUsePlanReturn,\n\tIUsePlansReturn,\n\tIUseRecordUsageReturn,\n\tIUseSubscriptionReturn,\n\tIUseUsageReturn,\n} from './hooks';\nexport {\n\tuseBillingPortal,\n\tuseCheckout,\n\tusePlan,\n\tusePlanAdmin,\n\tusePlans,\n\tuseRecordUsage,\n\tuseSubscription,\n\tuseUsage,\n} from './hooks';\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseBillingPortalReturn {\n\topenPortal: () => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useBillingPortal(client?: BillingClient): IUseBillingPortalReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useBillingPortal');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst openPortal = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.createPortalSession();\n\t\t\treturn result.url;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { openPortal, isLoading, error };\n}\n","import type { BillingClient, ICheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCheckoutReturn {\n\tcheckout: (input: ICheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCheckout(client?: BillingClient): IUseCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: ICheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createCheckoutSession(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type { IPlanDTO } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlanReturn {\n\tplan: IPlanDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function usePlan(planId: string): IUsePlanReturn;\nexport function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;\nexport function usePlan(\n\tclientOrPlanId: BillingClient | string | undefined,\n\tmaybePlanId?: string,\n): IUsePlanReturn {\n\tconst firstIsClient = clientOrPlanId === undefined || clientOrPlanId instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrPlanId as BillingClient | undefined) : undefined;\n\tconst planId = firstIsClient ? (maybePlanId as string) : clientOrPlanId;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'usePlan');\n\tconst [plan, setPlan] = useState<IPlanDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPlan(planId, { bust: opts?.force });\n\t\t\t\tsetPlan(result.plan);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, planId],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plan, isLoading, error, refresh };\n}\n","import type { BillingClient, ICreatePlanInput, IPlanDTO, IUpdatePlanInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\n/** @deprecated Use `usePlans().createPlan` / `updatePlan` / `deletePlan` instead — the list hook self-refreshes after each write. */\nexport interface IUsePlanAdminReturn {\n\tcreatePlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;\n\tupdatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;\n\tdeletePlan: (planId: string) => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\n// Action-only, like useUpdateRole/useWorkspaceProfile — pair with usePlans()\n// for the list and call its refresh() after a write.\n//\n// Unlike every other write in this SDK, @fonderie/billing does not gate\n// createPlan/updatePlan/deletePlan with requireAuth or an admin token — the\n// server trusts the caller to authorize access itself. Gate the UI that\n// calls this hook behind your own admin check before shipping it.\n/** @deprecated Use `usePlans().createPlan` / `updatePlan` / `deletePlan` instead — the list hook self-refreshes after each write. */\nexport function usePlanAdmin(client?: BillingClient): IUsePlanAdminReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePlanAdmin');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst createPlan = useCallback(\n\t\tasync (input: ICreatePlanInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createPlan(input);\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst updatePlan = useCallback(\n\t\tasync (planId: string, input: IUpdatePlanInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.updatePlan(planId, input);\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst deletePlan = useCallback(\n\t\tasync (planId: string) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.deletePlan(planId);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { createPlan, updatePlan, deletePlan, isLoading, error };\n}\n","import type {\n\tBillingClient,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIUpdatePlanInput,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlansReturn {\n\tplans: IPlanDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tcreatePlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;\n\tupdatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;\n\tdeletePlan: (planId: string) => Promise<void>;\n}\n\nexport function usePlans(client?: BillingClient): IUsePlansReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePlans');\n\tconst [plans, setPlans] = useState<IPlanDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listPlans({ bust: opts?.force });\n\t\t\t\tsetPlans(result.plans);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\t// Like usePlanAdmin, these writes are not auth-gated by @fonderie/billing —\n\t// gate the UI that calls them behind your own admin check before shipping it.\n\tconst createPlan = useCallback(\n\t\tasync (input: ICreatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createPlan(input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst updatePlan = useCallback(\n\t\tasync (planId: string, input: IUpdatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.updatePlan(planId, input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst deletePlan = useCallback(\n\t\tasync (planId: string) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.deletePlan(planId);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };\n}\n","import type { BillingClient, IRecordUsageInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\n/** @deprecated Use `useUsage(metric).recordUsage` instead — the usage hook self-refreshes after the write. */\nexport interface IUseRecordUsageReturn {\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\n/** @deprecated Use `useUsage(metric).recordUsage` instead — the usage hook self-refreshes after the write. */\nexport function useRecordUsage(client?: BillingClient): IUseRecordUsageReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useRecordUsage');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst recordUsage = useCallback(\n\t\tasync (input: IRecordUsageInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.recordUsage(input);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { recordUsage, isLoading, error };\n}\n","import type { BillingClient, ISubscriptionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseSubscriptionReturn {\n\tsubscription: ISubscriptionDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function useSubscription(client?: BillingClient): IUseSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSubscription');\n\tconst [subscription, setSubscription] = useState<ISubscriptionDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getSubscription({ bust: opts?.force });\n\t\t\t\tsetSubscription(result.subscription);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// No active subscription is a normal, expected state — not an error banner.\n\t\t\t\tif (apiError.status !== 404) setError(apiError);\n\t\t\t\tsetSubscription(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { subscription, isLoading, error, refresh };\n}\n","import type { IRecordUsageInput } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseUsageReturn {\n\ttotal: number | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n}\n\nexport function useUsage(metric: string): IUseUsageReturn;\nexport function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;\nexport function useUsage(\n\tclientOrMetric: BillingClient | string | undefined,\n\tmaybeMetric?: string,\n): IUseUsageReturn {\n\tconst firstIsClient = clientOrMetric === undefined || clientOrMetric instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrMetric as BillingClient | undefined) : undefined;\n\tconst metric = firstIsClient ? (maybeMetric as string) : clientOrMetric;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'useUsage');\n\tconst [total, setTotal] = useState<number | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getUsage(metric, { bust: opts?.force });\n\t\t\t\tsetTotal(result.total);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, metric],\n\t);\n\n\tconst recordUsage = useCallback(\n\t\tasync (input: IRecordUsageInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.recordUsage(input);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { total, isLoading, error, refresh, recordUsage };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,IAAAA,iBAAiC;;;ACVjC,oBAAiC;AACjC,mBAAqC;AACrC,IAAAC,gBAAsC;AAQ/B,SAAS,iBAAiB,QAAiD;AACjF,QAAM,cAAU,mCAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB;AACjF,QAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAkC,IAAI;AAEhE,QAAM,iBAAa,2BAAY,YAAY;AAC1C,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,QAAQ,oBAAoB;AACrD,aAAO,OAAO;AAAA,IACf,SAAS,KAAK;AACb,YAAM,WACL,eAAe,iCAAmB,MAAM,IAAI,+BAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AACjB,YAAM;AAAA,IACP,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,YAAY,WAAW,MAAM;AACvC;;;AChCA,IAAAC,iBAAiC;AACjC,IAAAC,gBAAqC;AACrC,IAAAA,gBAAsC;AAQ/B,SAAS,YAAY,QAA4C;AACvE,QAAM,cAAU,oCAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa;AAC5E,QAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAk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;AACb,cAAM,WACL,eAAe,kCAAmB,MAAM,IAAI,gCAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AACjB,cAAM;AAAA,MACP;AAAA,IACD;AAAA,IACA,CAAC,SAAS,OAAO;AAAA,EAClB;AAEA,gCAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,OAAO,WAAW,OAAO,SAAS,YAAY;AACxD;","names":["import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/hooks/useBillingPortal.ts","../src/hooks/useCheckout.ts","../src/hooks/usePlan.ts","../src/hooks/usePlans.ts","../src/hooks/useSubscription.ts","../src/hooks/useUsage.ts","../src/hooks/useWalletPreferences.ts"],"sourcesContent":["export type {\n\tBillingClient,\n\tICheckoutInput,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIPlanFeature,\n\tIRecordUsageInput,\n\tISubscriptionDTO,\n\tIUpdatePlanInput,\n\tSubscriberType,\n} from '@fonderie/client';\nexport { FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseBillingPortalReturn,\n\tIUseCheckoutReturn,\n\tIUsePlanReturn,\n\tIUsePlansReturn,\n\tIUseSubscriptionReturn,\n\tIUseUsageReturn,\n\tIUseWalletPreferencesReturn,\n} from './hooks';\nexport {\n\tuseBillingPortal,\n\tuseCheckout,\n\tusePlan,\n\tusePlans,\n\tuseSubscription,\n\tuseUsage,\n\tuseWalletPreferences,\n} from './hooks';\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseBillingPortalReturn {\n\topenPortal: () => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useBillingPortal(client?: BillingClient): IUseBillingPortalReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useBillingPortal');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst openPortal = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.createPortalSession();\n\t\t\treturn result.url;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { openPortal, isLoading, error };\n}\n","import type { BillingClient, ICheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCheckoutReturn {\n\tcheckout: (input: ICheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCheckout(client?: BillingClient): IUseCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: ICheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createCheckoutSession(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type { IPlanDTO } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlanReturn {\n\tplan: IPlanDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function usePlan(planId: string): IUsePlanReturn;\nexport function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;\nexport function usePlan(\n\tclientOrPlanId: BillingClient | string | undefined,\n\tmaybePlanId?: string,\n): IUsePlanReturn {\n\tconst firstIsClient = clientOrPlanId === undefined || clientOrPlanId instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrPlanId as BillingClient | undefined) : undefined;\n\tconst planId = firstIsClient ? (maybePlanId as string) : clientOrPlanId;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'usePlan');\n\tconst [plan, setPlan] = useState<IPlanDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPlan(planId, { bust: opts?.force });\n\t\t\t\tsetPlan(result.plan);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, planId],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plan, isLoading, error, refresh };\n}\n","import type {\n\tBillingClient,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIUpdatePlanInput,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlansReturn {\n\tplans: IPlanDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tcreatePlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;\n\tupdatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;\n\tdeletePlan: (planId: string) => Promise<void>;\n}\n\nexport function usePlans(client?: BillingClient): IUsePlansReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePlans');\n\tconst [plans, setPlans] = useState<IPlanDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listPlans({ bust: opts?.force });\n\t\t\t\tsetPlans(result.plans);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\t// These writes are not auth-gated by @fonderie/billing —\n\t// gate the UI that calls them behind your own admin check before shipping it.\n\tconst createPlan = useCallback(\n\t\tasync (input: ICreatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createPlan(input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst updatePlan = useCallback(\n\t\tasync (planId: string, input: IUpdatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.updatePlan(planId, input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst deletePlan = useCallback(\n\t\tasync (planId: string) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.deletePlan(planId);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };\n}\n","import type { BillingClient, ISubscriptionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseSubscriptionReturn {\n\tsubscription: ISubscriptionDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function useSubscription(client?: BillingClient): IUseSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSubscription');\n\tconst [subscription, setSubscription] = useState<ISubscriptionDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getSubscription({ bust: opts?.force });\n\t\t\t\tsetSubscription(result.subscription);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// No active subscription is a normal, expected state — not an error banner.\n\t\t\t\tif (apiError.status !== 404) setError(apiError);\n\t\t\t\tsetSubscription(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { subscription, isLoading, error, refresh };\n}\n","import type { IRecordUsageInput } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseUsageReturn {\n\ttotal: number | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n}\n\nexport function useUsage(metric: string): IUseUsageReturn;\nexport function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;\nexport function useUsage(\n\tclientOrMetric: BillingClient | string | undefined,\n\tmaybeMetric?: string,\n): IUseUsageReturn {\n\tconst firstIsClient = clientOrMetric === undefined || clientOrMetric instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrMetric as BillingClient | undefined) : undefined;\n\tconst metric = firstIsClient ? (maybeMetric as string) : clientOrMetric;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'useUsage');\n\tconst [total, setTotal] = useState<number | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getUsage(metric, { bust: opts?.force });\n\t\t\t\tsetTotal(result.total);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, metric],\n\t);\n\n\tconst recordUsage = useCallback(\n\t\tasync (input: IRecordUsageInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.recordUsage(input);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { total, isLoading, error, refresh, recordUsage };\n}\n","import { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletPreferencesReturn {\n\t// Per-subscriber toggle: when false, a debit stops at the free allowance and\n\t// never draws down purchased credits. null until the first read resolves; a\n\t// subscriber with no balance row reads the server default (true).\n\tspendPurchased: boolean | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tsetSpendPurchased: (spendPurchased: boolean) => Promise<void>;\n}\n\nexport function useWalletPreferences(client?: BillingClient): IUseWalletPreferencesReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletPreferences');\n\tconst [spendPurchased, setSpend] = useState<boolean | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWallet({ bust: opts?.force });\n\t\t\t\t// The DTO omits spendPurchased when no balance row exists; surface the\n\t\t\t\t// server default (spend_purchased DEFAULT true) rather than null.\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? true);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst setSpendPurchased = useCallback(\n\t\tasync (next: boolean) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\t// The toggle route returns the refreshed wallet, so adopt it directly.\n\t\t\t\tconst { result } = await billing.setWalletPreferences({ spendPurchased: next });\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? next);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { spendPurchased, isLoading, error, refresh, setSpendPurchased };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,IAAAA,iBAAiC;;;ACVjC,oBAAiC;AACjC,mBAAqC;AACrC,IAAAC,gBAAsC;AAQ/B,SAAS,iBAAiB,QAAiD;AACjF,QAAM,cAAU,mCAAqB,QAAQ,C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AO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AACjB,cAAM;AAAA,MACP;AAAA,IACD;AAAA,IACA,CAAC,OAAO;AAAA,EACT;AAEA,gCAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,gBAAgB,WAAW,OAAO,SAAS,kBAAkB;AACvE;","names":["import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FonderieApiError, BillingClient, ICheckoutInput, IPlanDTO, ICreatePlanInput, IUpdatePlanInput,
|
|
1
|
+
import { FonderieApiError, BillingClient, ICheckoutInput, IPlanDTO, ICreatePlanInput, IUpdatePlanInput, ISubscriptionDTO, IRecordUsageInput } from '@fonderie/client';
|
|
2
2
|
export { BillingClient, FonderieApiError, ICheckoutInput, ICreatePlanInput, IPlanDTO, IPlanFeature, IRecordUsageInput, ISubscriptionDTO, IUpdatePlanInput, SubscriberType } from '@fonderie/client';
|
|
3
3
|
|
|
4
4
|
interface IUseBillingPortalReturn {
|
|
@@ -26,17 +26,6 @@ interface IUsePlanReturn {
|
|
|
26
26
|
declare function usePlan(planId: string): IUsePlanReturn;
|
|
27
27
|
declare function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;
|
|
28
28
|
|
|
29
|
-
/** @deprecated Use `usePlans().createPlan` / `updatePlan` / `deletePlan` instead — the list hook self-refreshes after each write. */
|
|
30
|
-
interface IUsePlanAdminReturn {
|
|
31
|
-
createPlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;
|
|
32
|
-
updatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;
|
|
33
|
-
deletePlan: (planId: string) => Promise<void>;
|
|
34
|
-
isLoading: boolean;
|
|
35
|
-
error: FonderieApiError | null;
|
|
36
|
-
}
|
|
37
|
-
/** @deprecated Use `usePlans().createPlan` / `updatePlan` / `deletePlan` instead — the list hook self-refreshes after each write. */
|
|
38
|
-
declare function usePlanAdmin(client?: BillingClient): IUsePlanAdminReturn;
|
|
39
|
-
|
|
40
29
|
interface IUsePlansReturn {
|
|
41
30
|
plans: IPlanDTO[];
|
|
42
31
|
isLoading: boolean;
|
|
@@ -50,15 +39,6 @@ interface IUsePlansReturn {
|
|
|
50
39
|
}
|
|
51
40
|
declare function usePlans(client?: BillingClient): IUsePlansReturn;
|
|
52
41
|
|
|
53
|
-
/** @deprecated Use `useUsage(metric).recordUsage` instead — the usage hook self-refreshes after the write. */
|
|
54
|
-
interface IUseRecordUsageReturn {
|
|
55
|
-
recordUsage: (input: IRecordUsageInput) => Promise<void>;
|
|
56
|
-
isLoading: boolean;
|
|
57
|
-
error: FonderieApiError | null;
|
|
58
|
-
}
|
|
59
|
-
/** @deprecated Use `useUsage(metric).recordUsage` instead — the usage hook self-refreshes after the write. */
|
|
60
|
-
declare function useRecordUsage(client?: BillingClient): IUseRecordUsageReturn;
|
|
61
|
-
|
|
62
42
|
interface IUseSubscriptionReturn {
|
|
63
43
|
subscription: ISubscriptionDTO | null;
|
|
64
44
|
isLoading: boolean;
|
|
@@ -81,4 +61,15 @@ interface IUseUsageReturn {
|
|
|
81
61
|
declare function useUsage(metric: string): IUseUsageReturn;
|
|
82
62
|
declare function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;
|
|
83
63
|
|
|
84
|
-
|
|
64
|
+
interface IUseWalletPreferencesReturn {
|
|
65
|
+
spendPurchased: boolean | null;
|
|
66
|
+
isLoading: boolean;
|
|
67
|
+
error: FonderieApiError | null;
|
|
68
|
+
refresh: (opts?: {
|
|
69
|
+
force?: boolean;
|
|
70
|
+
}) => Promise<void>;
|
|
71
|
+
setSpendPurchased: (spendPurchased: boolean) => Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
declare function useWalletPreferences(client?: BillingClient): IUseWalletPreferencesReturn;
|
|
74
|
+
|
|
75
|
+
export { type IUseBillingPortalReturn, type IUseCheckoutReturn, type IUsePlanReturn, type IUsePlansReturn, type IUseSubscriptionReturn, type IUseUsageReturn, type IUseWalletPreferencesReturn, useBillingPortal, useCheckout, usePlan, usePlans, useSubscription, useUsage, useWalletPreferences };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FonderieApiError, BillingClient, ICheckoutInput, IPlanDTO, ICreatePlanInput, IUpdatePlanInput,
|
|
1
|
+
import { FonderieApiError, BillingClient, ICheckoutInput, IPlanDTO, ICreatePlanInput, IUpdatePlanInput, ISubscriptionDTO, IRecordUsageInput } from '@fonderie/client';
|
|
2
2
|
export { BillingClient, FonderieApiError, ICheckoutInput, ICreatePlanInput, IPlanDTO, IPlanFeature, IRecordUsageInput, ISubscriptionDTO, IUpdatePlanInput, SubscriberType } from '@fonderie/client';
|
|
3
3
|
|
|
4
4
|
interface IUseBillingPortalReturn {
|
|
@@ -26,17 +26,6 @@ interface IUsePlanReturn {
|
|
|
26
26
|
declare function usePlan(planId: string): IUsePlanReturn;
|
|
27
27
|
declare function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;
|
|
28
28
|
|
|
29
|
-
/** @deprecated Use `usePlans().createPlan` / `updatePlan` / `deletePlan` instead — the list hook self-refreshes after each write. */
|
|
30
|
-
interface IUsePlanAdminReturn {
|
|
31
|
-
createPlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;
|
|
32
|
-
updatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;
|
|
33
|
-
deletePlan: (planId: string) => Promise<void>;
|
|
34
|
-
isLoading: boolean;
|
|
35
|
-
error: FonderieApiError | null;
|
|
36
|
-
}
|
|
37
|
-
/** @deprecated Use `usePlans().createPlan` / `updatePlan` / `deletePlan` instead — the list hook self-refreshes after each write. */
|
|
38
|
-
declare function usePlanAdmin(client?: BillingClient): IUsePlanAdminReturn;
|
|
39
|
-
|
|
40
29
|
interface IUsePlansReturn {
|
|
41
30
|
plans: IPlanDTO[];
|
|
42
31
|
isLoading: boolean;
|
|
@@ -50,15 +39,6 @@ interface IUsePlansReturn {
|
|
|
50
39
|
}
|
|
51
40
|
declare function usePlans(client?: BillingClient): IUsePlansReturn;
|
|
52
41
|
|
|
53
|
-
/** @deprecated Use `useUsage(metric).recordUsage` instead — the usage hook self-refreshes after the write. */
|
|
54
|
-
interface IUseRecordUsageReturn {
|
|
55
|
-
recordUsage: (input: IRecordUsageInput) => Promise<void>;
|
|
56
|
-
isLoading: boolean;
|
|
57
|
-
error: FonderieApiError | null;
|
|
58
|
-
}
|
|
59
|
-
/** @deprecated Use `useUsage(metric).recordUsage` instead — the usage hook self-refreshes after the write. */
|
|
60
|
-
declare function useRecordUsage(client?: BillingClient): IUseRecordUsageReturn;
|
|
61
|
-
|
|
62
42
|
interface IUseSubscriptionReturn {
|
|
63
43
|
subscription: ISubscriptionDTO | null;
|
|
64
44
|
isLoading: boolean;
|
|
@@ -81,4 +61,15 @@ interface IUseUsageReturn {
|
|
|
81
61
|
declare function useUsage(metric: string): IUseUsageReturn;
|
|
82
62
|
declare function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;
|
|
83
63
|
|
|
84
|
-
|
|
64
|
+
interface IUseWalletPreferencesReturn {
|
|
65
|
+
spendPurchased: boolean | null;
|
|
66
|
+
isLoading: boolean;
|
|
67
|
+
error: FonderieApiError | null;
|
|
68
|
+
refresh: (opts?: {
|
|
69
|
+
force?: boolean;
|
|
70
|
+
}) => Promise<void>;
|
|
71
|
+
setSpendPurchased: (spendPurchased: boolean) => Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
declare function useWalletPreferences(client?: BillingClient): IUseWalletPreferencesReturn;
|
|
74
|
+
|
|
75
|
+
export { type IUseBillingPortalReturn, type IUseCheckoutReturn, type IUsePlanReturn, type IUsePlansReturn, type IUseSubscriptionReturn, type IUseUsageReturn, type IUseWalletPreferencesReturn, useBillingPortal, useCheckout, usePlan, usePlans, useSubscription, useUsage, useWalletPreferences };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { FonderieApiError as
|
|
2
|
+
import { FonderieApiError as FonderieApiError8 } from "@fonderie/client";
|
|
3
3
|
|
|
4
4
|
// src/hooks/useBillingPortal.ts
|
|
5
5
|
import { FonderieApiError } from "@fonderie/client";
|
|
@@ -88,77 +88,16 @@ function usePlan(clientOrPlanId, maybePlanId) {
|
|
|
88
88
|
return { plan, isLoading, error, refresh };
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
// src/hooks/
|
|
91
|
+
// src/hooks/usePlans.ts
|
|
92
92
|
import { FonderieApiError as FonderieApiError4 } from "@fonderie/client";
|
|
93
93
|
import { useFonderieSubClient as useFonderieSubClient4 } from "@fonderie/react";
|
|
94
|
-
import { useCallback as useCallback4, useState as useState4 } from "react";
|
|
95
|
-
function usePlanAdmin(client) {
|
|
96
|
-
const billing = useFonderieSubClient4(client, (c) => c.billing, "usePlanAdmin");
|
|
97
|
-
const [isLoading, setIsLoading] = useState4(false);
|
|
98
|
-
const [error, setError] = useState4(null);
|
|
99
|
-
const createPlan = useCallback4(
|
|
100
|
-
async (input) => {
|
|
101
|
-
setIsLoading(true);
|
|
102
|
-
setError(null);
|
|
103
|
-
try {
|
|
104
|
-
const { result } = await billing.createPlan(input);
|
|
105
|
-
return result.plan;
|
|
106
|
-
} catch (err) {
|
|
107
|
-
const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
|
|
108
|
-
setError(apiError);
|
|
109
|
-
throw apiError;
|
|
110
|
-
} finally {
|
|
111
|
-
setIsLoading(false);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
[billing]
|
|
115
|
-
);
|
|
116
|
-
const updatePlan = useCallback4(
|
|
117
|
-
async (planId, input) => {
|
|
118
|
-
setIsLoading(true);
|
|
119
|
-
setError(null);
|
|
120
|
-
try {
|
|
121
|
-
const { result } = await billing.updatePlan(planId, input);
|
|
122
|
-
return result.plan;
|
|
123
|
-
} catch (err) {
|
|
124
|
-
const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
|
|
125
|
-
setError(apiError);
|
|
126
|
-
throw apiError;
|
|
127
|
-
} finally {
|
|
128
|
-
setIsLoading(false);
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
[billing]
|
|
132
|
-
);
|
|
133
|
-
const deletePlan = useCallback4(
|
|
134
|
-
async (planId) => {
|
|
135
|
-
setIsLoading(true);
|
|
136
|
-
setError(null);
|
|
137
|
-
try {
|
|
138
|
-
await billing.deletePlan(planId);
|
|
139
|
-
} catch (err) {
|
|
140
|
-
const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
|
|
141
|
-
setError(apiError);
|
|
142
|
-
throw apiError;
|
|
143
|
-
} finally {
|
|
144
|
-
setIsLoading(false);
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
[billing]
|
|
148
|
-
);
|
|
149
|
-
return { createPlan, updatePlan, deletePlan, isLoading, error };
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// src/hooks/usePlans.ts
|
|
153
|
-
import { FonderieApiError as FonderieApiError5 } from "@fonderie/client";
|
|
154
|
-
import { useFonderieSubClient as useFonderieSubClient5 } from "@fonderie/react";
|
|
155
|
-
import { useCallback as useCallback5, useEffect as useEffect2, useState as useState5 } from "react";
|
|
94
|
+
import { useCallback as useCallback4, useEffect as useEffect2, useState as useState4 } from "react";
|
|
156
95
|
function usePlans(client) {
|
|
157
|
-
const billing =
|
|
158
|
-
const [plans, setPlans] =
|
|
159
|
-
const [isLoading, setIsLoading] =
|
|
160
|
-
const [error, setError] =
|
|
161
|
-
const refresh =
|
|
96
|
+
const billing = useFonderieSubClient4(client, (c) => c.billing, "usePlans");
|
|
97
|
+
const [plans, setPlans] = useState4([]);
|
|
98
|
+
const [isLoading, setIsLoading] = useState4(true);
|
|
99
|
+
const [error, setError] = useState4(null);
|
|
100
|
+
const refresh = useCallback4(
|
|
162
101
|
async (opts) => {
|
|
163
102
|
setIsLoading(true);
|
|
164
103
|
setError(null);
|
|
@@ -166,7 +105,7 @@ function usePlans(client) {
|
|
|
166
105
|
const { result } = await billing.listPlans({ bust: opts?.force });
|
|
167
106
|
setPlans(result.plans);
|
|
168
107
|
} catch (err) {
|
|
169
|
-
const apiError = err instanceof
|
|
108
|
+
const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
|
|
170
109
|
setError(apiError);
|
|
171
110
|
} finally {
|
|
172
111
|
setIsLoading(false);
|
|
@@ -174,7 +113,7 @@ function usePlans(client) {
|
|
|
174
113
|
},
|
|
175
114
|
[billing]
|
|
176
115
|
);
|
|
177
|
-
const createPlan =
|
|
116
|
+
const createPlan = useCallback4(
|
|
178
117
|
async (input) => {
|
|
179
118
|
setError(null);
|
|
180
119
|
try {
|
|
@@ -182,14 +121,14 @@ function usePlans(client) {
|
|
|
182
121
|
await refresh();
|
|
183
122
|
return result.plan;
|
|
184
123
|
} catch (err) {
|
|
185
|
-
const apiError = err instanceof
|
|
124
|
+
const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
|
|
186
125
|
setError(apiError);
|
|
187
126
|
throw apiError;
|
|
188
127
|
}
|
|
189
128
|
},
|
|
190
129
|
[billing, refresh]
|
|
191
130
|
);
|
|
192
|
-
const updatePlan =
|
|
131
|
+
const updatePlan = useCallback4(
|
|
193
132
|
async (planId, input) => {
|
|
194
133
|
setError(null);
|
|
195
134
|
try {
|
|
@@ -197,21 +136,21 @@ function usePlans(client) {
|
|
|
197
136
|
await refresh();
|
|
198
137
|
return result.plan;
|
|
199
138
|
} catch (err) {
|
|
200
|
-
const apiError = err instanceof
|
|
139
|
+
const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
|
|
201
140
|
setError(apiError);
|
|
202
141
|
throw apiError;
|
|
203
142
|
}
|
|
204
143
|
},
|
|
205
144
|
[billing, refresh]
|
|
206
145
|
);
|
|
207
|
-
const deletePlan =
|
|
146
|
+
const deletePlan = useCallback4(
|
|
208
147
|
async (planId) => {
|
|
209
148
|
setError(null);
|
|
210
149
|
try {
|
|
211
150
|
await billing.deletePlan(planId);
|
|
212
151
|
await refresh();
|
|
213
152
|
} catch (err) {
|
|
214
|
-
const apiError = err instanceof
|
|
153
|
+
const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
|
|
215
154
|
setError(apiError);
|
|
216
155
|
throw apiError;
|
|
217
156
|
}
|
|
@@ -224,43 +163,16 @@ function usePlans(client) {
|
|
|
224
163
|
return { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };
|
|
225
164
|
}
|
|
226
165
|
|
|
227
|
-
// src/hooks/useRecordUsage.ts
|
|
228
|
-
import { FonderieApiError as FonderieApiError6 } from "@fonderie/client";
|
|
229
|
-
import { useFonderieSubClient as useFonderieSubClient6 } from "@fonderie/react";
|
|
230
|
-
import { useCallback as useCallback6, useState as useState6 } from "react";
|
|
231
|
-
function useRecordUsage(client) {
|
|
232
|
-
const billing = useFonderieSubClient6(client, (c) => c.billing, "useRecordUsage");
|
|
233
|
-
const [isLoading, setIsLoading] = useState6(false);
|
|
234
|
-
const [error, setError] = useState6(null);
|
|
235
|
-
const recordUsage = useCallback6(
|
|
236
|
-
async (input) => {
|
|
237
|
-
setIsLoading(true);
|
|
238
|
-
setError(null);
|
|
239
|
-
try {
|
|
240
|
-
await billing.recordUsage(input);
|
|
241
|
-
} catch (err) {
|
|
242
|
-
const apiError = err instanceof FonderieApiError6 ? err : new FonderieApiError6("unknown", String(err), 0);
|
|
243
|
-
setError(apiError);
|
|
244
|
-
throw apiError;
|
|
245
|
-
} finally {
|
|
246
|
-
setIsLoading(false);
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
[billing]
|
|
250
|
-
);
|
|
251
|
-
return { recordUsage, isLoading, error };
|
|
252
|
-
}
|
|
253
|
-
|
|
254
166
|
// src/hooks/useSubscription.ts
|
|
255
|
-
import { FonderieApiError as
|
|
256
|
-
import { useFonderieSubClient as
|
|
257
|
-
import { useCallback as
|
|
167
|
+
import { FonderieApiError as FonderieApiError5 } from "@fonderie/client";
|
|
168
|
+
import { useFonderieSubClient as useFonderieSubClient5 } from "@fonderie/react";
|
|
169
|
+
import { useCallback as useCallback5, useEffect as useEffect3, useState as useState5 } from "react";
|
|
258
170
|
function useSubscription(client) {
|
|
259
|
-
const billing =
|
|
260
|
-
const [subscription, setSubscription] =
|
|
261
|
-
const [isLoading, setIsLoading] =
|
|
262
|
-
const [error, setError] =
|
|
263
|
-
const refresh =
|
|
171
|
+
const billing = useFonderieSubClient5(client, (c) => c.billing, "useSubscription");
|
|
172
|
+
const [subscription, setSubscription] = useState5(null);
|
|
173
|
+
const [isLoading, setIsLoading] = useState5(true);
|
|
174
|
+
const [error, setError] = useState5(null);
|
|
175
|
+
const refresh = useCallback5(
|
|
264
176
|
async (opts) => {
|
|
265
177
|
setIsLoading(true);
|
|
266
178
|
setError(null);
|
|
@@ -268,7 +180,7 @@ function useSubscription(client) {
|
|
|
268
180
|
const { result } = await billing.getSubscription({ bust: opts?.force });
|
|
269
181
|
setSubscription(result.subscription);
|
|
270
182
|
} catch (err) {
|
|
271
|
-
const apiError = err instanceof
|
|
183
|
+
const apiError = err instanceof FonderieApiError5 ? err : new FonderieApiError5("unknown", String(err), 0);
|
|
272
184
|
if (apiError.status !== 404) setError(apiError);
|
|
273
185
|
setSubscription(null);
|
|
274
186
|
} finally {
|
|
@@ -284,18 +196,18 @@ function useSubscription(client) {
|
|
|
284
196
|
}
|
|
285
197
|
|
|
286
198
|
// src/hooks/useUsage.ts
|
|
287
|
-
import { BillingClient as BillingClient2, FonderieApiError as
|
|
288
|
-
import { useFonderieSubClient as
|
|
289
|
-
import { useCallback as
|
|
199
|
+
import { BillingClient as BillingClient2, FonderieApiError as FonderieApiError6 } from "@fonderie/client";
|
|
200
|
+
import { useFonderieSubClient as useFonderieSubClient6 } from "@fonderie/react";
|
|
201
|
+
import { useCallback as useCallback6, useEffect as useEffect4, useState as useState6 } from "react";
|
|
290
202
|
function useUsage(clientOrMetric, maybeMetric) {
|
|
291
203
|
const firstIsClient = clientOrMetric === void 0 || clientOrMetric instanceof BillingClient2;
|
|
292
204
|
const explicit = firstIsClient ? clientOrMetric : void 0;
|
|
293
205
|
const metric = firstIsClient ? maybeMetric : clientOrMetric;
|
|
294
|
-
const billing =
|
|
295
|
-
const [total, setTotal] =
|
|
296
|
-
const [isLoading, setIsLoading] =
|
|
297
|
-
const [error, setError] =
|
|
298
|
-
const refresh =
|
|
206
|
+
const billing = useFonderieSubClient6(explicit, (c) => c.billing, "useUsage");
|
|
207
|
+
const [total, setTotal] = useState6(null);
|
|
208
|
+
const [isLoading, setIsLoading] = useState6(true);
|
|
209
|
+
const [error, setError] = useState6(null);
|
|
210
|
+
const refresh = useCallback6(
|
|
299
211
|
async (opts) => {
|
|
300
212
|
setIsLoading(true);
|
|
301
213
|
setError(null);
|
|
@@ -303,7 +215,7 @@ function useUsage(clientOrMetric, maybeMetric) {
|
|
|
303
215
|
const { result } = await billing.getUsage(metric, { bust: opts?.force });
|
|
304
216
|
setTotal(result.total);
|
|
305
217
|
} catch (err) {
|
|
306
|
-
const apiError = err instanceof
|
|
218
|
+
const apiError = err instanceof FonderieApiError6 ? err : new FonderieApiError6("unknown", String(err), 0);
|
|
307
219
|
setError(apiError);
|
|
308
220
|
} finally {
|
|
309
221
|
setIsLoading(false);
|
|
@@ -311,14 +223,14 @@ function useUsage(clientOrMetric, maybeMetric) {
|
|
|
311
223
|
},
|
|
312
224
|
[billing, metric]
|
|
313
225
|
);
|
|
314
|
-
const recordUsage =
|
|
226
|
+
const recordUsage = useCallback6(
|
|
315
227
|
async (input) => {
|
|
316
228
|
setError(null);
|
|
317
229
|
try {
|
|
318
230
|
await billing.recordUsage(input);
|
|
319
231
|
await refresh();
|
|
320
232
|
} catch (err) {
|
|
321
|
-
const apiError = err instanceof
|
|
233
|
+
const apiError = err instanceof FonderieApiError6 ? err : new FonderieApiError6("unknown", String(err), 0);
|
|
322
234
|
setError(apiError);
|
|
323
235
|
throw apiError;
|
|
324
236
|
}
|
|
@@ -330,15 +242,59 @@ function useUsage(clientOrMetric, maybeMetric) {
|
|
|
330
242
|
}, [refresh]);
|
|
331
243
|
return { total, isLoading, error, refresh, recordUsage };
|
|
332
244
|
}
|
|
245
|
+
|
|
246
|
+
// src/hooks/useWalletPreferences.ts
|
|
247
|
+
import { FonderieApiError as FonderieApiError7 } from "@fonderie/client";
|
|
248
|
+
import { useFonderieSubClient as useFonderieSubClient7 } from "@fonderie/react";
|
|
249
|
+
import { useCallback as useCallback7, useEffect as useEffect5, useState as useState7 } from "react";
|
|
250
|
+
function useWalletPreferences(client) {
|
|
251
|
+
const billing = useFonderieSubClient7(client, (c) => c.billing, "useWalletPreferences");
|
|
252
|
+
const [spendPurchased, setSpend] = useState7(null);
|
|
253
|
+
const [isLoading, setIsLoading] = useState7(true);
|
|
254
|
+
const [error, setError] = useState7(null);
|
|
255
|
+
const refresh = useCallback7(
|
|
256
|
+
async (opts) => {
|
|
257
|
+
setIsLoading(true);
|
|
258
|
+
setError(null);
|
|
259
|
+
try {
|
|
260
|
+
const { result } = await billing.getWallet({ bust: opts?.force });
|
|
261
|
+
setSpend(result.wallet.spendPurchased ?? true);
|
|
262
|
+
} catch (err) {
|
|
263
|
+
const apiError = err instanceof FonderieApiError7 ? err : new FonderieApiError7("unknown", String(err), 0);
|
|
264
|
+
setError(apiError);
|
|
265
|
+
} finally {
|
|
266
|
+
setIsLoading(false);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
[billing]
|
|
270
|
+
);
|
|
271
|
+
const setSpendPurchased = useCallback7(
|
|
272
|
+
async (next) => {
|
|
273
|
+
setError(null);
|
|
274
|
+
try {
|
|
275
|
+
const { result } = await billing.setWalletPreferences({ spendPurchased: next });
|
|
276
|
+
setSpend(result.wallet.spendPurchased ?? next);
|
|
277
|
+
} catch (err) {
|
|
278
|
+
const apiError = err instanceof FonderieApiError7 ? err : new FonderieApiError7("unknown", String(err), 0);
|
|
279
|
+
setError(apiError);
|
|
280
|
+
throw apiError;
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
[billing]
|
|
284
|
+
);
|
|
285
|
+
useEffect5(() => {
|
|
286
|
+
void refresh();
|
|
287
|
+
}, [refresh]);
|
|
288
|
+
return { spendPurchased, isLoading, error, refresh, setSpendPurchased };
|
|
289
|
+
}
|
|
333
290
|
export {
|
|
334
|
-
|
|
291
|
+
FonderieApiError8 as FonderieApiError,
|
|
335
292
|
useBillingPortal,
|
|
336
293
|
useCheckout,
|
|
337
294
|
usePlan,
|
|
338
|
-
usePlanAdmin,
|
|
339
295
|
usePlans,
|
|
340
|
-
useRecordUsage,
|
|
341
296
|
useSubscription,
|
|
342
|
-
useUsage
|
|
297
|
+
useUsage,
|
|
298
|
+
useWalletPreferences
|
|
343
299
|
};
|
|
344
300
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/hooks/useBillingPortal.ts","../src/hooks/useCheckout.ts","../src/hooks/usePlan.ts","../src/hooks/usePlanAdmin.ts","../src/hooks/usePlans.ts","../src/hooks/useRecordUsage.ts","../src/hooks/useSubscription.ts","../src/hooks/useUsage.ts"],"sourcesContent":["export type {\n\tBillingClient,\n\tICheckoutInput,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIPlanFeature,\n\tIRecordUsageInput,\n\tISubscriptionDTO,\n\tIUpdatePlanInput,\n\tSubscriberType,\n} from '@fonderie/client';\nexport { FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseBillingPortalReturn,\n\tIUseCheckoutReturn,\n\tIUsePlanAdminReturn,\n\tIUsePlanReturn,\n\tIUsePlansReturn,\n\tIUseRecordUsageReturn,\n\tIUseSubscriptionReturn,\n\tIUseUsageReturn,\n} from './hooks';\nexport {\n\tuseBillingPortal,\n\tuseCheckout,\n\tusePlan,\n\tusePlanAdmin,\n\tusePlans,\n\tuseRecordUsage,\n\tuseSubscription,\n\tuseUsage,\n} from './hooks';\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseBillingPortalReturn {\n\topenPortal: () => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useBillingPortal(client?: BillingClient): IUseBillingPortalReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useBillingPortal');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst openPortal = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.createPortalSession();\n\t\t\treturn result.url;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { openPortal, isLoading, error };\n}\n","import type { BillingClient, ICheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCheckoutReturn {\n\tcheckout: (input: ICheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCheckout(client?: BillingClient): IUseCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: ICheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createCheckoutSession(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type { IPlanDTO } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlanReturn {\n\tplan: IPlanDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function usePlan(planId: string): IUsePlanReturn;\nexport function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;\nexport function usePlan(\n\tclientOrPlanId: BillingClient | string | undefined,\n\tmaybePlanId?: string,\n): IUsePlanReturn {\n\tconst firstIsClient = clientOrPlanId === undefined || clientOrPlanId instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrPlanId as BillingClient | undefined) : undefined;\n\tconst planId = firstIsClient ? (maybePlanId as string) : clientOrPlanId;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'usePlan');\n\tconst [plan, setPlan] = useState<IPlanDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPlan(planId, { bust: opts?.force });\n\t\t\t\tsetPlan(result.plan);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, planId],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plan, isLoading, error, refresh };\n}\n","import type { BillingClient, ICreatePlanInput, IPlanDTO, IUpdatePlanInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\n/** @deprecated Use `usePlans().createPlan` / `updatePlan` / `deletePlan` instead — the list hook self-refreshes after each write. */\nexport interface IUsePlanAdminReturn {\n\tcreatePlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;\n\tupdatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;\n\tdeletePlan: (planId: string) => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\n// Action-only, like useUpdateRole/useWorkspaceProfile — pair with usePlans()\n// for the list and call its refresh() after a write.\n//\n// Unlike every other write in this SDK, @fonderie/billing does not gate\n// createPlan/updatePlan/deletePlan with requireAuth or an admin token — the\n// server trusts the caller to authorize access itself. Gate the UI that\n// calls this hook behind your own admin check before shipping it.\n/** @deprecated Use `usePlans().createPlan` / `updatePlan` / `deletePlan` instead — the list hook self-refreshes after each write. */\nexport function usePlanAdmin(client?: BillingClient): IUsePlanAdminReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePlanAdmin');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst createPlan = useCallback(\n\t\tasync (input: ICreatePlanInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createPlan(input);\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst updatePlan = useCallback(\n\t\tasync (planId: string, input: IUpdatePlanInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.updatePlan(planId, input);\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst deletePlan = useCallback(\n\t\tasync (planId: string) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.deletePlan(planId);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { createPlan, updatePlan, deletePlan, isLoading, error };\n}\n","import type {\n\tBillingClient,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIUpdatePlanInput,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlansReturn {\n\tplans: IPlanDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tcreatePlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;\n\tupdatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;\n\tdeletePlan: (planId: string) => Promise<void>;\n}\n\nexport function usePlans(client?: BillingClient): IUsePlansReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePlans');\n\tconst [plans, setPlans] = useState<IPlanDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listPlans({ bust: opts?.force });\n\t\t\t\tsetPlans(result.plans);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\t// Like usePlanAdmin, these writes are not auth-gated by @fonderie/billing —\n\t// gate the UI that calls them behind your own admin check before shipping it.\n\tconst createPlan = useCallback(\n\t\tasync (input: ICreatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createPlan(input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst updatePlan = useCallback(\n\t\tasync (planId: string, input: IUpdatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.updatePlan(planId, input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst deletePlan = useCallback(\n\t\tasync (planId: string) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.deletePlan(planId);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };\n}\n","import type { BillingClient, IRecordUsageInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\n/** @deprecated Use `useUsage(metric).recordUsage` instead — the usage hook self-refreshes after the write. */\nexport interface IUseRecordUsageReturn {\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\n/** @deprecated Use `useUsage(metric).recordUsage` instead — the usage hook self-refreshes after the write. */\nexport function useRecordUsage(client?: BillingClient): IUseRecordUsageReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useRecordUsage');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst recordUsage = useCallback(\n\t\tasync (input: IRecordUsageInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.recordUsage(input);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { recordUsage, isLoading, error };\n}\n","import type { BillingClient, ISubscriptionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseSubscriptionReturn {\n\tsubscription: ISubscriptionDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function useSubscription(client?: BillingClient): IUseSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSubscription');\n\tconst [subscription, setSubscription] = useState<ISubscriptionDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getSubscription({ bust: opts?.force });\n\t\t\t\tsetSubscription(result.subscription);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// No active subscription is a normal, expected state — not an error banner.\n\t\t\t\tif (apiError.status !== 404) setError(apiError);\n\t\t\t\tsetSubscription(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { subscription, isLoading, error, refresh };\n}\n","import type { IRecordUsageInput } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseUsageReturn {\n\ttotal: number | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n}\n\nexport function useUsage(metric: string): IUseUsageReturn;\nexport function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;\nexport function useUsage(\n\tclientOrMetric: BillingClient | string | undefined,\n\tmaybeMetric?: string,\n): IUseUsageReturn {\n\tconst firstIsClient = clientOrMetric === undefined || clientOrMetric instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrMetric as BillingClient | undefined) : undefined;\n\tconst metric = firstIsClient ? (maybeMetric as string) : clientOrMetric;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'useUsage');\n\tconst [total, setTotal] = useState<number | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getUsage(metric, { bust: opts?.force });\n\t\t\t\tsetTotal(result.total);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, metric],\n\t);\n\n\tconst recordUsage = useCallback(\n\t\tasync (input: IRecordUsageInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.recordUsage(input);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { total, isLoading, error, refresh, recordUsage };\n}\n"],"mappings":";AAWA,SAAS,oBAAAA,yBAAwB;;;ACVjC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,aAAa,gBAAgB;AAQ/B,SAAS,iBAAiB,QAAiD;AACjF,QAAM,UAAU,qBAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB;AACjF,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkC,IAAI;AAEhE,QAAM,aAAa,YAAY,YAAY;AAC1C,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,QAAQ,oBAAoB;AACrD,aAAO,OAAO;AAAA,IACf,SAAS,KAAK;AACb,YAAM,WACL,eAAe,mBAAmB,MAAM,IAAI,iBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AACjB,YAAM;AAAA,IACP,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,YAAY,WAAW,MAAM;AACvC;;;AChCA,SAAS,oBAAAC,yBAAwB;AACjC,SAAS,wBAAAC,6BAA4B;AACrC,SAAS,eAAAC,cAAa,YAAAC,iBAAgB;AAQ/B,SAAS,YAAY,QAA4C;AACvE,QAAM,UAAUF,sBAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa;AAC5E,QAAM,CAAC,WAAW,YAAY,IAAIE,UAAS,KAAK;AAChD,QAAM,CAA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K;AACb,cAAM,WACL,eAAeF,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AAAA,MAClB,UAAE;AACD,qBAAa,KAAK;AAAA,MACnB;AAAA,IACD;AAAA,IACA,CAAC,SAAS,MAAM;AAAA,EACjB;AAEA,QAAM,cAAcE;AAAA,IACnB,OAAO,UAA6B;AACnC,eAAS,IAAI;AACb,UAAI;AACH,cAAM,QAAQ,YAAY,KAAK;AAC/B,cAAM,QAAQ;AAAA,MACf,SAAS,KAAK;AACb,cAAM,WACL,eAAeF,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AACjB,cAAM;AAAA,MACP;AAAA,IACD;AAAA,IACA,CAAC,SAAS,OAAO;AAAA,EAClB;AAEA,EAAAG,WAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,OAAO,WAAW,OAAO,SAAS,YAAY;AACxD;","names":["FonderieApiError","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","BillingClient","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/hooks/useBillingPortal.ts","../src/hooks/useCheckout.ts","../src/hooks/usePlan.ts","../src/hooks/usePlans.ts","../src/hooks/useSubscription.ts","../src/hooks/useUsage.ts","../src/hooks/useWalletPreferences.ts"],"sourcesContent":["export type {\n\tBillingClient,\n\tICheckoutInput,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIPlanFeature,\n\tIRecordUsageInput,\n\tISubscriptionDTO,\n\tIUpdatePlanInput,\n\tSubscriberType,\n} from '@fonderie/client';\nexport { FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseBillingPortalReturn,\n\tIUseCheckoutReturn,\n\tIUsePlanReturn,\n\tIUsePlansReturn,\n\tIUseSubscriptionReturn,\n\tIUseUsageReturn,\n\tIUseWalletPreferencesReturn,\n} from './hooks';\nexport {\n\tuseBillingPortal,\n\tuseCheckout,\n\tusePlan,\n\tusePlans,\n\tuseSubscription,\n\tuseUsage,\n\tuseWalletPreferences,\n} from './hooks';\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseBillingPortalReturn {\n\topenPortal: () => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useBillingPortal(client?: BillingClient): IUseBillingPortalReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useBillingPortal');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst openPortal = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.createPortalSession();\n\t\t\treturn result.url;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { openPortal, isLoading, error };\n}\n","import type { BillingClient, ICheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCheckoutReturn {\n\tcheckout: (input: ICheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCheckout(client?: BillingClient): IUseCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: ICheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createCheckoutSession(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type { IPlanDTO } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlanReturn {\n\tplan: IPlanDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function usePlan(planId: string): IUsePlanReturn;\nexport function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;\nexport function usePlan(\n\tclientOrPlanId: BillingClient | string | undefined,\n\tmaybePlanId?: string,\n): IUsePlanReturn {\n\tconst firstIsClient = clientOrPlanId === undefined || clientOrPlanId instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrPlanId as BillingClient | undefined) : undefined;\n\tconst planId = firstIsClient ? (maybePlanId as string) : clientOrPlanId;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'usePlan');\n\tconst [plan, setPlan] = useState<IPlanDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPlan(planId, { bust: opts?.force });\n\t\t\t\tsetPlan(result.plan);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, planId],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plan, isLoading, error, refresh };\n}\n","import type {\n\tBillingClient,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIUpdatePlanInput,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlansReturn {\n\tplans: IPlanDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tcreatePlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;\n\tupdatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;\n\tdeletePlan: (planId: string) => Promise<void>;\n}\n\nexport function usePlans(client?: BillingClient): IUsePlansReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePlans');\n\tconst [plans, setPlans] = useState<IPlanDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listPlans({ bust: opts?.force });\n\t\t\t\tsetPlans(result.plans);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\t// These writes are not auth-gated by @fonderie/billing —\n\t// gate the UI that calls them behind your own admin check before shipping it.\n\tconst createPlan = useCallback(\n\t\tasync (input: ICreatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createPlan(input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst updatePlan = useCallback(\n\t\tasync (planId: string, input: IUpdatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.updatePlan(planId, input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst deletePlan = useCallback(\n\t\tasync (planId: string) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.deletePlan(planId);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };\n}\n","import type { BillingClient, ISubscriptionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseSubscriptionReturn {\n\tsubscription: ISubscriptionDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function useSubscription(client?: BillingClient): IUseSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSubscription');\n\tconst [subscription, setSubscription] = useState<ISubscriptionDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getSubscription({ bust: opts?.force });\n\t\t\t\tsetSubscription(result.subscription);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// No active subscription is a normal, expected state — not an error banner.\n\t\t\t\tif (apiError.status !== 404) setError(apiError);\n\t\t\t\tsetSubscription(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { subscription, isLoading, error, refresh };\n}\n","import type { IRecordUsageInput } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseUsageReturn {\n\ttotal: number | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n}\n\nexport function useUsage(metric: string): IUseUsageReturn;\nexport function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;\nexport function useUsage(\n\tclientOrMetric: BillingClient | string | undefined,\n\tmaybeMetric?: string,\n): IUseUsageReturn {\n\tconst firstIsClient = clientOrMetric === undefined || clientOrMetric instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrMetric as BillingClient | undefined) : undefined;\n\tconst metric = firstIsClient ? (maybeMetric as string) : clientOrMetric;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'useUsage');\n\tconst [total, setTotal] = useState<number | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getUsage(metric, { bust: opts?.force });\n\t\t\t\tsetTotal(result.total);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, metric],\n\t);\n\n\tconst recordUsage = useCallback(\n\t\tasync (input: IRecordUsageInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.recordUsage(input);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { total, isLoading, error, refresh, recordUsage };\n}\n","import { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletPreferencesReturn {\n\t// Per-subscriber toggle: when false, a debit stops at the free allowance and\n\t// never draws down purchased credits. null until the first read resolves; a\n\t// subscriber with no balance row reads the server default (true).\n\tspendPurchased: boolean | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tsetSpendPurchased: (spendPurchased: boolean) => Promise<void>;\n}\n\nexport function useWalletPreferences(client?: BillingClient): IUseWalletPreferencesReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletPreferences');\n\tconst [spendPurchased, setSpend] = useState<boolean | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWallet({ bust: opts?.force });\n\t\t\t\t// The DTO omits spendPurchased when no balance row exists; surface the\n\t\t\t\t// server default (spend_purchased DEFAULT true) rather than null.\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? true);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst setSpendPurchased = useCallback(\n\t\tasync (next: boolean) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\t// The toggle route returns the refreshed wallet, so adopt it directly.\n\t\t\t\tconst { result } = await billing.setWalletPreferences({ spendPurchased: next });\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? next);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { spendPurchased, isLoading, error, refresh, setSpendPurchased };\n}\n"],"mappings":";AAWA,SAAS,oBAAAA,yBAAwB;;;ACVjC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,aAAa,gBAAgB;AAQ/B,SAAS,iBAAiB,QAAiD;AACjF,QAAM,UAAU,qBAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB;AACjF,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkC,IAAI;AAEhE,QAAM,aAAa,YAAY,YAAY;AAC1C,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,QAAQ,oBAAoB;AACrD,aAAO,OAAO;AAAA,IACf,SAAS,KAAK;AACb,YAAM,WACL,eAAe,mBAAmB,MAAM,IAAI,iBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AACjB,YAAM;AAAA,IACP,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,YAAY,WAAW,MAAM;AACvC;;;AChCA,SAAS,oBAAAC,yBAAwB;AACjC,SAAS,wBAAAC,6BAA4B;AACrC,SAAS,eAAAC,cAAa,YAAAC,iBAAgB;AAQ/B,SAAS,YAAY,QAA4C;AACvE,QAAM,UAAUF,sBAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa;AAC5E,QAAM,CAAC,WAAW,YAAY,IA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CAAC,WAAW,YAAY,IAAIA,UAAS,IAAI;AAC/C,QAAM,CAAC,OAAO,QAAQ,IAAIA,UAAkC,IAAI;AAEhE,QAAM,UAAUF;AAAA,IACf,OAAO,SAA+B;AACrC,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb,UAAI;AACH,cAAM,EAAE,OAAO,IAAI,MAAM,QAAQ,UAAU,EAAE,MAAM,MAAM,MAAM,CAAC;AAGhE,iBAAS,OAAO,OAAO,kBAAkB,IAAI;AAAA,MAC9C,SAAS,KAAK;AACb,cAAM,WACL,eAAeF,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AAAA,MAClB,UAAE;AACD,qBAAa,KAAK;AAAA,MACnB;AAAA,IACD;AAAA,IACA,CAAC,OAAO;AAAA,EACT;AAEA,QAAM,oBAAoBE;AAAA,IACzB,OAAO,SAAkB;AACxB,eAAS,IAAI;AACb,UAAI;AAEH,cAAM,EAAE,OAAO,IAAI,MAAM,QAAQ,qBAAqB,EAAE,gBAAgB,KAAK,CAAC;AAC9E,iBAAS,OAAO,OAAO,kBAAkB,IAAI;AAAA,MAC9C,SAAS,KAAK;AACb,cAAM,WACL,eAAeF,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AACjB,cAAM;AAAA,MACP;AAAA,IACD;AAAA,IACA,CAAC,OAAO;AAAA,EACT;AAEA,EAAAG,WAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,gBAAgB,WAAW,OAAO,SAAS,kBAAkB;AACvE;","names":["FonderieApiError","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","BillingClient","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonderie/react-billing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "React hooks for Fonderie billing — thin bindings over @fonderie/client.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fonderiejs",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react": ">=18.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@types/node": "^26.
|
|
45
|
+
"@types/node": "^26.4.0",
|
|
46
46
|
"@types/react": "^19.2.18",
|
|
47
47
|
"react": "^19.2.8",
|
|
48
48
|
"react-dom": "^19.2.8",
|