@proveanything/smartlinks 2.2.1 → 3.0.0-alpha.0
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 -754
- package/dist/README.md +573 -573
- package/dist/adminCardsView.js +55 -55
- package/dist/api/adminCards.d.ts +8 -0
- package/dist/api/adminCards.js +9 -1
- package/dist/api/ai.d.ts +22 -11
- package/dist/api/ai.js +18 -14
- package/dist/api/analytics.d.ts +13 -0
- package/dist/api/analytics.js +13 -0
- package/dist/api/appConfiguration.d.ts +17 -14
- package/dist/api/appConfiguration.js +14 -12
- package/dist/api/appObjects.d.ts +80 -16
- package/dist/api/appObjects.js +74 -11
- package/dist/api/asset.d.ts +55 -19
- package/dist/api/asset.js +52 -32
- package/dist/api/attestation.d.ts +3 -2
- package/dist/api/attestation.js +1 -1
- package/dist/api/attestations.d.ts +22 -7
- package/dist/api/attestations.js +22 -7
- package/dist/api/authKit.d.ts +22 -5
- package/dist/api/authKit.js +21 -4
- package/dist/api/batch.d.ts +23 -16
- package/dist/api/batch.js +19 -13
- package/dist/api/bookings.d.ts +45 -9
- package/dist/api/bookings.js +39 -3
- package/dist/api/broadcasts.d.ts +26 -6
- package/dist/api/broadcasts.js +22 -2
- package/dist/api/claimSet.d.ts +48 -13
- package/dist/api/claimSet.js +43 -7
- package/dist/api/collection.d.ts +20 -6
- package/dist/api/collection.js +19 -8
- package/dist/api/comms.d.ts +43 -12
- package/dist/api/comms.js +43 -13
- package/dist/api/conditions.d.ts +12 -2
- package/dist/api/conditions.js +10 -1
- package/dist/api/config.d.ts +15 -2
- package/dist/api/config.js +12 -0
- package/dist/api/contact.d.ts +34 -13
- package/dist/api/contact.js +35 -10
- package/dist/api/containers.d.ts +41 -23
- package/dist/api/containers.js +37 -21
- package/dist/api/crate.d.ts +9 -8
- package/dist/api/crate.js +8 -8
- package/dist/api/dpp.d.ts +58 -10
- package/dist/api/dpp.js +57 -15
- package/dist/api/facets.d.ts +71 -0
- package/dist/api/facets.js +71 -0
- package/dist/api/files.d.ts +11 -5
- package/dist/api/files.js +9 -1
- package/dist/api/form.d.ts +9 -2
- package/dist/api/form.js +7 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +0 -1
- package/dist/api/integrations.d.ts +82 -27
- package/dist/api/integrations.js +63 -7
- package/dist/api/interactions.d.ts +42 -6
- package/dist/api/interactions.js +41 -5
- package/dist/api/jobs.d.ts +9 -2
- package/dist/api/jobs.js +6 -0
- package/dist/api/journeys.d.ts +13 -2
- package/dist/api/journeys.js +10 -1
- package/dist/api/journeysAnalytics.d.ts +12 -3
- package/dist/api/journeysAnalytics.js +9 -1
- package/dist/api/knowledge.d.ts +43 -10
- package/dist/api/knowledge.js +37 -5
- package/dist/api/location.d.ts +10 -3
- package/dist/api/location.js +7 -1
- package/dist/api/lots.d.ts +40 -13
- package/dist/api/lots.js +38 -8
- package/dist/api/loyalty.d.ts +70 -12
- package/dist/api/loyalty.js +60 -3
- package/dist/api/nfc.d.ts +8 -2
- package/dist/api/nfc.js +6 -1
- package/dist/api/order.d.ts +51 -160
- package/dist/api/order.js +46 -208
- package/dist/api/partner.d.ts +41 -8
- package/dist/api/partner.js +36 -4
- package/dist/api/products.d.ts +41 -8
- package/dist/api/products.js +33 -4
- package/dist/api/proof.d.ts +50 -13
- package/dist/api/proof.js +43 -7
- package/dist/api/realtime.d.ts +1 -11
- package/dist/api/realtime.js +1 -22
- package/dist/api/secrets.d.ts +25 -5
- package/dist/api/secrets.js +21 -2
- package/dist/api/segments.d.ts +26 -6
- package/dist/api/segments.js +22 -2
- package/dist/api/serviceAccounts.d.ts +8 -1
- package/dist/api/serviceAccounts.js +8 -1
- package/dist/api/shop.d.ts +41 -13
- package/dist/api/shop.js +35 -4
- package/dist/api/subscriptions.d.ts +47 -12
- package/dist/api/subscriptions.js +40 -4
- package/dist/api/tags.d.ts +40 -19
- package/dist/api/tags.js +38 -18
- package/dist/api/template.d.ts +31 -3
- package/dist/api/template.js +27 -0
- package/dist/api/translations.d.ts +17 -2
- package/dist/api/translations.js +14 -0
- package/dist/api/userGroups.d.ts +35 -9
- package/dist/api/userGroups.js +30 -5
- package/dist/api/variant.d.ts +11 -3
- package/dist/api/variant.js +9 -2
- package/dist/api/wallet.d.ts +23 -10
- package/dist/api/wallet.js +20 -2
- package/dist/apiVersion.d.ts +1 -1
- package/dist/apiVersion.js +1 -1
- package/dist/baseline.css +194 -194
- package/dist/docs/API_SUMMARY.md +1389 -2298
- package/dist/docs/PRODUCT_FACETS_SDK.md +10 -15
- package/dist/docs/admin-cards.md +189 -189
- package/dist/docs/admin-lists-and-pickers.md +1 -1
- 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 +3 -2
- package/dist/docs/api-versions.md +85 -76
- 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 +38 -50
- package/dist/docs/app-records-pattern.md +388 -388
- package/dist/docs/appConfig.md +550 -550
- package/dist/docs/assets.md +17 -3
- package/dist/docs/assistant-apps.md +172 -172
- package/dist/docs/assistant-context.md +119 -119
- package/dist/docs/attestations.md +5 -4
- package/dist/docs/auth-kit.md +1 -1
- package/dist/docs/bookings.md +442 -442
- package/dist/docs/comms.md +689 -686
- package/dist/docs/connectors.md +340 -340
- package/dist/docs/contact-search.md +4 -3
- package/dist/docs/container-tracking.md +7 -7
- package/dist/docs/css-baseline.md +133 -133
- package/dist/docs/customer-guide.md +70 -70
- 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/executor.md +1 -1
- package/dist/docs/files.md +69 -69
- package/dist/docs/forms.md +1 -1
- package/dist/docs/headless-providers.md +3 -3
- package/dist/docs/host-dependency-contract.md +252 -210
- package/dist/docs/i18n.md +292 -46
- package/dist/docs/integrations.md +322 -322
- package/dist/docs/interactions.md +544 -545
- package/dist/docs/item-context.md +181 -181
- package/dist/docs/knowledge.md +105 -102
- package/dist/docs/lists.md +114 -0
- package/dist/docs/lots.md +112 -111
- package/dist/docs/loyalty.md +348 -352
- package/dist/docs/members.md +183 -183
- package/dist/docs/memberships.md +150 -149
- package/dist/docs/mobile-admin-container.md +693 -693
- package/dist/docs/operations.md +281 -281
- package/dist/docs/overview.md +485 -485
- package/dist/docs/proof-claiming-methods.md +6 -6
- 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 +139 -138
- package/dist/docs/records-admin-pattern.md +304 -304
- package/dist/docs/server-functions.md +2 -2
- package/dist/docs/service-accounts.md +64 -64
- package/dist/docs/shop.md +4 -2
- package/dist/docs/site-seo.md +2 -1
- package/dist/docs/standard-query.md +187 -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/translations.md +6 -1
- package/dist/docs/upgrading-to-3.md +430 -0
- package/dist/docs/user-groups.md +4 -4
- package/dist/docs/utils.md +1 -1
- package/dist/docs/wallet-passes.md +107 -107
- package/dist/docs/websites.md +123 -123
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +2 -2
- package/dist/http.d.ts +15 -2
- package/dist/http.js +60 -2
- package/dist/i18n.d.ts +2 -14
- package/dist/i18n.js +6 -23
- package/dist/index.d.ts +7 -8
- package/dist/index.js +2 -0
- package/dist/list.d.ts +24 -0
- package/dist/list.js +80 -0
- package/dist/mobile-admin/types.d.ts +0 -16
- package/dist/openapi.yaml +290 -2723
- package/dist/shared-dependencies.d.ts +3 -3
- package/dist/shared-dependencies.js +13 -5
- package/dist/site.d.ts +1 -7
- package/dist/site.js +1 -14
- package/dist/theme-boot.js +82 -82
- package/dist/theme.css +75 -75
- package/dist/types/adminCards.d.ts +6 -3
- package/dist/types/ai.d.ts +0 -6
- package/dist/types/analytics.d.ts +5 -8
- package/dist/types/appManifest.d.ts +4 -5
- package/dist/types/appObjects.d.ts +14 -18
- package/dist/types/appObjects.js +0 -1
- package/dist/types/appOptions.d.ts +18 -0
- package/dist/types/asset.d.ts +3 -22
- package/dist/types/attestations.d.ts +7 -10
- package/dist/types/batch.d.ts +6 -14
- package/dist/types/bookings.d.ts +22 -4
- package/dist/types/broadcasts.d.ts +5 -13
- package/dist/types/broadcasts.js +0 -1
- package/dist/types/claimSet.d.ts +0 -5
- package/dist/types/comms.d.ts +11 -9
- package/dist/types/contact.d.ts +5 -29
- package/dist/types/contact.js +0 -13
- package/dist/types/containers.d.ts +15 -26
- package/dist/types/crate.d.ts +4 -12
- package/dist/types/dpp.d.ts +3 -3
- package/dist/types/dpp.js +0 -1
- package/dist/types/error.d.ts +8 -5
- package/dist/types/error.js +12 -5
- package/dist/types/facets.d.ts +15 -15
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/integrations.d.ts +3 -28
- package/dist/types/interaction.d.ts +3 -9
- package/dist/types/jobs.d.ts +3 -8
- package/dist/types/jobs.js +0 -1
- package/dist/types/journeys.d.ts +3 -8
- package/dist/types/journeys.js +0 -1
- package/dist/types/journeysAnalytics.d.ts +0 -1
- package/dist/types/list.d.ts +24 -0
- package/dist/types/list.js +2 -0
- package/dist/types/location.d.ts +0 -4
- package/dist/types/lots.d.ts +0 -9
- package/dist/types/loyalty.d.ts +0 -9
- package/dist/types/order.d.ts +7 -134
- package/dist/types/product.d.ts +11 -24
- package/dist/types/proof.d.ts +16 -0
- package/dist/types/realtime.d.ts +0 -29
- package/dist/types/segments.d.ts +5 -13
- package/dist/types/segments.js +0 -1
- package/dist/types/serviceAccounts.d.ts +3 -2
- package/dist/types/serviceAccounts.js +0 -1
- package/dist/types/shop.d.ts +5 -12
- package/dist/types/shop.js +0 -4
- package/dist/types/subscriptions.d.ts +18 -0
- package/dist/types/subscriptions.js +0 -8
- package/dist/types/tags.d.ts +6 -16
- package/dist/types/tags.js +0 -7
- package/dist/types/translations.d.ts +3 -9
- package/dist/types/variant.d.ts +0 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/API_SUMMARY.md +1389 -2298
- package/docs/PRODUCT_FACETS_SDK.md +10 -15
- package/docs/admin-cards.md +189 -189
- package/docs/admin-lists-and-pickers.md +1 -1
- 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 +3 -2
- package/docs/api-versions.md +85 -76
- 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 +38 -50
- package/docs/app-records-pattern.md +388 -388
- package/docs/appConfig.md +550 -550
- package/docs/assets.md +17 -3
- package/docs/assistant-apps.md +172 -172
- package/docs/assistant-context.md +119 -119
- package/docs/attestations.md +5 -4
- package/docs/auth-kit.md +1 -1
- package/docs/bookings.md +442 -442
- package/docs/comms.md +689 -686
- package/docs/connectors.md +340 -340
- package/docs/contact-search.md +4 -3
- package/docs/container-tracking.md +7 -7
- package/docs/css-baseline.md +133 -133
- package/docs/customer-guide.md +70 -70
- package/docs/deploying-apps.md +340 -340
- package/docs/dpp.md +115 -115
- package/docs/entitlements.md +90 -90
- package/docs/executor.md +1 -1
- package/docs/files.md +69 -69
- package/docs/forms.md +1 -1
- package/docs/headless-providers.md +3 -3
- package/docs/host-dependency-contract.md +252 -210
- package/docs/i18n.md +292 -46
- package/docs/integrations.md +322 -322
- package/docs/interactions.md +544 -545
- package/docs/item-context.md +181 -181
- package/docs/knowledge.md +105 -102
- package/docs/lists.md +114 -0
- package/docs/lots.md +112 -111
- package/docs/loyalty.md +348 -352
- package/docs/members.md +183 -183
- package/docs/memberships.md +150 -149
- package/docs/mobile-admin-container.md +693 -693
- package/docs/operations.md +281 -281
- package/docs/overview.md +485 -485
- package/docs/proof-claiming-methods.md +6 -6
- 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 +139 -138
- package/docs/server-functions.md +2 -2
- package/docs/service-accounts.md +64 -64
- package/docs/shop.md +4 -2
- package/docs/site-seo.md +2 -1
- package/docs/standard-query.md +187 -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/translations.md +6 -1
- package/docs/upgrading-to-3.md +430 -0
- package/docs/user-groups.md +4 -4
- package/docs/utils.md +1 -1
- package/docs/wallet-passes.md +107 -107
- package/docs/websites.md +123 -123
- package/openapi.yaml +290 -2723
- package/package.json +91 -87
- 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 +512 -0
- package/scripts/publish.mjs +272 -272
- package/scripts/register-release.mjs +91 -91
- package/scripts/upgrade.mjs +56 -0
- package/upgrade/3.json +2213 -0
package/dist/api/order.js
CHANGED
|
@@ -113,45 +113,51 @@ export var order;
|
|
|
113
113
|
}
|
|
114
114
|
order.remove = remove;
|
|
115
115
|
/**
|
|
116
|
-
* List orders for a collection with optional filters
|
|
116
|
+
* List orders for a collection with optional filters, a page at a time (default 100).
|
|
117
117
|
* Orders are returned in descending order by createdAt (newest first).
|
|
118
118
|
*
|
|
119
119
|
* @param collectionId - Identifier of the parent collection
|
|
120
|
-
* @param params - Optional
|
|
121
|
-
* @returns Promise resolving to
|
|
120
|
+
* @param params - Optional filters, plus `limit` and `cursor` for paging
|
|
121
|
+
* @returns Promise resolving to `{ items, nextCursor }`: the orders, and the cursor for the next page (null on the last)
|
|
122
122
|
* @throws ErrorResponse if the request fails
|
|
123
123
|
*
|
|
124
124
|
* @example
|
|
125
125
|
* ```typescript
|
|
126
|
-
* //
|
|
127
|
-
* const
|
|
126
|
+
* // The first page of orders (without items for better performance)
|
|
127
|
+
* const { items } = await order.list('coll_123')
|
|
128
128
|
*
|
|
129
|
-
* // List with filters
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* limit: 50,
|
|
133
|
-
*
|
|
134
|
-
* })
|
|
129
|
+
* // List with filters, page by page
|
|
130
|
+
* let page = await order.list('coll_123', { status: 'pending', limit: 50 })
|
|
131
|
+
* while (page.nextCursor) {
|
|
132
|
+
* page = await order.list('coll_123', { status: 'pending', limit: 50, cursor: page.nextCursor })
|
|
133
|
+
* }
|
|
135
134
|
*
|
|
136
135
|
* // Filter by customer with items
|
|
137
136
|
* const customerOrders = await order.list('coll_123', {
|
|
138
137
|
* customerId: 'CUST-789',
|
|
139
138
|
* includeItems: true
|
|
140
139
|
* })
|
|
140
|
+
*
|
|
141
|
+
* // Purchase orders from one supplier
|
|
142
|
+
* const purchases = await order.list('coll_123', { direction: 'purchase', partyId: supplierId })
|
|
141
143
|
* ```
|
|
142
144
|
*/
|
|
143
145
|
async function list(collectionId, params) {
|
|
144
146
|
const queryParams = new URLSearchParams();
|
|
145
147
|
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
146
148
|
queryParams.append('limit', params.limit.toString());
|
|
147
|
-
if (params === null || params === void 0 ? void 0 : params.
|
|
148
|
-
queryParams.append('
|
|
149
|
+
if (params === null || params === void 0 ? void 0 : params.cursor)
|
|
150
|
+
queryParams.append('cursor', params.cursor);
|
|
149
151
|
if (params === null || params === void 0 ? void 0 : params.status)
|
|
150
152
|
queryParams.append('status', params.status);
|
|
151
153
|
if (params === null || params === void 0 ? void 0 : params.orderRef)
|
|
152
154
|
queryParams.append('orderRef', params.orderRef);
|
|
153
155
|
if (params === null || params === void 0 ? void 0 : params.customerId)
|
|
154
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);
|
|
155
161
|
if (params === null || params === void 0 ? void 0 : params.includeItems)
|
|
156
162
|
queryParams.append('includeItems', 'true');
|
|
157
163
|
const query = queryParams.toString();
|
|
@@ -165,31 +171,27 @@ export var order;
|
|
|
165
171
|
*
|
|
166
172
|
* @param collectionId - Identifier of the parent collection
|
|
167
173
|
* @param orderId - Order ID
|
|
168
|
-
* @param params - Optional
|
|
169
|
-
* @returns Promise resolving to
|
|
174
|
+
* @param params - Optional `limit` and `cursor` for paging
|
|
175
|
+
* @returns Promise resolving to `{ items, nextCursor }`: the order's items, and the cursor for the next page (null on the last)
|
|
170
176
|
* @throws ErrorResponse if the request fails
|
|
171
177
|
*
|
|
172
178
|
* @example
|
|
173
179
|
* ```typescript
|
|
174
180
|
* // Get first page of items
|
|
175
|
-
* const page1 = await order.getItems('coll_123', 'order_abc123', {
|
|
176
|
-
* limit: 100,
|
|
177
|
-
* offset: 0
|
|
178
|
-
* })
|
|
181
|
+
* const page1 = await order.getItems('coll_123', 'order_abc123', { limit: 100 })
|
|
179
182
|
*
|
|
180
183
|
* // Get next page
|
|
181
|
-
*
|
|
182
|
-
* limit: 100,
|
|
183
|
-
*
|
|
184
|
-
* })
|
|
184
|
+
* if (page1.nextCursor) {
|
|
185
|
+
* const page2 = await order.getItems('coll_123', 'order_abc123', { limit: 100, cursor: page1.nextCursor })
|
|
186
|
+
* }
|
|
185
187
|
* ```
|
|
186
188
|
*/
|
|
187
189
|
async function getItems(collectionId, orderId, params) {
|
|
188
190
|
const queryParams = new URLSearchParams();
|
|
189
191
|
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
190
192
|
queryParams.append('limit', params.limit.toString());
|
|
191
|
-
if (params === null || params === void 0 ? void 0 : params.
|
|
192
|
-
queryParams.append('
|
|
193
|
+
if (params === null || params === void 0 ? void 0 : params.cursor)
|
|
194
|
+
queryParams.append('cursor', params.cursor);
|
|
193
195
|
const query = queryParams.toString();
|
|
194
196
|
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/${encodeURIComponent(orderId)}/items${query ? `?${query}` : ''}`;
|
|
195
197
|
return request(path);
|
|
@@ -261,46 +263,6 @@ export var order;
|
|
|
261
263
|
});
|
|
262
264
|
}
|
|
263
265
|
order.removeItems = removeItems;
|
|
264
|
-
/**
|
|
265
|
-
* Find all orders containing specific items (tags, proofs, or serial numbers).
|
|
266
|
-
* Use case: Scan a tag and immediately see if it's part of any order.
|
|
267
|
-
*
|
|
268
|
-
* @param collectionId - Identifier of the parent collection
|
|
269
|
-
* @param data - Items to look up
|
|
270
|
-
* @returns Promise resolving to a LookupOrdersResponse with matching orders
|
|
271
|
-
* @throws ErrorResponse if the request fails
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* ```typescript
|
|
275
|
-
* // Scan a tag and find associated orders
|
|
276
|
-
* const result = await order.lookup('coll_123', {
|
|
277
|
-
* items: [
|
|
278
|
-
* { itemType: 'tag', itemId: 'TAG001' }
|
|
279
|
-
* ]
|
|
280
|
-
* })
|
|
281
|
-
*
|
|
282
|
-
* if (result.orders.length > 0) {
|
|
283
|
-
* console.log(`Tag is part of ${result.orders.length} order(s)`)
|
|
284
|
-
* result.orders.forEach(ord => {
|
|
285
|
-
* console.log(`Order ${ord.orderRef}: ${ord.status}`)
|
|
286
|
-
* })
|
|
287
|
-
* }
|
|
288
|
-
*
|
|
289
|
-
* // Batch lookup multiple items
|
|
290
|
-
* const batchResult = await order.lookup('coll_123', {
|
|
291
|
-
* items: [
|
|
292
|
-
* { itemType: 'tag', itemId: 'TAG001' },
|
|
293
|
-
* { itemType: 'serial', itemId: 'SN12345' },
|
|
294
|
-
* { itemType: 'proof', itemId: 'proof_xyz' }
|
|
295
|
-
* ]
|
|
296
|
-
* })
|
|
297
|
-
* ```
|
|
298
|
-
*/
|
|
299
|
-
async function lookup(collectionId, data) {
|
|
300
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/lookup`;
|
|
301
|
-
return post(path, data);
|
|
302
|
-
}
|
|
303
|
-
order.lookup = lookup;
|
|
304
266
|
function validateOrderQuery(data) {
|
|
305
267
|
const query = data.query;
|
|
306
268
|
if (!query)
|
|
@@ -314,8 +276,8 @@ export var order;
|
|
|
314
276
|
* More powerful than the basic list() function.
|
|
315
277
|
*
|
|
316
278
|
* @param collectionId - Identifier of the parent collection
|
|
317
|
-
* @param data - Query parameters with filters
|
|
318
|
-
* @returns Promise resolving to
|
|
279
|
+
* @param data - Query parameters with filters and sorting, plus `limit` and `cursor` for paging
|
|
280
|
+
* @returns Promise resolving to `{ items, nextCursor }`: the matching orders, and the cursor for the next page (null on the last)
|
|
319
281
|
* @throws ErrorResponse if the request fails
|
|
320
282
|
*
|
|
321
283
|
* @example
|
|
@@ -331,6 +293,16 @@ export var order;
|
|
|
331
293
|
* },
|
|
332
294
|
* limit: 50
|
|
333
295
|
* })
|
|
296
|
+
* console.log(result.items.length)
|
|
297
|
+
*
|
|
298
|
+
* // The next page: the same query with the cursor
|
|
299
|
+
* if (result.nextCursor) {
|
|
300
|
+
* const next = await order.query('coll_123', {
|
|
301
|
+
* query: { status: 'pending', sortBy: 'createdAt', sortOrder: 'desc' },
|
|
302
|
+
* limit: 50,
|
|
303
|
+
* cursor: result.nextCursor
|
|
304
|
+
* })
|
|
305
|
+
* }
|
|
334
306
|
*
|
|
335
307
|
* // Find orders with specific metadata and item count
|
|
336
308
|
* const highPriority = await order.query('coll_123', {
|
|
@@ -434,43 +406,6 @@ export var order;
|
|
|
434
406
|
return request(path);
|
|
435
407
|
}
|
|
436
408
|
order.reports = reports;
|
|
437
|
-
/**
|
|
438
|
-
* Find all orders containing items with a specific product ID.
|
|
439
|
-
* Uses the automatic productSummary tracking in order metadata.
|
|
440
|
-
*
|
|
441
|
-
* @param collectionId - Identifier of the parent collection
|
|
442
|
-
* @param productId - Product ID to search for
|
|
443
|
-
* @param params - Optional pagination and includeItems parameters
|
|
444
|
-
* @returns Promise resolving to a LookupByProductResponse
|
|
445
|
-
* @throws ErrorResponse if the request fails
|
|
446
|
-
*
|
|
447
|
-
* @example
|
|
448
|
-
* ```typescript
|
|
449
|
-
* // Find all orders with a specific product
|
|
450
|
-
* const result = await order.findByProduct('coll_123', 'product_abc123', {
|
|
451
|
-
* limit: 50,
|
|
452
|
-
* includeItems: false
|
|
453
|
-
* })
|
|
454
|
-
*
|
|
455
|
-
* result.orders.forEach(ord => {
|
|
456
|
-
* const count = ord.metadata.productSummary?.['product_abc123'] ?? 0
|
|
457
|
-
* console.log(`Order ${ord.orderRef} has ${count} items of this product`)
|
|
458
|
-
* })
|
|
459
|
-
* ```
|
|
460
|
-
*/
|
|
461
|
-
async function findByProduct(collectionId, productId, params) {
|
|
462
|
-
const queryParams = new URLSearchParams();
|
|
463
|
-
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
464
|
-
queryParams.append('limit', params.limit.toString());
|
|
465
|
-
if (params === null || params === void 0 ? void 0 : params.offset)
|
|
466
|
-
queryParams.append('offset', params.offset.toString());
|
|
467
|
-
if (params === null || params === void 0 ? void 0 : params.includeItems)
|
|
468
|
-
queryParams.append('includeItems', 'true');
|
|
469
|
-
const query = queryParams.toString();
|
|
470
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/product/${encodeURIComponent(productId)}${query ? `?${query}` : ''}`;
|
|
471
|
-
return request(path);
|
|
472
|
-
}
|
|
473
|
-
order.findByProduct = findByProduct;
|
|
474
409
|
/**
|
|
475
410
|
* Get comprehensive scan analytics for all tags in an order.
|
|
476
411
|
* Returns scan counts, timestamps, locations, devices, and per-tag summaries.
|
|
@@ -508,7 +443,8 @@ export var order;
|
|
|
508
443
|
* @param collectionId - Identifier of the parent collection
|
|
509
444
|
* @param orderId - Order ID
|
|
510
445
|
* @param params - Optional filters (limit, date range, isAdmin)
|
|
511
|
-
* @returns Promise resolving to
|
|
446
|
+
* @returns Promise resolving to `{ items, nextCursor, orderRef, orderId }`: the scan events (one list, no
|
|
447
|
+
* pages: `limit` says how many, default 1000), with the order they belong to
|
|
512
448
|
* @throws ErrorResponse if the request fails
|
|
513
449
|
*
|
|
514
450
|
* @example
|
|
@@ -516,7 +452,7 @@ export var order;
|
|
|
516
452
|
* // Get all scan events
|
|
517
453
|
* const timeline = await order.getTimeline('coll_123', 'order_abc123')
|
|
518
454
|
*
|
|
519
|
-
* timeline.
|
|
455
|
+
* timeline.items.forEach(event => {
|
|
520
456
|
* console.log(`${event.timestamp}: ${event.eventType} by ${event.isAdmin ? 'admin' : 'customer'}`)
|
|
521
457
|
* })
|
|
522
458
|
*
|
|
@@ -540,7 +476,8 @@ export var order;
|
|
|
540
476
|
* @param collectionId - Identifier of the parent collection
|
|
541
477
|
* @param orderId - Order ID
|
|
542
478
|
* @param params - Optional limit parameter
|
|
543
|
-
* @returns Promise resolving to
|
|
479
|
+
* @returns Promise resolving to `{ items, nextCursor, orderRef, orderId }`: the scans that have a location
|
|
480
|
+
* (one list, no pages: `limit` says how many, default 1000), with the order they belong to
|
|
544
481
|
* @throws ErrorResponse if the request fails
|
|
545
482
|
*
|
|
546
483
|
* @example
|
|
@@ -549,8 +486,8 @@ export var order;
|
|
|
549
486
|
* limit: 100
|
|
550
487
|
* })
|
|
551
488
|
*
|
|
552
|
-
* console.log(`Order
|
|
553
|
-
* locations.
|
|
489
|
+
* console.log(`Order has ${locations.items.length} scans with a location`)
|
|
490
|
+
* locations.items.forEach(scan => {
|
|
554
491
|
* console.log(`${scan.location} at ${scan.timestamp}`)
|
|
555
492
|
* })
|
|
556
493
|
* ```
|
|
@@ -620,103 +557,4 @@ export var order;
|
|
|
620
557
|
return post(path, params || {});
|
|
621
558
|
}
|
|
622
559
|
order.getCollectionSummary = getCollectionSummary;
|
|
623
|
-
/**
|
|
624
|
-
* Find all orders containing items from a specific product.
|
|
625
|
-
* Uses indexed queries for fast lookups across order items.
|
|
626
|
-
*
|
|
627
|
-
* @param collectionId - Identifier of the parent collection
|
|
628
|
-
* @param productId - Product ID to search for
|
|
629
|
-
* @param params - Optional pagination and includeItems parameters
|
|
630
|
-
* @returns Promise resolving to a FindOrdersByAttributeResponse
|
|
631
|
-
* @throws ErrorResponse if the request fails
|
|
632
|
-
*
|
|
633
|
-
* @example
|
|
634
|
-
* ```typescript
|
|
635
|
-
* // Find all orders containing a product
|
|
636
|
-
* const { orders, limit, offset } = await order.findOrdersByProduct('coll_123', 'prod_789', {
|
|
637
|
-
* limit: 100
|
|
638
|
-
* })
|
|
639
|
-
*
|
|
640
|
-
* console.log(`Product appears in ${orders.length} orders`)
|
|
641
|
-
* ```
|
|
642
|
-
*/
|
|
643
|
-
async function findOrdersByProduct(collectionId, productId, params) {
|
|
644
|
-
const queryParams = new URLSearchParams();
|
|
645
|
-
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
646
|
-
queryParams.append('limit', params.limit.toString());
|
|
647
|
-
if (params === null || params === void 0 ? void 0 : params.offset)
|
|
648
|
-
queryParams.append('offset', params.offset.toString());
|
|
649
|
-
if (params === null || params === void 0 ? void 0 : params.includeItems)
|
|
650
|
-
queryParams.append('includeItems', 'true');
|
|
651
|
-
const query = queryParams.toString();
|
|
652
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/product/${encodeURIComponent(productId)}${query ? `?${query}` : ''}`;
|
|
653
|
-
return request(path);
|
|
654
|
-
}
|
|
655
|
-
order.findOrdersByProduct = findOrdersByProduct;
|
|
656
|
-
/**
|
|
657
|
-
* Get individual order items for a specific product.
|
|
658
|
-
* Returns all matching items with optional order summary.
|
|
659
|
-
*
|
|
660
|
-
* @param collectionId - Identifier of the parent collection
|
|
661
|
-
* @param productId - Product ID to search for
|
|
662
|
-
* @param params - Optional pagination and includeOrder parameters
|
|
663
|
-
* @returns Promise resolving to a FindItemsByAttributeResponse
|
|
664
|
-
* @throws ErrorResponse if the request fails
|
|
665
|
-
*
|
|
666
|
-
* @example
|
|
667
|
-
* ```typescript
|
|
668
|
-
* // Get all items for a product
|
|
669
|
-
* const { items } = await order.findItemsByProduct('coll_123', 'prod_789', {
|
|
670
|
-
* includeOrder: true
|
|
671
|
-
* })
|
|
672
|
-
*
|
|
673
|
-
* console.log(`Product delivered in ${items.length} order items`)
|
|
674
|
-
* ```
|
|
675
|
-
*/
|
|
676
|
-
async function findItemsByProduct(collectionId, productId, params) {
|
|
677
|
-
const queryParams = new URLSearchParams();
|
|
678
|
-
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
679
|
-
queryParams.append('limit', params.limit.toString());
|
|
680
|
-
if (params === null || params === void 0 ? void 0 : params.offset)
|
|
681
|
-
queryParams.append('offset', params.offset.toString());
|
|
682
|
-
if (params === null || params === void 0 ? void 0 : params.includeOrder)
|
|
683
|
-
queryParams.append('includeOrder', 'true');
|
|
684
|
-
const query = queryParams.toString();
|
|
685
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/product/${encodeURIComponent(productId)}/items${query ? `?${query}` : ''}`;
|
|
686
|
-
return request(path);
|
|
687
|
-
}
|
|
688
|
-
order.findItemsByProduct = findItemsByProduct;
|
|
689
|
-
/**
|
|
690
|
-
* Get unique order IDs containing items for a specific product.
|
|
691
|
-
* Lightweight query that only returns order IDs, not full order objects.
|
|
692
|
-
*
|
|
693
|
-
* @param collectionId - Identifier of the parent collection
|
|
694
|
-
* @param attribute - Attribute to search by ('productId')
|
|
695
|
-
* @param value - Product ID to search for
|
|
696
|
-
* @param params - Optional pagination parameters
|
|
697
|
-
* @returns Promise resolving to a GetOrderIdsResponse
|
|
698
|
-
* @throws ErrorResponse if the request fails
|
|
699
|
-
*
|
|
700
|
-
* @example
|
|
701
|
-
* ```typescript
|
|
702
|
-
* // Get order IDs for a product
|
|
703
|
-
* const productOrders = await order.getOrderIdsByAttribute(
|
|
704
|
-
* 'coll_123',
|
|
705
|
-
* 'productId',
|
|
706
|
-
* 'prod_789',
|
|
707
|
-
* { limit: 500 }
|
|
708
|
-
* )
|
|
709
|
-
* ```
|
|
710
|
-
*/
|
|
711
|
-
async function getOrderIdsByAttribute(collectionId, attribute, value, params) {
|
|
712
|
-
const queryParams = new URLSearchParams();
|
|
713
|
-
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
714
|
-
queryParams.append('limit', params.limit.toString());
|
|
715
|
-
if (params === null || params === void 0 ? void 0 : params.offset)
|
|
716
|
-
queryParams.append('offset', params.offset.toString());
|
|
717
|
-
const query = queryParams.toString();
|
|
718
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/ids/${attribute}/${encodeURIComponent(value)}${query ? `?${query}` : ''}`;
|
|
719
|
-
return request(path);
|
|
720
|
-
}
|
|
721
|
-
order.getOrderIdsByAttribute = getOrderIdsByAttribute;
|
|
722
560
|
})(order || (order = {}));
|
package/dist/api/partner.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Partner, PartnerClaimSet, CreatePartnerClaimSetRequest, PartnerTagHit, ClientErrorEvent } from "../types/index.js";
|
|
2
|
+
import type { ListResult } from "../types/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
|
|
@@ -6,25 +7,57 @@ import { Partner, PartnerClaimSet, CreatePartnerClaimSetRequest, PartnerTagHit,
|
|
|
6
7
|
* claimSet.ranges.* with scope { partnerId }.
|
|
7
8
|
*/
|
|
8
9
|
export declare namespace partner {
|
|
9
|
-
/**
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The partners you belong to, with your role in each. Returns `{ items, nextCursor }`: the partners are
|
|
12
|
+
* in `items` (empty for everyone else). The list is not paged, so `nextCursor` is always `null`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const { items: partners } = await partner.list()
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function list(): Promise<ListResult<Partner>>;
|
|
11
20
|
/** One partner (owners also see its members). */
|
|
12
21
|
function get(partnerId: string): Promise<Partner>;
|
|
13
|
-
/**
|
|
14
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The partner's claim sets. Returns `{ items, nextCursor }`: the sets are in `items`. The list is not
|
|
24
|
+
* paged, so `nextCursor` is always `null`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const { items: sets } = await partner.claimSets(partnerId)
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function claimSets(partnerId: string): Promise<ListResult<PartnerClaimSet>>;
|
|
15
32
|
/** One of the partner's claim sets. */
|
|
16
33
|
function getClaimSet(partnerId: string, claimSetId: string): Promise<PartnerClaimSet>;
|
|
17
34
|
/** A new claim set for the partner, on one of its tap domains (owners and admins). */
|
|
18
35
|
function createClaimSet(partnerId: string, params: CreatePartnerClaimSetRequest): Promise<PartnerClaimSet>;
|
|
19
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Find a tag across the partner's sets by its chip UID (8 or 14 hex) or its code (printed or bare).
|
|
38
|
+
* 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. The list is not paged, so
|
|
40
|
+
* `nextCursor` is always `null`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const { items: hits } = await partner.lookupTags(partnerId, { uid: '04A1B2C3D4E5F6' })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
20
47
|
function lookupTags(partnerId: string, query: {
|
|
21
48
|
uid?: string;
|
|
22
49
|
code?: string;
|
|
23
|
-
}): Promise<PartnerTagHit
|
|
50
|
+
}): Promise<ListResult<PartnerTagHit>>;
|
|
24
51
|
/**
|
|
25
52
|
* What phones reported about one chip (errors.report with entityType 'tag'), newest first: a tag that
|
|
26
53
|
* failed to program or register, with the host's NFC log in context. For a chip in the partner's sets,
|
|
27
|
-
* or attempts that named one of them.
|
|
54
|
+
* or attempts that named one of them. Returns `{ items, nextCursor }`: the ten latest reports are in
|
|
55
|
+
* `items`. The list is not paged, so `nextCursor` is always `null`.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const { items: attempts } = await partner.tagAttempts(partnerId, '04A1B2C3D4E5F6')
|
|
60
|
+
* ```
|
|
28
61
|
*/
|
|
29
|
-
function tagAttempts(partnerId: string, uid: string): Promise<ClientErrorEvent
|
|
62
|
+
function tagAttempts(partnerId: string, uid: string): Promise<ListResult<ClientErrorEvent>>;
|
|
30
63
|
}
|
package/dist/api/partner.js
CHANGED
|
@@ -7,7 +7,15 @@ import { request, post } from "../http.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export var partner;
|
|
9
9
|
(function (partner) {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* The partners you belong to, with your role in each. Returns `{ items, nextCursor }`: the partners are
|
|
12
|
+
* in `items` (empty for everyone else). The list is not paged, so `nextCursor` is always `null`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const { items: partners } = await partner.list()
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
11
19
|
async function list() {
|
|
12
20
|
return request(`/admin/partner`);
|
|
13
21
|
}
|
|
@@ -17,7 +25,15 @@ export var partner;
|
|
|
17
25
|
return request(`/admin/partner/${encodeURIComponent(partnerId)}`);
|
|
18
26
|
}
|
|
19
27
|
partner.get = get;
|
|
20
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* The partner's claim sets. Returns `{ items, nextCursor }`: the sets are in `items`. The list is not
|
|
30
|
+
* paged, so `nextCursor` is always `null`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const { items: sets } = await partner.claimSets(partnerId)
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
21
37
|
async function claimSets(partnerId) {
|
|
22
38
|
return request(`/admin/partner/${encodeURIComponent(partnerId)}/claimSet`);
|
|
23
39
|
}
|
|
@@ -32,7 +48,17 @@ export var partner;
|
|
|
32
48
|
return post(`/admin/partner/${encodeURIComponent(partnerId)}/claimSet`, params);
|
|
33
49
|
}
|
|
34
50
|
partner.createClaimSet = createClaimSet;
|
|
35
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Find a tag across the partner's sets by its chip UID (8 or 14 hex) or its code (printed or bare).
|
|
53
|
+
* 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. The list is not paged, so
|
|
55
|
+
* `nextCursor` is always `null`.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const { items: hits } = await partner.lookupTags(partnerId, { uid: '04A1B2C3D4E5F6' })
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
36
62
|
async function lookupTags(partnerId, query) {
|
|
37
63
|
const q = new URLSearchParams();
|
|
38
64
|
if (query.uid)
|
|
@@ -45,7 +71,13 @@ export var partner;
|
|
|
45
71
|
/**
|
|
46
72
|
* What phones reported about one chip (errors.report with entityType 'tag'), newest first: a tag that
|
|
47
73
|
* failed to program or register, with the host's NFC log in context. For a chip in the partner's sets,
|
|
48
|
-
* or attempts that named one of them.
|
|
74
|
+
* or attempts that named one of them. Returns `{ items, nextCursor }`: the ten latest reports are in
|
|
75
|
+
* `items`. The list is not paged, so `nextCursor` is always `null`.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const { items: attempts } = await partner.tagAttempts(partnerId, '04A1B2C3D4E5F6')
|
|
80
|
+
* ```
|
|
49
81
|
*/
|
|
50
82
|
async function tagAttempts(partnerId, uid) {
|
|
51
83
|
return request(`/admin/partner/${encodeURIComponent(partnerId)}/tags/attempts?uid=${encodeURIComponent(uid)}`);
|
package/dist/api/products.d.ts
CHANGED
|
@@ -1,31 +1,54 @@
|
|
|
1
1
|
import type { StandardQuery, QueryResult, QueryDescription } from "../types/query.js";
|
|
2
|
-
import { JsonValue, ProductClaimCreateRequestBody, ProductCreateRequest,
|
|
2
|
+
import { JsonValue, ProductClaimCreateRequestBody, ProductCreateRequest, ProductQueryMeta, ProductQueryRequest, ProductResponse, ProductUpdateRequest } from "../types/product.js";
|
|
3
|
+
import type { AssetResponse } from "../types/asset.js";
|
|
4
|
+
import type { ListResult } from "../types/list.js";
|
|
3
5
|
export declare namespace products {
|
|
4
6
|
function get(collectionId: string, productId: string, admin?: boolean): Promise<ProductResponse>;
|
|
5
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Every product in a collection, in one list (no pages). For filtering, sorting and paging use
|
|
9
|
+
* `products.query`.
|
|
10
|
+
*
|
|
11
|
+
* @param collectionId - Identifier of the parent collection
|
|
12
|
+
* @param admin - When `true`, targets the `/admin` endpoint; otherwise the `/public` one
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const { items } = await products.list(collectionId)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function list(collectionId: string, admin?: boolean): Promise<ListResult<ProductResponse>>;
|
|
6
20
|
function create(collectionId: string, data: ProductCreateRequest): Promise<ProductResponse>;
|
|
7
21
|
function update(collectionId: string, productId: string, data: ProductUpdateRequest): Promise<ProductResponse>;
|
|
8
22
|
function remove(collectionId: string, productId: string): Promise<void>;
|
|
9
23
|
/**
|
|
10
|
-
* Query products in a collection with filtering, sorting, and
|
|
24
|
+
* Query products in a collection with filtering, sorting, and paging.
|
|
11
25
|
*
|
|
12
26
|
* @param collectionId - Identifier of the parent collection
|
|
13
|
-
* @param body -
|
|
27
|
+
* @param body - Filters and sorting, plus `limit` (default 50) and `cursor` for paging
|
|
14
28
|
* @param admin - When `true`, targets the `/admin` endpoint (requires an
|
|
15
29
|
* authenticated admin context). Defaults to `false`, which targets the
|
|
16
30
|
* `/public` endpoint — consistent with `get`, `list`, and `listAssets`.
|
|
17
|
-
* @returns Promise resolving to
|
|
31
|
+
* @returns Promise resolving to `{ items, nextCursor, count?, meta? }`: the matching products, the cursor
|
|
32
|
+
* for the next page (null on the last), how many match in all where the server counted, and `meta`
|
|
33
|
+
* (how the query was run)
|
|
18
34
|
*
|
|
19
35
|
* @example
|
|
20
36
|
* ```typescript
|
|
21
37
|
* // Public query (default)
|
|
22
|
-
* await products.query(collectionId, { query: { search: 'cabernet' } })
|
|
38
|
+
* const { items, nextCursor, count } = await products.query(collectionId, { query: { search: 'cabernet' }, limit: 20 })
|
|
39
|
+
*
|
|
40
|
+
* // The next page: the same query with the cursor
|
|
41
|
+
* if (nextCursor) {
|
|
42
|
+
* await products.query(collectionId, { query: { search: 'cabernet' }, limit: 20, cursor: nextCursor })
|
|
43
|
+
* }
|
|
23
44
|
*
|
|
24
45
|
* // Admin query (authenticated)
|
|
25
46
|
* await products.query(collectionId, { query: { search: 'cabernet' } }, true)
|
|
26
47
|
* ```
|
|
27
48
|
*/
|
|
28
|
-
function query(collectionId: string, body: ProductQueryRequest, admin?: boolean): Promise<
|
|
49
|
+
function query(collectionId: string, body: ProductQueryRequest, admin?: boolean): Promise<ListResult<ProductResponse> & {
|
|
50
|
+
meta?: ProductQueryMeta;
|
|
51
|
+
}>;
|
|
29
52
|
/**
|
|
30
53
|
* The standard query on products (admin only): the one query shape every resource is moving to, with
|
|
31
54
|
* counts, totals and filtering by facet. It sits beside `products.query`, whose own body is unchanged.
|
|
@@ -48,7 +71,17 @@ export declare namespace products {
|
|
|
48
71
|
*/
|
|
49
72
|
function standardQueryFields(collectionId: string): Promise<QueryDescription>;
|
|
50
73
|
function clone(collectionId: string, productId: string, body?: Record<string, JsonValue>): Promise<ProductResponse>;
|
|
51
|
-
|
|
74
|
+
/**
|
|
75
|
+
* A product's assets (images, documents), in one list (no pages).
|
|
76
|
+
*
|
|
77
|
+
* @param admin - When `true`, targets the `/admin` endpoint; otherwise the `/public` one
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const { items } = await products.listAssets(collectionId, productId)
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
function listAssets(collectionId: string, productId: string, admin?: boolean): Promise<ListResult<AssetResponse>>;
|
|
52
85
|
function createClaimWindow(collectionId: string, productId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
53
86
|
function updateClaimWindow(collectionId: string, productId: string, claimId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
54
87
|
function refresh(collectionId: string, productId: string): Promise<ProductResponse>;
|
package/dist/api/products.js
CHANGED
|
@@ -7,6 +7,18 @@ export var products;
|
|
|
7
7
|
return request(path);
|
|
8
8
|
}
|
|
9
9
|
products.get = get;
|
|
10
|
+
/**
|
|
11
|
+
* Every product in a collection, in one list (no pages). For filtering, sorting and paging use
|
|
12
|
+
* `products.query`.
|
|
13
|
+
*
|
|
14
|
+
* @param collectionId - Identifier of the parent collection
|
|
15
|
+
* @param admin - When `true`, targets the `/admin` endpoint; otherwise the `/public` one
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const { items } = await products.list(collectionId)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
10
22
|
async function list(collectionId, admin) {
|
|
11
23
|
const base = admin ? '/admin' : '/public';
|
|
12
24
|
const path = `${base}/collection/${encodeURIComponent(collectionId)}/products`;
|
|
@@ -29,19 +41,26 @@ export var products;
|
|
|
29
41
|
}
|
|
30
42
|
products.remove = remove;
|
|
31
43
|
/**
|
|
32
|
-
* Query products in a collection with filtering, sorting, and
|
|
44
|
+
* Query products in a collection with filtering, sorting, and paging.
|
|
33
45
|
*
|
|
34
46
|
* @param collectionId - Identifier of the parent collection
|
|
35
|
-
* @param body -
|
|
47
|
+
* @param body - Filters and sorting, plus `limit` (default 50) and `cursor` for paging
|
|
36
48
|
* @param admin - When `true`, targets the `/admin` endpoint (requires an
|
|
37
49
|
* authenticated admin context). Defaults to `false`, which targets the
|
|
38
50
|
* `/public` endpoint — consistent with `get`, `list`, and `listAssets`.
|
|
39
|
-
* @returns Promise resolving to
|
|
51
|
+
* @returns Promise resolving to `{ items, nextCursor, count?, meta? }`: the matching products, the cursor
|
|
52
|
+
* for the next page (null on the last), how many match in all where the server counted, and `meta`
|
|
53
|
+
* (how the query was run)
|
|
40
54
|
*
|
|
41
55
|
* @example
|
|
42
56
|
* ```typescript
|
|
43
57
|
* // Public query (default)
|
|
44
|
-
* await products.query(collectionId, { query: { search: 'cabernet' } })
|
|
58
|
+
* const { items, nextCursor, count } = await products.query(collectionId, { query: { search: 'cabernet' }, limit: 20 })
|
|
59
|
+
*
|
|
60
|
+
* // The next page: the same query with the cursor
|
|
61
|
+
* if (nextCursor) {
|
|
62
|
+
* await products.query(collectionId, { query: { search: 'cabernet' }, limit: 20, cursor: nextCursor })
|
|
63
|
+
* }
|
|
45
64
|
*
|
|
46
65
|
* // Admin query (authenticated)
|
|
47
66
|
* await products.query(collectionId, { query: { search: 'cabernet' } }, true)
|
|
@@ -87,6 +106,16 @@ export var products;
|
|
|
87
106
|
return post(path, body);
|
|
88
107
|
}
|
|
89
108
|
products.clone = clone;
|
|
109
|
+
/**
|
|
110
|
+
* A product's assets (images, documents), in one list (no pages).
|
|
111
|
+
*
|
|
112
|
+
* @param admin - When `true`, targets the `/admin` endpoint; otherwise the `/public` one
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const { items } = await products.listAssets(collectionId, productId)
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
90
119
|
async function listAssets(collectionId, productId, admin) {
|
|
91
120
|
const base = admin ? '/admin' : '/public';
|
|
92
121
|
const path = `${base}/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/asset`;
|