@proveanything/smartlinks 2.1.47 → 2.2.0
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/api/dpp.d.ts +6 -0
- package/dist/api/dpp.js +12 -0
- package/dist/api/shop.d.ts +5 -1
- package/dist/api/shop.js +7 -7
- package/dist/api/subscriptions.d.ts +2 -1
- package/dist/api/subscriptions.js +4 -12
- package/dist/apiVersion.d.ts +9 -0
- package/dist/apiVersion.js +15 -0
- package/dist/baseline.css +194 -194
- package/dist/docs/API_SUMMARY.md +821 -811
- package/dist/docs/admin-cards.md +189 -189
- package/dist/docs/agent-tools.md +156 -156
- package/dist/docs/ai-tools-and-skills.md +180 -180
- package/dist/docs/ai.md +1721 -1721
- package/dist/docs/analytics.md +39 -39
- package/dist/docs/api-versions.md +76 -0
- 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/dpp.md +115 -99
- 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/i18n.md +9 -9
- 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 -102
- package/dist/docs/lots.md +111 -111
- package/dist/docs/loyalty.md +352 -352
- package/dist/docs/members.md +183 -183
- package/dist/docs/memberships.md +149 -149
- package/dist/docs/mobile-admin-container.md +693 -693
- package/dist/docs/operations.md +281 -281
- package/dist/docs/overview.md +485 -485
- 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/server-functions.md +1 -1
- package/dist/docs/service-accounts.md +64 -64
- 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/http.d.ts +14 -0
- package/dist/http.js +65 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/openapi.yaml +6 -3
- package/dist/theme-boot.js +82 -82
- package/dist/theme.css +75 -75
- package/dist/types/dpp.d.ts +14 -5
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/money.d.ts +15 -0
- package/dist/utils/money.js +72 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/docs/API_SUMMARY.md +821 -811
- package/docs/admin-cards.md +189 -189
- package/docs/agent-tools.md +156 -156
- package/docs/ai-tools-and-skills.md +180 -180
- package/docs/ai.md +1721 -1721
- package/docs/analytics.md +39 -39
- package/docs/api-versions.md +76 -0
- 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/dpp.md +115 -99
- package/docs/entitlements.md +90 -90
- package/docs/files.md +69 -69
- package/docs/host-dependency-contract.md +210 -210
- package/docs/i18n.md +9 -9
- package/docs/integrations.md +322 -322
- package/docs/interactions.md +545 -545
- package/docs/item-context.md +181 -181
- package/docs/knowledge.md +102 -102
- package/docs/lots.md +111 -111
- package/docs/loyalty.md +352 -352
- package/docs/members.md +183 -183
- package/docs/memberships.md +149 -149
- package/docs/mobile-admin-container.md +693 -693
- package/docs/operations.md +281 -281
- package/docs/overview.md +485 -485
- 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/server-functions.md +1 -1
- package/docs/service-accounts.md +64 -64
- 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 +6 -3
- 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/docs/deploying-apps.md
CHANGED
|
@@ -1,340 +1,340 @@
|
|
|
1
|
-
# Deploying & registering an app
|
|
2
|
-
|
|
3
|
-
> **SmartLinks SDK 2.x** (current `latest`). Part of the installable-app platform. Install
|
|
4
|
-
> `@proveanything/smartlinks@^2`.
|
|
5
|
-
|
|
6
|
-
A SmartLinks app is a bundle (widgets, containers, and — new — [server functions](server-functions.md))
|
|
7
|
-
described by an `app.manifest.json`. Deploying an app has two halves:
|
|
8
|
-
|
|
9
|
-
1. **Publish the bundles** to the SmartLinks app CDN.
|
|
10
|
-
2. **Register the release** — tell the SmartLinks backend a new version exists, hand it the
|
|
11
|
-
manifest, and let it validate everything. Registration is what makes the app (and its
|
|
12
|
-
server functions) known, installable, and testable.
|
|
13
|
-
|
|
14
|
-
This guide covers registration and how to wire it into your build.
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Fast dev publish
|
|
19
|
-
|
|
20
|
-
Getting a **dev** build live should be instant and secret-free. There are two paths depending on
|
|
21
|
-
**where you build** — pick the one that matches your setup. Both end the same way: the dev release
|
|
22
|
-
is registered and served **`no-store`** (every reload is instantly fresh — no cache-busting, no CDN
|
|
23
|
-
invalidation).
|
|
24
|
-
|
|
25
|
-
### A. From Lovable — hit Publish, no key anywhere *(recommended for Lovable apps)*
|
|
26
|
-
|
|
27
|
-
Lovable builds and hosts your app on **Publish**. You don't push to us and you **don't put any
|
|
28
|
-
secret in Lovable or your repo** — instead your build *pings* us and we pull your just-published
|
|
29
|
-
bundle. Two small additions to your build, both non-secret:
|
|
30
|
-
|
|
31
|
-
1. **Stamp the build hash into `app.manifest.json`.** In the same build step that content-hashes
|
|
32
|
-
your JS, write the hash into the manifest so we can tell when your new version is live:
|
|
33
|
-
```jsonc
|
|
34
|
-
// app.manifest.json
|
|
35
|
-
"build": { "hash": "a1b2c3d4", "at": "2026-09-20T10:00:00Z" }
|
|
36
|
-
```
|
|
37
|
-
2. **Ping us on publish** (a `postbuild` step — the app id is an *identifier, not a secret*, so it's
|
|
38
|
-
fine in the repo). **Prefer the tiny node wrapper** the example app ships
|
|
39
|
-
(`scripts/smartlinks-deploy.mjs` in `smartlinks-app-example` — copy it): its
|
|
40
|
-
no-key path does exactly this ping and, crucially, **resolves the app id from
|
|
41
|
-
`SMARTLINKS_APP_ID` *or* the manifest's `meta.appId`**, so it works even when no env var is set:
|
|
42
|
-
```js
|
|
43
|
-
// the id-resolution the wrapper uses — env var first, manifest fallback
|
|
44
|
-
const appId = process.env.SMARTLINKS_APP_ID
|
|
45
|
-
|| JSON.parse(fs.readFileSync('public/app.manifest.json')).meta.appId
|
|
46
|
-
```
|
|
47
|
-
```jsonc
|
|
48
|
-
// package.json — wrapper (recommended)
|
|
49
|
-
"scripts": { "postbuild": "node scripts/smartlinks-deploy.mjs" }
|
|
50
|
-
```
|
|
51
|
-
A bare `curl` works too, **but only if `$SMARTLINKS_APP_ID` is actually set in the build env** —
|
|
52
|
-
it has no manifest fallback, so an unset var makes the ping a silent no-op (a common miss):
|
|
53
|
-
```jsonc
|
|
54
|
-
"postbuild": "curl -fsS -X POST \"$SMARTLINKS_API/api/v1/apps/$SMARTLINKS_APP_ID/refresh-dev\" -H 'content-type: application/json' -d \"{\\\"hash\\\":\\\"$BUILD_HASH\\\"}\""
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
That's it — no deploy key. When the ping arrives, SmartLinks looks up your app's published URL
|
|
58
|
-
(from the catalog — **not** from the ping, so it's safe), **waits until your manifest reports that
|
|
59
|
-
exact `build.hash`** (so it never grabs a half-propagated build), validates the manifest + functions,
|
|
60
|
-
and registers the dev release (the hash becomes the version). `POST /apps/{appId}/refresh-dev`
|
|
61
|
-
authorises nothing on its own — worst case it re-fetches your app's own public bundle — so it needs
|
|
62
|
-
no secret; it's rate-limited and de-duped per app.
|
|
63
|
-
|
|
64
|
-
**Where your app learns its own id:** either `SMARTLINKS_APP_ID` (a build-env var) or the manifest's
|
|
65
|
-
`meta.appId`. **Whichever you use must equal your authoritative platform id** — the one in the
|
|
66
|
-
catalog (the `appModules` handle the CDN + every collection's config bind to). On the keyed
|
|
67
|
-
`/releases` path `meta.appId` is *ignored* in favour of the URL id, but for `refresh-dev` the id you
|
|
68
|
-
ping with **is** the lookup key — so if `meta.appId` is blank or has drifted from your platform id,
|
|
69
|
-
the ping resolves the wrong app (or `NO_DEV_URL`). **Stamp `meta.appId` with your real platform id**
|
|
70
|
-
(don't invent one) and the manifest fallback is reliable.
|
|
71
|
-
|
|
72
|
-
**One-time setup:** the app must exist in the catalog with its **id** and its **Lovable URL**
|
|
73
|
-
recorded (that's how we know what to fetch, and the `id` you ping with must match). Ask the platform
|
|
74
|
-
owner to register the app once; after that, every Publish auto-updates dev.
|
|
75
|
-
|
|
76
|
-
**If a publish doesn't appear:** because the ping is fire-and-forget, a failure (e.g. the build
|
|
77
|
-
hash never went live, or an invalid manifest) happens in the background — it won't show in your
|
|
78
|
-
build output. Every attempt (success *and* failure, with the reason) is recorded, and the platform
|
|
79
|
-
owner can see it in the console at **Admin → App Registry → Recent activity**. That's the place to
|
|
80
|
-
look for "I hit Publish but dev didn't change."
|
|
81
|
-
|
|
82
|
-
### B. From local / CI / Claude — `smartlinks-publish`
|
|
83
|
-
|
|
84
|
-
If you build somewhere you control (so you can hold a dev key locally — never committed), push the
|
|
85
|
-
built bundle straight to SmartLinks, which hosts + registers it:
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
# build dist/ first, then:
|
|
89
|
-
smartlinks-publish # uploads dist/ → SmartLinks hosts + registers the dev release
|
|
90
|
-
smartlinks-publish --watch # re-publish on every change (save → live)
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Env: `SMARTLINKS_APP_ID`, `SMARTLINKS_DEPLOY_KEY` (dev key — dev-only, safe to keep locally),
|
|
94
|
-
optional `SMARTLINKS_API` / `--dir`. It POSTs the files to `POST /apps/{appId}/publish?channel=dev`;
|
|
95
|
-
the server validates and writes them to `smartlinks.app/apps/{appId}/dev/…` (`no-store`).
|
|
96
|
-
|
|
97
|
-
- **Big bundles** go in batches (`/publish/files`), and any file of 4 MB or more goes straight to
|
|
98
|
-
storage through a one-off upload URL (`/publish/uploads`), so no file is too large to publish. The
|
|
99
|
-
final `/publish` call registers the release only once every file has landed.
|
|
100
|
-
- **Source maps (`.map`) are never published.** A release is promoted to beta and stable byte for byte,
|
|
101
|
-
so a map would serve the app's original source to anyone; the server drops any it's sent. Debug in
|
|
102
|
-
Forge's preview, where the dev server has full source. In Forge, **Release to dev** builds readable
|
|
103
|
-
(unminified) code; **Release to beta / stable** builds minified code (the build sees
|
|
104
|
-
`SMARTLINKS_BUILD=debug` or `production`).
|
|
105
|
-
|
|
106
|
-
**Which to use:** building in Lovable → **A** (ping, no key). Building anywhere you control →
|
|
107
|
-
**B** (push with a local key). For beta/stable, see the register-a-URL flow below.
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## Two "wheres": the API host vs the bundle CDN
|
|
112
|
-
|
|
113
|
-
Deploying touches two different locations — keep them distinct:
|
|
114
|
-
|
|
115
|
-
1. **The install endpoint (API host)** — *where you register*. On the **main SaaS this is
|
|
116
|
-
`https://smartlinks.app`** (the API lives under `/api/v1` — the same base your app already
|
|
117
|
-
passes to `initializeApi`). A client's isolated (VPC) environment has its **own** host; you
|
|
118
|
-
install into it by calling that host. This is the value that varies per deployment.
|
|
119
|
-
2. **The bundle CDN** — *where your built files are actually served from*, which you pass at
|
|
120
|
-
registration as **`bundleBaseUrl`**. **This depends on the channel:**
|
|
121
|
-
- **`dev` (Lovable):** your files are served by **Lovable at your published app URL** — that
|
|
122
|
-
URL is your dev `bundleBaseUrl`. Lovable *is* the CDN for dev; nothing is uploaded to
|
|
123
|
-
SmartLinks.
|
|
124
|
-
- **`prod`:** files are published to the SmartLinks app CDN at
|
|
125
|
-
`https://smartlinks.app/apps/{appId}/{version}/…` by your prod deploy step; that base is
|
|
126
|
-
your prod `bundleBaseUrl`.
|
|
127
|
-
|
|
128
|
-
```
|
|
129
|
-
https://smartlinks.app/apps/{appId}/{version}/app.manifest.json # prod layout
|
|
130
|
-
https://smartlinks.app/apps/{appId}/{version}/functions.umd.js
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Always pass `bundleBaseUrl` explicitly so it keeps working if a location changes.
|
|
134
|
-
|
|
135
|
-
> **Who publishes the bundles?** The platform does **not** fetch or mirror them for you —
|
|
136
|
-
> `bundleBaseUrl` must already serve the files at registration time. For `dev` that's Lovable
|
|
137
|
-
> (on Publish); for `prod` that's your own CDN deploy step. Registration records *where* the
|
|
138
|
-
> bundles are + the validated manifest; it does not host anything.
|
|
139
|
-
|
|
140
|
-
## Environments & the app registry
|
|
141
|
-
|
|
142
|
-
Historically an app was **stateless everywhere**: every environment fetched the same CDN
|
|
143
|
-
manifest on the fly, so apps were agnostic to shards, clients, and VPCs. Registration changes
|
|
144
|
-
that — an app is now **installed into an environment's registry**, which is **global to that
|
|
145
|
-
environment (not per-collection / not per-shard)**.
|
|
146
|
-
|
|
147
|
-
An **environment** is one SmartLinks deployment: the main SaaS, or a client's isolated (VPC)
|
|
148
|
-
instance. Each owns its own app registry, so:
|
|
149
|
-
|
|
150
|
-
- The **install endpoint's host is the environment** — `POST https://<that-env's-api>/api/v1/apps/…`.
|
|
151
|
-
Installing into a client's VPC means calling *their* API with *their* deploy key.
|
|
152
|
-
- **Rolling out to several environments = the same call, once per target** (different API host
|
|
153
|
-
+ key each). The registration script below takes the API base as a parameter for exactly this.
|
|
154
|
-
|
|
155
|
-
> Enabling an app on a specific **collection** (and consenting to its capabilities) is a
|
|
156
|
-
> separate, per-collection step layered on top of the environment's registry.
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## Channels
|
|
161
|
-
|
|
162
|
-
A release is registered on one **channel**, matching how you deploy:
|
|
163
|
-
|
|
164
|
-
| Channel | Deployed from | Typical use |
|
|
165
|
-
|---|---|---|
|
|
166
|
-
| `dev` | **Lovable "Publish"** | Live development / testing |
|
|
167
|
-
| `alpha` | your pipeline | Early internal testing |
|
|
168
|
-
| `beta` | your pipeline | Staging / preview |
|
|
169
|
-
| `stable`| your **Cloud Build** toolset (from git) | Production |
|
|
170
|
-
|
|
171
|
-
The canonical channels are **`dev` · `alpha` · `beta` · `stable`**. Legacy `prod`/`production`/
|
|
172
|
-
`live` are accepted and normalise to **`stable`** (there is no separate "prod" channel).
|
|
173
|
-
|
|
174
|
-
A collection chooses which channel it follows, so you can point a test collection at `dev`
|
|
175
|
-
and exercise a build before it reaches `prod`.
|
|
176
|
-
|
|
177
|
-
### `preview` — server code while you build (Forge)
|
|
178
|
-
|
|
179
|
-
Forge publishes an app's **server functions only** to a private `preview` channel whenever the
|
|
180
|
-
agent changes them, so the app's own preview can call the new code straight away. It is not a
|
|
181
|
-
channel a collection can follow, release to or promote from. A preview call runs only with the
|
|
182
|
-
**preview pass** Forge gives its preview — for one app on one collection, for a few hours — so
|
|
183
|
-
nobody else ever runs in-progress server code, while the builder can preview against any
|
|
184
|
-
collection they administer. The SDK sends the pass automatically (`SL.functions` with
|
|
185
|
-
`appChannel: 'preview'` and `slPreview` in the context); apps need no code for it. `dev` only
|
|
186
|
-
changes when you choose to release to it.
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## Deploy keys
|
|
191
|
-
|
|
192
|
-
Registration is authenticated by a **deploy key** — not a user login — scoped to the channels
|
|
193
|
-
it may write. Security comes from the *scope*: a leaked key can only do what its scope allows.
|
|
194
|
-
|
|
195
|
-
| Key | Where to keep it | May write | If it leaks |
|
|
196
|
-
|---|---|---|---|
|
|
197
|
-
| **Dev key** | a **Lovable workspace Build Secret** (below) | `dev` channel, **any app in the environment** | someone can register/overwrite `dev` releases — which are served only to test collections — but **never** `beta`/`prod` |
|
|
198
|
-
| **Prod master key** | your CI/Cloud Build secret store **only** | all channels | full control — so keep it out of app source entirely |
|
|
199
|
-
| **Per-app key** *(future)* | provisioned per app | one specific app | scoped to that one app |
|
|
200
|
-
|
|
201
|
-
**Keep the dev key in Lovable Build Secrets — do not commit it.** Lovable exposes
|
|
202
|
-
**workspace-level Build Secrets** shared across every project in the workspace: set the dev key
|
|
203
|
-
there **once** and every microapp inherits it, nothing is committed, and there's a single value
|
|
204
|
-
to rotate. (An earlier draft of this guide said to put the key in app source — don't; use Build
|
|
205
|
-
Secrets.)
|
|
206
|
-
|
|
207
|
-
**Minting (current state, 2.0.0-alpha):** the `dev` and `prod` keys are **shared secrets
|
|
208
|
-
configured on the SmartLinks backend** — one `dev` key and one `prod` key covering all
|
|
209
|
-
first-party apps. There is **no self-service minting UI yet**: ask the platform owner for the
|
|
210
|
-
`dev` key and put it in your workspace Build Secret. Per-app keys, self-service minting, and
|
|
211
|
-
rotation are planned; rotating the shared `dev` key just means updating the one Build Secret
|
|
212
|
-
(registered releases are unaffected — the key authorizes *writes*, it isn't stored on releases).
|
|
213
|
-
|
|
214
|
-
Present the key in the `x-smartlinks-deploy-key` header.
|
|
215
|
-
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
## The registration endpoint
|
|
219
|
-
|
|
220
|
-
```
|
|
221
|
-
POST https://smartlinks.app/api/v1/apps/{appId}/releases # main SaaS; a VPC env uses its own host
|
|
222
|
-
x-smartlinks-deploy-key: <your deploy key>
|
|
223
|
-
Content-Type: application/json
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
```jsonc
|
|
227
|
-
{
|
|
228
|
-
"channel": "dev", // dev | beta | prod
|
|
229
|
-
"version": "1.2.3", // from your manifest meta.version
|
|
230
|
-
"build": { "at": "2026-09-14T10:00:00Z", "gitHash": "abc1234", "builder": "lovable" },
|
|
231
|
-
"manifest": { /* your full app.manifest.json, including the functions block */ },
|
|
232
|
-
"bundleBaseUrl": "https://smartlinks.app/apps/currys/1.2.3"
|
|
233
|
-
}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### Responses
|
|
237
|
-
|
|
238
|
-
| Status | Meaning |
|
|
239
|
-
|---|---|
|
|
240
|
-
| `200` | Registered. Body: `{ ok: true, appId, channel, version, functions: [names], registeredAt, warnings? }` — `warnings` is present for non-blocking issues (e.g. `APPID_IGNORED` when the manifest declared a different id). |
|
|
241
|
-
| `422` | Validation failed — **the build should fail**. Body: `{ ok: false, errors: [...] }` |
|
|
242
|
-
| `401` | Missing/invalid deploy key |
|
|
243
|
-
| `403` | Key not permitted for that channel (e.g. a dev key targeting `prod`) — `CHANNEL_FORBIDDEN` |
|
|
244
|
-
|
|
245
|
-
Each validation error is `{ code, message, path }`, e.g.:
|
|
246
|
-
|
|
247
|
-
```json
|
|
248
|
-
{ "ok": false, "errors": [
|
|
249
|
-
{ "code": "AUTHORITY_INVALID", "message": "invalid authority \"root\"", "path": "functions.definitions[0].authority" },
|
|
250
|
-
{ "code": "CAPABILITY_INVALID", "message": "invalid capability \"bogus\"", "path": "functions.definitions[0].capabilities[0]" }
|
|
251
|
-
]}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
### Re-registering & version collisions
|
|
255
|
-
|
|
256
|
-
Registration is an **upsert keyed by (app, channel)** — the newest registration becomes that
|
|
257
|
-
channel's live release. Registering again **overwrites** it (last write wins); there is **no**
|
|
258
|
-
version-collision error even if `meta.version` is unchanged. So re-publishing to `dev` without
|
|
259
|
-
bumping the version is a normal, intentional overwrite — which is what you want on `dev`. (A
|
|
260
|
-
stricter `prod` policy that rejects a duplicate `version` may come later; it isn't enforced
|
|
261
|
-
today.)
|
|
262
|
-
|
|
263
|
-
### What gets validated
|
|
264
|
-
|
|
265
|
-
- The **app id is the `{appId}` in the URL** — the platform-assigned id, which is authoritative
|
|
266
|
-
(it's what every collection's config + the CDN path already bind to). `manifest.meta.appId` is
|
|
267
|
-
**ignored** for identity: if it differs, the release still registers under the URL id and you get
|
|
268
|
-
a non-blocking `APPID_IGNORED` warning. So pass your **platform id** in the URL (the script below
|
|
269
|
-
reads it from `SMARTLINKS_APP_ID`), and don't rely on the manifest to declare it.
|
|
270
|
-
- The **`functions` block** is validated with the *same* rules the runtime enforces
|
|
271
|
-
(names, triggers, `visibility`/`authority`, the capability grammar, duplicate names) — so
|
|
272
|
-
a malformed server function is caught **at deploy time**, not at runtime. See
|
|
273
|
-
[server-functions.md](server-functions.md).
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
|
-
## Wiring it into your build (the KEYED path — CI / controlled env / beta·stable)
|
|
278
|
-
|
|
279
|
-
> ⚠️ **This is the deploy-key path — not the default for a Lovable dev publish.** If you build in
|
|
280
|
-
> Lovable (no deploy key in the build), your dev publishes register via the **key-free `refresh-dev`
|
|
281
|
-
> ping** in **[Section A](#a-from-lovable--hit-publish-no-key-anywhere-recommended-for-lovable-apps)** — put *that* in `postbuild`, not the
|
|
282
|
-
> binary below. Reach for `smartlinks-register-release` only where you (a) hold a deploy key and
|
|
283
|
-
> (b) set `SMARTLINKS_CHANNEL` — i.e. a controlled dev/CI environment, or a formal **beta/stable**
|
|
284
|
-
> deploy. In a keyless Lovable postbuild this binary **skips silently** (no channel ⇒ no-op), so a
|
|
285
|
-
> dev publish would register *nothing* — that's the trap. One rule: **dev publish → `refresh-dev`;
|
|
286
|
-
> keyed/formal deploy → `register-release`.**
|
|
287
|
-
|
|
288
|
-
Registration is the **last step of a keyed build** — after bundles are built and hashed. Run a
|
|
289
|
-
small script that reads your built manifest and POSTs it, and **exits non-zero on failure**
|
|
290
|
-
so a bad install fails the publish.
|
|
291
|
-
|
|
292
|
-
The SDK ships the script, so you don't copy-paste it — run it as your postbuild step **in a keyed
|
|
293
|
-
environment**. It reads your built manifest, POSTs it, prints any warnings, and exits non-zero on
|
|
294
|
-
failure.
|
|
295
|
-
|
|
296
|
-
```jsonc
|
|
297
|
-
// package.json
|
|
298
|
-
"scripts": {
|
|
299
|
-
"build": "vite build && … && node scripts/hash-bundles.mjs",
|
|
300
|
-
"postbuild": "smartlinks-register-release" // ships in @proveanything/smartlinks
|
|
301
|
-
}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
It is driven entirely by env vars, so the same command works for dev (Lovable) and prod (CI):
|
|
305
|
-
|
|
306
|
-
| Env var | Required | What it is |
|
|
307
|
-
|---|---|---|
|
|
308
|
-
| `SMARTLINKS_APP_ID` | **yes** | your **platform** app id — authoritative, assigned by SmartLinks (per-project). Not the manifest's `meta.appId`. |
|
|
309
|
-
| `SMARTLINKS_DEPLOY_KEY` | yes* | channel-scoped deploy key. *dev builds skip quietly if unset; `beta`/`stable` hard-fail. |
|
|
310
|
-
| `SMARTLINKS_CHANNEL` | the gate | `dev` \| `alpha` \| `beta` \| `stable` (legacy `prod` → `stable`). **UNSET ⇒ skip** (preview builds never register). |
|
|
311
|
-
| `SMARTLINKS_BUNDLE_BASE_URL` | recommended | where the files are served — **dev:** your Lovable URL; **prod:** the CDN base. |
|
|
312
|
-
| `SMARTLINKS_API` | no | API host; default `https://smartlinks.app`. A VPC env uses its own. |
|
|
313
|
-
| `SMARTLINKS_MANIFEST` | no | manifest path; default `dist/app.manifest.json`. |
|
|
314
|
-
|
|
315
|
-
> The full source is at `scripts/register-release.mjs` in the SDK package if you'd rather vendor it.
|
|
316
|
-
|
|
317
|
-
Registration is gated by **`SMARTLINKS_CHANNEL`**, so a keyed build behaves correctly by intent:
|
|
318
|
-
|
|
319
|
-
| Build | `SMARTLINKS_CHANNEL` | Result |
|
|
320
|
-
|---|---|---|
|
|
321
|
-
| **Preview / live-edit / plain Lovable dev publish** | unset | **skips quietly** — never registers, never fails. (A Lovable dev publish is meant to register via the key-free `refresh-dev` ping in [Section A](#a-from-lovable--hit-publish-no-key-anywhere-recommended-for-lovable-apps), not this binary.) |
|
|
322
|
-
| **Controlled dev env (you hold a dev key)** | `dev` | registers to `dev` with the dev key + your `SMARTLINKS_BUNDLE_BASE_URL` |
|
|
323
|
-
| **Prod (CI / formal deploy)** | `stable` | registers to `stable` with the prod/master key; a missing key **hard-fails** |
|
|
324
|
-
|
|
325
|
-
> The middle row is a *controlled* dev environment where you deliberately hold a dev key and set the
|
|
326
|
-
> channel — **not** a stock Lovable publish, which carries neither and so should use `refresh-dev`.
|
|
327
|
-
|
|
328
|
-
**Two secrets, two scopes:** the **deploy key** is channel-scoped and can be a *workspace-level*
|
|
329
|
-
Lovable Build Secret shared by every app (a dev key only writes `dev`, so sharing it is safe). The
|
|
330
|
-
**`SMARTLINKS_APP_ID` is per-app** — set it as a *project-level* variable on each app, so each
|
|
331
|
-
registers under its own authoritative platform id.
|
|
332
|
-
|
|
333
|
-
The gate is `SMARTLINKS_CHANNEL`, so **set it only where you want a release** — i.e. on the
|
|
334
|
-
Publish/CI build, not on preview. If your host exposes a publish-only signal (an env var it sets
|
|
335
|
-
only on Publish), key `SMARTLINKS_CHANNEL` off that; otherwise set it in the Publish build's env
|
|
336
|
-
and leave it unset for preview. That one variable is the difference between "this build ships a
|
|
337
|
-
release" and "this build is just a preview."
|
|
338
|
-
|
|
339
|
-
That's it: a real Publish validates + registers your app (a broken manifest or function stops
|
|
340
|
-
the deploy with an actionable error), while preview builds stay quiet.
|
|
1
|
+
# Deploying & registering an app
|
|
2
|
+
|
|
3
|
+
> **SmartLinks SDK 2.x** (current `latest`). Part of the installable-app platform. Install
|
|
4
|
+
> `@proveanything/smartlinks@^2`.
|
|
5
|
+
|
|
6
|
+
A SmartLinks app is a bundle (widgets, containers, and — new — [server functions](server-functions.md))
|
|
7
|
+
described by an `app.manifest.json`. Deploying an app has two halves:
|
|
8
|
+
|
|
9
|
+
1. **Publish the bundles** to the SmartLinks app CDN.
|
|
10
|
+
2. **Register the release** — tell the SmartLinks backend a new version exists, hand it the
|
|
11
|
+
manifest, and let it validate everything. Registration is what makes the app (and its
|
|
12
|
+
server functions) known, installable, and testable.
|
|
13
|
+
|
|
14
|
+
This guide covers registration and how to wire it into your build.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Fast dev publish
|
|
19
|
+
|
|
20
|
+
Getting a **dev** build live should be instant and secret-free. There are two paths depending on
|
|
21
|
+
**where you build** — pick the one that matches your setup. Both end the same way: the dev release
|
|
22
|
+
is registered and served **`no-store`** (every reload is instantly fresh — no cache-busting, no CDN
|
|
23
|
+
invalidation).
|
|
24
|
+
|
|
25
|
+
### A. From Lovable — hit Publish, no key anywhere *(recommended for Lovable apps)*
|
|
26
|
+
|
|
27
|
+
Lovable builds and hosts your app on **Publish**. You don't push to us and you **don't put any
|
|
28
|
+
secret in Lovable or your repo** — instead your build *pings* us and we pull your just-published
|
|
29
|
+
bundle. Two small additions to your build, both non-secret:
|
|
30
|
+
|
|
31
|
+
1. **Stamp the build hash into `app.manifest.json`.** In the same build step that content-hashes
|
|
32
|
+
your JS, write the hash into the manifest so we can tell when your new version is live:
|
|
33
|
+
```jsonc
|
|
34
|
+
// app.manifest.json
|
|
35
|
+
"build": { "hash": "a1b2c3d4", "at": "2026-09-20T10:00:00Z" }
|
|
36
|
+
```
|
|
37
|
+
2. **Ping us on publish** (a `postbuild` step — the app id is an *identifier, not a secret*, so it's
|
|
38
|
+
fine in the repo). **Prefer the tiny node wrapper** the example app ships
|
|
39
|
+
(`scripts/smartlinks-deploy.mjs` in `smartlinks-app-example` — copy it): its
|
|
40
|
+
no-key path does exactly this ping and, crucially, **resolves the app id from
|
|
41
|
+
`SMARTLINKS_APP_ID` *or* the manifest's `meta.appId`**, so it works even when no env var is set:
|
|
42
|
+
```js
|
|
43
|
+
// the id-resolution the wrapper uses — env var first, manifest fallback
|
|
44
|
+
const appId = process.env.SMARTLINKS_APP_ID
|
|
45
|
+
|| JSON.parse(fs.readFileSync('public/app.manifest.json')).meta.appId
|
|
46
|
+
```
|
|
47
|
+
```jsonc
|
|
48
|
+
// package.json — wrapper (recommended)
|
|
49
|
+
"scripts": { "postbuild": "node scripts/smartlinks-deploy.mjs" }
|
|
50
|
+
```
|
|
51
|
+
A bare `curl` works too, **but only if `$SMARTLINKS_APP_ID` is actually set in the build env** —
|
|
52
|
+
it has no manifest fallback, so an unset var makes the ping a silent no-op (a common miss):
|
|
53
|
+
```jsonc
|
|
54
|
+
"postbuild": "curl -fsS -X POST \"$SMARTLINKS_API/api/v1/apps/$SMARTLINKS_APP_ID/refresh-dev\" -H 'content-type: application/json' -d \"{\\\"hash\\\":\\\"$BUILD_HASH\\\"}\""
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
That's it — no deploy key. When the ping arrives, SmartLinks looks up your app's published URL
|
|
58
|
+
(from the catalog — **not** from the ping, so it's safe), **waits until your manifest reports that
|
|
59
|
+
exact `build.hash`** (so it never grabs a half-propagated build), validates the manifest + functions,
|
|
60
|
+
and registers the dev release (the hash becomes the version). `POST /apps/{appId}/refresh-dev`
|
|
61
|
+
authorises nothing on its own — worst case it re-fetches your app's own public bundle — so it needs
|
|
62
|
+
no secret; it's rate-limited and de-duped per app.
|
|
63
|
+
|
|
64
|
+
**Where your app learns its own id:** either `SMARTLINKS_APP_ID` (a build-env var) or the manifest's
|
|
65
|
+
`meta.appId`. **Whichever you use must equal your authoritative platform id** — the one in the
|
|
66
|
+
catalog (the `appModules` handle the CDN + every collection's config bind to). On the keyed
|
|
67
|
+
`/releases` path `meta.appId` is *ignored* in favour of the URL id, but for `refresh-dev` the id you
|
|
68
|
+
ping with **is** the lookup key — so if `meta.appId` is blank or has drifted from your platform id,
|
|
69
|
+
the ping resolves the wrong app (or `NO_DEV_URL`). **Stamp `meta.appId` with your real platform id**
|
|
70
|
+
(don't invent one) and the manifest fallback is reliable.
|
|
71
|
+
|
|
72
|
+
**One-time setup:** the app must exist in the catalog with its **id** and its **Lovable URL**
|
|
73
|
+
recorded (that's how we know what to fetch, and the `id` you ping with must match). Ask the platform
|
|
74
|
+
owner to register the app once; after that, every Publish auto-updates dev.
|
|
75
|
+
|
|
76
|
+
**If a publish doesn't appear:** because the ping is fire-and-forget, a failure (e.g. the build
|
|
77
|
+
hash never went live, or an invalid manifest) happens in the background — it won't show in your
|
|
78
|
+
build output. Every attempt (success *and* failure, with the reason) is recorded, and the platform
|
|
79
|
+
owner can see it in the console at **Admin → App Registry → Recent activity**. That's the place to
|
|
80
|
+
look for "I hit Publish but dev didn't change."
|
|
81
|
+
|
|
82
|
+
### B. From local / CI / Claude — `smartlinks-publish`
|
|
83
|
+
|
|
84
|
+
If you build somewhere you control (so you can hold a dev key locally — never committed), push the
|
|
85
|
+
built bundle straight to SmartLinks, which hosts + registers it:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# build dist/ first, then:
|
|
89
|
+
smartlinks-publish # uploads dist/ → SmartLinks hosts + registers the dev release
|
|
90
|
+
smartlinks-publish --watch # re-publish on every change (save → live)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Env: `SMARTLINKS_APP_ID`, `SMARTLINKS_DEPLOY_KEY` (dev key — dev-only, safe to keep locally),
|
|
94
|
+
optional `SMARTLINKS_API` / `--dir`. It POSTs the files to `POST /apps/{appId}/publish?channel=dev`;
|
|
95
|
+
the server validates and writes them to `smartlinks.app/apps/{appId}/dev/…` (`no-store`).
|
|
96
|
+
|
|
97
|
+
- **Big bundles** go in batches (`/publish/files`), and any file of 4 MB or more goes straight to
|
|
98
|
+
storage through a one-off upload URL (`/publish/uploads`), so no file is too large to publish. The
|
|
99
|
+
final `/publish` call registers the release only once every file has landed.
|
|
100
|
+
- **Source maps (`.map`) are never published.** A release is promoted to beta and stable byte for byte,
|
|
101
|
+
so a map would serve the app's original source to anyone; the server drops any it's sent. Debug in
|
|
102
|
+
Forge's preview, where the dev server has full source. In Forge, **Release to dev** builds readable
|
|
103
|
+
(unminified) code; **Release to beta / stable** builds minified code (the build sees
|
|
104
|
+
`SMARTLINKS_BUILD=debug` or `production`).
|
|
105
|
+
|
|
106
|
+
**Which to use:** building in Lovable → **A** (ping, no key). Building anywhere you control →
|
|
107
|
+
**B** (push with a local key). For beta/stable, see the register-a-URL flow below.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Two "wheres": the API host vs the bundle CDN
|
|
112
|
+
|
|
113
|
+
Deploying touches two different locations — keep them distinct:
|
|
114
|
+
|
|
115
|
+
1. **The install endpoint (API host)** — *where you register*. On the **main SaaS this is
|
|
116
|
+
`https://smartlinks.app`** (the API lives under `/api/v1` — the same base your app already
|
|
117
|
+
passes to `initializeApi`). A client's isolated (VPC) environment has its **own** host; you
|
|
118
|
+
install into it by calling that host. This is the value that varies per deployment.
|
|
119
|
+
2. **The bundle CDN** — *where your built files are actually served from*, which you pass at
|
|
120
|
+
registration as **`bundleBaseUrl`**. **This depends on the channel:**
|
|
121
|
+
- **`dev` (Lovable):** your files are served by **Lovable at your published app URL** — that
|
|
122
|
+
URL is your dev `bundleBaseUrl`. Lovable *is* the CDN for dev; nothing is uploaded to
|
|
123
|
+
SmartLinks.
|
|
124
|
+
- **`prod`:** files are published to the SmartLinks app CDN at
|
|
125
|
+
`https://smartlinks.app/apps/{appId}/{version}/…` by your prod deploy step; that base is
|
|
126
|
+
your prod `bundleBaseUrl`.
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
https://smartlinks.app/apps/{appId}/{version}/app.manifest.json # prod layout
|
|
130
|
+
https://smartlinks.app/apps/{appId}/{version}/functions.umd.js
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Always pass `bundleBaseUrl` explicitly so it keeps working if a location changes.
|
|
134
|
+
|
|
135
|
+
> **Who publishes the bundles?** The platform does **not** fetch or mirror them for you —
|
|
136
|
+
> `bundleBaseUrl` must already serve the files at registration time. For `dev` that's Lovable
|
|
137
|
+
> (on Publish); for `prod` that's your own CDN deploy step. Registration records *where* the
|
|
138
|
+
> bundles are + the validated manifest; it does not host anything.
|
|
139
|
+
|
|
140
|
+
## Environments & the app registry
|
|
141
|
+
|
|
142
|
+
Historically an app was **stateless everywhere**: every environment fetched the same CDN
|
|
143
|
+
manifest on the fly, so apps were agnostic to shards, clients, and VPCs. Registration changes
|
|
144
|
+
that — an app is now **installed into an environment's registry**, which is **global to that
|
|
145
|
+
environment (not per-collection / not per-shard)**.
|
|
146
|
+
|
|
147
|
+
An **environment** is one SmartLinks deployment: the main SaaS, or a client's isolated (VPC)
|
|
148
|
+
instance. Each owns its own app registry, so:
|
|
149
|
+
|
|
150
|
+
- The **install endpoint's host is the environment** — `POST https://<that-env's-api>/api/v1/apps/…`.
|
|
151
|
+
Installing into a client's VPC means calling *their* API with *their* deploy key.
|
|
152
|
+
- **Rolling out to several environments = the same call, once per target** (different API host
|
|
153
|
+
+ key each). The registration script below takes the API base as a parameter for exactly this.
|
|
154
|
+
|
|
155
|
+
> Enabling an app on a specific **collection** (and consenting to its capabilities) is a
|
|
156
|
+
> separate, per-collection step layered on top of the environment's registry.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Channels
|
|
161
|
+
|
|
162
|
+
A release is registered on one **channel**, matching how you deploy:
|
|
163
|
+
|
|
164
|
+
| Channel | Deployed from | Typical use |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| `dev` | **Lovable "Publish"** | Live development / testing |
|
|
167
|
+
| `alpha` | your pipeline | Early internal testing |
|
|
168
|
+
| `beta` | your pipeline | Staging / preview |
|
|
169
|
+
| `stable`| your **Cloud Build** toolset (from git) | Production |
|
|
170
|
+
|
|
171
|
+
The canonical channels are **`dev` · `alpha` · `beta` · `stable`**. Legacy `prod`/`production`/
|
|
172
|
+
`live` are accepted and normalise to **`stable`** (there is no separate "prod" channel).
|
|
173
|
+
|
|
174
|
+
A collection chooses which channel it follows, so you can point a test collection at `dev`
|
|
175
|
+
and exercise a build before it reaches `prod`.
|
|
176
|
+
|
|
177
|
+
### `preview` — server code while you build (Forge)
|
|
178
|
+
|
|
179
|
+
Forge publishes an app's **server functions only** to a private `preview` channel whenever the
|
|
180
|
+
agent changes them, so the app's own preview can call the new code straight away. It is not a
|
|
181
|
+
channel a collection can follow, release to or promote from. A preview call runs only with the
|
|
182
|
+
**preview pass** Forge gives its preview — for one app on one collection, for a few hours — so
|
|
183
|
+
nobody else ever runs in-progress server code, while the builder can preview against any
|
|
184
|
+
collection they administer. The SDK sends the pass automatically (`SL.functions` with
|
|
185
|
+
`appChannel: 'preview'` and `slPreview` in the context); apps need no code for it. `dev` only
|
|
186
|
+
changes when you choose to release to it.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Deploy keys
|
|
191
|
+
|
|
192
|
+
Registration is authenticated by a **deploy key** — not a user login — scoped to the channels
|
|
193
|
+
it may write. Security comes from the *scope*: a leaked key can only do what its scope allows.
|
|
194
|
+
|
|
195
|
+
| Key | Where to keep it | May write | If it leaks |
|
|
196
|
+
|---|---|---|---|
|
|
197
|
+
| **Dev key** | a **Lovable workspace Build Secret** (below) | `dev` channel, **any app in the environment** | someone can register/overwrite `dev` releases — which are served only to test collections — but **never** `beta`/`prod` |
|
|
198
|
+
| **Prod master key** | your CI/Cloud Build secret store **only** | all channels | full control — so keep it out of app source entirely |
|
|
199
|
+
| **Per-app key** *(future)* | provisioned per app | one specific app | scoped to that one app |
|
|
200
|
+
|
|
201
|
+
**Keep the dev key in Lovable Build Secrets — do not commit it.** Lovable exposes
|
|
202
|
+
**workspace-level Build Secrets** shared across every project in the workspace: set the dev key
|
|
203
|
+
there **once** and every microapp inherits it, nothing is committed, and there's a single value
|
|
204
|
+
to rotate. (An earlier draft of this guide said to put the key in app source — don't; use Build
|
|
205
|
+
Secrets.)
|
|
206
|
+
|
|
207
|
+
**Minting (current state, 2.0.0-alpha):** the `dev` and `prod` keys are **shared secrets
|
|
208
|
+
configured on the SmartLinks backend** — one `dev` key and one `prod` key covering all
|
|
209
|
+
first-party apps. There is **no self-service minting UI yet**: ask the platform owner for the
|
|
210
|
+
`dev` key and put it in your workspace Build Secret. Per-app keys, self-service minting, and
|
|
211
|
+
rotation are planned; rotating the shared `dev` key just means updating the one Build Secret
|
|
212
|
+
(registered releases are unaffected — the key authorizes *writes*, it isn't stored on releases).
|
|
213
|
+
|
|
214
|
+
Present the key in the `x-smartlinks-deploy-key` header.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## The registration endpoint
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
POST https://smartlinks.app/api/v1/apps/{appId}/releases # main SaaS; a VPC env uses its own host
|
|
222
|
+
x-smartlinks-deploy-key: <your deploy key>
|
|
223
|
+
Content-Type: application/json
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
```jsonc
|
|
227
|
+
{
|
|
228
|
+
"channel": "dev", // dev | beta | prod
|
|
229
|
+
"version": "1.2.3", // from your manifest meta.version
|
|
230
|
+
"build": { "at": "2026-09-14T10:00:00Z", "gitHash": "abc1234", "builder": "lovable" },
|
|
231
|
+
"manifest": { /* your full app.manifest.json, including the functions block */ },
|
|
232
|
+
"bundleBaseUrl": "https://smartlinks.app/apps/currys/1.2.3"
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Responses
|
|
237
|
+
|
|
238
|
+
| Status | Meaning |
|
|
239
|
+
|---|---|
|
|
240
|
+
| `200` | Registered. Body: `{ ok: true, appId, channel, version, functions: [names], registeredAt, warnings? }` — `warnings` is present for non-blocking issues (e.g. `APPID_IGNORED` when the manifest declared a different id). |
|
|
241
|
+
| `422` | Validation failed — **the build should fail**. Body: `{ ok: false, errors: [...] }` |
|
|
242
|
+
| `401` | Missing/invalid deploy key |
|
|
243
|
+
| `403` | Key not permitted for that channel (e.g. a dev key targeting `prod`) — `CHANNEL_FORBIDDEN` |
|
|
244
|
+
|
|
245
|
+
Each validation error is `{ code, message, path }`, e.g.:
|
|
246
|
+
|
|
247
|
+
```json
|
|
248
|
+
{ "ok": false, "errors": [
|
|
249
|
+
{ "code": "AUTHORITY_INVALID", "message": "invalid authority \"root\"", "path": "functions.definitions[0].authority" },
|
|
250
|
+
{ "code": "CAPABILITY_INVALID", "message": "invalid capability \"bogus\"", "path": "functions.definitions[0].capabilities[0]" }
|
|
251
|
+
]}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Re-registering & version collisions
|
|
255
|
+
|
|
256
|
+
Registration is an **upsert keyed by (app, channel)** — the newest registration becomes that
|
|
257
|
+
channel's live release. Registering again **overwrites** it (last write wins); there is **no**
|
|
258
|
+
version-collision error even if `meta.version` is unchanged. So re-publishing to `dev` without
|
|
259
|
+
bumping the version is a normal, intentional overwrite — which is what you want on `dev`. (A
|
|
260
|
+
stricter `prod` policy that rejects a duplicate `version` may come later; it isn't enforced
|
|
261
|
+
today.)
|
|
262
|
+
|
|
263
|
+
### What gets validated
|
|
264
|
+
|
|
265
|
+
- The **app id is the `{appId}` in the URL** — the platform-assigned id, which is authoritative
|
|
266
|
+
(it's what every collection's config + the CDN path already bind to). `manifest.meta.appId` is
|
|
267
|
+
**ignored** for identity: if it differs, the release still registers under the URL id and you get
|
|
268
|
+
a non-blocking `APPID_IGNORED` warning. So pass your **platform id** in the URL (the script below
|
|
269
|
+
reads it from `SMARTLINKS_APP_ID`), and don't rely on the manifest to declare it.
|
|
270
|
+
- The **`functions` block** is validated with the *same* rules the runtime enforces
|
|
271
|
+
(names, triggers, `visibility`/`authority`, the capability grammar, duplicate names) — so
|
|
272
|
+
a malformed server function is caught **at deploy time**, not at runtime. See
|
|
273
|
+
[server-functions.md](server-functions.md).
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Wiring it into your build (the KEYED path — CI / controlled env / beta·stable)
|
|
278
|
+
|
|
279
|
+
> ⚠️ **This is the deploy-key path — not the default for a Lovable dev publish.** If you build in
|
|
280
|
+
> Lovable (no deploy key in the build), your dev publishes register via the **key-free `refresh-dev`
|
|
281
|
+
> ping** in **[Section A](#a-from-lovable--hit-publish-no-key-anywhere-recommended-for-lovable-apps)** — put *that* in `postbuild`, not the
|
|
282
|
+
> binary below. Reach for `smartlinks-register-release` only where you (a) hold a deploy key and
|
|
283
|
+
> (b) set `SMARTLINKS_CHANNEL` — i.e. a controlled dev/CI environment, or a formal **beta/stable**
|
|
284
|
+
> deploy. In a keyless Lovable postbuild this binary **skips silently** (no channel ⇒ no-op), so a
|
|
285
|
+
> dev publish would register *nothing* — that's the trap. One rule: **dev publish → `refresh-dev`;
|
|
286
|
+
> keyed/formal deploy → `register-release`.**
|
|
287
|
+
|
|
288
|
+
Registration is the **last step of a keyed build** — after bundles are built and hashed. Run a
|
|
289
|
+
small script that reads your built manifest and POSTs it, and **exits non-zero on failure**
|
|
290
|
+
so a bad install fails the publish.
|
|
291
|
+
|
|
292
|
+
The SDK ships the script, so you don't copy-paste it — run it as your postbuild step **in a keyed
|
|
293
|
+
environment**. It reads your built manifest, POSTs it, prints any warnings, and exits non-zero on
|
|
294
|
+
failure.
|
|
295
|
+
|
|
296
|
+
```jsonc
|
|
297
|
+
// package.json
|
|
298
|
+
"scripts": {
|
|
299
|
+
"build": "vite build && … && node scripts/hash-bundles.mjs",
|
|
300
|
+
"postbuild": "smartlinks-register-release" // ships in @proveanything/smartlinks
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
It is driven entirely by env vars, so the same command works for dev (Lovable) and prod (CI):
|
|
305
|
+
|
|
306
|
+
| Env var | Required | What it is |
|
|
307
|
+
|---|---|---|
|
|
308
|
+
| `SMARTLINKS_APP_ID` | **yes** | your **platform** app id — authoritative, assigned by SmartLinks (per-project). Not the manifest's `meta.appId`. |
|
|
309
|
+
| `SMARTLINKS_DEPLOY_KEY` | yes* | channel-scoped deploy key. *dev builds skip quietly if unset; `beta`/`stable` hard-fail. |
|
|
310
|
+
| `SMARTLINKS_CHANNEL` | the gate | `dev` \| `alpha` \| `beta` \| `stable` (legacy `prod` → `stable`). **UNSET ⇒ skip** (preview builds never register). |
|
|
311
|
+
| `SMARTLINKS_BUNDLE_BASE_URL` | recommended | where the files are served — **dev:** your Lovable URL; **prod:** the CDN base. |
|
|
312
|
+
| `SMARTLINKS_API` | no | API host; default `https://smartlinks.app`. A VPC env uses its own. |
|
|
313
|
+
| `SMARTLINKS_MANIFEST` | no | manifest path; default `dist/app.manifest.json`. |
|
|
314
|
+
|
|
315
|
+
> The full source is at `scripts/register-release.mjs` in the SDK package if you'd rather vendor it.
|
|
316
|
+
|
|
317
|
+
Registration is gated by **`SMARTLINKS_CHANNEL`**, so a keyed build behaves correctly by intent:
|
|
318
|
+
|
|
319
|
+
| Build | `SMARTLINKS_CHANNEL` | Result |
|
|
320
|
+
|---|---|---|
|
|
321
|
+
| **Preview / live-edit / plain Lovable dev publish** | unset | **skips quietly** — never registers, never fails. (A Lovable dev publish is meant to register via the key-free `refresh-dev` ping in [Section A](#a-from-lovable--hit-publish-no-key-anywhere-recommended-for-lovable-apps), not this binary.) |
|
|
322
|
+
| **Controlled dev env (you hold a dev key)** | `dev` | registers to `dev` with the dev key + your `SMARTLINKS_BUNDLE_BASE_URL` |
|
|
323
|
+
| **Prod (CI / formal deploy)** | `stable` | registers to `stable` with the prod/master key; a missing key **hard-fails** |
|
|
324
|
+
|
|
325
|
+
> The middle row is a *controlled* dev environment where you deliberately hold a dev key and set the
|
|
326
|
+
> channel — **not** a stock Lovable publish, which carries neither and so should use `refresh-dev`.
|
|
327
|
+
|
|
328
|
+
**Two secrets, two scopes:** the **deploy key** is channel-scoped and can be a *workspace-level*
|
|
329
|
+
Lovable Build Secret shared by every app (a dev key only writes `dev`, so sharing it is safe). The
|
|
330
|
+
**`SMARTLINKS_APP_ID` is per-app** — set it as a *project-level* variable on each app, so each
|
|
331
|
+
registers under its own authoritative platform id.
|
|
332
|
+
|
|
333
|
+
The gate is `SMARTLINKS_CHANNEL`, so **set it only where you want a release** — i.e. on the
|
|
334
|
+
Publish/CI build, not on preview. If your host exposes a publish-only signal (an env var it sets
|
|
335
|
+
only on Publish), key `SMARTLINKS_CHANNEL` off that; otherwise set it in the Publish build's env
|
|
336
|
+
and leave it unset for preview. That one variable is the difference between "this build ships a
|
|
337
|
+
release" and "this build is just a preview."
|
|
338
|
+
|
|
339
|
+
That's it: a real Publish validates + registers your app (a broken manifest or function stops
|
|
340
|
+
the deploy with an actionable error), while preview builds stay quiet.
|