@confect/foldkit 10.0.0-next.21 → 10.0.0-next.23
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 +76 -3
- package/dist/Command.d.ts +44 -40
- package/dist/Command.d.ts.map +1 -1
- package/dist/Command.js +20 -16
- package/dist/Command.js.map +1 -1
- package/dist/PaginatedQuery.d.ts +94 -30
- package/dist/PaginatedQuery.d.ts.map +1 -1
- package/dist/PaginatedQuery.js +72 -28
- package/dist/PaginatedQuery.js.map +1 -1
- package/dist/Subscription.d.ts +39 -37
- package/dist/Subscription.d.ts.map +1 -1
- package/dist/Subscription.js +23 -19
- package/dist/Subscription.js.map +1 -1
- package/package.json +11 -9
- package/src/Command.ts +44 -40
- package/src/PaginatedQuery.ts +107 -42
- package/src/Subscription.ts +39 -37
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,78 @@
|
|
|
1
1
|
# @confect/foldkit
|
|
2
2
|
|
|
3
|
+
## 10.0.0-next.23
|
|
4
|
+
|
|
5
|
+
No changes in this release.
|
|
6
|
+
|
|
7
|
+
## 10.0.0-next.22
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 6cc5834: Add experimental stream querying with reactive pagination, configurable middleware policies, and broader tracing.
|
|
12
|
+
|
|
13
|
+
### Stream queries and pagination
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
`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.
|
|
18
|
+
|
|
19
|
+
Use React's new `useStreamPaginatedQuery` for these queries:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { useStreamPaginatedQuery } from "@confect/react";
|
|
23
|
+
|
|
24
|
+
const { results, status, loadMore } = useStreamPaginatedQuery(
|
|
25
|
+
refs.public.notes.feed,
|
|
26
|
+
{},
|
|
27
|
+
{
|
|
28
|
+
initialNumItems: 10,
|
|
29
|
+
maximumRowsRead: 1000,
|
|
30
|
+
maximumBytesRead: 512 * 1024,
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
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.
|
|
38
|
+
|
|
39
|
+
### Middleware options
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
### Breaking changes
|
|
46
|
+
|
|
47
|
+
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`:
|
|
48
|
+
|
|
49
|
+
**Before:**
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
(effect, { name, args }) => effect;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**After:**
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
(effect, { invocation: { name, args } }) => effect;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Middleware with an options schema also receives `options` alongside `invocation`; middleware without one keeps its single-argument attachment API and receives only `{ invocation }`.
|
|
62
|
+
|
|
63
|
+
### Fixes and tracing
|
|
64
|
+
- Preserve `ConvexError.data` when a handler throws a `ConvexError` inside an Effect instead of returning it as a typed failure.
|
|
65
|
+
- 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.
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- 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.
|
|
70
|
+
|
|
71
|
+
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.
|
|
72
|
+
|
|
73
|
+
- 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.
|
|
74
|
+
- f721d2c: Remove spaces around em dashes and separator slashes in API documentation and `confect codegen` diagnostics.
|
|
75
|
+
|
|
3
76
|
## 10.0.0-next.21
|
|
4
77
|
|
|
5
78
|
### Major Changes
|
|
@@ -9,7 +82,7 @@
|
|
|
9
82
|
### Breaking Changes
|
|
10
83
|
- `engines.node` is now `>=24` on every `@confect/*` package, raised from `>=22`.
|
|
11
84
|
|
|
12
|
-
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
|
|
85
|
+
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.
|
|
13
86
|
|
|
14
87
|
## 10.0.0-next.20
|
|
15
88
|
|
|
@@ -17,7 +90,7 @@
|
|
|
17
90
|
|
|
18
91
|
### Minor Changes
|
|
19
92
|
|
|
20
|
-
- c1087eb: Add `@confect/foldkit
|
|
93
|
+
- 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.
|
|
21
94
|
|
|
22
95
|
```ts
|
|
23
96
|
import * as Confect from "@confect/foldkit";
|
|
@@ -47,7 +120,7 @@
|
|
|
47
120
|
}));
|
|
48
121
|
```
|
|
49
122
|
|
|
50
|
-
The Command factories accept Foldkit's `interrupt` option
|
|
123
|
+
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.
|
|
51
124
|
|
|
52
125
|
`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.
|
|
53
126
|
|
package/dist/Command.d.ts
CHANGED
|
@@ -4,18 +4,18 @@ import type * as Schema from "effect/Schema";
|
|
|
4
4
|
import * as FoldkitCommand from "foldkit/command";
|
|
5
5
|
import * as Client from "./Client";
|
|
6
6
|
/**
|
|
7
|
-
* Everything a Command against `Ref_` can fail with before it is folded into
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Everything a Command against `Ref_` can fail with before it is folded into an
|
|
8
|
+
* `onError` Message: the ref's typed error (if it declares an `error` schema),
|
|
9
|
+
* a transport-level `WebSocketClientError`, or a `SchemaError` from encoding
|
|
10
|
+
* args or decoding returns.
|
|
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
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* `SucceededSaveNote
|
|
14
|
+
* Maps a Confect function's outcome into the app's Messages. Every failure—the
|
|
15
|
+
* ref's typed error, a transport error, or a codec error—arrives via `onError`,
|
|
16
|
+
* so the resulting Command's error channel is `never`, as Foldkit requires.
|
|
17
|
+
* Follow Foldkit's naming convention: past-tense facts like
|
|
18
|
+
* `SucceededSaveNote`/`FailedSaveNote`.
|
|
19
19
|
*/
|
|
20
20
|
export interface Handlers<Ref_ extends Ref.AnyConfect, SuccessMessage, ErrorMessage> {
|
|
21
21
|
readonly onSuccess: (returns: Ref.Returns<Ref_>) => SuccessMessage;
|
|
@@ -31,25 +31,25 @@ type Instance<Name extends string, Ref_ extends Ref.AnyConfect, Message> = Reado
|
|
|
31
31
|
}>;
|
|
32
32
|
type SchemaArgs<Ref_ extends Ref.AnyConfect> = Schema.Schema.Type<Schema.Struct<Ref.ArgsSchema<Ref_>["fields"]>>;
|
|
33
33
|
/**
|
|
34
|
-
* A Foldkit Command definition whose args are the ref's args: our
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
34
|
+
* A Foldkit Command definition whose args are the ref's args: our ref-derived
|
|
35
|
+
* call signature (args optional when the ref declares none) intersected with
|
|
36
|
+
* Foldkit's own `CommandDefinitionWithArgs`, which supplies the
|
|
37
|
+
* `CommandDefinitionTypeId` brand and makes the definition assignable wherever
|
|
38
|
+
* Foldkit accepts one—including Story/Scene `Command.resolve` and `expectExact`
|
|
39
|
+
* matchers. Call it from `update` to construct a Command instance; nothing runs
|
|
40
|
+
* until the Foldkit runtime executes it.
|
|
41
41
|
*/
|
|
42
42
|
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
43
|
/**
|
|
44
|
-
* Makes a factory-built Command interruptible
|
|
44
|
+
* Makes a factory-built Command interruptible—Foldkit's `InterruptOption`
|
|
45
45
|
* applied to the ref's args. `true` keys every invocation by the Command
|
|
46
|
-
* name
|
|
46
|
+
* name—right when at most one invocation is meaningfully in flight; a
|
|
47
47
|
* `KeyedInterrupt` derives the key part from the ref's args, so concurrent
|
|
48
48
|
* invocations can be targeted independently.
|
|
49
49
|
*
|
|
50
50
|
* Interrupting stops the client-side Effect and guarantees the invocation's
|
|
51
|
-
* result Messages never dispatch
|
|
52
|
-
*
|
|
51
|
+
* result Messages never dispatch—it does not cancel the Convex function on the
|
|
52
|
+
* server, which runs to completion once the call is on the wire.
|
|
53
53
|
*/
|
|
54
54
|
export type InterruptOption<Ref_ extends Ref.AnyConfect, KeyField extends keyof SchemaArgs<Ref_> & string = keyof SchemaArgs<Ref_> & string> = FoldkitCommand.InterruptOption<SchemaArgs<Ref_>, KeyField>;
|
|
55
55
|
/**
|
|
@@ -58,17 +58,17 @@ export type InterruptOption<Ref_ extends Ref.AnyConfect, KeyField extends keyof
|
|
|
58
58
|
*/
|
|
59
59
|
export type KeyedInterrupt<Ref_ extends Ref.AnyConfect, KeyField extends keyof SchemaArgs<Ref_> & string> = Exclude<InterruptOption<Ref_, KeyField>, true>;
|
|
60
60
|
/**
|
|
61
|
-
* An interruptible Command definition whose key is the Command name
|
|
61
|
+
* An interruptible Command definition whose key is the Command name—the
|
|
62
62
|
* ref-derived call signature intersected with Foldkit's
|
|
63
|
-
* `Interruptible.DefinitionWithArgsNameKeyed`, which supplies the brand and
|
|
64
|
-
*
|
|
63
|
+
* `Interruptible.DefinitionWithArgsNameKeyed`, which supplies the brand and the
|
|
64
|
+
* `Interrupt` constructor.
|
|
65
65
|
*/
|
|
66
66
|
export type InterruptibleDefinition<Name extends string, Ref_ extends Ref.AnyConfect, Message> = ((...args: Ref.OptionalArgs<Ref_>) => Instance<Name, Ref_, Message> & Readonly<{
|
|
67
67
|
key: string;
|
|
68
68
|
}>) & FoldkitCommand.Interruptible.DefinitionWithArgsNameKeyed<Name, Ref.ArgsSchema<Ref_>["fields"], Effect.Effect<Message, never, Client.Client>>;
|
|
69
69
|
/**
|
|
70
70
|
* An interruptible Command definition whose key is derived from the ref's
|
|
71
|
-
* args
|
|
71
|
+
* args—the ref-derived call signature intersected with Foldkit's
|
|
72
72
|
* `Interruptible.DefinitionWithArgs`, which supplies the brand and the
|
|
73
73
|
* key-args-taking `Interrupt` constructor.
|
|
74
74
|
*/
|
|
@@ -76,18 +76,18 @@ export type KeyedInterruptibleDefinition<Name extends string, Ref_ extends Ref.A
|
|
|
76
76
|
key: string;
|
|
77
77
|
}>) & FoldkitCommand.Interruptible.DefinitionWithArgs<Name, Ref.ArgsSchema<Ref_>["fields"], Pick<SchemaArgs<Ref_>, KeyField>, Effect.Effect<Message, never, Client.Client>>;
|
|
78
78
|
/**
|
|
79
|
-
* An execute body for a hand-written `Command.define
|
|
80
|
-
* folded into a Message. Reach for these when the factory below doesn't fit:
|
|
81
|
-
*
|
|
79
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
80
|
+
* folded into a Message. Reach for these when the factory below doesn't fit: a
|
|
81
|
+
* custom args schema, `interrupt`, or a Command that makes several calls.
|
|
82
82
|
*/
|
|
83
83
|
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
84
|
/**
|
|
85
|
-
* An execute body for a hand-written `Command.define
|
|
85
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
86
86
|
* folded into a Message. See `queryEffect`.
|
|
87
87
|
*/
|
|
88
88
|
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
89
|
/**
|
|
90
|
-
* An execute body for a hand-written `Command.define
|
|
90
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
91
91
|
* folded into a Message. See `queryEffect`.
|
|
92
92
|
*/
|
|
93
93
|
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>;
|
|
@@ -123,22 +123,26 @@ declare const makeFactory: <BoundRef extends Ref.AnyConfect>(effectHelper: <Ref_
|
|
|
123
123
|
* messages: [SucceededGetNote, FailedGetNote],
|
|
124
124
|
* onSuccess: (note) => SucceededGetNote({ note }),
|
|
125
125
|
* onError: (error) => FailedGetNote({ message: String(error) }),
|
|
126
|
-
* })
|
|
126
|
+
* });
|
|
127
127
|
* // In update:
|
|
128
128
|
* // [model, [FetchNote({ noteId })]]
|
|
129
129
|
* ```
|
|
130
130
|
*
|
|
131
131
|
* Pass `interrupt` to make invocations interruptible via the returned
|
|
132
|
-
* definition's `Interrupt` constructor
|
|
133
|
-
*
|
|
132
|
+
* definition's `Interrupt` constructor—`true` keys them by the Command name, `{
|
|
133
|
+
* keyFields, toKey }` by a part derived from the ref's args:
|
|
134
134
|
*
|
|
135
135
|
* ```ts
|
|
136
|
-
* const SaveDraft = Command.mutation(
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* })
|
|
136
|
+
* const SaveDraft = Command.mutation(
|
|
137
|
+
* "SaveDraft",
|
|
138
|
+
* refs.public.notes.insert,
|
|
139
|
+
* {
|
|
140
|
+
* messages: [SucceededSaveDraft, FailedSaveDraft],
|
|
141
|
+
* onSuccess: (noteId) => SucceededSaveDraft({ noteId }),
|
|
142
|
+
* onError: (error) => FailedSaveDraft({ message: String(error) }),
|
|
143
|
+
* interrupt: true,
|
|
144
|
+
* },
|
|
145
|
+
* );
|
|
142
146
|
* // In update:
|
|
143
147
|
* // [model, [SaveDraft.Interrupt((outcome) => CompletedCancelSaveDraft({ outcome }))]]
|
|
144
148
|
* ```
|
|
@@ -150,8 +154,8 @@ export declare const query: ReturnType<typeof makeFactory<Ref.AnyConfectPublicQu
|
|
|
150
154
|
*/
|
|
151
155
|
export declare const mutation: ReturnType<typeof makeFactory<Ref.AnyConfectPublicMutation>>;
|
|
152
156
|
/**
|
|
153
|
-
* A Foldkit Command definition for a Confect action whose Command args are
|
|
154
|
-
*
|
|
157
|
+
* A Foldkit Command definition for a Confect action whose Command args are the
|
|
158
|
+
* ref's args. See `query`.
|
|
155
159
|
*/
|
|
156
160
|
export declare const action: ReturnType<typeof makeFactory<Ref.AnyConfectPublicAction>>;
|
|
157
161
|
export {};
|
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,GACf,MAAM,CAAC,oBAAoB,GAC3B,MAAM,CAAC,WAAW,CAAC;AAEvB;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ,CACvB,IAAI,SAAS,GAAG,CAAC,UAAU,EAC3B,cAAc,EACd,YAAY;IAEZ,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,cAAc,CAAC;IACnE,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,YAAY,CAAC;CACxD;AAED;;GAEG;AACH,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ACf,QAAQ,SAAS,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,EAChD,cAAc,SAAS,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAC3D,YAAY,SAAS,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,QAEnD,IAAI,OACL,IAAI,UACD,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,CAAC,GAC1E,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,GAAG,YAAY,CAAC;CAsCzD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;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
|
|
21
|
-
* folded into a Message. Reach for these when the factory below doesn't fit:
|
|
22
|
-
*
|
|
20
|
+
* An execute body for a hand-written `Command.define`—every failure already
|
|
21
|
+
* folded into a Message. Reach for these when the factory below doesn't fit: a
|
|
22
|
+
* 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));
|
|
@@ -74,22 +74,26 @@ const makeFactory = (effectHelper) => {
|
|
|
74
74
|
* messages: [SucceededGetNote, FailedGetNote],
|
|
75
75
|
* onSuccess: (note) => SucceededGetNote({ note }),
|
|
76
76
|
* onError: (error) => FailedGetNote({ message: String(error) }),
|
|
77
|
-
* })
|
|
77
|
+
* });
|
|
78
78
|
* // In update:
|
|
79
79
|
* // [model, [FetchNote({ noteId })]]
|
|
80
80
|
* ```
|
|
81
81
|
*
|
|
82
82
|
* Pass `interrupt` to make invocations interruptible via the returned
|
|
83
|
-
* definition's `Interrupt` constructor
|
|
84
|
-
*
|
|
83
|
+
* definition's `Interrupt` constructor—`true` keys them by the Command name, `{
|
|
84
|
+
* keyFields, toKey }` by a part derived from the ref's args:
|
|
85
85
|
*
|
|
86
86
|
* ```ts
|
|
87
|
-
* const SaveDraft = Command.mutation(
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* })
|
|
87
|
+
* const SaveDraft = Command.mutation(
|
|
88
|
+
* "SaveDraft",
|
|
89
|
+
* refs.public.notes.insert,
|
|
90
|
+
* {
|
|
91
|
+
* messages: [SucceededSaveDraft, FailedSaveDraft],
|
|
92
|
+
* onSuccess: (noteId) => SucceededSaveDraft({ noteId }),
|
|
93
|
+
* onError: (error) => FailedSaveDraft({ message: String(error) }),
|
|
94
|
+
* interrupt: true,
|
|
95
|
+
* },
|
|
96
|
+
* );
|
|
93
97
|
* // In update:
|
|
94
98
|
* // [model, [SaveDraft.Interrupt((outcome) => CompletedCancelSaveDraft({ outcome }))]]
|
|
95
99
|
* ```
|
|
@@ -101,8 +105,8 @@ const query = makeFactory(queryEffect);
|
|
|
101
105
|
*/
|
|
102
106
|
const mutation = makeFactory(mutationEffect);
|
|
103
107
|
/**
|
|
104
|
-
* A Foldkit Command definition for a Confect action whose Command args are
|
|
105
|
-
*
|
|
108
|
+
* A Foldkit Command definition for a Confect action whose Command args are the
|
|
109
|
+
* ref's args. See `query`.
|
|
106
110
|
*/
|
|
107
111
|
const action = makeFactory(actionEffect);
|
|
108
112
|
//#endregion
|
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 an\n * `onError` Message: the ref's typed error (if it declares an `error` schema),\n * a transport-level `WebSocketClientError`, or a `SchemaError` from encoding\n * 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\n * ref's typed error, a transport error, or a codec error—arrives via `onError`,\n * so the resulting Command's error channel is `never`, as Foldkit requires.\n * 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 ref-derived\n * call signature (args optional when the ref declares none) intersected with\n * Foldkit's own `CommandDefinitionWithArgs`, which supplies the\n * `CommandDefinitionTypeId` brand and makes the definition assignable wherever\n * Foldkit accepts one—including Story/Scene `Command.resolve` and `expectExact`\n * matchers. Call it from `update` to construct a Command instance; nothing runs\n * 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 the\n * 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 the\n * `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: a\n * 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 name, `{\n * keyFields, toKey }` by a part derived from the ref's args:\n *\n * ```ts\n * const SaveDraft = Command.mutation(\n * \"SaveDraft\",\n * refs.public.notes.insert,\n * {\n * messages: [SucceededSaveDraft, FailedSaveDraft],\n * onSuccess: (noteId) => SucceededSaveDraft({ noteId }),\n * onError: (error) => FailedSaveDraft({ message: String(error) }),\n * interrupt: true,\n * },\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 the\n * 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,C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