@read-frog/api-contract 0.14.0 → 0.15.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 +1105 -475
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +264 -97
- package/dist/index.js.map +1 -1
- package/package.json +15 -14
- package/src/contracts/beta-access.ts +3 -6
- package/src/contracts/billing.ts +5 -5
- package/src/contracts/card-template.ts +45 -39
- package/src/contracts/card.ts +22 -19
- package/src/contracts/ebook.ts +13 -11
- package/src/contracts/hosted-ai.ts +5 -5
- package/src/contracts/notebase-column.ts +40 -32
- package/src/contracts/notebase-row.ts +85 -45
- package/src/contracts/notebase.ts +60 -40
- package/src/contracts/shared.ts +21 -2
- package/src/contracts/srs.ts +96 -63
- package/src/contracts/stats.ts +9 -11
- package/src/contracts/user.ts +3 -3
- package/src/contracts/video-transcript.ts +22 -12
- package/src/index.ts +37 -33
- package/src/public-errors.ts +74 -51
- package/src/schemas/beta-access.ts +12 -10
- package/src/schemas/billing.ts +77 -59
- package/src/schemas/card.ts +66 -63
- package/src/schemas/ebook.ts +165 -129
- package/src/schemas/hosted-ai.ts +84 -74
- package/src/schemas/notebase-column.ts +50 -36
- package/src/schemas/notebase-row.ts +88 -57
- package/src/schemas/notebase-stats.ts +28 -20
- package/src/schemas/notebase-view.ts +59 -49
- package/src/schemas/notebase.ts +136 -96
- package/src/schemas/pagination.ts +9 -0
- package/src/schemas/resource-mutation.ts +6 -0
- package/src/schemas/srs-stats.ts +30 -22
- package/src/schemas/srs.ts +152 -106
- package/src/schemas/stats.ts +27 -21
- package/src/schemas/timezone.ts +19 -16
- package/src/schemas/user.ts +27 -19
- package/src/schemas/video-transcript.ts +33 -32
package/src/schemas/notebase.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { deletionResultSchema } from "./resource-mutation";
|
|
2
|
+
import {
|
|
3
|
+
notebaseColumnConfigSchema,
|
|
4
|
+
schedulingParamsShape,
|
|
5
|
+
srsWeightsSchema,
|
|
6
|
+
} from "@read-frog/definitions";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { notebaseColumnSchema } from "./notebase-column";
|
|
9
|
+
import { NOTEBASE_ROW_CREATE_MANY_MAX_ROWS, notebaseRowSchema } from "./notebase-row";
|
|
10
|
+
import { notebaseViewSchema } from "./notebase-view";
|
|
11
|
+
|
|
12
|
+
export const NotebaseListInputSchema = z.object({});
|
|
13
|
+
export type NotebaseListInput = z.infer<typeof NotebaseListInputSchema>;
|
|
14
|
+
|
|
15
|
+
export const notebaseSummarySchema = z.object({
|
|
11
16
|
id: z.string(),
|
|
12
17
|
name: z.string(),
|
|
13
|
-
})
|
|
14
|
-
export type
|
|
18
|
+
});
|
|
19
|
+
export type NotebaseSummary = z.infer<typeof notebaseSummarySchema>;
|
|
15
20
|
|
|
16
|
-
export const
|
|
17
|
-
export type
|
|
21
|
+
export const NotebaseListItemSchema = notebaseSummarySchema;
|
|
22
|
+
export type NotebaseListItem = z.infer<typeof NotebaseListItemSchema>;
|
|
23
|
+
|
|
24
|
+
export const NotebaseListOutputSchema = z.array(NotebaseListItemSchema);
|
|
25
|
+
export type NotebaseListOutput = z.infer<typeof NotebaseListOutputSchema>;
|
|
18
26
|
|
|
19
27
|
export const notebaseSchema = z.object({
|
|
20
28
|
id: z.string(),
|
|
@@ -32,105 +40,137 @@ export const notebaseSchema = z.object({
|
|
|
32
40
|
srsWeights: srsWeightsSchema.nullable(),
|
|
33
41
|
createdAt: z.date(),
|
|
34
42
|
updatedAt: z.date(),
|
|
35
|
-
})
|
|
36
|
-
export type Notebase = z.infer<typeof notebaseSchema
|
|
37
|
-
|
|
38
|
-
const notebaseInitialRowSchema = z
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
43
|
+
});
|
|
44
|
+
export type Notebase = z.infer<typeof notebaseSchema>;
|
|
45
|
+
|
|
46
|
+
const notebaseInitialRowSchema = z
|
|
47
|
+
.object({
|
|
48
|
+
id: z.uuid().optional(),
|
|
49
|
+
cells: z.record(z.string(), z.unknown()),
|
|
50
|
+
})
|
|
51
|
+
.strict();
|
|
52
|
+
|
|
53
|
+
export const notebaseCreateDataSchema = z
|
|
54
|
+
.object({
|
|
55
|
+
id: z.uuid().optional(),
|
|
56
|
+
name: z.string().min(1),
|
|
57
|
+
options: z
|
|
58
|
+
.object({
|
|
59
|
+
initialColumns: z
|
|
60
|
+
.array(
|
|
61
|
+
z
|
|
62
|
+
.object({
|
|
63
|
+
id: z.uuid(),
|
|
64
|
+
name: z.string().min(1),
|
|
65
|
+
config: notebaseColumnConfigSchema,
|
|
66
|
+
})
|
|
67
|
+
.strict(),
|
|
68
|
+
)
|
|
69
|
+
.min(1),
|
|
70
|
+
initialRow: notebaseInitialRowSchema.optional(),
|
|
71
|
+
initialRows: z
|
|
72
|
+
.array(notebaseInitialRowSchema)
|
|
73
|
+
.min(1)
|
|
74
|
+
.max(NOTEBASE_ROW_CREATE_MANY_MAX_ROWS)
|
|
75
|
+
.optional(),
|
|
76
|
+
})
|
|
77
|
+
.strict()
|
|
78
|
+
.superRefine((options, ctx) => {
|
|
79
|
+
if (options.initialRow && options.initialRows) {
|
|
80
|
+
ctx.addIssue({
|
|
81
|
+
code: "custom",
|
|
82
|
+
message: "Provide either initialRow or initialRows, not both.",
|
|
83
|
+
path: ["initialRows"],
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!options.initialRows) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const seenIds = new Set<string>();
|
|
92
|
+
options.initialRows.forEach((row, index) => {
|
|
93
|
+
if (row.id === undefined) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (seenIds.has(row.id)) {
|
|
98
|
+
ctx.addIssue({
|
|
99
|
+
code: "custom",
|
|
100
|
+
message: `Duplicate row id "${row.id}".`,
|
|
101
|
+
path: ["initialRows", index, "id"],
|
|
102
|
+
});
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
seenIds.add(row.id);
|
|
107
|
+
});
|
|
60
108
|
})
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
options.initialRows.forEach((row, index) => {
|
|
69
|
-
if (row.id === undefined) {
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (seenIds.has(row.id)) {
|
|
74
|
-
ctx.addIssue({
|
|
75
|
-
code: "custom",
|
|
76
|
-
message: `Duplicate row id "${row.id}".`,
|
|
77
|
-
path: ["initialRows", index, "id"],
|
|
78
|
-
})
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
seenIds.add(row.id)
|
|
83
|
-
})
|
|
84
|
-
}).optional(),
|
|
85
|
-
}).strict()
|
|
86
|
-
export type NotebaseCreateData = z.infer<typeof notebaseCreateDataSchema>
|
|
87
|
-
|
|
88
|
-
export const NotebaseCreateInputSchema = notebaseCreateDataSchema
|
|
89
|
-
export type NotebaseCreateInput = z.infer<typeof NotebaseCreateInputSchema>
|
|
109
|
+
.optional(),
|
|
110
|
+
})
|
|
111
|
+
.strict();
|
|
112
|
+
export type NotebaseCreateData = z.infer<typeof notebaseCreateDataSchema>;
|
|
113
|
+
|
|
114
|
+
export const NotebaseCreateInputSchema = notebaseCreateDataSchema;
|
|
115
|
+
export type NotebaseCreateInput = z.infer<typeof NotebaseCreateInputSchema>;
|
|
90
116
|
|
|
91
117
|
export const NotebaseCreateOutputSchema = z.object({
|
|
118
|
+
notebase: notebaseSchema,
|
|
92
119
|
txid: z.number(),
|
|
93
|
-
})
|
|
94
|
-
export type NotebaseCreateOutput = z.infer<typeof NotebaseCreateOutputSchema
|
|
95
|
-
|
|
96
|
-
export const notebaseUpdateDataSchema = z
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
120
|
+
});
|
|
121
|
+
export type NotebaseCreateOutput = z.infer<typeof NotebaseCreateOutputSchema>;
|
|
122
|
+
|
|
123
|
+
export const notebaseUpdateDataSchema = z
|
|
124
|
+
.object({
|
|
125
|
+
name: z.string().min(1).optional(),
|
|
126
|
+
srsNewPerDay: schedulingParamsShape.newPerDay.optional(),
|
|
127
|
+
srsReviewsPerDay: schedulingParamsShape.reviewsPerDay.optional(),
|
|
128
|
+
srsDesiredRetention: schedulingParamsShape.desiredRetention.optional(),
|
|
129
|
+
})
|
|
130
|
+
.strict();
|
|
131
|
+
export type NotebaseUpdateData = z.infer<typeof notebaseUpdateDataSchema>;
|
|
103
132
|
|
|
104
133
|
export const NotebaseUpdateInputSchema = notebaseUpdateDataSchema.extend({
|
|
105
134
|
id: z.uuid(),
|
|
106
|
-
})
|
|
107
|
-
export type NotebaseUpdateInput = z.infer<typeof NotebaseUpdateInputSchema
|
|
135
|
+
});
|
|
136
|
+
export type NotebaseUpdateInput = z.infer<typeof NotebaseUpdateInputSchema>;
|
|
108
137
|
|
|
109
138
|
export const NotebaseUpdateOutputSchema = z.object({
|
|
139
|
+
notebase: notebaseSchema,
|
|
110
140
|
txid: z.number(),
|
|
111
|
-
})
|
|
112
|
-
export type NotebaseUpdateOutput = z.infer<typeof NotebaseUpdateOutputSchema
|
|
141
|
+
});
|
|
142
|
+
export type NotebaseUpdateOutput = z.infer<typeof NotebaseUpdateOutputSchema>;
|
|
113
143
|
|
|
114
144
|
export const NotebaseDeleteInputSchema = z.object({
|
|
115
145
|
id: z.uuid(),
|
|
116
|
-
})
|
|
117
|
-
export type NotebaseDeleteInput = z.infer<typeof NotebaseDeleteInputSchema
|
|
146
|
+
});
|
|
147
|
+
export type NotebaseDeleteInput = z.infer<typeof NotebaseDeleteInputSchema>;
|
|
118
148
|
|
|
119
|
-
export const NotebaseDeleteOutputSchema =
|
|
120
|
-
|
|
121
|
-
})
|
|
122
|
-
export type NotebaseDeleteOutput = z.infer<typeof NotebaseDeleteOutputSchema>
|
|
149
|
+
export const NotebaseDeleteOutputSchema = deletionResultSchema;
|
|
150
|
+
export type NotebaseDeleteOutput = z.infer<typeof NotebaseDeleteOutputSchema>;
|
|
123
151
|
|
|
124
152
|
// Get endpoint schemas
|
|
125
153
|
export const NotebaseGetInputSchema = z.object({
|
|
126
154
|
id: z.uuid(),
|
|
127
|
-
})
|
|
128
|
-
export type NotebaseGetInput = z.infer<typeof NotebaseGetInputSchema
|
|
155
|
+
});
|
|
156
|
+
export type NotebaseGetInput = z.infer<typeof NotebaseGetInputSchema>;
|
|
157
|
+
|
|
158
|
+
export const NotebaseGetSummaryInputSchema = z.object({
|
|
159
|
+
id: z.uuid(),
|
|
160
|
+
});
|
|
161
|
+
export type NotebaseGetSummaryInput = z.infer<typeof NotebaseGetSummaryInputSchema>;
|
|
162
|
+
|
|
163
|
+
export const NotebaseGetSummaryOutputSchema = notebaseSummarySchema.extend({
|
|
164
|
+
srsNewPerDay: schedulingParamsShape.newPerDay,
|
|
165
|
+
srsReviewsPerDay: schedulingParamsShape.reviewsPerDay,
|
|
166
|
+
srsDesiredRetention: schedulingParamsShape.desiredRetention,
|
|
167
|
+
});
|
|
168
|
+
export type NotebaseGetSummaryOutput = z.infer<typeof NotebaseGetSummaryOutputSchema>;
|
|
129
169
|
|
|
130
170
|
export const NotebaseGetSchemaInputSchema = z.object({
|
|
131
171
|
id: z.uuid(),
|
|
132
|
-
})
|
|
133
|
-
export type NotebaseGetSchemaInput = z.infer<typeof NotebaseGetSchemaInputSchema
|
|
172
|
+
});
|
|
173
|
+
export type NotebaseGetSchemaInput = z.infer<typeof NotebaseGetSchemaInputSchema>;
|
|
134
174
|
|
|
135
175
|
export const NotebaseGetOutputSchema = notebaseSchema.extend({
|
|
136
176
|
createdAt: z.coerce.date(),
|
|
@@ -138,13 +178,13 @@ export const NotebaseGetOutputSchema = notebaseSchema.extend({
|
|
|
138
178
|
notebaseColumns: z.array(notebaseColumnSchema),
|
|
139
179
|
notebaseRows: z.array(notebaseRowSchema),
|
|
140
180
|
notebaseViews: z.array(notebaseViewSchema),
|
|
141
|
-
})
|
|
142
|
-
export type NotebaseGetOutput = z.infer<typeof NotebaseGetOutputSchema
|
|
181
|
+
});
|
|
182
|
+
export type NotebaseGetOutput = z.infer<typeof NotebaseGetOutputSchema>;
|
|
143
183
|
|
|
144
184
|
export const NotebaseGetSchemaOutputSchema = z.object({
|
|
145
185
|
id: z.string(),
|
|
146
186
|
name: z.string(),
|
|
147
187
|
updatedAt: z.coerce.date(),
|
|
148
188
|
notebaseColumns: z.array(notebaseColumnSchema),
|
|
149
|
-
})
|
|
150
|
-
export type NotebaseGetSchemaOutput = z.infer<typeof NotebaseGetSchemaOutputSchema
|
|
189
|
+
});
|
|
190
|
+
export type NotebaseGetSchemaOutput = z.infer<typeof NotebaseGetSchemaOutputSchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const paginationShape = {
|
|
3
|
+
// Existing callers omit pagination to read all matching records.
|
|
4
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
5
|
+
offset: z.number().int().min(0).optional(),
|
|
6
|
+
};
|
|
7
|
+
export function pageSchema<T extends z.ZodType>(itemSchema: T) {
|
|
8
|
+
return z.object({ items: z.array(itemSchema), hasMore: z.boolean() });
|
|
9
|
+
}
|
package/src/schemas/srs-stats.ts
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
import { z } from "zod"
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const srsActivityStatsItemSchema = z
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export const srsActivityStatsItemSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
date: z.iso.date(),
|
|
6
|
+
answers: z.number().int().nonnegative(),
|
|
7
|
+
durationMs: z.number().int().nonnegative(),
|
|
8
|
+
})
|
|
9
|
+
.strict();
|
|
10
|
+
export type SrsActivityStatsItem = z.infer<typeof srsActivityStatsItemSchema>;
|
|
9
11
|
|
|
10
|
-
export const srsActivityStatsOutputSchema = z
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export const srsActivityStatsOutputSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
learnedCards: z.number().int().nonnegative(),
|
|
15
|
+
daily: z.array(srsActivityStatsItemSchema),
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
export type SrsActivityStatsOutput = z.infer<typeof srsActivityStatsOutputSchema>;
|
|
15
19
|
|
|
16
|
-
export const srsMemoryGrowthStatsItemSchema = z
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
export const srsMemoryGrowthStatsItemSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
date: z.iso.date(),
|
|
23
|
+
delta: z.number().int(),
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
export type SrsMemoryGrowthStatsItem = z.infer<typeof srsMemoryGrowthStatsItemSchema>;
|
|
21
27
|
|
|
22
|
-
export const srsMemoryGrowthStatsOutputSchema = z
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
export const srsMemoryGrowthStatsOutputSchema = z
|
|
29
|
+
.object({
|
|
30
|
+
baseTotal: z.number().int().nonnegative(),
|
|
31
|
+
daily: z.array(srsMemoryGrowthStatsItemSchema),
|
|
32
|
+
})
|
|
33
|
+
.strict();
|
|
34
|
+
export type SrsMemoryGrowthStatsOutput = z.infer<typeof srsMemoryGrowthStatsOutputSchema>;
|