@gjermundgaraba/effect-actions 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Action.d.mts +6 -6
- package/dist/Action.mjs +11 -11
- package/dist/ActionCli.d.mts +23 -23
- package/dist/ActionCli.mjs +4 -4
- package/dist/ActionHttp.d.mts +16 -16
- package/dist/ActionHttp.mjs +7 -7
- package/dist/ActionMcp.d.mts +8 -8
- package/dist/ActionMcp.mjs +8 -8
- package/dist/ActionRpc.d.mts +22 -22
- package/dist/ActionRpc.mjs +8 -8
- package/dist/ActionToolkit.d.mts +1 -1
- package/dist/ActionToolkit.mjs +3 -3
- package/dist/Authentication.d.mts +2 -2
- package/dist/Authentication.mjs +1 -1
- package/dist/Event.d.mts +4 -4
- package/dist/Event.mjs +3 -3
- package/dist/Webhook.d.mts +2 -0
- package/dist/Webhook.mjs +1 -0
- package/dist/authentication/provider.d.mts +15 -15
- package/dist/authentication/refusal.mjs +1 -1
- package/dist/cli/commands.d.mts +2 -2
- package/dist/cli/commands.mjs +5 -5
- package/dist/contract/authorizer.d.mts +1 -1
- package/dist/contract/call.d.mts +2 -2
- package/dist/contract/caller.d.mts +1 -1
- package/dist/contract/declared.d.mts +1 -1
- package/dist/contract/declared.mjs +1 -1
- package/dist/contract/feed.d.mts +1 -1
- package/dist/contract/feed.mjs +6 -6
- package/dist/contract/hub.d.mts +1 -1
- package/dist/contract/idempotency.d.mts +1 -1
- package/dist/contract/idempotency.mjs +4 -4
- package/dist/contract/implementation.d.mts +27 -27
- package/dist/contract/implementation.mjs +1 -1
- package/dist/contract/input-check.d.mts +3 -3
- package/dist/contract/listed.d.mts +1 -1
- package/dist/contract/listed.mjs +1 -1
- package/dist/contract/pages.d.mts +1 -1
- package/dist/contract/push.d.mts +2 -2
- package/dist/contract/push.mjs +2 -2
- package/dist/contract/receiving.d.mts +2 -2
- package/dist/contract/receiving.mjs +1 -1
- package/dist/contract/serving.mjs +2 -2
- package/dist/contract/subscribe.mjs +1 -1
- package/dist/contract/transient.mjs +1 -1
- package/dist/contract/watch.d.mts +1 -1
- package/dist/contract/watch.mjs +2 -2
- package/dist/contract/webhooks.d.mts +1 -1
- package/dist/http/client.d.mts +9 -9
- package/dist/http/client.mjs +1 -1
- package/dist/http/events.d.mts +6 -6
- package/dist/http/events.mjs +4 -4
- package/dist/http/placed.d.mts +3 -3
- package/dist/http/placed.mjs +5 -5
- package/dist/http/streamed.d.mts +2 -2
- package/dist/http/streamed.mjs +1 -1
- package/dist/http/watch.mjs +1 -1
- package/dist/mcp/bridge.mjs +8 -8
- package/dist/mcp/client.d.mts +10 -10
- package/dist/mcp/client.mjs +4 -4
- package/dist/mcp/protocol.mjs +16 -4
- package/dist/mcp/reply.d.mts +1 -1
- package/dist/mcp/watch.mjs +4 -4
- package/dist/webhook/stored.mjs +1 -1
- package/dist/webhook/subscriptions.mjs +8 -5
- package/docs/setup.md +1 -1
- package/package.json +11 -12
package/dist/Action.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Authorizer, Deferred as Deferred$1 } from "./contract/authorizer.mjs";
|
|
2
|
+
import { Call } from "./contract/call.mjs";
|
|
2
3
|
import { Anyone } from "./contract/caller.mjs";
|
|
4
|
+
import { Codec, CodecOf, Fields, NoInput } from "./contract/codec.mjs";
|
|
3
5
|
import { BuiltIn, Forbidden, InvalidInput, Issue, Refusal, Unauthenticated } from "./contract/errors.mjs";
|
|
4
|
-
import { EventBuildError, EventBuildServices, EventOf, EventRequestOf, HoldingEvents, ServingEvents } from "./contract/feed.mjs";
|
|
5
6
|
import { Any as Any$1, Received, SubscriptionError } from "./Event.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import { ActionOf, AnyImplementation, Authorize, BuildError, BuildServices, Holding, Implementation, Known, Member, Offered, OptionalUnless, Protected, RequestOf, SelectedEventsOf, SelectedOf, Served, Serving } from "./contract/implementation.mjs";
|
|
8
|
-
import { Authorizer, Deferred as Deferred$1 } from "./contract/authorizer.mjs";
|
|
9
|
-
import { Call } from "./contract/call.mjs";
|
|
7
|
+
import { EventBuildError, EventBuildServices, EventOf, EventRequestOf, HoldingEvents, ServingEvents } from "./contract/feed.mjs";
|
|
10
8
|
import { Idempotency, layerIdempotency } from "./contract/idempotency.mjs";
|
|
9
|
+
import { ActionOf, AnyImplementation, Authorize, BuildError, BuildServices, Holding, Implementation, Known, Member, Offered, OptionalUnless, Protected, RequestOf, SelectedEventsOf, SelectedOf, Served, Serving } from "./contract/implementation.mjs";
|
|
10
|
+
import { ReportingOf } from "./contract/progress.mjs";
|
|
11
11
|
import { Answer, Stream, StreamOf } from "./contract/stream.mjs";
|
|
12
12
|
import { WatchArgs } from "./contract/watch.mjs";
|
|
13
13
|
import { Image } from "./contract/media.mjs";
|
package/dist/Action.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
+
import { authorizerOf } from "./contract/authorizer.mjs";
|
|
2
|
+
import { inputOf, jsonRoundTrip, onProgressOf, watchInput } from "./contract/call.mjs";
|
|
1
3
|
import { Anyone, assertCaller } from "./contract/caller.mjs";
|
|
2
|
-
import {
|
|
4
|
+
import { codecOf } from "./contract/codec.mjs";
|
|
3
5
|
import { assertDistinctTags, errorList, projectedErrors } from "./contract/declared.mjs";
|
|
4
|
-
import {
|
|
6
|
+
import { BuiltIn, Forbidden, InvalidInput, Refusal, Unauthenticated } from "./contract/errors.mjs";
|
|
7
|
+
import { NotServed, SubscriptionError } from "./Event.mjs";
|
|
8
|
+
import { acquireFeeds, eventsOf, feedBuilders } from "./contract/feed.mjs";
|
|
9
|
+
import { Idempotency, keyed, layerIdempotency } from "./contract/idempotency.mjs";
|
|
10
|
+
import { Implementation, acquire, builtWith, elementsOf, memoized, provideBuilders, toList, uniqueKey } from "./contract/implementation.mjs";
|
|
5
11
|
import { assertKnown, assertName, assertOnce, heldOnce } from "./contract/names.mjs";
|
|
6
12
|
import { progressSink } from "./contract/progress.mjs";
|
|
7
|
-
import { codecOf } from "./contract/codec.mjs";
|
|
8
|
-
import { Stream, elementOf } from "./contract/stream.mjs";
|
|
9
|
-
import { Implementation, acquire, builtWith, elementsOf, memoized, provideBuilders, toList, uniqueKey } from "./contract/implementation.mjs";
|
|
10
|
-
import { authorizerOf } from "./contract/authorizer.mjs";
|
|
11
|
-
import { inputOf, jsonRoundTrip, onProgressOf, watchInput } from "./contract/call.mjs";
|
|
12
|
-
import { acquireFeeds, eventsOf, feedBuilders } from "./contract/feed.mjs";
|
|
13
|
-
import { NotServed, SubscriptionError } from "./Event.mjs";
|
|
14
13
|
import { polledOn, queuedPush, readOn } from "./contract/push.mjs";
|
|
15
|
-
import { Image } from "./contract/media.mjs";
|
|
16
14
|
import { selectFrom } from "./contract/serving.mjs";
|
|
15
|
+
import { Stream, elementOf } from "./contract/stream.mjs";
|
|
17
16
|
import { watching } from "./contract/watch.mjs";
|
|
18
|
-
import {
|
|
17
|
+
import { Image } from "./contract/media.mjs";
|
|
18
|
+
import { InputCheck } from "./contract/input-check.mjs";
|
|
19
19
|
import { Array as Array$1, Cause, Effect, Function, Layer, Predicate, Schema, Stream as Stream$1 } from "effect";
|
|
20
20
|
// src/contract/Action.ts
|
|
21
21
|
function make(name, options) {
|
package/dist/ActionCli.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BuiltIn } from "./contract/errors.mjs";
|
|
2
|
+
import { Any } from "./Action.mjs";
|
|
3
|
+
import { Declaring } from "./contract/declared.mjs";
|
|
4
|
+
import { Any as Any$1, SubscriptionError } from "./Event.mjs";
|
|
2
5
|
import { EventBuildError, EventBuildServices, EventOf, EventRequestOf, ServingEvents } from "./contract/feed.mjs";
|
|
3
|
-
import { Any, SubscriptionError } from "./Event.mjs";
|
|
4
6
|
import { ActionOf, BuildError, BuildServices, Holding, Known, Member, RequestOf, Selected, SelectedEvents, SelectedEventsOf, SelectedOf, Selection, Served, ServedActions } from "./contract/implementation.mjs";
|
|
5
7
|
import { Receiving } from "./contract/receiving.mjs";
|
|
6
8
|
import { WatchArgs } from "./contract/watch.mjs";
|
|
7
|
-
import { Any as Any$1 } from "./Action.mjs";
|
|
8
|
-
import { Declaring } from "./contract/declared.mjs";
|
|
9
9
|
import { AnyHttp, Client, WatchError } from "./http/client.mjs";
|
|
10
10
|
import "./ActionHttp.mjs";
|
|
11
11
|
import { Options, UserError } from "./cli/commands.mjs";
|
|
@@ -13,7 +13,7 @@ import { Effect, Stream } from "effect";
|
|
|
13
13
|
import { HttpClient } from "effect/http";
|
|
14
14
|
import { CliError, Command } from "effect/cli";
|
|
15
15
|
interface AnyBinding extends Declaring {
|
|
16
|
-
readonly actions: readonly Any
|
|
16
|
+
readonly actions: readonly Any[];
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Make a command of your own fail as a derived command does. Give it what the command calls, the
|
|
@@ -29,12 +29,12 @@ interface AnyBinding extends Declaring {
|
|
|
29
29
|
* - A failure left unmapped, one call's included, is reported as a crash, `ERROR (#n)` with a stack trace: pipe the whole Effect through it, once.
|
|
30
30
|
* - To add context, such as how far a batch got, print it before this in the pipe, `Effect.tapError(() => Console.error(…))`: a `UserError` wrapped around the result puts its JSON mid-sentence and hides the action's failure from `catchReason`.
|
|
31
31
|
*/
|
|
32
|
-
export declare const toUserError: (calls: AnyBinding | readonly Any
|
|
32
|
+
export declare const toUserError: (calls: AnyBinding | readonly Any[]) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, UserError<Exclude<E, CliError.CliError>> | Exclude<E, Exclude<E, CliError.CliError>>, R>;
|
|
33
33
|
/**
|
|
34
34
|
* An aggregate command of the actions `A`: its name, the actions that are its subcommands,
|
|
35
35
|
* and their options.
|
|
36
36
|
*/
|
|
37
|
-
interface Options$1<A extends Any
|
|
37
|
+
interface Options$1<A extends Any | Any$1 = Any | Any$1> {
|
|
38
38
|
/** The aggregate command's name. */
|
|
39
39
|
readonly name: string;
|
|
40
40
|
/**
|
|
@@ -51,7 +51,7 @@ interface Options$1<A extends Any$1 | Any = Any$1 | Any> {
|
|
|
51
51
|
* The options of each subcommand, keyed by its action's name, as `command` takes them:
|
|
52
52
|
* `{ readFile: { positional: ["path"], render } }`.
|
|
53
53
|
*/
|
|
54
|
-
readonly commands?: { readonly [K in Extract<A, Any
|
|
54
|
+
readonly commands?: { readonly [K in Extract<A, Any> as K["name"]]?: Options<K>; };
|
|
55
55
|
/**
|
|
56
56
|
* Commands of your own beside the derived ones, as `Command.withSubcommands` takes them:
|
|
57
57
|
* `[importLinks]`, each made with Effect CLI's `Command.make` and printing its output itself,
|
|
@@ -72,14 +72,14 @@ type OwnCommand<Own extends Subcommands> = Subcommands extends Own ? never : Own
|
|
|
72
72
|
type CommandsOf<O> = O extends unknown ? "commands" extends keyof O ? NonNullable<O["commands" & keyof O]> : never : never;
|
|
73
73
|
type KeysOf<C> = C extends unknown ? keyof C : never;
|
|
74
74
|
type CommandOf<C, K> = C extends unknown ? K extends keyof C ? C[K] : never : never;
|
|
75
|
-
type KnownOptions<O, Keys, A extends Any
|
|
76
|
-
readonly commands?: Known<CommandsOf<O>, { readonly [K in A["name"]]: Options<A>; }> & { readonly [K in KeysOf<CommandsOf<O>>]?: Known<CommandOf<CommandsOf<O>, K>, Options<Any
|
|
75
|
+
type KnownOptions<O, Keys, A extends Any> = Known<O, Keys> & ([CommandsOf<O>] extends [never] ? unknown : {
|
|
76
|
+
readonly commands?: Known<CommandsOf<O>, { readonly [K in A["name"]]: Options<A>; }> & { readonly [K in KeysOf<CommandsOf<O>>]?: Known<CommandOf<CommandsOf<O>, K>, Options<Any>>; };
|
|
77
77
|
});
|
|
78
|
-
type Owning<App, A extends Any
|
|
79
|
-
type Local<App, A extends Any
|
|
78
|
+
type Owning<App, A extends Any> = App extends unknown ? A extends ActionOf<App> ? App : never : never;
|
|
79
|
+
type Local<App, A extends Any> = Effect.Effect<A["success"]["Type"], A["error"][number]["Type"] | BuildError<App, A> | BuiltIn, RequestOf<App, A> | BuildServices<App, A>>;
|
|
80
80
|
type LocalCall<Apps extends Served, O> = [SelectedOf<O, Apps>] extends [never] ? never : Local<Holding<Member<Apps>, SelectedOf<O, Apps>>, SelectedOf<O, Apps>>;
|
|
81
|
-
type LocalWatch<App, Listed extends Any> = [ServingEvents<App, Listed>] extends [never] ? never : Effect.Effect<void, SubscriptionError | BuiltIn | EventBuildError<App, Listed>, EventRequestOf<App, ServingEvents<App, Listed>> | EventBuildServices<App, Listed>>;
|
|
82
|
-
type Watched<M, E extends Any> = M extends {
|
|
81
|
+
type LocalWatch<App, Listed extends Any$1> = [ServingEvents<App, Listed>] extends [never] ? never : Effect.Effect<void, SubscriptionError | BuiltIn | EventBuildError<App, Listed>, EventRequestOf<App, ServingEvents<App, Listed>> | EventBuildServices<App, Listed>>;
|
|
82
|
+
type Watched<M, E extends Any$1> = M extends {
|
|
83
83
|
readonly watch: (event: E, ...args: WatchArgs<E, never>) => Stream.Stream<unknown, infer WE, infer WR>;
|
|
84
84
|
} ? {
|
|
85
85
|
readonly error: WE;
|
|
@@ -88,8 +88,8 @@ type Watched<M, E extends Any> = M extends {
|
|
|
88
88
|
readonly error: never;
|
|
89
89
|
readonly services: never;
|
|
90
90
|
};
|
|
91
|
-
type WatchFailure<H extends AnyHttp, C, E extends Any> = [E] extends [never] ? never : C extends Effect.Effect<infer M, infer CE, unknown> ? CE | Watched<M, E>["error"] : WatchError<E, H>;
|
|
92
|
-
type WatchServices<C, E extends Any> = [E] extends [never] ? never : C extends Effect.Effect<infer M, unknown, infer CR> ? CR | Watched<M, E>["services"] : HttpClient.HttpClient;
|
|
91
|
+
type WatchFailure<H extends AnyHttp, C, E extends Any$1> = [E] extends [never] ? never : C extends Effect.Effect<infer M, infer CE, unknown> ? CE | Watched<M, E>["error"] : WatchError<E, H>;
|
|
92
|
+
type WatchServices<C, E extends Any$1> = [E] extends [never] ? never : C extends Effect.Effect<infer M, unknown, infer CR> ? CR | Watched<M, E>["services"] : HttpClient.HttpClient;
|
|
93
93
|
/**
|
|
94
94
|
* Project one implemented action into a native Effect CLI command that runs its handler in
|
|
95
95
|
* process, behind its implementation's authorization. It is named after the action in kebab
|
|
@@ -110,14 +110,14 @@ type WatchServices<C, E extends Any> = [E] extends [never] ? never : C extends E
|
|
|
110
110
|
* - Each run builds the action's implementation, its builder and an authorizer an Effect builds, and releases them after the call, even where the host already built them; implementations passed beside it are not built.
|
|
111
111
|
* - A field named like a global flag (`help`, `version`, `log-level`) is no clash: its flag shadows the global one on this command.
|
|
112
112
|
*/
|
|
113
|
-
export declare const command: <const Apps extends ServedActions, A extends ActionOf<Member<Apps>>, const O = {}>(implementations: Apps, action: A, options?: O & NoInfer<Options<A>> & NoInfer<Known<O, Options<Any
|
|
113
|
+
export declare const command: <const Apps extends ServedActions, A extends ActionOf<Member<Apps>>, const O = {}>(implementations: Apps, action: A, options?: O & NoInfer<Options<A>> & NoInfer<Known<O, Options<Any>>>) => Command.Command<string, never, {}, Failing<Effect.Error<Local<Owning<Member<Apps>, A>, A>>>, Effect.Services<Local<Owning<Member<Apps>, A>, A>>>;
|
|
114
114
|
/**
|
|
115
115
|
* Project one action of an HTTP binding into a native Effect CLI command, derived as `command`
|
|
116
116
|
* derives it, that calls the action through `client`'s method and fails as the method does, or
|
|
117
117
|
* as the Effect building the client does. It runs nothing locally and names no caller: the
|
|
118
118
|
* server verifies the credentials its client sends.
|
|
119
119
|
*/
|
|
120
|
-
export declare function remoteCommand<const H extends AnyHttp, A extends H["actions"][number], const O = {}, C extends ClientOf<H, A> | undefined = undefined>(binding: H, action: A, options?: O & NoInfer<Options<A>> & NoInfer<Known<O, RemoteKeys<Options<Any
|
|
120
|
+
export declare function remoteCommand<const H extends AnyHttp, A extends H["actions"][number], const O = {}, C extends ClientOf<H, A> | undefined = undefined>(binding: H, action: A, options?: O & NoInfer<Options<A>> & NoInfer<Known<O, RemoteKeys<Options<Any>>>> & Calling<C>): Command.Command<string, never, {}, Failing<CallFailure<H, C, A>>, CallServices<C, A>>;
|
|
121
121
|
/** The `client` option of `remote` and `remoteCommand`, declared once for both. */
|
|
122
122
|
export interface Calling<C> {
|
|
123
123
|
/**
|
|
@@ -137,18 +137,18 @@ export interface Calling<C> {
|
|
|
137
137
|
*/
|
|
138
138
|
readonly client?: C;
|
|
139
139
|
}
|
|
140
|
-
type ClientOf<H extends AnyHttp, A extends Any
|
|
141
|
-
type Needed<O, L extends readonly unknown[], All extends Any
|
|
142
|
-
type NeededEvents<O, L extends readonly unknown[], All extends Any> = "actions" extends (O extends unknown ? keyof O : never) ? SelectedEvents<O, All> : Extract<L[number], All>;
|
|
140
|
+
type ClientOf<H extends AnyHttp, A extends Any, E extends Any$1 = never> = Effect.Effect<Pick<Client<H, unknown, unknown>, A["name"] | ([E] extends [never] ? never : "watch")>, unknown, unknown>;
|
|
141
|
+
type Needed<O, L extends readonly unknown[], All extends Any> = "actions" extends (O extends unknown ? keyof O : never) ? Selected<O, All> : Extract<L[number], All>;
|
|
142
|
+
type NeededEvents<O, L extends readonly unknown[], All extends Any$1> = "actions" extends (O extends unknown ? keyof O : never) ? SelectedEvents<O, All> : Extract<L[number], All>;
|
|
143
143
|
type RemoteKeys<Keys> = Keys & {
|
|
144
144
|
readonly client?: unknown;
|
|
145
145
|
};
|
|
146
146
|
type Failing<F> = [F] extends [never] ? never : UserError<Exclude<F, CliError.CliError>> | Extract<F, CliError.CliError>;
|
|
147
|
-
type Called<M, A extends Any
|
|
147
|
+
type Called<M, A extends Any> = A extends unknown ? A["name"] extends keyof M ? M[A["name"]] extends ((...input: never) => infer Call) ? Call : never : never : never;
|
|
148
148
|
type CallError<Call> = Effect.Error<Call> | Stream.Error<Call>;
|
|
149
149
|
type CallRequirements<Call> = Effect.Services<Call> | Stream.Services<Call>;
|
|
150
|
-
type CallFailure<H extends AnyHttp, C, A extends Any
|
|
151
|
-
type CallServices<C, A extends Any
|
|
150
|
+
type CallFailure<H extends AnyHttp, C, A extends Any> = C extends Effect.Effect<infer M, infer CE, unknown> ? CE | CallError<Called<M, A>> : CallError<Called<Client<H>, A>>;
|
|
151
|
+
type CallServices<C, A extends Any> = C extends Effect.Effect<infer M, unknown, infer CR> ? CR | CallRequirements<Called<M, A>> : HttpClient.HttpClient;
|
|
152
152
|
/**
|
|
153
153
|
* Project the implemented actions, every one or those `actions` selects, as subcommands of one
|
|
154
154
|
* aggregate command, each derived as `command` derives it and run in process. `commands` gives a
|
package/dist/ActionCli.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { client } from "./Action.mjs";
|
|
1
2
|
import { bindingErrors, eventErrors, projectedErrors } from "./contract/declared.mjs";
|
|
2
|
-
import { assertDistinct, assertKnown } from "./contract/names.mjs";
|
|
3
|
-
import { progressSink } from "./contract/progress.mjs";
|
|
4
|
-
import { elementOf } from "./contract/stream.mjs";
|
|
5
3
|
import { Implementation, acquire, assertHeld, elementsOf, notHeld, toList } from "./contract/implementation.mjs";
|
|
6
4
|
import { selection } from "./contract/listed.mjs";
|
|
5
|
+
import { assertDistinct, assertKnown } from "./contract/names.mjs";
|
|
6
|
+
import { progressSink } from "./contract/progress.mjs";
|
|
7
7
|
import { selectFrom } from "./contract/serving.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { elementOf } from "./contract/stream.mjs";
|
|
9
9
|
import { client as client$1 } from "./ActionHttp.mjs";
|
|
10
10
|
import { command as command$1, failingAsDerived, watchCommand } from "./cli/commands.mjs";
|
|
11
11
|
import { Cause, Effect, Logger, Runtime, Stream } from "effect";
|
package/dist/ActionHttp.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { Any, DescriptorOf, LayerIdentity, Matching, PublicOnly, RemoteRequest, Required, ServedProvider, ServerBuildServices, VerifierError } from "./authentication/provider.mjs";
|
|
2
|
+
import { Any as Any$1, Errors } from "./Action.mjs";
|
|
1
3
|
import { Anyone } from "./contract/caller.mjs";
|
|
4
|
+
import { Certain, ErrorsOf } from "./contract/declared.mjs";
|
|
2
5
|
import { BuiltIn, BuiltIns } from "./contract/errors.mjs";
|
|
6
|
+
import { Any as Any$2 } from "./Event.mjs";
|
|
3
7
|
import { EventBuildError, EventBuildServices, EventServedRequest, HoldingEvents, ServingEvents } from "./contract/feed.mjs";
|
|
4
|
-
import { Any } from "./Event.mjs";
|
|
5
8
|
import { BuildError, Holding, Known, Member, MiddlewareOf, Selected, SelectedEvents, Served } from "./contract/implementation.mjs";
|
|
6
|
-
import { Any as Any$1, Errors } from "./Action.mjs";
|
|
7
|
-
import { Certain, ErrorsOf } from "./contract/declared.mjs";
|
|
8
|
-
import { Any as Any$2, DescriptorOf, LayerIdentity, Matching, PublicOnly, RemoteRequest, Required, ServedProvider, ServerBuildServices, VerifierError } from "./authentication/provider.mjs";
|
|
9
9
|
import { Only } from "./contract/listed.mjs";
|
|
10
10
|
import { SubscriptionOf } from "./contract/push.mjs";
|
|
11
|
-
import { pageOf, sentOf } from "./http/events.mjs";
|
|
12
11
|
import { AnyHttp, Client, MethodError, Options, WatchError } from "./http/client.mjs";
|
|
12
|
+
import { pageOf, sentOf } from "./http/events.mjs";
|
|
13
13
|
import { SuccessOf } from "./http/streamed.mjs";
|
|
14
14
|
import { Placed, placed } from "./http/placed.mjs";
|
|
15
15
|
import { Context, Effect, FileSystem, Layer, Path, Schema, Types } from "effect";
|
|
@@ -34,11 +34,11 @@ type Through<M extends Middleware, R> = number extends M["length"] ? R | HttpApi
|
|
|
34
34
|
type ServerOnly<M extends Middleware, E extends Errors> = [Exclude<HttpApiMiddleware.Error<IdOf<M[number]>>, Extract<Certain<E>, Errors[number]>["Type"] | BuiltIn> | HttpApiMiddleware.MiddlewareClient<IdOf<M[number]>>] extends [never] ? unknown : {
|
|
35
35
|
readonly "Layer middleware fails only with the binding's errors and needs no client": never;
|
|
36
36
|
};
|
|
37
|
-
type HttpLayer<H extends AnyHttp, Apps extends Served, M extends Middleware, A extends Any$1 = H["actions"][number], E extends Any = H["events"][number]> = Layer.Layer<never, BuildError<Holding<Member<Apps>, A>, A> | EventBuildError<HoldingEvents<Member<Apps>, E>, E>, ServerBuildServices<Holding<Member<Apps>, A>, A> | EventBuildServices<HoldingEvents<Member<Apps>, E>, E> | HttpRouter.HttpRouter | HttpRouter.Request.From<"Requires", LayerRequest<Member<Apps>, A, E, M>> | ServedProvider<Member<Apps>, A, H extends {
|
|
37
|
+
type HttpLayer<H extends AnyHttp, Apps extends Served, M extends Middleware, A extends Any$1 = H["actions"][number], E extends Any$2 = H["events"][number]> = Layer.Layer<never, BuildError<Holding<Member<Apps>, A>, A> | EventBuildError<HoldingEvents<Member<Apps>, E>, E>, ServerBuildServices<Holding<Member<Apps>, A>, A> | EventBuildServices<HoldingEvents<Member<Apps>, E>, E> | HttpRouter.HttpRouter | HttpRouter.Request.From<"Requires", LayerRequest<Member<Apps>, A, E, M>> | ServedProvider<Member<Apps>, A, H extends {
|
|
38
38
|
readonly authentication: infer D;
|
|
39
39
|
} ? D : never, ServingEvents<Member<Apps>, E>> | IdOf<M[number]> | Etag.Generator | FileSystem.FileSystem | HttpPlatform.HttpPlatform | Path.Path>;
|
|
40
40
|
/** `ActionHttp.layer`'s options. */
|
|
41
|
-
export interface LayerOptions<M extends Middleware = [], C extends Any$1 | Any = never> {
|
|
41
|
+
export interface LayerOptions<M extends Middleware = [], C extends Any$1 | Any$2 = never> {
|
|
42
42
|
/**
|
|
43
43
|
* The actions and event types it serves, among the binding's the implementations hold:
|
|
44
44
|
* `[GetUser, UserRenamed]`, exactly those. Defaults to every one of them.
|
|
@@ -59,7 +59,7 @@ export interface LayerOptions<M extends Middleware = [], C extends Any$1 | Any =
|
|
|
59
59
|
*/
|
|
60
60
|
readonly middleware?: M;
|
|
61
61
|
}
|
|
62
|
-
type LayerRequest<App, A extends Any$1, E extends Any, M extends Middleware> = Exclude<Through<M, RemoteRequest<App, A> | EventServedRequest<App, E>>, HttpRouter.Provided | LayerIdentity<App, A, E>>;
|
|
62
|
+
type LayerRequest<App, A extends Any$1, E extends Any$2, M extends Middleware> = Exclude<Through<M, RemoteRequest<App, A> | EventServedRequest<App, E>>, HttpRouter.Provided | LayerIdentity<App, A, E>>;
|
|
63
63
|
/** Contract-level configuration shared by servers and clients. */
|
|
64
64
|
interface Options$1<E extends Errors = Errors> {
|
|
65
65
|
/**
|
|
@@ -87,18 +87,18 @@ interface Options$1<E extends Errors = Errors> {
|
|
|
87
87
|
*
|
|
88
88
|
* - One descriptor per binding: actions of a second identity take a second binding with its own `prefix`, and a public action may be in both.
|
|
89
89
|
*/
|
|
90
|
-
readonly authentication?: Any
|
|
90
|
+
readonly authentication?: Any;
|
|
91
91
|
}
|
|
92
92
|
type EndpointError<A extends Any$1, E extends Errors, D> = Schema.toCodecJson<A["error"][number] | E[number] | VerifierError<A, D> | BuiltIns>;
|
|
93
93
|
type Endpoint<A extends Any$1, E extends Errors, D> = A extends Any$1 ? HttpApiEndpoint.HttpApiEndpoint<A["name"], "POST", `/${string}`, never, never, Schema.toCodecJson<A["input"]>, never, SuccessOf<A, EndpointError<A, E, D>>, EndpointError<A, E, D>> : never;
|
|
94
|
-
type EventEndpoint<V extends Any, E extends Errors, D> = V extends Any ? HttpApiEndpoint.HttpApiEndpoint<V["name"], "POST", `/${string}`, never, never, Schema.toCodecJson<ReturnType<typeof SubscriptionOf<V>>>, never, Schema.toCodecJson<ReturnType<typeof pageOf<V>>> | ReturnType<typeof sentOf<V>>, Schema.toCodecJson<E[number] | VerifierError<V, D> | BuiltIns>> : never;
|
|
95
|
-
type Api<Actions extends readonly Any$1[], E extends Errors, D, Events extends readonly Any[]> = HttpApi.HttpApi<"actions", HttpApiGroup.HttpApiGroup<string, Endpoint<Actions[number], E, D> | EventEndpoint<Events[number], E, D>, true>>;
|
|
94
|
+
type EventEndpoint<V extends Any$2, E extends Errors, D> = V extends Any$2 ? HttpApiEndpoint.HttpApiEndpoint<V["name"], "POST", `/${string}`, never, never, Schema.toCodecJson<ReturnType<typeof SubscriptionOf<V>>>, never, Schema.toCodecJson<ReturnType<typeof pageOf<V>>> | ReturnType<typeof sentOf<V>>, Schema.toCodecJson<E[number] | VerifierError<V, D> | BuiltIns>> : never;
|
|
95
|
+
type Api<Actions extends readonly Any$1[], E extends Errors, D, Events extends readonly Any$2[]> = HttpApi.HttpApi<"actions", HttpApiGroup.HttpApiGroup<string, Endpoint<Actions[number], E, D> | EventEndpoint<Events[number], E, D>, true>>;
|
|
96
96
|
/**
|
|
97
97
|
* An HTTP binding: actions and event types, the errors every endpoint declares, and where they
|
|
98
98
|
* are mounted. Plain data, so a copy of it, or one made by another installed copy of this
|
|
99
99
|
* package, serves the same; `layer` serves it and `client` calls it.
|
|
100
100
|
*/
|
|
101
|
-
export interface Binding<Actions extends readonly Any$1[], E extends Errors = [], D extends Any
|
|
101
|
+
export interface Binding<Actions extends readonly Any$1[], E extends Errors = [], D extends Any | undefined = undefined, Events extends readonly Any$2[] = readonly []> {
|
|
102
102
|
/** Its protected actions' authentication descriptor, or `undefined` without one. */
|
|
103
103
|
readonly authentication: D;
|
|
104
104
|
/** The exact actions bound to this binding. */
|
|
@@ -136,11 +136,11 @@ export interface Binding<Actions extends readonly Any$1[], E extends Errors = []
|
|
|
136
136
|
* - An action and an event type of one name, or an event type listed twice, throw when `make` is called: they would share a client's method.
|
|
137
137
|
* - A protected event type, where `authentication` has `principal`, is bound at `POST <prefix>/events/<name>/subscribe` and `/unsubscribe` too, for `Webhook.layer`'s delivery, and OpenAPI lists both: a binding cannot know whether its server provides that layer, and without it they answer a 409 `Event.SubscriptionError`, reason `Unsupported`.
|
|
138
138
|
*/
|
|
139
|
-
export declare function make<const Contracts extends ReadonlyArray<(Any$1 | Any) & {
|
|
139
|
+
export declare function make<const Contracts extends ReadonlyArray<(Any$1 | Any$2) & {
|
|
140
140
|
readonly caller: typeof Anyone;
|
|
141
|
-
}>>(contracts: Contracts, options?: Pick<Options$1, "prefix">): Binding<Only<Contracts, Any$1>, [], undefined, Only<Contracts, Any>>;
|
|
142
|
-
export declare function make<const Contracts extends ReadonlyArray<Any$1 | Any>, const O extends Options$1 = {}>(contracts: Contracts, options: O & Required<Contracts[number]> & Matching<Contracts[number], NoInfer<DescriptorOf<O>>> & NoInfer<Known<O, Options$1>>): Binding<Only<Contracts, Any$1>, ErrorsOf<O>, DescriptorOf<O>, Only<Contracts, Any>>;
|
|
143
|
-
export declare function make<const Contracts extends ReadonlyArray<Any$1 | Any>>(contracts: Contracts & PublicOnly<Contracts>): Binding<Only<Contracts, Any$1>, [], undefined, Only<Contracts, Any>>;
|
|
141
|
+
}>>(contracts: Contracts, options?: Pick<Options$1, "prefix">): Binding<Only<Contracts, Any$1>, [], undefined, Only<Contracts, Any$2>>;
|
|
142
|
+
export declare function make<const Contracts extends ReadonlyArray<Any$1 | Any$2>, const O extends Options$1 = {}>(contracts: Contracts, options: O & Required<Contracts[number]> & Matching<Contracts[number], NoInfer<DescriptorOf<O>>> & NoInfer<Known<O, Options$1>>): Binding<Only<Contracts, Any$1>, ErrorsOf<O>, DescriptorOf<O>, Only<Contracts, Any$2>>;
|
|
143
|
+
export declare function make<const Contracts extends ReadonlyArray<Any$1 | Any$2>>(contracts: Contracts & PublicOnly<Contracts>): Binding<Only<Contracts, Any$1>, [], undefined, Only<Contracts, Any$2>>;
|
|
144
144
|
/**
|
|
145
145
|
* Serve the binding's actions and event types among `implementations` in one layer, or those its
|
|
146
146
|
* `actions` lists, authenticating a protected action's request before decoding it, then running
|
package/dist/ActionHttp.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import { providerOf } from "./authentication/provider.mjs";
|
|
2
|
+
import { inputParseOptions } from "./contract/call.mjs";
|
|
1
3
|
import { Anyone } from "./contract/caller.mjs";
|
|
2
|
-
import { declared } from "./contract/status.mjs";
|
|
3
4
|
import { bindingErrors, bindingOf, eventErrors, projectedErrors } from "./contract/declared.mjs";
|
|
4
|
-
import { elementOf } from "./contract/stream.mjs";
|
|
5
|
-
import { acquire } from "./contract/implementation.mjs";
|
|
6
|
-
import { inputParseOptions } from "./contract/call.mjs";
|
|
7
5
|
import { acquireFeeds, unkeyedHook } from "./contract/feed.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { providerOf } from "./authentication/provider.mjs";
|
|
6
|
+
import { acquire } from "./contract/implementation.mjs";
|
|
10
7
|
import { listed } from "./contract/listed.mjs";
|
|
11
8
|
import { provideServed, servingOf } from "./contract/serving.mjs";
|
|
12
|
-
import {
|
|
9
|
+
import { declared } from "./contract/status.mjs";
|
|
10
|
+
import { elementOf } from "./contract/stream.mjs";
|
|
11
|
+
import { offersWebhook, servedWebhooks } from "./contract/webhooks.mjs";
|
|
13
12
|
import { methods } from "./http/client.mjs";
|
|
14
13
|
import { answering, eventEndpointOf, servedSent, webhookAnswers, webhookEndpointsOf } from "./http/events.mjs";
|
|
15
14
|
import { SchemaErrors, schemaErrors } from "./http/schema-errors.mjs";
|
|
15
|
+
import { answeredWithProgress, answeringElements, answeringWithProgress, elementStreamOf, progressStreamOf } from "./http/streamed.mjs";
|
|
16
16
|
import { placed } from "./http/placed.mjs";
|
|
17
17
|
import { Context, Effect, Layer, Scope } from "effect";
|
|
18
18
|
import { FetchHttpClient, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
package/dist/ActionMcp.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { Any, Matching, ProviderOf, RemoteRequest, Required, ServerBuildServices } from "./authentication/provider.mjs";
|
|
2
|
+
import { Any as Any$1 } from "./Action.mjs";
|
|
3
|
+
import { Any as Any$2 } from "./Event.mjs";
|
|
1
4
|
import { EventBuildError, EventBuildServices, EventOf, EventRequestOf, EventServedRequest, HoldingEvents } from "./contract/feed.mjs";
|
|
2
|
-
import { Any } from "./Event.mjs";
|
|
3
5
|
import { ActionOf, BuildError, BuildServices, Holding, Known, Member, Protected, SelectedEventsOf, SelectedOf, Selection, Served, ServedRequest } from "./contract/implementation.mjs";
|
|
4
|
-
import { Any as Any$1 } from "./Action.mjs";
|
|
5
|
-
import { Any as Any$2, Matching, ProviderOf, RemoteRequest, Required, ServerBuildServices } from "./authentication/provider.mjs";
|
|
6
|
-
import { McpCallError } from "./mcp/reply.mjs";
|
|
7
6
|
import { Client, ClientOptions, client } from "./mcp/client.mjs";
|
|
7
|
+
import { McpCallError } from "./mcp/reply.mjs";
|
|
8
8
|
import { Params, RequestOptions, request } from "./mcp/request.mjs";
|
|
9
9
|
import { Cause, Effect, Layer, Scope, Stdio } from "effect";
|
|
10
10
|
import { HttpRouter } from "effect/http";
|
|
@@ -15,7 +15,7 @@ import { McpSchema, McpServer } from "effect/ai";
|
|
|
15
15
|
* among them, the actions `A` that are its tools and the event types `A` it serves, and the
|
|
16
16
|
* native features it serves beside them.
|
|
17
17
|
*/
|
|
18
|
-
export interface Options<E = never, R = never, A extends Any$1 | Any = Any$1 | Any> extends Omit<Parameters<typeof McpServer.layerStdio>[0], "protocols" | "registrations"> {
|
|
18
|
+
export interface Options<E = never, R = never, A extends Any$1 | Any$2 = Any$1 | Any$2> extends Omit<Parameters<typeof McpServer.layerStdio>[0], "protocols" | "registrations"> {
|
|
19
19
|
/**
|
|
20
20
|
* The actions that are tools and the event types it serves, among the implementations':
|
|
21
21
|
* `[GetUser, RenameUser, UserRenamed]`, exactly those. Each keeps its implementation's
|
|
@@ -47,7 +47,7 @@ export interface Options<E = never, R = never, A extends Any$1 | Any = Any$1 | A
|
|
|
47
47
|
* `McpServer.layerHttp` option, `allowedOrigins` among them, except `protocols`, `registrations`
|
|
48
48
|
* and `allowSessionTermination`, which are fixed.
|
|
49
49
|
*/
|
|
50
|
-
export interface LayerHttpOptions<E = never, R = never, A extends Any$1 | Any = Any$1 | Any> extends Options<E, R, A>, Omit<Parameters<typeof McpServer.layerHttp>[0], "protocols" | "path" | "allowSessionTermination" | "registrations"> {
|
|
50
|
+
export interface LayerHttpOptions<E = never, R = never, A extends Any$1 | Any$2 = Any$1 | Any$2> extends Options<E, R, A>, Omit<Parameters<typeof McpServer.layerHttp>[0], "protocols" | "path" | "allowSessionTermination" | "registrations"> {
|
|
51
51
|
/** The endpoint's route; defaults to `/mcp`. */
|
|
52
52
|
readonly path?: HttpRouter.PathInput;
|
|
53
53
|
/**
|
|
@@ -66,7 +66,7 @@ export interface LayerHttpOptions<E = never, R = never, A extends Any$1 | Any =
|
|
|
66
66
|
* - Every prompt and resource request needs a credential, listings included: to offer them signed out, serve them on an endpoint without protected tools.
|
|
67
67
|
* - A handler that sends a notification starts the response, so a refusal after it is an `isError: true` tool result, not the 401 or 403 a client re-authorizes on: refuse in `authorize`.
|
|
68
68
|
*/
|
|
69
|
-
readonly authentication?: Any
|
|
69
|
+
readonly authentication?: Any;
|
|
70
70
|
/**
|
|
71
71
|
* Whether MCP 2026-07-28 clients may subscribe, holding a stream open for list changes and
|
|
72
72
|
* resource updates. Defaults to whether `features` or event implementations are given: an
|
|
@@ -135,7 +135,7 @@ type Inferring<D, A extends Pick<Any$1, "caller">> = [D] extends [undefined] ? [
|
|
|
135
135
|
* - A poll's `maxEvents` caps a log source's page, at most 100, and is not honored for a check source, whose page is answered whole since only its last cursor resumes; `maxAgeMs` is accepted and not honored, a log source keeping what its `log.maxAge` and `log.maxEvents` say.
|
|
136
136
|
* - A push stream's failure that no refusal explains, such as an upstream's outage, is `notifications/events/error`, its cause logged and reported, and the stream resumes from where it reached after 5 seconds; a refusal ends it with `notifications/events/terminated`. One before `active`, or a poll's, is a JSON-RPC `-32603`, which `client`'s `watch` reconnects after, as after a 5xx.
|
|
137
137
|
*/
|
|
138
|
-
export declare function layerHttp<const Apps extends Served, const O extends Selection<ActionOf<Member<Apps>> | EventOf<Member<Apps>>> = {}, E = never, R = never, const D extends Any
|
|
138
|
+
export declare function layerHttp<const Apps extends Served, const O extends Selection<ActionOf<Member<Apps>> | EventOf<Member<Apps>>> = {}, E = never, R = never, const D extends Any | undefined = undefined>(implementations: Apps, options: LayerHttpOptions<E, R, ActionOf<Member<Apps>> | EventOf<Member<Apps>>> & O & NoInfer<Known<O, LayerHttpOptions<E, R>>> & NoInfer<Required<Contracts<Apps, O>>> & Matching<NoInfer<Contracts<Apps, O>>, NoInfer<D>> & Inferring<D, NoInfer<Contracts<Apps, O>>>): Layer.Layer<never, ServerError<Apps, O> | E, ServerBuildServices<Holding<Member<Apps>, SelectedOf<O, Apps>>, SelectedOf<O, Apps>> | EventServices<Apps, O> | HttpRouter.HttpRouter | HttpRouter.Request.From<"Requires", HttpToolRequestContext<RemoteRequest<Member<Apps>, SelectedOf<O, Apps>> | EventServedRequest<Member<Apps>, SelectedEventsOf<O, Apps>> | FeatureRequest<R>>> | ProviderOf<D> | Features<R>>;
|
|
139
139
|
/**
|
|
140
140
|
* Serve MCP tools through newline-delimited JSON-RPC on standard I/O, speaking MCP
|
|
141
141
|
* 2026-07-28, 2025-11-25 or 2025-06-18, as the host negotiates: the whole
|
package/dist/ActionMcp.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
+
import { promote, providerOf } from "./authentication/provider.mjs";
|
|
2
|
+
import { recordStepUp } from "./authentication/refusal.mjs";
|
|
3
|
+
import { inputParseOptions } from "./contract/call.mjs";
|
|
1
4
|
import { Anyone, assertAuthentication } from "./contract/caller.mjs";
|
|
2
5
|
import { projectedErrors } from "./contract/declared.mjs";
|
|
3
|
-
import { assertOnce, heldOnce } from "./contract/names.mjs";
|
|
4
|
-
import { toolSuccessOf } from "./contract/stream.mjs";
|
|
5
|
-
import { acquire, answeringWhole } from "./contract/implementation.mjs";
|
|
6
|
-
import { inputParseOptions } from "./contract/call.mjs";
|
|
7
6
|
import { hintsOf } from "./contract/hints.mjs";
|
|
7
|
+
import { acquire, answeringWhole } from "./contract/implementation.mjs";
|
|
8
8
|
import { liftOf, liftedFrom } from "./contract/lift.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { assertOnce, heldOnce } from "./contract/names.mjs";
|
|
10
10
|
import { provideServed, selectFrom } from "./contract/serving.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { toolSuccessOf } from "./contract/stream.mjs";
|
|
12
12
|
import { withStderrConsole } from "./stdio/console.mjs";
|
|
13
|
-
import { defaultPath, fieldKey, httpProtocol, isMisplaced, isObjectSchema, protocols, toolJsonSchema } from "./mcp/protocol.mjs";
|
|
14
13
|
import { eventSchemasOf, refuseUnservable, serveWebhooks, withEvents } from "./mcp/bridge.mjs";
|
|
15
14
|
import { progressNotifier } from "./mcp/progress.mjs";
|
|
15
|
+
import { defaultPath, fieldKey, httpProtocol, isMisplaced, isObjectSchema, protocols, toolJsonSchema } from "./mcp/protocol.mjs";
|
|
16
|
+
import { client } from "./mcp/client.mjs";
|
|
16
17
|
import { McpCallError } from "./mcp/reply.mjs";
|
|
17
18
|
import { request } from "./mcp/request.mjs";
|
|
18
|
-
import { client } from "./mcp/client.mjs";
|
|
19
19
|
import { Cause, Context, Effect, ErrorReporter, Exit, Fiber, Layer, Option, Predicate, Schema, Stdio, Stream } from "effect";
|
|
20
20
|
import { HttpRouter, HttpServerRequest } from "effect/http";
|
|
21
21
|
import { AiError, McpSchema, McpServer } from "effect/ai";
|
package/dist/ActionRpc.d.mts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Any as Any$1, Descriptor, DescriptorOf, LayerIdentity, Matching, ProviderOf, PublicOnly, RemoteRequest, Required, Security, ServedProvider, ServerBuildServices, VerifierError } from "./authentication/provider.mjs";
|
|
2
|
+
import { Any as Any$2, Errors } from "./Action.mjs";
|
|
3
|
+
import { Call } from "./contract/call.mjs";
|
|
2
4
|
import { Anyone } from "./contract/caller.mjs";
|
|
5
|
+
import { Codec } from "./contract/codec.mjs";
|
|
6
|
+
import { Certain, ErrorsOf } from "./contract/declared.mjs";
|
|
3
7
|
import { BuiltIn, BuiltIns, Unauthenticated } from "./contract/errors.mjs";
|
|
8
|
+
import { Any as Any$3, Received, SubscriptionError } from "./Event.mjs";
|
|
4
9
|
import { EventBuildError, EventBuildServices, EventServedRequest, HoldingEvents, ServingEvents } from "./contract/feed.mjs";
|
|
5
|
-
import { Any as Any$1, Received, SubscriptionError } from "./Event.mjs";
|
|
6
10
|
import { BuildError, Holding, Known, Member, MiddlewareOf, Selected, SelectedEvents, Served } from "./contract/implementation.mjs";
|
|
7
|
-
import { Call } from "./contract/call.mjs";
|
|
8
|
-
import { Answer, StreamOf } from "./contract/stream.mjs";
|
|
9
|
-
import { WatchArgs } from "./contract/watch.mjs";
|
|
10
|
-
import { Any as Any$2, Errors } from "./Action.mjs";
|
|
11
|
-
import { Certain, ErrorsOf } from "./contract/declared.mjs";
|
|
12
|
-
import { Any as Any$3, Descriptor, DescriptorOf, LayerIdentity, Matching, ProviderOf, PublicOnly, RemoteRequest, Required, Security, ServedProvider, ServerBuildServices, VerifierError } from "./authentication/provider.mjs";
|
|
13
11
|
import { Only } from "./contract/listed.mjs";
|
|
14
12
|
import { PushedOf, SubscriptionOf } from "./contract/push.mjs";
|
|
13
|
+
import { Answer, StreamOf } from "./contract/stream.mjs";
|
|
14
|
+
import { WatchArgs } from "./contract/watch.mjs";
|
|
15
15
|
import { Context, Effect, Layer, Schedule, Schema, Scope, Stream, Types } from "effect";
|
|
16
16
|
import { HttpRouter, HttpServerRequest } from "effect/http";
|
|
17
17
|
import { Rpc, RpcClient, RpcClientError, RpcGroup, RpcMessage, RpcMiddleware, RpcSchema, RpcServer } from "effect/rpc";
|
|
@@ -28,7 +28,7 @@ type ElementedOf<Element extends Schema.Constraint, P> = Schema.Union<readonly [
|
|
|
28
28
|
readonly value: P;
|
|
29
29
|
}>] : [])]>;
|
|
30
30
|
type RpcOf<A extends Any$2, E extends Errors, D> = A extends Any$2 ? A["success"] extends StreamOf<infer Element> ? Rpc.Rpc<A["name"], A["input"], RpcSchema.Stream<ElementedOf<Element, A["progress"]>, ErrorOf<A, E, D>>> : A["progress"] extends Codec ? Rpc.Rpc<A["name"], A["input"], RpcSchema.Stream<ReturnType<typeof ProgressedOf<A["progress"], A["success"]>>, ErrorOf<A, E, D>>> : Rpc.Rpc<A["name"], A["input"], A["success"], ErrorOf<A, E, D>> : never;
|
|
31
|
-
type EventRpcOf<V extends Any$
|
|
31
|
+
type EventRpcOf<V extends Any$3, E extends Errors, D> = V extends Any$3 ? Rpc.Rpc<V["name"], ReturnType<typeof SubscriptionOf<V>>, RpcSchema.Stream<ReturnType<typeof PushedOf<V>>, Schema.Union<ReadonlyArray<E[number] | VerifierError<V, D> | BuiltIns>>>> : never;
|
|
32
32
|
declare const authenticatedKey = "effect-actions/ActionRpc/Authenticated";
|
|
33
33
|
type RefusalOf<E extends Errors> = Schema.Union<ReadonlyArray<typeof Unauthenticated | E[number]>>;
|
|
34
34
|
declare const authenticatedBrand: unique symbol;
|
|
@@ -42,14 +42,14 @@ interface Authenticated<I, E extends Errors = Errors> {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
type AuthenticatedOf<D> = D extends Descriptor<infer I, unknown, Security, string, infer E> ? RpcMiddleware.ServiceClass<Authenticated<I, E>, typeof authenticatedKey, I, RefusalOf<E>, never, never, false> : never;
|
|
45
|
-
type NativeOf<N extends Rpc.Any, D> = [D] extends [Any$
|
|
45
|
+
type NativeOf<N extends Rpc.Any, D> = [D] extends [Any$1] ? Rpc.AddMiddleware<N, AuthenticatedOf<D>> : N;
|
|
46
46
|
/**
|
|
47
47
|
* An RPC binding: actions, event types, the errors every rpc declares, the descriptor
|
|
48
48
|
* authenticating its protected ones, and the native rpcs it serves beside them. Plain data, so a
|
|
49
49
|
* copy of it, or one made by another installed copy of this package, serves the same; `layer`
|
|
50
50
|
* serves it and `client` calls it.
|
|
51
51
|
*/
|
|
52
|
-
export interface Binding<Actions extends readonly Any$2[], E extends Errors = [], D extends Any$
|
|
52
|
+
export interface Binding<Actions extends readonly Any$2[], E extends Errors = [], D extends Any$1 | undefined = undefined, Events extends readonly Any$3[] = readonly [], N extends Rpc.Any = never> {
|
|
53
53
|
/** The descriptor authenticating its protected actions, or `undefined` when it names none. */
|
|
54
54
|
readonly authentication: D;
|
|
55
55
|
/** The exact actions bound to this binding. */
|
|
@@ -80,9 +80,9 @@ export interface Binding<Actions extends readonly Any$2[], E extends Errors = []
|
|
|
80
80
|
* their rpcs; `actions` carries the types.
|
|
81
81
|
*/
|
|
82
82
|
export interface Any {
|
|
83
|
-
readonly authentication?: Any$
|
|
83
|
+
readonly authentication?: Any$1 | undefined;
|
|
84
84
|
readonly actions: readonly Any$2[];
|
|
85
|
-
readonly events: readonly Any$
|
|
85
|
+
readonly events: readonly Any$3[];
|
|
86
86
|
readonly error: Errors;
|
|
87
87
|
readonly rpcs: RpcGroup.Any;
|
|
88
88
|
readonly group: RpcGroup.Any;
|
|
@@ -98,7 +98,7 @@ export interface Options<E extends Errors = Errors> {
|
|
|
98
98
|
* `Authentication.make(...)` of the protected actions' identity, which authenticates each of
|
|
99
99
|
* their messages: required when the binding holds a protected action, and of its identity.
|
|
100
100
|
*/
|
|
101
|
-
readonly authentication?: Any$
|
|
101
|
+
readonly authentication?: Any$1;
|
|
102
102
|
/**
|
|
103
103
|
* Native rpcs the binding serves beside its actions and event types, with their own schemas
|
|
104
104
|
* and handlers: `RpcGroup.make(Upload)`. Under an `authentication`, each of their messages
|
|
@@ -134,11 +134,11 @@ type RpcsOf<O> = O extends {
|
|
|
134
134
|
* - An action declaring `progress` is a stream rpc taking its input, streaming `{ _tag: "Progress", value }` for each value its handler reports, then one `{ _tag: "Final", value }` holding its answer: the native client's method of it returns a `Stream`.
|
|
135
135
|
* - An action answering a stream, `Action.Stream`, is a stream rpc taking its input, streaming `{ _tag: "Element", value }` for each element, beside `{ _tag: "Progress", value }` for each value where it declares `progress`; `client`'s method returns a `Stream` of the elements.
|
|
136
136
|
*/
|
|
137
|
-
export declare function make<const Contracts extends ReadonlyArray<(Any$2 | Any$
|
|
137
|
+
export declare function make<const Contracts extends ReadonlyArray<(Any$2 | Any$3) & {
|
|
138
138
|
readonly caller: typeof Anyone;
|
|
139
|
-
}>>(contracts: Contracts): Binding<Only<Contracts, Any$2>, [], undefined, Only<Contracts, Any$
|
|
140
|
-
export declare function make<const Contracts extends ReadonlyArray<Any$2 | Any$
|
|
141
|
-
export declare function make<const Contracts extends ReadonlyArray<Any$2 | Any$
|
|
139
|
+
}>>(contracts: Contracts): Binding<Only<Contracts, Any$2>, [], undefined, Only<Contracts, Any$3>>;
|
|
140
|
+
export declare function make<const Contracts extends ReadonlyArray<Any$2 | Any$3>, const O extends Options = {}>(contracts: Contracts, options: O & Required<Contracts[number]> & Matching<Contracts[number], NoInfer<DescriptorOf<O>>> & NoInfer<Known<O, Options>>): Binding<Only<Contracts, Any$2>, ErrorsOf<O>, DescriptorOf<O>, Only<Contracts, Any$3>, RpcsOf<O>>;
|
|
141
|
+
export declare function make<const Contracts extends ReadonlyArray<Any$2 | Any$3>>(contracts: Contracts & PublicOnly<Contracts>): Binding<Only<Contracts, Any$2>, [], undefined, Only<Contracts, Any$3>>;
|
|
142
142
|
type Middleware = readonly RpcMiddleware.AnyService[];
|
|
143
143
|
type IdOf<K> = K extends Context.Key<infer I extends RpcMiddleware.AnyId, unknown> ? I : never;
|
|
144
144
|
type Through<M extends Middleware, R> = number extends M["length"] ? R | RpcMiddleware.Requires<IdOf<M[number]>> : M extends readonly [infer K, ...infer Rest extends Middleware] ? Through<Rest, true extends Types.IsUnion<IdOf<K>> ? R | RpcMiddleware.Requires<IdOf<K>> : RpcMiddleware.ApplyServices<IdOf<K>, R>> : R;
|
|
@@ -148,15 +148,15 @@ type ForClient<K> = K extends {
|
|
|
148
148
|
type ServerOnly<M extends Middleware, E extends Errors> = [Exclude<RpcMiddleware.Error<IdOf<M[number]>>, Extract<Certain<E>, BindingError>["Type"] | BuiltIn> | ForClient<M[number]>] extends [never] ? unknown : {
|
|
149
149
|
readonly "Layer middleware fails only with the binding's errors and needs no client": never;
|
|
150
150
|
};
|
|
151
|
-
type LayerRequest<App, A extends Any$2, E extends Any$
|
|
152
|
-
type RpcLayer<B extends Any, Apps extends Served, M extends Middleware, A extends Any$2 = B["actions"][number], E extends Any$
|
|
151
|
+
type LayerRequest<App, A extends Any$2, E extends Any$3, M extends Middleware> = Exclude<Through<M, RemoteRequest<App, A> | EventServedRequest<App, E>>, HttpServerRequest.HttpServerRequest | HttpServerRequest.ParsedSearchParams | LayerIdentity<App, A, E>>;
|
|
152
|
+
type RpcLayer<B extends Any, Apps extends Served, M extends Middleware, A extends Any$2 = B["actions"][number], E extends Any$3 = B["events"][number]> = Layer.Layer<never, BuildError<Holding<Member<Apps>, A>, A> | EventBuildError<HoldingEvents<Member<Apps>, E>, E>, ServerBuildServices<Holding<Member<Apps>, A>, A> | EventBuildServices<HoldingEvents<Member<Apps>, E>, E> | RpcServer.Protocol | HttpRouter.Request.From<"Requires", LayerRequest<Member<Apps>, A, E, M>> | ServedProvider<Member<Apps>, A, B extends {
|
|
153
153
|
readonly authentication: infer D;
|
|
154
154
|
} ? D : never, ServingEvents<Member<Apps>, E>> | IdOf<M[number]> | NativeServer<RpcGroup.Rpcs<B["rpcs"]>, B extends {
|
|
155
155
|
readonly authentication: infer D;
|
|
156
156
|
} ? D : never>>;
|
|
157
157
|
type NativeServer<N extends Rpc.Any, D> = [N] extends [never] ? never : Rpc.ToHandler<N> | Exclude<Rpc.Middleware<N>, Authenticated<unknown>> | Rpc.ServicesServer<N> | ProviderOf<D>;
|
|
158
158
|
/** `ActionRpc.layer`'s options. */
|
|
159
|
-
export interface LayerOptions<M extends Middleware = [], C extends Any$2 | Any$
|
|
159
|
+
export interface LayerOptions<M extends Middleware = [], C extends Any$2 | Any$3 = never> {
|
|
160
160
|
/**
|
|
161
161
|
* The actions and event types it serves, among the binding's the implementations hold:
|
|
162
162
|
* `[GetUser, UserRenamed]`, exactly those. Defaults to every one of them.
|
|
@@ -262,7 +262,7 @@ type Method<A extends Any$2, E extends BindingError> = Call<A, Answer<A["success
|
|
|
262
262
|
* `mode: "poll"`, which rpcs do not serve, `NotServed` for an event the server does not serve), or
|
|
263
263
|
* Effect's own `RpcClientError` that no reconnect outlasts. An element that does not decode is a defect, as for a call.
|
|
264
264
|
*/
|
|
265
|
-
export type WatchError<W extends Any$
|
|
265
|
+
export type WatchError<W extends Any$3, B extends Any> = SubscriptionError | BuiltIns["Type"] | B["error"][number]["Type"] | VerifierError<W, B["authentication"]>["Type"] | RpcClientError.RpcClientError;
|
|
266
266
|
type Watching<B extends Any> = [B["events"][number]] extends [never] ? unknown : {
|
|
267
267
|
readonly watch: <W extends B["events"][number], SE = never>(event: W, ...args: WatchArgs<W, SE>) => Stream.Stream<Received<W>, WatchError<W, B> | SE>;
|
|
268
268
|
};
|
package/dist/ActionRpc.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { providerOf } from "./authentication/provider.mjs";
|
|
2
|
+
import { checked, checkedStream, decodeInput, inputParseOptions, sendingJson, watchInput } from "./contract/call.mjs";
|
|
1
3
|
import { Anyone } from "./contract/caller.mjs";
|
|
2
|
-
import { InvalidInput, Unauthenticated } from "./contract/errors.mjs";
|
|
3
4
|
import { bindingErrors, bindingOf, eventErrors } from "./contract/declared.mjs";
|
|
5
|
+
import { InvalidInput, Unauthenticated } from "./contract/errors.mjs";
|
|
6
|
+
import { acquireFeeds } from "./contract/feed.mjs";
|
|
7
|
+
import { acquire, elementsOf } from "./contract/implementation.mjs";
|
|
8
|
+
import { listed } from "./contract/listed.mjs";
|
|
4
9
|
import { reservedList, reservedNames } from "./contract/names.mjs";
|
|
5
10
|
import { answerFrom, elementsFrom } from "./contract/progress.mjs";
|
|
6
|
-
import { elementOf } from "./contract/stream.mjs";
|
|
7
|
-
import { acquire, elementsOf } from "./contract/implementation.mjs";
|
|
8
|
-
import { checked, checkedStream, decodeInput, inputParseOptions, sendingJson, watchInput } from "./contract/call.mjs";
|
|
9
|
-
import { concealed } from "./contract/reported.mjs";
|
|
10
|
-
import { acquireFeeds } from "./contract/feed.mjs";
|
|
11
11
|
import { PushedOf, Subscription, SubscriptionOf, queuedPush } from "./contract/push.mjs";
|
|
12
|
-
import {
|
|
13
|
-
import { listed } from "./contract/listed.mjs";
|
|
12
|
+
import { concealed } from "./contract/reported.mjs";
|
|
14
13
|
import { provideServed, servingOf } from "./contract/serving.mjs";
|
|
14
|
+
import { elementOf } from "./contract/stream.mjs";
|
|
15
15
|
import { watching } from "./contract/watch.mjs";
|
|
16
16
|
import { transportOf } from "./rpc/watch.mjs";
|
|
17
17
|
import { Cause, Effect, ErrorReporter, Layer, Match, Option, Predicate, Queue, Result, Schedule, Schema, SchemaTransformation, Stream } from "effect";
|
package/dist/ActionToolkit.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Any } from "./Action.mjs";
|
|
1
2
|
import { Codec } from "./contract/codec.mjs";
|
|
2
3
|
import { BuiltIns } from "./contract/errors.mjs";
|
|
3
4
|
import { ActionOf, BuildError, BuildServices, Holding, Known, Member, Offered, OptionalUnless, RequestOf, SelectedOf, ServedActions, Serving } from "./contract/implementation.mjs";
|
|
4
5
|
import { ToolSuccess } from "./contract/stream.mjs";
|
|
5
|
-
import { Any } from "./Action.mjs";
|
|
6
6
|
import { Effect, Layer, Schema } from "effect";
|
|
7
7
|
import { Prompt, Tool, Toolkit } from "effect/ai";
|
|
8
8
|
type NativeTool<A extends Any, R> = Tool.Tool<A["name"], {
|
package/dist/ActionToolkit.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { projectedErrors } from "./contract/declared.mjs";
|
|
2
|
+
import { hintsOf } from "./contract/hints.mjs";
|
|
3
|
+
import { Implementation, acquire, answeringWhole, provideHandlers, select, toList } from "./contract/implementation.mjs";
|
|
4
|
+
import { liftOf, liftedFrom } from "./contract/lift.mjs";
|
|
2
5
|
import { assertOnce, heldOnce } from "./contract/names.mjs";
|
|
3
6
|
import { progressSink } from "./contract/progress.mjs";
|
|
4
7
|
import { toolSuccessOf } from "./contract/stream.mjs";
|
|
5
|
-
import { Implementation, acquire, answeringWhole, provideHandlers, select, toList } from "./contract/implementation.mjs";
|
|
6
|
-
import { hintsOf } from "./contract/hints.mjs";
|
|
7
|
-
import { liftOf, liftedFrom } from "./contract/lift.mjs";
|
|
8
8
|
import { Effect, Schema, SchemaGetter } from "effect";
|
|
9
9
|
import { Prompt, Tool, Toolkit } from "effect/ai";
|
|
10
10
|
// src/toolkit/ActionToolkit.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Errors } from "./Action.mjs";
|
|
1
2
|
import { Codec } from "./contract/codec.mjs";
|
|
3
|
+
import { ErrorsOf } from "./contract/declared.mjs";
|
|
2
4
|
import { Refusal } from "./contract/errors.mjs";
|
|
3
5
|
import { Known, OptionalUnless } from "./contract/implementation.mjs";
|
|
4
|
-
import { Errors } from "./Action.mjs";
|
|
5
|
-
import { ErrorsOf } from "./contract/declared.mjs";
|
|
6
6
|
import { Any, Descriptor, Provider, Security } from "./authentication/provider.mjs";
|
|
7
7
|
import { Array, Context, Effect, Layer, Option, Redacted, Schema, Scope } from "effect";
|
|
8
8
|
import { HttpRouter, HttpServerResponse } from "effect/http";
|
package/dist/Authentication.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Unauthenticated, builtIns, scopeToken } from "./contract/errors.mjs";
|
|
2
1
|
import { assertDistinctTags, errorList } from "./contract/declared.mjs";
|
|
2
|
+
import { Unauthenticated, builtIns, scopeToken } from "./contract/errors.mjs";
|
|
3
3
|
import { providerOf } from "./authentication/provider.mjs";
|
|
4
4
|
import { answer, answerStepUp, bearer, challenge, declaredResponse, isRefusal, isStepUp, plain } from "./authentication/refusal.mjs";
|
|
5
5
|
import { Context, Effect, Function, Layer, Match, Option, Predicate, Redacted } from "effect";
|