notionary 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
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.
- notionary/__init__.py +14 -2
- notionary/blocks/enums.py +27 -6
- notionary/blocks/schemas.py +32 -78
- notionary/comments/client.py +6 -9
- notionary/comments/schemas.py +2 -29
- notionary/data_source/http/data_source_instance_client.py +4 -4
- notionary/data_source/properties/schemas.py +128 -107
- notionary/data_source/query/__init__.py +9 -0
- notionary/data_source/query/builder.py +12 -3
- notionary/data_source/query/schema.py +5 -0
- notionary/data_source/schemas.py +2 -2
- notionary/data_source/service.py +43 -132
- notionary/database/schemas.py +2 -2
- notionary/database/service.py +19 -63
- notionary/exceptions/__init__.py +10 -2
- notionary/exceptions/api.py +2 -2
- notionary/exceptions/base.py +1 -1
- notionary/exceptions/block_parsing.py +24 -3
- notionary/exceptions/data_source/builder.py +2 -2
- notionary/exceptions/data_source/properties.py +3 -3
- notionary/exceptions/file_upload.py +67 -0
- notionary/exceptions/properties.py +4 -4
- notionary/exceptions/search.py +4 -4
- notionary/file_upload/__init__.py +4 -0
- notionary/file_upload/client.py +124 -210
- notionary/file_upload/config/__init__.py +17 -0
- notionary/file_upload/config/config.py +32 -0
- notionary/file_upload/config/constants.py +16 -0
- notionary/file_upload/file/reader.py +28 -0
- notionary/file_upload/query/__init__.py +7 -0
- notionary/file_upload/query/builder.py +54 -0
- notionary/file_upload/query/models.py +37 -0
- notionary/file_upload/schemas.py +78 -0
- notionary/file_upload/service.py +152 -289
- notionary/file_upload/validation/factory.py +64 -0
- notionary/file_upload/validation/impl/file_name_length.py +23 -0
- notionary/file_upload/validation/models.py +124 -0
- notionary/file_upload/validation/port.py +7 -0
- notionary/file_upload/validation/service.py +17 -0
- notionary/file_upload/validation/validators/__init__.py +11 -0
- notionary/file_upload/validation/validators/file_exists.py +15 -0
- notionary/file_upload/validation/validators/file_extension.py +122 -0
- notionary/file_upload/validation/validators/file_name_length.py +21 -0
- notionary/file_upload/validation/validators/upload_limit.py +31 -0
- notionary/http/client.py +7 -23
- notionary/page/content/factory.py +2 -0
- notionary/page/content/parser/factory.py +8 -5
- notionary/page/content/parser/parsers/audio.py +8 -33
- notionary/page/content/parser/parsers/embed.py +0 -2
- notionary/page/content/parser/parsers/file.py +8 -35
- notionary/page/content/parser/parsers/file_like_block.py +89 -0
- notionary/page/content/parser/parsers/image.py +8 -35
- notionary/page/content/parser/parsers/pdf.py +8 -35
- notionary/page/content/parser/parsers/video.py +8 -35
- notionary/page/content/parser/pre_processsing/handlers/__init__.py +2 -0
- notionary/page/content/parser/pre_processsing/handlers/column_syntax.py +12 -8
- notionary/page/content/parser/pre_processsing/handlers/indentation.py +2 -0
- notionary/page/content/parser/pre_processsing/handlers/video_syntax.py +66 -0
- notionary/page/content/parser/pre_processsing/handlers/whitespace.py +2 -0
- notionary/page/content/renderer/renderers/audio.py +9 -21
- notionary/page/content/renderer/renderers/file.py +9 -21
- notionary/page/content/renderer/renderers/file_like_block.py +43 -0
- notionary/page/content/renderer/renderers/image.py +9 -21
- notionary/page/content/renderer/renderers/pdf.py +9 -21
- notionary/page/content/renderer/renderers/video.py +9 -21
- notionary/page/content/syntax/__init__.py +2 -1
- notionary/page/content/syntax/registry.py +38 -60
- notionary/page/properties/client.py +3 -3
- notionary/page/properties/{models.py → schemas.py} +93 -107
- notionary/page/properties/service.py +15 -4
- notionary/page/schemas.py +3 -3
- notionary/page/service.py +18 -79
- notionary/shared/entity/dto_parsers.py +1 -36
- notionary/shared/entity/entity_metadata_update_client.py +18 -4
- notionary/shared/entity/schemas.py +6 -6
- notionary/shared/entity/service.py +121 -40
- notionary/shared/models/file.py +34 -6
- notionary/shared/models/icon.py +5 -12
- notionary/user/bot.py +12 -12
- notionary/utils/decorators.py +8 -8
- notionary/utils/pagination.py +36 -32
- notionary/workspace/__init__.py +2 -2
- notionary/workspace/client.py +2 -0
- notionary/workspace/query/__init__.py +3 -2
- notionary/workspace/query/builder.py +25 -1
- notionary/workspace/query/models.py +9 -1
- notionary/workspace/query/service.py +15 -11
- notionary/workspace/service.py +46 -36
- {notionary-0.3.0.dist-info → notionary-0.4.0.dist-info}/METADATA +9 -5
- {notionary-0.3.0.dist-info → notionary-0.4.0.dist-info}/RECORD +92 -71
- notionary/file_upload/models.py +0 -69
- notionary/page/page_context.py +0 -50
- notionary/shared/models/cover.py +0 -20
- {notionary-0.3.0.dist-info → notionary-0.4.0.dist-info}/WHEEL +0 -0
- {notionary-0.3.0.dist-info → notionary-0.4.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import Literal, TypeVar
|
|
3
3
|
|
|
4
|
-
from pydantic import BaseModel, Field
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
5
5
|
|
|
6
6
|
from notionary.shared.properties.type import PropertyType
|
|
7
7
|
from notionary.shared.typings import JsonDict
|
|
@@ -126,109 +126,11 @@ class DataSourceStatusGroup(BaseModel):
|
|
|
126
126
|
option_ids: list[str]
|
|
127
127
|
|
|
128
128
|
|
|
129
|
-
# ============================================================================
|
|
130
|
-
# Config Models
|
|
131
|
-
# ============================================================================
|
|
132
|
-
|
|
133
|
-
|
|
134
129
|
class DataSourceStatusConfig(BaseModel):
|
|
135
130
|
options: list[DataSourcePropertyOption] = Field(default_factory=list)
|
|
136
131
|
groups: list[DataSourceStatusGroup] = Field(default_factory=list)
|
|
137
132
|
|
|
138
133
|
|
|
139
|
-
class DataSourceSelectConfig(BaseModel):
|
|
140
|
-
options: list[DataSourcePropertyOption] = Field(default_factory=list)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
class DataSourceMultiSelectConfig(BaseModel):
|
|
144
|
-
options: list[DataSourcePropertyOption] = Field(default_factory=list)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
class DataSourceRelationConfig(BaseModel):
|
|
148
|
-
data_source_id: str
|
|
149
|
-
type: RelationType = RelationType.SINGLE_PROPERTY
|
|
150
|
-
single_property: JsonDict = Field(default_factory=dict)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
class DataSourceNumberConfig(BaseModel):
|
|
154
|
-
format: NumberFormat
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
class DataSourceFormulaConfig(BaseModel):
|
|
158
|
-
expression: str
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
class DataSourceUniqueIdConfig(BaseModel):
|
|
162
|
-
prefix: str | None = None
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
class DataSourceRollupConfig(BaseModel):
|
|
166
|
-
function: RollupFunction
|
|
167
|
-
relation_property_id: str
|
|
168
|
-
relation_property_name: str
|
|
169
|
-
rollup_property_id: str
|
|
170
|
-
rollup_property_name: str
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
class DataSourceDateConfig(BaseModel): ...
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
class DataSourceCreatedTimeConfig(BaseModel): ...
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
class DataSourceCreatedByConfig(BaseModel): ...
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
class DataSourceLastEditedTimeConfig(BaseModel): ...
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
class DataSourceLastEditedByConfig(BaseModel): ...
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
class DataSourceLastVisitedTimeConfig(BaseModel): ...
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
class DataSourceTitleConfig(BaseModel): ...
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
class DataSourceRichTextConfig(BaseModel): ...
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
class DataSourceURLConfig(BaseModel): ...
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
class DataSourcePeopleConfig(BaseModel): ...
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
class DataSourceCheckboxConfig(BaseModel): ...
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
class DataSourceEmailConfig(BaseModel): ...
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
class DataSourcePhoneNumberConfig(BaseModel): ...
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
class DataSourceFilesConfig(BaseModel): ...
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
class DataSourceButtonConfig(BaseModel): ...
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
class DataSourceLocationConfig(BaseModel): ...
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
class DataSourceVerificationConfig(BaseModel): ...
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
class DataSourcePlaceConfig(BaseModel): ...
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
# ============================================================================
|
|
228
|
-
# Property Models
|
|
229
|
-
# ============================================================================
|
|
230
|
-
|
|
231
|
-
|
|
232
134
|
class DataSourceStatusProperty(DataSourceProperty):
|
|
233
135
|
type: Literal[PropertyType.STATUS] = PropertyType.STATUS
|
|
234
136
|
status: DataSourceStatusConfig = Field(default_factory=DataSourceStatusConfig)
|
|
@@ -242,6 +144,10 @@ class DataSourceStatusProperty(DataSourceProperty):
|
|
|
242
144
|
return [group.name for group in self.status.groups]
|
|
243
145
|
|
|
244
146
|
|
|
147
|
+
class DataSourceSelectConfig(BaseModel):
|
|
148
|
+
options: list[DataSourcePropertyOption] = Field(default_factory=list)
|
|
149
|
+
|
|
150
|
+
|
|
245
151
|
class DataSourceSelectProperty(DataSourceProperty):
|
|
246
152
|
type: Literal[PropertyType.SELECT] = PropertyType.SELECT
|
|
247
153
|
select: DataSourceSelectConfig = Field(default_factory=DataSourceSelectConfig)
|
|
@@ -251,6 +157,10 @@ class DataSourceSelectProperty(DataSourceProperty):
|
|
|
251
157
|
return [option.name for option in self.select.options]
|
|
252
158
|
|
|
253
159
|
|
|
160
|
+
class DataSourceMultiSelectConfig(BaseModel):
|
|
161
|
+
options: list[DataSourcePropertyOption] = Field(default_factory=list)
|
|
162
|
+
|
|
163
|
+
|
|
254
164
|
class DataSourceMultiSelectProperty(DataSourceProperty):
|
|
255
165
|
type: Literal[PropertyType.MULTI_SELECT] = PropertyType.MULTI_SELECT
|
|
256
166
|
multi_select: DataSourceMultiSelectConfig = Field(default_factory=DataSourceMultiSelectConfig)
|
|
@@ -260,6 +170,13 @@ class DataSourceMultiSelectProperty(DataSourceProperty):
|
|
|
260
170
|
return [option.name for option in self.multi_select.options]
|
|
261
171
|
|
|
262
172
|
|
|
173
|
+
# https://developers.notion.com/reference/property-object
|
|
174
|
+
class DataSourceRelationConfig(BaseModel):
|
|
175
|
+
data_source_id: str | None = None
|
|
176
|
+
type: RelationType = RelationType.SINGLE_PROPERTY
|
|
177
|
+
single_property: JsonDict = Field(default_factory=dict)
|
|
178
|
+
|
|
179
|
+
|
|
263
180
|
class DataSourceRelationProperty(DataSourceProperty):
|
|
264
181
|
type: Literal[PropertyType.RELATION] = PropertyType.RELATION
|
|
265
182
|
relation: DataSourceRelationConfig = Field(default_factory=DataSourceRelationConfig)
|
|
@@ -269,51 +186,90 @@ class DataSourceRelationProperty(DataSourceProperty):
|
|
|
269
186
|
return self.relation.data_source_id
|
|
270
187
|
|
|
271
188
|
|
|
189
|
+
class DataSourceDateConfig(BaseModel): ...
|
|
190
|
+
|
|
191
|
+
|
|
272
192
|
class DataSourceDateProperty(DataSourceProperty):
|
|
273
193
|
type: Literal[PropertyType.DATE] = PropertyType.DATE
|
|
274
194
|
date: DataSourceDateConfig = Field(default_factory=DataSourceDateConfig)
|
|
275
195
|
|
|
276
196
|
|
|
197
|
+
class DataSourceCreatedTimeConfig(BaseModel): ...
|
|
198
|
+
|
|
199
|
+
|
|
277
200
|
class DataSourceCreatedTimeProperty(DataSourceProperty):
|
|
278
201
|
type: Literal[PropertyType.CREATED_TIME] = PropertyType.CREATED_TIME
|
|
279
202
|
created_time: DataSourceCreatedTimeConfig = Field(default_factory=DataSourceCreatedTimeConfig)
|
|
280
203
|
|
|
281
204
|
|
|
205
|
+
class DataSourceCreatedByConfig(BaseModel): ...
|
|
206
|
+
|
|
207
|
+
|
|
282
208
|
class DataSourceCreatedByProperty(DataSourceProperty):
|
|
283
209
|
type: Literal[PropertyType.CREATED_BY] = PropertyType.CREATED_BY
|
|
284
210
|
created_by: DataSourceCreatedByConfig = Field(default_factory=DataSourceCreatedByConfig)
|
|
285
211
|
|
|
286
212
|
|
|
213
|
+
class DataSourceLastEditedTimeConfig(BaseModel): ...
|
|
214
|
+
|
|
215
|
+
|
|
287
216
|
class DataSourceLastEditedTimeProperty(DataSourceProperty):
|
|
288
217
|
type: Literal[PropertyType.LAST_EDITED_TIME] = PropertyType.LAST_EDITED_TIME
|
|
289
218
|
last_edited_time: DataSourceLastEditedTimeConfig = Field(default_factory=DataSourceLastEditedTimeConfig)
|
|
290
219
|
|
|
291
220
|
|
|
221
|
+
class DataSourceLastEditedByConfig(BaseModel): ...
|
|
222
|
+
|
|
223
|
+
|
|
292
224
|
class DataSourceLastEditedByProperty(DataSourceProperty):
|
|
293
225
|
type: Literal[PropertyType.LAST_EDITED_BY] = PropertyType.LAST_EDITED_BY
|
|
294
226
|
last_edited_by: DataSourceLastEditedByConfig = Field(default_factory=DataSourceLastEditedByConfig)
|
|
295
227
|
|
|
296
228
|
|
|
229
|
+
class DataSourceLastVisitedTimeConfig(BaseModel): ...
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
class DataSourceLastVisitedTimeProperty(DataSourceProperty):
|
|
233
|
+
type: Literal[PropertyType.LAST_VISITED_TIME] = PropertyType.LAST_VISITED_TIME
|
|
234
|
+
last_visited_time: DataSourceLastVisitedTimeConfig = Field(default_factory=DataSourceLastVisitedTimeConfig)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
class DataSourceTitleConfig(BaseModel): ...
|
|
238
|
+
|
|
239
|
+
|
|
297
240
|
class DataSourceTitleProperty(DataSourceProperty):
|
|
298
241
|
type: Literal[PropertyType.TITLE] = PropertyType.TITLE
|
|
299
242
|
title: DataSourceTitleConfig = Field(default_factory=DataSourceTitleConfig)
|
|
300
243
|
|
|
301
244
|
|
|
245
|
+
class DataSourceRichTextConfig(BaseModel): ...
|
|
246
|
+
|
|
247
|
+
|
|
302
248
|
class DataSourceRichTextProperty(DataSourceProperty):
|
|
303
249
|
type: Literal[PropertyType.RICH_TEXT] = PropertyType.RICH_TEXT
|
|
304
250
|
rich_text: DataSourceRichTextConfig = Field(default_factory=DataSourceRichTextConfig)
|
|
305
251
|
|
|
306
252
|
|
|
253
|
+
class DataSourceURLConfig(BaseModel): ...
|
|
254
|
+
|
|
255
|
+
|
|
307
256
|
class DataSourceURLProperty(DataSourceProperty):
|
|
308
257
|
type: Literal[PropertyType.URL] = PropertyType.URL
|
|
309
258
|
url: DataSourceURLConfig = Field(default_factory=DataSourceURLConfig)
|
|
310
259
|
|
|
311
260
|
|
|
261
|
+
class DataSourcePeopleConfig(BaseModel): ...
|
|
262
|
+
|
|
263
|
+
|
|
312
264
|
class DataSourcePeopleProperty(DataSourceProperty):
|
|
313
265
|
type: Literal[PropertyType.PEOPLE] = PropertyType.PEOPLE
|
|
314
266
|
people: DataSourcePeopleConfig = Field(default_factory=DataSourcePeopleConfig)
|
|
315
267
|
|
|
316
268
|
|
|
269
|
+
class DataSourceNumberConfig(BaseModel):
|
|
270
|
+
format: NumberFormat
|
|
271
|
+
|
|
272
|
+
|
|
317
273
|
class DataSourceNumberProperty(DataSourceProperty):
|
|
318
274
|
type: Literal[PropertyType.NUMBER] = PropertyType.NUMBER
|
|
319
275
|
number: DataSourceNumberConfig
|
|
@@ -323,26 +279,42 @@ class DataSourceNumberProperty(DataSourceProperty):
|
|
|
323
279
|
return self.number.format
|
|
324
280
|
|
|
325
281
|
|
|
282
|
+
class DataSourceCheckboxConfig(BaseModel): ...
|
|
283
|
+
|
|
284
|
+
|
|
326
285
|
class DataSourceCheckboxProperty(DataSourceProperty):
|
|
327
286
|
type: Literal[PropertyType.CHECKBOX] = PropertyType.CHECKBOX
|
|
328
287
|
checkbox: DataSourceCheckboxConfig = Field(default_factory=DataSourceCheckboxConfig)
|
|
329
288
|
|
|
330
289
|
|
|
290
|
+
class DataSourceEmailConfig(BaseModel): ...
|
|
291
|
+
|
|
292
|
+
|
|
331
293
|
class DataSourceEmailProperty(DataSourceProperty):
|
|
332
294
|
type: Literal[PropertyType.EMAIL] = PropertyType.EMAIL
|
|
333
295
|
email: DataSourceEmailConfig = Field(default_factory=DataSourceEmailConfig)
|
|
334
296
|
|
|
335
297
|
|
|
298
|
+
class DataSourcePhoneNumberConfig(BaseModel): ...
|
|
299
|
+
|
|
300
|
+
|
|
336
301
|
class DataSourcePhoneNumberProperty(DataSourceProperty):
|
|
337
302
|
type: Literal[PropertyType.PHONE_NUMBER] = PropertyType.PHONE_NUMBER
|
|
338
303
|
phone_number: DataSourcePhoneNumberConfig = Field(default_factory=DataSourcePhoneNumberConfig)
|
|
339
304
|
|
|
340
305
|
|
|
306
|
+
class DataSourceFilesConfig(BaseModel): ...
|
|
307
|
+
|
|
308
|
+
|
|
341
309
|
class DataSourceFilesProperty(DataSourceProperty):
|
|
342
310
|
type: Literal[PropertyType.FILES] = PropertyType.FILES
|
|
343
311
|
files: DataSourceFilesConfig = Field(default_factory=DataSourceFilesConfig)
|
|
344
312
|
|
|
345
313
|
|
|
314
|
+
class DataSourceFormulaConfig(BaseModel):
|
|
315
|
+
expression: str
|
|
316
|
+
|
|
317
|
+
|
|
346
318
|
class DataSourceFormulaProperty(DataSourceProperty):
|
|
347
319
|
type: Literal[PropertyType.FORMULA] = PropertyType.FORMULA
|
|
348
320
|
formula: DataSourceFormulaConfig
|
|
@@ -352,6 +324,14 @@ class DataSourceFormulaProperty(DataSourceProperty):
|
|
|
352
324
|
return self.formula.expression
|
|
353
325
|
|
|
354
326
|
|
|
327
|
+
class DataSourceRollupConfig(BaseModel):
|
|
328
|
+
function: RollupFunction
|
|
329
|
+
relation_property_id: str
|
|
330
|
+
relation_property_name: str
|
|
331
|
+
rollup_property_id: str
|
|
332
|
+
rollup_property_name: str
|
|
333
|
+
|
|
334
|
+
|
|
355
335
|
class DataSourceRollupProperty(DataSourceProperty):
|
|
356
336
|
type: Literal[PropertyType.ROLLUP] = PropertyType.ROLLUP
|
|
357
337
|
rollup: DataSourceRollupConfig
|
|
@@ -361,6 +341,10 @@ class DataSourceRollupProperty(DataSourceProperty):
|
|
|
361
341
|
return self.rollup.function
|
|
362
342
|
|
|
363
343
|
|
|
344
|
+
class DataSourceUniqueIdConfig(BaseModel):
|
|
345
|
+
prefix: str | None = None
|
|
346
|
+
|
|
347
|
+
|
|
364
348
|
class DataSourceUniqueIdProperty(DataSourceProperty):
|
|
365
349
|
type: Literal[PropertyType.UNIQUE_ID] = PropertyType.UNIQUE_ID
|
|
366
350
|
unique_id: DataSourceUniqueIdConfig = Field(default_factory=DataSourceUniqueIdConfig)
|
|
@@ -370,11 +354,43 @@ class DataSourceUniqueIdProperty(DataSourceProperty):
|
|
|
370
354
|
return self.unique_id.prefix
|
|
371
355
|
|
|
372
356
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
357
|
+
class DataSourceButtonConfig(BaseModel): ...
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
class DataSourceButtonProperty(DataSourceProperty):
|
|
361
|
+
type: Literal[PropertyType.BUTTON] = PropertyType.BUTTON
|
|
362
|
+
button: DataSourceButtonConfig = Field(default_factory=DataSourceButtonConfig)
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
class DataSourceLocationConfig(BaseModel): ...
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
class DataSourceLocationProperty(DataSourceProperty):
|
|
369
|
+
type: Literal[PropertyType.LOCATION] = PropertyType.LOCATION
|
|
370
|
+
location: DataSourceLocationConfig = Field(default_factory=DataSourceLocationConfig)
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
class DataSourcePlaceConfig(BaseModel): ...
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
class DataSourcePlaceProperty(DataSourceProperty):
|
|
377
|
+
type: Literal[PropertyType.PLACE] = PropertyType.PLACE
|
|
378
|
+
place: DataSourcePlaceConfig = Field(default_factory=DataSourcePlaceConfig)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
class DataSourceVerificationConfig(BaseModel): ...
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
class DataSourceVerificationProperty(DataSourceProperty):
|
|
385
|
+
type: Literal[PropertyType.VERIFICATION] = PropertyType.VERIFICATION
|
|
386
|
+
verification: DataSourceVerificationConfig = Field(default_factory=DataSourceVerificationConfig)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
class DataSourceUnknownProperty(BaseModel):
|
|
390
|
+
model_config = ConfigDict(extra="allow")
|
|
391
|
+
|
|
376
392
|
|
|
377
|
-
|
|
393
|
+
type AnyDataSourceProperty = (
|
|
378
394
|
DataSourceStatusProperty
|
|
379
395
|
| DataSourceSelectProperty
|
|
380
396
|
| DataSourceMultiSelectProperty
|
|
@@ -384,6 +400,7 @@ DiscriminatedDataSourceProperty = Annotated[
|
|
|
384
400
|
| DataSourceCreatedByProperty
|
|
385
401
|
| DataSourceLastEditedTimeProperty
|
|
386
402
|
| DataSourceLastEditedByProperty
|
|
403
|
+
| DataSourceLastVisitedTimeProperty
|
|
387
404
|
| DataSourceTitleProperty
|
|
388
405
|
| DataSourceRichTextProperty
|
|
389
406
|
| DataSourceURLProperty
|
|
@@ -395,8 +412,12 @@ DiscriminatedDataSourceProperty = Annotated[
|
|
|
395
412
|
| DataSourceFilesProperty
|
|
396
413
|
| DataSourceFormulaProperty
|
|
397
414
|
| DataSourceRollupProperty
|
|
398
|
-
| DataSourceUniqueIdProperty
|
|
399
|
-
|
|
400
|
-
|
|
415
|
+
| DataSourceUniqueIdProperty
|
|
416
|
+
| DataSourceButtonProperty
|
|
417
|
+
| DataSourceLocationProperty
|
|
418
|
+
| DataSourcePlaceProperty
|
|
419
|
+
| DataSourceVerificationProperty
|
|
420
|
+
| DataSourceUnknownProperty
|
|
421
|
+
)
|
|
401
422
|
|
|
402
423
|
DataSourcePropertyT = TypeVar("DataSourcePropertyT", bound=DataSourceProperty)
|
|
@@ -46,6 +46,7 @@ class DataSourceQueryBuilder:
|
|
|
46
46
|
self._negate_next = False
|
|
47
47
|
self._or_group: list[FilterCondition] | None = None
|
|
48
48
|
self._page_size: int | None = None
|
|
49
|
+
self._total_results_limit: int | None = None
|
|
49
50
|
|
|
50
51
|
def where(self, property_name: str) -> Self:
|
|
51
52
|
self._finalize_current_or_group()
|
|
@@ -193,9 +194,15 @@ class DataSourceQueryBuilder:
|
|
|
193
194
|
self._sorts.append(sort)
|
|
194
195
|
return self
|
|
195
196
|
|
|
196
|
-
def
|
|
197
|
-
if
|
|
197
|
+
def total_results_limit(self, total_result_limit: int) -> Self:
|
|
198
|
+
if total_result_limit < 1:
|
|
198
199
|
raise ValueError("Limit must be at least 1")
|
|
200
|
+
self._total_results_limit = total_result_limit
|
|
201
|
+
return self
|
|
202
|
+
|
|
203
|
+
def page_size(self, page_size: int) -> Self:
|
|
204
|
+
if page_size < 1:
|
|
205
|
+
raise ValueError("Page size must be at least 1")
|
|
199
206
|
self._page_size = page_size
|
|
200
207
|
return self
|
|
201
208
|
|
|
@@ -203,7 +210,9 @@ class DataSourceQueryBuilder:
|
|
|
203
210
|
self._finalize_current_or_group()
|
|
204
211
|
notion_filter = self._create_notion_filter_if_needed()
|
|
205
212
|
sorts = self._create_sorts_if_needed()
|
|
206
|
-
return DataSourceQueryParams(
|
|
213
|
+
return DataSourceQueryParams(
|
|
214
|
+
filter=notion_filter, sorts=sorts, page_size=self._page_size, total_results_limit=self._total_results_limit
|
|
215
|
+
)
|
|
207
216
|
|
|
208
217
|
def _select_property_without_negation(self, property_name: str) -> None:
|
|
209
218
|
self._current_property = property_name
|
|
@@ -289,6 +289,8 @@ class DataSourceQueryParams(BaseModel):
|
|
|
289
289
|
sorts: list[NotionSort] | None = None
|
|
290
290
|
page_size: int | None = None
|
|
291
291
|
|
|
292
|
+
total_results_limit: int | None = None
|
|
293
|
+
|
|
292
294
|
@model_serializer
|
|
293
295
|
def to_api_params(self) -> JsonDict:
|
|
294
296
|
result: JsonDict = {}
|
|
@@ -299,4 +301,7 @@ class DataSourceQueryParams(BaseModel):
|
|
|
299
301
|
if self.sorts is not None and len(self.sorts) > 0:
|
|
300
302
|
result["sorts"] = [sort.model_dump() for sort in self.sorts]
|
|
301
303
|
|
|
304
|
+
if self.page_size is not None:
|
|
305
|
+
result["page_size"] = self.page_size
|
|
306
|
+
|
|
302
307
|
return result
|
notionary/data_source/schemas.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from pydantic import BaseModel
|
|
2
2
|
|
|
3
3
|
from notionary.blocks.rich_text.models import RichText
|
|
4
|
-
from notionary.data_source.properties.schemas import
|
|
4
|
+
from notionary.data_source.properties.schemas import AnyDataSourceProperty
|
|
5
5
|
from notionary.page.schemas import NotionPageDto
|
|
6
6
|
from notionary.shared.entity.schemas import EntityResponseDto, NotionEntityUpdateDto
|
|
7
7
|
from notionary.shared.models.parent import Parent
|
|
@@ -24,4 +24,4 @@ class DataSourceDto(EntityResponseDto):
|
|
|
24
24
|
title: list[RichText]
|
|
25
25
|
description: list[RichText]
|
|
26
26
|
archived: bool
|
|
27
|
-
properties: dict[str,
|
|
27
|
+
properties: dict[str, AnyDataSourceProperty]
|