@lotics/app-sdk 0.131.14 → 0.131.16

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/AGENTS.md CHANGED
@@ -20,7 +20,7 @@ This file is the index. The **exact type** of anything is its shipped declaratio
20
20
  | [docs/workflows.md](./docs/workflows.md) | **The workflow-BODY reference** — the JS subset a body may use, opaque `fld_*`/`opt_*` keys, every step form, the accepted sugar, helpers, record-write surfaces, the traps and the verify loop. |
21
21
  | [docs/recipes.md](./docs/recipes.md) | Task-shaped how-tos — returning a generated file, returning structured data, parameterized lookups, composable optional filters, cell decoding, testing an AI action without spending credits. |
22
22
  | [docs/files.md](./docs/files.md) | Files end to end — `useFileUpload` and its `fidelity` and a photo's `place`, `renameFile` (a new file over the same bytes), `useAttachments`/`useAttachmentPiles`, `readFiles` and presigned URLs (a bearer credential — never logged or persisted), workflow-generated files, naming a zip's entries, the delivery bounds. |
23
- | [docs/members_and_options.md](./docs/members_and_options.md) | People and select options — `useMembers`, `useFieldOptions`, `useViewer`, `useWorkspaceTimezone`/`useWorkspaceCurrency`, `useAppContext`, `askAppContext` (ask the host's context early), the workspace's zone at the root, a member's links to one record for a person with no seat (`useOutsideLinks`). |
23
+ | [docs/members_and_options.md](./docs/members_and_options.md) | People and select options — `useMembers`, `useMemberNames` (name a stored member id), `useFieldOptions`, `useViewer`, `useWorkspaceTimezone`/`useWorkspaceCurrency`, `useAppContext`, `askAppContext` (ask the host's context early), the workspace's zone at the root, a member's links to one record for a person with no seat (`useOutsideLinks`). |
24
24
  | [docs/navigation_and_state.md](./docs/navigation_and_state.md) | `AppRouter` (embedded/standalone URL model, the screens and `drawers` it reports to the host, opening at `/` when the person opens the app from the host: `openRequested`, `subscribeOpen`), `useUrlState` + `urlParam` codecs, `useRecents`, `useFolderPick`. |
25
25
  | [docs/ai.md](./docs/ai.md) | `useAgentRun` (structured vs free-text, streaming parts, the agent's ask-back), `askAi`, `useAiContext`, and what the member's own chat agent can do with the app while it is open. |
26
26
  | [docs/security.md](./docs/security.md) | **Read before shipping** — the owner-principal model, `is_current_member` scoping, write attribution, group gates, public-app bounds, why a per-input bound is a tenancy floor rather than an authorization check. |
@@ -1884,6 +1884,8 @@ function rpcStandalone(op, payload) {
1884
1884
  return standaloneRename(payload);
1885
1885
  case "members":
1886
1886
  return standaloneMembers(payload);
1887
+ case "member_names":
1888
+ return Promise.reject(new Error("Naming members by id is available only in embedded apps \u2014 a signed-in member is required."));
1887
1889
  case "context":
1888
1890
  return standaloneContext();
1889
1891
  case "spec":
package/dist/hooks.d.ts CHANGED
@@ -151,7 +151,7 @@ export interface MembersOptions {
151
151
  enabled?: boolean;
152
152
  }
153
153
  /**
154
- * The organization's members, for an assign picker. Member-only, and gated on
154
+ * The people of the app's workspace, for an assign picker. Member-only, and gated on
155
155
  * the app declaring a `member`-typed workflow input. `name` may be empty —
156
156
  * fall back to `email`.
157
157
  *
@@ -161,6 +161,24 @@ export interface MembersOptions {
161
161
  * ```
162
162
  */
163
163
  export declare function useMembers(opts?: MembersOptions): MembersState;
164
+ export type MemberName = {
165
+ id: string;
166
+ name: string | null;
167
+ email: string | null;
168
+ image: string | null;
169
+ archived: boolean;
170
+ };
171
+ export interface MemberNamesState {
172
+ members: MemberName[];
173
+ loading: boolean;
174
+ error: string | null;
175
+ }
176
+ /**
177
+ * The name and photo of each member id, people who left included. An id of no member of the organization is absent.
178
+ * For DISPLAY of a stored id; `useMembers` is the SELECTION source. `email` is null for a person the viewer shares no
179
+ * workspace with. Member-only: outside an embedded app it errors.
180
+ */
181
+ export declare function useMemberNames(ids: readonly string[]): MemberNamesState;
164
182
  type AgentOutputOf<K extends string> = K extends keyof AppAgentResults ? AppAgentResults[K] : unknown;
165
183
  export interface AgentRunOptions {
166
184
  /** Groups this run with the session's prior runs as context; a new id clears it. */
package/dist/index.d.ts CHANGED
@@ -3,8 +3,8 @@ export { mount } from "./mount.js";
3
3
  export type { MountOptions } from "./mount.js";
4
4
  export { reportAppError } from "./error_report.js";
5
5
  export type { AppErrorKind } from "./error_report.js";
6
- export { useWorkflow, useWorkflows, writesSettled, useFileUpload, useAttachments, useAttachmentPiles, useMembers, useAgentRun, useAgentRuns, useAiContext, buildChoiceOutput, } from "./hooks.js";
7
- export type { UploadedFile, WorkflowResult, MembersOptions, AgentRunOptions, UseAgentRun, AgentRunLanding, AgentRunRecord, AgentRunState, AgentUIPart, PendingChoice, ChoiceQuestion, ChoiceOption, AskUserChoiceOutput, } from "./hooks.js";
6
+ export { useWorkflow, useWorkflows, writesSettled, useFileUpload, useAttachments, useAttachmentPiles, useMembers, useMemberNames, useAgentRun, useAgentRuns, useAiContext, buildChoiceOutput, } from "./hooks.js";
7
+ export type { UploadedFile, WorkflowResult, MembersOptions, MemberName, MemberNamesState, AgentRunOptions, UseAgentRun, AgentRunLanding, AgentRunRecord, AgentRunState, AgentUIPart, PendingChoice, ChoiceQuestion, ChoiceOption, AskUserChoiceOutput, } from "./hooks.js";
8
8
  export { useQuery, useQueries, queryAll, exportQuery, exportApp, useFieldOptions } from "./queries.js";
9
9
  export type { QueryCall, QueryState, RowOf, QueryOptions, ColumnKeyOf, FieldOptions, FieldOptionsState, FieldOptionsOptions, FigureUnits, } from "./queries.js";
10
10
  export type { QueryRow, QuerySortKey, QueryFieldSortKey, QueryFirstSortKey, QueryFilter, QueryFilterCondition, QueryFilterFieldCondition, QueryFilterRecordIdCondition, QueryFilterGroup, ExportCall, ExportFile, ExportReport, ExportTab, } from "./shared_types.js";
package/dist/index.js CHANGED
@@ -55,7 +55,7 @@ import {
55
55
  subtractDecimal,
56
56
  sumDecimal,
57
57
  urlParam
58
- } from "./chunk-VMPPIPWX.js";
58
+ } from "./chunk-6AR7WS7C.js";
59
59
 
60
60
  // src/mount.tsx
61
61
  import { createRoot } from "react-dom/client";
@@ -11300,6 +11300,23 @@ function useMembers(opts) {
11300
11300
  return { members: roster.data ?? NO_MEMBERS, loading: roster.loading, error: roster.error?.message ?? null };
11301
11301
  }
11302
11302
  var NO_MEMBERS = [];
11303
+ var MEMBER_NAMES_PER_REQUEST = 500;
11304
+ var NO_MEMBER_NAMES = { members: [], loading: false, error: null };
11305
+ function useMemberNames(ids) {
11306
+ const distinct = [...new Set(ids)].sort();
11307
+ const held2 = useKey(
11308
+ distinct.length === 0 ? null : JSON.stringify(["member_names", distinct]),
11309
+ async () => {
11310
+ const chunks = Array.from({ length: Math.ceil(distinct.length / MEMBER_NAMES_PER_REQUEST) }, (_, at2) => distinct.slice(at2 * MEMBER_NAMES_PER_REQUEST, (at2 + 1) * MEMBER_NAMES_PER_REQUEST));
11311
+ const answers2 = await Promise.all(chunks.map((chunk) => rpc("member_names", { ids: chunk })));
11312
+ return { ids: distinct, members: answers2.flatMap((answer) => answer.members) };
11313
+ },
11314
+ { focus: false }
11315
+ );
11316
+ if (distinct.length === 0) return NO_MEMBER_NAMES;
11317
+ const answers = held2.data !== void 0 && held2.data.ids.length === distinct.length && held2.data.ids.every((id, at2) => id === distinct[at2]);
11318
+ return { members: answers && held2.data !== void 0 ? held2.data.members : NO_MEMBER_NAMES.members, loading: held2.loading || !answers && held2.error === null, error: held2.error?.message ?? null };
11319
+ }
11303
11320
  function useAgentRun(alias) {
11304
11321
  const [state, setState] = useState2(null);
11305
11322
  const handleRef = useRef3(null);
@@ -11502,6 +11519,19 @@ function useAgentRuns(sessionId, opts) {
11502
11519
  // src/queries.ts
11503
11520
  import { useCallback as useCallback5, useMemo as useMemo3, useState as useState3 } from "react";
11504
11521
 
11522
+ // ../shared/src/iam_helpers.ts
11523
+ var ORGANIZATION_OWNER_ROLES = ["owner", "admin", "co_owner"];
11524
+ function isOrganizationOwner(role) {
11525
+ return ORGANIZATION_OWNER_ROLES.some((one) => one === role);
11526
+ }
11527
+ function organizationRole(stored) {
11528
+ if (stored === "owner") return "owner";
11529
+ return isCoOwner(stored) ? "co_owner" : "member";
11530
+ }
11531
+ function isCoOwner(role) {
11532
+ return isOrganizationOwner(role) && role !== "owner";
11533
+ }
11534
+
11505
11535
  // ../shared/src/app_screen/cells.ts
11506
11536
  function opt(v) {
11507
11537
  if (typeof v === "string") return v || null;
@@ -11615,7 +11645,7 @@ function readMembers(value) {
11615
11645
  if ("groups" in obj) {
11616
11646
  m.groups = Array.isArray(obj.groups) ? obj.groups.filter((g) => typeof g === "string") : [];
11617
11647
  }
11618
- if (obj.role === "owner" || obj.role === "admin" || obj.role === "member") m.role = obj.role;
11648
+ if (typeof obj.role === "string" && (isOrganizationOwner(obj.role) || obj.role === "member")) m.role = organizationRole(obj.role);
11619
11649
  if (typeof obj.joined === "string" && obj.joined !== "") m.joined = obj.joined;
11620
11650
  if (obj.archived === true) m.archived = true;
11621
11651
  out.push(m);
@@ -15497,6 +15527,7 @@ export {
15497
15527
  useFieldOptions,
15498
15528
  useFileUpload,
15499
15529
  useFolderPick,
15530
+ useMemberNames,
15500
15531
  useMembers,
15501
15532
  useNewRecord,
15502
15533
  useOutsideLinks,
package/dist/router.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  setUrlParams,
6
6
  settleOpen,
7
7
  subscribeOpen
8
- } from "./chunk-VMPPIPWX.js";
8
+ } from "./chunk-6AR7WS7C.js";
9
9
 
10
10
  // src/router.tsx
11
11
  import { useEffect, useLayoutEffect, useRef } from "react";
package/dist/rpc.d.ts CHANGED
@@ -13,7 +13,7 @@ import { type UrlParams, type UrlParamsPatch } from "./url_params.js";
13
13
  * cover is answered and none was sent for two frames: the app's first screen has its data
14
14
  * host → app: { id, type: "result", data } | { id, type: "error", message }
15
15
  */
16
- export type RpcOp = "query" | "export" | "field_options" | "workflow" | "agentRuns" | "agentRun.get" | "agentRun.cancel" | "upload" | "file.rename" | "members" | "context" | "spec" | "write_model" | "prediction_miss" | "openExternal" | "askAi" | "urlState.get" | "urlState.set" | "folder.get" | "folder.set" | "comments.list" | "comments.create" | "comments.update" | "comments.delete" | "comments.counts" | "recording.start" | "recording.stop" | "outsideLink.list" | "outsideLink.create" | "outsideLink.revoke";
16
+ export type RpcOp = "query" | "export" | "field_options" | "workflow" | "agentRuns" | "agentRun.get" | "agentRun.cancel" | "upload" | "file.rename" | "members" | "member_names" | "context" | "spec" | "write_model" | "prediction_miss" | "openExternal" | "askAi" | "urlState.get" | "urlState.set" | "folder.get" | "folder.set" | "comments.list" | "comments.create" | "comments.update" | "comments.delete" | "comments.counts" | "recording.start" | "recording.stop" | "outsideLink.list" | "outsideLink.create" | "outsideLink.revoke";
17
17
  export interface AgentRunPayload {
18
18
  alias: string;
19
19
  session_id: string;
@@ -261,7 +261,7 @@ export interface ResolvedMember {
261
261
  * The organization PERMISSION level, not a job title — "who is this person"
262
262
  * is `groups`. Raw: translate it yourself.
263
263
  */
264
- role?: "admin" | "member" | "owner";
264
+ role?: "co_owner" | "member" | "owner";
265
265
  /** ISO timestamp of joining the organization. */
266
266
  joined?: string;
267
267
  /**
@@ -14,7 +14,7 @@ Every select and member value reaches the app in one of two shapes, and most scr
14
14
  | Populate a select picker, or color a stored value | `useFieldOptions(alias)` | Each select column's **complete** option list — `{ key, alias, label, color }` — plus `byKey` and `byAlias` indexes |
15
15
  | Filter a number each row reads in its own unit | `useFieldOptions(alias).units` | The units or currencies a range on it compares in — `{ vocabulary, options }` |
16
16
  | Render a stored member value | `readMembers(cell)` | The members the record actually holds |
17
- | Populate a member picker (assign UIs) | `useMembers(opts?)` | The org roster — every member, not only the referenced ones |
17
+ | Populate a member picker (assign UIs) | `useMembers(opts?)` | The workspace roster — every person of the app's workspace, not only the referenced ones |
18
18
 
19
19
  Cells are **self-describing**: the server rewrites raw storage shapes into resolved objects before
20
20
  rows reach the app, so an app never maintains a hardcoded key→label or id→name map. Catalogs are
@@ -140,7 +140,7 @@ projected `select_member` cell to `Array<{ id, name, email?, image?, groups?, ro
140
140
  cookie-authenticated proxy, so an unsigned URL would not load inside an app iframe at all.
141
141
  - **`groups` is the platform's "department".** There is no department field; a member group is what
142
142
  an org uses to say Sale, Kế toán, CSKH. `[]` when the member is in none.
143
- - **`role` arrives RAW (`owner` / `admin` / `member`) and you translate it.** The platform ships no
143
+ - **`role` arrives RAW (`owner` / `co_owner` / `member`) and you translate it.** The platform ships no
144
144
  display word, because a server that picked one would leak English into every localized app — map
145
145
  it next to the rest of your vocabulary. It is a PERMISSION level, not a job title: everyone reads
146
146
  "Admin" beside a name as rank. If the question your screen asks is "who is this person in the
@@ -159,9 +159,9 @@ projected `select_member` cell to `Array<{ id, name, email?, image?, groups?, ro
159
159
  Decode with **`readMembers(cell)`** (`dist/members.d.ts`) → `ResolvedMember[]`. Same defensive
160
160
  contract as `readSelect`: `[]` for null/empty/unexpected cells, malformed entries dropped.
161
161
 
162
- ## The org roster: `useMembers(opts?)`
162
+ ## The workspace roster: `useMembers(opts?)`
163
163
 
164
- The candidate set for an "assign to a member" picker (`dist/hooks.d.ts`):
164
+ The candidate set for an "assign to a member" picker (`dist/hooks.d.ts`): the people of the app's workspace, organization owners included. A stored member who is not among them still resolves in a cell (`readMembers`), not in this list.
165
165
 
166
166
  ```tsx
167
167
  const { members, loading, error } = useMembers({ group: GRP.fulfillment });
@@ -191,7 +191,7 @@ three gates are observable as an `error` on the hook:
191
191
  member declaration gets: *"This app has not declared member access — listing members requires a
192
192
  declared workflow `member` input or query `member` param."* Member access is a declared,
193
193
  auditable surface, like queries and workflows.
194
- 3. **Declared groups only.** `{ group }` restricts the roster to one member group — but
194
+ 3. **Declared groups only.** `{ group }` restricts the roster to the people of one member group who are in the app's workspace — but
195
195
  only a group declared on some member input's `group` property. An undeclared group errors; an
196
196
  app can only enumerate groups it actually assigns into. A declared group with no members
197
197
  resolves to `{ members: [] }`.
@@ -230,6 +230,20 @@ the `select_member` field in the query, and the cell already carries the name.
230
230
  Names render; only the avatar photo is unavailable, so draw initials in its place. If a name
231
231
  renders blank, fix the query projection — never widen the bindings.
232
232
 
233
+ ## Naming a stored member id: `useMemberNames(ids)`
234
+
235
+ The name and photo of each member id, people who left included (`dist/hooks.d.ts`). It is for DISPLAY of an id a screen holds; `useMembers` stays the SELECTION source for pickers.
236
+
237
+ ```tsx
238
+ const { members, loading, error } = useMemberNames(filterMemberIds);
239
+ // members: { id, name, email, image, archived }[]
240
+ ```
241
+
242
+ - An id of no member of the organization is absent from `members`.
243
+ - `name` is null when the member has none; `email` is null for a person the viewer shares no workspace with. `role` and join date are never carried.
244
+ - One read per distinct set of ids, never on focus; an empty list reads nothing and answers `{ members: [], loading: false, error: null }`.
245
+ - Member-only: outside an embedded app (a standalone or public viewer) it resolves `error`, with `members: []`.
246
+
233
247
  ## `useViewer()` — display-only identity
234
248
 
235
249
  `useViewer()` (`dist/viewer.d.ts`) → `{ memberId, groupIds, loading }` — the signed-in member currently
package/docs/security.md CHANGED
@@ -97,7 +97,7 @@ A publicly-shared app (its own origin, or its public link) is reachable by **any
97
97
  | File upload (workflow `file` inputs) | Yes — bounded to the app's workspace |
98
98
  | Query/workflow file outputs | Yes — file cells and workflow-produced files return direct presigned URLs (24-hour TTL) that anonymous viewers can fetch; see [files](./files.md) |
99
99
  | Agent runs (`useAgentRun`) | **No** — rejected: agent runs require an authenticated member, and each member's run history is private to them (a guessed session id cannot read another member's thread) |
100
- | Member roster (`useMembers`) | **No** — same-org members only (below) |
100
+ | Member roster (`useMembers`) | **No** — signed-in members of the app's organization only (below) |
101
101
 
102
102
  **Warning — `is_current_member` on a public app resolves to the app owner.** An anonymous request has no viewer to bind, so both `is_current_member` and `current_member in_any_group` fall back to the owner's identity and the owner's groups. A "my items" query shows every anonymous visitor the *owner's* items, and a manager-only read template gated on a group the owner belongs to **passes for every anonymous visitor**. Never rely on viewer-bound predicates in a public app.
103
103
 
@@ -105,7 +105,7 @@ A publicly-shared app (its own origin, or its public link) is reachable by **any
105
105
 
106
106
  ### Member roster access
107
107
 
108
- Listing members (`useMembers`) takes an authenticated member of the app's own org, a declared `member` input or param, and a group only where one is declared; in query results a member cell carries `email` only for that same-org member. The gates and their errors: [members_and_options](./members_and_options.md#access-gates-when-it-errors).
108
+ Listing members (`useMembers`) takes an authenticated member of the app's own org, a declared `member` input or param, and a group only where one is declared, and answers the people of the app's workspace (organization owners included); in query results a member cell carries `email` only for a viewer of that same org. The gates and their errors: [members_and_options](./members_and_options.md#access-gates-when-it-errors).
109
109
 
110
110
  ## What runtime refinement cannot widen
111
111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.131.14",
3
+ "version": "0.131.16",
4
4
  "description": "The SDK a Lotics custom-code app reads and writes through — typed hooks over the host bridge, cell readers, mount() and AppRouter",
5
5
  "type": "module",
6
6
  "exports": {