refac: move common utils and interfaces to shared lib
This commit is contained in:
parent
9b30f3595d
commit
92dce58451
19 changed files with 23 additions and 27 deletions
|
@ -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;
|
||||
|
|
|
@ -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(() => [
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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>;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>;
|
||||
|
|
|
@ -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>;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Entity } from "../common/entity";
|
||||
import type { Entity } from "@/shared/lib/entity";
|
||||
|
||||
export interface Contact extends Entity {
|
||||
email: string;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Entity } from "../common/entity";
|
||||
import type { Entity } from "@/shared/lib/entity";
|
||||
|
||||
export interface AppFile extends Entity {
|
||||
name: string;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Entity } from "../common/entity";
|
||||
import type { Entity } from "@/shared/lib/entity";
|
||||
|
||||
export interface List extends Entity {
|
||||
displayName: string;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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[];
|
||||
|
|
|
@ -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[]>;
|
7
src/shared/lib/utils/date.ts
Normal file
7
src/shared/lib/utils/date.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
export function formatDate(date: Date): string {
|
||||
return date.toLocaleDateString(undefined, {
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
});
|
||||
}
|
|
@ -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));
|
Loading…
Reference in a new issue