File tree Expand file tree Collapse file tree 2 files changed +14
-16
lines changed
frontend/packages/db-structure/src/operation/schema Expand file tree Collapse file tree 2 files changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,15 @@ import type { Operation } from './index.js'
6
6
7
7
const isColumnPath = createPathValidator ( PATH_PATTERNS . COLUMN_BASE )
8
8
9
+ const columnPathSchema = v . custom < `/tables/${string } /columns/${string } `> (
10
+ isColumnPath ,
11
+ 'Path must match the pattern /tables/{tableName}/columns/{columnName}' ,
12
+ )
13
+
9
14
// Add column operation
10
15
const addColumnOperationSchema = v . object ( {
11
16
op : v . literal ( 'add' ) ,
12
- path : v . custom < `/tables/${string } /columns/${string } `> (
13
- isColumnPath ,
14
- 'Path must match the pattern /tables/{tableName}/columns/{columnName}' ,
15
- ) ,
17
+ path : columnPathSchema ,
16
18
value : columnSchema ,
17
19
} )
18
20
@@ -27,10 +29,7 @@ export const isAddColumnOperation = (
27
29
// Remove column operation
28
30
const removeColumnOperationSchema = v . object ( {
29
31
op : v . literal ( 'remove' ) ,
30
- path : v . custom < `/tables/${string } /columns/${string } `> (
31
- isColumnPath ,
32
- 'Path must match the pattern /tables/{tableName}/columns/{columnName}' ,
33
- ) ,
32
+ path : columnPathSchema ,
34
33
} )
35
34
36
35
export type RemoveColumnOperation = v . InferOutput <
Original file line number Diff line number Diff line change @@ -6,21 +6,20 @@ import type { Operation } from './index.js'
6
6
7
7
const isTablePath = createPathValidator ( PATH_PATTERNS . TABLE_BASE )
8
8
9
+ const tablePathSchema = v . custom < `/tables/${string } `> (
10
+ isTablePath ,
11
+ 'Path must match the pattern /tables/{tableName}' ,
12
+ )
13
+
9
14
const addTableOperationSchema = v . object ( {
10
15
op : v . literal ( 'add' ) ,
11
- path : v . custom < `/tables/${string } `> (
12
- isTablePath ,
13
- 'Path must match the pattern /tables/{tableName}' ,
14
- ) ,
16
+ path : tablePathSchema ,
15
17
value : tableSchema ,
16
18
} )
17
19
18
20
const removeTableOperationSchema = v . object ( {
19
21
op : v . literal ( 'remove' ) ,
20
- path : v . custom < `/tables/${string } `> (
21
- isTablePath ,
22
- 'Path must match the pattern /tables/{tableName}' ,
23
- ) ,
22
+ path : tablePathSchema ,
24
23
} )
25
24
26
25
export type AddTableOperation = v . InferOutput < typeof addTableOperationSchema >
You can’t perform that action at this time.
0 commit comments