@proveanything/smartlinks 2.1.17 → 2.1.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.
- package/dist/adminViews.d.ts +85 -0
- package/dist/adminViews.js +259 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/operations.d.ts +36 -0
- package/dist/api/operations.js +56 -0
- package/dist/api/order.d.ts +12 -1
- package/dist/api/order.js +15 -0
- package/dist/api/userGroups.d.ts +78 -0
- package/dist/api/userGroups.js +124 -0
- package/dist/docs/API_SUMMARY.md +604 -42
- package/dist/docs/admin-views.md +125 -0
- package/dist/docs/app-manifest.md +2 -0
- package/dist/docs/operations.md +281 -0
- package/dist/docs/overview.md +3 -0
- package/dist/docs/server-functions.md +18 -0
- package/dist/docs/user-groups.md +168 -0
- package/dist/docs/utils.md +17 -0
- package/dist/http.js +4 -0
- package/dist/iframeResponder.d.ts +15 -0
- package/dist/iframeResponder.js +39 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/openapi.yaml +1238 -276
- package/dist/testing/index.d.ts +13 -0
- package/dist/testing/index.js +55 -0
- package/dist/types/appManifest.d.ts +83 -0
- package/dist/types/containers.d.ts +8 -0
- package/dist/types/iframeResponder.d.ts +16 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/operations.d.ts +598 -0
- package/dist/types/operations.js +8 -0
- package/dist/types/order.d.ts +35 -6
- package/dist/types/userGroups.d.ts +103 -0
- package/dist/types/userGroups.js +5 -0
- package/dist/utils/conditions.d.ts +7 -0
- package/dist/utils/conditions.js +16 -9
- package/docs/API_SUMMARY.md +604 -42
- package/docs/admin-views.md +125 -0
- package/docs/app-manifest.md +2 -0
- package/docs/operations.md +281 -0
- package/docs/overview.md +3 -0
- package/docs/server-functions.md +18 -0
- package/docs/user-groups.md +168 -0
- package/docs/utils.md +17 -0
- package/openapi.yaml +1238 -276
- package/package.json +1 -1
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.18 | Generated: 2026-11-14T16:27:34.105Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -154,6 +154,7 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
154
154
|
- **location** - Functions for location operations
|
|
155
155
|
- **lots** - Functions for lots operations
|
|
156
156
|
- **navigation** - Functions for navigation operations
|
|
157
|
+
- **operations** - Functions for operations operations
|
|
157
158
|
- **order** - Functions for order operations
|
|
158
159
|
- **partner** - Functions for partner operations
|
|
159
160
|
- **products** - Functions for products operations
|
|
@@ -163,6 +164,7 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
163
164
|
- **tags** - Functions for tags operations
|
|
164
165
|
- **template** - Functions for template operations
|
|
165
166
|
- **translations** - Functions for translations operations
|
|
167
|
+
- **userGroups** - Functions for userGroups operations
|
|
166
168
|
|
|
167
169
|
## HTTP Utilities
|
|
168
170
|
|
|
@@ -2699,6 +2701,7 @@ interface AppFunctionDef {
|
|
|
2699
2701
|
visibility?: AppFunctionVisibility;
|
|
2700
2702
|
authority?: AppFunctionAuthority;
|
|
2701
2703
|
elevated?: boolean;
|
|
2704
|
+
userGroups?: string[];
|
|
2702
2705
|
capabilities?: string[];
|
|
2703
2706
|
dataScope?: 'collection' | 'global';
|
|
2704
2707
|
inputs?: AppFunctionInputs;
|
|
@@ -2867,6 +2870,11 @@ interface AppHistoryQuery {
|
|
|
2867
2870
|
**ServerFunctionSl** (interface)
|
|
2868
2871
|
```typescript
|
|
2869
2872
|
interface ServerFunctionSl {
|
|
2873
|
+
workOrders: WorkOrdersApi;
|
|
2874
|
+
stock: StockApi;
|
|
2875
|
+
boms: BomsApi;
|
|
2876
|
+
madeFrom: MadeFromApi;
|
|
2877
|
+
operations: OperationsApi;
|
|
2870
2878
|
bookings: ServerFunctionBookings;
|
|
2871
2879
|
appRecords: {
|
|
2872
2880
|
claim(fields: Record<string, any>): Promise<AppRecordClaimResult>;
|
|
@@ -2902,6 +2910,7 @@ interface ServerFunctionCaller {
|
|
|
2902
2910
|
origin?: string | null;
|
|
2903
2911
|
ip?: string | null;
|
|
2904
2912
|
via: AppFunctionTriggerType;
|
|
2913
|
+
userGroups: readonly string[];
|
|
2905
2914
|
}
|
|
2906
2915
|
```
|
|
2907
2916
|
|
|
@@ -3048,6 +3057,20 @@ interface PublicView {
|
|
|
3048
3057
|
}
|
|
3049
3058
|
```
|
|
3050
3059
|
|
|
3060
|
+
**AdminView** (interface)
|
|
3061
|
+
```typescript
|
|
3062
|
+
interface AdminView {
|
|
3063
|
+
id: string;
|
|
3064
|
+
title: string;
|
|
3065
|
+
path: string;
|
|
3066
|
+
group?: 'main' | 'settings' | 'record';
|
|
3067
|
+
within?: string;
|
|
3068
|
+
icon?: string;
|
|
3069
|
+
description?: string;
|
|
3070
|
+
params?: Record<string, string>;
|
|
3071
|
+
}
|
|
3072
|
+
```
|
|
3073
|
+
|
|
3051
3074
|
**AppManifest** (interface)
|
|
3052
3075
|
```typescript
|
|
3053
3076
|
interface AppManifest {
|
|
@@ -3083,6 +3106,7 @@ interface AppManifest {
|
|
|
3083
3106
|
};
|
|
3084
3107
|
linkable?: DeepLinkEntry[];
|
|
3085
3108
|
publicViews?: PublicView[];
|
|
3109
|
+
adminViews?: AdminView[];
|
|
3086
3110
|
executor?: AppManifestExecutor;
|
|
3087
3111
|
functions?: AppManifestFunctions;
|
|
3088
3112
|
realtime?: { channels: RealtimeChannelDeclaration[] };
|
|
@@ -7347,6 +7371,7 @@ interface Container {
|
|
|
7347
7371
|
status: ContainerStatus
|
|
7348
7372
|
metadata?: Record<string, any>
|
|
7349
7373
|
parentContainerId?: string
|
|
7374
|
+
fixed?: boolean
|
|
7350
7375
|
children?: Container[]
|
|
7351
7376
|
items?: ContainerItem[]
|
|
7352
7377
|
createdAt: string
|
|
@@ -7382,6 +7407,7 @@ interface CreateContainerInput {
|
|
|
7382
7407
|
status?: ContainerStatus
|
|
7383
7408
|
metadata?: Record<string, any>
|
|
7384
7409
|
parentContainerId?: string
|
|
7410
|
+
fixed?: boolean
|
|
7385
7411
|
}
|
|
7386
7412
|
```
|
|
7387
7413
|
|
|
@@ -7395,6 +7421,7 @@ interface UpdateContainerInput {
|
|
|
7395
7421
|
status?: ContainerStatus
|
|
7396
7422
|
metadata?: Record<string, any>
|
|
7397
7423
|
parentContainerId?: string | null
|
|
7424
|
+
fixed?: boolean
|
|
7398
7425
|
}
|
|
7399
7426
|
```
|
|
7400
7427
|
|
|
@@ -7885,6 +7912,8 @@ interface IframeResponderOptions {
|
|
|
7885
7912
|
) => Promise<void>;
|
|
7886
7913
|
onAuthLogout?: () => Promise<void>;
|
|
7887
7914
|
onRouteChange?: (path: string, state: Record<string, string>) => void;
|
|
7915
|
+
onNavigable?: (info: { views: string[]; chrome: 'none' | 'full' }) => void;
|
|
7916
|
+
onNavigateResult?: (result: { ok: boolean; view: string | null; path: string | null; reason?: string }) => void;
|
|
7888
7917
|
autoHeight?: boolean | { minHeight?: number };
|
|
7889
7918
|
onResize?: (height: number) => void;
|
|
7890
7919
|
onError?: (error: Error) => void;
|
|
@@ -7914,7 +7943,9 @@ interface SmartlinksIframeMessage {
|
|
|
7914
7943
|
| 'smartlinks:redirect'
|
|
7915
7944
|
| 'smartlinks:authkit:login'
|
|
7916
7945
|
| 'smartlinks:authkit:logout'
|
|
7917
|
-
| 'smartlinks:authkit:redirect'
|
|
7946
|
+
| 'smartlinks:authkit:redirect'
|
|
7947
|
+
| 'smartlinks:navigable'
|
|
7948
|
+
| 'smartlinks:navigate-result';
|
|
7918
7949
|
payload: Record<string, any>;
|
|
7919
7950
|
messageId?: string;
|
|
7920
7951
|
}
|
|
@@ -9640,6 +9671,355 @@ interface TagContext {
|
|
|
9640
9671
|
|
|
9641
9672
|
**TagStatus** = `'valid' | 'rescan' | 'invalid' | 'error'`
|
|
9642
9673
|
|
|
9674
|
+
### operations
|
|
9675
|
+
|
|
9676
|
+
**WorkOrderStage** (interface)
|
|
9677
|
+
```typescript
|
|
9678
|
+
interface WorkOrderStage {
|
|
9679
|
+
key: string
|
|
9680
|
+
position: number
|
|
9681
|
+
status: WorkOrderStageStatus
|
|
9682
|
+
plannedStart: string | null
|
|
9683
|
+
plannedEnd: string | null
|
|
9684
|
+
startedAt: string | null
|
|
9685
|
+
doneAt: string | null
|
|
9686
|
+
quantityDone: number
|
|
9687
|
+
quantityScrapped: number
|
|
9688
|
+
data: Record<string, any>
|
|
9689
|
+
}
|
|
9690
|
+
```
|
|
9691
|
+
|
|
9692
|
+
**WorkOrder** (interface)
|
|
9693
|
+
```typescript
|
|
9694
|
+
interface WorkOrder {
|
|
9695
|
+
id: string
|
|
9696
|
+
collectionId: string
|
|
9697
|
+
appId: string
|
|
9698
|
+
ref: string
|
|
9699
|
+
kind: string | null
|
|
9700
|
+
productId: string | null
|
|
9701
|
+
variantId: string | null
|
|
9702
|
+
quantity: number
|
|
9703
|
+
unit: string
|
|
9704
|
+
dueAt: string | null
|
|
9705
|
+
priority: number
|
|
9706
|
+
status: WorkOrderStatus
|
|
9707
|
+
statusReason: string | null
|
|
9708
|
+
orderId: string | null
|
|
9709
|
+
orderItemId: string | null
|
|
9710
|
+
parentId: string | null
|
|
9711
|
+
outputBatchId: string | null
|
|
9712
|
+
stages: WorkOrderStage[]
|
|
9713
|
+
currentStage: string | null
|
|
9714
|
+
late: boolean
|
|
9715
|
+
data: Record<string, any>
|
|
9716
|
+
createdBy: string | null
|
|
9717
|
+
createdAt: string
|
|
9718
|
+
updatedAt: string
|
|
9719
|
+
closedAt: string | null
|
|
9720
|
+
}
|
|
9721
|
+
```
|
|
9722
|
+
|
|
9723
|
+
**CreateWorkOrderInput** (interface)
|
|
9724
|
+
```typescript
|
|
9725
|
+
interface CreateWorkOrderInput {
|
|
9726
|
+
ref: string
|
|
9727
|
+
kind?: string
|
|
9728
|
+
productId?: string
|
|
9729
|
+
variantId?: string
|
|
9730
|
+
quantity?: number
|
|
9731
|
+
unit?: string
|
|
9732
|
+
dueAt?: string | null
|
|
9733
|
+
priority?: number
|
|
9734
|
+
orderId?: string
|
|
9735
|
+
orderItemId?: string
|
|
9736
|
+
parentId?: string
|
|
9737
|
+
outputBatchId?: string
|
|
9738
|
+
data?: Record<string, any>
|
|
9739
|
+
stages?: WorkOrderStageInput[]
|
|
9740
|
+
}
|
|
9741
|
+
```
|
|
9742
|
+
|
|
9743
|
+
**WorkOrderListParams** (interface)
|
|
9744
|
+
```typescript
|
|
9745
|
+
interface WorkOrderListParams {
|
|
9746
|
+
status?: WorkOrderStatus | WorkOrderStatus[]
|
|
9747
|
+
appId?: string
|
|
9748
|
+
productId?: string
|
|
9749
|
+
orderId?: string
|
|
9750
|
+
parentId?: string
|
|
9751
|
+
kind?: string
|
|
9752
|
+
late?: boolean
|
|
9753
|
+
dueFrom?: string
|
|
9754
|
+
dueTo?: string
|
|
9755
|
+
q?: string
|
|
9756
|
+
sort?: 'due' | 'priority' | 'created' | 'ref'
|
|
9757
|
+
limit?: number
|
|
9758
|
+
offset?: number
|
|
9759
|
+
}
|
|
9760
|
+
```
|
|
9761
|
+
|
|
9762
|
+
**WorkOrdersApi** (interface)
|
|
9763
|
+
```typescript
|
|
9764
|
+
interface WorkOrdersApi {
|
|
9765
|
+
get(idOrRef: string): Promise<WorkOrder | null>
|
|
9766
|
+
list(params?: WorkOrderListParams): Promise<{ items: WorkOrder[]; total: number; limit: number; offset: number }>
|
|
9767
|
+
create(input: CreateWorkOrderInput): Promise<WorkOrder>
|
|
9768
|
+
update(idOrRef: string, patch: UpdateWorkOrderInput, opts?: { reason?: string }): Promise<WorkOrder>
|
|
9769
|
+
setStatus(idOrRef: string, status: WorkOrderStatus, opts?: { reason?: string }): Promise<WorkOrder>
|
|
9770
|
+
remove(idOrRef: string): Promise<{ id: string; deleted: true }>
|
|
9771
|
+
startStage(idOrRef: string, stage: string): Promise<WorkOrder>
|
|
9772
|
+
progress(idOrRef: string, stage: string, by: { done?: number; scrapped?: number }, opts?: { reason?: string; note?: string }): Promise<WorkOrder>
|
|
9773
|
+
completeStage(idOrRef: string, stage: string, opts?: { closeWorkOrder?: boolean }): Promise<WorkOrder>
|
|
9774
|
+
skipStage(idOrRef: string, stage: string, opts: { reason: string }): Promise<WorkOrder>
|
|
9775
|
+
planStage(idOrRef: string, stage: string, plan: { plannedStart?: string | null; plannedEnd?: string | null; data?: Record<string, any> }): Promise<WorkOrder>
|
|
9776
|
+
setStages(idOrRef: string, stages: WorkOrderStageInput[]): Promise<WorkOrder>
|
|
9777
|
+
}
|
|
9778
|
+
```
|
|
9779
|
+
|
|
9780
|
+
**StockTarget** (interface)
|
|
9781
|
+
```typescript
|
|
9782
|
+
interface StockTarget {
|
|
9783
|
+
type: string; id: string
|
|
9784
|
+
}
|
|
9785
|
+
```
|
|
9786
|
+
|
|
9787
|
+
**StockLine** (interface)
|
|
9788
|
+
```typescript
|
|
9789
|
+
interface StockLine {
|
|
9790
|
+
id: string
|
|
9791
|
+
containerId: string
|
|
9792
|
+
productId: string
|
|
9793
|
+
variantId: string | null
|
|
9794
|
+
batchId: string | null
|
|
9795
|
+
state: StockState
|
|
9796
|
+
allocatedTo: StockTarget | null
|
|
9797
|
+
quantity: number
|
|
9798
|
+
unit: string
|
|
9799
|
+
updatedAt: string
|
|
9800
|
+
}
|
|
9801
|
+
```
|
|
9802
|
+
|
|
9803
|
+
**StockTotals** (interface)
|
|
9804
|
+
```typescript
|
|
9805
|
+
interface StockTotals {
|
|
9806
|
+
available: number; allocated: number; held: number; quarantine: number; total: number; unit: string | null
|
|
9807
|
+
}
|
|
9808
|
+
```
|
|
9809
|
+
|
|
9810
|
+
**StockItem** (interface)
|
|
9811
|
+
```typescript
|
|
9812
|
+
interface StockItem {
|
|
9813
|
+
productId: string; variantId?: string; batchId?: string; quantity: number; unit?: string
|
|
9814
|
+
}
|
|
9815
|
+
```
|
|
9816
|
+
|
|
9817
|
+
**StockMovementExtras** (interface)
|
|
9818
|
+
```typescript
|
|
9819
|
+
interface StockMovementExtras {
|
|
9820
|
+
workOrderId?: string; reason?: string; note?: string
|
|
9821
|
+
}
|
|
9822
|
+
```
|
|
9823
|
+
|
|
9824
|
+
**StockMovementOptions** (interface)
|
|
9825
|
+
```typescript
|
|
9826
|
+
interface StockMovementOptions {
|
|
9827
|
+
idempotencyKey?: string
|
|
9828
|
+
}
|
|
9829
|
+
```
|
|
9830
|
+
|
|
9831
|
+
**StockMovement** (interface)
|
|
9832
|
+
```typescript
|
|
9833
|
+
interface StockMovement {
|
|
9834
|
+
movementId: string
|
|
9835
|
+
kind: 'receive' | 'produce' | 'consume' | 'move' | 'allocate' | 'release' | 'hold' | 'unhold' | 'adjust'
|
|
9836
|
+
productId: string
|
|
9837
|
+
quantity: number
|
|
9838
|
+
unit: string
|
|
9839
|
+
from?: (StockLine & { emptied?: boolean }) | null
|
|
9840
|
+
to?: StockLine | null
|
|
9841
|
+
replayed: boolean
|
|
9842
|
+
}
|
|
9843
|
+
```
|
|
9844
|
+
|
|
9845
|
+
**StockPosition** (interface)
|
|
9846
|
+
```typescript
|
|
9847
|
+
interface StockPosition {
|
|
9848
|
+
product: { id: string; variantId: string | null; name: string | null; unit: string | null }
|
|
9849
|
+
onHand: StockTotals
|
|
9850
|
+
where: Array<{ containerId: string; container: StockWhereLine['container']; path: string; place: StockWhereLine['place']; quantity: number; batchId: string | null; state: StockState; allocatedTo: StockTarget | null }>
|
|
9851
|
+
onOrder: { total: number; lines: Array<{ orderId: string; orderRef: string | null; supplier: string | null; quantity: number; dueAt: string | null }> }
|
|
9852
|
+
beingMade: { total: number; lines: Array<{ workOrderId: string; ref: string; quantity: number; stage: string | null; status: WorkOrderStatus; dueAt: string | null }> }
|
|
9853
|
+
needed: { total: number; lines: Array<{ orderId?: string; orderRef?: string | null; workOrderId?: string; ref?: string; forProductId: string; quantity: number; neededBy: string | null; why: 'ordered' | 'work order' | 'order, not yet in production' }> }
|
|
9854
|
+
projected: Array<{ date: string; balance: number }>
|
|
9855
|
+
shortfall: { quantity: number; firstShortOn: string } | null
|
|
9856
|
+
horizonDays: number
|
|
9857
|
+
undatedLines?: number
|
|
9858
|
+
asOf: string
|
|
9859
|
+
sources: { stock: string; orders: string; workOrders: string }
|
|
9860
|
+
}
|
|
9861
|
+
```
|
|
9862
|
+
|
|
9863
|
+
**StockApi** (interface)
|
|
9864
|
+
```typescript
|
|
9865
|
+
interface StockApi {
|
|
9866
|
+
lines(params?: { containerId?: string; productId?: string; variantId?: string; batchId?: string; state?: StockState; allocatedTo?: StockTarget; limit?: number; offset?: number }): Promise<{ items: StockLine[]; total: number; limit: number; offset: number }>
|
|
9867
|
+
totals(params: { productId: string; variantId?: string; batchId?: string }): Promise<StockTotals>
|
|
9868
|
+
where(params: { productId: string; variantId?: string; batchId?: string; state?: StockState }): Promise<StockWhereLine[]>
|
|
9869
|
+
position(params: { productId: string; variantId?: string; horizonDays?: number; includeWhere?: boolean }): Promise<StockPosition>
|
|
9870
|
+
short(params?: { horizonDays?: number; limit?: number }): Promise<{ horizonDays: number; items: Array<{ product: StockPosition['product']; shortfall: NonNullable<StockPosition['shortfall']>; onHand: StockTotals; onOrder: number; beingMade: number; needed: number }>; checked: number; asOf: string }>
|
|
9871
|
+
receive(input: StockItem & StockMovementExtras & { containerId: string; state?: 'available' | 'held' | 'quarantine' }, opts?: StockMovementOptions): Promise<StockMovement>
|
|
9872
|
+
produce(input: StockItem & StockMovementExtras & { containerId: string; state?: 'available' | 'held' | 'quarantine' }, opts?: StockMovementOptions): Promise<StockMovement>
|
|
9873
|
+
consume(input: StockItem & StockMovementExtras & { containerId: string; allocatedTo?: StockTarget }, opts?: StockMovementOptions): Promise<StockMovement>
|
|
9874
|
+
move(input: StockItem & StockMovementExtras & { from: string; to: string; state?: StockState; allocatedTo?: StockTarget }, opts?: StockMovementOptions): Promise<StockMovement>
|
|
9875
|
+
allocate(input: StockItem & StockMovementExtras & { containerId: string; to: StockTarget }, opts?: StockMovementOptions): Promise<StockMovement>
|
|
9876
|
+
release(input: StockItem & StockMovementExtras & { containerId: string; from: StockTarget }, opts?: StockMovementOptions): Promise<StockMovement>
|
|
9877
|
+
hold(input: StockItem & StockMovementExtras & { containerId: string; state?: 'held' | 'quarantine'; reason: string }, opts?: StockMovementOptions): Promise<StockMovement>
|
|
9878
|
+
unhold(input: StockItem & StockMovementExtras & { containerId: string; state?: 'held' | 'quarantine'; reason: string }, opts?: StockMovementOptions): Promise<StockMovement>
|
|
9879
|
+
adjust(input: Omit<StockItem, 'quantity'> & StockMovementExtras & { containerId: string; by: number; state?: 'available' | 'held' | 'quarantine'; reason: string }, opts?: StockMovementOptions): Promise<StockMovement>
|
|
9880
|
+
}
|
|
9881
|
+
```
|
|
9882
|
+
|
|
9883
|
+
**BomLine** (interface)
|
|
9884
|
+
```typescript
|
|
9885
|
+
interface BomLine {
|
|
9886
|
+
componentProductId: string; componentVariantId?: string | null; quantity: number; unit?: string; optional?: boolean; note?: string | null
|
|
9887
|
+
}
|
|
9888
|
+
```
|
|
9889
|
+
|
|
9890
|
+
**Bom** (interface)
|
|
9891
|
+
```typescript
|
|
9892
|
+
interface Bom {
|
|
9893
|
+
id: string
|
|
9894
|
+
productId: string
|
|
9895
|
+
variantId: string | null
|
|
9896
|
+
version: number
|
|
9897
|
+
validFrom: string
|
|
9898
|
+
validTo: string | null
|
|
9899
|
+
yields: number
|
|
9900
|
+
note: string | null
|
|
9901
|
+
lines: Array<{ componentProductId: string; componentVariantId: string | null; quantity: number; unit: string; optional: boolean; note: string | null }>
|
|
9902
|
+
data: Record<string, any>
|
|
9903
|
+
createdBy: string | null
|
|
9904
|
+
createdAt: string
|
|
9905
|
+
}
|
|
9906
|
+
```
|
|
9907
|
+
|
|
9908
|
+
**BomTreeNode** (interface)
|
|
9909
|
+
```typescript
|
|
9910
|
+
interface BomTreeNode {
|
|
9911
|
+
productId: string; variantId: string | null; quantity: number; unit: string; optional: boolean; components: BomTreeNode[]
|
|
9912
|
+
}
|
|
9913
|
+
```
|
|
9914
|
+
|
|
9915
|
+
**BomExplosion** (interface)
|
|
9916
|
+
```typescript
|
|
9917
|
+
interface BomExplosion {
|
|
9918
|
+
productId: string
|
|
9919
|
+
variantId: string | null
|
|
9920
|
+
quantity: number
|
|
9921
|
+
hasBom: boolean
|
|
9922
|
+
tree: BomTreeNode[]
|
|
9923
|
+
materials: Array<{ productId: string; variantId: string | null; quantity: number; unit: string }>
|
|
9924
|
+
}
|
|
9925
|
+
```
|
|
9926
|
+
|
|
9927
|
+
**BomsApi** (interface)
|
|
9928
|
+
```typescript
|
|
9929
|
+
interface BomsApi {
|
|
9930
|
+
current(params: { productId: string; variantId?: string; at?: string }): Promise<Bom | null>
|
|
9931
|
+
versions(params: { productId: string; variantId?: string }): Promise<Bom[]>
|
|
9932
|
+
whereUsed(params: { componentProductId: string }): Promise<Array<{ productId: string; variantId: string | null; quantity: number; unit: string; yields: number; optional: boolean }>>
|
|
9933
|
+
explode(params: { productId: string; variantId?: string; quantity?: number; at?: string; includeOptional?: boolean }): Promise<BomExplosion>
|
|
9934
|
+
set(input: { productId: string; variantId?: string; lines: BomLine[]; yields?: number; note?: string; validFrom?: string; data?: Record<string, any> }): Promise<Bom>
|
|
9935
|
+
end(params: { productId: string; variantId?: string }): Promise<Bom | null>
|
|
9936
|
+
}
|
|
9937
|
+
```
|
|
9938
|
+
|
|
9939
|
+
**MadeFromSubject** (interface)
|
|
9940
|
+
```typescript
|
|
9941
|
+
interface MadeFromSubject {
|
|
9942
|
+
type: 'batch' | 'proof'; id: string
|
|
9943
|
+
}
|
|
9944
|
+
```
|
|
9945
|
+
|
|
9946
|
+
**MadeFromSource** (interface)
|
|
9947
|
+
```typescript
|
|
9948
|
+
interface MadeFromSource {
|
|
9949
|
+
type: 'batch' | 'proof' | 'product'; id: string
|
|
9950
|
+
}
|
|
9951
|
+
```
|
|
9952
|
+
|
|
9953
|
+
**MadeFromEntry** (interface)
|
|
9954
|
+
```typescript
|
|
9955
|
+
interface MadeFromEntry {
|
|
9956
|
+
id: string
|
|
9957
|
+
subject: MadeFromSubject
|
|
9958
|
+
source: MadeFromSource
|
|
9959
|
+
productId: string | null
|
|
9960
|
+
quantity: number | null
|
|
9961
|
+
unit: string | null
|
|
9962
|
+
workOrderId: string | null
|
|
9963
|
+
at: string
|
|
9964
|
+
by: string | null
|
|
9965
|
+
endedAt: string | null
|
|
9966
|
+
data: Record<string, any>
|
|
9967
|
+
}
|
|
9968
|
+
```
|
|
9969
|
+
|
|
9970
|
+
**MadeFromTraceNode** (interface)
|
|
9971
|
+
```typescript
|
|
9972
|
+
interface MadeFromTraceNode {
|
|
9973
|
+
source: MadeFromSource; productId: string | null; quantity: number | null; unit: string | null; at: string; workOrderId: string | null; madeFrom: MadeFromTraceNode[]
|
|
9974
|
+
}
|
|
9975
|
+
```
|
|
9976
|
+
|
|
9977
|
+
**MadeFromApi** (interface)
|
|
9978
|
+
```typescript
|
|
9979
|
+
interface MadeFromApi {
|
|
9980
|
+
of(subject: MadeFromSubject, opts?: { at?: string; includeEnded?: boolean }): Promise<MadeFromEntry[]>
|
|
9981
|
+
usedIn(source: MadeFromSource, opts?: { includeEnded?: boolean }): Promise<MadeFromEntry[]>
|
|
9982
|
+
trace(subject: MadeFromSubject, opts?: { depth?: number }): Promise<{ subject: MadeFromSubject; madeFrom: MadeFromTraceNode[] }>
|
|
9983
|
+
record(input: { subject: MadeFromSubject; sources: Array<MadeFromSource & { productId?: string; quantity?: number; unit?: string; data?: Record<string, any> }>; workOrderId?: string; at?: string }): Promise<MadeFromEntry[]>
|
|
9984
|
+
end(id: string, opts: { reason: string }): Promise<MadeFromEntry>
|
|
9985
|
+
}
|
|
9986
|
+
```
|
|
9987
|
+
|
|
9988
|
+
**OperationStep** (interface)
|
|
9989
|
+
```typescript
|
|
9990
|
+
interface OperationStep {
|
|
9991
|
+
op: string; args: any[]
|
|
9992
|
+
}
|
|
9993
|
+
```
|
|
9994
|
+
|
|
9995
|
+
**OperationsApi** (interface)
|
|
9996
|
+
```typescript
|
|
9997
|
+
interface OperationsApi {
|
|
9998
|
+
transaction(steps: OperationStep[]): Promise<{ results: any[] }>
|
|
9999
|
+
}
|
|
10000
|
+
```
|
|
10001
|
+
|
|
10002
|
+
**OperationsAdmin** (interface)
|
|
10003
|
+
```typescript
|
|
10004
|
+
interface OperationsAdmin {
|
|
10005
|
+
workOrders: WorkOrdersApi
|
|
10006
|
+
stock: StockApi
|
|
10007
|
+
boms: BomsApi
|
|
10008
|
+
madeFrom: MadeFromApi
|
|
10009
|
+
transaction: OperationsApi['transaction']
|
|
10010
|
+
}
|
|
10011
|
+
```
|
|
10012
|
+
|
|
10013
|
+
**WorkOrderStatus** = `'open' | 'on-hold' | 'blocked' | 'done' | 'cancelled'`
|
|
10014
|
+
|
|
10015
|
+
**WorkOrderStageStatus** = `'pending' | 'active' | 'done' | 'skipped'`
|
|
10016
|
+
|
|
10017
|
+
**WorkOrderStageInput** = `string | { key: string`
|
|
10018
|
+
|
|
10019
|
+
**UpdateWorkOrderInput** = `Partial<Omit<CreateWorkOrderInput, 'ref' | 'stages' | 'parentId'>>`
|
|
10020
|
+
|
|
10021
|
+
**StockState** = `'available' | 'allocated' | 'held' | 'quarantine'`
|
|
10022
|
+
|
|
9643
10023
|
### order
|
|
9644
10024
|
|
|
9645
10025
|
**OrderItem** (interface)
|
|
@@ -9647,18 +10027,44 @@ interface TagContext {
|
|
|
9647
10027
|
interface OrderItem {
|
|
9648
10028
|
id: string // UUID
|
|
9649
10029
|
orderId: string // Parent order ID
|
|
9650
|
-
itemType: 'tag' | 'proof' | 'serial' // Type of item
|
|
9651
|
-
itemId: string // The tag ID, proof ID, or serial number
|
|
10030
|
+
itemType: 'tag' | 'proof' | 'serial' | 'product' // Type of item ('product' = a quantity line)
|
|
10031
|
+
itemId: string // The tag ID, proof ID, or serial number (the product ID on a quantity line)
|
|
9652
10032
|
collectionId?: string // Collection ID
|
|
9653
10033
|
productId?: string // Product ID
|
|
9654
10034
|
variantId?: string | null // Variant ID
|
|
9655
10035
|
batchId?: string | null // Batch ID
|
|
10036
|
+
quantity: number // How many (1 for an identified thing)
|
|
10037
|
+
unit?: string | null // The unit the quantity is in
|
|
10038
|
+
quantityDone: number // Shipped (sales) or received (purchase) so far
|
|
10039
|
+
dueAt?: string | null // When this line is wanted or expected, if different from the order's
|
|
9656
10040
|
metadata: Record<string, any> // Item-specific metadata
|
|
9657
10041
|
createdAt: string // ISO 8601 timestamp
|
|
9658
10042
|
order?: OrderSummary // Optional order summary (when includeOrder=true)
|
|
9659
10043
|
}
|
|
9660
10044
|
```
|
|
9661
10045
|
|
|
10046
|
+
**OrderItemInput** (interface)
|
|
10047
|
+
```typescript
|
|
10048
|
+
interface OrderItemInput {
|
|
10049
|
+
itemType: 'tag' | 'proof' | 'serial' // Required: Type of item
|
|
10050
|
+
itemId: string // Required: Item identifier
|
|
10051
|
+
metadata?: Record<string, any> // Optional: Item-specific data
|
|
10052
|
+
}
|
|
10053
|
+
```
|
|
10054
|
+
|
|
10055
|
+
**OrderQuantityLineInput** (interface)
|
|
10056
|
+
```typescript
|
|
10057
|
+
interface OrderQuantityLineInput {
|
|
10058
|
+
itemType?: 'product'
|
|
10059
|
+
productId: string // Required: The product
|
|
10060
|
+
variantId?: string
|
|
10061
|
+
quantity: number // Required: How many
|
|
10062
|
+
unit?: string
|
|
10063
|
+
dueAt?: string // Optional: When this line is wanted or expected
|
|
10064
|
+
metadata?: Record<string, any>
|
|
10065
|
+
}
|
|
10066
|
+
```
|
|
10067
|
+
|
|
9662
10068
|
**OrderSummary** (interface)
|
|
9663
10069
|
```typescript
|
|
9664
10070
|
interface OrderSummary {
|
|
@@ -9679,6 +10085,9 @@ interface Order {
|
|
|
9679
10085
|
orderRef?: string // Customer's own order reference/ID (e.g., "ORD-12345")
|
|
9680
10086
|
customerId?: string // Customer's own customer ID (can map to CRM/contacts)
|
|
9681
10087
|
status: string // e.g., "pending", "processing", "shipped", "completed"
|
|
10088
|
+
direction: OrderDirection // 'sales' (someone wants it from us) or 'purchase' (we want it from a supplier)
|
|
10089
|
+
partyId?: string | null // The supplier, on a purchase order
|
|
10090
|
+
dueAt?: string | null // When it is wanted or expected
|
|
9682
10091
|
itemCount: number // Cached count of items (maintained automatically)
|
|
9683
10092
|
metadata: {
|
|
9684
10093
|
productSummary?: Record<string, number> // productId -> count (auto-maintained)
|
|
@@ -9693,11 +10102,10 @@ interface Order {
|
|
|
9693
10102
|
**CreateOrderRequest** (interface)
|
|
9694
10103
|
```typescript
|
|
9695
10104
|
interface CreateOrderRequest {
|
|
9696
|
-
items: Array<
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
}>
|
|
10105
|
+
items: Array<OrderItemInput | OrderQuantityLineInput>
|
|
10106
|
+
direction?: OrderDirection // Optional: 'sales' (default) or 'purchase'
|
|
10107
|
+
partyId?: string // Optional: The supplier, on a purchase order
|
|
10108
|
+
dueAt?: string // Optional: When it is wanted or expected
|
|
9701
10109
|
orderRef?: string // Optional: Your own order reference/ID
|
|
9702
10110
|
customerId?: string // Optional: Your customer ID
|
|
9703
10111
|
status?: string // Optional: Order status (default: "pending")
|
|
@@ -9715,6 +10123,9 @@ interface GetOrderParams {
|
|
|
9715
10123
|
**UpdateOrderRequest** (interface)
|
|
9716
10124
|
```typescript
|
|
9717
10125
|
interface UpdateOrderRequest {
|
|
10126
|
+
direction?: OrderDirection // Optional: 'sales' or 'purchase'
|
|
10127
|
+
partyId?: string | null // Optional: The supplier
|
|
10128
|
+
dueAt?: string | null // Optional: When it is wanted or expected
|
|
9718
10129
|
orderRef?: string // Optional: Update order reference
|
|
9719
10130
|
customerId?: string // Optional: Update customer ID
|
|
9720
10131
|
status?: string // Optional: Update status
|
|
@@ -9737,6 +10148,8 @@ interface ListOrdersRequest {
|
|
|
9737
10148
|
status?: string // Optional: Filter by status
|
|
9738
10149
|
orderRef?: string // Optional: Filter by order reference
|
|
9739
10150
|
customerId?: string // Optional: Filter by customer ID
|
|
10151
|
+
direction?: OrderDirection // Optional: Only sales, or only purchase, orders
|
|
10152
|
+
partyId?: string // Optional: Filter by supplier
|
|
9740
10153
|
includeItems?: boolean // Optional: Include items array (default: false)
|
|
9741
10154
|
}
|
|
9742
10155
|
```
|
|
@@ -10126,6 +10539,8 @@ interface CollectionSummaryResponse {
|
|
|
10126
10539
|
}
|
|
10127
10540
|
```
|
|
10128
10541
|
|
|
10542
|
+
**OrderDirection** = `'sales' | 'purchase'`
|
|
10543
|
+
|
|
10129
10544
|
### product
|
|
10130
10545
|
|
|
10131
10546
|
**ProductKey** (interface)
|
|
@@ -11132,6 +11547,107 @@ interface TranslationUpdateRequest {
|
|
|
11132
11547
|
|
|
11133
11548
|
**TranslationLookupRequest** = `TranslationLookupSingleRequest | TranslationLookupBatchRequest`
|
|
11134
11549
|
|
|
11550
|
+
### userGroups
|
|
11551
|
+
|
|
11552
|
+
**UserGroup** (interface)
|
|
11553
|
+
```typescript
|
|
11554
|
+
interface UserGroup {
|
|
11555
|
+
id: string
|
|
11556
|
+
collectionId?: string
|
|
11557
|
+
key?: string
|
|
11558
|
+
name: string
|
|
11559
|
+
description?: string
|
|
11560
|
+
members?: string[]
|
|
11561
|
+
createdAt?: string
|
|
11562
|
+
updatedAt?: string
|
|
11563
|
+
deleted?: boolean
|
|
11564
|
+
deletedAt?: string | null
|
|
11565
|
+
[extra: string]: any
|
|
11566
|
+
}
|
|
11567
|
+
```
|
|
11568
|
+
|
|
11569
|
+
**CreateUserGroupRequest** (interface)
|
|
11570
|
+
```typescript
|
|
11571
|
+
interface CreateUserGroupRequest {
|
|
11572
|
+
name: string
|
|
11573
|
+
key?: string
|
|
11574
|
+
description?: string
|
|
11575
|
+
members?: string[]
|
|
11576
|
+
[extra: string]: any
|
|
11577
|
+
}
|
|
11578
|
+
```
|
|
11579
|
+
|
|
11580
|
+
**UpdateUserGroupRequest** (interface)
|
|
11581
|
+
```typescript
|
|
11582
|
+
interface UpdateUserGroupRequest {
|
|
11583
|
+
name?: string
|
|
11584
|
+
description?: string
|
|
11585
|
+
members?: string[]
|
|
11586
|
+
[extra: string]: any
|
|
11587
|
+
}
|
|
11588
|
+
```
|
|
11589
|
+
|
|
11590
|
+
**UserGroupMember** (interface)
|
|
11591
|
+
```typescript
|
|
11592
|
+
interface UserGroupMember {
|
|
11593
|
+
uid: string
|
|
11594
|
+
name?: string | null
|
|
11595
|
+
email?: string | null
|
|
11596
|
+
}
|
|
11597
|
+
```
|
|
11598
|
+
|
|
11599
|
+
**UserGroupRef** (interface)
|
|
11600
|
+
```typescript
|
|
11601
|
+
interface UserGroupRef {
|
|
11602
|
+
id: string
|
|
11603
|
+
key: string | null
|
|
11604
|
+
name: string | null
|
|
11605
|
+
}
|
|
11606
|
+
```
|
|
11607
|
+
|
|
11608
|
+
**MyUserGroups** (interface)
|
|
11609
|
+
```typescript
|
|
11610
|
+
interface MyUserGroups {
|
|
11611
|
+
userGroups: string[]
|
|
11612
|
+
userGroupIds: string[]
|
|
11613
|
+
}
|
|
11614
|
+
```
|
|
11615
|
+
|
|
11616
|
+
**UserGroupChange** (interface)
|
|
11617
|
+
```typescript
|
|
11618
|
+
interface UserGroupChange {
|
|
11619
|
+
id: string
|
|
11620
|
+
at: string
|
|
11621
|
+
type: UserGroupChangeType
|
|
11622
|
+
entityId: string | null
|
|
11623
|
+
data: {
|
|
11624
|
+
userGroupId: string
|
|
11625
|
+
key: string | null
|
|
11626
|
+
name: string | null
|
|
11627
|
+
userId?: string
|
|
11628
|
+
previousName?: string | null
|
|
11629
|
+
members?: string[]
|
|
11630
|
+
}
|
|
11631
|
+
actorType: string | null
|
|
11632
|
+
actorId: string | null
|
|
11633
|
+
}
|
|
11634
|
+
```
|
|
11635
|
+
|
|
11636
|
+
**UserGroupHistoryParams** (interface)
|
|
11637
|
+
```typescript
|
|
11638
|
+
interface UserGroupHistoryParams {
|
|
11639
|
+
userGroupId?: string
|
|
11640
|
+
userId?: string
|
|
11641
|
+
from?: string
|
|
11642
|
+
to?: string
|
|
11643
|
+
limit?: number
|
|
11644
|
+
}
|
|
11645
|
+
```
|
|
11646
|
+
|
|
11647
|
+
**AddUserGroupMemberRequest** = ``
|
|
11648
|
+
|
|
11649
|
+
**UserGroupChangeType** = ``
|
|
11650
|
+
|
|
11135
11651
|
### variant
|
|
11136
11652
|
|
|
11137
11653
|
**VariantResponse** (interface)
|
|
@@ -13436,97 +13952,108 @@ Validate an NFC tag payload (public). POST /public/nfc/validate
|
|
|
13436
13952
|
**lookupTag**(tagId: string) → `Promise<NfcTagInfo[]>`
|
|
13437
13953
|
Lookup a tag by its ID (public). GET /public/nfc/findByTag/:tagId
|
|
13438
13954
|
|
|
13955
|
+
### operations
|
|
13956
|
+
|
|
13957
|
+
**admin**(collectionId: string, opts: { appId?: string } = {}) → `OperationsAdmin`
|
|
13958
|
+
The operations objects for one collection (admin). but a work order is always created for an app, so `workOrders.create` needs this. ```typescript const ops = operations.admin('coll_123', { appId: 'production' }) const caps = await ops.stock.position({ productId: 'brass-cap', horizonDays: 90 }) caps.onHand.available // 400 caps.shortfall // { quantity: 140, firstShortOn: '2026-12-14' } | null await ops.stock.move({ from: binId, to: cageId, productId: 'brass-cap', quantity: 100 }) await ops.workOrders.setStatus('19264', 'on-hold', { reason: 'Waiting for caps' }) ```
|
|
13959
|
+
|
|
13960
|
+
**describe**(collectionId: string) → `Promise<`
|
|
13961
|
+
What the server offers, by group: `{ workOrders: [...], stock: [...], boms: [...], madeFrom: [...] }`.
|
|
13962
|
+
|
|
13439
13963
|
### order
|
|
13440
13964
|
|
|
13441
|
-
**create**(collectionId: string,
|
|
13965
|
+
**create**(collectionId: string,
|
|
13442
13966
|
data: CreateOrderRequest) → `Promise<CreateOrderResponse>`
|
|
13443
13967
|
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' } }) ```
|
|
13444
13968
|
|
|
13445
|
-
**get**(collectionId: string,
|
|
13446
|
-
orderId: string,
|
|
13969
|
+
**get**(collectionId: string,
|
|
13970
|
+
orderId: string,
|
|
13447
13971
|
params?: GetOrderParams) → `Promise<GetOrderResponse>`
|
|
13448
13972
|
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 ```
|
|
13449
13973
|
|
|
13450
|
-
**update**(collectionId: string,
|
|
13451
|
-
orderId: string,
|
|
13974
|
+
**update**(collectionId: string,
|
|
13975
|
+
orderId: string,
|
|
13452
13976
|
data: UpdateOrderRequest) → `Promise<UpdateOrderResponse>`
|
|
13453
13977
|
Update order status or metadata. Items are managed separately via addItems/removeItems. ```typescript const updated = await order.update('coll_123', 'order_abc123', { status: 'shipped', metadata: { trackingNumber: '1Z999AA10123456784', shippedAt: '2026-02-02T14:30:00Z' } }) ```
|
|
13454
13978
|
|
|
13455
|
-
**remove**(collectionId: string,
|
|
13979
|
+
**remove**(collectionId: string,
|
|
13456
13980
|
orderId: string) → `Promise<DeleteOrderResponse>`
|
|
13457
13981
|
Delete an order and all its items (cascade delete). ```typescript await order.remove('coll_123', 'order_abc123') ```
|
|
13458
13982
|
|
|
13459
|
-
**list**(collectionId: string,
|
|
13983
|
+
**list**(collectionId: string,
|
|
13460
13984
|
params?: ListOrdersRequest) → `Promise<ListOrdersResponse>`
|
|
13461
13985
|
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 }) ```
|
|
13462
13986
|
|
|
13463
|
-
**getItems**(collectionId: string,
|
|
13464
|
-
orderId: string,
|
|
13987
|
+
**getItems**(collectionId: string,
|
|
13988
|
+
orderId: string,
|
|
13465
13989
|
params?: GetOrderItemsParams) → `Promise<GetOrderItemsResponse>`
|
|
13466
13990
|
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 }) ```
|
|
13467
13991
|
|
|
13468
|
-
**addItems**(collectionId: string,
|
|
13469
|
-
orderId: string,
|
|
13992
|
+
**addItems**(collectionId: string,
|
|
13993
|
+
orderId: string,
|
|
13470
13994
|
data: AddItemsRequest) → `Promise<AddItemsResponse>`
|
|
13471
13995
|
Add additional items to an existing order. ```typescript const updated = await order.addItems('coll_123', 'order_abc123', { items: [ { itemType: 'tag', itemId: 'TAG003' }, { itemType: 'proof', itemId: 'proof_xyz' } ] }) console.log(`Order now has ${updated.itemCount} items`) ```
|
|
13472
13996
|
|
|
13473
|
-
**
|
|
13474
|
-
|
|
13997
|
+
**lineDone**(collectionId: string, orderId: string, itemId: string, by: number) → `Promise<OrderItem>`
|
|
13998
|
+
Add to (or take from) how much of a line has been shipped or received. Atomic, so two receipts at once both count; it can't go below zero. ```typescript // 20 more caps arrived against a purchase order line await order.lineDone('coll_123', orderId, lineId, 20) ```
|
|
13999
|
+
|
|
14000
|
+
**removeItems**(collectionId: string,
|
|
14001
|
+
orderId: string,
|
|
13475
14002
|
data: RemoveItemsRequest) → `Promise<RemoveItemsResponse>`
|
|
13476
|
-
|
|
14003
|
+
Add to (or take from) how much of a line has been shipped or received. Atomic, so two receipts at once both count; it can't go below zero. ```typescript // 20 more caps arrived against a purchase order line await order.lineDone('coll_123', orderId, lineId, 20) ```
|
|
13477
14004
|
|
|
13478
|
-
**lookup**(collectionId: string,
|
|
14005
|
+
**lookup**(collectionId: string,
|
|
13479
14006
|
data: LookupOrdersRequest) → `Promise<LookupOrdersResponse>`
|
|
13480
14007
|
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' } ] }) ```
|
|
13481
14008
|
|
|
13482
|
-
**query**(collectionId: string,
|
|
14009
|
+
**query**(collectionId: string,
|
|
13483
14010
|
data: QueryOrdersRequest) → `Promise<QueryOrdersResponse>`
|
|
13484
14011
|
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: { productId: 'prod_789', batchId: 'BATCH-2024-001' }, includeItems: true }) // Find an order containing one of several specific items const matched = await order.query('coll_123', { query: { items: [ { itemType: 'tag', itemId: 'TAG001' }, { itemType: 'serial', itemId: 'SN12345' } ] }, includeItems: true }) ```
|
|
13485
14012
|
|
|
13486
|
-
**reports**(collectionId: string,
|
|
14013
|
+
**reports**(collectionId: string,
|
|
13487
14014
|
params?: ReportsParams) → `Promise<ReportsResponse>`
|
|
13488
14015
|
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 }) ```
|
|
13489
14016
|
|
|
13490
|
-
**findByProduct**(collectionId: string,
|
|
13491
|
-
productId: string,
|
|
14017
|
+
**findByProduct**(collectionId: string,
|
|
14018
|
+
productId: string,
|
|
13492
14019
|
params?: LookupByProductParams) → `Promise<LookupByProductResponse>`
|
|
13493
14020
|
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`) }) ```
|
|
13494
14021
|
|
|
13495
|
-
**getAnalytics**(collectionId: string,
|
|
14022
|
+
**getAnalytics**(collectionId: string,
|
|
13496
14023
|
orderId: string) → `Promise<OrderAnalyticsResponse>`
|
|
13497
14024
|
Get comprehensive scan analytics for all tags in an order. Returns scan counts, timestamps, locations, devices, and per-tag summaries. ```typescript const analytics = await order.getAnalytics('coll_123', 'order_abc123') if (analytics.analytics) { console.log(`Total scans: ${analytics.analytics.totalScans}`) console.log(`Admin scans: ${analytics.analytics.adminScans}`) console.log(`Created at: ${analytics.analytics.estimatedCreatedAt}`) console.log(`Unique locations: ${analytics.analytics.uniqueLocations}`) analytics.analytics.tagSummaries.forEach(tag => { console.log(`Tag ${tag.tagId}: ${tag.totalScans} scans`) }) } ```
|
|
13498
14025
|
|
|
13499
|
-
**getTimeline**(collectionId: string,
|
|
13500
|
-
orderId: string,
|
|
14026
|
+
**getTimeline**(collectionId: string,
|
|
14027
|
+
orderId: string,
|
|
13501
14028
|
params?: TimelineRequest) → `Promise<TimelineResponse>`
|
|
13502
14029
|
Get chronological timeline of all scan events for an order's tags. Supports filtering by date range and admin/customer scans. ```typescript // Get all scan events const timeline = await order.getTimeline('coll_123', 'order_abc123') timeline.timeline.forEach(event => { console.log(`${event.timestamp}: ${event.eventType} by ${event.isAdmin ? 'admin' : 'customer'}`) }) // Get admin scans only from last week const adminScans = await order.getTimeline('coll_123', 'order_abc123', { isAdmin: true, from: '2026-02-01T00:00:00Z', limit: 500 }) ```
|
|
13503
14030
|
|
|
13504
|
-
**getLocationHistory**(collectionId: string,
|
|
13505
|
-
orderId: string,
|
|
14031
|
+
**getLocationHistory**(collectionId: string,
|
|
14032
|
+
orderId: string,
|
|
13506
14033
|
params?: LocationRequest) → `Promise<LocationResponse>`
|
|
13507
14034
|
Get location-based scan history for an order's tags. Shows where the order's tags have been scanned. ```typescript const locations = await order.getLocationHistory('coll_123', 'order_abc123', { limit: 100 }) console.log(`Order scanned in ${locations.count} locations`) locations.locations.forEach(scan => { console.log(`${scan.location} at ${scan.timestamp}`) }) ```
|
|
13508
14035
|
|
|
13509
|
-
**getBulkAnalytics**(collectionId: string,
|
|
14036
|
+
**getBulkAnalytics**(collectionId: string,
|
|
13510
14037
|
data: BulkAnalyticsRequest) → `Promise<BulkAnalyticsResponse>`
|
|
13511
14038
|
Get analytics summary for multiple orders at once. Efficient way to retrieve scan data for many orders. ```typescript const bulk = await order.getBulkAnalytics('coll_123', { orderIds: ['order_1', 'order_2', 'order_3'], from: '2026-01-01T00:00:00Z' }) bulk.results.forEach(result => { if (result.analytics) { console.log(`${result.orderRef}: ${result.analytics.totalScans} scans`) } }) ```
|
|
13512
14039
|
|
|
13513
|
-
**getCollectionSummary**(collectionId: string,
|
|
14040
|
+
**getCollectionSummary**(collectionId: string,
|
|
13514
14041
|
params?: SummaryRequest) → `Promise<CollectionSummaryResponse>`
|
|
13515
14042
|
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' }) ```
|
|
13516
14043
|
|
|
13517
|
-
**findOrdersByProduct**(collectionId: string,
|
|
13518
|
-
productId: string,
|
|
14044
|
+
**findOrdersByProduct**(collectionId: string,
|
|
14045
|
+
productId: string,
|
|
13519
14046
|
params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
|
|
13520
14047
|
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`) ```
|
|
13521
14048
|
|
|
13522
|
-
**findItemsByProduct**(collectionId: string,
|
|
13523
|
-
productId: string,
|
|
14049
|
+
**findItemsByProduct**(collectionId: string,
|
|
14050
|
+
productId: string,
|
|
13524
14051
|
params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
|
|
13525
14052
|
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`) ```
|
|
13526
14053
|
|
|
13527
|
-
**getOrderIdsByAttribute**(collectionId: string,
|
|
13528
|
-
attribute: 'productId',
|
|
13529
|
-
value: string,
|
|
14054
|
+
**getOrderIdsByAttribute**(collectionId: string,
|
|
14055
|
+
attribute: 'productId',
|
|
14056
|
+
value: string,
|
|
13530
14057
|
params?: GetOrderIdsParams) → `Promise<GetOrderIdsResponse>`
|
|
13531
14058
|
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 } ) ```
|
|
13532
14059
|
|
|
@@ -14149,6 +14676,41 @@ Create or update a user data item. The item object must include an `id` field. `
|
|
|
14149
14676
|
**remove**(appId: string, itemId: string) → `Promise<void>`
|
|
14150
14677
|
Delete a user data item by ID. ```typescript await userAppData.remove('garden-planner', 'bed-1'); ```
|
|
14151
14678
|
|
|
14679
|
+
### userGroups
|
|
14680
|
+
|
|
14681
|
+
**mine**(collectionId: string) → `Promise<MyUserGroups>`
|
|
14682
|
+
The signed-in person's own user groups in this collection. Not signed in → both lists empty. Nobody can ask about anyone else with this. ```typescript const { userGroups: mine } = await userGroups.mine('coll_123') const canRelease = mine.includes('qc-controller') ```
|
|
14683
|
+
|
|
14684
|
+
**list**(collectionId: string) → `Promise<UserGroup[]>`
|
|
14685
|
+
Every user group in the collection (admin).
|
|
14686
|
+
|
|
14687
|
+
**get**(collectionId: string, userGroupId: string) → `Promise<UserGroup>`
|
|
14688
|
+
One user group (admin).
|
|
14689
|
+
|
|
14690
|
+
**create**(collectionId: string, data: CreateUserGroupRequest) → `Promise<UserGroup>`
|
|
14691
|
+
Create a user group (admin). Its key is made from the name unless you give one. ```typescript const qc = await userGroups.create('coll_123', { name: 'QC Controllers' }) qc.key // 'qc-controllers' ```
|
|
14692
|
+
|
|
14693
|
+
**update**(collectionId: string, userGroupId: string, data: UpdateUserGroupRequest) → `Promise<UserGroup>`
|
|
14694
|
+
Change a user group (admin): its name, description, or anything else you keep on it. The key stays. To change who is in it, prefer `addMember` / `removeMember`: saving a whole `members` list here can overwrite a change someone else made at the same moment.
|
|
14695
|
+
|
|
14696
|
+
**remove**(collectionId: string, userGroupId: string) → `Promise<UserGroup>`
|
|
14697
|
+
Delete a user group (admin). Its members lose whatever it allowed.
|
|
14698
|
+
|
|
14699
|
+
**members**(collectionId: string, userGroupId: string) → `Promise<UserGroupMember[]>`
|
|
14700
|
+
The people in a user group, with name and email (admin).
|
|
14701
|
+
|
|
14702
|
+
**addMember**(collectionId: string, userGroupId: string, who: AddUserGroupMemberRequest) → `Promise<UserGroup>`
|
|
14703
|
+
Add one person (admin), by user id or by email. By email, the person is found in the collection's logins or added to them (no welcome email is sent). Adding someone who is already in changes nothing. ```typescript await userGroups.addMember('coll_123', qc.id, { email: 'sam@example.com', name: 'Sam' }) ```
|
|
14704
|
+
|
|
14705
|
+
**removeMember**(collectionId: string, userGroupId: string, userId: string) → `Promise<UserGroup>`
|
|
14706
|
+
Remove one person (admin).
|
|
14707
|
+
|
|
14708
|
+
**history**(collectionId: string, params: UserGroupHistoryParams = {}) → `Promise<UserGroupChange[]>`
|
|
14709
|
+
What changed, newest first (admin): user groups created, renamed and deleted, and every person added or removed, each with the admin who did it (`actorId`) and when (`at`). Give `userGroupId` for one user group, `userId` for everything about one person, or neither for the whole collection. Covers the last 30 days unless you give `from` / `to` (at most 400 days). Takes about a second. ```typescript const who = await userGroups.history('coll_123', { userId: 'uid_1' }) // [{ at, type: 'usergroup.member-added', actorId: 'uid_admin', data: { key: 'qc-controllers', userId: 'uid_1', … } }] ```
|
|
14710
|
+
|
|
14711
|
+
**ofUser**(collectionId: string, userId: string) → `Promise<UserGroupRef[]>`
|
|
14712
|
+
The user groups one person is in (admin).
|
|
14713
|
+
|
|
14152
14714
|
### variant
|
|
14153
14715
|
|
|
14154
14716
|
**get**(collectionId: string,
|