@read-frog/api-contract 0.16.0 → 0.17.1
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 +458 -394
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/contracts/notebase-row.ts +31 -0
- package/src/public-errors.ts +1 -1
- package/src/schemas/notebase-row.ts +60 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@read-frog/api-contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@orpc/contract": "^1.
|
|
28
|
-
"
|
|
29
|
-
"
|
|
27
|
+
"@orpc/contract": "^1.15.2",
|
|
28
|
+
"@read-frog/definitions": "0.6.1",
|
|
29
|
+
"zod": "^4.6.5"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^26.1.0",
|
|
33
|
-
"tsdown": "^0.22.14",
|
|
34
32
|
"@repo/tsdown-config": "0.0.0",
|
|
35
|
-
"@repo/typescript-config": "0.0.0"
|
|
33
|
+
"@repo/typescript-config": "0.0.0",
|
|
34
|
+
"@types/node": "^26.6.2",
|
|
35
|
+
"tsdown": "^0.23.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsdown",
|
|
@@ -13,10 +13,14 @@ import {
|
|
|
13
13
|
NotebaseRowCreateManyOutputSchema,
|
|
14
14
|
NotebaseRowCreateOutputSchema,
|
|
15
15
|
NotebaseRowDeleteInputSchema,
|
|
16
|
+
NotebaseRowDeleteManyInputSchema,
|
|
17
|
+
NotebaseRowDeleteManyOutputSchema,
|
|
16
18
|
NotebaseRowDeleteOutputSchema,
|
|
17
19
|
NotebaseRowReorderInputSchema,
|
|
18
20
|
NotebaseRowReorderOutputSchema,
|
|
19
21
|
NotebaseRowUpdateInputSchema,
|
|
22
|
+
NotebaseRowUpdateManyInputSchema,
|
|
23
|
+
NotebaseRowUpdateManyOutputSchema,
|
|
20
24
|
NotebaseRowUpdateOutputSchema,
|
|
21
25
|
} from "#/schemas/notebase-row";
|
|
22
26
|
|
|
@@ -96,6 +100,21 @@ export const notebaseRowContract = {
|
|
|
96
100
|
.input(NotebaseRowUpdateInputSchema)
|
|
97
101
|
.output(NotebaseRowUpdateOutputSchema),
|
|
98
102
|
|
|
103
|
+
updateMany: defineAgentProcedure({
|
|
104
|
+
method: "PATCH",
|
|
105
|
+
path: "/notebase-rows/batch",
|
|
106
|
+
summary: "Update notes",
|
|
107
|
+
description:
|
|
108
|
+
"Update 1–50 notes atomically in one owned notebase. Each row supplies its ID and fields to merge; omitted fields are preserved and null clears a field. Supply each note's expectedUpdatedAt to guard against stale edits. A missing row, invalid field or modification conflict rolls back the whole batch. Items are returned in input order.",
|
|
109
|
+
tags: ["Notebase Rows"],
|
|
110
|
+
})
|
|
111
|
+
.errors(
|
|
112
|
+
pickPublicErrorMap("NOTEBASE_NOT_FOUND", "NOTEBASE_ROW_NOT_FOUND", "CELL_VALIDATION_FAILED"),
|
|
113
|
+
)
|
|
114
|
+
.errors(pickPublicErrorMap("RESOURCE_UPDATE_CONFLICT"))
|
|
115
|
+
.input(NotebaseRowUpdateManyInputSchema)
|
|
116
|
+
.output(NotebaseRowUpdateManyOutputSchema),
|
|
117
|
+
|
|
99
118
|
delete: defineAgentProcedure({
|
|
100
119
|
method: "DELETE",
|
|
101
120
|
path: "/notebase-rows/{notebaseRowId}",
|
|
@@ -108,6 +127,18 @@ export const notebaseRowContract = {
|
|
|
108
127
|
.input(NotebaseRowDeleteInputSchema)
|
|
109
128
|
.output(NotebaseRowDeleteOutputSchema),
|
|
110
129
|
|
|
130
|
+
deleteMany: defineAgentProcedure({
|
|
131
|
+
method: "POST",
|
|
132
|
+
path: "/notebase-rows/batch/delete",
|
|
133
|
+
summary: "Delete notes",
|
|
134
|
+
description:
|
|
135
|
+
"Permanently delete 1–50 owned notes atomically, including their derived cards and review records. Notes may belong to different notebases. If any ID is missing or inaccessible, nothing is deleted. Return deleted IDs in input order.",
|
|
136
|
+
tags: ["Notebase Rows"],
|
|
137
|
+
})
|
|
138
|
+
.errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT"))
|
|
139
|
+
.input(NotebaseRowDeleteManyInputSchema)
|
|
140
|
+
.output(NotebaseRowDeleteManyOutputSchema),
|
|
141
|
+
|
|
111
142
|
reorder: oc
|
|
112
143
|
.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT"))
|
|
113
144
|
.route({
|
package/src/public-errors.ts
CHANGED
|
@@ -32,7 +32,7 @@ export const CellValidationFailedDataSchema = z
|
|
|
32
32
|
notebaseColumnId: z.string(),
|
|
33
33
|
details: CellValidationFailureDetailsSchema,
|
|
34
34
|
reason: CellValidationFailureReasonSchema,
|
|
35
|
-
/** Index of the failing row within a batch input (createMany / initialRows). */
|
|
35
|
+
/** Index of the failing row within a batch input (createMany / updateMany / initialRows). */
|
|
36
36
|
rowIndex: z.number().int().min(0).optional(),
|
|
37
37
|
})
|
|
38
38
|
.strict();
|
|
@@ -94,6 +94,42 @@ export const NotebaseRowUpdateOutputSchema = z.object({
|
|
|
94
94
|
});
|
|
95
95
|
export type NotebaseRowUpdateOutput = z.infer<typeof NotebaseRowUpdateOutputSchema>;
|
|
96
96
|
|
|
97
|
+
export const NOTEBASE_ROW_UPDATE_MANY_MAX_ROWS = 50;
|
|
98
|
+
|
|
99
|
+
export const NotebaseRowUpdateManyInputSchema = z
|
|
100
|
+
.object({
|
|
101
|
+
notebaseId: z.uuid(),
|
|
102
|
+
rows: z
|
|
103
|
+
.array(
|
|
104
|
+
z.object({
|
|
105
|
+
id: z.uuid(),
|
|
106
|
+
data: notebaseRowUpdateDataSchema,
|
|
107
|
+
}),
|
|
108
|
+
)
|
|
109
|
+
.min(1)
|
|
110
|
+
.max(NOTEBASE_ROW_UPDATE_MANY_MAX_ROWS),
|
|
111
|
+
})
|
|
112
|
+
.superRefine((input, ctx) => {
|
|
113
|
+
const seenIds = new Set<string>();
|
|
114
|
+
input.rows.forEach((row, index) => {
|
|
115
|
+
if (seenIds.has(row.id)) {
|
|
116
|
+
ctx.addIssue({
|
|
117
|
+
code: "custom",
|
|
118
|
+
message: `Duplicate row id "${row.id}".`,
|
|
119
|
+
path: ["rows", index, "id"],
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
seenIds.add(row.id);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
export type NotebaseRowUpdateManyInput = z.infer<typeof NotebaseRowUpdateManyInputSchema>;
|
|
126
|
+
|
|
127
|
+
export const NotebaseRowUpdateManyOutputSchema = z.object({
|
|
128
|
+
items: z.array(notebaseRowSchema),
|
|
129
|
+
txid: z.number(),
|
|
130
|
+
});
|
|
131
|
+
export type NotebaseRowUpdateManyOutput = z.infer<typeof NotebaseRowUpdateManyOutputSchema>;
|
|
132
|
+
|
|
97
133
|
export const NotebaseRowDeleteInputSchema = z.object({
|
|
98
134
|
notebaseRowId: z.uuid(),
|
|
99
135
|
});
|
|
@@ -102,6 +138,30 @@ export type NotebaseRowDeleteInput = z.infer<typeof NotebaseRowDeleteInputSchema
|
|
|
102
138
|
export const NotebaseRowDeleteOutputSchema = deletionResultSchema;
|
|
103
139
|
export type NotebaseRowDeleteOutput = z.infer<typeof NotebaseRowDeleteOutputSchema>;
|
|
104
140
|
|
|
141
|
+
export const NOTEBASE_ROW_DELETE_MANY_MAX_ROWS = 50;
|
|
142
|
+
|
|
143
|
+
export const NotebaseRowDeleteManyInputSchema = z
|
|
144
|
+
.object({
|
|
145
|
+
ids: z.array(z.uuid()).min(1).max(NOTEBASE_ROW_DELETE_MANY_MAX_ROWS),
|
|
146
|
+
})
|
|
147
|
+
.superRefine((input, ctx) => {
|
|
148
|
+
const seenIds = new Set<string>();
|
|
149
|
+
input.ids.forEach((id, index) => {
|
|
150
|
+
if (seenIds.has(id)) {
|
|
151
|
+
ctx.addIssue({
|
|
152
|
+
code: "custom",
|
|
153
|
+
message: `Duplicate row id "${id}".`,
|
|
154
|
+
path: ["ids", index],
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
seenIds.add(id);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
export type NotebaseRowDeleteManyInput = z.infer<typeof NotebaseRowDeleteManyInputSchema>;
|
|
161
|
+
|
|
162
|
+
export const NotebaseRowDeleteManyOutputSchema = z.object({ ids: z.array(z.uuid()) });
|
|
163
|
+
export type NotebaseRowDeleteManyOutput = z.infer<typeof NotebaseRowDeleteManyOutputSchema>;
|
|
164
|
+
|
|
105
165
|
export const NotebaseRowReorderInputSchema = z.object({
|
|
106
166
|
notebaseId: z.uuid(),
|
|
107
167
|
ids: z.array(z.uuid()),
|