-
Notifications
You must be signed in to change notification settings - Fork 8
chore: Upgrade to Astro v6 #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
8726673
1edcff2
59bf35a
814f40d
1a4d93c
1232524
30cd46e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import type { Loader } from "astro/loaders"; | ||
| import { AstroError } from "astro/errors"; | ||
| import Airtable, { type Query, type FieldSet } from "airtable"; | ||
| import { createTypeAlias, printNode, zodToTs } from "zod-to-ts"; | ||
| import { zodSchemaFromAirtableTable } from "./schema.js"; | ||
|
|
||
| export interface AirtableLoaderOptions<TFields extends FieldSet = FieldSet> { | ||
|
|
@@ -44,11 +45,19 @@ export function airtableLoader({ | |
| } | ||
| logger.info(`Loaded ${records.length} records from "${table}"`); | ||
| }, | ||
| schema: () => | ||
| zodSchemaFromAirtableTable({ | ||
| createSchema: async () => { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the schema generation is async we need to use |
||
| const schema = await zodSchemaFromAirtableTable({ | ||
| baseID: base, | ||
| tableIdOrName: table, | ||
| apiKey: token, | ||
| }), | ||
| }); | ||
| const identifier = "Entry"; | ||
| const { node } = zodToTs(schema, identifier); | ||
| const typeAlias = createTypeAlias(node, identifier); | ||
| return { | ||
| schema, | ||
| types: `export ${printNode(typeAlias)}`, | ||
| }; | ||
| }, | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ export const FeedCategorySchema = z.object({ | |
| }); | ||
|
|
||
| // Legacy schemas from original implementation for exact backward compatibility | ||
| export const LegacyNSSchema = z.record(z.string()); | ||
| export const LegacyNSSchema = z.record(z.string(), z.unknown()); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Zod 4 requires two arguments for |
||
|
|
||
| export const LegacyImageSchema = z.object({ | ||
| url: z.string().optional(), | ||
|
|
@@ -111,7 +111,7 @@ export const LegacyItemSchema = z | |
| enclosures: z.array(LegacyEnclosureSchema), | ||
| meta: LegacyMetaSchema, | ||
| }) | ||
| .and(z.record(z.unknown())); // Allow additional fields | ||
| .and(z.record(z.string(), z.unknown())); // Allow additional fields | ||
|
|
||
| // Feed schema for the complete feed structure | ||
| export const FeedSchema = z.object({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zod-to-tsv2.0.0 is available, but the API is different from what the Astro docs expect. Since Astro v5 usedzod-to-ts@1.2.0, I kept the version there for parity.