1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | import { AppCheckTokenProvider } from './AppCheckTokenProvider';
|
18 | import { AuthTokenProvider } from './AuthTokenProvider';
|
19 | import { PersistentConnection } from './PersistentConnection';
|
20 | import { RepoInfo } from './RepoInfo';
|
21 | import { ServerActions } from './ServerActions';
|
22 | import { Node } from './snap/Node';
|
23 | import { SnapshotHolder } from './SnapshotHolder';
|
24 | import { SparseSnapshotTree } from './SparseSnapshotTree';
|
25 | import { StatsCollection } from './stats/StatsCollection';
|
26 | import { StatsListener } from './stats/StatsListener';
|
27 | import { StatsReporter } from './stats/StatsReporter';
|
28 | import { SyncTree } from './SyncTree';
|
29 | import { Indexable } from './util/misc';
|
30 | import { Path } from './util/Path';
|
31 | import { Tree } from './util/Tree';
|
32 | import { EventQueue } from './view/EventQueue';
|
33 | import { EventRegistration, QueryContext } from './view/EventRegistration';
|
34 | declare const enum TransactionStatus {
|
35 | RUN = 0,
|
36 | SENT = 1,
|
37 | COMPLETED = 2,
|
38 | SENT_NEEDS_ABORT = 3,
|
39 | NEEDS_ABORT = 4
|
40 | }
|
41 | interface Transaction {
|
42 | path: Path;
|
43 | update: (a: unknown) => unknown;
|
44 | onComplete: (error: Error | null, committed: boolean, node: Node | null) => void;
|
45 | status: TransactionStatus;
|
46 | order: number;
|
47 | applyLocally: boolean;
|
48 | retryCount: number;
|
49 | unwatcher: () => void;
|
50 | abortReason: string | null;
|
51 | currentWriteId: number;
|
52 | currentInputSnapshot: Node | null;
|
53 | currentOutputSnapshotRaw: Node | null;
|
54 | currentOutputSnapshotResolved: Node | null;
|
55 | }
|
56 |
|
57 |
|
58 |
|
59 | export declare class Repo {
|
60 | repoInfo_: RepoInfo;
|
61 | forceRestClient_: boolean;
|
62 | authTokenProvider_: AuthTokenProvider;
|
63 | appCheckProvider_: AppCheckTokenProvider;
|
64 |
|
65 | readonly key: string;
|
66 | dataUpdateCount: number;
|
67 | infoSyncTree_: SyncTree;
|
68 | serverSyncTree_: SyncTree;
|
69 | stats_: StatsCollection;
|
70 | statsListener_: StatsListener | null;
|
71 | eventQueue_: EventQueue;
|
72 | nextWriteId_: number;
|
73 | server_: ServerActions;
|
74 | statsReporter_: StatsReporter;
|
75 | infoData_: SnapshotHolder;
|
76 | interceptServerDataCallback_: ((a: string, b: unknown) => void) | null;
|
77 | /** A list of data pieces and paths to be set when this client disconnects. */
|
78 | onDisconnect_: SparseSnapshotTree;
|
79 | /** Stores queues of outstanding transactions for Firebase locations. */
|
80 | transactionQueueTree_: Tree<Transaction[]>;
|
81 | persistentConnection_: PersistentConnection | null;
|
82 | constructor(repoInfo_: RepoInfo, forceRestClient_: boolean, authTokenProvider_: AuthTokenProvider, appCheckProvider_: AppCheckTokenProvider);
|
83 | /**
|
84 | * @returns The URL corresponding to the root of this Firebase.
|
85 | */
|
86 | toString(): string;
|
87 | }
|
88 | export declare function repoStart(repo: Repo, appId: string, authOverride?: object): void;
|
89 | /**
|
90 | * @returns The time in milliseconds, taking the server offset into account if we have one.
|
91 | */
|
92 | export declare function repoServerTime(repo: Repo): number;
|
93 | /**
|
94 | * Generate ServerValues using some variables from the repo object.
|
95 | */
|
96 | export declare function repoGenerateServerValues(repo: Repo): Indexable;
|
97 | export declare function repoInterceptServerData(repo: Repo, callback: ((a: string, b: unknown) => unknown) | null): void;
|
98 | /**
|
99 | * The purpose of `getValue` is to return the latest known value
|
100 | * satisfying `query`.
|
101 | *
|
102 | * This method will first check for in-memory cached values
|
103 | * belonging to active listeners. If they are found, such values
|
104 | * are considered to be the most up-to-date.
|
105 | *
|
106 | * If the client is not connected, this method will try to
|
107 | * establish a connection and request the value for `query`. If
|
108 | * the client is not able to retrieve the query result, it reports
|
109 | * an error.
|
110 | *
|
111 | * @param query - The query to surface a value for.
|
112 | */
|
113 | export declare function repoGetValue(repo: Repo, query: QueryContext): Promise<Node>;
|
114 | export declare function repoSetWithPriority(repo: Repo, path: Path, newVal: unknown, newPriority: number | string | null, onComplete: ((status: Error | null, errorReason?: string) => void) | null): void;
|
115 | export declare function repoUpdate(repo: Repo, path: Path, childrenToMerge: {
|
116 | [k: string]: unknown;
|
117 | }, onComplete: ((status: Error | null, errorReason?: string) => void) | null): void;
|
118 | export declare function repoOnDisconnectCancel(repo: Repo, path: Path, onComplete: ((status: Error | null, errorReason?: string) => void) | null): void;
|
119 | export declare function repoOnDisconnectSet(repo: Repo, path: Path, value: unknown, onComplete: ((status: Error | null, errorReason?: string) => void) | null): void;
|
120 | export declare function repoOnDisconnectSetWithPriority(repo: Repo, path: Path, value: unknown, priority: unknown, onComplete: ((status: Error | null, errorReason?: string) => void) | null): void;
|
121 | export declare function repoOnDisconnectUpdate(repo: Repo, path: Path, childrenToMerge: {
|
122 | [k: string]: unknown;
|
123 | }, onComplete: ((status: Error | null, errorReason?: string) => void) | null): void;
|
124 | export declare function repoAddEventCallbackForQuery(repo: Repo, query: QueryContext, eventRegistration: EventRegistration): void;
|
125 | export declare function repoRemoveEventCallbackForQuery(repo: Repo, query: QueryContext, eventRegistration: EventRegistration): void;
|
126 | export declare function repoInterrupt(repo: Repo): void;
|
127 | export declare function repoResume(repo: Repo): void;
|
128 | export declare function repoStats(repo: Repo, showDelta?: boolean): void;
|
129 | export declare function repoStatsIncrementCounter(repo: Repo, metric: string): void;
|
130 | export declare function repoCallOnCompleteCallback(repo: Repo, callback: ((status: Error | null, errorReason?: string) => void) | null, status: string, errorReason?: string | null): void;
|
131 | /**
|
132 | * Creates a new transaction, adds it to the transactions we're tracking, and
|
133 | * sends it to the server if possible.
|
134 | *
|
135 | * @param path - Path at which to do transaction.
|
136 | * @param transactionUpdate - Update callback.
|
137 | * @param onComplete - Completion callback.
|
138 | * @param unwatcher - Function that will be called when the transaction no longer
|
139 | * need data updates for `path`.
|
140 | * @param applyLocally - Whether or not to make intermediate results visible
|
141 | */
|
142 | export declare function repoStartTransaction(repo: Repo, path: Path, transactionUpdate: (a: unknown) => unknown, onComplete: ((error: Error, committed: boolean, node: Node) => void) | null, unwatcher: () => void, applyLocally: boolean): void;
|
143 | export {};
|
144 |
|
\ | No newline at end of file |