@kurvball/rehearse 0.0.0-stage → 1.3.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 +107 -2
- package/dist/affected/affected.d.ts +22 -0
- package/dist/affected/affected.js +162 -0
- package/dist/affected/index.d.ts +1 -0
- package/dist/affected/index.js +1 -0
- package/dist/args.d.ts +12 -0
- package/dist/args.js +42 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +100 -0
- package/dist/commands/check.d.ts +2 -0
- package/dist/commands/check.js +42 -0
- package/dist/commands/clean.d.ts +2 -0
- package/dist/commands/clean.js +37 -0
- package/dist/commands/command.d.ts +30 -0
- package/dist/commands/command.js +38 -0
- package/dist/commands/compare.d.ts +4 -0
- package/dist/commands/compare.js +89 -0
- package/dist/commands/drive.d.ts +2 -0
- package/dist/commands/drive.js +244 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +32 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +19 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.js +69 -0
- package/dist/commands/open.d.ts +2 -0
- package/dist/commands/open.js +60 -0
- package/dist/commands/people.d.ts +2 -0
- package/dist/commands/people.js +49 -0
- package/dist/commands/run.d.ts +4 -0
- package/dist/commands/run.js +84 -0
- package/dist/commands/services.d.ts +28 -0
- package/dist/commands/services.js +51 -0
- package/dist/commands/stage.d.ts +7 -0
- package/dist/commands/stage.js +53 -0
- package/dist/commands/up.d.ts +3 -0
- package/dist/commands/up.js +77 -0
- package/dist/commands/validate.d.ts +2 -0
- package/dist/commands/validate.js +35 -0
- package/dist/commands/worlds.d.ts +2 -0
- package/dist/commands/worlds.js +15 -0
- package/dist/compare/announce.d.ts +6 -0
- package/dist/compare/announce.js +27 -0
- package/dist/compare/compare.d.ts +83 -0
- package/dist/compare/compare.js +335 -0
- package/dist/compare/diff.d.ts +15 -0
- package/dist/compare/diff.js +105 -0
- package/dist/compare/index.d.ts +5 -0
- package/dist/compare/index.js +5 -0
- package/dist/compare/setaside.d.ts +29 -0
- package/dist/compare/setaside.js +121 -0
- package/dist/compare/verdict.d.ts +21 -0
- package/dist/compare/verdict.js +30 -0
- package/dist/drive/aria.d.ts +8 -0
- package/dist/drive/aria.js +12 -0
- package/dist/drive/browser.d.ts +34 -0
- package/dist/drive/browser.js +216 -0
- package/dist/drive/daemon.d.ts +1 -0
- package/dist/drive/daemon.js +171 -0
- package/dist/drive/grammar.d.ts +93 -0
- package/dist/drive/grammar.js +303 -0
- package/dist/drive/index.d.ts +4 -0
- package/dist/drive/index.js +4 -0
- package/dist/drive/names.d.ts +24 -0
- package/dist/drive/names.js +97 -0
- package/dist/drive/state.d.ts +13 -0
- package/dist/drive/state.js +28 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.js +32 -0
- package/dist/exec.d.ts +16 -0
- package/dist/exec.js +43 -0
- package/dist/git/checkout.d.ts +11 -0
- package/dist/git/checkout.js +90 -0
- package/dist/git/git.d.ts +7 -0
- package/dist/git/git.js +27 -0
- package/dist/git/index.d.ts +2 -0
- package/dist/git/index.js +2 -0
- package/dist/git/seed.d.ts +3 -0
- package/dist/git/seed.js +115 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +15 -0
- package/dist/kinds/all.d.ts +4 -0
- package/dist/kinds/all.js +4 -0
- package/dist/kinds/call/check.d.ts +29 -0
- package/dist/kinds/call/check.js +187 -0
- package/dist/kinds/call/definition.d.ts +16 -0
- package/dist/kinds/call/definition.js +33 -0
- package/dist/kinds/call/hurl.d.ts +65 -0
- package/dist/kinds/call/hurl.js +333 -0
- package/dist/kinds/call/kind.d.ts +8 -0
- package/dist/kinds/call/kind.js +122 -0
- package/dist/kinds/call/send.d.ts +32 -0
- package/dist/kinds/call/send.js +152 -0
- package/dist/kinds/call/words.d.ts +22 -0
- package/dist/kinds/call/words.js +24 -0
- package/dist/kinds/file/kind.d.ts +44 -0
- package/dist/kinds/file/kind.js +331 -0
- package/dist/kinds/file/layouts.d.ts +14 -0
- package/dist/kinds/file/layouts.js +103 -0
- package/dist/kinds/flow/kind.d.ts +21 -0
- package/dist/kinds/flow/kind.js +412 -0
- package/dist/kinds/flow/literal.d.ts +8 -0
- package/dist/kinds/flow/literal.js +148 -0
- package/dist/kinds/index.d.ts +10 -0
- package/dist/kinds/index.js +8 -0
- package/dist/kinds/kind.d.ts +63 -0
- package/dist/kinds/kind.js +21 -0
- package/dist/kinds/piece/canvas.d.ts +18 -0
- package/dist/kinds/piece/canvas.js +165 -0
- package/dist/kinds/piece/conventions.d.ts +12 -0
- package/dist/kinds/piece/conventions.js +101 -0
- package/dist/kinds/piece/csf.d.ts +10 -0
- package/dist/kinds/piece/csf.js +304 -0
- package/dist/kinds/piece/kind.d.ts +12 -0
- package/dist/kinds/piece/kind.js +297 -0
- package/dist/kinds/piece/server.d.ts +23 -0
- package/dist/kinds/piece/server.js +236 -0
- package/dist/manifest/fill.d.ts +4 -0
- package/dist/manifest/fill.js +7 -0
- package/dist/manifest/index.d.ts +5 -0
- package/dist/manifest/index.js +5 -0
- package/dist/manifest/init.d.ts +1 -0
- package/dist/manifest/init.js +47 -0
- package/dist/manifest/load.d.ts +7 -0
- package/dist/manifest/load.js +245 -0
- package/dist/manifest/types.d.ts +255 -0
- package/dist/manifest/types.js +7 -0
- package/dist/manifest/yaml.d.ts +5 -0
- package/dist/manifest/yaml.js +47 -0
- package/dist/people/index.d.ts +1 -0
- package/dist/people/index.js +1 -0
- package/dist/people/people.d.ts +39 -0
- package/dist/people/people.js +139 -0
- package/dist/run/cache.d.ts +20 -0
- package/dist/run/cache.js +98 -0
- package/dist/run/index.d.ts +5 -0
- package/dist/run/index.js +4 -0
- package/dist/run/observation.d.ts +27 -0
- package/dist/run/observation.js +1 -0
- package/dist/run/parallel.d.ts +28 -0
- package/dist/run/parallel.js +140 -0
- package/dist/run/session.d.ts +35 -0
- package/dist/run/session.js +399 -0
- package/dist/run/vars.d.ts +3 -0
- package/dist/run/vars.js +13 -0
- package/dist/scenarios/area.d.ts +6 -0
- package/dist/scenarios/area.js +37 -0
- package/dist/scenarios/files.d.ts +9 -0
- package/dist/scenarios/files.js +26 -0
- package/dist/scenarios/glob.d.ts +6 -0
- package/dist/scenarios/glob.js +106 -0
- package/dist/scenarios/index.d.ts +4 -0
- package/dist/scenarios/index.js +4 -0
- package/dist/scenarios/read.d.ts +18 -0
- package/dist/scenarios/read.js +54 -0
- package/dist/scenarios/scenario.d.ts +34 -0
- package/dist/scenarios/scenario.js +10 -0
- package/dist/schema.d.ts +14 -0
- package/dist/schema.js +122 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +2 -0
- package/dist/services/registry.d.ts +23 -0
- package/dist/services/registry.js +49 -0
- package/dist/services/service.d.ts +23 -0
- package/dist/services/service.js +313 -0
- package/dist/stage/api.d.ts +30 -0
- package/dist/stage/api.js +206 -0
- package/dist/stage/client/client/api.js +11 -0
- package/dist/stage/client/client/index.js +1 -0
- package/dist/stage/client/features/canvas/call.js +65 -0
- package/dist/stage/client/features/canvas/context.js +1 -0
- package/dist/stage/client/features/canvas/file.js +36 -0
- package/dist/stage/client/features/canvas/flow.js +59 -0
- package/dist/stage/client/features/canvas/index.js +1 -0
- package/dist/stage/client/features/canvas/observed.js +8 -0
- package/dist/stage/client/features/canvas/parts.js +24 -0
- package/dist/stage/client/features/canvas/piece.js +31 -0
- package/dist/stage/client/features/canvas/reach.js +6 -0
- package/dist/stage/client/features/canvas/views.js +16 -0
- package/dist/stage/client/features/list/index.js +1 -0
- package/dist/stage/client/features/list/list.js +53 -0
- package/dist/stage/client/features/list/reach.js +10 -0
- package/dist/stage/client/features/scenario/heading.js +14 -0
- package/dist/stage/client/features/scenario/index.js +1 -0
- package/dist/stage/client/features/scenario/reach.js +9 -0
- package/dist/stage/client/features/scenario/scenario.js +145 -0
- package/dist/stage/client/features/try/index.js +1 -0
- package/dist/stage/client/features/try/reach.js +12 -0
- package/dist/stage/client/features/try/try.js +65 -0
- package/dist/stage/client/index.html +16 -0
- package/dist/stage/client/main.js +24 -0
- package/dist/stage/client/primitives/busy.js +6 -0
- package/dist/stage/client/primitives/focus.js +21 -0
- package/dist/stage/client/primitives/h.js +25 -0
- package/dist/stage/client/primitives/index.js +6 -0
- package/dist/stage/client/primitives/keyed.js +16 -0
- package/dist/stage/client/primitives/say.js +6 -0
- package/dist/stage/client/primitives/state.js +21 -0
- package/dist/stage/client/primitives/types.js +1 -0
- package/dist/stage/client/primitives/verdicts.js +8 -0
- package/dist/stage/client/stage.css +652 -0
- package/dist/stage/compared.d.ts +20 -0
- package/dist/stage/compared.js +58 -0
- package/dist/stage/files.d.ts +4 -0
- package/dist/stage/files.js +59 -0
- package/dist/stage/guard.d.ts +3 -0
- package/dist/stage/guard.js +20 -0
- package/dist/stage/http.d.ts +12 -0
- package/dist/stage/http.js +34 -0
- package/dist/stage/index.d.ts +1 -0
- package/dist/stage/index.js +1 -0
- package/dist/stage/sending.d.ts +18 -0
- package/dist/stage/sending.js +66 -0
- package/dist/stage/server.d.ts +33 -0
- package/dist/stage/server.js +253 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +5 -0
- package/dist/worlds/define.d.ts +16 -0
- package/dist/worlds/define.js +45 -0
- package/dist/worlds/index.d.ts +2 -0
- package/dist/worlds/index.js +2 -0
- package/dist/worlds/worlds.d.ts +15 -0
- package/dist/worlds/worlds.js +46 -0
- package/llms.txt +46 -0
- package/package.json +84 -3
- package/schema/v1/announce.schema.json +28 -0
- package/schema/v1/check.schema.json +67 -0
- package/schema/v1/clean.schema.json +19 -0
- package/schema/v1/common.schema.json +210 -0
- package/schema/v1/comparison.schema.json +298 -0
- package/schema/v1/dependents.schema.json +30 -0
- package/schema/v1/drive.schema.json +112 -0
- package/schema/v1/error.schema.json +26 -0
- package/schema/v1/file-scenario.schema.json +175 -0
- package/schema/v1/flow.schema.json +216 -0
- package/schema/v1/init.schema.json +20 -0
- package/schema/v1/list.schema.json +70 -0
- package/schema/v1/manifest.schema.json +434 -0
- package/schema/v1/observation.schema.json +388 -0
- package/schema/v1/open.schema.json +14 -0
- package/schema/v1/people.schema.json +88 -0
- package/schema/v1/samples/announce.yaml +5 -0
- package/schema/v1/samples/check.json +13 -0
- package/schema/v1/samples/clean.json +1 -0
- package/schema/v1/samples/comparison.json +83 -0
- package/schema/v1/samples/dependents.json +7 -0
- package/schema/v1/samples/drive.json +10 -0
- package/schema/v1/samples/error.json +10 -0
- package/schema/v1/samples/file-scenario.yaml +13 -0
- package/schema/v1/samples/flow.yaml +13 -0
- package/schema/v1/samples/init.json +1 -0
- package/schema/v1/samples/list.json +24 -0
- package/schema/v1/samples/manifest.yaml +55 -0
- package/schema/v1/samples/observation.json +49 -0
- package/schema/v1/samples/open.json +6 -0
- package/schema/v1/samples/people.json +11 -0
- package/schema/v1/samples/services.json +27 -0
- package/schema/v1/samples/stage.json +6 -0
- package/schema/v1/samples/try.json +13 -0
- package/schema/v1/samples/up.json +16 -0
- package/schema/v1/samples/validate.json +7 -0
- package/schema/v1/samples/worlds.json +21 -0
- package/schema/v1/services.schema.json +72 -0
- package/schema/v1/stage.schema.json +14 -0
- package/schema/v1/try.schema.json +56 -0
- package/schema/v1/up.schema.json +55 -0
- package/schema/v1/validate.schema.json +40 -0
- package/schema/v1/worlds.schema.json +33 -0
- package/skill/rehearse/SKILL.md +148 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { NO_ONE, NOBODY } from '../../people/index.js';
|
|
2
|
+
import { HURL_WORDS } from './words.js';
|
|
3
|
+
export const PREDICATES = [
|
|
4
|
+
'==',
|
|
5
|
+
'!=',
|
|
6
|
+
'>=',
|
|
7
|
+
'<=',
|
|
8
|
+
'>',
|
|
9
|
+
'<',
|
|
10
|
+
'contains',
|
|
11
|
+
'includes',
|
|
12
|
+
'startsWith',
|
|
13
|
+
'endsWith',
|
|
14
|
+
'matches',
|
|
15
|
+
'exists',
|
|
16
|
+
'isString',
|
|
17
|
+
'isInteger',
|
|
18
|
+
'isBoolean',
|
|
19
|
+
'isCollection',
|
|
20
|
+
'isEmpty',
|
|
21
|
+
'isUuid',
|
|
22
|
+
'isIsoDate',
|
|
23
|
+
];
|
|
24
|
+
const UNARY = new Set([
|
|
25
|
+
'exists',
|
|
26
|
+
'isString',
|
|
27
|
+
'isInteger',
|
|
28
|
+
'isBoolean',
|
|
29
|
+
'isCollection',
|
|
30
|
+
'isEmpty',
|
|
31
|
+
'isUuid',
|
|
32
|
+
'isIsoDate',
|
|
33
|
+
]);
|
|
34
|
+
export class Refusal extends Error {
|
|
35
|
+
name = 'Refusal';
|
|
36
|
+
line;
|
|
37
|
+
says;
|
|
38
|
+
constructor(line, says) {
|
|
39
|
+
super(says);
|
|
40
|
+
this.line = line;
|
|
41
|
+
this.says = says;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const METHOD = /^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s+(\S+)\s*$/;
|
|
45
|
+
const SECTION = /^\[([A-Za-z]+)\]\s*$/;
|
|
46
|
+
const RESPONSE = /^HTTP(?:\/[\d.]+)?\s+(\d{3}|\*)\s*$/;
|
|
47
|
+
const HEADER = /^([A-Za-z0-9!#$%&'*+.^_`|~-]+)\s*:\s*(.*)$/;
|
|
48
|
+
const NAME = /^[A-Za-z_][A-Za-z0-9_-]*$/;
|
|
49
|
+
const VARIABLE = /\{\{\s*([A-Za-z_][A-Za-z0-9_-]*)\s*\}\}/;
|
|
50
|
+
const REQUEST_SECTIONS = new Set(['query', 'querystringparams', 'options']);
|
|
51
|
+
const RESPONSE_SECTIONS = new Set(['captures', 'asserts']);
|
|
52
|
+
const OPTIONS = new Set(['retry', 'retry-interval']);
|
|
53
|
+
const QUERIES = ['status', 'header', 'body', 'duration', 'jsonpath'];
|
|
54
|
+
const BODIES = [
|
|
55
|
+
[/^file,/, 'file'],
|
|
56
|
+
[/^base64,/, 'base64'],
|
|
57
|
+
[/^hex,/, 'hex'],
|
|
58
|
+
[/^</, 'XML'],
|
|
59
|
+
[/^`[^`]/, 'one-line string'],
|
|
60
|
+
];
|
|
61
|
+
function readString(src, from, line) {
|
|
62
|
+
let out = '';
|
|
63
|
+
for (let i = from + 1; i < src.length; i++) {
|
|
64
|
+
if (src[i] === '\\')
|
|
65
|
+
out += src[++i] ?? '';
|
|
66
|
+
else if (src[i] === '"')
|
|
67
|
+
return [out, i + 1];
|
|
68
|
+
else
|
|
69
|
+
out += src[i];
|
|
70
|
+
}
|
|
71
|
+
throw new Refusal(line, HURL_WORDS.unclosed);
|
|
72
|
+
}
|
|
73
|
+
function parseQuery(src, line) {
|
|
74
|
+
let rest = src.trim();
|
|
75
|
+
const word = /^[A-Za-z]+/.exec(rest)?.[0] ?? '';
|
|
76
|
+
if (!QUERIES.includes(word))
|
|
77
|
+
throw new Refusal(line, HURL_WORDS.query(src.trim()));
|
|
78
|
+
const kind = word;
|
|
79
|
+
rest = rest.slice(word.length).trim();
|
|
80
|
+
let arg = null;
|
|
81
|
+
if (kind === 'header' || kind === 'jsonpath') {
|
|
82
|
+
if (!rest.startsWith('"'))
|
|
83
|
+
throw new Refusal(line, HURL_WORDS.query(src.trim()));
|
|
84
|
+
const [read, end] = readString(rest, 0, line);
|
|
85
|
+
arg = read;
|
|
86
|
+
rest = rest.slice(end).trim();
|
|
87
|
+
}
|
|
88
|
+
let count = false;
|
|
89
|
+
for (;;) {
|
|
90
|
+
const filter = /^(count|nth|regex|split|replace|toInt|toFloat|toDate|format|decode|urlDecode|urlEncode|htmlEscape|htmlUnescape|base64Decode|base64Encode|daysAfterNow|daysBeforeNow|jsonpath|xpath|toString|location)\b/.exec(rest)?.[1];
|
|
91
|
+
if (!filter)
|
|
92
|
+
break;
|
|
93
|
+
if (filter !== 'count')
|
|
94
|
+
throw new Refusal(line, HURL_WORDS.filter(filter));
|
|
95
|
+
count = true;
|
|
96
|
+
rest = rest.slice(filter.length).trim();
|
|
97
|
+
}
|
|
98
|
+
return { query: { kind, arg, count }, rest };
|
|
99
|
+
}
|
|
100
|
+
function parseValue(src, line) {
|
|
101
|
+
const t = src.trim();
|
|
102
|
+
if (t.startsWith('"')) {
|
|
103
|
+
const [read, end] = readString(t, 0, line);
|
|
104
|
+
if (t.slice(end).trim())
|
|
105
|
+
throw new Refusal(line, HURL_WORDS.value(t));
|
|
106
|
+
return { string: read };
|
|
107
|
+
}
|
|
108
|
+
if (t.startsWith('/') && t.lastIndexOf('/') > 0)
|
|
109
|
+
return { regex: t.slice(1, t.lastIndexOf('/')) };
|
|
110
|
+
if (t === 'true' || t === 'false')
|
|
111
|
+
return { literal: t === 'true' };
|
|
112
|
+
if (t === 'null')
|
|
113
|
+
return { literal: null };
|
|
114
|
+
if (/^-?\d+(\.\d+)?$/.test(t))
|
|
115
|
+
return { literal: Number(t) };
|
|
116
|
+
if (/^\{\{\s*[A-Za-z_][A-Za-z0-9_-]*\s*\}\}$/.test(t))
|
|
117
|
+
return { string: t };
|
|
118
|
+
throw new Refusal(line, HURL_WORDS.value(t));
|
|
119
|
+
}
|
|
120
|
+
function parseAssert(src, line) {
|
|
121
|
+
const { query, rest } = parseQuery(src, line);
|
|
122
|
+
let r = rest;
|
|
123
|
+
let not = false;
|
|
124
|
+
if (/^not\s/.test(r)) {
|
|
125
|
+
not = true;
|
|
126
|
+
r = r.slice(3).trim();
|
|
127
|
+
}
|
|
128
|
+
const predicate = [...PREDICATES]
|
|
129
|
+
.sort((a, b) => b.length - a.length)
|
|
130
|
+
.find((p) => r.startsWith(p) && (/^\W/.test(p) || !/^\w/.test(r.slice(p.length))));
|
|
131
|
+
if (!predicate)
|
|
132
|
+
throw new Refusal(line, HURL_WORDS.predicate(src.trim()));
|
|
133
|
+
r = r.slice(predicate.length).trim();
|
|
134
|
+
if (UNARY.has(predicate)) {
|
|
135
|
+
if (r)
|
|
136
|
+
throw new Refusal(line, HURL_WORDS.predicate(src.trim()));
|
|
137
|
+
return { line, text: src.trim(), query, not, predicate, value: null };
|
|
138
|
+
}
|
|
139
|
+
return { line, text: src.trim(), query, not, predicate, value: parseValue(r, line) };
|
|
140
|
+
}
|
|
141
|
+
const msOf = (v, line) => {
|
|
142
|
+
const m = /^(\d+)\s*(ms|s)?$/.exec(v.trim());
|
|
143
|
+
if (!m)
|
|
144
|
+
throw new Refusal(line, HURL_WORDS.value(v.trim()));
|
|
145
|
+
return Number(m[1]) * (m[2] === 's' ? 1000 : 1);
|
|
146
|
+
};
|
|
147
|
+
export function parseHurl(text, file) {
|
|
148
|
+
const lines = text.split(/\r?\n/);
|
|
149
|
+
const calls = [];
|
|
150
|
+
const named = new Map();
|
|
151
|
+
let comment = null;
|
|
152
|
+
let draft = null;
|
|
153
|
+
let mode = 'headers';
|
|
154
|
+
const close = () => {
|
|
155
|
+
if (!draft)
|
|
156
|
+
return;
|
|
157
|
+
const { call, bodyLines } = draft;
|
|
158
|
+
if (mode === 'fenced')
|
|
159
|
+
throw new Refusal(call.line, HURL_WORDS.unclosed);
|
|
160
|
+
const body = bodyLines.join('\n').trim();
|
|
161
|
+
if (body)
|
|
162
|
+
call.body = body;
|
|
163
|
+
while (call.lines.length > 1 && /^\s*(#.*)?$/.test(call.lines.at(-1)))
|
|
164
|
+
call.lines.pop();
|
|
165
|
+
call.last = call.first + call.lines.length - 1;
|
|
166
|
+
calls.push(call);
|
|
167
|
+
draft = null;
|
|
168
|
+
};
|
|
169
|
+
lines.forEach((raw, i) => {
|
|
170
|
+
const line = raw.replace(/\s+$/, '');
|
|
171
|
+
const n = i + 1;
|
|
172
|
+
const trimmed = line.trim();
|
|
173
|
+
const method = mode === 'fenced' ? null : METHOD.exec(line);
|
|
174
|
+
if (method) {
|
|
175
|
+
close();
|
|
176
|
+
const name = comment && comment.n === n - 1 ? comment.text : `${method[1]} ${method[2]}`;
|
|
177
|
+
const twice = named.get(name);
|
|
178
|
+
if (twice !== undefined)
|
|
179
|
+
throw new Refusal(n, HURL_WORDS.twice(name, twice));
|
|
180
|
+
named.set(name, n);
|
|
181
|
+
const first = comment && comment.n === n - 1 ? n - 1 : n;
|
|
182
|
+
draft = {
|
|
183
|
+
call: {
|
|
184
|
+
file,
|
|
185
|
+
line: n,
|
|
186
|
+
first,
|
|
187
|
+
last: n,
|
|
188
|
+
name,
|
|
189
|
+
method: method[1],
|
|
190
|
+
url: method[2],
|
|
191
|
+
headers: [],
|
|
192
|
+
query: [],
|
|
193
|
+
options: { retry: 0, interval: 1000 },
|
|
194
|
+
body: null,
|
|
195
|
+
status: null,
|
|
196
|
+
captures: [],
|
|
197
|
+
asserts: [],
|
|
198
|
+
lines: first < n ? [lines[first - 1].trimEnd(), line] : [line],
|
|
199
|
+
},
|
|
200
|
+
bodyLines: [],
|
|
201
|
+
};
|
|
202
|
+
comment = null;
|
|
203
|
+
mode = 'headers';
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (mode !== 'fenced' && trimmed.startsWith('#')) {
|
|
207
|
+
const said = trimmed.replace(/^#\s?/, '').trim();
|
|
208
|
+
comment = said ? { n, text: said } : null;
|
|
209
|
+
draft?.call.lines.push(line);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (!draft) {
|
|
213
|
+
if (trimmed)
|
|
214
|
+
throw new Refusal(n, HURL_WORDS.line);
|
|
215
|
+
comment = null;
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const d = draft;
|
|
219
|
+
d.call.lines.push(line);
|
|
220
|
+
if (mode === 'fenced') {
|
|
221
|
+
if (trimmed === '```')
|
|
222
|
+
mode = 'body';
|
|
223
|
+
else
|
|
224
|
+
d.bodyLines.push(raw);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (!trimmed) {
|
|
228
|
+
comment = null;
|
|
229
|
+
if (mode === 'body')
|
|
230
|
+
d.bodyLines.push('');
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const response = RESPONSE.exec(trimmed);
|
|
234
|
+
if (response && (mode === 'headers' || mode === 'body' || mode === 'query' || mode === 'options')) {
|
|
235
|
+
d.call.status = { line: n, want: response[1] === '*' ? '*' : Number(response[1]) };
|
|
236
|
+
mode = 'response';
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const section = SECTION.exec(trimmed);
|
|
240
|
+
if (section) {
|
|
241
|
+
const which = section[1].toLowerCase();
|
|
242
|
+
const responding = mode === 'response' || mode === 'captures' || mode === 'asserts';
|
|
243
|
+
const allowed = responding ? RESPONSE_SECTIONS : REQUEST_SECTIONS;
|
|
244
|
+
if (!allowed.has(which))
|
|
245
|
+
throw new Refusal(n, HURL_WORDS.section(section[1]));
|
|
246
|
+
mode = which === 'querystringparams' ? 'query' : which;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
switch (mode) {
|
|
250
|
+
case 'captures': {
|
|
251
|
+
const c = /^([A-Za-z_][A-Za-z0-9_-]*)\s*:\s*(.+)$/.exec(trimmed);
|
|
252
|
+
if (!c)
|
|
253
|
+
throw new Refusal(n, HURL_WORDS.capture);
|
|
254
|
+
const { query, rest } = parseQuery(c[2], n);
|
|
255
|
+
if (rest)
|
|
256
|
+
throw new Refusal(n, HURL_WORDS.query(c[2]));
|
|
257
|
+
d.call.captures.push({ line: n, name: c[1], query });
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
case 'asserts':
|
|
261
|
+
d.call.asserts.push(parseAssert(trimmed, n));
|
|
262
|
+
return;
|
|
263
|
+
case 'response': {
|
|
264
|
+
const h = HEADER.exec(trimmed);
|
|
265
|
+
if (!h)
|
|
266
|
+
throw new Refusal(n, HURL_WORDS.line);
|
|
267
|
+
d.call.asserts.push({
|
|
268
|
+
line: n,
|
|
269
|
+
text: trimmed,
|
|
270
|
+
query: { kind: 'header', arg: h[1], count: false },
|
|
271
|
+
not: false,
|
|
272
|
+
predicate: '==',
|
|
273
|
+
value: { string: h[2].trim() },
|
|
274
|
+
});
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
case 'options':
|
|
278
|
+
case 'query': {
|
|
279
|
+
const h = HEADER.exec(trimmed);
|
|
280
|
+
if (!h)
|
|
281
|
+
throw new Refusal(n, HURL_WORDS.keyValue);
|
|
282
|
+
if (mode === 'query') {
|
|
283
|
+
d.call.query.push([h[1], h[2]]);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const option = h[1].toLowerCase();
|
|
287
|
+
if (!OPTIONS.has(option))
|
|
288
|
+
throw new Refusal(n, HURL_WORDS.option(h[1]));
|
|
289
|
+
if (option === 'retry')
|
|
290
|
+
d.call.options.retry = Math.max(0, Math.min(60, Number(h[2]) || 0));
|
|
291
|
+
else
|
|
292
|
+
d.call.options.interval = msOf(h[2], n);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
case 'headers': {
|
|
296
|
+
const h = HEADER.exec(line);
|
|
297
|
+
if (h && !line.startsWith('{') && !line.startsWith('[')) {
|
|
298
|
+
d.call.headers.push([h[1], h[2]]);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
mode = 'body';
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
default:
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
if (trimmed.startsWith('```')) {
|
|
308
|
+
if (trimmed !== '```' && !/^```[a-z]*$/.test(trimmed))
|
|
309
|
+
throw new Refusal(n, HURL_WORDS.body('one-line'));
|
|
310
|
+
mode = 'fenced';
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const kind = BODIES.find(([test]) => test.test(trimmed));
|
|
314
|
+
if (kind && !d.bodyLines.length)
|
|
315
|
+
throw new Refusal(n, HURL_WORDS.body(kind[1]));
|
|
316
|
+
d.bodyLines.push(raw);
|
|
317
|
+
});
|
|
318
|
+
close();
|
|
319
|
+
return { calls };
|
|
320
|
+
}
|
|
321
|
+
export function whoOf(call) {
|
|
322
|
+
const auth = call.headers.find(([k]) => k.toLowerCase() === 'authorization');
|
|
323
|
+
if (!auth)
|
|
324
|
+
return NOBODY;
|
|
325
|
+
const named = VARIABLE.exec(auth[1]);
|
|
326
|
+
return named ? named[1] : NO_ONE;
|
|
327
|
+
}
|
|
328
|
+
export const pathOf = (url) => url.replace(/^\{\{\s*api\s*\}\}/, '') || '/';
|
|
329
|
+
export function requestOf(call) {
|
|
330
|
+
const query = call.query.map(([k, v]) => `${k}=${v}`).join('&');
|
|
331
|
+
return `${call.method} ${pathOf(call.url)}${query ? `?${query}` : ''}`;
|
|
332
|
+
}
|
|
333
|
+
export const isVariableName = (v) => NAME.test(v);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Manifest } from '../../manifest/index.ts';
|
|
2
|
+
import { type ParsedCall } from './hurl.ts';
|
|
3
|
+
export interface CallSpec {
|
|
4
|
+
call: ParsedCall;
|
|
5
|
+
calls: ParsedCall[];
|
|
6
|
+
}
|
|
7
|
+
export declare const callService: (m: Manifest) => string | null;
|
|
8
|
+
export declare const relativeTo: (root: string, file: string) => string;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { jsonDifferences, noCounts, setAsideJson, setAsideText, textDifferences, } from '../../compare/index.js';
|
|
3
|
+
import { hashOf } from '../../manifest/index.js';
|
|
4
|
+
import { NOBODY, NO_ONE, scrubDeep } from '../../people/index.js';
|
|
5
|
+
import { registerReader } from '../../scenarios/index.js';
|
|
6
|
+
import { broken, registerRunner } from '../kind.js';
|
|
7
|
+
import { callDefinition, own } from './definition.js';
|
|
8
|
+
import { parseHurl, Refusal, whoOf } from './hurl.js';
|
|
9
|
+
import { sendFile } from './send.js';
|
|
10
|
+
export const callService = (m) => m.scenarios.calls.service ?? m.defaults.service;
|
|
11
|
+
registerReader({
|
|
12
|
+
kind: 'call',
|
|
13
|
+
read(f, text, ctx) {
|
|
14
|
+
let calls;
|
|
15
|
+
try {
|
|
16
|
+
calls = parseHurl(text, f.file).calls;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error instanceof Refusal)
|
|
20
|
+
throw Object.assign(new Error(error.says), { line: error.line, says: error.says });
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
const service = callService(ctx.manifest);
|
|
24
|
+
return calls.map((call, i) => {
|
|
25
|
+
const who = whoOf(call);
|
|
26
|
+
return {
|
|
27
|
+
id: `${f.file}#${call.name}`,
|
|
28
|
+
kind: 'call',
|
|
29
|
+
name: call.name,
|
|
30
|
+
file: f.file,
|
|
31
|
+
abs: f.abs,
|
|
32
|
+
line: call.line,
|
|
33
|
+
from: f.from,
|
|
34
|
+
area: ctx.area,
|
|
35
|
+
definition: callDefinition(calls, i),
|
|
36
|
+
context: hashOf(calls.slice(0, i).map(own)),
|
|
37
|
+
world: ctx.manifest.defaults.world,
|
|
38
|
+
person: who === NOBODY || who === NO_ONE ? null : who,
|
|
39
|
+
service,
|
|
40
|
+
covers: f.covers,
|
|
41
|
+
spec: { call, calls },
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
function compareBody(a, b, rules, counts) {
|
|
47
|
+
if (typeof a === 'string' && typeof b === 'string')
|
|
48
|
+
return textDifferences(setAsideText(a, rules, noCounts()), setAsideText(b, rules, counts), 'body');
|
|
49
|
+
return jsonDifferences(setAsideJson(a, rules, noCounts()), setAsideJson(b, rules, counts));
|
|
50
|
+
}
|
|
51
|
+
registerRunner({
|
|
52
|
+
kind: 'call',
|
|
53
|
+
version: 'call/2',
|
|
54
|
+
services: (s) => (s.service ? [s.service] : []),
|
|
55
|
+
unordered: (_s, m) => m.scenarios.calls.unordered ?? false,
|
|
56
|
+
async run(scenarios, ctx) {
|
|
57
|
+
const out = new Map();
|
|
58
|
+
const byFile = new Map();
|
|
59
|
+
for (const s of scenarios)
|
|
60
|
+
byFile.set(s.abs, [...(byFile.get(s.abs) ?? []), s]);
|
|
61
|
+
for (const group of byFile.values()) {
|
|
62
|
+
const first = group[0];
|
|
63
|
+
const service = first.service;
|
|
64
|
+
const running = service ? ctx.running.find((r) => r.name === service) : undefined;
|
|
65
|
+
if (service && !running?.url) {
|
|
66
|
+
for (const s of group)
|
|
67
|
+
out.set(s.id, broken('up', `The calls are sent to ${service}, which isn't up with a URL.`));
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const spec = first.spec;
|
|
71
|
+
const variables = {
|
|
72
|
+
...ctx.variables,
|
|
73
|
+
...ctx.manifest.scenarios.calls.variables,
|
|
74
|
+
...(running?.url && { api: running.url.replace(/\/+$/, '') }),
|
|
75
|
+
};
|
|
76
|
+
const { sent, before } = await sendFile(spec.calls, { variables, people: ctx.tokens, as: ctx.as }, new Set(group.map((s) => s.name)));
|
|
77
|
+
for (const s of group) {
|
|
78
|
+
const one = sent.find((x) => x.call.name === s.name);
|
|
79
|
+
if (!one)
|
|
80
|
+
continue;
|
|
81
|
+
const observed = scrubDeep({
|
|
82
|
+
kind: 'call',
|
|
83
|
+
request: one.request,
|
|
84
|
+
who: one.who,
|
|
85
|
+
status: one.status,
|
|
86
|
+
contentType: one.contentType,
|
|
87
|
+
body: one.body,
|
|
88
|
+
tries: one.tries,
|
|
89
|
+
...(before.has(s.name) && { before: before.get(s.name) }),
|
|
90
|
+
}, ctx.tokens);
|
|
91
|
+
out.set(s.id, {
|
|
92
|
+
ok: one.failures.length === 0,
|
|
93
|
+
failures: one.failures.map((f) => ({
|
|
94
|
+
line: f.line,
|
|
95
|
+
text: f.text,
|
|
96
|
+
expected: f.expected,
|
|
97
|
+
got: f.got,
|
|
98
|
+
})),
|
|
99
|
+
observed,
|
|
100
|
+
artifacts: [],
|
|
101
|
+
broke: null,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
},
|
|
107
|
+
compare(base, head, rules, counts) {
|
|
108
|
+
const diffs = [];
|
|
109
|
+
if (base.status !== head.status)
|
|
110
|
+
diffs.push({ path: 'status', base: String(base.status), head: String(head.status), count: 1 });
|
|
111
|
+
if (base.contentType !== head.contentType)
|
|
112
|
+
diffs.push({
|
|
113
|
+
path: 'content type',
|
|
114
|
+
base: String(base.contentType),
|
|
115
|
+
head: String(head.contentType),
|
|
116
|
+
count: 1,
|
|
117
|
+
});
|
|
118
|
+
diffs.push(...compareBody(base.body, head.body, rules, counts));
|
|
119
|
+
return diffs;
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
export const relativeTo = (root, file) => path.relative(root, file).split(path.sep).join('/');
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ParsedCall } from './hurl.ts';
|
|
2
|
+
export declare const CALL_LIMIT_MS = 15000;
|
|
3
|
+
export declare const BODY_LIMIT = 200000;
|
|
4
|
+
export interface CallFailure {
|
|
5
|
+
line: number;
|
|
6
|
+
text: string;
|
|
7
|
+
expected: string | null;
|
|
8
|
+
got: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface CallSent {
|
|
11
|
+
call: ParsedCall;
|
|
12
|
+
who: string;
|
|
13
|
+
request: string;
|
|
14
|
+
status: number | null;
|
|
15
|
+
contentType: string | null;
|
|
16
|
+
body: unknown;
|
|
17
|
+
ms: number;
|
|
18
|
+
failures: CallFailure[];
|
|
19
|
+
tries: (number | null)[];
|
|
20
|
+
unreached: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface SendInput {
|
|
23
|
+
variables: Record<string, string>;
|
|
24
|
+
people: Record<string, string>;
|
|
25
|
+
as?: string | null;
|
|
26
|
+
limitMs?: number;
|
|
27
|
+
}
|
|
28
|
+
export type Fetcher = typeof fetch;
|
|
29
|
+
export declare function sendFile(calls: readonly ParsedCall[], input: SendInput, only?: ReadonlySet<string> | null, fetcher?: Fetcher): Promise<{
|
|
30
|
+
sent: CallSent[];
|
|
31
|
+
before: Map<string, number>;
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { NO_ONE, NOBODY, scrub } from '../../people/index.js';
|
|
2
|
+
import { check, evaluate, NoValue, substitute } from './check.js';
|
|
3
|
+
import { requestOf, whoOf } from './hurl.js';
|
|
4
|
+
import { HURL_WORDS } from './words.js';
|
|
5
|
+
export const CALL_LIMIT_MS = 15_000;
|
|
6
|
+
export const BODY_LIMIT = 200_000;
|
|
7
|
+
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
8
|
+
const failure = (line, text, expected, got) => ({
|
|
9
|
+
line,
|
|
10
|
+
text,
|
|
11
|
+
expected,
|
|
12
|
+
got,
|
|
13
|
+
});
|
|
14
|
+
async function answerOf(call, headers, vars, fetcher, limitMs) {
|
|
15
|
+
const url = new URL(substitute(call.url, vars));
|
|
16
|
+
for (const [k, v] of call.query)
|
|
17
|
+
url.searchParams.append(k, substitute(v, vars));
|
|
18
|
+
const body = call.body === null ? undefined : substitute(call.body, vars);
|
|
19
|
+
if (body !== undefined && !Object.keys(headers).some((k) => k.toLowerCase() === 'content-type'))
|
|
20
|
+
headers['content-type'] = /^[[{]/.test(body.trim()) ? 'application/json' : 'text/plain';
|
|
21
|
+
const begun = performance.now();
|
|
22
|
+
const r = await fetcher(url.href, {
|
|
23
|
+
method: call.method,
|
|
24
|
+
headers,
|
|
25
|
+
...(body !== undefined && { body }),
|
|
26
|
+
redirect: 'manual',
|
|
27
|
+
signal: AbortSignal.timeout(limitMs),
|
|
28
|
+
});
|
|
29
|
+
const text = await r.text();
|
|
30
|
+
let json;
|
|
31
|
+
try {
|
|
32
|
+
json = JSON.parse(text);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
json = undefined;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
status: r.status,
|
|
39
|
+
headers: Object.fromEntries(r.headers.entries()),
|
|
40
|
+
text,
|
|
41
|
+
json,
|
|
42
|
+
ms: Math.round(performance.now() - begun),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function headersOf(call, as) {
|
|
46
|
+
if (as === null)
|
|
47
|
+
return call.headers;
|
|
48
|
+
const rest = call.headers.filter(([k]) => k.toLowerCase() !== 'authorization');
|
|
49
|
+
return as === NOBODY ? rest : [...rest, ['Authorization', `Bearer {{${as}}}`]];
|
|
50
|
+
}
|
|
51
|
+
async function sendOne(call, vars, input, as, fetcher) {
|
|
52
|
+
const who = as ?? whoOf(call);
|
|
53
|
+
const sent = {
|
|
54
|
+
call,
|
|
55
|
+
who,
|
|
56
|
+
request: requestOf(call),
|
|
57
|
+
status: null,
|
|
58
|
+
contentType: null,
|
|
59
|
+
body: null,
|
|
60
|
+
ms: 0,
|
|
61
|
+
failures: [],
|
|
62
|
+
tries: [],
|
|
63
|
+
unreached: false,
|
|
64
|
+
};
|
|
65
|
+
if (who !== NOBODY && who !== NO_ONE && !(who in input.people) && !(who in input.variables)) {
|
|
66
|
+
sent.failures.push(failure(call.line, sent.request, null, HURL_WORDS.noOne(who, Object.keys(input.people))));
|
|
67
|
+
sent.unreached = true;
|
|
68
|
+
return sent;
|
|
69
|
+
}
|
|
70
|
+
const tries = 1 + call.options.retry;
|
|
71
|
+
for (let t = 0; t < tries; t++) {
|
|
72
|
+
if (t)
|
|
73
|
+
await wait(call.options.interval);
|
|
74
|
+
sent.failures = [];
|
|
75
|
+
let answer;
|
|
76
|
+
try {
|
|
77
|
+
const headers = Object.fromEntries(headersOf(call, as).map(([k, v]) => [k, substitute(v, vars)]));
|
|
78
|
+
answer = await answerOf(call, headers, vars, fetcher, input.limitMs ?? CALL_LIMIT_MS);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const said = error instanceof NoValue
|
|
82
|
+
? error.message
|
|
83
|
+
: HURL_WORDS.unreached(error instanceof Error ? error.message : '');
|
|
84
|
+
sent.failures.push(failure(call.line, sent.request, null, said));
|
|
85
|
+
sent.tries.push(null);
|
|
86
|
+
sent.unreached = true;
|
|
87
|
+
if (error instanceof NoValue)
|
|
88
|
+
break;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
sent.unreached = false;
|
|
92
|
+
sent.status = answer.status;
|
|
93
|
+
sent.contentType = answer.headers['content-type']?.split(';')[0]?.trim() ?? null;
|
|
94
|
+
sent.ms = answer.ms;
|
|
95
|
+
sent.tries.push(answer.status);
|
|
96
|
+
sent.body = answer.json !== undefined ? answer.json : answer.text.slice(0, BODY_LIMIT);
|
|
97
|
+
const want = call.status;
|
|
98
|
+
if (want && want.want !== '*' && want.want !== answer.status)
|
|
99
|
+
sent.failures.push(failure(want.line, `HTTP ${want.want}`, String(want.want), String(answer.status)));
|
|
100
|
+
for (const a of call.asserts) {
|
|
101
|
+
try {
|
|
102
|
+
const c = check(a, answer, vars);
|
|
103
|
+
if (!c.ok)
|
|
104
|
+
sent.failures.push(failure(a.line, a.text, c.expected, c.got));
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
sent.failures.push(failure(a.line, a.text, null, error instanceof Error ? error.message : String(error)));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (sent.failures.length)
|
|
111
|
+
continue;
|
|
112
|
+
for (const c of call.captures) {
|
|
113
|
+
const got = evaluate(c.query, answer);
|
|
114
|
+
if (got.found && got.value !== undefined)
|
|
115
|
+
vars[c.name] = got.value;
|
|
116
|
+
else
|
|
117
|
+
sent.failures.push(failure(c.line, HURL_WORDS.noCapture(c.name), HURL_WORDS.aValue, HURL_WORDS.nothing));
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
sent.failures = sent.failures.map((f) => ({
|
|
122
|
+
...f,
|
|
123
|
+
got: f.got === null ? null : scrub(f.got, input.people),
|
|
124
|
+
expected: f.expected === null ? null : scrub(f.expected, input.people),
|
|
125
|
+
}));
|
|
126
|
+
if (sent.tries.length < 2)
|
|
127
|
+
sent.tries = [];
|
|
128
|
+
return sent;
|
|
129
|
+
}
|
|
130
|
+
export async function sendFile(calls, input, only = null, fetcher = fetch) {
|
|
131
|
+
const vars = { ...input.variables, ...input.people };
|
|
132
|
+
const lastAsked = only
|
|
133
|
+
? Math.max(-1, ...calls.map((c, i) => (only.has(c.name) ? i : -1)))
|
|
134
|
+
: calls.length - 1;
|
|
135
|
+
const out = [];
|
|
136
|
+
const before = new Map();
|
|
137
|
+
let ran = 0;
|
|
138
|
+
for (const [i, call] of calls.entries()) {
|
|
139
|
+
const asked = !only || only.has(call.name);
|
|
140
|
+
if (!asked && i > lastAsked)
|
|
141
|
+
continue;
|
|
142
|
+
const sent = await sendOne(call, vars, input, asked ? (input.as ?? null) : null, fetcher);
|
|
143
|
+
if (!asked) {
|
|
144
|
+
ran += 1;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (only && ran)
|
|
148
|
+
before.set(call.name, ran);
|
|
149
|
+
out.push(sent);
|
|
150
|
+
}
|
|
151
|
+
return { sent: out, before };
|
|
152
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const HURL_WORDS: {
|
|
2
|
+
readonly section: (name: string) => string;
|
|
3
|
+
readonly option: (name: string) => string;
|
|
4
|
+
readonly query: (what: string) => string;
|
|
5
|
+
readonly filter: (name: string) => string;
|
|
6
|
+
readonly predicate: (what: string) => string;
|
|
7
|
+
readonly value: (what: string) => string;
|
|
8
|
+
readonly body: (kind: string) => string;
|
|
9
|
+
readonly line: 'Rehearse can’t read this line as Hurl’s plain part';
|
|
10
|
+
readonly keyValue: 'a line here is key: value';
|
|
11
|
+
readonly capture: 'a capture is name: query';
|
|
12
|
+
readonly twice: (name: string, first: number) => string;
|
|
13
|
+
readonly unclosed: 'a string or a body here is never closed';
|
|
14
|
+
readonly noValue: (name: string) => string;
|
|
15
|
+
readonly noOne: (who: string, named: readonly string[]) => string;
|
|
16
|
+
readonly noCapture: (name: string) => string;
|
|
17
|
+
readonly aValue: 'a value';
|
|
18
|
+
readonly nothing: '(nothing there)';
|
|
19
|
+
readonly notJson: 'the body is not JSON';
|
|
20
|
+
readonly count: 'count needs a collection';
|
|
21
|
+
readonly unreached: (why: string) => string;
|
|
22
|
+
};
|