-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.schema.json
372 lines (372 loc) · 12.4 KB
/
config.schema.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "JSON to Notion configuration schema",
"description": "Validates configuration input for the \"JSON to Notion\" script.",
"type": "object",
"additionalProperties": false,
"properties": {
"$schema": {
"description": "The JSON schema to use for the configuration file.",
"type": "string",
"default": "config.schema.json"
},
"notionIntegrationKey": {
"description": "The secret integration key for your Notion integration. Find it on your integration dashboard after creating a new integration on https://www.notion.so/my-integrations",
"type": "string",
"default": ""
},
"notionDatabaseId": {
"description": "The ID of the database you want to run the integration on. You can find the ID in the URL of your database, e.g. https://www.notion.so/myworkspace/your-database-id",
"type": "string",
"default": ""
},
"inputFile": {
"description": "The JSON file to import to Notion.",
"type": "string",
"default": "input.json",
"pattern": ".*.json"
},
"skipExisting": {
"description": "Whether to skip already existing entries in the database. If set to true, the script will only import entries that do not exist in the database yet.",
"type": "object",
"additionalProperties": false,
"default": {
"enabled": false,
"jsonKey": "keyInJSON",
"notionProperty": "ItemId",
"propertyType": "number"
},
"properties": {
"enabled": {
"description": "Whether to skip existing entries in the database.",
"type": "boolean",
"default": true
},
"jsonKey": {
"description": "The key in the JSON input that should be compared to the value of the \"notionProperty\".",
"type": "string",
"default": "keyInJSON"
},
"notionProperty": {
"description": "The name of the field in the Notion database that should be compared to the value of the \"jsonKey\".",
"type": "string",
"default": "ItemID"
},
"propertyType": {
"description": "The type of the property used for checking if an entry already exists in the database. Not all property types are supported.",
"type": "string",
"default": "rich_text",
"enum": [
"rich_text",
"title",
"number",
"select",
"url"
]
}
},
"required": [
"enabled",
"jsonKey",
"notionProperty",
"propertyType"
]
},
"missingInInputPolicy": {
"description": "Decide what to do with entries in the database that have the given notionProperty set, but do not exist in the input file (i.e., an updated dataset no longer contains this entry). If this key is omitted, no action is taken and such entries are ignored.",
"type": "object",
"additionalProperties": false,
"default": {
"policy": "noAction",
"jsonKey": "keyInJSON",
"notionProperty": "ItemId",
"propertyType": "number",
"alertedNotionProperty": "ItemName",
"alertedPropertyType": "title"
},
"properties": {
"policy": {
"description": "The action to take when an entry exists in the database whose notionProperty value does not exist in the input file.",
"type": "string",
"default": "noAction",
"oneOf": [
{
"const": "noAction",
"title": "Do nothing. Has the same behaviour as if the \"missingInInputPolicy\" key was omitted."
},
{
"const": "alert",
"title": "The given alertedNotionProperty of all entries that exist in the database but not in the input file will be logged to a file. If no alertedNotionProperty is given, the notionProperty is used."
},
{
"const": "remove",
"title": "All entries in the database that do not have a matching entry in the input file will be removed from the database, and the alertedNotionProperty is logged to a file. Please note that Notion only supports archiving pages using the API. You can restore such pages for a limited amount of time."
}
]
},
"jsonKey": {
"description": "The key in the JSON input that should be compared to the value of the \"notionProperty\".",
"type": "string",
"default": "keyInJSON"
},
"notionProperty": {
"description": "The name of the field in the Notion database that should be compared to the value of the \"jsonKey\".",
"type": "string",
"default": "ItemID"
},
"propertyType": {
"description": "The type of the property used for checking if an entry already exists in the database. Not all property types are supported.",
"type": "string",
"default": "rich_text",
"enum": [
"rich_text",
"title",
"number",
"select",
"url"
]
},
"alertedNotionProperty": {
"description": "The name of the field in the Notion database that should be used for logging objects missing in the input file.",
"type": "string",
"default": "ItemName"
},
"alertedPropertyType": {
"description": "The type of the property used for the logging. Not all property types are supported.",
"type": "string",
"default": "title",
"enum": [
"rich_text",
"title",
"number",
"select",
"url"
]
}
},
"dependentRequired": {
"alertedNotionProperty": ["alertedPropertyType"]
},
"required": [
"policy",
"jsonKey",
"notionProperty",
"propertyType"
]
},
"writeErroredObjectsToFile": {
"description": "Whether to write the input objects that failed to be imported to Notion to a file. This speeds up the process of cleaning up those errors and trying again.",
"type": "boolean",
"default": true
},
"propertyMappings": {
"description": "The mapping of JSON keys to Notion property names. If an existing JSON key is not mapped, it will be ignored.",
"type": "array",
"default": [
{
"jsonKey": "keyInJson",
"notionPropertyName": "keyInNotion",
"notionPropertyType": "rich_text",
"nestedObjectPolicy": {
"policy": "useNamedProperty",
"namedProperty": "nameOfNestedProperty"
}
}
],
"minItems": 1,
"items": {
"description": "A mapping of a JSON key to a Notion property name.",
"type": "object",
"additionalProperties": false,
"properties": {
"jsonKey": {
"description": "The JSON key to map to the Notion property.",
"type": "string",
"default": "keyInJson"
},
"notionPropertyName": {
"description": "The Notion property name to map to the JSON key.",
"type": "string",
"default": "keyInNotion"
},
"notionPropertyType": {
"description": "The type of the Notion property. Note: Not all property types are supported as of now. For \"multi_select\", the input string will be split along \",\" to create multiple entries. Combine this with the \"nestedObjectPolicy\" of \"concatenateProperties\".",
"type": "string",
"default": "rich_text",
"enum": [
"rich_text",
"number",
"select",
"multi_select",
"date",
"title",
"url",
"cover",
"icon"
]
},
"nestedObjectPolicy": {
"description": "The policy to use when the value of the specified JSON key contains another JSON object. This is useful when the JSON value is an object that contains multiple properties that should be mapped to a single Notion property.",
"type": "object",
"default": {
"policy": "useNamedProperty",
"namedProperty": "nameOfNestedProperty"
},
"additionalProperties": false,
"properties": {
"policy": {
"description": "The policy to use when the value of the specified JSON key contains another JSON object.",
"type": "string",
"default": "useNamedProperty",
"oneOf": [
{
"const": "useNamedProperty",
"title": "Use the value of the property with a specific name as defined by the \"namedProperty\" property in the configuration. If the value of this property is another object, the value of the first child property will be used."
},
{
"const": "concatenateProperties",
"title": "The values of all properties within the nested property will be concatenated into a single string, with \",\" as a delimiter. If the value of this property is another object, the value of the first child property will be used."
},
{
"const": "usePriorityList",
"title": "Try to use the value of the property with the highest priority as defined by the \"priorityList\" property in the configuration. If a property with the specified key does not exist, move to the property with the next highest priority. If no matching property is found, the value is interpreted as \"null\". If the value of the chosen property is another object, the value of the first child property will be used."
}
]
},
"namedProperty": {
"description": "The name of the property to use when the \"policy\" is set to \"useNamedProperty\".",
"type": "string",
"default": "namedProperty"
},
"priorityList": {
"description": "The prioritized list of properties to use when the \"policy\" is set to \"usePriorityList\". The script will use the value of the property with the highest priority.",
"type": "array",
"default": [
"highestPriorityProperty",
"secondHighestPriorityProperty"
],
"minItems": 1,
"uniqueItems": true
}
},
"if": {
"properties": {
"policy": {
"enum": [
"usePriorityList"
]
}
}
},
"then": {
"required": [
"priorityList"
]
},
"else": {
"if": {
"properties": {
"policy": {
"enum": [
"useNamedProperty"
]
}
}
},
"then": {
"required": [
"namedProperty"
]
}
}
},
"required": [
"jsonKey",
"notionPropertyName",
"notionPropertyType"
]
}
},
"required": [
"notionIntegrationKey",
"notionDatabaseId",
"inputFile",
"inputIsArray",
"propertyMappings"
]
},
"extraProperties": {
"description": "Extra properties to add to the Notion database. These properties will be added to every row in the database.",
"type": "array",
"default": [
{
"notionPropertyName": "Imported by",
"propertyValue": "Imported using JSON to Notion",
"notionPropertyType": "rich_text"
}
],
"items": {
"description": "The column name in Notion and the value that should be added.",
"type": "object",
"additionalProperties": false,
"properties": {
"notionPropertyName": {
"description": "The Notion property name to map to the JSON key.",
"type": "string",
"default": ""
},
"propertyValue": {
"description": "The value to add to the Notion property.",
"default": ""
},
"notionPropertyType": {
"description": "The type of the Notion property. Note: Not all property types are supported as of now. Unsupported types that may get supported later on: status, files, checkbox, email, phone number. If you would like one of these supported, please open an Issue on the project's Github page.",
"type": "string",
"default": "text",
"oneOf": [
{
"const": "rich_text",
"title": "Default text property. Type string."
},
{
"const": "number",
"title": "A simple number. Type number."
},
{
"const": "multi_select",
"title": "A multi-select property. The input must be an array with entries of the form {\"name\": \"WhatIWantToEnter\"}. Type array."
},
{
"const": "select",
"title": "A select property. Type string."
},
{
"const": "date",
"title": "A date. Only start times are supported as of now, and due to Notion's requirements, the date must be in valid ISO 8601 format. Type string."
},
{
"const": "title",
"title": "The title property of the field. Type string."
},
{
"const": "url",
"title": "A URL. Type string."
}
]
}
}
},
"required": [
"notionPropertyName",
"propertyValue",
"notionPropertyType"
]
}
},
"required": [
"notionIntegrationKey",
"notionDatabaseId",
"inputFile",
"propertyMappings"
]
}