@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.
- package/dist/index.d.ts +670 -301
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +305 -182
- package/dist/index.js.map +1 -1
- package/package.json +9 -7
- package/src/contracts/beta-access.ts +17 -0
- package/src/contracts/column.ts +62 -0
- package/src/contracts/custom-table.ts +82 -0
- package/src/contracts/row.ts +62 -0
- package/src/contracts/shared.ts +6 -0
- package/src/index.ts +21 -0
- package/src/public-errors.ts +104 -0
- package/src/schemas/beta-access.ts +16 -0
- package/src/schemas/column.ts +74 -0
- package/src/schemas/custom-table.ts +86 -0
- package/src/schemas/row.ts +73 -0
- package/src/schemas/view.ts +61 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/public-errors.ts","../src/schemas/beta-access.ts","../src/schemas/column.ts","../src/schemas/custom-table.ts","../src/schemas/row.ts","../src/schemas/view.ts","../src/index.ts"],"mappings":";;;;;;;cASa,iCAAA,EAAiC,CAAA,CAAA,OAAA;;;;;;KAMlC,2BAAA,GAA8B,CAAA,CAAE,KAAA,QAAa,iCAAA;AAAA,cAE5C,kCAAA,EAAkC,CAAA,CAAA,SAAA;;;;;;;KAOnC,4BAAA,GAA+B,CAAA,CAAE,KAAA,QAAa,kCAAA;AAAA,cAE7C,8BAAA,EAA8B,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;KAK/B,wBAAA,GAA2B,CAAA,CAAE,KAAA,QAAa,8BAAA;AAAA,cAEzC,qBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoCD,kBAAA,gBAAkC,qBAAA;AAAA,KAElC,kBAAA,eAAiC,kBAAA,YACjC,qBAAA,EAAuB,KAAA;EAAiB,IAAA,wBAA4B,CAAA,CAAE,UAAA;AAAA,IAC5E,CAAA,C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@@ -1,244 +1,367 @@
|
|
|
1
1
|
import { oc } from "@orpc/contract";
|
|
2
|
-
import { COLUMN_MAX_WIDTH, COLUMN_MIN_WIDTH, columnConfigSchema } from "@read-frog/definitions";
|
|
2
|
+
import { BETA_FEATURE_KEYS, COLUMN_MAX_WIDTH, COLUMN_MIN_WIDTH, columnConfigSchema } from "@read-frog/definitions";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
|
|
4
|
+
//#region src/schemas/beta-access.ts
|
|
5
|
+
const BetaFeatureKeySchema = z.enum(BETA_FEATURE_KEYS);
|
|
6
|
+
const BetaAccessStatusInputSchema = z.object({ featureKey: BetaFeatureKeySchema }).strict();
|
|
7
|
+
const BetaAccessStatusOutputSchema = z.object({
|
|
8
|
+
featureKey: BetaFeatureKeySchema,
|
|
9
|
+
allowed: z.boolean()
|
|
10
|
+
});
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/contracts/beta-access.ts
|
|
13
|
+
const betaAccessContract = { status: oc.route({
|
|
14
|
+
method: "GET",
|
|
15
|
+
path: "/beta-access/status",
|
|
16
|
+
summary: "Get beta access status for a feature",
|
|
17
|
+
tags: ["Beta Access"]
|
|
18
|
+
}).input(BetaAccessStatusInputSchema).output(BetaAccessStatusOutputSchema) };
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/public-errors.ts
|
|
21
|
+
const CellValidationFailureReasonSchema = z.enum([
|
|
22
|
+
"unknown_column",
|
|
23
|
+
"type_mismatch",
|
|
24
|
+
"invalid_select_option",
|
|
25
|
+
"invalid_date_format"
|
|
26
|
+
]);
|
|
27
|
+
const CellValidationFailureDetailsSchema = z.object({
|
|
28
|
+
expectedFormat: z.string().optional(),
|
|
29
|
+
expectedType: z.string().optional(),
|
|
30
|
+
receivedType: z.string().optional(),
|
|
31
|
+
receivedValue: z.unknown().optional(),
|
|
32
|
+
validOptions: z.array(z.string()).optional()
|
|
33
|
+
}).strict();
|
|
34
|
+
const CellValidationFailedDataSchema = z.object({
|
|
35
|
+
columnId: z.string(),
|
|
36
|
+
details: CellValidationFailureDetailsSchema,
|
|
37
|
+
reason: CellValidationFailureReasonSchema
|
|
38
|
+
}).strict();
|
|
39
|
+
const PUBLIC_APP_ERROR_DEFS = {
|
|
40
|
+
NOTEBASE_BETA_RESTRICTED: {
|
|
41
|
+
message: "Notebase is currently in beta for selected accounts",
|
|
42
|
+
status: 403
|
|
43
|
+
},
|
|
44
|
+
TABLE_NOT_FOUND: {
|
|
45
|
+
message: "Table not found",
|
|
46
|
+
status: 404
|
|
47
|
+
},
|
|
48
|
+
COLUMN_NOT_FOUND: {
|
|
49
|
+
message: "Column not found",
|
|
50
|
+
status: 404
|
|
51
|
+
},
|
|
52
|
+
ROW_NOT_FOUND: {
|
|
53
|
+
message: "Row not found",
|
|
54
|
+
status: 404
|
|
55
|
+
},
|
|
56
|
+
VIEW_NOT_FOUND: {
|
|
57
|
+
message: "View not found",
|
|
58
|
+
status: 404
|
|
59
|
+
},
|
|
60
|
+
CELL_VALIDATION_FAILED: {
|
|
61
|
+
data: CellValidationFailedDataSchema,
|
|
62
|
+
message: "Cell validation failed",
|
|
63
|
+
status: 422
|
|
64
|
+
},
|
|
65
|
+
PRIMARY_COLUMN_DELETE_NOT_ALLOWED: {
|
|
66
|
+
message: "Cannot delete primary column",
|
|
67
|
+
status: 400
|
|
68
|
+
},
|
|
69
|
+
CONCURRENT_POSITION_CONFLICT: {
|
|
70
|
+
message: "Concurrent position conflict, please retry",
|
|
71
|
+
status: 409
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
function isPublicAppErrorCode(code) {
|
|
75
|
+
return code !== void 0 && code in PUBLIC_APP_ERROR_DEFS;
|
|
76
|
+
}
|
|
77
|
+
function getPublicErrorDefinition(code) {
|
|
78
|
+
return PUBLIC_APP_ERROR_DEFS[code];
|
|
79
|
+
}
|
|
80
|
+
function pickPublicErrorMap(...codes) {
|
|
81
|
+
return Object.fromEntries(codes.map((code) => {
|
|
82
|
+
const definition = PUBLIC_APP_ERROR_DEFS[code];
|
|
83
|
+
if ("data" in definition) return [code, {
|
|
84
|
+
data: definition.data,
|
|
85
|
+
message: definition.message,
|
|
86
|
+
status: definition.status
|
|
87
|
+
}];
|
|
88
|
+
return [code, {
|
|
89
|
+
message: definition.message,
|
|
90
|
+
status: definition.status
|
|
91
|
+
}];
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
5
95
|
//#region src/schemas/column.ts
|
|
6
|
-
const
|
|
96
|
+
const columnWidthSchema = z.number().int().min(COLUMN_MIN_WIDTH).max(COLUMN_MAX_WIDTH);
|
|
97
|
+
const tableColumnSchema = z.object({
|
|
98
|
+
id: z.string(),
|
|
99
|
+
tableId: z.string(),
|
|
100
|
+
name: z.string(),
|
|
101
|
+
config: columnConfigSchema,
|
|
102
|
+
position: z.number(),
|
|
103
|
+
isPrimary: z.boolean(),
|
|
104
|
+
width: z.number().nullable(),
|
|
105
|
+
createdAt: z.coerce.date(),
|
|
106
|
+
updatedAt: z.coerce.date()
|
|
107
|
+
});
|
|
108
|
+
const columnCreateDataSchema = z.object({
|
|
109
|
+
id: z.uuid().optional(),
|
|
110
|
+
name: z.string().min(1),
|
|
111
|
+
config: columnConfigSchema
|
|
112
|
+
}).strict();
|
|
113
|
+
const columnUpdateDataSchema = z.object({
|
|
114
|
+
name: z.string().min(1).optional(),
|
|
115
|
+
config: columnConfigSchema.optional(),
|
|
116
|
+
width: columnWidthSchema.nullable().optional()
|
|
117
|
+
}).strict();
|
|
118
|
+
const ColumnCreateInputSchema = z.object({
|
|
7
119
|
tableId: z.uuid(),
|
|
8
|
-
data:
|
|
9
|
-
id: z.uuid().optional(),
|
|
10
|
-
name: z.string().min(1),
|
|
11
|
-
config: columnConfigSchema,
|
|
12
|
-
position: z.number().int().optional()
|
|
13
|
-
}).strict()
|
|
120
|
+
data: columnCreateDataSchema
|
|
14
121
|
});
|
|
15
|
-
const
|
|
122
|
+
const ColumnCreateOutputSchema = z.object({ txid: z.number() });
|
|
16
123
|
const ColumnUpdateInputSchema = z.object({
|
|
17
124
|
columnId: z.uuid(),
|
|
18
|
-
data:
|
|
19
|
-
name: z.string().min(1).optional(),
|
|
20
|
-
config: columnConfigSchema.optional(),
|
|
21
|
-
width: z.number().int().min(COLUMN_MIN_WIDTH).max(COLUMN_MAX_WIDTH).nullable().optional()
|
|
22
|
-
}).strict()
|
|
125
|
+
data: columnUpdateDataSchema
|
|
23
126
|
});
|
|
24
127
|
const ColumnUpdateOutputSchema = z.object({ txid: z.number() });
|
|
25
128
|
const ColumnDeleteInputSchema = z.object({ columnId: z.uuid() });
|
|
26
129
|
const ColumnDeleteOutputSchema = z.object({ txid: z.number() });
|
|
27
|
-
|
|
130
|
+
const ColumnReorderInputSchema = z.object({
|
|
131
|
+
tableId: z.uuid(),
|
|
132
|
+
ids: z.array(z.uuid())
|
|
133
|
+
});
|
|
134
|
+
const ColumnReorderOutputSchema = z.object({ txid: z.number() });
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/contracts/shared.ts
|
|
137
|
+
const notebaseProcedure = oc.errors(pickPublicErrorMap("NOTEBASE_BETA_RESTRICTED"));
|
|
28
138
|
//#endregion
|
|
29
139
|
//#region src/contracts/column.ts
|
|
30
140
|
const columnContract = {
|
|
31
|
-
|
|
141
|
+
create: notebaseProcedure.errors(pickPublicErrorMap("TABLE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
|
|
32
142
|
method: "POST",
|
|
33
143
|
path: "/columns",
|
|
34
|
-
summary: "
|
|
144
|
+
summary: "Create column",
|
|
35
145
|
tags: ["Columns"]
|
|
36
|
-
}).input(
|
|
37
|
-
update:
|
|
146
|
+
}).input(ColumnCreateInputSchema).output(ColumnCreateOutputSchema),
|
|
147
|
+
update: notebaseProcedure.errors(pickPublicErrorMap("COLUMN_NOT_FOUND")).route({
|
|
38
148
|
method: "PATCH",
|
|
39
149
|
path: "/columns/{columnId}",
|
|
40
|
-
summary: "Update column
|
|
150
|
+
summary: "Update column",
|
|
41
151
|
tags: ["Columns"]
|
|
42
152
|
}).input(ColumnUpdateInputSchema).output(ColumnUpdateOutputSchema),
|
|
43
|
-
delete:
|
|
153
|
+
delete: notebaseProcedure.errors(pickPublicErrorMap("COLUMN_NOT_FOUND", "PRIMARY_COLUMN_DELETE_NOT_ALLOWED", "CONCURRENT_POSITION_CONFLICT")).route({
|
|
44
154
|
method: "DELETE",
|
|
45
155
|
path: "/columns/{columnId}",
|
|
46
156
|
summary: "Delete column",
|
|
47
157
|
tags: ["Columns"]
|
|
48
|
-
}).input(ColumnDeleteInputSchema).output(ColumnDeleteOutputSchema)
|
|
158
|
+
}).input(ColumnDeleteInputSchema).output(ColumnDeleteOutputSchema),
|
|
159
|
+
reorder: notebaseProcedure.errors(pickPublicErrorMap("TABLE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
|
|
160
|
+
method: "POST",
|
|
161
|
+
path: "/columns/reorder",
|
|
162
|
+
summary: "Reorder columns in a table",
|
|
163
|
+
tags: ["Columns"]
|
|
164
|
+
}).input(ColumnReorderInputSchema).output(ColumnReorderOutputSchema)
|
|
49
165
|
};
|
|
50
|
-
|
|
51
166
|
//#endregion
|
|
52
|
-
//#region src/schemas/
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
id: z.string(),
|
|
56
|
-
name: z.string()
|
|
57
|
-
});
|
|
58
|
-
const CustomTableListOutputSchema = z.array(CustomTableListItemSchema);
|
|
59
|
-
const CustomTableCreateInputSchema = z.object({
|
|
60
|
-
id: z.uuid().optional(),
|
|
61
|
-
name: z.string().min(1)
|
|
62
|
-
});
|
|
63
|
-
const CustomTableCreateOutputSchema = z.object({ txid: z.number() });
|
|
64
|
-
const CustomTableUpdateInputSchema = z.object({
|
|
65
|
-
id: z.uuid(),
|
|
66
|
-
name: z.string().min(1).optional()
|
|
67
|
-
});
|
|
68
|
-
const CustomTableUpdateOutputSchema = z.object({ txid: z.number() });
|
|
69
|
-
const CustomTableDeleteInputSchema = z.object({ id: z.uuid() });
|
|
70
|
-
const CustomTableDeleteOutputSchema = z.object({ txid: z.number() });
|
|
71
|
-
const CustomTableGetInputSchema = z.object({ id: z.uuid() });
|
|
72
|
-
const CustomTableGetSchemaInputSchema = z.object({ id: z.uuid() });
|
|
73
|
-
const TableColumnSchema = z.object({
|
|
167
|
+
//#region src/schemas/row.ts
|
|
168
|
+
const rowCellsSchema = z.record(z.string(), z.unknown());
|
|
169
|
+
const tableRowSchema = z.object({
|
|
74
170
|
id: z.string(),
|
|
75
171
|
tableId: z.string(),
|
|
76
|
-
|
|
77
|
-
config: columnConfigSchema,
|
|
172
|
+
cells: rowCellsSchema,
|
|
78
173
|
position: z.number(),
|
|
79
|
-
isPrimary: z.boolean(),
|
|
80
|
-
width: z.number().nullable(),
|
|
81
174
|
createdAt: z.coerce.date(),
|
|
82
175
|
updatedAt: z.coerce.date()
|
|
83
176
|
});
|
|
84
|
-
const
|
|
85
|
-
id: z.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
177
|
+
const rowCreateDataSchema = z.object({
|
|
178
|
+
id: z.uuid().optional(),
|
|
179
|
+
cells: rowCellsSchema.optional()
|
|
180
|
+
}).strict();
|
|
181
|
+
const rowUpdateDataSchema = z.object({ cells: rowCellsSchema.optional() }).strict();
|
|
182
|
+
const RowCreateInputSchema = z.object({
|
|
183
|
+
tableId: z.uuid(),
|
|
184
|
+
data: rowCreateDataSchema
|
|
185
|
+
});
|
|
186
|
+
const RowCreateOutputSchema = z.object({ txid: z.number() });
|
|
187
|
+
const RowUpdateInputSchema = z.object({
|
|
188
|
+
rowId: z.uuid(),
|
|
189
|
+
data: rowUpdateDataSchema
|
|
190
|
+
});
|
|
191
|
+
const RowUpdateOutputSchema = z.object({
|
|
192
|
+
id: z.uuid(),
|
|
193
|
+
tableId: z.uuid(),
|
|
194
|
+
cells: rowCellsSchema,
|
|
195
|
+
position: z.number().int(),
|
|
196
|
+
createdAt: z.date(),
|
|
197
|
+
updatedAt: z.date(),
|
|
198
|
+
txid: z.number()
|
|
199
|
+
});
|
|
200
|
+
const RowDeleteInputSchema = z.object({ rowId: z.uuid() });
|
|
201
|
+
const RowDeleteOutputSchema = z.object({ txid: z.number() });
|
|
202
|
+
const RowReorderInputSchema = z.object({
|
|
203
|
+
tableId: z.uuid(),
|
|
204
|
+
ids: z.array(z.uuid())
|
|
91
205
|
});
|
|
92
|
-
const
|
|
206
|
+
const RowReorderOutputSchema = z.object({ txid: z.number() });
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/schemas/view.ts
|
|
209
|
+
const tableViewTypeSchema = z.enum([
|
|
210
|
+
"table",
|
|
211
|
+
"kanban",
|
|
212
|
+
"gallery"
|
|
213
|
+
]);
|
|
214
|
+
const viewConfigSchema = z.object({
|
|
215
|
+
columnWidths: z.record(z.string(), z.number()).optional(),
|
|
216
|
+
hiddenColumns: z.array(z.string()).optional(),
|
|
217
|
+
groupByColumnId: z.string().optional()
|
|
218
|
+
}).catchall(z.unknown());
|
|
219
|
+
const viewFilterSchema = z.object({
|
|
220
|
+
columnId: z.string(),
|
|
221
|
+
operator: z.string(),
|
|
222
|
+
value: z.unknown()
|
|
223
|
+
}).strict();
|
|
224
|
+
const viewFiltersSchema = z.array(viewFilterSchema);
|
|
225
|
+
const viewSortSchema = z.object({
|
|
226
|
+
columnId: z.string(),
|
|
227
|
+
direction: z.enum(["asc", "desc"])
|
|
228
|
+
}).strict();
|
|
229
|
+
const viewSortsSchema = z.array(viewSortSchema);
|
|
230
|
+
const viewCreateDataSchema = z.object({
|
|
231
|
+
id: z.uuid().optional(),
|
|
232
|
+
name: z.string().min(1),
|
|
233
|
+
type: tableViewTypeSchema,
|
|
234
|
+
config: viewConfigSchema.optional(),
|
|
235
|
+
filters: viewFiltersSchema.optional(),
|
|
236
|
+
sorts: viewSortsSchema.optional()
|
|
237
|
+
}).strict();
|
|
238
|
+
const viewUpdateDataSchema = z.object({
|
|
239
|
+
name: z.string().min(1).optional(),
|
|
240
|
+
type: tableViewTypeSchema.optional(),
|
|
241
|
+
config: viewConfigSchema.optional(),
|
|
242
|
+
filters: viewFiltersSchema.optional(),
|
|
243
|
+
sorts: viewSortsSchema.optional()
|
|
244
|
+
}).strict();
|
|
245
|
+
const tableViewSchema = z.object({
|
|
93
246
|
id: z.string(),
|
|
94
247
|
tableId: z.string(),
|
|
95
248
|
name: z.string(),
|
|
96
|
-
type:
|
|
97
|
-
|
|
98
|
-
"kanban",
|
|
99
|
-
"gallery"
|
|
100
|
-
]),
|
|
101
|
-
config: z.record(z.string(), z.unknown()).nullable(),
|
|
249
|
+
type: tableViewTypeSchema,
|
|
250
|
+
config: viewConfigSchema.nullable(),
|
|
102
251
|
filters: z.array(z.unknown()).nullable(),
|
|
103
252
|
sorts: z.array(z.unknown()).nullable(),
|
|
104
253
|
position: z.number(),
|
|
105
254
|
createdAt: z.coerce.date(),
|
|
106
255
|
updatedAt: z.coerce.date()
|
|
107
256
|
});
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/schemas/custom-table.ts
|
|
259
|
+
const CustomTableListInputSchema = z.object({});
|
|
260
|
+
const CustomTableListItemSchema = z.object({
|
|
261
|
+
id: z.string(),
|
|
262
|
+
name: z.string()
|
|
263
|
+
});
|
|
264
|
+
const CustomTableListOutputSchema = z.array(CustomTableListItemSchema);
|
|
265
|
+
const customTableCreateDataSchema = z.object({
|
|
266
|
+
id: z.uuid().optional(),
|
|
267
|
+
name: z.string().min(1)
|
|
268
|
+
}).strict();
|
|
269
|
+
const CustomTableCreateInputSchema = customTableCreateDataSchema;
|
|
270
|
+
const CustomTableCreateOutputSchema = z.object({ txid: z.number() });
|
|
271
|
+
const customTableUpdateDataSchema = z.object({ name: z.string().min(1).optional() }).strict();
|
|
272
|
+
const CustomTableUpdateInputSchema = customTableUpdateDataSchema.extend({ id: z.uuid() });
|
|
273
|
+
const CustomTableUpdateOutputSchema = z.object({ txid: z.number() });
|
|
274
|
+
const CustomTableDeleteInputSchema = z.object({ id: z.uuid() });
|
|
275
|
+
const CustomTableDeleteOutputSchema = z.object({ txid: z.number() });
|
|
276
|
+
const CustomTableGetInputSchema = z.object({ id: z.uuid() });
|
|
277
|
+
const CustomTableGetSchemaInputSchema = z.object({ id: z.uuid() });
|
|
108
278
|
const CustomTableGetOutputSchema = z.object({
|
|
109
279
|
id: z.string(),
|
|
110
280
|
userId: z.string(),
|
|
111
281
|
name: z.string(),
|
|
112
282
|
createdAt: z.coerce.date(),
|
|
113
283
|
updatedAt: z.coerce.date(),
|
|
114
|
-
columns: z.array(
|
|
115
|
-
rows: z.array(
|
|
116
|
-
views: z.array(
|
|
284
|
+
columns: z.array(tableColumnSchema),
|
|
285
|
+
rows: z.array(tableRowSchema),
|
|
286
|
+
views: z.array(tableViewSchema)
|
|
117
287
|
});
|
|
118
288
|
const CustomTableGetSchemaOutputSchema = z.object({
|
|
119
289
|
id: z.string(),
|
|
120
290
|
name: z.string(),
|
|
121
291
|
updatedAt: z.coerce.date(),
|
|
122
|
-
columns: z.array(
|
|
292
|
+
columns: z.array(tableColumnSchema)
|
|
123
293
|
});
|
|
124
|
-
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region src/contracts/custom-table.ts
|
|
127
|
-
const customTableContract = {
|
|
128
|
-
list: oc.route({
|
|
129
|
-
method: "GET",
|
|
130
|
-
path: "/custom-tables",
|
|
131
|
-
summary: "List custom tables",
|
|
132
|
-
tags: ["Custom Tables"]
|
|
133
|
-
}).input(CustomTableListInputSchema).output(CustomTableListOutputSchema),
|
|
134
|
-
get: oc.route({
|
|
135
|
-
method: "GET",
|
|
136
|
-
path: "/custom-tables/{id}",
|
|
137
|
-
summary: "Get custom table with columns, rows, and views",
|
|
138
|
-
tags: ["Custom Tables"]
|
|
139
|
-
}).input(CustomTableGetInputSchema).output(CustomTableGetOutputSchema),
|
|
140
|
-
getSchema: oc.route({
|
|
141
|
-
method: "GET",
|
|
142
|
-
path: "/custom-tables/{id}/schema",
|
|
143
|
-
summary: "Get custom table schema",
|
|
144
|
-
tags: ["Custom Tables"]
|
|
145
|
-
}).input(CustomTableGetSchemaInputSchema).output(CustomTableGetSchemaOutputSchema),
|
|
146
|
-
create: oc.route({
|
|
147
|
-
method: "POST",
|
|
148
|
-
path: "/custom-tables",
|
|
149
|
-
summary: "Create custom table",
|
|
150
|
-
tags: ["Custom Tables"]
|
|
151
|
-
}).input(CustomTableCreateInputSchema).output(CustomTableCreateOutputSchema),
|
|
152
|
-
update: oc.route({
|
|
153
|
-
method: "PUT",
|
|
154
|
-
path: "/custom-tables/{id}",
|
|
155
|
-
summary: "Update custom table",
|
|
156
|
-
tags: ["Custom Tables"]
|
|
157
|
-
}).input(CustomTableUpdateInputSchema).output(CustomTableUpdateOutputSchema),
|
|
158
|
-
delete: oc.route({
|
|
159
|
-
method: "DELETE",
|
|
160
|
-
path: "/custom-tables/{id}",
|
|
161
|
-
summary: "Delete custom table",
|
|
162
|
-
tags: ["Custom Tables"]
|
|
163
|
-
}).input(CustomTableDeleteInputSchema).output(CustomTableDeleteOutputSchema)
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
//#endregion
|
|
167
|
-
//#region src/schemas/notebase-beta.ts
|
|
168
|
-
const NotebaseBetaStatusInputSchema = z.object({}).strict();
|
|
169
|
-
const NotebaseBetaStatusOutputSchema = z.object({ allowed: z.boolean() });
|
|
170
|
-
|
|
171
|
-
//#endregion
|
|
172
|
-
//#region src/contracts/notebase-beta.ts
|
|
173
|
-
const notebaseBetaContract = { status: oc.route({
|
|
174
|
-
method: "GET",
|
|
175
|
-
path: "/notebase-beta/status",
|
|
176
|
-
summary: "Get Notebase beta access status",
|
|
177
|
-
tags: ["Notebase Beta"]
|
|
178
|
-
}).input(NotebaseBetaStatusInputSchema).output(NotebaseBetaStatusOutputSchema) };
|
|
179
|
-
|
|
180
|
-
//#endregion
|
|
181
|
-
//#region src/schemas/row.ts
|
|
182
|
-
const RowAddInputSchema = z.object({
|
|
183
|
-
tableId: z.uuid(),
|
|
184
|
-
data: z.object({
|
|
185
|
-
id: z.uuid().optional(),
|
|
186
|
-
cells: z.record(z.string(), z.unknown()),
|
|
187
|
-
position: z.number().int().optional()
|
|
188
|
-
}).strict()
|
|
189
|
-
});
|
|
190
|
-
const RowAddOutputSchema = z.object({ txid: z.number() });
|
|
191
|
-
const RowUpdateInputSchema = z.object({
|
|
192
|
-
rowId: z.uuid(),
|
|
193
|
-
data: z.object({
|
|
194
|
-
cells: z.record(z.string(), z.unknown()).optional(),
|
|
195
|
-
position: z.number().int().optional()
|
|
196
|
-
}).strict()
|
|
197
|
-
});
|
|
198
|
-
const RowUpdateOutputSchema = z.object({
|
|
199
|
-
id: z.uuid(),
|
|
200
|
-
tableId: z.uuid(),
|
|
201
|
-
cells: z.record(z.string(), z.unknown()),
|
|
202
|
-
position: z.number().int().nullable(),
|
|
203
|
-
createdAt: z.date(),
|
|
204
|
-
updatedAt: z.date(),
|
|
205
|
-
txid: z.number()
|
|
206
|
-
});
|
|
207
|
-
const RowDeleteInputSchema = z.object({ rowId: z.uuid() });
|
|
208
|
-
const RowDeleteOutputSchema = z.object({ txid: z.number() });
|
|
209
|
-
|
|
210
|
-
//#endregion
|
|
211
|
-
//#region src/contracts/row.ts
|
|
212
|
-
const rowContract = {
|
|
213
|
-
add: oc.route({
|
|
214
|
-
method: "POST",
|
|
215
|
-
path: "/rows",
|
|
216
|
-
summary: "Add row to table",
|
|
217
|
-
tags: ["Rows"]
|
|
218
|
-
}).input(RowAddInputSchema).output(RowAddOutputSchema),
|
|
219
|
-
update: oc.route({
|
|
220
|
-
method: "PATCH",
|
|
221
|
-
path: "/rows/{rowId}",
|
|
222
|
-
summary: "Update row cells",
|
|
223
|
-
tags: ["Rows"]
|
|
224
|
-
}).input(RowUpdateInputSchema).output(RowUpdateOutputSchema),
|
|
225
|
-
delete: oc.route({
|
|
226
|
-
method: "DELETE",
|
|
227
|
-
path: "/rows/{rowId}",
|
|
228
|
-
summary: "Delete row",
|
|
229
|
-
tags: ["Rows"]
|
|
230
|
-
}).input(RowDeleteInputSchema).output(RowDeleteOutputSchema)
|
|
231
|
-
};
|
|
232
|
-
|
|
233
294
|
//#endregion
|
|
234
295
|
//#region src/index.ts
|
|
235
296
|
const contract = {
|
|
236
|
-
|
|
297
|
+
betaAccess: betaAccessContract,
|
|
298
|
+
customTable: {
|
|
299
|
+
list: notebaseProcedure.route({
|
|
300
|
+
method: "GET",
|
|
301
|
+
path: "/custom-tables",
|
|
302
|
+
summary: "List custom tables",
|
|
303
|
+
tags: ["Custom Tables"]
|
|
304
|
+
}).input(CustomTableListInputSchema).output(CustomTableListOutputSchema),
|
|
305
|
+
get: notebaseProcedure.errors(pickPublicErrorMap("TABLE_NOT_FOUND")).route({
|
|
306
|
+
method: "GET",
|
|
307
|
+
path: "/custom-tables/{id}",
|
|
308
|
+
summary: "Get custom table with columns, rows, and views",
|
|
309
|
+
tags: ["Custom Tables"]
|
|
310
|
+
}).input(CustomTableGetInputSchema).output(CustomTableGetOutputSchema),
|
|
311
|
+
getSchema: notebaseProcedure.errors(pickPublicErrorMap("TABLE_NOT_FOUND")).route({
|
|
312
|
+
method: "GET",
|
|
313
|
+
path: "/custom-tables/{id}/schema",
|
|
314
|
+
summary: "Get custom table schema",
|
|
315
|
+
tags: ["Custom Tables"]
|
|
316
|
+
}).input(CustomTableGetSchemaInputSchema).output(CustomTableGetSchemaOutputSchema),
|
|
317
|
+
create: notebaseProcedure.route({
|
|
318
|
+
method: "POST",
|
|
319
|
+
path: "/custom-tables",
|
|
320
|
+
summary: "Create custom table",
|
|
321
|
+
tags: ["Custom Tables"]
|
|
322
|
+
}).input(CustomTableCreateInputSchema).output(CustomTableCreateOutputSchema),
|
|
323
|
+
update: notebaseProcedure.errors(pickPublicErrorMap("TABLE_NOT_FOUND")).route({
|
|
324
|
+
method: "PUT",
|
|
325
|
+
path: "/custom-tables/{id}",
|
|
326
|
+
summary: "Update custom table",
|
|
327
|
+
tags: ["Custom Tables"]
|
|
328
|
+
}).input(CustomTableUpdateInputSchema).output(CustomTableUpdateOutputSchema),
|
|
329
|
+
delete: notebaseProcedure.errors(pickPublicErrorMap("TABLE_NOT_FOUND")).route({
|
|
330
|
+
method: "DELETE",
|
|
331
|
+
path: "/custom-tables/{id}",
|
|
332
|
+
summary: "Delete custom table",
|
|
333
|
+
tags: ["Custom Tables"]
|
|
334
|
+
}).input(CustomTableDeleteInputSchema).output(CustomTableDeleteOutputSchema)
|
|
335
|
+
},
|
|
237
336
|
column: columnContract,
|
|
238
|
-
row:
|
|
239
|
-
|
|
337
|
+
row: {
|
|
338
|
+
create: notebaseProcedure.errors(pickPublicErrorMap("TABLE_NOT_FOUND", "CELL_VALIDATION_FAILED", "CONCURRENT_POSITION_CONFLICT")).route({
|
|
339
|
+
method: "POST",
|
|
340
|
+
path: "/rows",
|
|
341
|
+
summary: "Create row",
|
|
342
|
+
tags: ["Rows"]
|
|
343
|
+
}).input(RowCreateInputSchema).output(RowCreateOutputSchema),
|
|
344
|
+
update: notebaseProcedure.errors(pickPublicErrorMap("ROW_NOT_FOUND", "CELL_VALIDATION_FAILED")).route({
|
|
345
|
+
method: "PATCH",
|
|
346
|
+
path: "/rows/{rowId}",
|
|
347
|
+
summary: "Update row cells",
|
|
348
|
+
tags: ["Rows"]
|
|
349
|
+
}).input(RowUpdateInputSchema).output(RowUpdateOutputSchema),
|
|
350
|
+
delete: notebaseProcedure.errors(pickPublicErrorMap("ROW_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
|
|
351
|
+
method: "DELETE",
|
|
352
|
+
path: "/rows/{rowId}",
|
|
353
|
+
summary: "Delete row",
|
|
354
|
+
tags: ["Rows"]
|
|
355
|
+
}).input(RowDeleteInputSchema).output(RowDeleteOutputSchema),
|
|
356
|
+
reorder: notebaseProcedure.errors(pickPublicErrorMap("TABLE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
|
|
357
|
+
method: "POST",
|
|
358
|
+
path: "/rows/reorder",
|
|
359
|
+
summary: "Reorder rows in a table",
|
|
360
|
+
tags: ["Rows"]
|
|
361
|
+
}).input(RowReorderInputSchema).output(RowReorderOutputSchema)
|
|
362
|
+
}
|
|
240
363
|
};
|
|
241
|
-
|
|
242
364
|
//#endregion
|
|
243
|
-
export {
|
|
365
|
+
export { BetaAccessStatusInputSchema, BetaAccessStatusOutputSchema, BetaFeatureKeySchema, CellValidationFailedDataSchema, CellValidationFailureDetailsSchema, CellValidationFailureReasonSchema, ColumnCreateInputSchema, ColumnCreateOutputSchema, ColumnDeleteInputSchema, ColumnDeleteOutputSchema, ColumnReorderInputSchema, ColumnReorderOutputSchema, ColumnUpdateInputSchema, ColumnUpdateOutputSchema, CustomTableCreateInputSchema, CustomTableCreateOutputSchema, CustomTableDeleteInputSchema, CustomTableDeleteOutputSchema, CustomTableGetInputSchema, CustomTableGetOutputSchema, CustomTableGetSchemaInputSchema, CustomTableGetSchemaOutputSchema, CustomTableListInputSchema, CustomTableListItemSchema, CustomTableListOutputSchema, CustomTableUpdateInputSchema, CustomTableUpdateOutputSchema, PUBLIC_APP_ERROR_DEFS, RowCreateInputSchema, RowCreateOutputSchema, RowDeleteInputSchema, RowDeleteOutputSchema, RowReorderInputSchema, RowReorderOutputSchema, RowUpdateInputSchema, RowUpdateOutputSchema, columnCreateDataSchema, columnUpdateDataSchema, columnWidthSchema, contract, customTableCreateDataSchema, customTableUpdateDataSchema, getPublicErrorDefinition, isPublicAppErrorCode, pickPublicErrorMap, rowCellsSchema, rowCreateDataSchema, rowUpdateDataSchema, tableColumnSchema, tableRowSchema, tableViewSchema, tableViewTypeSchema, viewConfigSchema, viewCreateDataSchema, viewFilterSchema, viewFiltersSchema, viewSortSchema, viewSortsSchema, viewUpdateDataSchema };
|
|
366
|
+
|
|
244
367
|
//# sourceMappingURL=index.js.map
|