@fonderie/react-billing 0.2.0 → 0.4.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 CHANGED
@@ -20,18 +20,16 @@ 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: () => import_client9.FonderieApiError,
23
+ FonderieApiError: () => import_client7.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
29
  useUsage: () => useUsage
32
30
  });
33
31
  module.exports = __toCommonJS(index_exports);
34
- var import_client9 = require("@fonderie/client");
32
+ var import_client7 = require("@fonderie/client");
35
33
 
36
34
  // src/hooks/useBillingPortal.ts
37
35
  var import_client = require("@fonderie/client");
@@ -98,199 +96,181 @@ function usePlan(clientOrPlanId, maybePlanId) {
98
96
  const [plan, setPlan] = (0, import_react6.useState)(null);
99
97
  const [isLoading, setIsLoading] = (0, import_react6.useState)(true);
100
98
  const [error, setError] = (0, import_react6.useState)(null);
101
- const refresh = (0, import_react6.useCallback)(async () => {
102
- setIsLoading(true);
103
- setError(null);
104
- try {
105
- const { result } = await billing.getPlan(planId);
106
- setPlan(result.plan);
107
- } catch (err) {
108
- const apiError = err instanceof import_client3.FonderieApiError ? err : new import_client3.FonderieApiError("unknown", String(err), 0);
109
- setError(apiError);
110
- } finally {
111
- setIsLoading(false);
112
- }
113
- }, [billing, planId]);
99
+ const refresh = (0, import_react6.useCallback)(
100
+ async (opts) => {
101
+ setIsLoading(true);
102
+ setError(null);
103
+ try {
104
+ const { result } = await billing.getPlan(planId, { bust: opts?.force });
105
+ setPlan(result.plan);
106
+ } catch (err) {
107
+ const apiError = err instanceof import_client3.FonderieApiError ? err : new import_client3.FonderieApiError("unknown", String(err), 0);
108
+ setError(apiError);
109
+ } finally {
110
+ setIsLoading(false);
111
+ }
112
+ },
113
+ [billing, planId]
114
+ );
114
115
  (0, import_react6.useEffect)(() => {
115
116
  void refresh();
116
117
  }, [refresh]);
117
118
  return { plan, isLoading, error, refresh };
118
119
  }
119
120
 
120
- // src/hooks/usePlanAdmin.ts
121
+ // src/hooks/usePlans.ts
121
122
  var import_client4 = require("@fonderie/client");
122
123
  var import_react7 = require("@fonderie/react");
123
124
  var import_react8 = require("react");
124
- function usePlanAdmin(client) {
125
- const billing = (0, import_react7.useFonderieSubClient)(client, (c) => c.billing, "usePlanAdmin");
126
- const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
125
+ function usePlans(client) {
126
+ const billing = (0, import_react7.useFonderieSubClient)(client, (c) => c.billing, "usePlans");
127
+ const [plans, setPlans] = (0, import_react8.useState)([]);
128
+ const [isLoading, setIsLoading] = (0, import_react8.useState)(true);
127
129
  const [error, setError] = (0, import_react8.useState)(null);
130
+ const refresh = (0, import_react8.useCallback)(
131
+ async (opts) => {
132
+ setIsLoading(true);
133
+ setError(null);
134
+ try {
135
+ const { result } = await billing.listPlans({ bust: opts?.force });
136
+ setPlans(result.plans);
137
+ } catch (err) {
138
+ const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
139
+ setError(apiError);
140
+ } finally {
141
+ setIsLoading(false);
142
+ }
143
+ },
144
+ [billing]
145
+ );
128
146
  const createPlan = (0, import_react8.useCallback)(
129
147
  async (input) => {
130
- setIsLoading(true);
131
148
  setError(null);
132
149
  try {
133
150
  const { result } = await billing.createPlan(input);
151
+ await refresh();
134
152
  return result.plan;
135
153
  } catch (err) {
136
154
  const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
137
155
  setError(apiError);
138
156
  throw apiError;
139
- } finally {
140
- setIsLoading(false);
141
157
  }
142
158
  },
143
- [billing]
159
+ [billing, refresh]
144
160
  );
145
161
  const updatePlan = (0, import_react8.useCallback)(
146
162
  async (planId, input) => {
147
- setIsLoading(true);
148
163
  setError(null);
149
164
  try {
150
165
  const { result } = await billing.updatePlan(planId, input);
166
+ await refresh();
151
167
  return result.plan;
152
168
  } catch (err) {
153
169
  const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
154
170
  setError(apiError);
155
171
  throw apiError;
156
- } finally {
157
- setIsLoading(false);
158
172
  }
159
173
  },
160
- [billing]
174
+ [billing, refresh]
161
175
  );
162
176
  const deletePlan = (0, import_react8.useCallback)(
163
177
  async (planId) => {
164
- setIsLoading(true);
165
178
  setError(null);
166
179
  try {
167
180
  await billing.deletePlan(planId);
181
+ await refresh();
168
182
  } catch (err) {
169
183
  const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
170
184
  setError(apiError);
171
185
  throw apiError;
172
- } finally {
173
- setIsLoading(false);
174
186
  }
175
187
  },
176
- [billing]
188
+ [billing, refresh]
177
189
  );
178
- return { createPlan, updatePlan, deletePlan, isLoading, error };
190
+ (0, import_react8.useEffect)(() => {
191
+ void refresh();
192
+ }, [refresh]);
193
+ return { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };
179
194
  }
180
195
 
181
- // src/hooks/usePlans.ts
196
+ // src/hooks/useSubscription.ts
182
197
  var import_client5 = require("@fonderie/client");
183
198
  var import_react9 = require("@fonderie/react");
184
199
  var import_react10 = require("react");
185
- function usePlans(client) {
186
- const billing = (0, import_react9.useFonderieSubClient)(client, (c) => c.billing, "usePlans");
187
- const [plans, setPlans] = (0, import_react10.useState)([]);
200
+ function useSubscription(client) {
201
+ const billing = (0, import_react9.useFonderieSubClient)(client, (c) => c.billing, "useSubscription");
202
+ const [subscription, setSubscription] = (0, import_react10.useState)(null);
188
203
  const [isLoading, setIsLoading] = (0, import_react10.useState)(true);
189
204
  const [error, setError] = (0, import_react10.useState)(null);
190
- const refresh = (0, import_react10.useCallback)(async () => {
191
- setIsLoading(true);
192
- setError(null);
193
- try {
194
- const { result } = await billing.listPlans();
195
- setPlans(result.plans);
196
- } catch (err) {
197
- const apiError = err instanceof import_client5.FonderieApiError ? err : new import_client5.FonderieApiError("unknown", String(err), 0);
198
- setError(apiError);
199
- } finally {
200
- setIsLoading(false);
201
- }
202
- }, [billing]);
205
+ const refresh = (0, import_react10.useCallback)(
206
+ async (opts) => {
207
+ setIsLoading(true);
208
+ setError(null);
209
+ try {
210
+ const { result } = await billing.getSubscription({ bust: opts?.force });
211
+ setSubscription(result.subscription);
212
+ } catch (err) {
213
+ const apiError = err instanceof import_client5.FonderieApiError ? err : new import_client5.FonderieApiError("unknown", String(err), 0);
214
+ if (apiError.status !== 404) setError(apiError);
215
+ setSubscription(null);
216
+ } finally {
217
+ setIsLoading(false);
218
+ }
219
+ },
220
+ [billing]
221
+ );
203
222
  (0, import_react10.useEffect)(() => {
204
223
  void refresh();
205
224
  }, [refresh]);
206
- return { plans, isLoading, error, refresh };
225
+ return { subscription, isLoading, error, refresh };
207
226
  }
208
227
 
209
- // src/hooks/useRecordUsage.ts
228
+ // src/hooks/useUsage.ts
210
229
  var import_client6 = require("@fonderie/client");
211
230
  var import_react11 = require("@fonderie/react");
212
231
  var import_react12 = require("react");
213
- function useRecordUsage(client) {
214
- const billing = (0, import_react11.useFonderieSubClient)(client, (c) => c.billing, "useRecordUsage");
215
- const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
232
+ function useUsage(clientOrMetric, maybeMetric) {
233
+ const firstIsClient = clientOrMetric === void 0 || clientOrMetric instanceof import_client6.BillingClient;
234
+ const explicit = firstIsClient ? clientOrMetric : void 0;
235
+ const metric = firstIsClient ? maybeMetric : clientOrMetric;
236
+ const billing = (0, import_react11.useFonderieSubClient)(explicit, (c) => c.billing, "useUsage");
237
+ const [total, setTotal] = (0, import_react12.useState)(null);
238
+ const [isLoading, setIsLoading] = (0, import_react12.useState)(true);
216
239
  const [error, setError] = (0, import_react12.useState)(null);
240
+ const refresh = (0, import_react12.useCallback)(
241
+ async (opts) => {
242
+ setIsLoading(true);
243
+ setError(null);
244
+ try {
245
+ const { result } = await billing.getUsage(metric, { bust: opts?.force });
246
+ setTotal(result.total);
247
+ } catch (err) {
248
+ const apiError = err instanceof import_client6.FonderieApiError ? err : new import_client6.FonderieApiError("unknown", String(err), 0);
249
+ setError(apiError);
250
+ } finally {
251
+ setIsLoading(false);
252
+ }
253
+ },
254
+ [billing, metric]
255
+ );
217
256
  const recordUsage = (0, import_react12.useCallback)(
218
257
  async (input) => {
219
- setIsLoading(true);
220
258
  setError(null);
221
259
  try {
222
260
  await billing.recordUsage(input);
261
+ await refresh();
223
262
  } catch (err) {
224
263
  const apiError = err instanceof import_client6.FonderieApiError ? err : new import_client6.FonderieApiError("unknown", String(err), 0);
225
264
  setError(apiError);
226
265
  throw apiError;
227
- } finally {
228
- setIsLoading(false);
229
266
  }
230
267
  },
231
- [billing]
268
+ [billing, refresh]
232
269
  );
233
- return { recordUsage, isLoading, error };
234
- }
235
-
236
- // src/hooks/useSubscription.ts
237
- var import_client7 = require("@fonderie/client");
238
- var import_react13 = require("@fonderie/react");
239
- var import_react14 = require("react");
240
- function useSubscription(client) {
241
- const billing = (0, import_react13.useFonderieSubClient)(client, (c) => c.billing, "useSubscription");
242
- const [subscription, setSubscription] = (0, import_react14.useState)(null);
243
- const [isLoading, setIsLoading] = (0, import_react14.useState)(true);
244
- const [error, setError] = (0, import_react14.useState)(null);
245
- const refresh = (0, import_react14.useCallback)(async () => {
246
- setIsLoading(true);
247
- setError(null);
248
- try {
249
- const { result } = await billing.getSubscription();
250
- setSubscription(result.subscription);
251
- } catch (err) {
252
- const apiError = err instanceof import_client7.FonderieApiError ? err : new import_client7.FonderieApiError("unknown", String(err), 0);
253
- if (apiError.status !== 404) setError(apiError);
254
- setSubscription(null);
255
- } finally {
256
- setIsLoading(false);
257
- }
258
- }, [billing]);
259
- (0, import_react14.useEffect)(() => {
260
- void refresh();
261
- }, [refresh]);
262
- return { subscription, isLoading, error, refresh };
263
- }
264
-
265
- // src/hooks/useUsage.ts
266
- var import_client8 = require("@fonderie/client");
267
- var import_react15 = require("@fonderie/react");
268
- var import_react16 = require("react");
269
- function useUsage(clientOrMetric, maybeMetric) {
270
- const firstIsClient = clientOrMetric === void 0 || clientOrMetric instanceof import_client8.BillingClient;
271
- const explicit = firstIsClient ? clientOrMetric : void 0;
272
- const metric = firstIsClient ? maybeMetric : clientOrMetric;
273
- const billing = (0, import_react15.useFonderieSubClient)(explicit, (c) => c.billing, "useUsage");
274
- const [total, setTotal] = (0, import_react16.useState)(null);
275
- const [isLoading, setIsLoading] = (0, import_react16.useState)(true);
276
- const [error, setError] = (0, import_react16.useState)(null);
277
- const refresh = (0, import_react16.useCallback)(async () => {
278
- setIsLoading(true);
279
- setError(null);
280
- try {
281
- const { result } = await billing.getUsage(metric);
282
- setTotal(result.total);
283
- } catch (err) {
284
- const apiError = err instanceof import_client8.FonderieApiError ? err : new import_client8.FonderieApiError("unknown", String(err), 0);
285
- setError(apiError);
286
- } finally {
287
- setIsLoading(false);
288
- }
289
- }, [billing, metric]);
290
- (0, import_react16.useEffect)(() => {
270
+ (0, import_react12.useEffect)(() => {
291
271
  void refresh();
292
272
  }, [refresh]);
293
- return { total, isLoading, error, refresh };
273
+ return { total, isLoading, error, refresh, recordUsage };
294
274
  }
295
275
  // Annotate the CommonJS export names for ESM import in node:
296
276
  0 && (module.exports = {
@@ -298,9 +278,7 @@ function useUsage(clientOrMetric, maybeMetric) {
298
278
  useBillingPortal,
299
279
  useCheckout,
300
280
  usePlan,
301
- usePlanAdmin,
302
281
  usePlans,
303
- useRecordUsage,
304
282
  useSubscription,
305
283
  useUsage
306
284
  });
@@ -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: () => 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(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.getPlan(planId);\n\t\t\tsetPlan(result.plan);\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} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing, planId]);\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\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.\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 { BillingClient, IPlanDTO } 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: () => 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(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.listPlans();\n\t\t\tsetPlans(result.plans);\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} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plans, isLoading, error, refresh };\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\nexport interface IUseRecordUsageReturn {\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\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: () => 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(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.getSubscription();\n\t\t\tsetSubscription(result.subscription);\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\t// No active subscription is a normal, expected state — not an error banner.\n\t\t\tif (apiError.status !== 404) setError(apiError);\n\t\t\tsetSubscription(null);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { subscription, isLoading, error, refresh };\n}\n","import { 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: () => 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(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.getUsage(metric);\n\t\t\tsetTotal(result.total);\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} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing, metric]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { total, isLoading, error, refresh };\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,wBA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I;AACtD,QAAM,CAAC,WAAW,YAAY,QAAI,yBAAS,IAAI;AAC/C,QAAM,CAAC,OAAO,QAAQ,QAAI,yBAAkC,IAAI;AAEhE,QAAM,cAAU,4BAAY,YAAY;AACvC,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,QAAQ,SAAS,MAAM;AAChD,eAAS,OAAO,KAAK;AAAA,IACtB,SAAS,KAAK;AACb,YAAM,WACL,eAAe,kCAAmB,MAAM,IAAI,gCAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AAAA,IAClB,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,SAAS,MAAM,CAAC;AAEpB,gCAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,OAAO,WAAW,OAAO,QAAQ;AAC3C;","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"],"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} from './hooks';\nexport {\n\tuseBillingPortal,\n\tuseCheckout,\n\tusePlan,\n\tusePlans,\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 {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;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,kBAAk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AA,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"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { FonderieApiError, BillingClient, ICheckoutInput, IPlanDTO, ICreatePlanInput, IUpdatePlanInput, IRecordUsageInput, ISubscriptionDTO } from '@fonderie/client';
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 {
@@ -19,40 +19,33 @@ interface IUsePlanReturn {
19
19
  plan: IPlanDTO | null;
20
20
  isLoading: boolean;
21
21
  error: FonderieApiError | null;
22
- refresh: () => Promise<void>;
22
+ refresh: (opts?: {
23
+ force?: boolean;
24
+ }) => Promise<void>;
23
25
  }
24
26
  declare function usePlan(planId: string): IUsePlanReturn;
25
27
  declare function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;
26
28
 
27
- interface IUsePlanAdminReturn {
28
- createPlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;
29
- updatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;
30
- deletePlan: (planId: string) => Promise<void>;
31
- isLoading: boolean;
32
- error: FonderieApiError | null;
33
- }
34
- declare function usePlanAdmin(client?: BillingClient): IUsePlanAdminReturn;
35
-
36
29
  interface IUsePlansReturn {
37
30
  plans: IPlanDTO[];
38
31
  isLoading: boolean;
39
32
  error: FonderieApiError | null;
40
- refresh: () => Promise<void>;
33
+ refresh: (opts?: {
34
+ force?: boolean;
35
+ }) => Promise<void>;
36
+ createPlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;
37
+ updatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;
38
+ deletePlan: (planId: string) => Promise<void>;
41
39
  }
42
40
  declare function usePlans(client?: BillingClient): IUsePlansReturn;
43
41
 
44
- interface IUseRecordUsageReturn {
45
- recordUsage: (input: IRecordUsageInput) => Promise<void>;
46
- isLoading: boolean;
47
- error: FonderieApiError | null;
48
- }
49
- declare function useRecordUsage(client?: BillingClient): IUseRecordUsageReturn;
50
-
51
42
  interface IUseSubscriptionReturn {
52
43
  subscription: ISubscriptionDTO | null;
53
44
  isLoading: boolean;
54
45
  error: FonderieApiError | null;
55
- refresh: () => Promise<void>;
46
+ refresh: (opts?: {
47
+ force?: boolean;
48
+ }) => Promise<void>;
56
49
  }
57
50
  declare function useSubscription(client?: BillingClient): IUseSubscriptionReturn;
58
51
 
@@ -60,9 +53,12 @@ interface IUseUsageReturn {
60
53
  total: number | null;
61
54
  isLoading: boolean;
62
55
  error: FonderieApiError | null;
63
- refresh: () => Promise<void>;
56
+ refresh: (opts?: {
57
+ force?: boolean;
58
+ }) => Promise<void>;
59
+ recordUsage: (input: IRecordUsageInput) => Promise<void>;
64
60
  }
65
61
  declare function useUsage(metric: string): IUseUsageReturn;
66
62
  declare function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;
67
63
 
68
- export { type IUseBillingPortalReturn, type IUseCheckoutReturn, type IUsePlanAdminReturn, type IUsePlanReturn, type IUsePlansReturn, type IUseRecordUsageReturn, type IUseSubscriptionReturn, type IUseUsageReturn, useBillingPortal, useCheckout, usePlan, usePlanAdmin, usePlans, useRecordUsage, useSubscription, useUsage };
64
+ export { type IUseBillingPortalReturn, type IUseCheckoutReturn, type IUsePlanReturn, type IUsePlansReturn, type IUseSubscriptionReturn, type IUseUsageReturn, useBillingPortal, useCheckout, usePlan, usePlans, useSubscription, useUsage };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FonderieApiError, BillingClient, ICheckoutInput, IPlanDTO, ICreatePlanInput, IUpdatePlanInput, IRecordUsageInput, ISubscriptionDTO } from '@fonderie/client';
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 {
@@ -19,40 +19,33 @@ interface IUsePlanReturn {
19
19
  plan: IPlanDTO | null;
20
20
  isLoading: boolean;
21
21
  error: FonderieApiError | null;
22
- refresh: () => Promise<void>;
22
+ refresh: (opts?: {
23
+ force?: boolean;
24
+ }) => Promise<void>;
23
25
  }
24
26
  declare function usePlan(planId: string): IUsePlanReturn;
25
27
  declare function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;
26
28
 
27
- interface IUsePlanAdminReturn {
28
- createPlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;
29
- updatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;
30
- deletePlan: (planId: string) => Promise<void>;
31
- isLoading: boolean;
32
- error: FonderieApiError | null;
33
- }
34
- declare function usePlanAdmin(client?: BillingClient): IUsePlanAdminReturn;
35
-
36
29
  interface IUsePlansReturn {
37
30
  plans: IPlanDTO[];
38
31
  isLoading: boolean;
39
32
  error: FonderieApiError | null;
40
- refresh: () => Promise<void>;
33
+ refresh: (opts?: {
34
+ force?: boolean;
35
+ }) => Promise<void>;
36
+ createPlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;
37
+ updatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;
38
+ deletePlan: (planId: string) => Promise<void>;
41
39
  }
42
40
  declare function usePlans(client?: BillingClient): IUsePlansReturn;
43
41
 
44
- interface IUseRecordUsageReturn {
45
- recordUsage: (input: IRecordUsageInput) => Promise<void>;
46
- isLoading: boolean;
47
- error: FonderieApiError | null;
48
- }
49
- declare function useRecordUsage(client?: BillingClient): IUseRecordUsageReturn;
50
-
51
42
  interface IUseSubscriptionReturn {
52
43
  subscription: ISubscriptionDTO | null;
53
44
  isLoading: boolean;
54
45
  error: FonderieApiError | null;
55
- refresh: () => Promise<void>;
46
+ refresh: (opts?: {
47
+ force?: boolean;
48
+ }) => Promise<void>;
56
49
  }
57
50
  declare function useSubscription(client?: BillingClient): IUseSubscriptionReturn;
58
51
 
@@ -60,9 +53,12 @@ interface IUseUsageReturn {
60
53
  total: number | null;
61
54
  isLoading: boolean;
62
55
  error: FonderieApiError | null;
63
- refresh: () => Promise<void>;
56
+ refresh: (opts?: {
57
+ force?: boolean;
58
+ }) => Promise<void>;
59
+ recordUsage: (input: IRecordUsageInput) => Promise<void>;
64
60
  }
65
61
  declare function useUsage(metric: string): IUseUsageReturn;
66
62
  declare function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;
67
63
 
68
- export { type IUseBillingPortalReturn, type IUseCheckoutReturn, type IUsePlanAdminReturn, type IUsePlanReturn, type IUsePlansReturn, type IUseRecordUsageReturn, type IUseSubscriptionReturn, type IUseUsageReturn, useBillingPortal, useCheckout, usePlan, usePlanAdmin, usePlans, useRecordUsage, useSubscription, useUsage };
64
+ export { type IUseBillingPortalReturn, type IUseCheckoutReturn, type IUsePlanReturn, type IUsePlansReturn, type IUseSubscriptionReturn, type IUseUsageReturn, useBillingPortal, useCheckout, usePlan, usePlans, useSubscription, useUsage };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { FonderieApiError as FonderieApiError9 } from "@fonderie/client";
2
+ import { FonderieApiError as FonderieApiError7 } from "@fonderie/client";
3
3
 
4
4
  // src/hooks/useBillingPortal.ts
5
5
  import { FonderieApiError } from "@fonderie/client";
@@ -66,164 +66,129 @@ function usePlan(clientOrPlanId, maybePlanId) {
66
66
  const [plan, setPlan] = useState3(null);
67
67
  const [isLoading, setIsLoading] = useState3(true);
68
68
  const [error, setError] = useState3(null);
69
- const refresh = useCallback3(async () => {
70
- setIsLoading(true);
71
- setError(null);
72
- try {
73
- const { result } = await billing.getPlan(planId);
74
- setPlan(result.plan);
75
- } catch (err) {
76
- const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
77
- setError(apiError);
78
- } finally {
79
- setIsLoading(false);
80
- }
81
- }, [billing, planId]);
69
+ const refresh = useCallback3(
70
+ async (opts) => {
71
+ setIsLoading(true);
72
+ setError(null);
73
+ try {
74
+ const { result } = await billing.getPlan(planId, { bust: opts?.force });
75
+ setPlan(result.plan);
76
+ } catch (err) {
77
+ const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
78
+ setError(apiError);
79
+ } finally {
80
+ setIsLoading(false);
81
+ }
82
+ },
83
+ [billing, planId]
84
+ );
82
85
  useEffect(() => {
83
86
  void refresh();
84
87
  }, [refresh]);
85
88
  return { plan, isLoading, error, refresh };
86
89
  }
87
90
 
88
- // src/hooks/usePlanAdmin.ts
91
+ // src/hooks/usePlans.ts
89
92
  import { FonderieApiError as FonderieApiError4 } from "@fonderie/client";
90
93
  import { useFonderieSubClient as useFonderieSubClient4 } from "@fonderie/react";
91
- import { useCallback as useCallback4, useState as useState4 } from "react";
92
- function usePlanAdmin(client) {
93
- const billing = useFonderieSubClient4(client, (c) => c.billing, "usePlanAdmin");
94
- const [isLoading, setIsLoading] = useState4(false);
94
+ import { useCallback as useCallback4, useEffect as useEffect2, useState as useState4 } from "react";
95
+ function usePlans(client) {
96
+ const billing = useFonderieSubClient4(client, (c) => c.billing, "usePlans");
97
+ const [plans, setPlans] = useState4([]);
98
+ const [isLoading, setIsLoading] = useState4(true);
95
99
  const [error, setError] = useState4(null);
100
+ const refresh = useCallback4(
101
+ async (opts) => {
102
+ setIsLoading(true);
103
+ setError(null);
104
+ try {
105
+ const { result } = await billing.listPlans({ bust: opts?.force });
106
+ setPlans(result.plans);
107
+ } catch (err) {
108
+ const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
109
+ setError(apiError);
110
+ } finally {
111
+ setIsLoading(false);
112
+ }
113
+ },
114
+ [billing]
115
+ );
96
116
  const createPlan = useCallback4(
97
117
  async (input) => {
98
- setIsLoading(true);
99
118
  setError(null);
100
119
  try {
101
120
  const { result } = await billing.createPlan(input);
121
+ await refresh();
102
122
  return result.plan;
103
123
  } catch (err) {
104
124
  const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
105
125
  setError(apiError);
106
126
  throw apiError;
107
- } finally {
108
- setIsLoading(false);
109
127
  }
110
128
  },
111
- [billing]
129
+ [billing, refresh]
112
130
  );
113
131
  const updatePlan = useCallback4(
114
132
  async (planId, input) => {
115
- setIsLoading(true);
116
133
  setError(null);
117
134
  try {
118
135
  const { result } = await billing.updatePlan(planId, input);
136
+ await refresh();
119
137
  return result.plan;
120
138
  } catch (err) {
121
139
  const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
122
140
  setError(apiError);
123
141
  throw apiError;
124
- } finally {
125
- setIsLoading(false);
126
142
  }
127
143
  },
128
- [billing]
144
+ [billing, refresh]
129
145
  );
130
146
  const deletePlan = useCallback4(
131
147
  async (planId) => {
132
- setIsLoading(true);
133
148
  setError(null);
134
149
  try {
135
150
  await billing.deletePlan(planId);
151
+ await refresh();
136
152
  } catch (err) {
137
153
  const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
138
154
  setError(apiError);
139
155
  throw apiError;
140
- } finally {
141
- setIsLoading(false);
142
156
  }
143
157
  },
144
- [billing]
158
+ [billing, refresh]
145
159
  );
146
- return { createPlan, updatePlan, deletePlan, isLoading, error };
160
+ useEffect2(() => {
161
+ void refresh();
162
+ }, [refresh]);
163
+ return { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };
147
164
  }
148
165
 
149
- // src/hooks/usePlans.ts
166
+ // src/hooks/useSubscription.ts
150
167
  import { FonderieApiError as FonderieApiError5 } from "@fonderie/client";
151
168
  import { useFonderieSubClient as useFonderieSubClient5 } from "@fonderie/react";
152
- import { useCallback as useCallback5, useEffect as useEffect2, useState as useState5 } from "react";
153
- function usePlans(client) {
154
- const billing = useFonderieSubClient5(client, (c) => c.billing, "usePlans");
155
- const [plans, setPlans] = useState5([]);
169
+ import { useCallback as useCallback5, useEffect as useEffect3, useState as useState5 } from "react";
170
+ function useSubscription(client) {
171
+ const billing = useFonderieSubClient5(client, (c) => c.billing, "useSubscription");
172
+ const [subscription, setSubscription] = useState5(null);
156
173
  const [isLoading, setIsLoading] = useState5(true);
157
174
  const [error, setError] = useState5(null);
158
- const refresh = useCallback5(async () => {
159
- setIsLoading(true);
160
- setError(null);
161
- try {
162
- const { result } = await billing.listPlans();
163
- setPlans(result.plans);
164
- } catch (err) {
165
- const apiError = err instanceof FonderieApiError5 ? err : new FonderieApiError5("unknown", String(err), 0);
166
- setError(apiError);
167
- } finally {
168
- setIsLoading(false);
169
- }
170
- }, [billing]);
171
- useEffect2(() => {
172
- void refresh();
173
- }, [refresh]);
174
- return { plans, isLoading, error, refresh };
175
- }
176
-
177
- // src/hooks/useRecordUsage.ts
178
- import { FonderieApiError as FonderieApiError6 } from "@fonderie/client";
179
- import { useFonderieSubClient as useFonderieSubClient6 } from "@fonderie/react";
180
- import { useCallback as useCallback6, useState as useState6 } from "react";
181
- function useRecordUsage(client) {
182
- const billing = useFonderieSubClient6(client, (c) => c.billing, "useRecordUsage");
183
- const [isLoading, setIsLoading] = useState6(false);
184
- const [error, setError] = useState6(null);
185
- const recordUsage = useCallback6(
186
- async (input) => {
175
+ const refresh = useCallback5(
176
+ async (opts) => {
187
177
  setIsLoading(true);
188
178
  setError(null);
189
179
  try {
190
- await billing.recordUsage(input);
180
+ const { result } = await billing.getSubscription({ bust: opts?.force });
181
+ setSubscription(result.subscription);
191
182
  } catch (err) {
192
- const apiError = err instanceof FonderieApiError6 ? err : new FonderieApiError6("unknown", String(err), 0);
193
- setError(apiError);
194
- throw apiError;
183
+ const apiError = err instanceof FonderieApiError5 ? err : new FonderieApiError5("unknown", String(err), 0);
184
+ if (apiError.status !== 404) setError(apiError);
185
+ setSubscription(null);
195
186
  } finally {
196
187
  setIsLoading(false);
197
188
  }
198
189
  },
199
190
  [billing]
200
191
  );
201
- return { recordUsage, isLoading, error };
202
- }
203
-
204
- // src/hooks/useSubscription.ts
205
- import { FonderieApiError as FonderieApiError7 } from "@fonderie/client";
206
- import { useFonderieSubClient as useFonderieSubClient7 } from "@fonderie/react";
207
- import { useCallback as useCallback7, useEffect as useEffect3, useState as useState7 } from "react";
208
- function useSubscription(client) {
209
- const billing = useFonderieSubClient7(client, (c) => c.billing, "useSubscription");
210
- const [subscription, setSubscription] = useState7(null);
211
- const [isLoading, setIsLoading] = useState7(true);
212
- const [error, setError] = useState7(null);
213
- const refresh = useCallback7(async () => {
214
- setIsLoading(true);
215
- setError(null);
216
- try {
217
- const { result } = await billing.getSubscription();
218
- setSubscription(result.subscription);
219
- } catch (err) {
220
- const apiError = err instanceof FonderieApiError7 ? err : new FonderieApiError7("unknown", String(err), 0);
221
- if (apiError.status !== 404) setError(apiError);
222
- setSubscription(null);
223
- } finally {
224
- setIsLoading(false);
225
- }
226
- }, [billing]);
227
192
  useEffect3(() => {
228
193
  void refresh();
229
194
  }, [refresh]);
@@ -231,43 +196,58 @@ function useSubscription(client) {
231
196
  }
232
197
 
233
198
  // src/hooks/useUsage.ts
234
- import { BillingClient as BillingClient2, FonderieApiError as FonderieApiError8 } from "@fonderie/client";
235
- import { useFonderieSubClient as useFonderieSubClient8 } from "@fonderie/react";
236
- import { useCallback as useCallback8, useEffect as useEffect4, useState as useState8 } from "react";
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";
237
202
  function useUsage(clientOrMetric, maybeMetric) {
238
203
  const firstIsClient = clientOrMetric === void 0 || clientOrMetric instanceof BillingClient2;
239
204
  const explicit = firstIsClient ? clientOrMetric : void 0;
240
205
  const metric = firstIsClient ? maybeMetric : clientOrMetric;
241
- const billing = useFonderieSubClient8(explicit, (c) => c.billing, "useUsage");
242
- const [total, setTotal] = useState8(null);
243
- const [isLoading, setIsLoading] = useState8(true);
244
- const [error, setError] = useState8(null);
245
- const refresh = useCallback8(async () => {
246
- setIsLoading(true);
247
- setError(null);
248
- try {
249
- const { result } = await billing.getUsage(metric);
250
- setTotal(result.total);
251
- } catch (err) {
252
- const apiError = err instanceof FonderieApiError8 ? err : new FonderieApiError8("unknown", String(err), 0);
253
- setError(apiError);
254
- } finally {
255
- setIsLoading(false);
256
- }
257
- }, [billing, metric]);
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(
211
+ async (opts) => {
212
+ setIsLoading(true);
213
+ setError(null);
214
+ try {
215
+ const { result } = await billing.getUsage(metric, { bust: opts?.force });
216
+ setTotal(result.total);
217
+ } catch (err) {
218
+ const apiError = err instanceof FonderieApiError6 ? err : new FonderieApiError6("unknown", String(err), 0);
219
+ setError(apiError);
220
+ } finally {
221
+ setIsLoading(false);
222
+ }
223
+ },
224
+ [billing, metric]
225
+ );
226
+ const recordUsage = useCallback6(
227
+ async (input) => {
228
+ setError(null);
229
+ try {
230
+ await billing.recordUsage(input);
231
+ await refresh();
232
+ } catch (err) {
233
+ const apiError = err instanceof FonderieApiError6 ? err : new FonderieApiError6("unknown", String(err), 0);
234
+ setError(apiError);
235
+ throw apiError;
236
+ }
237
+ },
238
+ [billing, refresh]
239
+ );
258
240
  useEffect4(() => {
259
241
  void refresh();
260
242
  }, [refresh]);
261
- return { total, isLoading, error, refresh };
243
+ return { total, isLoading, error, refresh, recordUsage };
262
244
  }
263
245
  export {
264
- FonderieApiError9 as FonderieApiError,
246
+ FonderieApiError7 as FonderieApiError,
265
247
  useBillingPortal,
266
248
  useCheckout,
267
249
  usePlan,
268
- usePlanAdmin,
269
250
  usePlans,
270
- useRecordUsage,
271
251
  useSubscription,
272
252
  useUsage
273
253
  };
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: () => 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(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.getPlan(planId);\n\t\t\tsetPlan(result.plan);\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} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing, planId]);\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\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.\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 { BillingClient, IPlanDTO } 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: () => 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(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.listPlans();\n\t\t\tsetPlans(result.plans);\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} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plans, isLoading, error, refresh };\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\nexport interface IUseRecordUsageReturn {\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\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: () => 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(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.getSubscription();\n\t\t\tsetSubscription(result.subscription);\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\t// No active subscription is a normal, expected state — not an error banner.\n\t\t\tif (apiError.status !== 404) setError(apiError);\n\t\t\tsetSubscription(null);\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { subscription, isLoading, error, refresh };\n}\n","import { 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: () => 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(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.getUsage(metric);\n\t\t\tsetTotal(result.total);\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} finally {\n\t\t\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;AAEpB,EAAAG,WAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,OAAO,WAAW,OAAO,QAAQ;AAC3C;","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"],"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} from './hooks';\nexport {\n\tuseBillingPortal,\n\tuseCheckout,\n\tusePlan,\n\tusePlans,\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 {\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"],"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;AACv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AAK,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","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","BillingClient","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonderie/react-billing",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "React hooks for Fonderie billing — thin bindings over @fonderie/client.",
5
5
  "keywords": [
6
6
  "fonderiejs",