Skip to content

Commit

Permalink
chore: bump deps (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas authored Feb 1, 2025
1 parent 9d05723 commit c550dce
Show file tree
Hide file tree
Showing 30 changed files with 1,523 additions and 1,319 deletions.
49 changes: 0 additions & 49 deletions .eslintrc.cjs

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 'current'
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 'current'
registry-url: https://registry.npmjs.org
Expand Down
25 changes: 25 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
eslintConfigPrettier,
eslintPluginPrettierRecommended,
{
rules: {
"@typescript-eslint/no-unsafe-declaration-merging": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-object-type": [
"error",
{
allowInterfaces: "with-single-extends",
},
],
},
},
);
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,41 @@
"author": "Kévin Dunglas",
"license": "MIT",
"devDependencies": {
"@eslint/compat": "^1.2.5",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.19.0",
"@types/inflection": "^1.13.0",
"@types/jest": "^29.0.0",
"@types/jsonld": "^1.5.0",
"@types/lodash.get": "^4.4.0",
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.0",
"eslint-config-prettier": "^8.0.0",
"@types/node": "^22.0.0",
"eslint": "^9.0.0",
"eslint-config-prettier": "^10.0.0",
"eslint-import-resolver-typescript": "^3.5.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-watch": "^8.0.0",
"globals": "^15.14.0",
"jest": "^29.0.0",
"jest-fetch-mock": "^3.0.0",
"openapi-types": "^12.0.0",
"prettier": "^2.2.0",
"prettier": "^3.0.0",
"ts-jest": "^29.0.0",
"ts-node": "^10.9.0",
"typescript": "^4.1.0"
"typescript": "^5.7.0",
"typescript-eslint": "^8.22.0"
},
"dependencies": {
"graphql": "^16.0.0",
"inflection": "^1.13.0",
"inflection": "^3.0.0",
"jsonld": "^8.3.2",
"jsonref": "^8.0.0",
"jsonref": "^9.0.0",
"lodash.get": "^4.4.0",
"tslib": "^2.0.0"
},
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"lint": "esw --color src --ext .ts",
"lint": "eslint src",
"fix": "yarn lint --fix",
"eslint-check": "eslint-config-prettier src/index.ts",
"build": "rm -rf lib/* && tsc",
Expand Down
5 changes: 4 additions & 1 deletion src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export interface ApiOptions

export interface Api extends ApiOptions {}
export class Api {
constructor(public entrypoint: string, options: ApiOptions = {}) {
constructor(
public entrypoint: string,
options: ApiOptions = {},
) {
assignSealed(this, options);
}
}
5 changes: 4 additions & 1 deletion src/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export interface FieldOptions

export interface Field extends FieldOptions {}
export class Field {
constructor(public name: string, options: FieldOptions = {}) {
constructor(
public name: string,
options: FieldOptions = {},
) {
assignSealed(this, options);
}
}
2 changes: 1 addition & 1 deletion src/Operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Operation {
constructor(
public name: string,
public type: OperationType,
options: OperationOptions = {}
options: OperationOptions = {},
) {
assignSealed(this, options);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export class Parameter {
public range: string | null,
public required: boolean,
public description: string,
public deprecated?: boolean
public deprecated?: boolean,
) {}
}
2 changes: 1 addition & 1 deletion src/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Resource {
constructor(
public name: string,
public url: string,
options: ResourceOptions = {}
options: ResourceOptions = {},
) {
assignSealed(this, options);
}
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/fetchQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const setOptions = (query: string, options: RequestInit): RequestInit => {
export default async <TData = { [key: string]: unknown }>(
url: string,
query: string,
options: RequestInit = {}
options: RequestInit = {},
): Promise<{
response: Response;
body: ExecutionResult<TData>;
Expand Down
12 changes: 6 additions & 6 deletions src/graphql/parseGraphQl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const getRangeFromGraphQlType = (type: IntrospectionOutputTypeRef): string => {
};

const getReferenceFromGraphQlType = (
type: IntrospectionOutputTypeRef
type: IntrospectionOutputTypeRef,
): null | string => {
if (type.kind === "OBJECT" && type.name.endsWith("Connection")) {
return type.name.slice(0, type.name.lastIndexOf("Connection"));
Expand All @@ -37,7 +37,7 @@ const getReferenceFromGraphQlType = (

export default async (
entrypointUrl: string,
options: RequestInit = {}
options: RequestInit = {},
): Promise<{
api: Api;
response: Response;
Expand All @@ -50,11 +50,11 @@ export default async (
} = await fetchQuery<IntrospectionQuery>(
entrypointUrl,
introspectionQuery,
options
options,
);
if (!data?.__schema) {
throw new Error(
"Schema has not been retrieved from the introspection query."
"Schema has not been retrieved from the introspection query.",
);
}
const schema = data?.__schema;
Expand All @@ -70,7 +70,7 @@ export default async (
!type.name.startsWith(type.name[0].toLowerCase()) &&
!type.name.endsWith("Connection") &&
!type.name.endsWith("Edge") &&
!type.name.endsWith("PageInfo")
!type.name.endsWith("PageInfo"),
) as IntrospectionObjectType[];

const resources: Resource[] = [];
Expand Down Expand Up @@ -98,7 +98,7 @@ export default async (
fields,
readableFields,
writableFields,
})
}),
);
});

Expand Down
14 changes: 7 additions & 7 deletions src/hydra/fetchJsonLd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ test("fetch a JSON-LD document", () => {
status: 200,
statusText: "OK",
headers: { "Content-Type": "application/ld+json" },
}
},
);

return fetchJsonLd("/foo.jsonld").then((data) => {
expect(data.response.ok).toBe(true);
expect(((data as ResponseDocument).body as { name: string }).name).toBe(
"John Lennon"
"John Lennon",
);
});
});
Expand All @@ -39,7 +39,7 @@ test("fetch a non JSON-LD document", () => {
(data: { response: Response; body: undefined }) => {
expect(data.response.ok).toBe(true);
expect(typeof data.body).toBe("undefined");
}
},
);
});

Expand All @@ -56,7 +56,7 @@ test("fetch an error with Content-Type application/ld+json", () => {
status: 400,
statusText: "Bad Request",
headers: { "Content-Type": "application/ld+json" },
}
},
);

return fetchJsonLd("/foo.jsonld").catch(
Expand All @@ -65,7 +65,7 @@ test("fetch an error with Content-Type application/ld+json", () => {
expect(response.ok).toBe(false);
expect(body.born).toBe("1940-10-09");
});
}
},
);
});

Expand All @@ -82,7 +82,7 @@ test("fetch an error with Content-Type application/error+json", () => {
status: 400,
statusText: "Bad Request",
headers: { "Content-Type": "application/error+json" },
}
},
);

return fetchJsonLd("/foo.jsonld").catch(
Expand All @@ -91,7 +91,7 @@ test("fetch an error with Content-Type application/error+json", () => {
expect(response.ok).toBe(false);
expect(body.born).toBe("1940-10-09");
});
}
},
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/hydra/fetchJsonLd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ResponseDocument extends RemoteDocument {
*/
export default async function fetchJsonLd(
url: string,
options: RequestInitExtended = {}
options: RequestInitExtended = {},
): Promise<ResponseDocument | EmptyResponseDocument> {
const response = await fetch(url, setHeaders(options));
const { headers, status } = response;
Expand Down
12 changes: 5 additions & 7 deletions src/hydra/fetchResource.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import get from "lodash.get";
import type { EmptyResponseDocument, ResponseDocument } from "./fetchJsonLd.js";
import fetchJsonLd from "./fetchJsonLd.js";
import type { IriTemplateMapping, RequestInitExtended } from "./types.js";

export default (
resourceUrl: string,
options: RequestInitExtended = {}
options: RequestInitExtended = {},
): Promise<{ parameters: IriTemplateMapping[] }> => {
return fetchJsonLd(
resourceUrl,
Object.assign({ itemsPerPage: 0 }, options)
Object.assign({ itemsPerPage: 0 }, options),
).then((d: ResponseDocument | EmptyResponseDocument) => {
let hasPrefix = true;
if ((d as ResponseDocument).body) {
hasPrefix = "hydra:search" in (d as ResponseDocument).body;
}
return {
parameters: get(
d,
hasPrefix ? "body.hydra:search.hydra:mapping" : "body.search.mapping"
) as unknown as IriTemplateMapping[],
parameters: (hasPrefix
? (d as any)?.body?.["hydra:search"]?.["hydra:mapping"]
: (d as any)?.body?.search?.mapping) as unknown as IriTemplateMapping[],
};
});
};
2 changes: 1 addition & 1 deletion src/hydra/getParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { RequestInitExtended } from "./types.js";

export default (
resource: Resource,
options: RequestInitExtended = {}
options: RequestInitExtended = {},
): Promise<Parameter[]> =>
fetchResource(resource.url, options).then(({ parameters = [] }) => {
const resourceParameters: Parameter[] = [];
Expand Down
Loading

0 comments on commit c550dce

Please sign in to comment.