@ancha-labs/cli 0.4.35 → 0.4.36

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.
@@ -75,6 +75,35 @@ The harness can call the same `stripe.complete_checkout` action with `session` t
75
75
 
76
76
  Create an account link through `POST /v1/account_links` and open its `url` for the hosted Connect onboarding page. Express and Custom accounts use `type: account_onboarding`; Custom accounts also use `account_update`. Links are single use and expire after 5 minutes on the world clock: an expired or previously visited link redirects to `refresh_url`, where the app can create a fresh link. Submit the page's test identity and bank choice to collect requirements and begin capability review, then return to `return_url`. Leaving through the return link also reaches `return_url`; read the account's requirements and capabilities to determine its state.
77
77
 
78
+ ## Supabase apps
79
+
80
+ Run `ancha connect supabase --lang ts` for the client setup. The app receives `SUPABASE_URL`, `SUPABASE_ANON_KEY`, `SUPABASE_SERVICE_ROLE_KEY`, `SUPABASE_PUBLISHABLE_KEY`, `SUPABASE_SECRET_KEY`, `SUPABASE_JWT_SECRET` and `SUPABASE_PROJECT_REF`. Server clients can use the service role key for administrative work. Use the anon or publishable key with the signed-in user's session for requests governed by row-level security.
81
+
82
+ Ancha also supplies the variables frontend frameworks read: `NEXT_PUBLIC_SUPABASE_URL`, `NEXT_PUBLIC_SUPABASE_ANON_KEY`, `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY`; `VITE_SUPABASE_URL`, `VITE_SUPABASE_ANON_KEY`, `VITE_SUPABASE_PUBLISHABLE_KEY`, `VITE_SUPABASE_PROJECT_ID`; and `EXPO_PUBLIC_SUPABASE_URL`, `EXPO_PUBLIC_SUPABASE_ANON_KEY`. Keep the app's existing environment-variable names and pass their values to `createClient`:
83
+
84
+ ```ts
85
+ import { createClient } from '@supabase/supabase-js';
86
+
87
+ const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_ANON_KEY!);
88
+ const { data, error } = await supabase.auth.signInWithOtp({
89
+ email: 'tom.reyes@harborview-dental.example',
90
+ });
91
+ if (error) throw error;
92
+ ```
93
+
94
+ Read the email and code with `ancha world inbox`. For `seed.supabase.auth.email_otp: code`, pass that code to `supabase.auth.verifyOtp({ email, token: code, type: 'email' })`; for `link`, follow the captured sign-in link. Sign-up confirmations and password recovery messages also arrive in the inbox. The client keeps the returned session for Data API and private Storage calls.
95
+
96
+ The world loads the app's `supabase/migrations` and `supabase/seed.sql`. Add people, tenant rows and files with `seed.supabase`; see `ancha docs scenes` for a complete seed and checks. To call the app as a seeded user, give the app call `as`; Ancha creates the Supabase session and sends its bearer token:
97
+
98
+ ```yaml
99
+ world_rules:
100
+ app_calls:
101
+ - at: 5s
102
+ method: GET
103
+ path: /api/documents
104
+ as: { supabase: tom.reyes@harborview-dental.example }
105
+ ```
106
+
78
107
  ## Clerk sign-in
79
108
 
80
109
  Run `ancha connect clerk --lang ts` for the SDK configuration. The app receives `CLERK_API_URL`, `CLERK_SECRET_KEY`, `CLERK_PUBLISHABLE_KEY`, `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY`, `CLERK_JWT_KEY` and `CLERK_WEBHOOK_SIGNING_SECRET`. `CLERK_FRONTEND_API_URL`, `CLERK_PROXY_URL` and `NEXT_PUBLIC_CLERK_PROXY_URL` name the same Frontend API. Pass `apiUrl`, `publishableKey`, `jwtKey` and `proxyUrl` to `createClerkClient`; keep the app's `authenticateRequest` and organization checks. `CLERK_JWT_KEY` is the PEM public key for networkless verification. Session tokens last 60 seconds and are dated on the app's own clock: the world's when the app runs with `agent.clock: node`, real time otherwise.
@@ -218,6 +218,115 @@ checks:
218
218
 
219
219
  Use a native Stripe ID or a tool-local `$ref` (also `$type.ref`). Payment and paid-invoice refs identify their charge or PaymentIntent; customer refs identify customers or their stored payment methods. Other refs identify their seeded object type; invoice items use native IDs. `ancha twins seed stripe --json` prints validated examples. `ancha explain --json` reports the expected and actual state for each check.
220
220
 
221
+ ## Supabase
222
+
223
+ Ancha builds the world's Supabase database from the app's `supabase/migrations` in file-name order, then `supabase/seed.sql`, then `seed.supabase.users`, `sql`, `buckets` and `objects`, in that order. Users are inserted into `auth.users` and `auth.identities`, so the app's user triggers run. Give `migrations: [{ name, sql }]` and `seed_sql` inline to supply those inputs in the scene. Explicit inline inputs take precedence over the corresponding project files.
224
+
225
+ The Data API and Storage run requests as `anon`, `authenticated` or `service_role`, with the caller's JWT claims. Postgres evaluates the app's row-level security policies; `service_role` has `BYPASSRLS`. Use the anon key and a signed-in user to test tenant access.
226
+
227
+ `seed.supabase.auth` sets `email_otp` (`code` or `link`), `confirm_email`, `access_token_ttl`, `otp_ttl`, `email_rate_limit` (emails per hour), `site_url` and `redirect_urls`. Durations and signed URL expiry follow the world clock. Read sign-in emails, codes and confirmation links with `ancha world inbox`.
228
+
229
+ ```yaml
230
+ seed:
231
+ supabase:
232
+ migrations:
233
+ - name: 20261101090000_requests.sql
234
+ sql: |
235
+ create table public.document_requests (
236
+ tenant text not null,
237
+ requested_by uuid references auth.users(id),
238
+ document text not null,
239
+ status text not null
240
+ );
241
+ alter table public.document_requests enable row level security;
242
+ create policy own_requests on public.document_requests
243
+ for select to authenticated using (requested_by = auth.uid());
244
+ create policy own_uploads on storage.objects for insert to authenticated
245
+ with check (bucket_id = 'documents' and owner_id = auth.uid()::text);
246
+ seed_sql: "insert into public.document_requests values ('harborview-dental', null, 'engagement-letter.pdf', 'received')"
247
+ auth:
248
+ email_otp: code
249
+ confirm_email: true
250
+ access_token_ttl: 1h
251
+ otp_ttl: 10m
252
+ email_rate_limit: 30
253
+ site_url: http://localhost:3000
254
+ redirect_urls: [http://localhost:3000/auth/callback]
255
+ users:
256
+ - email: tom.reyes@harborview-dental.example
257
+ password: portal-demo-2
258
+ confirmed: true
259
+ sql:
260
+ - "insert into public.document_requests select 'harborview-dental', id, '2026-q4-payroll.csv', 'pending' from auth.users where email = 'tom.reyes@harborview-dental.example'"
261
+ buckets:
262
+ - { id: documents, public: false, allowed_mime_types: [text/csv] }
263
+ objects:
264
+ - bucket: documents
265
+ path: harborview-dental/2026-q3-payroll.csv
266
+ text: "employee,gross\nTom Reyes,8200\n"
267
+ content_type: text/csv
268
+ owner: tom.reyes@harborview-dental.example
269
+ ```
270
+
271
+ `supabase.rows` selects a table and column values in `where`; `{ user: <email> }` resolves a seeded user's Auth id. Choose `count`, `count_gte` or `count_lte`. Checks read as the project owner, so they inspect every tenant's final state. `supabase.objects` selects a bucket and either `path` or `prefix`, with optional `owner`, `count`, `size` and `sha256`; size and digest apply to a path. `supabase.users` checks an email's existence, confirmation and whether it signed in during the test.
272
+
273
+ ```yaml
274
+ checks:
275
+ - id: payroll_uploaded
276
+ state:
277
+ supabase.objects:
278
+ bucket: documents
279
+ path: harborview-dental/2026-q4-payroll.csv
280
+ owner: tom.reyes@harborview-dental.example
281
+ count: 1
282
+ - id: request_received
283
+ state:
284
+ supabase.rows:
285
+ table: document_requests
286
+ where:
287
+ requested_by: { user: tom.reyes@harborview-dental.example }
288
+ status: received
289
+ count: 1
290
+ - id: client_signed_in
291
+ state:
292
+ supabase.users:
293
+ email: tom.reyes@harborview-dental.example
294
+ confirmed: true
295
+ signed_in: true
296
+ ```
297
+
298
+ Use `supabase.sql` to run an administrator's SQL and `supabase.sign_in` to create a session for a seeded person. The same actions work through `ancha world act`. An app call with `as: { supabase: <email> }` signs that person in and sends their access token in `Authorization`.
299
+
300
+ Choose operation names from `ancha twins coverage supabase`. `world_rules.call_faults` returns a native provider error before execution: `effect: error` accepts a 5xx status; `effect: rate_limit` returns HTTP 429 and `Retry-After`.
301
+
302
+ ```yaml
303
+ world_rules:
304
+ actors:
305
+ - at: 0s
306
+ supabase.sign_in: { email: tom.reyes@harborview-dental.example }
307
+ - at: 1m
308
+ supabase.sql:
309
+ sql: "update public.document_requests set status = 'received' where tenant = 'harborview-dental'"
310
+ app_calls:
311
+ - at: 5s
312
+ method: GET
313
+ path: /api/documents
314
+ as: { supabase: tom.reyes@harborview-dental.example }
315
+ call_faults:
316
+ - ref: database_retry
317
+ service: supabase
318
+ match: GET /rest/v1/{table}
319
+ effect: error
320
+ status: 503
321
+ times: 1
322
+ - ref: auth_backoff
323
+ service: supabase
324
+ match: POST /auth/v1/otp
325
+ effect: rate_limit
326
+ retry_after: 3
327
+ times: 1
328
+ ```
329
+
221
330
  ## Clerk session and membership checks
222
331
 
223
332
  Clerk session and membership checks use a `user` id or an `email`. `clerk.sessions` accepts `status` and one of `count`, `count_gte` or `count_lte` (default: at least one). `clerk.memberships` accepts an `organization` id or slug, optional `role`, and an exact `count` (default: at least one). For example:
@@ -80,6 +80,8 @@ Use `--server-url <origin>` to target another local server. `ancha ui --server-u
80
80
 
81
81
  ## Native client contracts
82
82
 
83
+ **Supabase**: Postgres tables with row-level security, Auth sessions and Storage buckets and objects. Run `ancha connect supabase --lang ts` and pass `SUPABASE_URL` and `SUPABASE_ANON_KEY` to `createClient` from `@supabase/supabase-js`. The world builds the database from the app’s migrations and seed, captures sign-in mail in `ancha world inbox`, and grades rows, files and users with `supabase.rows`, `supabase.objects` and `supabase.users`. See `ancha docs apps` and `ancha docs scenes`.
84
+
83
85
  Run `ancha connect <tool> --lang ts` for the selected native HTTP setup. Google Ads also qualifies `--lang py` using the official Python client with a local TLS gRPC endpoint and the supplied test certificate. These connection overrides are necessary; changing only a model provider key does not connect tool clients.
84
86
 
85
87
  The new tools are LinkedIn Ads (202610), Salesforce (REST v67.0), Gong (v2), Google Ads (v26), ChatGPT Ads (Advertiser API v1), HubSpot (CRM v3), and Google Analytics (Data API v1beta REST). `ancha twins coverage <tool> --json` lists each one's supported operations. Slack, GitHub, Datadog, PagerDuty and Open-Meteo are available too.