@feelflow/ffid-sdk 1.17.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4LRZTABD.js → chunk-3IV7STDJ.js} +180 -2
- package/dist/{chunk-4L5JIETV.cjs → chunk-543CO3HP.cjs} +180 -2
- package/dist/components/index.cjs +7 -7
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/{index-B9sSp8kZ.d.cts → index-p4dJw3qR.d.cts} +42 -6
- package/dist/{index-B9sSp8kZ.d.ts → index-p4dJw3qR.d.ts} +42 -6
- package/dist/index.cjs +22 -22
- package/dist/index.d.cts +208 -3
- package/dist/index.d.ts +208 -3
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +180 -2
- package/dist/server/index.d.cts +246 -5
- package/dist/server/index.d.ts +246 -5
- package/dist/server/index.js +180 -2
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -121,7 +121,7 @@ function normalizeUserinfo(raw) {
|
|
|
121
121
|
seatModel: raw.subscription.seat_model ?? null,
|
|
122
122
|
memberRole: raw.subscription.member_role ?? null,
|
|
123
123
|
organizationId: raw.subscription.organization_id ?? null,
|
|
124
|
-
hasSeatAssignment: raw.subscription.has_seat_assignment ??
|
|
124
|
+
hasSeatAssignment: raw.subscription.has_seat_assignment ?? false
|
|
125
125
|
} : void 0
|
|
126
126
|
};
|
|
127
127
|
}
|
|
@@ -139,6 +139,7 @@ function mapUserinfoSubscriptionToSession(userinfo, serviceCode) {
|
|
|
139
139
|
planName: subscription.planCode,
|
|
140
140
|
status: subscription.status,
|
|
141
141
|
currentPeriodEnd: null,
|
|
142
|
+
trialEnd: null,
|
|
142
143
|
seatModel: subscription.seatModel ?? void 0,
|
|
143
144
|
memberRole: subscription.memberRole ?? void 0,
|
|
144
145
|
organizationId: subscription.organizationId
|
|
@@ -442,8 +443,160 @@ function createBillingMethods(deps) {
|
|
|
442
443
|
return { createCheckoutSession, createPortalSession };
|
|
443
444
|
}
|
|
444
445
|
|
|
446
|
+
// src/client/subscription-methods.ts
|
|
447
|
+
var EXT_PLANS_ENDPOINT = "/api/v1/subscriptions/ext/plans";
|
|
448
|
+
var EXT_SUBSCRIPTION_ENDPOINT = "/api/v1/subscriptions/ext";
|
|
449
|
+
var EXT_SUBSCRIBE_ENDPOINT = "/api/v1/subscriptions/ext/subscribe";
|
|
450
|
+
function createSubscriptionMethods(deps) {
|
|
451
|
+
const { fetchWithAuth, createError } = deps;
|
|
452
|
+
async function listPlans() {
|
|
453
|
+
return fetchWithAuth(EXT_PLANS_ENDPOINT);
|
|
454
|
+
}
|
|
455
|
+
async function getSubscription(subscriptionId) {
|
|
456
|
+
if (!subscriptionId) {
|
|
457
|
+
return {
|
|
458
|
+
error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
return fetchWithAuth(
|
|
462
|
+
`${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(subscriptionId)}`
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
async function subscribe(params) {
|
|
466
|
+
if (!params.organizationId || !params.planCode) {
|
|
467
|
+
return {
|
|
468
|
+
error: createError("VALIDATION_ERROR", "organizationId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
return fetchWithAuth(
|
|
472
|
+
EXT_SUBSCRIBE_ENDPOINT,
|
|
473
|
+
{
|
|
474
|
+
method: "POST",
|
|
475
|
+
body: JSON.stringify({
|
|
476
|
+
organizationId: params.organizationId,
|
|
477
|
+
planCode: params.planCode,
|
|
478
|
+
...params.billingInterval ? { billingInterval: params.billingInterval } : {},
|
|
479
|
+
...params.quantity !== void 0 ? { quantity: params.quantity } : {},
|
|
480
|
+
...params.userId ? { userId: params.userId } : {}
|
|
481
|
+
})
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
async function changePlan(params) {
|
|
486
|
+
if (!params.subscriptionId || !params.planCode) {
|
|
487
|
+
return {
|
|
488
|
+
error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
return fetchWithAuth(
|
|
492
|
+
`${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}/plan`,
|
|
493
|
+
{
|
|
494
|
+
method: "PUT",
|
|
495
|
+
body: JSON.stringify({
|
|
496
|
+
planCode: params.planCode,
|
|
497
|
+
...params.billingInterval ? { billingInterval: params.billingInterval } : {}
|
|
498
|
+
})
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
async function cancelSubscription(params) {
|
|
503
|
+
if (!params.subscriptionId) {
|
|
504
|
+
return {
|
|
505
|
+
error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059")
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
const body = {};
|
|
509
|
+
if (params.reason) body.reason = params.reason;
|
|
510
|
+
if (params.reasonDetails) body.reasonDetails = params.reasonDetails;
|
|
511
|
+
return fetchWithAuth(
|
|
512
|
+
`${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}`,
|
|
513
|
+
{
|
|
514
|
+
method: "DELETE",
|
|
515
|
+
...Object.keys(body).length > 0 ? { body: JSON.stringify(body) } : {}
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
async function previewPlanChange(params) {
|
|
520
|
+
if (!params.subscriptionId || !params.planCode) {
|
|
521
|
+
return {
|
|
522
|
+
error: createError("VALIDATION_ERROR", "subscriptionId \u3068 planCode \u306F\u5FC5\u9808\u3067\u3059")
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
return fetchWithAuth(
|
|
526
|
+
`${EXT_SUBSCRIPTION_ENDPOINT}/${encodeURIComponent(params.subscriptionId)}/plan/preview`,
|
|
527
|
+
{
|
|
528
|
+
method: "POST",
|
|
529
|
+
body: JSON.stringify({
|
|
530
|
+
planCode: params.planCode,
|
|
531
|
+
...params.billingInterval ? { billingInterval: params.billingInterval } : {}
|
|
532
|
+
})
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
return {
|
|
537
|
+
listPlans,
|
|
538
|
+
getSubscription,
|
|
539
|
+
subscribe,
|
|
540
|
+
changePlan,
|
|
541
|
+
cancelSubscription,
|
|
542
|
+
previewPlanChange
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// src/client/members-methods.ts
|
|
547
|
+
var EXT_MEMBERS_ENDPOINT = "/api/v1/organizations/ext/members";
|
|
548
|
+
function createMembersMethods(deps) {
|
|
549
|
+
const { fetchWithAuth, createError, serviceCode } = deps;
|
|
550
|
+
function buildQuery(organizationId) {
|
|
551
|
+
return new URLSearchParams({ organizationId, serviceCode }).toString();
|
|
552
|
+
}
|
|
553
|
+
async function listMembers(params) {
|
|
554
|
+
if (!params.organizationId) {
|
|
555
|
+
return {
|
|
556
|
+
error: createError("VALIDATION_ERROR", "organizationId \u306F\u5FC5\u9808\u3067\u3059")
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
return fetchWithAuth(
|
|
560
|
+
`${EXT_MEMBERS_ENDPOINT}?${buildQuery(params.organizationId)}`
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
async function updateMemberRole(params) {
|
|
564
|
+
if (!params.organizationId || !params.userId) {
|
|
565
|
+
return {
|
|
566
|
+
error: createError("VALIDATION_ERROR", "organizationId \u3068 userId \u306F\u5FC5\u9808\u3067\u3059")
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
if (!params.role) {
|
|
570
|
+
return {
|
|
571
|
+
error: createError("VALIDATION_ERROR", "role \u306F\u5FC5\u9808\u3067\u3059")
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
return fetchWithAuth(
|
|
575
|
+
`${EXT_MEMBERS_ENDPOINT}/${encodeURIComponent(params.userId)}?${buildQuery(params.organizationId)}`,
|
|
576
|
+
{
|
|
577
|
+
method: "PUT",
|
|
578
|
+
body: JSON.stringify({ role: params.role })
|
|
579
|
+
}
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
async function removeMember(params) {
|
|
583
|
+
if (!params.organizationId || !params.userId) {
|
|
584
|
+
return {
|
|
585
|
+
error: createError("VALIDATION_ERROR", "organizationId \u3068 userId \u306F\u5FC5\u9808\u3067\u3059")
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
return fetchWithAuth(
|
|
589
|
+
`${EXT_MEMBERS_ENDPOINT}/${encodeURIComponent(params.userId)}?${buildQuery(params.organizationId)}`,
|
|
590
|
+
{
|
|
591
|
+
method: "DELETE"
|
|
592
|
+
}
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
return { listMembers, updateMemberRole, removeMember };
|
|
596
|
+
}
|
|
597
|
+
|
|
445
598
|
// src/client/version-check.ts
|
|
446
|
-
var SDK_VERSION = "1.
|
|
599
|
+
var SDK_VERSION = "1.19.0";
|
|
447
600
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
448
601
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
449
602
|
function sdkHeaders() {
|
|
@@ -1503,6 +1656,22 @@ function createFFIDClient(config) {
|
|
|
1503
1656
|
fetchWithAuth,
|
|
1504
1657
|
createError
|
|
1505
1658
|
});
|
|
1659
|
+
const {
|
|
1660
|
+
listPlans,
|
|
1661
|
+
getSubscription,
|
|
1662
|
+
subscribe,
|
|
1663
|
+
changePlan,
|
|
1664
|
+
cancelSubscription,
|
|
1665
|
+
previewPlanChange
|
|
1666
|
+
} = createSubscriptionMethods({
|
|
1667
|
+
fetchWithAuth,
|
|
1668
|
+
createError
|
|
1669
|
+
});
|
|
1670
|
+
const { listMembers, updateMemberRole, removeMember } = createMembersMethods({
|
|
1671
|
+
fetchWithAuth,
|
|
1672
|
+
createError,
|
|
1673
|
+
serviceCode: config.serviceCode
|
|
1674
|
+
});
|
|
1506
1675
|
const {
|
|
1507
1676
|
requestPasswordReset,
|
|
1508
1677
|
verifyPasswordResetToken,
|
|
@@ -1546,8 +1715,17 @@ function createFFIDClient(config) {
|
|
|
1546
1715
|
exchangeCodeForTokens,
|
|
1547
1716
|
refreshAccessToken,
|
|
1548
1717
|
checkSubscription,
|
|
1718
|
+
listMembers,
|
|
1719
|
+
updateMemberRole,
|
|
1720
|
+
removeMember,
|
|
1549
1721
|
createCheckoutSession,
|
|
1550
1722
|
createPortalSession,
|
|
1723
|
+
listPlans,
|
|
1724
|
+
getSubscription,
|
|
1725
|
+
subscribe,
|
|
1726
|
+
changePlan,
|
|
1727
|
+
cancelSubscription,
|
|
1728
|
+
previewPlanChange,
|
|
1551
1729
|
verifyAccessToken,
|
|
1552
1730
|
requestPasswordReset,
|
|
1553
1731
|
verifyPasswordResetToken,
|
package/dist/server/index.d.cts
CHANGED
|
@@ -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:
|
|
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:
|
|
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,45 @@ interface FFIDCreatePortalParams {
|
|
|
308
492
|
/** URL to redirect when user exits the portal */
|
|
309
493
|
returnUrl: string;
|
|
310
494
|
}
|
|
495
|
+
|
|
496
|
+
/** Member role in an organization */
|
|
497
|
+
type FFIDMemberRole = 'owner' | 'admin' | 'member' | 'viewer';
|
|
498
|
+
/** Member status in an organization */
|
|
499
|
+
type FFIDMemberStatus = 'active' | 'invited' | 'suspended';
|
|
500
|
+
/** Organization member returned by the ext members API */
|
|
501
|
+
interface FFIDOrganizationMember {
|
|
502
|
+
/** User ID (UUID) */
|
|
503
|
+
userId: string;
|
|
504
|
+
/** Email address */
|
|
505
|
+
email: string;
|
|
506
|
+
/** Display name */
|
|
507
|
+
displayName: string | null;
|
|
508
|
+
/** Avatar URL */
|
|
509
|
+
avatarUrl: string | null;
|
|
510
|
+
/** Role in the organization */
|
|
511
|
+
role: FFIDMemberRole;
|
|
512
|
+
/** Membership status */
|
|
513
|
+
status: FFIDMemberStatus;
|
|
514
|
+
/** When the user joined */
|
|
515
|
+
joinedAt: string | null;
|
|
516
|
+
/** When the user was invited */
|
|
517
|
+
invitedAt: string | null;
|
|
518
|
+
/** Last sign-in timestamp */
|
|
519
|
+
lastSignInAt: string | null;
|
|
520
|
+
}
|
|
521
|
+
/** Response from listMembers (ext) */
|
|
522
|
+
interface FFIDListMembersResponse {
|
|
523
|
+
organizationId: string;
|
|
524
|
+
members: FFIDOrganizationMember[];
|
|
525
|
+
}
|
|
526
|
+
/** Response from updateMemberRole (ext) */
|
|
527
|
+
interface FFIDUpdateMemberRoleResponse {
|
|
528
|
+
member: FFIDOrganizationMember;
|
|
529
|
+
}
|
|
530
|
+
/** Response from removeMember (ext) */
|
|
531
|
+
interface FFIDRemoveMemberResponse {
|
|
532
|
+
message: string;
|
|
533
|
+
}
|
|
311
534
|
/**
|
|
312
535
|
* Result of a redirect operation (redirectToLogin / redirectToAuthorize / redirectToLogout)
|
|
313
536
|
*
|
|
@@ -424,8 +647,26 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
424
647
|
userId: string;
|
|
425
648
|
organizationId: string;
|
|
426
649
|
}) => Promise<FFIDApiResponse<FFIDSubscriptionCheckResponse>>;
|
|
650
|
+
listMembers: (params: {
|
|
651
|
+
organizationId: string;
|
|
652
|
+
}) => Promise<FFIDApiResponse<FFIDListMembersResponse>>;
|
|
653
|
+
updateMemberRole: (params: {
|
|
654
|
+
organizationId: string;
|
|
655
|
+
userId: string;
|
|
656
|
+
role: FFIDMemberRole;
|
|
657
|
+
}) => Promise<FFIDApiResponse<FFIDUpdateMemberRoleResponse>>;
|
|
658
|
+
removeMember: (params: {
|
|
659
|
+
organizationId: string;
|
|
660
|
+
userId: string;
|
|
661
|
+
}) => Promise<FFIDApiResponse<FFIDRemoveMemberResponse>>;
|
|
427
662
|
createCheckoutSession: (params: FFIDCreateCheckoutParams) => Promise<FFIDApiResponse<FFIDCheckoutSessionResponse>>;
|
|
428
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>>;
|
|
429
670
|
verifyAccessToken: (accessToken: string, options?: FFIDVerifyAccessTokenOptions) => Promise<FFIDApiResponse<FFIDOAuthUserInfo>>;
|
|
430
671
|
requestPasswordReset: (email: string) => Promise<FFIDApiResponse<FFIDPasswordResetResponse>>;
|
|
431
672
|
verifyPasswordResetToken: (accessToken: string) => Promise<FFIDApiResponse<FFIDPasswordResetVerifyResponse>>;
|