@enspirit/opspicy 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +281 -2
- package/bin/entry.js +27 -0
- package/bin/opspicy +19 -0
- package/dist/addresses.js +27 -0
- package/dist/behind.js +64 -0
- package/dist/citizens.js +71 -0
- package/dist/configuration.d.ts +56 -0
- package/dist/configuration.js +66 -0
- package/dist/explorer/afresh.js +43 -0
- package/dist/explorer/api.js +101 -0
- package/dist/explorer/asking.js +59 -0
- package/dist/explorer/build.js +11 -0
- package/dist/explorer/calls.js +42 -0
- package/dist/explorer/document.js +109 -0
- package/dist/explorer/elo-refs.js +153 -0
- package/dist/explorer/elo.js +95 -0
- package/dist/explorer/fonts/OFL.txt +93 -0
- package/dist/explorer/fonts/dm-sans-latin.woff2 +0 -0
- package/dist/explorer/html.js +59 -0
- package/dist/explorer/index.js +61 -0
- package/dist/explorer/json.js +33 -0
- package/dist/explorer/machine.js +34 -0
- package/dist/explorer/masking.js +57 -0
- package/dist/explorer/operation.js +94 -0
- package/dist/explorer/pages.js +132 -0
- package/dist/explorer/script/base.js +103 -0
- package/dist/explorer/script/call.js +161 -0
- package/dist/explorer/script/calling.js +103 -0
- package/dist/explorer/script/connection.js +83 -0
- package/dist/explorer/script/copying.js +75 -0
- package/dist/explorer/script/filter.js +56 -0
- package/dist/explorer/script/formaldef.js +37 -0
- package/dist/explorer/script/main.js +82 -0
- package/dist/explorer/script/markdown.js +143 -0
- package/dist/explorer/script/notes.js +184 -0
- package/dist/explorer/script/noting.js +38 -0
- package/dist/explorer/script/peek.js +62 -0
- package/dist/explorer/script/peeking.js +19 -0
- package/dist/explorer/script/ranking.js +91 -0
- package/dist/explorer/script/review.js +126 -0
- package/dist/explorer/script/rows.js +58 -0
- package/dist/explorer/script/run.js +168 -0
- package/dist/explorer/script/running.js +66 -0
- package/dist/explorer/script/search.js +122 -0
- package/dist/explorer/script/sending.js +64 -0
- package/dist/explorer/script/served.js +51 -0
- package/dist/explorer/serve.js +41 -0
- package/dist/explorer/server.js +143 -0
- package/dist/explorer/site.js +77 -0
- package/dist/explorer/style.css +241 -0
- package/dist/explorer/telling.js +30 -0
- package/dist/explorer/tests.js +78 -0
- package/dist/explorer/wiki.js +76 -0
- package/dist/files.js +176 -0
- package/dist/finding.js +17 -0
- package/dist/judging.js +75 -0
- package/dist/lines.js +30 -0
- package/dist/main.js +128 -0
- package/dist/meaning.js +100 -0
- package/dist/modelling.js +115 -0
- package/dist/naming.js +84 -0
- package/dist/notation.js +119 -0
- package/dist/planning.js +32 -0
- package/dist/reading.js +120 -0
- package/dist/report-file.js +42 -0
- package/dist/report.js +62 -0
- package/dist/running.js +102 -0
- package/dist/selecting.js +71 -0
- package/dist/starting.js +41 -0
- package/dist/suite.js +29 -0
- package/dist/words.js +103 -0
- package/dist/world.js +128 -0
- package/package.json +57 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bernard Lambeau
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,282 @@
|
|
|
1
|
-
#
|
|
1
|
+
# opspicy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Specifies the operations of a system by their clauses, and runs them.**
|
|
4
|
+
|
|
5
|
+
A system does things when it is asked to: it makes a board, invites a member, sends a reply. Each is an *operation*, and opspicy specifies one per file, in the terms of [KAOS](https://en.wikipedia.org/wiki/KAOS_(software_development)): what the operation is (`DomPre`, `DomPost`) and what the rules demand of it (`ReqPre`, `ReqPost`), as sentences. A sentence is checked when it has a formal definition, its *formaldef*: an expression in [Elo](https://elo-lang.org), true or false of what can be observed before and after one call.
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
name: CreateBoard
|
|
9
|
+
description: A member makes a board.
|
|
10
|
+
agent: Member
|
|
11
|
+
entry: POST /api/boards
|
|
12
|
+
input: BoardGiven
|
|
13
|
+
output: Board
|
|
14
|
+
|
|
15
|
+
ReqPre:
|
|
16
|
+
- (x) the requester is signed in
|
|
17
|
+
- (x) it has a name: "!isBlank(input.name | '')"
|
|
18
|
+
DomPost:
|
|
19
|
+
- (x) there is one more board, of this name: count(boards) == count(old.boards) + 1 && board(output.id).name == input.name
|
|
20
|
+
|
|
21
|
+
examples:
|
|
22
|
+
- when: a member makes a board
|
|
23
|
+
given: test/base, as member
|
|
24
|
+
input: { name: Suppliers }
|
|
25
|
+
then: 201
|
|
26
|
+
|
|
27
|
+
counterexamples:
|
|
28
|
+
- when: the name is blank
|
|
29
|
+
for: it has a name
|
|
30
|
+
given: test/base, as member
|
|
31
|
+
input: { name: ' ' }
|
|
32
|
+
then: 400 boards.nameRequired
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
One responsibility: *read a suite of such files, run each case against a running system through its front door, and say what does not hold.*
|
|
36
|
+
|
|
37
|
+
It knows nothing of the system: a suite tells it where the front door is, how somebody signs in and how a Background is set, in its [`config.ts`](doc/suite.md#the-configuration-configts). It comes after [webspicy](https://github.com/enspirit/webspicy), which specifies a web service route by route and looks at the answer: opspicy specifies it operation by operation, and looks at the state.
|
|
38
|
+
|
|
39
|
+
## Try it
|
|
40
|
+
|
|
41
|
+
To read a suite somebody wrote, and comment it, opspicy is installed from npm, with Node 22.18 or later:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm install -g @enspirit/opspicy # or nothing installed: npx @enspirit/opspicy serve path/to/suite
|
|
45
|
+
opspicy serve path/to/suite # http://127.0.0.1:8080: search it, read it, take notes, save them as review.md
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`opspicy explorer path/to/suite` writes the same pages as one file, `explorer.html`, to open or to send. Neither needs the system the suite specifies, nor its `config.ts`: [the explorer](#the-explorer).
|
|
49
|
+
|
|
50
|
+
To run one, [`example/`](example/) holds a system, a keeper of boards, and the suite that specifies it. From a checkout, Node runs both as they are:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
git clone https://github.com/enspirit/opspicy && cd opspicy && npm ci
|
|
54
|
+
node example/keeper.ts & # the system, on http://127.0.0.1:4000
|
|
55
|
+
export BOARDS_API=http://127.0.0.1:4000 BOARDS_MAY_BE_EMPTIED=yes
|
|
56
|
+
bin/opspicy example/suite # runs the suite
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
RenameBoard — Member · PUT /api/boards/:id · boards/operations/RenameBoard.yml
|
|
61
|
+
ReqPre ✓ the requester is signed in
|
|
62
|
+
DomPost ✓ the board has the name given
|
|
63
|
+
✗ example: a member renames a board
|
|
64
|
+
DomPost "the board has the name given" does not hold after the call
|
|
65
|
+
✓ counterexample: called as visitor — for "the requester is signed in" [from a condition]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The keeper has one fault, on purpose: it answers a renaming as if it had renamed. The answer is right and the state is not, which is what a run finds. Then, to read the suite rather than its files:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
bin/opspicy example/suite --report=last.json # the same run, kept
|
|
72
|
+
bin/opspicy explorer example/suite --report=last.json # writes explorer.html: open it
|
|
73
|
+
bin/opspicy serve example/suite --report=last.json --api # http://127.0.0.1:8080, and it runs what its page asks
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## How a case runs
|
|
77
|
+
|
|
78
|
+
| | |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| **Given** | The Background: the database is put in a seed, and who calls is signed in. |
|
|
81
|
+
| | The state is observed: `_.before`. |
|
|
82
|
+
| **When** | The operation is called once, through the front door, with the input. What it started and did not wait for is waited for. |
|
|
83
|
+
| **Then** | The state is observed again: `_.after`. |
|
|
84
|
+
| an example | Every precondition held before the call · the answer has the status said, and is of the type said, when the operation names one: a text is not a number there, nor true or false · every postcondition holds · an observation, and any route entered by `GET`, changed nothing. |
|
|
85
|
+
| a counterexample | The precondition it is `for` did not hold, and every other did (one that a condition gives is not asked the second: who violates a condition, somebody not signed in say, violates more) · it is refused with the status and the code said, as the type refusals have · **nothing changed**: every route of the state and every relation is as it was. |
|
|
86
|
+
|
|
87
|
+
Nothing is instrumented: a precondition is never *made* to hold. A case chooses its Background, and what is checked is that the preconditions are what the case says they are.
|
|
88
|
+
|
|
89
|
+
### Two runs
|
|
90
|
+
|
|
91
|
+
| | Checks | Reads |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| **complete** | Every clause that has a formaldef. | The routes of the state, and the relations of the database. |
|
|
94
|
+
| **fast** (`--fast`) | What must hold: every clause but those marked `(+)`, which it tells. | The routes of the state, and no relation. "Nothing changed" is then said of the routes alone. What the configuration's `atRest` asks of the database is still asked. |
|
|
95
|
+
|
|
96
|
+
The fast run is the system as a black box: it passes whatever the schema is, so it is the one that must stay as it is when the system is rebuilt inside. A clause that reads the database is checked in the complete run only, and [says so](doc/suite.md#an-operation-specificationareaoperationsoperationyml-and-an-observation-beside-it).
|
|
97
|
+
|
|
98
|
+
## Public interface
|
|
99
|
+
|
|
100
|
+
A command, a notation, and an image.
|
|
101
|
+
|
|
102
|
+
### The command
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
opspicy [<suite>] # runs the suite of that directory: this one, when none is named
|
|
106
|
+
opspicy [<suite>] --check # reads it, and says what cannot be read: no system needed
|
|
107
|
+
opspicy [<suite>] --fast # the fast run
|
|
108
|
+
opspicy [<suite>] --report=<file> # also writes what the run decided, as JSON, for the explorer
|
|
109
|
+
opspicy explorer [<suite>] [--report=<file>] [--out=explorer.html] [--name=<name>] [--version=<version>] [--runner=<command>]
|
|
110
|
+
# the wiki of the suite, one standalone HTML file, offline
|
|
111
|
+
opspicy serve [<suite>] [--report=<file>] [--name=<name>] [--version=<version>] [--runner=<command>] [--host=127.0.0.1] [--port=8080]
|
|
112
|
+
# the same wiki, served read-only, re-read when the suite changes
|
|
113
|
+
opspicy serve [<suite>] --api … # the same, and it runs what its page asks: on this machine only
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
There are three ways to have it, and it is the same command in each:
|
|
117
|
+
|
|
118
|
+
| | |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| The package | `npm install -g @enspirit/opspicy`, or beside a suite as a development dependency; `npx @enspirit/opspicy` installs nothing. It holds JavaScript: Node refuses to run TypeScript under a `node_modules`, so the sources are compiled when the package is made ([`build.ts`](build.ts)), and then only. |
|
|
121
|
+
| A checkout | [`bin/opspicy`](bin/opspicy), after `npm ci`. Node runs the TypeScript files of [`src/`](src/) as they are. |
|
|
122
|
+
| [The image](#the-image) | On its path, where Node runs the TypeScript files too. |
|
|
123
|
+
|
|
124
|
+
Which files it runs is decided in one place, [`bin/entry.js`](bin/entry.js): the sources where they are and Node runs them, the compiled files otherwise.
|
|
125
|
+
|
|
126
|
+
What of the suite is run, and how much of it is told, is asked through the environment:
|
|
127
|
+
|
|
128
|
+
| | |
|
|
129
|
+
| --- | --- |
|
|
130
|
+
| `O=boards` | Only the operations whose name, file or route holds that text: `O=CreateBoard`, `O=boards/`, `O=/api/boards`. |
|
|
131
|
+
| `METHOD=DELETE` | Only those entered by that method. |
|
|
132
|
+
| `CASE=blank` | Only the cases whose `when` holds that text. |
|
|
133
|
+
| `ROBUST=no\|only\|generated` | Only the examples; only the counterexamples; only those the conditions give. |
|
|
134
|
+
| `FAILFAST=yes` | Stops at the first case that fails. |
|
|
135
|
+
| `FAST=yes` | [The fast run](#two-runs); `--fast` says the same. |
|
|
136
|
+
| `LOG_LEVEL=DEBUG` | Also shows, under each case, the Background it was set in, then what it sent and what it was answered. `TRACE` adds everything around, in a line each and in the order it happened: each wait for the server to be at rest, who signed in, and what each route of the state told whom, before and after. Each of these lines begins with how long that step took: putting the database in the seed, a wait, a call. What the runner sends and is answered to sign an actor in is never shown; a case that is itself a sign-in is shown as any case is. `WARN` tells only the cases that fail. |
|
|
137
|
+
|
|
138
|
+
They combine: `O=boards ROBUST=no FAILFAST=yes LOG_LEVEL=DEBUG`. What is not understood stops the run before anything is called: `ROBUST=maybe`, a `LOG_LEVEL` that is none of `WARN`, `INFO`, `DEBUG` and `TRACE`, a flag the command does not have, a second directory. So does asking for what no case is. A run that was narrowed says so in its last lines.
|
|
139
|
+
|
|
140
|
+
It answers 0 when every case that was run passes, 1 when one does not, and 2 when nothing could be run, with a sentence saying why and before any case is: the suite cannot be read; it has no `config.ts`, or one that fails; the configuration does not say the database may be emptied; the report cannot be written where it is asked; the database or the system does not answer. The system is asked once for that, `GET` on its front door, whatever it answers.
|
|
141
|
+
|
|
142
|
+
A system that stops answering during the run is not that: each case then could not be run, which is a case that does not pass.
|
|
143
|
+
|
|
144
|
+
### The image
|
|
145
|
+
|
|
146
|
+
`enspirit/opspicy`, on Docker Hub: Node, `opspicy`, and `tsc` with Node's types. Its directory is `/suite`.
|
|
147
|
+
|
|
148
|
+
| Tag | Is |
|
|
149
|
+
| --- | --- |
|
|
150
|
+
| `0.2.0` | The version tagged `v0.2.0`: the image of that commit, as it was tested. Name one of these. |
|
|
151
|
+
| `latest`, `sha-<commit>` | The main branch, and one commit of it. |
|
|
152
|
+
|
|
153
|
+
**As a tool**, on a suite that is mounted:
|
|
154
|
+
|
|
155
|
+
```sh
|
|
156
|
+
docker run --rm -v "$PWD":/suite:ro enspirit/opspicy:0.2.0 opspicy --check
|
|
157
|
+
docker run --rm -v "$PWD":/suite:ro enspirit/opspicy:0.2.0 tsc -p . # type-checks its config.ts
|
|
158
|
+
docker run --rm -v "$PWD":/suite enspirit/opspicy:0.2.0 opspicy explorer --out=explorer.html
|
|
159
|
+
docker run --rm -v "$PWD":/suite:ro -p 127.0.0.1:8080:8080 enspirit/opspicy:0.2.0 opspicy serve --host=0.0.0.0
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The last one is read-only: `--api` is offered on the machine the server runs on, which a container is not.
|
|
163
|
+
|
|
164
|
+
**As the base of a suite's image**, where the system is reached: on the network of its stack, say.
|
|
165
|
+
|
|
166
|
+
```dockerfile
|
|
167
|
+
FROM enspirit/opspicy:0.2.0
|
|
168
|
+
COPY . /suite
|
|
169
|
+
CMD ["tail", "-f", "/dev/null"] # it sleeps, and `opspicy` is run in it
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
A suite's `config.ts` imports its type from where the image has it, `/opt/opspicy/src/configuration.ts`, and nothing else: [`example/suite/`](example/suite/) is written that way, with the `tsconfig.json` that checks it.
|
|
173
|
+
|
|
174
|
+
### A suite
|
|
175
|
+
|
|
176
|
+
A directory: a `config.ts`, which says how the suite meets the system, and a `specification/`, which says everything else, by area.
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
config.ts
|
|
180
|
+
specification/
|
|
181
|
+
areas.yml agents.yml backgrounds.yml state.yml world.yml
|
|
182
|
+
_shared/ predicates.yml functions.yml conditions.yml types.elo
|
|
183
|
+
<area>/ predicates.yml functions.yml conditions.yml types.elo
|
|
184
|
+
operations/<Operation>.yml
|
|
185
|
+
observations/<Observation>.yml
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Everything it says is a **citizen**: a name, a description, and for some a formaldef. **[`doc/suite.md`](doc/suite.md) is the reference**: [the metamodel](doc/suite.md#the-metamodel-citizens), [an operation's file](doc/suite.md#an-operation-specificationareaoperationsoperationyml-and-an-observation-beside-it), [what a formaldef reads](doc/suite.md#a-formaldef), [the state and the world](doc/suite.md#the-state-and-the-world-stateyml-worldyml), [what an area says](doc/suite.md#what-an-area-says-predicatesyml-functionsyml-conditionsyml-typeselo), and [the configuration](doc/suite.md#the-configuration-configts).
|
|
189
|
+
|
|
190
|
+
### The explorer
|
|
191
|
+
|
|
192
|
+
A wiki of a suite, as one HTML document that fetches nothing: the specification, and the last run of each operation when there is a report of one. A reader searches it, opens a formaldef at a click, follows a name in Elo to the citizen it names, takes notes that become one review file, and, where the document is served with `--api`, runs one case or calls an operation by hand.
|
|
193
|
+
|
|
194
|
+
**[`doc/explorer.md`](doc/explorer.md) is its reference**: its pages, [the notes and the review file](doc/explorer.md#notes-and-the-review-file), [calling an operation](doc/explorer.md#calling-an-operation), [running a case](doc/explorer.md#running-a-case), [the API](doc/explorer.md#served-with---api), and what the document says to its own script.
|
|
195
|
+
|
|
196
|
+
## Depends on
|
|
197
|
+
|
|
198
|
+
| | |
|
|
199
|
+
| --- | --- |
|
|
200
|
+
| Node.js 22.18 or later | It runs the TypeScript files directly: from a checkout and in the image, nothing is compiled. |
|
|
201
|
+
| `@enspirit/elo`, `luxon` | What a formaldef is written in, and the types; the dates Elo computes with. |
|
|
202
|
+
| `highlight.js`, `@enspirit/highlightjs-elo` | Elo as the explorer shows it: the grammar is Elo's own, applied when the document is written, so the page carries neither. |
|
|
203
|
+
| `@enspirit/elo-form` | The form an operation is called with, in the explorer: Elo's own contrib, whose standalone script and style a document is written with. |
|
|
204
|
+
| `yaml`, `pg` | Reading the files; reading the relations. |
|
|
205
|
+
| `typescript`, `@types/node` (development, and in the image) | Type-checking opspicy itself, and compiling the package; in the image, type-checking a suite's `config.ts`. Who installs the package downloads neither. |
|
|
206
|
+
| `playwright-core` (development) | Drives the installed Chrome in the browser tests; downloads no browser. |
|
|
207
|
+
| [dbagent](https://github.com/enspirit/dbagent), PostgreSQL (of a suite that wants them) | `dbagent(url)` sets a Background by installing a seed, and `noKeyHeld` reads PostgreSQL's advisory locks: both are handed to a `config.ts`, which may do without. |
|
|
208
|
+
|
|
209
|
+
## Must not
|
|
210
|
+
|
|
211
|
+
1. **Know the system it runs against.** No route, no name of a variable, no shape of an answer but what the configuration tells it.
|
|
212
|
+
2. **Act on the system but through its front door**, and through what the configuration gives it to set a Background.
|
|
213
|
+
3. **Write the database.** It is opened to read and nothing else.
|
|
214
|
+
4. **Make a precondition hold.** A case that does not start where it says it does is a finding, not something to arrange.
|
|
215
|
+
5. **Pass what it did not check.** A sentence with no formaldef is reported as told; a precondition nothing violates and an operation nothing shows are reported as gaps.
|
|
216
|
+
|
|
217
|
+
## Harness
|
|
218
|
+
|
|
219
|
+
```sh
|
|
220
|
+
npm ci
|
|
221
|
+
npm run typecheck # everything, example/keeper.ts included
|
|
222
|
+
npm test # needs neither a system nor a browser
|
|
223
|
+
npm run test:browser # needs Chrome: the one installed, or the executable CHROME names
|
|
224
|
+
npm run test:package # needs the registry: installs what would be published, and runs it
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
| What | Is held by |
|
|
228
|
+
| --- | --- |
|
|
229
|
+
| What reads a suite ([`notation`](src/notation.ts), [`citizens`](src/citizens.ts), [`modelling`](src/modelling.ts), [`words`](src/words.ts), [`lines`](src/lines.ts), [`reading`](src/reading.ts), and [`files`](src/files.ts) on a directory made for the test), names ([`naming`](src/naming.ts)), plans ([`planning`](src/planning.ts)), chooses what is run ([`selecting`](src/selecting.ts)), judges ([`judging`](src/judging.ts)) and tells ([`report`](src/report.ts), [`report-file`](src/report-file.ts)) | Pure, and tables of cases with no server and no mock: [`test/`](test/). |
|
|
230
|
+
| What sets a Background, calls and observes ([`world`](src/world.ts), [`running`](src/running.ts)), and the command | Cases run over the wire against the system of [`example/`](example/), started in the test's own process: a small real server, and the suite that specifies it. |
|
|
231
|
+
| What writes the explorer ([`src/explorer/`](src/explorer/)) and what its API answers | The same: pure for the document, over the wire for the API. |
|
|
232
|
+
| What the page's script decides: what a search finds and in what order, the review file, what a call sends and the command that says it ([`src/explorer/script/`](src/explorer/script/)) | `test/script*.test.ts`, which read the script as the page does; the copied command is run through a shell, with a stand-in for `curl`. |
|
|
233
|
+
| What the script does to the page | [`test/browser/`](test/browser/): a headless Chrome, driven with `playwright-core`, on the document opened by `file://` as it is used, and served with its API. They **fail** with a sentence saying so when there is no Chrome, never pass unchecked. |
|
|
234
|
+
| Which files the command runs, and what it hands them ([`bin/entry.js`](bin/entry.js)) | A table of cases: [`test/launcher.test.ts`](test/launcher.test.ts). |
|
|
235
|
+
| The package | [`test/package/`](test/package/): `npm pack`, `npm install` of that file in a directory outside the checkout, then the `opspicy` npm put there, on the example's suite: `--check`, `explorer`, `serve`, a run against the keeper, and a `config.ts` type-checked against what the package declares. |
|
|
236
|
+
| The image | CI builds it, type-checks the example's suite in it and runs it there. |
|
|
237
|
+
| What these documents link to | [`test/links.test.ts`](test/links.test.ts): every link, and every heading one names, exists. |
|
|
238
|
+
|
|
239
|
+
CI ([`.github/workflows/test.yml`](.github/workflows/test.yml)) runs all of it on Node 22.18 and 24, then pushes the image from the main branch and from a version tag.
|
|
240
|
+
|
|
241
|
+
To release: the version in `package.json`, and in the examples of this document, pushed to the main branch; then, once CI has pushed the image of that commit, a tag `v` + that version. CI refuses a tag that names another version, and gives the image of the commit its version: it is not built again.
|
|
242
|
+
|
|
243
|
+
The package is published by hand, from a checkout of that tag: `npm ci`, `npm run test:package`, then `npm publish`, which builds `dist/` first and publishes for everybody, as the manifest says. CI does not: it holds no token of npm.
|
|
244
|
+
|
|
245
|
+
## Status
|
|
246
|
+
|
|
247
|
+
> **In flight:** nothing.
|
|
248
|
+
|
|
249
|
+
One suite uses it: [the operations of saras](https://github.com/enspirit/saras/tree/main/tests/operations).
|
|
250
|
+
|
|
251
|
+
What the notation cannot say yet:
|
|
252
|
+
|
|
253
|
+
- **One call per case.** That a new password opens the account, that a link is good once: each is shown by what the one call left in the state, or told.
|
|
254
|
+
- **One precondition violated per counterexample**, so the order of two refusals is said nowhere.
|
|
255
|
+
- **What is answered is its status and its body.** A cookie cleared, a header set, a file that is neither JSON nor text: told only.
|
|
256
|
+
- **A member is checked where a type says what there is.** Elo's checker reads a formaldef under the types of the suite, and only a member that no type has is told: what may be `null` and is read as if it were not is left to the run. What a function is given has no type, so `withId(boards, 1).nam` is read, and gives nothing.
|
|
257
|
+
- **A predicate or a function is said in Elo, which decides and does not ask.** What a formaldef reads was observed before it is decided: neither can call the system.
|
|
258
|
+
- **What an area says is known to every area**: a condition by its sentence, a predicate, a function and a type by their name. The directory says where a word is at home, not who may say it. The same words written elsewhere with a formaldef of their own make that file unreadable, and the same words written with none take the formaldef silently.
|
|
259
|
+
- **A trigger is told.** `ReqTrig` says when an operation is performed without being asked, and one call shows nothing of it.
|
|
260
|
+
- **An agent is who calls.** What performs an operation without being asked (the server on its clock, say) has no entry to call, and is not an agent of `agents.yml`.
|
|
261
|
+
- **An operation with no example gets no counterexample from a condition**, which gives its first example to who violates it. And one written by hand does not stand in for it: who is not signed in violates more than the one precondition a counterexample is `for`. So that such an operation refuses a visitor is shown by no case.
|
|
262
|
+
- **`PATCH` is not a method an `entry` says.**
|
|
263
|
+
- **A type that is one of several is tried in their order.** Under `Int|String`, `"12"` is refused as a text given for a number; under `String|Int` it is a text.
|
|
264
|
+
- **Elo has no pattern**: "is an address" is approximated.
|
|
265
|
+
- **A Background is a seed of the database.** What else the world holds (a mail server, say) is not put back between cases.
|
|
266
|
+
- **`atRest` looks at the database.** Work a system starts without leaving a trace there is not waited for.
|
|
267
|
+
|
|
268
|
+
What the runner does not do yet:
|
|
269
|
+
|
|
270
|
+
- **"Nothing changed" is said of what was observed.** A requester whom every route of the state refuses is told nothing, before and after: where no relation is read (the fast run) and nobody looks on, a counterexample called by them shows that it is refused as said, and nothing of what the call left. A clause that names `seenBy.<actor>` has somebody look on.
|
|
271
|
+
- **A call has no time limit of its own**, nor a question asked of the database: a system that hangs holds a case for as long as Node waits.
|
|
272
|
+
- **An origin is a case's own within one run.** Given an `originHeader`, two runs may call from the same origins, and whoever looks on calls from the requester's.
|
|
273
|
+
- **A cookie is kept until it is taken back by name**: when it expires is not read.
|
|
274
|
+
- **`atRest` needs a `database`**, and is not waited for without one. It is waited for after any call that is not a `GET` and was not refused.
|
|
275
|
+
- **Gaps are not told at `LOG_LEVEL=WARN`**, and asking for one operation that has no case answers that nothing was run, without its gap.
|
|
276
|
+
- **Notes and the target of calls are kept by the name of the specification**, its directory's when `--name=` says none: two suites both in a `tests/operations`, opened as files in one browser, share them. Name each.
|
|
277
|
+
- **The API of a served explorer answers any program of the machine it is on**, not only the page it gave: it tells a page of another site from its own, and nothing more.
|
|
278
|
+
- **At `TRACE`, the path of the call that signs somebody in is shown**: a configuration that signs in by an address holding a token shows it there.
|
|
279
|
+
|
|
280
|
+
## Licence
|
|
281
|
+
|
|
282
|
+
[MIT](LICENSE). A document the explorer writes has inside it DM Sans, under the [SIL Open Font License](src/explorer/fonts/OFL.txt), and elo-form with Elo and Luxon, each MIT. The package holds the font too, with that licence beside it.
|
package/bin/entry.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Which file `opspicy` runs, and what it hands it: decided here, apart from the launcher that
|
|
2
|
+
// does it (opspicy), so that a table of cases holds it (test/launcher.test.ts). JavaScript, as
|
|
3
|
+
// the launcher is: installed, both are under a node_modules, where Node strips no types.
|
|
4
|
+
|
|
5
|
+
/** The file of each sub-command, from src/ or dist/, without its extension; the runner is asked by none. */
|
|
6
|
+
const ENTRIES = { explorer: 'explorer/build', serve: 'explorer/serve' };
|
|
7
|
+
const RUNNER = 'main';
|
|
8
|
+
|
|
9
|
+
/** Where Node refuses to run TypeScript: its own rule, a directory of that name anywhere above. */
|
|
10
|
+
const UNDER_NODE_MODULES = /[\\/]node_modules[\\/]/;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The file to run, from the directory of opspicy, and its arguments: the sub-command is named
|
|
14
|
+
* first or not at all, and is not handed on, each file reading its arguments as if it were run
|
|
15
|
+
* alone. The sources are run where they are and Node runs them, so from a checkout and in the
|
|
16
|
+
* image, whether or not a dist/ was built there: what is edited is what runs. The compiled files
|
|
17
|
+
* are run otherwise, which is what the package on npm is.
|
|
18
|
+
*
|
|
19
|
+
* @param {string[]} args what the command was given
|
|
20
|
+
* @param {{ at: string, sources: boolean }} where the directory of opspicy, and whether it holds src/
|
|
21
|
+
* @returns {{ file: string, args: string[] }}
|
|
22
|
+
*/
|
|
23
|
+
export function entryOf(args, { at, sources }) {
|
|
24
|
+
const asked = Object.hasOwn(ENTRIES, args[0] ?? '') ? ENTRIES[args[0]] : null;
|
|
25
|
+
const [directory, extension] = sources && !UNDER_NODE_MODULES.test(at) ? ['src', 'ts'] : ['dist', 'js'];
|
|
26
|
+
return { file: `${directory}/${asked ?? RUNNER}.${extension}`, args: asked ? args.slice(1) : args };
|
|
27
|
+
}
|
package/bin/opspicy
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// opspicy [<suite>] [--check] [--fast] [--report=<file>] runs the suite, or reads it (main)
|
|
3
|
+
// opspicy explorer [<suite>] [--out=<file>] … writes its explorer, one file (explorer/build)
|
|
4
|
+
// opspicy serve [<suite>] [--port=<port>] [--api] … serves its explorer (explorer/serve)
|
|
5
|
+
//
|
|
6
|
+
// The suite is a directory: this one when none is named. Each of the three is a file that reads
|
|
7
|
+
// the arguments of its process: this one says which (entry.js), takes the sub-command away, and
|
|
8
|
+
// runs it in this same process. From a checkout and in the image that file is TypeScript, of
|
|
9
|
+
// src/, which Node runs as it is; installed as a package it is the JavaScript of dist/.
|
|
10
|
+
//
|
|
11
|
+
// Node, not a shell: the one command is the same on macOS, Linux and Windows.
|
|
12
|
+
import { existsSync } from 'node:fs';
|
|
13
|
+
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { entryOf } from './entry.js';
|
|
15
|
+
|
|
16
|
+
const root = new URL('../', import.meta.url);
|
|
17
|
+
const { file, args } = entryOf(process.argv.slice(2), { at: fileURLToPath(root), sources: existsSync(new URL('src/main.ts', root)) });
|
|
18
|
+
process.argv.splice(2, Infinity, ...args);
|
|
19
|
+
await import(new URL(file, root).href);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Where a case and a clause are found: at an address made of their name. A sentence is named
|
|
2
|
+
// after where it stands (`CreateBoard/ReqPre/2`) unless its long form names it, and a name that
|
|
3
|
+
// is chosen may be the one another has, or become it once it is an address. Pure.
|
|
4
|
+
import { casesOf } from './planning.js';
|
|
5
|
+
/**
|
|
6
|
+
* The address a name gives: every character that is not a letter, a digit, `_` or `-` is a `-`.
|
|
7
|
+
* The explorer makes its anchors so, and a case is run by its anchor: `A/b` and `A b` are one.
|
|
8
|
+
*/
|
|
9
|
+
export const addressOf = (name) => name.replace(/[^A-Za-z0-9_-]/g, '-');
|
|
10
|
+
const told = (one) => `"${one.name}"${one.source ? ` (${one.source})` : ''}`;
|
|
11
|
+
/** Those of one kind that are at the address of another: each address with all who are there. */
|
|
12
|
+
function together(kind, citizens) {
|
|
13
|
+
const at = new Map();
|
|
14
|
+
for (const one of citizens)
|
|
15
|
+
at.set(addressOf(one.name), [...(at.get(addressOf(one.name)) ?? []), one]);
|
|
16
|
+
return [...at.values()].filter((all) => all.length > 1).map((all) => `the ${kind}s ${all.map(told).join(' and ')} are at the same address: name one otherwise`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What keeps each case, and each clause, of a suite from having an address of its own, across
|
|
20
|
+
* its operations: the cases it writes and those its conditions give it, its clauses and what an
|
|
21
|
+
* example alone also shows.
|
|
22
|
+
*/
|
|
23
|
+
export function sharedAddresses(operations, model) {
|
|
24
|
+
const cases = operations.flatMap((operation) => casesOf(operation, model));
|
|
25
|
+
const clauses = operations.flatMap((operation) => [...operation.clauses, ...operation.cases.flatMap((kase) => kase.and)]);
|
|
26
|
+
return [...together('case', cases), ...together('clause', clauses)];
|
|
27
|
+
}
|
package/dist/behind.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Whether a formaldef reads behind the front door: the relations of the database, `db`. What
|
|
2
|
+
// does is checked in the complete run only, and says so with `(+)`: the fast run reads no
|
|
3
|
+
// relation, and a clause that compared nothing with nothing would hold. Pure: Elo's parser is
|
|
4
|
+
// asked how the expression reads, and nothing is run.
|
|
5
|
+
import { parse } from '@enspirit/elo';
|
|
6
|
+
import { bare, definitionsUsed } from './naming.js';
|
|
7
|
+
const isTree = (value) => Boolean(value) && typeof value === 'object';
|
|
8
|
+
/** Where the relations are, beside the name `db`: in what there was, `old`, and in what was observed, `_.before` and `_.after`. */
|
|
9
|
+
const holdsRelations = (node) => isTree(node) && ((node.type === 'variable' && node.name === 'old') || (node.type === 'member_access' && ['before', 'after'].includes(String(node.property)) && isTree(node.object) && node.object.name === '_'));
|
|
10
|
+
/** `fetch(old, 'db')`: the member read by its key. */
|
|
11
|
+
const fetchesRelations = (args) => Array.isArray(args) && holdsRelations(args[0]) && isTree(args[1]) && args[1].type === 'string' && args[1].value === 'db';
|
|
12
|
+
/**
|
|
13
|
+
* Whether a tree of Elo reads the relations: it names `db` where nothing it binds itself is called
|
|
14
|
+
* so, or reads it of `old` or of what was observed. As Elo's parser reads it: a member `.db` of
|
|
15
|
+
* anything else, a text and a comment are not it. `_` handed whole to something is not followed.
|
|
16
|
+
*/
|
|
17
|
+
function reads(node, bound) {
|
|
18
|
+
if (Array.isArray(node))
|
|
19
|
+
return node.some((one) => reads(one, bound));
|
|
20
|
+
if (!isTree(node))
|
|
21
|
+
return false;
|
|
22
|
+
if (node.type === 'variable')
|
|
23
|
+
return node.name === 'db' && !bound.has('db');
|
|
24
|
+
if (node.type === 'member_access' && node.property === 'db' && holdsRelations(node.object))
|
|
25
|
+
return true;
|
|
26
|
+
if (node.type === 'function_call' && node.name === 'fetch' && fetchesRelations(node.args))
|
|
27
|
+
return true;
|
|
28
|
+
if (node.type === 'lambda')
|
|
29
|
+
return reads(node.body, new Set([...bound, ...node.params]));
|
|
30
|
+
if (node.type === 'let')
|
|
31
|
+
return readsLet(node.bindings, node.body, bound);
|
|
32
|
+
return Object.values(node).some((child) => reads(child, bound));
|
|
33
|
+
}
|
|
34
|
+
/** A `let`: each name is bound for those after it, and in its body. */
|
|
35
|
+
function readsLet(bindings, body, bound) {
|
|
36
|
+
let inner = bound;
|
|
37
|
+
for (const one of bindings) {
|
|
38
|
+
if (reads(one.value, inner))
|
|
39
|
+
return true;
|
|
40
|
+
inner = new Set([...inner, one.name]);
|
|
41
|
+
}
|
|
42
|
+
return reads(body, inner);
|
|
43
|
+
}
|
|
44
|
+
/** The same of a text. One Elo cannot read is told elsewhere: here it reads the database if it says the word at all. */
|
|
45
|
+
function readsRelations(text, given) {
|
|
46
|
+
try {
|
|
47
|
+
return reads(parse(text), new Set(given));
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return /(?<![\w.])db\b/.test(bare(text));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Asked once of each text: a predicate is named by many clauses, and each asks again. */
|
|
54
|
+
const asked = new Map();
|
|
55
|
+
function relationsRead(text, given = []) {
|
|
56
|
+
const key = `${given.join(',')}\n${text}`;
|
|
57
|
+
if (!asked.has(key))
|
|
58
|
+
asked.set(key, readsRelations(text, given));
|
|
59
|
+
return asked.get(key);
|
|
60
|
+
}
|
|
61
|
+
/** Whether an expression reads what only the database shows: itself, or through a predicate or a function it names. */
|
|
62
|
+
export function readsDatabase(source, definitions) {
|
|
63
|
+
return relationsRead(source) || definitionsUsed(source, definitions).some((one) => relationsRead(one.formaldef, one.parameters));
|
|
64
|
+
}
|
package/dist/citizens.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// The forms a citizen is written in. Pure.
|
|
2
|
+
//
|
|
3
|
+
// Every citizen has a long form, the same for all: its `name`, its `description`, and its
|
|
4
|
+
// `formaldef` when it has one, then what else its kind says.
|
|
5
|
+
//
|
|
6
|
+
// - name: board(id)
|
|
7
|
+
// description: The board of this number.
|
|
8
|
+
// formaldef: find(boards, b ~> b.id == id)
|
|
9
|
+
//
|
|
10
|
+
// A sentence (a clause, a condition) is its own description, so it has shorter forms, which say
|
|
11
|
+
// the same and nothing more: the sentence alone, or `sentence: formaldef`.
|
|
12
|
+
//
|
|
13
|
+
// - the filter is kept reduced to the attributes we know
|
|
14
|
+
// - it has a name: "!isBlank(input.name | '')"
|
|
15
|
+
import { marked } from './notation.js';
|
|
16
|
+
const LONG = ['name', 'description', 'formaldef'];
|
|
17
|
+
const isRecord = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
18
|
+
export const record = (value) => (isRecord(value) ? value : {});
|
|
19
|
+
export const list = (value) => (Array.isArray(value) ? value : []);
|
|
20
|
+
/**
|
|
21
|
+
* A list, as a file writes one under a key. A key that is absent or says nothing is an empty
|
|
22
|
+
* list. Anything else that is no list is told, and not read as an empty one: a dash forgotten
|
|
23
|
+
* would otherwise leave an operation with no clause, and nobody the wiser.
|
|
24
|
+
*/
|
|
25
|
+
export function listOf(what, value, problems) {
|
|
26
|
+
if (value !== undefined && value !== null && !Array.isArray(value))
|
|
27
|
+
problems.push(`${what} says a list, got ${(JSON.stringify(value) ?? String(value)).slice(0, 80)}`);
|
|
28
|
+
return list(value);
|
|
29
|
+
}
|
|
30
|
+
export const text = (value) => (typeof value === 'string' ? value.trim() : '');
|
|
31
|
+
const told = (value) => (value === undefined ? 'nothing' : JSON.stringify(value));
|
|
32
|
+
/** A kind of citizen, as a sentence names one: `an agent`, `a predicate`. */
|
|
33
|
+
export const a = (what) => `${/^[aeiou]/i.test(what) ? 'an' : 'a'} ${what}`;
|
|
34
|
+
/** A citizen, from its long form. What it lacks is told, and it is read as far as it goes: a citizen with no description is still one others may name. */
|
|
35
|
+
export function citizenOf(what, item, problems, { formaldef = false, also = [] } = {}) {
|
|
36
|
+
const raw = record(item);
|
|
37
|
+
const name = text(raw.name);
|
|
38
|
+
const known = [...LONG.filter((key) => key !== 'formaldef' || formaldef), ...also];
|
|
39
|
+
if (!name)
|
|
40
|
+
problems.push(`${a(what)} says its "name", its "description"${formaldef ? ' and its "formaldef"' : ''}, got ${told(item)}`);
|
|
41
|
+
const called = `${what} "${name}"`;
|
|
42
|
+
for (const key of Object.keys(raw))
|
|
43
|
+
if (name && !known.includes(key))
|
|
44
|
+
problems.push(`${called}: "${key}" is not something ${a(what)} says (${known.join(', ')})`);
|
|
45
|
+
if (name && !text(raw.description))
|
|
46
|
+
problems.push(`${called} says its "description"`);
|
|
47
|
+
if (name && formaldef && !text(raw.formaldef))
|
|
48
|
+
problems.push(`${called} says its "formaldef"`);
|
|
49
|
+
return { name, description: text(raw.description), formaldef: text(raw.formaldef) || undefined, raw };
|
|
50
|
+
}
|
|
51
|
+
function longSentence(what, raw, also) {
|
|
52
|
+
const known = [...LONG, ...also];
|
|
53
|
+
const unknown = Object.keys(raw).filter((key) => !known.includes(key));
|
|
54
|
+
if (unknown.length)
|
|
55
|
+
throw new Error(`${what}: "${unknown[0]}" is not something it says in its long form (${known.join(', ')})`);
|
|
56
|
+
if (!text(raw.description) || (raw.formaldef !== undefined && !text(raw.formaldef)))
|
|
57
|
+
throw new Error(`${what}: its long form says its "description", a sentence, and its "formaldef" in Elo if any, got ${told(raw)}`);
|
|
58
|
+
return { name: text(raw.name) || undefined, description: text(raw.description), formaldef: text(raw.formaldef) || undefined, long: true, raw };
|
|
59
|
+
}
|
|
60
|
+
/** A sentence: alone, with its formaldef as `sentence: formaldef`, or in its long form. Throws what is wrong with it. */
|
|
61
|
+
export function sentenceOf(what, item, also = []) {
|
|
62
|
+
if (typeof item === 'string' && item.trim())
|
|
63
|
+
return { ...marked(item), long: false, raw: {} };
|
|
64
|
+
const raw = record(item);
|
|
65
|
+
if ('description' in raw)
|
|
66
|
+
return longSentence(what, raw, also);
|
|
67
|
+
const [[sentence, formaldef] = [], ...others] = Object.entries(raw);
|
|
68
|
+
if (others.length || !sentence || typeof formaldef !== 'string' || !formaldef.trim())
|
|
69
|
+
throw new Error(`${what}: expected a sentence, one sentence with its formaldef in Elo, or its long form (${LONG.join(', ')}), got ${told(item)}`);
|
|
70
|
+
return { ...marked(sentence), formaldef: formaldef.trim(), long: false, raw: {} };
|
|
71
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface Answer {
|
|
2
|
+
status: number;
|
|
3
|
+
/** JSON as data, a text as it is, nothing otherwise. */
|
|
4
|
+
body: unknown;
|
|
5
|
+
}
|
|
6
|
+
/** Somebody's browser: it keeps the cookies it is given, and comes from one origin. */
|
|
7
|
+
export interface Browser {
|
|
8
|
+
call(method: string, path: string, body?: unknown): Promise<Answer>;
|
|
9
|
+
}
|
|
10
|
+
/** Asks the database, to read: one statement, its rows. */
|
|
11
|
+
export type Ask = (sql: string) => Promise<Record<string, unknown>[]>;
|
|
12
|
+
export interface Configuration {
|
|
13
|
+
/** The front door: an origin, with no path. */
|
|
14
|
+
api: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the database of this stack may be emptied. Setting a Background empties it, so a
|
|
17
|
+
* suite runs only where this is true: never where the database is somebody's.
|
|
18
|
+
*/
|
|
19
|
+
mayEmptyTheDatabase: boolean;
|
|
20
|
+
/** Sets the Background a case starts from: puts the database in a seed. */
|
|
21
|
+
background(seed: string): Promise<void>;
|
|
22
|
+
/** Signs an actor of the world in, on their browser; throws when they cannot. */
|
|
23
|
+
signIn(browser: Browser, actor: Record<string, unknown>, name: string): Promise<void>;
|
|
24
|
+
/** What a refusal is: the type of what is answered, and the code it carries. */
|
|
25
|
+
refusal: {
|
|
26
|
+
type: string;
|
|
27
|
+
code(body: unknown): unknown;
|
|
28
|
+
};
|
|
29
|
+
/** The database, for the relations of the state and to know the server is at rest. */
|
|
30
|
+
database?: string;
|
|
31
|
+
/** The header a proxy tells the origin of a call by. Given one, each case calls from an origin of its own. */
|
|
32
|
+
originHeader?: string;
|
|
33
|
+
/** Whether the server has nothing under way, for work that outlives the answer that started it. */
|
|
34
|
+
atRest?(ask: Ask): Promise<boolean>;
|
|
35
|
+
}
|
|
36
|
+
/** What a configuration is handed, so that it imports nothing. */
|
|
37
|
+
export interface Kit {
|
|
38
|
+
/** A variable of the environment. No default: a suite does not guess where the stack is. */
|
|
39
|
+
env(name: string): string;
|
|
40
|
+
/** Sets a Background by asking dbagent, over HTTP, to install the seed of that name. */
|
|
41
|
+
dbagent(url: string): Configuration['background'];
|
|
42
|
+
/** At rest when no key is held in the database: for a server that holds one while it works (PostgreSQL's advisory locks). */
|
|
43
|
+
noKeyHeld: NonNullable<Configuration['atRest']>;
|
|
44
|
+
}
|
|
45
|
+
export type Configure = (kit: Kit) => Configuration;
|
|
46
|
+
/** What keeps a suite from being configured: said in a line, and nothing is run. */
|
|
47
|
+
export declare class NotConfigured extends Error {
|
|
48
|
+
}
|
|
49
|
+
export declare const KIT: Kit;
|
|
50
|
+
/**
|
|
51
|
+
* The configuration of the suite under a directory. Whatever keeps it from being one is a
|
|
52
|
+
* `NotConfigured`, in a sentence: a file that is not there, that Node cannot read, that exports
|
|
53
|
+
* nothing, or that throws when asked. The file is named as a URL: a path is not one where it
|
|
54
|
+
* holds a `#` or a `%`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function configurationOf(root: string): Promise<Configuration>;
|