Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/document-queue-inference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -40,10 +40,12 @@ const payload = z.object({
kind: z.enum(['welcome', 'digest', 'receipt']),
});

export type EmailPayload = z.infer<typeof payload>;
// 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<EmailPayload>({ name: 'emails', schema: payload });
// And read from the contract wherever a name for it is needed.
export type EmailPayload = QueueBody<typeof emails>;
```

```ts
Expand Down
Loading