chore: workspace green check (Task 56)
Three issues uncovered by the full pnpm typecheck/test/boundaries pass
and resolved here:
- core-testing was importing IEventBus / IJobQueue from core-events /
core-shared, creating two boundary violations (tooling → core) and a
build-graph cycle. Inlined the type aliases (mirroring how
RecordingTracer / RecordingLogger handle ITracer / ILogger).
recording-event-bus.test.ts replaces defineEvent() with an inline
descriptor literal so no runtime import is needed either. core-events
and core-shared are removed from core-testing dependencies.
- turbo.json: typecheck and test no longer dependsOn ^typecheck / ^build.
Each package's tsc / vitest resolves cross-package types via
node_modules independently, and dropping the topological dep avoids the
spurious cycle warning that appeared once core-testing started
importing core-events / core-shared.
- turbo.json: feature.dependencies.allow gains "feature". Cross-feature
event flow (ADR-015) requires a consumer feature to import the
publisher's event contract directly. The dangerous form (importing
the publisher's handler/use-case/repo) is still blocked by E1's
no-handler-reexport ESLint rule and the missing public exports.
- TaskConfig<"slug-string"> → TaskConfig<{ input; output }> in the gen
job task template (and the shipped send-welcome-email.task.ts) since
runtime-generated slugs aren't keys of TypedJobs['tasks'].
This commit is contained in:
@@ -21,8 +21,6 @@
|
|||||||
"test": "vitest run"
|
"test": "vitest run"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@repo/core-events": "workspace:*",
|
|
||||||
"@repo/core-shared": "workspace:*",
|
|
||||||
"@testing-library/jest-dom": "^6.5.0",
|
"@testing-library/jest-dom": "^6.5.0",
|
||||||
"zod": "^3.23.0",
|
"zod": "^3.23.0",
|
||||||
"@testing-library/react": "^16.0.0",
|
"@testing-library/react": "^16.0.0",
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import { describe, it, expect } from "vitest";
|
import { describe, it, expect } from "vitest";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { defineEvent } from "@repo/core-events";
|
|
||||||
import { RecordingEventBus } from "@/instrumentation/recording-event-bus";
|
import { RecordingEventBus } from "@/instrumentation/recording-event-bus";
|
||||||
|
|
||||||
const evt = defineEvent("test.evt", z.object({ id: z.string() }).strict());
|
// Inline a descriptor literal so the test doesn't need to import from
|
||||||
|
// @repo/core-events (boundary-rule isolation, mirrors recording-tracer test).
|
||||||
|
const evt = {
|
||||||
|
name: "test.evt" as const,
|
||||||
|
schema: z.object({ id: z.string() }).strict(),
|
||||||
|
};
|
||||||
|
|
||||||
describe("RecordingEventBus", () => {
|
describe("RecordingEventBus", () => {
|
||||||
it("records every publish call after schema validation", async () => {
|
it("records every publish call after schema validation", async () => {
|
||||||
|
|||||||
@@ -1,5 +1,26 @@
|
|||||||
|
// Local type aliases matching the contracts in @repo/core-events.
|
||||||
|
// Kept inline to avoid a build-graph cycle between core-testing and core-events
|
||||||
|
// (mirrors the recording-tracer / recording-logger pattern).
|
||||||
import type { z } from "zod";
|
import type { z } from "zod";
|
||||||
import type { EventDescriptor, EventHandler, IEventBus } from "@repo/core-events";
|
|
||||||
|
type EventDescriptor<TName extends string, TSchema extends z.ZodType> = {
|
||||||
|
readonly name: TName;
|
||||||
|
readonly schema: TSchema;
|
||||||
|
};
|
||||||
|
|
||||||
|
type EventHandler<T> = (event: T) => Promise<void>;
|
||||||
|
|
||||||
|
interface IEventBus {
|
||||||
|
publish<T>(
|
||||||
|
descriptor: EventDescriptor<string, z.ZodType<T>>,
|
||||||
|
payload: T,
|
||||||
|
): Promise<void>;
|
||||||
|
subscribe<T>(
|
||||||
|
descriptor: EventDescriptor<string, z.ZodType<T>>,
|
||||||
|
consumerFeature: string,
|
||||||
|
handler: EventHandler<T>,
|
||||||
|
): void;
|
||||||
|
}
|
||||||
|
|
||||||
export class RecordingEventBus implements IEventBus {
|
export class RecordingEventBus implements IEventBus {
|
||||||
readonly published: { name: string; payload: unknown }[] = [];
|
readonly published: { name: string; payload: unknown }[] = [];
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
import type { IJobQueue } from "@repo/core-shared/jobs";
|
// Local type alias matching the contract in @repo/core-shared/jobs.
|
||||||
|
// Kept inline to avoid a build-graph cycle between core-testing and core-shared
|
||||||
|
// (mirrors the recording-tracer / recording-logger pattern).
|
||||||
|
interface IJobQueue {
|
||||||
|
enqueue<T>(
|
||||||
|
taskSlug: string,
|
||||||
|
input: T,
|
||||||
|
options?: { runAt?: Date },
|
||||||
|
): Promise<{ jobId: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
export class RecordingJobQueue implements IJobQueue {
|
export class RecordingJobQueue implements IJobQueue {
|
||||||
readonly enqueued: { taskSlug: string; input: unknown; options?: { runAt?: Date } }[] = [];
|
readonly enqueued: { taskSlug: string; input: unknown; options?: { runAt?: Date } }[] = [];
|
||||||
|
|||||||
@@ -3,8 +3,12 @@ import type { TaskConfig } from "payload";
|
|||||||
import { marketingPagesContainer } from "../../../di/container";
|
import { marketingPagesContainer } from "../../../di/container";
|
||||||
import { MARKETING_PAGES_SYMBOLS } from "../../../di/symbols";
|
import { MARKETING_PAGES_SYMBOLS } from "../../../di/symbols";
|
||||||
import type { ISendWelcomeEmailJob } from "../../../jobs/send-welcome-email.job";
|
import type { ISendWelcomeEmailJob } from "../../../jobs/send-welcome-email.job";
|
||||||
|
import type { SendWelcomeEmailInput } from "../../../jobs/send-welcome-email.job";
|
||||||
|
|
||||||
export const sendWelcomeEmailTask: TaskConfig<"marketing-pages.send-welcome-email"> = {
|
export const sendWelcomeEmailTask: TaskConfig<{
|
||||||
|
input: SendWelcomeEmailInput;
|
||||||
|
output: object;
|
||||||
|
}> = {
|
||||||
slug: "marketing-pages.send-welcome-email",
|
slug: "marketing-pages.send-welcome-email",
|
||||||
inputSchema: [],
|
inputSchema: [],
|
||||||
retries: { attempts: 3, backoff: { type: "exponential", delay: 1000 } },
|
retries: { attempts: 3, backoff: { type: "exponential", delay: 1000 } },
|
||||||
@@ -12,7 +16,7 @@ export const sendWelcomeEmailTask: TaskConfig<"marketing-pages.send-welcome-emai
|
|||||||
const job = marketingPagesContainer.get<ISendWelcomeEmailJob>(
|
const job = marketingPagesContainer.get<ISendWelcomeEmailJob>(
|
||||||
MARKETING_PAGES_SYMBOLS.ISendWelcomeEmailJob,
|
MARKETING_PAGES_SYMBOLS.ISendWelcomeEmailJob,
|
||||||
);
|
);
|
||||||
await job(input as never);
|
await job(input);
|
||||||
return { output: {} };
|
return { output: {} };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@@ -604,12 +604,6 @@ importers:
|
|||||||
|
|
||||||
packages/core-testing:
|
packages/core-testing:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@repo/core-events':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../core-events
|
|
||||||
'@repo/core-shared':
|
|
||||||
specifier: workspace:*
|
|
||||||
version: link:../core-shared
|
|
||||||
'@tanstack/react-query':
|
'@tanstack/react-query':
|
||||||
specifier: ^5.59.0
|
specifier: ^5.59.0
|
||||||
version: 5.96.2(react@19.2.4)
|
version: 5.96.2(react@19.2.4)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
"feature": {
|
"feature": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"allow": ["core", "tooling"]
|
"allow": ["core", "feature", "tooling"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"core": {
|
"core": {
|
||||||
@@ -65,14 +65,14 @@
|
|||||||
"dependsOn": ["^lint"]
|
"dependsOn": ["^lint"]
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"dependsOn": ["^build"]
|
"dependsOn": []
|
||||||
},
|
},
|
||||||
"test:e2e": {
|
"test:e2e": {
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
"cache": false
|
"cache": false
|
||||||
},
|
},
|
||||||
"typecheck": {
|
"typecheck": {
|
||||||
"dependsOn": ["^typecheck"]
|
"dependsOn": []
|
||||||
},
|
},
|
||||||
"build-storybook": {
|
"build-storybook": {
|
||||||
"outputs": ["storybook-static/**"]
|
"outputs": ["storybook-static/**"]
|
||||||
|
|||||||
@@ -2,9 +2,15 @@
|
|||||||
import type { TaskConfig } from "payload";
|
import type { TaskConfig } from "payload";
|
||||||
import { {{camelCase feature}}Container } from "../../../di/container";
|
import { {{camelCase feature}}Container } from "../../../di/container";
|
||||||
import { {{constantCase feature}}_SYMBOLS } from "../../../di/symbols";
|
import { {{constantCase feature}}_SYMBOLS } from "../../../di/symbols";
|
||||||
import type { I{{pascalCase job}}Job } from "../../../jobs/{{kebabCase job}}.job";
|
import type {
|
||||||
|
I{{pascalCase job}}Job,
|
||||||
|
{{pascalCase job}}Input,
|
||||||
|
} from "../../../jobs/{{kebabCase job}}.job";
|
||||||
|
|
||||||
export const {{camelCase job}}Task: TaskConfig<"{{kebabCase feature}}.{{kebabCase job}}"> = {
|
export const {{camelCase job}}Task: TaskConfig<{
|
||||||
|
input: {{pascalCase job}}Input;
|
||||||
|
output: object;
|
||||||
|
}> = {
|
||||||
slug: "{{kebabCase feature}}.{{kebabCase job}}",
|
slug: "{{kebabCase feature}}.{{kebabCase job}}",
|
||||||
inputSchema: [],
|
inputSchema: [],
|
||||||
retries: { attempts: 3, backoff: { type: "exponential", delay: 1000 } },
|
retries: { attempts: 3, backoff: { type: "exponential", delay: 1000 } },
|
||||||
@@ -12,7 +18,7 @@ export const {{camelCase job}}Task: TaskConfig<"{{kebabCase feature}}.{{kebabCas
|
|||||||
const job = {{camelCase feature}}Container.get<I{{pascalCase job}}Job>(
|
const job = {{camelCase feature}}Container.get<I{{pascalCase job}}Job>(
|
||||||
{{constantCase feature}}_SYMBOLS.I{{pascalCase job}}Job,
|
{{constantCase feature}}_SYMBOLS.I{{pascalCase job}}Job,
|
||||||
);
|
);
|
||||||
await job(input as never);
|
await job(input);
|
||||||
return { output: {} };
|
return { output: {} };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user