From 289d1562f2a4514286c18dbbe52b2a49ea6f3c4f Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo Date: Wed, 20 Aug 2025 04:39:13 +0800 Subject: [PATCH 1/5] fix: inline `GetGenericDatabaseWithOptions` was causing issues when used together with supabase-js & ssr --- src/PostgrestClient.ts | 27 +++++++++++++++++---------- src/index.ts | 3 +-- src/types.ts | 16 ---------------- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/PostgrestClient.ts b/src/PostgrestClient.ts index 1d4361e6..13afc923 100644 --- a/src/PostgrestClient.ts +++ b/src/PostgrestClient.ts @@ -1,6 +1,6 @@ import PostgrestQueryBuilder from './PostgrestQueryBuilder' import PostgrestFilterBuilder from './PostgrestFilterBuilder' -import { Fetch, GenericSchema, ClientServerOptions, GetGenericDatabaseWithOptions } from './types' +import { Fetch, GenericSchema, ClientServerOptions } from './types' /** * PostgREST client. @@ -14,16 +14,23 @@ import { Fetch, GenericSchema, ClientServerOptions, GetGenericDatabaseWithOption */ export default class PostgrestClient< Database = any, - ClientOptions extends ClientServerOptions = GetGenericDatabaseWithOptions< - Database, - { PostgrestVersion: '12' } - >['options'], + ClientOptions extends ClientServerOptions = Database extends { + __InternalSupabase: infer I extends ClientServerOptions + } + ? I + : {}, SchemaName extends string & - keyof GetGenericDatabaseWithOptions['db'] = 'public' extends keyof GetGenericDatabaseWithOptions['db'] + keyof Omit = 'public' extends keyof Omit< + Database, + '__InternalSupabase' + > ? 'public' - : string & keyof GetGenericDatabaseWithOptions['db'], - Schema extends GenericSchema = GetGenericDatabaseWithOptions['db'][SchemaName] extends GenericSchema - ? GetGenericDatabaseWithOptions['db'][SchemaName] + : string & keyof Omit, + Schema extends GenericSchema = Omit< + Database, + '__InternalSupabase' + >[SchemaName] extends GenericSchema + ? Omit[SchemaName] : any > { url: string @@ -86,7 +93,7 @@ export default class PostgrestClient< * * @param schema - The schema to query */ - schema['db']>( + schema>( schema: DynamicSchema ): PostgrestClient< Database, diff --git a/src/index.ts b/src/index.ts index af70f94f..8c435dda 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,8 +28,7 @@ export type { PostgrestResponseSuccess, PostgrestSingleResponse, PostgrestMaybeSingleResponse, - ClientServerOptions, - GetGenericDatabaseWithOptions, + ClientServerOptions as PostgrestClientOptions, } from './types' // https://github.com/supabase/postgrest-js/issues/551 // To be replaced with a helper type that only uses public types diff --git a/src/types.ts b/src/types.ts index 8d4ef3fa..d0b89036 100644 --- a/src/types.ts +++ b/src/types.ts @@ -80,22 +80,6 @@ export type DatabaseWithOptions = options: Options } -const INTERNAL_SUPABASE_OPTIONS = '__InternalSupabase' - -export type GetGenericDatabaseWithOptions< - Database, - Opts extends ClientServerOptions = { PostgrestVersion: '12' } -> = IsAny extends true - ? DatabaseWithOptions - : typeof INTERNAL_SUPABASE_OPTIONS extends keyof Database - ? Database[typeof INTERNAL_SUPABASE_OPTIONS] extends ClientServerOptions - ? DatabaseWithOptions< - Omit, - Database[typeof INTERNAL_SUPABASE_OPTIONS] - > - : DatabaseWithOptions, Opts> - : DatabaseWithOptions - export type MaxAffectedEnabled = PostgrestVersion extends `13${string}` ? true : false From 8d75750d61ae5c75090fd046ba23acecc090c4c5 Mon Sep 17 00:00:00 2001 From: avallete Date: Thu, 21 Aug 2025 13:55:14 +0200 Subject: [PATCH 2/5] chore: trigger release From 3bbdbbb3218ef190de680836ccd0ef0d29f9a359 Mon Sep 17 00:00:00 2001 From: avallete Date: Thu, 21 Aug 2025 13:57:48 +0200 Subject: [PATCH 3/5] chore: debug preview --- .github/workflows/preview-release.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml index 718c92a1..7c3caf33 100644 --- a/.github/workflows/preview-release.yml +++ b/.github/workflows/preview-release.yml @@ -31,6 +31,14 @@ on: types: [labeled, synchronize] jobs: + debug-context: + runs-on: ubuntu-latest + steps: + - run: | + echo "repo=${{ github.repository }}" + echo "event_name=${{ github.event_name }}" + echo "labels=${{ toJson(github.event.pull_request.labels) }}" + echo "has_preview_label=${{ contains(github.event.pull_request.labels.*.name, 'trigger: preview') }}" preview: # Run only for PRs with 'trigger: preview' label or pushes to master if: > From 78e9fcc5257c60e4cc3f22ce45d12034370af73e Mon Sep 17 00:00:00 2001 From: avallete Date: Thu, 21 Aug 2025 13:59:55 +0200 Subject: [PATCH 4/5] chore: target pull_request_target events --- .github/workflows/preview-release.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml index 7c3caf33..5fbe4c49 100644 --- a/.github/workflows/preview-release.yml +++ b/.github/workflows/preview-release.yml @@ -31,14 +31,6 @@ on: types: [labeled, synchronize] jobs: - debug-context: - runs-on: ubuntu-latest - steps: - - run: | - echo "repo=${{ github.repository }}" - echo "event_name=${{ github.event_name }}" - echo "labels=${{ toJson(github.event.pull_request.labels) }}" - echo "has_preview_label=${{ contains(github.event.pull_request.labels.*.name, 'trigger: preview') }}" preview: # Run only for PRs with 'trigger: preview' label or pushes to master if: > @@ -46,7 +38,7 @@ jobs: ( github.event_name == 'workflow_dispatch' || github.event_name == 'push' || - (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'trigger: preview')) + (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger: preview')) ) runs-on: ubuntu-latest outputs: From 8526ef73c1dd92929e091ed46b3412609d4e68d7 Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo Date: Fri, 22 Aug 2025 02:58:03 +0800 Subject: [PATCH 5/5] chore: use from secrets instead of vars --- .github/workflows/preview-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml index 5fbe4c49..7e913602 100644 --- a/.github/workflows/preview-release.yml +++ b/.github/workflows/preview-release.yml @@ -94,7 +94,7 @@ jobs: id: generate-token uses: actions/create-github-app-token@v1 with: - app-id: ${{ vars.CROSS_REPO_APP_ID }} + app-id: ${{ secrets.CROSS_REPO_APP_ID }} private-key: ${{ secrets.CROSS_REPO_APP_PRIVATE_KEY }} owner: supabase repositories: postgrest-js,supabase-js