@@ -2,11 +2,6 @@ import type { Thunk } from "@contentlayer/utils"
2
2
import type { QueryDatabaseParameters } from "@notionhq/client/build/src/api-endpoints"
3
3
4
4
export type DatabaseFieldTypeDefBase = {
5
- /**
6
- * When required, pages without this property defined will not be generated.
7
- */
8
- isRequired ?: boolean ,
9
-
10
5
/**
11
6
* Map this property to a specific key.
12
7
* Defaults to the property name.
@@ -17,25 +12,49 @@ export type DatabaseFieldTypeDefBase = {
17
12
* Field description used to generate comments.
18
13
*/
19
14
description ?: string ;
20
- } & ( { id : string } | { label : string } )
15
+
16
+ /**
17
+ * When required, pages without this property defined will not be generated.
18
+ */
19
+ isRequired ?: boolean ,
20
+ } & ( { id : string } | { name : string } )
21
21
22
22
export type DatabaseRelationFieldTypeDef = DatabaseFieldTypeDefBase & {
23
+ /**
24
+ * Type of the property to configure it.
25
+ */
23
26
type : 'relation' ,
24
- // TODO : Not used yet
25
- relation : DatabaseType ,
26
- single ?: boolean ,
27
- }
28
27
29
- export type DatabaseRollupFieldTypeDef = DatabaseFieldTypeDefBase & {
30
- type : 'rollup' ,
31
- relation : DatabaseType ,
28
+ /**
29
+ * Database related to this relation.
30
+ *
31
+ * TODO : Will be used for Rollup properties.
32
+ */
33
+ relation ?: DatabaseType ,
34
+
35
+ /**
36
+ * If true, the property will be of type `string` instead of type `string[]`
37
+ * and only the first item will be taken.
38
+ */
39
+ single ?: boolean ,
32
40
}
33
41
34
- export type DatabaseFieldTypeDef = DatabaseFieldTypeDefBase | DatabaseRollupFieldTypeDef | DatabaseRelationFieldTypeDef
42
+ export type DatabaseFieldTypeDef = DatabaseFieldTypeDefBase | DatabaseRelationFieldTypeDef
35
43
36
44
export type DatabaseTypeDef < Flattened extends boolean = true , DefName extends string = string > = {
45
+ /**
46
+ * The database name.
47
+ */
37
48
name : DefName ,
49
+
50
+ /**
51
+ * The database description used to generate comments.
52
+ */
38
53
description ?: string ,
54
+
55
+ /**
56
+ * The database ID used as the content source.
57
+ */
39
58
databaseId : string ,
40
59
41
60
/**
@@ -56,6 +75,10 @@ export type DatabaseTypeDef<Flattened extends boolean = true, DefName extends st
56
75
*/
57
76
query ?: Omit < QueryDatabaseParameters , 'database_id' | 'filter_properties' | 'start_cursor' | 'page_size' >
58
77
78
+ /**
79
+ * The fields configuration, usefull to remap keys and configure complex properties.
80
+ * Not required as the properties types are already inferred.
81
+ */
59
82
fields ?: Flattened extends false ? Record < string , DatabaseFieldTypeDef > | DatabaseFieldTypeDef [ ] : DatabaseFieldTypeDef [ ]
60
83
}
61
84
0 commit comments