@feelflow/ffid-sdk 2.12.1 → 2.15.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.
@@ -8,21 +8,63 @@ export { D as DEFAULT_API_BASE_URL } from '../constants-DvTGHPZn.js';
8
8
  * `<FFIDInquiryForm />` and submit through either endpoint.
9
9
  */
10
10
  /**
11
- * Categories surfaced by the default form. Consumers are free to
12
- * pass their own list via `<FFIDInquiryForm categories={...} />`.
11
+ * Legacy 6-value canonical categories. Retained for historical DB rows
12
+ * (the pre-2026 values `general`, `sales`, `support`, `press` still appear
13
+ * in older inquiries) and for 2.x backwards compatibility with SDK
14
+ * consumers that pinned to this exact set.
15
+ *
16
+ * Note: `partnership` and `other` intentionally also appear in
17
+ * {@link FFID_INQUIRY_CATEGORIES_SITE_2026}; the legacy-only subset is
18
+ * `general`, `sales`, `support`, `press`.
19
+ *
20
+ * @deprecated New integrations should use
21
+ * {@link FFID_INQUIRY_CATEGORIES_SITE_2026} (13 values, aligned with
22
+ * feelflow-website-2026 `/contact`). This legacy constant remains
23
+ * exported for 2.x compatibility and may be removed in 3.x.
13
24
  */
14
25
  declare const FFID_INQUIRY_CATEGORIES: readonly ["general", "sales", "support", "partnership", "press", "other"];
26
+ /**
27
+ * Type alias derived from the legacy 6-value list. Still referenced by
28
+ * {@link FFIDInquiryCreateParams.category} so existing callers compile
29
+ * without changes; no `@deprecated` on the type itself because the
30
+ * actionable migration target is the runtime constant above, and
31
+ * propagating `@deprecated` to the type would surface false-positive
32
+ * warnings on public API that deliberately accepts both shapes.
33
+ */
15
34
  type FFIDInquiryCategory = (typeof FFID_INQUIRY_CATEGORIES)[number];
35
+ /**
36
+ * 13-value category list that mirrors feelflow-website-2026
37
+ * `/contact` (`feelflow-site/src/lib/contact-schema.ts` `CATEGORY_OPTIONS`).
38
+ *
39
+ * Source-of-truth ownership: **the site repo is authoritative**; this
40
+ * constant is a delayed-sync snapshot shipped through the SDK so
41
+ * consumers can get autocomplete without depending on the site repo.
42
+ * Drift between site and the FFID admin UI is detected automatically by
43
+ * `scripts/sync-inquiry-categories.ts` (SDK-side drift is a separate
44
+ * follow-up and today is caught only if the SDK snapshot is updated
45
+ * alongside the admin UI constants).
46
+ */
47
+ declare const FFID_INQUIRY_CATEGORIES_SITE_2026: readonly ["consulting", "saas", "development", "agent-hub", "ai-feel-chatbot", "knowledge-db", "biz-simulator", "discussion-board", "realtime-ai", "partnership", "media", "recruiting", "other"];
48
+ type FFIDInquiryCategorySite2026 = (typeof FFID_INQUIRY_CATEGORIES_SITE_2026)[number];
16
49
  /**
17
50
  * Parameters for `client.inquiry.create()`. When submitting from a
18
51
  * server-side SDK (Service API Key), set `source` to a stable
19
52
  * origin string so admins can trace the submission back.
53
+ *
54
+ * `category` accepts any string at the SDK boundary to keep the SDK
55
+ * forward-compatible with new site-side categories added before the SDK
56
+ * re-publishes. FFID ext-endpoint validation (`/api/v1/ext/inquiry`) is
57
+ * lenient — `z.string().max(100).optional()` — so unknown strings flow
58
+ * through to the DB unchanged. Note: the `(string & {})` arm of the
59
+ * union intentionally keeps autocomplete active while allowing arbitrary
60
+ * strings; callers using exhaustive `switch` statements should include
61
+ * a `default` branch.
20
62
  */
21
63
  interface FFIDInquiryCreateParams {
22
64
  email: string;
23
65
  name: string;
24
66
  message: string;
25
- category?: FFIDInquiryCategory | (string & {});
67
+ category?: FFIDInquiryCategorySite2026 | FFIDInquiryCategory | (string & {});
26
68
  company?: string;
27
69
  phone?: string;
28
70
  locale?: 'ja' | 'en';
@@ -738,6 +780,96 @@ interface FFIDUpdateMemberRoleResponse {
738
780
  interface FFIDRemoveMemberResponse {
739
781
  message: string;
740
782
  }
783
+ /**
784
+ * User profile for the authenticated user (returned by `getProfile` / `updateProfile`).
785
+ *
786
+ * Mirrors the FFID backend `UserProfile` shape exposed via
787
+ * `GET /api/v1/users/ext/me` and `PUT /api/v1/users/ext/me`.
788
+ */
789
+ interface FFIDUserProfile {
790
+ /** User ID (UUID) */
791
+ id: string;
792
+ /** Email address */
793
+ email: string;
794
+ /** Display name (nullable when not set) */
795
+ displayName: string | null;
796
+ /** Avatar URL (nullable when not set) */
797
+ avatarUrl: string | null;
798
+ /** Phone number (nullable when not set) */
799
+ phone: string | null;
800
+ /** Company name (nullable when not set) */
801
+ companyName: string | null;
802
+ /** Department (nullable when not set) */
803
+ department: string | null;
804
+ /** Job title (nullable when not set) */
805
+ jobTitle: string | null;
806
+ /** IANA timezone (e.g. 'Asia/Tokyo') */
807
+ timezone: string;
808
+ /** Locale (e.g. 'ja', 'en') */
809
+ locale: string;
810
+ /** Arbitrary user preferences bag */
811
+ preferences: Record<string, unknown>;
812
+ /** Account creation timestamp (ISO 8601) */
813
+ createdAt: string;
814
+ /** Profile last-updated timestamp (ISO 8601) */
815
+ updatedAt: string;
816
+ }
817
+ /**
818
+ * Per-call options for profile methods (`getProfile` / `updateProfile`).
819
+ *
820
+ * Supply `accessToken` to forward an end-user Bearer token for the single call
821
+ * without mutating client-level auth state. Designed for server runtimes (Cloudflare
822
+ * Workers, Edge, Node) that receive a user-scoped Bearer per request and want to
823
+ * act as that user against `/api/v1/users/ext/me`.
824
+ *
825
+ * When `accessToken` is supplied with a non-empty value, it overrides the client's
826
+ * configured auth mode: authentication for that request uses only
827
+ * `Authorization: Bearer <accessToken>` (no service key, no cookie, no token-store
828
+ * lookup, no auto-refresh on 401). Non-auth headers such as `Content-Type` and
829
+ * SDK metadata headers (User-Agent / X-FFID-SDK-Version) are still attached.
830
+ *
831
+ * Runtime semantics:
832
+ * - `accessToken` omitted (or `undefined`) → no override, configured `authMode` is used
833
+ * - `accessToken` is empty string / whitespace-only → rejected as `VALIDATION_ERROR`
834
+ * before any network call (prevents silent impersonation fallback when a caller
835
+ * extracts a missing/blank `Authorization` header into this field)
836
+ * - `accessToken` is a non-empty string → override activated
837
+ */
838
+ interface FFIDProfileCallOptions {
839
+ /**
840
+ * End-user Bearer token forwarded for this single request.
841
+ *
842
+ * Must be a non-empty string when supplied. Passing `''` or a whitespace-only
843
+ * string is treated as a caller error and surfaces as `VALIDATION_ERROR` —
844
+ * this guards against the common footgun where a server runtime extracts the
845
+ * Bearer from an incoming request without checking the header is present.
846
+ */
847
+ accessToken?: string;
848
+ }
849
+ /**
850
+ * Request payload for `updateProfile`.
851
+ *
852
+ * Mirrors the FFID backend `UpdateUserProfileRequest` shape. All fields are
853
+ * optional — only the supplied keys will be updated (partial update semantics).
854
+ */
855
+ interface FFIDUpdateUserProfileRequest {
856
+ /** Display name */
857
+ displayName?: string;
858
+ /** Phone number */
859
+ phone?: string;
860
+ /** Company name */
861
+ companyName?: string;
862
+ /** Department */
863
+ department?: string;
864
+ /** Job title */
865
+ jobTitle?: string;
866
+ /** IANA timezone */
867
+ timezone?: string;
868
+ /** Locale */
869
+ locale?: string;
870
+ /** Arbitrary user preferences bag */
871
+ preferences?: Record<string, unknown>;
872
+ }
741
873
  /**
742
874
  * Result of a redirect operation (redirectToLogin / redirectToAuthorize / redirectToLogout)
743
875
  *
@@ -892,6 +1024,8 @@ declare function createFFIDClient(config: FFIDConfig): {
892
1024
  organizationId: string;
893
1025
  userId: string;
894
1026
  }) => Promise<FFIDApiResponse<FFIDRemoveMemberResponse>>;
1027
+ getProfile: (options?: FFIDProfileCallOptions) => Promise<FFIDApiResponse<FFIDUserProfile>>;
1028
+ updateProfile: (data: FFIDUpdateUserProfileRequest, options?: FFIDProfileCallOptions) => Promise<FFIDApiResponse<FFIDUserProfile>>;
895
1029
  createCheckoutSession: (params: FFIDCreateCheckoutParams) => Promise<FFIDApiResponse<FFIDCheckoutSessionResponse>>;
896
1030
  createPortalSession: (params: FFIDCreatePortalParams) => Promise<FFIDApiResponse<FFIDPortalSessionResponse>>;
897
1031
  listPlans: () => Promise<FFIDApiResponse<FFIDListPlansResponse>>;
@@ -1002,4 +1136,4 @@ interface KVNamespaceLike {
1002
1136
  */
1003
1137
  declare function createKVCacheAdapter(kv: KVNamespaceLike): FFIDCacheAdapter;
1004
1138
 
1005
- export { type FFIDCacheAdapter, type FFIDCacheConfig, type FFIDClient, type FFIDConfig, type FFIDOAuthUserInfo, type FFIDOrganization, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDResetSessionResponse, type FFIDSubscription, type FFIDUser, type FFIDVerifyAccessTokenOptions, type KVNamespaceLike, type TokenData, type TokenStore, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, createVerifyAccessToken };
1139
+ export { type FFIDCacheAdapter, type FFIDCacheConfig, type FFIDClient, type FFIDConfig, type FFIDOAuthUserInfo, type FFIDOrganization, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDProfileCallOptions, type FFIDResetSessionResponse, type FFIDSubscription, type FFIDUpdateUserProfileRequest, type FFIDUser, type FFIDUserProfile, type FFIDVerifyAccessTokenOptions, type KVNamespaceLike, type TokenData, type TokenStore, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, createVerifyAccessToken };
@@ -755,8 +755,57 @@ function createMembersMethods(deps) {
755
755
  return { listMembers, updateMemberRole, removeMember };
756
756
  }
757
757
 
758
+ // src/client/profile-methods.ts
759
+ var EXT_PROFILE_ENDPOINT = "/api/v1/users/ext/me";
760
+ function resolveAuthOverride(options, createError) {
761
+ if (!options || options.accessToken === void 0) {
762
+ return {};
763
+ }
764
+ const token = options.accessToken;
765
+ if (typeof token !== "string" || token.trim() === "") {
766
+ return {
767
+ error: createError(
768
+ "VALIDATION_ERROR",
769
+ "accessToken \u3092\u6307\u5B9A\u3059\u308B\u5834\u5408\u3001\u7A7A\u6587\u5B57\u5217\u3084\u7A7A\u767D\u306E\u307F\u306E\u5024\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093"
770
+ )
771
+ };
772
+ }
773
+ return { override: { accessToken: token } };
774
+ }
775
+ function createProfileMethods(deps) {
776
+ const { fetchWithAuth, createError } = deps;
777
+ async function getProfile(options) {
778
+ const { override, error } = resolveAuthOverride(options, createError);
779
+ if (error) return { error };
780
+ return fetchWithAuth(EXT_PROFILE_ENDPOINT, void 0, override);
781
+ }
782
+ async function updateProfile(data, options) {
783
+ if (data === null || typeof data !== "object" || Array.isArray(data)) {
784
+ return {
785
+ error: createError("VALIDATION_ERROR", "data \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059")
786
+ };
787
+ }
788
+ if (Object.keys(data).length === 0) {
789
+ return {
790
+ error: createError("VALIDATION_ERROR", "\u66F4\u65B0\u3059\u308B\u30D5\u30A3\u30FC\u30EB\u30C9\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044")
791
+ };
792
+ }
793
+ const { override, error } = resolveAuthOverride(options, createError);
794
+ if (error) return { error };
795
+ return fetchWithAuth(
796
+ EXT_PROFILE_ENDPOINT,
797
+ {
798
+ method: "PUT",
799
+ body: JSON.stringify(data)
800
+ },
801
+ override
802
+ );
803
+ }
804
+ return { getProfile, updateProfile };
805
+ }
806
+
758
807
  // src/client/version-check.ts
759
- var SDK_VERSION = "2.12.1";
808
+ var SDK_VERSION = "2.15.0";
760
809
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
761
810
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
762
811
  function sdkHeaders() {
@@ -1938,7 +1987,19 @@ function createFFIDClient(config) {
1938
1987
  function createError(code, message) {
1939
1988
  return { code, message };
1940
1989
  }
1941
- function buildFetchOptions(options) {
1990
+ function buildFetchOptions(options, authOverride) {
1991
+ if (authOverride) {
1992
+ return {
1993
+ ...options,
1994
+ credentials: "omit",
1995
+ headers: {
1996
+ "Content-Type": "application/json",
1997
+ ...sdkHeaders(),
1998
+ ...options.headers,
1999
+ Authorization: `Bearer ${authOverride.accessToken}`
2000
+ }
2001
+ };
2002
+ }
1942
2003
  if (authMode === "service-key") {
1943
2004
  return {
1944
2005
  ...options,
@@ -1985,10 +2046,10 @@ function createFFIDClient(config) {
1985
2046
  logger,
1986
2047
  errorCodes: FFID_ERROR_CODES
1987
2048
  });
1988
- async function fetchWithAuth(endpoint, options = {}) {
2049
+ async function fetchWithAuth(endpoint, options = {}, authOverride) {
1989
2050
  const url = `${baseUrl}${endpoint}`;
1990
2051
  logger.debug("Fetching:", url);
1991
- const fetchOptions = buildFetchOptions(options);
2052
+ const fetchOptions = buildFetchOptions(options, authOverride);
1992
2053
  let response;
1993
2054
  try {
1994
2055
  response = await fetch(url, fetchOptions);
@@ -2001,7 +2062,7 @@ function createFFIDClient(config) {
2001
2062
  }
2002
2063
  };
2003
2064
  }
2004
- if (authMode === "token" && response.status === UNAUTHORIZED_STATUS2) {
2065
+ if (!authOverride && authMode === "token" && response.status === UNAUTHORIZED_STATUS2) {
2005
2066
  const refreshResult = await refreshAccessToken();
2006
2067
  if (!refreshResult.error) {
2007
2068
  logger.debug("Token refreshed, retrying request");
@@ -2127,6 +2188,10 @@ function createFFIDClient(config) {
2127
2188
  createError,
2128
2189
  serviceCode: config.serviceCode
2129
2190
  });
2191
+ const { getProfile, updateProfile } = createProfileMethods({
2192
+ fetchWithAuth,
2193
+ createError
2194
+ });
2130
2195
  const {
2131
2196
  requestPasswordReset,
2132
2197
  verifyPasswordResetToken,
@@ -2198,6 +2263,8 @@ function createFFIDClient(config) {
2198
2263
  listMembers,
2199
2264
  updateMemberRole,
2200
2265
  removeMember,
2266
+ getProfile,
2267
+ updateProfile,
2201
2268
  createCheckoutSession,
2202
2269
  createPortalSession,
2203
2270
  listPlans,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feelflow/ffid-sdk",
3
- "version": "2.12.1",
3
+ "version": "2.15.0",
4
4
  "description": "FeelFlow ID Platform SDK for React/Next.js applications",
5
5
  "keywords": [
6
6
  "feelflow",