@hecks/client 4.0.0 → 6.0.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 +10 -7
- package/dist/answer.d.ts +28 -0
- package/dist/answer.js.map +1 -1
- package/dist/client.d.ts +22 -1
- package/dist/client.js +50 -3
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ The package is ESM and ships its type declarations.
|
|
|
52
52
|
## Use
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
|
-
import { HostClient
|
|
55
|
+
import { HostClient } from "@hecks/client";
|
|
56
56
|
|
|
57
57
|
const client = new HostClient({
|
|
58
58
|
domain: "Shop",
|
|
@@ -66,17 +66,17 @@ const answer = await client.read();
|
|
|
66
66
|
// One aggregate's states, as [id, state] pairs.
|
|
67
67
|
const events = client.instancesOf(answer, "Event").map(([id, state]) => ({
|
|
68
68
|
id,
|
|
69
|
-
name:
|
|
70
|
-
priceCents:
|
|
69
|
+
name: state.name, // a one-field value object answers bare: "Yoga"
|
|
70
|
+
priceCents: state.price, // 10800
|
|
71
71
|
}));
|
|
72
72
|
|
|
73
73
|
// A command, judged by the state that comes back.
|
|
74
74
|
const repriced = await client.apply({
|
|
75
75
|
verb: "Event.Reprice",
|
|
76
76
|
to: "yoga-1",
|
|
77
|
-
with: { price:
|
|
77
|
+
with: { price: 12000 },
|
|
78
78
|
parse: (answer) => client.instancesOf(answer, "Event"),
|
|
79
|
-
confirm: (states) => states.find(([id]) => id === "yoga-1")?.[1].price
|
|
79
|
+
confirm: (states) => states.find(([id]) => id === "yoga-1")?.[1].price === 12000,
|
|
80
80
|
});
|
|
81
81
|
```
|
|
82
82
|
|
|
@@ -92,6 +92,7 @@ const repriced = await client.apply({
|
|
|
92
92
|
| `actorId` | The Governance identity id of the signed-in person, sent as `actor_id` with every command unless a call names its own. An identified caller should pass this and leave `role` unset, so Governance's role assignments decide. The host honors `actor_id` only on its internal protocol, from its own peers. |
|
|
93
93
|
| `timeoutMs` | How long one request may take before it counts as unreachable. Defaults to `8000`. |
|
|
94
94
|
| `fetch` | The `fetch` to send requests with, for tests or a custom agent. Defaults to the global `fetch`, looked up on each call. |
|
|
95
|
+
| `bare` | Whether the host answers a value object that has one field as that field's bare value (`name: "Yoga"`, not `name: { value: "Yoga" }`). Defaults to `true`, sent as `"bare": true` on every request; `false` asks for the wrapped shape the host stores. A command takes either form. |
|
|
95
96
|
|
|
96
97
|
The environment variables are read once, when the client is constructed. A
|
|
97
98
|
missing domain or URL throws a `TypeError`.
|
|
@@ -105,14 +106,16 @@ missing domain or URL throws a `TypeError`.
|
|
|
105
106
|
- `read(): Promise<Answer>`: posts `{"read": true}` and returns everything the domain holds.
|
|
106
107
|
- `dispatch(verb, args = {}, to?, role?, actorId?): Promise<Answer>`: posts one command and returns the raw answer. `verb` is `Aggregate.Verb` or fully qualified. `to` targets an existing instance and is omitted for a command that creates one.
|
|
107
108
|
- `query(name, args = {}): Promise<Answer>`: asks one declared query (`Aggregate.Query`, bare or qualified) and returns the raw answer, with the result in `answer.queries` (`[{ query, rows, error? }]`). The host reads current state and writes nothing. A server-side call like the others: the host accepts it only from the same machine.
|
|
109
|
+
- `validate(verb, args = {}, to?, role?, actorId?): Promise<Validation>`: asks whether a command would be accepted right now, and if not, why: `{ ok, refusals: [{ kind, stage, refusal?, message, attribute?, path?, rule? }] }`. The host runs the command as far as it can and keeps nothing, and answers HTTP 200 whether or not it would be refused, so this resolves with the verdict and never throws `DomainRefusal`. Advisory: the state it judged can change before the real dispatch. The Rust host lists every unmet given, ensure and invariant of the stage it stopped in, and every unknown and absent argument, each naming its `rule` or its `attribute` and `path`; a coercion mismatch it reports alone.
|
|
110
|
+
- `schema(verb): Promise<object>`: the JSON Schema (draft 2020-12) of the facts a command takes, for checking a payload locally before asking. Rules over stored state ride along as `x-` annotations; `validate` stays the authority on them. The host serves it at the command's JSON route with `?schema=1`, from the `<domain>.schemas.json` the wasm build writes beside the IR. Throws `DomainUnavailable` when the host cannot be reached or has no schema for the command.
|
|
108
111
|
- `apply<T>(command): Promise<T>`: dispatches `command.verb` with `command.with`, `command.to`, `command.role` and `command.actorId`, reads the answer with `command.parse`, and returns the result when `command.confirm` accepts it. Otherwise it throws `DomainRefusal` built from the answer's last refusal.
|
|
109
112
|
- `instancesOf(answer, aggregate): [string, state][]`: the states of one aggregate, bare or qualified name.
|
|
110
113
|
|
|
111
114
|
Standalone readers, importable without a client:
|
|
112
115
|
|
|
113
116
|
- `instancesOf(answer, "Domain::Aggregate")`: the same lookup with the aggregate named in full.
|
|
114
|
-
- `text(raw): string | null`: a string value object's text, `null` when absent or empty.
|
|
115
|
-
- `whole(raw, key): number`: a numeric value object's number under `key` (`"value"`, `"cents"`), `0` when absent.
|
|
117
|
+
- `text(raw): string | null`: a string value object's text, bare or wrapped, `null` when absent or empty.
|
|
118
|
+
- `whole(raw, key): number`: a numeric value object's number, bare or wrapped under `key` (`"value"`, `"cents"`), `0` when absent.
|
|
116
119
|
- `optionalWhole(raw, key): number | null`: like `whole`, but `null` when the attribute was left unset.
|
|
117
120
|
- `rowsOf(answer, name?): Record<string, unknown>[] | null`: the rows a query answered, `null` when the answer has no entry for it; throws `DomainRefusal` when the host refused the question (an unknown query, or one answered outside the domain).
|
|
118
121
|
- `refusalOf(answer, verb): DomainRefusal`: the domain's own words for why a command changed nothing.
|
package/dist/answer.d.ts
CHANGED
|
@@ -4,6 +4,32 @@ export interface Refusal {
|
|
|
4
4
|
kind: string;
|
|
5
5
|
error: string;
|
|
6
6
|
}
|
|
7
|
+
/** One reason a command would be refused, as a validation reports it. */
|
|
8
|
+
export interface ValidationRefusal {
|
|
9
|
+
/** What sort of no: `refused`, `not_found`, `unauthorized` or `absent_argument`. */
|
|
10
|
+
kind: string;
|
|
11
|
+
/** The point of dispatch it came from: `arguments`, `role`, `references`, `state`, `givens`, `ensures`, `invariants`. */
|
|
12
|
+
stage: string;
|
|
13
|
+
/** The refusal class the domain raises (`GivenNotMet`), when the host names it. */
|
|
14
|
+
refusal?: string | null;
|
|
15
|
+
/** The domain's own words for why. */
|
|
16
|
+
message: string | null;
|
|
17
|
+
/** The attribute it is about, when the host knows (the Ruby runtime does; the Rust host does not yet). */
|
|
18
|
+
attribute?: string | null;
|
|
19
|
+
/** A JSON Pointer to the offending value, when the host knows. */
|
|
20
|
+
path?: string | null;
|
|
21
|
+
/** The text of the rule that refused, when the host knows. */
|
|
22
|
+
rule?: string | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether a command would be accepted right now and, if not, why. Advisory: the state it was judged
|
|
26
|
+
* on can change before the real dispatch, which stays authoritative. The Rust host stops at the
|
|
27
|
+
* first refusal, so `refusals` holds at most one there.
|
|
28
|
+
*/
|
|
29
|
+
export interface Validation {
|
|
30
|
+
ok: boolean;
|
|
31
|
+
refusals: ValidationRefusal[];
|
|
32
|
+
}
|
|
7
33
|
/**
|
|
8
34
|
* The body of every host answer: the state of the aggregates, keyed
|
|
9
35
|
* `Domain::Aggregate#id`, and the refusals the run reported. `error` is set
|
|
@@ -15,6 +41,8 @@ export interface Answer {
|
|
|
15
41
|
/** One entry per question asked with `HostClient#query`. */
|
|
16
42
|
queries?: QueryResult[];
|
|
17
43
|
error?: string;
|
|
44
|
+
/** Set on the answer to a validation (`HostClient#validate`). */
|
|
45
|
+
ok?: boolean;
|
|
18
46
|
}
|
|
19
47
|
/**
|
|
20
48
|
* What the host answered to one declared query: its rows (each a state, keyed
|
package/dist/answer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answer.js","sourceRoot":"","sources":["../src/answer.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,6EAA6E;AAC7E,8CAA8C;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"answer.js","sourceRoot":"","sources":["../src/answer.ts"],"names":[],"mappings":"A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AAK,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAChH,MAAM,IAAI,aAAa,CAAC,OAAO,EAAE,IAAI,IAAI,cAAc,EAAE,KAAK,CAAC,KAAK,IAAI,2BAA2B,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IACpH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Answer } from "./answer.js";
|
|
1
|
+
import type { Answer, Validation } from "./answer.js";
|
|
2
2
|
/** What a `HostClient` needs to reach one domain. */
|
|
3
3
|
export interface ClientOptions {
|
|
4
4
|
/** The domain's name as its bluebook declares it ("Shop"). Falls back to the `HECKS_DOMAIN` environment variable. */
|
|
@@ -23,6 +23,11 @@ export interface ClientOptions {
|
|
|
23
23
|
timeoutMs?: number;
|
|
24
24
|
/** The fetch to send requests with. Defaults to the global `fetch`, looked up on each call. */
|
|
25
25
|
fetch?: typeof fetch;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the host answers a single-field value object as its bare value. Defaults to true;
|
|
28
|
+
* false asks for the wrapped shape the host stores (`{ value: "x" }`, `{ cents: 900 }`).
|
|
29
|
+
*/
|
|
30
|
+
bare?: boolean;
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
28
33
|
* One command whose outcome is judged from the state that comes back.
|
|
@@ -51,6 +56,7 @@ export declare class HostClient {
|
|
|
51
56
|
private readonly actorId;
|
|
52
57
|
private readonly timeoutMs;
|
|
53
58
|
private readonly fetchImpl;
|
|
59
|
+
private readonly bare;
|
|
54
60
|
constructor(options?: ClientOptions);
|
|
55
61
|
/** A name in full: one that already carries `::` is left alone, any other is placed in this client's domain. */
|
|
56
62
|
qualify(name: string): string;
|
|
@@ -63,6 +69,21 @@ export declare class HostClient {
|
|
|
63
69
|
* from the state in it and turn a miss into a refusal with `refusalOf`.
|
|
64
70
|
*/
|
|
65
71
|
dispatch(verb: string, args?: Record<string, unknown>, to?: string, role?: string, actorId?: string): Promise<Answer>;
|
|
72
|
+
/**
|
|
73
|
+
* Asks whether a command would be accepted right now, and if not, why. The host runs the command
|
|
74
|
+
* as far as it can and keeps nothing: no write, no reaction. It answers HTTP 200 whether or not
|
|
75
|
+
* the command would be refused, so this resolves with the verdict and never throws a
|
|
76
|
+
* `DomainRefusal`; `DomainUnavailable` still means the host could not be reached.
|
|
77
|
+
*/
|
|
78
|
+
validate(verb: string, args?: Record<string, unknown>, to?: string, role?: string, actorId?: string): Promise<Validation>;
|
|
79
|
+
/**
|
|
80
|
+
* The JSON Schema of the facts one command takes (`Aggregate.Command`, bare or qualified), for
|
|
81
|
+
* checking a payload before asking the host. A schema cannot hold a rule over stored state, so
|
|
82
|
+
* those ride along as `x-` annotations; `validate` stays the authority. Throws
|
|
83
|
+
* `DomainUnavailable` when the host cannot be reached or has no schema for the command.
|
|
84
|
+
*/
|
|
85
|
+
schema(verb: string): Promise<Record<string, unknown>>;
|
|
86
|
+
private commandBody;
|
|
66
87
|
/**
|
|
67
88
|
* Asks one declared query (`Aggregate.Query`, bare or qualified) and returns the raw answer.
|
|
68
89
|
* The host reads current state and writes nothing; the rows are in `answer.queries`, which
|
package/dist/client.js
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
// "role": "Role", "actor_id": "<id>" }
|
|
10
10
|
// -> the same shape after the command ran
|
|
11
11
|
//
|
|
12
|
+
// Every request also carries `"bare": true` unless the client was built with
|
|
13
|
+
// `bare: false`: the host then answers a value object that has one field as
|
|
14
|
+
// that field's own value (`name: "Margherita"`, not `name: { value: "Margherita" }`),
|
|
15
|
+
// the same shape a command takes it in. Without it the host answers the shape
|
|
16
|
+
// it stores.
|
|
17
|
+
//
|
|
12
18
|
// The host answers HTTP 200 whether or not the domain refused, and its
|
|
13
19
|
// `refusals` list can carry entries replayed from history, so a command is
|
|
14
20
|
// judged by the state that comes back (see `HostClient#apply`), never by the
|
|
@@ -42,6 +48,7 @@ export class HostClient {
|
|
|
42
48
|
actorId;
|
|
43
49
|
timeoutMs;
|
|
44
50
|
fetchImpl;
|
|
51
|
+
bare;
|
|
45
52
|
constructor(options = {}) {
|
|
46
53
|
const domain = options.domain ?? fromEnv("HECKS_DOMAIN");
|
|
47
54
|
const url = options.url ?? fromEnv("HECKS_SERVICE_URL");
|
|
@@ -55,6 +62,7 @@ export class HostClient {
|
|
|
55
62
|
this.actorId = options.actorId;
|
|
56
63
|
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
57
64
|
this.fetchImpl = options.fetch;
|
|
65
|
+
this.bare = options.bare ?? true;
|
|
58
66
|
}
|
|
59
67
|
/** A name in full: one that already carries `::` is left alone, any other is placed in this client's domain. */
|
|
60
68
|
qualify(name) {
|
|
@@ -73,15 +81,54 @@ export class HostClient {
|
|
|
73
81
|
* from the state in it and turn a miss into a refusal with `refusalOf`.
|
|
74
82
|
*/
|
|
75
83
|
dispatch(verb, args = {}, to, role, actorId) {
|
|
84
|
+
return this.post(this.commandBody(verb, args, to, role, actorId));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Asks whether a command would be accepted right now, and if not, why. The host runs the command
|
|
88
|
+
* as far as it can and keeps nothing: no write, no reaction. It answers HTTP 200 whether or not
|
|
89
|
+
* the command would be refused, so this resolves with the verdict and never throws a
|
|
90
|
+
* `DomainRefusal`; `DomainUnavailable` still means the host could not be reached.
|
|
91
|
+
*/
|
|
92
|
+
async validate(verb, args = {}, to, role, actorId) {
|
|
93
|
+
const answer = await this.post({ ...this.commandBody(verb, args, to, role, actorId), dry_run: true });
|
|
94
|
+
return { ok: answer.ok === true, refusals: (answer.refusals ?? []) };
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The JSON Schema of the facts one command takes (`Aggregate.Command`, bare or qualified), for
|
|
98
|
+
* checking a payload before asking the host. A schema cannot hold a rule over stored state, so
|
|
99
|
+
* those ride along as `x-` annotations; `validate` stays the authority. Throws
|
|
100
|
+
* `DomainUnavailable` when the host cannot be reached or has no schema for the command.
|
|
101
|
+
*/
|
|
102
|
+
async schema(verb) {
|
|
103
|
+
const [domain, rest] = this.qualify(verb).split("::");
|
|
104
|
+
const [aggregate, command] = rest.split(".");
|
|
105
|
+
const send = this.fetchImpl ?? globalThis.fetch;
|
|
106
|
+
let res;
|
|
107
|
+
try {
|
|
108
|
+
res = await send(`${this.url}/${domain}/${aggregate}/${command}.json?schema=1`, { signal: AbortSignal.timeout(this.timeoutMs) });
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
throw new DomainUnavailable(`could not reach the domain at ${this.url}: ${err}`);
|
|
112
|
+
}
|
|
113
|
+
if (!res.ok)
|
|
114
|
+
throw new DomainUnavailable(`the domain answered HTTP ${res.status} for the schema of ${verb}`);
|
|
115
|
+
try {
|
|
116
|
+
return (await res.json());
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
throw new DomainUnavailable("the domain did not answer with JSON");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
commandBody(verb, args, to, role, actorId) {
|
|
76
123
|
const asRole = role ?? this.role;
|
|
77
124
|
const asActor = actorId ?? this.actorId;
|
|
78
|
-
return
|
|
125
|
+
return {
|
|
79
126
|
verb: this.qualify(verb),
|
|
80
127
|
...(to ? { to } : {}),
|
|
81
128
|
with: args,
|
|
82
129
|
...(asRole ? { role: asRole } : {}),
|
|
83
130
|
...(asActor ? { actor_id: asActor } : {}),
|
|
84
|
-
}
|
|
131
|
+
};
|
|
85
132
|
}
|
|
86
133
|
/**
|
|
87
134
|
* Asks one declared query (`Aggregate.Query`, bare or qualified) and returns the raw answer.
|
|
@@ -110,7 +157,7 @@ export class HostClient {
|
|
|
110
157
|
res = await send(`${this.url}/dispatch`, {
|
|
111
158
|
method: "POST",
|
|
112
159
|
headers: { "Content-Type": "application/json" },
|
|
113
|
-
body: JSON.stringify(body),
|
|
160
|
+
body: JSON.stringify(this.bare ? { ...body, bare: true } : body),
|
|
114
161
|
signal: AbortSignal.timeout(this.timeoutMs),
|
|
115
162
|
});
|
|
116
163
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,mDAAmD;AACnD,EAAE;AACF,qBAAqB;AACrB,iFAAiF;AACjF,4DAA4D;AAC5D,+EAA+E;AAC/E,uEAAuE;AACvE,2CAA2C;AAC3C,8CAA8C;AAC9C,EAAE;AACF,uEAAuE;AACvE,2EAA2E;AAC3E,6EAA6E;AAC7E,cAAc;AACd,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,qEAAqE;AACrE,yCAAyC;AACzC,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,2EAA2E;AAC3E,SAAS;AAET,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,kBAAkB,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,mDAAmD;AACnD,EAAE;AACF,qBAAqB;AACrB,iFAAiF;AACjF,4DAA4D;AAC5D,+EAA+E;AAC/E,uEAAuE;AACvE,2CAA2C;AAC3C,8CAA8C;AAC9C,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,sFAAsF;AACtF,8EAA8E;AAC9E,aAAa;AACb,EAAE;AACF,uEAAuE;AACvE,2EAA2E;AAC3E,6EAA6E;AAC7E,cAAc;AACd,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,qEAAqE;AACrE,yCAAyC;AACzC,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,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
|
1
1
|
export { HostClient, createClient } from "./client.js";
|
|
2
2
|
export type { ClientOptions, Command } from "./client.js";
|
|
3
3
|
export { instancesOf, rowsOf, text, whole, optionalWhole } from "./answer.js";
|
|
4
|
-
export type { Answer, QueryResult, Refusal } from "./answer.js";
|
|
4
|
+
export type { Answer, QueryResult, Refusal, Validation, ValidationRefusal } from "./answer.js";
|
|
5
5
|
export { DomainRefusal, DomainUnavailable, refusalOf } from "./errors.js";
|
|
6
6
|
export { createResilientFetch, ResilientFetchError } from "./resilientFetch.js";
|
|
7
7
|
export type { ResilientFetch, ResilientFetchConfig, ResilientRequest } from "./resilientFetch.js";
|
package/package.json
CHANGED