feat(marketing-pages): subscribe to auth.user.signed-up

Generated handler + Payload event-task via gen event consume,
threaded through symbols / both binders / cms re-export at the
configured anchors. bus.subscribe wires the in-memory delivery in
dev-seed; the __events.auth.user.signed-up.marketing-pages Payload
task closes the production-bus loop.

Also fixes two generator-level issues found during Phase 8:
- Drop publisher prompt's `when` clause so --args can supply the
  4th positional argument (Plop limitation: --args cannot bypass
  conditional prompts). Validate runs only in consume mode.
- Switch event-task.ts.hbs from TaskConfig<"slug-string"> to
  TaskConfig<{ input: ...; output: object }> since runtime-generated
  event slugs are not keys of TypedJobs['tasks'].
This commit is contained in:
2026-05-08 16:33:14 +02:00
parent c1b8a7e434
commit 6b57a34c0c
11 changed files with 114 additions and 7 deletions

View File

@@ -1,3 +1,4 @@
export { pages } from "./collections/pages";
export { siteSettings } from "./globals/site-settings";
// <gen:job-tasks>
export { onAuthUserSignedUpEventTask } from "./jobs/__events-auth-user-signed-up.task";

View File

@@ -0,0 +1,26 @@
// packages/marketing-pages/src/integrations/cms/jobs/__events-auth-user-signed-up.task.ts
// Generated by `gen event consume`. The PayloadJobsEventBus enqueues this task
// when auth publishes `auth.user.signed-up`. The handler
// resolves the consumer's wrapped event handler from the per-feature container
// and invokes it with the typed payload.
import type { TaskConfig } from "payload";
import { marketingPagesContainer } from "../../../di/container";
import { MARKETING_PAGES_SYMBOLS } from "../../../di/symbols";
import type { IOnAuthUserSignedUpHandler } from "../../../events/handlers/on-auth-user-signed-up.handler";
import type { UserSignedUpEvent } from "@repo/auth";
export const onAuthUserSignedUpEventTask: TaskConfig<{
input: UserSignedUpEvent;
output: object;
}> = {
slug: "__events.auth.user.signed-up.marketing-pages",
inputSchema: [],
retries: { attempts: 3, backoff: { type: "exponential", delay: 1000 } },
handler: async ({ input }) => {
const handler = marketingPagesContainer.get<IOnAuthUserSignedUpHandler>(
MARKETING_PAGES_SYMBOLS.IOnAuthUserSignedUpHandler,
);
await handler(input);
return { output: {} };
},
};