@lotics/app-sdk 0.23.0 → 0.24.0

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.
@@ -27,8 +27,8 @@ export { readSelect } from "./select.js";
27
27
  export type { ResolvedOption } from "./select.js";
28
28
  export type { AppFixture } from "./mock.js";
29
29
  export type { AppWorkflows, AppQueries } from "./types.js";
30
- export { row, readLinks } from "./row.js";
31
- export type { ResolvedLink } from "./row.js";
30
+ export { row, readLinks, readFiles } from "./row.js";
31
+ export type { ResolvedLink, AppFile } from "./row.js";
32
32
  export { useOptimistic } from "./use_optimistic.js";
33
33
  export type { OptimisticApi } from "./use_optimistic.js";
34
34
  export { useRecents } from "./use_recents.js";
package/dist/src/index.js CHANGED
@@ -20,6 +20,6 @@ export { rpc } from "./rpc.js";
20
20
  export { openExternal } from "./open_external.js";
21
21
  export { readMembers } from "./members.js";
22
22
  export { readSelect } from "./select.js";
23
- export { row, readLinks } from "./row.js";
23
+ export { row, readLinks, readFiles } from "./row.js";
24
24
  export { useOptimistic } from "./use_optimistic.js";
25
25
  export { useRecents } from "./use_recents.js";
package/dist/src/row.d.ts CHANGED
@@ -44,6 +44,27 @@ export interface ResolvedLink {
44
44
  declare function link(v: unknown): ResolvedLink | null;
45
45
  /** select_record_link → ALL linked records as `{ id, display }[]` (empty if none). */
46
46
  export declare function readLinks(v: unknown): ResolvedLink[];
47
+ /**
48
+ * A `files`-field cell entry, as the app query serializes it. The server
49
+ * presigns each file (24h) so `url`/`thumbnail_url` load directly — including
50
+ * from the sandboxed app iframe and for public apps — so the app can preview or
51
+ * download without deriving its own URL.
52
+ */
53
+ export interface AppFile {
54
+ id: string;
55
+ filename: string;
56
+ mime_type: string;
57
+ /** Presigned serving URL — render in an <Image>/preview or pass to openExternal. */
58
+ url: string;
59
+ /** Presigned thumbnail URL for images, when the server produced one. */
60
+ thumbnail_url?: string;
61
+ }
62
+ /**
63
+ * files field → the attached files with their presigned `url` (empty if none).
64
+ * Skips entries the server didn't presign (no `url`) so a consumer never renders
65
+ * an unservable file. Map to `@lotics/ui` `DisplayFile` for FileThumbnail/Gallery.
66
+ */
67
+ export declare function readFiles(v: unknown): AppFile[];
47
68
  export declare const row: {
48
69
  opt: typeof opt;
49
70
  text: typeof text;
package/dist/src/row.js CHANGED
@@ -89,4 +89,33 @@ export function readLinks(v) {
89
89
  }
90
90
  return v.map(asLink).filter((x) => x !== null);
91
91
  }
92
+ /**
93
+ * files field → the attached files with their presigned `url` (empty if none).
94
+ * Skips entries the server didn't presign (no `url`) so a consumer never renders
95
+ * an unservable file. Map to `@lotics/ui` `DisplayFile` for FileThumbnail/Gallery.
96
+ */
97
+ export function readFiles(v) {
98
+ if (!Array.isArray(v))
99
+ return [];
100
+ const out = [];
101
+ for (const f of v) {
102
+ if (!f || typeof f !== "object")
103
+ continue;
104
+ const id = f.id;
105
+ const url = f.url;
106
+ if (typeof id !== "string" || !id || typeof url !== "string" || !url)
107
+ continue;
108
+ const filename = f.filename;
109
+ const mime = f.mime_type;
110
+ const thumb = f.thumbnail_url;
111
+ out.push({
112
+ id,
113
+ filename: typeof filename === "string" ? filename : "",
114
+ mime_type: typeof mime === "string" ? mime : "",
115
+ url,
116
+ thumbnail_url: typeof thumb === "string" ? thumb : undefined,
117
+ });
118
+ }
119
+ return out;
120
+ }
92
121
  export const row = { opt, text, num, bool, date, link };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Runtime SDK for Lotics custom-code apps — typed hooks, postMessage bridge, mount entry point",
5
5
  "type": "module",
6
6
  "exports": {