@lotics/app-sdk 0.131.15 → 0.131.17
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 +1 -1
- package/dist/{chunk-VMPPIPWX.js → chunk-6AR7WS7C.js} +2 -0
- package/dist/hooks.d.ts +18 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +31 -4
- package/dist/router.js +1 -1
- package/dist/rpc.d.ts +1 -1
- package/dist/shared_types.d.ts +1 -1
- package/docs/members_and_options.md +15 -1
- package/package.json +1 -1
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
|
@@ -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-
|
|
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);
|
|
@@ -11503,7 +11520,17 @@ function useAgentRuns(sessionId, opts) {
|
|
|
11503
11520
|
import { useCallback as useCallback5, useMemo as useMemo3, useState as useState3 } from "react";
|
|
11504
11521
|
|
|
11505
11522
|
// ../shared/src/iam_helpers.ts
|
|
11506
|
-
var
|
|
11523
|
+
var ORGANIZATION_OWNER_ROLES = ["owner", "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 role === "co_owner";
|
|
11533
|
+
}
|
|
11507
11534
|
|
|
11508
11535
|
// ../shared/src/app_screen/cells.ts
|
|
11509
11536
|
function opt(v) {
|
|
@@ -11618,8 +11645,7 @@ function readMembers(value) {
|
|
|
11618
11645
|
if ("groups" in obj) {
|
|
11619
11646
|
m.groups = Array.isArray(obj.groups) ? obj.groups.filter((g) => typeof g === "string") : [];
|
|
11620
11647
|
}
|
|
11621
|
-
|
|
11622
|
-
if (role !== void 0) m.role = role;
|
|
11648
|
+
if (typeof obj.role === "string" && (isOrganizationOwner(obj.role) || obj.role === "member")) m.role = organizationRole(obj.role);
|
|
11623
11649
|
if (typeof obj.joined === "string" && obj.joined !== "") m.joined = obj.joined;
|
|
11624
11650
|
if (obj.archived === true) m.archived = true;
|
|
11625
11651
|
out.push(m);
|
|
@@ -15501,6 +15527,7 @@ export {
|
|
|
15501
15527
|
useFieldOptions,
|
|
15502
15528
|
useFileUpload,
|
|
15503
15529
|
useFolderPick,
|
|
15530
|
+
useMemberNames,
|
|
15504
15531
|
useMembers,
|
|
15505
15532
|
useNewRecord,
|
|
15506
15533
|
useOutsideLinks,
|
package/dist/router.js
CHANGED
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;
|
package/dist/shared_types.d.ts
CHANGED
|
@@ -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?: "
|
|
264
|
+
role?: "co_owner" | "member" | "owner";
|
|
265
265
|
/** ISO timestamp of joining the organization. */
|
|
266
266
|
joined?: string;
|
|
267
267
|
/**
|
|
@@ -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` / `
|
|
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
|
|
@@ -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/package.json
CHANGED