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 { Contact } from "@/domain/entities/contact";
|
||||||
|
import type { BaseCreateApiPort } from "@/shared/lib/ports";
|
||||||
|
|
||||||
export interface ContactFormApiCreateProps {
|
export interface ContactFormApiCreateProps {
|
||||||
email: string;
|
email: string;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, watch } from "vue";
|
import { computed, watch } from "vue";
|
||||||
import { formatDate } from "@/utils";
|
import { formatDate } from "@/shared/lib/utils/date";
|
||||||
import { useContactsTableStore } from "./store";
|
import { useContactsTableStore } from "./store";
|
||||||
|
|
||||||
const columns = computed(() => [
|
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 { Contact } from "@/domain/entities/contact";
|
||||||
|
import type { EntityId } from "@/shared/lib/entity";
|
||||||
|
import type { BaseFetchManyApiPort } from "@/shared/lib/ports";
|
||||||
|
|
||||||
export interface ContactsTableApiFetchManyProps {
|
export interface ContactsTableApiFetchManyProps {
|
||||||
listId?: EntityId;
|
listId?: EntityId;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { useFilesTableStore } from "./store";
|
import { useFilesTableStore } from "./store";
|
||||||
import { formatDate } from "@/utils";
|
import { formatDate } from "@/shared/lib/utils/date";
|
||||||
|
|
||||||
const filesStore = useFilesTableStore();
|
const filesStore = useFilesTableStore();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { BaseFetchManyApiPort } from "@/app/common/ports";
|
|
||||||
import type { AppFile } from "@/domain/entities/file";
|
import type { AppFile } from "@/domain/entities/file";
|
||||||
|
import type { BaseFetchManyApiPort } from "@/shared/lib/ports";
|
||||||
|
|
||||||
export type FilesTableApiPort = BaseFetchManyApiPort<AppFile>;
|
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 { List } from "@/domain/entities/list";
|
||||||
|
import type { BaseCreateApiPort } from "@/shared/lib/ports";
|
||||||
|
|
||||||
export interface ListFormApiCreateProps {
|
export interface ListFormApiCreateProps {
|
||||||
displayName: string;
|
displayName: string;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { BaseFetchManyApiPort } from "@/app/common/ports";
|
|
||||||
import type { List } from "@/domain/entities/list";
|
import type { List } from "@/domain/entities/list";
|
||||||
|
import type { BaseFetchManyApiPort } from "@/shared/lib/ports";
|
||||||
|
|
||||||
export type ListsSelectApiPort = BaseFetchManyApiPort<List>;
|
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 { List } from "@/domain/entities/list";
|
||||||
|
import type { BaseFetchManyApiPort } from "@/shared/lib/ports";
|
||||||
|
|
||||||
export type ListsTableApiPort = BaseFetchManyApiPort<List>;
|
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 {
|
export interface Contact extends Entity {
|
||||||
email: string;
|
email: string;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Entity } from "../common/entity";
|
import type { Entity } from "@/shared/lib/entity";
|
||||||
|
|
||||||
export interface AppFile extends Entity {
|
export interface AppFile extends Entity {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Entity } from "../common/entity";
|
import type { Entity } from "@/shared/lib/entity";
|
||||||
|
|
||||||
export interface List extends Entity {
|
export interface List extends Entity {
|
||||||
displayName: string;
|
displayName: string;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import type {
|
||||||
} from "@/app/contacts";
|
} from "@/app/contacts";
|
||||||
import type { EntityId } from "@/domain/common/entity";
|
import type { EntityId } from "@/domain/common/entity";
|
||||||
import type { Contact } from "@/domain/entities/contact";
|
import type { Contact } from "@/domain/entities/contact";
|
||||||
import { delay } from "@/utils";
|
import { delay } from "@/shared/lib/utils/promise";
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
|
|
||||||
let $instance: MockContactApi | undefined;
|
let $instance: MockContactApi | undefined;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { FileApiPort } from "@/app/files";
|
import type { FileApiPort } from "@/app/files";
|
||||||
import type { AppFile } from "@/domain/entities/file";
|
import type { AppFile } from "@/domain/entities/file";
|
||||||
import { delay } from "@/utils";
|
import { delay } from "@/shared/lib/utils/promise";
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
|
|
||||||
let $instance: FileApiPort | undefined;
|
let $instance: FileApiPort | undefined;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { ListApiPort, ListFormApiCreateProps } from "@/app/lists";
|
import type { ListApiPort, ListFormApiCreateProps } from "@/app/lists";
|
||||||
import type { List } from "@/domain/entities/list";
|
import type { List } from "@/domain/entities/list";
|
||||||
import { delay } from "@/utils";
|
import { delay } from "@/shared/lib/utils/promise";
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
|
|
||||||
let $instance: ListApiPort | undefined;
|
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 { faker } from "@faker-js/faker";
|
||||||
import type { Template } from "../domain/template";
|
|
||||||
|
|
||||||
export class MockTemplateApi implements TemplateApiPort {
|
export class MockTemplateApi implements TemplateApiPort {
|
||||||
#templates: Template[];
|
#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> {
|
export interface BaseFetchManyApiPort<E extends Entity, P = unknown> {
|
||||||
fetchMany(props: P): Promise<E[]>;
|
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
|
// This util is very useful for mocks to emulate http delay
|
||||||
export async function delay(timeout: number): Promise<void> {
|
export async function delay(timeout: number): Promise<void> {
|
||||||
return new Promise((resolve) => setTimeout(resolve, timeout));
|
return new Promise((resolve) => setTimeout(resolve, timeout));
|
Loading…
Reference in a new issue