@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.
@@ -0,0 +1,332 @@
1
+ /**
2
+ * FFID SDK Shared Constants
3
+ *
4
+ * Constants shared across all SDK entry points (main client + legal client).
5
+ * Centralizing these prevents drift during domain/URL changes.
6
+ */
7
+ /** Default FFID API base URL (production) */
8
+ declare const DEFAULT_API_BASE_URL = "https://id.feelflow.co.jp";
9
+
10
+ /**
11
+ * FFID Legal SDK Type Definitions
12
+ *
13
+ * Types for the FeelFlow ID Legal Document SDK.
14
+ * Used by external services to manage legal document agreements
15
+ * via Service API key authentication.
16
+ */
17
+ /**
18
+ * Configuration for the FFID Legal Client
19
+ *
20
+ * Unlike FFIDConfig (which uses Cookie auth), this uses
21
+ * X-Service-Api-Key header for server-to-server communication.
22
+ */
23
+ interface FFIDLegalClientConfig {
24
+ /** Service API key (format: ffid_sk_live_xxx or ffid_sk_test_xxx) */
25
+ apiKey: string;
26
+ /** FFID API base URL (defaults to https://id.feelflow.co.jp) */
27
+ apiBaseUrl?: string;
28
+ /** Enable debug logging */
29
+ debug?: boolean;
30
+ /** Custom logger */
31
+ logger?: FFIDLegalLogger;
32
+ }
33
+ /**
34
+ * Logger interface for Legal SDK
35
+ */
36
+ interface FFIDLegalLogger {
37
+ debug: (...args: unknown[]) => void;
38
+ info: (...args: unknown[]) => void;
39
+ warn: (...args: unknown[]) => void;
40
+ error: (...args: unknown[]) => void;
41
+ }
42
+ /**
43
+ * Legal document types
44
+ */
45
+ type FFIDLegalDocumentType = 'terms_of_service' | 'privacy_policy' | 'cookie_policy' | 'acceptable_use_policy' | 'data_processing_agreement' | 'service_level_agreement' | 'other';
46
+ /**
47
+ * Agreement methods
48
+ */
49
+ type FFIDAgreementMethod = 'explicit_checkbox' | 'click_through' | 'continued_use' | 'electronic_signature';
50
+ /**
51
+ * Legal document returned from the API
52
+ */
53
+ interface FFIDLegalDocument {
54
+ /** Document ID (UUID) */
55
+ id: string;
56
+ /** Document type */
57
+ type: FFIDLegalDocumentType;
58
+ /** Document title */
59
+ title: string;
60
+ /** Document version (e.g., "1.0.0") */
61
+ version: string;
62
+ /** Document content (Markdown) */
63
+ content: string;
64
+ /** Summary of the document */
65
+ summary: string | null;
66
+ /** Effective date (ISO 8601) */
67
+ effectiveDate: string;
68
+ /** Whether this document is currently active */
69
+ isActive: boolean;
70
+ /** Service scope: 'platform' or specific service ID */
71
+ serviceScope: string;
72
+ /** Whether agreement is required to use the service */
73
+ requiresAgreement: boolean;
74
+ /** SHA-256 hash of the content */
75
+ contentHash: string;
76
+ /** Created timestamp (ISO 8601) */
77
+ createdAt: string;
78
+ /** Updated timestamp (ISO 8601) */
79
+ updatedAt: string;
80
+ }
81
+ /**
82
+ * Service user agreement record
83
+ */
84
+ interface FFIDServiceUserAgreement {
85
+ /** Agreement ID (UUID) */
86
+ id: string;
87
+ /** Service ID (UUID) */
88
+ serviceId: string;
89
+ /** External user ID (from the calling service) */
90
+ externalUserId: string;
91
+ /** External user email (optional) */
92
+ externalUserEmail: string | null;
93
+ /** Document ID (UUID) */
94
+ documentId: string;
95
+ /** Agreement timestamp (ISO 8601) */
96
+ agreedAt: string;
97
+ /** Method of agreement */
98
+ agreementMethod: FFIDAgreementMethod;
99
+ /** IP address at time of agreement */
100
+ ipAddress: string | null;
101
+ /** User agent at time of agreement */
102
+ userAgent: string | null;
103
+ /** Document version at time of agreement */
104
+ documentVersion: string;
105
+ /** Document title at time of agreement */
106
+ documentTitle: string;
107
+ /** Document content hash at time of agreement */
108
+ documentHash: string;
109
+ /** Additional metadata */
110
+ metadata: Record<string, unknown>;
111
+ /** Created timestamp (ISO 8601) */
112
+ createdAt: string;
113
+ }
114
+ /**
115
+ * Request to record an agreement
116
+ */
117
+ interface FFIDRecordAgreementRequest {
118
+ /** External user ID (from the calling service, e.g., Google OAuth ID) */
119
+ externalUserId: string;
120
+ /** External user email (optional) */
121
+ externalUserEmail?: string;
122
+ /** Document ID to agree to */
123
+ documentId: string;
124
+ /** Method of agreement (defaults to 'click_through') */
125
+ agreementMethod?: FFIDAgreementMethod;
126
+ /** IP address of the user (if not provided, extracted from request) */
127
+ ipAddress?: string;
128
+ /** User agent of the user (if not provided, extracted from request) */
129
+ userAgent?: string;
130
+ /** Additional metadata to store with the agreement */
131
+ metadata?: Record<string, unknown>;
132
+ }
133
+ /**
134
+ * Response from recording an agreement
135
+ */
136
+ interface FFIDRecordAgreementResponse {
137
+ /** Success message */
138
+ message: string;
139
+ /** Created agreement ID */
140
+ agreementId: string;
141
+ /** Document ID that was agreed to */
142
+ documentId: string;
143
+ /** External user ID */
144
+ externalUserId: string;
145
+ }
146
+ /**
147
+ * Agreement check result (discriminated union for type safety)
148
+ *
149
+ * When hasAgreed is true, agreement is guaranteed to be present.
150
+ * When hasAgreed is false, agreement is null.
151
+ */
152
+ type FFIDAgreementCheckResult = {
153
+ hasAgreed: true;
154
+ agreement: FFIDServiceUserAgreement;
155
+ } | {
156
+ hasAgreed: false;
157
+ agreement: null;
158
+ };
159
+ /**
160
+ * Pending agreement info
161
+ */
162
+ interface FFIDPendingAgreement {
163
+ /** Document ID (UUID) */
164
+ documentId: string;
165
+ /** Document type */
166
+ documentType: FFIDLegalDocumentType;
167
+ /** Document title */
168
+ documentTitle: string;
169
+ /** Document version */
170
+ documentVersion: string;
171
+ /** Effective date (ISO 8601) */
172
+ effectiveDate: string;
173
+ }
174
+ /**
175
+ * Response from get pending agreements
176
+ */
177
+ interface FFIDPendingAgreementsResponse {
178
+ /** List of pending documents */
179
+ pendingDocuments: FFIDPendingAgreement[];
180
+ /** Number of pending documents */
181
+ count: number;
182
+ /** Whether there are any pending documents */
183
+ hasPending: boolean;
184
+ }
185
+ /**
186
+ * Known SDK error codes (generated client-side)
187
+ */
188
+ type FFIDLegalSdkErrorCode = 'MISSING_API_KEY' | 'NETWORK_ERROR' | 'PARSE_ERROR' | 'UNKNOWN_ERROR';
189
+ /**
190
+ * Known server error codes (returned from FFID API)
191
+ */
192
+ type FFIDLegalServerErrorCode = 'INVALID_API_KEY' | 'INSUFFICIENT_SCOPE' | 'DOCUMENT_NOT_FOUND' | 'ALREADY_AGREED' | 'VALIDATION_ERROR' | 'INTERNAL_ERROR' | 'NOT_FOUND' | 'UNAUTHORIZED' | 'FORBIDDEN';
193
+ /**
194
+ * All known error codes (SDK + Server)
195
+ * Uses intersection with string to allow future unknown codes
196
+ */
197
+ type FFIDLegalErrorCode = FFIDLegalSdkErrorCode | FFIDLegalServerErrorCode | (string & Record<never, never>);
198
+ /**
199
+ * Server error details structure
200
+ */
201
+ interface FFIDLegalServerError {
202
+ code: string;
203
+ message: string;
204
+ details?: Record<string, unknown>;
205
+ }
206
+ /**
207
+ * Server response envelope from FFID Legal API (discriminated union)
208
+ *
209
+ * All API responses follow this structure with success flag as discriminator.
210
+ * - When success is true, data is guaranteed to be present
211
+ * - When success is false, error is guaranteed to be present
212
+ *
213
+ * The SDK transforms this into FFIDLegalApiResponse<T>.
214
+ */
215
+ type FFIDLegalServerResponse<T> = {
216
+ success: true;
217
+ data: T;
218
+ error?: undefined;
219
+ } | {
220
+ success: false;
221
+ data?: undefined;
222
+ error: FFIDLegalServerError;
223
+ };
224
+ /**
225
+ * Error from the Legal SDK
226
+ */
227
+ interface FFIDLegalError {
228
+ /** Error code */
229
+ code: FFIDLegalErrorCode;
230
+ /** Human-readable error message */
231
+ message: string;
232
+ /** Additional error details */
233
+ details?: Record<string, unknown>;
234
+ }
235
+ /**
236
+ * API response wrapper (discriminated union for type safety)
237
+ *
238
+ * Either data is present (success) or error is present (failure), never both.
239
+ * This pattern ensures callers handle both cases explicitly.
240
+ */
241
+ type FFIDLegalApiResponse<T> = {
242
+ data: T;
243
+ error?: undefined;
244
+ } | {
245
+ data?: undefined;
246
+ error: FFIDLegalError;
247
+ };
248
+
249
+ /**
250
+ * FFID Legal API Client
251
+ *
252
+ * Handles API communication for legal document operations.
253
+ * Uses Service API key authentication (X-Service-Api-Key header)
254
+ * for server-to-server communication.
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * import { createFFIDLegalClient } from '@feelflow/ffid-sdk/legal'
259
+ *
260
+ * const legal = createFFIDLegalClient({
261
+ * apiKey: process.env.FFID_SERVICE_API_KEY!,
262
+ * })
263
+ *
264
+ * // Get all documents
265
+ * const { data, error } = await legal.getDocuments()
266
+ *
267
+ * // Record agreement
268
+ * await legal.recordAgreement({
269
+ * externalUserId: user.google_id,
270
+ * documentId: doc.id,
271
+ * })
272
+ *
273
+ * // Check agreement
274
+ * const check = await legal.checkAgreement(userId, docId)
275
+ * ```
276
+ */
277
+
278
+ /**
279
+ * Error codes used by the Legal SDK
280
+ */
281
+ declare const FFID_LEGAL_ERROR_CODES: {
282
+ /** API key is missing */
283
+ readonly MISSING_API_KEY: "MISSING_API_KEY";
284
+ /** Network request failed (fetch threw) */
285
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
286
+ /** Server returned non-JSON response */
287
+ readonly PARSE_ERROR: "PARSE_ERROR";
288
+ /** Server returned error without structured error body */
289
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
290
+ /** Input validation failed (empty required parameters) */
291
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
292
+ };
293
+ /**
294
+ * Creates an FFID Legal API client instance
295
+ *
296
+ * @param config - Client configuration
297
+ * @returns Legal client instance
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * const legal = createFFIDLegalClient({
302
+ * apiKey: process.env.FFID_SERVICE_API_KEY!,
303
+ * apiBaseUrl: 'https://id.feelflow.co.jp',
304
+ * debug: true,
305
+ * })
306
+ * ```
307
+ */
308
+ declare function createFFIDLegalClient(config: FFIDLegalClientConfig): {
309
+ /** Get all legal documents available to this service */
310
+ getDocuments: () => Promise<FFIDLegalApiResponse<{
311
+ documents: FFIDLegalDocument[];
312
+ count: number;
313
+ }>>;
314
+ /** Get a specific legal document by ID */
315
+ getDocument: (documentId: string) => Promise<FFIDLegalApiResponse<{
316
+ document: FFIDLegalDocument;
317
+ }>>;
318
+ /** Record a user's agreement to a legal document */
319
+ recordAgreement: (request: FFIDRecordAgreementRequest) => Promise<FFIDLegalApiResponse<FFIDRecordAgreementResponse>>;
320
+ /** Check if a user has agreed to a specific document */
321
+ checkAgreement: (externalUserId: string, documentId: string) => Promise<FFIDLegalApiResponse<FFIDAgreementCheckResult>>;
322
+ /** Get all documents that a user has not yet agreed to */
323
+ getPendingAgreements: (externalUserId: string) => Promise<FFIDLegalApiResponse<FFIDPendingAgreementsResponse>>;
324
+ /** Resolved logger instance */
325
+ logger: FFIDLegalLogger;
326
+ /** API base URL */
327
+ baseUrl: string;
328
+ };
329
+ /** Type of the FFID Legal client */
330
+ type FFIDLegalClient = ReturnType<typeof createFFIDLegalClient>;
331
+
332
+ export { DEFAULT_API_BASE_URL, type FFIDAgreementCheckResult, type FFIDAgreementMethod, type FFIDLegalApiResponse, type FFIDLegalClient, type FFIDLegalClientConfig, type FFIDLegalDocument, type FFIDLegalDocumentType, type FFIDLegalError, type FFIDLegalErrorCode, type FFIDLegalLogger, type FFIDLegalSdkErrorCode, type FFIDLegalServerError, type FFIDLegalServerErrorCode, type FFIDLegalServerResponse, type FFIDPendingAgreement, type FFIDPendingAgreementsResponse, type FFIDRecordAgreementRequest, type FFIDRecordAgreementResponse, type FFIDServiceUserAgreement, FFID_LEGAL_ERROR_CODES, createFFIDLegalClient };
@@ -0,0 +1,332 @@
1
+ /**
2
+ * FFID SDK Shared Constants
3
+ *
4
+ * Constants shared across all SDK entry points (main client + legal client).
5
+ * Centralizing these prevents drift during domain/URL changes.
6
+ */
7
+ /** Default FFID API base URL (production) */
8
+ declare const DEFAULT_API_BASE_URL = "https://id.feelflow.co.jp";
9
+
10
+ /**
11
+ * FFID Legal SDK Type Definitions
12
+ *
13
+ * Types for the FeelFlow ID Legal Document SDK.
14
+ * Used by external services to manage legal document agreements
15
+ * via Service API key authentication.
16
+ */
17
+ /**
18
+ * Configuration for the FFID Legal Client
19
+ *
20
+ * Unlike FFIDConfig (which uses Cookie auth), this uses
21
+ * X-Service-Api-Key header for server-to-server communication.
22
+ */
23
+ interface FFIDLegalClientConfig {
24
+ /** Service API key (format: ffid_sk_live_xxx or ffid_sk_test_xxx) */
25
+ apiKey: string;
26
+ /** FFID API base URL (defaults to https://id.feelflow.co.jp) */
27
+ apiBaseUrl?: string;
28
+ /** Enable debug logging */
29
+ debug?: boolean;
30
+ /** Custom logger */
31
+ logger?: FFIDLegalLogger;
32
+ }
33
+ /**
34
+ * Logger interface for Legal SDK
35
+ */
36
+ interface FFIDLegalLogger {
37
+ debug: (...args: unknown[]) => void;
38
+ info: (...args: unknown[]) => void;
39
+ warn: (...args: unknown[]) => void;
40
+ error: (...args: unknown[]) => void;
41
+ }
42
+ /**
43
+ * Legal document types
44
+ */
45
+ type FFIDLegalDocumentType = 'terms_of_service' | 'privacy_policy' | 'cookie_policy' | 'acceptable_use_policy' | 'data_processing_agreement' | 'service_level_agreement' | 'other';
46
+ /**
47
+ * Agreement methods
48
+ */
49
+ type FFIDAgreementMethod = 'explicit_checkbox' | 'click_through' | 'continued_use' | 'electronic_signature';
50
+ /**
51
+ * Legal document returned from the API
52
+ */
53
+ interface FFIDLegalDocument {
54
+ /** Document ID (UUID) */
55
+ id: string;
56
+ /** Document type */
57
+ type: FFIDLegalDocumentType;
58
+ /** Document title */
59
+ title: string;
60
+ /** Document version (e.g., "1.0.0") */
61
+ version: string;
62
+ /** Document content (Markdown) */
63
+ content: string;
64
+ /** Summary of the document */
65
+ summary: string | null;
66
+ /** Effective date (ISO 8601) */
67
+ effectiveDate: string;
68
+ /** Whether this document is currently active */
69
+ isActive: boolean;
70
+ /** Service scope: 'platform' or specific service ID */
71
+ serviceScope: string;
72
+ /** Whether agreement is required to use the service */
73
+ requiresAgreement: boolean;
74
+ /** SHA-256 hash of the content */
75
+ contentHash: string;
76
+ /** Created timestamp (ISO 8601) */
77
+ createdAt: string;
78
+ /** Updated timestamp (ISO 8601) */
79
+ updatedAt: string;
80
+ }
81
+ /**
82
+ * Service user agreement record
83
+ */
84
+ interface FFIDServiceUserAgreement {
85
+ /** Agreement ID (UUID) */
86
+ id: string;
87
+ /** Service ID (UUID) */
88
+ serviceId: string;
89
+ /** External user ID (from the calling service) */
90
+ externalUserId: string;
91
+ /** External user email (optional) */
92
+ externalUserEmail: string | null;
93
+ /** Document ID (UUID) */
94
+ documentId: string;
95
+ /** Agreement timestamp (ISO 8601) */
96
+ agreedAt: string;
97
+ /** Method of agreement */
98
+ agreementMethod: FFIDAgreementMethod;
99
+ /** IP address at time of agreement */
100
+ ipAddress: string | null;
101
+ /** User agent at time of agreement */
102
+ userAgent: string | null;
103
+ /** Document version at time of agreement */
104
+ documentVersion: string;
105
+ /** Document title at time of agreement */
106
+ documentTitle: string;
107
+ /** Document content hash at time of agreement */
108
+ documentHash: string;
109
+ /** Additional metadata */
110
+ metadata: Record<string, unknown>;
111
+ /** Created timestamp (ISO 8601) */
112
+ createdAt: string;
113
+ }
114
+ /**
115
+ * Request to record an agreement
116
+ */
117
+ interface FFIDRecordAgreementRequest {
118
+ /** External user ID (from the calling service, e.g., Google OAuth ID) */
119
+ externalUserId: string;
120
+ /** External user email (optional) */
121
+ externalUserEmail?: string;
122
+ /** Document ID to agree to */
123
+ documentId: string;
124
+ /** Method of agreement (defaults to 'click_through') */
125
+ agreementMethod?: FFIDAgreementMethod;
126
+ /** IP address of the user (if not provided, extracted from request) */
127
+ ipAddress?: string;
128
+ /** User agent of the user (if not provided, extracted from request) */
129
+ userAgent?: string;
130
+ /** Additional metadata to store with the agreement */
131
+ metadata?: Record<string, unknown>;
132
+ }
133
+ /**
134
+ * Response from recording an agreement
135
+ */
136
+ interface FFIDRecordAgreementResponse {
137
+ /** Success message */
138
+ message: string;
139
+ /** Created agreement ID */
140
+ agreementId: string;
141
+ /** Document ID that was agreed to */
142
+ documentId: string;
143
+ /** External user ID */
144
+ externalUserId: string;
145
+ }
146
+ /**
147
+ * Agreement check result (discriminated union for type safety)
148
+ *
149
+ * When hasAgreed is true, agreement is guaranteed to be present.
150
+ * When hasAgreed is false, agreement is null.
151
+ */
152
+ type FFIDAgreementCheckResult = {
153
+ hasAgreed: true;
154
+ agreement: FFIDServiceUserAgreement;
155
+ } | {
156
+ hasAgreed: false;
157
+ agreement: null;
158
+ };
159
+ /**
160
+ * Pending agreement info
161
+ */
162
+ interface FFIDPendingAgreement {
163
+ /** Document ID (UUID) */
164
+ documentId: string;
165
+ /** Document type */
166
+ documentType: FFIDLegalDocumentType;
167
+ /** Document title */
168
+ documentTitle: string;
169
+ /** Document version */
170
+ documentVersion: string;
171
+ /** Effective date (ISO 8601) */
172
+ effectiveDate: string;
173
+ }
174
+ /**
175
+ * Response from get pending agreements
176
+ */
177
+ interface FFIDPendingAgreementsResponse {
178
+ /** List of pending documents */
179
+ pendingDocuments: FFIDPendingAgreement[];
180
+ /** Number of pending documents */
181
+ count: number;
182
+ /** Whether there are any pending documents */
183
+ hasPending: boolean;
184
+ }
185
+ /**
186
+ * Known SDK error codes (generated client-side)
187
+ */
188
+ type FFIDLegalSdkErrorCode = 'MISSING_API_KEY' | 'NETWORK_ERROR' | 'PARSE_ERROR' | 'UNKNOWN_ERROR';
189
+ /**
190
+ * Known server error codes (returned from FFID API)
191
+ */
192
+ type FFIDLegalServerErrorCode = 'INVALID_API_KEY' | 'INSUFFICIENT_SCOPE' | 'DOCUMENT_NOT_FOUND' | 'ALREADY_AGREED' | 'VALIDATION_ERROR' | 'INTERNAL_ERROR' | 'NOT_FOUND' | 'UNAUTHORIZED' | 'FORBIDDEN';
193
+ /**
194
+ * All known error codes (SDK + Server)
195
+ * Uses intersection with string to allow future unknown codes
196
+ */
197
+ type FFIDLegalErrorCode = FFIDLegalSdkErrorCode | FFIDLegalServerErrorCode | (string & Record<never, never>);
198
+ /**
199
+ * Server error details structure
200
+ */
201
+ interface FFIDLegalServerError {
202
+ code: string;
203
+ message: string;
204
+ details?: Record<string, unknown>;
205
+ }
206
+ /**
207
+ * Server response envelope from FFID Legal API (discriminated union)
208
+ *
209
+ * All API responses follow this structure with success flag as discriminator.
210
+ * - When success is true, data is guaranteed to be present
211
+ * - When success is false, error is guaranteed to be present
212
+ *
213
+ * The SDK transforms this into FFIDLegalApiResponse<T>.
214
+ */
215
+ type FFIDLegalServerResponse<T> = {
216
+ success: true;
217
+ data: T;
218
+ error?: undefined;
219
+ } | {
220
+ success: false;
221
+ data?: undefined;
222
+ error: FFIDLegalServerError;
223
+ };
224
+ /**
225
+ * Error from the Legal SDK
226
+ */
227
+ interface FFIDLegalError {
228
+ /** Error code */
229
+ code: FFIDLegalErrorCode;
230
+ /** Human-readable error message */
231
+ message: string;
232
+ /** Additional error details */
233
+ details?: Record<string, unknown>;
234
+ }
235
+ /**
236
+ * API response wrapper (discriminated union for type safety)
237
+ *
238
+ * Either data is present (success) or error is present (failure), never both.
239
+ * This pattern ensures callers handle both cases explicitly.
240
+ */
241
+ type FFIDLegalApiResponse<T> = {
242
+ data: T;
243
+ error?: undefined;
244
+ } | {
245
+ data?: undefined;
246
+ error: FFIDLegalError;
247
+ };
248
+
249
+ /**
250
+ * FFID Legal API Client
251
+ *
252
+ * Handles API communication for legal document operations.
253
+ * Uses Service API key authentication (X-Service-Api-Key header)
254
+ * for server-to-server communication.
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * import { createFFIDLegalClient } from '@feelflow/ffid-sdk/legal'
259
+ *
260
+ * const legal = createFFIDLegalClient({
261
+ * apiKey: process.env.FFID_SERVICE_API_KEY!,
262
+ * })
263
+ *
264
+ * // Get all documents
265
+ * const { data, error } = await legal.getDocuments()
266
+ *
267
+ * // Record agreement
268
+ * await legal.recordAgreement({
269
+ * externalUserId: user.google_id,
270
+ * documentId: doc.id,
271
+ * })
272
+ *
273
+ * // Check agreement
274
+ * const check = await legal.checkAgreement(userId, docId)
275
+ * ```
276
+ */
277
+
278
+ /**
279
+ * Error codes used by the Legal SDK
280
+ */
281
+ declare const FFID_LEGAL_ERROR_CODES: {
282
+ /** API key is missing */
283
+ readonly MISSING_API_KEY: "MISSING_API_KEY";
284
+ /** Network request failed (fetch threw) */
285
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
286
+ /** Server returned non-JSON response */
287
+ readonly PARSE_ERROR: "PARSE_ERROR";
288
+ /** Server returned error without structured error body */
289
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
290
+ /** Input validation failed (empty required parameters) */
291
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
292
+ };
293
+ /**
294
+ * Creates an FFID Legal API client instance
295
+ *
296
+ * @param config - Client configuration
297
+ * @returns Legal client instance
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * const legal = createFFIDLegalClient({
302
+ * apiKey: process.env.FFID_SERVICE_API_KEY!,
303
+ * apiBaseUrl: 'https://id.feelflow.co.jp',
304
+ * debug: true,
305
+ * })
306
+ * ```
307
+ */
308
+ declare function createFFIDLegalClient(config: FFIDLegalClientConfig): {
309
+ /** Get all legal documents available to this service */
310
+ getDocuments: () => Promise<FFIDLegalApiResponse<{
311
+ documents: FFIDLegalDocument[];
312
+ count: number;
313
+ }>>;
314
+ /** Get a specific legal document by ID */
315
+ getDocument: (documentId: string) => Promise<FFIDLegalApiResponse<{
316
+ document: FFIDLegalDocument;
317
+ }>>;
318
+ /** Record a user's agreement to a legal document */
319
+ recordAgreement: (request: FFIDRecordAgreementRequest) => Promise<FFIDLegalApiResponse<FFIDRecordAgreementResponse>>;
320
+ /** Check if a user has agreed to a specific document */
321
+ checkAgreement: (externalUserId: string, documentId: string) => Promise<FFIDLegalApiResponse<FFIDAgreementCheckResult>>;
322
+ /** Get all documents that a user has not yet agreed to */
323
+ getPendingAgreements: (externalUserId: string) => Promise<FFIDLegalApiResponse<FFIDPendingAgreementsResponse>>;
324
+ /** Resolved logger instance */
325
+ logger: FFIDLegalLogger;
326
+ /** API base URL */
327
+ baseUrl: string;
328
+ };
329
+ /** Type of the FFID Legal client */
330
+ type FFIDLegalClient = ReturnType<typeof createFFIDLegalClient>;
331
+
332
+ export { DEFAULT_API_BASE_URL, type FFIDAgreementCheckResult, type FFIDAgreementMethod, type FFIDLegalApiResponse, type FFIDLegalClient, type FFIDLegalClientConfig, type FFIDLegalDocument, type FFIDLegalDocumentType, type FFIDLegalError, type FFIDLegalErrorCode, type FFIDLegalLogger, type FFIDLegalSdkErrorCode, type FFIDLegalServerError, type FFIDLegalServerErrorCode, type FFIDLegalServerResponse, type FFIDPendingAgreement, type FFIDPendingAgreementsResponse, type FFIDRecordAgreementRequest, type FFIDRecordAgreementResponse, type FFIDServiceUserAgreement, FFID_LEGAL_ERROR_CODES, createFFIDLegalClient };