@proveanything/smartlinks 2.1.20 → 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.
- package/dist/adminCardsView.d.ts +1 -1
- package/dist/adminCardsView.js +70 -55
- package/dist/api/appObjects.d.ts +26 -0
- package/dist/api/appObjects.js +31 -1
- package/dist/api/conditions.d.ts +51 -0
- package/dist/api/conditions.js +57 -0
- package/dist/api/contact.d.ts +83 -1
- package/dist/api/contact.js +104 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/products.d.ts +22 -0
- package/dist/api/products.js +29 -0
- package/dist/api/proof.d.ts +30 -0
- package/dist/api/proof.js +37 -0
- package/dist/api/realtime.d.ts +19 -0
- package/dist/api/realtime.js +26 -1
- package/dist/docs/API_SUMMARY.md +396 -170
- package/dist/docs/admin-cards.md +1 -1
- package/dist/docs/app-manifest.md +19 -0
- package/dist/docs/assistant-apps.md +4 -0
- package/dist/docs/assistant-context.md +119 -0
- package/dist/docs/realtime.md +20 -0
- package/dist/docs/standard-query.md +187 -0
- package/dist/docs/utils.md +22 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +0 -1
- package/dist/openapi.yaml +675 -0
- package/dist/types/adminCards.d.ts +2 -1
- package/dist/types/appManifest.d.ts +64 -1
- package/dist/types/contact.d.ts +55 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/query.d.ts +121 -0
- package/dist/types/query.js +5 -0
- package/dist/types/realtime.d.ts +7 -1
- package/dist/utils/conditions.d.ts +1 -1
- package/dist/utils/conditions.js +21 -6
- package/docs/API_SUMMARY.md +396 -170
- package/docs/admin-cards.md +1 -1
- package/docs/app-manifest.md +19 -0
- package/docs/assistant-apps.md +4 -0
- package/docs/assistant-context.md +119 -0
- package/docs/realtime.md +20 -0
- package/docs/standard-query.md +187 -0
- package/docs/utils.md +22 -8
- package/openapi.yaml +675 -0
- package/package.json +1 -1
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
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 }
|
|
@@ -3186,6 +3188,7 @@ interface AppManifest {
|
|
|
3186
3188
|
};
|
|
3187
3189
|
};
|
|
3188
3190
|
admin?: string;
|
|
3191
|
+
adminPage?: string;
|
|
3189
3192
|
widgets?: AppManifestWidgets;
|
|
3190
3193
|
containers?: {
|
|
3191
3194
|
files: AppManifestFiles;
|
|
@@ -3196,7 +3199,10 @@ interface AppManifest {
|
|
|
3196
3199
|
adminViews?: AdminView[];
|
|
3197
3200
|
executor?: AppManifestExecutor;
|
|
3198
3201
|
functions?: AppManifestFunctions;
|
|
3199
|
-
realtime?: {
|
|
3202
|
+
realtime?: {
|
|
3203
|
+
channels?: RealtimeChannelDeclaration[];
|
|
3204
|
+
staff?: string[];
|
|
3205
|
+
};
|
|
3200
3206
|
adminCards?: AppManifestAdminCards;
|
|
3201
3207
|
data?: AppDataDeclaration;
|
|
3202
3208
|
headless?: AppHeadlessDeclaration;
|
|
@@ -3221,6 +3227,29 @@ interface AppAssistantDeclaration {
|
|
|
3221
3227
|
skills?: AppAssistantFile[];
|
|
3222
3228
|
knowledge?: AppAssistantFile[];
|
|
3223
3229
|
preview?: string;
|
|
3230
|
+
purpose?: string;
|
|
3231
|
+
objects?: AssistantObject[];
|
|
3232
|
+
words?: Record<string, string>;
|
|
3233
|
+
recipes?: AssistantRecipe[];
|
|
3234
|
+
}
|
|
3235
|
+
```
|
|
3236
|
+
|
|
3237
|
+
**AssistantObject** (interface)
|
|
3238
|
+
```typescript
|
|
3239
|
+
interface AssistantObject {
|
|
3240
|
+
object: string;
|
|
3241
|
+
where?: Record<string, string | number | boolean>;
|
|
3242
|
+
means: string;
|
|
3243
|
+
fields?: Record<string, string>;
|
|
3244
|
+
write?: 'direct' | 'actions' | 'none';
|
|
3245
|
+
}
|
|
3246
|
+
```
|
|
3247
|
+
|
|
3248
|
+
**AssistantRecipe** (interface)
|
|
3249
|
+
```typescript
|
|
3250
|
+
interface AssistantRecipe {
|
|
3251
|
+
question: string;
|
|
3252
|
+
answer: string;
|
|
3224
3253
|
}
|
|
3225
3254
|
```
|
|
3226
3255
|
|
|
@@ -7440,6 +7469,56 @@ interface ContactListResponse {
|
|
|
7440
7469
|
}
|
|
7441
7470
|
```
|
|
7442
7471
|
|
|
7472
|
+
**ContactDuplicatePair** (interface)
|
|
7473
|
+
```typescript
|
|
7474
|
+
interface ContactDuplicatePair {
|
|
7475
|
+
keep: Contact
|
|
7476
|
+
merge: Contact
|
|
7477
|
+
matchedOn: "email" | "phone"
|
|
7478
|
+
}
|
|
7479
|
+
```
|
|
7480
|
+
|
|
7481
|
+
**ContactDuplicatesResponse** (interface)
|
|
7482
|
+
```typescript
|
|
7483
|
+
interface ContactDuplicatesResponse {
|
|
7484
|
+
pairs: ContactDuplicatePair[]
|
|
7485
|
+
scanned: number
|
|
7486
|
+
more: boolean
|
|
7487
|
+
}
|
|
7488
|
+
```
|
|
7489
|
+
|
|
7490
|
+
**ContactMergeResponse** (interface)
|
|
7491
|
+
```typescript
|
|
7492
|
+
interface ContactMergeResponse {
|
|
7493
|
+
contactId: string
|
|
7494
|
+
mergedFrom: string
|
|
7495
|
+
moved: {
|
|
7496
|
+
login: boolean
|
|
7497
|
+
identities: number
|
|
7498
|
+
records?: number
|
|
7499
|
+
cases?: number
|
|
7500
|
+
threads?: number
|
|
7501
|
+
bookings?: number
|
|
7502
|
+
loyaltyMembers?: number
|
|
7503
|
+
assets?: number
|
|
7504
|
+
uploadTokens?: number
|
|
7505
|
+
aiSessions?: number
|
|
7506
|
+
messages?: number
|
|
7507
|
+
conversations?: number
|
|
7508
|
+
}
|
|
7509
|
+
contact: Contact
|
|
7510
|
+
}
|
|
7511
|
+
```
|
|
7512
|
+
|
|
7513
|
+
**ContactLinkLoginResponse** (interface)
|
|
7514
|
+
```typescript
|
|
7515
|
+
interface ContactLinkLoginResponse {
|
|
7516
|
+
contactId: string
|
|
7517
|
+
linked: boolean
|
|
7518
|
+
contact: Contact
|
|
7519
|
+
}
|
|
7520
|
+
```
|
|
7521
|
+
|
|
7443
7522
|
**ContactSearchParams** (interface)
|
|
7444
7523
|
```typescript
|
|
7445
7524
|
interface ContactSearchParams {
|
|
@@ -7660,6 +7739,8 @@ interface ContactSchemaResponse {
|
|
|
7660
7739
|
|
|
7661
7740
|
**ContactUpdateRequest** = `Partial<ContactCreateRequest>`
|
|
7662
7741
|
|
|
7742
|
+
**ContactMergeErrorCode** = ``
|
|
7743
|
+
|
|
7663
7744
|
**PublicContactUpsertRequest** = `Partial<`
|
|
7664
7745
|
|
|
7665
7746
|
**ContactPatch** = `Partial<`
|
|
@@ -11285,6 +11366,72 @@ interface QrShortCodeLookupResponse {
|
|
|
11285
11366
|
}
|
|
11286
11367
|
```
|
|
11287
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
|
+
|
|
11288
11435
|
### realtime
|
|
11289
11436
|
|
|
11290
11437
|
**RealtimeTokenRequest** (interface)
|
|
@@ -11336,6 +11483,7 @@ interface RealtimeChangeEvent {
|
|
|
11336
11483
|
productId?: string
|
|
11337
11484
|
proofId?: string
|
|
11338
11485
|
status?: string
|
|
11486
|
+
kind?: string
|
|
11339
11487
|
at: number
|
|
11340
11488
|
}
|
|
11341
11489
|
```
|
|
@@ -11349,6 +11497,7 @@ interface RealtimeChangeFilter {
|
|
|
11349
11497
|
recordType?: string
|
|
11350
11498
|
productId?: string
|
|
11351
11499
|
proofId?: string
|
|
11500
|
+
kind?: string
|
|
11352
11501
|
}
|
|
11353
11502
|
```
|
|
11354
11503
|
|
|
@@ -12221,6 +12370,10 @@ type VerifyTokenResponse = {
|
|
|
12221
12370
|
}
|
|
12222
12371
|
```
|
|
12223
12372
|
|
|
12373
|
+
### conditions (api)
|
|
12374
|
+
|
|
12375
|
+
**SaveConditionRequest** = `Omit<SavedCondition, "id" | "deleted">`
|
|
12376
|
+
|
|
12224
12377
|
### functions (api)
|
|
12225
12378
|
|
|
12226
12379
|
**FunctionListEntry** (interface)
|
|
@@ -12593,70 +12746,70 @@ Fire-and-forget tag analytics event. Uses `navigator.sendBeacon()` when availabl
|
|
|
12593
12746
|
|
|
12594
12747
|
Workflow-oriented app objects for issues, requests, claims, and tasks that move through statuses and often need assignment or history.
|
|
12595
12748
|
|
|
12596
|
-
**create**(collectionId: string,
|
|
12597
|
-
appId: string,
|
|
12598
|
-
input: CreateCaseInput,
|
|
12749
|
+
**create**(collectionId: string,
|
|
12750
|
+
appId: string,
|
|
12751
|
+
input: CreateCaseInput,
|
|
12599
12752
|
admin: boolean = false) → `Promise<AppCase>`
|
|
12600
12753
|
Create a new case POST /cases
|
|
12601
12754
|
|
|
12602
|
-
**list**(collectionId: string,
|
|
12603
|
-
appId: string,
|
|
12604
|
-
params?: CaseListQueryParams,
|
|
12755
|
+
**list**(collectionId: string,
|
|
12756
|
+
appId: string,
|
|
12757
|
+
params?: CaseListQueryParams,
|
|
12605
12758
|
admin: boolean = false) → `Promise<PaginatedResponse<AppCase>>`
|
|
12606
12759
|
List cases with optional query parameters GET /cases
|
|
12607
12760
|
|
|
12608
|
-
**get**(collectionId: string,
|
|
12609
|
-
appId: string,
|
|
12610
|
-
caseId: string,
|
|
12761
|
+
**get**(collectionId: string,
|
|
12762
|
+
appId: string,
|
|
12763
|
+
caseId: string,
|
|
12611
12764
|
admin: boolean = false) → `Promise<AppCase>`
|
|
12612
12765
|
Get a single case by ID GET /cases/:caseId
|
|
12613
12766
|
|
|
12614
|
-
**update**(collectionId: string,
|
|
12615
|
-
appId: string,
|
|
12616
|
-
caseId: string,
|
|
12617
|
-
input: UpdateCaseInput,
|
|
12767
|
+
**update**(collectionId: string,
|
|
12768
|
+
appId: string,
|
|
12769
|
+
caseId: string,
|
|
12770
|
+
input: UpdateCaseInput,
|
|
12618
12771
|
admin: boolean = false) → `Promise<AppCase>`
|
|
12619
12772
|
Update a case PATCH /cases/:caseId Admin can update any field, public (owner) can only update data and owner zones
|
|
12620
12773
|
|
|
12621
|
-
**remove**(collectionId: string,
|
|
12622
|
-
appId: string,
|
|
12623
|
-
caseId: string,
|
|
12774
|
+
**remove**(collectionId: string,
|
|
12775
|
+
appId: string,
|
|
12776
|
+
caseId: string,
|
|
12624
12777
|
admin: boolean = false) → `Promise<`
|
|
12625
12778
|
Soft delete a case DELETE /cases/:caseId
|
|
12626
12779
|
|
|
12627
|
-
**aggregate**(collectionId: string,
|
|
12628
|
-
appId: string,
|
|
12629
|
-
request: AggregateRequest,
|
|
12780
|
+
**aggregate**(collectionId: string,
|
|
12781
|
+
appId: string,
|
|
12782
|
+
request: AggregateRequest,
|
|
12630
12783
|
admin: boolean = false) → `Promise<AggregateResponse>`
|
|
12631
12784
|
Get aggregate statistics for cases POST /cases/aggregate
|
|
12632
12785
|
|
|
12633
|
-
**summary**(collectionId: string,
|
|
12634
|
-
appId: string,
|
|
12786
|
+
**summary**(collectionId: string,
|
|
12787
|
+
appId: string,
|
|
12635
12788
|
request?: CaseSummaryRequest) → `Promise<CaseSummaryResponse>`
|
|
12636
12789
|
Get case summary (admin only) POST /cases/summary
|
|
12637
12790
|
|
|
12638
|
-
**appendHistory**(collectionId: string,
|
|
12639
|
-
appId: string,
|
|
12640
|
-
caseId: string,
|
|
12791
|
+
**appendHistory**(collectionId: string,
|
|
12792
|
+
appId: string,
|
|
12793
|
+
caseId: string,
|
|
12641
12794
|
input: AppendHistoryInput) → `Promise<AppCase>`
|
|
12642
12795
|
Append an entry to case history (admin only) POST /cases/:caseId/history
|
|
12643
12796
|
|
|
12644
|
-
**related**(collectionId: string,
|
|
12645
|
-
appId: string,
|
|
12797
|
+
**related**(collectionId: string,
|
|
12798
|
+
appId: string,
|
|
12646
12799
|
caseId: string) → `Promise<RelatedResponse>`
|
|
12647
12800
|
Get related threads and records for a case (admin only) GET /cases/:caseId/related
|
|
12648
12801
|
|
|
12649
12802
|
### app.options
|
|
12650
12803
|
|
|
12651
|
-
**get**(collectionId: string,
|
|
12652
|
-
appId: string,
|
|
12653
|
-
source: string,
|
|
12804
|
+
**get**(collectionId: string,
|
|
12805
|
+
appId: string,
|
|
12806
|
+
source: string,
|
|
12654
12807
|
opts: { q?: string; version?: string; admin?: boolean } = {},) → `Promise<import('../types/appOptions').AppOptionsResponse>`
|
|
12655
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.
|
|
12656
12809
|
|
|
12657
|
-
**saveList**(collectionId: string,
|
|
12658
|
-
appId: string,
|
|
12659
|
-
listId: string,
|
|
12810
|
+
**saveList**(collectionId: string,
|
|
12811
|
+
appId: string,
|
|
12812
|
+
listId: string,
|
|
12660
12813
|
values: import('../types/appOptions') → `void`
|
|
12661
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.
|
|
12662
12815
|
|
|
@@ -12664,84 +12817,92 @@ Save a value list's values, in order (admins). Codes never change and are never
|
|
|
12664
12817
|
|
|
12665
12818
|
General-purpose structured app objects. Use these when a simple scoped data item grows into something queryable, lifecycle-aware, or access-controlled.
|
|
12666
12819
|
|
|
12667
|
-
**create**(collectionId: string,
|
|
12668
|
-
appId: string,
|
|
12669
|
-
input: CreateRecordInput,
|
|
12820
|
+
**create**(collectionId: string,
|
|
12821
|
+
appId: string,
|
|
12822
|
+
input: CreateRecordInput,
|
|
12670
12823
|
admin: boolean = false) → `Promise<CreateRecordResponse>`
|
|
12671
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.
|
|
12672
12825
|
|
|
12673
|
-
**
|
|
12674
|
-
appId: string,
|
|
12675
|
-
|
|
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,
|
|
12676
12837
|
admin: boolean = false) → `Promise<PaginatedResponse<AppRecord>>`
|
|
12677
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`).
|
|
12678
12839
|
|
|
12679
|
-
**get**(collectionId: string,
|
|
12680
|
-
appId: string,
|
|
12681
|
-
recordId: string,
|
|
12840
|
+
**get**(collectionId: string,
|
|
12841
|
+
appId: string,
|
|
12842
|
+
recordId: string,
|
|
12682
12843
|
admin: boolean = false) → `Promise<AppRecord>`
|
|
12683
12844
|
Get a single record by ID GET /records/:recordId
|
|
12684
12845
|
|
|
12685
|
-
**update**(collectionId: string,
|
|
12686
|
-
appId: string,
|
|
12687
|
-
recordId: string,
|
|
12688
|
-
input: UpdateRecordInput,
|
|
12846
|
+
**update**(collectionId: string,
|
|
12847
|
+
appId: string,
|
|
12848
|
+
recordId: string,
|
|
12849
|
+
input: UpdateRecordInput,
|
|
12689
12850
|
admin: boolean = false) → `Promise<AppRecord>`
|
|
12690
12851
|
Update a record PATCH /records/:recordId Admin can update any field, public (owner) can only update data and owner
|
|
12691
12852
|
|
|
12692
|
-
**updateWithToken**(collectionId: string,
|
|
12693
|
-
appId: string,
|
|
12694
|
-
recordId: string,
|
|
12695
|
-
data: Record<string, unknown>,
|
|
12853
|
+
**updateWithToken**(collectionId: string,
|
|
12854
|
+
appId: string,
|
|
12855
|
+
recordId: string,
|
|
12856
|
+
data: Record<string, unknown>,
|
|
12696
12857
|
editToken: string) → `Promise<AppRecord>`
|
|
12697
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 |
|
|
12698
12859
|
|
|
12699
|
-
**remove**(collectionId: string,
|
|
12700
|
-
appId: string,
|
|
12701
|
-
recordId: string,
|
|
12860
|
+
**remove**(collectionId: string,
|
|
12861
|
+
appId: string,
|
|
12862
|
+
recordId: string,
|
|
12702
12863
|
admin: boolean = false) → `Promise<`
|
|
12703
12864
|
Soft delete a record DELETE /records/:recordId
|
|
12704
12865
|
|
|
12705
|
-
**aggregate**(collectionId: string,
|
|
12706
|
-
appId: string,
|
|
12707
|
-
request: AggregateRequest,
|
|
12866
|
+
**aggregate**(collectionId: string,
|
|
12867
|
+
appId: string,
|
|
12868
|
+
request: AggregateRequest,
|
|
12708
12869
|
admin: boolean = false) → `Promise<AggregateResponse>`
|
|
12709
12870
|
Get aggregate statistics for records POST /records/aggregate
|
|
12710
12871
|
|
|
12711
|
-
**restore**(collectionId: string,
|
|
12712
|
-
appId: string,
|
|
12872
|
+
**restore**(collectionId: string,
|
|
12873
|
+
appId: string,
|
|
12713
12874
|
recordId: string) → `Promise<AppRecord>`
|
|
12714
12875
|
Restore a soft-deleted record. POST /records/:recordId/restore (admin only)
|
|
12715
12876
|
|
|
12716
|
-
**upsert**(collectionId: string,
|
|
12717
|
-
appId: string,
|
|
12877
|
+
**upsert**(collectionId: string,
|
|
12878
|
+
appId: string,
|
|
12718
12879
|
input: UpsertRecordInput) → `Promise<UpsertRecordResponse>`
|
|
12719
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)
|
|
12720
12881
|
|
|
12721
|
-
**match**(collectionId: string,
|
|
12722
|
-
appId: string,
|
|
12723
|
-
input: MatchRecordsInput,
|
|
12882
|
+
**match**(collectionId: string,
|
|
12883
|
+
appId: string,
|
|
12884
|
+
input: MatchRecordsInput,
|
|
12724
12885
|
admin: boolean = false) → `Promise<MatchResult>`
|
|
12725
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 ```
|
|
12726
12887
|
|
|
12727
|
-
**bulkUpsert**(collectionId: string,
|
|
12728
|
-
appId: string,
|
|
12888
|
+
**bulkUpsert**(collectionId: string,
|
|
12889
|
+
appId: string,
|
|
12729
12890
|
records: BulkUpsertItem[]) → `Promise<BulkUpsertResult>`
|
|
12730
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)
|
|
12731
12892
|
|
|
12732
|
-
**bulkDelete**(collectionId: string,
|
|
12733
|
-
appId: string,
|
|
12893
|
+
**bulkDelete**(collectionId: string,
|
|
12894
|
+
appId: string,
|
|
12734
12895
|
input: BulkDeleteInput) → `Promise<BulkDeleteResult>`
|
|
12735
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' }, }); ```
|
|
12736
12897
|
|
|
12737
|
-
**resolveAll**(collectionId: string,
|
|
12738
|
-
appId: string,
|
|
12739
|
-
input: ResolveAllParams,
|
|
12898
|
+
**resolveAll**(collectionId: string,
|
|
12899
|
+
appId: string,
|
|
12900
|
+
input: ResolveAllParams,
|
|
12740
12901
|
admin: boolean = false) → `Promise<ResolveAllResult>`
|
|
12741
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
|
|
12742
12903
|
|
|
12743
|
-
**previewRule**(collectionId: string,
|
|
12744
|
-
appId: string,
|
|
12904
|
+
**previewRule**(collectionId: string,
|
|
12905
|
+
appId: string,
|
|
12745
12906
|
input: PreviewRuleParams) → `Promise<PreviewRuleResult>`
|
|
12746
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
|
|
12747
12908
|
|
|
@@ -12749,54 +12910,54 @@ Preview which products in the collection match a given facetRule. Admin only. Us
|
|
|
12749
12910
|
|
|
12750
12911
|
Conversation-oriented app objects for comments, discussions, Q&A, and reply-driven experiences.
|
|
12751
12912
|
|
|
12752
|
-
**create**(collectionId: string,
|
|
12753
|
-
appId: string,
|
|
12754
|
-
input: CreateThreadInput,
|
|
12913
|
+
**create**(collectionId: string,
|
|
12914
|
+
appId: string,
|
|
12915
|
+
input: CreateThreadInput,
|
|
12755
12916
|
admin: boolean = false) → `Promise<AppThread>`
|
|
12756
12917
|
Create a new thread POST /threads
|
|
12757
12918
|
|
|
12758
|
-
**list**(collectionId: string,
|
|
12759
|
-
appId: string,
|
|
12760
|
-
params?: ThreadListQueryParams,
|
|
12919
|
+
**list**(collectionId: string,
|
|
12920
|
+
appId: string,
|
|
12921
|
+
params?: ThreadListQueryParams,
|
|
12761
12922
|
admin: boolean = false) → `Promise<PaginatedResponse<AppThread>>`
|
|
12762
12923
|
List threads with optional query parameters GET /threads
|
|
12763
12924
|
|
|
12764
|
-
**get**(collectionId: string,
|
|
12765
|
-
appId: string,
|
|
12766
|
-
threadId: string,
|
|
12925
|
+
**get**(collectionId: string,
|
|
12926
|
+
appId: string,
|
|
12927
|
+
threadId: string,
|
|
12767
12928
|
admin: boolean = false) → `Promise<AppThread>`
|
|
12768
12929
|
Get a single thread by ID GET /threads/:threadId
|
|
12769
12930
|
|
|
12770
|
-
**update**(collectionId: string,
|
|
12771
|
-
appId: string,
|
|
12772
|
-
threadId: string,
|
|
12773
|
-
input: UpdateThreadInput,
|
|
12931
|
+
**update**(collectionId: string,
|
|
12932
|
+
appId: string,
|
|
12933
|
+
threadId: string,
|
|
12934
|
+
input: UpdateThreadInput,
|
|
12774
12935
|
admin: boolean = false) → `Promise<AppThread>`
|
|
12775
12936
|
Update a thread PATCH /threads/:threadId Admin can update any field, public (owner) can only update body, tags, data, owner
|
|
12776
12937
|
|
|
12777
|
-
**remove**(collectionId: string,
|
|
12778
|
-
appId: string,
|
|
12779
|
-
threadId: string,
|
|
12938
|
+
**remove**(collectionId: string,
|
|
12939
|
+
appId: string,
|
|
12940
|
+
threadId: string,
|
|
12780
12941
|
admin: boolean = false) → `Promise<`
|
|
12781
12942
|
Soft delete a thread DELETE /threads/:threadId
|
|
12782
12943
|
|
|
12783
|
-
**reply**(collectionId: string,
|
|
12784
|
-
appId: string,
|
|
12785
|
-
threadId: string,
|
|
12786
|
-
input: ReplyInput,
|
|
12944
|
+
**reply**(collectionId: string,
|
|
12945
|
+
appId: string,
|
|
12946
|
+
threadId: string,
|
|
12947
|
+
input: ReplyInput,
|
|
12787
12948
|
admin: boolean = false) → `Promise<AppThread>`
|
|
12788
12949
|
Add a reply to a thread POST /threads/:threadId/reply Atomically appends to replies array, increments replyCount, updates lastReplyAt
|
|
12789
12950
|
|
|
12790
|
-
**deleteReply**(collectionId: string,
|
|
12791
|
-
appId: string,
|
|
12792
|
-
threadId: string,
|
|
12793
|
-
replyId: string,
|
|
12951
|
+
**deleteReply**(collectionId: string,
|
|
12952
|
+
appId: string,
|
|
12953
|
+
threadId: string,
|
|
12954
|
+
replyId: string,
|
|
12794
12955
|
admin: boolean = false) → `Promise<AppThread>`
|
|
12795
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.
|
|
12796
12957
|
|
|
12797
|
-
**aggregate**(collectionId: string,
|
|
12798
|
-
appId: string,
|
|
12799
|
-
request: AggregateRequest,
|
|
12958
|
+
**aggregate**(collectionId: string,
|
|
12959
|
+
appId: string,
|
|
12960
|
+
request: AggregateRequest,
|
|
12800
12961
|
admin: boolean = false) → `Promise<AggregateResponse>`
|
|
12801
12962
|
Get aggregate statistics for threads POST /threads/aggregate
|
|
12802
12963
|
|
|
@@ -13737,6 +13898,23 @@ Logging: Append a single communication event. POST /admin/collection/:collection
|
|
|
13737
13898
|
body: LogBulkCommunicationEventsBody | ({ sourceId: string; ids: string[]; idField?: 'userId'|'contactId'; [k: string]: any }) → `void`
|
|
13738
13899
|
Logging: Append many communication events for a list of IDs. POST /admin/collection/:collectionId/comm/log/bulk
|
|
13739
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
|
+
|
|
13740
13918
|
### config
|
|
13741
13919
|
|
|
13742
13920
|
**getFields**() → `Promise<FieldDefinition[]>`
|
|
@@ -13747,56 +13925,74 @@ Returns all proof type definitions. Proof types are templates that specify which
|
|
|
13747
13925
|
|
|
13748
13926
|
### contact
|
|
13749
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
|
+
|
|
13750
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
|
|
13751
13937
|
|
|
13752
|
-
**list**(collectionId: string,
|
|
13938
|
+
**list**(collectionId: string,
|
|
13753
13939
|
params?: { limit?: number; offset?: number; includeDeleted?: boolean }) → `Promise<ContactListResponse>`
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
|
|
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,
|
|
13775
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
|
|
13776
13964
|
|
|
13777
|
-
**get**(collectionId: string,
|
|
13778
|
-
contactId: string,
|
|
13965
|
+
**get**(collectionId: string,
|
|
13966
|
+
contactId: string,
|
|
13779
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
|
|
13780
13969
|
|
|
13781
|
-
**update**(collectionId: string,
|
|
13782
|
-
contactId: string,
|
|
13970
|
+
**update**(collectionId: string,
|
|
13971
|
+
contactId: string,
|
|
13783
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
|
|
13784
13974
|
|
|
13785
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
|
|
13786
13977
|
|
|
13787
|
-
**lookup**(collectionId: string,
|
|
13978
|
+
**lookup**(collectionId: string,
|
|
13788
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
|
|
13789
13981
|
|
|
13790
|
-
**upsert**(collectionId: string,
|
|
13982
|
+
**upsert**(collectionId: string,
|
|
13791
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
|
|
13792
13985
|
|
|
13793
|
-
**publicUpsert**(collectionId: string,
|
|
13986
|
+
**publicUpsert**(collectionId: string,
|
|
13794
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
|
|
13795
13989
|
|
|
13796
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
|
|
13797
13992
|
|
|
13798
|
-
**publicUpdateMine**(collectionId: string,
|
|
13993
|
+
**publicUpdateMine**(collectionId: string,
|
|
13799
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
|
|
13800
13996
|
|
|
13801
13997
|
**publicGetSchema**(collectionId: string) → `Promise<ContactSchemaResponse>`
|
|
13802
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 }) } ```
|
|
@@ -13804,9 +14000,22 @@ Public: Get the contact schema for a collection. GET /public/collection/:collect
|
|
|
13804
14000
|
**erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
|
|
13805
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 }) } ```
|
|
13806
14002
|
|
|
13807
|
-
**
|
|
14003
|
+
**findDuplicates**(collectionId: string,
|
|
14004
|
+
params?: { limit?: number; offset?: number }) → `Promise<ContactDuplicatesResponse>`
|
|
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) } ```
|
|
14006
|
+
|
|
14007
|
+
**merge**(collectionId: string,
|
|
14008
|
+
keepContactId: string,
|
|
14009
|
+
fromContactId: string) → `Promise<ContactMergeResponse>`
|
|
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`).
|
|
14011
|
+
|
|
14012
|
+
**linkLogin**(collectionId: string,
|
|
14013
|
+
userId: string) → `Promise<ContactLinkLoginResponse>`
|
|
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 } ```
|
|
14015
|
+
|
|
14016
|
+
**getUser**(collectionId: string,
|
|
13808
14017
|
userId: string,) → `Promise<UserSearchResponse>`
|
|
13809
|
-
|
|
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 } ```
|
|
13810
14019
|
|
|
13811
14020
|
### containers
|
|
13812
14021
|
|
|
@@ -14634,76 +14843,90 @@ Look up a serial number by code for a product (admin only).
|
|
|
14634
14843
|
|
|
14635
14844
|
### products
|
|
14636
14845
|
|
|
14637
|
-
**get**(collectionId: string,
|
|
14638
|
-
productId: string,
|
|
14846
|
+
**get**(collectionId: string,
|
|
14847
|
+
productId: string,
|
|
14639
14848
|
admin?: boolean) → `Promise<ProductResponse>`
|
|
14640
14849
|
|
|
14641
|
-
**list**(collectionId: string,
|
|
14850
|
+
**list**(collectionId: string,
|
|
14642
14851
|
admin?: boolean) → `Promise<ProductResponse[]>`
|
|
14643
14852
|
|
|
14644
|
-
**create**(collectionId: string,
|
|
14853
|
+
**create**(collectionId: string,
|
|
14645
14854
|
data: ProductCreateRequest) → `Promise<ProductResponse>`
|
|
14646
14855
|
|
|
14647
|
-
**update**(collectionId: string,
|
|
14648
|
-
productId: string,
|
|
14856
|
+
**update**(collectionId: string,
|
|
14857
|
+
productId: string,
|
|
14649
14858
|
data: ProductUpdateRequest) → `Promise<ProductResponse>`
|
|
14650
14859
|
|
|
14651
|
-
**remove**(collectionId: string,
|
|
14860
|
+
**remove**(collectionId: string,
|
|
14652
14861
|
productId: string) → `Promise<void>`
|
|
14653
14862
|
|
|
14654
|
-
**query**(collectionId: string,
|
|
14655
|
-
body: ProductQueryRequest,
|
|
14863
|
+
**query**(collectionId: string,
|
|
14864
|
+
body: ProductQueryRequest,
|
|
14656
14865
|
admin?: boolean) → `Promise<ProductQueryResponse>`
|
|
14657
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) ```
|
|
14658
14867
|
|
|
14659
|
-
**
|
|
14660
|
-
|
|
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,
|
|
14661
14877
|
body: Record<string, JsonValue> = {}) → `Promise<ProductResponse>`
|
|
14662
|
-
|
|
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
|
|
14663
14879
|
|
|
14664
|
-
**listAssets**(collectionId: string,
|
|
14665
|
-
productId: string,
|
|
14880
|
+
**listAssets**(collectionId: string,
|
|
14881
|
+
productId: string,
|
|
14666
14882
|
admin?: boolean) → `Promise<unknown>`
|
|
14667
|
-
|
|
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
|
|
14668
14884
|
|
|
14669
|
-
**createClaimWindow**(collectionId: string,
|
|
14670
|
-
productId: string,
|
|
14885
|
+
**createClaimWindow**(collectionId: string,
|
|
14886
|
+
productId: string,
|
|
14671
14887
|
body: Record<string, JsonValue>) → `Promise<unknown>`
|
|
14672
|
-
|
|
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
|
|
14673
14889
|
|
|
14674
|
-
**updateClaimWindow**(collectionId: string,
|
|
14675
|
-
productId: string,
|
|
14676
|
-
claimId: string,
|
|
14890
|
+
**updateClaimWindow**(collectionId: string,
|
|
14891
|
+
productId: string,
|
|
14892
|
+
claimId: string,
|
|
14677
14893
|
body: Record<string, JsonValue>) → `Promise<unknown>`
|
|
14678
|
-
|
|
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
|
|
14679
14895
|
|
|
14680
|
-
**refresh**(collectionId: string,
|
|
14896
|
+
**refresh**(collectionId: string,
|
|
14681
14897
|
productId: string) → `Promise<ProductResponse>`
|
|
14682
|
-
|
|
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
|
|
14683
14899
|
|
|
14684
|
-
**getSN**(collectionId: string,
|
|
14685
|
-
productId: string,
|
|
14686
|
-
startIndex: number = 0,
|
|
14900
|
+
**getSN**(collectionId: string,
|
|
14901
|
+
productId: string,
|
|
14902
|
+
startIndex: number = 0,
|
|
14687
14903
|
count: number = 10) → `Promise<unknown>`
|
|
14688
|
-
|
|
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
|
|
14689
14905
|
|
|
14690
|
-
**lookupSN**(collectionId: string,
|
|
14691
|
-
productId: string,
|
|
14906
|
+
**lookupSN**(collectionId: string,
|
|
14907
|
+
productId: string,
|
|
14692
14908
|
codeId: string) → `Promise<unknown>`
|
|
14693
|
-
|
|
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
|
|
14694
14910
|
|
|
14695
|
-
**publicLookupClaim**(collectionId: string,
|
|
14696
|
-
productId: string,
|
|
14911
|
+
**publicLookupClaim**(collectionId: string,
|
|
14912
|
+
productId: string,
|
|
14697
14913
|
claimId: string) → `Promise<unknown>`
|
|
14698
|
-
|
|
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
|
|
14699
14915
|
|
|
14700
|
-
**publicCreateClaim**(collectionId: string,
|
|
14701
|
-
productId: string,
|
|
14916
|
+
**publicCreateClaim**(collectionId: string,
|
|
14917
|
+
productId: string,
|
|
14702
14918
|
body: ProductClaimCreateRequestBody) → `Promise<unknown>`
|
|
14703
|
-
|
|
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
|
|
14704
14920
|
|
|
14705
14921
|
### proof
|
|
14706
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
|
+
|
|
14707
14930
|
**get**(collectionId: string,
|
|
14708
14931
|
productId: string,
|
|
14709
14932
|
proofId: string,
|
|
@@ -14888,6 +15111,9 @@ One of your app's declared channels (manifest `realtime.channels`). ```ts const
|
|
|
14888
15111
|
**onChange**(scope: RealtimeScope, filter: RealtimeChangeFilter, onChangeFn: (change: RealtimeChangeEvent) → `void`
|
|
14889
15112
|
Something changed: refetch it. IDs only — never data. Admins of the collection see every change; everyone else sees changes to public things (public app records, products). Filter by `type` ('product' | 'proof' | 'asset' | 'record' | 'collection' | 'collection.apps' | 'settings'), `id`, `appId`, `recordType`, `productId`, `proofId`. ```ts const off = realtime.onChange({ collectionId }, { type: "record", appId, recordType: "entry" }, () => refetch()) ```
|
|
14890
15113
|
|
|
15114
|
+
**onStaffChange**(scope: RealtimeScope & { appId: string }, filter: RealtimeChangeFilter, onChangeFn: (change: RealtimeChangeEvent) → `void`
|
|
15115
|
+
Something this APP works on changed: one of its work orders, a container or stock it moved, or one of its own records. For the people who use the app, admins or not: someone hears these when they are in one of the app's user groups (the ones its server functions are limited to, or `realtime.staff` in its manifest), and so does a collection admin. IDs only — refetch through your own API. Types: 'workOrder' (`id`, `appId`), 'container' (`id`, `kind` = its container type), 'stock' (`id` = the container, `productId`), 'record' (`id`, `recordType`). Filter as with `onChange`; an empty filter hears them all. ```ts // A production app's screens refetch when anything on the floor changes. useEffect(() => realtime.onStaffChange({ collectionId, appId }, {}, () => queryClient.invalidateQueries()), [collectionId, appId]) ```
|
|
15116
|
+
|
|
14891
15117
|
**onMine**(scope: RealtimeScope, onMessage: (msg: RealtimeMessage) → `void`
|
|
14892
15118
|
Messages for the signed-in person only (e.g. "scan" — a tag they just scanned on another device).
|
|
14893
15119
|
|