@somewhere-cloud/cli 0.38.72 → 0.38.74

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.
@@ -3,20 +3,21 @@ import { SKILLS_DIR } from './skills-pack.js';
3
3
  // docs lint byte-compares this value when SOMEWHERE_CLI_REPO points here.
4
4
  export const AGENT_WORKFLOW = `## Build, deploy, test
5
5
 
6
- Enough to start a typical app: declare access, use the generated browser client;
7
- docs are for exceptions. Complete schema and calls below.
6
+ Enough to start a typical app: declare access and use the browser client; docs are for exceptions.
8
7
 
9
8
  | Requirement | Declaration below |
10
9
  | --- | --- |
11
10
  | Each user sees only their own rows | notes: owner() |
12
11
  | Team: owner adds members; members read/write; creator rights | teams/team_members/tasks: owner() + member(); role-owner delete branch |
13
- | Owner/staff record with staff-only child notes | tickets: owner() or server-assigned appRole(); messages: parent(); staff_notes: appRole() |
12
+ | Owner/staff record with staff-only child notes | tickets: owner() or appRole(); parent() thread; staff-only notes; POST setup below |
14
13
  | Public pages from private drafts | pages: conditional publicRead |
15
- | Share one record read-only with another account | shared_notes/note_shares: read-only grant() |
14
+ | Share one record read-only | shared_notes/note_shares: read-only grant() |
16
15
 
17
16
  db/schema.ts is declaration only: imports, constants/spreads, default schema;
18
17
  no helpers/expressions. id() is random text; owner() stamps user_id. client.read
19
- includes the key. Other fields: timestamp({ default: 'now' }), text({ nullable: true });
18
+ includes the key. Inside anyOf(), owner() takes only column/read: it stamps the
19
+ creator, not create/delete options; member() gates placement (non-member create is
20
+ refused), while creators or the allowed branch can delete. Other fields: timestamp({ default: 'now' }), text({ nullable: true });
20
21
  indexes: [['team_id']].
21
22
 
22
23
  \`\`\`ts
@@ -40,15 +41,15 @@ export default schema({
40
41
  }),
41
42
  tickets: table({ id: id(), subject: text() }, {
42
43
  scope: anyOf(owner(), appRole({ roles: { read: ['staff'], create: ['staff'], update: ['staff'] } })),
43
- client: { read: ['id', 'subject'], create: ['subject'], update: ['subject'] },
44
+ client: { read: true, create: ['subject'], update: ['subject'] },
44
45
  }),
45
46
  messages: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, {
46
47
  scope: parent({ via: 'ticket_id' }),
47
- client: { read: ['id', 'ticket_id', 'body'], create: ['ticket_id', 'body'] },
48
+ client: { read: true, create: ['ticket_id', 'body'] },
48
49
  }),
49
50
  staff_notes: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, {
50
51
  scope: appRole({ roles: { read: ['staff'], create: ['staff'] } }),
51
- client: { read: ['id', 'ticket_id', 'body'], create: ['ticket_id', 'body'] },
52
+ client: { read: true, create: ['ticket_id', 'body'] },
52
53
  }),
53
54
  pages: table({ id: id(), title: text(), published: boolean({ default: false }) }, {
54
55
  scope: owner(), client: { read: ['id', 'title'], create: ['title'], update: ['title'],
@@ -64,25 +65,30 @@ export default schema({
64
65
  }, { appRoles: { staff: { assignedBy: 'server' } } });
65
66
  \`\`\`
66
67
 
68
+ POST role setup once after sign-up/profile completion, not GET/every request:
69
+ cookie-authenticated GET cannot mutate roles.
70
+ Check admin here, or your own assignment rule.
67
71
  messages use parent(): owner() would hide staff replies from the customer.
68
72
  Use emailDomain for staff at your verified domain; assignedBy: 'server' when the
69
- app decides (admin promotion, payment, invitation); never use an unverified email ending.
73
+ app decides (promotion, payment, invitation). An email ending proves identity only
74
+ when verified; assigning a role anyway is your app's decision, whose permissions the platform enforces.
70
75
  Publish pages in an owner-checked endpoint. Share with caller-scoped
71
76
  sw.db.insert('note_shares', { grantee_id, note_id }); it checks row ownership.
77
+ Browser calls THROW, not { error }; catch below.
72
78
  Browser list: max 100, paginate after; no order (sort locally or in an endpoint).
73
79
 
74
80
  \`\`\`ts
75
81
  import { data } from 'somewhere:data';
76
- async function notes(after?: string) {
77
- const { data: note } = await data.notes.create({ title: 'Hello' });
78
- if (note) await data.notes.update(note.id, { title: 'Updated' });
79
- return data.notes.list({ limit: 100, after }); // next page: after = previous.next
82
+ export async function save(title: string) {
83
+ try { await data.notes.create({ title }); return null; }
84
+ catch (e) { return e instanceof Error ? e.message : 'Save failed'; }
80
85
  }
86
+ export const list = (after?: string) => data.notes.list({ limit: 100, after });
81
87
  \`\`\`
82
88
 
83
89
  Teams without verification: own membership table + member(); sw.groups and domain
84
90
  roles need VERIFIED emails. Members read/create/update tasks; creators or team owners delete while members.
85
- A restriction only narrows who may do its operations; it never grants read.
91
+ Restrictions narrow operations, not grant read.
86
92
  Comment-author-or-team-owner deletion stays a small endpoint.
87
93
  Create the team and its owner membership atomically:
88
94
 
@@ -91,13 +97,12 @@ Create the team and its owner membership atomically:
91
97
  export default sw.endpoint({
92
98
  auth: 'required', body: { name: 'string' },
93
99
  handler: async ({ user, params, body }, sw) => {
94
- const creatorEmail = user.email; // required auth supplies id and email
95
100
  const id = crypto.randomUUID();
96
101
  await sw.db.server.tx([
97
102
  { op: 'insert', table: 'teams', values: { id, name: body.name, owner_id: user.id } },
98
103
  { op: 'insert', table: 'team_members', values: { id: crypto.randomUUID(), team_id: id, user_id: user.id, role: 'owner' } },
99
104
  ]);
100
- return { id, creatorEmail };
105
+ return { id, email: user.email };
101
106
  },
102
107
  });
103
108
  \`\`\`
@@ -120,34 +125,29 @@ export default sw.endpoint({
120
125
  \`\`\`
121
126
 
122
127
  \`\`\`ts
123
- // api/_roles.ts — called by a server endpoint AFTER it authorizes the promotion
124
- export async function assignStaff(userId: string, sw: SomewhereRuntimeContext) {
125
- await sw.auth.server.setRoles(userId, { add: ['staff'] });
126
- }
128
+ // api/complete-profile.ts — POST once when an admin assigns staff after sign-up
129
+ export default sw.endpoint({
130
+ auth: 'required', body: { userId: 'string' },
131
+ handler: async ({ request, body }, sw) => {
132
+ await sw.auth.requireUser(request, { role: 'admin' });
133
+ await sw.auth.server.setRoles(body.userId, { add: ['staff'] });
134
+ return { ok: true };
135
+ },
136
+ });
127
137
  \`\`\`
128
138
 
129
- Do not mark app-read/write data serverOnly() and hand-write access checks: declare
130
- who may read/write it; the platform enforces it. Server-only fits job/import/audit/
131
- counter state, membership ledgers, and undeclarable rules: arbitrary predicates
132
- (e.g. expiry), or different writable fields per role (split tables or check that write).
133
- Grant ledgers need owner() scope and no browser writes. Keep other access declared.
139
+ Do not hand-write access to app-read/write data: declare who may read/write it.
140
+ serverOnly() fits job/import/audit/counter state and protected membership ledgers.
141
+ Grant ledgers use owner() without browser writes. Undeclarable: arbitrary predicates
142
+ (e.g. expiry) or per-role writable fields (split tables or check that write).
134
143
 
135
- Starter: src/pages/HomePage.tsx; routes src/App.tsx + src/routes.ts; auth hooks
136
- src/auth/hooks.ts. useAuth from @somewhere-cloud/sdk/react: signIn/signUp({ email,
137
- password }); sign-up signs in. Keep api/auth/[...path].ts; src/config.ts controls providers.
138
- api/notes/[id]/sub.ts → /api/notes/:id/sub (params.id); underscore files are helpers.
139
- POST: default export; GET/DELETE: named exports. Objects return JSON 200;
140
- Response.json sets status.
144
+ Build src/pages/HomePage.tsx; routes src/App.tsx + src/routes.ts; auth src/auth/hooks.ts.
145
+ Auth is wired: keep api/auth/[...path].ts; src/config.ts controls providers.
146
+ api/notes/[id]/sub.ts → params.id; underscore files are helpers. POST: default export;
147
+ GET/DELETE: named exports.
141
148
 
142
149
  \`\`\`ts
143
- export const GET = sw.endpoint({
144
- auth: 'required',
145
- handler: async (_, sw) => sw.db.from('notes', { limit: 100 }),
146
- });
147
- export const DELETE = sw.endpoint({
148
- auth: 'required',
149
- handler: async ({ params }, sw) => sw.db.remove('notes', { where: { id: params.id } }),
150
- });
150
+ export const GET = sw.endpoint({ auth: 'required', handler: async (_, sw) => sw.db.from('notes', { limit: 100 }) });
151
151
  \`\`\`
152
152
 
153
153
  sw.db applies caller scopes; sw.db.server bypasses them: authorize first.
@@ -163,13 +163,12 @@ need Origin equal to the app URL.
163
163
 
164
164
  Publish: somewhere typecheck → npx @somewhere-cloud/cli deploy → somewhere verify → somewhere test.
165
165
  Deploy raw source, no frontend build. Type errors stop upload; override: somewhere deploy --allow-type-errors.
166
- Tests: newUser() gives its own signed-in browser page and API request client; call N times (owner, member, outsider).
167
- No chosen email argument: grant roles or insert memberships in setup through your app's authorized server endpoint.
166
+ newUser() gives a signed-in page/API client; call N times (owner, member, outsider).
167
+ No chosen email argument: assign roles/memberships through your app's authorized POST setup.
168
168
  Diagnose with somewhere errors and somewhere logs.
169
169
 
170
170
  On demand:
171
171
  - Server paging: \`somewhere docs sw.db --section server-read-paging\`
172
- - Direct HTTP data tests: \`somewhere docs declared-data --section calling-the-data-endpoint-directly\`
173
172
  `;
174
173
  export const SKILLS_POINTER = `Task-specific skills: \`${SKILLS_DIR}/\`. Inspect/update with somewhere skills status/update.`;
175
174
  export const DECLARED_ACCESS_POINTER = '';
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyK7B,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,MAAM,CAAC,MAAM,cAAc,GAAG,uCAAuC,cAAc,KAAK,cAAc,KAAK,mBAAmB,IAAI,CAAC;AACnI,MAAM,CAAC,MAAM,cAAc,GAAG,4CAA4C,CAAC"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwK7B,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,MAAM,CAAC,MAAM,cAAc,GAAG,uCAAuC,cAAc,KAAK,cAAc,KAAK,mBAAmB,IAAI,CAAC;AACnI,MAAM,CAAC,MAAM,cAAc,GAAG,4CAA4C,CAAC"}
@@ -15,7 +15,7 @@
15
15
  import { type ApiClient } from './client.js';
16
16
  export declare const POST_LIVE_RENDER_WAIT_MS = 5000;
17
17
  export declare const POST_LIVE_RENDER_POLL_MS = 400;
18
- export declare const POST_LIVE_RENDER_STILL_RUNNING = "live; blank-page check still running, see the deploy log";
18
+ export declare const POST_LIVE_RENDER_STILL_RUNNING = "Render check still running; see its result with: somewhere call project_deploy_log '{}'";
19
19
  export interface PostLiveRenderRecord {
20
20
  status: string;
21
21
  blank_page_check?: unknown;
@@ -15,7 +15,7 @@
15
15
  import { CliApiError } from './client.js';
16
16
  export const POST_LIVE_RENDER_WAIT_MS = 5000;
17
17
  export const POST_LIVE_RENDER_POLL_MS = 400;
18
- export const POST_LIVE_RENDER_STILL_RUNNING = 'live; blank-page check still running, see the deploy log';
18
+ export const POST_LIVE_RENDER_STILL_RUNNING = "Render check still running; see its result with: somewhere call project_deploy_log '{}'";
19
19
  /** Wait for a pending render check. Throws the DEPLOY_BLANK_PAGE CliApiError
20
20
  * when the release rendered blank. A read that fails is retried until the
21
21
  * deadline; never success by default. */
@@ -1 +1 @@
1
- {"version":3,"file":"post-live-render.js","sourceRoot":"","sources":["../../src/lib/post-live-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAE1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAC7C,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,MAAM,CAAC,MAAM,8BAA8B,GAAG,0DAA0D,CAAC;AAqBzG;;0CAE0C;AAC1C,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAA+B,EAC/B,SAA6B,EAC7B,MAA8E,EAC9E,OAAwG,EAAE;IAE1G,IAAI,MAAM,CAAC,gBAAgB,EAAE,MAAM,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;IACtH,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1F,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,wBAAwB,CAAC;IACvD,MAAM,QAAQ,GAAG,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,wBAAwB,CAAC,CAAC;IACnE,OAAO,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;QACxB,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,C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AC,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/G,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,IAAI,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;YAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;YACzB,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,KAAM,EAAE,CAAC,CAAC,OAAO,IAAI,0BAA0B,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAChG,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,EAAE,gBAAgB,CAAC;QACtC,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,gBAAgB,IAAI,IAAI,EAAE,CAAC;QACnI,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** A warning for explicit GET-only route exports, not an authorization analysis. */
2
+ export declare function roleMethodHints(projectDir: string): string[];
@@ -0,0 +1,68 @@
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { join, relative } from 'node:path';
3
+ import ts from 'typescript';
4
+ const METHODS = new Set(['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']);
5
+ const ROLE_WRITES = new Set(['setRoles', 'grantRole', 'revokeRole']);
6
+ /** A warning for explicit GET-only route exports, not an authorization analysis. */
7
+ export function roleMethodHints(projectDir) {
8
+ const api = join(projectDir, 'api');
9
+ if (!existsSync(api))
10
+ return [];
11
+ const hints = [];
12
+ function visitDir(dir) {
13
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
14
+ const path = join(dir, entry.name);
15
+ if (entry.isDirectory()) {
16
+ visitDir(path);
17
+ continue;
18
+ }
19
+ if (!entry.isFile() || !/\.[cm]?[jt]sx?$/.test(entry.name) || /\.d\.ts$/.test(entry.name))
20
+ continue;
21
+ const file = ts.createSourceFile(path, readFileSync(path, 'utf8'), ts.ScriptTarget.Latest, true);
22
+ const exports = new Set();
23
+ let unknown = false;
24
+ for (const statement of file.statements) {
25
+ if (ts.isExportAssignment(statement))
26
+ unknown = true;
27
+ if (ts.isExportDeclaration(statement)) {
28
+ if (!statement.exportClause || !ts.isNamedExports(statement.exportClause))
29
+ unknown = true;
30
+ else
31
+ for (const spec of statement.exportClause.elements)
32
+ exports.add(spec.name.text);
33
+ }
34
+ if (ts.canHaveModifiers(statement)) {
35
+ const modifiers = ts.getModifiers(statement);
36
+ if (modifiers?.some(m => m.kind === ts.SyntaxKind.DefaultKeyword))
37
+ unknown = true;
38
+ if (!modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword))
39
+ continue;
40
+ if (ts.isVariableStatement(statement))
41
+ for (const decl of statement.declarationList.declarations) {
42
+ if (ts.isIdentifier(decl.name))
43
+ exports.add(decl.name.text);
44
+ }
45
+ if (ts.isFunctionDeclaration(statement) && statement.name)
46
+ exports.add(statement.name.text);
47
+ }
48
+ }
49
+ const methods = [...exports].filter(name => METHODS.has(name));
50
+ if (unknown || methods.length !== 1 || methods[0] !== 'GET')
51
+ continue;
52
+ let write;
53
+ function walk(node) {
54
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)
55
+ && ROLE_WRITES.has(node.expression.name.text)
56
+ && node.expression.expression.getText(file) === 'sw.auth.server')
57
+ write ??= node.expression.name.text;
58
+ ts.forEachChild(node, walk);
59
+ }
60
+ walk(file);
61
+ if (write)
62
+ hints.push(`hint: ${relative(projectDir, path).replaceAll('\\', '/')}: ${write} is called in a GET-only route; use a POST setup handler once after sign-up/profile completion (cookie GET cannot change roles).`);
63
+ }
64
+ }
65
+ visitDir(api);
66
+ return hints;
67
+ }
68
+ //# sourceMappingURL=role-method-hints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role-method-hints.js","sourceRoot":"","sources":["../../src/lib/role-method-hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AACtF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;AAErE,oFAAoF;AACpF,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACpC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAChC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,SAAS,QAAQ,CAAC,GAAW;QAC3B,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAAC,SAAS;YAAC,CAAC;YACtD,IAAI,CAAC,KAAK,CAAC,MAAM,EA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,CAAC,IAAI,CAAC,CAAC;YACX,IAAI,KAAK;gBAAE,KAAK,CAAC,IAAI,CAAC,SAAS,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,KAAK,kIAAkI,CAAC,CAAC;QAC/N,CAAC;IACH,CAAC;IACD,QAAQ,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Fixed platform text for completion telemetry that deliberately stores codes only. */
2
+ export declare const ROLE_CHANGE_METHOD_MESSAGE = "Role changes require POST, PUT, PATCH or DELETE when signed in by cookie; move setRoles/grantRole/revokeRole to a POST setup handler.";
3
+ export declare function runtimeRefusalMessage(code: string | null | undefined): string | undefined;
@@ -0,0 +1,6 @@
1
+ /** Fixed platform text for completion telemetry that deliberately stores codes only. */
2
+ export const ROLE_CHANGE_METHOD_MESSAGE = 'Role changes require POST, PUT, PATCH or DELETE when signed in by cookie; move setRoles/grantRole/revokeRole to a POST setup handler.';
3
+ export function runtimeRefusalMessage(code) {
4
+ return code === 'ROLE_CHANGE_METHOD_NOT_ALLOWED' ? ROLE_CHANGE_METHOD_MESSAGE : undefined;
5
+ }
6
+ //# sourceMappingURL=runtime-refusals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-refusals.js","sourceRoot":"","sources":["../../src/lib/runtime-refusals.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,MAAM,CAAC,MAAM,0BAA0B,GAAG,uIAAuI,CAAC;AAClL,MAAM,UAAU,qBAAqB,CAAC,IAA+B;IACnE,OAAO,IAAI,KAAK,gCAAgC,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5F,CAAC"}
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.72",
3
+ "version": "0.38.74",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@somewhere-cloud/cli",
9
- "version": "0.38.72",
9
+ "version": "0.38.74",
10
10
  "bundleDependencies": [
11
11
  "@modelcontextprotocol/sdk",
12
12
  "chokidar",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.72",
3
+ "version": "0.38.74",
4
4
  "description": "CLI for somewhere.cloud — auth, projects, deploy, pull, promote, db, logs, env, MCP bridge.",
5
5
  "keywords": [
6
6
  "somewhere",