@powerhousedao/reactor-browser 6.2.3-dev.6 → 6.2.3-dev.61
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-DG6UkyMv.d.ts} +362 -65
- package/dist/attachment-service-DG6UkyMv.d.ts.map +1 -0
- package/dist/{client-BIHN_UyR.d.ts → client-BnGewICj.d.ts} +3 -3
- package/dist/client-BnGewICj.d.ts.map +1 -0
- package/dist/{client-D66jVnot.js → client-CXDpILj6.js} +232 -32
- package/dist/client-CXDpILj6.js.map +1 -0
- package/dist/{client-DjK30EQ-.js → client-Cq5avLW5.js} +35 -22
- package/dist/client-Cq5avLW5.js.map +1 -0
- package/dist/{document-by-id-B4FIzG1w.js → dispatch-C1VVTn5S.js} +393 -54
- package/dist/dispatch-C1VVTn5S.js.map +1 -0
- package/dist/document-by-id-BRDkvmpn.js +16 -0
- package/dist/document-by-id-BRDkvmpn.js.map +1 -0
- package/dist/{document-model-modules-bTP87nyr.js → document-model-modules-Gsh1Xr7j.js} +60 -68
- package/dist/document-model-modules-Gsh1Xr7j.js.map +1 -0
- package/dist/{document-operations-WeE6wIDt.js → document-operations-BSzcF0mu.js} +805 -167
- package/dist/document-operations-BSzcF0mu.js.map +1 -0
- package/dist/{global-OuINvEGT.d.ts → global-BuSwbbY0.d.ts} +59 -13
- package/dist/global-BuSwbbY0.d.ts.map +1 -0
- package/dist/{index-B33TKEqp.d.ts → index-ewIc3pEO.d.ts} +19 -98
- package/dist/index-ewIc3pEO.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 +395 -371
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -47
- 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-DBq3iWYn.js → make-ph-event-functions-CdsvEl5t.js} +4 -2
- package/dist/{make-ph-event-functions-DBq3iWYn.js.map → make-ph-event-functions-CdsvEl5t.js.map} +1 -1
- 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-DxHuX41f.js} +66 -5
- package/dist/relational-DxHuX41f.js.map +1 -0
- package/dist/{renown-rqK8sokh.js → renown-CPAeJt5L.js} +7 -8
- package/dist/{renown-rqK8sokh.js.map → renown-CPAeJt5L.js.map} +1 -1
- package/dist/{renown-BHxwP7xU.js → renown-D05wkobG.js} +2 -2
- package/dist/{renown-BHxwP7xU.js.map → renown-D05wkobG.js.map} +1 -1
- package/dist/src/ai/index.d.ts +51 -62
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/index.js +5 -8
- 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 +2 -2
- 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 +176 -138
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +421 -618
- 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-3vHbIV5W.js} +58 -6
- package/dist/switchboard-3vHbIV5W.js.map +1 -0
- package/dist/{types-Dcv1ZLoW.d.ts → types-0Fh1tNjy.d.ts} +242 -17
- package/dist/types-0Fh1tNjy.d.ts.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/package.json +19 -20
- 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.map +0 -1
- 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.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/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,41 @@
|
|
|
1
|
-
import { a as PHGlobal$1, b as IPackagesListener, ct as
|
|
2
|
-
import { t as PGlite } from "./pglite-CntadC_p-
|
|
3
|
-
import { A as ViewFilterInput, C as GetDocumentQuery, D as PropagationMode$1, E as PhDocumentFieldsFragment, O as Scalars, S as GetDocumentOperationsQuery, b as DocumentChangesSubscription, c as ReactorGraphQLClient, g as ActionInput, k as SdkFunctionWrapper } from "./types-
|
|
1
|
+
import { a as PHGlobal$1, at as DocumentRefetchState, b as IPackagesListener, ct as IOperationCache, d as UsePHGlobalValue$1, dt as PromiseWithState, lt as OperationsCacheEntry, rt as IReactorBrowserClient$1, st as IDocumentCache, u as SetPHGlobalValue$1, ut as PromiseState, v as IPackageListerUnsubscribe, x as PackageManagerInstallResult, y as IPackageManager } from "./global-BuSwbbY0.js";
|
|
2
|
+
import { t as PGlite } from "./pglite-CntadC_p-DTkdF8sr.js";
|
|
3
|
+
import { A as ViewFilterInput, C as GetDocumentQuery, D as PropagationMode$1, E as PhDocumentFieldsFragment, O as Scalars, S as GetDocumentOperationsQuery, b as DocumentChangesSubscription, c as ReactorGraphQLClient, g as ActionInput, k as SdkFunctionWrapper } from "./types-0Fh1tNjy.js";
|
|
4
4
|
import { Action, DocumentModelLib, DocumentModelModule, Operation, PHDocument } from "document-model";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { Database, DocumentChangeEvent, DocumentModelSource, IDocumentModelRegistry, ISyncManager, OperationFilter, PagedResults, PagingOptions, PropagationMode, SearchFilter, ViewFilter } from "@powerhousedao/reactor";
|
|
5
|
+
import { BatchExecutionRequest, BatchExecutionResult, Database, DocumentChangeEvent, DocumentModelSource, DocumentRelationship, IDocumentModelRegistry, IReactorClient, ISyncManager, JobInfo, OperationFilter, PagedResults, PagingOptions, PropagationMode, SearchFilter, ViewFilter } from "@powerhousedao/reactor";
|
|
6
|
+
import { Action as Action$1, ActionSigningTarget, DocumentModelModule as DocumentModelModule$1, DocumentOperations, ISigner, Operation as Operation$1, PHBaseState, PHDocument as PHDocument$1, PHDocumentHeader, ProtocolVersions, SignaturePolicy } from "@powerhousedao/shared/document-model";
|
|
8
7
|
import { ReactNode } from "react";
|
|
9
8
|
import { GraphQLClient, Variables } from "graphql-request";
|
|
10
|
-
import * as graphql from "graphql";
|
|
11
9
|
import { DocumentNode } from "graphql";
|
|
12
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
13
10
|
import { IAttachmentService } from "@powerhousedao/reactor-attachments/client";
|
|
14
11
|
import { Kysely } from "kysely";
|
|
15
12
|
import { AddPHGlobalEventHandler, BrowserReactorClientModule, IReactorBrowserClient, SetPHGlobalValue, UsePHGlobalValue, WorkerReactorClientModule } from "@powerhousedao/reactor-browser";
|
|
16
13
|
import { RegistryPackageSource } from "@powerhousedao/shared";
|
|
17
|
-
|
|
14
|
+
//#region src/document-refetcher.d.ts
|
|
15
|
+
/** The refetch snapshot of a document with nothing in flight and no kept failure. */
|
|
16
|
+
declare const IDLE_REFETCH_STATE: DocumentRefetchState;
|
|
17
|
+
//#endregion
|
|
18
18
|
//#region src/document-cache.d.ts
|
|
19
19
|
declare function addPromiseState<T>(promise: Promise<T>): PromiseWithState<T>;
|
|
20
20
|
declare function readPromiseState<T>(promise: Promise<T> | PromiseWithState<T>): PromiseState<T>;
|
|
21
|
+
/** The snapshot every uncached document scope reads as. One frozen object, so `useSyncExternalStore` sees a stable value. */
|
|
22
|
+
declare const IDLE_OPERATIONS_ENTRY: OperationsCacheEntry;
|
|
23
|
+
/** Whether a document cache also serves operation history. `GraphQLClientDocumentCache` does not. */
|
|
24
|
+
declare function isOperationCache(cache: unknown): cache is IOperationCache;
|
|
21
25
|
/**
|
|
22
26
|
* Document cache implementation that uses the new ReactorClient API.
|
|
23
27
|
*
|
|
24
28
|
* This cache subscribes to document change events via IReactorBrowserClient.subscribe()
|
|
25
29
|
* and automatically updates the cache when documents are created, updated, or deleted.
|
|
30
|
+
* It also holds paginated operation history per document scope (see `IOperationCache`),
|
|
31
|
+
* which is dropped for a document whenever a change event for it arrives.
|
|
26
32
|
*/
|
|
27
|
-
declare class DocumentCache implements IDocumentCache {
|
|
33
|
+
declare class DocumentCache implements IDocumentCache, IOperationCache {
|
|
28
34
|
private client;
|
|
29
35
|
private documents;
|
|
30
36
|
private batchPromises;
|
|
31
37
|
private listeners;
|
|
38
|
+
private refetcher;
|
|
32
39
|
/**
|
|
33
40
|
* Cache keys that fetched a document under a name other than its id --
|
|
34
41
|
* slugs, which `client.get` resolves. Change events dispatch by `header.id`,
|
|
@@ -37,19 +44,55 @@ declare class DocumentCache implements IDocumentCache {
|
|
|
37
44
|
* the same document is cached under.
|
|
38
45
|
*/
|
|
39
46
|
private aliasKeys;
|
|
47
|
+
/** Operations by document id, then scope. Entries are replaced, never mutated. */
|
|
48
|
+
private operationEntries;
|
|
49
|
+
/** In-flight controllers and the next page's cursor/limit, by document id then scope. */
|
|
50
|
+
private operationRequests;
|
|
51
|
+
private operationListeners;
|
|
40
52
|
private unsubscribe;
|
|
41
53
|
constructor(client: IReactorBrowserClient$1);
|
|
42
54
|
private handleDocumentChange;
|
|
43
55
|
private handleDocumentDeleted;
|
|
44
56
|
private handleDocumentUpdated;
|
|
57
|
+
private notifyListeners;
|
|
45
58
|
/** The id an event dispatches by, plus every alias the document is cached under. */
|
|
46
59
|
private cacheKeysFor;
|
|
47
60
|
/** Records that `key` cached the document change events know as `header.id`. */
|
|
48
61
|
private recordAlias;
|
|
49
62
|
private invalidateBatchesContaining;
|
|
50
63
|
get(id: string, refetch?: boolean): Promise<PHDocument$1>;
|
|
64
|
+
getRefetchState(id: string): DocumentRefetchState;
|
|
51
65
|
getBatch(ids: string[]): Promise<PHDocument$1[]>;
|
|
52
66
|
subscribe(id: string | string[], callback: () => void): () => void;
|
|
67
|
+
getOperationsState(documentId: string, scope: string): OperationsCacheEntry;
|
|
68
|
+
loadOperations(documentId: string, scope: string, limit: number): void;
|
|
69
|
+
loadMoreOperations(documentId: string, scope: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Bring a document's cached scopes up to date after it changed, without
|
|
72
|
+
* throwing away what is already loaded.
|
|
73
|
+
*
|
|
74
|
+
* The operation stream is append-only: an update adds operations at higher
|
|
75
|
+
* revisions and never rewrites the ones below, so history already paged in
|
|
76
|
+
* is still correct. Dropping it meant a panel showing a fully loaded
|
|
77
|
+
* document re-walked every page on each edit -- the cost of which grows
|
|
78
|
+
* with the document, exactly where it hurts most. Each scope instead asks
|
|
79
|
+
* only for what comes after the newest revision it holds, using the
|
|
80
|
+
* `sinceRevision` filter, and appends the answer.
|
|
81
|
+
*
|
|
82
|
+
* A scope that has not finished paging is dropped as before: it has no
|
|
83
|
+
* meaningful "newest revision" to resume from, since asking for everything
|
|
84
|
+
* past the newest row it happens to hold would skip the pages between that
|
|
85
|
+
* row and the end of the stream.
|
|
86
|
+
*/
|
|
87
|
+
private refreshOperations;
|
|
88
|
+
/** Drops one scope of a document, aborting its request if one is in flight. */
|
|
89
|
+
private invalidateOperationsScope;
|
|
90
|
+
invalidateOperations(documentId: string): void;
|
|
91
|
+
subscribeOperations(documentId: string, callback: () => void): () => void;
|
|
92
|
+
private settleOperationsPage;
|
|
93
|
+
private setOperationsEntry;
|
|
94
|
+
private setOperationsRequest;
|
|
95
|
+
private notifyOperationListeners;
|
|
53
96
|
/**
|
|
54
97
|
* Disposes of the cache and unsubscribes from document change events.
|
|
55
98
|
*/
|
|
@@ -65,14 +108,22 @@ type RemoteOperationResultPage = GetDocumentOperationsQuery["documentOperations"
|
|
|
65
108
|
* Options for creating a RemoteDocumentController.
|
|
66
109
|
*/
|
|
67
110
|
type RemoteControllerOptions = {
|
|
68
|
-
client: RemoteControllerGraphQLClient;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
111
|
+
client: RemoteControllerGraphQLClient;
|
|
112
|
+
/** Remote document id. Omit for new documents. */
|
|
113
|
+
documentId?: string;
|
|
114
|
+
/** "batch" requires explicit push(), "streaming" auto-pushes after actions. Defaults to "batch" */
|
|
115
|
+
mode?: "batch" | "streaming";
|
|
116
|
+
/** Optional signer for action signing. */
|
|
117
|
+
signer?: ISigner;
|
|
118
|
+
/** Branch name, defaults to "main". */
|
|
119
|
+
branch?: string;
|
|
120
|
+
/** Parent document identifier for creating new documents. */
|
|
121
|
+
parentIdentifier?: string;
|
|
122
|
+
/** Conflict resolution strategy when remote has new operations. Default: no check (current behavior). */
|
|
123
|
+
onConflict?: ConflictStrategy;
|
|
124
|
+
/** Called when a streaming-mode push fails. If not provided, errors are silently swallowed. */
|
|
125
|
+
onPushError?: (error: unknown) => void;
|
|
126
|
+
/** Number of operations to fetch per page. Defaults to 100. */
|
|
76
127
|
operationsPageSize?: number;
|
|
77
128
|
};
|
|
78
129
|
/**
|
|
@@ -80,7 +131,8 @@ type RemoteControllerOptions = {
|
|
|
80
131
|
*/
|
|
81
132
|
type PushResult = {
|
|
82
133
|
remoteDocument: RemoteDocumentData;
|
|
83
|
-
actionCount: number;
|
|
134
|
+
actionCount: number;
|
|
135
|
+
/** The actions that were sent to the server (after signing, if applicable). */
|
|
84
136
|
operations: ReadonlyArray<Action$1>;
|
|
85
137
|
};
|
|
86
138
|
/**
|
|
@@ -102,9 +154,13 @@ type TrackedAction = {
|
|
|
102
154
|
};
|
|
103
155
|
/** Information about a detected conflict. */
|
|
104
156
|
type ConflictInfo = {
|
|
105
|
-
/** Remote operations added since the last pull, grouped by scope. */
|
|
106
|
-
|
|
107
|
-
|
|
157
|
+
/** Remote operations added since the last pull, grouped by scope. */
|
|
158
|
+
remoteOperations: Record<string, RemoteOperation[]>;
|
|
159
|
+
/** Local actions pending push. */
|
|
160
|
+
localActions: TrackedAction[];
|
|
161
|
+
/** Remote revision at last pull. */
|
|
162
|
+
knownRevision: Record<string, number>;
|
|
163
|
+
/** Current remote revision. */
|
|
108
164
|
currentRevision: Record<string, number>;
|
|
109
165
|
};
|
|
110
166
|
/** Custom merge handler receives conflict info and returns actions to push (or throws to abort). */
|
|
@@ -188,6 +244,8 @@ declare function phDocumentFromGetDocument<TDocument extends PHDocument = PHDocu
|
|
|
188
244
|
declare function phDocumentFromMutation<TDocument extends PHDocument = PHDocument>(document: GetDocumentQueryFields, operations: readonly RemoteOperation[], branch?: string): TDocument;
|
|
189
245
|
/** Turns a `revisionsList` selection into the header's per-scope revision map. */
|
|
190
246
|
declare function revisionMapFromRevisionsList(revisionsList: RevisionsListSelection): Record<string, number>;
|
|
247
|
+
/** The `DateTime` scalar deserializes as either an ISO string or a `Date`. */
|
|
248
|
+
declare function isoStringFromDateTime(value: string | Date): string;
|
|
191
249
|
//#endregion
|
|
192
250
|
//#region src/graphql-client/auth.d.ts
|
|
193
251
|
/**
|
|
@@ -217,6 +275,41 @@ declare function ambientRenownTokenProvider(): Promise<string | undefined>;
|
|
|
217
275
|
*/
|
|
218
276
|
declare function makeAuthMiddleware(tokenProvider: BearerTokenProvider): SdkFunctionWrapper;
|
|
219
277
|
//#endregion
|
|
278
|
+
//#region src/graphql-client/errors.d.ts
|
|
279
|
+
/** A call the Switchboard GraphQL surface cannot express. */
|
|
280
|
+
declare class GraphQLOperationNotSupportedError extends Error {
|
|
281
|
+
readonly name = "GraphQLOperationNotSupportedError";
|
|
282
|
+
readonly operation: string;
|
|
283
|
+
constructor(operation: string, reason: string);
|
|
284
|
+
static isError(error: unknown): error is GraphQLOperationNotSupportedError;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The Switchboard refused a request with 421 Misdirected Request: the
|
|
288
|
+
* `Drive-Id` it carried names a drive that Switchboard does not own.
|
|
289
|
+
*/
|
|
290
|
+
declare class GraphQLWrongBackendError extends Error {
|
|
291
|
+
readonly name = "GraphQLWrongBackendError";
|
|
292
|
+
readonly status = 421;
|
|
293
|
+
/** The drive the Switchboard refused, or `""` when its answer names none. */
|
|
294
|
+
readonly driveId: string;
|
|
295
|
+
/** The response body, parsed when it is JSON. */
|
|
296
|
+
readonly payload: unknown;
|
|
297
|
+
constructor(driveId: string, payload: unknown, options?: ErrorOptions);
|
|
298
|
+
static isError(error: unknown): error is GraphQLWrongBackendError;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* The reactor's `BatchJobFailedError`, rebuilt from a batch result; this entry
|
|
302
|
+
* imports the reactor for types only. The shared name lets either `isError`
|
|
303
|
+
* recognise it.
|
|
304
|
+
*/
|
|
305
|
+
declare class BatchJobFailedError extends Error {
|
|
306
|
+
readonly name = "BatchJobFailedError";
|
|
307
|
+
readonly key: string;
|
|
308
|
+
readonly jobs: Readonly<Record<string, JobInfo>>;
|
|
309
|
+
constructor(key: string, jobs: Record<string, JobInfo>);
|
|
310
|
+
static isError(error: unknown): error is BatchJobFailedError;
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
220
313
|
//#region src/graphql-client/subgraph.d.ts
|
|
221
314
|
/**
|
|
222
315
|
* The factory a GraphQL code generator produces for a schema.
|
|
@@ -303,14 +396,25 @@ declare class SubgraphSdkRegistry {
|
|
|
303
396
|
}
|
|
304
397
|
//#endregion
|
|
305
398
|
//#region src/graphql-client/graphql-reactor-client.d.ts
|
|
399
|
+
/** A call the client asks {@link GraphQLReactorClientOptions.driveIdFor} about. */
|
|
400
|
+
type DriveIdCall = {
|
|
401
|
+
readonly method: "create" | "execute" | "executeBatch" | "deleteDocument" | "find";
|
|
402
|
+
readonly documentId?: string;
|
|
403
|
+
readonly parentId?: string;
|
|
404
|
+
readonly jobs?: readonly {
|
|
405
|
+
readonly documentId: string;
|
|
406
|
+
}[];
|
|
407
|
+
};
|
|
306
408
|
type GraphQLReactorClientOptions = {
|
|
307
|
-
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
409
|
+
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
410
|
+
url: string;
|
|
308
411
|
/**
|
|
309
412
|
* A pre-built SDK to use instead of the transport derived from `url`.
|
|
310
413
|
* Mainly a test seam.
|
|
311
414
|
*
|
|
312
|
-
* A client built this way carries no auth middleware
|
|
313
|
-
* its own transport, and therefore its own headers
|
|
415
|
+
* A client built this way carries no auth middleware and no 421 mapping:
|
|
416
|
+
* the injected SDK owns its own transport, and therefore its own headers
|
|
417
|
+
* and transport errors.
|
|
314
418
|
*/
|
|
315
419
|
graphqlClient?: ReactorGraphQLClient;
|
|
316
420
|
/**
|
|
@@ -348,10 +452,12 @@ type GraphQLReactorClientOptions = {
|
|
|
348
452
|
* `state.document.version` is here. One action needs no prediction and is
|
|
349
453
|
* signed without any of this.
|
|
350
454
|
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
455
|
+
* An array is read once, when the client is built; a function is called at
|
|
456
|
+
* every batch, for a registry that gains models later. Below
|
|
457
|
+
* `GraphQLReactorProvider` this is its `documentModels` prop; a client
|
|
458
|
+
* constructed directly passes its own.
|
|
353
459
|
*/
|
|
354
|
-
documentModels?: readonly DocumentModelModule<any>[];
|
|
460
|
+
documentModels?: readonly DocumentModelModule<any>[] | (() => readonly DocumentModelModule<any>[]);
|
|
355
461
|
/**
|
|
356
462
|
* Signs the actions this client pushes, instead of the logged-in Renown user.
|
|
357
463
|
*
|
|
@@ -361,6 +467,13 @@ type GraphQLReactorClientOptions = {
|
|
|
361
467
|
* scripts, and integration suites that must sign deterministically.
|
|
362
468
|
*/
|
|
363
469
|
signer?: ISigner;
|
|
470
|
+
/**
|
|
471
|
+
* Names the drive a call belongs to when the client cannot prove it itself,
|
|
472
|
+
* for its `Drive-Id` header; `undefined` sends none. Return only a drive id
|
|
473
|
+
* the caller knows: a Switchboard that does not own it answers 421. Where
|
|
474
|
+
* the client has proof of its own and the two disagree, the proof is sent.
|
|
475
|
+
*/
|
|
476
|
+
driveIdFor?: (call: DriveIdCall) => string | undefined;
|
|
364
477
|
};
|
|
365
478
|
/**
|
|
366
479
|
* The marker {@link isGraphQLReactorClient} looks for.
|
|
@@ -388,6 +501,7 @@ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
|
|
|
388
501
|
private readonly subscriptionsUrl;
|
|
389
502
|
private readonly documentModels;
|
|
390
503
|
private readonly signer;
|
|
504
|
+
private readonly driveIdFor;
|
|
391
505
|
private stopRealtime;
|
|
392
506
|
private realtimeStarted;
|
|
393
507
|
private realtimeGeneration;
|
|
@@ -396,7 +510,33 @@ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
|
|
|
396
510
|
private realtimeRefusedCredentials;
|
|
397
511
|
constructor(options: GraphQLReactorClientOptions);
|
|
398
512
|
get<TDocument extends PHDocument>(identifier: string, view?: ViewFilter, signal?: AbortSignal): Promise<TDocument>;
|
|
513
|
+
/**
|
|
514
|
+
* Whether the Switchboard would serve the document to this client's caller,
|
|
515
|
+
* from its `documentServed` query: the same read gate `find` passes. Absent
|
|
516
|
+
* or withheld is `false`; a failure to decide throws.
|
|
517
|
+
*
|
|
518
|
+
* A point-in-time view throws {@link GraphQLOperationNotSupportedError}, as
|
|
519
|
+
* does a Switchboard without the query.
|
|
520
|
+
*/
|
|
521
|
+
isServed(identifier: string, view?: ViewFilter, signal?: AbortSignal): Promise<boolean>;
|
|
399
522
|
getOperations(documentIdentifier: string, view?: ViewFilter, filter?: OperationFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
|
|
523
|
+
/**
|
|
524
|
+
* Filters documents by criteria over the Switchboard's `findDocuments` query.
|
|
525
|
+
*
|
|
526
|
+
* The query filters by `type` and `parentId` only, at head. A search naming
|
|
527
|
+
* `ids` or `slugs` (present, whatever its length) and a point-in-time view are
|
|
528
|
+
* each by-contract limitations the query cannot express -- running it anyway
|
|
529
|
+
* would return every document instead of the named ones, or head instead of
|
|
530
|
+
* the asked-for revision, a silently wrong answer. {@link findIsServableOverGraphQL}
|
|
531
|
+
* is the single predicate that decides this, and an unservable `find` throws
|
|
532
|
+
* {@link GraphQLOperationNotSupportedError}. Drive enumeration itself filters
|
|
533
|
+
* by `type` at head, which is served.
|
|
534
|
+
*/
|
|
535
|
+
find<TDocument extends PHDocument = PHDocument>(search: SearchFilter, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<TDocument>>;
|
|
536
|
+
getOutgoingRelationships(sourceIdentifier: string, relationshipType: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
537
|
+
getIncomingRelationships(targetIdentifier: string, relationshipType: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
538
|
+
getOutgoingRelationshipEdges(sourceIdentifier: string, relationshipType?: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<DocumentRelationship>>;
|
|
539
|
+
getIncomingRelationshipEdges(targetIdentifier: string, relationshipType?: string, view?: ViewFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<DocumentRelationship>>;
|
|
400
540
|
create<TDocument extends PHDocument = PHDocument>(document: PHDocument, parentIdentifier?: string, signal?: AbortSignal): Promise<TDocument>;
|
|
401
541
|
/**
|
|
402
542
|
* Pushes actions to the Switchboard and returns the updated document.
|
|
@@ -416,6 +556,82 @@ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
|
|
|
416
556
|
* request. Declaring it would suggest a per-call choice that does not exist.
|
|
417
557
|
*/
|
|
418
558
|
execute<TDocument extends PHDocument>(documentIdentifier: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<TDocument>;
|
|
559
|
+
/**
|
|
560
|
+
* Runs multiple mutation jobs in dependency order over the Switchboard's
|
|
561
|
+
* `executeBatch` mutation and waits for all to settle, returning the result
|
|
562
|
+
* shaped like `IReactor.executeBatch`'s so the reference `DriveClient`
|
|
563
|
+
* consumes it unchanged.
|
|
564
|
+
*
|
|
565
|
+
* Not atomic: each job commits on its own and a failed job still releases
|
|
566
|
+
* its dependents. A FAILED job throws {@link BatchJobFailedError}, naming the
|
|
567
|
+
* first failed plan key and carrying every job's final state.
|
|
568
|
+
*
|
|
569
|
+
* Each job's actions are signed independently for the job's own
|
|
570
|
+
* `(documentId, branch)` target -- the per-action signing the reactor's own
|
|
571
|
+
* `signActions` does, not the batch state-prediction `execute` uses for a
|
|
572
|
+
* multi-action push. A drive job such as `addFile`'s is `CREATE_DOCUMENT` +
|
|
573
|
+
* `UPGRADE_DOCUMENT` + `ADD_RELATIONSHIP`, which the prediction path rejects
|
|
574
|
+
* outright and which has no fetchable baseline to stamp against. The reactor
|
|
575
|
+
* records but does not verify the stamped previous-state head, so signing
|
|
576
|
+
* each action bare is exactly what the in-process `DriveClient` relies on.
|
|
577
|
+
*
|
|
578
|
+
* The mutation is synchronous server-side: a job it returns is already
|
|
579
|
+
* settled, so {@link waitForJob} resolves from it without polling.
|
|
580
|
+
*/
|
|
581
|
+
executeBatch(request: BatchExecutionRequest, signal?: AbortSignal): Promise<BatchExecutionResult>;
|
|
582
|
+
/** The job as `jobStatus` reports it now; `undefined` when it reports none. */
|
|
583
|
+
getJob(jobId: string, signal?: AbortSignal): Promise<JobInfo | undefined>;
|
|
584
|
+
/** Polls `jobStatus` until the job is READ_READY or FAILED. */
|
|
585
|
+
waitForJob(jobOrId: string | JobInfo, signal?: AbortSignal): Promise<JobInfo>;
|
|
586
|
+
/**
|
|
587
|
+
* The policy the Switchboard gives a new document, read from its
|
|
588
|
+
* `createDefaults` query. A Switchboard without that query is refused with
|
|
589
|
+
* {@link GraphQLOperationNotSupportedError}: a guessed default would
|
|
590
|
+
* under-sign on a stricter host.
|
|
591
|
+
*/
|
|
592
|
+
getCreateSignaturePolicy(): Promise<SignaturePolicy>;
|
|
593
|
+
/**
|
|
594
|
+
* The protocol versions the Switchboard selects for a new document under
|
|
595
|
+
* `parentIdentifier`, read from its `createDefaults` query. A parent the
|
|
596
|
+
* caller may not read is refused by the server, never answered as if none
|
|
597
|
+
* was named; a Switchboard without the query is refused with
|
|
598
|
+
* {@link GraphQLOperationNotSupportedError}.
|
|
599
|
+
*/
|
|
600
|
+
getCreateProtocolVersions(parentIdentifier?: string, signal?: AbortSignal): Promise<ProtocolVersions>;
|
|
601
|
+
private createDefaults;
|
|
602
|
+
/**
|
|
603
|
+
* Sets or, with `null`, clears the preferred editor as a client-signed
|
|
604
|
+
* action, as the in-process client does.
|
|
605
|
+
*/
|
|
606
|
+
setPreferredEditor(documentIdentifier: string, preferredEditor: string | null, branch?: string, signal?: AbortSignal): Promise<PHDocument>;
|
|
607
|
+
/** The `Drive-Id` header for a call: the client's own proof, else the hook's. */
|
|
608
|
+
private driveIdHeaders;
|
|
609
|
+
/**
|
|
610
|
+
* Emits the changes the batch's settled jobs made, as `create` and `execute`
|
|
611
|
+
* do, so a cache is invalidated without a realtime socket. The documents a
|
|
612
|
+
* job wrote to are its own and those its consistency token names.
|
|
613
|
+
*/
|
|
614
|
+
private announceBatch;
|
|
615
|
+
/**
|
|
616
|
+
* The id a job's actions are signed for: a signature covers the document id,
|
|
617
|
+
* and the server resolves a slug before verifying. A document created by this
|
|
618
|
+
* job or an earlier one is named by its id. When the server has no such
|
|
619
|
+
* document the identifier is used as given, and the server decides; any
|
|
620
|
+
* other failure to read it throws, so nothing is signed for a slug.
|
|
621
|
+
*/
|
|
622
|
+
private batchWriteTarget;
|
|
623
|
+
/**
|
|
624
|
+
* Signs one batch job's actions for the job's own log.
|
|
625
|
+
*
|
|
626
|
+
* Each action is signed on its own for `(documentId, branch)`, the same
|
|
627
|
+
* per-action signing the reactor's `signActions` does: no state prediction
|
|
628
|
+
* across the job, so a job carrying a `CREATE_DOCUMENT` the push-prediction
|
|
629
|
+
* path rejects still signs. An action already signed under a key is left
|
|
630
|
+
* as it is: the reference `DriveClient` signs its jobs before handing them
|
|
631
|
+
* here. With no signer the actions pass through unsigned, matching
|
|
632
|
+
* {@link execute}.
|
|
633
|
+
*/
|
|
634
|
+
private signBatchJobActions;
|
|
419
635
|
/**
|
|
420
636
|
* Deletes a document and announces it as a `Deleted` event.
|
|
421
637
|
*
|
|
@@ -490,6 +706,19 @@ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
|
|
|
490
706
|
* `gql` document or a string and name the result type at the call site.
|
|
491
707
|
*/
|
|
492
708
|
request<TResult = unknown, TVariables extends Variables = Variables>(document: TypedGraphQLDocument<TResult, TVariables> | string, variables?: TVariables, options?: GraphQLRequestOptions): Promise<TResult>;
|
|
709
|
+
/**
|
|
710
|
+
* Shapes a document result page into the reactor's {@link PagedResults}.
|
|
711
|
+
*
|
|
712
|
+
* The items carry the same `PHDocumentFields` fragment as `get`, so the same
|
|
713
|
+
* adapter rebuilds each one. `hasNextPage` gates the cursor exactly as
|
|
714
|
+
* `getOperations` does: no cursor means no `next`.
|
|
715
|
+
*/
|
|
716
|
+
private toDocumentResults;
|
|
717
|
+
/**
|
|
718
|
+
* Shapes a relationship-edge result page into the reactor's
|
|
719
|
+
* {@link PagedResults}, restoring each edge's `Date` fields.
|
|
720
|
+
*/
|
|
721
|
+
private toRelationshipResults;
|
|
493
722
|
/**
|
|
494
723
|
* Opens the realtime socket on the first subscriber.
|
|
495
724
|
*
|
|
@@ -571,6 +800,15 @@ declare function isGraphQLReactorClient(client: unknown): client is GraphQLReact
|
|
|
571
800
|
* argument, so silently returning the head state would be wrong.
|
|
572
801
|
*/
|
|
573
802
|
declare function viewFilterInputFromViewFilter(view?: ViewFilter): ViewFilterInput | undefined;
|
|
803
|
+
/**
|
|
804
|
+
* The single source of truth for whether the Switchboard `findDocuments` query
|
|
805
|
+
* can serve a `find`. It is servable iff the search names neither `ids` nor
|
|
806
|
+
* `slugs` (present, regardless of length) AND the view is not point-in-time:
|
|
807
|
+
* each is a by-contract limitation of a surface that filters only by
|
|
808
|
+
* `type`/`parentId` at head. Exported so a caller can route around an
|
|
809
|
+
* unservable search instead of catching the error `find` throws for it.
|
|
810
|
+
*/
|
|
811
|
+
declare function findIsServableOverGraphQL(search: SearchFilter, view?: ViewFilter): boolean;
|
|
574
812
|
//#endregion
|
|
575
813
|
//#region src/graphql-client/graphql-reactor-provider.d.ts
|
|
576
814
|
declare global {
|
|
@@ -589,7 +827,8 @@ declare global {
|
|
|
589
827
|
*/
|
|
590
828
|
declare function ensurePHEventHandlers(): void;
|
|
591
829
|
type GraphQLReactorProviderProps = {
|
|
592
|
-
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
830
|
+
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
831
|
+
url: string;
|
|
593
832
|
/**
|
|
594
833
|
* Resolves the bearer token sent with every request, per request. Defaults to
|
|
595
834
|
* the token of the logged-in Renown user, or none when nobody is logged in.
|
|
@@ -675,15 +914,7 @@ type GraphQLReactorProviderProps = {
|
|
|
675
914
|
* effect rebuilds both if it runs again on the same client - which is what a
|
|
676
915
|
* `StrictMode` mount does.
|
|
677
916
|
*/
|
|
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;
|
|
917
|
+
declare function GraphQLReactorProvider({ url, tokenProvider, subscriptionsUrl, realtime, attachmentService, documentModels, children }: GraphQLReactorProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
687
918
|
/**
|
|
688
919
|
* Returns the {@link GraphQLReactorClient} mounted by
|
|
689
920
|
* {@link GraphQLReactorProvider}, or `undefined` when the slot holds something
|
|
@@ -705,7 +936,7 @@ declare function useSwitchboardClient(): GraphQLReactorClient | undefined;
|
|
|
705
936
|
* The operation selection of `GetDocumentOperations`, lifted into a fragment so
|
|
706
937
|
* the write path can reuse `remoteOperationToLocal` on the items it selects.
|
|
707
938
|
*/
|
|
708
|
-
declare const ReactorOperationFieldsFragmentDoc: graphql.DocumentNode;
|
|
939
|
+
declare const ReactorOperationFieldsFragmentDoc: import("graphql").DocumentNode;
|
|
709
940
|
/**
|
|
710
941
|
* `mutateDocument` plus the operations the mutation produced.
|
|
711
942
|
*
|
|
@@ -727,7 +958,7 @@ declare const ReactorOperationFieldsFragmentDoc: graphql.DocumentNode;
|
|
|
727
958
|
* by hand or the operations came from `main` while the actions were applied
|
|
728
959
|
* elsewhere. One variable cannot disagree with itself.
|
|
729
960
|
*/
|
|
730
|
-
declare const MutateDocumentWithOperationsDocument: graphql.DocumentNode;
|
|
961
|
+
declare const MutateDocumentWithOperationsDocument: import("graphql").DocumentNode;
|
|
731
962
|
type MutateDocumentWithOperationsVariables = {
|
|
732
963
|
documentIdentifier: Scalars["String"]["input"];
|
|
733
964
|
actions: ReadonlyArray<ActionInput>;
|
|
@@ -761,12 +992,12 @@ type MutateDocumentWithOperationsResult = {
|
|
|
761
992
|
*/
|
|
762
993
|
declare function stampAction(action: Action$1, document: PHDocument$1, revision?: number): Action$1;
|
|
763
994
|
/**
|
|
764
|
-
* Signs a stamped action
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
995
|
+
* Signs a stamped action for `target`, keeping any signatures it already
|
|
996
|
+
* carries. The signer reads `context.prevOpHash`, so this runs after
|
|
997
|
+
* {@link stampAction}. A v2 tuple covers the signer's identity, so the context
|
|
998
|
+
* takes the signer's user and app even when the action named others.
|
|
768
999
|
*/
|
|
769
|
-
declare function signStampedAction(action: Action$1, signer: ISigner, signal?: AbortSignal): Promise<Action$1>;
|
|
1000
|
+
declare function signStampedAction(action: Action$1, signer: ISigner, target: ActionSigningTarget, signal?: AbortSignal): Promise<Action$1>;
|
|
770
1001
|
/**
|
|
771
1002
|
* Stamps and signs a batch of actions against one document snapshot, so every
|
|
772
1003
|
* action carries the head its predecessor will leave behind.
|
|
@@ -856,13 +1087,15 @@ type DocumentChangesEventPayload = DocumentChangesSubscription["documentChanges"
|
|
|
856
1087
|
/** The connection payload sent with the `ConnectionInit` message. */
|
|
857
1088
|
type ConnectionParams = Record<string, string>;
|
|
858
1089
|
type DocumentChangesSubscriptionOptions = {
|
|
859
|
-
/** The websocket endpoint, e.g. `ws://localhost:4001/graphql/subscriptions`. */
|
|
1090
|
+
/** The websocket endpoint, e.g. `ws://localhost:4001/graphql/subscriptions`. */
|
|
1091
|
+
wsUrl: string;
|
|
860
1092
|
/**
|
|
861
1093
|
* Resolves the `ConnectionInit` payload. Called again on every reconnect, so
|
|
862
1094
|
* a token that expired while the socket was down is refreshed on the way back
|
|
863
1095
|
* up.
|
|
864
1096
|
*/
|
|
865
|
-
connectionParams?: () => Promise<ConnectionParams>;
|
|
1097
|
+
connectionParams?: () => Promise<ConnectionParams>;
|
|
1098
|
+
/** Called once per server event. */
|
|
866
1099
|
onEvent: (event: DocumentChangesEventPayload) => void;
|
|
867
1100
|
/**
|
|
868
1101
|
* Called when the socket gives up: the retries built into `graphql-ws` are
|
|
@@ -938,6 +1171,8 @@ declare function useDocument(id: string | null | undefined): PHDocument$1 | unde
|
|
|
938
1171
|
* - isPending: Whether the document is currently loading
|
|
939
1172
|
* - error: Any error that occurred during loading (e.g., document not found)
|
|
940
1173
|
* - reload: Function to force a refetch, or undefined when no id is supplied
|
|
1174
|
+
* - isRefetching: A loaded document is being refetched; `data` is the loaded one
|
|
1175
|
+
* - refetchError: The last refetch failure that kept the loaded document
|
|
941
1176
|
*/
|
|
942
1177
|
declare function useDocumentSafe(id: string | null | undefined): {
|
|
943
1178
|
readonly status: "initial";
|
|
@@ -945,24 +1180,32 @@ declare function useDocumentSafe(id: string | null | undefined): {
|
|
|
945
1180
|
readonly error: undefined;
|
|
946
1181
|
readonly data: undefined;
|
|
947
1182
|
readonly reload: undefined;
|
|
1183
|
+
readonly isRefetching: false;
|
|
1184
|
+
readonly refetchError: undefined;
|
|
948
1185
|
} | {
|
|
949
|
-
readonly reload: () => Promise<PHDocument$1>;
|
|
950
1186
|
readonly status: "pending";
|
|
951
1187
|
readonly isPending: true;
|
|
952
1188
|
readonly error: undefined;
|
|
953
1189
|
readonly data: undefined;
|
|
954
|
-
} | {
|
|
955
1190
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1191
|
+
readonly isRefetching: boolean;
|
|
1192
|
+
readonly refetchError: unknown;
|
|
1193
|
+
} | {
|
|
956
1194
|
readonly status: "success";
|
|
957
1195
|
readonly isPending: false;
|
|
958
1196
|
readonly error: undefined;
|
|
959
1197
|
readonly data: PHDocument$1;
|
|
960
|
-
} | {
|
|
961
1198
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1199
|
+
readonly isRefetching: boolean;
|
|
1200
|
+
readonly refetchError: unknown;
|
|
1201
|
+
} | {
|
|
962
1202
|
readonly status: "error";
|
|
963
1203
|
readonly isPending: false;
|
|
964
1204
|
readonly error: unknown;
|
|
965
1205
|
readonly data: undefined;
|
|
1206
|
+
readonly reload: () => Promise<PHDocument$1>;
|
|
1207
|
+
readonly isRefetching: boolean;
|
|
1208
|
+
readonly refetchError: unknown;
|
|
966
1209
|
};
|
|
967
1210
|
/**
|
|
968
1211
|
* Retrieves multiple documents from the reactor using React Suspense.
|
|
@@ -997,6 +1240,8 @@ declare function useGetDocuments(): (ids: string[]) => Promise<PHDocument$1[]>;
|
|
|
997
1240
|
* - isPending: Boolean indicating if the document is currently loading
|
|
998
1241
|
* - error: Any error that occurred during loading
|
|
999
1242
|
* - reload: Function to force reload the document from cache
|
|
1243
|
+
* - isRefetching: A loaded document is being refetched; `data` is the loaded one
|
|
1244
|
+
* - refetchError: The last refetch failure that kept the loaded document
|
|
1000
1245
|
*/
|
|
1001
1246
|
declare function useGetDocumentAsync(id: string | null | undefined): {
|
|
1002
1247
|
readonly status: "initial";
|
|
@@ -1004,24 +1249,32 @@ declare function useGetDocumentAsync(id: string | null | undefined): {
|
|
|
1004
1249
|
readonly isPending: false;
|
|
1005
1250
|
readonly error: undefined;
|
|
1006
1251
|
readonly reload: undefined;
|
|
1252
|
+
readonly isRefetching: false;
|
|
1253
|
+
readonly refetchError: undefined;
|
|
1007
1254
|
} | {
|
|
1008
|
-
readonly reload: () => Promise<PHDocument$1>;
|
|
1009
1255
|
readonly status: "pending";
|
|
1010
1256
|
readonly isPending: true;
|
|
1011
1257
|
readonly error: undefined;
|
|
1012
1258
|
readonly data: undefined;
|
|
1013
|
-
} | {
|
|
1014
1259
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1260
|
+
readonly isRefetching: boolean;
|
|
1261
|
+
readonly refetchError: unknown;
|
|
1262
|
+
} | {
|
|
1015
1263
|
readonly status: "success";
|
|
1016
1264
|
readonly isPending: false;
|
|
1017
1265
|
readonly error: undefined;
|
|
1018
1266
|
readonly data: PHDocument$1;
|
|
1019
|
-
} | {
|
|
1020
1267
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1268
|
+
readonly isRefetching: boolean;
|
|
1269
|
+
readonly refetchError: unknown;
|
|
1270
|
+
} | {
|
|
1021
1271
|
readonly status: "error";
|
|
1022
1272
|
readonly isPending: false;
|
|
1023
1273
|
readonly error: unknown;
|
|
1024
1274
|
readonly data: undefined;
|
|
1275
|
+
readonly reload: () => Promise<PHDocument$1>;
|
|
1276
|
+
readonly isRefetching: boolean;
|
|
1277
|
+
readonly refetchError: unknown;
|
|
1025
1278
|
};
|
|
1026
1279
|
//#endregion
|
|
1027
1280
|
//#region src/hooks/reactor.d.ts
|
|
@@ -1037,8 +1290,14 @@ declare const useReactorClient: UsePHGlobalValue<IReactorBrowserClient>;
|
|
|
1037
1290
|
declare const setReactorClient: SetPHGlobalValue<IReactorBrowserClient>;
|
|
1038
1291
|
/** Adds an event handler for the reactor client */
|
|
1039
1292
|
declare const addReactorClientEventHandler: AddPHGlobalEventHandler;
|
|
1293
|
+
/** Sets the client full-client actions use instead of the module's */
|
|
1294
|
+
declare const setFullReactorClient: SetPHGlobalValue<IReactorClient>;
|
|
1295
|
+
/** Adds an event handler for the full reactor client */
|
|
1296
|
+
declare const addFullReactorClientEventHandler: AddPHGlobalEventHandler;
|
|
1297
|
+
/** The client full-client actions use: the one set, else the module's. */
|
|
1298
|
+
declare function getFullReactorClient(): IReactorClient | undefined;
|
|
1040
1299
|
declare const useSync: () => ISyncManager | undefined;
|
|
1041
|
-
declare const useSyncList: () =>
|
|
1300
|
+
declare const useSyncList: () => import("@powerhousedao/reactor").Remote[];
|
|
1042
1301
|
declare const useModelRegistry: () => IDocumentModelRegistry | undefined;
|
|
1043
1302
|
declare const useDatabase: () => Kysely<Database> | undefined;
|
|
1044
1303
|
declare const usePGlite: () => PGlite | undefined;
|
|
@@ -1067,24 +1326,61 @@ declare function useDocumentModelModules(): DocumentModelModule[] | undefined;
|
|
|
1067
1326
|
declare function useDocumentModelModuleById(id: string | null | undefined, version?: number): DocumentModelModule | undefined;
|
|
1068
1327
|
//#endregion
|
|
1069
1328
|
//#region src/hooks/document-operations.d.ts
|
|
1070
|
-
type
|
|
1329
|
+
type UseDocumentOperationsOptions = {
|
|
1330
|
+
/**
|
|
1331
|
+
* Operations per page. Default 100. Applies to the next first-page load;
|
|
1332
|
+
* changing it while pages are already loaded has no effect until the next
|
|
1333
|
+
* invalidation or `refetch`.
|
|
1334
|
+
*/
|
|
1335
|
+
limit?: number;
|
|
1336
|
+
/** Whether to fetch at all. Default true. Pass false until the operations are needed. */
|
|
1337
|
+
enabled?: boolean;
|
|
1338
|
+
};
|
|
1339
|
+
/** What `useDocumentOperations` returns; exported so consumers can name it. */
|
|
1340
|
+
type DocumentOperationsResult = {
|
|
1341
|
+
/** Every operation of the scope loaded so far, oldest first. */
|
|
1342
|
+
operations: readonly Operation$1[];
|
|
1343
|
+
/** A page is in flight. */
|
|
1344
|
+
isLoading: boolean;
|
|
1345
|
+
/** The last page failed. Operations loaded before it stay available. */
|
|
1346
|
+
error: Error | undefined;
|
|
1347
|
+
/** The last page reported a further page. */
|
|
1348
|
+
hasNextPage: boolean;
|
|
1349
|
+
/** Loads the next page and appends it. No-op while loading or when there is none. */
|
|
1350
|
+
fetchNextPage: () => void;
|
|
1351
|
+
/** Drops the document's cached operations and reloads from the first page. */
|
|
1352
|
+
refetch: () => void;
|
|
1353
|
+
};
|
|
1354
|
+
/**
|
|
1355
|
+
* Legacy result of `useDocumentOperations(documentId)`.
|
|
1356
|
+
* @deprecated Call `useDocumentOperations(documentId, scope, options)` and read `operations`. Removed in the next major.
|
|
1357
|
+
*/
|
|
1358
|
+
type DocumentOperationsState = {
|
|
1071
1359
|
globalOperations: Operation$1[];
|
|
1072
1360
|
localOperations: Operation$1[];
|
|
1073
1361
|
isLoading: boolean;
|
|
1074
1362
|
error: Error | undefined;
|
|
1075
|
-
};
|
|
1076
|
-
/** What `useDocumentOperations` returns; exported so consumers can name it. */
|
|
1077
|
-
type DocumentOperationsState = InternalState & {
|
|
1078
1363
|
refetch: () => void;
|
|
1079
1364
|
};
|
|
1365
|
+
/** @deprecated Pass a scope: `useDocumentOperations(documentId, "global")`. The legacy form fetches the whole global and local history eagerly. Removed in the next major. */
|
|
1366
|
+
declare function useDocumentOperations(documentId: string | null | undefined): DocumentOperationsState;
|
|
1080
1367
|
/**
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1368
|
+
* Operation history of a document, read from the document cache and kept in
|
|
1369
|
+
* step with it: a change event for the document drops the cached pages and
|
|
1370
|
+
* the hook loads the first page again.
|
|
1371
|
+
*
|
|
1372
|
+
* Pages arrive oldest first. A view that wants the whole history calls
|
|
1373
|
+
* `fetchNextPage` while `hasNextPage` is true.
|
|
1083
1374
|
*
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1375
|
+
* An empty first page is a final result; there is no retry. When the active
|
|
1376
|
+
* document cache does not serve operations, the result is empty and not
|
|
1377
|
+
* loading.
|
|
1378
|
+
*
|
|
1379
|
+
* @param documentId - The document id, or null/undefined to skip fetching
|
|
1380
|
+
* @param scope - The operation scope, for example "global" or "local"
|
|
1381
|
+
* @param options - Page size and whether fetching is enabled
|
|
1086
1382
|
*/
|
|
1087
|
-
declare function useDocumentOperations(documentId: string | null | undefined):
|
|
1383
|
+
declare function useDocumentOperations(documentId: string | null | undefined, scope: string, options?: UseDocumentOperationsOptions): DocumentOperationsResult;
|
|
1088
1384
|
//#endregion
|
|
1089
1385
|
//#region src/hooks/attachment-service.d.ts
|
|
1090
1386
|
/** Returns the attachment service from window.ph */
|
|
@@ -1094,5 +1390,6 @@ declare const setAttachmentService: SetPHGlobalValue<IAttachmentService>;
|
|
|
1094
1390
|
/** Registers the attachmentService window event handler */
|
|
1095
1391
|
declare const addAttachmentServiceEventHandler: AddPHGlobalEventHandler;
|
|
1096
1392
|
//#endregion
|
|
1097
|
-
export {
|
|
1098
|
-
|
|
1393
|
+
export { GraphQLReactorProvider as $, useDocumentCache as A, DocumentChangeListener as At, makeAuthConnectionParams as B, RemoteDocumentChangeEvent as Bt, useReactorClient as C, RevisionsListSelection as Ct, addDocumentCacheEventHandler as D, revisionMapFromRevisionsList as Dt, useSyncList as E, phDocumentFromMutation as Et, useGetDocuments as F, IRemoteController as Ft, resolveDocumentModelModule as G, TrackedAction as Gt, subscriptionsUrlFromGraphqlUrl as H, RemoteOperation as Ht, ConnectionParams as I, MergeHandler as It, stampAction as J, addPromiseState as Jt, prepareSignedActions as K, DocumentCache as Kt, DocumentChangesEventPayload as L, PushResult as Lt, useDocuments as M, GetDocumentWithOperationsResult as Mt, useGetDocument as N, GetOperationsResult as Nt, setDocumentCache as O, ConflictInfo as Ot, useGetDocumentAsync as P, IRemoteClient as Pt, ReactorOperationFieldsFragmentDoc as Q, DocumentChangesSubscriptionOptions as R, RemoteControllerGraphQLClient as Rt, usePGlite as S, GetDocumentQueryResult as St, useSync as T, phDocumentFromGetDocument as Tt, StaticPackageManager as U, RemoteOperationResultPage as Ut, startDocumentChangesSubscription as V, RemoteDocumentData as Vt, packageFromDocumentModels as W, SyncStatus$1 as Wt, MutateDocumentWithOperationsResult as X, readPromiseState as Xt, MutateDocumentWithOperationsDocument as Y, isOperationCache as Yt, MutateDocumentWithOperationsVariables as Z, IDLE_REFETCH_STATE as Zt, setFullReactorClient as _, GraphQLWrongBackendError as _t, DocumentOperationsState as a, GraphQLReactorClientOptions as at, useDatabase as b, makeAuthMiddleware as bt, useDocumentModelModuleById as c, viewFilterInputFromViewFilter as ct, UseDispatchResult as d, SubgraphSdkRegistry as dt, GraphQLReactorProviderProps as et, useDispatch as f, TypedGraphQLDocument as ft, getFullReactorClient as g, GraphQLOperationNotSupportedError as gt, addReactorClientModuleEventHandler as h, BatchJobFailedError as ht, DocumentOperationsResult as i, GraphQLReactorClient as it, useDocumentSafe as j, GetDocumentResult as jt, useDocument as k, ConflictStrategy as kt, useDocumentModelModules as l, GraphQLRequestOptions as lt, addReactorClientEventHandler as m, subgraphUrlFromGraphqlUrl as mt, setAttachmentService as n, useSwitchboardClient as nt, UseDocumentOperationsOptions as o, findIsServableOverGraphQL as ot, addFullReactorClientEventHandler as p, describeGraphQLDocument as pt, signStampedAction as q, IDLE_OPERATIONS_ENTRY as qt, useAttachmentService as r, DriveIdCall as rt, useDocumentOperations as s, isGraphQLReactorClient as st, addAttachmentServiceEventHandler as t, ensurePHEventHandlers as tt, DispatchFn as u, SubgraphSdkFactory as ut, setReactorClient as v, BearerTokenProvider as vt, useReactorClientModule as w, isoStringFromDateTime as wt, useModelRegistry as x, GetDocumentQueryFields as xt, setReactorClientModule as y, ambientRenownTokenProvider as yt, isAuthRefusalClose as z, RemoteControllerOptions as zt };
|
|
1394
|
+
export {};
|
|
1395
|
+
//# sourceMappingURL=attachment-service-DG6UkyMv.d.ts.map
|