livepasses 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,677 @@
1
+ /**
2
+ * Standard API response envelope.
3
+ * All Livepasses API endpoints return this structure.
4
+ */
5
+ interface ApiResponse<T> {
6
+ success: boolean;
7
+ data?: T;
8
+ error?: ApiError;
9
+ message?: string;
10
+ meta?: ResponseMetadata;
11
+ }
12
+ /**
13
+ * Paginated API response envelope.
14
+ */
15
+ interface ApiPagedResponse<T> {
16
+ success: boolean;
17
+ items: T[];
18
+ pagination: PaginationMetadata;
19
+ error?: ApiError;
20
+ message?: string;
21
+ meta?: ResponseMetadata;
22
+ }
23
+ interface PaginationMetadata {
24
+ currentPage: number;
25
+ pageSize: number;
26
+ totalPages: number;
27
+ totalItems: number;
28
+ }
29
+ interface ResponseMetadata {
30
+ traceId?: string;
31
+ processingTimeMs?: number;
32
+ timestamp?: string;
33
+ }
34
+ interface ApiError {
35
+ message: string;
36
+ code: string;
37
+ details?: string;
38
+ timestamp?: string;
39
+ traceId?: string;
40
+ }
41
+ /**
42
+ * Base parameters for paginated list queries.
43
+ */
44
+ interface PagedParams {
45
+ page?: number;
46
+ pageSize?: number;
47
+ searchTerm?: string;
48
+ sortBy?: string;
49
+ sortDescending?: boolean;
50
+ }
51
+ /**
52
+ * All API error codes returned by the Livepasses API.
53
+ * Mirrors ApiErrorCodes.cs 1:1.
54
+ */
55
+ declare const ApiErrorCodes: {
56
+ readonly GENERAL_ERROR: "GENERAL_ERROR";
57
+ readonly INTERNAL_SERVER_ERROR: "INTERNAL_SERVER_ERROR";
58
+ readonly SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE";
59
+ readonly UNAUTHORIZED: "UNAUTHORIZED";
60
+ readonly FORBIDDEN: "FORBIDDEN";
61
+ readonly INVALID_API_KEY: "INVALID_API_KEY";
62
+ readonly API_KEY_EXPIRED: "API_KEY_EXPIRED";
63
+ readonly API_KEY_REVOKED: "API_KEY_REVOKED";
64
+ readonly INSUFFICIENT_PERMISSIONS: "INSUFFICIENT_PERMISSIONS";
65
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
66
+ readonly REQUIRED_FIELD_MISSING: "REQUIRED_FIELD_MISSING";
67
+ readonly INVALID_FIELD_VALUE: "INVALID_FIELD_VALUE";
68
+ readonly INVALID_FIELD_FORMAT: "INVALID_FIELD_FORMAT";
69
+ readonly FIELD_TOO_LONG: "FIELD_TOO_LONG";
70
+ readonly FIELD_TOO_SHORT: "FIELD_TOO_SHORT";
71
+ readonly NOT_FOUND: "NOT_FOUND";
72
+ readonly RESOURCE_EXISTS: "RESOURCE_EXISTS";
73
+ readonly RESOURCE_LOCKED: "RESOURCE_LOCKED";
74
+ readonly RESOURCE_EXPIRED: "RESOURCE_EXPIRED";
75
+ readonly BUSINESS_RULE_VIOLATION: "BUSINESS_RULE_VIOLATION";
76
+ readonly INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS";
77
+ readonly QUOTA_EXCEEDED: "QUOTA_EXCEEDED";
78
+ readonly OPERATION_NOT_ALLOWED: "OPERATION_NOT_ALLOWED";
79
+ readonly SUBSCRIPTION_REQUIRED: "SUBSCRIPTION_REQUIRED";
80
+ readonly FEATURE_NOT_AVAILABLE: "FEATURE_NOT_AVAILABLE";
81
+ readonly RATE_LIMIT_EXCEEDED: "RATE_LIMIT_EXCEEDED";
82
+ readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
83
+ readonly API_QUOTA_EXCEEDED: "API_QUOTA_EXCEEDED";
84
+ readonly TENANT_NOT_FOUND: "TENANT_NOT_FOUND";
85
+ readonly PARTNERSHIP_NOT_FOUND: "PARTNERSHIP_NOT_FOUND";
86
+ readonly PARTNERSHIP_INACTIVE: "PARTNERSHIP_INACTIVE";
87
+ readonly TENANT_SUSPENDED: "TENANT_SUSPENDED";
88
+ readonly PARTNERSHIP_TIER_LIMIT_REACHED: "PARTNERSHIP_TIER_LIMIT_REACHED";
89
+ readonly TEMPLATE_NOT_FOUND: "TEMPLATE_NOT_FOUND";
90
+ readonly PASS_NOT_FOUND: "PASS_NOT_FOUND";
91
+ readonly PASS_EXPIRED: "PASS_EXPIRED";
92
+ readonly PASS_ALREADY_USED: "PASS_ALREADY_USED";
93
+ readonly INVALID_PASS_FORMAT: "INVALID_PASS_FORMAT";
94
+ readonly TEMPLATE_INACTIVE: "TEMPLATE_INACTIVE";
95
+ readonly EXTERNAL_SERVICE_ERROR: "EXTERNAL_SERVICE_ERROR";
96
+ readonly PAYMENT_SERVICE_ERROR: "PAYMENT_SERVICE_ERROR";
97
+ readonly EMAIL_SERVICE_ERROR: "EMAIL_SERVICE_ERROR";
98
+ readonly SMS_SERVICE_ERROR: "SMS_SERVICE_ERROR";
99
+ readonly APPLE_WALLET_ERROR: "APPLE_WALLET_ERROR";
100
+ readonly GOOGLE_WALLET_ERROR: "GOOGLE_WALLET_ERROR";
101
+ };
102
+ type ApiErrorCode = (typeof ApiErrorCodes)[keyof typeof ApiErrorCodes];
103
+
104
+ interface HttpClientConfig {
105
+ apiKey: string;
106
+ baseUrl: string;
107
+ timeout: number;
108
+ maxRetries: number;
109
+ }
110
+ /**
111
+ * Internal HTTP client that wraps native fetch with:
112
+ * - API key injection
113
+ * - ApiResponse<T> envelope unwrapping
114
+ * - Typed error mapping
115
+ * - Automatic retry with exponential backoff for 429 and 5xx
116
+ */
117
+ declare class HttpClient {
118
+ private readonly config;
119
+ constructor(config: HttpClientConfig);
120
+ get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
121
+ post<T>(path: string, body?: unknown): Promise<T>;
122
+ put<T>(path: string, body?: unknown): Promise<T>;
123
+ delete<T>(path: string): Promise<T>;
124
+ /**
125
+ * Like get() but returns the full paginated response instead of unwrapping.
126
+ */
127
+ getPaged<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<ApiPagedResponse<T>>;
128
+ private request;
129
+ private requestPaged;
130
+ private fetchWithRetry;
131
+ private buildUrl;
132
+ }
133
+
134
+ /**
135
+ * Pass type definitions mirroring the Livepasses API DTOs.
136
+ */
137
+ /** Parameters for generating passes via POST /api/passes/generate */
138
+ interface GeneratePassesParams {
139
+ /** Template ID to generate passes from */
140
+ templateId: string;
141
+ /** Business context for pass generation (template-type specific) */
142
+ businessContext?: BusinessContext;
143
+ /** Pass recipients with business data */
144
+ passes: PassRecipient[];
145
+ /** Generation options */
146
+ options?: PassGenerationOptions;
147
+ }
148
+ /** Business context for pass generation - contains instance-specific data */
149
+ interface BusinessContext {
150
+ event?: EventContext;
151
+ loyalty?: LoyaltyContext;
152
+ coupon?: CouponContext;
153
+ }
154
+ interface EventContext {
155
+ eventName?: string;
156
+ eventDate?: string;
157
+ doorsOpen?: string;
158
+ specialAnnouncement?: string;
159
+ }
160
+ interface LoyaltyContext {
161
+ programUpdate?: string;
162
+ seasonalMessage?: string;
163
+ }
164
+ interface CouponContext {
165
+ campaignName?: string;
166
+ specialMessage?: string;
167
+ promotionStartDate?: string;
168
+ promotionEndDate?: string;
169
+ }
170
+ /** A single pass recipient */
171
+ interface PassRecipient {
172
+ customer: CustomerInfo;
173
+ businessData: BusinessData;
174
+ personalizations?: PersonalizationData;
175
+ }
176
+ interface CustomerInfo {
177
+ email?: string;
178
+ firstName: string;
179
+ lastName: string;
180
+ phone?: string;
181
+ preferredLanguage?: string;
182
+ }
183
+ /** Business data that adapts based on template type */
184
+ interface BusinessData {
185
+ sectionInfo?: string;
186
+ rowInfo?: string;
187
+ seatNumber?: string;
188
+ gateInfo?: string;
189
+ confirmationCode?: string;
190
+ ticketType?: string;
191
+ price?: number;
192
+ currency?: string;
193
+ membershipNumber?: string;
194
+ currentPoints?: number;
195
+ memberTier?: string;
196
+ lifetimePoints?: number;
197
+ accountBalance?: number;
198
+ memberSince?: string;
199
+ favoriteStore?: string;
200
+ promoCode?: string;
201
+ campaignId?: string;
202
+ customerSegment?: string;
203
+ maxUsageCount?: number;
204
+ sourceChannel?: string;
205
+ }
206
+ interface PersonalizationData {
207
+ dietaryRestrictions?: string;
208
+ accessibilityNeeds?: string;
209
+ customFields?: Record<string, string>;
210
+ }
211
+ interface PassGenerationOptions {
212
+ /** Delivery method: auto | email | sms | whatsapp | webhook | return_urls */
213
+ deliveryMethod?: string;
214
+ /** Generate for all platforms (Apple + Google). Defaults to true. */
215
+ generateForAllPlatforms?: boolean;
216
+ }
217
+ /** Result from pass generation */
218
+ interface PassGenerationResult {
219
+ batchId: string;
220
+ templateId: string;
221
+ generatedAt: string;
222
+ totalPasses: number;
223
+ /** When true, poll getBatchStatus() for results */
224
+ isAsyncProcessing: boolean;
225
+ batchOperation?: BatchOperationInfo;
226
+ /** Populated for sync generation, empty for async */
227
+ passes: GeneratedPass[];
228
+ delivery?: PassDeliveryResult;
229
+ businessMetrics?: BusinessMetrics;
230
+ }
231
+ interface BatchOperationInfo {
232
+ id: string;
233
+ status: string;
234
+ totalRecipients: number;
235
+ passesGenerated: number;
236
+ generationFailures: number;
237
+ progressPercentage: number;
238
+ estimatedCompletion?: string;
239
+ statusPollUrl: string;
240
+ }
241
+ interface GeneratedPass {
242
+ id: string;
243
+ customerEmail?: string;
244
+ confirmationCode?: string;
245
+ platforms: PassPlatforms;
246
+ businessData: UnifiedBusinessData;
247
+ qrCode?: string;
248
+ status: string;
249
+ analytics?: AnalyticsInfo;
250
+ }
251
+ interface PassPlatforms {
252
+ apple: PassPlatform;
253
+ google: PassPlatform;
254
+ }
255
+ interface PassPlatform {
256
+ available: boolean;
257
+ addToWalletUrl?: string;
258
+ passUrl?: string;
259
+ jwtToken?: string;
260
+ features: string[];
261
+ }
262
+ interface UnifiedBusinessData {
263
+ section?: string;
264
+ row?: string;
265
+ seat?: string;
266
+ gate?: string;
267
+ ticketType?: string;
268
+ formattedPrice?: string;
269
+ membershipNumber?: string;
270
+ currentPoints?: number;
271
+ memberTier?: string;
272
+ formattedBalance?: string;
273
+ promoCode?: string;
274
+ discountDescription?: string;
275
+ validityDescription?: string;
276
+ }
277
+ interface PassDeliveryResult {
278
+ method: string;
279
+ status: string;
280
+ sentAt: string;
281
+ details: DeliveryDetail[];
282
+ }
283
+ interface DeliveryDetail {
284
+ recipient?: string;
285
+ status: string;
286
+ }
287
+ interface BusinessMetrics {
288
+ totalRevenue?: number;
289
+ averageTicketPrice?: number;
290
+ seatDistribution?: Record<string, number>;
291
+ tierDistribution?: Record<string, number>;
292
+ revenueByCategory?: Record<string, number>;
293
+ }
294
+ interface AnalyticsInfo {
295
+ trackingId: string;
296
+ engagementUrl: string;
297
+ }
298
+ interface PassLookupResult {
299
+ passId: string;
300
+ passNumber: string;
301
+ templateId: string;
302
+ templateName: string;
303
+ templateType: string;
304
+ holderName?: string;
305
+ holderEmail?: string;
306
+ status: string;
307
+ isValid: boolean;
308
+ canBeRedeemed: boolean;
309
+ isExpired: boolean;
310
+ validFrom?: string;
311
+ validUntil?: string;
312
+ redeemedAt?: string;
313
+ generatedAt: string;
314
+ }
315
+ interface PassValidationResult {
316
+ passId: string;
317
+ passNumber: string;
318
+ status: string;
319
+ canBeRedeemed: boolean;
320
+ isExpired: boolean;
321
+ validationMessage: string;
322
+ templateType: string;
323
+ holderName?: string;
324
+ holderEmail?: string;
325
+ validFrom?: string;
326
+ validUntil?: string;
327
+ verificationMethods: string[];
328
+ }
329
+ interface PassRedemptionResult {
330
+ passId: string;
331
+ passNumber: string;
332
+ redeemedAt: string;
333
+ redemptionMethod: string;
334
+ previousStatus: string;
335
+ newStatus: string;
336
+ alreadyRedeemed: boolean;
337
+ }
338
+ interface RedemptionLocation {
339
+ name?: string;
340
+ latitude?: number;
341
+ longitude?: number;
342
+ }
343
+ interface RedeemPassParams {
344
+ location?: RedemptionLocation;
345
+ notes?: string;
346
+ }
347
+ interface CheckInParams {
348
+ location?: RedemptionLocation;
349
+ notes?: string;
350
+ }
351
+ interface RedeemCouponParams {
352
+ location?: RedemptionLocation;
353
+ notes?: string;
354
+ }
355
+ interface LoyaltyTransactionParams {
356
+ /** Transaction type: earn | spend */
357
+ transactionType: 'earn' | 'spend';
358
+ points: number;
359
+ description?: string;
360
+ }
361
+ interface UpdatePassParams {
362
+ businessData?: Partial<BusinessData>;
363
+ businessContext?: BusinessContext;
364
+ }
365
+ interface BulkUpdatePassesParams {
366
+ passIds: string[];
367
+ businessData?: Partial<BusinessData>;
368
+ businessContext?: BusinessContext;
369
+ }
370
+ interface BatchStatusResult {
371
+ id: string;
372
+ status: string;
373
+ totalRecipients: number;
374
+ passesGenerated: number;
375
+ passesDelivered: number;
376
+ generationFailures: number;
377
+ deliveryFailures: number;
378
+ progressPercentage: number;
379
+ startedAt?: string;
380
+ completedAt?: string;
381
+ estimatedCompletion?: string;
382
+ errorMessage?: string;
383
+ isCompleted: boolean;
384
+ isActive: boolean;
385
+ statistics?: BatchStatistics;
386
+ generatedPasses?: GeneratedPassSummary[];
387
+ }
388
+ interface BatchStatistics {
389
+ averageGenerationTimeSeconds: number;
390
+ generationSuccessRate: number;
391
+ deliverySuccessRate: number;
392
+ mostCommonError?: string;
393
+ totalDuration?: string;
394
+ }
395
+ interface GeneratedPassSummary {
396
+ id: string;
397
+ passNumber: string;
398
+ holderEmail?: string;
399
+ holderName?: string;
400
+ status: string;
401
+ hasApplePass: boolean;
402
+ hasGooglePass: boolean;
403
+ generatedAt: string;
404
+ }
405
+ interface ListPassesParams {
406
+ templateId?: string;
407
+ status?: string;
408
+ platform?: string;
409
+ page?: number;
410
+ pageSize?: number;
411
+ searchTerm?: string;
412
+ sortBy?: string;
413
+ sortDescending?: boolean;
414
+ }
415
+ interface GlobalPassDto {
416
+ id: string;
417
+ serialNumber: string;
418
+ platform: string;
419
+ status: string;
420
+ generatedAt: string;
421
+ redeemedAt?: string;
422
+ validUntil?: string;
423
+ holderEmail?: string;
424
+ templateId: string;
425
+ templateName: string;
426
+ templateType: string;
427
+ }
428
+ interface LookupPassParams {
429
+ passId?: string;
430
+ passNumber?: string;
431
+ }
432
+ interface GenerateAndWaitOptions {
433
+ /** Polling interval in milliseconds. Default: 2000 */
434
+ pollInterval?: number;
435
+ /** Maximum number of poll attempts. Default: 150 (5 minutes at 2s interval) */
436
+ maxAttempts?: number;
437
+ /** Callback invoked on each poll with current batch status */
438
+ onProgress?: (status: BatchStatusResult) => void;
439
+ }
440
+
441
+ declare class PassesResource {
442
+ private readonly http;
443
+ constructor(http: HttpClient);
444
+ /**
445
+ * Generate passes for one or more recipients.
446
+ * For a single recipient, the pass is returned synchronously.
447
+ * For multiple recipients, returns immediately with a batchId — poll with `getBatchStatus()`.
448
+ *
449
+ * @see generateAndWait for an auto-polling helper
450
+ */
451
+ generate(params: GeneratePassesParams): Promise<PassGenerationResult>;
452
+ /**
453
+ * Generate passes and automatically poll until the batch is complete.
454
+ * This is the recommended method for most use cases.
455
+ *
456
+ * For sync generation (1 recipient), returns immediately.
457
+ * For async batches (>1 recipient), polls `getBatchStatus()` until done.
458
+ */
459
+ generateAndWait(params: GeneratePassesParams, options?: GenerateAndWaitOptions): Promise<PassGenerationResult>;
460
+ /**
461
+ * List passes (paginated).
462
+ */
463
+ list(params?: ListPassesParams): Promise<ApiPagedResponse<GlobalPassDto>>;
464
+ /**
465
+ * Auto-paginate through all passes matching the given filters.
466
+ *
467
+ * @example
468
+ * ```ts
469
+ * for await (const pass of livepasses.passes.listAutoPaginate({ templateId: '...' })) {
470
+ * console.log(pass.id);
471
+ * }
472
+ * ```
473
+ */
474
+ listAutoPaginate(params?: Omit<ListPassesParams, 'page'>): AsyncGenerator<GlobalPassDto, void, undefined>;
475
+ /**
476
+ * Look up a pass by ID or pass number.
477
+ */
478
+ lookup(params: LookupPassParams): Promise<PassLookupResult>;
479
+ /**
480
+ * Validate a pass before redemption.
481
+ */
482
+ validate(passId: string): Promise<PassValidationResult>;
483
+ /**
484
+ * Update a pass's business data.
485
+ */
486
+ update(passId: string, params: UpdatePassParams): Promise<void>;
487
+ /**
488
+ * Bulk update multiple passes.
489
+ */
490
+ bulkUpdate(params: BulkUpdatePassesParams): Promise<void>;
491
+ /**
492
+ * Redeem a pass (generic redemption).
493
+ */
494
+ redeem(passId: string, params?: RedeemPassParams): Promise<PassRedemptionResult>;
495
+ /**
496
+ * Check in an event pass.
497
+ */
498
+ checkIn(passId: string, params?: CheckInParams): Promise<PassRedemptionResult>;
499
+ /**
500
+ * Redeem a coupon pass.
501
+ */
502
+ redeemCoupon(passId: string, params?: RedeemCouponParams): Promise<PassRedemptionResult>;
503
+ /**
504
+ * Earn or spend loyalty points.
505
+ */
506
+ loyaltyTransact(passId: string, params: LoyaltyTransactionParams): Promise<PassRedemptionResult>;
507
+ /**
508
+ * Get the status of a batch pass generation operation.
509
+ */
510
+ getBatchStatus(batchId: string): Promise<BatchStatusResult>;
511
+ }
512
+
513
+ interface TemplateListItem {
514
+ id: string;
515
+ name: string;
516
+ description?: string;
517
+ type: string;
518
+ status: string;
519
+ passCount: number;
520
+ createdAt: string;
521
+ updatedAt?: string;
522
+ }
523
+ interface TemplateDetail extends TemplateListItem {
524
+ businessFeatures?: Record<string, unknown>;
525
+ platformSupport?: Record<string, unknown>;
526
+ mediaConfiguration?: Record<string, unknown>;
527
+ }
528
+ interface ListTemplatesParams extends PagedParams {
529
+ type?: string;
530
+ status?: string;
531
+ }
532
+ interface CreateTemplateParams {
533
+ name: string;
534
+ description?: string;
535
+ businessFeatures: Record<string, unknown>;
536
+ requiredMedia?: string[];
537
+ }
538
+ interface UpdateTemplateParams {
539
+ name?: string;
540
+ description?: string;
541
+ businessFeatures?: Record<string, unknown>;
542
+ }
543
+
544
+ declare class TemplatesResource {
545
+ private readonly http;
546
+ constructor(http: HttpClient);
547
+ /**
548
+ * List templates (paginated).
549
+ */
550
+ list(params?: ListTemplatesParams): Promise<ApiPagedResponse<TemplateListItem>>;
551
+ /**
552
+ * Get a single template by ID.
553
+ */
554
+ get(templateId: string): Promise<TemplateDetail>;
555
+ /**
556
+ * Create a new template.
557
+ */
558
+ create(params: CreateTemplateParams): Promise<TemplateDetail>;
559
+ /**
560
+ * Update a template.
561
+ */
562
+ update(templateId: string, params: UpdateTemplateParams): Promise<TemplateDetail>;
563
+ /**
564
+ * Activate a template for pass generation.
565
+ */
566
+ activate(templateId: string): Promise<void>;
567
+ /**
568
+ * Deactivate a template.
569
+ */
570
+ deactivate(templateId: string): Promise<void>;
571
+ }
572
+
573
+ interface Webhook {
574
+ id: string;
575
+ url: string;
576
+ events: WebhookEventType[];
577
+ isActive: boolean;
578
+ createdAt: string;
579
+ secret?: string;
580
+ }
581
+ interface CreateWebhookParams {
582
+ url: string;
583
+ events: WebhookEventType[];
584
+ }
585
+ type WebhookEventType = 'pass.generated' | 'pass.redeemed' | 'pass.updated' | 'pass.expired' | 'pass.checked_in' | 'batch.completed' | 'batch.failed';
586
+
587
+ declare class WebhooksResource {
588
+ private readonly http;
589
+ constructor(http: HttpClient);
590
+ /**
591
+ * Create a webhook endpoint.
592
+ */
593
+ create(params: CreateWebhookParams): Promise<Webhook>;
594
+ /**
595
+ * List all registered webhooks.
596
+ */
597
+ list(): Promise<Webhook[]>;
598
+ /**
599
+ * Delete a webhook by ID.
600
+ */
601
+ delete(webhookId: string): Promise<void>;
602
+ }
603
+
604
+ interface LivepassesOptions {
605
+ /** API base URL. Default: https://api.livepasses.com */
606
+ baseUrl?: string;
607
+ /** Request timeout in milliseconds. Default: 30000 */
608
+ timeout?: number;
609
+ /** Maximum number of retries for failed requests. Default: 3 */
610
+ maxRetries?: number;
611
+ }
612
+ /**
613
+ * Livepasses API client.
614
+ *
615
+ * @example
616
+ * ```ts
617
+ * import { Livepasses } from 'livepasses';
618
+ *
619
+ * const client = new Livepasses('lp_api_key_...');
620
+ * const result = await client.passes.generate({
621
+ * templateId: 'template-id',
622
+ * passes: [{
623
+ * customer: { firstName: 'Jane', lastName: 'Doe', email: 'jane@example.com' },
624
+ * businessData: { sectionInfo: 'A', rowInfo: '12', seatNumber: '5' },
625
+ * }],
626
+ * });
627
+ * ```
628
+ */
629
+ declare class Livepasses {
630
+ readonly passes: PassesResource;
631
+ readonly templates: TemplatesResource;
632
+ readonly webhooks: WebhooksResource;
633
+ constructor(apiKey: string, options?: LivepassesOptions);
634
+ }
635
+
636
+ /**
637
+ * Base error class for all Livepasses API errors.
638
+ * Contains the HTTP status code, API error code, and optional details.
639
+ */
640
+ declare class LivepassesError extends Error {
641
+ readonly status: number;
642
+ readonly code: string;
643
+ readonly details?: string;
644
+ constructor(message: string, status: number, code: string, details?: string);
645
+ }
646
+ /** Thrown for 401 responses - invalid or missing API key */
647
+ declare class AuthenticationError extends LivepassesError {
648
+ constructor(message: string, code: string, details?: string);
649
+ }
650
+ /** Thrown for validation errors (400) - invalid input data */
651
+ declare class ValidationError extends LivepassesError {
652
+ constructor(message: string, code: string, details?: string);
653
+ }
654
+ /** Thrown for 403 responses - insufficient permissions */
655
+ declare class ForbiddenError extends LivepassesError {
656
+ constructor(message: string, code: string, details?: string);
657
+ }
658
+ /** Thrown for 404 responses - resource not found */
659
+ declare class NotFoundError extends LivepassesError {
660
+ constructor(message: string, code: string, details?: string);
661
+ }
662
+ /** Thrown for 429 responses - rate limit exceeded */
663
+ declare class RateLimitError extends LivepassesError {
664
+ /** Seconds to wait before retrying, from Retry-After header */
665
+ readonly retryAfter?: number;
666
+ constructor(message: string, code: string, retryAfter?: number, details?: string);
667
+ }
668
+ /** Thrown when subscription quota is exceeded */
669
+ declare class QuotaExceededError extends LivepassesError {
670
+ constructor(message: string, code: string, details?: string);
671
+ }
672
+ /** Thrown for business rule violations */
673
+ declare class BusinessRuleError extends LivepassesError {
674
+ constructor(message: string, code: string, details?: string);
675
+ }
676
+
677
+ export { type AnalyticsInfo, type ApiError, type ApiErrorCode, ApiErrorCodes, type ApiPagedResponse, type ApiResponse, AuthenticationError, type BatchOperationInfo, type BatchStatistics, type BatchStatusResult, type BulkUpdatePassesParams, type BusinessContext, type BusinessData, type BusinessMetrics, BusinessRuleError, type CheckInParams, type CouponContext, type CreateTemplateParams, type CreateWebhookParams, type CustomerInfo, type DeliveryDetail, type EventContext, ForbiddenError, type GenerateAndWaitOptions, type GeneratePassesParams, type GeneratedPass, type GeneratedPassSummary, type GlobalPassDto, type ListPassesParams, type ListTemplatesParams, Livepasses, LivepassesError, type LivepassesOptions, type LookupPassParams, type LoyaltyContext, type LoyaltyTransactionParams, NotFoundError, type PagedParams, type PaginationMetadata, type PassDeliveryResult, type PassGenerationOptions, type PassGenerationResult, type PassLookupResult, type PassPlatform, type PassPlatforms, type PassRecipient, type PassRedemptionResult, type PassValidationResult, type PersonalizationData, QuotaExceededError, RateLimitError, type RedeemCouponParams, type RedeemPassParams, type RedemptionLocation, type ResponseMetadata, type TemplateDetail, type TemplateListItem, type UnifiedBusinessData, type UpdatePassParams, type UpdateTemplateParams, ValidationError, type Webhook, type WebhookEventType, Livepasses as default };