@powerhousedao/reactor-browser 6.2.3-dev.8 → 6.2.3-dev.80
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/{attachment-service-D3EhiAJ7.d.ts → attachment-service-DPWkKp3y.d.ts} +636 -83
- package/dist/attachment-service-DPWkKp3y.d.ts.map +1 -0
- package/dist/{client-DjK30EQ-.js → client-BFnMV-EO.js} +39 -22
- package/dist/client-BFnMV-EO.js.map +1 -0
- package/dist/{client-D66jVnot.js → client-BUpynoY6.js} +345 -33
- package/dist/client-BUpynoY6.js.map +1 -0
- package/dist/{client-BIHN_UyR.d.ts → client-XPGQrO4a.d.ts} +3 -3
- package/dist/client-XPGQrO4a.d.ts.map +1 -0
- package/dist/dispatch-C8J9jQ-o.js +1171 -0
- package/dist/dispatch-C8J9jQ-o.js.map +1 -0
- package/dist/document-by-id-Dpp76ZNE.js +16 -0
- package/dist/document-by-id-Dpp76ZNE.js.map +1 -0
- package/dist/document-model-modules-XrYfGXt8.js +644 -0
- package/dist/document-model-modules-XrYfGXt8.js.map +1 -0
- package/dist/{document-operations-WeE6wIDt.js → document-operations-CdfiLNQN.js} +1919 -278
- package/dist/document-operations-CdfiLNQN.js.map +1 -0
- package/dist/global-BSyOOTvL.d.ts +647 -0
- package/dist/global-BSyOOTvL.d.ts.map +1 -0
- package/dist/{index-B33TKEqp.d.ts → index-Bjm0bSzf.d.ts} +19 -98
- package/dist/index-Bjm0bSzf.d.ts.map +1 -0
- package/dist/{index-BIVDXw3K.d.ts → index-rtDmzViP.d.ts} +3 -3
- package/dist/index-rtDmzViP.d.ts.map +1 -0
- package/dist/index.d.ts +813 -410
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +771 -119
- package/dist/index.js.map +1 -1
- package/dist/inspector-proxy-DODqs15F.d.ts +25 -0
- package/dist/inspector-proxy-DODqs15F.d.ts.map +1 -0
- package/dist/make-ph-event-functions-B5GU5xcR.js +180 -0
- package/dist/make-ph-event-functions-B5GU5xcR.js.map +1 -0
- package/dist/navigation-BqphkrOB.js +302 -0
- package/dist/navigation-BqphkrOB.js.map +1 -0
- package/dist/{pglite-CntadC_p-9NDG14dS.d.ts → pglite-CntadC_p-DTkdF8sr.d.ts} +11 -33
- package/dist/pglite-CntadC_p-DTkdF8sr.d.ts.map +1 -0
- package/dist/{relational-D1RB45sA.js → relational-DZuyKp2y.js} +66 -5
- package/dist/relational-DZuyKp2y.js.map +1 -0
- package/dist/{renown-rqK8sokh.js → renown-BtjgHBjH.js} +33 -28
- package/dist/{renown-rqK8sokh.js.map → renown-BtjgHBjH.js.map} +1 -1
- package/dist/{renown-BHxwP7xU.js → renown-BxkZYzbQ.js} +2 -2
- package/dist/{renown-BHxwP7xU.js.map → renown-BxkZYzbQ.js.map} +1 -1
- package/dist/src/ai/index.d.ts +53 -70
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/index.js +12 -28
- package/dist/src/ai/index.js.map +1 -1
- package/dist/src/analytics/index.d.ts +36 -44
- package/dist/src/analytics/index.d.ts.map +1 -1
- package/dist/src/analytics/index.js +4 -4
- package/dist/src/analytics/index.js.map +1 -1
- package/dist/src/document-model.d.ts +3 -4
- package/dist/src/document-model.d.ts.map +1 -1
- package/dist/src/document-model.js.map +1 -1
- package/dist/src/graphql/client.d.ts +4 -3
- package/dist/src/graphql/client.js +1 -1
- package/dist/src/graphql-client/entry.d.ts +5 -4
- package/dist/src/graphql-client/entry.js +4 -4
- package/dist/src/relational/index.d.ts +15 -9
- package/dist/src/relational/index.d.ts.map +1 -1
- package/dist/src/relational/index.js +1 -1
- package/dist/src/renown/index.d.ts +3 -2
- package/dist/src/renown/index.js +2 -2
- package/dist/src/rpc/index.d.ts +214 -140
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +587 -622
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/{store-BJYcr_FL.js → store-DInXcjal.js} +1 -1
- package/dist/{store-BJYcr_FL.js.map → store-DInXcjal.js.map} +1 -1
- package/dist/{switchboard-CaXQ4-5Q.js → switchboard-CYTCYt4Z.js} +61 -11
- package/dist/switchboard-CYTCYt4Z.js.map +1 -0
- package/dist/{types-6vDzbRRS.d.ts → types-520nWrB3.d.ts} +2 -2
- package/dist/types-520nWrB3.d.ts.map +1 -0
- package/dist/{types-Dcv1ZLoW.d.ts → types-BNVqRNli.d.ts} +320 -18
- package/dist/types-BNVqRNli.d.ts.map +1 -0
- package/package.json +21 -21
- package/dist/attachment-service-D3EhiAJ7.d.ts.map +0 -1
- package/dist/client-BIHN_UyR.d.ts.map +0 -1
- package/dist/client-D66jVnot.js.map +0 -1
- package/dist/client-DjK30EQ-.js.map +0 -1
- package/dist/document-by-id-B4FIzG1w.js +0 -519
- package/dist/document-by-id-B4FIzG1w.js.map +0 -1
- package/dist/document-model-modules-bTP87nyr.js +0 -419
- package/dist/document-model-modules-bTP87nyr.js.map +0 -1
- package/dist/document-operations-WeE6wIDt.js.map +0 -1
- package/dist/global-OuINvEGT.d.ts +0 -401
- package/dist/global-OuINvEGT.d.ts.map +0 -1
- package/dist/index-B33TKEqp.d.ts.map +0 -1
- package/dist/index-BIVDXw3K.d.ts.map +0 -1
- package/dist/inspector-proxy-6h5VKAwt.d.ts +0 -257
- package/dist/inspector-proxy-6h5VKAwt.d.ts.map +0 -1
- package/dist/make-ph-event-functions-DBq3iWYn.js +0 -53
- package/dist/make-ph-event-functions-DBq3iWYn.js.map +0 -1
- package/dist/pglite-CntadC_p-9NDG14dS.d.ts.map +0 -1
- package/dist/relational-D1RB45sA.js.map +0 -1
- package/dist/switchboard-CaXQ4-5Q.js.map +0 -1
- package/dist/types-6vDzbRRS.d.ts.map +0 -1
- package/dist/types-Dcv1ZLoW.d.ts.map +0 -1
|
@@ -1,34 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as PGlite } from "./pglite-CntadC_p-
|
|
3
|
-
import { A as
|
|
4
|
-
import { Action, DocumentModelLib, DocumentModelModule, Operation, PHDocument } from "document-model";
|
|
5
|
-
import { Action as Action$1, DocumentModelModule as DocumentModelModule$1, DocumentOperations, ISigner, Operation as Operation$1, PHBaseState, PHDocument as PHDocument$1, PHDocumentHeader } from "@powerhousedao/shared/document-model";
|
|
6
|
-
import * as _powerhousedao_reactor0 from "@powerhousedao/reactor";
|
|
7
|
-
import { Database, DocumentChangeEvent, DocumentModelSource, IDocumentModelRegistry, ISyncManager, OperationFilter, PagedResults, PagingOptions, PropagationMode, SearchFilter, ViewFilter } from "@powerhousedao/reactor";
|
|
1
|
+
import { $ as IPackageManager, Gt as IDocumentCache, Ht as DocumentRefetchState, Jt as OperationsCacheEntry, Kt as IDocumentTypeCache, Lt as IReactorBrowserClient$1, Q as IPackageListerUnsubscribe, Rt as IReactorBrowserReadClient, Ut as DocumentsOfTypeEntry, Xt as PromiseWithState, Yt as PromiseState, b as UsePHGlobalValue$1, et as IPackagesListener, qt as IOperationCache, s as PHGlobal$1, tt as PackageManagerInstallResult, v as SetPHGlobalValue$1, zt as IReactorBrowserWriteClient } from "./global-BSyOOTvL.js";
|
|
2
|
+
import { t as PGlite } from "./pglite-CntadC_p-DTkdF8sr.js";
|
|
3
|
+
import { A as Sdk, C as GetDocumentQuery, D as PhDocumentFieldsFragment, M as ViewFilterInput, O as PropagationMode$1, S as GetDocumentOperationsQuery, T as JobChangesSubscription, b as DocumentChangesSubscription, c as ReactorGraphQLClient, g as ActionInput, j as SdkFunctionWrapper, k as Scalars } from "./types-BNVqRNli.js";
|
|
8
4
|
import { ReactNode } from "react";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
5
|
+
import { Action, DocumentModelLib, DocumentModelModule, Operation, PHDocument } from "document-model";
|
|
6
|
+
import { Action as Action$1, ActionSigningTarget, DispatchOutcome, DocumentModelModule as DocumentModelModule$1, DocumentOperations, ISigner, Operation as Operation$1, PHBaseState, PHDocument as PHDocument$1, PHDocumentHeader, ProtocolVersions, SignaturePolicy } from "@powerhousedao/shared/document-model";
|
|
7
|
+
import { BatchExecutionRequest, BatchExecutionResult, ConsistencyToken, CreateProtocolVersionsOptions, Database, DocumentChangeEvent, DocumentModelSource, DocumentRelationship, DriveNodeKind, DriveNodePage, DriveNodeRecord, IDocumentModelRegistry, IDriveNodeSource, IDriveReadClient, IReactorClient, ISyncManager, JobInfo, NewDocumentOptions, OperationFilter, PagedResults, PagingOptions, PropagationMode, SearchFilter, ViewFilter } from "@powerhousedao/reactor";
|
|
8
|
+
import { Node } from "@powerhousedao/shared/document-drive";
|
|
11
9
|
import { DocumentNode } from "graphql";
|
|
12
|
-
import
|
|
10
|
+
import { GraphQLClient, Variables } from "graphql-request";
|
|
13
11
|
import { IAttachmentService } from "@powerhousedao/reactor-attachments/client";
|
|
14
12
|
import { Kysely } from "kysely";
|
|
15
|
-
import { AddPHGlobalEventHandler, BrowserReactorClientModule, IReactorBrowserClient, SetPHGlobalValue, UsePHGlobalValue, WorkerReactorClientModule } from "@powerhousedao/reactor-browser";
|
|
13
|
+
import { AddPHGlobalEventHandler, BrowserReactorClientModule, IReactorBrowserClient, ReactorBrowserHalves, SetPHGlobalValue, UsePHGlobalValue, WorkerReactorClientModule } from "@powerhousedao/reactor-browser";
|
|
16
14
|
import { RegistryPackageSource } from "@powerhousedao/shared";
|
|
17
|
-
|
|
15
|
+
//#region src/actions/dispatch.d.ts
|
|
16
|
+
/** Called once the write lands; `outcome.rejected` is empty when every action applied. */
|
|
17
|
+
type DispatchSuccessCallback = (result: PHDocument$1, outcome: DispatchOutcome) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Dispatches actions to a document.
|
|
20
|
+
* @param actionOrActions - The action or actions to dispatch.
|
|
21
|
+
* @param document - The document to dispatch actions to.
|
|
22
|
+
* @param onErrors - Callback invoked with an `OperationRejectedError` for each action the
|
|
23
|
+
* document did not apply, or with why nothing was dispatched. Runs before `onSuccess`.
|
|
24
|
+
* @param onSuccess - Callback invoked with the updated document once the write lands, after
|
|
25
|
+
* `onErrors` and also when an action was rejected; `outcome.rejected` lists the rejections.
|
|
26
|
+
* @returns The updated document, or undefined if the dispatch failed.
|
|
27
|
+
*/
|
|
28
|
+
declare function dispatchActions<TDocument = PHDocument$1, TAction = Action$1>(actionOrActions: TAction[] | TAction | undefined, document: TDocument | undefined, onErrors?: (errors: Error[]) => void, onSuccess?: DispatchSuccessCallback): Promise<PHDocument$1 | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Dispatches actions to a document.
|
|
31
|
+
* @param actionOrActions - The action or actions to dispatch.
|
|
32
|
+
* @param documentId - The ID of the document to dispatch actions to.
|
|
33
|
+
* @param onErrors - Callback invoked with an `OperationRejectedError` for each action the
|
|
34
|
+
* document did not apply. Runs before `onSuccess`.
|
|
35
|
+
* @param onSuccess - Callback invoked with the updated document once the write lands, after
|
|
36
|
+
* `onErrors` and also when an action was rejected; `outcome.rejected` lists the rejections.
|
|
37
|
+
* @returns The updated document, or undefined if the dispatch failed.
|
|
38
|
+
*/
|
|
39
|
+
declare function dispatchActions(actionOrActions: Action$1[] | Action$1 | undefined, documentId: string, onErrors?: (errors: Error[]) => void, onSuccess?: DispatchSuccessCallback): Promise<PHDocument$1 | undefined>;
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/document-refetcher.d.ts
|
|
42
|
+
/** The refetch snapshot of a document with nothing in flight and no kept failure. */
|
|
43
|
+
declare const IDLE_REFETCH_STATE: DocumentRefetchState;
|
|
44
|
+
//#endregion
|
|
18
45
|
//#region src/document-cache.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* The reads a {@link DocumentCache} makes. `getMany` is optional: without it,
|
|
48
|
+
* a batch reads each uncached id with `get`.
|
|
49
|
+
*/
|
|
50
|
+
interface IDocumentCacheReader extends Pick<IReactorBrowserReadClient, "get" | "find" | "getOperations" | "subscribe">, Partial<Pick<IReactorBrowserReadClient, "getMany">> {}
|
|
51
|
+
/** The most ids one `getMany` call is asked for. */
|
|
52
|
+
declare const GET_MANY_CHUNK_SIZE = 100;
|
|
19
53
|
declare function addPromiseState<T>(promise: Promise<T>): PromiseWithState<T>;
|
|
20
54
|
declare function readPromiseState<T>(promise: Promise<T> | PromiseWithState<T>): PromiseState<T>;
|
|
55
|
+
/** The snapshot every uncached document scope reads as. One frozen object, so `useSyncExternalStore` sees a stable value. */
|
|
56
|
+
declare const IDLE_OPERATIONS_ENTRY: OperationsCacheEntry;
|
|
57
|
+
/** Whether a document cache also serves operation history. `GraphQLClientDocumentCache` does not. */
|
|
58
|
+
declare function isOperationCache(cache: unknown): cache is IOperationCache;
|
|
59
|
+
/** The snapshot every unloaded type reads as, frozen so `useSyncExternalStore` sees one value. */
|
|
60
|
+
declare const IDLE_DOCUMENTS_OF_TYPE_ENTRY: DocumentsOfTypeEntry;
|
|
61
|
+
/** Whether a document cache also lists documents by type. */
|
|
62
|
+
declare function isDocumentTypeCache(cache: unknown): cache is IDocumentTypeCache;
|
|
21
63
|
/**
|
|
22
64
|
* Document cache implementation that uses the new ReactorClient API.
|
|
23
65
|
*
|
|
24
|
-
* This cache subscribes to document change events
|
|
66
|
+
* This cache subscribes to document change events through the client's read half
|
|
25
67
|
* and automatically updates the cache when documents are created, updated, or deleted.
|
|
68
|
+
* It is built over a browser client, whose `read` half it uses, or over a read
|
|
69
|
+
* half directly.
|
|
70
|
+
* It also holds paginated operation history per document scope (see `IOperationCache`),
|
|
71
|
+
* which is dropped for a document whenever a change event for it arrives.
|
|
26
72
|
*/
|
|
27
|
-
declare class DocumentCache implements IDocumentCache {
|
|
28
|
-
private client;
|
|
73
|
+
declare class DocumentCache implements IDocumentCache, IOperationCache, IDocumentTypeCache {
|
|
29
74
|
private documents;
|
|
30
75
|
private batchPromises;
|
|
31
76
|
private listeners;
|
|
77
|
+
private refetcher;
|
|
32
78
|
/**
|
|
33
79
|
* Cache keys that fetched a document under a name other than its id --
|
|
34
80
|
* slugs, which `client.get` resolves. Change events dispatch by `header.id`,
|
|
@@ -37,19 +83,84 @@ declare class DocumentCache implements IDocumentCache {
|
|
|
37
83
|
* the same document is cached under.
|
|
38
84
|
*/
|
|
39
85
|
private aliasKeys;
|
|
86
|
+
/** Operations by document id, then scope. Entries are replaced, never mutated. */
|
|
87
|
+
private operationEntries;
|
|
88
|
+
/** In-flight controllers and the next page's cursor/limit, by document id then scope. */
|
|
89
|
+
private operationRequests;
|
|
90
|
+
private operationListeners;
|
|
91
|
+
/** Documents by type and page size, keyed by typeKey. */
|
|
92
|
+
private typeEntries;
|
|
93
|
+
private typeRequests;
|
|
94
|
+
private typeListeners;
|
|
40
95
|
private unsubscribe;
|
|
41
|
-
|
|
96
|
+
private readonly client;
|
|
97
|
+
constructor(client: IReactorBrowserClient$1 | IDocumentCacheReader);
|
|
42
98
|
private handleDocumentChange;
|
|
43
99
|
private handleDocumentDeleted;
|
|
44
100
|
private handleDocumentUpdated;
|
|
101
|
+
private notifyListeners;
|
|
45
102
|
/** The id an event dispatches by, plus every alias the document is cached under. */
|
|
46
103
|
private cacheKeysFor;
|
|
47
104
|
/** Records that `key` cached the document change events know as `header.id`. */
|
|
48
105
|
private recordAlias;
|
|
49
106
|
private invalidateBatchesContaining;
|
|
50
107
|
get(id: string, refetch?: boolean): Promise<PHDocument$1>;
|
|
108
|
+
getRefetchState(id: string): DocumentRefetchState;
|
|
51
109
|
getBatch(ids: string[]): Promise<PHDocument$1[]>;
|
|
110
|
+
/**
|
|
111
|
+
* Reserves an entry for every id not yet cached and fills them from
|
|
112
|
+
* `getMany`, in chunks of {@link GET_MANY_CHUNK_SIZE}. Each id keeps its own
|
|
113
|
+
* entry, settled as `get` would settle it.
|
|
114
|
+
*/
|
|
115
|
+
private loadMany;
|
|
116
|
+
/**
|
|
117
|
+
* `getMany` rejects when any id is unavailable, so a failed chunk is split
|
|
118
|
+
* in half and retried; a single id is read with `get`, so it settles exactly
|
|
119
|
+
* as a single read would.
|
|
120
|
+
*/
|
|
121
|
+
private settleMany;
|
|
122
|
+
private settleFetched;
|
|
52
123
|
subscribe(id: string | string[], callback: () => void): () => void;
|
|
124
|
+
getOperationsState(documentId: string, scope: string): OperationsCacheEntry;
|
|
125
|
+
loadOperations(documentId: string, scope: string, limit: number): void;
|
|
126
|
+
loadMoreOperations(documentId: string, scope: string): void;
|
|
127
|
+
/**
|
|
128
|
+
* Bring a document's cached scopes up to date after it changed, without
|
|
129
|
+
* throwing away what is already loaded.
|
|
130
|
+
*
|
|
131
|
+
* The operation stream is append-only: an update adds operations at higher
|
|
132
|
+
* revisions and never rewrites the ones below, so history already paged in
|
|
133
|
+
* is still correct. Dropping it meant a panel showing a fully loaded
|
|
134
|
+
* document re-walked every page on each edit -- the cost of which grows
|
|
135
|
+
* with the document, exactly where it hurts most. Each scope instead asks
|
|
136
|
+
* only for what comes after the newest revision it holds, using the
|
|
137
|
+
* `sinceRevision` filter, and appends the answer.
|
|
138
|
+
*
|
|
139
|
+
* A scope that has not finished paging is dropped as before: it has no
|
|
140
|
+
* meaningful "newest revision" to resume from, since asking for everything
|
|
141
|
+
* past the newest row it happens to hold would skip the pages between that
|
|
142
|
+
* row and the end of the stream.
|
|
143
|
+
*/
|
|
144
|
+
private refreshOperations;
|
|
145
|
+
/** Drops one scope of a document, aborting its request if one is in flight. */
|
|
146
|
+
private invalidateOperationsScope;
|
|
147
|
+
invalidateOperations(documentId: string): void;
|
|
148
|
+
subscribeOperations(documentId: string, callback: () => void): () => void;
|
|
149
|
+
private settleOperationsPage;
|
|
150
|
+
private setOperationsEntry;
|
|
151
|
+
private setOperationsRequest;
|
|
152
|
+
private notifyOperationListeners;
|
|
153
|
+
getDocumentsOfTypeState(type: string, limit: number): DocumentsOfTypeEntry;
|
|
154
|
+
loadDocumentsOfType(type: string, limit: number): Promise<void>;
|
|
155
|
+
loadMoreDocumentsOfType(type: string, limit: number): void;
|
|
156
|
+
subscribeDocumentsOfType(type: string, limit: number, callback: () => void): () => void;
|
|
157
|
+
/** Loads one page after `before` and appends it; never rejects, the entry holds the error. */
|
|
158
|
+
private loadTypePage;
|
|
159
|
+
/** Reloads every loaded page of a type a created or deleted document belongs to. */
|
|
160
|
+
private reloadTypesChangedBy;
|
|
161
|
+
private primeDocument;
|
|
162
|
+
private getTypeEntry;
|
|
163
|
+
private setTypeEntry;
|
|
53
164
|
/**
|
|
54
165
|
* Disposes of the cache and unsubscribes from document change events.
|
|
55
166
|
*/
|
|
@@ -57,7 +168,7 @@ declare class DocumentCache implements IDocumentCache {
|
|
|
57
168
|
}
|
|
58
169
|
//#endregion
|
|
59
170
|
//#region src/remote-controller/types.d.ts
|
|
60
|
-
type RemoteControllerGraphQLClient = Pick<ReactorGraphQLClient, "GetDocument" | "GetDocumentWithOperations" | "GetDocumentOperations" | "MutateDocument" | "CreateDocument" | "CreateEmptyDocument" | "DeleteDocument" | "BatchGetDocumentOperations" | "BatchGetDocumentWithOperations">;
|
|
171
|
+
type RemoteControllerGraphQLClient = Pick<ReactorGraphQLClient, "GetDocument" | "GetDocumentWithOperations" | "GetDocumentOperations" | "MutateDocument" | "CreateDocument" | "CreateEmptyDocument" | "GetCreateDefaults" | "GetCreateProtocolVersions" | "DeleteDocument" | "BatchGetDocumentOperations" | "BatchGetDocumentWithOperations">;
|
|
61
172
|
type RemoteDocumentData = PhDocumentFieldsFragment;
|
|
62
173
|
type RemoteOperation = GetDocumentOperationsQuery["documentOperations"]["items"][number];
|
|
63
174
|
type RemoteOperationResultPage = GetDocumentOperationsQuery["documentOperations"];
|
|
@@ -65,14 +176,22 @@ type RemoteOperationResultPage = GetDocumentOperationsQuery["documentOperations"
|
|
|
65
176
|
* Options for creating a RemoteDocumentController.
|
|
66
177
|
*/
|
|
67
178
|
type RemoteControllerOptions = {
|
|
68
|
-
client: RemoteControllerGraphQLClient;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
179
|
+
client: RemoteControllerGraphQLClient;
|
|
180
|
+
/** Remote document id. Omit for new documents. */
|
|
181
|
+
documentId?: string;
|
|
182
|
+
/** "batch" requires explicit push(), "streaming" auto-pushes after actions. Defaults to "batch" */
|
|
183
|
+
mode?: "batch" | "streaming";
|
|
184
|
+
/** Optional signer for action signing. */
|
|
185
|
+
signer?: ISigner;
|
|
186
|
+
/** Branch name, defaults to "main". */
|
|
187
|
+
branch?: string;
|
|
188
|
+
/** Parent document identifier for creating new documents. */
|
|
189
|
+
parentIdentifier?: string;
|
|
190
|
+
/** Conflict resolution strategy when remote has new operations. Default: no check (current behavior). */
|
|
191
|
+
onConflict?: ConflictStrategy;
|
|
192
|
+
/** Called when a streaming-mode push fails. If not provided, errors are silently swallowed. */
|
|
193
|
+
onPushError?: (error: unknown) => void;
|
|
194
|
+
/** Number of operations to fetch per page. Defaults to 100. */
|
|
76
195
|
operationsPageSize?: number;
|
|
77
196
|
};
|
|
78
197
|
/**
|
|
@@ -80,7 +199,8 @@ type RemoteControllerOptions = {
|
|
|
80
199
|
*/
|
|
81
200
|
type PushResult = {
|
|
82
201
|
remoteDocument: RemoteDocumentData;
|
|
83
|
-
actionCount: number;
|
|
202
|
+
actionCount: number;
|
|
203
|
+
/** The actions that were sent to the server (after signing, if applicable). */
|
|
84
204
|
operations: ReadonlyArray<Action$1>;
|
|
85
205
|
};
|
|
86
206
|
/**
|
|
@@ -102,9 +222,13 @@ type TrackedAction = {
|
|
|
102
222
|
};
|
|
103
223
|
/** Information about a detected conflict. */
|
|
104
224
|
type ConflictInfo = {
|
|
105
|
-
/** Remote operations added since the last pull, grouped by scope. */
|
|
106
|
-
|
|
107
|
-
|
|
225
|
+
/** Remote operations added since the last pull, grouped by scope. */
|
|
226
|
+
remoteOperations: Record<string, RemoteOperation[]>;
|
|
227
|
+
/** Local actions pending push. */
|
|
228
|
+
localActions: TrackedAction[];
|
|
229
|
+
/** Remote revision at last pull. */
|
|
230
|
+
knownRevision: Record<string, number>;
|
|
231
|
+
/** Current remote revision. */
|
|
108
232
|
currentRevision: Record<string, number>;
|
|
109
233
|
};
|
|
110
234
|
/** Custom merge handler receives conflict info and returns actions to push (or throws to abort). */
|
|
@@ -170,8 +294,8 @@ type RevisionsListSelection = GetDocumentQueryFields["revisionsList"];
|
|
|
170
294
|
* `createPresignedHeader`: the creation signature is not fetchable over
|
|
171
295
|
* GraphQL and is not part of the operation signing payload.
|
|
172
296
|
*
|
|
173
|
-
* The read path never fetches operation history, so `operations`
|
|
174
|
-
* the document's
|
|
297
|
+
* The read path never fetches operation history, so `operations` maps each
|
|
298
|
+
* scope of the document's state and revisions to an empty array.
|
|
175
299
|
*
|
|
176
300
|
* `branch` is the branch the document was read from. The GraphQL type does not
|
|
177
301
|
* carry it, so it has to be passed back in by the caller; it defaults to the
|
|
@@ -188,6 +312,8 @@ declare function phDocumentFromGetDocument<TDocument extends PHDocument = PHDocu
|
|
|
188
312
|
declare function phDocumentFromMutation<TDocument extends PHDocument = PHDocument>(document: GetDocumentQueryFields, operations: readonly RemoteOperation[], branch?: string): TDocument;
|
|
189
313
|
/** Turns a `revisionsList` selection into the header's per-scope revision map. */
|
|
190
314
|
declare function revisionMapFromRevisionsList(revisionsList: RevisionsListSelection): Record<string, number>;
|
|
315
|
+
/** The `DateTime` scalar deserializes as either an ISO string or a `Date`. */
|
|
316
|
+
declare function isoStringFromDateTime(value: string | Date): string;
|
|
191
317
|
//#endregion
|
|
192
318
|
//#region src/graphql-client/auth.d.ts
|
|
193
319
|
/**
|
|
@@ -217,6 +343,88 @@ declare function ambientRenownTokenProvider(): Promise<string | undefined>;
|
|
|
217
343
|
*/
|
|
218
344
|
declare function makeAuthMiddleware(tokenProvider: BearerTokenProvider): SdkFunctionWrapper;
|
|
219
345
|
//#endregion
|
|
346
|
+
//#region src/graphql-client/drive-nodes.d.ts
|
|
347
|
+
/** The node queries a {@link GraphQLDriveNodeSource} runs. */
|
|
348
|
+
type DriveNodeQueries = Pick<Sdk, "GetDriveNodes" | "GetDriveNode" | "GetDriveDescendants">;
|
|
349
|
+
/**
|
|
350
|
+
* The reactor subgraph's type-neutral node queries (`driveNodes`, `driveNode`,
|
|
351
|
+
* `driveDescendants`) as an {@link IDriveNodeSource}, so a browser reads a
|
|
352
|
+
* legacy drive and a reactor-drive alike. The Switchboard serves only the
|
|
353
|
+
* nodes the caller may read. Drive ids must be canonical ids, not slugs.
|
|
354
|
+
*/
|
|
355
|
+
declare class GraphQLDriveNodeSource implements IDriveNodeSource {
|
|
356
|
+
private readonly queries;
|
|
357
|
+
private readonly headersFor;
|
|
358
|
+
constructor(queries: DriveNodeQueries, headersFor?: (driveId: string) => Record<string, string> | undefined);
|
|
359
|
+
getNode(driveId: string, nodeId: string, signal?: AbortSignal): Promise<DriveNodeRecord | undefined>;
|
|
360
|
+
listChildren(driveId: string, parentFolder: string | null | undefined, paging?: PagingOptions, signal?: AbortSignal, kind?: DriveNodeKind): Promise<DriveNodePage>;
|
|
361
|
+
getDescendants(driveId: string, root: string, signal?: AbortSignal): Promise<DriveNodeRecord[]>;
|
|
362
|
+
listAll(driveId: string, signal?: AbortSignal): Promise<DriveNodeRecord[]>;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* `read.drives` over a node source: the reactor's {@link IDriveReadClient},
|
|
366
|
+
* answering in the legacy `Node` shape for every drive type.
|
|
367
|
+
*/
|
|
368
|
+
declare class GraphQLDriveReadClient implements IDriveReadClient {
|
|
369
|
+
private readonly nodes;
|
|
370
|
+
constructor(nodes: IDriveNodeSource);
|
|
371
|
+
getNode(driveIdentifier: string, nodeId: string, signal?: AbortSignal): Promise<Node>;
|
|
372
|
+
listNodes(driveIdentifier: string, parentFolder?: string | null, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Node>>;
|
|
373
|
+
}
|
|
374
|
+
/** A node record in the legacy `Node` shape. */
|
|
375
|
+
declare function toLegacyNode(node: DriveNodeRecord): Node;
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/graphql-client/errors.d.ts
|
|
378
|
+
/** A call the Switchboard GraphQL surface cannot express. */
|
|
379
|
+
declare class GraphQLOperationNotSupportedError extends Error {
|
|
380
|
+
readonly name = "GraphQLOperationNotSupportedError";
|
|
381
|
+
readonly operation: string;
|
|
382
|
+
constructor(operation: string, reason: string);
|
|
383
|
+
static isError(error: unknown): error is GraphQLOperationNotSupportedError;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* The Switchboard refused a request with 421 Misdirected Request: the
|
|
387
|
+
* `Drive-Id` it carried names a drive that Switchboard does not own.
|
|
388
|
+
*/
|
|
389
|
+
declare class GraphQLWrongBackendError extends Error {
|
|
390
|
+
readonly name = "GraphQLWrongBackendError";
|
|
391
|
+
readonly status = 421;
|
|
392
|
+
/** The drive the Switchboard refused, or `""` when its answer names none. */
|
|
393
|
+
readonly driveId: string;
|
|
394
|
+
/** The response body, parsed when it is JSON. */
|
|
395
|
+
readonly payload: unknown;
|
|
396
|
+
constructor(driveId: string, payload: unknown, options?: ErrorOptions);
|
|
397
|
+
static isError(error: unknown): error is GraphQLWrongBackendError;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* The reactor's `BatchJobFailedError`, rebuilt from a batch result; this entry
|
|
401
|
+
* imports the reactor for types only. The shared name lets either `isError`
|
|
402
|
+
* recognise it.
|
|
403
|
+
*/
|
|
404
|
+
declare class BatchJobFailedError extends Error {
|
|
405
|
+
readonly name = "BatchJobFailedError";
|
|
406
|
+
readonly key: string;
|
|
407
|
+
readonly jobs: Readonly<Record<string, JobInfo>>;
|
|
408
|
+
constructor(key: string, jobs: Record<string, JobInfo>);
|
|
409
|
+
static isError(error: unknown): error is BatchJobFailedError;
|
|
410
|
+
}
|
|
411
|
+
/** A validation error naming root field `field` unknown: a host from before it. */
|
|
412
|
+
declare function queriesUnknownField(error: unknown, field: string): boolean;
|
|
413
|
+
/** A validation error naming `argument` unknown: a host from before it. */
|
|
414
|
+
declare function queriesUnknownArgument(error: unknown, argument: string): boolean;
|
|
415
|
+
/**
|
|
416
|
+
* The reactor's `JobFailedError`, rebuilt from a job the Switchboard reported
|
|
417
|
+
* FAILED; this entry imports the reactor for types only. A write handle's
|
|
418
|
+
* stage rejects with it. The message is the job error's message, as the
|
|
419
|
+
* reactor's is.
|
|
420
|
+
*/
|
|
421
|
+
declare class JobFailedError extends Error {
|
|
422
|
+
readonly name = "JobFailedError";
|
|
423
|
+
readonly job: JobInfo;
|
|
424
|
+
constructor(job: JobInfo);
|
|
425
|
+
static isError(error: unknown): error is JobFailedError;
|
|
426
|
+
}
|
|
427
|
+
//#endregion
|
|
220
428
|
//#region src/graphql-client/subgraph.d.ts
|
|
221
429
|
/**
|
|
222
430
|
* The factory a GraphQL code generator produces for a schema.
|
|
@@ -303,14 +511,25 @@ declare class SubgraphSdkRegistry {
|
|
|
303
511
|
}
|
|
304
512
|
//#endregion
|
|
305
513
|
//#region src/graphql-client/graphql-reactor-client.d.ts
|
|
514
|
+
/** A call the client asks {@link GraphQLReactorClientOptions.driveIdFor} about. */
|
|
515
|
+
type DriveIdCall = {
|
|
516
|
+
readonly method: "create" | "execute" | "executeBatch" | "deleteDocument" | "find";
|
|
517
|
+
readonly documentId?: string;
|
|
518
|
+
readonly parentId?: string;
|
|
519
|
+
readonly jobs?: readonly {
|
|
520
|
+
readonly documentId: string;
|
|
521
|
+
}[];
|
|
522
|
+
};
|
|
306
523
|
type GraphQLReactorClientOptions = {
|
|
307
|
-
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
524
|
+
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
525
|
+
url: string;
|
|
308
526
|
/**
|
|
309
527
|
* A pre-built SDK to use instead of the transport derived from `url`.
|
|
310
528
|
* Mainly a test seam.
|
|
311
529
|
*
|
|
312
|
-
* A client built this way carries no auth middleware
|
|
313
|
-
* its own transport, and therefore its own headers
|
|
530
|
+
* A client built this way carries no auth middleware and no 421 mapping:
|
|
531
|
+
* the injected SDK owns its own transport, and therefore its own headers
|
|
532
|
+
* and transport errors.
|
|
314
533
|
*/
|
|
315
534
|
graphqlClient?: ReactorGraphQLClient;
|
|
316
535
|
/**
|
|
@@ -348,10 +567,12 @@ type GraphQLReactorClientOptions = {
|
|
|
348
567
|
* `state.document.version` is here. One action needs no prediction and is
|
|
349
568
|
* signed without any of this.
|
|
350
569
|
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
570
|
+
* An array is read once, when the client is built; a function is called at
|
|
571
|
+
* every batch, for a registry that gains models later. Below
|
|
572
|
+
* `GraphQLReactorProvider` this is its `documentModels` prop; a client
|
|
573
|
+
* constructed directly passes its own.
|
|
353
574
|
*/
|
|
354
|
-
documentModels?: readonly DocumentModelModule<any>[];
|
|
575
|
+
documentModels?: readonly DocumentModelModule<any>[] | (() => readonly DocumentModelModule<any>[]);
|
|
355
576
|
/**
|
|
356
577
|
* Signs the actions this client pushes, instead of the logged-in Renown user.
|
|
357
578
|
*
|
|
@@ -361,6 +582,13 @@ type GraphQLReactorClientOptions = {
|
|
|
361
582
|
* scripts, and integration suites that must sign deterministically.
|
|
362
583
|
*/
|
|
363
584
|
signer?: ISigner;
|
|
585
|
+
/**
|
|
586
|
+
* Names the drive a call belongs to when the client cannot prove it itself,
|
|
587
|
+
* for its `Drive-Id` header; `undefined` sends none. Return only a drive id
|
|
588
|
+
* the caller knows: a Switchboard that does not own it answers 421. Where
|
|
589
|
+
* the client has proof of its own and the two disagree, the proof is sent.
|
|
590
|
+
*/
|
|
591
|
+
driveIdFor?: (call: DriveIdCall) => string | undefined;
|
|
364
592
|
};
|
|
365
593
|
/**
|
|
366
594
|
* The marker {@link isGraphQLReactorClient} looks for.
|
|
@@ -371,6 +599,11 @@ type GraphQLReactorClientOptions = {
|
|
|
371
599
|
* and answers `false`. A branded property survives both.
|
|
372
600
|
*/
|
|
373
601
|
declare const graphQLReactorClientBrand: "__powerhouseGraphQLReactorClient";
|
|
602
|
+
/** The read half of {@link GraphQLReactorClient}: the hooks' reads plus `drives`. */
|
|
603
|
+
interface GraphQLReactorReadClient extends IReactorBrowserReadClient {
|
|
604
|
+
/** A drive's nodes from the node queries, for every drive type. */
|
|
605
|
+
readonly drives: IDriveReadClient;
|
|
606
|
+
}
|
|
374
607
|
/**
|
|
375
608
|
* A light implementation of {@link IReactorBrowserClient} that talks plain
|
|
376
609
|
* GraphQL to a Switchboard, with no reactor in the bundle.
|
|
@@ -388,15 +621,83 @@ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
|
|
|
388
621
|
private readonly subscriptionsUrl;
|
|
389
622
|
private readonly documentModels;
|
|
390
623
|
private readonly signer;
|
|
624
|
+
private readonly driveIdFor;
|
|
391
625
|
private stopRealtime;
|
|
392
626
|
private realtimeStarted;
|
|
393
627
|
private realtimeGeneration;
|
|
394
628
|
private realtimeErrorLogged;
|
|
395
629
|
/** Whether the last socket died because the Switchboard refused its credentials. */
|
|
396
630
|
private realtimeRefusedCredentials;
|
|
631
|
+
/** The socket write handles wait on; opened by the first stage wait. */
|
|
632
|
+
private jobSocket;
|
|
633
|
+
/** Set once the `jobChanges` subscription failed; stage waits then only poll. */
|
|
634
|
+
private jobRealtimeBroken;
|
|
635
|
+
/** Set once the Switchboard refused the `document` query's `consistency` argument. */
|
|
636
|
+
private consistencyUnsupported;
|
|
637
|
+
private readonly driveNodes;
|
|
638
|
+
/**
|
|
639
|
+
* The read half: the reads the hooks make. Every method is this client's
|
|
640
|
+
* own; nothing that writes is reachable from it.
|
|
641
|
+
*/
|
|
642
|
+
readonly read: GraphQLReactorReadClient;
|
|
643
|
+
/**
|
|
644
|
+
* The write half. `execute` submits through `executeAsync` and hands back a
|
|
645
|
+
* handle whose `written` and `readable` resolve from `jobStatus`, woken by
|
|
646
|
+
* the `jobChanges` subscription when realtime is on, and whose `document()`
|
|
647
|
+
* runs the `document` query bounded by the receipt's token. `create` and
|
|
648
|
+
* `deleteDocument` have no asynchronous mutation: they run the synchronous
|
|
649
|
+
* ones and hand back a settled handle.
|
|
650
|
+
*/
|
|
651
|
+
readonly write: IReactorBrowserWriteClient;
|
|
397
652
|
constructor(options: GraphQLReactorClientOptions);
|
|
398
|
-
|
|
653
|
+
/**
|
|
654
|
+
* The Switchboard's drive node queries as a node source, for every drive
|
|
655
|
+
* type. `read.drives` answers from it.
|
|
656
|
+
*/
|
|
657
|
+
nodeSource(): IDriveNodeSource;
|
|
658
|
+
/**
|
|
659
|
+
* Reads a document. With a consistency token that names any coordinate, the
|
|
660
|
+
* Switchboard waits until its read models hold them; one without the
|
|
661
|
+
* `document` query's `consistency` argument is read without it, which after
|
|
662
|
+
* a write's `readable` stage still sees the write on a single node.
|
|
663
|
+
*/
|
|
664
|
+
get<TDocument extends PHDocument>(identifier: string, view?: ViewFilter, signal?: AbortSignal, consistencyToken?: ConsistencyToken): Promise<TDocument>;
|
|
665
|
+
/**
|
|
666
|
+
* Reads documents by id, in the order given; throws if any is missing. Each
|
|
667
|
+
* chunk of {@link GET_MANY_CHUNK_SIZE} ids is one request holding an aliased
|
|
668
|
+
* `document` field per id, with the selection and arguments `get` sends.
|
|
669
|
+
*/
|
|
670
|
+
getMany<TDocument extends PHDocument>(documentIds: string[], view?: ViewFilter, signal?: AbortSignal, consistencyToken?: ConsistencyToken): Promise<TDocument[]>;
|
|
671
|
+
/** One chunk of `getMany`, with the `consistency` argument while the Switchboard accepts it. */
|
|
672
|
+
private getDocumentChunk;
|
|
673
|
+
private runGetDocuments;
|
|
674
|
+
/**
|
|
675
|
+
* Whether the Switchboard would serve the document to this client's caller,
|
|
676
|
+
* from its `documentServed` query: the same read gate `find` passes. Absent
|
|
677
|
+
* or withheld is `false`; a failure to decide throws.
|
|
678
|
+
*
|
|
679
|
+
* A point-in-time view throws {@link GraphQLOperationNotSupportedError}, as
|
|
680
|
+
* does a Switchboard without the query.
|
|
681
|
+
*/
|
|
682
|
+
isServed(identifier: string, view?: ViewFilter, signal?: AbortSignal): Promise<boolean>;
|
|
399
683
|
getOperations(documentIdentifier: string, view?: ViewFilter, filter?: OperationFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
|
|
684
|
+
/**
|
|
685
|
+
* Filters documents by criteria over the Switchboard's `findDocuments` query.
|
|
686
|
+
*
|
|
687
|
+
* The query filters by `type` and `parentId` only, at head. A search naming
|
|
688
|
+
* `ids` or `slugs` (present, whatever its length) and a point-in-time view are
|
|
689
|
+
* each by-contract limitations the query cannot express -- running it anyway
|
|
690
|
+
* would return every document instead of the named ones, or head instead of
|
|
691
|
+
* the asked-for revision, a silently wrong answer. {@link findIsServableOverGraphQL}
|
|
692
|
+
* is the single predicate that decides this, and an unservable `find` throws
|
|
693
|
+
* {@link GraphQLOperationNotSupportedError}. Drive enumeration itself filters
|
|
694
|
+
* by `type` at head, which is served.
|
|
695
|
+
*/
|
|
696
|
+
find<TDocument extends PHDocument = PHDocument>(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<TDocument>>;
|
|
697
|
+
getOutgoingRelationships(sourceIdentifier: string, relationshipType: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
698
|
+
getIncomingRelationships(targetIdentifier: string, relationshipType: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
699
|
+
getOutgoingRelationshipEdges(sourceIdentifier: string, relationshipType?: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<DocumentRelationship>>;
|
|
700
|
+
getIncomingRelationshipEdges(targetIdentifier: string, relationshipType?: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<DocumentRelationship>>;
|
|
400
701
|
create<TDocument extends PHDocument = PHDocument>(document: PHDocument, parentIdentifier?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
401
702
|
/**
|
|
402
703
|
* Pushes actions to the Switchboard and returns the updated document.
|
|
@@ -416,6 +717,74 @@ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
|
|
|
416
717
|
* request. Declaring it would suggest a per-call choice that does not exist.
|
|
417
718
|
*/
|
|
418
719
|
execute<TDocument extends PHDocument>(documentIdentifier: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<TDocument>;
|
|
720
|
+
/**
|
|
721
|
+
* Runs multiple mutation jobs in dependency order over the Switchboard's
|
|
722
|
+
* `executeBatch` mutation and waits for all to settle, returning the result
|
|
723
|
+
* shaped like `IReactor.executeBatch`'s so the reference `DriveClient`
|
|
724
|
+
* consumes it unchanged.
|
|
725
|
+
*
|
|
726
|
+
* Not atomic: each job commits on its own and a failed job still releases
|
|
727
|
+
* its dependents. A FAILED job throws {@link BatchJobFailedError}, naming the
|
|
728
|
+
* first failed plan key and carrying every job's final state.
|
|
729
|
+
*
|
|
730
|
+
* Each job's actions are signed independently for the job's own
|
|
731
|
+
* `(documentId, branch)` target -- the per-action signing the reactor's own
|
|
732
|
+
* `signActions` does, not the batch state-prediction `execute` uses for a
|
|
733
|
+
* multi-action push. A drive job such as `addFile`'s is `CREATE_DOCUMENT` +
|
|
734
|
+
* `UPGRADE_DOCUMENT` + `ADD_RELATIONSHIP`, which the prediction path rejects
|
|
735
|
+
* outright and which has no fetchable baseline to stamp against. The reactor
|
|
736
|
+
* records but does not verify the stamped previous-state head, so signing
|
|
737
|
+
* each action bare is exactly what the in-process `DriveClient` relies on.
|
|
738
|
+
*
|
|
739
|
+
* The mutation is synchronous server-side: a job it returns is already
|
|
740
|
+
* settled, so {@link waitForJob} resolves from it without polling.
|
|
741
|
+
*/
|
|
742
|
+
executeBatch(request: BatchExecutionRequest, signal?: AbortSignal): Promise<BatchExecutionResult>;
|
|
743
|
+
/** The job as `jobStatus` reports it now; `undefined` when it reports none. */
|
|
744
|
+
getJob(jobId: string, signal?: AbortSignal): Promise<JobInfo | undefined>;
|
|
745
|
+
/** The job as `jobStatus` reports it now; throws when it reports none. */
|
|
746
|
+
getJobStatus(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
747
|
+
/** Polls `jobStatus` until the job is READ_READY or FAILED. */
|
|
748
|
+
waitForJob(jobOrId: string | JobInfo, signal?: AbortSignal): Promise<JobInfo>;
|
|
749
|
+
/** See {@link readCreateSignaturePolicy}. */
|
|
750
|
+
getCreateSignaturePolicy(): Promise<SignaturePolicy>;
|
|
751
|
+
/** See {@link readCreateProtocolVersions}; fitted to `documentModels`. */
|
|
752
|
+
getCreateProtocolVersions(options: CreateProtocolVersionsOptions, signal?: AbortSignal): Promise<ProtocolVersions>;
|
|
753
|
+
/** See {@link IReactorClient.newDocument}; the module comes from `documentModels`. */
|
|
754
|
+
newDocument<TDocument extends PHDocument = PHDocument>(documentType: string, options?: NewDocumentOptions, signal?: AbortSignal): Promise<TDocument>;
|
|
755
|
+
/**
|
|
756
|
+
* Sets or, with `null`, clears the preferred editor as a client-signed
|
|
757
|
+
* action, as the in-process client does.
|
|
758
|
+
*/
|
|
759
|
+
setPreferredEditor(documentIdentifier: string, preferredEditor: string | null, branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
760
|
+
/** The `Drive-Id` header for a call: the client's own proof, else the hook's. */
|
|
761
|
+
private driveIdHeaders;
|
|
762
|
+
/**
|
|
763
|
+
* Emits the changes the batch's settled jobs made, as `create` and `execute`
|
|
764
|
+
* do, so a cache is invalidated without a realtime socket. The documents a
|
|
765
|
+
* job wrote to are its own and those its consistency token names.
|
|
766
|
+
*/
|
|
767
|
+
private announceBatch;
|
|
768
|
+
/**
|
|
769
|
+
* The id a job's actions are signed for: a signature covers the document id,
|
|
770
|
+
* and the server resolves a slug before verifying. A document created by this
|
|
771
|
+
* job or an earlier one is named by its id. When the server has no such
|
|
772
|
+
* document the identifier is used as given, and the server decides; any
|
|
773
|
+
* other failure to read it throws, so nothing is signed for a slug.
|
|
774
|
+
*/
|
|
775
|
+
private batchWriteTarget;
|
|
776
|
+
/**
|
|
777
|
+
* Signs one batch job's actions for the job's own log.
|
|
778
|
+
*
|
|
779
|
+
* Each action is signed on its own for `(documentId, branch)`, the same
|
|
780
|
+
* per-action signing the reactor's `signActions` does: no state prediction
|
|
781
|
+
* across the job, so a job carrying a `CREATE_DOCUMENT` the push-prediction
|
|
782
|
+
* path rejects still signs. An action already signed under a key is left
|
|
783
|
+
* as it is: the reference `DriveClient` signs its jobs before handing them
|
|
784
|
+
* here. With no signer the actions pass through unsigned, matching
|
|
785
|
+
* {@link execute}.
|
|
786
|
+
*/
|
|
787
|
+
private signBatchJobActions;
|
|
419
788
|
/**
|
|
420
789
|
* Deletes a document and announces it as a `Deleted` event.
|
|
421
790
|
*
|
|
@@ -490,6 +859,53 @@ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
|
|
|
490
859
|
* `gql` document or a string and name the result type at the call site.
|
|
491
860
|
*/
|
|
492
861
|
request<TResult = unknown, TVariables extends Variables = Variables>(document: TypedGraphQLDocument<TResult, TVariables> | string, variables?: TVariables, options?: GraphQLRequestOptions): Promise<TResult>;
|
|
862
|
+
/**
|
|
863
|
+
* Shapes a document result page into the reactor's {@link PagedResults}.
|
|
864
|
+
*
|
|
865
|
+
* The items carry the same `PHDocumentFields` fragment as `get`, so the same
|
|
866
|
+
* adapter rebuilds each one. `hasNextPage` gates the cursor exactly as
|
|
867
|
+
* `getOperations` does: no cursor means no `next`.
|
|
868
|
+
*/
|
|
869
|
+
private toDocumentResults;
|
|
870
|
+
/**
|
|
871
|
+
* Shapes a relationship-edge result page into the reactor's
|
|
872
|
+
* {@link PagedResults}, restoring each edge's `Date` fields.
|
|
873
|
+
*/
|
|
874
|
+
private toRelationshipResults;
|
|
875
|
+
/**
|
|
876
|
+
* The write half's `execute`: signs as the facade's `execute` does, submits
|
|
877
|
+
* through `executeAsync` and returns once the job is accepted. When anyone
|
|
878
|
+
* subscribes, the document is read back once the job is readable and
|
|
879
|
+
* announced as `Updated`, as the facade's `execute` announces it; the handle
|
|
880
|
+
* shares that read with its own `document()`.
|
|
881
|
+
*/
|
|
882
|
+
private submitExecute;
|
|
883
|
+
/** The write half's `create`: the synchronous mutation, a settled handle. */
|
|
884
|
+
private submitCreate;
|
|
885
|
+
/** The write half's `deleteDocument`: the synchronous mutation, a settled handle. */
|
|
886
|
+
private submitDeleteDocument;
|
|
887
|
+
/** Reads a write's document back, bounded by its receipt's token. */
|
|
888
|
+
private handleReader;
|
|
889
|
+
/** Announces a write's document as `Updated` once it is readable. */
|
|
890
|
+
private announceWrite;
|
|
891
|
+
/**
|
|
892
|
+
* Waits for a job to settle a stage, resolving with a FAILED job too. Polls
|
|
893
|
+
* `jobStatus` with a doubling interval; with realtime on, a `jobChanges`
|
|
894
|
+
* event for the job wakes the wait early and the interval is only a safety
|
|
895
|
+
* net. A failed subscription is logged once and the wait keeps polling.
|
|
896
|
+
*/
|
|
897
|
+
private waitForStage;
|
|
898
|
+
/**
|
|
899
|
+
* Subscribes to one job's `jobChanges` when realtime is on and the
|
|
900
|
+
* subscription has not failed before. Returns the stop function, or
|
|
901
|
+
* undefined when nothing was subscribed.
|
|
902
|
+
*/
|
|
903
|
+
private watchJob;
|
|
904
|
+
/**
|
|
905
|
+
* The `document` query with the `consistency` argument, or without it once
|
|
906
|
+
* the Switchboard has refused the argument.
|
|
907
|
+
*/
|
|
908
|
+
private getDocumentAtConsistency;
|
|
493
909
|
/**
|
|
494
910
|
* Opens the realtime socket on the first subscriber.
|
|
495
911
|
*
|
|
@@ -555,6 +971,8 @@ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
|
|
|
555
971
|
*/
|
|
556
972
|
private emitChange;
|
|
557
973
|
}
|
|
974
|
+
/** {@link GraphQLReactorClient.nodeSource}, as a function. */
|
|
975
|
+
declare function createGraphQLDriveNodeSource(client: GraphQLReactorClient): IDriveNodeSource;
|
|
558
976
|
/**
|
|
559
977
|
* Whether a value is a {@link GraphQLReactorClient}, including one built by
|
|
560
978
|
* another copy of this module.
|
|
@@ -571,6 +989,15 @@ declare function isGraphQLReactorClient(client: unknown): client is GraphQLReact
|
|
|
571
989
|
* argument, so silently returning the head state would be wrong.
|
|
572
990
|
*/
|
|
573
991
|
declare function viewFilterInputFromViewFilter(view?: ViewFilter): ViewFilterInput | undefined;
|
|
992
|
+
/**
|
|
993
|
+
* The single source of truth for whether the Switchboard `findDocuments` query
|
|
994
|
+
* can serve a `find`. It is servable iff the search names neither `ids` nor
|
|
995
|
+
* `slugs` (present, regardless of length) AND the view is not point-in-time:
|
|
996
|
+
* each is a by-contract limitation of a surface that filters only by
|
|
997
|
+
* `type`/`parentId` at head. Exported so a caller can route around an
|
|
998
|
+
* unservable search instead of catching the error `find` throws for it.
|
|
999
|
+
*/
|
|
1000
|
+
declare function findIsServableOverGraphQL(search: SearchFilter, view?: ViewFilter): boolean;
|
|
574
1001
|
//#endregion
|
|
575
1002
|
//#region src/graphql-client/graphql-reactor-provider.d.ts
|
|
576
1003
|
declare global {
|
|
@@ -589,7 +1016,8 @@ declare global {
|
|
|
589
1016
|
*/
|
|
590
1017
|
declare function ensurePHEventHandlers(): void;
|
|
591
1018
|
type GraphQLReactorProviderProps = {
|
|
592
|
-
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
1019
|
+
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
1020
|
+
url: string;
|
|
593
1021
|
/**
|
|
594
1022
|
* Resolves the bearer token sent with every request, per request. Defaults to
|
|
595
1023
|
* the token of the logged-in Renown user, or none when nobody is logged in.
|
|
@@ -675,15 +1103,7 @@ type GraphQLReactorProviderProps = {
|
|
|
675
1103
|
* effect rebuilds both if it runs again on the same client - which is what a
|
|
676
1104
|
* `StrictMode` mount does.
|
|
677
1105
|
*/
|
|
678
|
-
declare function GraphQLReactorProvider({
|
|
679
|
-
url,
|
|
680
|
-
tokenProvider,
|
|
681
|
-
subscriptionsUrl,
|
|
682
|
-
realtime,
|
|
683
|
-
attachmentService,
|
|
684
|
-
documentModels,
|
|
685
|
-
children
|
|
686
|
-
}: GraphQLReactorProviderProps): react_jsx_runtime0.JSX.Element;
|
|
1106
|
+
declare function GraphQLReactorProvider({ url, tokenProvider, subscriptionsUrl, realtime, attachmentService, documentModels, children }: GraphQLReactorProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
687
1107
|
/**
|
|
688
1108
|
* Returns the {@link GraphQLReactorClient} mounted by
|
|
689
1109
|
* {@link GraphQLReactorProvider}, or `undefined` when the slot holds something
|
|
@@ -705,7 +1125,7 @@ declare function useSwitchboardClient(): GraphQLReactorClient | undefined;
|
|
|
705
1125
|
* The operation selection of `GetDocumentOperations`, lifted into a fragment so
|
|
706
1126
|
* the write path can reuse `remoteOperationToLocal` on the items it selects.
|
|
707
1127
|
*/
|
|
708
|
-
declare const ReactorOperationFieldsFragmentDoc: graphql.DocumentNode;
|
|
1128
|
+
declare const ReactorOperationFieldsFragmentDoc: import("graphql").DocumentNode;
|
|
709
1129
|
/**
|
|
710
1130
|
* `mutateDocument` plus the operations the mutation produced.
|
|
711
1131
|
*
|
|
@@ -727,7 +1147,7 @@ declare const ReactorOperationFieldsFragmentDoc: graphql.DocumentNode;
|
|
|
727
1147
|
* by hand or the operations came from `main` while the actions were applied
|
|
728
1148
|
* elsewhere. One variable cannot disagree with itself.
|
|
729
1149
|
*/
|
|
730
|
-
declare const MutateDocumentWithOperationsDocument: graphql.DocumentNode;
|
|
1150
|
+
declare const MutateDocumentWithOperationsDocument: import("graphql").DocumentNode;
|
|
731
1151
|
type MutateDocumentWithOperationsVariables = {
|
|
732
1152
|
documentIdentifier: Scalars["String"]["input"];
|
|
733
1153
|
actions: ReadonlyArray<ActionInput>;
|
|
@@ -742,6 +1162,33 @@ type MutateDocumentWithOperationsResult = {
|
|
|
742
1162
|
} | null;
|
|
743
1163
|
};
|
|
744
1164
|
};
|
|
1165
|
+
/**
|
|
1166
|
+
* `document`, bounded by a consistency token: the read waits until the
|
|
1167
|
+
* Switchboard's read models hold every operation the token names. The
|
|
1168
|
+
* `consistency` argument is additive on the Switchboard; one without it refuses
|
|
1169
|
+
* this document, and the client falls back to the plain `GetDocument`.
|
|
1170
|
+
*/
|
|
1171
|
+
declare const GetDocumentAtConsistencyDocument: import("graphql").DocumentNode;
|
|
1172
|
+
type GetDocumentAtConsistencyVariables = {
|
|
1173
|
+
identifier: Scalars["String"]["input"];
|
|
1174
|
+
view?: ViewFilterInput;
|
|
1175
|
+
consistency: {
|
|
1176
|
+
version: number;
|
|
1177
|
+
createdAtUtcIso: string;
|
|
1178
|
+
coordinates: ReadonlyArray<{
|
|
1179
|
+
documentId: string;
|
|
1180
|
+
scope: string;
|
|
1181
|
+
branch: string;
|
|
1182
|
+
operationIndex: number;
|
|
1183
|
+
}>;
|
|
1184
|
+
};
|
|
1185
|
+
};
|
|
1186
|
+
type GetDocumentAtConsistencyResult = {
|
|
1187
|
+
readonly document?: {
|
|
1188
|
+
readonly document: PhDocumentFieldsFragment;
|
|
1189
|
+
readonly childIds: ReadonlyArray<string>;
|
|
1190
|
+
} | null;
|
|
1191
|
+
};
|
|
745
1192
|
//#endregion
|
|
746
1193
|
//#region src/graphql-client/signing.d.ts
|
|
747
1194
|
/**
|
|
@@ -761,12 +1208,12 @@ type MutateDocumentWithOperationsResult = {
|
|
|
761
1208
|
*/
|
|
762
1209
|
declare function stampAction(action: Action$1, document: PHDocument$1, revision?: number): Action$1;
|
|
763
1210
|
/**
|
|
764
|
-
* Signs a stamped action
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
1211
|
+
* Signs a stamped action for `target`, keeping any signatures it already
|
|
1212
|
+
* carries. The signer reads `context.prevOpHash`, so this runs after
|
|
1213
|
+
* {@link stampAction}. A v2 tuple covers the signer's identity, so the context
|
|
1214
|
+
* takes the signer's user and app even when the action named others.
|
|
768
1215
|
*/
|
|
769
|
-
declare function signStampedAction(action: Action$1, signer: ISigner, signal?: AbortSignal): Promise<Action$1>;
|
|
1216
|
+
declare function signStampedAction(action: Action$1, signer: ISigner, target: ActionSigningTarget, signal?: AbortSignal): Promise<Action$1>;
|
|
770
1217
|
/**
|
|
771
1218
|
* Stamps and signs a batch of actions against one document snapshot, so every
|
|
772
1219
|
* action carries the head its predecessor will leave behind.
|
|
@@ -856,13 +1303,15 @@ type DocumentChangesEventPayload = DocumentChangesSubscription["documentChanges"
|
|
|
856
1303
|
/** The connection payload sent with the `ConnectionInit` message. */
|
|
857
1304
|
type ConnectionParams = Record<string, string>;
|
|
858
1305
|
type DocumentChangesSubscriptionOptions = {
|
|
859
|
-
/** The websocket endpoint, e.g. `ws://localhost:4001/graphql/subscriptions`. */
|
|
1306
|
+
/** The websocket endpoint, e.g. `ws://localhost:4001/graphql/subscriptions`. */
|
|
1307
|
+
wsUrl: string;
|
|
860
1308
|
/**
|
|
861
1309
|
* Resolves the `ConnectionInit` payload. Called again on every reconnect, so
|
|
862
1310
|
* a token that expired while the socket was down is refreshed on the way back
|
|
863
1311
|
* up.
|
|
864
1312
|
*/
|
|
865
|
-
connectionParams?: () => Promise<ConnectionParams>;
|
|
1313
|
+
connectionParams?: () => Promise<ConnectionParams>;
|
|
1314
|
+
/** Called once per server event. */
|
|
866
1315
|
onEvent: (event: DocumentChangesEventPayload) => void;
|
|
867
1316
|
/**
|
|
868
1317
|
* Called when the socket gives up: the retries built into `graphql-ws` are
|
|
@@ -891,6 +1340,33 @@ declare function isAuthRefusalClose(error: unknown): boolean;
|
|
|
891
1340
|
* socket. It is safe to call more than once.
|
|
892
1341
|
*/
|
|
893
1342
|
declare function startDocumentChangesSubscription(options: DocumentChangesSubscriptionOptions): () => void;
|
|
1343
|
+
/** The `jobChanges` payload, exactly as the Switchboard sends it. */
|
|
1344
|
+
type JobChangesEventPayload = JobChangesSubscription["jobChanges"];
|
|
1345
|
+
/**
|
|
1346
|
+
* One socket carrying `jobChanges` subscriptions, one per watched job. The
|
|
1347
|
+
* socket opens on the first watch and closes when nothing is watched.
|
|
1348
|
+
*/
|
|
1349
|
+
interface IJobChangesSocket {
|
|
1350
|
+
/**
|
|
1351
|
+
* Watches one job. `onEvent` is called per status change the Switchboard
|
|
1352
|
+
* reports; `onError` once if the subscription fails. Returns the stop
|
|
1353
|
+
* function, safe to call more than once.
|
|
1354
|
+
*/
|
|
1355
|
+
watch(jobId: string, onEvent: (event: JobChangesEventPayload) => void, onError: (error: unknown) => void): () => void;
|
|
1356
|
+
/** Closes the socket; a later watch opens a new one. */
|
|
1357
|
+
dispose(): void;
|
|
1358
|
+
}
|
|
1359
|
+
type JobChangesSocketOptions = {
|
|
1360
|
+
/** The websocket endpoint, e.g. `ws://localhost:4001/graphql/subscriptions`. */
|
|
1361
|
+
wsUrl: string;
|
|
1362
|
+
/** Resolves the `ConnectionInit` payload, per connect. */
|
|
1363
|
+
connectionParams?: () => Promise<ConnectionParams>;
|
|
1364
|
+
};
|
|
1365
|
+
/**
|
|
1366
|
+
* Opens the socket write handles wait on. `graphql-ws` multiplexes every
|
|
1367
|
+
* watched job over it and closes it once the last watch stops.
|
|
1368
|
+
*/
|
|
1369
|
+
declare function createJobChangesSocket(options: JobChangesSocketOptions): IJobChangesSocket;
|
|
894
1370
|
/**
|
|
895
1371
|
* Derives the websocket endpoint from the GraphQL http endpoint.
|
|
896
1372
|
*
|
|
@@ -938,6 +1414,8 @@ declare function useDocument(id: string | null | undefined): PHDocument$1 | unde
|
|
|
938
1414
|
* - isPending: Whether the document is currently loading
|
|
939
1415
|
* - error: Any error that occurred during loading (e.g., document not found)
|
|
940
1416
|
* - reload: Function to force a refetch, or undefined when no id is supplied
|
|
1417
|
+
* - isRefetching: A loaded document is being refetched; `data` is the loaded one
|
|
1418
|
+
* - refetchError: The last refetch failure that kept the loaded document
|
|
941
1419
|
*/
|
|
942
1420
|
declare function useDocumentSafe(id: string | null | undefined): {
|
|
943
1421
|
readonly status: "initial";
|
|
@@ -945,24 +1423,32 @@ declare function useDocumentSafe(id: string | null | undefined): {
|
|
|
945
1423
|
readonly error: undefined;
|
|
946
1424
|
readonly data: undefined;
|
|
947
1425
|
readonly reload: undefined;
|
|
1426
|
+
readonly isRefetching: false;
|
|
1427
|
+
readonly refetchError: undefined;
|
|
948
1428
|
} | {
|
|
949
|
-
readonly reload: () => Promise<PHDocument$1>;
|
|
950
1429
|
readonly status: "pending";
|
|
951
1430
|
readonly isPending: true;
|
|
952
1431
|
readonly error: undefined;
|
|
953
1432
|
readonly data: undefined;
|
|
954
|
-
} | {
|
|
955
1433
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1434
|
+
readonly isRefetching: boolean;
|
|
1435
|
+
readonly refetchError: unknown;
|
|
1436
|
+
} | {
|
|
956
1437
|
readonly status: "success";
|
|
957
1438
|
readonly isPending: false;
|
|
958
1439
|
readonly error: undefined;
|
|
959
1440
|
readonly data: PHDocument$1;
|
|
960
|
-
} | {
|
|
961
1441
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1442
|
+
readonly isRefetching: boolean;
|
|
1443
|
+
readonly refetchError: unknown;
|
|
1444
|
+
} | {
|
|
962
1445
|
readonly status: "error";
|
|
963
1446
|
readonly isPending: false;
|
|
964
1447
|
readonly error: unknown;
|
|
965
1448
|
readonly data: undefined;
|
|
1449
|
+
readonly reload: () => Promise<PHDocument$1>;
|
|
1450
|
+
readonly isRefetching: boolean;
|
|
1451
|
+
readonly refetchError: unknown;
|
|
966
1452
|
};
|
|
967
1453
|
/**
|
|
968
1454
|
* Retrieves multiple documents from the reactor using React Suspense.
|
|
@@ -997,6 +1483,8 @@ declare function useGetDocuments(): (ids: string[]) => Promise<PHDocument$1[]>;
|
|
|
997
1483
|
* - isPending: Boolean indicating if the document is currently loading
|
|
998
1484
|
* - error: Any error that occurred during loading
|
|
999
1485
|
* - reload: Function to force reload the document from cache
|
|
1486
|
+
* - isRefetching: A loaded document is being refetched; `data` is the loaded one
|
|
1487
|
+
* - refetchError: The last refetch failure that kept the loaded document
|
|
1000
1488
|
*/
|
|
1001
1489
|
declare function useGetDocumentAsync(id: string | null | undefined): {
|
|
1002
1490
|
readonly status: "initial";
|
|
@@ -1004,24 +1492,32 @@ declare function useGetDocumentAsync(id: string | null | undefined): {
|
|
|
1004
1492
|
readonly isPending: false;
|
|
1005
1493
|
readonly error: undefined;
|
|
1006
1494
|
readonly reload: undefined;
|
|
1495
|
+
readonly isRefetching: false;
|
|
1496
|
+
readonly refetchError: undefined;
|
|
1007
1497
|
} | {
|
|
1008
|
-
readonly reload: () => Promise<PHDocument$1>;
|
|
1009
1498
|
readonly status: "pending";
|
|
1010
1499
|
readonly isPending: true;
|
|
1011
1500
|
readonly error: undefined;
|
|
1012
1501
|
readonly data: undefined;
|
|
1013
|
-
} | {
|
|
1014
1502
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1503
|
+
readonly isRefetching: boolean;
|
|
1504
|
+
readonly refetchError: unknown;
|
|
1505
|
+
} | {
|
|
1015
1506
|
readonly status: "success";
|
|
1016
1507
|
readonly isPending: false;
|
|
1017
1508
|
readonly error: undefined;
|
|
1018
1509
|
readonly data: PHDocument$1;
|
|
1019
|
-
} | {
|
|
1020
1510
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1511
|
+
readonly isRefetching: boolean;
|
|
1512
|
+
readonly refetchError: unknown;
|
|
1513
|
+
} | {
|
|
1021
1514
|
readonly status: "error";
|
|
1022
1515
|
readonly isPending: false;
|
|
1023
1516
|
readonly error: unknown;
|
|
1024
1517
|
readonly data: undefined;
|
|
1518
|
+
readonly reload: () => Promise<PHDocument$1>;
|
|
1519
|
+
readonly isRefetching: boolean;
|
|
1520
|
+
readonly refetchError: unknown;
|
|
1025
1521
|
};
|
|
1026
1522
|
//#endregion
|
|
1027
1523
|
//#region src/hooks/reactor.d.ts
|
|
@@ -1033,25 +1529,44 @@ declare const setReactorClientModule: SetPHGlobalValue<BrowserReactorClientModul
|
|
|
1033
1529
|
declare const addReactorClientModuleEventHandler: AddPHGlobalEventHandler;
|
|
1034
1530
|
/** Returns the reactor client */
|
|
1035
1531
|
declare const useReactorClient: UsePHGlobalValue<IReactorBrowserClient>;
|
|
1036
|
-
/**
|
|
1532
|
+
/**
|
|
1533
|
+
* Sets the reactor client, and `window.ph.reactor` to its read and write
|
|
1534
|
+
* halves. A client without halves leaves `reactor` unset.
|
|
1535
|
+
*/
|
|
1037
1536
|
declare const setReactorClient: SetPHGlobalValue<IReactorBrowserClient>;
|
|
1537
|
+
/** Returns the reactor client's read and write halves */
|
|
1538
|
+
declare const useReactorHalves: UsePHGlobalValue<ReactorBrowserHalves>;
|
|
1539
|
+
/** Adds an event handler for the reactor client's halves */
|
|
1540
|
+
declare const addReactorHalvesEventHandler: AddPHGlobalEventHandler;
|
|
1038
1541
|
/** Adds an event handler for the reactor client */
|
|
1039
1542
|
declare const addReactorClientEventHandler: AddPHGlobalEventHandler;
|
|
1543
|
+
/** Sets the client full-client actions use instead of the module's */
|
|
1544
|
+
declare const setFullReactorClient: SetPHGlobalValue<IReactorClient>;
|
|
1545
|
+
/** Adds an event handler for the full reactor client */
|
|
1546
|
+
declare const addFullReactorClientEventHandler: AddPHGlobalEventHandler;
|
|
1547
|
+
/** The client full-client actions use: the one set, else the module's. */
|
|
1548
|
+
declare function getFullReactorClient(): IReactorClient | undefined;
|
|
1040
1549
|
declare const useSync: () => ISyncManager | undefined;
|
|
1041
|
-
declare const useSyncList: () =>
|
|
1550
|
+
declare const useSyncList: () => import("@powerhousedao/reactor").Remote[];
|
|
1042
1551
|
declare const useModelRegistry: () => IDocumentModelRegistry | undefined;
|
|
1043
1552
|
declare const useDatabase: () => Kysely<Database> | undefined;
|
|
1044
1553
|
declare const usePGlite: () => PGlite | undefined;
|
|
1045
1554
|
//#endregion
|
|
1046
1555
|
//#region src/hooks/dispatch.d.ts
|
|
1047
|
-
/**
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1051
|
-
*
|
|
1052
|
-
|
|
1053
|
-
|
|
1556
|
+
/** Dispatches actions.
|
|
1557
|
+
*
|
|
1558
|
+
* Once the write lands, `onErrors` runs first, with an `OperationRejectedError` per action
|
|
1559
|
+
* the document did not apply; it is skipped when every action applied. Then `onSuccess`
|
|
1560
|
+
* runs with the document and an outcome, whether or not any action was rejected:
|
|
1561
|
+
* `outcome.rejected` holds the same errors, and is empty only when every action applied.
|
|
1562
|
+
* If `onErrors` throws, `onSuccess` does not run.
|
|
1563
|
+
*
|
|
1564
|
+
* When nothing lands (no document, no reactor, a failed write), only `onErrors` runs, with why. */
|
|
1565
|
+
type DispatchFn<TAction> = (actionOrActions: TAction[] | TAction | undefined, onErrors?: (errors: Error[]) => void, onSuccess?: DispatchSuccessCallback) => void;
|
|
1054
1566
|
type UseDispatchResult<TDocument, TAction> = readonly [TDocument | undefined, DispatchFn<TAction>];
|
|
1567
|
+
/** A dispatch to the document `getDocument` returns when it runs. */
|
|
1568
|
+
declare function createDispatch<TDocument = PHDocument$1, TAction = Action$1>(getDocument: () => TDocument | undefined): DispatchFn<TAction>;
|
|
1569
|
+
/** Returns the document and a dispatch to it; see `DispatchFn` for the callbacks' order. */
|
|
1055
1570
|
declare function useDispatch<TDocument = PHDocument$1, TAction = Action$1>(document: TDocument | undefined): UseDispatchResult<TDocument, TAction>;
|
|
1056
1571
|
//#endregion
|
|
1057
1572
|
//#region src/hooks/document-model-modules.d.ts
|
|
@@ -1067,24 +1582,61 @@ declare function useDocumentModelModules(): DocumentModelModule[] | undefined;
|
|
|
1067
1582
|
declare function useDocumentModelModuleById(id: string | null | undefined, version?: number): DocumentModelModule | undefined;
|
|
1068
1583
|
//#endregion
|
|
1069
1584
|
//#region src/hooks/document-operations.d.ts
|
|
1070
|
-
type
|
|
1585
|
+
type UseDocumentOperationsOptions = {
|
|
1586
|
+
/**
|
|
1587
|
+
* Operations per page. Default 100. Applies to the next first-page load;
|
|
1588
|
+
* changing it while pages are already loaded has no effect until the next
|
|
1589
|
+
* invalidation or `refetch`.
|
|
1590
|
+
*/
|
|
1591
|
+
limit?: number;
|
|
1592
|
+
/** Whether to fetch at all. Default true. Pass false until the operations are needed. */
|
|
1593
|
+
enabled?: boolean;
|
|
1594
|
+
};
|
|
1595
|
+
/** What `useDocumentOperations` returns; exported so consumers can name it. */
|
|
1596
|
+
type DocumentOperationsResult = {
|
|
1597
|
+
/** Every operation of the scope loaded so far, oldest first. */
|
|
1598
|
+
operations: readonly Operation$1[];
|
|
1599
|
+
/** A page is in flight. */
|
|
1600
|
+
isLoading: boolean;
|
|
1601
|
+
/** The last page failed. Operations loaded before it stay available. */
|
|
1602
|
+
error: Error | undefined;
|
|
1603
|
+
/** The last page reported a further page. */
|
|
1604
|
+
hasNextPage: boolean;
|
|
1605
|
+
/** Loads the next page and appends it. No-op while loading or when there is none. */
|
|
1606
|
+
fetchNextPage: () => void;
|
|
1607
|
+
/** Drops the document's cached operations and reloads from the first page. */
|
|
1608
|
+
refetch: () => void;
|
|
1609
|
+
};
|
|
1610
|
+
/**
|
|
1611
|
+
* Legacy result of `useDocumentOperations(documentId)`.
|
|
1612
|
+
* @deprecated Call `useDocumentOperations(documentId, scope, options)` and read `operations`. Removed in the next major.
|
|
1613
|
+
*/
|
|
1614
|
+
type DocumentOperationsState = {
|
|
1071
1615
|
globalOperations: Operation$1[];
|
|
1072
1616
|
localOperations: Operation$1[];
|
|
1073
1617
|
isLoading: boolean;
|
|
1074
1618
|
error: Error | undefined;
|
|
1075
|
-
};
|
|
1076
|
-
/** What `useDocumentOperations` returns; exported so consumers can name it. */
|
|
1077
|
-
type DocumentOperationsState = InternalState & {
|
|
1078
1619
|
refetch: () => void;
|
|
1079
1620
|
};
|
|
1621
|
+
/** @deprecated Pass a scope: `useDocumentOperations(documentId, "global")`. The legacy form fetches the whole global and local history eagerly. Removed in the next major. */
|
|
1622
|
+
declare function useDocumentOperations(documentId: string | null | undefined): DocumentOperationsState;
|
|
1080
1623
|
/**
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1624
|
+
* Operation history of a document, read from the document cache and kept in
|
|
1625
|
+
* step with it: a change event for the document drops the cached pages and
|
|
1626
|
+
* the hook loads the first page again.
|
|
1627
|
+
*
|
|
1628
|
+
* Pages arrive oldest first. A view that wants the whole history calls
|
|
1629
|
+
* `fetchNextPage` while `hasNextPage` is true.
|
|
1083
1630
|
*
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1631
|
+
* An empty first page is a final result; there is no retry. When the active
|
|
1632
|
+
* document cache does not serve operations, the result is empty and not
|
|
1633
|
+
* loading.
|
|
1634
|
+
*
|
|
1635
|
+
* @param documentId - The document id, or null/undefined to skip fetching
|
|
1636
|
+
* @param scope - The operation scope, for example "global" or "local"
|
|
1637
|
+
* @param options - Page size and whether fetching is enabled
|
|
1086
1638
|
*/
|
|
1087
|
-
declare function useDocumentOperations(documentId: string | null | undefined):
|
|
1639
|
+
declare function useDocumentOperations(documentId: string | null | undefined, scope: string, options?: UseDocumentOperationsOptions): DocumentOperationsResult;
|
|
1088
1640
|
//#endregion
|
|
1089
1641
|
//#region src/hooks/attachment-service.d.ts
|
|
1090
1642
|
/** Returns the attachment service from window.ph */
|
|
@@ -1094,5 +1646,6 @@ declare const setAttachmentService: SetPHGlobalValue<IAttachmentService>;
|
|
|
1094
1646
|
/** Registers the attachmentService window event handler */
|
|
1095
1647
|
declare const addAttachmentServiceEventHandler: AddPHGlobalEventHandler;
|
|
1096
1648
|
//#endregion
|
|
1097
|
-
export {
|
|
1098
|
-
|
|
1649
|
+
export { prepareSignedActions as $, IRemoteClient as $t, addDocumentCacheEventHandler as A, JobFailedError as At, DocumentChangesEventPayload as B, GetDocumentQueryFields as Bt, useModelRegistry as C, SubgraphSdkRegistry as Ct, useReactorHalves as D, BatchJobFailedError as Dt, useReactorClientModule as E, subgraphUrlFromGraphqlUrl as Et, useDocuments as F, GraphQLDriveReadClient as Ft, createJobChangesSocket as G, phDocumentFromMutation as Gt, IJobChangesSocket as H, RevisionsListSelection as Ht, useGetDocument as I, toLegacyNode as It, startDocumentChangesSubscription as J, ConflictStrategy as Jt, isAuthRefusalClose as K, revisionMapFromRevisionsList as Kt, useGetDocumentAsync as L, BearerTokenProvider as Lt, useDocument as M, queriesUnknownField as Mt, useDocumentCache as N, DriveNodeQueries as Nt, useSync as O, GraphQLOperationNotSupportedError as Ot, useDocumentSafe as P, GraphQLDriveNodeSource as Pt, resolveDocumentModelModule as Q, GetOperationsResult as Qt, useGetDocuments as R, ambientRenownTokenProvider as Rt, useDatabase as S, SubgraphSdkFactory as St, useReactorClient as T, describeGraphQLDocument as Tt, JobChangesEventPayload as U, isoStringFromDateTime as Ut, DocumentChangesSubscriptionOptions as V, GetDocumentQueryResult as Vt, JobChangesSocketOptions as W, phDocumentFromGetDocument as Wt, StaticPackageManager as X, GetDocumentResult as Xt, subscriptionsUrlFromGraphqlUrl as Y, DocumentChangeListener as Yt, packageFromDocumentModels as Z, GetDocumentWithOperationsResult as Zt, addReactorHalvesEventHandler as _, isDocumentTypeCache as _n, createGraphQLDriveNodeSource as _t, DocumentOperationsState as a, RemoteDocumentChangeEvent as an, MutateDocumentWithOperationsDocument as at, setReactorClient as b, IDLE_REFETCH_STATE as bn, viewFilterInputFromViewFilter as bt, useDocumentModelModuleById as c, RemoteOperationResultPage as cn, ReactorOperationFieldsFragmentDoc as ct, UseDispatchResult as d, DocumentCache as dn, ensurePHEventHandlers as dt, IRemoteController as en, signStampedAction as et, createDispatch as f, GET_MANY_CHUNK_SIZE as fn, useSwitchboardClient as ft, addReactorClientModuleEventHandler as g, addPromiseState as gn, GraphQLReactorReadClient as gt, addReactorClientEventHandler as h, IDocumentCacheReader as hn, GraphQLReactorClientOptions as ht, DocumentOperationsResult as i, RemoteControllerOptions as in, GetDocumentAtConsistencyVariables as it, setDocumentCache as j, queriesUnknownArgument as jt, useSyncList as k, GraphQLWrongBackendError as kt, useDocumentModelModules as l, SyncStatus$1 as ln, GraphQLReactorProvider as lt, addFullReactorClientEventHandler as m, IDLE_OPERATIONS_ENTRY as mn, GraphQLReactorClient as mt, setAttachmentService as n, PushResult as nn, GetDocumentAtConsistencyDocument as nt, UseDocumentOperationsOptions as o, RemoteDocumentData as on, MutateDocumentWithOperationsResult as ot, useDispatch as p, IDLE_DOCUMENTS_OF_TYPE_ENTRY as pn, DriveIdCall as pt, makeAuthConnectionParams as q, ConflictInfo as qt, useAttachmentService as r, RemoteControllerGraphQLClient as rn, GetDocumentAtConsistencyResult as rt, useDocumentOperations as s, RemoteOperation as sn, MutateDocumentWithOperationsVariables as st, addAttachmentServiceEventHandler as t, MergeHandler as tn, stampAction as tt, DispatchFn as u, TrackedAction as un, GraphQLReactorProviderProps as ut, getFullReactorClient as v, isOperationCache as vn, findIsServableOverGraphQL as vt, usePGlite as w, TypedGraphQLDocument as wt, setReactorClientModule as x, dispatchActions as xn, GraphQLRequestOptions as xt, setFullReactorClient as y, readPromiseState as yn, isGraphQLReactorClient as yt, ConnectionParams as z, makeAuthMiddleware as zt };
|
|
1650
|
+
export {};
|
|
1651
|
+
//# sourceMappingURL=attachment-service-DPWkKp3y.d.ts.map
|