@fundedfast/sdk 1.3.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/README.md +352 -0
  3. package/dist/cjs/client.d.ts +130 -0
  4. package/dist/cjs/client.d.ts.map +1 -0
  5. package/dist/cjs/client.js +362 -0
  6. package/dist/cjs/client.js.map +1 -0
  7. package/dist/cjs/index.d.ts +27 -0
  8. package/dist/cjs/index.d.ts.map +1 -0
  9. package/dist/cjs/index.js +33 -0
  10. package/dist/cjs/index.js.map +1 -0
  11. package/dist/cjs/package.json +1 -0
  12. package/dist/cjs/resources/admin.d.ts +597 -0
  13. package/dist/cjs/resources/admin.d.ts.map +1 -0
  14. package/dist/cjs/resources/admin.js +842 -0
  15. package/dist/cjs/resources/admin.js.map +1 -0
  16. package/dist/cjs/resources/public.d.ts +519 -0
  17. package/dist/cjs/resources/public.d.ts.map +1 -0
  18. package/dist/cjs/resources/public.js +588 -0
  19. package/dist/cjs/resources/public.js.map +1 -0
  20. package/dist/cjs/types.d.ts +651 -0
  21. package/dist/cjs/types.d.ts.map +1 -0
  22. package/dist/cjs/types.js +11 -0
  23. package/dist/cjs/types.js.map +1 -0
  24. package/dist/cjs/webhooks.d.ts +104 -0
  25. package/dist/cjs/webhooks.d.ts.map +1 -0
  26. package/dist/cjs/webhooks.js +199 -0
  27. package/dist/cjs/webhooks.js.map +1 -0
  28. package/dist/esm/client.d.ts +130 -0
  29. package/dist/esm/client.d.ts.map +1 -0
  30. package/dist/esm/client.js +355 -0
  31. package/dist/esm/client.js.map +1 -0
  32. package/dist/esm/index.d.ts +27 -0
  33. package/dist/esm/index.d.ts.map +1 -0
  34. package/dist/esm/index.js +26 -0
  35. package/dist/esm/index.js.map +1 -0
  36. package/dist/esm/resources/admin.d.ts +597 -0
  37. package/dist/esm/resources/admin.d.ts.map +1 -0
  38. package/dist/esm/resources/admin.js +816 -0
  39. package/dist/esm/resources/admin.js.map +1 -0
  40. package/dist/esm/resources/public.d.ts +519 -0
  41. package/dist/esm/resources/public.d.ts.map +1 -0
  42. package/dist/esm/resources/public.js +578 -0
  43. package/dist/esm/resources/public.js.map +1 -0
  44. package/dist/esm/types.d.ts +651 -0
  45. package/dist/esm/types.d.ts.map +1 -0
  46. package/dist/esm/types.js +10 -0
  47. package/dist/esm/types.js.map +1 -0
  48. package/dist/esm/webhooks.d.ts +104 -0
  49. package/dist/esm/webhooks.d.ts.map +1 -0
  50. package/dist/esm/webhooks.js +159 -0
  51. package/dist/esm/webhooks.js.map +1 -0
  52. package/package.json +72 -0
@@ -0,0 +1,355 @@
1
+ /**
2
+ * @fundedfast/sdk - Client
3
+ *
4
+ * Production-grade HTTP client for the FAST platform API.
5
+ * Features: automatic retries with exponential backoff, rate limit awareness,
6
+ * request/response hooks, idempotency support, debug logging, and proper error handling.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { FastClient } from '@fundedfast/sdk';
11
+ *
12
+ * const fast = new FastClient({
13
+ * apiKey: process.env.FAST_API_KEY!,
14
+ * retry: { maxRetries: 3 },
15
+ * onResponse: ({ status, durationMs, correlationId }) => {
16
+ * metrics.histogram('fast.request.duration', durationMs, { status });
17
+ * },
18
+ * });
19
+ *
20
+ * const result = await fast.bets.validate({
21
+ * userId: 'player-42',
22
+ * externalBetId: 'BET-001',
23
+ * stakeAmount: 5.00,
24
+ * odds: 2.10,
25
+ * status: 'placed',
26
+ * });
27
+ * ```
28
+ *
29
+ * @module client
30
+ */
31
+ import { ChallengesApi, BetsApi, UsersApi, ReconciliationApi, EventsApi, SandboxApi, WidgetApi, } from './resources/public.js';
32
+ import { AdminApi } from './resources/admin.js';
33
+ // ============================================================================
34
+ // CONSTANTS
35
+ // ============================================================================
36
+ const DEFAULT_BASE_URL = 'https://api.fundedfast.eu/v1';
37
+ const DEFAULT_TIMEOUT = 10_000;
38
+ export const SDK_VERSION = '1.3.0';
39
+ const USER_AGENT = `fundedfast-sdk/${SDK_VERSION} node/${typeof globalThis !== 'undefined' && 'process' in globalThis ? globalThis.process?.version || 'unknown' : 'unknown'}`;
40
+ const DEFAULT_RETRY = {
41
+ maxRetries: 3,
42
+ initialDelay: 300,
43
+ maxDelay: 10_000,
44
+ retryableStatuses: [429, 500, 502, 503, 504],
45
+ };
46
+ /** The key as it may appear in logs: its prefix and last four characters. */
47
+ function redactKey(key) {
48
+ if (key.length <= 8)
49
+ return '***';
50
+ const prefix = /^[a-z]+[-_]/i.exec(key)?.[0] ?? '';
51
+ return `${prefix}***${key.slice(-4)}`;
52
+ }
53
+ /** Random idempotency key (crypto.randomUUID where available - Node 19+/browsers). */
54
+ function generateIdempotencyKey() {
55
+ const c = globalThis.crypto;
56
+ if (c && typeof c.randomUUID === 'function')
57
+ return c.randomUUID();
58
+ return `sdk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}-${Math.random().toString(36).slice(2, 12)}`;
59
+ }
60
+ function sleep(ms) {
61
+ return new Promise(resolve => setTimeout(resolve, ms));
62
+ }
63
+ // ============================================================================
64
+ // ERROR CLASSES
65
+ // ============================================================================
66
+ /**
67
+ * Error thrown when the FAST API returns a non-2xx response.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * try {
72
+ * await fast.challenges.purchase({ userId: 'x', challengeTierId: 'invalid' });
73
+ * } catch (err) {
74
+ * if (err instanceof FastApiError) {
75
+ * console.log(err.status); // 400
76
+ * console.log(err.code); // 'validation_error'
77
+ * console.log(err.correlationId); // 'abc-123' (for support)
78
+ * console.log(err.isRetryable); // false
79
+ * }
80
+ * }
81
+ * ```
82
+ */
83
+ export class FastApiError extends Error {
84
+ status;
85
+ code;
86
+ correlationId;
87
+ isRetryable;
88
+ rateLimitReset;
89
+ constructor(status, body, rateLimitReset) {
90
+ super(body.message || body.error || `HTTP ${status}`);
91
+ this.name = 'FastApiError';
92
+ this.status = status;
93
+ this.code = body.error || `http_${status}`;
94
+ this.correlationId = body.correlationId || '';
95
+ this.isRetryable = DEFAULT_RETRY.retryableStatuses.includes(status);
96
+ this.rateLimitReset = rateLimitReset;
97
+ }
98
+ }
99
+ /**
100
+ * Error thrown when a request times out.
101
+ */
102
+ export class FastTimeoutError extends Error {
103
+ timeoutMs;
104
+ constructor(timeoutMs) {
105
+ super(`Request timed out after ${timeoutMs}ms`);
106
+ this.name = 'FastTimeoutError';
107
+ this.timeoutMs = timeoutMs;
108
+ }
109
+ }
110
+ /**
111
+ * Error thrown when a network error occurs (DNS, connection refused, etc.)
112
+ */
113
+ export class FastNetworkError extends Error {
114
+ cause;
115
+ constructor(cause) {
116
+ super(`Network error: ${cause.message}`);
117
+ this.name = 'FastNetworkError';
118
+ this.cause = cause;
119
+ }
120
+ }
121
+ // ============================================================================
122
+ // CLIENT
123
+ // ============================================================================
124
+ /**
125
+ * FAST Platform API client.
126
+ *
127
+ * Provides typed access to all operator-facing endpoints with automatic retry,
128
+ * rate limit handling, and observability hooks.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const fast = new FastClient({ apiKey: 'key-...' });
133
+ *
134
+ * // Namespaced APIs
135
+ * const tiers = await fast.challenges.listTiers();
136
+ * const result = await fast.bets.validate(betEvent);
137
+ * const progress = await fast.users.getProgress('player-42');
138
+ * ```
139
+ */
140
+ export class FastClient {
141
+ baseUrl;
142
+ apiKey;
143
+ timeout;
144
+ retryConfig;
145
+ onRequest;
146
+ onResponse;
147
+ _fetch;
148
+ customHeaders;
149
+ debug;
150
+ /** Challenge purchase and tier management */
151
+ challenges;
152
+ /** Bet validation and ingestion */
153
+ bets;
154
+ /** User progress, history, and withdrawals */
155
+ users;
156
+ /** Bet event reconciliation */
157
+ reconciliation;
158
+ /** Real-time event streaming (SSE) */
159
+ events;
160
+ /** Sandbox operations (staging only) */
161
+ sandbox;
162
+ /** Widget module and branding configuration */
163
+ widget;
164
+ /** Admin / backoffice operations (tenant management) */
165
+ admin;
166
+ constructor(config) {
167
+ if (!config.apiKey) {
168
+ throw new Error('FastClient: apiKey is required');
169
+ }
170
+ // A server key in a page is a server key published to every visitor.
171
+ const inBrowser = typeof globalThis.window !== 'undefined'
172
+ && typeof globalThis.document !== 'undefined';
173
+ if (inBrowser && !config.dangerouslyAllowBrowser && !config.apiKey.startsWith('pk_')) {
174
+ throw new Error('FastClient: refusing to run in a browser with a server API key. Call FAST from your backend, '
175
+ + 'and use the widget (public pk_ key + user token) in the browser. '
176
+ + 'Pass dangerouslyAllowBrowser: true only if you understand the key will be exposed.');
177
+ }
178
+ this.baseUrl = (config.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, '');
179
+ this.apiKey = config.apiKey;
180
+ this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
181
+ this.onRequest = config.onRequest;
182
+ this.onResponse = config.onResponse;
183
+ this._fetch = config.fetch ?? globalThis.fetch.bind(globalThis);
184
+ this.customHeaders = config.headers ?? {};
185
+ this.debug = config.debug ?? false;
186
+ if (config.retry === false) {
187
+ this.retryConfig = null;
188
+ }
189
+ else {
190
+ this.retryConfig = { ...DEFAULT_RETRY, ...(config.retry || {}) };
191
+ }
192
+ this.challenges = new ChallengesApi(this);
193
+ this.bets = new BetsApi(this);
194
+ this.users = new UsersApi(this);
195
+ this.reconciliation = new ReconciliationApi(this);
196
+ this.events = new EventsApi(this);
197
+ this.sandbox = new SandboxApi(this);
198
+ this.widget = new WidgetApi(this);
199
+ this.admin = new AdminApi(this);
200
+ }
201
+ /**
202
+ * Execute an authenticated request against the FAST API.
203
+ * Handles retries, timeouts, rate limits, and hooks automatically.
204
+ *
205
+ * @internal Use the namespaced APIs (challenges, bets, users, etc.) instead.
206
+ */
207
+ async request(method, path, options) {
208
+ let url = `${this.baseUrl}${path}`;
209
+ if (options?.query) {
210
+ const params = new URLSearchParams();
211
+ for (const [k, v] of Object.entries(options.query)) {
212
+ if (v !== undefined && v !== '')
213
+ params.set(k, v);
214
+ }
215
+ const qs = params.toString();
216
+ if (qs)
217
+ url += `?${qs}`;
218
+ }
219
+ const headers = {
220
+ 'X-API-Key': this.apiKey,
221
+ 'User-Agent': USER_AGENT,
222
+ ...this.customHeaders,
223
+ };
224
+ if (options?.body) {
225
+ headers['Content-Type'] = 'application/json';
226
+ }
227
+ // Money-mutation endpoints (withdraw, refund-stake) REQUIRE X-Idempotency-Key.
228
+ // Auto-generate one per logical request when the caller does not supply one:
229
+ // the same key is reused across the retry loop below, so SDK retries are
230
+ // exactly-once on the server.
231
+ if (method === 'POST') {
232
+ headers['X-Idempotency-Key'] = options?.idempotencyKey || generateIdempotencyKey();
233
+ }
234
+ else if (options?.idempotencyKey) {
235
+ headers['X-Idempotency-Key'] = options.idempotencyKey;
236
+ }
237
+ const bodyStr = options?.body ? JSON.stringify(options.body) : undefined;
238
+ // Hook: onRequest
239
+ if (this.onRequest) {
240
+ // The hook is for logging and tracing; hand it the headers without the
241
+ // key, so a request logger does not write the server key to disk.
242
+ await this.onRequest({ method, url, headers: { ...headers, 'X-API-Key': redactKey(this.apiKey) }, body: bodyStr });
243
+ }
244
+ if (this.debug) {
245
+ console.log(`[fast-sdk] ${method} ${url}`);
246
+ }
247
+ const maxAttempts = this.retryConfig ? this.retryConfig.maxRetries + 1 : 1;
248
+ let lastError = null;
249
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
250
+ const start = Date.now();
251
+ try {
252
+ const controller = new AbortController();
253
+ const timer = setTimeout(() => controller.abort(), this.timeout);
254
+ const res = await this._fetch(url, {
255
+ method,
256
+ headers,
257
+ body: bodyStr,
258
+ signal: controller.signal,
259
+ });
260
+ clearTimeout(timer);
261
+ const durationMs = Date.now() - start;
262
+ if (res.ok) {
263
+ const body = await res.json();
264
+ if (this.onResponse) {
265
+ const correlationId = (body && typeof body === 'object' && 'correlationId' in body)
266
+ ? body.correlationId
267
+ : undefined;
268
+ await this.onResponse({
269
+ status: res.status,
270
+ headers: Object.fromEntries(res.headers.entries()),
271
+ body,
272
+ durationMs,
273
+ correlationId,
274
+ });
275
+ }
276
+ if (this.debug) {
277
+ console.log(`[fast-sdk] ${method} ${url} -> ${res.status} (${durationMs}ms)`);
278
+ }
279
+ return body;
280
+ }
281
+ // Non-2xx response
282
+ const errBody = await res.json().catch(() => ({
283
+ error: `http_${res.status}`,
284
+ message: res.statusText,
285
+ correlationId: '',
286
+ }));
287
+ // Rate limit: respect Retry-After header
288
+ const retryAfter = res.headers.get('Retry-After');
289
+ const rateLimitReset = retryAfter ? parseInt(retryAfter, 10) * 1000 : undefined;
290
+ const error = new FastApiError(res.status, errBody, rateLimitReset);
291
+ if (this.onResponse) {
292
+ await this.onResponse({
293
+ status: res.status,
294
+ headers: Object.fromEntries(res.headers.entries()),
295
+ body: errBody,
296
+ durationMs,
297
+ correlationId: errBody.correlationId,
298
+ });
299
+ }
300
+ // Should we retry?
301
+ if (this.retryConfig && attempt < maxAttempts && this.retryConfig.retryableStatuses.includes(res.status)) {
302
+ const delay = this.calculateDelay(attempt, rateLimitReset);
303
+ if (this.debug) {
304
+ console.log(`[fast-sdk] Retrying (${attempt}/${this.retryConfig.maxRetries}) after ${delay}ms...`);
305
+ }
306
+ await sleep(delay);
307
+ lastError = error;
308
+ continue;
309
+ }
310
+ throw error;
311
+ }
312
+ catch (err) {
313
+ if (err instanceof FastApiError)
314
+ throw err;
315
+ if (err instanceof Error && err.name === 'AbortError') {
316
+ const timeoutErr = new FastTimeoutError(this.timeout);
317
+ if (this.retryConfig && attempt < maxAttempts) {
318
+ const delay = this.calculateDelay(attempt);
319
+ if (this.debug) {
320
+ console.log(`[fast-sdk] Timeout, retrying (${attempt}/${this.retryConfig.maxRetries}) after ${delay}ms...`);
321
+ }
322
+ await sleep(delay);
323
+ lastError = timeoutErr;
324
+ continue;
325
+ }
326
+ throw timeoutErr;
327
+ }
328
+ // Network error
329
+ const netErr = new FastNetworkError(err instanceof Error ? err : new Error(String(err)));
330
+ if (this.retryConfig && attempt < maxAttempts) {
331
+ const delay = this.calculateDelay(attempt);
332
+ if (this.debug) {
333
+ console.log(`[fast-sdk] Network error, retrying (${attempt}/${this.retryConfig.maxRetries}) after ${delay}ms...`);
334
+ }
335
+ await sleep(delay);
336
+ lastError = netErr;
337
+ continue;
338
+ }
339
+ throw netErr;
340
+ }
341
+ }
342
+ // Should not reach here, but just in case
343
+ throw lastError || new Error('Request failed after all retry attempts');
344
+ }
345
+ calculateDelay(attempt, rateLimitReset) {
346
+ if (rateLimitReset && rateLimitReset > 0) {
347
+ return Math.min(rateLimitReset, this.retryConfig.maxDelay);
348
+ }
349
+ // Exponential backoff with jitter
350
+ const base = this.retryConfig.initialDelay * Math.pow(2, attempt - 1);
351
+ const jitter = base * 0.2 * Math.random();
352
+ return Math.min(base + jitter, this.retryConfig.maxDelay);
353
+ }
354
+ }
355
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAUH,OAAO,EACL,aAAa,EACb,OAAO,EACP,QAAQ,EACR,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,SAAS,GACV,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,gBAAgB,GAAG,8BAA8B,CAAC;AACxD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,UAAU,GAAG,kBAAkB,WAAW,SAAS,OAAO,UAAU,KAAK,WAAW,IAAI,SAAS,IAAI,UAAU,CAAC,CAAC,CAAE,UAAkB,CAAC,OAAO,EAAE,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AAExL,MAAM,aAAa,GAAgB;IACjC,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,GAAG;IACjB,QAAQ,EAAE,MAAM;IAChB,iBAAiB,EAAE,CA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AAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,MAAM,EAAE,IAAI,CAAC,WAAY,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fundedfast/sdk
3
+ *
4
+ * Official TypeScript SDK for the FAST platform.
5
+ * Zero dependencies. Works in Node.js 18+, Deno, Bun, and edge runtimes.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { FastClient } from '@fundedfast/sdk';
10
+ *
11
+ * const fast = new FastClient({ apiKey: process.env.FAST_API_KEY! });
12
+ *
13
+ * // Validate a bet
14
+ * const result = await fast.bets.validate({
15
+ * userId: 'player-42',
16
+ * externalBetId: 'BET-001',
17
+ * stakeAmount: 5.00,
18
+ * odds: 2.10,
19
+ * status: 'placed',
20
+ * });
21
+ * ```
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+ export { FastClient, FastApiError, FastTimeoutError, FastNetworkError } from './client.js';
26
+ export type { FastClientConfig, FastError, RetryConfig, RequestHook, ResponseHook, ChallengeStatus, FailureReason, BetStatus, ValidationStatus, FundedAccountStatus, WebhookDeliveryStatus, RejectionCode, IntegrationMode, WebhookEventType, RewardType, RewardApplyMode, LeaderboardPeriod, PurchaseRequest, BetEvent, WithdrawRequest, Challenge, ChallengeTier, ChallengeTierFull, TierTerms, ValidationResult, BetIngestResult, BatchBetResult, Ruleset, UserProgress, ChallengeProgress, ChallengePassedProgress, FundedAccountProgress, NoProgress, WithdrawableInfo, WithdrawalResult, ReconciliationData, SseToken, WebhookPayload, Achievement, UserAchievements, Reward, UserRewards, RewardClaimResult, LeaderboardEntry, TimelineEvent, WithdrawalEventResult, SandboxResetResult, SandboxUserResetResult, AdminBetEvent, BetSettleRequest, BulkSettleRequest, BulkSettleResult, WebhookDelivery, AuditEntry, TenantSettings, AdminOverview, BonusOffer, BonusStats, MissionDef, TournamentDef, TournamentLeaderboardEntry, LoyaltyConfig, LoyaltyTier, LoyaltyStats, WebhookEchoEntry, AdapterMapping, ReconciliationFlag, RewardRule, SelfExclusionRecord, } from './types.js';
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE3F,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EAGZ,eAAe,EACf,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,iBAAiB,EAGjB,eAAe,EACf,QAAQ,EACR,eAAe,EAGf,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,EACR,cAAc,EAGd,WAAW,EACX,gBAAgB,EAChB,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EAGtB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,cAAc,EACd,aAAa,EACb,UAAU,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,0BAA0B,EAC1B,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @fundedfast/sdk
3
+ *
4
+ * Official TypeScript SDK for the FAST platform.
5
+ * Zero dependencies. Works in Node.js 18+, Deno, Bun, and edge runtimes.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { FastClient } from '@fundedfast/sdk';
10
+ *
11
+ * const fast = new FastClient({ apiKey: process.env.FAST_API_KEY! });
12
+ *
13
+ * // Validate a bet
14
+ * const result = await fast.bets.validate({
15
+ * userId: 'player-42',
16
+ * externalBetId: 'BET-001',
17
+ * stakeAmount: 5.00,
18
+ * odds: 2.10,
19
+ * status: 'placed',
20
+ * });
21
+ * ```
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+ export { FastClient, FastApiError, FastTimeoutError, FastNetworkError } from './client.js';
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}