@thymian/plugin-sampler 0.3.0-canary.20261007-e6cb8dc → 0.3.0-canary.20261007-cdbe1d3
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/dist/cli/check-result.d.ts +88 -0
- package/dist/cli/check-result.d.ts.map +1 -0
- package/dist/cli/check-result.js +160 -0
- package/dist/cli/check-result.js.map +1 -0
- package/dist/cli/commands/sampler/check.d.ts +32 -4
- package/dist/cli/commands/sampler/check.d.ts.map +1 -1
- package/dist/cli/commands/sampler/check.js +126 -88
- package/dist/cli/commands/sampler/check.js.map +1 -1
- package/dist/cli/commands/sampler/init.d.ts +4 -6
- package/dist/cli/commands/sampler/init.d.ts.map +1 -1
- package/dist/cli/commands/sampler/init.js +33 -49
- package/dist/cli/commands/sampler/init.js.map +1 -1
- package/dist/cli/commands/sampler/show.d.ts +11 -0
- package/dist/cli/commands/sampler/show.d.ts.map +1 -0
- package/dist/cli/commands/sampler/show.js +36 -0
- package/dist/cli/commands/sampler/show.js.map +1 -0
- package/dist/cli/commands/sampler/sync.d.ts +11 -0
- package/dist/cli/commands/sampler/sync.d.ts.map +1 -0
- package/dist/cli/commands/sampler/sync.js +65 -0
- package/dist/cli/commands/sampler/sync.js.map +1 -0
- package/dist/cli/commands/sampler/validate.d.ts +3 -10
- package/dist/cli/commands/sampler/validate.d.ts.map +1 -1
- package/dist/cli/commands/sampler/validate.js +57 -126
- package/dist/cli/commands/sampler/validate.js.map +1 -1
- package/dist/generation/closed-schema.d.ts +22 -0
- package/dist/generation/closed-schema.d.ts.map +1 -0
- package/dist/generation/closed-schema.js +45 -0
- package/dist/generation/closed-schema.js.map +1 -0
- package/dist/generation/content-type-strategies/json.content-type-strategy.d.ts.map +1 -1
- package/dist/generation/content-type-strategies/json.content-type-strategy.js +3 -1
- package/dist/generation/content-type-strategies/json.content-type-strategy.js.map +1 -1
- package/dist/generation/content-type-strategies/xml.content-type-strategy.d.ts.map +1 -1
- package/dist/generation/content-type-strategies/xml.content-type-strategy.js +3 -1
- package/dist/generation/content-type-strategies/xml.content-type-strategy.js.map +1 -1
- package/dist/generation/generate-request-sample.d.ts +12 -0
- package/dist/generation/generate-request-sample.d.ts.map +1 -0
- package/dist/generation/{generate-samples.js → generate-request-sample.js} +11 -4
- package/dist/generation/generate-request-sample.js.map +1 -0
- package/dist/generation/request-generators/default-request-generator.d.ts +14 -0
- package/dist/generation/request-generators/default-request-generator.d.ts.map +1 -1
- package/dist/generation/request-generators/default-request-generator.js +18 -1
- package/dist/generation/request-generators/default-request-generator.js.map +1 -1
- package/dist/generation/types/declaration-set.d.ts +124 -0
- package/dist/generation/types/declaration-set.d.ts.map +1 -0
- package/dist/generation/types/declaration-set.js +389 -0
- package/dist/generation/types/declaration-set.js.map +1 -0
- package/dist/generation/types/example-reflection.d.ts +21 -0
- package/dist/generation/types/example-reflection.d.ts.map +1 -0
- package/dist/generation/types/example-reflection.js +135 -0
- package/dist/generation/types/example-reflection.js.map +1 -0
- package/dist/generation/types/generate-type-surface.d.ts +23 -0
- package/dist/generation/types/generate-type-surface.d.ts.map +1 -0
- package/dist/generation/types/generate-type-surface.js +671 -0
- package/dist/generation/types/generate-type-surface.js.map +1 -0
- package/dist/generation/types/schema-type.d.ts +20 -0
- package/dist/generation/types/schema-type.d.ts.map +1 -0
- package/dist/generation/types/schema-type.js +203 -0
- package/dist/generation/types/schema-type.js.map +1 -0
- package/dist/generation/types/self-check-surface.d.ts +32 -0
- package/dist/generation/types/self-check-surface.d.ts.map +1 -0
- package/dist/generation/types/self-check-surface.js +92 -0
- package/dist/generation/types/self-check-surface.js.map +1 -0
- package/dist/generation/types/type-names.d.ts +135 -0
- package/dist/generation/types/type-names.d.ts.map +1 -0
- package/dist/generation/types/type-names.js +213 -0
- package/dist/generation/types/type-names.js.map +1 -0
- package/dist/generation/types/write-type-surface.d.ts +58 -0
- package/dist/generation/types/write-type-surface.d.ts.map +1 -0
- package/dist/generation/types/write-type-surface.js +119 -0
- package/dist/generation/types/write-type-surface.js.map +1 -0
- package/dist/hooks/create-hook-utils.d.ts +22 -6
- package/dist/hooks/create-hook-utils.d.ts.map +1 -1
- package/dist/hooks/create-hook-utils.js +74 -96
- package/dist/hooks/create-hook-utils.js.map +1 -1
- package/dist/hooks/hook-api.d.ts +49 -0
- package/dist/hooks/hook-api.d.ts.map +1 -0
- package/dist/hooks/hook-api.js +105 -0
- package/dist/hooks/hook-api.js.map +1 -0
- package/dist/hooks/hook-diagnostics.d.ts +45 -0
- package/dist/hooks/hook-diagnostics.d.ts.map +1 -0
- package/dist/hooks/hook-diagnostics.js +80 -0
- package/dist/hooks/hook-diagnostics.js.map +1 -0
- package/dist/hooks/hook-errors.d.ts +33 -0
- package/dist/hooks/hook-errors.d.ts.map +1 -1
- package/dist/hooks/hook-errors.js +46 -0
- package/dist/hooks/hook-errors.js.map +1 -1
- package/dist/hooks/hook-registration.d.ts +108 -0
- package/dist/hooks/hook-registration.d.ts.map +1 -0
- package/dist/hooks/hook-registration.js +69 -0
- package/dist/hooks/hook-registration.js.map +1 -0
- package/dist/hooks/hook-runner.d.ts +111 -11
- package/dist/hooks/hook-runner.d.ts.map +1 -1
- package/dist/hooks/hook-runner.js +309 -142
- package/dist/hooks/hook-runner.js.map +1 -1
- package/dist/hooks/hook-utils-factory.d.ts +19 -0
- package/dist/hooks/hook-utils-factory.d.ts.map +1 -0
- package/dist/hooks/hook-utils-factory.js +2 -0
- package/dist/hooks/hook-utils-factory.js.map +1 -0
- package/dist/hooks/hook-utils.d.ts +80 -12
- package/dist/hooks/hook-utils.d.ts.map +1 -1
- package/dist/hooks/invoke-hook.d.ts +71 -0
- package/dist/hooks/invoke-hook.d.ts.map +1 -0
- package/dist/hooks/invoke-hook.js +161 -0
- package/dist/hooks/invoke-hook.js.map +1 -0
- package/dist/hooks/load-user-hooks.d.ts +96 -0
- package/dist/hooks/load-user-hooks.d.ts.map +1 -0
- package/dist/hooks/load-user-hooks.js +432 -0
- package/dist/hooks/load-user-hooks.js.map +1 -0
- package/dist/hooks/nested-request.d.ts +21 -0
- package/dist/hooks/nested-request.d.ts.map +1 -0
- package/dist/hooks/nested-request.js +24 -0
- package/dist/hooks/nested-request.js.map +1 -0
- package/dist/hooks/overlay-args.d.ts +40 -0
- package/dist/hooks/overlay-args.d.ts.map +1 -0
- package/dist/hooks/overlay-args.js +84 -0
- package/dist/hooks/overlay-args.js.map +1 -0
- package/dist/hooks/resolve-targeting.d.ts +16 -0
- package/dist/hooks/resolve-targeting.d.ts.map +1 -0
- package/dist/hooks/resolve-targeting.js +168 -0
- package/dist/hooks/resolve-targeting.js.map +1 -0
- package/dist/hooks/run-scoped-hooks.d.ts +83 -0
- package/dist/hooks/run-scoped-hooks.d.ts.map +1 -0
- package/dist/hooks/run-scoped-hooks.js +153 -0
- package/dist/hooks/run-scoped-hooks.js.map +1 -0
- package/dist/index.d.ts +42 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +152 -165
- package/dist/index.js.map +1 -1
- package/dist/request-sampler.d.ts +40 -11
- package/dist/request-sampler.d.ts.map +1 -1
- package/dist/request-sampler.js +51 -76
- package/dist/request-sampler.js.map +1 -1
- package/dist/sampler-paths.d.ts +19 -0
- package/dist/sampler-paths.d.ts.map +1 -0
- package/dist/sampler-paths.js +22 -0
- package/dist/sampler-paths.js.map +1 -0
- package/dist/selectors/nearest-paths.d.ts +14 -0
- package/dist/selectors/nearest-paths.d.ts.map +1 -0
- package/dist/selectors/nearest-paths.js +32 -0
- package/dist/selectors/nearest-paths.js.map +1 -0
- package/dist/selectors/path-glob.d.ts +94 -0
- package/dist/selectors/path-glob.d.ts.map +1 -0
- package/dist/selectors/path-glob.js +136 -0
- package/dist/selectors/path-glob.js.map +1 -0
- package/dist/selectors/selector-errors.d.ts +17 -0
- package/dist/selectors/selector-errors.d.ts.map +1 -0
- package/dist/selectors/selector-errors.js +139 -0
- package/dist/selectors/selector-errors.js.map +1 -0
- package/dist/selectors/selector.d.ts +55 -0
- package/dist/selectors/selector.d.ts.map +1 -0
- package/dist/selectors/selector.js +305 -0
- package/dist/selectors/selector.js.map +1 -0
- package/dist/selectors/transaction-catalog.d.ts +96 -0
- package/dist/selectors/transaction-catalog.d.ts.map +1 -0
- package/dist/selectors/transaction-catalog.js +193 -0
- package/dist/selectors/transaction-catalog.js.map +1 -0
- package/dist/selectors/transaction-filter.d.ts +119 -0
- package/dist/selectors/transaction-filter.d.ts.map +1 -0
- package/dist/selectors/transaction-filter.js +191 -0
- package/dist/selectors/transaction-filter.js.map +1 -0
- package/dist/ts-path.d.ts +36 -0
- package/dist/ts-path.d.ts.map +1 -0
- package/dist/ts-path.js +46 -0
- package/dist/ts-path.js.map +1 -0
- package/dist/utils.d.ts +1 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -20
- package/dist/utils.js.map +1 -1
- package/dist/validation/canonicalize.d.ts +17 -0
- package/dist/validation/canonicalize.d.ts.map +1 -0
- package/dist/validation/canonicalize.js +29 -0
- package/dist/validation/canonicalize.js.map +1 -0
- package/dist/validation/shared-compiler-host.d.ts +17 -0
- package/dist/validation/shared-compiler-host.d.ts.map +1 -0
- package/dist/validation/shared-compiler-host.js +58 -0
- package/dist/validation/shared-compiler-host.js.map +1 -0
- package/dist/validation/typecheck-hooks.d.ts +37 -0
- package/dist/validation/typecheck-hooks.d.ts.map +1 -0
- package/dist/validation/typecheck-hooks.js +169 -0
- package/dist/validation/typecheck-hooks.js.map +1 -0
- package/dist/validation/validate-sampler.d.ts +79 -0
- package/dist/validation/validate-sampler.d.ts.map +1 -0
- package/dist/validation/validate-sampler.js +89 -0
- package/dist/validation/validate-sampler.js.map +1 -0
- package/package.json +7 -11
- package/dist/cli/commands/sampler/generate/hook.d.ts +0 -10
- package/dist/cli/commands/sampler/generate/hook.d.ts.map +0 -1
- package/dist/cli/commands/sampler/generate/hook.js +0 -19
- package/dist/cli/commands/sampler/generate/hook.js.map +0 -1
- package/dist/cli/generate-hook.d.ts +0 -4
- package/dist/cli/generate-hook.d.ts.map +0 -1
- package/dist/cli/generate-hook.js +0 -96
- package/dist/cli/generate-hook.js.map +0 -1
- package/dist/cli/templates.d.ts +0 -4
- package/dist/cli/templates.d.ts.map +0 -1
- package/dist/cli/templates.js +0 -28
- package/dist/cli/templates.js.map +0 -1
- package/dist/constants.d.ts +0 -12
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -16
- package/dist/constants.js.map +0 -1
- package/dist/generation/generate-samples-for-thymian-format.d.ts +0 -4
- package/dist/generation/generate-samples-for-thymian-format.d.ts.map +0 -1
- package/dist/generation/generate-samples-for-thymian-format.js +0 -18
- package/dist/generation/generate-samples-for-thymian-format.js.map +0 -1
- package/dist/generation/generate-samples.d.ts +0 -4
- package/dist/generation/generate-samples.d.ts.map +0 -1
- package/dist/generation/generate-samples.js.map +0 -1
- package/dist/hooks/generate-request-types.d.ts +0 -34
- package/dist/hooks/generate-request-types.d.ts.map +0 -1
- package/dist/hooks/generate-request-types.js +0 -458
- package/dist/hooks/generate-request-types.js.map +0 -1
- package/dist/hooks/hook-types.d.ts +0 -7
- package/dist/hooks/hook-types.d.ts.map +0 -1
- package/dist/hooks/hook-types.js +0 -2
- package/dist/hooks/hook-types.js.map +0 -1
- package/dist/hooks/load-hooks-from-samples.d.ts +0 -3
- package/dist/hooks/load-hooks-from-samples.d.ts.map +0 -1
- package/dist/hooks/load-hooks-from-samples.js +0 -22
- package/dist/hooks/load-hooks-from-samples.js.map +0 -1
- package/dist/hooks/ts-config.d.ts +0 -10
- package/dist/hooks/ts-config.d.ts.map +0 -1
- package/dist/hooks/ts-config.js +0 -10
- package/dist/hooks/ts-config.js.map +0 -1
- package/dist/samples-structure/file-request-sample.d.ts +0 -20
- package/dist/samples-structure/file-request-sample.d.ts.map +0 -1
- package/dist/samples-structure/file-request-sample.js +0 -5
- package/dist/samples-structure/file-request-sample.js.map +0 -1
- package/dist/samples-structure/get-path-transaction-id.d.ts +0 -3
- package/dist/samples-structure/get-path-transaction-id.d.ts.map +0 -1
- package/dist/samples-structure/get-path-transaction-id.js +0 -22
- package/dist/samples-structure/get-path-transaction-id.js.map +0 -1
- package/dist/samples-structure/merge-tree.d.ts +0 -5
- package/dist/samples-structure/merge-tree.d.ts.map +0 -1
- package/dist/samples-structure/merge-tree.js +0 -118
- package/dist/samples-structure/merge-tree.js.map +0 -1
- package/dist/samples-structure/read-samples-from-dir.d.ts +0 -13
- package/dist/samples-structure/read-samples-from-dir.d.ts.map +0 -1
- package/dist/samples-structure/read-samples-from-dir.js +0 -205
- package/dist/samples-structure/read-samples-from-dir.js.map +0 -1
- package/dist/samples-structure/samples-from-transactions.d.ts +0 -5
- package/dist/samples-structure/samples-from-transactions.d.ts.map +0 -1
- package/dist/samples-structure/samples-from-transactions.js +0 -120
- package/dist/samples-structure/samples-from-transactions.js.map +0 -1
- package/dist/samples-structure/samples-tree-structure.d.ts +0 -106
- package/dist/samples-structure/samples-tree-structure.d.ts.map +0 -1
- package/dist/samples-structure/samples-tree-structure.js +0 -26
- package/dist/samples-structure/samples-tree-structure.js.map +0 -1
- package/dist/samples-structure/structure-meta-on-disc.d.ts +0 -11
- package/dist/samples-structure/structure-meta-on-disc.d.ts.map +0 -1
- package/dist/samples-structure/structure-meta-on-disc.js +0 -2
- package/dist/samples-structure/structure-meta-on-disc.js.map +0 -1
- package/dist/samples-structure/traverse.d.ts +0 -4
- package/dist/samples-structure/traverse.d.ts.map +0 -1
- package/dist/samples-structure/traverse.js +0 -13
- package/dist/samples-structure/traverse.js.map +0 -1
- package/dist/samples-structure/write-samples-to-dir.d.ts +0 -37
- package/dist/samples-structure/write-samples-to-dir.d.ts.map +0 -1
- package/dist/samples-structure/write-samples-to-dir.js +0 -183
- package/dist/samples-structure/write-samples-to-dir.js.map +0 -1
- package/dist/validation/validate-sampler-output.d.ts +0 -38
- package/dist/validation/validate-sampler-output.d.ts.map +0 -1
- package/dist/validation/validate-sampler-output.js +0 -288
- package/dist/validation/validate-sampler-output.js.map +0 -1
|
@@ -1,172 +1,339 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { getContentType, serializeRequest, ThymianFormat, } from '@thymian/core';
|
|
2
|
+
import { TransactionCatalog } from '../selectors/transaction-catalog.js';
|
|
3
|
+
import { createHookUtils, parseResponseBody, } from './create-hook-utils.js';
|
|
4
|
+
import { UndeclaredResponseError } from './hook-errors.js';
|
|
5
|
+
import { interpretHookFailure, invokeHook, invokeOrThrow, reportHookResults, } from './invoke-hook.js';
|
|
6
|
+
import {} from './load-user-hooks.js';
|
|
7
|
+
import { isOnChain, requestCycleError, } from './nested-request.js';
|
|
8
|
+
import { applyArgs } from './overlay-args.js';
|
|
9
|
+
import { RunScopedHooks } from './run-scoped-hooks.js';
|
|
10
|
+
const EMPTY_HOOKS = Object.freeze({
|
|
11
|
+
defineSample: [],
|
|
12
|
+
beforeEach: [],
|
|
13
|
+
afterEach: [],
|
|
14
|
+
authorize: [],
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Runs the user's hooks at the http-testing seams.
|
|
18
|
+
*
|
|
19
|
+
* Holds the bindings the loader produced and nothing else: an unbound
|
|
20
|
+
* Transaction simply has no hooks, which is the pass-through case, so there is
|
|
21
|
+
* no "not initialized" state to guard against.
|
|
22
|
+
*/
|
|
9
23
|
export class HookRunner {
|
|
10
|
-
path;
|
|
11
|
-
runRequest;
|
|
12
24
|
logger;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
ports;
|
|
26
|
+
format = new ThymianFormat();
|
|
27
|
+
catalog = TransactionCatalog.fromThymianFormat(new ThymianFormat());
|
|
28
|
+
byTransactionId = new Map();
|
|
29
|
+
globalAuthorize = [];
|
|
30
|
+
runScoped;
|
|
31
|
+
/**
|
|
32
|
+
* The origin this run is actually talking to — a `--target-url` override or
|
|
33
|
+
* a configured target, same as the server the description names when
|
|
34
|
+
* neither is set — so a run-scoped hook's seed goes where the run goes
|
|
35
|
+
* rather than where the description points.
|
|
36
|
+
*
|
|
37
|
+
* Captured once, from the very first request. "Before the run" has no
|
|
38
|
+
* meaning until something decides when the run starts, and the sampler's
|
|
39
|
+
* first observation of a run is its first request, so this is captured in
|
|
40
|
+
* lockstep with {@link RunScopedHooks.start}'s latch, in
|
|
41
|
+
* {@link beforeEachRequest}.
|
|
42
|
+
*
|
|
43
|
+
* **One origin per run**, which is a simplification the CLI does not
|
|
44
|
+
* currently expose: a format assembled from several descriptions may name
|
|
45
|
+
* different servers per transaction, and a `beforeAll` seed would still be
|
|
46
|
+
* sent to whichever origin the first request happened to use rather than to
|
|
47
|
+
* its own transaction's server. Per-request hooks are unaffected — they read
|
|
48
|
+
* the origin off the request in front of them. Reset on {@link load}, so the
|
|
49
|
+
* value never outlives the run that observed it.
|
|
50
|
+
*/
|
|
51
|
+
runOrigin;
|
|
52
|
+
constructor(logger, ports) {
|
|
20
53
|
this.logger = logger;
|
|
54
|
+
this.ports = ports;
|
|
55
|
+
this.runScoped = new RunScopedHooks(logger, this.utilsFactory);
|
|
21
56
|
}
|
|
22
|
-
|
|
23
|
-
|
|
57
|
+
/** Adopt a newly loaded format and the hooks bound against it. */
|
|
58
|
+
load(format, catalog, hooks) {
|
|
59
|
+
this.format = format;
|
|
60
|
+
this.catalog = catalog;
|
|
61
|
+
this.byTransactionId = hooks?.byTransactionId ?? new Map();
|
|
62
|
+
this.globalAuthorize = hooks?.globalAuthorize ?? [];
|
|
63
|
+
this.runScoped.load(hooks?.runScoped ?? { beforeAll: [], afterAll: [] });
|
|
64
|
+
// A load is a new run's format, so the previous run's observed origin must
|
|
65
|
+
// not survive into it: in a long-lived process — `thymian serve` — the
|
|
66
|
+
// second run's seeds would otherwise be sent to the first run's target.
|
|
67
|
+
this.runOrigin = undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Teardown, on `core.close`. A no-op when no request was ever sent, so a
|
|
71
|
+
* non-test command never runs somebody's teardown.
|
|
72
|
+
*/
|
|
73
|
+
async close() {
|
|
74
|
+
await this.runScoped.close();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The `utils` a hook with no request to shape gets: the run-scoped pair. A
|
|
78
|
+
* nested request is available, because a `beforeAll` seeding the API is the
|
|
79
|
+
* reason `utils.request` exists. `dir` comes from the registration's own
|
|
80
|
+
* file, not the process's working directory, so a run-scoped hook's file
|
|
81
|
+
* helpers resolve the same way a per-Transaction hook's do.
|
|
82
|
+
*/
|
|
83
|
+
utilsFactory = (entry) => {
|
|
84
|
+
const results = [];
|
|
85
|
+
return {
|
|
86
|
+
utils: createHookUtils(this.callContext({ dir: entry.dir, results, chain: [] })),
|
|
87
|
+
results,
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Shape one request draft with its Transaction's `defineSample` hook, if it
|
|
92
|
+
* has one. This is what `RequestSampler` calls at generation time; the sampler
|
|
93
|
+
* itself knows nothing about hooks.
|
|
94
|
+
*
|
|
95
|
+
* Runs through the same attribution wrapper as every other kind: a throwing
|
|
96
|
+
* `defineSample` used to escape here as a raw error with no pointer to the
|
|
97
|
+
* hook that threw it, misattributed by whatever generic handler caught it
|
|
98
|
+
* further up.
|
|
99
|
+
*/
|
|
100
|
+
shapeSample = async (draft, transactionId) => {
|
|
101
|
+
const entry = this.hooksFor(transactionId).defineSample[0];
|
|
102
|
+
if (!entry) {
|
|
24
103
|
return;
|
|
25
104
|
}
|
|
26
|
-
|
|
27
|
-
|
|
105
|
+
const results = [];
|
|
106
|
+
try {
|
|
107
|
+
await invokeOrThrow('defineSample', entry, [
|
|
108
|
+
draft,
|
|
109
|
+
createHookUtils(
|
|
110
|
+
// No nested request: a `defineSample` hook runs before any request
|
|
111
|
+
// exists, so there is no pipeline for one to run through.
|
|
112
|
+
{ dir: entry.dir, request: draft, results }),
|
|
113
|
+
]);
|
|
28
114
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
115
|
+
finally {
|
|
116
|
+
reportHookResults(this.logger, results);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
hooksFor(transactionId) {
|
|
120
|
+
if (!transactionId) {
|
|
121
|
+
return EMPTY_HOOKS;
|
|
122
|
+
}
|
|
123
|
+
return this.byTransactionId.get(transactionId) ?? EMPTY_HOOKS;
|
|
124
|
+
}
|
|
125
|
+
callContext(input) {
|
|
126
|
+
// A per-Transaction hook already has a request carrying the run's origin
|
|
127
|
+
// (the operator that overrides it for `--target-url` does so before
|
|
128
|
+
// `beforeRequest` fires), so it stays the source of truth there. A
|
|
129
|
+
// run-scoped hook has no request, which is exactly the case
|
|
130
|
+
// {@link runOrigin} exists for. Only `requestOther` needs this — it is
|
|
131
|
+
// what a nested `utils.request` inherits — so it lives in this closure
|
|
132
|
+
// rather than on the `HookCallContext` itself.
|
|
133
|
+
const origin = input.request?.origin ?? this.runOrigin;
|
|
134
|
+
return {
|
|
135
|
+
dir: input.dir,
|
|
136
|
+
request: input.request,
|
|
137
|
+
results: input.results,
|
|
138
|
+
requestOther: async (selector, args, options) => await this.runNested(selector, args, options, {
|
|
139
|
+
chain: input.chain,
|
|
140
|
+
results: input.results,
|
|
141
|
+
origin,
|
|
142
|
+
}),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async beforeEachRequest(hook) {
|
|
146
|
+
const { value, ctx } = hook;
|
|
147
|
+
// The first request is what "before the run" means to the sampler, so the
|
|
148
|
+
// latch is armed here — ahead of this transaction's own beforeEach hooks —
|
|
149
|
+
// and this request is also the run's one observation of the origin it is
|
|
150
|
+
// actually talking to. Captured before the latch arms, so a `beforeAll`
|
|
151
|
+
// seed sent while arming it already sees the run's target rather than the
|
|
152
|
+
// server the description names.
|
|
153
|
+
this.runOrigin ??= value.origin;
|
|
154
|
+
await this.runScoped.start();
|
|
155
|
+
return await this.compose('beforeEach', this.hooksFor(ctx?.transactionId).beforeEach, value, ctx, value, this.chainFor(ctx));
|
|
35
156
|
}
|
|
36
157
|
async afterEachResponse(hook) {
|
|
37
|
-
if (!this.initialized) {
|
|
38
|
-
throw new ThymianBaseError('Cannot run hooks before @thymian/plugin-sampler is initialized.', {
|
|
39
|
-
name: 'HookRunnerNotInitialized',
|
|
40
|
-
suggestions: ['Did you run "thymian sampler init"?'],
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
158
|
const { value, ctx } = hook;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
159
|
+
return await this.compose('afterEach', this.hooksFor(ctx.thymianTransaction?.transactionId).afterEach, value, ctx, ctx.requestTemplate, this.chainFor(ctx.thymianTransaction));
|
|
160
|
+
}
|
|
161
|
+
async authorize(hook) {
|
|
162
|
+
const { value, ctx } = hook;
|
|
163
|
+
const entry = this.authorizeFor(ctx?.transactionId);
|
|
164
|
+
return await this.compose('authorize', entry ? [entry] : [], value, ctx, value, this.chainFor(ctx));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Which authorize hook supplies this Transaction's credentials.
|
|
168
|
+
*
|
|
169
|
+
* A targeted hook wins over the global one for the Transactions it covers, and
|
|
170
|
+
* within each tier the last registration wins, so a later file can override an
|
|
171
|
+
* earlier one. Exactly one hook runs: authorization is "who am I", and
|
|
172
|
+
* composing two answers would mean two sets of credentials on one request.
|
|
173
|
+
*
|
|
174
|
+
* Whether it runs at all is not decided here — core runs this seam only when
|
|
175
|
+
* the run option and the request's own `authorize` flag agree — so a
|
|
176
|
+
* registered hook is necessary but not sufficient, which is what makes
|
|
177
|
+
* "force on" need both.
|
|
178
|
+
*/
|
|
179
|
+
authorizeFor(transactionId) {
|
|
180
|
+
return (this.hooksFor(transactionId).authorize.at(-1) ??
|
|
181
|
+
this.globalAuthorize.at(-1));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The chain a hook of `transaction` runs with: the Transaction's own Selector,
|
|
185
|
+
* so a hook that seeds itself is caught on the first step.
|
|
186
|
+
*/
|
|
187
|
+
chainFor(transaction) {
|
|
188
|
+
if (!transaction) {
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
const selector = this.catalog.selectorFor(transaction.transactionId);
|
|
192
|
+
return selector ? [selector] : [];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Run a kind's hooks in order over one value, and translate whatever comes
|
|
196
|
+
* back into the shape the http-testing seam expects.
|
|
197
|
+
*
|
|
198
|
+
* Every hook **mutates `value` in place**; the callback's return value is
|
|
199
|
+
* deliberately discarded (see {@link invokeHook}).
|
|
200
|
+
*/
|
|
201
|
+
async compose(kind, entries, value, ctx, request, chain) {
|
|
48
202
|
const testResults = [];
|
|
49
|
-
|
|
50
|
-
|
|
203
|
+
for (const entry of entries) {
|
|
204
|
+
const utils = createHookUtils(this.callContext({
|
|
205
|
+
dir: entry.dir,
|
|
206
|
+
request,
|
|
207
|
+
results: testResults,
|
|
208
|
+
chain,
|
|
209
|
+
}));
|
|
51
210
|
try {
|
|
52
|
-
|
|
211
|
+
await invokeHook(entry, [value, ctx, utils]);
|
|
53
212
|
}
|
|
54
213
|
catch (e) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
skip: e.message,
|
|
59
|
-
testResults,
|
|
60
|
-
};
|
|
214
|
+
const outcome = interpretHookFailure(e, kind, entry);
|
|
215
|
+
if (outcome.rethrow) {
|
|
216
|
+
throw outcome.rethrow;
|
|
61
217
|
}
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
result,
|
|
65
|
-
fail: e.message,
|
|
66
|
-
testResults,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
throw new ThymianBaseError(`Error while running afterEach hook${hook.ctx && hook.ctx.thymianTransaction ? ' for transaction: ' + thymianHttpTransactionToString(hook.ctx.thymianTransaction.thymianReq, hook.ctx.thymianTransaction.thymianRes) : ''}.`, {
|
|
70
|
-
cause: e,
|
|
71
|
-
name: 'HookError',
|
|
72
|
-
});
|
|
218
|
+
return { result: value, ...outcome.report, testResults };
|
|
73
219
|
}
|
|
74
220
|
}
|
|
75
|
-
return {
|
|
76
|
-
result,
|
|
77
|
-
testResults,
|
|
78
|
-
};
|
|
221
|
+
return { result: value, testResults };
|
|
79
222
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Send a request to another Transaction, addressed by its Selector.
|
|
225
|
+
*
|
|
226
|
+
* By default the nested request runs the target's own
|
|
227
|
+
* `beforeEach → authorize → afterEach` pipeline, so seeding behaves like the
|
|
228
|
+
* real run rather than like a second, quieter client. `runHooks: false` sends
|
|
229
|
+
* the generated request as-is, which is also the way out of a cycle.
|
|
230
|
+
*/
|
|
231
|
+
async runNested(selector, args, options, caller) {
|
|
232
|
+
const { chain, results: callerResults, origin: callerOrigin } = caller;
|
|
233
|
+
const runHooks = options.runHooks ?? true;
|
|
234
|
+
const transaction = this.catalog.resolve(selector);
|
|
235
|
+
const nested = [...chain, selector];
|
|
236
|
+
const template = applyArgs(await this.ports.sampleRequest(transaction), args);
|
|
237
|
+
// A seed goes where the run is going. The caller's request already carries
|
|
238
|
+
// whatever origin the run resolved — a `--target-url`, a configured target
|
|
239
|
+
// — and without inheriting it a seeding call would quietly send real
|
|
240
|
+
// traffic to the server the description names while the run itself talks to
|
|
241
|
+
// localhost.
|
|
242
|
+
if (callerOrigin) {
|
|
243
|
+
template.origin = callerOrigin;
|
|
86
244
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
? this.hooks.get(ctx.transactionId)
|
|
90
|
-
: undefined;
|
|
91
|
-
const authorize = hooks?.authorize?.at(-1);
|
|
92
|
-
if (!authorize) {
|
|
93
|
-
return {
|
|
94
|
-
result: value,
|
|
95
|
-
};
|
|
245
|
+
if (options.authorize !== undefined) {
|
|
246
|
+
template.authorize = options.authorize;
|
|
96
247
|
}
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
248
|
+
const authorizeHook = this.authorizeFor(transaction.transactionId);
|
|
249
|
+
// The guard has to ask the same question the two blocks below answer: will
|
|
250
|
+
// *any* hook run for this call? `runHooks` covers `beforeEach`/`afterEach`,
|
|
251
|
+
// but an `authorize` hook can run even with `runHooks: false` — it is
|
|
252
|
+
// gated by the *flag*, evaluated here after the overlay and `options`
|
|
253
|
+
// applied it, and by whether one is registered. Guarding on `runHooks`
|
|
254
|
+
// alone left that second path open: a global `authorize` seeding its own
|
|
255
|
+
// token with `runHooks: false` recursed into itself through exactly this
|
|
256
|
+
// path, with nothing to stop it short of a timeout.
|
|
257
|
+
const willRunAHook = runHooks || (template.authorize === true && !!authorizeHook);
|
|
258
|
+
if (willRunAHook && isOnChain(chain, selector)) {
|
|
259
|
+
throw requestCycleError(chain, selector);
|
|
105
260
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
skip: e.message,
|
|
111
|
-
testResults,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
if (e instanceof FailError) {
|
|
115
|
-
return {
|
|
116
|
-
result: value,
|
|
117
|
-
fail: e.message,
|
|
118
|
-
testResults,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
throw new ThymianBaseError(`Error while running authorize hook${hook.ctx ? ' for transaction: ' + thymianHttpTransactionToString(hook.ctx.thymianReq, hook.ctx.thymianRes) : ''}.`, {
|
|
122
|
-
cause: e,
|
|
123
|
-
name: 'HookError',
|
|
124
|
-
});
|
|
261
|
+
const results = [];
|
|
262
|
+
if (runHooks) {
|
|
263
|
+
const before = await this.compose('beforeEach', this.hooksFor(transaction.transactionId).beforeEach, template, transaction, template, nested);
|
|
264
|
+
results.push(...before.testResults);
|
|
125
265
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
throw new ThymianBaseError('Cannot run hooks before @thymian/plugin-sampler is initialized.', {
|
|
130
|
-
name: 'HookRunnerNotInitialized',
|
|
131
|
-
suggestions: ['Did you run "thymian sampler init"?'],
|
|
132
|
-
});
|
|
266
|
+
if (template.authorize && authorizeHook) {
|
|
267
|
+
const authorized = await this.compose('authorize', [authorizeHook], template, transaction, template, nested);
|
|
268
|
+
results.push(...authorized.testResults);
|
|
133
269
|
}
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
270
|
+
const request = serializeRequest({
|
|
271
|
+
requestTemplate: template,
|
|
272
|
+
source: transaction,
|
|
273
|
+
});
|
|
274
|
+
const response = await this.ports.dispatch(request);
|
|
275
|
+
if (runHooks) {
|
|
276
|
+
const after = await this.compose('afterEach', this.hooksFor(transaction.transactionId).afterEach, response, { request, requestTemplate: template, thymianTransaction: transaction }, template, nested);
|
|
277
|
+
results.push(...after.testResults);
|
|
278
|
+
}
|
|
279
|
+
// A nested request has no test case of its own; what its hooks recorded is
|
|
280
|
+
// logged rather than dropped.
|
|
281
|
+
reportHookResults(this.logger, results);
|
|
282
|
+
const body = parseResponseBody(response);
|
|
283
|
+
// The Selector said which Transaction to initiate; the server decided which
|
|
284
|
+
// one happened. Either way, a seed that was answered with something other
|
|
285
|
+
// than what it asked for is recorded on the *calling* hook's results — that
|
|
286
|
+
// is what lets `sampler check` say which seed a skip was caused by instead
|
|
287
|
+
// of only that this transaction did not work.
|
|
288
|
+
if (response.statusCode !== transaction.thymianRes.statusCode) {
|
|
289
|
+
// A declared status is one of the union's members and comes back for the
|
|
290
|
+
// caller to branch on. An undeclared one has no member to be, so it
|
|
291
|
+
// throws rather than arriving as a value whose type is a lie.
|
|
292
|
+
const undeclared = this.declaresStatus(transaction, response.statusCode)
|
|
293
|
+
? undefined
|
|
294
|
+
: new UndeclaredResponseError(selector, response.statusCode, response.headers, body);
|
|
295
|
+
callerResults.push({
|
|
296
|
+
type: 'invalid-transaction',
|
|
297
|
+
// The same sentence the thrown error carries, deliberately: when it
|
|
298
|
+
// escapes the hook it becomes the transaction's reason, and one
|
|
299
|
+
// sentence printed once is the whole point of saying it in one place.
|
|
300
|
+
message: undeclared?.message ??
|
|
301
|
+
`The seed "${selector}" was answered with ${response.statusCode}, not the ${transaction.thymianRes.statusCode} its selector names.`,
|
|
302
|
+
transaction,
|
|
303
|
+
timestamp: Date.now(),
|
|
304
|
+
details: undeclared
|
|
305
|
+
? 'Branch on the seed’s status code, or call utils.skip to end this transaction deliberately.'
|
|
306
|
+
: 'The specification declares that response, so the seed ran — but it did not put the system into the state this transaction describes. Branch on the status code in the seeding hook, or fix the data it sends.',
|
|
307
|
+
});
|
|
308
|
+
if (undeclared) {
|
|
309
|
+
throw undeclared;
|
|
164
310
|
}
|
|
165
311
|
}
|
|
166
312
|
return {
|
|
167
|
-
|
|
168
|
-
|
|
313
|
+
body,
|
|
314
|
+
headers: response.headers,
|
|
315
|
+
mediaType: mediaTypeOf(response),
|
|
316
|
+
statusCode: response.statusCode,
|
|
169
317
|
};
|
|
170
318
|
}
|
|
319
|
+
/** Whether the target's operation declares a response with this status. */
|
|
320
|
+
declaresStatus(transaction, statusCode) {
|
|
321
|
+
return this.catalog
|
|
322
|
+
.responsesOf(transaction)
|
|
323
|
+
.some(([, sibling]) => sibling.thymianRes.statusCode === statusCode);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* The media type a response actually carried: the essence of its content type,
|
|
328
|
+
* parameters stripped, or `''` when it declared none.
|
|
329
|
+
*
|
|
330
|
+
* Only the *status* decides whether a response is declared — that is what the
|
|
331
|
+
* union discriminates on, and what `UndeclaredResponseError` reports. The media
|
|
332
|
+
* type is reported as observed, so a body that arrives as something the
|
|
333
|
+
* description did not promise is visible rather than relabelled.
|
|
334
|
+
*/
|
|
335
|
+
function mediaTypeOf(response) {
|
|
336
|
+
const contentType = getContentType(response.headers);
|
|
337
|
+
return (contentType.split(';')[0] ?? '').trim().toLowerCase();
|
|
171
338
|
}
|
|
172
339
|
//# sourceMappingURL=hook-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-runner.js","sourceRoot":"","sources":["../../src/hooks/hook-runner.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"hook-runner.js","sourceRoot":"","sources":["../../src/hooks/hook-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAOd,gBAAgB,EAChB,aAAa,GAEd,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EACL,eAAe,EAEf,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAQ3D,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,SAAS,EACT,iBAAiB,GAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,WAAW,GAAqB,M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+
import type { HttpTestCaseResult } from '@thymian/core';
|
|
2
|
+
import type { Endpoints, HookUtils } from './hook-utils.js';
|
|
3
|
+
import type { CollectedRegistration } from './load-user-hooks.js';
|
|
4
|
+
/**
|
|
5
|
+
* Makes one `utils` object and the array its results land in, for one
|
|
6
|
+
* registration.
|
|
7
|
+
*
|
|
8
|
+
* A factory rather than a single object: results belong to one hook call, so
|
|
9
|
+
* each call needs its own array, and the caller is the only thing that knows
|
|
10
|
+
* where those results should end up. It takes the registration itself —
|
|
11
|
+
* rather than being called bare — so a run-scoped hook's file helpers resolve
|
|
12
|
+
* against *its own* file's directory instead of the process's working
|
|
13
|
+
* directory.
|
|
14
|
+
*/
|
|
15
|
+
export type HookUtilsFactory = (entry: CollectedRegistration) => {
|
|
16
|
+
utils: HookUtils<Endpoints>;
|
|
17
|
+
results: HttpTestCaseResult[];
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=hook-utils-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-utils-factory.d.ts","sourceRoot":"","sources":["../../src/hooks/hook-utils-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,qBAAqB,KAAK;IAC/D,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-utils-factory.js","sourceRoot":"","sources":["../../src/hooks/hook-utils-factory.ts"],"names":[],"mappings":""}
|