Skip to content

Commit

Permalink
chore: add .js extensions to imports
Browse files Browse the repository at this point in the history
  • Loading branch information
vwong committed Jan 30, 2025
1 parent d78a922 commit 7ae7006
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 61 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@
"dist"
],
"scripts": {
"build": "tsc --project tsconfig.json",
"dev": "tsx src/cli.ts",
"lint": "eslint --max-warnings=0",
"postinstall": "patch-package",
"prepare": "npm run build",
"prepare": "tsc --project tsconfig.json",
"prettier": "prettier --check .",
"prettier:fix": "prettier --cache --list-different --write .",
"start": "node dist/cli.mjs",
"test": "vitest",
"typecheck": "tsc --noEmit --project tsconfig.json"
},
"keywords": [],
"author": "",
"author": "Voon Siong Wong",
"license": "ISC",
"type": "module",
"dependencies": {
Expand Down
24 changes: 12 additions & 12 deletions src/compare/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import type { OpenAPIV2, OpenAPIV3 } from "openapi-types";
import Ajv from "ajv/dist/2019";
import Router, { HTTPMethod } from "find-my-way";

import type { Pact } from "../documents/pact";
import type { Result } from "../results";
import { setupAjv, setupRouter } from "./setup";
import { parse as parseOas } from "../documents/oas";
import { parse as parsePact } from "../documents/pact";
import { compareReqPath } from "./requestPath";
import { compareReqQuery } from "./requestQuery";
import { compareReqBody } from "./requestBody";
import { compareReqHeader } from "./requestHeader";
import { compareResBody } from "./responseBody";
import { compareResHeader } from "./responseHeader";
import { baseMockDetails } from "../results";
import type { Pact } from "../documents/pact.js";
import type { Result } from "../results/index.js";
import { setupAjv, setupRouter } from "./setup.js";
import { parse as parseOas } from "../documents/oas.js";
import { parse as parsePact } from "../documents/pact.js";
import { compareReqPath } from "./requestPath.js";
import { compareReqQuery } from "./requestQuery.js";
import { compareReqBody } from "./requestBody.js";
import { compareReqHeader } from "./requestHeader.js";
import { compareResBody } from "./responseBody.js";
import { compareResHeader } from "./responseHeader.js";
import { baseMockDetails } from "../results/index.js";

export class Comparator {
#ajvCoerce: Ajv;
Expand Down
13 changes: 7 additions & 6 deletions src/compare/requestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ import type { SchemaObject } from "ajv";
import type Ajv from "ajv/dist/2019";
import type { OpenAPIV2 } from "openapi-types";
import type Router from "find-my-way";
import type { Interaction } from "../documents/pact";
import type { Result } from "../results";
import { get } from "lodash-es";
import qs from "qs";

import type { Interaction } from "../documents/pact.js";
import type { Result } from "../results/index.js";
import {
baseMockDetails,
formatErrorMessage,
formatInstancePath,
formatSchemaPath,
} from "../results";
import { minimumSchema, transformRequestSchema } from "../transform";
import { findMatchingType } from "./utils/content";
import { dereferenceOas } from "./utils/schema";
} from "../results/index.js";
import { minimumSchema, transformRequestSchema } from "../transform/index.js";
import { findMatchingType } from "./utils/content.js";
import { dereferenceOas } from "./utils/schema.js";

const parseBody = (body: unknown, contentType: string) => {
if (
Expand Down
18 changes: 11 additions & 7 deletions src/compare/requestHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ import type { OpenAPIV3 } from "openapi-types";
import type { SchemaObject } from "ajv";
import type Ajv from "ajv/dist/2019";
import type Router from "find-my-way";
import type { Interaction } from "../documents/pact";
import type { Result } from "../results";
import { get } from "lodash-es";

import type { Interaction } from "../documents/pact.js";
import type { Result } from "../results/index.js";
import {
baseMockDetails,
formatErrorMessage,
formatInstancePath,
formatSchemaPath,
} from "../results";
import { minimumSchema } from "../transform";
import { findMatchingType, standardHttpRequestHeaders } from "./utils/content";
import { parseValue } from "./utils/parse";
import { dereferenceOas } from "./utils/schema";
} from "../results/index.js";
import { minimumSchema } from "../transform/index.js";
import {
findMatchingType,
standardHttpRequestHeaders,
} from "./utils/content.js";
import { parseValue } from "./utils/parse.js";
import { dereferenceOas } from "./utils/schema.js";

export function* compareReqHeader(
ajv: Ajv,
Expand Down
15 changes: 8 additions & 7 deletions src/compare/requestPath.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { SchemaObject } from "ajv";
import type Ajv from "ajv/dist/2019";
import type Router from "find-my-way";
import type { Interaction } from "../documents/pact";
import type { Result } from "../results";
import { baseMockDetails } from "../results";
import { minimumSchema } from "../transform";
import { cleanPathParameter } from "./utils/parameters";
import { parseValue } from "./utils/parse";
import { dereferenceOas } from "./utils/schema";

import type { Interaction } from "../documents/pact.js";
import type { Result } from "../results/index.js";
import { baseMockDetails } from "../results/index.js";
import { minimumSchema } from "../transform/index.js";
import { cleanPathParameter } from "./utils/parameters.js";
import { parseValue } from "./utils/parse.js";
import { dereferenceOas } from "./utils/schema.js";

export function* compareReqPath(
ajv: Ajv,
Expand Down
11 changes: 6 additions & 5 deletions src/compare/requestQuery.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import type { SchemaObject } from "ajv";
import type Ajv from "ajv/dist/2019";
import type Router from "find-my-way";
import type { Result } from "../results";
import type { Interaction } from "../documents/pact";
import { get } from "lodash-es";
import qs from "qs";

import type { Result } from "../results/index.js";
import type { Interaction } from "../documents/pact.js";
import {
baseMockDetails,
formatErrorMessage,
formatInstancePath,
formatSchemaPath,
} from "../results";
import { minimumSchema } from "../transform";
import { dereferenceOas } from "./utils/schema";
} from "../results/index.js";
import { minimumSchema } from "../transform/index.js";
import { dereferenceOas } from "./utils/schema.js";

export function* compareReqQuery(
ajv: Ajv,
Expand Down
13 changes: 7 additions & 6 deletions src/compare/responseBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import type { SchemaObject } from "ajv";
import type Ajv from "ajv/dist/2019";
import type Router from "find-my-way";
import type { OpenAPIV2, OpenAPIV3 } from "openapi-types";
import type { Interaction } from "../documents/pact";
import type { Result } from "../results";
import { get } from "lodash-es";

import type { Interaction } from "../documents/pact.js";
import type { Result } from "../results/index.js";
import {
baseMockDetails,
formatErrorMessage,
formatInstancePath,
formatSchemaPath,
} from "../results";
import { minimumSchema, transformResponseSchema } from "../transform";
import { findMatchingType } from "./utils/content";
import { dereferenceOas } from "./utils/schema";
} from "../results/index.js";
import { minimumSchema, transformResponseSchema } from "../transform/index.js";
import { findMatchingType } from "./utils/content.js";
import { dereferenceOas } from "./utils/schema.js";

const DEFAULT_CONTENT_TYPE = "application/json";

Expand Down
16 changes: 10 additions & 6 deletions src/compare/responseHeader.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import type { SchemaObject } from "ajv";
import type Ajv from "ajv/dist/2019";
import type Router from "find-my-way";
import type { Interaction } from "../documents/pact";
import type { Result } from "../results";
import { get } from "lodash-es";

import type { Interaction } from "../documents/pact.js";
import type { Result } from "../results/index.js";
import {
baseMockDetails,
formatErrorMessage,
formatInstancePath,
formatSchemaPath,
} from "../results";
import { minimumSchema } from "../transform";
import { findMatchingType, standardHttpResponseHeaders } from "./utils/content";
import { dereferenceOas } from "./utils/schema";
} from "../results/index.js";
import { minimumSchema } from "../transform/index.js";
import {
findMatchingType,
standardHttpResponseHeaders,
} from "./utils/content.js";
import { dereferenceOas } from "./utils/schema.js";

export function* compareResHeader(
ajv: Ajv,
Expand Down
4 changes: 2 additions & 2 deletions src/compare/setup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { OpenAPIV2, OpenAPIV3 } from "openapi-types";
import Ajv, { Options } from "ajv/dist/2019";
import Ajv, { Options } from "ajv/dist/2019.js";
import addFormats from "ajv-formats";
import Router, { HTTPMethod } from "find-my-way";
import { cleanPathParameter } from "./utils/parameters";
import { cleanPathParameter } from "./utils/parameters.js";

export function setupAjv(options: Options): Ajv {
const ajv = new Ajv(options);
Expand Down
2 changes: 1 addition & 1 deletion src/documents/pact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const parseAsPactV4Body = (body: unknown) => {
const flattenValues = (
values?: string | Record<string, string | string[]>,
): Record<string, string> | string | undefined => {
if (!values || typeof values === "string") return values;
if (!values || typeof values === "string") return values as string;

return Object.fromEntries(
Object.entries(values || {}).map(([key, value]) => [
Expand Down
6 changes: 3 additions & 3 deletions src/transform/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { transformRequestSchema } from "./requestSchema";
export { transformResponseSchema } from "./responseSchema";
export { minimumSchema } from "./minimumSchema";
export { transformRequestSchema } from "./requestSchema.js";
export { transformResponseSchema } from "./responseSchema.js";
export { minimumSchema } from "./minimumSchema.js";
2 changes: 1 addition & 1 deletion src/transform/minimumSchema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { OpenAPIV3 } from "openapi-types";
import { SchemaObject } from "ajv";
import { cloneDeep, get, set } from "lodash-es";
import { traverse } from "./utils";
import { traverse } from "./utils.js";

export const minimumSchema = (
originalSchema: SchemaObject,
Expand Down
2 changes: 1 addition & 1 deletion src/transform/requestSchema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SchemaObject } from "ajv";
import { each } from "lodash-es";
import { traverse } from "./utils";
import { traverse } from "./utils.js";

export const transformRequestSchema = (schema: SchemaObject): SchemaObject => {
// OpenAPI defines allOf to mean the union of all sub-schemas. JSON-Schema
Expand Down
2 changes: 1 addition & 1 deletion src/transform/responseSchema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SchemaObject } from "ajv";
import { each, get } from "lodash-es";
import { traverse } from "./utils";
import { traverse } from "./utils.js";

export const transformResponseSchema = (schema: SchemaObject): SchemaObject => {
// a provider must provide a superset of what the consumer asks for
Expand Down

0 comments on commit 7ae7006

Please sign in to comment.