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
19 changes: 14 additions & 5 deletions apps/content/docs/integrations/effect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -315,23 +315,32 @@ const procedure = os
}))
```

### `.input` and `.output` Extensions
### Schema Extension

Import `@orpc/effect/extensions/input-output` from a module that always runs during initialization, such as the file where you define your base builder or create your server. This lets you define `.input` and `.output` directly with Effect Schema:
Import `@orpc/effect/extensions/schema` from a module that always runs during initialization, such as the file where you define your base builder or create your server. This lets you use Effect Schema directly in `.input`, `.output`, and as error `data` in `.errors`:

<CodeGroup>

```ts usage
const procedure = base
.errors({
FORBIDDEN: {
data: Schema.Struct({ reason: Schema.String }),
},
})
.input(Schema.Struct({ name: Schema.String }))
.output(Schema.Struct({ greeting: Schema.String }))
.handler(handlerGen(function* ({ input, context }) {
.handler(handlerGen(function* ({ input, errors }) {
if (input.name === 'admin') {
return yield* Effect.fail(errors.FORBIDDEN({ data: { reason: 'Reserved name' } }))
}

return { greeting: `Hello ${input.name}!` }
}))
```

```ts setup
import '@orpc/effect/extensions/input-output'
import '@orpc/effect/extensions/schema'

import { os } from '@orpc/server'

Expand All @@ -341,7 +350,7 @@ export const base = os
</CodeGroup>

:::info
You can also use these extensions with the [contract builder](/docs/contract/procedure).
You can also use this extension with the [contract builder](/docs/contract/procedure). It does not cover `.errors` on standalone [middleware](/docs/middleware), so wrap Effect Schemas there with `Schema.toStandardSchemaV1`.
:::

### JSON Schema Converter
Expand Down
12 changes: 6 additions & 6 deletions packages/effect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"sideEffects": [
"./dist/extensions/effect.mjs",
"./dist/extensions/input-output.mjs"
"./dist/extensions/schema.mjs"
],
"publishConfig": {
"exports": {
Expand All @@ -39,18 +39,18 @@
"import": "./dist/extensions/effect.mjs",
"default": "./dist/extensions/effect.mjs"
},
"./extensions/input-output": {
"types": "./dist/extensions/input-output.d.mts",
"import": "./dist/extensions/input-output.mjs",
"default": "./dist/extensions/input-output.mjs"
"./extensions/schema": {
"types": "./dist/extensions/schema.d.mts",
"import": "./dist/extensions/schema.mjs",
"default": "./dist/extensions/schema.mjs"
}
}
},
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts",
"./extensions/effect": "./src/extensions/effect.ts",
"./extensions/input-output": "./src/extensions/input-output.ts"
"./extensions/schema": "./src/extensions/schema.ts"
},
"files": [
"dist"
Expand Down
207 changes: 0 additions & 207 deletions packages/effect/src/extensions/input-output.test-d.ts

This file was deleted.

47 changes: 0 additions & 47 deletions packages/effect/src/extensions/input-output.test.ts

This file was deleted.

Loading
Loading