From 18eda9bb5d5e28a0f0e97370720d9caf7290a099 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Tue, 31 Jan 2023 18:43:10 +0300 Subject: [PATCH] refac: move domain to --- src/app/contacts/ContactForm/ports.ts | 2 +- src/app/contacts/ContactsTable/ports.ts | 2 +- .../contacts/domain}/contact.ts | 0 src/app/contacts/domain/index.ts | 1 + src/app/contacts/store.ts | 2 +- src/app/files/FilesTable/ports.ts | 2 +- .../entities => app/files/domain}/file.ts | 0 src/app/files/domain/index.ts | 1 + src/app/files/store.ts | 2 +- src/app/lists/ListForm/ports.ts | 2 +- src/app/lists/ListsSelect/ports.ts | 2 +- src/app/lists/ListsTable/ports.ts | 2 +- src/app/lists/domain/index.ts | 1 + .../entities => app/lists/domain}/list.ts | 0 src/app/lists/store.ts | 2 +- src/infra/api/contact.ts | 2 +- src/infra/api/file.ts | 2 +- src/infra/api/list.ts | 2 +- src/infra/api/template.ts | 19 ------------------- 19 files changed, 15 insertions(+), 31 deletions(-) rename src/{domain/entities => app/contacts/domain}/contact.ts (100%) create mode 100644 src/app/contacts/domain/index.ts rename src/{domain/entities => app/files/domain}/file.ts (100%) create mode 100644 src/app/files/domain/index.ts create mode 100644 src/app/lists/domain/index.ts rename src/{domain/entities => app/lists/domain}/list.ts (100%) delete mode 100644 src/infra/api/template.ts diff --git a/src/app/contacts/ContactForm/ports.ts b/src/app/contacts/ContactForm/ports.ts index 359f34d..9bb1dbc 100644 --- a/src/app/contacts/ContactForm/ports.ts +++ b/src/app/contacts/ContactForm/ports.ts @@ -1,5 +1,5 @@ -import type { Contact } from "@/domain/entities/contact"; import type { BaseCreateApiPort } from "@/shared/lib/ports"; +import type { Contact } from "../domain"; export interface ContactFormApiCreateProps { email: string; diff --git a/src/app/contacts/ContactsTable/ports.ts b/src/app/contacts/ContactsTable/ports.ts index 3cf91fe..c185956 100644 --- a/src/app/contacts/ContactsTable/ports.ts +++ b/src/app/contacts/ContactsTable/ports.ts @@ -1,6 +1,6 @@ -import type { Contact } from "@/domain/entities/contact"; import type { EntityId } from "@/shared/lib/entity"; import type { BaseFetchManyApiPort } from "@/shared/lib/ports"; +import type { Contact } from "../domain"; export interface ContactsTableApiFetchManyProps { listId?: EntityId; diff --git a/src/domain/entities/contact.ts b/src/app/contacts/domain/contact.ts similarity index 100% rename from src/domain/entities/contact.ts rename to src/app/contacts/domain/contact.ts diff --git a/src/app/contacts/domain/index.ts b/src/app/contacts/domain/index.ts new file mode 100644 index 0000000..3d13aa7 --- /dev/null +++ b/src/app/contacts/domain/index.ts @@ -0,0 +1 @@ +export type { Contact } from "./contact"; diff --git a/src/app/contacts/store.ts b/src/app/contacts/store.ts index cc73b89..805bfa3 100644 --- a/src/app/contacts/store.ts +++ b/src/app/contacts/store.ts @@ -1,6 +1,6 @@ -import type { Contact } from "@/domain/entities/contact"; import { defineStore } from "pinia"; import { ref } from "vue"; +import type { Contact } from "./domain"; export const useContactsStore = defineStore("contacts", () => { const data = ref([] as Contact[]); diff --git a/src/app/files/FilesTable/ports.ts b/src/app/files/FilesTable/ports.ts index 358547b..d930d6c 100644 --- a/src/app/files/FilesTable/ports.ts +++ b/src/app/files/FilesTable/ports.ts @@ -1,4 +1,4 @@ -import type { AppFile } from "@/domain/entities/file"; import type { BaseFetchManyApiPort } from "@/shared/lib/ports"; +import type { AppFile } from "../domain"; export type FilesTableApiPort = BaseFetchManyApiPort; diff --git a/src/domain/entities/file.ts b/src/app/files/domain/file.ts similarity index 100% rename from src/domain/entities/file.ts rename to src/app/files/domain/file.ts diff --git a/src/app/files/domain/index.ts b/src/app/files/domain/index.ts new file mode 100644 index 0000000..1530d1b --- /dev/null +++ b/src/app/files/domain/index.ts @@ -0,0 +1 @@ +export type { AppFile } from "./file"; diff --git a/src/app/files/store.ts b/src/app/files/store.ts index 8abcc9e..7fe263b 100644 --- a/src/app/files/store.ts +++ b/src/app/files/store.ts @@ -1,6 +1,6 @@ -import type { AppFile } from "@/domain/entities/file"; import { defineStore } from "pinia"; import { ref } from "vue"; +import type { AppFile } from "./domain"; export const useFilesStore = defineStore("files", () => { const data = ref([] as AppFile[]); diff --git a/src/app/lists/ListForm/ports.ts b/src/app/lists/ListForm/ports.ts index 6ea63c8..61150a6 100644 --- a/src/app/lists/ListForm/ports.ts +++ b/src/app/lists/ListForm/ports.ts @@ -1,5 +1,5 @@ -import type { List } from "@/domain/entities/list"; import type { BaseCreateApiPort } from "@/shared/lib/ports"; +import type { List } from "../domain"; export interface ListFormApiCreateProps { displayName: string; diff --git a/src/app/lists/ListsSelect/ports.ts b/src/app/lists/ListsSelect/ports.ts index 8234b35..052f8f8 100644 --- a/src/app/lists/ListsSelect/ports.ts +++ b/src/app/lists/ListsSelect/ports.ts @@ -1,4 +1,4 @@ -import type { List } from "@/domain/entities/list"; import type { BaseFetchManyApiPort } from "@/shared/lib/ports"; +import type { List } from "../domain"; export type ListsSelectApiPort = BaseFetchManyApiPort; diff --git a/src/app/lists/ListsTable/ports.ts b/src/app/lists/ListsTable/ports.ts index 0b80661..80e681e 100644 --- a/src/app/lists/ListsTable/ports.ts +++ b/src/app/lists/ListsTable/ports.ts @@ -1,4 +1,4 @@ -import type { List } from "@/domain/entities/list"; import type { BaseFetchManyApiPort } from "@/shared/lib/ports"; +import type { List } from "../domain"; export type ListsTableApiPort = BaseFetchManyApiPort; diff --git a/src/app/lists/domain/index.ts b/src/app/lists/domain/index.ts new file mode 100644 index 0000000..456a8d3 --- /dev/null +++ b/src/app/lists/domain/index.ts @@ -0,0 +1 @@ +export type { List } from "./list"; diff --git a/src/domain/entities/list.ts b/src/app/lists/domain/list.ts similarity index 100% rename from src/domain/entities/list.ts rename to src/app/lists/domain/list.ts diff --git a/src/app/lists/store.ts b/src/app/lists/store.ts index b7e8d11..6cf931e 100644 --- a/src/app/lists/store.ts +++ b/src/app/lists/store.ts @@ -1,6 +1,6 @@ -import type { List } from "@/domain/entities/list"; import { defineStore } from "pinia"; import { ref } from "vue"; +import type { List } from "./domain"; export const useListsStore = defineStore("lists", () => { const data = ref([] as List[]); diff --git a/src/infra/api/contact.ts b/src/infra/api/contact.ts index e7f204e..04eeff1 100644 --- a/src/infra/api/contact.ts +++ b/src/infra/api/contact.ts @@ -3,7 +3,7 @@ import type { ContactFormApiCreateProps, ContactsTableApiFetchManyProps, } from "@/app/contacts"; -import type { Contact } from "@/domain/entities/contact"; +import type { Contact } from "@/app/contacts/domain"; import type { EntityId } from "@/shared/lib/entity"; import { delay } from "@/shared/lib/utils/promise"; import { faker } from "@faker-js/faker"; diff --git a/src/infra/api/file.ts b/src/infra/api/file.ts index 9faf1f6..61dacd7 100644 --- a/src/infra/api/file.ts +++ b/src/infra/api/file.ts @@ -1,5 +1,5 @@ import type { FileApiPort } from "@/app/files"; -import type { AppFile } from "@/domain/entities/file"; +import type { AppFile } from "@/app/files/domain"; import { delay } from "@/shared/lib/utils/promise"; import { faker } from "@faker-js/faker"; diff --git a/src/infra/api/list.ts b/src/infra/api/list.ts index 872162e..5553912 100644 --- a/src/infra/api/list.ts +++ b/src/infra/api/list.ts @@ -1,5 +1,5 @@ import type { ListApiPort, ListFormApiCreateProps } from "@/app/lists"; -import type { List } from "@/domain/entities/list"; +import type { List } from "@/app/lists/domain"; import { delay } from "@/shared/lib/utils/promise"; import { faker } from "@faker-js/faker"; diff --git a/src/infra/api/template.ts b/src/infra/api/template.ts deleted file mode 100644 index 3ca019a..0000000 --- a/src/infra/api/template.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { faker } from "@faker-js/faker"; - -export class MockTemplateApi implements TemplateApiPort { - #templates: Template[]; - - constructor() { - this.#templates = Array.from(new Array(20).keys()).map((_) => { - const id = faker.datatype.uuid(); - const displayName = faker.lorem.words(3); - const createdAt = faker.date.birthdate(); - return { id, displayName, createdAt }; - }); - } - - async fetchMany(): Promise { - await delay(1000); - return this.#templates.concat(); - } -}