@proveanything/smartlinks 3.0.0-alpha.1 → 3.0.0-alpha.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/README.md +741 -741
- package/dist/README.md +573 -573
- package/dist/adminCardsView.js +55 -55
- package/dist/api/analytics.d.ts +5 -4
- package/dist/api/analytics.js +5 -4
- package/dist/api/appConfiguration.d.ts +23 -18
- package/dist/api/appConfiguration.js +24 -18
- package/dist/api/appObjects.d.ts +54 -10
- package/dist/api/appObjects.js +75 -40
- package/dist/api/asset.d.ts +28 -22
- package/dist/api/asset.js +45 -56
- package/dist/api/attestation.d.ts +11 -3
- package/dist/api/attestation.js +12 -3
- package/dist/api/attestations.d.ts +12 -8
- package/dist/api/attestations.js +18 -21
- package/dist/api/authKit.d.ts +15 -10
- package/dist/api/authKit.js +17 -11
- package/dist/api/batch.d.ts +36 -25
- package/dist/api/batch.js +46 -39
- package/dist/api/bookings.d.ts +67 -11
- package/dist/api/bookings.js +82 -15
- package/dist/api/broadcasts.js +3 -17
- package/dist/api/claimSet.d.ts +26 -12
- package/dist/api/claimSet.js +32 -24
- package/dist/api/collection.d.ts +15 -10
- package/dist/api/collection.js +17 -11
- package/dist/api/comms.d.ts +12 -6
- package/dist/api/comms.js +12 -6
- package/dist/api/conditions.d.ts +7 -6
- package/dist/api/conditions.js +8 -6
- package/dist/api/contact.d.ts +6 -2
- package/dist/api/contact.js +25 -60
- package/dist/api/containers.d.ts +14 -10
- package/dist/api/containers.js +19 -14
- package/dist/api/crate.js +7 -9
- package/dist/api/dpp.d.ts +20 -13
- package/dist/api/dpp.js +23 -15
- package/dist/api/facets.d.ts +38 -13
- package/dist/api/facets.js +40 -15
- package/dist/api/files.d.ts +5 -2
- package/dist/api/files.js +7 -4
- package/dist/api/form.d.ts +8 -5
- package/dist/api/form.js +9 -5
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/integrations.d.ts +29 -17
- package/dist/api/integrations.js +32 -25
- package/dist/api/interactions.d.ts +11 -6
- package/dist/api/interactions.js +14 -23
- package/dist/api/jobs.d.ts +16 -6
- package/dist/api/jobs.js +30 -20
- package/dist/api/journeys.js +2 -14
- package/dist/api/journeysAnalytics.d.ts +8 -5
- package/dist/api/journeysAnalytics.js +8 -5
- package/dist/api/knowledge.d.ts +20 -14
- package/dist/api/knowledge.js +22 -15
- package/dist/api/location.d.ts +6 -3
- package/dist/api/location.js +8 -22
- package/dist/api/lots.d.ts +9 -5
- package/dist/api/lots.js +22 -26
- package/dist/api/loyalty.d.ts +25 -16
- package/dist/api/loyalty.js +33 -32
- package/dist/api/nfc.d.ts +3 -1
- package/dist/api/nfc.js +3 -1
- package/dist/api/order.d.ts +45 -39
- package/dist/api/order.js +48 -65
- package/dist/api/partner.d.ts +17 -14
- package/dist/api/partner.js +21 -22
- package/dist/api/payments.d.ts +60 -0
- package/dist/api/payments.js +94 -0
- package/dist/api/products.d.ts +35 -12
- package/dist/api/products.js +36 -13
- package/dist/api/proof.d.ts +41 -19
- package/dist/api/proof.js +44 -23
- package/dist/api/realtime.d.ts +3 -0
- package/dist/api/realtime.js +10 -2
- package/dist/api/segments.js +3 -15
- package/dist/api/serviceAccounts.d.ts +8 -5
- package/dist/api/serviceAccounts.js +9 -6
- package/dist/api/shop.d.ts +7 -5
- package/dist/api/shop.js +13 -19
- package/dist/api/subscriptions.d.ts +12 -10
- package/dist/api/subscriptions.js +17 -25
- package/dist/api/tags.d.ts +23 -20
- package/dist/api/tags.js +40 -52
- package/dist/api/template.d.ts +16 -11
- package/dist/api/template.js +19 -13
- package/dist/api/translations.js +2 -12
- package/dist/api/userGroups.d.ts +26 -16
- package/dist/api/userGroups.js +43 -30
- package/dist/api/variant.d.ts +10 -7
- package/dist/api/variant.js +11 -7
- package/dist/api/wallet.d.ts +14 -11
- package/dist/api/wallet.js +15 -12
- package/dist/baseline.css +194 -194
- package/dist/dataChanged.d.ts +74 -0
- package/dist/dataChanged.js +162 -0
- package/dist/docs/API_SUMMARY.md +1443 -1409
- package/dist/docs/admin-cards.md +189 -189
- package/dist/docs/agent-tools.md +156 -156
- package/dist/docs/ai-tools-and-skills.md +180 -180
- package/dist/docs/ai.md +1721 -1721
- package/dist/docs/analytics.md +1 -1
- package/dist/docs/api-versions.md +85 -85
- package/dist/docs/app-data-storage.md +277 -277
- package/dist/docs/app-docs.md +73 -73
- package/dist/docs/app-manifest.md +852 -852
- package/dist/docs/app-objects.md +4 -4
- package/dist/docs/app-records-pattern.md +388 -388
- package/dist/docs/appConfig.md +550 -550
- package/dist/docs/assistant-apps.md +172 -172
- package/dist/docs/assistant-context.md +119 -119
- package/dist/docs/attestations.md +8 -8
- package/dist/docs/bookings.md +105 -8
- package/dist/docs/caching.md +32 -3
- package/dist/docs/comms.md +689 -689
- package/dist/docs/connectors.md +340 -340
- package/dist/docs/contact-search.md +2 -3
- package/dist/docs/css-baseline.md +133 -133
- package/dist/docs/customer-guide.md +70 -70
- package/dist/docs/data-changed.md +91 -0
- package/dist/docs/deploying-apps.md +340 -340
- package/dist/docs/dpp.md +115 -115
- package/dist/docs/entitlements.md +90 -90
- package/dist/docs/files.md +69 -69
- package/dist/docs/host-dependency-contract.md +252 -252
- package/dist/docs/iframe-responder.md +11 -0
- package/dist/docs/integrations.md +322 -322
- package/dist/docs/interactions.md +544 -544
- package/dist/docs/item-context.md +181 -181
- package/dist/docs/knowledge.md +105 -105
- package/dist/docs/lists.md +157 -114
- package/dist/docs/lots.md +112 -112
- package/dist/docs/loyalty.md +348 -348
- package/dist/docs/members.md +183 -183
- package/dist/docs/memberships.md +150 -150
- package/dist/docs/mobile-admin-container.md +693 -693
- package/dist/docs/operations.md +281 -281
- package/dist/docs/overview.md +487 -485
- package/dist/docs/payments.md +94 -0
- package/dist/docs/proof-comms-triggers.md +142 -142
- package/dist/docs/proof-ownership-transfer.md +155 -155
- package/dist/docs/proof-product-data-scoping.md +462 -462
- package/dist/docs/proof-share-grants.md +305 -305
- package/dist/docs/realtime.md +149 -139
- package/dist/docs/records-admin-pattern.md +304 -304
- package/dist/docs/service-accounts.md +64 -64
- package/dist/docs/standard-query.md +196 -187
- package/dist/docs/tag-codes.md +97 -97
- package/dist/docs/tag-ranges.md +106 -106
- package/dist/docs/theme-tokens.md +252 -252
- package/dist/docs/upgrading-to-3.md +550 -430
- package/dist/docs/wallet-passes.md +107 -107
- package/dist/docs/websites.md +123 -123
- package/dist/http.d.ts +6 -3
- package/dist/http.js +48 -19
- package/dist/iframeResponder.d.ts +7 -0
- package/dist/iframeResponder.js +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/list.d.ts +12 -0
- package/dist/list.js +59 -0
- package/dist/openapi.yaml +722 -660
- package/dist/testing/bookingsMemory.d.ts +29 -1
- package/dist/testing/bookingsMemory.js +89 -1
- package/dist/testing/index.js +4 -1
- package/dist/theme-boot.js +82 -82
- package/dist/theme.css +75 -75
- package/dist/types/analytics.d.ts +7 -3
- package/dist/types/appManifest.d.ts +26 -4
- package/dist/types/appObjects.d.ts +27 -12
- package/dist/types/appOptions.d.ts +2 -2
- package/dist/types/asset.d.ts +5 -6
- package/dist/types/attestations.d.ts +7 -9
- package/dist/types/batch.d.ts +5 -5
- package/dist/types/bookings.d.ts +109 -6
- package/dist/types/comms.d.ts +9 -5
- package/dist/types/contact.d.ts +7 -4
- package/dist/types/containers.d.ts +2 -1
- package/dist/types/facets.d.ts +14 -2
- package/dist/types/files.d.ts +3 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/integrations.d.ts +2 -1
- package/dist/types/interaction.d.ts +15 -7
- package/dist/types/jobs.d.ts +1 -1
- package/dist/types/journeysAnalytics.d.ts +3 -2
- package/dist/types/knowledge.d.ts +6 -3
- package/dist/types/knowledge.js +0 -1
- package/dist/types/list.d.ts +30 -2
- package/dist/types/location.d.ts +7 -2
- package/dist/types/location.js +0 -1
- package/dist/types/lots.d.ts +5 -2
- package/dist/types/lots.js +0 -6
- package/dist/types/order.d.ts +22 -20
- package/dist/types/payments.d.ts +101 -0
- package/dist/types/payments.js +5 -0
- package/dist/types/product.d.ts +28 -11
- package/dist/types/proof.d.ts +7 -8
- package/dist/types/realtime.d.ts +5 -1
- package/dist/types/tags.d.ts +5 -3
- package/dist/types/userGroups.d.ts +3 -3
- package/dist/types/userGroups.js +0 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/API_SUMMARY.md +1443 -1409
- package/docs/admin-cards.md +189 -189
- package/docs/agent-tools.md +156 -156
- package/docs/ai-tools-and-skills.md +180 -180
- package/docs/ai.md +1721 -1721
- package/docs/analytics.md +1 -1
- package/docs/api-versions.md +85 -85
- package/docs/app-data-storage.md +277 -277
- package/docs/app-docs.md +73 -73
- package/docs/app-manifest.md +852 -852
- package/docs/app-objects.md +4 -4
- package/docs/app-records-pattern.md +388 -388
- package/docs/appConfig.md +550 -550
- package/docs/assistant-apps.md +172 -172
- package/docs/assistant-context.md +119 -119
- package/docs/attestations.md +8 -8
- package/docs/bookings.md +105 -8
- package/docs/caching.md +32 -3
- package/docs/comms.md +689 -689
- package/docs/connectors.md +340 -340
- package/docs/contact-search.md +2 -3
- package/docs/css-baseline.md +133 -133
- package/docs/customer-guide.md +70 -70
- package/docs/data-changed.md +91 -0
- package/docs/deploying-apps.md +340 -340
- package/docs/dpp.md +115 -115
- package/docs/entitlements.md +90 -90
- package/docs/files.md +69 -69
- package/docs/host-dependency-contract.md +252 -252
- package/docs/iframe-responder.md +11 -0
- package/docs/integrations.md +322 -322
- package/docs/interactions.md +544 -544
- package/docs/item-context.md +181 -181
- package/docs/knowledge.md +105 -105
- package/docs/lists.md +157 -114
- package/docs/lots.md +112 -112
- package/docs/loyalty.md +348 -348
- package/docs/members.md +183 -183
- package/docs/memberships.md +150 -150
- package/docs/mobile-admin-container.md +693 -693
- package/docs/operations.md +281 -281
- package/docs/overview.md +487 -485
- package/docs/payments.md +94 -0
- package/docs/proof-comms-triggers.md +142 -142
- package/docs/proof-ownership-transfer.md +155 -155
- package/docs/proof-product-data-scoping.md +462 -462
- package/docs/proof-share-grants.md +305 -305
- package/docs/realtime.md +149 -139
- package/docs/service-accounts.md +64 -64
- package/docs/standard-query.md +196 -187
- package/docs/tag-codes.md +97 -97
- package/docs/tag-ranges.md +106 -106
- package/docs/theme-lookbook.v1.json +120 -120
- package/docs/theme-tokens.md +252 -252
- package/docs/upgrading-to-3.md +550 -430
- package/docs/wallet-passes.md +107 -107
- package/docs/websites.md +123 -123
- package/openapi.yaml +722 -660
- package/package.json +91 -91
- package/scripts/headless-check.mjs +87 -87
- package/scripts/lib/bare-imports.mjs +57 -57
- package/scripts/lib/keyed-app-data.mjs +21 -21
- package/scripts/lib/upgrade.mjs +708 -512
- package/scripts/publish.mjs +272 -272
- package/scripts/register-release.mjs +91 -91
- package/scripts/upgrade.mjs +79 -56
- package/upgrade/3.json +2731 -2213
package/dist/api/order.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/api/order.ts
|
|
2
2
|
import { request, post, put, del, requestWithOptions } from "../http.js";
|
|
3
|
+
import { listQuery } from "../list.js";
|
|
3
4
|
/**
|
|
4
5
|
* Order Management API
|
|
5
6
|
*
|
|
@@ -135,7 +136,7 @@ export var order;
|
|
|
135
136
|
* // Filter by customer with items
|
|
136
137
|
* const customerOrders = await order.list('coll_123', {
|
|
137
138
|
* customerId: 'CUST-789',
|
|
138
|
-
*
|
|
139
|
+
* expand: ['items']
|
|
139
140
|
* })
|
|
140
141
|
*
|
|
141
142
|
* // Purchase orders from one supplier
|
|
@@ -143,31 +144,13 @@ export var order;
|
|
|
143
144
|
* ```
|
|
144
145
|
*/
|
|
145
146
|
async function list(collectionId, params) {
|
|
146
|
-
const
|
|
147
|
-
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
148
|
-
queryParams.append('limit', params.limit.toString());
|
|
149
|
-
if (params === null || params === void 0 ? void 0 : params.cursor)
|
|
150
|
-
queryParams.append('cursor', params.cursor);
|
|
151
|
-
if (params === null || params === void 0 ? void 0 : params.status)
|
|
152
|
-
queryParams.append('status', params.status);
|
|
153
|
-
if (params === null || params === void 0 ? void 0 : params.orderRef)
|
|
154
|
-
queryParams.append('orderRef', params.orderRef);
|
|
155
|
-
if (params === null || params === void 0 ? void 0 : params.customerId)
|
|
156
|
-
queryParams.append('customerId', params.customerId);
|
|
157
|
-
if (params === null || params === void 0 ? void 0 : params.direction)
|
|
158
|
-
queryParams.append('direction', params.direction);
|
|
159
|
-
if (params === null || params === void 0 ? void 0 : params.partyId)
|
|
160
|
-
queryParams.append('partyId', params.partyId);
|
|
161
|
-
if (params === null || params === void 0 ? void 0 : params.includeItems)
|
|
162
|
-
queryParams.append('includeItems', 'true');
|
|
163
|
-
const query = queryParams.toString();
|
|
164
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders${query ? `?${query}` : ''}`;
|
|
147
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders${listQuery(params)}`;
|
|
165
148
|
return request(path);
|
|
166
149
|
}
|
|
167
150
|
order.list = list;
|
|
168
151
|
/**
|
|
169
152
|
* Get items from an order with pagination support.
|
|
170
|
-
* Use this for orders with many items instead of
|
|
153
|
+
* Use this for orders with many items instead of `expand: ['items']`.
|
|
171
154
|
*
|
|
172
155
|
* @param collectionId - Identifier of the parent collection
|
|
173
156
|
* @param orderId - Order ID
|
|
@@ -187,13 +170,7 @@ export var order;
|
|
|
187
170
|
* ```
|
|
188
171
|
*/
|
|
189
172
|
async function getItems(collectionId, orderId, params) {
|
|
190
|
-
const
|
|
191
|
-
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
192
|
-
queryParams.append('limit', params.limit.toString());
|
|
193
|
-
if (params === null || params === void 0 ? void 0 : params.cursor)
|
|
194
|
-
queryParams.append('cursor', params.cursor);
|
|
195
|
-
const query = queryParams.toString();
|
|
196
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/${encodeURIComponent(orderId)}/items${query ? `?${query}` : ''}`;
|
|
173
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/${encodeURIComponent(orderId)}/items${listQuery(params)}`;
|
|
197
174
|
return request(path);
|
|
198
175
|
}
|
|
199
176
|
order.getItems = getItems;
|
|
@@ -276,21 +253,18 @@ export var order;
|
|
|
276
253
|
* More powerful than the basic list() function.
|
|
277
254
|
*
|
|
278
255
|
* @param collectionId - Identifier of the parent collection
|
|
279
|
-
* @param data -
|
|
256
|
+
* @param data - The filters (`query`), plus `orderBy`, the date ranges `createdAt` / `updatedAt`,
|
|
257
|
+
* `expand: ['items']`, and `limit` and `cursor` for paging. These all sit beside `query`, not inside it.
|
|
280
258
|
* @returns Promise resolving to `{ items, nextCursor }`: the matching orders, and the cursor for the next page (null on the last)
|
|
281
259
|
* @throws ErrorResponse if the request fails
|
|
282
260
|
*
|
|
283
261
|
* @example
|
|
284
262
|
* ```typescript
|
|
285
|
-
* // Find pending orders created in January 2026
|
|
263
|
+
* // Find pending orders created in January 2026, newest first
|
|
286
264
|
* const result = await order.query('coll_123', {
|
|
287
|
-
* query: {
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
* createdBefore: '2026-02-01T00:00:00Z',
|
|
291
|
-
* sortBy: 'createdAt',
|
|
292
|
-
* sortOrder: 'desc'
|
|
293
|
-
* },
|
|
265
|
+
* query: { status: 'pending' },
|
|
266
|
+
* createdAt: { gte: '2026-01-01T00:00:00Z', lte: '2026-02-01T00:00:00Z' },
|
|
267
|
+
* orderBy: [{ createdAt: 'desc' }],
|
|
294
268
|
* limit: 50
|
|
295
269
|
* })
|
|
296
270
|
* console.log(result.items.length)
|
|
@@ -298,40 +272,42 @@ export var order;
|
|
|
298
272
|
* // The next page: the same query with the cursor
|
|
299
273
|
* if (result.nextCursor) {
|
|
300
274
|
* const next = await order.query('coll_123', {
|
|
301
|
-
* query: { status: 'pending'
|
|
275
|
+
* query: { status: 'pending' },
|
|
276
|
+
* createdAt: { gte: '2026-01-01T00:00:00Z', lte: '2026-02-01T00:00:00Z' },
|
|
277
|
+
* orderBy: [{ createdAt: 'desc' }],
|
|
302
278
|
* limit: 50,
|
|
303
279
|
* cursor: result.nextCursor
|
|
304
280
|
* })
|
|
305
281
|
* }
|
|
306
282
|
*
|
|
307
|
-
* // Find orders with specific metadata and item count
|
|
283
|
+
* // Find orders with specific metadata and item count, with their items
|
|
308
284
|
* const highPriority = await order.query('coll_123', {
|
|
309
285
|
* query: {
|
|
310
286
|
* metadata: { priority: 'high' },
|
|
311
287
|
* minItemCount: 10,
|
|
312
288
|
* maxItemCount: 100
|
|
313
289
|
* },
|
|
314
|
-
*
|
|
290
|
+
* expand: ['items']
|
|
315
291
|
* })
|
|
316
292
|
*
|
|
317
|
-
|
|
293
|
+
* // Find orders containing a specific product batch
|
|
318
294
|
* const batchOrders = await order.query('coll_123', {
|
|
319
295
|
* query: {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
296
|
+
* productId: 'prod_789',
|
|
297
|
+
* batchId: 'BATCH-2024-001'
|
|
298
|
+
* },
|
|
299
|
+
* expand: ['items']
|
|
300
|
+
* })
|
|
301
|
+
*
|
|
302
|
+
* // Find an order containing one of several specific items
|
|
303
|
+
* const matched = await order.query('coll_123', {
|
|
304
|
+
* query: {
|
|
305
|
+
* items: [
|
|
306
|
+
* { itemType: 'tag', itemId: 'TAG001' },
|
|
307
|
+
* { itemType: 'serial', itemId: 'SN12345' }
|
|
308
|
+
* ]
|
|
333
309
|
* },
|
|
334
|
-
*
|
|
310
|
+
* expand: ['items']
|
|
335
311
|
* })
|
|
336
312
|
* ```
|
|
337
313
|
*/
|
|
@@ -442,20 +418,23 @@ export var order;
|
|
|
442
418
|
*
|
|
443
419
|
* @param collectionId - Identifier of the parent collection
|
|
444
420
|
* @param orderId - Order ID
|
|
445
|
-
* @param params - Optional filters (
|
|
446
|
-
* @returns Promise resolving to `{ items, nextCursor, orderRef, orderId }`: the scan events
|
|
447
|
-
*
|
|
421
|
+
* @param params - Optional filters (`from` / `to` time window, `isAdmin`), plus `limit` and `cursor` for paging
|
|
422
|
+
* @returns Promise resolving to `{ items, nextCursor, orderRef, orderId }`: the scan events, a page at a
|
|
423
|
+
* time (`limit` says how many, default 1000), with the order they belong to
|
|
448
424
|
* @throws ErrorResponse if the request fails
|
|
449
425
|
*
|
|
450
426
|
* @example
|
|
451
427
|
* ```typescript
|
|
452
|
-
* //
|
|
453
|
-
*
|
|
428
|
+
* // The first page of scan events
|
|
429
|
+
* let timeline = await order.getTimeline('coll_123', 'order_abc123')
|
|
454
430
|
*
|
|
455
431
|
* timeline.items.forEach(event => {
|
|
456
432
|
* console.log(`${event.timestamp}: ${event.eventType} by ${event.isAdmin ? 'admin' : 'customer'}`)
|
|
457
433
|
* })
|
|
458
434
|
*
|
|
435
|
+
* // The next page
|
|
436
|
+
* if (timeline.nextCursor) timeline = await order.getTimeline('coll_123', 'order_abc123', { cursor: timeline.nextCursor })
|
|
437
|
+
*
|
|
459
438
|
* // Get admin scans only from last week
|
|
460
439
|
* const adminScans = await order.getTimeline('coll_123', 'order_abc123', {
|
|
461
440
|
* isAdmin: true,
|
|
@@ -475,21 +454,25 @@ export var order;
|
|
|
475
454
|
*
|
|
476
455
|
* @param collectionId - Identifier of the parent collection
|
|
477
456
|
* @param orderId - Order ID
|
|
478
|
-
* @param params - Optional limit
|
|
479
|
-
* @returns Promise resolving to `{ items, nextCursor, orderRef, orderId }`: the scans that have a location
|
|
480
|
-
*
|
|
457
|
+
* @param params - Optional `limit` and `cursor` for paging
|
|
458
|
+
* @returns Promise resolving to `{ items, nextCursor, orderRef, orderId }`: the scans that have a location,
|
|
459
|
+
* a page at a time (`limit` says how many, default 1000), with the order they belong to
|
|
481
460
|
* @throws ErrorResponse if the request fails
|
|
482
461
|
*
|
|
483
462
|
* @example
|
|
484
463
|
* ```typescript
|
|
485
|
-
*
|
|
464
|
+
* let locations = await order.getLocationHistory('coll_123', 'order_abc123', {
|
|
486
465
|
* limit: 100
|
|
487
466
|
* })
|
|
488
467
|
*
|
|
489
|
-
* console.log(`Order has ${locations.items.length} scans with a location`)
|
|
490
468
|
* locations.items.forEach(scan => {
|
|
491
469
|
* console.log(`${scan.location} at ${scan.timestamp}`)
|
|
492
470
|
* })
|
|
471
|
+
*
|
|
472
|
+
* // The next page
|
|
473
|
+
* if (locations.nextCursor) {
|
|
474
|
+
* locations = await order.getLocationHistory('coll_123', 'order_abc123', { limit: 100, cursor: locations.nextCursor })
|
|
475
|
+
* }
|
|
493
476
|
* ```
|
|
494
477
|
*/
|
|
495
478
|
async function getLocationHistory(collectionId, orderId, params) {
|
package/dist/api/partner.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Partner, PartnerClaimSet, CreatePartnerClaimSetRequest, PartnerTagHit, ClientErrorEvent } from "../types/index.js";
|
|
2
|
-
import type { ListResult } from "../types/list.js";
|
|
2
|
+
import type { ListResult, ListOptions } from "../types/list.js";
|
|
3
3
|
/**
|
|
4
4
|
* Partners: organisations above collections (FanConnect, Zenith Coins, …) that own NFC claim sets and
|
|
5
5
|
* assign their tags into collections their people administer. Partners and their members are set up by
|
|
@@ -9,26 +9,29 @@ import type { ListResult } from "../types/list.js";
|
|
|
9
9
|
export declare namespace partner {
|
|
10
10
|
/**
|
|
11
11
|
* The partners you belong to, with your role in each. Returns `{ items, nextCursor }`: the partners are
|
|
12
|
-
* in `items` (empty for everyone else).
|
|
12
|
+
* in `items` (empty for everyone else). A page at a time (`limit` and `cursor`; 50 unless you say
|
|
13
|
+
* otherwise).
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
16
|
* ```typescript
|
|
16
|
-
*
|
|
17
|
+
* let page = await partner.list()
|
|
18
|
+
* while (page.nextCursor) page = await partner.list({ cursor: page.nextCursor })
|
|
17
19
|
* ```
|
|
18
20
|
*/
|
|
19
|
-
function list(): Promise<ListResult<Partner>>;
|
|
21
|
+
function list(options?: ListOptions): Promise<ListResult<Partner>>;
|
|
20
22
|
/** One partner (owners also see its members). */
|
|
21
23
|
function get(partnerId: string): Promise<Partner>;
|
|
22
24
|
/**
|
|
23
|
-
* The partner's claim sets. Returns `{ items, nextCursor }`: the sets are in `items`.
|
|
24
|
-
*
|
|
25
|
+
* The partner's claim sets. Returns `{ items, nextCursor }`: the sets are in `items`. A page at a time
|
|
26
|
+
* (`limit` and `cursor`; 50 unless you say otherwise).
|
|
25
27
|
*
|
|
26
28
|
* @example
|
|
27
29
|
* ```typescript
|
|
28
|
-
*
|
|
30
|
+
* let page = await partner.claimSets(partnerId)
|
|
31
|
+
* while (page.nextCursor) page = await partner.claimSets(partnerId, { cursor: page.nextCursor })
|
|
29
32
|
* ```
|
|
30
33
|
*/
|
|
31
|
-
function claimSets(partnerId: string): Promise<ListResult<PartnerClaimSet>>;
|
|
34
|
+
function claimSets(partnerId: string, options?: ListOptions): Promise<ListResult<PartnerClaimSet>>;
|
|
32
35
|
/** One of the partner's claim sets. */
|
|
33
36
|
function getClaimSet(partnerId: string, claimSetId: string): Promise<PartnerClaimSet>;
|
|
34
37
|
/** A new claim set for the partner, on one of its tap domains (owners and admins). */
|
|
@@ -36,8 +39,8 @@ export declare namespace partner {
|
|
|
36
39
|
/**
|
|
37
40
|
* Find a tag across the partner's sets by its chip UID (8 or 14 hex) or its code (printed or bare).
|
|
38
41
|
* Returns `{ items, nextCursor }`: `items` has one hit for each of the partner's sets the tag is in
|
|
39
|
-
* (usually one; none if the tag isn't the partner's). Never returns keys.
|
|
40
|
-
*
|
|
42
|
+
* (usually one; none if the tag isn't the partner's). Never returns keys. A look-up is never paged: every
|
|
43
|
+
* hit comes back in the one answer.
|
|
41
44
|
*
|
|
42
45
|
* @example
|
|
43
46
|
* ```typescript
|
|
@@ -51,13 +54,13 @@ export declare namespace partner {
|
|
|
51
54
|
/**
|
|
52
55
|
* What phones reported about one chip (errors.report with entityType 'tag'), newest first: a tag that
|
|
53
56
|
* failed to program or register, with the host's NFC log in context. For a chip in the partner's sets,
|
|
54
|
-
* or attempts that named one of them. Returns `{ items, nextCursor }`: the
|
|
55
|
-
* `items
|
|
57
|
+
* or attempts that named one of them. Returns `{ items, nextCursor }`: the latest reports are in
|
|
58
|
+
* `items` (ten unless `limit` says otherwise); `cursor` is the previous page's `nextCursor`.
|
|
56
59
|
*
|
|
57
60
|
* @example
|
|
58
61
|
* ```typescript
|
|
59
|
-
* const { items: attempts } = await partner.tagAttempts(partnerId, '04A1B2C3D4E5F6')
|
|
62
|
+
* const { items: attempts } = await partner.tagAttempts(partnerId, '04A1B2C3D4E5F6', { limit: 20 })
|
|
60
63
|
* ```
|
|
61
64
|
*/
|
|
62
|
-
function tagAttempts(partnerId: string, uid: string): Promise<ListResult<ClientErrorEvent>>;
|
|
65
|
+
function tagAttempts(partnerId: string, uid: string, options?: ListOptions): Promise<ListResult<ClientErrorEvent>>;
|
|
63
66
|
}
|
package/dist/api/partner.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { request, post } from "../http.js";
|
|
2
|
+
import { listQuery } from "../list.js";
|
|
2
3
|
/**
|
|
3
4
|
* Partners: organisations above collections (FanConnect, Zenith Coins, …) that own NFC claim sets and
|
|
4
5
|
* assign their tags into collections their people administer. Partners and their members are set up by
|
|
@@ -9,15 +10,17 @@ export var partner;
|
|
|
9
10
|
(function (partner) {
|
|
10
11
|
/**
|
|
11
12
|
* The partners you belong to, with your role in each. Returns `{ items, nextCursor }`: the partners are
|
|
12
|
-
* in `items` (empty for everyone else).
|
|
13
|
+
* in `items` (empty for everyone else). A page at a time (`limit` and `cursor`; 50 unless you say
|
|
14
|
+
* otherwise).
|
|
13
15
|
*
|
|
14
16
|
* @example
|
|
15
17
|
* ```typescript
|
|
16
|
-
*
|
|
18
|
+
* let page = await partner.list()
|
|
19
|
+
* while (page.nextCursor) page = await partner.list({ cursor: page.nextCursor })
|
|
17
20
|
* ```
|
|
18
21
|
*/
|
|
19
|
-
async function list() {
|
|
20
|
-
return request(`/admin/partner`);
|
|
22
|
+
async function list(options = {}) {
|
|
23
|
+
return request(`/admin/partner${listQuery(options)}`);
|
|
21
24
|
}
|
|
22
25
|
partner.list = list;
|
|
23
26
|
/** One partner (owners also see its members). */
|
|
@@ -26,16 +29,17 @@ export var partner;
|
|
|
26
29
|
}
|
|
27
30
|
partner.get = get;
|
|
28
31
|
/**
|
|
29
|
-
* The partner's claim sets. Returns `{ items, nextCursor }`: the sets are in `items`.
|
|
30
|
-
*
|
|
32
|
+
* The partner's claim sets. Returns `{ items, nextCursor }`: the sets are in `items`. A page at a time
|
|
33
|
+
* (`limit` and `cursor`; 50 unless you say otherwise).
|
|
31
34
|
*
|
|
32
35
|
* @example
|
|
33
36
|
* ```typescript
|
|
34
|
-
*
|
|
37
|
+
* let page = await partner.claimSets(partnerId)
|
|
38
|
+
* while (page.nextCursor) page = await partner.claimSets(partnerId, { cursor: page.nextCursor })
|
|
35
39
|
* ```
|
|
36
40
|
*/
|
|
37
|
-
async function claimSets(partnerId) {
|
|
38
|
-
return request(`/admin/partner/${encodeURIComponent(partnerId)}/claimSet`);
|
|
41
|
+
async function claimSets(partnerId, options = {}) {
|
|
42
|
+
return request(`/admin/partner/${encodeURIComponent(partnerId)}/claimSet${listQuery(options)}`);
|
|
39
43
|
}
|
|
40
44
|
partner.claimSets = claimSets;
|
|
41
45
|
/** One of the partner's claim sets. */
|
|
@@ -51,8 +55,8 @@ export var partner;
|
|
|
51
55
|
/**
|
|
52
56
|
* Find a tag across the partner's sets by its chip UID (8 or 14 hex) or its code (printed or bare).
|
|
53
57
|
* Returns `{ items, nextCursor }`: `items` has one hit for each of the partner's sets the tag is in
|
|
54
|
-
* (usually one; none if the tag isn't the partner's). Never returns keys.
|
|
55
|
-
*
|
|
58
|
+
* (usually one; none if the tag isn't the partner's). Never returns keys. A look-up is never paged: every
|
|
59
|
+
* hit comes back in the one answer.
|
|
56
60
|
*
|
|
57
61
|
* @example
|
|
58
62
|
* ```typescript
|
|
@@ -60,27 +64,22 @@ export var partner;
|
|
|
60
64
|
* ```
|
|
61
65
|
*/
|
|
62
66
|
async function lookupTags(partnerId, query) {
|
|
63
|
-
|
|
64
|
-
if (query.uid)
|
|
65
|
-
q.set('uid', query.uid);
|
|
66
|
-
if (query.code)
|
|
67
|
-
q.set('code', query.code);
|
|
68
|
-
return request(`/admin/partner/${encodeURIComponent(partnerId)}/tags/lookup?${q}`);
|
|
67
|
+
return request(`/admin/partner/${encodeURIComponent(partnerId)}/tags/lookup${listQuery(query)}`);
|
|
69
68
|
}
|
|
70
69
|
partner.lookupTags = lookupTags;
|
|
71
70
|
/**
|
|
72
71
|
* What phones reported about one chip (errors.report with entityType 'tag'), newest first: a tag that
|
|
73
72
|
* failed to program or register, with the host's NFC log in context. For a chip in the partner's sets,
|
|
74
|
-
* or attempts that named one of them. Returns `{ items, nextCursor }`: the
|
|
75
|
-
* `items
|
|
73
|
+
* or attempts that named one of them. Returns `{ items, nextCursor }`: the latest reports are in
|
|
74
|
+
* `items` (ten unless `limit` says otherwise); `cursor` is the previous page's `nextCursor`.
|
|
76
75
|
*
|
|
77
76
|
* @example
|
|
78
77
|
* ```typescript
|
|
79
|
-
* const { items: attempts } = await partner.tagAttempts(partnerId, '04A1B2C3D4E5F6')
|
|
78
|
+
* const { items: attempts } = await partner.tagAttempts(partnerId, '04A1B2C3D4E5F6', { limit: 20 })
|
|
80
79
|
* ```
|
|
81
80
|
*/
|
|
82
|
-
async function tagAttempts(partnerId, uid) {
|
|
83
|
-
return request(`/admin/partner/${encodeURIComponent(partnerId)}/tags/attempts
|
|
81
|
+
async function tagAttempts(partnerId, uid, options = {}) {
|
|
82
|
+
return request(`/admin/partner/${encodeURIComponent(partnerId)}/tags/attempts${listQuery(Object.assign({ uid }, options))}`);
|
|
84
83
|
}
|
|
85
84
|
partner.tagAttempts = tagAttempts;
|
|
86
85
|
})(partner || (partner = {}));
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { PaymentsPublicConfig, PaymentIntentInput, PaymentIntentResult, PaymentsStatus, PaymentsConnectInput, PaymentListParams, PaymentList, PaymentDomainResult } from '../types/payments.js';
|
|
2
|
+
export declare namespace payments {
|
|
3
|
+
/**
|
|
4
|
+
* Can this business take payments, and what Stripe.js needs. `ready` is false until the business has
|
|
5
|
+
* connected Stripe in Studio → Payments.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const cfg = await payments.config(collectionId)
|
|
10
|
+
* if (cfg.ready) stripePromise = loadStripe(cfg.publishableKey!, { stripeAccount: cfg.accountId! })
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
function config(collectionId: string): Promise<PaymentsPublicConfig>;
|
|
14
|
+
/**
|
|
15
|
+
* Start an in-page payment on the business's account. Confirm it in the page with Stripe.js, using the
|
|
16
|
+
* returned publishable key AND account id (`loadStripe(publishableKey, { stripeAccount: accountId })`).
|
|
17
|
+
* `amount` is in minor units (500 = £5.00). The app must be installed in the collection.
|
|
18
|
+
*
|
|
19
|
+
* The browser decides the amount, so use this for pay-what-you-want (donations, tips). For a fixed price
|
|
20
|
+
* use a hosted checkout (`shop.checkout`), where the server prices it.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const pi = await payments.createIntent(collectionId, { appId: 'tap-to-donate', amount: 500, currency: 'GBP', email })
|
|
25
|
+
* const stripe = await loadStripe(pi.publishableKey, { stripeAccount: pi.accountId })
|
|
26
|
+
* // <Elements stripe={stripe} options={{ clientSecret: pi.clientSecret }}> … stripe.confirmPayment(…)
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function createIntent(collectionId: string, input: PaymentIntentInput): Promise<PaymentIntentResult>;
|
|
30
|
+
namespace admin {
|
|
31
|
+
/**
|
|
32
|
+
* The business's payments account: connected, can take payments, can pay out. Pass `appIds` to see
|
|
33
|
+
* what SmartLinks takes from each.
|
|
34
|
+
*/
|
|
35
|
+
function status(collectionId: string, params?: {
|
|
36
|
+
appIds?: string[];
|
|
37
|
+
}): Promise<PaymentsStatus>;
|
|
38
|
+
/**
|
|
39
|
+
* Stripe's page to connect (or finish connecting) the business's Stripe account. Send the person to
|
|
40
|
+
* `url`. The account is made the first time; every app shares it.
|
|
41
|
+
*/
|
|
42
|
+
function connect(collectionId: string, input: PaymentsConnectInput): Promise<{
|
|
43
|
+
url: string;
|
|
44
|
+
expiresAt: string;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Stop using the business's Stripe account. SmartLinks forgets it (apps can no longer take payments
|
|
48
|
+
* until one is connected again); the Stripe account itself stays the business's own, with the
|
|
49
|
+
* payments already in it. Connecting again makes a new account.
|
|
50
|
+
*/
|
|
51
|
+
function disconnect(collectionId: string): Promise<{
|
|
52
|
+
connected: false;
|
|
53
|
+
disconnectedAccountId: string | null;
|
|
54
|
+
}>;
|
|
55
|
+
/** An app's in-page payments on the business's account, newest first (for reconciling). */
|
|
56
|
+
function intents(collectionId: string, params?: PaymentListParams): Promise<PaymentList>;
|
|
57
|
+
/** Let Apple Pay and Google Pay run on a site's own domain (smartlinks.app needs nothing). */
|
|
58
|
+
function registerDomain(collectionId: string, domain: string): Promise<PaymentDomainResult>;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// src/api/payments.ts
|
|
2
|
+
// Payments — see docs/payments.md. A business connects ONE Stripe account (Studio → Payments) and every app
|
|
3
|
+
// takes money on it: no Stripe keys in apps. Pages use `payments.config` and `payments.createIntent` for
|
|
4
|
+
// in-page payments (Payment Element, Apple Pay, Google Pay); Studio and admin screens use `payments.admin`.
|
|
5
|
+
// Fixed-price sales use a hosted checkout instead: `shop.checkout`, `memberships`.
|
|
6
|
+
import { request, post } from '../http.js';
|
|
7
|
+
const pub = (collectionId) => `/public/collection/${encodeURIComponent(collectionId)}/payments`;
|
|
8
|
+
const adm = (collectionId) => `/admin/collection/${encodeURIComponent(collectionId)}/payments`;
|
|
9
|
+
export var payments;
|
|
10
|
+
(function (payments) {
|
|
11
|
+
/**
|
|
12
|
+
* Can this business take payments, and what Stripe.js needs. `ready` is false until the business has
|
|
13
|
+
* connected Stripe in Studio → Payments.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const cfg = await payments.config(collectionId)
|
|
18
|
+
* if (cfg.ready) stripePromise = loadStripe(cfg.publishableKey!, { stripeAccount: cfg.accountId! })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
async function config(collectionId) {
|
|
22
|
+
return request(pub(collectionId));
|
|
23
|
+
}
|
|
24
|
+
payments.config = config;
|
|
25
|
+
/**
|
|
26
|
+
* Start an in-page payment on the business's account. Confirm it in the page with Stripe.js, using the
|
|
27
|
+
* returned publishable key AND account id (`loadStripe(publishableKey, { stripeAccount: accountId })`).
|
|
28
|
+
* `amount` is in minor units (500 = £5.00). The app must be installed in the collection.
|
|
29
|
+
*
|
|
30
|
+
* The browser decides the amount, so use this for pay-what-you-want (donations, tips). For a fixed price
|
|
31
|
+
* use a hosted checkout (`shop.checkout`), where the server prices it.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const pi = await payments.createIntent(collectionId, { appId: 'tap-to-donate', amount: 500, currency: 'GBP', email })
|
|
36
|
+
* const stripe = await loadStripe(pi.publishableKey, { stripeAccount: pi.accountId })
|
|
37
|
+
* // <Elements stripe={stripe} options={{ clientSecret: pi.clientSecret }}> … stripe.confirmPayment(…)
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
async function createIntent(collectionId, input) {
|
|
41
|
+
return post(`${pub(collectionId)}/intent`, input);
|
|
42
|
+
}
|
|
43
|
+
payments.createIntent = createIntent;
|
|
44
|
+
let admin;
|
|
45
|
+
(function (admin) {
|
|
46
|
+
/**
|
|
47
|
+
* The business's payments account: connected, can take payments, can pay out. Pass `appIds` to see
|
|
48
|
+
* what SmartLinks takes from each.
|
|
49
|
+
*/
|
|
50
|
+
async function status(collectionId, params) {
|
|
51
|
+
var _a;
|
|
52
|
+
const q = ((_a = params === null || params === void 0 ? void 0 : params.appIds) === null || _a === void 0 ? void 0 : _a.length) ? `?appIds=${encodeURIComponent(params.appIds.join(','))}` : '';
|
|
53
|
+
return request(`${adm(collectionId)}${q}`);
|
|
54
|
+
}
|
|
55
|
+
admin.status = status;
|
|
56
|
+
/**
|
|
57
|
+
* Stripe's page to connect (or finish connecting) the business's Stripe account. Send the person to
|
|
58
|
+
* `url`. The account is made the first time; every app shares it.
|
|
59
|
+
*/
|
|
60
|
+
async function connect(collectionId, input) {
|
|
61
|
+
return post(`${adm(collectionId)}/connect`, input);
|
|
62
|
+
}
|
|
63
|
+
admin.connect = connect;
|
|
64
|
+
/**
|
|
65
|
+
* Stop using the business's Stripe account. SmartLinks forgets it (apps can no longer take payments
|
|
66
|
+
* until one is connected again); the Stripe account itself stays the business's own, with the
|
|
67
|
+
* payments already in it. Connecting again makes a new account.
|
|
68
|
+
*/
|
|
69
|
+
async function disconnect(collectionId) {
|
|
70
|
+
return post(`${adm(collectionId)}/disconnect`, {});
|
|
71
|
+
}
|
|
72
|
+
admin.disconnect = disconnect;
|
|
73
|
+
/** An app's in-page payments on the business's account, newest first (for reconciling). */
|
|
74
|
+
async function intents(collectionId, params) {
|
|
75
|
+
const q = new URLSearchParams();
|
|
76
|
+
if (params === null || params === void 0 ? void 0 : params.appId)
|
|
77
|
+
q.set('appId', params.appId);
|
|
78
|
+
if (params === null || params === void 0 ? void 0 : params.since)
|
|
79
|
+
q.set('since', params.since);
|
|
80
|
+
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
81
|
+
q.set('limit', String(params.limit));
|
|
82
|
+
if (params === null || params === void 0 ? void 0 : params.after)
|
|
83
|
+
q.set('after', params.after);
|
|
84
|
+
const s = q.toString();
|
|
85
|
+
return request(`${adm(collectionId)}/intents${s ? `?${s}` : ''}`);
|
|
86
|
+
}
|
|
87
|
+
admin.intents = intents;
|
|
88
|
+
/** Let Apple Pay and Google Pay run on a site's own domain (smartlinks.app needs nothing). */
|
|
89
|
+
async function registerDomain(collectionId, domain) {
|
|
90
|
+
return post(`${adm(collectionId)}/domains`, { domain });
|
|
91
|
+
}
|
|
92
|
+
admin.registerDomain = registerDomain;
|
|
93
|
+
})(admin = payments.admin || (payments.admin = {}));
|
|
94
|
+
})(payments || (payments = {}));
|
package/dist/api/products.d.ts
CHANGED
|
@@ -1,30 +1,41 @@
|
|
|
1
1
|
import type { StandardQuery, QueryResult, QueryDescription } from "../types/query.js";
|
|
2
2
|
import { JsonValue, ProductClaimCreateRequestBody, ProductCreateRequest, ProductQueryMeta, ProductQueryRequest, ProductResponse, ProductUpdateRequest } from "../types/product.js";
|
|
3
3
|
import type { AssetResponse } from "../types/asset.js";
|
|
4
|
-
import type { ListResult } from "../types/list.js";
|
|
4
|
+
import type { ListResult, ListOptions } from "../types/list.js";
|
|
5
5
|
export declare namespace products {
|
|
6
6
|
function get(collectionId: string, productId: string, admin?: boolean): Promise<ProductResponse>;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The products in a collection, a page at a time. For searching, filtering and sorting use
|
|
9
9
|
* `products.query`.
|
|
10
10
|
*
|
|
11
11
|
* @param collectionId - Identifier of the parent collection
|
|
12
12
|
* @param admin - When `true`, targets the `/admin` endpoint; otherwise the `/public` one
|
|
13
|
+
* @param options - `limit` (default 50) and `cursor`; `expand: ['facets']` gives each product's facets
|
|
14
|
+
* as full values instead of their keys
|
|
13
15
|
*
|
|
14
16
|
* @example
|
|
15
17
|
* ```typescript
|
|
16
|
-
*
|
|
18
|
+
* let page = await products.list(collectionId, false, { limit: 50 })
|
|
19
|
+
* while (page.nextCursor) {
|
|
20
|
+
* page = await products.list(collectionId, false, { limit: 50, cursor: page.nextCursor })
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* // Admin, with full facet values
|
|
24
|
+
* const { items } = await products.list(collectionId, true, { expand: ['facets'] })
|
|
17
25
|
* ```
|
|
18
26
|
*/
|
|
19
|
-
function list(collectionId: string, admin?: boolean
|
|
27
|
+
function list(collectionId: string, admin?: boolean, options?: ListOptions & {
|
|
28
|
+
expand?: Array<'facets'>;
|
|
29
|
+
}): Promise<ListResult<ProductResponse>>;
|
|
20
30
|
function create(collectionId: string, data: ProductCreateRequest): Promise<ProductResponse>;
|
|
21
31
|
function update(collectionId: string, productId: string, data: ProductUpdateRequest): Promise<ProductResponse>;
|
|
22
32
|
function remove(collectionId: string, productId: string): Promise<void>;
|
|
23
33
|
/**
|
|
24
|
-
* Query products in a collection with filtering, sorting, and paging.
|
|
34
|
+
* Query products in a collection with search, filtering, sorting, and paging.
|
|
25
35
|
*
|
|
26
36
|
* @param collectionId - Identifier of the parent collection
|
|
27
|
-
* @param body -
|
|
37
|
+
* @param body - `q` (search text), `orderBy`, `createdAt` / `updatedAt` (date ranges), `expand: ['facets']`
|
|
38
|
+
* and the other filters in `query`, plus `limit` (default 50) and `cursor` for paging
|
|
28
39
|
* @param admin - When `true`, targets the `/admin` endpoint (requires an
|
|
29
40
|
* authenticated admin context). Defaults to `false`, which targets the
|
|
30
41
|
* `/public` endpoint — consistent with `get`, `list`, and `listAssets`.
|
|
@@ -35,15 +46,23 @@ export declare namespace products {
|
|
|
35
46
|
* @example
|
|
36
47
|
* ```typescript
|
|
37
48
|
* // Public query (default)
|
|
38
|
-
* const { items, nextCursor, count } = await products.query(collectionId, {
|
|
49
|
+
* const { items, nextCursor, count } = await products.query(collectionId, { q: 'cabernet', limit: 20 })
|
|
39
50
|
*
|
|
40
51
|
* // The next page: the same query with the cursor
|
|
41
52
|
* if (nextCursor) {
|
|
42
|
-
* await products.query(collectionId, {
|
|
53
|
+
* await products.query(collectionId, { q: 'cabernet', limit: 20, cursor: nextCursor })
|
|
43
54
|
* }
|
|
44
55
|
*
|
|
56
|
+
* // Newest first, created this month, active only, with full facet values
|
|
57
|
+
* await products.query(collectionId, {
|
|
58
|
+
* orderBy: [{ createdAt: 'desc' }],
|
|
59
|
+
* createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' },
|
|
60
|
+
* query: { status: ['active'] },
|
|
61
|
+
* expand: ['facets'],
|
|
62
|
+
* })
|
|
63
|
+
*
|
|
45
64
|
* // Admin query (authenticated)
|
|
46
|
-
* await products.query(collectionId, {
|
|
65
|
+
* await products.query(collectionId, { q: 'cabernet' }, true)
|
|
47
66
|
* ```
|
|
48
67
|
*/
|
|
49
68
|
function query(collectionId: string, body: ProductQueryRequest, admin?: boolean): Promise<ListResult<ProductResponse> & {
|
|
@@ -72,16 +91,20 @@ export declare namespace products {
|
|
|
72
91
|
function standardQueryFields(collectionId: string): Promise<QueryDescription>;
|
|
73
92
|
function clone(collectionId: string, productId: string, body?: Record<string, JsonValue>): Promise<ProductResponse>;
|
|
74
93
|
/**
|
|
75
|
-
* A product's assets (images, documents),
|
|
94
|
+
* A product's assets (images, documents), a page at a time.
|
|
76
95
|
*
|
|
77
96
|
* @param admin - When `true`, targets the `/admin` endpoint; otherwise the `/public` one
|
|
97
|
+
* @param options - `limit` (default 50) and `cursor`
|
|
78
98
|
*
|
|
79
99
|
* @example
|
|
80
100
|
* ```typescript
|
|
81
|
-
*
|
|
101
|
+
* let page = await products.listAssets(collectionId, productId, false, { limit: 50 })
|
|
102
|
+
* while (page.nextCursor) {
|
|
103
|
+
* page = await products.listAssets(collectionId, productId, false, { limit: 50, cursor: page.nextCursor })
|
|
104
|
+
* }
|
|
82
105
|
* ```
|
|
83
106
|
*/
|
|
84
|
-
function listAssets(collectionId: string, productId: string, admin?: boolean): Promise<ListResult<AssetResponse>>;
|
|
107
|
+
function listAssets(collectionId: string, productId: string, admin?: boolean, options?: ListOptions): Promise<ListResult<AssetResponse>>;
|
|
85
108
|
function createClaimWindow(collectionId: string, productId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
86
109
|
function updateClaimWindow(collectionId: string, productId: string, claimId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
87
110
|
function refresh(collectionId: string, productId: string): Promise<ProductResponse>;
|