@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.
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Crate Management Types
3
+ *
4
+ * Types for managing crates (containers for tags/products).
5
+ */
6
+ /**
7
+ * Item within a crate.
8
+ */
9
+ export interface CrateItem {
10
+ id: string;
11
+ codeId: string;
12
+ batchId?: string;
13
+ productId?: string;
14
+ claimId?: string;
15
+ productName?: string;
16
+ productGtin?: string;
17
+ productImage?: string;
18
+ data?: Record<string, any>;
19
+ }
20
+ /**
21
+ * Represents a crate containing items.
22
+ */
23
+ export interface Crate {
24
+ id: string;
25
+ items?: CrateItem[];
26
+ deleted?: boolean;
27
+ deletedAt?: string | null;
28
+ }
29
+ /**
30
+ * Query parameters for listing crates.
31
+ */
32
+ export interface ListCratesRequest {
33
+ limit?: number;
34
+ startAfter?: string;
35
+ includeDeleted?: boolean;
36
+ }
37
+ /**
38
+ * Response from listing crates.
39
+ */
40
+ export interface ListCratesResponse {
41
+ items: Crate[];
42
+ hasMore: boolean;
43
+ lastId: string | null;
44
+ }
45
+ /**
46
+ * Response from getting a single crate.
47
+ */
48
+ export interface GetCrateResponse extends Crate {
49
+ }
50
+ /**
51
+ * Request to create a crate.
52
+ */
53
+ export interface CreateCrateRequest {
54
+ items?: CrateItem[];
55
+ [key: string]: any;
56
+ }
57
+ /**
58
+ * Response from creating a crate.
59
+ */
60
+ export interface CreateCrateResponse extends Crate {
61
+ }
62
+ /**
63
+ * Request to update a crate.
64
+ */
65
+ export interface UpdateCrateRequest {
66
+ items?: CrateItem[];
67
+ [key: string]: any;
68
+ }
69
+ /**
70
+ * Response from updating a crate.
71
+ */
72
+ export interface UpdateCrateResponse extends Crate {
73
+ }
74
+ /**
75
+ * Response from deleting a crate.
76
+ */
77
+ export interface DeleteCrateResponse {
78
+ success: boolean;
79
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Crate Management Types
3
+ *
4
+ * Types for managing crates (containers for tags/products).
5
+ */
6
+ export {};
@@ -24,4 +24,5 @@ export * from "./jobs";
24
24
  export * from "./realtime";
25
25
  export * from "./tags";
26
26
  export * from "./order";
27
+ export * from "./crate";
27
28
  export * from "./iframeResponder";
@@ -26,4 +26,5 @@ export * from "./jobs";
26
26
  export * from "./realtime";
27
27
  export * from "./tags";
28
28
  export * from "./order";
29
+ export * from "./crate";
29
30
  export * from "./iframeResponder";
@@ -12,8 +12,23 @@ export interface OrderItem {
12
12
  orderId: string;
13
13
  itemType: 'tag' | 'proof' | 'serial';
14
14
  itemId: string;
15
+ collectionId?: string;
16
+ productId?: string;
17
+ variantId?: string | null;
18
+ batchId?: string | null;
15
19
  metadata: Record<string, any>;
16
20
  createdAt: string;
21
+ order?: OrderSummary;
22
+ }
23
+ /**
24
+ * Summary of order details (included with items when requested).
25
+ */
26
+ export interface OrderSummary {
27
+ id: string;
28
+ orderRef?: string;
29
+ status: string;
30
+ customerId?: string;
31
+ createdAt: string;
17
32
  }
18
33
  /**
19
34
  * Represents an order containing multiple items.
@@ -241,6 +256,55 @@ export interface LookupByProductResponse {
241
256
  limit: number;
242
257
  offset: number;
243
258
  }
259
+ /**
260
+ * Query parameters for finding orders by batch/product/variant.
261
+ */
262
+ export interface FindOrdersByAttributeParams {
263
+ limit?: number;
264
+ offset?: number;
265
+ includeItems?: boolean;
266
+ }
267
+ /**
268
+ * Response from finding orders by batch/product/variant.
269
+ */
270
+ export interface FindOrdersByAttributeResponse {
271
+ orders: Order[];
272
+ limit: number;
273
+ offset: number;
274
+ }
275
+ /**
276
+ * Query parameters for finding items by batch/product/variant.
277
+ */
278
+ export interface FindItemsByAttributeParams {
279
+ limit?: number;
280
+ offset?: number;
281
+ includeOrder?: boolean;
282
+ }
283
+ /**
284
+ * Response from finding items by batch/product/variant.
285
+ */
286
+ export interface FindItemsByAttributeResponse {
287
+ items: OrderItem[];
288
+ count: number;
289
+ limit: number;
290
+ offset: number;
291
+ }
292
+ /**
293
+ * Query parameters for getting order IDs by attribute.
294
+ */
295
+ export interface GetOrderIdsParams {
296
+ limit?: number;
297
+ offset?: number;
298
+ }
299
+ /**
300
+ * Response from getting order IDs by attribute.
301
+ */
302
+ export interface GetOrderIdsResponse {
303
+ orderIds: string[];
304
+ count: number;
305
+ attribute: 'batchId' | 'productId' | 'variantId';
306
+ value: string;
307
+ }
244
308
  /**
245
309
  * Summary of scans for a single tag.
246
310
  */
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.3.19 | Generated: 2026-02-08T09:16:59.107Z
3
+ Version: 1.3.21 | Generated: 2026-02-09T12:29:22.158Z
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
- **BatchResponse** = `any`
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
+ ```
647
+
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
+ ```
657
+
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
+ ```
629
666
 
630
- **BatchCreateRequest** = `any`
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
+ ```
631
675
 
632
- **BatchUpdateRequest** = `any`
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
 
@@ -1493,6 +1548,74 @@ interface ContactSchema {
1493
1548
 
1494
1549
  **FieldType** = ``
1495
1550
 
1551
+ ### crate
1552
+
1553
+ **CrateItem** (interface)
1554
+ ```typescript
1555
+ interface CrateItem {
1556
+ id: string // Item ID (tag ID)
1557
+ codeId: string // Code identifier
1558
+ batchId?: string // Batch identifier
1559
+ productId?: string // Product identifier
1560
+ claimId?: string // Claim identifier
1561
+ productName?: string // Product name
1562
+ productGtin?: string // Product GTIN
1563
+ productImage?: string // Product image URL
1564
+ data?: Record<string, any> // Additional item data
1565
+ }
1566
+ ```
1567
+
1568
+ **Crate** (interface)
1569
+ ```typescript
1570
+ interface Crate {
1571
+ id: string // Crate ID
1572
+ items?: CrateItem[] // Array of items in the crate
1573
+ deleted?: boolean // Whether the crate is soft-deleted
1574
+ deletedAt?: string | null // ISO 8601 timestamp when deleted
1575
+ }
1576
+ ```
1577
+
1578
+ **ListCratesRequest** (interface)
1579
+ ```typescript
1580
+ interface ListCratesRequest {
1581
+ limit?: number // Number of results per page (default: 100, max: 100)
1582
+ startAfter?: string // Crate ID to start after for pagination
1583
+ includeDeleted?: boolean // Include soft-deleted crates (default: false)
1584
+ }
1585
+ ```
1586
+
1587
+ **ListCratesResponse** (interface)
1588
+ ```typescript
1589
+ interface ListCratesResponse {
1590
+ items: Crate[] // Array of crates
1591
+ hasMore: boolean // Whether more results are available
1592
+ lastId: string | null // ID of last crate (use as startAfter for next page)
1593
+ }
1594
+ ```
1595
+
1596
+ **CreateCrateRequest** (interface)
1597
+ ```typescript
1598
+ interface CreateCrateRequest {
1599
+ items?: CrateItem[] // Initial items for the crate
1600
+ [key: string]: any // Additional fields
1601
+ }
1602
+ ```
1603
+
1604
+ **UpdateCrateRequest** (interface)
1605
+ ```typescript
1606
+ interface UpdateCrateRequest {
1607
+ items?: CrateItem[] // Updated items
1608
+ [key: string]: any // Additional fields
1609
+ }
1610
+ ```
1611
+
1612
+ **DeleteCrateResponse** (interface)
1613
+ ```typescript
1614
+ interface DeleteCrateResponse {
1615
+ success: boolean
1616
+ }
1617
+ ```
1618
+
1496
1619
  ### error
1497
1620
 
1498
1621
  **ErrorResponse** (interface)
@@ -2171,8 +2294,24 @@ interface OrderItem {
2171
2294
  orderId: string // Parent order ID
2172
2295
  itemType: 'tag' | 'proof' | 'serial' // Type of item
2173
2296
  itemId: string // The tag ID, proof ID, or serial number
2297
+ collectionId?: string // Collection ID
2298
+ productId?: string // Product ID
2299
+ variantId?: string | null // Variant ID
2300
+ batchId?: string | null // Batch ID
2174
2301
  metadata: Record<string, any> // Item-specific metadata
2175
2302
  createdAt: string // ISO 8601 timestamp
2303
+ order?: OrderSummary // Optional order summary (when includeOrder=true)
2304
+ }
2305
+ ```
2306
+
2307
+ **OrderSummary** (interface)
2308
+ ```typescript
2309
+ interface OrderSummary {
2310
+ id: string // Order ID
2311
+ orderRef?: string // Order reference
2312
+ status: string // Order status
2313
+ customerId?: string // Customer ID
2314
+ createdAt: string // ISO 8601 timestamp
2176
2315
  }
2177
2316
  ```
2178
2317
 
@@ -2395,6 +2534,61 @@ interface LookupByProductResponse {
2395
2534
  }
2396
2535
  ```
2397
2536
 
2537
+ **FindOrdersByAttributeParams** (interface)
2538
+ ```typescript
2539
+ interface FindOrdersByAttributeParams {
2540
+ limit?: number // Max results (default: 100)
2541
+ offset?: number // Pagination offset (default: 0)
2542
+ includeItems?: boolean // Include items array (default: false)
2543
+ }
2544
+ ```
2545
+
2546
+ **FindOrdersByAttributeResponse** (interface)
2547
+ ```typescript
2548
+ interface FindOrdersByAttributeResponse {
2549
+ orders: Order[]
2550
+ limit: number
2551
+ offset: number
2552
+ }
2553
+ ```
2554
+
2555
+ **FindItemsByAttributeParams** (interface)
2556
+ ```typescript
2557
+ interface FindItemsByAttributeParams {
2558
+ limit?: number // Max results (default: 100)
2559
+ offset?: number // Pagination offset (default: 0)
2560
+ includeOrder?: boolean // Include order summary (default: false)
2561
+ }
2562
+ ```
2563
+
2564
+ **FindItemsByAttributeResponse** (interface)
2565
+ ```typescript
2566
+ interface FindItemsByAttributeResponse {
2567
+ items: OrderItem[]
2568
+ count: number
2569
+ limit: number
2570
+ offset: number
2571
+ }
2572
+ ```
2573
+
2574
+ **GetOrderIdsParams** (interface)
2575
+ ```typescript
2576
+ interface GetOrderIdsParams {
2577
+ limit?: number // Max results (default: 1000)
2578
+ offset?: number // Pagination offset (default: 0)
2579
+ }
2580
+ ```
2581
+
2582
+ **GetOrderIdsResponse** (interface)
2583
+ ```typescript
2584
+ interface GetOrderIdsResponse {
2585
+ orderIds: string[]
2586
+ count: number
2587
+ attribute: 'batchId' | 'productId' | 'variantId'
2588
+ value: string
2589
+ }
2590
+ ```
2591
+
2398
2592
  **TagScanSummary** (interface)
2399
2593
  ```typescript
2400
2594
  interface TagScanSummary {
@@ -3875,6 +4069,19 @@ Get serial numbers for a batch (admin only).
3875
4069
  codeId: string) → `Promise<any>`
3876
4070
  Look up a serial number by code for a batch (admin only).
3877
4071
 
4072
+ **searchInCollection**(collectionId: string,
4073
+ params?: SearchBatchesRequest) → `Promise<BatchResponse[]>`
4074
+ 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`) } } }) ```
4075
+
4076
+ **findInCollection**(collectionId: string,
4077
+ batchId: string) → `Promise<BatchResponse>`
4078
+ 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}`) ```
4079
+
4080
+ **getBatchTags**(collectionId: string,
4081
+ batchId: string,
4082
+ claimSetId?: string) → `Promise<BatchTag[]>`
4083
+ 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') ```
4084
+
3878
4085
  ### broadcasts
3879
4086
 
3880
4087
  **create**(collectionId: string,
@@ -4123,20 +4330,26 @@ Public: Get contact update schema for a collection Fetches the public contact sc
4123
4330
 
4124
4331
  ### crate
4125
4332
 
4126
- **get**(collectionId: string, crateId: string) → `Promise<any>`
4127
- Get a single crate by ID for a collection (admin only).
4333
+ **list**(collectionId: string,
4334
+ params?: ListCratesRequest) `Promise<ListCratesResponse>`
4335
+ List crates for a collection with pagination support. Returns crates in pages, with support for soft-deleted crates. ```typescript // Get first page const page1 = await crate.list('coll_123', { limit: 100 }) console.log(`Found ${page1.items.length} crates`) // Get next page if (page1.hasMore) { const page2 = await crate.list('coll_123', { limit: 100, startAfter: page1.lastId }) } // Include soft-deleted crates const withDeleted = await crate.list('coll_123', { includeDeleted: true }) ```
4128
4336
 
4129
- **list**(collectionId: string) → `Promise<any[]>`
4130
- List all crates for a collection (admin only).
4337
+ **get**(collectionId: string,
4338
+ crateId: string) `Promise<GetCrateResponse>`
4339
+ Get a single crate by ID for a collection (admin only). ```typescript const crate = await crate.get('coll_123', 'crate_abc123') console.log(`Crate has ${crate.items?.length ?? 0} items`) ```
4131
4340
 
4132
- **create**(collectionId: string, data: any) → `Promise<any>`
4133
- Create a new crate for a collection (admin only).
4341
+ **create**(collectionId: string,
4342
+ data: CreateCrateRequest) `Promise<CreateCrateResponse>`
4343
+ Create a new crate for a collection (admin only). ```typescript const newCrate = await crate.create('coll_123', { items: [ { id: 'tag_001', codeId: 'ABC123', productId: 'prod_1', productName: 'Product Name' } ] }) console.log(`Created crate ${newCrate.id}`) ```
4134
4344
 
4135
- **update**(collectionId: string, crateId: string, data: any) → `Promise<any>`
4136
- Update a crate for a collection (admin only).
4345
+ **update**(collectionId: string,
4346
+ crateId: string,
4347
+ data: UpdateCrateRequest) → `Promise<UpdateCrateResponse>`
4348
+ Update a crate for a collection (admin only). ```typescript const updated = await crate.update('coll_123', 'crate_abc123', { items: [ { id: 'tag_002', codeId: 'XYZ789', productId: 'prod_2' } ] }) ```
4137
4349
 
4138
- **remove**(collectionId: string, crateId: string) → `Promise<void>`
4139
- Delete a crate for a collection (admin only).
4350
+ **remove**(collectionId: string,
4351
+ crateId: string) `Promise<DeleteCrateResponse>`
4352
+ Delete a crate for a collection (admin only). This performs a soft delete. ```typescript await crate.remove('coll_123', 'crate_abc123') ```
4140
4353
 
4141
4354
  ### form
4142
4355
 
@@ -4370,6 +4583,42 @@ Get analytics summary for multiple orders at once. Efficient way to retrieve sca
4370
4583
  params?: SummaryRequest) → `Promise<CollectionSummaryResponse>`
4371
4584
  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' }) ```
4372
4585
 
4586
+ **findByBatch**(collectionId: string,
4587
+ batchId: string,
4588
+ params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
4589
+ 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`) ```
4590
+
4591
+ **findOrdersByProduct**(collectionId: string,
4592
+ productId: string,
4593
+ params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
4594
+ 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`) ```
4595
+
4596
+ **findByVariant**(collectionId: string,
4597
+ variantId: string,
4598
+ params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
4599
+ 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`) ```
4600
+
4601
+ **findItemsByBatch**(collectionId: string,
4602
+ batchId: string,
4603
+ params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
4604
+ 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 }, {}) ```
4605
+
4606
+ **findItemsByProduct**(collectionId: string,
4607
+ productId: string,
4608
+ params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
4609
+ 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`) ```
4610
+
4611
+ **findItemsByVariant**(collectionId: string,
4612
+ variantId: string,
4613
+ params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
4614
+ 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 }) ```
4615
+
4616
+ **getOrderIdsByAttribute**(collectionId: string,
4617
+ attribute: 'batchId' | 'productId' | 'variantId',
4618
+ value: string,
4619
+ params?: GetOrderIdsParams) → `Promise<GetOrderIdsResponse>`
4620
+ 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 } ) ```
4621
+
4373
4622
  ### product
4374
4623
 
4375
4624
  **get**(collectionId: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.3.19",
3
+ "version": "1.3.21",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",