@enspirit/opspicy 0.3.1 → 0.3.2
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 +6 -6
- package/dist/configuration.d.ts +10 -1
- package/dist/world.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -186,16 +186,16 @@ A system that stops answering during the run is not that: each case then could n
|
|
|
186
186
|
|
|
187
187
|
| Tag | Is |
|
|
188
188
|
| --- | --- |
|
|
189
|
-
| `0.3.
|
|
189
|
+
| `0.3.2` | The version tagged `v0.3.2`: the image of that commit, as it was tested. Name one of these. |
|
|
190
190
|
| `latest`, `sha-<commit>` | The main branch, and one commit of it. |
|
|
191
191
|
|
|
192
192
|
**As a tool**, on a suite that is mounted:
|
|
193
193
|
|
|
194
194
|
```sh
|
|
195
|
-
docker run --rm -v "$PWD":/suite:ro enspirit/opspicy:0.3.
|
|
196
|
-
docker run --rm -v "$PWD":/suite:ro enspirit/opspicy:0.3.
|
|
197
|
-
docker run --rm -v "$PWD":/suite enspirit/opspicy:0.3.
|
|
198
|
-
docker run --rm -v "$PWD":/suite:ro -p 127.0.0.1:8080:8080 enspirit/opspicy:0.3.
|
|
195
|
+
docker run --rm -v "$PWD":/suite:ro enspirit/opspicy:0.3.2 opspicy --check
|
|
196
|
+
docker run --rm -v "$PWD":/suite:ro enspirit/opspicy:0.3.2 tsc -p . # type-checks its config.ts
|
|
197
|
+
docker run --rm -v "$PWD":/suite enspirit/opspicy:0.3.2 opspicy explorer --out=explorer.html
|
|
198
|
+
docker run --rm -v "$PWD":/suite:ro -p 127.0.0.1:8080:8080 enspirit/opspicy:0.3.2 opspicy serve --host=0.0.0.0
|
|
199
199
|
```
|
|
200
200
|
|
|
201
201
|
The last one is read-only: `--api` is offered on the machine the server runs on, which a container is not.
|
|
@@ -203,7 +203,7 @@ The last one is read-only: `--api` is offered on the machine the server runs on,
|
|
|
203
203
|
**As the base of a suite's image**, where the system is reached: on the network of its stack, say.
|
|
204
204
|
|
|
205
205
|
```dockerfile
|
|
206
|
-
FROM enspirit/opspicy:0.3.
|
|
206
|
+
FROM enspirit/opspicy:0.3.2
|
|
207
207
|
COPY . /suite
|
|
208
208
|
CMD ["tail", "-f", "/dev/null"] # it sleeps, and `opspicy` is run in it
|
|
209
209
|
```
|
package/dist/configuration.d.ts
CHANGED
|
@@ -3,9 +3,18 @@ export interface Answer {
|
|
|
3
3
|
/** JSON as data, a text as it is, nothing otherwise. */
|
|
4
4
|
body: unknown;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Somebody's browser: it keeps the cookies it is given, and comes from one origin. Any other scheme
|
|
8
|
+
* of sign-in is a header it sends with every call.
|
|
9
|
+
*/
|
|
7
10
|
export interface Browser {
|
|
8
11
|
call(method: string, path: string, body?: unknown): Promise<Answer>;
|
|
12
|
+
/**
|
|
13
|
+
* Sends a header with every call from now on, in place of one of the same name: `authorization`
|
|
14
|
+
* with `Bearer <token>`, say, for a system that signs its software in with a token. A header is
|
|
15
|
+
* never told of: a run says what was sent and what was answered, not what the call was signed with.
|
|
16
|
+
*/
|
|
17
|
+
header(name: string, value: string): void;
|
|
9
18
|
}
|
|
10
19
|
/** Asks the database, to read: one statement, its rows. */
|
|
11
20
|
export type Ask = (sql: string) => Promise<Record<string, unknown>[]>;
|
package/dist/world.js
CHANGED
|
@@ -28,8 +28,10 @@ async function bodyOf(response) {
|
|
|
28
28
|
/** A browser nobody is signed in on, calling from an origin when the system is told one. */
|
|
29
29
|
export function browser({ api, originHeader }, origin, hears) {
|
|
30
30
|
const jar = new Map();
|
|
31
|
+
const held = new Map();
|
|
31
32
|
const call = async (method, path, body) => {
|
|
32
|
-
const headers = {
|
|
33
|
+
const headers = { ...Object.fromEntries(held) };
|
|
34
|
+
headers.cookie = [...jar].map(([name, value]) => `${name}=${value}`).join('; ');
|
|
33
35
|
if (originHeader)
|
|
34
36
|
headers[originHeader] = origin;
|
|
35
37
|
if (body !== undefined)
|
|
@@ -41,7 +43,8 @@ export function browser({ api, originHeader }, origin, hears) {
|
|
|
41
43
|
hears?.({ method, path, sent: body, ...answer, ms: Date.now() - started });
|
|
42
44
|
return answer;
|
|
43
45
|
};
|
|
44
|
-
|
|
46
|
+
const header = (name, value) => void held.set(name.toLowerCase(), value);
|
|
47
|
+
return { call, header };
|
|
45
48
|
}
|
|
46
49
|
/** The browser of an actor: signed in when they have something to sign in with, as a visitor's otherwise. */
|
|
47
50
|
export async function browserOf(config, origin, name, actor, hears) {
|
package/package.json
CHANGED