@proveanything/smartlinks 1.3.20 → 1.3.22

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.
@@ -1,4 +1,4 @@
1
- import { BatchResponse, BatchCreateRequest, BatchUpdateRequest } from "../types/batch";
1
+ import { BatchResponse, BatchCreateRequest, BatchUpdateRequest, SearchBatchesRequest, BatchTag } from "../types/batch";
2
2
  export declare namespace batch {
3
3
  /**
4
4
  * Get a single batch by ID for a collection and product (admin only).
@@ -75,4 +75,84 @@ export declare namespace batch {
75
75
  * @throws ErrorResponse if the request fails
76
76
  */
77
77
  function lookupSN(collectionId: string, productId: string, batchId: string, codeId: string): Promise<any>;
78
+ /**
79
+ * Search for batches across all products in a collection.
80
+ * Allows searching by batch ID or name, with optional product filtering.
81
+ *
82
+ * @param collectionId - Identifier of the collection
83
+ * @param params - Optional search parameters (search term, productId filter, limit)
84
+ * @returns Promise resolving to an array of matching BatchResponse objects
85
+ * @throws ErrorResponse if the request fails
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * // Search for batches containing "2024"
90
+ * const batches = await batch.searchInCollection('coll_123', {
91
+ * search: 'BATCH-2024',
92
+ * limit: 50
93
+ * })
94
+ *
95
+ * // Filter batches for a specific product
96
+ * const productBatches = await batch.searchInCollection('coll_123', {
97
+ * productId: 'prod_abc',
98
+ * limit: 100
99
+ * })
100
+ *
101
+ * // Get all batches in collection
102
+ * const allBatches = await batch.searchInCollection('coll_123')
103
+ *
104
+ * // Check for expired batches
105
+ * batches.forEach(batch => {
106
+ * if (batch.expiryDate?.seconds) {
107
+ * const expiryDate = new Date(batch.expiryDate.seconds * 1000)
108
+ * if (expiryDate < new Date()) {
109
+ * console.log(`Batch ${batch.id} is expired`)
110
+ * }
111
+ * }
112
+ * })
113
+ * ```
114
+ */
115
+ function searchInCollection(collectionId: string, params?: SearchBatchesRequest): Promise<BatchResponse[]>;
116
+ /**
117
+ * Find a specific batch by ID across all products in a collection.
118
+ * Returns the batch along with the productId it belongs to.
119
+ *
120
+ * @param collectionId - Identifier of the collection
121
+ * @param batchId - Batch ID to find
122
+ * @returns Promise resolving to a BatchResponse with productId
123
+ * @throws ErrorResponse if the request fails (404 if not found)
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * // Find which product contains a specific batch
128
+ * const batch = await batch.findInCollection('coll_123', 'BATCH-2024-001')
129
+ * console.log(`Batch found in product: ${batch.productId}`)
130
+ * console.log(`Expires: ${batch.expiryDate}`)
131
+ * ```
132
+ */
133
+ function findInCollection(collectionId: string, batchId: string): Promise<BatchResponse>;
134
+ /**
135
+ * Get all tags/codes assigned to a specific batch.
136
+ * Shows which claim set codes have been assigned to this batch.
137
+ *
138
+ * @param collectionId - Identifier of the collection
139
+ * @param batchId - Batch ID
140
+ * @param claimSetId - Optional claim set ID to filter results
141
+ * @returns Promise resolving to an array of BatchTag objects
142
+ * @throws ErrorResponse if the request fails
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * // Get all tags assigned to a batch
147
+ * const tags = await batch.getBatchTags('coll_123', 'BATCH-2024-001')
148
+ * console.log(`Batch has ${tags.length} tags assigned`)
149
+ * tags.forEach(tag => {
150
+ * console.log(`Code: ${tag.code}, ClaimSet: ${tag.claimSetId}, TagID: ${tag.tagId}`)
151
+ * })
152
+ *
153
+ * // Get tags from a specific claim set
154
+ * const claimSetTags = await batch.getBatchTags('coll_123', 'BATCH-2024-001', '000001')
155
+ * ```
156
+ */
157
+ function getBatchTags(collectionId: string, batchId: string, claimSetId?: string): Promise<BatchTag[]>;
78
158
  }
package/dist/api/batch.js CHANGED
@@ -115,4 +115,108 @@ export var batch;
115
115
  return request(path);
116
116
  }
117
117
  batch.lookupSN = lookupSN;
118
+ /**
119
+ * Search for batches across all products in a collection.
120
+ * Allows searching by batch ID or name, with optional product filtering.
121
+ *
122
+ * @param collectionId - Identifier of the collection
123
+ * @param params - Optional search parameters (search term, productId filter, limit)
124
+ * @returns Promise resolving to an array of matching BatchResponse objects
125
+ * @throws ErrorResponse if the request fails
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * // Search for batches containing "2024"
130
+ * const batches = await batch.searchInCollection('coll_123', {
131
+ * search: 'BATCH-2024',
132
+ * limit: 50
133
+ * })
134
+ *
135
+ * // Filter batches for a specific product
136
+ * const productBatches = await batch.searchInCollection('coll_123', {
137
+ * productId: 'prod_abc',
138
+ * limit: 100
139
+ * })
140
+ *
141
+ * // Get all batches in collection
142
+ * const allBatches = await batch.searchInCollection('coll_123')
143
+ *
144
+ * // Check for expired batches
145
+ * batches.forEach(batch => {
146
+ * if (batch.expiryDate?.seconds) {
147
+ * const expiryDate = new Date(batch.expiryDate.seconds * 1000)
148
+ * if (expiryDate < new Date()) {
149
+ * console.log(`Batch ${batch.id} is expired`)
150
+ * }
151
+ * }
152
+ * })
153
+ * ```
154
+ */
155
+ async function searchInCollection(collectionId, params) {
156
+ const queryParams = new URLSearchParams();
157
+ if (params === null || params === void 0 ? void 0 : params.search)
158
+ queryParams.append('search', params.search);
159
+ if (params === null || params === void 0 ? void 0 : params.productId)
160
+ queryParams.append('productId', params.productId);
161
+ if (params === null || params === void 0 ? void 0 : params.limit)
162
+ queryParams.append('limit', params.limit.toString());
163
+ const query = queryParams.toString();
164
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/batch${query ? `?${query}` : ''}`;
165
+ return request(path);
166
+ }
167
+ batch.searchInCollection = searchInCollection;
168
+ /**
169
+ * Find a specific batch by ID across all products in a collection.
170
+ * Returns the batch along with the productId it belongs to.
171
+ *
172
+ * @param collectionId - Identifier of the collection
173
+ * @param batchId - Batch ID to find
174
+ * @returns Promise resolving to a BatchResponse with productId
175
+ * @throws ErrorResponse if the request fails (404 if not found)
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * // Find which product contains a specific batch
180
+ * const batch = await batch.findInCollection('coll_123', 'BATCH-2024-001')
181
+ * console.log(`Batch found in product: ${batch.productId}`)
182
+ * console.log(`Expires: ${batch.expiryDate}`)
183
+ * ```
184
+ */
185
+ async function findInCollection(collectionId, batchId) {
186
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/batch/${encodeURIComponent(batchId)}`;
187
+ return request(path);
188
+ }
189
+ batch.findInCollection = findInCollection;
190
+ /**
191
+ * Get all tags/codes assigned to a specific batch.
192
+ * Shows which claim set codes have been assigned to this batch.
193
+ *
194
+ * @param collectionId - Identifier of the collection
195
+ * @param batchId - Batch ID
196
+ * @param claimSetId - Optional claim set ID to filter results
197
+ * @returns Promise resolving to an array of BatchTag objects
198
+ * @throws ErrorResponse if the request fails
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * // Get all tags assigned to a batch
203
+ * const tags = await batch.getBatchTags('coll_123', 'BATCH-2024-001')
204
+ * console.log(`Batch has ${tags.length} tags assigned`)
205
+ * tags.forEach(tag => {
206
+ * console.log(`Code: ${tag.code}, ClaimSet: ${tag.claimSetId}, TagID: ${tag.tagId}`)
207
+ * })
208
+ *
209
+ * // Get tags from a specific claim set
210
+ * const claimSetTags = await batch.getBatchTags('coll_123', 'BATCH-2024-001', '000001')
211
+ * ```
212
+ */
213
+ async function getBatchTags(collectionId, batchId, claimSetId) {
214
+ const queryParams = new URLSearchParams();
215
+ if (claimSetId)
216
+ queryParams.append('claimSetId', claimSetId);
217
+ const query = queryParams.toString();
218
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/batch/${encodeURIComponent(batchId)}/tags${query ? `?${query}` : ''}`;
219
+ return request(path);
220
+ }
221
+ batch.getBatchTags = getBatchTags;
118
222
  })(batch || (batch = {}));
@@ -1,4 +1,4 @@
1
- import { CreateOrderRequest, CreateOrderResponse, GetOrderParams, GetOrderResponse, UpdateOrderRequest, UpdateOrderResponse, DeleteOrderResponse, ListOrdersRequest, ListOrdersResponse, GetOrderItemsParams, GetOrderItemsResponse, AddItemsRequest, AddItemsResponse, RemoveItemsRequest, RemoveItemsResponse, QueryOrdersRequest, QueryOrdersResponse, ReportsParams, ReportsResponse, LookupOrdersRequest, LookupOrdersResponse, LookupByProductParams, LookupByProductResponse, OrderAnalyticsResponse, TimelineRequest, TimelineResponse, LocationRequest, LocationResponse, BulkAnalyticsRequest, BulkAnalyticsResponse, SummaryRequest, CollectionSummaryResponse } from "../types/order";
1
+ import { CreateOrderRequest, CreateOrderResponse, GetOrderParams, GetOrderResponse, UpdateOrderRequest, UpdateOrderResponse, DeleteOrderResponse, ListOrdersRequest, ListOrdersResponse, GetOrderItemsParams, GetOrderItemsResponse, AddItemsRequest, AddItemsResponse, RemoveItemsRequest, RemoveItemsResponse, QueryOrdersRequest, QueryOrdersResponse, ReportsParams, ReportsResponse, LookupOrdersRequest, LookupOrdersResponse, LookupByProductParams, LookupByProductResponse, OrderAnalyticsResponse, TimelineRequest, TimelineResponse, LocationRequest, LocationResponse, BulkAnalyticsRequest, BulkAnalyticsResponse, SummaryRequest, CollectionSummaryResponse, FindOrdersByAttributeParams, FindOrdersByAttributeResponse, FindItemsByAttributeParams, FindItemsByAttributeResponse, GetOrderIdsParams, GetOrderIdsResponse } from "../types/order";
2
2
  /**
3
3
  * Order Management API
4
4
  *
@@ -443,4 +443,169 @@ export declare namespace order {
443
443
  * ```
444
444
  */
445
445
  function getCollectionSummary(collectionId: string, params?: SummaryRequest): Promise<CollectionSummaryResponse>;
446
+ /**
447
+ * Find all orders containing items from a specific batch.
448
+ * Uses indexed queries for fast lookups across order items.
449
+ *
450
+ * @param collectionId - Identifier of the parent collection
451
+ * @param batchId - Batch ID to search for
452
+ * @param params - Optional pagination and includeItems parameters
453
+ * @returns Promise resolving to a FindOrdersByAttributeResponse
454
+ * @throws ErrorResponse if the request fails
455
+ *
456
+ * @example
457
+ * ```typescript
458
+ * // Find orders with items from a specific batch
459
+ * const { orders } = await order.findByBatch('coll_123', 'BATCH-2024-001', {
460
+ * includeItems: true,
461
+ * limit: 50
462
+ * })
463
+ *
464
+ * // Get unique customers who received this batch
465
+ * const customers = [...new Set(orders.map(o => o.customerId).filter(Boolean))]
466
+ * console.log(`Batch delivered to ${customers.length} customers`)
467
+ * ```
468
+ */
469
+ function findByBatch(collectionId: string, batchId: string, params?: FindOrdersByAttributeParams): Promise<FindOrdersByAttributeResponse>;
470
+ /**
471
+ * Find all orders containing items from a specific product.
472
+ * Uses indexed queries for fast lookups across order items.
473
+ *
474
+ * @param collectionId - Identifier of the parent collection
475
+ * @param productId - Product ID to search for
476
+ * @param params - Optional pagination and includeItems parameters
477
+ * @returns Promise resolving to a FindOrdersByAttributeResponse
478
+ * @throws ErrorResponse if the request fails
479
+ *
480
+ * @example
481
+ * ```typescript
482
+ * // Find all orders containing a product
483
+ * const { orders, limit, offset } = await order.findOrdersByProduct('coll_123', 'prod_789', {
484
+ * limit: 100
485
+ * })
486
+ *
487
+ * console.log(`Product appears in ${orders.length} orders`)
488
+ * ```
489
+ */
490
+ function findOrdersByProduct(collectionId: string, productId: string, params?: FindOrdersByAttributeParams): Promise<FindOrdersByAttributeResponse>;
491
+ /**
492
+ * Find all orders containing items from a specific variant.
493
+ * Uses indexed queries for fast lookups across order items.
494
+ *
495
+ * @param collectionId - Identifier of the parent collection
496
+ * @param variantId - Variant ID to search for
497
+ * @param params - Optional pagination and includeItems parameters
498
+ * @returns Promise resolving to a FindOrdersByAttributeResponse
499
+ * @throws ErrorResponse if the request fails
500
+ *
501
+ * @example
502
+ * ```typescript
503
+ * // Find orders with a specific variant
504
+ * const { orders } = await order.findByVariant('coll_123', 'var_456', {
505
+ * includeItems: true
506
+ * })
507
+ *
508
+ * console.log(`Variant ${variantId} in ${orders.length} orders`)
509
+ * ```
510
+ */
511
+ function findByVariant(collectionId: string, variantId: string, params?: FindOrdersByAttributeParams): Promise<FindOrdersByAttributeResponse>;
512
+ /**
513
+ * Get individual order items (not full orders) for a specific batch.
514
+ * Returns all matching items with optional order summary.
515
+ *
516
+ * @param collectionId - Identifier of the parent collection
517
+ * @param batchId - Batch ID to search for
518
+ * @param params - Optional pagination and includeOrder parameters
519
+ * @returns Promise resolving to a FindItemsByAttributeResponse
520
+ * @throws ErrorResponse if the request fails
521
+ *
522
+ * @example
523
+ * ```typescript
524
+ * // Get items from a batch with order info
525
+ * const { items, count } = await order.findItemsByBatch('coll_123', 'BATCH-2024-001', {
526
+ * includeOrder: true,
527
+ * limit: 100
528
+ * })
529
+ *
530
+ * // Group by order status
531
+ * const byStatus = items.reduce((acc, item) => {
532
+ * const status = item.order?.status || 'unknown'
533
+ * acc[status] = (acc[status] || 0) + 1
534
+ * return acc
535
+ * }, {})
536
+ * ```
537
+ */
538
+ function findItemsByBatch(collectionId: string, batchId: string, params?: FindItemsByAttributeParams): Promise<FindItemsByAttributeResponse>;
539
+ /**
540
+ * Get individual order items for a specific product.
541
+ * Returns all matching items with optional order summary.
542
+ *
543
+ * @param collectionId - Identifier of the parent collection
544
+ * @param productId - Product ID to search for
545
+ * @param params - Optional pagination and includeOrder parameters
546
+ * @returns Promise resolving to a FindItemsByAttributeResponse
547
+ * @throws ErrorResponse if the request fails
548
+ *
549
+ * @example
550
+ * ```typescript
551
+ * // Get all items for a product
552
+ * const { items } = await order.findItemsByProduct('coll_123', 'prod_789', {
553
+ * includeOrder: true
554
+ * })
555
+ *
556
+ * console.log(`Product delivered in ${items.length} order items`)
557
+ * ```
558
+ */
559
+ function findItemsByProduct(collectionId: string, productId: string, params?: FindItemsByAttributeParams): Promise<FindItemsByAttributeResponse>;
560
+ /**
561
+ * Get individual order items for a specific variant.
562
+ * Returns all matching items with optional order summary.
563
+ *
564
+ * @param collectionId - Identifier of the parent collection
565
+ * @param variantId - Variant ID to search for
566
+ * @param params - Optional pagination and includeOrder parameters
567
+ * @returns Promise resolving to a FindItemsByAttributeResponse
568
+ * @throws ErrorResponse if the request fails
569
+ *
570
+ * @example
571
+ * ```typescript
572
+ * // Get variant items with order details
573
+ * const { items, count } = await order.findItemsByVariant('coll_123', 'var_456', {
574
+ * includeOrder: true,
575
+ * limit: 50
576
+ * })
577
+ * ```
578
+ */
579
+ function findItemsByVariant(collectionId: string, variantId: string, params?: FindItemsByAttributeParams): Promise<FindItemsByAttributeResponse>;
580
+ /**
581
+ * Get unique order IDs containing items matching the specified attribute.
582
+ * Lightweight query that only returns order IDs, not full order objects.
583
+ *
584
+ * @param collectionId - Identifier of the parent collection
585
+ * @param attribute - Attribute to search by ('batchId', 'productId', or 'variantId')
586
+ * @param value - Value to search for
587
+ * @param params - Optional pagination parameters
588
+ * @returns Promise resolving to a GetOrderIdsResponse
589
+ * @throws ErrorResponse if the request fails
590
+ *
591
+ * @example
592
+ * ```typescript
593
+ * // Get order IDs for a batch (fast count)
594
+ * const { orderIds, count } = await order.getOrderIdsByAttribute(
595
+ * 'coll_123',
596
+ * 'batchId',
597
+ * 'BATCH-2024-001'
598
+ * )
599
+ * console.log(`Batch appears in ${count} orders`)
600
+ *
601
+ * // Get order IDs for a product
602
+ * const productOrders = await order.getOrderIdsByAttribute(
603
+ * 'coll_123',
604
+ * 'productId',
605
+ * 'prod_789',
606
+ * { limit: 500 }
607
+ * )
608
+ * ```
609
+ */
610
+ function getOrderIdsByAttribute(collectionId: string, attribute: 'batchId' | 'productId' | 'variantId', value: string, params?: GetOrderIdsParams): Promise<GetOrderIdsResponse>;
446
611
  }
package/dist/api/order.js CHANGED
@@ -576,4 +576,251 @@ export var order;
576
576
  return post(path, params || {});
577
577
  }
578
578
  order.getCollectionSummary = getCollectionSummary;
579
+ /**
580
+ * Find all orders containing items from a specific batch.
581
+ * Uses indexed queries for fast lookups across order items.
582
+ *
583
+ * @param collectionId - Identifier of the parent collection
584
+ * @param batchId - Batch ID to search for
585
+ * @param params - Optional pagination and includeItems parameters
586
+ * @returns Promise resolving to a FindOrdersByAttributeResponse
587
+ * @throws ErrorResponse if the request fails
588
+ *
589
+ * @example
590
+ * ```typescript
591
+ * // Find orders with items from a specific batch
592
+ * const { orders } = await order.findByBatch('coll_123', 'BATCH-2024-001', {
593
+ * includeItems: true,
594
+ * limit: 50
595
+ * })
596
+ *
597
+ * // Get unique customers who received this batch
598
+ * const customers = [...new Set(orders.map(o => o.customerId).filter(Boolean))]
599
+ * console.log(`Batch delivered to ${customers.length} customers`)
600
+ * ```
601
+ */
602
+ async function findByBatch(collectionId, batchId, params) {
603
+ const queryParams = new URLSearchParams();
604
+ if (params === null || params === void 0 ? void 0 : params.limit)
605
+ queryParams.append('limit', params.limit.toString());
606
+ if (params === null || params === void 0 ? void 0 : params.offset)
607
+ queryParams.append('offset', params.offset.toString());
608
+ if (params === null || params === void 0 ? void 0 : params.includeItems)
609
+ queryParams.append('includeItems', 'true');
610
+ const query = queryParams.toString();
611
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/batch/${encodeURIComponent(batchId)}${query ? `?${query}` : ''}`;
612
+ return request(path);
613
+ }
614
+ order.findByBatch = findByBatch;
615
+ /**
616
+ * Find all orders containing items from a specific product.
617
+ * Uses indexed queries for fast lookups across order items.
618
+ *
619
+ * @param collectionId - Identifier of the parent collection
620
+ * @param productId - Product ID to search for
621
+ * @param params - Optional pagination and includeItems parameters
622
+ * @returns Promise resolving to a FindOrdersByAttributeResponse
623
+ * @throws ErrorResponse if the request fails
624
+ *
625
+ * @example
626
+ * ```typescript
627
+ * // Find all orders containing a product
628
+ * const { orders, limit, offset } = await order.findOrdersByProduct('coll_123', 'prod_789', {
629
+ * limit: 100
630
+ * })
631
+ *
632
+ * console.log(`Product appears in ${orders.length} orders`)
633
+ * ```
634
+ */
635
+ async function findOrdersByProduct(collectionId, productId, params) {
636
+ const queryParams = new URLSearchParams();
637
+ if (params === null || params === void 0 ? void 0 : params.limit)
638
+ queryParams.append('limit', params.limit.toString());
639
+ if (params === null || params === void 0 ? void 0 : params.offset)
640
+ queryParams.append('offset', params.offset.toString());
641
+ if (params === null || params === void 0 ? void 0 : params.includeItems)
642
+ queryParams.append('includeItems', 'true');
643
+ const query = queryParams.toString();
644
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/product/${encodeURIComponent(productId)}${query ? `?${query}` : ''}`;
645
+ return request(path);
646
+ }
647
+ order.findOrdersByProduct = findOrdersByProduct;
648
+ /**
649
+ * Find all orders containing items from a specific variant.
650
+ * Uses indexed queries for fast lookups across order items.
651
+ *
652
+ * @param collectionId - Identifier of the parent collection
653
+ * @param variantId - Variant ID to search for
654
+ * @param params - Optional pagination and includeItems parameters
655
+ * @returns Promise resolving to a FindOrdersByAttributeResponse
656
+ * @throws ErrorResponse if the request fails
657
+ *
658
+ * @example
659
+ * ```typescript
660
+ * // Find orders with a specific variant
661
+ * const { orders } = await order.findByVariant('coll_123', 'var_456', {
662
+ * includeItems: true
663
+ * })
664
+ *
665
+ * console.log(`Variant ${variantId} in ${orders.length} orders`)
666
+ * ```
667
+ */
668
+ async function findByVariant(collectionId, variantId, params) {
669
+ const queryParams = new URLSearchParams();
670
+ if (params === null || params === void 0 ? void 0 : params.limit)
671
+ queryParams.append('limit', params.limit.toString());
672
+ if (params === null || params === void 0 ? void 0 : params.offset)
673
+ queryParams.append('offset', params.offset.toString());
674
+ if (params === null || params === void 0 ? void 0 : params.includeItems)
675
+ queryParams.append('includeItems', 'true');
676
+ const query = queryParams.toString();
677
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/variant/${encodeURIComponent(variantId)}${query ? `?${query}` : ''}`;
678
+ return request(path);
679
+ }
680
+ order.findByVariant = findByVariant;
681
+ /**
682
+ * Get individual order items (not full orders) for a specific batch.
683
+ * Returns all matching items with optional order summary.
684
+ *
685
+ * @param collectionId - Identifier of the parent collection
686
+ * @param batchId - Batch ID to search for
687
+ * @param params - Optional pagination and includeOrder parameters
688
+ * @returns Promise resolving to a FindItemsByAttributeResponse
689
+ * @throws ErrorResponse if the request fails
690
+ *
691
+ * @example
692
+ * ```typescript
693
+ * // Get items from a batch with order info
694
+ * const { items, count } = await order.findItemsByBatch('coll_123', 'BATCH-2024-001', {
695
+ * includeOrder: true,
696
+ * limit: 100
697
+ * })
698
+ *
699
+ * // Group by order status
700
+ * const byStatus = items.reduce((acc, item) => {
701
+ * const status = item.order?.status || 'unknown'
702
+ * acc[status] = (acc[status] || 0) + 1
703
+ * return acc
704
+ * }, {})
705
+ * ```
706
+ */
707
+ async function findItemsByBatch(collectionId, batchId, params) {
708
+ const queryParams = new URLSearchParams();
709
+ if (params === null || params === void 0 ? void 0 : params.limit)
710
+ queryParams.append('limit', params.limit.toString());
711
+ if (params === null || params === void 0 ? void 0 : params.offset)
712
+ queryParams.append('offset', params.offset.toString());
713
+ if (params === null || params === void 0 ? void 0 : params.includeOrder)
714
+ queryParams.append('includeOrder', 'true');
715
+ const query = queryParams.toString();
716
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/batch/${encodeURIComponent(batchId)}/items${query ? `?${query}` : ''}`;
717
+ return request(path);
718
+ }
719
+ order.findItemsByBatch = findItemsByBatch;
720
+ /**
721
+ * Get individual order items for a specific product.
722
+ * Returns all matching items with optional order summary.
723
+ *
724
+ * @param collectionId - Identifier of the parent collection
725
+ * @param productId - Product ID to search for
726
+ * @param params - Optional pagination and includeOrder parameters
727
+ * @returns Promise resolving to a FindItemsByAttributeResponse
728
+ * @throws ErrorResponse if the request fails
729
+ *
730
+ * @example
731
+ * ```typescript
732
+ * // Get all items for a product
733
+ * const { items } = await order.findItemsByProduct('coll_123', 'prod_789', {
734
+ * includeOrder: true
735
+ * })
736
+ *
737
+ * console.log(`Product delivered in ${items.length} order items`)
738
+ * ```
739
+ */
740
+ async function findItemsByProduct(collectionId, productId, params) {
741
+ const queryParams = new URLSearchParams();
742
+ if (params === null || params === void 0 ? void 0 : params.limit)
743
+ queryParams.append('limit', params.limit.toString());
744
+ if (params === null || params === void 0 ? void 0 : params.offset)
745
+ queryParams.append('offset', params.offset.toString());
746
+ if (params === null || params === void 0 ? void 0 : params.includeOrder)
747
+ queryParams.append('includeOrder', 'true');
748
+ const query = queryParams.toString();
749
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/product/${encodeURIComponent(productId)}/items${query ? `?${query}` : ''}`;
750
+ return request(path);
751
+ }
752
+ order.findItemsByProduct = findItemsByProduct;
753
+ /**
754
+ * Get individual order items for a specific variant.
755
+ * Returns all matching items with optional order summary.
756
+ *
757
+ * @param collectionId - Identifier of the parent collection
758
+ * @param variantId - Variant ID to search for
759
+ * @param params - Optional pagination and includeOrder parameters
760
+ * @returns Promise resolving to a FindItemsByAttributeResponse
761
+ * @throws ErrorResponse if the request fails
762
+ *
763
+ * @example
764
+ * ```typescript
765
+ * // Get variant items with order details
766
+ * const { items, count } = await order.findItemsByVariant('coll_123', 'var_456', {
767
+ * includeOrder: true,
768
+ * limit: 50
769
+ * })
770
+ * ```
771
+ */
772
+ async function findItemsByVariant(collectionId, variantId, params) {
773
+ const queryParams = new URLSearchParams();
774
+ if (params === null || params === void 0 ? void 0 : params.limit)
775
+ queryParams.append('limit', params.limit.toString());
776
+ if (params === null || params === void 0 ? void 0 : params.offset)
777
+ queryParams.append('offset', params.offset.toString());
778
+ if (params === null || params === void 0 ? void 0 : params.includeOrder)
779
+ queryParams.append('includeOrder', 'true');
780
+ const query = queryParams.toString();
781
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/variant/${encodeURIComponent(variantId)}/items${query ? `?${query}` : ''}`;
782
+ return request(path);
783
+ }
784
+ order.findItemsByVariant = findItemsByVariant;
785
+ /**
786
+ * Get unique order IDs containing items matching the specified attribute.
787
+ * Lightweight query that only returns order IDs, not full order objects.
788
+ *
789
+ * @param collectionId - Identifier of the parent collection
790
+ * @param attribute - Attribute to search by ('batchId', 'productId', or 'variantId')
791
+ * @param value - Value to search for
792
+ * @param params - Optional pagination parameters
793
+ * @returns Promise resolving to a GetOrderIdsResponse
794
+ * @throws ErrorResponse if the request fails
795
+ *
796
+ * @example
797
+ * ```typescript
798
+ * // Get order IDs for a batch (fast count)
799
+ * const { orderIds, count } = await order.getOrderIdsByAttribute(
800
+ * 'coll_123',
801
+ * 'batchId',
802
+ * 'BATCH-2024-001'
803
+ * )
804
+ * console.log(`Batch appears in ${count} orders`)
805
+ *
806
+ * // Get order IDs for a product
807
+ * const productOrders = await order.getOrderIdsByAttribute(
808
+ * 'coll_123',
809
+ * 'productId',
810
+ * 'prod_789',
811
+ * { limit: 500 }
812
+ * )
813
+ * ```
814
+ */
815
+ async function getOrderIdsByAttribute(collectionId, attribute, value, params) {
816
+ const queryParams = new URLSearchParams();
817
+ if (params === null || params === void 0 ? void 0 : params.limit)
818
+ queryParams.append('limit', params.limit.toString());
819
+ if (params === null || params === void 0 ? void 0 : params.offset)
820
+ queryParams.append('offset', params.offset.toString());
821
+ const query = queryParams.toString();
822
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/ids/${attribute}/${encodeURIComponent(value)}${query ? `?${query}` : ''}`;
823
+ return request(path);
824
+ }
825
+ order.getOrderIdsByAttribute = getOrderIdsByAttribute;
579
826
  })(order || (order = {}));