@lotics/app-sdk 0.124.4 → 0.124.5

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/dist/hooks.d.ts CHANGED
@@ -3,7 +3,7 @@ import { type AttachmentPiles, type AttachmentPilesOptions, type AttachmentsOpti
3
3
  import { type AiContextValue } from "./rpc.js";
4
4
  import { type AgentUIPart, type PendingChoice, type AgentRunLanding } from "./agent_stream.js";
5
5
  import type { AppWorkflows, AppWorkflowResults, AppAgents, AppAgentResults } from "./types.js";
6
- import type { ResolvedMember } from "./members.js";
6
+ import type { ResolvedMember } from "./shared_types.js";
7
7
  import type { PhotoPlace } from "./row.js";
8
8
  export type { AgentRunState, AgentUIPart, PendingChoice, ChoiceQuestion, ChoiceOption, AskUserChoiceOutput, AgentRunLanding } from "./agent_stream.js";
9
9
  export { buildChoiceOutput } from "./agent_stream.js";
package/dist/index.d.ts CHANGED
@@ -6,7 +6,8 @@ export type { AppErrorKind } from "./error_report.js";
6
6
  export { useWorkflow, useWorkflows, writesSettled, useFileUpload, useAttachments, useAttachmentPiles, useMembers, useAgentRun, useAgentRuns, useAiContext, buildChoiceOutput, } from "./hooks.js";
7
7
  export type { UploadedFile, WorkflowResult, MembersOptions, AgentRunOptions, UseAgentRun, AgentRunLanding, AgentRunRecord, AgentRunState, AgentUIPart, PendingChoice, ChoiceQuestion, ChoiceOption, AskUserChoiceOutput, } from "./hooks.js";
8
8
  export { useQuery, useQueries, queryAll, exportQuery, useFieldOptions } from "./queries.js";
9
- export type { QueryRow, QueryCall, QueryState, RowOf, QueryOptions, ColumnKeyOf, QuerySortKey, QueryFieldSortKey, QueryFirstSortKey, QueryFilter, QueryFilterCondition, QueryFilterFieldCondition, QueryFilterRecordIdCondition, QueryFilterGroup, FieldOptions, FieldOptionsState, FieldOptionsOptions, FigureUnits, ExportCall, ExportFile, ExportReport, ExportTab, } from "./queries.js";
9
+ export type { QueryCall, QueryState, RowOf, QueryOptions, ColumnKeyOf, FieldOptions, FieldOptionsState, FieldOptionsOptions, FigureUnits, } from "./queries.js";
10
+ export type { QueryRow, QuerySortKey, QueryFieldSortKey, QueryFirstSortKey, QueryFilter, QueryFilterCondition, QueryFilterFieldCondition, QueryFilterRecordIdCondition, QueryFilterGroup, ExportCall, ExportFile, ExportReport, ExportTab, } from "./shared_types.js";
10
11
  export type { ExportedFile } from "./shared_types.js";
11
12
  export type { AttachedFile, AttachmentPiles, AttachmentPilesOptions, AttachmentsOptions, AttachmentsState } from "./attachments.js";
12
13
  export { useComments, useCommentCounts } from "./comments.js";
@@ -27,15 +28,15 @@ export { openApp, peekApp } from "./open_app.js";
27
28
  export { askAi, type AskAiArgs } from "./ask_ai.js";
28
29
  export { downloadFile } from "./download.js";
29
30
  export { renameFile } from "./rename_file.js";
30
- export { readMembers } from "./members.js";
31
- export type { ResolvedMember } from "./members.js";
32
- export { readSelect } from "./select.js";
33
- export type { ResolvedOption } from "./select.js";
31
+ export { readMembers, readSelect } from "./shared_types.js";
32
+ export type { ResolvedMember, ResolvedOption } from "./shared_types.js";
34
33
  export type { AppFixture, MockExport, MockQuery, MockQueryCall, MockWorkflow } from "./mock.js";
35
34
  export type { MockAgent, MockAgentRun } from "./mock_agent_run.js";
36
35
  export type { AppWorkflows, AppWorkflowResults, AppQueries, AppQueryColumns, AppAgents, AppAgentResults } from "./types.js";
37
- export { row, readLinks, readFiles, readLocked, readLockedBy, readCreatedAt, readUpdatedAt, PENDING } from "./row.js";
38
- export type { ResolvedLink, AppFile, PhotoPlace } from "./row.js";
36
+ export { row, readLinks } from "./shared_types.js";
37
+ export type { ResolvedLink } from "./shared_types.js";
38
+ export { readFiles, readLocked, readLockedBy, readCreatedAt, readUpdatedAt, PENDING } from "./row.js";
39
+ export type { AppFile, PhotoPlace } from "./row.js";
39
40
  export { useNewRecord, newRecordId } from "./new_record.js";
40
41
  export type { NewRecordApi } from "./new_record.js";
41
42
  export { useRecents } from "./use_recents.js";
package/dist/index.js CHANGED
@@ -10765,8 +10765,7 @@ function useAgentRuns(sessionId, opts) {
10765
10765
  // src/queries.ts
10766
10766
  import { useCallback as useCallback5, useMemo as useMemo3, useState as useState3 } from "react";
10767
10767
 
10768
- // src/row.ts
10769
- var PENDING = "__pending";
10768
+ // ../shared/src/app_screen/cells.ts
10770
10769
  function opt(v) {
10771
10770
  if (typeof v === "string") return v || null;
10772
10771
  if (Array.isArray(v)) return v.length ? opt(v[0]) : null;
@@ -10837,6 +10836,49 @@ function readLinks(v) {
10837
10836
  }
10838
10837
  return out;
10839
10838
  }
10839
+ var row = { opt, text, num, bool, date, datetime, link };
10840
+ function readSelect(value) {
10841
+ if (!Array.isArray(value)) return [];
10842
+ const out = [];
10843
+ for (const entry of value) {
10844
+ if (typeof entry === "string") {
10845
+ if (entry !== "") out.push({ key: entry, label: entry });
10846
+ continue;
10847
+ }
10848
+ if (!entry || typeof entry !== "object") continue;
10849
+ const obj = entry;
10850
+ const key = obj.key;
10851
+ if (typeof key !== "string" || key === "") continue;
10852
+ const label = typeof obj.label === "string" ? obj.label : key;
10853
+ out.push({ key, label });
10854
+ }
10855
+ return out;
10856
+ }
10857
+ function readMembers(value) {
10858
+ if (!Array.isArray(value)) return [];
10859
+ const out = [];
10860
+ for (const entry of value) {
10861
+ if (!entry || typeof entry !== "object") continue;
10862
+ const obj = entry;
10863
+ const id = obj.id;
10864
+ if (typeof id !== "string" || id === "") continue;
10865
+ const name = typeof obj.name === "string" ? obj.name : obj.name === null ? null : null;
10866
+ const m = { id, name };
10867
+ if ("email" in obj) m.email = typeof obj.email === "string" ? obj.email : null;
10868
+ if ("image" in obj) m.image = typeof obj.image === "string" ? obj.image : null;
10869
+ if ("groups" in obj) {
10870
+ m.groups = Array.isArray(obj.groups) ? obj.groups.filter((g) => typeof g === "string") : [];
10871
+ }
10872
+ if (obj.role === "owner" || obj.role === "admin" || obj.role === "member") m.role = obj.role;
10873
+ if (typeof obj.joined === "string" && obj.joined !== "") m.joined = obj.joined;
10874
+ if (obj.archived === true) m.archived = true;
10875
+ out.push(m);
10876
+ }
10877
+ return out;
10878
+ }
10879
+
10880
+ // src/row.ts
10881
+ var PENDING = "__pending";
10840
10882
  function placeOf(value) {
10841
10883
  if (typeof value !== "object" || value === null) return void 0;
10842
10884
  const latitude = Reflect.get(value, "latitude");
@@ -10880,7 +10922,7 @@ function readFiles(v) {
10880
10922
  }
10881
10923
  function readLocked(rowValue) {
10882
10924
  if (!rowValue || typeof rowValue !== "object") return false;
10883
- return bool(rowValue["__source_locked"]) === true;
10925
+ return row.bool(rowValue["__source_locked"]) === true;
10884
10926
  }
10885
10927
  function readLockedBy(rowValue) {
10886
10928
  if (!rowValue || typeof rowValue !== "object") return [];
@@ -10900,14 +10942,13 @@ function readCreatedAt(rowValue) {
10900
10942
  function readUpdatedAt(rowValue) {
10901
10943
  return rowInstant(rowValue, "__updated_at");
10902
10944
  }
10903
- var row = { opt, text, num, bool, date, datetime, link };
10904
10945
  function countsOf(rows, by) {
10905
10946
  const counts = {};
10906
10947
  for (const one of rows) {
10907
10948
  const cell = one[by];
10908
10949
  const held2 = Array.isArray(cell) ? cell : cell == null ? [] : [cell];
10909
10950
  for (const value of held2) {
10910
- const key = opt(value);
10951
+ const key = row.opt(value);
10911
10952
  if (key !== null) counts[key] = (counts[key] ?? 0) + 1;
10912
10953
  }
10913
10954
  }
@@ -14482,49 +14523,6 @@ function renameFile(file_id, filename) {
14482
14523
  return rpc("file.rename", { file_id, filename });
14483
14524
  }
14484
14525
 
14485
- // src/members.ts
14486
- function readMembers(value) {
14487
- if (!Array.isArray(value)) return [];
14488
- const out = [];
14489
- for (const entry of value) {
14490
- if (!entry || typeof entry !== "object") continue;
14491
- const obj = entry;
14492
- const id = obj.id;
14493
- if (typeof id !== "string" || id === "") continue;
14494
- const name = typeof obj.name === "string" ? obj.name : obj.name === null ? null : null;
14495
- const m = { id, name };
14496
- if ("email" in obj) m.email = typeof obj.email === "string" ? obj.email : null;
14497
- if ("image" in obj) m.image = typeof obj.image === "string" ? obj.image : null;
14498
- if ("groups" in obj) {
14499
- m.groups = Array.isArray(obj.groups) ? obj.groups.filter((g) => typeof g === "string") : [];
14500
- }
14501
- if (obj.role === "owner" || obj.role === "admin" || obj.role === "member") m.role = obj.role;
14502
- if (typeof obj.joined === "string" && obj.joined !== "") m.joined = obj.joined;
14503
- if (obj.archived === true) m.archived = true;
14504
- out.push(m);
14505
- }
14506
- return out;
14507
- }
14508
-
14509
- // src/select.ts
14510
- function readSelect(value) {
14511
- if (!Array.isArray(value)) return [];
14512
- const out = [];
14513
- for (const entry of value) {
14514
- if (typeof entry === "string") {
14515
- if (entry !== "") out.push({ key: entry, label: entry });
14516
- continue;
14517
- }
14518
- if (!entry || typeof entry !== "object") continue;
14519
- const obj = entry;
14520
- const key = obj.key;
14521
- if (typeof key !== "string" || key === "") continue;
14522
- const label = typeof obj.label === "string" ? obj.label : key;
14523
- out.push({ key, label });
14524
- }
14525
- return out;
14526
- }
14527
-
14528
14526
  // src/use_recents.ts
14529
14527
  import { useCallback as useCallback8, useEffect as useEffect5, useRef as useRef4, useState as useState4 } from "react";
14530
14528
  var PREFIX = "lotics.recents.";
package/dist/mock.d.ts CHANGED
@@ -10,7 +10,7 @@ import type { QueryAggregate } from "./shared_types.js";
10
10
  import type { WorkflowResult } from "./hooks.js";
11
11
  import type { MockAgent } from "./mock_agent_run.js";
12
12
  import type { ExportedFile } from "./shared_types.js";
13
- import type { ExportCall, QuerySortKey } from "./queries.js";
13
+ import type { ExportCall, QuerySortKey } from "./shared_types.js";
14
14
  import type { RecordingState } from "./recording_state.js";
15
15
  /** A result, or a function of the inputs — return a slow promise to review the pending state. */
16
16
  export type MockWorkflow = WorkflowResult | ((inputs: Record<string, unknown>) => WorkflowResult | Promise<WorkflowResult>);
package/dist/queries.d.ts CHANGED
@@ -1,22 +1,8 @@
1
1
  import type { QueryAggregate } from "./shared_types.js";
2
2
  import type { AppQueries, AppQueryColumns } from "./types.js";
3
- import type { ResolvedOption } from "./select.js";
4
- import type { ReportLanguage } from "./shared_types.js";
3
+ import type { ResolvedOption } from "./shared_types.js";
5
4
  import type { ExportedFile } from "./shared_types.js";
6
- import type { ReportColumn, ReportLabels, ReportReading } from "./shared_types.js";
7
- /**
8
- * One row of a query whose columns codegen could not read (a dynamic alias, a
9
- * bare `from_table`). Values stay `unknown` — the cell readers narrow them.
10
- * Only the two addressing columns are typed, because they are handed raw to a
11
- * `record_id` / `table_id`; every other `__*` column has a reader that owns it.
12
- */
13
- export interface QueryRow {
14
- [column: string]: unknown;
15
- /** The record this row came from: null on a grouped row, which stands for no one record. */
16
- __source_record_id?: string | null;
17
- /** The table that record lives in: null on a grouped row. */
18
- __source_table_id?: string | null;
19
- }
5
+ import type { ExportCall, QueryFilter, QueryRow, QuerySortKey } from "./shared_types.js";
20
6
  /**
21
7
  * The row type of alias `K`: its projected columns plus the two addressing
22
8
  * columns, and no index signature — a column the query does not carry reads
@@ -25,47 +11,6 @@ export interface QueryRow {
25
11
  export type RowOf<K extends string> = K extends keyof AppQueryColumns ? {
26
12
  [C in AppQueryColumns[K] & string]: unknown;
27
13
  } & Pick<QueryRow, "__source_record_id" | "__source_table_id"> : QueryRow;
28
- /** A column's order — applied after the named query, bounded to its projected columns. */
29
- export interface QueryFieldSortKey<C extends string = string> {
30
- field_key: C;
31
- order: "asc" | "desc";
32
- /** Where blank cells sit; `"bottom"` when omitted. */
33
- blank_position?: "top" | "bottom";
34
- }
35
- /** The rows each filter keeps, in turn, before the rest — a row with the first it meets, those meeting none last;
36
- * each part in the keys after. At most 8 filters. */
37
- export interface QueryFirstSortKey<C extends string = string> {
38
- first: QueryFilter<C>[];
39
- }
40
- /** One key of a read's order; each breaks the ties of the ones before it. */
41
- export type QuerySortKey<C extends string = string> = QueryFieldSortKey<C> | QueryFirstSortKey<C>;
42
- export interface QueryFilterFieldCondition<C extends string = string> {
43
- node_type: "condition";
44
- field_key: C;
45
- type?: string;
46
- operator: string;
47
- value?: unknown;
48
- /** A comparison on a figure read in each row's own unit or currency: the option, by key, its value is in. */
49
- unit_option?: string;
50
- }
51
- /** A condition on the row's own id — no `field_key`, since no field holds it. */
52
- export interface QueryFilterRecordIdCondition {
53
- node_type: "condition";
54
- type: "record_id";
55
- operator: string;
56
- value?: unknown;
57
- }
58
- export type QueryFilterCondition<C extends string = string> = QueryFilterFieldCondition<C> | QueryFilterRecordIdCondition;
59
- export interface QueryFilterGroup<C extends string = string> {
60
- node_type: "group";
61
- logic: "and" | "or";
62
- children: Array<QueryFilterCondition<C> | QueryFilterGroup<C>>;
63
- }
64
- /**
65
- * Runtime filter applied after the named query, bounded to its projected
66
- * columns — by `C` at compile time and again on the server.
67
- */
68
- export type QueryFilter<C extends string = string> = QueryFilterCondition<C> | QueryFilterGroup<C>;
69
14
  /** A `filter`/`sort` key on alias `K`: its projected columns, else `string`. */
70
15
  export type ColumnKeyOf<K extends string> = K extends keyof AppQueryColumns ? AppQueryColumns[K] & string : string;
71
16
  export interface QueryOptions<C extends string = string> {
@@ -201,72 +146,6 @@ export declare function queryAll(alias: string, params?: Record<string, unknown>
201
146
  filter?: QueryFilter;
202
147
  sort?: readonly QuerySortKey[];
203
148
  }): Promise<QueryRow[]>;
204
- /** What an export states of its rows beside them: the page's title, one line per thing narrowing them, and the
205
- * figures over them as the screen drew them. */
206
- export interface ExportReport {
207
- title: string;
208
- lines: string[];
209
- readings: ReportReading[];
210
- /** Each date filter narrowing the rows, by field alias: its bounds, a day or a minute of one, with no zone. */
211
- dates?: Record<string, {
212
- from?: string;
213
- to?: string;
214
- }>;
215
- /** The file's name, in the template grammar over the report; absent, the template's name, or `title`. */
216
- filename?: string;
217
- /** The period a register's tabs read their rows over: its bounds, a day or a minute of one, with no zone. */
218
- period?: {
219
- from: string;
220
- to: string;
221
- };
222
- /** The value the report was picked for (its `per`), as the reader names it. */
223
- per?: string;
224
- /** The fields of the picked row a one-link `per` names that `filename` reads as `per_row.<field>`, by field alias: a
225
- * scalar, null where the row holds none. */
226
- per_row?: Record<string, string | number | boolean | null>;
227
- }
228
- /** One tab of the register: its rows read as the export's own are — same query and params — under its own filter and order. */
229
- export interface ExportTab {
230
- tab: string;
231
- label: string;
232
- filter?: QueryFilter;
233
- sort?: readonly QuerySortKey[];
234
- /** A tab of totals over the period: the declared query `query` read again under `params` (the period's two days), its
235
- * rows joined to the tab's by the link column `via`, and the columns `columns` each one's `alias` and header. */
236
- totals?: {
237
- query: string;
238
- params: Record<string, string>;
239
- via: string;
240
- columns: {
241
- alias: string;
242
- label: string;
243
- }[];
244
- };
245
- }
246
- /** The file an export makes: the default report workbook — its words in `language`, the rows under `columns` on the
247
- * tab `sheet` — or a template the query declares under `templates`, by its name there. */
248
- export type ExportFile = {
249
- kind: "workbook";
250
- language: ReportLanguage;
251
- sheet: string;
252
- columns: ReportColumn[];
253
- } | {
254
- kind: "template";
255
- template: string;
256
- };
257
- export interface ExportCall {
258
- params?: Record<string, unknown>;
259
- filter?: QueryFilter;
260
- sort?: readonly QuerySortKey[];
261
- /** A register's tabs, each one's rows beside the call's own (the open tab's): a template reads them under each
262
- * tab's name, the workbook holds one sheet per tab. */
263
- tabs?: readonly ExportTab[];
264
- report: ExportReport;
265
- file: ExportFile;
266
- /** The words each option key of a select column prints as, by the column, in either file: a cell the server names
267
- * by its field's option prints as that. */
268
- labels?: ReportLabels;
269
- }
270
149
  /**
271
150
  * Every row a declared query matches — narrowed by `filter` and ordered by `sort` as a page of it is — made into one
272
151
  * file by the server, so no row reaches the browser. Past the most rows one export holds it is refused, never cut.
package/dist/row.d.ts CHANGED
@@ -5,40 +5,6 @@
5
5
  */
6
6
  /** The column a predicted row carries, so no surface opens a row the server has not answered for. */
7
7
  export declare const PENDING = "__pending";
8
- /** Select → first option key; `readSelect` for every option. */
9
- declare function opt(v: unknown): string | null;
10
- /** Numbers stringified; anything else non-string is "". */
11
- declare function text(v: unknown): string;
12
- /** `null` for an empty or non-finite cell — empty is not 0; write `?? 0` where it is. */
13
- declare function num(v: unknown): number | null;
14
- /**
15
- * `null` for an unanswered cell, which is not a "no". Write `=== true` where
16
- * only yes acts, `?? false` where false is the safe reading.
17
- */
18
- declare function bool(v: unknown): boolean | null;
19
- /**
20
- * The stored day at local midnight, so placement never shifts across zones. A
21
- * reduced-precision value ("2026-05") decodes to its period start.
22
- */
23
- declare function date(v: unknown): Date | null;
24
- /**
25
- * A local Date keeping the stored wall-clock time verbatim, with no UTC
26
- * conversion; a missing month/day is 1 and a missing time midnight.
27
- */
28
- declare function datetime(v: unknown): Date | null;
29
- export interface ResolvedLink {
30
- /** A `rec_…` id, to correlate or filter. */
31
- id: string;
32
- /** The primary-field value, to render. */
33
- display: string;
34
- }
35
- /** The first linked record, or null; `readLinks` for all. */
36
- declare function link(v: unknown): ResolvedLink | null;
37
- /**
38
- * Every linked record. A lookup of a link arrives one level deeper (one link
39
- * cell per linked row); it is flattened here, in order, each id once.
40
- */
41
- export declare function readLinks(v: unknown): ResolvedLink[];
42
8
  /** A files cell entry; `url`/`thumbnail_url` are presigned (24h) and load from the sandboxed frame. */
43
9
  export interface AppFile {
44
10
  id: string;
@@ -83,15 +49,6 @@ export declare function readLockedBy(rowValue: unknown): string[];
83
49
  export declare function readCreatedAt(rowValue: unknown): Date | null;
84
50
  /** `__updated_at`, as {@link readCreatedAt}. */
85
51
  export declare function readUpdatedAt(rowValue: unknown): Date | null;
86
- export declare const row: {
87
- opt: typeof opt;
88
- text: typeof text;
89
- num: typeof num;
90
- bool: typeof bool;
91
- date: typeof date;
92
- datetime: typeof datetime;
93
- link: typeof link;
94
- };
95
52
  /**
96
53
  * Rows counted per value of one column — what the query RPC's `count_by`
97
54
  * answers, over rows already in hand. A cell holding several values (a
@@ -99,4 +56,3 @@ export declare const row: {
99
56
  * same rows a `has_any_of` on each value keeps.
100
57
  */
101
58
  export declare function countsOf(rows: ReadonlyArray<Record<string, unknown>>, by: string): Record<string, number>;
102
- export {};