mindoodb-app-sdk 0.0.56 → 0.0.58
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/README.md +47 -2
- package/dist/{chunk-S73KTYZF.js → chunk-SKPP4T6S.js} +148 -0
- package/dist/index.d.ts +36 -3
- package/dist/index.js +101 -1
- package/dist/testing/index.d.ts +29 -5
- package/dist/testing/index.js +257 -18
- package/dist/{types-Dl70Tlfj.d.ts → types-DkzIJKBw.d.ts} +160 -2
- package/dist/vite/index.d.ts +20 -1
- package/dist/vite/index.js +16 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -144,6 +144,7 @@ interface MindooDBAppLaunchContext {
|
|
|
144
144
|
tenantId?: string;
|
|
145
145
|
preferredDatabaseId?: string;
|
|
146
146
|
user: { id: string; username: string };
|
|
147
|
+
browserFeatures?: MindooDBAppBrowserFeatures;
|
|
147
148
|
launchParameters: Record<string, string>;
|
|
148
149
|
databases: MindooDBAppDatabaseInfo[];
|
|
149
150
|
views: MindooDBAppResolvedViewDefinition[];
|
|
@@ -164,6 +165,18 @@ if (ctx.runtime === "iframe") {
|
|
|
164
165
|
}
|
|
165
166
|
```
|
|
166
167
|
|
|
168
|
+
`browserFeatures` says which browser features Haven leaves available to the app: `popups`, `camera`, `microphone`, `geolocation`, `clipboardWrite`, `motion`, `webRtc` and `workers`. `false` means Haven blocks the feature for this app, through the iframe sandbox, its `allow` attribute or the hosted app CSP, and the user has to enable it in the app's settings. The browser cannot report these restrictions to the app itself, so check them in an initial setup instead of letting a call fail silently:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
const ctx = await session.getLaunchContext();
|
|
172
|
+
|
|
173
|
+
if (ctx.browserFeatures && !ctx.browserFeatures.microphone) {
|
|
174
|
+
showSetupHint("Voice notes need microphone access. Enable it for this app in Haven's app settings.");
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Each flag matches the app definition field of the same name (`allowCamera`, `allowPopups`, …), so an app that always needs a feature can request it there. The field is absent on older hosts; treat that as unknown.
|
|
179
|
+
|
|
167
180
|
### Host-rendered menus
|
|
168
181
|
|
|
169
182
|
When your app runs inside an iframe, Haven can render a structured menu above the iframe chrome. This is useful for context menus, toolbar drop-downs, and simple pickers such as font-family or font-size lists.
|
|
@@ -253,7 +266,7 @@ Haven uses the app's registration label as the headline and ignores any title fr
|
|
|
253
266
|
|
|
254
267
|
An app can offer its own operations to AI agents. Haven registers them with the browser's agent interface ([WebMCP](https://webmachinelearning.github.io/webmcp/)) next to Haven's own tools, so an agent in the browser — or a local agent connected through a WebMCP bridge — can call "create a mind map", "list open tasks" or "attach this file" instead of clicking through the UI.
|
|
255
268
|
|
|
256
|
-
The app declares tools; `execute` runs inside the app. Haven validates the declarations, prefixes the names with the app's
|
|
269
|
+
The app declares tools; `execute` runs inside the app. Haven validates the declarations, prefixes the names with the app's tool prefix (`vega_maps_list` for `"agentToolPrefix": "vega"` in `haven-app.json`; without it Haven derives one from the app id or label), checks permission, asks the user before consequential calls, and forwards each call over the bridge. The tools disappear when the app closes.
|
|
257
270
|
|
|
258
271
|
Agents only see an app's tools while the user has **Agent tools** switched on in Haven (Settings → General) **and** has allowed this app (**Offer tools to AI agents** in the app's settings). Neither can be set by `haven-app.json`. `registerTools()` works either way; `enabled` in its answer says whether agents can call the tools right now.
|
|
259
272
|
|
|
@@ -309,7 +322,7 @@ if (session.agent) {
|
|
|
309
322
|
}
|
|
310
323
|
```
|
|
311
324
|
|
|
312
|
-
- **`registerTools(tools)`** replaces the app's whole tool set; call it again when the set changes (e.g. after a document opens). At most
|
|
325
|
+
- **`registerTools(tools)`** replaces the app's whole tool set; call it again when the set changes (e.g. after a document opens). At most 64 tools; names are lower case, digits and `_`, starting with a letter. Fewer is better: every tool costs the model context on each request and makes choosing harder, so large apps register the tools of the area the user has open and add the rest on demand.
|
|
313
326
|
- **`description`** is written for a model: what the tool does, when to use it, where ids come from, what it returns. **`inputSchema`** is a JSON Schema object; use `enum` for fixed choices.
|
|
314
327
|
- **`annotations`**: `readOnlyHint` for reads; `consequentialHint` for anything the user should confirm (sending, sharing, deleting) — Haven shows its own confirmation dialog and a refusal reaches the agent as `NOT_ALLOWED`; `untrustedContentHint` when the result contains text other people wrote.
|
|
315
328
|
- **Errors**: throw `MindooDBAppAgentToolError(code, message, requiredAction?)` with `NOT_FOUND`, `INVALID_INPUT`, `INVALID_STATE`, `STATE_CHANGED`, `NOT_ALLOWED` or `FAILED`; `requiredAction` tells the agent what to do next ("call todo_tasks_search"). Any other exception becomes `FAILED`. Haven passes the agent one JSON error.
|
|
@@ -346,6 +359,38 @@ const unbind = session.drag.bindSource(cardEl, {
|
|
|
346
359
|
|
|
347
360
|
`bindSource` starts after an 8px mouse/pen move, or a 400ms long-press on touch (so lists can still scroll). After start, the source frame keeps the pressed pointer (browsers do not retarget mouse-capture into Haven) and forwards `pointermove` / `pointerup` to the host. You can also call `session.drag.start` yourself with a PNG `ArrayBuffer` preview, then `reportPointer` / `release`. v1 is **copy-only** and **iframe-only**. Well-known types: `text/plain`, `text/markdown`, `application/json`, `application/x-mindoo-document`.
|
|
348
361
|
|
|
362
|
+
### Receiving files and content
|
|
363
|
+
|
|
364
|
+
Users can hand content to your app: files from the iOS/Android share sheet, "Open with Haven", the Files import folder, or files dropped/picked in Haven. Haven asks the user which app should receive it and only offers apps whose `haven-app.json` declares that they take it:
|
|
365
|
+
|
|
366
|
+
```json
|
|
367
|
+
"accepts": [
|
|
368
|
+
{
|
|
369
|
+
"id": "attach",
|
|
370
|
+
"label": { "en": "Attach to the open document", "de": "An das offene Dokument anhängen" },
|
|
371
|
+
"types": ["image/*", "application/pdf", "*/*"]
|
|
372
|
+
},
|
|
373
|
+
{ "id": "import-assets", "label": "Import as asset set", "types": ["*/*"], "folders": true, "maxBytes": 524288000 }
|
|
374
|
+
]
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Each entry is one choice in Haven's picker. `types` are MIME patterns (`text/plain` for shared text, `text/uri-list` for links), `folders: true` allows whole folders with relative paths, `multiple: false` limits it to one item, `maxBytes` caps the total size. Open apps are listed first.
|
|
378
|
+
|
|
379
|
+
```ts
|
|
380
|
+
session.onIncomingContent(async (content) => {
|
|
381
|
+
if (content.acceptId !== "attach") {
|
|
382
|
+
return { status: "rejected", message: "Unknown action" };
|
|
383
|
+
}
|
|
384
|
+
for (const item of content.items) {
|
|
385
|
+
const blob = await item.read(); // streamed from Haven in 1 MiB chunks
|
|
386
|
+
await attachments.add(item.path, blob);
|
|
387
|
+
}
|
|
388
|
+
return { status: "accepted", message: `${content.items.length} attachment(s) added` };
|
|
389
|
+
});
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
Register the handler once, early. Haven waits for it before delivering, so a launch started for a delivery receives it as soon as the handler exists. `item.path` is relative (`assets/logo.png` inside a shared folder) and never absolute. What the app does with the content is up to the app. The returned `status` and `message` are shown to the user; a throwing handler counts as `rejected`. In tests, `createMockMindooDBAppSession().emitIncomingContent({ acceptId, items })` plays Haven's part.
|
|
393
|
+
|
|
349
394
|
### Databases and capabilities
|
|
350
395
|
|
|
351
396
|
Each database mapped to your app carries a set of **capabilities** that Haven controls. Your app should check capabilities before attempting operations and adapt its UI accordingly.
|
|
@@ -40,6 +40,32 @@ var MindooDBAppValue = {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
// src/documentIds.ts
|
|
44
|
+
var MINDOODB_CUSTOM_DOCUMENT_ID_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
45
|
+
var MINDOODB_DOCUMENT_ID_PREFIX_PATTERN = /^[a-z][a-z0-9]{0,9}$/;
|
|
46
|
+
function isValidMindooDBDocumentId(id) {
|
|
47
|
+
return MINDOODB_CUSTOM_DOCUMENT_ID_PATTERN.test(id);
|
|
48
|
+
}
|
|
49
|
+
function mindooDBDocumentId(prefix, ...parts) {
|
|
50
|
+
const id = [prefix, ...parts].map((part) => String(part).toLowerCase().replace(/[^a-z0-9_]/g, "_")).join("_");
|
|
51
|
+
if (!isValidMindooDBDocumentId(id)) {
|
|
52
|
+
throw new Error(`mindooDBDocumentId: prefix "${prefix}" must start with a lowercase letter`);
|
|
53
|
+
}
|
|
54
|
+
return id;
|
|
55
|
+
}
|
|
56
|
+
function assertValidMindooDBCreateIds(input, methodName = "createDocument") {
|
|
57
|
+
if (input.id !== void 0 && !isValidMindooDBDocumentId(input.id)) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`${methodName}: invalid document id "${input.id}". Custom document IDs must match ${MINDOODB_CUSTOM_DOCUMENT_ID_PATTERN.source}.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
if (input.idPrefix !== void 0 && !MINDOODB_DOCUMENT_ID_PREFIX_PATTERN.test(input.idPrefix)) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`${methodName}: invalid idPrefix "${input.idPrefix}". ID prefixes must match ${MINDOODB_DOCUMENT_ID_PREFIX_PATTERN.source}.`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
43
69
|
// src/drag.ts
|
|
44
70
|
var MINDOODB_APP_MAX_DRAG_TYPES = 8;
|
|
45
71
|
var MINDOODB_APP_MAX_DRAG_PAYLOAD_BYTES = 32 * 1024;
|
|
@@ -639,6 +665,116 @@ function installHostShortcutCapture(options) {
|
|
|
639
665
|
// src/client/createMindooDBAppBridge.ts
|
|
640
666
|
import { parseMindooDBFormulaBooleanExpression } from "mindoodb-view-language";
|
|
641
667
|
|
|
668
|
+
// src/client/incomingContent.ts
|
|
669
|
+
var MINDOODB_APP_INCOMING_READ_CHUNK_BYTES = 1024 * 1024;
|
|
670
|
+
function isIncomingContentMessage(message) {
|
|
671
|
+
return message.kind === "incoming-content";
|
|
672
|
+
}
|
|
673
|
+
function toArrayBuffer(value) {
|
|
674
|
+
if (value instanceof ArrayBuffer) {
|
|
675
|
+
return value;
|
|
676
|
+
}
|
|
677
|
+
if (ArrayBuffer.isView(value)) {
|
|
678
|
+
const view = value;
|
|
679
|
+
return view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength);
|
|
680
|
+
}
|
|
681
|
+
throw new Error("Haven answered incoming.read without bytes.");
|
|
682
|
+
}
|
|
683
|
+
var MindooDBAppIncomingApiImpl = class {
|
|
684
|
+
constructor(rpc) {
|
|
685
|
+
this.rpc = rpc;
|
|
686
|
+
this.stopListening = this.rpc.addMessageListener((message) => {
|
|
687
|
+
if (!isIncomingContentMessage(message)) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
if (this.handler) {
|
|
691
|
+
void this.deliver(message.content);
|
|
692
|
+
} else {
|
|
693
|
+
this.pending.push(message.content);
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
rpc;
|
|
698
|
+
handler = null;
|
|
699
|
+
pending = [];
|
|
700
|
+
stopListening;
|
|
701
|
+
onIncomingContent(handler) {
|
|
702
|
+
this.handler = handler;
|
|
703
|
+
void this.rpc.call("incoming.subscribe", {}).catch((error) => {
|
|
704
|
+
console.warn("[mindoodb-app-sdk] Haven does not support incoming content.", error);
|
|
705
|
+
});
|
|
706
|
+
const queued = this.pending.splice(0);
|
|
707
|
+
queued.forEach((content) => {
|
|
708
|
+
void this.deliver(content);
|
|
709
|
+
});
|
|
710
|
+
return () => {
|
|
711
|
+
if (this.handler !== handler) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
this.handler = null;
|
|
715
|
+
void this.rpc.call("incoming.unsubscribe", {}).catch(() => {
|
|
716
|
+
});
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
dispose() {
|
|
720
|
+
this.stopListening();
|
|
721
|
+
this.handler = null;
|
|
722
|
+
this.pending.length = 0;
|
|
723
|
+
}
|
|
724
|
+
async deliver(info) {
|
|
725
|
+
const handler = this.handler;
|
|
726
|
+
if (!handler) {
|
|
727
|
+
this.pending.push(info);
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
const content = {
|
|
731
|
+
deliveryId: info.deliveryId,
|
|
732
|
+
acceptId: info.acceptId,
|
|
733
|
+
source: info.source,
|
|
734
|
+
items: info.items.map((item) => this.toItem(info.deliveryId, item))
|
|
735
|
+
};
|
|
736
|
+
let result;
|
|
737
|
+
try {
|
|
738
|
+
result = await handler(content) ?? { status: "accepted" };
|
|
739
|
+
} catch (error) {
|
|
740
|
+
result = { status: "rejected", message: error instanceof Error ? error.message : String(error) };
|
|
741
|
+
}
|
|
742
|
+
await this.rpc.call("incoming.complete", {
|
|
743
|
+
deliveryId: info.deliveryId,
|
|
744
|
+
status: result.status,
|
|
745
|
+
message: typeof result.message === "string" ? result.message.slice(0, 500) : void 0
|
|
746
|
+
}).catch((error) => {
|
|
747
|
+
console.warn("[mindoodb-app-sdk] Could not report an incoming content result.", error);
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
toItem(deliveryId, info) {
|
|
751
|
+
const read = async () => {
|
|
752
|
+
if ((info.kind === "text" || info.kind === "url") && typeof info.text === "string") {
|
|
753
|
+
return new Blob([info.text], { type: info.type });
|
|
754
|
+
}
|
|
755
|
+
const chunks = [];
|
|
756
|
+
let offset = 0;
|
|
757
|
+
while (offset < info.size) {
|
|
758
|
+
const length = Math.min(MINDOODB_APP_INCOMING_READ_CHUNK_BYTES, info.size - offset);
|
|
759
|
+
const chunk = toArrayBuffer(
|
|
760
|
+
await this.rpc.call("incoming.read", { deliveryId, itemId: info.itemId, offset, length })
|
|
761
|
+
);
|
|
762
|
+
if (chunk.byteLength === 0) {
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
chunks.push(chunk);
|
|
766
|
+
offset += chunk.byteLength;
|
|
767
|
+
}
|
|
768
|
+
return new Blob(chunks, { type: info.type });
|
|
769
|
+
};
|
|
770
|
+
return {
|
|
771
|
+
...info,
|
|
772
|
+
read,
|
|
773
|
+
readText: async () => (info.kind === "text" || info.kind === "url") && typeof info.text === "string" ? info.text : await (await read()).text()
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
|
|
642
778
|
// src/client/portRpcClient.ts
|
|
643
779
|
var PROTOCOL = "mindoodb-app-bridge";
|
|
644
780
|
function normalizeRpcValue(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
@@ -1914,6 +2050,7 @@ var MindooDBAppSessionImpl = class {
|
|
|
1914
2050
|
};
|
|
1915
2051
|
this.drag = new MindooDBAppDragApiImpl(this.rpc);
|
|
1916
2052
|
this.agent = new MindooDBAppAgentApiImpl(this.rpc);
|
|
2053
|
+
this.incoming = new MindooDBAppIncomingApiImpl(this.rpc);
|
|
1917
2054
|
this.storage = {
|
|
1918
2055
|
snapshot: async (options) => await this.rpc.call("appStorage.snapshot", {
|
|
1919
2056
|
prefixes: options?.prefixes
|
|
@@ -1977,6 +2114,7 @@ var MindooDBAppSessionImpl = class {
|
|
|
1977
2114
|
drag;
|
|
1978
2115
|
storage;
|
|
1979
2116
|
agent;
|
|
2117
|
+
incoming;
|
|
1980
2118
|
beforeCloseListeners = /* @__PURE__ */ new Set();
|
|
1981
2119
|
hostShortcuts = DEFAULT_HAVEN_HOST_SHORTCUTS;
|
|
1982
2120
|
stopHostShortcuts;
|
|
@@ -2108,6 +2246,10 @@ var MindooDBAppSessionImpl = class {
|
|
|
2108
2246
|
}
|
|
2109
2247
|
});
|
|
2110
2248
|
}
|
|
2249
|
+
/** Receive content the user hands to this app (share sheet, drop, …). */
|
|
2250
|
+
onIncomingContent(handler) {
|
|
2251
|
+
return this.incoming.onIncomingContent(handler);
|
|
2252
|
+
}
|
|
2111
2253
|
/** Subscribe to host-pushed UI language changes. */
|
|
2112
2254
|
onLocaleChange(listener) {
|
|
2113
2255
|
return this.rpc.addMessageListener((message) => {
|
|
@@ -2150,6 +2292,7 @@ var MindooDBAppSessionImpl = class {
|
|
|
2150
2292
|
this.stopHostFocus();
|
|
2151
2293
|
this.drag.dispose();
|
|
2152
2294
|
this.agent.dispose();
|
|
2295
|
+
this.incoming.dispose();
|
|
2153
2296
|
try {
|
|
2154
2297
|
await this.rpc.call("session.disconnect", {});
|
|
2155
2298
|
} finally {
|
|
@@ -2204,6 +2347,11 @@ function createMindooDBAppBridge() {
|
|
|
2204
2347
|
export {
|
|
2205
2348
|
MINDOODB_APP_VALUE_TAG,
|
|
2206
2349
|
MindooDBAppValue,
|
|
2350
|
+
MINDOODB_CUSTOM_DOCUMENT_ID_PATTERN,
|
|
2351
|
+
MINDOODB_DOCUMENT_ID_PREFIX_PATTERN,
|
|
2352
|
+
isValidMindooDBDocumentId,
|
|
2353
|
+
mindooDBDocumentId,
|
|
2354
|
+
assertValidMindooDBCreateIds,
|
|
2207
2355
|
MINDOODB_APP_MAX_DRAG_TYPES,
|
|
2208
2356
|
MINDOODB_APP_MAX_DRAG_PAYLOAD_BYTES,
|
|
2209
2357
|
MINDOODB_APP_MAX_DRAG_PREVIEW_BYTES,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppDragBindSourceOptions, b as MindooDBAppDragStartInput, c as MindooDBAppDragStartResult, d as MindooDBAppDragPreview, e as MindooDBAppBridge, f as MindooDBAppAgentToolErrorCode, g as MindooDBAppHostShortcutBinding, h as MindooDBAppHostShortcutAction, i as MindooDBAppHostingMode, j as MindooDBAppDefinition, k as MindooDBAppDatabase, l as MindooDBAppDocument, m as MindooDBAppRichTextSpan, n as MindooDBAppRichTextSnapshot, o as MindooDBAppCreateDocumentInput } from './types-
|
|
2
|
-
export { p as
|
|
1
|
+
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppDragBindSourceOptions, b as MindooDBAppDragStartInput, c as MindooDBAppDragStartResult, d as MindooDBAppDragPreview, e as MindooDBAppBridge, f as MindooDBAppAgentToolErrorCode, g as MindooDBAppHostShortcutBinding, h as MindooDBAppHostShortcutAction, i as MindooDBAppHostingMode, j as MindooDBAppDefinition, k as MindooDBAppDatabase, l as MindooDBAppDocument, m as MindooDBAppRichTextSpan, n as MindooDBAppRichTextSnapshot, o as MindooDBAppCreateDocumentInput } from './types-DkzIJKBw.js';
|
|
2
|
+
export { p as MINDOODB_APP_ACCEPTS_MAX, q as MINDOODB_APP_DEFINITION_FILE_NAME, r as MINDOODB_APP_DEFINITION_FORMAT, s as MINDOODB_APP_DEFINITION_PERMISSIONS, t as MINDOODB_APP_DEFINITION_REGISTRATION_PERMISSIONS, u as MINDOODB_APP_DEFINITION_VERSION, v as MINDOODB_APP_LISTING_DESCRIPTION_MAX, w as MINDOODB_APP_LISTING_MAX_SCREENSHOTS, x as MINDOODB_APP_LISTING_SUMMARY_MAX, y as MINDOODB_APP_SEAL_SIGNING_DOMAIN, z as MINDOODB_APP_WELL_KNOWN_DRAG_TYPES, A as MindooDBAppAcceptSpec, B as MindooDBAppAccessDecision, C as MindooDBAppAccessTier, D as MindooDBAppAgentApi, E as MindooDBAppAgentRegistration, F as MindooDBAppAgentTool, G as MindooDBAppAgentToolAnnotations, H as MindooDBAppAgentToolDescriptor, I as MindooDBAppAttachmentApi, J as MindooDBAppAttachmentChunk, K as MindooDBAppAttachmentInfo, L as MindooDBAppAttachmentPreviewOptions, N as MindooDBAppAttachmentPreviewSession, O as MindooDBAppAutomergeChangesPatch, P as MindooDBAppAutomergeChangesSince, Q as MindooDBAppAutomergeGetOptions, R as MindooDBAppAutomergePatchResult, S as MindooDBAppAutomergeSnapshot, T as MindooDBAppBridgeAgentInvokeMessage, U as MindooDBAppBridgeAgentResultMessage, V as MindooDBAppBridgeBeforeCloseAck, W as MindooDBAppBridgeBeforeCloseMessage, X as MindooDBAppBridgeConnectMessage, Y as MindooDBAppBridgeConnectOptions, Z as MindooDBAppBridgeConnectedMessage, _ as MindooDBAppBridgeDragDropMessage, $ as MindooDBAppBridgeDragLeaveMessage, a0 as MindooDBAppBridgeDragOverMessage, a1 as MindooDBAppBridgeErrorPayload, a2 as MindooDBAppBridgeHandshakeErrorMessage, a3 as MindooDBAppBridgeHostFocusChangedMessage, a4 as MindooDBAppBridgeIncomingContentMessage, a5 as MindooDBAppBridgeLocaleChangedMessage, a6 as MindooDBAppBridgePortMessage, a7 as MindooDBAppBridgeQueryResultMessage, a8 as MindooDBAppBridgeRpcError, a9 as MindooDBAppBridgeRpcMessage, aa as MindooDBAppBridgeRpcRequest, ab as MindooDBAppBridgeRpcSuccess, ac as MindooDBAppBridgeShortcutInvokedMessage, ad as MindooDBAppBridgeShortcutsChangedMessage, ae as MindooDBAppBridgeStreamAbortRequest, af as MindooDBAppBridgeStreamAck, ag as MindooDBAppBridgeStreamCloseRequest, ah as MindooDBAppBridgeStreamError, ai as MindooDBAppBridgeStreamMessage, aj as MindooDBAppBridgeStreamOpenResult, ak as MindooDBAppBridgeStreamReadRequest, al as MindooDBAppBridgeStreamWriteRequest, am as MindooDBAppBridgeThemeChangedMessage, an as MindooDBAppBridgeUiPreferencesChangedMessage, ao as MindooDBAppBridgeViewChangedMessage, ap as MindooDBAppBridgeViewportChangedMessage, aq as MindooDBAppBridgeWorkspaceFocusRequestedMessage, ar as MindooDBAppBrowserFeatures, as as MindooDBAppCapability, at as MindooDBAppConfiguredViewCategorizationStyle, au as MindooDBAppConfiguredViewColumn, av as MindooDBAppConfiguredViewColumnRole, aw as MindooDBAppConfiguredViewExpressionMode, ax as MindooDBAppConfiguredViewFieldExpression, ay as MindooDBAppConfiguredViewFilterDefinition, az as MindooDBAppConfiguredViewFilterMode, aA as MindooDBAppConfiguredViewFilterRule, aB as MindooDBAppConfiguredViewFormulaExpression, aC as MindooDBAppConfiguredViewFormulaFilterDefinition, aD as MindooDBAppConfiguredViewPreviewMode, aE as MindooDBAppConfiguredViewRuleFilterDefinition, aF as MindooDBAppConfiguredViewRuleMatchMode, aG as MindooDBAppConfiguredViewRuleOperator, aH as MindooDBAppConfiguredViewValueExpression, aI as MindooDBAppCreateKeyInfo, aJ as MindooDBAppCreateViewInput, aK as MindooDBAppCreateViewNavigatorInput, aL as MindooDBAppDatabaseInfo, aM as MindooDBAppDefinitionDatabase, aN as MindooDBAppDefinitionListing, aO as MindooDBAppDefinitionPermission, aP as MindooDBAppDefinitionRegistrationPermission, aQ as MindooDBAppDefinitionScreenshot, aR as MindooDBAppDefinitionValidation, aS as MindooDBAppDirectoryApi, aT as MindooDBAppDirectoryEntry, aU as MindooDBAppDocumentApi, aV as MindooDBAppDocumentHeadCursorResult, aW as MindooDBAppDocumentHistoryEntry, aX as MindooDBAppDocumentListQuery, aY as MindooDBAppDocumentListResult, aZ as MindooDBAppDocumentQuery, a_ as MindooDBAppDocumentRevisionId, a$ as MindooDBAppDocumentScanPreset, b0 as MindooDBAppDocumentSummary, b1 as MindooDBAppDragApi, b2 as MindooDBAppDragCancelReason, b3 as MindooDBAppDragDropEvent, b4 as MindooDBAppDragEffect, b5 as MindooDBAppDragHoverResult, b6 as MindooDBAppDragOffer, b7 as MindooDBAppDragOverEvent, b8 as MindooDBAppDragPointer, b9 as MindooDBAppDragProfile, ba as MindooDBAppEntryAttachmentRef, bb as MindooDBAppEntryProvenance, bc as MindooDBAppExtractDocumentTextInput, bd as MindooDBAppExtractDocumentTextResult, be as MindooDBAppExtractTextFormat, bf as MindooDBAppExtractionSetup, bg as MindooDBAppFulltextSetup, bh as MindooDBAppHistoricalDocument, bi as MindooDBAppHistoryQuery, bj as MindooDBAppHostTheme, bk as MindooDBAppIdentityApi, bl as MindooDBAppInaccessibleDocument, bm as MindooDBAppInaccessibleDocumentListQuery, bn as MindooDBAppInaccessibleDocumentListResult, bo as MindooDBAppIncomingContent, bp as MindooDBAppIncomingContentHandler, bq as MindooDBAppIncomingContentInfo, br as MindooDBAppIncomingItem, bs as MindooDBAppIncomingItemInfo, bt as MindooDBAppIncomingResult, bu as MindooDBAppIncomingSource, bv as MindooDBAppJsonCounterIncrementPatch, bw as MindooDBAppJsonListDeletePatch, bx as MindooDBAppJsonListInsertPatch, by as MindooDBAppJsonPatch, bz as MindooDBAppJsonSetPatch, bA as MindooDBAppJsonTextMarkPatch, bB as MindooDBAppJsonTextSplicePatch, bC as MindooDBAppJsonTextUnmarkPatch, bD as MindooDBAppJsonUnsetPatch, bE as MindooDBAppLaunchContext, bF as MindooDBAppListUsersOptions, bG as MindooDBAppListUsersPage, bH as MindooDBAppLiveQuerySubscription, bI as MindooDBAppLocalizedText, bJ as MindooDBAppMenuAnchor, bK as MindooDBAppMenuApi, bL as MindooDBAppMenuCommandItem, bM as MindooDBAppMenuDismissReason, bN as MindooDBAppMenuDismissedResult, bO as MindooDBAppMenuItem, bP as MindooDBAppMenuKind, bQ as MindooDBAppMenuPlacement, bR as MindooDBAppMenuPointAnchor, bS as MindooDBAppMenuRect, bT as MindooDBAppMenuRectAnchor, bU as MindooDBAppMenuSelectionResult, bV as MindooDBAppMenuSeparatorItem, bW as MindooDBAppNotificationSeverity, bX as MindooDBAppNotifyInput, bY as MindooDBAppNotifyResult, bZ as MindooDBAppProposeAppInput, b_ as MindooDBAppProposeAppResult, b$ as MindooDBAppQueryCoverage, c0 as MindooDBAppQueryInclude, c1 as MindooDBAppQueryIncludeCardinality, c2 as MindooDBAppQueryIncludeSlots, c3 as MindooDBAppQueryResult, c4 as MindooDBAppQueryRow, c5 as MindooDBAppQuerySortKey, c6 as MindooDBAppQueryTextClause, c7 as MindooDBAppReadableAttachmentStream, c8 as MindooDBAppRecipientOptions, c9 as MindooDBAppResolvedViewDefinition, ca as MindooDBAppResolvedViewSource, cb as MindooDBAppRevisionPhase, cc as MindooDBAppRevisionVerification, cd as MindooDBAppRichTextBlockSpan, ce as MindooDBAppRichTextGetOptions, cf as MindooDBAppRichTextImmutableString, cg as MindooDBAppRichTextMarkRange, ch as MindooDBAppRichTextMaterializeValue, ci as MindooDBAppRichTextPatch, cj as MindooDBAppRichTextScalar, ck as MindooDBAppRichTextSpliceStep, cl as MindooDBAppRichTextStep, cm as MindooDBAppRichTextStepPatch, cn as MindooDBAppRichTextTextSpan, co as MindooDBAppRuntime, cp as MindooDBAppScanAttachmentOptions, cq as MindooDBAppScanAttachmentResult, cr as MindooDBAppScopedDocId, cs as MindooDBAppScopedDocumentSummary, ct as MindooDBAppSealIntent, cu as MindooDBAppSealedChannelOpenInput, cv as MindooDBAppSealedChannelOpenResult, cw as MindooDBAppSealedChannelRequestInput, cx as MindooDBAppSession, cy as MindooDBAppShowMenuInput, cz as MindooDBAppShowMenuResult, cA as MindooDBAppSignPreview, cB as MindooDBAppSignPreviewScope, cC as MindooDBAppSignStatementInput, cD as MindooDBAppSignStatementResult, cE as MindooDBAppStorageApi, cF as MindooDBAppSummarySetup, cG as MindooDBAppTextCursorOptions, cH as MindooDBAppTextCursorPosition, cI as MindooDBAppTextCursorPositionsResult, cJ as MindooDBAppTextCursorsResult, cK as MindooDBAppTextEdit, cL as MindooDBAppTextPatch, cM as MindooDBAppThemeMode, cN as MindooDBAppTimestampApi, cO as MindooDBAppTimestampInput, cP as MindooDBAppTimestampProvider, cQ as MindooDBAppTimestampResult, cR as MindooDBAppUiPreferences, cS as MindooDBAppUpdateDocumentInput, cT as MindooDBAppViewCursorDocumentListResult, cU as MindooDBAppViewCursorResult, cV as MindooDBAppViewEntry, cW as MindooDBAppViewEntryKind, cX as MindooDBAppViewNavigator, cY as MindooDBAppViewNavigatorExpansionState, cZ as MindooDBAppViewNavigatorOpenOptions, c_ as MindooDBAppViewNavigatorPageOptions, c$ as MindooDBAppViewNavigatorPageResult, d0 as MindooDBAppViewNavigatorRangeQuery, d1 as MindooDBAppViewNavigatorSelectionState, d2 as MindooDBAppViewUpdateStats, d3 as MindooDBAppViewport, d4 as MindooDBAppWellKnownDragType, d5 as MindooDBAppWritableAttachmentStream, d6 as mindooDBAppAcceptMatchesType, d7 as resolveMindooDBAppDefinitionUrl, d8 as resolveMindooDBAppListingAssetUrl, d9 as resolveMindooDBAppLocalizedText, da as validateMindooDBAppAccepts, db as validateMindooDBAppDefinition } from './types-DkzIJKBw.js';
|
|
3
3
|
export { M as MINDOODB_APP_BUNDLE_ARCHIVE_FILE_NAME, a as MINDOODB_APP_BUNDLE_MANIFEST_FILE_NAME, b as MINDOODB_APP_BUNDLE_MANIFEST_FORMAT, c as MINDOODB_APP_BUNDLE_MANIFEST_VERSION, d as MindooDBAppBundleArchive, e as MindooDBAppBundleFileEntry, f as MindooDBAppBundleHash, g as MindooDBAppBundleManifest, h as MindooDBAppBundleManifestValidation, i as buildMindooDBAppBundleContentHashInput, j as isMindooDBAppBundleHash, n as normalizeMindooDBAppBundlePath, v as validateMindooDBAppBundleManifest } from './appBundleManifest-B0xfpaXG.js';
|
|
4
4
|
import { MindooDBAppBooleanExpression } from 'mindoodb-view-language';
|
|
5
5
|
export { MindooDBAppBooleanExpression, MindooDBAppExpression, MindooDBAppFilterDefinition, MindooDBAppViewCategoryChildrenPageRequest, MindooDBAppViewColumn, MindooDBAppViewColumnRole, MindooDBAppViewDefinition, MindooDBAppViewExpansionState, MindooDBAppViewExpressionBase, MindooDBAppViewExpressionDatePart, MindooDBAppViewExpressionOperation, MindooDBAppViewFieldExpression, MindooDBAppViewIfExpression, MindooDBAppViewLetExpression, MindooDBAppViewLiteralExpression, MindooDBAppViewLookupByPath, MindooDBAppViewOperationExpression, MindooDBAppViewOriginExpression, MindooDBAppViewPageRequest, MindooDBAppViewPageResult, MindooDBAppViewRow, MindooDBAppViewSortDirection, MindooDBAppViewTotalMode, MindooDBAppViewValueExpressionRef, MindooDBAppViewVariableExpression, createViewLanguage } from 'mindoodb-view-language';
|
|
@@ -57,6 +57,39 @@ declare const MindooDBAppValue: {
|
|
|
57
57
|
readonly isTyped: (value: unknown) => value is MindooDBAppTypedValue;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Rules for document ids an app chooses itself, as MindooDB enforces them
|
|
62
|
+
* (`CUSTOM_DOC_ID_REGEX` / `DOC_ID_PREFIX_REGEX` in mindoodb's core types).
|
|
63
|
+
* The mock database applies the same checks, so tests fail where Haven would.
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* A caller-provided document id (`documents.create({ id })`): a lowercase ASCII
|
|
67
|
+
* letter first, then lowercase ASCII letters, digits or `_`. Generated ids
|
|
68
|
+
* (ObjectIds, hex) may start with a digit, so never use one as a prefix as is.
|
|
69
|
+
*/
|
|
70
|
+
declare const MINDOODB_CUSTOM_DOCUMENT_ID_PATTERN: RegExp;
|
|
71
|
+
/**
|
|
72
|
+
* An `idPrefix` for generated ids: 1–10 lowercase ASCII letters or digits,
|
|
73
|
+
* starting with a letter, no `_` (MindooDB appends `_<objectid>` itself).
|
|
74
|
+
*/
|
|
75
|
+
declare const MINDOODB_DOCUMENT_ID_PREFIX_PATTERN: RegExp;
|
|
76
|
+
/** Whether `id` is accepted as a caller-provided document id. */
|
|
77
|
+
declare function isValidMindooDBDocumentId(id: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* A valid caller-provided document id from `prefix` and `parts`, joined with
|
|
80
|
+
* `_`: each part lowercased, other characters replaced by `_`. `prefix` must
|
|
81
|
+
* start with a lowercase letter (e.g. `documentId("game", workbookId, n)`).
|
|
82
|
+
*/
|
|
83
|
+
declare function mindooDBDocumentId(prefix: string, ...parts: Array<string | number>): string;
|
|
84
|
+
/**
|
|
85
|
+
* Throws the host's error when `input` carries an invalid `id` or `idPrefix`.
|
|
86
|
+
* `methodName` is the prefix of the message (Haven reports `createDocument`).
|
|
87
|
+
*/
|
|
88
|
+
declare function assertValidMindooDBCreateIds(input: {
|
|
89
|
+
id?: string;
|
|
90
|
+
idPrefix?: string;
|
|
91
|
+
}, methodName?: string): void;
|
|
92
|
+
|
|
60
93
|
/**
|
|
61
94
|
* Resolves whether Haven can render a built-in preview for an attachment.
|
|
62
95
|
*
|
|
@@ -578,4 +611,4 @@ declare function inheritDocumentEncryption(parent: Pick<MindooDBAppDocument, "de
|
|
|
578
611
|
*/
|
|
579
612
|
declare function watchWordChunks(database: MindooDBAppDatabase, parentId: string, listener: (docIds: string[]) => void): Promise<() => Promise<void>>;
|
|
580
613
|
|
|
581
|
-
export { type CreateMindooDBRichTextHandleOptions, type CreateMindooDBTextBufferOptions, DEFAULT_DRAG_LONG_PRESS_MS, DEFAULT_DRAG_POINTER_THRESHOLD_PX, DEFAULT_HAVEN_HOST_SHORTCUTS, DEFAULT_HAVEN_URL, type HavenAppLandingPage, type HavenStorageShimHandle, type InstallHavenStorageShimOptions, type ListingBlock, type ListingInline, MINDOODB_APP_HOSTING_QUERY_PARAM, MINDOODB_APP_LAUNCH_ID_QUERY_PARAM, MINDOODB_APP_MAX_DRAG_PAYLOAD_BYTES, MINDOODB_APP_MAX_DRAG_PREVIEW_BYTES, MINDOODB_APP_MAX_DRAG_PREVIEW_EDGE, MINDOODB_APP_MAX_DRAG_TYPES, MINDOODB_APP_VALUE_TAG, MINIMAL_DRAG_PREVIEW_PNG, MindooDBAppAgentToolError, MindooDBAppAgentToolErrorCode, type MindooDBAppAtomicValue, MindooDBAppAttachmentPreviewMode, MindooDBAppBridge, type MindooDBAppCounterValue, MindooDBAppCreateDocumentInput, MindooDBAppDatabase, MindooDBAppDefinition, MindooDBAppDocument, MindooDBAppDragBindSourceOptions, MindooDBAppDragInputError, MindooDBAppDragPreview, MindooDBAppDragStartInput, MindooDBAppDragStartResult, MindooDBAppHostShortcutAction, MindooDBAppHostShortcutBinding, MindooDBAppHostingMode, MindooDBAppRichTextSnapshot, MindooDBAppRichTextSpan, type MindooDBAppTimestampValue, type MindooDBAppTypedValue, MindooDBAppValue, MindooDBRichTextHandle, type MindooDBRichTextHandleChangeListener, type MindooDBRichTextHandleFlushResult, MindooDBTextBuffer, type MindooDBTextBufferFlushResult, type RenderHavenAppLandingPageOptions, abbreviateCanonicalName, applyHostedDocumentOverscrollContain, bindDragSource, buildHavenAppInstallUrl, canPreviewAttachment, createMindooDBAppBridge, createMindooDBRichTextHandle, createMindooDBTextBuffer, expandAbbreviatedName, inheritDocumentEncryption, installHavenStorageShim, installHostShortcutCapture, isHostShortcutAction, isHostedBundleRuntime, isLaunchedByHaven, isMindooDBAppDragType, listingMarkdownToPlainText, matchHostShortcut, normalizeDragAccepts, normalizeDragPointerInput, normalizeDragStartInput, parseListingMarkdown, queryDocuments, readMindooDBAppHostingMode, readMindooDBAppLaunchId, releaseMindooDBAppBridgeSessions, renderHavenAppLandingPage, resolveCurrentHavenAppUrl, sanitizeHostShortcutBindings, sanitizeListingHref, snapshotElementToPng, watchWordChunks };
|
|
614
|
+
export { type CreateMindooDBRichTextHandleOptions, type CreateMindooDBTextBufferOptions, DEFAULT_DRAG_LONG_PRESS_MS, DEFAULT_DRAG_POINTER_THRESHOLD_PX, DEFAULT_HAVEN_HOST_SHORTCUTS, DEFAULT_HAVEN_URL, type HavenAppLandingPage, type HavenStorageShimHandle, type InstallHavenStorageShimOptions, type ListingBlock, type ListingInline, MINDOODB_APP_HOSTING_QUERY_PARAM, MINDOODB_APP_LAUNCH_ID_QUERY_PARAM, MINDOODB_APP_MAX_DRAG_PAYLOAD_BYTES, MINDOODB_APP_MAX_DRAG_PREVIEW_BYTES, MINDOODB_APP_MAX_DRAG_PREVIEW_EDGE, MINDOODB_APP_MAX_DRAG_TYPES, MINDOODB_APP_VALUE_TAG, MINDOODB_CUSTOM_DOCUMENT_ID_PATTERN, MINDOODB_DOCUMENT_ID_PREFIX_PATTERN, MINIMAL_DRAG_PREVIEW_PNG, MindooDBAppAgentToolError, MindooDBAppAgentToolErrorCode, type MindooDBAppAtomicValue, MindooDBAppAttachmentPreviewMode, MindooDBAppBridge, type MindooDBAppCounterValue, MindooDBAppCreateDocumentInput, MindooDBAppDatabase, MindooDBAppDefinition, MindooDBAppDocument, MindooDBAppDragBindSourceOptions, MindooDBAppDragInputError, MindooDBAppDragPreview, MindooDBAppDragStartInput, MindooDBAppDragStartResult, MindooDBAppHostShortcutAction, MindooDBAppHostShortcutBinding, MindooDBAppHostingMode, MindooDBAppRichTextSnapshot, MindooDBAppRichTextSpan, type MindooDBAppTimestampValue, type MindooDBAppTypedValue, MindooDBAppValue, MindooDBRichTextHandle, type MindooDBRichTextHandleChangeListener, type MindooDBRichTextHandleFlushResult, MindooDBTextBuffer, type MindooDBTextBufferFlushResult, type RenderHavenAppLandingPageOptions, abbreviateCanonicalName, applyHostedDocumentOverscrollContain, assertValidMindooDBCreateIds, bindDragSource, buildHavenAppInstallUrl, canPreviewAttachment, createMindooDBAppBridge, createMindooDBRichTextHandle, createMindooDBTextBuffer, expandAbbreviatedName, inheritDocumentEncryption, installHavenStorageShim, installHostShortcutCapture, isHostShortcutAction, isHostedBundleRuntime, isLaunchedByHaven, isMindooDBAppDragType, isValidMindooDBDocumentId, listingMarkdownToPlainText, matchHostShortcut, mindooDBDocumentId, normalizeDragAccepts, normalizeDragPointerInput, normalizeDragStartInput, parseListingMarkdown, queryDocuments, readMindooDBAppHostingMode, readMindooDBAppLaunchId, releaseMindooDBAppBridgeSessions, renderHavenAppLandingPage, resolveCurrentHavenAppUrl, sanitizeHostShortcutBindings, sanitizeListingHref, snapshotElementToPng, watchWordChunks };
|
package/dist/index.js
CHANGED
|
@@ -7,24 +7,29 @@ import {
|
|
|
7
7
|
MINDOODB_APP_MAX_DRAG_PREVIEW_EDGE,
|
|
8
8
|
MINDOODB_APP_MAX_DRAG_TYPES,
|
|
9
9
|
MINDOODB_APP_VALUE_TAG,
|
|
10
|
+
MINDOODB_CUSTOM_DOCUMENT_ID_PATTERN,
|
|
11
|
+
MINDOODB_DOCUMENT_ID_PREFIX_PATTERN,
|
|
10
12
|
MINIMAL_DRAG_PREVIEW_PNG,
|
|
11
13
|
MindooDBAppAgentToolError,
|
|
12
14
|
MindooDBAppDragInputError,
|
|
13
15
|
MindooDBAppValue,
|
|
14
16
|
applyHostedDocumentOverscrollContain,
|
|
17
|
+
assertValidMindooDBCreateIds,
|
|
15
18
|
bindDragSource,
|
|
16
19
|
createMindooDBAppBridge,
|
|
17
20
|
installHostShortcutCapture,
|
|
18
21
|
isHostShortcutAction,
|
|
19
22
|
isMindooDBAppDragType,
|
|
23
|
+
isValidMindooDBDocumentId,
|
|
20
24
|
matchHostShortcut,
|
|
25
|
+
mindooDBDocumentId,
|
|
21
26
|
normalizeDragAccepts,
|
|
22
27
|
normalizeDragPointerInput,
|
|
23
28
|
normalizeDragStartInput,
|
|
24
29
|
releaseMindooDBAppBridgeSessions,
|
|
25
30
|
sanitizeHostShortcutBindings,
|
|
26
31
|
snapshotElementToPng
|
|
27
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-SKPP4T6S.js";
|
|
28
33
|
import {
|
|
29
34
|
MINDOODB_APP_BUNDLE_ARCHIVE_FILE_NAME,
|
|
30
35
|
MINDOODB_APP_BUNDLE_MANIFEST_FILE_NAME,
|
|
@@ -244,6 +249,80 @@ function readLocalizedText(value, label, maxLength, errors) {
|
|
|
244
249
|
}
|
|
245
250
|
return result;
|
|
246
251
|
}
|
|
252
|
+
var MINDOODB_APP_ACCEPTS_MAX = 16;
|
|
253
|
+
var ACCEPT_ID_PATTERN = /^[a-z0-9][a-z0-9_-]{0,47}$/;
|
|
254
|
+
var ACCEPT_TYPE_PATTERN = /^(\*|[a-z0-9][a-z0-9.+-]*)\/(\*|[a-z0-9][a-z0-9.+-]*)$/i;
|
|
255
|
+
function readAccepts(value, errors) {
|
|
256
|
+
if (value === void 0 || value === null) {
|
|
257
|
+
return void 0;
|
|
258
|
+
}
|
|
259
|
+
if (!Array.isArray(value)) {
|
|
260
|
+
errors.push("App definition accepts must be an array.");
|
|
261
|
+
return void 0;
|
|
262
|
+
}
|
|
263
|
+
if (value.length > MINDOODB_APP_ACCEPTS_MAX) {
|
|
264
|
+
errors.push(`App definition accepts must not have more than ${MINDOODB_APP_ACCEPTS_MAX} entries.`);
|
|
265
|
+
return void 0;
|
|
266
|
+
}
|
|
267
|
+
const result = [];
|
|
268
|
+
const ids = /* @__PURE__ */ new Set();
|
|
269
|
+
value.forEach((entry, index) => {
|
|
270
|
+
const label = `App definition accepts[${index}]`;
|
|
271
|
+
if (!isPlainObject(entry)) {
|
|
272
|
+
errors.push(`${label} must be an object.`);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const id = typeof entry.id === "string" ? entry.id.trim() : "";
|
|
276
|
+
if (!ACCEPT_ID_PATTERN.test(id)) {
|
|
277
|
+
errors.push(`${label}.id must be 1-48 lowercase letters, digits, "-" or "_", received ${JSON.stringify(entry.id)}.`);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (ids.has(id)) {
|
|
281
|
+
errors.push(`${label}.id "${id}" is used twice.`);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
ids.add(id);
|
|
285
|
+
const text = readLocalizedText(entry.label, `${label}.label`, 80, errors);
|
|
286
|
+
if (!text) {
|
|
287
|
+
errors.push(`${label}.label is required.`);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (!Array.isArray(entry.types) || !entry.types.length) {
|
|
291
|
+
errors.push(`${label}.types must be a non-empty array of MIME patterns.`);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const types = [];
|
|
295
|
+
for (const type of entry.types) {
|
|
296
|
+
if (typeof type !== "string" || !ACCEPT_TYPE_PATTERN.test(type.trim())) {
|
|
297
|
+
errors.push(`${label}.types contains an invalid MIME pattern ${JSON.stringify(type)}.`);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
types.push(type.trim().toLowerCase());
|
|
301
|
+
}
|
|
302
|
+
const folders = readOptionalBoolean(entry, "folders", errors);
|
|
303
|
+
const multiple = readOptionalBoolean(entry, "multiple", errors);
|
|
304
|
+
let maxBytes;
|
|
305
|
+
if (entry.maxBytes !== void 0) {
|
|
306
|
+
if (typeof entry.maxBytes !== "number" || !Number.isSafeInteger(entry.maxBytes) || entry.maxBytes <= 0) {
|
|
307
|
+
errors.push(`${label}.maxBytes must be a positive integer.`);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
maxBytes = entry.maxBytes;
|
|
311
|
+
}
|
|
312
|
+
result.push({ id, label: text, types, folders, multiple, maxBytes });
|
|
313
|
+
});
|
|
314
|
+
return result.length ? result : void 0;
|
|
315
|
+
}
|
|
316
|
+
function validateMindooDBAppAccepts(value) {
|
|
317
|
+
const errors = [];
|
|
318
|
+
const accepts = readAccepts(value, errors);
|
|
319
|
+
return { accepts: errors.length ? void 0 : accepts, errors };
|
|
320
|
+
}
|
|
321
|
+
function mindooDBAppAcceptMatchesType(pattern, type) {
|
|
322
|
+
const [patternMajor, patternMinor] = pattern.toLowerCase().split("/");
|
|
323
|
+
const [major, minor] = (type || "application/octet-stream").toLowerCase().split(";")[0].trim().split("/");
|
|
324
|
+
return (patternMajor === "*" || patternMajor === major) && (patternMinor === "*" || patternMinor === minor);
|
|
325
|
+
}
|
|
247
326
|
function readListingAssetPath(value, label, errors) {
|
|
248
327
|
if (value === void 0 || value === null) {
|
|
249
328
|
return void 0;
|
|
@@ -410,9 +489,18 @@ function validateMindooDBAppDefinition(raw) {
|
|
|
410
489
|
const allowCamera = readOptionalBoolean(raw, "allowCamera", errors);
|
|
411
490
|
const allowMicrophone = readOptionalBoolean(raw, "allowMicrophone", errors);
|
|
412
491
|
const allowGeolocation = readOptionalBoolean(raw, "allowGeolocation", errors);
|
|
492
|
+
const allowClipboardWrite = readOptionalBoolean(raw, "allowClipboardWrite", errors);
|
|
493
|
+
const allowMotion = readOptionalBoolean(raw, "allowMotion", errors);
|
|
413
494
|
const allowWebRtc = readOptionalBoolean(raw, "allowWebRtc", errors);
|
|
414
495
|
const allowWorkers = readOptionalBoolean(raw, "allowWorkers", errors);
|
|
415
496
|
const listing = readListing(raw.listing, errors);
|
|
497
|
+
const accepts = readAccepts(raw.accepts, errors);
|
|
498
|
+
const agentToolPrefix = readOptionalString(raw, "agentToolPrefix", errors);
|
|
499
|
+
if (agentToolPrefix !== void 0 && (!/^[a-z][a-z0-9_]{0,15}$/.test(agentToolPrefix) || agentToolPrefix.endsWith("_") || /^haven(?:_|$)/.test(agentToolPrefix))) {
|
|
500
|
+
errors.push(
|
|
501
|
+
`App definition agentToolPrefix must be 1-16 lowercase letters, digits or "_", start with a letter and not be "haven", received ${JSON.stringify(agentToolPrefix)}.`
|
|
502
|
+
);
|
|
503
|
+
}
|
|
416
504
|
if (defaultLaunchDatabaseId && databases && !databases.some((database) => database.logicalDatabaseId === defaultLaunchDatabaseId)) {
|
|
417
505
|
errors.push(
|
|
418
506
|
`App definition defaultLaunchDatabaseId "${defaultLaunchDatabaseId}" is not one of the declared databases.`
|
|
@@ -436,12 +524,16 @@ function validateMindooDBAppDefinition(raw) {
|
|
|
436
524
|
allowCamera,
|
|
437
525
|
allowMicrophone,
|
|
438
526
|
allowGeolocation,
|
|
527
|
+
allowClipboardWrite,
|
|
528
|
+
allowMotion,
|
|
439
529
|
allowWebRtc,
|
|
440
530
|
allowWorkers,
|
|
531
|
+
agentToolPrefix,
|
|
441
532
|
permissions,
|
|
442
533
|
launchParameters,
|
|
443
534
|
defaultLaunchDatabaseId,
|
|
444
535
|
databases,
|
|
536
|
+
accepts,
|
|
445
537
|
listing
|
|
446
538
|
},
|
|
447
539
|
errors: []
|
|
@@ -1680,6 +1772,7 @@ export {
|
|
|
1680
1772
|
DEFAULT_DRAG_POINTER_THRESHOLD_PX,
|
|
1681
1773
|
DEFAULT_HAVEN_HOST_SHORTCUTS,
|
|
1682
1774
|
DEFAULT_HAVEN_URL,
|
|
1775
|
+
MINDOODB_APP_ACCEPTS_MAX,
|
|
1683
1776
|
MINDOODB_APP_BUNDLE_ARCHIVE_FILE_NAME,
|
|
1684
1777
|
MINDOODB_APP_BUNDLE_MANIFEST_FILE_NAME,
|
|
1685
1778
|
MINDOODB_APP_BUNDLE_MANIFEST_FORMAT,
|
|
@@ -1701,6 +1794,8 @@ export {
|
|
|
1701
1794
|
MINDOODB_APP_SEAL_SIGNING_DOMAIN,
|
|
1702
1795
|
MINDOODB_APP_VALUE_TAG,
|
|
1703
1796
|
MINDOODB_APP_WELL_KNOWN_DRAG_TYPES,
|
|
1797
|
+
MINDOODB_CUSTOM_DOCUMENT_ID_PATTERN,
|
|
1798
|
+
MINDOODB_DOCUMENT_ID_PREFIX_PATTERN,
|
|
1704
1799
|
MINIMAL_DRAG_PREVIEW_PNG,
|
|
1705
1800
|
MindooDBAppAgentToolError,
|
|
1706
1801
|
MindooDBAppDragInputError,
|
|
@@ -1709,6 +1804,7 @@ export {
|
|
|
1709
1804
|
MindooDBTextBuffer,
|
|
1710
1805
|
abbreviateCanonicalName,
|
|
1711
1806
|
applyHostedDocumentOverscrollContain,
|
|
1807
|
+
assertValidMindooDBCreateIds,
|
|
1712
1808
|
bindDragSource,
|
|
1713
1809
|
buildHavenAppInstallUrl,
|
|
1714
1810
|
buildMindooDBAppBundleContentHashInput,
|
|
@@ -1726,8 +1822,11 @@ export {
|
|
|
1726
1822
|
isLaunchedByHaven,
|
|
1727
1823
|
isMindooDBAppBundleHash,
|
|
1728
1824
|
isMindooDBAppDragType,
|
|
1825
|
+
isValidMindooDBDocumentId,
|
|
1729
1826
|
listingMarkdownToPlainText,
|
|
1730
1827
|
matchHostShortcut,
|
|
1828
|
+
mindooDBAppAcceptMatchesType,
|
|
1829
|
+
mindooDBDocumentId,
|
|
1731
1830
|
normalizeDragAccepts,
|
|
1732
1831
|
normalizeDragPointerInput,
|
|
1733
1832
|
normalizeDragStartInput,
|
|
@@ -1745,6 +1844,7 @@ export {
|
|
|
1745
1844
|
sanitizeHostShortcutBindings,
|
|
1746
1845
|
sanitizeListingHref,
|
|
1747
1846
|
snapshotElementToPng,
|
|
1847
|
+
validateMindooDBAppAccepts,
|
|
1748
1848
|
validateMindooDBAppBundleManifest,
|
|
1749
1849
|
validateMindooDBAppDefinition,
|
|
1750
1850
|
watchWordChunks
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aK as MindooDBAppCreateViewNavigatorInput, cX as MindooDBAppViewNavigator, aa as MindooDBAppBridgeRpcRequest, bj as MindooDBAppHostTheme, as as MindooDBAppCapability, j as MindooDBAppDefinition, I as MindooDBAppAttachmentApi, e as MindooDBAppBridge, cx as MindooDBAppSession, bZ as MindooDBAppProposeAppInput, d3 as MindooDBAppViewport, cR as MindooDBAppUiPreferences, c3 as MindooDBAppQueryResult, d2 as MindooDBAppViewUpdateStats, a6 as MindooDBAppBridgePortMessage, aL as MindooDBAppDatabaseInfo, a1 as MindooDBAppBridgeErrorPayload, bE as MindooDBAppLaunchContext, aU as MindooDBAppDocumentApi, cZ as MindooDBAppViewNavigatorOpenOptions, bk as MindooDBAppIdentityApi, cN as MindooDBAppTimestampApi, aS as MindooDBAppDirectoryApi, l as MindooDBAppDocument, bg as MindooDBAppFulltextSetup, bf as MindooDBAppExtractionSetup, cF as MindooDBAppSummarySetup, b_ as MindooDBAppProposeAppResult, bu as MindooDBAppIncomingSource, c as MindooDBAppDragStartResult, b9 as MindooDBAppDragProfile, bt as MindooDBAppIncomingResult } from '../types-DkzIJKBw.js';
|
|
2
2
|
import * as mindoodb from 'mindoodb';
|
|
3
3
|
import 'mindoodb-view-language';
|
|
4
4
|
|
|
@@ -269,9 +269,11 @@ interface MockMindooDBAppDatabaseDefinition {
|
|
|
269
269
|
extractionSetup?: MindooDBAppExtractionSetup | null;
|
|
270
270
|
/**
|
|
271
271
|
* Initial summary buffer configuration returned by `getSummarySetup()`.
|
|
272
|
-
* `setSummarySetup()` overwrites it for the lifetime of the handle.
|
|
273
|
-
* mock's `query()`
|
|
274
|
-
*
|
|
272
|
+
* `setSummarySetup()` overwrites it for the lifetime of the handle. Rows
|
|
273
|
+
* of the mock's `query()` and `liveQuery()` carry only the fields this
|
|
274
|
+
* configuration puts into the summary buffer (MindooDB's defaults when
|
|
275
|
+
* unset), so apps notice nested or oversized fields missing from query
|
|
276
|
+
* results the same way they would in Haven.
|
|
275
277
|
*/
|
|
276
278
|
summarySetup?: MindooDBAppSummarySetup | null;
|
|
277
279
|
}
|
|
@@ -358,6 +360,28 @@ interface MockMindooDBAppSessionController {
|
|
|
358
360
|
emitHostFocusChange(focused: boolean): void;
|
|
359
361
|
resolveDrag(result: MindooDBAppDragStartResult): void;
|
|
360
362
|
getDragProfile(): MindooDBAppDragProfile | null;
|
|
363
|
+
/**
|
|
364
|
+
* Hands content to the app as Haven does after the user picked it in the
|
|
365
|
+
* "send to app" picker. Waits until the app registered `onIncomingContent`
|
|
366
|
+
* and resolves with the handler's result.
|
|
367
|
+
*/
|
|
368
|
+
emitIncomingContent(input: MockIncomingContentInput): Promise<MindooDBAppIncomingResult>;
|
|
369
|
+
}
|
|
370
|
+
/** Content for `emitIncomingContent`. */
|
|
371
|
+
interface MockIncomingContentInput {
|
|
372
|
+
acceptId?: string;
|
|
373
|
+
source?: MindooDBAppIncomingSource;
|
|
374
|
+
items: Array<{
|
|
375
|
+
file: Blob;
|
|
376
|
+
path?: string;
|
|
377
|
+
name?: string;
|
|
378
|
+
} | {
|
|
379
|
+
text: string;
|
|
380
|
+
path?: string;
|
|
381
|
+
} | {
|
|
382
|
+
url: string;
|
|
383
|
+
path?: string;
|
|
384
|
+
}>;
|
|
361
385
|
}
|
|
362
386
|
|
|
363
387
|
declare function createMockMindooDBAppSession(options?: CreateMockMindooDBAppSessionOptions): MockMindooDBAppSessionController;
|
|
@@ -435,4 +459,4 @@ interface FakeBridgeHostController {
|
|
|
435
459
|
}
|
|
436
460
|
declare function createFakeBridgeHost(options?: CreateFakeBridgeHostOptions): FakeBridgeHostController;
|
|
437
461
|
|
|
438
|
-
export { ALL_CAPABILITIES, type BrowserTestHost, type BrowserTestHostLog, type BrowserTestHostScan, type BrowserTestHostScanMode, type CreateBrowserTestHostOptions, type CreateFakeBridgeHostOptions, type CreateMockMindooDBAppSessionOptions, type EvaluatingViewDocument, type FakeBridgeHostController, type FakeBridgePortMessageHandler, type FakeBridgeRequestHandler, type FakeBridgeRpcResponse, type MockDatabaseOverride, type MockDatabasesFromDefinitionOptions, MockForbiddenError, type MockMindooDBAppDatabaseDefinition, type MockMindooDBAppSessionController, type MockSealedChannelOptions, type MockSeedDocument, type MountHavenTestHostOptions, TEST_HOST_LOCALES, type TestHostUrlSettings, capabilitiesForDefinitionPermissions, createBrowserTestHost, createEvaluatingViewNavigator, createFakeBridgeHost, createMemoryAttachments, createMockMindooDBAppBridge, createMockMindooDBAppSession, generateDirectoryUsers, loadMindoodbForTesting, mockDatabasesFromDefinition, mountHavenTestHost, previewJson, readTestHostUrlSettings };
|
|
462
|
+
export { ALL_CAPABILITIES, type BrowserTestHost, type BrowserTestHostLog, type BrowserTestHostScan, type BrowserTestHostScanMode, type CreateBrowserTestHostOptions, type CreateFakeBridgeHostOptions, type CreateMockMindooDBAppSessionOptions, type EvaluatingViewDocument, type FakeBridgeHostController, type FakeBridgePortMessageHandler, type FakeBridgeRequestHandler, type FakeBridgeRpcResponse, type MockDatabaseOverride, type MockDatabasesFromDefinitionOptions, MockForbiddenError, type MockIncomingContentInput, type MockMindooDBAppDatabaseDefinition, type MockMindooDBAppSessionController, type MockSealedChannelOptions, type MockSeedDocument, type MountHavenTestHostOptions, TEST_HOST_LOCALES, type TestHostUrlSettings, capabilitiesForDefinitionPermissions, createBrowserTestHost, createEvaluatingViewNavigator, createFakeBridgeHost, createMemoryAttachments, createMockMindooDBAppBridge, createMockMindooDBAppSession, generateDirectoryUsers, loadMindoodbForTesting, mockDatabasesFromDefinition, mountHavenTestHost, previewJson, readTestHostUrlSettings };
|