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:
@@ -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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user