@proveanything/smartlinks 2.1.32 → 2.1.33
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/adminViews.d.ts +86 -0
- package/dist/adminViews.js +178 -0
- package/dist/api/address.d.ts +39 -0
- package/dist/api/address.js +45 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/interactions.d.ts +3 -0
- package/dist/api/interactions.js +3 -0
- package/dist/context.d.ts +5 -0
- package/dist/context.js +4 -1
- package/dist/docs/API_SUMMARY.md +74 -9
- package/dist/docs/admin-views.md +93 -0
- package/dist/docs/app-manifest.md +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/openapi.yaml +81 -0
- package/dist/site.d.ts +5 -0
- package/dist/types/address.d.ts +69 -0
- package/dist/types/address.js +5 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/docs/API_SUMMARY.md +74 -9
- package/docs/admin-views.md +93 -0
- package/docs/app-manifest.md +14 -0
- package/openapi.yaml +81 -0
- package/package.json +1 -1
package/dist/docs/admin-views.md
CHANGED
|
@@ -132,6 +132,99 @@ SL.adminViews.openApp({ appId: 'crm', view: 'contact', params: { contactId } })
|
|
|
132
132
|
- **Name the views you link to** in your docs (`crm: contact`, `messages: log` with `contact`), and
|
|
133
133
|
keep their ids stable: other apps use them.
|
|
134
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
|
+
| `message.compose` | contactId, about | The composer, to that person (or choose who) |
|
|
185
|
+
| `message.log` | contactId, about | The Message log, filtered |
|
|
186
|
+
| `campaign.new` | segmentId | A new campaign to that segment |
|
|
187
|
+
| `campaign` | **campaignId** | One campaign |
|
|
188
|
+
| `templates` | | The email and message templates |
|
|
189
|
+
| `template` | **templateId** | One template in the editor |
|
|
190
|
+
| `product` | **productId** | One product (Items) |
|
|
191
|
+
| `proof` | **productId**, **proofId** | One item of a product |
|
|
192
|
+
| `interaction.type` | **interactionId** | One interaction type (Customers) |
|
|
193
|
+
| `settings` | | Studio → Settings |
|
|
194
|
+
| `settings.domain` · `.languages` · `.translations` · `.email` · `.team` · `.userGroups` | | That Studio page |
|
|
195
|
+
| `settings.setupLists` | appId | Set-up lists, for that app |
|
|
196
|
+
| `settings.portal` · `.hub` · `.signIn` | | The Portal, the Hub, customer sign-in |
|
|
197
|
+
| `media` | | Images and files |
|
|
198
|
+
| `app` | **appId**, view, params | Another app at one of its screens, as `openApp` |
|
|
199
|
+
|
|
200
|
+
`SL.adminViews.DESTINATIONS` has the same list in code.
|
|
201
|
+
|
|
202
|
+
### `about`: what a message is for
|
|
203
|
+
|
|
204
|
+
`message.compose` and `message.log` take `about`, the same shape as `comms.sendTransactional`
|
|
205
|
+
([comms.md](comms.md), "What a message is about"). `appId` defaults to your app.
|
|
206
|
+
- **The composer** sends it with the message. The Message log then shows the message against your
|
|
207
|
+
record ("Bookings · Sat 3pm"), with a link back to your screen (`view` + `params`).
|
|
208
|
+
- **The log** shows only the messages about that record.
|
|
209
|
+
|
|
210
|
+
### Messaging many people
|
|
211
|
+
|
|
212
|
+
One message to many people (everyone who booked, entered or joined) is a **campaign**: it has opt-in, an
|
|
213
|
+
unsubscribe, a report, and no cap. Never loop over people sending one message each.
|
|
214
|
+
1. Record an interaction or a tag on each person when they book.
|
|
215
|
+
2. Make a segment in Customers for that interaction or tag.
|
|
216
|
+
3. Open `campaign.new` with the segment.
|
|
217
|
+
|
|
218
|
+
A server function may still send one service message itself (a confirmation, a reminder:
|
|
219
|
+
`ctx.sl.messages.send`). A message a person writes goes through the composer.
|
|
220
|
+
|
|
221
|
+
### Hosts
|
|
222
|
+
|
|
223
|
+
The host answers `smartlinks:open` `{ id, to, params, about?, appParams? }` with `smartlinks:open-result`
|
|
224
|
+
`{ id, to, ok, reason? }`. It posts `smartlinks:destinations` `{ available }` on load, on request
|
|
225
|
+
(`smartlinks:destinations-request`) and whenever the list changes. Helpers: `SL.adminViews.postDestinations`
|
|
226
|
+
and `SL.adminViews.postOpenResult`.
|
|
227
|
+
|
|
135
228
|
## `chrome=none`: the host carries the menu
|
|
136
229
|
|
|
137
230
|
When a host's own menu already lists an app's views, it opens the app with `chrome=none`. The app then
|
|
@@ -400,6 +400,20 @@ page. Without this, those routes/modes are invisible to the platform and the Dev
|
|
|
400
400
|
|
|
401
401
|
Read the URL params with **`SL.readContext()`** (merges hash → search) instead of hand-rolling it.
|
|
402
402
|
|
|
403
|
+
##### The app's page on the business's address (`/_apps/<name>/`)
|
|
404
|
+
|
|
405
|
+
Every installed app with a public page also answers on the business's own address:
|
|
406
|
+
`https://<business>.smartlinks.host/_apps/<name>/#/your-route` (or their own domain). The name defaults to
|
|
407
|
+
the app id without its publisher handle and the business can rename it. There, the platform tells the page
|
|
408
|
+
who it belongs to, so **the URL carries no `collectionId` or `appId`**:
|
|
409
|
+
|
|
410
|
+
- Read context with **`SL.readContext()`**: it fills `collectionId` and `appId` from the page's address
|
|
411
|
+
when the URL doesn't carry them, and `basePath` (`/_apps/<name>`) for building share links:
|
|
412
|
+
`` `https://${location.host}${ctx.basePath ?? ''}/#/play` ``.
|
|
413
|
+
- Build with a **relative base** (`base: './'` in Vite) so assets load under `/_apps/<name>/`.
|
|
414
|
+
- Use hash routes (`#/play`); the path after `/_apps/<name>/` is served the app's `index.html` either way.
|
|
415
|
+
- Never put `collectionId` in your own share links: the address already says which business it is.
|
|
416
|
+
|
|
403
417
|
##### Public views vs the two portal surfaces
|
|
404
418
|
|
|
405
419
|
An app can have any combination of three setup styles. Only public views are external:
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { iframe } from "./iframe.js";
|
|
|
5
5
|
export { readContext } from "./context.js";
|
|
6
6
|
export * as i18n from "./i18n.js";
|
|
7
7
|
export * as adminViews from "./adminViews.js";
|
|
8
|
-
export type { NavigateRequest, NavigateTarget, OpenAppRequest } from "./adminViews.js";
|
|
8
|
+
export type { NavigateRequest, NavigateTarget, OpenAppRequest, Destination, DestinationInfo, DestinationAbout, OpenParams, OpenResult } from "./adminViews.js";
|
|
9
9
|
export { widgetStyleVars, widgetStyleControls, readableOn, WIDGET_STYLE_VARS } from "./widgetStyle.js";
|
|
10
10
|
export type { WidgetStyling } from "./widgetStyle.js";
|
|
11
11
|
export type { SmartLinksContext } from "./context.js";
|
package/dist/openapi.yaml
CHANGED
|
@@ -17408,6 +17408,87 @@ components:
|
|
|
17408
17408
|
name: X-API-Key
|
|
17409
17409
|
description: API key for server-to-server calls
|
|
17410
17410
|
schemas:
|
|
17411
|
+
AddressPage:
|
|
17412
|
+
type: object
|
|
17413
|
+
properties:
|
|
17414
|
+
appId:
|
|
17415
|
+
type: string
|
|
17416
|
+
title:
|
|
17417
|
+
type: string
|
|
17418
|
+
name:
|
|
17419
|
+
type: string
|
|
17420
|
+
defaultName:
|
|
17421
|
+
type: string
|
|
17422
|
+
listed:
|
|
17423
|
+
type: boolean
|
|
17424
|
+
url:
|
|
17425
|
+
type: string
|
|
17426
|
+
required:
|
|
17427
|
+
- appId
|
|
17428
|
+
- title
|
|
17429
|
+
- name
|
|
17430
|
+
- defaultName
|
|
17431
|
+
- listed
|
|
17432
|
+
- url
|
|
17433
|
+
AddressWebsite:
|
|
17434
|
+
type: object
|
|
17435
|
+
properties:
|
|
17436
|
+
appId:
|
|
17437
|
+
type: string
|
|
17438
|
+
title:
|
|
17439
|
+
type: string
|
|
17440
|
+
live:
|
|
17441
|
+
type: boolean
|
|
17442
|
+
channel:
|
|
17443
|
+
type: string
|
|
17444
|
+
required:
|
|
17445
|
+
- appId
|
|
17446
|
+
- title
|
|
17447
|
+
- live
|
|
17448
|
+
- channel
|
|
17449
|
+
AddressResponse:
|
|
17450
|
+
type: object
|
|
17451
|
+
properties:
|
|
17452
|
+
name:
|
|
17453
|
+
type: string
|
|
17454
|
+
host:
|
|
17455
|
+
type: string
|
|
17456
|
+
defaultHost:
|
|
17457
|
+
type: string
|
|
17458
|
+
domain:
|
|
17459
|
+
type: object
|
|
17460
|
+
additionalProperties: true
|
|
17461
|
+
front:
|
|
17462
|
+
$ref: "#/components/schemas/AddressFront"
|
|
17463
|
+
websites:
|
|
17464
|
+
type: array
|
|
17465
|
+
items:
|
|
17466
|
+
$ref: "#/components/schemas/AddressWebsite"
|
|
17467
|
+
pages:
|
|
17468
|
+
type: array
|
|
17469
|
+
items:
|
|
17470
|
+
$ref: "#/components/schemas/AddressPage"
|
|
17471
|
+
required:
|
|
17472
|
+
- name
|
|
17473
|
+
- host
|
|
17474
|
+
- defaultHost
|
|
17475
|
+
- domain
|
|
17476
|
+
- front
|
|
17477
|
+
- websites
|
|
17478
|
+
- pages
|
|
17479
|
+
AddressNameAvailability:
|
|
17480
|
+
type: object
|
|
17481
|
+
properties:
|
|
17482
|
+
available:
|
|
17483
|
+
type: boolean
|
|
17484
|
+
host:
|
|
17485
|
+
type: string
|
|
17486
|
+
required:
|
|
17487
|
+
- available
|
|
17488
|
+
- host
|
|
17489
|
+
AddressFront:
|
|
17490
|
+
type: object
|
|
17491
|
+
additionalProperties: true
|
|
17411
17492
|
AdminCardRefresh:
|
|
17412
17493
|
type: object
|
|
17413
17494
|
properties:
|
package/dist/site.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export interface SiteContext {
|
|
|
13
13
|
channel: string;
|
|
14
14
|
/** Where search engines consolidate the site (custom domain > chosen name > automatic address). */
|
|
15
15
|
canonicalHost: string;
|
|
16
|
+
/**
|
|
17
|
+
* Set when the app is served as a page under the business's address (`/_apps/<name>`): build links and
|
|
18
|
+
* share buttons to the app from it, e.g. `https://${canonicalHost}${basePath}/`.
|
|
19
|
+
*/
|
|
20
|
+
basePath?: string;
|
|
16
21
|
}
|
|
17
22
|
type HeaderSource = {
|
|
18
23
|
headers: Headers | Record<string, string | string[] | undefined>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A business's ADDRESS (prove docs/design/business-address.md): its name on smartlinks.host, its own
|
|
3
|
+
* domain, what its front page shows, and its apps' public pages under `/_apps/<name>/`.
|
|
4
|
+
*/
|
|
5
|
+
/** What the business's own address shows at its front page. */
|
|
6
|
+
export type AddressFront =
|
|
7
|
+
/** The collection's Hub (the default until the business chooses). `chosen: false` when never chosen. */
|
|
8
|
+
{
|
|
9
|
+
kind: 'hub';
|
|
10
|
+
chosen?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** A website built in Forge, installed on the collection and live (stable). */
|
|
13
|
+
| {
|
|
14
|
+
kind: 'website';
|
|
15
|
+
appId: string;
|
|
16
|
+
}
|
|
17
|
+
/** Send visitors to another address. Temporary (302) unless `permanent`; `keepPath` carries /about → target/about. */
|
|
18
|
+
| {
|
|
19
|
+
kind: 'redirect';
|
|
20
|
+
url: string;
|
|
21
|
+
keepPath?: boolean;
|
|
22
|
+
permanent?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** A simple page with the business's name, logo and the app pages it chose to show. */
|
|
25
|
+
| {
|
|
26
|
+
kind: 'holding';
|
|
27
|
+
};
|
|
28
|
+
/** An installed app's public page on the business's address. */
|
|
29
|
+
export interface AddressPage {
|
|
30
|
+
appId: string;
|
|
31
|
+
/** The app's name as installed. */
|
|
32
|
+
title: string;
|
|
33
|
+
/** The page name: `https://<address>/_apps/<name>/`. */
|
|
34
|
+
name: string;
|
|
35
|
+
/** What the name is when never changed: the app id without its publisher handle. */
|
|
36
|
+
defaultName: string;
|
|
37
|
+
/** Shown on the holding page. */
|
|
38
|
+
listed: boolean;
|
|
39
|
+
/** The full address of the page, on the business's main address. */
|
|
40
|
+
url: string;
|
|
41
|
+
}
|
|
42
|
+
/** A website installed on the collection: what the front page can show. */
|
|
43
|
+
export interface AddressWebsite {
|
|
44
|
+
appId: string;
|
|
45
|
+
title: string;
|
|
46
|
+
/** Live (on stable): only a live website can be the front page. */
|
|
47
|
+
live: boolean;
|
|
48
|
+
channel: string | null;
|
|
49
|
+
}
|
|
50
|
+
export interface AddressResponse {
|
|
51
|
+
/** The business's chosen name, or null when it hasn't chosen one (it uses `defaultHost`). */
|
|
52
|
+
name: string | null;
|
|
53
|
+
/** Its address on smartlinks.host: the chosen name, else the automatic one. */
|
|
54
|
+
host: string;
|
|
55
|
+
/** The automatic address every collection has (`c-<id>.smartlinks.host`). */
|
|
56
|
+
defaultHost: string | null;
|
|
57
|
+
/** Its own domain for its front page, and whether that works yet. */
|
|
58
|
+
domain: {
|
|
59
|
+
host: string;
|
|
60
|
+
live: boolean;
|
|
61
|
+
} | null;
|
|
62
|
+
front: AddressFront;
|
|
63
|
+
websites: AddressWebsite[];
|
|
64
|
+
pages: AddressPage[];
|
|
65
|
+
}
|
|
66
|
+
export interface AddressNameAvailability {
|
|
67
|
+
available: boolean;
|
|
68
|
+
host: string;
|
|
69
|
+
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
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.33 | Generated: 2026-11-20T18:06:02.523Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -137,6 +137,7 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
137
137
|
- **serialNumber** - Assign, lookup, and manage serial numbers across scopes.
|
|
138
138
|
|
|
139
139
|
— Other —
|
|
140
|
+
- **address** - Functions for address operations
|
|
140
141
|
- **adminCards** - Functions for adminCards operations
|
|
141
142
|
- **aiGuide** - Functions for aiGuide operations
|
|
142
143
|
- **analytics** - Functions for analytics operations
|
|
@@ -487,6 +488,53 @@ Examples include:
|
|
|
487
488
|
|
|
488
489
|
## Types
|
|
489
490
|
|
|
491
|
+
### address
|
|
492
|
+
|
|
493
|
+
**AddressPage** (interface)
|
|
494
|
+
```typescript
|
|
495
|
+
interface AddressPage {
|
|
496
|
+
appId: string
|
|
497
|
+
title: string
|
|
498
|
+
name: string
|
|
499
|
+
defaultName: string
|
|
500
|
+
listed: boolean
|
|
501
|
+
url: string
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
**AddressWebsite** (interface)
|
|
506
|
+
```typescript
|
|
507
|
+
interface AddressWebsite {
|
|
508
|
+
appId: string
|
|
509
|
+
title: string
|
|
510
|
+
live: boolean
|
|
511
|
+
channel: string | null
|
|
512
|
+
}
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**AddressResponse** (interface)
|
|
516
|
+
```typescript
|
|
517
|
+
interface AddressResponse {
|
|
518
|
+
name: string | null
|
|
519
|
+
host: string
|
|
520
|
+
defaultHost: string | null
|
|
521
|
+
domain: { host: string; live: boolean } | null
|
|
522
|
+
front: AddressFront
|
|
523
|
+
websites: AddressWebsite[]
|
|
524
|
+
pages: AddressPage[]
|
|
525
|
+
}
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
**AddressNameAvailability** (interface)
|
|
529
|
+
```typescript
|
|
530
|
+
interface AddressNameAvailability {
|
|
531
|
+
available: boolean
|
|
532
|
+
host: string
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
**AddressFront** = ``
|
|
537
|
+
|
|
490
538
|
### adminCards
|
|
491
539
|
|
|
492
540
|
**AdminCardRefresh** (interface)
|
|
@@ -12796,6 +12844,23 @@ interface Gs1DigitalLinkParams {
|
|
|
12796
12844
|
|
|
12797
12845
|
## API Functions
|
|
12798
12846
|
|
|
12847
|
+
### address
|
|
12848
|
+
|
|
12849
|
+
**get**(collectionId: string) → `Promise<AddressResponse>`
|
|
12850
|
+
Everything about the business's address: name, own domain, front page, websites that can take it, app pages.
|
|
12851
|
+
|
|
12852
|
+
**checkName**(collectionId: string, name: string) → `Promise<AddressNameAvailability>`
|
|
12853
|
+
Is this name free? (lower-case letters, numbers and hyphens)
|
|
12854
|
+
|
|
12855
|
+
**setName**(collectionId: string, name: string) → `Promise<`
|
|
12856
|
+
Choose (or change) the business's name: `<name>.smartlinks.host`. The previous name is released.
|
|
12857
|
+
|
|
12858
|
+
**setFront**(collectionId: string, front: AddressFront) → `Promise<`
|
|
12859
|
+
What the front page shows. Applies to the business's name, its automatic address and its own domain together. A website must be installed and live; a redirect must be https and not one of its own addresses.
|
|
12860
|
+
|
|
12861
|
+
**setPage**(collectionId: string, appId: string, change: { name?: string; listed?: boolean }) → `Promise<`
|
|
12862
|
+
Rename an app's page (old names keep redirecting) and/or show it on the holding page.
|
|
12863
|
+
|
|
12799
12864
|
### adminCards
|
|
12800
12865
|
|
|
12801
12866
|
**list**(collectionId: string) → `Promise<AdminCardsResponse>`
|
|
@@ -14568,38 +14633,38 @@ POST /api/v1/public/collection/:collectionId/interactions/submit Submits an inte
|
|
|
14568
14633
|
|
|
14569
14634
|
**ensureType**(collectionId: string,
|
|
14570
14635
|
input: EnsureInteractionTypeInput) → `Promise<InteractionTypeRecord>`
|
|
14571
|
-
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
14636
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, display: { title: 'Cast a vote', description: 'Someone voted in the poll' }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId // Always give display.title: it's the name staff see in the CRM, on activity and when choosing // "everyone who voted" for a segment. (Without one the platform names it from the key.)
|
|
14572
14637
|
|
|
14573
14638
|
**get**(collectionId: string,
|
|
14574
14639
|
id: string) → `Promise<InteractionTypeRecord>`
|
|
14575
|
-
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
14640
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, display: { title: 'Cast a vote', description: 'Someone voted in the poll' }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId // Always give display.title: it's the name staff see in the CRM, on activity and when choosing // "everyone who voted" for a segment. (Without one the platform names it from the key.)
|
|
14576
14641
|
|
|
14577
14642
|
**update**(collectionId: string,
|
|
14578
14643
|
id: string,
|
|
14579
14644
|
patchBody: UpdateInteractionTypeBody) → `Promise<InteractionTypeRecord>`
|
|
14580
|
-
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
14645
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, display: { title: 'Cast a vote', description: 'Someone voted in the poll' }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId // Always give display.title: it's the name staff see in the CRM, on activity and when choosing // "everyone who voted" for a segment. (Without one the platform names it from the key.)
|
|
14581
14646
|
|
|
14582
14647
|
**remove**(collectionId: string,
|
|
14583
14648
|
id: string) → `Promise<void>`
|
|
14584
|
-
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
14649
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, display: { title: 'Cast a vote', description: 'Someone voted in the poll' }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId // Always give display.title: it's the name staff see in the CRM, on activity and when choosing // "everyone who voted" for a segment. (Without one the platform names it from the key.)
|
|
14585
14650
|
|
|
14586
14651
|
**publicCountsByOutcome**(collectionId: string,
|
|
14587
14652
|
body: PublicInteractionsCountsByOutcomeRequest,
|
|
14588
14653
|
authToken?: string) → `Promise<OutcomeCount[]>`
|
|
14589
|
-
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
14654
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, display: { title: 'Cast a vote', description: 'Someone voted in the poll' }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId // Always give display.title: it's the name staff see in the CRM, on activity and when choosing // "everyone who voted" for a segment. (Without one the platform names it from the key.)
|
|
14590
14655
|
|
|
14591
14656
|
**publicMyInteractions**(collectionId: string,
|
|
14592
14657
|
body: PublicInteractionsByUserRequest,
|
|
14593
14658
|
authToken?: string) → `Promise<InteractionEventRow[]>`
|
|
14594
|
-
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
14659
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, display: { title: 'Cast a vote', description: 'Someone voted in the poll' }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId // Always give display.title: it's the name staff see in the CRM, on activity and when choosing // "everyone who voted" for a segment. (Without one the platform names it from the key.)
|
|
14595
14660
|
|
|
14596
14661
|
**publicList**(collectionId: string,
|
|
14597
14662
|
query: ListInteractionTypesQuery = {}) → `Promise<InteractionTypeList>`
|
|
14598
|
-
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
14663
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, display: { title: 'Cast a vote', description: 'Someone voted in the poll' }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId // Always give display.title: it's the name staff see in the CRM, on activity and when choosing // "everyone who voted" for a segment. (Without one the platform names it from the key.)
|
|
14599
14664
|
|
|
14600
14665
|
**publicGet**(collectionId: string,
|
|
14601
14666
|
id: string) → `Promise<InteractionTypeRecord>`
|
|
14602
|
-
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId
|
|
14667
|
+
Find this app's interaction type by its readable `key` (data.interactionType), or create it. Returns the type record — its `id` is the server-minted UUID every event must use. ADMIN only (run it in your admin/setup screen), then store the id in your app config so public code can read it: `interactionIds: { vote: type.id }`. Safe to run on every setup. const vote = await SL.interactions.ensureType(collectionId, { appId: 'my-app', key: 'vote', permissions: { allowPublicSubmit: true, uniquePerUser: true }, display: { title: 'Cast a vote', description: 'Someone voted in the poll' }, }) // vote.id → '52bab6fa-…' — store it in config; never hardcode 'vote' as an interactionId // Always give display.title: it's the name staff see in the CRM, on activity and when choosing // "everyone who voted" for a segment. (Without one the platform names it from the key.)
|
|
14603
14668
|
|
|
14604
14669
|
### jobs
|
|
14605
14670
|
|
package/docs/admin-views.md
CHANGED
|
@@ -132,6 +132,99 @@ SL.adminViews.openApp({ appId: 'crm', view: 'contact', params: { contactId } })
|
|
|
132
132
|
- **Name the views you link to** in your docs (`crm: contact`, `messages: log` with `contact`), and
|
|
133
133
|
keep their ids stable: other apps use them.
|
|
134
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
|
+
| `message.compose` | contactId, about | The composer, to that person (or choose who) |
|
|
185
|
+
| `message.log` | contactId, about | The Message log, filtered |
|
|
186
|
+
| `campaign.new` | segmentId | A new campaign to that segment |
|
|
187
|
+
| `campaign` | **campaignId** | One campaign |
|
|
188
|
+
| `templates` | | The email and message templates |
|
|
189
|
+
| `template` | **templateId** | One template in the editor |
|
|
190
|
+
| `product` | **productId** | One product (Items) |
|
|
191
|
+
| `proof` | **productId**, **proofId** | One item of a product |
|
|
192
|
+
| `interaction.type` | **interactionId** | One interaction type (Customers) |
|
|
193
|
+
| `settings` | | Studio → Settings |
|
|
194
|
+
| `settings.domain` · `.languages` · `.translations` · `.email` · `.team` · `.userGroups` | | That Studio page |
|
|
195
|
+
| `settings.setupLists` | appId | Set-up lists, for that app |
|
|
196
|
+
| `settings.portal` · `.hub` · `.signIn` | | The Portal, the Hub, customer sign-in |
|
|
197
|
+
| `media` | | Images and files |
|
|
198
|
+
| `app` | **appId**, view, params | Another app at one of its screens, as `openApp` |
|
|
199
|
+
|
|
200
|
+
`SL.adminViews.DESTINATIONS` has the same list in code.
|
|
201
|
+
|
|
202
|
+
### `about`: what a message is for
|
|
203
|
+
|
|
204
|
+
`message.compose` and `message.log` take `about`, the same shape as `comms.sendTransactional`
|
|
205
|
+
([comms.md](comms.md), "What a message is about"). `appId` defaults to your app.
|
|
206
|
+
- **The composer** sends it with the message. The Message log then shows the message against your
|
|
207
|
+
record ("Bookings · Sat 3pm"), with a link back to your screen (`view` + `params`).
|
|
208
|
+
- **The log** shows only the messages about that record.
|
|
209
|
+
|
|
210
|
+
### Messaging many people
|
|
211
|
+
|
|
212
|
+
One message to many people (everyone who booked, entered or joined) is a **campaign**: it has opt-in, an
|
|
213
|
+
unsubscribe, a report, and no cap. Never loop over people sending one message each.
|
|
214
|
+
1. Record an interaction or a tag on each person when they book.
|
|
215
|
+
2. Make a segment in Customers for that interaction or tag.
|
|
216
|
+
3. Open `campaign.new` with the segment.
|
|
217
|
+
|
|
218
|
+
A server function may still send one service message itself (a confirmation, a reminder:
|
|
219
|
+
`ctx.sl.messages.send`). A message a person writes goes through the composer.
|
|
220
|
+
|
|
221
|
+
### Hosts
|
|
222
|
+
|
|
223
|
+
The host answers `smartlinks:open` `{ id, to, params, about?, appParams? }` with `smartlinks:open-result`
|
|
224
|
+
`{ id, to, ok, reason? }`. It posts `smartlinks:destinations` `{ available }` on load, on request
|
|
225
|
+
(`smartlinks:destinations-request`) and whenever the list changes. Helpers: `SL.adminViews.postDestinations`
|
|
226
|
+
and `SL.adminViews.postOpenResult`.
|
|
227
|
+
|
|
135
228
|
## `chrome=none`: the host carries the menu
|
|
136
229
|
|
|
137
230
|
When a host's own menu already lists an app's views, it opens the app with `chrome=none`. The app then
|
package/docs/app-manifest.md
CHANGED
|
@@ -400,6 +400,20 @@ page. Without this, those routes/modes are invisible to the platform and the Dev
|
|
|
400
400
|
|
|
401
401
|
Read the URL params with **`SL.readContext()`** (merges hash → search) instead of hand-rolling it.
|
|
402
402
|
|
|
403
|
+
##### The app's page on the business's address (`/_apps/<name>/`)
|
|
404
|
+
|
|
405
|
+
Every installed app with a public page also answers on the business's own address:
|
|
406
|
+
`https://<business>.smartlinks.host/_apps/<name>/#/your-route` (or their own domain). The name defaults to
|
|
407
|
+
the app id without its publisher handle and the business can rename it. There, the platform tells the page
|
|
408
|
+
who it belongs to, so **the URL carries no `collectionId` or `appId`**:
|
|
409
|
+
|
|
410
|
+
- Read context with **`SL.readContext()`**: it fills `collectionId` and `appId` from the page's address
|
|
411
|
+
when the URL doesn't carry them, and `basePath` (`/_apps/<name>`) for building share links:
|
|
412
|
+
`` `https://${location.host}${ctx.basePath ?? ''}/#/play` ``.
|
|
413
|
+
- Build with a **relative base** (`base: './'` in Vite) so assets load under `/_apps/<name>/`.
|
|
414
|
+
- Use hash routes (`#/play`); the path after `/_apps/<name>/` is served the app's `index.html` either way.
|
|
415
|
+
- Never put `collectionId` in your own share links: the address already says which business it is.
|
|
416
|
+
|
|
403
417
|
##### Public views vs the two portal surfaces
|
|
404
418
|
|
|
405
419
|
An app can have any combination of three setup styles. Only public views are external:
|