syncorejs 0.2.1 → 0.2.2
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 +323 -42
- 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/doctor.mjs +513 -46
- package/dist/_vendor/cli/doctor.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/project.mjs +110 -12
- 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 +13 -3
- package/dist/_vendor/core/cli.d.mts.map +1 -1
- package/dist/_vendor/core/cli.mjs +242 -91
- 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 +52 -41
- package/dist/_vendor/core/runtime/devtools.mjs.map +1 -1
- package/dist/_vendor/core/runtime/functions.d.mts +10 -10
- package/dist/_vendor/core/runtime/functions.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/functions.mjs +2 -2
- package/dist/_vendor/core/runtime/functions.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs +77 -0
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs +617 -0
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs +186 -0
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/schedulerEngine.mjs +220 -0
- package/dist/_vendor/core/runtime/internal/engines/schedulerEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/schemaEngine.mjs +203 -0
- package/dist/_vendor/core/runtime/internal/engines/schemaEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs +177 -0
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs +144 -0
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs.map +1 -0
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs +220 -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 +37 -0
- package/dist/_vendor/core/runtime/internal/transactionCoordinator.mjs.map +1 -0
- package/dist/_vendor/core/runtime/runtime.d.mts +159 -205
- package/dist/_vendor/core/runtime/runtime.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/runtime.mjs +16 -1371
- package/dist/_vendor/core/runtime/runtime.mjs.map +1 -1
- package/dist/_vendor/core/transport.d.mts +111 -0
- package/dist/_vendor/core/transport.d.mts.map +1 -0
- package/dist/_vendor/core/transport.mjs +419 -0
- package/dist/_vendor/core/transport.mjs.map +1 -0
- package/dist/_vendor/devtools-protocol/index.d.ts +39 -1
- 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/index.d.ts +1 -1
- package/dist/_vendor/next/index.d.ts.map +1 -1
- package/dist/_vendor/next/index.js +31 -13
- package/dist/_vendor/next/index.js.map +1 -1
- package/dist/_vendor/platform-expo/index.d.ts +12 -12
- package/dist/_vendor/platform-expo/index.d.ts.map +1 -1
- package/dist/_vendor/platform-expo/index.js +4 -2
- 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-node/index.d.mts +23 -19
- package/dist/_vendor/platform-node/index.d.mts.map +1 -1
- package/dist/_vendor/platform-node/index.mjs +13 -5
- 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 +2 -1
- package/dist/_vendor/platform-web/external-change.d.ts.map +1 -1
- package/dist/_vendor/platform-web/external-change.js +2 -1
- package/dist/_vendor/platform-web/external-change.js.map +1 -1
- package/dist/_vendor/platform-web/index.d.ts +21 -21
- package/dist/_vendor/platform-web/index.d.ts.map +1 -1
- package/dist/_vendor/platform-web/index.js +44 -7
- package/dist/_vendor/platform-web/index.js.map +1 -1
- package/dist/_vendor/platform-web/react.d.ts.map +1 -1
- package/dist/_vendor/platform-web/react.js +29 -13
- package/dist/_vendor/platform-web/react.js.map +1 -1
- package/dist/_vendor/platform-web/worker.d.ts +11 -35
- package/dist/_vendor/platform-web/worker.d.ts.map +1 -1
- package/dist/_vendor/platform-web/worker.js +3 -267
- package/dist/_vendor/platform-web/worker.js.map +1 -1
- package/dist/_vendor/react/index.d.ts +36 -20
- package/dist/_vendor/react/index.d.ts.map +1 -1
- package/dist/_vendor/react/index.js +279 -57
- package/dist/_vendor/react/index.js.map +1 -1
- package/dist/_vendor/schema/definition.d.ts +48 -63
- package/dist/_vendor/schema/definition.d.ts.map +1 -1
- package/dist/_vendor/schema/definition.js +22 -39
- 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 +141 -121
- package/dist/_vendor/schema/validators.d.ts.map +1 -1
- package/dist/_vendor/schema/validators.js +300 -42
- package/dist/_vendor/schema/validators.js.map +1 -1
- package/dist/_vendor/svelte/index.d.ts +47 -19
- package/dist/_vendor/svelte/index.d.ts.map +1 -1
- package/dist/_vendor/svelte/index.js +250 -20
- package/dist/_vendor/svelte/index.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 +8 -3
|
@@ -1,43 +1,71 @@
|
|
|
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 exposed by Syncore's Svelte stores.
|
|
8
23
|
*/
|
|
9
|
-
interface SyncoreQueryStoreState<TResult> {
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
}
|
|
24
|
+
interface SyncoreQueryStoreState<TResult> extends SyncoreQueryState<TResult> {}
|
|
25
|
+
declare const skip: "skip";
|
|
26
|
+
type Skip = typeof skip;
|
|
17
27
|
/**
|
|
18
|
-
*
|
|
28
|
+
* Stores a Syncore client in Svelte component context and returns it.
|
|
19
29
|
*/
|
|
20
30
|
declare function setSyncoreClient(client: SyncoreClient): SyncoreClient;
|
|
21
31
|
/**
|
|
22
|
-
*
|
|
32
|
+
* Reads the Syncore client previously stored in Svelte component context.
|
|
23
33
|
*/
|
|
24
34
|
declare function getSyncoreClient(): SyncoreClient;
|
|
35
|
+
declare function createSyncoreStatusStore(): Readable<SyncoreRuntimeStatus>;
|
|
36
|
+
declare function createClientSyncoreStatusStore(client: SyncoreClient): Readable<SyncoreRuntimeStatus>;
|
|
25
37
|
/**
|
|
26
|
-
*
|
|
38
|
+
* Creates a reactive store for a Syncore query result using the contextual client.
|
|
27
39
|
*/
|
|
28
|
-
declare function
|
|
40
|
+
declare function createQueryValueStore<TReference extends FunctionReference<"query">>(reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<FunctionResult<TReference> | undefined>;
|
|
29
41
|
/**
|
|
30
|
-
*
|
|
42
|
+
* Creates a reactive store for a Syncore query result using an explicit client.
|
|
31
43
|
*/
|
|
32
|
-
declare function
|
|
44
|
+
declare function createClientQueryValueStore<TReference extends FunctionReference<"query">>(client: SyncoreClient, reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<FunctionResult<TReference> | undefined>;
|
|
33
45
|
/**
|
|
34
|
-
*
|
|
46
|
+
* Creates a reactive store with the full Syncore query state.
|
|
47
|
+
*/
|
|
48
|
+
declare function createQueryStore<TReference extends FunctionReference<"query">>(reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a reactive store with the full Syncore query state for an explicit client.
|
|
51
|
+
*/
|
|
52
|
+
declare function createClientQueryStore<TReference extends FunctionReference<"query">>(client: SyncoreClient, reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>>;
|
|
53
|
+
declare function createQueriesStore<TEntries extends QueriesRequestInput>(entries: TEntries): Readable<CreateQueriesStoreResult<TEntries>>;
|
|
54
|
+
declare function createClientQueriesStore<TEntries extends QueriesRequestInput>(client: SyncoreClient, entries: TEntries): Readable<CreateQueriesStoreResult<TEntries>>;
|
|
55
|
+
declare function createPaginatedQueryStore<TReference extends PaginatedQueryReference>(reference: TReference, args: PaginatedQueryArgs<TReference> | Skip, options: {
|
|
56
|
+
initialNumItems: number;
|
|
57
|
+
}): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>>;
|
|
58
|
+
declare function createClientPaginatedQueryStore<TReference extends PaginatedQueryReference>(client: SyncoreClient, reference: TReference, args: PaginatedQueryArgs<TReference> | Skip, options: {
|
|
59
|
+
initialNumItems: number;
|
|
60
|
+
}): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>>;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a callable wrapper for a Syncore mutation using the contextual client.
|
|
35
63
|
*/
|
|
36
64
|
declare function createMutation<TReference extends FunctionReference<"mutation">>(reference: TReference): (...args: OptionalArgsTuple<FunctionArgs<TReference>>) => Promise<FunctionResult<TReference>>;
|
|
37
65
|
/**
|
|
38
|
-
*
|
|
66
|
+
* Creates a callable wrapper for a Syncore action using the contextual client.
|
|
39
67
|
*/
|
|
40
68
|
declare function createAction<TReference extends FunctionReference<"action">>(reference: TReference): (...args: OptionalArgsTuple<FunctionArgs<TReference>>) => Promise<FunctionResult<TReference>>;
|
|
41
69
|
//#endregion
|
|
42
|
-
export { OptionalArgsTuple, SyncoreQueryStoreState, createAction, createClientQueryStore, createMutation, createQueryStore, getSyncoreClient, setSyncoreClient };
|
|
70
|
+
export { CreateQueriesStoreResult, OptionalArgsTuple, SyncoreQueryStoreState, createAction, createClientPaginatedQueryStore, createClientQueriesStore, createClientQueryStore, createClientQueryValueStore, createClientSyncoreStatusStore, createMutation, createPaginatedQueryStore, createQueriesStore, createQueryStore, createQueryValueStore, createSyncoreStatusStore, getSyncoreClient, setSyncoreClient, skip };
|
|
43
71
|
//# 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,IAAA;AAAA;AAAA,KAGlC,mBAAA,GAAsB,MAAA,SAAe,iBAAA;AAAA,KAErC,kBAAA,WAA6B,MAAA,SAAe,iBAAA,qBAG7C,iBAAA,CAAkB,cAAA,CAAe,UAAA;AAAA,KAGzB,wBAAA,kBAA0C,mBAAA,qBACrC,QAAA,GAAW,kBAAA,CAAmB,QAAA,CAAS,IAAA;AAAA,KAGnD,uBAAA,GAA0B,iBAAA,UAE7B,MAAA,mBACA,gBAAA;AAAA,KAGG,kBAAA,oBAAsC,iBAAA,aACzC,YAAA,CAAa,UAAA;EAAsB,cAAA,EAAgB,iBAAA;AAAA,IAC/C,IAAA,CAAK,YAAA,CA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AA,CAAyB,QAAA;AAAA,iBAIrB,wBAAA,kBAA0C,mBAAA,CAAA,CACxD,MAAA,EAAQ,aAAA,EACR,OAAA,EAAS,QAAA,GACR,QAAA,CAAS,wBAAA,CAAyB,QAAA;AAAA,iBAoErB,yBAAA,oBACK,uBAAA,CAAA,CAEnB,SAAA,EAAW,UAAA,EACX,IAAA,EAAM,kBAAA,CAAmB,UAAA,IAAc,IAAA,EACvC,OAAA;EACE,eAAA;AAAA,IAED,QAAA,CAAS,uBAAA,CAAwB,kBAAA,CAAmB,UAAA;AAAA,iBASvC,+BAAA,oBACK,uBAAA,CAAA,CAEnB,MAAA,EAAQ,aAAA,EACR,SAAA,EAAW,UAAA,EACX,IAAA,EAAM,kBAAA,CAAmB,UAAA,IAAc,IAAA,EACvC,OAAA;EACE,eAAA;AAAA,IAED,QAAA,CAAS,uBAAA,CAAwB,kBAAA,CAAmB,UAAA;;;;iBA0LvC,cAAA,oBACK,iBAAA,aAAA,CAEnB,SAAA,EAAW,UAAA,OAER,IAAA,EAAM,iBAAA,CAAkB,YAAA,CAAa,UAAA,OACrC,OAAA,CAAQ,cAAA,CAAe,UAAA;AAjc+B;;;AAAA,iBA4c3C,YAAA,oBAAgC,iBAAA,WAAA,CAC9C,SAAA,EAAW,UAAA,OAER,IAAA,EAAM,iBAAA,CAAkB,YAAA,CAAa,UAAA,OACrC,OAAA,CAAQ,cAAA,CAAe,UAAA"}
|
|
@@ -1,62 +1,222 @@
|
|
|
1
|
-
import { readable } from "svelte/store";
|
|
1
|
+
import { derived, readable } from "svelte/store";
|
|
2
2
|
import { getContext, setContext } from "svelte";
|
|
3
3
|
//#region src/index.ts
|
|
4
|
+
const skip = "skip";
|
|
5
|
+
const defaultRuntimeStatus = {
|
|
6
|
+
kind: "starting",
|
|
7
|
+
reason: "booting"
|
|
8
|
+
};
|
|
4
9
|
const SYNCORE_CLIENT_CONTEXT = Symbol("syncore.client");
|
|
5
10
|
/**
|
|
6
|
-
*
|
|
11
|
+
* Stores a Syncore client in Svelte component context and returns it.
|
|
7
12
|
*/
|
|
8
13
|
function setSyncoreClient(client) {
|
|
9
14
|
setContext(SYNCORE_CLIENT_CONTEXT, client);
|
|
10
15
|
return client;
|
|
11
16
|
}
|
|
12
17
|
/**
|
|
13
|
-
*
|
|
18
|
+
* Reads the Syncore client previously stored in Svelte component context.
|
|
14
19
|
*/
|
|
15
20
|
function getSyncoreClient() {
|
|
16
21
|
const client = getContext(SYNCORE_CLIENT_CONTEXT);
|
|
17
22
|
if (!client) throw new Error("Syncore client is missing from the Svelte component context.");
|
|
18
23
|
return client;
|
|
19
24
|
}
|
|
25
|
+
function createSyncoreStatusStore() {
|
|
26
|
+
return createClientSyncoreStatusStore(getSyncoreClient());
|
|
27
|
+
}
|
|
28
|
+
function createClientSyncoreStatusStore(client) {
|
|
29
|
+
return readable(defaultRuntimeStatus, createStatusStoreStart(client));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a reactive store for a Syncore query result using the contextual client.
|
|
33
|
+
*/
|
|
34
|
+
function createQueryValueStore(reference, ...args) {
|
|
35
|
+
return createClientQueryValueStore(getSyncoreClient(), reference, ...args);
|
|
36
|
+
}
|
|
20
37
|
/**
|
|
21
|
-
*
|
|
38
|
+
* Creates a reactive store for a Syncore query result using an explicit client.
|
|
39
|
+
*/
|
|
40
|
+
function createClientQueryValueStore(client, reference, ...args) {
|
|
41
|
+
return derived(createClientQueryStore(client, reference, ...args), ($state) => $state.data);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a reactive store with the full Syncore query state.
|
|
22
45
|
*/
|
|
23
46
|
function createQueryStore(reference, ...args) {
|
|
24
47
|
return createClientQueryStore(getSyncoreClient(), reference, ...args);
|
|
25
48
|
}
|
|
26
49
|
/**
|
|
27
|
-
*
|
|
50
|
+
* Creates a reactive store with the full Syncore query state for an explicit client.
|
|
28
51
|
*/
|
|
29
52
|
function createClientQueryStore(client, reference, ...args) {
|
|
30
|
-
|
|
53
|
+
const isSkipped = args[0] === skip;
|
|
54
|
+
const normalizedArgs = isSkipped ? void 0 : normalizeOptionalArgs(args);
|
|
55
|
+
return readable(toQueryState({
|
|
31
56
|
data: void 0,
|
|
32
|
-
error: void 0
|
|
33
|
-
|
|
34
|
-
|
|
57
|
+
error: void 0
|
|
58
|
+
}, defaultRuntimeStatus, isSkipped), createQueryStoreStart(client, reference, normalizedArgs, isSkipped));
|
|
59
|
+
}
|
|
60
|
+
function createQueriesStore(entries) {
|
|
61
|
+
return createClientQueriesStore(getSyncoreClient(), entries);
|
|
62
|
+
}
|
|
63
|
+
function createClientQueriesStore(client, entries) {
|
|
64
|
+
const normalizedEntries = Object.entries(entries).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => ({
|
|
65
|
+
key,
|
|
66
|
+
query: entry.query,
|
|
67
|
+
skipped: entry.args === skip,
|
|
68
|
+
args: entry.args === "skip" ? {} : normalizeOptionalArgs([entry.args ?? {}])
|
|
69
|
+
}));
|
|
70
|
+
return readable({}, (set) => {
|
|
71
|
+
const runtimeWatch = client.watchRuntimeStatus();
|
|
72
|
+
const watches = normalizedEntries.map((entry) => ({
|
|
73
|
+
key: entry.key,
|
|
74
|
+
skipped: entry.skipped,
|
|
75
|
+
watch: entry.skipped ? noOpWatch : client.watchQuery(entry.query, entry.args)
|
|
76
|
+
}));
|
|
77
|
+
const publish = () => {
|
|
78
|
+
const runtimeStatus = readRuntimeStatus(runtimeWatch);
|
|
79
|
+
set(Object.fromEntries(watches.map((entry) => [entry.key, toQueryState(entry.skipped ? {
|
|
80
|
+
data: void 0,
|
|
81
|
+
error: void 0
|
|
82
|
+
} : readWatchSnapshot(entry.watch), runtimeStatus, entry.skipped)])));
|
|
83
|
+
};
|
|
84
|
+
publish();
|
|
85
|
+
const cleanups = [runtimeWatch.onUpdate(publish), ...watches.map((entry) => entry.watch.onUpdate(publish))];
|
|
86
|
+
return () => {
|
|
87
|
+
for (const cleanup of cleanups) cleanup();
|
|
88
|
+
runtimeWatch.dispose?.();
|
|
89
|
+
for (const entry of watches) if (!entry.skipped) entry.watch.dispose?.();
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function createPaginatedQueryStore(reference, args, options) {
|
|
94
|
+
return createClientPaginatedQueryStore(getSyncoreClient(), reference, args, options);
|
|
95
|
+
}
|
|
96
|
+
function createClientPaginatedQueryStore(client, reference, args, options) {
|
|
97
|
+
if (typeof options.initialNumItems !== "number" || options.initialNumItems <= 0) throw new Error(`options.initialNumItems must be a positive number. Received ${String(options.initialNumItems)}.`);
|
|
98
|
+
const isSkipped = args === skip;
|
|
99
|
+
const baseArgs = isSkipped ? {} : args ?? {};
|
|
100
|
+
return readable(createEmptyPaginatedResult(defaultRuntimeStatus), (set) => {
|
|
101
|
+
const runtimeWatch = client.watchRuntimeStatus();
|
|
102
|
+
let state = {
|
|
103
|
+
nextPageKey: 1,
|
|
104
|
+
pages: isSkipped ? [] : [{
|
|
105
|
+
key: "0",
|
|
106
|
+
cursor: null,
|
|
107
|
+
numItems: options.initialNumItems
|
|
108
|
+
}]
|
|
109
|
+
};
|
|
110
|
+
const pageEntries = /* @__PURE__ */ new Map();
|
|
111
|
+
const disposePage = (key) => {
|
|
112
|
+
const entry = pageEntries.get(key);
|
|
113
|
+
if (!entry) return;
|
|
114
|
+
entry.unsubscribe();
|
|
115
|
+
entry.watch.dispose?.();
|
|
116
|
+
pageEntries.delete(key);
|
|
117
|
+
};
|
|
118
|
+
const ensurePages = () => {
|
|
119
|
+
const activeKeys = new Set(state.pages.map((page) => page.key));
|
|
120
|
+
for (const page of state.pages) {
|
|
121
|
+
if (pageEntries.has(page.key)) continue;
|
|
122
|
+
const watch = client.watchQuery(reference, {
|
|
123
|
+
...baseArgs,
|
|
124
|
+
paginationOpts: {
|
|
125
|
+
cursor: page.cursor,
|
|
126
|
+
numItems: page.numItems
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
const unsubscribe = watch.onUpdate(publish);
|
|
130
|
+
pageEntries.set(page.key, {
|
|
131
|
+
cursor: page.cursor,
|
|
132
|
+
numItems: page.numItems,
|
|
133
|
+
watch,
|
|
134
|
+
unsubscribe
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
for (const key of [...pageEntries.keys()]) if (!activeKeys.has(key)) disposePage(key);
|
|
138
|
+
};
|
|
139
|
+
const deriveResult = (runtimeStatus) => {
|
|
140
|
+
if (isSkipped) return createEmptyPaginatedResult(runtimeStatus);
|
|
141
|
+
const pages = [];
|
|
142
|
+
let error;
|
|
143
|
+
for (const page of state.pages) {
|
|
144
|
+
const entry = pageEntries.get(page.key);
|
|
145
|
+
if (!entry) break;
|
|
146
|
+
const pageError = entry.watch.localQueryError();
|
|
147
|
+
if (pageError) {
|
|
148
|
+
error = pageError;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
const value = entry.watch.localQueryResult();
|
|
152
|
+
if (!value) break;
|
|
153
|
+
pages.push(value);
|
|
154
|
+
}
|
|
155
|
+
const results = pages.flatMap((page) => page.page);
|
|
156
|
+
const lastLoadedPage = pages.at(-1);
|
|
157
|
+
const lastRequestedPage = state.pages.at(-1);
|
|
158
|
+
const lastRequestedEntry = lastRequestedPage ? pageEntries.get(lastRequestedPage.key) : void 0;
|
|
159
|
+
const lastRequestedResult = lastRequestedEntry?.watch.localQueryResult();
|
|
160
|
+
const isLoading = pages.length === 0 && !error;
|
|
161
|
+
const isLoadingMore = state.pages.length > pages.length || !!lastRequestedEntry && !lastRequestedResult && pages.length > 0;
|
|
162
|
+
const hasMore = !!lastLoadedPage && !lastLoadedPage.isDone;
|
|
163
|
+
return {
|
|
164
|
+
results,
|
|
165
|
+
pages,
|
|
166
|
+
status: error ? "error" : isLoading ? "loading" : isLoadingMore ? "loadingMore" : hasMore ? "ready" : "exhausted",
|
|
167
|
+
error,
|
|
168
|
+
isLoading,
|
|
169
|
+
isLoadingMore,
|
|
170
|
+
hasMore,
|
|
171
|
+
cursor: lastLoadedPage?.cursor ?? null,
|
|
172
|
+
runtimeStatus,
|
|
173
|
+
loadMore(numItems = options.initialNumItems) {
|
|
174
|
+
if (error || isLoadingMore || !hasMore || !lastLoadedPage?.cursor) return;
|
|
175
|
+
state = {
|
|
176
|
+
nextPageKey: state.nextPageKey + 1,
|
|
177
|
+
pages: [...state.pages, {
|
|
178
|
+
key: String(state.nextPageKey),
|
|
179
|
+
cursor: lastLoadedPage.cursor,
|
|
180
|
+
numItems
|
|
181
|
+
}]
|
|
182
|
+
};
|
|
183
|
+
ensurePages();
|
|
184
|
+
publish();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
function publish() {
|
|
189
|
+
set(deriveResult(readRuntimeStatus(runtimeWatch)));
|
|
190
|
+
}
|
|
191
|
+
ensurePages();
|
|
192
|
+
publish();
|
|
193
|
+
const detachRuntime = runtimeWatch.onUpdate(publish);
|
|
194
|
+
return () => {
|
|
195
|
+
detachRuntime();
|
|
196
|
+
runtimeWatch.dispose?.();
|
|
197
|
+
for (const key of [...pageEntries.keys()]) disposePage(key);
|
|
198
|
+
};
|
|
199
|
+
});
|
|
35
200
|
}
|
|
36
201
|
/**
|
|
37
|
-
*
|
|
202
|
+
* Creates a callable wrapper for a Syncore mutation using the contextual client.
|
|
38
203
|
*/
|
|
39
204
|
function createMutation(reference) {
|
|
40
205
|
const client = getSyncoreClient();
|
|
41
206
|
return (...args) => client.mutation(reference, normalizeOptionalArgs(args));
|
|
42
207
|
}
|
|
43
208
|
/**
|
|
44
|
-
*
|
|
209
|
+
* Creates a callable wrapper for a Syncore action using the contextual client.
|
|
45
210
|
*/
|
|
46
211
|
function createAction(reference) {
|
|
47
212
|
const client = getSyncoreClient();
|
|
48
213
|
return (...args) => client.action(reference, normalizeOptionalArgs(args));
|
|
49
214
|
}
|
|
50
|
-
function
|
|
215
|
+
function createStatusStoreStart(client) {
|
|
51
216
|
return (set) => {
|
|
52
|
-
const watch = client.
|
|
217
|
+
const watch = client.watchRuntimeStatus();
|
|
53
218
|
const sync = () => {
|
|
54
|
-
|
|
55
|
-
set({
|
|
56
|
-
data: watch.localQueryResult(),
|
|
57
|
-
error,
|
|
58
|
-
status: error ? "error" : "ready"
|
|
59
|
-
});
|
|
219
|
+
set(readRuntimeStatus(watch));
|
|
60
220
|
};
|
|
61
221
|
sync();
|
|
62
222
|
const unsubscribe = watch.onUpdate(sync);
|
|
@@ -66,10 +226,80 @@ function createQueryStoreStart(client, reference, args) {
|
|
|
66
226
|
};
|
|
67
227
|
};
|
|
68
228
|
}
|
|
229
|
+
function createQueryStoreStart(client, reference, args, isSkipped) {
|
|
230
|
+
return (set) => {
|
|
231
|
+
const runtimeWatch = client.watchRuntimeStatus();
|
|
232
|
+
const watch = isSkipped ? noOpWatch : client.watchQuery(reference, args ?? {});
|
|
233
|
+
const sync = () => {
|
|
234
|
+
set(toQueryState(isSkipped ? {
|
|
235
|
+
data: void 0,
|
|
236
|
+
error: void 0
|
|
237
|
+
} : readWatchSnapshot(watch), readRuntimeStatus(runtimeWatch), isSkipped));
|
|
238
|
+
};
|
|
239
|
+
sync();
|
|
240
|
+
const unsubscribeWatch = watch.onUpdate(sync);
|
|
241
|
+
const unsubscribeRuntime = runtimeWatch.onUpdate(sync);
|
|
242
|
+
return () => {
|
|
243
|
+
unsubscribeWatch();
|
|
244
|
+
unsubscribeRuntime();
|
|
245
|
+
runtimeWatch.dispose?.();
|
|
246
|
+
if (!isSkipped) watch.dispose?.();
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
}
|
|
69
250
|
function normalizeOptionalArgs(args) {
|
|
70
251
|
return args[0] ?? {};
|
|
71
252
|
}
|
|
253
|
+
function readWatchSnapshot(watch) {
|
|
254
|
+
return {
|
|
255
|
+
data: watch.localQueryResult(),
|
|
256
|
+
error: watch.localQueryError()
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function readRuntimeStatus(watch) {
|
|
260
|
+
return watch.localQueryResult() ?? defaultRuntimeStatus;
|
|
261
|
+
}
|
|
262
|
+
function toQueryState(snapshot, runtimeStatus, isSkipped) {
|
|
263
|
+
if (isSkipped) return {
|
|
264
|
+
data: void 0,
|
|
265
|
+
error: void 0,
|
|
266
|
+
status: "skipped",
|
|
267
|
+
runtimeStatus,
|
|
268
|
+
isLoading: false,
|
|
269
|
+
isError: false,
|
|
270
|
+
isReady: false
|
|
271
|
+
};
|
|
272
|
+
const status = snapshot.error !== void 0 ? "error" : snapshot.data === void 0 ? "loading" : "success";
|
|
273
|
+
return {
|
|
274
|
+
data: snapshot.data,
|
|
275
|
+
error: snapshot.error,
|
|
276
|
+
status,
|
|
277
|
+
runtimeStatus,
|
|
278
|
+
isLoading: status === "loading",
|
|
279
|
+
isError: status === "error",
|
|
280
|
+
isReady: status === "success"
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function createEmptyPaginatedResult(runtimeStatus) {
|
|
284
|
+
return {
|
|
285
|
+
results: [],
|
|
286
|
+
pages: [],
|
|
287
|
+
status: "ready",
|
|
288
|
+
error: void 0,
|
|
289
|
+
isLoading: false,
|
|
290
|
+
isLoadingMore: false,
|
|
291
|
+
hasMore: false,
|
|
292
|
+
cursor: null,
|
|
293
|
+
runtimeStatus,
|
|
294
|
+
loadMore() {}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
const noOpWatch = {
|
|
298
|
+
onUpdate: () => () => void 0,
|
|
299
|
+
localQueryResult: () => void 0,
|
|
300
|
+
localQueryError: () => void 0
|
|
301
|
+
};
|
|
72
302
|
//#endregion
|
|
73
|
-
export { createAction, createClientQueryStore, createMutation, createQueryStore, getSyncoreClient, setSyncoreClient };
|
|
303
|
+
export { createAction, createClientPaginatedQueryStore, createClientQueriesStore, createClientQueryStore, createClientQueryValueStore, createClientSyncoreStatusStore, createMutation, createPaginatedQueryStore, createQueriesStore, createQueryStore, createQueryValueStore, createSyncoreStatusStore, getSyncoreClient, setSyncoreClient, skip };
|
|
74
304
|
|
|
75
305
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type Readable, type StartStopNotifier, readable } from \"svelte/store\";\nimport { getContext, setContext } from \"svelte\";\nimport type {\n FunctionArgs,\n FunctionReference,\n FunctionResult,\n SyncoreClient,\n SyncoreWatch\n} from \"@syncore/core\";\n\nexport type OptionalArgsTuple<TArgs> =\n Record<never, never> extends TArgs ? [args?: TArgs] : [args: TArgs];\n\n/**\n * The observable state exposed by a Syncore-backed Svelte query store.\n */\nexport interface SyncoreQueryStoreState<TResult> {\n /** The latest local result for the watched query. */\n data: TResult | undefined;\n\n /** The latest local error for the watched query, if any. */\n error: Error | undefined;\n\n /** The current watch lifecycle status. */\n status: \"loading\" | \"ready\" | \"error\";\n}\n\nconst SYNCORE_CLIENT_CONTEXT = Symbol(\"syncore.client\");\n\n/**\n * Store a Syncore client in the current Svelte component context.\n */\nexport function setSyncoreClient(client: SyncoreClient): SyncoreClient {\n setContext(SYNCORE_CLIENT_CONTEXT, client);\n return client;\n}\n\n/**\n * Read the active Syncore client from the current Svelte component context.\n */\nexport function getSyncoreClient(): SyncoreClient {\n const client = getContext<SyncoreClient | undefined>(SYNCORE_CLIENT_CONTEXT);\n if (!client) {\n throw new Error(\n \"Syncore client is missing from the Svelte component context.\"\n );\n }\n return client;\n}\n\n/**\n * Create a readable Svelte store backed by a reactive Syncore query.\n */\nexport function createQueryStore<TReference extends FunctionReference<\"query\">>(\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>>\n): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n return createClientQueryStore(getSyncoreClient(), reference, ...args);\n}\n\n/**\n * Create a readable Svelte store backed by a reactive Syncore query.\n */\nexport function createClientQueryStore<\n TReference extends FunctionReference<\"query\">\n>(\n client: SyncoreClient,\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>>\n): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n const normalizedArgs = normalizeOptionalArgs(args);\n return readable<SyncoreQueryStoreState<FunctionResult<TReference>>>(\n {\n data: undefined,\n error: undefined,\n status: \"loading\"\n },\n createQueryStoreStart(client, reference, normalizedArgs)\n );\n}\n\n/**\n * Create a function that executes a Syncore mutation.\n */\nexport function createMutation<\n TReference extends FunctionReference<\"mutation\">\n>(\n reference: TReference\n): (\n ...args: OptionalArgsTuple<FunctionArgs<TReference>>\n) => Promise<FunctionResult<TReference>> {\n const client = getSyncoreClient();\n return (...args) =>\n client.mutation(reference, normalizeOptionalArgs(args)) as Promise<\n FunctionResult<TReference>\n >;\n}\n\n/**\n * Create a function that executes a Syncore action.\n */\nexport function createAction<TReference extends FunctionReference<\"action\">>(\n reference: TReference\n): (\n ...args: OptionalArgsTuple<FunctionArgs<TReference>>\n) => Promise<FunctionResult<TReference>> {\n const client = getSyncoreClient();\n return (...args) =>\n client.action(reference, normalizeOptionalArgs(args)) as Promise<\n FunctionResult<TReference>\n >;\n}\n\nfunction createQueryStoreStart<TReference extends FunctionReference<\"query\">>(\n client: SyncoreClient,\n reference: TReference,\n args: FunctionArgs<TReference>\n): StartStopNotifier<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n return (\n set: (value: SyncoreQueryStoreState<FunctionResult<TReference>>) => void\n ) => {\n const watch = client.watchQuery(reference, args) as SyncoreWatch<\n FunctionResult<TReference>\n >;\n const sync = () => {\n const error = watch.localQueryError();\n set({\n data: watch.localQueryResult(),\n error,\n status: error ? \"error\" : \"ready\"\n });\n };\n sync();\n const unsubscribe = watch.onUpdate(sync);\n return () => {\n unsubscribe();\n watch.dispose?.();\n };\n };\n}\n\nfunction normalizeOptionalArgs<TArgs>(\n args: [] | [TArgs] | readonly unknown[]\n): TArgs {\n return (args[0] ?? {}) as TArgs;\n}\n"],"mappings":";;;AA2BA,MAAM,yBAAyB,OAAO,iBAAiB;;;;AAKvD,SAAgB,iBAAiB,QAAsC;AACrE,YAAW,wBAAwB,OAAO;AAC1C,QAAO;;;;;AAMT,SAAgB,mBAAkC;CAChD,MAAM,SAAS,WAAsC,uBAAuB;AAC5E,KAAI,CAAC,OACH,OAAM,IAAI,MACR,+DACD;AAEH,QAAO;;;;;AAMT,SAAgB,iBACd,WACA,GAAG,MAC2D;AAC9D,QAAO,uBAAuB,kBAAkB,EAAE,WAAW,GAAG,KAAK;;;;;AAMvE,SAAgB,uBAGd,QACA,WACA,GAAG,MAC2D;AAE9D,QAAO,SACL;EACE,MAAM,KAAA;EACN,OAAO,KAAA;EACP,QAAQ;EACT,EACD,sBAAsB,QAAQ,WAPT,sBAAsB,KAAK,CAOQ,CACzD;;;;;AAMH,SAAgB,eAGd,WAGuC;CACvC,MAAM,SAAS,kBAAkB;AACjC,SAAQ,GAAG,SACT,OAAO,SAAS,WAAW,sBAAsB,KAAK,CAAC;;;;;AAQ3D,SAAgB,aACd,WAGuC;CACvC,MAAM,SAAS,kBAAkB;AACjC,SAAQ,GAAG,SACT,OAAO,OAAO,WAAW,sBAAsB,KAAK,CAAC;;AAKzD,SAAS,sBACP,QACA,WACA,MACuE;AACvE,SACE,QACG;EACH,MAAM,QAAQ,OAAO,WAAW,WAAW,KAAK;EAGhD,MAAM,aAAa;GACjB,MAAM,QAAQ,MAAM,iBAAiB;AACrC,OAAI;IACF,MAAM,MAAM,kBAAkB;IAC9B;IACA,QAAQ,QAAQ,UAAU;IAC3B,CAAC;;AAEJ,QAAM;EACN,MAAM,cAAc,MAAM,SAAS,KAAK;AACxC,eAAa;AACX,gBAAa;AACb,SAAM,WAAW;;;;AAKvB,SAAS,sBACP,MACO;AACP,QAAQ,KAAK,MAAM,EAAE"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n derived,\n type Readable,\n readable,\n type StartStopNotifier\n} from \"svelte/store\";\nimport { getContext, setContext } from \"svelte\";\nimport type {\n FunctionArgs,\n FunctionReference,\n FunctionResult,\n PaginationOptions,\n PaginationResult,\n SyncoreClient,\n SyncoreQueryState,\n SyncoreRuntimeStatus,\n SyncoreWatch,\n UsePaginatedQueryResult\n} from \"@syncore/core\";\n\nexport type OptionalArgsTuple<TArgs> =\n Record<never, never> extends TArgs ? [args?: TArgs] : [args: TArgs];\n\ntype ManagedSyncoreWatch<TResult> = SyncoreWatch<TResult> & {\n dispose?: () => void;\n};\n\ntype QueryRequestInput<\n TReference extends FunctionReference<\"query\"> = FunctionReference<\"query\">\n> = Record<never, never> extends FunctionArgs<TReference>\n ? {\n query: TReference;\n args?: FunctionArgs<TReference> | Skip;\n }\n : {\n query: TReference;\n args: FunctionArgs<TReference> | Skip;\n };\n\ntype QueriesRequestInput = Record<string, QueryRequestInput>;\n\ntype QueryStateForEntry<TEntry> = TEntry extends QueryRequestInput<\n infer TReference\n>\n ? SyncoreQueryState<FunctionResult<TReference>>\n : never;\n\nexport type CreateQueriesStoreResult<TEntries extends QueriesRequestInput> = {\n [TKey in keyof TEntries]: QueryStateForEntry<TEntries[TKey]>;\n};\n\ntype PaginatedQueryReference = FunctionReference<\n \"query\",\n Record<string, unknown>,\n PaginationResult<unknown>\n>;\n\ntype PaginatedQueryArgs<TReference extends FunctionReference<\"query\">> =\n FunctionArgs<TReference> extends { paginationOpts: PaginationOptions }\n ? Omit<FunctionArgs<TReference>, \"paginationOpts\">\n : never;\n\ntype PaginatedQueryItem<TReference extends FunctionReference<\"query\">> =\n FunctionResult<TReference> extends PaginationResult<infer TItem>\n ? TItem\n : never;\n\ntype PaginatedQueryInternalState = {\n nextPageKey: number;\n pages: Array<{\n key: string;\n cursor: string | null;\n numItems: number;\n }>;\n};\n\n/**\n * The reactive query state shape exposed by Syncore's Svelte stores.\n */\nexport interface SyncoreQueryStoreState<TResult>\n extends SyncoreQueryState<TResult> {}\n\nexport const skip = \"skip\" as const;\ntype Skip = typeof skip;\n\nconst defaultRuntimeStatus: SyncoreRuntimeStatus = {\n kind: \"starting\",\n reason: \"booting\"\n};\n\nconst SYNCORE_CLIENT_CONTEXT = Symbol(\"syncore.client\");\n\n/**\n * Stores a Syncore client in Svelte component context and returns it.\n */\nexport function setSyncoreClient(client: SyncoreClient): SyncoreClient {\n setContext(SYNCORE_CLIENT_CONTEXT, client);\n return client;\n}\n\n/**\n * Reads the Syncore client previously stored in Svelte component context.\n */\nexport function getSyncoreClient(): SyncoreClient {\n const client = getContext<SyncoreClient | undefined>(SYNCORE_CLIENT_CONTEXT);\n if (!client) {\n throw new Error(\n \"Syncore client is missing from the Svelte component context.\"\n );\n }\n return client;\n}\n\nexport function createSyncoreStatusStore(): Readable<SyncoreRuntimeStatus> {\n return createClientSyncoreStatusStore(getSyncoreClient());\n}\n\nexport function createClientSyncoreStatusStore(\n client: SyncoreClient\n): Readable<SyncoreRuntimeStatus> {\n return readable<SyncoreRuntimeStatus>(\n defaultRuntimeStatus,\n createStatusStoreStart(client)\n );\n}\n\n/**\n * Creates a reactive store for a Syncore query result using the contextual client.\n */\nexport function createQueryValueStore<\n TReference extends FunctionReference<\"query\">\n>(\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<FunctionResult<TReference> | undefined> {\n return createClientQueryValueStore(getSyncoreClient(), reference, ...args);\n}\n\n/**\n * Creates a reactive store for a Syncore query result using an explicit client.\n */\nexport function createClientQueryValueStore<\n TReference extends FunctionReference<\"query\">\n>(\n client: SyncoreClient,\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<FunctionResult<TReference> | undefined> {\n return derived(\n createClientQueryStore(client, reference, ...(args as OptionalArgsTuple<\n FunctionArgs<TReference>\n > | [Skip])),\n ($state) => $state.data\n );\n}\n\n/**\n * Creates a reactive store with the full Syncore query state.\n */\nexport function createQueryStore<TReference extends FunctionReference<\"query\">>(\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n return createClientQueryStore(getSyncoreClient(), reference, ...args);\n}\n\n/**\n * Creates a reactive store with the full Syncore query state for an explicit client.\n */\nexport function createClientQueryStore<\n TReference extends FunctionReference<\"query\">\n>(\n client: SyncoreClient,\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n const isSkipped = args[0] === skip;\n const normalizedArgs = isSkipped\n ? undefined\n : normalizeOptionalArgs(args as OptionalArgsTuple<FunctionArgs<TReference>>);\n return readable<SyncoreQueryStoreState<FunctionResult<TReference>>>(\n toQueryState<FunctionResult<TReference>>(\n {\n data: undefined,\n error: undefined\n },\n defaultRuntimeStatus,\n isSkipped\n ),\n createQueryStoreStart(client, reference, normalizedArgs, isSkipped)\n );\n}\n\nexport function createQueriesStore<TEntries extends QueriesRequestInput>(\n entries: TEntries\n): Readable<CreateQueriesStoreResult<TEntries>> {\n return createClientQueriesStore(getSyncoreClient(), entries);\n}\n\nexport function createClientQueriesStore<TEntries extends QueriesRequestInput>(\n client: SyncoreClient,\n entries: TEntries\n): Readable<CreateQueriesStoreResult<TEntries>> {\n const normalizedEntries = Object.entries(entries)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, entry]) => ({\n key,\n query: entry.query,\n skipped: entry.args === skip,\n args:\n entry.args === skip\n ? {}\n : normalizeOptionalArgs([entry.args ?? {}] as [] | [unknown])\n }));\n\n return readable<CreateQueriesStoreResult<TEntries>>(\n {} as CreateQueriesStoreResult<TEntries>,\n (set) => {\n const runtimeWatch = client.watchRuntimeStatus();\n const watches = normalizedEntries.map((entry) => ({\n key: entry.key,\n skipped: entry.skipped,\n watch: entry.skipped\n ? (noOpWatch as ManagedSyncoreWatch<unknown>)\n : (client.watchQuery(entry.query, entry.args) as ManagedSyncoreWatch<\n unknown\n >)\n }));\n const publish = () => {\n const runtimeStatus = readRuntimeStatus(runtimeWatch);\n set(\n Object.fromEntries(\n watches.map((entry) => [\n entry.key,\n toQueryState(\n entry.skipped\n ? {\n data: undefined,\n error: undefined\n }\n : readWatchSnapshot(entry.watch),\n runtimeStatus,\n entry.skipped\n )\n ])\n ) as CreateQueriesStoreResult<TEntries>\n );\n };\n\n publish();\n const cleanups = [\n runtimeWatch.onUpdate(publish),\n ...watches.map((entry) => entry.watch.onUpdate(publish))\n ];\n\n return () => {\n for (const cleanup of cleanups) {\n cleanup();\n }\n runtimeWatch.dispose?.();\n for (const entry of watches) {\n if (!entry.skipped) {\n entry.watch.dispose?.();\n }\n }\n };\n }\n );\n}\n\nexport function createPaginatedQueryStore<\n TReference extends PaginatedQueryReference\n>(\n reference: TReference,\n args: PaginatedQueryArgs<TReference> | Skip,\n options: {\n initialNumItems: number;\n }\n): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>> {\n return createClientPaginatedQueryStore(\n getSyncoreClient(),\n reference,\n args,\n options\n );\n}\n\nexport function createClientPaginatedQueryStore<\n TReference extends PaginatedQueryReference\n>(\n client: SyncoreClient,\n reference: TReference,\n args: PaginatedQueryArgs<TReference> | Skip,\n options: {\n initialNumItems: number;\n }\n): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>> {\n if (\n typeof options.initialNumItems !== \"number\" ||\n options.initialNumItems <= 0\n ) {\n throw new Error(\n `options.initialNumItems must be a positive number. Received ${String(\n options.initialNumItems\n )}.`\n );\n }\n\n const isSkipped = args === skip;\n const baseArgs = isSkipped ? {} : (args ?? {});\n\n return readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>>(\n createEmptyPaginatedResult(defaultRuntimeStatus),\n (set) => {\n const runtimeWatch = client.watchRuntimeStatus();\n let state: PaginatedQueryInternalState = {\n nextPageKey: 1,\n pages: isSkipped\n ? []\n : [\n {\n key: \"0\",\n cursor: null,\n numItems: options.initialNumItems\n }\n ]\n };\n const pageEntries = new Map<\n string,\n {\n cursor: string | null;\n numItems: number;\n watch: ManagedSyncoreWatch<PaginationResult<PaginatedQueryItem<TReference>>>;\n unsubscribe: () => void;\n }\n >();\n\n const disposePage = (key: string) => {\n const entry = pageEntries.get(key);\n if (!entry) {\n return;\n }\n entry.unsubscribe();\n entry.watch.dispose?.();\n pageEntries.delete(key);\n };\n\n const ensurePages = () => {\n const activeKeys = new Set(state.pages.map((page) => page.key));\n for (const page of state.pages) {\n if (pageEntries.has(page.key)) {\n continue;\n }\n const watch = client.watchQuery(reference, {\n ...(baseArgs as Record<string, unknown>),\n paginationOpts: {\n cursor: page.cursor,\n numItems: page.numItems\n }\n }) as ManagedSyncoreWatch<PaginationResult<PaginatedQueryItem<TReference>>>;\n const unsubscribe = watch.onUpdate(publish);\n pageEntries.set(page.key, {\n cursor: page.cursor,\n numItems: page.numItems,\n watch,\n unsubscribe\n });\n }\n for (const key of [...pageEntries.keys()]) {\n if (!activeKeys.has(key)) {\n disposePage(key);\n }\n }\n };\n\n const deriveResult = (\n runtimeStatus: SyncoreRuntimeStatus\n ): UsePaginatedQueryResult<PaginatedQueryItem<TReference>> => {\n if (isSkipped) {\n return createEmptyPaginatedResult(runtimeStatus);\n }\n\n const pages: Array<PaginationResult<PaginatedQueryItem<TReference>>> = [];\n let error: Error | undefined;\n\n for (const page of state.pages) {\n const entry = pageEntries.get(page.key);\n if (!entry) {\n break;\n }\n const pageError = entry.watch.localQueryError();\n if (pageError) {\n error = pageError;\n break;\n }\n const value = entry.watch.localQueryResult();\n if (!value) {\n break;\n }\n pages.push(value);\n }\n\n const results = pages.flatMap((page) => page.page);\n const lastLoadedPage = pages.at(-1);\n const lastRequestedPage = state.pages.at(-1);\n const lastRequestedEntry = lastRequestedPage\n ? pageEntries.get(lastRequestedPage.key)\n : undefined;\n const lastRequestedResult = lastRequestedEntry?.watch.localQueryResult();\n const isLoading = pages.length === 0 && !error;\n const isLoadingMore =\n state.pages.length > pages.length ||\n (!!lastRequestedEntry && !lastRequestedResult && pages.length > 0);\n const hasMore = !!lastLoadedPage && !lastLoadedPage.isDone;\n const status = error\n ? \"error\"\n : isLoading\n ? \"loading\"\n : isLoadingMore\n ? \"loadingMore\"\n : hasMore\n ? \"ready\"\n : \"exhausted\";\n\n return {\n results,\n pages,\n status,\n error,\n isLoading,\n isLoadingMore,\n hasMore,\n cursor: lastLoadedPage?.cursor ?? null,\n runtimeStatus,\n loadMore(numItems = options.initialNumItems) {\n if (\n error ||\n isLoadingMore ||\n !hasMore ||\n !lastLoadedPage?.cursor\n ) {\n return;\n }\n state = {\n nextPageKey: state.nextPageKey + 1,\n pages: [\n ...state.pages,\n {\n key: String(state.nextPageKey),\n cursor: lastLoadedPage.cursor,\n numItems\n }\n ]\n };\n ensurePages();\n publish();\n }\n };\n };\n\n function publish() {\n set(deriveResult(readRuntimeStatus(runtimeWatch)));\n }\n\n ensurePages();\n publish();\n const detachRuntime = runtimeWatch.onUpdate(publish);\n\n return () => {\n detachRuntime();\n runtimeWatch.dispose?.();\n for (const key of [...pageEntries.keys()]) {\n disposePage(key);\n }\n };\n }\n );\n}\n\n/**\n * Creates a callable wrapper for a Syncore mutation using the contextual client.\n */\nexport function createMutation<\n TReference extends FunctionReference<\"mutation\">\n>(\n reference: TReference\n): (\n ...args: OptionalArgsTuple<FunctionArgs<TReference>>\n) => Promise<FunctionResult<TReference>> {\n const client = getSyncoreClient();\n return (...args) =>\n client.mutation(reference, normalizeOptionalArgs(args)) as Promise<\n FunctionResult<TReference>\n >;\n}\n\n/**\n * Creates a callable wrapper for a Syncore action using the contextual client.\n */\nexport function createAction<TReference extends FunctionReference<\"action\">>(\n reference: TReference\n): (\n ...args: OptionalArgsTuple<FunctionArgs<TReference>>\n) => Promise<FunctionResult<TReference>> {\n const client = getSyncoreClient();\n return (...args) =>\n client.action(reference, normalizeOptionalArgs(args)) as Promise<\n FunctionResult<TReference>\n >;\n}\n\nfunction createStatusStoreStart(\n client: SyncoreClient\n): StartStopNotifier<SyncoreRuntimeStatus> {\n return (set) => {\n const watch = client.watchRuntimeStatus();\n const sync = () => {\n set(readRuntimeStatus(watch));\n };\n sync();\n const unsubscribe = watch.onUpdate(sync);\n return () => {\n unsubscribe();\n watch.dispose?.();\n };\n };\n}\n\nfunction createQueryStoreStart<TReference extends FunctionReference<\"query\">>(\n client: SyncoreClient,\n reference: TReference,\n args: FunctionArgs<TReference> | undefined,\n isSkipped: boolean\n): StartStopNotifier<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n return (\n set: (value: SyncoreQueryStoreState<FunctionResult<TReference>>) => void\n ) => {\n const runtimeWatch = client.watchRuntimeStatus();\n const watch = isSkipped\n ? (noOpWatch as ManagedSyncoreWatch<FunctionResult<TReference>>)\n : (client.watchQuery(reference, args ?? {}) as ManagedSyncoreWatch<\n FunctionResult<TReference>\n >);\n const sync = () => {\n set(\n toQueryState(\n isSkipped\n ? {\n data: undefined,\n error: undefined\n }\n : readWatchSnapshot(watch),\n readRuntimeStatus(runtimeWatch),\n isSkipped\n )\n );\n };\n sync();\n const unsubscribeWatch = watch.onUpdate(sync);\n const unsubscribeRuntime = runtimeWatch.onUpdate(sync);\n return () => {\n unsubscribeWatch();\n unsubscribeRuntime();\n runtimeWatch.dispose?.();\n if (!isSkipped) {\n watch.dispose?.();\n }\n };\n };\n}\n\nfunction normalizeOptionalArgs<TArgs>(\n args: [] | [TArgs] | readonly unknown[]\n): TArgs {\n return (args[0] ?? {}) as TArgs;\n}\n\nfunction readWatchSnapshot<TResult>(watch: SyncoreWatch<TResult>): {\n data: TResult | undefined;\n error: Error | undefined;\n} {\n return {\n data: watch.localQueryResult(),\n error: watch.localQueryError()\n };\n}\n\nfunction readRuntimeStatus(\n watch: SyncoreWatch<SyncoreRuntimeStatus>\n): SyncoreRuntimeStatus {\n return watch.localQueryResult() ?? defaultRuntimeStatus;\n}\n\nfunction toQueryState<TResult>(\n snapshot: {\n data: TResult | undefined;\n error: Error | undefined;\n },\n runtimeStatus: SyncoreRuntimeStatus,\n isSkipped: boolean\n): SyncoreQueryState<TResult> {\n if (isSkipped) {\n return {\n data: undefined,\n error: undefined,\n status: \"skipped\",\n runtimeStatus,\n isLoading: false,\n isError: false,\n isReady: false\n };\n }\n\n const status =\n snapshot.error !== undefined\n ? \"error\"\n : snapshot.data === undefined\n ? \"loading\"\n : \"success\";\n\n return {\n data: snapshot.data,\n error: snapshot.error,\n status,\n runtimeStatus,\n isLoading: status === \"loading\",\n isError: status === \"error\",\n isReady: status === \"success\"\n };\n}\n\nfunction createEmptyPaginatedResult<TItem>(\n runtimeStatus: SyncoreRuntimeStatus\n): UsePaginatedQueryResult<TItem> {\n return {\n results: [],\n pages: [],\n status: \"ready\",\n error: undefined,\n isLoading: false,\n isLoadingMore: false,\n hasMore: false,\n cursor: null,\n runtimeStatus,\n loadMore() {\n return;\n }\n };\n}\n\nconst noOpWatch: ManagedSyncoreWatch<never> = {\n onUpdate: () => () => undefined,\n localQueryResult: () => undefined,\n localQueryError: () => undefined\n};\n"],"mappings":";;;AAkFA,MAAa,OAAO;AAGpB,MAAM,uBAA6C;CACjD,MAAM;CACN,QAAQ;CACT;AAED,MAAM,yBAAyB,OAAO,iBAAiB;;;;AAKvD,SAAgB,iBAAiB,QAAsC;AACrE,YAAW,wBAAwB,OAAO;AAC1C,QAAO;;;;;AAMT,SAAgB,mBAAkC;CAChD,MAAM,SAAS,WAAsC,uBAAuB;AAC5E,KAAI,CAAC,OACH,OAAM,IAAI,MACR,+DACD;AAEH,QAAO;;AAGT,SAAgB,2BAA2D;AACzE,QAAO,+BAA+B,kBAAkB,CAAC;;AAG3D,SAAgB,+BACd,QACgC;AAChC,QAAO,SACL,sBACA,uBAAuB,OAAO,CAC/B;;;;;AAMH,SAAgB,sBAGd,WACA,GAAG,MAC+C;AAClD,QAAO,4BAA4B,kBAAkB,EAAE,WAAW,GAAG,KAAK;;;;;AAM5E,SAAgB,4BAGd,QACA,WACA,GAAG,MAC+C;AAClD,QAAO,QACL,uBAAuB,QAAQ,WAAW,GAAI,KAElC,GACX,WAAW,OAAO,KACpB;;;;;AAMH,SAAgB,iBACd,WACA,GAAG,MAC2D;AAC9D,QAAO,uBAAuB,kBAAkB,EAAE,WAAW,G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AoB;AACpB,gBAAa,WAAW;AACxB,OAAI,CAAC,UACH,OAAM,WAAW;;;;AAMzB,SAAS,sBACP,MACO;AACP,QAAQ,KAAK,MAAM,EAAE;;AAGvB,SAAS,kBAA2B,OAGlC;AACA,QAAO;EACL,MAAM,MAAM,kBAAkB;EAC9B,OAAO,MAAM,iBAAiB;EAC/B;;AAGH,SAAS,kBACP,OACsB;AACtB,QAAO,MAAM,kBAAkB,IAAI;;AAGrC,SAAS,aACP,UAIA,eACA,WAC4B;AAC5B,KAAI,UACF,QAAO;EACL,MAAM,KAAA;EACN,OAAO,KAAA;EACP,QAAQ;EACR;EACA,WAAW;EACX,SAAS;EACT,SAAS;EACV;CAGH,MAAM,SACJ,SAAS,UAAU,KAAA,IACf,UACA,SAAS,SAAS,KAAA,IAChB,YACA;AAER,QAAO;EACL,MAAM,SAAS;EACf,OAAO,SAAS;EAChB;EACA;EACA,WAAW,WAAW;EACtB,SAAS,WAAW;EACpB,SAAS,WAAW;EACrB;;AAGH,SAAS,2BACP,eACgC;AAChC,QAAO;EACL,SAAS,EAAE;EACX,OAAO,EAAE;EACT,QAAQ;EACR,OAAO,KAAA;EACP,WAAW;EACX,eAAe;EACf,SAAS;EACT,QAAQ;EACR;EACA,WAAW;EAGZ;;AAGH,MAAM,YAAwC;CAC5C,sBAAsB,KAAA;CACtB,wBAAwB,KAAA;CACxB,uBAAuB,KAAA;CACxB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ComponentPath, FunctionReferencesForTree, InstalledComponentApi, InstalledComponentsApi, ResolvedSyncoreComponent, SyncoreComponent, SyncoreComponentFunctionMetadata, SyncoreComponentHookContext, SyncoreComponentInstall, SyncoreComponentsManifest, SyncoreCoreCapability, SyncoreFunctionTree, SyncoreHostServiceName, SyncoreRequestedCapability, composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createInstalledComponentsApi, defineComponent, defineComponents, installComponent, resolveComponentsManifest, toCanonicalComponentFunctionName } from "./_vendor/core/index.d.mts";
|
|
2
|
+
export { type ComponentPath, type FunctionReferencesForTree, type InstalledComponentApi, type InstalledComponentsApi, type ResolvedSyncoreComponent, type SyncoreComponent, type SyncoreComponentFunctionMetadata, type SyncoreComponentHookContext, type SyncoreComponentInstall, type SyncoreComponentsManifest, type SyncoreCoreCapability, type SyncoreFunctionTree, type SyncoreHostServiceName, type SyncoreRequestedCapability, composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createInstalledComponentsApi, defineComponent, defineComponents, installComponent, resolveComponentsManifest, toCanonicalComponentFunctionName };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createInstalledComponentsApi, defineComponent, defineComponents, installComponent, resolveComponentsManifest, toCanonicalComponentFunctionName } from "./_vendor/core/index.mjs";
|
|
2
|
+
export { composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createInstalledComponentsApi, defineComponent, defineComponents, installComponent, resolveComponentsManifest, toCanonicalComponentFunctionName };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPath, FunctionReferencesForTree, InstalledComponentApi, InstalledComponentsApi, ResolvedSyncoreComponent, SyncoreComponent, SyncoreComponentFunctionMetadata, SyncoreComponentHookContext, SyncoreComponentInstall, SyncoreComponentsManifest, SyncoreCoreCapability, SyncoreFunctionTree, SyncoreHostServiceName, SyncoreRequestedCapability, composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createInstalledComponentsApi, defineComponent, defineComponents, installComponent, resolveComponentsManifest, toCanonicalComponentFunctionName } from "./components.js";
|
|
2
|
+
import { ActionCtx, ComparisonOperator, CronJobs, DevtoolsSink, DocumentForTable, EmptyArgs, FilterBuilder, FunctionArgs, FunctionArgsFromDefinition, FunctionConfig, FunctionKindFromDefinition, FunctionReference, FunctionReferenceFor, FunctionResult, FunctionResultFromDefinition, IndexRangeBuilder, InferArgs, InsertValueForTable, JsonObject, MisfirePolicy, MutationCtx, PaginationOptions, PaginationResult, QueryBuilder, QueryCondition, QueryCtx, QueryExpression, RecurringDailySchedule, RecurringIntervalSchedule, RecurringJobDefinition, RecurringSchedule, RecurringWeeklySchedule, RegisteredSyncoreFunction, RegisteredSyncoreHandler, RunResult, SchedulerApi, SchedulerOptions, SearchIndexBuilder, SearchQuery, StorageObject, StorageWriteInput, SyncoreCapabilities, SyncoreClient, SyncoreDatabaseReader, SyncoreDatabaseWriter, SyncoreFunctionDefinition, SyncoreFunctionKind, SyncoreFunctionRegistry, SyncoreResolvedComponents, SyncoreRuntime, SyncoreRuntimeOptions, SyncoreSqlDriver, SyncoreStorageAdapter, SyncoreStorageApi, SyncoreWatch, TableNames, action, createFunctionReference, createFunctionReferenceFor, cronJobs, generateId, mutation, query } from "./_vendor/core/index.d.mts";
|
|
2
3
|
export * from "./_vendor/schema/index.d.ts";
|
|
3
|
-
export { type ActionCtx, type
|
|
4
|
+
export { type ActionCtx, type ComparisonOperator, ComponentPath, type CronJobs, type DevtoolsSink, type DocumentForTable, type EmptyArgs, type FilterBuilder, type FunctionArgs, type FunctionArgsFromDefinition, type FunctionConfig, type FunctionKindFromDefinition, type FunctionReference, type FunctionReferenceFor, FunctionReferencesForTree, type FunctionResult, type FunctionResultFromDefinition, type IndexRangeBuilder, type InferArgs, type InsertValueForTable, InstalledComponentApi, InstalledComponentsApi, type JsonObject, type MisfirePolicy, type MutationCtx, type PaginationOptions, type PaginationResult, type QueryBuilder, type QueryCondition, type QueryCtx, type QueryExpression, type RecurringDailySchedule, type RecurringIntervalSchedule, type RecurringJobDefinition, type RecurringSchedule, type RecurringWeeklySchedule, type RegisteredSyncoreFunction, type RegisteredSyncoreHandler, ResolvedSyncoreComponent, type RunResult, type SchedulerApi, type SchedulerOptions, type SearchIndexBuilder, type SearchQuery, type StorageObject, type StorageWriteInput, type SyncoreCapabilities, type SyncoreClient, SyncoreComponent, SyncoreComponentFunctionMetadata, SyncoreComponentHookContext, SyncoreComponentInstall, SyncoreComponentsManifest, SyncoreCoreCapability, type SyncoreDatabaseReader, type SyncoreDatabaseWriter, type SyncoreFunctionDefinition, type SyncoreFunctionKind, type SyncoreFunctionRegistry, SyncoreFunctionTree, SyncoreHostServiceName, SyncoreRequestedCapability, type SyncoreResolvedComponents, SyncoreRuntime, type SyncoreRuntimeOptions, type SyncoreSqlDriver, type SyncoreStorageAdapter, type SyncoreStorageApi, type SyncoreWatch, type TableNames, action, composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createFunctionReference, createFunctionReferenceFor, createInstalledComponentsApi, cronJobs, defineComponent, defineComponents, generateId, installComponent, mutation, query, resolveComponentsManifest, toCanonicalComponentFunctionName };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createInstalledComponentsApi, defineComponent, defineComponents, installComponent, resolveComponentsManifest, toCanonicalComponentFunctionName } from "./components.js";
|
|
1
2
|
import { SyncoreRuntime, action, createFunctionReference, createFunctionReferenceFor, cronJobs, generateId, mutation, query } from "./_vendor/core/index.mjs";
|
|
2
3
|
export * from "./_vendor/schema/index.js";
|
|
3
|
-
export { SyncoreRuntime, action, createFunctionReference, createFunctionReferenceFor, cronJobs, generateId, mutation, query };
|
|
4
|
+
export { SyncoreRuntime, action, composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createFunctionReference, createFunctionReferenceFor, createInstalledComponentsApi, cronJobs, defineComponent, defineComponents, generateId, installComponent, mutation, query, resolveComponentsManifest, toCanonicalComponentFunctionName };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "syncorejs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Local-first reactive backend toolkit for offline apps",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"types": "./dist/cli.d.ts",
|
|
39
39
|
"import": "./dist/cli.js"
|
|
40
40
|
},
|
|
41
|
+
"./components": {
|
|
42
|
+
"default": "./dist/components.js",
|
|
43
|
+
"types": "./dist/components.d.ts",
|
|
44
|
+
"import": "./dist/components.js"
|
|
45
|
+
},
|
|
41
46
|
"./browser": {
|
|
42
47
|
"default": "./dist/browser.js",
|
|
43
48
|
"types": "./dist/browser.d.ts",
|
|
@@ -95,9 +100,9 @@
|
|
|
95
100
|
}
|
|
96
101
|
},
|
|
97
102
|
"scripts": {
|
|
98
|
-
"build": "tsdown --config tsdown.config.ts && tsx ../../scripts/vendor-syncore-internals.ts",
|
|
103
|
+
"build": "bun run build:deps && tsdown --config tsdown.config.ts && tsx ../../scripts/vendor-syncore-internals.ts",
|
|
99
104
|
"build:deps": "bun run --filter @syncore/core build && bun run --filter @syncore/schema build && bun run --filter @syncore/devtools-protocol build && bun run --filter @syncore/cli build && bun run --filter @syncore/react build && bun run --filter @syncore/platform-web build && bun run --filter @syncore/platform-node build && bun run --filter @syncore/platform-expo build && bun run --filter @syncore/next build && bun run --filter @syncore/svelte build",
|
|
100
|
-
"build:standalone": "bun run build
|
|
105
|
+
"build:standalone": "bun run build",
|
|
101
106
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
102
107
|
"lint": "eslint src --ext .ts,.tsx",
|
|
103
108
|
"test": "vitest run --passWithNoTests",
|