@gjermundgaraba/effect-actions 0.41.1 → 0.42.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.
Files changed (100) hide show
  1. package/dist/Action.d.mts +1 -1
  2. package/dist/Action.mjs +1 -1
  3. package/dist/ActionCli.d.mts +3 -3
  4. package/dist/ActionCli.mjs +2 -2
  5. package/dist/ActionEntity.d.mts +4 -4
  6. package/dist/ActionEntity.mjs +4 -4
  7. package/dist/ActionHttp.d.mts +3 -3
  8. package/dist/ActionHttp.mjs +3 -3
  9. package/dist/ActionMcp.d.mts +3 -3
  10. package/dist/ActionMcp.mjs +6 -6
  11. package/dist/ActionRpc.d.mts +4 -4
  12. package/dist/ActionRpc.mjs +3 -3
  13. package/dist/ActionToolkit.d.mts +2 -2
  14. package/dist/ActionToolkit.mjs +2 -2
  15. package/dist/Authentication.d.mts +3 -3
  16. package/dist/Authentication.mjs +3 -3
  17. package/dist/Event.d.mts +1 -1
  18. package/dist/Event.mjs +1 -1
  19. package/dist/Stored.d.mts +2 -2
  20. package/dist/Stored.mjs +3 -3
  21. package/dist/Testing.d.mts +1 -1
  22. package/dist/Testing.mjs +1 -1
  23. package/dist/Webhook.d.mts +3 -3
  24. package/dist/Webhook.mjs +5 -5
  25. package/dist/authentication/provider.d.mts +6 -6
  26. package/dist/authentication/provider.mjs +1 -1
  27. package/dist/authentication/refusal.mjs +2 -2
  28. package/dist/cli/commands.d.mts +2 -2
  29. package/dist/cli/commands.mjs +2 -2
  30. package/dist/contract/authorizer.d.mts +2 -3
  31. package/dist/contract/authorizer.mjs +1 -1
  32. package/dist/contract/call.d.mts +1 -1
  33. package/dist/contract/call.mjs +1 -1
  34. package/dist/contract/caller.d.mts +1 -1
  35. package/dist/contract/codes.mjs +1 -1
  36. package/dist/contract/declared.d.mts +1 -1
  37. package/dist/contract/declared.mjs +1 -1
  38. package/dist/contract/feed.d.mts +1 -1
  39. package/dist/contract/feed.mjs +1 -1
  40. package/dist/contract/hub.d.mts +1 -1
  41. package/dist/contract/hub.mjs +1 -1
  42. package/dist/contract/idempotency.d.mts +1 -1
  43. package/dist/contract/idempotency.mjs +1 -1
  44. package/dist/contract/implementation.d.mts +1 -1
  45. package/dist/contract/implementation.mjs +22 -3
  46. package/dist/contract/lift.mjs +1 -1
  47. package/dist/contract/log.d.mts +1 -1
  48. package/dist/contract/log.mjs +1 -1
  49. package/dist/contract/media.d.mts +1 -1
  50. package/dist/contract/occurrence.d.mts +1 -1
  51. package/dist/contract/pages.d.mts +1 -1
  52. package/dist/contract/pages.mjs +1 -1
  53. package/dist/contract/progress.d.mts +1 -1
  54. package/dist/contract/push.d.mts +1 -1
  55. package/dist/contract/push.mjs +1 -1
  56. package/dist/contract/receiving.d.mts +1 -1
  57. package/dist/contract/receiving.mjs +1 -1
  58. package/dist/contract/stream.d.mts +5 -5
  59. package/dist/contract/stream.mjs +4 -4
  60. package/dist/contract/subscribe.d.mts +1 -1
  61. package/dist/contract/subscribe.mjs +1 -1
  62. package/dist/contract/transient.mjs +2 -2
  63. package/dist/contract/wake.d.mts +1 -1
  64. package/dist/contract/watch.d.mts +1 -1
  65. package/dist/contract/watch.mjs +1 -1
  66. package/dist/contract/webhooks.d.mts +1 -1
  67. package/dist/contract/webhooks.mjs +1 -1
  68. package/dist/entity/forwarded.d.mts +1 -1
  69. package/dist/entity/wakes.mjs +3 -3
  70. package/dist/http/client.d.mts +3 -3
  71. package/dist/http/client.mjs +3 -3
  72. package/dist/http/events.d.mts +2 -2
  73. package/dist/http/events.mjs +3 -3
  74. package/dist/http/schema-errors.mjs +1 -1
  75. package/dist/http/streamed.d.mts +3 -3
  76. package/dist/http/streamed.mjs +3 -3
  77. package/dist/http/unavailable.mjs +1 -1
  78. package/dist/http/watch.mjs +2 -2
  79. package/dist/mcp/bridge.mjs +3 -3
  80. package/dist/mcp/client.d.mts +2 -2
  81. package/dist/mcp/client.mjs +3 -3
  82. package/dist/mcp/events.mjs +2 -2
  83. package/dist/mcp/progress.mjs +1 -1
  84. package/dist/mcp/protocol.mjs +2 -2
  85. package/dist/mcp/reply.d.mts +2 -2
  86. package/dist/mcp/reply.mjs +1 -1
  87. package/dist/mcp/request.mjs +1 -1
  88. package/dist/mcp/watch.mjs +1 -1
  89. package/dist/rpc/erased.d.mts +2 -2
  90. package/dist/rpc/erased.mjs +4 -4
  91. package/dist/rpc/watch.mjs +3 -3
  92. package/dist/testing/memory.d.mts +1 -1
  93. package/dist/webhook/attempt.mjs +1 -1
  94. package/dist/webhook/receiver.mjs +3 -3
  95. package/dist/webhook/signing.mjs +2 -2
  96. package/dist/webhook/stored.mjs +2 -2
  97. package/dist/webhook/subscriptions.mjs +2 -2
  98. package/docs/Action.md +1 -1
  99. package/docs/setup.md +1 -1
  100. package/package.json +7 -7
@@ -1,3 +1,4 @@
1
+ import { Duration, Effect, Match, Option, Predicate, Schema, Stream } from "effect";
1
2
  import { reasonOf } from "../contract/codes.mjs";
2
3
  import { InvalidInput } from "../contract/errors.mjs";
3
4
  import { defaultNextPoll } from "../contract/feed.mjs";
@@ -10,7 +11,6 @@ import { failingWhenSilent, failingWhenUnanswered, isTransient } from "../contra
10
11
  import { Active, Failed as Failed$1, Heartbeat, Occurred, PollEvents, SubscribeEvents, Terminated, UnsubscribeEvents, WireError, codes } from "./events.mjs";
11
12
  import { McpCallError, NoReply, ProtocolError, StatusError, bodyOf, callError, failWith, framesOf, isEventStream } from "./reply.mjs";
12
13
  import { request } from "./request.mjs";
13
- import { Duration, Effect, Match, Option, Predicate, Schema, Stream } from "effect";
14
14
  // src/mcp/watch.ts
15
15
  const replyOf = (success) => Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Union([Schema.Struct({ result: success }), Schema.Struct({ error: WireError })])));
16
16
  const pollReplyOf = replyOf(PollEvents.successSchema);
@@ -1,3 +1,5 @@
1
+ import { Effect, ErrorReporter, Schema } from "effect";
2
+ import { Rpc, RpcGroup, RpcMiddleware } from "effect/rpc";
1
3
  import "../authentication/provider.mjs";
2
4
  import { Forbidden } from "../contract/errors.mjs";
3
5
  import { Any } from "../Action.mjs";
@@ -10,8 +12,6 @@ import { ErasedValue } from "../contract/implementation.mjs";
10
12
  import "../contract/progress.mjs";
11
13
  import "../contract/watch.mjs";
12
14
  import "../contract/webhooks.mjs";
13
- import { Cause, Duration, Effect, ErrorReporter, Queue, Schema, Stream } from "effect";
14
- import { Rpc, RpcGroup, RpcMiddleware } from "effect/rpc";
15
15
  export declare class DeclaredFailure {
16
16
  readonly [ErrorReporter.ignore] = true;
17
17
  readonly json: Schema.Json;
@@ -1,3 +1,7 @@
1
+ import { Cause, Effect, ErrorReporter, Option, Predicate, Queue, Result, Schema, SchemaTransformation, Stream } from "effect";
2
+ import { HttpClientRequest, HttpServerRequest } from "effect/http";
3
+ import { HttpApiBuilder } from "effect/http-api";
4
+ import { Rpc, RpcGroup } from "effect/rpc";
1
5
  import { providerOf } from "../authentication/provider.mjs";
2
6
  import { checked, checkedStream, decodeInput, sendingJson, sentInput } from "../contract/call.mjs";
3
7
  import { Anyone, principalOf } from "../contract/caller.mjs";
@@ -15,10 +19,6 @@ import { Subscribed, WebhookCancellationOf, WebhookSubscriptionOf, deliveryUnsup
15
19
  import { watching } from "../contract/watch.mjs";
16
20
  import { offersWebhook, servingFeeds, webhookAnswers } from "../contract/webhooks.mjs";
17
21
  import { isUnknownTag, polledTransportOf, streamingOf } from "./watch.mjs";
18
- import { Cause, Effect, ErrorReporter, Option, Predicate, Queue, Result, Schema, SchemaTransformation, Stream } from "effect";
19
- import { HttpClientRequest, HttpServerRequest } from "effect/http";
20
- import { Rpc, RpcGroup } from "effect/rpc";
21
- import { HttpApiBuilder } from "effect/http-api";
22
22
  // src/rpc/erased.ts
23
23
  const streams = (action) => !Answering.$is("Value")(answeringOf(action));
24
24
  const withSyntheticRequestFromHeaders = (headers) => (effect) => effect.pipe(Effect.provideService(HttpServerRequest.HttpServerRequest, HttpServerRequest.fromClientRequest(HttpClientRequest.get("/", { headers }))), Effect.provideService(HttpServerRequest.ParsedSearchParams, {}));
@@ -1,10 +1,10 @@
1
+ import { Cause, Effect, Match, Predicate, Schema, Stream } from "effect";
2
+ import { HttpClientError } from "effect/http";
3
+ import { RpcClientError } from "effect/rpc";
1
4
  import { NotServed, SubscriptionError } from "../Event.mjs";
2
5
  import { readOn } from "../contract/push.mjs";
3
6
  import { deliveryUnsupported } from "../contract/subscribe.mjs";
4
7
  import { isTransientReason, receivedFrom } from "../contract/transient.mjs";
5
- import { Cause, Effect, Match, Predicate, Schema, Stream } from "effect";
6
- import { HttpClientError } from "effect/http";
7
- import { RpcClientError } from "effect/rpc";
8
8
  // src/rpc/watch.ts
9
9
  const isRpcClientError = Schema.is(RpcClientError.RpcClientError);
10
10
  const isAnsweredReason = Schema.is(Schema.Union([
@@ -1,4 +1,4 @@
1
1
  import { Layer } from "effect";
2
- import { HttpClient, HttpRouter, HttpServer } from "effect/http";
2
+ import { HttpRouter, HttpServer } from "effect/http";
3
3
  /** What in-memory routes may leave to the host: the router, the platform, nothing per request. */
4
4
  export type Served = HttpRouter.HttpRouter | HttpRouter.Request<"Requires", never> | HttpRouter.Request<"GlobalRequires", never> | HttpRouter.Request<"Error", unknown> | HttpRouter.Request<"GlobalError", unknown> | Layer.Success<typeof HttpServer.layerServices>;
@@ -1,6 +1,6 @@
1
- import { standardWebhooksSignature } from "./signing.mjs";
2
1
  import { Clock, Data, Duration, Effect, Option, Schema, Stream } from "effect";
3
2
  import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
3
+ import { standardWebhooksSignature } from "./signing.mjs";
4
4
  // src/webhook/attempt.ts
5
5
  var AttemptFailed = class extends Data.TaggedError("AttemptFailed") {};
6
6
  const timeout = Duration.seconds(5);
@@ -1,10 +1,10 @@
1
+ import { Clock, Effect, Option, Predicate, Schema } from "effect";
2
+ import { Base64Url } from "effect/encoding";
3
+ import { HttpServerRequest, HttpServerResponse } from "effect/http";
1
4
  import { signingSecretOf } from "../contract/callback.mjs";
2
5
  import { watchParameter } from "../contract/receiving.mjs";
3
6
  import { makeRecent } from "../contract/recent.mjs";
4
7
  import { constantTimeEqual, standardWebhooksSignature } from "./signing.mjs";
5
- import { Clock, Effect, Option, Predicate, Schema } from "effect";
6
- import { HttpServerRequest, HttpServerResponse } from "effect/http";
7
- import { Base64Url } from "effect/encoding";
8
8
  // src/webhook/receiver.ts
9
9
  const timestampToleranceSeconds = 300;
10
10
  const Body = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Json));
@@ -1,7 +1,7 @@
1
- import { sha256Hex } from "../contract/digest.mjs";
2
1
  import { Effect } from "effect";
3
- import { Base64, Hex } from "effect/encoding";
4
2
  import { Mac } from "effect/crypto";
3
+ import { Base64, Hex } from "effect/encoding";
4
+ import { sha256Hex } from "../contract/digest.mjs";
5
5
  // src/webhook/signing.ts
6
6
  const encoder = new TextEncoder();
7
7
  const hmac = (key, content) => Effect.promise(async () => {
@@ -1,8 +1,8 @@
1
+ import { Cause, Duration, Effect, Option, Queue, Schema, Semaphore } from "effect";
2
+ import { KeyValueStore } from "effect/persistence";
1
3
  import { CallbackUrl, WebhookSecret } from "../contract/callback.mjs";
2
4
  import { reported } from "../contract/reported.mjs";
3
5
  import { DeliveryStatus } from "../contract/subscribe.mjs";
4
- import { Cause, Duration, Effect, Option, Queue, Schema, Semaphore } from "effect";
5
- import { KeyValueStore } from "effect/persistence";
6
6
  // src/webhook/stored.ts
7
7
  const Stored = Schema.Struct({
8
8
  url: CallbackUrl,
@@ -1,3 +1,5 @@
1
+ import { Cause, Clock, Context, Deferred, Duration, Effect, Exit, Fiber, FiberMap, Match, Option, RcMap, Schedule, Schema, Scope, Semaphore, Stream } from "effect";
2
+ import { HttpRouter, HttpServerRequest } from "effect/http";
1
3
  import { canonicalInput } from "../contract/canonical.mjs";
2
4
  import { sentError } from "../contract/codes.mjs";
3
5
  import { CallbackFailed, NotSubscribed, SubscriptionError } from "../Event.mjs";
@@ -8,8 +10,6 @@ import { checkedHost } from "./address.mjs";
8
10
  import { attempt, challenged } from "./attempt.mjs";
9
11
  import { delivering, failingForMs, healthOf, healthTransition, iso, statusOf } from "./health.mjs";
10
12
  import { randomToken, subscriptionId } from "./signing.mjs";
11
- import { Cause, Clock, Context, Deferred, Duration, Effect, Exit, Fiber, FiberMap, Match, Option, RcMap, Schedule, Schema, Scope, Semaphore, Stream } from "effect";
12
- import { HttpRouter, HttpServerRequest } from "effect/http";
13
13
  // src/webhook/subscriptions.ts
14
14
  const minTtl = Duration.minutes(1);
15
15
  const rotationGrace = Duration.minutes(5);
package/docs/Action.md CHANGED
@@ -87,7 +87,7 @@ export const notes = Action.implement(
87
87
  A plain handler, no builder, is [quickstart/src/greeting/handlers.ts](../examples/quickstart/src/greeting/handlers.ts). The builder's rules, once per layer graph, a scope per call, passing the builder to `implement` itself, calling through `Action.client` and never the function you passed, are on `Action.implement`.
88
88
 
89
89
  - **One implementation may hold public and protected actions**, and actions only some surfaces serve: group by domain.
90
- - **Leave a handler's `Effect.fn` unnamed** unless you need handler-only timing. The span named after the action covers authorization, the handler and call cleanup, carrying `action.name` and `action.read_only` on it and its logs. Credential verification and input decoding run before it, so a request they reject has no action span; response encoding runs after it, so it can fail after a successful one.
90
+ - **Leave a handler's `Effect.fn` unnamed** unless you need handler-only timing. The span named after the action covers authorization, the handler and call cleanup, carrying `action.name` and `action.read_only` on it and its logs. A declared error, `Action.Unauthenticated` and `Action.Forbidden` included, is an answer, not a fault: the action span ends without failing and names the error's `_tag` in `error.type` (`_OTHER` for an error without one), so a backend can still find declared answers, while the caller still receives the error; a defect or an interruption fails it. A span the error passes through on its way out, such as a named `Effect.fn` or an `ActionRpc` server span, still fails. Credential verification and input decoding run before it, so a request they reject has no action span; response encoding runs after it, so it can fail after a successful one.
91
91
 
92
92
  ## Authorize calls
93
93
 
package/docs/setup.md CHANGED
@@ -23,7 +23,7 @@ The `effect` peer admits the 4.2.x patches from the oldest whose APIs and behavi
23
23
 
24
24
  Keep the tilde in `package.json`: `^4.2.0`, which npm writes for `effect@4.2.0`, admits a minor release outside the peer range. `npm install effect@~4.2.0` keeps it.
25
25
 
26
- Node `>=26.13.1`: the package's `engines`, the Node the library is developed and tested on. TypeScript 7 or newer. ESM only. The repository checks the examples with a stricter `tsconfig.json`; this is the minimum a project needs. The package's modules resolve only through its `exports`, which `"module": "nodenext"` reads, as a bundler project's `"moduleResolution": "bundler"` does. `"strict": true` is required, by Effect:
26
+ Node `>=26.13.1` per the package's `engines`; the repository's `.node-version` selects the Node release used in CI. TypeScript 7 or newer. ESM only. The repository checks the examples with a stricter `tsconfig.json`; this is the minimum a project needs. The package's modules resolve only through its `exports`, which `"module": "nodenext"` reads, as a bundler project's `"moduleResolution": "bundler"` does. `"strict": true` is required, by Effect:
27
27
 
28
28
  ```json
29
29
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjermundgaraba/effect-actions",
3
- "version": "0.41.1",
3
+ "version": "0.42.0",
4
4
  "description": "Define Effect action contracts once and project them onto HTTP, MCP, Effect RPC, native Toolkits, and CLIs.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -57,17 +57,17 @@
57
57
  "@clanker-stuff/oxlint-config": "0.6.1",
58
58
  "@effect/platform-node": "4.2.0",
59
59
  "@effect/sql-sqlite-node": "4.2.0",
60
- "@effect/tsgo": "0.74.4",
60
+ "@effect/tsgo": "0.74.3",
61
61
  "@effect/vitest": "4.2.0",
62
62
  "@modelcontextprotocol/client": "2.4.0",
63
63
  "@types/node": "26.6.11",
64
64
  "effect": "4.2.0",
65
65
  "tsx": "4.23.15",
66
66
  "typescript": "7.0.2",
67
- "ultracite": "8.3.1",
68
- "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
69
- "vite-plus": "1.8.0",
70
- "vitest": "5.1.1"
67
+ "ultracite": "8.3.2",
68
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.4.0",
69
+ "vite-plus": "1.9.0",
70
+ "vitest": "5.1.2"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "effect": "~4.2.0"
@@ -75,7 +75,7 @@
75
75
  "devEngines": {
76
76
  "packageManager": {
77
77
  "name": "pnpm",
78
- "version": "12.23.0",
78
+ "version": "12.26.0",
79
79
  "onFail": "download"
80
80
  }
81
81
  },