@acid-cat/cli 0.14.0 → 0.16.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 +64 -32
- package/dist/conform/check.d.ts +6 -2
- package/dist/conform/check.js +22 -3
- package/dist/conform/cli.js +283 -253
- package/dist/conform/http.js +10 -21
- package/dist/conform/index.d.ts +9 -1
- package/dist/conform/index.js +8 -2
- package/dist/conform/mcp-stdio.js +1 -19
- package/dist/conform/mcp.js +10 -21
- package/dist/conform/poll.d.ts +3 -3
- package/dist/conform/poll.js +51 -26
- package/dist/conform/properties.d.ts +0 -1
- package/dist/conform/properties.js +1 -1
- package/dist/conform/webhook.d.ts +4 -1
- package/dist/conform/webhook.js +20 -8
- package/dist/conform/webmcp.js +0 -5
- package/dist/json/package.json.js +1 -1
- package/dist/main.js +11 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,78 +1,112 @@
|
|
|
1
1
|
# @acid-cat/cli
|
|
2
2
|
|
|
3
|
-
The AcidCat command line
|
|
3
|
+
The AcidCat command line, published on npm as `@acid-cat/cli`. It gives the `acid-cat` command, which checks catalogs and tests implementations. Run it at build time, in CI or by hand. Do not use it in an application at run time.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
acid-cat check [--strict] [--output json] <catalog.json ...> # check catalogs
|
|
7
7
|
acid-cat format [--write] <catalog.json ...> # write catalogs in canonical form
|
|
8
8
|
acid-cat view <catalog.json> <target> # write the view of one target
|
|
9
9
|
acid-cat conform --mcp <url> [--mcp-handshake] --mcp-stdio "<command>" --http <url> --cli "<command>" --webmcp <url> [--deadline <ms>] [--max-bytes <n>] [--output json] # test an implementation
|
|
10
|
-
[--poll-buffer <n>] [--poll-lease-ms <ms>] [--webhook-principal <name> --webhook-cert <file> --webhook-key <file>]
|
|
10
|
+
[--poll-buffer <n>] [--poll-lease-mcp <url> --poll-lease-ms <ms>] [--webhook-principal <name> --webhook-cert <file> --webhook-key <file>]
|
|
11
11
|
[--webhook-other-principal <name>] [--webhook-min-ttl-ms <ms>] [--webhook-max-ttl-ms <ms>] [--webhook-max-subscriptions <n>]
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
## Install
|
|
15
|
+
|
|
14
16
|
Install it as a development dependency, and run it with `pnpm exec acid-cat …`:
|
|
15
17
|
|
|
16
18
|
```sh
|
|
17
19
|
pnpm add -D @acid-cat/cli
|
|
18
20
|
```
|
|
19
21
|
|
|
20
|
-
It
|
|
22
|
+
It needs Node.js 24 or later. `acid-cat conform --webmcp <url>` also needs [Playwright](https://playwright.dev) and Chromium.
|
|
23
|
+
|
|
24
|
+
`acid-cat` ignores a first argument `--`, which package runners such as `pnpm` and `npx` pass to it: `pnpm acid-cat -- check` is `acid-cat check`.
|
|
21
25
|
|
|
22
26
|
## Output
|
|
23
27
|
|
|
24
|
-
`check` and `conform` take `--output human` (the default) or `--output json`. Human output is text for a person. JSON output is one JSON document on standard output, for a script or an agent
|
|
28
|
+
`check` and `conform` take `--output human` (the default) or `--output json`. Human output is text for a person. JSON output is one JSON document on standard output, for a script or an agent, and nothing on standard error. The exit code is the same in both modes.
|
|
25
29
|
|
|
26
30
|
- `check`: `{ "conforms": boolean, "catalogs": [{ "file", "errors": [string], "warnings": [string] }] }`. `conforms` is `false` when the exit code is 1. A file that cannot be read, or that is not JSON, is a catalog with one error.
|
|
27
|
-
- `conform`: `{ "passed": number, "failed": number, "warnings": number, "checks": [{ "binding", "name", "rule", "passed", "warning"?, "detail"? }] }`. A check with a warning has `"passed": true` and `"warning": true`, and counts in `passed` and
|
|
31
|
+
- `conform`: `{ "passed": number, "failed": number, "warnings": number, "checks": [{ "binding", "name", "rule", "passed", "warning"?, "detail"? }] }`. A check with a warning has `"passed": true` and `"warning": true`, and counts in both `passed` and `warnings`.
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
You get the JSON document only when the options are correct. With incorrect options, the exit code is 1, and standard output can hold the help text. `conform` writes one line of text to standard error, and nothing to standard output, when it gets no binding, only some of the `--webhook-*` options, or a certificate file that it cannot read.
|
|
30
34
|
|
|
31
35
|
## check
|
|
32
36
|
|
|
33
|
-
`check` tests a catalog against [`schemas/catalog.schema.json`](../../schemas/catalog.schema.json) and against the [catalog rules](../../spec/conformance.md#catalog) that the schema cannot express.
|
|
37
|
+
`check` tests a catalog against [`schemas/catalog.schema.json`](../../schemas/catalog.schema.json) and against the [catalog rules](../../spec/conformance.md#catalog) that the schema cannot express. It reports two levels:
|
|
34
38
|
|
|
35
39
|
- An **error** is a broken rule. Examples: an audience that names an unknown target, an event payload that is not an object, or an id that is both a capability and an event.
|
|
36
40
|
- A **warning** is a broken recommendation. Examples: a file that is not in [canonical form](../../spec/catalog.md#canonical-form), or a member with no `x-` prefix.
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
It also checks each alias in `options.cli` against the [alias rules](../../spec/bindings/cli.md#aliases).
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
The exit code is 0 if there are no errors. It is 1 if there are errors. With `--strict`, warnings also give the exit code 1.
|
|
44
|
+
The exit code is 1 with errors, and 0 otherwise. With `--strict`, warnings also give exit code 1.
|
|
43
45
|
|
|
44
46
|
## format
|
|
45
47
|
|
|
46
|
-
`format` writes a catalog in canonical form. Use it for catalogs that
|
|
48
|
+
`format` writes a catalog in [canonical form](../../spec/catalog.md#canonical-form). Use it for catalogs that no catalog library wrote: Pkl output, generated files, or files you edit by hand. `--write` changes the files in place.
|
|
47
49
|
|
|
48
50
|
## view
|
|
49
51
|
|
|
50
|
-
`view` writes the [view](../../spec/catalog.md#views) of one target: the capabilities and
|
|
52
|
+
`view` writes the [view](../../spec/catalog.md#views) of one target: the capabilities, events and types that the target can use.
|
|
51
53
|
|
|
52
54
|
## conform
|
|
53
55
|
|
|
54
|
-
`conform` tests a running implementation of the [conformance fixture](conformance/fixture.pkl) through its bindings
|
|
56
|
+
`conform` tests a running implementation of the [conformance fixture](conformance/fixture.pkl) through its bindings. Each AcidCat core runs it in its tests.
|
|
57
|
+
|
|
58
|
+
### Options
|
|
59
|
+
|
|
60
|
+
Each flag has an equivalent option for `conform()` in code. Give one or more bindings.
|
|
61
|
+
|
|
62
|
+
| Flag | In code | What it does |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| `--mcp <url>` | `mcp` | Test the MCP binding through HTTP |
|
|
65
|
+
| `--mcp-handshake` | `mcpHandshake: true` | Also test the [`initialize` handshake of earlier revisions](../../spec/bindings/mcp.md#earlier-revisions-through-http) through HTTP |
|
|
66
|
+
| `--mcp-stdio "<command>"` | `mcpStdio` | Test the MCP binding through stdio. Each check starts the server as a process |
|
|
67
|
+
| `--http <url>` | `http` | Test the HTTP binding. The URL is the base URL, before `/capabilities` |
|
|
68
|
+
| `--cli "<command>"` | `cli` | Test the CLI binding |
|
|
69
|
+
| `--webmcp <url>` | `webmcp` | Test the WebMCP binding on a page that serves the `app` target. In code, `webmcp` can also be a function that installs the implementation on a host in the same process |
|
|
70
|
+
| `--deadline <ms>` | `deadline` | The deadline of each check. The default is 30 000 |
|
|
71
|
+
| `--max-bytes <n>` | `maximumBytes` | The body limit of the remote bindings, in bytes. The default is 1 048 576 |
|
|
72
|
+
| `--poll-buffer <n>` | `poll.bufferLimit` | The deployment's poll buffer size, from 1 to 97 |
|
|
73
|
+
| `--poll-lease-mcp <url>`, `--poll-lease-ms <ms>` | `pollLease: { mcp, leaseMs }` | An MCP server through HTTP with a poll lease time shorter than the deadline, and that lease time. Give both together |
|
|
74
|
+
| `--webhook-principal <name>`, `--webhook-cert <file>`, `--webhook-key <file>` | `webhook: { principal, cert, key }`, with the PEM text | Test webhook delivery. Give all three together |
|
|
75
|
+
| `--webhook-min-ttl-ms <ms>`, `--webhook-max-ttl-ms <ms>` | `webhook.minTtlMs`, `webhook.maxTtlMs` | The deployment's webhook lifetimes. The defaults are the specification's: 60 000 and 3 600 000 |
|
|
76
|
+
| `--webhook-max-subscriptions <n>` | `webhook.maxSubscriptions` | The deployment's limit of webhook subscriptions for one principal |
|
|
77
|
+
| `--webhook-other-principal <name>` | `webhook.otherPrincipal` | A second principal, for `Authorization: Bearer <name>` |
|
|
78
|
+
| `--output json` | | Write the result as JSON (see [Output](#output)) |
|
|
79
|
+
|
|
80
|
+
### What the checks test
|
|
55
81
|
|
|
56
|
-
|
|
57
|
-
- **MCP through stdio:** `--mcp-stdio "<command>"`, or `mcpStdio` in code. The checks start the server as a process. The official MCP client tests the tools and outcomes two times: with revision `2026-07-28`, and with the `initialize` handshake of revision `2025-11-25`. It also tests `notifications/tools/list_changed` and `notifications/cancelled`. Raw lines test the version negotiation, a line that is not JSON, a standard output with only JSON-RPC messages, and the end of standard input.
|
|
58
|
-
- **HTTP** and **CLI:** each outcome, each kind of call failure, availability, and rejections. For the CLI, also each kind of flag, including a repeated flag that gives one item of an array for each occurrence, or the whole array as JSON text, and the usage line of each command and of each event, with `[--cursor <string>] [--max-age-ms <integer>]`. The help of a command, an alias and an event must be `Usage: ` and the usage, an empty line, and the description. The help of a shared prefix must be its command list on standard output, and a shared prefix alone or with a flag that is not `--help` must write the same list to standard error, with exit code 2. An interrupt (`SIGINT`) during a call that holds gives exit code 130, and the call must end and delete its marker file. `watch --cursor` starts after the cursor, and a `--max-age-ms` that is not an integer gives exit code 3.
|
|
59
|
-
- **WebMCP:** the checks act as the WebMCP host. `--webmcp <url>` opens a page that serves the `app` target in Chromium, through [Playwright](https://playwright.dev), with a test `modelContext`. Install Playwright to use it: `pnpm add -D playwright`, then `pnpm exec playwright install chromium`. In code, `webmcp` can also be a function that installs the implementation on a host in the same process.
|
|
60
|
-
- **Events:** through HTTP, MCP with each transport, and the CLI. The checks examine the list of the events of the view, the call failures before the first occurrence (an event outside the view, and invalid input), each occurrence against `schemas/occurrence.schema.json` and the payload schema, the order of the occurrences, an occurrence with `truncated: true` (`fixture.ticks` with `gap`: `truncated` in the occurrence through HTTP and the CLI, `notifications/events/active` with `truncated: true` and the cursor before the event through MCP push, and a result with `truncated: true` through MCP poll), the cursor, each end of a subscription (complete and `internal`), and cancellation. Through MCP, they also examine `server/discover`, `events/list` with the delivery modes of the server, `notifications/events/active`, and the subscription id of each message. With `--mcp-handshake`, `initialize` must not declare the events extension. Through WebMCP, no event is a tool.
|
|
61
|
-
- **Poll delivery:** through MCP with each transport, when `events/list` gives `poll`. If not, the checks give a warning, and `events/poll` must answer `Unsupported`. The checks test each row of the table of [Poll](../../spec/bindings/mcp.md#poll): no cursor with no lease and with a lease, a cursor of the lease, a cursor of another lease with and without a lease of the key, a cursor of push delivery, and a cursor of another lease that has a cursor of the provider, which resumes after it. They also test the form of each result, `maxEvents` and `hasMore`, a `maxEvents` that is not valid, the failures before the first occurrence, which start no lease, and the error `-32603` after a defect. With `--poll-buffer <n>`, or `poll.bufferLimit` in code, they test a cursor older than the buffer: `n` is the buffer size of the deployment, from 1 to 97. With `--poll-lease-ms <ms>`, or `poll.leaseMs`, they test that a lease with no poll ends, and cancels its subscription. The lease time must be shorter than the deadline. A check makes other requests between two polls of a lease, so give a lease time of some seconds, for example 5 seconds. A shorter lease can end between two polls on a busy computer, and the check then fails. Each check uses a new key in its input, so the leases of an earlier run do not change the result.
|
|
62
|
-
- **Webhook delivery:** through MCP over HTTP, with `--webhook-principal <name>`, `--webhook-cert <file>` and `--webhook-key <file>` together, or `webhook: { principal, cert, key }` in code, with the PEM text. The checks run an HTTPS receiver on `127.0.0.1` with this certificate. Configure the deployment under test for the test: it trusts the certificate, allows deliveries to private addresses, and gives the principal `<name>` to a request with the header `Authorization: Bearer <name>`. The checks test `Forbidden` with no principal, `-32602` for a URL that is not `https` and for a secret that is not valid, the verification and `challenge_failed`, the form of the result of `events/subscribe` and its subscription id, the headers, the signature and the body of each delivery, the order of the deliveries, a renewal that signs with the old and the new secret, `events/unsubscribe` and a second `events/unsubscribe`, a retry with the same `webhook-id` after a status 500, a 410 that abandons a delivery, the control message `gap` with the watermark before an occurrence with `truncated: true`, the control message `terminated`, and the lifetime that the server grants for a `ttlMs` below the minimum, above the maximum, `null` and absent.
|
|
63
|
-
- `--webhook-min-ttl-ms <ms>` and `--webhook-max-ttl-ms <ms>`, or `webhook.minTtlMs` and `webhook.maxTtlMs`, give the lifetimes of the deployment. The defaults are those of the specification: 60 000 and 3 600 000. With `--webhook-min-ttl-ms`, which must be shorter than the deadline, the checks also test that a subscription with no renewal ends at the end of its lifetime, and gets no more deliveries.
|
|
64
|
-
- `--webhook-max-subscriptions <n>`, or `webhook.maxSubscriptions`, gives the limit of subscriptions of one principal. With it, the checks subscribe until the server answers `ResourceExhausted` (`-32025`, with `data: { limit: "subscriptions", max }`), then renew one subscription.
|
|
65
|
-
- `--webhook-other-principal <name>`, or `webhook.otherPrincipal`, gives a second principal, for `Authorization: Bearer <name>`. With it, the check of the limit fills the subscriptions of this principal, which no other check uses, so it expects exactly `n` subscriptions, and then tests that the first principal can still subscribe. Without it, the check uses the first principal, which can still have subscriptions of other checks. The retry check waits for the first retry of the deployment, so the deadline must be longer than that wait. Without these options, a server that does not list `webhook` must answer `events/subscribe` and `events/unsubscribe` with `Unsupported`. Through stdio, it must always do so.
|
|
66
|
-
- **Hints:** through MCP with each transport, each tool has `readOnlyHint`, `destructiveHint` and `idempotentHint` as the `readOnly`, `destructive` and `idempotent` of its capability. When a capability has no hint, the tool has no annotation or the MCP default.
|
|
67
|
-
- **Properties:** with fast-check, through MCP with each transport and through HTTP: concurrent calls each get exactly their own outcome, and a cancellation changes only its own call.
|
|
82
|
+
[`acid-cat conform`](../../spec/conformance.md#acid-cat-conform) lists every check. In short:
|
|
68
83
|
|
|
69
|
-
|
|
84
|
+
- MCP through HTTP and stdio: The official MCP client tests the tools and outcomes with revision `2026-07-28`, and with the `initialize` handshake of `2025-11-25` through stdio, or through HTTP with `--mcp-handshake`. Raw requests test rejections. Through stdio, raw lines also test version negotiation, lines that are not JSON, a clean standard output and the end of standard input.
|
|
85
|
+
- HTTP and CLI: Each outcome, each kind of call failure, availability and rejections. For the CLI: each kind of flag, usage lines, help, shared prefixes, aliases, interrupts with exit code 130, and `watch --cursor`.
|
|
86
|
+
- WebMCP: The checks act as the host: they open the page in Chromium through [Playwright](https://playwright.dev) with a test `modelContext`. Install it first: `pnpm add -D playwright`, then `pnpm exec playwright install chromium`.
|
|
87
|
+
- Events: Through HTTP, MCP and the CLI: the list of events, failures before the first occurrence, each occurrence against `schemas/occurrence.schema.json` and its payload schema, order, `truncated`, the cursor, each end, and cancellation. Through WebMCP, no event is a tool.
|
|
88
|
+
- [Poll delivery](../../spec/bindings/mcp.md#poll): Through MCP, when `events/list` gives `poll`. Otherwise the check gives a warning and `events/poll` must answer `Unsupported`. `--poll-buffer` adds a cursor older than the buffer. The lease time of `--mcp` and `--mcp-stdio` must be longer than the deadline, because a check uses a lease for its whole time. `--poll-lease-mcp` with `--poll-lease-ms` adds the end of an unused lease. Serve it from a second MCP server with a lease time shorter than the deadline, for example 1000.
|
|
89
|
+
- [Webhook delivery](../../spec/bindings/mcp.md#webhook): Through MCP over HTTP, with the three `--webhook-*` options. The checks run an HTTPS receiver on `127.0.0.1` with that certificate. Configure the deployment to trust the certificate, allow deliveries to private addresses, and give the principal `<name>` to a request with `Authorization: Bearer <name>`. The deadline must be longer than the deployment's first retry wait, and the maximum lifetime must be longer than the deadline. Give `--webhook-other-principal` with `--webhook-max-subscriptions`: the limit check then fills a principal that no other check uses. Without the webhook options, a server that does not list `webhook` must answer `Unsupported`.
|
|
90
|
+
- [Hints](../../spec/bindings/mcp.md#tools): Each MCP tool's annotations match its capability's hints.
|
|
91
|
+
- Properties: With fast-check, through MCP and HTTP: concurrent calls each get their own outcome, and a cancellation changes only its own call.
|
|
70
92
|
|
|
71
|
-
|
|
93
|
+
Each poll check uses a new key, so leases from an earlier run do not change the result.
|
|
94
|
+
|
|
95
|
+
### Waiting and deadlines
|
|
96
|
+
|
|
97
|
+
The checks wait for states they can observe, such as `fixture.held`, `fixture.watching` or a marker file, never for a fixed time. Each check has one deadline (`--deadline`, or `deadline` in code). A check that does not settle in time fails with "did not settle" and stops what it started, under a second deadline of the same length, so `conform` always returns. The deadline never makes a check pass.
|
|
98
|
+
|
|
99
|
+
### Result
|
|
100
|
+
|
|
101
|
+
A failed check of a SHOULD rule gives a warning, marked `!`, and passes. The exit code is 1 if a check fails.
|
|
102
|
+
|
|
103
|
+
### Use it in code
|
|
104
|
+
|
|
105
|
+
`conform()` and `serve()` come from `@acid-cat/cli`, and `createTestHost()` gives the WebMCP host that the checks use. This `serve()` is for tests only: it listens on `127.0.0.1`, on a free port, with plain HTTP. To serve an application, use its core's server: `serve` from `@acid-cat/core-ts/node`, `NodeServer` from `@acid-cat/core-effect`, or `remote::serve` from the crate `acid-cat-core`.
|
|
72
106
|
|
|
73
107
|
## Implementation
|
|
74
108
|
|
|
75
|
-
The command line is an [Effect](https://effect.website) program
|
|
109
|
+
The command line is an [Effect](https://effect.website) program built on `effect/cli`. It validates catalogs with Effect Schema, and imports `schemas/catalog.schema.json` and each schema in the catalog as Effect schemas. The canonical writer comes from [`@acid-cat/catalog`](../catalog/typescript).
|
|
76
110
|
|
|
77
111
|
| File | Contents |
|
|
78
112
|
| --- | --- |
|
|
@@ -81,7 +115,5 @@ The command line is an [Effect](https://effect.website) program that uses `effec
|
|
|
81
115
|
| `src/conform/` | The conformance checks, and `serve`, which serves web handlers on a local port for the tests |
|
|
82
116
|
| `conformance/` | The conformance fixture, in Pkl and in JSON |
|
|
83
117
|
| `test/` | Tests. Run them with `moon run cli:test` |
|
|
84
|
-
| `test/fixtures/` | The catalog
|
|
118
|
+
| `test/fixtures/` | The test catalog: a bakery, in canonical form, with capabilities and an event |
|
|
85
119
|
| `test/fixtures/rejected/` | Catalogs that `check` must reject, written by hand |
|
|
86
|
-
|
|
87
|
-
The canonical writer comes from [`@acid-cat/catalog`](../catalog/typescript).
|
package/dist/conform/check.d.ts
CHANGED
|
@@ -16,14 +16,17 @@ export declare const idsOf: (target: string) => string[];
|
|
|
16
16
|
export declare const eventIdsOf: (target: string) => string[];
|
|
17
17
|
export declare function expectOccurrence(value: unknown, id: string): Occurrence;
|
|
18
18
|
export declare const DEADLINE = 30000;
|
|
19
|
+
type Body = (signal: AbortSignal) => Promise<void> | void;
|
|
20
|
+
export type Define = (name: string, rule: string, body: Body) => void;
|
|
19
21
|
export declare class Checks {
|
|
20
22
|
#private;
|
|
21
23
|
readonly results: Check[];
|
|
22
24
|
readonly binding: string;
|
|
23
25
|
readonly deadline: number;
|
|
24
26
|
constructor(binding: string, deadline: number);
|
|
25
|
-
run(name: string, rule: string, body:
|
|
26
|
-
|
|
27
|
+
run(name: string, rule: string, body: Body): Promise<void>;
|
|
28
|
+
concurrently(define: (check: Define) => void): Promise<void>;
|
|
29
|
+
should(name: string, rule: string, body: Body): Promise<void>;
|
|
27
30
|
}
|
|
28
31
|
export declare function until<T, Done extends T>(what: string, read: () => Promise<T>, done: (value: T) => value is Done, signal: AbortSignal): Promise<Done>;
|
|
29
32
|
export declare function until<T>(what: string, read: () => Promise<T>, done: (value: T) => boolean, signal: AbortSignal): Promise<T>;
|
|
@@ -32,3 +35,4 @@ export declare function expect(condition: unknown, message: string): asserts con
|
|
|
32
35
|
export declare function expectEqual(actual: unknown, expected: unknown, what: string): void;
|
|
33
36
|
export declare const sorted: (values: Iterable<string>) => string[];
|
|
34
37
|
export declare const FORBIDDEN_ORIGIN = "https://not-allowed.acid-cat.invalid";
|
|
38
|
+
export {};
|
package/dist/conform/check.js
CHANGED
|
@@ -2,6 +2,7 @@ import fixture_acidcat_default from "../json/fixture.acidcat.json.js";
|
|
|
2
2
|
import { isObject } from "../json.js";
|
|
3
3
|
import { CALL_FAILURE_KINDS, isOccurrence, viewOf } from "@acid-cat/spec-ts";
|
|
4
4
|
import { Schema, SchemaRepresentation } from "effect";
|
|
5
|
+
import { availableParallelism } from "node:os";
|
|
5
6
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
6
7
|
// src/conform/check.ts
|
|
7
8
|
/** The conformance fixture: the catalog that each implementation serves. */
|
|
@@ -49,8 +50,25 @@ var Checks = class {
|
|
|
49
50
|
this.deadline = deadline;
|
|
50
51
|
}
|
|
51
52
|
async run(name, rule, body) {
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
this.results.push(this.#result(name, rule, await this.#settle(body)));
|
|
54
|
+
}
|
|
55
|
+
async concurrently(define) {
|
|
56
|
+
const defined = [];
|
|
57
|
+
define((name, rule, body) => defined.push({
|
|
58
|
+
name,
|
|
59
|
+
rule,
|
|
60
|
+
body
|
|
61
|
+
}));
|
|
62
|
+
const queue = defined.entries();
|
|
63
|
+
const settled = [];
|
|
64
|
+
const worker = async () => {
|
|
65
|
+
for (const [index, { name, rule, body }] of queue) settled.push([index, this.#result(name, rule, await this.#settle(body))]);
|
|
66
|
+
};
|
|
67
|
+
await Promise.all(Array.from({ length: availableParallelism() }, worker));
|
|
68
|
+
this.results.push(...settled.sort(([a], [b]) => a - b).map(([, check]) => check));
|
|
69
|
+
}
|
|
70
|
+
#result(name, rule, failure) {
|
|
71
|
+
return failure === void 0 ? {
|
|
54
72
|
binding: this.binding,
|
|
55
73
|
name,
|
|
56
74
|
rule,
|
|
@@ -61,7 +79,7 @@ var Checks = class {
|
|
|
61
79
|
rule,
|
|
62
80
|
passed: false,
|
|
63
81
|
detail: failure
|
|
64
|
-
}
|
|
82
|
+
};
|
|
65
83
|
}
|
|
66
84
|
async should(name, rule, body) {
|
|
67
85
|
const failure = await this.#settle(body);
|
|
@@ -90,6 +108,7 @@ var Checks = class {
|
|
|
90
108
|
return controller.signal.aborted ? `did not settle within ${this.deadline} ms: ${message}` : message;
|
|
91
109
|
} finally {
|
|
92
110
|
clearTimeout(timer);
|
|
111
|
+
controller.abort();
|
|
93
112
|
}
|
|
94
113
|
}
|
|
95
114
|
};
|