@gaganref/confect-foldkit 10.3.1-fork.2 → 10.3.1-fork.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Command.d.ts CHANGED
@@ -2,7 +2,7 @@ import type * as Ref from "@confect/core/Ref";
2
2
  import * as Effect from "effect/Effect";
3
3
  import type * as Schema from "effect/Schema";
4
4
  import * as FoldkitCommand from "foldkit/command";
5
- import * as Client from "./Client";
5
+ import * as Client from "./Client.js";
6
6
  /**
7
7
  * Everything a Command against `Ref_` can fail with before it is folded into an
8
8
  * `onError` Message: the ref's typed error (if it declares an `error` schema),
@@ -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,KAAK,QAAQ,CACX,IA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port * 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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AM,KAAK,OAAO,UAAU,aAAa,SAAS,CACnE,GACA,MAAM,UACR;CACF;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,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.js\";\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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,QACX,YAAY,WAAW;;;;;AAMzB,MAAa,WAET,YAAY,cAAc;;;;;AAM9B,MAAa,SAET,YAAY,YAAY"}
@@ -4,7 +4,7 @@ import * as Data from "effect/Data";
4
4
  import * as Option from "effect/Option";
5
5
  import * as Result from "effect/Result";
6
6
  import * as Schema from "effect/Schema";
7
- import * as Client from "./Client";
7
+ import * as Client from "./Client.js";
8
8
  /**
9
9
  * Identifies the cursor range fetched for one page.
10
10
  */
@@ -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;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CA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E,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"}
@@ -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/**\n * Identifies the cursor range fetched for one page.\n */\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/**\n * Options that remain fixed for one pagination session.\n */\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/**\n * Why the machine is fetching its current target.\n */\nexport type Direction =\n | \"Initial\"\n | \"Next\"\n | \"Previous\"\n | \"First\"\n | \"Split\"\n | \"Reset\";\n\n/**\n * A complete page that can remain on screen while another page is fetched.\n */\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/**\n * A closed machine that retains its generation for stale-result rejection.\n */\nexport type Idle = Data.TaggedEnum<{\n Idle: { readonly generation: number };\n}>;\n\n/**\n * A live cursor-pagination session.\n */\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/**\n * A schema-backed cursor-pagination machine.\n */\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/**\n * The logical request from which a subscription allocates a session id.\n */\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/**\n * The complete identity and arguments of a subscribed page request.\n */\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/**\n * The successful payload returned by a Convex paginated query.\n */\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 through\n * 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/**\n * Constructs a declared function or middleware failure envelope.\n */\nexport const FunctionError =\n Data.taggedEnum<FunctionErrorDefinition>().FunctionError;\n\n/**\n * A declared function or middleware failure, kept distinct from client errors.\n */\nexport type FunctionError<Query extends Ref.AnyConfectPublicPaginatedQuery> = [\n Ref.Error<Query>,\n] extends [never]\n ? never\n : TaggedFunctionError<Ref.Error<Query>>;\n\n/**\n * Every failure a paginated query subscription can settle with.\n */\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/**\n * The schema-and-constructor bundle returned by `make`.\n */\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/**\n * Builds a page machine from a paginated ref.\n */\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/**\n * Returns the logical request currently driving the subscription.\n */\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/**\n * Attaches the client-allocated pagination id to a logical request.\n */\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/**\n * Close the subscription while retaining its generation tombstone.\n */\nexport const close = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Idle => State.Idle({ generation: state.generation });\n\n/**\n * Start a fresh pagination session at page one while retaining visible data.\n */\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 exactly\n * that range rather than the first `initialNumItems` documents after its\n * cursor, however the data has moved meanwhile. Convex's own pagination keeps\n * that range in its query journal; stream-paginated queries have no journal, so\n * the pin is what keeps consecutive pages gap-free and duplicate-free for\n * 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/**\n * Navigate to the previous page, retaining the current page while it loads.\n */\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/**\n * Navigate to page one without invalidating the current pagination session.\n */\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/**\n * Whether a request still names the machine's live pagination session/page.\n */\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/**\n * The complete page currently available to render.\n */\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/**\n * The items currently available to render.\n */\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/**\n * The error from the most recent failed request, if any.\n */\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/**\n * The 1-indexed page number currently targeted by the subscription.\n */\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/**\n * Pattern-match exhaustively on the machine's AsyncData-style state.\n */\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,iBAAiB,OAAO,OAAO;CAC1C,QAAQ,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,IAAI,CAAC;CACjD,WAAW,OAAO,OAAO,OAAO,MAAM;AACxC,CAAC;AAWD,MAAM,cAAc,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAA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F,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.js\";\n\n/**\n * Identifies the cursor range fetched for one page.\n */\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/**\n * Options that remain fixed for one pagination session.\n */\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/**\n * Why the machine is fetching its current target.\n */\nexport type Direction =\n | \"Initial\"\n | \"Next\"\n | \"Previous\"\n | \"First\"\n | \"Split\"\n | \"Reset\";\n\n/**\n * A complete page that can remain on screen while another page is fetched.\n */\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/**\n * A closed machine that retains its generation for stale-result rejection.\n */\nexport type Idle = Data.TaggedEnum<{\n Idle: { readonly generation: number };\n}>;\n\n/**\n * A live cursor-pagination session.\n */\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/**\n * A schema-backed cursor-pagination machine.\n */\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/**\n * The logical request from which a subscription allocates a session id.\n */\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/**\n * The complete identity and arguments of a subscribed page request.\n */\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/**\n * The successful payload returned by a Convex paginated query.\n */\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 through\n * 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/**\n * Constructs a declared function or middleware failure envelope.\n */\nexport const FunctionError =\n Data.taggedEnum<FunctionErrorDefinition>().FunctionError;\n\n/**\n * A declared function or middleware failure, kept distinct from client errors.\n */\nexport type FunctionError<Query extends Ref.AnyConfectPublicPaginatedQuery> = [\n Ref.Error<Query>,\n] extends [never]\n ? never\n : TaggedFunctionError<Ref.Error<Query>>;\n\n/**\n * Every failure a paginated query subscription can settle with.\n */\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/**\n * The schema-and-constructor bundle returned by `make`.\n */\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/**\n * Builds a page machine from a paginated ref.\n */\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/**\n * Returns the logical request currently driving the subscription.\n */\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/**\n * Attaches the client-allocated pagination id to a logical request.\n */\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/**\n * Close the subscription while retaining its generation tombstone.\n */\nexport const close = <Item_, UserArgs_, Error_>(\n state: Active<Item_, UserArgs_, Error_>,\n): Idle => State.Idle({ generation: state.generation });\n\n/**\n * Start a fresh pagination session at page one while retaining visible data.\n */\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 exactly\n * that range rather than the first `initialNumItems` documents after its\n * cursor, however the data has moved meanwhile. Convex's own pagination keeps\n * that range in its query journal; stream-paginated queries have no journal, so\n * the pin is what keeps consecutive pages gap-free and duplicate-free for\n * 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/**\n * Navigate to the previous page, retaining the current page while it loads.\n */\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/**\n * Navigate to page one without invalidating the current pagination session.\n */\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/**\n * Whether a request still names the machine's live pagination session/page.\n */\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/**\n * The complete page currently available to render.\n */\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/**\n * The items currently available to render.\n */\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/**\n * The error from the most recent failed request, if any.\n */\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/**\n * The 1-indexed page number currently targeted by the subscription.\n */\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/**\n * Pattern-match exhaustively on the machine's AsyncData-style state.\n */\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,iBAAiB,OAAO,OAAO;CAC1C,QAAQ,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,IAAI,CAAC;CACjD,WAAW,OAAO,OAAO,OAAO,MAAM;AACxC,CAAC;AAWD,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,WAAW;AAClD,CAAC;AAuDD,MAAM,QAAQ,KAAK,WAA4B;AAoC/C,MAAM,QAAQ,KAAK,WAA4B;;;;AAiE/C,MAAa,gBACX,KAAK,WAAoC,CAAC,CAAC;AAsE7C,MAAM,yBAAyC;CAC7C,QAAQ;CACR,WAAW,OAAO,KAAK;AACzB;AAEA,MAAM,gBAAgB,OAAO,kBAAkB,OAAO;AAEtD,MAAM,gBACJ,YACA,MACA,YAEA,MAAM,OAAiC;CACrC;CACA;CACA,SAAS,cAAc,OAAO;CAC9B,cAAc,OAAO,KAAK;CAC1B,WAAW;CACX,SAAS,gBAAgB;CACzB,WAAW,CAAC;CACZ,OAAO,MAAM,QAAuB,EAAE,WAAW,UAAU,CAAC;AAC9D,CAAC;AAEH,MAAM,mCAAmC,QACvC,IAAI,WAAW,MACb,wBAAwB,IAAI,sBAAsB,GAAG,EAAE,qJAGzD;AAE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,IAAI,iBAAiB,UAAU,SAAS,CAAC,GAC/C,MAAM,IAAI,WAAW,cAAc,WAAW,eAAe,KAAK,GAClE,MAAM,UACR,CACF,GACA,MAAM,UACR;;;;AAKF,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"}
@@ -4,8 +4,8 @@ import * as Option from "effect/Option";
4
4
  import * as Schema from "effect/Schema";
5
5
  import * as Stream from "effect/Stream";
6
6
  import type * as FoldkitSubscription from "foldkit/subscription";
7
- import * as PaginatedQuery from "./PaginatedQuery";
8
- import * as Client from "./Client";
7
+ import * as PaginatedQuery from "./PaginatedQuery.js";
8
+ import * as Client from "./Client.js";
9
9
  /**
10
10
  * Everything a reactive query subscription against `Query` can fail with: the
11
11
  * ref's typed error (if it declares an `error` schema), a transport-level
@@ -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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,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IACtE,QAAQ,CAAC,oBAAoB,EAAE,CAC7B,YAAY,EAAE,aAAa,EAC3B,gBAAgB,EAAE,MAAM,aAAa,KAClC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;CAC9C,CAAC;AAEF,eAAO,MAAM,cAAc,GACxB,KAAK,QAEJ,iBAAiB,SAAS,GAAG,CAAC,8BAA8B,EAC5D,cAAc,WAEL,cAAc,CAAC,cAAc,CAAC,iBAAiB,CAAC,UACjD;IACN,QAAQ,CAAC,KAAK,EAAE,CACd,KAAK,EAAE,KAAK,KACT,cAAc,CAAC,KAAK,CACvB,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,EACtC,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAC1C,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,CACxC,CAAC;IACF,QAAQ,CAAC,SAAS,EAAE,CAClB,UAAU,EAAE,cAAc,CAAC,UAAU,CACnC,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,EACtC,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAC1C,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,CACxC,KACE,cAAc,CAAC;CACrB,KACA,kBAAkB,CACnB,KAAK,EACL,cAAc,EACd;IACE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAC7B,cAAc,CAAC,mBAAmB,CAChC,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAC3C,CACF,CAAC;CACH,EACD,MAAM,CAAC,MAAM,CAwFd,CAAC"}
@@ -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 server\n * 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\n * ref's typed error, a transport error, or a codec error—arrives via `onError`,\n * so the resulting stream's error channel is `never`, as Foldkit 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 the\n * ref as a reactive query against the `Client` resource and maps every emission\n * and every failure into a Message. Query failures are values, so the\n * subscription remains live and can later emit a successful result.\n *\n * Prefer `reactiveQuery`, which builds the whole entry; reach for this when you\n * 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 type\n * arguments), so the `args` extractor's parameter is already typed. Pass the\n * 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>()(\n * refs.public.notes.get,\n * {\n * args: (model) =>\n * Option.map(model.noteId, (noteId) => ({ noteId })),\n * onSuccess: (note) => SucceededGetNote({ note }),\n * onError: (error) => FailedGetNote({ message: String(error) }),\n * },\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 and\n * 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. The\n * machine state is the single source of truth: navigation and split-pinning\n * change the derived args, while `Idle` closes the subscription. Pagination ids\n * are allocated here and installed by the first settlement.\n *\n * The leading thunk fixes the `Model` type (TypeScript cannot partially infer\n * type arguments), so the `state` extractor's parameter is already 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 do\n * 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,W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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.js\";\nimport * as Client from \"./Client.js\";\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 server\n * 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\n * ref's typed error, a transport error, or a codec error—arrives via `onError`,\n * so the resulting stream's error channel is `never`, as Foldkit 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 the\n * ref as a reactive query against the `Client` resource and maps every emission\n * and every failure into a Message. Query failures are values, so the\n * subscription remains live and can later emit a successful result.\n *\n * Prefer `reactiveQuery`, which builds the whole entry; reach for this when you\n * 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 type\n * arguments), so the `args` extractor's parameter is already typed. Pass the\n * 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>()(\n * refs.public.notes.get,\n * {\n * args: (model) =>\n * Option.map(model.noteId, (noteId) => ({ noteId })),\n * onSuccess: (note) => SucceededGetNote({ note }),\n * onError: (error) => FailedGetNote({ message: String(error) }),\n * },\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 and\n * 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. The\n * machine state is the single source of truth: navigation and split-pinning\n * change the derived args, while `Idle` closes the subscription. Pagination ids\n * are allocated here and installed by the first settlement.\n *\n * The leading thunk fixes the `Model` type (TypeScript cannot partially infer\n * type arguments), so the `state` extractor's parameter is already 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 do\n * 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCJ,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,KAAK,MAAM,CAAC,CAAC,QAAQ;EACjE,CAAC;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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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * as Client from "./Client";
2
- export * as Command from "./Command";
3
- export * as PaginatedQuery from "./PaginatedQuery";
4
- export * as Subscription from "./Subscription";
1
+ export * as Client from "./Client.js";
2
+ export * as Command from "./Command.js";
3
+ export * as PaginatedQuery from "./PaginatedQuery.js";
4
+ export * as Subscription from "./Subscription.js";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@gaganref/confect-foldkit",
3
- "version": "10.3.1-fork.2",
3
+ "version": "10.3.1-fork.21",
4
4
  "peerDependencies": {
5
- "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.2",
6
- "@confect/js": "npm:@gaganref/confect-js@10.3.1-fork.2",
5
+ "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.21",
6
+ "@confect/js": "npm:@gaganref/confect-js@10.3.1-fork.21",
7
7
  "effect": "^4.0.0",
8
8
  "foldkit": "^0.165.0"
9
9
  },
package/src/Command.ts CHANGED
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
3
3
  import * as Match from "effect/Match";
4
4
  import type * as Schema from "effect/Schema";
5
5
  import * as FoldkitCommand from "foldkit/command";
6
- import * as Client from "./Client";
6
+ import * as Client from "./Client.js";
7
7
 
8
8
  /**
9
9
  * Everything a Command against `Ref_` can fail with before it is folded into an
@@ -9,7 +9,7 @@ import * as Result from "effect/Result";
9
9
  import * as Schema from "effect/Schema";
10
10
  import * as SchemaGetter from "effect/SchemaGetter";
11
11
  import * as SchemaIssue from "effect/SchemaIssue";
12
- import * as Client from "./Client";
12
+ import * as Client from "./Client.js";
13
13
 
14
14
  /**
15
15
  * Identifies the cursor range fetched for one page.
@@ -8,8 +8,8 @@ import * as Result from "effect/Result";
8
8
  import * as Schema from "effect/Schema";
9
9
  import * as Stream from "effect/Stream";
10
10
  import type * as FoldkitSubscription from "foldkit/subscription";
11
- import * as PaginatedQuery from "./PaginatedQuery";
12
- import * as Client from "./Client";
11
+ import * as PaginatedQuery from "./PaginatedQuery.js";
12
+ import * as Client from "./Client.js";
13
13
 
14
14
  /**
15
15
  * Everything a reactive query subscription against `Query` can fail with: the
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * as Client from "./Client";
2
- export * as Command from "./Command";
3
- export * as PaginatedQuery from "./PaginatedQuery";
4
- export * as Subscription from "./Subscription";
1
+ export * as Client from "./Client.js";
2
+ export * as Command from "./Command.js";
3
+ export * as PaginatedQuery from "./PaginatedQuery.js";
4
+ export * as Subscription from "./Subscription.js";