@powerhousedao/reactor-browser 6.2.3-dev.3 → 6.2.3-dev.31
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-CdwHrbDH.d.ts → attachment-service-CF8LWxyM.d.ts} +209 -64
- package/dist/attachment-service-CF8LWxyM.d.ts.map +1 -0
- package/dist/{client-DjK30EQ-.js → client-BiJAJ9dW.js} +1 -1
- package/dist/{client-DjK30EQ-.js.map → client-BiJAJ9dW.js.map} +1 -1
- package/dist/{client-BIHN_UyR.d.ts → client-CngU4mtn.d.ts} +3 -3
- package/dist/client-CngU4mtn.d.ts.map +1 -0
- package/dist/{client-D66jVnot.js → client-VV9M73s_.js} +126 -18
- package/dist/client-VV9M73s_.js.map +1 -0
- package/dist/{document-by-id-BSZqTN66.js → dispatch-BOQgTK9B.js} +375 -51
- package/dist/dispatch-BOQgTK9B.js.map +1 -0
- package/dist/document-by-id-Kuxk62l1.js +16 -0
- package/dist/document-by-id-Kuxk62l1.js.map +1 -0
- package/dist/{document-model-modules-DfQBNGc-.js → document-model-modules-Cv9KSduJ.js} +64 -97
- package/dist/document-model-modules-Cv9KSduJ.js.map +1 -0
- package/dist/{document-operations-Bgo6A6W2.js → document-operations-D16LsXDs.js} +202 -124
- package/dist/document-operations-D16LsXDs.js.map +1 -0
- package/dist/{global-BggszP4X.d.ts → global-yMvtFjK6.d.ts} +51 -14
- package/dist/global-yMvtFjK6.d.ts.map +1 -0
- package/dist/{index-CkJNhsQo.d.ts → index-UsPtg1Z3.d.ts} +21 -99
- package/dist/index-UsPtg1Z3.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 +413 -362
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +138 -43
- package/dist/index.js.map +1 -1
- package/dist/{inspector-proxy-6h5VKAwt.d.ts → inspector-proxy-B2qjCMEv.d.ts} +9 -4
- package/dist/inspector-proxy-B2qjCMEv.d.ts.map +1 -0
- package/dist/{make-ph-event-functions-DBq3iWYn.js → make-ph-event-functions-FzpvQtj6.js} +1 -1
- package/dist/{make-ph-event-functions-DBq3iWYn.js.map → make-ph-event-functions-FzpvQtj6.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-D4sxGPz7.js → relational-ChC_AWAK.js} +4 -3
- package/dist/{relational-D4sxGPz7.js.map → relational-ChC_AWAK.js.map} +1 -1
- package/dist/{renown-BIEv6bSI.js → renown-C9pYZRqf.js} +26 -12
- package/dist/renown-C9pYZRqf.js.map +1 -0
- package/dist/{renown-BHxwP7xU.js → renown-Def5iO8k.js} +2 -2
- package/dist/{renown-BHxwP7xU.js.map → renown-Def5iO8k.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 +8 -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 +3 -3
- package/dist/src/rpc/index.d.ts +40 -31
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +20 -5
- 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-D4-_jwk-.js → switchboard-Nyr7CXcr.js} +59 -7
- package/dist/switchboard-Nyr7CXcr.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-B7-_l_wE.d.ts} +86 -16
- package/dist/types-B7-_l_wE.d.ts.map +1 -0
- package/package.json +15 -16
- package/dist/attachment-service-CdwHrbDH.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/document-by-id-BSZqTN66.js.map +0 -1
- package/dist/document-model-modules-DfQBNGc-.js.map +0 -1
- package/dist/document-operations-Bgo6A6W2.js.map +0 -1
- package/dist/global-BggszP4X.d.ts.map +0 -1
- package/dist/index-BIVDXw3K.d.ts.map +0 -1
- package/dist/index-CkJNhsQo.d.ts.map +0 -1
- package/dist/inspector-proxy-6h5VKAwt.d.ts.map +0 -1
- package/dist/pglite-CntadC_p-9NDG14dS.d.ts.map +0 -1
- package/dist/renown-BIEv6bSI.js.map +0 -1
- package/dist/switchboard-D4-_jwk-.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-yMvtFjK6.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-B7-_l_wE.js";
|
|
4
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 { ReactNode } from "react";
|
|
7
|
-
import * as _powerhousedao_reactor0 from "@powerhousedao/reactor";
|
|
8
5
|
import { Database, DocumentChangeEvent, DocumentModelSource, IDocumentModelRegistry, ISyncManager, 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 } from "@powerhousedao/shared/document-model";
|
|
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). */
|
|
@@ -304,7 +360,8 @@ declare class SubgraphSdkRegistry {
|
|
|
304
360
|
//#endregion
|
|
305
361
|
//#region src/graphql-client/graphql-reactor-client.d.ts
|
|
306
362
|
type GraphQLReactorClientOptions = {
|
|
307
|
-
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
363
|
+
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
364
|
+
url: string;
|
|
308
365
|
/**
|
|
309
366
|
* A pre-built SDK to use instead of the transport derived from `url`.
|
|
310
367
|
* Mainly a test seam.
|
|
@@ -392,6 +449,8 @@ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
|
|
|
392
449
|
private realtimeStarted;
|
|
393
450
|
private realtimeGeneration;
|
|
394
451
|
private realtimeErrorLogged;
|
|
452
|
+
/** Whether the last socket died because the Switchboard refused its credentials. */
|
|
453
|
+
private realtimeRefusedCredentials;
|
|
395
454
|
constructor(options: GraphQLReactorClientOptions);
|
|
396
455
|
get<TDocument extends PHDocument>(identifier: string, view?: ViewFilter, signal?: AbortSignal): Promise<TDocument>;
|
|
397
456
|
getOperations(documentIdentifier: string, view?: ViewFilter, filter?: OperationFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
|
|
@@ -500,15 +559,39 @@ declare class GraphQLReactorClient implements IReactorBrowserClient$1 {
|
|
|
500
559
|
* Gives up on a failed socket so that a later subscriber can try again.
|
|
501
560
|
*
|
|
502
561
|
* `graphql-ws` retries on its own and only reports here once it has given up,
|
|
503
|
-
* or once the
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
562
|
+
* or once the Switchboard refused the credentials the socket carried - which
|
|
563
|
+
* `shouldRetry` declines to retry at all. Keeping the dead stop function
|
|
564
|
+
* would make every later `subscribe` a no-op, so realtime would stay off for
|
|
565
|
+
* the life of the page even after the user signs in.
|
|
566
|
+
*
|
|
567
|
+
* Why it died is recorded: a refusal is undone by a credential change and
|
|
568
|
+
* nothing else, and {@link notifyCredentialsChanged} acts only on that.
|
|
507
569
|
*
|
|
508
570
|
* The generation stamp discards a report from a socket that has already been
|
|
509
571
|
* replaced or disposed.
|
|
510
572
|
*/
|
|
511
573
|
private handleRealtimeFailure;
|
|
574
|
+
/**
|
|
575
|
+
* Reopens realtime after a sign-in, a sign-out or a token swap.
|
|
576
|
+
*
|
|
577
|
+
* Call it whenever the credentials this client authenticates with change.
|
|
578
|
+
*
|
|
579
|
+
* A live socket is replaced. `connectionParams` are resolved once, when the
|
|
580
|
+
* socket opens, so a socket keeps presenting the credentials it was opened
|
|
581
|
+
* with until something closes it - and a sign-out closes nothing. That left
|
|
582
|
+
* a signed-out tab still receiving the previous identity's document changes,
|
|
583
|
+
* on a shared machine, for as long as the socket happened to survive.
|
|
584
|
+
*
|
|
585
|
+
* A refused socket is reopened, for the same reason from the other side:
|
|
586
|
+
* otherwise it stays closed until an unrelated component happens to
|
|
587
|
+
* `subscribe`, so signing in leaves realtime off with nothing said - the
|
|
588
|
+
* state `handleRealtimeFailure` resets to avoid.
|
|
589
|
+
*
|
|
590
|
+
* A socket that died for any other reason is left alone: a network failure
|
|
591
|
+
* is not something a new token fixes, and reopening one here would turn a
|
|
592
|
+
* credential change into a reconnect loop.
|
|
593
|
+
*/
|
|
594
|
+
notifyCredentialsChanged(): void;
|
|
512
595
|
/** Closes the socket and lets a later subscriber open a new one. */
|
|
513
596
|
private teardownRealtime;
|
|
514
597
|
/** Maps a server event onto the client-side event and emits it. */
|
|
@@ -563,7 +646,8 @@ declare global {
|
|
|
563
646
|
*/
|
|
564
647
|
declare function ensurePHEventHandlers(): void;
|
|
565
648
|
type GraphQLReactorProviderProps = {
|
|
566
|
-
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
649
|
+
/** The Switchboard GraphQL endpoint, e.g. `http://localhost:4001/graphql`. */
|
|
650
|
+
url: string;
|
|
567
651
|
/**
|
|
568
652
|
* Resolves the bearer token sent with every request, per request. Defaults to
|
|
569
653
|
* the token of the logged-in Renown user, or none when nobody is logged in.
|
|
@@ -649,15 +733,7 @@ type GraphQLReactorProviderProps = {
|
|
|
649
733
|
* effect rebuilds both if it runs again on the same client - which is what a
|
|
650
734
|
* `StrictMode` mount does.
|
|
651
735
|
*/
|
|
652
|
-
declare function GraphQLReactorProvider({
|
|
653
|
-
url,
|
|
654
|
-
tokenProvider,
|
|
655
|
-
subscriptionsUrl,
|
|
656
|
-
realtime,
|
|
657
|
-
attachmentService,
|
|
658
|
-
documentModels,
|
|
659
|
-
children
|
|
660
|
-
}: GraphQLReactorProviderProps): react_jsx_runtime0.JSX.Element;
|
|
736
|
+
declare function GraphQLReactorProvider({ url, tokenProvider, subscriptionsUrl, realtime, attachmentService, documentModels, children }: GraphQLReactorProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
661
737
|
/**
|
|
662
738
|
* Returns the {@link GraphQLReactorClient} mounted by
|
|
663
739
|
* {@link GraphQLReactorProvider}, or `undefined` when the slot holds something
|
|
@@ -679,7 +755,7 @@ declare function useSwitchboardClient(): GraphQLReactorClient | undefined;
|
|
|
679
755
|
* The operation selection of `GetDocumentOperations`, lifted into a fragment so
|
|
680
756
|
* the write path can reuse `remoteOperationToLocal` on the items it selects.
|
|
681
757
|
*/
|
|
682
|
-
declare const ReactorOperationFieldsFragmentDoc: graphql.DocumentNode;
|
|
758
|
+
declare const ReactorOperationFieldsFragmentDoc: import("graphql").DocumentNode;
|
|
683
759
|
/**
|
|
684
760
|
* `mutateDocument` plus the operations the mutation produced.
|
|
685
761
|
*
|
|
@@ -701,7 +777,7 @@ declare const ReactorOperationFieldsFragmentDoc: graphql.DocumentNode;
|
|
|
701
777
|
* by hand or the operations came from `main` while the actions were applied
|
|
702
778
|
* elsewhere. One variable cannot disagree with itself.
|
|
703
779
|
*/
|
|
704
|
-
declare const MutateDocumentWithOperationsDocument: graphql.DocumentNode;
|
|
780
|
+
declare const MutateDocumentWithOperationsDocument: import("graphql").DocumentNode;
|
|
705
781
|
type MutateDocumentWithOperationsVariables = {
|
|
706
782
|
documentIdentifier: Scalars["String"]["input"];
|
|
707
783
|
actions: ReadonlyArray<ActionInput>;
|
|
@@ -735,12 +811,12 @@ type MutateDocumentWithOperationsResult = {
|
|
|
735
811
|
*/
|
|
736
812
|
declare function stampAction(action: Action$1, document: PHDocument$1, revision?: number): Action$1;
|
|
737
813
|
/**
|
|
738
|
-
* Signs a stamped action
|
|
739
|
-
*
|
|
740
|
-
*
|
|
741
|
-
*
|
|
814
|
+
* Signs a stamped action for `target`, keeping any signatures it already
|
|
815
|
+
* carries. The signer reads `context.prevOpHash`, so this runs after
|
|
816
|
+
* {@link stampAction}. A v2 tuple covers the signer's identity, so the context
|
|
817
|
+
* takes the signer's user and app even when the action named others.
|
|
742
818
|
*/
|
|
743
|
-
declare function signStampedAction(action: Action$1, signer: ISigner, signal?: AbortSignal): Promise<Action$1>;
|
|
819
|
+
declare function signStampedAction(action: Action$1, signer: ISigner, target: ActionSigningTarget, signal?: AbortSignal): Promise<Action$1>;
|
|
744
820
|
/**
|
|
745
821
|
* Stamps and signs a batch of actions against one document snapshot, so every
|
|
746
822
|
* action carries the head its predecessor will leave behind.
|
|
@@ -830,13 +906,15 @@ type DocumentChangesEventPayload = DocumentChangesSubscription["documentChanges"
|
|
|
830
906
|
/** The connection payload sent with the `ConnectionInit` message. */
|
|
831
907
|
type ConnectionParams = Record<string, string>;
|
|
832
908
|
type DocumentChangesSubscriptionOptions = {
|
|
833
|
-
/** The websocket endpoint, e.g. `ws://localhost:4001/graphql/subscriptions`. */
|
|
909
|
+
/** The websocket endpoint, e.g. `ws://localhost:4001/graphql/subscriptions`. */
|
|
910
|
+
wsUrl: string;
|
|
834
911
|
/**
|
|
835
912
|
* Resolves the `ConnectionInit` payload. Called again on every reconnect, so
|
|
836
913
|
* a token that expired while the socket was down is refreshed on the way back
|
|
837
914
|
* up.
|
|
838
915
|
*/
|
|
839
|
-
connectionParams?: () => Promise<ConnectionParams>;
|
|
916
|
+
connectionParams?: () => Promise<ConnectionParams>;
|
|
917
|
+
/** Called once per server event. */
|
|
840
918
|
onEvent: (event: DocumentChangesEventPayload) => void;
|
|
841
919
|
/**
|
|
842
920
|
* Called when the socket gives up: the retries built into `graphql-ws` are
|
|
@@ -845,6 +923,15 @@ type DocumentChangesSubscriptionOptions = {
|
|
|
845
923
|
*/
|
|
846
924
|
onError: (error: unknown) => void;
|
|
847
925
|
};
|
|
926
|
+
/**
|
|
927
|
+
* Whether a socket failure is the Switchboard refusing the credentials sent.
|
|
928
|
+
*
|
|
929
|
+
* Keyed on the close reason, not the code: both refusals close 4403, because
|
|
930
|
+
* `connectionParams` is resolved per connect and a reconnect carrying a fresh
|
|
931
|
+
* token genuinely succeeds. What the reason adds is that *this* attempt cannot
|
|
932
|
+
* be fixed by repeating it.
|
|
933
|
+
*/
|
|
934
|
+
declare function isAuthRefusalClose(error: unknown): boolean;
|
|
848
935
|
/**
|
|
849
936
|
* Opens one `documentChanges` subscription and feeds every event to `onEvent`.
|
|
850
937
|
*
|
|
@@ -903,6 +990,8 @@ declare function useDocument(id: string | null | undefined): PHDocument$1 | unde
|
|
|
903
990
|
* - isPending: Whether the document is currently loading
|
|
904
991
|
* - error: Any error that occurred during loading (e.g., document not found)
|
|
905
992
|
* - reload: Function to force a refetch, or undefined when no id is supplied
|
|
993
|
+
* - isRefetching: A loaded document is being refetched; `data` is the loaded one
|
|
994
|
+
* - refetchError: The last refetch failure that kept the loaded document
|
|
906
995
|
*/
|
|
907
996
|
declare function useDocumentSafe(id: string | null | undefined): {
|
|
908
997
|
readonly status: "initial";
|
|
@@ -910,24 +999,32 @@ declare function useDocumentSafe(id: string | null | undefined): {
|
|
|
910
999
|
readonly error: undefined;
|
|
911
1000
|
readonly data: undefined;
|
|
912
1001
|
readonly reload: undefined;
|
|
1002
|
+
readonly isRefetching: false;
|
|
1003
|
+
readonly refetchError: undefined;
|
|
913
1004
|
} | {
|
|
914
|
-
readonly reload: () => Promise<PHDocument$1>;
|
|
915
1005
|
readonly status: "pending";
|
|
916
1006
|
readonly isPending: true;
|
|
917
1007
|
readonly error: undefined;
|
|
918
1008
|
readonly data: undefined;
|
|
919
|
-
} | {
|
|
920
1009
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1010
|
+
readonly isRefetching: boolean;
|
|
1011
|
+
readonly refetchError: unknown;
|
|
1012
|
+
} | {
|
|
921
1013
|
readonly status: "success";
|
|
922
1014
|
readonly isPending: false;
|
|
923
1015
|
readonly error: undefined;
|
|
924
1016
|
readonly data: PHDocument$1;
|
|
925
|
-
} | {
|
|
926
1017
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1018
|
+
readonly isRefetching: boolean;
|
|
1019
|
+
readonly refetchError: unknown;
|
|
1020
|
+
} | {
|
|
927
1021
|
readonly status: "error";
|
|
928
1022
|
readonly isPending: false;
|
|
929
1023
|
readonly error: unknown;
|
|
930
1024
|
readonly data: undefined;
|
|
1025
|
+
readonly reload: () => Promise<PHDocument$1>;
|
|
1026
|
+
readonly isRefetching: boolean;
|
|
1027
|
+
readonly refetchError: unknown;
|
|
931
1028
|
};
|
|
932
1029
|
/**
|
|
933
1030
|
* Retrieves multiple documents from the reactor using React Suspense.
|
|
@@ -962,6 +1059,8 @@ declare function useGetDocuments(): (ids: string[]) => Promise<PHDocument$1[]>;
|
|
|
962
1059
|
* - isPending: Boolean indicating if the document is currently loading
|
|
963
1060
|
* - error: Any error that occurred during loading
|
|
964
1061
|
* - reload: Function to force reload the document from cache
|
|
1062
|
+
* - isRefetching: A loaded document is being refetched; `data` is the loaded one
|
|
1063
|
+
* - refetchError: The last refetch failure that kept the loaded document
|
|
965
1064
|
*/
|
|
966
1065
|
declare function useGetDocumentAsync(id: string | null | undefined): {
|
|
967
1066
|
readonly status: "initial";
|
|
@@ -969,24 +1068,32 @@ declare function useGetDocumentAsync(id: string | null | undefined): {
|
|
|
969
1068
|
readonly isPending: false;
|
|
970
1069
|
readonly error: undefined;
|
|
971
1070
|
readonly reload: undefined;
|
|
1071
|
+
readonly isRefetching: false;
|
|
1072
|
+
readonly refetchError: undefined;
|
|
972
1073
|
} | {
|
|
973
|
-
readonly reload: () => Promise<PHDocument$1>;
|
|
974
1074
|
readonly status: "pending";
|
|
975
1075
|
readonly isPending: true;
|
|
976
1076
|
readonly error: undefined;
|
|
977
1077
|
readonly data: undefined;
|
|
978
|
-
} | {
|
|
979
1078
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1079
|
+
readonly isRefetching: boolean;
|
|
1080
|
+
readonly refetchError: unknown;
|
|
1081
|
+
} | {
|
|
980
1082
|
readonly status: "success";
|
|
981
1083
|
readonly isPending: false;
|
|
982
1084
|
readonly error: undefined;
|
|
983
1085
|
readonly data: PHDocument$1;
|
|
984
|
-
} | {
|
|
985
1086
|
readonly reload: () => Promise<PHDocument$1>;
|
|
1087
|
+
readonly isRefetching: boolean;
|
|
1088
|
+
readonly refetchError: unknown;
|
|
1089
|
+
} | {
|
|
986
1090
|
readonly status: "error";
|
|
987
1091
|
readonly isPending: false;
|
|
988
1092
|
readonly error: unknown;
|
|
989
1093
|
readonly data: undefined;
|
|
1094
|
+
readonly reload: () => Promise<PHDocument$1>;
|
|
1095
|
+
readonly isRefetching: boolean;
|
|
1096
|
+
readonly refetchError: unknown;
|
|
990
1097
|
};
|
|
991
1098
|
//#endregion
|
|
992
1099
|
//#region src/hooks/reactor.d.ts
|
|
@@ -1003,7 +1110,7 @@ declare const setReactorClient: SetPHGlobalValue<IReactorBrowserClient>;
|
|
|
1003
1110
|
/** Adds an event handler for the reactor client */
|
|
1004
1111
|
declare const addReactorClientEventHandler: AddPHGlobalEventHandler;
|
|
1005
1112
|
declare const useSync: () => ISyncManager | undefined;
|
|
1006
|
-
declare const useSyncList: () =>
|
|
1113
|
+
declare const useSyncList: () => import("@powerhousedao/reactor").Remote[];
|
|
1007
1114
|
declare const useModelRegistry: () => IDocumentModelRegistry | undefined;
|
|
1008
1115
|
declare const useDatabase: () => Kysely<Database> | undefined;
|
|
1009
1116
|
declare const usePGlite: () => PGlite | undefined;
|
|
@@ -1032,24 +1139,61 @@ declare function useDocumentModelModules(): DocumentModelModule[] | undefined;
|
|
|
1032
1139
|
declare function useDocumentModelModuleById(id: string | null | undefined, version?: number): DocumentModelModule | undefined;
|
|
1033
1140
|
//#endregion
|
|
1034
1141
|
//#region src/hooks/document-operations.d.ts
|
|
1035
|
-
type
|
|
1142
|
+
type UseDocumentOperationsOptions = {
|
|
1143
|
+
/**
|
|
1144
|
+
* Operations per page. Default 100. Applies to the next first-page load;
|
|
1145
|
+
* changing it while pages are already loaded has no effect until the next
|
|
1146
|
+
* invalidation or `refetch`.
|
|
1147
|
+
*/
|
|
1148
|
+
limit?: number;
|
|
1149
|
+
/** Whether to fetch at all. Default true. Pass false until the operations are needed. */
|
|
1150
|
+
enabled?: boolean;
|
|
1151
|
+
};
|
|
1152
|
+
/** What `useDocumentOperations` returns; exported so consumers can name it. */
|
|
1153
|
+
type DocumentOperationsResult = {
|
|
1154
|
+
/** Every operation of the scope loaded so far, oldest first. */
|
|
1155
|
+
operations: readonly Operation$1[];
|
|
1156
|
+
/** A page is in flight. */
|
|
1157
|
+
isLoading: boolean;
|
|
1158
|
+
/** The last page failed. Operations loaded before it stay available. */
|
|
1159
|
+
error: Error | undefined;
|
|
1160
|
+
/** The last page reported a further page. */
|
|
1161
|
+
hasNextPage: boolean;
|
|
1162
|
+
/** Loads the next page and appends it. No-op while loading or when there is none. */
|
|
1163
|
+
fetchNextPage: () => void;
|
|
1164
|
+
/** Drops the document's cached operations and reloads from the first page. */
|
|
1165
|
+
refetch: () => void;
|
|
1166
|
+
};
|
|
1167
|
+
/**
|
|
1168
|
+
* Legacy result of `useDocumentOperations(documentId)`.
|
|
1169
|
+
* @deprecated Call `useDocumentOperations(documentId, scope, options)` and read `operations`. Removed in the next major.
|
|
1170
|
+
*/
|
|
1171
|
+
type DocumentOperationsState = {
|
|
1036
1172
|
globalOperations: Operation$1[];
|
|
1037
1173
|
localOperations: Operation$1[];
|
|
1038
1174
|
isLoading: boolean;
|
|
1039
1175
|
error: Error | undefined;
|
|
1040
|
-
};
|
|
1041
|
-
/** What `useDocumentOperations` returns; exported so consumers can name it. */
|
|
1042
|
-
type DocumentOperationsState = InternalState & {
|
|
1043
1176
|
refetch: () => void;
|
|
1044
1177
|
};
|
|
1178
|
+
/** @deprecated Pass a scope: `useDocumentOperations(documentId, "global")`. The legacy form fetches the whole global and local history eagerly. Removed in the next major. */
|
|
1179
|
+
declare function useDocumentOperations(documentId: string | null | undefined): DocumentOperationsState;
|
|
1045
1180
|
/**
|
|
1046
|
-
*
|
|
1047
|
-
*
|
|
1181
|
+
* Operation history of a document, read from the document cache and kept in
|
|
1182
|
+
* step with it: a change event for the document drops the cached pages and
|
|
1183
|
+
* the hook loads the first page again.
|
|
1184
|
+
*
|
|
1185
|
+
* Pages arrive oldest first. A view that wants the whole history calls
|
|
1186
|
+
* `fetchNextPage` while `hasNextPage` is true.
|
|
1048
1187
|
*
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1188
|
+
* An empty first page is a final result; there is no retry. When the active
|
|
1189
|
+
* document cache does not serve operations, the result is empty and not
|
|
1190
|
+
* loading.
|
|
1191
|
+
*
|
|
1192
|
+
* @param documentId - The document id, or null/undefined to skip fetching
|
|
1193
|
+
* @param scope - The operation scope, for example "global" or "local"
|
|
1194
|
+
* @param options - Page size and whether fetching is enabled
|
|
1051
1195
|
*/
|
|
1052
|
-
declare function useDocumentOperations(documentId: string | null | undefined):
|
|
1196
|
+
declare function useDocumentOperations(documentId: string | null | undefined, scope: string, options?: UseDocumentOperationsOptions): DocumentOperationsResult;
|
|
1053
1197
|
//#endregion
|
|
1054
1198
|
//#region src/hooks/attachment-service.d.ts
|
|
1055
1199
|
/** Returns the attachment service from window.ph */
|
|
@@ -1059,5 +1203,6 @@ declare const setAttachmentService: SetPHGlobalValue<IAttachmentService>;
|
|
|
1059
1203
|
/** Registers the attachmentService window event handler */
|
|
1060
1204
|
declare const addAttachmentServiceEventHandler: AddPHGlobalEventHandler;
|
|
1061
1205
|
//#endregion
|
|
1062
|
-
export {
|
|
1063
|
-
|
|
1206
|
+
export { useSwitchboardClient as $, useGetDocument as A, RemoteControllerOptions as At, StaticPackageManager as B, isOperationCache as Bt, useSyncList as C, GetDocumentWithOperationsResult as Ct, useDocumentCache as D, MergeHandler as Dt, useDocument as E, IRemoteController as Et, DocumentChangesSubscriptionOptions as F, SyncStatus$1 as Ft, stampAction as G, resolveDocumentModelModule as H, IDLE_REFETCH_STATE as Ht, isAuthRefusalClose as I, TrackedAction as It, MutateDocumentWithOperationsVariables as J, MutateDocumentWithOperationsDocument as K, makeAuthConnectionParams as L, DocumentCache as Lt, useGetDocuments as M, RemoteDocumentData as Mt, ConnectionParams as N, RemoteOperation as Nt, useDocumentSafe as O, PushResult as Ot, DocumentChangesEventPayload as P, RemoteOperationResultPage as Pt, ensurePHEventHandlers as Q, startDocumentChangesSubscription as R, IDLE_OPERATIONS_ENTRY as Rt, useSync as S, GetDocumentResult as St, setDocumentCache as T, IRemoteClient as Tt, prepareSignedActions as U, packageFromDocumentModels as V, readPromiseState as Vt, signStampedAction as W, GraphQLReactorProvider as X, ReactorOperationFieldsFragmentDoc as Y, GraphQLReactorProviderProps as Z, useDatabase as _, phDocumentFromMutation as _t, DocumentOperationsState as a, SubgraphSdkFactory as at, useReactorClient as b, ConflictStrategy as bt, useDocumentModelModuleById as c, describeGraphQLDocument as ct, UseDispatchResult as d, ambientRenownTokenProvider as dt, GraphQLReactorClient as et, useDispatch as f, makeAuthMiddleware as ft, setReactorClientModule as g, phDocumentFromGetDocument as gt, setReactorClient as h, RevisionsListSelection as ht, DocumentOperationsResult as i, GraphQLRequestOptions as it, useGetDocumentAsync as j, RemoteDocumentChangeEvent as jt, useDocuments as k, RemoteControllerGraphQLClient as kt, useDocumentModelModules as l, subgraphUrlFromGraphqlUrl as lt, addReactorClientModuleEventHandler as m, GetDocumentQueryResult as mt, setAttachmentService as n, isGraphQLReactorClient as nt, UseDocumentOperationsOptions as o, SubgraphSdkRegistry as ot, addReactorClientEventHandler as p, GetDocumentQueryFields as pt, MutateDocumentWithOperationsResult as q, useAttachmentService as r, viewFilterInputFromViewFilter as rt, useDocumentOperations as s, TypedGraphQLDocument as st, addAttachmentServiceEventHandler as t, GraphQLReactorClientOptions as tt, DispatchFn as u, BearerTokenProvider as ut, useModelRegistry as v, revisionMapFromRevisionsList as vt, addDocumentCacheEventHandler as w, GetOperationsResult as wt, useReactorClientModule as x, DocumentChangeListener as xt, usePGlite as y, ConflictInfo as yt, subscriptionsUrlFromGraphqlUrl as z, addPromiseState as zt };
|
|
1207
|
+
export {};
|
|
1208
|
+
//# sourceMappingURL=attachment-service-CF8LWxyM.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-service-CF8LWxyM.d.ts","names":[],"sources":["../src/document-refetcher.ts","../src/document-cache.ts","../src/remote-controller/types.ts","../src/graphql-client/adapter.ts","../src/graphql-client/auth.ts","../src/graphql-client/subgraph.ts","../src/graphql-client/graphql-reactor-client.ts","../src/graphql-client/graphql-reactor-provider.tsx","../src/graphql-client/operations.ts","../src/graphql-client/signing.ts","../src/graphql-client/static-package-manager.ts","../src/graphql-client/subscriptions.ts","../src/hooks/document-cache.ts","../src/hooks/reactor.ts","../src/hooks/dispatch.ts","../src/hooks/document-model-modules.ts","../src/hooks/document-operations.ts","../src/hooks/attachment-service.ts"],"mappings":";;;;;;;;;;;;;;;cASa,oBAAoB;;;iBCUjB,gBAAgB,GAAG,SAAS,QAAQ,KAAK,iBAAiB;iBAwB1D,iBAAiB,GAC/B,SAAS,QAAQ,KAAK,iBAAiB,KACtC,aAAa;;cA4BH,uBAAuB;;iBAQpB,iBAAiB,iBAAiB,SAAS;;;;;;;;;cAiD9C,yBAAyB,gBAAgB;UAuChC;UAtCZ;UACA;UAIA;UAEA;;;;;;;;UAkBA;;UAGA;;UAKA;UACA;UAEA;EAER,YAAoB,QAAQ;UAMpB;UAuBA;UAeM;UAON;;UAOA;;UAKA;UAMA;EAQR,IAAI,YAAY,oBAAoB,QAAQ;EA0B5C,gBAAgB,aAAa;EAI7B,SAAS,gBAAgB,QAAQ;EA8DjC,UAAU,uBAAuB;EAiBjC,mBAAmB,oBAAoB,gBAAgB;EAMvD,eAAe,oBAAoB,eAAe;EA8BlD,mBAAmB,oBAAoB;;;;;;;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,8BAA8B;cAK9B,eAAc;cAGd,oDAAW;cAKX,wBAAuB;cAGvB,mBAAkB,OAAO;cAOzB,iBAAgB;;;;;;;;;KC1DjB,WAAW,YACrB,iBAAiB,YAAY,qBAC7B,YAAY,QAAQ,kBACpB,aAAa,QAAQ;KAGX,kBAAkB,WAAW,qBACvC,uBACA,WAAW;iBAGG,YAAY,YAAY,cAAY,UAAU,UAC5D,UAAU,wBACT,kBAAkB,WAAW;;;iBCpBhB,2BAA2B;;;;;;;;;iBAuB3B,2BACd,+BACA,mBACC;;;KCvBS;;;;;;EAMV;;EAEA;;;KAIU;;EAEV,qBAAqB;;EAErB;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;;;;;KAaU;EACV,kBAAkB;EAClB,iBAAiB;EACjB;EACA,OAAO;EACP;;;iBAoFc,sBACd,wCACC;;;;;;;;;;;;;;;;;iBAiBa,sBACd,uCACA,eACA,UAAU,+BACT;;;;cC/IU,sBAAsB,iBAAiB;;cAIvC,sBAAsB,iBAAiB;;cAIvC,kCAAkC"}
|
|
@@ -87,4 +87,4 @@ var RegistryClient = class {
|
|
|
87
87
|
//#endregion
|
|
88
88
|
export { getPackagesByDocumentType as a, getPackages as i, getPackageInfo as n, getPackagesForDocumentType as o, getPackagePage as r, trimTrailingSlash as s, RegistryClient as t };
|
|
89
89
|
|
|
90
|
-
//# sourceMappingURL=client-
|
|
90
|
+
//# sourceMappingURL=client-BiJAJ9dW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-
|
|
1
|
+
{"version":3,"file":"client-BiJAJ9dW.js","names":[],"sources":["../src/registry/fetchers.ts","../src/registry/client.ts"],"sourcesContent":["import type { PackageInfo, PackagePage } from \"@powerhousedao/shared/registry\";\n\n// Strip a trailing \"/\" so we don't emit `http://host//packages` when a user\n// writes `packageRegistryUrl: \"http://host/\"`. Verdaccio's own web backend\n// 404s on the doubled slash, which cascades into an empty registry list and\n// masks the real install flow.\nexport function trimTrailingSlash(url: string): string {\n return url.endsWith(\"/\") ? url.slice(0, -1) : url;\n}\n\nexport async function getPackages(registryUrl: string) {\n const res = await fetch(`${trimTrailingSlash(registryUrl)}/packages`);\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n const data = (await res.json()) as PackageInfo[];\n return data;\n}\n\n/**\n * Fetch one page of the registry listing (trimmed items). Backed by the\n * paginated `GET /packages?limit=&offset=&search=` mode. Used by the Package\n * Manager's Available tab for infinite scroll + server-side search.\n */\nexport async function getPackagePage(\n registryUrl: string,\n params: { limit: number; offset: number; search?: string },\n): Promise<PackagePage> {\n const query = new URLSearchParams({\n limit: String(params.limit),\n offset: String(params.offset),\n });\n if (params.search) query.set(\"search\", params.search);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages?${query.toString()}`,\n );\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as PackagePage;\n}\n\n/**\n * Fetch full package info for every package exposing a given document type,\n * via the legacy `?documentType=` filter (returns full PackageInfo objects,\n * not just names). Used by the MissingPackageModal to offer installs without\n * loading the entire paginated listing.\n */\nexport async function getPackagesForDocumentType(\n registryUrl: string,\n documentType: string,\n): Promise<PackageInfo[]> {\n const encodedType = encodeURIComponent(documentType);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages?documentType=${encodedType}`,\n );\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as PackageInfo[];\n}\n\nexport async function getPackagesByDocumentType(\n registryUrl: string,\n documentType: string,\n): Promise<string[]> {\n const encodedType = encodeURIComponent(documentType);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages/by-document-type?type=${encodedType}`,\n );\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as string[];\n}\n\n/**\n * Fetch full metadata (versions + dist-tags) for one package from the\n * single-package endpoint. Returns null when the package no longer exists\n * upstream.\n */\nexport async function getPackageInfo(\n registryUrl: string,\n name: string,\n): Promise<PackageInfo | null> {\n const encodedName = encodeURIComponent(name);\n const res = await fetch(\n `${trimTrailingSlash(registryUrl)}/packages/${encodedName}`,\n );\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);\n return (await res.json()) as PackageInfo;\n}\n","import type { PackageInfo } from \"@powerhousedao/shared/registry\";\nimport { getPackages, getPackagesByDocumentType } from \"./fetchers.js\";\nimport type { PublishEvent } from \"./types.js\";\n\nfunction cdnUrlToApiUrl(cdnUrl: string): string {\n return cdnUrl.replace(/\\/-\\/cdn\\/?$/, \"\");\n}\nexport class RegistryClient {\n readonly apiUrl: string;\n\n constructor(cdnUrl: string) {\n this.apiUrl = cdnUrlToApiUrl(cdnUrl);\n }\n\n async getPackages(): Promise<PackageInfo[]> {\n const data = await getPackages(this.apiUrl);\n return data;\n }\n\n async getPackagesByDocumentType(documentType: string): Promise<string[]> {\n return await getPackagesByDocumentType(this.apiUrl, documentType);\n }\n\n async searchPackages(query: string): Promise<PackageInfo[]> {\n const packages = await this.getPackages();\n if (!query) return packages;\n const lowerQuery = query.toLowerCase();\n // Match on package name only (not description).\n return packages.filter((pkg) =>\n pkg.name.toLowerCase().includes(lowerQuery),\n );\n }\n\n onPublish(callback: (event: PublishEvent) => void): () => void {\n const eventSource = new EventSource(`${this.apiUrl}/-/events`);\n\n eventSource.addEventListener(\"publish\", (e: MessageEvent<string>) => {\n const data = JSON.parse(e.data) as PublishEvent;\n callback(data);\n });\n\n return () => {\n eventSource.close();\n };\n }\n}\n"],"mappings":";AAMA,SAAgB,kBAAkB,KAAqB;CACrD,OAAO,IAAI,SAAS,GAAG,IAAI,IAAI,MAAM,GAAG,EAAE,IAAI;AAChD;AAEA,eAAsB,YAAY,aAAqB;CACrD,MAAM,MAAM,MAAM,MAAM,GAAG,kBAAkB,WAAW,EAAE,UAAU;CACpE,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,wBAAwB,IAAI,QAAQ;CAEjE,OAAO,MADa,IAAI,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AgB,EAAE;AAC1C;AACA,IAAa,iBAAb,MAA4B;CAC1B;CAEA,YAAY,QAAgB;EAC1B,KAAK,SAAS,eAAe,MAAM;CACrC;CAEA,MAAM,cAAsC;EAE1C,OAAO,MADY,YAAY,KAAK,MAAM;CAE5C;CAEA,MAAM,0BAA0B,cAAyC;EACvE,OAAO,MAAM,0BAA0B,KAAK,QAAQ,YAAY;CAClE;CAEA,MAAM,eAAe,OAAuC;EAC1D,MAAM,WAAW,MAAM,KAAK,YAAY;EACxC,IAAI,CAAC,OAAO,OAAO;EACnB,MAAM,aAAa,MAAM,YAAY;EAErC,OAAO,SAAS,QAAQ,QACtB,IAAI,KAAK,YAAY,CAAC,CAAC,SAAS,UAAU,CAC5C;CACF;CAEA,UAAU,UAAqD;EAC7D,MAAM,cAAc,IAAI,YAAY,GAAG,KAAK,OAAO,UAAU;EAE7D,YAAY,iBAAiB,YAAY,MAA4B;GAEnE,SADa,KAAK,MAAM,EAAE,IACd,CAAC;EACf,CAAC;EAED,aAAa;GACX,YAAY,MAAM;EACpB;CACF;AACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { c as ReactorGraphQLClient, k as SdkFunctionWrapper } from "./types-
|
|
1
|
+
import { c as ReactorGraphQLClient, k as SdkFunctionWrapper } from "./types-B7-_l_wE.js";
|
|
2
2
|
import { GraphQLClient } from "graphql-request";
|
|
3
|
-
|
|
4
3
|
//#region src/graphql/client.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Creates a GraphQL client for the Reactor Subgraph API.
|
|
@@ -11,4 +10,5 @@ import { GraphQLClient } from "graphql-request";
|
|
|
11
10
|
declare function createClient(urlOrGQLClient: string | GraphQLClient, middleware?: SdkFunctionWrapper): ReactorGraphQLClient;
|
|
12
11
|
//#endregion
|
|
13
12
|
export { createClient as t };
|
|
14
|
-
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=client-CngU4mtn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-CngU4mtn.d.ts","names":[],"sources":["../src/graphql/client.ts"],"mappings":";;;;;;;;;iBA4BgB,aACd,yBAAyB,eACzB,aAAa,qBACZ"}
|