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