Skip to content

Commit bfbfe8c

Browse files
committed
refactor(core): add root index file, consolidate utility imports and update paths
- Moved utility imports to a centralized index file in the utils directory. - Updated import paths across various modules to use the new index file. - Removed redundant utility functions and adjusted related code accordingly. Signed-off-by: J3m5 <[email protected]>
1 parent 29ba9ae commit bfbfe8c

21 files changed

+55
-72
lines changed

src/core/Api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Resource } from "./Resource.js";
22
import type { Nullable } from "./types.js";
3-
import { assignSealed } from "./utils/assignSealed.js";
3+
import { assignSealed } from "./utils/index.js";
44

55
export interface ApiOptions
66
extends Nullable<{

src/core/Field.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Resource } from "./Resource.js";
22
import type { Nullable } from "./types.js";
3-
import { assignSealed } from "./utils/assignSealed.js";
3+
import { assignSealed } from "./utils/index.js";
44

55
export type FieldType =
66
| "string"

src/core/Operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Nullable } from "./types.js";
2-
import { assignSealed } from "./utils/assignSealed.js";
2+
import { assignSealed } from "./utils/index.js";
33

44
export type OperationType = "show" | "edit" | "delete" | "list" | "create";
55

src/core/Resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Field } from "./Field.js";
22
import type { Operation } from "./Operation.js";
33
import type { Parameter } from "./Parameter.js";
44
import type { Nullable } from "./types.js";
5-
import { assignSealed } from "./utils/assignSealed.js";
5+
import { assignSealed } from "./utils/index.js";
66

77
export interface ResourceOptions
88
extends Nullable<{

src/core/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
export * from "../graphql/index.js";
2-
export * from "../hydra/index.js";
3-
export * from "../openapi3/index.js";
4-
export * from "../swagger/index.js";
51
export * from "./Api.js";
62
export * from "./Field.js";
73
export * from "./Operation.js";

src/core/utils/getResources.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, test } from "vitest";
2-
import getResourcePaths from "./getResources.js";
2+
import { getResourcePaths } from "./index.js";
33

44
test("should get resource paths", () => {
55
const paths = {

src/core/utils/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { assignSealed } from "./assignSealed.js";
2+
export { getResourcePaths } from "./getResourcePaths.js";
3+
export { getType } from "./getType.js";
4+
export { parsedJsonReplacer } from "./parsedJsonReplacer.js";
5+
export { removeTrailingSlash } from "./removeTrailingSlash.js";

src/core/utils/parsedJsonReplacer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interface ResourceValue {
55

66
type ParsedJsonReplacerResult = ResourceValue | string | null;
77

8-
export default function parsedJsonReplacer(
8+
export function parsedJsonReplacer(
99
key: string,
1010
value: null | ResourceValue,
1111
): ParsedJsonReplacerResult {

src/graphql/parseGraphQl.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { getIntrospectionQuery } from "graphql/utilities/index.js";
2-
import fetchQuery from "./fetchQuery.js";
3-
import { Api } from "../Api.js";
4-
import { Field } from "../Field.js";
5-
import { Resource } from "../Resource.js";
61
import type {
72
IntrospectionObjectType,
83
IntrospectionOutputTypeRef,
94
IntrospectionQuery,
105
} from "graphql/utilities";
6+
import { getIntrospectionQuery } from "graphql/utilities/index.js";
7+
import { Api, Field, Resource } from "../core/index.js";
8+
import fetchQuery from "./fetchQuery.js";
119

1210
function getRangeFromGraphQlType(type: IntrospectionOutputTypeRef): string {
1311
if (type.kind === "NON_NULL") {

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 "../core/types.js";
33

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

0 commit comments

Comments
 (0)