ignotum 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/bin.mjs +663 -38
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/runtime/{api-D2bsAz4T.d.ts → api-Dp4J-xt-.d.ts} +2 -3
- package/dist/runtime/client.d.ts +20 -3
- package/dist/runtime/client.js +197 -20
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/{descriptor-t6BOEGw9-BTHR-ZMv.js → descriptor-t6BOEGw9-C1rwYIlx.js} +29 -2
- package/dist/runtime/descriptor-t6BOEGw9-C1rwYIlx.js.map +1 -0
- package/dist/runtime/{result-BgcHn25t.d.ts → id-Btwac71X-DhnKYsjY.d.ts} +8 -2
- package/dist/runtime/{index-Dl_VQGmA.d.ts → index-B5KSOjGN.d.ts} +60 -69
- package/dist/runtime/internal/api.d.ts +1 -1
- package/dist/runtime/internal/host.d.ts +20 -4
- package/dist/runtime/internal/host.js +190 -7
- package/dist/runtime/internal/host.js.map +1 -1
- package/dist/runtime/internal/server.d.ts +1 -1
- package/dist/runtime/internal/server.js +1 -1
- package/dist/runtime/internal/types.d.ts +1 -1
- package/dist/runtime/internal/types.js +1 -1
- package/dist/runtime/pagination-B1BzNkh8-BUSTbeSg.d.ts +80 -0
- package/dist/runtime/pagination-BKPko9Hm.d.ts +1 -0
- package/dist/runtime/{schema-B-jMZEbs.js → schema-D9RmboaS.js} +93 -29
- package/dist/runtime/schema-D9RmboaS.js.map +1 -0
- package/dist/runtime/server.d.ts +2 -2
- package/dist/runtime/server.js +2 -2
- package/package.json +4 -4
- package/src/cli/agent-files.ts +4 -0
- package/src/client/hooks.ts +164 -2
- package/src/client/index.ts +2 -1
- package/src/dev-runtime/database.ts +568 -37
- package/src/dev-runtime/migrations.ts +30 -0
- package/dist/runtime/descriptor-t6BOEGw9-BTHR-ZMv.js.map +0 -1
- package/dist/runtime/id-Btwac71X-B9OeBzvq.d.ts +0 -9
- package/dist/runtime/schema-B-jMZEbs.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./id-Btwac71X-B9OeBzvq.js";
|
|
1
|
+
import { a as InternalServerError, i as ErrorValue } from "./id-Btwac71X-DhnKYsjY.js";
|
|
3
2
|
import { Effect, Schema } from "effect";
|
|
4
3
|
//#region ../contracts/dist/runtime/sync.d.ts
|
|
5
4
|
declare const FunctionAddress: Schema.TemplateLiteral<readonly ["api.", Schema.String, ".", Schema.String]>;
|
|
@@ -45,4 +44,4 @@ declare const functionPathOf: <Kind extends FunctionKind, Args, Success, Failure
|
|
|
45
44
|
declare function createApi<Modules>(): Api<Modules>;
|
|
46
45
|
//#endregion
|
|
47
46
|
export { functionPathOf as i, FunctionReference as n, createApi as r, Api as t };
|
|
48
|
-
//# sourceMappingURL=api-
|
|
47
|
+
//# sourceMappingURL=api-Dp4J-xt-.d.ts.map
|
package/dist/runtime/client.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { n as FunctionReference } from "./api-
|
|
1
|
+
import { a as InternalServerError, i as ErrorValue, l as SettledResult, o as Match, s as QueryResult$1 } from "./id-Btwac71X-DhnKYsjY.js";
|
|
2
|
+
import { n as FunctionReference } from "./api-Dp4J-xt-.js";
|
|
3
|
+
import { n as PaginationPage, t as PaginationOptions } from "./pagination-B1BzNkh8-BUSTbeSg.js";
|
|
4
|
+
import "./pagination-BKPko9Hm.js";
|
|
3
5
|
import { Dispatch, Reducer, StateUpdater, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState } from "preact/hooks";
|
|
4
6
|
import { AnyComponent, Attributes, ClassAttributes, Component, ComponentChild, ComponentChildren, ComponentClass, ComponentConstructor, ComponentFactory, ComponentProps, ComponentType, ComponentType as ComponentType$1, Consumer, Context, ContextType, ErrorInfo, Fragment, FunctionComponent, FunctionalComponent, JSX, Key, PreactConsumer, PreactContext, PreactDOMAttributes, PreactProvider, Provider, Ref, RefCallback, RefObject, RenderableProps, TargetedAnimationEvent, TargetedClipboardEvent, TargetedCommandEvent, TargetedCompositionEvent, TargetedDragEvent, TargetedEvent, TargetedFocusEvent, TargetedInputEvent, TargetedKeyboardEvent, TargetedMouseEvent, TargetedPictureInPictureEvent, TargetedPointerEvent, TargetedSnapEvent, TargetedSubmitEvent, TargetedToggleEvent, TargetedTouchEvent, TargetedTransitionEvent, TargetedUIEvent, TargetedWheelEvent, VNode, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray } from "preact";
|
|
5
7
|
//#region src/client/query.d.ts
|
|
@@ -15,6 +17,21 @@ declare const Query: {
|
|
|
15
17
|
declare function useQuery<Success, Failure extends ErrorValue>(reference: FunctionReference<"Query", void, Success, Failure>): QueryResult$1<Success, Failure>;
|
|
16
18
|
declare function useQuery<Success, Failure extends ErrorValue>(reference: FunctionReference<"Query", void, Success, Failure>, args: QuerySkip): QueryResult$1<Success, Failure>;
|
|
17
19
|
declare function useQuery<Args extends object, Success, Failure extends ErrorValue>(reference: FunctionReference<"Query", Args, Success, Failure>, args: NoInfer<Args> | QuerySkip): QueryResult$1<Success, Failure>;
|
|
20
|
+
type PaginationStatus = "CanLoadMore" | "Exhausted" | "LoadingMore";
|
|
21
|
+
interface PaginatedQueryValue<Item> {
|
|
22
|
+
readonly items: ReadonlyArray<Item>;
|
|
23
|
+
readonly loadMore: () => void;
|
|
24
|
+
readonly status: PaginationStatus;
|
|
25
|
+
}
|
|
26
|
+
interface PaginatedQueryOptions {
|
|
27
|
+
readonly pageSize?: number;
|
|
28
|
+
}
|
|
29
|
+
type PaginationArguments = {
|
|
30
|
+
readonly pagination: PaginationOptions;
|
|
31
|
+
};
|
|
32
|
+
type ApplicationPaginationArguments<Args extends PaginationArguments> = Omit<Args, "pagination">;
|
|
33
|
+
declare function usePaginatedQuery<Args extends PaginationArguments, Item, Failure extends ErrorValue>(reference: keyof ApplicationPaginationArguments<Args> extends never ? FunctionReference<"Query", Args, PaginationPage<Item>, Failure> : never): QueryResult$1<PaginatedQueryValue<Item>, Failure>;
|
|
34
|
+
declare function usePaginatedQuery<Args extends PaginationArguments, Item, Failure extends ErrorValue>(reference: FunctionReference<"Query", Args, PaginationPage<Item>, Failure>, args: NoInfer<ApplicationPaginationArguments<Args>> | QuerySkip, options?: PaginatedQueryOptions): QueryResult$1<PaginatedQueryValue<Item>, Failure>;
|
|
18
35
|
type Mutation<Args, Success, Failure extends ErrorValue> = [Args] extends [void] ? () => Promise<SettledResult<Success, Failure>> : (args: Args) => Promise<SettledResult<Success, Failure>>;
|
|
19
36
|
declare const useMutation: <Args extends object | void, Success, Failure extends ErrorValue>(reference: FunctionReference<"Mutation", Args, Success, Failure>) => Mutation<Args, Success, Failure>;
|
|
20
37
|
//#endregion
|
|
@@ -32,5 +49,5 @@ declare const Result: {
|
|
|
32
49
|
type Result<Value, Error extends ErrorValue> = SettledResult<Value, Error>;
|
|
33
50
|
type QueryResult<Value, Error extends ErrorValue> = QueryResult$1<Value, Error>;
|
|
34
51
|
//#endregion
|
|
35
|
-
export { type AnyComponent, type AppDefinition, type Attributes, type ClassAttributes, Component, type ComponentChild, type ComponentChildren, type ComponentClass, type ComponentConstructor, type ComponentFactory, type ComponentProps, type ComponentType, type Consumer, type Context, type ContextType, type Dispatch, type ErrorInfo, Fragment, type FunctionComponent, type FunctionalComponent, type InternalServerError, type JSX, type Key, type PreactConsumer, type PreactContext, type PreactDOMAttributes, type PreactProvider, type Provider, Query, QueryResult, type QuerySkip, type Reducer, type Ref, type RefCallback, type RefObject, type RenderableProps, Result, type StateUpdater, type TargetedAnimationEvent, type TargetedClipboardEvent, type TargetedCommandEvent, type TargetedCompositionEvent, type TargetedDragEvent, type TargetedEvent, type TargetedFocusEvent, type TargetedInputEvent, type TargetedKeyboardEvent, type TargetedMouseEvent, type TargetedPictureInPictureEvent, type TargetedPointerEvent, type TargetedSnapEvent, type TargetedSubmitEvent, type TargetedToggleEvent, type TargetedTouchEvent, type TargetedTransitionEvent, type TargetedUIEvent, type TargetedWheelEvent, type VNode, app, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMutation, useQuery, useReducer, useRef, useState };
|
|
52
|
+
export { type AnyComponent, type AppDefinition, type Attributes, type ClassAttributes, Component, type ComponentChild, type ComponentChildren, type ComponentClass, type ComponentConstructor, type ComponentFactory, type ComponentProps, type ComponentType, type Consumer, type Context, type ContextType, type Dispatch, type ErrorInfo, Fragment, type FunctionComponent, type FunctionalComponent, type InternalServerError, type JSX, type Key, type PaginatedQueryOptions, type PaginatedQueryValue, type PaginationStatus, type PreactConsumer, type PreactContext, type PreactDOMAttributes, type PreactProvider, type Provider, Query, QueryResult, type QuerySkip, type Reducer, type Ref, type RefCallback, type RefObject, type RenderableProps, Result, type StateUpdater, type TargetedAnimationEvent, type TargetedClipboardEvent, type TargetedCommandEvent, type TargetedCompositionEvent, type TargetedDragEvent, type TargetedEvent, type TargetedFocusEvent, type TargetedInputEvent, type TargetedKeyboardEvent, type TargetedMouseEvent, type TargetedPictureInPictureEvent, type TargetedPointerEvent, type TargetedSnapEvent, type TargetedSubmitEvent, type TargetedToggleEvent, type TargetedTouchEvent, type TargetedTransitionEvent, type TargetedUIEvent, type TargetedWheelEvent, type VNode, app, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMutation, usePaginatedQuery, useQuery, useReducer, useRef, useState };
|
|
36
53
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/runtime/client.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { a as InvocationId, c as SubscriptionId, i as IdAlphabet, l as TableId, n as DeploymentId, r as GeneratedId, s as RuntimeRequestNonce, t as AppId } from "./id-D570vudg.js";
|
|
2
|
-
import {
|
|
2
|
+
import { d as failureFromWire, f as inspectResult, l as Result$1, o as PaginationPageSize, p as pending, t as ValueDescriptor, v as decodeTransportValue, y as encodeTransportObject } from "./descriptor-t6BOEGw9-C1rwYIlx.js";
|
|
3
3
|
import { a as FunctionAddress, c as ServerMessageJson, d as WireSuccess, f as AppStateRevision, i as DeploymentChangedCloseCode, l as WireFailure, m as InvocationKey, n as functionPathOf, o as Operation, p as DeploymentGeneration, r as ClientMessageJson, s as ProtocolErrorCode, u as WireResult } from "./api-DtX8qPrq.js";
|
|
4
|
-
import { Array, Cause, Context, Deferred, Duration, Effect, ErrorReporter, Fiber, HashMap, Layer, ManagedRuntime, Predicate, Schedule, Schema, String } from "effect";
|
|
5
|
-
import { useCallback, useContext, useDebugValue, useDebugValue as useDebugValue$1, useEffect, useEffect as useEffect$1, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMemo as useMemo$1, useReducer, useRef, useState, useState as useState$1 } from "preact/hooks";
|
|
4
|
+
import { Array as Array$1, Cause, Context, Deferred, Duration, Effect, ErrorReporter, Fiber, HashMap, Layer, ManagedRuntime, Predicate, Schedule, Schema, String } from "effect";
|
|
5
|
+
import { useCallback, useCallback as useCallback$1, useContext, useDebugValue, useDebugValue as useDebugValue$1, useEffect, useEffect as useEffect$1, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMemo as useMemo$1, useReducer, useRef, useState, useState as useState$1 } from "preact/hooks";
|
|
6
6
|
import * as Socket from "effect/unstable/socket/Socket";
|
|
7
7
|
import * as BrowserCrypto from "@effect/platform-browser/BrowserCrypto";
|
|
8
8
|
import { customAlphabet } from "nanoid";
|
|
9
9
|
import { Component, Fragment, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray } from "preact";
|
|
10
|
+
//#region ../contracts/dist/json.js
|
|
11
|
+
const encodeScalar = (value) => Schema.decodeSync(Schema.String)(JSON.stringify(value));
|
|
12
|
+
const encodeCanonicalJson = (value) => {
|
|
13
|
+
if (value === null || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return encodeScalar(value);
|
|
14
|
+
if (Predicate.isObject(value)) return `{${Array$1.map(Array$1.sort(String.Order)(Object.keys(value)), (key) => {
|
|
15
|
+
const field = Schema.decodeUnknownSync(Schema.Json)(value[key]);
|
|
16
|
+
return `${encodeScalar(key)}:${encodeCanonicalJson(field)}`;
|
|
17
|
+
}).join(",")}}`;
|
|
18
|
+
return `[${Schema.decodeUnknownSync(Schema.Array(Schema.Json))(value).map(encodeCanonicalJson).join(",")}]`;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
10
21
|
//#region src/client/errors.ts
|
|
11
22
|
/** @effect-diagnostics globalConsole:skip-file */
|
|
12
23
|
var ConnectionUnavailable = class extends Schema.TaggedError()("ConnectionUnavailable", {
|
|
@@ -55,16 +66,14 @@ const skip = Object.freeze(new QuerySkipToken());
|
|
|
55
66
|
const Query = { skip };
|
|
56
67
|
const isQuerySkip = (value) => value === skip;
|
|
57
68
|
//#endregion
|
|
58
|
-
//#region ../contracts/dist/
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return `[${Schema.decodeUnknownSync(Schema.Array(Schema.Json))(value).map(encodeCanonicalJson).join(",")}]`;
|
|
67
|
-
};
|
|
69
|
+
//#region ../contracts/dist/runtime/index.js
|
|
70
|
+
const IndexIdentity = Schema.String.pipe(Schema.brand("ignotum/runtime/IndexIdentity"));
|
|
71
|
+
const EncodedIndexKey = Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{2})*$/)).pipe(Schema.brand("ignotum/runtime/EncodedIndexKey"));
|
|
72
|
+
Schema.Union([
|
|
73
|
+
Schema.Boolean,
|
|
74
|
+
Schema.Finite,
|
|
75
|
+
Schema.String
|
|
76
|
+
]);
|
|
68
77
|
Schema.String.pipe(Schema.brand("ignotum/hosted/QueryKey"));
|
|
69
78
|
const TableDependency = Schema.Struct({
|
|
70
79
|
type: Schema.Literal("Table"),
|
|
@@ -75,9 +84,32 @@ const DocumentDependency = Schema.Struct({
|
|
|
75
84
|
tableId: TableId,
|
|
76
85
|
id: GeneratedId
|
|
77
86
|
});
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
const IndexRangeDependency = Schema.Struct({
|
|
88
|
+
type: Schema.Literal("IndexRange"),
|
|
89
|
+
tableId: TableId,
|
|
90
|
+
index: IndexIdentity,
|
|
91
|
+
lower: Schema.optional(EncodedIndexKey),
|
|
92
|
+
upper: Schema.optional(EncodedIndexKey)
|
|
93
|
+
});
|
|
94
|
+
const IndexPointInvalidation = Schema.Struct({
|
|
95
|
+
type: Schema.Literal("IndexPoint"),
|
|
96
|
+
tableId: TableId,
|
|
97
|
+
index: IndexIdentity,
|
|
98
|
+
key: EncodedIndexKey
|
|
99
|
+
});
|
|
100
|
+
const ReadDependency = Schema.Union([
|
|
101
|
+
TableDependency,
|
|
102
|
+
DocumentDependency,
|
|
103
|
+
IndexRangeDependency
|
|
104
|
+
]);
|
|
105
|
+
const WriteInvalidation = Schema.Union([
|
|
106
|
+
TableDependency,
|
|
107
|
+
DocumentDependency,
|
|
108
|
+
IndexPointInvalidation
|
|
109
|
+
]);
|
|
110
|
+
Schema.Union([ReadDependency, IndexPointInvalidation]);
|
|
111
|
+
const DependencySet = Schema.Array(ReadDependency);
|
|
112
|
+
const InvalidationSet = Schema.Array(WriteInvalidation);
|
|
81
113
|
const RuntimeQueryResult = Schema.Struct({
|
|
82
114
|
type: Schema.Literal("Query"),
|
|
83
115
|
result: WireResult,
|
|
@@ -243,12 +275,17 @@ const SchemaSnapshotField = Schema.Struct({
|
|
|
243
275
|
name: Schema.String,
|
|
244
276
|
value: ValueDescriptor
|
|
245
277
|
});
|
|
278
|
+
const SchemaSnapshotIndex = Schema.Struct({
|
|
279
|
+
name: Schema.String,
|
|
280
|
+
fields: Schema.Array(Schema.String)
|
|
281
|
+
});
|
|
246
282
|
const SchemaSnapshotTable = Schema.Struct({
|
|
247
283
|
name: Schema.String,
|
|
248
|
-
fields: Schema.Array(SchemaSnapshotField)
|
|
284
|
+
fields: Schema.Array(SchemaSnapshotField),
|
|
285
|
+
indexes: Schema.Array(SchemaSnapshotIndex)
|
|
249
286
|
});
|
|
250
287
|
Schema.Struct({
|
|
251
|
-
formatVersion: Schema.Literal(
|
|
288
|
+
formatVersion: Schema.Literal(2),
|
|
252
289
|
tables: Schema.Array(SchemaSnapshotTable)
|
|
253
290
|
});
|
|
254
291
|
const ServerFunctionArtifact = Schema.Struct({
|
|
@@ -273,8 +310,15 @@ ArtifactPath.make("server/schema.json");
|
|
|
273
310
|
//#region ../contracts/dist/runtime/transport.js
|
|
274
311
|
const runtimeInvocationPath = "/v1/invoke";
|
|
275
312
|
const runtimeRevisionPath = "/v1/revision";
|
|
313
|
+
const runtimeIndexPreparePath = "/v1/indexes/prepare";
|
|
314
|
+
const runtimeIndexCommitPath = "/v1/indexes/commit";
|
|
276
315
|
const appSyncPath = `/_ignotum/v1/sync`;
|
|
277
|
-
const RuntimeRequestPath = Schema.Literals([
|
|
316
|
+
const RuntimeRequestPath = Schema.Literals([
|
|
317
|
+
runtimeInvocationPath,
|
|
318
|
+
runtimeRevisionPath,
|
|
319
|
+
runtimeIndexPreparePath,
|
|
320
|
+
runtimeIndexCommitPath
|
|
321
|
+
]);
|
|
278
322
|
const RuntimeRequestTimestamp = Schema.FiniteFromString.pipe(Schema.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0)), Schema.brand("ignotum/runtime/RequestTimestamp"));
|
|
279
323
|
const RuntimeRequestSignature = Sha256.pipe(Schema.brand("ignotum/runtime/RequestSignature"));
|
|
280
324
|
Schema.Struct({
|
|
@@ -293,6 +337,11 @@ Schema.Struct({
|
|
|
293
337
|
deploymentId: Schema.optional(DeploymentId),
|
|
294
338
|
bodySha256: Sha256
|
|
295
339
|
});
|
|
340
|
+
Schema.Struct({
|
|
341
|
+
appId: AppId,
|
|
342
|
+
deploymentId: DeploymentId
|
|
343
|
+
});
|
|
344
|
+
Schema.Struct({ completed: Schema.Literal(true) });
|
|
296
345
|
const RuntimeErrorCode = Schema.Literals([
|
|
297
346
|
"InvalidRequest",
|
|
298
347
|
"InvalidSignature",
|
|
@@ -619,6 +668,134 @@ function useQuery(reference, args) {
|
|
|
619
668
|
if (Schema.is(ClientInfrastructureError)(result)) throw result;
|
|
620
669
|
return result;
|
|
621
670
|
}
|
|
671
|
+
function usePaginatedQuery(reference, args, options = {}) {
|
|
672
|
+
const functionPath = functionPathOf(reference);
|
|
673
|
+
const skipped = isQuerySkip(args);
|
|
674
|
+
const input = args === void 0 || skipped ? {} : args;
|
|
675
|
+
const jsonArgs = encodeTransportObject(input);
|
|
676
|
+
const pageSize = Schema.decodeSync(PaginationPageSize)(options.pageSize ?? 20);
|
|
677
|
+
const identity = skipped ? `skip:${functionPath}` : syncClientInternals.queryIdentity(functionPath, jsonArgs);
|
|
678
|
+
const [requestedPages, setRequestedPages] = useState$1(1);
|
|
679
|
+
const [refresh, setRefresh] = useState$1(0);
|
|
680
|
+
const [state, setState] = useState$1(() => ({
|
|
681
|
+
identity,
|
|
682
|
+
result: pending()
|
|
683
|
+
}));
|
|
684
|
+
const loadMore = useCallback$1(() => setRequestedPages((count) => count + 1), []);
|
|
685
|
+
useDebugValue$1({
|
|
686
|
+
args: input,
|
|
687
|
+
function: functionPath,
|
|
688
|
+
result: state.result
|
|
689
|
+
});
|
|
690
|
+
useEffect$1(() => {
|
|
691
|
+
setRequestedPages(1);
|
|
692
|
+
setState({
|
|
693
|
+
identity,
|
|
694
|
+
result: pending()
|
|
695
|
+
});
|
|
696
|
+
}, [identity, pageSize]);
|
|
697
|
+
useEffect$1(() => {
|
|
698
|
+
if (skipped) return;
|
|
699
|
+
let active = true;
|
|
700
|
+
const releases = [];
|
|
701
|
+
syncRuntime.runPromise(Effect.gen(function* () {
|
|
702
|
+
const client = yield* SyncClient;
|
|
703
|
+
const items = [];
|
|
704
|
+
let cursor = null;
|
|
705
|
+
for (let pageNumber = 0; pageNumber < requestedPages; pageNumber += 1) {
|
|
706
|
+
const pageArgs = encodeTransportObject({
|
|
707
|
+
...input,
|
|
708
|
+
pagination: {
|
|
709
|
+
cursor,
|
|
710
|
+
pageSize
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
const observer = yield* client.observe(functionPath, pageArgs);
|
|
714
|
+
if (!active) {
|
|
715
|
+
yield* observer.release;
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
const releaseSubscription = observer.subscribe(() => {
|
|
719
|
+
if (active) setRefresh((version) => version + 1);
|
|
720
|
+
});
|
|
721
|
+
releases.push(() => {
|
|
722
|
+
releaseSubscription();
|
|
723
|
+
syncRuntime.runFork(observer.release);
|
|
724
|
+
});
|
|
725
|
+
const snapshot = observer.getSnapshot();
|
|
726
|
+
if (Schema.is(ClientInfrastructureError)(snapshot)) {
|
|
727
|
+
setState({
|
|
728
|
+
identity,
|
|
729
|
+
result: snapshot
|
|
730
|
+
});
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
const inspected = inspectResult(snapshot);
|
|
734
|
+
if (inspected === void 0) {
|
|
735
|
+
setState({
|
|
736
|
+
identity,
|
|
737
|
+
result: items.length === 0 ? pending() : Result$1.succeed({
|
|
738
|
+
items,
|
|
739
|
+
loadMore,
|
|
740
|
+
status: "LoadingMore"
|
|
741
|
+
})
|
|
742
|
+
});
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
if (inspected.type === "Failure") {
|
|
746
|
+
setState({
|
|
747
|
+
identity,
|
|
748
|
+
result: snapshot
|
|
749
|
+
});
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
const page = inspected.value;
|
|
753
|
+
items.push(...page.items);
|
|
754
|
+
cursor = page.nextCursor;
|
|
755
|
+
if (cursor === null) {
|
|
756
|
+
setState({
|
|
757
|
+
identity,
|
|
758
|
+
result: Result$1.succeed({
|
|
759
|
+
items,
|
|
760
|
+
loadMore,
|
|
761
|
+
status: "Exhausted"
|
|
762
|
+
})
|
|
763
|
+
});
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
setState({
|
|
768
|
+
identity,
|
|
769
|
+
result: Result$1.succeed({
|
|
770
|
+
items,
|
|
771
|
+
loadMore,
|
|
772
|
+
status: "CanLoadMore"
|
|
773
|
+
})
|
|
774
|
+
});
|
|
775
|
+
})).catch((error) => {
|
|
776
|
+
if (active && Schema.is(ClientInfrastructureError)(error)) setState({
|
|
777
|
+
identity,
|
|
778
|
+
result: error
|
|
779
|
+
});
|
|
780
|
+
});
|
|
781
|
+
return () => {
|
|
782
|
+
active = false;
|
|
783
|
+
for (const release of releases) release();
|
|
784
|
+
};
|
|
785
|
+
}, [
|
|
786
|
+
functionPath,
|
|
787
|
+
identity,
|
|
788
|
+
loadMore,
|
|
789
|
+
pageSize,
|
|
790
|
+
refresh,
|
|
791
|
+
requestedPages,
|
|
792
|
+
skipped
|
|
793
|
+
]);
|
|
794
|
+
if (skipped || state.identity !== identity) return pending();
|
|
795
|
+
const result = state.result;
|
|
796
|
+
if (Schema.is(ClientInfrastructureError)(result)) throw result;
|
|
797
|
+
return result;
|
|
798
|
+
}
|
|
622
799
|
const useMutation = (reference) => useMemo$1(() => {
|
|
623
800
|
const mutate = (args) => {
|
|
624
801
|
const functionPath = functionPathOf(reference);
|
|
@@ -648,6 +825,6 @@ const app = (definition) => {
|
|
|
648
825
|
//#region src/client/index.ts
|
|
649
826
|
const Result = { match: Result$1.match };
|
|
650
827
|
//#endregion
|
|
651
|
-
export { Component, Fragment, Query, Result, app, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMutation, useQuery, useReducer, useRef, useState };
|
|
828
|
+
export { Component, Fragment, Query, Result, app, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMutation, usePaginatedQuery, useQuery, useReducer, useRef, useState };
|
|
652
829
|
|
|
653
830
|
//# sourceMappingURL=client.js.map
|