colacloud 1.0.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/LICENSE +21 -0
- package/README.md +340 -0
- package/dist/index.d.mts +580 -0
- package/dist/index.d.ts +580 -0
- package/dist/index.js +671 -0
- package/dist/index.mjs +632 -0
- package/package.json +58 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COLA Cloud API TypeScript Types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for the ColaCloud client
|
|
6
|
+
*/
|
|
7
|
+
interface ColaCloudConfig {
|
|
8
|
+
/** Your COLA Cloud API key */
|
|
9
|
+
apiKey: string;
|
|
10
|
+
/** Base URL for the API (defaults to https://app.colacloud.us/api/v1) */
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
/** Request timeout in milliseconds (defaults to 30000) */
|
|
13
|
+
timeout?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Pagination metadata returned with list endpoints
|
|
17
|
+
*/
|
|
18
|
+
interface Pagination {
|
|
19
|
+
/** Current page number (1-indexed) */
|
|
20
|
+
page: number;
|
|
21
|
+
/** Number of items per page */
|
|
22
|
+
per_page: number;
|
|
23
|
+
/** Total number of items across all pages */
|
|
24
|
+
total: number;
|
|
25
|
+
/** Total number of pages */
|
|
26
|
+
pages: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Response wrapper for paginated list endpoints
|
|
30
|
+
*/
|
|
31
|
+
interface PaginatedResponse<T> {
|
|
32
|
+
/** Array of items for the current page */
|
|
33
|
+
data: T[];
|
|
34
|
+
/** Pagination metadata */
|
|
35
|
+
pagination: Pagination;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Response wrapper for single item endpoints
|
|
39
|
+
*/
|
|
40
|
+
interface SingleResponse<T> {
|
|
41
|
+
/** The requested item */
|
|
42
|
+
data: T;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Rate limit information from response headers
|
|
46
|
+
*/
|
|
47
|
+
interface RateLimitInfo {
|
|
48
|
+
/** Maximum requests allowed per minute */
|
|
49
|
+
limit: number;
|
|
50
|
+
/** Remaining requests in the current window */
|
|
51
|
+
remaining: number;
|
|
52
|
+
/** Unix timestamp when the rate limit resets */
|
|
53
|
+
reset: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Extended response that includes rate limit information
|
|
57
|
+
*/
|
|
58
|
+
interface ResponseWithRateLimit<T> {
|
|
59
|
+
/** The response data */
|
|
60
|
+
data: T;
|
|
61
|
+
/** Rate limit information from headers */
|
|
62
|
+
rateLimit: RateLimitInfo | null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Summary information about a COLA (Certificate of Label Approval)
|
|
66
|
+
* Returned in list/search results
|
|
67
|
+
*/
|
|
68
|
+
interface ColaSummary {
|
|
69
|
+
/** Unique TTB identifier for this COLA */
|
|
70
|
+
ttb_id: string;
|
|
71
|
+
/** Brand name on the label */
|
|
72
|
+
brand_name: string | null;
|
|
73
|
+
/** Specific product name */
|
|
74
|
+
product_name: string | null;
|
|
75
|
+
/** Type of product (e.g., "DISTILLED SPIRITS", "WINE", "MALT BEVERAGES") */
|
|
76
|
+
product_type: string | null;
|
|
77
|
+
/** Product class name */
|
|
78
|
+
class_name: string | null;
|
|
79
|
+
/** Origin/country of the product */
|
|
80
|
+
origin_name: string | null;
|
|
81
|
+
/** Permit number of the applicant */
|
|
82
|
+
permit_number: string | null;
|
|
83
|
+
/** Date the COLA was approved */
|
|
84
|
+
approval_date: string | null;
|
|
85
|
+
/** Alcohol by volume percentage */
|
|
86
|
+
abv: number | null;
|
|
87
|
+
/** Container volume */
|
|
88
|
+
volume: string | null;
|
|
89
|
+
/** Number of images associated with this COLA */
|
|
90
|
+
image_count: number;
|
|
91
|
+
/** URL to the main/primary image */
|
|
92
|
+
main_image_url: string | null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Image associated with a COLA
|
|
96
|
+
*/
|
|
97
|
+
interface ColaImage {
|
|
98
|
+
/** Unique identifier for this image */
|
|
99
|
+
image_id: string;
|
|
100
|
+
/** URL to the image */
|
|
101
|
+
url: string;
|
|
102
|
+
/** Type of image (e.g., "front", "back") */
|
|
103
|
+
image_type: string | null;
|
|
104
|
+
/** Image width in pixels */
|
|
105
|
+
width: number | null;
|
|
106
|
+
/** Image height in pixels */
|
|
107
|
+
height: number | null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Barcode found on a COLA label
|
|
111
|
+
*/
|
|
112
|
+
interface ColaBarcode {
|
|
113
|
+
/** The barcode value/number */
|
|
114
|
+
barcode_value: string;
|
|
115
|
+
/** Type of barcode (e.g., "UPC-A", "EAN-13") */
|
|
116
|
+
barcode_type: string | null;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Full details for a COLA including images and barcodes
|
|
120
|
+
*/
|
|
121
|
+
interface ColaDetail extends ColaSummary {
|
|
122
|
+
/** Images associated with this COLA */
|
|
123
|
+
images: ColaImage[];
|
|
124
|
+
/** Barcodes found on the label */
|
|
125
|
+
barcodes: ColaBarcode[];
|
|
126
|
+
/** LLM-extracted description */
|
|
127
|
+
llm_description: string | null;
|
|
128
|
+
/** LLM-extracted ingredients */
|
|
129
|
+
llm_ingredients: string | null;
|
|
130
|
+
/** LLM-extracted tasting notes */
|
|
131
|
+
llm_tasting_notes: string | null;
|
|
132
|
+
/** LLM-extracted producer/brand information */
|
|
133
|
+
llm_producer: string | null;
|
|
134
|
+
/** Vintage year for wines */
|
|
135
|
+
vintage: number | null;
|
|
136
|
+
/** Grape varietal(s) */
|
|
137
|
+
varietal: string | null;
|
|
138
|
+
/** Wine appellation */
|
|
139
|
+
appellation: string | null;
|
|
140
|
+
/** Beer style */
|
|
141
|
+
beer_style: string | null;
|
|
142
|
+
/** International Bitterness Units */
|
|
143
|
+
ibu: number | null;
|
|
144
|
+
/** Status of the COLA */
|
|
145
|
+
status: string | null;
|
|
146
|
+
/** Date the COLA was submitted */
|
|
147
|
+
submitted_date: string | null;
|
|
148
|
+
/** Serial number */
|
|
149
|
+
serial_number: string | null;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Query parameters for searching/listing COLAs
|
|
153
|
+
*/
|
|
154
|
+
interface ColaListParams {
|
|
155
|
+
/** Search query string */
|
|
156
|
+
q?: string;
|
|
157
|
+
/** Filter by product type */
|
|
158
|
+
productType?: string;
|
|
159
|
+
/** Filter by origin/country */
|
|
160
|
+
origin?: string;
|
|
161
|
+
/** Filter by brand name */
|
|
162
|
+
brandName?: string;
|
|
163
|
+
/** Filter by approval date (from) */
|
|
164
|
+
approvalDateFrom?: string;
|
|
165
|
+
/** Filter by approval date (to) */
|
|
166
|
+
approvalDateTo?: string;
|
|
167
|
+
/** Minimum ABV percentage */
|
|
168
|
+
abvMin?: number;
|
|
169
|
+
/** Maximum ABV percentage */
|
|
170
|
+
abvMax?: number;
|
|
171
|
+
/** Page number (1-indexed) */
|
|
172
|
+
page?: number;
|
|
173
|
+
/** Items per page */
|
|
174
|
+
perPage?: number;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Summary information about a permittee (business/permit holder)
|
|
178
|
+
*/
|
|
179
|
+
interface PermitteeSummary {
|
|
180
|
+
/** Unique permit number */
|
|
181
|
+
permit_number: string;
|
|
182
|
+
/** Company/business name */
|
|
183
|
+
company_name: string | null;
|
|
184
|
+
/** State where the company is located */
|
|
185
|
+
company_state: string | null;
|
|
186
|
+
/** Type of permit */
|
|
187
|
+
permittee_type: string | null;
|
|
188
|
+
/** Whether the permit is currently active */
|
|
189
|
+
is_active: boolean;
|
|
190
|
+
/** Total number of COLAs */
|
|
191
|
+
colas: number;
|
|
192
|
+
/** Number of approved COLAs */
|
|
193
|
+
colas_approved: number;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Full details for a permittee including recent COLAs
|
|
197
|
+
*/
|
|
198
|
+
interface PermitteeDetail extends PermitteeSummary {
|
|
199
|
+
/** Recent COLAs from this permittee */
|
|
200
|
+
recent_colas: ColaSummary[];
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Query parameters for searching/listing permittees
|
|
204
|
+
*/
|
|
205
|
+
interface PermitteeListParams {
|
|
206
|
+
/** Search query string */
|
|
207
|
+
q?: string;
|
|
208
|
+
/** Filter by state */
|
|
209
|
+
state?: string;
|
|
210
|
+
/** Filter by active status */
|
|
211
|
+
isActive?: boolean;
|
|
212
|
+
/** Page number (1-indexed) */
|
|
213
|
+
page?: number;
|
|
214
|
+
/** Items per page */
|
|
215
|
+
perPage?: number;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Result of a barcode lookup
|
|
219
|
+
*/
|
|
220
|
+
interface BarcodeLookupResult {
|
|
221
|
+
/** The barcode value that was searched */
|
|
222
|
+
barcode_value: string;
|
|
223
|
+
/** Type of barcode */
|
|
224
|
+
barcode_type: string | null;
|
|
225
|
+
/** COLAs associated with this barcode */
|
|
226
|
+
colas: ColaSummary[];
|
|
227
|
+
/** Total number of COLAs with this barcode */
|
|
228
|
+
total_colas: number;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* API usage statistics for the current account
|
|
232
|
+
*/
|
|
233
|
+
interface UsageStats {
|
|
234
|
+
/** Account tier (e.g., "free", "pro", "enterprise") */
|
|
235
|
+
tier: string;
|
|
236
|
+
/** Monthly request limit */
|
|
237
|
+
monthly_limit: number;
|
|
238
|
+
/** Current billing period (ISO date string) */
|
|
239
|
+
current_period: string;
|
|
240
|
+
/** Number of requests used this period */
|
|
241
|
+
requests_used: number;
|
|
242
|
+
/** Number of requests remaining this period */
|
|
243
|
+
requests_remaining: number;
|
|
244
|
+
/** Per-minute rate limit */
|
|
245
|
+
per_minute_limit: number;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Error response structure from the API
|
|
249
|
+
*/
|
|
250
|
+
interface ApiErrorResponse {
|
|
251
|
+
/** Error message */
|
|
252
|
+
error: string;
|
|
253
|
+
/** Error code */
|
|
254
|
+
code?: string;
|
|
255
|
+
/** Additional error details */
|
|
256
|
+
details?: Record<string, unknown>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* COLA Cloud SDK Client
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* COLA Cloud API Client
|
|
265
|
+
*
|
|
266
|
+
* The main entry point for interacting with the COLA Cloud API.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```typescript
|
|
270
|
+
* import { ColaCloud } from 'colacloud';
|
|
271
|
+
*
|
|
272
|
+
* const client = new ColaCloud({ apiKey: 'your-api-key' });
|
|
273
|
+
*
|
|
274
|
+
* // Search COLAs
|
|
275
|
+
* const { data, pagination } = await client.colas.list({ q: 'bourbon' });
|
|
276
|
+
*
|
|
277
|
+
* // Get a single COLA
|
|
278
|
+
* const cola = await client.colas.get('12345678');
|
|
279
|
+
*
|
|
280
|
+
* // Iterate all results
|
|
281
|
+
* for await (const cola of client.colas.iterate({ q: 'whiskey' })) {
|
|
282
|
+
* console.log(cola.ttb_id);
|
|
283
|
+
* }
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
declare class ColaCloud {
|
|
287
|
+
private readonly apiKey;
|
|
288
|
+
private readonly baseUrl;
|
|
289
|
+
private readonly timeout;
|
|
290
|
+
/** COLA (Certificate of Label Approval) endpoints */
|
|
291
|
+
readonly colas: ColasResource;
|
|
292
|
+
/** Permittee (business/permit holder) endpoints */
|
|
293
|
+
readonly permittees: PermitteesResource;
|
|
294
|
+
/** Barcode lookup endpoint */
|
|
295
|
+
readonly barcodes: BarcodesResource;
|
|
296
|
+
/** Usage statistics endpoint */
|
|
297
|
+
readonly usage: UsageResource;
|
|
298
|
+
/**
|
|
299
|
+
* Create a new COLA Cloud API client
|
|
300
|
+
* @param config Configuration options
|
|
301
|
+
*/
|
|
302
|
+
constructor(config: ColaCloudConfig);
|
|
303
|
+
/**
|
|
304
|
+
* Make an authenticated request to the API
|
|
305
|
+
* @internal
|
|
306
|
+
*/
|
|
307
|
+
request<T>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, params?: Record<string, unknown>): Promise<ResponseWithRateLimit<T>>;
|
|
308
|
+
/**
|
|
309
|
+
* Handle error responses from the API
|
|
310
|
+
*/
|
|
311
|
+
private handleErrorResponse;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* COLA (Certificate of Label Approval) resource handler
|
|
315
|
+
*/
|
|
316
|
+
declare class ColasResource {
|
|
317
|
+
private readonly client;
|
|
318
|
+
constructor(client: ColaCloud);
|
|
319
|
+
/**
|
|
320
|
+
* List and search COLAs with pagination
|
|
321
|
+
* @param params Search and filter parameters
|
|
322
|
+
* @returns Paginated list of COLA summaries
|
|
323
|
+
*/
|
|
324
|
+
list(params?: ColaListParams): Promise<PaginatedResponse<ColaSummary>>;
|
|
325
|
+
/**
|
|
326
|
+
* List COLAs with rate limit information
|
|
327
|
+
* @param params Search and filter parameters
|
|
328
|
+
* @returns Paginated list with rate limit info
|
|
329
|
+
*/
|
|
330
|
+
listWithRateLimit(params?: ColaListParams): Promise<ResponseWithRateLimit<PaginatedResponse<ColaSummary>>>;
|
|
331
|
+
/**
|
|
332
|
+
* Get a single COLA by TTB ID
|
|
333
|
+
* @param ttbId The unique TTB identifier
|
|
334
|
+
* @returns Full COLA details including images and barcodes
|
|
335
|
+
*/
|
|
336
|
+
get(ttbId: string): Promise<ColaDetail>;
|
|
337
|
+
/**
|
|
338
|
+
* Get a single COLA with rate limit information
|
|
339
|
+
* @param ttbId The unique TTB identifier
|
|
340
|
+
* @returns COLA details with rate limit info
|
|
341
|
+
*/
|
|
342
|
+
getWithRateLimit(ttbId: string): Promise<ResponseWithRateLimit<ColaDetail>>;
|
|
343
|
+
/**
|
|
344
|
+
* Create an async iterator that automatically pages through all results
|
|
345
|
+
* @param params Search and filter parameters (page is ignored)
|
|
346
|
+
* @returns Async iterable that yields individual COLA summaries
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```typescript
|
|
350
|
+
* for await (const cola of client.colas.iterate({ q: 'bourbon' })) {
|
|
351
|
+
* console.log(cola.ttb_id, cola.brand_name);
|
|
352
|
+
* }
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
iterate(params?: Omit<ColaListParams, 'page'>): AsyncIterable<ColaSummary>;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Permittee (business/permit holder) resource handler
|
|
359
|
+
*/
|
|
360
|
+
declare class PermitteesResource {
|
|
361
|
+
private readonly client;
|
|
362
|
+
constructor(client: ColaCloud);
|
|
363
|
+
/**
|
|
364
|
+
* List and search permittees with pagination
|
|
365
|
+
* @param params Search and filter parameters
|
|
366
|
+
* @returns Paginated list of permittee summaries
|
|
367
|
+
*/
|
|
368
|
+
list(params?: PermitteeListParams): Promise<PaginatedResponse<PermitteeSummary>>;
|
|
369
|
+
/**
|
|
370
|
+
* List permittees with rate limit information
|
|
371
|
+
* @param params Search and filter parameters
|
|
372
|
+
* @returns Paginated list with rate limit info
|
|
373
|
+
*/
|
|
374
|
+
listWithRateLimit(params?: PermitteeListParams): Promise<ResponseWithRateLimit<PaginatedResponse<PermitteeSummary>>>;
|
|
375
|
+
/**
|
|
376
|
+
* Get a single permittee by permit number
|
|
377
|
+
* @param permitNumber The unique permit number
|
|
378
|
+
* @returns Full permittee details including recent COLAs
|
|
379
|
+
*/
|
|
380
|
+
get(permitNumber: string): Promise<PermitteeDetail>;
|
|
381
|
+
/**
|
|
382
|
+
* Get a single permittee with rate limit information
|
|
383
|
+
* @param permitNumber The unique permit number
|
|
384
|
+
* @returns Permittee details with rate limit info
|
|
385
|
+
*/
|
|
386
|
+
getWithRateLimit(permitNumber: string): Promise<ResponseWithRateLimit<PermitteeDetail>>;
|
|
387
|
+
/**
|
|
388
|
+
* Create an async iterator that automatically pages through all results
|
|
389
|
+
* @param params Search and filter parameters (page is ignored)
|
|
390
|
+
* @returns Async iterable that yields individual permittee summaries
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```typescript
|
|
394
|
+
* for await (const permittee of client.permittees.iterate({ state: 'CA' })) {
|
|
395
|
+
* console.log(permittee.company_name);
|
|
396
|
+
* }
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
399
|
+
iterate(params?: Omit<PermitteeListParams, 'page'>): AsyncIterable<PermitteeSummary>;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Barcode lookup resource handler
|
|
403
|
+
*/
|
|
404
|
+
declare class BarcodesResource {
|
|
405
|
+
private readonly client;
|
|
406
|
+
constructor(client: ColaCloud);
|
|
407
|
+
/**
|
|
408
|
+
* Look up COLAs by barcode value
|
|
409
|
+
* @param barcodeValue The barcode to search for (UPC, EAN, etc.)
|
|
410
|
+
* @returns Barcode information and associated COLAs
|
|
411
|
+
*/
|
|
412
|
+
lookup(barcodeValue: string): Promise<BarcodeLookupResult>;
|
|
413
|
+
/**
|
|
414
|
+
* Look up barcode with rate limit information
|
|
415
|
+
* @param barcodeValue The barcode to search for
|
|
416
|
+
* @returns Barcode lookup result with rate limit info
|
|
417
|
+
*/
|
|
418
|
+
lookupWithRateLimit(barcodeValue: string): Promise<ResponseWithRateLimit<BarcodeLookupResult>>;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Usage statistics resource handler
|
|
422
|
+
*/
|
|
423
|
+
declare class UsageResource {
|
|
424
|
+
private readonly client;
|
|
425
|
+
constructor(client: ColaCloud);
|
|
426
|
+
/**
|
|
427
|
+
* Get API usage statistics for the current account
|
|
428
|
+
* @returns Usage statistics including limits and current usage
|
|
429
|
+
*/
|
|
430
|
+
get(): Promise<UsageStats>;
|
|
431
|
+
/**
|
|
432
|
+
* Get usage statistics with rate limit information
|
|
433
|
+
* @returns Usage statistics with rate limit info
|
|
434
|
+
*/
|
|
435
|
+
getWithRateLimit(): Promise<ResponseWithRateLimit<UsageStats>>;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* COLA Cloud SDK Custom Error Classes
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Base error class for all COLA Cloud SDK errors
|
|
444
|
+
*/
|
|
445
|
+
declare class ColaCloudError extends Error {
|
|
446
|
+
/** HTTP status code (if applicable) */
|
|
447
|
+
readonly statusCode: number | undefined;
|
|
448
|
+
/** Error code from the API */
|
|
449
|
+
readonly code: string | undefined;
|
|
450
|
+
/** Additional error details */
|
|
451
|
+
readonly details: Record<string, unknown> | undefined;
|
|
452
|
+
constructor(message: string, statusCode?: number, code?: string, details?: Record<string, unknown>);
|
|
453
|
+
/**
|
|
454
|
+
* Create a ColaCloudError from an API error response
|
|
455
|
+
*/
|
|
456
|
+
static fromResponse(response: ApiErrorResponse, statusCode: number): ColaCloudError;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Error thrown when authentication fails (401 Unauthorized)
|
|
460
|
+
*/
|
|
461
|
+
declare class AuthenticationError extends ColaCloudError {
|
|
462
|
+
constructor(message?: string);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Error thrown when rate limit is exceeded (429 Too Many Requests)
|
|
466
|
+
*/
|
|
467
|
+
declare class RateLimitError extends ColaCloudError {
|
|
468
|
+
/** Rate limit information from headers */
|
|
469
|
+
readonly rateLimit: RateLimitInfo | null;
|
|
470
|
+
/** Seconds until the rate limit resets */
|
|
471
|
+
readonly retryAfter: number | null;
|
|
472
|
+
constructor(message?: string, rateLimit?: RateLimitInfo | null, retryAfter?: number | null);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Error thrown when a requested resource is not found (404 Not Found)
|
|
476
|
+
*/
|
|
477
|
+
declare class NotFoundError extends ColaCloudError {
|
|
478
|
+
/** The resource type that was not found */
|
|
479
|
+
readonly resourceType: string;
|
|
480
|
+
/** The identifier that was searched for */
|
|
481
|
+
readonly resourceId: string;
|
|
482
|
+
constructor(resourceType: string, resourceId: string);
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Error thrown when the request is invalid (400 Bad Request)
|
|
486
|
+
*/
|
|
487
|
+
declare class ValidationError extends ColaCloudError {
|
|
488
|
+
/** Field-level validation errors */
|
|
489
|
+
readonly fieldErrors: Record<string, string[]> | undefined;
|
|
490
|
+
constructor(message?: string, fieldErrors?: Record<string, string[]>);
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Error thrown when the server encounters an error (500+ status codes)
|
|
494
|
+
*/
|
|
495
|
+
declare class ServerError extends ColaCloudError {
|
|
496
|
+
constructor(message?: string, statusCode?: number);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Error thrown when a request times out
|
|
500
|
+
*/
|
|
501
|
+
declare class TimeoutError extends ColaCloudError {
|
|
502
|
+
/** The timeout value in milliseconds */
|
|
503
|
+
readonly timeoutMs: number;
|
|
504
|
+
constructor(timeoutMs: number);
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Error thrown when there's a network connectivity issue
|
|
508
|
+
*/
|
|
509
|
+
declare class NetworkError extends ColaCloudError {
|
|
510
|
+
/** The original error that caused this */
|
|
511
|
+
readonly cause: Error | undefined;
|
|
512
|
+
constructor(message?: string, cause?: Error);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* COLA Cloud SDK Pagination Utilities
|
|
517
|
+
*/
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Options for creating a paginated iterator
|
|
521
|
+
*/
|
|
522
|
+
interface PaginatedIteratorOptions<TParams> {
|
|
523
|
+
/** Parameters for the request (excluding page) */
|
|
524
|
+
params: TParams;
|
|
525
|
+
/** Function to fetch a page of results */
|
|
526
|
+
fetchPage: (params: TParams & {
|
|
527
|
+
page: number;
|
|
528
|
+
}) => Promise<{
|
|
529
|
+
response: PaginatedResponse<unknown>;
|
|
530
|
+
rateLimit: RateLimitInfo | null;
|
|
531
|
+
}>;
|
|
532
|
+
/** Starting page number (defaults to 1) */
|
|
533
|
+
startPage?: number;
|
|
534
|
+
/** Maximum number of pages to fetch (optional, defaults to all) */
|
|
535
|
+
maxPages?: number;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Result yielded by the paginated iterator
|
|
539
|
+
*/
|
|
540
|
+
interface PaginatedIteratorResult<T> {
|
|
541
|
+
/** The current item */
|
|
542
|
+
item: T;
|
|
543
|
+
/** Current page number */
|
|
544
|
+
page: number;
|
|
545
|
+
/** Index within the current page */
|
|
546
|
+
indexInPage: number;
|
|
547
|
+
/** Total items across all pages */
|
|
548
|
+
total: number;
|
|
549
|
+
/** Rate limit info from the last request */
|
|
550
|
+
rateLimit: RateLimitInfo | null;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Creates an async iterator that automatically handles pagination
|
|
554
|
+
* @param options Configuration for the paginated iterator
|
|
555
|
+
* @returns An async iterable that yields items across all pages
|
|
556
|
+
*/
|
|
557
|
+
declare function createPaginatedIterator<T, TParams>(options: PaginatedIteratorOptions<TParams>): AsyncIterable<T>;
|
|
558
|
+
/**
|
|
559
|
+
* Creates an async iterator that yields items with additional metadata
|
|
560
|
+
* @param options Configuration for the paginated iterator
|
|
561
|
+
* @returns An async iterable that yields items with page/index metadata
|
|
562
|
+
*/
|
|
563
|
+
declare function createPaginatedIteratorWithMetadata<T, TParams>(options: PaginatedIteratorOptions<TParams>): AsyncIterable<PaginatedIteratorResult<T>>;
|
|
564
|
+
/**
|
|
565
|
+
* Collects all items from a paginated iterator into an array
|
|
566
|
+
* Warning: Use with caution on large datasets
|
|
567
|
+
* @param iterator The async iterable to collect from
|
|
568
|
+
* @param maxItems Maximum number of items to collect (optional safety limit)
|
|
569
|
+
* @returns Array of all collected items
|
|
570
|
+
*/
|
|
571
|
+
declare function collectAll<T>(iterator: AsyncIterable<T>, maxItems?: number): Promise<T[]>;
|
|
572
|
+
/**
|
|
573
|
+
* Takes the first N items from a paginated iterator
|
|
574
|
+
* @param iterator The async iterable to take from
|
|
575
|
+
* @param count Number of items to take
|
|
576
|
+
* @returns Array of the first N items
|
|
577
|
+
*/
|
|
578
|
+
declare function take<T>(iterator: AsyncIterable<T>, count: number): Promise<T[]>;
|
|
579
|
+
|
|
580
|
+
export { type ApiErrorResponse, AuthenticationError, type BarcodeLookupResult, type ColaBarcode, ColaCloud, type ColaCloudConfig, ColaCloudError, type ColaDetail, type ColaImage, type ColaListParams, type ColaSummary, NetworkError, NotFoundError, type PaginatedIteratorOptions, type PaginatedIteratorResult, type PaginatedResponse, type Pagination, type PermitteeDetail, type PermitteeListParams, type PermitteeSummary, RateLimitError, type RateLimitInfo, type ResponseWithRateLimit, ServerError, type SingleResponse, TimeoutError, type UsageStats, ValidationError, collectAll, createPaginatedIterator, createPaginatedIteratorWithMetadata, take };
|