@feelflow/ffid-sdk 2.4.0 → 2.5.1

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.
@@ -449,13 +449,16 @@ function createBillingMethods(deps) {
449
449
  var EXT_PLANS_ENDPOINT = "/api/v1/subscriptions/ext/plans";
450
450
  var EXT_SUBSCRIPTION_ENDPOINT = "/api/v1/subscriptions/ext";
451
451
  var EXT_SUBSCRIBE_ENDPOINT = "/api/v1/subscriptions/ext/subscribe";
452
+ function isBlankString(value) {
453
+ return typeof value !== "string" || value.trim() === "";
454
+ }
452
455
  function createSubscriptionMethods(deps) {
453
456
  const { fetchWithAuth, createError } = deps;
454
457
  async function listPlans() {
455
458
  return fetchWithAuth(EXT_PLANS_ENDPOINT);
456
459
  }
457
460
  async function getSubscription(subscriptionId) {
458
- if (!subscriptionId) {
461
+ if (isBlankString(subscriptionId)) {
459
462
  return {
460
463
  error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
461
464
  };
@@ -485,7 +488,7 @@ function createSubscriptionMethods(deps) {
485
488
  );
486
489
  }
487
490
  async function changePlan(params) {
488
- if (!params.subscriptionId || !params.planCode) {
491
+ if (isBlankString(params.subscriptionId) || isBlankString(params.planCode)) {
489
492
  return {
490
493
  error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
491
494
  };
@@ -502,7 +505,7 @@ function createSubscriptionMethods(deps) {
502
505
  );
503
506
  }
504
507
  async function cancelSubscription(params) {
505
- if (!params.subscriptionId) {
508
+ if (isBlankString(params.subscriptionId)) {
506
509
  return {
507
510
  error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
508
511
  };
@@ -518,8 +521,19 @@ function createSubscriptionMethods(deps) {
518
521
  }
519
522
  );
520
523
  }
524
+ async function cancelPendingDowngrade(subscriptionId) {
525
+ if (isBlankString(subscriptionId)) {
526
+ return {
527
+ error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
528
+ };
529
+ }
530
+ return fetchWithAuth(
531
+ `${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(subscriptionId)}/pending-downgrade`,
532
+ { method: "DELETE" }
533
+ );
534
+ }
521
535
  async function previewPlanChange(params) {
522
- if (!params.subscriptionId || !params.planCode) {
536
+ if (isBlankString(params.subscriptionId) || isBlankString(params.planCode)) {
523
537
  return {
524
538
  error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
525
539
  };
@@ -541,6 +555,7 @@ function createSubscriptionMethods(deps) {
541
555
  subscribe,
542
556
  changePlan,
543
557
  cancelSubscription,
558
+ cancelPendingDowngrade,
544
559
  previewPlanChange
545
560
  };
546
561
  }
@@ -598,7 +613,7 @@ function createMembersMethods(deps) {
598
613
  }
599
614
 
600
615
  // src/client/version-check.ts
601
- var SDK_VERSION = "2.4.0";
616
+ var SDK_VERSION = "2.5.1";
602
617
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
603
618
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
604
619
  function sdkHeaders() {
@@ -1772,6 +1787,7 @@ function createFFIDClient(config) {
1772
1787
  subscribe,
1773
1788
  changePlan,
1774
1789
  cancelSubscription,
1790
+ cancelPendingDowngrade,
1775
1791
  previewPlanChange
1776
1792
  } = createSubscriptionMethods({
1777
1793
  fetchWithAuth,
@@ -1851,6 +1867,7 @@ function createFFIDClient(config) {
1851
1867
  subscribe,
1852
1868
  changePlan,
1853
1869
  cancelSubscription,
1870
+ cancelPendingDowngrade,
1854
1871
  previewPlanChange,
1855
1872
  verifyAccessToken,
1856
1873
  getSubscribeUrl,
@@ -451,13 +451,16 @@ function createBillingMethods(deps) {
451
451
  var EXT_PLANS_ENDPOINT = "/api/v1/subscriptions/ext/plans";
452
452
  var EXT_SUBSCRIPTION_ENDPOINT = "/api/v1/subscriptions/ext";
453
453
  var EXT_SUBSCRIBE_ENDPOINT = "/api/v1/subscriptions/ext/subscribe";
454
+ function isBlankString(value) {
455
+ return typeof value !== "string" || value.trim() === "";
456
+ }
454
457
  function createSubscriptionMethods(deps) {
455
458
  const { fetchWithAuth, createError } = deps;
456
459
  async function listPlans() {
457
460
  return fetchWithAuth(EXT_PLANS_ENDPOINT);
458
461
  }
459
462
  async function getSubscription(subscriptionId) {
460
- if (!subscriptionId) {
463
+ if (isBlankString(subscriptionId)) {
461
464
  return {
462
465
  error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
463
466
  };
@@ -487,7 +490,7 @@ function createSubscriptionMethods(deps) {
487
490
  );
488
491
  }
489
492
  async function changePlan(params) {
490
- if (!params.subscriptionId || !params.planCode) {
493
+ if (isBlankString(params.subscriptionId) || isBlankString(params.planCode)) {
491
494
  return {
492
495
  error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
493
496
  };
@@ -504,7 +507,7 @@ function createSubscriptionMethods(deps) {
504
507
  );
505
508
  }
506
509
  async function cancelSubscription(params) {
507
- if (!params.subscriptionId) {
510
+ if (isBlankString(params.subscriptionId)) {
508
511
  return {
509
512
  error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
510
513
  };
@@ -520,8 +523,19 @@ function createSubscriptionMethods(deps) {
520
523
  }
521
524
  );
522
525
  }
526
+ async function cancelPendingDowngrade(subscriptionId) {
527
+ if (isBlankString(subscriptionId)) {
528
+ return {
529
+ error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
530
+ };
531
+ }
532
+ return fetchWithAuth(
533
+ `${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(subscriptionId)}/pending-downgrade`,
534
+ { method: "DELETE" }
535
+ );
536
+ }
523
537
  async function previewPlanChange(params) {
524
- if (!params.subscriptionId || !params.planCode) {
538
+ if (isBlankString(params.subscriptionId) || isBlankString(params.planCode)) {
525
539
  return {
526
540
  error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
527
541
  };
@@ -543,6 +557,7 @@ function createSubscriptionMethods(deps) {
543
557
  subscribe,
544
558
  changePlan,
545
559
  cancelSubscription,
560
+ cancelPendingDowngrade,
546
561
  previewPlanChange
547
562
  };
548
563
  }
@@ -600,7 +615,7 @@ function createMembersMethods(deps) {
600
615
  }
601
616
 
602
617
  // src/client/version-check.ts
603
- var SDK_VERSION = "2.4.0";
618
+ var SDK_VERSION = "2.5.1";
604
619
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
605
620
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
606
621
  function sdkHeaders() {
@@ -1774,6 +1789,7 @@ function createFFIDClient(config) {
1774
1789
  subscribe,
1775
1790
  changePlan,
1776
1791
  cancelSubscription,
1792
+ cancelPendingDowngrade,
1777
1793
  previewPlanChange
1778
1794
  } = createSubscriptionMethods({
1779
1795
  fetchWithAuth,
@@ -1853,6 +1869,7 @@ function createFFIDClient(config) {
1853
1869
  subscribe,
1854
1870
  changePlan,
1855
1871
  cancelSubscription,
1872
+ cancelPendingDowngrade,
1856
1873
  previewPlanChange,
1857
1874
  verifyAccessToken,
1858
1875
  getSubscribeUrl,
@@ -1,30 +1,30 @@
1
1
  'use strict';
2
2
 
3
- var chunkCECTOY4A_cjs = require('../chunk-CECTOY4A.cjs');
3
+ var chunkPFPIILLQ_cjs = require('../chunk-PFPIILLQ.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "FFIDAnnouncementBadge", {
8
8
  enumerable: true,
9
- get: function () { return chunkCECTOY4A_cjs.FFIDAnnouncementBadge; }
9
+ get: function () { return chunkPFPIILLQ_cjs.FFIDAnnouncementBadge; }
10
10
  });
11
11
  Object.defineProperty(exports, "FFIDAnnouncementList", {
12
12
  enumerable: true,
13
- get: function () { return chunkCECTOY4A_cjs.FFIDAnnouncementList; }
13
+ get: function () { return chunkPFPIILLQ_cjs.FFIDAnnouncementList; }
14
14
  });
15
15
  Object.defineProperty(exports, "FFIDLoginButton", {
16
16
  enumerable: true,
17
- get: function () { return chunkCECTOY4A_cjs.FFIDLoginButton; }
17
+ get: function () { return chunkPFPIILLQ_cjs.FFIDLoginButton; }
18
18
  });
19
19
  Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
20
20
  enumerable: true,
21
- get: function () { return chunkCECTOY4A_cjs.FFIDOrganizationSwitcher; }
21
+ get: function () { return chunkPFPIILLQ_cjs.FFIDOrganizationSwitcher; }
22
22
  });
23
23
  Object.defineProperty(exports, "FFIDSubscriptionBadge", {
24
24
  enumerable: true,
25
- get: function () { return chunkCECTOY4A_cjs.FFIDSubscriptionBadge; }
25
+ get: function () { return chunkPFPIILLQ_cjs.FFIDSubscriptionBadge; }
26
26
  });
27
27
  Object.defineProperty(exports, "FFIDUserMenu", {
28
28
  enumerable: true,
29
- get: function () { return chunkCECTOY4A_cjs.FFIDUserMenu; }
29
+ get: function () { return chunkPFPIILLQ_cjs.FFIDUserMenu; }
30
30
  });
@@ -1 +1 @@
1
- export { FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-VJHI6RQQ.js';
1
+ export { FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-GGPL4Z2O.js';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkCECTOY4A_cjs = require('./chunk-CECTOY4A.cjs');
3
+ var chunkPFPIILLQ_cjs = require('./chunk-PFPIILLQ.cjs');
4
4
  var react = require('react');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
 
@@ -46,7 +46,7 @@ function createKVCacheAdapter(kv) {
46
46
  }
47
47
  function withFFIDAuth(Component, options = {}) {
48
48
  const WrappedComponent = (props) => {
49
- const { isLoading, isAuthenticated, login } = chunkCECTOY4A_cjs.useFFIDContext();
49
+ const { isLoading, isAuthenticated, login } = chunkPFPIILLQ_cjs.useFFIDContext();
50
50
  const hasRedirected = react.useRef(false);
51
51
  react.useEffect(() => {
52
52
  if (!isLoading && !isAuthenticated && options.redirectToLogin && !hasRedirected.current) {
@@ -71,83 +71,83 @@ function withFFIDAuth(Component, options = {}) {
71
71
 
72
72
  Object.defineProperty(exports, "DEFAULT_API_BASE_URL", {
73
73
  enumerable: true,
74
- get: function () { return chunkCECTOY4A_cjs.DEFAULT_API_BASE_URL; }
74
+ get: function () { return chunkPFPIILLQ_cjs.DEFAULT_API_BASE_URL; }
75
75
  });
76
76
  Object.defineProperty(exports, "FFIDAnnouncementBadge", {
77
77
  enumerable: true,
78
- get: function () { return chunkCECTOY4A_cjs.FFIDAnnouncementBadge; }
78
+ get: function () { return chunkPFPIILLQ_cjs.FFIDAnnouncementBadge; }
79
79
  });
80
80
  Object.defineProperty(exports, "FFIDAnnouncementList", {
81
81
  enumerable: true,
82
- get: function () { return chunkCECTOY4A_cjs.FFIDAnnouncementList; }
82
+ get: function () { return chunkPFPIILLQ_cjs.FFIDAnnouncementList; }
83
83
  });
84
84
  Object.defineProperty(exports, "FFIDLoginButton", {
85
85
  enumerable: true,
86
- get: function () { return chunkCECTOY4A_cjs.FFIDLoginButton; }
86
+ get: function () { return chunkPFPIILLQ_cjs.FFIDLoginButton; }
87
87
  });
88
88
  Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
89
89
  enumerable: true,
90
- get: function () { return chunkCECTOY4A_cjs.FFIDOrganizationSwitcher; }
90
+ get: function () { return chunkPFPIILLQ_cjs.FFIDOrganizationSwitcher; }
91
91
  });
92
92
  Object.defineProperty(exports, "FFIDProvider", {
93
93
  enumerable: true,
94
- get: function () { return chunkCECTOY4A_cjs.FFIDProvider; }
94
+ get: function () { return chunkPFPIILLQ_cjs.FFIDProvider; }
95
95
  });
96
96
  Object.defineProperty(exports, "FFIDSubscriptionBadge", {
97
97
  enumerable: true,
98
- get: function () { return chunkCECTOY4A_cjs.FFIDSubscriptionBadge; }
98
+ get: function () { return chunkPFPIILLQ_cjs.FFIDSubscriptionBadge; }
99
99
  });
100
100
  Object.defineProperty(exports, "FFIDUserMenu", {
101
101
  enumerable: true,
102
- get: function () { return chunkCECTOY4A_cjs.FFIDUserMenu; }
102
+ get: function () { return chunkPFPIILLQ_cjs.FFIDUserMenu; }
103
103
  });
104
104
  Object.defineProperty(exports, "FFID_ANNOUNCEMENTS_ERROR_CODES", {
105
105
  enumerable: true,
106
- get: function () { return chunkCECTOY4A_cjs.FFID_ANNOUNCEMENTS_ERROR_CODES; }
106
+ get: function () { return chunkPFPIILLQ_cjs.FFID_ANNOUNCEMENTS_ERROR_CODES; }
107
107
  });
108
108
  Object.defineProperty(exports, "createFFIDAnnouncementsClient", {
109
109
  enumerable: true,
110
- get: function () { return chunkCECTOY4A_cjs.createFFIDAnnouncementsClient; }
110
+ get: function () { return chunkPFPIILLQ_cjs.createFFIDAnnouncementsClient; }
111
111
  });
112
112
  Object.defineProperty(exports, "createFFIDClient", {
113
113
  enumerable: true,
114
- get: function () { return chunkCECTOY4A_cjs.createFFIDClient; }
114
+ get: function () { return chunkPFPIILLQ_cjs.createFFIDClient; }
115
115
  });
116
116
  Object.defineProperty(exports, "createTokenStore", {
117
117
  enumerable: true,
118
- get: function () { return chunkCECTOY4A_cjs.createTokenStore; }
118
+ get: function () { return chunkPFPIILLQ_cjs.createTokenStore; }
119
119
  });
120
120
  Object.defineProperty(exports, "generateCodeChallenge", {
121
121
  enumerable: true,
122
- get: function () { return chunkCECTOY4A_cjs.generateCodeChallenge; }
122
+ get: function () { return chunkPFPIILLQ_cjs.generateCodeChallenge; }
123
123
  });
124
124
  Object.defineProperty(exports, "generateCodeVerifier", {
125
125
  enumerable: true,
126
- get: function () { return chunkCECTOY4A_cjs.generateCodeVerifier; }
126
+ get: function () { return chunkPFPIILLQ_cjs.generateCodeVerifier; }
127
127
  });
128
128
  Object.defineProperty(exports, "retrieveCodeVerifier", {
129
129
  enumerable: true,
130
- get: function () { return chunkCECTOY4A_cjs.retrieveCodeVerifier; }
130
+ get: function () { return chunkPFPIILLQ_cjs.retrieveCodeVerifier; }
131
131
  });
132
132
  Object.defineProperty(exports, "storeCodeVerifier", {
133
133
  enumerable: true,
134
- get: function () { return chunkCECTOY4A_cjs.storeCodeVerifier; }
134
+ get: function () { return chunkPFPIILLQ_cjs.storeCodeVerifier; }
135
135
  });
136
136
  Object.defineProperty(exports, "useFFID", {
137
137
  enumerable: true,
138
- get: function () { return chunkCECTOY4A_cjs.useFFID; }
138
+ get: function () { return chunkPFPIILLQ_cjs.useFFID; }
139
139
  });
140
140
  Object.defineProperty(exports, "useFFIDAnnouncements", {
141
141
  enumerable: true,
142
- get: function () { return chunkCECTOY4A_cjs.useFFIDAnnouncements; }
142
+ get: function () { return chunkPFPIILLQ_cjs.useFFIDAnnouncements; }
143
143
  });
144
144
  Object.defineProperty(exports, "useSubscription", {
145
145
  enumerable: true,
146
- get: function () { return chunkCECTOY4A_cjs.useSubscription; }
146
+ get: function () { return chunkPFPIILLQ_cjs.useSubscription; }
147
147
  });
148
148
  Object.defineProperty(exports, "withSubscription", {
149
149
  enumerable: true,
150
- get: function () { return chunkCECTOY4A_cjs.withSubscription; }
150
+ get: function () { return chunkPFPIILLQ_cjs.withSubscription; }
151
151
  });
152
152
  exports.createKVCacheAdapter = createKVCacheAdapter;
153
153
  exports.createMemoryCacheAdapter = createMemoryCacheAdapter;
package/dist/index.d.cts CHANGED
@@ -257,6 +257,20 @@ interface FFIDCancelSubscriptionResponse {
257
257
  canceledAt: string | null;
258
258
  };
259
259
  }
260
+ /** Response from cancel pending downgrade endpoint */
261
+ interface FFIDCancelPendingDowngradeResponse {
262
+ message: string;
263
+ subscription: {
264
+ id: string;
265
+ organizationId: string;
266
+ serviceCode: string;
267
+ planCode: string;
268
+ billingInterval: FFIDBillingInterval;
269
+ status: FFIDSubscriptionStatus;
270
+ /** Always null after successful cancellation */
271
+ pendingDowngradePlanId: null;
272
+ };
273
+ }
260
274
  /** Parameters for previewing plan change */
261
275
  interface FFIDPreviewPlanChangeParams {
262
276
  /** Subscription ID (UUID) */
@@ -403,6 +417,7 @@ declare function createFFIDClient(config: FFIDConfig): {
403
417
  subscribe: (params: FFIDSubscribeParams) => Promise<FFIDApiResponse<FFIDSubscribeResponse>>;
404
418
  changePlan: (params: FFIDChangePlanParams) => Promise<FFIDApiResponse<FFIDChangePlanResponse>>;
405
419
  cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
420
+ cancelPendingDowngrade: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDCancelPendingDowngradeResponse>>;
406
421
  previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
407
422
  verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
408
423
  getSubscribeUrl: (options?: ContractWizardSubscribeOptions) => string;
@@ -714,4 +729,4 @@ declare function createFFIDAnnouncementsClient(config?: FFIDAnnouncementsClientC
714
729
  /** Type of the FFID Announcements client */
715
730
  type FFIDAnnouncementsClient = ReturnType<typeof createFFIDAnnouncementsClient>;
716
731
 
717
- export { AnnouncementListResponse, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, 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 };
732
+ 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, 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
@@ -257,6 +257,20 @@ interface FFIDCancelSubscriptionResponse {
257
257
  canceledAt: string | null;
258
258
  };
259
259
  }
260
+ /** Response from cancel pending downgrade endpoint */
261
+ interface FFIDCancelPendingDowngradeResponse {
262
+ message: string;
263
+ subscription: {
264
+ id: string;
265
+ organizationId: string;
266
+ serviceCode: string;
267
+ planCode: string;
268
+ billingInterval: FFIDBillingInterval;
269
+ status: FFIDSubscriptionStatus;
270
+ /** Always null after successful cancellation */
271
+ pendingDowngradePlanId: null;
272
+ };
273
+ }
260
274
  /** Parameters for previewing plan change */
261
275
  interface FFIDPreviewPlanChangeParams {
262
276
  /** Subscription ID (UUID) */
@@ -403,6 +417,7 @@ declare function createFFIDClient(config: FFIDConfig): {
403
417
  subscribe: (params: FFIDSubscribeParams) => Promise<FFIDApiResponse<FFIDSubscribeResponse>>;
404
418
  changePlan: (params: FFIDChangePlanParams) => Promise<FFIDApiResponse<FFIDChangePlanResponse>>;
405
419
  cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
420
+ cancelPendingDowngrade: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDCancelPendingDowngradeResponse>>;
406
421
  previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
407
422
  verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
408
423
  getSubscribeUrl: (options?: ContractWizardSubscribeOptions) => string;
@@ -714,4 +729,4 @@ declare function createFFIDAnnouncementsClient(config?: FFIDAnnouncementsClientC
714
729
  /** Type of the FFID Announcements client */
715
730
  type FFIDAnnouncementsClient = ReturnType<typeof createFFIDAnnouncementsClient>;
716
731
 
717
- export { AnnouncementListResponse, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, 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 };
732
+ 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, 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-VJHI6RQQ.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-VJHI6RQQ.js';
1
+ import { useFFIDContext } from './chunk-GGPL4Z2O.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-GGPL4Z2O.js';
3
3
  import { useRef, useEffect } from 'react';
4
4
  import { jsx, Fragment } from 'react/jsx-runtime';
5
5
 
@@ -447,13 +447,16 @@ function createBillingMethods(deps) {
447
447
  var EXT_PLANS_ENDPOINT = "/api/v1/subscriptions/ext/plans";
448
448
  var EXT_SUBSCRIPTION_ENDPOINT = "/api/v1/subscriptions/ext";
449
449
  var EXT_SUBSCRIBE_ENDPOINT = "/api/v1/subscriptions/ext/subscribe";
450
+ function isBlankString(value) {
451
+ return typeof value !== "string" || value.trim() === "";
452
+ }
450
453
  function createSubscriptionMethods(deps) {
451
454
  const { fetchWithAuth, createError } = deps;
452
455
  async function listPlans() {
453
456
  return fetchWithAuth(EXT_PLANS_ENDPOINT);
454
457
  }
455
458
  async function getSubscription(subscriptionId) {
456
- if (!subscriptionId) {
459
+ if (isBlankString(subscriptionId)) {
457
460
  return {
458
461
  error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
459
462
  };
@@ -483,7 +486,7 @@ function createSubscriptionMethods(deps) {
483
486
  );
484
487
  }
485
488
  async function changePlan(params) {
486
- if (!params.subscriptionId || !params.planCode) {
489
+ if (isBlankString(params.subscriptionId) || isBlankString(params.planCode)) {
487
490
  return {
488
491
  error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
489
492
  };
@@ -500,7 +503,7 @@ function createSubscriptionMethods(deps) {
500
503
  );
501
504
  }
502
505
  async function cancelSubscription(params) {
503
- if (!params.subscriptionId) {
506
+ if (isBlankString(params.subscriptionId)) {
504
507
  return {
505
508
  error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
506
509
  };
@@ -516,8 +519,19 @@ function createSubscriptionMethods(deps) {
516
519
  }
517
520
  );
518
521
  }
522
+ async function cancelPendingDowngrade(subscriptionId) {
523
+ if (isBlankString(subscriptionId)) {
524
+ return {
525
+ error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
526
+ };
527
+ }
528
+ return fetchWithAuth(
529
+ `${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(subscriptionId)}/pending-downgrade`,
530
+ { method: "DELETE" }
531
+ );
532
+ }
519
533
  async function previewPlanChange(params) {
520
- if (!params.subscriptionId || !params.planCode) {
534
+ if (isBlankString(params.subscriptionId) || isBlankString(params.planCode)) {
521
535
  return {
522
536
  error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
523
537
  };
@@ -539,6 +553,7 @@ function createSubscriptionMethods(deps) {
539
553
  subscribe,
540
554
  changePlan,
541
555
  cancelSubscription,
556
+ cancelPendingDowngrade,
542
557
  previewPlanChange
543
558
  };
544
559
  }
@@ -596,7 +611,7 @@ function createMembersMethods(deps) {
596
611
  }
597
612
 
598
613
  // src/client/version-check.ts
599
- var SDK_VERSION = "2.4.0";
614
+ var SDK_VERSION = "2.5.1";
600
615
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
601
616
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
602
617
  function sdkHeaders() {
@@ -1757,6 +1772,7 @@ function createFFIDClient(config) {
1757
1772
  subscribe,
1758
1773
  changePlan,
1759
1774
  cancelSubscription,
1775
+ cancelPendingDowngrade,
1760
1776
  previewPlanChange
1761
1777
  } = createSubscriptionMethods({
1762
1778
  fetchWithAuth,
@@ -1836,6 +1852,7 @@ function createFFIDClient(config) {
1836
1852
  subscribe,
1837
1853
  changePlan,
1838
1854
  cancelSubscription,
1855
+ cancelPendingDowngrade,
1839
1856
  previewPlanChange,
1840
1857
  verifyAccessToken,
1841
1858
  getSubscribeUrl,
@@ -186,6 +186,20 @@ interface FFIDCancelSubscriptionResponse {
186
186
  canceledAt: string | null;
187
187
  };
188
188
  }
189
+ /** Response from cancel pending downgrade endpoint */
190
+ interface FFIDCancelPendingDowngradeResponse {
191
+ message: string;
192
+ subscription: {
193
+ id: string;
194
+ organizationId: string;
195
+ serviceCode: string;
196
+ planCode: string;
197
+ billingInterval: FFIDBillingInterval;
198
+ status: FFIDSubscriptionStatus;
199
+ /** Always null after successful cancellation */
200
+ pendingDowngradePlanId: null;
201
+ };
202
+ }
189
203
  /** Parameters for previewing plan change */
190
204
  interface FFIDPreviewPlanChangeParams {
191
205
  /** Subscription ID (UUID) */
@@ -707,6 +721,7 @@ declare function createFFIDClient(config: FFIDConfig): {
707
721
  subscribe: (params: FFIDSubscribeParams) => Promise<FFIDApiResponse<FFIDSubscribeResponse>>;
708
722
  changePlan: (params: FFIDChangePlanParams) => Promise<FFIDApiResponse<FFIDChangePlanResponse>>;
709
723
  cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
724
+ cancelPendingDowngrade: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDCancelPendingDowngradeResponse>>;
710
725
  previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
711
726
  verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
712
727
  getSubscribeUrl: (options?: ContractWizardSubscribeOptions) => string;
@@ -186,6 +186,20 @@ interface FFIDCancelSubscriptionResponse {
186
186
  canceledAt: string | null;
187
187
  };
188
188
  }
189
+ /** Response from cancel pending downgrade endpoint */
190
+ interface FFIDCancelPendingDowngradeResponse {
191
+ message: string;
192
+ subscription: {
193
+ id: string;
194
+ organizationId: string;
195
+ serviceCode: string;
196
+ planCode: string;
197
+ billingInterval: FFIDBillingInterval;
198
+ status: FFIDSubscriptionStatus;
199
+ /** Always null after successful cancellation */
200
+ pendingDowngradePlanId: null;
201
+ };
202
+ }
189
203
  /** Parameters for previewing plan change */
190
204
  interface FFIDPreviewPlanChangeParams {
191
205
  /** Subscription ID (UUID) */
@@ -707,6 +721,7 @@ declare function createFFIDClient(config: FFIDConfig): {
707
721
  subscribe: (params: FFIDSubscribeParams) => Promise<FFIDApiResponse<FFIDSubscribeResponse>>;
708
722
  changePlan: (params: FFIDChangePlanParams) => Promise<FFIDApiResponse<FFIDChangePlanResponse>>;
709
723
  cancelSubscription: (params: FFIDCancelSubscriptionParams) => Promise<FFIDApiResponse<FFIDCancelSubscriptionResponse>>;
724
+ cancelPendingDowngrade: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDCancelPendingDowngradeResponse>>;
710
725
  previewPlanChange: (params: FFIDPreviewPlanChangeParams) => Promise<FFIDApiResponse<FFIDPlanChangePreviewResponse>>;
711
726
  verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
712
727
  getSubscribeUrl: (options?: ContractWizardSubscribeOptions) => string;
@@ -446,13 +446,16 @@ function createBillingMethods(deps) {
446
446
  var EXT_PLANS_ENDPOINT = "/api/v1/subscriptions/ext/plans";
447
447
  var EXT_SUBSCRIPTION_ENDPOINT = "/api/v1/subscriptions/ext";
448
448
  var EXT_SUBSCRIBE_ENDPOINT = "/api/v1/subscriptions/ext/subscribe";
449
+ function isBlankString(value) {
450
+ return typeof value !== "string" || value.trim() === "";
451
+ }
449
452
  function createSubscriptionMethods(deps) {
450
453
  const { fetchWithAuth, createError } = deps;
451
454
  async function listPlans() {
452
455
  return fetchWithAuth(EXT_PLANS_ENDPOINT);
453
456
  }
454
457
  async function getSubscription(subscriptionId) {
455
- if (!subscriptionId) {
458
+ if (isBlankString(subscriptionId)) {
456
459
  return {
457
460
  error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
458
461
  };
@@ -482,7 +485,7 @@ function createSubscriptionMethods(deps) {
482
485
  );
483
486
  }
484
487
  async function changePlan(params) {
485
- if (!params.subscriptionId || !params.planCode) {
488
+ if (isBlankString(params.subscriptionId) || isBlankString(params.planCode)) {
486
489
  return {
487
490
  error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
488
491
  };
@@ -499,7 +502,7 @@ function createSubscriptionMethods(deps) {
499
502
  );
500
503
  }
501
504
  async function cancelSubscription(params) {
502
- if (!params.subscriptionId) {
505
+ if (isBlankString(params.subscriptionId)) {
503
506
  return {
504
507
  error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
505
508
  };
@@ -515,8 +518,19 @@ function createSubscriptionMethods(deps) {
515
518
  }
516
519
  );
517
520
  }
521
+ async function cancelPendingDowngrade(subscriptionId) {
522
+ if (isBlankString(subscriptionId)) {
523
+ return {
524
+ error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
525
+ };
526
+ }
527
+ return fetchWithAuth(
528
+ `${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(subscriptionId)}/pending-downgrade`,
529
+ { method: "DELETE" }
530
+ );
531
+ }
518
532
  async function previewPlanChange(params) {
519
- if (!params.subscriptionId || !params.planCode) {
533
+ if (isBlankString(params.subscriptionId) || isBlankString(params.planCode)) {
520
534
  return {
521
535
  error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
522
536
  };
@@ -538,6 +552,7 @@ function createSubscriptionMethods(deps) {
538
552
  subscribe,
539
553
  changePlan,
540
554
  cancelSubscription,
555
+ cancelPendingDowngrade,
541
556
  previewPlanChange
542
557
  };
543
558
  }
@@ -595,7 +610,7 @@ function createMembersMethods(deps) {
595
610
  }
596
611
 
597
612
  // src/client/version-check.ts
598
- var SDK_VERSION = "2.4.0";
613
+ var SDK_VERSION = "2.5.1";
599
614
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
600
615
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
601
616
  function sdkHeaders() {
@@ -1756,6 +1771,7 @@ function createFFIDClient(config) {
1756
1771
  subscribe,
1757
1772
  changePlan,
1758
1773
  cancelSubscription,
1774
+ cancelPendingDowngrade,
1759
1775
  previewPlanChange
1760
1776
  } = createSubscriptionMethods({
1761
1777
  fetchWithAuth,
@@ -1835,6 +1851,7 @@ function createFFIDClient(config) {
1835
1851
  subscribe,
1836
1852
  changePlan,
1837
1853
  cancelSubscription,
1854
+ cancelPendingDowngrade,
1838
1855
  previewPlanChange,
1839
1856
  verifyAccessToken,
1840
1857
  getSubscribeUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feelflow/ffid-sdk",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "description": "FeelFlow ID Platform SDK for React/Next.js applications",
5
5
  "keywords": [
6
6
  "feelflow",