@somewhere-cloud/cli 0.38.80 → 0.38.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/commands/test.js +13 -3
- package/dist/commands/test.js.map +1 -1
- package/dist/lib/form-accounts.d.ts +41 -0
- package/dist/lib/form-accounts.js +158 -0
- package/dist/lib/form-accounts.js.map +1 -0
- package/dist/lib/init-agent-guide.d.ts +2 -2
- package/dist/lib/init-agent-guide.js +5 -0
- package/dist/lib/init-agent-guide.js.map +1 -1
- package/dist/lib/init-feature-template.js +5 -5
- package/dist/lib/init-test-template.js +8 -0
- package/dist/lib/init-test-template.js.map +1 -1
- package/dist/lib/init-ui-kit.d.ts +2 -2
- package/dist/lib/init-ui-kit.js +13 -12
- package/dist/lib/init-ui-kit.js.map +1 -1
- package/dist/lib/playwright-fixtures.d.ts +60 -0
- package/dist/lib/playwright-fixtures.js +384 -1
- package/dist/lib/playwright-fixtures.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/src/testing.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,15 @@ Republish the platform contract 6 CLI after npm accepted earlier uploads without
|
|
|
8
8
|
|
|
9
9
|
# Changelog
|
|
10
10
|
|
|
11
|
+
## 0.38.82
|
|
12
|
+
|
|
13
|
+
- somewhere test: under a required email-code policy, signIn waits out the platform's one-code-a-minute limit (for example right after signUp) instead of failing.
|
|
14
|
+
|
|
15
|
+
## 0.38.81
|
|
16
|
+
|
|
17
|
+
- somewhere test signs up through the app's own form: signUp(page) returns { id, email, password, verified } for an ordinary, unverified account at a reserved address (example.com by default; a chosen domain or address must be example.com/.org/.net or end in .example or .test). verify(page, person) enters the emailed code through the app; signIn(page, person) and signOut(page) use the app's form. Under a required email-code policy, signUp and signIn enter the emailed code. Accounts are deleted by the exact id their sign-up returned, never by address; an interrupted run is finished by the next one.
|
|
18
|
+
- The auth starter's form, code step and sign-out button carry data-sw-auth hooks, and its sample test signs up, signs out and signs back in through the form. The generated AGENTS.md says what one run covers.
|
|
19
|
+
|
|
11
20
|
## 0.38.80
|
|
12
21
|
|
|
13
22
|
- Starter: the MCP sign-in return now checks every remembered value, not only the address bar, with the same exact-path check again just before it is followed. It is kept in a __Host- cookie that other sites cannot set, duplicates are refused, and a page left open past ten minutes refuses plainly instead of following an expired request.
|
package/dist/commands/test.js
CHANGED
|
@@ -5,10 +5,11 @@ import { join, dirname } from 'node:path';
|
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { spawnSync } from 'node:child_process';
|
|
7
7
|
import { appendFileSync, existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
|
|
8
|
-
import { createHash } from 'node:crypto';
|
|
8
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
9
9
|
import { ApiClient } from '../lib/client.js';
|
|
10
10
|
import { cliConfigDir, getToken, loadProjectConfig } from '../lib/config.js';
|
|
11
11
|
import { ensurePrivateDir, writePrivateFile } from '../lib/test-identities.js';
|
|
12
|
+
import { describeSweep, sweepAccounts } from '../lib/form-accounts.js';
|
|
12
13
|
export function registerTest(program) {
|
|
13
14
|
program.command('test [file]')
|
|
14
15
|
.description('Run project Playwright tests against its canonical production origin')
|
|
@@ -70,6 +71,10 @@ export function registerTest(program) {
|
|
|
70
71
|
const ipv4First = await addressOrder;
|
|
71
72
|
const runnerEnv = { ...process.env, ...(ipv4First ? { NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ''} --dns-result-order=ipv4first` } : {}) };
|
|
72
73
|
const subset = Boolean(file || opts.grep || opts.failed);
|
|
74
|
+
// Form sign-up accounts (signUp fixture) left by an interrupted earlier run are finished first.
|
|
75
|
+
process.env.SW_TEST_RUN = randomUUID();
|
|
76
|
+
for (const line of describeSweep(await sweepAccounts(client, root, id), 'Before this run'))
|
|
77
|
+
process.stderr.write(line + '\n');
|
|
73
78
|
const config = join(dir, 'runner.config.cjs');
|
|
74
79
|
const artifacts = join(dir, createHash('sha256').update(id + origin).digest('hex').slice(0, 16));
|
|
75
80
|
if (opts.failed) {
|
|
@@ -85,7 +90,12 @@ export function registerTest(program) {
|
|
|
85
90
|
args.push('--grep', opts.grep);
|
|
86
91
|
if (opts.failed)
|
|
87
92
|
args.push('--last-failed');
|
|
88
|
-
const result = spawnSync(process.execPath, args, { stdio: 'inherit', env: { ...runnerEnv, SW_TEST_TARGET: JSON.stringify(target), SW_TEST_RELEASE: target.releaseId, SW_TEST_ORIGIN: origin, SW_TEST_BROWSER_LAUNCH_MS: String(browserLaunchMs), SW_TEST_BROWSER: `${channel ?? 'chromium'} ${version}`, SW_TEST_SUBSET: String(subset), SW_TEST_JSON: String(Boolean(opts.json)), SW_TEST_RESULTS: join(dir, 'results.json') } });
|
|
93
|
+
const result = spawnSync(process.execPath, args, { stdio: 'inherit', env: { ...runnerEnv, SW_TEST_TARGET: JSON.stringify(target), SW_TEST_RELEASE: target.releaseId, SW_TEST_ORIGIN: origin, SW_TEST_BROWSER_LAUNCH_MS: String(browserLaunchMs), SW_TEST_BROWSER: `${channel ?? 'chromium'} ${version}`, SW_TEST_SUBSET: String(subset), SW_TEST_JSON: String(Boolean(opts.json)), SW_TEST_RESULTS: join(dir, 'results.json'), SW_TEST_RUN: process.env.SW_TEST_RUN, SW_TEST_RUN_PID: String(process.pid) } });
|
|
94
|
+
// Anything a test's own cleanup could not finish (its record is kept) is retried once more here.
|
|
95
|
+
const after = await sweepAccounts(client, root, id).catch(error => { process.stderr.write(`Could not finish form sign-up cleanup: ${error instanceof Error ? error.message : String(error)}\n`); return null; });
|
|
96
|
+
const leftover = after ? describeSweep(after, 'After this run') : [];
|
|
97
|
+
for (const line of leftover)
|
|
98
|
+
process.stderr.write(line + '\n');
|
|
89
99
|
// Playwright may create raw error-context text; retain only screenshots and rerun state.
|
|
90
100
|
const cleanArtifacts = (path) => {
|
|
91
101
|
if (!existsSync(path))
|
|
@@ -99,7 +109,7 @@ export function registerTest(program) {
|
|
|
99
109
|
}
|
|
100
110
|
};
|
|
101
111
|
cleanArtifacts(artifacts);
|
|
102
|
-
process.exitCode = result.status
|
|
112
|
+
process.exitCode = result.status === null ? 1 : result.status || (after === null || after.failed.length || after.unknownId.length ? 1 : 0);
|
|
103
113
|
});
|
|
104
114
|
}
|
|
105
115
|
//# sourceMappingURL=test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EA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CAAC;YAAC,CAAC;QACjP,CAAC,CAAC;QACF,cAAc,CAAC,SAAS,CAAC,CAAC;QAC1B,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7I,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ApiClient } from './client.js';
|
|
2
|
+
export declare const RESERVED_DOMAINS_TEXT = "example.com, example.org, example.net, or a name ending in .example or .test (for example staff.example)";
|
|
3
|
+
export declare const DEFAULT_SIGNUP_DOMAIN = "example.com";
|
|
4
|
+
/** The one rule for a chosen sign-up address. ASCII only, one @, an ordinary local part, DNS
|
|
5
|
+
* labels, case-folded, no trailing dot; the domain is exactly example.com/.org/.net, or has
|
|
6
|
+
* .example or .test as its last label with at least one label before it. Nothing is converted
|
|
7
|
+
* (no IDN mapping, no trimming): input that is not already in this form is refused. Plus
|
|
8
|
+
* addressing is a literal part of the local part, never a signal. */
|
|
9
|
+
export declare function admitReservedAddress(value: unknown): string;
|
|
10
|
+
/** A fresh address at `domain` (reserved-checked); the random part makes a collision with an
|
|
11
|
+
* existing account in the project practically impossible, and a collision still fails. */
|
|
12
|
+
export declare function generatedAddress(domain?: string): string;
|
|
13
|
+
/** A generated password: letters, digits and punctuation, long enough for any app minimum. */
|
|
14
|
+
export declare function generatedPassword(): string;
|
|
15
|
+
export interface AccountRecord {
|
|
16
|
+
project_id: string;
|
|
17
|
+
email: string;
|
|
18
|
+
id: string | null;
|
|
19
|
+
run: string;
|
|
20
|
+
pid: number;
|
|
21
|
+
created_at: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function accountsDir(root: string, projectId: string): string;
|
|
24
|
+
/** Write one record per sign-up attempt, before the form is submitted, so an interrupted run is
|
|
25
|
+
* visible to the next one. Returns the record's file path. */
|
|
26
|
+
export declare function recordAttempt(root: string, projectId: string, email: string): string;
|
|
27
|
+
export declare function recordId(path: string, id: string): void;
|
|
28
|
+
export declare function forgetRecord(path: string): void;
|
|
29
|
+
/** Delete one account this run created, by exact id, with the developer delete. A 404 means it
|
|
30
|
+
* is already gone. Returns false when the delete could not be confirmed. */
|
|
31
|
+
export declare function deleteAccount(client: ApiClient, projectId: string, id: string): Promise<boolean>;
|
|
32
|
+
export interface SweepResult {
|
|
33
|
+
deleted: string[];
|
|
34
|
+
failed: string[];
|
|
35
|
+
unknownId: string[];
|
|
36
|
+
}
|
|
37
|
+
/** Finish the records of runs that ended (this one, or one that was interrupted): delete each
|
|
38
|
+
* recorded id, and report addresses whose id was never learned (they are never deleted by
|
|
39
|
+
* address). Records of another `somewhere test` still running are left to it. */
|
|
40
|
+
export declare function sweepAccounts(client: ApiClient, root: string, projectId: string): Promise<SweepResult>;
|
|
41
|
+
export declare function describeSweep(result: SweepResult, when: string): string[];
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accounts that `somewhere test` signs up through an app's own form (signUp fixture).
|
|
3
|
+
*
|
|
4
|
+
* These are ordinary app accounts made through the public door, exactly as a visitor makes them:
|
|
5
|
+
* unverified at first, with a password, and no managed test-identity marking or 24 h expiry.
|
|
6
|
+
* Their addresses are at reserved documentation domains, which can never receive mail, so the
|
|
7
|
+
* platform holds their auth mail in the project's test inbox instead of sending it. A reserved
|
|
8
|
+
* address grants nothing by itself.
|
|
9
|
+
*
|
|
10
|
+
* Cleanup is by exact account id only: an id is recorded only when this run's own sign-up
|
|
11
|
+
* response (or its sign-up code step) returned it, and it is deleted with the developer delete.
|
|
12
|
+
* Never by email. The run record is private (.somewhere/tests/accounts, 0700/0600) and holds the
|
|
13
|
+
* project, address, id and run, never a password or code. An interrupted run leaves its records,
|
|
14
|
+
* and the next `somewhere test` for the project finishes them.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, readdirSync, readFileSync, rmSync } from 'node:fs';
|
|
17
|
+
import { join } from 'node:path';
|
|
18
|
+
import { randomBytes } from 'node:crypto';
|
|
19
|
+
import { CliApiError } from './client.js';
|
|
20
|
+
import { ensurePrivateDir, writePrivateFile } from './test-identities.js';
|
|
21
|
+
export const RESERVED_DOMAINS_TEXT = 'example.com, example.org, example.net, or a name ending in .example or .test (for example staff.example)';
|
|
22
|
+
export const DEFAULT_SIGNUP_DOMAIN = 'example.com';
|
|
23
|
+
const EXACT = new Set(['example.com', 'example.org', 'example.net']);
|
|
24
|
+
const SUFFIX_TLDS = new Set(['example', 'test']);
|
|
25
|
+
const LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
26
|
+
const LOCAL = /^[a-z0-9](?:[a-z0-9._+-]{0,62}[a-z0-9])?$/;
|
|
27
|
+
function refuse(value, why) {
|
|
28
|
+
throw new Error(`signUp: "${value}" is not allowed (${why}). Test sign-ups use addresses that can never be a real mailbox: ${RESERVED_DOMAINS_TEXT}.`);
|
|
29
|
+
}
|
|
30
|
+
/** The one rule for a chosen sign-up address. ASCII only, one @, an ordinary local part, DNS
|
|
31
|
+
* labels, case-folded, no trailing dot; the domain is exactly example.com/.org/.net, or has
|
|
32
|
+
* .example or .test as its last label with at least one label before it. Nothing is converted
|
|
33
|
+
* (no IDN mapping, no trimming): input that is not already in this form is refused. Plus
|
|
34
|
+
* addressing is a literal part of the local part, never a signal. */
|
|
35
|
+
export function admitReservedAddress(value) {
|
|
36
|
+
if (typeof value !== 'string')
|
|
37
|
+
throw new Error('signUp: email must be a string.');
|
|
38
|
+
if (!/^[\x21-\x7e]+$/.test(value))
|
|
39
|
+
refuse(value, 'only plain ASCII letters, digits and punctuation, no spaces or display names');
|
|
40
|
+
const lower = value.toLowerCase();
|
|
41
|
+
const parts = lower.split('@');
|
|
42
|
+
if (parts.length !== 2)
|
|
43
|
+
refuse(value, 'exactly one @');
|
|
44
|
+
const [local, domain] = parts;
|
|
45
|
+
if (!LOCAL.test(local) || local.includes('..'))
|
|
46
|
+
refuse(value, 'the part before @ must be letters, digits and . _ + -, not starting or ending with punctuation');
|
|
47
|
+
if (domain.endsWith('.'))
|
|
48
|
+
refuse(value, 'no trailing dot');
|
|
49
|
+
if (domain.length > 253)
|
|
50
|
+
refuse(value, 'domain too long');
|
|
51
|
+
const labels = domain.split('.');
|
|
52
|
+
if (labels.some((label) => !LABEL.test(label)))
|
|
53
|
+
refuse(value, 'the domain must be dot-separated letters, digits and -');
|
|
54
|
+
const tld = labels[labels.length - 1];
|
|
55
|
+
if (!EXACT.has(domain) && !(labels.length >= 2 && SUFFIX_TLDS.has(tld)))
|
|
56
|
+
refuse(value, 'not a reserved domain');
|
|
57
|
+
return lower;
|
|
58
|
+
}
|
|
59
|
+
/** A fresh address at `domain` (reserved-checked); the random part makes a collision with an
|
|
60
|
+
* existing account in the project practically impossible, and a collision still fails. */
|
|
61
|
+
export function generatedAddress(domain = DEFAULT_SIGNUP_DOMAIN) {
|
|
62
|
+
if (typeof domain !== 'string')
|
|
63
|
+
throw new Error('signUp: domain must be a string.');
|
|
64
|
+
return admitReservedAddress(`sw-${randomBytes(6).toString('hex')}@${domain}`);
|
|
65
|
+
}
|
|
66
|
+
/** A generated password: letters, digits and punctuation, long enough for any app minimum. */
|
|
67
|
+
export function generatedPassword() {
|
|
68
|
+
return `Sw-${randomBytes(15).toString('base64url')}-9a`;
|
|
69
|
+
}
|
|
70
|
+
export function accountsDir(root, projectId) {
|
|
71
|
+
if (!/^[A-Za-z0-9-]{1,64}$/.test(projectId))
|
|
72
|
+
throw new Error('Unexpected project id in the test run record.');
|
|
73
|
+
return join(root, '.somewhere', 'tests', 'accounts', projectId);
|
|
74
|
+
}
|
|
75
|
+
/** Write one record per sign-up attempt, before the form is submitted, so an interrupted run is
|
|
76
|
+
* visible to the next one. Returns the record's file path. */
|
|
77
|
+
export function recordAttempt(root, projectId, email) {
|
|
78
|
+
const dir = accountsDir(root, projectId);
|
|
79
|
+
ensurePrivateDir(dir);
|
|
80
|
+
const path = join(dir, `${Date.now()}-${randomBytes(4).toString('hex')}.json`);
|
|
81
|
+
const record = { project_id: projectId, email, id: null, run: process.env.SW_TEST_RUN ?? 'direct', pid: Number(process.env.SW_TEST_RUN_PID ?? process.pid), created_at: new Date().toISOString() };
|
|
82
|
+
writePrivateFile(path, JSON.stringify(record) + '\n');
|
|
83
|
+
return path;
|
|
84
|
+
}
|
|
85
|
+
export function recordId(path, id) {
|
|
86
|
+
const record = JSON.parse(readFileSync(path, 'utf8'));
|
|
87
|
+
writePrivateFile(path, JSON.stringify({ ...record, id }) + '\n');
|
|
88
|
+
}
|
|
89
|
+
export function forgetRecord(path) { rmSync(path, { force: true }); }
|
|
90
|
+
/** Delete one account this run created, by exact id, with the developer delete. A 404 means it
|
|
91
|
+
* is already gone. Returns false when the delete could not be confirmed. */
|
|
92
|
+
export async function deleteAccount(client, projectId, id) {
|
|
93
|
+
try {
|
|
94
|
+
await client.call('DELETE', `/auth/users/${encodeURIComponent(id)}`, undefined, { project_id: projectId });
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return error instanceof CliApiError && error.statusCode === 404;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function alive(pid) {
|
|
102
|
+
if (!Number.isSafeInteger(pid) || pid <= 0 || pid === process.pid)
|
|
103
|
+
return false;
|
|
104
|
+
try {
|
|
105
|
+
process.kill(pid, 0);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
return error.code === 'EPERM';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** Finish the records of runs that ended (this one, or one that was interrupted): delete each
|
|
113
|
+
* recorded id, and report addresses whose id was never learned (they are never deleted by
|
|
114
|
+
* address). Records of another `somewhere test` still running are left to it. */
|
|
115
|
+
export async function sweepAccounts(client, root, projectId) {
|
|
116
|
+
const result = { deleted: [], failed: [], unknownId: [] };
|
|
117
|
+
const dir = accountsDir(root, projectId);
|
|
118
|
+
if (!existsSync(dir))
|
|
119
|
+
return result;
|
|
120
|
+
for (const name of readdirSync(dir).filter((entry) => /^\d+-[0-9a-f]{8}\.json$/.test(entry))) {
|
|
121
|
+
const path = join(dir, name);
|
|
122
|
+
let record;
|
|
123
|
+
try {
|
|
124
|
+
record = JSON.parse(readFileSync(path, 'utf8'));
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
result.failed.push(name);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (record.project_id !== projectId)
|
|
131
|
+
continue;
|
|
132
|
+
if (record.run !== process.env.SW_TEST_RUN && alive(record.pid))
|
|
133
|
+
continue;
|
|
134
|
+
if (record.id === null) {
|
|
135
|
+
result.unknownId.push(record.email);
|
|
136
|
+
forgetRecord(path);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (await deleteAccount(client, projectId, record.id)) {
|
|
140
|
+
result.deleted.push(record.id);
|
|
141
|
+
forgetRecord(path);
|
|
142
|
+
}
|
|
143
|
+
else
|
|
144
|
+
result.failed.push(record.email);
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
export function describeSweep(result, when) {
|
|
149
|
+
const lines = [];
|
|
150
|
+
if (result.deleted.length)
|
|
151
|
+
lines.push(`${when}: deleted ${result.deleted.length} leftover form sign-up account(s) by their recorded ids.`);
|
|
152
|
+
if (result.failed.length)
|
|
153
|
+
lines.push(`${when}: could not delete ${result.failed.length} form sign-up account(s): ${result.failed.join(', ')}; the record is kept and the next run retries.`);
|
|
154
|
+
if (result.unknownId.length)
|
|
155
|
+
lines.push(`${when}: a sign-up was submitted but its account id was never returned, so it was not deleted (accounts are never deleted by address): ${result.unknownId.join(', ')}. If it exists, delete it from the project's users list.`);
|
|
156
|
+
return lines;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=form-accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-accounts.js","sourceRoot":"","sources":["../../src/lib/form-accounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE1E,MAAM,CAAC,MAAM,qBAAqB,GAAG,0GAA0G,CAAC;AAChJ,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AACnD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;AACrE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AACjD,MAAM,KAAK,GAAG,wCAAwC,CAAC;AACvD,MAAM,KAAK,GAAG,2CAA2C,CAAC;AAE1D,SAAS,MAAM,CAAC,KAAa,EAAE,GAAW;IACxC,MAAM,IAAI,KAAK,CAAC,YAAY,KAAK,qBAAqB,GAAG,oEAAoE,qBAAqB,GAAG,CAAC,CAAC;AACzJ,CAAC;AAED;;;;sEAIsE;AACtE,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAClF,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM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C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAAC,SAAS;QAAC,CAAC;QAC9F,IAAI,MAAM,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;YAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAAC,CAAC;;YACzG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAmB,EAAE,IAAY;IAC7D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,aAAa,MAAM,CAAC,OAAO,CAAC,MAAM,0DAA0D,CAAC,CAAC;IAC3I,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,sBAAsB,MAAM,CAAC,MAAM,CAAC,MAAM,6BAA6B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;IAC7L,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,mIAAmI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;IACzQ,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const AGENT_WORKFLOW = "## Build, deploy, test\n\nEnough to start a typical app: declare access and use the browser client; docs are for exceptions.\n\n| Requirement | Declaration below |\n| --- | --- |\n| Each user sees only their own rows | notes: owner() |\n| Team: owner adds members; members read/write; creator rights | teams/team_members/tasks: owner() + member(); role-owner delete branch |\n| Owner/staff record with staff-only child notes | tickets: owner() or appRole(); parent() thread; staff-only notes; POST setup below |\n| Public pages from private drafts | pages: conditional publicRead |\n| Share one record read-only | shared_notes/note_shares: read-only grant() |\n\ndb/schema.ts is declaration only: imports, constants/spreads, default schema;\nno helpers/expressions. id() is random text; owner() stamps user_id. client.read\nincludes the key. Inside anyOf(), owner() takes only column/read: it stamps the\ncreator, not create/delete options; member() gates placement (non-member create is\nrefused), while creators or the allowed branch can delete. Other fields: timestamp({ default: 'now' }), text({ nullable: true });\nindexes: [['team_id']].\n\n```ts\nimport { schema, table, id, text, owner, member, anyOf, serverOnly, parent, appRole, boolean, grant } from 'somewhere/db';\nexport default schema({\n notes: table({ id: id(), title: text() }, { scope: owner(), client: { read: ['id', 'title'], create: ['title'], update: ['title'], delete: true },\n }),\n teams: table({ id: id(), name: text(), owner_id: text() }, {\n scope: member({ group: 'id', membership: 'team_members', member_user: 'user_id', member_group: 'team_id' }),\n client: { read: ['id', 'name'] },\n }),\n team_members: table({ id: id(), team_id: text(), user_id: text(), role: text() }, {\n scope: serverOnly(), unique: [['team_id', 'user_id']],\n }),\n tasks: table({ id: id(), team_id: text({ references: 'teams' }), title: text() }, {\n scope: anyOf(owner(), member({ group: 'team_id', membership: 'team_members',\n member_user: 'user_id', member_group: 'team_id', operations: ['read', 'create', 'update'] }),\n member({ group: 'team_id', membership: 'team_members', member_user: 'user_id',\n member_group: 'team_id', where: { role: 'owner' }, operations: ['delete'] })),\n client: { read: ['id', 'team_id', 'title'], create: ['team_id', 'title'], update: ['title'], delete: true },\n }),\n tickets: table({ id: id(), subject: text() }, {\n scope: anyOf(owner(), appRole({ roles: { read: ['staff'], create: ['staff'], update: ['staff'] } })),\n client: { read: true, create: ['subject'], update: ['subject'] },\n }),\n messages: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, {\n scope: parent({ via: 'ticket_id' }),\n client: { read: true, create: ['ticket_id', 'body'] },\n }),\n staff_notes: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, {\n scope: appRole({ roles: { read: ['staff'], create: ['staff'] } }),\n client: { read: true, create: ['ticket_id', 'body'] },\n }),\n pages: table({ id: id(), title: text(), published: boolean({ default: false }) }, {\n scope: owner(), client: { read: ['id', 'title'], create: ['title'], update: ['title'],\n publicRead: { where: { published: true } } },\n }),\n note_shares: table({ id: id(), grantee_id: text(), note_id: text({ references: 'shared_notes', onDelete: 'cascade' }) }, {\n scope: owner(), unique: [['note_id', 'grantee_id']],\n }),\n shared_notes: table({ id: id(), title: text() }, {\n scope: anyOf(owner(), grant({ table: 'note_shares', grantee: 'grantee_id', row: 'note_id', operations: ['read'] })),\n client: { read: ['id', 'title'], create: ['title'], update: ['title'] },\n }),\n}, { appRoles: { staff: { assignedBy: 'server' } } });\n```\n\nPOST role setup once after sign-up/profile completion, not GET/every request:\ncookie-authenticated GET cannot mutate roles.\nCheck admin here, or your own assignment rule.\nmessages use parent(): owner() would hide staff replies from the customer.\nUse emailDomain for staff at your verified domain; assignedBy: 'server' when the\napp decides (promotion, payment, invitation). An email ending proves identity only\nwhen verified; assigning a role anyway is your app's decision, whose permissions the platform enforces.\nPublish pages in an owner-checked endpoint. Share with caller-scoped\nsw.db.insert('note_shares', { grantee_id, note_id }); it checks row ownership.\nBrowser calls THROW, not { error }; catch below.\nBrowser list: max 100, paginate after; no order (sort locally or in an endpoint).\n\n```ts\nimport { data } from 'somewhere:data';\nexport async function save(title: string) {\n try { await data.notes.create({ title }); return null; }\n catch (e) { return e instanceof Error ? e.message : 'Save failed'; }\n}\nexport const list = (after?: string) => data.notes.list({ limit: 100, after });\n```\n\nTeams without verification: own membership table + member(); sw.groups and domain\nroles need VERIFIED emails. Members read/create/update tasks; creators or team owners delete while members.\nRestrictions narrow operations, not grant read.\nComment-author-or-team-owner deletion stays a small endpoint.\nCreate the team and its owner membership atomically:\n\n```ts\n// api/teams.ts\nexport default sw.endpoint({\n auth: 'required', body: { name: 'string' },\n handler: async ({ user, params, body }, sw) => {\n const id = crypto.randomUUID();\n await sw.db.server.tx([\n { op: 'insert', table: 'teams', values: { id, name: body.name, owner_id: user.id } },\n { op: 'insert', table: 'team_members', values: { id: crypto.randomUUID(), team_id: id, user_id: user.id, role: 'owner' } },\n ]);\n return { id, email: user.email };\n },\n});\n```\n\n```ts\n// api/teams/[id]/members.ts \u2014 only the team owner adds a member\nexport default sw.endpoint({\n auth: 'required', body: { email: 'string' },\n handler: async ({ user, params, body }, sw) => {\n const { data: teams } = await sw.db.from('teams', { where: { id: params.id, owner_id: user.id }, limit: 1 });\n if (!teams[0]) return Response.json({ error: 'Team owner required' }, { status: 403 });\n const { users: [target] } = await sw.auth.server.listUsers({ emails: [body.email] });\n if (!target) return Response.json({ error: 'Account not found' }, { status: 404 });\n await sw.db.server.insert('team_members', {\n id: crypto.randomUUID(), team_id: params.id, user_id: target.id, role: 'member',\n }, { onConflict: 'ignore' });\n return { ok: true };\n },\n});\n```\n\n```ts\n// api/complete-profile.ts \u2014 POST once when an admin assigns staff after sign-up\nexport default sw.endpoint({\n auth: 'required', body: { userId: 'string' },\n handler: async ({ request, body }, sw) => {\n await sw.auth.requireUser(request, { role: 'admin' });\n await sw.auth.server.setRoles(body.userId, { add: ['staff'] });\n return { ok: true };\n },\n});\n```\n\nDo not hand-write access to app-read/write data: declare who may read/write it.\nserverOnly() fits job/import/audit/counter state and protected membership ledgers.\nGrant ledgers use owner() without browser writes. Undeclarable: arbitrary predicates\n(e.g. expiry) or per-role writable fields (split tables or check that write).\n\nBuild src/pages/HomePage.tsx; routes src/App.tsx + src/routes.ts; auth src/auth/hooks.ts.\nAuth is wired: keep api/auth/[...path].ts; src/config.ts controls providers.\napi/notes/[id]/sub.ts \u2192 params.id; underscore files are helpers. POST: default export;\nGET/DELETE: named exports.\n\n```ts\nexport const GET = sw.endpoint({ auth: 'required', handler: async (_, sw) => sw.db.from('notes', { limit: 100 }) });\n```\n\nsw.db applies caller scopes; sw.db.server bypasses them: authorize first.\nReads: from(table, { where, columns, order: [['id', 'asc']], limit, offset }).\nFilter: { id: { in: ids } }; unique: [['a', 'b']] in schema.\nWrites: insert(table, values), update(table, { where, set }), remove(table, { where }).\ntx takes an ARRAY of write intents, never a callback; pre-generate related IDs.\n\nBrowser: fetch(path, { method: 'POST', credentials: 'same-origin',\nheaders: { 'content-type': 'application/json' }, body: JSON.stringify(values) }).\nAccess cookies refresh automatically. Cookie-auth POST/PATCH/DELETE from scripts\nneed Origin equal to the app URL.\n\nPublish: npx @somewhere-cloud/cli deploy, then somewhere test for the rules you changed.\nDeploy raw source, no frontend build; type errors stop upload.\nnewUser() gives a signed-in page/API client; call N times (owner, member, outsider).\nNo chosen email argument: assign roles/memberships through your app's authorized POST setup.\nTest users are verified and visible to this project's server user lookup.\nFor the complete owner-adds-member-by-email test and its endpoints, run\nsomewhere docs test and follow Two users sharing through the app.\nDiagnose with somewhere errors and somewhere logs.\n\nOn demand:\n- Server paging: `somewhere docs sw.db --section server-read-paging`\n\n## Testing shared access\n\nWith the teams and membership endpoints above, the owner adds a fixture by email\nand that fixture reads the shared team row:\n\n```ts\n// tests/team.spec.ts\nimport { test, expect, data } from '@somewhere-cloud/cli/testing';\ntest('owner adds a second user by email', async ({ newUser }) => {\n const owner = await newUser();\n const bob = await newUser();\n const name = `Shared team ${crypto.randomUUID()}`;\n const created = await owner.request.post('/api/teams', { data: { name } });\n expect(created.ok()).toBeTruthy();\n const { id } = await created.json();\n const added = await owner.request.post(`/api/teams/${id}/members`, { data: { email: bob.email } });\n expect(added.ok()).toBeTruthy();\n const response = await data(bob.request, 'teams', { operation: 'get', id });\n expect(response.ok()).toBeTruthy();\n expect((await response.json()).data).toMatchObject({ id, name });\n});\n```\n";
|
|
1
|
+
export declare const AGENT_WORKFLOW = "## Build, deploy, test\n\nEnough to start a typical app: declare access and use the browser client; docs are for exceptions.\n\n| Requirement | Declaration below |\n| --- | --- |\n| Each user sees only their own rows | notes: owner() |\n| Team: owner adds members; members read/write; creator rights | teams/team_members/tasks: owner() + member(); role-owner delete branch |\n| Owner/staff record with staff-only child notes | tickets: owner() or appRole(); parent() thread; staff-only notes; POST setup below |\n| Public pages from private drafts | pages: conditional publicRead |\n| Share one record read-only | shared_notes/note_shares: read-only grant() |\n\ndb/schema.ts is declaration only: imports, constants/spreads, default schema;\nno helpers/expressions. id() is random text; owner() stamps user_id. client.read\nincludes the key. Inside anyOf(), owner() takes only column/read: it stamps the\ncreator, not create/delete options; member() gates placement (non-member create is\nrefused), while creators or the allowed branch can delete. Other fields: timestamp({ default: 'now' }), text({ nullable: true });\nindexes: [['team_id']].\n\n```ts\nimport { schema, table, id, text, owner, member, anyOf, serverOnly, parent, appRole, boolean, grant } from 'somewhere/db';\nexport default schema({\n notes: table({ id: id(), title: text() }, { scope: owner(), client: { read: ['id', 'title'], create: ['title'], update: ['title'], delete: true },\n }),\n teams: table({ id: id(), name: text(), owner_id: text() }, {\n scope: member({ group: 'id', membership: 'team_members', member_user: 'user_id', member_group: 'team_id' }),\n client: { read: ['id', 'name'] },\n }),\n team_members: table({ id: id(), team_id: text(), user_id: text(), role: text() }, {\n scope: serverOnly(), unique: [['team_id', 'user_id']],\n }),\n tasks: table({ id: id(), team_id: text({ references: 'teams' }), title: text() }, {\n scope: anyOf(owner(), member({ group: 'team_id', membership: 'team_members',\n member_user: 'user_id', member_group: 'team_id', operations: ['read', 'create', 'update'] }),\n member({ group: 'team_id', membership: 'team_members', member_user: 'user_id',\n member_group: 'team_id', where: { role: 'owner' }, operations: ['delete'] })),\n client: { read: ['id', 'team_id', 'title'], create: ['team_id', 'title'], update: ['title'], delete: true },\n }),\n tickets: table({ id: id(), subject: text() }, {\n scope: anyOf(owner(), appRole({ roles: { read: ['staff'], create: ['staff'], update: ['staff'] } })),\n client: { read: true, create: ['subject'], update: ['subject'] },\n }),\n messages: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, {\n scope: parent({ via: 'ticket_id' }),\n client: { read: true, create: ['ticket_id', 'body'] },\n }),\n staff_notes: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, {\n scope: appRole({ roles: { read: ['staff'], create: ['staff'] } }),\n client: { read: true, create: ['ticket_id', 'body'] },\n }),\n pages: table({ id: id(), title: text(), published: boolean({ default: false }) }, {\n scope: owner(), client: { read: ['id', 'title'], create: ['title'], update: ['title'],\n publicRead: { where: { published: true } } },\n }),\n note_shares: table({ id: id(), grantee_id: text(), note_id: text({ references: 'shared_notes', onDelete: 'cascade' }) }, {\n scope: owner(), unique: [['note_id', 'grantee_id']],\n }),\n shared_notes: table({ id: id(), title: text() }, {\n scope: anyOf(owner(), grant({ table: 'note_shares', grantee: 'grantee_id', row: 'note_id', operations: ['read'] })),\n client: { read: ['id', 'title'], create: ['title'], update: ['title'] },\n }),\n}, { appRoles: { staff: { assignedBy: 'server' } } });\n```\n\nPOST role setup once after sign-up/profile completion, not GET/every request:\ncookie-authenticated GET cannot mutate roles.\nCheck admin here, or your own assignment rule.\nmessages use parent(): owner() would hide staff replies from the customer.\nUse emailDomain for staff at your verified domain; assignedBy: 'server' when the\napp decides (promotion, payment, invitation). An email ending proves identity only\nwhen verified; assigning a role anyway is your app's decision, whose permissions the platform enforces.\nPublish pages in an owner-checked endpoint. Share with caller-scoped\nsw.db.insert('note_shares', { grantee_id, note_id }); it checks row ownership.\nBrowser calls THROW, not { error }; catch below.\nBrowser list: max 100, paginate after; no order (sort locally or in an endpoint).\n\n```ts\nimport { data } from 'somewhere:data';\nexport async function save(title: string) {\n try { await data.notes.create({ title }); return null; }\n catch (e) { return e instanceof Error ? e.message : 'Save failed'; }\n}\nexport const list = (after?: string) => data.notes.list({ limit: 100, after });\n```\n\nTeams without verification: own membership table + member(); sw.groups and domain\nroles need VERIFIED emails. Members read/create/update tasks; creators or team owners delete while members.\nRestrictions narrow operations, not grant read.\nComment-author-or-team-owner deletion stays a small endpoint.\nCreate the team and its owner membership atomically:\n\n```ts\n// api/teams.ts\nexport default sw.endpoint({\n auth: 'required', body: { name: 'string' },\n handler: async ({ user, params, body }, sw) => {\n const id = crypto.randomUUID();\n await sw.db.server.tx([\n { op: 'insert', table: 'teams', values: { id, name: body.name, owner_id: user.id } },\n { op: 'insert', table: 'team_members', values: { id: crypto.randomUUID(), team_id: id, user_id: user.id, role: 'owner' } },\n ]);\n return { id, email: user.email };\n },\n});\n```\n\n```ts\n// api/teams/[id]/members.ts \u2014 only the team owner adds a member\nexport default sw.endpoint({\n auth: 'required', body: { email: 'string' },\n handler: async ({ user, params, body }, sw) => {\n const { data: teams } = await sw.db.from('teams', { where: { id: params.id, owner_id: user.id }, limit: 1 });\n if (!teams[0]) return Response.json({ error: 'Team owner required' }, { status: 403 });\n const { users: [target] } = await sw.auth.server.listUsers({ emails: [body.email] });\n if (!target) return Response.json({ error: 'Account not found' }, { status: 404 });\n await sw.db.server.insert('team_members', {\n id: crypto.randomUUID(), team_id: params.id, user_id: target.id, role: 'member',\n }, { onConflict: 'ignore' });\n return { ok: true };\n },\n});\n```\n\n```ts\n// api/complete-profile.ts \u2014 POST once when an admin assigns staff after sign-up\nexport default sw.endpoint({\n auth: 'required', body: { userId: 'string' },\n handler: async ({ request, body }, sw) => {\n await sw.auth.requireUser(request, { role: 'admin' });\n await sw.auth.server.setRoles(body.userId, { add: ['staff'] });\n return { ok: true };\n },\n});\n```\n\nDo not hand-write access to app-read/write data: declare who may read/write it.\nserverOnly() fits job/import/audit/counter state and protected membership ledgers.\nGrant ledgers use owner() without browser writes. Undeclarable: arbitrary predicates\n(e.g. expiry) or per-role writable fields (split tables or check that write).\n\nBuild src/pages/HomePage.tsx; routes src/App.tsx + src/routes.ts; auth src/auth/hooks.ts.\nAuth is wired: keep api/auth/[...path].ts; src/config.ts controls providers.\napi/notes/[id]/sub.ts \u2192 params.id; underscore files are helpers. POST: default export;\nGET/DELETE: named exports.\n\n```ts\nexport const GET = sw.endpoint({ auth: 'required', handler: async (_, sw) => sw.db.from('notes', { limit: 100 }) });\n```\n\nsw.db applies caller scopes; sw.db.server bypasses them: authorize first.\nReads: from(table, { where, columns, order: [['id', 'asc']], limit, offset }).\nFilter: { id: { in: ids } }; unique: [['a', 'b']] in schema.\nWrites: insert(table, values), update(table, { where, set }), remove(table, { where }).\ntx takes an ARRAY of write intents, never a callback; pre-generate related IDs.\n\nBrowser: fetch(path, { method: 'POST', credentials: 'same-origin',\nheaders: { 'content-type': 'application/json' }, body: JSON.stringify(values) }).\nAccess cookies refresh automatically. Cookie-auth POST/PATCH/DELETE from scripts\nneed Origin equal to the app URL.\n\nPublish: npx @somewhere-cloud/cli deploy, then somewhere test for the rules you changed.\nOne somewhere test run drives the UI and calls the API: signUp(page) uses your sign-up form\n(then signOut, signIn with its password, verify with the emailed code), newUser() acts as\nseveral people, and ready(page, 'signed-in' | 'signed-out') waits for the session check.\nYou do not need a separate browser script.\nDeploy raw source, no frontend build; type errors stop upload.\nnewUser() gives a signed-in page/API client; call N times (owner, member, outsider).\nNo chosen email argument: assign roles/memberships through your app's authorized POST setup.\nTest users are verified and visible to this project's server user lookup.\nEmail-domain role: signUp(page, { domain: 'staff.example' }), then verify(page, person).\nFor the complete owner-adds-member-by-email test and its endpoints, run\nsomewhere docs test and follow Two users sharing through the app.\nDiagnose with somewhere errors and somewhere logs.\n\nOn demand:\n- Server paging: `somewhere docs sw.db --section server-read-paging`\n\n## Testing shared access\n\nWith the teams and membership endpoints above, the owner adds a fixture by email\nand that fixture reads the shared team row:\n\n```ts\n// tests/team.spec.ts\nimport { test, expect, data } from '@somewhere-cloud/cli/testing';\ntest('owner adds a second user by email', async ({ newUser }) => {\n const owner = await newUser();\n const bob = await newUser();\n const name = `Shared team ${crypto.randomUUID()}`;\n const created = await owner.request.post('/api/teams', { data: { name } });\n expect(created.ok()).toBeTruthy();\n const { id } = await created.json();\n const added = await owner.request.post(`/api/teams/${id}/members`, { data: { email: bob.email } });\n expect(added.ok()).toBeTruthy();\n const response = await data(bob.request, 'teams', { operation: 'get', id });\n expect(response.ok()).toBeTruthy();\n expect((await response.json()).data).toMatchObject({ id, name });\n});\n```\n";
|
|
2
2
|
export declare const SKILLS_POINTER = "Task-specific skills: `.agents/skills/`. Inspect/update with somewhere skills status/update.";
|
|
3
3
|
export declare const DECLARED_ACCESS_POINTER = "";
|
|
4
4
|
/** One line telling agents the app's data and code can leave:
|
|
@@ -7,5 +7,5 @@ export declare const DECLARED_ACCESS_POINTER = "";
|
|
|
7
7
|
export declare const PORTABILITY_POINTER = "Data/code export limits: `somewhere docs portability`.";
|
|
8
8
|
/** One line: using the app from Claude as its signed-in user (MCP tools). */
|
|
9
9
|
export declare const MCP_POINTER = "Use this app from Claude as its signed-in user (MCP tools): `somewhere docs sw.endpoint --section mcp-tools-for-claude`.";
|
|
10
|
-
export declare const INIT_AGENTS_MD = "# somewhere.cloud project contract\n## Build, deploy, test\n\nEnough to start a typical app: declare access and use the browser client; docs are for exceptions.\n\n| Requirement | Declaration below |\n| --- | --- |\n| Each user sees only their own rows | notes: owner() |\n| Team: owner adds members; members read/write; creator rights | teams/team_members/tasks: owner() + member(); role-owner delete branch |\n| Owner/staff record with staff-only child notes | tickets: owner() or appRole(); parent() thread; staff-only notes; POST setup below |\n| Public pages from private drafts | pages: conditional publicRead |\n| Share one record read-only | shared_notes/note_shares: read-only grant() |\n\ndb/schema.ts is declaration only: imports, constants/spreads, default schema;\nno helpers/expressions. id() is random text; owner() stamps user_id. client.read\nincludes the key. Inside anyOf(), owner() takes only column/read: it stamps the\ncreator, not create/delete options; member() gates placement (non-member create is\nrefused), while creators or the allowed branch can delete. Other fields: timestamp({ default: 'now' }), text({ nullable: true });\nindexes: [['team_id']].\n\n```ts\nimport { schema, table, id, text, owner, member, anyOf, serverOnly, parent, appRole, boolean, grant } from 'somewhere/db';\nexport default schema({\n notes: table({ id: id(), title: text() }, { scope: owner(), client: { read: ['id', 'title'], create: ['title'], update: ['title'], delete: true },\n }),\n teams: table({ id: id(), name: text(), owner_id: text() }, {\n scope: member({ group: 'id', membership: 'team_members', member_user: 'user_id', member_group: 'team_id' }),\n client: { read: ['id', 'name'] },\n }),\n team_members: table({ id: id(), team_id: text(), user_id: text(), role: text() }, {\n scope: serverOnly(), unique: [['team_id', 'user_id']],\n }),\n tasks: table({ id: id(), team_id: text({ references: 'teams' }), title: text() }, {\n scope: anyOf(owner(), member({ group: 'team_id', membership: 'team_members',\n member_user: 'user_id', member_group: 'team_id', operations: ['read', 'create', 'update'] }),\n member({ group: 'team_id', membership: 'team_members', member_user: 'user_id',\n member_group: 'team_id', where: { role: 'owner' }, operations: ['delete'] })),\n client: { read: ['id', 'team_id', 'title'], create: ['team_id', 'title'], update: ['title'], delete: true },\n }),\n tickets: table({ id: id(), subject: text() }, {\n scope: anyOf(owner(), appRole({ roles: { read: ['staff'], create: ['staff'], update: ['staff'] } })),\n client: { read: true, create: ['subject'], update: ['subject'] },\n }),\n messages: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, {\n scope: parent({ via: 'ticket_id' }),\n client: { read: true, create: ['ticket_id', 'body'] },\n }),\n staff_notes: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, {\n scope: appRole({ roles: { read: ['staff'], create: ['staff'] } }),\n client: { read: true, create: ['ticket_id', 'body'] },\n }),\n pages: table({ id: id(), title: text(), published: boolean({ default: false }) }, {\n scope: owner(), client: { read: ['id', 'title'], create: ['title'], update: ['title'],\n publicRead: { where: { published: true } } },\n }),\n note_shares: table({ id: id(), grantee_id: text(), note_id: text({ references: 'shared_notes', onDelete: 'cascade' }) }, {\n scope: owner(), unique: [['note_id', 'grantee_id']],\n }),\n shared_notes: table({ id: id(), title: text() }, {\n scope: anyOf(owner(), grant({ table: 'note_shares', grantee: 'grantee_id', row: 'note_id', operations: ['read'] })),\n client: { read: ['id', 'title'], create: ['title'], update: ['title'] },\n }),\n}, { appRoles: { staff: { assignedBy: 'server' } } });\n```\n\nPOST role setup once after sign-up/profile completion, not GET/every request:\ncookie-authenticated GET cannot mutate roles.\nCheck admin here, or your own assignment rule.\nmessages use parent(): owner() would hide staff replies from the customer.\nUse emailDomain for staff at your verified domain; assignedBy: 'server' when the\napp decides (promotion, payment, invitation). An email ending proves identity only\nwhen verified; assigning a role anyway is your app's decision, whose permissions the platform enforces.\nPublish pages in an owner-checked endpoint. Share with caller-scoped\nsw.db.insert('note_shares', { grantee_id, note_id }); it checks row ownership.\nBrowser calls THROW, not { error }; catch below.\nBrowser list: max 100, paginate after; no order (sort locally or in an endpoint).\n\n```ts\nimport { data } from 'somewhere:data';\nexport async function save(title: string) {\n try { await data.notes.create({ title }); return null; }\n catch (e) { return e instanceof Error ? e.message : 'Save failed'; }\n}\nexport const list = (after?: string) => data.notes.list({ limit: 100, after });\n```\n\nTeams without verification: own membership table + member(); sw.groups and domain\nroles need VERIFIED emails. Members read/create/update tasks; creators or team owners delete while members.\nRestrictions narrow operations, not grant read.\nComment-author-or-team-owner deletion stays a small endpoint.\nCreate the team and its owner membership atomically:\n\n```ts\n// api/teams.ts\nexport default sw.endpoint({\n auth: 'required', body: { name: 'string' },\n handler: async ({ user, params, body }, sw) => {\n const id = crypto.randomUUID();\n await sw.db.server.tx([\n { op: 'insert', table: 'teams', values: { id, name: body.name, owner_id: user.id } },\n { op: 'insert', table: 'team_members', values: { id: crypto.randomUUID(), team_id: id, user_id: user.id, role: 'owner' } },\n ]);\n return { id, email: user.email };\n },\n});\n```\n\n```ts\n// api/teams/[id]/members.ts \u2014 only the team owner adds a member\nexport default sw.endpoint({\n auth: 'required', body: { email: 'string' },\n handler: async ({ user, params, body }, sw) => {\n const { data: teams } = await sw.db.from('teams', { where: { id: params.id, owner_id: user.id }, limit: 1 });\n if (!teams[0]) return Response.json({ error: 'Team owner required' }, { status: 403 });\n const { users: [target] } = await sw.auth.server.listUsers({ emails: [body.email] });\n if (!target) return Response.json({ error: 'Account not found' }, { status: 404 });\n await sw.db.server.insert('team_members', {\n id: crypto.randomUUID(), team_id: params.id, user_id: target.id, role: 'member',\n }, { onConflict: 'ignore' });\n return { ok: true };\n },\n});\n```\n\n```ts\n// api/complete-profile.ts \u2014 POST once when an admin assigns staff after sign-up\nexport default sw.endpoint({\n auth: 'required', body: { userId: 'string' },\n handler: async ({ request, body }, sw) => {\n await sw.auth.requireUser(request, { role: 'admin' });\n await sw.auth.server.setRoles(body.userId, { add: ['staff'] });\n return { ok: true };\n },\n});\n```\n\nDo not hand-write access to app-read/write data: declare who may read/write it.\nserverOnly() fits job/import/audit/counter state and protected membership ledgers.\nGrant ledgers use owner() without browser writes. Undeclarable: arbitrary predicates\n(e.g. expiry) or per-role writable fields (split tables or check that write).\n\nBuild src/pages/HomePage.tsx; routes src/App.tsx + src/routes.ts; auth src/auth/hooks.ts.\nAuth is wired: keep api/auth/[...path].ts; src/config.ts controls providers.\napi/notes/[id]/sub.ts \u2192 params.id; underscore files are helpers. POST: default export;\nGET/DELETE: named exports.\n\n```ts\nexport const GET = sw.endpoint({ auth: 'required', handler: async (_, sw) => sw.db.from('notes', { limit: 100 }) });\n```\n\nsw.db applies caller scopes; sw.db.server bypasses them: authorize first.\nReads: from(table, { where, columns, order: [['id', 'asc']], limit, offset }).\nFilter: { id: { in: ids } }; unique: [['a', 'b']] in schema.\nWrites: insert(table, values), update(table, { where, set }), remove(table, { where }).\ntx takes an ARRAY of write intents, never a callback; pre-generate related IDs.\n\nBrowser: fetch(path, { method: 'POST', credentials: 'same-origin',\nheaders: { 'content-type': 'application/json' }, body: JSON.stringify(values) }).\nAccess cookies refresh automatically. Cookie-auth POST/PATCH/DELETE from scripts\nneed Origin equal to the app URL.\n\nPublish: npx @somewhere-cloud/cli deploy, then somewhere test for the rules you changed.\nDeploy raw source, no frontend build; type errors stop upload.\nnewUser() gives a signed-in page/API client; call N times (owner, member, outsider).\nNo chosen email argument: assign roles/memberships through your app's authorized POST setup.\nTest users are verified and visible to this project's server user lookup.\nFor the complete owner-adds-member-by-email test and its endpoints, run\nsomewhere docs test and follow Two users sharing through the app.\nDiagnose with somewhere errors and somewhere logs.\n\nOn demand:\n- Server paging: `somewhere docs sw.db --section server-read-paging`\n\n## Testing shared access\n\nWith the teams and membership endpoints above, the owner adds a fixture by email\nand that fixture reads the shared team row:\n\n```ts\n// tests/team.spec.ts\nimport { test, expect, data } from '@somewhere-cloud/cli/testing';\ntest('owner adds a second user by email', async ({ newUser }) => {\n const owner = await newUser();\n const bob = await newUser();\n const name = `Shared team ${crypto.randomUUID()}`;\n const created = await owner.request.post('/api/teams', { data: { name } });\n expect(created.ok()).toBeTruthy();\n const { id } = await created.json();\n const added = await owner.request.post(`/api/teams/${id}/members`, { data: { email: bob.email } });\n expect(added.ok()).toBeTruthy();\n const response = await data(bob.request, 'teams', { operation: 'get', id });\n expect(response.ok()).toBeTruthy();\n expect((await response.json()).data).toMatchObject({ id, name });\n});\n```\n\nTask-specific skills: `.agents/skills/`. Inspect/update with somewhere skills status/update.\nData/code export limits: `somewhere docs portability`.\nUse this app from Claude as its signed-in user (MCP tools): `somewhere docs sw.endpoint --section mcp-tools-for-claude`.\n";
|
|
10
|
+
export declare const INIT_AGENTS_MD = "# somewhere.cloud project contract\n## Build, deploy, test\n\nEnough to start a typical app: declare access and use the browser client; docs are for exceptions.\n\n| Requirement | Declaration below |\n| --- | --- |\n| Each user sees only their own rows | notes: owner() |\n| Team: owner adds members; members read/write; creator rights | teams/team_members/tasks: owner() + member(); role-owner delete branch |\n| Owner/staff record with staff-only child notes | tickets: owner() or appRole(); parent() thread; staff-only notes; POST setup below |\n| Public pages from private drafts | pages: conditional publicRead |\n| Share one record read-only | shared_notes/note_shares: read-only grant() |\n\ndb/schema.ts is declaration only: imports, constants/spreads, default schema;\nno helpers/expressions. id() is random text; owner() stamps user_id. client.read\nincludes the key. Inside anyOf(), owner() takes only column/read: it stamps the\ncreator, not create/delete options; member() gates placement (non-member create is\nrefused), while creators or the allowed branch can delete. Other fields: timestamp({ default: 'now' }), text({ nullable: true });\nindexes: [['team_id']].\n\n```ts\nimport { schema, table, id, text, owner, member, anyOf, serverOnly, parent, appRole, boolean, grant } from 'somewhere/db';\nexport default schema({\n notes: table({ id: id(), title: text() }, { scope: owner(), client: { read: ['id', 'title'], create: ['title'], update: ['title'], delete: true },\n }),\n teams: table({ id: id(), name: text(), owner_id: text() }, {\n scope: member({ group: 'id', membership: 'team_members', member_user: 'user_id', member_group: 'team_id' }),\n client: { read: ['id', 'name'] },\n }),\n team_members: table({ id: id(), team_id: text(), user_id: text(), role: text() }, {\n scope: serverOnly(), unique: [['team_id', 'user_id']],\n }),\n tasks: table({ id: id(), team_id: text({ references: 'teams' }), title: text() }, {\n scope: anyOf(owner(), member({ group: 'team_id', membership: 'team_members',\n member_user: 'user_id', member_group: 'team_id', operations: ['read', 'create', 'update'] }),\n member({ group: 'team_id', membership: 'team_members', member_user: 'user_id',\n member_group: 'team_id', where: { role: 'owner' }, operations: ['delete'] })),\n client: { read: ['id', 'team_id', 'title'], create: ['team_id', 'title'], update: ['title'], delete: true },\n }),\n tickets: table({ id: id(), subject: text() }, {\n scope: anyOf(owner(), appRole({ roles: { read: ['staff'], create: ['staff'], update: ['staff'] } })),\n client: { read: true, create: ['subject'], update: ['subject'] },\n }),\n messages: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, {\n scope: parent({ via: 'ticket_id' }),\n client: { read: true, create: ['ticket_id', 'body'] },\n }),\n staff_notes: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, {\n scope: appRole({ roles: { read: ['staff'], create: ['staff'] } }),\n client: { read: true, create: ['ticket_id', 'body'] },\n }),\n pages: table({ id: id(), title: text(), published: boolean({ default: false }) }, {\n scope: owner(), client: { read: ['id', 'title'], create: ['title'], update: ['title'],\n publicRead: { where: { published: true } } },\n }),\n note_shares: table({ id: id(), grantee_id: text(), note_id: text({ references: 'shared_notes', onDelete: 'cascade' }) }, {\n scope: owner(), unique: [['note_id', 'grantee_id']],\n }),\n shared_notes: table({ id: id(), title: text() }, {\n scope: anyOf(owner(), grant({ table: 'note_shares', grantee: 'grantee_id', row: 'note_id', operations: ['read'] })),\n client: { read: ['id', 'title'], create: ['title'], update: ['title'] },\n }),\n}, { appRoles: { staff: { assignedBy: 'server' } } });\n```\n\nPOST role setup once after sign-up/profile completion, not GET/every request:\ncookie-authenticated GET cannot mutate roles.\nCheck admin here, or your own assignment rule.\nmessages use parent(): owner() would hide staff replies from the customer.\nUse emailDomain for staff at your verified domain; assignedBy: 'server' when the\napp decides (promotion, payment, invitation). An email ending proves identity only\nwhen verified; assigning a role anyway is your app's decision, whose permissions the platform enforces.\nPublish pages in an owner-checked endpoint. Share with caller-scoped\nsw.db.insert('note_shares', { grantee_id, note_id }); it checks row ownership.\nBrowser calls THROW, not { error }; catch below.\nBrowser list: max 100, paginate after; no order (sort locally or in an endpoint).\n\n```ts\nimport { data } from 'somewhere:data';\nexport async function save(title: string) {\n try { await data.notes.create({ title }); return null; }\n catch (e) { return e instanceof Error ? e.message : 'Save failed'; }\n}\nexport const list = (after?: string) => data.notes.list({ limit: 100, after });\n```\n\nTeams without verification: own membership table + member(); sw.groups and domain\nroles need VERIFIED emails. Members read/create/update tasks; creators or team owners delete while members.\nRestrictions narrow operations, not grant read.\nComment-author-or-team-owner deletion stays a small endpoint.\nCreate the team and its owner membership atomically:\n\n```ts\n// api/teams.ts\nexport default sw.endpoint({\n auth: 'required', body: { name: 'string' },\n handler: async ({ user, params, body }, sw) => {\n const id = crypto.randomUUID();\n await sw.db.server.tx([\n { op: 'insert', table: 'teams', values: { id, name: body.name, owner_id: user.id } },\n { op: 'insert', table: 'team_members', values: { id: crypto.randomUUID(), team_id: id, user_id: user.id, role: 'owner' } },\n ]);\n return { id, email: user.email };\n },\n});\n```\n\n```ts\n// api/teams/[id]/members.ts \u2014 only the team owner adds a member\nexport default sw.endpoint({\n auth: 'required', body: { email: 'string' },\n handler: async ({ user, params, body }, sw) => {\n const { data: teams } = await sw.db.from('teams', { where: { id: params.id, owner_id: user.id }, limit: 1 });\n if (!teams[0]) return Response.json({ error: 'Team owner required' }, { status: 403 });\n const { users: [target] } = await sw.auth.server.listUsers({ emails: [body.email] });\n if (!target) return Response.json({ error: 'Account not found' }, { status: 404 });\n await sw.db.server.insert('team_members', {\n id: crypto.randomUUID(), team_id: params.id, user_id: target.id, role: 'member',\n }, { onConflict: 'ignore' });\n return { ok: true };\n },\n});\n```\n\n```ts\n// api/complete-profile.ts \u2014 POST once when an admin assigns staff after sign-up\nexport default sw.endpoint({\n auth: 'required', body: { userId: 'string' },\n handler: async ({ request, body }, sw) => {\n await sw.auth.requireUser(request, { role: 'admin' });\n await sw.auth.server.setRoles(body.userId, { add: ['staff'] });\n return { ok: true };\n },\n});\n```\n\nDo not hand-write access to app-read/write data: declare who may read/write it.\nserverOnly() fits job/import/audit/counter state and protected membership ledgers.\nGrant ledgers use owner() without browser writes. Undeclarable: arbitrary predicates\n(e.g. expiry) or per-role writable fields (split tables or check that write).\n\nBuild src/pages/HomePage.tsx; routes src/App.tsx + src/routes.ts; auth src/auth/hooks.ts.\nAuth is wired: keep api/auth/[...path].ts; src/config.ts controls providers.\napi/notes/[id]/sub.ts \u2192 params.id; underscore files are helpers. POST: default export;\nGET/DELETE: named exports.\n\n```ts\nexport const GET = sw.endpoint({ auth: 'required', handler: async (_, sw) => sw.db.from('notes', { limit: 100 }) });\n```\n\nsw.db applies caller scopes; sw.db.server bypasses them: authorize first.\nReads: from(table, { where, columns, order: [['id', 'asc']], limit, offset }).\nFilter: { id: { in: ids } }; unique: [['a', 'b']] in schema.\nWrites: insert(table, values), update(table, { where, set }), remove(table, { where }).\ntx takes an ARRAY of write intents, never a callback; pre-generate related IDs.\n\nBrowser: fetch(path, { method: 'POST', credentials: 'same-origin',\nheaders: { 'content-type': 'application/json' }, body: JSON.stringify(values) }).\nAccess cookies refresh automatically. Cookie-auth POST/PATCH/DELETE from scripts\nneed Origin equal to the app URL.\n\nPublish: npx @somewhere-cloud/cli deploy, then somewhere test for the rules you changed.\nOne somewhere test run drives the UI and calls the API: signUp(page) uses your sign-up form\n(then signOut, signIn with its password, verify with the emailed code), newUser() acts as\nseveral people, and ready(page, 'signed-in' | 'signed-out') waits for the session check.\nYou do not need a separate browser script.\nDeploy raw source, no frontend build; type errors stop upload.\nnewUser() gives a signed-in page/API client; call N times (owner, member, outsider).\nNo chosen email argument: assign roles/memberships through your app's authorized POST setup.\nTest users are verified and visible to this project's server user lookup.\nEmail-domain role: signUp(page, { domain: 'staff.example' }), then verify(page, person).\nFor the complete owner-adds-member-by-email test and its endpoints, run\nsomewhere docs test and follow Two users sharing through the app.\nDiagnose with somewhere errors and somewhere logs.\n\nOn demand:\n- Server paging: `somewhere docs sw.db --section server-read-paging`\n\n## Testing shared access\n\nWith the teams and membership endpoints above, the owner adds a fixture by email\nand that fixture reads the shared team row:\n\n```ts\n// tests/team.spec.ts\nimport { test, expect, data } from '@somewhere-cloud/cli/testing';\ntest('owner adds a second user by email', async ({ newUser }) => {\n const owner = await newUser();\n const bob = await newUser();\n const name = `Shared team ${crypto.randomUUID()}`;\n const created = await owner.request.post('/api/teams', { data: { name } });\n expect(created.ok()).toBeTruthy();\n const { id } = await created.json();\n const added = await owner.request.post(`/api/teams/${id}/members`, { data: { email: bob.email } });\n expect(added.ok()).toBeTruthy();\n const response = await data(bob.request, 'teams', { operation: 'get', id });\n expect(response.ok()).toBeTruthy();\n expect((await response.json()).data).toMatchObject({ id, name });\n});\n```\n\nTask-specific skills: `.agents/skills/`. Inspect/update with somewhere skills status/update.\nData/code export limits: `somewhere docs portability`.\nUse this app from Claude as its signed-in user (MCP tools): `somewhere docs sw.endpoint --section mcp-tools-for-claude`.\n";
|
|
11
11
|
export declare const INIT_CLAUDE_MD = "Read AGENTS.md for project instructions.\n";
|
|
@@ -162,10 +162,15 @@ Access cookies refresh automatically. Cookie-auth POST/PATCH/DELETE from scripts
|
|
|
162
162
|
need Origin equal to the app URL.
|
|
163
163
|
|
|
164
164
|
Publish: npx @somewhere-cloud/cli deploy, then somewhere test for the rules you changed.
|
|
165
|
+
One somewhere test run drives the UI and calls the API: signUp(page) uses your sign-up form
|
|
166
|
+
(then signOut, signIn with its password, verify with the emailed code), newUser() acts as
|
|
167
|
+
several people, and ready(page, 'signed-in' | 'signed-out') waits for the session check.
|
|
168
|
+
You do not need a separate browser script.
|
|
165
169
|
Deploy raw source, no frontend build; type errors stop upload.
|
|
166
170
|
newUser() gives a signed-in page/API client; call N times (owner, member, outsider).
|
|
167
171
|
No chosen email argument: assign roles/memberships through your app's authorized POST setup.
|
|
168
172
|
Test users are verified and visible to this project's server user lookup.
|
|
173
|
+
Email-domain role: signUp(page, { domain: 'staff.example' }), then verify(page, person).
|
|
169
174
|
For the complete owner-adds-member-by-email test and its endpoints, run
|
|
170
175
|
somewhere docs test and follow Two users sharing through the app.
|
|
171
176
|
Diagnose with somewhere errors and somewhere logs.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-agent-guide.js","sourceRoot":"","sources":["../../src/lib/init-agent-guide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,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,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,2EAA2E;AAC3E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuM7B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,2BAA2B,UAAU,0DAA0D,CAAC;AAE9H,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;+EAE+E;AAC/E,MAAM,CAAC,MAAM,mBAAmB,GAAG,wDAAwD,CAAC;AAE5F,6EAA6E;AAC7E,MAAM,CAAC,MAAM,WAAW,GAAG,0HAA0H,CAAC;AAEtJ,MAAM,CAAC,MAAM,cAAc,GAAG,uCAAuC,cAAc,KAAK,cAAc,KAAK,mBAAmB,KAAK,WAAW,IAAI,CAAC;AACnJ,MAAM,CAAC,MAAM,cAAc,GAAG,4CAA4C,CAAC"}
|
|
@@ -1826,12 +1826,12 @@ export function MfaStep({ continuation }: { continuation: MfaContinuation }) {
|
|
|
1826
1826
|
<p>We emailed you a 6-digit sign-in code. It expires 5 minutes after you signed in.</p>
|
|
1827
1827
|
<div className="field">
|
|
1828
1828
|
<label className="field__label" htmlFor="mfa-code"><span>6-digit code from the email</span></label>
|
|
1829
|
-
<input id="mfa-code" className="control" autoComplete="one-time-code" inputMode="numeric" maxLength={8} autoFocus value={continuation.code}
|
|
1829
|
+
<input id="mfa-code" className="control" autoComplete="one-time-code" inputMode="numeric" maxLength={8} autoFocus value={continuation.code} data-sw-auth="mfa-code"
|
|
1830
1830
|
disabled={busy} onChange={(event) => continuation.setCode(event.target.value)} />
|
|
1831
1831
|
</div>
|
|
1832
|
-
{continuation.error ? <p className="error" role="alert">{continuation.error}</p> : null}
|
|
1832
|
+
{continuation.error ? <p className="error" role="alert" data-sw-auth="error">{continuation.error}</p> : null}
|
|
1833
1833
|
{continuation.notice ? <p role="status">{continuation.notice}</p> : null}
|
|
1834
|
-
<button type="submit" className="button" disabled={busy || !continuation.code.trim()} aria-busy={continuation.pending}>
|
|
1834
|
+
<button type="submit" className="button" disabled={busy || !continuation.code.trim()} aria-busy={continuation.pending} data-sw-auth="mfa-submit">
|
|
1835
1835
|
{continuation.pending ? 'Signing in…' : 'Finish signing in'}
|
|
1836
1836
|
</button>
|
|
1837
1837
|
<button type="button" className="button button--secondary" disabled={busy || !continuation.resendReady} aria-busy={continuation.resending}
|
|
@@ -2079,7 +2079,7 @@ export function AppShell({ appName, homeLink, account, busy, children }: AppShel
|
|
|
2079
2079
|
{account ? (
|
|
2080
2080
|
<div className="account">
|
|
2081
2081
|
<span className="account__label" title={account.label}>{account.label}</span>
|
|
2082
|
-
<button type="button" className="button button--quiet" onClick={account.onSignOut} disabled={account.signingOut}>
|
|
2082
|
+
<button type="button" className="button button--quiet" onClick={account.onSignOut} disabled={account.signingOut} data-sw-auth="sign-out">
|
|
2083
2083
|
{account.signingOut ? 'Signing out…' : 'Sign out'}
|
|
2084
2084
|
</button>
|
|
2085
2085
|
</div>
|
|
@@ -2251,7 +2251,7 @@ export function AppShell({ appName, homeLink, account, busy, children }: AppShel
|
|
|
2251
2251
|
{account ? (
|
|
2252
2252
|
<>
|
|
2253
2253
|
{' '}<span>{account.label}</span>{' '}
|
|
2254
|
-
<button type="button" onClick={account.onSignOut} disabled={account.signingOut}>
|
|
2254
|
+
<button type="button" onClick={account.onSignOut} disabled={account.signingOut} data-sw-auth="sign-out">
|
|
2255
2255
|
{account.signingOut ? 'Signing out…' : 'Sign out'}
|
|
2256
2256
|
</button>
|
|
2257
2257
|
{account.error ? <p role="alert">{account.error}</p> : null}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
const session = `import { test, expect, ready } from '@somewhere-cloud/cli/testing';
|
|
2
2
|
|
|
3
|
+
test('a new person signs up through the form, signs out and signs back in', async ({ page, signUp, signOut, signIn }) => {
|
|
4
|
+
const person = await signUp(page);
|
|
5
|
+
await expect(page.getByText(person.email)).toBeVisible();
|
|
6
|
+
await signOut(page);
|
|
7
|
+
await signIn(page, person);
|
|
8
|
+
await expect(page.getByText(person.email)).toBeVisible();
|
|
9
|
+
});
|
|
10
|
+
|
|
3
11
|
test('session and sign-out', async ({ newUser }) => {
|
|
4
12
|
const user = await newUser();
|
|
5
13
|
const me = await user.request.get('/api/auth/me');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-test-template.js","sourceRoot":"","sources":["../../src/lib/init-test-template.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG
|
|
1
|
+
{"version":3,"file":"init-test-template.js","sourceRoot":"","sources":["../../src/lib/init-test-template.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;CAsBf,CAAC;AACF,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BjB,CAAC;AACF,MAAM,UAAU,YAAY,CAAC,WAAW,GAAG,KAAK;IAC9C,OAAO,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAC7M,CAAC"}
|