Skip to content

Commit 7e7d114

Browse files
feat: add type def to docs for column endpoints (#596)
* feat: add type def to docs for column endpoints * update types --------- Co-authored-by: Bobbie Soedirgo <[email protected]>
1 parent 8514ff0 commit 7e7d114

File tree

2 files changed

+250
-132
lines changed

2 files changed

+250
-132
lines changed

Diff for: src/lib/types.ts

+39
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,45 @@ export const postgresColumnSchema = Type.Object({
4343
})
4444
export type PostgresColumn = Static<typeof postgresColumnSchema>
4545

46+
export const postgresColumnCreateSchema = Type.Object({
47+
table_id: Type.Integer(),
48+
name: Type.String(),
49+
type: Type.String(),
50+
default_value: Type.Optional(Type.Unknown()),
51+
default_value_format: Type.Optional(
52+
Type.Union([Type.Literal('expression'), Type.Literal('literal')])
53+
),
54+
is_identity: Type.Optional(Type.Boolean()),
55+
identity_generation: Type.Optional(
56+
Type.Union([Type.Literal('BY DEFAULT'), Type.Literal('ALWAYS')])
57+
),
58+
is_nullable: Type.Optional(Type.Boolean()),
59+
is_primary_key: Type.Optional(Type.Boolean()),
60+
is_unique: Type.Optional(Type.Boolean()),
61+
comment: Type.Optional(Type.String()),
62+
check: Type.Optional(Type.String()),
63+
})
64+
export type PostgresColumnCreate = Static<typeof postgresColumnCreateSchema>
65+
66+
export const postgresColumnUpdateSchema = Type.Object({
67+
name: Type.Optional(Type.String()),
68+
type: Type.Optional(Type.String()),
69+
drop_default: Type.Optional(Type.Boolean()),
70+
default_value: Type.Optional(Type.Unknown()),
71+
default_value_format: Type.Optional(
72+
Type.Union([Type.Literal('expression'), Type.Literal('literal')])
73+
),
74+
is_identity: Type.Optional(Type.Boolean()),
75+
identity_generation: Type.Optional(
76+
Type.Union([Type.Literal('BY DEFAULT'), Type.Literal('ALWAYS')])
77+
),
78+
is_nullable: Type.Optional(Type.Boolean()),
79+
is_unique: Type.Optional(Type.Boolean()),
80+
comment: Type.Optional(Type.String()),
81+
check: Type.Optional(Type.Union([Type.String(), Type.Null()])),
82+
})
83+
export type PostgresColumnUpdate = Static<typeof postgresColumnUpdateSchema>
84+
4685
// TODO Rethink config.sql
4786
export const postgresConfigSchema = Type.Object({
4887
name: Type.Unknown(),

0 commit comments

Comments
 (0)