@feelflow/ffid-sdk 1.18.0 → 1.19.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/{chunk-ZJIZTYXQ.js → chunk-3IV7STDJ.js} +118 -1
- package/dist/{chunk-THHBQAFX.cjs → chunk-543CO3HP.cjs} +118 -1
- package/dist/components/index.cjs +7 -7
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/{index-BHh-uxYS.d.cts → index-p4dJw3qR.d.cts} +4 -6
- package/dist/{index-BHh-uxYS.d.ts → index-p4dJw3qR.d.ts} +4 -6
- package/dist/index.cjs +22 -22
- package/dist/index.d.cts +196 -3
- package/dist/index.d.ts +196 -3
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +118 -1
- package/dist/server/index.d.cts +196 -5
- package/dist/server/index.d.ts +196 -5
- package/dist/server/index.js +118 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as
|
|
2
|
-
export {
|
|
1
|
+
import { F as FFIDSubscriptionStatus, a as FFIDConfig, b as FFIDApiResponse, c as FFIDSessionResponse, d as FFIDRedirectResult, e as FFIDError, f as FFIDSubscriptionCheckResponse, g as FFIDListMembersResponse, h as FFIDMemberRole, i as FFIDUpdateMemberRoleResponse, j as FFIDRemoveMemberResponse, k as FFIDCreateCheckoutParams, l as FFIDCheckoutSessionResponse, m as FFIDCreatePortalParams, n as FFIDPortalSessionResponse, o as FFIDVerifyAccessTokenOptions, p as FFIDOAuthUserInfo, q as FFIDAuthMode, r as FFIDLogger, s as FFIDCacheAdapter, t as FFIDUser, u as FFIDOrganization, v as FFIDSubscription, w as FFIDSubscriptionContextValue, x as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, y as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, z as FFIDAnnouncementsLogger } from './index-p4dJw3qR.cjs';
|
|
2
|
+
export { B as Announcement, C as AnnouncementStatus, D as AnnouncementType, E as FFIDAnnouncementBadge, G as FFIDAnnouncementList, H as FFIDAnnouncementsError, I as FFIDAnnouncementsErrorCode, J as FFIDAnnouncementsServerResponse, K as FFIDCacheConfig, M as FFIDContextValue, N as FFIDJwtClaims, O as FFIDLoginButton, P as FFIDMemberStatus, Q as FFIDOAuthTokenResponse, R as FFIDOAuthUserInfoMemberRole, S as FFIDOAuthUserInfoSubscription, T as FFIDOrganizationMember, U as FFIDOrganizationSwitcher, V as FFIDSeatModel, W as FFIDSubscriptionBadge, X as FFIDTokenIntrospectionResponse, Y as FFIDUserMenu, Z as UseFFIDAnnouncementsOptions, _ as UseFFIDAnnouncementsReturn, $ as useFFIDAnnouncements } from './index-p4dJw3qR.cjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode, ComponentType, FC } from 'react';
|
|
5
5
|
|
|
@@ -92,6 +92,193 @@ declare function storeCodeVerifier(verifier: string, logger?: PKCELogger): boole
|
|
|
92
92
|
*/
|
|
93
93
|
declare function retrieveCodeVerifier(logger?: PKCELogger): string | null;
|
|
94
94
|
|
|
95
|
+
/** Billing interval for subscriptions */
|
|
96
|
+
type FFIDBillingInterval = 'monthly' | 'yearly';
|
|
97
|
+
/** Service information returned by plans endpoint */
|
|
98
|
+
interface FFIDServiceInfo {
|
|
99
|
+
id: string;
|
|
100
|
+
code: string;
|
|
101
|
+
name: string;
|
|
102
|
+
description: string | null;
|
|
103
|
+
isActive: boolean;
|
|
104
|
+
createdAt: string;
|
|
105
|
+
plans: FFIDPlanInfo[];
|
|
106
|
+
}
|
|
107
|
+
/** Plan information returned by plans endpoint */
|
|
108
|
+
interface FFIDPlanInfo {
|
|
109
|
+
id: string;
|
|
110
|
+
serviceId: string;
|
|
111
|
+
code: string;
|
|
112
|
+
name: string;
|
|
113
|
+
description: string | null;
|
|
114
|
+
minSeats: number;
|
|
115
|
+
maxSeats: number | null;
|
|
116
|
+
trialDays: number;
|
|
117
|
+
priceMonthly: number;
|
|
118
|
+
priceYearly: number | null;
|
|
119
|
+
currency: string;
|
|
120
|
+
isActive: boolean;
|
|
121
|
+
displayOrder: number;
|
|
122
|
+
customPricing: boolean;
|
|
123
|
+
createdAt: string;
|
|
124
|
+
}
|
|
125
|
+
/** Response from list plans endpoint */
|
|
126
|
+
interface FFIDListPlansResponse {
|
|
127
|
+
services: FFIDServiceInfo[];
|
|
128
|
+
count: number;
|
|
129
|
+
}
|
|
130
|
+
/** Subscription details returned by ext API (sanitized, no Stripe IDs) */
|
|
131
|
+
interface FFIDSubscriptionDetail {
|
|
132
|
+
id: string;
|
|
133
|
+
organizationId: string;
|
|
134
|
+
organizationName: string;
|
|
135
|
+
serviceCode: string;
|
|
136
|
+
serviceName: string;
|
|
137
|
+
planCode: string;
|
|
138
|
+
planName: string;
|
|
139
|
+
status: FFIDSubscriptionStatus;
|
|
140
|
+
paymentMethod: string | null;
|
|
141
|
+
billingInterval: FFIDBillingInterval;
|
|
142
|
+
quantity: number;
|
|
143
|
+
currentPeriodStart: string | null;
|
|
144
|
+
currentPeriodEnd: string | null;
|
|
145
|
+
trialStart: string | null;
|
|
146
|
+
trialEnd: string | null;
|
|
147
|
+
canceledAt: string | null;
|
|
148
|
+
cancelAtPeriodEnd: boolean;
|
|
149
|
+
createdAt: string;
|
|
150
|
+
}
|
|
151
|
+
/** Parameters for subscribing to a plan */
|
|
152
|
+
interface FFIDSubscribeParams {
|
|
153
|
+
/** Organization ID (UUID) */
|
|
154
|
+
organizationId: string;
|
|
155
|
+
/** Plan code (e.g., 'free', 'basic', 'pro') */
|
|
156
|
+
planCode: string;
|
|
157
|
+
/** Billing interval (default: 'monthly') */
|
|
158
|
+
billingInterval?: FFIDBillingInterval;
|
|
159
|
+
/** Number of seats (default: plan's minSeats) */
|
|
160
|
+
quantity?: number;
|
|
161
|
+
/** User ID for seat auto-assignment (only needed for service-key mode) */
|
|
162
|
+
userId?: string;
|
|
163
|
+
}
|
|
164
|
+
/** Sanitized subscription fields returned by subscribe/reactivate endpoints (no Stripe IDs) */
|
|
165
|
+
interface FFIDSubscriptionSummary {
|
|
166
|
+
id: string;
|
|
167
|
+
organizationId: string;
|
|
168
|
+
serviceId: string;
|
|
169
|
+
planId: string;
|
|
170
|
+
status: FFIDSubscriptionStatus;
|
|
171
|
+
paymentMethod: string | null;
|
|
172
|
+
billingInterval: FFIDBillingInterval;
|
|
173
|
+
quantity: number;
|
|
174
|
+
currentPeriodStart: string | null;
|
|
175
|
+
currentPeriodEnd: string | null;
|
|
176
|
+
trialStart: string | null;
|
|
177
|
+
trialEnd: string | null;
|
|
178
|
+
canceledAt: string | null;
|
|
179
|
+
cancelAtPeriodEnd: boolean;
|
|
180
|
+
createdAt: string;
|
|
181
|
+
}
|
|
182
|
+
/** Response from subscribe endpoint */
|
|
183
|
+
interface FFIDSubscribeResponse {
|
|
184
|
+
subscription: FFIDSubscriptionSummary;
|
|
185
|
+
service: {
|
|
186
|
+
id: string;
|
|
187
|
+
code: string;
|
|
188
|
+
name: string;
|
|
189
|
+
};
|
|
190
|
+
plan: {
|
|
191
|
+
id: string;
|
|
192
|
+
code: string;
|
|
193
|
+
name: string;
|
|
194
|
+
priceMonthly: number;
|
|
195
|
+
priceYearly: number | null;
|
|
196
|
+
trialDays: number;
|
|
197
|
+
};
|
|
198
|
+
/** True if a canceled subscription was reactivated */
|
|
199
|
+
reactivated?: boolean;
|
|
200
|
+
/** True if Stripe checkout is needed (canceled paid plan reactivation) */
|
|
201
|
+
needsCheckout?: boolean;
|
|
202
|
+
}
|
|
203
|
+
/** Parameters for changing plan */
|
|
204
|
+
interface FFIDChangePlanParams {
|
|
205
|
+
/** Subscription ID (UUID) */
|
|
206
|
+
subscriptionId: string;
|
|
207
|
+
/** New plan code */
|
|
208
|
+
planCode: string;
|
|
209
|
+
/** New billing interval (default: keeps current) */
|
|
210
|
+
billingInterval?: FFIDBillingInterval;
|
|
211
|
+
}
|
|
212
|
+
/** Response from change plan endpoint */
|
|
213
|
+
interface FFIDChangePlanResponse {
|
|
214
|
+
message: string;
|
|
215
|
+
subscription: {
|
|
216
|
+
id: string;
|
|
217
|
+
organizationId: string;
|
|
218
|
+
serviceCode: string;
|
|
219
|
+
planCode: string;
|
|
220
|
+
planName: string;
|
|
221
|
+
billingInterval: FFIDBillingInterval;
|
|
222
|
+
status: FFIDSubscriptionStatus;
|
|
223
|
+
isUpgrade: boolean;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/** Parameters for canceling subscription */
|
|
227
|
+
interface FFIDCancelSubscriptionParams {
|
|
228
|
+
/** Subscription ID (UUID) */
|
|
229
|
+
subscriptionId: string;
|
|
230
|
+
/** Cancellation reason code */
|
|
231
|
+
reason?: 'too_expensive' | 'missing_features' | 'switched_service' | 'rarely_used' | 'customer_service' | 'other';
|
|
232
|
+
/** Additional cancellation details */
|
|
233
|
+
reasonDetails?: string;
|
|
234
|
+
}
|
|
235
|
+
/** Response from cancel subscription endpoint */
|
|
236
|
+
interface FFIDCancelSubscriptionResponse {
|
|
237
|
+
message: string;
|
|
238
|
+
subscription: {
|
|
239
|
+
id: string;
|
|
240
|
+
organizationId: string;
|
|
241
|
+
status: FFIDSubscriptionStatus;
|
|
242
|
+
canceledAt: string | null;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/** Parameters for previewing plan change */
|
|
246
|
+
interface FFIDPreviewPlanChangeParams {
|
|
247
|
+
/** Subscription ID (UUID) */
|
|
248
|
+
subscriptionId: string;
|
|
249
|
+
/** New plan code */
|
|
250
|
+
planCode: string;
|
|
251
|
+
/** New billing interval (default: keeps current) */
|
|
252
|
+
billingInterval?: FFIDBillingInterval;
|
|
253
|
+
}
|
|
254
|
+
/** Plan change preview line item */
|
|
255
|
+
interface FFIDPlanChangeLineItem {
|
|
256
|
+
description: string;
|
|
257
|
+
amount: number;
|
|
258
|
+
}
|
|
259
|
+
/** Response from plan change preview endpoint */
|
|
260
|
+
interface FFIDPlanChangePreviewResponse {
|
|
261
|
+
preview: {
|
|
262
|
+
currentPlan: {
|
|
263
|
+
name: string;
|
|
264
|
+
price: number;
|
|
265
|
+
};
|
|
266
|
+
newPlan: {
|
|
267
|
+
name: string;
|
|
268
|
+
price: number;
|
|
269
|
+
};
|
|
270
|
+
billingInterval: FFIDBillingInterval;
|
|
271
|
+
isUpgrade: boolean;
|
|
272
|
+
proratedAmount: number;
|
|
273
|
+
nextInvoiceAmount: number;
|
|
274
|
+
nextInvoiceDate: string | null;
|
|
275
|
+
currency: string;
|
|
276
|
+
isEstimate: boolean;
|
|
277
|
+
estimateReason?: string;
|
|
278
|
+
lineItems: FFIDPlanChangeLineItem[];
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
95
282
|
/** OTP / magic link methods - sendOtp / verifyOtp */
|
|
96
283
|
|
|
97
284
|
/** Response from sendOtp */
|
|
@@ -168,6 +355,12 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
168
355
|
}) => Promise<FFIDApiResponse<FFIDRemoveMemberResponse>>;
|
|
169
356
|
createCheckoutSession: (params: FFIDCreateCheckoutParams) => Promise<FFIDApiResponse<FFIDCheckoutSessionResponse>>;
|
|
170
357
|
createPortalSession: (params: FFIDCreatePortalParams) => Promise<FFIDApiResponse<FFIDPortalSessionResponse>>;
|
|
358
|
+
listPlans: () => Promise<FFIDApiResponse<FFIDListPlansResponse>>;
|
|
359
|
+
getSubscription: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDSubscriptionDetail>>;
|
|
360
|
+
subscribe: (params: FFIDSubscribeParams) => Promise<FFIDApiResponse<FFIDSubscribeResponse>>;
|
|
361
|
+
changePlan: (params: FFIDChangePlanParams) => Promise<FFIDApiResponse<FFIDChangePlanResponse>>;
|
|
362
|
+
cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
|
|
363
|
+
previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
|
|
171
364
|
verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
|
|
172
365
|
requestPasswordReset: (email: string) => Promise<FFIDApiResponse<FFIDPasswordResetResponse>>;
|
|
173
366
|
verifyPasswordResetToken: (accessToken: string) => Promise<FFIDApiResponse<FFIDPasswordResetVerifyResponse>>;
|
|
@@ -448,4 +641,4 @@ declare function createFFIDAnnouncementsClient(config?: FFIDAnnouncementsClientC
|
|
|
448
641
|
/** Type of the FFID Announcements client */
|
|
449
642
|
type FFIDAnnouncementsClient = ReturnType<typeof createFFIDAnnouncementsClient>;
|
|
450
643
|
|
|
451
|
-
export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, FFIDCacheAdapter, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, FFIDListMembersResponse, FFIDLogger, FFIDMemberRole, FFIDOAuthUserInfo, FFIDOrganization, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, FFIDPortalSessionResponse, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSessionResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, FFIDUpdateMemberRoleResponse, FFIDUser, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, type KVNamespaceLike, ListAnnouncementsOptions, type RedirectToAuthorizeOptions, type TokenData, type TokenStore, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useSubscription, withFFIDAuth, withSubscription };
|
|
644
|
+
export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, FFIDMemberRole, FFIDOAuthUserInfo, FFIDOrganization, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreviewResponse, type FFIDPlanInfo, FFIDPortalSessionResponse, type FFIDPreviewPlanChangeParams, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, FFIDRemoveMemberResponse, type FFIDResetSessionResponse, type FFIDServiceInfo, FFIDSessionResponse, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, FFIDUpdateMemberRoleResponse, FFIDUser, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, type KVNamespaceLike, ListAnnouncementsOptions, type RedirectToAuthorizeOptions, type TokenData, type TokenStore, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useSubscription, withFFIDAuth, withSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as
|
|
2
|
-
export {
|
|
1
|
+
import { F as FFIDSubscriptionStatus, a as FFIDConfig, b as FFIDApiResponse, c as FFIDSessionResponse, d as FFIDRedirectResult, e as FFIDError, f as FFIDSubscriptionCheckResponse, g as FFIDListMembersResponse, h as FFIDMemberRole, i as FFIDUpdateMemberRoleResponse, j as FFIDRemoveMemberResponse, k as FFIDCreateCheckoutParams, l as FFIDCheckoutSessionResponse, m as FFIDCreatePortalParams, n as FFIDPortalSessionResponse, o as FFIDVerifyAccessTokenOptions, p as FFIDOAuthUserInfo, q as FFIDAuthMode, r as FFIDLogger, s as FFIDCacheAdapter, t as FFIDUser, u as FFIDOrganization, v as FFIDSubscription, w as FFIDSubscriptionContextValue, x as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, y as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, z as FFIDAnnouncementsLogger } from './index-p4dJw3qR.js';
|
|
2
|
+
export { B as Announcement, C as AnnouncementStatus, D as AnnouncementType, E as FFIDAnnouncementBadge, G as FFIDAnnouncementList, H as FFIDAnnouncementsError, I as FFIDAnnouncementsErrorCode, J as FFIDAnnouncementsServerResponse, K as FFIDCacheConfig, M as FFIDContextValue, N as FFIDJwtClaims, O as FFIDLoginButton, P as FFIDMemberStatus, Q as FFIDOAuthTokenResponse, R as FFIDOAuthUserInfoMemberRole, S as FFIDOAuthUserInfoSubscription, T as FFIDOrganizationMember, U as FFIDOrganizationSwitcher, V as FFIDSeatModel, W as FFIDSubscriptionBadge, X as FFIDTokenIntrospectionResponse, Y as FFIDUserMenu, Z as UseFFIDAnnouncementsOptions, _ as UseFFIDAnnouncementsReturn, $ as useFFIDAnnouncements } from './index-p4dJw3qR.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode, ComponentType, FC } from 'react';
|
|
5
5
|
|
|
@@ -92,6 +92,193 @@ declare function storeCodeVerifier(verifier: string, logger?: PKCELogger): boole
|
|
|
92
92
|
*/
|
|
93
93
|
declare function retrieveCodeVerifier(logger?: PKCELogger): string | null;
|
|
94
94
|
|
|
95
|
+
/** Billing interval for subscriptions */
|
|
96
|
+
type FFIDBillingInterval = 'monthly' | 'yearly';
|
|
97
|
+
/** Service information returned by plans endpoint */
|
|
98
|
+
interface FFIDServiceInfo {
|
|
99
|
+
id: string;
|
|
100
|
+
code: string;
|
|
101
|
+
name: string;
|
|
102
|
+
description: string | null;
|
|
103
|
+
isActive: boolean;
|
|
104
|
+
createdAt: string;
|
|
105
|
+
plans: FFIDPlanInfo[];
|
|
106
|
+
}
|
|
107
|
+
/** Plan information returned by plans endpoint */
|
|
108
|
+
interface FFIDPlanInfo {
|
|
109
|
+
id: string;
|
|
110
|
+
serviceId: string;
|
|
111
|
+
code: string;
|
|
112
|
+
name: string;
|
|
113
|
+
description: string | null;
|
|
114
|
+
minSeats: number;
|
|
115
|
+
maxSeats: number | null;
|
|
116
|
+
trialDays: number;
|
|
117
|
+
priceMonthly: number;
|
|
118
|
+
priceYearly: number | null;
|
|
119
|
+
currency: string;
|
|
120
|
+
isActive: boolean;
|
|
121
|
+
displayOrder: number;
|
|
122
|
+
customPricing: boolean;
|
|
123
|
+
createdAt: string;
|
|
124
|
+
}
|
|
125
|
+
/** Response from list plans endpoint */
|
|
126
|
+
interface FFIDListPlansResponse {
|
|
127
|
+
services: FFIDServiceInfo[];
|
|
128
|
+
count: number;
|
|
129
|
+
}
|
|
130
|
+
/** Subscription details returned by ext API (sanitized, no Stripe IDs) */
|
|
131
|
+
interface FFIDSubscriptionDetail {
|
|
132
|
+
id: string;
|
|
133
|
+
organizationId: string;
|
|
134
|
+
organizationName: string;
|
|
135
|
+
serviceCode: string;
|
|
136
|
+
serviceName: string;
|
|
137
|
+
planCode: string;
|
|
138
|
+
planName: string;
|
|
139
|
+
status: FFIDSubscriptionStatus;
|
|
140
|
+
paymentMethod: string | null;
|
|
141
|
+
billingInterval: FFIDBillingInterval;
|
|
142
|
+
quantity: number;
|
|
143
|
+
currentPeriodStart: string | null;
|
|
144
|
+
currentPeriodEnd: string | null;
|
|
145
|
+
trialStart: string | null;
|
|
146
|
+
trialEnd: string | null;
|
|
147
|
+
canceledAt: string | null;
|
|
148
|
+
cancelAtPeriodEnd: boolean;
|
|
149
|
+
createdAt: string;
|
|
150
|
+
}
|
|
151
|
+
/** Parameters for subscribing to a plan */
|
|
152
|
+
interface FFIDSubscribeParams {
|
|
153
|
+
/** Organization ID (UUID) */
|
|
154
|
+
organizationId: string;
|
|
155
|
+
/** Plan code (e.g., 'free', 'basic', 'pro') */
|
|
156
|
+
planCode: string;
|
|
157
|
+
/** Billing interval (default: 'monthly') */
|
|
158
|
+
billingInterval?: FFIDBillingInterval;
|
|
159
|
+
/** Number of seats (default: plan's minSeats) */
|
|
160
|
+
quantity?: number;
|
|
161
|
+
/** User ID for seat auto-assignment (only needed for service-key mode) */
|
|
162
|
+
userId?: string;
|
|
163
|
+
}
|
|
164
|
+
/** Sanitized subscription fields returned by subscribe/reactivate endpoints (no Stripe IDs) */
|
|
165
|
+
interface FFIDSubscriptionSummary {
|
|
166
|
+
id: string;
|
|
167
|
+
organizationId: string;
|
|
168
|
+
serviceId: string;
|
|
169
|
+
planId: string;
|
|
170
|
+
status: FFIDSubscriptionStatus;
|
|
171
|
+
paymentMethod: string | null;
|
|
172
|
+
billingInterval: FFIDBillingInterval;
|
|
173
|
+
quantity: number;
|
|
174
|
+
currentPeriodStart: string | null;
|
|
175
|
+
currentPeriodEnd: string | null;
|
|
176
|
+
trialStart: string | null;
|
|
177
|
+
trialEnd: string | null;
|
|
178
|
+
canceledAt: string | null;
|
|
179
|
+
cancelAtPeriodEnd: boolean;
|
|
180
|
+
createdAt: string;
|
|
181
|
+
}
|
|
182
|
+
/** Response from subscribe endpoint */
|
|
183
|
+
interface FFIDSubscribeResponse {
|
|
184
|
+
subscription: FFIDSubscriptionSummary;
|
|
185
|
+
service: {
|
|
186
|
+
id: string;
|
|
187
|
+
code: string;
|
|
188
|
+
name: string;
|
|
189
|
+
};
|
|
190
|
+
plan: {
|
|
191
|
+
id: string;
|
|
192
|
+
code: string;
|
|
193
|
+
name: string;
|
|
194
|
+
priceMonthly: number;
|
|
195
|
+
priceYearly: number | null;
|
|
196
|
+
trialDays: number;
|
|
197
|
+
};
|
|
198
|
+
/** True if a canceled subscription was reactivated */
|
|
199
|
+
reactivated?: boolean;
|
|
200
|
+
/** True if Stripe checkout is needed (canceled paid plan reactivation) */
|
|
201
|
+
needsCheckout?: boolean;
|
|
202
|
+
}
|
|
203
|
+
/** Parameters for changing plan */
|
|
204
|
+
interface FFIDChangePlanParams {
|
|
205
|
+
/** Subscription ID (UUID) */
|
|
206
|
+
subscriptionId: string;
|
|
207
|
+
/** New plan code */
|
|
208
|
+
planCode: string;
|
|
209
|
+
/** New billing interval (default: keeps current) */
|
|
210
|
+
billingInterval?: FFIDBillingInterval;
|
|
211
|
+
}
|
|
212
|
+
/** Response from change plan endpoint */
|
|
213
|
+
interface FFIDChangePlanResponse {
|
|
214
|
+
message: string;
|
|
215
|
+
subscription: {
|
|
216
|
+
id: string;
|
|
217
|
+
organizationId: string;
|
|
218
|
+
serviceCode: string;
|
|
219
|
+
planCode: string;
|
|
220
|
+
planName: string;
|
|
221
|
+
billingInterval: FFIDBillingInterval;
|
|
222
|
+
status: FFIDSubscriptionStatus;
|
|
223
|
+
isUpgrade: boolean;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/** Parameters for canceling subscription */
|
|
227
|
+
interface FFIDCancelSubscriptionParams {
|
|
228
|
+
/** Subscription ID (UUID) */
|
|
229
|
+
subscriptionId: string;
|
|
230
|
+
/** Cancellation reason code */
|
|
231
|
+
reason?: 'too_expensive' | 'missing_features' | 'switched_service' | 'rarely_used' | 'customer_service' | 'other';
|
|
232
|
+
/** Additional cancellation details */
|
|
233
|
+
reasonDetails?: string;
|
|
234
|
+
}
|
|
235
|
+
/** Response from cancel subscription endpoint */
|
|
236
|
+
interface FFIDCancelSubscriptionResponse {
|
|
237
|
+
message: string;
|
|
238
|
+
subscription: {
|
|
239
|
+
id: string;
|
|
240
|
+
organizationId: string;
|
|
241
|
+
status: FFIDSubscriptionStatus;
|
|
242
|
+
canceledAt: string | null;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/** Parameters for previewing plan change */
|
|
246
|
+
interface FFIDPreviewPlanChangeParams {
|
|
247
|
+
/** Subscription ID (UUID) */
|
|
248
|
+
subscriptionId: string;
|
|
249
|
+
/** New plan code */
|
|
250
|
+
planCode: string;
|
|
251
|
+
/** New billing interval (default: keeps current) */
|
|
252
|
+
billingInterval?: FFIDBillingInterval;
|
|
253
|
+
}
|
|
254
|
+
/** Plan change preview line item */
|
|
255
|
+
interface FFIDPlanChangeLineItem {
|
|
256
|
+
description: string;
|
|
257
|
+
amount: number;
|
|
258
|
+
}
|
|
259
|
+
/** Response from plan change preview endpoint */
|
|
260
|
+
interface FFIDPlanChangePreviewResponse {
|
|
261
|
+
preview: {
|
|
262
|
+
currentPlan: {
|
|
263
|
+
name: string;
|
|
264
|
+
price: number;
|
|
265
|
+
};
|
|
266
|
+
newPlan: {
|
|
267
|
+
name: string;
|
|
268
|
+
price: number;
|
|
269
|
+
};
|
|
270
|
+
billingInterval: FFIDBillingInterval;
|
|
271
|
+
isUpgrade: boolean;
|
|
272
|
+
proratedAmount: number;
|
|
273
|
+
nextInvoiceAmount: number;
|
|
274
|
+
nextInvoiceDate: string | null;
|
|
275
|
+
currency: string;
|
|
276
|
+
isEstimate: boolean;
|
|
277
|
+
estimateReason?: string;
|
|
278
|
+
lineItems: FFIDPlanChangeLineItem[];
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
95
282
|
/** OTP / magic link methods - sendOtp / verifyOtp */
|
|
96
283
|
|
|
97
284
|
/** Response from sendOtp */
|
|
@@ -168,6 +355,12 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
168
355
|
}) => Promise<FFIDApiResponse<FFIDRemoveMemberResponse>>;
|
|
169
356
|
createCheckoutSession: (params: FFIDCreateCheckoutParams) => Promise<FFIDApiResponse<FFIDCheckoutSessionResponse>>;
|
|
170
357
|
createPortalSession: (params: FFIDCreatePortalParams) => Promise<FFIDApiResponse<FFIDPortalSessionResponse>>;
|
|
358
|
+
listPlans: () => Promise<FFIDApiResponse<FFIDListPlansResponse>>;
|
|
359
|
+
getSubscription: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDSubscriptionDetail>>;
|
|
360
|
+
subscribe: (params: FFIDSubscribeParams) => Promise<FFIDApiResponse<FFIDSubscribeResponse>>;
|
|
361
|
+
changePlan: (params: FFIDChangePlanParams) => Promise<FFIDApiResponse<FFIDChangePlanResponse>>;
|
|
362
|
+
cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
|
|
363
|
+
previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
|
|
171
364
|
verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
|
|
172
365
|
requestPasswordReset: (email: string) => Promise<FFIDApiResponse<FFIDPasswordResetResponse>>;
|
|
173
366
|
verifyPasswordResetToken: (accessToken: string) => Promise<FFIDApiResponse<FFIDPasswordResetVerifyResponse>>;
|
|
@@ -448,4 +641,4 @@ declare function createFFIDAnnouncementsClient(config?: FFIDAnnouncementsClientC
|
|
|
448
641
|
/** Type of the FFID Announcements client */
|
|
449
642
|
type FFIDAnnouncementsClient = ReturnType<typeof createFFIDAnnouncementsClient>;
|
|
450
643
|
|
|
451
|
-
export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, FFIDCacheAdapter, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, FFIDListMembersResponse, FFIDLogger, FFIDMemberRole, FFIDOAuthUserInfo, FFIDOrganization, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, FFIDPortalSessionResponse, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSessionResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, FFIDUpdateMemberRoleResponse, FFIDUser, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, type KVNamespaceLike, ListAnnouncementsOptions, type RedirectToAuthorizeOptions, type TokenData, type TokenStore, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useSubscription, withFFIDAuth, withSubscription };
|
|
644
|
+
export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, FFIDMemberRole, FFIDOAuthUserInfo, FFIDOrganization, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreviewResponse, type FFIDPlanInfo, FFIDPortalSessionResponse, type FFIDPreviewPlanChangeParams, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, FFIDRemoveMemberResponse, type FFIDResetSessionResponse, type FFIDServiceInfo, FFIDSessionResponse, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, FFIDUpdateMemberRoleResponse, FFIDUser, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, type KVNamespaceLike, ListAnnouncementsOptions, type RedirectToAuthorizeOptions, type TokenData, type TokenStore, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useSubscription, withFFIDAuth, withSubscription };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useFFIDContext } from './chunk-
|
|
2
|
-
export { DEFAULT_API_BASE_URL, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useFFIDAnnouncements, useSubscription, withSubscription } from './chunk-
|
|
1
|
+
import { useFFIDContext } from './chunk-3IV7STDJ.js';
|
|
2
|
+
export { DEFAULT_API_BASE_URL, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useFFIDAnnouncements, useSubscription, withSubscription } from './chunk-3IV7STDJ.js';
|
|
3
3
|
import { useRef, useEffect } from 'react';
|
|
4
4
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
package/dist/server/index.cjs
CHANGED
|
@@ -443,6 +443,106 @@ function createBillingMethods(deps) {
|
|
|
443
443
|
return { createCheckoutSession, createPortalSession };
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
+
// src/client/subscription-methods.ts
|
|
447
|
+
var EXT_PLANS_ENDPOINT = "/api/v1/subscriptions/ext/plans";
|
|
448
|
+
var EXT_SUBSCRIPTION_ENDPOINT = "/api/v1/subscriptions/ext";
|
|
449
|
+
var EXT_SUBSCRIBE_ENDPOINT = "/api/v1/subscriptions/ext/subscribe";
|
|
450
|
+
function createSubscriptionMethods(deps) {
|
|
451
|
+
const { fetchWithAuth, createError } = deps;
|
|
452
|
+
async function listPlans() {
|
|
453
|
+
return fetchWithAuth(EXT_PLANS_ENDPOINT);
|
|
454
|
+
}
|
|
455
|
+
async function getSubscription(subscriptionId) {
|
|
456
|
+
if (!subscriptionId) {
|
|
457
|
+
return {
|
|
458
|
+
error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
return fetchWithAuth(
|
|
462
|
+
`${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(subscriptionId)}`
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
async function subscribe(params) {
|
|
466
|
+
if (!params.organizationId || !params.planCode) {
|
|
467
|
+
return {
|
|
468
|
+
error: createError("VALIDATION_ERROR", "organizationId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
return fetchWithAuth(
|
|
472
|
+
EXT_SUBSCRIBE_ENDPOINT,
|
|
473
|
+
{
|
|
474
|
+
method: "POST",
|
|
475
|
+
body: JSON.stringify({
|
|
476
|
+
organizationId: params.organizationId,
|
|
477
|
+
planCode: params.planCode,
|
|
478
|
+
...params.billingInterval ? { billingInterval: params.billingInterval } : {},
|
|
479
|
+
...params.quantity !== void 0 ? { quantity: params.quantity } : {},
|
|
480
|
+
...params.userId ? { userId: params.userId } : {}
|
|
481
|
+
})
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
async function changePlan(params) {
|
|
486
|
+
if (!params.subscriptionId || !params.planCode) {
|
|
487
|
+
return {
|
|
488
|
+
error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
return fetchWithAuth(
|
|
492
|
+
`${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}/plan`,
|
|
493
|
+
{
|
|
494
|
+
method: "PUT",
|
|
495
|
+
body: JSON.stringify({
|
|
496
|
+
planCode: params.planCode,
|
|
497
|
+
...params.billingInterval ? { billingInterval: params.billingInterval } : {}
|
|
498
|
+
})
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
async function cancelSubscription(params) {
|
|
503
|
+
if (!params.subscriptionId) {
|
|
504
|
+
return {
|
|
505
|
+
error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
const body = {};
|
|
509
|
+
if (params.reason) body.reason = params.reason;
|
|
510
|
+
if (params.reasonDetails) body.reasonDetails = params.reasonDetails;
|
|
511
|
+
return fetchWithAuth(
|
|
512
|
+
`${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}`,
|
|
513
|
+
{
|
|
514
|
+
method: "DELETE",
|
|
515
|
+
...Object.keys(body).length > 0 ? { body: JSON.stringify(body) } : {}
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
async function previewPlanChange(params) {
|
|
520
|
+
if (!params.subscriptionId || !params.planCode) {
|
|
521
|
+
return {
|
|
522
|
+
error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
return fetchWithAuth(
|
|
526
|
+
`${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}/plan/preview`,
|
|
527
|
+
{
|
|
528
|
+
method: "POST",
|
|
529
|
+
body: JSON.stringify({
|
|
530
|
+
planCode: params.planCode,
|
|
531
|
+
...params.billingInterval ? { billingInterval: params.billingInterval } : {}
|
|
532
|
+
})
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
return {
|
|
537
|
+
listPlans,
|
|
538
|
+
getSubscription,
|
|
539
|
+
subscribe,
|
|
540
|
+
changePlan,
|
|
541
|
+
cancelSubscription,
|
|
542
|
+
previewPlanChange
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
|
|
446
546
|
// src/client/members-methods.ts
|
|
447
547
|
var EXT_MEMBERS_ENDPOINT = "/api/v1/organizations/ext/members";
|
|
448
548
|
function createMembersMethods(deps) {
|
|
@@ -496,7 +596,7 @@ function createMembersMethods(deps) {
|
|
|
496
596
|
}
|
|
497
597
|
|
|
498
598
|
// src/client/version-check.ts
|
|
499
|
-
var SDK_VERSION = "1.
|
|
599
|
+
var SDK_VERSION = "1.19.0";
|
|
500
600
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
501
601
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
502
602
|
function sdkHeaders() {
|
|
@@ -1556,6 +1656,17 @@ function createFFIDClient(config) {
|
|
|
1556
1656
|
fetchWithAuth,
|
|
1557
1657
|
createError
|
|
1558
1658
|
});
|
|
1659
|
+
const {
|
|
1660
|
+
listPlans,
|
|
1661
|
+
getSubscription,
|
|
1662
|
+
subscribe,
|
|
1663
|
+
changePlan,
|
|
1664
|
+
cancelSubscription,
|
|
1665
|
+
previewPlanChange
|
|
1666
|
+
} = createSubscriptionMethods({
|
|
1667
|
+
fetchWithAuth,
|
|
1668
|
+
createError
|
|
1669
|
+
});
|
|
1559
1670
|
const { listMembers, updateMemberRole, removeMember } = createMembersMethods({
|
|
1560
1671
|
fetchWithAuth,
|
|
1561
1672
|
createError,
|
|
@@ -1609,6 +1720,12 @@ function createFFIDClient(config) {
|
|
|
1609
1720
|
removeMember,
|
|
1610
1721
|
createCheckoutSession,
|
|
1611
1722
|
createPortalSession,
|
|
1723
|
+
listPlans,
|
|
1724
|
+
getSubscription,
|
|
1725
|
+
subscribe,
|
|
1726
|
+
changePlan,
|
|
1727
|
+
cancelSubscription,
|
|
1728
|
+
previewPlanChange,
|
|
1612
1729
|
verifyAccessToken,
|
|
1613
1730
|
requestPasswordReset,
|
|
1614
1731
|
verifyPasswordResetToken,
|