@driftfence/core 0.1.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 +81 -0
- package/README.md +36 -0
- package/dist/draft/scenario.d.ts +3 -0
- package/dist/draft/scenario.d.ts.map +1 -0
- package/dist/draft/scenario.js +207 -0
- package/dist/draft/scenario.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/io/config.d.ts +10 -0
- package/dist/io/config.d.ts.map +1 -0
- package/dist/io/config.js +165 -0
- package/dist/io/config.js.map +1 -0
- package/dist/io/contracts.d.ts +7 -0
- package/dist/io/contracts.d.ts.map +1 -0
- package/dist/io/contracts.js +562 -0
- package/dist/io/contracts.js.map +1 -0
- package/dist/io/files.d.ts +6 -0
- package/dist/io/files.d.ts.map +1 -0
- package/dist/io/files.js +49 -0
- package/dist/io/files.js.map +1 -0
- package/dist/io/suppressions.d.ts +16 -0
- package/dist/io/suppressions.d.ts.map +1 -0
- package/dist/io/suppressions.js +108 -0
- package/dist/io/suppressions.js.map +1 -0
- package/dist/io/traces.d.ts +3 -0
- package/dist/io/traces.d.ts.map +1 -0
- package/dist/io/traces.js +40 -0
- package/dist/io/traces.js.map +1 -0
- package/dist/match/expr.d.ts +3 -0
- package/dist/match/expr.d.ts.map +1 -0
- package/dist/match/expr.js +43 -0
- package/dist/match/expr.js.map +1 -0
- package/dist/match/value.d.ts +5 -0
- package/dist/match/value.d.ts.map +1 -0
- package/dist/match/value.js +127 -0
- package/dist/match/value.js.map +1 -0
- package/dist/normalize/trace.d.ts +12 -0
- package/dist/normalize/trace.d.ts.map +1 -0
- package/dist/normalize/trace.js +215 -0
- package/dist/normalize/trace.js.map +1 -0
- package/dist/query/index.d.ts +4 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +96 -0
- package/dist/query/index.js.map +1 -0
- package/dist/report/check.d.ts +3 -0
- package/dist/report/check.d.ts.map +1 -0
- package/dist/report/check.js +347 -0
- package/dist/report/check.js.map +1 -0
- package/dist/report/render.d.ts +11 -0
- package/dist/report/render.d.ts.map +1 -0
- package/dist/report/render.js +99 -0
- package/dist/report/render.js.map +1 -0
- package/dist/schemas/index.d.ts +578 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +492 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +402 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/errors.d.ts +18 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +34 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/json.d.ts +10 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +98 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/order.d.ts +8 -0
- package/dist/utils/order.d.ts.map +1 -0
- package/dist/utils/order.js +42 -0
- package/dist/utils/order.js.map +1 -0
- package/dist/utils/path.d.ts +8 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +168 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/verify/invariants.d.ts +3 -0
- package/dist/verify/invariants.d.ts.map +1 -0
- package/dist/verify/invariants.js +38 -0
- package/dist/verify/invariants.js.map +1 -0
- package/dist/verify/sequence.d.ts +3 -0
- package/dist/verify/sequence.d.ts.map +1 -0
- package/dist/verify/sequence.js +151 -0
- package/dist/verify/sequence.js.map +1 -0
- package/dist/verify/summary.d.ts +8 -0
- package/dist/verify/summary.d.ts.map +1 -0
- package/dist/verify/summary.js +132 -0
- package/dist/verify/summary.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/io/files.ts"],"names":[],"mappings":";;;;;AAGA,0C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,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC1B,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,OAAO,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,SAAS,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpB,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentName, ScenarioStatus, SuppressionFile, SuppressionRule } from "../types";
|
|
2
|
+
export declare const DEFAULT_SUPPRESSIONS: SuppressionFile;
|
|
3
|
+
export declare function canonicalizeSuppressions(file: SuppressionFile): SuppressionFile;
|
|
4
|
+
export declare function loadSuppressions(filePath: string): Promise<SuppressionFile>;
|
|
5
|
+
export declare function renderSuppressionsYaml(file: SuppressionFile): string;
|
|
6
|
+
export interface SuppressionTarget {
|
|
7
|
+
contractId: string;
|
|
8
|
+
scenarioId?: string;
|
|
9
|
+
component?: ComponentName;
|
|
10
|
+
classification: ScenarioStatus | "WARN";
|
|
11
|
+
code?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function isSuppressionExpired(suppression: SuppressionRule, now?: Date): boolean;
|
|
15
|
+
export declare function findMatchingSuppressions(file: SuppressionFile, target: SuppressionTarget, now?: Date): SuppressionRule[];
|
|
16
|
+
//# sourceMappingURL=suppressions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suppressions.d.ts","sourceRoot":"","sources":["../../src/io/suppressions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAIlB,eAAO,MAAM,oBAAoB,EAAE,eAGlC,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,eAAe,GACpB,eAAe,CA0BjB;AAuBD,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC,CAgB1B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAKpE;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,cAAc,EAAE,cAAc,GAAG,MAAM,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,eAAe,EAC5B,GAAG,OAAa,GACf,OAAO,CAET;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,iBAAiB,EACzB,GAAG,OAAa,GACf,eAAe,EAAE,CA+CnB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SUPPRESSIONS = void 0;
|
|
4
|
+
exports.canonicalizeSuppressions = canonicalizeSuppressions;
|
|
5
|
+
exports.loadSuppressions = loadSuppressions;
|
|
6
|
+
exports.renderSuppressionsYaml = renderSuppressionsYaml;
|
|
7
|
+
exports.isSuppressionExpired = isSuppressionExpired;
|
|
8
|
+
exports.findMatchingSuppressions = findMatchingSuppressions;
|
|
9
|
+
const yaml_1 = require("yaml");
|
|
10
|
+
const schemas_1 = require("../schemas");
|
|
11
|
+
const errors_1 = require("../utils/errors");
|
|
12
|
+
const files_1 = require("./files");
|
|
13
|
+
exports.DEFAULT_SUPPRESSIONS = {
|
|
14
|
+
schemaVersion: "driftfence-suppressions/v1",
|
|
15
|
+
suppressions: []
|
|
16
|
+
};
|
|
17
|
+
function canonicalizeSuppressions(file) {
|
|
18
|
+
return {
|
|
19
|
+
schemaVersion: "driftfence-suppressions/v1",
|
|
20
|
+
suppressions: [...file.suppressions]
|
|
21
|
+
.sort((left, right) => left.id.localeCompare(right.id))
|
|
22
|
+
.map((suppression) => ({
|
|
23
|
+
id: suppression.id,
|
|
24
|
+
match: {
|
|
25
|
+
contractId: suppression.match.contractId,
|
|
26
|
+
...(suppression.match.scenarioId
|
|
27
|
+
? { scenarioId: suppression.match.scenarioId }
|
|
28
|
+
: {}),
|
|
29
|
+
...(suppression.match.component
|
|
30
|
+
? { component: suppression.match.component }
|
|
31
|
+
: {}),
|
|
32
|
+
...(suppression.match.classification
|
|
33
|
+
? { classification: suppression.match.classification }
|
|
34
|
+
: {}),
|
|
35
|
+
...(suppression.match.code ? { code: suppression.match.code } : {}),
|
|
36
|
+
...(suppression.match.name ? { name: suppression.match.name } : {})
|
|
37
|
+
},
|
|
38
|
+
reason: suppression.reason,
|
|
39
|
+
owner: suppression.owner,
|
|
40
|
+
expiresAt: suppression.expiresAt
|
|
41
|
+
}))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function validateSuppressionFile(file) {
|
|
45
|
+
const ids = new Set();
|
|
46
|
+
for (const suppression of file.suppressions) {
|
|
47
|
+
if (ids.has(suppression.id)) {
|
|
48
|
+
throw new errors_1.DriftFenceError(`Duplicate suppression id: ${suppression.id}`, errors_1.EXIT_CODES.CONFIG_ERROR);
|
|
49
|
+
}
|
|
50
|
+
ids.add(suppression.id);
|
|
51
|
+
if (Number.isNaN(Date.parse(suppression.expiresAt))) {
|
|
52
|
+
throw new errors_1.DriftFenceError(`Invalid suppression expiry: ${suppression.id}`, errors_1.EXIT_CODES.CONFIG_ERROR);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function loadSuppressions(filePath) {
|
|
57
|
+
if (!(await (0, files_1.pathExists)(filePath))) {
|
|
58
|
+
return exports.DEFAULT_SUPPRESSIONS;
|
|
59
|
+
}
|
|
60
|
+
const raw = (0, yaml_1.parse)(await (0, files_1.readUtf8File)(filePath));
|
|
61
|
+
const parsed = schemas_1.suppressionFileSchema.safeParse(raw);
|
|
62
|
+
if (!parsed.success) {
|
|
63
|
+
throw new errors_1.DriftFenceError(`Invalid suppressions file: ${parsed.error.message}`, errors_1.EXIT_CODES.CONFIG_ERROR);
|
|
64
|
+
}
|
|
65
|
+
validateSuppressionFile(parsed.data);
|
|
66
|
+
return canonicalizeSuppressions(parsed.data);
|
|
67
|
+
}
|
|
68
|
+
function renderSuppressionsYaml(file) {
|
|
69
|
+
return (0, yaml_1.stringify)(canonicalizeSuppressions(file), {
|
|
70
|
+
aliasDuplicateObjects: false,
|
|
71
|
+
lineWidth: 0
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function isSuppressionExpired(suppression, now = new Date()) {
|
|
75
|
+
return new Date(suppression.expiresAt).getTime() <= now.getTime();
|
|
76
|
+
}
|
|
77
|
+
function findMatchingSuppressions(file, target, now = new Date()) {
|
|
78
|
+
return file.suppressions.filter((suppression) => {
|
|
79
|
+
if (isSuppressionExpired(suppression, now)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if (suppression.match.contractId !== target.contractId) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (suppression.match.scenarioId !== undefined &&
|
|
86
|
+
suppression.match.scenarioId !== target.scenarioId) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (suppression.match.component !== undefined &&
|
|
90
|
+
suppression.match.component !== target.component) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (suppression.match.classification !== undefined &&
|
|
94
|
+
suppression.match.classification !== target.classification) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (suppression.match.code !== undefined &&
|
|
98
|
+
suppression.match.code !== target.code) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (suppression.match.name !== undefined &&
|
|
102
|
+
suppression.match.name !== target.name) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=suppressions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suppressions.js","sourceRoot":"","sources":["../../src/io/suppressions.ts"],"names":[],"mappings":";;;AAiBA,4DA4BC;AAuBD,4CAkBC;AAED,wDAKC;AAWD,oDAKC;AAED,4DAmDC;AAlKD,+BAAsE;AAEtE,wCAAmD;AAOnD,4CAA8D;AAC9D,mCAAmD;AAEtC,QAAA,oBAAoB,GAAoB;IACnD,aAAa,EAAE,4BAA4B;IAC3C,YAAY,EAAE,EAAE;CACjB,CAAC;AAEF,SAAgB,wBAAwB,CACtC,IAAqB;IAErB,OAAO;QACL,aAAa,EAAE,4BAA4B;QAC3C,YAAY,EAAE,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;aACjC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;aACtD,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YACrB,EAAE,EAAE,WAAW,CAAC,EAAE;YAClB,KAAK,EAAE;gBACL,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,UAAU;gBACxC,GAAG,CAAC,WAAW,CAAC,KAAK,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C,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traces.d.ts","sourceRoot":"","sources":["../../src/io/traces.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA6BhD,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,EAAE,CAAC,CA4B5B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadTraces = loadTraces;
|
|
4
|
+
const schemas_1 = require("../schemas");
|
|
5
|
+
const errors_1 = require("../utils/errors");
|
|
6
|
+
const files_1 = require("./files");
|
|
7
|
+
async function loadTraceFile(filePath) {
|
|
8
|
+
let raw;
|
|
9
|
+
try {
|
|
10
|
+
raw = JSON.parse(await (0, files_1.readUtf8File)(filePath));
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
throw new errors_1.DriftFenceError(`Invalid trace JSON at ${filePath}: ${error instanceof Error ? error.message : String(error)}`, errors_1.EXIT_CODES.TRACE_ERROR);
|
|
14
|
+
}
|
|
15
|
+
const parsed = schemas_1.traceFileSchema.safeParse(raw);
|
|
16
|
+
if (!parsed.success) {
|
|
17
|
+
throw new errors_1.DriftFenceError(`Invalid trace file at ${filePath}: ${parsed.error.message}`, errors_1.EXIT_CODES.TRACE_ERROR);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
...parsed.data,
|
|
21
|
+
filePath
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async function loadTraces(tracesDir) {
|
|
25
|
+
if (!(await (0, files_1.pathExists)(tracesDir))) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const filePaths = await (0, files_1.readDirectoryFiles)(tracesDir, (filePath) => filePath.endsWith(".json"));
|
|
29
|
+
const traces = await Promise.all(filePaths.map((filePath) => loadTraceFile(filePath)));
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
for (const trace of traces) {
|
|
32
|
+
const key = `${trace.contractId}::${trace.scenarioId}`;
|
|
33
|
+
if (seen.has(key)) {
|
|
34
|
+
throw new errors_1.DriftFenceError(`Duplicate trace for ${trace.contractId} / ${trace.scenarioId}`, errors_1.EXIT_CODES.TRACE_ERROR);
|
|
35
|
+
}
|
|
36
|
+
seen.add(key);
|
|
37
|
+
}
|
|
38
|
+
return traces.sort((left, right) => `${left.contractId}::${left.scenarioId}`.localeCompare(`${right.contractId}::${right.scenarioId}`));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=traces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traces.js","sourceRoot":"","sources":["../../src/io/traces.ts"],"names":[],"mappings":";;AA8BA,gCA8BC;AA5DD,wCAA6C;AAE7C,4CAA8D;AAC9D,mCAAuE;AAEvE,KAAK,UAAU,aAAa,CAAC,QAAgB;IAC3C,IAAI,GAAY,CAAC;IACjB,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAA,oBAAY,EAAC,QAAQ,CAAC,CAAY,CAAC;IAC5D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,wBAAe,CACvB,yBAAyB,QAAQ,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC9F,mBAAU,CAAC,WAAW,CACvB,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,yBAAe,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,wBAAe,CACvB,yBAAyB,QAAQ,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAC5D,mBAAU,CAAC,WA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|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expr.d.ts","sourceRoot":"","sources":["../../src/match/expr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAQnD,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAgDvE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evaluateExpr = evaluateExpr;
|
|
4
|
+
const json_1 = require("../utils/json");
|
|
5
|
+
const path_1 = require("../utils/path");
|
|
6
|
+
function truthy(value) {
|
|
7
|
+
return Boolean(value);
|
|
8
|
+
}
|
|
9
|
+
function evaluateExpr(expr, context) {
|
|
10
|
+
if (expr === null || typeof expr !== "object" || Array.isArray(expr)) {
|
|
11
|
+
return expr;
|
|
12
|
+
}
|
|
13
|
+
if (!(0, json_1.isPlainObject)(expr)) {
|
|
14
|
+
return expr;
|
|
15
|
+
}
|
|
16
|
+
if ("$from" in expr) {
|
|
17
|
+
return (0, path_1.resolvePath)(context, expr.$from);
|
|
18
|
+
}
|
|
19
|
+
if ("$eq" in expr) {
|
|
20
|
+
return (0, json_1.deepEqual)(evaluateExpr(expr.$eq[0], context), evaluateExpr(expr.$eq[1], context));
|
|
21
|
+
}
|
|
22
|
+
if ("$and" in expr) {
|
|
23
|
+
return expr.$and.every((item) => evaluateExpr(item, context) === true);
|
|
24
|
+
}
|
|
25
|
+
if ("$or" in expr) {
|
|
26
|
+
return expr.$or.some((item) => evaluateExpr(item, context) === true);
|
|
27
|
+
}
|
|
28
|
+
if ("$not" in expr) {
|
|
29
|
+
return !truthy(evaluateExpr(expr.$not, context));
|
|
30
|
+
}
|
|
31
|
+
if ("$implies" in expr) {
|
|
32
|
+
return (!truthy(evaluateExpr(expr.$implies[0], context)) ||
|
|
33
|
+
truthy(evaluateExpr(expr.$implies[1], context)));
|
|
34
|
+
}
|
|
35
|
+
if ("$occurred" in expr) {
|
|
36
|
+
return (context.occurredCounts[expr.$occurred] ?? 0) > 0;
|
|
37
|
+
}
|
|
38
|
+
if ("$count" in expr) {
|
|
39
|
+
return context.occurredCounts[expr.$count] ?? 0;
|
|
40
|
+
}
|
|
41
|
+
return expr;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=expr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expr.js","sourceRoot":"","sources":["../../src/match/expr.ts"],"names":[],"mappings":";;AAQA,oCAgDC;AAvDD,wCAAyD;AACzD,wCAA4C;AAE5C,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,SAAgB,YAAY,CAAC,IAAU,EAAE,OAAqB;IAC5D,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,IAAA,oBAAa,EAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,OAAO,IAAA,kBAAW,EAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,IAAA,gBAAS,EACd,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAClC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CACnC,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;IACvE,CAAC;IAED,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,CACL,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAChD,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAChD,CAAC;IACJ,CAAC;IAED,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,OAAO,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ErrorExpectation, MatchContext, MatchFailure, MatchOptions, MatchResult, ValueMatcher } from "../types";
|
|
2
|
+
export declare function matchValue(expected: ValueMatcher, actual: unknown, context: MatchContext, options: MatchOptions, path?: string): MatchResult;
|
|
3
|
+
export declare function matchErrorExpectation(expected: ErrorExpectation, actual: unknown, context: MatchContext, options: MatchOptions): MatchResult;
|
|
4
|
+
export declare function describeMatchFailure(failure: MatchFailure): string;
|
|
5
|
+
//# sourceMappingURL=value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../src/match/value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACb,MAAM,UAAU,CAAC;AA+BlB,wBAAgB,UAAU,CACxB,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,YAAY,EACrB,IAAI,SAAK,GACR,WAAW,CA4Gb;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,YAAY,GACpB,WAAW,CAuBb;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAIlE"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchValue = matchValue;
|
|
4
|
+
exports.matchErrorExpectation = matchErrorExpectation;
|
|
5
|
+
exports.describeMatchFailure = describeMatchFailure;
|
|
6
|
+
const json_1 = require("../utils/json");
|
|
7
|
+
const path_1 = require("../utils/path");
|
|
8
|
+
function joinPath(basePath, key) {
|
|
9
|
+
return basePath === "" ? key : `${basePath}.${key}`;
|
|
10
|
+
}
|
|
11
|
+
function fail(path, expected, actual) {
|
|
12
|
+
return {
|
|
13
|
+
ok: false,
|
|
14
|
+
failure: {
|
|
15
|
+
path,
|
|
16
|
+
expected,
|
|
17
|
+
actual
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function isReservedObject(value) {
|
|
22
|
+
if (!(0, json_1.isPlainObject)(value)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const keys = Object.keys(value);
|
|
26
|
+
return (keys.length === 1 &&
|
|
27
|
+
["$from", "$any", "$oneOf", "$regex", "$ignore"].includes(keys[0] ?? ""));
|
|
28
|
+
}
|
|
29
|
+
function matchValue(expected, actual, context, options, path = "") {
|
|
30
|
+
if (isReservedObject(expected)) {
|
|
31
|
+
if ("$ignore" in expected) {
|
|
32
|
+
return { ok: true };
|
|
33
|
+
}
|
|
34
|
+
if ("$any" in expected) {
|
|
35
|
+
return actual !== undefined ? { ok: true } : fail(path, expected, actual);
|
|
36
|
+
}
|
|
37
|
+
if ("$from" in expected) {
|
|
38
|
+
const resolvedValue = (0, path_1.resolvePath)(context, expected.$from);
|
|
39
|
+
return (0, json_1.deepEqual)(resolvedValue, actual)
|
|
40
|
+
? { ok: true }
|
|
41
|
+
: fail(path, resolvedValue, actual);
|
|
42
|
+
}
|
|
43
|
+
if ("$oneOf" in expected) {
|
|
44
|
+
const values = expected.$oneOf;
|
|
45
|
+
return values.some((item) => (0, json_1.deepEqual)(item, actual))
|
|
46
|
+
? { ok: true }
|
|
47
|
+
: fail(path, values, actual);
|
|
48
|
+
}
|
|
49
|
+
if ("$regex" in expected) {
|
|
50
|
+
return typeof actual === "string" &&
|
|
51
|
+
new RegExp(expected.$regex).test(actual)
|
|
52
|
+
? { ok: true }
|
|
53
|
+
: fail(path, expected.$regex, actual);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (expected === null || typeof expected !== "object") {
|
|
57
|
+
return (0, json_1.deepEqual)(expected, actual)
|
|
58
|
+
? { ok: true }
|
|
59
|
+
: fail(path, expected, actual);
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(expected)) {
|
|
62
|
+
if (!Array.isArray(actual)) {
|
|
63
|
+
return fail(path, expected, actual);
|
|
64
|
+
}
|
|
65
|
+
if (options.strictArrays && actual.length !== expected.length) {
|
|
66
|
+
return fail(path, expected.length, actual.length);
|
|
67
|
+
}
|
|
68
|
+
if (actual.length < expected.length) {
|
|
69
|
+
return fail(path, expected.length, actual.length);
|
|
70
|
+
}
|
|
71
|
+
for (let index = 0; index < expected.length; index += 1) {
|
|
72
|
+
const nested = matchValue(expected[index], actual[index], context, options, `${path}[${index}]`);
|
|
73
|
+
if (!nested.ok) {
|
|
74
|
+
return nested;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return { ok: true };
|
|
78
|
+
}
|
|
79
|
+
if (!(0, json_1.isPlainObject)(actual)) {
|
|
80
|
+
return fail(path, expected, actual);
|
|
81
|
+
}
|
|
82
|
+
for (const [key, nestedExpected] of Object.entries(expected)) {
|
|
83
|
+
const nestedPath = joinPath(path, key);
|
|
84
|
+
const keyExists = Object.prototype.hasOwnProperty.call(actual, key);
|
|
85
|
+
if (isReservedObject(nestedExpected) && "$ignore" in nestedExpected) {
|
|
86
|
+
if (!keyExists) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (!keyExists) {
|
|
91
|
+
return fail(nestedPath, nestedExpected, undefined);
|
|
92
|
+
}
|
|
93
|
+
const nestedActual = actual[key];
|
|
94
|
+
const nestedMatch = matchValue(nestedExpected, nestedActual, context, options, nestedPath);
|
|
95
|
+
if (!nestedMatch.ok) {
|
|
96
|
+
return nestedMatch;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (options.strictObjects) {
|
|
100
|
+
for (const key of Object.keys(actual)) {
|
|
101
|
+
if (!(key in expected)) {
|
|
102
|
+
return fail(joinPath(path, key), undefined, actual[key]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return { ok: true };
|
|
107
|
+
}
|
|
108
|
+
function matchErrorExpectation(expected, actual, context, options) {
|
|
109
|
+
if ("none" in expected) {
|
|
110
|
+
return actual === null || actual === undefined
|
|
111
|
+
? { ok: true }
|
|
112
|
+
: fail("error", expected, actual);
|
|
113
|
+
}
|
|
114
|
+
if (actual === null ||
|
|
115
|
+
actual === undefined ||
|
|
116
|
+
typeof actual !== "object" ||
|
|
117
|
+
Array.isArray(actual)) {
|
|
118
|
+
return fail("error", expected, actual);
|
|
119
|
+
}
|
|
120
|
+
return matchValue(expected, actual, context, options, "error");
|
|
121
|
+
}
|
|
122
|
+
function describeMatchFailure(failure) {
|
|
123
|
+
return failure.path === ""
|
|
124
|
+
? "Values differ."
|
|
125
|
+
: `Mismatch at ${failure.path}.`;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value.js","sourceRoot":"","sources":["../../src/match/value.ts"],"names":[],"mappings":";;AAsCA,gCAkHC;AAED,sDA4BC;AAED,oDAIC;AApLD,wCAAyD;AACzD,wCAA4C;AAE5C,SAAS,QAAQ,CAAC,QAAgB,EAAE,GAAW;IAC7C,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,GAAG,EAAE,CAAC;AACtD,CAAC;AAED,SAAS,IAAI,CAAC,IAAY,EAAE,QAAiB,EAAE,MAAe;IAC5D,OAAO;QACL,EAAE,EAAE,KAAK;QACT,OAAO,EAAE;YACP,IAAI;YACJ,QAAQ;YACR,MAAM;SACP;KACF,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,CAAC,IAAA,oBAAa,EAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,OAAO,CACL,IAAI,CAAC,MAAM,KAAK,CAAC;QACjB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,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import type { CallRecord, MatchOptions, ResolvedDriftFenceConfig, TraceFile, WorkflowContractFile } from "../types";
|
|
2
|
+
export declare function normalizeTrace(trace: TraceFile, config: ResolvedDriftFenceConfig): TraceFile;
|
|
3
|
+
export declare function normalizeContract(contract: WorkflowContractFile, config: ResolvedDriftFenceConfig): WorkflowContractFile;
|
|
4
|
+
export declare function resolveMatchOptions(fileDefaults: {
|
|
5
|
+
strictObjects?: boolean;
|
|
6
|
+
strictArrays?: boolean;
|
|
7
|
+
} | undefined, scenarioOptions: {
|
|
8
|
+
strictObjects?: boolean;
|
|
9
|
+
strictArrays?: boolean;
|
|
10
|
+
} | undefined): MatchOptions;
|
|
11
|
+
export declare function countOccurredCalls(calls: CallRecord[]): Record<string, number>;
|
|
12
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/normalize/trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,wBAAwB,EACxB,SAAS,EAET,oBAAoB,EACrB,MAAM,UAAU,CAAC;AA4FlB,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,wBAAwB,GAC/B,SAAS,CAmBX;AAqCD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,EAAE,wBAAwB,GAC/B,oBAAoB,CA6GtB;AAED,wBAAgB,mBAAmB,CACjC,YAAY,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,EAC7E,eAAe,EACX;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GACnD,SAAS,GACZ,YAAY,CAOd;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,EAAE,GAClB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxB"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeTrace = normalizeTrace;
|
|
4
|
+
exports.normalizeContract = normalizeContract;
|
|
5
|
+
exports.resolveMatchOptions = resolveMatchOptions;
|
|
6
|
+
exports.countOccurredCalls = countOccurredCalls;
|
|
7
|
+
const errors_1 = require("../utils/errors");
|
|
8
|
+
const json_1 = require("../utils/json");
|
|
9
|
+
const path_1 = require("../utils/path");
|
|
10
|
+
function applyAlias(name, aliases) {
|
|
11
|
+
return aliases[name] ?? name;
|
|
12
|
+
}
|
|
13
|
+
function transformValue(value, transform) {
|
|
14
|
+
switch (transform) {
|
|
15
|
+
case "redact":
|
|
16
|
+
return "[REDACTED]";
|
|
17
|
+
case "ignore":
|
|
18
|
+
return undefined;
|
|
19
|
+
case "zero":
|
|
20
|
+
if (typeof value === "number") {
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
if ((0, json_1.isNumericString)(value)) {
|
|
24
|
+
return "0";
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
case "sortArray":
|
|
28
|
+
if (!Array.isArray(value)) {
|
|
29
|
+
throw new errors_1.DriftFenceError("Configured sortArrayPaths target must resolve to an array.", errors_1.EXIT_CODES.CONFIG_ERROR);
|
|
30
|
+
}
|
|
31
|
+
return [...value].sort((left, right) => (0, json_1.stableStringify)(left).localeCompare((0, json_1.stableStringify)(right)));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function applyTransforms(root, paths, transform) {
|
|
35
|
+
for (const currentPath of paths) {
|
|
36
|
+
if (!(0, path_1.hasPath)(root, currentPath)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (transform === "ignore") {
|
|
40
|
+
(0, path_1.deletePath)(root, currentPath);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const currentValue = (0, path_1.resolvePath)(root, currentPath);
|
|
44
|
+
const nextValue = transformValue(currentValue, transform);
|
|
45
|
+
(0, path_1.setPath)(root, currentPath, nextValue);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function normalizeValue(value, config) {
|
|
49
|
+
const clone = (0, json_1.jsonClone)(value);
|
|
50
|
+
applyTransforms(clone, config.normalization.redactPaths, "redact");
|
|
51
|
+
applyTransforms(clone, config.normalization.ignorePaths, "ignore");
|
|
52
|
+
applyTransforms(clone, config.normalization.zeroPaths, "zero");
|
|
53
|
+
applyTransforms(clone, config.normalization.sortArrayPaths, "sortArray");
|
|
54
|
+
return clone;
|
|
55
|
+
}
|
|
56
|
+
function normalizeCall(call, config) {
|
|
57
|
+
if (call.kind === "effect") {
|
|
58
|
+
return normalizeValue({
|
|
59
|
+
...call,
|
|
60
|
+
name: applyAlias(call.name, config.aliases.effects)
|
|
61
|
+
}, config);
|
|
62
|
+
}
|
|
63
|
+
return normalizeValue({
|
|
64
|
+
...call,
|
|
65
|
+
event: applyAlias(call.event, config.aliases.emits)
|
|
66
|
+
}, config);
|
|
67
|
+
}
|
|
68
|
+
function normalizeTrace(trace, config) {
|
|
69
|
+
return {
|
|
70
|
+
...trace,
|
|
71
|
+
input: normalizeValue(trace.input, config),
|
|
72
|
+
...(trace.stateBefore !== undefined
|
|
73
|
+
? { stateBefore: normalizeValue(trace.stateBefore, config) }
|
|
74
|
+
: {}),
|
|
75
|
+
calls: trace.calls.map((call) => normalizeCall(call, config)),
|
|
76
|
+
...(trace.output !== undefined
|
|
77
|
+
? { output: normalizeValue(trace.output, config) }
|
|
78
|
+
: {}),
|
|
79
|
+
...(trace.error !== undefined
|
|
80
|
+
? { error: normalizeValue(trace.error, config) }
|
|
81
|
+
: {}),
|
|
82
|
+
...(trace.stateAfter !== undefined
|
|
83
|
+
? { stateAfter: normalizeValue(trace.stateAfter, config) }
|
|
84
|
+
: {}),
|
|
85
|
+
...(trace.meta !== undefined ? { meta: (0, json_1.jsonClone)(trace.meta) } : {})
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function matcherIsReserved(value) {
|
|
89
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
const keys = Object.keys(value);
|
|
93
|
+
return (keys.length === 1 &&
|
|
94
|
+
["$from", "$any", "$oneOf", "$regex", "$ignore"].includes(keys[0] ?? ""));
|
|
95
|
+
}
|
|
96
|
+
function cloneMatcherValue(value) {
|
|
97
|
+
if (value === undefined || value === null || typeof value !== "object") {
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
if (matcherIsReserved(value)) {
|
|
101
|
+
return (0, json_1.jsonClone)(value);
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(value)) {
|
|
104
|
+
return value.map((item) => cloneMatcherValue(item));
|
|
105
|
+
}
|
|
106
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [
|
|
107
|
+
key,
|
|
108
|
+
cloneMatcherValue(child)
|
|
109
|
+
]));
|
|
110
|
+
}
|
|
111
|
+
function normalizeContract(contract, config) {
|
|
112
|
+
return {
|
|
113
|
+
...contract,
|
|
114
|
+
scenarios: contract.scenarios.map((scenario) => {
|
|
115
|
+
const projectedCalls = scenario.expect.sequence?.steps.map((step) => step.kind === "effect"
|
|
116
|
+
? {
|
|
117
|
+
...(step.args !== undefined
|
|
118
|
+
? { args: cloneMatcherValue(step.args) }
|
|
119
|
+
: {}),
|
|
120
|
+
...(step.result !== undefined
|
|
121
|
+
? { result: cloneMatcherValue(step.result) }
|
|
122
|
+
: {})
|
|
123
|
+
}
|
|
124
|
+
: {
|
|
125
|
+
...(step.payload !== undefined
|
|
126
|
+
? { payload: cloneMatcherValue(step.payload) }
|
|
127
|
+
: {})
|
|
128
|
+
});
|
|
129
|
+
const normalizedProjection = normalizeValue({
|
|
130
|
+
...(scenario.expect.output !== undefined
|
|
131
|
+
? { output: cloneMatcherValue(scenario.expect.output) }
|
|
132
|
+
: {}),
|
|
133
|
+
...(scenario.expect.error !== undefined
|
|
134
|
+
? {
|
|
135
|
+
error: cloneMatcherValue(scenario.expect.error)
|
|
136
|
+
}
|
|
137
|
+
: {}),
|
|
138
|
+
...(scenario.expect.stateAfter !== undefined
|
|
139
|
+
? { stateAfter: cloneMatcherValue(scenario.expect.stateAfter) }
|
|
140
|
+
: {}),
|
|
141
|
+
...(projectedCalls !== undefined ? { calls: projectedCalls } : {})
|
|
142
|
+
}, config);
|
|
143
|
+
return {
|
|
144
|
+
...scenario,
|
|
145
|
+
expect: {
|
|
146
|
+
...scenario.expect,
|
|
147
|
+
...(scenario.expect.output !== undefined &&
|
|
148
|
+
normalizedProjection.output !== undefined
|
|
149
|
+
? { output: normalizedProjection.output }
|
|
150
|
+
: {}),
|
|
151
|
+
...(scenario.expect.error !== undefined &&
|
|
152
|
+
normalizedProjection.error !== undefined
|
|
153
|
+
? {
|
|
154
|
+
error: normalizedProjection.error
|
|
155
|
+
}
|
|
156
|
+
: {}),
|
|
157
|
+
...(scenario.expect.stateAfter !== undefined &&
|
|
158
|
+
normalizedProjection.stateAfter !== undefined
|
|
159
|
+
? { stateAfter: normalizedProjection.stateAfter }
|
|
160
|
+
: {}),
|
|
161
|
+
...(scenario.expect.sequence !== undefined
|
|
162
|
+
? {
|
|
163
|
+
sequence: {
|
|
164
|
+
...scenario.expect.sequence,
|
|
165
|
+
steps: scenario.expect.sequence.steps.map((step, index) => step.kind === "effect"
|
|
166
|
+
? {
|
|
167
|
+
...step,
|
|
168
|
+
...(step.args !== undefined &&
|
|
169
|
+
normalizedProjection.calls?.[index]?.args !==
|
|
170
|
+
undefined
|
|
171
|
+
? {
|
|
172
|
+
args: normalizedProjection.calls[index]?.args
|
|
173
|
+
}
|
|
174
|
+
: {}),
|
|
175
|
+
...(step.result !== undefined &&
|
|
176
|
+
normalizedProjection.calls?.[index]?.result !==
|
|
177
|
+
undefined
|
|
178
|
+
? {
|
|
179
|
+
result: normalizedProjection.calls[index]?.result
|
|
180
|
+
}
|
|
181
|
+
: {})
|
|
182
|
+
}
|
|
183
|
+
: {
|
|
184
|
+
...step,
|
|
185
|
+
...(step.payload !== undefined &&
|
|
186
|
+
normalizedProjection.calls?.[index]?.payload !==
|
|
187
|
+
undefined
|
|
188
|
+
? {
|
|
189
|
+
payload: normalizedProjection.calls[index]?.payload
|
|
190
|
+
}
|
|
191
|
+
: {})
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
: {})
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
})
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function resolveMatchOptions(fileDefaults, scenarioOptions) {
|
|
202
|
+
return {
|
|
203
|
+
strictObjects: scenarioOptions?.strictObjects ?? fileDefaults?.strictObjects ?? true,
|
|
204
|
+
strictArrays: scenarioOptions?.strictArrays ?? fileDefaults?.strictArrays ?? true
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function countOccurredCalls(calls) {
|
|
208
|
+
const counts = {};
|
|
209
|
+
for (const call of calls) {
|
|
210
|
+
const key = call.kind === "effect" ? `effect:${call.name}` : `emit:${call.event}`;
|
|
211
|
+
counts[key] = (counts[key] ?? 0) + 1;
|
|
212
|
+
}
|
|
213
|
+
return counts;
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=trace.js.map
|