From cf58d1ed56c671d0ee077dfecc286002b4bae5ed Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 26 Apr 2024 16:07:55 +0200 Subject: [PATCH 1/4] Improve `asDrizzleTable()` types (#10882) --- .changeset/angry-lemons-tie.md | 7 +++++++ packages/db/src/runtime/index.ts | 2 +- packages/db/src/utils.ts | 11 ++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .changeset/angry-lemons-tie.md diff --git a/.changeset/angry-lemons-tie.md b/.changeset/angry-lemons-tie.md new file mode 100644 index 000000000000..91e0978f4953 --- /dev/null +++ b/.changeset/angry-lemons-tie.md @@ -0,0 +1,7 @@ +--- +"@astrojs/db": patch +--- + +Improves the typing of the `asDrizzleTable()` utility + +Fixes a type error when passing the output of `defineTable()` to the utility and returns a more detailed type inferred from the columns of the passed table config. diff --git a/packages/db/src/runtime/index.ts b/packages/db/src/runtime/index.ts index 67dea935af46..06d08a8793f9 100644 --- a/packages/db/src/runtime/index.ts +++ b/packages/db/src/runtime/index.ts @@ -8,7 +8,7 @@ import { sqliteTable, text, } from 'drizzle-orm/sqlite-core'; -import { type DBColumn, type DBTable } from '../core/types.js'; +import type { DBColumn, DBTable } from '../core/types.js'; import { type SerializedSQL, isSerializedSQL } from './types.js'; import { pathToFileURL } from './utils.js'; diff --git a/packages/db/src/utils.ts b/packages/db/src/utils.ts index 4e1a18685ebf..7a98cca35cfc 100644 --- a/packages/db/src/utils.ts +++ b/packages/db/src/utils.ts @@ -1,2 +1,11 @@ export { defineDbIntegration } from './core/utils.js'; -export { asDrizzleTable } from './runtime/index.js'; +import { tableSchema } from './core/schemas.js'; +import type { ColumnsConfig, TableConfig } from './core/types.js'; +import { type Table, asDrizzleTable as internal_asDrizzleTable } from './runtime/index.js'; + +export function asDrizzleTable< + TableName extends string = string, + TColumns extends ColumnsConfig = ColumnsConfig, +>(name: TableName, tableConfig: TableConfig) { + return internal_asDrizzleTable(name, tableSchema.parse(tableConfig)) as Table; +} From c238aa81ee91ce85f40740234fe6878faa27dceb Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 26 Apr 2024 14:09:06 +0000 Subject: [PATCH 2/4] [ci] format --- packages/db/src/utils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/db/src/utils.ts b/packages/db/src/utils.ts index 7a98cca35cfc..0f244cd00be5 100644 --- a/packages/db/src/utils.ts +++ b/packages/db/src/utils.ts @@ -7,5 +7,8 @@ export function asDrizzleTable< TableName extends string = string, TColumns extends ColumnsConfig = ColumnsConfig, >(name: TableName, tableConfig: TableConfig) { - return internal_asDrizzleTable(name, tableSchema.parse(tableConfig)) as Table; + return internal_asDrizzleTable(name, tableSchema.parse(tableConfig)) as Table< + TableName, + TColumns + >; } From 76980362dd898065651f7157324147255767bf70 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 29 Apr 2024 12:30:00 +0200 Subject: [PATCH 3/4] chore(astro): reorganize integrations hooks (#10896) * chore(astro): reorganize integrations hooks * fix: test paths --- packages/astro/src/@types/astro.ts | 2 +- packages/astro/src/config/index.ts | 2 +- packages/astro/src/core/build/generate.ts | 2 +- packages/astro/src/core/build/index.ts | 2 +- packages/astro/src/core/build/plugins/plugin-manifest.ts | 2 +- packages/astro/src/core/build/plugins/plugin-ssr.ts | 2 +- packages/astro/src/core/build/static-build.ts | 2 +- packages/astro/src/core/dev/container.ts | 2 +- packages/astro/src/core/preview/index.ts | 2 +- packages/astro/src/core/sync/index.ts | 2 +- .../{astroFeaturesValidation.ts => features-validation.ts} | 0 packages/astro/src/integrations/{index.ts => hooks.ts} | 2 +- .../astro/src/vite-plugin-integrations-container/index.ts | 2 +- packages/astro/test/units/integrations/api.test.js | 4 ++-- 14 files changed, 14 insertions(+), 14 deletions(-) rename packages/astro/src/integrations/{astroFeaturesValidation.ts => features-validation.ts} (100%) rename packages/astro/src/integrations/{index.ts => hooks.ts} (99%) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index d9c8a9489c25..0cff203cf227 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -19,7 +19,7 @@ import type { AstroTimer } from '../core/config/timer.js'; import type { TSConfig } from '../core/config/tsconfig.js'; import type { AstroCookies } from '../core/cookies/index.js'; import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core.js'; -import type { getToolbarServerCommunicationHelpers } from '../integrations/index.js'; +import type { getToolbarServerCommunicationHelpers } from '../integrations/hooks.js'; import type { AstroPreferences } from '../preferences/index.js'; import type { ToolbarAppEventTarget, diff --git a/packages/astro/src/config/index.ts b/packages/astro/src/config/index.ts index f48bf4b153b2..3f4652f20419 100644 --- a/packages/astro/src/config/index.ts +++ b/packages/astro/src/config/index.ts @@ -27,7 +27,7 @@ export function getViteConfig(inlineConfig: UserConfig) { import('../core/logger/node.js'), import('../core/config/index.js'), import('../core/create-vite.js'), - import('../integrations/index.js'), + import('../integrations/hooks.js'), import('./vite-plugin-content-listen.js'), ]); const logger = new Logger({ diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 381c9e6426c8..5c6c302db773 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -30,7 +30,7 @@ import { removeTrailingForwardSlash, } from '../../core/path.js'; import { toRoutingStrategy } from '../../i18n/utils.js'; -import { runHookBuildGenerated } from '../../integrations/index.js'; +import { runHookBuildGenerated } from '../../integrations/hooks.js'; import { getOutputDirectory, isServerLikeOutput } from '../../prerender/utils.js'; import type { SSRManifestI18n } from '../app/types.js'; import { NoPrerenderedRoutesWithDomains } from '../errors/errors-data.js'; diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 2b71feaf9a9a..ea1b715bbd57 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -18,7 +18,7 @@ import { runHookBuildStart, runHookConfigDone, runHookConfigSetup, -} from '../../integrations/index.js'; +} from '../../integrations/hooks.js'; import { isServerLikeOutput } from '../../prerender/utils.js'; import { resolveConfig } from '../config/config.js'; import { createNodeLogger } from '../config/logging.js'; diff --git a/packages/astro/src/core/build/plugins/plugin-manifest.ts b/packages/astro/src/core/build/plugins/plugin-manifest.ts index c1e87bf458d3..498ccdbb544b 100644 --- a/packages/astro/src/core/build/plugins/plugin-manifest.ts +++ b/packages/astro/src/core/build/plugins/plugin-manifest.ts @@ -5,7 +5,7 @@ import { type Plugin as VitePlugin } from 'vite'; import { getAssetsPrefix } from '../../../assets/utils/getAssetsPrefix.js'; import { normalizeTheLocale } from '../../../i18n/index.js'; import { toRoutingStrategy } from '../../../i18n/utils.js'; -import { runHookBuildSsr } from '../../../integrations/index.js'; +import { runHookBuildSsr } from '../../../integrations/hooks.js'; import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../../vite-plugin-scripts/index.js'; import type { SSRManifestI18n, diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index 5f32ea63b209..5ccb8746364f 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -2,7 +2,7 @@ import { join } from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; import type { Plugin as VitePlugin } from 'vite'; import type { AstroAdapter } from '../../../@types/astro.js'; -import { isFunctionPerRouteEnabled } from '../../../integrations/index.js'; +import { isFunctionPerRouteEnabled } from '../../../integrations/hooks.js'; import { isServerLikeOutput } from '../../../prerender/utils.js'; import { routeIsRedirect } from '../../redirects/index.js'; import { addRollupInput } from '../add-rollup-input.js'; diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index 6e8fb0be4421..6aa1eca901ba 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -17,7 +17,7 @@ import { import { emptyDir, removeEmptyDirs } from '../../core/fs/index.js'; import { appendForwardSlash, prependForwardSlash, removeFileExtension } from '../../core/path.js'; import { isModeServerWithNoAdapter } from '../../core/util.js'; -import { runHookBuildSetup } from '../../integrations/index.js'; +import { runHookBuildSetup } from '../../integrations/hooks.js'; import { getOutputDirectory, isServerLikeOutput } from '../../prerender/utils.js'; import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; diff --git a/packages/astro/src/core/dev/container.ts b/packages/astro/src/core/dev/container.ts index d252e2eea534..58962de0f710 100644 --- a/packages/astro/src/core/dev/container.ts +++ b/packages/astro/src/core/dev/container.ts @@ -10,7 +10,7 @@ import { runHookConfigSetup, runHookServerDone, runHookServerStart, -} from '../../integrations/index.js'; +} from '../../integrations/hooks.js'; import { createVite } from '../create-vite.js'; import type { Logger } from '../logger/core.js'; import { apply as applyPolyfill } from '../polyfill.js'; diff --git a/packages/astro/src/core/preview/index.ts b/packages/astro/src/core/preview/index.ts index e03e7641906d..e7e3282ff3d2 100644 --- a/packages/astro/src/core/preview/index.ts +++ b/packages/astro/src/core/preview/index.ts @@ -5,7 +5,7 @@ import type { AstroInlineConfig, PreviewModule, PreviewServer } from '../../@typ import { AstroIntegrationLogger } from '../../core/logger/core.js'; import { telemetry } from '../../events/index.js'; import { eventCliSession } from '../../events/session.js'; -import { runHookConfigDone, runHookConfigSetup } from '../../integrations/index.js'; +import { runHookConfigDone, runHookConfigSetup } from '../../integrations/hooks.js'; import { resolveConfig } from '../config/config.js'; import { createNodeLogger } from '../config/logging.js'; import { createSettings } from '../config/settings.js'; diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index f50284369661..a5763b68f370 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -9,7 +9,7 @@ import { createContentTypesGenerator } from '../../content/index.js'; import { globalContentConfigObserver } from '../../content/utils.js'; import { telemetry } from '../../events/index.js'; import { eventCliSession } from '../../events/session.js'; -import { runHookConfigSetup } from '../../integrations/index.js'; +import { runHookConfigSetup } from '../../integrations/hooks.js'; import { setUpEnvTs } from '../../vite-plugin-inject-env-ts/index.js'; import { getTimeStat } from '../build/util.js'; import { resolveConfig } from '../config/config.js'; diff --git a/packages/astro/src/integrations/astroFeaturesValidation.ts b/packages/astro/src/integrations/features-validation.ts similarity index 100% rename from packages/astro/src/integrations/astroFeaturesValidation.ts rename to packages/astro/src/integrations/features-validation.ts diff --git a/packages/astro/src/integrations/index.ts b/packages/astro/src/integrations/hooks.ts similarity index 99% rename from packages/astro/src/integrations/index.ts rename to packages/astro/src/integrations/hooks.ts index 61487fb06534..51f600ae85f6 100644 --- a/packages/astro/src/integrations/index.ts +++ b/packages/astro/src/integrations/hooks.ts @@ -20,7 +20,7 @@ import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.j import { mergeConfig } from '../core/config/index.js'; import type { AstroIntegrationLogger, Logger } from '../core/logger/core.js'; import { isServerLikeOutput } from '../prerender/utils.js'; -import { validateSupportedFeatures } from './astroFeaturesValidation.js'; +import { validateSupportedFeatures } from './features-validation.js'; async function withTakingALongTimeMsg({ name, diff --git a/packages/astro/src/vite-plugin-integrations-container/index.ts b/packages/astro/src/vite-plugin-integrations-container/index.ts index 2125df857d9f..5c1bb044dd36 100644 --- a/packages/astro/src/vite-plugin-integrations-container/index.ts +++ b/packages/astro/src/vite-plugin-integrations-container/index.ts @@ -4,7 +4,7 @@ import type { AstroSettings, InjectedRoute, ResolvedInjectedRoute } from '../@ty import type { Logger } from '../core/logger/core.js'; import { normalizePath } from 'vite'; -import { runHookServerSetup } from '../integrations/index.js'; +import { runHookServerSetup } from '../integrations/hooks.js'; /** Connect Astro integrations into Vite, as needed. */ export default function astroIntegrationsContainerPlugin({ diff --git a/packages/astro/test/units/integrations/api.test.js b/packages/astro/test/units/integrations/api.test.js index e05c4f9442cb..06785e11b3d3 100644 --- a/packages/astro/test/units/integrations/api.test.js +++ b/packages/astro/test/units/integrations/api.test.js @@ -1,7 +1,7 @@ import * as assert from 'node:assert/strict'; import { describe, it } from 'node:test'; -import { validateSupportedFeatures } from '../../../dist/integrations/astroFeaturesValidation.js'; -import { runHookBuildSetup, runHookConfigSetup } from '../../../dist/integrations/index.js'; +import { validateSupportedFeatures } from '../../../dist/integrations/features-validation.js'; +import { runHookBuildSetup, runHookConfigSetup } from '../../../dist/integrations/hooks.js'; import { defaultLogger } from '../test-utils.js'; describe('Integration API', () => { From b6f011d7c0a762f549af7577c42017d2d30e0342 Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:51:30 +0200 Subject: [PATCH 4/4] fix(actions): Make it possible for users with write access to make preview releases (#10903) --- .github/workflows/snapshot-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml index b067394e46df..bee678c962a8 100644 --- a/.github/workflows/snapshot-release.yml +++ b/.github/workflows/snapshot-release.yml @@ -25,10 +25,10 @@ jobs: issues: write pull-requests: write steps: - - name: "Check if user has admin access (only admins can publish snapshot releases)." + - name: "Check if user has write access" uses: "lannonbr/repo-permission-check-action@2.0.2" with: - permission: "admin" + permission: "write" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}