@pactflow/openapi-pact-comparator 1.15.0 → 2.0.1
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 +28098 -29103
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +3796 -3199
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3796 -3199
- package/dist/index.mjs.map +1 -1
- package/dist/src/cli/runner.d.ts +11 -2
- package/dist/src/compare/asyncapi/index.d.ts +5 -0
- package/dist/src/compare/asyncapi/matchMessages.d.ts +33 -0
- package/dist/src/compare/asyncapi/messageHeaders.d.ts +9 -0
- package/dist/src/compare/asyncapi/messagePayload.d.ts +10 -0
- package/dist/src/compare/asyncapi/syncMessage.d.ts +5 -0
- package/dist/src/compare/index.d.ts +6 -1
- package/dist/src/compare/oas/index.d.ts +6 -0
- package/dist/src/compare/{requestBody.d.ts → oas/requestBody.d.ts} +2 -2
- package/dist/src/compare/{requestHeader.d.ts → oas/requestHeader.d.ts} +2 -2
- package/dist/src/compare/{requestPath.d.ts → oas/requestPath.d.ts} +2 -2
- package/dist/src/compare/{requestQuery.d.ts → oas/requestQuery.d.ts} +2 -2
- package/dist/src/compare/{requestSecurity.d.ts → oas/requestSecurity.d.ts} +2 -2
- package/dist/src/compare/{responseBody.d.ts → oas/responseBody.d.ts} +2 -2
- package/dist/src/compare/{responseHeader.d.ts → oas/responseHeader.d.ts} +2 -2
- package/dist/src/compare/oas/setup.d.ts +4 -0
- package/dist/src/compare/setup.d.ts +1 -5
- package/dist/src/documents/asyncapi.d.ts +44 -0
- package/dist/src/documents/pact.d.ts +58 -40
- package/dist/src/index.d.ts +2 -1
- package/dist/src/results/index.d.ts +10 -6
- package/dist/src/transform/flattenAllOf.d.ts +1 -1
- package/dist/src/transform/index.d.ts +1 -1
- package/dist/src/transform/minimumSchema.d.ts +1 -1
- package/dist/src/transform/responseSchema.d.ts +2 -2
- package/dist/src/utils/interaction.d.ts +2 -2
- package/dist/src/utils/quirks.d.ts +1 -1
- package/dist/src/utils/schema.d.ts +5 -1
- package/dist/src/utils/validation.d.ts +2 -1
- package/package.json +16 -11
- /package/dist/src/compare/{utils → oas/utils}/content.d.ts +0 -0
- /package/dist/src/compare/{utils → oas/utils}/parameters.d.ts +0 -0
- /package/dist/src/compare/{utils → oas/utils}/parse.d.ts +0 -0
- /package/dist/src/compare/{utils → oas/utils}/statusCodes.d.ts +0 -0
package/dist/src/cli/runner.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { OpenAPIV2, OpenAPIV3 } from "openapi-types";
|
|
2
|
+
import type { AsyncAPIDocument } from "../documents/asyncapi";
|
|
2
3
|
import { type Result } from "../index";
|
|
3
4
|
type OASDocument = OpenAPIV2.Document | OpenAPIV3.Document;
|
|
5
|
+
export interface SpecPaths {
|
|
6
|
+
oasPath?: string;
|
|
7
|
+
asyncapiPath?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ComparatorDocs {
|
|
10
|
+
oas?: OASDocument;
|
|
11
|
+
asyncapi?: AsyncAPIDocument;
|
|
12
|
+
}
|
|
4
13
|
export interface ComparatorLike {
|
|
5
14
|
compare(pact: unknown): AsyncGenerator<Result>;
|
|
6
15
|
}
|
|
@@ -8,7 +17,7 @@ export interface RunnerDependencies {
|
|
|
8
17
|
readFile: (path: string) => Promise<string>;
|
|
9
18
|
fetch: (url: string) => Promise<Response>;
|
|
10
19
|
output: (message: string) => void;
|
|
11
|
-
createComparator: (
|
|
20
|
+
createComparator: (docs: ComparatorDocs) => ComparatorLike;
|
|
12
21
|
}
|
|
13
22
|
export declare class Runner {
|
|
14
23
|
private deps;
|
|
@@ -17,6 +26,6 @@ export declare class Runner {
|
|
|
17
26
|
private readContent;
|
|
18
27
|
private parseContent;
|
|
19
28
|
private readAndParse;
|
|
20
|
-
run(
|
|
29
|
+
run(specPaths: SpecPaths, pactPaths: string[]): Promise<number>;
|
|
21
30
|
}
|
|
22
31
|
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type Ajv from "ajv/dist/2019";
|
|
2
|
+
import type { AsyncAPIDocument, ResolvedMessage } from "#documents/asyncapi";
|
|
3
|
+
import type { AsyncInteraction } from "#documents/pact";
|
|
4
|
+
import type { Result } from "#results/index";
|
|
5
|
+
export declare function compareAsyncInteraction(ajv: Ajv, asyncapi: AsyncAPIDocument | undefined, cache: Map<string, ResolvedMessage>, interaction: AsyncInteraction, index: number): Iterable<Result>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type Ajv from "ajv/dist/2019";
|
|
2
|
+
import type { AsyncAPIDocument, ResolvedMessage } from "#documents/asyncapi";
|
|
3
|
+
import type { Result } from "#results/index";
|
|
4
|
+
type InteractionContext = {
|
|
5
|
+
description?: string;
|
|
6
|
+
providerState?: string;
|
|
7
|
+
asyncapiReferences?: {
|
|
8
|
+
operationId: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function checkAsyncapiPreamble(asyncapi: AsyncAPIDocument | undefined, interaction: InteractionContext, index: number, interactionKind: string): {
|
|
12
|
+
ok: true;
|
|
13
|
+
asyncapi: AsyncAPIDocument;
|
|
14
|
+
operationId: string;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
result: Result;
|
|
18
|
+
};
|
|
19
|
+
type MessageContent = {
|
|
20
|
+
payload: unknown;
|
|
21
|
+
contentType?: string;
|
|
22
|
+
metadata?: Record<string, string>;
|
|
23
|
+
};
|
|
24
|
+
type MessageLocations = {
|
|
25
|
+
payload: string;
|
|
26
|
+
headers: string;
|
|
27
|
+
spec: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function tryMatchAllMessages(ajv: Ajv, asyncapi: AsyncAPIDocument, candidates: Iterable<ResolvedMessage>, content: MessageContent, interactionContext: {
|
|
30
|
+
description?: string;
|
|
31
|
+
providerState?: string;
|
|
32
|
+
}, locations: MessageLocations, direction: "request" | "response", noMatchMockDetails: NonNullable<Result["mockDetails"]>): Generator<Result>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type Ajv from "ajv/dist/2019";
|
|
2
|
+
import type { Message } from "#documents/asyncapi";
|
|
3
|
+
import type { Result } from "#results/index";
|
|
4
|
+
export declare function compareMessageHeaders(ajv: Ajv, message: Message, content: {
|
|
5
|
+
metadata?: Record<string, string>;
|
|
6
|
+
}, interactionContext: {
|
|
7
|
+
description?: string;
|
|
8
|
+
providerState?: string;
|
|
9
|
+
}, metadataLocation: string, messagePath: string, direction: "request" | "response"): Iterable<Result>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type Ajv from "ajv/dist/2019";
|
|
2
|
+
import type { Message } from "#documents/asyncapi";
|
|
3
|
+
import type { Result } from "#results/index";
|
|
4
|
+
export declare function compareMessagePayload(ajv: Ajv, message: Message, content: {
|
|
5
|
+
payload: unknown;
|
|
6
|
+
contentType?: string;
|
|
7
|
+
}, interactionContext: {
|
|
8
|
+
description?: string;
|
|
9
|
+
providerState?: string;
|
|
10
|
+
}, contentLocation: string, messagePath: string, direction: "request" | "response"): Iterable<Result>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type Ajv from "ajv/dist/2019";
|
|
2
|
+
import type { AsyncAPIDocument, ResolvedMessage } from "#documents/asyncapi";
|
|
3
|
+
import type { SyncInteraction } from "#documents/pact";
|
|
4
|
+
import type { Result } from "#results/index";
|
|
5
|
+
export declare function compareSyncInteraction(ajv: Ajv, asyncapi: AsyncAPIDocument | undefined, cache: Map<string, ResolvedMessage>, interaction: SyncInteraction, index: number): Iterable<Result>;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { OpenAPIV2, OpenAPIV3 } from "openapi-types";
|
|
2
|
+
import type { AsyncAPIDocument } from "#documents/asyncapi";
|
|
2
3
|
import type { Pact } from "#documents/pact";
|
|
3
4
|
import type { Result } from "#results/index";
|
|
5
|
+
export interface ComparatorOptions {
|
|
6
|
+
oas?: OpenAPIV2.Document | OpenAPIV3.Document;
|
|
7
|
+
asyncapi?: AsyncAPIDocument;
|
|
8
|
+
}
|
|
4
9
|
export declare class Comparator {
|
|
5
10
|
#private;
|
|
6
|
-
constructor(
|
|
11
|
+
constructor(options?: ComparatorOptions);
|
|
7
12
|
compare(pact: Pact): AsyncGenerator<Result>;
|
|
8
13
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type Ajv from "ajv/dist/2019";
|
|
2
|
+
import type Router from "find-my-way";
|
|
3
|
+
import type { HttpInteraction } from "#documents/pact";
|
|
4
|
+
import type { Result } from "#results/index";
|
|
5
|
+
import type { Config } from "#utils/config";
|
|
6
|
+
export declare function compareHttpInteraction(ajvCoerce: Ajv, ajvNocoerce: Ajv, router: Router.Instance<Router.HTTPVersion.V1> | undefined, interaction: HttpInteraction, index: number, config: Config): Iterable<Result>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Ajv from "ajv/dist/2019";
|
|
2
2
|
import type Router from "find-my-way";
|
|
3
|
-
import type {
|
|
3
|
+
import type { HttpInteraction } from "#documents/pact";
|
|
4
4
|
import type { Result } from "#results/index";
|
|
5
5
|
import type { Config } from "#utils/config";
|
|
6
|
-
export declare function compareReqBody(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction:
|
|
6
|
+
export declare function compareReqBody(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction: HttpInteraction, index: number, config: Config): Iterable<Result>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Ajv from "ajv/dist/2019";
|
|
2
2
|
import type Router from "find-my-way";
|
|
3
|
-
import type {
|
|
3
|
+
import type { HttpInteraction } from "#documents/pact";
|
|
4
4
|
import type { Result } from "#results/index";
|
|
5
5
|
import type { Config } from "#utils/config";
|
|
6
|
-
export declare function compareReqHeader(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction:
|
|
6
|
+
export declare function compareReqHeader(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction: HttpInteraction, index: number, config: Config): Iterable<Result>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Ajv from "ajv/dist/2019";
|
|
2
2
|
import type Router from "find-my-way";
|
|
3
|
-
import type {
|
|
3
|
+
import type { HttpInteraction } from "#documents/pact";
|
|
4
4
|
import type { Result } from "#results/index";
|
|
5
5
|
import type { Config } from "#utils/config";
|
|
6
|
-
export declare function compareReqPath(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction:
|
|
6
|
+
export declare function compareReqPath(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction: HttpInteraction, index: number, config: Config): Iterable<Result>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Ajv from "ajv/dist/2019";
|
|
2
2
|
import type Router from "find-my-way";
|
|
3
|
+
import type { HttpInteraction } from "#documents/pact";
|
|
3
4
|
import type { Result } from "#results/index";
|
|
4
|
-
import type { Interaction } from "#documents/pact";
|
|
5
5
|
import type { Config } from "#utils/config";
|
|
6
|
-
export declare function compareReqQuery(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction:
|
|
6
|
+
export declare function compareReqQuery(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction: HttpInteraction, index: number, config: Config): Iterable<Result>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Ajv from "ajv/dist/2019";
|
|
2
2
|
import type Router from "find-my-way";
|
|
3
|
-
import type {
|
|
3
|
+
import type { HttpInteraction } from "#documents/pact";
|
|
4
4
|
import type { Result } from "#results/index";
|
|
5
5
|
import type { Config } from "#utils/config";
|
|
6
|
-
export declare function compareReqSecurity(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction:
|
|
6
|
+
export declare function compareReqSecurity(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction: HttpInteraction, index: number, config: Config): Iterable<Result>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Ajv from "ajv/dist/2019";
|
|
2
2
|
import type Router from "find-my-way";
|
|
3
|
-
import type {
|
|
3
|
+
import type { HttpInteraction } from "#documents/pact";
|
|
4
4
|
import type { Result } from "#results/index";
|
|
5
5
|
import type { Config } from "#utils/config";
|
|
6
|
-
export declare function compareResBody(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction:
|
|
6
|
+
export declare function compareResBody(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction: HttpInteraction, index: number, config: Config): Iterable<Result>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Ajv from "ajv/dist/2019";
|
|
2
2
|
import type Router from "find-my-way";
|
|
3
|
-
import type {
|
|
3
|
+
import type { HttpInteraction } from "#documents/pact";
|
|
4
4
|
import type { Result } from "#results/index";
|
|
5
5
|
import type { Config } from "#utils/config";
|
|
6
|
-
export declare function compareResHeader(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction:
|
|
6
|
+
export declare function compareResHeader(ajv: Ajv, route: Router.FindResult<Router.HTTPVersion.V1>, interaction: HttpInteraction, index: number, _config: Config): Iterable<Result>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import Router from "find-my-way";
|
|
2
|
+
import type { OpenAPIV2, OpenAPIV3 } from "openapi-types";
|
|
3
|
+
import type { Config } from "#utils/config";
|
|
4
|
+
export declare function setupRouter(oas: OpenAPIV2.Document | OpenAPIV3.Document, config: Config): Router.Instance<Router.HTTPVersion.V1>;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Ajv, { Options } from "ajv/dist/2019.js";
|
|
3
|
-
import Router from "find-my-way";
|
|
4
|
-
import type { Config } from "#utils/config";
|
|
1
|
+
import Ajv, { type Options } from "ajv/dist/2019.js";
|
|
5
2
|
export declare function setupAjv(options: Options): Ajv;
|
|
6
|
-
export declare function setupRouter(oas: OpenAPIV2.Document | OpenAPIV3.Document, config: Config): Router.Instance<Router.HTTPVersion.V1>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface AsyncAPIDocument {
|
|
2
|
+
asyncapi: string;
|
|
3
|
+
info: {
|
|
4
|
+
title: string;
|
|
5
|
+
version: string;
|
|
6
|
+
};
|
|
7
|
+
channels?: Record<string, Channel>;
|
|
8
|
+
operations?: Record<string, Operation>;
|
|
9
|
+
components?: {
|
|
10
|
+
messages?: Record<string, Message>;
|
|
11
|
+
schemas?: Record<string, object>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface Channel {
|
|
15
|
+
messages?: Record<string, Message | Ref>;
|
|
16
|
+
}
|
|
17
|
+
export interface OperationReply {
|
|
18
|
+
channel?: Ref;
|
|
19
|
+
messages?: Array<Ref | Message>;
|
|
20
|
+
}
|
|
21
|
+
export interface Operation {
|
|
22
|
+
action: "send" | "receive";
|
|
23
|
+
channel: Ref;
|
|
24
|
+
messages?: Array<Ref | Message>;
|
|
25
|
+
reply?: OperationReply;
|
|
26
|
+
}
|
|
27
|
+
export interface Message {
|
|
28
|
+
payload?: object;
|
|
29
|
+
headers?: object;
|
|
30
|
+
contentType?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface Ref {
|
|
33
|
+
$ref: string;
|
|
34
|
+
}
|
|
35
|
+
export declare class ParserError extends Error {
|
|
36
|
+
constructor();
|
|
37
|
+
}
|
|
38
|
+
export declare const parse: (doc: AsyncAPIDocument) => void;
|
|
39
|
+
export interface ResolvedMessage {
|
|
40
|
+
message: Message;
|
|
41
|
+
path: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function iterateMessages(doc: AsyncAPIDocument, operationId: string, cache: Map<string, ResolvedMessage>): Generator<ResolvedMessage>;
|
|
44
|
+
export declare function iterateReplyMessages(doc: AsyncAPIDocument, operationId: string, cache: Map<string, ResolvedMessage>): Generator<ResolvedMessage>;
|
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
import { Static } from "@sinclair/typebox";
|
|
2
|
-
import { ErrorObject } from "ajv";
|
|
3
|
-
export declare const Interaction: import("@sinclair/typebox").TObject<{
|
|
4
|
-
_skip: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
5
|
-
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
6
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
|
-
providerState: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
8
|
-
request: import("@sinclair/typebox").TObject<{
|
|
9
|
-
body: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnknown>;
|
|
10
|
-
headers: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>]>>;
|
|
11
|
-
method: import("@sinclair/typebox").TString;
|
|
12
|
-
path: import("@sinclair/typebox").TString;
|
|
13
|
-
query: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TString, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>]>>;
|
|
14
|
-
}>;
|
|
15
|
-
response: import("@sinclair/typebox").TObject<{
|
|
16
|
-
body: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnknown>;
|
|
17
|
-
headers: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>]>>;
|
|
18
|
-
status: import("@sinclair/typebox").TNumber;
|
|
19
|
-
}>;
|
|
20
|
-
}>;
|
|
21
|
-
export type Interaction = Static<typeof Interaction>;
|
|
1
|
+
import { type Static } from "@sinclair/typebox";
|
|
2
|
+
import { type ErrorObject } from "ajv";
|
|
22
3
|
export declare const Pact: import("@sinclair/typebox").TObject<{
|
|
23
4
|
metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
24
5
|
pactSpecification: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
@@ -29,27 +10,64 @@ export declare const Pact: import("@sinclair/typebox").TObject<{
|
|
|
29
10
|
version: import("@sinclair/typebox").TString;
|
|
30
11
|
}>>;
|
|
31
12
|
}>>;
|
|
32
|
-
interactions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").
|
|
33
|
-
_skip: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
34
|
-
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
35
|
-
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
36
|
-
providerState: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
37
|
-
request: import("@sinclair/typebox").TObject<{
|
|
38
|
-
body: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnknown>;
|
|
39
|
-
headers: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>]>>;
|
|
40
|
-
method: import("@sinclair/typebox").TString;
|
|
41
|
-
path: import("@sinclair/typebox").TString;
|
|
42
|
-
query: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TString, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>]>>;
|
|
43
|
-
}>;
|
|
44
|
-
response: import("@sinclair/typebox").TObject<{
|
|
45
|
-
body: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnknown>;
|
|
46
|
-
headers: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>]>>;
|
|
47
|
-
status: import("@sinclair/typebox").TNumber;
|
|
48
|
-
}>;
|
|
49
|
-
}>>;
|
|
13
|
+
interactions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>;
|
|
50
14
|
}>;
|
|
51
15
|
export type Pact = Static<typeof Pact>;
|
|
52
|
-
export
|
|
16
|
+
export interface HttpInteraction {
|
|
17
|
+
_kind: "http";
|
|
18
|
+
description?: string;
|
|
19
|
+
providerState?: string;
|
|
20
|
+
request: {
|
|
21
|
+
body?: unknown;
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
method: string;
|
|
24
|
+
path: string;
|
|
25
|
+
query?: string | Record<string, string>;
|
|
26
|
+
};
|
|
27
|
+
response: {
|
|
28
|
+
body?: unknown;
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
status: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface AsyncInteraction {
|
|
34
|
+
_kind: "async";
|
|
35
|
+
description?: string;
|
|
36
|
+
providerState?: string;
|
|
37
|
+
asyncapiReferences?: {
|
|
38
|
+
operationId: string;
|
|
39
|
+
};
|
|
40
|
+
payload: unknown;
|
|
41
|
+
contentType?: string;
|
|
42
|
+
metadata?: Record<string, string>;
|
|
43
|
+
}
|
|
44
|
+
export interface SyncInteraction {
|
|
45
|
+
_kind: "sync";
|
|
46
|
+
description?: string;
|
|
47
|
+
providerState?: string;
|
|
48
|
+
asyncapiReferences?: {
|
|
49
|
+
operationId: string;
|
|
50
|
+
};
|
|
51
|
+
request: {
|
|
52
|
+
payload: unknown;
|
|
53
|
+
contentType?: string;
|
|
54
|
+
metadata?: Record<string, string>;
|
|
55
|
+
};
|
|
56
|
+
responses: Array<{
|
|
57
|
+
payload: unknown;
|
|
58
|
+
contentType?: string;
|
|
59
|
+
metadata?: Record<string, string>;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
export interface SkippedInteraction {
|
|
63
|
+
_kind: "skip";
|
|
64
|
+
}
|
|
65
|
+
export type Interaction = HttpInteraction | AsyncInteraction | SyncInteraction | SkippedInteraction;
|
|
66
|
+
export interface ParsedPact {
|
|
67
|
+
metadata?: Pact["metadata"];
|
|
68
|
+
interactions: Interaction[];
|
|
69
|
+
}
|
|
70
|
+
export declare const parse: (pact: Pact) => ParsedPact;
|
|
53
71
|
export declare class ParserError extends Error {
|
|
54
72
|
errors: ErrorObject[];
|
|
55
73
|
constructor(errors: ErrorObject[]);
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ErrorObject } from "ajv";
|
|
2
|
-
|
|
3
|
-
type ErrorCode = "request.accept.incompatible" | "request.authorization.missing" | "request.body.incompatible" | "request.content-type.incompatible" | "request.header.incompatible" | "request.path-or-method.unknown" | "request.query.incompatible" | "response.body.incompatible" | "response.body.unknown" | "response.content-type.incompatible" | "response.header.incompatible" | "response.header.unknown" | "response.status.unknown";
|
|
4
|
-
type WarningCode = "pact-broker.no-pacts-found" | "request.accept.unknown" | "request.body.unknown" | "request.content-type.missing" | "request.content-type.unknown" | "request.header.unknown" | "request.query.unknown" | "response.content-type.unknown" | "response.header.undefined" | "response.status.default";
|
|
2
|
+
type InfoCode = "message.matched";
|
|
3
|
+
type ErrorCode = "message.headers.incompatible" | "message.no.match" | "message.operation.unknown" | "message.payload.incompatible" | "message.references.missing" | "message.reply.missing" | "message.spec.missing" | "request.accept.incompatible" | "request.authorization.missing" | "request.body.incompatible" | "request.content-type.incompatible" | "request.header.incompatible" | "request.path-or-method.unknown" | "request.query.incompatible" | "request.spec.missing" | "response.body.incompatible" | "response.body.unknown" | "response.content-type.incompatible" | "response.header.incompatible" | "response.header.unknown" | "response.status.unknown";
|
|
4
|
+
type WarningCode = "message.payload.unknown" | "message.response.missing" | "pact-broker.no-pacts-found" | "request.accept.unknown" | "request.body.unknown" | "request.content-type.missing" | "request.content-type.unknown" | "request.header.unknown" | "request.query.unknown" | "response.content-type.unknown" | "response.header.undefined" | "response.status.default";
|
|
5
5
|
export interface Result {
|
|
6
|
-
code: ErrorCode | WarningCode;
|
|
6
|
+
code: ErrorCode | WarningCode | InfoCode;
|
|
7
7
|
message: string;
|
|
8
8
|
mockDetails?: {
|
|
9
9
|
interactionDescription?: string | null;
|
|
@@ -17,12 +17,16 @@ export interface Result {
|
|
|
17
17
|
pathName?: string | null;
|
|
18
18
|
value: unknown;
|
|
19
19
|
};
|
|
20
|
-
type: "error" | "warning";
|
|
20
|
+
type: "error" | "warning" | "info";
|
|
21
|
+
causes?: Result[];
|
|
21
22
|
}
|
|
22
23
|
export declare const formatMessage: (error: ErrorObject) => string | undefined;
|
|
23
24
|
export declare const formatInstancePath: (error: ErrorObject) => string;
|
|
24
25
|
export declare const formatSchemaPath: (error: ErrorObject) => string;
|
|
25
|
-
export declare const baseMockDetails: (interaction:
|
|
26
|
+
export declare const baseMockDetails: (interaction: {
|
|
27
|
+
description?: string;
|
|
28
|
+
providerState?: string;
|
|
29
|
+
}) => {
|
|
26
30
|
interactionDescription: string | undefined;
|
|
27
31
|
interactionState: string;
|
|
28
32
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SchemaObject } from "ajv";
|
|
1
|
+
import type { SchemaObject } from "ajv";
|
|
2
2
|
export declare function flattenAllOf(s: SchemaObject, refs: string[]): SchemaObject;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SchemaObject } from "ajv";
|
|
2
|
-
export declare const
|
|
1
|
+
import type { SchemaObject } from "ajv";
|
|
2
|
+
export declare const transformReceivedSchema: (schema: SchemaObject, quirks?: boolean) => SchemaObject;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const isValidRequest: (interaction:
|
|
1
|
+
import type { HttpInteraction } from "../documents/pact";
|
|
2
|
+
export declare const isValidRequest: (interaction: HttpInteraction) => boolean;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { OpenAPIV3 } from "openapi-types";
|
|
2
1
|
import type { SchemaObject } from "ajv";
|
|
2
|
+
import type { OpenAPIV3 } from "openapi-types";
|
|
3
|
+
export declare const resolveSchemaRefs: (schema: unknown, doc: object, visited?: Set<string>) => unknown;
|
|
3
4
|
export declare const splitPath: (path: string) => string | string[];
|
|
4
5
|
export declare const dereferenceOas: (schema: SchemaObject, oas: OpenAPIV3.Document) => any;
|
|
6
|
+
export declare const dereferenceDoc: (schema: {
|
|
7
|
+
$ref?: string;
|
|
8
|
+
}, doc: object) => unknown;
|
|
5
9
|
export declare const traverse: (schema: SchemaObject, visitor: (schema: SchemaObject) => void) => void;
|
|
6
10
|
export declare const traverseWithDereferencing: (schema: SchemaObject, visitor: (schema: SchemaObject) => void) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pactflow/openapi-pact-comparator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "An OpenAPI Specification and Pact Comparison library",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"changeset:version": "changeset version",
|
|
26
26
|
"lint": "eslint --max-warnings=0",
|
|
27
27
|
"patch-package": "patch-package",
|
|
28
|
+
"postinstall": "patch-package",
|
|
28
29
|
"prepare": "npm run build",
|
|
29
30
|
"prettier": "prettier --check .",
|
|
30
31
|
"prettier:fix": "prettier --cache --list-different --write .",
|
|
@@ -43,39 +44,43 @@
|
|
|
43
44
|
"email": "voon.wong@smartbear.com"
|
|
44
45
|
},
|
|
45
46
|
"license": "MIT",
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=22"
|
|
49
|
+
},
|
|
46
50
|
"type": "module",
|
|
47
51
|
"devDependencies": {
|
|
48
52
|
"@changesets/cli": "2.31.0",
|
|
49
53
|
"@eslint/js": "10.0.1",
|
|
50
|
-
"@rollup/plugin-commonjs": "29.0.
|
|
54
|
+
"@rollup/plugin-commonjs": "29.0.3",
|
|
51
55
|
"@rollup/plugin-json": "6.1.0",
|
|
52
56
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
53
57
|
"@rollup/plugin-typescript": "12.3.0",
|
|
54
58
|
"@sinclair/typebox": "0.34.49",
|
|
59
|
+
"@tsconfig/node22": "22.0.5",
|
|
55
60
|
"@types/js-yaml": "4.0.9",
|
|
56
61
|
"@types/lodash-es": "4.17.12",
|
|
57
62
|
"@types/node": "24.12.4",
|
|
58
63
|
"@types/qs": "6.15.1",
|
|
59
|
-
"@vitest/coverage-v8": "4.1.
|
|
64
|
+
"@vitest/coverage-v8": "4.1.8",
|
|
60
65
|
"ajv": "8.20.0",
|
|
61
66
|
"ajv-formats": "3.0.1",
|
|
62
|
-
"commander": "
|
|
63
|
-
"eslint": "10.
|
|
67
|
+
"commander": "15.0.0",
|
|
68
|
+
"eslint": "10.4.1",
|
|
64
69
|
"eslint-config-prettier": "10.1.8",
|
|
65
70
|
"find-my-way": "9.6.0",
|
|
66
|
-
"js-yaml": "4.
|
|
71
|
+
"js-yaml": "4.2.0",
|
|
67
72
|
"lodash-es": "4.18.1",
|
|
68
73
|
"openapi-types": "12.1.3",
|
|
69
74
|
"parse-multipart-data": "1.5.0",
|
|
70
75
|
"patch-package": "8.0.1",
|
|
71
76
|
"prettier": "3.8.3",
|
|
72
|
-
"qs": "6.15.
|
|
73
|
-
"rollup": "4.
|
|
77
|
+
"qs": "6.15.2",
|
|
78
|
+
"rollup": "4.61.0",
|
|
74
79
|
"tslib": "2.8.1",
|
|
75
|
-
"tsx": "4.22.
|
|
80
|
+
"tsx": "4.22.4",
|
|
76
81
|
"typescript": "6.0.3",
|
|
77
|
-
"typescript-eslint": "8.
|
|
78
|
-
"vitest": "4.1.
|
|
82
|
+
"typescript-eslint": "8.60.1",
|
|
83
|
+
"vitest": "4.1.8"
|
|
79
84
|
},
|
|
80
85
|
"imports": {
|
|
81
86
|
"#compare/*": "./src/compare/*.ts",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|