mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-13 02:53:50 +00:00
chore(#29): update generate database types location
This commit is contained in:
Vendored
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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<Database>(
|
||||
|
||||
Vendored
+639
@@ -0,0 +1,639 @@
|
||||
export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[];
|
||||
|
||||
export type Database = {
|
||||
graphql_public: {
|
||||
Tables: {
|
||||
[_ in never]: never;
|
||||
};
|
||||
Views: {
|
||||
[_ in never]: never;
|
||||
};
|
||||
Functions: {
|
||||
graphql: {
|
||||
Args: {
|
||||
operationName?: string;
|
||||
query?: string;
|
||||
variables?: Json;
|
||||
extensions?: Json;
|
||||
};
|
||||
Returns: Json;
|
||||
};
|
||||
};
|
||||
Enums: {
|
||||
[_ in never]: never;
|
||||
};
|
||||
CompositeTypes: {
|
||||
[_ in never]: never;
|
||||
};
|
||||
};
|
||||
public: {
|
||||
Tables: {
|
||||
customers: {
|
||||
Row: {
|
||||
id: string;
|
||||
stripe_customer_id: string | null;
|
||||
};
|
||||
Insert: {
|
||||
id: string;
|
||||
stripe_customer_id?: string | null;
|
||||
};
|
||||
Update: {
|
||||
id?: string;
|
||||
stripe_customer_id?: string | null;
|
||||
};
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: 'customers_id_fkey';
|
||||
columns: ['id'];
|
||||
isOneToOne: true;
|
||||
referencedRelation: 'users';
|
||||
referencedColumns: ['id'];
|
||||
}
|
||||
];
|
||||
};
|
||||
prices: {
|
||||
Row: {
|
||||
active: boolean | null;
|
||||
currency: string | null;
|
||||
description: string | null;
|
||||
id: string;
|
||||
interval: Database['public']['Enums']['pricing_plan_interval'] | null;
|
||||
interval_count: number | null;
|
||||
metadata: Json | null;
|
||||
product_id: string;
|
||||
trial_period_days: number | null;
|
||||
type: Database['public']['Enums']['pricing_type'] | null;
|
||||
unit_amount: number | null;
|
||||
};
|
||||
Insert: {
|
||||
active?: boolean | null;
|
||||
currency?: string | null;
|
||||
description?: string | null;
|
||||
id: string;
|
||||
interval?: Database['public']['Enums']['pricing_plan_interval'] | null;
|
||||
interval_count?: number | null;
|
||||
metadata?: Json | null;
|
||||
product_id: string;
|
||||
trial_period_days?: number | null;
|
||||
type?: Database['public']['Enums']['pricing_type'] | null;
|
||||
unit_amount?: number | null;
|
||||
};
|
||||
Update: {
|
||||
active?: boolean | null;
|
||||
currency?: string | null;
|
||||
description?: string | null;
|
||||
id?: string;
|
||||
interval?: Database['public']['Enums']['pricing_plan_interval'] | null;
|
||||
interval_count?: number | null;
|
||||
metadata?: Json | null;
|
||||
product_id?: string;
|
||||
trial_period_days?: number | null;
|
||||
type?: Database['public']['Enums']['pricing_type'] | null;
|
||||
unit_amount?: number | null;
|
||||
};
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: 'prices_product_id_fkey';
|
||||
columns: ['product_id'];
|
||||
isOneToOne: false;
|
||||
referencedRelation: 'products';
|
||||
referencedColumns: ['id'];
|
||||
}
|
||||
];
|
||||
};
|
||||
products: {
|
||||
Row: {
|
||||
active: boolean | null;
|
||||
created_at: string;
|
||||
description: string | null;
|
||||
features: string[] | null;
|
||||
id: string;
|
||||
images: string[] | null;
|
||||
metadata: Json | null;
|
||||
name: string | null;
|
||||
updated_at: string;
|
||||
};
|
||||
Insert: {
|
||||
active?: boolean | null;
|
||||
created_at?: string;
|
||||
description?: string | null;
|
||||
features?: string[] | null;
|
||||
id: string;
|
||||
images?: string[] | null;
|
||||
metadata?: Json | null;
|
||||
name?: string | null;
|
||||
updated_at?: string;
|
||||
};
|
||||
Update: {
|
||||
active?: boolean | null;
|
||||
created_at?: string;
|
||||
description?: string | null;
|
||||
features?: string[] | null;
|
||||
id?: string;
|
||||
images?: string[] | null;
|
||||
metadata?: Json | null;
|
||||
name?: string | null;
|
||||
updated_at?: string;
|
||||
};
|
||||
Relationships: [];
|
||||
};
|
||||
subscriptions: {
|
||||
Row: {
|
||||
cancel_at: string | null;
|
||||
cancel_at_period_end: boolean | null;
|
||||
canceled_at: string | null;
|
||||
created: string;
|
||||
current_period_end: string;
|
||||
current_period_start: string;
|
||||
ended_at: string | null;
|
||||
id: string;
|
||||
metadata: Json | null;
|
||||
price_id: string | null;
|
||||
quantity: number | null;
|
||||
status: Database['public']['Enums']['subscription_status'] | null;
|
||||
trial_end: string | null;
|
||||
trial_start: string | null;
|
||||
user_id: string;
|
||||
};
|
||||
Insert: {
|
||||
cancel_at?: string | null;
|
||||
cancel_at_period_end?: boolean | null;
|
||||
canceled_at?: string | null;
|
||||
created?: string;
|
||||
current_period_end?: string;
|
||||
current_period_start?: string;
|
||||
ended_at?: string | null;
|
||||
id: string;
|
||||
metadata?: Json | null;
|
||||
price_id?: string | null;
|
||||
quantity?: number | null;
|
||||
status?: Database['public']['Enums']['subscription_status'] | null;
|
||||
trial_end?: string | null;
|
||||
trial_start?: string | null;
|
||||
user_id: string;
|
||||
};
|
||||
Update: {
|
||||
cancel_at?: string | null;
|
||||
cancel_at_period_end?: boolean | null;
|
||||
canceled_at?: string | null;
|
||||
created?: string;
|
||||
current_period_end?: string;
|
||||
current_period_start?: string;
|
||||
ended_at?: string | null;
|
||||
id?: string;
|
||||
metadata?: Json | null;
|
||||
price_id?: string | null;
|
||||
quantity?: number | null;
|
||||
status?: Database['public']['Enums']['subscription_status'] | null;
|
||||
trial_end?: string | null;
|
||||
trial_start?: string | null;
|
||||
user_id?: string;
|
||||
};
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: 'subscriptions_price_id_fkey';
|
||||
columns: ['price_id'];
|
||||
isOneToOne: false;
|
||||
referencedRelation: 'prices';
|
||||
referencedColumns: ['id'];
|
||||
},
|
||||
{
|
||||
foreignKeyName: 'subscriptions_user_id_fkey';
|
||||
columns: ['user_id'];
|
||||
isOneToOne: false;
|
||||
referencedRelation: 'users';
|
||||
referencedColumns: ['id'];
|
||||
}
|
||||
];
|
||||
};
|
||||
users: {
|
||||
Row: {
|
||||
id: string;
|
||||
name: string | null;
|
||||
};
|
||||
Insert: {
|
||||
id: string;
|
||||
name?: string | null;
|
||||
};
|
||||
Update: {
|
||||
id?: string;
|
||||
name?: string | null;
|
||||
};
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: 'users_id_fkey';
|
||||
columns: ['id'];
|
||||
isOneToOne: true;
|
||||
referencedRelation: 'users';
|
||||
referencedColumns: ['id'];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
Views: {
|
||||
[_ in never]: never;
|
||||
};
|
||||
Functions: {
|
||||
[_ in never]: never;
|
||||
};
|
||||
Enums: {
|
||||
pricing_plan_interval: 'day' | 'week' | 'month' | 'year';
|
||||
pricing_type: 'one_time' | 'recurring';
|
||||
subscription_status:
|
||||
| 'trialing'
|
||||
| 'active'
|
||||
| 'canceled'
|
||||
| 'incomplete'
|
||||
| 'incomplete_expired'
|
||||
| 'past_due'
|
||||
| 'unpaid'
|
||||
| 'paused';
|
||||
};
|
||||
CompositeTypes: {
|
||||
[_ in never]: never;
|
||||
};
|
||||
};
|
||||
storage: {
|
||||
Tables: {
|
||||
buckets: {
|
||||
Row: {
|
||||
allowed_mime_types: string[] | null;
|
||||
avif_autodetection: boolean | null;
|
||||
created_at: string | null;
|
||||
file_size_limit: number | null;
|
||||
id: string;
|
||||
name: string;
|
||||
owner: string | null;
|
||||
owner_id: string | null;
|
||||
public: boolean | null;
|
||||
updated_at: string | null;
|
||||
};
|
||||
Insert: {
|
||||
allowed_mime_types?: string[] | null;
|
||||
avif_autodetection?: boolean | null;
|
||||
created_at?: string | null;
|
||||
file_size_limit?: number | null;
|
||||
id: string;
|
||||
name: string;
|
||||
owner?: string | null;
|
||||
owner_id?: string | null;
|
||||
public?: boolean | null;
|
||||
updated_at?: string | null;
|
||||
};
|
||||
Update: {
|
||||
allowed_mime_types?: string[] | null;
|
||||
avif_autodetection?: boolean | null;
|
||||
created_at?: string | null;
|
||||
file_size_limit?: number | null;
|
||||
id?: string;
|
||||
name?: string;
|
||||
owner?: string | null;
|
||||
owner_id?: string | null;
|
||||
public?: boolean | null;
|
||||
updated_at?: string | null;
|
||||
};
|
||||
Relationships: [];
|
||||
};
|
||||
migrations: {
|
||||
Row: {
|
||||
executed_at: string | null;
|
||||
hash: string;
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
Insert: {
|
||||
executed_at?: string | null;
|
||||
hash: string;
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
Update: {
|
||||
executed_at?: string | null;
|
||||
hash?: string;
|
||||
id?: number;
|
||||
name?: string;
|
||||
};
|
||||
Relationships: [];
|
||||
};
|
||||
objects: {
|
||||
Row: {
|
||||
bucket_id: string | null;
|
||||
created_at: string | null;
|
||||
id: string;
|
||||
last_accessed_at: string | null;
|
||||
metadata: Json | null;
|
||||
name: string | null;
|
||||
owner: string | null;
|
||||
owner_id: string | null;
|
||||
path_tokens: string[] | null;
|
||||
updated_at: string | null;
|
||||
version: string | null;
|
||||
};
|
||||
Insert: {
|
||||
bucket_id?: string | null;
|
||||
created_at?: string | null;
|
||||
id?: string;
|
||||
last_accessed_at?: string | null;
|
||||
metadata?: Json | null;
|
||||
name?: string | null;
|
||||
owner?: string | null;
|
||||
owner_id?: string | null;
|
||||
path_tokens?: string[] | null;
|
||||
updated_at?: string | null;
|
||||
version?: string | null;
|
||||
};
|
||||
Update: {
|
||||
bucket_id?: string | null;
|
||||
created_at?: string | null;
|
||||
id?: string;
|
||||
last_accessed_at?: string | null;
|
||||
metadata?: Json | null;
|
||||
name?: string | null;
|
||||
owner?: string | null;
|
||||
owner_id?: string | null;
|
||||
path_tokens?: string[] | null;
|
||||
updated_at?: string | null;
|
||||
version?: string | null;
|
||||
};
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: 'objects_bucketId_fkey';
|
||||
columns: ['bucket_id'];
|
||||
isOneToOne: false;
|
||||
referencedRelation: 'buckets';
|
||||
referencedColumns: ['id'];
|
||||
}
|
||||
];
|
||||
};
|
||||
s3_multipart_uploads: {
|
||||
Row: {
|
||||
bucket_id: string;
|
||||
created_at: string;
|
||||
id: string;
|
||||
in_progress_size: number;
|
||||
key: string;
|
||||
owner_id: string | null;
|
||||
upload_signature: string;
|
||||
version: string;
|
||||
};
|
||||
Insert: {
|
||||
bucket_id: string;
|
||||
created_at?: string;
|
||||
id: string;
|
||||
in_progress_size?: number;
|
||||
key: string;
|
||||
owner_id?: string | null;
|
||||
upload_signature: string;
|
||||
version: string;
|
||||
};
|
||||
Update: {
|
||||
bucket_id?: string;
|
||||
created_at?: string;
|
||||
id?: string;
|
||||
in_progress_size?: number;
|
||||
key?: string;
|
||||
owner_id?: string | null;
|
||||
upload_signature?: string;
|
||||
version?: string;
|
||||
};
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: 's3_multipart_uploads_bucket_id_fkey';
|
||||
columns: ['bucket_id'];
|
||||
isOneToOne: false;
|
||||
referencedRelation: 'buckets';
|
||||
referencedColumns: ['id'];
|
||||
}
|
||||
];
|
||||
};
|
||||
s3_multipart_uploads_parts: {
|
||||
Row: {
|
||||
bucket_id: string;
|
||||
created_at: string;
|
||||
etag: string;
|
||||
id: string;
|
||||
key: string;
|
||||
owner_id: string | null;
|
||||
part_number: number;
|
||||
size: number;
|
||||
upload_id: string;
|
||||
version: string;
|
||||
};
|
||||
Insert: {
|
||||
bucket_id: string;
|
||||
created_at?: string;
|
||||
etag: string;
|
||||
id?: string;
|
||||
key: string;
|
||||
owner_id?: string | null;
|
||||
part_number: number;
|
||||
size?: number;
|
||||
upload_id: string;
|
||||
version: string;
|
||||
};
|
||||
Update: {
|
||||
bucket_id?: string;
|
||||
created_at?: string;
|
||||
etag?: string;
|
||||
id?: string;
|
||||
key?: string;
|
||||
owner_id?: string | null;
|
||||
part_number?: number;
|
||||
size?: number;
|
||||
upload_id?: string;
|
||||
version?: string;
|
||||
};
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: 's3_multipart_uploads_parts_bucket_id_fkey';
|
||||
columns: ['bucket_id'];
|
||||
isOneToOne: false;
|
||||
referencedRelation: 'buckets';
|
||||
referencedColumns: ['id'];
|
||||
},
|
||||
{
|
||||
foreignKeyName: 's3_multipart_uploads_parts_upload_id_fkey';
|
||||
columns: ['upload_id'];
|
||||
isOneToOne: false;
|
||||
referencedRelation: 's3_multipart_uploads';
|
||||
referencedColumns: ['id'];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
Views: {
|
||||
[_ in never]: never;
|
||||
};
|
||||
Functions: {
|
||||
can_insert_object: {
|
||||
Args: {
|
||||
bucketid: string;
|
||||
name: string;
|
||||
owner: string;
|
||||
metadata: Json;
|
||||
};
|
||||
Returns: undefined;
|
||||
};
|
||||
extension: {
|
||||
Args: {
|
||||
name: string;
|
||||
};
|
||||
Returns: string;
|
||||
};
|
||||
filename: {
|
||||
Args: {
|
||||
name: string;
|
||||
};
|
||||
Returns: string;
|
||||
};
|
||||
foldername: {
|
||||
Args: {
|
||||
name: string;
|
||||
};
|
||||
Returns: string[];
|
||||
};
|
||||
get_size_by_bucket: {
|
||||
Args: Record<PropertyKey, never>;
|
||||
Returns: {
|
||||
size: number;
|
||||
bucket_id: string;
|
||||
}[];
|
||||
};
|
||||
list_multipart_uploads_with_delimiter: {
|
||||
Args: {
|
||||
bucket_id: string;
|
||||
prefix_param: string;
|
||||
delimiter_param: string;
|
||||
max_keys?: number;
|
||||
next_key_token?: string;
|
||||
next_upload_token?: string;
|
||||
};
|
||||
Returns: {
|
||||
key: string;
|
||||
id: string;
|
||||
created_at: string;
|
||||
}[];
|
||||
};
|
||||
list_objects_with_delimiter: {
|
||||
Args: {
|
||||
bucket_id: string;
|
||||
prefix_param: string;
|
||||
delimiter_param: string;
|
||||
max_keys?: number;
|
||||
start_after?: string;
|
||||
next_token?: string;
|
||||
};
|
||||
Returns: {
|
||||
name: string;
|
||||
id: string;
|
||||
metadata: Json;
|
||||
updated_at: string;
|
||||
}[];
|
||||
};
|
||||
operation: {
|
||||
Args: Record<PropertyKey, never>;
|
||||
Returns: string;
|
||||
};
|
||||
search: {
|
||||
Args: {
|
||||
prefix: string;
|
||||
bucketname: string;
|
||||
limits?: number;
|
||||
levels?: number;
|
||||
offsets?: number;
|
||||
search?: string;
|
||||
sortcolumn?: string;
|
||||
sortorder?: string;
|
||||
};
|
||||
Returns: {
|
||||
name: string;
|
||||
id: string;
|
||||
updated_at: string;
|
||||
created_at: string;
|
||||
last_accessed_at: string;
|
||||
metadata: Json;
|
||||
}[];
|
||||
};
|
||||
};
|
||||
Enums: {
|
||||
[_ in never]: never;
|
||||
};
|
||||
CompositeTypes: {
|
||||
[_ in never]: never;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
type PublicSchema = Database[Extract<keyof Database, 'public'>];
|
||||
|
||||
export type Tables<
|
||||
PublicTableNameOrOptions extends
|
||||
| keyof (PublicSchema['Tables'] & PublicSchema['Views'])
|
||||
| { schema: keyof Database },
|
||||
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
|
||||
? keyof (Database[PublicTableNameOrOptions['schema']]['Tables'] &
|
||||
Database[PublicTableNameOrOptions['schema']]['Views'])
|
||||
: never = never
|
||||
> = PublicTableNameOrOptions extends { schema: keyof Database }
|
||||
? (Database[PublicTableNameOrOptions['schema']]['Tables'] &
|
||||
Database[PublicTableNameOrOptions['schema']]['Views'])[TableName] extends {
|
||||
Row: infer R;
|
||||
}
|
||||
? R
|
||||
: never
|
||||
: PublicTableNameOrOptions extends keyof (PublicSchema['Tables'] & PublicSchema['Views'])
|
||||
? (PublicSchema['Tables'] & PublicSchema['Views'])[PublicTableNameOrOptions] extends {
|
||||
Row: infer R;
|
||||
}
|
||||
? R
|
||||
: never
|
||||
: never;
|
||||
|
||||
export type TablesInsert<
|
||||
PublicTableNameOrOptions extends keyof PublicSchema['Tables'] | { schema: keyof Database },
|
||||
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
|
||||
? keyof Database[PublicTableNameOrOptions['schema']]['Tables']
|
||||
: never = never
|
||||
> = PublicTableNameOrOptions extends { schema: keyof Database }
|
||||
? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends {
|
||||
Insert: infer I;
|
||||
}
|
||||
? I
|
||||
: never
|
||||
: PublicTableNameOrOptions extends keyof PublicSchema['Tables']
|
||||
? PublicSchema['Tables'][PublicTableNameOrOptions] extends {
|
||||
Insert: infer I;
|
||||
}
|
||||
? I
|
||||
: never
|
||||
: never;
|
||||
|
||||
export type TablesUpdate<
|
||||
PublicTableNameOrOptions extends keyof PublicSchema['Tables'] | { schema: keyof Database },
|
||||
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
|
||||
? keyof Database[PublicTableNameOrOptions['schema']]['Tables']
|
||||
: never = never
|
||||
> = PublicTableNameOrOptions extends { schema: keyof Database }
|
||||
? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends {
|
||||
Update: infer U;
|
||||
}
|
||||
? U
|
||||
: never
|
||||
: PublicTableNameOrOptions extends keyof PublicSchema['Tables']
|
||||
? PublicSchema['Tables'][PublicTableNameOrOptions] extends {
|
||||
Update: infer U;
|
||||
}
|
||||
? U
|
||||
: never
|
||||
: never;
|
||||
|
||||
export type Enums<
|
||||
PublicEnumNameOrOptions extends keyof PublicSchema['Enums'] | { schema: keyof Database },
|
||||
EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
|
||||
? keyof Database[PublicEnumNameOrOptions['schema']]['Enums']
|
||||
: never = never
|
||||
> = PublicEnumNameOrOptions extends { schema: keyof Database }
|
||||
? Database[PublicEnumNameOrOptions['schema']]['Enums'][EnumName]
|
||||
: PublicEnumNameOrOptions extends keyof PublicSchema['Enums']
|
||||
? PublicSchema['Enums'][PublicEnumNameOrOptions]
|
||||
: never;
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user