From 49a9b079ea2e29c3cb0fbf28a594198f1999853b Mon Sep 17 00:00:00 2001 From: OllyNicholass Date: Tue, 17 Sep 2024 19:28:03 +0100 Subject: [PATCH] chore(#29): update generate database types location --- package.json | 2 +- src/app.d.ts | 2 +- src/hooks.server.ts | 2 +- {types => src/lib/types}/supabase.d.ts | 0 src/lib/utils/supabase/admin.ts | 6 +++--- 5 files changed, 6 insertions(+), 6 deletions(-) rename {types => src/lib/types}/supabase.d.ts (100%) diff --git a/package.json b/package.json index afe8db8..9af2e3f 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --check . && eslint .", "format": "prettier --write .", - "generate": "supabase gen types typescript --local > types/supabase.d.ts && prettier --write types/supabase.d.ts" + "generate": "supabase gen types typescript --local > src/lib/types/supabase.d.ts && prettier --write src/lib/types/supabase.d.ts" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.0.0", diff --git a/src/app.d.ts b/src/app.d.ts index dcc4861..b2b1e8f 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -2,7 +2,7 @@ // for information about these interfaces // and what to do when importing types import { SupabaseClient, Session, User } from '@supabase/supabase-js'; -import type { Database } from '$lib/generated/supabase-schema'; +import type { Database } from '$lib/types/supabase'; declare global { const __DATE__: string; const __RELOAD_SW__: boolean; diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 65c473d..06db40f 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,7 +1,7 @@ import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from '$env/static/public'; import { createServerClient } from '@supabase/ssr'; import type { Handle } from '@sveltejs/kit'; -import type { Database } from '$lib/generated/supabase-schema'; +import type { Database } from '$lib/types/supabase'; export const handle: Handle = async ({ event, resolve }) => { event.locals.supabase = createServerClient( diff --git a/types/supabase.d.ts b/src/lib/types/supabase.d.ts similarity index 100% rename from types/supabase.d.ts rename to src/lib/types/supabase.d.ts diff --git a/src/lib/utils/supabase/admin.ts b/src/lib/utils/supabase/admin.ts index 6a774d6..9fb94c3 100644 --- a/src/lib/utils/supabase/admin.ts +++ b/src/lib/utils/supabase/admin.ts @@ -1,6 +1,6 @@ import { createClient } from '@supabase/supabase-js'; import stripe from 'stripe'; -import type { Database, Tables, TablesInsert } from '$types/supabase'; +import type { Database, Tables, TablesInsert } from '$lib/types/supabase'; import { PUBLIC_SUPABASE_URL, PUBLIC_STRIPE_SECRET_KEY } from '$env/static/public'; import { SUPABASE_SERVICE_ROLE_KEY } from '$env/static/private'; @@ -34,8 +34,8 @@ const upsertProductRecord = async (product: stripe.Product) => { features: product.marketing_features.map(({ name }) => name || '').filter((name) => !!name), images: product.images ?? null, metadata: product.metadata, - created: new Date(product.created * 1000).toISOString(), - updated: new Date(product.updated * 1000).toISOString() + created_at: new Date(product.created * 1000).toISOString(), + updated_at: new Date(product.updated * 1000).toISOString() }; const { error: upsertError } = await supabaseAdmin.from('products').upsert([productData]);