@read-frog/api-contract 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,86 @@
1
+ import { z } from "zod"
2
+ import { tableColumnSchema } from "./column"
3
+ import { tableRowSchema } from "./row"
4
+ import { tableViewSchema } from "./view"
5
+
6
+ export const CustomTableListInputSchema = z.object({})
7
+ export type CustomTableListInput = z.infer<typeof CustomTableListInputSchema>
8
+
9
+ export const CustomTableListItemSchema = z.object({
10
+ id: z.string(),
11
+ name: z.string(),
12
+ })
13
+ export type CustomTableListItem = z.infer<typeof CustomTableListItemSchema>
14
+
15
+ export const CustomTableListOutputSchema = z.array(CustomTableListItemSchema)
16
+ export type CustomTableListOutput = z.infer<typeof CustomTableListOutputSchema>
17
+
18
+ export const customTableCreateDataSchema = z.object({
19
+ id: z.uuid().optional(),
20
+ name: z.string().min(1),
21
+ }).strict()
22
+ export type CustomTableCreateData = z.infer<typeof customTableCreateDataSchema>
23
+
24
+ export const CustomTableCreateInputSchema = customTableCreateDataSchema
25
+ export type CustomTableCreateInput = z.infer<typeof CustomTableCreateInputSchema>
26
+
27
+ export const CustomTableCreateOutputSchema = z.object({
28
+ txid: z.number(),
29
+ })
30
+ export type CustomTableCreateOutput = z.infer<typeof CustomTableCreateOutputSchema>
31
+
32
+ export const customTableUpdateDataSchema = z.object({
33
+ name: z.string().min(1).optional(),
34
+ }).strict()
35
+ export type CustomTableUpdateData = z.infer<typeof customTableUpdateDataSchema>
36
+
37
+ export const CustomTableUpdateInputSchema = customTableUpdateDataSchema.extend({
38
+ id: z.uuid(),
39
+ })
40
+ export type CustomTableUpdateInput = z.infer<typeof CustomTableUpdateInputSchema>
41
+
42
+ export const CustomTableUpdateOutputSchema = z.object({
43
+ txid: z.number(),
44
+ })
45
+ export type CustomTableUpdateOutput = z.infer<typeof CustomTableUpdateOutputSchema>
46
+
47
+ export const CustomTableDeleteInputSchema = z.object({
48
+ id: z.uuid(),
49
+ })
50
+ export type CustomTableDeleteInput = z.infer<typeof CustomTableDeleteInputSchema>
51
+
52
+ export const CustomTableDeleteOutputSchema = z.object({
53
+ txid: z.number(),
54
+ })
55
+ export type CustomTableDeleteOutput = z.infer<typeof CustomTableDeleteOutputSchema>
56
+
57
+ // Get endpoint schemas
58
+ export const CustomTableGetInputSchema = z.object({
59
+ id: z.uuid(),
60
+ })
61
+ export type CustomTableGetInput = z.infer<typeof CustomTableGetInputSchema>
62
+
63
+ export const CustomTableGetSchemaInputSchema = z.object({
64
+ id: z.uuid(),
65
+ })
66
+ export type CustomTableGetSchemaInput = z.infer<typeof CustomTableGetSchemaInputSchema>
67
+
68
+ export const CustomTableGetOutputSchema = z.object({
69
+ id: z.string(),
70
+ userId: z.string(),
71
+ name: z.string(),
72
+ createdAt: z.coerce.date(),
73
+ updatedAt: z.coerce.date(),
74
+ columns: z.array(tableColumnSchema),
75
+ rows: z.array(tableRowSchema),
76
+ views: z.array(tableViewSchema),
77
+ })
78
+ export type CustomTableGetOutput = z.infer<typeof CustomTableGetOutputSchema>
79
+
80
+ export const CustomTableGetSchemaOutputSchema = z.object({
81
+ id: z.string(),
82
+ name: z.string(),
83
+ updatedAt: z.coerce.date(),
84
+ columns: z.array(tableColumnSchema),
85
+ })
86
+ export type CustomTableGetSchemaOutput = z.infer<typeof CustomTableGetSchemaOutputSchema>
@@ -0,0 +1,73 @@
1
+ import { z } from "zod"
2
+
3
+ export const rowCellsSchema = z.record(z.string(), z.unknown())
4
+
5
+ export const tableRowSchema = z.object({
6
+ id: z.string(),
7
+ tableId: z.string(),
8
+ cells: rowCellsSchema,
9
+ position: z.number(),
10
+ createdAt: z.coerce.date(),
11
+ updatedAt: z.coerce.date(),
12
+ })
13
+ export type TableRow = z.infer<typeof tableRowSchema>
14
+
15
+ export const rowCreateDataSchema = z.object({
16
+ id: z.uuid().optional(),
17
+ cells: rowCellsSchema.optional(),
18
+ }).strict()
19
+ export type RowCreateData = z.infer<typeof rowCreateDataSchema>
20
+
21
+ export const rowUpdateDataSchema = z.object({
22
+ cells: rowCellsSchema.optional(),
23
+ }).strict()
24
+ export type RowUpdateData = z.infer<typeof rowUpdateDataSchema>
25
+
26
+ export const RowCreateInputSchema = z.object({
27
+ tableId: z.uuid(),
28
+ data: rowCreateDataSchema,
29
+ })
30
+ export type RowCreateInput = z.infer<typeof RowCreateInputSchema>
31
+
32
+ export const RowCreateOutputSchema = z.object({
33
+ txid: z.number(),
34
+ })
35
+ export type RowCreateOutput = z.infer<typeof RowCreateOutputSchema>
36
+
37
+ export const RowUpdateInputSchema = z.object({
38
+ rowId: z.uuid(),
39
+ data: rowUpdateDataSchema,
40
+ })
41
+ export type RowUpdateInput = z.infer<typeof RowUpdateInputSchema>
42
+
43
+ export const RowUpdateOutputSchema = z.object({
44
+ id: z.uuid(),
45
+ tableId: z.uuid(),
46
+ cells: rowCellsSchema,
47
+ position: z.number().int(),
48
+ createdAt: z.date(),
49
+ updatedAt: z.date(),
50
+ txid: z.number(),
51
+ })
52
+ export type RowUpdateOutput = z.infer<typeof RowUpdateOutputSchema>
53
+
54
+ export const RowDeleteInputSchema = z.object({
55
+ rowId: z.uuid(),
56
+ })
57
+ export type RowDeleteInput = z.infer<typeof RowDeleteInputSchema>
58
+
59
+ export const RowDeleteOutputSchema = z.object({
60
+ txid: z.number(),
61
+ })
62
+ export type RowDeleteOutput = z.infer<typeof RowDeleteOutputSchema>
63
+
64
+ export const RowReorderInputSchema = z.object({
65
+ tableId: z.uuid(),
66
+ ids: z.array(z.uuid()),
67
+ })
68
+ export type RowReorderInput = z.infer<typeof RowReorderInputSchema>
69
+
70
+ export const RowReorderOutputSchema = z.object({
71
+ txid: z.number(),
72
+ })
73
+ export type RowReorderOutput = z.infer<typeof RowReorderOutputSchema>
@@ -0,0 +1,61 @@
1
+ import { z } from "zod"
2
+
3
+ export const tableViewTypeSchema = z.enum(["table", "kanban", "gallery"])
4
+ export type TableViewType = z.infer<typeof tableViewTypeSchema>
5
+
6
+ export const viewConfigSchema = z.object({
7
+ columnWidths: z.record(z.string(), z.number()).optional(),
8
+ hiddenColumns: z.array(z.string()).optional(),
9
+ groupByColumnId: z.string().optional(),
10
+ }).catchall(z.unknown())
11
+ export type ViewConfig = z.infer<typeof viewConfigSchema>
12
+
13
+ export const viewFilterSchema = z.object({
14
+ columnId: z.string(),
15
+ operator: z.string(),
16
+ value: z.unknown(),
17
+ }).strict()
18
+ export type ViewFilter = z.infer<typeof viewFilterSchema>
19
+
20
+ export const viewFiltersSchema = z.array(viewFilterSchema)
21
+
22
+ export const viewSortSchema = z.object({
23
+ columnId: z.string(),
24
+ direction: z.enum(["asc", "desc"]),
25
+ }).strict()
26
+ export type ViewSort = z.infer<typeof viewSortSchema>
27
+
28
+ export const viewSortsSchema = z.array(viewSortSchema)
29
+
30
+ export const viewCreateDataSchema = z.object({
31
+ id: z.uuid().optional(),
32
+ name: z.string().min(1),
33
+ type: tableViewTypeSchema,
34
+ config: viewConfigSchema.optional(),
35
+ filters: viewFiltersSchema.optional(),
36
+ sorts: viewSortsSchema.optional(),
37
+ }).strict()
38
+ export type ViewCreateData = z.infer<typeof viewCreateDataSchema>
39
+
40
+ export const viewUpdateDataSchema = z.object({
41
+ name: z.string().min(1).optional(),
42
+ type: tableViewTypeSchema.optional(),
43
+ config: viewConfigSchema.optional(),
44
+ filters: viewFiltersSchema.optional(),
45
+ sorts: viewSortsSchema.optional(),
46
+ }).strict()
47
+ export type ViewUpdateData = z.infer<typeof viewUpdateDataSchema>
48
+
49
+ export const tableViewSchema = z.object({
50
+ id: z.string(),
51
+ tableId: z.string(),
52
+ name: z.string(),
53
+ type: tableViewTypeSchema,
54
+ config: viewConfigSchema.nullable(),
55
+ filters: z.array(z.unknown()).nullable(),
56
+ sorts: z.array(z.unknown()).nullable(),
57
+ position: z.number(),
58
+ createdAt: z.coerce.date(),
59
+ updatedAt: z.coerce.date(),
60
+ })
61
+ export type TableView = z.infer<typeof tableViewSchema>