@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,90 @@
|
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, rmSync, statSync, utimesSync, writeFileSync, } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { RehearseError } from '../errors.js';
|
|
4
|
+
import { sh, tail } from '../exec.js';
|
|
5
|
+
import { stateDir } from '../services/index.js';
|
|
6
|
+
import { commitOf, git, gitOr, topOf } from './git.js';
|
|
7
|
+
import { preparedMark, seedDependencies, unseed } from './seed.js';
|
|
8
|
+
export const checkoutsDir = (m) => path.join(stateDir(m.dir), 'checkouts');
|
|
9
|
+
export function dirtyOf(m, checkout) {
|
|
10
|
+
const status = gitOr(checkout, ['status', '--porcelain', '--untracked-files=all']);
|
|
11
|
+
if (status === null)
|
|
12
|
+
return true;
|
|
13
|
+
const rehearsesOwnFiles = [
|
|
14
|
+
...m.overlay.map((o) => o.to.replace(/\/+$/, '')),
|
|
15
|
+
path.relative(checkout, stateDir(m.dir)).split(path.sep).join('/'),
|
|
16
|
+
];
|
|
17
|
+
return status
|
|
18
|
+
.split('\n')
|
|
19
|
+
.filter(Boolean)
|
|
20
|
+
.map((line) => line.slice(3).replace(/^"|"$/g, ''))
|
|
21
|
+
.some((file) => !rehearsesOwnFiles.some((i) => i && (file === i || file.startsWith(`${i}/`))));
|
|
22
|
+
}
|
|
23
|
+
export function infoOf(m, checkout, ref) {
|
|
24
|
+
return { path: checkout, ref, commit: commitOf(checkout), dirty: dirtyOf(m, checkout) };
|
|
25
|
+
}
|
|
26
|
+
export function overlay(m, checkout) {
|
|
27
|
+
for (const o of m.overlay) {
|
|
28
|
+
if (!existsSync(o.from))
|
|
29
|
+
throw new RehearseError('overlay', `The overlay ${o.from} isn't there.`);
|
|
30
|
+
const to = path.resolve(checkout, o.to);
|
|
31
|
+
mkdirSync(path.dirname(to), { recursive: true });
|
|
32
|
+
cpSync(o.from, to, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const NAMED_AS_A_FOLDER = /^(?:\.{1,2}(?:\/|$)|\/|~\/)/;
|
|
36
|
+
export async function checkoutFor(m, repo, given, progress, keep = [], cwd = process.cwd()) {
|
|
37
|
+
if (NAMED_AS_A_FOLDER.test(given)) {
|
|
38
|
+
const asPath = path.resolve(cwd, given.replace(/^~(?=\/)/, process.env.HOME ?? '~'));
|
|
39
|
+
if (!existsSync(asPath) || !statSync(asPath).isDirectory())
|
|
40
|
+
throw new RehearseError('no_checkout', `There is no checkout at ${asPath}.`);
|
|
41
|
+
return { path: topOf(asPath) ?? asPath, ref: null };
|
|
42
|
+
}
|
|
43
|
+
const commit = commitOf(repo, given);
|
|
44
|
+
if (!commit)
|
|
45
|
+
throw new RehearseError('git', `${given} isn't a commit Rehearse can find in ${repo}.${existsSync(path.resolve(cwd, given)) ? ` To mean the folder, write ./${given}.` : ''}`);
|
|
46
|
+
const dir = path.join(checkoutsDir(m), commit.slice(0, 12));
|
|
47
|
+
if (!existsSync(dir)) {
|
|
48
|
+
mkdirSync(checkoutsDir(m), { recursive: true });
|
|
49
|
+
progress(`Checking out ${given} (${commit.slice(0, 12)}) into ${dir}`);
|
|
50
|
+
gitOr(repo, ['worktree', 'prune']);
|
|
51
|
+
git(repo, ['worktree', 'add', '--detach', dir, commit]);
|
|
52
|
+
}
|
|
53
|
+
if (m.prepare && !existsSync(preparedMark(dir))) {
|
|
54
|
+
const seeded = m.seed ? seedDependencies(dir, progress) : [];
|
|
55
|
+
progress(`Preparing ${dir}: ${m.prepare}`);
|
|
56
|
+
let ran = await sh(m.prepare, { cwd: dir, timeoutMs: 30 * 60_000 });
|
|
57
|
+
if (ran.code !== 0 && seeded.length > 0) {
|
|
58
|
+
progress(`Preparing ${dir} again, without the seeded dependencies: ${m.prepare}`);
|
|
59
|
+
unseed(seeded);
|
|
60
|
+
ran = await sh(m.prepare, { cwd: dir, timeoutMs: 30 * 60_000 });
|
|
61
|
+
}
|
|
62
|
+
if (ran.code !== 0)
|
|
63
|
+
throw new RehearseError('prepare', `Preparing ${given} failed (${m.prepare}): ${tail(ran.stderr || ran.stdout) || `exit ${ran.code}`}`);
|
|
64
|
+
writeFileSync(preparedMark(dir), `${new Date().toISOString()}\n`);
|
|
65
|
+
}
|
|
66
|
+
const now = new Date();
|
|
67
|
+
utimesSync(dir, now, now);
|
|
68
|
+
evict(m, repo, [dir, ...keep]);
|
|
69
|
+
return { path: dir, ref: given };
|
|
70
|
+
}
|
|
71
|
+
export function evict(m, repo, keep = []) {
|
|
72
|
+
const root = checkoutsDir(m);
|
|
73
|
+
if (!existsSync(root))
|
|
74
|
+
return [];
|
|
75
|
+
const dirs = readdirSync(root, { withFileTypes: true })
|
|
76
|
+
.filter((d) => d.isDirectory())
|
|
77
|
+
.map((d) => path.join(root, d.name))
|
|
78
|
+
.sort((a, b) => statSync(b).mtimeMs - statSync(a).mtimeMs);
|
|
79
|
+
const gone = [];
|
|
80
|
+
for (const dir of dirs.slice(m.budget.checkouts)) {
|
|
81
|
+
if (keep.some((k) => path.resolve(k) === path.resolve(dir)))
|
|
82
|
+
continue;
|
|
83
|
+
gitOr(repo, ['worktree', 'remove', '--force', dir]);
|
|
84
|
+
rmSync(dir, { recursive: true, force: true });
|
|
85
|
+
rmSync(preparedMark(dir), { force: true });
|
|
86
|
+
gone.push(dir);
|
|
87
|
+
}
|
|
88
|
+
gitOr(repo, ['worktree', 'prune']);
|
|
89
|
+
return gone;
|
|
90
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function git(dir: string, args: readonly string[], options?: {
|
|
2
|
+
input?: string;
|
|
3
|
+
}): string;
|
|
4
|
+
export declare function gitOr(dir: string, args: readonly string[]): string | null;
|
|
5
|
+
export declare const topOf: (dir: string) => string | null;
|
|
6
|
+
export declare const commitOf: (dir: string, ref?: string) => string | null;
|
|
7
|
+
export declare const isDirty: (dir: string) => boolean;
|
package/dist/git/git.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { RehearseError, errorText } from '../errors.js';
|
|
3
|
+
export function git(dir, args, options = {}) {
|
|
4
|
+
try {
|
|
5
|
+
return execFileSync('git', ['-C', dir, ...args], {
|
|
6
|
+
encoding: 'utf8',
|
|
7
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
8
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
9
|
+
...(options.input !== undefined && { input: options.input }),
|
|
10
|
+
}).trimEnd();
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
const said = error.stderr?.trim().split('\n').at(-1) ?? errorText(error);
|
|
14
|
+
throw new RehearseError('git', `git ${args.join(' ')} failed in ${dir}: ${said}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function gitOr(dir, args) {
|
|
18
|
+
try {
|
|
19
|
+
return git(dir, args);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const topOf = (dir) => gitOr(dir, ['rev-parse', '--show-toplevel']);
|
|
26
|
+
export const commitOf = (dir, ref = 'HEAD') => gitOr(dir, ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`]);
|
|
27
|
+
export const isDirty = (dir) => (gitOr(dir, ['status', '--porcelain', '--untracked-files=no']) ?? '') !== '';
|
package/dist/git/seed.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { constants, copyFileSync, existsSync, linkSync, lstatSync, mkdirSync, readdirSync, readFileSync, readlinkSync, rmSync, statSync, symlinkSync, writeFileSync, } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { gitOr } from './git.js';
|
|
5
|
+
const LOCKFILES = [
|
|
6
|
+
'pnpm-lock.yaml',
|
|
7
|
+
'package-lock.json',
|
|
8
|
+
'npm-shrinkwrap.json',
|
|
9
|
+
'yarn.lock',
|
|
10
|
+
'bun.lock',
|
|
11
|
+
'bun.lockb',
|
|
12
|
+
];
|
|
13
|
+
const CACHES_REBUILT_ON_DEMAND = new Set(['.cache', '.vite']);
|
|
14
|
+
const SMALL_ENOUGH_TO_REWRITE = 1_000_000;
|
|
15
|
+
export const preparedMark = (dir) => `${dir}.prepared`;
|
|
16
|
+
function lockfilesOf(dir) {
|
|
17
|
+
const hash = createHash('sha256');
|
|
18
|
+
let found = false;
|
|
19
|
+
for (const name of LOCKFILES) {
|
|
20
|
+
const file = path.join(dir, name);
|
|
21
|
+
if (!existsSync(file))
|
|
22
|
+
continue;
|
|
23
|
+
found = true;
|
|
24
|
+
hash.update(`${name}\n`).update(readFileSync(file));
|
|
25
|
+
}
|
|
26
|
+
return found ? hash.digest('hex') : null;
|
|
27
|
+
}
|
|
28
|
+
function newestPreparedWithTheSameLockfile(dir) {
|
|
29
|
+
const wanted = lockfilesOf(dir);
|
|
30
|
+
if (wanted === null)
|
|
31
|
+
return null;
|
|
32
|
+
const root = path.dirname(dir);
|
|
33
|
+
const prepared = readdirSync(root, { withFileTypes: true })
|
|
34
|
+
.filter((d) => d.isDirectory() && path.join(root, d.name) !== dir)
|
|
35
|
+
.map((d) => path.join(root, d.name))
|
|
36
|
+
.filter((other) => existsSync(preparedMark(other)))
|
|
37
|
+
.sort((a, b) => statSync(b).mtimeMs - statSync(a).mtimeMs);
|
|
38
|
+
return prepared.find((other) => lockfilesOf(other) === wanted) ?? null;
|
|
39
|
+
}
|
|
40
|
+
function packageFolders(dir) {
|
|
41
|
+
const listed = gitOr(dir, ['ls-files', '-z', '--', 'package.json', '*/package.json']) ?? '';
|
|
42
|
+
return [
|
|
43
|
+
...new Set(listed
|
|
44
|
+
.split('\0')
|
|
45
|
+
.filter((f) => f && !f.split('/').includes('node_modules'))
|
|
46
|
+
.map((f) => path.posix.dirname(f))),
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
const placedAgain = (text, from, to) => text.split(from).join(to);
|
|
50
|
+
function copyLink(from, to, roots) {
|
|
51
|
+
const target = readlinkSync(from);
|
|
52
|
+
const inside = path.isAbsolute(target) && target.startsWith(`${roots.from}${path.sep}`);
|
|
53
|
+
symlinkSync(inside ? path.join(roots.to, path.relative(roots.from, target)) : target, to);
|
|
54
|
+
}
|
|
55
|
+
function copyFileOver(from, to, roots, mayNameTheCheckout) {
|
|
56
|
+
const seen = lstatSync(from);
|
|
57
|
+
if (mayNameTheCheckout && seen.size <= SMALL_ENOUGH_TO_REWRITE) {
|
|
58
|
+
const text = readFileSync(from, 'utf8');
|
|
59
|
+
if (text.includes(roots.from)) {
|
|
60
|
+
writeFileSync(to, placedAgain(text, roots.from, roots.to), { mode: seen.mode & 0o7777 });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (seen.nlink > 1)
|
|
65
|
+
try {
|
|
66
|
+
linkSync(from, to);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
rmSync(to, { force: true });
|
|
71
|
+
}
|
|
72
|
+
copyFileSync(from, to, constants.COPYFILE_FICLONE);
|
|
73
|
+
}
|
|
74
|
+
function copyTree(from, to, roots) {
|
|
75
|
+
mkdirSync(to);
|
|
76
|
+
const isBin = path.basename(from) === '.bin';
|
|
77
|
+
const isModules = path.basename(from) === 'node_modules';
|
|
78
|
+
for (const entry of readdirSync(from, { withFileTypes: true })) {
|
|
79
|
+
if (isModules && CACHES_REBUILT_ON_DEMAND.has(entry.name))
|
|
80
|
+
continue;
|
|
81
|
+
const [a, b] = [path.join(from, entry.name), path.join(to, entry.name)];
|
|
82
|
+
if (entry.isSymbolicLink())
|
|
83
|
+
copyLink(a, b, roots);
|
|
84
|
+
else if (entry.isDirectory())
|
|
85
|
+
copyTree(a, b, roots);
|
|
86
|
+
else if (entry.isFile())
|
|
87
|
+
copyFileOver(a, b, roots, isBin || (isModules && entry.name.startsWith('.')));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export function seedDependencies(dir, progress) {
|
|
91
|
+
const from = newestPreparedWithTheSameLockfile(dir);
|
|
92
|
+
if (from === null)
|
|
93
|
+
return [];
|
|
94
|
+
const seeded = [];
|
|
95
|
+
for (const folder of packageFolders(dir)) {
|
|
96
|
+
const source = path.join(from, folder, 'node_modules');
|
|
97
|
+
const target = path.join(dir, folder, 'node_modules');
|
|
98
|
+
if (!existsSync(source) || existsSync(target) || !existsSync(path.dirname(target)))
|
|
99
|
+
continue;
|
|
100
|
+
try {
|
|
101
|
+
copyTree(source, target, { from, to: dir });
|
|
102
|
+
seeded.push(target);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
rmSync(target, { recursive: true, force: true });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (seeded.length > 0)
|
|
109
|
+
progress(`Seeded ${seeded.length} node_modules folder${seeded.length === 1 ? '' : 's'} from ${from}, prepared with the same lockfile.`);
|
|
110
|
+
return seeded;
|
|
111
|
+
}
|
|
112
|
+
export function unseed(seeded) {
|
|
113
|
+
for (const dir of seeded)
|
|
114
|
+
rmSync(dir, { recursive: true, force: true });
|
|
115
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { main as runCli } from './cli.ts';
|
|
2
|
+
export { findManifest, loadManifest, manifestFrom, hashOf } from './manifest/index.ts';
|
|
3
|
+
export type { Manifest, Service, Person, World, Standin, Kind } from './manifest/index.ts';
|
|
4
|
+
export { fill } from './manifest/index.ts';
|
|
5
|
+
export { validate, validatorOf, SCHEMAS, SCHEMA_DIR, type SchemaName } from './schema.ts';
|
|
6
|
+
export { signedInFrom, scrub, scrubDeep } from './people/index.ts';
|
|
7
|
+
export { chainOf } from './worlds/index.ts';
|
|
8
|
+
export { readScenarios } from './scenarios/index.ts';
|
|
9
|
+
export type { Scenario, ScenarioRef } from './scenarios/index.ts';
|
|
10
|
+
export { RehearseError } from './errors.ts';
|
|
11
|
+
export { VERSION } from './version.ts';
|
|
12
|
+
export { compare, type Comparison, type CompareOptions } from './compare/index.ts';
|
|
13
|
+
export { runSide, type SideRun, type SessionOptions } from './run/index.ts';
|
|
14
|
+
export type { Observation } from './run/index.ts';
|
|
15
|
+
export { affected } from './affected/index.ts';
|
|
16
|
+
export { bringUp, bringDown } from './services/index.ts';
|
|
17
|
+
export { defineWorld, buildWorld, worldChain, worldMain, type WorldDefinition, type WorldContext, } from './worlds/index.ts';
|
|
18
|
+
export { setAsideJson, setAsideText } from './compare/index.ts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { main as runCli } from './cli.js';
|
|
2
|
+
export { findManifest, loadManifest, manifestFrom, hashOf } from './manifest/index.js';
|
|
3
|
+
export { fill } from './manifest/index.js';
|
|
4
|
+
export { validate, validatorOf, SCHEMAS, SCHEMA_DIR } from './schema.js';
|
|
5
|
+
export { signedInFrom, scrub, scrubDeep } from './people/index.js';
|
|
6
|
+
export { chainOf } from './worlds/index.js';
|
|
7
|
+
export { readScenarios } from './scenarios/index.js';
|
|
8
|
+
export { RehearseError } from './errors.js';
|
|
9
|
+
export { VERSION } from './version.js';
|
|
10
|
+
export { compare } from './compare/index.js';
|
|
11
|
+
export { runSide } from './run/index.js';
|
|
12
|
+
export { affected } from './affected/index.js';
|
|
13
|
+
export { bringUp, bringDown } from './services/index.js';
|
|
14
|
+
export { defineWorld, buildWorld, worldChain, worldMain, } from './worlds/index.js';
|
|
15
|
+
export { setAsideJson, setAsideText } from './compare/index.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Assert, Query } from './hurl.ts';
|
|
2
|
+
export interface Answer {
|
|
3
|
+
status: number;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
text: string;
|
|
6
|
+
json: unknown;
|
|
7
|
+
ms: number;
|
|
8
|
+
}
|
|
9
|
+
export interface Found {
|
|
10
|
+
found: boolean;
|
|
11
|
+
value: unknown;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function jsonpath(doc: unknown, path: string): Found;
|
|
15
|
+
export declare function evaluate(query: Query, answer: Answer): Found;
|
|
16
|
+
export declare class NoValue extends Error {
|
|
17
|
+
name: string;
|
|
18
|
+
readonly variable: string;
|
|
19
|
+
constructor(variable: string);
|
|
20
|
+
}
|
|
21
|
+
export declare function substitute(text: string, vars: Readonly<Record<string, unknown>>): string;
|
|
22
|
+
export declare const variablesIn: (text: string) => string[];
|
|
23
|
+
export interface Checked {
|
|
24
|
+
ok: boolean;
|
|
25
|
+
expected: string | null;
|
|
26
|
+
got: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const shown: (v: unknown) => string;
|
|
29
|
+
export declare function check(assert: Assert, answer: Answer, vars: Readonly<Record<string, unknown>>): Checked;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { HURL_WORDS } from './words.js';
|
|
2
|
+
const isObject = (x) => typeof x === 'object' && x !== null;
|
|
3
|
+
function filtered(nodes, inner) {
|
|
4
|
+
const f = /^\?\(@\.([A-Za-z_][A-Za-z0-9_]*)\s*(==|!=)\s*('([^']*)'|"([^"]*)"|-?\d+(?:\.\d+)?|true|false|null)\)$/.exec(inner);
|
|
5
|
+
if (!f)
|
|
6
|
+
throw new Error(`unsupported filter ${inner}`);
|
|
7
|
+
const want = f[4] ?? f[5] ?? JSON.parse(f[3]);
|
|
8
|
+
return nodes.flatMap((x) => (Array.isArray(x) ? x : []).filter((y) => isObject(y) && (f[2] === '==') === (y[f[1]] === want)));
|
|
9
|
+
}
|
|
10
|
+
export function jsonpath(doc, path) {
|
|
11
|
+
if (!path.startsWith('$'))
|
|
12
|
+
throw new Error(`a JSON path starts with $: ${path}`);
|
|
13
|
+
let nodes = [doc];
|
|
14
|
+
let definite = true;
|
|
15
|
+
let i = 1;
|
|
16
|
+
while (i < path.length) {
|
|
17
|
+
if (path.startsWith('..', i))
|
|
18
|
+
throw new Error(`unsupported JSON path ${path}`);
|
|
19
|
+
if (path[i] === '.') {
|
|
20
|
+
const m = /^\.([A-Za-z_$][A-Za-z0-9_$-]*|\*)/.exec(path.slice(i));
|
|
21
|
+
if (!m)
|
|
22
|
+
throw new Error(`bad JSON path ${path}`);
|
|
23
|
+
i += m[0].length;
|
|
24
|
+
if (m[1] === '*') {
|
|
25
|
+
definite = false;
|
|
26
|
+
nodes = nodes.flatMap((x) => (isObject(x) ? Object.values(x) : []));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const key = m[1];
|
|
30
|
+
nodes = nodes.flatMap((x) => (isObject(x) && key in x ? [x[key]] : []));
|
|
31
|
+
}
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (path[i] === '[') {
|
|
35
|
+
const end = path.indexOf(']', i);
|
|
36
|
+
if (end < 0)
|
|
37
|
+
throw new Error(`bad JSON path ${path}`);
|
|
38
|
+
const inner = path.slice(i + 1, end).trim();
|
|
39
|
+
i = end + 1;
|
|
40
|
+
if (inner === '*') {
|
|
41
|
+
definite = false;
|
|
42
|
+
nodes = nodes.flatMap((x) => (Array.isArray(x) ? x : isObject(x) ? Object.values(x) : []));
|
|
43
|
+
}
|
|
44
|
+
else if (/^-?\d+$/.test(inner)) {
|
|
45
|
+
const k = Number(inner);
|
|
46
|
+
nodes = nodes.flatMap((x) => (Array.isArray(x) && x.at(k) !== undefined ? [x.at(k)] : []));
|
|
47
|
+
}
|
|
48
|
+
else if (/^'.*'$|^".*"$/.test(inner)) {
|
|
49
|
+
const k = inner.slice(1, -1);
|
|
50
|
+
nodes = nodes.flatMap((x) => (isObject(x) && k in x ? [x[k]] : []));
|
|
51
|
+
}
|
|
52
|
+
else if (inner.startsWith('?(')) {
|
|
53
|
+
definite = false;
|
|
54
|
+
nodes = filtered(nodes, inner);
|
|
55
|
+
}
|
|
56
|
+
else
|
|
57
|
+
throw new Error(`unsupported JSON path part [${inner}]`);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
throw new Error(`bad JSON path ${path}`);
|
|
61
|
+
}
|
|
62
|
+
if (definite)
|
|
63
|
+
return nodes.length ? { found: true, value: nodes[0] } : { found: false, value: undefined };
|
|
64
|
+
return { found: true, value: nodes };
|
|
65
|
+
}
|
|
66
|
+
export function evaluate(query, answer) {
|
|
67
|
+
let found = true;
|
|
68
|
+
let value;
|
|
69
|
+
switch (query.kind) {
|
|
70
|
+
case 'status':
|
|
71
|
+
value = answer.status;
|
|
72
|
+
break;
|
|
73
|
+
case 'duration':
|
|
74
|
+
value = answer.ms;
|
|
75
|
+
break;
|
|
76
|
+
case 'header':
|
|
77
|
+
value = answer.headers[(query.arg ?? '').toLowerCase()];
|
|
78
|
+
found = value !== undefined;
|
|
79
|
+
break;
|
|
80
|
+
case 'body':
|
|
81
|
+
value = answer.text;
|
|
82
|
+
break;
|
|
83
|
+
case 'jsonpath':
|
|
84
|
+
if (answer.json === undefined)
|
|
85
|
+
return { found: false, value: undefined, error: HURL_WORDS.notJson };
|
|
86
|
+
({ found, value } = jsonpath(answer.json, query.arg ?? '$'));
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (query.count) {
|
|
90
|
+
if (!Array.isArray(value))
|
|
91
|
+
return { found: false, value, error: HURL_WORDS.count };
|
|
92
|
+
value = value.length;
|
|
93
|
+
}
|
|
94
|
+
return { found, value };
|
|
95
|
+
}
|
|
96
|
+
const VARIABLE = /\{\{\s*([A-Za-z_][A-Za-z0-9_-]*)\s*\}\}/g;
|
|
97
|
+
export class NoValue extends Error {
|
|
98
|
+
name = 'NoValue';
|
|
99
|
+
variable;
|
|
100
|
+
constructor(variable) {
|
|
101
|
+
super(HURL_WORDS.noValue(variable));
|
|
102
|
+
this.variable = variable;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export function substitute(text, vars) {
|
|
106
|
+
return text.replace(VARIABLE, (_all, name) => {
|
|
107
|
+
if (!(name in vars) || vars[name] === undefined)
|
|
108
|
+
throw new NoValue(name);
|
|
109
|
+
const v = vars[name];
|
|
110
|
+
return typeof v === 'string' ? v : JSON.stringify(v);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export const variablesIn = (text) => [...text.matchAll(VARIABLE)].map((m) => m[1]);
|
|
114
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
115
|
+
const ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
|
|
116
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
117
|
+
function wanted(assert, vars) {
|
|
118
|
+
const v = assert.value;
|
|
119
|
+
if (v === null)
|
|
120
|
+
return null;
|
|
121
|
+
if ('string' in v) {
|
|
122
|
+
const whole = /^\{\{\s*([A-Za-z_][A-Za-z0-9_-]*)\s*\}\}$/.exec(v.string);
|
|
123
|
+
if (whole) {
|
|
124
|
+
const name = whole[1];
|
|
125
|
+
if (!(name in vars))
|
|
126
|
+
throw new NoValue(whole[1]);
|
|
127
|
+
return vars[whole[1]];
|
|
128
|
+
}
|
|
129
|
+
return substitute(v.string, vars);
|
|
130
|
+
}
|
|
131
|
+
if ('regex' in v)
|
|
132
|
+
return new RegExp(v.regex);
|
|
133
|
+
return v.literal;
|
|
134
|
+
}
|
|
135
|
+
function holds(predicate, found, v, want) {
|
|
136
|
+
const n = (x) => (typeof x === 'number' ? x : NaN);
|
|
137
|
+
switch (predicate) {
|
|
138
|
+
case 'exists':
|
|
139
|
+
return found && v !== undefined;
|
|
140
|
+
case '==':
|
|
141
|
+
return found && same(v, want);
|
|
142
|
+
case '!=':
|
|
143
|
+
return !(found && same(v, want));
|
|
144
|
+
case '>':
|
|
145
|
+
return found && n(v) > n(want);
|
|
146
|
+
case '>=':
|
|
147
|
+
return found && n(v) >= n(want);
|
|
148
|
+
case '<':
|
|
149
|
+
return found && n(v) < n(want);
|
|
150
|
+
case '<=':
|
|
151
|
+
return found && n(v) <= n(want);
|
|
152
|
+
case 'contains':
|
|
153
|
+
return typeof v === 'string' && typeof want === 'string' && v.includes(want);
|
|
154
|
+
case 'includes':
|
|
155
|
+
return Array.isArray(v) && v.some((x) => same(x, want));
|
|
156
|
+
case 'startsWith':
|
|
157
|
+
return typeof v === 'string' && typeof want === 'string' && v.startsWith(want);
|
|
158
|
+
case 'endsWith':
|
|
159
|
+
return typeof v === 'string' && typeof want === 'string' && v.endsWith(want);
|
|
160
|
+
case 'matches':
|
|
161
|
+
return typeof v === 'string' && want instanceof RegExp && want.test(v);
|
|
162
|
+
case 'isString':
|
|
163
|
+
return typeof v === 'string';
|
|
164
|
+
case 'isInteger':
|
|
165
|
+
return Number.isInteger(v);
|
|
166
|
+
case 'isBoolean':
|
|
167
|
+
return typeof v === 'boolean';
|
|
168
|
+
case 'isCollection':
|
|
169
|
+
return Array.isArray(v) || isObject(v);
|
|
170
|
+
case 'isEmpty':
|
|
171
|
+
return (Array.isArray(v) || typeof v === 'string') && v.length === 0;
|
|
172
|
+
case 'isUuid':
|
|
173
|
+
return typeof v === 'string' && UUID.test(v);
|
|
174
|
+
case 'isIsoDate':
|
|
175
|
+
return typeof v === 'string' && ISO.test(v);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export const shown = (v) => v instanceof RegExp ? String(v) : v === undefined ? HURL_WORDS.nothing : JSON.stringify(v);
|
|
179
|
+
export function check(assert, answer, vars) {
|
|
180
|
+
const got = evaluate(assert.query, answer);
|
|
181
|
+
const want = wanted(assert, vars);
|
|
182
|
+
const ok = holds(assert.predicate, got.found, got.value, want) !== assert.not;
|
|
183
|
+
const expected = assert.value === null ? null : shown(want);
|
|
184
|
+
if (got.error)
|
|
185
|
+
return { ok: false, expected, got: got.error };
|
|
186
|
+
return { ok, expected, got: got.found ? shown(got.value) : HURL_WORDS.nothing };
|
|
187
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ParsedCall } from './hurl.ts';
|
|
2
|
+
export declare const own: (c: ParsedCall) => {
|
|
3
|
+
method: string;
|
|
4
|
+
url: string;
|
|
5
|
+
headers: [string, string][];
|
|
6
|
+
query: [string, string][];
|
|
7
|
+
body: string | null;
|
|
8
|
+
status: number | "*" | null;
|
|
9
|
+
asserts: string[];
|
|
10
|
+
captures: (string | import("./hurl.ts").Query)[][];
|
|
11
|
+
options: {
|
|
12
|
+
retry: number;
|
|
13
|
+
interval: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function callDefinition(calls: readonly ParsedCall[], index: number): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { hashOf } from '../../manifest/index.js';
|
|
2
|
+
import { variablesIn } from './check.js';
|
|
3
|
+
export const own = (c) => ({
|
|
4
|
+
method: c.method,
|
|
5
|
+
url: c.url,
|
|
6
|
+
headers: c.headers,
|
|
7
|
+
query: c.query,
|
|
8
|
+
body: c.body,
|
|
9
|
+
status: c.status?.want ?? null,
|
|
10
|
+
asserts: c.asserts.map((a) => a.text),
|
|
11
|
+
captures: c.captures.map((x) => [x.name, x.query]),
|
|
12
|
+
options: c.options,
|
|
13
|
+
});
|
|
14
|
+
const usesOf = (c) => new Set(variablesIn([
|
|
15
|
+
c.url,
|
|
16
|
+
...c.headers.map(([, v]) => v),
|
|
17
|
+
...c.query.map(([, v]) => v),
|
|
18
|
+
c.body ?? '',
|
|
19
|
+
...c.asserts.map((a) => a.text),
|
|
20
|
+
].join('\n')));
|
|
21
|
+
export function callDefinition(calls, index) {
|
|
22
|
+
const needed = new Set([index]);
|
|
23
|
+
const wanted = usesOf(calls[index]);
|
|
24
|
+
for (let i = index - 1; i >= 0; i -= 1) {
|
|
25
|
+
const c = calls[i];
|
|
26
|
+
if (c.captures.some((x) => wanted.has(x.name))) {
|
|
27
|
+
needed.add(i);
|
|
28
|
+
for (const v of usesOf(c))
|
|
29
|
+
wanted.add(v);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return hashOf([...needed].sort((a, b) => a - b).map((i) => own(calls[i])));
|
|
33
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type QueryKind = 'status' | 'header' | 'body' | 'duration' | 'jsonpath';
|
|
2
|
+
export interface Query {
|
|
3
|
+
kind: QueryKind;
|
|
4
|
+
arg: string | null;
|
|
5
|
+
count: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type Value = {
|
|
8
|
+
string: string;
|
|
9
|
+
} | {
|
|
10
|
+
regex: string;
|
|
11
|
+
} | {
|
|
12
|
+
literal: number | boolean | null;
|
|
13
|
+
};
|
|
14
|
+
export declare const PREDICATES: readonly ['==', '!=', '>=', '<=', '>', '<', 'contains', 'includes', 'startsWith', 'endsWith', 'matches', 'exists', 'isString', 'isInteger', 'isBoolean', 'isCollection', 'isEmpty', 'isUuid', 'isIsoDate'];
|
|
15
|
+
export type Predicate = (typeof PREDICATES)[number];
|
|
16
|
+
export interface Assert {
|
|
17
|
+
line: number;
|
|
18
|
+
text: string;
|
|
19
|
+
query: Query;
|
|
20
|
+
not: boolean;
|
|
21
|
+
predicate: Predicate;
|
|
22
|
+
value: Value | null;
|
|
23
|
+
}
|
|
24
|
+
export interface Capture {
|
|
25
|
+
line: number;
|
|
26
|
+
name: string;
|
|
27
|
+
query: Query;
|
|
28
|
+
}
|
|
29
|
+
export interface ParsedCall {
|
|
30
|
+
file: string;
|
|
31
|
+
line: number;
|
|
32
|
+
first: number;
|
|
33
|
+
last: number;
|
|
34
|
+
name: string;
|
|
35
|
+
method: string;
|
|
36
|
+
url: string;
|
|
37
|
+
headers: [string, string][];
|
|
38
|
+
query: [string, string][];
|
|
39
|
+
options: {
|
|
40
|
+
retry: number;
|
|
41
|
+
interval: number;
|
|
42
|
+
};
|
|
43
|
+
body: string | null;
|
|
44
|
+
status: {
|
|
45
|
+
line: number;
|
|
46
|
+
want: number | '*';
|
|
47
|
+
} | null;
|
|
48
|
+
captures: Capture[];
|
|
49
|
+
asserts: Assert[];
|
|
50
|
+
lines: string[];
|
|
51
|
+
}
|
|
52
|
+
export declare class Refusal extends Error {
|
|
53
|
+
name: string;
|
|
54
|
+
readonly line: number;
|
|
55
|
+
readonly says: string;
|
|
56
|
+
constructor(line: number, says: string);
|
|
57
|
+
}
|
|
58
|
+
export interface Parsed {
|
|
59
|
+
calls: ParsedCall[];
|
|
60
|
+
}
|
|
61
|
+
export declare function parseHurl(text: string, file: string): Parsed;
|
|
62
|
+
export declare function whoOf(call: Pick<ParsedCall, 'headers'>): string;
|
|
63
|
+
export declare const pathOf: (url: string) => string;
|
|
64
|
+
export declare function requestOf(call: Pick<ParsedCall, 'method' | 'url' | 'query'>): string;
|
|
65
|
+
export declare const isVariableName: (v: string) => boolean;
|