@feelflow/ffid-sdk 2.10.0 → 2.12.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-55KLWKM7.cjs → chunk-5ZMR3NNO.cjs} +369 -184
- package/dist/{chunk-6DYAJ6IJ.js → chunk-KJUA77BM.js} +369 -185
- package/dist/components/index.cjs +8 -8
- 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-BSuGxrqG.d.cts → index-BuT9VaRt.d.cts} +127 -42
- package/dist/{index-BSuGxrqG.d.ts → index-BuT9VaRt.d.ts} +127 -42
- package/dist/index.cjs +28 -24
- package/dist/index.d.cts +72 -3
- package/dist/index.d.ts +72 -3
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +146 -4
- package/dist/server/index.d.cts +57 -0
- package/dist/server/index.d.ts +57 -0
- package/dist/server/index.js +146 -4
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 FFIDInquiryCreateParams, r as FFIDInquiryCreateResponse, s as FFIDAuthMode, t as FFIDLogger, u as FFIDCacheAdapter, v as FFIDUser, w as FFIDOrganization, x as FFIDSubscription, y as FFIDSubscriptionContextValue, z as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, A as FFIDAnnouncementsApiResponse, B as AnnouncementListResponse, C as FFIDAnnouncementsLogger } from './index-
|
|
2
|
-
export { D as Announcement, E as AnnouncementStatus, G as AnnouncementType, H as FFIDAnnouncementBadge, I as FFIDAnnouncementList, J as FFIDAnnouncementsError, K as FFIDAnnouncementsErrorCode, M as FFIDAnnouncementsServerResponse, N as FFIDCacheConfig, O as FFIDContextValue, P as FFIDInquiryCategory, Q as FFIDInquiryForm, R as FFIDInquiryFormCategoryItem, S as
|
|
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 FFIDInquiryCreateParams, r as FFIDInquiryCreateResponse, s as FFIDAuthMode, t as FFIDLogger, u as FFIDCacheAdapter, v as FFIDUser, w as FFIDOrganization, x as FFIDSubscription, y as FFIDSubscriptionContextValue, z as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, A as FFIDAnnouncementsApiResponse, B as AnnouncementListResponse, C as FFIDAnnouncementsLogger } from './index-BuT9VaRt.cjs';
|
|
2
|
+
export { D as Announcement, E as AnnouncementStatus, G as AnnouncementType, H as FFIDAnnouncementBadge, I as FFIDAnnouncementList, J as FFIDAnnouncementsError, K as FFIDAnnouncementsErrorCode, M as FFIDAnnouncementsServerResponse, N as FFIDCacheConfig, O as FFIDContextValue, P as FFIDInquiryCategory, Q as FFIDInquiryForm, R as FFIDInquiryFormCategoryItem, S as FFIDInquiryFormClassNames, T as FFIDInquiryFormOrganization, U as FFIDInquiryFormPlaceholderContext, V as FFIDInquiryFormPrefill, W as FFIDInquiryFormProps, X as FFIDInquiryFormSubmitData, Y as FFIDInquiryFormSubmitResult, Z as FFIDJwtClaims, _ as FFIDLoginButton, $ as FFIDMemberStatus, a0 as FFIDOAuthTokenResponse, a1 as FFIDOAuthUserInfoMemberRole, a2 as FFIDOAuthUserInfoSubscription, a3 as FFIDOrganizationMember, a4 as FFIDOrganizationSwitcher, a5 as FFIDSeatModel, a6 as FFIDSubscriptionBadge, a7 as FFIDTokenIntrospectionResponse, a8 as FFIDUserMenu, a9 as FFID_INQUIRY_CATEGORIES, aa as UseFFIDAnnouncementsOptions, ab as UseFFIDAnnouncementsReturn, ac as useFFIDAnnouncements } from './index-BuT9VaRt.cjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode, ComponentType, FC } from 'react';
|
|
5
5
|
|
|
@@ -341,6 +341,62 @@ type FFIDPlanChangePreview = FFIDPlanChangePreviewBase & ({
|
|
|
341
341
|
interface FFIDPlanChangePreviewResponse {
|
|
342
342
|
preview: FFIDPlanChangePreview;
|
|
343
343
|
}
|
|
344
|
+
/** Parameters for previewing a seat count change */
|
|
345
|
+
interface FFIDPreviewSeatChangeParams {
|
|
346
|
+
/** Subscription ID (UUID) */
|
|
347
|
+
subscriptionId: string;
|
|
348
|
+
/** New seat quantity. Must be an integer within the plan's allowed range. */
|
|
349
|
+
quantity: number;
|
|
350
|
+
}
|
|
351
|
+
/** Seat change preview line item */
|
|
352
|
+
interface FFIDSeatChangeLineItem {
|
|
353
|
+
description: string;
|
|
354
|
+
amount: number;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Seat change proration preview.
|
|
358
|
+
*
|
|
359
|
+
* Sister type to `FFIDPlanChangePreview`. The shared `type` discriminant lets
|
|
360
|
+
* consumers narrow a preview payload without inspecting unrelated fields.
|
|
361
|
+
*
|
|
362
|
+
* - `isEstimate=true` (default when Stripe is not configured or data is unavailable):
|
|
363
|
+
* `proratedAmount` is computed locally as `(newQuantity - currentQuantity) * unitPrice`.
|
|
364
|
+
* - `isEstimate=false`: `proratedAmount` reflects Stripe's live proration calculation.
|
|
365
|
+
*
|
|
366
|
+
* `nextInvoiceAmount` is always a local estimate (`unitPrice * newQuantity`).
|
|
367
|
+
*
|
|
368
|
+
* `pricingUnavailable=true` indicates the plan uses custom pricing with a zero unit
|
|
369
|
+
* price (Enterprise). Consumers should hide monetary amounts in this case.
|
|
370
|
+
*/
|
|
371
|
+
interface FFIDSeatChangePreview {
|
|
372
|
+
/** Discriminant for preview response variants (pairs with `FFIDPlanChangePreview.type`) */
|
|
373
|
+
type: 'seat-change';
|
|
374
|
+
currentQuantity: number;
|
|
375
|
+
newQuantity: number;
|
|
376
|
+
/** Per-seat price for the current billing interval */
|
|
377
|
+
unitPrice: number;
|
|
378
|
+
billingInterval: FFIDBillingInterval;
|
|
379
|
+
/**
|
|
380
|
+
* Prorated cost for the current billing period. Negative when seats are decreased
|
|
381
|
+
* (credit). `0` when `pricingUnavailable === true` (Enterprise custom pricing).
|
|
382
|
+
*/
|
|
383
|
+
proratedAmount: number;
|
|
384
|
+
/** Next invoice full amount — always a local estimate (`unitPrice * newQuantity`) */
|
|
385
|
+
nextInvoiceAmount: number;
|
|
386
|
+
nextInvoiceDate: string | null;
|
|
387
|
+
currency: FFIDSupportedCurrency;
|
|
388
|
+
/** true when proratedAmount is estimated from local prices rather than Stripe proration data */
|
|
389
|
+
isEstimate: boolean;
|
|
390
|
+
/** true when unit price is 0 due to custom pricing (Enterprise) — hide monetary amounts */
|
|
391
|
+
pricingUnavailable?: boolean;
|
|
392
|
+
/** Reason why `isEstimate` is true. Only meaningful when `isEstimate === true`. */
|
|
393
|
+
estimateReason?: 'no_stripe_data' | 'custom_pricing' | 'stripe_error';
|
|
394
|
+
lineItems: FFIDSeatChangeLineItem[];
|
|
395
|
+
}
|
|
396
|
+
/** Response from seat change preview endpoint */
|
|
397
|
+
interface FFIDSeatChangePreviewResponse {
|
|
398
|
+
preview: FFIDSeatChangePreview;
|
|
399
|
+
}
|
|
344
400
|
|
|
345
401
|
/** OTP / magic link methods - sendOtp / verifyOtp */
|
|
346
402
|
|
|
@@ -453,6 +509,7 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
453
509
|
cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
|
|
454
510
|
cancelPendingDowngrade: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDCancelPendingDowngradeResponse>>;
|
|
455
511
|
previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
|
|
512
|
+
previewSeatChange: (params: FFIDPreviewSeatChangeParams) => Promise<FFIDApiResponse<FFIDSeatChangePreviewResponse>>;
|
|
456
513
|
verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
|
|
457
514
|
getSubscribeUrl: (options?: ContractWizardSubscribeOptions) => string;
|
|
458
515
|
redirectToSubscribe: (options?: ContractWizardSubscribeOptions) => FFIDRedirectResult;
|
|
@@ -499,6 +556,18 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
499
556
|
/** Type of the FFID client */
|
|
500
557
|
type FFIDClient = ReturnType<typeof createFFIDClient>;
|
|
501
558
|
|
|
559
|
+
/** Subscription management methods - plan listing, subscribe, change, cancel, preview */
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Thrown by the SDK when the server returns a payload that violates a type-level
|
|
563
|
+
* invariant the SDK relies on for consumer narrowing. Always indicates a server
|
|
564
|
+
* regression (or a client/server version mismatch); never caused by user input.
|
|
565
|
+
*/
|
|
566
|
+
declare class FFIDSDKError extends Error {
|
|
567
|
+
readonly code: string;
|
|
568
|
+
constructor(code: string, message: string);
|
|
569
|
+
}
|
|
570
|
+
|
|
502
571
|
/**
|
|
503
572
|
* Create an in-memory cache adapter using a Map.
|
|
504
573
|
* Suitable for single-process environments (e.g., development, testing).
|
|
@@ -844,4 +913,4 @@ declare function createInquiryMethods(deps: InquiryMethodsDeps): {
|
|
|
844
913
|
};
|
|
845
914
|
type FFIDInquiryClient = ReturnType<typeof createInquiryMethods>;
|
|
846
915
|
|
|
847
|
-
export { AnnouncementListResponse, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelPendingDowngradeResponse, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, type FFIDInquiryClient, FFIDInquiryCreateParams, FFIDInquiryCreateResponse, FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, FFIDMemberRole, type FFIDNewsletterClient, type FFIDNewsletterConfirmParams, type FFIDNewsletterConfirmResponse, type FFIDNewsletterSubscribeParams, type FFIDNewsletterSubscribeResponse, type FFIDNewsletterType, type FFIDNewsletterUnsubscribeParams, type FFIDNewsletterUnsubscribeResponse, FFIDOAuthUserInfo, FFIDOrganization, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreview, 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, type FFIDSupportedCurrency, FFIDUpdateMemberRoleResponse, FFIDUser, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_NEWSLETTER_TYPES, 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 };
|
|
916
|
+
export { AnnouncementListResponse, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelPendingDowngradeResponse, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, type FFIDInquiryClient, FFIDInquiryCreateParams, FFIDInquiryCreateResponse, FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, FFIDMemberRole, type FFIDNewsletterClient, type FFIDNewsletterConfirmParams, type FFIDNewsletterConfirmResponse, type FFIDNewsletterSubscribeParams, type FFIDNewsletterSubscribeResponse, type FFIDNewsletterType, type FFIDNewsletterUnsubscribeParams, type FFIDNewsletterUnsubscribeResponse, FFIDOAuthUserInfo, FFIDOrganization, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreview, type FFIDPlanChangePreviewResponse, type FFIDPlanInfo, FFIDPortalSessionResponse, type FFIDPreviewPlanChangeParams, type FFIDPreviewSeatChangeParams, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSDKError, type FFIDSeatChangeLineItem, type FFIDSeatChangePreview, type FFIDSeatChangePreviewResponse, type FFIDServiceInfo, FFIDSessionResponse, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, type FFIDSupportedCurrency, FFIDUpdateMemberRoleResponse, FFIDUser, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_NEWSLETTER_TYPES, 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 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 FFIDInquiryCreateParams, r as FFIDInquiryCreateResponse, s as FFIDAuthMode, t as FFIDLogger, u as FFIDCacheAdapter, v as FFIDUser, w as FFIDOrganization, x as FFIDSubscription, y as FFIDSubscriptionContextValue, z as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, A as FFIDAnnouncementsApiResponse, B as AnnouncementListResponse, C as FFIDAnnouncementsLogger } from './index-
|
|
2
|
-
export { D as Announcement, E as AnnouncementStatus, G as AnnouncementType, H as FFIDAnnouncementBadge, I as FFIDAnnouncementList, J as FFIDAnnouncementsError, K as FFIDAnnouncementsErrorCode, M as FFIDAnnouncementsServerResponse, N as FFIDCacheConfig, O as FFIDContextValue, P as FFIDInquiryCategory, Q as FFIDInquiryForm, R as FFIDInquiryFormCategoryItem, S as
|
|
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 FFIDInquiryCreateParams, r as FFIDInquiryCreateResponse, s as FFIDAuthMode, t as FFIDLogger, u as FFIDCacheAdapter, v as FFIDUser, w as FFIDOrganization, x as FFIDSubscription, y as FFIDSubscriptionContextValue, z as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, A as FFIDAnnouncementsApiResponse, B as AnnouncementListResponse, C as FFIDAnnouncementsLogger } from './index-BuT9VaRt.js';
|
|
2
|
+
export { D as Announcement, E as AnnouncementStatus, G as AnnouncementType, H as FFIDAnnouncementBadge, I as FFIDAnnouncementList, J as FFIDAnnouncementsError, K as FFIDAnnouncementsErrorCode, M as FFIDAnnouncementsServerResponse, N as FFIDCacheConfig, O as FFIDContextValue, P as FFIDInquiryCategory, Q as FFIDInquiryForm, R as FFIDInquiryFormCategoryItem, S as FFIDInquiryFormClassNames, T as FFIDInquiryFormOrganization, U as FFIDInquiryFormPlaceholderContext, V as FFIDInquiryFormPrefill, W as FFIDInquiryFormProps, X as FFIDInquiryFormSubmitData, Y as FFIDInquiryFormSubmitResult, Z as FFIDJwtClaims, _ as FFIDLoginButton, $ as FFIDMemberStatus, a0 as FFIDOAuthTokenResponse, a1 as FFIDOAuthUserInfoMemberRole, a2 as FFIDOAuthUserInfoSubscription, a3 as FFIDOrganizationMember, a4 as FFIDOrganizationSwitcher, a5 as FFIDSeatModel, a6 as FFIDSubscriptionBadge, a7 as FFIDTokenIntrospectionResponse, a8 as FFIDUserMenu, a9 as FFID_INQUIRY_CATEGORIES, aa as UseFFIDAnnouncementsOptions, ab as UseFFIDAnnouncementsReturn, ac as useFFIDAnnouncements } from './index-BuT9VaRt.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode, ComponentType, FC } from 'react';
|
|
5
5
|
|
|
@@ -341,6 +341,62 @@ type FFIDPlanChangePreview = FFIDPlanChangePreviewBase & ({
|
|
|
341
341
|
interface FFIDPlanChangePreviewResponse {
|
|
342
342
|
preview: FFIDPlanChangePreview;
|
|
343
343
|
}
|
|
344
|
+
/** Parameters for previewing a seat count change */
|
|
345
|
+
interface FFIDPreviewSeatChangeParams {
|
|
346
|
+
/** Subscription ID (UUID) */
|
|
347
|
+
subscriptionId: string;
|
|
348
|
+
/** New seat quantity. Must be an integer within the plan's allowed range. */
|
|
349
|
+
quantity: number;
|
|
350
|
+
}
|
|
351
|
+
/** Seat change preview line item */
|
|
352
|
+
interface FFIDSeatChangeLineItem {
|
|
353
|
+
description: string;
|
|
354
|
+
amount: number;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Seat change proration preview.
|
|
358
|
+
*
|
|
359
|
+
* Sister type to `FFIDPlanChangePreview`. The shared `type` discriminant lets
|
|
360
|
+
* consumers narrow a preview payload without inspecting unrelated fields.
|
|
361
|
+
*
|
|
362
|
+
* - `isEstimate=true` (default when Stripe is not configured or data is unavailable):
|
|
363
|
+
* `proratedAmount` is computed locally as `(newQuantity - currentQuantity) * unitPrice`.
|
|
364
|
+
* - `isEstimate=false`: `proratedAmount` reflects Stripe's live proration calculation.
|
|
365
|
+
*
|
|
366
|
+
* `nextInvoiceAmount` is always a local estimate (`unitPrice * newQuantity`).
|
|
367
|
+
*
|
|
368
|
+
* `pricingUnavailable=true` indicates the plan uses custom pricing with a zero unit
|
|
369
|
+
* price (Enterprise). Consumers should hide monetary amounts in this case.
|
|
370
|
+
*/
|
|
371
|
+
interface FFIDSeatChangePreview {
|
|
372
|
+
/** Discriminant for preview response variants (pairs with `FFIDPlanChangePreview.type`) */
|
|
373
|
+
type: 'seat-change';
|
|
374
|
+
currentQuantity: number;
|
|
375
|
+
newQuantity: number;
|
|
376
|
+
/** Per-seat price for the current billing interval */
|
|
377
|
+
unitPrice: number;
|
|
378
|
+
billingInterval: FFIDBillingInterval;
|
|
379
|
+
/**
|
|
380
|
+
* Prorated cost for the current billing period. Negative when seats are decreased
|
|
381
|
+
* (credit). `0` when `pricingUnavailable === true` (Enterprise custom pricing).
|
|
382
|
+
*/
|
|
383
|
+
proratedAmount: number;
|
|
384
|
+
/** Next invoice full amount — always a local estimate (`unitPrice * newQuantity`) */
|
|
385
|
+
nextInvoiceAmount: number;
|
|
386
|
+
nextInvoiceDate: string | null;
|
|
387
|
+
currency: FFIDSupportedCurrency;
|
|
388
|
+
/** true when proratedAmount is estimated from local prices rather than Stripe proration data */
|
|
389
|
+
isEstimate: boolean;
|
|
390
|
+
/** true when unit price is 0 due to custom pricing (Enterprise) — hide monetary amounts */
|
|
391
|
+
pricingUnavailable?: boolean;
|
|
392
|
+
/** Reason why `isEstimate` is true. Only meaningful when `isEstimate === true`. */
|
|
393
|
+
estimateReason?: 'no_stripe_data' | 'custom_pricing' | 'stripe_error';
|
|
394
|
+
lineItems: FFIDSeatChangeLineItem[];
|
|
395
|
+
}
|
|
396
|
+
/** Response from seat change preview endpoint */
|
|
397
|
+
interface FFIDSeatChangePreviewResponse {
|
|
398
|
+
preview: FFIDSeatChangePreview;
|
|
399
|
+
}
|
|
344
400
|
|
|
345
401
|
/** OTP / magic link methods - sendOtp / verifyOtp */
|
|
346
402
|
|
|
@@ -453,6 +509,7 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
453
509
|
cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
|
|
454
510
|
cancelPendingDowngrade: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDCancelPendingDowngradeResponse>>;
|
|
455
511
|
previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
|
|
512
|
+
previewSeatChange: (params: FFIDPreviewSeatChangeParams) => Promise<FFIDApiResponse<FFIDSeatChangePreviewResponse>>;
|
|
456
513
|
verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
|
|
457
514
|
getSubscribeUrl: (options?: ContractWizardSubscribeOptions) => string;
|
|
458
515
|
redirectToSubscribe: (options?: ContractWizardSubscribeOptions) => FFIDRedirectResult;
|
|
@@ -499,6 +556,18 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
499
556
|
/** Type of the FFID client */
|
|
500
557
|
type FFIDClient = ReturnType<typeof createFFIDClient>;
|
|
501
558
|
|
|
559
|
+
/** Subscription management methods - plan listing, subscribe, change, cancel, preview */
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Thrown by the SDK when the server returns a payload that violates a type-level
|
|
563
|
+
* invariant the SDK relies on for consumer narrowing. Always indicates a server
|
|
564
|
+
* regression (or a client/server version mismatch); never caused by user input.
|
|
565
|
+
*/
|
|
566
|
+
declare class FFIDSDKError extends Error {
|
|
567
|
+
readonly code: string;
|
|
568
|
+
constructor(code: string, message: string);
|
|
569
|
+
}
|
|
570
|
+
|
|
502
571
|
/**
|
|
503
572
|
* Create an in-memory cache adapter using a Map.
|
|
504
573
|
* Suitable for single-process environments (e.g., development, testing).
|
|
@@ -844,4 +913,4 @@ declare function createInquiryMethods(deps: InquiryMethodsDeps): {
|
|
|
844
913
|
};
|
|
845
914
|
type FFIDInquiryClient = ReturnType<typeof createInquiryMethods>;
|
|
846
915
|
|
|
847
|
-
export { AnnouncementListResponse, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelPendingDowngradeResponse, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, type FFIDInquiryClient, FFIDInquiryCreateParams, FFIDInquiryCreateResponse, FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, FFIDMemberRole, type FFIDNewsletterClient, type FFIDNewsletterConfirmParams, type FFIDNewsletterConfirmResponse, type FFIDNewsletterSubscribeParams, type FFIDNewsletterSubscribeResponse, type FFIDNewsletterType, type FFIDNewsletterUnsubscribeParams, type FFIDNewsletterUnsubscribeResponse, FFIDOAuthUserInfo, FFIDOrganization, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreview, 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, type FFIDSupportedCurrency, FFIDUpdateMemberRoleResponse, FFIDUser, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_NEWSLETTER_TYPES, 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 };
|
|
916
|
+
export { AnnouncementListResponse, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelPendingDowngradeResponse, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, type FFIDInquiryClient, FFIDInquiryCreateParams, FFIDInquiryCreateResponse, FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, FFIDMemberRole, type FFIDNewsletterClient, type FFIDNewsletterConfirmParams, type FFIDNewsletterConfirmResponse, type FFIDNewsletterSubscribeParams, type FFIDNewsletterSubscribeResponse, type FFIDNewsletterType, type FFIDNewsletterUnsubscribeParams, type FFIDNewsletterUnsubscribeResponse, FFIDOAuthUserInfo, FFIDOrganization, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreview, type FFIDPlanChangePreviewResponse, type FFIDPlanInfo, FFIDPortalSessionResponse, type FFIDPreviewPlanChangeParams, type FFIDPreviewSeatChangeParams, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSDKError, type FFIDSeatChangeLineItem, type FFIDSeatChangePreview, type FFIDSeatChangePreviewResponse, type FFIDServiceInfo, FFIDSessionResponse, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, type FFIDSupportedCurrency, FFIDUpdateMemberRoleResponse, FFIDUser, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_NEWSLETTER_TYPES, 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, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_INQUIRY_CATEGORIES, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useFFIDAnnouncements, useSubscription, withSubscription } from './chunk-
|
|
1
|
+
import { useFFIDContext } from './chunk-KJUA77BM.js';
|
|
2
|
+
export { DEFAULT_API_BASE_URL, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSDKError, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_INQUIRY_CATEGORIES, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useFFIDAnnouncements, useSubscription, withSubscription } from './chunk-KJUA77BM.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
|
@@ -453,9 +453,118 @@ function createBillingMethods(deps) {
|
|
|
453
453
|
var EXT_PLANS_ENDPOINT = "/api/v1/subscriptions/ext/plans";
|
|
454
454
|
var EXT_SUBSCRIPTION_ENDPOINT = "/api/v1/subscriptions/ext";
|
|
455
455
|
var EXT_SUBSCRIBE_ENDPOINT = "/api/v1/subscriptions/ext/subscribe";
|
|
456
|
+
var FFIDSDKError = class extends Error {
|
|
457
|
+
code;
|
|
458
|
+
constructor(code, message) {
|
|
459
|
+
super(message);
|
|
460
|
+
this.name = "FFIDSDKError";
|
|
461
|
+
this.code = code;
|
|
462
|
+
}
|
|
463
|
+
};
|
|
456
464
|
function isBlankString(value) {
|
|
457
465
|
return typeof value !== "string" || value.trim() === "";
|
|
458
466
|
}
|
|
467
|
+
var MALFORMED_PREVIEW_CODE = "MALFORMED_PLAN_CHANGE_PREVIEW";
|
|
468
|
+
var MALFORMED_SEAT_PREVIEW_CODE = "MALFORMED_SEAT_CHANGE_PREVIEW";
|
|
469
|
+
var SEAT_ESTIMATE_REASONS = /* @__PURE__ */ new Set(["no_stripe_data", "custom_pricing", "stripe_error"]);
|
|
470
|
+
function validatePlanChangePreview(preview) {
|
|
471
|
+
if (preview === null || typeof preview !== "object") {
|
|
472
|
+
throw new FFIDSDKError(
|
|
473
|
+
MALFORMED_PREVIEW_CODE,
|
|
474
|
+
"SDK: server returned malformed PlanChangePreview \u2014 expected object, got " + (preview === null ? "null" : typeof preview)
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
const p = preview;
|
|
478
|
+
const flag = p.willApplyAtPeriodEnd;
|
|
479
|
+
if (typeof flag !== "boolean") {
|
|
480
|
+
throw new FFIDSDKError(
|
|
481
|
+
MALFORMED_PREVIEW_CODE,
|
|
482
|
+
`SDK: server returned malformed PlanChangePreview \u2014 willApplyAtPeriodEnd must be boolean (got ${typeof flag})`
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
const { proratedAmount, effectiveDate } = p;
|
|
486
|
+
if (flag === true) {
|
|
487
|
+
if (proratedAmount !== 0) {
|
|
488
|
+
throw new FFIDSDKError(
|
|
489
|
+
MALFORMED_PREVIEW_CODE,
|
|
490
|
+
`SDK: server returned malformed PlanChangePreview \u2014 willApplyAtPeriodEnd=true requires proratedAmount=0 (got ${JSON.stringify(proratedAmount)})`
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
if (effectiveDate !== null && typeof effectiveDate !== "string") {
|
|
494
|
+
throw new FFIDSDKError(
|
|
495
|
+
MALFORMED_PREVIEW_CODE,
|
|
496
|
+
`SDK: server returned malformed PlanChangePreview \u2014 willApplyAtPeriodEnd=true requires effectiveDate to be string or null (got ${typeof effectiveDate})`
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
if (effectiveDate !== null) {
|
|
502
|
+
throw new FFIDSDKError(
|
|
503
|
+
MALFORMED_PREVIEW_CODE,
|
|
504
|
+
`SDK: server returned malformed PlanChangePreview \u2014 willApplyAtPeriodEnd=false requires effectiveDate=null (got ${JSON.stringify(effectiveDate)})`
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
if (typeof proratedAmount !== "number") {
|
|
508
|
+
throw new FFIDSDKError(
|
|
509
|
+
MALFORMED_PREVIEW_CODE,
|
|
510
|
+
`SDK: server returned malformed PlanChangePreview \u2014 willApplyAtPeriodEnd=false requires proratedAmount to be a number (got ${typeof proratedAmount})`
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
function validateSeatChangePreview(preview) {
|
|
515
|
+
if (preview === null || typeof preview !== "object") {
|
|
516
|
+
throw new FFIDSDKError(
|
|
517
|
+
MALFORMED_SEAT_PREVIEW_CODE,
|
|
518
|
+
"SDK: server returned malformed SeatChangePreview \u2014 expected object, got " + (preview === null ? "null" : typeof preview)
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
const p = preview;
|
|
522
|
+
if (p.type !== "seat-change") {
|
|
523
|
+
throw new FFIDSDKError(
|
|
524
|
+
MALFORMED_SEAT_PREVIEW_CODE,
|
|
525
|
+
`SDK: server returned malformed SeatChangePreview \u2014 type must be 'seat-change' (got ${JSON.stringify(p.type)})`
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
const numericFields = [
|
|
529
|
+
"currentQuantity",
|
|
530
|
+
"newQuantity",
|
|
531
|
+
"unitPrice",
|
|
532
|
+
"proratedAmount",
|
|
533
|
+
"nextInvoiceAmount"
|
|
534
|
+
];
|
|
535
|
+
for (const key of numericFields) {
|
|
536
|
+
if (typeof p[key] !== "number") {
|
|
537
|
+
throw new FFIDSDKError(
|
|
538
|
+
MALFORMED_SEAT_PREVIEW_CODE,
|
|
539
|
+
`SDK: server returned malformed SeatChangePreview \u2014 ${key} must be a number (got ${typeof p[key]})`
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
if (p.nextInvoiceDate !== null && typeof p.nextInvoiceDate !== "string") {
|
|
544
|
+
throw new FFIDSDKError(
|
|
545
|
+
MALFORMED_SEAT_PREVIEW_CODE,
|
|
546
|
+
`SDK: server returned malformed SeatChangePreview \u2014 nextInvoiceDate must be string or null (got ${typeof p.nextInvoiceDate})`
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
if (typeof p.isEstimate !== "boolean") {
|
|
550
|
+
throw new FFIDSDKError(
|
|
551
|
+
MALFORMED_SEAT_PREVIEW_CODE,
|
|
552
|
+
`SDK: server returned malformed SeatChangePreview \u2014 isEstimate must be boolean (got ${typeof p.isEstimate})`
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
if (p.estimateReason !== void 0 && !SEAT_ESTIMATE_REASONS.has(p.estimateReason)) {
|
|
556
|
+
throw new FFIDSDKError(
|
|
557
|
+
MALFORMED_SEAT_PREVIEW_CODE,
|
|
558
|
+
`SDK: server returned malformed SeatChangePreview \u2014 estimateReason must be one of 'no_stripe_data' | 'custom_pricing' | 'stripe_error' (got ${JSON.stringify(p.estimateReason)})`
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
if (!Array.isArray(p.lineItems)) {
|
|
562
|
+
throw new FFIDSDKError(
|
|
563
|
+
MALFORMED_SEAT_PREVIEW_CODE,
|
|
564
|
+
`SDK: server returned malformed SeatChangePreview \u2014 lineItems must be an array (got ${typeof p.lineItems})`
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
459
568
|
function createSubscriptionMethods(deps) {
|
|
460
569
|
const { fetchWithAuth, createError } = deps;
|
|
461
570
|
async function listPlans() {
|
|
@@ -542,7 +651,7 @@ function createSubscriptionMethods(deps) {
|
|
|
542
651
|
error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
|
|
543
652
|
};
|
|
544
653
|
}
|
|
545
|
-
|
|
654
|
+
const response = await fetchWithAuth(
|
|
546
655
|
`${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}/plan/preview`,
|
|
547
656
|
{
|
|
548
657
|
method: "POST",
|
|
@@ -552,6 +661,36 @@ function createSubscriptionMethods(deps) {
|
|
|
552
661
|
})
|
|
553
662
|
}
|
|
554
663
|
);
|
|
664
|
+
if (response.data !== void 0) {
|
|
665
|
+
validatePlanChangePreview(response.data.preview);
|
|
666
|
+
}
|
|
667
|
+
return response;
|
|
668
|
+
}
|
|
669
|
+
async function previewSeatChange(params) {
|
|
670
|
+
if (isBlankString(params.subscriptionId)) {
|
|
671
|
+
return {
|
|
672
|
+
error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
if (typeof params.quantity !== "number" || !Number.isInteger(params.quantity) || params.quantity < 1) {
|
|
676
|
+
return {
|
|
677
|
+
error: createError(
|
|
678
|
+
"VALIDATION_ERROR",
|
|
679
|
+
`quantity \u306F 1 \u4EE5\u4E0A\u306E\u6574\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 (received: ${String(params.quantity)})`
|
|
680
|
+
)
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
const response = await fetchWithAuth(
|
|
684
|
+
`${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}/seats/preview`,
|
|
685
|
+
{
|
|
686
|
+
method: "POST",
|
|
687
|
+
body: JSON.stringify({ quantity: params.quantity })
|
|
688
|
+
}
|
|
689
|
+
);
|
|
690
|
+
if (response.data !== void 0) {
|
|
691
|
+
validateSeatChangePreview(response.data.preview);
|
|
692
|
+
}
|
|
693
|
+
return response;
|
|
555
694
|
}
|
|
556
695
|
return {
|
|
557
696
|
listPlans,
|
|
@@ -560,7 +699,8 @@ function createSubscriptionMethods(deps) {
|
|
|
560
699
|
changePlan,
|
|
561
700
|
cancelSubscription,
|
|
562
701
|
cancelPendingDowngrade,
|
|
563
|
-
previewPlanChange
|
|
702
|
+
previewPlanChange,
|
|
703
|
+
previewSeatChange
|
|
564
704
|
};
|
|
565
705
|
}
|
|
566
706
|
|
|
@@ -617,7 +757,7 @@ function createMembersMethods(deps) {
|
|
|
617
757
|
}
|
|
618
758
|
|
|
619
759
|
// src/client/version-check.ts
|
|
620
|
-
var SDK_VERSION = "2.
|
|
760
|
+
var SDK_VERSION = "2.12.0";
|
|
621
761
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
622
762
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
623
763
|
function sdkHeaders() {
|
|
@@ -1941,7 +2081,8 @@ function createFFIDClient(config) {
|
|
|
1941
2081
|
changePlan,
|
|
1942
2082
|
cancelSubscription,
|
|
1943
2083
|
cancelPendingDowngrade,
|
|
1944
|
-
previewPlanChange
|
|
2084
|
+
previewPlanChange,
|
|
2085
|
+
previewSeatChange
|
|
1945
2086
|
} = createSubscriptionMethods({
|
|
1946
2087
|
fetchWithAuth,
|
|
1947
2088
|
createError
|
|
@@ -2031,6 +2172,7 @@ function createFFIDClient(config) {
|
|
|
2031
2172
|
cancelSubscription,
|
|
2032
2173
|
cancelPendingDowngrade,
|
|
2033
2174
|
previewPlanChange,
|
|
2175
|
+
previewSeatChange,
|
|
2034
2176
|
verifyAccessToken,
|
|
2035
2177
|
getSubscribeUrl,
|
|
2036
2178
|
redirectToSubscribe,
|
package/dist/server/index.d.cts
CHANGED
|
@@ -358,6 +358,62 @@ type FFIDPlanChangePreview = FFIDPlanChangePreviewBase & ({
|
|
|
358
358
|
interface FFIDPlanChangePreviewResponse {
|
|
359
359
|
preview: FFIDPlanChangePreview;
|
|
360
360
|
}
|
|
361
|
+
/** Parameters for previewing a seat count change */
|
|
362
|
+
interface FFIDPreviewSeatChangeParams {
|
|
363
|
+
/** Subscription ID (UUID) */
|
|
364
|
+
subscriptionId: string;
|
|
365
|
+
/** New seat quantity. Must be an integer within the plan's allowed range. */
|
|
366
|
+
quantity: number;
|
|
367
|
+
}
|
|
368
|
+
/** Seat change preview line item */
|
|
369
|
+
interface FFIDSeatChangeLineItem {
|
|
370
|
+
description: string;
|
|
371
|
+
amount: number;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Seat change proration preview.
|
|
375
|
+
*
|
|
376
|
+
* Sister type to `FFIDPlanChangePreview`. The shared `type` discriminant lets
|
|
377
|
+
* consumers narrow a preview payload without inspecting unrelated fields.
|
|
378
|
+
*
|
|
379
|
+
* - `isEstimate=true` (default when Stripe is not configured or data is unavailable):
|
|
380
|
+
* `proratedAmount` is computed locally as `(newQuantity - currentQuantity) * unitPrice`.
|
|
381
|
+
* - `isEstimate=false`: `proratedAmount` reflects Stripe's live proration calculation.
|
|
382
|
+
*
|
|
383
|
+
* `nextInvoiceAmount` is always a local estimate (`unitPrice * newQuantity`).
|
|
384
|
+
*
|
|
385
|
+
* `pricingUnavailable=true` indicates the plan uses custom pricing with a zero unit
|
|
386
|
+
* price (Enterprise). Consumers should hide monetary amounts in this case.
|
|
387
|
+
*/
|
|
388
|
+
interface FFIDSeatChangePreview {
|
|
389
|
+
/** Discriminant for preview response variants (pairs with `FFIDPlanChangePreview.type`) */
|
|
390
|
+
type: 'seat-change';
|
|
391
|
+
currentQuantity: number;
|
|
392
|
+
newQuantity: number;
|
|
393
|
+
/** Per-seat price for the current billing interval */
|
|
394
|
+
unitPrice: number;
|
|
395
|
+
billingInterval: FFIDBillingInterval;
|
|
396
|
+
/**
|
|
397
|
+
* Prorated cost for the current billing period. Negative when seats are decreased
|
|
398
|
+
* (credit). `0` when `pricingUnavailable === true` (Enterprise custom pricing).
|
|
399
|
+
*/
|
|
400
|
+
proratedAmount: number;
|
|
401
|
+
/** Next invoice full amount — always a local estimate (`unitPrice * newQuantity`) */
|
|
402
|
+
nextInvoiceAmount: number;
|
|
403
|
+
nextInvoiceDate: string | null;
|
|
404
|
+
currency: FFIDSupportedCurrency;
|
|
405
|
+
/** true when proratedAmount is estimated from local prices rather than Stripe proration data */
|
|
406
|
+
isEstimate: boolean;
|
|
407
|
+
/** true when unit price is 0 due to custom pricing (Enterprise) — hide monetary amounts */
|
|
408
|
+
pricingUnavailable?: boolean;
|
|
409
|
+
/** Reason why `isEstimate` is true. Only meaningful when `isEstimate === true`. */
|
|
410
|
+
estimateReason?: 'no_stripe_data' | 'custom_pricing' | 'stripe_error';
|
|
411
|
+
lineItems: FFIDSeatChangeLineItem[];
|
|
412
|
+
}
|
|
413
|
+
/** Response from seat change preview endpoint */
|
|
414
|
+
interface FFIDSeatChangePreviewResponse {
|
|
415
|
+
preview: FFIDSeatChangePreview;
|
|
416
|
+
}
|
|
361
417
|
|
|
362
418
|
/**
|
|
363
419
|
* FFID SDK Type Definitions
|
|
@@ -845,6 +901,7 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
845
901
|
cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
|
|
846
902
|
cancelPendingDowngrade: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDCancelPendingDowngradeResponse>>;
|
|
847
903
|
previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
|
|
904
|
+
previewSeatChange: (params: FFIDPreviewSeatChangeParams) => Promise<FFIDApiResponse<FFIDSeatChangePreviewResponse>>;
|
|
848
905
|
verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
|
|
849
906
|
getSubscribeUrl: (options?: ContractWizardSubscribeOptions) => string;
|
|
850
907
|
redirectToSubscribe: (options?: ContractWizardSubscribeOptions) => FFIDRedirectResult;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -358,6 +358,62 @@ type FFIDPlanChangePreview = FFIDPlanChangePreviewBase & ({
|
|
|
358
358
|
interface FFIDPlanChangePreviewResponse {
|
|
359
359
|
preview: FFIDPlanChangePreview;
|
|
360
360
|
}
|
|
361
|
+
/** Parameters for previewing a seat count change */
|
|
362
|
+
interface FFIDPreviewSeatChangeParams {
|
|
363
|
+
/** Subscription ID (UUID) */
|
|
364
|
+
subscriptionId: string;
|
|
365
|
+
/** New seat quantity. Must be an integer within the plan's allowed range. */
|
|
366
|
+
quantity: number;
|
|
367
|
+
}
|
|
368
|
+
/** Seat change preview line item */
|
|
369
|
+
interface FFIDSeatChangeLineItem {
|
|
370
|
+
description: string;
|
|
371
|
+
amount: number;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Seat change proration preview.
|
|
375
|
+
*
|
|
376
|
+
* Sister type to `FFIDPlanChangePreview`. The shared `type` discriminant lets
|
|
377
|
+
* consumers narrow a preview payload without inspecting unrelated fields.
|
|
378
|
+
*
|
|
379
|
+
* - `isEstimate=true` (default when Stripe is not configured or data is unavailable):
|
|
380
|
+
* `proratedAmount` is computed locally as `(newQuantity - currentQuantity) * unitPrice`.
|
|
381
|
+
* - `isEstimate=false`: `proratedAmount` reflects Stripe's live proration calculation.
|
|
382
|
+
*
|
|
383
|
+
* `nextInvoiceAmount` is always a local estimate (`unitPrice * newQuantity`).
|
|
384
|
+
*
|
|
385
|
+
* `pricingUnavailable=true` indicates the plan uses custom pricing with a zero unit
|
|
386
|
+
* price (Enterprise). Consumers should hide monetary amounts in this case.
|
|
387
|
+
*/
|
|
388
|
+
interface FFIDSeatChangePreview {
|
|
389
|
+
/** Discriminant for preview response variants (pairs with `FFIDPlanChangePreview.type`) */
|
|
390
|
+
type: 'seat-change';
|
|
391
|
+
currentQuantity: number;
|
|
392
|
+
newQuantity: number;
|
|
393
|
+
/** Per-seat price for the current billing interval */
|
|
394
|
+
unitPrice: number;
|
|
395
|
+
billingInterval: FFIDBillingInterval;
|
|
396
|
+
/**
|
|
397
|
+
* Prorated cost for the current billing period. Negative when seats are decreased
|
|
398
|
+
* (credit). `0` when `pricingUnavailable === true` (Enterprise custom pricing).
|
|
399
|
+
*/
|
|
400
|
+
proratedAmount: number;
|
|
401
|
+
/** Next invoice full amount — always a local estimate (`unitPrice * newQuantity`) */
|
|
402
|
+
nextInvoiceAmount: number;
|
|
403
|
+
nextInvoiceDate: string | null;
|
|
404
|
+
currency: FFIDSupportedCurrency;
|
|
405
|
+
/** true when proratedAmount is estimated from local prices rather than Stripe proration data */
|
|
406
|
+
isEstimate: boolean;
|
|
407
|
+
/** true when unit price is 0 due to custom pricing (Enterprise) — hide monetary amounts */
|
|
408
|
+
pricingUnavailable?: boolean;
|
|
409
|
+
/** Reason why `isEstimate` is true. Only meaningful when `isEstimate === true`. */
|
|
410
|
+
estimateReason?: 'no_stripe_data' | 'custom_pricing' | 'stripe_error';
|
|
411
|
+
lineItems: FFIDSeatChangeLineItem[];
|
|
412
|
+
}
|
|
413
|
+
/** Response from seat change preview endpoint */
|
|
414
|
+
interface FFIDSeatChangePreviewResponse {
|
|
415
|
+
preview: FFIDSeatChangePreview;
|
|
416
|
+
}
|
|
361
417
|
|
|
362
418
|
/**
|
|
363
419
|
* FFID SDK Type Definitions
|
|
@@ -845,6 +901,7 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
845
901
|
cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
|
|
846
902
|
cancelPendingDowngrade: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDCancelPendingDowngradeResponse>>;
|
|
847
903
|
previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
|
|
904
|
+
previewSeatChange: (params: FFIDPreviewSeatChangeParams) => Promise<FFIDApiResponse<FFIDSeatChangePreviewResponse>>;
|
|
848
905
|
verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
|
|
849
906
|
getSubscribeUrl: (options?: ContractWizardSubscribeOptions) => string;
|
|
850
907
|
redirectToSubscribe: (options?: ContractWizardSubscribeOptions) => FFIDRedirectResult;
|