Skip to content

Commit

Permalink
refactor: rename to AccountModuleFacade
Browse files Browse the repository at this point in the history
  • Loading branch information
laminne committed Jul 24, 2024
1 parent ab313db commit 25f07f4
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 65 deletions.
21 changes: 14 additions & 7 deletions pkg/intermodule/adaptor/account.ts → pkg/intermodule/account.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { Result } from '@mikuroxina/mini-fn';
import type { Account, AccountID } from '../../accounts/model/account.js';
import type { FetchService } from '../../accounts/service/fetch.js';
import type { FetchFollowService } from '../../accounts/service/fetchFollow.js';
import type {
AccountModuleFacade,
PartialAccount,
} from '../interfaces/account.js';
Account,
AccountID,
AccountName,
} from '../accounts/model/account.js';
import type { FetchService } from '../accounts/service/fetch.js';
import type { FetchFollowService } from '../accounts/service/fetchFollow.js';

export class AccountModule implements AccountModuleFacade {
export interface PartialAccount {
id: AccountID;
name: AccountName;
nickname: string;
bio: string;
}

export class AccountModuleFacade {
constructor(
private readonly fetchService: FetchService,
private readonly fetchFollowService: FetchFollowService,
Expand Down
23 changes: 0 additions & 23 deletions pkg/intermodule/interfaces/account.ts

This file was deleted.

10 changes: 0 additions & 10 deletions pkg/intermodule/interfaces/timeline.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Result } from '@mikuroxina/mini-fn';
import type { Note } from '../../notes/model/note.js';
import type { PushTimelineService } from '../../timeline/service/push.js';
import type { Note } from '../notes/model/note.js';
import type { PushTimelineService } from '../timeline/service/push.js';

export class TimelineModule {
export class TimelineModuleFacade {
constructor(private readonly pushTimelineService: PushTimelineService) {}

Check warning on line 6 in pkg/intermodule/timeline.ts

View check run for this annotation

Codecov / codecov/patch

pkg/intermodule/timeline.ts#L5-L6

Added lines #L5 - L6 were not covered by tests

/*
Expand Down
2 changes: 1 addition & 1 deletion pkg/notes/adaptor/controller/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Option, Result } from '@mikuroxina/mini-fn';

import type { AccountID } from '../../../accounts/model/account.js';
import type { MediumID } from '../../../drive/model/medium.js';
import type { AccountModuleFacade } from '../../../intermodule/interfaces/account.js';
import type { AccountModuleFacade } from '../../../intermodule/account.js';
import type { NoteID, NoteVisibility } from '../../model/note.js';
import type { CreateService } from '../../service/create.js';
import type { FetchService } from '../../service/fetch.js';
Expand Down
7 changes: 2 additions & 5 deletions pkg/notes/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { prismaClient } from '../adaptors/prisma.js';
import { SnowflakeIDGenerator } from '../id/mod.js';
import type { ID } from '../id/type.js';
import { AccountModule } from '../intermodule/adaptor/account.js';
import { AccountModuleFacade } from '../intermodule/account.js';

Check warning on line 24 in pkg/notes/mod.ts

View check run for this annotation

Codecov / codecov/patch

pkg/notes/mod.ts#L24

Added line #L24 was not covered by tests
import { BookmarkController } from './adaptor/controller/bookmark.js';
import { NoteController } from './adaptor/controller/note.js';
import {
Expand Down Expand Up @@ -91,10 +91,7 @@ const accountFollowRepository = isProduction
? prismaFollowRepo(prismaClient)
: newFollowRepo();

Check warning on line 92 in pkg/notes/mod.ts

View check run for this annotation

Codecov / codecov/patch

pkg/notes/mod.ts#L90-L92

Added lines #L90 - L92 were not covered by tests

// const accountFetchService = new AccountFetchService(accountRepoObject);
// const accountFetchFollowservice = new FetchFollowService();

const accountModule = new AccountModule(
const accountModule = new AccountModuleFacade(
Ether.runEther(Cat.cat(fetch).feed(Ether.compose(accountRepository)).value),
Ether.runEther(
Cat.cat(fetchFollow)
Expand Down
4 changes: 2 additions & 2 deletions pkg/notes/service/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { Account, type AccountID } from '../../accounts/model/account.js';
import { FetchService as AccountFetchService } from '../../accounts/service/fetch.js';
import { FetchFollowService } from '../../accounts/service/fetchFollow.js';
import { AccountModule } from '../../intermodule/adaptor/account.js';
import { AccountModuleFacade } from '../../intermodule/account.js';
import { InMemoryNoteRepository } from '../adaptor/repository/dummy.js';
import { Note, type NoteID } from '../model/note.js';
import { FetchService } from './fetch.js';
Expand Down Expand Up @@ -91,7 +91,7 @@ const accountRepository = new InMemoryAccountRepository([
frozenAccount,
]);
const accountFollowRepository = new InMemoryAccountFollowRepository();
const accountModule = new AccountModule(
const accountModule = new AccountModuleFacade(
new AccountFetchService(accountRepository),
new FetchFollowService(accountFollowRepository, accountRepository),
);
Expand Down
2 changes: 1 addition & 1 deletion pkg/notes/service/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Option, Result } from '@mikuroxina/mini-fn';

import type { AccountModuleFacade } from '../../intermodule/interfaces/account.js';
import type { AccountModuleFacade } from '../../intermodule/account.js';
import type { Note, NoteID } from '../model/note.js';
import type { NoteRepository } from '../model/repository.js';

Expand Down
2 changes: 1 addition & 1 deletion pkg/timeline/adaptor/controller/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { z } from '@hono/zod-openapi';
import { Result } from '@mikuroxina/mini-fn';

import type { Account, AccountID } from '../../../accounts/model/account.js';
import type { AccountModuleFacade } from '../../../intermodule/interfaces/account.js';
import type { AccountModuleFacade } from '../../../intermodule/account.js';
import type { NoteID } from '../../../notes/model/note.js';
import type { ListID } from '../../model/list.js';
import type { AccountTimelineService } from '../../service/account.js';
Expand Down
4 changes: 2 additions & 2 deletions pkg/timeline/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { AccountID } from '../accounts/model/account.js';
import { FetchService as AccountFetchService } from '../accounts/service/fetch.js';
import { FetchFollowService } from '../accounts/service/fetchFollow.js';

Check warning on line 10 in pkg/timeline/mod.ts

View check run for this annotation

Codecov / codecov/patch

pkg/timeline/mod.ts#L9-L10

Added lines #L9 - L10 were not covered by tests
import { SnowflakeIDGenerator } from '../id/mod.js';
import { AccountModule } from '../intermodule/adaptor/account.js';
import { AccountModuleFacade } from '../intermodule/account.js';

Check warning on line 12 in pkg/timeline/mod.ts

View check run for this annotation

Codecov / codecov/patch

pkg/timeline/mod.ts#L12

Added line #L12 was not covered by tests
import { Note, type NoteID } from '../notes/model/note.js';
import { TimelineController } from './adaptor/controller/timeline.js';
import {
Expand All @@ -35,7 +35,7 @@ const idGenerator = new SnowflakeIDGenerator(0, {

const accountRepository = new InMemoryAccountRepository([]);
const accountFollowRepository = new InMemoryAccountFollowRepository();
const accountModule = new AccountModule(
const accountModule = new AccountModuleFacade(
new AccountFetchService(accountRepository),
new FetchFollowService(accountFollowRepository, accountRepository),
);

Check warning on line 41 in pkg/timeline/mod.ts

View check run for this annotation

Codecov / codecov/patch

pkg/timeline/mod.ts#L36-L41

Added lines #L36 - L41 were not covered by tests
Expand Down
6 changes: 3 additions & 3 deletions pkg/timeline/service/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
import { Account, type AccountID } from '../../accounts/model/account.js';
import { FetchService as AccountFetchService } from '../../accounts/service/fetch.js';
import { FetchFollowService } from '../../accounts/service/fetchFollow.js';
import { AccountModule } from '../../intermodule/adaptor/account.js';
import type { PartialAccount } from '../../intermodule/interfaces/account.js';
import { AccountModuleFacade } from '../../intermodule/account.js';
import type { PartialAccount } from '../../intermodule/account.js';
import { Note, type NoteID } from '../../notes/model/note.js';
import { InMemoryTimelineRepository } from '../adaptor/repository/dummy.js';
import { AccountTimelineService } from './account.js';
Expand All @@ -18,7 +18,7 @@ import { NoteVisibilityService } from './noteVisibility.js';
describe('AccountTimelineService', () => {
const accountRepository = new InMemoryAccountRepository([]);
const accountFollowRepository = new InMemoryAccountFollowRepository();
const accountModule = new AccountModule(
const accountModule = new AccountModuleFacade(
new AccountFetchService(accountRepository),
new FetchFollowService(accountFollowRepository, accountRepository),
);
Expand Down
4 changes: 2 additions & 2 deletions pkg/timeline/service/noteVisibility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import type { AccountID } from '../../accounts/model/account.js';
import { FetchService as AccountFetchService } from '../../accounts/service/fetch.js';
import { FetchFollowService } from '../../accounts/service/fetchFollow.js';
import { AccountModule } from '../../intermodule/adaptor/account.js';
import { AccountModuleFacade } from '../../intermodule/account.js';
import {
dummyDirectNote,
dummyFollowersNote,
Expand All @@ -21,7 +21,7 @@ import { NoteVisibilityService } from './noteVisibility.js';
describe('NoteVisibilityService', () => {
const accountRepository = new InMemoryAccountRepository([]);
const accountFollowRepository = new InMemoryAccountFollowRepository();
const accountModule = new AccountModule(
const accountModule = new AccountModuleFacade(
new AccountFetchService(accountRepository),
new FetchFollowService(accountFollowRepository, accountRepository),
);
Expand Down
2 changes: 1 addition & 1 deletion pkg/timeline/service/noteVisibility.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ether, Option, Result } from '@mikuroxina/mini-fn';

import type { AccountID } from '../../accounts/model/account.js';
import type { AccountModuleFacade } from '../../intermodule/interfaces/account.js';
import type { AccountModuleFacade } from '../../intermodule/account.js';
import type { Note } from '../../notes/model/note.js';

export interface NoteVisibilityCheckArgs {
Expand Down
4 changes: 2 additions & 2 deletions pkg/timeline/service/push.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '../../accounts/adaptor/repository/dummy.js';
import { FetchService as AccountFetchService } from '../../accounts/service/fetch.js';
import { FetchFollowService } from '../../accounts/service/fetchFollow.js';
import { AccountModule } from '../../intermodule/adaptor/account.js';
import { AccountModuleFacade } from '../../intermodule/account.js';
import { InMemoryTimelineCacheRepository } from '../adaptor/repository/dummyCache.js';
import { dummyPublicNote, partialAccount1 } from '../testData/testData.js';
import { NoteVisibilityService } from './noteVisibility.js';
Expand All @@ -16,7 +16,7 @@ import { PushTimelineService } from './push.js';
describe('PushTimelineService', () => {
const accountRepository = new InMemoryAccountRepository([]);
const accountFollowRepository = new InMemoryAccountFollowRepository();
const accountModule = new AccountModule(
const accountModule = new AccountModuleFacade(
new AccountFetchService(accountRepository),
new FetchFollowService(accountFollowRepository, accountRepository),
);
Expand Down
2 changes: 1 addition & 1 deletion pkg/timeline/service/push.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Result } from '@mikuroxina/mini-fn';

import type { AccountModuleFacade } from '../../intermodule/interfaces/account.js';
import type { AccountModuleFacade } from '../../intermodule/account.js';
import type { Note } from '../../notes/model/note.js';
import type { TimelineNotesCacheRepository } from '../model/repository.js';
import type { NoteVisibilityService } from './noteVisibility.js';
Expand Down
2 changes: 1 addition & 1 deletion pkg/timeline/testData/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Option } from '@mikuroxina/mini-fn';

import { Account, type AccountID } from '../../accounts/model/account.js';
import type { PartialAccount } from '../../intermodule/interfaces/account.js';
import type { PartialAccount } from '../../intermodule/account.js';
import { Note, type NoteID } from '../../notes/model/note.js';

export const dummyPublicNote = Note.new({
Expand Down

0 comments on commit 25f07f4

Please sign in to comment.