Skip to content

Commit

Permalink
fix(api): unused exports and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ascariandrea committed Nov 30, 2024
1 parent e56686a commit c1671d9
Show file tree
Hide file tree
Showing 25 changed files with 42 additions and 54 deletions.
2 changes: 2 additions & 0 deletions packages/@liexp/backend/src/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ export * from "./BadRequestError.js";
export * from "./NotAuthorizedError.js";
export * from "./NotFoundError.js";
export * from "./ServerError.js";

export { IOError } from "ts-io-error/lib/index.js";
1 change: 1 addition & 0 deletions services/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"bin:run": "node ./build/bin/cli.js",
"build": "tsc -b tsconfig.build.json",
"clean": "rm -rf build",
"db:diagram": "node -r tsx/cjs -T ./node_modules/.bin/typeorm-uml ormconfig.js -D LR -d ./data/media/docs/diagrams/typeorm-uml.png",
"db:dump": "tsx ./src/scripts/database.dump.ts",
"db:dump:alpha": "DOTENV_CONFIG_PATH=.env.alpha pnpm db:dump -p alpha",
"dev": "node --watch build/run.js",
Expand Down
5 changes: 3 additions & 2 deletions services/api/src/context/context.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import { type PDFProvider } from "@liexp/shared/lib/providers/pdf/pdf.provider.j
import { type AppConfig } from "#app/config.js";
import { type ENV } from "#io/ENV.js";
import { type QueuesProvider } from "#providers/queue.provider.js";

export interface ENVContext {
env: ENV;
}

export interface PDFProviderContext {
interface PDFProviderContext {
pdf: PDFProvider;
}

export interface HTTPProviderContext {
interface HTTPProviderContext {
http: HTTPProvider;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const findOneResourceAndMapText = (
);
};

export const extractEntitiesFromAny = (
const extractEntitiesFromAny = (
body: ExtractEntitiesWithNLPInput,
): TEReader<ExtractEntitiesWithNLPOutput> => {
return pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface ExifMetadata {
height?: number;
}

export const readExifMetadataFromBuffer =
const readExifMetadataFromBuffer =
(buf: ArrayBuffer): TEReader<ExifReader.Tags> =>
(ctx) => {
return ctx.imgProc.readExif(buf as any, {});
Expand Down
5 changes: 0 additions & 5 deletions services/api/src/flows/events/extractFromURL.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,6 @@ export interface DataPayloadLink {
type: EventType;
}

export interface DataPayload {
keywords: string[];
links: DataPayloadLink[];
}

export const extractEventFromURL =
(
p: puppeteer.Page,
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/flows/graphs/createFlowGraph.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const updateMap =
);
};

export const getFlowGraph =
const getFlowGraph =
({
events,
actors,
Expand Down
4 changes: 2 additions & 2 deletions services/api/src/flows/links/takeLinkScreenshot.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const rejectCookieModal = async (page: puppeteer.Page): Promise<void> => {
await button?.click();
};

export const takeLinkScreenshot =
const takeLinkScreenshot =
(link: LinkEntity): TEReader<Buffer> =>
(ctx) => {
return pipe(
Expand Down Expand Up @@ -73,7 +73,7 @@ export const takeLinkScreenshot =
);
};

export const uploadScreenshot = (
const uploadScreenshot = (
link: LinkEntity,
buffer: Buffer,
): TEReader<Partial<MediaEntity>> => {
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/flows/media/extra/extractMP4Extra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { type ServerContext } from "#context/context.type.js";
import { type TEReader } from "#flows/flow.types.js";
import { toControllerError } from "#io/ControllerError.js";

export const extractVideoFFProbeData =
const extractVideoFFProbeData =
(location: string): TEReader<Ffmpeg.FfprobeData> =>
(ctx) =>
pipe(ctx.ffmpeg.ffprobe(location), fp.TE.mapLeft(toControllerError));
Expand Down
6 changes: 3 additions & 3 deletions services/api/src/flows/media/extractMediaFromPlatform.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
type ControllerError,
} from "#io/ControllerError.js";

export const extractTitleFromPlatform = (
const extractTitleFromPlatform = (
page: puppeteer.Page,
): TE.TaskEither<ControllerError, string> => {
return pipe(
Expand All @@ -28,7 +28,7 @@ export const extractTitleFromPlatform = (
);
};

export const extractDescriptionFromPlatform = (
const extractDescriptionFromPlatform = (
m: VideoPlatformMatch,
page: puppeteer.Page,
): TE.TaskEither<ControllerError, string | undefined> => {
Expand Down Expand Up @@ -62,7 +62,7 @@ export const extractDescriptionFromPlatform = (
);
};

export const extractEmbedFromPlatform = (
const extractEmbedFromPlatform = (
url: URL,
m: VideoPlatformMatch,
page: puppeteer.Page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { toControllerError } from "#io/ControllerError.js";

export type SimpleMP4Media = SimpleMedia<MP4Type>;

export const takeVideoScreenshots =
const takeVideoScreenshots =
({
filename,
media,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { resizeThumbnailFlow } from "./thumbnailResize.flow.js";
import { type ServerContext } from "#context/context.type.js";
import { type TEReader } from "#flows/flow.types.js";

export type ExtractThumbnailFlow<T extends MediaType> = (
type ExtractThumbnailFlow<T extends MediaType> = (
media: SimpleMedia<T>,
) => TEReader<PutObjectCommandInput[]>;

Expand Down
5 changes: 0 additions & 5 deletions services/api/src/flows/networks/createNetworkGraph.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,6 @@ const initialResult: Result = {
totals: EventTotalsMonoid.empty,
};

export interface Graph {
nodes: any[];
links: any[];
}

export const createNetworkGraph =
(
type: NetworkType,
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/flows/tg/upsertPinnedMessage.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ToPinnedMessageOptions {
// actorLimit: number;
}

// todo: to retrieve from db
// TODO: to retrieve from db
export const toPinnedMessage = ({
bot,
keywords,
Expand Down
9 changes: 0 additions & 9 deletions services/api/src/flows/wikipedia/fetchFromWikipedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,3 @@ export const fetchFromWikipedia: FetchFromWikipediaFlow = (title) => (wp) => {
})),
);
};

export const searchAndParseFromWikipedia: FetchFromWikipediaFlow =
(search) => (wp) => {
return pipe(
wp.search(search),
TE.mapLeft(toControllerError),
TE.chain((p) => fetchFromWikipedia(p[0].title)(wp)),
);
};
6 changes: 4 additions & 2 deletions services/api/src/io/ControllerError.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { toNotAuthorizedError } from "@liexp/backend/lib/errors/NotAuthorizedError.js";
import { toNotFoundError } from "@liexp/backend/lib/errors/NotFoundError.js";
import { ServerError } from "@liexp/backend/lib/errors/ServerError.js";
import {
toNotAuthorizedError,
IOError,
} from "@liexp/backend/lib/errors/index.js";
import { JWTError } from "@liexp/backend/lib/providers/jwt/jwt.provider.js";
import { fp, pipe } from "@liexp/core/lib/fp/index.js";
import { DecodeError } from "@liexp/shared/lib/io/http/Error/DecodeError.js";
import { UnauthorizedError } from "express-jwt";
import * as t from "io-ts";
import { IOError } from "ts-io-error";
import { toAPIError, toControllerError } from "./ControllerError.js";

describe("ControllerError", () => {
Expand Down
4 changes: 2 additions & 2 deletions services/api/src/io/ControllerError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ServerError,
BadRequestError,
NotAuthorizedError,
IOError,
} from "@liexp/backend/lib/errors/index.js";
import { type FSError } from "@liexp/backend/lib/providers/fs/fs.provider.js";
import { JWTError } from "@liexp/backend/lib/providers/jwt/jwt.provider.js";
Expand All @@ -21,7 +22,6 @@ import { type HTTPError } from "@liexp/shared/lib/providers/http/http.provider.j
import { UnauthorizedError } from "express-jwt";
import { pipe } from "fp-ts/lib/function.js";
import { failure } from "io-ts/lib/PathReporter.js";
import { IOError } from "ts-io-error/lib/index.js";

export type ControllerError =
| HTTPError
Expand Down Expand Up @@ -73,7 +73,7 @@ export const toControllerError = (e: unknown): ControllerError => {
});
};

export const report = (err: ControllerError): string => {
const report = (err: ControllerError): string => {
return `[${err.name}] ${err.message}:\n${reportIOErrorDetails(err.details)}`;
};

Expand Down
10 changes: 5 additions & 5 deletions services/api/src/providers/queue.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
type ControllerError,
} from "#io/ControllerError.js";

export interface QueueProvider<J extends Queue.Queue> {
interface QueueProvider<J extends Queue.Queue> {
addJob: (job: J) => TaskEither<ControllerError, void>;
getJob: (
resource: Queue.QueueResourceNames,
Expand All @@ -25,19 +25,19 @@ export interface QueueProvider<J extends Queue.Queue> {
exists: (job: J) => TaskEither<ControllerError, boolean>;
deleteJob: (
resource: Queue.QueueResourceNames,
id: string,
id: UUID,
) => TaskEither<ControllerError, void>;
}

export const GetQueueJobProvider = <J extends Queue.Queue>(
const GetQueueJobProvider = <J extends Queue.Queue>(
fs: FSClient,
configPath: string,
): ((type: Queue.QueueTypes) => QueueProvider<J>) => {
const getJobPath = (
job: {
resource: Queue.QueueResourceNames;
type: string;
id: string;
id: UUID;
},
status?: Queue.Status,
) => {
Expand Down Expand Up @@ -73,7 +73,7 @@ export const GetQueueJobProvider = <J extends Queue.Queue>(
return pipe(
fs.getObject(path.resolve(configPath, file)),
fp.TE.mapLeft(toControllerError),
fp.TE.map((data) => JSON.parse(data)),
fp.TE.map(JSON.parse),
);
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { fetchGroups } from "#queries/groups/fetchGroups.query.js";
import { fetchKeywords } from "#queries/keywords/fetchKeywords.query.js";
import { fetchManyMedia } from "#queries/media/fetchManyMedia.query.js";

export const fetchLinksT =
const fetchLinksT =
(urlMetadata: URLMetadataClient) =>
(
links: (http.Common.UUID | CreateLink)[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const getWhere = (
: q.where.bind(q);
};

export const whereInTitle =
const whereInTitle =
(config: EventsConfig) =>
(
q: SelectQueryBuilder<EventV2Entity>,
Expand Down Expand Up @@ -86,7 +86,7 @@ export const whereInTitle =
});
};

export const whereActorInArray =
const whereActorInArray =
(config: EventsConfig) =>
(
selectQ: SelectQueryBuilder<EventV2Entity>,
Expand Down Expand Up @@ -120,7 +120,7 @@ export const whereActorInArray =
return selectQ;
};

export const whereGroupInArray =
const whereGroupInArray =
(config: EventsConfig) =>
(
q: SelectQueryBuilder<EventV2Entity>,
Expand Down
1 change: 1 addition & 0 deletions services/api/src/utils/json.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const GetWriteJSON =
);
};

// TODO: never used
export const GetReadJSON =
(log: Logger) =>
<A, O = A, I = unknown>(
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/utils/orm.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const getWhereOption = (_f: Query.FilterQuery): Partial<ORMFilter> => {
);
};

export const getOrder = (
const getOrder = (
order: ORMOrder["order"],
prefix?: string,
orderedKeys?: string[],
Expand Down
4 changes: 2 additions & 2 deletions services/api/test/__mocks__/puppeteer.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const puppeteerMock = {
launch: vi.fn(),
} as any as Mocked<PuppeteerExtra>;

export const pageMock = {
const pageMock = {
on: vi.fn(),
goto: vi.fn().mockRejectedValue(new Error("goto not implemented")),
click: vi.fn().mockRejectedValue(new Error("click: Not implemented")),
Expand All @@ -33,7 +33,7 @@ export const pageMock = {
browser: () => browserMock,
};

export const browserMock = {
const browserMock = {
on: vi.fn(),
newPage: vi.fn().mockResolvedValue(pageMock),
pages: vi.fn().mockResolvedValue([pageMock] as any),
Expand Down
6 changes: 3 additions & 3 deletions services/api/test/arbitraries/TGMessage.arb.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fc } from "@liexp/test";
import type TelegramBot from "node-telegram-bot-api";

export const TGFromArb = fc.record({
const TGFromArb = fc.record({
id: fc.nat(),
is_bot: fc.boolean(),
first_name: fc.string(),
Expand All @@ -10,7 +10,7 @@ export const TGFromArb = fc.record({
language_code: fc.constant("en"),
});

export const TGChatArb: fc.Arbitrary<TelegramBot.Chat> = fc.record({
const TGChatArb: fc.Arbitrary<TelegramBot.Chat> = fc.record({
id: fc.nat(),
first_name: fc.string(),
last_name: fc.string(),
Expand All @@ -26,7 +26,7 @@ export const TGPhotoArb: fc.Arbitrary<TelegramBot.PhotoSize> = fc.record({
height: fc.nat(),
});

export const TGCaptionEntityArb: fc.Arbitrary<TelegramBot.MessageEntity> = fc.record({
const TGCaptionEntityArb: fc.Arbitrary<TelegramBot.MessageEntity> = fc.record({
offset: fc.nat(),
length: fc.nat(),
type: fc.constant("text_link"),
Expand Down
4 changes: 2 additions & 2 deletions services/api/test/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface AppMocks {
queueFS: typeof queueFSMock;
}

export const fetchHTML = vi.fn();
export const fetchMetadata = vi.fn();
const fetchHTML = vi.fn();
const fetchMetadata = vi.fn();

export const axiosMock = {
get: vi.fn(),
Expand Down

0 comments on commit c1671d9

Please sign in to comment.