@somewhere-cloud/cli 0.38.62 → 0.38.63
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const AGENT_WORKFLOW = "## Build, deploy, test\n\nDeclare access rules in db/schema.ts; use the schema-generated browser client\nfor ordinary app reads and writes. The platform enforces those rules on every call.\nStart with owner() for personal rows:\n\nSchema: db/schema.ts is declaration only: imports and a default schema export.\nNo helper functions
|
|
1
|
+
export declare const AGENT_WORKFLOW = "## Build, deploy, test\n\nDeclare access rules in db/schema.ts; use the schema-generated browser client\nfor ordinary app reads and writes. The platform enforces those rules on every call.\nStart with owner() for personal rows:\n\nSchema: db/schema.ts is declaration only: imports and a default schema export.\nNo helper functions or arbitrary TypeScript expressions. Named declarative\nconstants and spreads of those constants are supported.\nid() is a random text key; references use text(). owner() adds/fills user_id.\n\n```ts\nimport { schema, table, id, text, owner } from 'somewhere/db';\nexport default schema({\n notes: table({ id: id(), title: text() }, {\n scope: owner(),\n client: { read: ['id', 'title'], create: ['title'], update: ['title'], delete: true },\n }),\n});\n```\n\nBrowser data is generated from the schema. list returns at most 100 rows, no\norder option: sort in the client or use a server endpoint for ordered queries.\n\n```ts\nimport { data } from 'somewhere:data';\nasync function useNotesData() {\n const { data: note } = await data.notes.create({ title: 'Hello' });\n if (note) await data.notes.update(note.id, { title: 'Updated' });\n const page = await data.notes.list({ limit: 100 });\n if (page.has_more && page.next) return data.notes.list({ limit: 100, after: page.next });\n return page;\n}\n```\n\n\nUse serverOnly() and endpoint checks only when a required rule cannot be expressed\nby the declared scopes: compare the required identities and relationships with\nthe supported owner, membership, parent and role policies before choosing the fallback.\nBuilt-in groups and email-domain roles require VERIFIED email. If the app must\nwork before verification, use its own membership/role table and server checks.\nNever grant privilege solely because an unverified address claims a domain.\n\nStarter map:\n- src/App.tsx + src/routes.ts: route selection, including a detail path parameter;\n navigate/linkTo accept string paths. Extensionless paths serve index.html.\n- src/pages/HomePage.tsx: build here; src/pages/SignedInLayout.tsx: signed-in layout;\n src/ui/AppShell.tsx: account/sign-out; src/ui/layout.tsx: PageHeader (React-node title).\n- src/auth/hooks.ts: existing useAuthState/useSignOut; src/services/auth.ts: errors.\n In components, useAuth from @somewhere-cloud/sdk/react exposes signIn/signUp\n ({ email, password }); both throw readable errors. Sign-up signs in immediately;\n unverified users pass auth: 'required'. Keep api/auth/[...path].ts and the session gate.\n- src/config.ts: app name, SIGN_IN_PROVIDERS, SHOW_EMAIL_VERIFICATION.\n\nEndpoint files: api/notes.ts \u2192 /api/notes; api/notes/[id].ts \u2192 params.id;\napi/notes/[id]/sub.ts \u2192 /api/notes/:id/sub; underscore-prefixed files are helpers.\nThe global sw only declares endpoints; the handler's second argument is the runtime.\nMethod-named exports select GET/DELETE; default export handles POST with a body.\nDeclare auth on every endpoint; declare body fields before reading JSON. GET has no body.\nPlain objects become JSON 200; return Response.json(value, { status }) for other statuses.\n\n```ts\nexport const GET = sw.endpoint({\n auth: 'required',\n handler: async ({ params }, sw) => sw.db.from('notes', { limit: 100 }),\n});\nexport default sw.endpoint({\n auth: 'required', body: { title: 'string' },\n handler: async ({ body }, sw) => sw.db.insert('notes', { title: body.title }),\n});\nexport const DELETE = sw.endpoint({\n auth: 'required',\n handler: async ({ params }, sw) => sw.db.remove('notes', { where: { id: params.id } }),\n});\n```\n\n\nScopes:\n- owner(): personal rows, caller ownership applied by the platform.\n- member(): your membership table controls shared rows; parent(): inherit a related row's access.\n- serverOnly(): functions authorize every read/write; no browser data access.\n- publicRead: { where }: visitor reads of explicitly selected rows/columns.\nclient grants browser operations/columns; read must include the primary key.\nOmitted browser write grants prevent direct writes; use endpoints for validation.\n\nServer calls return { data: rows, count, changes }. sw.db applies caller scopes;\nsw.db.server bypasses them, so authorize first and supply trusted ownership on insert.\nupdate takes TWO arguments: table and { where, set }. Transactions take an ARRAY\nof write intents, never a callback; pre-generate related IDs. No reads or result\nreferences inside tx; a zero-match update does not abort it. Use unique constraints\nfor concurrent uniqueness, not a read-then-insert check.\n\n```ts\nasync function writeNotes(sw: SomewhereRuntimeContext, ownerId: string) {\n // ownerId must come from the caller or an authorized lookup, never unchecked input.\n const id = crypto.randomUUID();\n await sw.db.server.tx([\n { op: 'insert', table: 'notes', values: { id, user_id: ownerId, title: 'Hello' } },\n { op: 'update', table: 'notes', where: { id }, set: { title: 'Updated' } },\n ]);\n await sw.db.from('notes', { where: { id }, limit: 1 });\n await sw.db.insert('notes', { title: 'Hello' });\n await sw.db.update('notes', { where: { id }, set: { title: 'Updated' } });\n await sw.db.remove('notes', { where: { id } });\n // Server directory: authorize the caller before looking up another account.\n const { users: [user] } = await sw.auth.server.listUsers({ emails: ['person@example.com'] });\n return user; // undefined when no eligible account matches\n}\n```\n\n\nCall your API with fetch(path, { method: 'POST', credentials: 'same-origin',\nheaders: { 'content-type': 'application/json' }, body: JSON.stringify(values) }).\nThe short-lived access cookie refreshes automatically; do not store tokens.\nScripts sending cookie-authenticated POST/PATCH/DELETE must send Origin equal to\nthe app URL. UI rendering/session checks are asynchronous: wait for loaded UI.\nTest with throwaway users at <name>@<subdomain>.test.somewhere.site.\n\nPublish: somewhere typecheck \u2192 somewhere deploy \u2192 somewhere test.\nDeploy raw source; do not run a frontend build. Type errors stop before upload;\nexplicit override: somewhere deploy --allow-type-errors. Deploy applies the schema.\nsomewhere test runs project tests against production; also test each table's\naccess and the affected journey. Diagnose with somewhere errors and somewhere logs.\nRATE_LIMIT_UNAVAILABLE is temporary platform unavailability: the request was not\nadmitted; retry it and keep rateLimit protection.\n\nOn demand:\n- Membership/parent: `somewhere docs sw.db --section owner-or-member-and-parent-access`\n- Groups: `somewhere docs sw.groups --section create-a-group`\n- Transactions: `somewhere docs sw.db --section transaction-intents`\n- Updates: `somewhere docs sw.db --section update-shape`\n- Browser limits: `somewhere docs sw.db --section browser-list-limits`\n- Direct HTTP data tests: `somewhere docs declared-data --section calling-the-data-endpoint-directly`\n- Auth hooks: `somewhere docs auth-client --section react-auth-state`\n- Files/background import: `somewhere docs recipe-csv-import --section larger-files`\n- Scheduled work: `somewhere docs cron --section create-a-schedule`\n- Server-rendered pages: `somewhere docs recipe-seo --section 5-server-rendered-pages-and-redirects`\n";
|
|
2
2
|
export declare const SKILLS_POINTER: string;
|
|
3
3
|
export declare const DECLARED_ACCESS_POINTER = "";
|
|
4
4
|
/** One line telling agents the app's data and code can leave:
|
|
@@ -9,7 +9,8 @@ for ordinary app reads and writes. The platform enforces those rules on every ca
|
|
|
9
9
|
Start with owner() for personal rows:
|
|
10
10
|
|
|
11
11
|
Schema: db/schema.ts is declaration only: imports and a default schema export.
|
|
12
|
-
No helper functions
|
|
12
|
+
No helper functions or arbitrary TypeScript expressions. Named declarative
|
|
13
|
+
constants and spreads of those constants are supported.
|
|
13
14
|
id() is a random text key; references use text(). owner() adds/fills user_id.
|
|
14
15
|
|
|
15
16
|
\`\`\`ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-agent-guide.js","sourceRoot":"","sources":["../../src/lib/init-agent-guide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE1D,2EAA2E;AAC3E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAG
|
|
1
|
+
{"version":3,"file":"init-agent-guide.js","sourceRoot":"","sources":["../../src/lib/init-agent-guide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE1D,2EAA2E;AAC3E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyI7B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,UAAU,QAAQ;MACzD,UAAU,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;MACvE,oJAAoJ,CAAC;AAEzJ,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;+EAE+E;AAC/E,MAAM,CAAC,MAAM,mBAAmB,GAAG,oHAAoH;MACnJ,kIAAkI;MAClI,gDAAgD,CAAC;AAErD,MAAM,CAAC,MAAM,cAAc,GAAG,uCAAuC,cAAc,KAAK,uBAAuB,KAAK,mBAAmB,KAAK,cAAc,IAAI,CAAC;AAC/J,MAAM,CAAC,MAAM,cAAc,GAAG,4CAA4C,CAAC"}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@somewhere-cloud/cli",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.63",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@somewhere-cloud/cli",
|
|
9
|
-
"version": "0.38.
|
|
9
|
+
"version": "0.38.63",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@modelcontextprotocol/sdk",
|
|
12
12
|
"chokidar",
|