refactor(features): split entities into models/ + errors/ subdirs
All 5 features (auth, blog, marketing-pages, navigation; media has no entities yet) now follow Lazar's pattern: - entities/<x>.ts → entities/models/<x>.ts - entities/errors.ts → entities/errors/<domain>.ts + errors/common.ts Updates all import paths across factories, contracts, tests, use cases, controllers, repositories, integrations, and src/index.ts exports. navigation divergence: had no errors.ts; errors/header.ts + errors/common.ts added as new forward-looking stubs. Refactor log: docs/superpowers/refactor-logs/2026-05-05-lazar-pattern-conformance.md Spec: §5, §9.3 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,15 +20,47 @@ single follow-up pass.
|
||||
|
||||
## 1. File renames (before → after)
|
||||
|
||||
(populated as work progresses)
|
||||
### Task 2: Entities split
|
||||
|
||||
Entity model moves (git mv — history preserved):
|
||||
- `packages/auth/src/entities/user.ts` → `packages/auth/src/entities/models/user.ts`
|
||||
- `packages/auth/src/entities/user.test.ts` → `packages/auth/src/entities/models/user.test.ts`
|
||||
- `packages/auth/src/entities/session.ts` → `packages/auth/src/entities/models/session.ts`
|
||||
- `packages/auth/src/entities/session.test.ts` → `packages/auth/src/entities/models/session.test.ts`
|
||||
- `packages/auth/src/entities/cookie.ts` → `packages/auth/src/entities/models/cookie.ts`
|
||||
- `packages/auth/src/entities/errors.test.ts` → `packages/auth/src/entities/errors/errors.test.ts`
|
||||
- `packages/blog/src/entities/article.ts` → `packages/blog/src/entities/models/article.ts`
|
||||
- `packages/blog/src/entities/article.test.ts` → `packages/blog/src/entities/models/article.test.ts`
|
||||
- `packages/blog/src/entities/errors.test.ts` → `packages/blog/src/entities/errors/errors.test.ts`
|
||||
- `packages/marketing-pages/src/entities/page.ts` → `packages/marketing-pages/src/entities/models/page.ts`
|
||||
- `packages/marketing-pages/src/entities/page.test.ts` → `packages/marketing-pages/src/entities/models/page.test.ts`
|
||||
- `packages/marketing-pages/src/entities/site-settings.ts` → `packages/marketing-pages/src/entities/models/site-settings.ts`
|
||||
- `packages/marketing-pages/src/entities/site-settings.test.ts` → `packages/marketing-pages/src/entities/models/site-settings.test.ts`
|
||||
- `packages/marketing-pages/src/entities/errors.test.ts` → `packages/marketing-pages/src/entities/errors/errors.test.ts`
|
||||
- `packages/navigation/src/entities/header.ts` → `packages/navigation/src/entities/models/header.ts`
|
||||
- `packages/navigation/src/entities/header.test.ts` → `packages/navigation/src/entities/models/header.test.ts`
|
||||
|
||||
## 2. Files added (with purpose)
|
||||
|
||||
(populated as work progresses)
|
||||
### Task 2: Entities split — new error files
|
||||
|
||||
- `packages/auth/src/entities/errors/auth.ts` — AuthenticationError, UnauthenticatedError, UnauthorizedError (split from errors.ts)
|
||||
- `packages/auth/src/entities/errors/common.ts` — InputParseError (auth copy)
|
||||
- `packages/blog/src/entities/errors/article.ts` — ArticleNotFoundError (split from errors.ts)
|
||||
- `packages/blog/src/entities/errors/common.ts` — InputParseError (blog copy)
|
||||
- `packages/marketing-pages/src/entities/errors/page.ts` — PageNotFoundError (split from errors.ts)
|
||||
- `packages/marketing-pages/src/entities/errors/common.ts` — InputParseError (marketing-pages copy)
|
||||
- `packages/navigation/src/entities/errors/header.ts` — HeaderNotFoundError (new; navigation had no errors.ts)
|
||||
- `packages/navigation/src/entities/errors/common.ts` — InputParseError (navigation copy)
|
||||
|
||||
## 3. Files deleted (with reason)
|
||||
|
||||
(populated as work progresses)
|
||||
### Task 2: Entities split — old errors.ts files removed
|
||||
|
||||
- `packages/auth/src/entities/errors.ts` — replaced by `errors/auth.ts` + `errors/common.ts`
|
||||
- `packages/blog/src/entities/errors.ts` — replaced by `errors/article.ts` + `errors/common.ts`
|
||||
- `packages/marketing-pages/src/entities/errors.ts` — replaced by `errors/page.ts` + `errors/common.ts`
|
||||
- (navigation had no `errors.ts` to delete)
|
||||
|
||||
## 4. Pattern changes (code-level)
|
||||
|
||||
@@ -39,7 +71,15 @@ single follow-up pass.
|
||||
(populated when controllers are split)
|
||||
|
||||
### 4.3 Entities split — models/ + errors/ subdirs
|
||||
(populated when entities are reshaped)
|
||||
|
||||
Pattern now in place across auth, blog, marketing-pages, navigation (media skipped — no entities yet):
|
||||
|
||||
- Entity Zod schemas + types live at `entities/models/<x>.ts`
|
||||
- Domain errors live at `entities/errors/<domain>.ts` (e.g. `errors/auth.ts`, `errors/article.ts`)
|
||||
- Shared `InputParseError` lives at `entities/errors/common.ts` (one copy per feature — ~6 lines each)
|
||||
- Colocated entity test files moved alongside their respective sources (`models/*.test.ts`, `errors/errors.test.ts`)
|
||||
- All imports across factories, contracts, repositories, use cases, controllers, tests, and `src/index.ts` updated to new paths
|
||||
- navigation divergence: no `errors.ts` existed pre-refactor; `errors/header.ts` (HeaderNotFoundError) and `errors/common.ts` added as new forward-looking stubs
|
||||
|
||||
## 5. DI changes
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineFactory } from "@repo/core-testing/factory";
|
||||
import type { Session } from "../entities/session.js";
|
||||
import type { Session } from "../entities/models/session.js";
|
||||
|
||||
export const sessionFactory = defineFactory<Session>(({ sequence }) => ({
|
||||
id: `session-${sequence}`,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineFactory } from "@repo/core-testing/factory";
|
||||
import type { User } from "../entities/user.js";
|
||||
import type { User } from "../entities/models/user.js";
|
||||
|
||||
export const userFactory = defineFactory<User>(({ sequence }) => ({
|
||||
id: `user-${sequence}`,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { User } from "../../entities/user";
|
||||
import type { User } from "../../entities/models/user";
|
||||
|
||||
export interface IUsersRepository {
|
||||
getUser(id: string): Promise<User | undefined>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Cookie } from "../../entities/cookie";
|
||||
import type { Session } from "../../entities/session";
|
||||
import type { User } from "../../entities/user";
|
||||
import type { Cookie } from "../../entities/models/cookie";
|
||||
import type { Session } from "../../entities/models/session";
|
||||
import type { User } from "../../entities/models/user";
|
||||
|
||||
export interface IAuthenticationService {
|
||||
generateUserId(): string;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { MockUsersRepository } from "@/infrastructure/repositories/mock-users.re
|
||||
import { MockAuthenticationService } from "@/infrastructure/services/mock-authentication.service";
|
||||
import type { IUsersRepository } from "@/application/repositories/users-repository.interface";
|
||||
import type { IAuthenticationService } from "@/application/services/authentication-service.interface";
|
||||
import { AuthenticationError } from "@/entities/errors";
|
||||
import { AuthenticationError } from "@/entities/errors/auth";
|
||||
import { signInUseCase } from "./sign-in.use-case";
|
||||
|
||||
describe("signInUseCase", () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AuthenticationError } from "../../entities/errors";
|
||||
import type { Cookie } from "../../entities/cookie";
|
||||
import type { Session } from "../../entities/session";
|
||||
import { AuthenticationError } from "../../entities/errors/auth";
|
||||
import type { Cookie } from "../../entities/models/cookie";
|
||||
import type { Session } from "../../entities/models/session";
|
||||
import { authContainer } from "../../di/container";
|
||||
import { AUTH_SYMBOLS } from "../../di/symbols";
|
||||
import type { IUsersRepository } from "../repositories/users-repository.interface";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Cookie } from "../../entities/cookie";
|
||||
import type { Cookie } from "../../entities/models/cookie";
|
||||
import { authContainer } from "../../di/container";
|
||||
import { AUTH_SYMBOLS } from "../../di/symbols";
|
||||
import type { IAuthenticationService } from "../services/authentication-service.interface";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { MockUsersRepository } from "@/infrastructure/repositories/mock-users.re
|
||||
import { MockAuthenticationService } from "@/infrastructure/services/mock-authentication.service";
|
||||
import type { IUsersRepository } from "@/application/repositories/users-repository.interface";
|
||||
import type { IAuthenticationService } from "@/application/services/authentication-service.interface";
|
||||
import { AuthenticationError } from "@/entities/errors";
|
||||
import { AuthenticationError } from "@/entities/errors/auth";
|
||||
import { signUpUseCase } from "./sign-up.use-case";
|
||||
|
||||
describe("signUpUseCase", () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AuthenticationError } from "../../entities/errors";
|
||||
import type { Cookie } from "../../entities/cookie";
|
||||
import type { Session } from "../../entities/session";
|
||||
import type { User } from "../../entities/user";
|
||||
import { AuthenticationError } from "../../entities/errors/auth";
|
||||
import type { Cookie } from "../../entities/models/cookie";
|
||||
import type { Session } from "../../entities/models/session";
|
||||
import type { User } from "../../entities/models/user";
|
||||
import { authContainer } from "../../di/container";
|
||||
import { AUTH_SYMBOLS } from "../../di/symbols";
|
||||
import type { IUsersRepository } from "../repositories/users-repository.interface";
|
||||
|
||||
@@ -15,9 +15,3 @@ export class UnauthorizedError extends Error {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class InputParseError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
5
packages/auth/src/entities/errors/common.ts
Normal file
5
packages/auth/src/entities/errors/common.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export class InputParseError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
AuthenticationError,
|
||||
UnauthenticatedError,
|
||||
UnauthorizedError,
|
||||
InputParseError,
|
||||
} from "./errors";
|
||||
} from "./auth";
|
||||
import { InputParseError } from "./common";
|
||||
|
||||
describe("AuthenticationError", () => {
|
||||
it("is an instance of Error with the given message", () => {
|
||||
@@ -1,11 +1,11 @@
|
||||
export type { User } from "./entities/user";
|
||||
export type { Session } from "./entities/session";
|
||||
export type { Cookie } from "./entities/cookie";
|
||||
export type { User } from "./entities/models/user";
|
||||
export type { Session } from "./entities/models/session";
|
||||
export type { Cookie } from "./entities/models/cookie";
|
||||
export type { AuthRouter } from "./integrations/api/router";
|
||||
export {
|
||||
AuthenticationError,
|
||||
UnauthenticatedError,
|
||||
UnauthorizedError,
|
||||
InputParseError,
|
||||
} from "./entities/errors";
|
||||
} from "./entities/errors/auth";
|
||||
export { InputParseError } from "./entities/errors/common";
|
||||
export { SESSION_COOKIE } from "./config";
|
||||
|
||||
@@ -2,7 +2,7 @@ import "reflect-metadata";
|
||||
import { injectable } from "inversify";
|
||||
|
||||
import type { IUsersRepository } from "../../application/repositories/users-repository.interface";
|
||||
import type { User } from "../../entities/user";
|
||||
import type { User } from "../../entities/models/user";
|
||||
|
||||
const DEFAULT_SEED: User[] = [
|
||||
{ id: "1", username: "alice", passwordHash: "hashed_password_alice" },
|
||||
|
||||
@@ -3,10 +3,10 @@ import { inject, injectable } from "inversify";
|
||||
|
||||
import type { IAuthenticationService } from "../../application/services/authentication-service.interface";
|
||||
import type { IUsersRepository } from "../../application/repositories/users-repository.interface";
|
||||
import { UnauthenticatedError } from "../../entities/errors";
|
||||
import { sessionSchema, type Session } from "../../entities/session";
|
||||
import type { Cookie } from "../../entities/cookie";
|
||||
import type { User } from "../../entities/user";
|
||||
import { UnauthenticatedError } from "../../entities/errors/auth";
|
||||
import { sessionSchema, type Session } from "../../entities/models/session";
|
||||
import type { Cookie } from "../../entities/models/cookie";
|
||||
import type { User } from "../../entities/models/user";
|
||||
import { AUTH_SYMBOLS } from "../../di/symbols";
|
||||
import { SESSION_COOKIE } from "../../config";
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { MockUsersRepository } from "@/infrastructure/repositories/mock-users.re
|
||||
import { MockAuthenticationService } from "@/infrastructure/services/mock-authentication.service";
|
||||
import type { IUsersRepository } from "@/application/repositories/users-repository.interface";
|
||||
import type { IAuthenticationService } from "@/application/services/authentication-service.interface";
|
||||
import { InputParseError } from "@/entities/errors";
|
||||
import { InputParseError } from "@/entities/errors/common";
|
||||
import { signInController } from "./sign-in.controller";
|
||||
|
||||
describe("signInController", () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { InputParseError } from "../../entities/errors";
|
||||
import type { Cookie } from "../../entities/cookie";
|
||||
import { InputParseError } from "../../entities/errors/common";
|
||||
import type { Cookie } from "../../entities/models/cookie";
|
||||
import { signInUseCase } from "../../application/use-cases/sign-in.use-case";
|
||||
|
||||
const inputSchema = z.object({
|
||||
|
||||
@@ -5,7 +5,7 @@ import { MockUsersRepository } from "@/infrastructure/repositories/mock-users.re
|
||||
import { MockAuthenticationService } from "@/infrastructure/services/mock-authentication.service";
|
||||
import type { IUsersRepository } from "@/application/repositories/users-repository.interface";
|
||||
import type { IAuthenticationService } from "@/application/services/authentication-service.interface";
|
||||
import { InputParseError } from "@/entities/errors";
|
||||
import { InputParseError } from "@/entities/errors/common";
|
||||
import { signOutController } from "./sign-out.controller";
|
||||
|
||||
describe("signOutController", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { InputParseError } from "../../entities/errors";
|
||||
import type { Cookie } from "../../entities/cookie";
|
||||
import { InputParseError } from "../../entities/errors/common";
|
||||
import type { Cookie } from "../../entities/models/cookie";
|
||||
import { signOutUseCase } from "../../application/use-cases/sign-out.use-case";
|
||||
|
||||
export async function signOutController(
|
||||
|
||||
@@ -5,7 +5,7 @@ import { MockUsersRepository } from "@/infrastructure/repositories/mock-users.re
|
||||
import { MockAuthenticationService } from "@/infrastructure/services/mock-authentication.service";
|
||||
import type { IUsersRepository } from "@/application/repositories/users-repository.interface";
|
||||
import type { IAuthenticationService } from "@/application/services/authentication-service.interface";
|
||||
import { InputParseError } from "@/entities/errors";
|
||||
import { InputParseError } from "@/entities/errors/common";
|
||||
import { signUpController } from "./sign-up.controller";
|
||||
|
||||
describe("signUpController", () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { InputParseError } from "../../entities/errors";
|
||||
import { InputParseError } from "../../entities/errors/common";
|
||||
import { signUpUseCase } from "../../application/use-cases/sign-up.use-case";
|
||||
|
||||
const inputSchema = z
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineFactory } from "@repo/core-testing/factory";
|
||||
import type { Article } from "../entities/article.js";
|
||||
import type { Article } from "../entities/models/article.js";
|
||||
|
||||
export const articleFactory = defineFactory<Article>(({ sequence }) => ({
|
||||
id: `article-${sequence}`,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Article } from "../../entities/article";
|
||||
import type { Article } from "../../entities/models/article";
|
||||
|
||||
export interface IArticlesRepository {
|
||||
getArticle(id: string): Promise<Article | undefined>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Article } from "../../entities/article";
|
||||
import type { Article } from "../../entities/models/article";
|
||||
import { blogContainer } from "../../di/container";
|
||||
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||
import type { IArticlesRepository } from "../repositories/articles-repository.interface";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Article } from "../../entities/article";
|
||||
import type { Article } from "../../entities/models/article";
|
||||
import { blogContainer } from "../../di/container";
|
||||
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||
import type { IArticlesRepository } from "../repositories/articles-repository.interface";
|
||||
|
||||
@@ -3,9 +3,3 @@ export class ArticleNotFoundError extends Error {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class InputParseError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
5
packages/blog/src/entities/errors/common.ts
Normal file
5
packages/blog/src/entities/errors/common.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export class InputParseError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { ArticleNotFoundError, InputParseError } from "./errors";
|
||||
import { ArticleNotFoundError } from "./article";
|
||||
import { InputParseError } from "./common";
|
||||
|
||||
describe("ArticleNotFoundError", () => {
|
||||
it("uses the default message when none is given", () => {
|
||||
@@ -1,4 +1,5 @@
|
||||
export type { Article, ArticleStatus } from "./entities/article";
|
||||
export type { Article, ArticleStatus } from "./entities/models/article";
|
||||
export type { BlogRouter } from "./integrations/api/router";
|
||||
export { ArticleNotFoundError, InputParseError } from "./entities/errors";
|
||||
export { ArticleNotFoundError } from "./entities/errors/article";
|
||||
export { InputParseError } from "./entities/errors/common";
|
||||
export { articleBySlugQuery, listArticlesQuery } from "./ui/query";
|
||||
|
||||
@@ -2,7 +2,7 @@ import "reflect-metadata";
|
||||
import { injectable } from "inversify";
|
||||
|
||||
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||
import type { Article } from "../../entities/article";
|
||||
import type { Article } from "../../entities/models/article";
|
||||
|
||||
@injectable()
|
||||
export class MockArticlesRepository implements IArticlesRepository {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { getPayload } from "payload";
|
||||
import type { SanitizedConfig } from "payload";
|
||||
|
||||
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||
import type { Article } from "../../entities/article";
|
||||
import type { Article } from "../../entities/models/article";
|
||||
|
||||
type PayloadArticleDoc = {
|
||||
id: string | number;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { blogContainer } from "../../di/container";
|
||||
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||
import { MockArticlesRepository } from "../../infrastructure/repositories/mock-articles.repository";
|
||||
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||
import { InputParseError } from "../../entities/errors";
|
||||
import { InputParseError } from "../../entities/errors/common";
|
||||
import {
|
||||
createArticleController,
|
||||
getArticlesController,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { InputParseError } from "../../entities/errors";
|
||||
import type { Article } from "../../entities/article";
|
||||
import { InputParseError } from "../../entities/errors/common";
|
||||
import type { Article } from "../../entities/models/article";
|
||||
import { blogContainer } from "../../di/container";
|
||||
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { it, expect, beforeEach } from "vitest";
|
||||
import { defineContractSuite } from "@repo/core-testing/contract";
|
||||
import type { IPagesRepository } from "../application/repositories/pages-repository.interface.js";
|
||||
import type { Page } from "../entities/page.js";
|
||||
import type { Page } from "../entities/models/page.js";
|
||||
|
||||
const SEED_DATE = new Date("2026-01-01T00:00:00.000Z");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineFactory } from "@repo/core-testing/factory";
|
||||
import type { Page } from "../entities/page.js";
|
||||
import type { Page } from "../entities/models/page.js";
|
||||
|
||||
export const pageFactory = defineFactory<Page>(({ sequence }) => ({
|
||||
id: `page-${sequence}`,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineFactory } from "@repo/core-testing/factory";
|
||||
import type { SiteSettings } from "../entities/site-settings.js";
|
||||
import type { SiteSettings } from "../entities/models/site-settings.js";
|
||||
|
||||
export const siteSettingsFactory = defineFactory<SiteSettings>(({ sequence }) => ({
|
||||
siteName: `Site ${sequence}`,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Page } from "../../entities/page";
|
||||
import type { Page } from "../../entities/models/page";
|
||||
|
||||
export interface IPagesRepository {
|
||||
getPageBySlug(slug: string): Promise<Page | undefined>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SiteSettings } from "../../entities/site-settings";
|
||||
import type { SiteSettings } from "../../entities/models/site-settings";
|
||||
|
||||
export interface ISiteSettingsRepository {
|
||||
getSiteSettings(): Promise<SiteSettings>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Page } from "../../entities/page";
|
||||
import type { Page } from "../../entities/models/page";
|
||||
import { marketingPagesContainer } from "../../di/container";
|
||||
import { MARKETING_PAGES_SYMBOLS } from "../../di/symbols";
|
||||
import type { IPagesRepository } from "../repositories/pages-repository.interface";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SiteSettings } from "../../entities/site-settings";
|
||||
import type { SiteSettings } from "../../entities/models/site-settings";
|
||||
import { marketingPagesContainer } from "../../di/container";
|
||||
import { MARKETING_PAGES_SYMBOLS } from "../../di/symbols";
|
||||
import type { ISiteSettingsRepository } from "../repositories/site-settings-repository.interface";
|
||||
|
||||
5
packages/marketing-pages/src/entities/errors/common.ts
Normal file
5
packages/marketing-pages/src/entities/errors/common.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export class InputParseError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { PageNotFoundError, InputParseError } from "./errors";
|
||||
import { PageNotFoundError } from "./page";
|
||||
import { InputParseError } from "./common";
|
||||
|
||||
describe("PageNotFoundError", () => {
|
||||
it("uses the default message when none is given", () => {
|
||||
@@ -3,9 +3,3 @@ export class PageNotFoundError extends Error {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class InputParseError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
export type { Page, PageStatus, Hero } from "./entities/page";
|
||||
export type { SiteSettings } from "./entities/site-settings";
|
||||
export type { Page, PageStatus, Hero } from "./entities/models/page";
|
||||
export type { SiteSettings } from "./entities/models/site-settings";
|
||||
export type { MarketingPagesRouter } from "./integrations/api/router";
|
||||
export { PageNotFoundError, InputParseError } from "./entities/errors";
|
||||
export { PageNotFoundError } from "./entities/errors/page";
|
||||
export { InputParseError } from "./entities/errors/common";
|
||||
export { pageBySlugQuery, siteSettingsQuery } from "./ui/query";
|
||||
|
||||
@@ -2,7 +2,7 @@ import "reflect-metadata";
|
||||
import { injectable } from "inversify";
|
||||
|
||||
import type { IPagesRepository } from "../../application/repositories/pages-repository.interface";
|
||||
import type { Page } from "../../entities/page";
|
||||
import type { Page } from "../../entities/models/page";
|
||||
|
||||
const SEED_DATE = new Date("2026-01-01T00:00:00.000Z");
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import "reflect-metadata";
|
||||
import { injectable } from "inversify";
|
||||
|
||||
import type { ISiteSettingsRepository } from "../../application/repositories/site-settings-repository.interface";
|
||||
import type { SiteSettings } from "../../entities/site-settings";
|
||||
import type { SiteSettings } from "../../entities/models/site-settings";
|
||||
|
||||
@injectable()
|
||||
export class MockSiteSettingsRepository implements ISiteSettingsRepository {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
CONTRACT_PAGES_SEED,
|
||||
} from "@/__contracts__/pages-repository.contract";
|
||||
import { stubPayloadConfig } from "@repo/core-testing/payload/stub-config";
|
||||
import type { Page } from "@/entities/page";
|
||||
import type { Page } from "@/entities/models/page";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// In-memory Payload stub for pages (read-only collection)
|
||||
|
||||
@@ -4,7 +4,7 @@ import { getPayload } from "payload";
|
||||
import type { SanitizedConfig } from "payload";
|
||||
|
||||
import type { IPagesRepository } from "../../application/repositories/pages-repository.interface";
|
||||
import type { Page } from "../../entities/page";
|
||||
import type { Page } from "../../entities/models/page";
|
||||
|
||||
type PayloadPageDoc = {
|
||||
id: string | number;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { getPayload } from "payload";
|
||||
import type { SanitizedConfig } from "payload";
|
||||
|
||||
import type { ISiteSettingsRepository } from "../../application/repositories/site-settings-repository.interface";
|
||||
import type { SiteSettings } from "../../entities/site-settings";
|
||||
import type { SiteSettings } from "../../entities/models/site-settings";
|
||||
|
||||
type PayloadSiteSettings = {
|
||||
siteName?: string | null;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { MockPagesRepository } from "@/infrastructure/repositories/mock-pages.re
|
||||
import { MockSiteSettingsRepository } from "@/infrastructure/repositories/mock-site-settings.repository";
|
||||
import type { IPagesRepository } from "@/application/repositories/pages-repository.interface";
|
||||
import type { ISiteSettingsRepository } from "@/application/repositories/site-settings-repository.interface";
|
||||
import { InputParseError } from "@/entities/errors";
|
||||
import { InputParseError } from "@/entities/errors/common";
|
||||
import {
|
||||
getPageBySlugController,
|
||||
getSiteSettingsController,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { InputParseError } from "../../entities/errors";
|
||||
import type { Page } from "../../entities/page";
|
||||
import type { SiteSettings } from "../../entities/site-settings";
|
||||
import { InputParseError } from "../../entities/errors/common";
|
||||
import type { Page } from "../../entities/models/page";
|
||||
import type { SiteSettings } from "../../entities/models/site-settings";
|
||||
import { getPageBySlugUseCase } from "../../application/use-cases/get-page-by-slug.use-case";
|
||||
import { getSiteSettingsUseCase } from "../../application/use-cases/get-site-settings.use-case";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { it, expect, beforeEach } from "vitest";
|
||||
import { defineContractSuite } from "@repo/core-testing/contract";
|
||||
import type { IHeaderRepository } from "../application/repositories/header-repository.interface.js";
|
||||
import type { Header } from "../entities/header.js";
|
||||
import type { Header } from "../entities/models/header.js";
|
||||
|
||||
/**
|
||||
* Known fixtures that every implementation's `buildSubject` must pre-seed.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineFactory } from "@repo/core-testing/factory";
|
||||
import type { Header } from "../entities/header.js";
|
||||
import type { Header } from "../entities/models/header.js";
|
||||
|
||||
export const headerFactory = defineFactory<Header>(({ sequence }) => ({
|
||||
logoId: `logo-${sequence}`,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineFactory } from "@repo/core-testing/factory";
|
||||
import type { HeaderItem } from "../entities/header.js";
|
||||
import type { HeaderItem } from "../entities/models/header.js";
|
||||
|
||||
export const navItemFactory = defineFactory<HeaderItem>(({ sequence }) => ({
|
||||
label: `Item ${sequence}`,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Header } from "../../entities/header";
|
||||
import type { Header } from "../../entities/models/header";
|
||||
|
||||
export interface IHeaderRepository {
|
||||
getHeader(): Promise<Header>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Header } from "../../entities/header";
|
||||
import type { Header } from "../../entities/models/header";
|
||||
import { navigationContainer } from "../../di/container";
|
||||
import { NAVIGATION_SYMBOLS } from "../../di/symbols";
|
||||
import type { IHeaderRepository } from "../repositories/header-repository.interface";
|
||||
|
||||
5
packages/navigation/src/entities/errors/common.ts
Normal file
5
packages/navigation/src/entities/errors/common.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export class InputParseError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
5
packages/navigation/src/entities/errors/header.ts
Normal file
5
packages/navigation/src/entities/errors/header.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export class HeaderNotFoundError extends Error {
|
||||
constructor(message = "Header not found", options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
export type { Header, HeaderItem } from "./entities/header";
|
||||
export type { Header, HeaderItem } from "./entities/models/header";
|
||||
export type { NavigationRouter } from "./integrations/api/router";
|
||||
export { headerQuery } from "./ui/query";
|
||||
|
||||
@@ -2,7 +2,7 @@ import "reflect-metadata";
|
||||
import { injectable } from "inversify";
|
||||
|
||||
import type { IHeaderRepository } from "../../application/repositories/header-repository.interface";
|
||||
import type { Header, HeaderItem } from "../../entities/header";
|
||||
import type { Header, HeaderItem } from "../../entities/models/header";
|
||||
|
||||
const DEFAULT_ITEMS: HeaderItem[] = [
|
||||
{ label: "Home", href: "/", external: false },
|
||||
|
||||
@@ -4,7 +4,7 @@ import { getPayload } from "payload";
|
||||
import type { SanitizedConfig } from "payload";
|
||||
|
||||
import type { IHeaderRepository } from "../../application/repositories/header-repository.interface";
|
||||
import type { Header, HeaderItem } from "../../entities/header";
|
||||
import type { Header, HeaderItem } from "../../entities/models/header";
|
||||
|
||||
type PayloadHeaderGlobal = {
|
||||
logo?: string | number | { id: string | number } | null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Header } from "../../entities/header";
|
||||
import type { Header } from "../../entities/models/header";
|
||||
import { getHeaderUseCase } from "../../application/use-cases/get-header.use-case";
|
||||
|
||||
export async function getHeaderController(): Promise<Header> {
|
||||
|
||||
Reference in New Issue
Block a user