mindoodb-app-sdk 0.0.34 → 0.0.37
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 +38 -8
- package/TESTING.md +59 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +54 -1
- package/dist/testing/index.d.ts +37 -2
- package/dist/testing/index.js +642 -13
- package/dist/{types-Bl6CrBn1.d.ts → types-Plb92iSn.d.ts} +105 -4
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -326,7 +326,7 @@ const window = await db.documents.list({
|
|
|
326
326
|
// Read
|
|
327
327
|
const doc = await db.documents.get(docId);
|
|
328
328
|
|
|
329
|
-
// Create (MindooDB generates
|
|
329
|
+
// Create (MindooDB generates an ObjectId; optionally use a named document key)
|
|
330
330
|
const created = await db.documents.create({
|
|
331
331
|
set: { title: "Meeting notes", content: "..." },
|
|
332
332
|
decryptionKeyId: "team-key", // omit to use "default"
|
|
@@ -335,15 +335,16 @@ const created = await db.documents.create({
|
|
|
335
335
|
// Create with a caller-provided id (e.g. a known well-known document the app
|
|
336
336
|
// always loads on launch, or migrating an id from another system).
|
|
337
337
|
const settings = await db.documents.create({
|
|
338
|
-
id: "
|
|
338
|
+
id: "appsettings",
|
|
339
339
|
set: { theme: "dark" },
|
|
340
340
|
});
|
|
341
341
|
// Subsequent calls with the same id return the existing document and DO NOT
|
|
342
342
|
// overwrite `set`, so `documents.create({ id })` is safe to call on every app
|
|
343
343
|
// launch as a "create-if-missing" primitive. Custom ids must match
|
|
344
|
-
// /^[
|
|
345
|
-
//
|
|
346
|
-
//
|
|
344
|
+
// /^[a-z][a-z0-9_]*$/ (lowercase only — ids become on-disk filenames, which are
|
|
345
|
+
// case-insensitive: first char must be a lowercase letter, subsequent chars may
|
|
346
|
+
// be lowercase letters, digits, or `_`). Documents created with the same custom
|
|
347
|
+
// id on different replicas merge correctly when synced.
|
|
347
348
|
|
|
348
349
|
// Update top-level fields
|
|
349
350
|
const updated = await db.documents.update(docId, {
|
|
@@ -990,9 +991,33 @@ const setup = await db.getFulltextSetup(); // null when never configured
|
|
|
990
991
|
```
|
|
991
992
|
|
|
992
993
|
- Without `include`, every non-underscore top-level field with extractable text is indexed (auto mode). Pass `include: ["subject", "body"]` to pin the indexed fields, including nested/long-text fields outside the summary buffer.
|
|
993
|
-
- `attachments: true` indexes attachment text under the synthetic `_attachments` field using the host's extractors (Haven ships
|
|
994
|
+
- `attachments: true` indexes attachment text under the synthetic `_attachments` field using the host's extractors (Haven ships anydoc for Office/PDF/… plus plain-text extractors). Restrict a query to attachment content with `text: { query, fields: ["_attachments"] }`.
|
|
994
995
|
- Changing the configuration (including `language`) rebuilds the index in the background; queries during the rebuild report `coverage: "rebuilding"`.
|
|
995
996
|
|
|
997
|
+
**Extracting text from bytes you already have** (requires `attachments`):
|
|
998
|
+
|
|
999
|
+
```ts
|
|
1000
|
+
const stream = await db.attachments.openReadStream(docId, fileName);
|
|
1001
|
+
const chunks: Uint8Array[] = [];
|
|
1002
|
+
for (;;) {
|
|
1003
|
+
const chunk = await stream.read();
|
|
1004
|
+
if (chunk === null) break;
|
|
1005
|
+
chunks.push(chunk);
|
|
1006
|
+
}
|
|
1007
|
+
await stream.close();
|
|
1008
|
+
const bytes = concatUint8Arrays(chunks); // your helper
|
|
1009
|
+
|
|
1010
|
+
const { text, handled, format, engine } = await db.attachments.extractText({
|
|
1011
|
+
bytes,
|
|
1012
|
+
mimeType: "application/pdf",
|
|
1013
|
+
fileName,
|
|
1014
|
+
format: "markdown", // default — or "plainText"
|
|
1015
|
+
});
|
|
1016
|
+
if (handled) {
|
|
1017
|
+
console.log(engine, format, text.slice(0, 200));
|
|
1018
|
+
}
|
|
1019
|
+
```
|
|
1020
|
+
|
|
996
1021
|
**Live queries** keep a query result up to date. The callback receives the initial result and runs again whenever the result actually changed — the host coalesces bursts of writes and fingerprints results, so you only hear about real changes:
|
|
997
1022
|
|
|
998
1023
|
```ts
|
|
@@ -1387,7 +1412,7 @@ You do **not** need a full Haven environment to test apps that use `mindoodb-app
|
|
|
1387
1412
|
|
|
1388
1413
|
The SDK ships a dedicated `mindoodb-app-sdk/testing` entrypoint with two levels of test helpers:
|
|
1389
1414
|
|
|
1390
|
-
- **Level 1 -- app tests:** Returns a fake `MindooDBAppSession` and bridge for unit, composable, store, and component tests. No `postMessage` or `MessageChannel` involved.
|
|
1415
|
+
- **Level 1 -- app tests:** Returns a fake `MindooDBAppSession` and bridge for unit, composable, store, and component tests. No `postMessage` or `MessageChannel` involved. With the optional `mindoodb` peer, `createViewNavigator` evaluates view definitions against seeded documents (same VirtualView engine as Haven).
|
|
1391
1416
|
- **Level 2 -- bridge protocol tests:** A fake host harness that exercises the real `createMindooDBAppBridge()` handshake over `postMessage` and `MessageChannel`. Useful for integration-style tests.
|
|
1392
1417
|
|
|
1393
1418
|
Use Level 1 when you are testing app behavior. Use Level 2 when you want to validate the bridge transport itself.
|
|
@@ -1469,8 +1494,13 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
|
|
|
1469
1494
|
| `applyAutomergeChanges(docId, patch)` | `Promise<MindooDBAppAutomergePatchResult>` |
|
|
1470
1495
|
| `create(input)` | `Promise<MindooDBAppDocument>` |
|
|
1471
1496
|
| `update(docId, patch)` | `Promise<MindooDBAppDocument>` |
|
|
1497
|
+
| `addRecipients(docId, recipients)` | `Promise<MindooDBAppDocument>` |
|
|
1498
|
+
| `removeRecipients(docId, recipients)` | `Promise<MindooDBAppDocument>` |
|
|
1499
|
+
| `setRecipients(docId, recipients)` | `Promise<MindooDBAppDocument>` |
|
|
1472
1500
|
| `delete(docId)` | `Promise<{ ok: true }>` |
|
|
1473
1501
|
| `undelete(docId)` | `Promise<{ ok: true }>` |
|
|
1502
|
+
| `getDefaultCreateKeyId()` | `Promise<string>` |
|
|
1503
|
+
| `listCreateKeys()` | `Promise<MindooDBAppCreateKeyInfo[]>` |
|
|
1474
1504
|
| `listHistory(docId)` | `Promise<MindooDBAppDocumentHistoryEntry[]>` |
|
|
1475
1505
|
| `getAtTimestamp(docId, timestamp)` | `Promise<MindooDBAppHistoricalDocument>` |
|
|
1476
1506
|
| `getAtRevision(docId, revisionId, opts?)` | `Promise<MindooDBAppHistoricalDocument>` |
|
|
@@ -1480,7 +1510,7 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
|
|
|
1480
1510
|
|
|
1481
1511
|
`list(query?)` accepts the changefeed query options documented above. The `cursor` value is an opaque checkpoint string managed by Haven and should be stored and passed back unchanged.
|
|
1482
1512
|
|
|
1483
|
-
For `create(input)`, use `MindooDBAppCreateDocumentInput` with shape `{ set: Record<string, unknown>; decryptionKeyId?: string; id?: string }`. The optional `id` lets the app pick the document id instead of letting MindooDB generate
|
|
1513
|
+
For `create(input)`, use `MindooDBAppCreateDocumentInput` with shape `{ set: Record<string, unknown>; decryptionKeyId?: string; recipients?: string[]; recipientOptions?: { includeSelf?: boolean }; id?: string }`. Omit both `decryptionKeyId` and `recipients` to use the database default shared key (`getDefaultCreateKeyId()` / `listCreateKeys()`). Pass `recipients` to encrypt the document for specific directory users (the launching user is included unless `recipientOptions.includeSelf` is `false`). Use `includeSelf: false` to write initial `set` values and hand the document to someone else — empty `recipients` with `includeSelf: false` is rejected. Changing that list later is `addRecipients` / `removeRecipients` / `setRecipients` — do not write `_encryptFor` via `update`. The optional `id` lets the app pick the document id instead of letting MindooDB generate an ObjectId; when provided it must match `/^[a-z][a-z0-9_]*$/` (lowercase only, since ids become on-disk filenames) and existing live documents with that id are returned as-is (idempotent create-if-missing). If an existing custom-id document is deleted, `create({ id })` undeletes it and preserves the previous document body. Documents created with the same custom id on different replicas converge correctly when synced.
|
|
1484
1514
|
|
|
1485
1515
|
`delete(docId)` writes a lifecycle tombstone; it does not erase the document body from the append-only history. Use `undelete(docId)` to make the latest document state live again. If you want to record a deletion reason, first call `update(docId, { set: { intendedDeletionReason: "..." } })`, then call `delete(docId)`.
|
|
1486
1516
|
|
package/TESTING.md
CHANGED
|
@@ -15,10 +15,13 @@ import {
|
|
|
15
15
|
The testing entrypoint emulates document storage with real Automerge documents,
|
|
16
16
|
so `@automerge/automerge` is declared as an optional peer dependency. Add it to
|
|
17
17
|
your app's `devDependencies` when you import `mindoodb-app-sdk/testing`
|
|
18
|
-
(the runtime SDK entrypoint does not need it)
|
|
18
|
+
(the runtime SDK entrypoint does not need it).
|
|
19
|
+
|
|
20
|
+
Evaluating VirtualViews also need the optional `mindoodb` peer (same core engine
|
|
21
|
+
Haven uses):
|
|
19
22
|
|
|
20
23
|
```bash
|
|
21
|
-
pnpm add -D @automerge/automerge
|
|
24
|
+
pnpm add -D @automerge/automerge mindoodb
|
|
22
25
|
```
|
|
23
26
|
|
|
24
27
|
## Pick a level
|
|
@@ -99,11 +102,64 @@ When you pass `databases`, the mock session also exposes them through `session.g
|
|
|
99
102
|
Each database entry can provide:
|
|
100
103
|
|
|
101
104
|
- `info`
|
|
105
|
+
- `documents` — seed documents into the mock store (used by `list`/`query` and by evaluating VirtualViews)
|
|
102
106
|
- `methods.documents`
|
|
103
|
-
- `methods.views` for session-level `createView()` and `openView()` calls
|
|
107
|
+
- `methods.views` for session-level `createView()` and `openView()` calls (overrides the default evaluating navigator)
|
|
104
108
|
- `methods.attachments`
|
|
105
109
|
- `fulltextSetup` — the initial config returned by `db.getFulltextSetup()`; `db.setFulltextSetup()` overwrites it for the lifetime of the handle. Use this to test your app's full-text bootstrap logic. Note the mock evaluates `text` query clauses regardless of this config.
|
|
106
110
|
|
|
111
|
+
### Evaluating VirtualViews
|
|
112
|
+
|
|
113
|
+
With the optional `mindoodb` peer installed (`pnpm add -D mindoodb`),
|
|
114
|
+
`session.createViewNavigator({ definition, databaseIds })` evaluates the view
|
|
115
|
+
definition against seeded (and later created) documents using the same
|
|
116
|
+
VirtualView engine Haven uses. That means class-scoped filters,
|
|
117
|
+
`childDocumentsBetween`, and multi-database origins work in Vitest without a
|
|
118
|
+
full Haven host:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { createViewLanguage } from "mindoodb-view-language";
|
|
122
|
+
import { createMockMindooDBAppSession } from "mindoodb-app-sdk/testing";
|
|
123
|
+
|
|
124
|
+
const v = createViewLanguage();
|
|
125
|
+
const mock = createMockMindooDBAppSession({
|
|
126
|
+
databases: [{
|
|
127
|
+
info: { id: "teacher_core", title: "Core", capabilities: ["read", "views"] },
|
|
128
|
+
documents: [
|
|
129
|
+
{ id: "obs_a", data: { type: "observation", classGroupId: "cls_a" } },
|
|
130
|
+
{ id: "obs_b", data: { type: "observation", classGroupId: "cls_b" } },
|
|
131
|
+
],
|
|
132
|
+
}],
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const navigator = await mock.session.createViewNavigator({
|
|
136
|
+
databaseIds: ["teacher_core"],
|
|
137
|
+
definition: {
|
|
138
|
+
id: "class-detail-v1",
|
|
139
|
+
title: "Class",
|
|
140
|
+
filter: {
|
|
141
|
+
mode: "expression",
|
|
142
|
+
expression: v.and(
|
|
143
|
+
v.eq(v.field("type"), "observation"),
|
|
144
|
+
v.eq(v.field("classGroupId"), "cls_a"),
|
|
145
|
+
),
|
|
146
|
+
},
|
|
147
|
+
columns: [
|
|
148
|
+
{ name: "type", role: "category", expression: v.field("type") },
|
|
149
|
+
{ name: "sourceType", role: "display", expression: v.field("type") },
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
options: { includeCategories: false, includeDocuments: true },
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
await navigator.expandAll();
|
|
156
|
+
const page = await navigator.entriesForward({ limit: 100 });
|
|
157
|
+
// page.entries → only obs_a
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Without `mindoodb`, the testing entrypoint falls back to an empty navigator and
|
|
161
|
+
logs a warning — install the peer for realistic view tests.
|
|
162
|
+
|
|
107
163
|
The default in-memory document store also implements `documents.query()` and `documents.liveQuery()`: expression and formula-string filters are evaluated against the seeded documents, `sortBy`/`limit`/`offset` work as documented, and live query callbacks fire automatically after `create`/`update`/`delete`/`undelete` mutations. Full-text `text` clauses are supported with a deterministic mock implementation (token matching with prefix/AND semantics and an occurrence-count `textScore`) — assert on membership and relative ordering, not absolute scores, since real hosts use a BM25-style engine. That means app code built on queries and live queries is testable at Level 1 without any extra setup:
|
|
108
164
|
|
|
109
165
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge, b as MindooDBAppDatabase, c as MindooDBAppDocument, d as MindooDBAppRichTextSpan, e as MindooDBAppRichTextSnapshot } from './types-
|
|
2
|
-
export { f as MINDOODB_APP_SEAL_SIGNING_DOMAIN, g as MindooDBAppAccessDecision, h as MindooDBAppAccessTier, i as MindooDBAppAttachmentApi, j as MindooDBAppAttachmentChunk, k as MindooDBAppAttachmentInfo, l as MindooDBAppAttachmentPreviewOptions, m as MindooDBAppAttachmentPreviewSession, n as MindooDBAppAutomergeChangesPatch, o as MindooDBAppAutomergeChangesSince, p as MindooDBAppAutomergeGetOptions, q as MindooDBAppAutomergePatchResult, r as MindooDBAppAutomergeSnapshot, s as MindooDBAppBridgeConnectMessage, t as MindooDBAppBridgeConnectOptions, u as MindooDBAppBridgeConnectedMessage, v as MindooDBAppBridgeErrorPayload, w as MindooDBAppBridgeHandshakeErrorMessage, x as MindooDBAppBridgeLocaleChangedMessage, y as MindooDBAppBridgePortMessage, z as MindooDBAppBridgeQueryResultMessage, A as MindooDBAppBridgeRpcError, B as MindooDBAppBridgeRpcMessage, C as MindooDBAppBridgeRpcRequest, D as MindooDBAppBridgeRpcSuccess, E as MindooDBAppBridgeStreamAbortRequest, F as MindooDBAppBridgeStreamAck, G as MindooDBAppBridgeStreamCloseRequest, H as MindooDBAppBridgeStreamError, I as MindooDBAppBridgeStreamMessage, J as MindooDBAppBridgeStreamOpenResult, K as MindooDBAppBridgeStreamReadRequest, L as MindooDBAppBridgeStreamWriteRequest, N as MindooDBAppBridgeThemeChangedMessage, O as MindooDBAppBridgeUiPreferencesChangedMessage, P as MindooDBAppBridgeViewChangedMessage, Q as MindooDBAppBridgeViewportChangedMessage, R as MindooDBAppCapability, S as MindooDBAppConfiguredViewCategorizationStyle, T as MindooDBAppConfiguredViewColumn, U as MindooDBAppConfiguredViewColumnRole, V as MindooDBAppConfiguredViewExpressionMode, W as MindooDBAppConfiguredViewFieldExpression, X as MindooDBAppConfiguredViewFilterDefinition, Y as MindooDBAppConfiguredViewFilterMode, Z as MindooDBAppConfiguredViewFilterRule, _ as MindooDBAppConfiguredViewFormulaExpression, $ as MindooDBAppConfiguredViewFormulaFilterDefinition, a0 as MindooDBAppConfiguredViewPreviewMode, a1 as MindooDBAppConfiguredViewRuleFilterDefinition, a2 as MindooDBAppConfiguredViewRuleMatchMode, a3 as MindooDBAppConfiguredViewRuleOperator, a4 as MindooDBAppConfiguredViewValueExpression, a5 as MindooDBAppCreateDocumentInput, a6 as
|
|
1
|
+
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge, b as MindooDBAppDatabase, c as MindooDBAppDocument, d as MindooDBAppRichTextSpan, e as MindooDBAppRichTextSnapshot } from './types-Plb92iSn.js';
|
|
2
|
+
export { f as MINDOODB_APP_SEAL_SIGNING_DOMAIN, g as MindooDBAppAccessDecision, h as MindooDBAppAccessTier, i as MindooDBAppAttachmentApi, j as MindooDBAppAttachmentChunk, k as MindooDBAppAttachmentInfo, l as MindooDBAppAttachmentPreviewOptions, m as MindooDBAppAttachmentPreviewSession, n as MindooDBAppAutomergeChangesPatch, o as MindooDBAppAutomergeChangesSince, p as MindooDBAppAutomergeGetOptions, q as MindooDBAppAutomergePatchResult, r as MindooDBAppAutomergeSnapshot, s as MindooDBAppBridgeConnectMessage, t as MindooDBAppBridgeConnectOptions, u as MindooDBAppBridgeConnectedMessage, v as MindooDBAppBridgeErrorPayload, w as MindooDBAppBridgeHandshakeErrorMessage, x as MindooDBAppBridgeLocaleChangedMessage, y as MindooDBAppBridgePortMessage, z as MindooDBAppBridgeQueryResultMessage, A as MindooDBAppBridgeRpcError, B as MindooDBAppBridgeRpcMessage, C as MindooDBAppBridgeRpcRequest, D as MindooDBAppBridgeRpcSuccess, E as MindooDBAppBridgeStreamAbortRequest, F as MindooDBAppBridgeStreamAck, G as MindooDBAppBridgeStreamCloseRequest, H as MindooDBAppBridgeStreamError, I as MindooDBAppBridgeStreamMessage, J as MindooDBAppBridgeStreamOpenResult, K as MindooDBAppBridgeStreamReadRequest, L as MindooDBAppBridgeStreamWriteRequest, N as MindooDBAppBridgeThemeChangedMessage, O as MindooDBAppBridgeUiPreferencesChangedMessage, P as MindooDBAppBridgeViewChangedMessage, Q as MindooDBAppBridgeViewportChangedMessage, R as MindooDBAppCapability, S as MindooDBAppConfiguredViewCategorizationStyle, T as MindooDBAppConfiguredViewColumn, U as MindooDBAppConfiguredViewColumnRole, V as MindooDBAppConfiguredViewExpressionMode, W as MindooDBAppConfiguredViewFieldExpression, X as MindooDBAppConfiguredViewFilterDefinition, Y as MindooDBAppConfiguredViewFilterMode, Z as MindooDBAppConfiguredViewFilterRule, _ as MindooDBAppConfiguredViewFormulaExpression, $ as MindooDBAppConfiguredViewFormulaFilterDefinition, a0 as MindooDBAppConfiguredViewPreviewMode, a1 as MindooDBAppConfiguredViewRuleFilterDefinition, a2 as MindooDBAppConfiguredViewRuleMatchMode, a3 as MindooDBAppConfiguredViewRuleOperator, a4 as MindooDBAppConfiguredViewValueExpression, a5 as MindooDBAppCreateDocumentInput, a6 as MindooDBAppCreateKeyInfo, a7 as MindooDBAppCreateViewInput, a8 as MindooDBAppCreateViewNavigatorInput, a9 as MindooDBAppDatabaseInfo, aa as MindooDBAppDirectoryApi, ab as MindooDBAppDirectoryEntry, ac as MindooDBAppDocumentApi, ad as MindooDBAppDocumentHeadCursorResult, ae as MindooDBAppDocumentHistoryEntry, af as MindooDBAppDocumentListQuery, ag as MindooDBAppDocumentListResult, ah as MindooDBAppDocumentQuery, ai as MindooDBAppDocumentRevisionId, aj as MindooDBAppDocumentScanPreset, ak as MindooDBAppDocumentSummary, al as MindooDBAppEntryAttachmentRef, am as MindooDBAppEntryProvenance, an as MindooDBAppExtractDocumentTextInput, ao as MindooDBAppExtractDocumentTextResult, ap as MindooDBAppExtractTextFormat, aq as MindooDBAppExtractionSetup, ar as MindooDBAppFulltextSetup, as as MindooDBAppHistoricalDocument, at as MindooDBAppHistoryQuery, au as MindooDBAppHostTheme, av as MindooDBAppIdentityApi, aw as MindooDBAppJsonListDeletePatch, ax as MindooDBAppJsonListInsertPatch, ay as MindooDBAppJsonPatch, az as MindooDBAppJsonSetPatch, aA as MindooDBAppJsonTextMarkPatch, aB as MindooDBAppJsonTextSplicePatch, aC as MindooDBAppJsonTextUnmarkPatch, aD as MindooDBAppJsonUnsetPatch, aE as MindooDBAppLaunchContext, aF as MindooDBAppLiveQuerySubscription, aG as MindooDBAppMenuAnchor, aH as MindooDBAppMenuApi, aI as MindooDBAppMenuCommandItem, aJ as MindooDBAppMenuDismissReason, aK as MindooDBAppMenuDismissedResult, aL as MindooDBAppMenuItem, aM as MindooDBAppMenuKind, aN as MindooDBAppMenuPlacement, aO as MindooDBAppMenuPointAnchor, aP as MindooDBAppMenuRect, aQ as MindooDBAppMenuRectAnchor, aR as MindooDBAppMenuSelectionResult, aS as MindooDBAppMenuSeparatorItem, aT as MindooDBAppQueryCoverage, aU as MindooDBAppQueryResult, aV as MindooDBAppQueryRow, aW as MindooDBAppQuerySortKey, aX as MindooDBAppQueryTextClause, aY as MindooDBAppReadableAttachmentStream, aZ as MindooDBAppRecipientOptions, a_ as MindooDBAppResolvedViewDefinition, a$ as MindooDBAppResolvedViewSource, b0 as MindooDBAppRevisionPhase, b1 as MindooDBAppRevisionVerification, b2 as MindooDBAppRichTextBlockSpan, b3 as MindooDBAppRichTextGetOptions, b4 as MindooDBAppRichTextImmutableString, b5 as MindooDBAppRichTextMarkRange, b6 as MindooDBAppRichTextMaterializeValue, b7 as MindooDBAppRichTextPatch, b8 as MindooDBAppRichTextScalar, b9 as MindooDBAppRichTextSpliceStep, ba as MindooDBAppRichTextStep, bb as MindooDBAppRichTextStepPatch, bc as MindooDBAppRichTextTextSpan, bd as MindooDBAppRuntime, be as MindooDBAppScanAttachmentOptions, bf as MindooDBAppScanAttachmentResult, bg as MindooDBAppScopedDocId, bh as MindooDBAppScopedDocumentSummary, bi as MindooDBAppSealIntent, bj as MindooDBAppSession, bk as MindooDBAppShowMenuInput, bl as MindooDBAppShowMenuResult, bm as MindooDBAppSignPreview, bn as MindooDBAppSignPreviewScope, bo as MindooDBAppSignStatementInput, bp as MindooDBAppSignStatementResult, bq as MindooDBAppTextEdit, br as MindooDBAppTextPatch, bs as MindooDBAppThemeMode, bt as MindooDBAppTimestampApi, bu as MindooDBAppTimestampInput, bv as MindooDBAppTimestampProvider, bw as MindooDBAppTimestampResult, bx as MindooDBAppUiPreferences, by as MindooDBAppUpdateDocumentInput, bz as MindooDBAppViewCursorDocumentListResult, bA as MindooDBAppViewCursorResult, bB as MindooDBAppViewEntry, bC as MindooDBAppViewEntryKind, bD as MindooDBAppViewNavigator, bE as MindooDBAppViewNavigatorExpansionState, bF as MindooDBAppViewNavigatorOpenOptions, bG as MindooDBAppViewNavigatorPageOptions, bH as MindooDBAppViewNavigatorPageResult, bI as MindooDBAppViewNavigatorRangeQuery, bJ as MindooDBAppViewNavigatorSelectionState, bK as MindooDBAppViewUpdateStats, bL as MindooDBAppViewport, bM as MindooDBAppWritableAttachmentStream } from './types-Plb92iSn.js';
|
|
3
3
|
import { MindooDBAppBooleanExpression } from 'mindoodb-view-language';
|
|
4
4
|
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';
|
|
5
5
|
import { MindooDB, MindooQuerySortKey, MindooQueryOptions, MindooQueryResult } from 'mindoodb';
|
package/dist/index.js
CHANGED
|
@@ -852,6 +852,22 @@ var MindooDBAppDatabaseImpl = class {
|
|
|
852
852
|
docId,
|
|
853
853
|
patch
|
|
854
854
|
}),
|
|
855
|
+
addRecipients: async (docId, recipients) => await this.rpc.call("documents.addRecipients", {
|
|
856
|
+
databaseId: this.databaseId,
|
|
857
|
+
docId,
|
|
858
|
+
recipients
|
|
859
|
+
}),
|
|
860
|
+
removeRecipients: async (docId, recipients) => await this.rpc.call("documents.removeRecipients", {
|
|
861
|
+
databaseId: this.databaseId,
|
|
862
|
+
docId,
|
|
863
|
+
recipients
|
|
864
|
+
}),
|
|
865
|
+
setRecipients: async (docId, recipients, options) => await this.rpc.call("documents.setRecipients", {
|
|
866
|
+
databaseId: this.databaseId,
|
|
867
|
+
docId,
|
|
868
|
+
recipients,
|
|
869
|
+
recipientOptions: options
|
|
870
|
+
}),
|
|
855
871
|
delete: async (docId) => await this.rpc.call("documents.delete", {
|
|
856
872
|
databaseId: this.databaseId,
|
|
857
873
|
docId
|
|
@@ -901,6 +917,21 @@ var MindooDBAppDatabaseImpl = class {
|
|
|
901
917
|
getDefaultCreateKeyId: async () => await this.rpc.call("documents.getDefaultCreateKeyId", {
|
|
902
918
|
databaseId: this.databaseId
|
|
903
919
|
}),
|
|
920
|
+
listCreateKeys: async () => {
|
|
921
|
+
try {
|
|
922
|
+
return await this.rpc.call("documents.listCreateKeys", {
|
|
923
|
+
databaseId: this.databaseId
|
|
924
|
+
});
|
|
925
|
+
} catch (error) {
|
|
926
|
+
if (!isMethodNotFoundError(error)) {
|
|
927
|
+
throw error;
|
|
928
|
+
}
|
|
929
|
+
const keyId = await this.rpc.call("documents.getDefaultCreateKeyId", {
|
|
930
|
+
databaseId: this.databaseId
|
|
931
|
+
});
|
|
932
|
+
return [{ keyId, isDefault: true }];
|
|
933
|
+
}
|
|
934
|
+
},
|
|
904
935
|
listHistory: async (docId) => await this.rpc.call("documents.history.list", {
|
|
905
936
|
databaseId: this.databaseId,
|
|
906
937
|
docId
|
|
@@ -946,7 +977,19 @@ var MindooDBAppDatabaseImpl = class {
|
|
|
946
977
|
excerpt: async (publicKeys) => await this.rpc.call("directory.excerpt", {
|
|
947
978
|
databaseId: this.databaseId,
|
|
948
979
|
publicKeys
|
|
949
|
-
})
|
|
980
|
+
}),
|
|
981
|
+
listUsers: async () => {
|
|
982
|
+
try {
|
|
983
|
+
return await this.rpc.call("directory.listUsers", {
|
|
984
|
+
databaseId: this.databaseId
|
|
985
|
+
});
|
|
986
|
+
} catch (error) {
|
|
987
|
+
if (!isMethodNotFoundError(error)) {
|
|
988
|
+
throw error;
|
|
989
|
+
}
|
|
990
|
+
return [];
|
|
991
|
+
}
|
|
992
|
+
}
|
|
950
993
|
};
|
|
951
994
|
this.attachments = {
|
|
952
995
|
list: async (docId, options) => await this.rpc.call("attachments.list", {
|
|
@@ -1060,6 +1103,16 @@ var MindooDBAppDatabaseImpl = class {
|
|
|
1060
1103
|
timestamp: options?.timestamp,
|
|
1061
1104
|
revisionId: options?.revisionId
|
|
1062
1105
|
});
|
|
1106
|
+
},
|
|
1107
|
+
extractText: async (input) => {
|
|
1108
|
+
return await this.rpc.call("attachments.extractText", {
|
|
1109
|
+
databaseId: this.databaseId,
|
|
1110
|
+
bytes: input.bytes,
|
|
1111
|
+
mimeType: input.mimeType,
|
|
1112
|
+
fileName: input.fileName,
|
|
1113
|
+
format: input.format,
|
|
1114
|
+
languages: input.languages
|
|
1115
|
+
});
|
|
1063
1116
|
}
|
|
1064
1117
|
};
|
|
1065
1118
|
}
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a8 as MindooDBAppCreateViewNavigatorInput, bD as MindooDBAppViewNavigator, aE as MindooDBAppLaunchContext, a9 as MindooDBAppDatabaseInfo, ac as MindooDBAppDocumentApi, bF as MindooDBAppViewNavigatorOpenOptions, i as MindooDBAppAttachmentApi, av as MindooDBAppIdentityApi, bt as MindooDBAppTimestampApi, aa as MindooDBAppDirectoryApi, c as MindooDBAppDocument, ar as MindooDBAppFulltextSetup, aq as MindooDBAppExtractionSetup, a as MindooDBAppBridge, bj as MindooDBAppSession, C as MindooDBAppBridgeRpcRequest, au as MindooDBAppHostTheme, bL as MindooDBAppViewport, bx as MindooDBAppUiPreferences, aU as MindooDBAppQueryResult, bK as MindooDBAppViewUpdateStats, y as MindooDBAppBridgePortMessage } from '../types-Plb92iSn.js';
|
|
2
|
+
import * as mindoodb from 'mindoodb';
|
|
2
3
|
import 'mindoodb-view-language';
|
|
3
4
|
|
|
5
|
+
type EvaluatingViewDocument = {
|
|
6
|
+
origin: string;
|
|
7
|
+
docId: string;
|
|
8
|
+
data: Record<string, unknown>;
|
|
9
|
+
createdAt?: string | null;
|
|
10
|
+
lastModifiedAt?: string | null;
|
|
11
|
+
witnessed?: boolean;
|
|
12
|
+
awaitingWitness?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type MindoodbVirtualViews = typeof mindoodb;
|
|
15
|
+
declare function loadMindoodbForTesting(): Promise<MindoodbVirtualViews | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Build an async SDK navigator that evaluates `input.definition` against the
|
|
18
|
+
* provided materialised documents (same engine Haven uses for bridge views).
|
|
19
|
+
*
|
|
20
|
+
* Returns `null` when the optional `mindoodb` peer is not installed.
|
|
21
|
+
*/
|
|
22
|
+
declare function createEvaluatingViewNavigator(input: MindooDBAppCreateViewNavigatorInput, documents: EvaluatingViewDocument[]): Promise<MindooDBAppViewNavigator | null>;
|
|
23
|
+
|
|
4
24
|
type MaybePromise<T> = T | Promise<T>;
|
|
5
25
|
type MockViewApi = {
|
|
6
26
|
create(input: MindooDBAppCreateViewNavigatorInput): MaybePromise<MindooDBAppViewNavigator>;
|
|
@@ -14,9 +34,23 @@ type MockDatabaseMethods = {
|
|
|
14
34
|
timestamps?: Partial<MindooDBAppTimestampApi>;
|
|
15
35
|
directory?: Partial<MindooDBAppDirectoryApi>;
|
|
16
36
|
};
|
|
37
|
+
interface MockSeedDocument {
|
|
38
|
+
id: string;
|
|
39
|
+
data: Record<string, unknown>;
|
|
40
|
+
updatedAt?: string;
|
|
41
|
+
isDeleted?: boolean;
|
|
42
|
+
heads?: string[];
|
|
43
|
+
attachments?: MindooDBAppDocument["attachments"];
|
|
44
|
+
}
|
|
17
45
|
interface MockMindooDBAppDatabaseDefinition {
|
|
18
46
|
info: MindooDBAppDatabaseInfo;
|
|
19
47
|
methods?: MockDatabaseMethods;
|
|
48
|
+
/**
|
|
49
|
+
* Documents pre-loaded into the mock database store. Used by
|
|
50
|
+
* `documents.list` / `query` and by the evaluating VirtualView navigator
|
|
51
|
+
* (`session.createViewNavigator`).
|
|
52
|
+
*/
|
|
53
|
+
documents?: MockSeedDocument[];
|
|
20
54
|
/**
|
|
21
55
|
* Initial full-text configuration returned by `getFulltextSetup()`.
|
|
22
56
|
* `setFulltextSetup()` overwrites it for the lifetime of the handle.
|
|
@@ -51,6 +85,7 @@ interface MockMindooDBAppSessionController {
|
|
|
51
85
|
emitUiPreferencesChange(uiPreferences: MindooDBAppUiPreferences): void;
|
|
52
86
|
emitLocaleChange(locale: string): void;
|
|
53
87
|
}
|
|
88
|
+
|
|
54
89
|
declare function createMockMindooDBAppSession(options?: CreateMockMindooDBAppSessionOptions): MockMindooDBAppSessionController;
|
|
55
90
|
declare function createMockMindooDBAppBridge(options?: CreateMockMindooDBAppSessionOptions): MockMindooDBAppSessionController;
|
|
56
91
|
type FakeBridgeRequestHandler = (params: unknown, context: {
|
|
@@ -88,4 +123,4 @@ interface FakeBridgeHostController {
|
|
|
88
123
|
}
|
|
89
124
|
declare function createFakeBridgeHost(options?: CreateFakeBridgeHostOptions): FakeBridgeHostController;
|
|
90
125
|
|
|
91
|
-
export { type CreateFakeBridgeHostOptions, type CreateMockMindooDBAppSessionOptions, type FakeBridgeHostController, type FakeBridgePortMessageHandler, type FakeBridgeRequestHandler, type MockMindooDBAppDatabaseDefinition, type MockMindooDBAppSessionController, createFakeBridgeHost, createMockMindooDBAppBridge, createMockMindooDBAppSession };
|
|
126
|
+
export { type CreateFakeBridgeHostOptions, type CreateMockMindooDBAppSessionOptions, type EvaluatingViewDocument, type FakeBridgeHostController, type FakeBridgePortMessageHandler, type FakeBridgeRequestHandler, type MockMindooDBAppDatabaseDefinition, type MockMindooDBAppSessionController, type MockSeedDocument, createEvaluatingViewNavigator, createFakeBridgeHost, createMockMindooDBAppBridge, createMockMindooDBAppSession, loadMindoodbForTesting };
|