mindoodb-app-sdk 0.0.4

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,372 @@
1
+ import { MindooDBAppBooleanExpression, MindooDBAppExpression, MindooDBAppViewSortDirection, MindooDBAppViewTotalMode, MindooDBAppViewDefinition, MindooDBAppViewPageRequest, MindooDBAppViewPageResult, MindooDBAppViewExpansionState, MindooDBAppViewRow, MindooDBAppViewLookupByPath, MindooDBAppViewCategoryChildrenPageRequest } from 'mindoodb-view-language';
2
+
3
+ /** Launch target used by the Administrator when opening an app. */
4
+ type MindooDBAppRuntime = "iframe" | "window";
5
+ /** Theme mode currently active in the Administrator host UI. */
6
+ type MindooDBAppThemeMode = "light" | "dark";
7
+ /** Host theme snapshot exposed to running apps. */
8
+ interface MindooDBAppHostTheme {
9
+ mode: MindooDBAppThemeMode;
10
+ preset: string;
11
+ }
12
+ /** Iframe viewport dimensions reported by the Haven host. */
13
+ interface MindooDBAppViewport {
14
+ width: number;
15
+ height: number;
16
+ }
17
+ /** Saved categorization mode for Haven-managed view mappings delivered at launch time. */
18
+ type MindooDBAppConfiguredViewCategorizationStyle = "document_then_category" | "category_then_document";
19
+ /** Preferred preview layout for a Haven-managed view mapping. */
20
+ type MindooDBAppConfiguredViewPreviewMode = "tree" | "table";
21
+ /** Column role used by Haven-managed view mappings. */
22
+ type MindooDBAppConfiguredViewColumnRole = "category" | "sort" | "display" | "total";
23
+ /** Filter authoring mode used by Haven-managed view mappings. */
24
+ type MindooDBAppConfiguredViewFilterMode = "rules" | "formula";
25
+ /** Rule match mode used by visual-rule filters. */
26
+ type MindooDBAppConfiguredViewRuleMatchMode = "all" | "any";
27
+ /** Visual-rule operator supported by Haven-managed view mappings. */
28
+ type MindooDBAppConfiguredViewRuleOperator = "eq" | "neq" | "contains" | "notContains" | "gt" | "gte" | "lt" | "lte" | "exists" | "notExists";
29
+ /** Field/formula authoring modes for Haven-managed view columns. */
30
+ type MindooDBAppConfiguredViewExpressionMode = "field" | "formula";
31
+ /** One visual filter rule inside a Haven-managed view mapping. */
32
+ interface MindooDBAppConfiguredViewFilterRule {
33
+ id: string;
34
+ field: string;
35
+ operator: MindooDBAppConfiguredViewRuleOperator;
36
+ value?: string;
37
+ }
38
+ /** Field-based value expression used by Haven-managed view mappings. */
39
+ interface MindooDBAppConfiguredViewFieldExpression {
40
+ mode: "field";
41
+ field: string;
42
+ }
43
+ /** Formula-based value expression used by Haven-managed view mappings. */
44
+ interface MindooDBAppConfiguredViewFormulaExpression {
45
+ mode: "formula";
46
+ expression: MindooDBAppExpression;
47
+ }
48
+ /** Column expression authoring shape used by Haven-managed view mappings. */
49
+ type MindooDBAppConfiguredViewValueExpression = MindooDBAppConfiguredViewFieldExpression | MindooDBAppConfiguredViewFormulaExpression;
50
+ /** Rule-based filter stored by Haven for app-owned view mappings. */
51
+ interface MindooDBAppConfiguredViewRuleFilterDefinition {
52
+ mode: "rules";
53
+ match: MindooDBAppConfiguredViewRuleMatchMode;
54
+ rules: MindooDBAppConfiguredViewFilterRule[];
55
+ }
56
+ /** Formula-based filter stored by Haven for app-owned view mappings. */
57
+ interface MindooDBAppConfiguredViewFormulaFilterDefinition {
58
+ mode: "formula";
59
+ expression: MindooDBAppBooleanExpression;
60
+ }
61
+ /** Full filter authoring shape stored for Haven-managed app view mappings. */
62
+ type MindooDBAppConfiguredViewFilterDefinition = MindooDBAppConfiguredViewRuleFilterDefinition | MindooDBAppConfiguredViewFormulaFilterDefinition;
63
+ /** Column definition stored for a Haven-managed app view mapping. */
64
+ interface MindooDBAppConfiguredViewColumn {
65
+ id: string;
66
+ title: string;
67
+ name: string;
68
+ role: MindooDBAppConfiguredViewColumnRole;
69
+ expression: MindooDBAppConfiguredViewValueExpression;
70
+ sorting: MindooDBAppViewSortDirection;
71
+ totalMode: MindooDBAppViewTotalMode;
72
+ hidden: boolean;
73
+ }
74
+ /** One resolved source binding for an app-owned Haven view mapping. */
75
+ interface MindooDBAppResolvedViewSource {
76
+ origin: string;
77
+ databaseId: string;
78
+ title: string;
79
+ targetMode: "local" | "server";
80
+ connectionId?: string;
81
+ tenantId: string;
82
+ databaseName: string;
83
+ }
84
+ /** Full Haven-managed view mapping delivered to the running application at launch time. */
85
+ interface MindooDBAppResolvedViewDefinition {
86
+ id: string;
87
+ description?: string;
88
+ categorizationStyle: MindooDBAppConfiguredViewCategorizationStyle;
89
+ previewMode: MindooDBAppConfiguredViewPreviewMode;
90
+ sources: MindooDBAppResolvedViewSource[];
91
+ filter: MindooDBAppConfiguredViewFilterDefinition;
92
+ columns: MindooDBAppConfiguredViewColumn[];
93
+ }
94
+ /** Permission/capability flags exposed for a database binding inside the app session. */
95
+ type MindooDBAppCapability = "read" | "create" | "update" | "delete" | "history" | "attachments" | "views";
96
+ /** Metadata about the current app launch supplied by the Administrator host. */
97
+ interface MindooDBAppLaunchContext {
98
+ appId: string;
99
+ appInstanceId: string;
100
+ appVersion?: string;
101
+ launchId: string;
102
+ runtime: MindooDBAppRuntime;
103
+ theme: MindooDBAppHostTheme;
104
+ viewport: MindooDBAppViewport | null;
105
+ tenantId?: string;
106
+ preferredDatabaseId?: string;
107
+ user: {
108
+ id: string;
109
+ username: string;
110
+ };
111
+ launchParameters: Record<string, string>;
112
+ views: MindooDBAppResolvedViewDefinition[];
113
+ }
114
+ /** Attachment metadata returned by the attachment APIs. */
115
+ interface MindooDBAppAttachmentInfo {
116
+ attachmentId: string;
117
+ fileName: string;
118
+ mimeType: string;
119
+ size: number;
120
+ }
121
+ /** Database entry visible to the app during launch and database listing. */
122
+ interface MindooDBAppDatabaseInfo {
123
+ id: string;
124
+ title: string;
125
+ role?: string;
126
+ capabilities: MindooDBAppCapability[];
127
+ }
128
+ /** Lightweight document row returned by list operations. */
129
+ interface MindooDBAppDocumentSummary {
130
+ id: string;
131
+ data?: Record<string, unknown>;
132
+ attachmentCount?: number;
133
+ updatedAt?: string;
134
+ }
135
+ /** Fully loaded document returned by `get()`, `create()`, or `update()`. */
136
+ interface MindooDBAppDocument {
137
+ id: string;
138
+ data: Record<string, unknown>;
139
+ attachments?: MindooDBAppAttachmentInfo[];
140
+ updatedAt?: string;
141
+ }
142
+ /** One entry in the document history timeline. */
143
+ interface MindooDBAppDocumentHistoryEntry {
144
+ timestamp: number;
145
+ publicKey: string;
146
+ publicKeyFingerprint?: string;
147
+ identityLabel?: string;
148
+ isDeleted: boolean;
149
+ isCurrent: boolean;
150
+ summary?: string;
151
+ }
152
+ /** Historical snapshot returned for a document at a specific timestamp. */
153
+ interface MindooDBAppHistoricalDocument {
154
+ id: string;
155
+ timestamp: number;
156
+ state: "missing" | "deleted" | "exists";
157
+ data: Record<string, unknown> | null;
158
+ }
159
+ /** Query options for paging through documents in a database. */
160
+ interface MindooDBAppDocumentListQuery {
161
+ limit?: number;
162
+ cursor?: string | null;
163
+ fields?: string[];
164
+ filter?: Record<string, unknown>;
165
+ }
166
+ /** Paged result returned by `documents.list()`. */
167
+ interface MindooDBAppDocumentListResult {
168
+ items: MindooDBAppDocumentSummary[];
169
+ nextCursor: string | null;
170
+ }
171
+ /** Payload used when creating a new document. */
172
+ interface MindooDBAppCreateDocumentInput {
173
+ data: Record<string, unknown>;
174
+ /** Optional named document key. Defaults to `"default"` when omitted. */
175
+ decryptionKeyId?: string;
176
+ }
177
+ /** Patch payload used when updating an existing document. */
178
+ interface MindooDBAppUpdateDocumentInput {
179
+ data: Record<string, unknown>;
180
+ }
181
+ /** Query used for history lookups at a specific timestamp. */
182
+ interface MindooDBAppHistoryQuery {
183
+ timestamp: number;
184
+ }
185
+ /** Optional parameters for establishing the app bridge connection. */
186
+ interface MindooDBAppBridgeConnectOptions {
187
+ launchId?: string;
188
+ targetOrigin?: string;
189
+ connectTimeoutMs?: number;
190
+ }
191
+ /** Initial postMessage handshake sent from the app to the Administrator. */
192
+ interface MindooDBAppBridgeConnectMessage {
193
+ protocol: "mindoodb-app-bridge";
194
+ type: "mindoodb-app:connect";
195
+ launchId: string;
196
+ }
197
+ /** Handshake acknowledgement returned by the Administrator host. */
198
+ interface MindooDBAppBridgeConnectedMessage {
199
+ protocol: "mindoodb-app-bridge";
200
+ type: "mindoodb-app:connected";
201
+ }
202
+ /** Structured error payload transported over bridge RPC or stream messages. */
203
+ interface MindooDBAppBridgeErrorPayload {
204
+ code: string;
205
+ message: string;
206
+ }
207
+ /** Request envelope used by the port-based RPC transport. */
208
+ interface MindooDBAppBridgeRpcRequest<TParams = unknown> {
209
+ protocol: "mindoodb-app-bridge";
210
+ kind: "request";
211
+ id: string;
212
+ method: string;
213
+ params: TParams;
214
+ }
215
+ /** Successful RPC response envelope. */
216
+ interface MindooDBAppBridgeRpcSuccess<TResult = unknown> {
217
+ protocol: "mindoodb-app-bridge";
218
+ kind: "success";
219
+ id: string;
220
+ result: TResult;
221
+ }
222
+ /** Failed RPC response envelope. */
223
+ interface MindooDBAppBridgeRpcError {
224
+ protocol: "mindoodb-app-bridge";
225
+ kind: "error";
226
+ id: string;
227
+ error: MindooDBAppBridgeErrorPayload;
228
+ }
229
+ /** Union of all RPC-level bridge messages. */
230
+ type MindooDBAppBridgeRpcMessage = MindooDBAppBridgeRpcRequest | MindooDBAppBridgeRpcSuccess | MindooDBAppBridgeRpcError;
231
+ /** Result returned when the host opens a streamed attachment channel. */
232
+ interface MindooDBAppBridgeStreamOpenResult {
233
+ streamId: string;
234
+ }
235
+ /** Request asking the host for the next chunk on a read stream. */
236
+ interface MindooDBAppBridgeStreamReadRequest {
237
+ protocol: "mindoodb-app-bridge";
238
+ kind: "stream-read";
239
+ streamId: string;
240
+ }
241
+ /** Request sending one chunk over a write stream. */
242
+ interface MindooDBAppBridgeStreamWriteRequest {
243
+ protocol: "mindoodb-app-bridge";
244
+ kind: "stream-write";
245
+ streamId: string;
246
+ chunk: ArrayBuffer;
247
+ }
248
+ /** Request closing a stream gracefully. */
249
+ interface MindooDBAppBridgeStreamCloseRequest {
250
+ protocol: "mindoodb-app-bridge";
251
+ kind: "stream-close";
252
+ streamId: string;
253
+ }
254
+ /** Request aborting a stream due to cancellation or failure. */
255
+ interface MindooDBAppBridgeStreamAbortRequest {
256
+ protocol: "mindoodb-app-bridge";
257
+ kind: "stream-abort";
258
+ streamId: string;
259
+ }
260
+ /** Streamed attachment payload delivered over the message port. */
261
+ interface MindooDBAppAttachmentChunk {
262
+ protocol: "mindoodb-app-bridge";
263
+ kind: "stream-chunk";
264
+ streamId: string;
265
+ chunk?: ArrayBuffer;
266
+ done: boolean;
267
+ }
268
+ /** Host acknowledgement for a write/close/abort stream request. */
269
+ interface MindooDBAppBridgeStreamAck {
270
+ protocol: "mindoodb-app-bridge";
271
+ kind: "stream-ack";
272
+ streamId: string;
273
+ }
274
+ /** Stream-level error message. */
275
+ interface MindooDBAppBridgeStreamError {
276
+ protocol: "mindoodb-app-bridge";
277
+ kind: "stream-error";
278
+ streamId: string;
279
+ error: MindooDBAppBridgeErrorPayload;
280
+ }
281
+ /** Union of all non-RPC stream transport messages. */
282
+ type MindooDBAppBridgeStreamMessage = MindooDBAppBridgeStreamReadRequest | MindooDBAppBridgeStreamWriteRequest | MindooDBAppBridgeStreamCloseRequest | MindooDBAppBridgeStreamAbortRequest | MindooDBAppAttachmentChunk | MindooDBAppBridgeStreamAck | MindooDBAppBridgeStreamError;
283
+ /** Host-pushed event emitted when the Administrator theme changes. */
284
+ interface MindooDBAppBridgeThemeChangedMessage {
285
+ protocol: "mindoodb-app-bridge";
286
+ kind: "theme-changed";
287
+ theme: MindooDBAppHostTheme;
288
+ }
289
+ /** Host-pushed event emitted when the Haven iframe viewport changes. */
290
+ interface MindooDBAppBridgeViewportChangedMessage {
291
+ protocol: "mindoodb-app-bridge";
292
+ kind: "viewport-changed";
293
+ viewport: MindooDBAppViewport;
294
+ }
295
+ /** Any message that can travel across the dedicated bridge MessagePort. */
296
+ type MindooDBAppBridgePortMessage = MindooDBAppBridgeRpcMessage | MindooDBAppBridgeStreamMessage | MindooDBAppBridgeThemeChangedMessage | MindooDBAppBridgeViewportChangedMessage;
297
+ /** Pull-based read stream for document attachments. */
298
+ interface MindooDBAppReadableAttachmentStream {
299
+ read(): Promise<Uint8Array | null>;
300
+ close(): Promise<void>;
301
+ }
302
+ /** Push-based write stream for document attachments. */
303
+ interface MindooDBAppWritableAttachmentStream {
304
+ write(chunk: Uint8Array): Promise<void>;
305
+ close(): Promise<void>;
306
+ abort(): Promise<void>;
307
+ }
308
+ /** Document operations exposed by an opened database handle. */
309
+ interface MindooDBAppDocumentApi {
310
+ list(query?: MindooDBAppDocumentListQuery): Promise<MindooDBAppDocumentListResult>;
311
+ get(docId: string): Promise<MindooDBAppDocument | null>;
312
+ create(input: MindooDBAppCreateDocumentInput): Promise<MindooDBAppDocument>;
313
+ update(docId: string, patch: MindooDBAppUpdateDocumentInput): Promise<MindooDBAppDocument>;
314
+ delete(docId: string): Promise<{
315
+ ok: true;
316
+ }>;
317
+ listHistory(docId: string): Promise<MindooDBAppDocumentHistoryEntry[]>;
318
+ getAtTimestamp(docId: string, timestamp: number): Promise<MindooDBAppHistoricalDocument>;
319
+ }
320
+ /** Handle for one created or opened virtual view. */
321
+ interface MindooDBAppViewHandle {
322
+ getDefinition(): Promise<MindooDBAppViewDefinition>;
323
+ refresh(): Promise<void>;
324
+ page(input?: MindooDBAppViewPageRequest): Promise<MindooDBAppViewPageResult>;
325
+ getExpansionState(): Promise<MindooDBAppViewExpansionState>;
326
+ setExpansionState(state: MindooDBAppViewExpansionState): Promise<MindooDBAppViewExpansionState>;
327
+ expand(rowKey: string): Promise<MindooDBAppViewExpansionState>;
328
+ collapse(rowKey: string): Promise<MindooDBAppViewExpansionState>;
329
+ expandAll(): Promise<MindooDBAppViewExpansionState>;
330
+ collapseAll(): Promise<MindooDBAppViewExpansionState>;
331
+ getRow(rowKey: string): Promise<MindooDBAppViewRow | null>;
332
+ getCategory(input: MindooDBAppViewLookupByPath): Promise<MindooDBAppViewRow | null>;
333
+ pageCategory(categoryKey: string, input?: MindooDBAppViewCategoryChildrenPageRequest): Promise<MindooDBAppViewPageResult>;
334
+ listCategoryDocumentIds(categoryKey: string): Promise<string[]>;
335
+ dispose(): Promise<void>;
336
+ }
337
+ /** Entry point for creating or opening views in a database. */
338
+ interface MindooDBAppViewApi {
339
+ create(definition: MindooDBAppViewDefinition): Promise<MindooDBAppViewHandle>;
340
+ open(viewId: string): Promise<MindooDBAppViewHandle>;
341
+ }
342
+ /** Attachment operations exposed by an opened database handle. */
343
+ interface MindooDBAppAttachmentApi {
344
+ list(docId: string): Promise<MindooDBAppAttachmentInfo[]>;
345
+ remove(docId: string, attachmentName: string): Promise<{
346
+ ok: true;
347
+ }>;
348
+ openReadStream(docId: string, attachmentName: string): Promise<MindooDBAppReadableAttachmentStream>;
349
+ openWriteStream(docId: string, attachmentName: string, contentType?: string): Promise<MindooDBAppWritableAttachmentStream>;
350
+ }
351
+ /** Database handle returned from `session.openDatabase()`. */
352
+ interface MindooDBAppDatabase {
353
+ info(): Promise<MindooDBAppDatabaseInfo>;
354
+ documents: MindooDBAppDocumentApi;
355
+ views: MindooDBAppViewApi;
356
+ attachments: MindooDBAppAttachmentApi;
357
+ }
358
+ /** Connected session between the running app and the Administrator host. */
359
+ interface MindooDBAppSession {
360
+ getLaunchContext(): Promise<MindooDBAppLaunchContext>;
361
+ listDatabases(): Promise<MindooDBAppDatabaseInfo[]>;
362
+ openDatabase(databaseId: string): Promise<MindooDBAppDatabase>;
363
+ onThemeChange(listener: (theme: MindooDBAppHostTheme) => void): () => void;
364
+ onViewportChange(listener: (viewport: MindooDBAppViewport) => void): () => void;
365
+ disconnect(): Promise<void>;
366
+ }
367
+ /** Root SDK bridge object used to establish a session. */
368
+ interface MindooDBAppBridge {
369
+ connect(options?: MindooDBAppBridgeConnectOptions): Promise<MindooDBAppSession>;
370
+ }
371
+
372
+ export type { MindooDBAppResolvedViewDefinition as $, MindooDBAppConfiguredViewExpressionMode as A, MindooDBAppConfiguredViewFieldExpression as B, MindooDBAppConfiguredViewFilterDefinition as C, MindooDBAppConfiguredViewFilterMode as D, MindooDBAppConfiguredViewFilterRule as E, MindooDBAppConfiguredViewFormulaExpression as F, MindooDBAppConfiguredViewFormulaFilterDefinition as G, MindooDBAppConfiguredViewPreviewMode as H, MindooDBAppConfiguredViewRuleFilterDefinition as I, MindooDBAppConfiguredViewRuleMatchMode as J, MindooDBAppConfiguredViewRuleOperator as K, MindooDBAppConfiguredViewValueExpression as L, MindooDBAppBridge as M, MindooDBAppCreateDocumentInput as N, MindooDBAppDatabase as O, MindooDBAppDatabaseInfo as P, MindooDBAppDocument as Q, MindooDBAppDocumentApi as R, MindooDBAppDocumentHistoryEntry as S, MindooDBAppDocumentListQuery as T, MindooDBAppDocumentListResult as U, MindooDBAppDocumentSummary as V, MindooDBAppHistoricalDocument as W, MindooDBAppHistoryQuery as X, MindooDBAppHostTheme as Y, MindooDBAppLaunchContext as Z, MindooDBAppReadableAttachmentStream as _, MindooDBAppAttachmentApi as a, MindooDBAppResolvedViewSource as a0, MindooDBAppRuntime as a1, MindooDBAppSession as a2, MindooDBAppThemeMode as a3, MindooDBAppUpdateDocumentInput as a4, MindooDBAppViewApi as a5, MindooDBAppViewHandle as a6, MindooDBAppViewport as a7, MindooDBAppWritableAttachmentStream as a8, MindooDBAppAttachmentChunk as b, MindooDBAppAttachmentInfo as c, MindooDBAppBridgeConnectMessage as d, MindooDBAppBridgeConnectOptions as e, MindooDBAppBridgeConnectedMessage as f, MindooDBAppBridgeErrorPayload as g, MindooDBAppBridgePortMessage as h, MindooDBAppBridgeRpcError as i, MindooDBAppBridgeRpcMessage as j, MindooDBAppBridgeRpcRequest as k, MindooDBAppBridgeRpcSuccess as l, MindooDBAppBridgeStreamAbortRequest as m, MindooDBAppBridgeStreamAck as n, MindooDBAppBridgeStreamCloseRequest as o, MindooDBAppBridgeStreamError as p, MindooDBAppBridgeStreamMessage as q, MindooDBAppBridgeStreamOpenResult as r, MindooDBAppBridgeStreamReadRequest as s, MindooDBAppBridgeStreamWriteRequest as t, MindooDBAppBridgeThemeChangedMessage as u, MindooDBAppBridgeViewportChangedMessage as v, MindooDBAppCapability as w, MindooDBAppConfiguredViewCategorizationStyle as x, MindooDBAppConfiguredViewColumn as y, MindooDBAppConfiguredViewColumnRole as z };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "mindoodb-app-sdk",
3
+ "version": "0.0.4",
4
+ "description": "MindooDB app SDK for building apps that connect to the Haven host bridge",
5
+ "license": "ISC",
6
+ "author": "Mindoo GmbH",
7
+ "keywords": [
8
+ "mindoodb",
9
+ "haven",
10
+ "sdk",
11
+ "iframe",
12
+ "bridge"
13
+ ],
14
+ "type": "module",
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "TESTING.md"
21
+ ],
22
+ "sideEffects": false,
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "default": "./dist/index.js"
28
+ },
29
+ "./testing": {
30
+ "types": "./dist/testing/index.d.ts",
31
+ "import": "./dist/testing/index.js",
32
+ "default": "./dist/testing/index.js"
33
+ }
34
+ },
35
+ "scripts": {
36
+ "build": "tsup src/index.ts src/testing/index.ts --format esm --dts --clean --tsconfig tsconfig.build.json",
37
+ "typecheck": "tsc --noEmit -p tsconfig.json",
38
+ "test": "vitest run",
39
+ "test:watch": "vitest",
40
+ "prepublishOnly": "npm run build && npm run test"
41
+ },
42
+ "dependencies": {
43
+ "mindoodb-view-language": "^0.0.4"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^25.5.0",
47
+ "tsup": "^8.5.1",
48
+ "typescript": "^6.0.2",
49
+ "vitest": "^4.1.2"
50
+ }
51
+ }