colacloud 1.2.0 → 1.4.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/README.md +1 -1
- package/dist/index.d.mts +242 -39
- package/dist/index.d.ts +242 -39
- package/dist/index.js +156 -49
- package/dist/index.mjs +156 -49
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,10 +20,14 @@ interface Pagination {
|
|
|
20
20
|
page: number;
|
|
21
21
|
/** Number of items per page */
|
|
22
22
|
per_page: number;
|
|
23
|
-
/** Total number of items across all pages */
|
|
24
|
-
total: number;
|
|
25
|
-
/** Total number of pages */
|
|
26
|
-
pages: number;
|
|
23
|
+
/** Total number of items across all pages (null when using offset pagination without count) */
|
|
24
|
+
total: number | null;
|
|
25
|
+
/** Total number of pages (null when using offset pagination without count) */
|
|
26
|
+
pages: number | null;
|
|
27
|
+
/** Whether there are more results available */
|
|
28
|
+
has_more?: boolean;
|
|
29
|
+
/** Pagination mode: "cursor" or "offset" */
|
|
30
|
+
mode?: string;
|
|
27
31
|
}
|
|
28
32
|
/**
|
|
29
33
|
* Response wrapper for paginated list endpoints
|
|
@@ -42,24 +46,26 @@ interface SingleResponse<T> {
|
|
|
42
46
|
data: T;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
|
-
*
|
|
49
|
+
* Quota information parsed from response headers
|
|
46
50
|
*/
|
|
47
|
-
interface
|
|
48
|
-
/**
|
|
51
|
+
interface QuotaInfo {
|
|
52
|
+
/** Which meter this quota applies to */
|
|
53
|
+
meter: 'detail_views' | 'list_records';
|
|
54
|
+
/** Quota limit for the current billing period */
|
|
49
55
|
limit: number;
|
|
50
|
-
/** Remaining
|
|
56
|
+
/** Remaining quota in the current billing period */
|
|
51
57
|
remaining: number;
|
|
52
|
-
/** Unix timestamp when
|
|
58
|
+
/** Unix timestamp when quotas reset (first of next month) */
|
|
53
59
|
reset: number;
|
|
54
60
|
}
|
|
55
61
|
/**
|
|
56
|
-
* Extended response that includes
|
|
62
|
+
* Extended response that includes quota information
|
|
57
63
|
*/
|
|
58
|
-
interface
|
|
64
|
+
interface ResponseWithQuota<T> {
|
|
59
65
|
/** The response data */
|
|
60
66
|
data: T;
|
|
61
|
-
/**
|
|
62
|
-
|
|
67
|
+
/** Quota information from headers */
|
|
68
|
+
quota: QuotaInfo | null;
|
|
63
69
|
}
|
|
64
70
|
/**
|
|
65
71
|
* Summary information about a COLA (Certificate of Label Approval)
|
|
@@ -322,6 +328,140 @@ interface UsageStats {
|
|
|
322
328
|
/** Per-minute burst limit */
|
|
323
329
|
per_minute_limit: number;
|
|
324
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Metadata for reference data list responses
|
|
333
|
+
*/
|
|
334
|
+
interface ReferenceListMeta {
|
|
335
|
+
/** Total number of items */
|
|
336
|
+
total: number;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Metadata for paginated reference data responses
|
|
340
|
+
*/
|
|
341
|
+
interface ReferenceListPaginatedMeta {
|
|
342
|
+
/** Total number of items */
|
|
343
|
+
total: number;
|
|
344
|
+
/** Current page number */
|
|
345
|
+
page: number;
|
|
346
|
+
/** Items per page */
|
|
347
|
+
per_page: number;
|
|
348
|
+
/** Whether there are more results */
|
|
349
|
+
has_more: boolean;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Response wrapper for reference data list endpoints
|
|
353
|
+
*/
|
|
354
|
+
interface ReferenceListResponse<T> {
|
|
355
|
+
/** Array of items */
|
|
356
|
+
data: T[];
|
|
357
|
+
/** Response metadata */
|
|
358
|
+
meta: ReferenceListMeta;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Response wrapper for paginated reference data list endpoints
|
|
362
|
+
*/
|
|
363
|
+
interface ReferencePaginatedResponse<T> {
|
|
364
|
+
/** Array of items */
|
|
365
|
+
data: T[];
|
|
366
|
+
/** Response metadata with pagination */
|
|
367
|
+
meta: ReferenceListPaginatedMeta;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Response wrapper for single reference data endpoints
|
|
371
|
+
*/
|
|
372
|
+
interface ReferenceSingleResponse<T> {
|
|
373
|
+
/** The requested item */
|
|
374
|
+
data: T;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Query parameters for processing times overview
|
|
378
|
+
*/
|
|
379
|
+
interface ProcessingTimesParams {
|
|
380
|
+
/** Filter by commodity type */
|
|
381
|
+
commodity?: string;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Query parameters for formula processing times
|
|
385
|
+
*/
|
|
386
|
+
interface FormulaProcessingTimesParams {
|
|
387
|
+
/** Filter by formula type */
|
|
388
|
+
formulaType?: string;
|
|
389
|
+
/** Filter by commodity type */
|
|
390
|
+
commodity?: string;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Query parameters for registration processing times
|
|
394
|
+
*/
|
|
395
|
+
interface RegistrationProcessingTimesParams {
|
|
396
|
+
/** Filter by category */
|
|
397
|
+
category?: string;
|
|
398
|
+
/** Filter by application type */
|
|
399
|
+
applicationType?: string;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Query parameters for production reports
|
|
403
|
+
*/
|
|
404
|
+
interface ProductionReportsParams {
|
|
405
|
+
/** Filter by commodity type */
|
|
406
|
+
commodity?: string;
|
|
407
|
+
/** Filter by year */
|
|
408
|
+
year?: number;
|
|
409
|
+
/** Filter by month */
|
|
410
|
+
month?: number;
|
|
411
|
+
/** Filter by report type */
|
|
412
|
+
reportType?: string;
|
|
413
|
+
/** Filter by statistical group */
|
|
414
|
+
statisticalGroup?: string;
|
|
415
|
+
/** Page number (1-indexed, default 1) */
|
|
416
|
+
page?: number;
|
|
417
|
+
/** Items per page (default 100, max 100) */
|
|
418
|
+
perPage?: number;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Query parameters for AVA (American Viticultural Area) list
|
|
422
|
+
*/
|
|
423
|
+
interface AvaListParams {
|
|
424
|
+
/** Filter by state */
|
|
425
|
+
state?: string;
|
|
426
|
+
/** Search by name */
|
|
427
|
+
q?: string;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* A processing time record
|
|
431
|
+
*/
|
|
432
|
+
interface ProcessingTime {
|
|
433
|
+
[key: string]: unknown;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* A formula processing time record
|
|
437
|
+
*/
|
|
438
|
+
interface FormulaProcessingTime {
|
|
439
|
+
[key: string]: unknown;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* A registration processing time record
|
|
443
|
+
*/
|
|
444
|
+
interface RegistrationProcessingTime {
|
|
445
|
+
[key: string]: unknown;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* A production report record
|
|
449
|
+
*/
|
|
450
|
+
interface ProductionReport {
|
|
451
|
+
[key: string]: unknown;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* An AVA (American Viticultural Area) summary record
|
|
455
|
+
*/
|
|
456
|
+
interface AvaSummary {
|
|
457
|
+
[key: string]: unknown;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Full AVA (American Viticultural Area) detail record
|
|
461
|
+
*/
|
|
462
|
+
interface AvaDetail {
|
|
463
|
+
[key: string]: unknown;
|
|
464
|
+
}
|
|
325
465
|
/**
|
|
326
466
|
* Error response structure from the API
|
|
327
467
|
*/
|
|
@@ -373,6 +513,12 @@ declare class ColaCloud {
|
|
|
373
513
|
readonly barcodes: BarcodesResource;
|
|
374
514
|
/** Usage statistics endpoint */
|
|
375
515
|
readonly usage: UsageResource;
|
|
516
|
+
/** Processing times reference data endpoints */
|
|
517
|
+
readonly processingTimes: ProcessingTimesResource;
|
|
518
|
+
/** Production reports reference data endpoints */
|
|
519
|
+
readonly productionReports: ProductionReportsResource;
|
|
520
|
+
/** AVA (American Viticultural Area) reference data endpoints */
|
|
521
|
+
readonly avas: AvasResource;
|
|
376
522
|
/**
|
|
377
523
|
* Create a new COLA Cloud API client
|
|
378
524
|
* @param config Configuration options
|
|
@@ -382,7 +528,7 @@ declare class ColaCloud {
|
|
|
382
528
|
* Make an authenticated request to the API
|
|
383
529
|
* @internal
|
|
384
530
|
*/
|
|
385
|
-
request<T>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, params?: Record<string, unknown>): Promise<
|
|
531
|
+
request<T>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, params?: Record<string, unknown>): Promise<ResponseWithQuota<T>>;
|
|
386
532
|
/**
|
|
387
533
|
* Handle error responses from the API
|
|
388
534
|
*/
|
|
@@ -401,11 +547,11 @@ declare class ColasResource {
|
|
|
401
547
|
*/
|
|
402
548
|
list(params?: ColaListParams): Promise<PaginatedResponse<ColaSummary>>;
|
|
403
549
|
/**
|
|
404
|
-
* List COLAs with
|
|
550
|
+
* List COLAs with quota information
|
|
405
551
|
* @param params Search and filter parameters
|
|
406
|
-
* @returns Paginated list with
|
|
552
|
+
* @returns Paginated list with quota info
|
|
407
553
|
*/
|
|
408
|
-
|
|
554
|
+
listWithQuota(params?: ColaListParams): Promise<ResponseWithQuota<PaginatedResponse<ColaSummary>>>;
|
|
409
555
|
/**
|
|
410
556
|
* Get a single COLA by TTB ID
|
|
411
557
|
* @param ttbId The unique TTB identifier
|
|
@@ -413,11 +559,11 @@ declare class ColasResource {
|
|
|
413
559
|
*/
|
|
414
560
|
get(ttbId: string): Promise<ColaDetail>;
|
|
415
561
|
/**
|
|
416
|
-
* Get a single COLA with
|
|
562
|
+
* Get a single COLA with quota information
|
|
417
563
|
* @param ttbId The unique TTB identifier
|
|
418
|
-
* @returns COLA details with
|
|
564
|
+
* @returns COLA details with quota info
|
|
419
565
|
*/
|
|
420
|
-
|
|
566
|
+
getWithQuota(ttbId: string): Promise<ResponseWithQuota<ColaDetail>>;
|
|
421
567
|
/**
|
|
422
568
|
* Create an async iterator that automatically pages through all results
|
|
423
569
|
* @param params Search and filter parameters (page is ignored)
|
|
@@ -445,11 +591,11 @@ declare class PermitteesResource {
|
|
|
445
591
|
*/
|
|
446
592
|
list(params?: PermitteeListParams): Promise<PaginatedResponse<PermitteeSummary>>;
|
|
447
593
|
/**
|
|
448
|
-
* List permittees with
|
|
594
|
+
* List permittees with quota information
|
|
449
595
|
* @param params Search and filter parameters
|
|
450
|
-
* @returns Paginated list with
|
|
596
|
+
* @returns Paginated list with quota info
|
|
451
597
|
*/
|
|
452
|
-
|
|
598
|
+
listWithQuota(params?: PermitteeListParams): Promise<ResponseWithQuota<PaginatedResponse<PermitteeSummary>>>;
|
|
453
599
|
/**
|
|
454
600
|
* Get a single permittee by permit number
|
|
455
601
|
* @param permitNumber The unique permit number
|
|
@@ -457,11 +603,11 @@ declare class PermitteesResource {
|
|
|
457
603
|
*/
|
|
458
604
|
get(permitNumber: string): Promise<PermitteeDetail>;
|
|
459
605
|
/**
|
|
460
|
-
* Get a single permittee with
|
|
606
|
+
* Get a single permittee with quota information
|
|
461
607
|
* @param permitNumber The unique permit number
|
|
462
|
-
* @returns Permittee details with
|
|
608
|
+
* @returns Permittee details with quota info
|
|
463
609
|
*/
|
|
464
|
-
|
|
610
|
+
getWithQuota(permitNumber: string): Promise<ResponseWithQuota<PermitteeDetail>>;
|
|
465
611
|
/**
|
|
466
612
|
* Create an async iterator that automatically pages through all results
|
|
467
613
|
* @param params Search and filter parameters (page is ignored)
|
|
@@ -489,11 +635,11 @@ declare class BarcodesResource {
|
|
|
489
635
|
*/
|
|
490
636
|
lookup(barcodeValue: string): Promise<BarcodeLookupResult>;
|
|
491
637
|
/**
|
|
492
|
-
* Look up barcode with
|
|
638
|
+
* Look up barcode with quota information
|
|
493
639
|
* @param barcodeValue The barcode to search for
|
|
494
|
-
* @returns Barcode lookup result with
|
|
640
|
+
* @returns Barcode lookup result with quota info
|
|
495
641
|
*/
|
|
496
|
-
|
|
642
|
+
lookupWithQuota(barcodeValue: string): Promise<ResponseWithQuota<BarcodeLookupResult>>;
|
|
497
643
|
}
|
|
498
644
|
/**
|
|
499
645
|
* Usage statistics resource handler
|
|
@@ -507,10 +653,67 @@ declare class UsageResource {
|
|
|
507
653
|
*/
|
|
508
654
|
get(): Promise<UsageStats>;
|
|
509
655
|
/**
|
|
510
|
-
* Get usage statistics with
|
|
511
|
-
* @returns Usage statistics with
|
|
656
|
+
* Get usage statistics with quota information
|
|
657
|
+
* @returns Usage statistics with quota info
|
|
658
|
+
*/
|
|
659
|
+
getWithQuota(): Promise<ResponseWithQuota<UsageStats>>;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Processing times reference data resource handler
|
|
663
|
+
*/
|
|
664
|
+
declare class ProcessingTimesResource {
|
|
665
|
+
private readonly client;
|
|
666
|
+
constructor(client: ColaCloud);
|
|
667
|
+
/**
|
|
668
|
+
* Get processing times overview
|
|
669
|
+
* @param params Optional filter parameters
|
|
670
|
+
* @returns Processing times data with total count
|
|
671
|
+
*/
|
|
672
|
+
list(params?: ProcessingTimesParams): Promise<ReferenceListResponse<ProcessingTime>>;
|
|
673
|
+
/**
|
|
674
|
+
* Get formula processing times
|
|
675
|
+
* @param params Optional filter parameters
|
|
676
|
+
* @returns Formula processing times data with total count
|
|
677
|
+
*/
|
|
678
|
+
formula(params?: FormulaProcessingTimesParams): Promise<ReferenceListResponse<FormulaProcessingTime>>;
|
|
679
|
+
/**
|
|
680
|
+
* Get registration processing times
|
|
681
|
+
* @param params Optional filter parameters
|
|
682
|
+
* @returns Registration processing times data with total count
|
|
683
|
+
*/
|
|
684
|
+
registration(params?: RegistrationProcessingTimesParams): Promise<ReferenceListResponse<RegistrationProcessingTime>>;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Production reports reference data resource handler
|
|
688
|
+
*/
|
|
689
|
+
declare class ProductionReportsResource {
|
|
690
|
+
private readonly client;
|
|
691
|
+
constructor(client: ColaCloud);
|
|
692
|
+
/**
|
|
693
|
+
* List production reports with pagination
|
|
694
|
+
* @param params Filter and pagination parameters
|
|
695
|
+
* @returns Paginated production reports data
|
|
696
|
+
*/
|
|
697
|
+
list(params?: ProductionReportsParams): Promise<ReferencePaginatedResponse<ProductionReport>>;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* AVA (American Viticultural Area) reference data resource handler
|
|
701
|
+
*/
|
|
702
|
+
declare class AvasResource {
|
|
703
|
+
private readonly client;
|
|
704
|
+
constructor(client: ColaCloud);
|
|
705
|
+
/**
|
|
706
|
+
* List and search AVAs
|
|
707
|
+
* @param params Optional filter parameters
|
|
708
|
+
* @returns AVA data with total count
|
|
709
|
+
*/
|
|
710
|
+
list(params?: AvaListParams): Promise<ReferenceListResponse<AvaSummary>>;
|
|
711
|
+
/**
|
|
712
|
+
* Get a single AVA by ID
|
|
713
|
+
* @param avaId The unique AVA identifier
|
|
714
|
+
* @returns Full AVA details
|
|
512
715
|
*/
|
|
513
|
-
|
|
716
|
+
get(avaId: string): Promise<AvaDetail>;
|
|
514
717
|
}
|
|
515
718
|
|
|
516
719
|
/**
|
|
@@ -543,11 +746,11 @@ declare class AuthenticationError extends ColaCloudError {
|
|
|
543
746
|
* Error thrown when rate limit is exceeded (429 Too Many Requests)
|
|
544
747
|
*/
|
|
545
748
|
declare class RateLimitError extends ColaCloudError {
|
|
546
|
-
/**
|
|
547
|
-
readonly
|
|
749
|
+
/** Quota information from headers */
|
|
750
|
+
readonly quota: QuotaInfo | null;
|
|
548
751
|
/** Seconds until the rate limit resets */
|
|
549
752
|
readonly retryAfter: number | null;
|
|
550
|
-
constructor(message?: string,
|
|
753
|
+
constructor(message?: string, quota?: QuotaInfo | null, retryAfter?: number | null);
|
|
551
754
|
}
|
|
552
755
|
/**
|
|
553
756
|
* Error thrown when a requested resource is not found (404 Not Found)
|
|
@@ -605,7 +808,7 @@ interface PaginatedIteratorOptions<TParams> {
|
|
|
605
808
|
page: number;
|
|
606
809
|
}) => Promise<{
|
|
607
810
|
response: PaginatedResponse<unknown>;
|
|
608
|
-
|
|
811
|
+
quota: QuotaInfo | null;
|
|
609
812
|
}>;
|
|
610
813
|
/** Starting page number (defaults to 1) */
|
|
611
814
|
startPage?: number;
|
|
@@ -624,8 +827,8 @@ interface PaginatedIteratorResult<T> {
|
|
|
624
827
|
indexInPage: number;
|
|
625
828
|
/** Total items across all pages */
|
|
626
829
|
total: number;
|
|
627
|
-
/**
|
|
628
|
-
|
|
830
|
+
/** Quota info from the last request */
|
|
831
|
+
quota: QuotaInfo | null;
|
|
629
832
|
}
|
|
630
833
|
/**
|
|
631
834
|
* Creates an async iterator that automatically handles pagination
|
|
@@ -655,4 +858,4 @@ declare function collectAll<T>(iterator: AsyncIterable<T>, maxItems?: number): P
|
|
|
655
858
|
*/
|
|
656
859
|
declare function take<T>(iterator: AsyncIterable<T>, count: number): Promise<T[]>;
|
|
657
860
|
|
|
658
|
-
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
|
|
861
|
+
export { type ApiErrorResponse, AuthenticationError, type AvaDetail, type AvaListParams, type AvaSummary, type BarcodeLookupResult, type ColaBarcode, ColaCloud, type ColaCloudConfig, ColaCloudError, type ColaDetail, type ColaImage, type ColaListParams, type ColaSummary, type FormulaProcessingTime, type FormulaProcessingTimesParams, NetworkError, NotFoundError, type PaginatedIteratorOptions, type PaginatedIteratorResult, type PaginatedResponse, type Pagination, type PermitteeDetail, type PermitteeListParams, type PermitteeSummary, type ProcessingTime, type ProcessingTimesParams, type ProductionReport, type ProductionReportsParams, type QuotaInfo, RateLimitError, type ReferenceListMeta, type ReferenceListPaginatedMeta, type ReferenceListResponse, type ReferencePaginatedResponse, type ReferenceSingleResponse, type RegistrationProcessingTime, type RegistrationProcessingTimesParams, type ResponseWithQuota, ServerError, type SingleResponse, TimeoutError, type UsageStats, ValidationError, collectAll, createPaginatedIterator, createPaginatedIteratorWithMetadata, take };
|