mirror of
https://github.com/withastro/astro.git
synced 2025-01-13 22:11:20 -05:00
chore: add changeset
This commit is contained in:
parent
9a55d61539
commit
c4d4378c50
1 changed files with 57 additions and 0 deletions
57
.changeset/green-deers-trade.md
Normal file
57
.changeset/green-deers-trade.md
Normal file
|
@ -0,0 +1,57 @@
|
|||
---
|
||||
"astro": minor
|
||||
"@astrojs/db": minor
|
||||
---
|
||||
|
||||
Adds a new `defineIntegration` helper and reworks typings for integrations authors extending Astro DB.
|
||||
|
||||
This release adds a new `defineIntegration` helper through the `astro/integration` import that allows to define a type-safe integration and handle options validation (not required):
|
||||
|
||||
```ts
|
||||
import { defineIntegration } from "astro/integration"
|
||||
import { z } from "astro/zod"
|
||||
|
||||
export const integration = defineIntegration({
|
||||
name: "my-integration",
|
||||
// optional
|
||||
optionsSchema: z.object({ id: z.string() }),
|
||||
setup({ options }) {
|
||||
return {
|
||||
hooks: {
|
||||
"astro:config:setup": (params) => {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Astro DB `defineDbIntegration` has been removed in favor of a way that works with this new `defineIntegration` (but also the `AstroIntegration` type):
|
||||
|
||||
```ts
|
||||
import {} from "astro"
|
||||
import { defineIntegration } from "astro/integration"
|
||||
import type { AstroDbHooks } from "@astrojs/db/types"
|
||||
|
||||
declare module "astro" {
|
||||
interface AstroIntegrationHooks extends AstroDbHooks {}
|
||||
}
|
||||
|
||||
export default defineIntegration({
|
||||
name: "db-test-integration",
|
||||
setup() {
|
||||
return {
|
||||
hooks: {
|
||||
'astro:db:setup': ({ extendDb }) => {
|
||||
extendDb({
|
||||
configEntrypoint: './integration/config.ts',
|
||||
seedEntrypoint: './integration/seed.ts',
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
```
|
Loading…
Add table
Reference in a new issue