Skip to content

Commit 1af6b84

Browse files
hfjoshenlim
andauthored
types are broken (supabase#39866)
* types are broken * Fix TS issues --------- Co-authored-by: Joshen Lim <[email protected]>
1 parent f647316 commit 1af6b84

File tree

13 files changed

+490
-2173
lines changed

13 files changed

+490
-2173
lines changed

apps/studio/components/interfaces/Database/Privileges/Privileges.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,14 @@ export function useApplyPrivilegeOperations(callback?: () => void) {
300300
.map((op) => ({
301301
column_id: String(op.id),
302302
grantee: op.grantee,
303-
privilege_type: op.privilege_type as ColumnPrivilegesRevoke[number]['privilege_type'],
303+
privilege_type: op.privilege_type as ColumnPrivilegesRevoke['privilege_type'],
304304
}))
305305
const revokeColumnOperations = columnOperations
306306
.filter((op) => op.type === 'revoke')
307307
.map((op) => ({
308308
column_id: String(op.id),
309309
grantee: op.grantee,
310-
privilege_type: op.privilege_type as ColumnPrivilegesRevoke[number]['privilege_type'],
310+
privilege_type: op.privilege_type as ColumnPrivilegesRevoke['privilege_type'],
311311
}))
312312

313313
// annoyingly these can't be run all at once

apps/studio/components/interfaces/LogDrains/LogDrainDestinationSheetForm.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ const formUnion = z.discriminatedUnion('type', [
5555
api_key: z.string().min(1, { message: 'API key is required' }),
5656
region: z.string().min(1, { message: 'Region is required' }),
5757
}),
58+
z.object({
59+
type: z.literal('loki'),
60+
url: z.string().min(1, { message: 'Loki URL is required' }),
61+
headers: z.record(z.string(), z.string()),
62+
username: z.string().optional(),
63+
password: z.string().optional(),
64+
}),
65+
// [Joshen] To fix API types, not supported in the UI
5866
z.object({
5967
type: z.literal('elastic'),
6068
}),
@@ -65,11 +73,13 @@ const formUnion = z.discriminatedUnion('type', [
6573
type: z.literal('bigquery'),
6674
}),
6775
z.object({
68-
type: z.literal('loki'),
69-
url: z.string().min(1, { message: 'Loki URL is required' }),
70-
headers: z.record(z.string(), z.string()),
71-
username: z.string().optional(),
72-
password: z.string().optional(),
76+
type: z.literal('clickhouse'),
77+
}),
78+
z.object({
79+
type: z.literal('s3'),
80+
}),
81+
z.object({
82+
type: z.literal('sentry'),
7383
}),
7484
])
7585

apps/studio/components/interfaces/LogDrains/LogDrains.constants.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { BracesIcon } from 'lucide-react'
1+
import { components } from 'api-types'
22
import { Datadog, Grafana } from 'icons'
3+
import { BracesIcon } from 'lucide-react'
34

45
const iconProps = {
56
height: 24,
@@ -31,11 +32,13 @@ export const LOG_DRAIN_TYPES = [
3132

3233
export const LOG_DRAIN_SOURCE_VALUES = LOG_DRAIN_TYPES.map((source) => source.value)
3334

34-
export type LogDrainType =
35-
| (typeof LOG_DRAIN_TYPES)[number]['value']
36-
| 'postgres'
37-
| 'bigquery'
38-
| 'elastic'
35+
// export type LogDrainType =
36+
// | (typeof LOG_DRAIN_TYPES)[number]['value']
37+
// | 'postgres'
38+
// | 'bigquery'
39+
// | 'elastic'
40+
41+
export type LogDrainType = components['schemas']['LFBackend']['type']
3942

4043
export const DATADOG_REGIONS = [
4144
{

apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import type { Dictionary } from 'types'
44

55
import { FOREIGN_KEY_CASCADE_ACTION } from 'data/database/database-query-constants'
66
import type { ForeignKeyConstraint } from 'data/database/foreign-key-constraints-query'
7+
import type { RetrievedTableColumn, RetrieveTableResult } from 'data/tables/table-retrieve-query'
78
import { uuidv4 } from 'lib/helpers'
9+
import { toast } from 'sonner'
810
import {
911
ColumnField,
1012
CreateColumnPayload,
1113
ExtendedPostgresRelationship,
1214
UpdateColumnPayload,
1315
} from '../SidePanelEditor.types'
14-
import type { RetrievedTableColumn, RetrieveTableResult } from 'data/tables/table-retrieve-query'
15-
import { toast } from 'sonner'
1616

1717
const isSQLExpression = (input: string) => {
1818
if (['CURRENT_DATE'].includes(input)) return true
@@ -136,10 +136,10 @@ export const generateUpdateColumnPayload = (
136136
payload.name = name
137137
}
138138
if (!isEqual(originalColumn.comment?.trim(), comment)) {
139-
payload.comment = comment || null
139+
payload.comment = comment
140140
}
141141
if (!isEqual(originalColumn.check?.trim(), check)) {
142-
payload.check = check || null
142+
payload.check = check
143143
}
144144

145145
if (!isEqual(originalColumn.format, type)) {

apps/studio/data/database-columns/database-column-create-mutation.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@ import pgMeta from '@supabase/pg-meta'
22
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
33
import { toast } from 'sonner'
44

5-
import type { components } from 'data/api'
65
import { executeSql } from 'data/sql/execute-sql-query'
76
import type { ResponseError } from 'types'
87

9-
export type CreateColumnBody = Omit<components['schemas']['CreateColumnBody'], 'tableId'> & {
8+
export type CreateColumnBody = {
109
schema: string
1110
table: string
11+
name: string
12+
type: string
13+
check?: string
14+
comment?: string
15+
defaultValue?: any
16+
defaultValueFormat?: 'expression' | 'literal'
17+
identityGeneration?: 'BY DEFAULT' | 'ALWAYS'
18+
isIdentity?: boolean
19+
isNullable?: boolean
20+
isPrimaryKey?: boolean
21+
isUnique?: boolean
1222
}
1323

1424
export type DatabaseColumnCreateVariables = {

apps/studio/data/database-columns/database-column-update-mutation.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ import { PGColumn } from '@supabase/pg-meta/src/pg-meta-columns'
33
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
44
import { toast } from 'sonner'
55

6-
import type { components } from 'data/api'
76
import { executeSql } from 'data/sql/execute-sql-query'
87
import type { ResponseError } from 'types'
8+
import { CreateColumnBody } from './database-column-create-mutation'
99

10-
export type UpdateColumnBody = Omit<
11-
components['schemas']['UpdateColumnBody'],
12-
'check' | 'comment'
10+
export type UpdateColumnBody = Partial<
11+
Omit<CreateColumnBody, 'schema' | 'table' | 'isPrimaryKey'>
1312
> & {
14-
check?: string | null
15-
comment?: string | null
13+
dropDefault?: boolean
1614
}
1715

1816
export type DatabaseColumnUpdateVariables = {

apps/studio/data/database-policies/database-policy-create-mutation.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ import pgMeta from '@supabase/pg-meta'
22
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
33
import { toast } from 'sonner'
44

5-
import type { components } from 'data/api'
65
import { executeSql } from 'data/sql/execute-sql-query'
76
import type { ResponseError } from 'types'
87
import { databasePoliciesKeys } from './keys'
98

10-
type CreatePolicyBody = components['schemas']['CreatePolicyBody']
9+
type CreatePolicyBody = {
10+
name: string
11+
table: string
12+
schema?: string
13+
definition?: string
14+
check?: string
15+
action?: 'PERMISSIVE' | 'RESTRICTIVE'
16+
command?: 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE' | 'ALL'
17+
roles?: string[]
18+
}
1119

1220
export type DatabasePolicyCreateVariables = {
1321
projectRef: string

apps/studio/data/privileges/column-privileges-grant-mutation.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
import pgMeta from '@supabase/pg-meta'
12
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
3+
import { executeSql } from 'data/sql/execute-sql-query'
24
import { toast } from 'sonner'
3-
import type { components } from 'data/api'
45
import type { ResponseError } from 'types'
56
import { privilegeKeys } from './keys'
6-
import pgMeta from '@supabase/pg-meta'
7-
import { executeSql } from 'data/sql/execute-sql-query'
87

9-
export type ColumnPrivilegesGrant = components['schemas']['GrantColumnPrivilegesBody']
8+
export type ColumnPrivilegesGrant = {
9+
column_id: string
10+
grantee: string
11+
privilege_type: 'ALL' | 'SELECT' | 'INSERT' | 'UPDATE' | 'REFERENCES'
12+
is_grantable?: boolean
13+
}
1014

1115
export type ColumnPrivilegesGrantVariables = {
1216
projectRef: string
1317
connectionString?: string | null
14-
grants: ColumnPrivilegesGrant
18+
grants: ColumnPrivilegesGrant[]
1519
}
1620

1721
export async function grantColumnPrivileges({

apps/studio/data/privileges/column-privileges-revoke-mutation.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
import pgMeta from '@supabase/pg-meta'
12
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
3+
import { executeSql } from 'data/sql/execute-sql-query'
24
import { toast } from 'sonner'
3-
import type { components } from 'data/api'
45
import type { ResponseError } from 'types'
5-
import pgMeta from '@supabase/pg-meta'
6-
import { executeSql } from 'data/sql/execute-sql-query'
76
import { privilegeKeys } from './keys'
87

9-
export type ColumnPrivilegesRevoke = components['schemas']['RevokeColumnPrivilegesBody']
8+
export type ColumnPrivilegesRevoke = {
9+
column_id: string
10+
grantee: string
11+
privilege_type: 'ALL' | 'SELECT' | 'INSERT' | 'UPDATE' | 'REFERENCES'
12+
}
1013

1114
export type ColumnPrivilegesRevokeVariables = {
1215
projectRef: string
1316
connectionString?: string | null
14-
revokes: ColumnPrivilegesRevoke
17+
revokes: ColumnPrivilegesRevoke[]
1518
}
1619

1720
export async function revokeColumnPrivileges({

apps/studio/data/tables/table-create-mutation.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import pgMeta from '@supabase/pg-meta'
22
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
33
import { toast } from 'sonner'
44

5-
import type { components } from 'data/api'
65
import { executeSql } from 'data/sql/execute-sql-query'
76
import type { ResponseError } from 'types'
87
import { tableKeys } from './keys'
98

10-
export type CreateTableBody = components['schemas']['CreateTableBody']
9+
export type CreateTableBody = {
10+
name: string
11+
schema?: string
12+
comment?: string
13+
}
1114

1215
export type TableCreateVariables = {
1316
projectRef: string

0 commit comments

Comments
 (0)