@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.
- package/README.md +7 -7
- 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 +18 -9
- package/dist/api/bookings.js +23 -13
- 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 +0 -1
- package/dist/api/index.js +0 -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/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/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/docs/API_SUMMARY.md +289 -483
- package/dist/docs/ai.md +15 -15
- package/dist/docs/analytics.md +1 -1
- package/dist/docs/app-objects.md +4 -4
- package/dist/docs/attestations.md +8 -8
- package/dist/docs/contact-search.md +2 -3
- package/dist/docs/knowledge.md +3 -3
- package/dist/docs/lists.md +58 -15
- package/dist/docs/upgrading-to-3.md +238 -136
- package/dist/list.d.ts +12 -0
- package/dist/list.js +59 -0
- package/dist/openapi.yaml +301 -662
- package/dist/types/analytics.d.ts +7 -3
- 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 +10 -5
- 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/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/product.d.ts +28 -11
- package/dist/types/proof.d.ts +7 -8
- 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 +289 -483
- package/docs/ai.md +15 -15
- package/docs/analytics.md +1 -1
- package/docs/app-objects.md +4 -4
- package/docs/attestations.md +8 -8
- package/docs/contact-search.md +2 -3
- package/docs/knowledge.md +3 -3
- package/docs/lists.md +58 -15
- package/docs/upgrading-to-3.md +238 -136
- package/openapi.yaml +301 -662
- package/package.json +1 -1
- package/scripts/lib/upgrade.mjs +216 -60
- package/scripts/upgrade.mjs +33 -10
- package/upgrade/3.json +2731 -2213
package/dist/docs/ai.md
CHANGED
|
@@ -104,9 +104,9 @@ import { initializeApi, knowledge } from '@proveanything/smartlinks';
|
|
|
104
104
|
initializeApi({ baseURL: 'https://smartlinks.app/api/v1' });
|
|
105
105
|
|
|
106
106
|
const { items: results } = await knowledge.publicSearch('my-collection', {
|
|
107
|
-
|
|
107
|
+
q: 'How do I descale this machine?',
|
|
108
108
|
filters: { productId: 'coffee-maker-deluxe' },
|
|
109
|
-
|
|
109
|
+
limit: 3
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
for (const r of results) {
|
|
@@ -156,7 +156,7 @@ Public endpoints don't require an API key. Anonymous callers see public content
|
|
|
156
156
|
```typescript
|
|
157
157
|
// No API key needed
|
|
158
158
|
const { items: results } = await knowledge.publicSearch('my-collection', {
|
|
159
|
-
|
|
159
|
+
q: 'How do I clean this?'
|
|
160
160
|
});
|
|
161
161
|
```
|
|
162
162
|
|
|
@@ -723,10 +723,10 @@ const { items: sources } = await knowledge.listSources('my-collection', 'manuals
|
|
|
723
723
|
|
|
724
724
|
```typescript
|
|
725
725
|
const { items: results, mode } = await knowledge.publicSearch('my-collection', {
|
|
726
|
-
|
|
726
|
+
q: 'How do I descale my coffee maker?',
|
|
727
727
|
sets: ['manuals'], // optional: ids or keys
|
|
728
728
|
filters: { productId: 'coffee-maker-deluxe' }, // optional: exact matches on a document's meta
|
|
729
|
-
|
|
729
|
+
limit: 5 // optional: default 8, at most 25 at a time
|
|
730
730
|
});
|
|
731
731
|
|
|
732
732
|
for (const r of results) {
|
|
@@ -737,7 +737,7 @@ for (const r of results) {
|
|
|
737
737
|
}
|
|
738
738
|
```
|
|
739
739
|
|
|
740
|
-
`mode` says how the search ran: `hybrid` (meaning and keywords), `keywords`, or `none` (there were no sets to search). Admins can search every set, staff ones included, with `knowledge.search(collectionId, {
|
|
740
|
+
`mode` says how the search ran: `hybrid` (meaning and keywords), `keywords`, or `none` (there were no sets to search). Admins can search every set, staff ones included, with `knowledge.search(collectionId, { q })`. Both searches return their matches as `items`, with `query` (what was searched for) and `mode` beside them.
|
|
741
741
|
|
|
742
742
|
### AI-written answers (admin agent with `knowledge.search`)
|
|
743
743
|
|
|
@@ -802,9 +802,9 @@ if (ai.voice.isSupported()) {
|
|
|
802
802
|
|
|
803
803
|
// Find the best passage in the manuals
|
|
804
804
|
const { items: results } = await knowledge.publicSearch('my-collection', {
|
|
805
|
-
|
|
805
|
+
q: question,
|
|
806
806
|
filters: { productId: 'coffee-maker-deluxe' },
|
|
807
|
-
|
|
807
|
+
limit: 1
|
|
808
808
|
});
|
|
809
809
|
|
|
810
810
|
// Speak it
|
|
@@ -827,9 +827,9 @@ class ProductVoiceAssistant {
|
|
|
827
827
|
|
|
828
828
|
// Find the best passage
|
|
829
829
|
const { items: results } = await knowledge.publicSearch(this.collectionId, {
|
|
830
|
-
|
|
830
|
+
q: question,
|
|
831
831
|
filters: { productId: this.productId },
|
|
832
|
-
|
|
832
|
+
limit: 1
|
|
833
833
|
});
|
|
834
834
|
const answer = results[0]?.text ?? "Sorry, I couldn't find that in the manual.";
|
|
835
835
|
|
|
@@ -1017,9 +1017,9 @@ Fill the basket, tamp firmly, press the espresso button...',
|
|
|
1017
1017
|
// Website, any time: show the matching sections
|
|
1018
1018
|
async function answerQuestion(collectionId: string, question: string) {
|
|
1019
1019
|
const { items: results } = await knowledge.publicSearch(collectionId, {
|
|
1020
|
-
|
|
1020
|
+
q: question,
|
|
1021
1021
|
filters: { productId: 'coffee-maker-deluxe' },
|
|
1022
|
-
|
|
1022
|
+
limit: 3
|
|
1023
1023
|
});
|
|
1024
1024
|
return results.map(r => ({ title: r.heading ?? r.title, snippet: r.snippet, url: r.url }));
|
|
1025
1025
|
}
|
|
@@ -1089,7 +1089,7 @@ export function useProductHelp(collectionId: string, productId: string) {
|
|
|
1089
1089
|
setLoading(true);
|
|
1090
1090
|
setError(null);
|
|
1091
1091
|
try {
|
|
1092
|
-
const res = await knowledge.publicSearch(collectionId, { query, filters: { productId },
|
|
1092
|
+
const res = await knowledge.publicSearch(collectionId, { q: query, filters: { productId }, limit: 3 });
|
|
1093
1093
|
setResults(res.items);
|
|
1094
1094
|
} catch (err: any) {
|
|
1095
1095
|
setError(err.message);
|
|
@@ -1343,7 +1343,7 @@ async function voiceAssistant() {
|
|
|
1343
1343
|
const question = await ai.voice.listen();
|
|
1344
1344
|
|
|
1345
1345
|
showStatus('Searching...');
|
|
1346
|
-
const { items: results } = await knowledge.publicSearch('my-collection', {
|
|
1346
|
+
const { items: results } = await knowledge.publicSearch('my-collection', { q: question, limit: 1 });
|
|
1347
1347
|
const answer = results[0]?.text ?? "Sorry, I couldn't find that.";
|
|
1348
1348
|
|
|
1349
1349
|
showStatus('Speaking...');
|
|
@@ -1585,7 +1585,7 @@ For the `rag` strategy to find anything, the product's documents must be in a kn
|
|
|
1585
1585
|
|
|
1586
1586
|
```typescript
|
|
1587
1587
|
const { items: results } = await SL.knowledge.publicSearch(collectionId, {
|
|
1588
|
-
|
|
1588
|
+
q: userQuestion,
|
|
1589
1589
|
filters: { productId: ragHint.productId },
|
|
1590
1590
|
});
|
|
1591
1591
|
```
|
package/dist/docs/analytics.md
CHANGED
|
@@ -582,7 +582,7 @@ const page = await analytics.admin.events('demo-collection', {
|
|
|
582
582
|
from: '2026-03-01T00:00:00Z',
|
|
583
583
|
to: '2026-03-31T23:59:59Z',
|
|
584
584
|
limit: 100,
|
|
585
|
-
|
|
585
|
+
orderBy: [{ timestamp: 'desc' }],
|
|
586
586
|
})
|
|
587
587
|
// page.items → the event rows
|
|
588
588
|
// page.nextCursor → pass it back as `cursor` (with the same filters) for the next 100; null on the last page
|
package/dist/docs/app-objects.md
CHANGED
|
@@ -186,7 +186,7 @@ async function fetchAllRecords(collectionId: string, appId: string) {
|
|
|
186
186
|
const page: ListResult<AppRecord> = await app.records.list(
|
|
187
187
|
collectionId,
|
|
188
188
|
appId,
|
|
189
|
-
{ limit: 100, cursor,
|
|
189
|
+
{ limit: 100, cursor, orderBy: [{ createdAt: 'desc' }] }
|
|
190
190
|
);
|
|
191
191
|
|
|
192
192
|
results.push(...page.items);
|
|
@@ -376,7 +376,7 @@ List filters that pair with this (see `ThreadListQueryParams`):
|
|
|
376
376
|
const feed = await app.threads.list(collectionId, appId, {
|
|
377
377
|
parentType: 'memory',
|
|
378
378
|
parentIds: visibleMemoryIds,
|
|
379
|
-
|
|
379
|
+
orderBy: [{ createdAt: 'desc' }],
|
|
380
380
|
});
|
|
381
381
|
```
|
|
382
382
|
|
|
@@ -919,7 +919,7 @@ const activeRegistrations = await app.records.list(collectionId, appId, {
|
|
|
919
919
|
// Find expiring registrations (admin)
|
|
920
920
|
const expiringSoon = await app.records.list(collectionId, appId, {
|
|
921
921
|
recordType: 'product_registration',
|
|
922
|
-
expiresAt:
|
|
922
|
+
expiresAt: { lte: new Date(Date.now() + 30*24*60*60*1000) } // next 30 days
|
|
923
923
|
}, true);
|
|
924
924
|
```
|
|
925
925
|
|
|
@@ -1572,7 +1572,7 @@ const newCase: AppCase = await app.cases.create(collectionId, appId, {
|
|
|
1572
1572
|
const threadList: ListResult<AppThread> = await app.threads.list(
|
|
1573
1573
|
collectionId,
|
|
1574
1574
|
appId,
|
|
1575
|
-
{ limit: 50,
|
|
1575
|
+
{ limit: 50, orderBy: [{ createdAt: 'desc' }] }
|
|
1576
1576
|
);
|
|
1577
1577
|
```
|
|
1578
1578
|
|
|
@@ -242,7 +242,7 @@ const { items: records, nextCursor } = await attestations.list('coll_123', {
|
|
|
242
242
|
subjectType: 'container',
|
|
243
243
|
subjectId: 'cask-uuid',
|
|
244
244
|
attestationType: 'temperature',
|
|
245
|
-
|
|
245
|
+
recordedAt: { gte: '2025-01-01T00:00:00Z' },
|
|
246
246
|
limit: 50,
|
|
247
247
|
})
|
|
248
248
|
// nextCursor is null on the last page; otherwise pass it back as `cursor` for the next 50
|
|
@@ -436,8 +436,8 @@ GET /api/v1/admin/collection/:collectionId/attestations/tree-latest
|
|
|
436
436
|
| `subjectType` | ✅ | Subject type |
|
|
437
437
|
| `subjectId` | ✅ | Subject UUID |
|
|
438
438
|
| `attestationType` | — | Filter by type |
|
|
439
|
-
| `
|
|
440
|
-
| `
|
|
439
|
+
| `recordedAt[gte]` | — | Recorded on or after this date and time (ISO 8601). In the SDK: `recordedAt: { gte }` |
|
|
440
|
+
| `recordedAt[lte]` | — | Recorded on or before this date and time. In the SDK: `recordedAt: { lte }` |
|
|
441
441
|
| `limit` | — | Default `100` |
|
|
442
442
|
| `cursor` | — | The previous page's `nextCursor` |
|
|
443
443
|
|
|
@@ -450,8 +450,8 @@ GET /api/v1/admin/collection/:collectionId/attestations/tree-latest
|
|
|
450
450
|
| `attestationType` | ✅ | |
|
|
451
451
|
| `valueField` | — | Dot-path inside `value` to aggregate |
|
|
452
452
|
| `groupBy` | — | `hour` \| `day` \| `week` \| `month` (default `day`) |
|
|
453
|
-
| `
|
|
454
|
-
| `
|
|
453
|
+
| `recordedAt[gte]` | — | ISO 8601 |
|
|
454
|
+
| `recordedAt[lte]` | — | ISO 8601 |
|
|
455
455
|
| `limit` | — | Max buckets (default `200`) |
|
|
456
456
|
|
|
457
457
|
#### GET query parameters (tree-summary / tree-latest)
|
|
@@ -463,8 +463,8 @@ GET /api/v1/admin/collection/:collectionId/attestations/tree-latest
|
|
|
463
463
|
| `attestationType` | ✅ (tree-summary) | |
|
|
464
464
|
| `valueField` | — | |
|
|
465
465
|
| `groupBy` | — | |
|
|
466
|
-
| `
|
|
467
|
-
| `
|
|
466
|
+
| `recordedAt[gte]` | — | |
|
|
467
|
+
| `recordedAt[lte]` | — | |
|
|
468
468
|
| `limit` | — | |
|
|
469
469
|
| `includeItems` | — | Include container items in BFS traversal (default `true`) |
|
|
470
470
|
|
|
@@ -520,7 +520,7 @@ const { summary } = await attestations.publicTreeSummary('coll_123', {
|
|
|
520
520
|
attestationType: 'temperature',
|
|
521
521
|
valueField: 'celsius',
|
|
522
522
|
groupBy: 'day',
|
|
523
|
-
|
|
523
|
+
recordedAt: { gte: sevenDaysAgo },
|
|
524
524
|
})
|
|
525
525
|
```
|
|
526
526
|
|
|
@@ -24,7 +24,7 @@ await contact.search({ collectionId, id: "uuid-here" })
|
|
|
24
24
|
await contact.search({
|
|
25
25
|
collectionId,
|
|
26
26
|
tags: ["vip"],
|
|
27
|
-
|
|
27
|
+
createdAt: { gte: "2026-01-01T00:00:00Z" },
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
// Find by external ID (e.g. Shopify customer ID)
|
|
@@ -72,8 +72,7 @@ All filters are ANDed with each other and with any text search.
|
|
|
72
72
|
| `tagsAll` | `string \| string[]` | Contacts must have **all** of these tags. |
|
|
73
73
|
| `source` | `string` | Exact match on the `source` field. |
|
|
74
74
|
| `locale` | `string` | Exact match on the `locale` field (e.g. `"en-US"`). |
|
|
75
|
-
| `
|
|
76
|
-
| `createdTo` | `string` (ISO-8601) | Upper bound on `created_at`. |
|
|
75
|
+
| `createdAt` | `{ gte?, lte? }` (ISO-8601 or `Date`) | When the contact was created: on or after `gte`, on or before `lte`. |
|
|
77
76
|
|
|
78
77
|
### JSONB field filters
|
|
79
78
|
|
package/dist/docs/knowledge.md
CHANGED
|
@@ -58,14 +58,14 @@ failed re-read keeps the previous passages searchable. `knowledge.reindex` reads
|
|
|
58
58
|
```typescript
|
|
59
59
|
// From a website, Portal or Hub: public sets, plus customer sets for a signed-in person
|
|
60
60
|
const { items } = await knowledge.publicSearch('coll_123', {
|
|
61
|
-
|
|
61
|
+
q: 'how do I descale',
|
|
62
62
|
filters: { productId: 'prod_k200' }, // exact matches on a document's meta
|
|
63
|
-
|
|
63
|
+
limit: 5,
|
|
64
64
|
})
|
|
65
65
|
for (const r of items) console.log(r.title, r.heading, r.url, r.snippet)
|
|
66
66
|
|
|
67
67
|
// Staff: every set
|
|
68
|
-
const { items: staffMatches, mode } = await knowledge.search('coll_123', {
|
|
68
|
+
const { items: staffMatches, mode } = await knowledge.search('coll_123', { q: 'refund policy for damaged items' })
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
Both searches answer in the same shape: the matches in `items`, best first, with `query` and `mode` beside
|
package/dist/docs/lists.md
CHANGED
|
@@ -24,7 +24,8 @@ const { items, nextCursor } = await tags.list('coll_123', { limit: 100 })
|
|
|
24
24
|
|
|
25
25
|
## Paging
|
|
26
26
|
|
|
27
|
-
Two options, the same on every list
|
|
27
|
+
Two options, the same on every list: `limit` (how many) and `cursor` (where to carry on). A list returns
|
|
28
|
+
50 items unless you ask for another number, and each list has its own maximum.
|
|
28
29
|
|
|
29
30
|
```typescript
|
|
30
31
|
let cursor: string | undefined
|
|
@@ -37,8 +38,10 @@ do {
|
|
|
37
38
|
|
|
38
39
|
- A cursor is opaque. Don't build one, read one, or keep one for later: use the one the last page gave you.
|
|
39
40
|
- A cursor that isn't one the list gave out is refused with `400 INVALID_CURSOR`.
|
|
40
|
-
-
|
|
41
|
-
|
|
41
|
+
- **`items` is one page, not everything.** If you need them all, follow `nextCursor` or use `all` (below).
|
|
42
|
+
- The one exception is a small fixed set: a page's widgets, the facet definitions, config fields, the
|
|
43
|
+
connectors that exist. Those always come back whole. Their functions take no `limit` or `cursor`, and
|
|
44
|
+
`nextCursor` is always `null`.
|
|
42
45
|
|
|
43
46
|
### Walking every page
|
|
44
47
|
|
|
@@ -52,15 +55,18 @@ for await (const c of each((cursor) => contact.list('coll_123', { limit: 100, cu
|
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
const everyTag = await all((cursor) => tags.list('coll_123', { cursor }))
|
|
58
|
+
const variants = await all((cursor) => variant.list('coll_123', 'prod_1', { limit: 200, cursor }))
|
|
55
59
|
```
|
|
56
60
|
|
|
61
|
+
A bigger `limit` means fewer round trips when you want everything.
|
|
62
|
+
|
|
57
63
|
`all` stops at 10,000 items so a mistake can't fetch a whole database. Raise it on purpose when you mean
|
|
58
64
|
to: `all(page, { max: 50000 })`.
|
|
59
65
|
|
|
60
66
|
## `count`
|
|
61
67
|
|
|
62
|
-
`count` is the total number of items that match, not the number on this page.
|
|
63
|
-
|
|
68
|
+
`count` is the total number of items that match, not the number on this page. Most lists give it. It is
|
|
69
|
+
absent where counting would cost a scan, and on a list that only ever returns "the newest N".
|
|
64
70
|
|
|
65
71
|
```typescript
|
|
66
72
|
const { items, count } = await app.records.list('coll_123', 'my-app', { limit: 20 })
|
|
@@ -75,25 +81,57 @@ When you need a count and the list doesn't give one, use the [standard query](st
|
|
|
75
81
|
A few lists say more than the list, and those fields sit beside `items`:
|
|
76
82
|
|
|
77
83
|
```typescript
|
|
78
|
-
const { items, mode } = await knowledge.search('coll_123', {
|
|
84
|
+
const { items, mode } = await knowledge.search('coll_123', { q: 'how do I descale' })
|
|
79
85
|
const { items: pairs, scanned } = await contact.findDuplicates('coll_123')
|
|
80
86
|
```
|
|
81
87
|
|
|
82
88
|
Each function's return type names them.
|
|
83
89
|
|
|
84
|
-
##
|
|
90
|
+
## The same words on every list
|
|
85
91
|
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
Where a list can search, sort, filter by date or bring related things along, it uses the same option as
|
|
93
|
+
every other list that can. Each function's options say which of these it has.
|
|
88
94
|
|
|
95
|
+
| To | Option | Example |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| Search | `q` | `{ q: 'oak' }` |
|
|
98
|
+
| Sort | `orderBy` | `{ orderBy: [{ createdAt: 'desc' }, { name: 'asc' }] }` |
|
|
99
|
+
| Filter on a date field | the field, with `gte` and `lte` | `{ createdAt: { gte: '2026-11-01T00:00:00Z', lte: new Date() } }` |
|
|
100
|
+
| Give the time window of a log or a schedule | `from`, `to` | `{ from: '2026-11-01T00:00:00Z', to: '2026-12-01T00:00:00Z' }` |
|
|
101
|
+
| Bring related things along | `expand` | `{ expand: ['items'] }` |
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { app, contact, order } from '@proveanything/smartlinks'
|
|
105
|
+
|
|
106
|
+
const open = await app.cases.list('coll_123', 'support', {
|
|
107
|
+
status: 'open',
|
|
108
|
+
orderBy: [{ priority: 'desc' }, { createdAt: 'asc' }],
|
|
109
|
+
createdAt: { gte: '2026-11-01T00:00:00Z' },
|
|
110
|
+
})
|
|
111
|
+
const recent = await contact.search({ collectionId: 'coll_123', q: 'jo', createdAt: { gte: lastWeek } })
|
|
112
|
+
const withItems = await order.list('coll_123', { expand: ['items'] })
|
|
89
113
|
```
|
|
90
|
-
This list has no "serach" parameter. Did you mean "search"?
|
|
91
|
-
```
|
|
92
114
|
|
|
93
|
-
|
|
94
|
-
|
|
115
|
+
- **Dates** are a full date and time (ISO 8601) or a `Date`. A date with no time means midnight UTC at the
|
|
116
|
+
start of that day, so for "to the end of the 30th" give the 30th at 23:59:59, or the 1st with `from`/`to`.
|
|
117
|
+
- **`gte` and `lte` include the moment you give.**
|
|
118
|
+
- **`from` and `to`** belong to lists that are a log or a schedule (events, messages sent, jobs, bookings
|
|
119
|
+
and slots): one time window for the whole list, not a filter on a named field.
|
|
120
|
+
- **Sorting** is by the fields the list names. Asking for another is refused, with the ones it has.
|
|
121
|
+
|
|
122
|
+
## What a list can't do, it says
|
|
123
|
+
|
|
124
|
+
Nothing is silently ignored. A list answers `400` and says what it does take when you send:
|
|
95
125
|
|
|
96
|
-
|
|
126
|
+
- an option it doesn't read (`UNKNOWN_PARAMETER`, with the options that exist and the nearest match);
|
|
127
|
+
- the older spelling of one of the words above (`UNKNOWN_PARAMETER`: `This list has no "search" parameter. Use "q".`);
|
|
128
|
+
- a field it can't sort by, a related thing it doesn't know, or a value that isn't a date (`INVALID_PARAMETER`);
|
|
129
|
+
- `limit` or `cursor` on a fixed set (`UNKNOWN_PARAMETER`: `This list is always returned whole`);
|
|
130
|
+
- an admin-only option on a public list (for example `includeDeleted`).
|
|
131
|
+
|
|
132
|
+
So a mistyped filter is an error you see, not a filter that silently does nothing.
|
|
133
|
+
|
|
134
|
+
## Filtering, sorting and counting beyond that
|
|
97
135
|
|
|
98
136
|
Lists take the few filters each one always took. For anything richer (several conditions, sorting on any
|
|
99
137
|
field, counts, totals, following links to related records) use the [standard query](standard-query.md):
|
|
@@ -111,4 +149,9 @@ SmartLinks-Version: 2027-01
|
|
|
111
149
|
{ "items": [ … ], "nextCursor": "eyJvIjoyMDB9", "count": 1240 }
|
|
112
150
|
```
|
|
113
151
|
|
|
114
|
-
For a list that is a `POST` (a search or a query), `limit
|
|
152
|
+
For a list that is a `POST` (a search or a query), `limit`, `cursor` and the words above go at the top level
|
|
153
|
+
of the body. In an address the words are written like this:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
?q=oak&orderBy=createdAt:desc,name:asc&createdAt[gte]=2026-11-01T00:00:00Z&expand=items,facets
|
|
157
|
+
```
|