Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use standard imports over path aliases #4

Merged
merged 1 commit into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const { pathsToModuleNameMapper } = require("ts-jest/utils");
const { compilerOptions } = require("./tsconfig");

module.exports = {
preset: "ts-jest",
testEnvironment: "jsdom",
Expand All @@ -9,7 +6,6 @@ module.exports = {
},
testMatch: ["<rootDir>/src/**/*.spec.+(ts|tsx|js)"],
moduleFileExtensions: ["ts", "tsx", "js"],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: "<rootDir>/src/" }),
reporters: ["default", "jest-github-actions-reporter"],
testLocationInResults: true,
};
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "~types";
export * from "~services";
export * from "./types";
export * from "./services";
2 changes: 1 addition & 1 deletion src/services/crop.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CropService } from "./crop";
import CropData, { cropWithoutMaster, cropWithoutMasterOrAssetSize } from "~__fixtures__/crop-data";
import CropData, { cropWithoutMaster, cropWithoutMasterOrAssetSize } from "../__fixtures__/crop-data";

test("extraction of highest quality assest", () => {
const cropService = new CropService(CropData);
Expand Down
9 changes: 5 additions & 4 deletions src/services/crop.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { PathReporter } from "io-ts/PathReporter";
import Service from "~services/service";
import { Asset, Crop } from "~types";
import { either, isRight } from "fp-ts/Either";
import Logger from "~utils/logger";
import { PathReporter } from "io-ts/PathReporter";
import Service from "./service";
import { Asset } from "../types/asset";
import { Crop } from "../types/crop";
import { Logger } from "../utils";

class CropService extends Service<Crop> {
isValid: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/services/iframe-post-message.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IframePostMessageService } from "./iframe-post-message";
import iframePostMessageData from "~__fixtures__/iframe-post-message-data";
import iframePostMessageData from "../__fixtures__/iframe-post-message-data";

test("validation of bad data", () => {
const input = new MessageEvent("*", {
Expand Down
10 changes: 5 additions & 5 deletions src/services/iframe-post-message.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { IframePostMessage } from "~types";
import { either, isRight } from "fp-ts/Either";
import Service from "~services/service";
import { CropService } from "~services/crop";
import { PathReporter } from "io-ts/PathReporter";
import Logger from "~utils/logger";
import { either, isRight } from "fp-ts/Either";
import { IframePostMessage } from "../types";
import Service from "./service";
import { CropService } from "./crop";
import { Logger } from "../utils";

class IframePostMessageService extends Service<IframePostMessage> {
isValid: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/services/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./iframe-post-message";
export * from "./crop";
2 changes: 1 addition & 1 deletion src/services/service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logger from "~utils/logger";
import { Logger } from "../utils";

abstract class Service<T> {
abstract isValid: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/types/argo/action.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "io-ts";
import URLFromString from "~types/io-ts/URLFromString";
import URLFromString from "../io-ts/URLFromString";
import { ArgoMethod } from "./method";

const ArgoAction = t.type({
Expand Down
15 changes: 5 additions & 10 deletions src/types/argo/data-entity.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import * as t from "io-ts";
import URLFromString from "~types/io-ts/URLFromString";
import { Mixed, Type, TypeC } from "io-ts";
import URLFromString from "../io-ts/URLFromString";

const DataEntity: <C extends Mixed>(codec: C) => TypeC<{ data: C; uri: Type<URL, string, unknown> }> = <
C extends t.Mixed
>(
codec: C
) =>
t.type(
{
uri: URLFromString,
data: codec,
},
"DataEntity"
);

// type ArgoEntity = t.TypeOf<typeof ArgoEntity>;
t.type({
uri: URLFromString,
data: codec,
});

export { DataEntity };
6 changes: 2 additions & 4 deletions src/types/argo/entity.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as t from "io-ts";
import URLFromString from "~types/io-ts/URLFromString";
import { IntersectionC, KeyofC, Mixed, PartialC, ReadonlyArrayC, StringC, Type, TypeC } from "io-ts";
import URLFromString from "../io-ts/URLFromString";
import { ArgoAction } from "./action";
import { ArgoLink } from "./link";
import { IntersectionC, KeyofC, Mixed, PartialC, ReadonlyArrayC, StringC, Type, TypeC } from "io-ts";

const ArgoEntity: <C extends Mixed>(
codec: C
Expand All @@ -28,6 +28,4 @@ const ArgoEntity: <C extends Mixed>(
}),
]);

// type ArgoEntity = t.TypeOf<typeof ArgoEntity>;

export { ArgoEntity };
2 changes: 1 addition & 1 deletion src/types/argo/link.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "io-ts";
import URLFromString from "~types/io-ts/URLFromString";
import URLFromString from "../io-ts/URLFromString";

const ArgoLink = t.type({
rel: t.string,
Expand Down
2 changes: 1 addition & 1 deletion src/types/asset/asset.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Asset } from "./asset";
import { isRight } from "fp-ts/Either";
import { Asset } from "./asset";

test("foo", () => {
const data = {
Expand Down
2 changes: 1 addition & 1 deletion src/types/asset/asset.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "io-ts";
import URLFromString from "~types/io-ts/URLFromString";
import URLFromString from "../io-ts/URLFromString";
import { Dimensions } from "./dimensions";
import { GridMimeType } from "./grid-mime-type";

Expand Down
2 changes: 1 addition & 1 deletion src/types/asset/grid-mime-type.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GridMimeType } from "./grid-mime-type";
import { isLeft, isRight } from "fp-ts/Either";
import { GridMimeType } from "./grid-mime-type";

test("valid input", () => {
["image/jpeg", "image/png", "image/tiff"].forEach((mime) => {
Expand Down
2 changes: 1 addition & 1 deletion src/types/collection/action-data.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionData } from "./action-data";
import { either, isLeft, isRight } from "fp-ts/Either";
import { ActionData } from "./action-data";

test("valid input", () => {
const data = ActionData.decode({
Expand Down
2 changes: 1 addition & 1 deletion src/types/collection/collection.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Collection } from "./collection";
import { either, isLeft, isRight } from "fp-ts/Either";
import { Collection } from "./collection";

test("valid input", () => {
const data = Collection.decode({
Expand Down
4 changes: 2 additions & 2 deletions src/types/crop/crop.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Crop } from "./crop";
import { isRight } from "fp-ts/Either";
import cropData from "~__fixtures__/crop-data";
import { Crop } from "./crop";
import cropData from "../../__fixtures__/crop-data";

test("decoding a crop", () => {
const parsed = Crop.decode(cropData);
Expand Down
2 changes: 1 addition & 1 deletion src/types/crop/crop.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as t from "io-ts";
import { DateFromISOString } from "io-ts-types";
import { Specification } from "./specification";
import { Asset } from "~types/asset";
import { Asset } from "../asset";

const Crop = t.intersection([
t.type({
Expand Down
4 changes: 2 additions & 2 deletions src/types/crop/specification.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Specification } from "./specification";
import { isRight } from "fp-ts/Either";
import cropData from "~__fixtures__/crop-data";
import { Specification } from "./specification";
import cropData from "../../__fixtures__/crop-data";

test("decoding a crop specification", () => {
const parsed = Specification.decode(cropData.specification);
Expand Down
2 changes: 1 addition & 1 deletion src/types/crop/specification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "io-ts";
import URLFromString from "~types/io-ts/URLFromString";
import URLFromString from "../io-ts/URLFromString";
import { Bounds } from "./bounds";
import { CropType } from "./crop-type";

Expand Down
6 changes: 3 additions & 3 deletions src/types/iframe-post-message.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as t from "io-ts";
import { DataEntity } from "~/types/argo";
import { Crop } from "~/types/crop";
import { GridImage } from "~/types/image";
import { DataEntity } from "./argo";
import { Crop } from "./crop";
import { GridImage } from "./image";

const IframePostMessage = t.type({
crop: DataEntity(Crop),
Expand Down
4 changes: 2 additions & 2 deletions src/types/image/image.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GridImage } from "./image";
import imageData from "~__fixtures__/image-data";
import { isRight } from "fp-ts/Either";
import { GridImage } from "./image";
import imageData from "../../__fixtures__/image-data";

test("foo", () => {
const parsed = GridImage.decode(imageData);
Expand Down
19 changes: 10 additions & 9 deletions src/types/image/image.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import * as t from "io-ts";
import { DateFromISOString } from "io-ts-types";

import { Identifier } from "./identifiers";
import { UploadInfo } from "./upload-info";
import { Asset } from "~types/asset";
import { FileMetadata, ImageMetadata } from "./metadata";
import { Crop } from "~types/crop";
import { SyndicationRights, SyndicationStatus } from "~types/syndication";
import { InvalidReason } from "~types/image/invalid-reason";
import { InvalidReason } from "./invalid-reason";
import { Cost } from "./cost";
import { Persisted } from "./persisted";
import { Lease } from "~types/lease";
import { Collection } from "~types/collection";
import { Usage } from "~types/usage";
import { UserMetadata } from "./metadata";
import { ArgoEntity, DataEntity } from "~/types/argo";
import { EmptyUsage } from "~types/usage/empty-usage";
import { Lease } from "../lease";

import { ArgoEntity, DataEntity } from "../argo";
import { Asset } from "../asset";
import { Crop } from "../crop";
import { Collection } from "../collection";
import { SyndicationRights, SyndicationStatus } from "../syndication";
import { EmptyUsage, Usage } from "../usage";

// TODO be better!
const UsageRights = t.unknown;
Expand Down
5 changes: 2 additions & 3 deletions src/types/image/metadata/user-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as t from "io-ts";
import { ImageMetadata } from "./image-metadata";
import { Photoshoot } from "./photoshoot";
import { ArgoEntity } from "~types";
import { ImageMetadata, Photoshoot } from "./";
import { ArgoEntity } from "../../argo";

const UserMetadata = t.partial({
archived: t.boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/types/io-ts/URLFromString.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import URLFromString from "./URLFromString";
import { either, isLeft, isRight } from "fp-ts/Either";
import URLFromString from "./URLFromString";

test("valid input", () => {
const value = URLFromString.decode("https://a.domain.com/path/to/resource");
Expand Down
2 changes: 1 addition & 1 deletion src/types/lease/lease.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Lease } from "./lease";
import { isRight } from "fp-ts/Either";
import { Lease } from "./lease";

test("blah", () => {
const parsed = Lease.decode({});
Expand Down
2 changes: 1 addition & 1 deletion src/types/syndication/syndication-rights.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as t from "io-ts";
import { DateFromISOString } from "io-ts-types";
import { Supplier } from "./supplier";
import { Right } from "./right";
import { Supplier } from "./supplier";

const SyndicationRights = t.intersection([
t.type({
Expand Down
2 changes: 1 addition & 1 deletion src/types/usage/metadata/digital-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "io-ts";
import URLFromString from "~types/io-ts/URLFromString";
import URLFromString from "../../io-ts/URLFromString";

const DigitalUsageMetadata = t.intersection([
t.type({
Expand Down
2 changes: 1 addition & 1 deletion src/types/usage/reference.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as t from "io-ts";

import { ReferenceType } from "./reference-type";
import URLFromString from "~types/io-ts/URLFromString";
import URLFromString from "../io-ts/URLFromString";

const UsageReference = t.intersection([
t.type({
Expand Down
2 changes: 1 addition & 1 deletion src/types/usage/usage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as t from "io-ts";
import { DateFromISOString } from "io-ts-types";
import { UsageReference } from "./reference";
import { UsageType } from "./usage-type";
import { UsageStatus } from "./usage-status";
import { UsageType } from "./usage-type";

import {
PrintUsageMetadata,
Expand Down
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./logger";
2 changes: 1 addition & 1 deletion src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ interface Logger {
log: (message?: unknown, ...optionalParams: unknown[]) => void;
}

export default Logger;
export { Logger };
6 changes: 1 addition & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
"module": "commonjs",
"declaration": true,
"outDir": "./lib",
"strict": true,
"baseUrl": "./src",
"paths": {
"~*": ["./*"]
}
"strict": true
},
"include": [
"src/**/*"
Expand Down