@proveanything/smartlinks 2.1.22 → 2.1.23

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.
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.1.22 | Generated: 2026-11-18T08:01:22.740Z
3
+ Version: 2.1.23 | Generated: 2026-11-19T11:28:05.726Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -9,6 +9,7 @@ This is a concise summary of all available API functions and types.
9
9
  For detailed guides on specific features:
10
10
 
11
11
  - **[SmartLinks Microapp Overview](overview.md)** - Platform architecture, data model, auth patterns, storage, anti-patterns, and quick-reference for all SDK docs
12
+ - **[The Standard Query](standard-query.md)** - One request body to filter, sort, page, count, total and follow links, the same on proofs, contacts, products and app records: `proof.query`, `contact.query`, `products.standardQuery`, `app.records.query`
12
13
  - **[Assets](assets.md)** - Asset object, AssetRef, upload, replace, soft-delete, restore, bulk-delete, and public token-based uploads
13
14
  - **[AI & Chat Completions](ai.md)** - Chat completions, RAG (document-grounded Q&A), voice integration, streaming, tool calling, podcast generation
14
15
  - **[Translations](translations.md)** - Runtime translation lookup, browser-side IndexedDB caching, and admin translation management
@@ -143,6 +144,7 @@ The Smartlinks SDK is organized into the following namespaces:
143
144
  - **attestation** - Functions for attestation operations
144
145
  - **attestations** - Functions for attestations operations
145
146
  - **bookings** - Functions for bookings operations
147
+ - **conditions** - Functions for conditions operations
146
148
  - **config** - Functions for config operations
147
149
  - **containers** - Functions for containers operations
148
150
  - **errors** - Functions for errors operations
@@ -538,7 +540,7 @@ interface AdminCardPayload {
538
540
  trend?: { direction: 'up' | 'down' | 'flat'; label?: string; good?: boolean }
539
541
  status?: { tone: 'ok' | 'attention' | 'neutral' | 'error'; text: string }
540
542
  progress?: { done: number; total: number; label?: string }
541
- items?: Array<{ title: string; subtitle?: string; meta?: string; path?: string }>
543
+ items?: Array<{ title: string; subtitle?: string; meta?: string; path?: string; image?: string }>
542
544
  todo?: Array<{ text: string; action?: AdminCardAction }>
543
545
  actions?: AdminCardAction[]
544
546
  empty?: { text: string; action?: AdminCardAction }
@@ -11364,6 +11366,72 @@ interface QrShortCodeLookupResponse {
11364
11366
  }
11365
11367
  ```
11366
11368
 
11369
+ ### query
11370
+
11371
+ **QueryFieldTest** (interface)
11372
+ ```typescript
11373
+ interface QueryFieldTest {
11374
+ eq?: QueryValue
11375
+ ne?: QueryValue
11376
+ gt?: QueryValue
11377
+ gte?: QueryValue
11378
+ lt?: QueryValue
11379
+ lte?: QueryValue
11380
+ in?: QueryValue[]
11381
+ nin?: QueryValue[]
11382
+ contains?: string
11383
+ startsWith?: string
11384
+ isNull?: boolean
11385
+ has?: string
11386
+ hasAny?: string[]
11387
+ hasAll?: string[]
11388
+ }
11389
+ ```
11390
+
11391
+ **QueryWhere** (interface)
11392
+ ```typescript
11393
+ interface QueryWhere {
11394
+ and?: QueryWhere[]
11395
+ or?: QueryWhere[]
11396
+ not?: QueryWhere
11397
+ [field: string]: QueryValue | QueryFieldTest | QueryKeyedTest | QueryWhere | QueryWhere[] | undefined
11398
+ }
11399
+ ```
11400
+
11401
+ **StandardQuery** (interface)
11402
+ ```typescript
11403
+ interface StandardQuery {
11404
+ where?: QueryWhere
11405
+ orderBy?: Array<Record<string, 'asc' | 'desc'>>
11406
+ limit?: number
11407
+ cursor?: string | null
11408
+ select?: string[]
11409
+ count?: boolean
11410
+ groupBy?: string[]
11411
+ aggregates?: Record<string, QueryAggregate>
11412
+ expand?: string[] | Record<string, string[] | true>
11413
+ }
11414
+ ```
11415
+
11416
+ **QueryDescription** (interface)
11417
+ ```typescript
11418
+ interface QueryDescription {
11419
+ name: string
11420
+ fields: Record<string, { type: 'string' | 'number' | 'boolean' | 'date' | 'list' | 'keyed' | 'json'; about?: string; can: string[] }>
11421
+ count: boolean
11422
+ aggregates: boolean
11423
+ links: Record<string, { to: string; by: string; about?: string }>
11424
+ limits: { limit: number; groups: number }
11425
+ shape: string
11426
+ }
11427
+ ```
11428
+
11429
+ **QueryValue** = `string | number | boolean`
11430
+
11431
+ **QueryKeyedTest** = `Record<string, QueryValue | { eq?: QueryValue`
11432
+
11433
+ **QueryAggregate** = ``
11434
+
11367
11435
  ### realtime
11368
11436
 
11369
11437
  **RealtimeTokenRequest** (interface)
@@ -12302,6 +12370,10 @@ type VerifyTokenResponse = {
12302
12370
  }
12303
12371
  ```
12304
12372
 
12373
+ ### conditions (api)
12374
+
12375
+ **SaveConditionRequest** = `Omit<SavedCondition, "id" | "deleted">`
12376
+
12305
12377
  ### functions (api)
12306
12378
 
12307
12379
  **FunctionListEntry** (interface)
@@ -12674,70 +12746,70 @@ Fire-and-forget tag analytics event. Uses `navigator.sendBeacon()` when availabl
12674
12746
 
12675
12747
  Workflow-oriented app objects for issues, requests, claims, and tasks that move through statuses and often need assignment or history.
12676
12748
 
12677
- **create**(collectionId: string,
12678
- appId: string,
12679
- input: CreateCaseInput,
12749
+ **create**(collectionId: string,
12750
+ appId: string,
12751
+ input: CreateCaseInput,
12680
12752
  admin: boolean = false) → `Promise<AppCase>`
12681
12753
  Create a new case POST /cases
12682
12754
 
12683
- **list**(collectionId: string,
12684
- appId: string,
12685
- params?: CaseListQueryParams,
12755
+ **list**(collectionId: string,
12756
+ appId: string,
12757
+ params?: CaseListQueryParams,
12686
12758
  admin: boolean = false) → `Promise<PaginatedResponse<AppCase>>`
12687
12759
  List cases with optional query parameters GET /cases
12688
12760
 
12689
- **get**(collectionId: string,
12690
- appId: string,
12691
- caseId: string,
12761
+ **get**(collectionId: string,
12762
+ appId: string,
12763
+ caseId: string,
12692
12764
  admin: boolean = false) → `Promise<AppCase>`
12693
12765
  Get a single case by ID GET /cases/:caseId
12694
12766
 
12695
- **update**(collectionId: string,
12696
- appId: string,
12697
- caseId: string,
12698
- input: UpdateCaseInput,
12767
+ **update**(collectionId: string,
12768
+ appId: string,
12769
+ caseId: string,
12770
+ input: UpdateCaseInput,
12699
12771
  admin: boolean = false) → `Promise<AppCase>`
12700
12772
  Update a case PATCH /cases/:caseId Admin can update any field, public (owner) can only update data and owner zones
12701
12773
 
12702
- **remove**(collectionId: string,
12703
- appId: string,
12704
- caseId: string,
12774
+ **remove**(collectionId: string,
12775
+ appId: string,
12776
+ caseId: string,
12705
12777
  admin: boolean = false) → `Promise<`
12706
12778
  Soft delete a case DELETE /cases/:caseId
12707
12779
 
12708
- **aggregate**(collectionId: string,
12709
- appId: string,
12710
- request: AggregateRequest,
12780
+ **aggregate**(collectionId: string,
12781
+ appId: string,
12782
+ request: AggregateRequest,
12711
12783
  admin: boolean = false) → `Promise<AggregateResponse>`
12712
12784
  Get aggregate statistics for cases POST /cases/aggregate
12713
12785
 
12714
- **summary**(collectionId: string,
12715
- appId: string,
12786
+ **summary**(collectionId: string,
12787
+ appId: string,
12716
12788
  request?: CaseSummaryRequest) → `Promise<CaseSummaryResponse>`
12717
12789
  Get case summary (admin only) POST /cases/summary
12718
12790
 
12719
- **appendHistory**(collectionId: string,
12720
- appId: string,
12721
- caseId: string,
12791
+ **appendHistory**(collectionId: string,
12792
+ appId: string,
12793
+ caseId: string,
12722
12794
  input: AppendHistoryInput) → `Promise<AppCase>`
12723
12795
  Append an entry to case history (admin only) POST /cases/:caseId/history
12724
12796
 
12725
- **related**(collectionId: string,
12726
- appId: string,
12797
+ **related**(collectionId: string,
12798
+ appId: string,
12727
12799
  caseId: string) → `Promise<RelatedResponse>`
12728
12800
  Get related threads and records for a case (admin only) GET /cases/:caseId/related
12729
12801
 
12730
12802
  ### app.options
12731
12803
 
12732
- **get**(collectionId: string,
12733
- appId: string,
12734
- source: string,
12804
+ **get**(collectionId: string,
12805
+ appId: string,
12806
+ source: string,
12735
12807
  opts: { q?: string; version?: string; admin?: boolean } = {},) → `Promise<import('../types/appOptions').AppOptionsResponse>`
12736
12808
  `source` = `type:<record type or declared type id>` | `list:<list id>`. Admins (`admin: true`) see every entry; the public API lists public records and lists the app declares public. Hold on to `version` and pass it back to get `{ unchanged: true }` when nothing changed.
12737
12809
 
12738
- **saveList**(collectionId: string,
12739
- appId: string,
12740
- listId: string,
12810
+ **saveList**(collectionId: string,
12811
+ appId: string,
12812
+ listId: string,
12741
12813
  values: import('../types/appOptions') → `void`
12742
12814
  Save a value list's values, in order (admins). Codes never change and are never lost: a value left out stays, switched off, at the end. → the list as saved.
12743
12815
 
@@ -12745,84 +12817,92 @@ Save a value list's values, in order (admins). Codes never change and are never
12745
12817
 
12746
12818
  General-purpose structured app objects. Use these when a simple scoped data item grows into something queryable, lifecycle-aware, or access-controlled.
12747
12819
 
12748
- **create**(collectionId: string,
12749
- appId: string,
12750
- input: CreateRecordInput,
12820
+ **create**(collectionId: string,
12821
+ appId: string,
12822
+ input: CreateRecordInput,
12751
12823
  admin: boolean = false) → `Promise<CreateRecordResponse>`
12752
12824
  Create a new record POST /records When called on the public endpoint (admin = false) with an anonymous caller, and the app's `publicCreate.records.anonymous.edit.editToken` policy is enabled, the response includes a one-time `editToken` string. Store it immediately — it is never returned again.
12753
12825
 
12754
- **list**(collectionId: string,
12755
- appId: string,
12756
- params?: RecordListQueryParams,
12826
+ **query**(collectionId: string,
12827
+ appId: string,
12828
+ body: StandardQuery = {}) → `Promise<QueryResult>`
12829
+ The standard query on an app's records (admin only): filter, sort, page, count and total in one call, reaching into a record's own fields by path, and following a record to its `product` and its `contact`. POST /admin/collection/:collectionId/app/:appId/records/query Fields: id, recordType, ref, status, visibility, customId, productId, variantId, batchId, proofId, contactId, authorId, parentType, parentId, createdAt, updatedAt, startsAt, expiresAt, and the documents data, owner and admin, reached by path: `"data.status"`, `"data.line.name"`. ```typescript // How many work orders by status, and how many units on each await app.records.query(collectionId, appId, { where: { recordType: 'work_order' }, groupBy: ['data.status'], aggregates: { orders: { count: true }, units: { sum: 'data.qty' } }, }) ```
12830
+
12831
+ **queryFields**(collectionId: string, appId: string) → `Promise<QueryDescription>`
12832
+ What a records query can use: its fields, what each can filter, sort, group or total, and its links. GET /admin/collection/:collectionId/app/:appId/records/query
12833
+
12834
+ **list**(collectionId: string,
12835
+ appId: string,
12836
+ params?: RecordListQueryParams,
12757
12837
  admin: boolean = false) → `Promise<PaginatedResponse<AppRecord>>`
12758
12838
  List records with optional query parameters GET /records Public/owner callers only receive records with `status: "active"`. Admin callers can query all statuses (for example `draft`/`archived`).
12759
12839
 
12760
- **get**(collectionId: string,
12761
- appId: string,
12762
- recordId: string,
12840
+ **get**(collectionId: string,
12841
+ appId: string,
12842
+ recordId: string,
12763
12843
  admin: boolean = false) → `Promise<AppRecord>`
12764
12844
  Get a single record by ID GET /records/:recordId
12765
12845
 
12766
- **update**(collectionId: string,
12767
- appId: string,
12768
- recordId: string,
12769
- input: UpdateRecordInput,
12846
+ **update**(collectionId: string,
12847
+ appId: string,
12848
+ recordId: string,
12849
+ input: UpdateRecordInput,
12770
12850
  admin: boolean = false) → `Promise<AppRecord>`
12771
12851
  Update a record PATCH /records/:recordId Admin can update any field, public (owner) can only update data and owner
12772
12852
 
12773
- **updateWithToken**(collectionId: string,
12774
- appId: string,
12775
- recordId: string,
12776
- data: Record<string, unknown>,
12853
+ **updateWithToken**(collectionId: string,
12854
+ appId: string,
12855
+ recordId: string,
12856
+ data: Record<string, unknown>,
12777
12857
  editToken: string) → `Promise<AppRecord>`
12778
12858
  Amend the `data` zone of a record using an anonymous edit token. PATCH /records/:recordId (public endpoint, no auth) This is the follow-up call after an anonymous `create()` that returned an `editToken`. Present the token via `X-Edit-Token` — the server validates it with a constant-time comparison and, if `windowMinutes` is configured in the policy, checks that the token has not expired. **Scope:** only the `data` zone may be modified via this path. `owner`, `admin`, `status`, `visibility`, and indexed fields are immutable to anonymous token holders. ```ts const record = await app.records.create(collectionId, appId, { recordType: 'payment', visibility: 'public', data: { amount: 9900, currency: 'USD' }, }) const { editToken } = record // store this immediately! // Later, once the payment gateway confirms: const updated = await app.records.updateWithToken( collectionId, appId, record.id, { amount: 9900, currency: 'USD', transactionId: 'txn_abc123' }, editToken, ) ``` ### Error codes | HTTP | `errorCode` | Meaning | |------|-----------------------|---------------------------------------------------| | 401 | `UNAUTHORIZED` | No auth token and no `X-Edit-Token` header | | 403 | `FORBIDDEN` | Policy not enabled, or token does not match | | 403 | `EDIT_WINDOW_EXPIRED` | `windowMinutes` elapsed since record creation | | 404 | `NOT_FOUND` | Record does not exist |
12779
12859
 
12780
- **remove**(collectionId: string,
12781
- appId: string,
12782
- recordId: string,
12860
+ **remove**(collectionId: string,
12861
+ appId: string,
12862
+ recordId: string,
12783
12863
  admin: boolean = false) → `Promise<`
12784
12864
  Soft delete a record DELETE /records/:recordId
12785
12865
 
12786
- **aggregate**(collectionId: string,
12787
- appId: string,
12788
- request: AggregateRequest,
12866
+ **aggregate**(collectionId: string,
12867
+ appId: string,
12868
+ request: AggregateRequest,
12789
12869
  admin: boolean = false) → `Promise<AggregateResponse>`
12790
12870
  Get aggregate statistics for records POST /records/aggregate
12791
12871
 
12792
- **restore**(collectionId: string,
12793
- appId: string,
12872
+ **restore**(collectionId: string,
12873
+ appId: string,
12794
12874
  recordId: string) → `Promise<AppRecord>`
12795
12875
  Restore a soft-deleted record. POST /records/:recordId/restore (admin only)
12796
12876
 
12797
- **upsert**(collectionId: string,
12798
- appId: string,
12877
+ **upsert**(collectionId: string,
12878
+ appId: string,
12799
12879
  input: UpsertRecordInput) → `Promise<UpsertRecordResponse>`
12800
12880
  Upsert a record by ref — creates if no record with that ref exists, otherwise updates. Scope, specificity, and ref are canonicalized on write. POST /records/upsert (admin only)
12801
12881
 
12802
- **match**(collectionId: string,
12803
- appId: string,
12804
- input: MatchRecordsInput,
12882
+ **match**(collectionId: string,
12883
+ appId: string,
12884
+ input: MatchRecordsInput,
12805
12885
  admin: boolean = false) → `Promise<MatchResult>`
12806
12886
  Match records against a runtime target scope. Returns records whose scope is satisfied by the target, ordered by specificity descending (most specific first). POST /records/match ```ts const { records, best } = await app.records.match(collectionId, appId, { target: { productId: 'prod_abc', facets: { tier: ['gold'] } }, strategy: 'best', recordType: 'nutrition', }, true); // best.nutrition → the single highest-specificity nutrition record ```
12807
12887
 
12808
- **bulkUpsert**(collectionId: string,
12809
- appId: string,
12888
+ **bulkUpsert**(collectionId: string,
12889
+ appId: string,
12810
12890
  records: BulkUpsertItem[]) → `Promise<BulkUpsertResult>`
12811
12891
  Upsert up to 500 records in a single transaction. Each row is individually error-isolated — a failure on one row does not abort the others. POST /records/bulk-upsert (admin only)
12812
12892
 
12813
- **bulkDelete**(collectionId: string,
12814
- appId: string,
12893
+ **bulkDelete**(collectionId: string,
12894
+ appId: string,
12815
12895
  input: BulkDeleteInput) → `Promise<BulkDeleteResult>`
12816
12896
  Soft-delete records in bulk. Supports two modes: - **refs mode**: explicit list of refs (max 1000) - **scope mode**: delete by scope anchor (productId / variantId / etc.) POST /records/bulk-delete (admin only) ```ts // Refs mode await app.records.bulkDelete(collectionId, appId, { refs: ['product:prod_abc', 'product:prod_xyz'], recordType: 'nutrition', }); // Scope mode await app.records.bulkDelete(collectionId, appId, { scope: { productId: 'prod_abc' }, }); ```
12817
12897
 
12818
- **resolveAll**(collectionId: string,
12819
- appId: string,
12820
- input: ResolveAllParams,
12898
+ **resolveAll**(collectionId: string,
12899
+ appId: string,
12900
+ input: ResolveAllParams,
12821
12901
  admin: boolean = false) → `Promise<ResolveAllResult>`
12822
12902
  Resolve every applicable record for a product context in one call. Returns records across all tiers (proof, batch, variant, product, rule, facet, collection) deduplicated and sorted by specificity descending. POST /records/resolve-all
12823
12903
 
12824
- **previewRule**(collectionId: string,
12825
- appId: string,
12904
+ **previewRule**(collectionId: string,
12905
+ appId: string,
12826
12906
  input: PreviewRuleParams) → `Promise<PreviewRuleResult>`
12827
12907
  Preview which products in the collection match a given facetRule. Admin only. Use for live "matches N products" feedback while authoring a rule. POST /records/preview-rule
12828
12908
 
@@ -12830,54 +12910,54 @@ Preview which products in the collection match a given facetRule. Admin only. Us
12830
12910
 
12831
12911
  Conversation-oriented app objects for comments, discussions, Q&A, and reply-driven experiences.
12832
12912
 
12833
- **create**(collectionId: string,
12834
- appId: string,
12835
- input: CreateThreadInput,
12913
+ **create**(collectionId: string,
12914
+ appId: string,
12915
+ input: CreateThreadInput,
12836
12916
  admin: boolean = false) → `Promise<AppThread>`
12837
12917
  Create a new thread POST /threads
12838
12918
 
12839
- **list**(collectionId: string,
12840
- appId: string,
12841
- params?: ThreadListQueryParams,
12919
+ **list**(collectionId: string,
12920
+ appId: string,
12921
+ params?: ThreadListQueryParams,
12842
12922
  admin: boolean = false) → `Promise<PaginatedResponse<AppThread>>`
12843
12923
  List threads with optional query parameters GET /threads
12844
12924
 
12845
- **get**(collectionId: string,
12846
- appId: string,
12847
- threadId: string,
12925
+ **get**(collectionId: string,
12926
+ appId: string,
12927
+ threadId: string,
12848
12928
  admin: boolean = false) → `Promise<AppThread>`
12849
12929
  Get a single thread by ID GET /threads/:threadId
12850
12930
 
12851
- **update**(collectionId: string,
12852
- appId: string,
12853
- threadId: string,
12854
- input: UpdateThreadInput,
12931
+ **update**(collectionId: string,
12932
+ appId: string,
12933
+ threadId: string,
12934
+ input: UpdateThreadInput,
12855
12935
  admin: boolean = false) → `Promise<AppThread>`
12856
12936
  Update a thread PATCH /threads/:threadId Admin can update any field, public (owner) can only update body, tags, data, owner
12857
12937
 
12858
- **remove**(collectionId: string,
12859
- appId: string,
12860
- threadId: string,
12938
+ **remove**(collectionId: string,
12939
+ appId: string,
12940
+ threadId: string,
12861
12941
  admin: boolean = false) → `Promise<`
12862
12942
  Soft delete a thread DELETE /threads/:threadId
12863
12943
 
12864
- **reply**(collectionId: string,
12865
- appId: string,
12866
- threadId: string,
12867
- input: ReplyInput,
12944
+ **reply**(collectionId: string,
12945
+ appId: string,
12946
+ threadId: string,
12947
+ input: ReplyInput,
12868
12948
  admin: boolean = false) → `Promise<AppThread>`
12869
12949
  Add a reply to a thread POST /threads/:threadId/reply Atomically appends to replies array, increments replyCount, updates lastReplyAt
12870
12950
 
12871
- **deleteReply**(collectionId: string,
12872
- appId: string,
12873
- threadId: string,
12874
- replyId: string,
12951
+ **deleteReply**(collectionId: string,
12952
+ appId: string,
12953
+ threadId: string,
12954
+ replyId: string,
12875
12955
  admin: boolean = false) → `Promise<AppThread>`
12876
12956
  Delete a single reply from a thread by its reply id (moderation). DELETE /threads/:threadId/reply/:replyId Authorised for the reply's author, the proof owner, or a collection admin.
12877
12957
 
12878
- **aggregate**(collectionId: string,
12879
- appId: string,
12880
- request: AggregateRequest,
12958
+ **aggregate**(collectionId: string,
12959
+ appId: string,
12960
+ request: AggregateRequest,
12881
12961
  admin: boolean = false) → `Promise<AggregateResponse>`
12882
12962
  Get aggregate statistics for threads POST /threads/aggregate
12883
12963
 
@@ -13818,6 +13898,23 @@ Logging: Append a single communication event. POST /admin/collection/:collection
13818
13898
  body: LogBulkCommunicationEventsBody | ({ sourceId: string; ids: string[]; idField?: 'userId'|'contactId'; [k: string]: any }) → `void`
13819
13899
  Logging: Append many communication events for a list of IDs. POST /admin/collection/:collectionId/comm/log/bulk
13820
13900
 
13901
+ ### conditions
13902
+
13903
+ **list**(collectionId: string, admin = false) → `Promise<SavedCondition[]>`
13904
+ Every saved condition in the collection (removed ones left out).
13905
+
13906
+ **get**(collectionId: string, conditionId: string, admin = false) → `Promise<SavedCondition>`
13907
+ One saved condition. Public reads 404 for a removed one; an admin read returns it with `deleted: true`. ```typescript const ukOnly = await conditions.get('coll_123', 'nfCmuWDY') ```
13908
+
13909
+ **create**(collectionId: string, data: SaveConditionRequest) → `Promise<SavedCondition>`
13910
+ Save a new condition (admin). ```typescript const c = await conditions.create('coll_123', { title: 'UK only', type: 'and', conditions: [{ type: 'country', countries: ['GB'], contains: true }], }) ```
13911
+
13912
+ **update**(collectionId: string, conditionId: string, data: Partial<SaveConditionRequest>) → `Promise<SavedCondition>`
13913
+ Change a saved condition (admin). Send the fields to change; `conditions` is replaced whole.
13914
+
13915
+ **remove**(collectionId: string, conditionId: string) → `Promise<SavedCondition>`
13916
+ Remove a saved condition (admin). It's kept, marked deleted, and passes for everyone from then on.
13917
+
13821
13918
  ### config
13822
13919
 
13823
13920
  **getFields**() → `Promise<FieldDefinition[]>`
@@ -13828,56 +13925,74 @@ Returns all proof type definitions. Proof types are templates that specify which
13828
13925
 
13829
13926
  ### contact
13830
13927
 
13928
+ **query**(collectionId: string,
13929
+ body: StandardQuery = {}) → `Promise<QueryResult>`
13930
+ The standard query on contacts (admin only): filter, sort, page, count and total in one call. POST /admin/collection/:collectionId/contacts/query Fields: contactId, userId, firstName, lastName, displayName, company, email, phone, tags, source, locale, createdAt, updatedAt. Email and phone are the contact's main one. Deleted and erased contacts are never returned. ```typescript await contact.query(collectionId, { where: { tags: { hasAny: ['vip', 'trade'] }, createdAt: { gte: '2026-01-01' } }, select: ['contactId', 'firstName', 'email'], count: true, }) await contact.query(collectionId, { groupBy: ['company'], aggregates: { people: { count: true } } }) ```
13931
+
13932
+ **queryFields**(collectionId: string) → `Promise<QueryDescription>`
13933
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13934
+
13831
13935
  **create**(collectionId: string, data: ContactCreateRequest) → `Promise<ContactResponse>`
13936
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13832
13937
 
13833
- **list**(collectionId: string,
13938
+ **list**(collectionId: string,
13834
13939
  params?: { limit?: number; offset?: number; includeDeleted?: boolean }) → `Promise<ContactListResponse>`
13835
-
13836
- **search**({
13837
- collectionId,
13838
- q,
13839
- typeahead,
13840
- email,
13841
- phone,
13842
- id,
13843
- userId,
13844
- tags,
13845
- tagsAll,
13846
- source,
13847
- locale,
13848
- createdFrom,
13849
- createdTo,
13850
- externalIdKey,
13851
- externalIdValue,
13852
- customFieldKey,
13853
- customFieldValue,
13854
- limit,
13855
- offset,
13940
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13941
+
13942
+ **search**({
13943
+ collectionId,
13944
+ q,
13945
+ typeahead,
13946
+ email,
13947
+ phone,
13948
+ id,
13949
+ userId,
13950
+ tags,
13951
+ tagsAll,
13952
+ source,
13953
+ locale,
13954
+ createdFrom,
13955
+ createdTo,
13956
+ externalIdKey,
13957
+ externalIdValue,
13958
+ customFieldKey,
13959
+ customFieldValue,
13960
+ limit,
13961
+ offset,
13856
13962
  }: ContactSearchParams) → `Promise<ContactSearchResponse>`
13963
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13857
13964
 
13858
- **get**(collectionId: string,
13859
- contactId: string,
13965
+ **get**(collectionId: string,
13966
+ contactId: string,
13860
13967
  params?: { includeDeleted?: boolean }) → `Promise<ContactResponse>`
13968
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13861
13969
 
13862
- **update**(collectionId: string,
13863
- contactId: string,
13970
+ **update**(collectionId: string,
13971
+ contactId: string,
13864
13972
  data: ContactUpdateRequest) → `Promise<ContactResponse>`
13973
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13865
13974
 
13866
13975
  **remove**(collectionId: string, contactId: string) → `Promise<void>`
13976
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13867
13977
 
13868
- **lookup**(collectionId: string,
13978
+ **lookup**(collectionId: string,
13869
13979
  params: { email?: string; phone?: string }) → `Promise<ContactResponse>`
13980
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13870
13981
 
13871
- **upsert**(collectionId: string,
13982
+ **upsert**(collectionId: string,
13872
13983
  data: ContactCreateRequest) → `Promise<ContactResponse>`
13984
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13873
13985
 
13874
- **publicUpsert**(collectionId: string,
13986
+ **publicUpsert**(collectionId: string,
13875
13987
  data: PublicContactUpsertRequest) → `Promise<PublicContactUpsertResponse>`
13988
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13876
13989
 
13877
13990
  **publicGetMine**(collectionId: string) → `Promise<PublicGetMyContactResponse>`
13991
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13878
13992
 
13879
- **publicUpdateMine**(collectionId: string,
13993
+ **publicUpdateMine**(collectionId: string,
13880
13994
  data: ContactPatch) → `Promise<PublicUpdateMyContactResponse>`
13995
+ What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
13881
13996
 
13882
13997
  **publicGetSchema**(collectionId: string) → `Promise<ContactSchemaResponse>`
13883
13998
  Public: Get the contact schema for a collection. GET /public/collection/:collectionId/contact/schema Returns a ContactSchemaResponse describing all publicly visible contact fields. Core fields and collection-defined custom fields are merged into a single flat schema. Fields not in `publicVisibleFields` are stripped entirely from the response. Fields visible but not in `publicEditableFields` have `ui:disabled: true` in `uiSchema`. Use `fieldOrder` to render fields in the correct sequence, and `evaluateConditions` from the types package to handle conditional field visibility. ```typescript import { contact, evaluateConditions } from '@proveanything/smartlinks' const schema = await contact.publicGetSchema(collectionId) for (const fieldId of schema.fieldOrder) { const property = schema.schema.properties[fieldId] const ui = schema.uiSchema[fieldId] || {} const visible = evaluateConditions(property.conditions, property.showWhen, formValues) const disabled = ui['ui:disabled'] === true if (visible) renderField({ fieldId, property, ui, disabled }) } ```
@@ -13885,20 +14000,20 @@ Public: Get the contact schema for a collection. GET /public/collection/:collect
13885
14000
  **erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
13886
14001
  Public: Get the contact schema for a collection. GET /public/collection/:collectionId/contact/schema Returns a ContactSchemaResponse describing all publicly visible contact fields. Core fields and collection-defined custom fields are merged into a single flat schema. Fields not in `publicVisibleFields` are stripped entirely from the response. Fields visible but not in `publicEditableFields` have `ui:disabled: true` in `uiSchema`. Use `fieldOrder` to render fields in the correct sequence, and `evaluateConditions` from the types package to handle conditional field visibility. ```typescript import { contact, evaluateConditions } from '@proveanything/smartlinks' const schema = await contact.publicGetSchema(collectionId) for (const fieldId of schema.fieldOrder) { const property = schema.schema.properties[fieldId] const ui = schema.uiSchema[fieldId] || {} const visible = evaluateConditions(property.conditions, property.showWhen, formValues) const disabled = ui['ui:disabled'] === true if (visible) renderField({ fieldId, property, ui, disabled }) } ```
13887
14002
 
13888
- **findDuplicates**(collectionId: string,
14003
+ **findDuplicates**(collectionId: string,
13889
14004
  params?: { limit?: number; offset?: number }) → `Promise<ContactDuplicatesResponse>`
13890
14005
  Admin: pairs of contacts that look like one person. GET /admin/collection/:collectionId/contacts/duplicates The pattern it finds: someone the collection knew by email first (an import, a list, a form) who later signed in. Their sign-in got a second contact, which could not take the email the first one already held — so one contact has the email and no sign-in, the other the sign-in (and everything they did) and no email. The match is made on the server, on verified addresses only. Checks a window of contacts per call; while `more` is true, call again with `offset` moved on by `scanned`. ```typescript const { pairs } = await contact.findDuplicates(collectionId) for (const pair of pairs) { await contact.merge(collectionId, pair.keep.contactId, pair.merge.contactId) } ```
13891
14006
 
13892
- **merge**(collectionId: string,
13893
- keepContactId: string,
14007
+ **merge**(collectionId: string,
14008
+ keepContactId: string,
13894
14009
  fromContactId: string) → `Promise<ContactMergeResponse>`
13895
14010
  Admin: fold contact `fromContactId` INTO contact `keepContactId`. POST /admin/collection/:collectionId/contacts/:keepContactId/merge The kept contact gains the other's sign-in, emails and phones, and anything it had no value for; its own values win. Everything recorded against the other contact moves to the kept one. Consent is never loosened: an opt-out on either contact stays an opt-out. The other contact is soft-deleted and marked with `customFields.mergedInto`. Refused (HTTP 409, `error` = a `ContactMergeErrorCode`) when the two have different sign-ins (`LOGIN_CONFLICT`) or are both members of the same loyalty scheme (`LOYALTY_CONFLICT`).
13896
14011
 
13897
- **linkLogin**(collectionId: string,
14012
+ **linkLogin**(collectionId: string,
13898
14013
  userId: string) → `Promise<ContactLinkLoginResponse>`
13899
14014
  Admin: the contact that carries a sign-in, attaching the sign-in first to the contact that already holds its verified email or phone. POST /admin/collection/:collectionId/contacts/link-login For a service about to create a contact for a `userId`: call this first and only create when it throws 404 (`NOTHING_TO_LINK`), so a person the collection already knows by email stays one contact. The address is read from the sign-in itself and must be verified; nothing the caller says about an email is used. Never creates a contact. ```typescript let contactId: string try { contactId = (await contact.linkLogin(collectionId, userId)).contactId } catch (err) { if (err.statusCode !== 404) throw err contactId = (await contact.create(collectionId, { userId, source: 'my-service' })).contactId } ```
13900
14015
 
13901
- **getUser**(collectionId: string,
14016
+ **getUser**(collectionId: string,
13902
14017
  userId: string,) → `Promise<UserSearchResponse>`
13903
14018
  Admin: the contact that carries a sign-in, attaching the sign-in first to the contact that already holds its verified email or phone. POST /admin/collection/:collectionId/contacts/link-login For a service about to create a contact for a `userId`: call this first and only create when it throws 404 (`NOTHING_TO_LINK`), so a person the collection already knows by email stays one contact. The address is read from the sign-in itself and must be verified; nothing the caller says about an email is used. Never creates a contact. ```typescript let contactId: string try { contactId = (await contact.linkLogin(collectionId, userId)).contactId } catch (err) { if (err.statusCode !== 404) throw err contactId = (await contact.create(collectionId, { userId, source: 'my-service' })).contactId } ```
13904
14019
 
@@ -14728,76 +14843,90 @@ Look up a serial number by code for a product (admin only).
14728
14843
 
14729
14844
  ### products
14730
14845
 
14731
- **get**(collectionId: string,
14732
- productId: string,
14846
+ **get**(collectionId: string,
14847
+ productId: string,
14733
14848
  admin?: boolean) → `Promise<ProductResponse>`
14734
14849
 
14735
- **list**(collectionId: string,
14850
+ **list**(collectionId: string,
14736
14851
  admin?: boolean) → `Promise<ProductResponse[]>`
14737
14852
 
14738
- **create**(collectionId: string,
14853
+ **create**(collectionId: string,
14739
14854
  data: ProductCreateRequest) → `Promise<ProductResponse>`
14740
14855
 
14741
- **update**(collectionId: string,
14742
- productId: string,
14856
+ **update**(collectionId: string,
14857
+ productId: string,
14743
14858
  data: ProductUpdateRequest) → `Promise<ProductResponse>`
14744
14859
 
14745
- **remove**(collectionId: string,
14860
+ **remove**(collectionId: string,
14746
14861
  productId: string) → `Promise<void>`
14747
14862
 
14748
- **query**(collectionId: string,
14749
- body: ProductQueryRequest,
14863
+ **query**(collectionId: string,
14864
+ body: ProductQueryRequest,
14750
14865
  admin?: boolean) → `Promise<ProductQueryResponse>`
14751
14866
  Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
14752
14867
 
14753
- **clone**(collectionId: string,
14754
- productId: string,
14868
+ **standardQuery**(collectionId: string,
14869
+ body: StandardQuery = {}) → `Promise<QueryResult>`
14870
+ The standard query on products (admin only): the one query shape every resource is moving to, with counts, totals and filtering by facet. It sits beside `products.query`, whose own body is unchanged. POST /admin/collection/:collectionId/products/standard/query Fields: id, name, description, sku, gtin, schemaType, status, sortOrder, createdAt, updatedAt, facets. Facets are filtered by key: the facet by its key or name, the value by its key or name. ```typescript await products.standardQuery(collectionId, { where: { facets: { brand: 'Breville', category: { in: ['Toasters', 'Kettles'] } }, status: 'active' }, select: ['id', 'name', 'sku'], count: true, }) ```
14871
+
14872
+ **standardQueryFields**(collectionId: string) → `Promise<QueryDescription>`
14873
+ What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
14874
+
14875
+ **clone**(collectionId: string,
14876
+ productId: string,
14755
14877
  body: Record<string, JsonValue> = {}) → `Promise<ProductResponse>`
14756
- Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
14878
+ What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
14757
14879
 
14758
- **listAssets**(collectionId: string,
14759
- productId: string,
14880
+ **listAssets**(collectionId: string,
14881
+ productId: string,
14760
14882
  admin?: boolean) → `Promise<unknown>`
14761
- Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
14883
+ What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
14762
14884
 
14763
- **createClaimWindow**(collectionId: string,
14764
- productId: string,
14885
+ **createClaimWindow**(collectionId: string,
14886
+ productId: string,
14765
14887
  body: Record<string, JsonValue>) → `Promise<unknown>`
14766
- Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
14888
+ What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
14767
14889
 
14768
- **updateClaimWindow**(collectionId: string,
14769
- productId: string,
14770
- claimId: string,
14890
+ **updateClaimWindow**(collectionId: string,
14891
+ productId: string,
14892
+ claimId: string,
14771
14893
  body: Record<string, JsonValue>) → `Promise<unknown>`
14772
- Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
14894
+ What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
14773
14895
 
14774
- **refresh**(collectionId: string,
14896
+ **refresh**(collectionId: string,
14775
14897
  productId: string) → `Promise<ProductResponse>`
14776
- Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
14898
+ What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
14777
14899
 
14778
- **getSN**(collectionId: string,
14779
- productId: string,
14780
- startIndex: number = 0,
14900
+ **getSN**(collectionId: string,
14901
+ productId: string,
14902
+ startIndex: number = 0,
14781
14903
  count: number = 10) → `Promise<unknown>`
14782
- Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
14904
+ What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
14783
14905
 
14784
- **lookupSN**(collectionId: string,
14785
- productId: string,
14906
+ **lookupSN**(collectionId: string,
14907
+ productId: string,
14786
14908
  codeId: string) → `Promise<unknown>`
14787
- Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
14909
+ What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
14788
14910
 
14789
- **publicLookupClaim**(collectionId: string,
14790
- productId: string,
14911
+ **publicLookupClaim**(collectionId: string,
14912
+ productId: string,
14791
14913
  claimId: string) → `Promise<unknown>`
14792
- Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
14914
+ What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
14793
14915
 
14794
- **publicCreateClaim**(collectionId: string,
14795
- productId: string,
14916
+ **publicCreateClaim**(collectionId: string,
14917
+ productId: string,
14796
14918
  body: ProductClaimCreateRequestBody) → `Promise<unknown>`
14797
- Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
14919
+ What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
14798
14920
 
14799
14921
  ### proof
14800
14922
 
14923
+ **query**(collectionId: string,
14924
+ body: StandardQuery = {}) → `Promise<QueryResult>`
14925
+ The standard query on proofs (admin only): filter, sort, page, count and total a collection's proofs in one call, and follow a proof to its `product` and its `owner` (the owner's contact). POST /admin/collection/:collectionId/proof/query Fields: id, productId, userId (the owner's login id), batchId, variantId, lotId, status, claimable, createdAt, updatedAt. A proof's own values are not returned by this call. ```typescript // How many people own each product await proof.query(collectionId, { where: { userId: { isNull: false } }, groupBy: ['productId'], aggregates: { owners: { countDistinct: 'userId' } }, }) // The most recent owner of a product, with their name await proof.query(collectionId, { where: { productId: 'toaster', userId: { isNull: false } }, orderBy: [{ createdAt: 'desc' }], limit: 1, expand: { owner: ['firstName', 'lastName', 'email'] }, }) ```
14926
+
14927
+ **queryFields**(collectionId: string) → `Promise<QueryDescription>`
14928
+ What a proofs query can use: its fields, what each can filter, sort, group or total, and its links. GET /admin/collection/:collectionId/proof/query
14929
+
14801
14930
  **get**(collectionId: string,
14802
14931
  productId: string,
14803
14932
  proofId: string,