@book.dev/sdk 1.60.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.
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/dist/account.d.ts +57 -0
- package/dist/account.js +104 -0
- package/dist/account.js.map +1 -0
- package/dist/ai.d.ts +264 -0
- package/dist/ai.js +36 -0
- package/dist/ai.js.map +1 -0
- package/dist/backup.d.ts +52 -0
- package/dist/backup.js +35 -0
- package/dist/backup.js.map +1 -0
- package/dist/bookFolder.d.ts +44 -0
- package/dist/bookFolder.js +98 -0
- package/dist/bookFolder.js.map +1 -0
- package/dist/bookfile.d.ts +42 -0
- package/dist/bookfile.js +159 -0
- package/dist/bookfile.js.map +1 -0
- package/dist/client.d.ts +279 -0
- package/dist/client.js +502 -0
- package/dist/client.js.map +1 -0
- package/dist/connection.d.ts +20 -0
- package/dist/connection.js +77 -0
- package/dist/connection.js.map +1 -0
- package/dist/content.d.ts +38 -0
- package/dist/content.js +107 -0
- package/dist/content.js.map +1 -0
- package/dist/database.d.ts +687 -0
- package/dist/database.js +1082 -0
- package/dist/database.js.map +1 -0
- package/dist/formula.d.ts +41 -0
- package/dist/formula.js +469 -0
- package/dist/formula.js.map +1 -0
- package/dist/forwarding/challenge.d.ts +35 -0
- package/dist/forwarding/challenge.js +45 -0
- package/dist/forwarding/challenge.js.map +1 -0
- package/dist/forwarding/encoding.d.ts +14 -0
- package/dist/forwarding/encoding.js +54 -0
- package/dist/forwarding/encoding.js.map +1 -0
- package/dist/forwarding/forwardingClient.d.ts +76 -0
- package/dist/forwarding/forwardingClient.js +128 -0
- package/dist/forwarding/forwardingClient.js.map +1 -0
- package/dist/forwarding/index.d.ts +5 -0
- package/dist/forwarding/index.js +14 -0
- package/dist/forwarding/index.js.map +1 -0
- package/dist/forwarding/siteKey.d.ts +12 -0
- package/dist/forwarding/siteKey.js +36 -0
- package/dist/forwarding/siteKey.js.map +1 -0
- package/dist/forwarding/tunnelClient.d.ts +56 -0
- package/dist/forwarding/tunnelClient.js +206 -0
- package/dist/forwarding/tunnelClient.js.map +1 -0
- package/dist/forwarding/tunnelProtocol.d.ts +45 -0
- package/dist/forwarding/tunnelProtocol.js +29 -0
- package/dist/forwarding/tunnelProtocol.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/mtime.d.ts +51 -0
- package/dist/mtime.js +84 -0
- package/dist/mtime.js.map +1 -0
- package/dist/pageProperties.d.ts +80 -0
- package/dist/pageProperties.js +97 -0
- package/dist/pageProperties.js.map +1 -0
- package/dist/plugins.d.ts +110 -0
- package/dist/plugins.js +113 -0
- package/dist/plugins.js.map +1 -0
- package/dist/routes.d.ts +89 -0
- package/dist/routes.js +89 -0
- package/dist/routes.js.map +1 -0
- package/dist/sampleDocument.d.ts +25 -0
- package/dist/sampleDocument.js +67 -0
- package/dist/sampleDocument.js.map +1 -0
- package/dist/suggestions.d.ts +126 -0
- package/dist/suggestions.js +21 -0
- package/dist/suggestions.js.map +1 -0
- package/dist/templates.d.ts +35 -0
- package/dist/templates.js +555 -0
- package/dist/templates.js.map +1 -0
- package/dist/types.d.ts +146 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/package.json +33 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenBook domain types — the single source of truth shared by the server, the
|
|
3
|
+
* desktop app, and the web shell. Because every layer imports these same
|
|
4
|
+
* definitions, page data cannot drift between client and server.
|
|
5
|
+
*
|
|
6
|
+
* A **page** is the unit of storage: a stable UUID, an optional unique name, and
|
|
7
|
+
* an opaque document payload ({@link PageSnapshot}). The storage layer treats
|
|
8
|
+
* `data` as opaque JSON; its internal shape is owned by the document editor.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The serialized form of a reactive document. Three sibling keys:
|
|
12
|
+
* - `editorjs` — EditorJS `OutputData` (kept opaque here so the SDK has no
|
|
13
|
+
* dependency on the editor; cast at the edit site).
|
|
14
|
+
* - `values` — `[cellId, value]` pairs from the reactive store.
|
|
15
|
+
* - `names` — `[name, cellId]` pairs (the name index).
|
|
16
|
+
*/
|
|
17
|
+
export interface PageSnapshot {
|
|
18
|
+
editorjs: unknown;
|
|
19
|
+
values: Array<[string, unknown]>;
|
|
20
|
+
names: Array<[string, string]>;
|
|
21
|
+
/** Which editor owns this document ('blocks' = the CRDT block editor). */
|
|
22
|
+
editor?: string;
|
|
23
|
+
/** CRDT block-editor document (opaque here; shaped by the ui package). */
|
|
24
|
+
blockdoc?: unknown;
|
|
25
|
+
/**
|
|
26
|
+
* `[blockId, ISO mtime]` pairs — when each top-level block last changed. The
|
|
27
|
+
* server stamps these on write (see sdk `stampSnapshotMtimes`): a block whose
|
|
28
|
+
* content is unchanged keeps its old timestamp, a changed/new one is restamped
|
|
29
|
+
* `now`. This is the per-block change signal the on-disk book mirror, the
|
|
30
|
+
* external-change watcher, and conflict detection all read; absent on pages
|
|
31
|
+
* written before the feature shipped (treated as "unknown — assume changed").
|
|
32
|
+
*/
|
|
33
|
+
mtimes?: Array<[string, string]>;
|
|
34
|
+
}
|
|
35
|
+
/** An empty snapshot, for initializing a brand-new page. */
|
|
36
|
+
export declare const emptyPageSnapshot: () => PageSnapshot;
|
|
37
|
+
/** Lightweight page record for listings (no `data` payload). */
|
|
38
|
+
export interface PageMeta {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string | null;
|
|
41
|
+
/** The page's emoji icon, or `null` when none is set — projected from
|
|
42
|
+
* `page.properties` so lists (sidebar, tabs, mentions) resolve it directly,
|
|
43
|
+
* without a per-page fetch. */
|
|
44
|
+
icon: string | null;
|
|
45
|
+
/**
|
|
46
|
+
* If this page *hosts* a database (contains a collection of row pages), the
|
|
47
|
+
* id of that database; otherwise `null`. Lets the sidebar mark database
|
|
48
|
+
* pages and the document area decide whether to render the database view.
|
|
49
|
+
*/
|
|
50
|
+
hostedDatabaseId: string | null;
|
|
51
|
+
/** The page this page is nested under, if any (drives the sidebar tree). */
|
|
52
|
+
parentId: string | null;
|
|
53
|
+
/**
|
|
54
|
+
* When the page is in the trash (soft-deleted), the ISO timestamp it was
|
|
55
|
+
* deleted; `null` for live pages. Trash listings carry this so the UI can
|
|
56
|
+
* show how long ago each item was deleted.
|
|
57
|
+
*/
|
|
58
|
+
deletedAt: string | null;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
updatedAt: string;
|
|
61
|
+
}
|
|
62
|
+
/** A full page as returned by the store. `data` is the document snapshot. */
|
|
63
|
+
export interface StoredPage {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string | null;
|
|
66
|
+
data: PageSnapshot;
|
|
67
|
+
/** The database this page *hosts*, if any (mirrors {@link PageMeta.hostedDatabaseId}). */
|
|
68
|
+
hostedDatabaseId: string | null;
|
|
69
|
+
/** The database this page is a *row* of, if any; `null` for ordinary pages. */
|
|
70
|
+
databaseId: string | null;
|
|
71
|
+
/** The page this page is nested under, if any. */
|
|
72
|
+
parentId: string | null;
|
|
73
|
+
/** Manual database-property values, keyed by property id (empty for non-rows). */
|
|
74
|
+
properties: Record<string, unknown>;
|
|
75
|
+
/** When the page is in the trash, the ISO timestamp it was deleted; else `null`. */
|
|
76
|
+
deletedAt: string | null;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
updatedAt: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Payload for creating/updating a page.
|
|
82
|
+
* - `id` present → upsert that page; absent → create with a fresh server id.
|
|
83
|
+
* - `name` optional; unique across the store when set.
|
|
84
|
+
*
|
|
85
|
+
* Note: a page's database membership (`databaseId`) and manual `properties` are
|
|
86
|
+
* not set through this payload — they are managed by the database row APIs so a
|
|
87
|
+
* routine content save never clobbers them.
|
|
88
|
+
*/
|
|
89
|
+
export interface PageInput {
|
|
90
|
+
id?: string;
|
|
91
|
+
name?: string | null;
|
|
92
|
+
data: PageSnapshot;
|
|
93
|
+
/**
|
|
94
|
+
* The page to nest this new page under. Applied only when the page is first
|
|
95
|
+
* created; a later content save with the same id leaves the parent untouched.
|
|
96
|
+
*/
|
|
97
|
+
parentId?: string | null;
|
|
98
|
+
}
|
|
99
|
+
/** Status of a desktop install's local server. */
|
|
100
|
+
export interface ServerInfo {
|
|
101
|
+
/** Whether the local server is currently running. */
|
|
102
|
+
running: boolean;
|
|
103
|
+
/** Bound base URL the local UI connects to, when running (loopback). */
|
|
104
|
+
address: string | null;
|
|
105
|
+
/**
|
|
106
|
+
* Whether the host process manages the local server lifecycle (true in the
|
|
107
|
+
* packaged desktop app). When false (e.g. dev, or the web shell), the server
|
|
108
|
+
* is external and start/stop are unavailable.
|
|
109
|
+
*/
|
|
110
|
+
managed: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Whether the server is published on the LAN (bound beyond loopback). When
|
|
113
|
+
* true, the workspace is reachable by other devices and an {@link accessToken}
|
|
114
|
+
* is required. Off by default.
|
|
115
|
+
*/
|
|
116
|
+
published?: boolean;
|
|
117
|
+
/** The shareable LAN URL (`http://<ip>:<port>`) when published; else null. */
|
|
118
|
+
lanAddress?: string | null;
|
|
119
|
+
/**
|
|
120
|
+
* The access token clients must present when {@link published}. Surfaced so the
|
|
121
|
+
* UI can show/copy it for other devices; the local UI sends it automatically.
|
|
122
|
+
*/
|
|
123
|
+
accessToken?: string | null;
|
|
124
|
+
/** Folder the on-disk book mirror writes to (durable mode). */
|
|
125
|
+
bookDir?: string | null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Controls for the host-managed local server, provided by the platform layer
|
|
129
|
+
* (the Tauri desktop app). Absent on the web, where there is no local server.
|
|
130
|
+
*/
|
|
131
|
+
export interface ServerControls {
|
|
132
|
+
info(): Promise<ServerInfo>;
|
|
133
|
+
/** Legacy lifecycle hooks. The desktop now keeps the local server always-on
|
|
134
|
+
* over IPC, so these are optional and unused there. */
|
|
135
|
+
start?(): Promise<ServerInfo>;
|
|
136
|
+
stop?(): Promise<ServerInfo>;
|
|
137
|
+
/** Publish (or unpublish) the server on the LAN — adds the `0.0.0.0` bind and
|
|
138
|
+
* requires the access token. The local UI keeps using IPC; resolves the new
|
|
139
|
+
* status. */
|
|
140
|
+
publish?(enabled: boolean): Promise<ServerInfo>;
|
|
141
|
+
/** Open a native folder picker to choose the book-mirror directory. Resolves
|
|
142
|
+
* the new status (with the chosen `bookDir`), or unchanged if cancelled. */
|
|
143
|
+
chooseBookDir?(): Promise<ServerInfo>;
|
|
144
|
+
/** Reveal the current book-mirror directory in the OS file manager. */
|
|
145
|
+
revealBookDir?(): Promise<void>;
|
|
146
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenBook domain types — the single source of truth shared by the server, the
|
|
3
|
+
* desktop app, and the web shell. Because every layer imports these same
|
|
4
|
+
* definitions, page data cannot drift between client and server.
|
|
5
|
+
*
|
|
6
|
+
* A **page** is the unit of storage: a stable UUID, an optional unique name, and
|
|
7
|
+
* an opaque document payload ({@link PageSnapshot}). The storage layer treats
|
|
8
|
+
* `data` as opaque JSON; its internal shape is owned by the document editor.
|
|
9
|
+
*/
|
|
10
|
+
/** An empty snapshot, for initializing a brand-new page. */
|
|
11
|
+
export const emptyPageSnapshot = () => ({
|
|
12
|
+
editorjs: { blocks: [] },
|
|
13
|
+
values: [],
|
|
14
|
+
names: [],
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA4BH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAiB,EAAE,CAAC,CAAC;IACpD,QAAQ,EAAE,EAAC,MAAM,EAAE,EAAE,EAAC;IACtB,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;CACV,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@book.dev/sdk",
|
|
3
|
+
"version": "1.60.0",
|
|
4
|
+
"description": "Shared OpenBook types and HTTP client used by the server, desktop, and web.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"module": "dist/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"author": "",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "^6.0.3"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -p tsconfig.json",
|
|
28
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
29
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
30
|
+
"lint": "eslint .",
|
|
31
|
+
"lint-fix": "eslint . --fix"
|
|
32
|
+
}
|
|
33
|
+
}
|