Skip to content

Commit

Permalink
db: update schema and generated types
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Jul 19, 2024
1 parent 7bc20de commit f621d0c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/supabase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"types": "./src/index.ts",
"scripts": {
"build": "bun run types && bun run schemas",
"types": "supabase gen types typescript --project-id jvpdyxpjpodxsuvhufpw > src/supa.types.ts",
"types": "supabase gen types gen types --lang=typescript --project-id mitkjznioyrucenuzsdb > src/supa.types.ts",
"schemas": "supabase-to-zod --input src/supa.types.ts --output src/supa.schemas.ts",
"fake": "bun run ./scripts/fake-orders.ts"
},
Expand Down
33 changes: 25 additions & 8 deletions apps/supabase/src/supa.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
.nullable(),
);

export const auctionDetailsRowSchema = z.object({
export const auctionsRowSchema = z.object({
address_auctioning_token: z.string().nullable(),
address_bidding_token: z.string().nullable(),
allow_list_manager: z.string().nullable(),
Expand Down Expand Up @@ -42,7 +42,7 @@ export const auctionDetailsRowSchema = z.object({
usd_amount_traded: z.number().nullable(),
});

export const auctionDetailsInsertSchema = z.object({
export const auctionsInsertSchema = z.object({
address_auctioning_token: z.string().optional().nullable(),
address_bidding_token: z.string().optional().nullable(),
allow_list_manager: z.string().optional().nullable(),
Expand Down Expand Up @@ -70,7 +70,7 @@ export const auctionDetailsInsertSchema = z.object({
usd_amount_traded: z.number().optional().nullable(),
});

export const auctionDetailsUpdateSchema = z.object({
export const auctionsUpdateSchema = z.object({
address_auctioning_token: z.string().optional().nullable(),
address_bidding_token: z.string().optional().nullable(),
allow_list_manager: z.string().optional().nullable(),
Expand Down Expand Up @@ -98,7 +98,7 @@ export const auctionDetailsUpdateSchema = z.object({
usd_amount_traded: z.number().optional().nullable(),
});

export const auctionDetailsRelationshipsSchema = z.tuple([]);
export const auctionsRelationshipsSchema = z.tuple([]);

export const esrRowSchema = z.object({
account: z.string().nullable(),
Expand Down Expand Up @@ -126,6 +126,23 @@ export const esrUpdateSchema = z.object({

export const esrRelationshipsSchema = z.tuple([]);

export const indexerRowSchema = z.object({
id: z.number(),
last_indexed_block: z.string(),
});

export const indexerInsertSchema = z.object({
id: z.number().optional(),
last_indexed_block: z.string(),
});

export const indexerUpdateSchema = z.object({
id: z.number().optional(),
last_indexed_block: z.string().optional(),
});

export const indexerRelationshipsSchema = z.tuple([]);

export const ordersRowSchema = z.object({
auction_id: z.number(),
buy_amount: z.number(),
Expand Down Expand Up @@ -164,7 +181,7 @@ export const ordersUpdateSchema = z.object({

export const ordersRelationshipsSchema = z.tuple([]);

export const preSaleRowSchema = z.object({
export const presaleRowSchema = z.object({
account: z.string().nullable(),
address: z.string().nullable(),
created_at: z.string(),
Expand All @@ -173,7 +190,7 @@ export const preSaleRowSchema = z.object({
signature: z.string().nullable(),
});

export const preSaleInsertSchema = z.object({
export const presaleInsertSchema = z.object({
account: z.string().optional().nullable(),
address: z.string().optional().nullable(),
created_at: z.string().optional(),
Expand All @@ -182,7 +199,7 @@ export const preSaleInsertSchema = z.object({
signature: z.string().optional().nullable(),
});

export const preSaleUpdateSchema = z.object({
export const presaleUpdateSchema = z.object({
account: z.string().optional().nullable(),
address: z.string().optional().nullable(),
created_at: z.string().optional(),
Expand All @@ -191,7 +208,7 @@ export const preSaleUpdateSchema = z.object({
signature: z.string().optional().nullable(),
});

export const preSaleRelationshipsSchema = z.tuple([]);
export const presaleRelationshipsSchema = z.tuple([]);

export const sessionRowSchema = z.object({
account: z.string(),
Expand Down
19 changes: 17 additions & 2 deletions apps/supabase/src/supa.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type Json =
export type Database = {
public: {
Tables: {
auction_details: {
auctions: {
Row: {
address_auctioning_token: string | null
address_bidding_token: string | null
Expand Down Expand Up @@ -117,6 +117,21 @@ export type Database = {
}
Relationships: []
}
indexer: {
Row: {
id: number
last_indexed_block: string
}
Insert: {
id?: number
last_indexed_block: string
}
Update: {
id?: number
last_indexed_block?: string
}
Relationships: []
}
orders: {
Row: {
auction_id: number
Expand Down Expand Up @@ -153,7 +168,7 @@ export type Database = {
}
Relationships: []
}
pre_sale: {
presale: {
Row: {
account: string | null
address: string | null
Expand Down

0 comments on commit f621d0c

Please sign in to comment.