refac: move common utils and interfaces to shared lib

This commit is contained in:
Dmitriy Pleshevskiy 2023-01-31 17:52:49 +03:00
parent 9b30f3595d
commit 92dce58451
Signed by: pleshevskiy
GPG Key ID: 1B59187B161C0215
19 changed files with 23 additions and 27 deletions

View File

@ -1,5 +1,5 @@
import type { BaseCreateApiPort } from "@/app/common/ports";
import type { Contact } from "@/domain/entities/contact";
import type { BaseCreateApiPort } from "@/shared/lib/ports";
export interface ContactFormApiCreateProps {
email: string;

View File

@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed, watch } from "vue";
import { formatDate } from "@/utils";
import { formatDate } from "@/shared/lib/utils/date";
import { useContactsTableStore } from "./store";
const columns = computed(() => [

View File

@ -1,6 +1,6 @@
import type { BaseFetchManyApiPort } from "@/app/common/ports";
import type { EntityId } from "@/domain/common/entity";
import type { Contact } from "@/domain/entities/contact";
import type { EntityId } from "@/shared/lib/entity";
import type { BaseFetchManyApiPort } from "@/shared/lib/ports";
export interface ContactsTableApiFetchManyProps {
listId?: EntityId;

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed } from "vue";
import { useFilesTableStore } from "./store";
import { formatDate } from "@/utils";
import { formatDate } from "@/shared/lib/utils/date";
const filesStore = useFilesTableStore();

View File

@ -1,4 +1,4 @@
import type { BaseFetchManyApiPort } from "@/app/common/ports";
import type { AppFile } from "@/domain/entities/file";
import type { BaseFetchManyApiPort } from "@/shared/lib/ports";
export type FilesTableApiPort = BaseFetchManyApiPort<AppFile>;

View File

@ -1,5 +1,5 @@
import type { BaseCreateApiPort } from "@/app/common/ports";
import type { List } from "@/domain/entities/list";
import type { BaseCreateApiPort } from "@/shared/lib/ports";
export interface ListFormApiCreateProps {
displayName: string;

View File

@ -1,4 +1,4 @@
import type { BaseFetchManyApiPort } from "@/app/common/ports";
import type { List } from "@/domain/entities/list";
import type { BaseFetchManyApiPort } from "@/shared/lib/ports";
export type ListsSelectApiPort = BaseFetchManyApiPort<List>;

View File

@ -1,4 +1,4 @@
import type { BaseFetchManyApiPort } from "@/app/common/ports";
import type { List } from "@/domain/entities/list";
import type { BaseFetchManyApiPort } from "@/shared/lib/ports";
export type ListsTableApiPort = BaseFetchManyApiPort<List>;

View File

@ -1,4 +1,4 @@
import type { Entity } from "../common/entity";
import type { Entity } from "@/shared/lib/entity";
export interface Contact extends Entity {
email: string;

View File

@ -1,4 +1,4 @@
import type { Entity } from "../common/entity";
import type { Entity } from "@/shared/lib/entity";
export interface AppFile extends Entity {
name: string;

View File

@ -1,4 +1,4 @@
import type { Entity } from "../common/entity";
import type { Entity } from "@/shared/lib/entity";
export interface List extends Entity {
displayName: string;

View File

@ -5,7 +5,7 @@ import type {
} from "@/app/contacts";
import type { EntityId } from "@/domain/common/entity";
import type { Contact } from "@/domain/entities/contact";
import { delay } from "@/utils";
import { delay } from "@/shared/lib/utils/promise";
import { faker } from "@faker-js/faker";
let $instance: MockContactApi | undefined;

View File

@ -1,6 +1,6 @@
import type { FileApiPort } from "@/app/files";
import type { AppFile } from "@/domain/entities/file";
import { delay } from "@/utils";
import { delay } from "@/shared/lib/utils/promise";
import { faker } from "@faker-js/faker";
let $instance: FileApiPort | undefined;

View File

@ -1,6 +1,6 @@
import type { ListApiPort, ListFormApiCreateProps } from "@/app/lists";
import type { List } from "@/domain/entities/list";
import { delay } from "@/utils";
import { delay } from "@/shared/lib/utils/promise";
import { faker } from "@faker-js/faker";
let $instance: ListApiPort | undefined;

View File

@ -1,7 +1,4 @@
import type { TemplateApiPort } from "@/app_core/ports/template";
import { delay } from "@/utils";
import { faker } from "@faker-js/faker";
import type { Template } from "../domain/template";
export class MockTemplateApi implements TemplateApiPort {
#templates: Template[];

View File

@ -1,4 +1,4 @@
import type { Entity } from "@/domain/common/entity";
import type { Entity } from "./entity";
export interface BaseFetchManyApiPort<E extends Entity, P = unknown> {
fetchMany(props: P): Promise<E[]>;

View File

@ -0,0 +1,7 @@
export function formatDate(date: Date): string {
return date.toLocaleDateString(undefined, {
year: "numeric",
month: "2-digit",
day: "2-digit",
});
}

View File

@ -1,11 +1,3 @@
export function formatDate(date: Date): string {
return date.toLocaleDateString(undefined, {
year: "numeric",
month: "2-digit",
day: "2-digit",
});
}
// This util is very useful for mocks to emulate http delay
export async function delay(timeout: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, timeout));