@proveanything/smartlinks 3.0.0-alpha.1 → 3.0.0-alpha.2

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.
Files changed (145) hide show
  1. package/README.md +7 -7
  2. package/dist/api/analytics.d.ts +5 -4
  3. package/dist/api/analytics.js +5 -4
  4. package/dist/api/appConfiguration.d.ts +23 -18
  5. package/dist/api/appConfiguration.js +24 -18
  6. package/dist/api/appObjects.d.ts +54 -10
  7. package/dist/api/appObjects.js +75 -40
  8. package/dist/api/asset.d.ts +28 -22
  9. package/dist/api/asset.js +45 -56
  10. package/dist/api/attestation.d.ts +11 -3
  11. package/dist/api/attestation.js +12 -3
  12. package/dist/api/attestations.d.ts +12 -8
  13. package/dist/api/attestations.js +18 -21
  14. package/dist/api/authKit.d.ts +15 -10
  15. package/dist/api/authKit.js +17 -11
  16. package/dist/api/batch.d.ts +36 -25
  17. package/dist/api/batch.js +46 -39
  18. package/dist/api/bookings.d.ts +18 -9
  19. package/dist/api/bookings.js +23 -13
  20. package/dist/api/broadcasts.js +3 -17
  21. package/dist/api/claimSet.d.ts +26 -12
  22. package/dist/api/claimSet.js +32 -24
  23. package/dist/api/collection.d.ts +15 -10
  24. package/dist/api/collection.js +17 -11
  25. package/dist/api/comms.d.ts +12 -6
  26. package/dist/api/comms.js +12 -6
  27. package/dist/api/conditions.d.ts +7 -6
  28. package/dist/api/conditions.js +8 -6
  29. package/dist/api/contact.d.ts +6 -2
  30. package/dist/api/contact.js +25 -60
  31. package/dist/api/containers.d.ts +14 -10
  32. package/dist/api/containers.js +19 -14
  33. package/dist/api/crate.js +7 -9
  34. package/dist/api/dpp.d.ts +20 -13
  35. package/dist/api/dpp.js +23 -15
  36. package/dist/api/facets.d.ts +38 -13
  37. package/dist/api/facets.js +40 -15
  38. package/dist/api/files.d.ts +5 -2
  39. package/dist/api/files.js +7 -4
  40. package/dist/api/form.d.ts +8 -5
  41. package/dist/api/form.js +9 -5
  42. package/dist/api/index.d.ts +0 -1
  43. package/dist/api/index.js +0 -1
  44. package/dist/api/integrations.d.ts +29 -17
  45. package/dist/api/integrations.js +32 -25
  46. package/dist/api/interactions.d.ts +11 -6
  47. package/dist/api/interactions.js +14 -23
  48. package/dist/api/jobs.d.ts +16 -6
  49. package/dist/api/jobs.js +30 -20
  50. package/dist/api/journeys.js +2 -14
  51. package/dist/api/journeysAnalytics.d.ts +8 -5
  52. package/dist/api/journeysAnalytics.js +8 -5
  53. package/dist/api/knowledge.d.ts +20 -14
  54. package/dist/api/knowledge.js +22 -15
  55. package/dist/api/location.d.ts +6 -3
  56. package/dist/api/location.js +8 -22
  57. package/dist/api/lots.d.ts +9 -5
  58. package/dist/api/lots.js +22 -26
  59. package/dist/api/loyalty.d.ts +25 -16
  60. package/dist/api/loyalty.js +33 -32
  61. package/dist/api/nfc.d.ts +3 -1
  62. package/dist/api/nfc.js +3 -1
  63. package/dist/api/order.d.ts +45 -39
  64. package/dist/api/order.js +48 -65
  65. package/dist/api/partner.d.ts +17 -14
  66. package/dist/api/partner.js +21 -22
  67. package/dist/api/products.d.ts +35 -12
  68. package/dist/api/products.js +36 -13
  69. package/dist/api/proof.d.ts +41 -19
  70. package/dist/api/proof.js +44 -23
  71. package/dist/api/segments.js +3 -15
  72. package/dist/api/serviceAccounts.d.ts +8 -5
  73. package/dist/api/serviceAccounts.js +9 -6
  74. package/dist/api/shop.d.ts +7 -5
  75. package/dist/api/shop.js +13 -19
  76. package/dist/api/subscriptions.d.ts +12 -10
  77. package/dist/api/subscriptions.js +17 -25
  78. package/dist/api/tags.d.ts +23 -20
  79. package/dist/api/tags.js +40 -52
  80. package/dist/api/template.d.ts +16 -11
  81. package/dist/api/template.js +19 -13
  82. package/dist/api/translations.js +2 -12
  83. package/dist/api/userGroups.d.ts +26 -16
  84. package/dist/api/userGroups.js +43 -30
  85. package/dist/api/variant.d.ts +10 -7
  86. package/dist/api/variant.js +11 -7
  87. package/dist/api/wallet.d.ts +14 -11
  88. package/dist/api/wallet.js +15 -12
  89. package/dist/docs/API_SUMMARY.md +289 -483
  90. package/dist/docs/ai.md +15 -15
  91. package/dist/docs/analytics.md +1 -1
  92. package/dist/docs/app-objects.md +4 -4
  93. package/dist/docs/attestations.md +8 -8
  94. package/dist/docs/contact-search.md +2 -3
  95. package/dist/docs/knowledge.md +3 -3
  96. package/dist/docs/lists.md +58 -15
  97. package/dist/docs/upgrading-to-3.md +238 -136
  98. package/dist/list.d.ts +12 -0
  99. package/dist/list.js +59 -0
  100. package/dist/openapi.yaml +301 -662
  101. package/dist/types/analytics.d.ts +7 -3
  102. package/dist/types/appObjects.d.ts +27 -12
  103. package/dist/types/appOptions.d.ts +2 -2
  104. package/dist/types/asset.d.ts +5 -6
  105. package/dist/types/attestations.d.ts +7 -9
  106. package/dist/types/batch.d.ts +5 -5
  107. package/dist/types/bookings.d.ts +10 -5
  108. package/dist/types/comms.d.ts +9 -5
  109. package/dist/types/contact.d.ts +7 -4
  110. package/dist/types/containers.d.ts +2 -1
  111. package/dist/types/facets.d.ts +14 -2
  112. package/dist/types/files.d.ts +3 -2
  113. package/dist/types/integrations.d.ts +2 -1
  114. package/dist/types/interaction.d.ts +15 -7
  115. package/dist/types/jobs.d.ts +1 -1
  116. package/dist/types/journeysAnalytics.d.ts +3 -2
  117. package/dist/types/knowledge.d.ts +6 -3
  118. package/dist/types/knowledge.js +0 -1
  119. package/dist/types/list.d.ts +30 -2
  120. package/dist/types/location.d.ts +7 -2
  121. package/dist/types/location.js +0 -1
  122. package/dist/types/lots.d.ts +5 -2
  123. package/dist/types/lots.js +0 -6
  124. package/dist/types/order.d.ts +22 -20
  125. package/dist/types/product.d.ts +28 -11
  126. package/dist/types/proof.d.ts +7 -8
  127. package/dist/types/tags.d.ts +5 -3
  128. package/dist/types/userGroups.d.ts +3 -3
  129. package/dist/types/userGroups.js +0 -4
  130. package/dist/version.d.ts +1 -1
  131. package/dist/version.js +1 -1
  132. package/docs/API_SUMMARY.md +289 -483
  133. package/docs/ai.md +15 -15
  134. package/docs/analytics.md +1 -1
  135. package/docs/app-objects.md +4 -4
  136. package/docs/attestations.md +8 -8
  137. package/docs/contact-search.md +2 -3
  138. package/docs/knowledge.md +3 -3
  139. package/docs/lists.md +58 -15
  140. package/docs/upgrading-to-3.md +238 -136
  141. package/openapi.yaml +301 -662
  142. package/package.json +1 -1
  143. package/scripts/lib/upgrade.mjs +216 -60
  144. package/scripts/upgrade.mjs +33 -10
  145. package/upgrade/3.json +2731 -2213
@@ -1,4 +1,5 @@
1
1
  import { request, post, patch, del, put } from '../http.js';
2
+ import { listQuery } from '../list.js';
2
3
  // ==================== APP NAMESPACE ====================
3
4
  export var app;
4
5
  (function (app) {
@@ -14,24 +15,23 @@ export var app;
14
15
  * see every entry; the public API lists public records and lists the app declares public. Hold on
15
16
  * to `version` and pass it back to get `{ unchanged: true }` when nothing changed.
16
17
  *
17
- * Returns `{ items, nextCursor, count?, version, mode }`: the entries are in `items`, already sorted.
18
- * A picker is not paged, so `nextCursor` is always `null`.
18
+ * Returns `{ items, nextCursor, count?, version, mode }`: the entries are in `items`, already sorted,
19
+ * 50 at a time unless you give a `limit` (at most 1000). Pass `nextCursor` back as `cursor` for the
20
+ * next page; `null` means that was the last one. `q` searches the entries.
19
21
  *
20
22
  * @example
21
23
  * ```typescript
22
- * const res = await app.options.get(collectionId, appId, 'type:machine', { admin: true })
24
+ * const res = await app.options.get(collectionId, appId, 'type:machine', { admin: true, limit: 200 })
23
25
  * if (!res.unchanged) { options = res.items; version = res.version }
26
+ *
27
+ * // A type too large to send whole: search it
28
+ * const found = await app.options.get(collectionId, appId, 'type:machine', { q: 'mix', limit: 20 })
24
29
  * ```
25
30
  */
26
31
  async function get(collectionId, appId, source, opts = {}) {
27
32
  const zone = opts.admin ? 'admin' : 'public';
28
- const qs = new URLSearchParams();
29
- if (opts.q)
30
- qs.set('q', opts.q);
31
- if (opts.version)
32
- qs.set('version', opts.version);
33
- const query = qs.toString();
34
- return request(`/${zone}/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}/options/${encodeURIComponent(source)}${query ? `?${query}` : ''}`);
33
+ const query = listQuery({ q: opts.q, version: opts.version, limit: opts.limit, cursor: opts.cursor });
34
+ return request(`/${zone}/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}/options/${encodeURIComponent(source)}${query}`);
35
35
  }
36
36
  options.get = get;
37
37
  /**
@@ -68,6 +68,7 @@ export var app;
68
68
  *
69
69
  * Returns `{ items, nextCursor, count }`: the cases are in `items`, `count` is how many match in
70
70
  * all, and `nextCursor` is `null` on the last page. Page with `limit` and `cursor`.
71
+ * Sort with `orderBy`. A date field (`createdAt`, `updatedAt`, `closedAt`) takes a range: `{ gte, lte }`.
71
72
  * `includeDeleted`, `contactId` and `assignedTo` are for admin calls (`admin = true`) only: the
72
73
  * public list refuses a parameter it does not read.
73
74
  *
@@ -78,12 +79,17 @@ export var app;
78
79
  * while (page.nextCursor) {
79
80
  * page = await app.cases.list(collectionId, appId, { status: 'open', limit: 50, cursor: page.nextCursor })
80
81
  * }
82
+ *
83
+ * // This month's cases, most urgent first
84
+ * await app.cases.list(collectionId, appId, {
85
+ * createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' },
86
+ * orderBy: [{ priority: 'desc' }, { createdAt: 'asc' }],
87
+ * })
81
88
  * ```
82
89
  */
83
90
  async function list(collectionId, appId, params, admin = false) {
84
91
  const path = basePath(collectionId, appId, admin);
85
- const queryParams = params ? buildQueryString(params) : '';
86
- return request(`${path}${queryParams}`);
92
+ return request(`${path}${appListQuery(params)}`);
87
93
  }
88
94
  cases.list = list;
89
95
  /**
@@ -176,6 +182,7 @@ export var app;
176
182
  *
177
183
  * Returns `{ items, nextCursor, count }`: the threads are in `items`, `count` is how many match in
178
184
  * all, and `nextCursor` is `null` on the last page. Page with `limit` and `cursor`.
185
+ * Sort with `orderBy`. A date field (`createdAt`, `updatedAt`) takes a range: `{ gte, lte }`.
179
186
  * `includeDeleted` and `contactId` are for admin calls (`admin = true`) only: the public list
180
187
  * refuses a parameter it does not read.
181
188
  *
@@ -186,12 +193,17 @@ export var app;
186
193
  * while (page.nextCursor) {
187
194
  * page = await app.threads.list(collectionId, appId, { parentType: 'case', parentId: caseId, limit: 50, cursor: page.nextCursor })
188
195
  * }
196
+ *
197
+ * // The threads with the newest replies, started this month
198
+ * await app.threads.list(collectionId, appId, {
199
+ * createdAt: { gte: '2026-11-01T00:00:00Z' },
200
+ * orderBy: [{ lastReplyAt: 'desc' }],
201
+ * })
189
202
  * ```
190
203
  */
191
204
  async function list(collectionId, appId, params, admin = false) {
192
205
  const path = basePath(collectionId, appId, admin);
193
- const queryParams = params ? buildQueryString(params) : '';
194
- return request(`${path}${queryParams}`);
206
+ return request(`${path}${appListQuery(params)}`);
195
207
  }
196
208
  threads.list = list;
197
209
  /**
@@ -315,6 +327,8 @@ export var app;
315
327
  *
316
328
  * Returns `{ items, nextCursor, count }`: the records are in `items`, `count` is how many match in
317
329
  * all, and `nextCursor` is `null` on the last page. Page with `limit` and `cursor`.
330
+ * Search with `q`, sort with `orderBy`. A date field (`createdAt`, `updatedAt`, `startsAt`,
331
+ * `expiresAt`) takes a range: `{ gte, lte }`.
318
332
  *
319
333
  * Public/owner callers only receive records with `status: "active"`.
320
334
  * Admin callers can query all statuses (for example `draft`/`archived`).
@@ -328,12 +342,19 @@ export var app;
328
342
  * while (page.nextCursor) {
329
343
  * page = await app.records.list(collectionId, appId, { recordType: 'tip', limit: 100, cursor: page.nextCursor })
330
344
  * }
345
+ *
346
+ * // Tips about watering, changed this month, newest change first
347
+ * await app.records.list(collectionId, appId, {
348
+ * recordType: 'tip',
349
+ * q: 'watering',
350
+ * updatedAt: { gte: '2026-11-01T00:00:00Z' },
351
+ * orderBy: [{ updatedAt: 'desc' }],
352
+ * })
331
353
  * ```
332
354
  */
333
355
  async function list(collectionId, appId, params, admin = false) {
334
356
  const path = basePath(collectionId, appId, admin);
335
- const queryParams = params ? buildQueryString(params) : '';
336
- return request(`${path}${queryParams}`);
357
+ return request(`${path}${appListQuery(params)}`);
337
358
  }
338
359
  records_1.list = list;
339
360
  /**
@@ -446,8 +467,9 @@ export var app;
446
467
  /**
447
468
  * Match records against a runtime target scope.
448
469
  * Returns `{ items, nextCursor, count, strategy }`: `items` are the records whose scope is satisfied
449
- * by the target, most specific first, and `count` is how many matched. It is not paged
450
- * (`nextCursor` is always `null`); cap the answer with `limit`.
470
+ * by the target, most specific first, and `count` is how many matched. Without a `limit` it answers
471
+ * up to 100. Give a `limit` (in `input`) to page: when there are more, pass `nextCursor` back as
472
+ * `cursor`.
451
473
  * POST /records/match
452
474
  *
453
475
  * @param admin - false for public endpoint (visibility-filtered, active-only), true for admin
@@ -460,6 +482,13 @@ export var app;
460
482
  * recordType: 'nutrition',
461
483
  * }, true);
462
484
  * const best = items[0] // the single highest-specificity nutrition record
485
+ *
486
+ * // 50 at a time
487
+ * const target = { productId: 'prod_abc' }
488
+ * let page = await app.records.match(collectionId, appId, { target, limit: 50 })
489
+ * while (page.nextCursor) {
490
+ * page = await app.records.match(collectionId, appId, { target, limit: 50, cursor: page.nextCursor })
491
+ * }
463
492
  * ```
464
493
  */
465
494
  async function match(collectionId, appId, input, admin = false) {
@@ -509,19 +538,27 @@ export var app;
509
538
  * Resolve every applicable record for a product context in one call.
510
539
  * Returns `{ items, nextCursor, count, context, truncated }`: `items` are the records across all
511
540
  * tiers (proof, batch, variant, product, rule, facet, collection), deduplicated and sorted by
512
- * specificity descending, each as `{ record, matchedAt, specificity }`. It is not paged
513
- * (`nextCursor` is always `null`); `truncated` says the answer was cut at `limit`.
541
+ * specificity descending, each as `{ record, matchedAt, specificity }`. Without a `limit` it answers
542
+ * up to 500. Give a `limit` (in `input`) to page: when there are more, pass `nextCursor` back as
543
+ * `cursor`.
514
544
  * POST /records/resolve-all
515
545
  *
516
546
  * @param admin - false for public (visibility-filtered, active-only), true for admin (all statuses)
517
547
  *
518
548
  * @example
519
549
  * ```ts
520
- * const { items, truncated } = await app.records.resolveAll(collectionId, appId, {
550
+ * const { items } = await app.records.resolveAll(collectionId, appId, {
521
551
  * context: { productId: 'prod_abc' },
522
552
  * recordType: 'nutrition',
523
553
  * })
524
554
  * for (const { record, matchedAt } of items) console.log(matchedAt, record.data)
555
+ *
556
+ * // 100 at a time
557
+ * const context = { productId: 'prod_abc' }
558
+ * let page = await app.records.resolveAll(collectionId, appId, { context, limit: 100 })
559
+ * while (page.nextCursor) {
560
+ * page = await app.records.resolveAll(collectionId, appId, { context, limit: 100, cursor: page.nextCursor })
561
+ * }
525
562
  * ```
526
563
  */
527
564
  async function resolveAll(collectionId, appId, input, admin = false) {
@@ -543,33 +580,31 @@ export var app;
543
580
  })(app || (app = {})); // end namespace app
544
581
  // ==================== HELPERS ====================
545
582
  /**
546
- * Build a query string from an object of parameters
583
+ * The query string of a cases / threads / records list, in the order the options were given. Paging and
584
+ * the standard words (`q`, `orderBy`, a date range) go through `listQuery`. Two filters keep their own
585
+ * spelling: `parentIds` is sent comma-joined, and `dataFilter` as `dataFilter[key]=value` (repeated for
586
+ * an array of values).
547
587
  */
548
- function buildQueryString(params) {
588
+ function appListQuery(params) {
589
+ if (!params)
590
+ return '';
549
591
  const parts = [];
550
- const add = (key, value) => {
551
- if (value === undefined || value === null)
552
- return;
553
- parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
554
- };
555
592
  for (const [key, value] of Object.entries(params)) {
556
593
  if (value === undefined || value === null)
557
594
  continue;
558
- if (Array.isArray(value)) {
559
- add(key, value.join(',')); // unchanged: top-level arrays are sent comma-joined
560
- }
561
- else if (typeof value === 'object' && !(value instanceof Date)) {
562
- // Nested filter objects (e.g. dataFilter: { versionId: 'x', zone: 'in:a,b' }) → dataFilter[versionId]=x
595
+ if (key === 'dataFilter' && typeof value === 'object' && !Array.isArray(value)) {
563
596
  for (const [sub, subValue] of Object.entries(value)) {
564
- if (Array.isArray(subValue))
565
- subValue.forEach((v) => add(`${key}[${sub}]`, v));
566
- else
567
- add(`${key}[${sub}]`, subValue);
597
+ for (const v of Array.isArray(subValue) ? subValue : [subValue]) {
598
+ if (v === undefined || v === null)
599
+ continue;
600
+ parts.push(`${encodeURIComponent(`${key}[${sub}]`)}=${encodeURIComponent(String(v))}`);
601
+ }
568
602
  }
603
+ continue;
569
604
  }
570
- else {
571
- add(key, value instanceof Date ? value.toISOString() : value);
572
- }
605
+ const one = listQuery({ [key]: key === 'parentIds' && Array.isArray(value) ? value.join(',') : value });
606
+ if (one)
607
+ parts.push(one.slice(1));
573
608
  }
574
609
  return parts.length ? `?${parts.join('&')}` : '';
575
610
  }
@@ -1,4 +1,4 @@
1
- import type { ListResult } from "../types/list.js";
1
+ import type { ListResult, ListOptions } from "../types/list.js";
2
2
  import { Asset, AssetResponse, UploadAssetOptions, UploadFromUrlOptions, ListAssetsOptions, GetAssetOptions, RemoveAssetOptions, AdminListAssetsOptions, UpdateAssetOptions, ReplaceAssetFileOptions, DeleteAssetOptions, BulkDeleteAssetsOptions, RequestUploadTokenOptions, UploadTokenResponse, PublicTokenUploadOptions, CreateResumableUploadOptions, ResumableUploadHandle } from "../types/asset.js";
3
3
  export declare namespace asset {
4
4
  /**
@@ -45,47 +45,52 @@ export declare namespace asset {
45
45
  function uploadFromUrl(options: UploadFromUrlOptions): Promise<Asset>;
46
46
  function getForCollection(collectionId: string, assetId: string): Promise<AssetResponse>;
47
47
  /**
48
- * The collection's own assets (public). Returns `{ items, nextCursor }`: the assets are in `items`.
49
- * The list is not paged, so `nextCursor` is always `null`.
48
+ * The collection's own assets (public). Returns `{ items, nextCursor, count }`: the assets are in
49
+ * `items`, 50 at a time unless you give a `limit` (at most 1000). Pass `nextCursor` back as `cursor`
50
+ * for the next page; `null` means that was the last one.
50
51
  *
51
52
  * @example
52
53
  * ```typescript
53
- * const { items } = await asset.listForCollection('my-collection')
54
+ * let page = await asset.listForCollection('my-collection', { limit: 100 })
55
+ * while (page.nextCursor) page = await asset.listForCollection('my-collection', { limit: 100, cursor: page.nextCursor })
54
56
  * ```
55
57
  */
56
- function listForCollection(collectionId: string): Promise<ListResult<AssetResponse>>;
58
+ function listForCollection(collectionId: string, options?: ListOptions): Promise<ListResult<AssetResponse>>;
57
59
  function getForProduct(collectionId: string, productId: string, assetId: string): Promise<AssetResponse>;
58
60
  /**
59
- * A product's assets (public). Returns `{ items, nextCursor }`: the assets are in `items`.
60
- * The list is not paged, so `nextCursor` is always `null`.
61
+ * A product's assets (public). Returns `{ items, nextCursor, count }`: the assets are in `items`,
62
+ * 50 at a time unless you give a `limit` (at most 1000). Pass `nextCursor` back as `cursor` for the
63
+ * next page; `null` means that was the last one.
61
64
  *
62
65
  * @example
63
66
  * ```typescript
64
- * const { items } = await asset.listForProduct('my-collection', 'wine-bottle')
67
+ * const { items, nextCursor } = await asset.listForProduct('my-collection', 'wine-bottle', { limit: 100 })
65
68
  * ```
66
69
  */
67
- function listForProduct(collectionId: string, productId: string): Promise<ListResult<AssetResponse>>;
70
+ function listForProduct(collectionId: string, productId: string, options?: ListOptions): Promise<ListResult<AssetResponse>>;
68
71
  function getForProof(collectionId: string, productId: string, proofId: string, assetId: string): Promise<AssetResponse>;
69
72
  /**
70
- * A proof's assets (public), optionally only one app's. Returns `{ items, nextCursor }`: the assets
71
- * are in `items`. The list is not paged, so `nextCursor` is always `null`.
73
+ * A proof's assets (public), optionally only one app's. Returns `{ items, nextCursor, count }`: the
74
+ * assets are in `items`, 50 at a time unless you give a `limit` (at most 1000). Pass `nextCursor`
75
+ * back as `cursor` for the next page; `null` means that was the last one.
72
76
  *
73
77
  * @example
74
78
  * ```typescript
75
- * const { items } = await asset.listForProof('my-collection', 'wine-bottle', proofId, 'gallery')
79
+ * const { items, nextCursor } = await asset.listForProof('my-collection', 'wine-bottle', proofId, 'gallery', { limit: 100 })
76
80
  * ```
77
81
  */
78
- function listForProof(collectionId: string, productId: string, proofId: string, appId?: string): Promise<ListResult<AssetResponse>>;
82
+ function listForProof(collectionId: string, productId: string, proofId: string, appId?: string, options?: ListOptions): Promise<ListResult<AssetResponse>>;
79
83
  /**
80
- * List assets for a given scope (a collection, a product or a proof). Returns `{ items, nextCursor }`:
81
- * the assets are in `items`. These lists are not paged, so `nextCursor` is always `null`.
84
+ * List assets for a given scope (a collection, a product or a proof). Returns
85
+ * `{ items, nextCursor, count }`: the assets are in `items`, 50 at a time unless you give a `limit`
86
+ * (at most 1000). Pass `nextCursor` back as `cursor` for the next page; `null` means that was the
87
+ * last one.
82
88
  *
83
89
  * @example
84
90
  * ```typescript
85
- * const { items } = await asset.list({
86
- * scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' },
87
- * appId: 'gallery',
88
- * })
91
+ * const scope = { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' } as const
92
+ * let page = await asset.list({ scope, appId: 'gallery', limit: 100 })
93
+ * while (page.nextCursor) page = await asset.list({ scope, appId: 'gallery', limit: 100, cursor: page.nextCursor })
89
94
  * ```
90
95
  */
91
96
  function list(options: ListAssetsOptions): Promise<ListResult<Asset>>;
@@ -101,14 +106,15 @@ export declare namespace asset {
101
106
  * List assets for a collection with full filtering options (admin). Returns `{ items, nextCursor }`:
102
107
  * the assets are in `items`, 50 at a time unless you give a `limit` (at most 200). Pass `nextCursor`
103
108
  * back as `cursor` for the next page; `null` means that was the last one. `count` (how many match in
104
- * all) is there when you gave a `limit` or a `cursor`.
109
+ * all) is there when you gave a `limit` or a `cursor`. Sort with `orderBy` (`createdAt`, `name`,
110
+ * `size` or `assetType`).
105
111
  *
106
112
  * @example
107
113
  * ```typescript
108
- * let page = await asset.listAdmin({ collectionId: 'my-collection', assetType: 'Image', limit: 20 })
114
+ * let page = await asset.listAdmin({ collectionId: 'my-collection', assetType: 'Image', orderBy: [{ name: 'asc' }], limit: 20 })
109
115
  * console.log(`${page.count} images`)
110
116
  * while (page.nextCursor) {
111
- * page = await asset.listAdmin({ collectionId: 'my-collection', assetType: 'Image', limit: 20, cursor: page.nextCursor })
117
+ * page = await asset.listAdmin({ collectionId: 'my-collection', assetType: 'Image', orderBy: [{ name: 'asc' }], limit: 20, cursor: page.nextCursor })
112
118
  * }
113
119
  * ```
114
120
  */
package/dist/api/asset.js CHANGED
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { request, post, put, del, getApiHeaders, getBaseURL, isProxyEnabled, proxyUploadFormData } from "../http.js";
13
13
  import { SmartlinksApiError } from "../types/error.js";
14
+ import { listQuery } from "../list.js";
14
15
  export var asset;
15
16
  (function (asset) {
16
17
  function resolveApiUrl(path) {
@@ -209,16 +210,18 @@ export var asset;
209
210
  }
210
211
  asset.getForCollection = getForCollection;
211
212
  /**
212
- * The collection's own assets (public). Returns `{ items, nextCursor }`: the assets are in `items`.
213
- * The list is not paged, so `nextCursor` is always `null`.
213
+ * The collection's own assets (public). Returns `{ items, nextCursor, count }`: the assets are in
214
+ * `items`, 50 at a time unless you give a `limit` (at most 1000). Pass `nextCursor` back as `cursor`
215
+ * for the next page; `null` means that was the last one.
214
216
  *
215
217
  * @example
216
218
  * ```typescript
217
- * const { items } = await asset.listForCollection('my-collection')
219
+ * let page = await asset.listForCollection('my-collection', { limit: 100 })
220
+ * while (page.nextCursor) page = await asset.listForCollection('my-collection', { limit: 100, cursor: page.nextCursor })
218
221
  * ```
219
222
  */
220
- async function listForCollection(collectionId) {
221
- const path = `/public/collection/${encodeURIComponent(collectionId)}/asset`;
223
+ async function listForCollection(collectionId, options = {}) {
224
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/asset${listQuery({ limit: options.limit, cursor: options.cursor })}`;
222
225
  return request(path);
223
226
  }
224
227
  asset.listForCollection = listForCollection;
@@ -229,16 +232,17 @@ export var asset;
229
232
  }
230
233
  asset.getForProduct = getForProduct;
231
234
  /**
232
- * A product's assets (public). Returns `{ items, nextCursor }`: the assets are in `items`.
233
- * The list is not paged, so `nextCursor` is always `null`.
235
+ * A product's assets (public). Returns `{ items, nextCursor, count }`: the assets are in `items`,
236
+ * 50 at a time unless you give a `limit` (at most 1000). Pass `nextCursor` back as `cursor` for the
237
+ * next page; `null` means that was the last one.
234
238
  *
235
239
  * @example
236
240
  * ```typescript
237
- * const { items } = await asset.listForProduct('my-collection', 'wine-bottle')
241
+ * const { items, nextCursor } = await asset.listForProduct('my-collection', 'wine-bottle', { limit: 100 })
238
242
  * ```
239
243
  */
240
- async function listForProduct(collectionId, productId) {
241
- const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/asset`;
244
+ async function listForProduct(collectionId, productId, options = {}) {
245
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/asset${listQuery({ limit: options.limit, cursor: options.cursor })}`;
242
246
  return request(path);
243
247
  }
244
248
  asset.listForProduct = listForProduct;
@@ -249,42 +253,36 @@ export var asset;
249
253
  }
250
254
  asset.getForProof = getForProof;
251
255
  /**
252
- * A proof's assets (public), optionally only one app's. Returns `{ items, nextCursor }`: the assets
253
- * are in `items`. The list is not paged, so `nextCursor` is always `null`.
256
+ * A proof's assets (public), optionally only one app's. Returns `{ items, nextCursor, count }`: the
257
+ * assets are in `items`, 50 at a time unless you give a `limit` (at most 1000). Pass `nextCursor`
258
+ * back as `cursor` for the next page; `null` means that was the last one.
254
259
  *
255
260
  * @example
256
261
  * ```typescript
257
- * const { items } = await asset.listForProof('my-collection', 'wine-bottle', proofId, 'gallery')
262
+ * const { items, nextCursor } = await asset.listForProof('my-collection', 'wine-bottle', proofId, 'gallery', { limit: 100 })
258
263
  * ```
259
264
  */
260
- async function listForProof(collectionId, productId, proofId, appId) {
261
- let path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/asset`;
262
- if (appId) {
263
- path += `?appId=${encodeURIComponent(appId)}`;
264
- }
265
+ async function listForProof(collectionId, productId, proofId, appId, options = {}) {
266
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/asset${listQuery({ appId, limit: options.limit, cursor: options.cursor })}`;
265
267
  return request(path);
266
268
  }
267
269
  asset.listForProof = listForProof;
268
270
  /**
269
- * List assets for a given scope (a collection, a product or a proof). Returns `{ items, nextCursor }`:
270
- * the assets are in `items`. These lists are not paged, so `nextCursor` is always `null`.
271
+ * List assets for a given scope (a collection, a product or a proof). Returns
272
+ * `{ items, nextCursor, count }`: the assets are in `items`, 50 at a time unless you give a `limit`
273
+ * (at most 1000). Pass `nextCursor` back as `cursor` for the next page; `null` means that was the
274
+ * last one.
271
275
  *
272
276
  * @example
273
277
  * ```typescript
274
- * const { items } = await asset.list({
275
- * scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' },
276
- * appId: 'gallery',
277
- * })
278
+ * const scope = { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' } as const
279
+ * let page = await asset.list({ scope, appId: 'gallery', limit: 100 })
280
+ * while (page.nextCursor) page = await asset.list({ scope, appId: 'gallery', limit: 100, cursor: page.nextCursor })
278
281
  * ```
279
282
  */
280
283
  async function list(options) {
281
284
  const base = buildScopeBase(options.scope);
282
- const params = new URLSearchParams();
283
- if (options.appId)
284
- params.set('appId', options.appId);
285
- if (typeof options.limit === 'number')
286
- params.set('limit', String(options.limit));
287
- const path = `${base}/asset${params.toString() ? `?${params}` : ''}`;
285
+ const path = `${base}/asset${listQuery({ appId: options.appId, limit: options.limit, cursor: options.cursor })}`;
288
286
  return request(path);
289
287
  }
290
288
  asset.list = list;
@@ -323,41 +321,32 @@ export var asset;
323
321
  * List assets for a collection with full filtering options (admin). Returns `{ items, nextCursor }`:
324
322
  * the assets are in `items`, 50 at a time unless you give a `limit` (at most 200). Pass `nextCursor`
325
323
  * back as `cursor` for the next page; `null` means that was the last one. `count` (how many match in
326
- * all) is there when you gave a `limit` or a `cursor`.
324
+ * all) is there when you gave a `limit` or a `cursor`. Sort with `orderBy` (`createdAt`, `name`,
325
+ * `size` or `assetType`).
327
326
  *
328
327
  * @example
329
328
  * ```typescript
330
- * let page = await asset.listAdmin({ collectionId: 'my-collection', assetType: 'Image', limit: 20 })
329
+ * let page = await asset.listAdmin({ collectionId: 'my-collection', assetType: 'Image', orderBy: [{ name: 'asc' }], limit: 20 })
331
330
  * console.log(`${page.count} images`)
332
331
  * while (page.nextCursor) {
333
- * page = await asset.listAdmin({ collectionId: 'my-collection', assetType: 'Image', limit: 20, cursor: page.nextCursor })
332
+ * page = await asset.listAdmin({ collectionId: 'my-collection', assetType: 'Image', orderBy: [{ name: 'asc' }], limit: 20, cursor: page.nextCursor })
334
333
  * }
335
334
  * ```
336
335
  */
337
336
  async function listAdmin(options) {
338
- const params = new URLSearchParams();
339
- if (options.productId)
340
- params.set('productId', options.productId);
341
- if (options.proofId)
342
- params.set('proofId', options.proofId);
343
- if (options.appId)
344
- params.set('appId', options.appId);
345
- if (options.assetType)
346
- params.set('assetType', options.assetType);
347
- if (options.labels)
348
- params.set('labels', options.labels);
349
- if (options.sort)
350
- params.set('sort', options.sort);
351
- if (options.order)
352
- params.set('order', options.order);
353
- if (typeof options.limit === 'number')
354
- params.set('limit', String(options.limit));
355
- if (options.cursor)
356
- params.set('cursor', options.cursor);
357
- if (options.include && options.include.length)
358
- params.set('include', options.include.join(','));
359
- const qs = params.toString();
360
- const path = `/admin/collection/${encodeURIComponent(options.collectionId)}/asset${qs ? `?${qs}` : ''}`;
337
+ const qs = listQuery({
338
+ productId: options.productId,
339
+ proofId: options.proofId,
340
+ appId: options.appId,
341
+ assetType: options.assetType,
342
+ labels: options.labels,
343
+ orderBy: options.orderBy,
344
+ limit: options.limit,
345
+ cursor: options.cursor,
346
+ // not a list word here: sent comma-joined, as the route reads it
347
+ include: options.include && options.include.length ? options.include.join(',') : undefined,
348
+ });
349
+ const path = `/admin/collection/${encodeURIComponent(options.collectionId)}/asset${qs}`;
361
350
  return request(path);
362
351
  }
363
352
  asset.listAdmin = listAdmin;
@@ -1,5 +1,5 @@
1
1
  import type { AttestationResponse, AttestationCreateRequest, AttestationUpdateRequest } from "../types/attestation.js";
2
- import type { ListResult } from "../types/list.js";
2
+ import type { ListResult, ListOptions } from "../types/list.js";
3
3
  /**
4
4
  * @deprecated Legacy Firestore-backed attestation API.
5
5
  *
@@ -17,10 +17,18 @@ import type { ListResult } from "../types/list.js";
17
17
  */
18
18
  export declare namespace attestation {
19
19
  /**
20
- * List all attestations for a proof, in one list (no pages): `{ items, nextCursor: null }`.
20
+ * List the attestations for a proof: `{ items, nextCursor, count }`, 50 at a time unless you give a
21
+ * `limit` (at most 1000). Pass `nextCursor` back as `cursor` for the next page; `null` means that
22
+ * was the last one.
21
23
  * @deprecated Use `attestations.list()` with `subjectType='proof'` instead.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * let page = await attestation.list('coll_123', 'prod_abc', 'proof_1', { limit: 100 })
28
+ * while (page.nextCursor) page = await attestation.list('coll_123', 'prod_abc', 'proof_1', { limit: 100, cursor: page.nextCursor })
29
+ * ```
22
30
  */
23
- function list(collectionId: string, productId: string, proofId: string): Promise<ListResult<AttestationResponse>>;
31
+ function list(collectionId: string, productId: string, proofId: string, options?: ListOptions): Promise<ListResult<AttestationResponse>>;
24
32
  /**
25
33
  * Get a single attestation by ID.
26
34
  * @deprecated Use `attestations.list()` with `subjectType='proof'` and filter by ID instead.
@@ -1,4 +1,5 @@
1
1
  import { request, post, put, del } from "../http.js";
2
+ import { listQuery } from "../list.js";
2
3
  /**
3
4
  * @deprecated Legacy Firestore-backed attestation API.
4
5
  *
@@ -17,11 +18,19 @@ import { request, post, put, del } from "../http.js";
17
18
  export var attestation;
18
19
  (function (attestation) {
19
20
  /**
20
- * List all attestations for a proof, in one list (no pages): `{ items, nextCursor: null }`.
21
+ * List the attestations for a proof: `{ items, nextCursor, count }`, 50 at a time unless you give a
22
+ * `limit` (at most 1000). Pass `nextCursor` back as `cursor` for the next page; `null` means that
23
+ * was the last one.
21
24
  * @deprecated Use `attestations.list()` with `subjectType='proof'` instead.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * let page = await attestation.list('coll_123', 'prod_abc', 'proof_1', { limit: 100 })
29
+ * while (page.nextCursor) page = await attestation.list('coll_123', 'prod_abc', 'proof_1', { limit: 100, cursor: page.nextCursor })
30
+ * ```
22
31
  */
23
- async function list(collectionId, productId, proofId) {
24
- const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation`;
32
+ async function list(collectionId, productId, proofId, options = {}) {
33
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation${listQuery({ limit: options.limit, cursor: options.cursor })}`;
25
34
  return request(path);
26
35
  }
27
36
  attestation.list = list;
@@ -67,7 +67,8 @@ export declare namespace attestations {
67
67
  /**
68
68
  * List attestations for a subject (admin).
69
69
  *
70
- * Returns all three data zones. Supports filtering by type and date range.
70
+ * Returns all three data zones. Supports filtering by type and by when it was recorded
71
+ * (`recordedAt: { gte, lte }`).
71
72
  *
72
73
  * @param collectionId - Collection context
73
74
  * @param params - Query parameters; `subjectType` and `subjectId` are required. Page with
@@ -76,13 +77,13 @@ export declare namespace attestations {
76
77
  *
77
78
  * @example
78
79
  * ```typescript
79
- * let page = await attestations.list('coll_123', {
80
+ * const filters = {
80
81
  * subjectType: 'container',
81
82
  * subjectId: 'uuid-of-cask',
82
83
  * attestationType: 'temperature',
83
- * recordedAfter: '2025-01-01T00:00:00Z',
84
- * limit: 50,
85
- * })
84
+ * recordedAt: { gte: '2025-01-01T00:00:00Z' },
85
+ * } as const
86
+ * let page = await attestations.list('coll_123', { ...filters, limit: 50 })
86
87
  * const records = page.items
87
88
  * // next page: pass the cursor back with the same filters
88
89
  * if (page.nextCursor) page = await attestations.list('coll_123', { ...filters, limit: 50, cursor: page.nextCursor })
@@ -108,7 +109,7 @@ export declare namespace attestations {
108
109
  * attestationType: 'temperature',
109
110
  * valueField: 'celsius',
110
111
  * groupBy: 'day',
111
- * recordedAfter: '2025-01-01T00:00:00Z',
112
+ * recordedAt: { gte: '2025-01-01T00:00:00Z' },
112
113
  * })
113
114
  * ```
114
115
  */
@@ -205,7 +206,7 @@ export declare namespace attestations {
205
206
  *
206
207
  * @param collectionId - Collection context
207
208
  * @param params - Query parameters; `subjectType` and `subjectId` are required. Page with
208
- * `limit` and `cursor`
209
+ * `limit` and `cursor`; filter by when it was recorded with `recordedAt: { gte, lte }`
209
210
  * @returns `{ items: Attestation[], nextCursor, audience: AttestationAudience }` — `nextCursor` is
210
211
  * `null` on the last page
211
212
  *
@@ -214,6 +215,8 @@ export declare namespace attestations {
214
215
  * const { items: records, nextCursor, audience } = await attestations.publicList('coll_123', {
215
216
  * subjectType: 'proof',
216
217
  * subjectId: 'proof-uuid',
218
+ * recordedAt: { gte: '2025-01-01T00:00:00Z', lte: '2025-12-31T23:59:59Z' },
219
+ * limit: 50,
217
220
  * })
218
221
  * ```
219
222
  */
@@ -310,13 +313,14 @@ export declare namespace attestations {
310
313
  *
311
314
  * @param collectionId - Collection context
312
315
  * @param containerId - Container UUID
313
- * @param params - Optional filters (attestationType, date range) and paging (`limit`, `cursor`)
316
+ * @param params - Optional filters (`attestationType`, `recordedAt: { gte, lte }`) and paging (`limit`, `cursor`)
314
317
  * @returns `{ items: Attestation[], nextCursor, audience }` — `nextCursor` is `null` on the last page
315
318
  *
316
319
  * @example
317
320
  * ```typescript
318
321
  * const { items: records, nextCursor } = await attestations.publicContainerList('coll_123', containerId, {
319
322
  * attestationType: 'temperature',
323
+ * recordedAt: { gte: '2025-01-01T00:00:00Z' },
320
324
  * limit: 50,
321
325
  * })
322
326
  * ```