@proveanything/smartlinks 2.1.19 → 2.1.22
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/api/aiGuide.d.ts +2 -0
- package/dist/api/aiGuide.js +1 -0
- package/dist/api/contact.d.ts +60 -1
- package/dist/api/contact.js +74 -0
- package/dist/api/realtime.d.ts +19 -0
- package/dist/api/realtime.js +26 -1
- package/dist/docs/API_SUMMARY.md +101 -3
- 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/index.d.ts +2 -0
- package/dist/index.js +0 -1
- package/dist/live.d.ts +8 -0
- package/dist/live.js +50 -8
- package/dist/openapi.yaml +247 -0
- package/dist/types/appManifest.d.ts +64 -1
- package/dist/types/contact.d.ts +55 -0
- package/dist/types/realtime.d.ts +7 -1
- package/docs/API_SUMMARY.md +101 -3
- 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/openapi.yaml +247 -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.22 | Generated: 2026-11-18T08:01:22.740Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -3186,6 +3186,7 @@ interface AppManifest {
|
|
|
3186
3186
|
};
|
|
3187
3187
|
};
|
|
3188
3188
|
admin?: string;
|
|
3189
|
+
adminPage?: string;
|
|
3189
3190
|
widgets?: AppManifestWidgets;
|
|
3190
3191
|
containers?: {
|
|
3191
3192
|
files: AppManifestFiles;
|
|
@@ -3196,7 +3197,10 @@ interface AppManifest {
|
|
|
3196
3197
|
adminViews?: AdminView[];
|
|
3197
3198
|
executor?: AppManifestExecutor;
|
|
3198
3199
|
functions?: AppManifestFunctions;
|
|
3199
|
-
realtime?: {
|
|
3200
|
+
realtime?: {
|
|
3201
|
+
channels?: RealtimeChannelDeclaration[];
|
|
3202
|
+
staff?: string[];
|
|
3203
|
+
};
|
|
3200
3204
|
adminCards?: AppManifestAdminCards;
|
|
3201
3205
|
data?: AppDataDeclaration;
|
|
3202
3206
|
headless?: AppHeadlessDeclaration;
|
|
@@ -3221,6 +3225,29 @@ interface AppAssistantDeclaration {
|
|
|
3221
3225
|
skills?: AppAssistantFile[];
|
|
3222
3226
|
knowledge?: AppAssistantFile[];
|
|
3223
3227
|
preview?: string;
|
|
3228
|
+
purpose?: string;
|
|
3229
|
+
objects?: AssistantObject[];
|
|
3230
|
+
words?: Record<string, string>;
|
|
3231
|
+
recipes?: AssistantRecipe[];
|
|
3232
|
+
}
|
|
3233
|
+
```
|
|
3234
|
+
|
|
3235
|
+
**AssistantObject** (interface)
|
|
3236
|
+
```typescript
|
|
3237
|
+
interface AssistantObject {
|
|
3238
|
+
object: string;
|
|
3239
|
+
where?: Record<string, string | number | boolean>;
|
|
3240
|
+
means: string;
|
|
3241
|
+
fields?: Record<string, string>;
|
|
3242
|
+
write?: 'direct' | 'actions' | 'none';
|
|
3243
|
+
}
|
|
3244
|
+
```
|
|
3245
|
+
|
|
3246
|
+
**AssistantRecipe** (interface)
|
|
3247
|
+
```typescript
|
|
3248
|
+
interface AssistantRecipe {
|
|
3249
|
+
question: string;
|
|
3250
|
+
answer: string;
|
|
3224
3251
|
}
|
|
3225
3252
|
```
|
|
3226
3253
|
|
|
@@ -7440,6 +7467,56 @@ interface ContactListResponse {
|
|
|
7440
7467
|
}
|
|
7441
7468
|
```
|
|
7442
7469
|
|
|
7470
|
+
**ContactDuplicatePair** (interface)
|
|
7471
|
+
```typescript
|
|
7472
|
+
interface ContactDuplicatePair {
|
|
7473
|
+
keep: Contact
|
|
7474
|
+
merge: Contact
|
|
7475
|
+
matchedOn: "email" | "phone"
|
|
7476
|
+
}
|
|
7477
|
+
```
|
|
7478
|
+
|
|
7479
|
+
**ContactDuplicatesResponse** (interface)
|
|
7480
|
+
```typescript
|
|
7481
|
+
interface ContactDuplicatesResponse {
|
|
7482
|
+
pairs: ContactDuplicatePair[]
|
|
7483
|
+
scanned: number
|
|
7484
|
+
more: boolean
|
|
7485
|
+
}
|
|
7486
|
+
```
|
|
7487
|
+
|
|
7488
|
+
**ContactMergeResponse** (interface)
|
|
7489
|
+
```typescript
|
|
7490
|
+
interface ContactMergeResponse {
|
|
7491
|
+
contactId: string
|
|
7492
|
+
mergedFrom: string
|
|
7493
|
+
moved: {
|
|
7494
|
+
login: boolean
|
|
7495
|
+
identities: number
|
|
7496
|
+
records?: number
|
|
7497
|
+
cases?: number
|
|
7498
|
+
threads?: number
|
|
7499
|
+
bookings?: number
|
|
7500
|
+
loyaltyMembers?: number
|
|
7501
|
+
assets?: number
|
|
7502
|
+
uploadTokens?: number
|
|
7503
|
+
aiSessions?: number
|
|
7504
|
+
messages?: number
|
|
7505
|
+
conversations?: number
|
|
7506
|
+
}
|
|
7507
|
+
contact: Contact
|
|
7508
|
+
}
|
|
7509
|
+
```
|
|
7510
|
+
|
|
7511
|
+
**ContactLinkLoginResponse** (interface)
|
|
7512
|
+
```typescript
|
|
7513
|
+
interface ContactLinkLoginResponse {
|
|
7514
|
+
contactId: string
|
|
7515
|
+
linked: boolean
|
|
7516
|
+
contact: Contact
|
|
7517
|
+
}
|
|
7518
|
+
```
|
|
7519
|
+
|
|
7443
7520
|
**ContactSearchParams** (interface)
|
|
7444
7521
|
```typescript
|
|
7445
7522
|
interface ContactSearchParams {
|
|
@@ -7660,6 +7737,8 @@ interface ContactSchemaResponse {
|
|
|
7660
7737
|
|
|
7661
7738
|
**ContactUpdateRequest** = `Partial<ContactCreateRequest>`
|
|
7662
7739
|
|
|
7740
|
+
**ContactMergeErrorCode** = ``
|
|
7741
|
+
|
|
7663
7742
|
**PublicContactUpsertRequest** = `Partial<`
|
|
7664
7743
|
|
|
7665
7744
|
**ContactPatch** = `Partial<`
|
|
@@ -11336,6 +11415,7 @@ interface RealtimeChangeEvent {
|
|
|
11336
11415
|
productId?: string
|
|
11337
11416
|
proofId?: string
|
|
11338
11417
|
status?: string
|
|
11418
|
+
kind?: string
|
|
11339
11419
|
at: number
|
|
11340
11420
|
}
|
|
11341
11421
|
```
|
|
@@ -11349,6 +11429,7 @@ interface RealtimeChangeFilter {
|
|
|
11349
11429
|
recordType?: string
|
|
11350
11430
|
productId?: string
|
|
11351
11431
|
proofId?: string
|
|
11432
|
+
kind?: string
|
|
11352
11433
|
}
|
|
11353
11434
|
```
|
|
11354
11435
|
|
|
@@ -12154,6 +12235,7 @@ interface GuideStartOptions {
|
|
|
12154
12235
|
onCaption?: (text: string) => void
|
|
12155
12236
|
onReply?: (text: string) => void
|
|
12156
12237
|
onError?: (message: string) => void
|
|
12238
|
+
onMuted?: (muted: boolean) => void
|
|
12157
12239
|
}
|
|
12158
12240
|
```
|
|
12159
12241
|
|
|
@@ -13803,9 +13885,22 @@ Public: Get the contact schema for a collection. GET /public/collection/:collect
|
|
|
13803
13885
|
**erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
|
|
13804
13886
|
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 }) } ```
|
|
13805
13887
|
|
|
13888
|
+
**findDuplicates**(collectionId: string,
|
|
13889
|
+
params?: { limit?: number; offset?: number }) → `Promise<ContactDuplicatesResponse>`
|
|
13890
|
+
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
|
+
|
|
13892
|
+
**merge**(collectionId: string,
|
|
13893
|
+
keepContactId: string,
|
|
13894
|
+
fromContactId: string) → `Promise<ContactMergeResponse>`
|
|
13895
|
+
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
|
+
|
|
13897
|
+
**linkLogin**(collectionId: string,
|
|
13898
|
+
userId: string) → `Promise<ContactLinkLoginResponse>`
|
|
13899
|
+
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
|
+
|
|
13806
13901
|
**getUser**(collectionId: string,
|
|
13807
13902
|
userId: string,) → `Promise<UserSearchResponse>`
|
|
13808
|
-
|
|
13903
|
+
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 } ```
|
|
13809
13904
|
|
|
13810
13905
|
### containers
|
|
13811
13906
|
|
|
@@ -14887,6 +14982,9 @@ One of your app's declared channels (manifest `realtime.channels`). ```ts const
|
|
|
14887
14982
|
**onChange**(scope: RealtimeScope, filter: RealtimeChangeFilter, onChangeFn: (change: RealtimeChangeEvent) → `void`
|
|
14888
14983
|
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()) ```
|
|
14889
14984
|
|
|
14985
|
+
**onStaffChange**(scope: RealtimeScope & { appId: string }, filter: RealtimeChangeFilter, onChangeFn: (change: RealtimeChangeEvent) → `void`
|
|
14986
|
+
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]) ```
|
|
14987
|
+
|
|
14890
14988
|
**onMine**(scope: RealtimeScope, onMessage: (msg: RealtimeMessage) → `void`
|
|
14891
14989
|
Messages for the signed-in person only (e.g. "scan" — a tag they just scanned on another device).
|
|
14892
14990
|
|
package/docs/app-manifest.md
CHANGED
|
@@ -219,6 +219,25 @@ A relative path (from the app's public root) to the `app.admin.json` file. Omit
|
|
|
219
219
|
"admin": "app.admin.json"
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
+
#### `adminPage`
|
|
223
|
+
|
|
224
|
+
The page a host opens as the app's **admin screen**, from the app's root: `"admin.html"` or `"index.html"`.
|
|
225
|
+
Studio, the console and Forge's preview read it rather than guess. Omit it to take the host's default:
|
|
226
|
+
|
|
227
|
+
| App | Default admin page |
|
|
228
|
+
|-----|--------------------|
|
|
229
|
+
| An installed app | `admin.html` |
|
|
230
|
+
| A core app (`core-<name>`, one of Studio's own sections) | the root page, `index.html` |
|
|
231
|
+
|
|
232
|
+
Declare it when the default is wrong. AuthKit (`core-account`) is the example: its root page is the
|
|
233
|
+
**public sign-in screen** every site sends people to, so its admin lives at `admin.html`:
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
"adminPage": "admin.html"
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Never move a public page off the root to make room for the admin: sign-in links and embeds point at the root.
|
|
240
|
+
|
|
222
241
|
#### `widgets`
|
|
223
242
|
|
|
224
243
|
Declares the widget bundle. Omit if the app has no widget component.
|
package/docs/assistant-apps.md
CHANGED
|
@@ -37,6 +37,10 @@ and change them through change sets. The declarations make it *good* at your app
|
|
|
37
37
|
The files sit in `public/assistant/` in your project and ship with every release like any other static
|
|
38
38
|
file (they are read from the release's CDN folder, on the channel the collection runs your app on).
|
|
39
39
|
|
|
40
|
+
The same block also says **what your app's data means** to the assistant (`purpose`, `objects`, `words`,
|
|
41
|
+
`recipes`): which standard objects are what in your app, and which may only be changed through your
|
|
42
|
+
actions. See **[assistant-context.md](assistant-context.md)**.
|
|
43
|
+
|
|
40
44
|
### How they are loaded
|
|
41
45
|
|
|
42
46
|
When an admin opens a chat, the assistant's box gets the **index** of every installed app's skills: one
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Telling the assistant what your app's data means
|
|
2
|
+
|
|
3
|
+
SmartLinks keeps a business's data in standard objects: work orders, containers and stock, bookings,
|
|
4
|
+
records, contacts, history. The assistant can read all of them. What it can't know is what they **mean in
|
|
5
|
+
your app**: that a work order is a job, that a container of type `drum` is a drum of juice, that a
|
|
6
|
+
booking with `data.event = "christmas-fair"` is a stall at the school fair.
|
|
7
|
+
|
|
8
|
+
Tell it, in the manifest's `assistant` block, beside any skills and knowledge files
|
|
9
|
+
([assistant-apps.md](assistant-apps.md)). Four keys:
|
|
10
|
+
|
|
11
|
+
```jsonc
|
|
12
|
+
// app.manifest.json
|
|
13
|
+
"assistant": {
|
|
14
|
+
"purpose": "Production manager for a fragrance filling and decorating factory: jobs from sales order to put-away.",
|
|
15
|
+
"objects": [
|
|
16
|
+
{
|
|
17
|
+
"object": "workOrder",
|
|
18
|
+
"where": { "appId": "accord-production" },
|
|
19
|
+
"means": "A job.",
|
|
20
|
+
"fields": {
|
|
21
|
+
"ref": "job number, from the sales order",
|
|
22
|
+
"kind": "job type: FillOnly, DecorateOnly, CompleteJob, PackagingOnly, Conversion",
|
|
23
|
+
"dueAt": "target date",
|
|
24
|
+
"data.stage": "the stage shown on screen",
|
|
25
|
+
"stages": "picking, then decoration, filling, packaging (\"boxing\" on screen), wrapping"
|
|
26
|
+
},
|
|
27
|
+
"write": "actions"
|
|
28
|
+
},
|
|
29
|
+
{ "object": "container", "where": { "containerType": "drum" }, "means": "A drum of bulk juice; its ref is the batch number.", "write": "actions" },
|
|
30
|
+
{ "object": "container", "where": { "containerType": "location" }, "means": "A place in the factory.", "write": "direct" },
|
|
31
|
+
{ "object": "history", "where": { "type": "job.*" }, "means": "A job's timeline.", "write": "none" }
|
|
32
|
+
],
|
|
33
|
+
"words": {
|
|
34
|
+
"GMP": "the batch manufacturing record printed for each job",
|
|
35
|
+
"the diary": "production runs by day"
|
|
36
|
+
},
|
|
37
|
+
"recipes": [
|
|
38
|
+
{ "question": "What's on tomorrow?", "answer": "this app's work order stages planned for that day, by stage; show machine or crew" },
|
|
39
|
+
{ "question": "Which jobs are late?", "answer": "use the action jobs.late: it applies the app's own rule for late" }
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
| Key | What it is | Limit |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| `purpose` | One line on what the app or site is for. The assistant always has it in view. | 200 characters |
|
|
47
|
+
| `objects` | What each standard object means here, and whether the assistant may change it. | 20 |
|
|
48
|
+
| `words` | The business's own terms. | 40 |
|
|
49
|
+
| `recipes` | How to answer the questions people actually ask. | 30 |
|
|
50
|
+
|
|
51
|
+
All four together: at most 6,000 characters. The assistant reads this every time a question touches your
|
|
52
|
+
app, so short wins. Anything malformed is left out and anything too long is cut (recipes first), without
|
|
53
|
+
an error: check what you wrote reads well.
|
|
54
|
+
|
|
55
|
+
## Objects
|
|
56
|
+
|
|
57
|
+
- **`object`**: the standard object: `workOrder`, `workOrderStage`, `container`, `stock`, `booking`,
|
|
58
|
+
`record`, `contact`, `product`, `history`.
|
|
59
|
+
- **`where`**: which ones, with the filters the SDK takes (`appId`, `containerType`, `recordType`,
|
|
60
|
+
`data.<field>`).
|
|
61
|
+
- **`means`**: what it is here, in a sentence.
|
|
62
|
+
- **`fields`**: only the fields whose name doesn't say what they hold.
|
|
63
|
+
- **`write`**: may the assistant change it?
|
|
64
|
+
|
|
65
|
+
| `write` | Means |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `direct` | Through the API, as a planned change the person applies. |
|
|
68
|
+
| `actions` | **Only through one of your app's actions**, never another way. |
|
|
69
|
+
| `none` | Never. |
|
|
70
|
+
| absent | Nothing is said; the platform's usual rules apply. |
|
|
71
|
+
|
|
72
|
+
**Record types you declared in the `data` block don't need repeating.** The assistant gets their titles
|
|
73
|
+
and fields from there ([admin-lists-and-pickers.md](admin-lists-and-pickers.md)); add an `objects`
|
|
74
|
+
entry only to say what one means or to set its `write` rule.
|
|
75
|
+
|
|
76
|
+
## Actions, when changing something has rules
|
|
77
|
+
|
|
78
|
+
If creating or changing a thing involves rules that live in your code (a number from a counter, a check,
|
|
79
|
+
someone who must be told), don't describe the rules and hope: mark the object `"write": "actions"` and
|
|
80
|
+
give the assistant an **action** that does it. An action is one of your functions offered as a tool
|
|
81
|
+
([agent-tools.md](agent-tools.md)):
|
|
82
|
+
|
|
83
|
+
```jsonc
|
|
84
|
+
{
|
|
85
|
+
"name": "run.plan",
|
|
86
|
+
"trigger": { "type": "http", "methods": ["POST"] },
|
|
87
|
+
"agent": {
|
|
88
|
+
"tool": true,
|
|
89
|
+
"audience": ["assistant"],
|
|
90
|
+
"title": "Plan a production run",
|
|
91
|
+
"description": "Plan one stage of a job for a day, by hand or on a machine, with its crew.",
|
|
92
|
+
"input": { "type": "object", "properties": { "job": { "type": "string" }, "stage": { "type": "string" }, "date": { "type": "string" } }, "required": ["job", "stage", "date"] },
|
|
93
|
+
"approval": "require"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Your rules then run in code every time. Keep actions few and coarse: one "find jobs" with filters, not
|
|
99
|
+
five narrow ones. Use `"approval": "require"` for anything that changes or sends something: the person
|
|
100
|
+
confirms it on a card.
|
|
101
|
+
|
|
102
|
+
## A site speaks for the business
|
|
103
|
+
|
|
104
|
+
A site is the business's own app, so its description is about the **business**:
|
|
105
|
+
|
|
106
|
+
- its `purpose` leads the assistant's map of the business;
|
|
107
|
+
- it may describe objects that **other installed apps** keep. Narrow them with `where.appId`:
|
|
108
|
+
|
|
109
|
+
```jsonc
|
|
110
|
+
{ "object": "booking", "where": { "appId": "appointment-booking", "data.event": "christmas-fair" }, "means": "A stall at the Christmas fair." }
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- where the site and an app describe the same object, the site's meaning comes first.
|
|
114
|
+
|
|
115
|
+
So "how many bookings for the Christmas fair?" is answered from the right bookings.
|
|
116
|
+
|
|
117
|
+
## Types
|
|
118
|
+
|
|
119
|
+
`AppAssistantDeclaration` (`purpose`, `objects`, `words`, `recipes`), `AssistantObject`, `AssistantRecipe`.
|
package/docs/realtime.md
CHANGED
|
@@ -37,6 +37,26 @@ off()
|
|
|
37
37
|
- **A change carries ids, never data.** Refetch through the normal API, which applies the normal
|
|
38
38
|
permissions, so realtime can never show someone data they couldn't read anyway.
|
|
39
39
|
|
|
40
|
+
### Changes to what your app works on: `onStaffChange`
|
|
41
|
+
|
|
42
|
+
Work orders, containers and stock aren't public and aren't only for admins: the people on a production
|
|
43
|
+
floor or in a warehouse need to see them move. Those changes go to the app's **staff feed**:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// Every screen of a production app refetches when a job, a container or stock changes.
|
|
47
|
+
const off = realtime.onStaffChange({ collectionId, appId }, {}, () => queryClient.invalidateQueries())
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- **Types:** `workOrder` (`id`, `appId`), `container` (`id`, `kind` = its container type), `stock`
|
|
51
|
+
(`id` = the container, `productId`). Filter as with `onChange`: `{ type: 'workOrder', id }`.
|
|
52
|
+
- **What is sent:** a change to one of the app's work orders; a change to a container or stock made
|
|
53
|
+
**by the app's own server functions**; and a change to one of the app's own records (`type: 'record'`,
|
|
54
|
+
with `recordType`), except a person's private ones. Sent after the change is saved, each thing once.
|
|
55
|
+
- **Who hears it:** someone in one of the app's user groups, and collection admins. By default the
|
|
56
|
+
groups are the ones the app's server functions are limited to (`userGroups` on each function).
|
|
57
|
+
To say otherwise, name them: `"realtime": { "staff": ["manager", "warehouse-operative"] }`.
|
|
58
|
+
- **IDs only**, as always: refetch through your own functions, which apply your own rules.
|
|
59
|
+
|
|
40
60
|
With React Query, invalidate on change:
|
|
41
61
|
|
|
42
62
|
```ts
|
package/openapi.yaml
CHANGED
|
@@ -3223,6 +3223,70 @@ paths:
|
|
|
3223
3223
|
application/json:
|
|
3224
3224
|
schema:
|
|
3225
3225
|
$ref: "#/components/schemas/ContactCreateRequest"
|
|
3226
|
+
/admin/collection/{collectionId}/contacts/duplicates:
|
|
3227
|
+
get:
|
|
3228
|
+
tags:
|
|
3229
|
+
- contact
|
|
3230
|
+
summary: "Admin: pairs of contacts that look like one person."
|
|
3231
|
+
operationId: contact_findDuplicates
|
|
3232
|
+
security:
|
|
3233
|
+
- bearerAuth: []
|
|
3234
|
+
parameters:
|
|
3235
|
+
- name: collectionId
|
|
3236
|
+
in: path
|
|
3237
|
+
required: true
|
|
3238
|
+
schema:
|
|
3239
|
+
type: string
|
|
3240
|
+
- name: limit
|
|
3241
|
+
in: query
|
|
3242
|
+
required: false
|
|
3243
|
+
schema:
|
|
3244
|
+
type: string
|
|
3245
|
+
- name: offset
|
|
3246
|
+
in: query
|
|
3247
|
+
required: false
|
|
3248
|
+
schema:
|
|
3249
|
+
type: string
|
|
3250
|
+
responses:
|
|
3251
|
+
200:
|
|
3252
|
+
description: Success
|
|
3253
|
+
content:
|
|
3254
|
+
application/json:
|
|
3255
|
+
schema:
|
|
3256
|
+
$ref: "#/components/schemas/ContactDuplicatesResponse"
|
|
3257
|
+
400:
|
|
3258
|
+
description: Bad request
|
|
3259
|
+
401:
|
|
3260
|
+
description: Unauthorized
|
|
3261
|
+
404:
|
|
3262
|
+
description: Not found
|
|
3263
|
+
/admin/collection/{collectionId}/contacts/link-login:
|
|
3264
|
+
post:
|
|
3265
|
+
tags:
|
|
3266
|
+
- contact
|
|
3267
|
+
summary: "Admin: the contact that carries a sign-in, attaching the sign-in first to the contact that already holds its verified email or phone."
|
|
3268
|
+
operationId: contact_linkLogin
|
|
3269
|
+
security:
|
|
3270
|
+
- bearerAuth: []
|
|
3271
|
+
parameters:
|
|
3272
|
+
- name: collectionId
|
|
3273
|
+
in: path
|
|
3274
|
+
required: true
|
|
3275
|
+
schema:
|
|
3276
|
+
type: string
|
|
3277
|
+
responses:
|
|
3278
|
+
200:
|
|
3279
|
+
description: Success
|
|
3280
|
+
content:
|
|
3281
|
+
application/json:
|
|
3282
|
+
schema:
|
|
3283
|
+
$ref: "#/components/schemas/ContactLinkLoginResponse"
|
|
3284
|
+
400:
|
|
3285
|
+
description: Bad request
|
|
3286
|
+
401:
|
|
3287
|
+
description: Unauthorized
|
|
3288
|
+
404:
|
|
3289
|
+
description: Not found
|
|
3226
3290
|
/admin/collection/{collectionId}/contacts/lookup:
|
|
3227
3291
|
get:
|
|
3228
3292
|
tags:
|
|
@@ -3538,6 +3602,38 @@ paths:
|
|
|
3538
3602
|
description: Unauthorized
|
|
3539
3603
|
404:
|
|
3540
3604
|
description: Not found
|
|
3605
|
+
/admin/collection/{collectionId}/contacts/{keepContactId}/merge:
|
|
3606
|
+
post:
|
|
3607
|
+
tags:
|
|
3608
|
+
- contact
|
|
3609
|
+
summary: "Admin: fold contact `fromContactId` INTO contact `keepContactId`."
|
|
3610
|
+
operationId: contact_merge
|
|
3611
|
+
security:
|
|
3612
|
+
- bearerAuth: []
|
|
3613
|
+
parameters:
|
|
3614
|
+
- name: collectionId
|
|
3615
|
+
in: path
|
|
3616
|
+
required: true
|
|
3617
|
+
schema:
|
|
3618
|
+
type: string
|
|
3619
|
+
- name: keepContactId
|
|
3620
|
+
in: path
|
|
3621
|
+
required: true
|
|
3622
|
+
schema:
|
|
3623
|
+
type: string
|
|
3624
|
+
responses:
|
|
3625
|
+
200:
|
|
3626
|
+
description: Success
|
|
3627
|
+
content:
|
|
3628
|
+
application/json:
|
|
3629
|
+
schema:
|
|
3630
|
+
$ref: "#/components/schemas/ContactMergeResponse"
|
|
3631
|
+
400:
|
|
3632
|
+
description: Bad request
|
|
3633
|
+
401:
|
|
3634
|
+
description: Unauthorized
|
|
3635
|
+
404:
|
|
3636
|
+
description: Not found
|
|
3541
3637
|
/admin/collection/{collectionId}/containers:
|
|
3542
3638
|
get:
|
|
3543
3639
|
tags:
|
|
@@ -21669,6 +21765,8 @@ components:
|
|
|
21669
21765
|
type: string
|
|
21670
21766
|
admin:
|
|
21671
21767
|
type: string
|
|
21768
|
+
adminPage:
|
|
21769
|
+
type: string
|
|
21672
21770
|
widgets:
|
|
21673
21771
|
$ref: "#/components/schemas/AppManifestWidgets"
|
|
21674
21772
|
containers:
|
|
@@ -21699,6 +21797,14 @@ components:
|
|
|
21699
21797
|
realtime:
|
|
21700
21798
|
type: object
|
|
21701
21799
|
additionalProperties: true
|
|
21800
|
+
channels:
|
|
21801
|
+
type: array
|
|
21802
|
+
items:
|
|
21803
|
+
$ref: "#/components/schemas/RealtimeChannelDeclaration"
|
|
21804
|
+
staff:
|
|
21805
|
+
type: array
|
|
21806
|
+
items:
|
|
21807
|
+
type: string
|
|
21702
21808
|
adminCards:
|
|
21703
21809
|
$ref: "#/components/schemas/AppManifestAdminCards"
|
|
21704
21810
|
data:
|
|
@@ -21741,6 +21847,55 @@ components:
|
|
|
21741
21847
|
$ref: "#/components/schemas/AppAssistantFile"
|
|
21742
21848
|
preview:
|
|
21743
21849
|
type: string
|
|
21850
|
+
purpose:
|
|
21851
|
+
type: string
|
|
21852
|
+
objects:
|
|
21853
|
+
type: array
|
|
21854
|
+
items:
|
|
21855
|
+
$ref: "#/components/schemas/AssistantObject"
|
|
21856
|
+
words:
|
|
21857
|
+
type: object
|
|
21858
|
+
additionalProperties:
|
|
21859
|
+
type: string
|
|
21860
|
+
recipes:
|
|
21861
|
+
type: array
|
|
21862
|
+
items:
|
|
21863
|
+
$ref: "#/components/schemas/AssistantRecipe"
|
|
21864
|
+
AssistantObject:
|
|
21865
|
+
type: object
|
|
21866
|
+
properties:
|
|
21867
|
+
object:
|
|
21868
|
+
type: string
|
|
21869
|
+
where:
|
|
21870
|
+
type: object
|
|
21871
|
+
additionalProperties:
|
|
21872
|
+
type: object
|
|
21873
|
+
additionalProperties: true
|
|
21874
|
+
means:
|
|
21875
|
+
type: string
|
|
21876
|
+
fields:
|
|
21877
|
+
type: object
|
|
21878
|
+
additionalProperties:
|
|
21879
|
+
type: string
|
|
21880
|
+
write:
|
|
21881
|
+
type: string
|
|
21882
|
+
enum:
|
|
21883
|
+
- direct
|
|
21884
|
+
- actions
|
|
21885
|
+
- none
|
|
21886
|
+
required:
|
|
21887
|
+
- object
|
|
21888
|
+
- means
|
|
21889
|
+
AssistantRecipe:
|
|
21890
|
+
type: object
|
|
21891
|
+
properties:
|
|
21892
|
+
question:
|
|
21893
|
+
type: string
|
|
21894
|
+
answer:
|
|
21895
|
+
type: string
|
|
21896
|
+
required:
|
|
21897
|
+
- question
|
|
21898
|
+
- answer
|
|
21744
21899
|
ConnectorConnectionField:
|
|
21745
21900
|
type: object
|
|
21746
21901
|
properties:
|
|
@@ -28537,6 +28692,91 @@ components:
|
|
|
28537
28692
|
- items
|
|
28538
28693
|
- limit
|
|
28539
28694
|
- offset
|
|
28695
|
+
ContactDuplicatePair:
|
|
28696
|
+
type: object
|
|
28697
|
+
properties:
|
|
28698
|
+
keep:
|
|
28699
|
+
$ref: "#/components/schemas/Contact"
|
|
28700
|
+
merge:
|
|
28701
|
+
$ref: "#/components/schemas/Contact"
|
|
28702
|
+
matchedOn:
|
|
28703
|
+
type: object
|
|
28704
|
+
additionalProperties: true
|
|
28705
|
+
required:
|
|
28706
|
+
- keep
|
|
28707
|
+
- merge
|
|
28708
|
+
- matchedOn
|
|
28709
|
+
ContactDuplicatesResponse:
|
|
28710
|
+
type: object
|
|
28711
|
+
properties:
|
|
28712
|
+
pairs:
|
|
28713
|
+
type: array
|
|
28714
|
+
items:
|
|
28715
|
+
$ref: "#/components/schemas/ContactDuplicatePair"
|
|
28716
|
+
scanned:
|
|
28717
|
+
type: number
|
|
28718
|
+
more:
|
|
28719
|
+
type: boolean
|
|
28720
|
+
required:
|
|
28721
|
+
- pairs
|
|
28722
|
+
- scanned
|
|
28723
|
+
- more
|
|
28724
|
+
ContactMergeResponse:
|
|
28725
|
+
type: object
|
|
28726
|
+
properties:
|
|
28727
|
+
contactId:
|
|
28728
|
+
type: string
|
|
28729
|
+
mergedFrom:
|
|
28730
|
+
type: string
|
|
28731
|
+
moved:
|
|
28732
|
+
type: object
|
|
28733
|
+
additionalProperties: true
|
|
28734
|
+
login:
|
|
28735
|
+
type: boolean
|
|
28736
|
+
identities:
|
|
28737
|
+
type: number
|
|
28738
|
+
records:
|
|
28739
|
+
type: number
|
|
28740
|
+
cases:
|
|
28741
|
+
type: number
|
|
28742
|
+
threads:
|
|
28743
|
+
type: number
|
|
28744
|
+
bookings:
|
|
28745
|
+
type: number
|
|
28746
|
+
loyaltyMembers:
|
|
28747
|
+
type: number
|
|
28748
|
+
assets:
|
|
28749
|
+
type: number
|
|
28750
|
+
uploadTokens:
|
|
28751
|
+
type: number
|
|
28752
|
+
aiSessions:
|
|
28753
|
+
type: number
|
|
28754
|
+
messages:
|
|
28755
|
+
type: number
|
|
28756
|
+
conversations:
|
|
28757
|
+
type: number
|
|
28758
|
+
contact:
|
|
28759
|
+
$ref: "#/components/schemas/Contact"
|
|
28760
|
+
required:
|
|
28761
|
+
- contactId
|
|
28762
|
+
- mergedFrom
|
|
28763
|
+
- moved
|
|
28764
|
+
- login
|
|
28765
|
+
- identities
|
|
28766
|
+
- contact
|
|
28767
|
+
ContactLinkLoginResponse:
|
|
28768
|
+
type: object
|
|
28769
|
+
properties:
|
|
28770
|
+
contactId:
|
|
28771
|
+
type: string
|
|
28772
|
+
linked:
|
|
28773
|
+
type: boolean
|
|
28774
|
+
contact:
|
|
28775
|
+
$ref: "#/components/schemas/Contact"
|
|
28776
|
+
required:
|
|
28777
|
+
- contactId
|
|
28778
|
+
- linked
|
|
28779
|
+
- contact
|
|
28540
28780
|
ContactSearchParams:
|
|
28541
28781
|
type: object
|
|
28542
28782
|
properties:
|
|
@@ -28904,6 +29144,9 @@ components:
|
|
|
28904
29144
|
$ref: "#/components/schemas/Contact"
|
|
28905
29145
|
ContactUpdateRequest:
|
|
28906
29146
|
$ref: "#/components/schemas/ContactCreateRequest"
|
|
29147
|
+
ContactMergeErrorCode:
|
|
29148
|
+
type: object
|
|
29149
|
+
additionalProperties: true
|
|
28907
29150
|
PublicContactUpsertRequest:
|
|
28908
29151
|
$ref: "#/components/schemas/Contact"
|
|
28909
29152
|
ContactPatch:
|
|
@@ -35373,6 +35616,8 @@ components:
|
|
|
35373
35616
|
type: string
|
|
35374
35617
|
status:
|
|
35375
35618
|
type: string
|
|
35619
|
+
kind:
|
|
35620
|
+
type: string
|
|
35376
35621
|
at:
|
|
35377
35622
|
type: number
|
|
35378
35623
|
required:
|
|
@@ -35393,6 +35638,8 @@ components:
|
|
|
35393
35638
|
type: string
|
|
35394
35639
|
proofId:
|
|
35395
35640
|
type: string
|
|
35641
|
+
kind:
|
|
35642
|
+
type: string
|
|
35396
35643
|
RealtimeChannelDeclaration:
|
|
35397
35644
|
type: object
|
|
35398
35645
|
properties:
|