@confect/foldkit 10.0.0-next.20 → 10.0.0-next.22
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/CHANGELOG.md +82 -2
- package/dist/Command.d.ts +12 -13
- package/dist/Command.d.ts.map +1 -1
- package/dist/Command.js +4 -4
- package/dist/Command.js.map +1 -1
- package/dist/PaginatedQuery.d.ts +11 -1
- package/dist/PaginatedQuery.d.ts.map +1 -1
- package/dist/PaginatedQuery.js +30 -14
- package/dist/PaginatedQuery.js.map +1 -1
- package/dist/Subscription.d.ts +1 -2
- package/dist/Subscription.d.ts.map +1 -1
- package/dist/Subscription.js.map +1 -1
- package/package.json +11 -11
- package/src/Command.ts +12 -13
- package/src/PaginatedQuery.ts +24 -13
- package/src/Subscription.ts +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,92 @@
|
|
|
1
1
|
# @confect/foldkit
|
|
2
2
|
|
|
3
|
+
## 10.0.0-next.22
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6cc5834: Add experimental stream querying with reactive pagination, configurable middleware policies, and broader tracing.
|
|
8
|
+
|
|
9
|
+
### Stream queries and pagination
|
|
10
|
+
|
|
11
|
+
Create composable Effect streams with `reader.table(...).stream(index, range?, order?)` and `QueryStream` from `@confect/server`. Merge, filter, map, join, deduplicate, narrow, and reverse queries without losing cursor pagination. Order keys and directions are checked by the type system. Joins support left-join placeholders through `onEmpty`, and effectful filters and maps support ordered concurrency. Reversing a distinct stream preserves its chosen representatives.
|
|
12
|
+
|
|
13
|
+
`QueryStream.paginate` resumes from indexed cursor bounds and supports pinned page ranges, automatic split recommendations, and `maximumRowsRead`/`maximumBytesRead` budgets that count underlying query-stream reads, including filtered documents. Byte counts are estimates. If a budget prevents safe progress or splitting, pagination fails with `ReadBudgetExceededError`; increase the budget or reduce the query's read requirements.
|
|
14
|
+
|
|
15
|
+
Use React's new `useStreamPaginatedQuery` for these queries:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { useStreamPaginatedQuery } from "@confect/react";
|
|
19
|
+
|
|
20
|
+
const { results, status, loadMore } = useStreamPaginatedQuery(
|
|
21
|
+
refs.public.notes.feed,
|
|
22
|
+
{},
|
|
23
|
+
{
|
|
24
|
+
initialNumItems: 10,
|
|
25
|
+
maximumRowsRead: 1000,
|
|
26
|
+
maximumBytesRead: 512 * 1024,
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The hook pins loaded pages to fixed ranges, splits oversized or budget-limited pages, and restarts pagination on invalid cursors. Foldkit's `PaginatedQuery` also supports stream queries and preserves page ranges when navigating back and forward, avoiding skipped or repeated documents as data changes.
|
|
32
|
+
|
|
33
|
+
Stream cursors expose their order-key values. Do not paginate publicly over sensitive indexed fields unless they are pinned with `eq`. All `QueryStream` APIs are experimental.
|
|
34
|
+
|
|
35
|
+
### Middleware options
|
|
36
|
+
|
|
37
|
+
Declare a lazy `options` schema on `MiddlewareSpec.MiddlewareSpec`, then pass typed values with `.middleware(Policy, options)` on functions or groups. Options are validated without coercion during codegen and server registration; keep schemas and values client-safe because generated refs carry them.
|
|
38
|
+
|
|
39
|
+
The same policy can be attached repeatedly with non-equivalent options. Every attachment runs, with group policies before function policies. Equivalent options and duplicate policies without options are rejected. Register implementations against the same spec used for attachments.
|
|
40
|
+
|
|
41
|
+
### Breaking changes
|
|
42
|
+
|
|
43
|
+
Middleware callbacks passed to `MiddlewareImpl.make` or `MiddlewareImpl.makeByFunctionType` receive invocation metadata under `invocation`. To migrate, nest destructuring of `name`, `functionType`, `functionVisibility`, and decoded `args`:
|
|
44
|
+
|
|
45
|
+
**Before:**
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
(effect, { name, args }) => effect;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**After:**
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
(effect, { invocation: { name, args } }) => effect;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Middleware with an options schema also receives `options` alongside `invocation`; middleware without one keeps its single-argument attachment API and receives only `{ invocation }`.
|
|
58
|
+
|
|
59
|
+
### Fixes and tracing
|
|
60
|
+
- Preserve `ConvexError.data` when a handler throws a `ConvexError` inside an Effect instead of returning it as a typed failure.
|
|
61
|
+
- Add named tracing spans for JavaScript client calls, server function execution, database writes and pagination, `QueryStream.unique`/`QueryStream.paginate`, and `confect codegen`/`confect dev` code-generation passes.
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- 9f4e2c0: Require `effect@^4.0.0-rc.113` across `@confect/*` and raise `@confect/server`'s optional `@effect/platform-node` peer to the same range. Upgrade Effect alongside Confect; existing Confect call sites are unchanged.
|
|
66
|
+
|
|
67
|
+
Effect's own APIs include breaking renames: use `Config.String` instead of `Config.string`, and `LanguageModel.LanguageModel` instead of `LanguageModel.Service` when annotating the result of `AiGatewayLanguageModel.make`. See the [Effect RC 113 release notes](https://github.com/Effect-TS/effect/releases/tag/effect%404.0.0-rc.113) for the complete migration guidance.
|
|
68
|
+
|
|
69
|
+
- 90c80e9: Require `effect@^4.0.0-rc.115` across `@confect/*` and `@effect/platform-node@^4.0.0-rc.115` when using `@confect/server`'s optional Node integration. Upgrade these dependencies alongside Confect; existing Confect call sites are unchanged.
|
|
70
|
+
- f721d2c: Remove spaces around em dashes and separator slashes in API documentation and `confect codegen` diagnostics.
|
|
71
|
+
|
|
72
|
+
## 10.0.0-next.21
|
|
73
|
+
|
|
74
|
+
### Major Changes
|
|
75
|
+
|
|
76
|
+
- a6425c5: Raise the minimum supported Node.js version to 24.
|
|
77
|
+
|
|
78
|
+
### Breaking Changes
|
|
79
|
+
- `engines.node` is now `>=24` on every `@confect/*` package, raised from `>=22`.
|
|
80
|
+
|
|
81
|
+
Node 22 has entered maintenance, so Confect now targets Node 24, the active LTS line. To migrate, move the Node version your project builds and runs on to 24 or later—on Node 22, installing `@confect/*` now fails your package manager's engine check. No API changes accompany the raise: code already running on Node 24 needs no edits.
|
|
82
|
+
|
|
3
83
|
## 10.0.0-next.20
|
|
4
84
|
|
|
5
85
|
## 10.0.0-next.19
|
|
6
86
|
|
|
7
87
|
### Minor Changes
|
|
8
88
|
|
|
9
|
-
- c1087eb: Add `@confect/foldkit
|
|
89
|
+
- c1087eb: Add `@confect/foldkit`—client-side bindings for [Foldkit](https://foldkit.dev) apps. The package maps Confect's client surface onto Foldkit's integration seams: `Client.layer` provides the scoped WebSocket client and pagination-session allocator through an application's `resources`, `Subscription.reactiveQuery` builds a subscription entry that opens, re-opens, and closes a reactive query as `Option`-wrapped args derived from the Model change, and `Command.query`/`Command.mutation`/`Command.action` build Command definitions whose args are the ref's args and whose Messages are declared with the same `messages` field Foldkit's own `Command.define` takes. Every failure is folded into a Message via the required `onError` handler, so Command and Subscription error channels stay `never` as Foldkit requires.
|
|
10
90
|
|
|
11
91
|
```ts
|
|
12
92
|
import * as Confect from "@confect/foldkit";
|
|
@@ -36,7 +116,7 @@
|
|
|
36
116
|
}));
|
|
37
117
|
```
|
|
38
118
|
|
|
39
|
-
The Command factories accept Foldkit's `interrupt` option
|
|
119
|
+
The Command factories accept Foldkit's `interrupt` option—`true` keys invocations by the Command name, `{ keyFields, toKey }` by a part derived from the ref's args—and the returned definition gains the `Interrupt` constructor for stopping in-flight invocations. Factory-built definitions instantiate Foldkit's own definition interfaces, so they are accepted wherever Foldkit accepts a Command definition—including Story/Scene `Command.resolve` and `expectExact` matchers. `Command.queryEffect`, `Command.mutationEffect`, and `Command.actionEffect` return execute bodies for hand-written `Command.define` calls (custom args schemas, multi-call Commands), and `Subscription.reactiveQueryStream` is the `dependenciesToStream` escape hatch for hand-written subscription entries.
|
|
40
120
|
|
|
41
121
|
`PaginatedQuery` navigates a paginated query one page at a time over Convex's cursor pagination. `PaginatedQuery.make(ref)` returns the Model and settlement schemas. Its states use Foldkit `AsyncData`'s vocabulary and semantics: `Idle`, `Loading`, `Refreshing`, `Success`, `Failure`, and `Stale`. Failed settlements preserve the complete error contract: declared function and middleware errors are wrapped as `FunctionError`, Convex's invalid-cursor pseudo-error is normalized to the new `@confect/core/PaginationError.InvalidCursor`, and `WebSocketClientError` and `SchemaError` are carried directly. `settle` accepts a request-bound `Result`, turns a failed refresh into `Stale`, automatically resets an invalid cursor, and ignores successes or failures from superseded requests. All machine operations (`init`, `reinitialize`, `reset`, `close`, `next`, `prev`, and `first`) remain pure.
|
|
42
122
|
|
package/dist/Command.d.ts
CHANGED
|
@@ -11,11 +11,10 @@ import * as Client from "./Client";
|
|
|
11
11
|
*/
|
|
12
12
|
export type Error<Ref_ extends Ref.AnyConfect> = Ref.Error<Ref_> | Client.WebSocketClientError | Schema.SchemaError;
|
|
13
13
|
/**
|
|
14
|
-
* Maps a Confect function's outcome into the app's Messages. Every failure —
|
|
15
|
-
* the ref's typed error, a transport error, or a codec error — arrives via
|
|
14
|
+
* Maps a Confect function's outcome into the app's Messages. Every failure—the ref's typed error, a transport error, or a codec error—arrives via
|
|
16
15
|
* `onError`, so the resulting Command's error channel is `never`, as Foldkit
|
|
17
16
|
* requires. Follow Foldkit's naming convention: past-tense facts like
|
|
18
|
-
* `SucceededSaveNote
|
|
17
|
+
* `SucceededSaveNote`/`FailedSaveNote`.
|
|
19
18
|
*/
|
|
20
19
|
export interface Handlers<Ref_ extends Ref.AnyConfect, SuccessMessage, ErrorMessage> {
|
|
21
20
|
readonly onSuccess: (returns: Ref.Returns<Ref_>) => SuccessMessage;
|
|
@@ -35,20 +34,20 @@ type SchemaArgs<Ref_ extends Ref.AnyConfect> = Schema.Schema.Type<Schema.Struct<
|
|
|
35
34
|
* ref-derived call signature (args optional when the ref declares none)
|
|
36
35
|
* intersected with Foldkit's own `CommandDefinitionWithArgs`, which supplies
|
|
37
36
|
* the `CommandDefinitionTypeId` brand and makes the definition assignable
|
|
38
|
-
* wherever Foldkit accepts one
|
|
37
|
+
* wherever Foldkit accepts one—including Story/Scene `Command.resolve`
|
|
39
38
|
* and `expectExact` matchers. Call it from `update` to construct a Command
|
|
40
39
|
* instance; nothing runs until the Foldkit runtime executes it.
|
|
41
40
|
*/
|
|
42
41
|
export type Definition<Name extends string, Ref_ extends Ref.AnyConfect, Message> = ((...args: Ref.OptionalArgs<Ref_>) => Instance<Name, Ref_, Message>) & FoldkitCommand.CommandDefinitionWithArgs<Name, Ref.ArgsSchema<Ref_>["fields"], Effect.Effect<Message, never, Client.Client>>;
|
|
43
42
|
/**
|
|
44
|
-
* Makes a factory-built Command interruptible
|
|
43
|
+
* Makes a factory-built Command interruptible—Foldkit's `InterruptOption`
|
|
45
44
|
* applied to the ref's args. `true` keys every invocation by the Command
|
|
46
|
-
* name
|
|
45
|
+
* name—right when at most one invocation is meaningfully in flight; a
|
|
47
46
|
* `KeyedInterrupt` derives the key part from the ref's args, so concurrent
|
|
48
47
|
* invocations can be targeted independently.
|
|
49
48
|
*
|
|
50
49
|
* Interrupting stops the client-side Effect and guarantees the invocation's
|
|
51
|
-
* result Messages never dispatch
|
|
50
|
+
* result Messages never dispatch—it does not cancel the Convex function on
|
|
52
51
|
* the server, which runs to completion once the call is on the wire.
|
|
53
52
|
*/
|
|
54
53
|
export type InterruptOption<Ref_ extends Ref.AnyConfect, KeyField extends keyof SchemaArgs<Ref_> & string = keyof SchemaArgs<Ref_> & string> = FoldkitCommand.InterruptOption<SchemaArgs<Ref_>, KeyField>;
|
|
@@ -58,7 +57,7 @@ export type InterruptOption<Ref_ extends Ref.AnyConfect, KeyField extends keyof
|
|
|
58
57
|
*/
|
|
59
58
|
export type KeyedInterrupt<Ref_ extends Ref.AnyConfect, KeyField extends keyof SchemaArgs<Ref_> & string> = Exclude<InterruptOption<Ref_, KeyField>, true>;
|
|
60
59
|
/**
|
|
61
|
-
* An interruptible Command definition whose key is the Command name
|
|
60
|
+
* An interruptible Command definition whose key is the Command name—the
|
|
62
61
|
* ref-derived call signature intersected with Foldkit's
|
|
63
62
|
* `Interruptible.DefinitionWithArgsNameKeyed`, which supplies the brand and
|
|
64
63
|
* the `Interrupt` constructor.
|
|
@@ -68,7 +67,7 @@ export type InterruptibleDefinition<Name extends string, Ref_ extends Ref.AnyCon
|
|
|
68
67
|
}>) & FoldkitCommand.Interruptible.DefinitionWithArgsNameKeyed<Name, Ref.ArgsSchema<Ref_>["fields"], Effect.Effect<Message, never, Client.Client>>;
|
|
69
68
|
/**
|
|
70
69
|
* An interruptible Command definition whose key is derived from the ref's
|
|
71
|
-
* args
|
|
70
|
+
* args—the ref-derived call signature intersected with Foldkit's
|
|
72
71
|
* `Interruptible.DefinitionWithArgs`, which supplies the brand and the
|
|
73
72
|
* key-args-taking `Interrupt` constructor.
|
|
74
73
|
*/
|
|
@@ -76,18 +75,18 @@ export type KeyedInterruptibleDefinition<Name extends string, Ref_ extends Ref.A
|
|
|
76
75
|
key: string;
|
|
77
76
|
}>) & FoldkitCommand.Interruptible.DefinitionWithArgs<Name, Ref.ArgsSchema<Ref_>["fields"], Pick<SchemaArgs<Ref_>, KeyField>, Effect.Effect<Message, never, Client.Client>>;
|
|
78
77
|
/**
|
|
79
|
-
* An execute body for a hand-written `Command.define
|
|
78
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
80
79
|
* folded into a Message. Reach for these when the factory below doesn't fit:
|
|
81
80
|
* a custom args schema, `interrupt`, or a Command that makes several calls.
|
|
82
81
|
*/
|
|
83
82
|
export declare const queryEffect: <Query extends Ref.AnyConfectPublicQuery, SuccessMessage, ErrorMessage>(ref: Query, handlers: Handlers<Query, SuccessMessage, ErrorMessage>) => (...args: Ref.OptionalArgs<Query>) => Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client>;
|
|
84
83
|
/**
|
|
85
|
-
* An execute body for a hand-written `Command.define
|
|
84
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
86
85
|
* folded into a Message. See `queryEffect`.
|
|
87
86
|
*/
|
|
88
87
|
export declare const mutationEffect: <Mutation extends Ref.AnyConfectPublicMutation, SuccessMessage, ErrorMessage>(ref: Mutation, handlers: Handlers<Mutation, SuccessMessage, ErrorMessage>) => (...args: Ref.OptionalArgs<Mutation>) => Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client>;
|
|
89
88
|
/**
|
|
90
|
-
* An execute body for a hand-written `Command.define
|
|
89
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
91
90
|
* folded into a Message. See `queryEffect`.
|
|
92
91
|
*/
|
|
93
92
|
export declare const actionEffect: <Action extends Ref.AnyConfectPublicAction, SuccessMessage, ErrorMessage>(ref: Action, handlers: Handlers<Action, SuccessMessage, ErrorMessage>) => (...args: Ref.OptionalArgs<Action>) => Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client>;
|
|
@@ -129,7 +128,7 @@ declare const makeFactory: <BoundRef extends Ref.AnyConfect>(effectHelper: <Ref_
|
|
|
129
128
|
* ```
|
|
130
129
|
*
|
|
131
130
|
* Pass `interrupt` to make invocations interruptible via the returned
|
|
132
|
-
* definition's `Interrupt` constructor
|
|
131
|
+
* definition's `Interrupt` constructor—`true` keys them by the Command
|
|
133
132
|
* name, `{ keyFields, toKey }` by a part derived from the ref's args:
|
|
134
133
|
*
|
|
135
134
|
* ```ts
|
package/dist/Command.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../src/Command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,cAAc,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,MAAM,KAAK,CAAC,IAAI,SAAS,GAAG,CAAC,UAAU,IACzC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAC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AE,cAAc,GAAG,YAAY,CAAC;CAsCzD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,KAAK,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAClD,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,UAAU,CAC/B,OAAO,WAAW,CAAC,GAAG,CAAC,wBAAwB,CAAC,CACnB,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,UAAU,CAC7B,OAAO,WAAW,CAAC,GAAG,CAAC,sBAAsB,CAAC,CACnB,CAAC"}
|
package/dist/Command.js
CHANGED
|
@@ -17,18 +17,18 @@ const run = (handlers, invoke) => Effect.flatMap(Client, invoke).pipe(Effect.mat
|
|
|
17
17
|
onFailure: handlers.onError
|
|
18
18
|
}));
|
|
19
19
|
/**
|
|
20
|
-
* An execute body for a hand-written `Command.define
|
|
20
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
21
21
|
* folded into a Message. Reach for these when the factory below doesn't fit:
|
|
22
22
|
* a custom args schema, `interrupt`, or a Command that makes several calls.
|
|
23
23
|
*/
|
|
24
24
|
const queryEffect = (ref, handlers) => (...args) => run(handlers, (client) => client.query(ref, ...args));
|
|
25
25
|
/**
|
|
26
|
-
* An execute body for a hand-written `Command.define
|
|
26
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
27
27
|
* folded into a Message. See `queryEffect`.
|
|
28
28
|
*/
|
|
29
29
|
const mutationEffect = (ref, handlers) => (...args) => run(handlers, (client) => client.mutation(ref, ...args));
|
|
30
30
|
/**
|
|
31
|
-
* An execute body for a hand-written `Command.define
|
|
31
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
32
32
|
* folded into a Message. See `queryEffect`.
|
|
33
33
|
*/
|
|
34
34
|
const actionEffect = (ref, handlers) => (...args) => run(handlers, (client) => client.action(ref, ...args));
|
|
@@ -80,7 +80,7 @@ const makeFactory = (effectHelper) => {
|
|
|
80
80
|
* ```
|
|
81
81
|
*
|
|
82
82
|
* Pass `interrupt` to make invocations interruptible via the returned
|
|
83
|
-
* definition's `Interrupt` constructor
|
|
83
|
+
* definition's `Interrupt` constructor—`true` keys them by the Command
|
|
84
84
|
* name, `{ keyFields, toKey }` by a part derived from the ref's args:
|
|
85
85
|
*
|
|
86
86
|
* ```ts
|
package/dist/Command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.js","names":["Client.Client"],"sources":["../src/Command.ts"],"sourcesContent":["import type * as Ref from \"@confect/core/Ref\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport type * as Schema from \"effect/Schema\";\nimport * as FoldkitCommand from \"foldkit/command\";\nimport * as Client from \"./Client\";\n\n/**\n * Everything a Command against `Ref_` can fail with before it is folded into\n * an `onError` Message: the ref's typed error (if it declares an `error`\n * schema), a transport-level `WebSocketClientError`, or a `SchemaError` from\n * encoding args or decoding returns.\n */\nexport type Error<Ref_ extends Ref.AnyConfect> =\n | Ref.Error<Ref_>\n | Client.WebSocketClientError\n | Schema.SchemaError;\n\n/**\n * Maps a Confect function's outcome into the app's Messages. Every failure —\n * the ref's typed error, a transport error, or a codec error — arrives via\n * `onError`, so the resulting Command's error channel is `never`, as Foldkit\n * requires. Follow Foldkit's naming convention: past-tense facts like\n * `SucceededSaveNote` / `FailedSaveNote`.\n */\nexport interface Handlers<\n Ref_ extends Ref.AnyConfect,\n SuccessMessage,\n ErrorMessage,\n> {\n readonly onSuccess: (returns: Ref.Returns<Ref_>) => SuccessMessage;\n readonly onError: (error: Error<Ref_>) => ErrorMessage;\n}\n\n/**\n * The Command instance a definition call constructs.\n */\ntype Instance<\n Name extends string,\n Ref_ extends Ref.AnyConfect,\n Message,\n> = Readonly<{\n name: Name;\n args: Ref.Args<Ref_>;\n effect: Effect.Effect<Message, never, Client.Client>;\n}>;\n\ntype SchemaArgs<Ref_ extends Ref.AnyConfect> = Schema.Schema.Type<\n Schema.Struct<Ref.ArgsSchema<Ref_>[\"fields\"]>\n>;\n\n/**\n * A Foldkit Command definition whose args are the ref's args: our\n * ref-derived call signature (args optional when the ref declares none)\n * intersected with Foldkit's own `CommandDefinitionWithArgs`, which supplies\n * the `CommandDefinitionTypeId` brand and makes the definition assignable\n * wherever Foldkit accepts one — including Story/Scene `Command.resolve`\n * and `expectExact` matchers. Call it from `update` to construct a Command\n * instance; nothing runs until the Foldkit runtime executes it.\n */\nexport type Definition<\n Name extends string,\n Ref_ extends Ref.AnyConfect,\n Message,\n> = ((...args: Ref.OptionalArgs<Ref_>) => Instance<Name, Ref_, Message>) &\n FoldkitCommand.CommandDefinitionWithArgs<\n Name,\n Ref.ArgsSchema<Ref_>[\"fields\"],\n Effect.Effect<Message, never, Client.Client>\n >;\n\n/**\n * Makes a factory-built Command interruptible — Foldkit's `InterruptOption`\n * applied to the ref's args. `true` keys every invocation by the Command\n * name — right when at most one invocation is meaningfully in flight; a\n * `KeyedInterrupt` derives the key part from the ref's args, so concurrent\n * invocations can be targeted independently.\n *\n * Interrupting stops the client-side Effect and guarantees the invocation's\n * result Messages never dispatch — it does not cancel the Convex function on\n * the server, which runs to completion once the call is on the wire.\n */\nexport type InterruptOption<\n Ref_ extends Ref.AnyConfect,\n KeyField extends keyof SchemaArgs<Ref_> & string = keyof SchemaArgs<Ref_> &\n string,\n> = FoldkitCommand.InterruptOption<SchemaArgs<Ref_>, KeyField>;\n\n/**\n * The keyed arm of `InterruptOption`: `keyFields` declares the args the\n * `Interrupt` constructor requires; `toKey` derives the key part from them.\n */\nexport type KeyedInterrupt<\n Ref_ extends Ref.AnyConfect,\n KeyField extends keyof SchemaArgs<Ref_> & string,\n> = Exclude<InterruptOption<Ref_, KeyField>, true>;\n\n/**\n * An interruptible Command definition whose key is the Command name — the\n * ref-derived call signature intersected with Foldkit's\n * `Interruptible.DefinitionWithArgsNameKeyed`, which supplies the brand and\n * the `Interrupt` constructor.\n */\nexport type InterruptibleDefinition<\n Name extends string,\n Ref_ extends Ref.AnyConfect,\n Message,\n> = ((\n ...args: Ref.OptionalArgs<Ref_>\n) => Instance<Name, Ref_, Message> & Readonly<{ key: string }>) &\n FoldkitCommand.Interruptible.DefinitionWithArgsNameKeyed<\n Name,\n Ref.ArgsSchema<Ref_>[\"fields\"],\n Effect.Effect<Message, never, Client.Client>\n >;\n\n/**\n * An interruptible Command definition whose key is derived from the ref's\n * args — the ref-derived call signature intersected with Foldkit's\n * `Interruptible.DefinitionWithArgs`, which supplies the brand and the\n * key-args-taking `Interrupt` constructor.\n */\nexport type KeyedInterruptibleDefinition<\n Name extends string,\n Ref_ extends Ref.AnyConfect,\n KeyField extends keyof SchemaArgs<Ref_> & string,\n Message,\n> = ((\n ...args: Ref.OptionalArgs<Ref_>\n) => Instance<Name, Ref_, Message> & Readonly<{ key: string }>) &\n FoldkitCommand.Interruptible.DefinitionWithArgs<\n Name,\n Ref.ArgsSchema<Ref_>[\"fields\"],\n Pick<SchemaArgs<Ref_>, KeyField>,\n Effect.Effect<Message, never, Client.Client>\n >;\n\nconst run = <Ref_ extends Ref.AnyConfect, SuccessMessage, ErrorMessage>(\n handlers: Handlers<Ref_, SuccessMessage, ErrorMessage>,\n invoke: (\n client: Client.Client,\n ) => Effect.Effect<Ref.Returns<Ref_>, Error<Ref_>>,\n): Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client> =>\n Effect.flatMap(Client.Client, invoke).pipe(\n Effect.match({\n onSuccess: handlers.onSuccess,\n onFailure: handlers.onError,\n }),\n );\n\n/**\n * An execute body for a hand-written `Command.define` — every failure already\n * folded into a Message. Reach for these when the factory below doesn't fit:\n * a custom args schema, `interrupt`, or a Command that makes several calls.\n */\nexport const queryEffect =\n <Query extends Ref.AnyConfectPublicQuery, SuccessMessage, ErrorMessage>(\n ref: Query,\n handlers: Handlers<Query, SuccessMessage, ErrorMessage>,\n ) =>\n (\n ...args: Ref.OptionalArgs<Query>\n ): Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client> =>\n run(handlers, (client) => client.query(ref, ...args));\n\n/**\n * An execute body for a hand-written `Command.define` — every failure already\n * folded into a Message. See `queryEffect`.\n */\nexport const mutationEffect =\n <Mutation extends Ref.AnyConfectPublicMutation, SuccessMessage, ErrorMessage>(\n ref: Mutation,\n handlers: Handlers<Mutation, SuccessMessage, ErrorMessage>,\n ) =>\n (\n ...args: Ref.OptionalArgs<Mutation>\n ): Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client> =>\n run(handlers, (client) => client.mutation(ref, ...args));\n\n/**\n * An execute body for a hand-written `Command.define` — every failure already\n * folded into a Message. See `queryEffect`.\n */\nexport const actionEffect =\n <Action extends Ref.AnyConfectPublicAction, SuccessMessage, ErrorMessage>(\n ref: Action,\n handlers: Handlers<Action, SuccessMessage, ErrorMessage>,\n ) =>\n (\n ...args: Ref.OptionalArgs<Action>\n ): Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client> =>\n run(handlers, (client) => client.action(ref, ...args));\n\ntype RunWithArgs<Ref_ extends Ref.AnyConfect, Message> = (\n ...args: Ref.OptionalArgs<Ref_>\n) => Effect.Effect<Message, never, Client.Client>;\n\nfunction makeDefinition<\n Name extends string,\n Ref_ extends Ref.AnyConfect,\n SuccessMessage,\n ErrorMessage,\n KeyField extends keyof SchemaArgs<Ref_> & string = keyof SchemaArgs<Ref_> &\n string,\n>(\n name: Name,\n ref: Ref_,\n messages: ReadonlyArray<Schema.Top>,\n runWithArgs: RunWithArgs<Ref_, SuccessMessage | ErrorMessage>,\n interrupt?: InterruptOption<Ref_, KeyField>,\n): Definition<Name, Ref_, SuccessMessage | ErrorMessage> {\n type Fields = Ref.ArgsSchema<Ref_>[\"fields\"];\n type FoldkitArgs = SchemaArgs<Ref_>;\n\n const fields: Fields = ref.args.fields;\n const execute = (args: FoldkitArgs | undefined) =>\n runWithArgs(\n ...((args === undefined ? [] : [args]) as Ref.OptionalArgs<Ref_>),\n );\n\n return Match.value(interrupt).pipe(\n Match.withReturnType<\n Definition<Name, Ref_, SuccessMessage | ErrorMessage>\n >(),\n Match.when(\n undefined,\n () =>\n FoldkitCommand.define(name, {\n args: fields,\n messages,\n execute,\n }) as Definition<Name, Ref_, SuccessMessage | ErrorMessage>,\n ),\n Match.when(\n true,\n (nameKeyedInterrupt) =>\n FoldkitCommand.define(name, {\n args: fields,\n messages,\n interrupt: nameKeyedInterrupt,\n execute,\n }) as InterruptibleDefinition<\n Name,\n Ref_,\n SuccessMessage | ErrorMessage\n >,\n ),\n Match.when(Match.defined, (keyedInterrupt) => {\n const definition: FoldkitCommand.CommandDefinitionWithArgs<\n Name,\n Fields,\n ReturnType<typeof execute>\n > = FoldkitCommand.define(name, {\n args: fields,\n messages,\n interrupt: keyedInterrupt,\n execute,\n });\n return definition as Definition<\n Name,\n Ref_,\n SuccessMessage | ErrorMessage\n >;\n }),\n Match.exhaustive,\n );\n}\n\ntype FactoryConfig<\n Ref_ extends Ref.AnyConfect,\n Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage,\n ErrorMessage,\n> = Handlers<Ref_, SuccessMessage, ErrorMessage> & {\n readonly messages: Messages;\n};\n\ntype KeyedFactoryConfig<\n Ref_ extends Ref.AnyConfect,\n Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage,\n ErrorMessage,\n KeyField extends keyof SchemaArgs<Ref_> & string,\n> = FactoryConfig<Ref_, Messages, SuccessMessage, ErrorMessage> & {\n readonly interrupt: KeyedInterrupt<Ref_, KeyField>;\n};\n\ntype NameKeyedFactoryConfig<\n Ref_ extends Ref.AnyConfect,\n Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage,\n ErrorMessage,\n> = FactoryConfig<Ref_, Messages, SuccessMessage, ErrorMessage> & {\n readonly interrupt: true;\n};\n\ntype StandardFactoryConfig<\n Ref_ extends Ref.AnyConfect,\n Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage,\n ErrorMessage,\n> = FactoryConfig<Ref_, Messages, SuccessMessage, ErrorMessage> & {\n readonly interrupt?: never;\n};\n\n/**\n * Builds the overload set for one ref kind. Each arm preserves whether\n * `interrupt` is absent, `true`, or args-keyed all the way to\n * `makeDefinition`.\n */\nconst makeFactory = <BoundRef extends Ref.AnyConfect>(\n effectHelper: <Ref_ extends BoundRef, SuccessMessage, ErrorMessage>(\n ref: Ref_,\n handlers: Handlers<Ref_, SuccessMessage, ErrorMessage>,\n ) => RunWithArgs<Ref_, SuccessMessage | ErrorMessage>,\n) => {\n function factory<\n const Name extends string,\n Ref_ extends BoundRef,\n const Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage extends Schema.Schema.Type<Messages[number]>,\n ErrorMessage extends Schema.Schema.Type<Messages[number]>,\n KeyField extends keyof SchemaArgs<Ref_> & string,\n >(\n name: Name,\n ref: Ref_,\n config: KeyedFactoryConfig<\n Ref_,\n Messages,\n SuccessMessage,\n ErrorMessage,\n KeyField\n >,\n ): KeyedInterruptibleDefinition<\n Name,\n Ref_,\n KeyField,\n SuccessMessage | ErrorMessage\n >;\n function factory<\n const Name extends string,\n Ref_ extends BoundRef,\n const Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage extends Schema.Schema.Type<Messages[number]>,\n ErrorMessage extends Schema.Schema.Type<Messages[number]>,\n >(\n name: Name,\n ref: Ref_,\n config: NameKeyedFactoryConfig<\n Ref_,\n Messages,\n SuccessMessage,\n ErrorMessage\n >,\n ): InterruptibleDefinition<Name, Ref_, SuccessMessage | ErrorMessage>;\n function factory<\n const Name extends string,\n Ref_ extends BoundRef,\n const Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage extends Schema.Schema.Type<Messages[number]>,\n ErrorMessage extends Schema.Schema.Type<Messages[number]>,\n >(\n name: Name,\n ref: Ref_,\n config: StandardFactoryConfig<Ref_, Messages, SuccessMessage, ErrorMessage>,\n ): Definition<Name, Ref_, SuccessMessage | ErrorMessage>;\n function factory<\n const Name extends string,\n Ref_ extends BoundRef,\n SuccessMessage,\n ErrorMessage,\n KeyField extends keyof SchemaArgs<Ref_> & string,\n >(\n name: Name,\n ref: Ref_,\n config: FactoryConfig<\n Ref_,\n ReadonlyArray<Schema.Top>,\n SuccessMessage,\n ErrorMessage\n > & {\n readonly interrupt?: InterruptOption<Ref_, KeyField>;\n },\n ): Definition<Name, Ref_, SuccessMessage | ErrorMessage> {\n const runWithArgs = effectHelper(ref, config);\n return Match.value(config.interrupt).pipe(\n Match.withReturnType<\n Definition<Name, Ref_, SuccessMessage | ErrorMessage>\n >(),\n Match.when(undefined, () =>\n makeDefinition(name, ref, config.messages, runWithArgs),\n ),\n Match.when(true, (interrupt) =>\n makeDefinition(name, ref, config.messages, runWithArgs, interrupt),\n ),\n Match.when(Match.defined, (interrupt) =>\n makeDefinition(name, ref, config.messages, runWithArgs, interrupt),\n ),\n Match.exhaustive,\n );\n }\n\n return factory;\n};\n\n/**\n * A Foldkit Command definition for a Confect query whose Command args are the\n * ref's args:\n *\n * ```ts\n * const FetchNote = Command.query(\"FetchNote\", refs.public.notes.get, {\n * messages: [SucceededGetNote, FailedGetNote],\n * onSuccess: (note) => SucceededGetNote({ note }),\n * onError: (error) => FailedGetNote({ message: String(error) }),\n * })\n * // In update:\n * // [model, [FetchNote({ noteId })]]\n * ```\n *\n * Pass `interrupt` to make invocations interruptible via the returned\n * definition's `Interrupt` constructor — `true` keys them by the Command\n * name, `{ keyFields, toKey }` by a part derived from the ref's args:\n *\n * ```ts\n * const SaveDraft = Command.mutation(\"SaveDraft\", refs.public.notes.insert, {\n * messages: [SucceededSaveDraft, FailedSaveDraft],\n * onSuccess: (noteId) => SucceededSaveDraft({ noteId }),\n * onError: (error) => FailedSaveDraft({ message: String(error) }),\n * interrupt: true,\n * })\n * // In update:\n * // [model, [SaveDraft.Interrupt((outcome) => CompletedCancelSaveDraft({ outcome }))]]\n * ```\n */\nexport const query: ReturnType<typeof makeFactory<Ref.AnyConfectPublicQuery>> =\n makeFactory(queryEffect);\n\n/**\n * A Foldkit Command definition for a Confect mutation whose Command args are\n * the ref's args. See `query`.\n */\nexport const mutation: ReturnType<\n typeof makeFactory<Ref.AnyConfectPublicMutation>\n> = makeFactory(mutationEffect);\n\n/**\n * A Foldkit Command definition for a Confect action whose Command args are\n * the ref's args. See `query`.\n */\nexport const action: ReturnType<\n typeof makeFactory<Ref.AnyConfectPublicAction>\n> = makeFactory(actionEffect);\n"],"mappings":";;;;;;;;;;;;;;AAyIA,MAAM,OACJ,UACA,WAIA,OAAO,QAAQA,QAAe,MAAM,CAAC,CAAC,KACpC,OAAO,MAAM;CACX,WAAW,SAAS;CACpB,WAAW,SAAS;AACtB,CAAC,CACH;;;;;;AAOF,MAAa,eAET,KACA,cAGA,GAAG,SAEH,IAAI,WAAW,WAAW,OAAO,MAAM,KAAK,GAAG,IAAI,CAAC;;;;;AAMxD,MAAa,kBAET,KACA,cAGA,GAAG,SAEH,IAAI,WAAW,WAAW,OAAO,SAAS,KAAK,GAAG,IAAI,CAAC;;;;;AAM3D,MAAa,gBAET,KACA,cAGA,GAAG,SAEH,IAAI,WAAW,WAAW,OAAO,OAAO,KAAK,GAAG,IAAI,CAAC;AAMzD,SAAS,eAQP,MACA,KACA,UACA,aACA,WACuD;CAIvD,MAAM,SAAiB,IAAI,KAAK;CAChC,MAAM,WAAW,SACf,YACE,GAAK,SAAS,KAAA,IAAY,CAAC,IAAI,CAAC,IAAI,CACtC;CAEF,OAAO,MAAM,MAAM,SAAS,CAAC,CAAC,KAC5B,MAAM,eAEJ,GACF,MAAM,KACJ,KAAA,SAEE,eAAe,OAAO,MAAM;EAC1B,MAAM;EACN;EACA;CACF,CAAC,CACL,GACA,MAAM,KACJ,OACC,uBACC,eAAe,OAAO,MAAM;EAC1B,MAAM;EACN;EACA,WAAW;EACX;CACF,CAAC,CAKL,GACA,MAAM,KAAK,MAAM,UAAU,mBAAmB;EAW5C,OANI,eAAe,OAAO,MAAM;GAC9B,MAAM;GACN;GACA,WAAW;GACX;EACF,CACgB;CAKlB,CAAC,GACD,MAAM,UACR;AACF;;;;;;AA4CA,MAAM,eACJ,iBAIG;CAmDH,SAAS,QAOP,MACA,KACA,QAQuD;EACvD,MAAM,cAAc,aAAa,KAAK,MAAM;EAC5C,OAAO,MAAM,MAAM,OAAO,SAAS,CAAC,CAAC,KACnC,MAAM,eAEJ,GACF,MAAM,KAAK,KAAA,SACT,eAAe,MAAM,KAAK,OAAO,UAAU,WAAW,CACxD,GACA,MAAM,KAAK,OAAO,cAChB,eAAe,MAAM,KAAK,OAAO,UAAU,aAAa,SAAS,CACnE,GACA,MAAM,KAAK,MAAM,UAAU,cACzB,eAAe,MAAM,KAAK,OAAO,UAAU,aAAa,SAAS,CACnE,GACA,MAAM,UACR;CACF;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,QACX,YAAY,WAAW;;;;;AAMzB,MAAa,WAET,YAAY,cAAc;;;;;AAM9B,MAAa,SAET,YAAY,YAAY"}
|
|
1
|
+
{"version":3,"file":"Command.js","names":["Client.Client"],"sources":["../src/Command.ts"],"sourcesContent":["import type * as Ref from \"@confect/core/Ref\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport type * as Schema from \"effect/Schema\";\nimport * as FoldkitCommand from \"foldkit/command\";\nimport * as Client from \"./Client\";\n\n/**\n * Everything a Command against `Ref_` can fail with before it is folded into\n * an `onError` Message: the ref's typed error (if it declares an `error`\n * schema), a transport-level `WebSocketClientError`, or a `SchemaError` from\n * encoding args or decoding returns.\n */\nexport type Error<Ref_ extends Ref.AnyConfect> =\n | Ref.Error<Ref_>\n | Client.WebSocketClientError\n | Schema.SchemaError;\n\n/**\n * Maps a Confect function's outcome into the app's Messages. Every failure—the ref's typed error, a transport error, or a codec error—arrives via\n * `onError`, so the resulting Command's error channel is `never`, as Foldkit\n * requires. Follow Foldkit's naming convention: past-tense facts like\n * `SucceededSaveNote`/`FailedSaveNote`.\n */\nexport interface Handlers<\n Ref_ extends Ref.AnyConfect,\n SuccessMessage,\n ErrorMessage,\n> {\n readonly onSuccess: (returns: Ref.Returns<Ref_>) => SuccessMessage;\n readonly onError: (error: Error<Ref_>) => ErrorMessage;\n}\n\n/**\n * The Command instance a definition call constructs.\n */\ntype Instance<\n Name extends string,\n Ref_ extends Ref.AnyConfect,\n Message,\n> = Readonly<{\n name: Name;\n args: Ref.Args<Ref_>;\n effect: Effect.Effect<Message, never, Client.Client>;\n}>;\n\ntype SchemaArgs<Ref_ extends Ref.AnyConfect> = Schema.Schema.Type<\n Schema.Struct<Ref.ArgsSchema<Ref_>[\"fields\"]>\n>;\n\n/**\n * A Foldkit Command definition whose args are the ref's args: our\n * ref-derived call signature (args optional when the ref declares none)\n * intersected with Foldkit's own `CommandDefinitionWithArgs`, which supplies\n * the `CommandDefinitionTypeId` brand and makes the definition assignable\n * wherever Foldkit accepts one—including Story/Scene `Command.resolve`\n * and `expectExact` matchers. Call it from `update` to construct a Command\n * instance; nothing runs until the Foldkit runtime executes it.\n */\nexport type Definition<\n Name extends string,\n Ref_ extends Ref.AnyConfect,\n Message,\n> = ((...args: Ref.OptionalArgs<Ref_>) => Instance<Name, Ref_, Message>) &\n FoldkitCommand.CommandDefinitionWithArgs<\n Name,\n Ref.ArgsSchema<Ref_>[\"fields\"],\n Effect.Effect<Message, never, Client.Client>\n >;\n\n/**\n * Makes a factory-built Command interruptible—Foldkit's `InterruptOption`\n * applied to the ref's args. `true` keys every invocation by the Command\n * name—right when at most one invocation is meaningfully in flight; a\n * `KeyedInterrupt` derives the key part from the ref's args, so concurrent\n * invocations can be targeted independently.\n *\n * Interrupting stops the client-side Effect and guarantees the invocation's\n * result Messages never dispatch—it does not cancel the Convex function on\n * the server, which runs to completion once the call is on the wire.\n */\nexport type InterruptOption<\n Ref_ extends Ref.AnyConfect,\n KeyField extends keyof SchemaArgs<Ref_> & string = keyof SchemaArgs<Ref_> &\n string,\n> = FoldkitCommand.InterruptOption<SchemaArgs<Ref_>, KeyField>;\n\n/**\n * The keyed arm of `InterruptOption`: `keyFields` declares the args the\n * `Interrupt` constructor requires; `toKey` derives the key part from them.\n */\nexport type KeyedInterrupt<\n Ref_ extends Ref.AnyConfect,\n KeyField extends keyof SchemaArgs<Ref_> & string,\n> = Exclude<InterruptOption<Ref_, KeyField>, true>;\n\n/**\n * An interruptible Command definition whose key is the Command name—the\n * ref-derived call signature intersected with Foldkit's\n * `Interruptible.DefinitionWithArgsNameKeyed`, which supplies the brand and\n * the `Interrupt` constructor.\n */\nexport type InterruptibleDefinition<\n Name extends string,\n Ref_ extends Ref.AnyConfect,\n Message,\n> = ((\n ...args: Ref.OptionalArgs<Ref_>\n) => Instance<Name, Ref_, Message> & Readonly<{ key: string }>) &\n FoldkitCommand.Interruptible.DefinitionWithArgsNameKeyed<\n Name,\n Ref.ArgsSchema<Ref_>[\"fields\"],\n Effect.Effect<Message, never, Client.Client>\n >;\n\n/**\n * An interruptible Command definition whose key is derived from the ref's\n * args—the ref-derived call signature intersected with Foldkit's\n * `Interruptible.DefinitionWithArgs`, which supplies the brand and the\n * key-args-taking `Interrupt` constructor.\n */\nexport type KeyedInterruptibleDefinition<\n Name extends string,\n Ref_ extends Ref.AnyConfect,\n KeyField extends keyof SchemaArgs<Ref_> & string,\n Message,\n> = ((\n ...args: Ref.OptionalArgs<Ref_>\n) => Instance<Name, Ref_, Message> & Readonly<{ key: string }>) &\n FoldkitCommand.Interruptible.DefinitionWithArgs<\n Name,\n Ref.ArgsSchema<Ref_>[\"fields\"],\n Pick<SchemaArgs<Ref_>, KeyField>,\n Effect.Effect<Message, never, Client.Client>\n >;\n\nconst run = <Ref_ extends Ref.AnyConfect, SuccessMessage, ErrorMessage>(\n handlers: Handlers<Ref_, SuccessMessage, ErrorMessage>,\n invoke: (\n client: Client.Client,\n ) => Effect.Effect<Ref.Returns<Ref_>, Error<Ref_>>,\n): Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client> =>\n Effect.flatMap(Client.Client, invoke).pipe(\n Effect.match({\n onSuccess: handlers.onSuccess,\n onFailure: handlers.onError,\n }),\n );\n\n/**\n * An execute body for a hand-written `Command.define`—every failure already\n * folded into a Message. Reach for these when the factory below doesn't fit:\n * a custom args schema, `interrupt`, or a Command that makes several calls.\n */\nexport const queryEffect =\n <Query extends Ref.AnyConfectPublicQuery, SuccessMessage, ErrorMessage>(\n ref: Query,\n handlers: Handlers<Query, SuccessMessage, ErrorMessage>,\n ) =>\n (\n ...args: Ref.OptionalArgs<Query>\n ): Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client> =>\n run(handlers, (client) => client.query(ref, ...args));\n\n/**\n * An execute body for a hand-written `Command.define`—every failure already\n * folded into a Message. See `queryEffect`.\n */\nexport const mutationEffect =\n <Mutation extends Ref.AnyConfectPublicMutation, SuccessMessage, ErrorMessage>(\n ref: Mutation,\n handlers: Handlers<Mutation, SuccessMessage, ErrorMessage>,\n ) =>\n (\n ...args: Ref.OptionalArgs<Mutation>\n ): Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client> =>\n run(handlers, (client) => client.mutation(ref, ...args));\n\n/**\n * An execute body for a hand-written `Command.define`—every failure already\n * folded into a Message. See `queryEffect`.\n */\nexport const actionEffect =\n <Action extends Ref.AnyConfectPublicAction, SuccessMessage, ErrorMessage>(\n ref: Action,\n handlers: Handlers<Action, SuccessMessage, ErrorMessage>,\n ) =>\n (\n ...args: Ref.OptionalArgs<Action>\n ): Effect.Effect<SuccessMessage | ErrorMessage, never, Client.Client> =>\n run(handlers, (client) => client.action(ref, ...args));\n\ntype RunWithArgs<Ref_ extends Ref.AnyConfect, Message> = (\n ...args: Ref.OptionalArgs<Ref_>\n) => Effect.Effect<Message, never, Client.Client>;\n\nfunction makeDefinition<\n Name extends string,\n Ref_ extends Ref.AnyConfect,\n SuccessMessage,\n ErrorMessage,\n KeyField extends keyof SchemaArgs<Ref_> & string = keyof SchemaArgs<Ref_> &\n string,\n>(\n name: Name,\n ref: Ref_,\n messages: ReadonlyArray<Schema.Top>,\n runWithArgs: RunWithArgs<Ref_, SuccessMessage | ErrorMessage>,\n interrupt?: InterruptOption<Ref_, KeyField>,\n): Definition<Name, Ref_, SuccessMessage | ErrorMessage> {\n type Fields = Ref.ArgsSchema<Ref_>[\"fields\"];\n type FoldkitArgs = SchemaArgs<Ref_>;\n\n const fields: Fields = ref.args.fields;\n const execute = (args: FoldkitArgs | undefined) =>\n runWithArgs(\n ...((args === undefined ? [] : [args]) as Ref.OptionalArgs<Ref_>),\n );\n\n return Match.value(interrupt).pipe(\n Match.withReturnType<\n Definition<Name, Ref_, SuccessMessage | ErrorMessage>\n >(),\n Match.when(\n undefined,\n () =>\n FoldkitCommand.define(name, {\n args: fields,\n messages,\n execute,\n }) as Definition<Name, Ref_, SuccessMessage | ErrorMessage>,\n ),\n Match.when(\n true,\n (nameKeyedInterrupt) =>\n FoldkitCommand.define(name, {\n args: fields,\n messages,\n interrupt: nameKeyedInterrupt,\n execute,\n }) as InterruptibleDefinition<\n Name,\n Ref_,\n SuccessMessage | ErrorMessage\n >,\n ),\n Match.when(Match.defined, (keyedInterrupt) => {\n const definition: FoldkitCommand.CommandDefinitionWithArgs<\n Name,\n Fields,\n ReturnType<typeof execute>\n > = FoldkitCommand.define(name, {\n args: fields,\n messages,\n interrupt: keyedInterrupt,\n execute,\n });\n return definition as Definition<\n Name,\n Ref_,\n SuccessMessage | ErrorMessage\n >;\n }),\n Match.exhaustive,\n );\n}\n\ntype FactoryConfig<\n Ref_ extends Ref.AnyConfect,\n Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage,\n ErrorMessage,\n> = Handlers<Ref_, SuccessMessage, ErrorMessage> & {\n readonly messages: Messages;\n};\n\ntype KeyedFactoryConfig<\n Ref_ extends Ref.AnyConfect,\n Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage,\n ErrorMessage,\n KeyField extends keyof SchemaArgs<Ref_> & string,\n> = FactoryConfig<Ref_, Messages, SuccessMessage, ErrorMessage> & {\n readonly interrupt: KeyedInterrupt<Ref_, KeyField>;\n};\n\ntype NameKeyedFactoryConfig<\n Ref_ extends Ref.AnyConfect,\n Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage,\n ErrorMessage,\n> = FactoryConfig<Ref_, Messages, SuccessMessage, ErrorMessage> & {\n readonly interrupt: true;\n};\n\ntype StandardFactoryConfig<\n Ref_ extends Ref.AnyConfect,\n Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage,\n ErrorMessage,\n> = FactoryConfig<Ref_, Messages, SuccessMessage, ErrorMessage> & {\n readonly interrupt?: never;\n};\n\n/**\n * Builds the overload set for one ref kind. Each arm preserves whether\n * `interrupt` is absent, `true`, or args-keyed all the way to\n * `makeDefinition`.\n */\nconst makeFactory = <BoundRef extends Ref.AnyConfect>(\n effectHelper: <Ref_ extends BoundRef, SuccessMessage, ErrorMessage>(\n ref: Ref_,\n handlers: Handlers<Ref_, SuccessMessage, ErrorMessage>,\n ) => RunWithArgs<Ref_, SuccessMessage | ErrorMessage>,\n) => {\n function factory<\n const Name extends string,\n Ref_ extends BoundRef,\n const Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage extends Schema.Schema.Type<Messages[number]>,\n ErrorMessage extends Schema.Schema.Type<Messages[number]>,\n KeyField extends keyof SchemaArgs<Ref_> & string,\n >(\n name: Name,\n ref: Ref_,\n config: KeyedFactoryConfig<\n Ref_,\n Messages,\n SuccessMessage,\n ErrorMessage,\n KeyField\n >,\n ): KeyedInterruptibleDefinition<\n Name,\n Ref_,\n KeyField,\n SuccessMessage | ErrorMessage\n >;\n function factory<\n const Name extends string,\n Ref_ extends BoundRef,\n const Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage extends Schema.Schema.Type<Messages[number]>,\n ErrorMessage extends Schema.Schema.Type<Messages[number]>,\n >(\n name: Name,\n ref: Ref_,\n config: NameKeyedFactoryConfig<\n Ref_,\n Messages,\n SuccessMessage,\n ErrorMessage\n >,\n ): InterruptibleDefinition<Name, Ref_, SuccessMessage | ErrorMessage>;\n function factory<\n const Name extends string,\n Ref_ extends BoundRef,\n const Messages extends ReadonlyArray<Schema.Top>,\n SuccessMessage extends Schema.Schema.Type<Messages[number]>,\n ErrorMessage extends Schema.Schema.Type<Messages[number]>,\n >(\n name: Name,\n ref: Ref_,\n config: StandardFactoryConfig<Ref_, Messages, SuccessMessage, ErrorMessage>,\n ): Definition<Name, Ref_, SuccessMessage | ErrorMessage>;\n function factory<\n const Name extends string,\n Ref_ extends BoundRef,\n SuccessMessage,\n ErrorMessage,\n KeyField extends keyof SchemaArgs<Ref_> & string,\n >(\n name: Name,\n ref: Ref_,\n config: FactoryConfig<\n Ref_,\n ReadonlyArray<Schema.Top>,\n SuccessMessage,\n ErrorMessage\n > & {\n readonly interrupt?: InterruptOption<Ref_, KeyField>;\n },\n ): Definition<Name, Ref_, SuccessMessage | ErrorMessage> {\n const runWithArgs = effectHelper(ref, config);\n return Match.value(config.interrupt).pipe(\n Match.withReturnType<\n Definition<Name, Ref_, SuccessMessage | ErrorMessage>\n >(),\n Match.when(undefined, () =>\n makeDefinition(name, ref, config.messages, runWithArgs),\n ),\n Match.when(true, (interrupt) =>\n makeDefinition(name, ref, config.messages, runWithArgs, interrupt),\n ),\n Match.when(Match.defined, (interrupt) =>\n makeDefinition(name, ref, config.messages, runWithArgs, interrupt),\n ),\n Match.exhaustive,\n );\n }\n\n return factory;\n};\n\n/**\n * A Foldkit Command definition for a Confect query whose Command args are the\n * ref's args:\n *\n * ```ts\n * const FetchNote = Command.query(\"FetchNote\", refs.public.notes.get, {\n * messages: [SucceededGetNote, FailedGetNote],\n * onSuccess: (note) => SucceededGetNote({ note }),\n * onError: (error) => FailedGetNote({ message: String(error) }),\n * })\n * // In update:\n * // [model, [FetchNote({ noteId })]]\n * ```\n *\n * Pass `interrupt` to make invocations interruptible via the returned\n * definition's `Interrupt` constructor—`true` keys them by the Command\n * name, `{ keyFields, toKey }` by a part derived from the ref's args:\n *\n * ```ts\n * const SaveDraft = Command.mutation(\"SaveDraft\", refs.public.notes.insert, {\n * messages: [SucceededSaveDraft, FailedSaveDraft],\n * onSuccess: (noteId) => SucceededSaveDraft({ noteId }),\n * onError: (error) => FailedSaveDraft({ message: String(error) }),\n * interrupt: true,\n * })\n * // In update:\n * // [model, [SaveDraft.Interrupt((outcome) => CompletedCancelSaveDraft({ outcome }))]]\n * ```\n */\nexport const query: ReturnType<typeof makeFactory<Ref.AnyConfectPublicQuery>> =\n makeFactory(queryEffect);\n\n/**\n * A Foldkit Command definition for a Confect mutation whose Command args are\n * the ref's args. See `query`.\n */\nexport const mutation: ReturnType<\n typeof makeFactory<Ref.AnyConfectPublicMutation>\n> = makeFactory(mutationEffect);\n\n/**\n * A Foldkit Command definition for a Confect action whose Command args are\n * the ref's args. See `query`.\n */\nexport const action: ReturnType<\n typeof makeFactory<Ref.AnyConfectPublicAction>\n> = makeFactory(actionEffect);\n"],"mappings":";;;;;;;;;;;;;;AAwIA,MAAM,OACJ,UACA,WAIA,OAAO,QAAQA,QAAe,MAAM,CAAC,CAAC,KACpC,OAAO,MAAM;CACX,WAAW,SAAS;CACpB,WAAW,SAAS;AACtB,CAAC,CACH;;;;;;AAOF,MAAa,eAET,KACA,cAGA,GAAG,SAEH,IAAI,WAAW,WAAW,OAAO,MAAM,KAAK,GAAG,IAAI,CAAC;;;;;AAMxD,MAAa,kBAET,KACA,cAGA,GAAG,SAEH,IAAI,WAAW,WAAW,OAAO,SAAS,KAAK,GAAG,IAAI,CAAC;;;;;AAM3D,MAAa,gBAET,KACA,cAGA,GAAG,SAEH,IAAI,WAAW,WAAW,OAAO,OAAO,KAAK,GAAG,IAAI,CAAC;AAMzD,SAAS,eAQP,MACA,KACA,UACA,aACA,WACuD;CAIvD,MAAM,SAAiB,IAAI,KAAK;CAChC,MAAM,WAAW,SACf,YACE,GAAK,SAAS,KAAA,IAAY,CAAC,IAAI,CAAC,IAAI,CACtC;CAEF,OAAO,MAAM,MAAM,SAAS,CAAC,CAAC,KAC5B,MAAM,eAEJ,GACF,MAAM,KACJ,KAAA,SAEE,eAAe,OAAO,MAAM;EAC1B,MAAM;EACN;EACA;CACF,CAAC,CACL,GACA,MAAM,KACJ,OACC,uBACC,eAAe,OAAO,MAAM;EAC1B,MAAM;EACN;EACA,WAAW;EACX;CACF,CAAC,CAKL,GACA,MAAM,KAAK,MAAM,UAAU,mBAAmB;EAW5C,OANI,eAAe,OAAO,MAAM;GAC9B,MAAM;GACN;GACA,WAAW;GACX;EACF,CACgB;CAKlB,CAAC,GACD,MAAM,UACR;AACF;;;;;;AA4CA,MAAM,eACJ,iBAIG;CAmDH,SAAS,QAOP,MACA,KACA,QAQuD;EACvD,MAAM,cAAc,aAAa,KAAK,MAAM;EAC5C,OAAO,MAAM,MAAM,OAAO,SAAS,CAAC,CAAC,KACnC,MAAM,eAEJ,GACF,MAAM,KAAK,KAAA,SACT,eAAe,MAAM,KAAK,OAAO,UAAU,WAAW,CACxD,GACA,MAAM,KAAK,OAAO,cAChB,eAAe,MAAM,KAAK,OAAO,UAAU,aAAa,SAAS,CACnE,GACA,MAAM,KAAK,MAAM,UAAU,cACzB,eAAe,MAAM,KAAK,OAAO,UAAU,aAAa,SAAS,CACnE,GACA,MAAM,UACR;CACF;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,QACX,YAAY,WAAW;;;;;AAMzB,MAAa,WAET,YAAY,cAAc;;;;;AAM9B,MAAa,SAET,YAAY,YAAY"}
|
package/dist/PaginatedQuery.d.ts
CHANGED
|
@@ -163,7 +163,17 @@ export declare const allocateRequest: <UserArgs_>(request: SubscriptionRequest<U
|
|
|
163
163
|
export declare const close: <Item_, UserArgs_, Error_>(state: Active<Item_, UserArgs_, Error_>) => Idle;
|
|
164
164
|
/** Start a fresh pagination session at page one while retaining visible data. */
|
|
165
165
|
export declare const reset: <Item_, UserArgs_, Error_>(state: Active<Item_, UserArgs_, Error_>) => Active<Item_, UserArgs_, Error_>;
|
|
166
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Navigate to the next page, retaining the current page while it loads.
|
|
168
|
+
*
|
|
169
|
+
* The page being left is pushed onto the stack *pinned* to the range it
|
|
170
|
+
* displayed—its cursor to its continuation cursor—so `prev` reloads
|
|
171
|
+
* exactly that range rather than the first `initialNumItems` documents
|
|
172
|
+
* after its cursor, however the data has moved meanwhile. Convex's own
|
|
173
|
+
* pagination keeps that range in its query journal; stream-paginated
|
|
174
|
+
* queries have no journal, so the pin is what keeps consecutive pages
|
|
175
|
+
* gap-free and duplicate-free for them.
|
|
176
|
+
*/
|
|
167
177
|
export declare const next: <Item_, UserArgs_, Error_>(state: Active<Item_, UserArgs_, Error_>) => Option.Option<Active<Item_, UserArgs_, Error_>>;
|
|
168
178
|
/** Navigate to the previous page, retaining the current page while it loads. */
|
|
169
179
|
export declare const prev: <Item_, UserArgs_, Error_>(state: Active<Item_, UserArgs_, Error_>) => Option.Option<Active<Item_, UserArgs_, Error_>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginatedQuery.d.ts","sourceRoot":"","sources":["../src/PaginatedQuery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,eAAe,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAGpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,cAAc;;;EAGzB,CAAC;AAEH,4DAA4D;AAC5D,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AAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EACzC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EACtC,QAAQ,EAAE;QACR,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC;QACnC,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,CAAC;QAC5C,QAAQ,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5D,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpD,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACrD,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACpD,GACA,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CA4B1B,CAAC"}
|
package/dist/PaginatedQuery.js
CHANGED
|
@@ -223,20 +223,36 @@ const reset = (state) => ({
|
|
|
223
223
|
prevStack: [],
|
|
224
224
|
phase: pendingPhase(phaseData(state.phase), "Reset")
|
|
225
225
|
});
|
|
226
|
-
/**
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
226
|
+
/**
|
|
227
|
+
* Navigate to the next page, retaining the current page while it loads.
|
|
228
|
+
*
|
|
229
|
+
* The page being left is pushed onto the stack *pinned* to the range it
|
|
230
|
+
* displayed—its cursor to its continuation cursor—so `prev` reloads
|
|
231
|
+
* exactly that range rather than the first `initialNumItems` documents
|
|
232
|
+
* after its cursor, however the data has moved meanwhile. Convex's own
|
|
233
|
+
* pagination keeps that range in its query journal; stream-paginated
|
|
234
|
+
* queries have no journal, so the pin is what keeps consecutive pages
|
|
235
|
+
* gap-free and duplicate-free for them.
|
|
236
|
+
*/
|
|
237
|
+
const next = (state) => Match.value(state.phase).pipe(Match.withReturnType(), Match.tag("Success", ({ data }) => Match.value(data.isDone).pipe(Match.withReturnType(), Match.when(true, () => Option.none()), Match.when(false, () => {
|
|
238
|
+
const end = Option.getOrElse(data.descriptor.endCursor, () => data.continueCursor);
|
|
239
|
+
return Option.some({
|
|
240
|
+
...state,
|
|
241
|
+
requestId: state.requestId + 1,
|
|
242
|
+
current: {
|
|
243
|
+
cursor: end,
|
|
244
|
+
endCursor: Option.none()
|
|
245
|
+
},
|
|
246
|
+
prevStack: [...state.prevStack, {
|
|
247
|
+
cursor: data.descriptor.cursor,
|
|
248
|
+
endCursor: Option.some(end)
|
|
249
|
+
}],
|
|
250
|
+
phase: Phase.Refreshing({
|
|
251
|
+
data,
|
|
252
|
+
direction: "Next"
|
|
253
|
+
})
|
|
254
|
+
});
|
|
255
|
+
}), Match.exhaustive)), Match.tag("Loading", "Refreshing", "Failure", "Stale", () => Option.none()), Match.exhaustive);
|
|
240
256
|
/** Navigate to the previous page, retaining the current page while it loads. */
|
|
241
257
|
const prev = (state) => Match.value(state.phase).pipe(Match.withReturnType(), Match.tag("Success", ({ data }) => {
|
|
242
258
|
const current = state.prevStack.at(-1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginatedQuery.js","names":["Client.WebSocketClientError"],"sources":["../src/PaginatedQuery.ts"],"sourcesContent":["import * as MiddlewareSpec from \"@confect/core/MiddlewareSpec\";\nimport * as PaginationError from \"@confect/core/PaginationError\";\nimport * as Ref from \"@confect/core/Ref\";\nimport * as Data from \"effect/Data\";\nimport * as Function from \"effect/Function\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaGetter from \"effect/SchemaGetter\";\nimport * as SchemaIssue from \"effect/SchemaIssue\";\nimport * as Client from \"./Client\";\n\n/** Identifies the cursor range fetched for one page. */\nexport interface PageDescriptor {\n readonly cursor: string | null;\n readonly endCursor: Option.Option<string>;\n}\n\nexport const PageDescriptor = Schema.Struct({\n cursor: Schema.Union([Schema.String, Schema.Null]),\n endCursor: Schema.Option(Schema.String),\n});\n\n/** Options that remain fixed for one pagination session. */\nexport interface Options {\n readonly initialNumItems: number;\n readonly maximumRowsRead?: number;\n readonly maximumBytesRead?: number;\n}\n\nconst PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));\nconst NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\n\nexport const Options = Schema.Struct({\n initialNumItems: PositiveInt,\n maximumRowsRead: Schema.optionalKey(PositiveInt),\n maximumBytesRead: Schema.optionalKey(PositiveInt),\n});\n\n/** Why the machine is fetching its current target. */\nexport type Direction =\n | \"Initial\"\n | \"Next\"\n | \"Previous\"\n | \"First\"\n | \"Split\"\n | \"Reset\";\n\n/** A complete page that can remain on screen while another page is fetched. */\nexport interface Page<Item_> {\n readonly descriptor: PageDescriptor;\n readonly number: number;\n readonly items: ReadonlyArray<Item_>;\n readonly continueCursor: string;\n readonly isDone: boolean;\n}\n\nexport type Loading = Data.TaggedEnum<{\n Loading: { readonly direction: Direction };\n}>;\n\nexport type Refreshing<Item_> = Data.TaggedEnum<{\n Refreshing: { readonly data: Page<Item_>; readonly direction: Direction };\n}>;\n\nexport type Success<Item_> = Data.TaggedEnum<{\n Success: { readonly data: Page<Item_> };\n}>;\n\nexport type Failure<Error_> = Data.TaggedEnum<{\n Failure: { readonly error: Error_ };\n}>;\n\nexport type Stale<Item_, Error_> = Data.TaggedEnum<{\n Stale: { readonly data: Page<Item_>; readonly error: Error_ };\n}>;\n\nexport type Phase<Item_, Error_> =\n | Loading\n | Refreshing<Item_>\n | Success<Item_>\n | Failure<Error_>\n | Stale<Item_, Error_>;\n\ninterface PhaseDefinition extends Data.TaggedEnum.WithGenerics<2> {\n readonly taggedEnum: Phase<this[\"A\"], this[\"B\"]>;\n}\n\nconst Phase = Data.taggedEnum<PhaseDefinition>();\n\n/** A closed machine that retains its generation for stale-result rejection. */\nexport type Idle = Data.TaggedEnum<{\n Idle: { readonly generation: number };\n}>;\n\n/** A live cursor-pagination session. */\nexport type Active<Item_, UserArgs_, Error_> = Data.TaggedEnum<{\n Active: {\n readonly generation: number;\n readonly args: UserArgs_;\n readonly options: Options;\n readonly paginationId: Option.Option<number>;\n readonly requestId: number;\n readonly current: PageDescriptor;\n readonly prevStack: ReadonlyArray<PageDescriptor>;\n readonly phase: Phase<Item_, Error_>;\n };\n}>;\n\n/** A schema-backed cursor-pagination machine. */\nexport type State<Item_, UserArgs_, Error_> =\n | Idle\n | Active<Item_, UserArgs_, Error_>;\n\ninterface StateDefinition extends Data.TaggedEnum.WithGenerics<3> {\n readonly taggedEnum: State<this[\"A\"], this[\"B\"], this[\"C\"]>;\n}\n\nconst State = Data.taggedEnum<StateDefinition>();\n\n/** The logical request from which a subscription allocates a session id. */\nexport interface SubscriptionRequest<UserArgs_> {\n readonly generation: number;\n readonly args: UserArgs_;\n readonly options: Options;\n readonly paginationId: Option.Option<number>;\n readonly requestId: number;\n readonly descriptor: PageDescriptor;\n}\n\n/** The complete identity and arguments of a subscribed page request. */\nexport interface Request<UserArgs_> {\n readonly generation: number;\n readonly args: UserArgs_;\n readonly options: Options;\n readonly paginationId: number;\n readonly requestId: number;\n readonly descriptor: PageDescriptor;\n}\n\n/** The successful payload returned by a Convex paginated query. */\nexport interface PageResult<Item_> {\n readonly page: ReadonlyArray<Item_>;\n readonly isDone: boolean;\n readonly continueCursor: string;\n readonly splitCursor?: string | null;\n readonly pageStatus?: \"SplitRecommended\" | \"SplitRequired\" | null;\n}\n\n/**\n * One correlated subscription outcome. Both success and failure travel\n * through this value so `settle` can mirror `AsyncData.settle`.\n */\nexport interface Settlement<Item_, UserArgs_, Error_> {\n readonly request: Request<UserArgs_>;\n readonly result: Result.Result<PageResult<Item_>, Error_>;\n}\n\nexport type Item<Query extends Ref.AnyConfectPublicPaginatedQuery> =\n Ref.Returns<Query>[\"page\"][number];\n\nexport type UserArgs<Query extends Ref.AnyConfectPublicPaginatedQuery> = Omit<\n Ref.Args<Query>,\n \"paginationOpts\"\n>;\n\ntype TaggedFunctionError<Error_> = Data.TaggedEnum<{\n FunctionError: { readonly error: Error_ };\n}>;\n\ninterface FunctionErrorDefinition extends Data.TaggedEnum.WithGenerics<1> {\n readonly taggedEnum: TaggedFunctionError<this[\"A\"]>;\n}\n\n/** Constructs a declared function or middleware failure envelope. */\nexport const FunctionError =\n Data.taggedEnum<FunctionErrorDefinition>().FunctionError;\n\n/** A declared function or middleware failure, kept distinct from client errors. */\nexport type FunctionError<Query extends Ref.AnyConfectPublicPaginatedQuery> = [\n Ref.Error<Query>,\n] extends [never]\n ? never\n : TaggedFunctionError<Ref.Error<Query>>;\n\n/** Every failure a paginated query subscription can settle with. */\nexport type Error<Query extends Ref.AnyConfectPublicPaginatedQuery> =\n | FunctionError<Query>\n | PaginationError.InvalidCursor\n | Client.WebSocketClientError\n | Schema.SchemaError;\n\nexport { InvalidCursor } from \"@confect/core/PaginationError\";\n\ntype MachineState<Query extends Ref.AnyConfectPublicPaginatedQuery> = State<\n Item<Query>,\n UserArgs<Query>,\n Error<Query>\n>;\n\ntype MachineActive<Query extends Ref.AnyConfectPublicPaginatedQuery> = Active<\n Item<Query>,\n UserArgs<Query>,\n Error<Query>\n>;\n\n/** The schema-and-constructor bundle returned by `make`. */\nexport interface PaginatedQuery<\n Query extends Ref.AnyConfectPublicPaginatedQuery,\n> {\n readonly ref: Query;\n readonly schema: Schema.Codec<MachineState<Query>, unknown>;\n readonly idle: Idle;\n readonly subscriptionRequestSchema: Schema.Codec<\n SubscriptionRequest<UserArgs<Query>>,\n unknown\n >;\n readonly requestSchema: Schema.Codec<Request<UserArgs<Query>>, unknown>;\n readonly settlement: Schema.Codec<\n Settlement<Item<Query>, UserArgs<Query>, Error<Query>>,\n unknown\n >;\n readonly init: keyof UserArgs<Query> extends never\n ? (state: Idle, options: Options) => MachineActive<Query>\n : (\n state: Idle,\n args: UserArgs<Query>,\n options: Options,\n ) => MachineActive<Query>;\n readonly reinitialize: keyof UserArgs<Query> extends never\n ? (state: MachineActive<Query>, options?: Options) => MachineActive<Query>\n : (\n state: MachineActive<Query>,\n args: UserArgs<Query>,\n options?: Options,\n ) => MachineActive<Query>;\n}\n\nexport type Any = PaginatedQuery<Ref.AnyConfectPublicPaginatedQuery>;\n\nconst firstDescriptor = (): PageDescriptor => ({\n cursor: null,\n endCursor: Option.none(),\n});\n\nconst decodeOptions = Schema.decodeUnknownSync(Options);\n\nconst initialState = <Item_, UserArgs_, Error_>(\n generation: number,\n args: UserArgs_,\n options: Options,\n): Active<Item_, UserArgs_, Error_> =>\n State.Active<Item_, UserArgs_, Error_>({\n generation,\n args,\n options: decodeOptions(options),\n paginationId: Option.none(),\n requestId: 1,\n current: firstDescriptor(),\n prevStack: [],\n phase: Phase.Loading<Item_, Error_>({ direction: \"Initial\" }),\n });\n\nconst missingPaginatedProvenanceError = (ref: Ref.AnyConfect) =>\n new globalThis.Error(\n `Paginated query ref \"${Ref.getConvexFunctionName(ref)}\" was not built ` +\n \"with `FunctionSpec.publicPaginatedQuery`. `PaginatedQuery.make` \" +\n \"requires the user-args and item schemas that constructor stores.\",\n );\n\nconst paginatedKindOrThrow = (ref: Ref.AnyConfectPublicPaginatedQuery) =>\n Match.value(ref.kind).pipe(\n Match.tag(\"Paginated\", (kind) => kind),\n Match.tag(\"Standard\", () => {\n throw missingPaginatedProvenanceError(ref);\n }),\n Match.exhaustive,\n );\n\nconst SchemaErrorJson = Schema.TaggedStruct(\"SchemaError\", {\n message: Schema.String,\n});\n\nconst SerializableSchemaError = Schema.instanceOf(Schema.SchemaError, {\n toCodecJson: () =>\n Schema.link<Schema.SchemaError>()(SchemaErrorJson, {\n decode: SchemaGetter.transform(\n ({ message }) =>\n new Schema.SchemaError(new SchemaIssue.InvalidValue({ message })),\n ),\n encode: SchemaGetter.transform((error) =>\n SchemaErrorJson.make({ message: error.message }),\n ),\n }),\n});\n\n/** Builds a page machine from a paginated ref. */\nexport const make = <Query extends Ref.AnyConfectPublicPaginatedQuery>(\n ref: Query,\n): PaginatedQuery<Query> => {\n const kind = paginatedKindOrThrow(ref);\n const hasUserArgs = globalThis.Object.keys(kind.userArgs.fields).length > 0;\n const functionErrorSchemas = [\n ...(\"error\" in ref && ref.error !== undefined ? [ref.error] : []),\n ...MiddlewareSpec.errorSchemas(ref.middlewareSpecs),\n ];\n const errorSchema = Schema.Union([\n PaginationError.InvalidCursor,\n Client.WebSocketClientError,\n SerializableSchemaError,\n ...(functionErrorSchemas.length === 0\n ? []\n : [\n Schema.TaggedStruct(\"FunctionError\", {\n error:\n functionErrorSchemas.length === 1\n ? functionErrorSchemas[0]!\n : Schema.Union(functionErrorSchemas),\n }),\n ]),\n ]) as Schema.Codec<Error<Query>, unknown>;\n const directions = Schema.Literals([\n \"Initial\",\n \"Next\",\n \"Previous\",\n \"First\",\n \"Split\",\n \"Reset\",\n ]);\n const page = Schema.Struct({\n descriptor: PageDescriptor,\n number: PositiveInt,\n items: kind.page,\n continueCursor: Schema.String,\n isDone: Schema.Boolean,\n });\n const phase = Schema.TaggedUnion({\n Loading: { direction: directions },\n Refreshing: { data: page, direction: directions },\n Success: { data: page },\n Failure: { error: errorSchema },\n Stale: { data: page, error: errorSchema },\n });\n const subscriptionRequestSchema: PaginatedQuery<Query>[\"subscriptionRequestSchema\"] =\n Schema.Struct({\n generation: PositiveInt,\n args: kind.userArgs,\n options: Options,\n paginationId: Schema.Option(PositiveInt),\n requestId: PositiveInt,\n descriptor: PageDescriptor,\n });\n const requestSchema: PaginatedQuery<Query>[\"requestSchema\"] = Schema.Struct({\n generation: PositiveInt,\n args: kind.userArgs,\n options: Options,\n paginationId: PositiveInt,\n requestId: PositiveInt,\n descriptor: PageDescriptor,\n });\n const pageResult = Schema.Struct({\n page: kind.page,\n isDone: Schema.Boolean,\n continueCursor: Schema.String,\n splitCursor: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),\n pageStatus: Schema.optionalKey(\n Schema.Union([\n Schema.Literal(\"SplitRecommended\"),\n Schema.Literal(\"SplitRequired\"),\n Schema.Null,\n ]),\n ),\n });\n const schema: PaginatedQuery<Query>[\"schema\"] = Schema.TaggedUnion({\n Idle: { generation: NonNegativeInt },\n Active: {\n generation: PositiveInt,\n args: kind.userArgs,\n options: Options,\n paginationId: Schema.Option(PositiveInt),\n requestId: PositiveInt,\n current: PageDescriptor,\n prevStack: Schema.Array(PageDescriptor),\n phase,\n },\n });\n const settlement: PaginatedQuery<Query>[\"settlement\"] = Schema.Struct({\n request: requestSchema,\n result: Schema.Result(pageResult, errorSchema),\n });\n\n const init: PaginatedQuery<Query>[\"init\"] = (\n state: Idle,\n argsOrOptions: UserArgs<Query> | Options,\n options?: Options,\n ): MachineActive<Query> =>\n Match.value(options).pipe(\n Match.withReturnType<MachineActive<Query>>(),\n Match.when(undefined, () =>\n initialState(\n state.generation + 1,\n {} as UserArgs<Query>,\n argsOrOptions as Options,\n ),\n ),\n Match.when(Match.defined, (definedOptions) =>\n initialState(\n state.generation + 1,\n argsOrOptions as UserArgs<Query>,\n definedOptions,\n ),\n ),\n Match.exhaustive,\n );\n\n const reinitialize: PaginatedQuery<Query>[\"reinitialize\"] = (\n state: MachineActive<Query>,\n argsOrOptions?: UserArgs<Query> | Options,\n options?: Options,\n ): MachineActive<Query> =>\n Match.value(options).pipe(\n Match.withReturnType<MachineActive<Query>>(),\n Match.when(Match.defined, (definedOptions) =>\n initialState(\n state.generation + 1,\n argsOrOptions as UserArgs<Query>,\n definedOptions,\n ),\n ),\n Match.when(undefined, () =>\n Match.value(argsOrOptions).pipe(\n Match.withReturnType<MachineActive<Query>>(),\n Match.when(undefined, () =>\n initialState(state.generation + 1, state.args, state.options),\n ),\n Match.when(Match.defined, (definedArgsOrOptions) =>\n Match.value(hasUserArgs).pipe(\n Match.withReturnType<MachineActive<Query>>(),\n Match.when(true, () =>\n initialState(\n state.generation + 1,\n definedArgsOrOptions as UserArgs<Query>,\n state.options,\n ),\n ),\n Match.when(false, () =>\n initialState(\n state.generation + 1,\n state.args,\n definedArgsOrOptions as Options,\n ),\n ),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\n return {\n ref,\n schema,\n idle: State.Idle({ generation: 0 }),\n subscriptionRequestSchema,\n requestSchema,\n settlement,\n init,\n reinitialize,\n };\n};\n\nconst descriptorEquals = (a: PageDescriptor, b: PageDescriptor): boolean =>\n a.cursor === b.cursor &&\n Option.match(a.endCursor, {\n onNone: () => Option.isNone(b.endCursor),\n onSome: (aEnd) =>\n Option.match(b.endCursor, {\n onNone: () => false,\n onSome: (bEnd) => aEnd === bEnd,\n }),\n });\n\n/** Returns the logical request currently driving the subscription. */\nexport const getSubscriptionRequest = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): SubscriptionRequest<UserArgs_> => ({\n generation: state.generation,\n args: state.args,\n options: state.options,\n paginationId: state.paginationId,\n requestId: state.requestId,\n descriptor: state.current,\n});\n\n/** Attaches the client-allocated pagination id to a logical request. */\nexport const allocateRequest = <UserArgs_>(\n request: SubscriptionRequest<UserArgs_>,\n paginationId: number,\n): Request<UserArgs_> => ({\n ...request,\n paginationId,\n});\n\nconst phaseData = <Item_, Error_>(\n phase: Phase<Item_, Error_>,\n): Option.Option<Page<Item_>> =>\n Match.value(phase).pipe(\n Match.withReturnType<Option.Option<Page<Item_>>>(),\n Match.tag(\"Refreshing\", \"Success\", \"Stale\", (dataPhase) =>\n Option.some(dataPhase.data),\n ),\n Match.tag(\"Loading\", \"Failure\", () => Option.none()),\n Match.exhaustive,\n );\n\nconst pendingPhase = <Item_>(\n data: Option.Option<Page<Item_>>,\n direction: Direction,\n): Loading | Refreshing<Item_> =>\n Option.match(data, {\n onNone: () => Phase.Loading<Item_, never>({ direction }),\n onSome: (page) => Phase.Refreshing<Item_, never>({ data: page, direction }),\n });\n\n/** Close the subscription while retaining its generation tombstone. */\nexport const close = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Idle => State.Idle({ generation: state.generation });\n\n/** Start a fresh pagination session at page one while retaining visible data. */\nexport const reset = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Active<Item_, UserArgs_, Error_> => ({\n ...state,\n generation: state.generation + 1,\n paginationId: Option.none(),\n requestId: 1,\n current: firstDescriptor(),\n prevStack: [],\n phase: pendingPhase(phaseData(state.phase), \"Reset\"),\n});\n\n/** Navigate to the next page, retaining the current page while it loads. */\nexport const next = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Option.Option<Active<Item_, UserArgs_, Error_>> =>\n Match.value(state.phase).pipe(\n Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),\n Match.tag(\"Success\", ({ data }) =>\n Match.value(data.isDone).pipe(\n Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),\n Match.when(true, () => Option.none()),\n Match.when(false, () =>\n Option.some({\n ...state,\n requestId: state.requestId + 1,\n current: {\n cursor: Option.getOrElse(\n data.descriptor.endCursor,\n () => data.continueCursor,\n ),\n endCursor: Option.none(),\n },\n prevStack: [...state.prevStack, data.descriptor],\n phase: Phase.Refreshing<Item_, Error_>({\n data,\n direction: \"Next\",\n }),\n }),\n ),\n Match.exhaustive,\n ),\n ),\n Match.tag(\"Loading\", \"Refreshing\", \"Failure\", \"Stale\", () => Option.none()),\n Match.exhaustive,\n );\n\n/** Navigate to the previous page, retaining the current page while it loads. */\nexport const prev = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Option.Option<Active<Item_, UserArgs_, Error_>> =>\n Match.value(state.phase).pipe(\n Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),\n Match.tag(\"Success\", ({ data }) => {\n const current = state.prevStack.at(-1);\n return Match.value(current).pipe(\n Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),\n Match.when(undefined, () => Option.none()),\n Match.when(Match.defined, (previous) =>\n Option.some({\n ...state,\n requestId: state.requestId + 1,\n current: previous,\n prevStack: state.prevStack.slice(0, -1),\n phase: Phase.Refreshing<Item_, Error_>({\n data,\n direction: \"Previous\",\n }),\n }),\n ),\n Match.exhaustive,\n );\n }),\n Match.tag(\"Loading\", \"Refreshing\", \"Failure\", \"Stale\", () => Option.none()),\n Match.exhaustive,\n );\n\n/** Navigate to page one without invalidating the current pagination session. */\nexport const first = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Option.Option<Active<Item_, UserArgs_, Error_>> =>\n Match.value(\n state.prevStack.length === 0 &&\n descriptorEquals(state.current, firstDescriptor()),\n ).pipe(\n Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),\n Match.when(true, () => Option.none()),\n Match.when(false, () =>\n Option.some({\n ...state,\n requestId: state.requestId + 1,\n current: firstDescriptor(),\n prevStack: [],\n phase: pendingPhase(phaseData(state.phase), \"First\"),\n }),\n ),\n Match.exhaustive,\n );\n\n/** Whether a request still names the machine's live pagination session/page. */\nexport const isCurrentRequest = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n candidate: Request<UserArgs_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", (active) =>\n Match.value(active.paginationId).pipe(\n Match.tag(\"None\", () =>\n Match.value(\n active.generation === candidate.generation &&\n active.requestId === candidate.requestId &&\n descriptorEquals(active.current, candidate.descriptor),\n ).pipe(\n Match.when(true, () => true),\n Match.when(false, () => false),\n Match.exhaustive,\n ),\n ),\n Match.tag(\n \"Some\",\n ({ value }) =>\n active.generation === candidate.generation &&\n value === candidate.paginationId &&\n active.requestId === candidate.requestId &&\n descriptorEquals(active.current, candidate.descriptor),\n ),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\nconst pageFromResult = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n result: PageResult<Item_>,\n): Page<Item_> => ({\n descriptor: state.current,\n number: state.prevStack.length + 1,\n items: result.page,\n continueCursor: result.continueCursor,\n isDone: result.isDone,\n});\n\nconst settleSuccess = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n result: PageResult<Item_>,\n): Active<Item_, UserArgs_, Error_> => {\n const splitCursor = result.splitCursor;\n const splitSignaled = Match.value(result.pageStatus).pipe(\n Match.whenOr(\"SplitRecommended\", \"SplitRequired\", () => true),\n Match.whenOr(null, undefined, () => false),\n Match.exhaustive,\n );\n const shouldSplit =\n typeof splitCursor === \"string\" &&\n (splitSignaled || result.page.length > 2 * state.options.initialNumItems);\n const shouldRetreat =\n result.page.length === 0 && result.isDone && state.prevStack.length > 0;\n\n return Match.value(shouldSplit).pipe(\n Match.withReturnType<Active<Item_, UserArgs_, Error_>>(),\n Match.when(true, () => {\n const deliveredPage = pageFromResult(state, result);\n const previous = Match.value(result.pageStatus).pipe(\n Match.withReturnType<Option.Option<Page<Item_>>>(),\n Match.when(\"SplitRequired\", () => phaseData(state.phase)),\n Match.whenOr(\"SplitRecommended\", null, undefined, () =>\n Option.some(deliveredPage),\n ),\n Match.exhaustive,\n );\n return {\n ...state,\n requestId: state.requestId + 1,\n current: {\n cursor: state.current.cursor,\n endCursor: Option.fromNullishOr(splitCursor),\n },\n phase: pendingPhase(previous, \"Split\"),\n };\n }),\n Match.when(false, () =>\n Match.value(shouldRetreat).pipe(\n Match.withReturnType<Active<Item_, UserArgs_, Error_>>(),\n Match.when(true, () => ({\n ...state,\n requestId: state.requestId + 1,\n current: state.prevStack[state.prevStack.length - 1],\n prevStack: state.prevStack.slice(0, -1),\n phase: pendingPhase(phaseData(state.phase), \"Previous\"),\n })),\n Match.when(false, () => ({\n ...state,\n phase: Phase.Success<Item_, Error_>({\n data: pageFromResult(state, result),\n }),\n })),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n};\n\nconst settleFailure = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n error: Error_,\n): Active<Item_, UserArgs_, Error_> => ({\n ...state,\n phase: Option.match(phaseData(state.phase), {\n onNone: () => Phase.Failure<Item_, Error_>({ error }),\n onSome: (data) => Phase.Stale<Item_, Error_>({ error, data }),\n }),\n});\n\n/**\n * Fold a correlated `Result` into the machine. Like `AsyncData.settle`, a\n * success becomes `Success`; a failure becomes `Stale` when a page is held,\n * otherwise `Failure`. Outcomes from superseded requests and outcomes that\n * arrive after the subscription closed are ignored.\n */\nexport const settle: {\n <Item_, UserArgs_, Error_>(\n settlement: Settlement<Item_, UserArgs_, Error_>,\n ): (\n state: State<Item_, UserArgs_, Error_>,\n ) => State<Item_, UserArgs_, Error_>;\n <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n settlement: Settlement<Item_, UserArgs_, Error_>,\n ): State<Item_, UserArgs_, Error_>;\n} = Function.dual(\n 2,\n <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n settlement: Settlement<Item_, UserArgs_, Error_>,\n ): State<Item_, UserArgs_, Error_> =>\n Match.value(state).pipe(\n Match.withReturnType<State<Item_, UserArgs_, Error_>>(),\n Match.tag(\"Idle\", () => state),\n Match.tag(\"Active\", (active) =>\n Match.value(isCurrentRequest(active, settlement.request)).pipe(\n Match.when(false, () => active),\n Match.when(true, () => {\n const allocated = {\n ...active,\n paginationId: Option.some(settlement.request.paginationId),\n };\n return Result.match(settlement.result, {\n onSuccess: (result) => settleSuccess(allocated, result),\n onFailure: (error) =>\n Match.value(error).pipe(\n Match.when(\n Match.instanceOf(PaginationError.InvalidCursor),\n () => reset(allocated),\n ),\n Match.orElse((other) => settleFailure(allocated, other)),\n ),\n });\n }),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n ),\n);\n\n/** The complete page currently available to render. */\nexport const getPage = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): Option.Option<Page<Item_>> =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => Option.none()),\n Match.tag(\"Active\", ({ phase }) => phaseData(phase)),\n Match.exhaustive,\n );\n\n/** The items currently available to render. */\nexport const getItems = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): Option.Option<ReadonlyArray<Item_>> =>\n Option.map(getPage(state), (page) => page.items);\n\n/** The error from the most recent failed request, if any. */\nexport const getError = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): Option.Option<Error_> =>\n Match.value(state).pipe(\n Match.withReturnType<Option.Option<Error_>>(),\n Match.tag(\"Idle\", () => Option.none()),\n Match.tag(\"Active\", ({ phase }) =>\n Match.value(phase).pipe(\n Match.withReturnType<Option.Option<Error_>>(),\n Match.tag(\"Failure\", \"Stale\", ({ error }) => Option.some(error)),\n Match.tag(\"Loading\", \"Refreshing\", \"Success\", () => Option.none()),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\n/** The 1-indexed page number currently targeted by the subscription. */\nexport const targetPageNumber = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): number => state.prevStack.length + 1;\n\nexport const hasPage = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean => Option.isSome(getPage(state));\n\nexport const hasError = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean => Option.isSome(getError(state));\n\nexport const isFirst = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", ({ prevStack }) => prevStack.length === 0),\n Match.exhaustive,\n );\n\nexport const isLast = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", ({ phase }) =>\n Match.value(phase).pipe(\n Match.tag(\"Success\", ({ data }) => data.isDone),\n Match.tag(\"Loading\", \"Refreshing\", \"Failure\", \"Stale\", () => false),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\ntype WithPhase<State_, Phase_> = Omit<State_, \"phase\"> & {\n readonly phase: Phase_;\n};\n\nexport const isIdle = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is Idle => state._tag === \"Idle\";\n\nexport const isLoading = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is WithPhase<Active<Item_, UserArgs_, Error_>, Loading> =>\n state._tag === \"Active\" && state.phase._tag === \"Loading\";\n\nexport const isRefreshing = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is WithPhase<Active<Item_, UserArgs_, Error_>, Refreshing<Item_>> =>\n state._tag === \"Active\" && state.phase._tag === \"Refreshing\";\n\nexport const isSuccess = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is WithPhase<Active<Item_, UserArgs_, Error_>, Success<Item_>> =>\n state._tag === \"Active\" && state.phase._tag === \"Success\";\n\nexport const isFailure = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is WithPhase<Active<Item_, UserArgs_, Error_>, Failure<Error_>> =>\n state._tag === \"Active\" && state.phase._tag === \"Failure\";\n\nexport const isStale = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is WithPhase<Active<Item_, UserArgs_, Error_>, Stale<Item_, Error_>> =>\n state._tag === \"Active\" && state.phase._tag === \"Stale\";\n\nexport const isPending = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", ({ phase }) =>\n Match.value(phase).pipe(\n Match.tag(\"Loading\", \"Refreshing\", () => true),\n Match.tag(\"Success\", \"Failure\", \"Stale\", () => false),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\nexport const canNext = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", ({ phase }) =>\n Match.value(phase).pipe(\n Match.tag(\"Success\", ({ data }) => !data.isDone),\n Match.tag(\"Loading\", \"Refreshing\", \"Failure\", \"Stale\", () => false),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\nexport const canPrev = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", ({ phase, prevStack }) =>\n Match.value(phase).pipe(\n Match.tag(\"Success\", () => prevStack.length > 0),\n Match.tag(\"Loading\", \"Refreshing\", \"Failure\", \"Stale\", () => false),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\n/** Pattern-match exhaustively on the machine's AsyncData-style state. */\nexport const match: {\n <Item_, Error_, A, B, C, D, E, F>(handlers: {\n readonly onIdle: (idle: Idle) => A;\n readonly onLoading: (loading: Loading) => B;\n readonly onRefreshing: (refreshing: Refreshing<Item_>) => C;\n readonly onFailure: (failure: Failure<Error_>) => D;\n readonly onStale: (stale: Stale<Item_, Error_>) => E;\n readonly onSuccess: (success: Success<Item_>) => F;\n }): <UserArgs_>(\n state: State<Item_, UserArgs_, Error_>,\n ) => A | B | C | D | E | F;\n <Item_, UserArgs_, Error_, A, B, C, D, E, F>(\n state: State<Item_, UserArgs_, Error_>,\n handlers: {\n readonly onIdle: (idle: Idle) => A;\n readonly onLoading: (loading: Loading) => B;\n readonly onRefreshing: (refreshing: Refreshing<Item_>) => C;\n readonly onFailure: (failure: Failure<Error_>) => D;\n readonly onStale: (stale: Stale<Item_, Error_>) => E;\n readonly onSuccess: (success: Success<Item_>) => F;\n },\n ): A | B | C | D | E | F;\n} = Function.dual(\n 2,\n <Item_, UserArgs_, Error_, A, B, C, D, E, F>(\n state: State<Item_, UserArgs_, Error_>,\n handlers: {\n readonly onIdle: (idle: Idle) => A;\n readonly onLoading: (loading: Loading) => B;\n readonly onRefreshing: (refreshing: Refreshing<Item_>) => C;\n readonly onFailure: (failure: Failure<Error_>) => D;\n readonly onStale: (stale: Stale<Item_, Error_>) => E;\n readonly onSuccess: (success: Success<Item_>) => F;\n },\n ): A | B | C | D | E | F =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", handlers.onIdle),\n Match.tag(\"Active\", ({ phase }) =>\n Match.value(phase).pipe(\n Match.tag(\"Loading\", handlers.onLoading),\n Match.tag(\"Refreshing\", handlers.onRefreshing),\n Match.tag(\"Failure\", handlers.onFailure),\n Match.tag(\"Stale\", handlers.onStale),\n Match.tag(\"Success\", handlers.onSuccess),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n ) as A | B | C | D | E | F,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAa,iBAAiB,OAAO,OAAO;CAC1C,QAAQ,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,IAAI,CAAC;CACjD,WAAW,OAAO,OAAO,OAAO,MAAM;AACxC,CAAC;AASD,MAAM,cAAc,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AAC5D,MAAM,iBAAiB,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAExE,MAAa,UAAU,OAAO,OAAO;CACnC,iBAAiB;CACjB,iBAAiB,OAAO,YAAY,WAAW;CAC/C,kBAAkB,OAAO,YAAY,W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C,CAAC,KACjB,MAAM,IAAI,cAAc,KAAK,GAC7B,MAAM,IAAI,WAAW,EAAE,YACrB,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,IAAI,YAAY,EAAE,WAAW,CAAC,KAAK,MAAM,GAC/C,MAAM,IAAI,WAAW,cAAc,WAAW,eAAe,KAAK,GAClE,MAAM,UACR,CACF,GACA,MAAM,UACR;AAEF,MAAa,WACX,UAEA,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,IAAI,cAAc,KAAK,GAC7B,MAAM,IAAI,WAAW,EAAE,OAAO,gBAC5B,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,IAAI,iBAAiB,UAAU,SAAS,CAAC,GAC/C,MAAM,IAAI,WAAW,cAAc,WAAW,eAAe,KAAK,GAClE,MAAM,UACR,CACF,GACA,MAAM,UACR;;AAGF,MAAa,QAsBT,SAAS,KACX,IAEE,OACA,aASA,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,IAAI,QAAQ,SAAS,MAAM,GACjC,MAAM,IAAI,WAAW,EAAE,YACrB,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,IAAI,WAAW,SAAS,SAAS,GACvC,MAAM,IAAI,cAAc,SAAS,YAAY,GAC7C,MAAM,IAAI,WAAW,SAAS,SAAS,GACvC,MAAM,IAAI,SAAS,SAAS,OAAO,GACnC,MAAM,IAAI,WAAW,SAAS,SAAS,GACvC,MAAM,UACR,CACF,GACA,MAAM,UACR,CACJ"}
|
|
1
|
+
{"version":3,"file":"PaginatedQuery.js","names":["Client.WebSocketClientError"],"sources":["../src/PaginatedQuery.ts"],"sourcesContent":["import * as MiddlewareSpec from \"@confect/core/MiddlewareSpec\";\nimport * as PaginationError from \"@confect/core/PaginationError\";\nimport * as Ref from \"@confect/core/Ref\";\nimport * as Data from \"effect/Data\";\nimport * as Function from \"effect/Function\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaGetter from \"effect/SchemaGetter\";\nimport * as SchemaIssue from \"effect/SchemaIssue\";\nimport * as Client from \"./Client\";\n\n/** Identifies the cursor range fetched for one page. */\nexport interface PageDescriptor {\n readonly cursor: string | null;\n readonly endCursor: Option.Option<string>;\n}\n\nexport const PageDescriptor = Schema.Struct({\n cursor: Schema.Union([Schema.String, Schema.Null]),\n endCursor: Schema.Option(Schema.String),\n});\n\n/** Options that remain fixed for one pagination session. */\nexport interface Options {\n readonly initialNumItems: number;\n readonly maximumRowsRead?: number;\n readonly maximumBytesRead?: number;\n}\n\nconst PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));\nconst NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\n\nexport const Options = Schema.Struct({\n initialNumItems: PositiveInt,\n maximumRowsRead: Schema.optionalKey(PositiveInt),\n maximumBytesRead: Schema.optionalKey(PositiveInt),\n});\n\n/** Why the machine is fetching its current target. */\nexport type Direction =\n | \"Initial\"\n | \"Next\"\n | \"Previous\"\n | \"First\"\n | \"Split\"\n | \"Reset\";\n\n/** A complete page that can remain on screen while another page is fetched. */\nexport interface Page<Item_> {\n readonly descriptor: PageDescriptor;\n readonly number: number;\n readonly items: ReadonlyArray<Item_>;\n readonly continueCursor: string;\n readonly isDone: boolean;\n}\n\nexport type Loading = Data.TaggedEnum<{\n Loading: { readonly direction: Direction };\n}>;\n\nexport type Refreshing<Item_> = Data.TaggedEnum<{\n Refreshing: { readonly data: Page<Item_>; readonly direction: Direction };\n}>;\n\nexport type Success<Item_> = Data.TaggedEnum<{\n Success: { readonly data: Page<Item_> };\n}>;\n\nexport type Failure<Error_> = Data.TaggedEnum<{\n Failure: { readonly error: Error_ };\n}>;\n\nexport type Stale<Item_, Error_> = Data.TaggedEnum<{\n Stale: { readonly data: Page<Item_>; readonly error: Error_ };\n}>;\n\nexport type Phase<Item_, Error_> =\n | Loading\n | Refreshing<Item_>\n | Success<Item_>\n | Failure<Error_>\n | Stale<Item_, Error_>;\n\ninterface PhaseDefinition extends Data.TaggedEnum.WithGenerics<2> {\n readonly taggedEnum: Phase<this[\"A\"], this[\"B\"]>;\n}\n\nconst Phase = Data.taggedEnum<PhaseDefinition>();\n\n/** A closed machine that retains its generation for stale-result rejection. */\nexport type Idle = Data.TaggedEnum<{\n Idle: { readonly generation: number };\n}>;\n\n/** A live cursor-pagination session. */\nexport type Active<Item_, UserArgs_, Error_> = Data.TaggedEnum<{\n Active: {\n readonly generation: number;\n readonly args: UserArgs_;\n readonly options: Options;\n readonly paginationId: Option.Option<number>;\n readonly requestId: number;\n readonly current: PageDescriptor;\n readonly prevStack: ReadonlyArray<PageDescriptor>;\n readonly phase: Phase<Item_, Error_>;\n };\n}>;\n\n/** A schema-backed cursor-pagination machine. */\nexport type State<Item_, UserArgs_, Error_> =\n | Idle\n | Active<Item_, UserArgs_, Error_>;\n\ninterface StateDefinition extends Data.TaggedEnum.WithGenerics<3> {\n readonly taggedEnum: State<this[\"A\"], this[\"B\"], this[\"C\"]>;\n}\n\nconst State = Data.taggedEnum<StateDefinition>();\n\n/** The logical request from which a subscription allocates a session id. */\nexport interface SubscriptionRequest<UserArgs_> {\n readonly generation: number;\n readonly args: UserArgs_;\n readonly options: Options;\n readonly paginationId: Option.Option<number>;\n readonly requestId: number;\n readonly descriptor: PageDescriptor;\n}\n\n/** The complete identity and arguments of a subscribed page request. */\nexport interface Request<UserArgs_> {\n readonly generation: number;\n readonly args: UserArgs_;\n readonly options: Options;\n readonly paginationId: number;\n readonly requestId: number;\n readonly descriptor: PageDescriptor;\n}\n\n/** The successful payload returned by a Convex paginated query. */\nexport interface PageResult<Item_> {\n readonly page: ReadonlyArray<Item_>;\n readonly isDone: boolean;\n readonly continueCursor: string;\n readonly splitCursor?: string | null;\n readonly pageStatus?: \"SplitRecommended\" | \"SplitRequired\" | null;\n}\n\n/**\n * One correlated subscription outcome. Both success and failure travel\n * through this value so `settle` can mirror `AsyncData.settle`.\n */\nexport interface Settlement<Item_, UserArgs_, Error_> {\n readonly request: Request<UserArgs_>;\n readonly result: Result.Result<PageResult<Item_>, Error_>;\n}\n\nexport type Item<Query extends Ref.AnyConfectPublicPaginatedQuery> =\n Ref.Returns<Query>[\"page\"][number];\n\nexport type UserArgs<Query extends Ref.AnyConfectPublicPaginatedQuery> = Omit<\n Ref.Args<Query>,\n \"paginationOpts\"\n>;\n\ntype TaggedFunctionError<Error_> = Data.TaggedEnum<{\n FunctionError: { readonly error: Error_ };\n}>;\n\ninterface FunctionErrorDefinition extends Data.TaggedEnum.WithGenerics<1> {\n readonly taggedEnum: TaggedFunctionError<this[\"A\"]>;\n}\n\n/** Constructs a declared function or middleware failure envelope. */\nexport const FunctionError =\n Data.taggedEnum<FunctionErrorDefinition>().FunctionError;\n\n/** A declared function or middleware failure, kept distinct from client errors. */\nexport type FunctionError<Query extends Ref.AnyConfectPublicPaginatedQuery> = [\n Ref.Error<Query>,\n] extends [never]\n ? never\n : TaggedFunctionError<Ref.Error<Query>>;\n\n/** Every failure a paginated query subscription can settle with. */\nexport type Error<Query extends Ref.AnyConfectPublicPaginatedQuery> =\n | FunctionError<Query>\n | PaginationError.InvalidCursor\n | Client.WebSocketClientError\n | Schema.SchemaError;\n\nexport { InvalidCursor } from \"@confect/core/PaginationError\";\n\ntype MachineState<Query extends Ref.AnyConfectPublicPaginatedQuery> = State<\n Item<Query>,\n UserArgs<Query>,\n Error<Query>\n>;\n\ntype MachineActive<Query extends Ref.AnyConfectPublicPaginatedQuery> = Active<\n Item<Query>,\n UserArgs<Query>,\n Error<Query>\n>;\n\n/** The schema-and-constructor bundle returned by `make`. */\nexport interface PaginatedQuery<\n Query extends Ref.AnyConfectPublicPaginatedQuery,\n> {\n readonly ref: Query;\n readonly schema: Schema.Codec<MachineState<Query>, unknown>;\n readonly idle: Idle;\n readonly subscriptionRequestSchema: Schema.Codec<\n SubscriptionRequest<UserArgs<Query>>,\n unknown\n >;\n readonly requestSchema: Schema.Codec<Request<UserArgs<Query>>, unknown>;\n readonly settlement: Schema.Codec<\n Settlement<Item<Query>, UserArgs<Query>, Error<Query>>,\n unknown\n >;\n readonly init: keyof UserArgs<Query> extends never\n ? (state: Idle, options: Options) => MachineActive<Query>\n : (\n state: Idle,\n args: UserArgs<Query>,\n options: Options,\n ) => MachineActive<Query>;\n readonly reinitialize: keyof UserArgs<Query> extends never\n ? (state: MachineActive<Query>, options?: Options) => MachineActive<Query>\n : (\n state: MachineActive<Query>,\n args: UserArgs<Query>,\n options?: Options,\n ) => MachineActive<Query>;\n}\n\nexport type Any = PaginatedQuery<Ref.AnyConfectPublicPaginatedQuery>;\n\nconst firstDescriptor = (): PageDescriptor => ({\n cursor: null,\n endCursor: Option.none(),\n});\n\nconst decodeOptions = Schema.decodeUnknownSync(Options);\n\nconst initialState = <Item_, UserArgs_, Error_>(\n generation: number,\n args: UserArgs_,\n options: Options,\n): Active<Item_, UserArgs_, Error_> =>\n State.Active<Item_, UserArgs_, Error_>({\n generation,\n args,\n options: decodeOptions(options),\n paginationId: Option.none(),\n requestId: 1,\n current: firstDescriptor(),\n prevStack: [],\n phase: Phase.Loading<Item_, Error_>({ direction: \"Initial\" }),\n });\n\nconst missingPaginatedProvenanceError = (ref: Ref.AnyConfect) =>\n new globalThis.Error(\n `Paginated query ref \"${Ref.getConvexFunctionName(ref)}\" was not built ` +\n \"with `FunctionSpec.publicPaginatedQuery`. `PaginatedQuery.make` \" +\n \"requires the user-args and item schemas that constructor stores.\",\n );\n\nconst paginatedKindOrThrow = (ref: Ref.AnyConfectPublicPaginatedQuery) =>\n Match.value(ref.kind).pipe(\n Match.tag(\"Paginated\", (kind) => kind),\n Match.tag(\"Standard\", () => {\n throw missingPaginatedProvenanceError(ref);\n }),\n Match.exhaustive,\n );\n\nconst SchemaErrorJson = Schema.TaggedStruct(\"SchemaError\", {\n message: Schema.String,\n});\n\nconst SerializableSchemaError = Schema.instanceOf(Schema.SchemaError, {\n toCodecJson: () =>\n Schema.link<Schema.SchemaError>()(SchemaErrorJson, {\n decode: SchemaGetter.transform(\n ({ message }) =>\n new Schema.SchemaError(new SchemaIssue.InvalidValue({ message })),\n ),\n encode: SchemaGetter.transform((error) =>\n SchemaErrorJson.make({ message: error.message }),\n ),\n }),\n});\n\n/** Builds a page machine from a paginated ref. */\nexport const make = <Query extends Ref.AnyConfectPublicPaginatedQuery>(\n ref: Query,\n): PaginatedQuery<Query> => {\n const kind = paginatedKindOrThrow(ref);\n const hasUserArgs = globalThis.Object.keys(kind.userArgs.fields).length > 0;\n const functionErrorSchemas = [\n ...(\"error\" in ref && ref.error !== undefined ? [ref.error] : []),\n ...MiddlewareSpec.errorSchemas(ref.middlewareSpecs),\n ];\n const errorSchema = Schema.Union([\n PaginationError.InvalidCursor,\n Client.WebSocketClientError,\n SerializableSchemaError,\n ...(functionErrorSchemas.length === 0\n ? []\n : [\n Schema.TaggedStruct(\"FunctionError\", {\n error:\n functionErrorSchemas.length === 1\n ? functionErrorSchemas[0]!\n : Schema.Union(functionErrorSchemas),\n }),\n ]),\n ]) as Schema.Codec<Error<Query>, unknown>;\n const directions = Schema.Literals([\n \"Initial\",\n \"Next\",\n \"Previous\",\n \"First\",\n \"Split\",\n \"Reset\",\n ]);\n const page = Schema.Struct({\n descriptor: PageDescriptor,\n number: PositiveInt,\n items: kind.page,\n continueCursor: Schema.String,\n isDone: Schema.Boolean,\n });\n const phase = Schema.TaggedUnion({\n Loading: { direction: directions },\n Refreshing: { data: page, direction: directions },\n Success: { data: page },\n Failure: { error: errorSchema },\n Stale: { data: page, error: errorSchema },\n });\n const subscriptionRequestSchema: PaginatedQuery<Query>[\"subscriptionRequestSchema\"] =\n Schema.Struct({\n generation: PositiveInt,\n args: kind.userArgs,\n options: Options,\n paginationId: Schema.Option(PositiveInt),\n requestId: PositiveInt,\n descriptor: PageDescriptor,\n });\n const requestSchema: PaginatedQuery<Query>[\"requestSchema\"] = Schema.Struct({\n generation: PositiveInt,\n args: kind.userArgs,\n options: Options,\n paginationId: PositiveInt,\n requestId: PositiveInt,\n descriptor: PageDescriptor,\n });\n const pageResult = Schema.Struct({\n page: kind.page,\n isDone: Schema.Boolean,\n continueCursor: Schema.String,\n splitCursor: Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),\n pageStatus: Schema.optionalKey(\n Schema.Union([\n Schema.Literal(\"SplitRecommended\"),\n Schema.Literal(\"SplitRequired\"),\n Schema.Null,\n ]),\n ),\n });\n const schema: PaginatedQuery<Query>[\"schema\"] = Schema.TaggedUnion({\n Idle: { generation: NonNegativeInt },\n Active: {\n generation: PositiveInt,\n args: kind.userArgs,\n options: Options,\n paginationId: Schema.Option(PositiveInt),\n requestId: PositiveInt,\n current: PageDescriptor,\n prevStack: Schema.Array(PageDescriptor),\n phase,\n },\n });\n const settlement: PaginatedQuery<Query>[\"settlement\"] = Schema.Struct({\n request: requestSchema,\n result: Schema.Result(pageResult, errorSchema),\n });\n\n const init: PaginatedQuery<Query>[\"init\"] = (\n state: Idle,\n argsOrOptions: UserArgs<Query> | Options,\n options?: Options,\n ): MachineActive<Query> =>\n Match.value(options).pipe(\n Match.withReturnType<MachineActive<Query>>(),\n Match.when(undefined, () =>\n initialState(\n state.generation + 1,\n {} as UserArgs<Query>,\n argsOrOptions as Options,\n ),\n ),\n Match.when(Match.defined, (definedOptions) =>\n initialState(\n state.generation + 1,\n argsOrOptions as UserArgs<Query>,\n definedOptions,\n ),\n ),\n Match.exhaustive,\n );\n\n const reinitialize: PaginatedQuery<Query>[\"reinitialize\"] = (\n state: MachineActive<Query>,\n argsOrOptions?: UserArgs<Query> | Options,\n options?: Options,\n ): MachineActive<Query> =>\n Match.value(options).pipe(\n Match.withReturnType<MachineActive<Query>>(),\n Match.when(Match.defined, (definedOptions) =>\n initialState(\n state.generation + 1,\n argsOrOptions as UserArgs<Query>,\n definedOptions,\n ),\n ),\n Match.when(undefined, () =>\n Match.value(argsOrOptions).pipe(\n Match.withReturnType<MachineActive<Query>>(),\n Match.when(undefined, () =>\n initialState(state.generation + 1, state.args, state.options),\n ),\n Match.when(Match.defined, (definedArgsOrOptions) =>\n Match.value(hasUserArgs).pipe(\n Match.withReturnType<MachineActive<Query>>(),\n Match.when(true, () =>\n initialState(\n state.generation + 1,\n definedArgsOrOptions as UserArgs<Query>,\n state.options,\n ),\n ),\n Match.when(false, () =>\n initialState(\n state.generation + 1,\n state.args,\n definedArgsOrOptions as Options,\n ),\n ),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\n return {\n ref,\n schema,\n idle: State.Idle({ generation: 0 }),\n subscriptionRequestSchema,\n requestSchema,\n settlement,\n init,\n reinitialize,\n };\n};\n\nconst descriptorEquals = (a: PageDescriptor, b: PageDescriptor): boolean =>\n a.cursor === b.cursor &&\n Option.match(a.endCursor, {\n onNone: () => Option.isNone(b.endCursor),\n onSome: (aEnd) =>\n Option.match(b.endCursor, {\n onNone: () => false,\n onSome: (bEnd) => aEnd === bEnd,\n }),\n });\n\n/** Returns the logical request currently driving the subscription. */\nexport const getSubscriptionRequest = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): SubscriptionRequest<UserArgs_> => ({\n generation: state.generation,\n args: state.args,\n options: state.options,\n paginationId: state.paginationId,\n requestId: state.requestId,\n descriptor: state.current,\n});\n\n/** Attaches the client-allocated pagination id to a logical request. */\nexport const allocateRequest = <UserArgs_>(\n request: SubscriptionRequest<UserArgs_>,\n paginationId: number,\n): Request<UserArgs_> => ({\n ...request,\n paginationId,\n});\n\nconst phaseData = <Item_, Error_>(\n phase: Phase<Item_, Error_>,\n): Option.Option<Page<Item_>> =>\n Match.value(phase).pipe(\n Match.withReturnType<Option.Option<Page<Item_>>>(),\n Match.tag(\"Refreshing\", \"Success\", \"Stale\", (dataPhase) =>\n Option.some(dataPhase.data),\n ),\n Match.tag(\"Loading\", \"Failure\", () => Option.none()),\n Match.exhaustive,\n );\n\nconst pendingPhase = <Item_>(\n data: Option.Option<Page<Item_>>,\n direction: Direction,\n): Loading | Refreshing<Item_> =>\n Option.match(data, {\n onNone: () => Phase.Loading<Item_, never>({ direction }),\n onSome: (page) => Phase.Refreshing<Item_, never>({ data: page, direction }),\n });\n\n/** Close the subscription while retaining its generation tombstone. */\nexport const close = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Idle => State.Idle({ generation: state.generation });\n\n/** Start a fresh pagination session at page one while retaining visible data. */\nexport const reset = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Active<Item_, UserArgs_, Error_> => ({\n ...state,\n generation: state.generation + 1,\n paginationId: Option.none(),\n requestId: 1,\n current: firstDescriptor(),\n prevStack: [],\n phase: pendingPhase(phaseData(state.phase), \"Reset\"),\n});\n\n/**\n * Navigate to the next page, retaining the current page while it loads.\n *\n * The page being left is pushed onto the stack *pinned* to the range it\n * displayed—its cursor to its continuation cursor—so `prev` reloads\n * exactly that range rather than the first `initialNumItems` documents\n * after its cursor, however the data has moved meanwhile. Convex's own\n * pagination keeps that range in its query journal; stream-paginated\n * queries have no journal, so the pin is what keeps consecutive pages\n * gap-free and duplicate-free for them.\n */\nexport const next = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Option.Option<Active<Item_, UserArgs_, Error_>> =>\n Match.value(state.phase).pipe(\n Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),\n Match.tag(\"Success\", ({ data }) =>\n Match.value(data.isDone).pipe(\n Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),\n Match.when(true, () => Option.none()),\n Match.when(false, () => {\n const end = Option.getOrElse(\n data.descriptor.endCursor,\n () => data.continueCursor,\n );\n return Option.some({\n ...state,\n requestId: state.requestId + 1,\n current: { cursor: end, endCursor: Option.none() },\n prevStack: [\n ...state.prevStack,\n { cursor: data.descriptor.cursor, endCursor: Option.some(end) },\n ],\n phase: Phase.Refreshing<Item_, Error_>({\n data,\n direction: \"Next\",\n }),\n });\n }),\n Match.exhaustive,\n ),\n ),\n Match.tag(\"Loading\", \"Refreshing\", \"Failure\", \"Stale\", () => Option.none()),\n Match.exhaustive,\n );\n\n/** Navigate to the previous page, retaining the current page while it loads. */\nexport const prev = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Option.Option<Active<Item_, UserArgs_, Error_>> =>\n Match.value(state.phase).pipe(\n Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),\n Match.tag(\"Success\", ({ data }) => {\n const current = state.prevStack.at(-1);\n return Match.value(current).pipe(\n Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),\n Match.when(undefined, () => Option.none()),\n Match.when(Match.defined, (previous) =>\n Option.some({\n ...state,\n requestId: state.requestId + 1,\n current: previous,\n prevStack: state.prevStack.slice(0, -1),\n phase: Phase.Refreshing<Item_, Error_>({\n data,\n direction: \"Previous\",\n }),\n }),\n ),\n Match.exhaustive,\n );\n }),\n Match.tag(\"Loading\", \"Refreshing\", \"Failure\", \"Stale\", () => Option.none()),\n Match.exhaustive,\n );\n\n/** Navigate to page one without invalidating the current pagination session. */\nexport const first = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Option.Option<Active<Item_, UserArgs_, Error_>> =>\n Match.value(\n state.prevStack.length === 0 &&\n descriptorEquals(state.current, firstDescriptor()),\n ).pipe(\n Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),\n Match.when(true, () => Option.none()),\n Match.when(false, () =>\n Option.some({\n ...state,\n requestId: state.requestId + 1,\n current: firstDescriptor(),\n prevStack: [],\n phase: pendingPhase(phaseData(state.phase), \"First\"),\n }),\n ),\n Match.exhaustive,\n );\n\n/** Whether a request still names the machine's live pagination session/page. */\nexport const isCurrentRequest = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n candidate: Request<UserArgs_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", (active) =>\n Match.value(active.paginationId).pipe(\n Match.tag(\"None\", () =>\n Match.value(\n active.generation === candidate.generation &&\n active.requestId === candidate.requestId &&\n descriptorEquals(active.current, candidate.descriptor),\n ).pipe(\n Match.when(true, () => true),\n Match.when(false, () => false),\n Match.exhaustive,\n ),\n ),\n Match.tag(\n \"Some\",\n ({ value }) =>\n active.generation === candidate.generation &&\n value === candidate.paginationId &&\n active.requestId === candidate.requestId &&\n descriptorEquals(active.current, candidate.descriptor),\n ),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\nconst pageFromResult = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n result: PageResult<Item_>,\n): Page<Item_> => ({\n descriptor: state.current,\n number: state.prevStack.length + 1,\n items: result.page,\n continueCursor: result.continueCursor,\n isDone: result.isDone,\n});\n\nconst settleSuccess = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n result: PageResult<Item_>,\n): Active<Item_, UserArgs_, Error_> => {\n const splitCursor = result.splitCursor;\n const splitSignaled = Match.value(result.pageStatus).pipe(\n Match.whenOr(\"SplitRecommended\", \"SplitRequired\", () => true),\n Match.whenOr(null, undefined, () => false),\n Match.exhaustive,\n );\n const shouldSplit =\n typeof splitCursor === \"string\" &&\n (splitSignaled || result.page.length > 2 * state.options.initialNumItems);\n const shouldRetreat =\n result.page.length === 0 && result.isDone && state.prevStack.length > 0;\n\n return Match.value(shouldSplit).pipe(\n Match.withReturnType<Active<Item_, UserArgs_, Error_>>(),\n Match.when(true, () => {\n const deliveredPage = pageFromResult(state, result);\n const previous = Match.value(result.pageStatus).pipe(\n Match.withReturnType<Option.Option<Page<Item_>>>(),\n Match.when(\"SplitRequired\", () => phaseData(state.phase)),\n Match.whenOr(\"SplitRecommended\", null, undefined, () =>\n Option.some(deliveredPage),\n ),\n Match.exhaustive,\n );\n return {\n ...state,\n requestId: state.requestId + 1,\n current: {\n cursor: state.current.cursor,\n endCursor: Option.fromNullishOr(splitCursor),\n },\n phase: pendingPhase(previous, \"Split\"),\n };\n }),\n Match.when(false, () =>\n Match.value(shouldRetreat).pipe(\n Match.withReturnType<Active<Item_, UserArgs_, Error_>>(),\n Match.when(true, () => ({\n ...state,\n requestId: state.requestId + 1,\n current: state.prevStack[state.prevStack.length - 1],\n prevStack: state.prevStack.slice(0, -1),\n phase: pendingPhase(phaseData(state.phase), \"Previous\"),\n })),\n Match.when(false, () => ({\n ...state,\n phase: Phase.Success<Item_, Error_>({\n data: pageFromResult(state, result),\n }),\n })),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n};\n\nconst settleFailure = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n error: Error_,\n): Active<Item_, UserArgs_, Error_> => ({\n ...state,\n phase: Option.match(phaseData(state.phase), {\n onNone: () => Phase.Failure<Item_, Error_>({ error }),\n onSome: (data) => Phase.Stale<Item_, Error_>({ error, data }),\n }),\n});\n\n/**\n * Fold a correlated `Result` into the machine. Like `AsyncData.settle`, a\n * success becomes `Success`; a failure becomes `Stale` when a page is held,\n * otherwise `Failure`. Outcomes from superseded requests and outcomes that\n * arrive after the subscription closed are ignored.\n */\nexport const settle: {\n <Item_, UserArgs_, Error_>(\n settlement: Settlement<Item_, UserArgs_, Error_>,\n ): (\n state: State<Item_, UserArgs_, Error_>,\n ) => State<Item_, UserArgs_, Error_>;\n <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n settlement: Settlement<Item_, UserArgs_, Error_>,\n ): State<Item_, UserArgs_, Error_>;\n} = Function.dual(\n 2,\n <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n settlement: Settlement<Item_, UserArgs_, Error_>,\n ): State<Item_, UserArgs_, Error_> =>\n Match.value(state).pipe(\n Match.withReturnType<State<Item_, UserArgs_, Error_>>(),\n Match.tag(\"Idle\", () => state),\n Match.tag(\"Active\", (active) =>\n Match.value(isCurrentRequest(active, settlement.request)).pipe(\n Match.when(false, () => active),\n Match.when(true, () => {\n const allocated = {\n ...active,\n paginationId: Option.some(settlement.request.paginationId),\n };\n return Result.match(settlement.result, {\n onSuccess: (result) => settleSuccess(allocated, result),\n onFailure: (error) =>\n Match.value(error).pipe(\n Match.when(\n Match.instanceOf(PaginationError.InvalidCursor),\n () => reset(allocated),\n ),\n Match.orElse((other) => settleFailure(allocated, other)),\n ),\n });\n }),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n ),\n);\n\n/** The complete page currently available to render. */\nexport const getPage = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): Option.Option<Page<Item_>> =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => Option.none()),\n Match.tag(\"Active\", ({ phase }) => phaseData(phase)),\n Match.exhaustive,\n );\n\n/** The items currently available to render. */\nexport const getItems = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): Option.Option<ReadonlyArray<Item_>> =>\n Option.map(getPage(state), (page) => page.items);\n\n/** The error from the most recent failed request, if any. */\nexport const getError = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): Option.Option<Error_> =>\n Match.value(state).pipe(\n Match.withReturnType<Option.Option<Error_>>(),\n Match.tag(\"Idle\", () => Option.none()),\n Match.tag(\"Active\", ({ phase }) =>\n Match.value(phase).pipe(\n Match.withReturnType<Option.Option<Error_>>(),\n Match.tag(\"Failure\", \"Stale\", ({ error }) => Option.some(error)),\n Match.tag(\"Loading\", \"Refreshing\", \"Success\", () => Option.none()),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\n/** The 1-indexed page number currently targeted by the subscription. */\nexport const targetPageNumber = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): number => state.prevStack.length + 1;\n\nexport const hasPage = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean => Option.isSome(getPage(state));\n\nexport const hasError = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean => Option.isSome(getError(state));\n\nexport const isFirst = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", ({ prevStack }) => prevStack.length === 0),\n Match.exhaustive,\n );\n\nexport const isLast = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", ({ phase }) =>\n Match.value(phase).pipe(\n Match.tag(\"Success\", ({ data }) => data.isDone),\n Match.tag(\"Loading\", \"Refreshing\", \"Failure\", \"Stale\", () => false),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\ntype WithPhase<State_, Phase_> = Omit<State_, \"phase\"> & {\n readonly phase: Phase_;\n};\n\nexport const isIdle = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is Idle => state._tag === \"Idle\";\n\nexport const isLoading = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is WithPhase<Active<Item_, UserArgs_, Error_>, Loading> =>\n state._tag === \"Active\" && state.phase._tag === \"Loading\";\n\nexport const isRefreshing = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is WithPhase<Active<Item_, UserArgs_, Error_>, Refreshing<Item_>> =>\n state._tag === \"Active\" && state.phase._tag === \"Refreshing\";\n\nexport const isSuccess = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is WithPhase<Active<Item_, UserArgs_, Error_>, Success<Item_>> =>\n state._tag === \"Active\" && state.phase._tag === \"Success\";\n\nexport const isFailure = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is WithPhase<Active<Item_, UserArgs_, Error_>, Failure<Error_>> =>\n state._tag === \"Active\" && state.phase._tag === \"Failure\";\n\nexport const isStale = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): state is WithPhase<Active<Item_, UserArgs_, Error_>, Stale<Item_, Error_>> =>\n state._tag === \"Active\" && state.phase._tag === \"Stale\";\n\nexport const isPending = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", ({ phase }) =>\n Match.value(phase).pipe(\n Match.tag(\"Loading\", \"Refreshing\", () => true),\n Match.tag(\"Success\", \"Failure\", \"Stale\", () => false),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\nexport const canNext = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", ({ phase }) =>\n Match.value(phase).pipe(\n Match.tag(\"Success\", ({ data }) => !data.isDone),\n Match.tag(\"Loading\", \"Refreshing\", \"Failure\", \"Stale\", () => false),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\nexport const canPrev = <Item_, UserArgs_, Error_>(\n state: State<Item_, UserArgs_, Error_>,\n): boolean =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", () => false),\n Match.tag(\"Active\", ({ phase, prevStack }) =>\n Match.value(phase).pipe(\n Match.tag(\"Success\", () => prevStack.length > 0),\n Match.tag(\"Loading\", \"Refreshing\", \"Failure\", \"Stale\", () => false),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n );\n\n/** Pattern-match exhaustively on the machine's AsyncData-style state. */\nexport const match: {\n <Item_, Error_, A, B, C, D, E, F>(handlers: {\n readonly onIdle: (idle: Idle) => A;\n readonly onLoading: (loading: Loading) => B;\n readonly onRefreshing: (refreshing: Refreshing<Item_>) => C;\n readonly onFailure: (failure: Failure<Error_>) => D;\n readonly onStale: (stale: Stale<Item_, Error_>) => E;\n readonly onSuccess: (success: Success<Item_>) => F;\n }): <UserArgs_>(\n state: State<Item_, UserArgs_, Error_>,\n ) => A | B | C | D | E | F;\n <Item_, UserArgs_, Error_, A, B, C, D, E, F>(\n state: State<Item_, UserArgs_, Error_>,\n handlers: {\n readonly onIdle: (idle: Idle) => A;\n readonly onLoading: (loading: Loading) => B;\n readonly onRefreshing: (refreshing: Refreshing<Item_>) => C;\n readonly onFailure: (failure: Failure<Error_>) => D;\n readonly onStale: (stale: Stale<Item_, Error_>) => E;\n readonly onSuccess: (success: Success<Item_>) => F;\n },\n ): A | B | C | D | E | F;\n} = Function.dual(\n 2,\n <Item_, UserArgs_, Error_, A, B, C, D, E, F>(\n state: State<Item_, UserArgs_, Error_>,\n handlers: {\n readonly onIdle: (idle: Idle) => A;\n readonly onLoading: (loading: Loading) => B;\n readonly onRefreshing: (refreshing: Refreshing<Item_>) => C;\n readonly onFailure: (failure: Failure<Error_>) => D;\n readonly onStale: (stale: Stale<Item_, Error_>) => E;\n readonly onSuccess: (success: Success<Item_>) => F;\n },\n ): A | B | C | D | E | F =>\n Match.value(state).pipe(\n Match.tag(\"Idle\", handlers.onIdle),\n Match.tag(\"Active\", ({ phase }) =>\n Match.value(phase).pipe(\n Match.tag(\"Loading\", handlers.onLoading),\n Match.tag(\"Refreshing\", handlers.onRefreshing),\n Match.tag(\"Failure\", handlers.onFailure),\n Match.tag(\"Stale\", handlers.onStale),\n Match.tag(\"Success\", handlers.onSuccess),\n Match.exhaustive,\n ),\n ),\n Match.exhaustive,\n ) as A | B | C | D | E | F,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAa,iBAAiB,OAAO,OAAO;CAC1C,QAAQ,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,IAAI,CAAC;CACjD,WAAW,OAAO,OAAO,OAAO,MAAM;AACxC,CAAC;AASD,MAAM,cAAc,OAAO,IAA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ACA,MAAM,UACR,CACJ"}
|
package/dist/Subscription.d.ts
CHANGED
|
@@ -22,8 +22,7 @@ export interface Dependencies<Query extends Ref.AnyConfectPublicQuery> {
|
|
|
22
22
|
readonly args: Option.Option<Ref.Args<Query>>;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Maps a reactive query's emissions into the app's Messages. Every failure —
|
|
26
|
-
* the ref's typed error, a transport error, or a codec error — arrives via
|
|
25
|
+
* Maps a reactive query's emissions into the app's Messages. Every failure—the ref's typed error, a transport error, or a codec error—arrives via
|
|
27
26
|
* `onError`, so the resulting stream's error channel is `never`, as Foldkit
|
|
28
27
|
* requires.
|
|
29
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Subscription.d.ts","sourceRoot":"","sources":["../src/Subscription.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,GAAG,MAAM,mBAAmB,CAAC;AAE9C,OAAO,KAAK,KAAK,WAAW,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,mBAAmB,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,MAAM,KAAK,CAAC,KAAK,SAAS,GAAG,CAAC,qBAAqB,IACrD,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAChB,MAAM,CAAC,oBAAoB,GAC3B,MAAM,CAAC,WAAW,CAAC;AAsBvB;;;;GAIG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK,SAAS,GAAG,CAAC,qBAAqB;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,K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C7B,cAAc,CAAC,mBAAmB,CAChC,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAC3C,CACF,CAAC;CACH,EACD,MAAM,CAAC,MAAM,CAwFd,CAAC"}
|
package/dist/Subscription.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Subscription.js","names":["Client.WebSocketClientError","PaginatedQuery.FunctionError","PaginatedQuery.getSubscriptionRequest","Client.Client","PaginatedQuery.allocateRequest"],"sources":["../src/Subscription.ts"],"sourcesContent":["import * as PaginationError from \"@confect/core/PaginationError\";\nimport type * as Ref from \"@confect/core/Ref\";\nimport * as Effect from \"effect/Effect\";\nimport type * as Equivalence from \"effect/Equivalence\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\nimport type * as FoldkitSubscription from \"foldkit/subscription\";\nimport * as PaginatedQuery from \"./PaginatedQuery\";\nimport * as Client from \"./Client\";\n\n/**\n * Everything a reactive query subscription against `Query` can fail with: the\n * ref's typed error (if it declares an `error` schema), a transport-level\n * `WebSocketClientError`, or a `SchemaError` from encoding args or decoding\n * returns.\n */\nexport type Error<Query extends Ref.AnyConfectPublicQuery> =\n | Ref.Error<Query>\n | Client.WebSocketClientError\n | Schema.SchemaError;\n\nconst paginatedError = <Query extends Ref.AnyConfectPublicPaginatedQuery>(\n error: Error<Query>,\n): PaginatedQuery.Error<Query> =>\n Match.value(error).pipe(\n Match.when(Schema.isSchemaError, (schemaError) => schemaError),\n Match.when(Match.instanceOf(Client.WebSocketClientError), (clientError) =>\n PaginationError.fromConvexQueryError(clientError.cause).pipe(\n Option.getOrElse(() => clientError),\n ),\n ),\n Match.when(Match.any, (functionError) =>\n PaginationError.fromConvexErrorData(functionError).pipe(\n Option.getOrElse(() =>\n PaginatedQuery.FunctionError({ error: functionError }),\n ),\n ),\n ),\n Match.exhaustive,\n ) as PaginatedQuery.Error<Query>;\n\n/**\n * The dependency record of a `reactiveQuery` entry. `None` means the\n * subscription is closed; a change from one `Some` to another tears the\n * server subscription down and reopens it with the new args.\n */\nexport interface Dependencies<Query extends Ref.AnyConfectPublicQuery> {\n readonly args: Option.Option<Ref.Args<Query>>;\n}\n\n/**\n * Maps a reactive query's emissions into the app's Messages. Every failure —\n * the ref's typed error, a transport error, or a codec error — arrives via\n * `onError`, so the resulting stream's error channel is `never`, as Foldkit\n * requires.\n */\nexport interface Handlers<\n Query extends Ref.AnyConfectPublicQuery,\n SuccessMessage,\n ErrorMessage,\n> {\n readonly onSuccess: (returns: Ref.Returns<Query>) => SuccessMessage;\n readonly onError: (error: Error<Query>) => ErrorMessage;\n}\n\n/**\n * The `args` extractor is required whenever the query declares args; queries\n * without args may omit it, in which case the subscription is always open.\n */\ntype ArgsConfig<Query extends Ref.AnyConfectPublicQuery, Model> = {\n readonly args?: (model: Model) => Option.Option<Ref.Args<Query>>;\n} & (keyof Ref.Args<Query> extends never\n ? unknown\n : {\n readonly args: (model: Model) => Option.Option<Ref.Args<Query>>;\n });\n\n/**\n * A `dependenciesToStream` body for a hand-written subscription entry: runs\n * the ref as a reactive query against the `Client` resource and maps\n * every emission and every failure into a Message. Query failures are values,\n * so the subscription remains live and can later emit a successful result.\n *\n * Prefer `reactiveQuery`, which builds the whole entry; reach for this when\n * you need control over the entry's dependencies (custom gating, extra\n * dependencies).\n */\nexport const reactiveQueryStream =\n <Query extends Ref.AnyConfectPublicQuery, SuccessMessage, ErrorMessage>(\n ref: Query,\n handlers: Handlers<Query, SuccessMessage, ErrorMessage>,\n ) =>\n (\n ...args: Ref.OptionalArgs<Query>\n ): Stream.Stream<SuccessMessage | ErrorMessage, never, Client.Client> =>\n Client.Client.pipe(\n Effect.map((client) => client.reactiveQueryResult(ref, ...args)),\n Stream.unwrap,\n Stream.map(\n Result.match({\n onSuccess: handlers.onSuccess,\n onFailure: handlers.onError,\n }),\n ),\n );\n\n/**\n * A complete Foldkit subscription entry for a Confect reactive query. The\n * leading thunk fixes the `Model` type (TypeScript cannot partially infer\n * type arguments), so the `args` extractor's parameter is already typed.\n * Pass the result as an entry value to `Subscription.make`:\n *\n * ```ts\n * import * as Confect from \"@confect/foldkit\"\n * import * as Subscription from \"foldkit/subscription\"\n *\n * const subscriptions = Subscription.make<\n * Model,\n * Message,\n * Confect.Client.Client\n * >()(() => ({\n * note: Confect.Subscription.reactiveQuery<Model>()(refs.public.notes.get, {\n * args: (model) => Option.map(model.noteId, (noteId) => ({ noteId })),\n * onSuccess: (note) => SucceededGetNote({ note }),\n * onError: (error) => FailedGetNote({ message: String(error) }),\n * }),\n * }))\n * ```\n *\n * The entry's dependencies are the query args wrapped in `Option`: `None`\n * closes the subscription, a change from one `Some` to another unsubscribes\n * and resubscribes with the new args, and structurally equal args leave the\n * subscription running (equivalence is derived from the ref's args schema).\n * Queries without args may omit `args`, leaving the subscription always open.\n */\nexport const reactiveQuery =\n <Model>() =>\n <Query extends Ref.AnyConfectPublicQuery, SuccessMessage, ErrorMessage>(\n ref: Query,\n config: Handlers<Query, SuccessMessage, ErrorMessage> &\n ArgsConfig<Query, Model>,\n ): FoldkitSubscription.EntryWithoutKeepAlive<\n Model,\n SuccessMessage | ErrorMessage,\n Dependencies<Query>,\n Client.Client\n > => {\n const modelToArgs = config.args;\n\n return {\n dependenciesSchema: Schema.Struct({\n args: Schema.Option(ref.args),\n }),\n modelToDependencies: (model) => ({\n args:\n modelToArgs === undefined\n ? Option.some({} as Ref.Args<Query>)\n : modelToArgs(model),\n }),\n dependenciesToStream: ({ args }) =>\n Option.match(args, {\n onNone: () => Stream.empty,\n onSome: (someArgs) => reactiveQueryStream(ref, config)(someArgs),\n }),\n };\n };\n\n/**\n * A complete Foldkit subscription entry that keeps exactly one live reactive\n * page subscription in sync with a `PaginatedQuery` machine in the Model.\n * The machine state is the single source of truth: navigation and\n * split-pinning change the derived args, while `Idle` closes the subscription.\n * Pagination ids are allocated here and installed by the first settlement.\n *\n * The leading thunk fixes the `Model` type (TypeScript cannot partially\n * infer type arguments), so the `state` extractor's parameter is already\n * typed:\n *\n * ```ts\n * import * as Confect from \"@confect/foldkit\"\n * import * as Subscription from \"foldkit/subscription\"\n *\n * const subscriptions = Subscription.make<\n * Model,\n * Message,\n * Confect.Client.Client\n * >()(() => ({\n * notesPage: Confect.Subscription.paginatedQuery<Model>()(Notes, {\n * state: (model) => model.notes,\n * onSettled: (settlement) => SettledGetNotesPage({ settlement }),\n * }),\n * }))\n * ```\n *\n * Pass the settlement to `PaginatedQuery.settle` in `update`. The request\n * identity is included in both success and failure Messages, so superseded\n * outcomes cannot settle a newer page or pagination session. Query failures\n * do not close the Convex subscription; a later result can recover naturally.\n */\ntype DependenciesSchema<Dependencies_> = Schema.Schema<Dependencies_> & {\n readonly fields: Schema.Struct.Fields;\n};\n\ntype EntryWithKeepAlive<Model, Message, Dependencies_, Services> = {\n readonly dependenciesSchema: DependenciesSchema<Dependencies_>;\n readonly modelToDependencies: (model: Model) => Dependencies_;\n readonly keepAliveEquivalence: Equivalence.Equivalence<Dependencies_>;\n readonly dependenciesToStream: (\n dependencies: Dependencies_,\n readDependencies: () => Dependencies_,\n ) => Stream.Stream<Message, never, Services>;\n};\n\nexport const paginatedQuery =\n <Model>() =>\n <\n PaginatedQueryRef extends Ref.AnyConfectPublicPaginatedQuery,\n SettledMessage,\n >(\n machine: PaginatedQuery.PaginatedQuery<PaginatedQueryRef>,\n config: {\n readonly state: (\n model: Model,\n ) => PaginatedQuery.State<\n PaginatedQuery.Item<PaginatedQueryRef>,\n PaginatedQuery.UserArgs<PaginatedQueryRef>,\n PaginatedQuery.Error<PaginatedQueryRef>\n >;\n readonly onSettled: (\n settlement: PaginatedQuery.Settlement<\n PaginatedQuery.Item<PaginatedQueryRef>,\n PaginatedQuery.UserArgs<PaginatedQueryRef>,\n PaginatedQuery.Error<PaginatedQueryRef>\n >,\n ) => SettledMessage;\n },\n ): EntryWithKeepAlive<\n Model,\n SettledMessage,\n {\n readonly request: Option.Option<\n PaginatedQuery.SubscriptionRequest<\n PaginatedQuery.UserArgs<PaginatedQueryRef>\n >\n >;\n },\n Client.Client\n > => {\n const ref = machine.ref;\n const composedArgsSchema = ref.args;\n const requestEquivalence = Schema.toEquivalence(\n machine.subscriptionRequestSchema,\n );\n const optionalRequestEquivalence = Option.makeEquivalence<\n PaginatedQuery.SubscriptionRequest<\n PaginatedQuery.UserArgs<PaginatedQueryRef>\n >\n >((left, right) =>\n requestEquivalence(\n { ...left, paginationId: Option.none() },\n { ...right, paginationId: Option.none() },\n ),\n );\n\n return {\n dependenciesSchema: Schema.Struct({\n request: Schema.Option(machine.subscriptionRequestSchema),\n }),\n modelToDependencies: (model) => ({\n request: Match.value(config.state(model)).pipe(\n Match.tag(\"Idle\", () => Option.none()),\n Match.tag(\"Active\", (state) =>\n Option.some(PaginatedQuery.getSubscriptionRequest(state)),\n ),\n Match.exhaustive,\n ),\n }),\n keepAliveEquivalence: (left, right) =>\n optionalRequestEquivalence(left.request, right.request),\n dependenciesToStream: ({\n request,\n }): Stream.Stream<SettledMessage, never, Client.Client> =>\n Option.match(request, {\n onNone: () => Stream.empty,\n onSome: (subscriptionRequest) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const client = yield* Client.Client;\n const paginationId = yield* client.resolvePaginationId(\n subscriptionRequest.paginationId,\n );\n const allocatedRequest = PaginatedQuery.allocateRequest(\n subscriptionRequest,\n paginationId,\n );\n const { descriptor, options } = allocatedRequest;\n const composedArgs = composedArgsSchema.make({\n ...allocatedRequest.args,\n paginationOpts: {\n numItems: options.initialNumItems,\n cursor: descriptor.cursor,\n id: paginationId,\n ...Match.value(options.maximumRowsRead).pipe(\n Match.when(undefined, () => ({})),\n Match.when(Match.defined, (maximumRowsRead) => ({\n maximumRowsRead,\n })),\n Match.exhaustive,\n ),\n ...Match.value(options.maximumBytesRead).pipe(\n Match.when(undefined, () => ({})),\n Match.when(Match.defined, (maximumBytesRead) => ({\n maximumBytesRead,\n })),\n Match.exhaustive,\n ),\n ...Option.match(descriptor.endCursor, {\n onNone: () => ({}),\n onSome: (endCursor) => ({ endCursor }),\n }),\n },\n });\n return client.reactiveQueryResult(ref, composedArgs).pipe(\n Stream.map((result) =>\n config.onSettled({\n request: allocatedRequest,\n result: Result.mapError(result, paginatedError),\n }),\n ),\n );\n }),\n ),\n }),\n };\n };\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAM,kBACJ,UAEA,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,KAAK,OAAO,gBAAgB,gBAAgB,WAAW,GAC7D,MAAM,KAAK,MAAM,WAAWA,oBAA2B,IAAI,gBACzD,gBAAgB,qBAAqB,YAAY,KAAK,CAAC,CAAC,KACtD,OAAO,gBAAgB,WAAW,CACpC,CACF,GACA,MAAM,KAAK,MAAM,MAAM,kBACrB,gBAAgB,oBAAoB,aAAa,CAAC,CAAC,KACjD,OAAO,gBACLC,cAA6B,EAAE,OAAO,cAAc,CAAC,CACvD,CACF,CACF,GACA,MAAM,UACR;;;;;;;;;;;AAgDF,MAAa,uBAET,KACA,cAGA,GAAG,SAAA,OAEW,KACZ,OAAO,KAAK,WAAW,OAAO,oBAAoB,KAAK,GAAG,IAAI,CAAC,GAC/D,OAAO,QACP,OAAO,IACL,OAAO,MAAM;CACX,WAAW,SAAS;CACpB,WAAW,SAAS;AACtB,CAAC,CACH,CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BJ,MAAa,uBAGT,KACA,WAOG;CACH,MAAM,cAAc,OAAO;CAE3B,OAAO;EACL,oBAAoB,OAAO,OAAO,EAChC,MAAM,OAAO,OAAO,IAAI,IAAI,EAC9B,CAAC;EACD,sBAAsB,WAAW,EAC/B,MACE,gBAAgB,KAAA,IACZ,OAAO,KAAK,CAAC,CAAoB,IACjC,YAAY,KAAK,EACzB;EACA,uBAAuB,EAAE,WACvB,OAAO,MAAM,MAAM;GACjB,cAAc,OAAO;GACrB,SAAS,aAAa,oBAAoB,KAA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;MACA,GAAG,MAAM,MAAM,QAAQ,gBAAgB,CAAC,CAAC,KACvC,MAAM,KAAK,KAAA,UAAkB,CAAC,EAAE,GAChC,MAAM,KAAK,MAAM,UAAU,sBAAsB,EAC/C,iBACF,EAAE,GACF,MAAM,UACR;MACA,GAAG,OAAO,MAAM,WAAW,WAAW;OACpC,eAAe,CAAC;OAChB,SAAS,eAAe,EAAE,UAAU;MACtC,CAAC;KACH;IACF,CAAC;IACD,OAAO,OAAO,oBAAoB,KAAK,YAAY,CAAC,CAAC,KACnD,OAAO,KAAK,WACV,OAAO,UAAU;KACf,SAAS;KACT,QAAQ,OAAO,SAAS,QAAQ,cAAc;IAChD,CAAC,CACH,CACF;GACF,CAAC,CACH;EACJ,CAAC;CACL;AACF"}
|
|
1
|
+
{"version":3,"file":"Subscription.js","names":["Client.WebSocketClientError","PaginatedQuery.FunctionError","PaginatedQuery.getSubscriptionRequest","Client.Client","PaginatedQuery.allocateRequest"],"sources":["../src/Subscription.ts"],"sourcesContent":["import * as PaginationError from \"@confect/core/PaginationError\";\nimport type * as Ref from \"@confect/core/Ref\";\nimport * as Effect from \"effect/Effect\";\nimport type * as Equivalence from \"effect/Equivalence\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\nimport type * as FoldkitSubscription from \"foldkit/subscription\";\nimport * as PaginatedQuery from \"./PaginatedQuery\";\nimport * as Client from \"./Client\";\n\n/**\n * Everything a reactive query subscription against `Query` can fail with: the\n * ref's typed error (if it declares an `error` schema), a transport-level\n * `WebSocketClientError`, or a `SchemaError` from encoding args or decoding\n * returns.\n */\nexport type Error<Query extends Ref.AnyConfectPublicQuery> =\n | Ref.Error<Query>\n | Client.WebSocketClientError\n | Schema.SchemaError;\n\nconst paginatedError = <Query extends Ref.AnyConfectPublicPaginatedQuery>(\n error: Error<Query>,\n): PaginatedQuery.Error<Query> =>\n Match.value(error).pipe(\n Match.when(Schema.isSchemaError, (schemaError) => schemaError),\n Match.when(Match.instanceOf(Client.WebSocketClientError), (clientError) =>\n PaginationError.fromConvexQueryError(clientError.cause).pipe(\n Option.getOrElse(() => clientError),\n ),\n ),\n Match.when(Match.any, (functionError) =>\n PaginationError.fromConvexErrorData(functionError).pipe(\n Option.getOrElse(() =>\n PaginatedQuery.FunctionError({ error: functionError }),\n ),\n ),\n ),\n Match.exhaustive,\n ) as PaginatedQuery.Error<Query>;\n\n/**\n * The dependency record of a `reactiveQuery` entry. `None` means the\n * subscription is closed; a change from one `Some` to another tears the\n * server subscription down and reopens it with the new args.\n */\nexport interface Dependencies<Query extends Ref.AnyConfectPublicQuery> {\n readonly args: Option.Option<Ref.Args<Query>>;\n}\n\n/**\n * Maps a reactive query's emissions into the app's Messages. Every failure—the ref's typed error, a transport error, or a codec error—arrives via\n * `onError`, so the resulting stream's error channel is `never`, as Foldkit\n * requires.\n */\nexport interface Handlers<\n Query extends Ref.AnyConfectPublicQuery,\n SuccessMessage,\n ErrorMessage,\n> {\n readonly onSuccess: (returns: Ref.Returns<Query>) => SuccessMessage;\n readonly onError: (error: Error<Query>) => ErrorMessage;\n}\n\n/**\n * The `args` extractor is required whenever the query declares args; queries\n * without args may omit it, in which case the subscription is always open.\n */\ntype ArgsConfig<Query extends Ref.AnyConfectPublicQuery, Model> = {\n readonly args?: (model: Model) => Option.Option<Ref.Args<Query>>;\n} & (keyof Ref.Args<Query> extends never\n ? unknown\n : {\n readonly args: (model: Model) => Option.Option<Ref.Args<Query>>;\n });\n\n/**\n * A `dependenciesToStream` body for a hand-written subscription entry: runs\n * the ref as a reactive query against the `Client` resource and maps\n * every emission and every failure into a Message. Query failures are values,\n * so the subscription remains live and can later emit a successful result.\n *\n * Prefer `reactiveQuery`, which builds the whole entry; reach for this when\n * you need control over the entry's dependencies (custom gating, extra\n * dependencies).\n */\nexport const reactiveQueryStream =\n <Query extends Ref.AnyConfectPublicQuery, SuccessMessage, ErrorMessage>(\n ref: Query,\n handlers: Handlers<Query, SuccessMessage, ErrorMessage>,\n ) =>\n (\n ...args: Ref.OptionalArgs<Query>\n ): Stream.Stream<SuccessMessage | ErrorMessage, never, Client.Client> =>\n Client.Client.pipe(\n Effect.map((client) => client.reactiveQueryResult(ref, ...args)),\n Stream.unwrap,\n Stream.map(\n Result.match({\n onSuccess: handlers.onSuccess,\n onFailure: handlers.onError,\n }),\n ),\n );\n\n/**\n * A complete Foldkit subscription entry for a Confect reactive query. The\n * leading thunk fixes the `Model` type (TypeScript cannot partially infer\n * type arguments), so the `args` extractor's parameter is already typed.\n * Pass the result as an entry value to `Subscription.make`:\n *\n * ```ts\n * import * as Confect from \"@confect/foldkit\"\n * import * as Subscription from \"foldkit/subscription\"\n *\n * const subscriptions = Subscription.make<\n * Model,\n * Message,\n * Confect.Client.Client\n * >()(() => ({\n * note: Confect.Subscription.reactiveQuery<Model>()(refs.public.notes.get, {\n * args: (model) => Option.map(model.noteId, (noteId) => ({ noteId })),\n * onSuccess: (note) => SucceededGetNote({ note }),\n * onError: (error) => FailedGetNote({ message: String(error) }),\n * }),\n * }))\n * ```\n *\n * The entry's dependencies are the query args wrapped in `Option`: `None`\n * closes the subscription, a change from one `Some` to another unsubscribes\n * and resubscribes with the new args, and structurally equal args leave the\n * subscription running (equivalence is derived from the ref's args schema).\n * Queries without args may omit `args`, leaving the subscription always open.\n */\nexport const reactiveQuery =\n <Model>() =>\n <Query extends Ref.AnyConfectPublicQuery, SuccessMessage, ErrorMessage>(\n ref: Query,\n config: Handlers<Query, SuccessMessage, ErrorMessage> &\n ArgsConfig<Query, Model>,\n ): FoldkitSubscription.EntryWithoutKeepAlive<\n Model,\n SuccessMessage | ErrorMessage,\n Dependencies<Query>,\n Client.Client\n > => {\n const modelToArgs = config.args;\n\n return {\n dependenciesSchema: Schema.Struct({\n args: Schema.Option(ref.args),\n }),\n modelToDependencies: (model) => ({\n args:\n modelToArgs === undefined\n ? Option.some({} as Ref.Args<Query>)\n : modelToArgs(model),\n }),\n dependenciesToStream: ({ args }) =>\n Option.match(args, {\n onNone: () => Stream.empty,\n onSome: (someArgs) => reactiveQueryStream(ref, config)(someArgs),\n }),\n };\n };\n\n/**\n * A complete Foldkit subscription entry that keeps exactly one live reactive\n * page subscription in sync with a `PaginatedQuery` machine in the Model.\n * The machine state is the single source of truth: navigation and\n * split-pinning change the derived args, while `Idle` closes the subscription.\n * Pagination ids are allocated here and installed by the first settlement.\n *\n * The leading thunk fixes the `Model` type (TypeScript cannot partially\n * infer type arguments), so the `state` extractor's parameter is already\n * typed:\n *\n * ```ts\n * import * as Confect from \"@confect/foldkit\"\n * import * as Subscription from \"foldkit/subscription\"\n *\n * const subscriptions = Subscription.make<\n * Model,\n * Message,\n * Confect.Client.Client\n * >()(() => ({\n * notesPage: Confect.Subscription.paginatedQuery<Model>()(Notes, {\n * state: (model) => model.notes,\n * onSettled: (settlement) => SettledGetNotesPage({ settlement }),\n * }),\n * }))\n * ```\n *\n * Pass the settlement to `PaginatedQuery.settle` in `update`. The request\n * identity is included in both success and failure Messages, so superseded\n * outcomes cannot settle a newer page or pagination session. Query failures\n * do not close the Convex subscription; a later result can recover naturally.\n */\ntype DependenciesSchema<Dependencies_> = Schema.Schema<Dependencies_> & {\n readonly fields: Schema.Struct.Fields;\n};\n\ntype EntryWithKeepAlive<Model, Message, Dependencies_, Services> = {\n readonly dependenciesSchema: DependenciesSchema<Dependencies_>;\n readonly modelToDependencies: (model: Model) => Dependencies_;\n readonly keepAliveEquivalence: Equivalence.Equivalence<Dependencies_>;\n readonly dependenciesToStream: (\n dependencies: Dependencies_,\n readDependencies: () => Dependencies_,\n ) => Stream.Stream<Message, never, Services>;\n};\n\nexport const paginatedQuery =\n <Model>() =>\n <\n PaginatedQueryRef extends Ref.AnyConfectPublicPaginatedQuery,\n SettledMessage,\n >(\n machine: PaginatedQuery.PaginatedQuery<PaginatedQueryRef>,\n config: {\n readonly state: (\n model: Model,\n ) => PaginatedQuery.State<\n PaginatedQuery.Item<PaginatedQueryRef>,\n PaginatedQuery.UserArgs<PaginatedQueryRef>,\n PaginatedQuery.Error<PaginatedQueryRef>\n >;\n readonly onSettled: (\n settlement: PaginatedQuery.Settlement<\n PaginatedQuery.Item<PaginatedQueryRef>,\n PaginatedQuery.UserArgs<PaginatedQueryRef>,\n PaginatedQuery.Error<PaginatedQueryRef>\n >,\n ) => SettledMessage;\n },\n ): EntryWithKeepAlive<\n Model,\n SettledMessage,\n {\n readonly request: Option.Option<\n PaginatedQuery.SubscriptionRequest<\n PaginatedQuery.UserArgs<PaginatedQueryRef>\n >\n >;\n },\n Client.Client\n > => {\n const ref = machine.ref;\n const composedArgsSchema = ref.args;\n const requestEquivalence = Schema.toEquivalence(\n machine.subscriptionRequestSchema,\n );\n const optionalRequestEquivalence = Option.makeEquivalence<\n PaginatedQuery.SubscriptionRequest<\n PaginatedQuery.UserArgs<PaginatedQueryRef>\n >\n >((left, right) =>\n requestEquivalence(\n { ...left, paginationId: Option.none() },\n { ...right, paginationId: Option.none() },\n ),\n );\n\n return {\n dependenciesSchema: Schema.Struct({\n request: Schema.Option(machine.subscriptionRequestSchema),\n }),\n modelToDependencies: (model) => ({\n request: Match.value(config.state(model)).pipe(\n Match.tag(\"Idle\", () => Option.none()),\n Match.tag(\"Active\", (state) =>\n Option.some(PaginatedQuery.getSubscriptionRequest(state)),\n ),\n Match.exhaustive,\n ),\n }),\n keepAliveEquivalence: (left, right) =>\n optionalRequestEquivalence(left.request, right.request),\n dependenciesToStream: ({\n request,\n }): Stream.Stream<SettledMessage, never, Client.Client> =>\n Option.match(request, {\n onNone: () => Stream.empty,\n onSome: (subscriptionRequest) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const client = yield* Client.Client;\n const paginationId = yield* client.resolvePaginationId(\n subscriptionRequest.paginationId,\n );\n const allocatedRequest = PaginatedQuery.allocateRequest(\n subscriptionRequest,\n paginationId,\n );\n const { descriptor, options } = allocatedRequest;\n const composedArgs = composedArgsSchema.make({\n ...allocatedRequest.args,\n paginationOpts: {\n numItems: options.initialNumItems,\n cursor: descriptor.cursor,\n id: paginationId,\n ...Match.value(options.maximumRowsRead).pipe(\n Match.when(undefined, () => ({})),\n Match.when(Match.defined, (maximumRowsRead) => ({\n maximumRowsRead,\n })),\n Match.exhaustive,\n ),\n ...Match.value(options.maximumBytesRead).pipe(\n Match.when(undefined, () => ({})),\n Match.when(Match.defined, (maximumBytesRead) => ({\n maximumBytesRead,\n })),\n Match.exhaustive,\n ),\n ...Option.match(descriptor.endCursor, {\n onNone: () => ({}),\n onSome: (endCursor) => ({ endCursor }),\n }),\n },\n });\n return client.reactiveQueryResult(ref, composedArgs).pipe(\n Stream.map((result) =>\n config.onSettled({\n request: allocatedRequest,\n result: Result.mapError(result, paginatedError),\n }),\n ),\n );\n }),\n ),\n }),\n };\n };\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAM,kBACJ,UAEA,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,KAAK,OAAO,gBAAgB,gBAAgB,WAAW,GAC7D,MAAM,KAAK,MAAM,WAAWA,oBAA2B,IAAI,gBACzD,gBAAgB,qBAAqB,YAAY,KAAK,CAAC,CAAC,KACtD,OAAO,gBAAgB,WAAW,CACpC,CACF,GACA,MAAM,KAAK,MAAM,MAAM,kBACrB,gBAAgB,oBAAoB,aAAa,CAAC,CAAC,KACjD,OAAO,gBACLC,cAA6B,EAAE,OAAO,cAAc,CAAC,CACvD,CACF,CACF,GACA,MAAM,UACR;;;;;;;;;;;AA+CF,MAAa,uBAET,KACA,cAGA,GAAG,SAAA,OAEW,KACZ,OAAO,KAAK,WAAW,OAAO,oBAAoB,KAAK,GAAG,IAAI,CAAC,GAC/D,OAAO,QACP,OAAO,IACL,OAAO,MAAM;CACX,WAAW,SAAS;CACpB,WAAW,SAAS;AACtB,CAAC,CACH,CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BJ,MAAa,uBAGT,KACA,WAOG;CACH,MAAM,c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Y,YAAY;IAChC,MAAM,eAAe,mBAAmB,KAAK;KAC3C,GAAG,iBAAiB;KACpB,gBAAgB;MACd,UAAU,QAAQ;MAClB,QAAQ,WAAW;MACnB,IAAI;MACJ,GAAG,MAAM,MAAM,QAAQ,eAAe,CAAC,CAAC,KACtC,MAAM,KAAK,KAAA,UAAkB,CAAC,EAAE,GAChC,MAAM,KAAK,MAAM,UAAU,qBAAqB,EAC9C,gBACF,EAAE,GACF,MAAM,UACR;MACA,GAAG,MAAM,MAAM,QAAQ,gBAAgB,CAAC,CAAC,KACvC,MAAM,KAAK,KAAA,UAAkB,CAAC,EAAE,GAChC,MAAM,KAAK,MAAM,UAAU,sBAAsB,EAC/C,iBACF,EAAE,GACF,MAAM,UACR;MACA,GAAG,OAAO,MAAM,WAAW,WAAW;OACpC,eAAe,CAAC;OAChB,SAAS,eAAe,EAAE,UAAU;MACtC,CAAC;KACH;IACF,CAAC;IACD,OAAO,OAAO,oBAAoB,KAAK,YAAY,CAAC,CAAC,KACnD,OAAO,KAAK,WACV,OAAO,UAAU;KACf,SAAS;KACT,QAAQ,OAAO,SAAS,QAAQ,cAAc;IAChD,CAAC,CACH,CACF;GACF,CAAC,CACH;EACJ,CAAC;CACL;AACF"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@confect/foldkit",
|
|
3
3
|
"description": "Client-side bindings for Foldkit apps",
|
|
4
|
-
"version": "10.0.0-next.
|
|
4
|
+
"version": "10.0.0-next.22",
|
|
5
5
|
"author": "RJ Dellecese",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/rjdellecese/confect/issues"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@effect/vitest": "4.0.0-rc.
|
|
11
|
-
"@types/node": "
|
|
10
|
+
"@effect/vitest": "4.0.0-rc.115",
|
|
11
|
+
"@types/node": "24.13.3",
|
|
12
12
|
"convex": "1.45.0",
|
|
13
|
-
"effect": "4.0.0-rc.
|
|
13
|
+
"effect": "4.0.0-rc.115",
|
|
14
14
|
"foldkit": "0.148.1",
|
|
15
|
-
"tsdown": "0.
|
|
15
|
+
"tsdown": "0.23.0",
|
|
16
16
|
"typescript": "7.0.2",
|
|
17
17
|
"unrun": "0.3.1",
|
|
18
|
-
"vitest": "
|
|
18
|
+
"vitest": "5.0.0"
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=24"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"main": "./dist/index.js",
|
|
51
51
|
"module": "./dist/index.js",
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
53
|
+
"@confect/core": "^10.0.0-next.22",
|
|
54
|
+
"@confect/js": "^10.0.0-next.22",
|
|
55
|
+
"effect": "^4.0.0-rc.115",
|
|
56
|
+
"foldkit": "^0.148.0"
|
|
57
57
|
},
|
|
58
58
|
"repository": {
|
|
59
59
|
"type": "git",
|
package/src/Command.ts
CHANGED
|
@@ -17,11 +17,10 @@ export type Error<Ref_ extends Ref.AnyConfect> =
|
|
|
17
17
|
| Schema.SchemaError;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Maps a Confect function's outcome into the app's Messages. Every failure —
|
|
21
|
-
* the ref's typed error, a transport error, or a codec error — arrives via
|
|
20
|
+
* Maps a Confect function's outcome into the app's Messages. Every failure—the ref's typed error, a transport error, or a codec error—arrives via
|
|
22
21
|
* `onError`, so the resulting Command's error channel is `never`, as Foldkit
|
|
23
22
|
* requires. Follow Foldkit's naming convention: past-tense facts like
|
|
24
|
-
* `SucceededSaveNote
|
|
23
|
+
* `SucceededSaveNote`/`FailedSaveNote`.
|
|
25
24
|
*/
|
|
26
25
|
export interface Handlers<
|
|
27
26
|
Ref_ extends Ref.AnyConfect,
|
|
@@ -54,7 +53,7 @@ type SchemaArgs<Ref_ extends Ref.AnyConfect> = Schema.Schema.Type<
|
|
|
54
53
|
* ref-derived call signature (args optional when the ref declares none)
|
|
55
54
|
* intersected with Foldkit's own `CommandDefinitionWithArgs`, which supplies
|
|
56
55
|
* the `CommandDefinitionTypeId` brand and makes the definition assignable
|
|
57
|
-
* wherever Foldkit accepts one
|
|
56
|
+
* wherever Foldkit accepts one—including Story/Scene `Command.resolve`
|
|
58
57
|
* and `expectExact` matchers. Call it from `update` to construct a Command
|
|
59
58
|
* instance; nothing runs until the Foldkit runtime executes it.
|
|
60
59
|
*/
|
|
@@ -70,14 +69,14 @@ export type Definition<
|
|
|
70
69
|
>;
|
|
71
70
|
|
|
72
71
|
/**
|
|
73
|
-
* Makes a factory-built Command interruptible
|
|
72
|
+
* Makes a factory-built Command interruptible—Foldkit's `InterruptOption`
|
|
74
73
|
* applied to the ref's args. `true` keys every invocation by the Command
|
|
75
|
-
* name
|
|
74
|
+
* name—right when at most one invocation is meaningfully in flight; a
|
|
76
75
|
* `KeyedInterrupt` derives the key part from the ref's args, so concurrent
|
|
77
76
|
* invocations can be targeted independently.
|
|
78
77
|
*
|
|
79
78
|
* Interrupting stops the client-side Effect and guarantees the invocation's
|
|
80
|
-
* result Messages never dispatch
|
|
79
|
+
* result Messages never dispatch—it does not cancel the Convex function on
|
|
81
80
|
* the server, which runs to completion once the call is on the wire.
|
|
82
81
|
*/
|
|
83
82
|
export type InterruptOption<
|
|
@@ -96,7 +95,7 @@ export type KeyedInterrupt<
|
|
|
96
95
|
> = Exclude<InterruptOption<Ref_, KeyField>, true>;
|
|
97
96
|
|
|
98
97
|
/**
|
|
99
|
-
* An interruptible Command definition whose key is the Command name
|
|
98
|
+
* An interruptible Command definition whose key is the Command name—the
|
|
100
99
|
* ref-derived call signature intersected with Foldkit's
|
|
101
100
|
* `Interruptible.DefinitionWithArgsNameKeyed`, which supplies the brand and
|
|
102
101
|
* the `Interrupt` constructor.
|
|
@@ -116,7 +115,7 @@ export type InterruptibleDefinition<
|
|
|
116
115
|
|
|
117
116
|
/**
|
|
118
117
|
* An interruptible Command definition whose key is derived from the ref's
|
|
119
|
-
* args
|
|
118
|
+
* args—the ref-derived call signature intersected with Foldkit's
|
|
120
119
|
* `Interruptible.DefinitionWithArgs`, which supplies the brand and the
|
|
121
120
|
* key-args-taking `Interrupt` constructor.
|
|
122
121
|
*/
|
|
@@ -149,7 +148,7 @@ const run = <Ref_ extends Ref.AnyConfect, SuccessMessage, ErrorMessage>(
|
|
|
149
148
|
);
|
|
150
149
|
|
|
151
150
|
/**
|
|
152
|
-
* An execute body for a hand-written `Command.define
|
|
151
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
153
152
|
* folded into a Message. Reach for these when the factory below doesn't fit:
|
|
154
153
|
* a custom args schema, `interrupt`, or a Command that makes several calls.
|
|
155
154
|
*/
|
|
@@ -164,7 +163,7 @@ export const queryEffect =
|
|
|
164
163
|
run(handlers, (client) => client.query(ref, ...args));
|
|
165
164
|
|
|
166
165
|
/**
|
|
167
|
-
* An execute body for a hand-written `Command.define
|
|
166
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
168
167
|
* folded into a Message. See `queryEffect`.
|
|
169
168
|
*/
|
|
170
169
|
export const mutationEffect =
|
|
@@ -178,7 +177,7 @@ export const mutationEffect =
|
|
|
178
177
|
run(handlers, (client) => client.mutation(ref, ...args));
|
|
179
178
|
|
|
180
179
|
/**
|
|
181
|
-
* An execute body for a hand-written `Command.define
|
|
180
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
182
181
|
* folded into a Message. See `queryEffect`.
|
|
183
182
|
*/
|
|
184
183
|
export const actionEffect =
|
|
@@ -418,7 +417,7 @@ const makeFactory = <BoundRef extends Ref.AnyConfect>(
|
|
|
418
417
|
* ```
|
|
419
418
|
*
|
|
420
419
|
* Pass `interrupt` to make invocations interruptible via the returned
|
|
421
|
-
* definition's `Interrupt` constructor
|
|
420
|
+
* definition's `Interrupt` constructor—`true` keys them by the Command
|
|
422
421
|
* name, `{ keyFields, toKey }` by a part derived from the ref's args:
|
|
423
422
|
*
|
|
424
423
|
* ```ts
|
package/src/PaginatedQuery.ts
CHANGED
|
@@ -543,7 +543,17 @@ export const reset = <Item_, UserArgs_, Error_>(
|
|
|
543
543
|
phase: pendingPhase(phaseData(state.phase), "Reset"),
|
|
544
544
|
});
|
|
545
545
|
|
|
546
|
-
/**
|
|
546
|
+
/**
|
|
547
|
+
* Navigate to the next page, retaining the current page while it loads.
|
|
548
|
+
*
|
|
549
|
+
* The page being left is pushed onto the stack *pinned* to the range it
|
|
550
|
+
* displayed—its cursor to its continuation cursor—so `prev` reloads
|
|
551
|
+
* exactly that range rather than the first `initialNumItems` documents
|
|
552
|
+
* after its cursor, however the data has moved meanwhile. Convex's own
|
|
553
|
+
* pagination keeps that range in its query journal; stream-paginated
|
|
554
|
+
* queries have no journal, so the pin is what keeps consecutive pages
|
|
555
|
+
* gap-free and duplicate-free for them.
|
|
556
|
+
*/
|
|
547
557
|
export const next = <Item_, UserArgs_, Error_>(
|
|
548
558
|
state: Active<Item_, UserArgs_, Error_>,
|
|
549
559
|
): Option.Option<Active<Item_, UserArgs_, Error_>> =>
|
|
@@ -553,24 +563,25 @@ export const next = <Item_, UserArgs_, Error_>(
|
|
|
553
563
|
Match.value(data.isDone).pipe(
|
|
554
564
|
Match.withReturnType<Option.Option<Active<Item_, UserArgs_, Error_>>>(),
|
|
555
565
|
Match.when(true, () => Option.none()),
|
|
556
|
-
Match.when(false, () =>
|
|
557
|
-
Option.
|
|
566
|
+
Match.when(false, () => {
|
|
567
|
+
const end = Option.getOrElse(
|
|
568
|
+
data.descriptor.endCursor,
|
|
569
|
+
() => data.continueCursor,
|
|
570
|
+
);
|
|
571
|
+
return Option.some({
|
|
558
572
|
...state,
|
|
559
573
|
requestId: state.requestId + 1,
|
|
560
|
-
current: {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
endCursor: Option.none(),
|
|
566
|
-
},
|
|
567
|
-
prevStack: [...state.prevStack, data.descriptor],
|
|
574
|
+
current: { cursor: end, endCursor: Option.none() },
|
|
575
|
+
prevStack: [
|
|
576
|
+
...state.prevStack,
|
|
577
|
+
{ cursor: data.descriptor.cursor, endCursor: Option.some(end) },
|
|
578
|
+
],
|
|
568
579
|
phase: Phase.Refreshing<Item_, Error_>({
|
|
569
580
|
data,
|
|
570
581
|
direction: "Next",
|
|
571
582
|
}),
|
|
572
|
-
})
|
|
573
|
-
),
|
|
583
|
+
});
|
|
584
|
+
}),
|
|
574
585
|
Match.exhaustive,
|
|
575
586
|
),
|
|
576
587
|
),
|
package/src/Subscription.ts
CHANGED
|
@@ -52,8 +52,7 @@ export interface Dependencies<Query extends Ref.AnyConfectPublicQuery> {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* Maps a reactive query's emissions into the app's Messages. Every failure —
|
|
56
|
-
* the ref's typed error, a transport error, or a codec error — arrives via
|
|
55
|
+
* Maps a reactive query's emissions into the app's Messages. Every failure—the ref's typed error, a transport error, or a codec error—arrives via
|
|
57
56
|
* `onError`, so the resulting stream's error channel is `never`, as Foldkit
|
|
58
57
|
* requires.
|
|
59
58
|
*/
|