@proveanything/smartlinks 2.1.39 → 2.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +754 -754
- package/dist/README.md +573 -573
- package/dist/adminCardsView.js +55 -55
- package/dist/adminViews.d.ts +1 -1
- package/dist/adminViews.js +3 -1
- package/dist/ai-tools.d.ts +2 -1
- package/dist/ai-tools.js +3 -0
- package/dist/api/ai.d.ts +2 -21
- package/dist/api/ai.js +0 -35
- package/dist/api/collection.d.ts +8 -1
- package/dist/api/collection.js +10 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/knowledge.d.ts +64 -0
- package/dist/api/knowledge.js +97 -0
- package/dist/baseline.css +194 -194
- package/dist/docs/API_SUMMARY.md +1046 -964
- package/dist/docs/admin-cards.md +189 -189
- package/dist/docs/admin-views.md +257 -255
- package/dist/docs/agent-tools.md +156 -156
- package/dist/docs/ai-tools-and-skills.md +180 -180
- package/dist/docs/ai.md +1721 -1834
- package/dist/docs/analytics.md +39 -39
- package/dist/docs/app-data-storage.md +277 -277
- package/dist/docs/app-docs.md +73 -73
- package/dist/docs/app-manifest.md +852 -852
- package/dist/docs/app-records-pattern.md +388 -388
- package/dist/docs/appConfig.md +550 -550
- package/dist/docs/assistant-apps.md +172 -172
- package/dist/docs/assistant-context.md +119 -119
- package/dist/docs/bookings.md +442 -442
- package/dist/docs/comms.md +686 -686
- package/dist/docs/connectors.md +340 -340
- package/dist/docs/css-baseline.md +133 -133
- package/dist/docs/customer-guide.md +70 -70
- package/dist/docs/deploying-apps.md +340 -340
- package/dist/docs/entitlements.md +90 -90
- package/dist/docs/files.md +69 -69
- package/dist/docs/host-dependency-contract.md +210 -210
- package/dist/docs/integrations.md +322 -322
- package/dist/docs/interactions.md +545 -545
- package/dist/docs/item-context.md +181 -181
- package/dist/docs/knowledge.md +102 -0
- package/dist/docs/lots.md +111 -111
- package/dist/docs/loyalty.md +352 -352
- package/dist/docs/members.md +182 -182
- package/dist/docs/mobile-admin-container.md +693 -693
- package/dist/docs/operations.md +281 -281
- package/dist/docs/overview.md +482 -482
- package/dist/docs/proof-comms-triggers.md +142 -142
- package/dist/docs/proof-ownership-transfer.md +155 -155
- package/dist/docs/proof-product-data-scoping.md +462 -462
- package/dist/docs/proof-share-grants.md +305 -305
- package/dist/docs/realtime.md +138 -138
- package/dist/docs/records-admin-pattern.md +304 -304
- package/dist/docs/standard-query.md +187 -187
- package/dist/docs/tag-codes.md +97 -97
- package/dist/docs/theme-tokens.md +252 -252
- package/dist/docs/wallet-passes.md +107 -107
- package/dist/docs/websites.md +123 -123
- package/dist/openapi.yaml +320 -306
- package/dist/theme-boot.js +78 -78
- package/dist/theme.css +75 -75
- package/dist/types/ai.d.ts +9 -91
- package/dist/types/appManifest.d.ts +21 -0
- package/dist/types/collection.d.ts +26 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/knowledge.d.ts +120 -0
- package/dist/types/knowledge.js +2 -0
- package/docs/API_SUMMARY.md +1046 -964
- package/docs/admin-cards.md +189 -189
- package/docs/admin-views.md +257 -255
- package/docs/agent-tools.md +156 -156
- package/docs/ai-tools-and-skills.md +180 -180
- package/docs/ai.md +1721 -1834
- package/docs/analytics.md +39 -39
- package/docs/app-data-storage.md +277 -277
- package/docs/app-docs.md +73 -73
- package/docs/app-manifest.md +852 -852
- package/docs/app-records-pattern.md +388 -388
- package/docs/appConfig.md +550 -550
- package/docs/assistant-apps.md +172 -172
- package/docs/assistant-context.md +119 -119
- package/docs/bookings.md +442 -442
- package/docs/comms.md +686 -686
- package/docs/connectors.md +340 -340
- package/docs/css-baseline.md +133 -133
- package/docs/customer-guide.md +70 -70
- package/docs/deploying-apps.md +340 -340
- package/docs/entitlements.md +90 -90
- package/docs/files.md +69 -69
- package/docs/host-dependency-contract.md +210 -210
- package/docs/integrations.md +322 -322
- package/docs/interactions.md +545 -545
- package/docs/item-context.md +181 -181
- package/docs/knowledge.md +102 -0
- package/docs/lots.md +111 -111
- package/docs/loyalty.md +352 -352
- package/docs/members.md +182 -182
- package/docs/mobile-admin-container.md +693 -693
- package/docs/operations.md +281 -281
- package/docs/overview.md +482 -482
- package/docs/proof-comms-triggers.md +142 -142
- package/docs/proof-ownership-transfer.md +155 -155
- package/docs/proof-product-data-scoping.md +462 -462
- package/docs/proof-share-grants.md +305 -305
- package/docs/realtime.md +138 -138
- package/docs/standard-query.md +187 -187
- package/docs/tag-codes.md +97 -97
- package/docs/theme-lookbook.v1.json +120 -120
- package/docs/theme-tokens.md +252 -252
- package/docs/wallet-passes.md +107 -107
- package/docs/websites.md +123 -123
- package/openapi.yaml +320 -306
- package/package.json +87 -87
- package/scripts/headless-check.mjs +87 -87
- package/scripts/lib/bare-imports.mjs +57 -57
- package/scripts/lib/keyed-app-data.mjs +21 -21
- package/scripts/publish.mjs +272 -272
- package/scripts/register-release.mjs +91 -91
package/dist/docs/admin-views.md
CHANGED
|
@@ -1,255 +1,257 @@
|
|
|
1
|
-
# Admin views
|
|
2
|
-
|
|
3
|
-
An app's **admin views** are its admin screens by name: "the campaigns list", "one campaign", "bookings
|
|
4
|
-
for a day". The app declares them once, in `app.manifest.json#adminViews`, and three things read the same
|
|
5
|
-
list:
|
|
6
|
-
|
|
7
|
-
| Reader | What it does with the views |
|
|
8
|
-
|---|---|
|
|
9
|
-
| **The app's own side menu** | areas (`main`) in order, Settings (`settings`) at the bottom; opening a record swaps in that record's views |
|
|
10
|
-
| **Studio's workspace menu** (coming) | lifts an app's areas into the business's own menu, then opens the app with `chrome=none` |
|
|
11
|
-
| **The Studio assistant** | opens a view while it talks: "here are Saturday's bookings" |
|
|
12
|
-
|
|
13
|
-
Admin views are not portal pages (`linkable`, see [deep-link-discovery.md](deep-link-discovery.md)) and
|
|
14
|
-
not standalone screens (`publicViews`). They are the admin side only.
|
|
15
|
-
|
|
16
|
-
Core apps with three or more areas follow prove `server/docs/design/core-app-layout.md`. Their side menu
|
|
17
|
-
is built from these views.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Declaring views
|
|
22
|
-
|
|
23
|
-
```json
|
|
24
|
-
"adminViews": [
|
|
25
|
-
{ "id": "campaigns", "title": "Campaigns", "path": "/campaigns", "icon": "megaphone",
|
|
26
|
-
"description": "Campaigns: drafts, scheduled and sent, with their results.",
|
|
27
|
-
"params": { "status": "draft | scheduled | sent" } },
|
|
28
|
-
{ "id": "campaign", "title": "Campaign", "path": "/campaigns/{campaignId}", "group": "record",
|
|
29
|
-
"within": "campaigns", "params": { "campaignId": "a campaign's id" },
|
|
30
|
-
"description": "One campaign: its message, who it goes to, and how it landed." },
|
|
31
|
-
{ "id": "log", "title": "Message log", "path": "/log", "icon": "scroll-text" },
|
|
32
|
-
{ "id": "settings", "title": "Settings", "path": "/settings", "icon": "settings", "group": "settings" }
|
|
33
|
-
]
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
| Field | Meaning |
|
|
37
|
-
|---|---|
|
|
38
|
-
| `id` | Stable, unique in the app. Hosts and the assistant keep it, so never reuse one for another screen. |
|
|
39
|
-
| `title` | The menu label, in the business's words. |
|
|
40
|
-
| `path` | Hash route in the admin page. `{name}` marks a required param. |
|
|
41
|
-
| `group` | `main` (default), an area in the menu. `settings`, pinned at the bottom. `record`, a screen inside one record, never in the main menu. |
|
|
42
|
-
| `within` | The view this one sits in. A record's first view names its area. The record's other views name the record's first view. |
|
|
43
|
-
| `icon` | A [Lucide](https://lucide.dev/icons) name, kebab-case. |
|
|
44
|
-
| `description` | One line on what the screen shows. The assistant reads it to choose a view. |
|
|
45
|
-
| `params` | Each param, with a few words on what it is. `{name}` params are required; the rest are optional query params. Never list platform context (`collectionId`, `appId`, …). |
|
|
46
|
-
|
|
47
|
-
**A record with several screens** (a product with details, proofs and variants):
|
|
48
|
-
|
|
49
|
-
```json
|
|
50
|
-
{ "id": "product", "title": "Details", "path": "/products/{productId}", "group": "record", "within": "products" },
|
|
51
|
-
{ "id": "product.proofs", "title": "Proofs", "path": "/products/{productId}/proofs", "group": "record", "within": "product" },
|
|
52
|
-
{ "id": "product.variants", "title": "Variants", "path": "/products/{productId}/variants", "group": "record", "within": "product" }
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
While a product is open, the menu reads "← Products", then Details, Proofs, Variants.
|
|
56
|
-
|
|
57
|
-
Declare only screens worth opening by name. A dialog, a step inside a form or a filter state is not a
|
|
58
|
-
view; it is a param of one (`status`, `tab`).
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## Building the menu from them
|
|
63
|
-
|
|
64
|
-
Import the manifest so there is one list, and use the helpers:
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
import * as SL from '@proveanything/smartlinks'
|
|
68
|
-
import manifest from '../public/app.manifest.json'
|
|
69
|
-
|
|
70
|
-
const views = manifest.adminViews as SL.AdminView[]
|
|
71
|
-
|
|
72
|
-
SL.adminViews.menu(views) // { main: [...areas], settings: [...] }
|
|
73
|
-
SL.adminViews.match(views, location.pathname) // { view, params } | null — what screen this is
|
|
74
|
-
SL.adminViews.trail(views, 'campaign') // [campaigns, campaign] — campaigns is the current menu item
|
|
75
|
-
SL.adminViews.recordMenu(views, 'campaign') // { back: campaigns, record, items } — the swapped menu
|
|
76
|
-
SL.adminViews.pathFor(views[1], { campaignId }) // '/campaigns/c_1'
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Route the app by these paths, not by a `?tab=` param. The host keeps the path in its own address
|
|
80
|
-
(`?path=`), so a screen survives a reload and can be shared.
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## Following the host: `smartlinks:navigate`
|
|
85
|
-
|
|
86
|
-
The host (Studio, the assistant) asks the app to open a screen without reloading it:
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
host → app { type: 'smartlinks:navigate', view?: 'campaign', params?: { campaignId: 'c_1' }, path?: '/log', highlight?: 'row-id' }
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Register once, near the router:
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
const navigate = useNavigate()
|
|
96
|
-
useEffect(() => SL.adminViews.onNavigate(views, (to) => navigate(to.path)), [navigate])
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
- Registering posts `smartlinks:navigable` to the host. A host that never hears it (an older build)
|
|
100
|
-
reloads the frame at the new path instead.
|
|
101
|
-
- Only messages from the parent window are taken. A `view` is resolved to its path, and a raw `path`
|
|
102
|
-
must be a hash route of this app.
|
|
103
|
-
- After each request the app posts `smartlinks:navigate-result` `{ ok, view, path, reason? }`, so the
|
|
104
|
-
assistant can say when a screen couldn't be opened.
|
|
105
|
-
- `highlight` is optional. It is an id the app understands, such as a row to point at; ignore it if you
|
|
106
|
-
have nothing to point at.
|
|
107
|
-
|
|
108
|
-
Hosts on the SDK use `IframeResponder.navigate(req)`, which returns `false` when the app isn't
|
|
109
|
-
navigable. Hosts with their own frame code use `SL.adminViews.postNavigate(frame.contentWindow, req)`.
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
## Opening another app: `smartlinks:open-app`
|
|
114
|
-
|
|
115
|
-
Apps link to each other's screens. Some examples:
|
|
116
|
-
- Messages opens a person in the CRM.
|
|
117
|
-
- The CRM opens that person's messages.
|
|
118
|
-
- A message about a booking opens the booking.
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
SL.adminViews.openApp({ appId: 'crm', view: 'contact', params: { contactId } })
|
|
122
|
-
// app → host { type: 'smartlinks:open-app', payload: { appId, view?, params?, path? } }
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
- **How the host resolves it.** Studio reads that app's published manifest `adminViews`, fills the
|
|
126
|
-
view's path from `params`, and opens the app there. The other app doesn't need any particular SDK,
|
|
127
|
-
only declared views.
|
|
128
|
-
- **Fallbacks.** An unknown view, or an app without views, opens at its start. A raw `path` (a hash
|
|
129
|
-
route of that app) is used as given.
|
|
130
|
-
- **Only that collection's apps.** The host opens only apps installed in, or core to, the collection
|
|
131
|
-
it is showing.
|
|
132
|
-
- **Name the views you link to** in your docs (`crm: contact`, `messages: log` with `contact`), and
|
|
133
|
-
keep their ids stable: other apps use them.
|
|
134
|
-
|
|
135
|
-
## Opening the platform's screens: `open` by name
|
|
136
|
-
|
|
137
|
-
Your admin screens sit inside Studio, next to the platform's own screens. **Link to them; don't copy them.**
|
|
138
|
-
To message someone, open the Messages composer. To show a person, open their contact. Don't build your own
|
|
139
|
-
email pop-up, contact page or message log.
|
|
140
|
-
|
|
141
|
-
```ts
|
|
142
|
-
// Message this person, tied to the booking: it is logged against the booking and links back to it
|
|
143
|
-
SL.adminViews.open('message.compose', {
|
|
144
|
-
contactId,
|
|
145
|
-
about: { type: 'booking', id: bookingId, view: 'booking', params: { bookingId }, label: 'Sat 3pm' },
|
|
146
|
-
})
|
|
147
|
-
SL.adminViews.open('contact', { contactId }) // the person, in Customers
|
|
148
|
-
SL.adminViews.open('contact.messages', { contactId }) // everything sent to them
|
|
149
|
-
SL.adminViews.open('settings.domain') // a Studio settings page
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
You name **what** to open, never which app has it. Studio decides that, so your link keeps working if
|
|
153
|
-
the screen moves to another app. `open` resolves with `{ ok, reason? }`:
|
|
154
|
-
|
|
155
|
-
| `reason` | Meaning |
|
|
156
|
-
|---|---|
|
|
157
|
-
| `no-host` | Not inside Studio (the admin page opened on its own) |
|
|
158
|
-
| `not-here` | That screen's app isn't on in this business |
|
|
159
|
-
| `unknown` | Studio doesn't know the name |
|
|
160
|
-
| `missing-param` | A required param is missing |
|
|
161
|
-
| `preview` | Forge preview: it showed what would open instead |
|
|
162
|
-
|
|
163
|
-
### Ask first: `canOpen`
|
|
164
|
-
|
|
165
|
-
```ts
|
|
166
|
-
const canMessage = await SL.adminViews.canOpen('message.compose')
|
|
167
|
-
// SL.adminViews.available() → ['contact', 'message.compose', 'settings.domain', …]
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
- If it's `false`, hide the button, or tell the owner what to switch on ("Switch on Messages to send
|
|
171
|
-
messages").
|
|
172
|
-
- Build your own version only when the platform has nothing for it.
|
|
173
|
-
- `canOpen` answers at once inside Studio. With no host, it answers `false` after a short wait.
|
|
174
|
-
|
|
175
|
-
### The names
|
|
176
|
-
|
|
177
|
-
| Name | Params (**required**) | Opens |
|
|
178
|
-
|---|---|---|
|
|
179
|
-
| `contacts` | | The contacts list (Customers) |
|
|
180
|
-
| `contact` | **contactId** | One contact |
|
|
181
|
-
| `contact.messages` | **contactId** | The Message log for that person |
|
|
182
|
-
| `conversation` | **conversationId** | One conversation (Messages) |
|
|
183
|
-
| `segment` | **segmentId** | One segment (Customers) |
|
|
184
|
-
| `contact.conversations` | **contactId** | Their conversations in the Inbox (Messages) |
|
|
185
|
-
| `loyalty.scheme` | **schemeId** | One loyalty scheme (Customers) |
|
|
186
|
-
| `message.compose` | contactId, about | The composer, to that person (or choose who) |
|
|
187
|
-
| `message.log` | contactId, about | The Message log, filtered |
|
|
188
|
-
| `campaign.new` | segmentId | A new campaign to that segment |
|
|
189
|
-
| `campaign` | **campaignId** | One campaign |
|
|
190
|
-
| `templates` | | The email and message templates |
|
|
191
|
-
| `template` | **templateId** | One template in the editor |
|
|
192
|
-
| `product` | **productId** | One product (Items) |
|
|
193
|
-
| `proof` | **productId**, **proofId** | One item of a product |
|
|
194
|
-
| `interaction.type` | **interactionId** | One interaction type (Customers) |
|
|
195
|
-
| `batch` | **productId**, **batchId** | One batch of a product |
|
|
196
|
-
| `variant` | **productId**, **variantId** | One variant of a product |
|
|
197
|
-
| `lot` | **lotId** | One lot |
|
|
198
|
-
| `tags` | | The tags and codes on items |
|
|
199
|
-
| `print` | **productId**, proofId | Print labels and QR codes for a product, or one item |
|
|
200
|
-
| `form` | **formId** | One form, open to edit |
|
|
201
|
-
| `assets` | | The asset register: what the business owns (Assets) |
|
|
202
|
-
| `asset` · `asset.history` | **productId** (its type), **proofId** | One asset, or its history |
|
|
203
|
-
| `places` | | Where assets are kept |
|
|
204
|
-
| `settings` | | Studio → Settings |
|
|
205
|
-
| `settings.address` | `appId`? | Your address: the business's name, front page, app pages (with `appId`, that app's page: where the owner renames it or makes it the front page) and links domain. Put a "Change this address" link beside any link to your app's page. |
|
|
206
|
-
| `settings.domain` · `.languages` · `.translations` · `.email` · `.team` · `.userGroups` | | That Studio page |
|
|
207
|
-
| `settings.setupLists` | appId | Set-up lists, for that app |
|
|
208
|
-
| `settings.billing` | | Billing: plan, invoices, AI credits. Link here when the AI allowance is used up |
|
|
209
|
-
| `settings.
|
|
210
|
-
| `settings.
|
|
211
|
-
| `settings.
|
|
212
|
-
| `
|
|
213
|
-
| `
|
|
214
|
-
|
|
215
|
-
`
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
- **The
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
1
|
+
# Admin views
|
|
2
|
+
|
|
3
|
+
An app's **admin views** are its admin screens by name: "the campaigns list", "one campaign", "bookings
|
|
4
|
+
for a day". The app declares them once, in `app.manifest.json#adminViews`, and three things read the same
|
|
5
|
+
list:
|
|
6
|
+
|
|
7
|
+
| Reader | What it does with the views |
|
|
8
|
+
|---|---|
|
|
9
|
+
| **The app's own side menu** | areas (`main`) in order, Settings (`settings`) at the bottom; opening a record swaps in that record's views |
|
|
10
|
+
| **Studio's workspace menu** (coming) | lifts an app's areas into the business's own menu, then opens the app with `chrome=none` |
|
|
11
|
+
| **The Studio assistant** | opens a view while it talks: "here are Saturday's bookings" |
|
|
12
|
+
|
|
13
|
+
Admin views are not portal pages (`linkable`, see [deep-link-discovery.md](deep-link-discovery.md)) and
|
|
14
|
+
not standalone screens (`publicViews`). They are the admin side only.
|
|
15
|
+
|
|
16
|
+
Core apps with three or more areas follow prove `server/docs/design/core-app-layout.md`. Their side menu
|
|
17
|
+
is built from these views.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Declaring views
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
"adminViews": [
|
|
25
|
+
{ "id": "campaigns", "title": "Campaigns", "path": "/campaigns", "icon": "megaphone",
|
|
26
|
+
"description": "Campaigns: drafts, scheduled and sent, with their results.",
|
|
27
|
+
"params": { "status": "draft | scheduled | sent" } },
|
|
28
|
+
{ "id": "campaign", "title": "Campaign", "path": "/campaigns/{campaignId}", "group": "record",
|
|
29
|
+
"within": "campaigns", "params": { "campaignId": "a campaign's id" },
|
|
30
|
+
"description": "One campaign: its message, who it goes to, and how it landed." },
|
|
31
|
+
{ "id": "log", "title": "Message log", "path": "/log", "icon": "scroll-text" },
|
|
32
|
+
{ "id": "settings", "title": "Settings", "path": "/settings", "icon": "settings", "group": "settings" }
|
|
33
|
+
]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
| Field | Meaning |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `id` | Stable, unique in the app. Hosts and the assistant keep it, so never reuse one for another screen. |
|
|
39
|
+
| `title` | The menu label, in the business's words. |
|
|
40
|
+
| `path` | Hash route in the admin page. `{name}` marks a required param. |
|
|
41
|
+
| `group` | `main` (default), an area in the menu. `settings`, pinned at the bottom. `record`, a screen inside one record, never in the main menu. |
|
|
42
|
+
| `within` | The view this one sits in. A record's first view names its area. The record's other views name the record's first view. |
|
|
43
|
+
| `icon` | A [Lucide](https://lucide.dev/icons) name, kebab-case. |
|
|
44
|
+
| `description` | One line on what the screen shows. The assistant reads it to choose a view. |
|
|
45
|
+
| `params` | Each param, with a few words on what it is. `{name}` params are required; the rest are optional query params. Never list platform context (`collectionId`, `appId`, …). |
|
|
46
|
+
|
|
47
|
+
**A record with several screens** (a product with details, proofs and variants):
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{ "id": "product", "title": "Details", "path": "/products/{productId}", "group": "record", "within": "products" },
|
|
51
|
+
{ "id": "product.proofs", "title": "Proofs", "path": "/products/{productId}/proofs", "group": "record", "within": "product" },
|
|
52
|
+
{ "id": "product.variants", "title": "Variants", "path": "/products/{productId}/variants", "group": "record", "within": "product" }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
While a product is open, the menu reads "← Products", then Details, Proofs, Variants.
|
|
56
|
+
|
|
57
|
+
Declare only screens worth opening by name. A dialog, a step inside a form or a filter state is not a
|
|
58
|
+
view; it is a param of one (`status`, `tab`).
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Building the menu from them
|
|
63
|
+
|
|
64
|
+
Import the manifest so there is one list, and use the helpers:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import * as SL from '@proveanything/smartlinks'
|
|
68
|
+
import manifest from '../public/app.manifest.json'
|
|
69
|
+
|
|
70
|
+
const views = manifest.adminViews as SL.AdminView[]
|
|
71
|
+
|
|
72
|
+
SL.adminViews.menu(views) // { main: [...areas], settings: [...] }
|
|
73
|
+
SL.adminViews.match(views, location.pathname) // { view, params } | null — what screen this is
|
|
74
|
+
SL.adminViews.trail(views, 'campaign') // [campaigns, campaign] — campaigns is the current menu item
|
|
75
|
+
SL.adminViews.recordMenu(views, 'campaign') // { back: campaigns, record, items } — the swapped menu
|
|
76
|
+
SL.adminViews.pathFor(views[1], { campaignId }) // '/campaigns/c_1'
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Route the app by these paths, not by a `?tab=` param. The host keeps the path in its own address
|
|
80
|
+
(`?path=`), so a screen survives a reload and can be shared.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Following the host: `smartlinks:navigate`
|
|
85
|
+
|
|
86
|
+
The host (Studio, the assistant) asks the app to open a screen without reloading it:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
host → app { type: 'smartlinks:navigate', view?: 'campaign', params?: { campaignId: 'c_1' }, path?: '/log', highlight?: 'row-id' }
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Register once, near the router:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const navigate = useNavigate()
|
|
96
|
+
useEffect(() => SL.adminViews.onNavigate(views, (to) => navigate(to.path)), [navigate])
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- Registering posts `smartlinks:navigable` to the host. A host that never hears it (an older build)
|
|
100
|
+
reloads the frame at the new path instead.
|
|
101
|
+
- Only messages from the parent window are taken. A `view` is resolved to its path, and a raw `path`
|
|
102
|
+
must be a hash route of this app.
|
|
103
|
+
- After each request the app posts `smartlinks:navigate-result` `{ ok, view, path, reason? }`, so the
|
|
104
|
+
assistant can say when a screen couldn't be opened.
|
|
105
|
+
- `highlight` is optional. It is an id the app understands, such as a row to point at; ignore it if you
|
|
106
|
+
have nothing to point at.
|
|
107
|
+
|
|
108
|
+
Hosts on the SDK use `IframeResponder.navigate(req)`, which returns `false` when the app isn't
|
|
109
|
+
navigable. Hosts with their own frame code use `SL.adminViews.postNavigate(frame.contentWindow, req)`.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Opening another app: `smartlinks:open-app`
|
|
114
|
+
|
|
115
|
+
Apps link to each other's screens. Some examples:
|
|
116
|
+
- Messages opens a person in the CRM.
|
|
117
|
+
- The CRM opens that person's messages.
|
|
118
|
+
- A message about a booking opens the booking.
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
SL.adminViews.openApp({ appId: 'crm', view: 'contact', params: { contactId } })
|
|
122
|
+
// app → host { type: 'smartlinks:open-app', payload: { appId, view?, params?, path? } }
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
- **How the host resolves it.** Studio reads that app's published manifest `adminViews`, fills the
|
|
126
|
+
view's path from `params`, and opens the app there. The other app doesn't need any particular SDK,
|
|
127
|
+
only declared views.
|
|
128
|
+
- **Fallbacks.** An unknown view, or an app without views, opens at its start. A raw `path` (a hash
|
|
129
|
+
route of that app) is used as given.
|
|
130
|
+
- **Only that collection's apps.** The host opens only apps installed in, or core to, the collection
|
|
131
|
+
it is showing.
|
|
132
|
+
- **Name the views you link to** in your docs (`crm: contact`, `messages: log` with `contact`), and
|
|
133
|
+
keep their ids stable: other apps use them.
|
|
134
|
+
|
|
135
|
+
## Opening the platform's screens: `open` by name
|
|
136
|
+
|
|
137
|
+
Your admin screens sit inside Studio, next to the platform's own screens. **Link to them; don't copy them.**
|
|
138
|
+
To message someone, open the Messages composer. To show a person, open their contact. Don't build your own
|
|
139
|
+
email pop-up, contact page or message log.
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
// Message this person, tied to the booking: it is logged against the booking and links back to it
|
|
143
|
+
SL.adminViews.open('message.compose', {
|
|
144
|
+
contactId,
|
|
145
|
+
about: { type: 'booking', id: bookingId, view: 'booking', params: { bookingId }, label: 'Sat 3pm' },
|
|
146
|
+
})
|
|
147
|
+
SL.adminViews.open('contact', { contactId }) // the person, in Customers
|
|
148
|
+
SL.adminViews.open('contact.messages', { contactId }) // everything sent to them
|
|
149
|
+
SL.adminViews.open('settings.domain') // a Studio settings page
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
You name **what** to open, never which app has it. Studio decides that, so your link keeps working if
|
|
153
|
+
the screen moves to another app. `open` resolves with `{ ok, reason? }`:
|
|
154
|
+
|
|
155
|
+
| `reason` | Meaning |
|
|
156
|
+
|---|---|
|
|
157
|
+
| `no-host` | Not inside Studio (the admin page opened on its own) |
|
|
158
|
+
| `not-here` | That screen's app isn't on in this business |
|
|
159
|
+
| `unknown` | Studio doesn't know the name |
|
|
160
|
+
| `missing-param` | A required param is missing |
|
|
161
|
+
| `preview` | Forge preview: it showed what would open instead |
|
|
162
|
+
|
|
163
|
+
### Ask first: `canOpen`
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
const canMessage = await SL.adminViews.canOpen('message.compose')
|
|
167
|
+
// SL.adminViews.available() → ['contact', 'message.compose', 'settings.domain', …]
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
- If it's `false`, hide the button, or tell the owner what to switch on ("Switch on Messages to send
|
|
171
|
+
messages").
|
|
172
|
+
- Build your own version only when the platform has nothing for it.
|
|
173
|
+
- `canOpen` answers at once inside Studio. With no host, it answers `false` after a short wait.
|
|
174
|
+
|
|
175
|
+
### The names
|
|
176
|
+
|
|
177
|
+
| Name | Params (**required**) | Opens |
|
|
178
|
+
|---|---|---|
|
|
179
|
+
| `contacts` | | The contacts list (Customers) |
|
|
180
|
+
| `contact` | **contactId** | One contact |
|
|
181
|
+
| `contact.messages` | **contactId** | The Message log for that person |
|
|
182
|
+
| `conversation` | **conversationId** | One conversation (Messages) |
|
|
183
|
+
| `segment` | **segmentId** | One segment (Customers) |
|
|
184
|
+
| `contact.conversations` | **contactId** | Their conversations in the Inbox (Messages) |
|
|
185
|
+
| `loyalty.scheme` | **schemeId** | One loyalty scheme (Customers) |
|
|
186
|
+
| `message.compose` | contactId, about | The composer, to that person (or choose who) |
|
|
187
|
+
| `message.log` | contactId, about | The Message log, filtered |
|
|
188
|
+
| `campaign.new` | segmentId | A new campaign to that segment |
|
|
189
|
+
| `campaign` | **campaignId** | One campaign |
|
|
190
|
+
| `templates` | | The email and message templates |
|
|
191
|
+
| `template` | **templateId** | One template in the editor |
|
|
192
|
+
| `product` | **productId** | One product (Items) |
|
|
193
|
+
| `proof` | **productId**, **proofId** | One item of a product |
|
|
194
|
+
| `interaction.type` | **interactionId** | One interaction type (Customers) |
|
|
195
|
+
| `batch` | **productId**, **batchId** | One batch of a product |
|
|
196
|
+
| `variant` | **productId**, **variantId** | One variant of a product |
|
|
197
|
+
| `lot` | **lotId** | One lot |
|
|
198
|
+
| `tags` | | The tags and codes on items |
|
|
199
|
+
| `print` | **productId**, proofId | Print labels and QR codes for a product, or one item |
|
|
200
|
+
| `form` | **formId** | One form, open to edit |
|
|
201
|
+
| `assets` | | The asset register: what the business owns (Assets) |
|
|
202
|
+
| `asset` · `asset.history` | **productId** (its type), **proofId** | One asset, or its history |
|
|
203
|
+
| `places` | | Where assets are kept |
|
|
204
|
+
| `settings` | | Studio → Settings |
|
|
205
|
+
| `settings.address` | `appId`? | Your address: the business's name, front page, app pages (with `appId`, that app's page: where the owner renames it or makes it the front page) and links domain. Put a "Change this address" link beside any link to your app's page. |
|
|
206
|
+
| `settings.domain` · `.languages` · `.translations` · `.email` · `.team` · `.userGroups` | | That Studio page |
|
|
207
|
+
| `settings.setupLists` | appId | Set-up lists, for that app |
|
|
208
|
+
| `settings.billing` | `intent`? | Billing: plan, invoices, AI credits. Link here when the AI allowance is used up. `intent: 'upgrade'` opens on the plans to move up to |
|
|
209
|
+
| `settings.addons` | | Add-ons: features the account can switch on (on enterprise, every feature, each switchable) |
|
|
210
|
+
| `settings.modules` | | Modules: install, reorder and remove the account's apps |
|
|
211
|
+
| `settings.integrations` | | Connections to other systems |
|
|
212
|
+
| `settings.guide` · `settings.translationRules` | | The customer guide · translation rules |
|
|
213
|
+
| `settings.portal` · `.hub` · `.signIn` | | The Portal, the Hub, customer sign-in |
|
|
214
|
+
| `media` | | Images and files |
|
|
215
|
+
| `app` | **appId**, view, params | Another app at one of its screens, as `openApp` |
|
|
216
|
+
|
|
217
|
+
`SL.adminViews.DESTINATIONS` has the same list in code.
|
|
218
|
+
|
|
219
|
+
### `about`: what a message is for
|
|
220
|
+
|
|
221
|
+
`message.compose` and `message.log` take `about`, the same shape as `comms.sendTransactional`
|
|
222
|
+
([comms.md](comms.md), "What a message is about"). `appId` defaults to your app.
|
|
223
|
+
- **The composer** sends it with the message. The Message log then shows the message against your
|
|
224
|
+
record ("Bookings · Sat 3pm"), with a link back to your screen (`view` + `params`).
|
|
225
|
+
- **The log** shows only the messages about that record.
|
|
226
|
+
|
|
227
|
+
### Messaging many people
|
|
228
|
+
|
|
229
|
+
One message to many people (everyone who booked, entered or joined) is a **campaign**: it has opt-in, an
|
|
230
|
+
unsubscribe, a report, and no cap. Never loop over people sending one message each.
|
|
231
|
+
1. Record an interaction or a tag on each person when they book.
|
|
232
|
+
2. Make a segment in Customers for that interaction or tag.
|
|
233
|
+
3. Open `campaign.new` with the segment.
|
|
234
|
+
|
|
235
|
+
A server function may still send one service message itself (a confirmation, a reminder:
|
|
236
|
+
`ctx.sl.messages.send`). A message a person writes goes through the composer.
|
|
237
|
+
|
|
238
|
+
### Hosts
|
|
239
|
+
|
|
240
|
+
The host answers `smartlinks:open` `{ id, to, params, about?, appParams? }` with `smartlinks:open-result`
|
|
241
|
+
`{ id, to, ok, reason? }`. It posts `smartlinks:destinations` `{ available }` on load, on request
|
|
242
|
+
(`smartlinks:destinations-request`) and whenever the list changes. Helpers: `SL.adminViews.postDestinations`
|
|
243
|
+
and `SL.adminViews.postOpenResult`.
|
|
244
|
+
|
|
245
|
+
## `chrome=none`: the host carries the menu
|
|
246
|
+
|
|
247
|
+
When a host's own menu already lists an app's views, it opens the app with `chrome=none`. The app then
|
|
248
|
+
hides its side menu and the bar holding its toggle, and shows only the content. The page header
|
|
249
|
+
(`AdminPageHeader`) stays: it is content.
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
const bare = SL.adminViews.hostChrome() === 'none'
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
`hostChrome()` reads the address the page was first opened at, so the app's own navigation can't lose it.
|
|
256
|
+
With `chrome=none` the app moves between areas only when the host says so (`smartlinks:navigate`).
|
|
257
|
+
Links inside the content, such as opening a campaign from the list, still work as normal.
|