From 6ad09cac32bf7b37969cc5c61841a96ab2a9baaf Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:24:19 +0200 Subject: [PATCH 1/2] chore: change TableV2 to Table (#443) --- .../library/powersync/AppSchema.ts | 6 +++--- demos/example-capacitor/src/library/powersync/AppSchema.ts | 4 ++-- demos/example-electron/src/library/powersync/AppSchema.ts | 4 ++-- demos/example-nextjs/src/library/powersync/AppSchema.ts | 4 ++-- .../src/library/powersync/AppSchema.ts | 2 +- .../src/library/powersync/AppSchema.ts | 6 +++--- .../src/library/powersync/AppSchema.ts | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/demos/django-react-native-todolist/library/powersync/AppSchema.ts b/demos/django-react-native-todolist/library/powersync/AppSchema.ts index 00ab261f..dd3a8c01 100644 --- a/demos/django-react-native-todolist/library/powersync/AppSchema.ts +++ b/demos/django-react-native-todolist/library/powersync/AppSchema.ts @@ -1,9 +1,9 @@ -import { column, Schema, TableV2 } from '@powersync/react-native'; +import { column, Schema, Table } from '@powersync/react-native'; export const LIST_TABLE = 'lists'; export const TODO_TABLE = 'todos'; -const todos = new TableV2( +const todos = new Table( { list_id: column.text, created_at: column.text, @@ -17,7 +17,7 @@ const todos = new TableV2( { indexes: { list: ['list_id'] } } ); -const lists = new TableV2({ +const lists = new Table({ created_at: column.text, name: column.text, owner_id: column.text diff --git a/demos/example-capacitor/src/library/powersync/AppSchema.ts b/demos/example-capacitor/src/library/powersync/AppSchema.ts index 94e71a39..3569f78f 100644 --- a/demos/example-capacitor/src/library/powersync/AppSchema.ts +++ b/demos/example-capacitor/src/library/powersync/AppSchema.ts @@ -1,6 +1,6 @@ -import { column, Schema, TableV2 } from '@powersync/web'; +import { column, Schema, Table } from '@powersync/web'; -const customers = new TableV2({ +const customers = new Table({ name: column.text, created_at: column.text }); diff --git a/demos/example-electron/src/library/powersync/AppSchema.ts b/demos/example-electron/src/library/powersync/AppSchema.ts index 94e71a39..3569f78f 100644 --- a/demos/example-electron/src/library/powersync/AppSchema.ts +++ b/demos/example-electron/src/library/powersync/AppSchema.ts @@ -1,6 +1,6 @@ -import { column, Schema, TableV2 } from '@powersync/web'; +import { column, Schema, Table } from '@powersync/web'; -const customers = new TableV2({ +const customers = new Table({ name: column.text, created_at: column.text }); diff --git a/demos/example-nextjs/src/library/powersync/AppSchema.ts b/demos/example-nextjs/src/library/powersync/AppSchema.ts index 94e71a39..3569f78f 100644 --- a/demos/example-nextjs/src/library/powersync/AppSchema.ts +++ b/demos/example-nextjs/src/library/powersync/AppSchema.ts @@ -1,6 +1,6 @@ -import { column, Schema, TableV2 } from '@powersync/web'; +import { column, Schema, Table } from '@powersync/web'; -const customers = new TableV2({ +const customers = new Table({ name: column.text, created_at: column.text }); diff --git a/demos/react-supabase-todolist-optional-sync/src/library/powersync/AppSchema.ts b/demos/react-supabase-todolist-optional-sync/src/library/powersync/AppSchema.ts index c7485e43..94a0a842 100644 --- a/demos/react-supabase-todolist-optional-sync/src/library/powersync/AppSchema.ts +++ b/demos/react-supabase-todolist-optional-sync/src/library/powersync/AppSchema.ts @@ -1,4 +1,4 @@ -import { AbstractPowerSyncDatabase, column, ColumnsType, Schema, Table, TableV2Options } from '@powersync/web'; +import { AbstractPowerSyncDatabase, column, Schema, Table } from '@powersync/web'; import { setSyncEnabled } from './SyncMode'; /** diff --git a/demos/vue-supabase-todolist/src/library/powersync/AppSchema.ts b/demos/vue-supabase-todolist/src/library/powersync/AppSchema.ts index f8796ee1..c9a32c03 100644 --- a/demos/vue-supabase-todolist/src/library/powersync/AppSchema.ts +++ b/demos/vue-supabase-todolist/src/library/powersync/AppSchema.ts @@ -1,9 +1,9 @@ -import { column, Schema, TableV2 } from '@powersync/web'; +import { column, Schema, Table } from '@powersync/web'; export const LISTS_TABLE = 'lists'; export const TODOS_TABLE = 'todos'; -const todos = new TableV2( +const todos = new Table( { list_id: column.text, created_at: column.text, @@ -16,7 +16,7 @@ const todos = new TableV2( { indexes: { list: ['list_id'] } } ); -const lists = new TableV2({ +const lists = new Table({ created_at: column.text, name: column.text, owner_id: column.text diff --git a/demos/yjs-react-supabase-text-collab/src/library/powersync/AppSchema.ts b/demos/yjs-react-supabase-text-collab/src/library/powersync/AppSchema.ts index 93f395a3..15cf6519 100644 --- a/demos/yjs-react-supabase-text-collab/src/library/powersync/AppSchema.ts +++ b/demos/yjs-react-supabase-text-collab/src/library/powersync/AppSchema.ts @@ -1,11 +1,11 @@ -import { column, Schema, TableV2 } from '@powersync/web'; +import { column, Schema, Table } from '@powersync/web'; -const documents = new TableV2({ +const documents = new Table({ title: column.text, created_at: column.text }); -const document_updates = new TableV2( +const document_updates = new Table( { document_id: column.text, created_at: column.text, From bd8c026f8d80e7fa6fa5e620a5b2f0d45578909f Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:31:34 +0200 Subject: [PATCH 2/2] chore: clean up connectors (#444) --- .../angular-supabase-todolist/src/app/supabase.service.ts | 4 +--- .../library/django/DjangoConnector.ts | 4 +--- demos/react-multi-client/src/library/SupabaseConnector.ts | 3 +-- .../react-native-supabase-group-chat/src/lib/connector.ts | 5 +---- .../library/supabase/SupabaseConnector.ts | 4 +--- .../library/supabase/SupabaseConnector.ts | 4 +--- .../src/library/powersync/SupabaseConnector.ts | 3 +-- .../src/library/powersync/SupabaseConnector.ts | 3 +-- .../src/library/powersync/SupabaseConnector.ts | 3 +-- .../src/library/powersync/SupabaseConnector.ts | 3 +-- .../supabase/functions/merge-document-updates/index.ts | 8 ++++---- .../src/db/sync/SharedWebStreamingSyncImplementation.ts | 3 +-- 12 files changed, 15 insertions(+), 32 deletions(-) diff --git a/demos/angular-supabase-todolist/src/app/supabase.service.ts b/demos/angular-supabase-todolist/src/app/supabase.service.ts index 9c59931e..5e71ba5d 100644 --- a/demos/angular-supabase-todolist/src/app/supabase.service.ts +++ b/demos/angular-supabase-todolist/src/app/supabase.service.ts @@ -65,10 +65,8 @@ export class SupabaseService implements PowerSyncBackendConnector { } return { - client: this.supabase, endpoint: environment.powersyncUrl, - token: session.access_token ?? '', - expiresAt: session.expires_at ? new Date(session.expires_at * 1000) : undefined + token: session.access_token ?? '' }; } diff --git a/demos/django-react-native-todolist/library/django/DjangoConnector.ts b/demos/django-react-native-todolist/library/django/DjangoConnector.ts index 417000ae..e6ca31dd 100644 --- a/demos/django-react-native-todolist/library/django/DjangoConnector.ts +++ b/demos/django-react-native-todolist/library/django/DjangoConnector.ts @@ -45,9 +45,7 @@ export class DjangoConnector implements PowerSyncBackendConnector { const session = await this.apiClient.getToken(userId); return { endpoint: AppConfig.powersyncUrl, - token: session.token ?? '', - expiresAt: undefined, - userID: userId + token: session.token ?? '' }; } diff --git a/demos/react-multi-client/src/library/SupabaseConnector.ts b/demos/react-multi-client/src/library/SupabaseConnector.ts index 589b9f0b..c2e238af 100644 --- a/demos/react-multi-client/src/library/SupabaseConnector.ts +++ b/demos/react-multi-client/src/library/SupabaseConnector.ts @@ -70,8 +70,7 @@ export class SupabaseConnector extends BaseObserver i return { token: token, - endpoint: import.meta.env.VITE_POWERSYNC_URL, - expiresAt: expires_at ? new Date(expires_at) : undefined + endpoint: import.meta.env.VITE_POWERSYNC_URL }; } diff --git a/demos/react-native-supabase-group-chat/src/lib/connector.ts b/demos/react-native-supabase-group-chat/src/lib/connector.ts index 49955633..69bb9e31 100644 --- a/demos/react-native-supabase-group-chat/src/lib/connector.ts +++ b/demos/react-native-supabase-group-chat/src/lib/connector.ts @@ -36,11 +36,8 @@ export class Connector implements PowerSyncBackendConnector { console.debug('session expires at', session.expires_at); return { - client: this.supabaseClient, endpoint: config.powerSyncUrl, - token: session.access_token ?? '', - expiresAt: session.expires_at ? new Date(session.expires_at * 1000) : undefined, - userID: session.user.id + token: session.access_token ?? '' }; } diff --git a/demos/react-native-supabase-todolist/library/supabase/SupabaseConnector.ts b/demos/react-native-supabase-todolist/library/supabase/SupabaseConnector.ts index 6c6db246..1ace8192 100644 --- a/demos/react-native-supabase-todolist/library/supabase/SupabaseConnector.ts +++ b/demos/react-native-supabase-todolist/library/supabase/SupabaseConnector.ts @@ -56,9 +56,7 @@ export class SupabaseConnector implements PowerSyncBackendConnector { return { endpoint: AppConfig.powersyncUrl, - token: session.access_token ?? '', - expiresAt: session.expires_at ? new Date(session.expires_at * 1000) : undefined, - userID: session.user.id + token: session.access_token ?? '' }; } diff --git a/demos/react-native-web-supabase-todolist/library/supabase/SupabaseConnector.ts b/demos/react-native-web-supabase-todolist/library/supabase/SupabaseConnector.ts index 5a20632a..e1f50b52 100644 --- a/demos/react-native-web-supabase-todolist/library/supabase/SupabaseConnector.ts +++ b/demos/react-native-web-supabase-todolist/library/supabase/SupabaseConnector.ts @@ -56,9 +56,7 @@ export class SupabaseConnector implements PowerSyncBackendConnector { return { endpoint: AppConfig.powersyncUrl, - token: session.access_token ?? '', - expiresAt: session.expires_at ? new Date(session.expires_at * 1000) : undefined, - userID: session.user.id + token: session.access_token ?? '' }; } diff --git a/demos/react-supabase-todolist-optional-sync/src/library/powersync/SupabaseConnector.ts b/demos/react-supabase-todolist-optional-sync/src/library/powersync/SupabaseConnector.ts index c999c3b1..45690970 100644 --- a/demos/react-supabase-todolist-optional-sync/src/library/powersync/SupabaseConnector.ts +++ b/demos/react-supabase-todolist-optional-sync/src/library/powersync/SupabaseConnector.ts @@ -112,8 +112,7 @@ export class SupabaseConnector extends BaseObserver i return { endpoint: this.config.powersyncUrl, - token: session.access_token ?? '', - expiresAt: session.expires_at ? new Date(session.expires_at * 1000) : undefined + token: session.access_token ?? '' }; } diff --git a/demos/react-supabase-todolist/src/library/powersync/SupabaseConnector.ts b/demos/react-supabase-todolist/src/library/powersync/SupabaseConnector.ts index 12386845..85c1cc29 100644 --- a/demos/react-supabase-todolist/src/library/powersync/SupabaseConnector.ts +++ b/demos/react-supabase-todolist/src/library/powersync/SupabaseConnector.ts @@ -98,8 +98,7 @@ export class SupabaseConnector extends BaseObserver i return { endpoint: this.config.powersyncUrl, - token: session.access_token ?? '', - expiresAt: session.expires_at ? new Date(session.expires_at * 1000) : undefined + token: session.access_token ?? '' }; } diff --git a/demos/vue-supabase-todolist/src/library/powersync/SupabaseConnector.ts b/demos/vue-supabase-todolist/src/library/powersync/SupabaseConnector.ts index 12386845..85c1cc29 100644 --- a/demos/vue-supabase-todolist/src/library/powersync/SupabaseConnector.ts +++ b/demos/vue-supabase-todolist/src/library/powersync/SupabaseConnector.ts @@ -98,8 +98,7 @@ export class SupabaseConnector extends BaseObserver i return { endpoint: this.config.powersyncUrl, - token: session.access_token ?? '', - expiresAt: session.expires_at ? new Date(session.expires_at * 1000) : undefined + token: session.access_token ?? '' }; } diff --git a/demos/yjs-react-supabase-text-collab/src/library/powersync/SupabaseConnector.ts b/demos/yjs-react-supabase-text-collab/src/library/powersync/SupabaseConnector.ts index 986264eb..7ffcd09a 100644 --- a/demos/yjs-react-supabase-text-collab/src/library/powersync/SupabaseConnector.ts +++ b/demos/yjs-react-supabase-text-collab/src/library/powersync/SupabaseConnector.ts @@ -69,8 +69,7 @@ export class SupabaseConnector extends BaseObserver i return { endpoint: data.powersync_url, - token: data.token, - expiresAt: undefined + token: data.token }; } diff --git a/demos/yjs-react-supabase-text-collab/supabase/functions/merge-document-updates/index.ts b/demos/yjs-react-supabase-text-collab/supabase/functions/merge-document-updates/index.ts index 340e6592..8e23df2f 100644 --- a/demos/yjs-react-supabase-text-collab/supabase/functions/merge-document-updates/index.ts +++ b/demos/yjs-react-supabase-text-collab/supabase/functions/merge-document-updates/index.ts @@ -71,10 +71,10 @@ Deno.serve(async (req) => { } ); } catch (err) { - return new Response( - JSON.stringify({ error: String(err?.message ?? err) }), - { status: 500, headers: responseHeaders } - ); + return new Response(JSON.stringify({ error: String(err?.message ?? err) }), { + status: 500, + headers: responseHeaders + }); } }); diff --git a/packages/web/src/db/sync/SharedWebStreamingSyncImplementation.ts b/packages/web/src/db/sync/SharedWebStreamingSyncImplementation.ts index 934cfa58..43d22a79 100644 --- a/packages/web/src/db/sync/SharedWebStreamingSyncImplementation.ts +++ b/packages/web/src/db/sync/SharedWebStreamingSyncImplementation.ts @@ -38,8 +38,7 @@ class SharedSyncClientProvider extends AbstractSharedSyncClientProvider { */ return { endpoint: credentials.endpoint, - token: credentials.token, - expiresAt: credentials.expiresAt + token: credentials.token }; }