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,43 +1,269 @@
|
|
|
1
1
|
import { Readable } from "svelte/store";
|
|
2
|
-
import { FunctionArgs, FunctionReference, FunctionResult, SyncoreClient } from "../core/index.d.mts";
|
|
2
|
+
import { FunctionArgs, FunctionReference, FunctionResult, PaginationOptions, PaginationResult, SyncoreClient, SyncoreQueryState, SyncoreRuntimeStatus, UsePaginatedQueryResult } from "../core/index.d.mts";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
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 CreateQueriesStoreResult<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;
|
|
6
21
|
/**
|
|
7
|
-
* The
|
|
22
|
+
* The reactive query state shape emitted by Syncore's Svelte store factories.
|
|
23
|
+
*
|
|
24
|
+
* Extends {@link SyncoreQueryState} with the same fields (`data`, `error`,
|
|
25
|
+
* `status`, `runtimeStatus`, `isLoading`, `isError`, `isReady`). Returned as
|
|
26
|
+
* the value of stores created by {@link createQueryStore} and
|
|
27
|
+
* {@link createClientQueryStore}.
|
|
8
28
|
*/
|
|
9
|
-
interface SyncoreQueryStoreState<TResult> {
|
|
10
|
-
/** The latest local result for the watched query. */
|
|
11
|
-
data: TResult | undefined;
|
|
12
|
-
/** The latest local error for the watched query, if any. */
|
|
13
|
-
error: Error | undefined;
|
|
14
|
-
/** The current watch lifecycle status. */
|
|
15
|
-
status: "loading" | "ready" | "error";
|
|
16
|
-
}
|
|
29
|
+
interface SyncoreQueryStoreState<TResult> extends SyncoreQueryState<TResult> {}
|
|
17
30
|
/**
|
|
18
|
-
*
|
|
31
|
+
* A sentinel value that tells Syncore store factories to skip the query.
|
|
32
|
+
*
|
|
33
|
+
* Use `skip` in place of a query’s `args` argument to avoid firing the query
|
|
34
|
+
* while some required data is not yet available (e.g. a user ID that loads
|
|
35
|
+
* asynchronously). The store will remain in a `"loading"` / skipped state
|
|
36
|
+
* until a non-skip value is provided.
|
|
37
|
+
*
|
|
38
|
+
* ```svelte
|
|
39
|
+
* <script>
|
|
40
|
+
* import { createQueryValueStore, skip } from "syncorejs/svelte";
|
|
41
|
+
* import { api } from "../syncore/_generated/api";
|
|
42
|
+
*
|
|
43
|
+
* export let userId: string | undefined;
|
|
44
|
+
*
|
|
45
|
+
* $: profile = createQueryValueStore(
|
|
46
|
+
* api.users.get,
|
|
47
|
+
* userId ? { id: userId } : skip
|
|
48
|
+
* );
|
|
49
|
+
* </script>
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare const skip: "skip";
|
|
53
|
+
type Skip = typeof skip;
|
|
54
|
+
/**
|
|
55
|
+
* Store the Syncore client in Svelte’s component context.
|
|
56
|
+
*
|
|
57
|
+
* Call this once at the root of your component tree (e.g. in a layout or
|
|
58
|
+
* root `+layout.svelte`) so that the context-aware store factories
|
|
59
|
+
* (`createQueryStore`, `createQueriesStore`, etc.) can retrieve it
|
|
60
|
+
* automatically without prop-drilling.
|
|
61
|
+
*
|
|
62
|
+
* ```svelte
|
|
63
|
+
* <!-- +layout.svelte -->
|
|
64
|
+
* <script>
|
|
65
|
+
* import { setSyncoreClient } from "syncorejs/svelte";
|
|
66
|
+
* export let data; // { client } from +layout.ts
|
|
67
|
+
* setSyncoreClient(data.client);
|
|
68
|
+
* </script>
|
|
69
|
+
* <slot />
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param client - The ready Syncore client to store in context.
|
|
73
|
+
* @returns The same `client` for convenience.
|
|
19
74
|
*/
|
|
20
75
|
declare function setSyncoreClient(client: SyncoreClient): SyncoreClient;
|
|
21
76
|
/**
|
|
22
|
-
*
|
|
77
|
+
* Retrieve the Syncore client from Svelte’s component context.
|
|
78
|
+
*
|
|
79
|
+
* Throws if {@link setSyncoreClient} has not been called by an ancestor
|
|
80
|
+
* component. Only use this inside Svelte components; for standalone scripts
|
|
81
|
+
* keep an explicit reference to the client instead.
|
|
82
|
+
*
|
|
83
|
+
* @throws `Error` when no client is found in the component context.
|
|
23
84
|
*/
|
|
24
85
|
declare function getSyncoreClient(): SyncoreClient;
|
|
25
86
|
/**
|
|
26
|
-
* Create a
|
|
87
|
+
* Create a reactive Svelte store that tracks the Syncore runtime status.
|
|
88
|
+
*
|
|
89
|
+
* Uses the client from Svelte context (set via {@link setSyncoreClient}).
|
|
90
|
+
* Subscribe to gate your UI on `"ready"` before rendering data-dependent
|
|
91
|
+
* components.
|
|
92
|
+
*
|
|
93
|
+
* ```svelte
|
|
94
|
+
* <script>
|
|
95
|
+
* import { createSyncoreStatusStore } from "syncorejs/svelte";
|
|
96
|
+
* const status = createSyncoreStatusStore();
|
|
97
|
+
* </script>
|
|
98
|
+
*
|
|
99
|
+
* {#if $status.kind === "ready"}
|
|
100
|
+
* <App />
|
|
101
|
+
* {:else}
|
|
102
|
+
* <Loading />
|
|
103
|
+
* {/if}
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
declare function createSyncoreStatusStore(): Readable<SyncoreRuntimeStatus>;
|
|
107
|
+
/**
|
|
108
|
+
* Create a reactive Svelte store that tracks the Syncore runtime status.
|
|
109
|
+
*
|
|
110
|
+
* Accepts an explicit `client` rather than reading from Svelte context,
|
|
111
|
+
* making it usable outside component trees (e.g. in module-level code or
|
|
112
|
+
* SvelteKit `load` functions).
|
|
113
|
+
*
|
|
114
|
+
* @param client - The Syncore client to observe.
|
|
115
|
+
*/
|
|
116
|
+
declare function createClientSyncoreStatusStore(client: SyncoreClient): Readable<SyncoreRuntimeStatus>;
|
|
117
|
+
/**
|
|
118
|
+
* Create a reactive Svelte store that emits the current value of a Syncore
|
|
119
|
+
* query, or `undefined` while loading.
|
|
120
|
+
*
|
|
121
|
+
* Uses the client from Svelte context (set via {@link setSyncoreClient}).
|
|
122
|
+
* Pass `skip` as `args` to pause the query.
|
|
123
|
+
*
|
|
124
|
+
* ```svelte
|
|
125
|
+
* <script>
|
|
126
|
+
* import { createQueryValueStore } from "syncorejs/svelte";
|
|
127
|
+
* import { api } from "../syncore/_generated/api";
|
|
128
|
+
*
|
|
129
|
+
* const todos = createQueryValueStore(api.todos.list);
|
|
130
|
+
* </script>
|
|
131
|
+
*
|
|
132
|
+
* {#each $todos ?? [] as todo}
|
|
133
|
+
* <p>{todo.text}</p>
|
|
134
|
+
* {/each}
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
declare function createQueryValueStore<TReference extends FunctionReference<"query">>(reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<FunctionResult<TReference> | undefined>;
|
|
138
|
+
/**
|
|
139
|
+
* Create a reactive Svelte store that emits the current value of a Syncore
|
|
140
|
+
* query, or `undefined` while loading.
|
|
141
|
+
*
|
|
142
|
+
* Accepts an explicit `client` instead of reading from Svelte context.
|
|
143
|
+
*
|
|
144
|
+
* @param client - The Syncore client to query against.
|
|
145
|
+
*/
|
|
146
|
+
declare function createClientQueryValueStore<TReference extends FunctionReference<"query">>(client: SyncoreClient, reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<FunctionResult<TReference> | undefined>;
|
|
147
|
+
/**
|
|
148
|
+
* Create a reactive Svelte store that emits the full {@link SyncoreQueryState}
|
|
149
|
+
* for a query, including `data`, `error`, `status`, and `isPending`.
|
|
150
|
+
*
|
|
151
|
+
* Uses the client from Svelte context (set via {@link setSyncoreClient}).
|
|
152
|
+
*
|
|
153
|
+
* ```svelte
|
|
154
|
+
* <script>
|
|
155
|
+
* import { createQueryStore } from "syncorejs/svelte";
|
|
156
|
+
* import { api } from "../syncore/_generated/api";
|
|
157
|
+
*
|
|
158
|
+
* const state = createQueryStore(api.todos.list);
|
|
159
|
+
* </script>
|
|
160
|
+
*
|
|
161
|
+
* {#if $state.isPending}
|
|
162
|
+
* <Spinner />
|
|
163
|
+
* {:else if $state.error}
|
|
164
|
+
* <Error message={$state.error.message} />
|
|
165
|
+
* {:else}
|
|
166
|
+
* {#each $state.data as todo}<p>{todo.text}</p>{/each}
|
|
167
|
+
* {/if}
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
declare function createQueryStore<TReference extends FunctionReference<"query">>(reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>>;
|
|
171
|
+
/**
|
|
172
|
+
* Create a reactive Svelte store that emits the full {@link SyncoreQueryState}
|
|
173
|
+
* for a query, including `data`, `error`, `status`, and `isPending`.
|
|
174
|
+
*
|
|
175
|
+
* Accepts an explicit `client` instead of reading from Svelte context.
|
|
176
|
+
*
|
|
177
|
+
* @param client - The Syncore client to query against.
|
|
178
|
+
*/
|
|
179
|
+
declare function createClientQueryStore<TReference extends FunctionReference<"query">>(client: SyncoreClient, reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>>;
|
|
180
|
+
/**
|
|
181
|
+
* Create a reactive Svelte store that simultaneously observes multiple
|
|
182
|
+
* Syncore queries.
|
|
183
|
+
*
|
|
184
|
+
* Uses the client from Svelte context (set via {@link setSyncoreClient}).
|
|
185
|
+
* Each key in `entries` corresponds to a key in the emitted result object.
|
|
186
|
+
*
|
|
187
|
+
* ```svelte
|
|
188
|
+
* <script>
|
|
189
|
+
* import { createQueriesStore } from "syncorejs/svelte";
|
|
190
|
+
* import { api } from "../syncore/_generated/api";
|
|
191
|
+
*
|
|
192
|
+
* const stores = createQueriesStore({
|
|
193
|
+
* todos: { query: api.todos.list },
|
|
194
|
+
* user: { query: api.users.me },
|
|
195
|
+
* });
|
|
196
|
+
* </script>
|
|
197
|
+
*
|
|
198
|
+
* <p>{$stores.user.data?.name} has {$stores.todos.data?.length} todos</p>
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
declare function createQueriesStore<TEntries extends QueriesRequestInput>(entries: TEntries): Readable<CreateQueriesStoreResult<TEntries>>;
|
|
202
|
+
/**
|
|
203
|
+
* Create a reactive Svelte store that simultaneously observes multiple
|
|
204
|
+
* Syncore queries.
|
|
205
|
+
*
|
|
206
|
+
* Accepts an explicit `client` instead of reading from Svelte context.
|
|
207
|
+
*
|
|
208
|
+
* @param client - The Syncore client to query against.
|
|
209
|
+
*/
|
|
210
|
+
declare function createClientQueriesStore<TEntries extends QueriesRequestInput>(client: SyncoreClient, entries: TEntries): Readable<CreateQueriesStoreResult<TEntries>>;
|
|
211
|
+
/**
|
|
212
|
+
* Create a reactive Svelte store for cursor-based paginated Syncore queries.
|
|
213
|
+
*
|
|
214
|
+
* Uses the client from Svelte context (set via {@link setSyncoreClient}).
|
|
215
|
+
* The store handles page tracking and exposes a `loadMore()` function so you
|
|
216
|
+
* can implement “Load More” UIs without manual cursor management.
|
|
217
|
+
*
|
|
218
|
+
* The query referenced by `reference` must accept a `paginationOpts`
|
|
219
|
+
* argument and return a {@link PaginationResult}.
|
|
220
|
+
*
|
|
221
|
+
* ```svelte
|
|
222
|
+
* <script>
|
|
223
|
+
* import { createPaginatedQueryStore } from "syncorejs/svelte";
|
|
224
|
+
* import { api } from "../syncore/_generated/api";
|
|
225
|
+
*
|
|
226
|
+
* const result = createPaginatedQueryStore(
|
|
227
|
+
* api.todos.listPaginated,
|
|
228
|
+
* {},
|
|
229
|
+
* { initialNumItems: 10 }
|
|
230
|
+
* );
|
|
231
|
+
* </script>
|
|
232
|
+
*
|
|
233
|
+
* {#each $result.results as todo}<p>{todo.text}</p>{/each}
|
|
234
|
+
* {#if $result.canLoadMore}
|
|
235
|
+
* <button on:click={() => $result.loadMore(10)}>Load more</button>
|
|
236
|
+
* {/if}
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @param reference - A paginated query function reference.
|
|
240
|
+
* @param args - Query arguments excluding `paginationOpts`, or `skip`.
|
|
241
|
+
* @param options.initialNumItems - Number of items to fetch on the first page.
|
|
27
242
|
*/
|
|
28
|
-
declare function
|
|
243
|
+
declare function createPaginatedQueryStore<TReference extends PaginatedQueryReference>(reference: TReference, args: PaginatedQueryArgs<TReference> | Skip, options: {
|
|
244
|
+
initialNumItems: number;
|
|
245
|
+
}): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>>;
|
|
29
246
|
/**
|
|
30
|
-
* Create a
|
|
247
|
+
* Create a reactive Svelte store for cursor-based paginated Syncore queries.
|
|
248
|
+
*
|
|
249
|
+
* Accepts an explicit `client` instead of reading from Svelte context.
|
|
250
|
+
*
|
|
251
|
+
* @param client - The Syncore client to query against.
|
|
252
|
+
* @param reference - A paginated query function reference.
|
|
253
|
+
* @param args - Query arguments excluding `paginationOpts`, or `skip`.
|
|
254
|
+
* @param options.initialNumItems - Number of items to fetch on the first page.
|
|
31
255
|
*/
|
|
32
|
-
declare function
|
|
256
|
+
declare function createClientPaginatedQueryStore<TReference extends PaginatedQueryReference>(client: SyncoreClient, reference: TReference, args: PaginatedQueryArgs<TReference> | Skip, options: {
|
|
257
|
+
initialNumItems: number;
|
|
258
|
+
}): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>>;
|
|
33
259
|
/**
|
|
34
|
-
*
|
|
260
|
+
* Creates a callable wrapper for a Syncore mutation using the contextual client.
|
|
35
261
|
*/
|
|
36
262
|
declare function createMutation<TReference extends FunctionReference<"mutation">>(reference: TReference): (...args: OptionalArgsTuple<FunctionArgs<TReference>>) => Promise<FunctionResult<TReference>>;
|
|
37
263
|
/**
|
|
38
|
-
*
|
|
264
|
+
* Creates a callable wrapper for a Syncore action using the contextual client.
|
|
39
265
|
*/
|
|
40
266
|
declare function createAction<TReference extends FunctionReference<"action">>(reference: TReference): (...args: OptionalArgsTuple<FunctionArgs<TReference>>) => Promise<FunctionResult<TReference>>;
|
|
41
267
|
//#endregion
|
|
42
|
-
export { OptionalArgsTuple, SyncoreQueryStoreState, createAction, createClientQueryStore, createMutation, createQueryStore, getSyncoreClient, setSyncoreClient };
|
|
268
|
+
export { CreateQueriesStoreResult, OptionalArgsTuple, SyncoreQueryStoreState, createAction, createClientPaginatedQueryStore, createClientQueriesStore, createClientQueryStore, createClientQueryValueStore, createClientSyncoreStatusStore, createMutation, createPaginatedQueryStore, createQueriesStore, createQueryStore, createQueryValueStore, createSyncoreStatusStore, getSyncoreClient, setSyncoreClient, skip };
|
|
43
269
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;KAoBY,iBAAA,UACV,MAAA,uBAA6B,KAAA,IAAS,IAAA,GAAO,KAAA,KAAU,IAAA,EAAM,KAAA;AAAA,KAM1D,iBAAA,oBACgB,iBAAA,YAA6B,iBAAA,aAC9C,MAAA,uBAA6B,YAAA,CAAa,UAAA;EAExC,KAAA,EAAO,UAAA;EACP,IAAA,GAAO,YAAA,CAAa,UAAA,IAAc,IAAA;AAAA;EAGlC,KAAA,EAAO,UAAA;EACP,IAAA,EAAM,YAAA,CAAa,UAAA,IAAc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