foldkit-remote 0.12.0 → 0.14.0
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 +265 -12
- package/dist/{index-njA5CxbS.d.mts → index-CXAGo7Dz.d.mts} +484 -50
- package/dist/index-CXAGo7Dz.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/port.d.mts +1 -1
- package/dist/port.mjs +1 -1
- package/dist/{src-9NIJGDTJ.mjs → src-CcPPtNuH.mjs} +1121 -131
- package/dist/src-CcPPtNuH.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/index-njA5CxbS.d.mts.map +0 -1
- package/dist/src-9NIJGDTJ.mjs.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Context, Duration, Effect, Layer, Option, Result, Schema, Stream } from "effect";
|
|
1
|
+
import { Context, Data, Duration, Effect, Layer, Option, Result, Schema, Stream } from "effect";
|
|
2
|
+
import { KeyValueStore } from "effect/persistence";
|
|
2
3
|
import * as Domain from "foldkit-entity";
|
|
3
|
-
import { AnyEntity, AnyQuery, Dependencies, InputExpr, Query } from "foldkit-entity";
|
|
4
|
+
import { AnyEntity, AnyQuery, AnyWrite, BoundWrite, Dependencies, InputExpr, Query, Write } from "foldkit-entity";
|
|
4
5
|
import { Command } from "foldkit/command";
|
|
5
6
|
import { EntryWithoutKeepAlive } from "foldkit/subscription";
|
|
6
|
-
import { ActiveSurface, Contract, Invalid, Metadata, ModelRef, Projection, Surface, Wiring } from "foldkit-surface";
|
|
7
|
+
import { ActiveSurface, Contract, Invalid, Metadata, ModelRef, Projection, Surface, SurfaceSource, Wiring } from "foldkit-surface";
|
|
7
8
|
import { Rpc, RpcClientError, RpcGroup } from "effect/rpc";
|
|
8
|
-
import { KeyValueStore } from "effect/persistence";
|
|
9
9
|
import * as Update from "foldkit/update";
|
|
10
10
|
//#region ../metadata/src/index.d.ts
|
|
11
11
|
/** Marks a `Metadata` value. Its entries are private to this module. */
|
|
@@ -108,6 +108,13 @@ declare const isGapped: (connection: Connection) => boolean;
|
|
|
108
108
|
interface RemoteError {
|
|
109
109
|
readonly _tag: string;
|
|
110
110
|
readonly message: string;
|
|
111
|
+
/**
|
|
112
|
+
* A refused mutation's refusal, encoded as the server sent it. Read it
|
|
113
|
+
* decoded, by its mutation, with `Data.refusal`.
|
|
114
|
+
*/
|
|
115
|
+
readonly refusal?: unknown;
|
|
116
|
+
/** Why the server refused who is asking (`_tag: 'Forbidden'`), when it said. */
|
|
117
|
+
readonly reason?: string;
|
|
111
118
|
}
|
|
112
119
|
type RemoteData<A> = {
|
|
113
120
|
readonly _tag: 'Initial';
|
|
@@ -144,6 +151,8 @@ type Freshness = {
|
|
|
144
151
|
declare const remoteErrorSchema: Schema.Struct<{
|
|
145
152
|
readonly _tag: Schema.String;
|
|
146
153
|
readonly message: Schema.String;
|
|
154
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
155
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
147
156
|
}>;
|
|
148
157
|
declare const remoteDataSchema: <A>(value: Schema.Schema<A>) => Schema.Codec<RemoteData<A>, unknown>;
|
|
149
158
|
declare const RemoteData: {
|
|
@@ -152,6 +161,11 @@ declare const RemoteData: {
|
|
|
152
161
|
* be embedded in a hand-written Model schema, not only through `Remote.select`.
|
|
153
162
|
*/
|
|
154
163
|
schema: <A>(value: Schema.Schema<A>) => Schema.Schema<RemoteData<A>>;
|
|
164
|
+
/**
|
|
165
|
+
* Whether the read has an answer: `Ready`, `Refreshing`, `Failed` or
|
|
166
|
+
* `NotFound`. `Initial` and `Loading` are still waiting for one.
|
|
167
|
+
*/
|
|
168
|
+
answered: <A>(data: RemoteData<A>) => boolean;
|
|
155
169
|
/** Exhaustive: omitting a state is a compile error. */
|
|
156
170
|
match: <A, R>(data: RemoteData<A>, cases: {
|
|
157
171
|
readonly Initial: () => R;
|
|
@@ -338,26 +352,81 @@ interface MutationAnswer {
|
|
|
338
352
|
*/
|
|
339
353
|
declare const reconcileMutation: (store: EntityStore, state: MutationState, requestId: string, answer: MutationAnswer) => Reconciled;
|
|
340
354
|
/** A mutation an application declares: its name and input/output codecs. */
|
|
341
|
-
interface MutationDescriptor<Name extends string, Input, Output> {
|
|
355
|
+
interface MutationDescriptor<Name extends string, Input, Output, Refused = unknown> {
|
|
342
356
|
readonly name: Name;
|
|
343
357
|
readonly Input: Schema.Codec<Input>;
|
|
344
358
|
readonly Output: Schema.Codec<Output>;
|
|
359
|
+
/**
|
|
360
|
+
* What the server may refuse the mutation with, as a value a client can
|
|
361
|
+
* match on rather than a message to parse: `Schema.Never` when it declares
|
|
362
|
+
* none.
|
|
363
|
+
*/
|
|
364
|
+
readonly Refusal: Schema.Codec<Refused, unknown>;
|
|
365
|
+
/**
|
|
366
|
+
* What the mutation writes, when it was declared as a `Write`: the optimistic
|
|
367
|
+
* patch a client shows, and what a server can run without a handler.
|
|
368
|
+
*/
|
|
369
|
+
readonly write?: AnyWrite | undefined;
|
|
345
370
|
}
|
|
371
|
+
/** Refusals a form or an editor knows how to show. */
|
|
372
|
+
declare const Refusal: {
|
|
373
|
+
/** One input key was refused, for `reason`, which a form shows beside that key. */
|
|
374
|
+
field: <const Key extends string, Reason extends Schema.Top>(key: Key, reason: Reason) => Schema.TaggedStruct<"Field", {
|
|
375
|
+
readonly key: Schema.Literal<Key>;
|
|
376
|
+
readonly reason: Reason;
|
|
377
|
+
}>;
|
|
378
|
+
/** The row moved on since the client read it; the author decides what wins. */
|
|
379
|
+
conflict: Schema.TaggedStruct<"Conflict", {}>;
|
|
380
|
+
/** Whether a refusal, of whatever mutation, is a `Refusal.field`. */
|
|
381
|
+
isField: <I>(input: I) => input is I & {
|
|
382
|
+
readonly _tag: "Field";
|
|
383
|
+
readonly key: string;
|
|
384
|
+
readonly reason: unknown;
|
|
385
|
+
};
|
|
386
|
+
/** Whether a refusal, of whatever mutation, is `Refusal.conflict`. */
|
|
387
|
+
isConflict: <I>(input: I) => input is I & {
|
|
388
|
+
readonly _tag: "Conflict";
|
|
389
|
+
};
|
|
390
|
+
};
|
|
346
391
|
/** A codec, or the fields of a `Schema.Struct` where one is expected. */
|
|
347
392
|
type SchemaOrFields = Schema.Codec<any, any, any, any> | Schema.Struct.Fields;
|
|
348
393
|
/** The decoded type of a codec, or of the Struct the fields describe. */
|
|
349
394
|
type TypeOf<S extends SchemaOrFields> = S extends Schema.Codec<infer T, any, any, any> ? T : S extends Schema.Struct.Fields ? Schema.Struct.Type<S> : never;
|
|
350
395
|
/** The codec itself, or a `Schema.Struct` over the fields. */
|
|
351
396
|
declare const schemaOf: <S extends SchemaOrFields>(shape: S) => Schema.Codec<TypeOf<S>>;
|
|
397
|
+
/**
|
|
398
|
+
* A bound write as the store patches it: its fields as they are, and each
|
|
399
|
+
* relation it points as the ref key the store holds (`'User:u1'`), or null.
|
|
400
|
+
*/
|
|
401
|
+
declare const patchOfWrite: (bound: BoundWrite) => NormalizedPatch;
|
|
402
|
+
/**
|
|
403
|
+
* What a declared write shows before the server answers: an update's or an
|
|
404
|
+
* insert's row as a patch (an update's only for the keys named, when some
|
|
405
|
+
* are). A delete shows nothing, since no operation removes a row from every
|
|
406
|
+
* list it is in; its answer does.
|
|
407
|
+
*/
|
|
408
|
+
declare const optimisticOfWrite: (write: AnyWrite, input: unknown, keys: ReadonlyArray<string> | undefined) => ReadonlyArray<NormalizedPatch>;
|
|
352
409
|
declare const Mutation: {
|
|
353
410
|
/**
|
|
354
411
|
* Declares a mutation. `Input` and `Output` are codecs, or the fields of the
|
|
355
412
|
* `Schema.Struct` they would be (`{ id: ProjectId, name: Schema.String }`).
|
|
413
|
+
* `Refusal`, when given, is what the server may refuse with: a codec, usually
|
|
414
|
+
* a union of `Refusal.field(...)` and `Refusal.conflict`.
|
|
415
|
+
*/
|
|
416
|
+
/**
|
|
417
|
+
* A mutation that is a declared `Write` (`update`, `insert` or `delete`): its
|
|
418
|
+
* input is the write's, and it answers nothing but the row it changed, as a
|
|
419
|
+
* patch, or its deletion. It may be refused as a conflict, for a write that
|
|
420
|
+
* `expect`s a revision the row has moved past.
|
|
356
421
|
*/
|
|
357
|
-
|
|
422
|
+
write: <const Name extends string, Fields extends Schema.Struct.Fields>(name: Name, write: Write<any, Fields>) => MutationDescriptor<Name, Schema.Struct.Type<Fields>, {}, typeof Refusal.conflict.Type> & {
|
|
423
|
+
readonly write: Write<any, Fields>;
|
|
424
|
+
};
|
|
425
|
+
make: <const Name extends string, Input extends SchemaOrFields, Output extends SchemaOrFields, Refused = never>(name: Name, config: {
|
|
358
426
|
readonly Input: Input;
|
|
359
427
|
readonly Output: Output;
|
|
360
|
-
|
|
428
|
+
readonly Refusal?: Schema.Codec<Refused, any>;
|
|
429
|
+
}) => MutationDescriptor<Name, TypeOf<Input>, TypeOf<Output>, Refused>;
|
|
361
430
|
};
|
|
362
431
|
//#endregion
|
|
363
432
|
//#region src/query.d.ts
|
|
@@ -480,8 +549,10 @@ declare const Query$1: {
|
|
|
480
549
|
before: (cursor: Cursor) => <R extends QueryRef<string, unknown>>(ref: R) => R;
|
|
481
550
|
from: <E extends AnyEntity>(entity: E) => Query<E>;
|
|
482
551
|
where: (...predicates: ReadonlyArray<import("foldkit-entity").Predicate>) => <E extends AnyEntity>(self: Query<E>) => Query<E>;
|
|
483
|
-
orderBy: (...terms: ReadonlyArray<import("foldkit-entity").
|
|
484
|
-
|
|
552
|
+
orderBy: (...terms: ReadonlyArray<import("foldkit-entity").Ordering>) => <E extends AnyEntity>(self: Query<E>) => Query<E>;
|
|
553
|
+
orderFor: (self: AnyQuery, input: Readonly<Record<string, unknown>>) => ReadonlyArray<import("foldkit-entity").OrderTerm>;
|
|
554
|
+
placement: (self: AnyQuery, input: Readonly<Record<string, unknown>>) => import("foldkit-entity").Placement;
|
|
555
|
+
dependencies: (self: AnyQuery) => import("foldkit-entity").QueryDependencies;
|
|
485
556
|
unsupported: (self: AnyQuery, supported: ReadonlyArray<import("foldkit-entity").Operation>) => ReadonlyArray<import("foldkit-entity").Operation>;
|
|
486
557
|
show: (self: AnyQuery) => string;
|
|
487
558
|
};
|
|
@@ -863,8 +934,20 @@ declare const RemoteReadError_base: Schema.Class<RemoteReadError, Schema.TaggedS
|
|
|
863
934
|
declare class RemoteReadError extends RemoteReadError_base {}
|
|
864
935
|
declare const RemoteMutationError_base: Schema.Class<RemoteMutationError, Schema.TaggedStruct<"RemoteMutationError", {
|
|
865
936
|
readonly message: Schema.String;
|
|
937
|
+
/** The mutation's own `Refusal`, encoded, when the server refused it as one. */
|
|
938
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
866
939
|
}>, import("effect/Cause").YieldableError>;
|
|
867
940
|
declare class RemoteMutationError extends RemoteMutationError_base {}
|
|
941
|
+
declare const RemoteForbidden_base: Schema.Class<RemoteForbidden, Schema.TaggedStruct<"Forbidden", {
|
|
942
|
+
readonly message: Schema.String;
|
|
943
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
944
|
+
}>, import("effect/Cause").YieldableError>;
|
|
945
|
+
/**
|
|
946
|
+
* The server refused who is asking: they may not do this, and asking again
|
|
947
|
+
* as the same principal is refused again. `reason` is the application's own
|
|
948
|
+
* words for the person who asked; without it the refusal says nothing of why.
|
|
949
|
+
*/
|
|
950
|
+
declare class RemoteForbidden extends RemoteForbidden_base {}
|
|
868
951
|
declare const RemoteLiveError_base: Schema.Class<RemoteLiveError, Schema.TaggedStruct<"RemoteLiveError", {
|
|
869
952
|
readonly message: Schema.String;
|
|
870
953
|
}>, import("effect/Cause").YieldableError>;
|
|
@@ -926,6 +1009,8 @@ declare const MutationRequest: Schema.Struct<{
|
|
|
926
1009
|
readonly requestId: Schema.String;
|
|
927
1010
|
readonly mutation: Schema.String;
|
|
928
1011
|
readonly input: Schema.Unknown;
|
|
1012
|
+
/** For a mutation that is a `Write`: the input keys to write, when not all of them. */
|
|
1013
|
+
readonly keys: Schema.optional<Schema.$Array<Schema.String>>;
|
|
929
1014
|
}>;
|
|
930
1015
|
declare const LiveEdge: Schema.Struct<{
|
|
931
1016
|
readonly entity: Schema.String;
|
|
@@ -1049,6 +1134,8 @@ declare const Mutate: Rpc.Rpc<"FoldkitRemoteMutate", Schema.Struct<{
|
|
|
1049
1134
|
readonly requestId: Schema.String;
|
|
1050
1135
|
readonly mutation: Schema.String;
|
|
1051
1136
|
readonly input: Schema.Unknown;
|
|
1137
|
+
/** For a mutation that is a `Write`: the input keys to write, when not all of them. */
|
|
1138
|
+
readonly keys: Schema.optional<Schema.$Array<Schema.String>>;
|
|
1052
1139
|
}>, Schema.Struct<{
|
|
1053
1140
|
readonly output: Schema.Unknown;
|
|
1054
1141
|
readonly entities: Schema.$Array<Schema.Struct<{
|
|
@@ -1080,7 +1167,7 @@ declare const Mutate: Rpc.Rpc<"FoldkitRemoteMutate", Schema.Struct<{
|
|
|
1080
1167
|
readonly entity: Schema.String;
|
|
1081
1168
|
readonly id: Schema.String;
|
|
1082
1169
|
}>>>;
|
|
1083
|
-
}>, typeof RemoteMutationError, never, never>;
|
|
1170
|
+
}>, Schema.Union<readonly [typeof RemoteMutationError, typeof RemoteForbidden]>, never, never>;
|
|
1084
1171
|
declare const Live: Rpc.Rpc<"FoldkitRemoteLive", Schema.Struct<{
|
|
1085
1172
|
readonly version: Schema.Number;
|
|
1086
1173
|
readonly requirements: Schema.$Array<Schema.Codec<Requirement, Requirement, never, never>>;
|
|
@@ -1265,6 +1352,8 @@ declare const RemoteRpc: RpcGroup.RpcGroup<Rpc.Rpc<"FoldkitRemoteRead", Schema.S
|
|
|
1265
1352
|
readonly requestId: Schema.String;
|
|
1266
1353
|
readonly mutation: Schema.String;
|
|
1267
1354
|
readonly input: Schema.Unknown;
|
|
1355
|
+
/** For a mutation that is a `Write`: the input keys to write, when not all of them. */
|
|
1356
|
+
readonly keys: Schema.optional<Schema.$Array<Schema.String>>;
|
|
1268
1357
|
}>, Schema.Struct<{
|
|
1269
1358
|
readonly output: Schema.Unknown;
|
|
1270
1359
|
readonly entities: Schema.$Array<Schema.Struct<{
|
|
@@ -1296,7 +1385,7 @@ declare const RemoteRpc: RpcGroup.RpcGroup<Rpc.Rpc<"FoldkitRemoteRead", Schema.S
|
|
|
1296
1385
|
readonly entity: Schema.String;
|
|
1297
1386
|
readonly id: Schema.String;
|
|
1298
1387
|
}>>>;
|
|
1299
|
-
}>, typeof RemoteMutationError, never, never> | Rpc.Rpc<"FoldkitRemoteLive", Schema.Struct<{
|
|
1388
|
+
}>, Schema.Union<readonly [typeof RemoteMutationError, typeof RemoteForbidden]>, never, never> | Rpc.Rpc<"FoldkitRemoteLive", Schema.Struct<{
|
|
1300
1389
|
readonly version: Schema.Number;
|
|
1301
1390
|
readonly requirements: Schema.$Array<Schema.Codec<Requirement, Requirement, never, never>>;
|
|
1302
1391
|
/** Resume cursor; events at or before it are duplicates. */
|
|
@@ -1412,8 +1501,14 @@ interface RemoteModel {
|
|
|
1412
1501
|
readonly live: Readonly<Record<string, LiveState>>;
|
|
1413
1502
|
/** Mutation pending/applied/failed ledger. */
|
|
1414
1503
|
readonly mutations: MutationState;
|
|
1415
|
-
/**
|
|
1504
|
+
/**
|
|
1505
|
+
* Streams that broke, by an error or by an event ahead of their cursor, and
|
|
1506
|
+
* have not resubscribed since: changes after the break are missed until the
|
|
1507
|
+
* live entry restarts them and refetches what they cover.
|
|
1508
|
+
*/
|
|
1416
1509
|
readonly gaps: ReadonlySet<string>;
|
|
1510
|
+
/** Each live stream that has ever broken, by stream key. One that never broke is absent. */
|
|
1511
|
+
readonly streams: Readonly<Record<string, StreamHealth>>;
|
|
1417
1512
|
/**
|
|
1418
1513
|
* The `entity\0id\0field` marks a read is currently fetching. A field absent
|
|
1419
1514
|
* from the store reads as `Loading` while its mark is here and `Initial`
|
|
@@ -1440,6 +1535,42 @@ interface RemoteModel {
|
|
|
1440
1535
|
* is how a view retries.
|
|
1441
1536
|
*/
|
|
1442
1537
|
readonly failures: Failures;
|
|
1538
|
+
/**
|
|
1539
|
+
* The storage key the cache was last restored from, through `Hydrated`'s
|
|
1540
|
+
* `from`. `Data.persistence` saves under a key only once its own snapshot is
|
|
1541
|
+
* in, so a save at startup cannot write the empty store over it.
|
|
1542
|
+
*/
|
|
1543
|
+
readonly restoredFrom: Option.Option<string>;
|
|
1544
|
+
/**
|
|
1545
|
+
* Under `verifyPlacement`, the order each list was placed in, by edge key,
|
|
1546
|
+
* and the rows placing took out of its first page, until the server's page
|
|
1547
|
+
* for it arrives to be compared with them.
|
|
1548
|
+
*/
|
|
1549
|
+
readonly placed: Readonly<Record<string, PlacedOrder>>;
|
|
1550
|
+
/** Under `verifyPlacement`, each placement the server's page disagreed with. */
|
|
1551
|
+
readonly placementMismatches: ReadonlyArray<PlacementMismatch>;
|
|
1552
|
+
}
|
|
1553
|
+
/** A list's first page as the client placed it: its keys in order, and those it took out. */
|
|
1554
|
+
interface PlacedOrder {
|
|
1555
|
+
readonly order: ReadonlyArray<string>;
|
|
1556
|
+
readonly dropped: ReadonlyArray<string>;
|
|
1557
|
+
}
|
|
1558
|
+
/** A list the client placed rows in one order and the server then listed in another. */
|
|
1559
|
+
interface PlacementMismatch {
|
|
1560
|
+
readonly connection: string;
|
|
1561
|
+
/** The keys as placed, as far as the server's page reached. */
|
|
1562
|
+
readonly placed: ReadonlyArray<string>;
|
|
1563
|
+
/** The keys of the server's first page. */
|
|
1564
|
+
readonly served: ReadonlyArray<string>;
|
|
1565
|
+
}
|
|
1566
|
+
/** How a live stream has fared, as its live entry restarts it. */
|
|
1567
|
+
interface StreamHealth {
|
|
1568
|
+
/** How many times it broke. The live entry restarts on each, so it only grows. */
|
|
1569
|
+
readonly restarts: number;
|
|
1570
|
+
/** Breaks since its last applied event: what the restart's backoff grows with. */
|
|
1571
|
+
readonly failures: number;
|
|
1572
|
+
/** Why it last broke; none for a gap, which is not an error. */
|
|
1573
|
+
readonly error: Option.Option<RemoteError>;
|
|
1443
1574
|
}
|
|
1444
1575
|
/**
|
|
1445
1576
|
* Failed reads, as the errors they failed with.
|
|
@@ -1497,8 +1628,8 @@ type RemoteMessage = {
|
|
|
1497
1628
|
/**
|
|
1498
1629
|
* The live stream whose subscription broke, when this is that rather
|
|
1499
1630
|
* than a read. Nothing was being read, so no field failed: the stream is
|
|
1500
|
-
* recorded as a gap, since changes after it are missed until the
|
|
1501
|
-
*
|
|
1631
|
+
* recorded as a gap, since changes after it are missed until the live
|
|
1632
|
+
* entry restarts it.
|
|
1502
1633
|
*/
|
|
1503
1634
|
readonly stream?: string | undefined;
|
|
1504
1635
|
} |
|
|
@@ -1540,6 +1671,8 @@ type RemoteMessage = {
|
|
|
1540
1671
|
*/
|
|
1541
1672
|
readonly connections?: Readonly<Record<string, ReadonlyArray<ReadonlyArray<Edge>>>> | undefined;
|
|
1542
1673
|
readonly merge: MergePolicy;
|
|
1674
|
+
/** The storage key the snapshot was read from, when it was: `restoredFrom`. */
|
|
1675
|
+
readonly from?: string | undefined;
|
|
1543
1676
|
} |
|
|
1544
1677
|
/** A mutation began; its optimistic operations show until it settles. */
|
|
1545
1678
|
{
|
|
@@ -1667,6 +1800,8 @@ declare const remoteMessageCases: {
|
|
|
1667
1800
|
error: Schema.Struct<{
|
|
1668
1801
|
readonly _tag: Schema.String;
|
|
1669
1802
|
readonly message: Schema.String;
|
|
1803
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
1804
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
1670
1805
|
}>;
|
|
1671
1806
|
stream: Schema.optional<Schema.String>;
|
|
1672
1807
|
};
|
|
@@ -1691,6 +1826,7 @@ declare const remoteMessageCases: {
|
|
|
1691
1826
|
};
|
|
1692
1827
|
Hydrated: {
|
|
1693
1828
|
connections: Schema.optional<Schema.Unknown>;
|
|
1829
|
+
from: Schema.optional<Schema.String>;
|
|
1694
1830
|
entities: Schema.Unknown;
|
|
1695
1831
|
merge: Schema.Union<readonly [Schema.Literal<"replace">, Schema.Literal<"preserve-existing">]>;
|
|
1696
1832
|
};
|
|
@@ -1717,6 +1853,8 @@ declare const remoteMessageCases: {
|
|
|
1717
1853
|
error: Schema.Struct<{
|
|
1718
1854
|
readonly _tag: Schema.String;
|
|
1719
1855
|
readonly message: Schema.String;
|
|
1856
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
1857
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
1720
1858
|
}>;
|
|
1721
1859
|
};
|
|
1722
1860
|
OverlayShown: {
|
|
@@ -1767,6 +1905,8 @@ declare const remoteMessageCases: {
|
|
|
1767
1905
|
error: Schema.Struct<{
|
|
1768
1906
|
readonly _tag: Schema.String;
|
|
1769
1907
|
readonly message: Schema.String;
|
|
1908
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
1909
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
1770
1910
|
}>;
|
|
1771
1911
|
};
|
|
1772
1912
|
};
|
|
@@ -1789,6 +1929,8 @@ declare const isRemoteMessage: <M extends {
|
|
|
1789
1929
|
readonly _tag: RemoteMessageTag;
|
|
1790
1930
|
}>;
|
|
1791
1931
|
declare const remoteMessageSchema: Schema.Schema<RemoteMessage>;
|
|
1932
|
+
/** The ids `OverlayShown` shows now, each once, in the order they are drawn. */
|
|
1933
|
+
declare const overlaysOf: (model: RemoteModel) => ReadonlyArray<string>;
|
|
1792
1934
|
/** The key a grown window is kept under: its connection and the window first asked for. */
|
|
1793
1935
|
declare const windowGrowthKey: (identity: string, window: string) => string;
|
|
1794
1936
|
/**
|
|
@@ -1811,6 +1953,12 @@ declare const refreshedAt: (refresh: RefreshState, requests: ReadonlyArray<Requi
|
|
|
1811
1953
|
* refreshed at the next generation.
|
|
1812
1954
|
*/
|
|
1813
1955
|
declare const withRefreshRequested: (refresh: RefreshState, requests: ReadonlyArray<Requirement>, connections?: ReadonlyArray<string>) => RefreshState;
|
|
1956
|
+
/**
|
|
1957
|
+
* Marks connections as needing to be asked again, and restarts a read of them
|
|
1958
|
+
* already in flight: a page requested before what invalidated it could land
|
|
1959
|
+
* after it, saying what is no longer true. `Remote.refresh` marks the same way.
|
|
1960
|
+
*/
|
|
1961
|
+
declare const invalidateConnections: (model: RemoteModel, connections: ReadonlyArray<string>) => RemoteModel;
|
|
1814
1962
|
/**
|
|
1815
1963
|
* Whether one field's read already began under the generation that field was
|
|
1816
1964
|
* last refreshed at. Such a read is in flight and would otherwise outlive the
|
|
@@ -1826,8 +1974,8 @@ declare const refreshIsInFlight: (refresh: RefreshState, request: Requirement, f
|
|
|
1826
1974
|
declare const isLoading: (model: RemoteModel, entity: string, id: string, fields: ReadonlyArray<string>) => boolean;
|
|
1827
1975
|
/**
|
|
1828
1976
|
* The pure reducer all four producers share. A live event that arrives ahead of
|
|
1829
|
-
* its cursor is a gap: it is not applied, and the stream is recorded so
|
|
1830
|
-
*
|
|
1977
|
+
* its cursor is a gap: it is not applied, and the stream is recorded so its
|
|
1978
|
+
* live entry restarts it rather than silently missing facts. When every field a Message
|
|
1831
1979
|
* touches keeps its identity, `model` itself is returned, so the application's
|
|
1832
1980
|
* root keeps its identity and Foldkit does not render. The common no-ops do (a
|
|
1833
1981
|
* duplicate live event, a repeated `ReadStarted`); a repeated failure, or a
|
|
@@ -1910,7 +2058,7 @@ declare const coalesceReads: (read: BatchRead, options?: CoalesceOptions) => Eff
|
|
|
1910
2058
|
declare const RemoteClient_base: Context.ServiceClass<RemoteClient, "foldkit-remote/RemoteClient", {
|
|
1911
2059
|
readonly read: (batch: Schema.Schema.Type<typeof ReadBatch>) => Effect.Effect<Schema.Schema.Type<typeof ReadBatchResult>, RemoteReadError | RemoteProtocolError>;
|
|
1912
2060
|
readonly query: (request: Schema.Schema.Type<typeof QueryRequest>) => Effect.Effect<Schema.Schema.Type<typeof QueryResult>, RemoteQueryError>;
|
|
1913
|
-
readonly mutate: (request: Schema.Schema.Type<typeof MutationRequest>) => Effect.Effect<Schema.Schema.Type<typeof MutationResult>, RemoteMutationError>;
|
|
2061
|
+
readonly mutate: (request: Schema.Schema.Type<typeof MutationRequest>) => Effect.Effect<Schema.Schema.Type<typeof MutationResult>, RemoteMutationError | RemoteForbidden>;
|
|
1914
2062
|
readonly live: (request: {
|
|
1915
2063
|
readonly requirements: ReadonlyArray<Requirement>;
|
|
1916
2064
|
readonly after: LiveCursor;
|
|
@@ -1934,7 +2082,7 @@ declare class RemoteClient extends RemoteClient_base {}
|
|
|
1934
2082
|
interface RemoteRpcClient<R = never, TransportError = never> {
|
|
1935
2083
|
readonly FoldkitRemoteRead: (payload: Schema.Schema.Type<typeof ReadBatch>) => Effect.Effect<Schema.Schema.Type<typeof ReadBatchResult>, RemoteReadError | RemoteProtocolError | TransportError, R>;
|
|
1936
2084
|
readonly FoldkitRemoteQuery: (payload: Schema.Schema.Type<typeof QueryRequest>) => Effect.Effect<Schema.Schema.Type<typeof QueryResult>, RemoteQueryError | TransportError, R>;
|
|
1937
|
-
readonly FoldkitRemoteMutate: (payload: Schema.Schema.Type<typeof MutationRequest>) => Effect.Effect<Schema.Schema.Type<typeof MutationResult>, RemoteMutationError | TransportError, R>;
|
|
2085
|
+
readonly FoldkitRemoteMutate: (payload: Schema.Schema.Type<typeof MutationRequest>) => Effect.Effect<Schema.Schema.Type<typeof MutationResult>, RemoteMutationError | RemoteForbidden | TransportError, R>;
|
|
1938
2086
|
readonly FoldkitRemoteLive: (payload: Schema.Schema.Type<typeof LiveRequirement>) => Stream.Stream<Schema.Schema.Type<typeof LiveChange>, RemoteLiveError | RemoteProtocolError | TransportError, R>;
|
|
1939
2087
|
}
|
|
1940
2088
|
/** Reconstructs the client's `ConnectionChange` from the wire's flattened edge. */
|
|
@@ -1944,13 +2092,15 @@ declare const liveEventOf: (change: Schema.Schema.Type<typeof LiveChange>) => Li
|
|
|
1944
2092
|
declare const remoteError: (error: {
|
|
1945
2093
|
readonly _tag: string;
|
|
1946
2094
|
readonly message: string;
|
|
2095
|
+
readonly refusal?: unknown;
|
|
2096
|
+
readonly reason?: string | undefined;
|
|
1947
2097
|
}) => RemoteError;
|
|
1948
2098
|
declare const coalescedLayer: <E, R>(layer: Layer.Layer<RemoteClient, E, R>, options?: CoalesceOptions) => Layer.Layer<RemoteClient, E, R>;
|
|
1949
2099
|
/**
|
|
1950
2100
|
* `Remote.mutate` as a standalone effect, so `Remote.mutateInto` can reuse it
|
|
1951
2101
|
* without the object literal referencing itself.
|
|
1952
2102
|
*/
|
|
1953
|
-
declare const mutateRemote: <Name extends string, Input, Output>(mutation: MutationDescriptor<Name, Input, Output>, input: Input, requestId: string) => Effect.Effect<{
|
|
2103
|
+
declare const mutateRemote: <Name extends string, Input, Output>(mutation: MutationDescriptor<Name, Input, Output, unknown>, input: Input, requestId: string, keys?: readonly string[] | undefined) => Effect.Effect<{
|
|
1954
2104
|
output: Output;
|
|
1955
2105
|
entities: readonly {
|
|
1956
2106
|
readonly entity: string;
|
|
@@ -1964,7 +2114,7 @@ declare const mutateRemote: <Name extends string, Input, Output>(mutation: Mutat
|
|
|
1964
2114
|
readonly entity: string;
|
|
1965
2115
|
readonly id: string;
|
|
1966
2116
|
}[];
|
|
1967
|
-
}, RemoteMutationError, RemoteClient>;
|
|
2117
|
+
}, RemoteMutationError | RemoteForbidden, RemoteClient>;
|
|
1968
2118
|
//#endregion
|
|
1969
2119
|
//#region src/json.d.ts
|
|
1970
2120
|
/** A request: which of Remote's calls, and its payload as the RPC protocol encodes it. */
|
|
@@ -1978,6 +2128,11 @@ declare const RemoteJsonAnswer: Schema.Union<readonly [Schema.Struct<{
|
|
|
1978
2128
|
readonly result: Schema.Unknown;
|
|
1979
2129
|
}>, Schema.Struct<{
|
|
1980
2130
|
readonly error: Schema.String;
|
|
2131
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
2132
|
+
/** Who is asking was refused, with the application's reason when it gave one. */
|
|
2133
|
+
readonly forbidden: Schema.optional<Schema.Struct<{
|
|
2134
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
2135
|
+
}>>;
|
|
1981
2136
|
}>]>;
|
|
1982
2137
|
type RemoteJsonAnswer = typeof RemoteJsonAnswer.Type;
|
|
1983
2138
|
/**
|
|
@@ -1986,6 +2141,22 @@ type RemoteJsonAnswer = typeof RemoteJsonAnswer.Type;
|
|
|
1986
2141
|
*/
|
|
1987
2142
|
type RemoteJsonSend = (request: string) => Promise<unknown>;
|
|
1988
2143
|
//#endregion
|
|
2144
|
+
//#region src/sse.d.ts
|
|
2145
|
+
/** What `httpWithLive` needs besides the URL. Mirrors `http`, plus the fetch itself. */
|
|
2146
|
+
interface LiveFetchOptions {
|
|
2147
|
+
/** Read per request, so a token that changes reaches the next call. */
|
|
2148
|
+
readonly headers?: (() => Readonly<Record<string, string>>) | undefined;
|
|
2149
|
+
/** Defaults to the global one; pass it to route calls elsewhere in tests. */
|
|
2150
|
+
readonly fetch?: typeof fetch | undefined;
|
|
2151
|
+
}
|
|
2152
|
+
/** Remote's live stream over fetch: `serveFetch`'s live open as a `Stream`. */
|
|
2153
|
+
declare const liveFetch: (url: string, options?: LiveFetchOptions) => RemoteRpcClient["FoldkitRemoteLive"];
|
|
2154
|
+
/**
|
|
2155
|
+
* Remote's client over HTTP with live: reads, queries, and mutations as
|
|
2156
|
+
* `http` sends them, live as `liveFetch` streams it, for `clientLayer`.
|
|
2157
|
+
*/
|
|
2158
|
+
declare const httpWithLive: (url: string, options?: LiveFetchOptions) => RemoteRpcClient;
|
|
2159
|
+
//#endregion
|
|
1989
2160
|
//#region src/relation.d.ts
|
|
1990
2161
|
interface RefParts {
|
|
1991
2162
|
readonly entity: string;
|
|
@@ -2337,6 +2508,8 @@ interface RemoteInspection {
|
|
|
2337
2508
|
readonly connections: ReadonlyArray<string>;
|
|
2338
2509
|
readonly live: ReadonlyArray<string>;
|
|
2339
2510
|
readonly gaps: ReadonlyArray<string>;
|
|
2511
|
+
/** Under `verifyPlacement`, each placement the server's page disagreed with. */
|
|
2512
|
+
readonly placementMismatches: ReadonlyArray<PlacementMismatch>;
|
|
2340
2513
|
/**
|
|
2341
2514
|
* The `entity\0id\0field` marks of reads in flight, and a
|
|
2342
2515
|
* `\0connection\0identity` mark for each query in flight. This is what "Remote is
|
|
@@ -2531,6 +2704,134 @@ declare const RemotePolicy: {
|
|
|
2531
2704
|
refreshes: (policy: RemotePolicy) => boolean;
|
|
2532
2705
|
};
|
|
2533
2706
|
//#endregion
|
|
2707
|
+
//#region src/placement.d.ts
|
|
2708
|
+
/** Where a row falls in a loaded list. */
|
|
2709
|
+
type RowPlace = Data.TaggedEnum<{
|
|
2710
|
+
/** Just before this edge, in this segment. */
|
|
2711
|
+
Before: {
|
|
2712
|
+
readonly segment: number;
|
|
2713
|
+
readonly edge: string;
|
|
2714
|
+
};
|
|
2715
|
+
/** After every edge of this segment, which ends the list. */
|
|
2716
|
+
End: {
|
|
2717
|
+
readonly segment: number;
|
|
2718
|
+
};
|
|
2719
|
+
/** In rows the list has not loaded: past a `Cursor` boundary, or in a gap. */
|
|
2720
|
+
Outside: {};
|
|
2721
|
+
/** Not judged exactly, and why. */
|
|
2722
|
+
Unknown: {
|
|
2723
|
+
readonly reason: string;
|
|
2724
|
+
};
|
|
2725
|
+
}>;
|
|
2726
|
+
declare const RowPlace: {
|
|
2727
|
+
readonly Unknown: Data.TaggedEnum.ConstructorFrom<{
|
|
2728
|
+
readonly _tag: "Unknown";
|
|
2729
|
+
readonly reason: string;
|
|
2730
|
+
}, "_tag">;
|
|
2731
|
+
readonly Before: Data.TaggedEnum.ConstructorFrom<{
|
|
2732
|
+
readonly _tag: "Before";
|
|
2733
|
+
readonly segment: number;
|
|
2734
|
+
readonly edge: string;
|
|
2735
|
+
}, "_tag">;
|
|
2736
|
+
readonly End: Data.TaggedEnum.ConstructorFrom<{
|
|
2737
|
+
readonly _tag: "End";
|
|
2738
|
+
readonly segment: number;
|
|
2739
|
+
}, "_tag">;
|
|
2740
|
+
readonly Outside: Data.TaggedEnum.ConstructorFrom<{
|
|
2741
|
+
readonly _tag: "Outside";
|
|
2742
|
+
}, "_tag">;
|
|
2743
|
+
readonly $is: <Tag extends "Unknown" | "Before" | "End" | "Outside">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
2744
|
+
readonly _tag: "Unknown";
|
|
2745
|
+
readonly reason: string;
|
|
2746
|
+
}, {
|
|
2747
|
+
readonly _tag: Tag;
|
|
2748
|
+
}> | Extract<{
|
|
2749
|
+
readonly _tag: "Before";
|
|
2750
|
+
readonly segment: number;
|
|
2751
|
+
readonly edge: string;
|
|
2752
|
+
}, {
|
|
2753
|
+
readonly _tag: Tag;
|
|
2754
|
+
}> | Extract<{
|
|
2755
|
+
readonly _tag: "End";
|
|
2756
|
+
readonly segment: number;
|
|
2757
|
+
}, {
|
|
2758
|
+
readonly _tag: Tag;
|
|
2759
|
+
}> | Extract<{
|
|
2760
|
+
readonly _tag: "Outside";
|
|
2761
|
+
}, {
|
|
2762
|
+
readonly _tag: Tag;
|
|
2763
|
+
}>;
|
|
2764
|
+
readonly $match: {
|
|
2765
|
+
<Cases extends {
|
|
2766
|
+
readonly Unknown: (args: {
|
|
2767
|
+
readonly _tag: "Unknown";
|
|
2768
|
+
readonly reason: string;
|
|
2769
|
+
}) => any;
|
|
2770
|
+
readonly Before: (args: {
|
|
2771
|
+
readonly _tag: "Before";
|
|
2772
|
+
readonly segment: number;
|
|
2773
|
+
readonly edge: string;
|
|
2774
|
+
}) => any;
|
|
2775
|
+
readonly End: (args: {
|
|
2776
|
+
readonly _tag: "End";
|
|
2777
|
+
readonly segment: number;
|
|
2778
|
+
}) => any;
|
|
2779
|
+
readonly Outside: (args: {
|
|
2780
|
+
readonly _tag: "Outside";
|
|
2781
|
+
}) => any;
|
|
2782
|
+
}>(cases: Cases): (value: {
|
|
2783
|
+
readonly _tag: "Unknown";
|
|
2784
|
+
readonly reason: string;
|
|
2785
|
+
} | {
|
|
2786
|
+
readonly _tag: "Before";
|
|
2787
|
+
readonly segment: number;
|
|
2788
|
+
readonly edge: string;
|
|
2789
|
+
} | {
|
|
2790
|
+
readonly _tag: "End";
|
|
2791
|
+
readonly segment: number;
|
|
2792
|
+
} | {
|
|
2793
|
+
readonly _tag: "Outside";
|
|
2794
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Unknown" | "Before" | "End" | "Outside"]>>;
|
|
2795
|
+
<Cases extends {
|
|
2796
|
+
readonly Unknown: (args: {
|
|
2797
|
+
readonly _tag: "Unknown";
|
|
2798
|
+
readonly reason: string;
|
|
2799
|
+
}) => any;
|
|
2800
|
+
readonly Before: (args: {
|
|
2801
|
+
readonly _tag: "Before";
|
|
2802
|
+
readonly segment: number;
|
|
2803
|
+
readonly edge: string;
|
|
2804
|
+
}) => any;
|
|
2805
|
+
readonly End: (args: {
|
|
2806
|
+
readonly _tag: "End";
|
|
2807
|
+
readonly segment: number;
|
|
2808
|
+
}) => any;
|
|
2809
|
+
readonly Outside: (args: {
|
|
2810
|
+
readonly _tag: "Outside";
|
|
2811
|
+
}) => any;
|
|
2812
|
+
}>(value: {
|
|
2813
|
+
readonly _tag: "Unknown";
|
|
2814
|
+
readonly reason: string;
|
|
2815
|
+
} | {
|
|
2816
|
+
readonly _tag: "Before";
|
|
2817
|
+
readonly segment: number;
|
|
2818
|
+
readonly edge: string;
|
|
2819
|
+
} | {
|
|
2820
|
+
readonly _tag: "End";
|
|
2821
|
+
readonly segment: number;
|
|
2822
|
+
} | {
|
|
2823
|
+
readonly _tag: "Outside";
|
|
2824
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Unknown" | "Before" | "End" | "Outside"]>>;
|
|
2825
|
+
};
|
|
2826
|
+
};
|
|
2827
|
+
/**
|
|
2828
|
+
* Where the row stored under `key` falls in `connection`, by `body`'s order
|
|
2829
|
+
* for `input` (encoded, as a connection's identity carries it). The row's own
|
|
2830
|
+
* edge, if the list holds it, is left out: placing a row that moved asks
|
|
2831
|
+
* where it goes now.
|
|
2832
|
+
*/
|
|
2833
|
+
declare const placeIn: (store: EntityStore, connection: Connection, body: AnyQuery, input: Readonly<Record<string, unknown>>, key: string) => RowPlace;
|
|
2834
|
+
//#endregion
|
|
2534
2835
|
//#region src/index.d.ts
|
|
2535
2836
|
/** What a domain registers: a Remote descriptor, or a `foldkit-entity` Entity (read through `Entity.from`). */
|
|
2536
2837
|
type EntityLike = EntityDescriptor<any, any> | Domain.AnyEntity;
|
|
@@ -2572,6 +2873,12 @@ interface RemoteDescriptor<Entities extends readonly EntityLike[] = readonly Ent
|
|
|
2572
2873
|
readonly entities: ReadonlyMap<string, EntityDescriptor<any, any>>;
|
|
2573
2874
|
readonly queries: ReadonlyMap<string, QueryDescriptor<any, any, any>>;
|
|
2574
2875
|
readonly mutations: ReadonlyMap<string, MutationDescriptor<any, any, any>>;
|
|
2876
|
+
/**
|
|
2877
|
+
* Per entity name, the members its server filters rows by under a rule
|
|
2878
|
+
* the client does not run (`ReadFilter`), so a change to one is fetched,
|
|
2879
|
+
* not placed.
|
|
2880
|
+
*/
|
|
2881
|
+
readonly filtered: ReadonlyMap<string, ReadonlyArray<string>>;
|
|
2575
2882
|
};
|
|
2576
2883
|
}
|
|
2577
2884
|
declare const boundRemoteNames: unique symbol;
|
|
@@ -2584,6 +2891,24 @@ interface BoundRemote<AppModel, Store extends RemoteModel, Names extends string
|
|
|
2584
2891
|
readonly [boundRemoteNames]?: Names;
|
|
2585
2892
|
}
|
|
2586
2893
|
type MutationInput<M> = M extends MutationDescriptor<any, infer Input, any> ? Input : never;
|
|
2894
|
+
/** How `Data.persistence` keeps the cache across a reload. */
|
|
2895
|
+
interface PersistenceOptions<AppModel> {
|
|
2896
|
+
/**
|
|
2897
|
+
* Where the snapshot is stored, from the Model: one key per principal, so a
|
|
2898
|
+
* change of principal reads and writes another snapshot.
|
|
2899
|
+
*/
|
|
2900
|
+
readonly key: (model: AppModel) => string;
|
|
2901
|
+
/** Who the snapshot is for; one taken under another scope is discarded. */
|
|
2902
|
+
readonly scope: (model: AppModel) => string;
|
|
2903
|
+
/** The query connections whose rows survive a reload; none by default. */
|
|
2904
|
+
readonly connections?: ReadonlyArray<ConnectionIdentity> | undefined;
|
|
2905
|
+
/** What to keep, when it is not `snapshotOf` the `connections`. */
|
|
2906
|
+
readonly snapshot?: ((remote: RemoteModel) => Snapshot) | undefined;
|
|
2907
|
+
/** A snapshot larger than this is neither written nor read. */
|
|
2908
|
+
readonly maxBytes?: number | undefined;
|
|
2909
|
+
/** How long the cache must be unchanged before it is written; default 250 milliseconds. */
|
|
2910
|
+
readonly debounce?: Duration.Input | undefined;
|
|
2911
|
+
}
|
|
2587
2912
|
interface DomainMutateOptions {
|
|
2588
2913
|
/** Overrides the generated id, for a retry, a durable bridge, or a test. */
|
|
2589
2914
|
readonly requestId?: string | undefined;
|
|
@@ -2598,7 +2923,21 @@ interface DomainMutateOptions {
|
|
|
2598
2923
|
}) => ReadonlyArray<OptimisticOperation>) | undefined;
|
|
2599
2924
|
/** The clock `MutationSucceeded` stamps the answer with; default `Date.now`, read at each use. */
|
|
2600
2925
|
readonly now?: (() => number) | undefined;
|
|
2926
|
+
/**
|
|
2927
|
+
* For a mutation that is a `Write`: the input keys to write, when only some
|
|
2928
|
+
* changed (what an author edited). The rest of the input is still sent, whole.
|
|
2929
|
+
*/
|
|
2930
|
+
readonly keys?: ReadonlyArray<string> | undefined;
|
|
2601
2931
|
}
|
|
2932
|
+
/**
|
|
2933
|
+
* One entry of the active record `subscriptions`, `wiring` and `satisfy`
|
|
2934
|
+
* take: a Surface as the Model activates it (`Surface.at`/`Surface.when`),
|
|
2935
|
+
* a source of keyed instances (`Surface.each`, or any `SurfaceSource`), or a
|
|
2936
|
+
* Surface without params read whole. A family joins its parent's
|
|
2937
|
+
* requirements with its instances', so passing the family alone fetches both
|
|
2938
|
+
* the page and what the page reveals.
|
|
2939
|
+
*/
|
|
2940
|
+
type ActiveEntry<AppModel> = ActiveSurface<AppModel> | Surface<AppModel, any, any, void> | SurfaceSource<AppModel>;
|
|
2602
2941
|
/** A Foldkit Subscription entry of the Remote domain, emitting its Messages through `RemoteClient`. */
|
|
2603
2942
|
type RemoteEntry<AppModel, Dependencies> = EntryWithoutKeepAlive<AppModel, RemoteMessage, Dependencies, RemoteClient>;
|
|
2604
2943
|
/**
|
|
@@ -2614,7 +2953,31 @@ interface LiveDependencies {
|
|
|
2614
2953
|
readonly requirements: ReadonlyArray<Requirement>;
|
|
2615
2954
|
readonly cursor: LiveCursor;
|
|
2616
2955
|
readonly floor: number;
|
|
2956
|
+
/** How many times the stream broke; each break restarts it. */
|
|
2957
|
+
readonly restarts: number;
|
|
2958
|
+
/** Breaks since its last applied event, which the restart's backoff grows with. */
|
|
2959
|
+
readonly failures: number;
|
|
2617
2960
|
}
|
|
2961
|
+
/**
|
|
2962
|
+
* Whether what an active entry reads live is arriving. `Reconnecting` is a
|
|
2963
|
+
* stream that broke and waits to resubscribe; until it has, changes are
|
|
2964
|
+
* missed, and its rows may be out of date.
|
|
2965
|
+
*/
|
|
2966
|
+
type LiveStatus =
|
|
2967
|
+
/** It reads nothing live. */
|
|
2968
|
+
{
|
|
2969
|
+
readonly _tag: 'Idle';
|
|
2970
|
+
} |
|
|
2971
|
+
/** Subscribed, and not broken since. */
|
|
2972
|
+
{
|
|
2973
|
+
readonly _tag: 'Live';
|
|
2974
|
+
} | {
|
|
2975
|
+
readonly _tag: 'Reconnecting';
|
|
2976
|
+
/** Breaks in a row, the first being 1. */
|
|
2977
|
+
readonly attempt: number;
|
|
2978
|
+
/** Why it broke; none for a gap in its events. */
|
|
2979
|
+
readonly error: Option.Option<RemoteError>;
|
|
2980
|
+
};
|
|
2618
2981
|
interface SubscriptionsOptions extends ObserveOptions, LiveOptions, RetainOptions {}
|
|
2619
2982
|
/** A Remote domain's wiring for an assembly: it routes Remote's Messages into `reduce`, brings its Subscriptions and contract, and requires `RemoteClient` from the runtime's resources Layer. */
|
|
2620
2983
|
type RemoteWiring<AppModel> = Wiring<AppModel, RemoteMessage | RemoteMessageInput, RemoteClient>;
|
|
@@ -2672,7 +3035,7 @@ interface RemoteDomain<AppModel, Store extends RemoteModel, Entities extends rea
|
|
|
2672
3035
|
* read one connection, so it is not a property of the read.
|
|
2673
3036
|
*/
|
|
2674
3037
|
explain<Name extends string, Input>(model: AppModel, projection: QueryProjection<AppModel, any, Name, Input>, options?: {
|
|
2675
|
-
readonly surfaces?: Readonly<Record<string, ActiveSurface<AppModel>>> | undefined;
|
|
3038
|
+
readonly surfaces?: Readonly<Record<string, ActiveSurface<AppModel> | SurfaceSource<AppModel>>> | undefined;
|
|
2676
3039
|
}): QueryExplanation;
|
|
2677
3040
|
/**
|
|
2678
3041
|
* Why a read shows what it shows, in words. Any Remote read: `Data.get`,
|
|
@@ -2684,7 +3047,7 @@ interface RemoteDomain<AppModel, Store extends RemoteModel, Entities extends rea
|
|
|
2684
3047
|
* does and Remote's Subscriptions are not running. Pure, like `explain`.
|
|
2685
3048
|
*/
|
|
2686
3049
|
why(model: AppModel, projection: Projection<AppModel, RemoteData<unknown>>, options?: {
|
|
2687
|
-
readonly surfaces?: Readonly<Record<string, ActiveSurface<AppModel>>> | undefined;
|
|
3050
|
+
readonly surfaces?: Readonly<Record<string, ActiveSurface<AppModel> | SurfaceSource<AppModel>>> | undefined;
|
|
2688
3051
|
}): ReadDiagnosis;
|
|
2689
3052
|
/**
|
|
2690
3053
|
* The rows of a loaded list that a body matches, decoded as the list decodes
|
|
@@ -2717,6 +3080,20 @@ interface RemoteDomain<AppModel, Store extends RemoteModel, Entities extends rea
|
|
|
2717
3080
|
overlay(model: AppModel, id: string, optimistic: ReadonlyArray<OptimisticOperation>): AppModel;
|
|
2718
3081
|
/** Lifts what `overlay` showed under this id. Lifting nothing returns the same Model. */
|
|
2719
3082
|
lift(model: AppModel, id: string): AppModel;
|
|
3083
|
+
/**
|
|
3084
|
+
* The ids `overlay` shows now, in the order they are drawn, a later one over
|
|
3085
|
+
* an earlier: what a caller that overlays from its own state reconciles
|
|
3086
|
+
* against.
|
|
3087
|
+
*/
|
|
3088
|
+
overlays(model: AppModel): ReadonlyArray<string>;
|
|
3089
|
+
/**
|
|
3090
|
+
* The edges a connection shows, as its reads draw them: the server's pages
|
|
3091
|
+
* with pending edits placed, each inserted row where the body's order puts
|
|
3092
|
+
* it (or at the end its overlay names, when it cannot be placed), minus
|
|
3093
|
+
* removed edges and tombstones. Takes the `RemoteModel`, so a persistence
|
|
3094
|
+
* `snapshot` can store a list as it is shown.
|
|
3095
|
+
*/
|
|
3096
|
+
visibleItems(remote: RemoteModel, connection: ConnectionIdentity): ReadonlyArray<Edge>;
|
|
2720
3097
|
/** `Remote.refresh`: marks what a projection or a Surface requires as due, for its read entry to refetch. */
|
|
2721
3098
|
refresh(model: AppModel, target: Projection<AppModel, unknown> | Surface<AppModel, any, any, void>): AppModel;
|
|
2722
3099
|
/** `Remote.forget`: the Model with every server-derived fact gone, for a change of principal. */
|
|
@@ -2730,16 +3107,18 @@ interface RemoteDomain<AppModel, Store extends RemoteModel, Entities extends rea
|
|
|
2730
3107
|
*/
|
|
2731
3108
|
active<Value>(name: string, projectionOf: (model: AppModel) => Option.Option<Projection<AppModel, Value>>): ActiveSurface<AppModel>;
|
|
2732
3109
|
/**
|
|
2733
|
-
* The Foldkit Subscription entries for the active
|
|
2734
|
-
* `Subscription.make`: a read entry per
|
|
2735
|
-
* entry per
|
|
2736
|
-
* retain entry (`Remote.retain`).
|
|
2737
|
-
* entry
|
|
2738
|
-
*
|
|
2739
|
-
*
|
|
2740
|
-
*
|
|
2741
|
-
|
|
2742
|
-
|
|
3110
|
+
* The Foldkit Subscription entries for the active record, keyed for
|
|
3111
|
+
* `Subscription.make`: a read entry per record entry (`Remote.observe`), a
|
|
3112
|
+
* live entry per record entry that reads through `live` (`Remote.live`), and
|
|
3113
|
+
* one retain entry (`Remote.retain`). A `Surface.each` family is one record
|
|
3114
|
+
* entry whose read unions its parent's requirements with its instances'.
|
|
3115
|
+
* Retention is the domain's: the retain entry of every call roots the active
|
|
3116
|
+
* Surfaces of every call, so reads split over calls (one per policy) do not
|
|
3117
|
+
* collect each other's data. A Surface's params are a function of the Model
|
|
3118
|
+
* (`Surface.at`), so what is fetched, subscribed, and retained follows the
|
|
3119
|
+
* Model.
|
|
3120
|
+
*/
|
|
3121
|
+
subscriptions<const Active extends Readonly<Record<string, ActiveEntry<AppModel>>>>(active: Active, options?: SubscriptionsOptions): SubscriptionEntries<AppModel, Active>;
|
|
2743
3122
|
/** `Remote.plan`: the requirements the store does not satisfy. */
|
|
2744
3123
|
plan<Value>(model: AppModel, projection: Projection<AppModel, Value>, options?: PlanOptions): ReadonlyArray<Requirement>;
|
|
2745
3124
|
/** `Remote.meta`: when what a projection shows was last received, and whether it is stale or loading. */
|
|
@@ -2786,7 +3165,7 @@ interface RemoteDomain<AppModel, Store extends RemoteModel, Entities extends rea
|
|
|
2786
3165
|
* `options.passes` run out first. Reads are cache-first: a field already
|
|
2787
3166
|
* held is not asked again.
|
|
2788
3167
|
*/
|
|
2789
|
-
satisfy(model: AppModel, active: Readonly<Record<string,
|
|
3168
|
+
satisfy(model: AppModel, active: Readonly<Record<string, ActiveEntry<AppModel>>>, options?: SatisfyOptions): Effect.Effect<AppModel, RemoteReadError | RemoteProtocolError | RemoteQueryError | RemoteUnsatisfied, RemoteClient>;
|
|
2790
3169
|
/**
|
|
2791
3170
|
* Starts a registered mutation from `update`: applies `MutationStarted` (with
|
|
2792
3171
|
* the optimistic operations) to the Model and returns the Command that runs
|
|
@@ -2799,6 +3178,18 @@ interface RemoteDomain<AppModel, Store extends RemoteModel, Entities extends rea
|
|
|
2799
3178
|
* pending, applied, or failed with the error the server or transport gave.
|
|
2800
3179
|
*/
|
|
2801
3180
|
mutation(model: AppModel, requestId: string): MutationStatus;
|
|
3181
|
+
/**
|
|
3182
|
+
* Why the server refused a mutation, as the value its `Refusal` declares:
|
|
3183
|
+
* none while it is pending or applied, when it failed for another reason,
|
|
3184
|
+
* or when the refusal does not decode as `mutation`'s.
|
|
3185
|
+
*/
|
|
3186
|
+
refusal<Refused>(model: AppModel, requestId: string, mutation: MutationDescriptor<string, any, any, Refused>): Option.Option<Refused>;
|
|
3187
|
+
/**
|
|
3188
|
+
* Whether what `active` reads live is arriving: `Reconnecting` from the
|
|
3189
|
+
* moment its stream breaks until it resubscribes, which its live entry does
|
|
3190
|
+
* on its own, with backoff.
|
|
3191
|
+
*/
|
|
3192
|
+
liveStatus(model: AppModel, active: ActiveEntry<AppModel>): LiveStatus;
|
|
2802
3193
|
/** `updateRemote` on the bound slice: reduces one of Remote's Messages, as `RemoteMessage` or as the application's union constructs it. */
|
|
2803
3194
|
reduce(model: AppModel, message: RemoteMessage | RemoteMessageInput): AppModel;
|
|
2804
3195
|
/**
|
|
@@ -2808,7 +3199,17 @@ interface RemoteDomain<AppModel, Store extends RemoteModel, Entities extends rea
|
|
|
2808
3199
|
* most one Remote wiring: every domain claims the same tags, and routing
|
|
2809
3200
|
* takes the first claimant.
|
|
2810
3201
|
*/
|
|
2811
|
-
wiring: <const Active extends Readonly<Record<string,
|
|
3202
|
+
wiring: <const Active extends Readonly<Record<string, ActiveEntry<AppModel>>>>(active: Active, options?: SubscriptionsOptions) => RemoteWiring<AppModel>;
|
|
3203
|
+
/**
|
|
3204
|
+
* Keeps the cache across a reload, as a wiring beside `wiring`: at start and
|
|
3205
|
+
* whenever `key` changes, the stored snapshot is restored (`Hydrated`, with
|
|
3206
|
+
* what the store already holds kept over it, so a page resumed from the
|
|
3207
|
+
* server wins); and the cache is written back when it changes, once its own
|
|
3208
|
+
* snapshot is in. Overlays, optimistic layers, the mutation ledger, live
|
|
3209
|
+
* cursors and gaps are never stored. A change of principal should `forget`
|
|
3210
|
+
* in `update`, and name another `key`.
|
|
3211
|
+
*/
|
|
3212
|
+
persistence(options: PersistenceOptions<AppModel>): Wiring<AppModel, RemoteMessage, KeyValueStore.KeyValueStore>;
|
|
2812
3213
|
/** `Remote.inspect` of the bound slice. */
|
|
2813
3214
|
inspect(model: AppModel): RemoteInspection;
|
|
2814
3215
|
}
|
|
@@ -2830,7 +3231,7 @@ interface RemoteFold<AppModel, ParentMessage, Domain extends RemoteDomain<AppMod
|
|
|
2830
3231
|
/** `Data.mutate`, its Command lifted. */
|
|
2831
3232
|
readonly mutate: (...args: Parameters<Domain['mutate']>) => FoldedMutationStarted<AppModel, ParentMessage>;
|
|
2832
3233
|
/** `Data.subscriptions`, every entry lifted to the wrapper Message. */
|
|
2833
|
-
readonly subscriptions: <const Active extends Readonly<Record<string,
|
|
3234
|
+
readonly subscriptions: <const Active extends Readonly<Record<string, ActiveEntry<AppModel>>>>(active: Active, options?: SubscriptionsOptions) => SubscriptionEntries<AppModel, Active, ParentMessage>;
|
|
2834
3235
|
}
|
|
2835
3236
|
/** The application Model a bound domain is over. */
|
|
2836
3237
|
type ModelOfDomain<Domain> = Domain extends RemoteDomain<infer AppModel, any, any, any, any> ? AppModel : never;
|
|
@@ -2916,6 +3317,13 @@ declare class RemoteUnsatisfied extends RemoteUnsatisfied_base {}
|
|
|
2916
3317
|
interface LiveOptions {
|
|
2917
3318
|
/** The clock `LiveReceived` stamps events with; default `Date.now`, read at each use. */
|
|
2918
3319
|
readonly now?: (() => number) | undefined;
|
|
3320
|
+
/**
|
|
3321
|
+
* The first restart's delay after a stream breaks, doubled for each break in
|
|
3322
|
+
* a row, with ±20% jitter: Sync's transport policy. Default `50 millis`.
|
|
3323
|
+
*/
|
|
3324
|
+
readonly retryBase?: Duration.Input | undefined;
|
|
3325
|
+
/** The longest a restart waits. Default `5 seconds`. */
|
|
3326
|
+
readonly maxRetryDelay?: Duration.Input | undefined;
|
|
2919
3327
|
}
|
|
2920
3328
|
/** A query the read entry runs, as its dependencies carry it: plain data Foldkit compares. */
|
|
2921
3329
|
declare const PlannedQuery: Schema.Struct<{
|
|
@@ -2979,6 +3387,8 @@ declare const Remote: {
|
|
|
2979
3387
|
error: Schema.Struct<{
|
|
2980
3388
|
readonly _tag: Schema.String;
|
|
2981
3389
|
readonly message: Schema.String;
|
|
3390
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
3391
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
2982
3392
|
}>;
|
|
2983
3393
|
stream: Schema.optional<Schema.String>;
|
|
2984
3394
|
};
|
|
@@ -3003,6 +3413,7 @@ declare const Remote: {
|
|
|
3003
3413
|
};
|
|
3004
3414
|
Hydrated: {
|
|
3005
3415
|
connections: Schema.optional<Schema.Unknown>;
|
|
3416
|
+
from: Schema.optional<Schema.String>;
|
|
3006
3417
|
entities: Schema.Unknown;
|
|
3007
3418
|
merge: Schema.Union<readonly [Schema.Literal<"replace">, Schema.Literal<"preserve-existing">]>;
|
|
3008
3419
|
};
|
|
@@ -3029,6 +3440,8 @@ declare const Remote: {
|
|
|
3029
3440
|
error: Schema.Struct<{
|
|
3030
3441
|
readonly _tag: Schema.String;
|
|
3031
3442
|
readonly message: Schema.String;
|
|
3443
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
3444
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
3032
3445
|
}>;
|
|
3033
3446
|
};
|
|
3034
3447
|
OverlayShown: {
|
|
@@ -3079,6 +3492,8 @@ declare const Remote: {
|
|
|
3079
3492
|
error: Schema.Struct<{
|
|
3080
3493
|
readonly _tag: Schema.String;
|
|
3081
3494
|
readonly message: Schema.String;
|
|
3495
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
3496
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
3082
3497
|
}>;
|
|
3083
3498
|
};
|
|
3084
3499
|
};
|
|
@@ -3116,6 +3531,8 @@ declare const Remote: {
|
|
|
3116
3531
|
error: Schema.Struct<{
|
|
3117
3532
|
readonly _tag: Schema.String;
|
|
3118
3533
|
readonly message: Schema.String;
|
|
3534
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
3535
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
3119
3536
|
}>;
|
|
3120
3537
|
stream: Schema.optional<Schema.String>;
|
|
3121
3538
|
};
|
|
@@ -3140,6 +3557,7 @@ declare const Remote: {
|
|
|
3140
3557
|
};
|
|
3141
3558
|
Hydrated: {
|
|
3142
3559
|
connections: Schema.optional<Schema.Unknown>;
|
|
3560
|
+
from: Schema.optional<Schema.String>;
|
|
3143
3561
|
entities: Schema.Unknown;
|
|
3144
3562
|
merge: Schema.Union<readonly [Schema.Literal<"replace">, Schema.Literal<"preserve-existing">]>;
|
|
3145
3563
|
};
|
|
@@ -3166,6 +3584,8 @@ declare const Remote: {
|
|
|
3166
3584
|
error: Schema.Struct<{
|
|
3167
3585
|
readonly _tag: Schema.String;
|
|
3168
3586
|
readonly message: Schema.String;
|
|
3587
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
3588
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
3169
3589
|
}>;
|
|
3170
3590
|
};
|
|
3171
3591
|
OverlayShown: {
|
|
@@ -3216,6 +3636,8 @@ declare const Remote: {
|
|
|
3216
3636
|
error: Schema.Struct<{
|
|
3217
3637
|
readonly _tag: Schema.String;
|
|
3218
3638
|
readonly message: Schema.String;
|
|
3639
|
+
readonly refusal: Schema.optional<Schema.Unknown>;
|
|
3640
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
3219
3641
|
}>;
|
|
3220
3642
|
};
|
|
3221
3643
|
}>;
|
|
@@ -3267,13 +3689,22 @@ declare const Remote: {
|
|
|
3267
3689
|
readonly entities: Entities;
|
|
3268
3690
|
readonly queries?: Queries;
|
|
3269
3691
|
readonly mutations?: Mutations;
|
|
3692
|
+
/**
|
|
3693
|
+
* Places what the server said (a mutation's answer, a read, a live
|
|
3694
|
+
* patch) as usual, and also fetches each list it placed in, comparing the
|
|
3695
|
+
* server's first page with the order it placed: a disagreement is kept in
|
|
3696
|
+
* `placementMismatches` (`Data.inspect`). A pending edit is not checked,
|
|
3697
|
+
* since the server does not have it yet. For development and tests, where
|
|
3698
|
+
* a collation that drifts should be found.
|
|
3699
|
+
*/
|
|
3700
|
+
readonly verifyPlacement?: boolean | undefined;
|
|
3270
3701
|
}) => RemoteDomain<AppModel, Store, Entities, Queries, Mutations>;
|
|
3271
3702
|
/**
|
|
3272
3703
|
* Declares a Remote domain without binding it: its entities, queries, and
|
|
3273
3704
|
* mutations, plus the submodel. For a domain reused across applications or
|
|
3274
3705
|
* bound in a test; `Remote.make` is the one-step form.
|
|
3275
3706
|
*/
|
|
3276
|
-
define: <const Entities extends readonly EntityLike[], const Queries extends readonly QueryDescriptor<any, any, any>[] = readonly QueryDescriptor<any, any, any>[], const Mutations extends readonly MutationDescriptor<any, any, any>[] = readonly MutationDescriptor<any, any, any>[]>(config: {
|
|
3707
|
+
define: <const Entities extends readonly EntityLike[], const Queries extends readonly QueryDescriptor<any, any, any>[] = readonly QueryDescriptor<any, any, any>[], const Mutations extends readonly MutationDescriptor<any, any, any>[] = readonly MutationDescriptor<any, any, any, unknown>[]>(config: {
|
|
3277
3708
|
readonly entities: Entities;
|
|
3278
3709
|
readonly queries?: Queries;
|
|
3279
3710
|
readonly mutations?: Mutations;
|
|
@@ -3401,8 +3832,16 @@ declare const Remote: {
|
|
|
3401
3832
|
* request to `url`. `headers` is read per request (a session token, say).
|
|
3402
3833
|
*/
|
|
3403
3834
|
http: (url: string, options?: {
|
|
3404
|
-
readonly headers?: () => Readonly<Record<string, string
|
|
3835
|
+
readonly headers?: (() => Readonly<Record<string, string>>) | undefined;
|
|
3836
|
+
readonly fetch?: typeof fetch | undefined;
|
|
3405
3837
|
}) => RemoteRpcClient;
|
|
3838
|
+
/**
|
|
3839
|
+
* Remote's client over HTTP with live, for `clientLayer`: reads, queries,
|
|
3840
|
+
* and mutations as `http` sends them, live requirements as one `POST`
|
|
3841
|
+
* answered with a `text/event-stream` of changes.
|
|
3842
|
+
* `foldkit-remote-server/fetch` is the other end.
|
|
3843
|
+
*/
|
|
3844
|
+
httpWithLive: (url: string, options?: LiveFetchOptions) => RemoteRpcClient;
|
|
3406
3845
|
clientLayer: <R = never>(client: RemoteRpcClient<R, RpcClientError.RpcClientError>, options?: CoalesceOptions) => Layer.Layer<RemoteClient, never, R>;
|
|
3407
3846
|
/**
|
|
3408
3847
|
* Wraps a `RemoteClient` layer so its reads coalesce: requirements issued
|
|
@@ -3461,12 +3900,6 @@ declare const Remote: {
|
|
|
3461
3900
|
}, RemoteQueryError, RemoteClient>;
|
|
3462
3901
|
/** The `RemoteMessage` that merges a query page into its connection. */
|
|
3463
3902
|
queryMessage: <Name extends string, Input>(ref: QueryRef<Name, Input>, result: Schema.Schema.Type<typeof QueryResult>, select?: RelationRequirement | undefined, now?: number | undefined) => RemoteMessage;
|
|
3464
|
-
/**
|
|
3465
|
-
* The edges a connection shows: its server-known region with pending and
|
|
3466
|
-
* confirmed overlays placed around it, minus removed edges and edges whose
|
|
3467
|
-
* target is a tombstone.
|
|
3468
|
-
*/
|
|
3469
|
-
visibleItems: (model: RemoteModel, connection: ConnectionIdentity) => ReadonlyArray<Edge>;
|
|
3470
3903
|
/** A pure, serializable view of the whole cache. */
|
|
3471
3904
|
inspect: (model: RemoteModel) => RemoteInspection;
|
|
3472
3905
|
/** A pure, serializable view of one entity, or `undefined` if unknown. */
|
|
@@ -3476,7 +3909,7 @@ declare const Remote: {
|
|
|
3476
3909
|
* returning the result's normalized patches so the caller can reconcile them
|
|
3477
3910
|
* through `updateRemote`'s `MutationSucceeded` (or `Remote.mutateInto`).
|
|
3478
3911
|
*/
|
|
3479
|
-
mutate: <Name extends string, Input, Output>(mutation: MutationDescriptor<Name, Input, Output>, input: Input, requestId: string) => Effect.Effect<{
|
|
3912
|
+
mutate: <Name extends string, Input, Output>(mutation: MutationDescriptor<Name, Input, Output, unknown>, input: Input, requestId: string, keys?: readonly string[] | undefined) => Effect.Effect<{
|
|
3480
3913
|
output: Output;
|
|
3481
3914
|
entities: readonly {
|
|
3482
3915
|
readonly entity: string;
|
|
@@ -3490,7 +3923,7 @@ declare const Remote: {
|
|
|
3490
3923
|
readonly entity: string;
|
|
3491
3924
|
readonly id: string;
|
|
3492
3925
|
}[];
|
|
3493
|
-
}, RemoteMutationError, RemoteClient>;
|
|
3926
|
+
}, RemoteMutationError | RemoteForbidden, RemoteClient>;
|
|
3494
3927
|
/**
|
|
3495
3928
|
* Runs a mutation and reconciles its patches into a `RemoteModel` in one step,
|
|
3496
3929
|
* returning the new model alongside the typed Output. The model-level form of
|
|
@@ -3498,10 +3931,10 @@ declare const Remote: {
|
|
|
3498
3931
|
* application the three are `update` (with `optimistic`), a Command, and the
|
|
3499
3932
|
* Message the Command returns, so the optimistic operations show meanwhile.
|
|
3500
3933
|
*/
|
|
3501
|
-
mutateInto: <Name extends string, Input, Output, AppModel, Store extends RemoteModel>(bound: BoundRemote<AppModel, Store, string>, model: AppModel, mutation: MutationDescriptor<Name, Input, Output>, input: Input, requestId: string, options?: MutateOptions | undefined) => Effect.Effect<{
|
|
3934
|
+
mutateInto: <Name extends string, Input, Output, AppModel, Store extends RemoteModel>(bound: BoundRemote<AppModel, Store, string>, model: AppModel, mutation: MutationDescriptor<Name, Input, Output, unknown>, input: Input, requestId: string, options?: MutateOptions | undefined) => Effect.Effect<{
|
|
3502
3935
|
output: Output;
|
|
3503
3936
|
model: AppModel;
|
|
3504
|
-
}, RemoteMutationError, RemoteClient>;
|
|
3937
|
+
}, RemoteMutationError | RemoteForbidden, RemoteClient>;
|
|
3505
3938
|
/**
|
|
3506
3939
|
* A Foldkit Subscription entry that plans a Surface's missing fields from the
|
|
3507
3940
|
* Model and fetches them through `RemoteClient`, emitting a `RemoteMessage`
|
|
@@ -3516,11 +3949,12 @@ declare const Remote: {
|
|
|
3516
3949
|
* requirements, emitting a `LiveReceived` per event and a `ReadFailed`
|
|
3517
3950
|
* carrying its `stream` when the stream breaks (including
|
|
3518
3951
|
* `ResumeUnavailable`). That records a gap on the stream rather than a failed
|
|
3519
|
-
* read, since nothing was being read
|
|
3952
|
+
* read, since nothing was being read, and restarts the entry after a
|
|
3953
|
+
* backoff; the restart refetches what it covers. The resume cursor is read
|
|
3520
3954
|
* from `RemoteModel.live`, so the application tracks no cursor of its own.
|
|
3521
3955
|
*/
|
|
3522
3956
|
live: <AppModel, Store extends RemoteModel, Names extends string, Model, SurfaceMessage, Params, Message = RemoteMessage>(bound: BoundRemote<AppModel, Store, Names>, surface: Surface<AppModel, Model, SurfaceMessage, Params>, params: Params, toMessage?: (message: RemoteMessage) => Message, options?: LiveOptions) => EntryWithoutKeepAlive<AppModel, Message, LiveDependencies, RemoteClient>;
|
|
3523
3957
|
};
|
|
3524
3958
|
//#endregion
|
|
3525
|
-
export {
|
|
3526
|
-
//# sourceMappingURL=index-
|
|
3959
|
+
export { Matched as $, writeEntity as $i, RelationRequest as $n, RemoteConnections as $r, RemoteResumePart as $t, RemoteWiring as A, patchOfWrite as Ai, withRefreshRequested as An, emptyLiveState as Ar, refsIn as At, PlanFreshness as B, entry as Bi, MutationRequest as Bn, addOverlay as Br, RemoteClient as Bt, Registered as C, SchemaOrFields as Ci, refreshedAt as Cn, LiveCursor as Cr, RelationAnnotation as Ct, RemoteEntry as D, failMutation as Di, retentionRootsSchema as Dn, applyConnectionEvent as Dr, aliasedField as Dt, RemoteDomain as E, emptyMutationState as Ei, remoteModelSchema as En, LiveState as Er, RelationShape as Et, SubscriptionsOptions as F, EntityStore as Fi, LiveEdge as Fn, ConnectionOverlay as Fr, httpWithLive as Ft, ExplainedDependencies as G, markStale as Gi, QueryRequest as Gn, removeLayer as Gr, mutateRemote as Gt, deadlineOf as H, isFieldStale as Hi, NormalizedEntity as Hn, connectionIdentity as Hr, coalescedLayer as Ht, RowPlace as I, EntityWrite as Ii, LiveRequirement as In, EntityLayer as Ir, liveFetch as It, RemoteInspection as J, remove as Ji, REMOTE_PROTOCOL_VERSION as Jn, settleSuccess as Jr, CoalesceOptions as Jt, QueryExplanation as K, missingFields as Ki, QueryResult as Kn, removeOverlay as Kr, remoteError as Kt, placeIn as L, clearStale as Li, MAX_FIELDS_PER_REQUEST as Ln, OptimisticOperation as Lr, RemoteJsonAnswer as Lt, SatisfyOptions as M, schemaOf as Mi, ConnectionChangeSchema as Mn, liveHasPrevious as Mr, relationShape as Mt, SelectsEntity as N, EntityEntry as Ni, Live as Nn, ConnectionChange as Nr, targetsOf as Nt, RemoteFold as O, mutationStatus as Oi, updateRemote as On, applyEntityEvent as Or, isRefPage as Ot, SubscriptionEntries as P, EntityKey as Pi, LiveChange as Pn, ConnectionIdentity as Pr, LiveFetchOptions as Pt, Judged as Q, writeEntities as Qi, ReadRequest as Qn, RelationRequirement as Qr, requirementKey as Qt, RemotePolicy as R, emptyStore as Ri, MAX_RELATION_DEPTH as Rn, OptimisticState as Rr, RemoteJsonRequest as Rt, ReadMeta as S, Refusal as Si, refreshIsInFlight as Sn, EntityApplied as Sr, RefParts as St, RemoteDescriptor as T, beginMutation as Ti, remoteMessageSchema as Tn, LiveOutcome as Tr, RelationKind as Tt, plan as U, isFieldUnavailable as Ui, PageSize as Un, emptyOptimistic as Ur, connectionChangeOf as Ut, PlanOptions as V, hasField as Vi, MutationResult as Vn, beginOptimistic as Vr, RemoteRpcClient as Vt, windowKey as W, isTombstone as Wi, QueryEdge as Wn, pruneOverlays as Wr, liveEventOf as Wt, inspectRemote as X, setUnavailable as Xi, ReadBatch as Xn, visibleStore as Xr, coalesceQueries as Xt, inspectEntity as Y, setStale as Yi, Read as Yn, visibleItems as Yr, QueryRun as Yt, Belongs as Z, tombstone as Zi, ReadBatchResult as Zn, ConnectionRequirement as Zr, coalesceReads as Zt, QueryOptions as _, items as _a, MutationDescriptor as _i, isQueryLoading as _n, RetentionRoots as _r, pageSchema as _t, EntitySelection as a, Boundary as aa, IDENTITY_SEPARATOR as ai, RemoteMessageInput as an, RemoteReadError as ar, EntityDescriptor as at, QueryWindowOptions as b, terminal as ba, NormalizedPatch as bi, onlyOverlaid as bn, BoundaryCounts as br, RELATION_ALIAS as bt, LiveOptions as c, Edge as ca, Query$1 as ci, StreamHealth as cn, WindowSchema as cr, FieldsFrom as ct, MutateOptions as d, cursor as da, QueryRef as di, forgetRemote as dn, REMOTE_CACHE_VERSION as dr, Page as dt, Freshness as ea, RemoteRequirements as ei, Failures as en, RemoteForbidden as er, MatchingOptions as et, MutationStarted as f, edge as fa, QueryWindow as fi, initialRemoteModel as fn, RemotePersistence as fr, Selection as ft, QueryInput as g, isGapped as ga, MutationAnswer as gi, isLoadingThrough as gn, Retained as gr, assemble as gt, QueryEntity as h, hasPrevious as ha, Mutation as hi, isLoading as hn, ConnectionRoot as hr, SelectionValueOf as ht, EntityLike as i, remoteErrorSchema as ia, ConnectionSpec as ii, RemoteMessage as in, RemoteQueryError as ir, Entity$2 as it, RetainOptions as j, reconcileMutation as ji, writeRead as jn, liveHasNext as jr, relationAlias as jt, RemoteUnsatisfied as k, optimisticOfWrite as ki, windowGrowthKey as kn, classifyLive as kr, refParts as kt, LiveStatus as l, EdgeRef as la, QueryDescriptor as li, emptyRefresh as ln, WireBoundary as lr, RefKey as lt, PersistenceOptions as m, hasNext as ma, stableStringify as mi, isFieldFailed as mn, SnapshotOptions as mr, SelectionValue as mt, BoundRemote as n, RemoteError as na, connectionsOf as ni, PlacementMismatch as nn, RemoteMutationError as nr, matching as nt, FoldedMutationStarted as o, Connection as oa, LiveInsertion as oi, RemoteMessageTag as on, RemoteRpc as or, EntityPatch as ot, ObserveOptions as p, emptyConnection as pa, ResultOf as pi, invalidateConnections as pn, Snapshot as pr, SelectionOf as pt, ReadDiagnosis as q, readField as qi, QueryRpc as qn, settleFailure as qr, BatchRead as qt, DomainMutateOptions as r, remoteDataSchema as ra, requirementsOf as ri, RefreshState as rn, RemoteProtocolError as rr, AnySchema as rt, LiveDependencies as s, Cursor as sa, LivePolicy as si, RemoteModel as sn, SettledFields as sr, EntityRef as st, ActiveEntry as t, RemoteData as ta, Requirement as ti, PlacedOrder as tn, RemoteLiveError as tr, belongsEncoded as tt, ModelOfDomain as u, Segment as ua, QueryInputs as ui, failureOf as un, MergePolicy as ur, RefPage as ut, QueryProjection as v, merge as va, MutationState as vi, isRemoteMessage as vn, gc as vr, relationOf as vt, Remote as w, TypeOf as wi, remoteMessageCases as wn, LiveEvent as wr, RelationEntityAnnotation as wt, ReadDependencies as x, unknown as xa, Reconciled as xi, overlaysOf as xn, ConnectionApplied as xr, RefPageValue as xt, QueryRequirement as y, segment as ya, MutationStatus as yi, noFailures as yn, reachable as yr, unavailableOf as yt, Deadline as z, entityKey as zi, Mutate as zn, addLayer as zr, RemoteJsonSend as zt };
|
|
3960
|
+
//# sourceMappingURL=index-CXAGo7Dz.d.mts.map
|