@softr/sdk 0.0.90-alpha.6 → 0.0.90-alpha.7

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.
@@ -2,7 +2,7 @@ import { User } from "./user.js";
2
2
  import { Formatting } from "../formatting.js";
3
3
  import { Permissions } from "./permissions.js";
4
4
  import { SoftrContext } from "./context.js";
5
- import * as react0 from "react";
5
+ import * as react3 from "react";
6
6
  import { ReactNode } from "react";
7
7
  import * as _tanstack_react_start0 from "@tanstack/react-start";
8
8
 
@@ -104,7 +104,7 @@ declare function AuthSettingsProvider({
104
104
  }: {
105
105
  value: AuthOptions;
106
106
  children?: ReactNode;
107
- }): react0.JSX.Element;
107
+ }): react3.JSX.Element;
108
108
  /**
109
109
  * Which ways in this app offers. Requires an {@link AuthSettingsProvider}
110
110
  * above it.
@@ -1,4 +1,5 @@
1
1
  import { settings } from "./methods/settings.js";
2
+ import { currentUserRow } from "./current-user-row.js";
2
3
  import { confirmAuthenticatorSetup, removeAuthenticator, resetAuthenticator, sendAuthenticatorResetCode, skipAuthenticatorSetup, startAuthenticatorSetup, verifyAuthenticator } from "./methods/authenticator.js";
3
4
  import { sendSignInCode, signInWithCode } from "./methods/code.js";
4
5
  import { signInWithMagicLink } from "./methods/magicLink.js";
@@ -7,7 +8,6 @@ import { checkPasswordLink, requestPasswordReset, setPasswordWithLink } from "./
7
8
  import { confirmSignUp, signUp } from "./methods/signup.js";
8
9
  import { signInWithGoogle } from "./methods/social.js";
9
10
  import { removeAvatar, updateProfile } from "./methods/profile.js";
10
- import { currentUserRow } from "./current-user-row.js";
11
11
  import "@tanstack/react-start/server-only";
12
12
 
13
13
  //#region src/auth/server.ts
@@ -30,6 +30,15 @@ function refererHeader() {
30
30
  const referer = getRequestHeader("referer");
31
31
  return { Referer: referer !== void 0 && URL.parse(referer)?.origin === page.origin ? referer : page.href };
32
32
  }
33
+ /** A datasource call the service refused. `status` is its HTTP status. */
34
+ var DatasourceError = class extends Error {
35
+ status;
36
+ constructor(message, status) {
37
+ super(message);
38
+ this.name = "DatasourceError";
39
+ this.status = status;
40
+ }
41
+ };
33
42
  async function describeFailure(res) {
34
43
  const body = await res.json().catch(() => null);
35
44
  const message = typeof body === "object" && body !== null && "message" in body ? body.message : null;
@@ -235,7 +244,7 @@ async function updateRecord(action, options) {
235
244
  },
236
245
  body: JSON.stringify({ fields: rawFields })
237
246
  });
238
- if (!res.ok) throw new Error(`datasource update failed for action "${actionId}": ${await describeFailure(res)}`);
247
+ if (!res.ok) throw new DatasourceError(`datasource update failed for action "${actionId}": ${await describeFailure(res)}`, res.status);
239
248
  const record = await res.json();
240
249
  return {
241
250
  id: record.id,
@@ -257,7 +266,7 @@ async function deleteRecord(action, options) {
257
266
  ...refererHeader()
258
267
  }
259
268
  });
260
- if (!res.ok) throw new Error(`datasource delete failed for action "${actionId}": ${await describeFailure(res)}`);
269
+ if (!res.ok) throw new DatasourceError(`datasource delete failed for action "${actionId}": ${await describeFailure(res)}`, res.status);
261
270
  }
262
271
  function resolveTarget(subject, operation) {
263
272
  const declaredBy = operation === "read" ? "defineQuery" : "defineMutation";
@@ -281,4 +290,4 @@ function dealiasData(data, select) {
281
290
  }
282
291
 
283
292
  //#endregion
284
- export { createRecord, deleteRecord, describeFailure, dsUrl, getRecord, listRecords, refererHeader, resolveTarget, updateRecord };
293
+ export { DatasourceError, createRecord, deleteRecord, describeFailure, dsUrl, getRecord, listRecords, refererHeader, resolveTarget, updateRecord };
package/dist/mcp.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { DatasourceAction } from "./action.js";
1
+ import { DatasourceAction, ReadShape } from "./action.js";
2
2
  import * as _tanstack_react_start6 from "@tanstack/react-start";
3
3
 
4
4
  //#region src/mcp.d.ts
5
5
 
6
- type SoftrMcpOptions = {
6
+ type SoftrMcpOptions<TUsers extends ReadShape = ReadShape> = {
7
7
  /**
8
8
  * The actions to expose as tools, from `defineQuery` and `defineMutation`.
9
9
  *
@@ -12,6 +12,19 @@ type SoftrMcpOptions = {
12
12
  * decide who may run the ones that are listed.
13
13
  */
14
14
  actions?: Array<DatasourceAction>;
15
+ /**
16
+ * Fills the owner of a person's record from who is calling, the way the app's
17
+ * pages do with `auth.currentUserRow`. The field is left out of the tool, so
18
+ * the assistant can't leave it wrong or name someone else.
19
+ */
20
+ owner?: SoftrMcpOwner<TUsers>;
21
+ };
22
+ type SoftrMcpOwner<TUsers extends ReadShape = ReadShape> = {
23
+ /** The people table, and its email field, to find the caller's row in. */
24
+ users: DatasourceAction<TUsers>;
25
+ email: keyof TUsers["fields"] & string;
26
+ /** Listed create or update action id to the field that links to the caller's row. */
27
+ fields: Record<string, string>;
15
28
  };
16
29
  /**
17
30
  * Serves the MCP endpoint and its OAuth flow from the app's own origin.
@@ -31,6 +44,6 @@ type SoftrMcpOptions = {
31
44
  * ],
32
45
  * }))
33
46
  */
34
- declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start6.RequestMiddlewareAfterServer<{}, undefined, undefined>;
47
+ declare function softrMcpMiddleware<TUsers extends ReadShape>(options?: SoftrMcpOptions<TUsers>): _tanstack_react_start6.RequestMiddlewareAfterServer<{}, undefined, undefined>;
35
48
  //#endregion
36
49
  export { softrMcpMiddleware };
package/dist/mcp.js CHANGED
@@ -5,8 +5,10 @@ import { softrConfig } from "./softr-config.js";
5
5
  import { sessionConfig } from "./auth/config.js";
6
6
  import { readSessionToken, withSessionToken } from "./auth/session.js";
7
7
  import { isDatasourceAction } from "./action.js";
8
+ import { DatasourceError } from "./datasource/record.js";
8
9
  import { makePlatform } from "./auth/platform.js";
9
10
  import { ds } from "./datasource/datasource.js";
11
+ import { currentUserRow } from "./auth/current-user-row.js";
10
12
  import { z } from "zod";
11
13
  import { createMiddleware } from "@tanstack/react-start";
12
14
 
@@ -48,6 +50,14 @@ function softrMcpMiddleware(options = {}) {
48
50
  assert(!actions.has(value.id), `two actions share the id "${value.id}"`);
49
51
  actions.set(value.id, value);
50
52
  }
53
+ const owner = options.owner;
54
+ for (const [actionId, field] of Object.entries(owner?.fields ?? {})) {
55
+ const action = actions.get(actionId);
56
+ assert(action, `owner names "${actionId}", which is not a listed action`);
57
+ const { operation, fields } = action.resource;
58
+ assert(operation === "create" || operation === "update", `owner fills "${actionId}", which is a ${operation}`);
59
+ assert(field in (fields ?? {}), `"${actionId}" has no field "${field}" for the owner`);
60
+ }
51
61
  return createMiddleware({ type: "request" }).server(async ({ next, request }) => {
52
62
  const url = new URL(request.url);
53
63
  const origin = url.origin;
@@ -71,7 +81,7 @@ function softrMcpMiddleware(options = {}) {
71
81
  });
72
82
  case AUTHORIZE_PATH: return await authorize(request, login);
73
83
  case TOKEN_PATH: return await issueToken(request);
74
- case MCP_PATH: return await rpc(request, origin, actions);
84
+ case MCP_PATH: return await rpc(request, origin, actions, owner);
75
85
  default: return await next();
76
86
  }
77
87
  });
@@ -258,10 +268,11 @@ const MAX_LIMIT = 100;
258
268
  * that only ever reads one datasource exposes one read, even though its
259
269
  * credentials would allow more.
260
270
  */
261
- function describeTool(action) {
271
+ function describeTool(action, ownerField) {
262
272
  const { operation, fields } = action.resource;
263
273
  const names = Object.keys(fields ?? {});
264
- const fieldProps = Object.fromEntries(names.map((name) => [name, { description: `The "${name}" field.` }]));
274
+ const writable = names.filter((name) => name !== ownerField);
275
+ const fieldProps = Object.fromEntries(writable.map((name) => [name, { description: `The "${name}" field.` }]));
265
276
  switch (operation) {
266
277
  case "read": return {
267
278
  name: action.id,
@@ -287,7 +298,7 @@ function describeTool(action) {
287
298
  };
288
299
  case "create": return {
289
300
  name: action.id,
290
- description: `Create a record with "${action.id}". Writable fields: ${names.join(", ")}.`,
301
+ description: `Create a record with "${action.id}". Writable fields: ${writable.join(", ")}.`,
291
302
  inputSchema: {
292
303
  type: "object",
293
304
  properties: fieldProps,
@@ -296,7 +307,7 @@ function describeTool(action) {
296
307
  };
297
308
  case "update": return {
298
309
  name: action.id,
299
- description: `Update a record with "${action.id}". Writable fields: ${names.join(", ")}.`,
310
+ description: `Update a record with "${action.id}". Writable fields: ${writable.join(", ")}.`,
300
311
  inputSchema: {
301
312
  type: "object",
302
313
  properties: {
@@ -332,7 +343,7 @@ function describeTool(action) {
332
343
  * visitor's user groups exactly as it would a click in the app. Nothing here
333
344
  * decides what is allowed.
334
345
  */
335
- async function runTool(action, args) {
346
+ async function runTool(action, args, owner) {
336
347
  const typed = action;
337
348
  switch (action.resource.operation) {
338
349
  case "read": {
@@ -344,13 +355,21 @@ async function runTool(action, args) {
344
355
  nextOffset: result$1.nextOffset
345
356
  };
346
357
  }
347
- case "create": return await ds.create(typed, { data: writableFields(action, args) });
358
+ case "create": {
359
+ const data = writableFields(action, args, owner?.field);
360
+ if (owner !== null) {
361
+ const row = await owner.row();
362
+ if (row === null) throw new Error("The visitor has no row in the people table, so this record can't be created for them.");
363
+ data[owner.field] = { id: row.id };
364
+ }
365
+ return await ds.create(typed, { data });
366
+ }
348
367
  case "update": {
349
368
  const { id,...data } = args;
350
369
  assert(typeof id === "string" && id !== "", "update needs a record id");
351
370
  return await ds.update(typed, {
352
371
  id,
353
- data: writableFields(action, data)
372
+ data: writableFields(action, data, owner?.field)
354
373
  });
355
374
  }
356
375
  case "delete": {
@@ -361,8 +380,19 @@ async function runTool(action, args) {
361
380
  }
362
381
  }
363
382
  }
383
+ function ownerFieldOf(owner, actionId) {
384
+ return owner !== void 0 && Object.hasOwn(owner.fields, actionId) ? owner.fields[actionId] : void 0;
385
+ }
386
+ function ownerFill(owner, actionId, sessionToken) {
387
+ const field = ownerFieldOf(owner, actionId);
388
+ if (owner === void 0 || field === void 0) return null;
389
+ return {
390
+ field,
391
+ row: async () => currentUserRow(await resolveUser(sessionToken), owner.users, owner.email)
392
+ };
393
+ }
364
394
  /**
365
- * Only the fields the action declared.
395
+ * Only the fields the action declared, less the owner it fills itself.
366
396
  *
367
397
  * `additionalProperties: false` in the tool schema is a hint to the model, not
368
398
  * a check — a client can send whatever it likes. An unlisted key reaches the
@@ -370,9 +400,18 @@ async function runTool(action, args) {
370
400
  * straight through. So the action's field list gets enforced here, or it isn't
371
401
  * a boundary at all.
372
402
  */
373
- function writableFields(action, args) {
403
+ function writableFields(action, args, ownerField) {
374
404
  const allowed = action.resource.fields ?? {};
375
- return Object.fromEntries(Object.entries(args).filter(([name]) => name in allowed));
405
+ return Object.fromEntries(Object.entries(args).filter(([name]) => name in allowed && name !== ownerField));
406
+ }
407
+ /**
408
+ * The error as the assistant should read it. A row rule that keeps the caller
409
+ * from changing a record answers 404, the same as a deleted record, so a bare
410
+ * "not found" would leave the assistant guessing.
411
+ */
412
+ function describeError(error) {
413
+ if (error instanceof DatasourceError && error.status === 404) return "Refused: this record doesn't exist, or the visitor's user group may not change it. If it still shows in a read, it is a permission. Tell the visitor they don't have access to this action, and that the app's builder can grant it.";
414
+ return error instanceof Error ? error.message : String(error);
376
415
  }
377
416
  function clampLimit(raw) {
378
417
  if (typeof raw !== "number" || !Number.isInteger(raw)) return DEFAULT_LIMIT;
@@ -382,7 +421,7 @@ function clampOffset(raw) {
382
421
  if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 0) return null;
383
422
  return raw;
384
423
  }
385
- async function rpc(request, origin, actions) {
424
+ async function rpc(request, origin, actions, owner) {
386
425
  if (request.method !== "POST") return methodNotAllowed("POST");
387
426
  const token = bearerToken(request);
388
427
  if (token === null) return unauthorized(origin);
@@ -419,7 +458,7 @@ async function rpc(request, origin, actions) {
419
458
  }
420
459
  });
421
460
  }
422
- case "tools/list": return result(id, { tools: [WHOAMI, ...[...actions.values()].map(describeTool)] });
461
+ case "tools/list": return result(id, { tools: [WHOAMI, ...[...actions.values()].map((action) => describeTool(action, ownerFieldOf(owner, action.id)))] });
423
462
  case "tools/call": {
424
463
  const name = params?.name;
425
464
  const args = typeof params?.arguments === "object" && params.arguments !== null ? params.arguments : {};
@@ -431,13 +470,13 @@ async function rpc(request, origin, actions) {
431
470
  const action = typeof name === "string" ? actions.get(name) : void 0;
432
471
  if (action === void 0) return failure(id, -32602, `Unknown tool: ${String(name)}`);
433
472
  try {
434
- return result(id, toolResult(await withSessionToken(sessionToken, () => runTool(action, args))));
473
+ return result(id, toolResult(await withSessionToken(sessionToken, () => runTool(action, args, ownerFill(owner, action.id, sessionToken)))));
435
474
  } catch (error) {
436
475
  return result(id, {
437
476
  isError: true,
438
477
  content: [{
439
478
  type: "text",
440
- text: error instanceof Error ? error.message : String(error)
479
+ text: describeError(error)
441
480
  }]
442
481
  });
443
482
  }
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.0.90-alpha.6";
2
+ var version = "0.0.90-alpha.7";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/package.json CHANGED
@@ -1,16 +1,37 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "0.0.90-alpha.6",
3
+ "version": "0.0.90-alpha.7",
4
4
  "type": "module",
5
5
  "exports": {
6
- ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
7
- "./client": { "types": "./dist/client.d.ts", "import": "./dist/client.js" },
8
- "./server": { "types": "./dist/server.d.ts", "import": "./dist/server.js" },
9
- "./vite": { "types": "./dist/vite.d.ts", "import": "./dist/vite.js" }
10
- },
11
- "bin": { "softr-sdk": "./dist/cli.js" },
12
- "files": ["dist", "schema", "skills", "!skills/_artifacts"],
13
- "publishConfig": { "access": "public" },
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js"
9
+ },
10
+ "./client": {
11
+ "types": "./dist/client.d.ts",
12
+ "import": "./dist/client.js"
13
+ },
14
+ "./server": {
15
+ "types": "./dist/server.d.ts",
16
+ "import": "./dist/server.js"
17
+ },
18
+ "./vite": {
19
+ "types": "./dist/vite.d.ts",
20
+ "import": "./dist/vite.js"
21
+ }
22
+ },
23
+ "bin": {
24
+ "softr-sdk": "./dist/cli.js"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "schema",
29
+ "skills",
30
+ "!skills/_artifacts"
31
+ ],
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
14
35
  "scripts": {
15
36
  "build": "tsdown",
16
37
  "test": "node --import ./src/test-utils/setup.ts --test",
@@ -42,7 +63,9 @@
42
63
  "optional": true
43
64
  }
44
65
  },
45
- "keywords": ["tanstack-intent"],
66
+ "keywords": [
67
+ "tanstack-intent"
68
+ ],
46
69
  "intent": {
47
70
  "version": 1,
48
71
  "repo": "@softr/sdk",
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: core
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  # Softr SDK core
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  name: agent-chat
3
3
  description: >-
4
- Chat with one of the app's Softr agents: listAgents() and useAgentChat(agentId,
5
- { record }) from @softr/sdk give the chat state with no UI — messages, the
6
- streaming reply, past chats, approve, reject, connect. Load it for an agent
7
- chat, approving its actions, which records the agent may change for each
8
- visitor, or connecting the visitor's account a tool needs.
4
+ Chat with one of the app's Softr agents: listAgents() and
5
+ useAgentChat(agentId, { record }) from @softr/sdk give the chat state with no
6
+ UI — messages, the streaming reply, past chats, approve, reject, connect. Load
7
+ it for an agent chat, approving its actions, which records the agent may
8
+ change for each visitor, or connecting the visitor's account a tool needs.
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  **Boundary.** `listAgents` and `useAgentChat` live on `@softr/sdk`. `listAgents` runs in a route loader, `useAgentChat` in a component. Neither needs a route, server function or registration of its own. It chats as the signed-in visitor, or anonymously when no one is signed in.
@@ -92,6 +92,7 @@ The agent reads and changes data through the app's own MCP, as the visitor who i
92
92
 
93
93
  **The agent calls a listed action directly, with any input.** It skips pages and server functions. Two things guard it: the action's `permissions` say who may run it, and the app's data restrictions say which rows each user group reaches. A read returns every row the visitor may see, and an update or delete takes any id that passes both.
94
94
 
95
+ - **The owner comes from the app, never from the agent.** Name each create's owner link in `owner` on `softrMcpMiddleware`, as [mcp/SKILL.md](../mcp/SKILL.md) shows. The agent knows the visitor's login, not their row, and could name anyone.
95
96
  - **By default, each visitor changes only their own records.** On a table whose rows belong to a person, such as requests or bookings, open its create, update and delete to every signed-in visitor, and let the table's data restriction narrow edit and delete to the visitor's own rows. The groups that manage everyone's records get no restriction.
96
97
  - Split an action by role only for fields one role sets. A request's status goes on its own update with `customGroups` for the managers, and the visitor's update doesn't list it. One update open to every signed-in visitor that writes the status lets an employee have the agent approve their own vacation request.
97
98
  - Don't list an update or delete on a table whose rows belong to people until its restriction is in place. Without it, the agent edits anyone's row.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  **Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  **Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  # The current user
@@ -7,7 +7,7 @@ description: >-
7
7
  metadata:
8
8
  type: sub-skill
9
9
  library: softr-sdk
10
- library_version: 0.0.90-alpha.6
10
+ library_version: 0.0.90-alpha.7
11
11
  ---
12
12
 
13
13
  **Boundary.** `upload` lives on `@softr/sdk/server` and runs inside server functions. `useFileUpload` and `FileItem` live on `@softr/sdk` and run in components. `FileAttachment` comes from `@softr/sdk` and can be imported anywhere.
@@ -8,7 +8,7 @@ description: >-
8
8
  metadata:
9
9
  type: sub-skill
10
10
  library: softr-sdk
11
- library_version: 0.0.90-alpha.6
11
+ library_version: 0.0.90-alpha.7
12
12
  ---
13
13
 
14
14
  # Dates, times and numbers
@@ -7,7 +7,7 @@ description: >-
7
7
  metadata:
8
8
  type: sub-skill
9
9
  library: softr-sdk
10
- library_version: 0.0.90-alpha.6
10
+ library_version: 0.0.90-alpha.7
11
11
  ---
12
12
 
13
13
  **Boundary.** `integration` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineIntegration` and every type come from `@softr/sdk` and can be imported anywhere.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  **Boundary.** `softrMcpMiddleware` lives on `@softr/sdk` and is registered once, in `src/start.ts`. The actions you hand it are the same `defineQuery` / `defineMutation` values the app's own pages use — declared wherever they already live, not duplicated for MCP.
@@ -54,10 +54,24 @@ The list is the whole tool surface. Write it out:
54
54
  - An action you leave out is invisible to the assistant, even where the app's pages use it freely.
55
55
  - An action you list still obeys its own `permissions`. Listing it does not widen who may run it — the assistant runs as whoever signed in, with that user's groups.
56
56
  - The assistant calls the action directly and skips server functions, so a row filter written in one does not apply. A listed read returns every row the user's data restrictions allow, and a listed update or delete takes any id that passes them. On a table whose rows belong to people, list an action only once a data restriction scopes the table to the user's own rows.
57
+ - A create on a table whose rows belong to a person gets its owner from `owner`, never from the assistant. See below.
57
58
  - Two actions with the same `id` throw at startup. So does anything that is not a `defineQuery` or `defineMutation` value.
58
59
 
59
60
  Reads first. Add a write only when the user asked for one, and name it back to them.
60
61
 
62
+ ## The owner of a person's record
63
+
64
+ The assistant knows the caller's login, not their row in the people table. Left to fill an owner link, it writes the login id, which shows as a stray name, or anyone's row it likes. `owner` takes the field out of the tool and fills it with the caller's own row, found the way `auth.currentUserRow` finds it:
65
+
66
+ ```ts
67
+ softrMcpMiddleware({
68
+ actions: [listRequests, requestTimeOff],
69
+ owner: { users: usersQuery, email: 'email', fields: { requestTimeOff: 'employee' } },
70
+ })
71
+ ```
72
+
73
+ `fields` maps each create or update action id to its owner link. A caller with no row in the people table is refused, and nothing is created. On an update the field is only taken out, so nobody moves a record to someone else.
74
+
61
75
  ## The login round trip
62
76
 
63
77
  Connecting starts with an approval page the app serves. Most people hit it signed out, and that page cannot sign anyone in. It sends them to the login page named in `softr.json` (`auth.routes.login.path`), with the approval page in the search param named there (`auth.routes.login.redirectParam`).
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  # Installing the app
@@ -8,7 +8,7 @@ description: >-
8
8
  metadata:
9
9
  type: sub-skill
10
10
  library: softr-sdk
11
- library_version: 0.0.90-alpha.6
11
+ library_version: 0.0.90-alpha.7
12
12
  ---
13
13
 
14
14
  **Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineMutation` and every type come from `@softr/sdk` and can be imported anywhere.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  **Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. The same holds for any helper that calls `ds`: declare it inside the handler. A function at module level that calls `ds` keeps the server-only import in the browser bundle, and every page stops loading until it moves. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  **Boundary.** `Audience` and `defineVisibility` come from `@softr/sdk` and work anywhere.
@@ -3,13 +3,13 @@ name: routes-and-visibility
3
3
  description: >-
4
4
  Add a route file and declare its settings: definePage with its visibility
5
5
  (LOGGED_IN_USERS, NON_LOGGED_IN_USERS and customGroups) and its title,
6
- guardRoute or assertRouteAccess in beforeLoad, pageHead in head,
7
- isAuthorized and checkAccess anywhere, rendering an access error, and the
8
- lint rules that require the declaration.
6
+ guardRoute or assertRouteAccess in beforeLoad, pageHead in head, isAuthorized
7
+ and checkAccess anywhere, rendering an access error, and the lint rules that
8
+ require the declaration.
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  **Boundary.** `definePage`, `pageHead`, the access functions and the error predicates come from `@softr/sdk` and work anywhere.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 0.0.90-alpha.6
12
+ library_version: 0.0.90-alpha.7
13
13
  ---
14
14
 
15
15
  **Boundary.** `workflow` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineWorkflow` and every type come from `@softr/sdk` and can be imported anywhere.