diff --git a/.changeset/document-queue-inference.md b/.changeset/document-queue-inference.md new file mode 100644 index 0000000..a845151 --- /dev/null +++ b/.changeset/document-queue-inference.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/README.md b/README.md index 36c6077..e5c517a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Declare the payload once, and derive both ends from it: ```ts // contracts/emails.ts -import { defineQueue } from '@observerly/orderly'; +import { defineQueue, type QueueBody } from '@observerly/orderly'; import { z } from 'zod'; @@ -40,10 +40,12 @@ const payload = z.object({ kind: z.enum(['welcome', 'digest', 'receipt']), }); -export type EmailPayload = z.infer; +// Any Standard Schema library plugs in: zod, valibot, arktype, or a plain function that throws. The +// body's type is inferred from the schema, so it is named once, here. +export const emails = defineQueue({ name: 'emails', schema: payload }); -// Any Standard Schema library plugs in: zod, valibot, arktype, or a plain function that throws. -export const emails = defineQueue({ name: 'emails', schema: payload }); +// And read from the contract wherever a name for it is needed. +export type EmailPayload = QueueBody; ``` ```ts