@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.
- package/dist/api/batch.d.ts +81 -1
- package/dist/api/batch.js +104 -0
- package/dist/api/order.d.ts +166 -1
- package/dist/api/order.js +247 -0
- package/dist/docs/API_SUMMARY.md +186 -5
- package/dist/types/batch.d.ts +46 -3
- package/dist/types/interaction.d.ts +6 -0
- package/dist/types/order.d.ts +64 -0
- package/docs/API_SUMMARY.md +186 -5
- package/package.json +1 -1
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.22 | Generated: 2026-02-13T10:45:57.755Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -625,11 +625,66 @@ interface AuthKitConfig {
|
|
|
625
625
|
|
|
626
626
|
### batch
|
|
627
627
|
|
|
628
|
-
**
|
|
628
|
+
**FirebaseTimestamp** (interface)
|
|
629
|
+
```typescript
|
|
630
|
+
interface FirebaseTimestamp {
|
|
631
|
+
seconds: number // Unix timestamp in seconds
|
|
632
|
+
nanoseconds?: number // Nanoseconds component
|
|
633
|
+
}
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
**BatchResponse** (interface)
|
|
637
|
+
```typescript
|
|
638
|
+
interface BatchResponse {
|
|
639
|
+
id: string // Batch ID
|
|
640
|
+
name?: string // Batch name
|
|
641
|
+
expiryDate?: FirebaseTimestamp | string // Firebase timestamp or ISO 8601 date
|
|
642
|
+
productId?: string // Product ID (for collection-level searches)
|
|
643
|
+
collectionId?: string // Collection ID
|
|
644
|
+
[key: string]: any // Additional batch fields
|
|
645
|
+
}
|
|
646
|
+
```
|
|
629
647
|
|
|
630
|
-
**BatchCreateRequest**
|
|
648
|
+
**BatchCreateRequest** (interface)
|
|
649
|
+
```typescript
|
|
650
|
+
interface BatchCreateRequest {
|
|
651
|
+
id: string // Batch ID
|
|
652
|
+
name?: string // Batch name
|
|
653
|
+
expiryDate?: FirebaseTimestamp | string // Firebase timestamp or ISO 8601 date
|
|
654
|
+
[key: string]: any // Additional batch fields
|
|
655
|
+
}
|
|
656
|
+
```
|
|
631
657
|
|
|
632
|
-
**BatchUpdateRequest**
|
|
658
|
+
**BatchUpdateRequest** (interface)
|
|
659
|
+
```typescript
|
|
660
|
+
interface BatchUpdateRequest {
|
|
661
|
+
name?: string // Batch name
|
|
662
|
+
expiryDate?: FirebaseTimestamp | string // Firebase timestamp or ISO 8601 date
|
|
663
|
+
[key: string]: any // Additional batch fields
|
|
664
|
+
}
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
**SearchBatchesRequest** (interface)
|
|
668
|
+
```typescript
|
|
669
|
+
interface SearchBatchesRequest {
|
|
670
|
+
search?: string // Search term (batch ID or name)
|
|
671
|
+
productId?: string // Filter by specific product
|
|
672
|
+
limit?: number // Max results (default: 100)
|
|
673
|
+
}
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
**BatchTag** (interface)
|
|
677
|
+
```typescript
|
|
678
|
+
interface BatchTag {
|
|
679
|
+
code: string // Code/tag ID
|
|
680
|
+
claimSetId: string // Claim set ID
|
|
681
|
+
collectionId?: string // Collection ID
|
|
682
|
+
productId?: string // Associated product ID
|
|
683
|
+
batchId?: string // Batch ID
|
|
684
|
+
tagId?: string // Tag identifier
|
|
685
|
+
index?: number // Position in claim set
|
|
686
|
+
}
|
|
687
|
+
```
|
|
633
688
|
|
|
634
689
|
### broadcasts
|
|
635
690
|
|
|
@@ -1741,6 +1796,7 @@ interface AdminInteractionsQueryRequest {
|
|
|
1741
1796
|
contactId?: string
|
|
1742
1797
|
appId?: string
|
|
1743
1798
|
interactionId?: string
|
|
1799
|
+
scope?: string
|
|
1744
1800
|
interactionIds?: string[]
|
|
1745
1801
|
broadcastId?: string
|
|
1746
1802
|
outcome?: string | null
|
|
@@ -1759,6 +1815,7 @@ interface AdminInteractionsQueryRequest {
|
|
|
1759
1815
|
interface AdminInteractionsCountsByOutcomeRequest {
|
|
1760
1816
|
appId?: string
|
|
1761
1817
|
interactionId?: string
|
|
1818
|
+
scope?: string
|
|
1762
1819
|
from?: string
|
|
1763
1820
|
to?: string
|
|
1764
1821
|
limit?: number
|
|
@@ -1772,6 +1829,7 @@ interface AdminInteractionsCountsByOutcomeRequest {
|
|
|
1772
1829
|
interface PublicInteractionsCountsByOutcomeRequest {
|
|
1773
1830
|
appId: string
|
|
1774
1831
|
interactionId: string
|
|
1832
|
+
scope?: string
|
|
1775
1833
|
from?: string
|
|
1776
1834
|
to?: string
|
|
1777
1835
|
limit?: number
|
|
@@ -1783,6 +1841,7 @@ interface PublicInteractionsCountsByOutcomeRequest {
|
|
|
1783
1841
|
interface PublicInteractionsByUserRequest {
|
|
1784
1842
|
appId?: string
|
|
1785
1843
|
interactionId?: string
|
|
1844
|
+
scope?: string
|
|
1786
1845
|
from?: string
|
|
1787
1846
|
to?: string
|
|
1788
1847
|
limit?: number
|
|
@@ -1796,7 +1855,8 @@ interface InteractionEventRow {
|
|
|
1796
1855
|
collectionId: string
|
|
1797
1856
|
timestamp: string
|
|
1798
1857
|
appId?: string
|
|
1799
|
-
interactionId?: string
|
|
1858
|
+
interactionId?: string // a link to a Interaction Object
|
|
1859
|
+
scope?: string // a customizable string to segment interactions
|
|
1800
1860
|
broadcastId?: string
|
|
1801
1861
|
userId?: string
|
|
1802
1862
|
contactId?: string
|
|
@@ -1821,6 +1881,7 @@ interface InteractionEventBase {
|
|
|
1821
1881
|
userId?: string
|
|
1822
1882
|
contactId?: string
|
|
1823
1883
|
interactionId: string
|
|
1884
|
+
scope?: string
|
|
1824
1885
|
appId?: string
|
|
1825
1886
|
broadcastId?: string
|
|
1826
1887
|
journeyId?: string
|
|
@@ -2239,8 +2300,24 @@ interface OrderItem {
|
|
|
2239
2300
|
orderId: string // Parent order ID
|
|
2240
2301
|
itemType: 'tag' | 'proof' | 'serial' // Type of item
|
|
2241
2302
|
itemId: string // The tag ID, proof ID, or serial number
|
|
2303
|
+
collectionId?: string // Collection ID
|
|
2304
|
+
productId?: string // Product ID
|
|
2305
|
+
variantId?: string | null // Variant ID
|
|
2306
|
+
batchId?: string | null // Batch ID
|
|
2242
2307
|
metadata: Record<string, any> // Item-specific metadata
|
|
2243
2308
|
createdAt: string // ISO 8601 timestamp
|
|
2309
|
+
order?: OrderSummary // Optional order summary (when includeOrder=true)
|
|
2310
|
+
}
|
|
2311
|
+
```
|
|
2312
|
+
|
|
2313
|
+
**OrderSummary** (interface)
|
|
2314
|
+
```typescript
|
|
2315
|
+
interface OrderSummary {
|
|
2316
|
+
id: string // Order ID
|
|
2317
|
+
orderRef?: string // Order reference
|
|
2318
|
+
status: string // Order status
|
|
2319
|
+
customerId?: string // Customer ID
|
|
2320
|
+
createdAt: string // ISO 8601 timestamp
|
|
2244
2321
|
}
|
|
2245
2322
|
```
|
|
2246
2323
|
|
|
@@ -2463,6 +2540,61 @@ interface LookupByProductResponse {
|
|
|
2463
2540
|
}
|
|
2464
2541
|
```
|
|
2465
2542
|
|
|
2543
|
+
**FindOrdersByAttributeParams** (interface)
|
|
2544
|
+
```typescript
|
|
2545
|
+
interface FindOrdersByAttributeParams {
|
|
2546
|
+
limit?: number // Max results (default: 100)
|
|
2547
|
+
offset?: number // Pagination offset (default: 0)
|
|
2548
|
+
includeItems?: boolean // Include items array (default: false)
|
|
2549
|
+
}
|
|
2550
|
+
```
|
|
2551
|
+
|
|
2552
|
+
**FindOrdersByAttributeResponse** (interface)
|
|
2553
|
+
```typescript
|
|
2554
|
+
interface FindOrdersByAttributeResponse {
|
|
2555
|
+
orders: Order[]
|
|
2556
|
+
limit: number
|
|
2557
|
+
offset: number
|
|
2558
|
+
}
|
|
2559
|
+
```
|
|
2560
|
+
|
|
2561
|
+
**FindItemsByAttributeParams** (interface)
|
|
2562
|
+
```typescript
|
|
2563
|
+
interface FindItemsByAttributeParams {
|
|
2564
|
+
limit?: number // Max results (default: 100)
|
|
2565
|
+
offset?: number // Pagination offset (default: 0)
|
|
2566
|
+
includeOrder?: boolean // Include order summary (default: false)
|
|
2567
|
+
}
|
|
2568
|
+
```
|
|
2569
|
+
|
|
2570
|
+
**FindItemsByAttributeResponse** (interface)
|
|
2571
|
+
```typescript
|
|
2572
|
+
interface FindItemsByAttributeResponse {
|
|
2573
|
+
items: OrderItem[]
|
|
2574
|
+
count: number
|
|
2575
|
+
limit: number
|
|
2576
|
+
offset: number
|
|
2577
|
+
}
|
|
2578
|
+
```
|
|
2579
|
+
|
|
2580
|
+
**GetOrderIdsParams** (interface)
|
|
2581
|
+
```typescript
|
|
2582
|
+
interface GetOrderIdsParams {
|
|
2583
|
+
limit?: number // Max results (default: 1000)
|
|
2584
|
+
offset?: number // Pagination offset (default: 0)
|
|
2585
|
+
}
|
|
2586
|
+
```
|
|
2587
|
+
|
|
2588
|
+
**GetOrderIdsResponse** (interface)
|
|
2589
|
+
```typescript
|
|
2590
|
+
interface GetOrderIdsResponse {
|
|
2591
|
+
orderIds: string[]
|
|
2592
|
+
count: number
|
|
2593
|
+
attribute: 'batchId' | 'productId' | 'variantId'
|
|
2594
|
+
value: string
|
|
2595
|
+
}
|
|
2596
|
+
```
|
|
2597
|
+
|
|
2466
2598
|
**TagScanSummary** (interface)
|
|
2467
2599
|
```typescript
|
|
2468
2600
|
interface TagScanSummary {
|
|
@@ -3943,6 +4075,19 @@ Get serial numbers for a batch (admin only).
|
|
|
3943
4075
|
codeId: string) → `Promise<any>`
|
|
3944
4076
|
Look up a serial number by code for a batch (admin only).
|
|
3945
4077
|
|
|
4078
|
+
**searchInCollection**(collectionId: string,
|
|
4079
|
+
params?: SearchBatchesRequest) → `Promise<BatchResponse[]>`
|
|
4080
|
+
Search for batches across all products in a collection. Allows searching by batch ID or name, with optional product filtering. ```typescript // Search for batches containing "2024" const batches = await batch.searchInCollection('coll_123', { search: 'BATCH-2024', limit: 50 }) // Filter batches for a specific product const productBatches = await batch.searchInCollection('coll_123', { productId: 'prod_abc', limit: 100 }) // Get all batches in collection const allBatches = await batch.searchInCollection('coll_123') // Check for expired batches batches.forEach(batch => { if (batch.expiryDate?.seconds) { const expiryDate = new Date(batch.expiryDate.seconds * 1000) if (expiryDate < new Date()) { console.log(`Batch ${batch.id} is expired`) } } }) ```
|
|
4081
|
+
|
|
4082
|
+
**findInCollection**(collectionId: string,
|
|
4083
|
+
batchId: string) → `Promise<BatchResponse>`
|
|
4084
|
+
Find a specific batch by ID across all products in a collection. Returns the batch along with the productId it belongs to. ```typescript // Find which product contains a specific batch const batch = await batch.findInCollection('coll_123', 'BATCH-2024-001') console.log(`Batch found in product: ${batch.productId}`) console.log(`Expires: ${batch.expiryDate}`) ```
|
|
4085
|
+
|
|
4086
|
+
**getBatchTags**(collectionId: string,
|
|
4087
|
+
batchId: string,
|
|
4088
|
+
claimSetId?: string) → `Promise<BatchTag[]>`
|
|
4089
|
+
Get all tags/codes assigned to a specific batch. Shows which claim set codes have been assigned to this batch. ```typescript // Get all tags assigned to a batch const tags = await batch.getBatchTags('coll_123', 'BATCH-2024-001') console.log(`Batch has ${tags.length} tags assigned`) tags.forEach(tag => { console.log(`Code: ${tag.code}, ClaimSet: ${tag.claimSetId}, TagID: ${tag.tagId}`) }) // Get tags from a specific claim set const claimSetTags = await batch.getBatchTags('coll_123', 'BATCH-2024-001', '000001') ```
|
|
4090
|
+
|
|
3946
4091
|
### broadcasts
|
|
3947
4092
|
|
|
3948
4093
|
**create**(collectionId: string,
|
|
@@ -4444,6 +4589,42 @@ Get analytics summary for multiple orders at once. Efficient way to retrieve sca
|
|
|
4444
4589
|
params?: SummaryRequest) → `Promise<CollectionSummaryResponse>`
|
|
4445
4590
|
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' }) ```
|
|
4446
4591
|
|
|
4592
|
+
**findByBatch**(collectionId: string,
|
|
4593
|
+
batchId: string,
|
|
4594
|
+
params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
|
|
4595
|
+
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`) ```
|
|
4596
|
+
|
|
4597
|
+
**findOrdersByProduct**(collectionId: string,
|
|
4598
|
+
productId: string,
|
|
4599
|
+
params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
|
|
4600
|
+
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`) ```
|
|
4601
|
+
|
|
4602
|
+
**findByVariant**(collectionId: string,
|
|
4603
|
+
variantId: string,
|
|
4604
|
+
params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
|
|
4605
|
+
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`) ```
|
|
4606
|
+
|
|
4607
|
+
**findItemsByBatch**(collectionId: string,
|
|
4608
|
+
batchId: string,
|
|
4609
|
+
params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
|
|
4610
|
+
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 }, {}) ```
|
|
4611
|
+
|
|
4612
|
+
**findItemsByProduct**(collectionId: string,
|
|
4613
|
+
productId: string,
|
|
4614
|
+
params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
|
|
4615
|
+
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`) ```
|
|
4616
|
+
|
|
4617
|
+
**findItemsByVariant**(collectionId: string,
|
|
4618
|
+
variantId: string,
|
|
4619
|
+
params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
|
|
4620
|
+
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 }) ```
|
|
4621
|
+
|
|
4622
|
+
**getOrderIdsByAttribute**(collectionId: string,
|
|
4623
|
+
attribute: 'batchId' | 'productId' | 'variantId',
|
|
4624
|
+
value: string,
|
|
4625
|
+
params?: GetOrderIdsParams) → `Promise<GetOrderIdsResponse>`
|
|
4626
|
+
Get unique order IDs containing items matching the specified attribute. Lightweight query that only returns order IDs, not full order objects. ```typescript // Get order IDs for a batch (fast count) const { orderIds, count } = await order.getOrderIdsByAttribute( 'coll_123', 'batchId', 'BATCH-2024-001' ) console.log(`Batch appears in ${count} orders`) // Get order IDs for a product const productOrders = await order.getOrderIdsByAttribute( 'coll_123', 'productId', 'prod_789', { limit: 500 } ) ```
|
|
4627
|
+
|
|
4447
4628
|
### product
|
|
4448
4629
|
|
|
4449
4630
|
**get**(collectionId: string,
|