@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.
@@ -21,6 +21,193 @@ interface FFIDCacheConfig {
21
21
  ttl: number;
22
22
  }
23
23
 
24
+ /** Billing interval for subscriptions */
25
+ type FFIDBillingInterval = 'monthly' | 'yearly';
26
+ /** Service information returned by plans endpoint */
27
+ interface FFIDServiceInfo {
28
+ id: string;
29
+ code: string;
30
+ name: string;
31
+ description: string | null;
32
+ isActive: boolean;
33
+ createdAt: string;
34
+ plans: FFIDPlanInfo[];
35
+ }
36
+ /** Plan information returned by plans endpoint */
37
+ interface FFIDPlanInfo {
38
+ id: string;
39
+ serviceId: string;
40
+ code: string;
41
+ name: string;
42
+ description: string | null;
43
+ minSeats: number;
44
+ maxSeats: number | null;
45
+ trialDays: number;
46
+ priceMonthly: number;
47
+ priceYearly: number | null;
48
+ currency: string;
49
+ isActive: boolean;
50
+ displayOrder: number;
51
+ customPricing: boolean;
52
+ createdAt: string;
53
+ }
54
+ /** Response from list plans endpoint */
55
+ interface FFIDListPlansResponse {
56
+ services: FFIDServiceInfo[];
57
+ count: number;
58
+ }
59
+ /** Subscription details returned by ext API (sanitized, no Stripe IDs) */
60
+ interface FFIDSubscriptionDetail {
61
+ id: string;
62
+ organizationId: string;
63
+ organizationName: string;
64
+ serviceCode: string;
65
+ serviceName: string;
66
+ planCode: string;
67
+ planName: string;
68
+ status: FFIDSubscriptionStatus;
69
+ paymentMethod: string | null;
70
+ billingInterval: FFIDBillingInterval;
71
+ quantity: number;
72
+ currentPeriodStart: string | null;
73
+ currentPeriodEnd: string | null;
74
+ trialStart: string | null;
75
+ trialEnd: string | null;
76
+ canceledAt: string | null;
77
+ cancelAtPeriodEnd: boolean;
78
+ createdAt: string;
79
+ }
80
+ /** Parameters for subscribing to a plan */
81
+ interface FFIDSubscribeParams {
82
+ /** Organization ID (UUID) */
83
+ organizationId: string;
84
+ /** Plan code (e.g., 'free', 'basic', 'pro') */
85
+ planCode: string;
86
+ /** Billing interval (default: 'monthly') */
87
+ billingInterval?: FFIDBillingInterval;
88
+ /** Number of seats (default: plan's minSeats) */
89
+ quantity?: number;
90
+ /** User ID for seat auto-assignment (only needed for service-key mode) */
91
+ userId?: string;
92
+ }
93
+ /** Sanitized subscription fields returned by subscribe/reactivate endpoints (no Stripe IDs) */
94
+ interface FFIDSubscriptionSummary {
95
+ id: string;
96
+ organizationId: string;
97
+ serviceId: string;
98
+ planId: string;
99
+ status: FFIDSubscriptionStatus;
100
+ paymentMethod: string | null;
101
+ billingInterval: FFIDBillingInterval;
102
+ quantity: number;
103
+ currentPeriodStart: string | null;
104
+ currentPeriodEnd: string | null;
105
+ trialStart: string | null;
106
+ trialEnd: string | null;
107
+ canceledAt: string | null;
108
+ cancelAtPeriodEnd: boolean;
109
+ createdAt: string;
110
+ }
111
+ /** Response from subscribe endpoint */
112
+ interface FFIDSubscribeResponse {
113
+ subscription: FFIDSubscriptionSummary;
114
+ service: {
115
+ id: string;
116
+ code: string;
117
+ name: string;
118
+ };
119
+ plan: {
120
+ id: string;
121
+ code: string;
122
+ name: string;
123
+ priceMonthly: number;
124
+ priceYearly: number | null;
125
+ trialDays: number;
126
+ };
127
+ /** True if a canceled subscription was reactivated */
128
+ reactivated?: boolean;
129
+ /** True if Stripe checkout is needed (canceled paid plan reactivation) */
130
+ needsCheckout?: boolean;
131
+ }
132
+ /** Parameters for changing plan */
133
+ interface FFIDChangePlanParams {
134
+ /** Subscription ID (UUID) */
135
+ subscriptionId: string;
136
+ /** New plan code */
137
+ planCode: string;
138
+ /** New billing interval (default: keeps current) */
139
+ billingInterval?: FFIDBillingInterval;
140
+ }
141
+ /** Response from change plan endpoint */
142
+ interface FFIDChangePlanResponse {
143
+ message: string;
144
+ subscription: {
145
+ id: string;
146
+ organizationId: string;
147
+ serviceCode: string;
148
+ planCode: string;
149
+ planName: string;
150
+ billingInterval: FFIDBillingInterval;
151
+ status: FFIDSubscriptionStatus;
152
+ isUpgrade: boolean;
153
+ };
154
+ }
155
+ /** Parameters for canceling subscription */
156
+ interface FFIDCancelSubscriptionParams {
157
+ /** Subscription ID (UUID) */
158
+ subscriptionId: string;
159
+ /** Cancellation reason code */
160
+ reason?: 'too_expensive' | 'missing_features' | 'switched_service' | 'rarely_used' | 'customer_service' | 'other';
161
+ /** Additional cancellation details */
162
+ reasonDetails?: string;
163
+ }
164
+ /** Response from cancel subscription endpoint */
165
+ interface FFIDCancelSubscriptionResponse {
166
+ message: string;
167
+ subscription: {
168
+ id: string;
169
+ organizationId: string;
170
+ status: FFIDSubscriptionStatus;
171
+ canceledAt: string | null;
172
+ };
173
+ }
174
+ /** Parameters for previewing plan change */
175
+ interface FFIDPreviewPlanChangeParams {
176
+ /** Subscription ID (UUID) */
177
+ subscriptionId: string;
178
+ /** New plan code */
179
+ planCode: string;
180
+ /** New billing interval (default: keeps current) */
181
+ billingInterval?: FFIDBillingInterval;
182
+ }
183
+ /** Plan change preview line item */
184
+ interface FFIDPlanChangeLineItem {
185
+ description: string;
186
+ amount: number;
187
+ }
188
+ /** Response from plan change preview endpoint */
189
+ interface FFIDPlanChangePreviewResponse {
190
+ preview: {
191
+ currentPlan: {
192
+ name: string;
193
+ price: number;
194
+ };
195
+ newPlan: {
196
+ name: string;
197
+ price: number;
198
+ };
199
+ billingInterval: FFIDBillingInterval;
200
+ isUpgrade: boolean;
201
+ proratedAmount: number;
202
+ nextInvoiceAmount: number;
203
+ nextInvoiceDate: string | null;
204
+ currency: string;
205
+ isEstimate: boolean;
206
+ estimateReason?: string;
207
+ lineItems: FFIDPlanChangeLineItem[];
208
+ };
209
+ }
210
+
24
211
  /**
25
212
  * FFID SDK Type Definitions
26
213
  *
@@ -103,7 +290,7 @@ interface FFIDSubscription {
103
290
  /** Plan display name */
104
291
  planName: string;
105
292
  /** Subscription status */
106
- status: 'trialing' | 'active' | 'past_due' | 'canceled' | 'paused';
293
+ status: FFIDSubscriptionStatus;
107
294
  /** Current billing period end date */
108
295
  currentPeriodEnd: string | null;
109
296
  /** Trial end date (null if not a trial or no trial_end set) */
@@ -118,7 +305,7 @@ interface FFIDSubscription {
118
305
  /** OAuth userinfo subscription summary */
119
306
  interface FFIDOAuthUserInfoSubscription {
120
307
  subscriptionId: string | null;
121
- status: 'trialing' | 'active' | 'past_due' | 'canceled' | 'paused' | null;
308
+ status: FFIDSubscriptionStatus | null;
122
309
  planCode: string | null;
123
310
  seatModel: FFIDSeatModel | null;
124
311
  memberRole: FFIDOAuthUserInfoMemberRole | null;
@@ -255,9 +442,6 @@ type FFIDApiResponse<T> = {
255
442
  data?: undefined;
256
443
  error: FFIDError;
257
444
  };
258
- /**
259
- * Subscription check response from ext/check endpoint
260
- */
261
445
  /** Subscription status values matching the FFID platform's SubscriptionStatus type */
262
446
  type FFIDSubscriptionStatus = 'trialing' | 'active' | 'past_due' | 'canceled' | 'pending_invoice' | 'paused' | 'incomplete' | 'incomplete_expired' | 'unpaid';
263
447
  interface FFIDSubscriptionCheckResponse {
@@ -308,6 +492,7 @@ interface FFIDCreatePortalParams {
308
492
  /** URL to redirect when user exits the portal */
309
493
  returnUrl: string;
310
494
  }
495
+
311
496
  /** Member role in an organization */
312
497
  type FFIDMemberRole = 'owner' | 'admin' | 'member' | 'viewer';
313
498
  /** Member status in an organization */
@@ -476,6 +661,12 @@ declare function createFFIDClient(config: FFIDConfig): {
476
661
  }) => Promise<FFIDApiResponse<FFIDRemoveMemberResponse>>;
477
662
  createCheckoutSession: (params: FFIDCreateCheckoutParams) => Promise<FFIDApiResponse<FFIDCheckoutSessionResponse>>;
478
663
  createPortalSession: (params: FFIDCreatePortalParams) => Promise<FFIDApiResponse<FFIDPortalSessionResponse>>;
664
+ listPlans: () => Promise<FFIDApiResponse<FFIDListPlansResponse>>;
665
+ getSubscription: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDSubscriptionDetail>>;
666
+ subscribe: (params: FFIDSubscribeParams) => Promise<FFIDApiResponse<FFIDSubscribeResponse>>;
667
+ changePlan: (params: FFIDChangePlanParams) => Promise<FFIDApiResponse<FFIDChangePlanResponse>>;
668
+ cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
669
+ previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
479
670
  verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
480
671
  requestPasswordReset: (email: string) => Promise<FFIDApiResponse<FFIDPasswordResetResponse>>;
481
672
  verifyPasswordResetToken: (accessToken: string) => Promise<FFIDApiResponse<FFIDPasswordResetVerifyResponse>>;
@@ -21,6 +21,193 @@ interface FFIDCacheConfig {
21
21
  ttl: number;
22
22
  }
23
23
 
24
+ /** Billing interval for subscriptions */
25
+ type FFIDBillingInterval = 'monthly' | 'yearly';
26
+ /** Service information returned by plans endpoint */
27
+ interface FFIDServiceInfo {
28
+ id: string;
29
+ code: string;
30
+ name: string;
31
+ description: string | null;
32
+ isActive: boolean;
33
+ createdAt: string;
34
+ plans: FFIDPlanInfo[];
35
+ }
36
+ /** Plan information returned by plans endpoint */
37
+ interface FFIDPlanInfo {
38
+ id: string;
39
+ serviceId: string;
40
+ code: string;
41
+ name: string;
42
+ description: string | null;
43
+ minSeats: number;
44
+ maxSeats: number | null;
45
+ trialDays: number;
46
+ priceMonthly: number;
47
+ priceYearly: number | null;
48
+ currency: string;
49
+ isActive: boolean;
50
+ displayOrder: number;
51
+ customPricing: boolean;
52
+ createdAt: string;
53
+ }
54
+ /** Response from list plans endpoint */
55
+ interface FFIDListPlansResponse {
56
+ services: FFIDServiceInfo[];
57
+ count: number;
58
+ }
59
+ /** Subscription details returned by ext API (sanitized, no Stripe IDs) */
60
+ interface FFIDSubscriptionDetail {
61
+ id: string;
62
+ organizationId: string;
63
+ organizationName: string;
64
+ serviceCode: string;
65
+ serviceName: string;
66
+ planCode: string;
67
+ planName: string;
68
+ status: FFIDSubscriptionStatus;
69
+ paymentMethod: string | null;
70
+ billingInterval: FFIDBillingInterval;
71
+ quantity: number;
72
+ currentPeriodStart: string | null;
73
+ currentPeriodEnd: string | null;
74
+ trialStart: string | null;
75
+ trialEnd: string | null;
76
+ canceledAt: string | null;
77
+ cancelAtPeriodEnd: boolean;
78
+ createdAt: string;
79
+ }
80
+ /** Parameters for subscribing to a plan */
81
+ interface FFIDSubscribeParams {
82
+ /** Organization ID (UUID) */
83
+ organizationId: string;
84
+ /** Plan code (e.g., 'free', 'basic', 'pro') */
85
+ planCode: string;
86
+ /** Billing interval (default: 'monthly') */
87
+ billingInterval?: FFIDBillingInterval;
88
+ /** Number of seats (default: plan's minSeats) */
89
+ quantity?: number;
90
+ /** User ID for seat auto-assignment (only needed for service-key mode) */
91
+ userId?: string;
92
+ }
93
+ /** Sanitized subscription fields returned by subscribe/reactivate endpoints (no Stripe IDs) */
94
+ interface FFIDSubscriptionSummary {
95
+ id: string;
96
+ organizationId: string;
97
+ serviceId: string;
98
+ planId: string;
99
+ status: FFIDSubscriptionStatus;
100
+ paymentMethod: string | null;
101
+ billingInterval: FFIDBillingInterval;
102
+ quantity: number;
103
+ currentPeriodStart: string | null;
104
+ currentPeriodEnd: string | null;
105
+ trialStart: string | null;
106
+ trialEnd: string | null;
107
+ canceledAt: string | null;
108
+ cancelAtPeriodEnd: boolean;
109
+ createdAt: string;
110
+ }
111
+ /** Response from subscribe endpoint */
112
+ interface FFIDSubscribeResponse {
113
+ subscription: FFIDSubscriptionSummary;
114
+ service: {
115
+ id: string;
116
+ code: string;
117
+ name: string;
118
+ };
119
+ plan: {
120
+ id: string;
121
+ code: string;
122
+ name: string;
123
+ priceMonthly: number;
124
+ priceYearly: number | null;
125
+ trialDays: number;
126
+ };
127
+ /** True if a canceled subscription was reactivated */
128
+ reactivated?: boolean;
129
+ /** True if Stripe checkout is needed (canceled paid plan reactivation) */
130
+ needsCheckout?: boolean;
131
+ }
132
+ /** Parameters for changing plan */
133
+ interface FFIDChangePlanParams {
134
+ /** Subscription ID (UUID) */
135
+ subscriptionId: string;
136
+ /** New plan code */
137
+ planCode: string;
138
+ /** New billing interval (default: keeps current) */
139
+ billingInterval?: FFIDBillingInterval;
140
+ }
141
+ /** Response from change plan endpoint */
142
+ interface FFIDChangePlanResponse {
143
+ message: string;
144
+ subscription: {
145
+ id: string;
146
+ organizationId: string;
147
+ serviceCode: string;
148
+ planCode: string;
149
+ planName: string;
150
+ billingInterval: FFIDBillingInterval;
151
+ status: FFIDSubscriptionStatus;
152
+ isUpgrade: boolean;
153
+ };
154
+ }
155
+ /** Parameters for canceling subscription */
156
+ interface FFIDCancelSubscriptionParams {
157
+ /** Subscription ID (UUID) */
158
+ subscriptionId: string;
159
+ /** Cancellation reason code */
160
+ reason?: 'too_expensive' | 'missing_features' | 'switched_service' | 'rarely_used' | 'customer_service' | 'other';
161
+ /** Additional cancellation details */
162
+ reasonDetails?: string;
163
+ }
164
+ /** Response from cancel subscription endpoint */
165
+ interface FFIDCancelSubscriptionResponse {
166
+ message: string;
167
+ subscription: {
168
+ id: string;
169
+ organizationId: string;
170
+ status: FFIDSubscriptionStatus;
171
+ canceledAt: string | null;
172
+ };
173
+ }
174
+ /** Parameters for previewing plan change */
175
+ interface FFIDPreviewPlanChangeParams {
176
+ /** Subscription ID (UUID) */
177
+ subscriptionId: string;
178
+ /** New plan code */
179
+ planCode: string;
180
+ /** New billing interval (default: keeps current) */
181
+ billingInterval?: FFIDBillingInterval;
182
+ }
183
+ /** Plan change preview line item */
184
+ interface FFIDPlanChangeLineItem {
185
+ description: string;
186
+ amount: number;
187
+ }
188
+ /** Response from plan change preview endpoint */
189
+ interface FFIDPlanChangePreviewResponse {
190
+ preview: {
191
+ currentPlan: {
192
+ name: string;
193
+ price: number;
194
+ };
195
+ newPlan: {
196
+ name: string;
197
+ price: number;
198
+ };
199
+ billingInterval: FFIDBillingInterval;
200
+ isUpgrade: boolean;
201
+ proratedAmount: number;
202
+ nextInvoiceAmount: number;
203
+ nextInvoiceDate: string | null;
204
+ currency: string;
205
+ isEstimate: boolean;
206
+ estimateReason?: string;
207
+ lineItems: FFIDPlanChangeLineItem[];
208
+ };
209
+ }
210
+
24
211
  /**
25
212
  * FFID SDK Type Definitions
26
213
  *
@@ -103,7 +290,7 @@ interface FFIDSubscription {
103
290
  /** Plan display name */
104
291
  planName: string;
105
292
  /** Subscription status */
106
- status: 'trialing' | 'active' | 'past_due' | 'canceled' | 'paused';
293
+ status: FFIDSubscriptionStatus;
107
294
  /** Current billing period end date */
108
295
  currentPeriodEnd: string | null;
109
296
  /** Trial end date (null if not a trial or no trial_end set) */
@@ -118,7 +305,7 @@ interface FFIDSubscription {
118
305
  /** OAuth userinfo subscription summary */
119
306
  interface FFIDOAuthUserInfoSubscription {
120
307
  subscriptionId: string | null;
121
- status: 'trialing' | 'active' | 'past_due' | 'canceled' | 'paused' | null;
308
+ status: FFIDSubscriptionStatus | null;
122
309
  planCode: string | null;
123
310
  seatModel: FFIDSeatModel | null;
124
311
  memberRole: FFIDOAuthUserInfoMemberRole | null;
@@ -255,9 +442,6 @@ type FFIDApiResponse<T> = {
255
442
  data?: undefined;
256
443
  error: FFIDError;
257
444
  };
258
- /**
259
- * Subscription check response from ext/check endpoint
260
- */
261
445
  /** Subscription status values matching the FFID platform's SubscriptionStatus type */
262
446
  type FFIDSubscriptionStatus = 'trialing' | 'active' | 'past_due' | 'canceled' | 'pending_invoice' | 'paused' | 'incomplete' | 'incomplete_expired' | 'unpaid';
263
447
  interface FFIDSubscriptionCheckResponse {
@@ -308,6 +492,7 @@ interface FFIDCreatePortalParams {
308
492
  /** URL to redirect when user exits the portal */
309
493
  returnUrl: string;
310
494
  }
495
+
311
496
  /** Member role in an organization */
312
497
  type FFIDMemberRole = 'owner' | 'admin' | 'member' | 'viewer';
313
498
  /** Member status in an organization */
@@ -476,6 +661,12 @@ declare function createFFIDClient(config: FFIDConfig): {
476
661
  }) => Promise<FFIDApiResponse<FFIDRemoveMemberResponse>>;
477
662
  createCheckoutSession: (params: FFIDCreateCheckoutParams) => Promise<FFIDApiResponse<FFIDCheckoutSessionResponse>>;
478
663
  createPortalSession: (params: FFIDCreatePortalParams) => Promise<FFIDApiResponse<FFIDPortalSessionResponse>>;
664
+ listPlans: () => Promise<FFIDApiResponse<FFIDListPlansResponse>>;
665
+ getSubscription: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDSubscriptionDetail>>;
666
+ subscribe: (params: FFIDSubscribeParams) => Promise<FFIDApiResponse<FFIDSubscribeResponse>>;
667
+ changePlan: (params: FFIDChangePlanParams) => Promise<FFIDApiResponse<FFIDChangePlanResponse>>;
668
+ cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
669
+ previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
479
670
  verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
480
671
  requestPasswordReset: (email: string) => Promise<FFIDApiResponse<FFIDPasswordResetResponse>>;
481
672
  verifyPasswordResetToken: (accessToken: string) => Promise<FFIDApiResponse<FFIDPasswordResetVerifyResponse>>;
@@ -442,6 +442,106 @@ function createBillingMethods(deps) {
442
442
  return { createCheckoutSession, createPortalSession };
443
443
  }
444
444
 
445
+ // src/client/subscription-methods.ts
446
+ var EXT_PLANS_ENDPOINT = "/api/v1/subscriptions/ext/plans";
447
+ var EXT_SUBSCRIPTION_ENDPOINT = "/api/v1/subscriptions/ext";
448
+ var EXT_SUBSCRIBE_ENDPOINT = "/api/v1/subscriptions/ext/subscribe";
449
+ function createSubscriptionMethods(deps) {
450
+ const { fetchWithAuth, createError } = deps;
451
+ async function listPlans() {
452
+ return fetchWithAuth(EXT_PLANS_ENDPOINT);
453
+ }
454
+ async function getSubscription(subscriptionId) {
455
+ if (!subscriptionId) {
456
+ return {
457
+ error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
458
+ };
459
+ }
460
+ return fetchWithAuth(
461
+ `${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(subscriptionId)}`
462
+ );
463
+ }
464
+ async function subscribe(params) {
465
+ if (!params.organizationId || !params.planCode) {
466
+ return {
467
+ error: createError("VALIDATION_ERROR", "organizationId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
468
+ };
469
+ }
470
+ return fetchWithAuth(
471
+ EXT_SUBSCRIBE_ENDPOINT,
472
+ {
473
+ method: "POST",
474
+ body: JSON.stringify({
475
+ organizationId: params.organizationId,
476
+ planCode: params.planCode,
477
+ ...params.billingInterval ? { billingInterval: params.billingInterval } : {},
478
+ ...params.quantity !== void 0 ? { quantity: params.quantity } : {},
479
+ ...params.userId ? { userId: params.userId } : {}
480
+ })
481
+ }
482
+ );
483
+ }
484
+ async function changePlan(params) {
485
+ if (!params.subscriptionId || !params.planCode) {
486
+ return {
487
+ error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
488
+ };
489
+ }
490
+ return fetchWithAuth(
491
+ `${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}/plan`,
492
+ {
493
+ method: "PUT",
494
+ body: JSON.stringify({
495
+ planCode: params.planCode,
496
+ ...params.billingInterval ? { billingInterval: params.billingInterval } : {}
497
+ })
498
+ }
499
+ );
500
+ }
501
+ async function cancelSubscription(params) {
502
+ if (!params.subscriptionId) {
503
+ return {
504
+ error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
505
+ };
506
+ }
507
+ const body = {};
508
+ if (params.reason) body.reason = params.reason;
509
+ if (params.reasonDetails) body.reasonDetails = params.reasonDetails;
510
+ return fetchWithAuth(
511
+ `${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}`,
512
+ {
513
+ method: "DELETE",
514
+ ...Object.keys(body).length > 0 ? { body: JSON.stringify(body) } : {}
515
+ }
516
+ );
517
+ }
518
+ async function previewPlanChange(params) {
519
+ if (!params.subscriptionId || !params.planCode) {
520
+ return {
521
+ error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
522
+ };
523
+ }
524
+ return fetchWithAuth(
525
+ `${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}/plan/preview`,
526
+ {
527
+ method: "POST",
528
+ body: JSON.stringify({
529
+ planCode: params.planCode,
530
+ ...params.billingInterval ? { billingInterval: params.billingInterval } : {}
531
+ })
532
+ }
533
+ );
534
+ }
535
+ return {
536
+ listPlans,
537
+ getSubscription,
538
+ subscribe,
539
+ changePlan,
540
+ cancelSubscription,
541
+ previewPlanChange
542
+ };
543
+ }
544
+
445
545
  // src/client/members-methods.ts
446
546
  var EXT_MEMBERS_ENDPOINT = "/api/v1/organizations/ext/members";
447
547
  function createMembersMethods(deps) {
@@ -495,7 +595,7 @@ function createMembersMethods(deps) {
495
595
  }
496
596
 
497
597
  // src/client/version-check.ts
498
- var SDK_VERSION = "1.18.0";
598
+ var SDK_VERSION = "1.19.0";
499
599
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
500
600
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
501
601
  function sdkHeaders() {
@@ -1555,6 +1655,17 @@ function createFFIDClient(config) {
1555
1655
  fetchWithAuth,
1556
1656
  createError
1557
1657
  });
1658
+ const {
1659
+ listPlans,
1660
+ getSubscription,
1661
+ subscribe,
1662
+ changePlan,
1663
+ cancelSubscription,
1664
+ previewPlanChange
1665
+ } = createSubscriptionMethods({
1666
+ fetchWithAuth,
1667
+ createError
1668
+ });
1558
1669
  const { listMembers, updateMemberRole, removeMember } = createMembersMethods({
1559
1670
  fetchWithAuth,
1560
1671
  createError,
@@ -1608,6 +1719,12 @@ function createFFIDClient(config) {
1608
1719
  removeMember,
1609
1720
  createCheckoutSession,
1610
1721
  createPortalSession,
1722
+ listPlans,
1723
+ getSubscription,
1724
+ subscribe,
1725
+ changePlan,
1726
+ cancelSubscription,
1727
+ previewPlanChange,
1611
1728
  verifyAccessToken,
1612
1729
  requestPasswordReset,
1613
1730
  verifyPasswordResetToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feelflow/ffid-sdk",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "FeelFlow ID Platform SDK for React/Next.js applications",
5
5
  "keywords": [
6
6
  "feelflow",