@proveanything/smartlinks 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/contact.d.ts +12 -0
- package/dist/api/contact.js +12 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/order.d.ts +189 -0
- package/dist/api/order.js +240 -0
- package/dist/api/tags.d.ts +194 -0
- package/dist/api/tags.js +258 -0
- package/dist/docs/API_SUMMARY.md +587 -221
- package/dist/types/contact.d.ts +32 -1
- package/dist/types/contact.js +35 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/order.d.ts +137 -0
- package/dist/types/order.js +7 -0
- package/dist/types/tags.d.ts +172 -0
- package/dist/types/tags.js +7 -0
- package/docs/API_SUMMARY.md +368 -2
- package/package.json +1 -1
- package/dist/API_SUMMARY.md +0 -3230
package/dist/api/contact.d.ts
CHANGED
|
@@ -19,6 +19,18 @@ export declare namespace contact {
|
|
|
19
19
|
function publicUpsert(collectionId: string, data: PublicContactUpsertRequest): Promise<PublicContactUpsertResponse>;
|
|
20
20
|
function publicGetMine(collectionId: string): Promise<PublicGetMyContactResponse>;
|
|
21
21
|
function publicUpdateMine(collectionId: string, data: ContactPatch): Promise<PublicUpdateMyContactResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Public: Get contact update schema for a collection
|
|
24
|
+
*
|
|
25
|
+
* Fetches the public contact schema including core fields, custom fields with
|
|
26
|
+
* conditional visibility rules, and visibility/editability settings.
|
|
27
|
+
*
|
|
28
|
+
* Custom fields may include a `condition` property that specifies when the field
|
|
29
|
+
* should be displayed. Apps rendering these forms should:
|
|
30
|
+
* 1. Evaluate each field's `condition` against current form values
|
|
31
|
+
* 2. Hide fields whose conditions are not met
|
|
32
|
+
* 3. Skip validation for hidden fields (they shouldn't be required when not visible)
|
|
33
|
+
*/
|
|
22
34
|
function publicGetSchema(collectionId: string): Promise<ContactSchema>;
|
|
23
35
|
function erase(collectionId: string, contactId: string, body?: any): Promise<ContactResponse>;
|
|
24
36
|
function getUser(collectionId: string, userId: string): Promise<UserSearchResponse>;
|
package/dist/api/contact.js
CHANGED
|
@@ -71,7 +71,18 @@ export var contact;
|
|
|
71
71
|
return patch(path, data);
|
|
72
72
|
}
|
|
73
73
|
contact.publicUpdateMine = publicUpdateMine;
|
|
74
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Public: Get contact update schema for a collection
|
|
76
|
+
*
|
|
77
|
+
* Fetches the public contact schema including core fields, custom fields with
|
|
78
|
+
* conditional visibility rules, and visibility/editability settings.
|
|
79
|
+
*
|
|
80
|
+
* Custom fields may include a `condition` property that specifies when the field
|
|
81
|
+
* should be displayed. Apps rendering these forms should:
|
|
82
|
+
* 1. Evaluate each field's `condition` against current form values
|
|
83
|
+
* 2. Hide fields whose conditions are not met
|
|
84
|
+
* 3. Skip validation for hidden fields (they shouldn't be required when not visible)
|
|
85
|
+
*/
|
|
75
86
|
async function publicGetSchema(collectionId) {
|
|
76
87
|
const path = `/public/collection/${encodeURIComponent(collectionId)}/contact/schema`;
|
|
77
88
|
return request(path);
|
package/dist/api/index.d.ts
CHANGED
|
@@ -27,4 +27,6 @@ export { template } from "./template";
|
|
|
27
27
|
export { interactions } from "./interactions";
|
|
28
28
|
export { location } from "./location";
|
|
29
29
|
export * as realtime from "./realtime";
|
|
30
|
+
export { tags } from "./tags";
|
|
31
|
+
export { order } from "./order";
|
|
30
32
|
export type { AIGenerateContentRequest, AIGenerateImageRequest, AISearchPhotosRequest, AISearchPhotosPhoto } from "./ai";
|
package/dist/api/index.js
CHANGED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { CreateOrderRequest, CreateOrderResponse, GetOrderResponse, UpdateOrderRequest, UpdateOrderResponse, DeleteOrderResponse, ListOrdersRequest, ListOrdersResponse, AddItemsRequest, AddItemsResponse, RemoveItemsRequest, RemoveItemsResponse, LookupOrdersRequest, LookupOrdersResponse } from "../types/order";
|
|
2
|
+
/**
|
|
3
|
+
* Order Management API
|
|
4
|
+
*
|
|
5
|
+
* Group scanned tags, proofs, or serial numbers into orders with flexible metadata.
|
|
6
|
+
* Designed for fulfillment, shipping, batch processing, and audit trails.
|
|
7
|
+
*/
|
|
8
|
+
export declare namespace order {
|
|
9
|
+
/**
|
|
10
|
+
* Create a new order with items.
|
|
11
|
+
*
|
|
12
|
+
* @param collectionId - Identifier of the parent collection
|
|
13
|
+
* @param data - Order creation data including items
|
|
14
|
+
* @returns Promise resolving to a CreateOrderResponse object
|
|
15
|
+
* @throws ErrorResponse if the request fails
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const order = await order.create('coll_123', {
|
|
20
|
+
* orderRef: 'ORD-12345',
|
|
21
|
+
* customerId: 'CUST-789',
|
|
22
|
+
* items: [
|
|
23
|
+
* { itemType: 'tag', itemId: 'TAG001' },
|
|
24
|
+
* { itemType: 'tag', itemId: 'TAG002' },
|
|
25
|
+
* { itemType: 'serial', itemId: 'SN12345' }
|
|
26
|
+
* ],
|
|
27
|
+
* status: 'pending',
|
|
28
|
+
* metadata: {
|
|
29
|
+
* shipmentId: 'SHIP-789',
|
|
30
|
+
* destination: 'Warehouse B'
|
|
31
|
+
* }
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function create(collectionId: string, data: CreateOrderRequest): Promise<CreateOrderResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Get a single order by ID with all its items.
|
|
38
|
+
*
|
|
39
|
+
* @param collectionId - Identifier of the parent collection
|
|
40
|
+
* @param orderId - Order ID
|
|
41
|
+
* @returns Promise resolving to a GetOrderResponse object
|
|
42
|
+
* @throws ErrorResponse if the request fails
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const order = await order.get('coll_123', 'order_abc123')
|
|
47
|
+
* console.log(`Order has ${order.itemCount} items`)
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
function get(collectionId: string, orderId: string): Promise<GetOrderResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Update order status or metadata.
|
|
53
|
+
* Items are managed separately via addItems/removeItems.
|
|
54
|
+
*
|
|
55
|
+
* @param collectionId - Identifier of the parent collection
|
|
56
|
+
* @param orderId - Order ID
|
|
57
|
+
* @param data - Update data (only include fields to update)
|
|
58
|
+
* @returns Promise resolving to an UpdateOrderResponse object
|
|
59
|
+
* @throws ErrorResponse if the request fails
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const updated = await order.update('coll_123', 'order_abc123', {
|
|
64
|
+
* status: 'shipped',
|
|
65
|
+
* metadata: {
|
|
66
|
+
* trackingNumber: '1Z999AA10123456784',
|
|
67
|
+
* shippedAt: '2026-02-02T14:30:00Z'
|
|
68
|
+
* }
|
|
69
|
+
* })
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
function update(collectionId: string, orderId: string, data: UpdateOrderRequest): Promise<UpdateOrderResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Delete an order and all its items (cascade delete).
|
|
75
|
+
*
|
|
76
|
+
* @param collectionId - Identifier of the parent collection
|
|
77
|
+
* @param orderId - Order ID
|
|
78
|
+
* @returns Promise resolving to a DeleteOrderResponse object
|
|
79
|
+
* @throws ErrorResponse if the request fails
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* await order.remove('coll_123', 'order_abc123')
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
function remove(collectionId: string, orderId: string): Promise<DeleteOrderResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* List orders for a collection with optional filters and pagination.
|
|
89
|
+
* Orders are returned in descending order by createdAt (newest first).
|
|
90
|
+
*
|
|
91
|
+
* @param collectionId - Identifier of the parent collection
|
|
92
|
+
* @param params - Optional query parameters for filtering and pagination
|
|
93
|
+
* @returns Promise resolving to a ListOrdersResponse object
|
|
94
|
+
* @throws ErrorResponse if the request fails
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* // List all orders
|
|
99
|
+
* const all = await order.list('coll_123')
|
|
100
|
+
*
|
|
101
|
+
* // List with filters
|
|
102
|
+
* const pending = await order.list('coll_123', {
|
|
103
|
+
* status: 'pending',
|
|
104
|
+
* limit: 50,
|
|
105
|
+
* offset: 0
|
|
106
|
+
* })
|
|
107
|
+
*
|
|
108
|
+
* // Filter by customer
|
|
109
|
+
* const customerOrders = await order.list('coll_123', {
|
|
110
|
+
* customerId: 'CUST-789'
|
|
111
|
+
* })
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
function list(collectionId: string, params?: ListOrdersRequest): Promise<ListOrdersResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Add additional items to an existing order.
|
|
117
|
+
*
|
|
118
|
+
* @param collectionId - Identifier of the parent collection
|
|
119
|
+
* @param orderId - Order ID
|
|
120
|
+
* @param data - Items to add
|
|
121
|
+
* @returns Promise resolving to an AddItemsResponse object (updated order)
|
|
122
|
+
* @throws ErrorResponse if the request fails
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const updated = await order.addItems('coll_123', 'order_abc123', {
|
|
127
|
+
* items: [
|
|
128
|
+
* { itemType: 'tag', itemId: 'TAG003' },
|
|
129
|
+
* { itemType: 'proof', itemId: 'proof_xyz' }
|
|
130
|
+
* ]
|
|
131
|
+
* })
|
|
132
|
+
* console.log(`Order now has ${updated.itemCount} items`)
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
function addItems(collectionId: string, orderId: string, data: AddItemsRequest): Promise<AddItemsResponse>;
|
|
136
|
+
/**
|
|
137
|
+
* Remove specific items from an order.
|
|
138
|
+
*
|
|
139
|
+
* @param collectionId - Identifier of the parent collection
|
|
140
|
+
* @param orderId - Order ID
|
|
141
|
+
* @param data - Item IDs to remove
|
|
142
|
+
* @returns Promise resolving to a RemoveItemsResponse object (updated order)
|
|
143
|
+
* @throws ErrorResponse if the request fails
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const updated = await order.removeItems('coll_123', 'order_abc123', {
|
|
148
|
+
* itemIds: ['item_001', 'item_002']
|
|
149
|
+
* })
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
function removeItems(collectionId: string, orderId: string, data: RemoveItemsRequest): Promise<RemoveItemsResponse>;
|
|
153
|
+
/**
|
|
154
|
+
* Find all orders containing specific items (tags, proofs, or serial numbers).
|
|
155
|
+
* Use case: Scan a tag and immediately see if it's part of any order.
|
|
156
|
+
*
|
|
157
|
+
* @param collectionId - Identifier of the parent collection
|
|
158
|
+
* @param data - Items to look up
|
|
159
|
+
* @returns Promise resolving to a LookupOrdersResponse with matching orders
|
|
160
|
+
* @throws ErrorResponse if the request fails
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* // Scan a tag and find associated orders
|
|
165
|
+
* const result = await order.lookup('coll_123', {
|
|
166
|
+
* items: [
|
|
167
|
+
* { itemType: 'tag', itemId: 'TAG001' }
|
|
168
|
+
* ]
|
|
169
|
+
* })
|
|
170
|
+
*
|
|
171
|
+
* if (result.orders.length > 0) {
|
|
172
|
+
* console.log(`Tag is part of ${result.orders.length} order(s)`)
|
|
173
|
+
* result.orders.forEach(ord => {
|
|
174
|
+
* console.log(`Order ${ord.orderRef}: ${ord.status}`)
|
|
175
|
+
* })
|
|
176
|
+
* }
|
|
177
|
+
*
|
|
178
|
+
* // Batch lookup multiple items
|
|
179
|
+
* const batchResult = await order.lookup('coll_123', {
|
|
180
|
+
* items: [
|
|
181
|
+
* { itemType: 'tag', itemId: 'TAG001' },
|
|
182
|
+
* { itemType: 'serial', itemId: 'SN12345' },
|
|
183
|
+
* { itemType: 'proof', itemId: 'proof_xyz' }
|
|
184
|
+
* ]
|
|
185
|
+
* })
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
function lookup(collectionId: string, data: LookupOrdersRequest): Promise<LookupOrdersResponse>;
|
|
189
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// src/api/order.ts
|
|
2
|
+
import { request, post, put, del, requestWithOptions } from "../http";
|
|
3
|
+
/**
|
|
4
|
+
* Order Management API
|
|
5
|
+
*
|
|
6
|
+
* Group scanned tags, proofs, or serial numbers into orders with flexible metadata.
|
|
7
|
+
* Designed for fulfillment, shipping, batch processing, and audit trails.
|
|
8
|
+
*/
|
|
9
|
+
export var order;
|
|
10
|
+
(function (order) {
|
|
11
|
+
/**
|
|
12
|
+
* Create a new order with items.
|
|
13
|
+
*
|
|
14
|
+
* @param collectionId - Identifier of the parent collection
|
|
15
|
+
* @param data - Order creation data including items
|
|
16
|
+
* @returns Promise resolving to a CreateOrderResponse object
|
|
17
|
+
* @throws ErrorResponse if the request fails
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const order = await order.create('coll_123', {
|
|
22
|
+
* orderRef: 'ORD-12345',
|
|
23
|
+
* customerId: 'CUST-789',
|
|
24
|
+
* items: [
|
|
25
|
+
* { itemType: 'tag', itemId: 'TAG001' },
|
|
26
|
+
* { itemType: 'tag', itemId: 'TAG002' },
|
|
27
|
+
* { itemType: 'serial', itemId: 'SN12345' }
|
|
28
|
+
* ],
|
|
29
|
+
* status: 'pending',
|
|
30
|
+
* metadata: {
|
|
31
|
+
* shipmentId: 'SHIP-789',
|
|
32
|
+
* destination: 'Warehouse B'
|
|
33
|
+
* }
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
async function create(collectionId, data) {
|
|
38
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders`;
|
|
39
|
+
return post(path, data);
|
|
40
|
+
}
|
|
41
|
+
order.create = create;
|
|
42
|
+
/**
|
|
43
|
+
* Get a single order by ID with all its items.
|
|
44
|
+
*
|
|
45
|
+
* @param collectionId - Identifier of the parent collection
|
|
46
|
+
* @param orderId - Order ID
|
|
47
|
+
* @returns Promise resolving to a GetOrderResponse object
|
|
48
|
+
* @throws ErrorResponse if the request fails
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const order = await order.get('coll_123', 'order_abc123')
|
|
53
|
+
* console.log(`Order has ${order.itemCount} items`)
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
async function get(collectionId, orderId) {
|
|
57
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/${encodeURIComponent(orderId)}`;
|
|
58
|
+
return request(path);
|
|
59
|
+
}
|
|
60
|
+
order.get = get;
|
|
61
|
+
/**
|
|
62
|
+
* Update order status or metadata.
|
|
63
|
+
* Items are managed separately via addItems/removeItems.
|
|
64
|
+
*
|
|
65
|
+
* @param collectionId - Identifier of the parent collection
|
|
66
|
+
* @param orderId - Order ID
|
|
67
|
+
* @param data - Update data (only include fields to update)
|
|
68
|
+
* @returns Promise resolving to an UpdateOrderResponse object
|
|
69
|
+
* @throws ErrorResponse if the request fails
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const updated = await order.update('coll_123', 'order_abc123', {
|
|
74
|
+
* status: 'shipped',
|
|
75
|
+
* metadata: {
|
|
76
|
+
* trackingNumber: '1Z999AA10123456784',
|
|
77
|
+
* shippedAt: '2026-02-02T14:30:00Z'
|
|
78
|
+
* }
|
|
79
|
+
* })
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
async function update(collectionId, orderId, data) {
|
|
83
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/${encodeURIComponent(orderId)}`;
|
|
84
|
+
return put(path, data);
|
|
85
|
+
}
|
|
86
|
+
order.update = update;
|
|
87
|
+
/**
|
|
88
|
+
* Delete an order and all its items (cascade delete).
|
|
89
|
+
*
|
|
90
|
+
* @param collectionId - Identifier of the parent collection
|
|
91
|
+
* @param orderId - Order ID
|
|
92
|
+
* @returns Promise resolving to a DeleteOrderResponse object
|
|
93
|
+
* @throws ErrorResponse if the request fails
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* await order.remove('coll_123', 'order_abc123')
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
async function remove(collectionId, orderId) {
|
|
101
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/${encodeURIComponent(orderId)}`;
|
|
102
|
+
return del(path);
|
|
103
|
+
}
|
|
104
|
+
order.remove = remove;
|
|
105
|
+
/**
|
|
106
|
+
* List orders for a collection with optional filters and pagination.
|
|
107
|
+
* Orders are returned in descending order by createdAt (newest first).
|
|
108
|
+
*
|
|
109
|
+
* @param collectionId - Identifier of the parent collection
|
|
110
|
+
* @param params - Optional query parameters for filtering and pagination
|
|
111
|
+
* @returns Promise resolving to a ListOrdersResponse object
|
|
112
|
+
* @throws ErrorResponse if the request fails
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* // List all orders
|
|
117
|
+
* const all = await order.list('coll_123')
|
|
118
|
+
*
|
|
119
|
+
* // List with filters
|
|
120
|
+
* const pending = await order.list('coll_123', {
|
|
121
|
+
* status: 'pending',
|
|
122
|
+
* limit: 50,
|
|
123
|
+
* offset: 0
|
|
124
|
+
* })
|
|
125
|
+
*
|
|
126
|
+
* // Filter by customer
|
|
127
|
+
* const customerOrders = await order.list('coll_123', {
|
|
128
|
+
* customerId: 'CUST-789'
|
|
129
|
+
* })
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
async function list(collectionId, params) {
|
|
133
|
+
const queryParams = new URLSearchParams();
|
|
134
|
+
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
135
|
+
queryParams.append('limit', params.limit.toString());
|
|
136
|
+
if (params === null || params === void 0 ? void 0 : params.offset)
|
|
137
|
+
queryParams.append('offset', params.offset.toString());
|
|
138
|
+
if (params === null || params === void 0 ? void 0 : params.status)
|
|
139
|
+
queryParams.append('status', params.status);
|
|
140
|
+
if (params === null || params === void 0 ? void 0 : params.orderRef)
|
|
141
|
+
queryParams.append('orderRef', params.orderRef);
|
|
142
|
+
if (params === null || params === void 0 ? void 0 : params.customerId)
|
|
143
|
+
queryParams.append('customerId', params.customerId);
|
|
144
|
+
const query = queryParams.toString();
|
|
145
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders${query ? `?${query}` : ''}`;
|
|
146
|
+
return request(path);
|
|
147
|
+
}
|
|
148
|
+
order.list = list;
|
|
149
|
+
/**
|
|
150
|
+
* Add additional items to an existing order.
|
|
151
|
+
*
|
|
152
|
+
* @param collectionId - Identifier of the parent collection
|
|
153
|
+
* @param orderId - Order ID
|
|
154
|
+
* @param data - Items to add
|
|
155
|
+
* @returns Promise resolving to an AddItemsResponse object (updated order)
|
|
156
|
+
* @throws ErrorResponse if the request fails
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const updated = await order.addItems('coll_123', 'order_abc123', {
|
|
161
|
+
* items: [
|
|
162
|
+
* { itemType: 'tag', itemId: 'TAG003' },
|
|
163
|
+
* { itemType: 'proof', itemId: 'proof_xyz' }
|
|
164
|
+
* ]
|
|
165
|
+
* })
|
|
166
|
+
* console.log(`Order now has ${updated.itemCount} items`)
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
async function addItems(collectionId, orderId, data) {
|
|
170
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/${encodeURIComponent(orderId)}/items`;
|
|
171
|
+
return post(path, data);
|
|
172
|
+
}
|
|
173
|
+
order.addItems = addItems;
|
|
174
|
+
/**
|
|
175
|
+
* Remove specific items from an order.
|
|
176
|
+
*
|
|
177
|
+
* @param collectionId - Identifier of the parent collection
|
|
178
|
+
* @param orderId - Order ID
|
|
179
|
+
* @param data - Item IDs to remove
|
|
180
|
+
* @returns Promise resolving to a RemoveItemsResponse object (updated order)
|
|
181
|
+
* @throws ErrorResponse if the request fails
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const updated = await order.removeItems('coll_123', 'order_abc123', {
|
|
186
|
+
* itemIds: ['item_001', 'item_002']
|
|
187
|
+
* })
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
async function removeItems(collectionId, orderId, data) {
|
|
191
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/${encodeURIComponent(orderId)}/items`;
|
|
192
|
+
// DELETE with body requires requestWithOptions since del() doesn't send body
|
|
193
|
+
return requestWithOptions(path, {
|
|
194
|
+
method: 'DELETE',
|
|
195
|
+
headers: { 'Content-Type': 'application/json' },
|
|
196
|
+
body: JSON.stringify(data)
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
order.removeItems = removeItems;
|
|
200
|
+
/**
|
|
201
|
+
* Find all orders containing specific items (tags, proofs, or serial numbers).
|
|
202
|
+
* Use case: Scan a tag and immediately see if it's part of any order.
|
|
203
|
+
*
|
|
204
|
+
* @param collectionId - Identifier of the parent collection
|
|
205
|
+
* @param data - Items to look up
|
|
206
|
+
* @returns Promise resolving to a LookupOrdersResponse with matching orders
|
|
207
|
+
* @throws ErrorResponse if the request fails
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* // Scan a tag and find associated orders
|
|
212
|
+
* const result = await order.lookup('coll_123', {
|
|
213
|
+
* items: [
|
|
214
|
+
* { itemType: 'tag', itemId: 'TAG001' }
|
|
215
|
+
* ]
|
|
216
|
+
* })
|
|
217
|
+
*
|
|
218
|
+
* if (result.orders.length > 0) {
|
|
219
|
+
* console.log(`Tag is part of ${result.orders.length} order(s)`)
|
|
220
|
+
* result.orders.forEach(ord => {
|
|
221
|
+
* console.log(`Order ${ord.orderRef}: ${ord.status}`)
|
|
222
|
+
* })
|
|
223
|
+
* }
|
|
224
|
+
*
|
|
225
|
+
* // Batch lookup multiple items
|
|
226
|
+
* const batchResult = await order.lookup('coll_123', {
|
|
227
|
+
* items: [
|
|
228
|
+
* { itemType: 'tag', itemId: 'TAG001' },
|
|
229
|
+
* { itemType: 'serial', itemId: 'SN12345' },
|
|
230
|
+
* { itemType: 'proof', itemId: 'proof_xyz' }
|
|
231
|
+
* ]
|
|
232
|
+
* })
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
async function lookup(collectionId, data) {
|
|
236
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/lookup`;
|
|
237
|
+
return post(path, data);
|
|
238
|
+
}
|
|
239
|
+
order.lookup = lookup;
|
|
240
|
+
})(order || (order = {}));
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { CreateTagRequest, CreateTagResponse, CreateTagsBatchRequest, CreateTagsBatchResponse, UpdateTagRequest, UpdateTagResponse, DeleteTagResponse, GetTagResponse, ListTagsRequest, ListTagsResponse, PublicGetTagRequest, PublicGetTagResponse, PublicBatchLookupRequest, PublicBatchLookupResponse, PublicBatchLookupQueryRequest, PublicBatchLookupQueryResponse } from "../types/tags";
|
|
2
|
+
/**
|
|
3
|
+
* Tag Management API
|
|
4
|
+
*
|
|
5
|
+
* Create mappings between physical tags (NFC tags, QR codes, etc.) and digital proofs.
|
|
6
|
+
* Supports automatic serial number generation, batch operations, and public lookups.
|
|
7
|
+
*/
|
|
8
|
+
export declare namespace tags {
|
|
9
|
+
/**
|
|
10
|
+
* Create a single tag mapping.
|
|
11
|
+
* If proofId is not provided, automatically generates a serial number.
|
|
12
|
+
*
|
|
13
|
+
* @param collectionId - Identifier of the parent collection
|
|
14
|
+
* @param data - Tag creation data
|
|
15
|
+
* @returns Promise resolving to a CreateTagResponse object
|
|
16
|
+
* @throws ErrorResponse if the request fails
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Auto-generate serial number
|
|
21
|
+
* const tag = await tags.create('coll_123', {
|
|
22
|
+
* tagId: 'TAG001',
|
|
23
|
+
* productId: 'prod_456',
|
|
24
|
+
* variantId: 'var_789'
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* // Use explicit proof ID
|
|
28
|
+
* const tag2 = await tags.create('coll_123', {
|
|
29
|
+
* tagId: 'TAG002',
|
|
30
|
+
* productId: 'prod_456',
|
|
31
|
+
* proofId: 'proof_explicit_123'
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function create(collectionId: string, data: CreateTagRequest): Promise<CreateTagResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Create multiple tag mappings efficiently in a batch operation.
|
|
38
|
+
* By default, auto-generates serial numbers for all tags without explicit proofId.
|
|
39
|
+
* Tags are grouped by product/variant/batch and serial numbers are generated in
|
|
40
|
+
* a single transaction per group for optimal performance.
|
|
41
|
+
*
|
|
42
|
+
* @param collectionId - Identifier of the parent collection
|
|
43
|
+
* @param data - Batch creation data
|
|
44
|
+
* @returns Promise resolving to a CreateTagsBatchResponse with summary and results
|
|
45
|
+
* @throws ErrorResponse if the request fails
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const result = await tags.createBatch('coll_123', {
|
|
50
|
+
* tags: [
|
|
51
|
+
* { tagId: 'TAG001', productId: 'prod_456', variantId: 'var_789' },
|
|
52
|
+
* { tagId: 'TAG002', productId: 'prod_456', variantId: 'var_789' },
|
|
53
|
+
* { tagId: 'TAG003', productId: 'prod_456', batchId: 'batch_100' }
|
|
54
|
+
* ]
|
|
55
|
+
* })
|
|
56
|
+
*
|
|
57
|
+
* console.log(`Created: ${result.summary.created}, Failed: ${result.summary.failed}`)
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
function createBatch(collectionId: string, data: CreateTagsBatchRequest): Promise<CreateTagsBatchResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* Update an existing tag mapping.
|
|
63
|
+
*
|
|
64
|
+
* @param collectionId - Identifier of the parent collection
|
|
65
|
+
* @param tagId - Unique tag identifier
|
|
66
|
+
* @param data - Update data (only include fields to update)
|
|
67
|
+
* @returns Promise resolving to an UpdateTagResponse object
|
|
68
|
+
* @throws ErrorResponse if the request fails
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const updated = await tags.update('coll_123', 'TAG001', {
|
|
73
|
+
* variantId: 'var_999',
|
|
74
|
+
* metadata: { notes: 'Updated variant' }
|
|
75
|
+
* })
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
function update(collectionId: string, tagId: string, data: UpdateTagRequest): Promise<UpdateTagResponse>;
|
|
79
|
+
/**
|
|
80
|
+
* Delete a tag mapping.
|
|
81
|
+
*
|
|
82
|
+
* @param collectionId - Identifier of the parent collection
|
|
83
|
+
* @param tagId - Unique tag identifier
|
|
84
|
+
* @returns Promise resolving to a DeleteTagResponse object
|
|
85
|
+
* @throws ErrorResponse if the request fails
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* await tags.remove('coll_123', 'TAG001')
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
function remove(collectionId: string, tagId: string): Promise<DeleteTagResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* Get a single tag mapping by tagId.
|
|
95
|
+
*
|
|
96
|
+
* @param collectionId - Identifier of the parent collection
|
|
97
|
+
* @param tagId - Unique tag identifier
|
|
98
|
+
* @returns Promise resolving to a GetTagResponse object
|
|
99
|
+
* @throws ErrorResponse if the request fails
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const tag = await tags.get('coll_123', 'TAG001')
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
function get(collectionId: string, tagId: string): Promise<GetTagResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* List all tags for a collection with optional filters and pagination.
|
|
109
|
+
*
|
|
110
|
+
* @param collectionId - Identifier of the parent collection
|
|
111
|
+
* @param params - Optional query parameters for filtering and pagination
|
|
112
|
+
* @returns Promise resolving to a ListTagsResponse object
|
|
113
|
+
* @throws ErrorResponse if the request fails
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* // List all tags
|
|
118
|
+
* const all = await tags.list('coll_123')
|
|
119
|
+
*
|
|
120
|
+
* // List with filters
|
|
121
|
+
* const filtered = await tags.list('coll_123', {
|
|
122
|
+
* productId: 'prod_456',
|
|
123
|
+
* variantId: 'var_789',
|
|
124
|
+
* limit: 50,
|
|
125
|
+
* offset: 0
|
|
126
|
+
* })
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
function list(collectionId: string, params?: ListTagsRequest): Promise<ListTagsResponse>;
|
|
130
|
+
/**
|
|
131
|
+
* Public lookup of a single tag by tagId.
|
|
132
|
+
* Optionally embed related collection, product, or proof data.
|
|
133
|
+
* No authentication required.
|
|
134
|
+
*
|
|
135
|
+
* @param tagId - Unique tag identifier
|
|
136
|
+
* @param params - Optional parameters (embed)
|
|
137
|
+
* @returns Promise resolving to a PublicGetTagResponse with optional embedded data
|
|
138
|
+
* @throws ErrorResponse if the request fails
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // Simple lookup
|
|
143
|
+
* const result = await tags.publicGet('TAG001')
|
|
144
|
+
*
|
|
145
|
+
* // With embedded data
|
|
146
|
+
* const withData = await tags.publicGet('TAG001', {
|
|
147
|
+
* embed: 'collection,product,proof'
|
|
148
|
+
* })
|
|
149
|
+
* console.log(withData.tag, withData.collection, withData.product, withData.proof)
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
function publicGet(tagId: string, params?: PublicGetTagRequest): Promise<PublicGetTagResponse>;
|
|
153
|
+
/**
|
|
154
|
+
* Public batch lookup of multiple tags in a single request (POST).
|
|
155
|
+
* Optionally embed related data. Related data is deduplicated and batch-fetched.
|
|
156
|
+
* No authentication required.
|
|
157
|
+
*
|
|
158
|
+
* @param data - Request containing array of tagIds and optional embed parameter
|
|
159
|
+
* @returns Promise resolving to PublicBatchLookupResponse with deduplicated related data
|
|
160
|
+
* @throws ErrorResponse if the request fails
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const result = await tags.publicBatchLookup({
|
|
165
|
+
* tagIds: ['TAG001', 'TAG002', 'TAG003'],
|
|
166
|
+
* embed: 'collection,product'
|
|
167
|
+
* })
|
|
168
|
+
*
|
|
169
|
+
* // Access tags and deduplicated collections/products
|
|
170
|
+
* console.log(result.tags['TAG001'])
|
|
171
|
+
* console.log(result.collections)
|
|
172
|
+
* console.log(result.products)
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
function publicBatchLookup(data: PublicBatchLookupRequest): Promise<PublicBatchLookupResponse>;
|
|
176
|
+
/**
|
|
177
|
+
* Public batch lookup of multiple tags using query parameters (GET).
|
|
178
|
+
* Alternative to publicBatchLookup for simple GET requests.
|
|
179
|
+
* No authentication required.
|
|
180
|
+
*
|
|
181
|
+
* @param params - Query parameters with comma-separated tagIds and optional embed
|
|
182
|
+
* @returns Promise resolving to PublicBatchLookupQueryResponse
|
|
183
|
+
* @throws ErrorResponse if the request fails
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const result = await tags.publicBatchLookupQuery({
|
|
188
|
+
* tagIds: 'TAG001,TAG002,TAG003',
|
|
189
|
+
* embed: 'collection'
|
|
190
|
+
* })
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
function publicBatchLookupQuery(params: PublicBatchLookupQueryRequest): Promise<PublicBatchLookupQueryResponse>;
|
|
194
|
+
}
|