@somewhere-cloud/cli 0.38.155 → 0.38.157

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 +8 -1
  2. package/dist/commands/docs.js +1 -1
  3. package/dist/lib/bundle.js +286 -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,12 +1,12 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.155",
3
+ "version": "0.38.157",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@somewhere-cloud/cli",
9
- "version": "0.38.155",
9
+ "version": "0.38.157",
10
10
  "license": "MIT",
11
11
  "bin": {
12
12
  "somewhere": "bin/somewhere.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.155",
3
+ "version": "0.38.157",
4
4
  "description": "CLI for somewhere.cloud — auth, projects, deploy, pull, promote, db, logs, env, MCP bridge.",
5
5
  "keywords": [
6
6
  "somewhere",
@@ -32,7 +32,6 @@
32
32
  "bin",
33
33
  "dist/commands/docs.js",
34
34
  "dist/commands/init.js",
35
- "dist/docs",
36
35
  "dist/index.js",
37
36
  "dist/lib/bundle.js",
38
37
  "dist/lib/bundle.js.map",
@@ -68,5 +67,5 @@
68
67
  },
69
68
  "bundleDependencies": [],
70
69
  "bundledDependencies": [],
71
- "gitHead": "8157ab0a4d981ed89bae7d6120bbe500eef9d5ee"
70
+ "gitHead": "cf8c5403eef26a24004e1b2dd4ecc11fceb9f726"
72
71
  }
@@ -1,39 +0,0 @@
1
- # Run a public repo as your own instance
2
-
3
- ## Run a public repo as your own instance
4
-
5
- ### 1. Clone and inspect
6
-
7
- Run `git clone <public-repo-url> <new-instance-folder>` and `cd <new-instance-folder>`. Run `git remote get-url origin` and `git rev-parse HEAD` to record what you copied. Keep any inherited `.somewhere.json` in place for the new-instance deploy.
8
-
9
- Read any setup notes. With or without notes, run `rg -n 'signInPath|createSomewhereAuth|somewhereAuth|appRoles:|verifyInvocation|mcp:' .`. Read `somewhere.auth.json` for the sign-in path when present. Otherwise trace auth UI and routes from the auth calls. Read `db/schema.ts` for app-wide roles, the invocation guard in each job handler for its caller, and each endpoint's `mcp` declaration for the tool name and input. Use `grep -R -n -E` with the same pattern if ripgrep is unavailable.
10
-
11
- ### 2. Check the CLI and account
12
-
13
- Use CLI 0.38.115 or later. Run `somewhere --version` and `somewhere whoami`. If needed, run `npx -y @somewhere-cloud/cli@latest --version` and use that invocation for every command below. Run `somewhere login` if needed and check `somewhere whoami` again for the intended account.
14
-
15
- ### 3. Deploy a new instance
16
-
17
- From the clone, run `somewhere deploy --new`. It publishes raw source and updates the link to a new project named for the folder. The current CLI keeps control of deploy when the installed repo pin is older. Use the new ID in `somewhere project view <new-id> --json` to verify ownership and confirm that it differs from the inherited ID.
18
-
19
- ### 4. Check the public page and inputs
20
-
21
- Run `curl -fsS <printed-app-url>/` and confirm it serves the app. If a required input is missing, run `somewhere deploy --list-unpublished` to inspect omissions. For an app with a sign-in adapter, run `somewhere file somewhere.auth.json --version <deployed-version> --project <new-id>` and check its `signInPath`.
22
-
23
- ### 5. Give the owner access
24
-
25
- Have the intended owner sign in to the app and confirm their identity. Use the deploy cue or run `somewhere auth roles grant <app-email-or-user-id> <declared-role> --project <new-id>`. Verify with `somewhere auth roles list --role <declared-role> --project <new-id>` and have the owner exercise a private action.
26
-
27
- On a disposable project, run `somewhere test-users prepare owner --json` from its linked folder and use the actor's email or ID for the grant. To check the owner page, run `somewhere browser --project <new-id> --path <owner-path> --auth-user <app-user-id>` with the ID from the manifest. Run `somewhere test-users cleanup` after the proof.
28
-
29
- ### 6. Register and test schedules
30
-
31
- Run `somewhere cron list --project <new-id>`. The `sw.jobs.verifyInvocation` guard accepts jobs as well as cron. Trace its callers to tell which handlers need a recurring schedule. Read the handler for the route and payload, and use the setup notes or confirm the cadence with the owner when source gives none.
32
-
33
- For each missing schedule run `somewhere cron create '<cron>' <route> --name <name> --project <new-id>` with `--payload '<json>'` and `--timezone <IANA-zone>` as needed. Add `--disabled` on a fixture. Run `somewhere cron run <name> --project <new-id> --wait` and verify the effect. For captured mail, run `somewhere email test-inbox <test-address>`. Use an address allowed by the handler. For a recurring schedule, check the enabled status and next run in `somewhere cron list --project <new-id>`.
34
-
35
- ### 7. Connect app tools and record the result
36
-
37
- If the app declares tools, run `somewhere docs app-mcp`. Connect `<printed-app-url>/mcp` in a client that supports remote MCP with OAuth. Start signed out, check that the app redirects to its sign-in page, then sign in as the app owner and approve. List the tools, perform a reversible private action and check its effect in the app. For a headless app sign-in, keep one cookie jar across consent and sign-in, use a browser user agent and send the app's origin on same-origin form POSTs.
38
-
39
- Record the live URL, owner access, private action, tool and schedule results, and the public upstream URL and commit.
@@ -1,161 +0,0 @@
1
- # Analytics — Track Events, Query Aggregates
2
-
3
- Answer product questions such as "how many people who start onboarding finish
4
- it?" Record `onboarding_started` and `onboarding_completed` from your functions
5
- with `sw.analytics.track`. Events go to the platform's event store, outside
6
- your app database, so there is no table to create. Compare the daily counts
7
- with two MCP calls:
8
-
9
- ```text
10
- analytics_query({ project_id: "my-app", event: "onboarding_started", group_by: "day" })
11
- analytics_query({ project_id: "my-app", event: "onboarding_completed", group_by: "day" })
12
- ```
13
-
14
- Each returns `{ rows: [{ bucket: "2026-09-02", count: 31 }, …], count, group_by: "day" }`,
15
- newest day first. Convert each count with `Number(row.count)`, then divide
16
- completed by started for each day to get the completion rate. Page views are
17
- counted on the server with no script in your pages, and kept apart from
18
- events (**Page views** below).
19
-
20
- ## Record an event from your app
21
-
22
- Copy the checked handler in `browser` → `count-what-users-do`. It requires a
23
- signed-in user, accepts only the event names you list, and returns the track
24
- result. Add `onboarding_started` and `onboarding_completed` to the event
25
- names it accepts, and call it at each step.
26
-
27
- `sw.analytics.track(event, { properties?, page?, referrer?, user_agent? })`
28
- waits for the platform and returns one of:
29
-
30
- - `{ recorded: true, event, user_id, attribution }`
31
- - `{ recorded: false, reason }`, where `reason` is `consent_pending`,
32
- `consent_declined` or `consent_unavailable` when the project requires
33
- visitor consent (**Consent** below)
34
-
35
- Not recording is a normal result, not an error. When recording is allowed, an
36
- invalid event or a platform failure throws.
37
-
38
- The platform sets the attribution. When the request comes from a verified
39
- signed-in user, `user_id` is their id and `attribution` is `"app_user"`;
40
- otherwise the event belongs to the project (`user_id: null`,
41
- `attribution: "project"`). Identity fields in the options are ignored, so a
42
- caller cannot claim to be someone else.
43
-
44
- Name events as stable snake_case verbs (`onboarding_completed`,
45
- `checkout_started`) and keep names short. `properties` is a JSON object of
46
- labels you can read back on raw rows. Queries count events; they do not sum or
47
- average property values. An event name or `properties` over the size limit
48
- returns `VALIDATION_ERROR` naming the limit.
49
-
50
- ## analytics_query({ project_id, event?, from?, to?, group_by?, limit? })
51
-
52
- | `group_by` | Each row | Order |
53
- |---|---|---|
54
- | `"day"` | `{ bucket: "2026-09-02", count }` | newest first |
55
- | `"hour"` | `{ bucket: "2026-09-02T14:00:00Z", count }` | newest first |
56
- | `"event"` | `{ event, count }` | most frequent first |
57
- | `"user"` | `{ user_id, count }`, signed-in users only | most active first |
58
- | omitted | `{ timestamp, event, user_id, properties, page }` | newest first |
59
-
60
- Omit `event` to count every event. `from` and `to` take an ISO-8601 date or a
61
- unix-ms number and include their own instant, so `to: "2026-09-02"` stops at
62
- the start of that day (UTC). `limit` caps the rows; the tool's input schema
63
- gives the default and maximum. A day or hour with no events has no row, so match rows by
64
- `bucket` when you compare two events. The result is
65
- `{ rows, count, group_by }`.
66
-
67
- Inside a function, `sw.analytics.query({ event, group_by: "day" })` returns the
68
- same result. Query results are project-wide: anyone with access to the project
69
- can read them, including properties and user ids on raw rows. Read them from
70
- MCP or run `somewhere call analytics_query '{…}'`.
71
- Do not add a public endpoint that forwards browser input into a query or
72
- returns its rows.
73
-
74
- ## analytics_track({ project_id, event, user_id?, properties?, page?, referrer?, user_agent? })
75
-
76
- From a developer session, `analytics_track` records a project-level event as
77
- you, for example after a migration or a pricing change:
78
-
79
- ```text
80
- analytics_track({ project_id: "my-app", event: "pricing_changed", properties: "{\"version\":3}" })
81
- ```
82
-
83
- It needs editor access. It has no visitor, so it carries no user attribution,
84
- and the platform ignores a `user_id` argument. It cannot carry a visitor's
85
- consent choice: when consent mode is required, it returns `recorded: false`
86
- with `consent_pending`. Use it for project events your policy allows, not as a
87
- stand-in for a visitor's opt-in.
88
-
89
- ## Page views
90
-
91
- Successful HTML page loads on your site are counted on the server, with no
92
- script in your pages. Asset requests, `/api/` routes, known bots and the
93
- preview (`-dev`) address are not counted, and consent mode applies the same
94
- way. Page views are separate from your events, so `analytics_query` leaves
95
- them out. Read totals, top pages and referrers with a developer key:
96
-
97
- ```text
98
- GET /v1/projects/<project-id>/analytics/pageviews?days=30
99
- ```
100
-
101
- `days` is `7` (the default), `30` or `90`; page views are kept for about three months.
102
-
103
- ## Common patterns
104
-
105
- - **Funnel:** one event per step, then one `group_by: "day"` query per step,
106
- as in the opening example.
107
- - **What happens most:** `analytics_query({ project_id, group_by: "event" })`.
108
- - **Most active signed-in users:**
109
- `analytics_query({ project_id, group_by: "user", limit: 20 })`.
110
- - **Check recent events while building:** omit `group_by` and set a small
111
- `limit` to see raw rows.
112
-
113
- ## Consent
114
-
115
- An app whose code calls `sw.analytics.track` gets `mode: "auto"` (below) at
116
- its next deploy, unless it already has a consent setting of its own. The deploy
117
- answer says so in `consent_prompt` and in a line of `privacy_lines`; tell your
118
- human: "Visitors in the EU and UK will see a small analytics choice on your
119
- app." A running app is never changed between deploys. To keep the prompt off,
120
- set `analytics_consent: { mode: "off", policy_version: "1" }` through
121
- `project_update`; that choice is kept at later deploys.
122
-
123
- Without `sw.analytics.track`, events and page views are recorded without a
124
- consent prompt. If the app asks visitors for consent before counting them, set
125
- `analytics_consent: { mode: "required", policy_version: "v1" }` through
126
- `project_update`. The platform then records only when the incoming request carries
127
- the visitor's original acceptance of that exact policy version. The choice is
128
- read from the platform's own consent cookie on the original request; your code
129
- cannot supply or change it.
130
-
131
- With `mode: "auto"` the platform decides per visitor and shows its own small
132
- prompt, so the app needs no banner. Visitors in the EU, EEA, UK and
133
- Switzerland are asked first, with "no" as easy as "yes"; elsewhere events are
134
- recorded. A browser that sends Global Privacy Control or Do Not Track counts
135
- as "no" everywhere, with no prompt. Page views stay anonymous and are counted
136
- without a prompt, except with those browser signals. The visitor's country is
137
- read per request and never stored. Tell your human when you turn this on:
138
- "Visitors in the EU and UK will see a small analytics choice on your app."
139
-
140
- Without a matching acceptance, `track` returns `recorded: false` with
141
- `consent_pending` or `consent_declined`. If the policy cannot be read or is
142
- malformed, nothing is recorded and the reason is `consent_unavailable`. The
143
- banner, revoking a choice and the consent endpoint are in `deploy` →
144
- `optional-analytics-consent`. Consent mode covers the platform's page views
145
- and `sw.analytics` events; anything else your app collects is outside it.
146
-
147
- ## What NOT to do
148
-
149
- - Don't count events in your app database. Events go to the platform's event
150
- store, and `analytics_query` counts them without a table or a write on
151
- your database.
152
- - Don't write logs through analytics; use `sw.logs`. Analytics is for counting.
153
- - Keep personal data such as names and emails out of event names and
154
- `properties`: everyone who can query the project sees them. Signed-in
155
- attribution already links events to the user's id.
156
- - Don't expect sums or averages. Track a distinct event for each outcome, and
157
- keep amounts in your database.
158
- - Don't send a user id to attribute events; the platform derives it.
159
-
160
- Related: `browser` → `count-what-users-do`, `deploy` →
161
- `optional-analytics-consent`, `sw.logs`.
@@ -1,339 +0,0 @@
1
- # API quick reference
2
-
3
- ## How Somewhere works
4
-
5
- Somewhere is the backend for apps your agent builds. One project gives your app
6
- its web address, server functions, one SQL database, sign-in, files, email, AI
7
- and background work. Write React and TypeScript, then run `somewhere deploy`.
8
- The platform compiles your source and serves the app and its functions together.
9
-
10
- Somewhere runs on Cloudflare. Functions run on Workers, each project has its own
11
- D1 database, files are stored in R2, and Durable Objects coordinate real-time
12
- channels and releases. Replicas and limits: `docs({ topic: 'database-engine' })`.
13
-
14
- A starter has these parts:
15
-
16
- | Part | Source | Purpose |
17
- |---|---|---|
18
- | App | `src/`, `index.html` | The interface and browser routes. |
19
- | Functions | `api/` | Server code: `api/notes.ts` answers `/api/notes`. Every handler receives `sw`, bound to the project. |
20
- | Data | `db/schema.ts` | Optional: tables, columns and access rules, applied on deploy. The default starter has none. |
21
- | Auth | `api/auth/[...path].ts`, `src/auth/` | Working sign-in and session hooks to extend. |
22
-
23
- The default starter includes sign-in screens; minimal includes the SDK and auth
24
- route, while bare omits both. Browser
25
- sessions use Secure, HttpOnly cookies. Normal owner-table operations get the
26
- user from the verified session and scope rows to that user. A table's `client`
27
- block chooses which operations and columns the browser may use.
28
-
29
- Your functions decide who may perform privileged actions. Check the caller
30
- before using server authority, sending an email or charging a card. Keep
31
- secrets in `sw.env`, read them inside handlers, and make repeated effects safe
32
- with a stable operation identity. Deploy raw source from the app root; the
33
- platform handles compilation.
34
- Expose a browser value only with `public: true` and a `VITE_` or
35
- `REACT_APP_` name; visitors can read it.
36
-
37
- Your data and code are yours: `somewhere pull` returns the source, `somewhere db dump`
38
- the raw SQL database as one `.sql` file and `db_export` one table as CSV, and a
39
- project can attach PostgreSQL in your own Neon account. Managed-database tables
40
- are not in the dump or CSV export yet; `docs({ topic: 'portability' })` lists each path's limits.
41
-
42
- Start with **Start an app**, **Data**, **Auth**, **Functions** and **Env vars
43
- and secrets**. Each primitive opens with one working path and links to deeper
44
- sections. Recipes contain complete jobs and live outside this short reading
45
- path. The index below lists every topic, including specialized capabilities.
46
-
47
- Use `somewhere docs <topic>` or MCP `docs({ topic })`. To load one section,
48
- use `somewhere docs <topic> --section <id>` or `docs({ topic, section })`.
49
- Use an explicit full view for the complete reference. Recipe first calls
50
- already return the whole recipe.
51
-
52
- <!-- BEGIN GENERATED CAPABILITY INDEX -->
53
- ## Complete capability index
54
-
55
- Read any topic for its examples, signatures and limits.
56
-
57
- ### How Somewhere works
58
-
59
- - **Handled for you — the foundation behind your app** — Built-in work and the choices your app owns. `docs({ topic: 'handled-for-you' })`
60
- - **Database — SQL support, capabilities, and limits** — Capabilities, limits, concurrency, supported SQL. `docs({ topic: 'database-engine' })`
61
- - **Security model — who can read/write what** — Developer, project, end-user, and server authority boundaries. `docs({ topic: 'security-model' })`
62
- - **Built-in protections — what the platform handles** — Runtime, deploy and safety responsibilities. `docs({ topic: 'guarantees' })`
63
- - **Portability — getting your data out** — Export data and move your app. `docs({ topic: 'portability' })`
64
-
65
- ### Primitives
66
-
67
- - **Start an app** — Build, deploy, and verify a first app. `docs({ topic: 'getting-started' })`
68
- - **Deployed Functions** — Server routes, HTML pages and SPA coexistence with Request/Response and sw. `docs({ topic: 'functions' })`
69
- - **sw.env — Environment Variables (inside deployed functions)** — Server keys and deliberate public browser keys in one store. `docs({ topic: 'sw.env' })`
70
- - **Declared data — the schema file is the contract** — Schema, access rules, typed client, which rows are the user's. `docs({ topic: 'declared-data' })`
71
- - **Groups** — Shared rows, invites and roles. `docs({ topic: 'sw.groups' })`
72
- - **sw.db — Database (inside deployed functions)** — Queries, atomic writes, live views and server SQL. `docs({ topic: 'sw.db' })`
73
- - **Auth — End-User Authentication** — Sign-in, sessions, OAuth and account settings. `docs({ topic: 'sw.auth' })`
74
- - **Files** — Who reads, uploads, replaces, deletes files; somewhere:files. `docs({ topic: 'declared-files' })`
75
- - **sw.fs — File Storage (inside deployed functions)** — Store, read, version, publish, sign, move, and upload files. `docs({ topic: 'sw.fs' })`
76
- - **Email** — Email on every plan: managed sender for users/owner; own sender domain for anyone. Caps: `/v1/pricing`. `docs({ topic: 'sw.email' })`
77
- - **sw.mail — Mailboxes (inside deployed functions)** — Read, search and reply to received mail; project and per-user mailboxes. `docs({ topic: 'sw.mail' })`
78
- - **AI and search** — Text, image, speech, embeddings, moderation, memory and agents. `docs({ topic: 'sw.ai' })`
79
- - **Search — managed document search and named indexes** — Search files or build semantic indexes over app data. `docs({ topic: 'search' })`
80
- - **Somewhere agent loop — sw.agent** — Bound agent steps and spend; hooks, durable status, retries. `docs({ topic: 'sw.agent' })`
81
- - **Jobs and schedules** — Background jobs: status, retries, cancel. `docs({ topic: 'sw.jobs' })`
82
- - **Cron — Scheduled Tasks** — Schedule recurring function execution with cron expressions. `docs({ topic: 'cron' })`
83
- - **Payments** — Onboard sellers; charge, refund, reconcile. `docs({ topic: 'payments' })`
84
- - **Deploy and domains** — Deploy source, promote, roll back and undeploy. `docs({ topic: 'deploy' })`
85
- - **Custom Domains** — Attach, verify, inspect, and remove custom domains. `docs({ topic: 'domains' })`
86
- - **Test, observe and troubleshoot** — Test live pages, screenshots and interactions. `docs({ topic: 'browser' })`
87
- - **sw.endpoint — declarative endpoint wrapper** — Optional auth, validation and rate limiting around a handler. `docs({ topic: 'sw.endpoint' })`
88
- - **sw.fetch — outbound HTTP fetch from a function** — Policy-checked outbound HTTP requests from deployed functions. `docs({ topic: 'sw.fetch' })`
89
- - **sw.rateLimit — Rate limiting** — Limit requests and actions. `docs({ topic: 'sw.rateLimit' })`
90
- - **sw.notifications — unified notify primitive** — One notification through bell, push, or zero-setup email. `docs({ topic: 'sw.notifications' })`
91
- - **sw.push — Web Push notifications** — Browser notifications; per-device send history. `docs({ topic: 'sw.push' })`
92
- - **Live updates — rooms and live lists** — Keep a list of rows fresh in open tabs (sw.rooms.live). `docs({ topic: 'live' })`
93
- - **Rooms — shared state, presence and messages on one row** — Multiplayer state on one row, with an optional referee. `docs({ topic: 'rooms' })`
94
- - **Project groups** — Organize projects with shared access and themes. `docs({ topic: 'project-groups' })`
95
- - **Render — PDFs** — Render HTML or URLs into PDF documents. `docs({ topic: 'render' })`
96
- - **sw.web — Read pages from the public web** — Read and extract content from public web pages. `docs({ topic: 'sw.web' })`
97
- - **sw.image — Image transformations** — Transform, resize, convert, and optimize image assets. `docs({ topic: 'sw.image' })`
98
- - **Calendar — atomic holds and reservations** — Atomic time holds, availability, confirmation and release. `docs({ topic: 'calendar' })`
99
- - **Google Calendar — add events to a user's own calendar** — Add and update events in a user's own Google Calendar, from requests and scheduled jobs. `docs({ topic: 'google-calendar' })`
100
- - **sw.billing — plans & feature gating for YOUR app's users** — Plans and entitlements for your app's own users. `docs({ topic: 'sw.billing' })`
101
- - **Use your app from Claude (app MCP tools)** — Preview: your app serves its own MCP tools at /mcp; people connect it in Claude and use it as themselves. `docs({ topic: 'app-mcp' })`
102
-
103
- ### Recipes and jobs
104
-
105
- - **Run a public repo as your own instance** — Run a public repo as your own instance. `docs({ topic: 'adopt' })`
106
- - **Recipe — Sign-in, email alerts, daily reminder** — Owner rows, contact form and daily reminder. `docs({ topic: 'recipe-signed-in-app' })`
107
- - **Recipe — Sign-in: the starter, your data, then providers** — Starter login, social sign-in and magic links. `docs({ topic: 'recipe-login' })`
108
- - **Recipe — File uploads: each user's own files** — Owner-scoped uploads from the page. `docs({ topic: 'recipe-file-uploads' })`
109
- - **Recipe — Email the signed-in user** — Verified recipients, test inbox, send outcomes. `docs({ topic: 'recipe-email' })`
110
- - **Recipe — Push notifications to a signed-in user** — Notify a user; check delivery. `docs({ topic: 'recipe-push-notifications' })`
111
- - **Recipe — A background job with a status the user sees** — Per-user work, status and repeat-safe results. `docs({ topic: 'recipe-background-jobs' })`
112
- - **Recipe — AI features: suggest a title** — Signed-in model call, model choice, AI options. `docs({ topic: 'recipe-ai-features' })`
113
- - **Recipe — Read receipts with AI** — Read private receipts with AI; review and save. `docs({ topic: 'recipe-ai-receipts' })`
114
- - **Recipe — SEO: titles, previews, sitemap** — Titles, link previews, sitemap, robots and SEO checks. `docs({ topic: 'recipe-seo' })`
115
- - **Recipe — CSV import** — Upload, one job, retry-safe batched writes. `docs({ topic: 'recipe-csv-import' })`
116
- - **Recipe — PDFs** — Generate, store privately, preview, merge, split. `docs({ topic: 'recipe-pdfs' })`
117
- - **Recipe — Paid and OAuth-protected APIs** — 402 payment and 401 OAuth challenges. `docs({ topic: 'recipe-paid-api' })`
118
- - **Recipe — Bring an existing app** — From GitHub, a folder, a zip, Supabase or Lovable. `docs({ topic: 'recipe-import-app' })`
119
- - **Recipe — AI agent with tool calls** — Agent chatbot with owner rows and conversation history. `docs({ topic: 'recipe-ai-agent' })`
120
- - **Recipe — Booking / calendar app** — Start booking checkout with a calendar hold. `docs({ topic: 'recipe-booking' })`
121
- - **Recipe — Fixed-price catalog checkout** — Start a fixed-price catalog checkout. `docs({ topic: 'recipe-ecommerce' })`
122
- - **Recipe — Multi-chat (Claude.ai-style conversation list)** — Multi-conversation chat with history and search. `docs({ topic: 'recipe-multi-chat' })`
123
- - **Recipe — Cheap model escalates to smart model when stuck** — A low-cost model escalates to a stronger one when stuck. `docs({ topic: 'recipe-escalation' })`
124
- - **Live data — one poller, fan out to every client** — Recipe: one cron poller, fanned out by a live view. `docs({ topic: 'live-data' })`
125
- - **Architecture Patterns — How to wire common app shapes** — Compose primitives into common app architectures. `docs({ topic: 'architecture-patterns' })`
126
- - **Migrating a Supabase app** — Move a Supabase app and its data. `docs({ topic: 'migration-supabase' })`
127
-
128
- ### Surfaces
129
-
130
- - **Setup — Use the CLI, or connect MCP without a shell** — Connect with CLI or MCP. `docs({ topic: 'setup' })`
131
- - **@somewhere-cloud/cli — full command reference** — CLI commands and JSON output. `docs({ topic: 'cli' })`
132
- - **@somewhere-cloud/sdk — optional adapter, one auth path** — Optional SDK for browser and server code. `docs({ topic: 'sdk' })`
133
- - **Client SDK — JavaScript and TypeScript** — JS/TS SDK: starter auth, typed function calls, automation. `docs({ topic: 'sdks' })`
134
- - **Local dev — `somewhere dev`** — Run locally with `somewhere dev`; pull, typecheck, inspect. `docs({ topic: 'local-dev' })`
135
- - **Auth on the client — the correct session code** — Browser sign-in with HttpOnly cookies. `docs({ topic: 'auth-client' })`
136
- - **Typed functions — one contract, both sides** — Typed handlers and browser calls. `docs({ topic: 'typed-functions' })`
137
- - **GitHub push-to-deploy** — Deploy on GitHub push; check status. `docs({ topic: 'github' })`
138
- - **Preview — `somewhere preview` (every plan)** — Private previews for signed-in accounts on every plan. `docs({ topic: 'dev-environments' })`
139
- - **Projects — Full Lifecycle** — Create, edit, export and manage projects. `docs({ topic: 'projects' })`
140
- - **Connect an agent, claim an app, disconnect** — Connect an agent with a code, claim an app, disconnect. `docs({ topic: 'connect-agent' })`
141
- - **Inspect — Read live state before writing** — Inspect source, releases, routes, logs and live state. `docs({ topic: 'inspect' })`
142
-
143
- ### Reference and help
144
-
145
- - **Testing your app** — Run independent live app tests with project Playwright fixtures. `docs({ topic: 'test' })`
146
- - **Verify before deploy** — Typecheck, compile and handler checks, and unit tests. `docs({ topic: 'verify-before-deploy' })`
147
- - **Limits** — Function, record, env, upload, and deploy ceilings. `docs({ topic: 'limits' })`
148
- - **Deploy intelligence — what a deploy records, and where to read it** — Analysis and diagnostics after each deploy. `docs({ topic: 'deploy-intelligence' })`
149
- - **Smoke tests — deploy and recurring checks** — Automatic uptime and behavior checks. `docs({ topic: 'smoke' })`
150
- - **SQL compatibility — what Postgres code ports, and what doesn't** — How Postgres-style SQL translates and where it differs. `docs({ topic: 'sql-compatibility' })`
151
- - **PostgreSQL** — Attach a PostgreSQL database you own; use its driver. `docs({ topic: 'postgres' })`
152
- - **CORS — which browser origins may call your project's functions** — Your own origins already work; add a third-party origin. `docs({ topic: 'cors' })`
153
- - **Design System — Read before generating UI** — Starter tokens, components, themes and design. `docs({ topic: 'design-system' })`
154
- - **Pricing** — Current plans and limits. `docs({ topic: 'pricing' })`
155
- - **Plans & Pricing** — Usage, plan activation and account billing. `docs({ topic: 'billing' })`
156
- - **Pricing comparison — somewhere.cloud vs the stack** — Compare costs with a conventional assembled stack. `docs({ topic: 'pricing-comparison' })`
157
- - **You own your domain** — Domain custody, portability, renewal and detachment. `docs({ topic: 'domain-ownership' })`
158
- - **sw.logs — Application Logging (inside deployed functions)** — Write logs and inspect failures. `docs({ topic: 'sw.logs' })`
159
- - **Analytics — Track Events, Query Aggregates** — Track events and query aggregates for an application. `docs({ topic: 'analytics' })`
160
- - **Tasks — shared context for work** — Per-project work, comments, relationships, completion. `docs({ topic: 'tasks' })`
161
- - **Recent behaviour changes** — Dated behaviour changes. `docs({ topic: 'changes' })`
162
- - **Platform Feedback — Bug? Doc gap? Tell us.** — Report and follow platform or docs issues. `docs({ topic: 'feedback' })`
163
- - **Speed** — Measure latency and speed up your app. `docs({ topic: 'speed' })`
164
- - **Common Mistakes — Things real users have hit** — Avoid recurring deploy, auth, database, and file mistakes. `docs({ topic: 'common-mistakes' })`
165
- - **Troubleshooting — Common errors and what to do** — Common platform errors and their recovery paths. `docs({ topic: 'troubleshooting' })`
166
- - **File tools — project-wide search, glob, diff and integrity check** — Developer search, glob, diff, integrity checks. `docs({ topic: 'file-tools' })`
167
- - **Discovered API surface** — REST, runtime and MCP calls. `docs({ topic: 'api-surface' })`
168
- - **somewhere.cloud vs Supabase — honest comparison** — Compare capabilities and operating tradeoffs with Supabase. `docs({ topic: 'vs-supabase' })`
169
- - **somewhere.cloud vs Vercel — honest comparison** — Compare capabilities and operating tradeoffs with Vercel. `docs({ topic: 'vs-vercel' })`
170
-
171
- ### Tool call reference
172
-
173
- - **Account tool reference** — Arguments, examples and limits for account tool calls. `docs({ topic: 'tool-reference-account' })`
174
- - **Ai tool reference** — Arguments, examples and limits for ai tool calls. `docs({ topic: 'tool-reference-ai' })`
175
- - **Analytics tool reference** — Arguments, examples and limits for analytics tool calls. `docs({ topic: 'tool-reference-analytics' })`
176
- - **Api tool reference** — Arguments, examples and limits for api tool calls. `docs({ topic: 'tool-reference-api' })`
177
- - **Artifacts tool reference** — Arguments, examples and limits for artifacts tool calls. `docs({ topic: 'tool-reference-artifacts' })`
178
- - **Auth tool reference** — Arguments, examples and limits for auth tool calls. `docs({ topic: 'tool-reference-auth' })`
179
- - **Browser tool reference** — Arguments, examples and limits for browser tool calls. `docs({ topic: 'tool-reference-browser' })`
180
- - **Code tool reference** — Arguments, examples and limits for code tool calls. `docs({ topic: 'tool-reference-code' })`
181
- - **Connect tool reference** — Arguments, examples and limits for connect tool calls. `docs({ topic: 'tool-reference-connect' })`
182
- - **Cron tool reference** — Arguments, examples and limits for cron tool calls. `docs({ topic: 'tool-reference-cron' })`
183
- - **Db tool reference** — Arguments, examples and limits for db tool calls. `docs({ topic: 'tool-reference-db' })`
184
- - **Domains tool reference** — Arguments, examples and limits for domains tool calls. `docs({ topic: 'tool-reference-domains' })`
185
- - **Email tool reference** — Arguments, examples and limits for email tool calls. `docs({ topic: 'tool-reference-email' })`
186
- - **Env tool reference** — Arguments, examples and limits for env tool calls. `docs({ topic: 'tool-reference-env' })`
187
- - **Feedback tool reference** — Arguments, examples and limits for feedback tool calls. `docs({ topic: 'tool-reference-feedback' })`
188
- - **Fs tool reference** — Arguments, examples and limits for fs tool calls. `docs({ topic: 'tool-reference-fs' })`
189
- - **Github tool reference** — Arguments, examples and limits for github tool calls. `docs({ topic: 'tool-reference-github' })`
190
- - **Groups tool reference** — Arguments, examples and limits for groups tool calls. `docs({ topic: 'tool-reference-groups' })`
191
- - **Help tool reference** — Arguments, examples and limits for help tool calls. `docs({ topic: 'tool-reference-help' })`
192
- - **Jobs tool reference** — Arguments, examples and limits for jobs tool calls. `docs({ topic: 'tool-reference-jobs' })`
193
- - **Live tool reference** — Arguments, examples and limits for live tool calls. `docs({ topic: 'tool-reference-live' })`
194
- - **Logs tool reference** — Arguments, examples and limits for logs tool calls. `docs({ topic: 'tool-reference-logs' })`
195
- - **Payments tool reference** — Arguments, examples and limits for payments tool calls. `docs({ topic: 'tool-reference-payments' })`
196
- - **Project tool reference** — Arguments, examples and limits for project tool calls. `docs({ topic: 'tool-reference-project' })`
197
- - **Push tool reference** — Arguments, examples and limits for push tool calls. `docs({ topic: 'tool-reference-push' })`
198
- - **Rate Limit tool reference** — Arguments, examples and limits for rate limit tool calls. `docs({ topic: 'tool-reference-rate-limit' })`
199
- - **Search tool reference** — Arguments, examples and limits for search tool calls. `docs({ topic: 'tool-reference-search' })`
200
- - **Security tool reference** — Arguments, examples and limits for security tool calls. `docs({ topic: 'tool-reference-security' })`
201
- - **Smoke tool reference** — Arguments, examples and limits for smoke tool calls. `docs({ topic: 'tool-reference-smoke' })`
202
- - **Stock Photos tool reference** — Arguments, examples and limits for stock photos tool calls. `docs({ topic: 'tool-reference-stock-photos' })`
203
- - **Tasks tool reference** — Arguments, examples and limits for tasks tool calls. `docs({ topic: 'tool-reference-tasks' })`
204
- - **Telegram tool reference** — Arguments, examples and limits for telegram tool calls. `docs({ topic: 'tool-reference-telegram' })`
205
- - **Usage tool reference** — Arguments, examples and limits for usage tool calls. `docs({ topic: 'tool-reference-usage' })`
206
- - **Web tool reference** — Arguments, examples and limits for web tool calls. `docs({ topic: 'tool-reference-web' })`
207
- - **Webhooks tool reference** — Arguments, examples and limits for webhooks tool calls. `docs({ topic: 'tool-reference-webhooks' })`
208
- <!-- END GENERATED CAPABILITY INDEX -->
209
-
210
- <!-- BEGIN CANONICAL AGENT WORKFLOW -->
211
- ## Getting started — build, deploy, verify
212
-
213
- Ask before destructive or paid actions unless the user already authorized them.
214
-
215
- To change an existing app, start with `somewhere pull <app>` in a fresh folder.
216
- In a connector without a terminal, read its live source with `project_export`.
217
-
218
- For a new app, `somewhere init --name <slug>` writes React + TypeScript. Signed out: local only;
219
- signed in: also creates and links a project.
220
- Default: sign-in UI; minimal: SDK/auth route; bare: neither. `init --catalog --json`: modules.
221
- `npx -y @somewhere-cloud/cli@latest deploy` publishes raw source: signed out, a temporary URL, claim link
222
- and expiry; linked, your account project. On a hosted VM, `somewhere login` uses browser approval and keeps you signed in.
223
- Cron needs a claimed project. The test inbox works on temporary projects.
224
- Start auth/data/cron with `somewhere docs recipe-signed-in-app --full`.
225
-
226
- After edits: `somewhere typecheck` and focused local/browser tests. Publish:
227
- 1. `somewhere deploy` (do not build first). Deploy
228
- checks compilation, schema and secrets; `somewhere deploy-check` runs them without publishing
229
- (diagnosis, review, `--run /api/x`).
230
- 2. Run `somewhere verify` on the final journey (`--flow flow.json`). Sign test users up
231
- in-app at `*.test.somewhere.site`; more: `actors` + `journey` (`somewhere docs browser`).
232
- In your own Playwright script: `page.setDefaultTimeout(5_000)`, never a fixed sleep (wait for
233
- the thing itself), stop at the first failure and print `page.url()` and the visible error
234
- text, and after a fix rerun only the checks that failed (`somewhere docs test`).
235
- 3. Inspect: `somewhere browser`; diagnose: `somewhere logs --tail 10`, `somewhere errors`.
236
- 4. Test mail: `somewhere email test-inbox <addr>` includes `verification_code`.
237
- Don't retest sign-in or `sw.db.from` scoping; test each table's scope, auth before `sw.db.server`/raw SQL, bad input and journeys.
238
-
239
- Routes: `index.html` loads `src/main.tsx`; unmatched extensionless paths
240
- (`/signin`) serve it. Route the app by `location.pathname`.
241
- `api/notes/[id].ts` is `/api/notes/:id`; `_`-prefixed names are import-only
242
- helpers. Avoid names differing only in case.
243
-
244
- With auth enabled, `api/auth/[...path].ts` is
245
- `export { somewhereAuth as default } from '@somewhere-cloud/sdk/server'`; pages
246
- use `createSomewhereAuth()` from `@somewhere-cloud/sdk/auth` (client and React hooks:
247
- `somewhere docs auth-client --section react-auth-state`). `auth.signUp({ email, password,
248
- displayName? })` / `auth.signIn({ email, password })` return the user or throw
249
- with the message. Use the starter's `useAuthState()` gate. Render private UI only
250
- after the session is confirmed. Keep the pending view and the retry view.
251
- Browser tests wait for the expected screen. If your SDK publishes
252
- `data-sw-auth` on `<html>`, first wait for the expected sign-in state there.
253
- Sign-up sets `email_verified: false`; unverified users pass
254
- `auth: 'required'`. `sw.auth.requireUser(req)` returns `{ id, email,
255
- role, email_verified, … }` or throws 401 `AUTH_REQUIRED`;
256
- `sw.auth.fromRequest(req)` returns it or `null`.
257
-
258
- Functions: JSON endpoints use `sw.endpoint({ auth, body, rateLimit, handler:
259
- async ({ body, user, params }, sw) => value })`; set `auth` (`'required'`,
260
- `'optional'`, `'none'`) or deploy refuses it. Webhooks and streaming use a bare `export default async
261
- function (req: Request, sw: SomewhereRuntimeContext)` returning a `Response`.
262
- Params: `params.id` there, `sw.params.id` bare.
263
-
264
- Data: `id()` is a random text key on new tables (reference with `text()`); integer-id tables keep integers. The starter's `id({ uuid: false })` is deliberate.
265
- Declare tables in `db/schema.ts`; pages use `somewhere:data`
266
- (`data.notes.list()`, `.create()`, `.update(id, …)`) without API files.
267
- Its wire is same-origin `POST /__sw/data` (`somewhere docs declared-data --section
268
- calling-the-data-endpoint-directly`); app hosts serve no `/v1/…` API.
269
- Use `owner()` for personal rows, `group()` for invited teams, `appRole()`
270
- for app-wide roles, `anyOf()` for owner or a role, `allOf()` for members-only rows.
271
- Sharing your own rows with specific people: `anyOf(owner(), grant())`
272
- (`somewhere docs declared-data --section per-owner-sharing`).
273
- Booking/help desk: `somewhere docs sw.db --section provider-or-booker-and-owner-or-staff-recipes`.
274
- Keep fitting scopes when an exceptional write needs `sw.db.server.tx`.
275
- `shared()` gives signed-in reads and creator-only writes. `client` sets browser
276
- columns. `publicRead: { where }` admits visitors and may cache anonymous reads
277
- for up to 120 seconds. For fresh pages, use `sw.db.server.from` in a page handler
278
- with a publication filter, public columns and `Cache-Control: no-store`. Public-profile enquiries use
279
- `client.intake` (`somewhere docs declared-data`). Keep scopes and grants;
280
- functions handle authorized exceptional writes and side effects. Declare the
281
- body schema (a missing or mistyped field is a 400); `handle` below is a
282
- public address its owner claimed:
283
-
284
- ```ts
285
- export default sw.endpoint({
286
- auth: 'none',
287
- body: { handle: 'string', title: 'string', from_email: 'email' },
288
- handler: async ({ body }, sw) => {
289
- const title = body.title.trim();
290
- if (!title || title.length > 200 || /[\r\n]/.test(title)) return Response.json({ error: 'bad title' }, { status: 400 });
291
- const { data: [profile] } = await sw.db.server.from('profiles', { where: { handle: body.handle }, limit: 1 });
292
- if (!profile) return Response.json({ error: 'unknown handle' }, { status: 404 });
293
- await sw.db.server.insert('entries', { user_id: profile.user_id, owner_email: profile.owner_email,
294
- title, from_email: body.from_email, created_ms: Date.now() });
295
- },
296
- });
297
- ```
298
-
299
- Use the looked-up owner, never the body. Rate limits/alerts: `recipe-signed-in-app`.
300
- Use `serverOnly()` only when every operation needs a function's own access check.
301
- Structured queries: `sw.db.from` / `insert` / `update` / `remove` return `{ data: rows[], count,
302
- changes }`; `where: { a: 1, b: { in: ids }, c: { gte: 2 }, d: null }` (one
303
- operator per column). Raw SQL uses a separate raw database, never managed tables.
304
- For cross-user managed work, authorize the caller and use `sw.db.server.from` /
305
- `insert` / `update` / `remove`; keep `owner()`/`group()`. Parallel reads: `Promise.all`.
306
-
307
- Unique pair: `unique: [['org_id','email']]` in table options.
308
-
309
- Test schedules now: `somewhere cron run <id> --wait`. Do not wait for it to fire.
310
- <!-- END CANONICAL AGENT WORKFLOW -->
311
-
312
- ## More information
313
-
314
- - Anonymous quickstart: <https://somewhere.cloud/docs/start.txt>.
315
- If that URL cannot be fetched,
316
- `npx -y @somewhere-cloud/cli@latest docs start` prints the same text, and
317
- `docs({ topic: 'getting-started' })` covers the same first app.
318
- - Platform contract: <https://somewhere.cloud/agent.txt>. In an app, start with the `AGENTS.md` written by `somewhere init`.
319
- - Security practices: <https://somewhere.cloud/security.txt>
320
- - Migration and portability: <https://somewhere.cloud/migration.txt>
321
- - Long-form reference: <https://somewhere.cloud/llms-full.txt>
322
-
323
- For current plans, prices and limits, see https://somewhere.cloud/pricing.
324
-
325
- If a documented contract appears wrong, call `support_ticket({ message })` with
326
- the smallest reproduction; read it back later with
327
- `support_ticket({ ticket_id })`.
328
-
329
- ### Release privacy facts
330
-
331
- `GET /v1/projects/:id/privacy` returns `{ release_id, privacy_facts, privacy_lines }`.
332
- Read access is the same as project deploy history. `project_privacy_facts` reads this record;
333
- `somewhere privacy` prints its lines. A successful source deploy includes the same record
334
- and lines. Only declared owner table names, file collection names, domains and flags are
335
- stored with the release. Source references do not cover requests built while the app runs.
336
- Unavailable source signals or older releases say the facts are unavailable.
337
- A missing privacy/policy name warns only when a declared owner table, file collection,
338
- AI reference or outside domain was found, and names those signals. This is a guess from
339
- file and route names. Sign-in settings and executed email/payment/AI usage are not included.