@lotics/app-sdk 0.90.0 → 0.90.1

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.
@@ -383,10 +383,10 @@ export interface FieldOptionsOptions {
383
383
  * ```tsx
384
384
  * const { fields } = useFieldOptions("records");
385
385
  * // populate + color a picker:
386
- * <Picker options={fields.status?.options ?? []}
387
- * renderOptionContent={(o) => <OptionBadge value={o} />} />
386
+ * <Select variant="native" options={fields.status?.options ?? []}
387
+ * renderOptionContent={(o) => <Status option={o} />} />
388
388
  * // color a stored value:
389
- * <OptionBadge value={fields.status?.byKey(readSelect(r.status)[0]?.key ?? "")} />
389
+ * <Status option={fields.status?.byKey(readSelect(r.status)[0]?.key ?? "")} />
390
390
  * ```
391
391
  */
392
392
  export declare function useFieldOptions<K extends keyof AppQueries & string>(alias: K, opts?: FieldOptionsOptions): FieldOptionsState;
@@ -448,7 +448,7 @@ export declare function usePaginatedQuery<K extends string>(alias: K, ...args: Q
448
448
  *
449
449
  * ```tsx
450
450
  * const { total } = useCount("orders", { q }, { filter: unpaidFilter });
451
- * return <Badge label={total == null ? "…" : `${total}`} />;
451
+ * return <Status label={total == null ? "…" : `${total}`} />;
452
452
  * ```
453
453
  */
454
454
  export declare function useCount<K extends string>(alias: K, ...args: QueryArgs<K, CountOptions<ColumnKeyOf<K>>>): CountState;
@@ -619,7 +619,7 @@ export interface MembersOptions {
619
619
  *
620
620
  * ```tsx
621
621
  * const { members } = useMembers({ group: "grp_..." });
622
- * // <Picker options={members.map((m) => ({
622
+ * // <Select variant="native" options={members.map((m) => ({
623
623
  * // value: m.id, label: m.name || m.email || m.id, image: m.image,
624
624
  * // }))} />
625
625
  * ```
package/dist/src/hooks.js CHANGED
@@ -536,7 +536,7 @@ export function useAiContext(slot, context) {
536
536
  *
537
537
  * ```tsx
538
538
  * const { members } = useMembers({ group: "grp_..." });
539
- * // <Picker options={members.map((m) => ({
539
+ * // <Select variant="native" options={members.map((m) => ({
540
540
  * // value: m.id, label: m.name || m.email || m.id, image: m.image,
541
541
  * // }))} />
542
542
  * ```
@@ -4,15 +4,14 @@
4
4
  * "@lotics/app-sdk"` and ship the resulting bundle via `lotics app deploy`.
5
5
  *
6
6
  * This SDK is data + RPC only — it deliberately does NOT re-export any
7
- * `@lotics/ui` components, so it ships without pulling in packages/ui's
8
- * React Native Web dependency tree. That is a packaging choice, NOT a
9
- * limitation on apps: apps import `@lotics/ui` directly as a normal dep.
10
- * The starter scaffold (`packages/sdk/src/starter_template.ts`) wires the
11
- * full setup — `@lotics/ui` + react-native + react-native-web, the
12
- * react-native→react-native-web Vite alias, `@lotics/ui/index.css` +
13
- * `fonts.css`, and a `PortalHost` for overlays. Build dashboards by
14
- * composing `@lotics/ui` components (Card, KpiCard, charts, Table, …),
15
- * not raw HTML/CSS. See `docs/apps.md` → "Styling & components".
7
+ * `@lotics/ui` component, so an app's dependency on the kit is its own and one
8
+ * version answers for it. That is a packaging choice, NOT a limitation: apps
9
+ * import `@lotics/ui` directly as an ordinary dependency. The starter scaffold
10
+ * (`packages/sdk/src/starter_template.ts`) wires it — the kit as a dependency,
11
+ * `@lotics/ui/styles.css` + `fonts.css` in the entry, and `loticsResolve()` as
12
+ * the whole `resolve` block. Build screens by composing kit components (Card,
13
+ * Metric, charts, Table, …), not raw HTML/CSS. See `docs/apps.md` → "Styling
14
+ * & components".
16
15
  */
17
16
  export { mount } from "./mount.js";
18
17
  export type { MountOptions } from "./mount.js";
package/dist/src/index.js CHANGED
@@ -4,15 +4,14 @@
4
4
  * "@lotics/app-sdk"` and ship the resulting bundle via `lotics app deploy`.
5
5
  *
6
6
  * This SDK is data + RPC only — it deliberately does NOT re-export any
7
- * `@lotics/ui` components, so it ships without pulling in packages/ui's
8
- * React Native Web dependency tree. That is a packaging choice, NOT a
9
- * limitation on apps: apps import `@lotics/ui` directly as a normal dep.
10
- * The starter scaffold (`packages/sdk/src/starter_template.ts`) wires the
11
- * full setup — `@lotics/ui` + react-native + react-native-web, the
12
- * react-native→react-native-web Vite alias, `@lotics/ui/index.css` +
13
- * `fonts.css`, and a `PortalHost` for overlays. Build dashboards by
14
- * composing `@lotics/ui` components (Card, KpiCard, charts, Table, …),
15
- * not raw HTML/CSS. See `docs/apps.md` → "Styling & components".
7
+ * `@lotics/ui` component, so an app's dependency on the kit is its own and one
8
+ * version answers for it. That is a packaging choice, NOT a limitation: apps
9
+ * import `@lotics/ui` directly as an ordinary dependency. The starter scaffold
10
+ * (`packages/sdk/src/starter_template.ts`) wires it — the kit as a dependency,
11
+ * `@lotics/ui/styles.css` + `fonts.css` in the entry, and `loticsResolve()` as
12
+ * the whole `resolve` block. Build screens by composing kit components (Card,
13
+ * Metric, charts, Table, …), not raw HTML/CSS. See `docs/apps.md` → "Styling
14
+ * & components".
16
15
  */
17
16
  export { mount } from "./mount.js";
18
17
  export { useWorkflow, useQuery, useInfiniteQuery, usePaginatedQuery, useCount, useFieldOptions, useFileUpload, useAttachments, useMembers, useAgentRun, useAgentRuns, useAiContext, buildChoiceOutput, } from "./hooks.js";
@@ -18,7 +18,7 @@ export interface ResolvedOption {
18
18
  * Named palette color token (e.g. `"blue"`, `"emerald"`). Populated by
19
19
  * `useFieldOptions` (which reads the field config); absent on options read
20
20
  * back from a query CELL via `readSelect` — a cell carries only key + label.
21
- * Pass the resolved option straight to `@lotics/ui`'s `OptionBadge`, which
21
+ * Pass the resolved option straight to `@lotics/ui`'s `Status`, which
22
22
  * degrades a missing/unknown token to a neutral badge.
23
23
  */
24
24
  color?: string;
@@ -439,7 +439,7 @@ a partial as its period start.
439
439
 
440
440
  **`readSelect`.** A query **cell** carries `key` + `label` only — `color` comes from
441
441
  `useFieldOptions`, not the cell. An option deleted after the cell was written surfaces as
442
- `label === key` (the stale state is explicit, never hidden). Render with `@lotics/ui` `OptionBadge`
442
+ `label === key` (the stale state is explicit, never hidden). Render with `@lotics/ui` `Status`
443
443
  — see [./members_and_options.md](./members_and_options.md).
444
444
 
445
445
  **`readMembers`.** `name` is `null` when the id doesn't resolve in the app's org (e.g. a removed
@@ -477,7 +477,7 @@ A query cell carries only the options a record actually holds (key + label, no c
477
477
  **complete** option list of a select column — every option including those in no current row, with
478
478
  colors — use **`useFieldOptions`**, and prefer it over deriving options from loaded rows
479
479
  (row-derived sets are incomplete until every page loads and carry no colors). Its full contract
480
- (return shape, `byKey`, `opts.enabled`, freshness), rendering the values (`OptionBadge`,
480
+ (return shape, `byKey`, `opts.enabled`, freshness), rendering the values (`Status`,
481
481
  `MemberChip`, `MemberSelect`), and the member roster (`useMembers`) live in
482
482
  [./members_and_options.md](./members_and_options.md).
483
483
 
@@ -510,7 +510,7 @@ pieces. Compose these — don't hand-roll search:
510
510
 
511
511
  - **`Combobox`** (`@lotics/ui/combobox`) owns the interaction — debounced `onSearchChange`, a
512
512
  popover listbox with rich rows (`renderOptionContent`), keyboard navigation, `recentOptions`,
513
- `allowCustom`. (For a known small list with no search box, `Picker`.)
513
+ `allowCustom`. (For a known small list with no search box, `Select`.)
514
514
  - **A parameterized `search` query** — a `from_table` with `search: "{{params.q}}"` over the
515
515
  maintained search document: **diacritics- and case-insensitive**, trigram-indexed, and AND-ed
516
516
  with the template's `filter` (search within a scope). The full `search` contract is in
@@ -540,7 +540,7 @@ const [typed, setTyped] = useState(""); // the input's own value, every
540
540
  const [term, setTerm] = useState(""); // what the server is asked, once typing settles
541
541
  const commit = useDebouncedCallback(setTerm, 250);
542
542
 
543
- <SearchInput value={typed} onChangeText={(v) => { setTyped(v); commit(v.trim()); }} />;
543
+ <TextInput type="search" value={typed} onChangeText={(v) => { setTyped(v); commit(v.trim()); }} />;
544
544
 
545
545
  const { rows, loading } = useQuery(
546
546
  "searchCustomers",
@@ -560,8 +560,8 @@ relationship exists.
560
560
  When the user doesn't know the term — "show me everything, let me narrow it" — build a modal table
561
561
  they can browse (numbered pages), search, sort, and filter:
562
562
 
563
- - **The screen is app-owned**, composed from `@lotics/ui`: a `Dialog` over `SearchInput` + filter
564
- pills (`ColumnFilter`) + `Table` + `Pagination`. It needs both `@lotics/ui` and the SDK (which is
563
+ - **The screen is app-owned**, composed from `@lotics/ui`: a `Dialog` over a search `TextInput` + filter
564
+ pills (`FilterChip column=`) + `Table` + `Pagination`. It needs both `@lotics/ui` and the SDK (which is
565
565
  UI-free), so it lives in the app (e.g. a `record_picker.tsx`) — reuse it for any table by passing
566
566
  a different `alias` + column config.
567
567
  - **`usePaginatedQuery`** drives it: the page of rows, the `total` for "Page 1 of N" (the built-in
package/docs/files.md CHANGED
@@ -19,7 +19,7 @@ discipline in [data fetching](./data_fetching.md).
19
19
  | Attach to a record | a declared workflow with a `{ type: "file" }` input | the workflow writes the id(s) into a `files` field — the **only** write path |
20
20
  | Read back from records | `useQuery` + `readFiles(cell)` | `AppFile[]` — presigned `url`/`thumbnail_url` (24 h) + `size`/`created_at` |
21
21
  | Receive a generated document | `useWorkflow` → `WorkflowResult.files` | presigned files auto-extracted from the run |
22
- | Show it | `@lotics/ui` `FileThumbnail` / `FileGrid` / `FileGalleryModal` | map to `DisplayFile` (see below) |
22
+ | Show it | `@lotics/ui` `FileThumbnail` / `FileThumbnailGrid` / `FileGalleryDialog` | map to `DisplayFile` (see below) |
23
23
  | Save browser-built bytes | `downloadFile(filename, data, mimeType?)` | a client-side download (see [runtime](./runtime.md)) |
24
24
 
25
25
  An uploaded file is **inert until a workflow attaches it** — it has an id and serving URLs, but
@@ -175,10 +175,10 @@ Each `AttachedFile` is `{ id, filename, mime_type, preview_url, status, file_id?
175
175
 
176
176
  Wiring to `@lotics/ui`: in a `Composer`, trigger picking from `actionsButton` (via `pickFiles`),
177
177
  render the attachment pills with `FileThumbnail` as above, and gate `sendDisabled` on `uploading`.
178
- For a full add-files *screen* (not a composer pill), map each `AttachedFile` to a `FileGrid`
179
- `FileUpload` entry — ready → `{ status: "complete", id: file_id, file: <DisplayFile> }`, else
180
- `{ status, id, filename, mimeType: mime_type, previewUrl: preview_url }` — and `FileGrid` renders
181
- the uploading/error/retry tiles itself.
178
+ For a full add-files *screen* (not a composer pill), map each `AttachedFile` to a
179
+ `FileThumbnailGrid` `FileUpload` entry — ready → `{ status: "complete", id: file_id, file:
180
+ <DisplayFile> }`, else `{ status, id, filename, mimeType: mime_type, previewUrl: preview_url }`
181
+ — and the grid renders the uploading/error/retry tiles itself.
182
182
 
183
183
  ## File cells in query results — `readFiles` and `AppFile`
184
184
 
@@ -325,11 +325,10 @@ not viewing). Component contracts live in the `@lotics/ui` reference
325
325
  For an `AttachedFile` still uploading, map `preview_url` → `url` (there is no server URL yet).
326
326
  The app owns this data→UI adapter — the SDK deliberately never imports `@lotics/ui`.
327
327
 
328
- - **`FileThumbnail`** — one square tile; `uploading` overlays a spinner, images fall back from
329
- `thumbnailUrl` to `url` on error.
330
- - **`FileGrid`** — a grid of completed files plus a live `uploads` queue (it renders
331
- uploading/error/retry tiles itself).
332
- - **`FileGalleryModal`** — the full-screen viewer (filename · counter · actions · close, with
328
+ - **`FileThumbnail`** — one square tile; `uploading` takes the queue status and overlays the
329
+ scrim, the spinner or the retry, images fall back from `previewUrl` to `thumbnailUrl` to `url`.
330
+ - **`FileThumbnailGrid`** — a grid of stored files plus a live `uploads` queue, in one grid.
331
+ - **`FileGalleryDialog`** — the full-screen viewer (filename · counter · actions · close, with
333
332
  prev/next + ESC), delegating per-file to **`FilePreview`**, which dispatches by MIME. Wire
334
333
  `onFilePress` → a `number | null` `activeIndex`.
335
334
  - PDF renders **inline to a canvas** (a nested PDF browsing context is blocked in the sandboxed
@@ -4,7 +4,7 @@ How an app renders and picks **people** and **select-field options**, plus the *
4
4
  surface. Covers the two cell readers (`readSelect`, `readMembers`), the two catalog hooks
5
5
  (`useFieldOptions`, `useMembers`), the viewer identity hook (`useViewer`), comments
6
6
  (`useComments`, `useCommentCounts`), and the `@lotics/ui` components they feed. Read this before
7
- building an assign picker, a colored status badge, a per-viewer ("my records") screen, or a
7
+ building an assign picker, a colored `Status` mark, a per-viewer ("my records") screen, or a
8
8
  comment thread. Query mechanics live in [queries](./queries.md); the authority model in
9
9
  [security](./security.md).
10
10
 
@@ -61,7 +61,7 @@ const { fields } = useFieldOptions("orders"); // same alias you query
61
61
  // are { value, label }, so map the option key to `value`):
62
62
  <Select
63
63
  options={(fields.status?.options ?? []).map((o) => ({ value: o.key, label: o.label }))}
64
- renderOptionContent={(o) => <OptionBadge value={fields.status?.byKey(o.value)} />}
64
+ renderOptionContent={(o) => <Status option={fields.status?.byKey(o.value)} />}
65
65
  value={status} onValueChange={setStatus}
66
66
  />
67
67
  ```
@@ -78,7 +78,7 @@ name**, not the field key. Each `FieldOptions`:
78
78
  | `byKey(key)` | Resolve one option by key; `undefined` for an unknown key (option removed after the cell was written) |
79
79
 
80
80
  - `color` is a named palette token (e.g. `"blue"`, `"emerald"`). Pass the option straight to
81
- `@lotics/ui`'s `OptionBadge`; a missing/unrecognized token degrades to a neutral badge.
81
+ `@lotics/ui`'s `Status`; a missing/unrecognized token degrades to a neutral badge.
82
82
  - **A column the server can't map to a single source select field is simply absent** from
83
83
  `fields` — a UNION output whose arms disagree on the source field, or a computed column. Read
84
84
  defensively: `fields.status?.options ?? []`.
@@ -99,7 +99,7 @@ until an edit drawer opens). State: `{ fields, loading, isValidating, error, ref
99
99
 
100
100
  ```tsx
101
101
  const opt = readSelect(row.status)[0];
102
- <OptionBadge value={opt ? (fields.status?.byKey(opt.key) ?? opt) : null} />
102
+ <Status option={opt ? (fields.status?.byKey(opt.key) ?? opt) : null} />
103
103
  ```
104
104
 
105
105
  `byKey` hit → the configured color. `byKey` miss (option removed post-write) → fall back to the
@@ -128,12 +128,12 @@ projected `select_member` cell to `Array<{ id, name, email?, image?, groups?, ro
128
128
  "Admin" beside a name as rank. If the question your screen asks is "who is this person in the
129
129
  company", the answer is `groups`.
130
130
  - **`joined` is an ISO timestamp of when the membership began.** Render it at whatever precision
131
- your question needs — `@lotics/ui`'s `MemberProfileCard` shows month and year, because "is this
131
+ your question needs — `@lotics/ui`'s `MemberPeek` shows month and year, because "is this
132
132
  the new person?" does not want a day. Absent on a public response, and on an id that did not
133
133
  resolve: there is no membership to have begun.
134
134
  - **`archived: true` marks someone who has LEFT** — omitted otherwise, never `false`. It is the one
135
135
  field that is NOT gated (a departed colleague reading as a current assignee is wrong on a public
136
- app too). Feed it to `inactive` on `MemberChip` / `MemberProfileCard`.
136
+ app too). Feed it to `inactive` on `MemberChip` / `MemberPeek`.
137
137
  - **An id that no longer resolves** (removed member, id outside the org) comes back with
138
138
  `name: null` — an explicit missing state, never an empty string. Render a placeholder.
139
139
  - Only ids already present in the projected rows are resolved — a member cell never exposes the
@@ -256,7 +256,7 @@ client-side up front, and re-checked server-side.
256
256
  - **The author is always the real signed-in member** — correct attribution, enforced server-side.
257
257
  **Warning:** under "View as", comments still author as the real member (the admin), not the
258
258
  view-as target — unlike `useViewer` and `is_current_member` scoping, which follow the target.
259
- - **Edit and delete are author-only**, checked server-side against the viewer. `CommentList`'s
259
+ - **Edit and delete are author-only**, checked server-side against the viewer. `CommentThread`'s
260
260
  `currentMemberId` prop drives the matching affordance client-side.
261
261
 
262
262
  ### Reading & writing
@@ -277,13 +277,13 @@ renders the panel. State: `{ comments, loading, error, available, createComment,
277
277
  updateComment, deleteComment, refetch }`.
278
278
 
279
279
  - `comments` — newest first on the wire (server order). Pass the array as-is to `@lotics/ui`'s
280
- `CommentList`, which re-sorts oldest-first for display. Each `AppComment`: `{ id, record_id,
280
+ `CommentThread`, which re-sorts oldest-first for display. Each `AppComment`: `{ id, record_id,
281
281
  table_id, member_id, content, files, workspace_id, created_at, updated_at }`. Attachments
282
282
  (`AppCommentFile`) carry `id` / `filename` / `mime_type` — a file's identity is its `id`, and
283
283
  the server re-reads every attachment from storage by that id, so nothing else you hold about a
284
284
  file can affect what is stored. The `url` / `thumbnail_url` / `preview_url` fields exist on the type
285
285
  but the server does not populate them today — render attachments by name and type (what
286
- `CommentList`'s default file row does), never by counting on a fetchable URL.
286
+ `CommentThread`'s default file row does), never by counting on a fetchable URL.
287
287
  - `createComment({ content, file_ids? })` — posts as the viewing member. `file_ids` come from
288
288
  `useFileUpload` / `useAttachments` (see [files](./files.md)). A comment must have content or at
289
289
  least one file (empty input is a client no-op; the server enforces the same rule). Content max
@@ -296,7 +296,7 @@ updateComment, deleteComment, refetch }`.
296
296
  on it.
297
297
  - **Limitation:** a comment carries `member_id` only — resolving the author's display name needs a
298
298
  member source: the `useMembers` roster (requires the member-access declaration above) or member
299
- cells in your own data. An unresolvable id should render a fallback (`CommentList` has an
299
+ cells in your own data. An unresolvable id should render a fallback (`CommentThread` has an
300
300
  `unknownMember` label for exactly this).
301
301
  - **Freshness:** SWR-cached, revalidates on focus/reconnect, so another viewer's comment appears on
302
302
  the next focus or explicit `refetch()` — not on its own. Comments are the one read that does not
@@ -320,10 +320,10 @@ directly (full props: `node_modules/@lotics/ui/AGENTS.md` and its `docs/`):
320
320
 
321
321
  | Value | Component | Feed it |
322
322
  | --- | --- | --- |
323
- | A select value (stored or picker option) | `OptionBadge` | A `useFieldOptions` option, or `byKey(readSelect(cell)[0]?.key)`; accepts a single option, an array (multi → one badge each), or null (renders nothing). Missing/unknown color → neutral. |
323
+ | A select value (stored or picker option) | `Status` | A `useFieldOptions` option, or `byKey(readSelect(cell)[0]?.key)`; accepts a single option, an array (multi → one badge each), or null (renders nothing). Missing/unknown color → neutral. |
324
324
  | A person, inline | `MemberChip` | `name` / `image` from a roster or a cell — both carry it; no image → initials |
325
325
  | A member picker | `MemberSelect` | `members={useMembers().members}` — renders each option as a `MemberChip`; `MEMBER_UNASSIGNED` marks its optional "unassigned" option |
326
- | A comment thread | `CommentList` + `CommentComposer` | `useComments` state; `resolveMember` bridges `member_id` → your member source |
326
+ | A comment thread | `CommentThread` + `CommentComposer` | `useComments` state; `resolveMember` bridges `member_id` → your member source |
327
327
 
328
328
  The SDK never imports `@lotics/ui` — the app owns the (thin) data→UI adapter in each row above.
329
329
 
package/docs/runtime.md CHANGED
@@ -266,7 +266,7 @@ page (standalone). Opens in a new tab with `noopener,noreferrer`.
266
266
  - Typical use: opening a workflow-generated file's `url` from
267
267
  `WorkflowResult.files[]` (see [mutations](./mutations.md)).
268
268
  - **Not a preview mechanism.** To *view* a file inline, use `@lotics/ui`'s
269
- `FilePreview`/`FileGalleryModal` (see [files](./files.md)); `openExternal` is
269
+ `FilePreview`/`FileGalleryDialog` (`@lotics/ui` ≥ 48 — see [files](./files.md)); `openExternal` is
270
270
  "leave the app".
271
271
 
272
272
  ## `openApp()` — the cross-app hop
@@ -445,14 +445,11 @@ is a transport that wasn't wired.
445
445
  no dynamic `import()`, no Node built-ins. Don't touch `window` at module top
446
446
  level — resolve lazily (test environments import modules before `jsdom` is
447
447
  ready).
448
- - **Two bundlers in the family.** Apps build with Vite; the Lotics product
449
- frontend builds with Metro (React Native Web). The SDK itself is never
450
- Metro-bundled — the host frontend is forbidden from importing
451
- `@lotics/app-sdk` (enforced by a dependency-direction test) — but sibling
452
- packages apps share with the product (`@lotics/ui`, `@lotics/xlsx`,
453
- `@lotics/docx`) build under both. When a shared package must diverge per
454
- target, use platform files (`x.web.ts` / `x.ts`) plus conditional package
455
- `exports` — never a runtime `require` or dynamic import.
448
+ - **One module per entry.** A package apps share with the Lotics product
449
+ (`@lotics/ui`, `@lotics/xlsx`, `@lotics/docx`) ships ONE module per entry: no
450
+ platform twins, no per-target `exports` condition. The SDK itself is never
451
+ bundled by the product at all — the host frontend is forbidden from importing
452
+ `@lotics/app-sdk`, enforced by a dependency-direction test.
456
453
  - **Self-contained on npm.** The SDK cannot import workspace-private or
457
454
  host-only packages (`@lotics/shared`, `@lotics/ui-internal`, the frontend's
458
455
  `@/` alias) or any React Native / Expo module — also test-enforced. A helper
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.90.0",
3
+ "version": "0.90.1",
4
4
  "description": "Runtime SDK for Lotics custom-code apps \u2014 typed hooks, postMessage bridge, mount entry point",
5
5
  "type": "module",
6
6
  "exports": {