@proveanything/smartlinks 1.7.5 → 1.7.6
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/dist/api/order.d.ts +16 -105
- package/dist/api/order.js +22 -152
- package/dist/docs/API_SUMMARY.md +28 -33
- package/dist/openapi.yaml +65 -165
- package/dist/types/order.d.ts +29 -15
- package/docs/API_SUMMARY.md +28 -33
- package/openapi.yaml +65 -165
- package/package.json +1 -1
package/dist/api/order.d.ts
CHANGED
|
@@ -220,7 +220,7 @@ export declare namespace order {
|
|
|
220
220
|
*/
|
|
221
221
|
function lookup(collectionId: string, data: LookupOrdersRequest): Promise<LookupOrdersResponse>;
|
|
222
222
|
/**
|
|
223
|
-
* Advanced query for orders with
|
|
223
|
+
* Advanced query for orders with order-level and item-level filtering.
|
|
224
224
|
* More powerful than the basic list() function.
|
|
225
225
|
*
|
|
226
226
|
* @param collectionId - Identifier of the parent collection
|
|
@@ -251,6 +251,17 @@ export declare namespace order {
|
|
|
251
251
|
* },
|
|
252
252
|
* includeItems: true
|
|
253
253
|
* })
|
|
254
|
+
*
|
|
255
|
+
* // Find orders containing a specific product batch
|
|
256
|
+
* const batchOrders = await order.query('coll_123', {
|
|
257
|
+
* query: {
|
|
258
|
+
* item: {
|
|
259
|
+
* productId: 'prod_789',
|
|
260
|
+
* batchId: 'BATCH-2024-001'
|
|
261
|
+
* }
|
|
262
|
+
* },
|
|
263
|
+
* includeItems: true
|
|
264
|
+
* })
|
|
254
265
|
* ```
|
|
255
266
|
*/
|
|
256
267
|
function query(collectionId: string, data: QueryOrdersRequest): Promise<QueryOrdersResponse>;
|
|
@@ -443,30 +454,6 @@ export declare namespace order {
|
|
|
443
454
|
* ```
|
|
444
455
|
*/
|
|
445
456
|
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
457
|
/**
|
|
471
458
|
* Find all orders containing items from a specific product.
|
|
472
459
|
* Uses indexed queries for fast lookups across order items.
|
|
@@ -488,54 +475,6 @@ export declare namespace order {
|
|
|
488
475
|
* ```
|
|
489
476
|
*/
|
|
490
477
|
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
478
|
/**
|
|
540
479
|
* Get individual order items for a specific product.
|
|
541
480
|
* Returns all matching items with optional order summary.
|
|
@@ -558,46 +497,18 @@ export declare namespace order {
|
|
|
558
497
|
*/
|
|
559
498
|
function findItemsByProduct(collectionId: string, productId: string, params?: FindItemsByAttributeParams): Promise<FindItemsByAttributeResponse>;
|
|
560
499
|
/**
|
|
561
|
-
* Get
|
|
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.
|
|
500
|
+
* Get unique order IDs containing items for a specific product.
|
|
582
501
|
* Lightweight query that only returns order IDs, not full order objects.
|
|
583
502
|
*
|
|
584
503
|
* @param collectionId - Identifier of the parent collection
|
|
585
|
-
* @param attribute - Attribute to search by ('
|
|
586
|
-
* @param value -
|
|
504
|
+
* @param attribute - Attribute to search by ('productId')
|
|
505
|
+
* @param value - Product ID to search for
|
|
587
506
|
* @param params - Optional pagination parameters
|
|
588
507
|
* @returns Promise resolving to a GetOrderIdsResponse
|
|
589
508
|
* @throws ErrorResponse if the request fails
|
|
590
509
|
*
|
|
591
510
|
* @example
|
|
592
511
|
* ```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
512
|
* // Get order IDs for a product
|
|
602
513
|
* const productOrders = await order.getOrderIdsByAttribute(
|
|
603
514
|
* 'coll_123',
|
|
@@ -607,5 +518,5 @@ export declare namespace order {
|
|
|
607
518
|
* )
|
|
608
519
|
* ```
|
|
609
520
|
*/
|
|
610
|
-
function getOrderIdsByAttribute(collectionId: string, attribute: '
|
|
521
|
+
function getOrderIdsByAttribute(collectionId: string, attribute: 'productId', value: string, params?: GetOrderIdsParams): Promise<GetOrderIdsResponse>;
|
|
611
522
|
}
|
package/dist/api/order.js
CHANGED
|
@@ -286,8 +286,14 @@ export var order;
|
|
|
286
286
|
return post(path, data);
|
|
287
287
|
}
|
|
288
288
|
order.lookup = lookup;
|
|
289
|
+
function validateOrderQuery(data) {
|
|
290
|
+
var _a;
|
|
291
|
+
if (((_a = data.query) === null || _a === void 0 ? void 0 : _a.item) && !data.query.item.productId) {
|
|
292
|
+
throw new Error('query.item.productId is required when using item-level order filters');
|
|
293
|
+
}
|
|
294
|
+
}
|
|
289
295
|
/**
|
|
290
|
-
* Advanced query for orders with
|
|
296
|
+
* Advanced query for orders with order-level and item-level filtering.
|
|
291
297
|
* More powerful than the basic list() function.
|
|
292
298
|
*
|
|
293
299
|
* @param collectionId - Identifier of the parent collection
|
|
@@ -318,9 +324,21 @@ export var order;
|
|
|
318
324
|
* },
|
|
319
325
|
* includeItems: true
|
|
320
326
|
* })
|
|
327
|
+
*
|
|
328
|
+
* // Find orders containing a specific product batch
|
|
329
|
+
* const batchOrders = await order.query('coll_123', {
|
|
330
|
+
* query: {
|
|
331
|
+
* item: {
|
|
332
|
+
* productId: 'prod_789',
|
|
333
|
+
* batchId: 'BATCH-2024-001'
|
|
334
|
+
* }
|
|
335
|
+
* },
|
|
336
|
+
* includeItems: true
|
|
337
|
+
* })
|
|
321
338
|
* ```
|
|
322
339
|
*/
|
|
323
340
|
async function query(collectionId, data) {
|
|
341
|
+
validateOrderQuery(data);
|
|
324
342
|
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/query`;
|
|
325
343
|
return post(path, data);
|
|
326
344
|
}
|
|
@@ -576,42 +594,6 @@ export var order;
|
|
|
576
594
|
return post(path, params || {});
|
|
577
595
|
}
|
|
578
596
|
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
597
|
/**
|
|
616
598
|
* Find all orders containing items from a specific product.
|
|
617
599
|
* Uses indexed queries for fast lookups across order items.
|
|
@@ -645,78 +627,6 @@ export var order;
|
|
|
645
627
|
return request(path);
|
|
646
628
|
}
|
|
647
629
|
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
630
|
/**
|
|
721
631
|
* Get individual order items for a specific product.
|
|
722
632
|
* Returns all matching items with optional order summary.
|
|
@@ -751,58 +661,18 @@ export var order;
|
|
|
751
661
|
}
|
|
752
662
|
order.findItemsByProduct = findItemsByProduct;
|
|
753
663
|
/**
|
|
754
|
-
* Get
|
|
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.
|
|
664
|
+
* Get unique order IDs containing items for a specific product.
|
|
787
665
|
* Lightweight query that only returns order IDs, not full order objects.
|
|
788
666
|
*
|
|
789
667
|
* @param collectionId - Identifier of the parent collection
|
|
790
|
-
* @param attribute - Attribute to search by ('
|
|
791
|
-
* @param value -
|
|
668
|
+
* @param attribute - Attribute to search by ('productId')
|
|
669
|
+
* @param value - Product ID to search for
|
|
792
670
|
* @param params - Optional pagination parameters
|
|
793
671
|
* @returns Promise resolving to a GetOrderIdsResponse
|
|
794
672
|
* @throws ErrorResponse if the request fails
|
|
795
673
|
*
|
|
796
674
|
* @example
|
|
797
675
|
* ```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
676
|
* // Get order IDs for a product
|
|
807
677
|
* const productOrders = await order.getOrderIdsByAttribute(
|
|
808
678
|
* 'coll_123',
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.6 | Generated: 2026-03-12T15:07:14.383Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -4400,23 +4400,38 @@ interface GetOrderItemsResponse {
|
|
|
4400
4400
|
}
|
|
4401
4401
|
```
|
|
4402
4402
|
|
|
4403
|
-
**
|
|
4403
|
+
**QueryOrderItemFilter** (interface)
|
|
4404
4404
|
```typescript
|
|
4405
|
-
interface
|
|
4406
|
-
|
|
4405
|
+
interface QueryOrderItemFilter {
|
|
4406
|
+
productId: string
|
|
4407
|
+
batchId?: string
|
|
4408
|
+
variantId?: string
|
|
4409
|
+
}
|
|
4410
|
+
```
|
|
4411
|
+
|
|
4412
|
+
**QueryOrdersFilter** (interface)
|
|
4413
|
+
```typescript
|
|
4414
|
+
interface QueryOrdersFilter {
|
|
4407
4415
|
status?: string
|
|
4408
4416
|
orderRef?: string
|
|
4409
4417
|
customerId?: string
|
|
4410
|
-
createdAfter?: string
|
|
4411
|
-
createdBefore?: string
|
|
4412
|
-
updatedAfter?: string
|
|
4413
|
-
updatedBefore?: string
|
|
4418
|
+
createdAfter?: string // ISO 8601 date
|
|
4419
|
+
createdBefore?: string // ISO 8601 date
|
|
4420
|
+
updatedAfter?: string // ISO 8601 date
|
|
4421
|
+
updatedBefore?: string // ISO 8601 date
|
|
4414
4422
|
minItemCount?: number
|
|
4415
4423
|
maxItemCount?: number
|
|
4416
4424
|
metadata?: Record<string, any>
|
|
4425
|
+
item?: QueryOrderItemFilter
|
|
4417
4426
|
sortBy?: string
|
|
4418
4427
|
sortOrder?: 'asc' | 'desc'
|
|
4419
|
-
|
|
4428
|
+
}
|
|
4429
|
+
```
|
|
4430
|
+
|
|
4431
|
+
**QueryOrdersRequest** (interface)
|
|
4432
|
+
```typescript
|
|
4433
|
+
interface QueryOrdersRequest {
|
|
4434
|
+
query?: QueryOrdersFilter
|
|
4420
4435
|
limit?: number // Optional: Max results (default: 100)
|
|
4421
4436
|
offset?: number // Optional: Pagination offset (default: 0)
|
|
4422
4437
|
includeItems?: boolean // Optional: Include items array (default: false)
|
|
@@ -4537,7 +4552,7 @@ interface GetOrderIdsParams {
|
|
|
4537
4552
|
interface GetOrderIdsResponse {
|
|
4538
4553
|
orderIds: string[]
|
|
4539
4554
|
count: number
|
|
4540
|
-
attribute: '
|
|
4555
|
+
attribute: 'productId'
|
|
4541
4556
|
value: string
|
|
4542
4557
|
}
|
|
4543
4558
|
```
|
|
@@ -6308,7 +6323,7 @@ Find all orders containing specific items (tags, proofs, or serial numbers). Use
|
|
|
6308
6323
|
|
|
6309
6324
|
**query**(collectionId: string,
|
|
6310
6325
|
data: QueryOrdersRequest) → `Promise<QueryOrdersResponse>`
|
|
6311
|
-
Advanced query for orders with
|
|
6326
|
+
Advanced query for orders with order-level and item-level filtering. More powerful than the basic list() function. ```typescript // Find pending orders created in January 2026 const result = await order.query('coll_123', { query: { status: 'pending', createdAfter: '2026-01-01T00:00:00Z', createdBefore: '2026-02-01T00:00:00Z', sortBy: 'createdAt', sortOrder: 'desc' }, limit: 50 }) // Find orders with specific metadata and item count const highPriority = await order.query('coll_123', { query: { metadata: { priority: 'high' }, minItemCount: 10, maxItemCount: 100 }, includeItems: true }) // Find orders containing a specific product batch const batchOrders = await order.query('coll_123', { query: { item: { productId: 'prod_789', batchId: 'BATCH-2024-001' } }, includeItems: true }) ```
|
|
6312
6327
|
|
|
6313
6328
|
**reports**(collectionId: string,
|
|
6314
6329
|
params?: ReportsParams) → `Promise<ReportsResponse>`
|
|
@@ -6341,41 +6356,21 @@ Get analytics summary for multiple orders at once. Efficient way to retrieve sca
|
|
|
6341
6356
|
params?: SummaryRequest) → `Promise<CollectionSummaryResponse>`
|
|
6342
6357
|
Get collection-wide analytics summary across all orders. Returns daily scan counts and admin activity overview. ```typescript // Get all-time collection summary const summary = await order.getCollectionSummary('coll_123') console.log(`Admin activity count: ${summary.adminActivity.count}`) console.log('Scans by day:') summary.scansByDay.forEach(day => { console.log(` ${day.date}: ${day.scanCount} scans`) }) // Get summary for last 30 days const recentSummary = await order.getCollectionSummary('coll_123', { from: '2026-01-08T00:00:00Z', to: '2026-02-08T00:00:00Z' }) ```
|
|
6343
6358
|
|
|
6344
|
-
**findByBatch**(collectionId: string,
|
|
6345
|
-
batchId: string,
|
|
6346
|
-
params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
|
|
6347
|
-
Find all orders containing items from a specific batch. Uses indexed queries for fast lookups across order items. ```typescript // Find orders with items from a specific batch const { orders } = await order.findByBatch('coll_123', 'BATCH-2024-001', { includeItems: true, limit: 50 }) // Get unique customers who received this batch const customers = [...new Set(orders.map(o => o.customerId).filter(Boolean))] console.log(`Batch delivered to ${customers.length} customers`) ```
|
|
6348
|
-
|
|
6349
6359
|
**findOrdersByProduct**(collectionId: string,
|
|
6350
6360
|
productId: string,
|
|
6351
6361
|
params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
|
|
6352
6362
|
Find all orders containing items from a specific product. Uses indexed queries for fast lookups across order items. ```typescript // Find all orders containing a product const { orders, limit, offset } = await order.findOrdersByProduct('coll_123', 'prod_789', { limit: 100 }) console.log(`Product appears in ${orders.length} orders`) ```
|
|
6353
6363
|
|
|
6354
|
-
**findByVariant**(collectionId: string,
|
|
6355
|
-
variantId: string,
|
|
6356
|
-
params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
|
|
6357
|
-
Find all orders containing items from a specific variant. Uses indexed queries for fast lookups across order items. ```typescript // Find orders with a specific variant const { orders } = await order.findByVariant('coll_123', 'var_456', { includeItems: true }) console.log(`Variant ${variantId} in ${orders.length} orders`) ```
|
|
6358
|
-
|
|
6359
|
-
**findItemsByBatch**(collectionId: string,
|
|
6360
|
-
batchId: string,
|
|
6361
|
-
params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
|
|
6362
|
-
Get individual order items (not full orders) for a specific batch. Returns all matching items with optional order summary. ```typescript // Get items from a batch with order info const { items, count } = await order.findItemsByBatch('coll_123', 'BATCH-2024-001', { includeOrder: true, limit: 100 }) // Group by order status const byStatus = items.reduce((acc, item) => { const status = item.order?.status || 'unknown' acc[status] = (acc[status] || 0) + 1 return acc }, {}) ```
|
|
6363
|
-
|
|
6364
6364
|
**findItemsByProduct**(collectionId: string,
|
|
6365
6365
|
productId: string,
|
|
6366
6366
|
params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
|
|
6367
6367
|
Get individual order items for a specific product. Returns all matching items with optional order summary. ```typescript // Get all items for a product const { items } = await order.findItemsByProduct('coll_123', 'prod_789', { includeOrder: true }) console.log(`Product delivered in ${items.length} order items`) ```
|
|
6368
6368
|
|
|
6369
|
-
**findItemsByVariant**(collectionId: string,
|
|
6370
|
-
variantId: string,
|
|
6371
|
-
params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
|
|
6372
|
-
Get individual order items for a specific variant. Returns all matching items with optional order summary. ```typescript // Get variant items with order details const { items, count } = await order.findItemsByVariant('coll_123', 'var_456', { includeOrder: true, limit: 50 }) ```
|
|
6373
|
-
|
|
6374
6369
|
**getOrderIdsByAttribute**(collectionId: string,
|
|
6375
|
-
attribute: '
|
|
6370
|
+
attribute: 'productId',
|
|
6376
6371
|
value: string,
|
|
6377
6372
|
params?: GetOrderIdsParams) → `Promise<GetOrderIdsResponse>`
|
|
6378
|
-
Get unique order IDs containing items
|
|
6373
|
+
Get unique order IDs containing items for a specific product. Lightweight query that only returns order IDs, not full order objects. ```typescript // Get order IDs for a product const productOrders = await order.getOrderIdsByAttribute( 'coll_123', 'productId', 'prod_789', { limit: 500 } ) ```
|
|
6379
6374
|
|
|
6380
6375
|
### product
|
|
6381
6376
|
|