@proveanything/smartlinks 1.3.19 → 1.3.21

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,22 +1,111 @@
1
+ import { GetCrateResponse, CreateCrateRequest, CreateCrateResponse, UpdateCrateRequest, UpdateCrateResponse, DeleteCrateResponse, ListCratesRequest, ListCratesResponse } from "../types/crate";
2
+ /**
3
+ * Crate Management API
4
+ *
5
+ * Manage crates (containers for tags/products) within collections.
6
+ */
1
7
  export declare namespace crate {
2
8
  /**
3
- * Get a single crate by ID for a collection (admin only).
9
+ * List crates for a collection with pagination support.
10
+ * Returns crates in pages, with support for soft-deleted crates.
11
+ *
12
+ * @param collectionId - Identifier of the parent collection
13
+ * @param params - Optional query parameters for pagination and filtering
14
+ * @returns Promise resolving to a ListCratesResponse object
15
+ * @throws ErrorResponse if the request fails
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Get first page
20
+ * const page1 = await crate.list('coll_123', { limit: 100 })
21
+ * console.log(`Found ${page1.items.length} crates`)
22
+ *
23
+ * // Get next page
24
+ * if (page1.hasMore) {
25
+ * const page2 = await crate.list('coll_123', {
26
+ * limit: 100,
27
+ * startAfter: page1.lastId
28
+ * })
29
+ * }
30
+ *
31
+ * // Include soft-deleted crates
32
+ * const withDeleted = await crate.list('coll_123', {
33
+ * includeDeleted: true
34
+ * })
35
+ * ```
4
36
  */
5
- function get(collectionId: string, crateId: string): Promise<any>;
37
+ function list(collectionId: string, params?: ListCratesRequest): Promise<ListCratesResponse>;
6
38
  /**
7
- * List all crates for a collection (admin only).
39
+ * Get a single crate by ID for a collection (admin only).
40
+ *
41
+ * @param collectionId - Identifier of the parent collection
42
+ * @param crateId - Crate ID
43
+ * @returns Promise resolving to a GetCrateResponse object
44
+ * @throws ErrorResponse if the request fails
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const crate = await crate.get('coll_123', 'crate_abc123')
49
+ * console.log(`Crate has ${crate.items?.length ?? 0} items`)
50
+ * ```
8
51
  */
9
- function list(collectionId: string): Promise<any[]>;
52
+ function get(collectionId: string, crateId: string): Promise<GetCrateResponse>;
10
53
  /**
11
54
  * Create a new crate for a collection (admin only).
55
+ *
56
+ * @param collectionId - Identifier of the parent collection
57
+ * @param data - Crate creation data
58
+ * @returns Promise resolving to a CreateCrateResponse object
59
+ * @throws ErrorResponse if the request fails
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const newCrate = await crate.create('coll_123', {
64
+ * items: [
65
+ * {
66
+ * id: 'tag_001',
67
+ * codeId: 'ABC123',
68
+ * productId: 'prod_1',
69
+ * productName: 'Product Name'
70
+ * }
71
+ * ]
72
+ * })
73
+ * console.log(`Created crate ${newCrate.id}`)
74
+ * ```
12
75
  */
13
- function create(collectionId: string, data: any): Promise<any>;
76
+ function create(collectionId: string, data: CreateCrateRequest): Promise<CreateCrateResponse>;
14
77
  /**
15
78
  * Update a crate for a collection (admin only).
79
+ *
80
+ * @param collectionId - Identifier of the parent collection
81
+ * @param crateId - Crate ID
82
+ * @param data - Update data
83
+ * @returns Promise resolving to an UpdateCrateResponse object
84
+ * @throws ErrorResponse if the request fails
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const updated = await crate.update('coll_123', 'crate_abc123', {
89
+ * items: [
90
+ * { id: 'tag_002', codeId: 'XYZ789', productId: 'prod_2' }
91
+ * ]
92
+ * })
93
+ * ```
16
94
  */
17
- function update(collectionId: string, crateId: string, data: any): Promise<any>;
95
+ function update(collectionId: string, crateId: string, data: UpdateCrateRequest): Promise<UpdateCrateResponse>;
18
96
  /**
19
97
  * Delete a crate for a collection (admin only).
98
+ * This performs a soft delete.
99
+ *
100
+ * @param collectionId - Identifier of the parent collection
101
+ * @param crateId - Crate ID
102
+ * @returns Promise resolving to a DeleteCrateResponse object
103
+ * @throws ErrorResponse if the request fails
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * await crate.remove('coll_123', 'crate_abc123')
108
+ * ```
20
109
  */
21
- function remove(collectionId: string, crateId: string): Promise<void>;
110
+ function remove(collectionId: string, crateId: string): Promise<DeleteCrateResponse>;
22
111
  }
package/dist/api/crate.js CHANGED
@@ -1,24 +1,94 @@
1
1
  import { request, post, put, del } from "../http";
2
+ /**
3
+ * Crate Management API
4
+ *
5
+ * Manage crates (containers for tags/products) within collections.
6
+ */
2
7
  export var crate;
3
8
  (function (crate) {
4
9
  /**
5
- * Get a single crate by ID for a collection (admin only).
10
+ * List crates for a collection with pagination support.
11
+ * Returns crates in pages, with support for soft-deleted crates.
12
+ *
13
+ * @param collectionId - Identifier of the parent collection
14
+ * @param params - Optional query parameters for pagination and filtering
15
+ * @returns Promise resolving to a ListCratesResponse object
16
+ * @throws ErrorResponse if the request fails
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Get first page
21
+ * const page1 = await crate.list('coll_123', { limit: 100 })
22
+ * console.log(`Found ${page1.items.length} crates`)
23
+ *
24
+ * // Get next page
25
+ * if (page1.hasMore) {
26
+ * const page2 = await crate.list('coll_123', {
27
+ * limit: 100,
28
+ * startAfter: page1.lastId
29
+ * })
30
+ * }
31
+ *
32
+ * // Include soft-deleted crates
33
+ * const withDeleted = await crate.list('coll_123', {
34
+ * includeDeleted: true
35
+ * })
36
+ * ```
6
37
  */
7
- async function get(collectionId, crateId) {
8
- const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate/${encodeURIComponent(crateId)}`;
38
+ async function list(collectionId, params) {
39
+ const queryParams = new URLSearchParams();
40
+ if (params === null || params === void 0 ? void 0 : params.limit)
41
+ queryParams.append('limit', params.limit.toString());
42
+ if (params === null || params === void 0 ? void 0 : params.startAfter)
43
+ queryParams.append('startAfter', params.startAfter);
44
+ if (params === null || params === void 0 ? void 0 : params.includeDeleted)
45
+ queryParams.append('includeDeleted', 'true');
46
+ const query = queryParams.toString();
47
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate${query ? `?${query}` : ''}`;
9
48
  return request(path);
10
49
  }
11
- crate.get = get;
50
+ crate.list = list;
12
51
  /**
13
- * List all crates for a collection (admin only).
52
+ * Get a single crate by ID for a collection (admin only).
53
+ *
54
+ * @param collectionId - Identifier of the parent collection
55
+ * @param crateId - Crate ID
56
+ * @returns Promise resolving to a GetCrateResponse object
57
+ * @throws ErrorResponse if the request fails
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const crate = await crate.get('coll_123', 'crate_abc123')
62
+ * console.log(`Crate has ${crate.items?.length ?? 0} items`)
63
+ * ```
14
64
  */
15
- async function list(collectionId) {
16
- const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate`;
65
+ async function get(collectionId, crateId) {
66
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate/${encodeURIComponent(crateId)}`;
17
67
  return request(path);
18
68
  }
19
- crate.list = list;
69
+ crate.get = get;
20
70
  /**
21
71
  * Create a new crate for a collection (admin only).
72
+ *
73
+ * @param collectionId - Identifier of the parent collection
74
+ * @param data - Crate creation data
75
+ * @returns Promise resolving to a CreateCrateResponse object
76
+ * @throws ErrorResponse if the request fails
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const newCrate = await crate.create('coll_123', {
81
+ * items: [
82
+ * {
83
+ * id: 'tag_001',
84
+ * codeId: 'ABC123',
85
+ * productId: 'prod_1',
86
+ * productName: 'Product Name'
87
+ * }
88
+ * ]
89
+ * })
90
+ * console.log(`Created crate ${newCrate.id}`)
91
+ * ```
22
92
  */
23
93
  async function create(collectionId, data) {
24
94
  const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate`;
@@ -27,6 +97,21 @@ export var crate;
27
97
  crate.create = create;
28
98
  /**
29
99
  * Update a crate for a collection (admin only).
100
+ *
101
+ * @param collectionId - Identifier of the parent collection
102
+ * @param crateId - Crate ID
103
+ * @param data - Update data
104
+ * @returns Promise resolving to an UpdateCrateResponse object
105
+ * @throws ErrorResponse if the request fails
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const updated = await crate.update('coll_123', 'crate_abc123', {
110
+ * items: [
111
+ * { id: 'tag_002', codeId: 'XYZ789', productId: 'prod_2' }
112
+ * ]
113
+ * })
114
+ * ```
30
115
  */
31
116
  async function update(collectionId, crateId, data) {
32
117
  const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate/${encodeURIComponent(crateId)}`;
@@ -35,6 +120,17 @@ export var crate;
35
120
  crate.update = update;
36
121
  /**
37
122
  * Delete a crate for a collection (admin only).
123
+ * This performs a soft delete.
124
+ *
125
+ * @param collectionId - Identifier of the parent collection
126
+ * @param crateId - Crate ID
127
+ * @returns Promise resolving to a DeleteCrateResponse object
128
+ * @throws ErrorResponse if the request fails
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * await crate.remove('coll_123', 'crate_abc123')
133
+ * ```
38
134
  */
39
135
  async function remove(collectionId, crateId) {
40
136
  const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate/${encodeURIComponent(crateId)}`;
@@ -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
  }