diff --git a/packages/@liexp/backend/src/flows/event/createEventFromURL.flow.spec.ts b/packages/@liexp/backend/src/flows/event/createEventFromURL.flow.spec.ts index 07fff8ffe..4ef9dfb1d 100644 --- a/packages/@liexp/backend/src/flows/event/createEventFromURL.flow.spec.ts +++ b/packages/@liexp/backend/src/flows/event/createEventFromURL.flow.spec.ts @@ -9,8 +9,8 @@ import { describe, expect, it } from "vitest"; import { mockDeep } from "vitest-mock-extended"; import { EventV2Entity } from "../../entities/Event.v2.entity.js"; import { UserEntity } from "../../entities/User.entity.js"; -import { initContext } from "../../test/index.js"; -import { mockedContext, mockTERightOnce } from "../../test/mocks/mock.utils.js"; +import { mockedContext } from "../../test/index.js"; +import { mockTERightOnce } from "../../test/mocks/mock.utils.js"; import { createEventFromURL, type CreateEventFromURLContext, @@ -18,15 +18,7 @@ import { describe(createEventFromURL.name, () => { const appTest = { - ctx: mockedContext({ - puppeteer: mockDeep(), - logger: mockDeep(), - db: mockDeep(), - ner: mockDeep(), - fs: mockDeep(), - urlMetadata: mockDeep(), - config: initContext().config, - }), + ctx: mockedContext({}), }; it("should create an event from a URL", async () => { @@ -61,46 +53,6 @@ describe(createEventFromURL.name, () => { mockTERightOnce(appTest.ctx.db.findOneOrFail, () => savedEvent); - // mocks.urlMetadata.fetchMetadata.mockResolvedValue({ - // title, - // description, - // url: scientificStudyData.url, - // keywords: [], - // }); - - // mockTERightOnce(appTest.ctx.puppeteer.getBrowser, () => null); - // mocks.puppeteer.page.goto.mockResolvedValueOnce(undefined); - - // // evaluate title - // mocks.puppeteer.page.$eval.mockResolvedValueOnce(title); - // // evaluate dropdown click - // mocks.puppeteer.page.click.mockResolvedValueOnce(undefined); - // // evaluate date string - // mocks.puppeteer.page.$eval.mockResolvedValueOnce([ - // "Received 27 July 2020", - // "Accepted 1 August 2020", - // ]); - // // wait for - // mocks.puppeteer.page.waitForSelector.mockResolvedValueOnce(undefined); - // mocks.puppeteer.page.$$.mockResolvedValueOnce([ - // { - // evaluate: vi.fn().mockResolvedValue(description), - // }, - // ]); - - // mocks.puppeteer.page.$eval.mockResolvedValueOnce("page content"); - - // mocks.ner.winkMethods.learnCustomEntities.mockResolvedValueOnce({} as any); - // mocks.ner.doc.out.mockReturnValue([]); - // mocks.ner.doc.sentences.mockReturnValue({ each: vi.fn() } as any); - // mocks.ner.doc.customEntities.mockReturnValue({ - // out: vi.fn().mockReturnValue([]), - // } as any); - // mocks.ner.doc.tokens.mockReturnValue({ each: vi.fn() } as any); - - // mocks.fs.existsSync.mockReturnValue(false); - // mocks.fs.readFileSync.mockReturnValue("[]"); - const user = new UserEntity(); const event: any = await pipe( diff --git a/packages/@liexp/backend/src/flows/event/createEventFromURL.flow.ts b/packages/@liexp/backend/src/flows/event/createEventFromURL.flow.ts index a2e1ee03d..8e2fd25ef 100644 --- a/packages/@liexp/backend/src/flows/event/createEventFromURL.flow.ts +++ b/packages/@liexp/backend/src/flows/event/createEventFromURL.flow.ts @@ -16,7 +16,7 @@ import { EventV2Entity } from "../../entities/Event.v2.entity.js"; import { type UserEntity } from "../../entities/User.entity.js"; import { ServerError } from "../../errors/ServerError.js"; import { findByURL } from "../../queries/events/scientificStudy.query.js"; -import { extractEventFromURL } from "./extractFromURL.flow.js"; +import { extractEventFromURL } from "./extractEventFromURL.flow.js"; export type CreateEventFromURLContext = LoggerContext & ConfigContext & diff --git a/packages/@liexp/backend/src/flows/event/extractFromURL.flow.spec.ts b/packages/@liexp/backend/src/flows/event/extractEventFromURL.flow.spec.ts similarity index 93% rename from packages/@liexp/backend/src/flows/event/extractFromURL.flow.spec.ts rename to packages/@liexp/backend/src/flows/event/extractEventFromURL.flow.spec.ts index f29744f69..8f6921ba5 100644 --- a/packages/@liexp/backend/src/flows/event/extractFromURL.flow.spec.ts +++ b/packages/@liexp/backend/src/flows/event/extractEventFromURL.flow.spec.ts @@ -7,27 +7,25 @@ import { sanitizeURL } from "@liexp/shared/lib/utils/url.utils.js"; import { fc } from "@liexp/test"; import { describe, expect, it, vi } from "vitest"; import { mock } from "vitest-mock-extended"; +import { testConfig, mockedContext } from "../../../test/index.js"; +import { mockTERightOnce } from "../../../test/mocks/mock.utils.js"; +import { mocks } from "../../../test/mocks.js"; import { LinkEntity } from "../../entities/Link.entity.js"; import { UserEntity } from "../../entities/User.entity.js"; -import { initContext, testConfig } from "../../test/index.js"; -import { mockedContext, mockTERightOnce } from "../../test/mocks/mock.utils.js"; -import { mocks } from "../../test/mocks.js"; import { createEventFromURL, type CreateEventFromURLContext, } from "./createEventFromURL.flow.js"; -import { extractEventFromURL } from "./extractFromURL.flow.js"; +import { extractEventFromURL } from "./extractEventFromURL.flow.js"; describe.skip(extractEventFromURL.name, () => { const appTest = { ctx: mockedContext({ puppeteer: mock(), - logger: mock(), db: mock(), ner: mock(), fs: mock(), urlMetadata: mock(), - config: testConfig, }), }; diff --git a/packages/@liexp/backend/src/flows/event/extractFromURL.flow.ts b/packages/@liexp/backend/src/flows/event/extractEventFromURL.flow.ts similarity index 72% rename from packages/@liexp/backend/src/flows/event/extractFromURL.flow.ts rename to packages/@liexp/backend/src/flows/event/extractEventFromURL.flow.ts index 64e81da77..5a11899f7 100644 --- a/packages/@liexp/backend/src/flows/event/extractFromURL.flow.ts +++ b/packages/@liexp/backend/src/flows/event/extractEventFromURL.flow.ts @@ -9,7 +9,6 @@ import { } from "@liexp/shared/lib/io/http/Events/EventType.js"; import { toInitialValue } from "@liexp/shared/lib/providers/blocknote/utils.js"; import { parse } from "date-fns"; -import { sequenceS } from "fp-ts/lib/Apply.js"; import * as O from "fp-ts/lib/Option.js"; import { type ReaderTaskEither } from "fp-ts/lib/ReaderTaskEither.js"; import * as TE from "fp-ts/lib/TaskEither.js"; @@ -176,97 +175,90 @@ const extractByProvider = (ctx) => { return pipe( TE.Do, - TE.bind("relations", () => - sequenceS(TE.ApplicativeSeq)({ - relations: extractRelationsFromURL(p, l.url)(ctx), - provider: extractPageMetadataFromProviderLink(p, host, l)(ctx), - }), + TE.bind("relations", () => extractRelationsFromURL(p, l.url)(ctx)), + TE.bind("provider", () => + extractPageMetadataFromProviderLink(p, host, l)(ctx), ), - TE.bind( - "suggestions", - ({ - relations: { - relations: { entities }, - provider, - }, - }) => { - if (fp.O.isSome(provider)) { + TE.bind("metadata", ({ provider }) => { + if (fp.O.isSome(provider)) { + return fp.TE.right(provider.value); + } + + return fp.TE.right({ + url: l.url, + title: l.title, + description: l.description ?? l.title, + keywords: [], + image: l.image?.id ?? null, + icon: "", + provider: undefined, + type, + } satisfies Metadata); + }), + TE.bind("suggestions", ({ relations: { entities }, metadata }) => { + return pipe( + TE.Do, + TE.bind("link", () => { return pipe( - TE.Do, - TE.bind("link", () => { - return pipe( - LinkIO.decodeSingle(l), - fp.E.fold(() => fp.O.none, fp.O.some), - fp.TE.right, - ); - }), - TE.bind("relations", () => - pipe( - fp.TE.right( - getRelationIdsFromEventRelations({ - groupsMembers: [], - media: [], - areas: [], - actors: entities.actors as any[], - groups: entities.groups as any[], - keywords: entities.keywords as any[], - links: entities.links as any[], - }), - ), - ), - ), - TE.chain(({ link, relations }) => - TE.tryCatch(() => { - const suggestionMaker = getSuggestions((v) => - Promise.resolve(toInitialValue(v)), - ); + LinkIO.decodeSingle(l), + fp.E.fold(() => fp.O.none, fp.O.some), + fp.TE.right, + ); + }), - return suggestionMaker( - provider.value, - link, - O.none, - relations, - ); - }, ServerError.fromUnknown), + TE.bind("relations", () => + pipe( + fp.TE.right( + getRelationIdsFromEventRelations({ + groupsMembers: [], + media: [], + areas: [], + actors: entities.actors as any[], + groups: entities.groups as any[], + keywords: entities.keywords as any[], + links: entities.links as any[], + }), ), - TE.map((suggestions) => { - return suggestions.find((s) => s.event.type === type); - }), - TE.map(O.fromNullable), - ); - } - return TE.right(O.none); - }, - ), + ), + ), + TE.chain(({ link, relations }) => + TE.tryCatch(() => { + const suggestionMaker = getSuggestions((v) => + Promise.resolve(toInitialValue(v)), + ); - TE.map( - ({ - relations: { - relations: { entities }, - }, - suggestions, - }) => - pipe( - suggestions, - O.map((s) => ({ - ...s.event, - id: uuid(), - excerpt: s.event.excerpt ?? null, - body: s.event.body ?? null, - location: null, - links: [l], - keywords: [], - media: [], - events: [], - socialPosts: [], - actors: entities.actors, - groups: entities.groups, - stories: [], - createdAt: new Date(), - updatedAt: new Date(), - deletedAt: null, - })), + return suggestionMaker(metadata, link, O.none, relations); + }, ServerError.fromUnknown), ), + TE.map((suggestions) => { + return suggestions.find((s) => s.event.type === type); + }), + TE.map(O.fromNullable), + ); + }), + + TE.map(({ relations: { entities }, suggestions }) => + pipe( + suggestions, + O.map((s) => ({ + ...s.event, + id: uuid(), + excerpt: s.event.excerpt ?? null, + body: s.event.body ?? null, + location: null, + links: [l], + keywords: [], + media: [], + events: [], + socialPosts: [], + actors: entities.actors, + groups: entities.groups, + stories: [], + createdAt: new Date(), + updatedAt: new Date(), + deletedAt: null, + })), + ), ), ); }; diff --git a/packages/@liexp/backend/src/flows/media/createAndUpload.flow.spec.ts b/packages/@liexp/backend/src/flows/media/createAndUpload.flow.spec.ts new file mode 100644 index 000000000..3ec9d0d3c --- /dev/null +++ b/packages/@liexp/backend/src/flows/media/createAndUpload.flow.spec.ts @@ -0,0 +1,240 @@ +import { fp } from "@liexp/core/lib/fp/index.js"; +import { + IframeVideoType, + ImageType, + MP4Type, +} from "@liexp/shared/lib/io/http/Media/MediaType.js"; +import { MediaArb } from "@liexp/shared/lib/tests/index.js"; +import { throwTE } from "@liexp/shared/lib/utils/task.utils.js"; +import * as tests from "@liexp/test"; +import { pipe } from "fp-ts/lib/function.js"; +import { beforeEach, describe, expect, test, vi } from "vitest"; +import { mock, mockClear, mockDeep } from "vitest-mock-extended"; +import { mockedContext } from "../../../test/index.js"; +import { mockTERightOnce } from "../../../test/mocks/mock.utils.js"; +import { sharpMock } from "../../../test/mocks/sharp.mock.js"; +import { mocks } from "../../../test/mocks.js"; +import { type FSClient } from "../../providers/fs/fs.provider.js"; +import { + createAndUpload, + type CreateAndUploadFlowContext, +} from "./createAndUpload.flow.js"; + +describe(createAndUpload.name, () => { + const fs = mock(); + const Test = { + ctx: mockedContext({ + env: process.env as any, + fs, + http: mockDeep(), + pdf: mockDeep(), + ffmpeg: mockDeep(), + puppeteer: mockDeep(), + imgProc: mockDeep(), + s3: mockDeep(), + queue: mockDeep(), + db: mockDeep(), + }), + mocks, + }; + const addJob = vi.fn().mockImplementationOnce(() => fp.TE.right(undefined)); + + beforeEach(() => { + mockClear(Test.ctx.db); + mockClear(Test.ctx.s3); + + mockTERightOnce(Test.ctx.db.save, (_, m) => m); + }); + + test.todo("Should create a media from PDF location"); + + test("Should create a media from image location", async () => { + const [media] = tests.fc + .sample(MediaArb, 1) + .map(({ createdAt, updatedAt, id, thumbnail, ...m }, i) => ({ + ...m, + id, + label: `label-${id}`, + location: `https://example.com/${id}.jpg`, + type: ImageType.types[0].value, + creator: undefined, + })); + + const mediaUploadLocation = tests.fc.sample(tests.fc.webUrl(), 1)[0]; + mockTERightOnce(Test.ctx.s3.upload, () => ({ + Location: mediaUploadLocation, + })); + + const response = await pipe( + createAndUpload( + { + ...media, + location: media.location, + thumbnail: undefined, + }, + { Body: "image", ContentType: ImageType.types[0].value }, + media.id, + false, + )(Test.ctx), + throwTE, + ); + + expect(response).toMatchObject({ + location: mediaUploadLocation, + }); + }); + + test("Should create a media from MP4 file location", async () => { + const [media] = tests.fc + .sample(MediaArb, 1) + .map(({ createdAt, updatedAt, deletedAt, id, thumbnail, ...m }, i) => ({ + ...m, + id, + label: `label-${id}`, + location: `https://example.com/${id}.mp4`, + type: MP4Type.value, + creator: undefined, + extra: undefined, + })); + + const mediaUploadLocation = tests.fc.sample(tests.fc.webUrl(), 1)[0]; + mockTERightOnce(Test.ctx.s3.upload, () => ({ + Location: mediaUploadLocation, + })); + + const result = await pipe( + createAndUpload( + { + ...media, + location: media.location, + thumbnail: undefined, + }, + { Body: {}, ContentType: MP4Type.value }, + media.id, + false, + )(Test.ctx), + throwTE, + ); + + expect(addJob).not.toHaveBeenCalled(); + + expect(result).toMatchObject({ + ...media, + id: expect.any(String), + description: media.description ?? media.label, + creator: undefined, + location: mediaUploadLocation, + // extra: { + // width: 0, + // height: expect.any(Number), + // thumbnailWidth: 0, + // thumbnailHeight: 0, + // thumbnails: [], + // needRegenerateThumbnail: false, + // }, + extra: undefined, + // socialPosts: [], + // transferable: true, + // createdAt: expect.any(String), + // updatedAt: expect.any(String), + }); + }); + + test("Should create a media from iframe/video location", async () => { + const [media] = tests.fc + .sample(MediaArb, 1) + .map(({ createdAt, updatedAt, deletedAt, thumbnail, id, ...m }, i) => ({ + ...m, + id, + label: `label-${id}`, + location: `https://www.youtube.com/watch?v=${id}`, + type: IframeVideoType.value, + creator: undefined, + })); + + const response = await pipe( + createAndUpload( + { + ...media, + location: media.location, + thumbnail: undefined, + }, + { Body: {}, ContentType: IframeVideoType.value }, + media.id, + false, + )(Test.ctx), + throwTE, + ); + + expect(Test.ctx.s3.upload).toHaveBeenCalledTimes(0); + expect(Test.ctx.db.save).toHaveBeenCalledTimes(1); + + expect(response).toMatchObject({ + ...media, + id: expect.any(String), + // location: `https://www.youtube.com/embed/${media.id}`, + location: `https://www.youtube.com/watch?v=${media.id}`, + description: media.description ?? media.label, + creator: undefined, + // extra: { + // width: 0, + // height: 0, + // thumbnailWidth: 0, + // thumbnailHeight: 0, + // thumbnails: [], + // needRegenerateThumbnail: false, + // }, + // socialPosts: [], + // transferable: true, + // createdAt: expect.any(String), + // updatedAt: expect.any(String), + }); + }); + + test("Should get an error when 'location' in media is duplicated", async () => { + const [media] = tests.fc + .sample(MediaArb, 1) + .map(({ id, createdAt, updatedAt, ...m }) => ({ + ...m, + id, + label: `label-${id}`, + description: `description-${id}`, + events: [], + links: [], + keywords: [], + areas: [], + featuredInStories: [], + socialPosts: [], + location: `https://example.com/${id}.jpg`, + thumbnail: `https://example.com/${id}-thumb.jpg`, + creator: undefined, + extra: undefined, + })); + + Test.ctx.db.findOneOrFail.mockResolvedValueOnce(media as any); + + Test.mocks.axios.get.mockImplementation(() => { + return Promise.resolve({ data: Buffer.from([]) }); + }); + + Test.mocks.redis.publish.mockResolvedValueOnce(1); + + const task = pipe( + createAndUpload( + { + ...media, + location: media.location, + thumbnail: undefined, + }, + { Body: {}, ContentType: IframeVideoType.value }, + media.id, + true, + )(Test.ctx), + ); + + await expect(throwTE(task)).rejects.toThrowError(); + + expect(sharpMock.toFormat).not.toHaveBeenCalled(); + expect(sharpMock.toBuffer).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/@liexp/backend/src/flows/media/createAndUpload.flow.ts b/packages/@liexp/backend/src/flows/media/createAndUpload.flow.ts index 8443231d8..0a6fdbd43 100644 --- a/packages/@liexp/backend/src/flows/media/createAndUpload.flow.ts +++ b/packages/@liexp/backend/src/flows/media/createAndUpload.flow.ts @@ -31,22 +31,23 @@ import { type MediaEntity } from "../../entities/Media.entity.js"; import { ServerError } from "../../errors/ServerError.js"; import { upload } from "../../flows/space/upload.flow.js"; import { MediaRepository } from "../../services/entity-repository.service.js"; +import { LoggerService } from "../../services/logger/logger.service.js"; import { createThumbnail } from "./thumbnails/createThumbnail.flow.js"; -export const createAndUpload = < - C extends SpaceContext & - ENVContext & - QueuesProviderContext & - DatabaseContext & - LoggerContext & - ConfigContext & - FSClientContext & - HTTPProviderContext & - PDFProviderContext & - FFMPEGProviderContext & - PuppeteerProviderContext & - ImgProcClientContext, ->( +export type CreateAndUploadFlowContext = SpaceContext & + ENVContext & + QueuesProviderContext & + DatabaseContext & + LoggerContext & + ConfigContext & + FSClientContext & + HTTPProviderContext & + PDFProviderContext & + FFMPEGProviderContext & + PuppeteerProviderContext & + ImgProcClientContext; + +export const createAndUpload = ( createMediaData: Media.CreateMedia, { Body, ContentType }: { Body: any; ContentType?: MediaType }, id: UUID | undefined, @@ -61,6 +62,7 @@ export const createAndUpload = < if (IframeVideoType.is(createMediaData.type)) { return fp.RTE.right(createMediaData.location); } + const mediaKey = getMediaKey( "media", mediaId, @@ -79,6 +81,7 @@ export const createAndUpload = < ); }), // ctx.logger.debug.logInTaskEither("Result %O"), + LoggerService.RTE.info("Result %O"), fp.RTE.bind("thumbnail", ({ mediaId, location }) => pipe( extractThumb @@ -98,6 +101,7 @@ export const createAndUpload = < MediaRepository.save([ { ...createMediaData, + description: createMediaData.description ?? createMediaData.label, events: [], links: [], featuredInStories: [], diff --git a/packages/@liexp/backend/src/flows/tg/__tests__/createFromTGMessage.flow.spec.ts b/packages/@liexp/backend/src/flows/tg/__tests__/createFromTGMessage.flow.spec.ts index 158766fb7..4c43c387f 100644 --- a/packages/@liexp/backend/src/flows/tg/__tests__/createFromTGMessage.flow.spec.ts +++ b/packages/@liexp/backend/src/flows/tg/__tests__/createFromTGMessage.flow.spec.ts @@ -15,11 +15,11 @@ import { beforeAll, describe, expect, test, vi } from "vitest"; import { TGMessageArb, TGPhotoArb, -} from "../../../test/arbitraries/TGMessage.arb.js"; -import { initContext } from "../../../test/index.js"; -import puppeteerMocks from "../../../test/mocks/puppeteer.mock.js"; -import { mocks } from "../../../test/mocks.js"; -import { type UserTest } from "../../../test/user.utils.js"; +} from "../../../../test/arbitraries/TGMessage.arb.js"; +import { mockedContext } from "../../../../test/index.js"; +import puppeteerMocks from "../../../../test/mocks/puppeteer.mock.js"; +import { mocks } from "../../../../test/mocks.js"; +import { type UserTest } from "../../../../test/user.utils.js"; import { createFromTGMessage } from "../createFromTGMessage.flow.js"; const tempDir = path.resolve(__dirname, `../../../../temp/tg/media`); @@ -36,7 +36,7 @@ interface MessageTest { describe("Create From TG Message", () => { let admin: UserTest; - const ctx = initContext(); + const ctx = mockedContext(); beforeAll(() => { [admin] = fc.sample(UserArb, 1).map((u) => ({ diff --git a/packages/@liexp/backend/src/flows/tg/__tests__/upsertPinnedMessage.flow.spec.ts b/packages/@liexp/backend/src/flows/tg/__tests__/upsertPinnedMessage.flow.spec.ts index d6f4bc861..d921ec111 100644 --- a/packages/@liexp/backend/src/flows/tg/__tests__/upsertPinnedMessage.flow.spec.ts +++ b/packages/@liexp/backend/src/flows/tg/__tests__/upsertPinnedMessage.flow.spec.ts @@ -1,23 +1,30 @@ import { KeywordArb } from "@liexp/shared/lib/tests/arbitrary/Keyword.arbitrary.js"; import { ActorArb, UncategorizedArb } from "@liexp/shared/lib/tests/index.js"; import { throwTE } from "@liexp/shared/lib/utils/task.utils.js"; -import { fc } from "@liexp/test"; +import { fc } from "@liexp/test/lib/index.js"; import * as E from "fp-ts/lib/Either.js"; import { describe, expect, test } from "vitest"; +import { mockDeep } from "vitest-mock-extended"; import { ActorEntity } from "../../../entities/Actor.entity.js"; import { EventV2Entity } from "../../../entities/Event.v2.entity.js"; import { KeywordEntity } from "../../../entities/Keyword.entity.js"; -import { initContext } from "../../../test/index.js"; +import { mockedContext } from "../../../test/index.js"; import { mocks } from "../../../test/mocks.js"; import { toPinnedMessage, upsertPinnedMessage, + type UpsertPinnerMessageFlowContext, } from "../upsertPinnedMessage.flow.js"; describe("Upsert Pinned Message Flow", () => { const Test = { - ctx: initContext(), + ctx: mockedContext({ + db: mockDeep(), + env: process.env as any, + tg: mockDeep(), + }), }; + test.skip("Should upsert the message with 5 keywords", async () => { const keywordCount = 10; const actorCount = 10; diff --git a/packages/@liexp/backend/src/flows/tg/upsertPinnedMessage.flow.ts b/packages/@liexp/backend/src/flows/tg/upsertPinnedMessage.flow.ts index 8fe69044e..2c1d1c23c 100644 --- a/packages/@liexp/backend/src/flows/tg/upsertPinnedMessage.flow.ts +++ b/packages/@liexp/backend/src/flows/tg/upsertPinnedMessage.flow.ts @@ -38,13 +38,13 @@ ${keywords.map((k) => `#${k.tag} (${k.eventCount})`).join("\n")} \n `; +export type UpsertPinnerMessageFlowContext = DatabaseContext & + LoggerContext & + ENVContext & + TGBotProviderContext; + export const upsertPinnedMessage = - < - C extends DatabaseContext & - LoggerContext & - ENVContext & - TGBotProviderContext, - >( + ( limit: number, ): ReaderTaskEither => (ctx) => { diff --git a/packages/@liexp/backend/src/test/index.ts b/packages/@liexp/backend/src/test/index.ts deleted file mode 100644 index 74f055a37..000000000 --- a/packages/@liexp/backend/src/test/index.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { GetLogger } from "@liexp/core/lib/index.js"; -import { HTTPProvider } from "@liexp/shared/lib/providers/http/http.provider.js"; -import { PDFProvider } from "@liexp/shared/lib/providers/pdf/pdf.provider.js"; -import D from "debug"; -import * as puppeteer from "puppeteer-core"; -import { type ConfigContext } from "../context/config.context.js"; -import { type DatabaseContext } from "../context/db.context.js"; -import { type ENVContext } from "../context/env.context.js"; -import { type FSClientContext } from "../context/fs.context.js"; -import { type HTTPProviderContext } from "../context/http.context.js"; -import { - type FFMPEGProviderContext, - type ImgProcClientContext, - type NERProviderContext, - type TGBotProviderContext, -} from "../context/index.js"; -import { type LoggerContext } from "../context/logger.context.js"; -import { type PDFProviderContext } from "../context/pdf.context.js"; -import { type PuppeteerProviderContext } from "../context/puppeteer.context.js"; -import { type QueuesProviderContext } from "../context/queue.context.js"; -import { type SpaceContext } from "../context/space.context.js"; -import { type URLMetadataContext } from "../context/urlMetadata.context.js"; -import { type BACKEND_ENV } from "../io/ENV.js"; -import { MakeURLMetadata } from "../providers/URLMetadata.provider.js"; -import { GetFFMPEGProvider } from "../providers/ffmpeg/ffmpeg.provider.js"; -import { GetFSClient } from "../providers/fs/fs.provider.js"; -import { MakeImgProcClient } from "../providers/imgproc/imgproc.provider.js"; -import { GetNERProvider } from "../providers/ner/ner.provider.js"; -import { GetDatabaseClient } from "../providers/orm/index.js"; -import { GetPuppeteerProvider } from "../providers/puppeteer.provider.js"; -import { GetQueueProvider } from "../providers/queue.provider.js"; -import { MakeSpaceProvider } from "../providers/space/space.provider.js"; -import { TGBotProvider } from "../providers/tg/tg.provider.js"; -import { EventsConfig } from "../queries/config/index.js"; -import { mocks } from "./mocks.js"; - -const pdfContext = PDFProvider({ client: mocks.pdf }); - -type TestContext = ENVContext & - PDFProviderContext & - TGBotProviderContext & - LoggerContext & - DatabaseContext & - PuppeteerProviderContext & - ConfigContext & - FSClientContext & - NERProviderContext & - URLMetadataContext & - HTTPProviderContext & - ImgProcClientContext & - SpaceContext & - QueuesProviderContext & - FFMPEGProviderContext; - -export const testConfig = { - dirs: { - cwd: "", - config: { nlp: "" }, - temp: { root: "", queue: "", stats: "", nlp: "", media: "" }, - }, - media: { - thumbnailHeight: 0, - thumbnailWidth: 0, - }, - events: EventsConfig, -}; - -export const initContext = (): TestContext => { - D.enable(process.env.DEBUG ?? "*"); - - const logger = GetLogger("test"); - - const fs = GetFSClient({ client: mocks.fs }); - - const ctx = { - env: process.env as any as BACKEND_ENV, - db: GetDatabaseClient({ - connection: mocks.db.connection, - logger, - }), - fs, - s3: MakeSpaceProvider({ - client: mocks.s3.client as any, - getSignedUrl: mocks.s3.getSignedUrl, - classes: mocks.s3.classes as any, - }), - config: testConfig, - pdf: pdfContext, - puppeteer: GetPuppeteerProvider( - mocks.puppeteer, - {}, - puppeteer.KnownDevices, - ), - ffmpeg: GetFFMPEGProvider(mocks.ffmpeg), - queue: GetQueueProvider(fs, "fake-queue"), - http: HTTPProvider(mocks.axios as any), - ner: GetNERProvider({ - nlp: mocks.ner, - entitiesFile: "fake", - logger, - }), - urlMetadata: MakeURLMetadata({ - client: mocks.urlMetadata.fetchHTML as any, - parser: { - getMetadata: mocks.urlMetadata.fetchMetadata, - }, - }), - tg: TGBotProvider( - { logger: logger, client: () => mocks.tg as any }, - { token: "fake", chat: "fake", polling: false, baseApiUrl: "fake" }, - ), - imgProc: MakeImgProcClient({ - logger: logger.extend("imgproc"), - client: mocks.sharp, - exifR: mocks.exifR, - }), - logger: GetLogger("test"), - }; - - return ctx; -}; diff --git a/packages/@liexp/backend/src/test/arbitraries/TGMessage.arb.ts b/packages/@liexp/backend/test/arbitraries/TGMessage.arb.ts similarity index 100% rename from packages/@liexp/backend/src/test/arbitraries/TGMessage.arb.ts rename to packages/@liexp/backend/test/arbitraries/TGMessage.arb.ts diff --git a/packages/@liexp/backend/test/index.ts b/packages/@liexp/backend/test/index.ts new file mode 100644 index 000000000..45073891a --- /dev/null +++ b/packages/@liexp/backend/test/index.ts @@ -0,0 +1,79 @@ +import { GetLogger } from "@liexp/core/lib/index.js"; +import D from "debug"; +import { mockDeep, type DeepMockProxy } from "vitest-mock-extended"; +import { type ConfigContext } from "../src/context/config.context.js"; +import { type DatabaseContext } from "../src/context/db.context.js"; +import { type ENVContext } from "../src/context/env.context.js"; +import { type FSClientContext } from "../src/context/fs.context.js"; +import { type HTTPProviderContext } from "../src/context/http.context.js"; +import { + type FFMPEGProviderContext, + type ImgProcClientContext, + type NERProviderContext, + type TGBotProviderContext, +} from "../src/context/index.js"; +import { type LoggerContext } from "../src/context/logger.context.js"; +import { type PDFProviderContext } from "../src/context/pdf.context.js"; +import { type PuppeteerProviderContext } from "../src/context/puppeteer.context.js"; +import { type QueuesProviderContext } from "../src/context/queue.context.js"; +import { type SpaceContext } from "../src/context/space.context.js"; +import { type URLMetadataContext } from "../src/context/urlMetadata.context.js"; +import { EventsConfig } from "../src/queries/config/index.js"; + +type TestContext = ENVContext & + PDFProviderContext & + TGBotProviderContext & + LoggerContext & + DatabaseContext & + PuppeteerProviderContext & + ConfigContext & + FSClientContext & + NERProviderContext & + URLMetadataContext & + HTTPProviderContext & + ImgProcClientContext & + SpaceContext & + QueuesProviderContext & + FFMPEGProviderContext; + +D.enable(process.env.DEBUG ?? "@liexp:*"); + +const logger = GetLogger("test"); + +export const testConfig = { + dirs: { + cwd: "", + config: { nlp: "" }, + temp: { root: "", queue: "", stats: "", nlp: "", media: "" }, + }, + media: { + thumbnailHeight: 0, + thumbnailWidth: 0, + }, + events: EventsConfig, +}; + +type MockedContext> = { + [K in keyof C]: DeepMockProxy; +}; + +export const mockedContext = >( + ctx: Partial>, +): Omit => ({ + puppeteer: mockDeep(), + db: mockDeep(), + ner: mockDeep(), + fs: mockDeep(), + urlMetadata: mockDeep(), + env: process.env as any, + pdf: mockDeep(), + http: mockDeep(), + tg: mockDeep(), + s3: mockDeep(), + imgProc: mockDeep(), + queue: mockDeep(), + ffmpeg: mockDeep(), + ...ctx, + config: testConfig, + logger: ctx?.logger ?? logger, +}); diff --git a/packages/@liexp/backend/src/test/mocks.ts b/packages/@liexp/backend/test/mocks.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks.ts rename to packages/@liexp/backend/test/mocks.ts diff --git a/packages/@liexp/backend/src/test/mocks/blocknote-core.mock.ts b/packages/@liexp/backend/test/mocks/blocknote-core.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/blocknote-core.mock.ts rename to packages/@liexp/backend/test/mocks/blocknote-core.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/blocknote-react.mock.ts b/packages/@liexp/backend/test/mocks/blocknote-react.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/blocknote-react.mock.ts rename to packages/@liexp/backend/test/mocks/blocknote-react.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/canvas.mock.ts b/packages/@liexp/backend/test/mocks/canvas.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/canvas.mock.ts rename to packages/@liexp/backend/test/mocks/canvas.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/db.mock.ts b/packages/@liexp/backend/test/mocks/db.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/db.mock.ts rename to packages/@liexp/backend/test/mocks/db.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/exifreader.mock.ts b/packages/@liexp/backend/test/mocks/exifreader.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/exifreader.mock.ts rename to packages/@liexp/backend/test/mocks/exifreader.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/ffmpeg.mock.ts b/packages/@liexp/backend/test/mocks/ffmpeg.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/ffmpeg.mock.ts rename to packages/@liexp/backend/test/mocks/ffmpeg.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/fs.mock.ts b/packages/@liexp/backend/test/mocks/fs.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/fs.mock.ts rename to packages/@liexp/backend/test/mocks/fs.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/ig.mock.ts b/packages/@liexp/backend/test/mocks/ig.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/ig.mock.ts rename to packages/@liexp/backend/test/mocks/ig.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/mock.utils.ts b/packages/@liexp/backend/test/mocks/mock.utils.ts similarity index 55% rename from packages/@liexp/backend/src/test/mocks/mock.utils.ts rename to packages/@liexp/backend/test/mocks/mock.utils.ts index d8ad6d8d3..990a8aeee 100644 --- a/packages/@liexp/backend/src/test/mocks/mock.utils.ts +++ b/packages/@liexp/backend/test/mocks/mock.utils.ts @@ -1,7 +1,7 @@ import { fp } from "@liexp/core/lib/fp/index.js"; +import { type ReaderTaskEither } from "fp-ts/lib/ReaderTaskEither"; import { type TaskEither } from "fp-ts/lib/TaskEither"; import { type MockInstance } from "vitest"; -import { type DeepMockProxy } from "vitest-mock-extended"; export const mockTERightOnce = ( fn: MockInstance<(...args: any[]) => TaskEither>, @@ -11,10 +11,10 @@ export const mockTERightOnce = ( return fp.TE.right(value(...args)); }); -type MockedContext> = { - [K in keyof C]: DeepMockProxy; -}; - -export const mockedContext = >( - ctx: C, -): MockedContext => ctx; +export const mockRTERightOnce = ( + fn: MockInstance<(...args: any[]) => ReaderTaskEither>, + value: (...args: any[]) => U, +) => + fn.mockImplementationOnce((...args) => { + return fp.RTE.right(value(...args)); + }); diff --git a/packages/@liexp/backend/src/test/mocks/nlp.mock.ts b/packages/@liexp/backend/test/mocks/nlp.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/nlp.mock.ts rename to packages/@liexp/backend/test/mocks/nlp.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/pdfjs.mock.ts b/packages/@liexp/backend/test/mocks/pdfjs.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/pdfjs.mock.ts rename to packages/@liexp/backend/test/mocks/pdfjs.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/puppeteer.mock.ts b/packages/@liexp/backend/test/mocks/puppeteer.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/puppeteer.mock.ts rename to packages/@liexp/backend/test/mocks/puppeteer.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/queue.mock.ts b/packages/@liexp/backend/test/mocks/queue.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/queue.mock.ts rename to packages/@liexp/backend/test/mocks/queue.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/redis.mock.ts b/packages/@liexp/backend/test/mocks/redis.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/redis.mock.ts rename to packages/@liexp/backend/test/mocks/redis.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/s3.mock.ts b/packages/@liexp/backend/test/mocks/s3.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/s3.mock.ts rename to packages/@liexp/backend/test/mocks/s3.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/sharp.mock.ts b/packages/@liexp/backend/test/mocks/sharp.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/sharp.mock.ts rename to packages/@liexp/backend/test/mocks/sharp.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/slate.mock.ts b/packages/@liexp/backend/test/mocks/slate.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/slate.mock.ts rename to packages/@liexp/backend/test/mocks/slate.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/tg.mock.ts b/packages/@liexp/backend/test/mocks/tg.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/tg.mock.ts rename to packages/@liexp/backend/test/mocks/tg.mock.ts diff --git a/packages/@liexp/backend/src/test/mocks/wikipedia.mock.ts b/packages/@liexp/backend/test/mocks/wikipedia.mock.ts similarity index 100% rename from packages/@liexp/backend/src/test/mocks/wikipedia.mock.ts rename to packages/@liexp/backend/test/mocks/wikipedia.mock.ts diff --git a/packages/@liexp/backend/src/test/user.utils.ts b/packages/@liexp/backend/test/user.utils.ts similarity index 100% rename from packages/@liexp/backend/src/test/user.utils.ts rename to packages/@liexp/backend/test/user.utils.ts diff --git a/packages/@liexp/backend/src/test/vitest.base-config.ts b/packages/@liexp/backend/test/vitest.base-config.ts similarity index 100% rename from packages/@liexp/backend/src/test/vitest.base-config.ts rename to packages/@liexp/backend/test/vitest.base-config.ts diff --git a/packages/@liexp/backend/tsconfig.build.json b/packages/@liexp/backend/tsconfig.build.json index dd2596cc7..0c4b3113c 100644 --- a/packages/@liexp/backend/tsconfig.build.json +++ b/packages/@liexp/backend/tsconfig.build.json @@ -2,10 +2,11 @@ "extends": "./tsconfig.json", "compilerOptions": { "composite": false, + "noEmit": false, "types": ["node"], "rootDir": "./src", "tsBuildInfoFile": "lib/build.tsbuildinfo" }, "include": ["src", "typings", "../shared/typings", "src/**/*.json"], - "exclude": ["node_modules", "lib", "src/**/*.spec.ts"] + "exclude": ["node_modules", "lib", "src/**/*.spec.ts", "test"] } diff --git a/packages/@liexp/backend/tsconfig.json b/packages/@liexp/backend/tsconfig.json index a30e795b0..e228cbb9c 100644 --- a/packages/@liexp/backend/tsconfig.json +++ b/packages/@liexp/backend/tsconfig.json @@ -20,7 +20,13 @@ "rootDir": "./src", "tsBuildInfoFile": "lib/.tsbuildinfo" }, - "include": ["./src", "./typings", "../shared/typings", "./src/**/*.json"], + "include": [ + "./src", + "./test", + "./typings", + "../shared/typings", + "./src/**/*.json" + ], "exclude": ["node_modules", "lib"], "references": [ { diff --git a/packages/@liexp/backend/urls/0d1785bf42b588eaa482b4a024c964d3096dc6e0.txt b/packages/@liexp/backend/urls/0d1785bf42b588eaa482b4a024c964d3096dc6e0.txt deleted file mode 100644 index acdfa8602..000000000 --- a/packages/@liexp/backend/urls/0d1785bf42b588eaa482b4a024c964d3096dc6e0.txt +++ /dev/null @@ -1 +0,0 @@ -"page content" \ No newline at end of file diff --git a/packages/@liexp/backend/vitest.config.ts b/packages/@liexp/backend/vitest.config.ts index 508519694..d529e43a9 100644 --- a/packages/@liexp/backend/vitest.config.ts +++ b/packages/@liexp/backend/vitest.config.ts @@ -1,22 +1,27 @@ import viteTsconfigPaths from "vite-tsconfig-paths"; import { defineConfig, mergeConfig } from "vitest/config"; -import { baseConfig } from "./src/test/vitest.base-config"; +import { baseConfig } from "./test/vitest.base-config"; -export default mergeConfig(baseConfig, defineConfig({ - test: { - name: "@liexp/backend", - root: __dirname, - globals: true, - include: [__dirname + "/src/**/*.spec.ts"], - watch: false, - coverage: { - thresholds: { - lines: 90, - statements: 80, - functions: 80, +export default mergeConfig( + baseConfig, + defineConfig({ + test: { + name: "@liexp/backend", + root: __dirname, + globals: true, + include: [__dirname + "/src/**/*.spec.ts"], + watch: false, + coverage: { + thresholds: { + lines: 90, + statements: 80, + functions: 80, + }, }, }, - }, - plugins: [viteTsconfigPaths({ root: __dirname })], - root: __dirname, -})); + plugins: [ + viteTsconfigPaths({ root: __dirname }), + ], + root: __dirname, + }), +); diff --git a/packages/@liexp/backend/vitest.config.ts.timestamp-1737064274359-67b01676a0689.mjs b/packages/@liexp/backend/vitest.config.ts.timestamp-1737064274359-67b01676a0689.mjs deleted file mode 100644 index 105a54e69..000000000 --- a/packages/@liexp/backend/vitest.config.ts.timestamp-1737064274359-67b01676a0689.mjs +++ /dev/null @@ -1,57 +0,0 @@ -// vitest.config.ts -import viteTsconfigPaths2 from "file:///home/ascariandrea/Workspace/lies-exposed/node_modules/vite-tsconfig-paths/dist/index.js"; -import { defineConfig as defineConfig2, mergeConfig } from "file:///home/ascariandrea/Workspace/lies-exposed/node_modules/vitest/dist/config.js"; - -// src/test/vitest.base-config.ts -import { URL } from "url"; -import viteTsconfigPaths from "file:///home/ascariandrea/Workspace/lies-exposed/node_modules/vite-tsconfig-paths/dist/index.js"; -import { defineConfig } from "file:///home/ascariandrea/Workspace/lies-exposed/node_modules/vitest/dist/config.js"; -var __vite_injected_original_import_meta_url = "file:///home/ascariandrea/Workspace/lies-exposed/packages/@liexp/backend/src/test/vitest.base-config.ts"; -var PathnameAlias = (url) => (mockPath) => { - return new URL(mockPath, url).pathname; -}; -var toAlias = PathnameAlias(__vite_injected_original_import_meta_url); -var baseConfig = defineConfig({ - root: toAlias("./"), - test: { - environment: "node", - watch: false, - alias: { - sharp: toAlias("mocks/sharp.mock.js"), - canvas: toAlias("mocks/canvas.mock.js"), - "pdfjs-dist/legacy/build/pdf.js": toAlias("mocks/pdfjs.mock.js"), - "@blocknote/core": toAlias("mocks/blocknote-core.mock.js"), - "@blocknote/react/**": toAlias("mocks/blocknote-react.mock.js") - } - }, - plugins: [ - viteTsconfigPaths({ - root: toAlias("./") - }) - ] -}); - -// vitest.config.ts -var __vite_injected_original_dirname = "/home/ascariandrea/Workspace/lies-exposed/packages/@liexp/backend"; -var vitest_config_default = mergeConfig(baseConfig, defineConfig2({ - test: { - name: "@liexp/backend", - root: __vite_injected_original_dirname, - globals: true, - include: [__vite_injected_original_dirname + "/src/**/*.spec.ts"], - watch: false, - coverage: { - thresholds: { - lines: 90, - statements: 80, - functions: 80 - } - } - }, - plugins: [viteTsconfigPaths2({ root: __vite_injected_original_dirname })], - root: __vite_injected_original_dirname -})); -export { - vitest_config_default as default -}; -//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZXN0LmNvbmZpZy50cyIsICJzcmMvdGVzdC92aXRlc3QuYmFzZS1jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvaG9tZS9hc2NhcmlhbmRyZWEvV29ya3NwYWNlL2xpZXMtZXhwb3NlZC9wYWNrYWdlcy9AbGlleHAvYmFja2VuZFwiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9maWxlbmFtZSA9IFwiL2hvbWUvYXNjYXJpYW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g== diff --git a/services/worker/src/bin/extract-events.ts b/services/worker/src/bin/extract-events.ts index 0e91ed0e2..bfea5f45b 100644 --- a/services/worker/src/bin/extract-events.ts +++ b/services/worker/src/bin/extract-events.ts @@ -2,7 +2,7 @@ import { EventV2Entity } from "@liexp/backend/lib/entities/Event.v2.entity.js"; import { type DataPayloadLink, extractEventFromURL, -} from "@liexp/backend/lib/flows/event/extractFromURL.flow.js"; +} from "@liexp/backend/lib/flows/event/extractEventFromURL.flow.js"; import { getOneAdminOrFail } from "@liexp/backend/lib/flows/user/getOneUserOrFail.flow.js"; import { findByURL } from "@liexp/backend/lib/queries/events/scientificStudy.query.js"; import { throwTE } from "@liexp/shared/lib/utils/task.utils.js"; diff --git a/services/worker/tsconfig.json b/services/worker/tsconfig.json index 67494008b..e7079ce9d 100644 --- a/services/worker/tsconfig.json +++ b/services/worker/tsconfig.json @@ -38,6 +38,6 @@ "references": [ { "path": "../../packages/@liexp/core" }, { "path": "../../packages/@liexp/shared" }, - { "path": "../../packages/@liexp/backend" } + { "path": "../../packages/@liexp/backend/tsconfig.build.json" } ] }