mindoodb-app-sdk 0.0.49 → 0.0.53

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.
@@ -1,4 +1,4 @@
1
- import { as as MindooDBAppCreateViewNavigatorInput, cl as MindooDBAppViewNavigator, bd as MindooDBAppLaunchContext, at as MindooDBAppDatabaseInfo, aB as MindooDBAppDocumentApi, cn as MindooDBAppViewNavigatorOpenOptions, v as MindooDBAppAttachmentApi, b1 as MindooDBAppIdentityApi, cb as MindooDBAppTimestampApi, az as MindooDBAppDirectoryApi, j as MindooDBAppDocument, aZ as MindooDBAppFulltextSetup, aY as MindooDBAppExtractionSetup, bs as MindooDBAppProposeAppInput, bt as MindooDBAppProposeAppResult, e as MindooDBAppBridge, c0 as MindooDBAppSession, V as MindooDBAppBridgeRpcRequest, b0 as MindooDBAppHostTheme, ct as MindooDBAppViewport, cf as MindooDBAppUiPreferences, by as MindooDBAppQueryResult, cs as MindooDBAppViewUpdateStats, R as MindooDBAppBridgePortMessage, c as MindooDBAppDragStartResult, aS as MindooDBAppDragProfile } from '../types-C-eyC839.js';
1
+ import { ay as MindooDBAppCreateViewNavigatorInput, cC as MindooDBAppViewNavigator, $ as MindooDBAppBridgeRpcRequest, b7 as MindooDBAppHostTheme, ag as MindooDBAppCapability, i as MindooDBAppDefinition, e as MindooDBAppBridge, cc as MindooDBAppSession, bE as MindooDBAppProposeAppInput, cK as MindooDBAppViewport, cw as MindooDBAppUiPreferences, bK as MindooDBAppQueryResult, cJ as MindooDBAppViewUpdateStats, X as MindooDBAppBridgePortMessage, bl as MindooDBAppLaunchContext, az as MindooDBAppDatabaseInfo, aI as MindooDBAppDocumentApi, cE as MindooDBAppViewNavigatorOpenOptions, A as MindooDBAppAttachmentApi, b8 as MindooDBAppIdentityApi, cs as MindooDBAppTimestampApi, aG as MindooDBAppDirectoryApi, k as MindooDBAppDocument, b4 as MindooDBAppFulltextSetup, b3 as MindooDBAppExtractionSetup, ck as MindooDBAppSummarySetup, bF as MindooDBAppProposeAppResult, c as MindooDBAppDragStartResult, aZ as MindooDBAppDragProfile } from '../types-CsKw_niD.js';
2
2
  import * as mindoodb from 'mindoodb';
3
3
  import 'mindoodb-view-language';
4
4
 
@@ -21,6 +21,92 @@ declare function loadMindoodbForTesting(): Promise<MindoodbVirtualViews | null>;
21
21
  */
22
22
  declare function createEvaluatingViewNavigator(input: MindooDBAppCreateViewNavigatorInput, documents: EvaluatingViewDocument[]): Promise<MindooDBAppViewNavigator | null>;
23
23
 
24
+ /**
25
+ * A stand-in Haven for a real browser: the app runs in an iframe, exactly as Haven frames
26
+ * it, and talks to the same in-memory mock host the Vitest helpers use.
27
+ *
28
+ * This is what an app's test URL (`/__haven-test/` in the starter) mounts, so Playwright
29
+ * and a developer's own eyes see the real app — real bridge handshake, real DOM — with
30
+ * seeded data and scriptable host services, and without setting up an identity, a
31
+ * tenant and an install in a real Haven. It is never meant to be deployed where end
32
+ * users can reach it.
33
+ */
34
+ /** A scan the test host hands out on the app's next `attachments.scan()` call. */
35
+ interface BrowserTestHostScan {
36
+ fileName: string;
37
+ mimeType: "image/jpeg" | "image/png" | "application/pdf";
38
+ size: number;
39
+ }
40
+ /** What the test host recorded, in the order the app asked. */
41
+ interface BrowserTestHostLog {
42
+ notifications: Array<{
43
+ id?: string;
44
+ severity?: string;
45
+ text?: string;
46
+ durationMs?: number;
47
+ }>;
48
+ previews: Array<{
49
+ databaseId: string;
50
+ docId: string;
51
+ attachmentName: string;
52
+ }>;
53
+ scans: Array<{
54
+ databaseId: string;
55
+ docId: string;
56
+ result: "scanned" | "cancelled";
57
+ }>;
58
+ focusRequests: number;
59
+ requests: MindooDBAppBridgeRpcRequest[];
60
+ }
61
+ interface CreateBrowserTestHostOptions extends CreateFakeBridgeHostOptions {
62
+ /** The iframe the app runs in. Its `src` is set by the host. */
63
+ frame: HTMLIFrameElement;
64
+ /** URL of the app page, relative to the test page or absolute. */
65
+ appUrl: string;
66
+ /** Called after every request, e.g. to re-render a control panel. */
67
+ onChange?: () => void;
68
+ }
69
+ interface BrowserTestHost {
70
+ host: FakeBridgeHostController;
71
+ log: BrowserTestHostLog;
72
+ /**
73
+ * Decides the outcome of the app's next `attachments.scan()`: a file description to
74
+ * "scan", or `null` to act as if the user cancelled. Without a call, scans cancel.
75
+ */
76
+ setNextScan(scan: BrowserTestHostScan | null): void;
77
+ setTheme(theme: MindooDBAppHostTheme): void;
78
+ setHostFocus(focused: boolean): void;
79
+ /** Reloads the app frame. The mock data survives; the app's in-memory state does not. */
80
+ reloadApp(): void;
81
+ dispose(): void;
82
+ }
83
+ /**
84
+ * The capabilities Haven grants for the permissions a definition requests. `read` is
85
+ * implied by the mapping, `write` is create plus update.
86
+ */
87
+ declare function capabilitiesForDefinitionPermissions(permissions: readonly string[] | undefined): MindooDBAppCapability[];
88
+ /** Mock databases for every database a `haven-app.json` declares, granted as requested. */
89
+ declare function mockDatabasesFromDefinition(definition: Pick<MindooDBAppDefinition, "databases">, seed?: Record<string, MockMindooDBAppDatabaseDefinition["documents"]>): MockMindooDBAppDatabaseDefinition[];
90
+ declare function createBrowserTestHost(options: CreateBrowserTestHostOptions): BrowserTestHost;
91
+ interface MountHavenTestHostOptions extends Omit<CreateBrowserTestHostOptions, "frame" | "onChange"> {
92
+ /** Element to render into. Defaults to `document.body`, which is cleared. */
93
+ container?: HTMLElement;
94
+ /** Heading of the control panel, e.g. the app label. */
95
+ title?: string;
96
+ }
97
+ declare global {
98
+ interface Window {
99
+ /** Set by {@link mountHavenTestHost} so Playwright can script the host. */
100
+ __havenTestHost?: BrowserTestHost;
101
+ }
102
+ }
103
+ /**
104
+ * Renders the full test page: the app frame plus a control panel for theme, host focus
105
+ * and the next scan, and a live log of notifications, previews, scans and requests.
106
+ * The returned host is also available as `window.__havenTestHost`.
107
+ */
108
+ declare function mountHavenTestHost(options: MountHavenTestHostOptions): BrowserTestHost;
109
+
24
110
  type MaybePromise<T> = T | Promise<T>;
25
111
  type MockViewApi = {
26
112
  create(input: MindooDBAppCreateViewNavigatorInput): MaybePromise<MindooDBAppViewNavigator>;
@@ -72,6 +158,13 @@ interface MockMindooDBAppDatabaseDefinition {
72
158
  * their setup/bootstrap logic.
73
159
  */
74
160
  extractionSetup?: MindooDBAppExtractionSetup | null;
161
+ /**
162
+ * Initial summary buffer configuration returned by `getSummarySetup()`.
163
+ * `setSummarySetup()` overwrites it for the lifetime of the handle. The
164
+ * mock's `query()` reads the seeded documents directly and ignores this
165
+ * config — it exists so apps can test their setup/bootstrap logic.
166
+ */
167
+ summarySetup?: MindooDBAppSummarySetup | null;
75
168
  }
76
169
  /**
77
170
  * Stands in for the host-owned sealed channel.
@@ -122,6 +215,8 @@ interface MockMindooDBAppSessionController {
122
215
  emitLocaleChange(locale: string): void;
123
216
  /** Runs the app's `onBeforeClose` listeners, as the host does before a teardown. */
124
217
  emitBeforeClose(): Promise<void>;
218
+ /** Sets whether this mock launch has host focus and notifies listeners. */
219
+ emitHostFocusChange(focused: boolean): void;
125
220
  resolveDrag(result: MindooDBAppDragStartResult): void;
126
221
  getDragProfile(): MindooDBAppDragProfile | null;
127
222
  }
@@ -140,6 +235,8 @@ type FakeBridgePortMessageHandler = (message: Exclude<MindooDBAppBridgePortMessa
140
235
  interface CreateFakeBridgeHostOptions extends CreateMockMindooDBAppSessionOptions {
141
236
  windowMode?: "parent" | "opener";
142
237
  requestHandlers?: Record<string, FakeBridgeRequestHandler>;
238
+ /** Called for every RPC request the app sends, before it is answered. */
239
+ onRequest?: (request: MindooDBAppBridgeRpcRequest) => void;
143
240
  onPortMessage?: FakeBridgePortMessageHandler;
144
241
  }
145
242
  interface FakeBridgeHostController {
@@ -150,11 +247,19 @@ interface FakeBridgeHostController {
150
247
  /** Every `apps.propose` call the app under test made, in order. */
151
248
  readonly proposedApps: ReadonlyArray<MindooDBAppProposeAppInput>;
152
249
  install(): void;
250
+ /**
251
+ * Answers a `mindoodb-app:connect` handshake received some other way than through
252
+ * `install()` — in a real browser, from the app frame's `message` event
253
+ * (`host.acceptConnection(event.data, event.ports)`). Returns `false` for messages
254
+ * that are not a handshake for this launch.
255
+ */
256
+ acceptConnection(message: unknown, transfer?: readonly Transferable[]): boolean;
153
257
  dispose(): void;
154
258
  emitThemeChange(theme: MindooDBAppHostTheme): void;
155
259
  emitViewportChange(viewport: MindooDBAppViewport): void;
156
260
  emitUiPreferencesChange(uiPreferences: MindooDBAppUiPreferences): void;
157
261
  emitLocaleChange(locale: string): void;
262
+ emitHostFocusChange(focused: boolean): void;
158
263
  /** Push a live-query result to connected apps, as the Haven host would. */
159
264
  emitQueryResult(subscriptionId: string, result: MindooDBAppQueryResult): void;
160
265
  /** Push a navigator view-changed event to connected apps. */
@@ -170,4 +275,4 @@ interface FakeBridgeHostController {
170
275
  }
171
276
  declare function createFakeBridgeHost(options?: CreateFakeBridgeHostOptions): FakeBridgeHostController;
172
277
 
173
- export { type CreateFakeBridgeHostOptions, type CreateMockMindooDBAppSessionOptions, type EvaluatingViewDocument, type FakeBridgeHostController, type FakeBridgePortMessageHandler, type FakeBridgeRequestHandler, type MockMindooDBAppDatabaseDefinition, type MockMindooDBAppSessionController, type MockSealedChannelOptions, type MockSeedDocument, createEvaluatingViewNavigator, createFakeBridgeHost, createMockMindooDBAppBridge, createMockMindooDBAppSession, loadMindoodbForTesting };
278
+ export { type BrowserTestHost, type BrowserTestHostLog, type BrowserTestHostScan, type CreateBrowserTestHostOptions, type CreateFakeBridgeHostOptions, type CreateMockMindooDBAppSessionOptions, type EvaluatingViewDocument, type FakeBridgeHostController, type FakeBridgePortMessageHandler, type FakeBridgeRequestHandler, type MockMindooDBAppDatabaseDefinition, type MockMindooDBAppSessionController, type MockSealedChannelOptions, type MockSeedDocument, type MountHavenTestHostOptions, capabilitiesForDefinitionPermissions, createBrowserTestHost, createEvaluatingViewNavigator, createFakeBridgeHost, createMockMindooDBAppBridge, createMockMindooDBAppSession, loadMindoodbForTesting, mockDatabasesFromDefinition, mountHavenTestHost };