Skip to content

Commit f72f819

Browse files
committed
chore: added types generation for the supabase db client
1 parent 699e699 commit f72f819

File tree

6 files changed

+635
-4
lines changed

6 files changed

+635
-4
lines changed

web/netlify/functions/update-settings.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { Handler } from "@netlify/functions";
22
import { verifyTypedData } from "viem";
33
import { createClient } from "@supabase/supabase-js";
4+
import { Database } from "../../src/types/supabase-notification";
45
import messages from "../../src/consts/eip712-messages";
56

6-
const SUPABASE_KEY = process.env.SUPABASE_CLIENT_API_KEY;
7-
const SUPABASE_URL = process.env.SUPABASE_URL;
8-
const supabase = createClient(SUPABASE_URL!, SUPABASE_KEY!);
7+
const supabase = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_CLIENT_API_KEY!);
98

109
export const handler: Handler = async (event) => {
1110
try {

web/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"check-types": "tsc --noEmit",
3535
"generate": "yarn generate:gql && yarn generate:hooks",
3636
"generate:gql": "graphql-codegen --require tsconfig-paths/register",
37-
"generate:hooks": "NODE_NO_WARNINGS=1 wagmi generate"
37+
"generate:hooks": "NODE_NO_WARNINGS=1 wagmi generate",
38+
"generate:supabase": "scripts/generateSupabaseTypes.sh"
3839
},
3940
"prettier": "@kleros/kleros-v2-prettier-config",
4041
"devDependencies": {
@@ -62,6 +63,7 @@
6263
"eslint-plugin-react-hooks": "^4.6.0",
6364
"lru-cache": "^7.18.3",
6465
"parcel": "2.8.3",
66+
"supabase": "^1.88.0",
6567
"typescript": "^4.9.5"
6668
},
6769
"dependencies": {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4+
5+
mkdir -p $SCRIPT_DIR/../src/types
6+
7+
# Docs: https://supabase.com/docs/guides/api/rest/generating-types#generating-types-using-supabase-cli
8+
supabase=$SCRIPT_DIR/../../node_modules/supabase/bin/supabase
9+
$supabase gen types typescript --project-id elokscrfhzodpgvaixfd --schema public > $SCRIPT_DIR/../src/types/supabase-notification.ts
10+
$supabase gen types typescript --project-id pyyfdntuqbsfquzzatkz --schema public > $SCRIPT_DIR/../src/types/supabase-datalake.ts

web/src/types/supabase-datalake.ts

Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[];
2+
3+
export interface Database {
4+
public: {
5+
Tables: {
6+
CIDs: {
7+
Row: {
8+
cid: string;
9+
estuary: boolean | null;
10+
file_headers: string | null;
11+
threat_detected: boolean | null;
12+
verified: boolean | null;
13+
};
14+
Insert: {
15+
cid: string;
16+
estuary?: boolean | null;
17+
file_headers?: string | null;
18+
threat_detected?: boolean | null;
19+
verified?: boolean | null;
20+
};
21+
Update: {
22+
cid?: string;
23+
estuary?: boolean | null;
24+
file_headers?: string | null;
25+
threat_detected?: boolean | null;
26+
verified?: boolean | null;
27+
};
28+
Relationships: [];
29+
};
30+
"court-v1-metaevidence": {
31+
Row: {
32+
arbitrable: string;
33+
chainId: number;
34+
metaEvidenceId: string;
35+
uri: string | null;
36+
};
37+
Insert: {
38+
arbitrable: string;
39+
chainId?: number;
40+
metaEvidenceId: string;
41+
uri?: string | null;
42+
};
43+
Update: {
44+
arbitrable?: string;
45+
chainId?: number;
46+
metaEvidenceId?: string;
47+
uri?: string | null;
48+
};
49+
Relationships: [];
50+
};
51+
"derived-accounts": {
52+
Row: {
53+
account: string;
54+
derived: string;
55+
};
56+
Insert: {
57+
account: string;
58+
derived: string;
59+
};
60+
Update: {
61+
account?: string;
62+
derived?: string;
63+
};
64+
Relationships: [];
65+
};
66+
"gnosischain-justifications": {
67+
Row: {
68+
created_at: string | null;
69+
disputeIDAndAppeal: string;
70+
id: string;
71+
justification: string;
72+
voteID: number;
73+
};
74+
Insert: {
75+
created_at?: string | null;
76+
disputeIDAndAppeal: string;
77+
id?: string;
78+
justification: string;
79+
voteID: number;
80+
};
81+
Update: {
82+
created_at?: string | null;
83+
disputeIDAndAppeal?: string;
84+
id?: string;
85+
justification?: string;
86+
voteID?: number;
87+
};
88+
Relationships: [];
89+
};
90+
historical: {
91+
Row: {
92+
block: number | null;
93+
chain_name: string;
94+
contract: string;
95+
event: string;
96+
logIndex: number;
97+
message: Json | null;
98+
project: string | null;
99+
routing_key: string;
100+
timestamp: string | null;
101+
tx: string;
102+
};
103+
Insert: {
104+
block?: number | null;
105+
chain_name: string;
106+
contract: string;
107+
event: string;
108+
logIndex: number;
109+
message?: Json | null;
110+
project?: string | null;
111+
routing_key: string;
112+
timestamp?: string | null;
113+
tx: string;
114+
};
115+
Update: {
116+
block?: number | null;
117+
chain_name?: string;
118+
contract?: string;
119+
event?: string;
120+
logIndex?: number;
121+
message?: Json | null;
122+
project?: string | null;
123+
routing_key?: string;
124+
timestamp?: string | null;
125+
tx?: string;
126+
};
127+
Relationships: [];
128+
};
129+
logbook: {
130+
Row: {
131+
dapp: string;
132+
lastSeenBlock: number | null;
133+
network: string | null;
134+
process: string;
135+
unix: number | null;
136+
};
137+
Insert: {
138+
dapp: string;
139+
lastSeenBlock?: number | null;
140+
network?: string | null;
141+
process: string;
142+
unix?: number | null;
143+
};
144+
Update: {
145+
dapp?: string;
146+
lastSeenBlock?: number | null;
147+
network?: string | null;
148+
process?: string;
149+
unix?: number | null;
150+
};
151+
Relationships: [];
152+
};
153+
"mainnet-justifications": {
154+
Row: {
155+
created_at: string | null;
156+
disputeIDAndAppeal: string | null;
157+
id: string;
158+
justification: string | null;
159+
voteID: number | null;
160+
};
161+
Insert: {
162+
created_at?: string | null;
163+
disputeIDAndAppeal?: string | null;
164+
id?: string;
165+
justification?: string | null;
166+
voteID?: number | null;
167+
};
168+
Update: {
169+
created_at?: string | null;
170+
disputeIDAndAppeal?: string | null;
171+
id?: string;
172+
justification?: string | null;
173+
voteID?: number | null;
174+
};
175+
Relationships: [];
176+
};
177+
"poh-vouchdb": {
178+
Row: {
179+
chainId: number;
180+
claimer: string;
181+
expiration: number;
182+
pohId: string;
183+
signature: string;
184+
voucher: string;
185+
};
186+
Insert: {
187+
chainId: number;
188+
claimer: string;
189+
expiration: number;
190+
pohId: string;
191+
signature: string;
192+
voucher: string;
193+
};
194+
Update: {
195+
chainId?: number;
196+
claimer?: string;
197+
expiration?: number;
198+
pohId?: string;
199+
signature?: string;
200+
voucher?: string;
201+
};
202+
Relationships: [];
203+
};
204+
"pohv2-events": {
205+
Row: {
206+
chain_name: string;
207+
log_index: number;
208+
tx: string;
209+
};
210+
Insert: {
211+
chain_name: string;
212+
log_index: number;
213+
tx: string;
214+
};
215+
Update: {
216+
chain_name?: string;
217+
log_index?: number;
218+
tx?: string;
219+
};
220+
Relationships: [];
221+
};
222+
"sce-contracts": {
223+
Row: {
224+
address: string;
225+
contract: Json | null;
226+
network: string;
227+
project: string | null;
228+
};
229+
Insert: {
230+
address: string;
231+
contract?: Json | null;
232+
network: string;
233+
project?: string | null;
234+
};
235+
Update: {
236+
address?: string;
237+
contract?: Json | null;
238+
network?: string;
239+
project?: string | null;
240+
};
241+
Relationships: [];
242+
};
243+
"sce-heights": {
244+
Row: {
245+
height: number;
246+
network: string;
247+
};
248+
Insert: {
249+
height: number;
250+
network: string;
251+
};
252+
Update: {
253+
height?: number;
254+
network?: string;
255+
};
256+
Relationships: [];
257+
};
258+
"sepolia-justifications": {
259+
Row: {
260+
created_at: string | null;
261+
disputeIDAndAppeal: string | null;
262+
id: number;
263+
justification: string | null;
264+
voteID: number | null;
265+
};
266+
Insert: {
267+
created_at?: string | null;
268+
disputeIDAndAppeal?: string | null;
269+
id?: number;
270+
justification?: string | null;
271+
voteID?: number | null;
272+
};
273+
Update: {
274+
created_at?: string | null;
275+
disputeIDAndAppeal?: string | null;
276+
id?: number;
277+
justification?: string | null;
278+
voteID?: number | null;
279+
};
280+
Relationships: [];
281+
};
282+
};
283+
Views: {
284+
[_ in never]: never;
285+
};
286+
Functions: {
287+
[_ in never]: never;
288+
};
289+
Enums: {
290+
[_ in never]: never;
291+
};
292+
CompositeTypes: {
293+
[_ in never]: never;
294+
};
295+
};
296+
}

0 commit comments

Comments
 (0)