@read-frog/api-contract 0.14.0 → 0.16.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.
Files changed (41) hide show
  1. package/dist/index.d.ts +1186 -481
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +326 -97
  4. package/dist/index.js.map +1 -1
  5. package/package.json +15 -14
  6. package/src/contracts/beta-access.ts +3 -6
  7. package/src/contracts/billing.ts +5 -5
  8. package/src/contracts/card-template.ts +45 -39
  9. package/src/contracts/card.ts +22 -19
  10. package/src/contracts/ebook.ts +13 -11
  11. package/src/contracts/hosted-ai.ts +5 -5
  12. package/src/contracts/mcp-connection.ts +26 -0
  13. package/src/contracts/notebase-column.ts +40 -32
  14. package/src/contracts/notebase-row.ts +85 -45
  15. package/src/contracts/notebase.ts +60 -40
  16. package/src/contracts/shared.ts +21 -2
  17. package/src/contracts/srs.ts +96 -63
  18. package/src/contracts/stats.ts +9 -11
  19. package/src/contracts/user.ts +3 -3
  20. package/src/contracts/video-transcript.ts +22 -12
  21. package/src/index.ts +40 -33
  22. package/src/public-errors.ts +74 -51
  23. package/src/schemas/beta-access.ts +12 -10
  24. package/src/schemas/billing.ts +103 -59
  25. package/src/schemas/card.ts +66 -63
  26. package/src/schemas/ebook.ts +165 -129
  27. package/src/schemas/hosted-ai.ts +84 -74
  28. package/src/schemas/mcp-connection.ts +28 -0
  29. package/src/schemas/notebase-column.ts +50 -36
  30. package/src/schemas/notebase-row.ts +88 -57
  31. package/src/schemas/notebase-stats.ts +28 -20
  32. package/src/schemas/notebase-view.ts +59 -49
  33. package/src/schemas/notebase.ts +136 -96
  34. package/src/schemas/pagination.ts +9 -0
  35. package/src/schemas/resource-mutation.ts +6 -0
  36. package/src/schemas/srs-stats.ts +30 -22
  37. package/src/schemas/srs.ts +152 -106
  38. package/src/schemas/stats.ts +27 -21
  39. package/src/schemas/timezone.ts +19 -16
  40. package/src/schemas/user.ts +27 -19
  41. package/src/schemas/video-transcript.ts +33 -32
@@ -1,7 +1,16 @@
1
- import { NOTEBASE_COLUMN_MAX_WIDTH, NOTEBASE_COLUMN_MIN_WIDTH, notebaseColumnConfigSchema } from "@read-frog/definitions"
2
- import { z } from "zod"
1
+ import { deletionResultSchema, expectedUpdatedAtSchema } from "./resource-mutation";
2
+ import {
3
+ NOTEBASE_COLUMN_MAX_WIDTH,
4
+ NOTEBASE_COLUMN_MIN_WIDTH,
5
+ notebaseColumnConfigSchema,
6
+ } from "@read-frog/definitions";
7
+ import { z } from "zod";
3
8
 
4
- export const notebaseColumnWidthSchema = z.number().int().min(NOTEBASE_COLUMN_MIN_WIDTH).max(NOTEBASE_COLUMN_MAX_WIDTH)
9
+ export const notebaseColumnWidthSchema = z
10
+ .number()
11
+ .int()
12
+ .min(NOTEBASE_COLUMN_MIN_WIDTH)
13
+ .max(NOTEBASE_COLUMN_MAX_WIDTH);
5
14
 
6
15
  export const notebaseColumnSchema = z.object({
7
16
  id: z.string(),
@@ -14,63 +23,68 @@ export const notebaseColumnSchema = z.object({
14
23
  wrap: z.boolean(),
15
24
  createdAt: z.coerce.date(),
16
25
  updatedAt: z.coerce.date(),
17
- })
18
- export type NotebaseColumn = z.infer<typeof notebaseColumnSchema>
26
+ });
27
+ export type NotebaseColumn = z.infer<typeof notebaseColumnSchema>;
19
28
 
20
- export const notebaseColumnCreateDataSchema = z.object({
21
- id: z.uuid().optional(),
22
- name: z.string().min(1),
23
- config: notebaseColumnConfigSchema,
24
- }).strict()
25
- export type NotebaseColumnCreateData = z.infer<typeof notebaseColumnCreateDataSchema>
29
+ export const notebaseColumnCreateDataSchema = z
30
+ .object({
31
+ id: z.uuid().optional(),
32
+ name: z.string().min(1),
33
+ config: notebaseColumnConfigSchema,
34
+ })
35
+ .strict();
36
+ export type NotebaseColumnCreateData = z.infer<typeof notebaseColumnCreateDataSchema>;
26
37
 
27
- export const notebaseColumnUpdateDataSchema = z.object({
28
- name: z.string().min(1).optional(),
29
- config: notebaseColumnConfigSchema.optional(),
30
- width: notebaseColumnWidthSchema.nullable().optional(),
31
- wrap: z.boolean().optional(),
32
- }).strict()
33
- export type NotebaseColumnUpdateData = z.infer<typeof notebaseColumnUpdateDataSchema>
38
+ export const notebaseColumnUpdateDataSchema = z
39
+ .object({
40
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional(),
41
+ name: z.string().min(1).optional(),
42
+ config: notebaseColumnConfigSchema.optional(),
43
+ width: notebaseColumnWidthSchema.nullable().optional(),
44
+ wrap: z.boolean().optional(),
45
+ })
46
+ .strict();
47
+ export type NotebaseColumnUpdateData = z.infer<typeof notebaseColumnUpdateDataSchema>;
34
48
 
35
49
  export const NotebaseColumnCreateInputSchema = z.object({
36
50
  notebaseId: z.uuid(),
37
51
  data: notebaseColumnCreateDataSchema,
38
- })
39
- export type NotebaseColumnCreateInput = z.infer<typeof NotebaseColumnCreateInputSchema>
52
+ });
53
+ export type NotebaseColumnCreateInput = z.infer<typeof NotebaseColumnCreateInputSchema>;
40
54
 
41
55
  export const NotebaseColumnCreateOutputSchema = z.object({
56
+ field: notebaseColumnSchema,
42
57
  txid: z.number(),
43
- })
44
- export type NotebaseColumnCreateOutput = z.infer<typeof NotebaseColumnCreateOutputSchema>
58
+ });
59
+ export type NotebaseColumnCreateOutput = z.infer<typeof NotebaseColumnCreateOutputSchema>;
45
60
 
46
61
  export const NotebaseColumnUpdateInputSchema = z.object({
47
62
  notebaseColumnId: z.uuid(),
48
63
  data: notebaseColumnUpdateDataSchema,
49
- })
50
- export type NotebaseColumnUpdateInput = z.infer<typeof NotebaseColumnUpdateInputSchema>
64
+ });
65
+ export type NotebaseColumnUpdateInput = z.infer<typeof NotebaseColumnUpdateInputSchema>;
51
66
 
52
67
  export const NotebaseColumnUpdateOutputSchema = z.object({
68
+ field: notebaseColumnSchema,
53
69
  txid: z.number(),
54
- })
55
- export type NotebaseColumnUpdateOutput = z.infer<typeof NotebaseColumnUpdateOutputSchema>
70
+ });
71
+ export type NotebaseColumnUpdateOutput = z.infer<typeof NotebaseColumnUpdateOutputSchema>;
56
72
 
57
73
  export const NotebaseColumnDeleteInputSchema = z.object({
58
74
  notebaseColumnId: z.uuid(),
59
- })
60
- export type NotebaseColumnDeleteInput = z.infer<typeof NotebaseColumnDeleteInputSchema>
75
+ });
76
+ export type NotebaseColumnDeleteInput = z.infer<typeof NotebaseColumnDeleteInputSchema>;
61
77
 
62
- export const NotebaseColumnDeleteOutputSchema = z.object({
63
- txid: z.number(),
64
- })
65
- export type NotebaseColumnDeleteOutput = z.infer<typeof NotebaseColumnDeleteOutputSchema>
78
+ export const NotebaseColumnDeleteOutputSchema = deletionResultSchema;
79
+ export type NotebaseColumnDeleteOutput = z.infer<typeof NotebaseColumnDeleteOutputSchema>;
66
80
 
67
81
  export const NotebaseColumnReorderInputSchema = z.object({
68
82
  notebaseId: z.uuid(),
69
83
  ids: z.array(z.uuid()),
70
- })
71
- export type NotebaseColumnReorderInput = z.infer<typeof NotebaseColumnReorderInputSchema>
84
+ });
85
+ export type NotebaseColumnReorderInput = z.infer<typeof NotebaseColumnReorderInputSchema>;
72
86
 
73
87
  export const NotebaseColumnReorderOutputSchema = z.object({
74
88
  txid: z.number(),
75
- })
76
- export type NotebaseColumnReorderOutput = z.infer<typeof NotebaseColumnReorderOutputSchema>
89
+ });
90
+ export type NotebaseColumnReorderOutput = z.infer<typeof NotebaseColumnReorderOutputSchema>;
@@ -1,6 +1,8 @@
1
- import { z } from "zod"
1
+ import { paginationShape, pageSchema } from "./pagination";
2
+ import { deletionResultSchema, expectedUpdatedAtSchema } from "./resource-mutation";
3
+ import { z } from "zod";
2
4
 
3
- export const notebaseRowCellsSchema = z.record(z.string(), z.unknown())
5
+ export const notebaseRowCellsSchema = z.record(z.string(), z.unknown());
4
6
 
5
7
  export const notebaseRowSchema = z.object({
6
8
  id: z.string(),
@@ -9,68 +11,77 @@ export const notebaseRowSchema = z.object({
9
11
  position: z.number(),
10
12
  createdAt: z.coerce.date(),
11
13
  updatedAt: z.coerce.date(),
12
- })
13
- export type NotebaseRow = z.infer<typeof notebaseRowSchema>
14
+ });
15
+ export type NotebaseRow = z.infer<typeof notebaseRowSchema>;
14
16
 
15
- export const notebaseRowCreateDataSchema = z.object({
16
- id: z.uuid().optional(),
17
- cells: notebaseRowCellsSchema.optional(),
18
- }).strict()
19
- export type NotebaseRowCreateData = z.infer<typeof notebaseRowCreateDataSchema>
17
+ export const notebaseRowCreateDataSchema = z
18
+ .object({
19
+ id: z.uuid().optional(),
20
+ cells: notebaseRowCellsSchema.optional(),
21
+ })
22
+ .strict();
23
+ export type NotebaseRowCreateData = z.infer<typeof notebaseRowCreateDataSchema>;
20
24
 
21
- export const notebaseRowUpdateDataSchema = z.object({
22
- cells: notebaseRowCellsSchema.optional(),
23
- }).strict()
24
- export type NotebaseRowUpdateData = z.infer<typeof notebaseRowUpdateDataSchema>
25
+ export const notebaseRowUpdateDataSchema = z
26
+ .object({
27
+ cells: notebaseRowCellsSchema.optional(),
28
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional(),
29
+ })
30
+ .strict();
31
+ export type NotebaseRowUpdateData = z.infer<typeof notebaseRowUpdateDataSchema>;
25
32
 
26
33
  export const NotebaseRowCreateInputSchema = z.object({
27
34
  notebaseId: z.uuid(),
28
35
  data: notebaseRowCreateDataSchema,
29
- })
30
- export type NotebaseRowCreateInput = z.infer<typeof NotebaseRowCreateInputSchema>
36
+ });
37
+ export type NotebaseRowCreateInput = z.infer<typeof NotebaseRowCreateInputSchema>;
31
38
 
32
39
  export const NotebaseRowCreateOutputSchema = z.object({
40
+ note: notebaseRowSchema,
33
41
  txid: z.number(),
34
- })
35
- export type NotebaseRowCreateOutput = z.infer<typeof NotebaseRowCreateOutputSchema>
42
+ });
43
+ export type NotebaseRowCreateOutput = z.infer<typeof NotebaseRowCreateOutputSchema>;
36
44
 
37
- export const NOTEBASE_ROW_CREATE_MANY_MAX_ROWS = 50
45
+ export const NOTEBASE_ROW_CREATE_MANY_MAX_ROWS = 50;
38
46
 
39
- export const NotebaseRowCreateManyInputSchema = z.object({
40
- notebaseId: z.uuid(),
41
- rows: z.array(notebaseRowCreateDataSchema).min(1).max(NOTEBASE_ROW_CREATE_MANY_MAX_ROWS),
42
- }).superRefine((input, ctx) => {
43
- const seenIds = new Set<string>()
44
-
45
- input.rows.forEach((row, index) => {
46
- if (row.id === undefined) {
47
- return
48
- }
49
-
50
- if (seenIds.has(row.id)) {
51
- ctx.addIssue({
52
- code: "custom",
53
- message: `Duplicate row id "${row.id}".`,
54
- path: ["rows", index, "id"],
55
- })
56
- return
57
- }
58
-
59
- seenIds.add(row.id)
47
+ export const NotebaseRowCreateManyInputSchema = z
48
+ .object({
49
+ notebaseId: z.uuid(),
50
+ rows: z.array(notebaseRowCreateDataSchema).min(1).max(NOTEBASE_ROW_CREATE_MANY_MAX_ROWS),
60
51
  })
61
- })
62
- export type NotebaseRowCreateManyInput = z.infer<typeof NotebaseRowCreateManyInputSchema>
52
+ .superRefine((input, ctx) => {
53
+ const seenIds = new Set<string>();
54
+
55
+ input.rows.forEach((row, index) => {
56
+ if (row.id === undefined) {
57
+ return;
58
+ }
59
+
60
+ if (seenIds.has(row.id)) {
61
+ ctx.addIssue({
62
+ code: "custom",
63
+ message: `Duplicate row id "${row.id}".`,
64
+ path: ["rows", index, "id"],
65
+ });
66
+ return;
67
+ }
68
+
69
+ seenIds.add(row.id);
70
+ });
71
+ });
72
+ export type NotebaseRowCreateManyInput = z.infer<typeof NotebaseRowCreateManyInputSchema>;
63
73
 
64
74
  export const NotebaseRowCreateManyOutputSchema = z.object({
75
+ items: z.array(notebaseRowSchema),
65
76
  txid: z.number(),
66
- })
67
- export type NotebaseRowCreateManyOutput = z.infer<typeof NotebaseRowCreateManyOutputSchema>
77
+ });
78
+ export type NotebaseRowCreateManyOutput = z.infer<typeof NotebaseRowCreateManyOutputSchema>;
68
79
 
69
80
  export const NotebaseRowUpdateInputSchema = z.object({
70
81
  notebaseRowId: z.uuid(),
71
82
  data: notebaseRowUpdateDataSchema,
72
- })
73
- export type NotebaseRowUpdateInput = z.infer<typeof NotebaseRowUpdateInputSchema>
83
+ });
84
+ export type NotebaseRowUpdateInput = z.infer<typeof NotebaseRowUpdateInputSchema>;
74
85
 
75
86
  export const NotebaseRowUpdateOutputSchema = z.object({
76
87
  id: z.uuid(),
@@ -80,26 +91,46 @@ export const NotebaseRowUpdateOutputSchema = z.object({
80
91
  createdAt: z.date(),
81
92
  updatedAt: z.date(),
82
93
  txid: z.number(),
83
- })
84
- export type NotebaseRowUpdateOutput = z.infer<typeof NotebaseRowUpdateOutputSchema>
94
+ });
95
+ export type NotebaseRowUpdateOutput = z.infer<typeof NotebaseRowUpdateOutputSchema>;
85
96
 
86
97
  export const NotebaseRowDeleteInputSchema = z.object({
87
98
  notebaseRowId: z.uuid(),
88
- })
89
- export type NotebaseRowDeleteInput = z.infer<typeof NotebaseRowDeleteInputSchema>
99
+ });
100
+ export type NotebaseRowDeleteInput = z.infer<typeof NotebaseRowDeleteInputSchema>;
90
101
 
91
- export const NotebaseRowDeleteOutputSchema = z.object({
92
- txid: z.number(),
93
- })
94
- export type NotebaseRowDeleteOutput = z.infer<typeof NotebaseRowDeleteOutputSchema>
102
+ export const NotebaseRowDeleteOutputSchema = deletionResultSchema;
103
+ export type NotebaseRowDeleteOutput = z.infer<typeof NotebaseRowDeleteOutputSchema>;
95
104
 
96
105
  export const NotebaseRowReorderInputSchema = z.object({
97
106
  notebaseId: z.uuid(),
98
107
  ids: z.array(z.uuid()),
99
- })
100
- export type NotebaseRowReorderInput = z.infer<typeof NotebaseRowReorderInputSchema>
108
+ });
109
+ export type NotebaseRowReorderInput = z.infer<typeof NotebaseRowReorderInputSchema>;
101
110
 
102
111
  export const NotebaseRowReorderOutputSchema = z.object({
103
112
  txid: z.number(),
104
- })
105
- export type NotebaseRowReorderOutput = z.infer<typeof NotebaseRowReorderOutputSchema>
113
+ });
114
+ export type NotebaseRowReorderOutput = z.infer<typeof NotebaseRowReorderOutputSchema>;
115
+
116
+ export const NotebaseRowListInputSchema = z
117
+ .object({
118
+ notebaseId: z.uuid().optional(),
119
+ // Two characters is already a meaningful CJK query; one matches nearly
120
+ // every note while costing the same full scan, so the floor is a cost
121
+ // control rather than an ergonomic preference.
122
+ query: z.string().trim().min(2).max(200).optional(),
123
+ ...paginationShape,
124
+ })
125
+ // Listing without a notebase is a plain indexed read. Searching is not: it
126
+ // expands every candidate row's cells and cannot use an index, so it stays
127
+ // scoped to one notebase, where `notebase_rows_notebase_id_idx` bounds the
128
+ // candidate set. Searching everything means iterating over notebases.
129
+ .refine((input) => input.query === undefined || input.notebaseId !== undefined, {
130
+ error: "notebaseId is required when query is set",
131
+ path: ["notebaseId"],
132
+ });
133
+ export type NotebaseRowListInput = z.infer<typeof NotebaseRowListInputSchema>;
134
+ export const NotebaseRowListOutputSchema = pageSchema(notebaseRowSchema);
135
+ export const NotebaseRowGetInputSchema = z.object({ id: z.uuid() });
136
+ export const NotebaseRowGetOutputSchema = notebaseRowSchema;
@@ -1,24 +1,32 @@
1
- import { z } from "zod"
1
+ import { z } from "zod";
2
2
 
3
- export const notebaseActivityStatsItemSchema = z.object({
4
- date: z.iso.date(),
5
- notes: z.number().int().nonnegative(),
6
- }).strict()
7
- export type NotebaseActivityStatsItem = z.infer<typeof notebaseActivityStatsItemSchema>
3
+ export const notebaseActivityStatsItemSchema = z
4
+ .object({
5
+ date: z.iso.date(),
6
+ notes: z.number().int().nonnegative(),
7
+ })
8
+ .strict();
9
+ export type NotebaseActivityStatsItem = z.infer<typeof notebaseActivityStatsItemSchema>;
8
10
 
9
- export const notebaseActivityStatsOutputSchema = z.object({
10
- daily: z.array(notebaseActivityStatsItemSchema),
11
- }).strict()
12
- export type NotebaseActivityStatsOutput = z.infer<typeof notebaseActivityStatsOutputSchema>
11
+ export const notebaseActivityStatsOutputSchema = z
12
+ .object({
13
+ daily: z.array(notebaseActivityStatsItemSchema),
14
+ })
15
+ .strict();
16
+ export type NotebaseActivityStatsOutput = z.infer<typeof notebaseActivityStatsOutputSchema>;
13
17
 
14
- export const notebaseRowGrowthStatsItemSchema = z.object({
15
- date: z.iso.date(),
16
- delta: z.number().int(),
17
- }).strict()
18
- export type NotebaseRowGrowthStatsItem = z.infer<typeof notebaseRowGrowthStatsItemSchema>
18
+ export const notebaseRowGrowthStatsItemSchema = z
19
+ .object({
20
+ date: z.iso.date(),
21
+ delta: z.number().int(),
22
+ })
23
+ .strict();
24
+ export type NotebaseRowGrowthStatsItem = z.infer<typeof notebaseRowGrowthStatsItemSchema>;
19
25
 
20
- export const notebaseRowGrowthStatsOutputSchema = z.object({
21
- baseTotal: z.number().int().nonnegative(),
22
- daily: z.array(notebaseRowGrowthStatsItemSchema),
23
- }).strict()
24
- export type NotebaseRowGrowthStatsOutput = z.infer<typeof notebaseRowGrowthStatsOutputSchema>
26
+ export const notebaseRowGrowthStatsOutputSchema = z
27
+ .object({
28
+ baseTotal: z.number().int().nonnegative(),
29
+ daily: z.array(notebaseRowGrowthStatsItemSchema),
30
+ })
31
+ .strict();
32
+ export type NotebaseRowGrowthStatsOutput = z.infer<typeof notebaseRowGrowthStatsOutputSchema>;
@@ -1,50 +1,60 @@
1
- import { z } from "zod"
2
-
3
- export const notebaseViewTypeSchema = z.enum(["table", "kanban", "gallery"])
4
- export type NotebaseViewType = z.infer<typeof notebaseViewTypeSchema>
5
-
6
- export const notebaseViewConfigSchema = z.object({
7
- notebaseColumnWidths: z.record(z.string(), z.number()).optional(),
8
- hiddenNotebaseColumns: z.array(z.string()).optional(),
9
- groupByNotebaseColumnId: z.string().optional(),
10
- }).catchall(z.unknown())
11
- export type NotebaseViewConfig = z.infer<typeof notebaseViewConfigSchema>
12
-
13
- export const notebaseViewFilterSchema = z.object({
14
- notebaseColumnId: z.string(),
15
- operator: z.string(),
16
- value: z.unknown(),
17
- }).strict()
18
- export type NotebaseViewFilter = z.infer<typeof notebaseViewFilterSchema>
19
-
20
- export const notebaseViewFiltersSchema = z.array(notebaseViewFilterSchema)
21
-
22
- export const notebaseViewSortSchema = z.object({
23
- notebaseColumnId: z.string(),
24
- direction: z.enum(["asc", "desc"]),
25
- }).strict()
26
- export type NotebaseViewSort = z.infer<typeof notebaseViewSortSchema>
27
-
28
- export const notebaseViewSortsSchema = z.array(notebaseViewSortSchema)
29
-
30
- export const notebaseViewCreateDataSchema = z.object({
31
- id: z.uuid().optional(),
32
- name: z.string().min(1),
33
- type: notebaseViewTypeSchema,
34
- config: notebaseViewConfigSchema.optional(),
35
- filters: notebaseViewFiltersSchema.optional(),
36
- sorts: notebaseViewSortsSchema.optional(),
37
- }).strict()
38
- export type NotebaseViewCreateData = z.infer<typeof notebaseViewCreateDataSchema>
39
-
40
- export const notebaseViewUpdateDataSchema = z.object({
41
- name: z.string().min(1).optional(),
42
- type: notebaseViewTypeSchema.optional(),
43
- config: notebaseViewConfigSchema.optional(),
44
- filters: notebaseViewFiltersSchema.optional(),
45
- sorts: notebaseViewSortsSchema.optional(),
46
- }).strict()
47
- export type NotebaseViewUpdateData = z.infer<typeof notebaseViewUpdateDataSchema>
1
+ import { z } from "zod";
2
+
3
+ export const notebaseViewTypeSchema = z.enum(["table", "kanban", "gallery"]);
4
+ export type NotebaseViewType = z.infer<typeof notebaseViewTypeSchema>;
5
+
6
+ export const notebaseViewConfigSchema = z
7
+ .object({
8
+ notebaseColumnWidths: z.record(z.string(), z.number()).optional(),
9
+ hiddenNotebaseColumns: z.array(z.string()).optional(),
10
+ groupByNotebaseColumnId: z.string().optional(),
11
+ })
12
+ .catchall(z.unknown());
13
+ export type NotebaseViewConfig = z.infer<typeof notebaseViewConfigSchema>;
14
+
15
+ export const notebaseViewFilterSchema = z
16
+ .object({
17
+ notebaseColumnId: z.string(),
18
+ operator: z.string(),
19
+ value: z.unknown(),
20
+ })
21
+ .strict();
22
+ export type NotebaseViewFilter = z.infer<typeof notebaseViewFilterSchema>;
23
+
24
+ export const notebaseViewFiltersSchema = z.array(notebaseViewFilterSchema);
25
+
26
+ export const notebaseViewSortSchema = z
27
+ .object({
28
+ notebaseColumnId: z.string(),
29
+ direction: z.enum(["asc", "desc"]),
30
+ })
31
+ .strict();
32
+ export type NotebaseViewSort = z.infer<typeof notebaseViewSortSchema>;
33
+
34
+ export const notebaseViewSortsSchema = z.array(notebaseViewSortSchema);
35
+
36
+ export const notebaseViewCreateDataSchema = z
37
+ .object({
38
+ id: z.uuid().optional(),
39
+ name: z.string().min(1),
40
+ type: notebaseViewTypeSchema,
41
+ config: notebaseViewConfigSchema.optional(),
42
+ filters: notebaseViewFiltersSchema.optional(),
43
+ sorts: notebaseViewSortsSchema.optional(),
44
+ })
45
+ .strict();
46
+ export type NotebaseViewCreateData = z.infer<typeof notebaseViewCreateDataSchema>;
47
+
48
+ export const notebaseViewUpdateDataSchema = z
49
+ .object({
50
+ name: z.string().min(1).optional(),
51
+ type: notebaseViewTypeSchema.optional(),
52
+ config: notebaseViewConfigSchema.optional(),
53
+ filters: notebaseViewFiltersSchema.optional(),
54
+ sorts: notebaseViewSortsSchema.optional(),
55
+ })
56
+ .strict();
57
+ export type NotebaseViewUpdateData = z.infer<typeof notebaseViewUpdateDataSchema>;
48
58
 
49
59
  export const notebaseViewSchema = z.object({
50
60
  id: z.string(),
@@ -57,5 +67,5 @@ export const notebaseViewSchema = z.object({
57
67
  position: z.number(),
58
68
  createdAt: z.coerce.date(),
59
69
  updatedAt: z.coerce.date(),
60
- })
61
- export type NotebaseView = z.infer<typeof notebaseViewSchema>
70
+ });
71
+ export type NotebaseView = z.infer<typeof notebaseViewSchema>;