@somewhere-cloud/cli 0.38.155 → 0.38.156

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.
Files changed (142) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/dist/commands/docs.js +1 -1
  3. package/dist/lib/bundle.js +276 -188
  4. package/dist/lib/bundle.js.map +3 -3
  5. package/npm-shrinkwrap.json +2 -2
  6. package/package.json +2 -3
  7. package/dist/docs/adopt.md +0 -39
  8. package/dist/docs/analytics.md +0 -161
  9. package/dist/docs/api-reference.md +0 -339
  10. package/dist/docs/api-surface.md +0 -2067
  11. package/dist/docs/app-mcp.md +0 -162
  12. package/dist/docs/architecture-patterns.md +0 -334
  13. package/dist/docs/auth-client.md +0 -531
  14. package/dist/docs/billing.md +0 -76
  15. package/dist/docs/browser.md +0 -639
  16. package/dist/docs/calendar.md +0 -298
  17. package/dist/docs/changes.md +0 -323
  18. package/dist/docs/cli.md +0 -407
  19. package/dist/docs/common-mistakes.md +0 -199
  20. package/dist/docs/connect-agent.md +0 -72
  21. package/dist/docs/cors.md +0 -114
  22. package/dist/docs/cron.md +0 -167
  23. package/dist/docs/database-engine.md +0 -167
  24. package/dist/docs/declared-data.md +0 -1656
  25. package/dist/docs/declared-files.md +0 -475
  26. package/dist/docs/deploy-intelligence.md +0 -188
  27. package/dist/docs/deploy.md +0 -733
  28. package/dist/docs/design-system.md +0 -273
  29. package/dist/docs/dev-environments.md +0 -496
  30. package/dist/docs/domain-ownership.md +0 -31
  31. package/dist/docs/domains.md +0 -370
  32. package/dist/docs/feedback.md +0 -88
  33. package/dist/docs/file-tools.md +0 -116
  34. package/dist/docs/functions.md +0 -489
  35. package/dist/docs/getting-started.md +0 -238
  36. package/dist/docs/github.md +0 -95
  37. package/dist/docs/google-calendar.md +0 -212
  38. package/dist/docs/groups.md +0 -836
  39. package/dist/docs/guarantees.md +0 -58
  40. package/dist/docs/handled-for-you.md +0 -224
  41. package/dist/docs/inspect.md +0 -171
  42. package/dist/docs/limits.md +0 -68
  43. package/dist/docs/live-data.md +0 -197
  44. package/dist/docs/live.md +0 -92
  45. package/dist/docs/local-dev.md +0 -30
  46. package/dist/docs/migration-supabase.md +0 -58
  47. package/dist/docs/payments.md +0 -1102
  48. package/dist/docs/portability.md +0 -194
  49. package/dist/docs/postgres.md +0 -301
  50. package/dist/docs/pricing-comparison.md +0 -42
  51. package/dist/docs/pricing.md +0 -39
  52. package/dist/docs/project-groups.md +0 -107
  53. package/dist/docs/projects.md +0 -380
  54. package/dist/docs/recipe-ai-agent.md +0 -112
  55. package/dist/docs/recipe-ai-features.md +0 -227
  56. package/dist/docs/recipe-ai-receipts.md +0 -783
  57. package/dist/docs/recipe-background-jobs.md +0 -369
  58. package/dist/docs/recipe-booking.md +0 -348
  59. package/dist/docs/recipe-csv-import.md +0 -390
  60. package/dist/docs/recipe-ecommerce.md +0 -127
  61. package/dist/docs/recipe-email.md +0 -282
  62. package/dist/docs/recipe-escalation.md +0 -133
  63. package/dist/docs/recipe-file-uploads.md +0 -159
  64. package/dist/docs/recipe-import-app.md +0 -110
  65. package/dist/docs/recipe-login.md +0 -457
  66. package/dist/docs/recipe-multi-chat.md +0 -198
  67. package/dist/docs/recipe-paid-api.md +0 -161
  68. package/dist/docs/recipe-pdfs.md +0 -205
  69. package/dist/docs/recipe-push-notifications.md +0 -107
  70. package/dist/docs/recipe-seo.md +0 -200
  71. package/dist/docs/recipe-signed-in-app.md +0 -330
  72. package/dist/docs/render.md +0 -99
  73. package/dist/docs/rooms.md +0 -554
  74. package/dist/docs/sdk.md +0 -287
  75. package/dist/docs/sdks.md +0 -24
  76. package/dist/docs/search.md +0 -199
  77. package/dist/docs/security-model.md +0 -168
  78. package/dist/docs/setup.md +0 -212
  79. package/dist/docs/smoke.md +0 -102
  80. package/dist/docs/speed.md +0 -298
  81. package/dist/docs/sql-compatibility.md +0 -96
  82. package/dist/docs/sw.agent.md +0 -248
  83. package/dist/docs/sw.ai.md +0 -1291
  84. package/dist/docs/sw.auth.md +0 -1811
  85. package/dist/docs/sw.billing.md +0 -171
  86. package/dist/docs/sw.db.md +0 -2128
  87. package/dist/docs/sw.email.md +0 -661
  88. package/dist/docs/sw.endpoint.md +0 -187
  89. package/dist/docs/sw.env.md +0 -303
  90. package/dist/docs/sw.fetch.md +0 -115
  91. package/dist/docs/sw.fs.md +0 -424
  92. package/dist/docs/sw.groups.md +0 -836
  93. package/dist/docs/sw.image.md +0 -69
  94. package/dist/docs/sw.jobs.md +0 -520
  95. package/dist/docs/sw.logs.md +0 -61
  96. package/dist/docs/sw.mail.md +0 -106
  97. package/dist/docs/sw.notifications.md +0 -78
  98. package/dist/docs/sw.push.md +0 -161
  99. package/dist/docs/sw.rateLimit.md +0 -67
  100. package/dist/docs/sw.web.md +0 -128
  101. package/dist/docs/tasks.md +0 -269
  102. package/dist/docs/test.md +0 -220
  103. package/dist/docs/tool-reference-account.md +0 -7
  104. package/dist/docs/tool-reference-ai.md +0 -121
  105. package/dist/docs/tool-reference-analytics.md +0 -37
  106. package/dist/docs/tool-reference-api.md +0 -19
  107. package/dist/docs/tool-reference-artifacts.md +0 -35
  108. package/dist/docs/tool-reference-auth.md +0 -163
  109. package/dist/docs/tool-reference-browser.md +0 -114
  110. package/dist/docs/tool-reference-code.md +0 -26
  111. package/dist/docs/tool-reference-connect.md +0 -21
  112. package/dist/docs/tool-reference-cron.md +0 -48
  113. package/dist/docs/tool-reference-db.md +0 -282
  114. package/dist/docs/tool-reference-domains.md +0 -107
  115. package/dist/docs/tool-reference-email.md +0 -55
  116. package/dist/docs/tool-reference-env.md +0 -19
  117. package/dist/docs/tool-reference-feedback.md +0 -56
  118. package/dist/docs/tool-reference-fs.md +0 -265
  119. package/dist/docs/tool-reference-github.md +0 -57
  120. package/dist/docs/tool-reference-groups.md +0 -85
  121. package/dist/docs/tool-reference-help.md +0 -29
  122. package/dist/docs/tool-reference-jobs.md +0 -39
  123. package/dist/docs/tool-reference-live.md +0 -48
  124. package/dist/docs/tool-reference-logs.md +0 -16
  125. package/dist/docs/tool-reference-payments.md +0 -44
  126. package/dist/docs/tool-reference-project.md +0 -706
  127. package/dist/docs/tool-reference-push.md +0 -78
  128. package/dist/docs/tool-reference-rate-limit.md +0 -18
  129. package/dist/docs/tool-reference-search.md +0 -68
  130. package/dist/docs/tool-reference-security.md +0 -42
  131. package/dist/docs/tool-reference-smoke.md +0 -17
  132. package/dist/docs/tool-reference-stock-photos.md +0 -20
  133. package/dist/docs/tool-reference-tasks.md +0 -73
  134. package/dist/docs/tool-reference-telegram.md +0 -32
  135. package/dist/docs/tool-reference-usage.md +0 -9
  136. package/dist/docs/tool-reference-web.md +0 -71
  137. package/dist/docs/tool-reference-webhooks.md +0 -9
  138. package/dist/docs/troubleshooting.md +0 -411
  139. package/dist/docs/typed-functions.md +0 -94
  140. package/dist/docs/verify-before-deploy.md +0 -67
  141. package/dist/docs/vs-supabase.md +0 -75
  142. package/dist/docs/vs-vercel.md +0 -103
@@ -1,496 +0,0 @@
1
- # Preview — `somewhere preview` (every plan)
2
-
3
- Every project has ONE production environment. On every plan, signed-in users
4
- can additionally create **previews**: immutable builds with their own database
5
- clone and environment variables, reachable behind a login gate and promoted
6
- to production only when you say so. Preview saves never change production —
7
- only a production deploy, a promote, or a rollback does.
8
-
9
- Where a change lands depends on the command:
10
-
11
- - `somewhere deploy` publishes to production when the deploy finishes. This
12
- is the normal path.
13
- - `somewhere dev` serves the frontend on your machine with hot reload against
14
- the deployed project. Its `sw.db` and `sw.fs` calls use the project's own
15
- database and files, so local writes are production writes.
16
- - You can also run the CLI in an agent's hosted terminal. Sign in there with
17
- `somewhere auth login`. The same `dev`, `deploy`, and `preview` rules apply.
18
- - `somewhere preview` saves each change as a new preview at a private URL,
19
- running against its own copy of the production database. Review what a
20
- preview can show (see the next section), then promote that exact preview
21
- with `POST /v1/promote`; if production moved since the preview was created,
22
- the promote conflicts instead of replacing it.
23
- - A project that has never been published can open a preview too; no deploy
24
- is needed first. Promoting it publishes the project's first version.
25
-
26
- ## Signing in to a preview
27
-
28
- A preview has its own sign-in. Your app's `sw.auth` sign-up, sign-in, session
29
- check (`/api/auth/me` in the starter), refresh, sign-out, email verification and
30
- password reset work in a preview, against the preview's own user list:
31
-
32
- - **A preview starts with no users.** Sign up in the app, or add a test user
33
- with `somewhere preview user-add [email]` (it prints the password once).
34
- `somewhere preview users` lists the preview's users; `somewhere preview
35
- user-remove <id-or-email>` deletes a test user. Production accounts,
36
- passwords and sessions are never copied into a preview.
37
- - **Copied rows that belong to a production user stay private.** The preview's
38
- data is a copy of production, but a new preview user is not that production
39
- user, so rows private to an existing user are not visible to them. Public rows
40
- and the preview users' own new rows are.
41
- - **Sessions belong to one preview.** A preview session means nothing to the
42
- live app or to another preview of the same project, and a live-app session or
43
- token means nothing to a preview. Previews of one project share the
44
- `<subdomain>-dev` address, so opening another preview signs you out of the
45
- first one's app. Sign-up and sign-in in a preview return `token` and
46
- `refresh_token` but no `session_token`; `sw.auth.logout` there takes the
47
- `refresh_token` or the access token (a `session_token` alone answers
48
- `VALIDATION_ERROR`).
49
- - **You stay signed in as on the live app.** A preview access token lasts 60
50
- seconds, as on the live app, and the session check (`/api/auth/me` in the
51
- starter) renews it from the preview's own refresh cookie and sets new
52
- cookies, so a reload keeps you signed in. Requesting, resending and entering
53
- an email verification code renew the same way, so a code entered minutes
54
- later still works. Renewal happens only for the session the access token
55
- belongs to; `X-No-Auto-Refresh: 1` opts out.
56
- - **Sign-in mail is captured, never sent**, whatever the address: verification
57
- codes and reset links (the link opens the preview) are stored in the
58
- project's test inbox, labelled with the preview. Read them with
59
- `somewhere preview mail`. A preview link lets someone view and use the
60
- preview; it never lets them read its mail. A preview keeps up to 100
61
- captured messages, and all of a project's previews together up to 200
62
- (4 MiB), for seven days; closing a preview deletes its mail. A reset request
63
- for an address no preview account uses captures a short note saying so, so a
64
- reset answers the same whether or not the account exists. At a limit, the
65
- verification or reset request that would capture a message answers
66
- `TEST_INBOX_FULL` (HTTP 507) and changes nothing, so a code or link already
67
- captured keeps working.
68
- - **Public reads work.** Rows and pages that are public in production
69
- (`client.publicRead`) are public to whoever holds the preview link.
70
- - Ten wrong sign-ins for one address lock that address for 15 minutes
71
- (`RATE_LIMITED`, HTTP 429), whether or not a preview account uses it.
72
- - **Server user lookups and roles work.** In a preview's server code,
73
- `sw.auth.server.listUsers` (by `ids`, by `emails`, or page by page) lists
74
- that preview's own users, with the same fields, order and cursor as on the
75
- live app, and `sw.auth.server.setRoles` grants and removes roles declared
76
- `assignedBy: 'server'` for that preview's users, in the preview's copy of
77
- the data, under the role rules of the code you saved. A grant made in a
78
- preview never counts on the live app or in another preview. Preview user ids
79
- start with `pvu_`; the platform assigns them (sign-up ignores an `id` it is
80
- sent, as on the live app, and `somewhere preview user-add` cannot choose
81
- one), so no preview user is ever a
82
- production user, and a role or team row copied from production names nobody
83
- in the preview. A preview whose users were created before preview ids began
84
- with `pvu_` keeps signing them in, but `listUsers` and `setRoles` there
85
- answer `PREVIEW_RECREATE_REQUIRED` (HTTP 409): "Create a new preview to use
86
- roles and teams; this preview's users use the older identity format."
87
- - **Built-in teams work.** Every `sw.groups` call (create, list, get,
88
- invite, invitations, remove, leave, delete, roles) acts on the preview's own
89
- users and its copy of the data, under the role rules of the code you saved;
90
- the live app's teams, members, invitations and users are never read or
91
- changed, and a team made in a preview means nothing in another preview.
92
- Teams and members copied from production name production users, so they
93
- match nobody in the preview. An invitation is captured, never sent
94
- (`delivery: "captured"`): read it with `somewhere preview mail`; its link
95
- opens your `redirect_uri` on the preview with an `invite_id` and does not
96
- sign anyone in. The invitee signs up or signs in to the preview with the
97
- invited address and verifies it, and is admitted at once: at verification,
98
- at sign-in, or the next time they list their teams (on the live app
99
- admission can take a moment longer). An account in the preview that already
100
- verified the address is admitted when the invitation is made. Invitation
101
- limits count on the preview's own counters, never the live app's. A preview
102
- saved before teams worked in previews answers `PREVIEW_RESAVE_REQUIRED`
103
- (HTTP 409) for invitations until its next save (`somewhere preview` again);
104
- a preview whose users use the older identity format answers
105
- `PREVIEW_RECREATE_REQUIRED` for every `sw.groups` call.
106
- - Every other account operation refuses in a preview with HTTP 409
107
- (`PREVIEW_AUTH_UNSUPPORTED`, or `PREVIEW_SUBJECT_UNSUPPORTED` for other
108
- signed-in features): "<operation> is not available in a preview. Use
109
- preview sign-up or preview user tools; nothing ran." That covers sign-in
110
- methods other than email and password (social sign-in, magic links, sign-in
111
- codes and second factors), profile and password changes, invites, provider
112
- tokens, exports and account administration.
113
- - A preview saved before sign-in reached previews keeps refusing it until its
114
- next save (`somewhere preview` again).
115
- - A project still on the older preview runtime has no sign-in in its previews
116
- yet. Every sign-in call there, and every request that presents a sign-in
117
- token, answers `PREVIEW_AUTH_UNAVAILABLE` (HTTP 409, "Sign-in is not
118
- available in previews of this project yet"); a preview never reads the live
119
- app's users. Signed-out requests work as before, and the live app is
120
- unaffected. A preview of such a project saved before 2026-11-15 does not run
121
- until it is saved again: it answers `PREVIEW_RESAVE_REQUIRED` (HTTP 409), and
122
- `somewhere preview` in its folder saves it, keeping its data and files.
123
-
124
- ### The preview credential
125
-
126
- `somewhere preview` gets a credential for each preview it opens, kept
127
- owner-only in `~/.somewhere/previews/`, outside your project folder. The
128
- preview commands above use it and nothing else, never your own sign-in. It
129
- works only on that preview's users, test users and captured mail; every other
130
- command and endpoint refuses it (`PREVIEW_CREDENTIAL_NOT_ACCEPTED`), so it
131
- cannot promote, close or deploy anything or change production settings. It
132
- stops working on the next request after the preview is closed, promoted or
133
- expires, after its links are revoked (`POST /v1/projects/:id/preview/revoke`),
134
- or once the person who opened the preview can no longer edit the project.
135
-
136
- ## What a preview cannot do yet
137
-
138
- A preview runs your new code against a copy of production data, but these
139
- parts of an app do not work in a preview today. Check them in production
140
- after you promote (`somewhere rollback --yes` undoes a promote).
141
-
142
- - **Scheduled tasks.** Nothing runs on a schedule in a preview, and
143
- `sw.cron` refuses there with `PREVIEW_CRON_UNAVAILABLE`: a schedule is a
144
- production setting; run a scheduled handler once with
145
- `somewhere cron run <name> --preview` or `somewhere preview run-job`.
146
- Background jobs do work in a preview, with smaller limits (see `sw.jobs` →
147
- "In a preview").
148
- - **AI calls and rooms.** `sw.ai` and rooms refuse in a preview.
149
- - **Signed-in calls other than data, files and teams.** A preview user can
150
- read and write the app's data and files and use its teams. Signed-in inbox,
151
- push, notifications and payment calls answer `PREVIEW_SUBJECT_UNSUPPORTED`
152
- in a preview.
153
- - **Tests.** `somewhere test --preview` (and `openTestApp({ preview: true })`)
154
- test the preview; `somewhere test-users` and `somewhere browser --auth-user`
155
- run against production only.
156
- - **The raw SQL database.** Only the managed tables are copied; a raw SQL
157
- query against a preview answers `RAW_PREVIEW_DATABASE_NOT_READY`.
158
- - **Reading logs from preview code.** `sw.logs.tail` in a preview answers
159
- `DRAFT_PLATFORM_CAPABILITY_DENIED`: a project's logs are not separated by
160
- preview. Read them with `somewhere logs`. A
161
- preview's own `console` output and `sw.logs` writes are still recorded.
162
- - **Most platform tools and endpoints.** Only the preview commands, the
163
- database query/batch/migrate target, exact preview source reads, the
164
- preview cron run and the test-inbox filter take a preview. Every other tool
165
- or endpoint (`db_browse`, `somewhere db rows`, `run_code`, env, files, logs,
166
- users, imports, cron and job runs, …) acts on production only: a request
167
- that names a preview, draft, development slot, environment or release in
168
- any spelling or position (a field, a query parameter, a header) is refused
169
- with `PREVIEW_TARGET_NOT_SUPPORTED` before anything runs or is written.
170
- Nothing falls back to production. Your own data is never read as a request
171
- to target a preview: file contents, upload bytes, row values, function
172
- arguments and webhook payloads can contain fields named `env`, `release`,
173
- `preview` or `draft`. A production-only change sent from a preview's own
174
- address, or with the platform's preview headers (`X-Sw-Env-Slot` other than
175
- `prod`, `X-Sw-Draft-Id`, `X-Sw-Draft-Candidate`), is refused the same way. To see a preview's rows, call one of your
176
- app's own endpoints with `POST https://runner.somewhere.cloud/v1/deploy/preview/invoke` (below).
177
-
178
- What does work: sign-in for the preview's own users and everything they do
179
- with the app's data and files, public reads, your schema change applied to the
180
- copied rows, `sw.db` and `sw.fs` on the copies, email to the project test inbox,
181
- Stripe test-mode checkout, and writing logs (read them with `somewhere logs`).
182
-
183
- A preview answers each request somewhat more slowly than production: in our
184
- measurements a data read took about 365 ms against 110 ms, and creating a team
185
- about 630 ms against 310 ms. On every call the platform re-checks that the
186
- preview is still open and current and looks up the signed-in user in the
187
- preview's own users, so a preview never acts for a closed preview or a
188
- production account.
189
-
190
- Next: `dev-environments` → `create-a-preview` to start one, `promote` and
191
- `roll-back` to ship or undo, and `local-dev` for the local loop.
192
-
193
- ## When to use this — not by default
194
-
195
- **Default to shipping to production.** `somewhere deploy` deploys straight to
196
- production and is the right path for almost all work: iterating on a new
197
- project, building something that has no users yet, fixing your own site.
198
- Every deploy reaches production the moment it finishes — that immediacy is the point.
199
-
200
- Reach for a preview only when you have a **concrete reason to
201
- protect production**: real users on the site, a risky change you want to
202
- preview against production-shaped data before promotion, or a migration you
203
- want to rehearse. If you don't have users yet, don't add the preview → promote
204
- loop — just deploy.
205
-
206
- ## Who has this
207
-
208
- Available to signed-in accounts on **every plan**. Free allows three open
209
- previews across projects. Anonymous accounts cannot create previews. The
210
- builder spending allowance is separate. Production deploys are unaffected. On every plan, `somewhere dev` serves the frontend on
211
- your machine against the deployed backend, and `somewhere deploy-check --run`
212
- runs one handler before you deploy.
213
-
214
- ## The mental model
215
-
216
- - **Production** — what visitors see. Served at your project URL. Changed
217
- only by a production deploy, a promote, or a rollback.
218
- - **Preview** — an immutable build created from a complete snapshot of your
219
- source. Each save mints a NEW preview in the same preview session. Previews
220
- run against an isolated, populated copy of your production database, taken
221
- when the preview session is created (on a never-published project, an empty
222
- database and no files), and see the dev-scoped environment
223
- variables, so nothing a preview does can touch production data or read
224
- production-only secrets. A preview function cannot make outbound requests
225
- (`DRAFT_EGRESS_DENIED`).
226
- A preview function resolves the signed-in user of the preview's own copy
227
- read-only: no refresh, no session minting, and the public sign-in API is not
228
- available from a preview. If that identity lookup cannot be completed, or
229
- returns something that is not a valid identity, the request fails with
230
- `AUTH_VERIFY_UNAVAILABLE` (503) — it never falls back to a visitor.
231
-
232
- ## Email and payments in a preview
233
-
234
- A preview keeps its own database and file copy, but it is not a separate app:
235
- the services below behave as described, and everything else shared stays
236
- unavailable in a preview: a preview function's call fails with
237
- `DRAFT_SIDE_EFFECT_BLOCKED`, and a platform API request made from a draft
238
- returns `DRAFT_SIDE_EFFECTS_BLOCKED`.
239
-
240
- - **Rate limits are separate per preview.** `sw.rateLimit.check` and an
241
- endpoint's `rateLimit` apply the same limits as on the live app, counted on
242
- counters that belong to that preview alone: preview traffic never spends a
243
- live-app limit, the live app's never spends a preview's, and two previews do
244
- not share counts. Closing the preview ends its counters.
245
- - **Email** goes only to this project's test inbox. `sw.email.send` to an
246
- address ending in `@<subdomain>.test.somewhere.site` is stored there
247
- (`status: "captured"`; read it with the `email_test_inbox` tool or
248
- `somewhere email test-inbox <address> --preview`) and never sent. Email sent from a preview is
249
- captured, and counts against that preview's own send limit, not the
250
- account's. The live app and every preview
251
- share that inbox; each message says who sent it (`environment`:
252
- `production` or `preview`, and `preview_session_id`; `unknown` for an app
253
- message stored before 2026-11-14, when senders were not yet recorded), and
254
- both readers filter by it. Another project's test address is refused with
255
- `EMAIL_TEST_ADDRESS_NOT_OWNED`; any other recipient is refused with
256
- `PREVIEW_EMAIL_TEST_INBOX_ONLY`. Other email methods are unavailable in a
257
- preview.
258
- - **Payments** run in Stripe test mode only. `sw.payments.checkout`,
259
- `checkoutForUser`, `portal` and `portalForUser` work, and return URLs may
260
- point at the preview. Test-mode payment state is the project's shared test
261
- state, not a preview copy. Checkout for a signed-in preview user
262
- (`checkoutForUser`, plan checkout) answers `PREVIEW_SUBJECT_UNSUPPORTED` in
263
- a preview.
264
- - **Payment callbacks from a preview are withheld:** they are never delivered
265
- to your project webhook. Where the platform records such an event, it carries
266
- `preview: { delivery: "withheld" }`. Test webhook fulfillment in
267
- development.
268
- - A preview checkout that names a quote, booking or calendar hold is refused
269
- with `PREVIEW_PAYMENT_SHARED_RECORD_REFUSED`, because those records are
270
- shared with the live app.
271
- - **Scheduled tasks** never run on a schedule in a preview. Run one once in
272
- the preview with `somewhere cron run <name> --preview`, or any handler with
273
- `somewhere preview run-job <handler-path>` (see the cron topic); the
274
- production schedule never changes. Production job reads show production
275
- jobs only (`GET /v1/jobs?environment=preview` is refused with
276
- `PREVIEW_TARGET_NOT_SUPPORTED`); preview code reads only its own preview's
277
- jobs. The production route `POST /v1/cron/:id/run` refuses preview fields.
278
-
279
- ## Choose production or the preview clone explicitly for schema changes
280
-
281
- A preview's database is an **isolated exact copy of your production database,
282
- data included, taken when the preview session is created**: tables, rows,
283
- hidden row identities, generated fields, exact values, sequence positions,
284
- indexes, views and triggers. The copy is verified by a complete readback
285
- before the preview is ready; a copy that cannot be completed or confirmed is
286
- refused, never handed to you partial or schema-only. On a brand new project
287
- that has never run a `CREATE TABLE`, production has no tables and **the
288
- preview database starts empty**. On a project that has never been published,
289
- the preview's database and files always start empty. Preview writes stay in the copy and never
290
- merge into production.
291
-
292
- Copy limits and refusals (`retry` is on every refusal):
293
-
294
- - Bounds: 50,000 rows per table, 100 captured columns per table (a hidden row
295
- id counts), 100,000 bytes per generated statement, 16 MiB of replay SQL.
296
- A larger database, or a shape the copy cannot reproduce, is refused with
297
- `DATABASE_COPY_UNSUPPORTED` (409, `retry: false`). Provider limits can
298
- refuse a smaller case; nothing is split or partially copied.
299
- - Full-text (FTS5) tables with internally stored content are copied,
300
- including their declared options (`tokenize`, `prefix`, `columnsize`,
301
- `detail`, `UNINDEXED`) and persisted configuration. External-content and
302
- contentless full-text tables, other virtual-table modules and unknown
303
- configuration refuse. The SQL dump captures the same full-text shapes
304
- and refuses the same ones.
305
- - `DATABASE_COPY_UNCONFIRMED` (503, `retry: true`): the platform could not
306
- confirm the outcome of the copy. Retry the same create; a retry may still
307
- refuse until the unconfirmed attempt has been cleaned up — the platform
308
- never starts a blind second copy on top of an unknown one.
309
- - `DRAFT_NEW_COPY_REQUIRED` (409, `retry: false`): a preview whose database
310
- holds the schema without a copy of the data is not served; its data is kept
311
- but its URLs fail readiness. Start a new preview session.
312
-
313
- Preview releases apply `db/schema.ts` to the preview's managed database.
314
- For projects with a separate raw SQL database, preview-targeted migrations
315
- return `RAW_PREVIEW_DATABASE_NOT_READY`. Rehearse raw SQL DDL on a separate
316
- test project.
317
-
318
- If a project has a raw SQL preview copy, apply DDL there with `db_migrate`
319
- using `target:"preview"`, `preview_session_id`, and optionally `preview_id`.
320
- The changes survive new candidates in the same session and are discarded
321
- with the copy when the session closes, is promoted, or expires. Conflicting
322
- target fields return `DATABASE_TARGET_AMBIGUOUS`. An unknown, closed, expired,
323
- or mismatched preview returns `PREVIEW_TARGET_INVALID`.
324
-
325
- ## Create a preview
326
-
327
- From a shell, run `somewhere preview` in the project root. Each save becomes
328
- a new preview at a private URL, and the command prints its
329
- `preview_session_id`, `preview_id` and the exact
330
- `somewhere promote <preview_session_id> <preview_id> --yes` line to ship it. The
331
- API form below is what it sends.
332
-
333
- The CLI keeps one preview per folder:
334
-
335
- - `somewhere preview` continues the preview this folder last opened while it
336
- is open, and says which one it is using; `--new` opens a fresh one.
337
- - `somewhere preview list` shows every open preview with its age, when it
338
- expires, and whether production has moved since it was opened (then it can
339
- no longer be promoted).
340
- - `somewhere preview close [preview_session_id]` closes a preview and deletes
341
- its copy of the production data and files and the test-inbox mail it sent.
342
- Kept after close: the preview's job runs and log lines (labelled as the
343
- preview's, under the project's normal log and job retention), and the
344
- record that the preview session and its builds existed (no data).
345
- - After `somewhere promote <preview_session_id> <preview_id> --yes`, the folder records the promoted version as its
346
- base, so the next `somewhere preview` and `somewhere pull` work without a
347
- pull first.
348
- - `somewhere deploy` warns when previews are open: a production deploy makes
349
- them unpromotable.
350
-
351
- An open preview holds a copy of production data until it is promoted, closed,
352
- or expires (24 hours unused, 7 days at most). Close the ones you are done
353
- with.
354
-
355
- A preview save is one **complete snapshot** — the full files/functions maps,
356
- never a partial patch:
357
-
358
- ```
359
- POST /v1/deploy
360
- {
361
- "project_id": "...",
362
- "preview": true,
363
- "scope": "all",
364
- "files": { ...complete static map... },
365
- "binary_files": { },
366
- "functions": { ...complete functions map... },
367
- "replace_functions": true,
368
- "preview_session_id": "draft_<uuid>", // returned session identifier
369
- "preview_operation_id": "<fresh-id>", // new id for every snapshot
370
- "expected_preview_id": null, // null for the FIRST preview
371
- "base_release_id": "<current production release id>" // null if never published
372
- }
373
- ```
374
-
375
- Send all three maps every time, including the empty ones: `binary_files: {}`
376
- and `functions: {}` when the project has none. An omitted map is not read as
377
- "keep what is there"; the save is refused with
378
- `DRAFT_COMPLETE_SNAPSHOT_REQUIRED` and nothing changes. The first preview of a
379
- project can only be created this way; `project_patch` edits an existing preview.
380
-
381
- The response returns `preview_session_id`, `preview_id`, and a
382
- `preview_url`. Sending preview-only fields WITHOUT `preview: true` fails
383
- closed (`DRAFT_FIELDS_REQUIRE_DRAFT`) — it never silently deploys to
384
- production.
385
-
386
- ## Iterate
387
-
388
- Send another complete snapshot with the SAME `preview_session_id`, a **fresh**
389
- `preview_operation_id`, and `expected_preview_id` set to the current
390
- preview. Each save advances the preview pointer under
391
- optimistic concurrency:
392
-
393
- - Stale `expected_preview_id` → `DRAFT_CANDIDATE_CONFLICT`
394
- (re-read the preview session, retry from its exact current preview).
395
- - A reused operation id → `DRAFT_OPERATION_REUSED` (use a fresh id per
396
- snapshot).
397
- - Retrying the SAME operation with the SAME snapshot is idempotent — it
398
- returns the same preview.
399
-
400
- ## Run a preview function
401
-
402
- Invoke one function against the session's latest preview — it executes with
403
- the preview's isolated database and dev-scoped environment:
404
-
405
- ```
406
- POST https://runner.somewhere.cloud/v1/deploy/preview/invoke
407
- { "project_id": "...", "preview_session_id": "draft_<uuid>",
408
- "preview_id": "<optional exact-preview pin>",
409
- "method": "GET", "path": "/api/hello" }
410
- ```
411
-
412
- Same Authorization header as the API. Omit the preview pin to run the latest;
413
- pin it to refuse if the preview session moved (`DRAFT_VERSION_MISMATCH`).
414
-
415
- ## Preview in a browser
416
-
417
- Mint a one-time capability URL for the exact preview you want to
418
- preview:
419
-
420
- ```
421
- POST /v1/projects/:id/preview/mint
422
- { "preview_session_id": "draft_<uuid>",
423
- "preview_id": "<exact preview_id>" }
424
- → { "preview_url": "https://<subdomain>-dev.somewhere.site/__sw_cap?t=..." }
425
- ```
426
-
427
- Open the returned `preview_url` in the browser. The `/__sw_cap` exchange is
428
- single-use: it consumes the token, sets a host-only preview cookie, and
429
- redirects to the clean `-dev` URL. The dev hostname is never public: missing,
430
- replayed, forged, expired, revoked, stale, or closed capabilities fail closed,
431
- and the production hostname is untouched.
432
-
433
- The preview link follows your latest save; a test run (`somewhere test --preview`)
434
- is pinned to the version it started on. After a save, an open tab shows the new
435
- version within ten seconds, and a session closed or expired stops within ten seconds.
436
-
437
- ## Environment variables and secrets per environment
438
-
439
- Every env var has a scope: `all` (both), `dev` (previews only), or `prod`
440
- (production only) — set via `POST /v1/env` with `scope`. Previews see
441
- dev + all and can NEVER read prod-only values; production sees prod + all
442
- and never dev-only values. Use distinct names per environment (for example
443
- `STRIPE_KEY_TEST` with scope dev and `STRIPE_KEY` with scope prod).
444
-
445
- Env values are captured per preview at snapshot time: adding or changing a var
446
- does NOT reach an existing preview — it takes effect on the NEXT preview.
447
- Production uses current values after its one-time live-configuration adoption;
448
- until then, changes take effect on its next deploy. Create a new preview
449
- snapshot to pick up a changed development value.
450
-
451
- ## Promote
452
-
453
- When the preview is right, promote that exact build:
454
-
455
- ```
456
- POST /v1/promote
457
- { "project_id": "...", "preview_session_id": "draft_<uuid>",
458
- "preview_id": "<the preview you reviewed>",
459
- "message": "why this ship" }
460
- ```
461
-
462
- Promotion is atomic: it makes the exact source you reviewed the new production
463
- release, or nothing changes. If production moved since the preview was created,
464
- the promote conflicts instead of replacing it. A promoted preview session is
465
- finished — further changes start a NEW preview session.
466
-
467
- On a never-published project, promoting a preview publishes the project's
468
- first version, exactly as a first `somewhere deploy` of that source would. The
469
- first promote wins: every other preview opened before it then conflicts, and
470
- a failed promote leaves nothing live.
471
-
472
- From the CLI: `somewhere promote <preview_session_id> <preview_id> --yes`.
473
-
474
- A function that is live in production but missing from the preview is KEPT by
475
- default — for example one added by a direct deploy after the preview was cut.
476
- The response lists those paths as `preserved_functions`. To make production
477
- match the preview exactly, pass `--prune` (API: `"replace_functions": true`);
478
- the paths it deletes come back as `removed_functions`.
479
-
480
- ## Roll back
481
-
482
- To restore the previous production version, run `somewhere rollback --yes`, call the connector tool `project_rollback`, or send `POST /v1/promote/rollback`. Preview
483
- data never merges into production: the preview database clone is discarded
484
- with the preview session.
485
-
486
- ## When a preview session can't continue
487
-
488
- A promoted, closed, or expired preview session returns
489
- `DRAFT_SESSION_TERMINAL` (non-retryable) naming its state — the recovery is
490
- always a NEW preview session with a fresh `preview_session_id` from the current
491
- production release. A preview still provisioning returns
492
- `DRAFT_SANDBOX_NOT_READY` (retry the exact same operation).
493
-
494
- Building on localhost, without a preview → docs({ topic: 'local-dev' }).
495
- Production deploys and their guarantees → docs({ topic: 'deploy' }).
496
- Env var scopes → docs({ topic: 'sw.env' }).
@@ -1,31 +0,0 @@
1
- # You own your domain
2
-
3
- When you buy a domain through somewhere.cloud, it is registered in **your name** from the moment of purchase. The owner of record is you — not us.
4
-
5
- ## What that means
6
-
7
- - **You are the legal owner.** The registration lists your name and email as the registrant. Somewhere HQ, Inc. appears only as the operational contact, which is what lets us handle DNS, SSL, and renewals for you.
8
- - **Privacy protection.** On purchase the platform turns on the registrar's free privacy protection, which keeps your name and email out of public domain lookups on endings that support it.
9
- - **Your address stays private too.** We don't ask for a postal address when you buy; the record uses our company address on your behalf.
10
-
11
- ## Price
12
-
13
- You pay the registrar's price with no markup. The first year can be a registrar promotion priced below later years; the purchase page and the search show the price of each later year.
14
-
15
- ## Taking your domain elsewhere
16
-
17
- You can keep the domain here or move it:
18
-
19
- 1. **Keep it here (default).** We manage DNS, SSL, and renewal. Nothing to do.
20
- 2. **Move it to your own Name.com account.** Free, from 5 days after registration. Name.com is the registrar of every domain bought here.
21
- 3. **Transfer to any other registrar.** Standard transfer with an authorization code, from 60 days after registration: the [ICANN transfer rule](https://www.icann.org/resources/pages/name-holder-faqs-2017-10-10-en) lets a registrar refuse a transfer in a domain's first 60 days, and Name.com locks every new registration for those 60 days. Country endings such as .co.uk and .de follow their own registry's rules.
22
-
23
- To start option 2 or 3, email support@somewhere.cloud from your account email and name the domain. No exit fees, no retention hoops.
24
-
25
- ## Renewals
26
-
27
- Each year the platform charges the registrar's renewal price at that time, with no markup, and then renews the domain. If the charge does not go through, you are emailed and the domain is not renewed. Automatic renewal can be turned off for a domain at any time.
28
-
29
- ## Domains you bought elsewhere
30
-
31
- Connecting a domain you already own (from any registrar) never changes its ownership — it stays in your account at your registrar; we only serve traffic for it.