@rebasepro/server 0.29.2 → 0.29.3

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.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * EXPERIMENTAL. Apps saved to the project: the TSX a show_app call ran, kept
3
+ * in `rebase.saved_apps` so it opens again — in the conversation
4
+ * (`open_app`), in the admin panel, or as a Claude artifact — for whoever it
5
+ * was saved for.
6
+ *
7
+ * Who sees one is its `visibility`: `personal` (its owner), `roles` (anyone
8
+ * holding one of its `roles`), or `team` (everyone who signs in). Saving for
9
+ * more than oneself takes the admin role, because a shared app is code an AI
10
+ * wrote, running for other people. Seeing an app is not reaching its data:
11
+ * an app reads and writes only through the data tools, as whoever opens it,
12
+ * under their RLS.
13
+ *
14
+ * The table is not a collection and carries no RLS, so no end user is granted
15
+ * anything on it; every read and write here filters by the viewer itself.
16
+ *
17
+ * @module
18
+ */
19
+ import type { DataDriver } from "@rebasepro/types";
20
+ import { type SqlExec } from "../boot/ddl-bootstrap.js";
21
+ export type AppVisibility = "personal" | "roles" | "team";
22
+ export declare const APP_VISIBILITIES: readonly AppVisibility[];
23
+ export interface SavedAppSummary {
24
+ id: string;
25
+ title: string;
26
+ collections: string[];
27
+ visibility: AppVisibility;
28
+ roles: string[];
29
+ ownerId: string;
30
+ updatedAt: string;
31
+ }
32
+ export interface SavedApp extends SavedAppSummary {
33
+ code: string;
34
+ createdAt: string;
35
+ }
36
+ /** Who is asking: whose personal apps, which roles' apps, and whether they may share. */
37
+ export interface AppViewer {
38
+ uid: string;
39
+ roles: readonly string[];
40
+ }
41
+ export interface SaveAppInput {
42
+ /** The app to replace, by its owner (or an admin); a new app without it. */
43
+ id?: string;
44
+ title: string;
45
+ code: string;
46
+ collections: string[];
47
+ visibility: AppVisibility;
48
+ /** For `roles`: who sees it. */
49
+ roles?: string[];
50
+ }
51
+ /** A request the store refuses, with a reason the caller can show. */
52
+ export declare class SavedAppError extends Error {
53
+ }
54
+ export interface SavedAppStore {
55
+ list(viewer: AppViewer): Promise<SavedAppSummary[]>;
56
+ get(id: string, viewer: AppViewer): Promise<SavedApp | undefined>;
57
+ save(input: SaveAppInput, viewer: AppViewer): Promise<SavedApp>;
58
+ remove(id: string, viewer: AppViewer): Promise<boolean>;
59
+ }
60
+ /** The most apps one person keeps: saved apps are a place to keep work, not storage. */
61
+ export declare const MAX_APPS_PER_OWNER = 200;
62
+ /** The longest app one person saves, in characters: any signed-in user may save, so the store is bounded per app too. */
63
+ export declare const MAX_APP_CODE_LENGTH = 256000;
64
+ /**
65
+ * The store on `driver`'s database, made once per driver; `undefined` on a
66
+ * driver with no SQL (saved apps need a table).
67
+ */
68
+ export declare function savedAppStore(driver: DataDriver): SavedAppStore | undefined;
69
+ export declare function createSavedAppStore(exec: SqlExec): SavedAppStore;