@feelflow/ffid-sdk 0.1.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/README.md +270 -0
- package/dist/chunk-A63MX52D.js +861 -0
- package/dist/chunk-YCMQXJOS.cjs +872 -0
- package/dist/components/index.cjs +22 -0
- package/dist/components/index.d.cts +3 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +1 -0
- package/dist/index-CtBBLbTn.d.cts +322 -0
- package/dist/index-CtBBLbTn.d.ts +322 -0
- package/dist/index.cjs +68 -0
- package/dist/index.d.cts +181 -0
- package/dist/index.d.ts +181 -0
- package/dist/index.js +31 -0
- package/dist/legal/index.cjs +180 -0
- package/dist/legal/index.d.cts +332 -0
- package/dist/legal/index.d.ts +332 -0
- package/dist/legal/index.js +176 -0
- package/package.json +84 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkYCMQXJOS_cjs = require('../chunk-YCMQXJOS.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "FFIDLoginButton", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkYCMQXJOS_cjs.FFIDLoginButton; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkYCMQXJOS_cjs.FFIDOrganizationSwitcher; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "FFIDSubscriptionBadge", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkYCMQXJOS_cjs.FFIDSubscriptionBadge; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "FFIDUserMenu", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkYCMQXJOS_cjs.FFIDUserMenu; }
|
|
22
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { h as FFIDLoginButton, n as FFIDLoginButtonProps, i as FFIDOrganizationSwitcher, o as FFIDOrganizationSwitcherClassNames, p as FFIDOrganizationSwitcherProps, l as FFIDSubscriptionBadge, q as FFIDSubscriptionBadgeClassNames, r as FFIDSubscriptionBadgeProps, m as FFIDUserMenu, s as FFIDUserMenuClassNames, t as FFIDUserMenuProps } from '../index-CtBBLbTn.cjs';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { h as FFIDLoginButton, n as FFIDLoginButtonProps, i as FFIDOrganizationSwitcher, o as FFIDOrganizationSwitcherClassNames, p as FFIDOrganizationSwitcherProps, l as FFIDSubscriptionBadge, q as FFIDSubscriptionBadgeClassNames, r as FFIDSubscriptionBadgeProps, m as FFIDUserMenu, s as FFIDUserMenuClassNames, t as FFIDUserMenuProps } from '../index-CtBBLbTn.js';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-A63MX52D.js';
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ButtonHTMLAttributes, ReactNode, CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FFID SDK Type Definitions
|
|
6
|
+
*
|
|
7
|
+
* Core types for the FeelFlow ID SDK
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* User information from FFID
|
|
11
|
+
*/
|
|
12
|
+
interface FFIDUser {
|
|
13
|
+
/** User ID (UUID) */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Email address */
|
|
16
|
+
email: string;
|
|
17
|
+
/** Display name */
|
|
18
|
+
displayName: string | null;
|
|
19
|
+
/** Avatar URL */
|
|
20
|
+
avatarUrl: string | null;
|
|
21
|
+
/** Locale setting (e.g., 'ja', 'en') */
|
|
22
|
+
locale: string | null;
|
|
23
|
+
/** Timezone (e.g., 'Asia/Tokyo') */
|
|
24
|
+
timezone: string | null;
|
|
25
|
+
/** Account creation timestamp */
|
|
26
|
+
createdAt: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Organization membership information
|
|
30
|
+
*/
|
|
31
|
+
interface FFIDOrganization {
|
|
32
|
+
/** Organization ID (UUID) */
|
|
33
|
+
id: string;
|
|
34
|
+
/** Organization name */
|
|
35
|
+
name: string;
|
|
36
|
+
/** URL-safe slug */
|
|
37
|
+
slug: string;
|
|
38
|
+
/** User's role in this organization */
|
|
39
|
+
role: 'owner' | 'admin' | 'member';
|
|
40
|
+
/** Membership status */
|
|
41
|
+
status: 'active' | 'invited' | 'suspended';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Subscription/contract information
|
|
45
|
+
*/
|
|
46
|
+
interface FFIDSubscription {
|
|
47
|
+
/** Subscription ID (UUID) */
|
|
48
|
+
id: string;
|
|
49
|
+
/** Service code (e.g., 'chatbot') */
|
|
50
|
+
serviceCode: string;
|
|
51
|
+
/** Service display name */
|
|
52
|
+
serviceName: string;
|
|
53
|
+
/** Plan code (e.g., 'basic', 'pro') */
|
|
54
|
+
planCode: string;
|
|
55
|
+
/** Plan display name */
|
|
56
|
+
planName: string;
|
|
57
|
+
/** Subscription status */
|
|
58
|
+
status: 'trialing' | 'active' | 'past_due' | 'canceled' | 'paused';
|
|
59
|
+
/** Current billing period end date */
|
|
60
|
+
currentPeriodEnd: string | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* SDK configuration options
|
|
64
|
+
*/
|
|
65
|
+
interface FFIDConfig {
|
|
66
|
+
/** Service code to identify your application */
|
|
67
|
+
serviceCode: string;
|
|
68
|
+
/** FFID API base URL (defaults to production) */
|
|
69
|
+
apiBaseUrl?: string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Enable debug logging (deprecated: use logger instead)
|
|
72
|
+
* When true and no logger provided, uses console for logging
|
|
73
|
+
* @deprecated Use `logger` option for custom logging
|
|
74
|
+
*/
|
|
75
|
+
debug?: boolean | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Custom logger for SDK debug output
|
|
78
|
+
* If not provided: uses no-op logger (silent)
|
|
79
|
+
* If debug=true and no logger: uses console
|
|
80
|
+
*/
|
|
81
|
+
logger?: FFIDLogger | undefined;
|
|
82
|
+
/** Session refresh interval in milliseconds */
|
|
83
|
+
refreshInterval?: number | undefined;
|
|
84
|
+
/** Callback when authentication state changes */
|
|
85
|
+
onAuthStateChange?: ((user: FFIDUser | null) => void) | undefined;
|
|
86
|
+
/** Callback on authentication error */
|
|
87
|
+
onError?: ((error: FFIDError) => void) | undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* FFID context value provided to consumers
|
|
91
|
+
*/
|
|
92
|
+
interface FFIDContextValue {
|
|
93
|
+
/** Current authenticated user (null if not authenticated) */
|
|
94
|
+
user: FFIDUser | null;
|
|
95
|
+
/** User's organization memberships */
|
|
96
|
+
organizations: FFIDOrganization[];
|
|
97
|
+
/** Currently selected organization */
|
|
98
|
+
currentOrganization: FFIDOrganization | null;
|
|
99
|
+
/** User's subscriptions for the current service */
|
|
100
|
+
subscriptions: FFIDSubscription[];
|
|
101
|
+
/** Whether authentication is being checked */
|
|
102
|
+
isLoading: boolean;
|
|
103
|
+
/** Whether the user is authenticated */
|
|
104
|
+
isAuthenticated: boolean;
|
|
105
|
+
/** Any authentication error */
|
|
106
|
+
error: FFIDError | null;
|
|
107
|
+
/** Redirect to FFID login page */
|
|
108
|
+
login: () => void;
|
|
109
|
+
/** Sign out and clear session */
|
|
110
|
+
logout: () => Promise<void>;
|
|
111
|
+
/** Switch to a different organization */
|
|
112
|
+
switchOrganization: (organizationId: string) => void;
|
|
113
|
+
/** Refresh session data */
|
|
114
|
+
refresh: () => Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Subscription context value
|
|
118
|
+
*/
|
|
119
|
+
interface FFIDSubscriptionContextValue {
|
|
120
|
+
/** Active subscription for current service (null if none) */
|
|
121
|
+
subscription: FFIDSubscription | null;
|
|
122
|
+
/** Current plan code */
|
|
123
|
+
planCode: string | null;
|
|
124
|
+
/** Whether subscription is active */
|
|
125
|
+
isActive: boolean;
|
|
126
|
+
/** Whether in trial period */
|
|
127
|
+
isTrialing: boolean;
|
|
128
|
+
/** Whether subscription is canceled */
|
|
129
|
+
isCanceled: boolean;
|
|
130
|
+
/** Check if user has specific plan */
|
|
131
|
+
hasPlan: (plans: string | string[]) => boolean;
|
|
132
|
+
/** Check if user has access (active or trialing subscription) */
|
|
133
|
+
hasAccess: () => boolean;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Logger interface for SDK debug output
|
|
137
|
+
*
|
|
138
|
+
* Allows injection of custom loggers (e.g., winston, pino)
|
|
139
|
+
* or use of the built-in console logger when debug is enabled
|
|
140
|
+
*/
|
|
141
|
+
interface FFIDLogger {
|
|
142
|
+
/** Debug level logging */
|
|
143
|
+
debug: (...args: unknown[]) => void;
|
|
144
|
+
/** Info level logging */
|
|
145
|
+
info: (...args: unknown[]) => void;
|
|
146
|
+
/** Warning level logging */
|
|
147
|
+
warn: (...args: unknown[]) => void;
|
|
148
|
+
/** Error level logging */
|
|
149
|
+
error: (...args: unknown[]) => void;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* FFID error object
|
|
153
|
+
*/
|
|
154
|
+
interface FFIDError {
|
|
155
|
+
/** Error code */
|
|
156
|
+
code: string;
|
|
157
|
+
/** Human-readable error message */
|
|
158
|
+
message: string;
|
|
159
|
+
/** Additional error details */
|
|
160
|
+
details?: Record<string, unknown>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Session response from FFID API
|
|
164
|
+
*/
|
|
165
|
+
interface FFIDSessionResponse {
|
|
166
|
+
user: FFIDUser;
|
|
167
|
+
organizations: FFIDOrganization[];
|
|
168
|
+
subscriptions: FFIDSubscription[];
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* API response wrapper (discriminated union for type safety)
|
|
172
|
+
*
|
|
173
|
+
* Either data is present (success) or error is present (failure), never both.
|
|
174
|
+
* This pattern ensures callers handle both cases explicitly.
|
|
175
|
+
*/
|
|
176
|
+
type FFIDApiResponse<T> = {
|
|
177
|
+
data: T;
|
|
178
|
+
error?: undefined;
|
|
179
|
+
} | {
|
|
180
|
+
data?: undefined;
|
|
181
|
+
error: FFIDError;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
interface FFIDLoginButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
185
|
+
/** Button content */
|
|
186
|
+
children?: ReactNode;
|
|
187
|
+
/** Custom class name */
|
|
188
|
+
className?: string;
|
|
189
|
+
/** Show loading state while checking auth */
|
|
190
|
+
showLoading?: boolean;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Login button that redirects to FFID authentication
|
|
194
|
+
*/
|
|
195
|
+
declare function FFIDLoginButton({ children, className, showLoading, disabled, ...props }: FFIDLoginButtonProps): react_jsx_runtime.JSX.Element | null;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* ClassNames for styling individual parts of FFIDUserMenu
|
|
199
|
+
* @see https://www.radix-ui.com/primitives/docs/guides/styling
|
|
200
|
+
*/
|
|
201
|
+
interface FFIDUserMenuClassNames {
|
|
202
|
+
/** Container wrapper */
|
|
203
|
+
container?: string;
|
|
204
|
+
/** Avatar button trigger */
|
|
205
|
+
button?: string;
|
|
206
|
+
/** Avatar element (image or fallback) */
|
|
207
|
+
avatar?: string;
|
|
208
|
+
/** Dropdown menu container */
|
|
209
|
+
menu?: string;
|
|
210
|
+
/** User info section at top of menu */
|
|
211
|
+
userInfo?: string;
|
|
212
|
+
/** Custom menu item buttons */
|
|
213
|
+
menuItem?: string;
|
|
214
|
+
/** Logout button */
|
|
215
|
+
logout?: string;
|
|
216
|
+
}
|
|
217
|
+
interface FFIDUserMenuProps {
|
|
218
|
+
/** Custom class name for the container */
|
|
219
|
+
className?: string;
|
|
220
|
+
/**
|
|
221
|
+
* Class names for individual parts (Radix UI pattern)
|
|
222
|
+
* Allows styling each internal element separately
|
|
223
|
+
*/
|
|
224
|
+
classNames?: FFIDUserMenuClassNames;
|
|
225
|
+
/** Custom avatar component */
|
|
226
|
+
renderAvatar?: (user: {
|
|
227
|
+
avatarUrl: string | null;
|
|
228
|
+
displayName: string | null;
|
|
229
|
+
email: string;
|
|
230
|
+
}) => ReactNode;
|
|
231
|
+
/** Custom menu items */
|
|
232
|
+
menuItems?: Array<{
|
|
233
|
+
label: string;
|
|
234
|
+
onClick: () => void;
|
|
235
|
+
icon?: ReactNode;
|
|
236
|
+
}>;
|
|
237
|
+
/** Show organization info */
|
|
238
|
+
showOrganization?: boolean;
|
|
239
|
+
/** Logout button text */
|
|
240
|
+
logoutText?: string;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* User menu component showing avatar and dropdown
|
|
244
|
+
*/
|
|
245
|
+
declare function FFIDUserMenu({ className, classNames, renderAvatar, menuItems, showOrganization, logoutText, }: FFIDUserMenuProps): react_jsx_runtime.JSX.Element | null;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* ClassNames for styling individual parts of FFIDOrganizationSwitcher
|
|
249
|
+
* @see https://www.radix-ui.com/primitives/docs/guides/styling
|
|
250
|
+
*/
|
|
251
|
+
interface FFIDOrganizationSwitcherClassNames {
|
|
252
|
+
/** Container wrapper */
|
|
253
|
+
container?: string;
|
|
254
|
+
/** Trigger button */
|
|
255
|
+
button?: string;
|
|
256
|
+
/** Dropdown menu */
|
|
257
|
+
dropdown?: string;
|
|
258
|
+
/** Organization option (each item) */
|
|
259
|
+
option?: string;
|
|
260
|
+
/** Currently selected option (added in addition to option) */
|
|
261
|
+
optionSelected?: string;
|
|
262
|
+
}
|
|
263
|
+
interface FFIDOrganizationSwitcherProps {
|
|
264
|
+
/** Custom class name */
|
|
265
|
+
className?: string;
|
|
266
|
+
/**
|
|
267
|
+
* Class names for individual parts (Radix UI pattern)
|
|
268
|
+
* Allows styling each internal element separately
|
|
269
|
+
*/
|
|
270
|
+
classNames?: FFIDOrganizationSwitcherClassNames;
|
|
271
|
+
/** Custom render for organization item */
|
|
272
|
+
renderOrganization?: (org: FFIDOrganization, isCurrent: boolean) => ReactNode;
|
|
273
|
+
/** Label text */
|
|
274
|
+
label?: string;
|
|
275
|
+
/** Empty state text */
|
|
276
|
+
emptyText?: string;
|
|
277
|
+
/** Called when organization is switched */
|
|
278
|
+
onSwitch?: (organizationId: string) => void;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Organization switcher dropdown
|
|
282
|
+
*/
|
|
283
|
+
declare function FFIDOrganizationSwitcher({ className, classNames, renderOrganization, label, emptyText, onSwitch, }: FFIDOrganizationSwitcherProps): react_jsx_runtime.JSX.Element | null;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* ClassNames for styling individual parts of FFIDSubscriptionBadge
|
|
287
|
+
* @see https://www.radix-ui.com/primitives/docs/guides/styling
|
|
288
|
+
*/
|
|
289
|
+
interface FFIDSubscriptionBadgeClassNames {
|
|
290
|
+
/** The badge span element (also accessible via className prop) */
|
|
291
|
+
badge?: string;
|
|
292
|
+
}
|
|
293
|
+
interface FFIDSubscriptionBadgeProps {
|
|
294
|
+
/** Custom class name (applies to badge span) */
|
|
295
|
+
className?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Class names for individual parts (Radix UI pattern)
|
|
298
|
+
* For this simple component, using className is usually sufficient
|
|
299
|
+
*/
|
|
300
|
+
classNames?: FFIDSubscriptionBadgeClassNames;
|
|
301
|
+
/** Custom style */
|
|
302
|
+
style?: CSSProperties;
|
|
303
|
+
/** Show plan name instead of status */
|
|
304
|
+
showPlanName?: boolean;
|
|
305
|
+
/** Custom labels for each status */
|
|
306
|
+
labels?: {
|
|
307
|
+
active?: string;
|
|
308
|
+
trialing?: string;
|
|
309
|
+
pastDue?: string;
|
|
310
|
+
canceled?: string;
|
|
311
|
+
paused?: string;
|
|
312
|
+
none?: string;
|
|
313
|
+
};
|
|
314
|
+
/** Custom render function */
|
|
315
|
+
render?: (status: string, planName: string | null) => ReactNode;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Subscription status badge
|
|
319
|
+
*/
|
|
320
|
+
declare function FFIDSubscriptionBadge({ className, classNames, style, showPlanName, labels, render, }: FFIDSubscriptionBadgeProps): react_jsx_runtime.JSX.Element;
|
|
321
|
+
|
|
322
|
+
export { type FFIDConfig as F, type FFIDUser as a, type FFIDOrganization as b, type FFIDError as c, type FFIDSubscriptionContextValue as d, type FFIDApiResponse as e, type FFIDContextValue as f, type FFIDLogger as g, FFIDLoginButton as h, FFIDOrganizationSwitcher as i, type FFIDSessionResponse as j, type FFIDSubscription as k, FFIDSubscriptionBadge as l, FFIDUserMenu as m, type FFIDLoginButtonProps as n, type FFIDOrganizationSwitcherClassNames as o, type FFIDOrganizationSwitcherProps as p, type FFIDSubscriptionBadgeClassNames as q, type FFIDSubscriptionBadgeProps as r, type FFIDUserMenuClassNames as s, type FFIDUserMenuProps as t };
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ButtonHTMLAttributes, ReactNode, CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FFID SDK Type Definitions
|
|
6
|
+
*
|
|
7
|
+
* Core types for the FeelFlow ID SDK
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* User information from FFID
|
|
11
|
+
*/
|
|
12
|
+
interface FFIDUser {
|
|
13
|
+
/** User ID (UUID) */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Email address */
|
|
16
|
+
email: string;
|
|
17
|
+
/** Display name */
|
|
18
|
+
displayName: string | null;
|
|
19
|
+
/** Avatar URL */
|
|
20
|
+
avatarUrl: string | null;
|
|
21
|
+
/** Locale setting (e.g., 'ja', 'en') */
|
|
22
|
+
locale: string | null;
|
|
23
|
+
/** Timezone (e.g., 'Asia/Tokyo') */
|
|
24
|
+
timezone: string | null;
|
|
25
|
+
/** Account creation timestamp */
|
|
26
|
+
createdAt: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Organization membership information
|
|
30
|
+
*/
|
|
31
|
+
interface FFIDOrganization {
|
|
32
|
+
/** Organization ID (UUID) */
|
|
33
|
+
id: string;
|
|
34
|
+
/** Organization name */
|
|
35
|
+
name: string;
|
|
36
|
+
/** URL-safe slug */
|
|
37
|
+
slug: string;
|
|
38
|
+
/** User's role in this organization */
|
|
39
|
+
role: 'owner' | 'admin' | 'member';
|
|
40
|
+
/** Membership status */
|
|
41
|
+
status: 'active' | 'invited' | 'suspended';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Subscription/contract information
|
|
45
|
+
*/
|
|
46
|
+
interface FFIDSubscription {
|
|
47
|
+
/** Subscription ID (UUID) */
|
|
48
|
+
id: string;
|
|
49
|
+
/** Service code (e.g., 'chatbot') */
|
|
50
|
+
serviceCode: string;
|
|
51
|
+
/** Service display name */
|
|
52
|
+
serviceName: string;
|
|
53
|
+
/** Plan code (e.g., 'basic', 'pro') */
|
|
54
|
+
planCode: string;
|
|
55
|
+
/** Plan display name */
|
|
56
|
+
planName: string;
|
|
57
|
+
/** Subscription status */
|
|
58
|
+
status: 'trialing' | 'active' | 'past_due' | 'canceled' | 'paused';
|
|
59
|
+
/** Current billing period end date */
|
|
60
|
+
currentPeriodEnd: string | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* SDK configuration options
|
|
64
|
+
*/
|
|
65
|
+
interface FFIDConfig {
|
|
66
|
+
/** Service code to identify your application */
|
|
67
|
+
serviceCode: string;
|
|
68
|
+
/** FFID API base URL (defaults to production) */
|
|
69
|
+
apiBaseUrl?: string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Enable debug logging (deprecated: use logger instead)
|
|
72
|
+
* When true and no logger provided, uses console for logging
|
|
73
|
+
* @deprecated Use `logger` option for custom logging
|
|
74
|
+
*/
|
|
75
|
+
debug?: boolean | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Custom logger for SDK debug output
|
|
78
|
+
* If not provided: uses no-op logger (silent)
|
|
79
|
+
* If debug=true and no logger: uses console
|
|
80
|
+
*/
|
|
81
|
+
logger?: FFIDLogger | undefined;
|
|
82
|
+
/** Session refresh interval in milliseconds */
|
|
83
|
+
refreshInterval?: number | undefined;
|
|
84
|
+
/** Callback when authentication state changes */
|
|
85
|
+
onAuthStateChange?: ((user: FFIDUser | null) => void) | undefined;
|
|
86
|
+
/** Callback on authentication error */
|
|
87
|
+
onError?: ((error: FFIDError) => void) | undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* FFID context value provided to consumers
|
|
91
|
+
*/
|
|
92
|
+
interface FFIDContextValue {
|
|
93
|
+
/** Current authenticated user (null if not authenticated) */
|
|
94
|
+
user: FFIDUser | null;
|
|
95
|
+
/** User's organization memberships */
|
|
96
|
+
organizations: FFIDOrganization[];
|
|
97
|
+
/** Currently selected organization */
|
|
98
|
+
currentOrganization: FFIDOrganization | null;
|
|
99
|
+
/** User's subscriptions for the current service */
|
|
100
|
+
subscriptions: FFIDSubscription[];
|
|
101
|
+
/** Whether authentication is being checked */
|
|
102
|
+
isLoading: boolean;
|
|
103
|
+
/** Whether the user is authenticated */
|
|
104
|
+
isAuthenticated: boolean;
|
|
105
|
+
/** Any authentication error */
|
|
106
|
+
error: FFIDError | null;
|
|
107
|
+
/** Redirect to FFID login page */
|
|
108
|
+
login: () => void;
|
|
109
|
+
/** Sign out and clear session */
|
|
110
|
+
logout: () => Promise<void>;
|
|
111
|
+
/** Switch to a different organization */
|
|
112
|
+
switchOrganization: (organizationId: string) => void;
|
|
113
|
+
/** Refresh session data */
|
|
114
|
+
refresh: () => Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Subscription context value
|
|
118
|
+
*/
|
|
119
|
+
interface FFIDSubscriptionContextValue {
|
|
120
|
+
/** Active subscription for current service (null if none) */
|
|
121
|
+
subscription: FFIDSubscription | null;
|
|
122
|
+
/** Current plan code */
|
|
123
|
+
planCode: string | null;
|
|
124
|
+
/** Whether subscription is active */
|
|
125
|
+
isActive: boolean;
|
|
126
|
+
/** Whether in trial period */
|
|
127
|
+
isTrialing: boolean;
|
|
128
|
+
/** Whether subscription is canceled */
|
|
129
|
+
isCanceled: boolean;
|
|
130
|
+
/** Check if user has specific plan */
|
|
131
|
+
hasPlan: (plans: string | string[]) => boolean;
|
|
132
|
+
/** Check if user has access (active or trialing subscription) */
|
|
133
|
+
hasAccess: () => boolean;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Logger interface for SDK debug output
|
|
137
|
+
*
|
|
138
|
+
* Allows injection of custom loggers (e.g., winston, pino)
|
|
139
|
+
* or use of the built-in console logger when debug is enabled
|
|
140
|
+
*/
|
|
141
|
+
interface FFIDLogger {
|
|
142
|
+
/** Debug level logging */
|
|
143
|
+
debug: (...args: unknown[]) => void;
|
|
144
|
+
/** Info level logging */
|
|
145
|
+
info: (...args: unknown[]) => void;
|
|
146
|
+
/** Warning level logging */
|
|
147
|
+
warn: (...args: unknown[]) => void;
|
|
148
|
+
/** Error level logging */
|
|
149
|
+
error: (...args: unknown[]) => void;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* FFID error object
|
|
153
|
+
*/
|
|
154
|
+
interface FFIDError {
|
|
155
|
+
/** Error code */
|
|
156
|
+
code: string;
|
|
157
|
+
/** Human-readable error message */
|
|
158
|
+
message: string;
|
|
159
|
+
/** Additional error details */
|
|
160
|
+
details?: Record<string, unknown>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Session response from FFID API
|
|
164
|
+
*/
|
|
165
|
+
interface FFIDSessionResponse {
|
|
166
|
+
user: FFIDUser;
|
|
167
|
+
organizations: FFIDOrganization[];
|
|
168
|
+
subscriptions: FFIDSubscription[];
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* API response wrapper (discriminated union for type safety)
|
|
172
|
+
*
|
|
173
|
+
* Either data is present (success) or error is present (failure), never both.
|
|
174
|
+
* This pattern ensures callers handle both cases explicitly.
|
|
175
|
+
*/
|
|
176
|
+
type FFIDApiResponse<T> = {
|
|
177
|
+
data: T;
|
|
178
|
+
error?: undefined;
|
|
179
|
+
} | {
|
|
180
|
+
data?: undefined;
|
|
181
|
+
error: FFIDError;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
interface FFIDLoginButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
185
|
+
/** Button content */
|
|
186
|
+
children?: ReactNode;
|
|
187
|
+
/** Custom class name */
|
|
188
|
+
className?: string;
|
|
189
|
+
/** Show loading state while checking auth */
|
|
190
|
+
showLoading?: boolean;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Login button that redirects to FFID authentication
|
|
194
|
+
*/
|
|
195
|
+
declare function FFIDLoginButton({ children, className, showLoading, disabled, ...props }: FFIDLoginButtonProps): react_jsx_runtime.JSX.Element | null;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* ClassNames for styling individual parts of FFIDUserMenu
|
|
199
|
+
* @see https://www.radix-ui.com/primitives/docs/guides/styling
|
|
200
|
+
*/
|
|
201
|
+
interface FFIDUserMenuClassNames {
|
|
202
|
+
/** Container wrapper */
|
|
203
|
+
container?: string;
|
|
204
|
+
/** Avatar button trigger */
|
|
205
|
+
button?: string;
|
|
206
|
+
/** Avatar element (image or fallback) */
|
|
207
|
+
avatar?: string;
|
|
208
|
+
/** Dropdown menu container */
|
|
209
|
+
menu?: string;
|
|
210
|
+
/** User info section at top of menu */
|
|
211
|
+
userInfo?: string;
|
|
212
|
+
/** Custom menu item buttons */
|
|
213
|
+
menuItem?: string;
|
|
214
|
+
/** Logout button */
|
|
215
|
+
logout?: string;
|
|
216
|
+
}
|
|
217
|
+
interface FFIDUserMenuProps {
|
|
218
|
+
/** Custom class name for the container */
|
|
219
|
+
className?: string;
|
|
220
|
+
/**
|
|
221
|
+
* Class names for individual parts (Radix UI pattern)
|
|
222
|
+
* Allows styling each internal element separately
|
|
223
|
+
*/
|
|
224
|
+
classNames?: FFIDUserMenuClassNames;
|
|
225
|
+
/** Custom avatar component */
|
|
226
|
+
renderAvatar?: (user: {
|
|
227
|
+
avatarUrl: string | null;
|
|
228
|
+
displayName: string | null;
|
|
229
|
+
email: string;
|
|
230
|
+
}) => ReactNode;
|
|
231
|
+
/** Custom menu items */
|
|
232
|
+
menuItems?: Array<{
|
|
233
|
+
label: string;
|
|
234
|
+
onClick: () => void;
|
|
235
|
+
icon?: ReactNode;
|
|
236
|
+
}>;
|
|
237
|
+
/** Show organization info */
|
|
238
|
+
showOrganization?: boolean;
|
|
239
|
+
/** Logout button text */
|
|
240
|
+
logoutText?: string;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* User menu component showing avatar and dropdown
|
|
244
|
+
*/
|
|
245
|
+
declare function FFIDUserMenu({ className, classNames, renderAvatar, menuItems, showOrganization, logoutText, }: FFIDUserMenuProps): react_jsx_runtime.JSX.Element | null;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* ClassNames for styling individual parts of FFIDOrganizationSwitcher
|
|
249
|
+
* @see https://www.radix-ui.com/primitives/docs/guides/styling
|
|
250
|
+
*/
|
|
251
|
+
interface FFIDOrganizationSwitcherClassNames {
|
|
252
|
+
/** Container wrapper */
|
|
253
|
+
container?: string;
|
|
254
|
+
/** Trigger button */
|
|
255
|
+
button?: string;
|
|
256
|
+
/** Dropdown menu */
|
|
257
|
+
dropdown?: string;
|
|
258
|
+
/** Organization option (each item) */
|
|
259
|
+
option?: string;
|
|
260
|
+
/** Currently selected option (added in addition to option) */
|
|
261
|
+
optionSelected?: string;
|
|
262
|
+
}
|
|
263
|
+
interface FFIDOrganizationSwitcherProps {
|
|
264
|
+
/** Custom class name */
|
|
265
|
+
className?: string;
|
|
266
|
+
/**
|
|
267
|
+
* Class names for individual parts (Radix UI pattern)
|
|
268
|
+
* Allows styling each internal element separately
|
|
269
|
+
*/
|
|
270
|
+
classNames?: FFIDOrganizationSwitcherClassNames;
|
|
271
|
+
/** Custom render for organization item */
|
|
272
|
+
renderOrganization?: (org: FFIDOrganization, isCurrent: boolean) => ReactNode;
|
|
273
|
+
/** Label text */
|
|
274
|
+
label?: string;
|
|
275
|
+
/** Empty state text */
|
|
276
|
+
emptyText?: string;
|
|
277
|
+
/** Called when organization is switched */
|
|
278
|
+
onSwitch?: (organizationId: string) => void;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Organization switcher dropdown
|
|
282
|
+
*/
|
|
283
|
+
declare function FFIDOrganizationSwitcher({ className, classNames, renderOrganization, label, emptyText, onSwitch, }: FFIDOrganizationSwitcherProps): react_jsx_runtime.JSX.Element | null;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* ClassNames for styling individual parts of FFIDSubscriptionBadge
|
|
287
|
+
* @see https://www.radix-ui.com/primitives/docs/guides/styling
|
|
288
|
+
*/
|
|
289
|
+
interface FFIDSubscriptionBadgeClassNames {
|
|
290
|
+
/** The badge span element (also accessible via className prop) */
|
|
291
|
+
badge?: string;
|
|
292
|
+
}
|
|
293
|
+
interface FFIDSubscriptionBadgeProps {
|
|
294
|
+
/** Custom class name (applies to badge span) */
|
|
295
|
+
className?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Class names for individual parts (Radix UI pattern)
|
|
298
|
+
* For this simple component, using className is usually sufficient
|
|
299
|
+
*/
|
|
300
|
+
classNames?: FFIDSubscriptionBadgeClassNames;
|
|
301
|
+
/** Custom style */
|
|
302
|
+
style?: CSSProperties;
|
|
303
|
+
/** Show plan name instead of status */
|
|
304
|
+
showPlanName?: boolean;
|
|
305
|
+
/** Custom labels for each status */
|
|
306
|
+
labels?: {
|
|
307
|
+
active?: string;
|
|
308
|
+
trialing?: string;
|
|
309
|
+
pastDue?: string;
|
|
310
|
+
canceled?: string;
|
|
311
|
+
paused?: string;
|
|
312
|
+
none?: string;
|
|
313
|
+
};
|
|
314
|
+
/** Custom render function */
|
|
315
|
+
render?: (status: string, planName: string | null) => ReactNode;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Subscription status badge
|
|
319
|
+
*/
|
|
320
|
+
declare function FFIDSubscriptionBadge({ className, classNames, style, showPlanName, labels, render, }: FFIDSubscriptionBadgeProps): react_jsx_runtime.JSX.Element;
|
|
321
|
+
|
|
322
|
+
export { type FFIDConfig as F, type FFIDUser as a, type FFIDOrganization as b, type FFIDError as c, type FFIDSubscriptionContextValue as d, type FFIDApiResponse as e, type FFIDContextValue as f, type FFIDLogger as g, FFIDLoginButton as h, FFIDOrganizationSwitcher as i, type FFIDSessionResponse as j, type FFIDSubscription as k, FFIDSubscriptionBadge as l, FFIDUserMenu as m, type FFIDLoginButtonProps as n, type FFIDOrganizationSwitcherClassNames as o, type FFIDOrganizationSwitcherProps as p, type FFIDSubscriptionBadgeClassNames as q, type FFIDSubscriptionBadgeProps as r, type FFIDUserMenuClassNames as s, type FFIDUserMenuProps as t };
|