syncorejs 0.2.1 → 0.2.3
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/README.md +2 -1
- package/dist/_vendor/cli/app.d.mts.map +1 -1
- package/dist/_vendor/cli/app.mjs +330 -46
- package/dist/_vendor/cli/app.mjs.map +1 -1
- package/dist/_vendor/cli/context.mjs +27 -9
- package/dist/_vendor/cli/context.mjs.map +1 -1
- package/dist/_vendor/cli/dev-session.mjs.map +1 -1
- package/dist/_vendor/cli/doctor.mjs +513 -46
- package/dist/_vendor/cli/doctor.mjs.map +1 -1
- package/dist/_vendor/cli/errors.mjs.map +1 -1
- package/dist/_vendor/cli/help.mjs.map +1 -1
- package/dist/_vendor/cli/index.mjs +9 -2
- package/dist/_vendor/cli/index.mjs.map +1 -1
- package/dist/_vendor/cli/messages.mjs +5 -4
- package/dist/_vendor/cli/messages.mjs.map +1 -1
- package/dist/_vendor/cli/preflight.mjs.map +1 -1
- package/dist/_vendor/cli/project.mjs +125 -27
- package/dist/_vendor/cli/project.mjs.map +1 -1
- package/dist/_vendor/cli/render.mjs +57 -9
- package/dist/_vendor/cli/render.mjs.map +1 -1
- package/dist/_vendor/cli/targets.mjs +4 -3
- package/dist/_vendor/cli/targets.mjs.map +1 -1
- package/dist/_vendor/core/cli.d.mts +20 -4
- package/dist/_vendor/core/cli.d.mts.map +1 -1
- package/dist/_vendor/core/cli.mjs +458 -133
- package/dist/_vendor/core/cli.mjs.map +1 -1
- package/dist/_vendor/core/devtools-auth.mjs +60 -0
- package/dist/_vendor/core/devtools-auth.mjs.map +1 -0
- package/dist/_vendor/core/index.d.mts +5 -3
- package/dist/_vendor/core/index.mjs +22 -2
- package/dist/_vendor/core/index.mjs.map +1 -1
- package/dist/_vendor/core/runtime/components.d.mts +111 -0
- package/dist/_vendor/core/runtime/components.d.mts.map +1 -0
- package/dist/_vendor/core/runtime/components.mjs +186 -0
- package/dist/_vendor/core/runtime/components.mjs.map +1 -0
- package/dist/_vendor/core/runtime/devtools.d.mts +4 -4
- package/dist/_vendor/core/runtime/devtools.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/devtools.mjs +178 -60
- package/dist/_vendor/core/runtime/devtools.mjs.map +1 -1
- package/dist/_vendor/core/runtime/functions.d.mts +398 -16
- package/dist/_vendor/core/runtime/functions.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/functions.mjs +74 -3
- package/dist/_vendor/core/runtime/functions.mjs.map +1 -1
- package/dist/_vendor/core/runtime/id.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/id.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs +83 -0
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs +720 -0
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs +234 -0
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/schedulerEngine.mjs +255 -0
- package/dist/_vendor/core/runtime/internal/engines/schedulerEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/schemaEngine.mjs +200 -0
- package/dist/_vendor/core/runtime/internal/engines/schemaEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs +252 -0
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs +145 -0
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs +221 -0
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/runtimeStatus.mjs +32 -0
- package/dist/_vendor/core/runtime/internal/runtimeStatus.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/systemMeta.mjs +61 -0
- package/dist/_vendor/core/runtime/internal/systemMeta.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/transactionCoordinator.mjs +41 -0
- package/dist/_vendor/core/runtime/internal/transactionCoordinator.mjs.map +1 -0
- package/dist/_vendor/core/runtime/runtime.d.mts +1187 -202
- package/dist/_vendor/core/runtime/runtime.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/runtime.mjs +73 -1365
- package/dist/_vendor/core/runtime/runtime.mjs.map +1 -1
- package/dist/_vendor/core/transport.d.mts +113 -0
- package/dist/_vendor/core/transport.d.mts.map +1 -0
- package/dist/_vendor/core/transport.mjs +428 -0
- package/dist/_vendor/core/transport.mjs.map +1 -0
- package/dist/_vendor/devtools-protocol/index.d.ts +187 -4
- package/dist/_vendor/devtools-protocol/index.d.ts.map +1 -1
- package/dist/_vendor/devtools-protocol/index.js +25 -9
- package/dist/_vendor/devtools-protocol/index.js.map +1 -1
- package/dist/_vendor/next/config.d.ts +3 -4
- package/dist/_vendor/next/config.d.ts.map +1 -1
- package/dist/_vendor/next/config.js +37 -19
- package/dist/_vendor/next/config.js.map +1 -1
- package/dist/_vendor/next/index.d.ts +109 -29
- package/dist/_vendor/next/index.d.ts.map +1 -1
- package/dist/_vendor/next/index.js +104 -26
- package/dist/_vendor/next/index.js.map +1 -1
- package/dist/_vendor/platform-expo/index.d.ts +156 -37
- package/dist/_vendor/platform-expo/index.d.ts.map +1 -1
- package/dist/_vendor/platform-expo/index.js +80 -12
- package/dist/_vendor/platform-expo/index.js.map +1 -1
- package/dist/_vendor/platform-expo/react.d.ts.map +1 -1
- package/dist/_vendor/platform-expo/react.js +11 -10
- package/dist/_vendor/platform-expo/react.js.map +1 -1
- package/dist/_vendor/platform-expo/web-sqljs-wasm.js +16 -0
- package/dist/_vendor/platform-expo/web-sqljs-wasm.js.map +1 -0
- package/dist/_vendor/platform-node/index.d.mts +192 -24
- package/dist/_vendor/platform-node/index.d.mts.map +1 -1
- package/dist/_vendor/platform-node/index.mjs +236 -97
- package/dist/_vendor/platform-node/index.mjs.map +1 -1
- package/dist/_vendor/platform-node/ipc-react.d.mts.map +1 -1
- package/dist/_vendor/platform-node/ipc-react.mjs +15 -2
- package/dist/_vendor/platform-node/ipc-react.mjs.map +1 -1
- package/dist/_vendor/platform-node/ipc.d.mts +11 -35
- package/dist/_vendor/platform-node/ipc.d.mts.map +1 -1
- package/dist/_vendor/platform-node/ipc.mjs +3 -273
- package/dist/_vendor/platform-node/ipc.mjs.map +1 -1
- package/dist/_vendor/platform-web/external-change.d.ts +43 -1
- package/dist/_vendor/platform-web/external-change.d.ts.map +1 -1
- package/dist/_vendor/platform-web/external-change.js +32 -1
- package/dist/_vendor/platform-web/external-change.js.map +1 -1
- package/dist/_vendor/platform-web/index.d.ts +323 -51
- package/dist/_vendor/platform-web/index.d.ts.map +1 -1
- package/dist/_vendor/platform-web/index.js +233 -30
- package/dist/_vendor/platform-web/index.js.map +1 -1
- package/dist/_vendor/platform-web/indexeddb.d.ts +12 -0
- package/dist/_vendor/platform-web/indexeddb.d.ts.map +1 -1
- package/dist/_vendor/platform-web/indexeddb.js +10 -0
- package/dist/_vendor/platform-web/indexeddb.js.map +1 -1
- package/dist/_vendor/platform-web/opfs.d.ts +13 -0
- package/dist/_vendor/platform-web/opfs.d.ts.map +1 -1
- package/dist/_vendor/platform-web/opfs.js +12 -0
- package/dist/_vendor/platform-web/opfs.js.map +1 -1
- package/dist/_vendor/platform-web/persistence.d.ts +54 -0
- package/dist/_vendor/platform-web/persistence.d.ts.map +1 -1
- package/dist/_vendor/platform-web/persistence.js +15 -0
- package/dist/_vendor/platform-web/persistence.js.map +1 -1
- package/dist/_vendor/platform-web/react.d.ts +1 -2
- package/dist/_vendor/platform-web/react.d.ts.map +1 -1
- package/dist/_vendor/platform-web/react.js +27 -13
- package/dist/_vendor/platform-web/react.js.map +1 -1
- package/dist/_vendor/platform-web/sqljs.js +10 -1
- package/dist/_vendor/platform-web/sqljs.js.map +1 -1
- package/dist/_vendor/platform-web/web-sqljs-wasm.js +8 -0
- package/dist/_vendor/platform-web/web-sqljs-wasm.js.map +1 -0
- package/dist/_vendor/platform-web/worker.d.ts +71 -44
- package/dist/_vendor/platform-web/worker.d.ts.map +1 -1
- package/dist/_vendor/platform-web/worker.js +40 -271
- package/dist/_vendor/platform-web/worker.js.map +1 -1
- package/dist/_vendor/react/index.d.ts +222 -23
- package/dist/_vendor/react/index.d.ts.map +1 -1
- package/dist/_vendor/react/index.js +476 -63
- package/dist/_vendor/react/index.js.map +1 -1
- package/dist/_vendor/schema/definition.d.ts +151 -37
- package/dist/_vendor/schema/definition.d.ts.map +1 -1
- package/dist/_vendor/schema/definition.js +102 -20
- package/dist/_vendor/schema/definition.js.map +1 -1
- package/dist/_vendor/schema/index.d.ts +4 -4
- package/dist/_vendor/schema/index.js +2 -2
- package/dist/_vendor/schema/planner.d.ts +19 -2
- package/dist/_vendor/schema/planner.d.ts.map +1 -1
- package/dist/_vendor/schema/planner.js +79 -3
- package/dist/_vendor/schema/planner.js.map +1 -1
- package/dist/_vendor/schema/validators.d.ts +279 -83
- package/dist/_vendor/schema/validators.d.ts.map +1 -1
- package/dist/_vendor/schema/validators.js +330 -38
- package/dist/_vendor/schema/validators.js.map +1 -1
- package/dist/_vendor/svelte/index.d.ts +245 -19
- package/dist/_vendor/svelte/index.d.ts.map +1 -1
- package/dist/_vendor/svelte/index.js +443 -20
- package/dist/_vendor/svelte/index.js.map +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/components.d.ts +2 -0
- package/dist/components.js +2 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/package.json +29 -21
|
@@ -1,20 +1,64 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import
|
|
3
|
-
import { FunctionReference, SyncoreClient } from "../core/index.d.mts";
|
|
2
|
+
import { FunctionArgs, FunctionReference, FunctionResult, PaginationOptions, PaginationResult, SyncoreClient, SyncoreQueryState, SyncoreRuntimeStatus, UsePaginatedQueryResult } from "../core/index.d.mts";
|
|
4
3
|
|
|
5
4
|
//#region src/index.d.ts
|
|
6
5
|
type OptionalArgsTuple<TArgs> = Record<never, never> extends TArgs ? [args?: TArgs] : [args: TArgs];
|
|
6
|
+
type QueryRequestInput<TReference extends FunctionReference<"query"> = FunctionReference<"query">> = Record<never, never> extends FunctionArgs<TReference> ? {
|
|
7
|
+
query: TReference;
|
|
8
|
+
args?: FunctionArgs<TReference> | Skip;
|
|
9
|
+
} : {
|
|
10
|
+
query: TReference;
|
|
11
|
+
args: FunctionArgs<TReference> | Skip;
|
|
12
|
+
};
|
|
13
|
+
type QueriesRequestInput = Record<string, QueryRequestInput>;
|
|
14
|
+
type QueryStateForEntry<TEntry> = TEntry extends QueryRequestInput<infer TReference> ? SyncoreQueryState<FunctionResult<TReference>> : never;
|
|
15
|
+
type UseQueriesResult<TEntries extends QueriesRequestInput> = { [TKey in keyof TEntries]: QueryStateForEntry<TEntries[TKey]> };
|
|
16
|
+
type PaginatedQueryReference = FunctionReference<"query", Record<string, unknown>, PaginationResult<unknown>>;
|
|
17
|
+
type PaginatedQueryArgs<TReference extends FunctionReference<"query">> = FunctionArgs<TReference> extends {
|
|
18
|
+
paginationOpts: PaginationOptions;
|
|
19
|
+
} ? Omit<FunctionArgs<TReference>, "paginationOpts"> : never;
|
|
20
|
+
type PaginatedQueryItem<TReference extends FunctionReference<"query">> = FunctionResult<TReference> extends PaginationResult<infer TItem> ? TItem : never;
|
|
7
21
|
/**
|
|
8
|
-
* Pass `
|
|
9
|
-
*
|
|
22
|
+
* Pass `skip` as the `args` argument to any Syncore React hook to suppress
|
|
23
|
+
* that subscription entirely.
|
|
24
|
+
*
|
|
25
|
+
* Useful when the query arguments depend on state that is not yet available
|
|
26
|
+
* (e.g. a selected item ID) — instead of conditionally calling the hook
|
|
27
|
+
* (which violates the Rules of Hooks), pass `skip` to deactivate it:
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const task = useQuery(api.tasks.get, selectedId ? { id: selectedId } : skip);
|
|
31
|
+
* // task is `undefined` while selectedId is null/undefined
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Skipped queries return `undefined` for `data`, `"skipped"` for `status`,
|
|
35
|
+
* and `false` for `isLoading`.
|
|
10
36
|
*/
|
|
11
37
|
declare const skip: "skip";
|
|
12
38
|
type Skip = typeof skip;
|
|
13
39
|
/**
|
|
14
|
-
*
|
|
40
|
+
* Provides a Syncore client to all React descendants via context.
|
|
41
|
+
*
|
|
42
|
+
* Wrap your app (or any subtree that uses Syncore hooks) with
|
|
43
|
+
* `SyncoreProvider`. All `useQuery`, `useMutation`, `useAction`, and
|
|
44
|
+
* `useQueries` calls inside the tree will automatically use the client you
|
|
45
|
+
* supply.
|
|
46
|
+
*
|
|
47
|
+
* ```tsx
|
|
48
|
+
* // For a browser worker setup
|
|
49
|
+
* const client = createBrowserWorkerClient();
|
|
15
50
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
51
|
+
* function App() {
|
|
52
|
+
* return (
|
|
53
|
+
* <SyncoreProvider client={client}>
|
|
54
|
+
* <TaskList />
|
|
55
|
+
* </SyncoreProvider>
|
|
56
|
+
* );
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* For Next.js apps use `SyncoreNextProvider` which also handles service worker
|
|
61
|
+
* and worker URL configuration.
|
|
18
62
|
*/
|
|
19
63
|
declare function SyncoreProvider({
|
|
20
64
|
client,
|
|
@@ -22,37 +66,192 @@ declare function SyncoreProvider({
|
|
|
22
66
|
}: {
|
|
23
67
|
client: SyncoreClient;
|
|
24
68
|
children: ReactNode;
|
|
25
|
-
}):
|
|
69
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
26
70
|
/**
|
|
27
|
-
*
|
|
71
|
+
* Returns the active `SyncoreClient` from the nearest {@link SyncoreProvider}
|
|
72
|
+
* in the React tree.
|
|
73
|
+
*
|
|
74
|
+
* Throws if called outside of a `SyncoreProvider`. Prefer the higher-level
|
|
75
|
+
* hooks (`useQuery`, `useMutation`, etc.) for common operations — use
|
|
76
|
+
* `useSyncore` only when you need direct access to the client object.
|
|
28
77
|
*
|
|
29
|
-
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* const client = useSyncore();
|
|
80
|
+
* const tasks = await client.query(api.tasks.list);
|
|
81
|
+
* ```
|
|
30
82
|
*/
|
|
31
83
|
declare function useSyncore(): SyncoreClient;
|
|
32
84
|
/**
|
|
33
|
-
*
|
|
85
|
+
* Subscribe to the runtime’s lifecycle status.
|
|
86
|
+
*
|
|
87
|
+
* Returns a {@link SyncoreRuntimeStatus} that updates whenever the underlying
|
|
88
|
+
* runtime changes state (e.g. starting, ready, error). Use it to gate your UI
|
|
89
|
+
* on the runtime being ready or to display an error boundary:
|
|
90
|
+
*
|
|
91
|
+
* ```tsx
|
|
92
|
+
* function TaskList() {
|
|
93
|
+
* const status = useSyncoreStatus();
|
|
94
|
+
* if (status.kind === "starting") return <Spinner />;
|
|
95
|
+
* if (status.kind === "error") return <ErrorScreen error={status.error} />;
|
|
96
|
+
* return <Tasks />;
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* Most components do not need this — `useQuery` already incorporates runtime
|
|
101
|
+
* status into the `SyncoreQueryState.runtimeStatus` field.
|
|
102
|
+
*/
|
|
103
|
+
declare function useSyncoreStatus(): SyncoreRuntimeStatus;
|
|
104
|
+
/**
|
|
105
|
+
* Subscribe to a reactive Syncore query and return the current data.
|
|
106
|
+
*
|
|
107
|
+
* The component re-renders automatically whenever the query result changes.
|
|
108
|
+
* If the query throws, `useQuery` re-throws the error so a React error
|
|
109
|
+
* boundary can catch it — use {@link useQueryState} if you need to handle
|
|
110
|
+
* errors inline.
|
|
111
|
+
*
|
|
112
|
+
* ```tsx
|
|
113
|
+
* // Basic usage
|
|
114
|
+
* const tasks = useQuery(api.tasks.list);
|
|
115
|
+
*
|
|
116
|
+
* // With arguments
|
|
117
|
+
* const task = useQuery(api.tasks.get, { id: taskId });
|
|
34
118
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
119
|
+
* // Conditionally skip when arguments are not yet available
|
|
120
|
+
* const task = useQuery(api.tasks.get, taskId ? { id: taskId } : skip);
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @param reference - A typed function reference (from the generated `api` object).
|
|
124
|
+
* @param args - The query’s arguments, or `skip` to suppress the subscription.
|
|
125
|
+
* @returns The current query result, or `undefined` while loading.
|
|
38
126
|
*/
|
|
39
127
|
declare function useQuery<TArgs, TResult>(reference: FunctionReference<"query", TArgs, TResult>, ...args: OptionalArgsTuple<TArgs> | [Skip]): TResult | undefined;
|
|
40
128
|
/**
|
|
41
|
-
*
|
|
129
|
+
* Subscribe to a reactive Syncore query and return the full
|
|
130
|
+
* {@link SyncoreQueryState} including loading, error, and runtime status.
|
|
131
|
+
*
|
|
132
|
+
* Use this instead of {@link useQuery} when you need to:
|
|
133
|
+
* - Differentiate between `undefined` data and an error.
|
|
134
|
+
* - React to `isLoading` / `isError` without relying on error boundaries.
|
|
135
|
+
* - Inspect `runtimeStatus` for the underlying runtime’s health.
|
|
136
|
+
*
|
|
137
|
+
* ```tsx
|
|
138
|
+
* const { data, isLoading, isError, error } = useQueryState(api.tasks.list);
|
|
139
|
+
*
|
|
140
|
+
* if (isLoading) return <Spinner />;
|
|
141
|
+
* if (isError) return <ErrorBanner message={error.message} />;
|
|
142
|
+
* return <TaskList tasks={data} />;
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
declare function useQueryState<TArgs, TResult>(reference: FunctionReference<"query", TArgs, TResult>, ...args: OptionalArgsTuple<TArgs> | [Skip]): SyncoreQueryState<TResult>;
|
|
146
|
+
/**
|
|
147
|
+
* Returns a stable callback for executing a Syncore mutation.
|
|
148
|
+
*
|
|
149
|
+
* The returned function is type-safe: its parameter types are inferred from
|
|
150
|
+
* the mutation definition and remain stable across re-renders (no need to
|
|
151
|
+
* wrap in `useCallback`).
|
|
152
|
+
*
|
|
153
|
+
* ```tsx
|
|
154
|
+
* const createTask = useMutation(api.tasks.create);
|
|
155
|
+
*
|
|
156
|
+
* return (
|
|
157
|
+
* <button onClick={() => createTask({ title: "New task" })}>
|
|
158
|
+
* Add task
|
|
159
|
+
* </button>
|
|
160
|
+
* );
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @param reference - A typed mutation reference from the generated `api` object.
|
|
164
|
+
* @returns A function that, when called, executes the mutation and returns a
|
|
165
|
+
* promise that resolves to the mutation’s return value.
|
|
42
166
|
*/
|
|
43
167
|
declare function useMutation<TArgs, TResult>(reference: FunctionReference<"mutation", TArgs, TResult>): (...args: OptionalArgsTuple<TArgs>) => Promise<TResult>;
|
|
44
168
|
/**
|
|
45
|
-
*
|
|
169
|
+
* Returns a stable callback for executing a Syncore action.
|
|
170
|
+
*
|
|
171
|
+
* Identical to {@link useMutation} but for actions. Use this when the work you
|
|
172
|
+
* need to do cannot run inside a transaction (external API calls, long-running
|
|
173
|
+
* tasks, etc.).
|
|
174
|
+
*
|
|
175
|
+
* ```tsx
|
|
176
|
+
* const importTasks = useAction(api.tasks.importFromCsv);
|
|
177
|
+
*
|
|
178
|
+
* return (
|
|
179
|
+
* <button onClick={() => importTasks({ url: csvUrl })}>
|
|
180
|
+
* Import
|
|
181
|
+
* </button>
|
|
182
|
+
* );
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* @param reference - A typed action reference from the generated `api` object.
|
|
186
|
+
* @returns A function that, when called, executes the action and returns a
|
|
187
|
+
* promise that resolves to the action’s return value.
|
|
46
188
|
*/
|
|
47
189
|
declare function useAction<TArgs, TResult>(reference: FunctionReference<"action", TArgs, TResult>): (...args: OptionalArgsTuple<TArgs>) => Promise<TResult>;
|
|
48
190
|
/**
|
|
49
|
-
*
|
|
191
|
+
* Subscribe to multiple Syncore queries simultaneously and receive per-entry
|
|
192
|
+
* state objects in a single hook call.
|
|
193
|
+
*
|
|
194
|
+
* More efficient than calling `useQuery` in a loop when the set of queries is
|
|
195
|
+
* known at component render time. The hook maintains only one subscription per
|
|
196
|
+
* unique `(reference, args)` combination even if entries are duplicated.
|
|
197
|
+
*
|
|
198
|
+
* ```tsx
|
|
199
|
+
* const { header, sidebar } = useQueries({
|
|
200
|
+
* header: { query: api.layout.header },
|
|
201
|
+
* sidebar: { query: api.layout.sidebar, args: { userId } },
|
|
202
|
+
* });
|
|
203
|
+
*
|
|
204
|
+
* if (header.isLoading || sidebar.isLoading) return <Spinner />;
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @param entries - A record of named query requests. Each entry can include
|
|
208
|
+
* `args: skip` to suppress that specific subscription.
|
|
209
|
+
* @returns A record with the same keys, each holding a {@link SyncoreQueryState}.
|
|
210
|
+
*/
|
|
211
|
+
declare function useQueries<TEntries extends QueriesRequestInput>(entries: TEntries): UseQueriesResult<TEntries>;
|
|
212
|
+
/**
|
|
213
|
+
* Subscribe to a paginated Syncore query, incrementally loading more pages.
|
|
214
|
+
*
|
|
215
|
+
* The query must accept a `paginationOpts` argument and return a
|
|
216
|
+
* `PaginationResult`. The hook manages cursors automatically — call the
|
|
217
|
+
* returned `loadMore` function to append the next page to the results.
|
|
218
|
+
*
|
|
219
|
+
* ```tsx
|
|
220
|
+
* const { results, status, loadMore, hasMore } = usePaginatedQuery(
|
|
221
|
+
* api.tasks.list,
|
|
222
|
+
* { projectId },
|
|
223
|
+
* { initialNumItems: 20 },
|
|
224
|
+
* );
|
|
225
|
+
*
|
|
226
|
+
* return (
|
|
227
|
+
* <>
|
|
228
|
+
* {results.map((t) => <TaskRow key={t._id} task={t} />)}
|
|
229
|
+
* {hasMore && (
|
|
230
|
+
* <button
|
|
231
|
+
* onClick={() => loadMore(20)}
|
|
232
|
+
* disabled={status === "loadingMore"}
|
|
233
|
+
* >
|
|
234
|
+
* Load more
|
|
235
|
+
* </button>
|
|
236
|
+
* )}
|
|
237
|
+
* </>
|
|
238
|
+
* );
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* Pass `skip` as `args` to suppress the subscription until arguments are
|
|
242
|
+
* ready.
|
|
243
|
+
*
|
|
244
|
+
* @param reference - A typed query reference whose handler calls
|
|
245
|
+
* `ctx.db.query(…).paginate(paginationOpts)`.
|
|
246
|
+
* @param args - Arguments for the query (excluding
|
|
247
|
+
* `paginationOpts`, which is managed internally), or `skip`.
|
|
248
|
+
* @param options.initialNumItems - Number of items to load on the first page.
|
|
249
|
+
* @returns A {@link UsePaginatedQueryResult} with the accumulated results and
|
|
250
|
+
* a `loadMore` callback.
|
|
50
251
|
*/
|
|
51
|
-
declare function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
args?: Record<string, unknown>;
|
|
55
|
-
}>): Record<string, TResult | undefined>;
|
|
252
|
+
declare function usePaginatedQuery<TReference extends PaginatedQueryReference>(reference: TReference, args: PaginatedQueryArgs<TReference> | Skip, options: {
|
|
253
|
+
initialNumItems: number;
|
|
254
|
+
}): UsePaginatedQueryResult<PaginatedQueryItem<TReference>>;
|
|
56
255
|
//#endregion
|
|
57
|
-
export { SyncoreProvider, skip, useAction, useMutation, useQueries, useQuery, useSyncore };
|
|
256
|
+
export { SyncoreProvider, UseQueriesResult, skip, useAction, useMutation, usePaginatedQuery, useQueries, useQuery, useQueryState, useSyncore, useSyncoreStatus };
|
|
58
257
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;KA0BK,iBAAA,UACH,MAAA,uBAA6B,KAAA,IAAS,IAAA,GAAO,KAAA,KAAU,IAAA,EAAM,KAAA;AAAA,KAE1D,iBAAA,oBAC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