autumn-js 0.1.42 → 0.1.43
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/libraries/backend/better-auth.mjs +0 -1
- package/dist/libraries/backend/constants.mjs +0 -1
- package/dist/libraries/backend/convex.mjs +0 -1
- package/dist/libraries/backend/elysia.mjs +0 -1
- package/dist/libraries/backend/express.mjs +0 -1
- package/dist/libraries/backend/fastify.mjs +0 -1
- package/dist/libraries/backend/hono.mjs +0 -1
- package/dist/libraries/backend/index.mjs +0 -1
- package/dist/libraries/backend/next.js +3 -3500
- package/dist/libraries/backend/next.mjs +5 -3504
- package/dist/libraries/backend/react-router.mjs +0 -1
- package/dist/libraries/backend/remix_dep.mjs +0 -1
- package/dist/libraries/backend/routes/backendRouter.mjs +0 -1
- package/dist/libraries/backend/routes/entityRoutes.mjs +0 -1
- package/dist/libraries/backend/routes/genRoutes.mjs +0 -1
- package/dist/libraries/backend/routes/productRoutes.mjs +0 -1
- package/dist/libraries/backend/routes/referralRoutes.mjs +0 -1
- package/dist/libraries/backend/schemas/zod.mjs +0 -2
- package/dist/libraries/backend/supabase.mjs +0 -1
- package/dist/libraries/backend/tanstack.js +4 -96
- package/dist/libraries/backend/tanstack.mjs +1 -98
- package/dist/libraries/backend/utils/backendRes.mjs +0 -1
- package/dist/libraries/backend/utils/betterAuth/middlewares.mjs +0 -1
- package/dist/libraries/backend/utils/logBackendErrors.mjs +0 -1
- package/dist/libraries/backend/utils/secretKeyCheck.mjs +0 -1
- package/dist/libraries/backend/utils/withAuth.mjs +0 -1
- package/dist/libraries/react/{chunk-CBCX366C.mjs → chunk-MFENLDKQ.mjs} +21 -21
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +11 -11
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +11 -11
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +11 -11
- package/dist/libraries/react/components/ui/dialog.mjs +2 -2
- package/dist/libraries/react/components/ui/popover.mjs +2 -2
- package/dist/next/client/AutumnClientProvider.d.mts +2 -0
- package/dist/next/client/AutumnClientProvider.d.ts +2 -0
- package/dist/next/client/NextAutumnClient.d.mts +253 -0
- package/dist/next/client/NextAutumnClient.d.ts +253 -0
- package/dist/next/client/NextAutumnProvider.d.mts +12 -0
- package/dist/next/client/NextAutumnProvider.d.ts +12 -0
- package/dist/next/client/clientAttachTypes-BtZh00uu.d.ts +121 -0
- package/dist/next/client/clientAttachTypes-yOuJqDWt.d.mts +121 -0
- package/dist/next/client/clientEntTypes-Bsi7ciUF.d.ts +73 -0
- package/dist/next/client/clientEntTypes-aLfa3lyP.d.mts +73 -0
- package/dist/next/client/clientUtils.d.mts +19 -0
- package/dist/next/client/clientUtils.d.ts +19 -0
- package/dist/next/client/cusTypes-B-rJwpui.d.ts +123 -0
- package/dist/next/client/cusTypes-CXjHwB-c.d.mts +123 -0
- package/dist/next/client/entTypes-BkN-Puru.d.mts +22 -0
- package/dist/next/client/entTypes-DjKFS-Zk.d.ts +22 -0
- package/dist/next/client/error-DHbclCVh.d.mts +17 -0
- package/dist/next/client/error-DHbclCVh.d.ts +17 -0
- package/dist/next/client/hooks/useAutumn.d.mts +19 -0
- package/dist/next/client/hooks/useAutumn.d.ts +19 -0
- package/dist/next/client/hooks/useCustomer.d.mts +87 -0
- package/dist/next/client/hooks/useCustomer.d.ts +87 -0
- package/dist/next/client/hooks/useEntity.d.mts +33 -0
- package/dist/next/client/hooks/useEntity.d.ts +33 -0
- package/dist/next/client/hooks/usePricingTable.d.mts +34 -0
- package/dist/next/client/hooks/usePricingTable.d.ts +34 -0
- package/dist/next/client/prodTypes-B_VMILpU.d.mts +162 -0
- package/dist/next/client/prodTypes-B_VMILpU.d.ts +162 -0
- package/dist/next/client/types.d.mts +75 -0
- package/dist/next/client/types.d.ts +75 -0
- package/dist/next/server/auth/authPlugin.d.mts +13 -0
- package/dist/next/server/auth/authPlugin.d.ts +13 -0
- package/dist/next/server/auth/clerk-wrapper.d.mts +3 -0
- package/dist/next/server/auth/clerk-wrapper.d.ts +3 -0
- package/dist/next/server/auth/get-next-headers.d.mts +6 -0
- package/dist/next/server/auth/get-next-headers.d.ts +6 -0
- package/dist/next/server/auth/handleAuthProvider.d.mts +44 -0
- package/dist/next/server/auth/handleAuthProvider.d.ts +44 -0
- package/dist/next/server/auth/supabase-wrapper.d.mts +3 -0
- package/dist/next/server/auth/supabase-wrapper.d.ts +3 -0
- package/dist/next/server/auth/withNextAuth.d.mts +16 -0
- package/dist/next/server/auth/withNextAuth.d.ts +16 -0
- package/dist/next/server/componentActions.d.mts +12 -0
- package/dist/next/server/componentActions.d.ts +12 -0
- package/dist/next/server/cusActions.d.mts +633 -0
- package/dist/next/server/cusActions.d.ts +633 -0
- package/dist/next/server/cusTypes-CrLBF0Kx.d.mts +327 -0
- package/dist/next/server/cusTypes-CrLBF0Kx.d.ts +327 -0
- package/dist/next/server/genActions.d.mts +84 -0
- package/dist/next/server/genActions.d.ts +84 -0
- package/dist/next/server/response-eH4S4sg0.d.mts +29 -0
- package/dist/next/server/response-eH4S4sg0.d.ts +29 -0
- package/dist/next/server/utils.d.mts +5 -0
- package/dist/next/server/utils.d.ts +5 -0
- package/dist/utils/encryptUtils.d.mts +4 -0
- package/dist/utils/encryptUtils.d.ts +4 -0
- package/dist/utils/entityUtils.d.mts +3 -0
- package/dist/utils/entityUtils.d.ts +3 -0
- package/dist/utils/logger.d.mts +45 -0
- package/dist/utils/logger.d.ts +45 -0
- package/dist/utils/toSnakeCase.d.mts +7 -0
- package/dist/utils/toSnakeCase.d.ts +7 -0
- package/package.json +1 -1
- package/dist/libraries/backend/chunk-6DZX6EAA.mjs +0 -37
- package/dist/libraries/react/chunk-5AWCXHI3.mjs +0 -743
- package/dist/libraries/react/{chunk-BVLKOMJA.mjs → chunk-74TUFYHU.mjs} +3 -3
- package/dist/libraries/react/{chunk-AHFPBGNV.mjs → chunk-MM4LTFTB.mjs} +3 -3
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { a as AutumnPromise, R as Result, g as CheckResult, d as SetupPaymentResult, Q as QueryResult, A as AttachParams, C as CancelParams, c as CancelResult, f as CheckParams, T as TrackParams, b as TrackResult, O as OpenBillingPortalParams } from './clientAttachTypes-yOuJqDWt.mjs';
|
|
2
|
+
import { C as CheckoutResult, a as CreateReferralCodeResult, R as RedeemReferralCodeResult, A as AttachResult, b as CreateEntityParams, G as GetEntityParams } from './clientEntTypes-aLfa3lyP.mjs';
|
|
3
|
+
import { C as CustomerData, b as CreateCustomerParams, a as Customer, B as BillingPortalResult } from './cusTypes-CXjHwB-c.mjs';
|
|
4
|
+
import { E as Entity, D as DeleteEntityResult } from './entTypes-BkN-Puru.mjs';
|
|
5
|
+
import { A as AutumnError } from './error-DHbclCVh.mjs';
|
|
6
|
+
import { P as Product } from './prodTypes-B_VMILpU.mjs';
|
|
7
|
+
import 'zod/v4';
|
|
8
|
+
|
|
9
|
+
interface AutumnClientConfig {
|
|
10
|
+
backendUrl?: string;
|
|
11
|
+
getBearerToken?: () => Promise<string | null | undefined>;
|
|
12
|
+
customerData?: CustomerData;
|
|
13
|
+
includeCredentials?: boolean;
|
|
14
|
+
betterAuthUrl?: string;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
pathPrefix?: string;
|
|
17
|
+
}
|
|
18
|
+
interface IAutumnClient {
|
|
19
|
+
readonly backendUrl?: string;
|
|
20
|
+
readonly prefix: string;
|
|
21
|
+
readonly headers?: Record<string, string>;
|
|
22
|
+
readonly customerData?: CustomerData;
|
|
23
|
+
createCustomer(params: Omit<CreateCustomerParams, "id" | "data"> & {
|
|
24
|
+
errorOnNotFound?: boolean;
|
|
25
|
+
}): Promise<any>;
|
|
26
|
+
detectCors(): Promise<{
|
|
27
|
+
valid: boolean;
|
|
28
|
+
includeCredentials: boolean | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
shouldIncludeCredentials(): Promise<boolean>;
|
|
31
|
+
getHeaders(): Promise<Record<string, string>>;
|
|
32
|
+
handleFetch(options: {
|
|
33
|
+
path: string;
|
|
34
|
+
method: string;
|
|
35
|
+
body?: any;
|
|
36
|
+
}): Promise<any>;
|
|
37
|
+
post(path: string, body: any): Promise<any>;
|
|
38
|
+
get(path: string): Promise<any>;
|
|
39
|
+
delete(path: string): Promise<any>;
|
|
40
|
+
attach(args: any): Promise<any>;
|
|
41
|
+
checkout(args: any): Promise<any>;
|
|
42
|
+
cancel(args: any): Promise<any>;
|
|
43
|
+
check(args: any): Promise<any>;
|
|
44
|
+
track(args: any): Promise<any>;
|
|
45
|
+
openBillingPortal(args: any): Promise<any>;
|
|
46
|
+
setupPayment(args: any): Promise<any>;
|
|
47
|
+
query(args: any): Promise<any>;
|
|
48
|
+
entities: {
|
|
49
|
+
create(args: any): Promise<any>;
|
|
50
|
+
get(entityId: string, args: any): Promise<any>;
|
|
51
|
+
delete(args: any): Promise<any>;
|
|
52
|
+
};
|
|
53
|
+
referrals: {
|
|
54
|
+
createCode(args: any): Promise<any>;
|
|
55
|
+
redeemCode(args: any): Promise<any>;
|
|
56
|
+
};
|
|
57
|
+
products: {
|
|
58
|
+
list(): AutumnPromise<{
|
|
59
|
+
list: Product[];
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
declare class AutumnClient implements IAutumnClient {
|
|
64
|
+
readonly backendUrl?: string;
|
|
65
|
+
protected readonly getBearerToken?: () => Promise<string | null | undefined>;
|
|
66
|
+
readonly customerData?: CustomerData;
|
|
67
|
+
protected includeCredentials?: boolean;
|
|
68
|
+
readonly prefix: string;
|
|
69
|
+
readonly camelCase: boolean;
|
|
70
|
+
readonly headers?: Record<string, string>;
|
|
71
|
+
readonly framework?: string;
|
|
72
|
+
constructor({ backendUrl, getBearerToken, customerData, includeCredentials, betterAuthUrl, headers, pathPrefix, }: AutumnClientConfig);
|
|
73
|
+
/**
|
|
74
|
+
* Detects if the backend supports CORS credentials by making an OPTIONS request
|
|
75
|
+
*/
|
|
76
|
+
detectCors(): Promise<{
|
|
77
|
+
valid: boolean;
|
|
78
|
+
includeCredentials: boolean;
|
|
79
|
+
} | {
|
|
80
|
+
valid: boolean;
|
|
81
|
+
includeCredentials: undefined;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Automatically determines whether to include credentials based on CORS detection
|
|
85
|
+
*/
|
|
86
|
+
shouldIncludeCredentials(): Promise<boolean>;
|
|
87
|
+
getHeaders(): Promise<Record<string, string>>;
|
|
88
|
+
handleFetch({ path, method, body, }: {
|
|
89
|
+
path: string;
|
|
90
|
+
method: string;
|
|
91
|
+
body?: Record<string, unknown> | Record<string, unknown>[];
|
|
92
|
+
}): Promise<Result<any, AutumnError>>;
|
|
93
|
+
post(path: string, body: Record<string, unknown> | Record<string, unknown>[]): Promise<Result<any, AutumnError>>;
|
|
94
|
+
get(path: string): Promise<Result<any, AutumnError>>;
|
|
95
|
+
delete(path: string): Promise<Result<any, AutumnError>>;
|
|
96
|
+
createCustomer(params: Omit<CreateCustomerParams, "id" | "data"> & {
|
|
97
|
+
errorOnNotFound?: boolean;
|
|
98
|
+
}): Promise<Result<Customer, AutumnError>>;
|
|
99
|
+
attach: (params: {
|
|
100
|
+
productId?: string | undefined;
|
|
101
|
+
entityId?: string | undefined;
|
|
102
|
+
options?: {
|
|
103
|
+
featureId: string;
|
|
104
|
+
quantity: number;
|
|
105
|
+
}[] | undefined;
|
|
106
|
+
productIds?: string[] | undefined;
|
|
107
|
+
freeTrial?: boolean | undefined;
|
|
108
|
+
successUrl?: string | undefined;
|
|
109
|
+
metadata?: Record<string, string> | undefined;
|
|
110
|
+
forceCheckout?: boolean | undefined;
|
|
111
|
+
dialog?: any;
|
|
112
|
+
entityData?: any;
|
|
113
|
+
openInNewTab?: boolean | undefined;
|
|
114
|
+
reward?: string | undefined;
|
|
115
|
+
checkoutSessionParams?: Record<string, any> | undefined;
|
|
116
|
+
}) => AutumnPromise<{
|
|
117
|
+
customer_id: string;
|
|
118
|
+
product_ids: string[];
|
|
119
|
+
code: string;
|
|
120
|
+
message: string;
|
|
121
|
+
checkout_url?: string | undefined;
|
|
122
|
+
customer_data?: any;
|
|
123
|
+
invoice?: {
|
|
124
|
+
status: string;
|
|
125
|
+
stripe_id: string;
|
|
126
|
+
hosted_invoice_url: string | null;
|
|
127
|
+
total: number;
|
|
128
|
+
currency: string;
|
|
129
|
+
} | undefined;
|
|
130
|
+
}>;
|
|
131
|
+
checkout: (params: {
|
|
132
|
+
productId?: string | undefined;
|
|
133
|
+
productIds?: string[] | undefined;
|
|
134
|
+
entityId?: string | undefined;
|
|
135
|
+
entityData?: any;
|
|
136
|
+
options?: {
|
|
137
|
+
featureId: string;
|
|
138
|
+
quantity: number;
|
|
139
|
+
}[] | undefined;
|
|
140
|
+
successUrl?: string | undefined;
|
|
141
|
+
openInNewTab?: boolean | undefined;
|
|
142
|
+
dialog?: any;
|
|
143
|
+
forceCheckout?: boolean | undefined;
|
|
144
|
+
checkoutSessionParams?: Record<string, any> | undefined;
|
|
145
|
+
reward?: string | undefined;
|
|
146
|
+
}) => AutumnPromise<CheckoutResult>;
|
|
147
|
+
cancel: (params: {
|
|
148
|
+
productId: string;
|
|
149
|
+
entityId?: string | undefined;
|
|
150
|
+
cancelImmediately?: boolean | undefined;
|
|
151
|
+
}) => AutumnPromise<{
|
|
152
|
+
success: boolean;
|
|
153
|
+
customer_id: string;
|
|
154
|
+
product_id: string;
|
|
155
|
+
}>;
|
|
156
|
+
check: (params: {
|
|
157
|
+
featureId?: string | undefined;
|
|
158
|
+
productId?: string | undefined;
|
|
159
|
+
entityId?: string | undefined;
|
|
160
|
+
requiredBalance?: number | undefined;
|
|
161
|
+
sendEvent?: boolean | undefined;
|
|
162
|
+
withPreview?: boolean | undefined;
|
|
163
|
+
dialog?: any;
|
|
164
|
+
entityData?: any;
|
|
165
|
+
properties?: Record<string, any> | undefined;
|
|
166
|
+
}) => AutumnPromise<CheckResult>;
|
|
167
|
+
track: (params: {
|
|
168
|
+
featureId?: string | undefined;
|
|
169
|
+
eventName?: string | undefined;
|
|
170
|
+
entityId?: string | undefined;
|
|
171
|
+
value?: number | undefined;
|
|
172
|
+
idempotencyKey?: string | undefined;
|
|
173
|
+
entityData?: any;
|
|
174
|
+
}) => AutumnPromise<{
|
|
175
|
+
id: string;
|
|
176
|
+
code: string;
|
|
177
|
+
customer_id: string;
|
|
178
|
+
feature_id?: string | undefined;
|
|
179
|
+
event_name?: string | undefined;
|
|
180
|
+
}>;
|
|
181
|
+
openBillingPortal: (params?: {
|
|
182
|
+
returnUrl?: string | undefined;
|
|
183
|
+
openInNewTab?: boolean | undefined;
|
|
184
|
+
} | undefined) => AutumnPromise<BillingPortalResult>;
|
|
185
|
+
setupPayment: (params: {
|
|
186
|
+
successUrl?: string | undefined;
|
|
187
|
+
checkoutSessionParams?: Record<string, any> | undefined;
|
|
188
|
+
openInNewTab?: boolean | undefined;
|
|
189
|
+
}) => AutumnPromise<SetupPaymentResult>;
|
|
190
|
+
query: (params: {
|
|
191
|
+
featureId: string | string[];
|
|
192
|
+
range?: "24h" | "7d" | "30d" | "90d" | "last_cycle" | undefined;
|
|
193
|
+
}) => AutumnPromise<QueryResult>;
|
|
194
|
+
entities: {
|
|
195
|
+
create: (params: {
|
|
196
|
+
id: string;
|
|
197
|
+
featureId: string;
|
|
198
|
+
name?: string | undefined;
|
|
199
|
+
} | {
|
|
200
|
+
id: string;
|
|
201
|
+
featureId: string;
|
|
202
|
+
name?: string | undefined;
|
|
203
|
+
}[]) => AutumnPromise<Entity | Entity[]>;
|
|
204
|
+
get: (entityId: string, params?: {
|
|
205
|
+
expand?: string[] | undefined;
|
|
206
|
+
} | undefined) => AutumnPromise<Entity>;
|
|
207
|
+
delete: (entityId: string) => AutumnPromise<DeleteEntityResult>;
|
|
208
|
+
};
|
|
209
|
+
referrals: {
|
|
210
|
+
createCode: (params: {
|
|
211
|
+
programId: string;
|
|
212
|
+
}) => AutumnPromise<CreateReferralCodeResult>;
|
|
213
|
+
redeemCode: (params: {
|
|
214
|
+
code: string;
|
|
215
|
+
}) => AutumnPromise<RedeemReferralCodeResult>;
|
|
216
|
+
};
|
|
217
|
+
products: {
|
|
218
|
+
list: () => AutumnPromise<{
|
|
219
|
+
list: Product[];
|
|
220
|
+
}>;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
interface ErrorResponse {
|
|
225
|
+
message: string;
|
|
226
|
+
code: string;
|
|
227
|
+
}
|
|
228
|
+
type OmitCustomerType = "id" | "name" | "email" | "fingerprint" | "customer_id";
|
|
229
|
+
interface NextAutumnClientConfig {
|
|
230
|
+
encryptedCustomerId?: string;
|
|
231
|
+
customerData?: CustomerData;
|
|
232
|
+
}
|
|
233
|
+
declare class NextAutumnClient extends AutumnClient {
|
|
234
|
+
private readonly encryptedCustomerId?;
|
|
235
|
+
constructor({ encryptedCustomerId, customerData }: NextAutumnClientConfig);
|
|
236
|
+
createCustomer(params: Omit<CreateCustomerParams, "id" | "data"> & {
|
|
237
|
+
errorOnNotFound?: boolean;
|
|
238
|
+
}): Promise<any>;
|
|
239
|
+
getPricingTable(): Promise<any>;
|
|
240
|
+
attach: (params: AttachParams) => AutumnPromise<AttachResult>;
|
|
241
|
+
cancel: (params: CancelParams) => AutumnPromise<CancelResult>;
|
|
242
|
+
check: (params: CheckParams) => AutumnPromise<CheckResult>;
|
|
243
|
+
track: (params: TrackParams) => AutumnPromise<TrackResult>;
|
|
244
|
+
openBillingPortal: (params?: OpenBillingPortalParams | undefined) => Promise<any>;
|
|
245
|
+
entities: {
|
|
246
|
+
create: (params: CreateEntityParams | CreateEntityParams[]) => AutumnPromise<Entity | Entity[]>;
|
|
247
|
+
get: (entityId: string, params?: GetEntityParams) => AutumnPromise<Entity>;
|
|
248
|
+
delete: (entityId: string) => AutumnPromise<DeleteEntityResult>;
|
|
249
|
+
};
|
|
250
|
+
referrals: any;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export { type ErrorResponse, NextAutumnClient, type NextAutumnClientConfig, type OmitCustomerType };
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { a as AutumnPromise, R as Result, g as CheckResult, d as SetupPaymentResult, Q as QueryResult, A as AttachParams, C as CancelParams, c as CancelResult, f as CheckParams, T as TrackParams, b as TrackResult, O as OpenBillingPortalParams } from './clientAttachTypes-BtZh00uu.js';
|
|
2
|
+
import { C as CheckoutResult, a as CreateReferralCodeResult, R as RedeemReferralCodeResult, A as AttachResult, b as CreateEntityParams, G as GetEntityParams } from './clientEntTypes-Bsi7ciUF.js';
|
|
3
|
+
import { C as CustomerData, b as CreateCustomerParams, a as Customer, B as BillingPortalResult } from './cusTypes-B-rJwpui.js';
|
|
4
|
+
import { E as Entity, D as DeleteEntityResult } from './entTypes-DjKFS-Zk.js';
|
|
5
|
+
import { A as AutumnError } from './error-DHbclCVh.js';
|
|
6
|
+
import { P as Product } from './prodTypes-B_VMILpU.js';
|
|
7
|
+
import 'zod/v4';
|
|
8
|
+
|
|
9
|
+
interface AutumnClientConfig {
|
|
10
|
+
backendUrl?: string;
|
|
11
|
+
getBearerToken?: () => Promise<string | null | undefined>;
|
|
12
|
+
customerData?: CustomerData;
|
|
13
|
+
includeCredentials?: boolean;
|
|
14
|
+
betterAuthUrl?: string;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
pathPrefix?: string;
|
|
17
|
+
}
|
|
18
|
+
interface IAutumnClient {
|
|
19
|
+
readonly backendUrl?: string;
|
|
20
|
+
readonly prefix: string;
|
|
21
|
+
readonly headers?: Record<string, string>;
|
|
22
|
+
readonly customerData?: CustomerData;
|
|
23
|
+
createCustomer(params: Omit<CreateCustomerParams, "id" | "data"> & {
|
|
24
|
+
errorOnNotFound?: boolean;
|
|
25
|
+
}): Promise<any>;
|
|
26
|
+
detectCors(): Promise<{
|
|
27
|
+
valid: boolean;
|
|
28
|
+
includeCredentials: boolean | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
shouldIncludeCredentials(): Promise<boolean>;
|
|
31
|
+
getHeaders(): Promise<Record<string, string>>;
|
|
32
|
+
handleFetch(options: {
|
|
33
|
+
path: string;
|
|
34
|
+
method: string;
|
|
35
|
+
body?: any;
|
|
36
|
+
}): Promise<any>;
|
|
37
|
+
post(path: string, body: any): Promise<any>;
|
|
38
|
+
get(path: string): Promise<any>;
|
|
39
|
+
delete(path: string): Promise<any>;
|
|
40
|
+
attach(args: any): Promise<any>;
|
|
41
|
+
checkout(args: any): Promise<any>;
|
|
42
|
+
cancel(args: any): Promise<any>;
|
|
43
|
+
check(args: any): Promise<any>;
|
|
44
|
+
track(args: any): Promise<any>;
|
|
45
|
+
openBillingPortal(args: any): Promise<any>;
|
|
46
|
+
setupPayment(args: any): Promise<any>;
|
|
47
|
+
query(args: any): Promise<any>;
|
|
48
|
+
entities: {
|
|
49
|
+
create(args: any): Promise<any>;
|
|
50
|
+
get(entityId: string, args: any): Promise<any>;
|
|
51
|
+
delete(args: any): Promise<any>;
|
|
52
|
+
};
|
|
53
|
+
referrals: {
|
|
54
|
+
createCode(args: any): Promise<any>;
|
|
55
|
+
redeemCode(args: any): Promise<any>;
|
|
56
|
+
};
|
|
57
|
+
products: {
|
|
58
|
+
list(): AutumnPromise<{
|
|
59
|
+
list: Product[];
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
declare class AutumnClient implements IAutumnClient {
|
|
64
|
+
readonly backendUrl?: string;
|
|
65
|
+
protected readonly getBearerToken?: () => Promise<string | null | undefined>;
|
|
66
|
+
readonly customerData?: CustomerData;
|
|
67
|
+
protected includeCredentials?: boolean;
|
|
68
|
+
readonly prefix: string;
|
|
69
|
+
readonly camelCase: boolean;
|
|
70
|
+
readonly headers?: Record<string, string>;
|
|
71
|
+
readonly framework?: string;
|
|
72
|
+
constructor({ backendUrl, getBearerToken, customerData, includeCredentials, betterAuthUrl, headers, pathPrefix, }: AutumnClientConfig);
|
|
73
|
+
/**
|
|
74
|
+
* Detects if the backend supports CORS credentials by making an OPTIONS request
|
|
75
|
+
*/
|
|
76
|
+
detectCors(): Promise<{
|
|
77
|
+
valid: boolean;
|
|
78
|
+
includeCredentials: boolean;
|
|
79
|
+
} | {
|
|
80
|
+
valid: boolean;
|
|
81
|
+
includeCredentials: undefined;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Automatically determines whether to include credentials based on CORS detection
|
|
85
|
+
*/
|
|
86
|
+
shouldIncludeCredentials(): Promise<boolean>;
|
|
87
|
+
getHeaders(): Promise<Record<string, string>>;
|
|
88
|
+
handleFetch({ path, method, body, }: {
|
|
89
|
+
path: string;
|
|
90
|
+
method: string;
|
|
91
|
+
body?: Record<string, unknown> | Record<string, unknown>[];
|
|
92
|
+
}): Promise<Result<any, AutumnError>>;
|
|
93
|
+
post(path: string, body: Record<string, unknown> | Record<string, unknown>[]): Promise<Result<any, AutumnError>>;
|
|
94
|
+
get(path: string): Promise<Result<any, AutumnError>>;
|
|
95
|
+
delete(path: string): Promise<Result<any, AutumnError>>;
|
|
96
|
+
createCustomer(params: Omit<CreateCustomerParams, "id" | "data"> & {
|
|
97
|
+
errorOnNotFound?: boolean;
|
|
98
|
+
}): Promise<Result<Customer, AutumnError>>;
|
|
99
|
+
attach: (params: {
|
|
100
|
+
productId?: string | undefined;
|
|
101
|
+
entityId?: string | undefined;
|
|
102
|
+
options?: {
|
|
103
|
+
featureId: string;
|
|
104
|
+
quantity: number;
|
|
105
|
+
}[] | undefined;
|
|
106
|
+
productIds?: string[] | undefined;
|
|
107
|
+
freeTrial?: boolean | undefined;
|
|
108
|
+
successUrl?: string | undefined;
|
|
109
|
+
metadata?: Record<string, string> | undefined;
|
|
110
|
+
forceCheckout?: boolean | undefined;
|
|
111
|
+
dialog?: any;
|
|
112
|
+
entityData?: any;
|
|
113
|
+
openInNewTab?: boolean | undefined;
|
|
114
|
+
reward?: string | undefined;
|
|
115
|
+
checkoutSessionParams?: Record<string, any> | undefined;
|
|
116
|
+
}) => AutumnPromise<{
|
|
117
|
+
customer_id: string;
|
|
118
|
+
product_ids: string[];
|
|
119
|
+
code: string;
|
|
120
|
+
message: string;
|
|
121
|
+
checkout_url?: string | undefined;
|
|
122
|
+
customer_data?: any;
|
|
123
|
+
invoice?: {
|
|
124
|
+
status: string;
|
|
125
|
+
stripe_id: string;
|
|
126
|
+
hosted_invoice_url: string | null;
|
|
127
|
+
total: number;
|
|
128
|
+
currency: string;
|
|
129
|
+
} | undefined;
|
|
130
|
+
}>;
|
|
131
|
+
checkout: (params: {
|
|
132
|
+
productId?: string | undefined;
|
|
133
|
+
productIds?: string[] | undefined;
|
|
134
|
+
entityId?: string | undefined;
|
|
135
|
+
entityData?: any;
|
|
136
|
+
options?: {
|
|
137
|
+
featureId: string;
|
|
138
|
+
quantity: number;
|
|
139
|
+
}[] | undefined;
|
|
140
|
+
successUrl?: string | undefined;
|
|
141
|
+
openInNewTab?: boolean | undefined;
|
|
142
|
+
dialog?: any;
|
|
143
|
+
forceCheckout?: boolean | undefined;
|
|
144
|
+
checkoutSessionParams?: Record<string, any> | undefined;
|
|
145
|
+
reward?: string | undefined;
|
|
146
|
+
}) => AutumnPromise<CheckoutResult>;
|
|
147
|
+
cancel: (params: {
|
|
148
|
+
productId: string;
|
|
149
|
+
entityId?: string | undefined;
|
|
150
|
+
cancelImmediately?: boolean | undefined;
|
|
151
|
+
}) => AutumnPromise<{
|
|
152
|
+
success: boolean;
|
|
153
|
+
customer_id: string;
|
|
154
|
+
product_id: string;
|
|
155
|
+
}>;
|
|
156
|
+
check: (params: {
|
|
157
|
+
featureId?: string | undefined;
|
|
158
|
+
productId?: string | undefined;
|
|
159
|
+
entityId?: string | undefined;
|
|
160
|
+
requiredBalance?: number | undefined;
|
|
161
|
+
sendEvent?: boolean | undefined;
|
|
162
|
+
withPreview?: boolean | undefined;
|
|
163
|
+
dialog?: any;
|
|
164
|
+
entityData?: any;
|
|
165
|
+
properties?: Record<string, any> | undefined;
|
|
166
|
+
}) => AutumnPromise<CheckResult>;
|
|
167
|
+
track: (params: {
|
|
168
|
+
featureId?: string | undefined;
|
|
169
|
+
eventName?: string | undefined;
|
|
170
|
+
entityId?: string | undefined;
|
|
171
|
+
value?: number | undefined;
|
|
172
|
+
idempotencyKey?: string | undefined;
|
|
173
|
+
entityData?: any;
|
|
174
|
+
}) => AutumnPromise<{
|
|
175
|
+
id: string;
|
|
176
|
+
code: string;
|
|
177
|
+
customer_id: string;
|
|
178
|
+
feature_id?: string | undefined;
|
|
179
|
+
event_name?: string | undefined;
|
|
180
|
+
}>;
|
|
181
|
+
openBillingPortal: (params?: {
|
|
182
|
+
returnUrl?: string | undefined;
|
|
183
|
+
openInNewTab?: boolean | undefined;
|
|
184
|
+
} | undefined) => AutumnPromise<BillingPortalResult>;
|
|
185
|
+
setupPayment: (params: {
|
|
186
|
+
successUrl?: string | undefined;
|
|
187
|
+
checkoutSessionParams?: Record<string, any> | undefined;
|
|
188
|
+
openInNewTab?: boolean | undefined;
|
|
189
|
+
}) => AutumnPromise<SetupPaymentResult>;
|
|
190
|
+
query: (params: {
|
|
191
|
+
featureId: string | string[];
|
|
192
|
+
range?: "24h" | "7d" | "30d" | "90d" | "last_cycle" | undefined;
|
|
193
|
+
}) => AutumnPromise<QueryResult>;
|
|
194
|
+
entities: {
|
|
195
|
+
create: (params: {
|
|
196
|
+
id: string;
|
|
197
|
+
featureId: string;
|
|
198
|
+
name?: string | undefined;
|
|
199
|
+
} | {
|
|
200
|
+
id: string;
|
|
201
|
+
featureId: string;
|
|
202
|
+
name?: string | undefined;
|
|
203
|
+
}[]) => AutumnPromise<Entity | Entity[]>;
|
|
204
|
+
get: (entityId: string, params?: {
|
|
205
|
+
expand?: string[] | undefined;
|
|
206
|
+
} | undefined) => AutumnPromise<Entity>;
|
|
207
|
+
delete: (entityId: string) => AutumnPromise<DeleteEntityResult>;
|
|
208
|
+
};
|
|
209
|
+
referrals: {
|
|
210
|
+
createCode: (params: {
|
|
211
|
+
programId: string;
|
|
212
|
+
}) => AutumnPromise<CreateReferralCodeResult>;
|
|
213
|
+
redeemCode: (params: {
|
|
214
|
+
code: string;
|
|
215
|
+
}) => AutumnPromise<RedeemReferralCodeResult>;
|
|
216
|
+
};
|
|
217
|
+
products: {
|
|
218
|
+
list: () => AutumnPromise<{
|
|
219
|
+
list: Product[];
|
|
220
|
+
}>;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
interface ErrorResponse {
|
|
225
|
+
message: string;
|
|
226
|
+
code: string;
|
|
227
|
+
}
|
|
228
|
+
type OmitCustomerType = "id" | "name" | "email" | "fingerprint" | "customer_id";
|
|
229
|
+
interface NextAutumnClientConfig {
|
|
230
|
+
encryptedCustomerId?: string;
|
|
231
|
+
customerData?: CustomerData;
|
|
232
|
+
}
|
|
233
|
+
declare class NextAutumnClient extends AutumnClient {
|
|
234
|
+
private readonly encryptedCustomerId?;
|
|
235
|
+
constructor({ encryptedCustomerId, customerData }: NextAutumnClientConfig);
|
|
236
|
+
createCustomer(params: Omit<CreateCustomerParams, "id" | "data"> & {
|
|
237
|
+
errorOnNotFound?: boolean;
|
|
238
|
+
}): Promise<any>;
|
|
239
|
+
getPricingTable(): Promise<any>;
|
|
240
|
+
attach: (params: AttachParams) => AutumnPromise<AttachResult>;
|
|
241
|
+
cancel: (params: CancelParams) => AutumnPromise<CancelResult>;
|
|
242
|
+
check: (params: CheckParams) => AutumnPromise<CheckResult>;
|
|
243
|
+
track: (params: TrackParams) => AutumnPromise<TrackResult>;
|
|
244
|
+
openBillingPortal: (params?: OpenBillingPortalParams | undefined) => Promise<any>;
|
|
245
|
+
entities: {
|
|
246
|
+
create: (params: CreateEntityParams | CreateEntityParams[]) => AutumnPromise<Entity | Entity[]>;
|
|
247
|
+
get: (entityId: string, params?: GetEntityParams) => AutumnPromise<Entity>;
|
|
248
|
+
delete: (entityId: string) => AutumnPromise<DeleteEntityResult>;
|
|
249
|
+
};
|
|
250
|
+
referrals: any;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export { type ErrorResponse, NextAutumnClient, type NextAutumnClientConfig, type OmitCustomerType };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { C as CustomerData } from './cusTypes-CXjHwB-c.mjs';
|
|
3
|
+
import './prodTypes-B_VMILpU.mjs';
|
|
4
|
+
import 'zod/v4';
|
|
5
|
+
|
|
6
|
+
declare const NextAutumnProvider: ({ encryptedCustomerId, customerData, children, }: {
|
|
7
|
+
encryptedCustomerId?: string;
|
|
8
|
+
customerData?: CustomerData;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { NextAutumnProvider };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { C as CustomerData } from './cusTypes-B-rJwpui.js';
|
|
3
|
+
import './prodTypes-B_VMILpU.js';
|
|
4
|
+
import 'zod/v4';
|
|
5
|
+
|
|
6
|
+
declare const NextAutumnProvider: ({ encryptedCustomerId, customerData, children, }: {
|
|
7
|
+
encryptedCustomerId?: string;
|
|
8
|
+
customerData?: CustomerData;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { NextAutumnProvider };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { C as CheckFeatureResult, c as CheckProductResult } from './prodTypes-B_VMILpU.js';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
import { A as AutumnError } from './error-DHbclCVh.js';
|
|
4
|
+
|
|
5
|
+
declare const CancelResultSchema: z.ZodObject<{
|
|
6
|
+
success: z.ZodBoolean;
|
|
7
|
+
customer_id: z.ZodString;
|
|
8
|
+
product_id: z.ZodString;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type CancelResult = z.infer<typeof CancelResultSchema>;
|
|
11
|
+
declare const TrackResultSchema: z.ZodObject<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
code: z.ZodString;
|
|
14
|
+
customer_id: z.ZodString;
|
|
15
|
+
feature_id: z.ZodOptional<z.ZodString>;
|
|
16
|
+
event_name: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
type TrackResult = z.infer<typeof TrackResultSchema>;
|
|
19
|
+
type CheckResult = CheckFeatureResult & CheckProductResult;
|
|
20
|
+
interface SetupPaymentResult {
|
|
21
|
+
customer_id: string;
|
|
22
|
+
url: string;
|
|
23
|
+
}
|
|
24
|
+
type QueryResult = {
|
|
25
|
+
list: Array<{
|
|
26
|
+
period: number;
|
|
27
|
+
} & {
|
|
28
|
+
[key: string]: number;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type Success<T> = {
|
|
33
|
+
data: T;
|
|
34
|
+
error: null;
|
|
35
|
+
statusCode?: number;
|
|
36
|
+
};
|
|
37
|
+
type Failure<E> = {
|
|
38
|
+
data: null;
|
|
39
|
+
error: E;
|
|
40
|
+
statusCode?: number;
|
|
41
|
+
};
|
|
42
|
+
type Result<T, E> = Success<T> | Failure<E>;
|
|
43
|
+
type AutumnPromise<T> = Promise<Result<T, AutumnError>>;
|
|
44
|
+
|
|
45
|
+
declare const CancelParamsSchema: z.ZodObject<{
|
|
46
|
+
productId: z.ZodString;
|
|
47
|
+
entityId: z.ZodOptional<z.ZodString>;
|
|
48
|
+
cancelImmediately: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
type CancelParams = z.infer<typeof CancelParamsSchema>;
|
|
51
|
+
declare const CheckParamsSchema: z.ZodObject<{
|
|
52
|
+
featureId: z.ZodOptional<z.ZodString>;
|
|
53
|
+
productId: z.ZodOptional<z.ZodString>;
|
|
54
|
+
entityId: z.ZodOptional<z.ZodString>;
|
|
55
|
+
requiredBalance: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
sendEvent: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
withPreview: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
+
dialog: z.ZodOptional<z.ZodAny>;
|
|
59
|
+
entityData: z.ZodOptional<z.ZodAny>;
|
|
60
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
type CheckParams = z.infer<typeof CheckParamsSchema>;
|
|
63
|
+
declare const TrackParamsSchema: z.ZodObject<{
|
|
64
|
+
featureId: z.ZodOptional<z.ZodString>;
|
|
65
|
+
eventName: z.ZodOptional<z.ZodString>;
|
|
66
|
+
entityId: z.ZodOptional<z.ZodString>;
|
|
67
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
69
|
+
entityData: z.ZodOptional<z.ZodAny>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
type TrackParams = z.infer<typeof TrackParamsSchema>;
|
|
72
|
+
declare const OpenBillingPortalParamsSchema: z.ZodObject<{
|
|
73
|
+
returnUrl: z.ZodOptional<z.ZodString>;
|
|
74
|
+
openInNewTab: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
type OpenBillingPortalParams = z.infer<typeof OpenBillingPortalParamsSchema>;
|
|
77
|
+
declare const SetupPaymentParamsSchema: z.ZodObject<{
|
|
78
|
+
successUrl: z.ZodOptional<z.ZodString>;
|
|
79
|
+
checkoutSessionParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
80
|
+
openInNewTab: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
type SetupPaymentParams = z.infer<typeof SetupPaymentParamsSchema>;
|
|
83
|
+
|
|
84
|
+
declare const AttachParamsSchema: z.ZodObject<{
|
|
85
|
+
productId: z.ZodOptional<z.ZodString>;
|
|
86
|
+
entityId: z.ZodOptional<z.ZodString>;
|
|
87
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
88
|
+
featureId: z.ZodString;
|
|
89
|
+
quantity: z.ZodNumber;
|
|
90
|
+
}, z.core.$strip>>>;
|
|
91
|
+
productIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
92
|
+
freeTrial: z.ZodOptional<z.ZodBoolean>;
|
|
93
|
+
successUrl: z.ZodOptional<z.ZodString>;
|
|
94
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
95
|
+
forceCheckout: z.ZodOptional<z.ZodBoolean>;
|
|
96
|
+
dialog: z.ZodOptional<z.ZodAny>;
|
|
97
|
+
entityData: z.ZodOptional<z.ZodAny>;
|
|
98
|
+
openInNewTab: z.ZodOptional<z.ZodBoolean>;
|
|
99
|
+
reward: z.ZodOptional<z.ZodString>;
|
|
100
|
+
checkoutSessionParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
type AttachParams = z.infer<typeof AttachParamsSchema>;
|
|
103
|
+
declare const CheckoutParamsSchema: z.ZodObject<{
|
|
104
|
+
productId: z.ZodOptional<z.ZodString>;
|
|
105
|
+
productIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
106
|
+
entityId: z.ZodOptional<z.ZodString>;
|
|
107
|
+
entityData: z.ZodOptional<z.ZodAny>;
|
|
108
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
109
|
+
featureId: z.ZodString;
|
|
110
|
+
quantity: z.ZodNumber;
|
|
111
|
+
}, z.core.$strip>>>;
|
|
112
|
+
successUrl: z.ZodOptional<z.ZodString>;
|
|
113
|
+
openInNewTab: z.ZodOptional<z.ZodBoolean>;
|
|
114
|
+
dialog: z.ZodOptional<z.ZodAny>;
|
|
115
|
+
forceCheckout: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
checkoutSessionParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
117
|
+
reward: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
type CheckoutParams = z.infer<typeof CheckoutParamsSchema>;
|
|
120
|
+
|
|
121
|
+
export type { AttachParams as A, CancelParams as C, OpenBillingPortalParams as O, QueryResult as Q, Result as R, SetupPaymentParams as S, TrackParams as T, AutumnPromise as a, TrackResult as b, CancelResult as c, SetupPaymentResult as d, CheckoutParams as e, CheckParams as f, CheckResult as g, Success as h };
|