@pactflow/openapi-pact-comparator 1.7.0 → 1.8.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/dist/cli.cjs +28 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +26 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +26 -7
- package/dist/index.mjs.map +1 -1
- package/dist/src/documents/pact.d.ts +5 -2
- package/dist/src/results/index.d.ts +1 -1
- package/package.json +15 -15
package/dist/cli.cjs
CHANGED
|
@@ -3249,7 +3249,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3249
3249
|
|
|
3250
3250
|
const negativeNumberArg = (arg) => {
|
|
3251
3251
|
// return false if not a negative number
|
|
3252
|
-
if (
|
|
3252
|
+
if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg)) return false;
|
|
3253
3253
|
// negative number is ok unless digit used as an option in command hierarchy
|
|
3254
3254
|
return !this._getCommandAndAncestors().some((cmd) =>
|
|
3255
3255
|
cmd.options
|
|
@@ -27592,6 +27592,7 @@ var Ajv$1 = /*@__PURE__*/getDefaultExportFromCjs(ajvExports);
|
|
|
27592
27592
|
// a full schema can be found at https://github.com/pactflow/pact-schemas
|
|
27593
27593
|
// but we don't use that here, because we try to be permissive with input
|
|
27594
27594
|
const Interaction = Type.Object({
|
|
27595
|
+
_skip: Type.Optional(Type.Boolean()),
|
|
27595
27596
|
type: Type.Optional(Type.String()),
|
|
27596
27597
|
description: Type.Optional(Type.String()),
|
|
27597
27598
|
providerState: Type.Optional(Type.String()),
|
|
@@ -27631,7 +27632,8 @@ const Pact = Type.Object({
|
|
|
27631
27632
|
version: Type.String(),
|
|
27632
27633
|
})),
|
|
27633
27634
|
})),
|
|
27634
|
-
interactions: Type.Array(Interaction),
|
|
27635
|
+
interactions: Type.Optional(Type.Array(Interaction)),
|
|
27636
|
+
messages: Type.Optional(Type.Array(Type.Unknown())),
|
|
27635
27637
|
});
|
|
27636
27638
|
const supportedInteractions = (i) => !i.type || i.type.toLowerCase() === "synchronous/http";
|
|
27637
27639
|
const parseAsPactV4Body = (body) => {
|
|
@@ -27705,10 +27707,11 @@ const interactionV4 = (i) => ({
|
|
|
27705
27707
|
const ajv = new Ajv$1();
|
|
27706
27708
|
const validate = ajv.compile(Pact);
|
|
27707
27709
|
const parse = (pact) => {
|
|
27708
|
-
const { metadata, interactions } = pact;
|
|
27710
|
+
const { metadata, interactions, messages } = pact;
|
|
27709
27711
|
const isValid = validate({
|
|
27710
27712
|
metadata,
|
|
27711
|
-
interactions: interactions
|
|
27713
|
+
interactions: interactions?.filter(supportedInteractions),
|
|
27714
|
+
messages,
|
|
27712
27715
|
});
|
|
27713
27716
|
if (!isValid) {
|
|
27714
27717
|
throw new ParserError(validate.errors);
|
|
@@ -27720,9 +27723,10 @@ const parse = (pact) => {
|
|
|
27720
27723
|
const interactionParser = version >= 4 ? interactionV4 : version >= 3 ? interactionV3 : interactionV1;
|
|
27721
27724
|
return {
|
|
27722
27725
|
metadata,
|
|
27723
|
-
interactions: interactions
|
|
27724
|
-
|
|
27725
|
-
|
|
27726
|
+
interactions: interactions?.map((i) => supportedInteractions(i)
|
|
27727
|
+
? interactionParser(i)
|
|
27728
|
+
: { _skip: true }),
|
|
27729
|
+
messages,
|
|
27726
27730
|
};
|
|
27727
27731
|
};
|
|
27728
27732
|
class ParserError extends Error {
|
|
@@ -32503,7 +32507,17 @@ class Comparator {
|
|
|
32503
32507
|
this.#router = setupRouter(this.#oas, this.#config);
|
|
32504
32508
|
}
|
|
32505
32509
|
const parsedPact = parse(pact);
|
|
32506
|
-
|
|
32510
|
+
const parsedInteractions = parsedPact.interactions || [];
|
|
32511
|
+
const UNSUPPORTED_INTERACTION_WARNING = {
|
|
32512
|
+
code: "interaction.type.unsupported",
|
|
32513
|
+
message: `Non-HTTP Interaction is not supported, OPC can only compare HTTP interactions.`,
|
|
32514
|
+
type: "warning",
|
|
32515
|
+
};
|
|
32516
|
+
for (const [index, interaction] of parsedInteractions.entries()) {
|
|
32517
|
+
if (interaction._skip) {
|
|
32518
|
+
yield UNSUPPORTED_INTERACTION_WARNING;
|
|
32519
|
+
continue;
|
|
32520
|
+
}
|
|
32507
32521
|
const { method, path, query } = interaction.request;
|
|
32508
32522
|
let pathWithLeadingSlash = path.startsWith("/") ? path : `/${path}`;
|
|
32509
32523
|
if (this.#config.get("no-percent-encoding")) {
|
|
@@ -32549,10 +32563,15 @@ class Comparator {
|
|
|
32549
32563
|
yield* compareResHeader(this.#ajvCoerce, route, interaction, index, this.#config);
|
|
32550
32564
|
yield* compareResBody(this.#ajvNocoerce, route, interaction, index, this.#config);
|
|
32551
32565
|
}
|
|
32566
|
+
if (parsedPact.messages) {
|
|
32567
|
+
for (const [_message] of parsedPact.messages.entries()) {
|
|
32568
|
+
yield UNSUPPORTED_INTERACTION_WARNING;
|
|
32569
|
+
}
|
|
32570
|
+
}
|
|
32552
32571
|
}
|
|
32553
32572
|
}
|
|
32554
32573
|
|
|
32555
|
-
var version = "1.
|
|
32574
|
+
var version = "1.8.0";
|
|
32556
32575
|
var packageJson = {
|
|
32557
32576
|
version: version};
|
|
32558
32577
|
|