@proveanything/smartlinks 1.3.16 → 1.3.18

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,9 +1,22 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.3.16 | Generated: 2026-02-06T12:14:25.408Z
3
+ Version: 1.3.18 | Generated: 2026-02-07T16:00:44.350Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
7
+ ## Documentation
8
+
9
+ For detailed guides on specific features:
10
+
11
+ - **[AI & Chat Completions](ai.md)** - Chat completions, RAG (document-grounded Q&A), voice integration, streaming, tool calling, podcast generation
12
+ - **[Widgets](widgets.md)** - Embeddable React components for parent applications
13
+ - **[Realtime](realtime.md)** - Real-time data updates and WebSocket connections
14
+ - **[iframe Responder](iframe-responder.md)** - iframe integration and cross-origin communication
15
+ - **[i18n](i18n.md)** - Internationalization and localization
16
+ - **[Liquid Templates](liquid-templates.md)** - Dynamic templating for content generation
17
+ - **[Theme System](theme.system.md)** - Theme configuration and customization
18
+ - **[Theme Defaults](theme-defaults.md)** - Default theme values and presets
19
+
7
20
  ## API Namespaces
8
21
 
9
22
  The Smartlinks SDK is organized into the following namespaces:
@@ -42,7 +55,7 @@ The Smartlinks SDK is organized into the following namespaces:
42
55
  - **qr** - Lookup short codes to resolve collection/product/proof context.
43
56
 
44
57
  — AI & Utilities —
45
- - **ai** - Generate content and images, search photos, chat, upload files, and cache.
58
+ - **ai** - Chat completions, RAG (document Q&A), podcast generation, TTS, content/image generation, voice integration.
46
59
  - **serialNumber** - Assign, lookup, and manage serial numbers across scopes.
47
60
 
48
61
  — Other —
@@ -2173,8 +2186,11 @@ interface Order {
2173
2186
  customerId?: string // Customer's own customer ID (can map to CRM/contacts)
2174
2187
  status: string // e.g., "pending", "processing", "shipped", "completed"
2175
2188
  itemCount: number // Cached count of items (maintained automatically)
2176
- metadata: Record<string, any> // Flexible additional data
2177
- items: OrderItem[] // Array of items in this order
2189
+ metadata: {
2190
+ productSummary?: Record<string, number> // productId -> count (auto-maintained)
2191
+ [key: string]: any // Flexible additional data
2192
+ }
2193
+ items?: OrderItem[] // Array of items (only when includeItems=true)
2178
2194
  createdAt: string // ISO 8601 timestamp
2179
2195
  updatedAt: string // ISO 8601 timestamp
2180
2196
  }
@@ -2195,6 +2211,13 @@ interface CreateOrderRequest {
2195
2211
  }
2196
2212
  ```
2197
2213
 
2214
+ **GetOrderParams** (interface)
2215
+ ```typescript
2216
+ interface GetOrderParams {
2217
+ includeItems?: boolean // Optional: Include items array (default: false)
2218
+ }
2219
+ ```
2220
+
2198
2221
  **UpdateOrderRequest** (interface)
2199
2222
  ```typescript
2200
2223
  interface UpdateOrderRequest {
@@ -2220,6 +2243,7 @@ interface ListOrdersRequest {
2220
2243
  status?: string // Optional: Filter by status
2221
2244
  orderRef?: string // Optional: Filter by order reference
2222
2245
  customerId?: string // Optional: Filter by customer ID
2246
+ includeItems?: boolean // Optional: Include items array (default: false)
2223
2247
  }
2224
2248
  ```
2225
2249
 
@@ -2267,6 +2291,110 @@ interface LookupOrdersResponse {
2267
2291
  }
2268
2292
  ```
2269
2293
 
2294
+ **GetOrderItemsParams** (interface)
2295
+ ```typescript
2296
+ interface GetOrderItemsParams {
2297
+ limit?: number // Optional: Max results (default: 100)
2298
+ offset?: number // Optional: Pagination offset (default: 0)
2299
+ }
2300
+ ```
2301
+
2302
+ **GetOrderItemsResponse** (interface)
2303
+ ```typescript
2304
+ interface GetOrderItemsResponse {
2305
+ items: OrderItem[]
2306
+ limit: number
2307
+ offset: number
2308
+ }
2309
+ ```
2310
+
2311
+ **QueryOrdersRequest** (interface)
2312
+ ```typescript
2313
+ interface QueryOrdersRequest {
2314
+ query?: {
2315
+ status?: string
2316
+ orderRef?: string
2317
+ customerId?: string
2318
+ createdAfter?: string // ISO 8601 date
2319
+ createdBefore?: string // ISO 8601 date
2320
+ updatedAfter?: string // ISO 8601 date
2321
+ updatedBefore?: string // ISO 8601 date
2322
+ minItemCount?: number
2323
+ maxItemCount?: number
2324
+ metadata?: Record<string, any>
2325
+ sortBy?: string
2326
+ sortOrder?: 'asc' | 'desc'
2327
+ }
2328
+ limit?: number // Optional: Max results (default: 100)
2329
+ offset?: number // Optional: Pagination offset (default: 0)
2330
+ includeItems?: boolean // Optional: Include items array (default: false)
2331
+ }
2332
+ ```
2333
+
2334
+ **QueryOrdersResponse** (interface)
2335
+ ```typescript
2336
+ interface QueryOrdersResponse {
2337
+ orders: Order[]
2338
+ limit: number
2339
+ offset: number
2340
+ }
2341
+ ```
2342
+
2343
+ **ReportsParams** (interface)
2344
+ ```typescript
2345
+ interface ReportsParams {
2346
+ groupByStatus?: boolean
2347
+ groupByCollection?: boolean
2348
+ groupByCustomer?: boolean
2349
+ groupByDate?: boolean
2350
+ groupByItemType?: boolean
2351
+ groupByProduct?: boolean
2352
+ includeItemStats?: boolean
2353
+ includeCount?: boolean // default: true
2354
+ topN?: number // for customer/product grouping (default: 10)
2355
+ status?: string
2356
+ createdAfter?: string // ISO 8601 date
2357
+ createdBefore?: string // ISO 8601 date
2358
+ }
2359
+ ```
2360
+
2361
+ **ReportsResponse** (interface)
2362
+ ```typescript
2363
+ interface ReportsResponse {
2364
+ totalOrders?: number
2365
+ ordersByStatus?: Record<string, number>
2366
+ ordersByCollection?: Record<string, number>
2367
+ ordersByCustomer?: Record<string, number>
2368
+ ordersByDate?: Record<string, number>
2369
+ itemsByType?: Record<string, number>
2370
+ itemsByProduct?: Record<string, number>
2371
+ itemStats?: {
2372
+ totalItems: number
2373
+ avgItemsPerOrder: number
2374
+ maxItemsInOrder: number
2375
+ minItemsInOrder: number
2376
+ }
2377
+ }
2378
+ ```
2379
+
2380
+ **LookupByProductParams** (interface)
2381
+ ```typescript
2382
+ interface LookupByProductParams {
2383
+ limit?: number // Optional: Max results (default: 100)
2384
+ offset?: number // Optional: Pagination offset (default: 0)
2385
+ includeItems?: boolean // Optional: Include items array (default: false)
2386
+ }
2387
+ ```
2388
+
2389
+ **LookupByProductResponse** (interface)
2390
+ ```typescript
2391
+ interface LookupByProductResponse {
2392
+ orders: Order[]
2393
+ limit: number
2394
+ offset: number
2395
+ }
2396
+ ```
2397
+
2270
2398
  ### product
2271
2399
 
2272
2400
  **Product** (interface)
@@ -2671,6 +2799,426 @@ interface TemplateRenderSourceResponse {
2671
2799
 
2672
2800
  ### ai (api)
2673
2801
 
2802
+ **ContentPart** (interface)
2803
+ ```typescript
2804
+ interface ContentPart {
2805
+ type: 'text' | 'image_url'
2806
+ text?: string
2807
+ image_url?: {
2808
+ url: string
2809
+ detail?: 'auto' | 'low' | 'high'
2810
+ }
2811
+ }
2812
+ ```
2813
+
2814
+ **FunctionCall** (interface)
2815
+ ```typescript
2816
+ interface FunctionCall {
2817
+ name: string
2818
+ arguments: string
2819
+ }
2820
+ ```
2821
+
2822
+ **ToolCall** (interface)
2823
+ ```typescript
2824
+ interface ToolCall {
2825
+ id: string
2826
+ type: 'function'
2827
+ function: {
2828
+ name: string
2829
+ arguments: string
2830
+ }
2831
+ }
2832
+ ```
2833
+
2834
+ **ChatMessage** (interface)
2835
+ ```typescript
2836
+ interface ChatMessage {
2837
+ role: 'system' | 'user' | 'assistant' | 'function' | 'tool'
2838
+ content: string | ContentPart[]
2839
+ name?: string
2840
+ function_call?: FunctionCall
2841
+ tool_calls?: ToolCall[]
2842
+ tool_call_id?: string
2843
+ }
2844
+ ```
2845
+
2846
+ **ToolDefinition** (interface)
2847
+ ```typescript
2848
+ interface ToolDefinition {
2849
+ type: 'function'
2850
+ function: {
2851
+ name: string
2852
+ description: string
2853
+ parameters: {
2854
+ type: 'object'
2855
+ properties: Record<string, {
2856
+ type: string
2857
+ description?: string
2858
+ enum?: string[]
2859
+ }>
2860
+ required?: string[]
2861
+ }
2862
+ }
2863
+ }
2864
+ ```
2865
+
2866
+ **ChatCompletionRequest** (interface)
2867
+ ```typescript
2868
+ interface ChatCompletionRequest {
2869
+ messages: ChatMessage[]
2870
+ model?: string
2871
+ stream?: boolean
2872
+ tools?: ToolDefinition[]
2873
+ tool_choice?: 'none' | 'auto' | 'required' | { type: 'function'; function: { name: string } }
2874
+ temperature?: number
2875
+ max_tokens?: number
2876
+ top_p?: number
2877
+ frequency_penalty?: number
2878
+ presence_penalty?: number
2879
+ response_format?: { type: 'text' | 'json_object' }
2880
+ user?: string
2881
+ }
2882
+ ```
2883
+
2884
+ **ChatCompletionChoice** (interface)
2885
+ ```typescript
2886
+ interface ChatCompletionChoice {
2887
+ index: number
2888
+ message: ChatMessage
2889
+ finish_reason: 'stop' | 'length' | 'function_call' | 'tool_calls' | 'content_filter' | null
2890
+ }
2891
+ ```
2892
+
2893
+ **ChatCompletionResponse** (interface)
2894
+ ```typescript
2895
+ interface ChatCompletionResponse {
2896
+ id: string
2897
+ object: 'chat.completion'
2898
+ created: number
2899
+ model: string
2900
+ choices: ChatCompletionChoice[]
2901
+ usage: {
2902
+ prompt_tokens: number
2903
+ completion_tokens: number
2904
+ total_tokens: number
2905
+ }
2906
+ }
2907
+ ```
2908
+
2909
+ **ChatCompletionChunk** (interface)
2910
+ ```typescript
2911
+ interface ChatCompletionChunk {
2912
+ id: string
2913
+ object: 'chat.completion.chunk'
2914
+ created: number
2915
+ model: string
2916
+ choices: Array<{
2917
+ index: number
2918
+ delta: Partial<ChatMessage>
2919
+ finish_reason: string | null
2920
+ }>
2921
+ }
2922
+ ```
2923
+
2924
+ **AIModel** (interface)
2925
+ ```typescript
2926
+ interface AIModel {
2927
+ id: string
2928
+ provider: 'gemini' | 'openai'
2929
+ modelId: string
2930
+ name: string
2931
+ description: string
2932
+ capabilities: Array<'text' | 'vision' | 'audio' | 'code'>
2933
+ contextWindow: number
2934
+ pricing: {
2935
+ input: number
2936
+ output: number
2937
+ cached?: number
2938
+ }
2939
+ features: string[]
2940
+ recommended?: string
2941
+ }
2942
+ ```
2943
+
2944
+ **ModelList** (interface)
2945
+ ```typescript
2946
+ interface ModelList {
2947
+ object: 'list'
2948
+ data: AIModel[]
2949
+ }
2950
+ ```
2951
+
2952
+ **DocumentChunk** (interface)
2953
+ ```typescript
2954
+ interface DocumentChunk {
2955
+ text: string
2956
+ embedding: number[]
2957
+ metadata: {
2958
+ chunkIndex: number
2959
+ documentId: string
2960
+ [key: string]: any
2961
+ }
2962
+ }
2963
+ ```
2964
+
2965
+ **IndexDocumentRequest** (interface)
2966
+ ```typescript
2967
+ interface IndexDocumentRequest {
2968
+ productId: string
2969
+ text?: string
2970
+ documentUrl?: string
2971
+ metadata?: Record<string, any>
2972
+ chunkSize?: number
2973
+ overlap?: number
2974
+ provider?: 'openai' | 'gemini'
2975
+ }
2976
+ ```
2977
+
2978
+ **IndexDocumentResponse** (interface)
2979
+ ```typescript
2980
+ interface IndexDocumentResponse {
2981
+ success: boolean
2982
+ productId: string
2983
+ documentId: string
2984
+ chunks: number
2985
+ metadata: {
2986
+ textLength: number
2987
+ chunkSize: number
2988
+ overlap: number
2989
+ embeddingDimensions: number
2990
+ }
2991
+ sample?: {
2992
+ text: string
2993
+ chunkIndex: number
2994
+ }
2995
+ }
2996
+ ```
2997
+
2998
+ **ConfigureAssistantRequest** (interface)
2999
+ ```typescript
3000
+ interface ConfigureAssistantRequest {
3001
+ productId: string
3002
+ systemPrompt?: string
3003
+ model?: string
3004
+ maxTokensPerResponse?: number
3005
+ temperature?: number
3006
+ rateLimitPerUser?: number
3007
+ allowedTopics?: string[]
3008
+ customInstructions?: {
3009
+ tone?: string
3010
+ additionalRules?: string
3011
+ [key: string]: any
3012
+ }
3013
+ }
3014
+ ```
3015
+
3016
+ **ConfigureAssistantResponse** (interface)
3017
+ ```typescript
3018
+ interface ConfigureAssistantResponse {
3019
+ success: boolean
3020
+ configuration: {
3021
+ productId: string
3022
+ systemPrompt: string
3023
+ model: string
3024
+ maxTokensPerResponse: number
3025
+ temperature: number
3026
+ rateLimitPerUser: number
3027
+ allowedTopics: string[]
3028
+ customInstructions?: Record<string, any>
3029
+ updatedAt: string
3030
+ }
3031
+ }
3032
+ ```
3033
+
3034
+ **PublicChatRequest** (interface)
3035
+ ```typescript
3036
+ interface PublicChatRequest {
3037
+ productId: string
3038
+ userId: string
3039
+ message: string
3040
+ sessionId?: string
3041
+ stream?: boolean
3042
+ }
3043
+ ```
3044
+
3045
+ **PublicChatResponse** (interface)
3046
+ ```typescript
3047
+ interface PublicChatResponse {
3048
+ message: string
3049
+ sessionId: string
3050
+ usage: {
3051
+ prompt_tokens: number
3052
+ completion_tokens: number
3053
+ total_tokens: number
3054
+ }
3055
+ context?: {
3056
+ chunksUsed: number
3057
+ topSimilarity: number
3058
+ }
3059
+ }
3060
+ ```
3061
+
3062
+ **Session** (interface)
3063
+ ```typescript
3064
+ interface Session {
3065
+ sessionId: string
3066
+ productId: string
3067
+ userId: string
3068
+ messageCount: number
3069
+ createdAt: string
3070
+ lastActivityAt: string
3071
+ messages: ChatMessage[]
3072
+ }
3073
+ ```
3074
+
3075
+ **RateLimitStatus** (interface)
3076
+ ```typescript
3077
+ interface RateLimitStatus {
3078
+ used: number
3079
+ remaining: number
3080
+ resetAt: string
3081
+ }
3082
+ ```
3083
+
3084
+ **SessionStatistics** (interface)
3085
+ ```typescript
3086
+ interface SessionStatistics {
3087
+ totalSessions: number
3088
+ activeSessions: number
3089
+ totalMessages: number
3090
+ rateLimitedUsers: number
3091
+ }
3092
+ ```
3093
+
3094
+ **VoiceSessionRequest** (interface)
3095
+ ```typescript
3096
+ interface VoiceSessionRequest {
3097
+ productId: string
3098
+ userId: string
3099
+ collectionId: string
3100
+ settings?: {
3101
+ voice?: string
3102
+ language?: string
3103
+ model?: string
3104
+ }
3105
+ }
3106
+ ```
3107
+
3108
+ **VoiceSessionResponse** (interface)
3109
+ ```typescript
3110
+ interface VoiceSessionResponse {
3111
+ token: string
3112
+ systemInstruction: string
3113
+ expiresAt: string
3114
+ productName: string
3115
+ }
3116
+ ```
3117
+
3118
+ **EphemeralTokenRequest** (interface)
3119
+ ```typescript
3120
+ interface EphemeralTokenRequest {
3121
+ settings?: {
3122
+ ttl?: number
3123
+ voice?: string
3124
+ language?: string
3125
+ model?: string
3126
+ }
3127
+ }
3128
+ ```
3129
+
3130
+ **EphemeralTokenResponse** (interface)
3131
+ ```typescript
3132
+ interface EphemeralTokenResponse {
3133
+ token: string
3134
+ expiresAt: string
3135
+ }
3136
+ ```
3137
+
3138
+ **TranscriptionResponse** (interface)
3139
+ ```typescript
3140
+ interface TranscriptionResponse {
3141
+ text: string
3142
+ }
3143
+ ```
3144
+
3145
+ **TTSRequest** (interface)
3146
+ ```typescript
3147
+ interface TTSRequest {
3148
+ text: string
3149
+ voice?: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer'
3150
+ speed?: number
3151
+ format?: 'mp3' | 'opus' | 'aac' | 'flac'
3152
+ }
3153
+ ```
3154
+
3155
+ **GeneratePodcastRequest** (interface)
3156
+ ```typescript
3157
+ interface GeneratePodcastRequest {
3158
+ productId: string
3159
+ documentText?: string
3160
+ duration?: number
3161
+ style?: 'casual' | 'professional' | 'educational' | 'entertaining'
3162
+ voices?: {
3163
+ host1?: string
3164
+ host2?: string
3165
+ }
3166
+ includeAudio?: boolean
3167
+ language?: string
3168
+ customInstructions?: string
3169
+ }
3170
+ ```
3171
+
3172
+ **PodcastSegment** (interface)
3173
+ ```typescript
3174
+ interface PodcastSegment {
3175
+ speaker: 'host1' | 'host2'
3176
+ text: string
3177
+ timestamp?: number
3178
+ duration?: number
3179
+ }
3180
+ ```
3181
+
3182
+ **PodcastScript** (interface)
3183
+ ```typescript
3184
+ interface PodcastScript {
3185
+ title: string
3186
+ description: string
3187
+ segments: PodcastSegment[]
3188
+ }
3189
+ ```
3190
+
3191
+ **GeneratePodcastResponse** (interface)
3192
+ ```typescript
3193
+ interface GeneratePodcastResponse {
3194
+ success: boolean
3195
+ podcastId: string
3196
+ script: PodcastScript
3197
+ audio?: {
3198
+ host1Url?: string
3199
+ host2Url?: string
3200
+ mixedUrl?: string
3201
+ }
3202
+ metadata: {
3203
+ duration: number
3204
+ wordCount: number
3205
+ generatedAt: string
3206
+ }
3207
+ }
3208
+ ```
3209
+
3210
+ **PodcastStatus** (interface)
3211
+ ```typescript
3212
+ interface PodcastStatus {
3213
+ podcastId: string
3214
+ status: 'generating_script' | 'generating_audio' | 'mixing' | 'completed' | 'failed'
3215
+ progress: number
3216
+ estimatedTimeRemaining?: number
3217
+ error?: string
3218
+ result?: GeneratePodcastResponse
3219
+ }
3220
+ ```
3221
+
2674
3222
  **AIGenerateContentRequest** (interface)
2675
3223
  ```typescript
2676
3224
  interface AIGenerateContentRequest {
@@ -2800,6 +3348,67 @@ type AccountInfoResponse = {
2800
3348
 
2801
3349
  ### ai
2802
3350
 
3351
+ **create**(collectionId: string,
3352
+ request: ChatCompletionRequest) → `Promise<ChatCompletionResponse | AsyncIterable<ChatCompletionChunk>>`
3353
+ Create a chat completion (streaming or non-streaming)
3354
+
3355
+ **list**(collectionId: string) → `Promise<ModelList>`
3356
+ List available AI models
3357
+
3358
+ **get**(collectionId: string, modelId: string) → `Promise<AIModel>`
3359
+ Get specific model information
3360
+
3361
+ **indexDocument**(collectionId: string,
3362
+ request: IndexDocumentRequest) → `Promise<IndexDocumentResponse>`
3363
+ Index a document for RAG
3364
+
3365
+ **configureAssistant**(collectionId: string,
3366
+ request: ConfigureAssistantRequest) → `Promise<ConfigureAssistantResponse>`
3367
+ Configure AI assistant behavior
3368
+
3369
+ **stats**(collectionId: string) → `Promise<SessionStatistics>`
3370
+ Get session statistics
3371
+
3372
+ **reset**(collectionId: string, userId: string) → `Promise<`
3373
+ Reset rate limit for a user
3374
+
3375
+ **generate**(collectionId: string,
3376
+ request: GeneratePodcastRequest) → `Promise<GeneratePodcastResponse>`
3377
+ Generate a NotebookLM-style conversational podcast from product documents
3378
+
3379
+ **getStatus**(collectionId: string, podcastId: string) → `Promise<PodcastStatus>`
3380
+ Get podcast generation status
3381
+
3382
+ **generate**(collectionId: string,
3383
+ request: TTSRequest) → `Promise<Blob>`
3384
+ Generate text-to-speech audio
3385
+
3386
+ **chat**(collectionId: string,
3387
+ request: PublicChatRequest) → `Promise<PublicChatResponse>`
3388
+ Chat with product assistant (RAG)
3389
+
3390
+ **getSession**(collectionId: string, sessionId: string) → `Promise<Session>`
3391
+ Get session history
3392
+
3393
+ **clearSession**(collectionId: string, sessionId: string) → `Promise<`
3394
+ Clear session history
3395
+
3396
+ **getRateLimit**(collectionId: string, userId: string) → `Promise<RateLimitStatus>`
3397
+ Check rate limit status
3398
+
3399
+ **getToken**(collectionId: string,
3400
+ request: EphemeralTokenRequest) → `Promise<EphemeralTokenResponse>`
3401
+ Generate ephemeral token for Gemini Live
3402
+
3403
+ **isSupported**() → `boolean`
3404
+ Check if voice is supported in browser
3405
+
3406
+ **listen**(language = 'en-US') → `Promise<string>`
3407
+ Listen for voice input
3408
+
3409
+ **speak**(text: string, options?: { voice?: string; rate?: number }) → `Promise<void>`
3410
+ Speak text
3411
+
2803
3412
  **generateContent**(collectionId: string,
2804
3413
  params: AIGenerateContentRequest,
2805
3414
  admin: boolean = true) → `Promise<any>`
@@ -3519,8 +4128,9 @@ Lookup a tag by its ID (public). GET /public/nfc/findByTag/:tagId
3519
4128
  Create a new order with items. ```typescript const order = await order.create('coll_123', { orderRef: 'ORD-12345', customerId: 'CUST-789', items: [ { itemType: 'tag', itemId: 'TAG001' }, { itemType: 'tag', itemId: 'TAG002' }, { itemType: 'serial', itemId: 'SN12345' } ], status: 'pending', metadata: { shipmentId: 'SHIP-789', destination: 'Warehouse B' } }) ```
3520
4129
 
3521
4130
  **get**(collectionId: string,
3522
- orderId: string) → `Promise<GetOrderResponse>`
3523
- Get a single order by ID with all its items. ```typescript const order = await order.get('coll_123', 'order_abc123') console.log(`Order has ${order.itemCount} items`) ```
4131
+ orderId: string,
4132
+ params?: GetOrderParams) `Promise<GetOrderResponse>`
4133
+ Get a single order by ID. ```typescript // Get order without items (faster) const order = await order.get('coll_123', 'order_abc123') console.log(`Order has ${order.itemCount} items`) // Get order with items const orderWithItems = await order.get('coll_123', 'order_abc123', { includeItems: true }) console.log(orderWithItems.items) // Items array available ```
3524
4134
 
3525
4135
  **update**(collectionId: string,
3526
4136
  orderId: string,
@@ -3533,7 +4143,12 @@ Delete an order and all its items (cascade delete). ```typescript await order.re
3533
4143
 
3534
4144
  **list**(collectionId: string,
3535
4145
  params?: ListOrdersRequest) → `Promise<ListOrdersResponse>`
3536
- List orders for a collection with optional filters and pagination. Orders are returned in descending order by createdAt (newest first). ```typescript // List all orders const all = await order.list('coll_123') // List with filters const pending = await order.list('coll_123', { status: 'pending', limit: 50, offset: 0 }) // Filter by customer const customerOrders = await order.list('coll_123', { customerId: 'CUST-789' }) ```
4146
+ List orders for a collection with optional filters and pagination. Orders are returned in descending order by createdAt (newest first). ```typescript // List all orders (without items for better performance) const all = await order.list('coll_123') // List with filters const pending = await order.list('coll_123', { status: 'pending', limit: 50, offset: 0 }) // Filter by customer with items const customerOrders = await order.list('coll_123', { customerId: 'CUST-789', includeItems: true }) ```
4147
+
4148
+ **getItems**(collectionId: string,
4149
+ orderId: string,
4150
+ params?: GetOrderItemsParams) → `Promise<GetOrderItemsResponse>`
4151
+ Get items from an order with pagination support. Use this for orders with many items instead of includeItems. ```typescript // Get first page of items const page1 = await order.getItems('coll_123', 'order_abc123', { limit: 100, offset: 0 }) // Get next page const page2 = await order.getItems('coll_123', 'order_abc123', { limit: 100, offset: 100 }) ```
3537
4152
 
3538
4153
  **addItems**(collectionId: string,
3539
4154
  orderId: string,
@@ -3549,6 +4164,19 @@ Remove specific items from an order. ```typescript const updated = await order.r
3549
4164
  data: LookupOrdersRequest) → `Promise<LookupOrdersResponse>`
3550
4165
  Find all orders containing specific items (tags, proofs, or serial numbers). Use case: Scan a tag and immediately see if it's part of any order. ```typescript // Scan a tag and find associated orders const result = await order.lookup('coll_123', { items: [ { itemType: 'tag', itemId: 'TAG001' } ] }) if (result.orders.length > 0) { console.log(`Tag is part of ${result.orders.length} order(s)`) result.orders.forEach(ord => { console.log(`Order ${ord.orderRef}: ${ord.status}`) }) } // Batch lookup multiple items const batchResult = await order.lookup('coll_123', { items: [ { itemType: 'tag', itemId: 'TAG001' }, { itemType: 'serial', itemId: 'SN12345' }, { itemType: 'proof', itemId: 'proof_xyz' } ] }) ```
3551
4166
 
4167
+ **query**(collectionId: string,
4168
+ data: QueryOrdersRequest) → `Promise<QueryOrdersResponse>`
4169
+ Advanced query for orders with date filtering, metadata search, and sorting. 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 }) ```
4170
+
4171
+ **reports**(collectionId: string,
4172
+ params?: ReportsParams) → `Promise<ReportsResponse>`
4173
+ Get reports and aggregations for orders. Provides analytics grouped by status, customer, product, date, etc. ```typescript // Get order counts by status const statusReport = await order.reports('coll_123', { groupByStatus: true }) console.log(statusReport.ordersByStatus) // { pending: 45, shipped: 123, completed: 789 } // Get comprehensive analytics const fullReport = await order.reports('coll_123', { groupByStatus: true, groupByProduct: true, includeItemStats: true, createdAfter: '2026-01-01T00:00:00Z' }) console.log(fullReport.itemStats?.avgItemsPerOrder) // Get top 10 customers by order count const topCustomers = await order.reports('coll_123', { groupByCustomer: true, topN: 10 }) ```
4174
+
4175
+ **findByProduct**(collectionId: string,
4176
+ productId: string,
4177
+ params?: LookupByProductParams) → `Promise<LookupByProductResponse>`
4178
+ Find all orders containing items with a specific product ID. Uses the automatic productSummary tracking in order metadata. ```typescript // Find all orders with a specific product const result = await order.findByProduct('coll_123', 'product_abc123', { limit: 50, includeItems: false }) result.orders.forEach(ord => { const count = ord.metadata.productSummary?.['product_abc123'] ?? 0 console.log(`Order ${ord.orderRef} has ${count} items of this product`) }) ```
4179
+
3552
4180
  ### product
3553
4181
 
3554
4182
  **get**(collectionId: string,