Skip to content

Commit 1e897ee

Browse files
committed
refactor(types): deduplicate RequestInitExtended into src/types.ts
* Removed duplicate definitions from `src/hydra/types.ts` and deleted `src/openapi3/types.ts`. * Added a single canonical `RequestInitExtended` interface in `src/types.ts`. * Updated all affected import paths across Hydra and OpenAPI3 modules. Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
1 parent 01354c9 commit 1e897ee

File tree

8 files changed

+12
-14
lines changed

8 files changed

+12
-14
lines changed

src/hydra/fetchJsonLd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Document, JsonLd, RemoteDocument } from "jsonld/jsonld-spec.js";
2-
import type { RequestInitExtended } from "./types.js";
2+
import type { RequestInitExtended } from "../types.js";
33

44
const jsonLdMimeType = "application/ld+json";
55
const jsonProblemMimeType = "application/problem+json";

src/hydra/fetchResource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fetchJsonLd from "./fetchJsonLd.js";
2-
import type { IriTemplateMapping, RequestInitExtended } from "./types.js";
2+
import type { IriTemplateMapping } from "./types.js";
3+
import type { RequestInitExtended } from "../types.js";
34

45
export default async function fetchResource(
56
resourceUrl: string,

src/hydra/getParameters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Parameter } from "../Parameter.js";
22
import fetchResource from "./fetchResource.js";
33
import type { Resource } from "../Resource.js";
4-
import type { RequestInitExtended } from "./types.js";
4+
import type { RequestInitExtended } from "../types.js";
55

66
export default async function getParameters(
77
resource: Resource,

src/hydra/parseHydraDocumentation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import type {
1414
Entrypoint,
1515
ExpandedOperation,
1616
ExpandedRdfProperty,
17-
RequestInitExtended,
18-
} from "./types.js";
17+
} from "./types.js";
18+
import type { RequestInitExtended } from "../types.js";
1919

2020
/**
2121
* Extracts the short name of a resource.

src/hydra/types.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
export interface RequestInitExtended extends Omit<RequestInit, "headers"> {
2-
headers?: HeadersInit | (() => HeadersInit);
3-
}
4-
51
export interface IriTemplateMapping {
62
"@type": "IriTemplateMapping";
73
variable: "string";
@@ -94,7 +90,7 @@ export interface ExpandedRdfProperty {
9490
];
9591
}
9692

97-
export interface ExpandedSupportedProperty {
93+
interface ExpandedSupportedProperty {
9894
"@type": ["http://www.w3.org/ns/hydra/core#SupportedProperty"];
9995
"http://www.w3.org/ns/hydra/core#title": [
10096
{

src/openapi3/parseOpenApi3Documentation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Api } from "../Api.js";
33
import handleJson, { removeTrailingSlash } from "./handleJson.js";
44
import type { OpenAPIV3 } from "openapi-types";
5-
import type { RequestInitExtended } from "./types.js";
5+
import type { RequestInitExtended } from "../types.js";
66

77
export interface ParsedOpenApi3Documentation {
88
api: Api;

src/openapi3/types.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
export type Nullable<T extends Record<string, unknown>> = {
22
[P in keyof T]: T[P] | null;
33
};
4+
5+
export interface RequestInitExtended extends Omit<RequestInit, "headers"> {
6+
headers?: HeadersInit | (() => HeadersInit);
7+
}

0 commit comments

Comments
 (0)