@powerhousedao/reactor 6.0.0-dev.209 → 6.0.0-dev.210
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/dist/index.d.ts +824 -722
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +279 -159
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Action, CreateDocumentActionInput, DocumentModelModule, ISigner, Operation, OperationContext, OperationWithContext, OperationWithContext as OperationWithContext$1, PHDocument, PHDocumentState, SignatureVerificationHandler, UpgradeDocumentActionInput, UpgradeManifest, UpgradeReducer, UpgradeTransition, actions as documentActions } from "@powerhousedao/shared/document-model";
|
|
2
|
+
import { DocumentDriveDocument, DriveInput, FolderNode, Node } from "@powerhousedao/shared/document-drive";
|
|
2
3
|
import { ILogger } from "document-model";
|
|
3
4
|
import * as kysely from "kysely";
|
|
4
5
|
import { Generated, Insertable, Kysely, Transaction } from "kysely";
|
|
@@ -1266,6 +1267,544 @@ interface IEventBus {
|
|
|
1266
1267
|
emit(type: number, data: any): Promise<void>;
|
|
1267
1268
|
}
|
|
1268
1269
|
//#endregion
|
|
1270
|
+
//#region src/shared/awaiter.d.ts
|
|
1271
|
+
interface IJobAwaiter {
|
|
1272
|
+
/**
|
|
1273
|
+
* Waits for a job to complete: turns a job into a promise.
|
|
1274
|
+
*
|
|
1275
|
+
* @param jobId - The job id or job object
|
|
1276
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1277
|
+
* @returns The result of the job
|
|
1278
|
+
*/
|
|
1279
|
+
waitForJob(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
1280
|
+
/**
|
|
1281
|
+
* Shuts down the job awaiter. This will synchronously reject all pending jobs.
|
|
1282
|
+
*/
|
|
1283
|
+
shutdown(): void;
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Event-driven implementation of IJobAwaiter.
|
|
1287
|
+
* Subscribes to operation events to detect job completion without polling.
|
|
1288
|
+
*/
|
|
1289
|
+
declare class JobAwaiter implements IJobAwaiter {
|
|
1290
|
+
private eventBus;
|
|
1291
|
+
private getJobStatus;
|
|
1292
|
+
private pendingJobs;
|
|
1293
|
+
private unsubscribers;
|
|
1294
|
+
constructor(eventBus: IEventBus, getJobStatus: (jobId: string, signal?: AbortSignal) => Promise<JobInfo>);
|
|
1295
|
+
private subscribeToEvents;
|
|
1296
|
+
shutdown(): void;
|
|
1297
|
+
waitForJob(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
1298
|
+
private handleWriteReady;
|
|
1299
|
+
private handleReadReady;
|
|
1300
|
+
private handleJobFailed;
|
|
1301
|
+
private checkAndResolveWaiters;
|
|
1302
|
+
}
|
|
1303
|
+
//#endregion
|
|
1304
|
+
//#region src/subs/types.d.ts
|
|
1305
|
+
/**
|
|
1306
|
+
* Error handler for subscription callback errors
|
|
1307
|
+
*/
|
|
1308
|
+
interface ISubscriptionErrorHandler {
|
|
1309
|
+
/**
|
|
1310
|
+
* Called when a subscription callback throws an error
|
|
1311
|
+
* @param error - The error that was thrown
|
|
1312
|
+
* @param context - Context about which subscription failed
|
|
1313
|
+
*/
|
|
1314
|
+
handleError(error: unknown, context: SubscriptionErrorContext): void;
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Context information about a subscription error
|
|
1318
|
+
*/
|
|
1319
|
+
interface SubscriptionErrorContext {
|
|
1320
|
+
/** The type of event that was being processed */
|
|
1321
|
+
eventType: "created" | "deleted" | "updated" | "relationshipChanged";
|
|
1322
|
+
/** The subscription ID that failed */
|
|
1323
|
+
subscriptionId: string;
|
|
1324
|
+
/** Optional additional data about the event */
|
|
1325
|
+
eventData?: unknown;
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Interface for subscribing to document events in the reactor.
|
|
1329
|
+
*/
|
|
1330
|
+
interface IReactorSubscriptionManager {
|
|
1331
|
+
/**
|
|
1332
|
+
* Subscribes to document creation events
|
|
1333
|
+
*
|
|
1334
|
+
* @param callback - Function called when documents are created
|
|
1335
|
+
* @param search - Optional search filter to limit which documents trigger events
|
|
1336
|
+
* @param view - Optional filter containing branch and scopes information
|
|
1337
|
+
* @returns A function that unsubscribes from the events
|
|
1338
|
+
*/
|
|
1339
|
+
onDocumentCreated(callback: (result: PagedResults<string>) => void, search?: SearchFilter): () => void;
|
|
1340
|
+
/**
|
|
1341
|
+
* Subscribes to document deletion events
|
|
1342
|
+
*
|
|
1343
|
+
* @param callback - Function called when documents are deleted
|
|
1344
|
+
* @param search - Optional search filter to limit which documents trigger events
|
|
1345
|
+
* @returns A function that unsubscribes from the events
|
|
1346
|
+
*/
|
|
1347
|
+
onDocumentDeleted(callback: (documentIds: string[]) => void, search?: SearchFilter): () => void;
|
|
1348
|
+
/**
|
|
1349
|
+
* Subscribes to document state updates
|
|
1350
|
+
*
|
|
1351
|
+
* @param callback - Function called when documents are updated
|
|
1352
|
+
* @param search - Optional search filter to limit which documents trigger events
|
|
1353
|
+
* @param view - Optional filter containing branch and scopes information
|
|
1354
|
+
* @returns A function that unsubscribes from the events
|
|
1355
|
+
*/
|
|
1356
|
+
onDocumentStateUpdated(callback: (result: PagedResults<PHDocument>) => void, search?: SearchFilter, view?: ViewFilter): () => void;
|
|
1357
|
+
/**
|
|
1358
|
+
* Subscribes to parent-child relationship change events
|
|
1359
|
+
*
|
|
1360
|
+
* @param callback - Function called when parent-child relationships change
|
|
1361
|
+
* @param search - Optional search filter to limit which documents trigger events
|
|
1362
|
+
* @returns A function that unsubscribes from the events
|
|
1363
|
+
*/
|
|
1364
|
+
onRelationshipChanged(callback: (parentId: string, childId: string, changeType: RelationshipChangeType) => void, search?: SearchFilter): () => void;
|
|
1365
|
+
}
|
|
1366
|
+
//#endregion
|
|
1367
|
+
//#region src/client/types.d.ts
|
|
1368
|
+
/**
|
|
1369
|
+
* Describes the types of document changes that can occur.
|
|
1370
|
+
*/
|
|
1371
|
+
declare enum DocumentChangeType {
|
|
1372
|
+
Created = "created",
|
|
1373
|
+
Deleted = "deleted",
|
|
1374
|
+
Updated = "updated",
|
|
1375
|
+
ParentAdded = "parent_added",
|
|
1376
|
+
ParentRemoved = "parent_removed",
|
|
1377
|
+
ChildAdded = "child_added",
|
|
1378
|
+
ChildRemoved = "child_removed"
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* Represents a change event for documents.
|
|
1382
|
+
*/
|
|
1383
|
+
type DocumentChangeEvent = {
|
|
1384
|
+
type: DocumentChangeType;
|
|
1385
|
+
documents: PHDocument[];
|
|
1386
|
+
context?: {
|
|
1387
|
+
parentId?: string;
|
|
1388
|
+
childId?: string;
|
|
1389
|
+
};
|
|
1390
|
+
};
|
|
1391
|
+
/**
|
|
1392
|
+
* Options for creating an empty document.
|
|
1393
|
+
*/
|
|
1394
|
+
type CreateDocumentOptions = {
|
|
1395
|
+
/** Optional "id" or "slug" of parent document */parentIdentifier?: string; /** Optional version of the document model to use (defaults to latest) */
|
|
1396
|
+
documentModelVersion?: number;
|
|
1397
|
+
};
|
|
1398
|
+
/**
|
|
1399
|
+
* Drive-aware operations grouped under `client.drives`.
|
|
1400
|
+
*
|
|
1401
|
+
* These methods orchestrate the multi-action, multi-document choreography
|
|
1402
|
+
* required to keep a drive's `state.global.nodes` array consistent with the
|
|
1403
|
+
* relationship index and the underlying documents. Use the flat
|
|
1404
|
+
* `IReactorClient` primitives (`get`, `execute`, `find`) for everything that
|
|
1405
|
+
* is not drive-aware.
|
|
1406
|
+
*/
|
|
1407
|
+
interface IDriveClient {
|
|
1408
|
+
/**
|
|
1409
|
+
* Creates a new drive document and waits for completion.
|
|
1410
|
+
*/
|
|
1411
|
+
create(input: DriveInput, signal?: AbortSignal): Promise<DocumentDriveDocument>;
|
|
1412
|
+
/**
|
|
1413
|
+
* Adds a document to a drive as a single batched operation.
|
|
1414
|
+
*
|
|
1415
|
+
* Issues CREATE_DOCUMENT, UPGRADE_DOCUMENT, ADD_RELATIONSHIP on the new
|
|
1416
|
+
* document and ADD_FILE on the drive in a single dependent batch.
|
|
1417
|
+
*/
|
|
1418
|
+
addFile<TDocument extends PHDocument = PHDocument>(driveIdentifier: string, document: PHDocument, parentFolder?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
1419
|
+
/**
|
|
1420
|
+
* Adds a folder node to a drive.
|
|
1421
|
+
*/
|
|
1422
|
+
addFolder(driveIdentifier: string, name: string, parentFolder?: string, signal?: AbortSignal): Promise<FolderNode>;
|
|
1423
|
+
/**
|
|
1424
|
+
* Removes a node from a drive. Folder nodes cascade: descendant file
|
|
1425
|
+
* documents are deleted first, then the folder node entry itself.
|
|
1426
|
+
*/
|
|
1427
|
+
removeNode(driveIdentifier: string, nodeId: string, signal?: AbortSignal): Promise<void>;
|
|
1428
|
+
/**
|
|
1429
|
+
* Renames a node. Updates both the underlying document header and the
|
|
1430
|
+
* drive's node entry.
|
|
1431
|
+
*/
|
|
1432
|
+
renameNode(driveIdentifier: string, nodeId: string, name: string, signal?: AbortSignal): Promise<Node>;
|
|
1433
|
+
/**
|
|
1434
|
+
* Moves a node to a different parent folder within the same drive.
|
|
1435
|
+
* Pass `undefined` to move the node to the drive root.
|
|
1436
|
+
*/
|
|
1437
|
+
moveNode(driveIdentifier: string, srcNodeId: string, targetParentFolderId: string | undefined, signal?: AbortSignal): Promise<DocumentDriveDocument>;
|
|
1438
|
+
/**
|
|
1439
|
+
* Copies a node (and its subtree, if it is a folder) within a drive.
|
|
1440
|
+
* Each copied file gets a new id and a duplicated document.
|
|
1441
|
+
*/
|
|
1442
|
+
copyNode(driveIdentifier: string, srcNodeId: string, targetParentFolderId: string | undefined, signal?: AbortSignal): Promise<DocumentDriveDocument>;
|
|
1443
|
+
/**
|
|
1444
|
+
* Returns a single node from the drive's `state.global.nodes` array.
|
|
1445
|
+
*/
|
|
1446
|
+
getNode(driveIdentifier: string, nodeId: string, signal?: AbortSignal): Promise<Node>;
|
|
1447
|
+
/**
|
|
1448
|
+
* Returns nodes in the drive, optionally filtered to a single parent
|
|
1449
|
+
* folder. Pass `null` to list root-level nodes only.
|
|
1450
|
+
*/
|
|
1451
|
+
listNodes(driveIdentifier: string, parentFolder?: string | null, signal?: AbortSignal): Promise<Node[]>;
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* The ReactorClient interface that wraps lower-level APIs to provide
|
|
1455
|
+
* a simpler interface for document operations.
|
|
1456
|
+
*
|
|
1457
|
+
* Features:
|
|
1458
|
+
* - Wraps Jobs with Promises for easier async handling
|
|
1459
|
+
* - Manages signing of submitted Action objects
|
|
1460
|
+
* - Provides quality-of-life functions for common tasks
|
|
1461
|
+
* - Wraps subscription interface with ViewFilters
|
|
1462
|
+
*/
|
|
1463
|
+
interface IReactorClient {
|
|
1464
|
+
/**
|
|
1465
|
+
* Drive-aware operations. See {@link IDriveClient}.
|
|
1466
|
+
*/
|
|
1467
|
+
readonly drives: IDriveClient;
|
|
1468
|
+
/**
|
|
1469
|
+
* Retrieves a list of document model modules.
|
|
1470
|
+
*
|
|
1471
|
+
* @param namespace - Optional namespace like "powerhouse" or "sky", defaults to ""
|
|
1472
|
+
* @param paging - Optional pagination options
|
|
1473
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1474
|
+
* @returns List of document model modules
|
|
1475
|
+
*/
|
|
1476
|
+
getDocumentModelModules(namespace?: string, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<DocumentModelModule>>;
|
|
1477
|
+
/**
|
|
1478
|
+
* Retrieves a specific document model module by document type.
|
|
1479
|
+
*
|
|
1480
|
+
* @param documentType - The document type identifier
|
|
1481
|
+
* @returns The document model module
|
|
1482
|
+
*/
|
|
1483
|
+
getDocumentModelModule(documentType: string): Promise<DocumentModelModule<any>>;
|
|
1484
|
+
/**
|
|
1485
|
+
* Retrieves a specific document by identifier (either id or slug).
|
|
1486
|
+
*
|
|
1487
|
+
* @param identifier - Required, this is the document id or slug
|
|
1488
|
+
* @param view - Optional filter containing branch and scopes information
|
|
1489
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1490
|
+
* @returns The up-to-date PHDocument with scopes and list of child document ids
|
|
1491
|
+
*/
|
|
1492
|
+
get<TDocument extends PHDocument>(identifier: string, view?: ViewFilter, signal?: AbortSignal): Promise<TDocument>;
|
|
1493
|
+
/**
|
|
1494
|
+
* Retrieves operations for a document.
|
|
1495
|
+
*
|
|
1496
|
+
* @param documentIdentifier - Required, this is either a document "id" field or a "slug"
|
|
1497
|
+
* @param view - Optional filter containing branch and scopes information
|
|
1498
|
+
* @param filter - Optional filter for actionTypes, timestamps, and revision
|
|
1499
|
+
* @param paging - Optional pagination options
|
|
1500
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1501
|
+
* @returns Paginated list of operations
|
|
1502
|
+
*/
|
|
1503
|
+
getOperations(documentIdentifier: string, view?: ViewFilter, filter?: OperationFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Retrieves outgoing relationships of a given type from a source document.
|
|
1506
|
+
*
|
|
1507
|
+
* @param sourceIdentifier - Required, this is either a document "id" field or a "slug"
|
|
1508
|
+
* @param relationshipType - The relationship type to filter by
|
|
1509
|
+
* @param view - Optional filter containing branch and scopes information
|
|
1510
|
+
* @param paging - Optional pagination options
|
|
1511
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1512
|
+
* @returns The target documents and paging cursor
|
|
1513
|
+
*/
|
|
1514
|
+
getOutgoingRelationships(sourceIdentifier: string, relationshipType: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
1515
|
+
/**
|
|
1516
|
+
* Retrieves incoming relationships of a given type to a target document.
|
|
1517
|
+
*
|
|
1518
|
+
* @param targetIdentifier - Required, this is either a document "id" field or a "slug"
|
|
1519
|
+
* @param relationshipType - The relationship type to filter by
|
|
1520
|
+
* @param view - Optional filter containing branch and scopes information
|
|
1521
|
+
* @param paging - Optional pagination options
|
|
1522
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1523
|
+
* @returns The source documents and paging cursor
|
|
1524
|
+
*/
|
|
1525
|
+
getIncomingRelationships(targetIdentifier: string, relationshipType: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
1526
|
+
/**
|
|
1527
|
+
* Filters documents by criteria and returns a list of them
|
|
1528
|
+
*
|
|
1529
|
+
* @param search - Search filter options (type, parentId, identifiers)
|
|
1530
|
+
* @param view - Optional filter containing branch and scopes information
|
|
1531
|
+
* @param paging - Optional pagination options
|
|
1532
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1533
|
+
* @returns List of documents matching criteria and pagination cursor
|
|
1534
|
+
*/
|
|
1535
|
+
find(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
1536
|
+
/**
|
|
1537
|
+
* Creates a document and waits for completion
|
|
1538
|
+
*
|
|
1539
|
+
* @param document - Document with optional id, slug, parent, model type, and initial state
|
|
1540
|
+
* @param parentIdentifier - Optional "id" or "slug" of parent document
|
|
1541
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1542
|
+
* @returns The created document
|
|
1543
|
+
*/
|
|
1544
|
+
create<TDocument extends PHDocument = PHDocument>(document: PHDocument, parentIdentifier?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
1545
|
+
/**
|
|
1546
|
+
* Creates an empty document and waits for completion
|
|
1547
|
+
*
|
|
1548
|
+
* @param documentModelType - Type of document to create
|
|
1549
|
+
* @param options - Optional creation options (parentIdentifier, documentModelVersion)
|
|
1550
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1551
|
+
*/
|
|
1552
|
+
createEmpty<TDocument extends PHDocument>(documentModelType: string, options?: CreateDocumentOptions, signal?: AbortSignal): Promise<TDocument>;
|
|
1553
|
+
/**
|
|
1554
|
+
* Creates an empty document in a drive as a single batched operation.
|
|
1555
|
+
* This is more efficient than createEmpty + addFile as it batches all
|
|
1556
|
+
* actions into dependent jobs and waits for them to complete together.
|
|
1557
|
+
*
|
|
1558
|
+
* @deprecated Use {@link IDriveClient.addFile} via `client.drives.addFile`
|
|
1559
|
+
* instead. This method will be removed in a future release.
|
|
1560
|
+
* @param driveId - The drive document id or slug
|
|
1561
|
+
* @param document - The document to create
|
|
1562
|
+
* @param parentFolder - Optional folder id within the drive
|
|
1563
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1564
|
+
* @returns The created document
|
|
1565
|
+
*/
|
|
1566
|
+
createDocumentInDrive<TDocument extends PHDocument>(driveId: string, document: PHDocument, parentFolder?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
1567
|
+
/**
|
|
1568
|
+
* Applies a list of actions to a document and waits for completion
|
|
1569
|
+
*
|
|
1570
|
+
* @param documentIdentifier - Target document id or slug
|
|
1571
|
+
* @param branch - Branch to apply actions to
|
|
1572
|
+
* @param actions - List of actions to apply
|
|
1573
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1574
|
+
* @returns The updated document
|
|
1575
|
+
*/
|
|
1576
|
+
execute<TDocument extends PHDocument>(documentIdentifier: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<TDocument>;
|
|
1577
|
+
/**
|
|
1578
|
+
* Submits a list of actions to a document
|
|
1579
|
+
*
|
|
1580
|
+
* @param documentIdentifier - Target document id or slug
|
|
1581
|
+
* @param branch - Branch to apply actions to
|
|
1582
|
+
* @param actions - List of actions to apply
|
|
1583
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1584
|
+
* @returns The job
|
|
1585
|
+
*/
|
|
1586
|
+
executeAsync(documentIdentifier: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<JobInfo>;
|
|
1587
|
+
/**
|
|
1588
|
+
* Renames a document and waits for completion
|
|
1589
|
+
*
|
|
1590
|
+
* @param documentIdentifier - Target document id or slug
|
|
1591
|
+
* @param name - The new name of the document
|
|
1592
|
+
* @param branch - Optional branch to rename the document, defaults to "main"
|
|
1593
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1594
|
+
* @returns The updated document.
|
|
1595
|
+
*/
|
|
1596
|
+
rename(documentIdentifier: string, name: string, branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
1597
|
+
/**
|
|
1598
|
+
* Adds a relationship between two documents and waits for completion.
|
|
1599
|
+
*
|
|
1600
|
+
* @param sourceIdentifier - Source document id or slug
|
|
1601
|
+
* @param targetIdentifier - Target document id or slug
|
|
1602
|
+
* @param relationshipType - Relationship type identifier
|
|
1603
|
+
* @param branch - Optional branch to add the relationship to, defaults to "main"
|
|
1604
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1605
|
+
* @returns The updated source document
|
|
1606
|
+
*/
|
|
1607
|
+
addRelationship(sourceIdentifier: string, targetIdentifier: string, relationshipType: string, branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
1608
|
+
/**
|
|
1609
|
+
* Removes a relationship between two documents and waits for completion.
|
|
1610
|
+
*
|
|
1611
|
+
* @param sourceIdentifier - Source document id or slug
|
|
1612
|
+
* @param targetIdentifier - Target document id or slug
|
|
1613
|
+
* @param relationshipType - Relationship type identifier
|
|
1614
|
+
* @param branch - Optional branch to remove the relationship from, defaults to "main"
|
|
1615
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1616
|
+
* @returns The updated source document
|
|
1617
|
+
*/
|
|
1618
|
+
removeRelationship(sourceIdentifier: string, targetIdentifier: string, relationshipType: string, branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
1619
|
+
/**
|
|
1620
|
+
* Moves a relationship from one source document to another and waits for completion.
|
|
1621
|
+
*
|
|
1622
|
+
* @param sourceParentIdentifier - Source parent document id or slug
|
|
1623
|
+
* @param targetParentIdentifier - Target parent document id or slug
|
|
1624
|
+
* @param targetIdentifier - The target document id or slug
|
|
1625
|
+
* @param relationshipType - Relationship type identifier
|
|
1626
|
+
* @param branch - Optional branch to apply the move to, defaults to "main"
|
|
1627
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1628
|
+
* @returns The updated source and target documents
|
|
1629
|
+
*/
|
|
1630
|
+
moveRelationship(sourceParentIdentifier: string, targetParentIdentifier: string, targetIdentifier: string, relationshipType: string, branch?: string, signal?: AbortSignal): Promise<{
|
|
1631
|
+
source: PHDocument;
|
|
1632
|
+
target: PHDocument;
|
|
1633
|
+
}>;
|
|
1634
|
+
/**
|
|
1635
|
+
* Deletes a document and waits for completion
|
|
1636
|
+
*
|
|
1637
|
+
* @param identifier - Document identifier (id or slug)
|
|
1638
|
+
* @param propagate - Optional mode for handling children, CASCADE deletes child documents
|
|
1639
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1640
|
+
* @returns a promise, resolving on deletion confirmation
|
|
1641
|
+
*/
|
|
1642
|
+
deleteDocument(identifier: string, propagate?: PropagationMode, signal?: AbortSignal): Promise<void>;
|
|
1643
|
+
/**
|
|
1644
|
+
* Deletes documents and waits for completion
|
|
1645
|
+
*
|
|
1646
|
+
* @param identifiers - Document identifiers (ids or slugs)
|
|
1647
|
+
* @param propagate - Optional mode for handling children, CASCADE deletes child documents
|
|
1648
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1649
|
+
* @returns a promise, resolving on deletion confirmation
|
|
1650
|
+
*/
|
|
1651
|
+
deleteDocuments(identifiers: string[], propagate?: PropagationMode, signal?: AbortSignal): Promise<void>;
|
|
1652
|
+
/**
|
|
1653
|
+
* Loads multiple batches of pre-existing operations across documents with dependency management.
|
|
1654
|
+
* Waits for all jobs to complete.
|
|
1655
|
+
*
|
|
1656
|
+
* @param request - Batch load request containing jobs with dependencies
|
|
1657
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1658
|
+
* @returns Map of job keys to completed job information
|
|
1659
|
+
*/
|
|
1660
|
+
loadBatch(request: BatchLoadRequest, signal?: AbortSignal): Promise<BatchLoadResult>;
|
|
1661
|
+
/**
|
|
1662
|
+
* Retrieves the status of a job
|
|
1663
|
+
*
|
|
1664
|
+
* @param jobId - The job id
|
|
1665
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1666
|
+
* @returns The job status
|
|
1667
|
+
*/
|
|
1668
|
+
getJobStatus(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
1669
|
+
/**
|
|
1670
|
+
* Waits for a job to complete
|
|
1671
|
+
*
|
|
1672
|
+
* @param jobId - The job id or job object
|
|
1673
|
+
* @param signal - Optional abort signal to cancel the request
|
|
1674
|
+
* @returns The result of the job
|
|
1675
|
+
*/
|
|
1676
|
+
waitForJob(jobId: string | JobInfo, signal?: AbortSignal): Promise<JobInfo>;
|
|
1677
|
+
/**
|
|
1678
|
+
* Subscribes to changes for documents matching specified filters
|
|
1679
|
+
*
|
|
1680
|
+
* @param search - Search filter options (type, parentId, identifiers)
|
|
1681
|
+
* @param callback - Function called when documents change with the change event details
|
|
1682
|
+
* @param view - Optional filter containing branch and scopes information
|
|
1683
|
+
* @returns A function that unsubscribes from the changes
|
|
1684
|
+
*/
|
|
1685
|
+
subscribe(search: SearchFilter, callback: (event: DocumentChangeEvent) => void, view?: ViewFilter): () => void;
|
|
1686
|
+
}
|
|
1687
|
+
//#endregion
|
|
1688
|
+
//#region src/client/reactor-client.d.ts
|
|
1689
|
+
/**
|
|
1690
|
+
* ReactorClient implementation that wraps lower-level APIs to provide
|
|
1691
|
+
* a simpler interface for document operations.
|
|
1692
|
+
*
|
|
1693
|
+
* Features:
|
|
1694
|
+
* - Wraps Jobs with Promises for easier async handling
|
|
1695
|
+
* - Manages signing of submitted Action objects
|
|
1696
|
+
* - Provides quality-of-life functions for common tasks
|
|
1697
|
+
* - Wraps subscription interface with ViewFilters
|
|
1698
|
+
*/
|
|
1699
|
+
declare class ReactorClient implements IReactorClient {
|
|
1700
|
+
private logger;
|
|
1701
|
+
private reactor;
|
|
1702
|
+
private signer;
|
|
1703
|
+
private subscriptionManager;
|
|
1704
|
+
private jobAwaiter;
|
|
1705
|
+
private documentIndexer;
|
|
1706
|
+
private documentView;
|
|
1707
|
+
readonly drives: IDriveClient;
|
|
1708
|
+
constructor(logger: ILogger, reactor: IReactor, signer: ISigner, subscriptionManager: IReactorSubscriptionManager, jobAwaiter: IJobAwaiter, documentIndexer: IDocumentIndexer, documentView: IDocumentView);
|
|
1709
|
+
/**
|
|
1710
|
+
* Retrieves a list of document model modules.
|
|
1711
|
+
*/
|
|
1712
|
+
getDocumentModelModules(namespace?: string, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<DocumentModelModule>>;
|
|
1713
|
+
/**
|
|
1714
|
+
* Retrieves a specific document model module by document type.
|
|
1715
|
+
*
|
|
1716
|
+
* @param documentType - The document type identifier
|
|
1717
|
+
* @returns The document model module
|
|
1718
|
+
*/
|
|
1719
|
+
getDocumentModelModule(documentType: string): Promise<DocumentModelModule<any>>;
|
|
1720
|
+
/**
|
|
1721
|
+
* Retrieves a specific PHDocument
|
|
1722
|
+
*/
|
|
1723
|
+
get<TDocument extends PHDocument>(identifier: string, view?: ViewFilter, signal?: AbortSignal): Promise<TDocument>;
|
|
1724
|
+
/**
|
|
1725
|
+
* Retrieves operations for a document
|
|
1726
|
+
*/
|
|
1727
|
+
getOperations(documentIdentifier: string, view?: ViewFilter, filter?: OperationFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
|
|
1728
|
+
private getOperationsWithCompositeCursor;
|
|
1729
|
+
/**
|
|
1730
|
+
* Retrieves outgoing relationships of a given type from a source document.
|
|
1731
|
+
*/
|
|
1732
|
+
getOutgoingRelationships(sourceIdentifier: string, relationshipType: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
1733
|
+
/**
|
|
1734
|
+
* Retrieves incoming relationships of a given type to a target document.
|
|
1735
|
+
*/
|
|
1736
|
+
getIncomingRelationships(targetIdentifier: string, relationshipType: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
1737
|
+
/**
|
|
1738
|
+
* Filters documents by criteria and returns a list of them
|
|
1739
|
+
*/
|
|
1740
|
+
find(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
1741
|
+
/**
|
|
1742
|
+
* Creates a document and waits for completion
|
|
1743
|
+
*/
|
|
1744
|
+
create<TDocument extends PHDocument = PHDocument>(document: PHDocument, parentIdentifier?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
1745
|
+
/**
|
|
1746
|
+
* Creates an empty document and waits for completion
|
|
1747
|
+
*/
|
|
1748
|
+
createEmpty<TDocument extends PHDocument>(documentModelType: string, options?: CreateDocumentOptions, signal?: AbortSignal): Promise<TDocument>;
|
|
1749
|
+
/**
|
|
1750
|
+
* Creates an empty document in a drive as a single batched operation.
|
|
1751
|
+
* Delegates to {@link IDriveClient.addFile}.
|
|
1752
|
+
*
|
|
1753
|
+
* @deprecated Use `client.drives.addFile` instead. This method will be
|
|
1754
|
+
* removed in a future release.
|
|
1755
|
+
*/
|
|
1756
|
+
createDocumentInDrive<TDocument extends PHDocument>(driveId: string, document: PHDocument, parentFolder?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
1757
|
+
/**
|
|
1758
|
+
* Applies a list of actions to a document and waits for completion
|
|
1759
|
+
*/
|
|
1760
|
+
execute<TDocument extends PHDocument>(documentIdentifier: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<TDocument>;
|
|
1761
|
+
/**
|
|
1762
|
+
* Submits a list of actions to a document
|
|
1763
|
+
*/
|
|
1764
|
+
executeAsync(documentIdentifier: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<JobInfo>;
|
|
1765
|
+
/**
|
|
1766
|
+
* Renames a document and waits for completion
|
|
1767
|
+
*/
|
|
1768
|
+
rename(documentIdentifier: string, name: string, branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
1769
|
+
/**
|
|
1770
|
+
* Adds multiple documents as children to another and waits for completion
|
|
1771
|
+
*/
|
|
1772
|
+
addRelationship(sourceIdentifier: string, targetIdentifier: string, relationshipType: string, branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
1773
|
+
/**
|
|
1774
|
+
* Removes a relationship between two documents and waits for completion.
|
|
1775
|
+
*/
|
|
1776
|
+
removeRelationship(sourceIdentifier: string, targetIdentifier: string, relationshipType: string, branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
1777
|
+
/**
|
|
1778
|
+
* Moves a relationship from one source document to another and waits for completion.
|
|
1779
|
+
*/
|
|
1780
|
+
moveRelationship(sourceParentIdentifier: string, targetParentIdentifier: string, targetIdentifier: string, relationshipType: string, branch?: string, signal?: AbortSignal): Promise<{
|
|
1781
|
+
source: PHDocument;
|
|
1782
|
+
target: PHDocument;
|
|
1783
|
+
}>;
|
|
1784
|
+
loadBatch(request: BatchLoadRequest, signal?: AbortSignal): Promise<BatchLoadResult>;
|
|
1785
|
+
/**
|
|
1786
|
+
* Deletes a document and waits for completion
|
|
1787
|
+
*/
|
|
1788
|
+
deleteDocument(identifier: string, propagate?: PropagationMode, signal?: AbortSignal): Promise<void>;
|
|
1789
|
+
/**
|
|
1790
|
+
* Deletes documents and waits for completion
|
|
1791
|
+
*/
|
|
1792
|
+
deleteDocuments(identifiers: string[], propagate?: PropagationMode, signal?: AbortSignal): Promise<void>;
|
|
1793
|
+
/**
|
|
1794
|
+
* Retrieves the status of a job
|
|
1795
|
+
*/
|
|
1796
|
+
getJobStatus(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
1797
|
+
/**
|
|
1798
|
+
* Waits for a job to complete
|
|
1799
|
+
*/
|
|
1800
|
+
waitForJob(jobId: string | JobInfo, signal?: AbortSignal): Promise<JobInfo>;
|
|
1801
|
+
/**
|
|
1802
|
+
* Subscribes to changes for documents matching specified filters
|
|
1803
|
+
*/
|
|
1804
|
+
subscribe(search: SearchFilter, callback: (event: DocumentChangeEvent) => void, view?: ViewFilter): () => void;
|
|
1805
|
+
private removeAllIncomingRelationships;
|
|
1806
|
+
}
|
|
1807
|
+
//#endregion
|
|
1269
1808
|
//#region src/executor/types.d.ts
|
|
1270
1809
|
/**
|
|
1271
1810
|
* Represents the result of a job execution
|
|
@@ -1708,40 +2247,6 @@ interface IDocumentModelRegistry {
|
|
|
1708
2247
|
getUpgradeReducer(documentType: string, fromVersion: number, toVersion: number): UpgradeReducer<any, any>;
|
|
1709
2248
|
}
|
|
1710
2249
|
//#endregion
|
|
1711
|
-
//#region src/shared/awaiter.d.ts
|
|
1712
|
-
interface IJobAwaiter {
|
|
1713
|
-
/**
|
|
1714
|
-
* Waits for a job to complete: turns a job into a promise.
|
|
1715
|
-
*
|
|
1716
|
-
* @param jobId - The job id or job object
|
|
1717
|
-
* @param signal - Optional abort signal to cancel the request
|
|
1718
|
-
* @returns The result of the job
|
|
1719
|
-
*/
|
|
1720
|
-
waitForJob(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
1721
|
-
/**
|
|
1722
|
-
* Shuts down the job awaiter. This will synchronously reject all pending jobs.
|
|
1723
|
-
*/
|
|
1724
|
-
shutdown(): void;
|
|
1725
|
-
}
|
|
1726
|
-
/**
|
|
1727
|
-
* Event-driven implementation of IJobAwaiter.
|
|
1728
|
-
* Subscribes to operation events to detect job completion without polling.
|
|
1729
|
-
*/
|
|
1730
|
-
declare class JobAwaiter implements IJobAwaiter {
|
|
1731
|
-
private eventBus;
|
|
1732
|
-
private getJobStatus;
|
|
1733
|
-
private pendingJobs;
|
|
1734
|
-
private unsubscribers;
|
|
1735
|
-
constructor(eventBus: IEventBus, getJobStatus: (jobId: string, signal?: AbortSignal) => Promise<JobInfo>);
|
|
1736
|
-
private subscribeToEvents;
|
|
1737
|
-
shutdown(): void;
|
|
1738
|
-
waitForJob(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
1739
|
-
private handleWriteReady;
|
|
1740
|
-
private handleReadReady;
|
|
1741
|
-
private handleJobFailed;
|
|
1742
|
-
private checkAndResolveWaiters;
|
|
1743
|
-
}
|
|
1744
|
-
//#endregion
|
|
1745
2250
|
//#region src/shared/consistency-tracker.d.ts
|
|
1746
2251
|
interface IConsistencyTracker {
|
|
1747
2252
|
/**
|
|
@@ -1877,108 +2382,45 @@ interface SyncDeadLetterTable {
|
|
|
1877
2382
|
job_dependencies: unknown;
|
|
1878
2383
|
remote_name: string;
|
|
1879
2384
|
document_id: string;
|
|
1880
|
-
scopes: unknown;
|
|
1881
|
-
branch: string;
|
|
1882
|
-
operations: unknown;
|
|
1883
|
-
error_source: string;
|
|
1884
|
-
error_message: string;
|
|
1885
|
-
created_at: Generated<Date>;
|
|
1886
|
-
}
|
|
1887
|
-
interface Database$1 {
|
|
1888
|
-
Operation: OperationTable;
|
|
1889
|
-
Keyframe: KeyframeTable;
|
|
1890
|
-
document_collections: DocumentCollectionTable;
|
|
1891
|
-
operation_index_operations: OperationIndexOperationTable;
|
|
1892
|
-
sync_remotes: SyncRemoteTable;
|
|
1893
|
-
sync_cursors: SyncCursorTable;
|
|
1894
|
-
sync_dead_letters: SyncDeadLetterTable;
|
|
1895
|
-
}
|
|
1896
|
-
interface DocumentTable {
|
|
1897
|
-
id: string;
|
|
1898
|
-
createdAt: Generated<Date>;
|
|
1899
|
-
updatedAt: Generated<Date>;
|
|
1900
|
-
}
|
|
1901
|
-
interface DocumentRelationshipTable {
|
|
1902
|
-
id: Generated<string>;
|
|
1903
|
-
sourceId: string;
|
|
1904
|
-
targetId: string;
|
|
1905
|
-
relationshipType: string;
|
|
1906
|
-
metadata: unknown;
|
|
1907
|
-
createdAt: Generated<Date>;
|
|
1908
|
-
updatedAt: Generated<Date>;
|
|
1909
|
-
}
|
|
1910
|
-
interface IndexerStateTable {
|
|
1911
|
-
id: Generated<number>;
|
|
1912
|
-
lastOperationId: number;
|
|
1913
|
-
lastOperationTimestamp: Generated<Date>;
|
|
1914
|
-
}
|
|
1915
|
-
interface DocumentIndexerDatabase {
|
|
1916
|
-
Document: DocumentTable;
|
|
1917
|
-
DocumentRelationship: DocumentRelationshipTable;
|
|
1918
|
-
IndexerState: IndexerStateTable;
|
|
1919
|
-
}
|
|
1920
|
-
//#endregion
|
|
1921
|
-
//#region src/subs/types.d.ts
|
|
1922
|
-
/**
|
|
1923
|
-
* Error handler for subscription callback errors
|
|
1924
|
-
*/
|
|
1925
|
-
interface ISubscriptionErrorHandler {
|
|
1926
|
-
/**
|
|
1927
|
-
* Called when a subscription callback throws an error
|
|
1928
|
-
* @param error - The error that was thrown
|
|
1929
|
-
* @param context - Context about which subscription failed
|
|
1930
|
-
*/
|
|
1931
|
-
handleError(error: unknown, context: SubscriptionErrorContext): void;
|
|
1932
|
-
}
|
|
1933
|
-
/**
|
|
1934
|
-
* Context information about a subscription error
|
|
1935
|
-
*/
|
|
1936
|
-
interface SubscriptionErrorContext {
|
|
1937
|
-
/** The type of event that was being processed */
|
|
1938
|
-
eventType: "created" | "deleted" | "updated" | "relationshipChanged";
|
|
1939
|
-
/** The subscription ID that failed */
|
|
1940
|
-
subscriptionId: string;
|
|
1941
|
-
/** Optional additional data about the event */
|
|
1942
|
-
eventData?: unknown;
|
|
1943
|
-
}
|
|
1944
|
-
/**
|
|
1945
|
-
* Interface for subscribing to document events in the reactor.
|
|
1946
|
-
*/
|
|
1947
|
-
interface IReactorSubscriptionManager {
|
|
1948
|
-
/**
|
|
1949
|
-
* Subscribes to document creation events
|
|
1950
|
-
*
|
|
1951
|
-
* @param callback - Function called when documents are created
|
|
1952
|
-
* @param search - Optional search filter to limit which documents trigger events
|
|
1953
|
-
* @param view - Optional filter containing branch and scopes information
|
|
1954
|
-
* @returns A function that unsubscribes from the events
|
|
1955
|
-
*/
|
|
1956
|
-
onDocumentCreated(callback: (result: PagedResults<string>) => void, search?: SearchFilter): () => void;
|
|
1957
|
-
/**
|
|
1958
|
-
* Subscribes to document deletion events
|
|
1959
|
-
*
|
|
1960
|
-
* @param callback - Function called when documents are deleted
|
|
1961
|
-
* @param search - Optional search filter to limit which documents trigger events
|
|
1962
|
-
* @returns A function that unsubscribes from the events
|
|
1963
|
-
*/
|
|
1964
|
-
onDocumentDeleted(callback: (documentIds: string[]) => void, search?: SearchFilter): () => void;
|
|
1965
|
-
/**
|
|
1966
|
-
* Subscribes to document state updates
|
|
1967
|
-
*
|
|
1968
|
-
* @param callback - Function called when documents are updated
|
|
1969
|
-
* @param search - Optional search filter to limit which documents trigger events
|
|
1970
|
-
* @param view - Optional filter containing branch and scopes information
|
|
1971
|
-
* @returns A function that unsubscribes from the events
|
|
1972
|
-
*/
|
|
1973
|
-
onDocumentStateUpdated(callback: (result: PagedResults<PHDocument>) => void, search?: SearchFilter, view?: ViewFilter): () => void;
|
|
1974
|
-
/**
|
|
1975
|
-
* Subscribes to parent-child relationship change events
|
|
1976
|
-
*
|
|
1977
|
-
* @param callback - Function called when parent-child relationships change
|
|
1978
|
-
* @param search - Optional search filter to limit which documents trigger events
|
|
1979
|
-
* @returns A function that unsubscribes from the events
|
|
1980
|
-
*/
|
|
1981
|
-
onRelationshipChanged(callback: (parentId: string, childId: string, changeType: RelationshipChangeType) => void, search?: SearchFilter): () => void;
|
|
2385
|
+
scopes: unknown;
|
|
2386
|
+
branch: string;
|
|
2387
|
+
operations: unknown;
|
|
2388
|
+
error_source: string;
|
|
2389
|
+
error_message: string;
|
|
2390
|
+
created_at: Generated<Date>;
|
|
2391
|
+
}
|
|
2392
|
+
interface Database$1 {
|
|
2393
|
+
Operation: OperationTable;
|
|
2394
|
+
Keyframe: KeyframeTable;
|
|
2395
|
+
document_collections: DocumentCollectionTable;
|
|
2396
|
+
operation_index_operations: OperationIndexOperationTable;
|
|
2397
|
+
sync_remotes: SyncRemoteTable;
|
|
2398
|
+
sync_cursors: SyncCursorTable;
|
|
2399
|
+
sync_dead_letters: SyncDeadLetterTable;
|
|
2400
|
+
}
|
|
2401
|
+
interface DocumentTable {
|
|
2402
|
+
id: string;
|
|
2403
|
+
createdAt: Generated<Date>;
|
|
2404
|
+
updatedAt: Generated<Date>;
|
|
2405
|
+
}
|
|
2406
|
+
interface DocumentRelationshipTable {
|
|
2407
|
+
id: Generated<string>;
|
|
2408
|
+
sourceId: string;
|
|
2409
|
+
targetId: string;
|
|
2410
|
+
relationshipType: string;
|
|
2411
|
+
metadata: unknown;
|
|
2412
|
+
createdAt: Generated<Date>;
|
|
2413
|
+
updatedAt: Generated<Date>;
|
|
2414
|
+
}
|
|
2415
|
+
interface IndexerStateTable {
|
|
2416
|
+
id: Generated<number>;
|
|
2417
|
+
lastOperationId: number;
|
|
2418
|
+
lastOperationTimestamp: Generated<Date>;
|
|
2419
|
+
}
|
|
2420
|
+
interface DocumentIndexerDatabase {
|
|
2421
|
+
Document: DocumentTable;
|
|
2422
|
+
DocumentRelationship: DocumentRelationshipTable;
|
|
2423
|
+
IndexerState: IndexerStateTable;
|
|
1982
2424
|
}
|
|
1983
2425
|
//#endregion
|
|
1984
2426
|
//#region src/sync/errors.d.ts
|
|
@@ -2278,695 +2720,355 @@ interface ISyncManager {
|
|
|
2278
2720
|
*
|
|
2279
2721
|
* @returns Array of all remotes
|
|
2280
2722
|
*/
|
|
2281
|
-
list(): Remote[];
|
|
2282
|
-
/**
|
|
2283
|
-
* Waits for sync operations for a job to complete.
|
|
2284
|
-
* Resolves when SYNC_SUCCEEDED is emitted.
|
|
2285
|
-
* Rejects when SYNC_FAILED is emitted.
|
|
2286
|
-
*
|
|
2287
|
-
* @param jobId - The job id to wait for
|
|
2288
|
-
* @param signal - Optional abort signal
|
|
2289
|
-
* @returns The sync result
|
|
2290
|
-
*/
|
|
2291
|
-
waitForSync(jobId: string, signal?: AbortSignal): Promise<SyncResult>;
|
|
2292
|
-
/**
|
|
2293
|
-
* Gets the current sync status for a document.
|
|
2294
|
-
*
|
|
2295
|
-
* @param documentId - The document ID to check
|
|
2296
|
-
* @returns The sync status, or undefined if the document has never been tracked
|
|
2297
|
-
*/
|
|
2298
|
-
getSyncStatus(documentId: string): SyncStatus | undefined;
|
|
2299
|
-
/**
|
|
2300
|
-
* Registers a callback that fires when a document's sync status changes.
|
|
2301
|
-
*
|
|
2302
|
-
* @param callback - Called with (documentId, newStatus) on each transition
|
|
2303
|
-
* @returns Unsubscribe function
|
|
2304
|
-
*/
|
|
2305
|
-
onSyncStatusChange(callback: SyncStatusChangeCallback): () => void;
|
|
2306
|
-
}
|
|
2307
|
-
//#endregion
|
|
2308
|
-
//#region src/core/types.d.ts
|
|
2309
|
-
/**
|
|
2310
|
-
* A single mutation job within a batch request.
|
|
2311
|
-
*/
|
|
2312
|
-
type ExecutionJobPlan = {
|
|
2313
|
-
key: string;
|
|
2314
|
-
documentId: string;
|
|
2315
|
-
scope: string;
|
|
2316
|
-
branch: string;
|
|
2317
|
-
actions: Action[];
|
|
2318
|
-
dependsOn: string[];
|
|
2319
|
-
};
|
|
2320
|
-
/**
|
|
2321
|
-
* Request for batch mutation operation.
|
|
2322
|
-
*/
|
|
2323
|
-
type BatchExecutionRequest = {
|
|
2324
|
-
jobs: ExecutionJobPlan[];
|
|
2325
|
-
};
|
|
2326
|
-
/**
|
|
2327
|
-
* Result from batch mutation operation.
|
|
2328
|
-
*/
|
|
2329
|
-
type BatchExecutionResult = {
|
|
2330
|
-
jobs: Record<string, JobInfo>;
|
|
2331
|
-
};
|
|
2332
|
-
/**
|
|
2333
|
-
* A single load job within a batch request.
|
|
2334
|
-
*/
|
|
2335
|
-
type LoadJobPlan = {
|
|
2336
|
-
key: string;
|
|
2337
|
-
documentId: string;
|
|
2338
|
-
scope: string;
|
|
2339
|
-
branch: string;
|
|
2340
|
-
operations: Operation[];
|
|
2341
|
-
dependsOn: string[];
|
|
2342
|
-
};
|
|
2343
|
-
/**
|
|
2344
|
-
* Request for batch load operation.
|
|
2345
|
-
*/
|
|
2346
|
-
type BatchLoadRequest = {
|
|
2347
|
-
jobs: LoadJobPlan[];
|
|
2348
|
-
};
|
|
2349
|
-
/**
|
|
2350
|
-
* Result from batch load operation.
|
|
2351
|
-
*/
|
|
2352
|
-
type BatchLoadResult = {
|
|
2353
|
-
jobs: Record<string, JobInfo>;
|
|
2354
|
-
};
|
|
2355
|
-
/**
|
|
2356
|
-
* The main Reactor interface that serves as a facade for document operations.
|
|
2357
|
-
* This interface provides a unified API for document management, including
|
|
2358
|
-
* creation, retrieval, mutation, and deletion operations.
|
|
2359
|
-
*/
|
|
2360
|
-
interface IReactor {
|
|
2361
|
-
/**
|
|
2362
|
-
* Signals that the reactor should shutdown.
|
|
2363
|
-
*/
|
|
2364
|
-
kill(): ShutdownStatus;
|
|
2365
|
-
/**
|
|
2366
|
-
* Retrieves a list of document model modules.
|
|
2367
|
-
*
|
|
2368
|
-
* @param namespace - Optional namespace like "powerhouse" or "sky", defaults to ""
|
|
2369
|
-
* @param paging - Optional options for paging data in large queries.
|
|
2370
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2371
|
-
* @returns List of document model modules
|
|
2372
|
-
*/
|
|
2373
|
-
getDocumentModels(namespace?: string, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<DocumentModelModule>>;
|
|
2374
|
-
/**
|
|
2375
|
-
* Retrieves a specific PHDocument by id
|
|
2376
|
-
*
|
|
2377
|
-
* @param id - Required, this is the document id
|
|
2378
|
-
* @param view - Optional filter containing branch and scopes information
|
|
2379
|
-
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2380
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2381
|
-
* @returns The up-to-date PHDocument
|
|
2382
|
-
*/
|
|
2383
|
-
get<TDocument extends PHDocument>(id: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
|
|
2384
|
-
/**
|
|
2385
|
-
* Retrieves a specific PHDocument by slug
|
|
2386
|
-
*
|
|
2387
|
-
* @param slug - Required, this is the document slug
|
|
2388
|
-
* @param view - Optional filter containing branch and scopes information
|
|
2389
|
-
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2390
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2391
|
-
* @returns The up-to-date PHDocument with scopes and list of child document ids
|
|
2392
|
-
*/
|
|
2393
|
-
getBySlug<TDocument extends PHDocument>(slug: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
|
|
2394
|
-
/**
|
|
2395
|
-
* Retrieves a specific PHDocument by identifier (either id or slug).
|
|
2396
|
-
* Throws an error if the identifier matches both an id and a slug that refer to different documents.
|
|
2397
|
-
*
|
|
2398
|
-
* @param identifier - Required, this is the document id or slug
|
|
2399
|
-
* @param view - Optional filter containing branch and scopes information
|
|
2400
|
-
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2401
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2402
|
-
* @returns The up-to-date PHDocument with scopes and list of child document ids
|
|
2403
|
-
* @throws {Error} If identifier matches both an ID and slug referring to different documents
|
|
2404
|
-
*/
|
|
2405
|
-
getByIdOrSlug<TDocument extends PHDocument>(identifier: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
|
|
2406
|
-
/**
|
|
2407
|
-
* Retrieves the children of a document
|
|
2408
|
-
*
|
|
2409
|
-
* @param parentId - The parent document id
|
|
2410
|
-
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2411
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2412
|
-
* @returns The list of child document ids
|
|
2413
|
-
*/
|
|
2414
|
-
getChildren(parentId: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
|
|
2415
|
-
/**
|
|
2416
|
-
* Retrieves the parents of a document
|
|
2417
|
-
*
|
|
2418
|
-
* @param childId - The child document id
|
|
2419
|
-
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2420
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2421
|
-
* @returns The list of parent document ids
|
|
2422
|
-
*/
|
|
2423
|
-
getParents(childId: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
|
|
2424
|
-
/**
|
|
2425
|
-
* Retrieves the operations for a document
|
|
2426
|
-
*
|
|
2427
|
-
* @param documentId - The document id
|
|
2428
|
-
* @param view - Optional filter containing branch and scopes information
|
|
2429
|
-
* @param filter - Optional filter for actionTypes, timestamps, and revision
|
|
2430
|
-
* @param paging - Optional pagination options
|
|
2431
|
-
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2432
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2433
|
-
* @returns The list of operations
|
|
2434
|
-
*/
|
|
2435
|
-
getOperations(documentId: string, view?: ViewFilter, filter?: OperationFilter, paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<Record<string, PagedResults<Operation>>>;
|
|
2436
|
-
/**
|
|
2437
|
-
* Filters documents by criteria and returns a list of them
|
|
2438
|
-
*
|
|
2439
|
-
* @param search - Search filter options (type, parentId, identifiers)
|
|
2440
|
-
* @param view - Optional filter containing branch and scopes information
|
|
2441
|
-
* @param paging - Optional pagination options
|
|
2442
|
-
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2443
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2444
|
-
* @returns List of documents matching criteria and pagination cursor
|
|
2445
|
-
*/
|
|
2446
|
-
find(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
2447
|
-
/**
|
|
2448
|
-
* Creates a document
|
|
2449
|
-
*
|
|
2450
|
-
* @param document - Document with optional id, slug, parent, model type, and initial state
|
|
2451
|
-
* @param signer - Optional signer to sign the actions
|
|
2452
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2453
|
-
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2454
|
-
* @returns The job status
|
|
2455
|
-
*/
|
|
2456
|
-
create(document: PHDocument, signer?: ISigner, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
2457
|
-
/**
|
|
2458
|
-
* Deletes a document
|
|
2459
|
-
*
|
|
2460
|
-
* @param id - Document id
|
|
2461
|
-
* @param signer - Optional signer to sign the actions
|
|
2462
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2463
|
-
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2464
|
-
* @returns The job id and status
|
|
2465
|
-
*/
|
|
2466
|
-
deleteDocument(id: string, signer?: ISigner, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
2467
|
-
/**
|
|
2468
|
-
* Applies a list of actions to a document.
|
|
2469
|
-
*
|
|
2470
|
-
* @param docId - Document id
|
|
2471
|
-
* @param branch - Branch to apply actions to
|
|
2472
|
-
* @param actions - List of actions to apply
|
|
2473
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2474
|
-
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2475
|
-
* @returns The job id and status
|
|
2476
|
-
*/
|
|
2477
|
-
execute(docId: string, branch: string, actions: Action[], signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
2478
|
-
/**
|
|
2479
|
-
* Loads existing operations generated elsewhere into this reactor.
|
|
2480
|
-
*
|
|
2481
|
-
* @param docId - Document id
|
|
2482
|
-
* @param branch - Branch to load operations to
|
|
2483
|
-
* @param operations - List of operations to load
|
|
2484
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2485
|
-
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2486
|
-
* @returns The job id and status
|
|
2487
|
-
*/
|
|
2488
|
-
load(docId: string, branch: string, operations: Operation[], signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
2489
|
-
/**
|
|
2490
|
-
* Applies multiple mutations across documents with dependency management.
|
|
2491
|
-
*
|
|
2492
|
-
* @param request - Batch mutation request containing jobs with dependencies
|
|
2493
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2494
|
-
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2495
|
-
* @returns Map of job keys to job information
|
|
2496
|
-
*/
|
|
2497
|
-
executeBatch(request: BatchExecutionRequest, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<BatchExecutionResult>;
|
|
2498
|
-
/**
|
|
2499
|
-
* Loads multiple batches of pre-existing operations across documents with dependency management.
|
|
2500
|
-
*
|
|
2501
|
-
* @param request - Batch load request containing jobs with dependencies
|
|
2502
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2503
|
-
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2504
|
-
* @returns Map of job keys to job information
|
|
2505
|
-
*/
|
|
2506
|
-
loadBatch(request: BatchLoadRequest, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<BatchLoadResult>;
|
|
2723
|
+
list(): Remote[];
|
|
2507
2724
|
/**
|
|
2508
|
-
*
|
|
2725
|
+
* Waits for sync operations for a job to complete.
|
|
2726
|
+
* Resolves when SYNC_SUCCEEDED is emitted.
|
|
2727
|
+
* Rejects when SYNC_FAILED is emitted.
|
|
2509
2728
|
*
|
|
2510
|
-
* @param
|
|
2511
|
-
* @param
|
|
2512
|
-
* @
|
|
2513
|
-
* @param signer - Optional signer to sign the actions
|
|
2514
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2515
|
-
* @returns The job id and status
|
|
2729
|
+
* @param jobId - The job id to wait for
|
|
2730
|
+
* @param signal - Optional abort signal
|
|
2731
|
+
* @returns The sync result
|
|
2516
2732
|
*/
|
|
2517
|
-
|
|
2733
|
+
waitForSync(jobId: string, signal?: AbortSignal): Promise<SyncResult>;
|
|
2518
2734
|
/**
|
|
2519
|
-
*
|
|
2735
|
+
* Gets the current sync status for a document.
|
|
2520
2736
|
*
|
|
2521
|
-
* @param
|
|
2522
|
-
* @
|
|
2523
|
-
* @param branch - Branch to remove children from, defaults to "main"
|
|
2524
|
-
* @param signer - Optional signer to sign the actions
|
|
2525
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2526
|
-
* @returns The job id and status
|
|
2737
|
+
* @param documentId - The document ID to check
|
|
2738
|
+
* @returns The sync status, or undefined if the document has never been tracked
|
|
2527
2739
|
*/
|
|
2528
|
-
|
|
2740
|
+
getSyncStatus(documentId: string): SyncStatus | undefined;
|
|
2529
2741
|
/**
|
|
2530
|
-
*
|
|
2742
|
+
* Registers a callback that fires when a document's sync status changes.
|
|
2531
2743
|
*
|
|
2532
|
-
* @param
|
|
2533
|
-
* @returns
|
|
2744
|
+
* @param callback - Called with (documentId, newStatus) on each transition
|
|
2745
|
+
* @returns Unsubscribe function
|
|
2534
2746
|
*/
|
|
2535
|
-
|
|
2747
|
+
onSyncStatusChange(callback: SyncStatusChangeCallback): () => void;
|
|
2536
2748
|
}
|
|
2749
|
+
//#endregion
|
|
2750
|
+
//#region src/core/types.d.ts
|
|
2537
2751
|
/**
|
|
2538
|
-
*
|
|
2752
|
+
* A single mutation job within a batch request.
|
|
2539
2753
|
*/
|
|
2540
|
-
type
|
|
2541
|
-
|
|
2754
|
+
type ExecutionJobPlan = {
|
|
2755
|
+
key: string;
|
|
2756
|
+
documentId: string;
|
|
2757
|
+
scope: string;
|
|
2758
|
+
branch: string;
|
|
2759
|
+
actions: Action[];
|
|
2760
|
+
dependsOn: string[];
|
|
2542
2761
|
};
|
|
2543
2762
|
/**
|
|
2544
|
-
*
|
|
2545
|
-
*/
|
|
2546
|
-
type Database = Database$1 & DocumentViewDatabase & DocumentIndexerDatabase;
|
|
2547
|
-
/**
|
|
2548
|
-
* Container for all sync manager dependencies created during the build process.
|
|
2549
|
-
*/
|
|
2550
|
-
interface SyncModule {
|
|
2551
|
-
remoteStorage: ISyncRemoteStorage;
|
|
2552
|
-
cursorStorage: ISyncCursorStorage;
|
|
2553
|
-
deadLetterStorage: ISyncDeadLetterStorage;
|
|
2554
|
-
channelFactory: IChannelFactory;
|
|
2555
|
-
syncManager: ISyncManager;
|
|
2556
|
-
}
|
|
2557
|
-
/**
|
|
2558
|
-
* Container for all reactor dependencies created during the build process.
|
|
2559
|
-
* Provides direct access to internal components for advanced use cases,
|
|
2560
|
-
* testing, or integration scenarios.
|
|
2763
|
+
* Request for batch mutation operation.
|
|
2561
2764
|
*/
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
queue: IQueue;
|
|
2566
|
-
jobTracker: IJobTracker;
|
|
2567
|
-
executorManager: IJobExecutorManager;
|
|
2568
|
-
database: Kysely<Database>;
|
|
2569
|
-
operationStore: IOperationStore;
|
|
2570
|
-
keyframeStore: IKeyframeStore;
|
|
2571
|
-
writeCache: IWriteCache;
|
|
2572
|
-
operationIndex: IOperationIndex;
|
|
2573
|
-
documentView: IDocumentView;
|
|
2574
|
-
documentViewConsistencyTracker: IConsistencyTracker;
|
|
2575
|
-
documentIndexer: IDocumentIndexer;
|
|
2576
|
-
documentIndexerConsistencyTracker: IConsistencyTracker;
|
|
2577
|
-
readModelCoordinator: IReadModelCoordinator;
|
|
2578
|
-
subscriptionManager: IReactorSubscriptionManager;
|
|
2579
|
-
processorManager: IProcessorManager$1;
|
|
2580
|
-
processorManagerConsistencyTracker: IConsistencyTracker;
|
|
2581
|
-
syncModule: SyncModule | undefined;
|
|
2582
|
-
reactor: IReactor;
|
|
2583
|
-
}
|
|
2765
|
+
type BatchExecutionRequest = {
|
|
2766
|
+
jobs: ExecutionJobPlan[];
|
|
2767
|
+
};
|
|
2584
2768
|
/**
|
|
2585
|
-
*
|
|
2586
|
-
* Provides direct access to internal components for advanced use cases,
|
|
2587
|
-
* testing, or integration scenarios.
|
|
2769
|
+
* Result from batch mutation operation.
|
|
2588
2770
|
*/
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
eventBus: IEventBus;
|
|
2593
|
-
documentIndexer: IDocumentIndexer;
|
|
2594
|
-
documentView: IDocumentView;
|
|
2595
|
-
signer: ISigner;
|
|
2596
|
-
subscriptionManager: IReactorSubscriptionManager;
|
|
2597
|
-
jobAwaiter: IJobAwaiter;
|
|
2598
|
-
reactorModule: ReactorModule | undefined;
|
|
2599
|
-
}
|
|
2600
|
-
//#endregion
|
|
2601
|
-
//#region src/client/types.d.ts
|
|
2771
|
+
type BatchExecutionResult = {
|
|
2772
|
+
jobs: Record<string, JobInfo>;
|
|
2773
|
+
};
|
|
2602
2774
|
/**
|
|
2603
|
-
*
|
|
2775
|
+
* A single load job within a batch request.
|
|
2604
2776
|
*/
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
}
|
|
2777
|
+
type LoadJobPlan = {
|
|
2778
|
+
key: string;
|
|
2779
|
+
documentId: string;
|
|
2780
|
+
scope: string;
|
|
2781
|
+
branch: string;
|
|
2782
|
+
operations: Operation[];
|
|
2783
|
+
dependsOn: string[];
|
|
2784
|
+
};
|
|
2614
2785
|
/**
|
|
2615
|
-
*
|
|
2786
|
+
* Request for batch load operation.
|
|
2616
2787
|
*/
|
|
2617
|
-
type
|
|
2618
|
-
|
|
2619
|
-
documents: PHDocument[];
|
|
2620
|
-
context?: {
|
|
2621
|
-
parentId?: string;
|
|
2622
|
-
childId?: string;
|
|
2623
|
-
};
|
|
2788
|
+
type BatchLoadRequest = {
|
|
2789
|
+
jobs: LoadJobPlan[];
|
|
2624
2790
|
};
|
|
2625
2791
|
/**
|
|
2626
|
-
*
|
|
2792
|
+
* Result from batch load operation.
|
|
2627
2793
|
*/
|
|
2628
|
-
type
|
|
2629
|
-
|
|
2630
|
-
documentModelVersion?: number;
|
|
2794
|
+
type BatchLoadResult = {
|
|
2795
|
+
jobs: Record<string, JobInfo>;
|
|
2631
2796
|
};
|
|
2632
2797
|
/**
|
|
2633
|
-
* The
|
|
2634
|
-
* a
|
|
2635
|
-
*
|
|
2636
|
-
* Features:
|
|
2637
|
-
* - Wraps Jobs with Promises for easier async handling
|
|
2638
|
-
* - Manages signing of submitted Action objects
|
|
2639
|
-
* - Provides quality-of-life functions for common tasks
|
|
2640
|
-
* - Wraps subscription interface with ViewFilters
|
|
2798
|
+
* The main Reactor interface that serves as a facade for document operations.
|
|
2799
|
+
* This interface provides a unified API for document management, including
|
|
2800
|
+
* creation, retrieval, mutation, and deletion operations.
|
|
2641
2801
|
*/
|
|
2642
|
-
interface
|
|
2802
|
+
interface IReactor {
|
|
2803
|
+
/**
|
|
2804
|
+
* Signals that the reactor should shutdown.
|
|
2805
|
+
*/
|
|
2806
|
+
kill(): ShutdownStatus;
|
|
2643
2807
|
/**
|
|
2644
2808
|
* Retrieves a list of document model modules.
|
|
2645
2809
|
*
|
|
2646
2810
|
* @param namespace - Optional namespace like "powerhouse" or "sky", defaults to ""
|
|
2647
|
-
* @param paging - Optional
|
|
2811
|
+
* @param paging - Optional options for paging data in large queries.
|
|
2648
2812
|
* @param signal - Optional abort signal to cancel the request
|
|
2649
2813
|
* @returns List of document model modules
|
|
2650
2814
|
*/
|
|
2651
|
-
|
|
2815
|
+
getDocumentModels(namespace?: string, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<DocumentModelModule>>;
|
|
2652
2816
|
/**
|
|
2653
|
-
* Retrieves a specific
|
|
2817
|
+
* Retrieves a specific PHDocument by id
|
|
2654
2818
|
*
|
|
2655
|
-
* @param
|
|
2656
|
-
* @
|
|
2819
|
+
* @param id - Required, this is the document id
|
|
2820
|
+
* @param view - Optional filter containing branch and scopes information
|
|
2821
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2822
|
+
* @param signal - Optional abort signal to cancel the request
|
|
2823
|
+
* @returns The up-to-date PHDocument
|
|
2657
2824
|
*/
|
|
2658
|
-
|
|
2825
|
+
get<TDocument extends PHDocument>(id: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
|
|
2659
2826
|
/**
|
|
2660
|
-
* Retrieves a specific
|
|
2827
|
+
* Retrieves a specific PHDocument by slug
|
|
2661
2828
|
*
|
|
2662
|
-
* @param
|
|
2829
|
+
* @param slug - Required, this is the document slug
|
|
2663
2830
|
* @param view - Optional filter containing branch and scopes information
|
|
2831
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2664
2832
|
* @param signal - Optional abort signal to cancel the request
|
|
2665
2833
|
* @returns The up-to-date PHDocument with scopes and list of child document ids
|
|
2666
2834
|
*/
|
|
2667
|
-
|
|
2835
|
+
getBySlug<TDocument extends PHDocument>(slug: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
|
|
2668
2836
|
/**
|
|
2669
|
-
* Retrieves
|
|
2837
|
+
* Retrieves a specific PHDocument by identifier (either id or slug).
|
|
2838
|
+
* Throws an error if the identifier matches both an id and a slug that refer to different documents.
|
|
2670
2839
|
*
|
|
2671
|
-
* @param
|
|
2840
|
+
* @param identifier - Required, this is the document id or slug
|
|
2672
2841
|
* @param view - Optional filter containing branch and scopes information
|
|
2673
|
-
* @param
|
|
2674
|
-
* @param paging - Optional pagination options
|
|
2842
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2675
2843
|
* @param signal - Optional abort signal to cancel the request
|
|
2676
|
-
* @returns
|
|
2844
|
+
* @returns The up-to-date PHDocument with scopes and list of child document ids
|
|
2845
|
+
* @throws {Error} If identifier matches both an ID and slug referring to different documents
|
|
2677
2846
|
*/
|
|
2678
|
-
|
|
2847
|
+
getByIdOrSlug<TDocument extends PHDocument>(identifier: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
|
|
2679
2848
|
/**
|
|
2680
|
-
* Retrieves
|
|
2849
|
+
* Retrieves outgoing relationships of a given type from a source document.
|
|
2681
2850
|
*
|
|
2682
|
-
* @param
|
|
2683
|
-
* @param
|
|
2684
|
-
* @param
|
|
2851
|
+
* @param sourceId - The source document id
|
|
2852
|
+
* @param relationshipType - The relationship type to filter by
|
|
2853
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2685
2854
|
* @param signal - Optional abort signal to cancel the request
|
|
2686
|
-
* @returns The
|
|
2855
|
+
* @returns The list of target document ids
|
|
2687
2856
|
*/
|
|
2688
|
-
|
|
2857
|
+
getOutgoingRelationships(sourceId: string, relationshipType: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
|
|
2689
2858
|
/**
|
|
2690
|
-
* Retrieves
|
|
2859
|
+
* Retrieves incoming relationships of a given type to a target document.
|
|
2691
2860
|
*
|
|
2692
|
-
* @param
|
|
2693
|
-
* @param
|
|
2694
|
-
* @param
|
|
2861
|
+
* @param targetId - The target document id
|
|
2862
|
+
* @param relationshipType - The relationship type to filter by
|
|
2863
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2695
2864
|
* @param signal - Optional abort signal to cancel the request
|
|
2696
|
-
* @returns The
|
|
2865
|
+
* @returns The list of source document ids
|
|
2697
2866
|
*/
|
|
2698
|
-
|
|
2867
|
+
getIncomingRelationships(targetId: string, relationshipType: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
|
|
2699
2868
|
/**
|
|
2700
|
-
*
|
|
2869
|
+
* Retrieves the operations for a document
|
|
2701
2870
|
*
|
|
2702
|
-
* @param
|
|
2871
|
+
* @param documentId - The document id
|
|
2703
2872
|
* @param view - Optional filter containing branch and scopes information
|
|
2873
|
+
* @param filter - Optional filter for actionTypes, timestamps, and revision
|
|
2704
2874
|
* @param paging - Optional pagination options
|
|
2875
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2705
2876
|
* @param signal - Optional abort signal to cancel the request
|
|
2706
|
-
* @returns
|
|
2707
|
-
*/
|
|
2708
|
-
find(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
2709
|
-
/**
|
|
2710
|
-
* Creates a document and waits for completion
|
|
2711
|
-
*
|
|
2712
|
-
* @param document - Document with optional id, slug, parent, model type, and initial state
|
|
2713
|
-
* @param parentIdentifier - Optional "id" or "slug" of parent document
|
|
2714
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2715
|
-
* @returns The created document
|
|
2716
|
-
*/
|
|
2717
|
-
create<TDocument extends PHDocument = PHDocument>(document: PHDocument, parentIdentifier?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
2718
|
-
/**
|
|
2719
|
-
* Creates an empty document and waits for completion
|
|
2720
|
-
*
|
|
2721
|
-
* @param documentModelType - Type of document to create
|
|
2722
|
-
* @param options - Optional creation options (parentIdentifier, documentModelVersion)
|
|
2723
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2724
|
-
*/
|
|
2725
|
-
createEmpty<TDocument extends PHDocument>(documentModelType: string, options?: CreateDocumentOptions, signal?: AbortSignal): Promise<TDocument>;
|
|
2726
|
-
/**
|
|
2727
|
-
* Creates an empty document in a drive as a single batched operation.
|
|
2728
|
-
* This is more efficient than createEmpty + addFile as it batches all
|
|
2729
|
-
* actions into dependent jobs and waits for them to complete together.
|
|
2730
|
-
*
|
|
2731
|
-
* @param driveId - The drive document id or slug
|
|
2732
|
-
* @param document - The document to create
|
|
2733
|
-
* @param parentFolder - Optional folder id within the drive
|
|
2734
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2735
|
-
* @returns The created document
|
|
2736
|
-
*/
|
|
2737
|
-
createDocumentInDrive<TDocument extends PHDocument>(driveId: string, document: PHDocument, parentFolder?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
2738
|
-
/**
|
|
2739
|
-
* Applies a list of actions to a document and waits for completion
|
|
2740
|
-
*
|
|
2741
|
-
* @param documentIdentifier - Target document id or slug
|
|
2742
|
-
* @param branch - Branch to apply actions to
|
|
2743
|
-
* @param actions - List of actions to apply
|
|
2744
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2745
|
-
* @returns The updated document
|
|
2746
|
-
*/
|
|
2747
|
-
execute<TDocument extends PHDocument>(documentIdentifier: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<TDocument>;
|
|
2748
|
-
/**
|
|
2749
|
-
* Submits a list of actions to a document
|
|
2750
|
-
*
|
|
2751
|
-
* @param documentIdentifier - Target document id or slug
|
|
2752
|
-
* @param branch - Branch to apply actions to
|
|
2753
|
-
* @param actions - List of actions to apply
|
|
2754
|
-
* @param signal - Optional abort signal to cancel the request
|
|
2755
|
-
* @returns The job
|
|
2877
|
+
* @returns The list of operations
|
|
2756
2878
|
*/
|
|
2757
|
-
|
|
2879
|
+
getOperations(documentId: string, view?: ViewFilter, filter?: OperationFilter, paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<Record<string, PagedResults<Operation>>>;
|
|
2758
2880
|
/**
|
|
2759
|
-
*
|
|
2881
|
+
* Filters documents by criteria and returns a list of them
|
|
2760
2882
|
*
|
|
2761
|
-
* @param
|
|
2762
|
-
* @param
|
|
2763
|
-
* @param
|
|
2883
|
+
* @param search - Search filter options (type, parentId, identifiers)
|
|
2884
|
+
* @param view - Optional filter containing branch and scopes information
|
|
2885
|
+
* @param paging - Optional pagination options
|
|
2886
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
2764
2887
|
* @param signal - Optional abort signal to cancel the request
|
|
2765
|
-
* @returns
|
|
2888
|
+
* @returns List of documents matching criteria and pagination cursor
|
|
2766
2889
|
*/
|
|
2767
|
-
|
|
2890
|
+
find(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
2768
2891
|
/**
|
|
2769
|
-
*
|
|
2892
|
+
* Creates a document
|
|
2770
2893
|
*
|
|
2771
|
-
* @param
|
|
2772
|
-
* @param
|
|
2773
|
-
* @param branch - Optional branch to add children to, defaults to "main"
|
|
2894
|
+
* @param document - Document with optional id, slug, parent, model type, and initial state
|
|
2895
|
+
* @param signer - Optional signer to sign the actions
|
|
2774
2896
|
* @param signal - Optional abort signal to cancel the request
|
|
2775
|
-
* @
|
|
2897
|
+
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2898
|
+
* @returns The job status
|
|
2776
2899
|
*/
|
|
2777
|
-
|
|
2900
|
+
create(document: PHDocument, signer?: ISigner, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
2778
2901
|
/**
|
|
2779
|
-
*
|
|
2902
|
+
* Deletes a document
|
|
2780
2903
|
*
|
|
2781
|
-
* @param
|
|
2782
|
-
* @param
|
|
2783
|
-
* @param branch - Optional branch to remove children from, defaults to "main"
|
|
2904
|
+
* @param id - Document id
|
|
2905
|
+
* @param signer - Optional signer to sign the actions
|
|
2784
2906
|
* @param signal - Optional abort signal to cancel the request
|
|
2785
|
-
* @
|
|
2907
|
+
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2908
|
+
* @returns The job id and status
|
|
2786
2909
|
*/
|
|
2787
|
-
|
|
2910
|
+
deleteDocument(id: string, signer?: ISigner, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
2788
2911
|
/**
|
|
2789
|
-
*
|
|
2912
|
+
* Applies a list of actions to a document.
|
|
2790
2913
|
*
|
|
2791
|
-
* @param
|
|
2792
|
-
* @param
|
|
2793
|
-
* @param
|
|
2794
|
-
* @param branch - Optional branch to move children to, defaults to "main"
|
|
2914
|
+
* @param docId - Document id
|
|
2915
|
+
* @param branch - Branch to apply actions to
|
|
2916
|
+
* @param actions - List of actions to apply
|
|
2795
2917
|
* @param signal - Optional abort signal to cancel the request
|
|
2796
|
-
* @
|
|
2918
|
+
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2919
|
+
* @returns The job id and status
|
|
2797
2920
|
*/
|
|
2798
|
-
|
|
2799
|
-
source: PHDocument;
|
|
2800
|
-
target: PHDocument;
|
|
2801
|
-
}>;
|
|
2921
|
+
execute(docId: string, branch: string, actions: Action[], signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
2802
2922
|
/**
|
|
2803
|
-
*
|
|
2923
|
+
* Loads existing operations generated elsewhere into this reactor.
|
|
2804
2924
|
*
|
|
2805
|
-
* @param
|
|
2806
|
-
* @param
|
|
2925
|
+
* @param docId - Document id
|
|
2926
|
+
* @param branch - Branch to load operations to
|
|
2927
|
+
* @param operations - List of operations to load
|
|
2807
2928
|
* @param signal - Optional abort signal to cancel the request
|
|
2808
|
-
* @
|
|
2929
|
+
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2930
|
+
* @returns The job id and status
|
|
2809
2931
|
*/
|
|
2810
|
-
|
|
2932
|
+
load(docId: string, branch: string, operations: Operation[], signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
2811
2933
|
/**
|
|
2812
|
-
*
|
|
2934
|
+
* Applies multiple mutations across documents with dependency management.
|
|
2813
2935
|
*
|
|
2814
|
-
* @param
|
|
2815
|
-
* @param propagate - Optional mode for handling children, CASCADE deletes child documents
|
|
2936
|
+
* @param request - Batch mutation request containing jobs with dependencies
|
|
2816
2937
|
* @param signal - Optional abort signal to cancel the request
|
|
2817
|
-
* @
|
|
2938
|
+
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2939
|
+
* @returns Map of job keys to job information
|
|
2818
2940
|
*/
|
|
2819
|
-
|
|
2941
|
+
executeBatch(request: BatchExecutionRequest, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<BatchExecutionResult>;
|
|
2820
2942
|
/**
|
|
2821
2943
|
* Loads multiple batches of pre-existing operations across documents with dependency management.
|
|
2822
|
-
* Waits for all jobs to complete.
|
|
2823
2944
|
*
|
|
2824
2945
|
* @param request - Batch load request containing jobs with dependencies
|
|
2825
2946
|
* @param signal - Optional abort signal to cancel the request
|
|
2826
|
-
* @
|
|
2947
|
+
* @param meta - Optional metadata that flows through the job lifecycle
|
|
2948
|
+
* @returns Map of job keys to job information
|
|
2827
2949
|
*/
|
|
2828
|
-
loadBatch(request: BatchLoadRequest, signal?: AbortSignal): Promise<BatchLoadResult>;
|
|
2950
|
+
loadBatch(request: BatchLoadRequest, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<BatchLoadResult>;
|
|
2829
2951
|
/**
|
|
2830
|
-
*
|
|
2952
|
+
* Adds a relationship between two documents.
|
|
2831
2953
|
*
|
|
2832
|
-
* @param
|
|
2954
|
+
* @param sourceId - Source document id
|
|
2955
|
+
* @param targetId - Target document id
|
|
2956
|
+
* @param relationshipType - Relationship type identifier
|
|
2957
|
+
* @param branch - Branch to add the relationship to, defaults to "main"
|
|
2958
|
+
* @param signer - Optional signer to sign the actions
|
|
2833
2959
|
* @param signal - Optional abort signal to cancel the request
|
|
2834
|
-
* @returns The job status
|
|
2960
|
+
* @returns The job id and status
|
|
2835
2961
|
*/
|
|
2836
|
-
|
|
2962
|
+
addRelationship(sourceId: string, targetId: string, relationshipType: string, branch?: string, signer?: ISigner, signal?: AbortSignal): Promise<JobInfo>;
|
|
2837
2963
|
/**
|
|
2838
|
-
*
|
|
2964
|
+
* Removes a relationship between two documents.
|
|
2839
2965
|
*
|
|
2840
|
-
* @param
|
|
2966
|
+
* @param sourceId - Source document id
|
|
2967
|
+
* @param targetId - Target document id
|
|
2968
|
+
* @param relationshipType - Relationship type identifier
|
|
2969
|
+
* @param branch - Branch to remove the relationship from, defaults to "main"
|
|
2970
|
+
* @param signer - Optional signer to sign the actions
|
|
2841
2971
|
* @param signal - Optional abort signal to cancel the request
|
|
2842
|
-
* @returns The
|
|
2972
|
+
* @returns The job id and status
|
|
2843
2973
|
*/
|
|
2844
|
-
|
|
2974
|
+
removeRelationship(sourceId: string, targetId: string, relationshipType: string, branch?: string, signer?: ISigner, signal?: AbortSignal): Promise<JobInfo>;
|
|
2845
2975
|
/**
|
|
2846
|
-
*
|
|
2976
|
+
* Retrieves the status of a job
|
|
2847
2977
|
*
|
|
2848
|
-
* @param
|
|
2849
|
-
* @
|
|
2850
|
-
* @param view - Optional filter containing branch and scopes information
|
|
2851
|
-
* @returns A function that unsubscribes from the changes
|
|
2978
|
+
* @param jobId - The job id
|
|
2979
|
+
* @returns The job status
|
|
2852
2980
|
*/
|
|
2853
|
-
|
|
2981
|
+
getJobStatus(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
2982
|
+
}
|
|
2983
|
+
/**
|
|
2984
|
+
* Feature flags for reactor configuration
|
|
2985
|
+
*/
|
|
2986
|
+
type ReactorFeatures = {
|
|
2987
|
+
[key: string]: boolean;
|
|
2988
|
+
};
|
|
2989
|
+
/**
|
|
2990
|
+
* Combined database type that includes all schemas
|
|
2991
|
+
*/
|
|
2992
|
+
type Database = Database$1 & DocumentViewDatabase & DocumentIndexerDatabase;
|
|
2993
|
+
/**
|
|
2994
|
+
* Container for all sync manager dependencies created during the build process.
|
|
2995
|
+
*/
|
|
2996
|
+
interface SyncModule {
|
|
2997
|
+
remoteStorage: ISyncRemoteStorage;
|
|
2998
|
+
cursorStorage: ISyncCursorStorage;
|
|
2999
|
+
deadLetterStorage: ISyncDeadLetterStorage;
|
|
3000
|
+
channelFactory: IChannelFactory;
|
|
3001
|
+
syncManager: ISyncManager;
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* Container for all reactor dependencies created during the build process.
|
|
3005
|
+
* Provides direct access to internal components for advanced use cases,
|
|
3006
|
+
* testing, or integration scenarios.
|
|
3007
|
+
*/
|
|
3008
|
+
interface ReactorModule {
|
|
3009
|
+
eventBus: IEventBus;
|
|
3010
|
+
documentModelRegistry: IDocumentModelRegistry;
|
|
3011
|
+
queue: IQueue;
|
|
3012
|
+
jobTracker: IJobTracker;
|
|
3013
|
+
executorManager: IJobExecutorManager;
|
|
3014
|
+
database: Kysely<Database>;
|
|
3015
|
+
operationStore: IOperationStore;
|
|
3016
|
+
keyframeStore: IKeyframeStore;
|
|
3017
|
+
writeCache: IWriteCache;
|
|
3018
|
+
operationIndex: IOperationIndex;
|
|
3019
|
+
documentView: IDocumentView;
|
|
3020
|
+
documentViewConsistencyTracker: IConsistencyTracker;
|
|
3021
|
+
documentIndexer: IDocumentIndexer;
|
|
3022
|
+
documentIndexerConsistencyTracker: IConsistencyTracker;
|
|
3023
|
+
readModelCoordinator: IReadModelCoordinator;
|
|
3024
|
+
subscriptionManager: IReactorSubscriptionManager;
|
|
3025
|
+
processorManager: IProcessorManager$1;
|
|
3026
|
+
processorManagerConsistencyTracker: IConsistencyTracker;
|
|
3027
|
+
syncModule: SyncModule | undefined;
|
|
3028
|
+
reactor: IReactor;
|
|
3029
|
+
}
|
|
3030
|
+
/**
|
|
3031
|
+
* Container for all reactor client dependencies created during the build process.
|
|
3032
|
+
* Provides direct access to internal components for advanced use cases,
|
|
3033
|
+
* testing, or integration scenarios.
|
|
3034
|
+
*/
|
|
3035
|
+
interface ReactorClientModule {
|
|
3036
|
+
client: ReactorClient;
|
|
3037
|
+
reactor: IReactor;
|
|
3038
|
+
eventBus: IEventBus;
|
|
3039
|
+
documentIndexer: IDocumentIndexer;
|
|
3040
|
+
documentView: IDocumentView;
|
|
3041
|
+
signer: ISigner;
|
|
3042
|
+
subscriptionManager: IReactorSubscriptionManager;
|
|
3043
|
+
jobAwaiter: IJobAwaiter;
|
|
3044
|
+
reactorModule: ReactorModule | undefined;
|
|
2854
3045
|
}
|
|
2855
3046
|
//#endregion
|
|
2856
|
-
//#region src/client/
|
|
3047
|
+
//#region src/client/drive-client.d.ts
|
|
2857
3048
|
/**
|
|
2858
|
-
*
|
|
2859
|
-
* a simpler interface for document operations.
|
|
3049
|
+
* Implementation of {@link IDriveClient}.
|
|
2860
3050
|
*
|
|
2861
|
-
*
|
|
2862
|
-
* -
|
|
2863
|
-
* -
|
|
2864
|
-
*
|
|
2865
|
-
* - Wraps subscription interface with ViewFilters
|
|
3051
|
+
* Holds a back-reference to its parent {@link IReactorClient} for read and
|
|
3052
|
+
* single-document write primitives, plus direct access to {@link IReactor}
|
|
3053
|
+
* for batch execution. The back-reference is captured but never invoked
|
|
3054
|
+
* during construction, so the partial-`this` hazard does not apply.
|
|
2866
3055
|
*/
|
|
2867
|
-
declare class
|
|
2868
|
-
private
|
|
2869
|
-
private
|
|
2870
|
-
private
|
|
2871
|
-
private
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
* @param documentType - The document type identifier
|
|
2884
|
-
* @returns The document model module
|
|
2885
|
-
*/
|
|
2886
|
-
getDocumentModelModule(documentType: string): Promise<DocumentModelModule<any>>;
|
|
2887
|
-
/**
|
|
2888
|
-
* Retrieves a specific PHDocument
|
|
2889
|
-
*/
|
|
2890
|
-
get<TDocument extends PHDocument>(identifier: string, view?: ViewFilter, signal?: AbortSignal): Promise<TDocument>;
|
|
2891
|
-
/**
|
|
2892
|
-
* Retrieves operations for a document
|
|
2893
|
-
*/
|
|
2894
|
-
getOperations(documentIdentifier: string, view?: ViewFilter, filter?: OperationFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
|
|
2895
|
-
private getOperationsWithCompositeCursor;
|
|
2896
|
-
/**
|
|
2897
|
-
* Retrieves children of a document
|
|
2898
|
-
*/
|
|
2899
|
-
getChildren(parentIdentifier: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
2900
|
-
/**
|
|
2901
|
-
* Retrieves parents of a document
|
|
2902
|
-
*/
|
|
2903
|
-
getParents(childIdentifier: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
2904
|
-
/**
|
|
2905
|
-
* Filters documents by criteria and returns a list of them
|
|
2906
|
-
*/
|
|
2907
|
-
find(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
2908
|
-
/**
|
|
2909
|
-
* Creates a document and waits for completion
|
|
2910
|
-
*/
|
|
2911
|
-
create<TDocument extends PHDocument = PHDocument>(document: PHDocument, parentIdentifier?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
2912
|
-
/**
|
|
2913
|
-
* Creates an empty document and waits for completion
|
|
2914
|
-
*/
|
|
2915
|
-
createEmpty<TDocument extends PHDocument>(documentModelType: string, options?: CreateDocumentOptions, signal?: AbortSignal): Promise<TDocument>;
|
|
2916
|
-
/**
|
|
2917
|
-
* Creates an empty document in a drive as a single batched operation.
|
|
2918
|
-
*/
|
|
2919
|
-
createDocumentInDrive<TDocument extends PHDocument>(driveId: string, document: PHDocument, parentFolder?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
2920
|
-
/**
|
|
2921
|
-
* Applies a list of actions to a document and waits for completion
|
|
2922
|
-
*/
|
|
2923
|
-
execute<TDocument extends PHDocument>(documentIdentifier: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<TDocument>;
|
|
2924
|
-
/**
|
|
2925
|
-
* Submits a list of actions to a document
|
|
2926
|
-
*/
|
|
2927
|
-
executeAsync(documentIdentifier: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<JobInfo>;
|
|
2928
|
-
/**
|
|
2929
|
-
* Renames a document and waits for completion
|
|
2930
|
-
*/
|
|
2931
|
-
rename(documentIdentifier: string, name: string, branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
2932
|
-
/**
|
|
2933
|
-
* Adds multiple documents as children to another and waits for completion
|
|
2934
|
-
*/
|
|
2935
|
-
addChildren(parentIdentifier: string, documentIdentifiers: string[], branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
2936
|
-
/**
|
|
2937
|
-
* Removes multiple documents as children from another and waits for completion
|
|
2938
|
-
*/
|
|
2939
|
-
removeChildren(parentIdentifier: string, documentIdentifiers: string[], branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
2940
|
-
/**
|
|
2941
|
-
* Moves multiple documents from one parent to another and waits for completion
|
|
2942
|
-
*/
|
|
2943
|
-
moveChildren(sourceParentIdentifier: string, targetParentIdentifier: string, documentIdentifiers: string[], branch?: string, signal?: AbortSignal): Promise<{
|
|
2944
|
-
source: PHDocument;
|
|
2945
|
-
target: PHDocument;
|
|
2946
|
-
}>;
|
|
2947
|
-
loadBatch(request: BatchLoadRequest, signal?: AbortSignal): Promise<BatchLoadResult>;
|
|
2948
|
-
/**
|
|
2949
|
-
* Deletes a document and waits for completion
|
|
2950
|
-
*/
|
|
2951
|
-
deleteDocument(identifier: string, propagate?: PropagationMode, signal?: AbortSignal): Promise<void>;
|
|
2952
|
-
/**
|
|
2953
|
-
* Deletes documents and waits for completion
|
|
2954
|
-
*/
|
|
2955
|
-
deleteDocuments(identifiers: string[], propagate?: PropagationMode, signal?: AbortSignal): Promise<void>;
|
|
2956
|
-
/**
|
|
2957
|
-
* Retrieves the status of a job
|
|
2958
|
-
*/
|
|
2959
|
-
getJobStatus(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
2960
|
-
/**
|
|
2961
|
-
* Waits for a job to complete
|
|
2962
|
-
*/
|
|
2963
|
-
waitForJob(jobId: string | JobInfo, signal?: AbortSignal): Promise<JobInfo>;
|
|
2964
|
-
/**
|
|
2965
|
-
* Subscribes to changes for documents matching specified filters
|
|
2966
|
-
*/
|
|
2967
|
-
subscribe(search: SearchFilter, callback: (event: DocumentChangeEvent) => void, view?: ViewFilter): () => void;
|
|
2968
|
-
private removeFromAllParents;
|
|
2969
|
-
private removeFromParent;
|
|
3056
|
+
declare class DriveClient implements IDriveClient {
|
|
3057
|
+
private readonly client;
|
|
3058
|
+
private readonly logger;
|
|
3059
|
+
private readonly reactor;
|
|
3060
|
+
private readonly signer;
|
|
3061
|
+
constructor(client: IReactorClient, logger: ILogger, reactor: IReactor, signer: ISigner);
|
|
3062
|
+
create(input: DriveInput, signal?: AbortSignal): Promise<DocumentDriveDocument>;
|
|
3063
|
+
addFile<TDocument extends PHDocument = PHDocument>(driveIdentifier: string, document: PHDocument, parentFolder?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
3064
|
+
addFolder(driveIdentifier: string, name: string, parentFolder?: string, signal?: AbortSignal): Promise<FolderNode>;
|
|
3065
|
+
removeNode(driveIdentifier: string, nodeId: string, signal?: AbortSignal): Promise<void>;
|
|
3066
|
+
renameNode(driveIdentifier: string, nodeId: string, name: string, signal?: AbortSignal): Promise<Node>;
|
|
3067
|
+
moveNode(driveIdentifier: string, srcNodeId: string, targetParentFolderId: string | undefined, signal?: AbortSignal): Promise<DocumentDriveDocument>;
|
|
3068
|
+
copyNode(driveIdentifier: string, srcNodeId: string, targetParentFolderId: string | undefined, signal?: AbortSignal): Promise<DocumentDriveDocument>;
|
|
3069
|
+
getNode(driveIdentifier: string, nodeId: string, signal?: AbortSignal): Promise<Node>;
|
|
3070
|
+
listNodes(driveIdentifier: string, parentFolder?: string | null, signal?: AbortSignal): Promise<Node[]>;
|
|
3071
|
+
private removeFileNode;
|
|
2970
3072
|
}
|
|
2971
3073
|
//#endregion
|
|
2972
3074
|
//#region src/cache/write-cache-types.d.ts
|
|
@@ -3156,8 +3258,8 @@ declare class Reactor implements IReactor {
|
|
|
3156
3258
|
get<TDocument extends PHDocument>(id: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
|
|
3157
3259
|
getBySlug<TDocument extends PHDocument>(slug: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
|
|
3158
3260
|
getByIdOrSlug<TDocument extends PHDocument>(identifier: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
|
|
3159
|
-
|
|
3160
|
-
|
|
3261
|
+
getOutgoingRelationships(sourceId: string, relationshipType: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
|
|
3262
|
+
getIncomingRelationships(targetId: string, relationshipType: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
|
|
3161
3263
|
getOperations(documentId: string, view?: ViewFilter, filter?: OperationFilter, paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<Record<string, PagedResults<Operation>>>;
|
|
3162
3264
|
find(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
3163
3265
|
create(document: PHDocument, signer?: ISigner, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
@@ -3166,8 +3268,8 @@ declare class Reactor implements IReactor {
|
|
|
3166
3268
|
load(docId: string, branch: string, operations: Operation[], signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
3167
3269
|
executeBatch(request: BatchExecutionRequest, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<BatchExecutionResult>;
|
|
3168
3270
|
loadBatch(request: BatchLoadRequest, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<BatchLoadResult>;
|
|
3169
|
-
|
|
3170
|
-
|
|
3271
|
+
addRelationship(sourceId: string, targetId: string, relationshipType: string, branch?: string, signer?: ISigner, signal?: AbortSignal): Promise<JobInfo>;
|
|
3272
|
+
removeRelationship(sourceId: string, targetId: string, relationshipType: string, branch?: string, signer?: ISigner, signal?: AbortSignal): Promise<JobInfo>;
|
|
3171
3273
|
getJobStatus(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
3172
3274
|
private findByIds;
|
|
3173
3275
|
private findBySlugs;
|
|
@@ -4388,5 +4490,5 @@ declare class ProcessorManager extends BaseReadModel implements IProcessorManage
|
|
|
4388
4490
|
private deleteProcessorCursors;
|
|
4389
4491
|
}
|
|
4390
4492
|
//#endregion
|
|
4391
|
-
export { type AtomicTxn, type AttachmentHash, type AttachmentRef, BaseReadModel, type BatchLoadRequest, type BatchLoadResult, type CachedSnapshot, type ChannelConfig, ChannelError, ChannelErrorSource, type ChannelHealth, type ChannelMeta, ChannelScheme, type ConnectionState, type ConnectionStateChangeCallback, type ConnectionStateChangedEvent, type ConnectionStateSnapshot, type ConsistencyCoordinate, type ConsistencyKey, type ConsistencyToken, ConsistencyTracker, type Database, type DeadLetterAddedEvent, DefaultSubscriptionErrorHandler, type DocumentChangeEvent, DocumentChangeType, type DocumentGraphEdge, type DocumentIndexerDatabase, DocumentIntegrityService, DocumentModelRegistry, type DocumentRelationship, type DocumentRevisions, type DocumentStreamKey, type DocumentViewDatabase, DuplicateManifestError, DuplicateModuleError, DuplicateOperationError, EventBus, EventBusAggregateError, type ExecutorStartedEvent, type ExecutorStoppedEvent, type GqlChannelConfig, GqlRequestChannel, GqlRequestChannelFactory, GqlResponseChannel, GqlResponseChannelFactory, type IChannel, type IChannelFactory, type IConsistencyTracker, type IDocumentGraph, type IDocumentIndexer, type IDocumentIntegrityService, type IDocumentModelLoader, type IDocumentModelRegistry, type IDocumentView, type IEventBus, type IJobAwaiter, type IJobExecutor, type IJobExecutorManager, type IJobTracker, type IKeyframeStore, type IOperationIndex, type IOperationStore, type IPollTimer, type IProcessor, type IProcessorHostModule, type IProcessorManager, type IQueue, type IReactor, type IReactorClient, type IReactorSubscriptionManager, type IReadModel, type IReadModelCoordinator, type IRelationalDb, type ISubscriptionErrorHandler, type ISyncCursorStorage, type ISyncManager, type ISyncRemoteStorage, type ISyncStatusTracker, type IWriteCache, SimpleJobExecutor as InMemoryJobExecutor, SimpleJobExecutor, InMemoryJobTracker, InMemoryQueue, type InsertableDocumentSnapshot, IntervalPollTimer, InvalidModuleError, type Job, type JobAvailableEvent, JobAwaiter, type JobCompletedEvent, type JobExecutorConfig, JobExecutorEventTypes, type JobExecutorFactory, type JobFailedEvent, type JobInfo, type JobPendingEvent, type JobReadReadyEvent, type JobResult, type JobRunningEvent, type JobStartedEvent, JobStatus, type JobWriteReadyEvent, type JwtHandler, type KeyframeSnapshot, type KeyframeValidationIssue, KyselyDocumentIndexer, KyselyDocumentView, KyselyKeyframeStore, KyselyOperationStore, KyselySyncCursorStorage, KyselySyncRemoteStorage, KyselyWriteCache, type LoadJobPlan, Mailbox, ModuleNotFoundError, NullDocumentModelResolver, type OperationBatch, type OperationContext, type OperationFilter, type OperationIndexEntry, type OperationTable, type OperationWithContext, OptimisticLockError, type PagedResults, type PagingOptions, type ParsedDriveUrl, PollingChannelError, type ProcessorApp, type ProcessorFactory, type ProcessorFactoryBuilder, type ProcessorFilter, ProcessorManager, type ProcessorRecord, type ProcessorStatus, PropagationMode, QueueEventTypes, REACTOR_SCHEMA, Reactor, ReactorBuilder, ReactorClient, ReactorClientBuilder, type ReactorClientModule, ReactorEventTypes, type ReactorFeatures, type JobFailedEvent$1 as ReactorJobFailedEvent, type ReactorModule, ReactorSubscriptionManager, ReadModelCoordinator, type RebuildResult, RelationalDbProcessor, RelationshipChangeType, type Remote, type RemoteCursor, type RemoteFilter, type RemoteOptions, type RemoteRecord, type RemoteStatus, RevisionMismatchError, type SearchFilter, type ShutdownStatus, type SignatureVerificationHandler, type SignerConfig, SimpleJobExecutorManager, type SnapshotValidationIssue, type Database$1 as StorageDatabase, type SubscriptionErrorContext, SyncBuilder, type SyncEnvelope, type SyncEnvelopeType, SyncEventTypes, type SyncFailedEvent, type SyncModule, SyncOperation, SyncOperationAggregateError, type SyncOperationErrorType, SyncOperationStatus, type SyncPendingEvent, SyncStatus, type SyncStatusChangeCallback, SyncStatusTracker, type SyncSucceededEvent, type TrackedProcessor, type Unsubscribe, type ValidationResult, type ViewFilter, type WriteCacheConfig, addRelationshipAction, batchOperationsByDocument, consolidateSyncOperations, createDocumentAction, createMutableShutdownStatus, createRelationalDb, deleteDocumentAction, documentActions, driveCollectionId, driveIdFromUrl, envelopesToSyncOperations, getMigrationStatus, makeConsistencyKey, parseDriveUrl, removeRelationshipAction, runMigrations, sortEnvelopesByFirstOperationTimestamp, trimMailboxFromAckOrdinal, upgradeDocumentAction };
|
|
4493
|
+
export { type AtomicTxn, type AttachmentHash, type AttachmentRef, BaseReadModel, type BatchLoadRequest, type BatchLoadResult, type CachedSnapshot, type ChannelConfig, ChannelError, ChannelErrorSource, type ChannelHealth, type ChannelMeta, ChannelScheme, type ConnectionState, type ConnectionStateChangeCallback, type ConnectionStateChangedEvent, type ConnectionStateSnapshot, type ConsistencyCoordinate, type ConsistencyKey, type ConsistencyToken, ConsistencyTracker, type Database, type DeadLetterAddedEvent, DefaultSubscriptionErrorHandler, type DocumentChangeEvent, DocumentChangeType, type DocumentGraphEdge, type DocumentIndexerDatabase, DocumentIntegrityService, DocumentModelRegistry, type DocumentRelationship, type DocumentRevisions, type DocumentStreamKey, type DocumentViewDatabase, DriveClient, DuplicateManifestError, DuplicateModuleError, DuplicateOperationError, EventBus, EventBusAggregateError, type ExecutorStartedEvent, type ExecutorStoppedEvent, type GqlChannelConfig, GqlRequestChannel, GqlRequestChannelFactory, GqlResponseChannel, GqlResponseChannelFactory, type IChannel, type IChannelFactory, type IConsistencyTracker, type IDocumentGraph, type IDocumentIndexer, type IDocumentIntegrityService, type IDocumentModelLoader, type IDocumentModelRegistry, type IDocumentView, type IDriveClient, type IEventBus, type IJobAwaiter, type IJobExecutor, type IJobExecutorManager, type IJobTracker, type IKeyframeStore, type IOperationIndex, type IOperationStore, type IPollTimer, type IProcessor, type IProcessorHostModule, type IProcessorManager, type IQueue, type IReactor, type IReactorClient, type IReactorSubscriptionManager, type IReadModel, type IReadModelCoordinator, type IRelationalDb, type ISubscriptionErrorHandler, type ISyncCursorStorage, type ISyncManager, type ISyncRemoteStorage, type ISyncStatusTracker, type IWriteCache, SimpleJobExecutor as InMemoryJobExecutor, SimpleJobExecutor, InMemoryJobTracker, InMemoryQueue, type InsertableDocumentSnapshot, IntervalPollTimer, InvalidModuleError, type Job, type JobAvailableEvent, JobAwaiter, type JobCompletedEvent, type JobExecutorConfig, JobExecutorEventTypes, type JobExecutorFactory, type JobFailedEvent, type JobInfo, type JobPendingEvent, type JobReadReadyEvent, type JobResult, type JobRunningEvent, type JobStartedEvent, JobStatus, type JobWriteReadyEvent, type JwtHandler, type KeyframeSnapshot, type KeyframeValidationIssue, KyselyDocumentIndexer, KyselyDocumentView, KyselyKeyframeStore, KyselyOperationStore, KyselySyncCursorStorage, KyselySyncRemoteStorage, KyselyWriteCache, type LoadJobPlan, Mailbox, ModuleNotFoundError, NullDocumentModelResolver, type OperationBatch, type OperationContext, type OperationFilter, type OperationIndexEntry, type OperationTable, type OperationWithContext, OptimisticLockError, type PagedResults, type PagingOptions, type ParsedDriveUrl, PollingChannelError, type ProcessorApp, type ProcessorFactory, type ProcessorFactoryBuilder, type ProcessorFilter, ProcessorManager, type ProcessorRecord, type ProcessorStatus, PropagationMode, QueueEventTypes, REACTOR_SCHEMA, Reactor, ReactorBuilder, ReactorClient, ReactorClientBuilder, type ReactorClientModule, ReactorEventTypes, type ReactorFeatures, type JobFailedEvent$1 as ReactorJobFailedEvent, type ReactorModule, ReactorSubscriptionManager, ReadModelCoordinator, type RebuildResult, RelationalDbProcessor, RelationshipChangeType, type Remote, type RemoteCursor, type RemoteFilter, type RemoteOptions, type RemoteRecord, type RemoteStatus, RevisionMismatchError, type SearchFilter, type ShutdownStatus, type SignatureVerificationHandler, type SignerConfig, SimpleJobExecutorManager, type SnapshotValidationIssue, type Database$1 as StorageDatabase, type SubscriptionErrorContext, SyncBuilder, type SyncEnvelope, type SyncEnvelopeType, SyncEventTypes, type SyncFailedEvent, type SyncModule, SyncOperation, SyncOperationAggregateError, type SyncOperationErrorType, SyncOperationStatus, type SyncPendingEvent, SyncStatus, type SyncStatusChangeCallback, SyncStatusTracker, type SyncSucceededEvent, type TrackedProcessor, type Unsubscribe, type ValidationResult, type ViewFilter, type WriteCacheConfig, addRelationshipAction, batchOperationsByDocument, consolidateSyncOperations, createDocumentAction, createMutableShutdownStatus, createRelationalDb, deleteDocumentAction, documentActions, driveCollectionId, driveIdFromUrl, envelopesToSyncOperations, getMigrationStatus, makeConsistencyKey, parseDriveUrl, removeRelationshipAction, runMigrations, sortEnvelopesByFirstOperationTimestamp, trimMailboxFromAckOrdinal, upgradeDocumentAction };
|
|
4392
4494
|
//# sourceMappingURL=index.d.ts.map
|