@gjermundgaraba/effect-actions 0.11.0 → 0.13.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/README.md +102 -41
- package/dist/Action.d.mts +31 -117
- package/dist/Action.mjs +14 -53
- package/dist/ActionCli.d.mts +60 -28
- package/dist/ActionCli.mjs +54 -48
- package/dist/ActionHttp.d.mts +18 -67
- package/dist/ActionHttp.mjs +20 -70
- package/dist/ActionMcp.d.mts +23 -29
- package/dist/ActionMcp.mjs +56 -114
- package/dist/ActionRpc.d.mts +147 -0
- package/dist/ActionRpc.mjs +113 -0
- package/dist/ActionToolkit.d.mts +28 -9
- package/dist/ActionToolkit.mjs +31 -4
- package/dist/Authentication.d.mts +15 -15
- package/dist/Authentication.mjs +42 -96
- package/dist/Testing.d.mts +30 -23
- package/dist/Testing.mjs +27 -44
- package/dist/{internal/authentication.d.mts → authentication/provider.d.mts} +41 -9
- package/dist/authentication/provider.mjs +12 -0
- package/dist/authentication/refusal.mjs +36 -0
- package/dist/{internal/cli.d.mts → cli/commands.d.mts} +16 -12
- package/dist/cli/commands.mjs +302 -0
- package/dist/{internal → contract}/call.d.mts +2 -2
- package/dist/contract/call.mjs +10 -0
- package/dist/{internal → contract}/errors.d.mts +13 -10
- package/dist/{internal → contract}/errors.mjs +9 -14
- package/dist/{internal → contract}/implementation.d.mts +37 -21
- package/dist/{internal → contract}/implementation.mjs +18 -49
- package/dist/contract/media.d.mts +13 -0
- package/dist/contract/media.mjs +18 -0
- package/dist/contract/rules.d.mts +25 -0
- package/dist/{internal/actions.mjs → contract/rules.mjs} +6 -42
- package/dist/{internal → http}/client.d.mts +7 -9
- package/dist/http/client.mjs +17 -0
- package/dist/http/declared.mjs +20 -0
- package/dist/http/schema-errors.mjs +9 -0
- package/dist/mcp/protocol.d.mts +18 -0
- package/dist/{internal/mcp.mjs → mcp/protocol.mjs} +29 -62
- package/dist/stdio/console.mjs +64 -0
- package/dist/{internal → testing}/memory.d.mts +1 -1
- package/dist/{internal → testing}/memory.mjs +5 -17
- package/dist/toolkit/tools.mjs +29 -0
- package/docs/Action-failures.md +47 -0
- package/docs/Action-in-process.md +93 -0
- package/docs/Action.md +211 -426
- package/docs/ActionCli-failures.md +104 -0
- package/docs/ActionCli.md +208 -293
- package/docs/ActionHttp-failures.md +83 -0
- package/docs/ActionHttp.md +205 -282
- package/docs/ActionMcp-failures.md +31 -0
- package/docs/ActionMcp.md +222 -271
- package/docs/ActionRpc-failures.md +21 -0
- package/docs/ActionRpc.md +179 -0
- package/docs/ActionToolkit-failures.md +15 -0
- package/docs/ActionToolkit.md +103 -119
- package/docs/Authentication-advanced.md +139 -0
- package/docs/Authentication-failures.md +99 -0
- package/docs/Authentication.md +143 -392
- package/docs/CONTEXT.md +40 -24
- package/docs/README.md +75 -35
- package/docs/Testing-failures.md +21 -0
- package/docs/Testing.md +193 -151
- package/docs/guarantees.md +35 -96
- package/docs/setup-failures.md +37 -0
- package/docs/setup.md +90 -92
- package/examples/README.md +68 -0
- package/examples/assistant/README.md +92 -0
- package/examples/assistant/src/agent.ts +92 -0
- package/examples/assistant/src/cli.ts +34 -0
- package/examples/assistant/src/commands.ts +25 -0
- package/examples/assistant/src/identity/Identity.ts +33 -0
- package/examples/assistant/src/identity/authorize.ts +24 -0
- package/examples/assistant/src/identity/handlers.ts +10 -0
- package/examples/assistant/src/identity/members.ts +9 -0
- package/examples/assistant/src/identity/permissions.ts +23 -0
- package/examples/assistant/src/scripted.ts +23 -0
- package/examples/assistant/src/tasks/Tasks.ts +63 -0
- package/examples/assistant/src/tasks/handlers.ts +25 -0
- package/examples/assistant/src/tasks/store.ts +96 -0
- package/examples/assistant/src/toolkit.ts +30 -0
- package/examples/assistant/test/commands.test.ts +57 -0
- package/examples/assistant/test/identity/identity.test.ts +43 -0
- package/examples/assistant/test/tasks/store.test.ts +48 -0
- package/examples/assistant/test/tasks/tasks.test.ts +75 -0
- package/examples/assistant/test/toolkit.test.ts +121 -0
- package/examples/kitchen-sink/README.md +318 -0
- package/examples/kitchen-sink/src/Actions.ts +19 -0
- package/examples/kitchen-sink/src/Api.ts +24 -0
- package/examples/kitchen-sink/src/Rpc.ts +12 -0
- package/examples/kitchen-sink/src/admin/Admin.ts +59 -0
- package/examples/kitchen-sink/src/admin/authenticate.ts +18 -0
- package/examples/kitchen-sink/src/admin/authorize.ts +27 -0
- package/examples/kitchen-sink/src/admin/grants.ts +22 -0
- package/examples/kitchen-sink/src/admin/handlers.ts +21 -0
- package/examples/kitchen-sink/src/admin/keys.ts +8 -0
- package/examples/kitchen-sink/src/agent.ts +47 -0
- package/examples/kitchen-sink/src/assistant/Assistant.ts +82 -0
- package/examples/kitchen-sink/src/assistant/conversations.ts +71 -0
- package/examples/kitchen-sink/src/assistant/demo-model.ts +33 -0
- package/examples/kitchen-sink/src/assistant/handlers.ts +126 -0
- package/examples/kitchen-sink/src/attachments/Attachments.ts +48 -0
- package/examples/kitchen-sink/src/attachments/download.ts +49 -0
- package/examples/kitchen-sink/src/attachments/handlers.ts +38 -0
- package/examples/kitchen-sink/src/attachments/store.ts +58 -0
- package/examples/kitchen-sink/src/browser.ts +33 -0
- package/examples/kitchen-sink/src/cli.ts +85 -0
- package/examples/kitchen-sink/src/config.ts +18 -0
- package/examples/kitchen-sink/src/identity/Identity.ts +61 -0
- package/examples/kitchen-sink/src/identity/authenticate.ts +87 -0
- package/examples/kitchen-sink/src/identity/authorize.ts +16 -0
- package/examples/kitchen-sink/src/identity/directory.ts +52 -0
- package/examples/kitchen-sink/src/identity/handlers.ts +9 -0
- package/examples/kitchen-sink/src/identity/members.ts +13 -0
- package/examples/kitchen-sink/src/identity/quota.ts +62 -0
- package/examples/kitchen-sink/src/issues/Issues.ts +111 -0
- package/examples/kitchen-sink/src/issues/assistant.ts +23 -0
- package/examples/kitchen-sink/src/issues/guide.ts +37 -0
- package/examples/kitchen-sink/src/issues/handlers.ts +37 -0
- package/examples/kitchen-sink/src/issues/store.ts +96 -0
- package/examples/kitchen-sink/src/issues/write-limit.ts +42 -0
- package/examples/kitchen-sink/src/memory.ts +30 -0
- package/examples/kitchen-sink/src/ops.ts +42 -0
- package/examples/kitchen-sink/src/request-policy.ts +63 -0
- package/examples/kitchen-sink/src/routes.ts +120 -0
- package/examples/kitchen-sink/src/sdk.ts +46 -0
- package/examples/kitchen-sink/src/seed.ts +65 -0
- package/examples/kitchen-sink/src/server.ts +62 -0
- package/examples/kitchen-sink/src/stdio.ts +34 -0
- package/examples/kitchen-sink/src/workspaces/Workspaces.ts +28 -0
- package/examples/kitchen-sink/src/workspaces/handlers.ts +23 -0
- package/examples/kitchen-sink/src/workspaces/registry.ts +46 -0
- package/examples/kitchen-sink/src/workspaces/tenant.ts +17 -0
- package/examples/kitchen-sink/test/admin/admin.test.ts +67 -0
- package/examples/kitchen-sink/test/assistant/assistant.test.ts +435 -0
- package/examples/kitchen-sink/test/attachments/attachments.test.ts +161 -0
- package/examples/kitchen-sink/test/identity/identity.test.ts +137 -0
- package/examples/kitchen-sink/test/identity/session.test.ts +110 -0
- package/examples/kitchen-sink/test/issues/assistant.test.ts +75 -0
- package/examples/kitchen-sink/test/issues/issues.test.ts +135 -0
- package/examples/kitchen-sink/test/request-policy.test.ts +125 -0
- package/examples/kitchen-sink/test/routes.test.ts +123 -0
- package/examples/kitchen-sink/test/support/scripted.ts +40 -0
- package/examples/live-rpc/README.md +107 -0
- package/examples/live-rpc/src/Rpc.ts +8 -0
- package/examples/live-rpc/src/browser.ts +98 -0
- package/examples/live-rpc/src/chat/Chat.ts +77 -0
- package/examples/live-rpc/src/chat/authorize.ts +16 -0
- package/examples/live-rpc/src/chat/handlers.ts +50 -0
- package/examples/live-rpc/src/chat/room.ts +23 -0
- package/examples/live-rpc/src/chat/store.ts +54 -0
- package/examples/live-rpc/src/client.ts +37 -0
- package/examples/live-rpc/src/identity/Identity.ts +19 -0
- package/examples/live-rpc/src/identity/members.ts +8 -0
- package/examples/live-rpc/src/identity/verifier.ts +23 -0
- package/examples/live-rpc/src/routes.ts +22 -0
- package/examples/live-rpc/src/server.ts +43 -0
- package/examples/live-rpc/test/browser.test.ts +105 -0
- package/examples/live-rpc/test/chat/chat.test.ts +69 -0
- package/examples/live-rpc/test/routes.test.ts +99 -0
- package/examples/live-rpc/test/server.test.ts +75 -0
- package/examples/mcp-tools/README.md +141 -0
- package/examples/mcp-tools/src/instructions.ts +12 -0
- package/examples/mcp-tools/src/printers/Printers.ts +121 -0
- package/examples/mcp-tools/src/printers/fake.ts +115 -0
- package/examples/mcp-tools/src/printers/farm.ts +136 -0
- package/examples/mcp-tools/src/printers/handlers.ts +29 -0
- package/examples/mcp-tools/src/routes.ts +52 -0
- package/examples/mcp-tools/src/server.ts +31 -0
- package/examples/mcp-tools/src/stdio.ts +26 -0
- package/examples/mcp-tools/test/printers/printers.test.ts +189 -0
- package/examples/mcp-tools/test/routes.test.ts +202 -0
- package/examples/notes-service/README.md +111 -0
- package/examples/notes-service/src/Api.ts +13 -0
- package/examples/notes-service/src/browser.ts +41 -0
- package/examples/notes-service/src/cli.ts +22 -0
- package/examples/notes-service/src/commands.ts +137 -0
- package/examples/notes-service/src/identity/Identity.ts +31 -0
- package/examples/notes-service/src/identity/authorize.ts +18 -0
- package/examples/notes-service/src/identity/handlers.ts +10 -0
- package/examples/notes-service/src/identity/users.ts +9 -0
- package/examples/notes-service/src/identity/verifier.ts +36 -0
- package/examples/notes-service/src/notes/Notes.ts +119 -0
- package/examples/notes-service/src/notes/handlers.ts +39 -0
- package/examples/notes-service/src/notes/store.ts +84 -0
- package/examples/notes-service/src/routes.ts +45 -0
- package/examples/notes-service/src/server.ts +26 -0
- package/examples/notes-service/src/status/Status.ts +10 -0
- package/examples/notes-service/src/status/handlers.ts +14 -0
- package/examples/notes-service/src/stdio.ts +25 -0
- package/examples/notes-service/test/commands.test.ts +288 -0
- package/examples/notes-service/test/notes/notes.test.ts +103 -0
- package/examples/notes-service/test/routes.test.ts +84 -0
- package/examples/quickstart/README.md +31 -0
- package/examples/quickstart/src/Api.ts +5 -0
- package/examples/quickstart/src/client.ts +13 -0
- package/examples/quickstart/src/greeting/Greeting.ts +12 -0
- package/examples/quickstart/src/greeting/handlers.ts +6 -0
- package/examples/quickstart/src/routes.ts +11 -0
- package/examples/quickstart/src/server.ts +16 -0
- package/examples/quickstart/test/greeting/greeting.test.ts +18 -0
- package/package.json +27 -9
- package/dist/internal/actions.d.mts +0 -9
- package/dist/internal/authentication.mjs +0 -11
- package/dist/internal/call.mjs +0 -12
- package/dist/internal/cli.mjs +0 -328
- package/dist/internal/client.mjs +0 -25
- package/dist/internal/console.mjs +0 -77
- package/dist/internal/declared.d.mts +0 -13
- package/dist/internal/declared.mjs +0 -34
- package/dist/internal/mcp.d.mts +0 -14
- package/dist/internal/media.d.mts +0 -8
- package/dist/internal/media.mjs +0 -26
- package/dist/internal/refusal.mjs +0 -67
- package/dist/internal/schema-errors.mjs +0 -20
- package/dist/internal/tools.mjs +0 -44
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# ActionHttp failure modes
|
|
2
|
+
|
|
3
|
+
What you see when something is wrong, and the fix. Search for a fragment of the message.
|
|
4
|
+
The tasks are in [ActionHttp.md](ActionHttp.md).
|
|
5
|
+
|
|
6
|
+
## Binding and serving
|
|
7
|
+
|
|
8
|
+
- A route returns 404, which a client method reports as an `HttpClientError` with `DecodeError`
|
|
9
|
+
or `StatusCodeError`: the path lacks the prefix, no `layer` call serves the action, or the
|
|
10
|
+
binding does not hold that very action value, as when a test declares the contract again.
|
|
11
|
+
- `No action of these implementations is in this HTTP binding: x`,
|
|
12
|
+
`Listed in actions, but the binding does not hold it: <names>` or
|
|
13
|
+
`but no implementation holds it`, thrown by `layer`: the binding, the implementations and
|
|
14
|
+
`actions` are matched by action value, never by name. `x (another contract)` is an action of a
|
|
15
|
+
bound name that is not the bound value, as a second copy of the contracts module makes.
|
|
16
|
+
- `Duplicate served action: <name>` thrown by `layer`, or
|
|
17
|
+
`Method 'POST' already declared for route '<prefix>/<action>'` when the host builds: an action
|
|
18
|
+
is served once. One `layer` call got two implementations of it, or two calls serve it: give
|
|
19
|
+
each layer its own `actions`.
|
|
20
|
+
- `Duplicate action: <name>` thrown by `make`: two actions share a name, or one is listed twice.
|
|
21
|
+
Rename one, or bind it under another prefix.
|
|
22
|
+
- `ActionHttp binding: error _tag "Forbidden" is built in, and declared on every surface` thrown by
|
|
23
|
+
`make`: a binding error is a built-in error or reuses its tag. Drop it, or rename your own.
|
|
24
|
+
- `Duplicate OpenAPI operationId: <name>` from `OpenApi.fromApi`, or a combined document or
|
|
25
|
+
native client lacking one binding's actions: bindings combined into one `HttpApi` need distinct
|
|
26
|
+
action names and distinct prefixes. Rename or re-prefix one, or document each binding alone.
|
|
27
|
+
- `Service not found: effect-actions/Authentication/Security/…` when the host builds: a binding
|
|
28
|
+
holding a protected action is served with the native `HttpApiBuilder`. Serve it with `layer`.
|
|
29
|
+
- Swagger shows no Authorize button: the binding holds no protected action.
|
|
30
|
+
|
|
31
|
+
## Types
|
|
32
|
+
|
|
33
|
+
- `No overload matches this call` at `make`, naming
|
|
34
|
+
`"Protected actions take options naming their authentication"`, or a type error naming
|
|
35
|
+
`authentication`: give `{ authentication: Login }`. Do not silence it with
|
|
36
|
+
`caller: Action.Anyone`.
|
|
37
|
+
- `Argument of type 'Options<…> | undefined' is not assignable` at `make`: a helper forwards
|
|
38
|
+
options that may be absent. Pass `options ?? {}`.
|
|
39
|
+
- `Provider<…>` among the layer's requirements, or
|
|
40
|
+
`Type 'Provider<...>' is not assignable to type 'never'` where the server is launched: provide
|
|
41
|
+
the descriptor's provider ([Authentication-failures.md](Authentication-failures.md)).
|
|
42
|
+
- `Authentication "<name>": the binding's descriptor is not its provider's`, a defect when `layer`
|
|
43
|
+
builds: build the binding and its provider from one descriptor.
|
|
44
|
+
- `Type 'X' is not assignable to type 'never'` where the server is launched, or
|
|
45
|
+
`Request<"Requires", X>` in the layer's type: a handler, an authorizer or a layer middleware
|
|
46
|
+
reads a request service `X` that nothing around the layer provides, or router middleware
|
|
47
|
+
provides `X` and is not declared `HttpRouter.middleware<{ provides: X }>()`
|
|
48
|
+
([Serve the routes](ActionHttp.md#serve-the-routes)). Where `X` is the identity, a public
|
|
49
|
+
handler reads it, or a layer whose middleware requires it serves public actions: make the
|
|
50
|
+
action protected, or serve the protected actions from a layer of their own.
|
|
51
|
+
- Type error on `middleware` naming
|
|
52
|
+
`"Layer middleware fails only with the binding's errors and needs no client"`: add the error to
|
|
53
|
+
the binding's `error`, given inline so its type is certain, or move the check to the handlers
|
|
54
|
+
and declare the error on their actions.
|
|
55
|
+
|
|
56
|
+
## Requests
|
|
57
|
+
|
|
58
|
+
- A route answers without credentials: its contract is `caller: Action.Anyone`.
|
|
59
|
+
- A protected route answers 401 to a request with no content type or invalid input:
|
|
60
|
+
authentication runs before the body is read. Send the token.
|
|
61
|
+
- 400 `InvalidInput` on a valid-looking request: its `message` names each field that did not
|
|
62
|
+
decode or the action does not declare, such as a misspelling. An action without input takes
|
|
63
|
+
only `{}`, and needs a body.
|
|
64
|
+
- 415 `Unsupported content-type: <type>` (`none` without one): the request is not typed as JSON,
|
|
65
|
+
such as `fetch`'s default `text/plain` for a string body. Send `Content-Type: application/json`.
|
|
66
|
+
- Empty 500: a defect, or a handler result not matching the success schema. The cause is in the
|
|
67
|
+
server's logs, written by its request logger, and under `Testing.layer` in the test's, as an error.
|
|
68
|
+
|
|
69
|
+
## Client methods
|
|
70
|
+
|
|
71
|
+
- `HttpClientError` whose `reason._tag` is `DecodeError`, printed `Decode error (<status> …)`,
|
|
72
|
+
for a status such as 429: no schema declares that status. For a 500, see the empty 500 above. Declare the error on the binding when middleware answers with it, or on
|
|
73
|
+
the action when its handler does.
|
|
74
|
+
- `HttpClientError` whose `reason._tag` is `InvalidUrlError` outside a browser: relative routes
|
|
75
|
+
have no page to resolve against. Set `baseUrl`.
|
|
76
|
+
- Type error listing `HttpClient` as an unsatisfied requirement: provide one, such as
|
|
77
|
+
`FetchHttpClient.layer`, or use `fetchClient`.
|
|
78
|
+
- `Expected 1 arguments` at a client method: `{}` is not a valid input for the action, so pass
|
|
79
|
+
its input. Where the argument may be omitted, leave it out: `undefined` is a type error.
|
|
80
|
+
- Type error passing `{ payload: ... }` to a client method: `payload` is the native client's
|
|
81
|
+
shape. Pass the input itself.
|
|
82
|
+
- `InvalidInput` `Expected Filters` given a plain object: the input is a class, which encodes
|
|
83
|
+
only its instances. Pass `new Filters({ ... })`.
|