@lotics/app-sdk 0.133.49 → 0.134.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.
package/AGENTS.md CHANGED
@@ -16,7 +16,7 @@ This file is the index. The **exact type** of anything is its shipped declaratio
16
16
  |---|---|
17
17
  | [docs/data_fetching.md](./docs/data_fetching.md) | The reads: `useQuery(alias, params, opts)` — its rows (`limit`), numbered pages (`page`), a keyset feed (`more`), its `total` or the total alone, only the columns it draws (`fields`), a push re-reading only the records it changed (`refresh: "changed"`), with `total: { by }` a count per value of one column and `total: { where }` a count per named filter, from one scan — `useQueries` for reads known only at render, `queryAll` outside React, `exportQuery` for a file of them the server makes, `exportApp` for the workbook of a JSON app's List; every hook answers one `QueryState`. The ROW type (`RowOf` — the alias's projected columns and nothing else), runtime `sort`/`filter` keys, cell readers (`row.*`, `readSelect`, `readMembers`, `readLinks`, `readFiles`, `readLocked`/`readLockedBy`, `readCreatedAt`/`readUpdatedAt`), the SDK's own cache — **arrival revalidates** — **realtime push** and `answeredAt` (the server answering again what a screen drew), a write drawn on every read from the press, a count as its own full scan, and the search-as-you-type and record-picker patterns. |
18
18
  | [docs/queries.md](./docs/queries.md) | **The query engine reference** — AST node kinds, per-field-type operators, filters/params/pruning, free-text search, combining tables, shaping (aggregates, date buckets, windows), runtime refinement bounds, limits and the efficiency playbook. |
19
- | [docs/mutations.md](./docs/mutations.md) | `useWorkflow` (the ONLY write path; `useWorkflows` for writes that are data), the `WorkflowResult` resolve-never-throw contract (`field_errors`), typed inputs, every write drawn on every read from the press — predicted from the workflow's own steps, taken back on a refusal, `pending` meanwhile — the re-read a successful write triggers over the tables its body names, diff-before-update, locked records, `useNewRecord`, read-after-write ordering (`writesSettled()`), `useRecording`, `useRecordings` over several aliases. |
19
+ | [docs/mutations.md](./docs/mutations.md) | `useWorkflow` (the ONLY write path; `useWorkflows` for writes that are data), the `WorkflowResult` resolve-never-throw contract (`field_errors`), typed inputs, every write drawn on every read from the press — predicted from the workflow's own steps, taken back on a refusal, `pending` meanwhile — the re-read a successful write triggers over the tables its body names, diff-before-update, locked records, `useNewRecord`, read-after-write ordering (`writesSettled()`). |
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. |
@@ -1438,78 +1438,6 @@ async function runUploadPipeline(file, rpc2, options = {}) {
1438
1438
  return uploaded;
1439
1439
  }
1440
1440
 
1441
- // src/recording_state.ts
1442
- var IDLE_RECORDING = { phase: "idle" };
1443
- var states = /* @__PURE__ */ new Map();
1444
- var listeners = /* @__PURE__ */ new Set();
1445
- var version = 0;
1446
- function emit() {
1447
- version += 1;
1448
- for (const listener of listeners) listener();
1449
- }
1450
- function recordingsVersion() {
1451
- return version;
1452
- }
1453
- function subscribeRecordings(listener) {
1454
- listeners.add(listener);
1455
- return () => {
1456
- listeners.delete(listener);
1457
- };
1458
- }
1459
- function recordingStateOf(alias) {
1460
- return states.get(alias) ?? IDLE_RECORDING;
1461
- }
1462
- function anyRecordingLive() {
1463
- for (const state of states.values()) if (state.phase === "live") return true;
1464
- return false;
1465
- }
1466
- function applyRecordingChange(alias, state) {
1467
- if (state.phase === "idle") states.delete(alias);
1468
- else states.set(alias, state);
1469
- emit();
1470
- }
1471
- function replaceRecordings(snapshot) {
1472
- states.clear();
1473
- for (const [alias, state] of Object.entries(snapshot)) {
1474
- if (state.phase !== "idle") states.set(alias, state);
1475
- }
1476
- emit();
1477
- }
1478
- function isRecord(value) {
1479
- return value !== null && typeof value === "object" && !Array.isArray(value);
1480
- }
1481
- function readRecordingState(raw) {
1482
- if (!isRecord(raw)) return null;
1483
- if (raw.phase === "idle") return IDLE_RECORDING;
1484
- const inputs = raw.inputs;
1485
- if (!isRecord(inputs)) return null;
1486
- switch (raw.phase) {
1487
- case "live":
1488
- case "interrupted":
1489
- return typeof raw.elapsed_seconds === "number" ? { phase: raw.phase, elapsed_seconds: raw.elapsed_seconds, inputs } : null;
1490
- case "processing":
1491
- return { phase: "processing", inputs };
1492
- case "filed":
1493
- return typeof raw.execution_id === "string" ? { phase: "filed", execution_id: raw.execution_id, inputs } : null;
1494
- case "failed":
1495
- return typeof raw.message === "string" ? { phase: "failed", message: raw.message, inputs } : null;
1496
- default:
1497
- return null;
1498
- }
1499
- }
1500
- function readRecordingSnapshot(raw) {
1501
- if (!isRecord(raw)) return {};
1502
- const entries = Object.entries(raw).flatMap(([alias, value]) => {
1503
- const state = readRecordingState(value);
1504
- if (state === null) {
1505
- console.error(`The host's context carried a malformed recording for "${alias}"; it reads as idle.`, value);
1506
- return [];
1507
- }
1508
- return [[alias, state]];
1509
- });
1510
- return Object.fromEntries(entries);
1511
- }
1512
-
1513
1441
  // src/rpc.ts
1514
1442
  var hostOriginCache;
1515
1443
  function getHostOrigin() {
@@ -1602,12 +1530,6 @@ function subscribeQueriesChanged(cb) {
1602
1530
  refetchSubscribers.delete(cb);
1603
1531
  };
1604
1532
  }
1605
- var mountedAliases = /* @__PURE__ */ new Map();
1606
- function notifyLocalWrite(reads) {
1607
- const aliases = reads === void 0 ? [...mountedAliases.keys()] : [...reads];
1608
- if (aliases.length === 0) return;
1609
- queriesChanged(aliases);
1610
- }
1611
1533
  function queriesChanged(aliases, changes) {
1612
1534
  for (const cb of refetchSubscribers) cb([...aliases], changes);
1613
1535
  }
@@ -1655,18 +1577,6 @@ function ensureListener() {
1655
1577
  );
1656
1578
  return;
1657
1579
  }
1658
- if (msg.type === "recordingChanged") {
1659
- const state = readRecordingState(msg.state);
1660
- if (typeof msg.alias !== "string" || state === null) {
1661
- console.error("The host sent a malformed recordingChanged push; it is ignored.", msg);
1662
- return;
1663
- }
1664
- const before = recordingStateOf(msg.alias);
1665
- applyRecordingChange(msg.alias, state);
1666
- const newlyFiled = state.phase === "filed" && !(before.phase === "filed" && before.execution_id === state.execution_id);
1667
- if (newlyFiled) notifyLocalWrite();
1668
- return;
1669
- }
1670
1580
  if (typeof msg.id !== "number") return;
1671
1581
  const handler = pending.get(msg.id);
1672
1582
  if (handler) {
@@ -2129,11 +2039,6 @@ function rpcStandalone(op, payload) {
2129
2039
  case "comments.delete":
2130
2040
  case "comments.counts":
2131
2041
  return rejectCommentsStandalone();
2132
- case "recording.start":
2133
- case "recording.stop":
2134
- return Promise.reject(
2135
- new Error("Recording needs the Lotics host and a signed-in member. Gate the control on useRecording's `available`.")
2136
- );
2137
2042
  case "outsideLink.list":
2138
2043
  case "outsideLink.create":
2139
2044
  case "outsideLink.revoke":
@@ -2200,8 +2105,7 @@ async function standaloneContext() {
2200
2105
  comments_enabled: info.comments_enabled,
2201
2106
  timezone: info.timezone,
2202
2107
  language: info.language,
2203
- default_currency: info.default_currency,
2204
- recording_enabled: false
2108
+ default_currency: info.default_currency
2205
2109
  };
2206
2110
  }
2207
2111
  async function standalonePredictionMiss(payload) {
@@ -2358,12 +2262,6 @@ export {
2358
2262
  IMAGE_FIDELITIES,
2359
2263
  DEFAULT_IMAGE_FIDELITY,
2360
2264
  preparedForUpload,
2361
- recordingsVersion,
2362
- subscribeRecordings,
2363
- recordingStateOf,
2364
- anyRecordingLive,
2365
- replaceRecordings,
2366
- readRecordingSnapshot,
2367
2265
  urlParam,
2368
2266
  decodeAll,
2369
2267
  encodePatch,
package/dist/index.d.ts CHANGED
@@ -17,9 +17,6 @@ export { askAppContext, useAppContext, useViewer, useWorkspaceCurrency, useWorks
17
17
  export type { AppAbsence } from "./shared_types.js";
18
18
  export { useOutsideLinks } from "./outside_link.js";
19
19
  export type { OutsideLinksState } from "./outside_link.js";
20
- export { useRecording, useRecordings } from "./recording.js";
21
- export type { UseRecording, UseRecordings } from "./recording.js";
22
- export type { RecordingState, RecordingInputs } from "./recording_state.js";
23
20
  export { requestGeofencedLocation, isWithinZone } from "./geolocation.js";
24
21
  export type { GeofenceZone, GeoCoords, GeofenceOutcome, GeofenceOptions } from "./geolocation.js";
25
22
  export { rpc, hostSpec, holdDrawn, isEmbedded, installPageHost, openRequested, subscribeOpen, queriesChanged, ApiRefusal, PageHostRefusal } from "./rpc.js";
package/dist/index.js CHANGED
@@ -10,7 +10,6 @@ import {
10
10
  __export,
11
11
  addDecimal,
12
12
  aggregateRows,
13
- anyRecordingLive,
14
13
  applyPatch,
15
14
  bandKey,
16
15
  bandOf,
@@ -44,11 +43,7 @@ import {
44
43
  powerDecimal,
45
44
  preparedForUpload,
46
45
  queriesChanged,
47
- readRecordingSnapshot,
48
- recordingStateOf,
49
- recordingsVersion,
50
46
  releaseAllHolds,
51
- replaceRecordings,
52
47
  roundDecimal,
53
48
  rpc,
54
49
  rpcAgentRun,
@@ -57,12 +52,11 @@ import {
57
52
  setUrlParams,
58
53
  subscribeOpen,
59
54
  subscribeQueriesChanged,
60
- subscribeRecordings,
61
55
  subscribeUrlParams,
62
56
  subtractDecimal,
63
57
  sumDecimal,
64
58
  urlParam
65
- } from "./chunk-NS3BIL73.js";
59
+ } from "./chunk-FE5YWUAG.js";
66
60
 
67
61
  // src/mount.tsx
68
62
  import { createRoot } from "react-dom/client";
@@ -115,10 +109,6 @@ function getMockExportApp(list2) {
115
109
  if (!isMockMode()) return null;
116
110
  return registeredFixture?.exportApps?.[list2] ?? null;
117
111
  }
118
- function getMockRecordings() {
119
- if (!isMockMode()) return null;
120
- return registeredFixture?.recordings ?? null;
121
- }
122
112
 
123
113
  // ../shared/src/app_host/app_spec_inline.ts
124
114
  var APP_SPEC_ELEMENT_ID = "lotics-app-spec";
@@ -11144,7 +11134,6 @@ var APP_CONTEXT_KEY = "app-context";
11144
11134
  async function readContext() {
11145
11135
  try {
11146
11136
  const context = await rpc("context", {});
11147
- replaceRecordings(readRecordingSnapshot(context.recordings));
11148
11137
  return context;
11149
11138
  } catch (cause) {
11150
11139
  console.error("The app's context could not be read from its host", cause);
@@ -11163,7 +11152,6 @@ function useAppContext() {
11163
11152
  admin: data?.admin === true,
11164
11153
  absences: data?.absences ?? null,
11165
11154
  commentsEnabled: data?.comments_enabled ?? false,
11166
- recordingEnabled: data?.recording_enabled === true,
11167
11155
  timezone: data?.timezone,
11168
11156
  language: data?.language,
11169
11157
  currency: data?.default_currency,
@@ -15767,56 +15755,6 @@ function useOutsideLinks(record_id) {
15767
15755
  };
15768
15756
  }
15769
15757
 
15770
- // src/recording.ts
15771
- import { useCallback as useCallback7, useMemo as useMemo4, useSyncExternalStore as useSyncExternalStore3 } from "react";
15772
- var NO_MOCKS = {};
15773
- async function startRecording(alias, inputs) {
15774
- if (getMockRecordings()?.[alias]) return { started: true };
15775
- return rpc("recording.start", { alias, inputs });
15776
- }
15777
- async function stopRecording(alias) {
15778
- if (getMockRecordings()?.[alias]) return;
15779
- await rpc("recording.stop", { alias });
15780
- }
15781
- function busyWith(mocks, hostBusy) {
15782
- return hostBusy || Object.values(mocks).some((state) => state.phase === "live");
15783
- }
15784
- function useRecording(alias) {
15785
- const { recordingEnabled } = useAppContext();
15786
- const mocks = getMockRecordings() ?? NO_MOCKS;
15787
- const mocked = mocks[alias];
15788
- const hostState = useSyncExternalStore3(subscribeRecordings, () => recordingStateOf(alias));
15789
- const hostBusy = useSyncExternalStore3(subscribeRecordings, anyRecordingLive);
15790
- const start = useCallback7((inputs) => startRecording(alias, inputs ?? {}), [alias]);
15791
- const stop = useCallback7(() => stopRecording(alias), [alias]);
15792
- return {
15793
- available: mocked !== void 0 || recordingEnabled,
15794
- state: mocked ?? hostState,
15795
- busy: busyWith(mocks, hostBusy),
15796
- start,
15797
- stop
15798
- };
15799
- }
15800
- function useRecordings(aliases) {
15801
- const { recordingEnabled } = useAppContext();
15802
- const mocks = getMockRecordings() ?? NO_MOCKS;
15803
- const version2 = useSyncExternalStore3(subscribeRecordings, recordingsVersion);
15804
- const hostBusy = useSyncExternalStore3(subscribeRecordings, anyRecordingLive);
15805
- const key = aliases.join("\n");
15806
- const states = useMemo4(
15807
- () => Object.fromEntries(key.split("\n").filter((alias) => alias !== "").map((alias) => [alias, mocks[alias] ?? recordingStateOf(alias)])),
15808
- // eslint-disable-next-line react-hooks/exhaustive-deps
15809
- [key, version2, mocks]
15810
- );
15811
- return {
15812
- available: recordingEnabled || aliases.some((alias) => mocks[alias] !== void 0),
15813
- states,
15814
- busy: busyWith(mocks, hostBusy),
15815
- start: startRecording,
15816
- stop: stopRecording
15817
- };
15818
- }
15819
-
15820
15758
  // src/geolocation.ts
15821
15759
  function isWithinZone(latitude, longitude, zone) {
15822
15760
  const [centerLat, centerLon] = zone.coordinates;
@@ -15912,7 +15850,7 @@ function renameFile(file_id, filename) {
15912
15850
  }
15913
15851
 
15914
15852
  // src/use_recents.ts
15915
- import { useCallback as useCallback8, useEffect as useEffect5, useRef as useRef4, useState as useState4 } from "react";
15853
+ import { useCallback as useCallback7, useEffect as useEffect5, useRef as useRef4, useState as useState4 } from "react";
15916
15854
  var PREFIX = "lotics.recents.";
15917
15855
  function read(storageKey) {
15918
15856
  try {
@@ -15940,7 +15878,7 @@ function useRecents(key, options = {}) {
15940
15878
  useEffect5(() => {
15941
15879
  setRecents(read(storageKey).slice(0, maxRef.current));
15942
15880
  }, [storageKey]);
15943
- const remember = useCallback8(
15881
+ const remember = useCallback7(
15944
15882
  (item) => {
15945
15883
  setRecents((prev) => {
15946
15884
  const k = keyOfRef.current(item);
@@ -15951,7 +15889,7 @@ function useRecents(key, options = {}) {
15951
15889
  },
15952
15890
  [storageKey]
15953
15891
  );
15954
- const forget = useCallback8(
15892
+ const forget = useCallback7(
15955
15893
  (item) => {
15956
15894
  setRecents((prev) => {
15957
15895
  const k = keyOfRef.current(item);
@@ -15962,7 +15900,7 @@ function useRecents(key, options = {}) {
15962
15900
  },
15963
15901
  [storageKey]
15964
15902
  );
15965
- const clear = useCallback8(() => {
15903
+ const clear = useCallback7(() => {
15966
15904
  write(storageKey, []);
15967
15905
  setRecents([]);
15968
15906
  }, [storageKey]);
@@ -15970,7 +15908,7 @@ function useRecents(key, options = {}) {
15970
15908
  }
15971
15909
 
15972
15910
  // src/use_url_state.ts
15973
- import { useCallback as useCallback9, useEffect as useEffect6, useMemo as useMemo5, useRef as useRef5, useState as useState5 } from "react";
15911
+ import { useCallback as useCallback8, useEffect as useEffect6, useMemo as useMemo4, useRef as useRef5, useState as useState5 } from "react";
15974
15912
  function useUrlState(defs) {
15975
15913
  const defsRef = useRef5(defs);
15976
15914
  defsRef.current = defs;
@@ -15990,8 +15928,8 @@ function useUrlState(defs) {
15990
15928
  unsubscribe();
15991
15929
  };
15992
15930
  }, []);
15993
- const values2 = useMemo5(() => decodeAll(defsRef.current, params), [params]);
15994
- const setValues = useCallback9(
15931
+ const values2 = useMemo4(() => decodeAll(defsRef.current, params), [params]);
15932
+ const setValues = useCallback8(
15995
15933
  (patch) => {
15996
15934
  editedRef.current = true;
15997
15935
  const encoded = encodePatch(defsRef.current, patch);
@@ -16006,7 +15944,7 @@ function useUrlState(defs) {
16006
15944
  }
16007
15945
 
16008
15946
  // src/folder_pick.ts
16009
- import { useCallback as useCallback10 } from "react";
15947
+ import { useCallback as useCallback9 } from "react";
16010
15948
  function useFolderPick(table) {
16011
15949
  const key = JSON.stringify(["folder-pick", table]);
16012
15950
  const { data, error } = useKey(
@@ -16020,7 +15958,7 @@ function useFolderPick(table) {
16020
15958
  ),
16021
15959
  { focus: false, arrival: false }
16022
15960
  );
16023
- const pick2 = useCallback10(
15961
+ const pick2 = useCallback9(
16024
15962
  (id) => {
16025
15963
  setKey(key, id);
16026
15964
  rpc("folder.set", { table_id: table, record_id: id }).catch(
@@ -16089,8 +16027,6 @@ export {
16089
16027
  useQueries,
16090
16028
  useQuery,
16091
16029
  useRecents,
16092
- useRecording,
16093
- useRecordings,
16094
16030
  useUrlState,
16095
16031
  useViewer,
16096
16032
  useWorkflow,
package/dist/mock.d.ts CHANGED
@@ -12,7 +12,6 @@ import type { MockAgent } from "./mock_agent_run.js";
12
12
  import type { ExportedFile } from "./shared_types.js";
13
13
  import type { ExportNarrowing } from "./shared_types.js";
14
14
  import type { ExportCall, QuerySortKey } from "./shared_types.js";
15
- import type { RecordingState } from "./recording_state.js";
16
15
  /** A result, or a function of the inputs — return a slow promise to review the pending state. */
17
16
  export type MockWorkflow = WorkflowResult | ((inputs: Record<string, unknown>) => WorkflowResult | Promise<WorkflowResult>);
18
17
  export interface MockQueryCall {
@@ -41,8 +40,6 @@ export interface AppFixture {
41
40
  exports?: Record<string, MockExport>;
42
41
  /** By the View id of the List exported. */
43
42
  exportApps?: Record<string, MockExportApp>;
44
- /** `useRecording(alias)` reads as available; `start`/`stop` change nothing. */
45
- recordings?: Record<string, RecordingState>;
46
43
  /** How long a played agent run waits before each line it streams; a real run's pace when unset. */
47
44
  agentBeatMs?: number;
48
45
  }
@@ -61,4 +58,3 @@ export declare function getMockAgentBeat(): number | undefined;
61
58
  export declare function getMockExport(alias: string): MockExport | null;
62
59
  /** Null for an unmocked List, which the server exports. */
63
60
  export declare function getMockExportApp(list: string): MockExportApp | null;
64
- export declare function getMockRecordings(): Record<string, RecordingState> | null;
package/dist/router.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  setUrlParams,
7
7
  settleOpen,
8
8
  subscribeOpen
9
- } from "./chunk-NS3BIL73.js";
9
+ } from "./chunk-FE5YWUAG.js";
10
10
 
11
11
  // src/router.tsx
12
12
  import { useEffect, useLayoutEffect, useRef } from "react";
package/dist/rpc.d.ts CHANGED
@@ -14,7 +14,7 @@ import { type UrlParams, type UrlParamsPatch } from "./url_params.js";
14
14
  * cover is answered and none was sent for two frames: the app's first screen has its data
15
15
  * host → app: { id, type: "result", data } | { id, type: "error", message }
16
16
  */
17
- 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
+ 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" | "outsideLink.list" | "outsideLink.create" | "outsideLink.revoke";
18
18
  export interface AgentRunPayload {
19
19
  alias: string;
20
20
  session_id: string;
@@ -87,11 +87,6 @@ export interface AppContext {
87
87
  /** The ISO 4217 code uncoded money is counted in; absent from an older host,
88
88
  * which refuses such money rather than guess a currency. */
89
89
  default_currency?: string;
90
- /** True only from a host with `recording.*`, for a signed-in member, on an
91
- * instance that transcribes; absent reads as false. */
92
- recording_enabled?: boolean;
93
- /** This app's recordings the host still tracks, by alias. */
94
- recordings?: Record<string, unknown>;
95
90
  /** Who in the organization is away, or will be, and who stands in — absent from an older host and for a visitor from
96
91
  * outside the organization. */
97
92
  absences?: AppAbsence[];