@read-frog/api-contract 0.4.1 → 0.6.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.
- package/dist/index.d.ts +1158 -325
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +486 -202
- package/dist/index.js.map +1 -1
- package/package.json +18 -10
- package/src/contracts/beta-access.ts +1 -1
- package/src/contracts/card-template.ts +71 -0
- package/src/contracts/card.ts +45 -0
- package/src/contracts/notebase-column.ts +63 -0
- package/src/contracts/notebase-row.ts +62 -0
- package/src/contracts/notebase.ts +82 -0
- package/src/contracts/shared.ts +1 -1
- package/src/contracts/srs.ts +38 -0
- package/src/contracts/user.ts +17 -0
- package/src/index.ts +22 -10
- package/src/public-errors.ts +46 -12
- package/src/schemas/card.ts +120 -0
- package/src/schemas/notebase-column.ts +74 -0
- package/src/schemas/notebase-row.ts +73 -0
- package/src/schemas/notebase-view.ts +61 -0
- package/src/schemas/notebase.ts +103 -0
- package/src/schemas/srs.ts +129 -0
- package/src/schemas/timezone.ts +23 -0
- package/src/schemas/user.ts +13 -0
- package/src/contracts/column.ts +0 -62
- package/src/contracts/custom-table.ts +0 -82
- package/src/contracts/row.ts +0 -62
- package/src/schemas/column.ts +0 -74
- package/src/schemas/custom-table.ts +0 -86
- package/src/schemas/row.ts +0 -73
- package/src/schemas/view.ts +0 -61
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { oc } from "@orpc/contract"
|
|
2
|
+
import {
|
|
3
|
+
userEnsureTimezoneInputSchema,
|
|
4
|
+
userEnsureTimezoneOutputSchema,
|
|
5
|
+
} from "#/schemas/user"
|
|
6
|
+
|
|
7
|
+
export const userContract = {
|
|
8
|
+
ensureTimezone: oc
|
|
9
|
+
.route({
|
|
10
|
+
method: "POST",
|
|
11
|
+
path: "/users/me/timezone/ensure",
|
|
12
|
+
summary: "Ensure the authenticated user has a timezone",
|
|
13
|
+
tags: ["Users"],
|
|
14
|
+
})
|
|
15
|
+
.input(userEnsureTimezoneInputSchema)
|
|
16
|
+
.output(userEnsureTimezoneOutputSchema),
|
|
17
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import type { ContractRouterClient } from "@orpc/contract"
|
|
2
2
|
import { betaAccessContract } from "./contracts/beta-access"
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { cardContract } from "./contracts/card"
|
|
4
|
+
import { cardTemplateContract } from "./contracts/card-template"
|
|
5
|
+
import { notebaseContract } from "./contracts/notebase"
|
|
6
|
+
import { notebaseColumnContract } from "./contracts/notebase-column"
|
|
7
|
+
import { notebaseRowContract } from "./contracts/notebase-row"
|
|
8
|
+
import { srsContract } from "./contracts/srs"
|
|
9
|
+
import { userContract } from "./contracts/user"
|
|
6
10
|
|
|
7
11
|
export const contract = {
|
|
8
12
|
betaAccess: betaAccessContract,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
card: cardContract,
|
|
14
|
+
cardTemplate: cardTemplateContract,
|
|
15
|
+
notebase: notebaseContract,
|
|
16
|
+
notebaseColumn: notebaseColumnContract,
|
|
17
|
+
notebaseRow: notebaseRowContract,
|
|
18
|
+
srs: srsContract,
|
|
19
|
+
user: userContract,
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
export type ORPCRouterClient = ContractRouterClient<typeof contract>
|
|
15
23
|
|
|
16
24
|
export * from "./public-errors"
|
|
17
25
|
export * from "./schemas/beta-access"
|
|
18
|
-
export * from "./schemas/
|
|
19
|
-
export * from "./schemas/
|
|
20
|
-
export * from "./schemas/
|
|
21
|
-
export * from "./schemas/
|
|
26
|
+
export * from "./schemas/card"
|
|
27
|
+
export * from "./schemas/notebase"
|
|
28
|
+
export * from "./schemas/notebase-column"
|
|
29
|
+
export * from "./schemas/notebase-row"
|
|
30
|
+
export * from "./schemas/notebase-view"
|
|
31
|
+
export * from "./schemas/srs"
|
|
32
|
+
export * from "./schemas/timezone"
|
|
33
|
+
export * from "./schemas/user"
|
package/src/public-errors.ts
CHANGED
|
@@ -8,7 +8,7 @@ interface PublicAppErrorDefinition {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const CellValidationFailureReasonSchema = z.enum([
|
|
11
|
-
"
|
|
11
|
+
"unknown_notebase_column",
|
|
12
12
|
"type_mismatch",
|
|
13
13
|
"invalid_select_option",
|
|
14
14
|
"invalid_date_format",
|
|
@@ -25,31 +25,65 @@ export const CellValidationFailureDetailsSchema = z.object({
|
|
|
25
25
|
export type CellValidationFailureDetails = z.infer<typeof CellValidationFailureDetailsSchema>
|
|
26
26
|
|
|
27
27
|
export const CellValidationFailedDataSchema = z.object({
|
|
28
|
-
|
|
28
|
+
notebaseColumnId: z.string(),
|
|
29
29
|
details: CellValidationFailureDetailsSchema,
|
|
30
30
|
reason: CellValidationFailureReasonSchema,
|
|
31
31
|
}).strict()
|
|
32
32
|
export type CellValidationFailedData = z.infer<typeof CellValidationFailedDataSchema>
|
|
33
33
|
|
|
34
|
+
export const CardTemplateInvalidColumnsDataSchema = z.object({
|
|
35
|
+
notebaseColumnIds: z.array(z.string()),
|
|
36
|
+
}).strict()
|
|
37
|
+
export type CardTemplateInvalidColumnsData = z.infer<typeof CardTemplateInvalidColumnsDataSchema>
|
|
38
|
+
|
|
34
39
|
export const PUBLIC_APP_ERROR_DEFS = {
|
|
35
40
|
NOTEBASE_BETA_RESTRICTED: {
|
|
36
41
|
message: "Notebase is currently in beta for selected accounts",
|
|
37
42
|
status: 403,
|
|
38
43
|
},
|
|
39
|
-
|
|
40
|
-
message: "
|
|
44
|
+
NOTEBASE_NOT_FOUND: {
|
|
45
|
+
message: "Notebase not found",
|
|
46
|
+
status: 404,
|
|
47
|
+
},
|
|
48
|
+
NOTEBASE_COLUMN_NOT_FOUND: {
|
|
49
|
+
message: "Notebase column not found",
|
|
41
50
|
status: 404,
|
|
42
51
|
},
|
|
43
|
-
|
|
44
|
-
message: "
|
|
52
|
+
NOTEBASE_ROW_NOT_FOUND: {
|
|
53
|
+
message: "Notebase row not found",
|
|
45
54
|
status: 404,
|
|
46
55
|
},
|
|
47
|
-
|
|
48
|
-
message: "
|
|
56
|
+
CARD_NOT_FOUND: {
|
|
57
|
+
message: "Card not found",
|
|
49
58
|
status: 404,
|
|
50
59
|
},
|
|
51
|
-
|
|
52
|
-
message: "
|
|
60
|
+
CARD_TEMPLATE_NOT_FOUND: {
|
|
61
|
+
message: "Card template not found",
|
|
62
|
+
status: 404,
|
|
63
|
+
},
|
|
64
|
+
CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS: {
|
|
65
|
+
data: CardTemplateInvalidColumnsDataSchema,
|
|
66
|
+
message: "Card template references unknown notebase columns",
|
|
67
|
+
status: 422,
|
|
68
|
+
},
|
|
69
|
+
CARD_TEMPLATE_NOTEBASE_COLUMN_IN_USE: {
|
|
70
|
+
message: "Notebase column is used by a card template",
|
|
71
|
+
status: 409,
|
|
72
|
+
},
|
|
73
|
+
CARD_NOT_REVIEWABLE: {
|
|
74
|
+
message: "Card cannot be reviewed in its current state",
|
|
75
|
+
status: 409,
|
|
76
|
+
},
|
|
77
|
+
CARD_REVIEW_STATE_STALE: {
|
|
78
|
+
message: "Card review state is stale",
|
|
79
|
+
status: 409,
|
|
80
|
+
},
|
|
81
|
+
CARD_REVIEW_ROLLBACK_UNAVAILABLE: {
|
|
82
|
+
message: "Card review cannot be rolled back",
|
|
83
|
+
status: 409,
|
|
84
|
+
},
|
|
85
|
+
NOTEBASE_VIEW_NOT_FOUND: {
|
|
86
|
+
message: "Notebase view not found",
|
|
53
87
|
status: 404,
|
|
54
88
|
},
|
|
55
89
|
CELL_VALIDATION_FAILED: {
|
|
@@ -57,8 +91,8 @@ export const PUBLIC_APP_ERROR_DEFS = {
|
|
|
57
91
|
message: "Cell validation failed",
|
|
58
92
|
status: 422,
|
|
59
93
|
},
|
|
60
|
-
|
|
61
|
-
message: "Cannot delete primary column",
|
|
94
|
+
PRIMARY_NOTEBASE_COLUMN_DELETE_NOT_ALLOWED: {
|
|
95
|
+
message: "Cannot delete primary notebase column",
|
|
62
96
|
status: 400,
|
|
63
97
|
},
|
|
64
98
|
CONCURRENT_POSITION_CONFLICT: {
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cardIdentityShape,
|
|
3
|
+
cardMemoryStateShape,
|
|
4
|
+
cardStateSchema,
|
|
5
|
+
cardTemplateConfigSchema,
|
|
6
|
+
scheduleStatusSchema,
|
|
7
|
+
} from "@read-frog/definitions"
|
|
8
|
+
import { z } from "zod"
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
cardStateSchema,
|
|
12
|
+
scheduleStatusSchema,
|
|
13
|
+
}
|
|
14
|
+
export type { CardState, ScheduleStatus } from "@read-frog/definitions"
|
|
15
|
+
|
|
16
|
+
export const cardTemplateSchema = z.object({
|
|
17
|
+
id: z.uuid(),
|
|
18
|
+
notebaseId: z.uuid(),
|
|
19
|
+
name: z.string(),
|
|
20
|
+
config: cardTemplateConfigSchema,
|
|
21
|
+
createdAt: z.coerce.date(),
|
|
22
|
+
updatedAt: z.coerce.date(),
|
|
23
|
+
})
|
|
24
|
+
export type CardTemplate = z.infer<typeof cardTemplateSchema>
|
|
25
|
+
|
|
26
|
+
export const CardTemplateListInputSchema = z.object({
|
|
27
|
+
notebaseId: z.uuid(),
|
|
28
|
+
})
|
|
29
|
+
export type CardTemplateListInput = z.infer<typeof CardTemplateListInputSchema>
|
|
30
|
+
|
|
31
|
+
export const CardTemplateListOutputSchema = z.array(cardTemplateSchema)
|
|
32
|
+
export type CardTemplateListOutput = z.infer<typeof CardTemplateListOutputSchema>
|
|
33
|
+
|
|
34
|
+
export const CardTemplateGetInputSchema = z.object({
|
|
35
|
+
id: z.uuid(),
|
|
36
|
+
})
|
|
37
|
+
export type CardTemplateGetInput = z.infer<typeof CardTemplateGetInputSchema>
|
|
38
|
+
|
|
39
|
+
export const CardTemplateGetOutputSchema = cardTemplateSchema
|
|
40
|
+
export type CardTemplateGetOutput = z.infer<typeof CardTemplateGetOutputSchema>
|
|
41
|
+
|
|
42
|
+
export const CardTemplateCreateInputSchema = z.object({
|
|
43
|
+
id: z.uuid().optional(),
|
|
44
|
+
notebaseId: z.uuid(),
|
|
45
|
+
name: z.string().min(1),
|
|
46
|
+
config: cardTemplateConfigSchema,
|
|
47
|
+
}).strict()
|
|
48
|
+
export type CardTemplateCreateInput = z.infer<typeof CardTemplateCreateInputSchema>
|
|
49
|
+
|
|
50
|
+
export const CardTemplateCreateOutputSchema = cardTemplateSchema.extend({
|
|
51
|
+
txid: z.number(),
|
|
52
|
+
})
|
|
53
|
+
export type CardTemplateCreateOutput = z.infer<typeof CardTemplateCreateOutputSchema>
|
|
54
|
+
|
|
55
|
+
export const CardTemplateUpdateInputSchema = z.object({
|
|
56
|
+
id: z.uuid(),
|
|
57
|
+
name: z.string().min(1).optional(),
|
|
58
|
+
config: cardTemplateConfigSchema.optional(),
|
|
59
|
+
}).strict()
|
|
60
|
+
export type CardTemplateUpdateInput = z.infer<typeof CardTemplateUpdateInputSchema>
|
|
61
|
+
|
|
62
|
+
export const CardTemplateUpdateOutputSchema = cardTemplateSchema.extend({
|
|
63
|
+
txid: z.number(),
|
|
64
|
+
})
|
|
65
|
+
export type CardTemplateUpdateOutput = z.infer<typeof CardTemplateUpdateOutputSchema>
|
|
66
|
+
|
|
67
|
+
export const CardTemplateDeleteInputSchema = z.object({
|
|
68
|
+
id: z.uuid(),
|
|
69
|
+
})
|
|
70
|
+
export type CardTemplateDeleteInput = z.infer<typeof CardTemplateDeleteInputSchema>
|
|
71
|
+
|
|
72
|
+
export const CardTemplateDeleteOutputSchema = z.object({
|
|
73
|
+
txid: z.number(),
|
|
74
|
+
})
|
|
75
|
+
export type CardTemplateDeleteOutput = z.infer<typeof CardTemplateDeleteOutputSchema>
|
|
76
|
+
|
|
77
|
+
export const cardSchema = z.object({
|
|
78
|
+
...cardIdentityShape,
|
|
79
|
+
...cardMemoryStateShape,
|
|
80
|
+
createdAt: z.coerce.date(),
|
|
81
|
+
updatedAt: z.coerce.date(),
|
|
82
|
+
})
|
|
83
|
+
export type Card = z.infer<typeof cardSchema>
|
|
84
|
+
|
|
85
|
+
export const renderedCardSchema = cardSchema.extend({
|
|
86
|
+
front: z.string(),
|
|
87
|
+
back: z.string(),
|
|
88
|
+
})
|
|
89
|
+
export type RenderedCard = z.infer<typeof renderedCardSchema>
|
|
90
|
+
|
|
91
|
+
export const CardListInputSchema = z.object({
|
|
92
|
+
notebaseId: z.uuid(),
|
|
93
|
+
templateId: z.uuid().optional(),
|
|
94
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
95
|
+
offset: z.number().int().min(0).optional(),
|
|
96
|
+
})
|
|
97
|
+
export type CardListInput = z.infer<typeof CardListInputSchema>
|
|
98
|
+
|
|
99
|
+
export const CardListOutputSchema = z.array(renderedCardSchema)
|
|
100
|
+
export type CardListOutput = z.infer<typeof CardListOutputSchema>
|
|
101
|
+
|
|
102
|
+
export const CardGetInputSchema = z.object({
|
|
103
|
+
id: z.uuid(),
|
|
104
|
+
})
|
|
105
|
+
export type CardGetInput = z.infer<typeof CardGetInputSchema>
|
|
106
|
+
|
|
107
|
+
export const CardGetOutputSchema = renderedCardSchema
|
|
108
|
+
export type CardGetOutput = z.infer<typeof CardGetOutputSchema>
|
|
109
|
+
|
|
110
|
+
export const CardGenerateInputSchema = z.object({
|
|
111
|
+
notebaseId: z.uuid(),
|
|
112
|
+
templateId: z.uuid().optional(),
|
|
113
|
+
})
|
|
114
|
+
export type CardGenerateInput = z.infer<typeof CardGenerateInputSchema>
|
|
115
|
+
|
|
116
|
+
export const CardGenerateOutputSchema = z.object({
|
|
117
|
+
created: z.number().int().min(0),
|
|
118
|
+
txid: z.number(),
|
|
119
|
+
})
|
|
120
|
+
export type CardGenerateOutput = z.infer<typeof CardGenerateOutputSchema>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { NOTEBASE_COLUMN_MAX_WIDTH, NOTEBASE_COLUMN_MIN_WIDTH, notebaseColumnConfigSchema } from "@read-frog/definitions"
|
|
2
|
+
import { z } from "zod"
|
|
3
|
+
|
|
4
|
+
export const notebaseColumnWidthSchema = z.number().int().min(NOTEBASE_COLUMN_MIN_WIDTH).max(NOTEBASE_COLUMN_MAX_WIDTH)
|
|
5
|
+
|
|
6
|
+
export const notebaseColumnSchema = z.object({
|
|
7
|
+
id: z.string(),
|
|
8
|
+
notebaseId: z.string(),
|
|
9
|
+
name: z.string(),
|
|
10
|
+
config: notebaseColumnConfigSchema,
|
|
11
|
+
position: z.number(),
|
|
12
|
+
isPrimary: z.boolean(),
|
|
13
|
+
width: z.number().nullable(),
|
|
14
|
+
createdAt: z.coerce.date(),
|
|
15
|
+
updatedAt: z.coerce.date(),
|
|
16
|
+
})
|
|
17
|
+
export type NotebaseColumn = z.infer<typeof notebaseColumnSchema>
|
|
18
|
+
|
|
19
|
+
export const notebaseColumnCreateDataSchema = z.object({
|
|
20
|
+
id: z.uuid().optional(),
|
|
21
|
+
name: z.string().min(1),
|
|
22
|
+
config: notebaseColumnConfigSchema,
|
|
23
|
+
}).strict()
|
|
24
|
+
export type NotebaseColumnCreateData = z.infer<typeof notebaseColumnCreateDataSchema>
|
|
25
|
+
|
|
26
|
+
export const notebaseColumnUpdateDataSchema = z.object({
|
|
27
|
+
name: z.string().min(1).optional(),
|
|
28
|
+
config: notebaseColumnConfigSchema.optional(),
|
|
29
|
+
width: notebaseColumnWidthSchema.nullable().optional(),
|
|
30
|
+
}).strict()
|
|
31
|
+
export type NotebaseColumnUpdateData = z.infer<typeof notebaseColumnUpdateDataSchema>
|
|
32
|
+
|
|
33
|
+
export const NotebaseColumnCreateInputSchema = z.object({
|
|
34
|
+
notebaseId: z.uuid(),
|
|
35
|
+
data: notebaseColumnCreateDataSchema,
|
|
36
|
+
})
|
|
37
|
+
export type NotebaseColumnCreateInput = z.infer<typeof NotebaseColumnCreateInputSchema>
|
|
38
|
+
|
|
39
|
+
export const NotebaseColumnCreateOutputSchema = z.object({
|
|
40
|
+
txid: z.number(),
|
|
41
|
+
})
|
|
42
|
+
export type NotebaseColumnCreateOutput = z.infer<typeof NotebaseColumnCreateOutputSchema>
|
|
43
|
+
|
|
44
|
+
export const NotebaseColumnUpdateInputSchema = z.object({
|
|
45
|
+
notebaseColumnId: z.uuid(),
|
|
46
|
+
data: notebaseColumnUpdateDataSchema,
|
|
47
|
+
})
|
|
48
|
+
export type NotebaseColumnUpdateInput = z.infer<typeof NotebaseColumnUpdateInputSchema>
|
|
49
|
+
|
|
50
|
+
export const NotebaseColumnUpdateOutputSchema = z.object({
|
|
51
|
+
txid: z.number(),
|
|
52
|
+
})
|
|
53
|
+
export type NotebaseColumnUpdateOutput = z.infer<typeof NotebaseColumnUpdateOutputSchema>
|
|
54
|
+
|
|
55
|
+
export const NotebaseColumnDeleteInputSchema = z.object({
|
|
56
|
+
notebaseColumnId: z.uuid(),
|
|
57
|
+
})
|
|
58
|
+
export type NotebaseColumnDeleteInput = z.infer<typeof NotebaseColumnDeleteInputSchema>
|
|
59
|
+
|
|
60
|
+
export const NotebaseColumnDeleteOutputSchema = z.object({
|
|
61
|
+
txid: z.number(),
|
|
62
|
+
})
|
|
63
|
+
export type NotebaseColumnDeleteOutput = z.infer<typeof NotebaseColumnDeleteOutputSchema>
|
|
64
|
+
|
|
65
|
+
export const NotebaseColumnReorderInputSchema = z.object({
|
|
66
|
+
notebaseId: z.uuid(),
|
|
67
|
+
ids: z.array(z.uuid()),
|
|
68
|
+
})
|
|
69
|
+
export type NotebaseColumnReorderInput = z.infer<typeof NotebaseColumnReorderInputSchema>
|
|
70
|
+
|
|
71
|
+
export const NotebaseColumnReorderOutputSchema = z.object({
|
|
72
|
+
txid: z.number(),
|
|
73
|
+
})
|
|
74
|
+
export type NotebaseColumnReorderOutput = z.infer<typeof NotebaseColumnReorderOutputSchema>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
|
|
3
|
+
export const notebaseRowCellsSchema = z.record(z.string(), z.unknown())
|
|
4
|
+
|
|
5
|
+
export const notebaseRowSchema = z.object({
|
|
6
|
+
id: z.string(),
|
|
7
|
+
notebaseId: z.string(),
|
|
8
|
+
cells: notebaseRowCellsSchema,
|
|
9
|
+
position: z.number(),
|
|
10
|
+
createdAt: z.coerce.date(),
|
|
11
|
+
updatedAt: z.coerce.date(),
|
|
12
|
+
})
|
|
13
|
+
export type NotebaseRow = z.infer<typeof notebaseRowSchema>
|
|
14
|
+
|
|
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>
|
|
20
|
+
|
|
21
|
+
export const notebaseRowUpdateDataSchema = z.object({
|
|
22
|
+
cells: notebaseRowCellsSchema.optional(),
|
|
23
|
+
}).strict()
|
|
24
|
+
export type NotebaseRowUpdateData = z.infer<typeof notebaseRowUpdateDataSchema>
|
|
25
|
+
|
|
26
|
+
export const NotebaseRowCreateInputSchema = z.object({
|
|
27
|
+
notebaseId: z.uuid(),
|
|
28
|
+
data: notebaseRowCreateDataSchema,
|
|
29
|
+
})
|
|
30
|
+
export type NotebaseRowCreateInput = z.infer<typeof NotebaseRowCreateInputSchema>
|
|
31
|
+
|
|
32
|
+
export const NotebaseRowCreateOutputSchema = z.object({
|
|
33
|
+
txid: z.number(),
|
|
34
|
+
})
|
|
35
|
+
export type NotebaseRowCreateOutput = z.infer<typeof NotebaseRowCreateOutputSchema>
|
|
36
|
+
|
|
37
|
+
export const NotebaseRowUpdateInputSchema = z.object({
|
|
38
|
+
notebaseRowId: z.uuid(),
|
|
39
|
+
data: notebaseRowUpdateDataSchema,
|
|
40
|
+
})
|
|
41
|
+
export type NotebaseRowUpdateInput = z.infer<typeof NotebaseRowUpdateInputSchema>
|
|
42
|
+
|
|
43
|
+
export const NotebaseRowUpdateOutputSchema = z.object({
|
|
44
|
+
id: z.uuid(),
|
|
45
|
+
notebaseId: z.uuid(),
|
|
46
|
+
cells: notebaseRowCellsSchema,
|
|
47
|
+
position: z.number().int(),
|
|
48
|
+
createdAt: z.date(),
|
|
49
|
+
updatedAt: z.date(),
|
|
50
|
+
txid: z.number(),
|
|
51
|
+
})
|
|
52
|
+
export type NotebaseRowUpdateOutput = z.infer<typeof NotebaseRowUpdateOutputSchema>
|
|
53
|
+
|
|
54
|
+
export const NotebaseRowDeleteInputSchema = z.object({
|
|
55
|
+
notebaseRowId: z.uuid(),
|
|
56
|
+
})
|
|
57
|
+
export type NotebaseRowDeleteInput = z.infer<typeof NotebaseRowDeleteInputSchema>
|
|
58
|
+
|
|
59
|
+
export const NotebaseRowDeleteOutputSchema = z.object({
|
|
60
|
+
txid: z.number(),
|
|
61
|
+
})
|
|
62
|
+
export type NotebaseRowDeleteOutput = z.infer<typeof NotebaseRowDeleteOutputSchema>
|
|
63
|
+
|
|
64
|
+
export const NotebaseRowReorderInputSchema = z.object({
|
|
65
|
+
notebaseId: z.uuid(),
|
|
66
|
+
ids: z.array(z.uuid()),
|
|
67
|
+
})
|
|
68
|
+
export type NotebaseRowReorderInput = z.infer<typeof NotebaseRowReorderInputSchema>
|
|
69
|
+
|
|
70
|
+
export const NotebaseRowReorderOutputSchema = z.object({
|
|
71
|
+
txid: z.number(),
|
|
72
|
+
})
|
|
73
|
+
export type NotebaseRowReorderOutput = z.infer<typeof NotebaseRowReorderOutputSchema>
|
|
@@ -0,0 +1,61 @@
|
|
|
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>
|
|
48
|
+
|
|
49
|
+
export const notebaseViewSchema = z.object({
|
|
50
|
+
id: z.string(),
|
|
51
|
+
notebaseId: z.string(),
|
|
52
|
+
name: z.string(),
|
|
53
|
+
type: notebaseViewTypeSchema,
|
|
54
|
+
config: notebaseViewConfigSchema.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 NotebaseView = z.infer<typeof notebaseViewSchema>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { schedulingParamsShape, srsWeightsSchema } from "@read-frog/definitions"
|
|
2
|
+
import { z } from "zod"
|
|
3
|
+
import { notebaseColumnSchema } from "./notebase-column"
|
|
4
|
+
import { notebaseRowSchema } from "./notebase-row"
|
|
5
|
+
import { notebaseViewSchema } from "./notebase-view"
|
|
6
|
+
|
|
7
|
+
export const NotebaseListInputSchema = z.object({})
|
|
8
|
+
export type NotebaseListInput = z.infer<typeof NotebaseListInputSchema>
|
|
9
|
+
|
|
10
|
+
export const NotebaseListItemSchema = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
name: z.string(),
|
|
13
|
+
})
|
|
14
|
+
export type NotebaseListItem = z.infer<typeof NotebaseListItemSchema>
|
|
15
|
+
|
|
16
|
+
export const NotebaseListOutputSchema = z.array(NotebaseListItemSchema)
|
|
17
|
+
export type NotebaseListOutput = z.infer<typeof NotebaseListOutputSchema>
|
|
18
|
+
|
|
19
|
+
export const notebaseSchema = z.object({
|
|
20
|
+
id: z.string(),
|
|
21
|
+
userId: z.string(),
|
|
22
|
+
name: z.string(),
|
|
23
|
+
srsNewPerDay: schedulingParamsShape.newPerDay,
|
|
24
|
+
srsReviewsPerDay: schedulingParamsShape.reviewsPerDay,
|
|
25
|
+
srsDesiredRetention: schedulingParamsShape.desiredRetention,
|
|
26
|
+
srsEnableShortTerm: schedulingParamsShape.enableShortTerm,
|
|
27
|
+
srsMaximumInterval: schedulingParamsShape.maximumInterval,
|
|
28
|
+
srsLearningSteps: schedulingParamsShape.learningSteps,
|
|
29
|
+
srsRelearningSteps: schedulingParamsShape.relearningSteps,
|
|
30
|
+
srsLeechThreshold: schedulingParamsShape.leechThreshold,
|
|
31
|
+
srsEnableFuzz: schedulingParamsShape.enableFuzz,
|
|
32
|
+
srsWeights: srsWeightsSchema.nullable(),
|
|
33
|
+
createdAt: z.date(),
|
|
34
|
+
updatedAt: z.date(),
|
|
35
|
+
})
|
|
36
|
+
export type Notebase = z.infer<typeof notebaseSchema>
|
|
37
|
+
|
|
38
|
+
export const notebaseCreateDataSchema = z.object({
|
|
39
|
+
id: z.uuid().optional(),
|
|
40
|
+
name: z.string().min(1),
|
|
41
|
+
}).strict()
|
|
42
|
+
export type NotebaseCreateData = z.infer<typeof notebaseCreateDataSchema>
|
|
43
|
+
|
|
44
|
+
export const NotebaseCreateInputSchema = notebaseCreateDataSchema
|
|
45
|
+
export type NotebaseCreateInput = z.infer<typeof NotebaseCreateInputSchema>
|
|
46
|
+
|
|
47
|
+
export const NotebaseCreateOutputSchema = z.object({
|
|
48
|
+
txid: z.number(),
|
|
49
|
+
})
|
|
50
|
+
export type NotebaseCreateOutput = z.infer<typeof NotebaseCreateOutputSchema>
|
|
51
|
+
|
|
52
|
+
export const notebaseUpdateDataSchema = z.object({
|
|
53
|
+
name: z.string().min(1).optional(),
|
|
54
|
+
}).strict()
|
|
55
|
+
export type NotebaseUpdateData = z.infer<typeof notebaseUpdateDataSchema>
|
|
56
|
+
|
|
57
|
+
export const NotebaseUpdateInputSchema = notebaseUpdateDataSchema.extend({
|
|
58
|
+
id: z.uuid(),
|
|
59
|
+
})
|
|
60
|
+
export type NotebaseUpdateInput = z.infer<typeof NotebaseUpdateInputSchema>
|
|
61
|
+
|
|
62
|
+
export const NotebaseUpdateOutputSchema = z.object({
|
|
63
|
+
txid: z.number(),
|
|
64
|
+
})
|
|
65
|
+
export type NotebaseUpdateOutput = z.infer<typeof NotebaseUpdateOutputSchema>
|
|
66
|
+
|
|
67
|
+
export const NotebaseDeleteInputSchema = z.object({
|
|
68
|
+
id: z.uuid(),
|
|
69
|
+
})
|
|
70
|
+
export type NotebaseDeleteInput = z.infer<typeof NotebaseDeleteInputSchema>
|
|
71
|
+
|
|
72
|
+
export const NotebaseDeleteOutputSchema = z.object({
|
|
73
|
+
txid: z.number(),
|
|
74
|
+
})
|
|
75
|
+
export type NotebaseDeleteOutput = z.infer<typeof NotebaseDeleteOutputSchema>
|
|
76
|
+
|
|
77
|
+
// Get endpoint schemas
|
|
78
|
+
export const NotebaseGetInputSchema = z.object({
|
|
79
|
+
id: z.uuid(),
|
|
80
|
+
})
|
|
81
|
+
export type NotebaseGetInput = z.infer<typeof NotebaseGetInputSchema>
|
|
82
|
+
|
|
83
|
+
export const NotebaseGetSchemaInputSchema = z.object({
|
|
84
|
+
id: z.uuid(),
|
|
85
|
+
})
|
|
86
|
+
export type NotebaseGetSchemaInput = z.infer<typeof NotebaseGetSchemaInputSchema>
|
|
87
|
+
|
|
88
|
+
export const NotebaseGetOutputSchema = notebaseSchema.extend({
|
|
89
|
+
createdAt: z.coerce.date(),
|
|
90
|
+
updatedAt: z.coerce.date(),
|
|
91
|
+
notebaseColumns: z.array(notebaseColumnSchema),
|
|
92
|
+
notebaseRows: z.array(notebaseRowSchema),
|
|
93
|
+
notebaseViews: z.array(notebaseViewSchema),
|
|
94
|
+
})
|
|
95
|
+
export type NotebaseGetOutput = z.infer<typeof NotebaseGetOutputSchema>
|
|
96
|
+
|
|
97
|
+
export const NotebaseGetSchemaOutputSchema = z.object({
|
|
98
|
+
id: z.string(),
|
|
99
|
+
name: z.string(),
|
|
100
|
+
updatedAt: z.coerce.date(),
|
|
101
|
+
notebaseColumns: z.array(notebaseColumnSchema),
|
|
102
|
+
})
|
|
103
|
+
export type NotebaseGetSchemaOutput = z.infer<typeof NotebaseGetSchemaOutputSchema>
|